unused_lifetimes lint has false positives with GATs #94307
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-GATs
Area: Generic associated types (GATs)
C-bug
Category: This is a bug.
E-easy
Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
E-mentor
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
F-lint-single_use_lifetimes
`single_use_lifetimes` lint
GATs-triaged
Issues using the `generic_associated_types` feature that have been triaged
The
unused_lifetimes
lint 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
:The text was updated successfully, but these errors were encountered: