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

user type annotations are captured post normalization #54940

Open
nikomatsakis opened this issue Oct 9, 2018 · 11 comments

Comments

@nikomatsakis
Copy link
Contributor

@nikomatsakis nikomatsakis commented Oct 9, 2018

This example compiles but should not. Haven't investigated deeply.

#![feature(nll)]

trait Foo { 
    type Item;
}

impl<'a, u32> Foo for &'a u32 {
    type Item = &'a i32;
}

fn main() {
    let a = 22_i32;
    let x: <&'static u32 as Foo>::Item = &a;
}

cc #47184

@nikomatsakis

This comment has been minimized.

Copy link
Contributor Author

@nikomatsakis nikomatsakis commented Oct 9, 2018

I think in general we probably need to rework a bit how the NLL checker is handling user-given type annotations to cover normalizations. My expectation is that we should move over to the strategy of instantiating the user-types with fresh type variables so that we can run the normalize routine on them, and then adapt the relate_tys code to handle unbound type variables. We've done most of the legwork here already so that should be too hard to do.

@pnkfelix pnkfelix changed the title nll type anntation not preserved for non-normalized projections nll type annotation not preserved for non-normalized projections Oct 16, 2018
@pnkfelix

This comment has been minimized.

Copy link
Member

@pnkfelix pnkfelix commented Oct 16, 2018

Discussed at NLL weekly meeting. Assigning to @nikomatsakis as primary person to resolve this. Assigning to self as a kind of backup plan since I know that @nikomatsakis has some conflicts this week that will impede their ability to actually hack on this problem in the short term.

@nikomatsakis

This comment has been minimized.

Copy link
Contributor Author

@nikomatsakis nikomatsakis commented Oct 16, 2018

The problem is that we are capturing these types after they've been normalized. I think the best fix would be to capture the types before they've been normalized, and then have the NLL checker do the normalization. I'm not 100% sure how much of a pain this is going to be though; it might be a bit of a pain in some cases.

@nikomatsakis

This comment has been minimized.

Copy link
Contributor Author

@nikomatsakis nikomatsakis commented Oct 16, 2018

It also would require #55093 to land first.

@nikomatsakis

This comment has been minimized.

Copy link
Contributor Author

@nikomatsakis nikomatsakis commented Oct 16, 2018

OK, digging a bit deeper. This is going to be an awful pain to fix =)

@nikomatsakis nikomatsakis changed the title nll type annotation not preserved for non-normalized projections user type annotations are captured post normalization Oct 16, 2018
@nikomatsakis

This comment has been minimized.

Copy link
Contributor Author

@nikomatsakis nikomatsakis commented Oct 18, 2018

Demoting to release. This will be complex and is a relatively obscure bug.

@nikomatsakis

This comment has been minimized.

Copy link
Contributor Author

@nikomatsakis nikomatsakis commented Nov 13, 2018

Demoting from release milestone. This is really effectively blocked on lazy normalization so going to focus on that.

@pnkfelix

This comment has been minimized.

Copy link
Member

@pnkfelix pnkfelix commented Feb 27, 2019

triage: Marking P-high. If WG-traits or T-compiler wants to demote then they can do so, but from my point of view this is going to be one of the last things potentially blocking turning borrowck=migrate on by default for the 2015 edition, so I want it to be readily visible.

@pnkfelix pnkfelix added the P-high label Feb 27, 2019
@pnkfelix

This comment has been minimized.

Copy link
Member

@pnkfelix pnkfelix commented Feb 27, 2019

also, nominating for discussion at NLL meeting, just to get check-in about what plan is for lazy-normalization from niko.

@pnkfelix

This comment has been minimized.

Copy link
Member

@pnkfelix pnkfelix commented Mar 13, 2019

triage. Pinged @nikomatsakis ; after I asked if there was any updated here, they responded:

Not really. My expectation is that this won't be closed for some time, but looking at it again -- and in light of the 2PB discussion =) -- maybe I should think harder about a way to fix it

@pnkfelix pnkfelix removed the I-nominated label Mar 13, 2019
@pnkfelix

This comment has been minimized.

Copy link
Member

@pnkfelix pnkfelix commented May 2, 2019

triage: marking as blocked on #60471. Downgrading to P-medium.

@pnkfelix pnkfelix added S-blocked P-medium and removed P-high labels May 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.