From 2fe50bc01bf9023b64a72407bb41a1f3b7245abd Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 3 May 2019 13:04:26 +0900 Subject: Propagate mutability from arguments to local bindings in async fn --- src/libsyntax/parse/parser.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index f70acb3e7da..c5173aa5569 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -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 = __argN;` statement, instead just adding a `let = ;` // 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: ` to replace the argument of the @@ -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 -- cgit 1.4.1-3-g733a5