Skip to content

Subtree update of rust-analyzer #130812

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

Merged
merged 220 commits into from
Sep 25, 2024
Merged

Subtree update of rust-analyzer #130812

merged 220 commits into from
Sep 25, 2024

Conversation

lnicola
Copy link
Member

@lnicola lnicola commented Sep 25, 2024

r? @ghost

IvarWithoutBones and others added 30 commits August 27, 2024 14:25
When formatting generated code the xtask crate attempts to run `rustup run stable rustfmt`,
which fails if `rustup` is not installed. This results in test failures when another source manages
the compiler toolchain, for example when using Nix (or any other distro-specific packaging solution):

* xtask::codegen::grammar::test
* xtask::codegen::assists_doc_tests::test

With this commit xtask will first attempt to run `rustup run stable rustfmt`, and if that fails just
plain `rustfmt`. It still validates a stable version is being used.

This allows `cargo test` to pass on systems that do not use `rustup`.
…r=Veykril

fix: do not assume rustup is installed in xtask codegen

When formatting generated code the xtask crate attempts to run `rustup run stable rustfmt`, which fails if `rustup` is not installed. This results in test failures when another source manages the compiler toolchain, for example when using Nix (or any other distro-specific packaging solution):
* xtask::codegen::grammar::test
* xtask::codegen::assists_doc_tests::test

With this PR xtask will first attempt to run `rustup run stable rustfmt`, and if that fails just plain `rustfmt`. It still validates a stable version is being used. This allows `cargo test` to pass on systems that do not use `rustup`.
feat: Implement object safety and its hovering hint

Resolves rust-lang#17779

- [x] Fill missing implementations
- [x] Hover rendering
- [x] Implement object safety's own test suite, like layout
- [x] Add test cases (from rustc maybe)
- [x] Clean up ugly codes
- [x] Add doc string
…impl" assists

This makes the generated impl's indentation match the ADT it targets, improving formatting when
using nested modules inside of the same file or when defining types inside of a function.
…, r=Veykril

fix: consider indentation in the "Generate impl" and "Generate trait impl" assists

This makes the generated impl's indentation match the ADT it targets, improving formatting when using nested modules inside of the same file or when defining types inside of a function. See the added tests for an example.

At first I tried to call some of the convenient helpers that delegate to `IndentLevel::increase_indent` on the generated impl, but as the comment on that function notes it does not indent the first token, making it inapplicable here. I hope the solution in this PR is acceptable, please let me know if I missed something :)
fix: `std::error::Error` is object unsafe

Fixes rust-lang#17998

I tried to get generic predicates of assoc function itself, not inherited from the parent here;

https://github.com/rust-lang/rust-analyzer/blob/0ae42bd42576566540a84c62e118aa823edcf2ec/crates/hir-ty/src/object_safety.rs#L420-L442

But this naive equality check approach doesn't work when the assoc function has one or more generic paramters like;

```rust
trait Foo {}
trait Bar: Foo {
    fn bar(&self);
}
```

because the generic predicates of the parent, `Bar` is `[^1.0 implements Foo]` and the generic predicates of `fn bar` is `[^1.1 implements Foo]`, which are different.

This PR implements a correct logic for filtering out parent generic predicates for this.
…=Veykril

Do not report missing unsafe on `addr_of[_mut]!(EXTERN_OR_MUT_STATIC)`

The compiler no longer does as well; see rust-lang#125834.

Also require unsafe when accessing `extern` `static` (other than by `addr_of!()`).

Fixes rust-lang#17978.
…Veykril

fix(ide-completion): fix handling of `for` in `impl T for A` in function body

Closes rust-lang#17787.
internal: Improve inlay hint resolution reliability

The payload now ships the range the inlay hint ought to be triggered for instead of trying to estimate it from its position which is somewhat brittle
This reverts commit 7d9e4fcc07e5de94e37b73436147cdbbaa35dbdc.
bors and others added 11 commits September 24, 2024 11:01
…Veykril

fix: Fix a bug in span map merge, and add explanations of how span maps are stored

Because it took me hours to figure out that contrary to common sense, the offset stored is the *end* of the node, and we search by the *start*. Which is why we need a convoluted `partition_point()` instead of a simple `binary_search()`. And this was not documented at all. Which made me make mistakes with my implementation of `SpanMap::merge()`.

The other bug fixed about span map merging is correctly keeping track of the current offset in presence of multiple sibling macro invocations. Unrelated, but because of the previous issue it took me hours to debug, so I figured out I'll put them together for posterity.

Fixes rust-lang#18163.
fix: Temporary fix for `remove_unused_imports` not handling import aliases correctly

Fixes rust-lang#18129
Without this, build scripts don't run for tests and as such any proc-macros in dev-deps fail to resolve
…Veykril

fix: Pass all-targets for build scripts in more cli commands

Without this, build scripts don't run for tests and as such any proc-macros in dev-deps fail to resolve
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 25, 2024
@rustbot
Copy link
Collaborator

rustbot commented Sep 25, 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

@workingjubilee
Copy link
Member

   error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead?
    --> crates/mbe/src/lib.rs:12:1
     |
  12 | extern crate rustc_lexer;
     | ^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: see issue #27812 <https://github.com/rust-lang/rust/issues/27812> for more information
     = help: add `#![feature(rustc_private)]` to the crate attributes to enable
     = note: this compiler was built on 2024-09-21; consider upgrading it if it is out of date
  
  error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead?
     --> crates/mbe/src/expander/transcriber.rs:370:21
      |
  370 |                 if !rustc_lexer::is_ident(&concatenated) {
      |                     ^^^^^^^^^^^^^^^^^^^^^
      |

huh.

@rust-log-analyzer

This comment has been minimized.

@lnicola
Copy link
Member Author

lnicola commented Sep 25, 2024

@bors r+ p=1 subtree sync

@bors
Copy link
Collaborator

bors commented Sep 25, 2024

📌 Commit 35bc50f 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 Sep 25, 2024
@bors
Copy link
Collaborator

bors commented Sep 25, 2024

⌛ Testing commit 35bc50f with merge b511753...

@bors
Copy link
Collaborator

bors commented Sep 25, 2024

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 25, 2024
@bors bors merged commit b511753 into rust-lang:master Sep 25, 2024
7 checks passed
@rustbot rustbot added this to the 1.83.0 milestone Sep 25, 2024
@lnicola lnicola deleted the sync-from-ra branch September 25, 2024 17:03
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b511753): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.4% [-0.4%, -0.4%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.4% [-0.4%, -0.4%] 1

Max RSS (memory usage)

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

Cycles

Results (primary 2.4%, secondary -2.5%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
2.4% [2.4%, 2.4%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.5% [-3.7%, -1.9%] 7
All ❌✅ (primary) 2.4% [2.4%, 2.4%] 1

Binary size

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

Bootstrap: 771.82s -> 769.756s (-0.27%)
Artifact size: 340.87 MiB -> 340.86 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.