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 #122981

Closed
wants to merge 98 commits into from
Closed

Conversation

lnicola
Copy link
Member

@lnicola lnicola commented Mar 24, 2024

r? ghost

Jesse-Bakker and others added 30 commits March 13, 2024 18:02
fix: Ignore some warnings if they originate from within macro expansions

These tend to be annoying noise as we can't handle `allow`s for them properly for the time being.
Bump dependencies and use in-tree `rustc_pattern_analysis`

One last `pattern_analysis` API change. I don't have any more planned! So we can now use the in-tree version when available.
fix: handle attributes when typing curly bracket

fix rust-lang#16848.

When inserting a `{`, if it is identified that the front part of `expr` is `attr`, we consider it as inserting `{}` around the entire `expr` (excluding the attr part).
…illa

Fix panic with impl trait associated types in where clause

Not sure if this is the correct fix, but the tests are green :')

Fixes rust-lang#16823
… r=Veykril

Refactor extension to support arbitrary shell command runnables

Currently, the extension assumes that all runnables invoke cargo. Arguments are sometimes full CLI arguments, and sometimes arguments passed to a cargo subcommand.

Refactor the extension so that tasks are just a `program` and a list of strings `args`, and rename `CargoTask` to `RustTask` to make it generic.

(This was factored out of rust-lang#16135 and tidied.)
fix: Make inlay hint resolving work better for inlays targetting the same position
bors and others added 22 commits March 21, 2024 15:58
fix: Fix projects depending on `rustc_private` hanging

If loading the root fails, we'll hang up in this loop as we never inserted the entry that asserts we already visited a package. This fixes that
Fixes rust-lang/rust-analyzer#16902
…, r=Veykril

Have Derive Attribute share a token tree with it's proc macros.

The goal of this PR is to stop creating a token tree for each derive proc macro.

This is done by giving the derive proc macros an id to its parent derive element.

From running the analysis stat on the rust analyzer project I did see a small memory decrease.

```
Inference:           42.80s, 362ginstr, 591mb
MIR lowering:        8.67s, 67ginstr, 291mb
Mir failed bodies: 18 (0%)
Data layouts:        85.81ms, 609minstr, 8mb
Failed data layouts: 135 (6%)
Const evaluation:    440.57ms, 5235minstr, 13mb
Failed const evals: 1 (0%)
Total:               64.16s, 552ginstr, 1731mb
```
After Change
```
Inference:           40.32s, 340ginstr, 593mb
MIR lowering:        7.95s, 62ginstr, 292mb
Mir failed bodies: 18 (0%)
Data layouts:        87.97ms, 591minstr, 8mb
Failed data layouts: 135 (6%)
Const evaluation:    433.38ms, 5226minstr, 14mb
Failed const evals: 1 (0%)
Total:               60.49s, 523ginstr, 1680mb
```

Currently this breaks the expansion for the actual derive attribute.

## TODO
- [x] Pick a better name for the function `smart_macro_arg`
fix: Some file watching related vfs fixes

Fixes rust-lang/rust-analyzer#15554, additionally it seems that client side file watching was broken on windows this entire time, this PR switches `DidChangeWatchedFilesRegistrationOptions` to use relative glob patterns which do work on windows in VSCode.
fix: Don't assert paths being utf8 when filtering them in the watcher

Closes rust-lang/rust-analyzer#16914
fix: handle self::super when lowering UseTree

fix rust-lang#16800.
internal: Rename ProcMacroKind::FuncLike to Bang
fix: Rename `func_like` to `FuncLike`

Should fix rust-lang#16926. Please check the issue for more information.
internal: Build x86_64-unknown-linux-gnu releases on Rocky Linux 8
@rustbot
Copy link
Collaborator

rustbot commented Mar 24, 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

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 24, 2024
@rust-log-analyzer
Copy link
Collaborator

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
    Checking time v0.3.34
error[E0423]: expected function, tuple struct or tuple variant, found struct `IdxContainer`
   --> crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs:436:35
    |
436 |                         variants: IdxContainer(variants),
    |
   ::: /checkout/compiler/rustc_index/src/vec.rs:42:1
    |
    |
42  | pub struct IndexVec<I: Idx, T> {
    | ------------------------------ `IdxContainer` defined here
help: you might have meant to use an associated function to build this type
    |
436 |                         variants: IdxContainer::new(),
    |                                               ~~~~~~~
    |                                               ~~~~~~~
436 |                         variants: IdxContainer::from_raw(_),
    |                                               ~~~~~~~~~~~~~
436 |                         variants: IdxContainer::with_capacity(_),
    |                                               ~~~~~~~~~~~~~~~~~~
436 |                         variants: IdxContainer::from_elem(_, _),
      and 2 other candidates
help: consider using the `Default` trait
    |
    |
436 |                         variants: <IdxContainer as std::default::Default>::default(),
help: consider importing this tuple struct instead
    |
    |
3   + use ra_ap_rustc_pattern_analysis::index::IdxContainer;


error[E0277]: the trait bound `hir_def::EnumVariantId: rustc_index::Idx` is not satisfied
    |
    |
280 |     type VariantIdx = EnumVariantId;
    |                       ^^^^^^^^^^^^^ the trait `rustc_index::Idx` is not implemented for `hir_def::EnumVariantId`
    = help: the following other types implement trait `rustc_index::Idx`:
              usize
              u32
              rustc_query_system::dep_graph::graph::DepNodeIndex
              rustc_query_system::dep_graph::graph::DepNodeIndex
              rustc_errors::codes::ErrCode
              rustc_type_ir::ty_kind::TyVid
              rustc_type_ir::ty_kind::IntVid
              rustc_type_ir::ty_kind::FloatVid
              rustc_query_system::dep_graph::serialized::SerializedDepNodeIndex
note: required by a bound in `rustc_pattern_analysis::PatCx::VariantIdx`
   --> /checkout/compiler/rustc_pattern_analysis/src/lib.rs:99:30
    |
    |
99  |     type VariantIdx: Clone + index::Idx + fmt::Debug;
    |                              ^^^^^^^^^^ required by this bound in `PatCx::VariantIdx`
error[E0050]: method `write_variant_name` has 2 parameters but the declaration in trait `write_variant_name` has 3
   --> crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs:453:12
    |
453 |           f: &mut fmt::Formatter<'_>,
453 |           f: &mut fmt::Formatter<'_>,
    |  ____________^
454 | |         pat: &rustc_pattern_analysis::pat::DeconstructedPat<Self>,
    |
    |
    = note: `write_variant_name` from trait: `fn(&mut Formatter<'_>, &Constructor<Self>, &<Self as PatCx>::Ty) -> std::result::Result<(), std::fmt::Error>`
error[E0004]: non-exhaustive patterns: `&Constructor::Never` not covered
   --> crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs:332:43
    |
    |
332 |         let tys: SmallVec<[_; 2]> = match ctor {
    |                                           ^^^^ pattern `&Constructor::Never` not covered
    |
note: `Constructor<MatchCheckCtx<'_>>` defined here
    |
    |
651 | pub enum Constructor<Cx: PatCx> {
...
683 |     Never,
    |     ----- not covered
    |     ----- not covered
    = note: the matched value is of type `&Constructor<MatchCheckCtx<'_>>`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
388 ~             },
389 +             &Constructor::Never => todo!()
    |

---
    |
222 |         let kind = match pat.ctor() {
    |                          ^^^^^^^^^^ pattern `&Constructor::Never` not covered
    |
note: `Constructor<MatchCheckCtx<'_>>` defined here
    |
    |
651 | pub enum Constructor<Cx: PatCx> {
...
683 |     Never,
    |     ----- not covered
    |     ----- not covered
    = note: the matched value is of type `&Constructor<MatchCheckCtx<'_>>`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
271 ~             },
272 +             &Constructor::Never => todo!()
    |


error[E0004]: non-exhaustive patterns: `&Constructor::Never` not covered
   --> crates/hir-ty/src/diagnostics/match_check/pat_analysis.rs:297:15
    |
297 |         match ctor {
    |               ^^^^ pattern `&Constructor::Never` not covered
    |
note: `Constructor<MatchCheckCtx<'_>>` defined here
    |
    |
651 | pub enum Constructor<Cx: PatCx> {
...
683 |     Never,
    |     ----- not covered
    |     ----- not covered
    = note: the matched value is of type `&Constructor<MatchCheckCtx<'_>>`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
322 ~             },
323 +             &Constructor::Never => todo!()
    |

@lnicola
Copy link
Member Author

lnicola commented Mar 24, 2024

@Nadrieril I think I'm gonna let you sort this one out. The two IdxContainers are not compatible and there are some API changes in rustc_pattern_analysis.

@lnicola lnicola closed this Mar 24, 2024
@lnicola lnicola deleted the sync-from-ra branch March 24, 2024 06:39
bors added a commit to rust-lang/rust-analyzer that referenced this pull request Mar 25, 2024
Revert to the crates.io version of rustc_pattern_analysis

The API hasn't fully settled yet, and there's an extra wrinkle with `IdxContainer` which blocked the [subtree update](rust-lang/rust#122981). Let's just keep using the crates.io version for a bit longer.

r? `@lnicola`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.