Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

async fn forgets the mutability of the arguments #60498

Closed
taiki-e opened this issue May 3, 2019 · 3 comments

Comments

Projects
None yet
6 participants
@taiki-e
Copy link
Contributor

commented May 3, 2019

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)

@taiki-e

This comment has been minimized.

Copy link
Contributor Author

commented May 3, 2019

@rustbot modify labels: A-async-await and T-compiler.

@cramertj

This comment has been minimized.

Copy link
Member

commented May 3, 2019

@davidtwco I wonder if this is related to the drop order fix desugaring?

@davidtwco

This comment has been minimized.

Copy link
Member

commented May 3, 2019

@cramertj Oops, looks like it is. Thanks @taiki-e for the fix.

Centril added a commit to Centril/rust that referenced this issue May 3, 2019

Rollup merge of rust-lang#60501 - taiki-e:async-await-mutable-argumen…
…ts, r=cramertj

Propagate mutability from arguments to local bindings in async fn

Fixes rust-lang#60498

cc @nikomatsakis
r? @davidtwco

@bors bors closed this in #60501 May 3, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.