Propagate mutability from arguments to local bindings in async fn
This commit is contained in:
parent
d15fc17381
commit
2fe50bc01b
2 changed files with 14 additions and 6 deletions
|
@ -8725,9 +8725,9 @@ impl<'a> Parser<'a> {
|
||||||
// Check if this is a ident pattern, if so, we can optimize and avoid adding 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>;`
|
// `let <pat> = __argN;` statement, instead just adding a `let <pat> = <pat>;`
|
||||||
// statement.
|
// statement.
|
||||||
let (ident, is_simple_pattern) = match input.pat.node {
|
let (binding_mode, ident, is_simple_pattern) = match input.pat.node {
|
||||||
PatKind::Ident(_, ident, _) => (ident, true),
|
PatKind::Ident(binding_mode, ident, _) => (binding_mode, ident, true),
|
||||||
_ => (ident, false),
|
_ => (BindingMode::ByValue(Mutability::Immutable), ident, false),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Construct an argument representing `__argN: <ty>` to replace the argument of the
|
// Construct an argument representing `__argN: <ty>` to replace the argument of the
|
||||||
|
@ -8755,9 +8755,7 @@ impl<'a> Parser<'a> {
|
||||||
let move_local = Local {
|
let move_local = Local {
|
||||||
pat: P(Pat {
|
pat: P(Pat {
|
||||||
id,
|
id,
|
||||||
node: PatKind::Ident(
|
node: PatKind::Ident(binding_mode, ident, None),
|
||||||
BindingMode::ByValue(Mutability::Immutable), ident, None,
|
|
||||||
),
|
|
||||||
span,
|
span,
|
||||||
}),
|
}),
|
||||||
// We explicitly do not specify the type for this statement. When the user's
|
// We explicitly do not specify the type for this statement. When the user's
|
||||||
|
|
10
src/test/ui/async-await/mutable-arguments.rs
Normal file
10
src/test/ui/async-await/mutable-arguments.rs
Normal file
|
@ -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() {}
|
Loading…
Add table
Add a link
Reference in a new issue