-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
A-documentationArea: Adding or improving documentationArea: Adding or improving documentationC-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.I-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 appliedgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
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`
hombit
Metadata
Metadata
Assignees
Labels
A-documentationArea: Adding or improving documentationArea: Adding or improving documentationC-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.Call for participation: Medium difficulty level problem and requires some initial experience.I-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 appliedgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy