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

Remove special-casing around AliasKind::Opaque when structurally resolving in new solver #119817

Merged
merged 1 commit into from
Jan 12, 2024

Conversation

compiler-errors
Copy link
Member

This fixes a few inconsistencies around where we don't eagerly resolve opaques to their (locally-defined) hidden types in the new solver. It essentially allows this code to work:

fn main() {
    type Tait = impl Sized;
    struct S {
        i: i32,
    }
    let x: Tait = S { i: 0 };
    println!("{}", x.i);
}

Since Tait is defined in main, we are able to poke through the type of x with deref.

r? lcnr

@rustbot rustbot added 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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative labels Jan 10, 2024
@rustbot
Copy link
Collaborator

rustbot commented Jan 10, 2024

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

{
return Some(ty);
}
if let DefineOpaqueTypes::No = define_opaque_types
Copy link
Member Author

@compiler-errors compiler-errors Jan 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is copied from #118915, since otherwise Opaque alias-eq ?0 won't reveal the opaque in Reveal::All mode.

The important part is the && let Reveal::UserFacing = param_env.reveal() line, since in reveal-all mode, we don't care if opaques are local or not, we always want to reveal them.

Copy link
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me on the impl, but I am blocking this on #118915

@@ -23,7 +23,7 @@ impl<'tcx> StructurallyNormalizeExt<'tcx> for At<'_, 'tcx> {

if self.infcx.next_trait_solver() {
// FIXME(-Znext-solver): Should we resolve opaques here?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the fixme

@lcnr lcnr added S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 10, 2024
@lcnr
Copy link
Contributor

lcnr commented Jan 12, 2024

@bors r+ rollup (new solver)

@bors
Copy link
Contributor

bors commented Jan 12, 2024

📌 Commit 68c2f11 has been approved by lcnr

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-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. labels Jan 12, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 12, 2024
…llaumeGomez

Rollup of 6 pull requests

Successful merges:

 - rust-lang#119817 (Remove special-casing around `AliasKind::Opaque` when structurally resolving in new solver)
 - rust-lang#119819 (Check rust lints when an unknown lint is detected)
 - rust-lang#119872 (Give me a way to emit all the delayed bugs as errors (add `-Zeagerly-emit-delayed-bugs`))
 - rust-lang#119877 (Add more information to `visit_projection_elem`)
 - rust-lang#119884 (Rename `--env` option flag to `--env-set`)
 - rust-lang#119885 (Revert rust-lang#113923)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 46c3c01 into rust-lang:master Jan 12, 2024
11 checks passed
@rustbot rustbot added this to the 1.77.0 milestone Jan 12, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jan 12, 2024
Rollup merge of rust-lang#119817 - compiler-errors:normalize-opaques, r=lcnr

Remove special-casing around `AliasKind::Opaque` when structurally resolving in new solver

This fixes a few inconsistencies around where we don't eagerly resolve opaques to their (locally-defined) hidden types in the new solver. It essentially allows this code to work:
```rust
fn main() {
    type Tait = impl Sized;
    struct S {
        i: i32,
    }
    let x: Tait = S { i: 0 };
    println!("{}", x.i);
}
```

Since `Tait` is defined in `main`, we are able to poke through the type of `x` with deref.

r? lcnr
@compiler-errors compiler-errors deleted the normalize-opaques branch January 12, 2024 23:38
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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants