- Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied
Description
Summary
clippy::useless_conversion
is issued when Into
is used to convert to the same type but with different lifetime. The suggested fix breaks the code.
Lint Name
useless_conversion
Reproducer
I tried this code:
pub trait MyTrait { type Borrowed<'a>; } pub fn make_static<T: MyTrait>(x: T::Borrowed<'_>) -> T::Borrowed<'static> where for<'a> T::Borrowed<'a>: Into<T::Borrowed<'static>>, { x.into() }
I saw this happen:
| 9 | x.into() | ^^^^^^^^ help: consider removing `.into()`: `x`
This breaks:
pub fn make_static<T: MyTrait>(x: T::Borrowed<'_>) -> T::Borrowed<'static> where for<'a> T::Borrowed<'a>: Into<T::Borrowed<'static>>, { x }
9 | x | ^ returning this value requires that `'1` must outlive `'static`
Version
rust stable 1.85.0 clippy 0.1.85 (2025-02-17 4d91de4e48)
Additional Labels
@rustbot label +I-suggestion-causes-error
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedIssue: The suggestions provided by this Lint cause an ICE/error when applied