bors[bot] [Sat, 8 Jan 2022 14:46:01 +0000 (14:46 +0000)]
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>
bors[bot] [Sat, 8 Jan 2022 09:05:09 +0000 (09:05 +0000)]
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>
bors[bot] [Fri, 7 Jan 2022 14:02:01 +0000 (14:02 +0000)]
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.
bors[bot] [Fri, 7 Jan 2022 13:38:23 +0000 (13:38 +0000)]
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
bors[bot] [Fri, 7 Jan 2022 13:24:58 +0000 (13:24 +0000)]
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?
bors[bot] [Thu, 6 Jan 2022 12:53:49 +0000 (12:53 +0000)]
Merge #11193
11193: feat: Add config to replace specific proc-macros with dummy expanders r=Veykril a=Veykril
With this one can specify proc-macros from crates to expand into their input as a (temporary) workaround for the current completion problems with some of the bigger attribute proc-macros like `async_trait`.
This could've been done by just not expanding these macros, but that would require fiddling with nameres. I felt like this approach was simpler to pull off while also keeping the behaviour of the attributes/proc-macro in that they still expand instead of being dead syntax to us.
Usage(`async_trait` as example):
```jsonc
"rust-analyzer.procMacro.dummies": {
"async-trait": [ // crate name(as per its cargo.toml definition, not the dependency name)
"async_trait" // exported proc-macro name
]
},
```
bors[bot] [Thu, 6 Jan 2022 12:41:02 +0000 (12:41 +0000)]
Merge #11211
11211: fix: Fix parsing of `#[derive]` paths r=jonas-schievink a=jonas-schievink
Currently this code produces an empty derive path for every `,`, which makes the IDE layer resolve derive paths to the wrong derive macro in the list. Skip `,`s to fix that. (nameres just ignored them, so it didn't cause problems there)
bors r+
Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
This will parse the field expression and look at whether it is marked `&` or `&mut` and include a modifier if appropriate. The original issue only mentions `&mut params` but I've found that this issue also occurs for `&mut locals` as well as `¶ms` and `&locals` so I've also added tests for them.
I'd definitely be interested in hearing where I can make my code more idiomatic for Rust.
11202: fix: Fix `apply_demorgan` assist hanging for certain binary expressions r=Veykril a=Veykril
bors[bot] [Wed, 5 Jan 2022 20:45:27 +0000 (20:45 +0000)]
Merge #11201
11201: fix: Fix completions not considering ancestor items for attribute search r=Veykril a=Veykril
Turns out we never filled the `CompletionContext` with the attribute expansion of attributed impls and traits when typing in the assoc items, as we were only considering the assoc item to have an attribute to expand.
bors r+
- insert commas around when necessary
- only suggest `self` completions when param list is empty
- stop suggesting completions for identifiers which are already on the param list