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

Propagate mutability from arguments to local bindings in async fn #60501

Merged
merged 1 commit into from
May 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8725,9 +8725,9 @@ impl<'a> Parser<'a> {
// Check if this is a ident pattern, if so, we can optimize and avoid adding a
// `let <pat> = __argN;` statement, instead just adding a `let <pat> = <pat>;`
// statement.
let (ident, is_simple_pattern) = match input.pat.node {
PatKind::Ident(_, ident, _) => (ident, true),
_ => (ident, false),
let (binding_mode, ident, is_simple_pattern) = match input.pat.node {
PatKind::Ident(binding_mode, ident, _) => (binding_mode, ident, true),
_ => (BindingMode::ByValue(Mutability::Immutable), ident, false),
};

// Construct an argument representing `__argN: <ty>` to replace the argument of the
Expand Down Expand Up @@ -8755,9 +8755,7 @@ impl<'a> Parser<'a> {
let move_local = Local {
pat: P(Pat {
id,
node: PatKind::Ident(
BindingMode::ByValue(Mutability::Immutable), ident, None,
),
node: PatKind::Ident(binding_mode, ident, None),
span,
}),
// We explicitly do not specify the type for this statement. When the user's
Expand Down
10 changes: 10 additions & 0 deletions src/test/ui/async-await/mutable-arguments.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// edition:2018
// run-pass

#![feature(async_await)]

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

fn main() {}