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
Closed

async fn forgets the mutability of the arguments #60498

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

Comments

@taiki-e
Copy link
Member

@taiki-e taiki-e 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
Copy link
Member Author

@taiki-e taiki-e commented May 3, 2019

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

@cramertj
Copy link
Member

@cramertj cramertj commented May 3, 2019

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

@davidtwco
Copy link
Member

@davidtwco davidtwco 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
…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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

6 participants