-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
NLL should identify and respect the lifetime annotations that the user wrote #47184
Copy link
Copy link
Closed
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.Call for participation: Hard difficulty. Experience needed to fix: A lot.NLL-soundWorking towards the "invalid code does not compile" goalWorking towards the "invalid code does not compile" goalT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.metabugIssues about issues themselves ("bugs about bugs")Issues about issues themselves ("bugs about bugs")
Milestone
Metadata
Metadata
Assignees
Labels
A-NLLArea: Non-lexical lifetimes (NLL)Area: Non-lexical lifetimes (NLL)C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-hardCall for participation: Hard difficulty. Experience needed to fix: A lot.Call for participation: Hard difficulty. Experience needed to fix: A lot.NLL-soundWorking towards the "invalid code does not compile" goalWorking towards the "invalid code does not compile" goalT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.metabugIssues about issues themselves ("bugs about bugs")Issues about issues themselves ("bugs about bugs")
Type
Fields
Give feedbackNo fields configured for issues without a type.
We have made some progress on this issue.
Here's a list of everywhere within function bodies where we annotate types, with check boxes on the ones that are currently getting checked by the MIR-borrowck / NLL.
let x: u32 = 3;let (x, y): (u32, u32) = (33, 54);patterns.rsUI test.let _: Foo<'long> = c_is_short_oops;(support ascription for patterns in NLL #53873)let x: T;(support ascription for patterns in NLL #53873)let (x, y): (u32, u32);refbindings: e.g.let ref x: u32 = 3;, broken out into handle user type annotations in NLL forrefbindings #55401"2048".parse::<u32>()-- MIR: support user-given type annotations on fns, structs, and enums #53225<T as Trait<_>>::method-- MIR: support user-given type annotations on fns, structs, and enums #53225<_ as Trait<T>>::method-- MIR: support user-given type annotations on fns, structs, and enums #53225<_ as Trait<_>>::method<T>-- MIR: support user-given type annotations on fns, structs, and enums #53225Foo::<X>::method-- broken out into nll should respect lifetime annotations from multi-segment paths #54574let x = foo::<...>;-- MIR: support user-given type annotations on fns, structs, and enums #53225let x = SomeStruct::<'static> { field: u32 };-- MIR: support user-given type annotations on fns, structs, and enums #53225<T as Foo>::BAR? (broken out to nll: respect user type annotations with constants in expressions #54571)<T as Foo>::BAR? (nll: respect user type annotations with constants in patterns #55511)let A::<'static>(r) = ...? -- broken out into nll should respect lifetime annotations from patterns #54573Enum::Variant::<...>(...)-- MIR: support user-given type annotations on fns, structs, and enums #53225None::<&'static u32>-- MIR: support user-given type annotations on fns, structs, and enums #53225x as T(broken out into NLL should respect lifetimes inasexpressions #54332)x: &'static u32(broken out into nll should preserve user types in type ascription #54331)<Type as Trait>::method(args);-- MIR: support user-given type annotations on fns, structs, and enums #53225yield-subtype.rstest but that will also need resolved.(We should update this list as we think of more.)
Original bug report follows:
This code compiles with 1.24.0-nightly (2018-01-03 0a3761e):
This is confusing as the
Vecalmost certainly cannot contain a reference of a'staticlifetime. If you uncomment the call toonly_static, you get the expected error that theStringdoes not live long enough.@nikomatsakis said: