Skip to content

incompletely relating alias args may cause borrowck ICE #140211

Open

Description

@lcnr
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);
   |     ^^^^^^^^^^^^^^^^^^^

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Apr 23, 2025
  2. added
    fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Apr 23, 2025
  3. changed the title [-]imcompletely relating alias args may cause borrowck ICE[/-] [+]incompletely relating alias args may cause borrowck ICE[/+] on Apr 23, 2025
  4. added 2 commits that reference this issue on Oct 5, 2026
  5. added a commit that references this issue on Oct 5, 2026
  6. added 3 commits that reference this issue on Oct 7, 2026
  7. added a commit that references this issue on Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions