Skip to content
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

impl vs param_env candidates in normalization #31

Closed
aliemjay opened this issue Jun 15, 2023 · 3 comments
Closed

impl vs param_env candidates in normalization #31

aliemjay opened this issue Jun 15, 2023 · 3 comments

Comments

@aliemjay
Copy link
Member

While investigating rust-lang/rust#112583, it seems that it reveals a bug in the new solver rather than being fixed by it. The new solver accepts this:

trait Trait {
    type Ty;
}

impl<T> Trait for T {
    type Ty = ();
}

fn test<T: Trait>() {
    let _: <T as Trait>::Ty = ();
}

It uses the impl candidate for normalization instead of the ParamEnv candidate.

This means that we're using a different candidate when solving T: Trait than when normalizing <T as Trait>::Ty. I don't think it is unsound but it can lead to some surprising behavior like this requiring 'a == 'static despite using the impl candidate for normalization:

trait Trait<'a> {
    type Ty;
}

impl<T> Trait<'_> for T {
    type Ty = ();
}

fn test<'a, T: Trait<'static>>() {
    let _: <T as Trait<'a>>::Ty = ();
    //~^ ERROR lifetime may not live long enough
}
@compiler-errors
Copy link
Member

This is kinda related to #1 since the new solver totally doesn't even consider "rigid" associated types as valid normalization candidates

@compiler-errors
Copy link
Member

Also see #12

@aliemjay
Copy link
Member Author

Oh, this is clearly a duplicate of #12.

@aliemjay aliemjay closed this as not planned Won't fix, can't repro, duplicate, stale Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants