-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Wrong suggestion of const fn
if member of member implements Drop
#4979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
phansch
added a commit
to phansch/rust-clippy
that referenced
this issue
Jan 2, 2020
This fixes some additional false positives with functions or methods that return types which implement drop. Since `drop` can't be const-evaluated, these cases can't be made const. Fixes rust-lang#4979
phansch
added a commit
to phansch/rust-clippy
that referenced
this issue
Jan 3, 2020
This fixes some additional false positives with functions or methods that return types which implement drop. Since `drop` can't be const-evaluated, these cases can't be made const. Fixes rust-lang#4979
This is now triggering more because more things were made const in rust 1.61.0. naga has contains the following code: impl<W: Write> Writer<W> {
/// Finishes writing and returns the output.
pub fn finish(self) -> W {
self.out
}
...
} This triggers the lint:
but when you actually apply that you get an error:
|
This seems fixed. Can we close the issue? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cargo clippy -V: clippy 0.0.212 (c807fbc 2019-12-29)
rustc -V: rustc 1.40.0 (73528e339 2019-12-16)
Summary
A warning "this could be a const_fn" is triggered for a function of a struct that doesn't implement Drop, but on some level of depth contains a member that does implement it. Adding const to such function results in compilation error.
Steps to reproduce
Run the following code with
cargo clippy -- -W clippy::missing-const-for-fn
:It results in a warning:
After adding const to the function
Foo::take
we get an error:Note that Foo doesn't implement Drop, its field String also doesn't, but String's field Vec does implement it.
Also note there was already a similar fixed issue, but for structs that implement Drop: #4449
The text was updated successfully, but these errors were encountered: