Open y21 opened 4 weeks ago
I do wonder what https://github.com/rust-lang/rust-clippy/blob/f5e250180c342bb52808c9a934c962a8fe40afc7/clippy_lints/src/missing_const_for_fn.rs#L154-L158 is for... That seems like dead code essentially. We are early-returning if already_const
before this, so I don't see how is_const_fn_raw()
could be true.
Fixes #12677
The
method_accepts_droppable
check that was there seemed overly conservative.Accepting parameters that implement
Drop
should still be fine as long as the parameter isn't actually dropped, as is the case in the linked issue where the droppable is moved into the return place. This more accurate analysis ("is there adrop
terminator") is already done byqualify_min_const_fn
here, so I don't think this additional check is really necessary?Fixing the other, second case in the linked issue was only slightly more involved, since
Vec::new()
is a function call that has the ability to panic, so there must be adrop()
terminator for cleanup, however we should be able to freely ignore that. Const checking ignores cleanup blocks, so we should, too?r? @Jarcho
changelog: [
missing_const_for_fn
]: continue linting on fns with parameters implementingDrop
if they're not actually dropped