-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
unused_lifetimes lint has false positives with GATs #94307
Copy link
Copy link
Closed
Labels
A-GATsArea: Generic associated types (GATs)Area: Generic associated types (GATs)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.F-generic_associated_types`#![feature(generic_associated_types)]` a.k.a. GATs`#![feature(generic_associated_types)]` a.k.a. GATsL-single_use_lifetimesLint: single_use_lifetimesLint: single_use_lifetimes
Metadata
Metadata
Assignees
Labels
A-GATsArea: Generic associated types (GATs)Area: Generic associated types (GATs)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.F-generic_associated_types`#![feature(generic_associated_types)]` a.k.a. GATs`#![feature(generic_associated_types)]` a.k.a. GATsL-single_use_lifetimesLint: single_use_lifetimesLint: single_use_lifetimes
Type
Fields
Give feedbackNo fields configured for issues without a type.
The
unused_lifetimeslint can be incorrectly triggered both by declaring and by implementing GATs.Declaring a GAT with an unconstrained lifetime causes the lint to fire (Playground):
This code should be accepted (or maybe produce a lint about a lack of constraints on
'x). Right now, it produces warnings about unused lifetimes. Note that there is no way to elide the lifetime (as the lint suggests) and that removing the lifetime breaks the API for implementors and users.Implementing a GAT without using a lifetime causes the lint to fire:
This code should be accepted, as there is no way for the implementor to elide the lifetime here (
'_is reserved and omitting the<'x>is a lifetime mismatch). Using the lifetime in the type would alter the meaning of the code and may break consumers.Meta
rustc --version --verbose: