needless_pass_by_ref_mut
should not trigger when values derived from the &mut
are used in an unsafe block
#13172
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
I-suggestion-causes-bug
Issue: The suggestion compiles but changes the code to behave in an unintended way
Summary
Using values derived from a
&mut
inside of an unsafe block can still trigger theneedless_pass_by_ref_mut
lint.It seems like it was partially addressed in #11586, which should already be present in 1.80, but that only seems to cover direct use of the &mut in an unsafe block, not values derived from the &mut.
Lint Name
needless_pass_by_ref_mut
Reproducer
I tried this code:
I saw this happen:
I expected to see this happen:
Nothing in this case. The compiler can't know if my unsafe usage of
child
is safe to call from a shared reference. Switching it to a shared reference could cause unsoundness.Version
Additional Labels
@rustbot label +I-suggestion-causes-bug
The text was updated successfully, but these errors were encountered: