Skip to content

incompletely relating alias args may cause borrowck ICE #140211

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

Open
lcnr opened this issue Apr 23, 2025 · 0 comments
Open

incompletely relating alias args may cause borrowck ICE #140211

lcnr opened this issue Apr 23, 2025 · 0 comments
Labels
fixed-by-next-solver Fixed by the next-generation trait solver, `-Znext-solver`.

Comments

@lcnr
Copy link
Contributor

lcnr commented Apr 23, 2025

trait Id {
    type This<'a>;
}

#[derive(Copy, Clone)]
struct W<T>(T);
impl Id for W<u32> {
    type This<'a> = W<u32>;
}
impl Id for W<i32> {
    type This<'a> = W<i32>;
}

trait Trait<T> {}
// when using this impl we only normalize after instantiating
// with infer vars, at this point `<?t as Id>::This<'a>` is still
// ambig, so we keep the alias around and require it to structurally
// relate.
impl<T: Id> Trait<for<'a> fn(T::This<'a>)> for T {}
fn is_trait<T: Trait<U>, U>(_x: T) {}

fn main() {
    let x = W(1);
    // We prove `W<_>: Trait<for<'a> fn(<W<_>>::This<'a>)>` during
    // typeck, and `W<i32>: Trait<for<'a> fn(<W<i32>)>` during borrowck.
    // This then fails.
    is_trait(x);
    let _: W<i32> = x;
}

ICEs with

error: internal compiler error: error performing operation: fully_perform
  --> src/main.rs:20:5
   |
20 |     is_trait::<_, _>(x);
   |     ^^^^^^^^^^^^^^^^^^^
   |
note: delayed at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/compiler/rustc_trait_selection/src/traits/query/type_op/custom.rs:87:25 - disabled backtrace
  --> src/main.rs:20:5
   |
20 |     is_trait::<_, _>(x);
   |     ^^^^^^^^^^^^^^^^^^^
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 23, 2025
@lcnr lcnr added fixed-by-next-solver Fixed by the next-generation trait solver, `-Znext-solver`. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 23, 2025
@lcnr lcnr changed the title imcompletely relating alias args may cause borrowck ICE incompletely relating alias args may cause borrowck ICE Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed-by-next-solver Fixed by the next-generation trait solver, `-Znext-solver`.
Projects
None yet
Development

No branches or pull requests

2 participants