missing_const_for_fn
misses some cases with generics involved
#12677
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-negative
Issue: The lint should have been triggered on code, but wasn't
Summary
As soon as there is some type complexity involved the lint seems to fail to see the possible
const
.At first, I suspected generics and lifetimes on the struct, but they don't seem to be the main reason as its also reproducible without. Having generic things like
Vec<Generic>
seems to be part of the issue.Interestingly it's not the entire issue as my second example highlights.
I'm not sure if I can further pinpoint the root cause. When more is known please update the issue title to reflect this.
Lint Name
missing_const_for_fn
Reproducer
I expected to see this happen:
The lint should hint both methods to be possible as
const
.Instead, this happened:
Only the second method is marked to be possible as
const
.Another way where a
Vec
seems to prevent this lint from working is this:The lint should also detect this one, but it doesn't. Removing the
vec
from the struct andnew
function and this is correctly suggested. Usingtext: usize
instead oftext: String
also works. So somehow this combination results in not detecting this possibleconst
.Version
The text was updated successfully, but these errors were encountered: