]> git.lizzy.rs Git - rust.git/log
rust.git
2 years agoMerge #11433
bors[bot] [Mon, 28 Feb 2022 10:15:44 +0000 (10:15 +0000)]
Merge #11433

11433: minor: Add scary warning to `onEnter` r=lnicola a=lnicola

Closes #11432

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoAdd scary warning to onEnter
Laurențiu Nicola [Tue, 8 Feb 2022 06:34:24 +0000 (08:34 +0200)]
Add scary warning to onEnter

2 years agoMerge #11579
bors[bot] [Mon, 28 Feb 2022 09:18:26 +0000 (09:18 +0000)]
Merge #11579

11579: minor: Future-proof against a next edition by using `>=` and not `==` r=lnicola a=ChayimFriedman2

So that we won't have a strange bug when edition 2024 will land.

rustc [also does that](https://github.com/rust-lang/rust/blob/427cf81206d3b6cf41c86c1b9ce113a33f1ce860/compiler/rustc_builtin_macros/src/edition_panic.rs#L84).

Co-authored-by: Chayim Refael Friedman <chayimfr@gmail.com>
2 years agoFuture-proof against a next edition by using `>=` and not `==`
Chayim Refael Friedman [Mon, 28 Feb 2022 09:13:55 +0000 (11:13 +0200)]
Future-proof against a next edition by using `>=` and not `==`

So that we won't have a strange bug when edition 2024 will land.

rustc [also does that](https://github.com/rust-lang/rust/blob/427cf81206d3b6cf41c86c1b9ce113a33f1ce860/compiler/rustc_builtin_macros/src/edition_panic.rs#L84).

2 years agoMerge #11573
bors[bot] [Sun, 27 Feb 2022 12:00:04 +0000 (12:00 +0000)]
Merge #11573

11573: refactorings and FIXME fixes in text edit r=lnicola a=HansAuger

This is mainly me learning some rust, and only anecdotally about addressing some `fixme`s. Feel free to nope :)

There is a follow up PR in the pipeline which tackles the other two `fixme`s but it's a bit more invasive. So I wanted to get this out of the way

Co-authored-by: Moritz Vetter <mv@3yourmind.com>
2 years agoMerge #11567
bors[bot] [Sun, 27 Feb 2022 11:34:01 +0000 (11:34 +0000)]
Merge #11567

11567: Fix `if` in #11561 r=Veykril a=ChayimFriedman2

Fixes #11561.

Co-authored-by: Chayim Refael Friedman <chayimfr@gmail.com>
2 years agoMerge #11570
bors[bot] [Sun, 27 Feb 2022 09:17:46 +0000 (09:17 +0000)]
Merge #11570

11570: minor: Remove misleading comments r=lnicola a=ChayimFriedman2

They're not true anymore after #11375.

Co-authored-by: Chayim Refael Friedman <chayimfr@gmail.com>
2 years agoRemove misleading comments
Chayim Refael Friedman [Sun, 27 Feb 2022 07:52:11 +0000 (09:52 +0200)]
Remove misleading comments

They're not true anymore after #11375.

2 years agoadd two more unit tests for text_edit
Moritz Vetter [Sun, 27 Feb 2022 01:11:56 +0000 (02:11 +0100)]
add two more unit tests for text_edit

2 years agoFix `if` in #11561
Chayim Refael Friedman [Sun, 27 Feb 2022 00:12:22 +0000 (00:12 +0000)]
Fix `if` in #11561

2 years agoMerge #11560
bors[bot] [Sat, 26 Feb 2022 17:00:11 +0000 (17:00 +0000)]
Merge #11560

11560: internal: Update `url` to make `webrender` build when computing metrics r=jonas-schievink a=lnicola

Closes #9997

This doesn't seem to affect the metrics, but I'm not sure since somehow I get different values than what shows up on CI.

With `stable`:

```
  exprs: 94151, ??ty: 96 (0%), ?ty: 25 (0%), !ty: 6
```

CI shows 16.

Also, https://github.com/rust-analyzer/rust-analyzer/pull/7250 strikes again, I can never tell what those numbers are.

r? `@jonas-schievink`

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoMerge #11565
bors[bot] [Sat, 26 Feb 2022 16:49:16 +0000 (16:49 +0000)]
Merge #11565

11565: fix: Fix body selection in while loops r=Veykril a=lnicola

CC #11561

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoMerge #11566
bors[bot] [Sat, 26 Feb 2022 15:48:11 +0000 (15:48 +0000)]
Merge #11566

11566: minor: Make hir::Local::name infallible r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoMake hir::Local::name infallible
Lukas Wirth [Sat, 26 Feb 2022 14:06:11 +0000 (15:06 +0100)]
Make hir::Local::name infallible

2 years agorefact: edit text in place in TextEdit::apply
Moritz Vetter [Sat, 26 Feb 2022 14:50:09 +0000 (15:50 +0100)]
refact: edit text in place in TextEdit::apply

2 years agotest: add unit test for TextEdit::apply()
Moritz Vetter [Sat, 26 Feb 2022 14:46:14 +0000 (15:46 +0100)]
test: add unit test for TextEdit::apply()

2 years agoFix body selection in while loops
Laurențiu Nicola [Sat, 26 Feb 2022 14:45:06 +0000 (16:45 +0200)]
Fix body selection in while loops

2 years agoMerge #11564
bors[bot] [Sat, 26 Feb 2022 13:53:30 +0000 (13:53 +0000)]
Merge #11564

11564: internal: Cleanup highlighting tests r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoRename test highlighting output files
Lukas Wirth [Sat, 26 Feb 2022 13:51:13 +0000 (14:51 +0100)]
Rename test highlighting output files

2 years agoSplit up highlighting tests a bit more
Lukas Wirth [Sat, 26 Feb 2022 13:45:09 +0000 (14:45 +0100)]
Split up highlighting tests a bit more

2 years agoRe-order and cleanup highlighting tests
Lukas Wirth [Sat, 26 Feb 2022 13:29:03 +0000 (14:29 +0100)]
Re-order and cleanup highlighting tests

2 years agoMerge #11562
bors[bot] [Sat, 26 Feb 2022 12:54:57 +0000 (12:54 +0000)]
Merge #11562

11562: fix: Don't emit unresolvedReference highlight tags in unlinked files r=Veykril a=Veykril

Emitting these overwrites any syntax based highlighting that is being done in the file, causing a lot of noise if the user gave them a specific color.
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agofix: Don't emit unresolvedReference highlight tags in unlinked files
Lukas Wirth [Sat, 26 Feb 2022 12:53:54 +0000 (13:53 +0100)]
fix: Don't emit unresolvedReference highlight tags in unlinked files

2 years agoUpdate url to make webrender build
Laurențiu Nicola [Sat, 26 Feb 2022 09:56:57 +0000 (11:56 +0200)]
Update url to make webrender build

2 years agoMerge #11538
bors[bot] [Fri, 25 Feb 2022 21:17:24 +0000 (21:17 +0000)]
Merge #11538

11538: feat: Make private editable completions configurable, disable by default r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10253
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/9885

This does disable these completions by default, as it seems that people find this behaviour surprising(due to other IDEs usually not doing this).

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agofeat: Make private editable completions configurable, disable by default
Lukas Wirth [Wed, 23 Feb 2022 15:02:54 +0000 (16:02 +0100)]
feat: Make private editable completions configurable, disable by default

2 years agoMerge #11554
bors[bot] [Fri, 25 Feb 2022 18:14:04 +0000 (18:14 +0000)]
Merge #11554

11554: fix: fix type mismatches with `unreachable!` macro in Rust 1.59 r=jonas-schievink a=jonas-schievink

should fix https://github.com/rust-analyzer/rust-analyzer/issues/11551

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2 years agoImplement the new built-in `unreachable!` macro
Jonas Schievink [Fri, 25 Feb 2022 18:13:04 +0000 (19:13 +0100)]
Implement the new built-in `unreachable!` macro

2 years agoMerge #11552
bors[bot] [Fri, 25 Feb 2022 17:41:05 +0000 (17:41 +0000)]
Merge #11552

11552: fix: properly display `$crate` in hovers r=jonas-schievink a=jonas-schievink

We used to print it as `{extern_crate}`, this PR resolves it to the crate's name, or falls back to `$crate` if the crate has no name.

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2 years agoResolve `$crate` in `HirDisplay` of `Path`
Jonas Schievink [Fri, 25 Feb 2022 17:38:51 +0000 (18:38 +0100)]
Resolve `$crate` in `HirDisplay` of `Path`

2 years agoMerge #11550
bors[bot] [Fri, 25 Feb 2022 16:11:22 +0000 (16:11 +0000)]
Merge #11550

11550: Refactor autoderef/method resolution r=flodiebold a=flodiebold

- don't return the receiver type from method resolution; instead just
 return the autorefs/autoderefs that happened and repeat them. This
 ensures all the effects like trait obligations and whatever we learned
 about type variables from derefing them are actually applied. Also, it
 allows us to get rid of `decanonicalize_ty`, which was just wrong in
 principle.

 - Autoderef itself now directly works with an inference table. Sadly
 this has the effect of making it harder to use as an iterator, often
 requiring manual `while let` loops. (rustc works around this by using
 inner mutability in the inference context, so that things like unifying
 types don't require a unique reference.)

 - We now record the adjustments (autoref/deref) for method receivers
 and index expressions, which we didn't before.

 - Removed the redundant crate parameter from method resolution, since
 the trait_env contains the crate as well.

 - in the HIR API, the methods now take a scope to determine the trait env.
 `Type` carries a trait env, but I think that's probably a bad decision
 because it's easy to create it with the wrong env, e.g. by using
 `Adt::ty`. This mostly didn't matter so far because
 `iterate_method_candidates` took a crate parameter and ignored
 `self.krate`, but the trait env would still have been wrong in those
 cases, which I think would give some wrong results in some edge cases.

Fixes #10058.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2 years agoAvoid autoderef coercions leaking if they don't apply
Florian Diebold [Fri, 25 Feb 2022 14:46:02 +0000 (15:46 +0100)]
Avoid autoderef coercions leaking if they don't apply

2 years agoMerge #11549
bors[bot] [Fri, 25 Feb 2022 13:34:18 +0000 (13:34 +0000)]
Merge #11549

11549: feat: support concat_bytes r=jonas-schievink a=ihciah

Support `concat_bytes`.
Solve #11544.

Co-authored-by: ihciah <ihciah@gmail.com>
2 years agoFix unreachable pub
Florian Diebold [Fri, 25 Feb 2022 11:09:49 +0000 (12:09 +0100)]
Fix unreachable pub

2 years agoMerge #11548
bors[bot] [Fri, 25 Feb 2022 10:57:24 +0000 (10:57 +0000)]
Merge #11548

11548: Add CSV output to analysis-stats r=flodiebold a=flodiebold

For easy diffing, to find changes in unknown types / type mismatches.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2 years agoRefactor autoderef and method resolution
Florian Diebold [Wed, 16 Feb 2022 16:44:03 +0000 (17:44 +0100)]
Refactor autoderef and method resolution

 - don't return the receiver type from method resolution; instead just
 return the autorefs/autoderefs that happened and repeat them. This
 ensures all the effects like trait obligations and whatever we learned
 about type variables from derefing them are actually applied. Also, it
 allows us to get rid of `decanonicalize_ty`, which was just wrong in
 principle.

 - Autoderef itself now directly works with an inference table. Sadly
 this has the effect of making it harder to use as an iterator, often
 requiring manual `while let` loops. (rustc works around this by using
 inner mutability in the inference context, so that things like unifying
 types don't require a unique reference.)

 - We now record the adjustments (autoref/deref) for method receivers
 and index expressions, which we didn't before.

 - Removed the redundant crate parameter from method resolution, since
 the trait_env contains the crate as well.

 - in the HIR API, the methods now take a scope to determine the trait env.
 `Type` carries a trait env, but I think that's probably a bad decision
 because it's easy to create it with the wrong env, e.g. by using
 `Adt::ty`. This mostly didn't matter so far because
 `iterate_method_candidates` took a crate parameter and ignored
 `self.krate`, but the trait env would still have been wrong in those
 cases, which I think would give some wrong results in some edge cases.

Fixes #10058.

2 years agoAdd some tests
Florian Diebold [Sun, 5 Sep 2021 14:40:46 +0000 (16:40 +0200)]
Add some tests

2 years agofeat: support concat_bytes
ihciah [Fri, 25 Feb 2022 10:46:11 +0000 (18:46 +0800)]
feat: support concat_bytes

2 years agoAdd CSV output to analysis-stats
Florian Diebold [Thu, 24 Feb 2022 19:44:26 +0000 (20:44 +0100)]
Add CSV output to analysis-stats

For easy diffing.

2 years agoMerge #11462
bors[bot] [Thu, 24 Feb 2022 20:59:27 +0000 (20:59 +0000)]
Merge #11462

11462: 11422 highlight continue and break r=Veykril a=HansAuger

Closes #11422

Co-authored-by: Moritz Vetter <mv@3yourmind.com>
2 years agorefactor(11422): make number unsigned, nest enums into each other
Moritz Vetter [Thu, 24 Feb 2022 20:29:26 +0000 (21:29 +0100)]
refactor(11422): make number unsigned, nest enums into each other

2 years agofix(11422): have two different funuctions - one for iterating breaks, one for iteraat...
Moritz Vetter [Thu, 24 Feb 2022 17:56:08 +0000 (18:56 +0100)]
fix(11422): have two different funuctions - one for iterating breaks, one for iteraating breaks and continues

2 years agoadd logic to highlight continue and break keywords according to expectations
Moritz Vetter [Sun, 13 Feb 2022 11:48:04 +0000 (12:48 +0100)]
add logic to highlight continue and break keywords according to expectations

2 years agorefactor helper function to work with function taking expression enum instead of...
Moritz Vetter [Sun, 13 Feb 2022 11:04:51 +0000 (12:04 +0100)]
refactor helper function to work with function taking expression enum instead of break expression

2 years agoadd some breaking tests (TDD - style)
Moritz Vetter [Sun, 13 Feb 2022 03:05:52 +0000 (04:05 +0100)]
add some breaking tests (TDD - style)

2 years agoMerge #11531
bors[bot] [Thu, 24 Feb 2022 12:57:51 +0000 (12:57 +0000)]
Merge #11531

11531: fix: Make fill_match_arms assist handle doc(hidden) and non_exhaustive r=Veykril a=OleStrohm

Fixes #11499
Fixes #11500
This keeps track of the relevant attributes and adds in a wildcard pat at the end of the match when necessary.

I decided to do them in the same PR since they both needed the ability to add a wildcard arm, and so their changes would overlap if done separately, but I'll split them up if that seems better.

This is my first PR to rust-analyzer, so all feedback is greatly appreciated!

Co-authored-by: Ole Strohm <strohm99@gmail.com>
2 years agoMerge #11540
bors[bot] [Thu, 24 Feb 2022 11:25:18 +0000 (11:25 +0000)]
Merge #11540

11540: fix: Resolve private fields in type inference r=flodiebold a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10253#issuecomment-920962927
(the same issue probably exists for method calls, but I think fixing that might be trickier)

Visibility checks were introduced in https://github.com/rust-analyzer/rust-analyzer/issues/7841 for autoderef to work properly, so now we just record the first field we find unconditionally, and then overwrite it if autoderef manages to find another field in a later cycle.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoMerge #11545
bors[bot] [Thu, 24 Feb 2022 10:14:36 +0000 (10:14 +0000)]
Merge #11545

11545: add `is_slice` method to `hir::Type` r=flodiebold a=nerdypepper

would like to have this on `hir::Type` for a small project i am working on, unless there is another way to check if `hir::Type` is a slice primitive?

Co-authored-by: Akshay <nerdy@peppe.rs>
2 years agoadd `is_slice` method to `hir::Type`
Akshay [Thu, 24 Feb 2022 09:50:12 +0000 (15:20 +0530)]
add `is_slice` method to `hir::Type`

2 years agoIgnore doc(hidden) for crate-local enums
Ole Strohm [Wed, 23 Feb 2022 18:08:18 +0000 (18:08 +0000)]
Ignore doc(hidden) for crate-local enums

2 years agofix: Resolve private fields in type inference
Lukas Wirth [Wed, 23 Feb 2022 15:45:58 +0000 (16:45 +0100)]
fix: Resolve private fields in type inference

2 years agoSimplify
Lukas Wirth [Wed, 23 Feb 2022 15:29:33 +0000 (16:29 +0100)]
Simplify

2 years agoMerge #11539
bors[bot] [Wed, 23 Feb 2022 15:05:22 +0000 (15:05 +0000)]
Merge #11539

11539: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoSimplify
Lukas Wirth [Wed, 23 Feb 2022 14:55:06 +0000 (15:55 +0100)]
Simplify

2 years agoMerge #11537
bors[bot] [Wed, 23 Feb 2022 11:01:06 +0000 (11:01 +0000)]
Merge #11537

11537: internal: Reduce visibility of proc-macros to pub(crate) r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoReduce visibility of proc-macros to pub(crate)
Lukas Wirth [Wed, 23 Feb 2022 10:57:11 +0000 (11:57 +0100)]
Reduce visibility of proc-macros to pub(crate)

2 years agoMerge #11536
bors[bot] [Wed, 23 Feb 2022 10:32:15 +0000 (10:32 +0000)]
Merge #11536

11536: internal: Resolve functions as proc-macros via `FileAstId` r=Veykril a=Veykril

cc https://github.com/rust-analyzer/rust-analyzer/issues/11528
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoResolve functions as proc-macros via FileAstId
Lukas Wirth [Wed, 23 Feb 2022 10:21:46 +0000 (11:21 +0100)]
Resolve functions as proc-macros via FileAstId

2 years agoMerge #11535
bors[bot] [Wed, 23 Feb 2022 07:59:13 +0000 (07:59 +0000)]
Merge #11535

11535: Add Kakoune and Helix configuration r=lnicola a=woshilapin

Follow-up of https://github.com/rust-analyzer/rust-analyzer.github.io/pull/181
Fixes https://github.com/rust-analyzer/rust-analyzer.github.io/pull/180

cc `@lnicola`

Co-authored-by: Jean SIMARD <woshilapin@tuziwo.info>
2 years agoAdd Kakoune and Helix configuration
Jean SIMARD [Wed, 23 Feb 2022 07:55:16 +0000 (08:55 +0100)]
Add Kakoune and Helix configuration

Follow-up of rust-analyzer/rust-analyser.github.io#181
Fixes rust-analyzer/rust-analyser.github.io#180

2 years agoMerge #11534
bors[bot] [Wed, 23 Feb 2022 04:39:42 +0000 (04:39 +0000)]
Merge #11534

11534: minor: Improve instructions for running pre-release versions r=lnicola a=lnicola

Closes #11468

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2 years agoRemove reference to updates.channel from settings
Laurențiu Nicola [Wed, 23 Feb 2022 04:38:01 +0000 (06:38 +0200)]
Remove reference to updates.channel from settings

2 years agoRephrase nightly instructions in the manual
Laurențiu Nicola [Wed, 23 Feb 2022 04:37:16 +0000 (06:37 +0200)]
Rephrase nightly instructions in the manual

2 years agoAdded test
Ole Strohm [Tue, 22 Feb 2022 22:48:44 +0000 (22:48 +0000)]
Added test

2 years agoDedup code
Ole Strohm [Tue, 22 Feb 2022 22:41:03 +0000 (22:41 +0000)]
Dedup code

2 years agoMerge #11461
bors[bot] [Tue, 22 Feb 2022 18:46:12 +0000 (18:46 +0000)]
Merge #11461

11461: Extract struct from enum variant filters generics r=jo-goro a=jo-goro

Fixes #11452.

This PR updates extract_struct_from_enum_variant. Extracting a struct `A` form an enum like
```rust
enum X<'a, 'b> {
    A { a: &'a () },
    B { b: &'b () },
}
```
will now be correctly generated as
```rust
struct A<'a> { a: &'a () }

enum X<'a, 'b> {
    A(A<'a>),
    B { b: &'b () },
}
```
instead of the previous
```rust
struct A<'a, 'b>{ a: &'a () } // <- should not have 'b

enum X<'a, 'b> {
    A(A<'a, 'b>),
    B { b: &'b () },
}
```

This also works for generic type parameters and const generics.

Bounds are also copied, however I have not yet implemented a filter for unneeded bounds. Extracting `B` from the following enum
```rust
enum X<'a, 'b: 'a> {
    A { a: &'a () },
    B { b: &'b () },
}
```
will be generated as
```rust
struct B<'b: 'a> { b: &'b () } // <- should be `struct B<'b> { b: &'b () }`

enum X<'a, 'b: 'a> {
    A { a: &'a () },
    B(B<'b>),
}
```

Extracting bounds with where clauses is also still not implemented.

Co-authored-by: Jonas Goronczy <goronczy.jonas@gmail.com>
2 years agoReplaced fold with for loop
Jonas Goronczy [Tue, 22 Feb 2022 18:38:34 +0000 (19:38 +0100)]
Replaced fold with for loop

2 years agoMerge #11472
bors[bot] [Tue, 22 Feb 2022 18:12:27 +0000 (18:12 +0000)]
Merge #11472

11472: fix: visibility in impl items and pub(crate) to pub in extract_module r=feniljain a=feniljain

Should fix #11007 and #11443

Makes following changes:

- Removes visiblity modifiers from trait items
- Respect user given visibility
- Updated tests for the same

Co-authored-by: vi_mi <fkjainco@gmail.com>
Co-authored-by: vi_mi <49019259+feniljain@users.noreply.github.com>
2 years agochore: reposition comment
vi_mi [Tue, 22 Feb 2022 14:16:50 +0000 (19:46 +0530)]
chore: reposition comment

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agofix: Make match_arms assist handle doc(hidden) and non_exhaustive
Ole Strohm [Tue, 22 Feb 2022 13:59:30 +0000 (13:59 +0000)]
fix: Make match_arms assist handle doc(hidden) and non_exhaustive

2 years agofix: visibility in impl items and pub(crate) to pub in extract_module
vi_mi [Tue, 22 Feb 2022 13:02:36 +0000 (18:32 +0530)]
fix: visibility in impl items and pub(crate) to pub in extract_module

2 years agoMerge #11530
bors[bot] [Tue, 22 Feb 2022 11:33:32 +0000 (11:33 +0000)]
Merge #11530

11530: fix: Fix expand_macro always expanding the first listed derive r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agofix: Fix expand_macro always expanding the first listed derive
Lukas Wirth [Tue, 22 Feb 2022 11:32:15 +0000 (12:32 +0100)]
fix: Fix expand_macro always expanding the first listed derive

2 years agoMerge #11513
bors[bot] [Tue, 22 Feb 2022 10:12:30 +0000 (10:12 +0000)]
Merge #11513

11513: internal: Expand the derive attribute into a pseudo expansion r=Veykril a=Veykril

Quoting my comment:

> We generate a very specific expansion here, as we do not actually expand the `#[derive]` attribute
> itself in name res, but we do want to expand it to something for the IDE layer, so that the input
> derive attributes can be downmapped, and resolved as proper paths.
> This is basically a hack, that simplifies the hacks we need in a lot of ide layer places to
> somewhat inconsistently resolve derive attributes.
>
> As such, we expand `#[derive(Foo, bar::Bar)]` into
> ```
>  #[Foo]
>  #[bar::Bar]
>  ();
> ```
> which allows fallback path resolution in hir::Semantics to properly identify our derives.
> Since we do not expand the attribute in nameres though, we keep the original item.
>
> The ideal expansion here would be for the `#[derive]` to re-emit the annotated item and somehow
> use the input paths in its output as well.
> But that would bring two problems with it, for one every derive would duplicate the item token tree
> wasting a lot of memory, and it would also require some way to use a path in a way that makes it
> always resolve as a derive without nameres recollecting them.
> So this hacky approach is a lot more friendly for us, though it does require a bit of support in
> [`hir::Semantics`] to make this work.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoupdate references::derive test output
Lukas Wirth [Tue, 22 Feb 2022 09:52:35 +0000 (10:52 +0100)]
update references::derive test output

2 years agosimplify and document
Lukas Wirth [Tue, 22 Feb 2022 09:45:29 +0000 (10:45 +0100)]
simplify and document

2 years agoSimplify
Lukas Wirth [Mon, 21 Feb 2022 12:34:05 +0000 (13:34 +0100)]
Simplify

2 years agoFix syntax highlighting not highlighting derives anymore
Lukas Wirth [Mon, 21 Feb 2022 12:21:25 +0000 (13:21 +0100)]
Fix syntax highlighting not highlighting derives anymore

2 years agoMake replace_derive_with_manual_impl work again
Lukas Wirth [Mon, 21 Feb 2022 11:57:57 +0000 (12:57 +0100)]
Make replace_derive_with_manual_impl work again

2 years agoFix `expand_macro` not working for derive attributes
Lukas Wirth [Mon, 21 Feb 2022 10:51:53 +0000 (11:51 +0100)]
Fix `expand_macro` not working for derive attributes

2 years agointernal: Expand the derive attribute into a pseudo expansion
Lukas Wirth [Mon, 21 Feb 2022 01:42:58 +0000 (02:42 +0100)]
internal: Expand the derive attribute into a pseudo expansion

2 years agoMerge #11527
bors[bot] [Tue, 22 Feb 2022 09:08:22 +0000 (09:08 +0000)]
Merge #11527

11527: internal: Split unresolve proc-macro error out of mbe r=Veykril a=Veykril

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agointernal: Split unresolve proc-macro error out of mbe
Lukas Wirth [Mon, 21 Feb 2022 18:14:06 +0000 (19:14 +0100)]
internal: Split unresolve proc-macro error out of mbe

2 years agoMerge #11525
bors[bot] [Tue, 22 Feb 2022 08:56:34 +0000 (08:56 +0000)]
Merge #11525

11525: fix(assist): Drop generic args in path before insert use in `replace_qualified_name_with_use` r=Veykril a=tysg

Fixes #11505. also removed an unnecessary `clone_for_update` call.

Co-authored-by: Tianyi Song <42670338+tysg@users.noreply.github.com>
2 years agoMerge #11524
bors[bot] [Tue, 22 Feb 2022 08:38:57 +0000 (08:38 +0000)]
Merge #11524

11524: doc: state that only the latest stable toolchain is supported r=lnicola a=jtroo

This closes #11226. The content seemed to make more sense in the
installation section as opposed to the Troubleshooting section.

Co-authored-by: Jan Tache <j.andreitabs@gmail.com>
2 years agoDrop generic args in path before insert use
Tianyi Song [Fri, 28 Jan 2022 08:15:23 +0000 (16:15 +0800)]
Drop generic args in path before insert use

2 years agoChange Rust Analyzer->rust-analyzer to match style
Jan Tache [Tue, 22 Feb 2022 07:01:05 +0000 (23:01 -0800)]
Change Rust Analyzer->rust-analyzer to match style

2 years agodoc: state that only the latest stable toolchain is supported
Jan Tache [Tue, 22 Feb 2022 06:37:19 +0000 (22:37 -0800)]
doc: state that only the latest stable toolchain is supported

This closes #11226. The content seemed to make more sense in the
installation section as opposed to the Troubleshooting section.

2 years agoRemoves ExtractedGenerics struct
Jonas Goronczy [Mon, 21 Feb 2022 22:00:16 +0000 (23:00 +0100)]
Removes ExtractedGenerics struct

2 years agoMerge #11490
bors[bot] [Mon, 21 Feb 2022 21:57:44 +0000 (21:57 +0000)]
Merge #11490

11490: Correctly fix formatting doc tests with generics r=Veykril a=KarlWithK

Before the doc_test would be outputted like this:
```zsh
"Foo<T, U>::t"
```
However, this would cause problems with shell redirection. I've changed it
so when generics are involved we simply wrap the expression under quotes as so:
```zsh
"\"Foo<T, U>::t\""
```

Note:
At the cost of adding this, I had to allocate a new string via
`format!{}`. However, I argue this is alright as this for just for
outputting the name of the doc test.

The following tests have been changed:
```
runnables::tests::doc_test_type_params
runnables::tests::test_doc_runnables_impl_mod
runnables::tests::test_runnables_doc_test_in_impl
```

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

Co-authored-by: KarlWithK <jocelinc60@outlook.com>
Co-authored-by: SeniorMars <jocelinc60@outlook.com>
2 years agoUpdate crates/ide/src/runnables.rs
SeniorMars [Mon, 21 Feb 2022 21:23:09 +0000 (15:23 -0600)]
Update crates/ide/src/runnables.rs

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoCleanup
Jonas Goronczy [Mon, 21 Feb 2022 18:51:09 +0000 (19:51 +0100)]
Cleanup

2 years agoMerge #11522
bors[bot] [Mon, 21 Feb 2022 17:08:19 +0000 (17:08 +0000)]
Merge #11522

11522: fix: Make code lenses work on attributed items r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agofix: Make code lenses work on attributed items
Lukas Wirth [Mon, 21 Feb 2022 17:07:47 +0000 (18:07 +0100)]
fix: Make code lenses work on attributed items

2 years agoMerge #11455
bors[bot] [Mon, 21 Feb 2022 16:56:37 +0000 (16:56 +0000)]
Merge #11455

11455: Handle proc-macro functions as the proc-macro they resolve to r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agoMove fn to proc-macro conversion to name classification
Lukas Wirth [Mon, 21 Feb 2022 16:56:11 +0000 (17:56 +0100)]
Move fn to proc-macro conversion to name classification

2 years agoMerge #11481
bors[bot] [Mon, 21 Feb 2022 13:08:31 +0000 (13:08 +0000)]
Merge #11481

11481: Display parameter names when hovering over a function pointer r=Veykril a=Vannevelj

Implements #11474

The idea is pretty straightforward: previously we constructed the hover based on just the parameter types, now we pass in the parameter names as well. I went for a quick-hit approach here but I expect someone will be able to point me to a better way of resolving the identifier.

I haven't figured out yet how to actually run my rust-analyzer locally so I can see it in action but the unit test indicates it should work.

Co-authored-by: Jeroen Vannevel <jer_vannevel@outlook.com>
2 years agoMerge #11517
bors[bot] [Mon, 21 Feb 2022 12:52:11 +0000 (12:52 +0000)]
Merge #11517

11517: fix: Fix qualfiied record literal completion triggering too eagerly r=Veykril a=Veykril

Supercedes https://github.com/rust-analyzer/rust-analyzer/pull/10909
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10889
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 years agofix: Fix qualfiied record literal completion triggering too eagerly
Lukas Wirth [Mon, 21 Feb 2022 12:50:16 +0000 (13:50 +0100)]
fix: Fix qualfiied record literal completion triggering too eagerly

2 years agoMerge #11516
bors[bot] [Mon, 21 Feb 2022 12:44:10 +0000 (12:44 +0000)]
Merge #11516

11516: fix: Don't count commas when looking for the derive attribute in diagnostics r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>