-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
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 have
Description
Lint name: useless_conversion
Reproduction using current nightly on Playground
I tried this code:
struct MyStruct<const C: char>;
impl From<MyStruct<'a'>> for MyStruct<'b'> {
fn from(_s: MyStruct<'a'>) -> Self {
MyStruct
}
}
fn main() {
let s: MyStruct<'a'> = MyStruct;
let _: MyStruct<'b'> = s.into();
}
I expected to see this happen: No Clippy warnings.
Instead, this happened:
Checking playground v0.0.1 (/playground)
warning: useless conversion to the same type: `MyStruct<'a'>`
--> src/main.rs:11:28
|
11 | let _: MyStruct<'b'> = s.into();
| ^^^^^^^^ help: consider removing `.into()`: `s`
|
= note: `#[warn(clippy::useless_conversion)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion
warning: 1 warning emitted
Finished dev [unoptimized + debuginfo] target(s) in 0.54s
The conversion isn't useless - removing .into()
is a compilation error.
Meta
Clippy and rustc are current nightly: 2021-05-09
This seems like a very similar error to #7206, but I filed them separately because they're different lints.
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 have