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

Closed
nikomatsakis opened this issue Oct 9, 2018 · 13 comments · Fixed by #101947
Closed

user type annotations are captured post normalization #54940

nikomatsakis opened this issue Oct 9, 2018 · 13 comments · Fixed by #101947
Assignees
Labels
A-NLL Area: Non Lexical Lifetimes (NLL) A-traits Area: Trait system NLL-sound Working towards the "invalid code does not compile" goal P-medium Medium priority S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. S-types-tracked Status: Being actively tracked by the types team T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.

Comments

@nikomatsakis
Copy link
Contributor

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 nikomatsakis added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-NLL Area: Non Lexical Lifetimes (NLL) NLL-sound Working towards the "invalid code does not compile" goal labels Oct 9, 2018
@nikomatsakis nikomatsakis added this to the Edition 2018 RC 2 milestone Oct 9, 2018
@nikomatsakis
Copy link
Contributor Author

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
Copy link
Member

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
Copy link
Contributor Author

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
Copy link
Contributor Author

It also would require #55093 to land first.

@nikomatsakis
Copy link
Contributor Author

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
Copy link
Contributor Author

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

@nikomatsakis nikomatsakis added A-traits Area: Trait system WG-traits Working group: Traits, https://internals.rust-lang.org/t/announcing-traits-working-group/6804 labels Nov 13, 2018
@nikomatsakis nikomatsakis removed this from the Rust 2018 Release milestone Nov 13, 2018
@nikomatsakis
Copy link
Contributor Author

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

@pnkfelix
Copy link
Member

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 High priority label Feb 27, 2019
@pnkfelix
Copy link
Member

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

@pnkfelix
Copy link
Member

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
Copy link
Member

pnkfelix commented May 2, 2019

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

@pnkfelix pnkfelix added S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. P-medium Medium priority and removed P-high High priority labels May 2, 2019
@Aaron1011
Copy link
Member

This compiles without #![feature(nll)], but it doesn't seem possible to exploit this. Actually trying to use x as &'static i32 causes a compilation error.

@lcnr
Copy link
Contributor

lcnr commented Apr 11, 2022

I intend to look into this in the somewhat near future

@rustbot claim

@rustbot rustbot assigned lcnr and unassigned nikomatsakis Apr 11, 2022
@jackh726 jackh726 added T-types Relevant to the types team, which will review and decide on the PR/issue. S-types-tracked Status: Being actively tracked by the types team and removed WG-traits Working group: Traits, https://internals.rust-lang.org/t/announcing-traits-working-group/6804 labels Jun 24, 2022
@bors bors closed this as completed in af58fc8 Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-NLL Area: Non Lexical Lifetimes (NLL) A-traits Area: Trait system NLL-sound Working towards the "invalid code does not compile" goal P-medium Medium priority S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. S-types-tracked Status: Being actively tracked by the types team T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-types Relevant to the types team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants