Closed
Description
Hello together,
The following code snippet (in src/lib.rs
):
pub struct A;
impl A {
#![warn(clippy::missing_const_for_fn)]
pub fn a(self) -> B {
B
}
}
impl Drop for A {
fn drop(&mut self) {}
}
pub struct B;
leads to this suggestion:
warning: this could be a const_fn
--> src/lib.rs:4:5
|
4 | / pub fn a(self) -> B {
5 | | B
6 | | }
| |_____^
|
note: lint level defined here
--> src/lib.rs:3:13
|
3 | #![warn(clippy::missing_const_for_fn)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_const_for_fn
but the suggested fix (i.e. add the const
qualifier) is wrong. After the fix the following error occurs:
error[E0493]: destructors cannot be evaluated at compile-time
--> src/lib.rs:4:20
|
4 | pub const fn a(self) -> B {
| ^^^^ constant functions cannot evaluate destructors
error: aborting due to previous error
Meta
$ cargo clippy -V
clippy 0.0.212 (e3cb40e 2019-06-25)
$ rustc --version
rustc 1.37.0 (eae3437df 2019-08-13)