Skip to content

async fn raises unused_mut on parameter that is used mutably #60566

Closed
@Arnavion

Description

@Arnavion
rustc 1.36.0-nightly (8dd4aae9a 2019-05-04)
binary: rustc
commit-hash: 8dd4aae9a83964cc08505da92d07ec68a3a2341d
commit-date: 2019-05-04
host: x86_64-pc-windows-msvc
release: 1.36.0-nightly
LLVM version: 8.0

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=4f2bb9f701bdbbb3424e926989bc0f2f

#![feature(async_await)]
#![deny(unused_mut)]

pub struct S;

pub async fn foo(mut s: S) {
    let _ = &mut s;
}

raises unused_mut on the s parameter of foo.

@taiki-e This is also raised in the test case you added in #60501, but I assume the test passes because it defaults to ignoring the warning.


Workaround:

-pub async fn foo(mut s: S) {
+pub async fn foo(s: S) {
+    let mut s = s;
     let _ = &mut s;

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-async-awaitArea: Async & AwaitA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions