-
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-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 appliedL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestions
Description
clippy 0.0.212 (754b4c0 2018-11-23)
The following function triggers the use_self
lint:
enum MyEnum { A, B }
impl MyEnum {
pub fn iterator<'a>(self) -> impl Iterator<Item=&'a Self> {
static ITEMS: [MyEnum; 2] = [MyEnum::A, MyEnum::B];
ITEMS.iter()
}
}
Replacing [MyEnum; 2]
with [Self; 2]
, as suggested, leads to this error:
error[E0401]: can't use type parameters from outer function
Minimal example:
enum MyEnum { A }
impl MyEnum {
fn foo() {
static FOO: MyEnum = MyEnum::A;
}
}
Clippy suggests changing FOO: MyEnum
to FOO: Self
, which doesn't compile
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-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 appliedL-suggestionLint: Improving, adding or fixing lint suggestionsLint: Improving, adding or fixing lint suggestions