Commit graph

278 commits

Author SHA1 Message Date
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