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 · Fixed by #60501
Closed

async fn forgets the mutability of the arguments #60498

taiki-e opened this issue May 3, 2019 · 3 comments · Fixed by #60501
Labels
A-async-await Area: Async & Await AsyncAwait-Polish Async-await issues that are part of the "polish" area C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@taiki-e
Copy link
Member

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 commented May 3, 2019

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

@rustbot rustbot added A-async-await Area: Async & Await T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 3, 2019
@cramertj
Copy link
Member

cramertj commented May 3, 2019

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

@davidtwco
Copy link
Member

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

@jonas-schievink jonas-schievink added the C-bug Category: This is a bug. label May 3, 2019
@Centril Centril added the AsyncAwait-Polish Async-await issues that are part of the "polish" area label May 3, 2019
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await AsyncAwait-Polish Async-await issues that are part of the "polish" area C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants