-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Tracking issue for future-incompatibility lint late_bound_lifetime_arguments #42868
Copy link
Copy link
Open
Labels
A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-future-incompatibilityCategory: Future-incompatibility lintsCategory: Future-incompatibility lintsC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCL-late_bound_lifetime_argumentsLint: late_bound_lifetime_argumentsLint: late_bound_lifetime_argumentsT-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.T-langRelevant to the language teamRelevant to the language teamT-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-future-incompatibilityCategory: Future-incompatibility lintsCategory: Future-incompatibility lintsC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCL-late_bound_lifetime_argumentsLint: late_bound_lifetime_argumentsLint: late_bound_lifetime_argumentsT-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.T-langRelevant to the language teamRelevant to the language teamT-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Projects
Status
Idea
What is this lint about
In functions not all lifetime parameters are created equal.
For example, if you have a function like
both
'aand'bare listed in the same parameter list, but when stripped from the surface syntax the function looks more likewhere
'bis a "true" ("early-bound") parameter of the function, and'ais an "existential" ("late-bound") parameter. This means the function is not parameterized by'a.To give some more intuition, let's write a type for function pointer to
f:See more about this distinction in http://smallcultfollowing.com/babysteps/blog/2013/10/29/intermingled-parameter-lists/#early--vs-late-bound-lifetimes
When lifetime arguments are provided to a function explicitly, e.g.
the first argument doesn't make much sense because the function is not parameterized by
'a.Providing arguments for "late-bound" lifetime parameters in general doesn't make sense, while arguments for "early-bound" lifetime parameters can be provided.
It's not clear how to provide arguments for early-bound lifetime parameters if they are intermixed with late-bound parameters in the same list. For now providing any explicit arguments is prohibited if late-bound parameters are present, so in the future we can adopt any solution without hitting backward compatibility issues.
Note that late-bound lifetime parameters can be introduced implicitly through lifetime elision:
The precise rules discerning between early- and late-bound lifetimes can be found here:
rust/src/librustc/middle/resolve_lifetime.rs
Lines 1541 to 1700 in 91aff57
How to fix this warning/error
Just removing the lifetime arguments pointed to by the lint should be enough in most cases.
Current status
late_bound_lifetime_argumentslint as warn-by-defaultlate_bound_lifetime_argumentslint deny-by-defaultlate_bound_lifetime_argumentslint a hard error