-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
This lint disagrees with rustc if a function can be const in certain situations involving the nightly #![feature(const_trait_impl)].
Lint Name
missing_const_for_fn
Reproducer
I tried this code:
#![feature(const_trait_impl)]
pub const trait All {
fn all() -> impl Iterator<Item = Self>;
}
impl const All for i32 {
fn all() -> impl Iterator<Item = Self> {
Self::MIN..=Self::MAX
}
}
#[deny(clippy::missing_const_for_fn)]
fn breaks() {
let x = i32::all();
}I saw this happen:
error: this could be a `const fn`
--> src/lib.rs:12:1
|
12 | / fn breaks() {
13 | | let x = i32::all();
14 | | }
| |_^I expected to see this happen:
This lint is a false positive here, as following the suggestion leads to:
error[E0493]: destructor of `impl std::iter::Iterator<Item = i32>` cannot be evaluated at compile-time
--> src/lib.rs:13:9
|
13 | let x = i32::all();
| ^ the destructor for this type cannot be evaluated in constant functions
14 | }
| - value is dropped hereVersion
rustc 1.94.0-nightly (21cf7fb3f 2025-12-28)
binary: rustc
commit-hash: 21cf7fb3ff9159b0b562431312969dd548ae8782
commit-date: 2025-12-28
host: x86_64-unknown-linux-gnu
release: 1.94.0-nightly
LLVM version: 21.1.8
Additional Labels
@rustbot label +I-suggestion-causes-error
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