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

⬆️ rust-analyzer #102912

Merged
merged 111 commits into from
Oct 11, 2022
Merged

⬆️ rust-analyzer #102912

merged 111 commits into from
Oct 11, 2022

Conversation

lnicola
Copy link
Member

@lnicola lnicola commented Oct 11, 2022

r? @ghost

lowr and others added 30 commits September 9, 2022 16:47
Simplify feature representation in CargoConfig
Remove reference to Toggle inlay hints

This simply removes the reference to the `Toggle inlay hints` action after its removal in rust-lang/rust-analyzer#13215.
In fact, this reference is still visible [in the User Manual here](https://rust-analyzer.github.io/manual.html#inlay-hints).
…ykril

Ensure at least one trait bound in `TyKind::DynTy`

One would expect `TyKind::DynTy` to have at least one trait bound, but we may produce a dyn type with no trait bounds at all. This patch prevents it by returning `TyKind::Error` in such cases.

An "empty" dyn type would have caused panic during method resolution without rust-lang#13257. Although already fixed, I think an invariant to never produce such types would help prevent similar problems in the future.
feat: Display the value of enum variant on hover

fixes rust-lang#12955

This PR adds const eval support for enums, as well as showing their value on hover, just as consts currently have.

I developed these two things at the same time, but I've realized now that they are separate. However since the hover is just a 10 line change (not including tests), I figured I may as well put them in the same PR. Though if you want them split up into "enum const eval support"  and "show enum variant value on hover", I think that's reasonable too.

Since this adds const eval support for enums this also allows consts that reference enums to have their values computed now too.

The const evaluation itself is quite rudimentary, it doesn't keep track of the actual type of the enum, but it turns out that Rust doesn't actually either, and `E::A as u8` is valid regardless of the `repr` on `E`.

It also doesn't really care about what expression the enum variant contains, it could for example be a string, despite that not being allowed, but I guess it's up to the `cargo check` diagnostics to inform of such issues anyway?
bors and others added 17 commits October 3, 2022 12:05
…, r=Veykril

internal: change generic parameter order

tl;dr: This PR changes the `Substitution` for trait items and methods like so:

```rust
trait Trait<TP, const CP: usize> { // note the implicit Self as first parameter
  type Type<TC, const CC: usize>;
  fn f<TC, const CC: usize>() {}
}
impl<TP, const CP: usize> S {
  fn f<TC, const CC: usize>() {}
}
```

- before this PR: `[Self, TP, CP, TC, CC]` for each trait item, `[TP, CP, TC, CC]` for `S::f`
- after this PR: `[TC, CC, Self, TP, CP]` for each trait item, `[TC, CC, TP, CP]` for `S::f`

---

This PR "inverts" the generic parameters/arguments of an item and its parent. This is to fulfill [chalk's expectation](https://github.com/rust-lang/chalk/blob/d875af0ff196dd6430b5f5fd87a640fa5ab59d1e/chalk-solve/src/rust_ir.rs#L498-L502) on the order of generic arguments in `Substitution`s for generic associated types and it's one step forward for GATs support (hopefully). Although chalk doesn't put any constraint for other items, it feels more natural to get everything aligned than special casing GATs.

One complication is that `TyBuilder` now demands its users to pass in parent's `Substitution` upon construction unless it's obvious that the the item has no parent (e.g. an ADT never has parent). All users *should* already know the parent of the item in question, and without this, it cannot be easily reasoned about whether we're pushing the argument for the item or for its parent.

Some additional notes:
- f8f5a5e: This isn't related to the change, but I felt it's nicer.

- 78977cd: There's one major change here other than the generic param order: Default arguments are now bound by the same `Binder` as the item in question rather than a `Binder` limited to parameters they can refer to (i.e. arguments that syntactically appear before them). Now that the order of generic parameters is changed, it would be somewhat complicated to make such `Binder`s as before, and the "full" `Binder`s shouldn't be a problem because we already make sure that the default arguments don't refer to the generic arguments after them with `fallback_bound_vars()`.

- 7556f74: This is split from 4385d3d to make it easy to revert if it turns out that the GATs with const generics panic is actually not resolved with this PR. cc rust-lang#11878 rust-lang#11957
…, r=Veykril

fix: treat enum variants as generic item on their own

Fixup for rust-lang#13335

It turns out I tried to merge two procedures into one utility function without noticing the incompatibility.

This time I *did* run analysis-stats on the four crates and confirmed it doesn't crash and this patch doesn't cause regression.
…ro, r=Veykril

Revert "Add proc-macro dependency to rustc crates"

1. This panics since it indexes into the wrong thing, so fixes rust-lang/rust-analyzer#13340
2. This didn't fix what I thought it would either
Reverts rust-lang/rust-analyzer#13328
…, r=Veykril

fix: use `BoundVar`s from current generic scope

Fixup for rust-lang#13335, addresses rust-lang/rust-analyzer#13339 (comment)

Before the change in generic parameter order, `BoundVar`s for trait reference didn't change whether you are in an impl's scope or in an associated item's scope. Now that item's generic params come before its parent's, we need to shift their indices when we are in an associated item's scope.
…, r=Veykril

minor: Fix go-to-def for shadowed `include*!`

Add a check in go-to-def feature, so that we don't assume any macro named `include`/`include_str`/`include_bytes` is the builtin one.
…e_str, r=Veykril

fix: Make go-to-def work for `#[doc = include_str!("path")]`

See the added test, go-to-def on `#[doc = include_str!("path$0")]` should navigate to `path`.
The main change here should be that flags are not inhereted, so

   $ rust-analyzer analysis-stats . -v -v

would do what it should do

We also no longer Don\'t
internal: ⬆️ xflags

The main change here should be that flags are not inhereted, so

   $ rust-analyzer analysis-stats . -v -v

would do what it should do

We also no longer Don\'t
@lnicola
Copy link
Member Author

lnicola commented Oct 11, 2022

@bors r+ rollup=iffy

@bors
Copy link
Contributor

bors commented Oct 11, 2022

📌 Commit c867288 has been approved by lnicola

It is now in the queue for this repository.

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Oct 11, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 11, 2022
…iaskrgr

Rollup of 11 pull requests

Successful merges:

 - rust-lang#100387 (Check uniqueness of impl items by trait item when applicable.)
 - rust-lang#101727 (Stabilize map_first_last)
 - rust-lang#101774 (Warn about safety of `fetch_update`)
 - rust-lang#102227 (fs::get_path solarish version.)
 - rust-lang#102445 (Add `is_empty()` method to `core::ffi::CStr`.)
 - rust-lang#102612 (Migrate `codegen_ssa` to diagnostics structs - [Part 1])
 - rust-lang#102685 (Interpret EH actions properly)
 - rust-lang#102869 (Add basename and dirname aliases)
 - rust-lang#102889 (rustc_hir: Less error-prone methods for accessing `PartialRes` resolution)
 - rust-lang#102893 (Fix ICE rust-lang#102878)
 - rust-lang#102912 (:arrow_up: rust-analyzer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 3e01d07 into rust-lang:master Oct 11, 2022
@rustbot rustbot added this to the 1.66.0 milestone Oct 11, 2022
@lnicola lnicola deleted the rust-analyzer-2022-10-11 branch October 12, 2022 07:06
Aaron1011 pushed a commit to Aaron1011/rust that referenced this pull request Jan 6, 2023
…r=lnicola

⬆️ rust-analyzer

r? `@ghost`
Aaron1011 pushed a commit to Aaron1011/rust that referenced this pull request Jan 6, 2023
…iaskrgr

Rollup of 11 pull requests

Successful merges:

 - rust-lang#100387 (Check uniqueness of impl items by trait item when applicable.)
 - rust-lang#101727 (Stabilize map_first_last)
 - rust-lang#101774 (Warn about safety of `fetch_update`)
 - rust-lang#102227 (fs::get_path solarish version.)
 - rust-lang#102445 (Add `is_empty()` method to `core::ffi::CStr`.)
 - rust-lang#102612 (Migrate `codegen_ssa` to diagnostics structs - [Part 1])
 - rust-lang#102685 (Interpret EH actions properly)
 - rust-lang#102869 (Add basename and dirname aliases)
 - rust-lang#102889 (rustc_hir: Less error-prone methods for accessing `PartialRes` resolution)
 - rust-lang#102893 (Fix ICE rust-lang#102878)
 - rust-lang#102912 (:arrow_up: rust-analyzer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.