Skip to content

Projection does not normalize the environment #21664

Closed
@nikomatsakis

Description

@nikomatsakis

Currently we store non-normalized predicts in the environment and normalize as we go, but we don't do that for projection, because it leads to a kind of infinite loop -- normalizing something requires drawing on the environment which requires normalizing something.

Here is an example of code that does not compile as a result:

pub trait Integral {
    type Opposite;
}

impl Integral for i32 {
    type Opposite = u32;
}

impl Integral for u32 {
    type Opposite = i32;
}

pub trait FnLike<A> {
    type R;
}

fn foo<T>()
    where T : FnLike<<i32 as Integral>::Opposite, R=bool>
{
    bar::<T>();
}

fn bar<T>()
    where T : FnLike<u32, R=bool>
{}

fn main() { }

This is blocking my attempts to make the fn return as associated type, because a situation much like the above arises when you do that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-associated-itemsArea: Associated items (types, constants & functions)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions