needless_pass_by_ref_mut
false positive for required mut reference in async function
#11216
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-error
Issue: The suggestions provided by this Lint cause an ICE/error when applied
Summary
When passing a mut reference into an async function, the
needless_pass_by_ref_mut
warning is always triggered, even if the reference is used to call a function that requires it to be mutable. If the suggestion is taken, the resulting code does not compile.Removing the
async
modifier from therequires_mut
function in the reproducer (and replacingblock_on
with a direct function call) will produce correct output. In practice I discovered this bug with a trait parameter for anasync_trait
, but it presents on struct methods as well.Lint Name
needless_pass_by_ref_mut
Reproducer
I tried this code:
I saw this happen:
I expected to see this happen:
No warning generated, the mut reference is required.
Version
Additional Labels
@rustbot label +I-suggestion-causes-error
The text was updated successfully, but these errors were encountered: