- Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
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 haveI-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 applied
Description
Summary
.
Lint Name
use_self
Reproducer
I tried this code:
struct Foo; impl Foo { fn foo<const N: usize>(&self) -> usize { let f = self; f.bar::<{ let f = Foo; f.bar::<7>() }>() + N } const fn bar<const M: usize>(&self) -> usize { M } } fn main() { let f = Foo; assert_eq!(f.foo::<13>(), 20) }
I saw this happen:
warning: unnecessary structure name repetition --> const-arg-in-const-arg.rs:7:21 | 7 | let f = Foo; | ^^^ help: use the applicable keyword: `Self` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#use_self = note: requested on the command line with `-W clippy::use-self`
I expected to see this happen:
Suggestion does not compile wif const_generic_exprs feature is not enabled
error: generic parameters may not be used in const operations --> const-arg-in-const-arg.rs:7:21 | 7 | let f = Self; | ^^^^ cannot perform const operation using `Self` | = note: type parameters may not be used in const expressions = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions error: aborting due to previous error
Version
rustc 1.71.0-nightly (6d140d59b 2023-05-06) binary: rustc commit-hash: 6d140d59bb957903b02ddb993450509d8d92b448 commit-date: 2023-05-06 host: x86_64-unknown-linux-gnu release: 1.71.0-nightly LLVM version: 16.0.2
Additional Labels
No response
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 haveI-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 applied