Closed
Description
$ cargo clippy -V
clippy 0.0.212 (fc96aa03 2019-05-04)
Clippy incorrectly suggests to use Self when referring to a generic type with a different T
in a trait implementation.
impl TryFromMrb<Value> for Option<String> {
type From = Ruby;
type To = Rust;
unsafe fn try_from_mrb(
interp: &Mrb,
value: Value,
) -> Result<Self, Error<Self::From, Self::To>> {
// Clippy suggests replacing "Option" with "Self", which does not compile
let value = <Option<Value>>::try_from_mrb(interp, value)?;
if let Some(item) = value {
Ok(Some(String::try_from_mrb(interp, item)?))
} else {
Ok(None)
}
}
}
Results in the following error
error: unnecessary structure name repetition
--> mruby/src/convert/nilable/string.rs:36:22
|
36 | let value = <Option<Value>>::try_from_mrb(interp, value)?;
| ^^^^^^ help: use the applicable keyword: `Self`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#use_self