Skip to content

Conversation

matthiaskrgr
Copy link
Member

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

celinval and others added 17 commits December 7, 2023 17:01
The instance evaluation is needed to handle intrinsics such as
`type_id` and `type_name`.

Since we now use Allocation to represent all evaluated constants,
provide a few methods to help process the data inside an allocation.
detects redundant imports that can be eliminated.

for rust-lang#117772 :

In order to facilitate review and modification, split the checking code and
removing redundant imports code into two PR.
A refactoring in rust-lang#117076 changed the `DefIdVisitorSkeleton` to avoid
calling `visit_projection_ty` for `ty::Projection` aliases, and instead
just iterate over the args - this makes sense, as `visit_projection_ty`
will indirectly visit all of the same args, but in doing so, will also
create a `TraitRef` containing the trait's `DefId`, which also gets
visited. The trait's `DefId` isn't visited when we only visit the
arguments without separating them into `TraitRef` and own args first.

Signed-off-by: David Wood <[email protected]>
- Take more things by self, not &self
- Clone more things
- Rework namespacing so we can use `ty::` in the canonicalizer
… r=lcnr

Uplift the (new solver) canonicalizer into `rustc_next_trait_solver`

Uplifts the new trait solver's canonicalizer into a new crate called `rustc_next_trait_solver`.

The crate name is literally a bikeshed-avoidance name, so let's not block this PR on that -- renames are welcome later.

There are a host of other changes that were required to make this possible:
* Expose a `ConstTy` trait to get the `Interner::Ty` from a `Interner::Const`.
* Expose some constructor methods to construct `Bound` variants. These are currently methods defined on the interner themselves, but they could be pulled into traits later.
* Expose a `IntoKind` trait to turn a `Ty`/`Const`/`Region` into their corresponding `*Kind`s.
* Some minor tweaks to other APIs in `rustc_type_ir`.

The canonicalizer code itself is best reviewed **with whitespace ignored.**

r? `@lcnr`
…petrochenkov

remove redundant imports

detects redundant imports that can be eliminated.

for rust-lang#117772 :

In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.

r? `@petrochenkov`
Add instance evaluation and methods to read an allocation in StableMIR

The instance evaluation is needed to handle intrinsics such as `type_id` and `type_name`.

Since we now use Allocation to represent all evaluated constants, provide a few methods to help process the data inside an allocation.

I've also started to add a structured way to get information about the compilation target machine. For now, I've only added information needed to process an allocation.

r? `````@ouz-a`````
…it-trait-ref-and-args, r=TaKO8Ki

privacy: visit trait def id of projections

Fixes rust-lang#117997.

A refactoring in rust-lang#117076 changed the `DefIdVisitorSkeleton` to avoid calling `visit_projection_ty` for `ty::Projection` aliases, and instead just iterate over the args - this makes sense, as `visit_projection_ty` will indirectly visit all of the same args, but in doing so, will also create a `TraitRef` containing the trait's `DefId`, which also gets visited. The trait's `DefId` isn't visited when we only visit the arguments without separating them into `TraitRef` and own args first.

Eventually this influences the reachability set and whether a function is encoded into the metadata.
…er-errors

recurse into refs when comparing tys for diagnostics

before:
![image](https://github.com/rust-lang/rust/assets/23638587/bf6abd62-c7f3-4c09-a47e-31b6e129de19)

after:
![image](https://github.com/rust-lang/rust/assets/23638587/b704d728-ddba-4204-aebe-c07dcbbcb55c)

this diff from the test suite is also quite nice imo:
```diff
`@@` -4,8 +4,8 `@@` error[E0308]: mismatched types
 LL |     debug_assert_eq!(iter.next(), Some(value));
    |                                   ^^^^^^^^^^^ expected `Option<<I as Iterator>::Item>`, found `Option<&<I as Iterator>::Item>`
    |
-   = note: expected enum `Option<<I as Iterator>::Item>`
-              found enum `Option<&<I as Iterator>::Item>`
+   = note: expected enum `Option<_>`
+              found enum `Option<&_>`
```
…mpiler-errors

temporarily revert "ice on ambguity in mir typeck"

Reverts rust-lang#116530 as a temporary measure to fix rust-lang#117577. That issue should be ultimately fixed by checking WF of type annotations prior to normalization, which is implemented in rust-lang#104098 but this PR is intended to be backported to beta.

r? `@compiler-errors` (the reviewer of the reverted PR)
@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) rollup A PR which is a rollup labels Dec 8, 2023
@matthiaskrgr
Copy link
Member Author

@bors r+ rollup=never p=6

@bors
Copy link
Collaborator

bors commented Dec 8, 2023

📌 Commit a720b77 has been approved by matthiaskrgr

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 Dec 8, 2023
@bors
Copy link
Collaborator

bors commented Dec 8, 2023

⌛ Testing commit a720b77 with merge f846663...

bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 8, 2023
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#117586 (Uplift the (new solver) canonicalizer into `rustc_next_trait_solver`)
 - rust-lang#118692 (remove redundant imports)
 - rust-lang#118694 (Add instance evaluation and methods to read an allocation in StableMIR)
 - rust-lang#118715 (privacy: visit trait def id of projections)
 - rust-lang#118730 (recurse into refs when comparing tys for diagnostics)
 - rust-lang#118736 (temporarily revert "ice on ambguity in mir typeck")

r? `@ghost`
`@rustbot` modify labels: rollup
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-stable failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
   Compiling rustc_lexer v0.0.0 (/checkout/compiler/rustc_lexer)
[RUSTC-TIMING] rustc_parse_format test:false 1.427
[RUSTC-TIMING] rustc_lexer test:true 3.038
   Compiling rustc_span v0.0.0 (/checkout/compiler/rustc_span)
error[E0277]: `*const [u8]` cannot be sent between threads safely
  --> compiler/rustc_data_structures/src/owned_slice/tests.rs:31:29
   |
31 |     let slice = slice_owned(slice, |s| &s[1..][..4]);
   |                 ----------- ^^^^^ `*const [u8]` cannot be sent between threads safely
   |                 required by a bound introduced by this call
   |
   |
   = help: within `OwnedSlice`, the trait `std::marker::Send` is not implemented for `*const [u8]`
note: required because it appears within the type `OwnedSlice`
   |
20 | pub struct OwnedSlice {
   |            ^^^^^^^^^^
note: required by a bound in `slice_owned`
note: required by a bound in `slice_owned`
  --> compiler/rustc_data_structures/src/owned_slice.rs:62:8
   |
60 | pub fn slice_owned<O, F>(owner: O, slicer: F) -> OwnedSlice
61 | where
62 |     O: Send + Sync + 'static,
   |        ^^^^ required by this bound in `slice_owned`


error[E0277]: `Rc<(dyn std::marker::Send + std::marker::Sync + 'static)>` cannot be sent between threads safely
  --> compiler/rustc_data_structures/src/owned_slice/tests.rs:31:29
   |
31 |     let slice = slice_owned(slice, |s| &s[1..][..4]);
   |                 ----------- ^^^^^ `Rc<(dyn std::marker::Send + std::marker::Sync + 'static)>` cannot be sent between threads safely
   |                 required by a bound introduced by this call
   |
   |
   = help: within `OwnedSlice`, the trait `std::marker::Send` is not implemented for `Rc<(dyn std::marker::Send + std::marker::Sync + 'static)>`
note: required because it appears within the type `OwnedSlice`
   |
20 | pub struct OwnedSlice {
   |            ^^^^^^^^^^
note: required by a bound in `slice_owned`
note: required by a bound in `slice_owned`
  --> compiler/rustc_data_structures/src/owned_slice.rs:62:8
   |
60 | pub fn slice_owned<O, F>(owner: O, slicer: F) -> OwnedSlice
61 | where
62 |     O: Send + Sync + 'static,
   |        ^^^^ required by this bound in `slice_owned`


error[E0277]: `*const [u8]` cannot be shared between threads safely
  --> compiler/rustc_data_structures/src/owned_slice/tests.rs:31:29
   |
31 |     let slice = slice_owned(slice, |s| &s[1..][..4]);
   |                 ----------- ^^^^^ `*const [u8]` cannot be shared between threads safely
   |                 required by a bound introduced by this call
   |
   |
   = help: within `OwnedSlice`, the trait `std::marker::Sync` is not implemented for `*const [u8]`
note: required because it appears within the type `OwnedSlice`
   |
20 | pub struct OwnedSlice {
   |            ^^^^^^^^^^
note: required by a bound in `slice_owned`
note: required by a bound in `slice_owned`
  --> compiler/rustc_data_structures/src/owned_slice.rs:62:15
   |
60 | pub fn slice_owned<O, F>(owner: O, slicer: F) -> OwnedSlice
61 | where
62 |     O: Send + Sync + 'static,
   |               ^^^^ required by this bound in `slice_owned`


error[E0277]: `Rc<(dyn std::marker::Send + std::marker::Sync + 'static)>` cannot be shared between threads safely
  --> compiler/rustc_data_structures/src/owned_slice/tests.rs:31:29
   |
31 |     let slice = slice_owned(slice, |s| &s[1..][..4]);
   |                 ----------- ^^^^^ `Rc<(dyn std::marker::Send + std::marker::Sync + 'static)>` cannot be shared between threads safely
   |                 required by a bound introduced by this call
   |
   |
   = help: within `OwnedSlice`, the trait `std::marker::Sync` is not implemented for `Rc<(dyn std::marker::Send + std::marker::Sync + 'static)>`
note: required because it appears within the type `OwnedSlice`
   |
20 | pub struct OwnedSlice {
   |            ^^^^^^^^^^
note: required by a bound in `slice_owned`
note: required by a bound in `slice_owned`
  --> compiler/rustc_data_structures/src/owned_slice.rs:62:15
   |
60 | pub fn slice_owned<O, F>(owner: O, slicer: F) -> OwnedSlice
61 | where
62 |     O: Send + Sync + 'static,
   |               ^^^^ required by this bound in `slice_owned`


error[E0277]: `*const [u8]` cannot be sent between threads safely
  --> compiler/rustc_data_structures/src/owned_slice/tests.rs:32:29
   |
32 |     let slice = slice_owned(slice, |s| s);
   |                 ----------- ^^^^^ `*const [u8]` cannot be sent between threads safely
   |                 required by a bound introduced by this call
   |
   |
   = help: within `OwnedSlice`, the trait `std::marker::Send` is not implemented for `*const [u8]`
note: required because it appears within the type `OwnedSlice`
   |
20 | pub struct OwnedSlice {
   |            ^^^^^^^^^^
note: required by a bound in `slice_owned`
note: required by a bound in `slice_owned`
  --> compiler/rustc_data_structures/src/owned_slice.rs:62:8
   |
60 | pub fn slice_owned<O, F>(owner: O, slicer: F) -> OwnedSlice
61 | where
62 |     O: Send + Sync + 'static,
   |        ^^^^ required by this bound in `slice_owned`


error[E0277]: `Rc<(dyn std::marker::Send + std::marker::Sync + 'static)>` cannot be sent between threads safely
  --> compiler/rustc_data_structures/src/owned_slice/tests.rs:32:29
   |
32 |     let slice = slice_owned(slice, |s| s);
   |                 ----------- ^^^^^ `Rc<(dyn std::marker::Send + std::marker::Sync + 'static)>` cannot be sent between threads safely
   |                 required by a bound introduced by this call
   |
   |
   = help: within `OwnedSlice`, the trait `std::marker::Send` is not implemented for `Rc<(dyn std::marker::Send + std::marker::Sync + 'static)>`
note: required because it appears within the type `OwnedSlice`
   |
20 | pub struct OwnedSlice {
   |            ^^^^^^^^^^
note: required by a bound in `slice_owned`
note: required by a bound in `slice_owned`
  --> compiler/rustc_data_structures/src/owned_slice.rs:62:8
   |
60 | pub fn slice_owned<O, F>(owner: O, slicer: F) -> OwnedSlice
61 | where
62 |     O: Send + Sync + 'static,
   |        ^^^^ required by this bound in `slice_owned`


error[E0277]: `*const [u8]` cannot be shared between threads safely
  --> compiler/rustc_data_structures/src/owned_slice/tests.rs:32:29
   |
32 |     let slice = slice_owned(slice, |s| s);
   |                 ----------- ^^^^^ `*const [u8]` cannot be shared between threads safely
   |                 required by a bound introduced by this call
   |
   |
   = help: within `OwnedSlice`, the trait `std::marker::Sync` is not implemented for `*const [u8]`
note: required because it appears within the type `OwnedSlice`
   |
20 | pub struct OwnedSlice {
   |            ^^^^^^^^^^
note: required by a bound in `slice_owned`
note: required by a bound in `slice_owned`
  --> compiler/rustc_data_structures/src/owned_slice.rs:62:15
   |
60 | pub fn slice_owned<O, F>(owner: O, slicer: F) -> OwnedSlice
61 | where
62 |     O: Send + Sync + 'static,
   |               ^^^^ required by this bound in `slice_owned`


error[E0277]: `Rc<(dyn std::marker::Send + std::marker::Sync + 'static)>` cannot be shared between threads safely
  --> compiler/rustc_data_structures/src/owned_slice/tests.rs:32:29
   |
32 |     let slice = slice_owned(slice, |s| s);
   |                 ----------- ^^^^^ `Rc<(dyn std::marker::Send + std::marker::Sync + 'static)>` cannot be shared between threads safely
   |                 required by a bound introduced by this call
   |
   |
   = help: within `OwnedSlice`, the trait `std::marker::Sync` is not implemented for `Rc<(dyn std::marker::Send + std::marker::Sync + 'static)>`
note: required because it appears within the type `OwnedSlice`
   |
20 | pub struct OwnedSlice {
   |            ^^^^^^^^^^
note: required by a bound in `slice_owned`
note: required by a bound in `slice_owned`
  --> compiler/rustc_data_structures/src/owned_slice.rs:62:15
   |
60 | pub fn slice_owned<O, F>(owner: O, slicer: F) -> OwnedSlice
61 | where
62 |     O: Send + Sync + 'static,
   |               ^^^^ required by this bound in `slice_owned`


error[E0277]: `*const [u8]` cannot be sent between threads safely
  --> compiler/rustc_data_structures/src/owned_slice/tests.rs:33:29
   |
33 |     let slice = slice_owned(slice, |s| &s[1..]);
   |                 ----------- ^^^^^ `*const [u8]` cannot be sent between threads safely
   |                 required by a bound introduced by this call
   |
   |
   = help: within `OwnedSlice`, the trait `std::marker::Send` is not implemented for `*const [u8]`
note: required because it appears within the type `OwnedSlice`
   |
20 | pub struct OwnedSlice {
   |            ^^^^^^^^^^
note: required by a bound in `slice_owned`
note: required by a bound in `slice_owned`
  --> compiler/rustc_data_structures/src/owned_slice.rs:62:8
   |
60 | pub fn slice_owned<O, F>(owner: O, slicer: F) -> OwnedSlice
61 | where
62 |     O: Send + Sync + 'static,
   |        ^^^^ required by this bound in `slice_owned`


error[E0277]: `Rc<(dyn std::marker::Send + std::marker::Sync + 'static)>` cannot be sent between threads safely
  --> compiler/rustc_data_structures/src/owned_slice/tests.rs:33:29
   |
33 |     let slice = slice_owned(slice, |s| &s[1..]);
   |                 ----------- ^^^^^ `Rc<(dyn std::marker::Send + std::marker::Sync + 'static)>` cannot be sent between threads safely
   |                 required by a bound introduced by this call
   |
   |
   = help: within `OwnedSlice`, the trait `std::marker::Send` is not implemented for `Rc<(dyn std::marker::Send + std::marker::Sync + 'static)>`
note: required because it appears within the type `OwnedSlice`
   |
20 | pub struct OwnedSlice {
   |            ^^^^^^^^^^
note: required by a bound in `slice_owned`
note: required by a bound in `slice_owned`
  --> compiler/rustc_data_structures/src/owned_slice.rs:62:8
   |
60 | pub fn slice_owned<O, F>(owner: O, slicer: F) -> OwnedSlice
61 | where
62 |     O: Send + Sync + 'static,
   |        ^^^^ required by this bound in `slice_owned`


error[E0277]: `*const [u8]` cannot be shared between threads safely
  --> compiler/rustc_data_structures/src/owned_slice/tests.rs:33:29
   |
33 |     let slice = slice_owned(slice, |s| &s[1..]);
   |                 ----------- ^^^^^ `*const [u8]` cannot be shared between threads safely
   |                 required by a bound introduced by this call
   |
   |
   = help: within `OwnedSlice`, the trait `std::marker::Sync` is not implemented for `*const [u8]`
note: required because it appears within the type `OwnedSlice`
   |
20 | pub struct OwnedSlice {
   |            ^^^^^^^^^^
note: required by a bound in `slice_owned`
note: required by a bound in `slice_owned`
  --> compiler/rustc_data_structures/src/owned_slice.rs:62:15
   |
60 | pub fn slice_owned<O, F>(owner: O, slicer: F) -> OwnedSlice
61 | where
62 |     O: Send + Sync + 'static,
   |               ^^^^ required by this bound in `slice_owned`


error[E0277]: `Rc<(dyn std::marker::Send + std::marker::Sync + 'static)>` cannot be shared between threads safely
  --> compiler/rustc_data_structures/src/owned_slice/tests.rs:33:29
   |
33 |     let slice = slice_owned(slice, |s| &s[1..]);
   |                 ----------- ^^^^^ `Rc<(dyn std::marker::Send + std::marker::Sync + 'static)>` cannot be shared between threads safely
   |                 required by a bound introduced by this call
   |
   |
   = help: within `OwnedSlice`, the trait `std::marker::Sync` is not implemented for `Rc<(dyn std::marker::Send + std::marker::Sync + 'static)>`
note: required because it appears within the type `OwnedSlice`
   |
20 | pub struct OwnedSlice {
   |            ^^^^^^^^^^
note: required by a bound in `slice_owned`
note: required by a bound in `slice_owned`
  --> compiler/rustc_data_structures/src/owned_slice.rs:62:15
   |
60 | pub fn slice_owned<O, F>(owner: O, slicer: F) -> OwnedSlice
61 | where
62 |     O: Send + Sync + 'static,
   |               ^^^^ required by this bound in `slice_owned`

@bors
Copy link
Collaborator

bors commented Dec 8, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 8, 2023
@matthiaskrgr matthiaskrgr deleted the rollup-jaym8pv branch March 16, 2024 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) rollup A PR which is a rollup S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants