From 5604d9a93f68e54aac6b5c83811fcd97b252a079 Mon Sep 17 00:00:00 2001 From: David Wood Date: Fri, 7 Jun 2019 18:35:06 +0100 Subject: [PATCH] tests: Add regression test for #61452. --- src/test/ui/async-await/issue-61452.rs | 14 +++++++++++++ src/test/ui/async-await/issue-61452.stderr | 23 ++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/test/ui/async-await/issue-61452.rs create mode 100644 src/test/ui/async-await/issue-61452.stderr diff --git a/src/test/ui/async-await/issue-61452.rs b/src/test/ui/async-await/issue-61452.rs new file mode 100644 index 0000000000000..20b9b645daead --- /dev/null +++ b/src/test/ui/async-await/issue-61452.rs @@ -0,0 +1,14 @@ +// edition:2018 +#![feature(async_await)] + +pub async fn f(x: Option) { + x.take(); + //~^ ERROR cannot borrow `x` as mutable, as it is not declared as mutable [E0596] +} + +pub async fn g(x: usize) { + x += 1; + //~^ ERROR cannot assign twice to immutable variable `x` [E0384] +} + +fn main() {} diff --git a/src/test/ui/async-await/issue-61452.stderr b/src/test/ui/async-await/issue-61452.stderr new file mode 100644 index 0000000000000..742490d8de43c --- /dev/null +++ b/src/test/ui/async-await/issue-61452.stderr @@ -0,0 +1,23 @@ +error[E0596]: cannot borrow `x` as mutable, as it is not declared as mutable + --> $DIR/issue-61452.rs:5:5 + | +LL | pub async fn f(x: Option) { + | - help: consider changing this to be mutable: `mut x` +LL | x.take(); + | ^ cannot borrow as mutable + +error[E0384]: cannot assign twice to immutable variable `x` + --> $DIR/issue-61452.rs:10:5 + | +LL | pub async fn g(x: usize) { + | - + | | + | first assignment to `x` + | help: make this binding mutable: `mut x` +LL | x += 1; + | ^^^^^^ cannot assign twice to immutable variable + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0384, E0596. +For more information about an error, try `rustc --explain E0384`.