Closed
Description
clippy 0.0.212 (082cfa7 2019-06-07)
Clippy incorrectly suggests to use Self when implementing From
conversion for the Box<dyn Trait>
type.
#![deny(clippy::pedantic)]
trait Foo: 'static {}
struct Bar;
impl Foo for Bar {}
impl<T: Foo> From<T> for Box<dyn Foo> {
fn from(t: T) -> Self {
Box::new(t)
}
}
Results the following error:
unnecessary structure name repetition
#[deny(clippy::use_self)] implied by #[deny(clippy::pedantic)]
for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#use_selfclippy(use_self)
lib.rs(1, 9): lint level defined here
But code with this suggestion does not compile:
#![deny(clippy::pedantic)]
trait Foo: 'static {}
struct Bar;
impl Foo for Bar {}
impl<T: Foo> From<T> for Box<dyn Foo> {
fn from(t: T) -> Self {
Self::new(t)
}
}
no function or associated item named `new` found for type `std::boxed::Box<(dyn Foo + 'static)>` in the current scope
the method `new` exists but the following trait bounds were not satisfied:
`dyn Foo : std::marker::Sized`
Metadata
Metadata
Assignees
Labels
Area: Adding or improving documentationCategory: Clippy is not doing the correct thingCall for participation: Medium difficulty level problem and requires some initial experience.Issue: The suggestions provided by this Lint cause an ICE/error when appliedThese issues are a good way to get started with Clippy