Skip to content

user type annotations are captured post normalization #54940

Description

@nikomatsakis

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

Activity

  1. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    A-NLLArea: Non-lexical lifetimes (NLL)
    NLL-soundWorking towards the "invalid code does not compile" goal
    on Oct 9, 2018
  2. added this to the Edition 2018 RC 2 milestone on Oct 9, 2018
  3. nikomatsakis commented on Oct 9, 2018

    @nikomatsakis
    ContributorAuthor

    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.

  4. changed the title [-]nll type anntation not preserved for non-normalized projections[/-] [+]nll type annotation not preserved for non-normalized projections[/+] on Oct 16, 2018
  5. pnkfelix commented on Oct 16, 2018

    @pnkfelix
    Contributor

    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.

  6. nikomatsakis commented on Oct 16, 2018

    @nikomatsakis
    ContributorAuthor

    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.

  7. nikomatsakis commented on Oct 16, 2018

    @nikomatsakis
    ContributorAuthor

    It also would require #55093 to land first.

  8. nikomatsakis commented on Oct 16, 2018

    @nikomatsakis
    ContributorAuthor

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

  9. changed the title [-]nll type annotation not preserved for non-normalized projections[/-] [+]user type annotations are captured post normalization[/+] on Oct 16, 2018
  10. 14 remaining items

  11. added and removed
    P-highHigh priority
    on May 2, 2019
  12. Aaron1011 commented on Sep 15, 2020

    @Aaron1011
    Contributor

    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.

  13. lcnr commented on Apr 11, 2022

    @lcnr
    Contributor

    I intend to look into this in the somewhat near future

    @rustbot claim

  14. added
    T-typesRelevant to the types team, which will review and decide on the PR/issue.
    S-types-trackedStatus: Being actively tracked by the types team
    and removed on Jun 24, 2022
  15. added a commit that references this issue on Jan 9, 2023
    af58fc8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-NLLArea: Non-lexical lifetimes (NLL)A-trait-systemArea: Trait systemNLL-soundWorking towards the "invalid code does not compile" goalP-mediumMedium priorityS-blockedStatus: Blocked on something else such as an RFC or other implementation work.S-types-trackedStatus: Being actively tracked by the types teamT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions