]> git.lizzy.rs Git - rust.git/log
rust.git
3 years agoMerge #8510 #8533
bors[bot] [Thu, 15 Apr 2021 16:42:36 +0000 (16:42 +0000)]
Merge #8510 #8533

8510: Move cursor position when using item movers r=jonas-schievink a=jonas-schievink

This updates the cursor position when moving items around to stay in the same location within the moved node.

I changed the `moveItem` response to `SnippetTextEdit[]`, since that made more sense to me (the file was ignored by the client anyways, since the edits always apply to the current document). It also matches `onEnter`, which seems logical to me, but please let me know if this doesn't make sense.

There's still a bug in the client-side snippet code that will cause the cursor position to be slightly off when moving parameters in the same line (presumably we don't track the column correctly after deleting `$0`). Not really sure how to fix that immediately, but this PR should already be an improvement despite that bug.

8533: Fix typo in style guide r=jonas-schievink a=jonas-schievink

Fixes bold text rendering

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoFix typo in style guide
Jonas Schievink [Thu, 15 Apr 2021 16:38:52 +0000 (18:38 +0200)]
Fix typo in style guide

3 years agoMerge #8532
bors[bot] [Thu, 15 Apr 2021 16:32:53 +0000 (16:32 +0000)]
Merge #8532

8532: Make `find_path` tests adhere to style guide r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoMake find_path tests adhere to style guide
Jonas Schievink [Thu, 15 Apr 2021 16:32:19 +0000 (18:32 +0200)]
Make find_path tests adhere to style guide

3 years agoMerge #8529
bors[bot] [Thu, 15 Apr 2021 16:16:10 +0000 (16:16 +0000)]
Merge #8529

8529: minor: notify 5.0.0.pre7 r=kjeremy a=kjeremy

Fixes windows leak: https://github.com/notify-rs/notify/pull/298

Co-authored-by: kjeremy <kjeremy@gmail.com>
3 years agoUpdate license check
kjeremy [Thu, 15 Apr 2021 16:15:23 +0000 (12:15 -0400)]
Update license check

3 years agonotify 5.0.0.pre7
kjeremy [Thu, 15 Apr 2021 15:51:32 +0000 (11:51 -0400)]
notify 5.0.0.pre7

Fixes windows leak: https://github.com/notify-rs/notify/pull/298

3 years agoMerge #8526
bors[bot] [Thu, 15 Apr 2021 08:53:03 +0000 (08:53 +0000)]
Merge #8526

8526: fix: Do not show flyimports in trait or impl declarations r=SomeoneToIgnore a=SomeoneToIgnore

Part of https://github.com/rust-analyzer/rust-analyzer/issues/8518

Removes autoimport suggestions for the case:

> inside trait definitions / impls (trait Trait {$0} / impl Foo {$0}), nothing except the fn, type and const keywords (and the full item completions for trait impls) should appear (currently many types and autoimport suggestions)

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
3 years agoDo not show flyimports in trait or impl declarations
Kirill Bulatov [Thu, 15 Apr 2021 08:50:47 +0000 (11:50 +0300)]
Do not show flyimports in trait or impl declarations

3 years agoMerge #8515
bors[bot] [Wed, 14 Apr 2021 20:53:27 +0000 (20:53 +0000)]
Merge #8515

8515: internal: Profile trait solving for all invocations r=flodiebold a=SomeoneToIgnore

Follow-up of https://github.com/rust-analyzer/rust-analyzer/pull/8514#issuecomment-819610492

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
3 years agoProfile trait solving for all invocations
Kirill Bulatov [Wed, 14 Apr 2021 16:11:17 +0000 (19:11 +0300)]
Profile trait solving for all invocations

3 years agoMerge #8514
bors[bot] [Wed, 14 Apr 2021 14:20:13 +0000 (14:20 +0000)]
Merge #8514

8514: Add more profiling spans into type inference r=matklad a=SomeoneToIgnore

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

I've added a minimal set of spans to remove `???` and showcase the underlying issue:

<img width="1552" alt="image" src="https://user-images.githubusercontent.com/2690773/114722983-f2181900-9d42-11eb-821d-9e93ded5f81f.png">

`db.trait_solve` reliably produces the same timings for the same input in the same place for me, despite supposedly being cached by Salsa.
In my perception, this is a bit odd, so I've decided to stop at this point and discuss it with people with better knowledge on the topic.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
3 years agoBetter places for spans
Kirill Bulatov [Wed, 14 Apr 2021 14:15:37 +0000 (17:15 +0300)]
Better places for spans

3 years agoWe need to go deeper
Kirill Bulatov [Wed, 14 Apr 2021 13:59:08 +0000 (16:59 +0300)]
We need to go deeper

3 years agoAdd a missing span
Kirill Bulatov [Wed, 14 Apr 2021 12:52:56 +0000 (15:52 +0300)]
Add a missing span

3 years agoMove cursor position when using item movers
Jonas Schievink [Tue, 13 Apr 2021 18:32:45 +0000 (20:32 +0200)]
Move cursor position when using item movers

3 years agoMerge #8507
bors[bot] [Tue, 13 Apr 2021 12:34:12 +0000 (12:34 +0000)]
Merge #8507

8507: internal: follow test style guide in typing.rs r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agointernal: follow test style guide in typing.rs
Jonas Schievink [Tue, 13 Apr 2021 12:31:05 +0000 (14:31 +0200)]
internal: follow test style guide in typing.rs

3 years agoMerge #8506
bors[bot] [Tue, 13 Apr 2021 12:23:37 +0000 (12:23 +0000)]
Merge #8506

8506: crossbeam-channel 0.5.1 r=kjeremy a=kjeremy

Fixes a potential memory leak in unbound channels.

Co-authored-by: kjeremy <kjeremy@gmail.com>
3 years agocrossbeam-channel 0.5.1
kjeremy [Tue, 13 Apr 2021 12:19:47 +0000 (08:19 -0400)]
crossbeam-channel 0.5.1

Fixes a potential memory leak in unbound channels.

3 years agoMerge #8504
bors[bot] [Tue, 13 Apr 2021 12:14:16 +0000 (12:14 +0000)]
Merge #8504

8504: decl_check: follow test style guide r=jonas-schievink a=jonas-schievink

changelog skip

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agodecl_check: follow test style guide
Jonas Schievink [Tue, 13 Apr 2021 12:13:35 +0000 (14:13 +0200)]
decl_check: follow test style guide

3 years agoMerge #8432
bors[bot] [Tue, 13 Apr 2021 12:02:26 +0000 (12:02 +0000)]
Merge #8432

8432: decl_check: consider outer scopes' allows r=jonas-schievink a=lf-

Fix #8417. Also makes it less noisy about no_mangle annotated stuff the
user can do nothing about.

Note: this still is broken with bitfield! macros. A repro in an ignore
test is included here. I believe this bug is elsewhere, and I don't
think I can work around it here.

I would like help filing the remaining bug, as it does actually affect
users, but I don't know how to describe the behaviour (or even if it
is unintended).

Co-authored-by: Jade <software@lfcode.ca>
3 years agoMerge #8354
bors[bot] [Tue, 13 Apr 2021 11:46:23 +0000 (11:46 +0000)]
Merge #8354

8354: Distinguishing between different operators in semantic highlighting r=matklad a=chetankhilosiya

Co-authored-by: Chetan Khilosiya <chetan.khilosiya@gmail.com>
3 years agoMerge #8415
bors[bot] [Tue, 13 Apr 2021 11:39:03 +0000 (11:39 +0000)]
Merge #8415

8415: Fix faulty assertion when extracting function with macro call r=matklad a=brandondong

**Reproduction:**
```rust
fn main() {
    let n = 1;
    let k = n * n;
    dbg!(n);
}
```
1. Select the second and third lines of the main function. Use the "Extract into function" code assist.
2. Panic occurs in debug, error is logged in release: "[ERROR ide_assists::handlers::extract_function] assertion failed: matches!(path, ast :: Expr :: PathExpr(_))".
3. Function generates successfully on release where the panic was bypassed.
```rust
fn fun_name(n: i32) {
    let k = n * n;
    dbg!(n);
}
```

**Cause:**
- The generated function will take `n` as a parameter. The extraction logic needs to search the usages of `n` to determine whether it is used mutably or not. The helper `path_element_of_reference` is called for each usage but the second usage is a macro call and fails the `Expr::PathExpr(_)` match assertion.
- The caller of `path_element_of_reference` does implicitly assume it to be a `Expr::PathExpr(_)` in how it looks at its parent node for determining whether it is used mutably. This logic will not work for macros.
- I'm not sure if there are any other cases besides macros where it could be something other than a `Expr::PathExpr(_)`. I tried various examples and could not find any.

**Fix:**
- Update assertion to include the macro case.
- Add a FIXME to properly handle checking if a macro usage requires mutable access. For now, return false instead of running the existing logic that is tailored for `Expr::PathExpr(_)`'s.

Co-authored-by: Brandon <brandondong604@hotmail.com>
3 years agoMerge #8489
bors[bot] [Tue, 13 Apr 2021 10:06:36 +0000 (10:06 +0000)]
Merge #8489

8489: Indent block expressions on enter r=matklad a=jonas-schievink

This improves on https://github.com/rust-analyzer/rust-analyzer/pull/8388 by also indenting the created block expression on enter.

![on enter](https://user-images.githubusercontent.com/1786438/114444123-cb38d600-9bce-11eb-8af2-8e8d1c0f9908.gif)

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoMerge #8500
bors[bot] [Tue, 13 Apr 2021 09:56:45 +0000 (09:56 +0000)]
Merge #8500

8500: internal: fix flakiness of accidentally quadratic test r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agointernal: fix flakiness of accidentally quadratic test
Aleksey Kladov [Tue, 13 Apr 2021 09:49:10 +0000 (12:49 +0300)]
internal: fix flakiness of accidentally quadratic test

3 years agoMerge #8499
bors[bot] [Tue, 13 Apr 2021 09:23:24 +0000 (09:23 +0000)]
Merge #8499

8499: internal: don't use `#[should_panic]` for tests r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agointernal: don't use `#[should_panic]` for tests
Aleksey Kladov [Tue, 13 Apr 2021 09:20:54 +0000 (12:20 +0300)]
internal: don't use `#[should_panic]` for tests

3 years agoMerge #8498
bors[bot] [Tue, 13 Apr 2021 09:09:24 +0000 (09:09 +0000)]
Merge #8498

8498: feat: improve performance by delaying computation of fixes for diagnostics r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agofeat: improve performance by delaying computation of fixes for diagnostics
Aleksey Kladov [Tue, 13 Apr 2021 08:48:12 +0000 (11:48 +0300)]
feat: improve performance by delaying computation of fixes for diagnostics

3 years agoEnsure that listing&resolving code actions use the same set of actions
Aleksey Kladov [Tue, 13 Apr 2021 08:27:00 +0000 (11:27 +0300)]
Ensure that listing&resolving code actions use the same set of actions

3 years agoaddress review feedback
Jade [Tue, 13 Apr 2021 08:20:00 +0000 (01:20 -0700)]
address review feedback

3 years agoMerge #8494
bors[bot] [Tue, 13 Apr 2021 07:59:36 +0000 (07:59 +0000)]
Merge #8494

8494: internal: unfork code paths for unresolved and resolved assist r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agointernal: unfork code paths for unresolved and resolved assist
Aleksey Kladov [Mon, 12 Apr 2021 20:08:56 +0000 (23:08 +0300)]
internal: unfork code paths for unresolved and resolved assist

3 years agoMerge #8496
bors[bot] [Tue, 13 Apr 2021 06:22:09 +0000 (06:22 +0000)]
Merge #8496

8496: Exclude nightly tag from git describe to fix version string r=lnicola a=lnicola

Otherwise if we run `git describe` on the release day we pick up the `nightly` tag from the previous release.

changelog fix

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
3 years agoExclude nightly tag from git describe to fix version string
Laurențiu Nicola [Tue, 13 Apr 2021 06:20:17 +0000 (09:20 +0300)]
Exclude nightly tag from git describe to fix version string

3 years agoAdd a cov_mark
Jonas Schievink [Mon, 12 Apr 2021 22:51:10 +0000 (00:51 +0200)]
Add a cov_mark

3 years agoSimplify multiline check
Jonas Schievink [Mon, 12 Apr 2021 19:41:44 +0000 (21:41 +0200)]
Simplify multiline check

3 years agoIndent block expressions on enter
Jonas Schievink [Mon, 12 Apr 2021 18:35:38 +0000 (20:35 +0200)]
Indent block expressions on enter

3 years agoMerge #8488
bors[bot] [Mon, 12 Apr 2021 18:26:23 +0000 (18:26 +0000)]
Merge #8488

8488: Fix typo: liner -> linear r=SomeoneToIgnore a=NieDzejkob

:see_no_evil:

Co-authored-by: Jakub Kądziołka <kuba@kadziolka.net>
3 years agoFix typo: liner -> linear
Jakub Kądziołka [Mon, 12 Apr 2021 18:20:25 +0000 (20:20 +0200)]
Fix typo: liner -> linear

:see_no_evil:

3 years agoMerge #8483
bors[bot] [Mon, 12 Apr 2021 16:29:56 +0000 (16:29 +0000)]
Merge #8483

8483: internal: clarify who a rls-2.0 wg r=edwin0cheng a=matklad

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agointernal: clarify who a rls-2.0 wg
Aleksey Kladov [Mon, 12 Apr 2021 16:06:07 +0000 (19:06 +0300)]
internal: clarify who a rls-2.0 wg

3 years agoMerge #8481
bors[bot] [Mon, 12 Apr 2021 14:58:44 +0000 (14:58 +0000)]
Merge #8481

8481: internal: prepare for lazy diagnostics r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agointernal: prepare for lazy diagnostics
Aleksey Kladov [Mon, 12 Apr 2021 14:58:01 +0000 (17:58 +0300)]
internal: prepare for lazy diagnostics

3 years agoMerge #8478
bors[bot] [Mon, 12 Apr 2021 13:20:01 +0000 (13:20 +0000)]
Merge #8478

8478: fix: don't spam repeated error messages when `cargo check` fails r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agofix: don't spam repeated error messages when `cargo check` fails
Aleksey Kladov [Mon, 12 Apr 2021 13:09:21 +0000 (16:09 +0300)]
fix: don't spam repeated error messages when `cargo check` fails

Conceptually, using a *message* here is wrong, because this is a
"status", rather than "point in time" thing. But statuses are an LSP
extension, while messages are stable. As a compromise, send message only
for more critical `metadata` failures, and only once per state change.

3 years agoMerge #8476
bors[bot] [Mon, 12 Apr 2021 12:32:55 +0000 (12:32 +0000)]
Merge #8476

8476: feat: avoid checking the whole project during initial loading r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agofeat: avoid checking the whole project during initial loading
Aleksey Kladov [Mon, 12 Apr 2021 08:04:36 +0000 (11:04 +0300)]
feat: avoid checking the whole project during initial loading

3 years agoAdd macro test
Brandon [Sun, 11 Apr 2021 18:12:02 +0000 (11:12 -0700)]
Add macro test

3 years agoMerge #8469
bors[bot] [Sun, 11 Apr 2021 10:08:30 +0000 (10:08 +0000)]
Merge #8469

8469: Remove assertion in impl collection r=flodiebold a=flodiebold

This condition should always be true for *valid* code, but of course
there might be invalid code or things that we can't currently resolve.

Fixes #8464.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
3 years agoRemove assertion in impl collection
Florian Diebold [Sun, 11 Apr 2021 09:42:54 +0000 (11:42 +0200)]
Remove assertion in impl collection

This condition should always be true for *valid* code, but of course
there might be invalid code or things that we can't currently resolve.

Fixes #8464.

3 years agoMerge #8465
bors[bot] [Sat, 10 Apr 2021 23:42:26 +0000 (23:42 +0000)]
Merge #8465

8465: Include more info in assert r=jonas-schievink a=jonas-schievink

This helped find https://github.com/rust-analyzer/rust-analyzer/issues/8464

changelog skip

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoInclude more info in assert
Jonas Schievink [Sat, 10 Apr 2021 23:41:40 +0000 (01:41 +0200)]
Include more info in assert

3 years agoMerge #8463
bors[bot] [Sat, 10 Apr 2021 23:33:18 +0000 (23:33 +0000)]
Merge #8463

8463: Support macros in pattern position r=jonas-schievink a=jonas-schievink

This was fairly easy, because patterns are limited to bodies, so almost all changes were inside body lowering.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoSupport macros in pattern position
Jonas Schievink [Sat, 10 Apr 2021 21:12:02 +0000 (23:12 +0200)]
Support macros in pattern position

3 years agoMerge #8436
bors[bot] [Sat, 10 Apr 2021 21:35:05 +0000 (21:35 +0000)]
Merge #8436

8436: Fix extract function's mutability of variables outliving the body r=matklad a=brandondong

**Reproduction:**
```rust
fn main() {
    let mut k = 1;
    let mut j = 2;
    j += 1;
    k += j;
}
```
1. Select the first to third lines of the main function. Use the "Extract into function" code assist.
2. The output is the following which does not compile because the outlived variable `k` is declared as immutable:
```rust
fn main() {
    let (k, j) = fun_name();
    k += j;
}

fn fun_name() -> (i32, i32) {
    let mut k = 1;
    let mut j = 2;
    j += 1;
    (k, j)
}
```
3. We would instead expect the output to be:
```rust
fn main() {
    let (mut k, j) = fun_name();
    k += j;
}
```

**Fix:**
- Instead of declaring outlived variables as immutable unconditionally, check for any mutable usages outside of the extracted function.

Co-authored-by: Brandon <brandondong604@hotmail.com>
3 years agoMerge #8460
bors[bot] [Sat, 10 Apr 2021 18:34:59 +0000 (18:34 +0000)]
Merge #8460

8460: Revert "Rewrite `#[derive]` removal code to be based on AST" r=jonas-schievink a=jonas-schievink

It breaks some function-like proc macros: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Proc.20macro.20expansion/near/233971916

It also uses attribute indices incorrectly, which causes insufficient attributes to be removed.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoRevert "Rewrite `#[derive]` removal to be based on AST"
Jonas Schievink [Sat, 10 Apr 2021 18:30:28 +0000 (20:30 +0200)]
Revert "Rewrite `#[derive]` removal to be based on AST"

This reverts commit 7e78aebc8fbbb4043d62949681e4d700f1a2ec46.

3 years agoRevert "Use `pub(crate)`"
Jonas Schievink [Sat, 10 Apr 2021 18:30:24 +0000 (20:30 +0200)]
Revert "Use `pub(crate)`"

This reverts commit c51213c2e7de21b7e68e6773ca3be0cdfc7c18af.

3 years agoRevert "Use `name![derive]`"
Jonas Schievink [Sat, 10 Apr 2021 18:30:19 +0000 (20:30 +0200)]
Revert "Use `name![derive]`"

This reverts commit d6187de4cd34a1288c7820c5477b81b1e9b692a9.

3 years agoMerge #8458
bors[bot] [Sat, 10 Apr 2021 16:06:01 +0000 (16:06 +0000)]
Merge #8458

8458: Respect test style guidelines in tests::traits r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoRespect test style guidelines in tests::traits
Lukas Wirth [Sat, 10 Apr 2021 16:03:27 +0000 (18:03 +0200)]
Respect test style guidelines in tests::traits

3 years agoMerge #8457
bors[bot] [Sat, 10 Apr 2021 15:53:06 +0000 (15:53 +0000)]
Merge #8457

8457: Implement more precise binary op return type heuristic r=flodiebold a=Veykril

Should fix #7150

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoAdd test for binary op return ty with adt
Lukas Wirth [Sat, 10 Apr 2021 15:52:24 +0000 (17:52 +0200)]
Add test for binary op return ty with adt

3 years agoAdd manual ops::Add impls to test::traits::closure_2
Lukas Wirth [Sat, 10 Apr 2021 15:16:35 +0000 (17:16 +0200)]
Add manual ops::Add impls to test::traits::closure_2

3 years agoImplement more precise binary op return type prediction
Lukas Wirth [Sat, 10 Apr 2021 14:56:32 +0000 (16:56 +0200)]
Implement more precise binary op return type prediction

3 years agoMerge #8410
bors[bot] [Sat, 10 Apr 2021 13:07:46 +0000 (13:07 +0000)]
Merge #8410

8410: Use CompletionTextEdit::InsertAndReplace if supported by the client r=Veykril a=Veykril

Fixes #8404, Fixes #3130

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoMerge #8384
bors[bot] [Sat, 10 Apr 2021 10:01:03 +0000 (10:01 +0000)]
Merge #8384

8384: add is quadratic test r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
3 years agoLet's try testing for "is not quadratic" condition
Aleksey Kladov [Tue, 6 Apr 2021 18:59:47 +0000 (21:59 +0300)]
Let's try testing for "is not quadratic" condition

3 years agoMerge #8453
bors[bot] [Fri, 9 Apr 2021 20:52:41 +0000 (20:52 +0000)]
Merge #8453

8453: Avoid an unnecessary `collect` r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoAvoid an unnecessary `collect`
Jonas Schievink [Fri, 9 Apr 2021 20:52:13 +0000 (22:52 +0200)]
Avoid an unnecessary `collect`

3 years agoMerge #8450
bors[bot] [Fri, 9 Apr 2021 15:16:36 +0000 (15:16 +0000)]
Merge #8450

8450: Don't ignore unnamed consts when looking for definitions r=Veykril a=Veykril

Fixes #8448
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
3 years agoInsert unnamed consts to ChildBySource DynMap
Lukas Wirth [Fri, 9 Apr 2021 15:14:48 +0000 (17:14 +0200)]
Insert unnamed consts to ChildBySource DynMap

3 years agoMerge #8447
bors[bot] [Fri, 9 Apr 2021 13:30:12 +0000 (13:30 +0000)]
Merge #8447

8447: Resolve prelude and crate root names in the root DefMap r=jonas-schievink a=jonas-schievink

Should fix https://github.com/rust-analyzer/rust-analyzer/issues/8418

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoResolve prelude and crate root names in the root DefMap
Jonas Schievink [Fri, 9 Apr 2021 13:25:12 +0000 (15:25 +0200)]
Resolve prelude and crate root names in the root DefMap

3 years agoMerge #8443 #8446
bors[bot] [Fri, 9 Apr 2021 12:53:49 +0000 (12:53 +0000)]
Merge #8443 #8446

8443: Rewrite `#[derive]` removal code to be based on AST r=jonas-schievink a=jonas-schievink

We now remove any `#[derive]` before and including the one we want to expand, in the `macro_arg` query.

The same infra will be needed by attribute macros (except we only remove the attribute we're expanding, not any preceding ones).

Part of https://github.com/rust-analyzer/rust-analyzer/issues/8434 (doesn't implement the cfg-expansion yet, because that's more difficult)

8446: Undo path resolution hack for extern prelude r=jonas-schievink a=jonas-schievink

Reverts the change made in https://github.com/rust-analyzer/rust-analyzer/pull/7959

We don't populate the extern prelude for block DefMaps anymore,
so this is unnecessary

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoUse `name![derive]`
Jonas Schievink [Fri, 9 Apr 2021 12:50:42 +0000 (14:50 +0200)]
Use `name![derive]`

3 years agoUndo path resolution hack for extern prelude
Jonas Schievink [Fri, 9 Apr 2021 12:46:52 +0000 (14:46 +0200)]
Undo path resolution hack for extern prelude

We don't populate the extern prelude for block DefMaps anymore,
so this is unnecessary

3 years agoMerge #8445
bors[bot] [Fri, 9 Apr 2021 12:43:48 +0000 (12:43 +0000)]
Merge #8445

8445: `hir_ty` cleanup r=flodiebold a=flodiebold

Move lots of things around within `hir_ty`. Most notably, all the Chalk-related stuff moves from within `traits/` to the top-level, since Chalk isn't purely a "traits thing" anymore.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
3 years agoMore cleanups / module docs
Florian Diebold [Fri, 9 Apr 2021 12:39:07 +0000 (14:39 +0200)]
More cleanups / module docs

3 years agoMore cleanups
Florian Diebold [Fri, 9 Apr 2021 12:33:03 +0000 (14:33 +0200)]
More cleanups

3 years agoMore moving stuff around
Florian Diebold [Fri, 9 Apr 2021 12:28:04 +0000 (14:28 +0200)]
More moving stuff around

3 years agoUse `pub(crate)`
Jonas Schievink [Fri, 9 Apr 2021 12:24:31 +0000 (14:24 +0200)]
Use `pub(crate)`

3 years agoMerge #8444
bors[bot] [Fri, 9 Apr 2021 12:24:03 +0000 (12:24 +0000)]
Merge #8444

8444: Shrink `unlinked-file` diagnostic to 3 characters r=jonas-schievink a=jonas-schievink

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

(the diagnostic fires intentionally on `#[cfg]`d modules, but with this won't cover the whole file)

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
3 years agoShrink `unlinked-file` diagnostic to 3 characters
Jonas Schievink [Fri, 9 Apr 2021 12:22:38 +0000 (14:22 +0200)]
Shrink `unlinked-file` diagnostic to 3 characters

3 years agoMove some more stuff to better places
Florian Diebold [Fri, 9 Apr 2021 12:18:58 +0000 (14:18 +0200)]
Move some more stuff to better places

3 years agoMove ToChalk -> mapping
Florian Diebold [Fri, 9 Apr 2021 12:15:26 +0000 (14:15 +0200)]
Move ToChalk -> mapping

3 years agoReorganize hir_ty modules
Florian Diebold [Fri, 9 Apr 2021 12:11:37 +0000 (14:11 +0200)]
Reorganize hir_ty modules

Chalk isn't really a 'traits' thing anymore, so it doesn't make sense to
have all the Chalk-related stuff in submodules of `traits`.

3 years agoRewrite `#[derive]` removal to be based on AST
Jonas Schievink [Fri, 9 Apr 2021 12:10:54 +0000 (14:10 +0200)]
Rewrite `#[derive]` removal to be based on AST

3 years agoStore `#[derive]` attribute ID along macro invoc
Jonas Schievink [Fri, 9 Apr 2021 11:38:01 +0000 (13:38 +0200)]
Store `#[derive]` attribute ID along macro invoc

3 years agoRename `Attr`s `index` field to `id`
Jonas Schievink [Fri, 9 Apr 2021 11:36:22 +0000 (13:36 +0200)]
Rename `Attr`s `index` field to `id`

3 years agoAdd `AttrId` to track attribute sources
Jonas Schievink [Thu, 8 Apr 2021 17:44:21 +0000 (19:44 +0200)]
Add `AttrId` to track attribute sources

3 years agoMerge #8406
bors[bot] [Fri, 9 Apr 2021 10:45:34 +0000 (10:45 +0000)]
Merge #8406

8406: Improve indexing of impls r=flodiebold a=flodiebold

Store impls for e.g. &Foo with the ones for Foo instead of the big "other" bucket. This can improve performance and simplifies the HIR impl search a bit.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
3 years agoImprove indexing of impls
Florian Diebold [Wed, 7 Apr 2021 17:35:24 +0000 (19:35 +0200)]
Improve indexing of impls

Store impls for e.g. &Foo with the ones for Foo instead of the big
"other" bucket. This can improve performance and simplifies the HIR impl
search a bit.

3 years agoMerge #8440
bors[bot] [Fri, 9 Apr 2021 09:18:42 +0000 (09:18 +0000)]
Merge #8440

8440: Fix crash on syn involving lifetimes returned by Chalk r=flodiebold a=flodiebold

If we get lifetime variables back in autoderef, just immediately replace them by static lifetimes for now. Method resolution doesn't really deal correctly with new variables being introduced (this needs to be fixed more properly).

This fixes `rust-analyzer analysis-stats --with-deps` crashing in the RA repo.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
3 years agoFix crash on syn involving lifetimes returned by Chalk
Florian Diebold [Thu, 8 Apr 2021 21:34:05 +0000 (23:34 +0200)]
Fix crash on syn involving lifetimes returned by Chalk

If we get lifetime variables back in autoderef, just immediately replace
them by static lifetimes for now. Method resolution doesn't really deal
correctly with new variables being introduced (this needs to be fixed
more properly).

This fixes `rust-analyzer analysis-stats --with-deps` crashing in the RA
repo.

3 years agoFix extract function's mutability of variables outliving the body
Brandon [Wed, 7 Apr 2021 05:09:26 +0000 (22:09 -0700)]
Fix extract function's mutability of variables outliving the body