Skip to content

Commit 2fe50bc

Browse files
committedMay 3, 2019
Propagate mutability from arguments to local bindings in async fn
1 parent d15fc17 commit 2fe50bc

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed
 

‎src/libsyntax/parse/parser.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -8725,9 +8725,9 @@ impl<'a> Parser<'a> {
87258725
// Check if this is a ident pattern, if so, we can optimize and avoid adding a
87268726
// `let <pat> = __argN;` statement, instead just adding a `let <pat> = <pat>;`
87278727
// statement.
8728-
let (ident, is_simple_pattern) = match input.pat.node {
8729-
PatKind::Ident(_, ident, _) => (ident, true),
8730-
_ => (ident, false),
8728+
let (binding_mode, ident, is_simple_pattern) = match input.pat.node {
8729+
PatKind::Ident(binding_mode, ident, _) => (binding_mode, ident, true),
8730+
_ => (BindingMode::ByValue(Mutability::Immutable), ident, false),
87318731
};
87328732

87338733
// Construct an argument representing `__argN: <ty>` to replace the argument of the
@@ -8755,9 +8755,7 @@ impl<'a> Parser<'a> {
87558755
let move_local = Local {
87568756
pat: P(Pat {
87578757
id,
8758-
node: PatKind::Ident(
8759-
BindingMode::ByValue(Mutability::Immutable), ident, None,
8760-
),
8758+
node: PatKind::Ident(binding_mode, ident, None),
87618759
span,
87628760
}),
87638761
// We explicitly do not specify the type for this statement. When the user's
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// edition:2018
2+
// run-pass
3+
4+
#![feature(async_await)]
5+
6+
async fn foo(n: u32, mut vec: Vec<u32>) {
7+
vec.push(n);
8+
}
9+
10+
fn main() {}

0 commit comments

Comments
 (0)