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

NLL should respect lifetimes in as expressions #54332

Closed
nikomatsakis opened this issue Sep 18, 2018 · 2 comments
Closed

NLL should respect lifetimes in as expressions #54332

nikomatsakis opened this issue Sep 18, 2018 · 2 comments
Assignees
Labels
A-NLL Area: Non Lexical Lifetimes (NLL) NLL-sound Working towards the "invalid code does not compile" goal T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nikomatsakis
Copy link
Contributor

Spawned off from #47184. The following test case compiles, but it should not:

#![allow(warnings)]
#![feature(nll)]

fn main() {
    let x = 22_u32;
    let y: &u32 = (&x) as &'static u32;
}

The problem is that the "cast" expression is not preserving the full type that the user gave (&'static u32).

This is very similar to #54331

@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) labels Sep 18, 2018
@nikomatsakis
Copy link
Contributor Author

In fact, I would handle this by just wrapping casts in one of the ExprKind::Type nodes that are added in #54331

@nikomatsakis nikomatsakis added this to the Edition 2018 RC 2 milestone Sep 18, 2018
@matthewjasper matthewjasper added the NLL-sound Working towards the "invalid code does not compile" goal label Sep 22, 2018
@nikomatsakis
Copy link
Contributor Author

I'm assigning this to @KiChjang since it is a good follow-up to the work they've been doing

bors added a commit that referenced this issue Oct 19, 2018
…stants, r=pnkfelix

support type annot in constants, casts

Fixes #54571
Fixes #54332
Fixes #55183

r? @pnkfelix
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) NLL-sound Working towards the "invalid code does not compile" goal T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants