Commit graph

482 commits

Author SHA1 Message Date
Matthias Krüger
3d9b3a8575 remove more redundant clones (clippy::redundant_clone()) 2021-03-21 12:10:39 +01:00
cynecx
42abfa0f88 hir_ty: add coverage testing for autoderef_visibility_method test 2021-03-20 20:35:57 +01:00
cynecx
2dc85f739a hir_ty: fix test by removing trailing whitespace 2021-03-20 19:58:00 +01:00
cynecx
ac2a831b2e hir_ty: iterate_method_candidates_for_self_ty pass visible_from_module down to iterate_inherent_methods 2021-03-20 19:50:55 +01:00
cynecx
66d295d72d hir_ty: fix visibility in infer_inherent_method test 2021-03-20 19:47:14 +01:00
cynecx
34bb13e293 hir_ty: introduce visible_from_module param into method resolution 2021-03-20 19:28:26 +01:00
cynecx
b1b456c642 hir_ty: check field visibility while iterating through autoderef candidates 2021-03-20 19:07:23 +01:00
cynecx
30980396af hir_ty: add field_visibilities and fn_visibility queries 2021-03-20 18:29:30 +01:00
cynecx
edfd741c5b hir_ty: add tests around autoderef with visibility checking 2021-03-20 17:26:18 +01:00
cynecx
15e4aae823 hir_ty: fix tests by making required methods public 2021-03-20 17:12:49 +01:00
Florian Diebold
7ec3b66f7a Turn Obligation into something similar to chalk_ir::DomainGoal
This includes starting to make use of Chalk's `Cast` trait.
2021-03-20 12:47:12 +01:00
Florian Diebold
8e7e405f6a Remove WhereClause::Error
Chalk doesn't have it, and judging from the removed code, it wasn't
useful anyway.
2021-03-20 10:51:00 +01:00
Florian Diebold
7a5fb37cf1 Rename GenericPredicate -> WhereClause 2021-03-20 10:46:36 +01:00
Lukas Wirth
8996b1a235 Replace Projection variant in GenericPredicate with AliasEq 2021-03-19 12:12:18 +01:00
Florian Diebold
7a7e47eab7 Chalkify TraitRef 2021-03-18 21:53:19 +01:00
Jonas Schievink
ebd4c8c5df Fix infinite recursion when computing diagnostics for inner items 2021-03-18 20:15:06 +01:00
bors[bot]
d3da042a62
Merge #8082
8082: Proper handle inner recursive macro rules cases r=edwin0cheng a=edwin0cheng

Fixes #7645

cc @jonas-schievink 

bors r+

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2021-03-18 12:25:44 +00:00
Edwin Cheng
13f30e9ef5 Handle inner recursive macro rules cases 2021-03-18 20:19:15 +08:00
Jonas Schievink
94b3b32c98 Support #[cfg] on all associated items 2021-03-18 01:28:55 +01:00
Jonas Schievink
a85b32abdc Add test for self-calling inner function 2021-03-17 22:30:09 +01:00
Jonas Schievink
9436436d20 Improve test 2021-03-17 18:35:17 +01:00
Jonas Schievink
6356ea24dd Add test for #[cfg] on function params 2021-03-17 18:28:27 +01:00
Jonas Schievink
cb530e7c97 Handle #[cfg] on call arguments 2021-03-17 15:10:46 +01:00
Matthias Krüger
966c23f529 avoid converting types into themselves via .into() (clippy::useless-conversion)
example: let x: String = String::from("hello world").into();
2021-03-17 01:27:56 +01:00
Florian Diebold
ce2cae45b5 Rename Substs -> Substitution 2021-03-16 17:58:17 +01:00
bors[bot]
1a82af3527
Merge #7900 #8000
7900: show function params in completion detail r=matklad a=JoshMcguigan

This resolves #7842 by updating the detail for function completions from `-> T` to `fn(T, U) -> V`. I added an expicit unit test for this, `ide_completion::render::fn_detail_includes_args_and_return_type`, which passes.

Lots of other unit tests fail (~60 of them) due to this change, although I believe the failures are purely cosmetic (they were testing the exact format of this output). I'm happy to go update those tests, but before I do that I'd like to make sure this is in fact the format we want for the detail?

edit - I realized `UPDATE_EXPECT=1 cargo test` automatically updates `expect!` tests. Big 👍 to whoever worked on that! So I'll go ahead and update all these tests soon. But I still would like to confirm `fn(T, U) -> V` is the desired content in the `detail` field. 

8000: Use hir formatter for hover text r=matklad a=oxalica

Fix #2765 , (should) fix #4665

Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
Co-authored-by: oxalica <oxalicc@pm.me>
2021-03-16 08:05:24 +00:00
Edwin Cheng
8e07b23b84 Fix macro expansion for statements w/o semicolon 2021-03-16 13:44:50 +08:00
Florian Diebold
455e755bb0 Use SmallVec for Substs
Doesn't help as much as I hoped, but it helps a bit and I also did some
refactorings that were necessary anyway.
2021-03-15 19:48:03 +01:00
Florian Diebold
287e9a870c Fix unification logic 2021-03-15 19:14:10 +01:00
oxalica
87171238c6
Use hir formatter more 2021-03-16 01:04:33 +08:00
oxalica
ef416e0154
Impl HirDisplay for function hover message 2021-03-16 01:04:20 +08:00
oxalica
2bb8956a10
Introduce FunctionQualifier for hir::FunctionData 2021-03-16 01:03:07 +08:00
bors[bot]
5f6d71cf0c
Merge #8029
8029: Enable thread-local coverage marks r=JoshMcguigan a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-03-15 14:42:26 +00:00
bors[bot]
f2c39d0cdf
Merge #8020
8020: Power up goto_implementation r=matklad a=Veykril

by allowing it to be invoked on references of names, now showing all (trait)
implementations of the given type in all crates instead of just the defining
crate as well as including support for builtin types

![image](https://user-images.githubusercontent.com/3757771/111144403-52bb0700-8587-11eb-9205-7a2a5b8b75a3.png)
Example screenshot of `impl`s of Box in `log`, `alloc`, `std` and the current crate. Before you had to invoke it on the definition where it would only show the `impls` in `alloc`.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-15 14:08:26 +00:00
Laurențiu Nicola
88cee24c6c Enable thread-local coverage marks 2021-03-15 16:02:50 +02:00
bors[bot]
6139bd7649
Merge #8018
8018: Make Ty wrap TyKind in an Arc r=flodiebold a=flodiebold

... to further move towards Chalk.

This is a bit of a slowdown (218ginstr vs 213ginstr for inference on RA), even though it allows us to unwrap the Substs in `TyKind::Ref` etc..

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2021-03-15 12:51:27 +00:00
Lukas Wirth
6241567948 Speedup trait impl search for goto_implementation 2021-03-15 13:49:21 +01:00
Aleksey Kladov
f7156cb0ae Simplify source maps for fields 2021-03-15 15:38:50 +03:00
Florian Diebold
42217738e0 Don't use Substs for Ref/Raw/Array/Slice 2021-03-14 20:21:05 +01:00
Florian Diebold
af466f8542 Make Ty wrap TyKind in an Arc
... like it will be in Chalk. We still keep `interned_mut` and
`into_inner` methods that will probably not exist with Chalk.

This worsens performance slightly (5ginstr inference on RA), but doesn't
include other simplifications we can do yet.
2021-03-14 17:31:08 +01:00
Florian Diebold
1954147834 More renaming 2021-03-14 16:33:27 +01:00
Florian Diebold
eea777c714 Use chalk_ir::FnSig 2021-03-14 16:30:43 +01:00
Florian Diebold
3411fe3e84 Rename some fields to their Chalk names 2021-03-14 16:30:43 +01:00
Florian Diebold
3743ede404 Move type lowering methods to TyLoweringContext 2021-03-13 22:44:36 +01:00
Florian Diebold
c82d1823a1 Create TraitEnvironment through a query 2021-03-13 20:38:45 +01:00
Florian Diebold
b035c314b4 Use chalk_ir::OpaqueTyId 2021-03-13 20:05:47 +01:00
Florian Diebold
1bf6b7360c Use chalk_ir::PlaceholderIndex 2021-03-13 19:47:34 +01:00
Florian Diebold
2d69eb131f Use chalk_ir::ClosureId 2021-03-13 19:27:09 +01:00
Florian Diebold
9719ce9fc7 Use chalk_ir::FnDefId 2021-03-13 17:56:48 +01:00
Florian Diebold
19664e276a Use chalk_ir::AssocTypeId 2021-03-13 17:56:48 +01:00
Florian Diebold
dfafcd926a Use chalk_ir::ForeignDefId 2021-03-13 17:56:48 +01:00
Florian Diebold
6c32bbf3ca Separate Ty and TyKind like in Chalk
Currently `Ty` just wraps `TyKind`, but this allows us to change most
places to already use `intern` / `interned`.
2021-03-13 16:17:15 +01:00
Jonas Schievink
8447f101ac Remove ItemTree::source
`HasSource` should be used instead
2021-03-12 23:54:29 +01:00
Florian Diebold
784636f1c1 Simplify a bit 2021-03-12 20:51:29 +01:00
Florian Diebold
ec70387a4c Use Chalk Environment more directly 2021-03-12 19:12:17 +01:00
Jonas Schievink
c2622c9228 Prefer names from outer DefMap over extern prelude 2021-03-10 16:33:18 +01:00
Aleksey Kladov
842d8ad9c8 Compilation speed 2021-03-09 22:30:58 +03:00
Jonas Schievink
b885e6bdee Delete ContainerId 2021-03-09 19:09:02 +01:00
Jonas Schievink
a430549aa6 Stop using ContainerId in AssocContainerId 2021-03-09 18:27:23 +01:00
Jonas Schievink
12f6bdcfd9 Check ancestor maps when computing traits in scope 2021-03-09 18:27:23 +01:00
Jonas Schievink
1da0a27626 Use body.block_scopes in hir_ty tests 2021-03-09 18:27:23 +01:00
Jonas Schievink
0cb46a9e8d Use body.block_scopes to validate inner items 2021-03-09 18:27:23 +01:00
Laurențiu Nicola
fc9eed4836 Use upstream cov-mark 2021-03-08 22:19:44 +02:00
kjeremy
e13ac349b5 Cargo update
Chalk changes just a version # bump. There are no actual commits.
2021-03-08 10:39:11 -05:00
Laurențiu Nicola
d3ca22876c Make two calls virtual 2021-03-05 20:25:24 +02:00
Lukas Wirth
50e01d2bc7 Use chalk_ir::AdtId 2021-03-04 19:38:02 +01:00
bors[bot]
a6ee8e9e76
Merge #7829 #7833
7829: Bump deps r=matklad a=lnicola

Unfortunately, this brings a bunch of proc macros dep because `cargo-metadata` went full-in on `derive-builder`. I'm not sure what we can do here..

7833: Use chalk_ir::Mutability r=Veykril a=Veykril



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-03-01 19:31:01 +00:00
Lukas Wirth
7072f59fc6 Use chalk_ir::Mutability 2021-03-01 19:57:36 +01:00
Laurențiu Nicola
63e8bdb8a2 Bump chalk 2021-03-01 18:17:03 +02:00
Lukas Wirth
5d121cdb45 Introduce Ty::Alias 2021-03-01 14:24:00 +01:00
Lukas Wirth
4b7fc69315 Assert index relationship between type_variable_table and var_unification_table 2021-03-01 13:54:17 +01:00
Lukas Wirth
11a1f13cd1 Being Ty::InferenceVar closes to chalk equivalent 2021-03-01 12:41:29 +01:00
bors[bot]
5df3ee8274
Merge #7816
7816: Lift Ty::Fn into a struct r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-02-28 22:54:07 +00:00
Lukas Wirth
407196b8c0 Lift FnPointer into a struct 2021-02-28 23:53:21 +01:00
cynecx
2cdd1ff1b5 hir_ty: use default type generic for box expressions 2021-02-28 21:18:30 +01:00
Lukas Wirth
a3fd2faba5 Remove Substs from Ty::ForeignType 2021-02-28 20:44:09 +01:00
Lukas Wirth
0e995adcf6 Turn Ty::Tuple variant into a tuple-variant 2021-02-28 20:39:43 +01:00
Lukas Wirth
faf2dd49e4 Fix code_model::Type::walk not walking all types 2021-02-28 20:15:56 +01:00
Lukas Wirth
a3f5491a1a Inline TypeCtor into Ty 2021-02-28 19:13:37 +01:00
Lukas Wirth
7c2dd85a32 Use chalk_ir::Scalar directly 2021-02-28 11:06:37 +01:00
Lukas Wirth
5183c9f083 Introduce TypeCtor::Scalar 2021-02-28 01:20:04 +01:00
Laurențiu Nicola
d03cfe141c Add test from #7273 2021-02-21 19:22:14 +02:00
Laurențiu Nicola
48ae948b22 Bump deps 2021-02-21 19:13:11 +02:00
Lukas Wirth
0799288f01 Don't write trailing whitespace when formatting empty GenericPredicates 2021-02-20 20:43:04 +01:00
Lukas Wirth
9e5192d917 Don't lower TypeBound::Lifetime as GenericPredicate::Error 2021-02-20 19:08:20 +01:00
Laurențiu Nicola
c1d37f030f Add test 2021-02-20 12:43:52 +02:00
Jonas Schievink
216dc856c5 Wrap BuiltinType in code model 2021-02-11 19:52:33 +01:00
Jonas Schievink
925c51aef3 Add test for #1165
Closes #1165
2021-02-10 18:42:35 +01:00
Jonas Schievink
2382dce2d3 Slightly expand test 2021-02-10 17:37:15 +01:00
Jonas Schievink
3c5734712a Add more tests 2021-02-10 15:59:20 +01:00
Jonas Schievink
a00fa0c06f Put the old resolver back 2021-02-10 15:12:45 +01:00
Jonas Schievink
244d8e37f1 Update fixed tests 2021-02-10 14:48:52 +01:00
Jonas Schievink
e837df8479 infer: update resolver when descending into block 2021-02-10 14:41:54 +01:00
Aleksey Kladov
4b1279d0b1 Infra for "unit" benchmarking 2021-02-09 20:25:39 +03:00
bors[bot]
876c4519e3
Merge #7602
7602: Check for dyn impls in method resolution r=flodiebold a=Veykril

Fixes #6777

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-02-08 18:22:35 +00:00
Lukas Wirth
965d31ce5b Check for dyn impls in method resolution 2021-02-08 19:13:54 +01:00
kjeremy
0c3b38695a Update crates
Pulls in https://github.com/rust-lang/chalk/pull/682
2021-02-08 11:38:51 -05:00
bors[bot]
737e7a7b75
Merge #7574
7574: Remove various redundant clones r=kjeremy a=yoshuawuyts

I noticed when running clippy through RA that there are a few instances where `clone` is called where it's not actually needed. I figured a small patch to remove these might be welcome here.

Thanks!

Co-authored-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
2021-02-05 16:04:50 +00:00
Yoshua Wuyts
79d103d5b4 Remove redundant clones 2021-02-05 16:57:26 +01:00
bors[bot]
855b00cbe6
Merge #7570 #7571
7570: Add doc gen to the `generate_enum_match_method` assist r=yoshuawuyts a=yoshuawuyts

Implements a small extension to https://github.com/rust-analyzer/rust-analyzer/pull/7562, generating default comments. I wasn't sure if this would fit the goals of Rust-Analyzer, so I chose to split it into a separate PR. This is especially useful when writing code in a codebase which uses `#![warn(missing_docs)]` lint, as many production-grade libraries do.

The comments we're generating here are similar to the ones found on [`Option::is_some`](https://doc.rust-lang.org/std/option/enum.Option.html#method.is_some) and [`Result::is_err`](https://doc.rust-lang.org/std/result/enum.Result.html#method.is_err). I briefly considered only generating these for `pub` types, but they seem small and unobtrusive enough that they're probably useful in the general case. Thanks!

## Example

__input__
```rust
pub(crate) enum Variant {
    Undefined,
    Minor, // cursor here
    Major,
}
```

__output__
```rust
pub(crate) enum Variant {
    Undefined,
    Minor,
    Major,
}

impl Variant {
    /// Returns `true` if the variant is [`Minor`].
    pub(crate) fn is_minor(&self) -> bool {
        matches!(self, Self::Minor)
    }
}
```

## Future Directions

This opens up the path to adding an assist for generating these comments on existing `is_` methods. This would make it both easy to document new code, and update existing code with documentation.

7571: Cleanup decl_check r=Veykril a=Veykril

bors r+

Co-authored-by: Yoshua Wuyts <yoshuawuyts@gmail.com>
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-02-05 15:17:41 +00:00
Lukas Wirth
eeb5bfcfab Cleanup decl_check 2021-02-05 16:09:45 +01:00
Lukas Wirth
486c7175fe Remove unnecessary allocs in case_conv 2021-02-05 15:02:39 +01:00
Jonas Schievink
5d99ba1d9a Make ModPath's representation private 2021-02-04 20:49:24 +01:00
Jonas Schievink
b7be2b1d3c Use block_def_map in body lowering 2021-02-03 14:21:15 +01:00
Laurențiu Nicola
9c4b799dce Bump chalk 2021-02-02 17:40:01 +02:00
Jonas Schievink
7202ce6c96
Revert "Use block_def_map in body lowering" 2021-02-02 11:46:58 +01:00
Jonas Schievink
9cc7d57429 Use block_def_map in body lowering 2021-02-01 13:33:18 +01:00
Lukas Wirth
426ad8e165 Classify function calls as functions when shadowed by types 2021-01-28 19:08:55 +01:00
Laurențiu Nicola
efafcf2428 Bump deps 2021-01-27 14:22:19 +02:00
Jonas Schievink
5c241b0766 Create all ModuleIds through a DefMap method
`ModuleId` needs to be able to represent blocks, and only the
associated `DefMap` will know how to construct that `ModuleId`
2021-01-25 15:21:33 +01:00
Phil Ellison
65a5ea581d Update tests to register the required standard library types 2021-01-23 07:40:25 +00:00
Phil Ellison
7c691f51f9 Fix test names 2021-01-23 07:40:25 +00:00
Phil Ellison
8c7ccdc29d Identify methods using functions ids rather than string names 2021-01-23 07:40:25 +00:00
Phil Ellison
1ff860b93c Implement fix, add tests 2021-01-23 07:40:25 +00:00
Phil Ellison
1316422a7c Add diagnostic for filter_map followed by next 2021-01-23 07:40:24 +00:00
Jonas Schievink
3de8f57c51 Make ModuleId's krate field private 2021-01-22 18:09:55 +01:00
Jonas Schievink
ce29730bc7 Obtain ModuleId's DefMap through a method 2021-01-22 16:33:58 +01:00
bors[bot]
c050e972a3
Merge #7386
7386: Handle box with allocator r=flodiebold a=tweksteen

In 1.49.0, the definition of Box was modified to support an optional
Allocator[1]. Adapt the parsing of the `box` keyword to supply the
expected number of parameters to the constructor.

[1] f288cd2e17

Fixes: #6956 


Co-authored-by: Thiébaud Weksteen <tweek@google.com>
2021-01-22 13:14:40 +00:00
Thiébaud Weksteen
be0691b02b Handle box with allocator
In 1.49.0, the definition of Box was modified to support an optional
Allocator[1]. Adapt the parsing of the `box` keyword to supply the
expected number of parameters to the constructor.

[1] f288cd2e17
2021-01-22 13:50:23 +01:00
Laurențiu Nicola
e42dfd7a40 Bump chalk 2021-01-21 10:29:19 +02:00
kjeremy
1e0b163860 chalk 0.49.0 2021-01-20 12:31:03 -05:00
Jonas Schievink
0587b99fde Make public DefMap fields private 2021-01-20 15:41:18 +01:00
Jonas Schievink
57a82fb05b Rename CrateDefMap to DefMap 2021-01-18 20:18:05 +01:00
bors[bot]
9daba961f2
Merge #7291
7291: Wrap remaining self/super/crate in Name{Ref} r=matklad a=Veykril

That should be the remaining special casing for `self` 🎉 

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-01-18 16:13:06 +00:00
Aleksey Kladov
1c8feac01f ⬆️ arena 2021-01-17 11:43:04 +03:00
bors[bot]
3224ecea87
Merge #7276
7276: Remove map module from la-arena public API r=lnicola a=arzg

It’s unlikely that more items will be added to the module, so it’s simpler for users if `ArenaMap` is re-exported and the module made private.

This doesn’t compile for the same reason that #7275 doesn’t:

> This pull request doesn’t compile because dependencies on la-arena go through crates.io, so existing dependencies on the crate are referencing an old version. As such, this PR will only compile once a new la-arena version has been published.

Co-authored-by: Aramis Razzaghipour <aramisnoah@gmail.com>
2021-01-17 07:20:36 +00:00
bors[bot]
f5f011ba71
Merge #7304
7304: Depend on local copy of la-arena instead of crates.io’s r=lnicola a=arzg

This addresses [this comment](https://github.com/rust-analyzer/rust-analyzer/pull/7276#issuecomment-760909936). #7275 and #7276 should start compiling if this is merged.

Co-authored-by: Aramis Razzaghipour <aramisnoah@gmail.com>
2021-01-17 07:05:44 +00:00
Aramis Razzaghipour
709034d123
Depend on local copy of la-arena instead of crates.io’s 2021-01-17 17:52:57 +11:00
Lukas Wirth
98718e0544 Wrap remaining self/super/crate in Name{Ref} 2021-01-15 22:18:43 +01:00
Daiki Ihara
85cd3524e2 Add support for yiled keyword 2021-01-15 23:35:17 +09:00
Aramis Razzaghipour
9b5ba090db
Remove map module from la-arena public API
It’s unlikely that more items will be added to the module,
so it’s simpler for users if `ArenaMap` is re-exported
and the module made private.
2021-01-15 11:14:04 +11:00
Aleksey Kladov
4c4e54ac8a prepare to publish el libro de arena 2021-01-14 19:06:02 +03:00
Lukas Wirth
3d6480bc31 Render Fn* trait objects and impl types as rust does 2021-01-13 13:29:47 +01:00
Vincent Esche
c8c2bd097a Fixed typos in local bindings 2021-01-09 15:41:29 +01:00
Vincent Esche
21f8239ac8 Fixed typos in code comments 2021-01-09 15:41:29 +01:00
bors[bot]
1a29934c37
Merge #7145
7145: Proper handling $crate Take 2 [DO NOT MERGE] r=edwin0cheng a=edwin0cheng

Similar to previous PR (#7133) , but improved the following things :

1. Instead of storing the whole `ExpansionInfo`, we store a similar but stripped version `HygieneInfo`.
2. Instread of storing the `SyntaxNode` (because every token we are interested are IDENT), we store the `TextRange` only.
3. Because of 2, we now can put it in Salsa.
4. And most important improvement: Instead of computing the whole frames every single time, we compute it recursively through salsa: (Such that in the best scenario, we only need to compute the first layer of frame)

```rust
        let def_site = db.hygiene_frame(info.def.file_id);
        let call_site = db.hygiene_frame(info.arg.file_id);

        HygieneFrame { expansion: Some(info), local_inner, krate, call_site, def_site }
```

The overall speed compared to previous PR is much faster (65s vs 45s) :
```
[WITH old PR]
Database loaded 644.86ms, 284mi
Crates in this dir: 36
Total modules found: 576
Total declarations: 11153
Total functions: 8715
Item Collection: 15.78s, 91562mi
Total expressions: 240721
Expressions of unknown type: 2635 (1%)
Expressions of partially unknown type: 2064 (0%)
Type mismatches: 865
Inference: 49.84s, 250747mi
Total: 65.62s, 342310mi
rust-analyzer -q analysis-stats .  66.72s user 0.57s system 99% cpu 1:07.40 total

[WITH this PR]
Database loaded 665.83ms, 284mi
Crates in this dir: 36
Total modules found: 577
Total declarations: 11188
Total functions: 8743
Item Collection: 15.28s, 84919mi
Total expressions: 241229
Expressions of unknown type: 2637 (1%)
Expressions of partially unknown type: 2064 (0%)
Type mismatches: 868
Inference: 30.15s, 135293mi
Total: 45.43s, 220213mi   
rust-analyzer -q analysis-stats .  46.26s user 0.74s system 99% cpu 47.294 total
```

*HOWEVER*,  it is still a perf regression (35s vs 45s):
```
[WITHOUT this PR]
Database loaded 657.42ms, 284mi
Crates in this dir: 36
Total modules found: 577
Total declarations: 11177
Total functions: 8735
Item Collection: 12.87s, 72407mi
Total expressions: 239380
Expressions of unknown type: 2643 (1%)
Expressions of partially unknown type: 2064 (0%)
Type mismatches: 868
Inference: 22.88s, 97889mi
Total: 35.74s, 170297mi
rust-analyzer -q analysis-stats .  36.71s user 0.63s system 99% cpu 37.498 total
```



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2021-01-08 03:57:11 +00:00
Phil Ellison
554ee6ea02 cargo fmt 2021-01-07 19:01:33 +00:00
Phil Ellison
b2dbe6e43a Add fix to wrap return expression in Some 2021-01-07 19:01:33 +00:00
Kevaundray Wedderburn
72b9a4fbd3 Change <|> to $0 - Rebase 2021-01-07 12:09:23 +00:00
Edwin Cheng
76f2b9d2ef Proper handling $crate Take 2 2021-01-07 13:08:32 +08:00
Aleksey Kladov
f9707cde68 Rename expr -> tail_expr 2021-01-05 15:51:13 +03:00
kjeremy
f2d1144b4a Update crates 2021-01-04 11:12:42 -05:00
Lukas Wirth
47900dd3bc Impl hovering for TypeParams 2021-01-04 12:24:47 +01:00
Jesse Bakker
c7e0c7f43a Upgrade expect-test to 1.1 2021-01-03 14:43:29 +01:00
Jonas Schievink
85cc3cfec9
Revert "Proper handling $crate and local_inner_macros" 2021-01-03 11:47:57 +01:00
Edwin Cheng
26b9c793f1 Fixed nested eager macro bug 2021-01-03 17:56:59 +08:00
bors[bot]
a88d4f8c72
Merge #7133
7133: Proper handling $crate and local_inner_macros r=jonas-schievink a=edwin0cheng

This PR introduces `HygineFrames` to store the macro definition/call site hierarchy in hyginee and when resolving `local_inner_macros` and `$crate`, we use the token to look up the corresponding frame and return the correct value.

See also: https://rustc-dev-guide.rust-lang.org/macro-expansion.html#hygiene-and-hierarchies

fixe #6890 and  #6788

r? @jonas-schievink 

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2021-01-02 17:42:45 +00:00
bors[bot]
3b347eaa4e
Merge #7134
7134: Fix infer error of macro invocation in array expr r=edwin0cheng a=edwin0cheng

Fixed following infer error:

```rust
macro_rules! bar { () => {0u32} }
fn test() {
    let a = [bar!()];   // a : [unknown]
}
```

bors r+

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2021-01-02 14:16:26 +00:00
Edwin Cheng
63e330f402 Fix infer error of macro invocation in array expr 2021-01-02 22:06:59 +08:00
Edwin Cheng
fe5340d970 Introduce HygieneFrames for proper token hyginee 2021-01-02 20:39:57 +08:00
Florian Diebold
29acd39800 Don't emit arg count diagnostics for method calls with unknown receiver
Fixes #7098.
2021-01-01 20:49:18 +01:00
bors[bot]
0e5fe47153
Merge #7080
7080: Implement ConstParams for HIR r=Veykril a=Veykril

r? @flodiebold 

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-01-01 13:45:10 +00:00
Lukas Wirth
18bf2e5af5 Add ConstParams to the ide layer 2021-01-01 14:43:16 +01:00
Lukas Wirth
0acdb73076 Add ConstParams to the HIR 2021-01-01 10:06:42 +01:00
kjeremy
dc1396eec7 Update crates 2020-12-30 10:39:50 -05:00
Laurențiu Nicola
fbeccf0b9d Allow spurious warning from rust-lang/rust#80501 2020-12-30 11:37:52 +02:00
bors[bot]
06320015af
Merge #7021
7021: Track labels in the HIR r=matklad a=Veykril

Groundwork for #6966

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-24 12:04:28 +00:00
Lukas Wirth
262b9c3982 Track labels in the HIR 2020-12-24 12:49:40 +01:00
bors[bot]
a82c2445be
Merge #7020
7020: Implement const pat and expr inference r=flodiebold a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-23 19:50:04 +00:00
Lukas Wirth
a142beaf01 Implement const block inference 2020-12-23 12:24:24 +01:00
Lukas Wirth
0a780c0ab3 Implement const pat inference 2020-12-23 12:15:38 +01:00
Laurențiu Nicola
c04406287a Bump chalk 2020-12-23 12:58:23 +02:00
Lukas Wirth
fa65d6ba85 Higher-ranked trait bounds for where clauses 2020-12-17 22:01:42 +01:00
Jonas Schievink
6615fda695 decl_check: don't pass db around so often 2020-12-17 01:19:56 +01:00
Jonas Schievink
b238ddd21a Make macro def krate mandatory
Refactors builtin derive support to go through proper name resolution
2020-12-15 20:33:05 +01:00
Jonas Schievink
c1cb595382 Move to upstream macro_rules! model 2020-12-15 15:37:37 +01:00
Edwin Cheng
9da1eee436 Add regression test 2020-12-15 15:24:35 +08:00
Florian Diebold
4788aaa5f0 Add test for #6852 2020-12-13 14:53:04 +01:00
bors[bot]
ca3a54f0a4
Merge #6852
6852: Ignore lifetime params in substitutions r=matklad a=Veykril

[`hir_ty::utils::Generics`](https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/hir_ty/src/utils.rs#L153) currently only assumes type parameters but not lifetime parameters and therefor creates incorrect index and length calculations, this PR just makes the use sites ignore LifetimeGenerics for now.

This fixes the panic at least locally for me for `analysis-stats`. Funnily enough this panic prevented me from using reference search for the `args` field to fix this problem.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-13 11:34:43 +00:00
Lukas Wirth
ae8a802085 Ignore lifetime params in substitutions 2020-12-13 11:34:44 +01:00
bors[bot]
a15d19619e
Merge #6845
6845: Don't HirDisplay unknown types when displaying for source r=Veykril a=Veykril

Was wondering why the add missing impl assist didn't do anything here:
![Code_JCA1Qo0V9P](https://user-images.githubusercontent.com/3757771/101990300-7af44a80-3ca6-11eb-8431-e5eb4de4e78c.png)
Turns out me forgetting to set the Index::Idx type in the trait causes RA to panic due to it trying to to create an unparsable type in the `make` module.
Now we get this instead which imo is definitely better to have.
![Code_MUFPJUCULY](https://user-images.githubusercontent.com/3757771/101990347-c9094e00-3ca6-11eb-9c6a-146bddf64b7c.png)



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-12 18:06:36 +00:00
Lukas Wirth
69b78edb5e Don't HirDisplay unknown types when displaying for source 2020-12-12 19:05:00 +01:00
bors[bot]
479d1f7eec
Merge #6818
6818: Add Lifetimes to the HIR r=matklad a=Veykril

This doesn't handle resolve yet as I don't know yet how that will be used. I'll get to that once I start moving the lifetime reference PR to the hir.

This also adds a new `hir` name type for lifetimes and labels, `hir::LifetimeName`.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-12-12 14:35:38 +00:00
ivan770
f7f4f366ac
Added remove this semicolon test 2020-12-12 13:50:11 +02:00
Lukas Wirth
11f8664182 Add Lifetimes to the HIR 2020-12-12 00:56:52 +01:00
Lukas Wirth
378ec2841b Infer labeled blocks 2020-12-12 00:06:48 +01:00
bors[bot]
44978acf51
Merge #6769
6769: Add native "remove this semicolon" diagnostics r=matklad a=ivan770

Closes #6739 
![demo2](https://user-images.githubusercontent.com/14003886/101530533-b76c3180-399a-11eb-9d18-5c8457721655.gif)


Co-authored-by: ivan770 <leshenko.ivan770@gmail.com>
2020-12-10 16:18:49 +00:00
ivan770
bbb0bc7b04
Cast to ExprStmt, style fixes 2020-12-10 18:10:39 +02:00
Jonas Schievink
05d4a5a150 Use mark/hit 2020-12-10 15:56:04 +01:00
Jonas Schievink
d82292e1ce Ignore extern items in incorrect-case check 2020-12-10 15:45:01 +01:00
Jonas Schievink
dedd888570 Implement HirDisplay for FnSig
This could be useful for diagnostics, but isn't used right now
2020-12-09 18:06:56 +01:00
Aleksey Kladov
6e24321e45 Introduce anchored_path
They allow to represent paths like `#[path = "C:\path.rs"] mod foo;`
in a lossless cross-platform & network-transparent way.
2020-12-09 19:07:05 +03:00
ivan770
35006eba79 Apply rustfmt changes 2020-12-09 08:22:13 +00:00
ivan770
86c183716c
Apply suggestions from code review
Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2020-12-09 10:17:28 +02:00
ivan770
7738467e0a Format code 2020-12-08 19:25:21 +00:00
ivan770
581567a4c8
Remove use via super 2020-12-08 20:50:13 +02:00
ivan770
cb66bb8ff9
Remove this semicolon 2020-12-08 20:47:20 +02:00
Florian Diebold
78dd548243 Upgrade Chalk
Also make overflow depth and max type size configurable through env variables.
This can be helpful at least for debugging.

Fixes #6628.
2020-12-07 11:48:58 +01:00
Florian Diebold
e5fd550dfd Use correct, full substs for self type in impl
Without arbitrary self types, the self type could never refer to the method type
parameters, so this wasn't a problem; but with arbitrary self types, it can.

This fixes the crash from #6668; but it doesn't make method resolution work for
these methods.
2020-12-04 18:43:47 +01:00
Lukas Wirth
377fa7db3f Check structs for match exhaustiveness 2020-11-24 18:50:56 +01:00
Lukas Wirth
4d841dc4e7 Add middle ellipsis missing arm text 2020-11-24 16:46:06 +01:00
Lukas Wirth
a4b5275656 Handle ellipsis in tuple patterns in match exhaustiveness checking 2020-11-24 16:43:28 +01:00
Lukas Wirth
a5efefd3d7 Properly infer tuple struct patterns when encountering ellipsis 2020-11-24 16:11:40 +01:00
Lukas Wirth
35dd62e915 Properly infer tuple patterns when encountering ellipsis 2020-11-24 13:56:20 +01:00
Aleksey Kladov
731f7bfc02 Replace RacyFlag with OnceCell 2020-11-11 03:11:40 +01:00
Igor Aleksanov
dd2febf05a Improve decl_check module readability 2020-11-03 10:13:49 +03:00
Igor Aleksanov
9e172ffeb7 Remove numbers from comments in decl_check.rs 2020-11-03 10:11:02 +03:00
Igor Aleksanov
bdfe12df8f Check for allow(..) attributes for case diagnostic 2020-11-03 10:11:02 +03:00
kjeremy
0403e82d91 Bump chalk and lexer 2020-11-02 12:00:58 -05:00
Aleksey Kladov
ba8d6d1e4e Remove more unreachable pubs 2020-11-02 16:58:33 +01:00
Aleksey Kladov
b610118453 Deny unreachable-pub
It's very useful when `pub` is equivalent to "this is crate's public
API", let's enforce this!

Ideally, we should enforce it for local `cargo test`, and only during
CI, but that needs https://github.com/rust-lang/cargo/issues/5034.
2020-11-02 14:07:08 +01:00
Florian Diebold
bca51e3519 Upgrade Chalk to 0.36
Quite a few changes, because Chalk got rid of the `ApplicationTy` nesting.
2020-10-30 18:57:55 +01:00
Benjamin Coenen
7322a69cf6 refactor(hir_ty): do not override DisplayTarget in hir_fmt
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-10-28 17:58:16 +01:00
Benjamin Coenen
ec3638adb9 do not use associated types placeholder for inlay hint
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-10-28 15:42:51 +01:00
Benjamin Coenen
0aca7b78de do not use associated types placeholder for inlay hint
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-10-28 15:23:23 +01:00
Benjamin Coenen
ef2f7bb243 do not use associated types placeholder for inlay hint
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-10-28 14:07:12 +01:00
Benjamin Coenen
8762b797fd do not use associated types placeholder for inlay hint
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-10-28 11:20:05 +01:00
Benjamin Coenen
73161cc9cd do not use associated types placeholder for inlay hint #6191
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-10-27 20:23:09 +01:00
GrayJack
08e95a5dc1
Fix case where non FnOnce variables is marked callable 2020-10-26 15:20:33 -03:00
bors[bot]
29f5154d1c
Merge #6350
6350: Make IncorrectDiagnostic match rustc by copying rustc's code. r=popzxc a=ArifRoktim

This closes #6343 and closes #6345.

The old algorithm which used a `DetectedCase` enum, didn't match how rustc thinks of cases. Some inputs can be interpreted as more than 1 case depending on the situation. For example, to rustc:
- `ABCD`: Can be both camel case and upper snake case
- `X86_64`: Can be both camel case and upper snake case

I could've made `detect_case` return a collection of `DetectedCase` and then modified the other code as such, but I think using the same code rustc uses is simpler and a surefire way to achieve the same diagnostics as rustc.

Co-authored-by: Arif Roktim <arifrroktim@gmail.com>
2020-10-26 13:20:57 +00:00
Florian Diebold
39dfca23f1 Add tracing to main rust-analyzer binary 2020-10-25 13:53:38 +01:00
Florian Diebold
6b5f82bcea Get rid of FAKE_PLACEHOLDER
The lifetime placeholder can be replaced by the static lifetime, and for array
sizes we should just be using a concrete const.
2020-10-25 12:42:38 +01:00
Arif Roktim
afb2166aeb Make IncorrectDiagnostic match rustc by copying rustc's code. 2020-10-24 19:21:53 -04:00
Laurențiu Nicola
c81d044622 Bump chalk 2020-10-24 17:14:05 +03:00
Florian Diebold
baeb16e83f Improve Chalk debugging
- add panic context for the trait goal if CHALK_DEBUG is set
 - print the Chalk program even if we're panicking
 - log goal/solution while TLS is still set
2020-10-23 15:28:02 +02:00
bors[bot]
31db677a94
Merge #6319
6319: Properly identify camel cased acronyms as UpperCamelCase r=popzxc a=ArifRoktim

This closes #6305.

Co-authored-by: Arif Roktim <arifrroktim@gmail.com>
2020-10-22 14:24:10 +00:00
Arif Roktim
854b133181 Properly identify camel cased acronyms as UpperCamelCase 2020-10-21 17:10:22 -04:00
bors[bot]
9eb6cbb80b
Merge #6307
6307: Add whitelist of safe intrinsics r=frazar a=frazar

This PR should fix #5996, where intrinsic operations where all marked as unsafe.

I'm rather new to this codebase, so I might be doing something *very* wrong. Please forgive me!

In particular, I'm not sure how to "check that we are in extern `rust-intrinsics`" as mentioned [in this comment](https://github.com/rust-analyzer/rust-analyzer/issues/5996#issuecomment-709234802). 

Co-authored-by: Francesco Zardi <frazar@users.noreply.github.com>
2020-10-21 20:09:11 +00:00
Francesco Zardi
0be21b05d6 Move safe intrinsic tests 2020-10-21 21:53:05 +02:00
Igor Aleksanov
2a20e7795c Add descriptions for diagnostics parseable by xtask 2020-10-19 20:55:16 +03:00
Roland Ruckerbauer
0e9d1e17d6 binary operator overload type inference: add test mark 2020-10-14 19:00:04 +02:00
Roland Ruckerbauer
4e49b2f731 Implement binary operator overloading type inference 2020-10-13 20:48:08 +02:00
Igor Aleksanov
fb0ab9f745 Keep SyntaxNodePtr::range private 2020-10-12 11:05:00 +03:00
Igor Aleksanov
66cea8cbaa Replace 'if let' with 'match' in decl_check.rs 2020-10-12 11:05:00 +03:00
Igor Aleksanov
559cc97073 Add to_upper_snake_case function to stdx 2020-10-12 11:05:00 +03:00
Igor Aleksanov
ebd30033b3 Fix compilation error 2020-10-12 11:05:00 +03:00
Igor Aleksanov
f2c91fc5a8 Apply suggestions from code review
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2020-10-12 11:05:00 +03:00
Igor Aleksanov
9ea57cac0e Fix code style issues 2020-10-12 11:05:00 +03:00
Igor Aleksanov
2a72f876d6 Fix issues with match arm bindings 2020-10-12 11:05:00 +03:00
Igor Aleksanov
45ac2b2ede Code style adjustments 2020-10-12 11:05:00 +03:00
Igor Aleksanov
b42562b5de Make incorrect case diagnostic work inside of functions 2020-10-12 11:05:00 +03:00
Igor Aleksanov
9ec1741b65 Refactor string helpers for decl_check module 2020-10-12 11:05:00 +03:00
Igor Aleksanov
fb96bba878 Add diagnostics for enum names and variants 2020-10-12 11:05:00 +03:00
Igor Aleksanov
e24e22f288 Add fix for incorrect case diagnostic 2020-10-12 11:04:59 +03:00
Igor Aleksanov
17f1026c46 Improve string helpers functions 2020-10-12 10:59:54 +03:00
Igor Aleksanov
21dd704b6b Check structure fields to be snake_case 2020-10-12 10:59:54 +03:00
Igor Aleksanov
329626124f Add check for structure names to be CamelCase 2020-10-12 10:59:54 +03:00
Igor Aleksanov
1773c6d154 Extract helper functions into a separate module 2020-10-12 10:59:54 +03:00
Igor Aleksanov
f5cea35986 Add checks for function parameters 2020-10-12 10:59:54 +03:00
Igor Aleksanov
4039176ec6 Create basic support for names case checks and implement function name case check 2020-10-12 10:59:54 +03:00
kjeremy
a7d6674e4d Update crates 2020-10-11 18:01:50 -04:00
Casey Primozic
37df2138ec
Switch from git to latest tagged release of chalk deps 2020-10-07 12:11:22 -07:00
Casey Primozic
13bdadb515
Make unimplemented match variants explicit 2020-10-06 23:56:31 -07:00
Casey Primozic
f40e86e141
todo!() -> unimplemented!() // FIXME for CI 2020-10-06 15:19:34 -07:00
Casey Primozic
56a8a7645f
Bump chalk to use latest git to get fix
* Chalk very recently (like an hour ago) merged a fix that prevents rust analyzer from panicking.  This allows it to be usable again for code that hits those situations.  See #6134, #6145, Probably #6120
2020-10-06 15:05:20 -07:00
Lukas Wirth
643bbf15a2 Fix trait object hir formatting behind pointer and references 2020-10-06 14:40:27 +02:00
Nathan Whitaker
f50458deaf Update chalk to 0.30.0 2020-09-28 14:24:11 -04:00
Jeremy Kolb
76dfac7894 chalk 0.29.0 2020-09-28 07:44:27 -04:00
Bram van den Heuvel
dff6895ce8 Update chalk to 0.28.0 2020-09-25 15:29:31 +02:00
Jean SIMARD
875ad9b5c4
Bump smol_str from 0.1.16 to 0.1.17 2020-09-24 16:39:08 +02:00