Commit graph

11819 commits

Author SHA1 Message Date
Florian Diebold
d174b919dc Enable attribute macro expansion in analysis-stats
Before:
```
> $ rust-analyzer -q analysis-stats --with-proc-macro --load-output-dirs .
Database loaded:     19.08s, 277minstr
  crates: 34, mods: 688, decls: 13202, fns: 10412
Item Collection:     16.21s, 76ginstr
  exprs: 290580, ??ty: 2508 (0%), ?ty: 1814 (0%), !ty: 947
Inference:           27.46s, 108ginstr
Total:               43.67s, 184ginstr
```
After:
```
> $ ./target/release/rust-analyzer -q analysis-stats --with-proc-macro --load-output-dirs .
Database loaded:     1.09s, 277minstr
  crates: 34, mods: 688, decls: 14790, fns: 11006
Item Collection:     18.20s, 78ginstr
  exprs: 297826, ??ty: 493 (0%), ?ty: 558 (0%), !ty: 342
Inference:           28.34s, 111ginstr
Total:               46.54s, 190ginstr
```
2021-06-05 11:29:24 +02:00
Joshua Warner
ca9ffba047 Add assist for converting a tuple enum variant to a named variant 2021-06-04 21:48:32 -07:00
Lukas Wirth
544eca10d6 Complete third-party attributes 2021-06-04 21:07:19 +02:00
Lukas Wirth
7524850831 Render documentation for derive completion 2021-06-04 20:58:12 +02:00
Lukas Wirth
1bd04d9064 Don't inline mutable locals in 'inline_local_variable' 2021-06-04 20:43:48 +02:00
bors[bot]
98395f29a4
Merge #9138
9138: feat: Implement hover for lints r=Veykril a=Veykril

fixes https://github.com/rust-analyzer/rust-analyzer/issues/8857, fixes https://github.com/rust-analyzer/rust-analyzer/issues/3941

![URXBanNxYe](https://user-images.githubusercontent.com/3757771/120830905-4bd8da80-c55f-11eb-9f55-ff5a321726fa.gif)

We also generate the default lints(and lint groups 🎉) instead now by invoking `rustc -W help` and parsing the output from that.


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-04 17:45:37 +00:00
Lukas Wirth
0c89f38378 Replace - with _ in generated lint names 2021-06-04 19:10:52 +02:00
Lukas Wirth
0b9ba4977e Generate default lint groups 2021-06-04 18:55:08 +02:00
Lukas Wirth
343df88ac7 Generate default lint completions 2021-06-04 18:35:19 +02:00
Lukas Wirth
5d17b6a687 Implement hover for lints 2021-06-04 17:03:18 +02:00
bors[bot]
92d91050c4
Merge #9137
9137: fix: fix incorrect "unresolved import" error when using derive helpers r=jonas-schievink a=jonas-schievink

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/9133

cursed bug

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-06-04 14:51:39 +00:00
Jonas Schievink
20de86d014 Return ReachedFixedPoint::No when resolving derive helper 2021-06-04 16:50:35 +02:00
Lukas Wirth
07394316ff Add function references hover action 2021-06-04 15:54:55 +02:00
Lukas Wirth
5f1fac44c5 Cleanup parameter_hint_heuristics inlay hints test 2021-06-04 14:09:20 +02:00
Lukas Wirth
b0f6d8868c Reorganize inlay_hints tests 2021-06-04 13:47:39 +02:00
Jonas Schievink
17565f4dea Set enable_proc_attr_macros in hir_ty TestDB 2021-06-03 18:11:33 +02:00
Jonas Schievink
d1c4d28eed Update list of built-in attributes 2021-06-03 18:09:21 +02:00
Jonas Schievink
9fdb8f9037 Make it opt-in 2021-06-03 18:09:21 +02:00
Jonas Schievink
e5a2c6596d Expand procedural attribute macros 2021-06-03 18:09:21 +02:00
bors[bot]
7f9c4a59d9
Merge #9130
9130: Prefix/suffix parameter inlay hint hiding heuristic is more strict r=Veykril a=Veykril

Instead of just plainly checking prefix/suffix of the argument string to the parameter name we only check for prefixes and suffixes if they are split apart via an underscore meaning, with the argument `foo`, it will be hidden for the parameter name `foo_bar` but not for `foobar`.

bors r+
Closes https://github.com/rust-analyzer/rust-analyzer/issues/8878

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-03 14:26:07 +00:00
Lukas Wirth
cc762c30df Prefix/suffix parameter inlay hint hiding heuristic is more strict 2021-06-03 16:22:24 +02:00
Matthias Krüger
9452dfaac7 NFC: remove redundant clones (clippy::perf) 2021-06-03 15:32:46 +02:00
bors[bot]
23b48d377d
Merge #9127
9127: internal: make variant fields inherit the enum's visibility in the ItemTree r=jonas-schievink a=jonas-schievink

No observable changes from what I can tell, but this is "more correct".

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-06-03 12:27:57 +00:00
Jonas Schievink
28e3e683b2 ItemTree: make variant fields inherit the enum's visibility 2021-06-03 14:26:26 +02:00
bors[bot]
48ea50bf04
Merge #9124
9124: Apply a few clippy suggestions r=lnicola a=clemenswasser



Co-authored-by: Clemens Wasser <clemens.wasser@gmail.com>
2021-06-03 12:09:10 +00:00
bors[bot]
c7eb19ebf9
Merge #9104
9104: Implement `#[rustc_skip_array_during_method_dispatch]` r=flodiebold a=jonas-schievink

haxx run the world

Closes https://github.com/rust-analyzer/rust-analyzer/issues/8552
Part of https://github.com/rust-analyzer/rust-analyzer/issues/9056

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-06-03 11:52:15 +00:00
Jonas Schievink
70e19fd1cb Add comment 2021-06-03 13:51:43 +02:00
Clemens Wasser
629e8d1ed0 Apply more clippy suggestions and update generated 2021-06-03 12:46:56 +02:00
bors[bot]
50936397cc
Merge #9105
9105: internal: calculate pattern adjustments r=flodiebold a=iDawer

This extends `InferenceResult` with `pub pat_adjustments: FxHashMap<PatId, Vec<Ty>>`.

Fixes #9095 


Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2021-06-03 09:55:37 +00:00
Clemens Wasser
3c6dc0f89d Apply a few clippy suggestions 2021-06-03 11:46:03 +02:00
bors[bot]
092396c65a
Merge #9119
9119: fix: some minor "extract type alias" fixes r=jonas-schievink a=jonas-schievink

It now correctly works inside traits, and no longer messes up the indentation of the original node

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-06-02 20:28:15 +00:00
Jonas Schievink
6c0e58d107 Preserve indentation 2021-06-02 22:27:12 +02:00
Jonas Schievink
e4c019fcaa Account for traits 2021-06-02 22:20:41 +02:00
bors[bot]
c2157f5f96
Merge #9118
9118: Document that `addCallArgumentSnippets` requires `addCallParenthesis r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-02 20:12:10 +00:00
Lukas Wirth
d304352407 Document that addCallArgumentSnippets requires `addCallParenthesis 2021-06-02 22:10:09 +02:00
bors[bot]
e5c86ee3eb
Merge #9117
9117: Allow expand-macro to be invoked anywhere inside a macro call r=Veykril a=Veykril

I don't really see a reason to only limit this to the name-ref of a macro.
bors r+
Closes #4606

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-02 19:43:29 +00:00
Lukas Wirth
841feef79e Allow expand-macro to be invoked anywhere inside a macro call 2021-06-02 21:42:49 +02:00
Lukas Wirth
ded4e7cc83 Fix bind patterns always being treated as ref taking patterns 2021-06-02 20:00:39 +02:00
bors[bot]
5be653d426
Merge #9108
9108: Don't show extract into variable assist for unit expressions r=jonas-schievink a=brandondong

**Reproduction:**

```rust
fn main() {
    let mut i = 3;
    $0if i >= 0 {
        i += 1;
    } else {
        i -= 1;
    }$0
}
```

1. Select the snippet of code between the $0's.
2. The extract into variable assist shows up, pushing down the more useful extract into function assist.
3. The resulting output of selecting the extract into variable assist is valid but with the extracted variable having the unit type:
```rust
fn main() {
    let mut i = 3;
    let var_name = if i >= 0 {
        i += 1;
    } else {
        i -= 1;
    };
    var_name
}
```

**Fix:**
- Don't show the extract into variable assist for unit expressions. I could not think of any scenarios where such a variable extraction would be desired.

Co-authored-by: Brandon <brandondong604@hotmail.com>
2021-06-02 17:25:11 +00:00
bors[bot]
a421482e75
Merge #9112
9112: Fix some bugs in `extract_struct_from_enum_variant` assist r=Veykril a=Veykril

bors r+
Fixes #9100
Fixes #9099
Kind of fixes  #9109, it now copies all the generics might be incorrect if the variant doesn't use all of them)

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-06-02 16:18:42 +00:00
Lukas Wirth
6ffe1d99d4 Fix references to patterns in extract_struct_from_enum_variant assist 2021-06-02 18:16:59 +02:00
Lukas Wirth
9ff7ab680c Carry over attributes in extract_struct_from_enum_variant 2021-06-02 17:55:08 +02:00
Lukas Wirth
f3dc4321c8 Account for generics in extract_struct_from_enum_variant 2021-06-02 17:44:00 +02:00
bors[bot]
2022cfce44
Merge #9111
9111: fix: make "extract type alias" place extracted type alias outside of impl r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-06-02 15:21:17 +00:00
Lukas Wirth
76fd1b316f Remove obsolete is_new_item field on CompletionContext 2021-06-02 17:12:36 +02:00
Jonas Schievink
66a5fd375a Place extracted type alias outside of impl 2021-06-02 16:50:44 +02:00
Lukas Wirth
9271941a95 Add MethodCall and FieldAccess variants to ImmediateLocation 2021-06-02 15:21:18 +02:00
Brandon
7d2710218f Don't show extract into variable assist for unit expressions 2021-06-02 00:59:09 -07:00
Dawer
0a8c30a96f internal: implement pattern adjustments. 2021-06-02 01:32:05 +05:00
Dawer
99516bbd67 minor: Avoid eprintln on panic 2021-06-02 01:32:05 +05:00
Jonas Schievink
955064b6aa Implement #[rustc_skip_array_during_method_dispatch] 2021-06-01 21:34:08 +02:00
Jonas Schievink
41321fa71d Fall back to legacy prelude 2021-06-01 19:03:00 +02:00
Jonas Schievink
f96c1a0414 Implement per-edition preludes 2021-06-01 13:39:19 +02:00
bors[bot]
71117e6812
Merge #8717
8717: Update match checking algorithm r=iDawer a=iDawer

I've recently got interest in the match checking to extend the current algo to support reporting witnesses of non-exhaustiveness.
It appears the algo is outdated from rustc's implementation. I decided to rewrite it based on the latest rustc's version. It is a diff-based port to ra codebase. That means you can diff-compare these files to rustc.
I'm striving to keep minimal ra-related changes in the algo to make it easier to backport future changes from the upstream.

Based on upstream algorithm of version rust-lang/rust 1.52.0-nightly (25c15cdbe 2021-04-22)
https://github.com/rust-lang/rust/blob/25c15cdbe/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs

The goal of this PR is to cover the current `missing-match-arm` diagnostic.

What is remaining to do:
- [x] Error handling. The errors that are unrelated to match checking will be handled before the check. Just like how it made in rustc.
  - [x] Lowering `hir_def::expr::Pat` to `hir_ty::diagnostics::match_check::Pat`. rustc's match checking works on top of `rustc_mir_build::thir::Pat`, which is lowered from `hir::Pat` and carries some extra semantics used by the check. All unrelated checks are done there. RA could use this to rule out running the check on unimplemented cases (`Pat::ConstBlock`, etc).
  - [x] ~~Proper~~Loose typecheck of match arm patterns (https://github.com/rust-analyzer/rust-analyzer/pull/8840, https://github.com/rust-analyzer/rust-analyzer/pull/8875).
- [x] Tests from `hir_ty::diagnostics::match_check::tests`.
- [x] Clean up `todo`s
- [x] Test run on real repos https://github.com/rust-analyzer/rust-analyzer/pull/8717#issuecomment-847120265.

Co-authored-by: Dawer <7803845+iDawer@users.noreply.github.com>
2021-05-31 21:01:52 +00:00
Dawer
e7c49666be Expand fixme comments 2021-06-01 01:44:51 +05:00
Dawer
31b6a750f8 fix: panic on extra fields in a pattern 2021-06-01 00:49:44 +05:00
Dawer
4899ac8c05 Correct binding pattern's type; handle invalid records. 2021-06-01 00:49:44 +05:00
Dawer
3088ca0a53 Take substitutions into account. 2021-06-01 00:49:44 +05:00
Dawer
e16f413582 eprint panic context 2021-06-01 00:49:44 +05:00
Dawer
f571b62a13 minor: doc comment pat_util 2021-06-01 00:49:44 +05:00
Dawer
977ba46bb1 Test match guards, reference patterns 2021-06-01 00:49:44 +05:00
Dawer
4cce7a6407 Box field detection; test #[non-exhaustive] attribute 2021-06-01 00:49:44 +05:00
Dawer
f46a42f73a Better tests: check if match checking bails out. 2021-06-01 00:49:27 +05:00
Dawer
e84efc4a46 Replace the old match checking algorithm 2021-06-01 00:23:09 +05:00
Dawer
894b4c64ff Include old tests 2021-06-01 00:08:43 +05:00
Dawer
7d675eda80 Don't panic on a pattern of unresolved ADT variant. 2021-06-01 00:08:43 +05:00
Dawer
466345ca81 Clean up, more docs. 2021-06-01 00:08:27 +05:00
Dawer
49e016169f Check pattern types. 2021-06-01 00:03:47 +05:00
Dawer
9b841a9a04 Expand binding patterns. 2021-06-01 00:03:47 +05:00
Dawer
d7239e5ab4 Fix visibility warnings 2021-06-01 00:03:47 +05:00
Dawer
a236bfa57a Lower binding pattern 2021-06-01 00:03:47 +05:00
Dawer
cf6f989a8d Lower bool literals 2021-06-01 00:03:47 +05:00
Dawer
d6d77e8a35 Treat ctor of unhandled type as non-exhaustive. 2021-06-01 00:03:47 +05:00
Dawer
e711abc290 Lower Pat::Path 2021-06-01 00:03:47 +05:00
Dawer
e50ce67631 Do not do match check if lowering failed. 2021-06-01 00:03:47 +05:00
Dawer
de6f430140 Fix panics on pattern_arena.borrow with ugly cloning 2021-06-01 00:03:46 +05:00
Dawer
975109051c Basic lowering hir_def::exrp::Pat -> typed HIR.
Pattern arena is broken
2021-06-01 00:03:46 +05:00
Dawer
2431ff5987 Handle unordered fields in struct patterns 2021-06-01 00:03:46 +05:00
Dawer
3ffcb2658c Complete field replacing 2021-06-01 00:03:46 +05:00
Dawer
3a85e47f6a Support bool literal patterns 2021-06-01 00:03:46 +05:00
Dawer
5a8a0b6269 Check enum patterns 2021-06-01 00:03:46 +05:00
Dawer
b4f4197332 Build wildcard witnesses instead of panicking 2021-06-01 00:03:46 +05:00
Dawer
678d85ca7e Implement struct ctor application 2021-06-01 00:03:46 +05:00
Dawer
062c7953a1 Add remaining Constructor variants 2021-06-01 00:03:46 +05:00
Dawer
2880fd2320 Complete usefulness::SubPatSet impl 2021-06-01 00:03:46 +05:00
Dawer
f4c3960364 List useless patterns in a useful match arm 2021-06-01 00:03:45 +05:00
Dawer
f4a95c93fe Remove unneeded indirection on PatCtxt 2021-06-01 00:03:45 +05:00
Dawer
26baab5d28 Enable generation of non-exhaustiveness witnesses 2021-06-01 00:03:45 +05:00
Dawer
c3c2893f30 Update match checking.
fn is_useful , more skeletons

Specify a lifetime on pattern references

impl PatStack

fill impl Matrix

PatStack::pop_head_constructor

Index-based approach

struct PatCtxt

fields construction fn Fields::wildcards

split wildcard

fn Constructor::is_covered_by_any(..)

fn Matrix::specialize_constructor(..)

impl Usefulness

Initial work on witness construction

Reorganize files

Replace match checking diagnostic

Handle types of expanded patterns

unit match checking go brrr
2021-06-01 00:03:45 +05:00
cynecx
759cb07891 hir_ty: use correct receiver_ty in method resolution 2021-05-31 20:26:38 +02:00
bors[bot]
7c1d8ca635
Merge #9088
9088: minor: remove debug print r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-31 17:22:09 +00:00
Aleksey Kladov
ee51bf04be minor: remove debug print 2021-05-31 20:20:30 +03:00
bors[bot]
4cb4b23dc6
Merge #9084 #9087
9084: fix: avoid panics in match case diagnostic r=matklad a=matklad

bors r+
🤖

closes #8809

9087: fix: fix shell injection in task spawning r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-31 17:12:01 +00:00
Jonas Schievink
b5fe4c6ef0 Use cargo check again 2021-05-31 18:58:36 +02:00
Aleksey Kladov
159922de93 minor: it's Parameter, not Argument 2021-05-31 19:45:50 +03:00
Aleksey Kladov
341f8bb200 fix: avoid panics in match case diagnostic 2021-05-31 19:45:50 +03:00
bors[bot]
10b15b27f2
Merge #8952
8952: add support of impl block for doctest into runnables r=matklad a=bnjjj

close #6356 

Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2021-05-31 15:48:41 +00:00
Jonas Schievink
cfcadcb295 Simplify proc_macro_srv tests 2021-05-31 17:32:56 +02:00
bors[bot]
c460baeaf3
Merge #9079
9079: Don't take the parent kind of trailing attributes in attr completion r=Veykril a=Veykril

bors r+
fixes https://github.com/rust-analyzer/rust-analyzer/issues/9076

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-31 13:38:32 +00:00
Lukas Wirth
741b2f531f Don't take the parent kind of trailing attributes in attr completion 2021-05-31 15:35:22 +02:00
bors[bot]
e6ec860363
Merge #9039
9039: feat: Complete fields and methods with `self.` prefixed when inside methods r=matklad a=Veykril


![w65NbjkZiG](https://user-images.githubusercontent.com/3757771/119984385-a0111700-bfc1-11eb-9dbf-52fdaa4d72b5.gif)
Closes #7173

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-31 13:21:31 +00:00
Lukas Wirth
fb7105a580 Add config setting for self-on-the-fly 2021-05-31 15:14:56 +02:00
Lukas Wirth
4507382f2e Move unprefixed field/method completion to dot 2021-05-31 15:10:20 +02:00
Lukas Wirth
d346f5bf75 Less strings, more hir::Names 2021-05-31 14:55:16 +02:00
Lukas Wirth
ca49fbe0a1 Complete self. prefixed fields and methods inside methods 2021-05-31 14:52:55 +02:00
bors[bot]
e9a797748d
Merge #8866
8866: Update salsa r=matklad a=jonas-schievink

This updates salsa to include https://github.com/salsa-rs/salsa/pull/265, and removes all cancellation-related code from rust-analyzer

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-31 12:42:32 +00:00
bors[bot]
b8d269990c
Merge #9060
9060: feat: Diagnose unimplemented built-in macros r=matklad a=jonas-schievink

A number of built-in attribute macros are unsupported, I thought it might be useful to put a diagnostic on their definition in libcore. Not sure.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-31 12:34:01 +00:00
Lukas Wirth
971b0836ef Use Names instead of Strings in the completion rendering api 2021-05-31 14:15:15 +02:00
bors[bot]
3cb3f1d17b
Merge #9025
9025: internal: Display unknown types in `analysis-stats` r=flodiebold a=lnicola



Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-05-31 08:20:28 +00:00
bors[bot]
92b9e5ef3c
Merge #9068
9068: Move more `CompletinoContext` fields to `ImmediateLocation` r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-30 19:37:29 +00:00
Lukas Wirth
5660408f0a Move more fields to ImmediateLocation 2021-05-30 21:35:01 +02:00
cynecx
51cbcc5346 hir_ty: don't pass where clauses of associated types down to chalk (temp. fix #9052) 2021-05-30 19:21:08 +02:00
Lukas Wirth
c5cd25d755 Fix incorrect prefer_inner calls on some attribute completions 2021-05-30 17:13:00 +02:00
bors[bot]
f41b68637a
Merge #9062
9062: internal: Bump deps r=lnicola a=lnicola

Fixes #9061

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-05-30 11:48:59 +00:00
Laurențiu Nicola
36567eb9be Bump deps 2021-05-30 14:48:10 +03:00
Jonas Schievink
cb5454db86 Diagnose unimplemented built-in macros 2021-05-30 04:19:47 +02:00
Jonas Schievink
39533ad7dd Only complete derive proc macros in #[derive] 2021-05-29 21:18:14 +02:00
Jonas Schievink
acb5c227ed Update to prerelease 2021-05-29 21:10:00 +02:00
Jonas Schievink
8c639a87bd Thread proc-macro types through the HIR 2021-05-29 20:32:57 +02:00
bors[bot]
f6da603c7f
Merge #9050
9050: hir_ty: use async ret type for inference inside async bodies r=flodiebold a=cynecx

Fixes #9004.

Co-authored-by: cynecx <me@cynecx.net>
2021-05-29 17:39:15 +00:00
bors[bot]
0438e2ceaa
Merge #9054
9054: fix: fix `matches!` macro on nightly toolchains r=jonas-schievink a=jonas-schievink

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/9043

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-29 16:33:20 +00:00
Jonas Schievink
4c4bcaebbe Treat pat_param like pat fragments 2021-05-29 18:32:32 +02:00
bors[bot]
11a1bd3259
Merge #9051
9051: Fix incorrect setting descriptions r=lnicola a=sclu1034

Descriptions for diagnostic warning hint and info display were swapped.

Fixes #8485.

Co-authored-by: Lucas Schwiderski <lucas@lschwiderski.de>
2021-05-29 16:23:59 +00:00
cynecx
54d60fdee9 hir_ty: use async ret type for inference inside async bodies 2021-05-29 18:17:45 +02:00
Lucas Schwiderski
9a057c0ff4
Fix incorrect setting descriptions
Descriptions for diagnostic warning hint and info display were swapped.

Fixes #8485.

Signed-off-by: Lucas Schwiderski <lucas@lschwiderski.de>
2021-05-29 18:08:14 +02:00
bors[bot]
3fa3343e47
Merge #9048
9048: Add some lint completion tests r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-29 15:33:57 +00:00
Lukas Wirth
c9598a4cbf Add some lint completion tests 2021-05-29 17:19:49 +02:00
Jonas Schievink
31588aea04 Remove fragment kind knowledge from builtin macros 2021-05-29 17:17:08 +02:00
bors[bot]
247faf271b
Merge #9027
9027: feat: Attribute completion is context aware r=Veykril a=Veykril

This splits off the `lint` and `derive` completions into their own submodules of `attribute`.

The idea is to create a lazy global hashmap that maps `SyntaxKind` to attribute names(`&[&str]`) in which we index with the syntax kind of the "thing" we are attributing giving us the attributes back that are valid for this kind. Then we use this name to do a binary search on the attribute list to fetch and build the corresponding completion item.


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-29 12:14:16 +00:00
Lukas Wirth
c9f0f47bbb simplify 2021-05-29 14:02:06 +02:00
Lukas Wirth
e42c448077 More completion pattern tests 2021-05-28 22:19:52 +02:00
Lukas Wirth
47ad752e6c Implement prev sibling determination for CompletionContext 2021-05-28 22:03:31 +02:00
Lukas Wirth
a6b92a8cc0 simplify 2021-05-28 20:46:09 +02:00
bors[bot]
d5f7b2e52a
Merge #9028
9028: only advertise range formatting support if enabled r=Veykril a=euclio

Fixes #9009.

Co-authored-by: Andy Russell <arussell123@gmail.com>
2021-05-28 15:26:20 +00:00
bors[bot]
2968731fd5
Merge #9040
9040: Don't label derive macros with their banged_name r=Veykril a=Veykril

cc https://github.com/rust-analyzer/rust-analyzer/issues/7072#issuecomment-850396203
This doesn't fix it non builtin derives yet I think cause of a FIXME somewhere that doesn't categorize proc-macro derives as derives yet
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-28 12:59:54 +00:00
Lukas Wirth
439ae17e1b Don't label derive macros with their banged_name 2021-05-28 14:59:24 +02:00
bors[bot]
b5d41ba0e2
Merge #9038
9038: Folding range for return types r=Veykril a=MozarellaMan

For issue #8957 

![return type fold](https://user-images.githubusercontent.com/48062697/119979082-5c62e100-bfb2-11eb-9729-1dea1ce74de1.gif)


Co-authored-by: Ayomide Bamidele <48062697+MozarellaMan@users.noreply.github.com>
2021-05-28 12:16:18 +00:00
Ayomide Bamidele
b4e936f8f0 Test for correct amount of emitted folds 2021-05-28 13:10:41 +01:00
Ayomide Bamidele
156d995423 Folding range for return types 2021-05-28 12:39:02 +01:00
Lukas Wirth
61b4456752 Move runnable lenses below attributes 2021-05-28 13:02:42 +02:00
Laurențiu Nicola
2dee5930e0 Remove undocumented TextDocumentSyncKind::Full support 2021-05-28 13:01:04 +03:00
bors[bot]
bca00ac340
Merge #9033
9033: Complete keywords in (Assoc)ItemList with leading attribute r=Veykril a=Veykril

Fixes #7673
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-28 01:21:45 +00:00
Lukas Wirth
1894db49b1 Complete keywords in (Assoc)ItemList with leading attribute 2021-05-28 03:20:55 +02:00
bors[bot]
3a1598c3bc
Merge #9032
9032: Only complete modules in empty use-statements r=Veykril a=Veykril

bors r+
Part of #8518

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-28 00:43:16 +00:00
Lukas Wirth
9e71dd9799 Only complete modules in empty use-statements 2021-05-28 02:42:47 +02:00
Lukas Wirth
411eee7614 Add another attribute completion test 2021-05-28 01:09:22 +02:00
Lukas Wirth
0724bd0f21 Add attribute completion tests 2021-05-28 01:02:41 +02:00
bors[bot]
5b4589f474
Merge #9029
9029: minor: test that `ItemTree` makes `hir_def` queries syntax-independent r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-27 22:47:04 +00:00
Jonas Schievink
55f3ca2b74 Test that ItemTree works as intended 2021-05-28 00:46:05 +02:00
Lukas Wirth
594270be49 tt muncher time 2021-05-28 00:35:21 +02:00
Lukas Wirth
ab9c6ea4dd Split attribute completion module into attribute, derive and lint modules 2021-05-27 23:40:33 +02:00
Andy Russell
a0cd7fe242
only advertise range formatting support if enabled 2021-05-27 17:36:13 -04:00
Lukas Wirth
fc37e2f953 Attribute completion is context aware 2021-05-27 23:28:14 +02:00
bors[bot]
01bfc5f5c0
Merge #9026
9026: Complete modules in assoc item lists r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-27 19:13:34 +00:00
Lukas Wirth
ea251cbd4a Complete modules in item lists 2021-05-27 21:12:50 +02:00
Lukas Wirth
7ad378fec0 Complete modules in assoc item lists 2021-05-27 20:53:38 +02:00
Jonas Schievink
26b4777e1f Move hir_ty incremental test to its own file 2021-05-27 20:21:52 +02:00
bors[bot]
a2940c42c0
Merge #9020
9020: fix: Don't complete non-macro item paths in impls and modules r=Veykril a=Veykril

Part of #8518
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-27 16:34:46 +00:00
Laurențiu Nicola
aabbc84957 Display unknown types in analysis-stats 2021-05-27 19:30:28 +03:00
Lukas Wirth
3a16950fd9 Cleanup ImmediateLocation determination 2021-05-27 18:16:39 +02:00
Laurențiu Nicola
2268a220e4 Don't store supertraits in ItemTree 2021-05-27 16:52:30 +03:00
Jonas Schievink
33debc4065 Update salsa 2021-05-27 15:05:41 +02:00
bors[bot]
d0a4ba294c
Merge #8997
8997: internal: stop expanding UseTrees during ItemTree lowering r=jonas-schievink a=jonas-schievink

Closes https://github.com/rust-analyzer/rust-analyzer/issues/8908

Messy diff, but `ItemTree` lowering got simpler, since we now have a strict 1-to-1 mapping between `ast::Item` and `ModItem`.

The most messy part is mapping a single `UseTree` back to its `ast::UseTree` counterpart for diagnostics, but I think the ad-hoc source map built during lowering does the job.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2021-05-27 11:56:26 +00:00
Jonas Schievink
196cb65ead Drop ignore from doctests 2021-05-27 13:55:31 +02:00
Lukas Wirth
f41c983424 Don't complete non-macro item paths in impls and modules 2021-05-27 12:23:36 +02:00
bors[bot]
7d1653dcdc
Merge #9005
9005: internal: Document semantic token tags r=matklad a=Veykril

Closes #6457

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-27 07:04:15 +00:00
Lukas Wirth
30948e1ecb simplify 2021-05-27 03:47:20 +02:00
Lukas Wirth
6ec4ea8d9e simplify 2021-05-27 03:15:48 +02:00
Lukas Wirth
7de925b8ab Collapse more CompletionContext booleans into enums 2021-05-27 02:54:49 +02:00
bors[bot]
d6ed315806
Merge #9017
9017: internal: Reduce the number of traits passed through chalk during applicable trait lookup r=SomeoneToIgnore a=SomeoneToIgnore

Inherent traits can be omitted before trait solving, presumably slightly helping https://github.com/rust-analyzer/rust-analyzer/issues/7542 and slightly simplifying the code.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2021-05-26 23:06:59 +00:00
Kirill Bulatov
050c592b8c Exclude inherent traits more eagerly 2021-05-27 02:00:23 +03:00
Lukas Wirth
1f897f7319 Set record_pat_syntax more precisely in CompletionContext 2021-05-26 23:46:00 +02:00
bors[bot]
666fc1cec1
Merge #9015
9015: Merge pattern completion related bools into an enum r=Veykril a=Veykril

The two bools can never both be set so this is basically just a tri-state enum.
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-26 20:43:53 +00:00
Lukas Wirth
7d865ef071 Merge pattern completion related bools into an enum 2021-05-26 22:39:47 +02:00
bors[bot]
8389510f8d
Merge #9012
9012: feat: add tab stops for keyword completions r=matklad a=eduardocanellas

Add tab stops for all the keywords that I judged fit. I also introduced some line breaks and spaces, following the pattern I saw in the `postfix` module.

Co-authored-by: Eduardo Canellas <eduardocanellas98@gmail.com>
2021-05-26 20:29:52 +00:00
Lukas Wirth
26e784a575 simplify 2021-05-26 21:09:27 +02:00
Eduardo Canellas
052df3deb7 feat: add tab stops for keyword completions 2021-05-26 14:24:54 -03:00
bors[bot]
bb1c7fc0cf
Merge #9008
9008: fix: remove undesired completions from trait/impl blocks r=Veykril a=eduardocanellas

Related to #8518


Co-authored-by: Eduardo Canellas <eduardocanellas98@gmail.com>
2021-05-26 17:04:09 +00:00
Eduardo Canellas
ce36746035 fix: remove undesired completions from trait/impl blocks 2021-05-26 13:21:27 -03:00
bors[bot]
f3aaae6555
Merge #9007
9007: Internal: `clippy::redundant_clone` fixes r=lnicola a=lnicola

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-05-26 15:36:14 +00:00
Laurențiu Nicola
8206939fed clippy::redundant_clone fixes 2021-05-26 18:34:50 +03:00
Lukas Wirth
7ebfc3d410 Document semantic token tags 2021-05-26 15:23:05 +02:00
bors[bot]
5a1fd05760
Merge #9003
9003: minor: Document semantic token modifiers r=Veykril a=Veykril

Part of #6457

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-26 12:08:56 +00:00
Lukas Wirth
887dd2d5bb Document semantic token modifiers 2021-05-26 13:37:54 +02:00
bors[bot]
5701c553cb
Merge #9002
9002: Move annotations below item attributes r=Veykril a=Veykril

This moves annotations/code lenses below attributes in items, bringing them inline with functions where this is already the case. This is done by changing the annotations covering range to just the name node's range which is also more inline with what the lsp expects which is that the range should ideally only cover a single line. 

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/9000
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-26 10:26:19 +00:00
Lukas Wirth
dfa47eaadb Move annotations below item attributes 2021-05-26 12:23:51 +02:00
bors[bot]
8483fb0f26
Merge #8996
8996: Fix bug where library functions were not highlighted as such r=arzg a=arzg

Sorry about forgetting to test this in my last PR.

Co-authored-by: Aramis Razzaghipour <aramisnoah@gmail.com>
2021-05-25 23:28:02 +00:00
Jonas Schievink
fe910c7bc4 Reduce memory usage a bit 2021-05-26 01:26:16 +02:00
Aramis Razzaghipour
8960a08951
Fix bug where library functions were not highlighted as such 2021-05-26 09:26:13 +10:00
Jonas Schievink
356dd3d909 Clean up ItemTree lowering now that it's 1:1 2021-05-26 01:09:31 +02:00
Jonas Schievink
b52df91877 Stop expanding UseTrees during ItemTree lowering 2021-05-26 01:01:58 +02:00
bors[bot]
5587d0a3e3
Merge #8973
8973: internal: move diagnostics to hir r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-25 20:33:21 +00:00
bors[bot]
e23083f398
Merge #8993
8993: fix: don't show pd/ppd completions where it shouldn't be r=flodiebold a=eduardocanellas

Closes #8992


Co-authored-by: Eduardo Canellas <eduardocanellas98@gmail.com>
2021-05-25 19:58:49 +00:00
bors[bot]
3b10f9e714
Merge #8994
8994: Check for subdirs in vfs loader exclusions. r=matklad a=ammkrn

The current logic used to transfer global_excludes into vfs exclusions
only transfers global_excludes that are the parent of an item in
dirs.include.
This commit additionally adds an item from global_exclude to the vfs
exclusions if the global_exclude is a child of an included item.

Co-authored-by: ammkrn <ammkrn@tuta.io>
2021-05-25 16:40:57 +00:00
ammkrn
96ee19851b Check for subdirs in vfs loader exclusions.
The current logic used to transfer global_excludes into vfs exclusions
only transfers global_excludes that are the parent of an item in
dirs.include.
This commit additionally adds an item from global_exclude to the vfs
exclusions if the global_exclude is a child of an included item.
2021-05-25 11:35:39 -05:00
Eduardo Canellas
e31a762c63 fix: don't show pd/ppd completions where it shouldn't be 2021-05-25 11:53:11 -03:00
Aleksey Kladov
5c9f31d4c2 internal: move diagnostics to hir
The idea here is to eventually get rid of `dyn Diagnostic` and
`DiagnosticSink` infrastructure altogether, and just have a `enum
hir::Diagnostic` instead.

The problem with `dyn Diagnostic` is that it is defined in the lowest
level of the stack (hir_expand), but is used by the highest level (ide).

As a first step, we free hir_expand and hir_def from `dyn Diagnostic`
and kick the can up to `hir_ty`, as an intermediate state. The plan is
then to move DiagnosticSink similarly to the hir crate, and, as final
third step, remove its usage from the ide.

One currently unsolved problem is testing. You can notice that the test
which checks precise diagnostic ranges, unresolved_import_in_use_tree,
was moved to the ide layer. Logically, only IDE should have the infra to
render a specific range.

At the same time, the range is determined with the data produced in
hir_def and hir crates, so this layering is rather unfortunate. Working
on hir_def shouldn't require compiling `ide` for testing.
2021-05-25 17:49:59 +03:00
Lukas Wirth
28ca371755 Consider trait to be in scope for trait-impl 2021-05-25 16:16:29 +02:00
bors[bot]
35db5e99f6
Merge #8990
8990: feat: Also do goto implementation on assoc consts r=lnicola a=lf-

I forgot to put this into #8988, sorry.

Goto implementation on a const on the trait will go to the
implementations with their respective definitions of the const, if
present.

Co-authored-by: Jade <software@lfcode.ca>
2021-05-25 13:33:07 +00:00
Jade
0292efd363 Also do goto implementation on assoc consts
I forgot to put this into #8988, sorry.

Goto implementation on a const on the trait will go to the
implementations with their respective definitions of the const, if
present.
2021-05-25 06:27:41 -07:00