Skip to content

Projection bounds can be non-global when corresponding trait goal are global #218

@compiler-errors

Description

@compiler-errors

Strange inconsistency. Probably should be considered when reworking our global/non-global characterization strategy.

trait Foo<'a> {
    type Assoc;
}

impl<'a, T> Foo<'a> for T {
    type Assoc = u8;
}

fn no_proj<'a, T>() where T: Foo<'a> {}
fn with_proj<'a, T>() -> T::Assoc where T: Foo<'a> {}

fn test<'a, U>() where i32: Foo<'static, Assoc = U> {
    // Ok, only requires proving `i32: Trait<'a>`, via impl.
    no_proj::<'a, i32>();

    // FAILS, prefer non-global `<i32 as Trait<'static>> normalizes-to U`.
    with_proj::<'a, i32>();
}

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