Skip to content

async fn forgets the mutability of the arguments #60498

Closed
@taiki-e

Description

@taiki-e

Code:

#![feature(async_await)]

async fn foo(n: u32, mut vec: Vec<u32>) {
    vec.push(n);
}

Error:

error[E0596]: cannot borrow `vec` as mutable, as it is not declared as mutable
 --> code\src\lib.rs:4:5
  |
3 | async fn foo(n: u32, mut vec: Vec<u32>) {
  |                      ------- help: consider changing this to be mutable: `mut vec`
4 |     vec.push(n);
  |     ^^^ cannot borrow as mutable

Rustc version: rustc 1.36.0-nightly (08bfe16 2019-05-02)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-async-awaitArea: Async & AwaitAsyncAwait-PolishAsync-await issues that are part of the "polish" areaC-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