Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subtree update of rust-analyzer #128490

Merged
merged 225 commits into from
Aug 1, 2024
Merged

Subtree update of rust-analyzer #128490

merged 225 commits into from
Aug 1, 2024

Conversation

lnicola
Copy link
Member

@lnicola lnicola commented Aug 1, 2024

r? @ghost

Veykril and others added 30 commits July 12, 2024 16:01
When the user applies the "Extract Variable" assist, the cursor is
positioned at the newly inserted variable. This commit adds a command
to the assist that triggers the rename action in VSCode. This way, the
user can quickly rename the variable after applying the assist.

Fixes part of: rust-lang#17579
- move `edit.rename()` to the end of the function
- use a match statement to set `res.command`
Implement symbol interning infra

Will fix rust-lang/rust-analyzer#15590

My unsafe-fu is not the best but it does satisfy miri.

There is still some follow up work to do, notably a lot of places using strings instead of symbols/names, most notably the token tree.
…=Veykril

Trigger VSCode to rename after extract variable assist is applied

When the user applies the "Extract Variable" assist, the cursor is
positioned at the newly inserted variable. This commit adds a command
to the assist that triggers the rename action in VSCode. This way, the
user can quickly rename the variable after applying the assist.

Fixes part of: rust-lang#17579

https://github.com/user-attachments/assets/4cf38740-ab22-4b94-b0f1-eddd51c26c29

I haven't yet looked at the module or function extraction assists yet.
feat: Add incorrect case diagnostics for enum variant fields and all variables/params

Updates the incorrect case diagnostic to check:

1. Fields of enum variants. Example:
```rust
enum Foo {
    Variant { nonSnake: u8 }
}
```
2. All variable bindings, instead of just let bindings and certain match arm patters. Examples:
```rust
match 1 { nonSnake => () }
match 1 { nonSnake @ 1 => () }
match 1 { nonSnake1 @ nonSnake2 => () } // slightly cursed, but these both introduce new
                                        // bindings that are bound to the same value.

const ONE: i32 = 1;
match 1 { nonSnake @ ONE } //  ONE is ignored since it is not a binding

match Some(1) { Some(nonSnake) => () }

struct Foo { field: u8 }
match (Foo { field: 1 } ) {
    Foo { field: nonSnake } => ();
}

struct Foo { nonSnake: u8 } // diagnostic here, at definition
match (Foo { nonSnake: 1 } ) { // no diagnostic here...
    Foo { nonSnake } => ();    // ...or here, since these are not where the name is introduced
}

for nonSnake in [] {}

struct Foo(u8);
for Foo(nonSnake) in [] {}
```
3. All parameter bindings, instead of just top-level binding identifiers. Examples:
```rust
fn func(nonSnake: u8) {} // worked before

struct Foo { field: u8 }
fn func(Foo { field: nonSnake }: Foo) {} // now get diagnostic for nonSnake
```

This is accomplished by changing the way binding identifier patterns are filtered:
- Previously, all binding idents were skipped, except a few classes of "good" binding locations that were checked.
- Now, all binding idents are checked, except field shorthands which are skipped.

Moving from a whitelist to a blacklist potentially makes the analysis more brittle:
If new pattern types are added in the future where ident pats don't introduce new names, then they may incorrectly create diagnostics.

But the benefit of the blacklist approach is simplicity: I think a whitelist approach would need to recursively visit patterns to collect renaming candidates?
Encode ident rawness and literal kind separately in tt::Leaf
Fix incorrect encoding of literals in the proc-macro-api on version 4

Quick follow up on rust-lang/rust-analyzer#17559 breaking things
Set `RUSTC_TOOLCHAIN` for runnables

With this the client doesn't necessarily need to guess the sysroot anymore
bors and others added 15 commits July 30, 2024 06:49
feat: Introduce workspace `rust-analyzer.toml`s

In order to globally configure a project it was, prior to this PR, possible to have a `ratoml` at the root path of a project. This is not the case anymore. Instead we now let ratoml files that are placed at the root of any workspace have a new scope called `workspace`. Although there is not a difference between a `workspace` scope and and a `global` scope, future PRs will change that.
minor: Set tracing level to debug when `cargo config get env` fails

fixes rust-lang#17739
fix: Errors on method call inferences with elided lifetimes

Fixes rust-lang#17734

Currently, we are matching non-lifetime(type or const) generic arg to liftime argument position while building substs for method calling when there are elided lifetimes.
This mismatch just make a subst for error lifetime and while this alone is not much a trouble, it also makes the mismatched type or const generic arg cannot be used in its proper place and this makes type inference failure
…irement-in-linked-projects, r=Veykril

fix: remove AbsPath requirement from linkedProjects

Should (fingers crossed!) fix rust-lang/rust-analyzer#17664. I opened the `rustc` workspace with the [suggested configuration](https://github.com/rust-lang/rust/blob/e552c168c72c95dc28950a9aae8ed7030199aa0d/src/etc/rust_analyzer_settings.json) and I was able to successfully open some rustc crates (`rustc_incremental`) and have IDE functionality.

`@Veykril:` can you try these changes and let me know if it fixed rustc?
fix: Apply `IndexMut` obligations for non-assigning mutable index usages

Fixes rust-lang#17738

Currently, we are pushing `IndexMut` obligations only for assign usages;
https://github.com/rust-lang/rust-analyzer/blob/f982f3fa2c23570c10108e83c1ecc392ea411866/crates/hir-ty/src/infer/expr.rs#L809-L817
The user does not specify `{arg}` in their JSON, and be pedantic about
commas in JSON sample.
docs: Fix JSON example for rust-analyzer.workspace.discoverConfig

The user does not specify `{arg}` in their JSON, and be pedantic about commas in JSON sample.
when josh-proxy screws up the roundtrip, say what the involved commits are

Helps debugging rust-lang/rust-analyzer#17733
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 1, 2024
@rustbot
Copy link
Collaborator

rustbot commented Aug 1, 2024

rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead.

cc @rust-lang/rust-analyzer

@lnicola
Copy link
Member Author

lnicola commented Aug 1, 2024

@bors r+ p=1 subtree sync

@bors
Copy link
Contributor

bors commented Aug 1, 2024

📌 Commit 9ec4844 has been approved by lnicola

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 1, 2024
@bors
Copy link
Contributor

bors commented Aug 1, 2024

⌛ Testing commit 9ec4844 with merge e60ebb2...

@bors
Copy link
Contributor

bors commented Aug 1, 2024

☀️ Test successful - checks-actions
Approved by: lnicola
Pushing e60ebb2 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 1, 2024
@bors bors merged commit e60ebb2 into rust-lang:master Aug 1, 2024
7 checks passed
@rustbot rustbot added this to the 1.82.0 milestone Aug 1, 2024
@lnicola lnicola deleted the sync-from-ra branch August 1, 2024 15:54
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (e60ebb2): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 756.519s -> 756.054s (-0.06%)
Artifact size: 336.96 MiB -> 336.95 MiB (-0.00%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.