Open
Description
Summary
fn a() {
let x = 1 else { return }; //~ WARN irrefutable `let...else` pattern
// Multiline else blocks should not get printed
let x = 1 else { //~ WARN irrefutable `let...else` pattern
eprintln!("problem case encountered");
return
};
}
this cannot be a const fn yet although clippy suggets it:
error[E0015]: cannot call non-const fn `std::io::_eprint` in constant functions
--> a.rs:6:9
|
6 | eprintln!("problem case encountered");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
= note: this error originates in the macro `eprintln` (in Nightly builds, run with -Z macro-backtrace for more info)
error: `std::fmt::Arguments::<'a>::new_const` is not yet stable as a const fn
--> a.rs:6:9
|
6 | eprintln!("problem case encountered");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: add `#![feature(const_fmt_arguments_new)]` to the crate attributes to enable
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `eprintln` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 2 previous errors; 4 warnings emitted
Lint Name
missing-const-for-fn:
Reproducer
I tried this code:
<code>
I saw this happen:
<output>
I expected to see this happen:
Version
rustc 1.81.0-nightly (9c3bc805d 2024-06-27)
binary: rustc
commit-hash: 9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9
commit-date: 2024-06-27
host: x86_64-unknown-linux-gnu
release: 1.81.0-nightly
LLVM version: 18.1.7
Additional Labels
No response