rust-lang / rust-lang/rust-clippy
FP missing-const-for-fn: `the destructor for this type cannot be evaluated in constant functions
Open
@J-ZhengLi is already working on this.
Since Jul 8, 2024.
C-bug
I-false-positive
I-suggestion-causes-error
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
.
Reproducer
I tried this code:
use std::cell::Cell;
const NONE_CELL_STRING: Option<Cell<String>> = None;
fn a() { // clippy suggests this to be const
let _: &'static Option<Cell<String>> = &NONE_CELL_STRING;
}
I expected to see this happen:
Instead, this happened:
error[E0493]: destructor of `std::option::Option<std::cell::Cell<std::string::String>>` cannot be evaluated at compile-time
--> a.rs:6:45
|
6 | let _: &'static Option<Cell<String>> = &NONE_CELL_STRING;
| ^^^^^^^^^^^^^^^^ the destructor for this type cannot be evaluated in constant functions
7 | }
| - value is dropped here
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.