Skip to content

Structural normalization tries to normalize (later) rigid aliases #78

Closed
rust-lang/rust
#119091
@compiler-errors

Description

@compiler-errors
trait Trait {
    type Assoc;
}

fn call<T: Trait>(_: <T as Trait>::Assoc, _: T) { }

fn foo<T: Trait>(rigid: <T as Trait>::Assoc, t: T) {
    call::<_ /* ?0 */>(rigid, t);
    //~^ ERROR: type mismatch resolving `<T as Trait>::Assoc normalizes-to <T as Trait>::Assoc`
    //
    // Checking the first argument of `call` will cause us to
    // try to coerce `<?0 as Trait>::Assoc` and `<T as Trait>::Assoc`.
    // The left hand side is eagerly structurally normalized to
    // `?1`, then we add `<?0 as Trait>::Assoc normalizes-to ?1`,
    // which fails.
}

Given some <?0 as Trait>::Assoc, structural normalize currently checks if the predicate <?0 as Trait>::Assoc normalizes-to ?1 may hold. This is ambiguous, but fails later if ?0 is constrained to some T where T: Trait, because <T as Trait>::Assoc is now rigid.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions