Commit Graph

20673 Commits

Author SHA1 Message Date
Jonas Schievink
7e8b96f07c Fix concatenation of super mod paths 2022-01-11 15:39:13 +01:00
bors[bot]
6824722f54
Merge #11257
11257: feat: Report `DefDiagnostic`s from inside item bodies r=jonas-schievink a=jonas-schievink

Reports diagnostics from all block-level `DefMap`s, and adds some code to avoid adding duplicate diagnostics to the body's `SourceMap`.

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2022-01-11 13:36:53 +00:00
Jonas Schievink
0706de94bb Report DefDiagnostics from inside item bodies 2022-01-11 14:34:25 +01:00
bors[bot]
5a711d4f3a
Merge #11210
11210: feat: Deprioritize ops methods in completion r=Veykril a=Veykril

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



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-11 09:39:12 +00:00
Lukas Wirth
4901ea3eef Lookup lang attribute on assoc item trait directly 2022-01-11 10:28:38 +01:00
Lukas Wirth
94b369faa3 Update tests 2022-01-11 09:26:53 +01:00
Lukas Wirth
ca0633c808 feat: Deprioritize ops methods in completion 2022-01-11 09:26:53 +01:00
bors[bot]
85bcca6b37
Merge #11252
11252: Fix documentation of snippet r=Veykril a=weirane

Closes #11234

Co-authored-by: Wang Ruochen <wrc@ruo-chen.wang>
2022-01-11 08:11:55 +00:00
Wang Ruochen
01b3ce3006
Fix documentation of snippet 2022-01-10 21:29:41 -08:00
bors[bot]
8dd58ceb7b
Merge #11247
11247: Print a single ellipsis for any number of omitted types r=jonas-schievink a=jonas-schievink

Helps a little bit with https://github.com/rust-analyzer/rust-analyzer/issues/11240

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2022-01-10 15:56:54 +00:00
Jonas Schievink
601dc50b5a Print a single ellipsis for any number of omitted types 2022-01-10 16:55:53 +01:00
bors[bot]
0f8c96c926
Merge #11238
11238: fix: shrink the span of errors from attribute macros and derives r=jonas-schievink a=jonas-schievink

Some procedural macros tend to get very large invocations, for example RTIC's, leading to issues like https://github.com/rtic-rs/cortex-m-rtic/issues/582, where almost the entire screen is underlined while editing incomplete code in the macro.

This PR shrinks the spans of errors from attribute macros and derives to point only at the attribute, which also matches rustc more closely.

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2022-01-08 14:46:01 +00:00
Jonas Schievink
3dd5e273b6 Shrink diagnostic spans for errors inside macros 2022-01-08 15:40:42 +01:00
Jonas Schievink
67f548d8e9 Allow doc comments on all Items 2022-01-08 15:27:48 +01:00
bors[bot]
ca8bd3ec42
Merge #11237
11237: fix: Fix outline modules spilling inner doc injections into their parent r=Veykril a=Veykril

Fixes another regression caused by https://github.com/rust-analyzer/rust-analyzer/pull/11225
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-08 13:55:18 +00:00
Lukas Wirth
b32f611b6e fix: Fix outline modules spilling inner doc injections into their parent 2022-01-08 14:54:31 +01:00
bors[bot]
01c3303270
Merge #11236
11236: internal: Remove `InFile` wrapping from `DynMap` keys r=Veykril a=Veykril

We already store a `DynMap` per `(Container, HirFileId)` pair, so the `InFile` keys are already guruanteed to always be of the same file id
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-08 11:17:56 +00:00
Lukas Wirth
47591f0fb2 Remove InFile wrapping from DynMap keys 2022-01-08 12:16:44 +01:00
Lukas Wirth
b6826e9246 Only add generics with the correct file id to DynMap 2022-01-08 11:34:58 +01:00
bors[bot]
926ba99f43
Merge #11235
11235: internal: Record attribute calls on assoc items in TraitData and ImplData r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-08 10:11:37 +00:00
Lukas Wirth
8d4f40e881 Do less allocs in trait_data and impl_data queries 2022-01-08 11:04:16 +01:00
Lukas Wirth
6746ba5839 Record attribute calls on assoc items in TraitData and ImplData 2022-01-08 10:45:12 +01:00
bors[bot]
c17db9fa53
Merge #11107
11107: Fix generic type substitution in impl trait with assoc type r=pnevyk a=pnevyk

Fixes #11045 

The path transform now detects if a type parameter that is being substituted has an associated type. In that case it is necessary (or safe in general case) to fully qualify the substitution with a trait which the associated type belongs to.

This PR also fixes the previous wrong behavior of the substitution that could create an invalid tree `PATH_TYPE -> PATH_TYPE -> ...`.

Co-authored-by: Petr Nevyhoštěný <petr.nevyhosteny@gmail.com>
2022-01-08 09:05:09 +00:00
bors[bot]
54c9998933
Merge #11232
11232: Filter out macro calls by file id in when building DynMap r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-07 20:52:57 +00:00
Lukas Wirth
6cf0cadfaa Simplify 2022-01-07 21:52:37 +01:00
Lukas Wirth
0c9268c1ee Filter out macro calls by file id in when building DynMap 2022-01-07 21:31:08 +01:00
bors[bot]
41a0e95d61
Merge #11230
11230: fix: Fix attribute stripping ignoring doc comments r=Veykril a=Veykril

Follow up to https://github.com/rust-analyzer/rust-analyzer/pull/11225#pullrequestreview-846779237


Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-07 18:06:33 +00:00
Lukas Wirth
81163b8cd4 fix: Fix attribute stripping ignoring doc comments 2022-01-07 18:51:10 +01:00
Petr Nevyhoštěný
a710b87b1b Fix generic type substitution in impl trait with assoc const 2022-01-07 16:41:39 +01:00
bors[bot]
40009e07d0
Merge #11145
11145: feat: add config to use reasonable default expression instead of todo! when filling missing fields r=Veykril a=bnjjj

Use `Default::default()` in struct fields when we ask to fill it instead of putting `todo!()` for every fields

before:

```rust
pub enum Other {
    One,
    Two,
}

pub struct Test {
    text: String,
    num: usize,
    other: Other,
}

fn t_test() {
    let test = Test {<|>};
}
``` 

after: 

```rust
pub enum Other {
    One,
    Two,
}

pub struct Test {
    text: String,
    num: usize,
    other: Other,
}

fn t_test() {
    let test = Test {
        text: String::new(),
        num: 0,
        other: todo!(),
    };
}
``` 



Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Co-authored-by: Coenen Benjamin <benjamin.coenen@hotmail.com>
2022-01-07 14:10:11 +00:00
bors[bot]
efb9b89163
Merge #11220
11220: Turbo fish assist: don't include lifetime parameters r=Veykril a=Vannevelj

Fixes #11219

The issue talks about three different types of params: type, const & lifetime. I wasn't entirely sure which ones are intended to be included here so I've gone for the type & const params (i.e. exclude lifetime).

I've added a test case for both a lifetime param and a const param. I'm still making my way through the rust book (chapter 7, yay) so I'm not too sure yet what these are but my testing shows that this approach generates code that compiles.

Co-authored-by: Jeroen Vannevel <jer_vannevel@outlook.com>
2022-01-07 14:02:01 +00:00
Benjamin Coenen
8e0a05eb70 feat(diagnostics): use default expression instead of todo! when missing fields
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2022-01-07 15:01:37 +01:00
Jeroen Vannevel
0a240e31c5
succinct code 2022-01-07 13:53:42 +00:00
bors[bot]
b70493d095
Merge #11225
11225: internal: Cleanup doc and attribute handling r=Veykril a=Veykril

(very vague PR title but as I tried to fix the mentioned issue I ran into more and more subtle things that were interwoven)
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11215

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-07 13:38:23 +00:00
Lukas Wirth
87735e5e9e Update item tree test output 2022-01-07 14:29:58 +01:00
bors[bot]
c09504bd58
Merge #11194
11194: fix(gen-doc-assist): remove lifetimes in description of `new` r=Veykril a=numero-744

From wrong behavior:

```rust
/// Creates a new [`MyGenericStruct<'a, T>`].
```

to correct behavior:

```rust
/// Creates a new [`MyGenericStruct<T>`].
```

But I feel like there is a better way to implement it. Do you know if there is an existing function that could do the work of `lifetimes_removed()` below?

Co-authored-by: Côme ALLART <come.allart@etu.emse.fr>
2022-01-07 13:24:58 +00:00
Lukas Wirth
ca4baa6e55 Use FileAstId<ast::Adt> in nameres where appropriate instead 2022-01-07 14:20:27 +01:00
Jeroen Vannevel
4bcdb05325
include tabstops 2022-01-07 13:17:21 +00:00
Lukas Wirth
08adce61a1 Better interface for doc comment and attribute processing 2022-01-07 14:14:33 +01:00
Benjamin Coenen
b60a29ca94 feat(diagnostics): use default expression instead of todo! when missing fields
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2022-01-07 14:13:34 +01:00
Côme ALLART
1b5c60f549 refactor: apply suggestions
See PR #11194
2022-01-07 14:07:35 +01:00
Coenen Benjamin
0a4239a815
Update crates/rust-analyzer/src/config.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-07 14:07:02 +01:00
Jeroen Vannevel
778e71b15f
fmt 2022-01-07 12:40:41 +00:00
Jeroen Vannevel
76e0429048
concise filtering 2022-01-07 12:34:03 +00:00
Lukas Wirth
69dbfc7754 Generate AnyHasDocComments node 2022-01-07 12:38:18 +01:00
Jeroen Vannevel
734193bc23 support const params 2022-01-07 01:09:32 +00:00
Jeroen Vannevel
b6201051b2 Count the type parameters only 2022-01-07 01:02:16 +00:00
bors[bot]
2fb6f5e46a
Merge #11218
11218: fix: Correct has_ref detection, avoiding duplicate &mut insertion on parameter completion r=Veykril a=weirane

The original code fails to detect there's a ref in scenarios such as `&mut s` and `& s` because `WHITESPACE` and `IDENT` got reversed.

Closes #11199.

Co-authored-by: Wang Ruochen <wrc@ruo-chen.wang>
2022-01-06 23:17:51 +00:00
Wang Ruochen
3a57f700d8
Correct has_ref detection 2022-01-06 11:46:28 -08:00
Benjamin Coenen
f4ce0d78bb add better default behavior on fill struct fields diagnostic
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2022-01-06 15:42:29 +01:00