about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/borrowck/tainted-promoteds.rs12
-rw-r--r--tests/ui/borrowck/tainted-promoteds.stderr14
2 files changed, 26 insertions, 0 deletions
diff --git a/tests/ui/borrowck/tainted-promoteds.rs b/tests/ui/borrowck/tainted-promoteds.rs
new file mode 100644
index 00000000000..2b6f0ddbd6c
--- /dev/null
+++ b/tests/ui/borrowck/tainted-promoteds.rs
@@ -0,0 +1,12 @@
+// Regression test for issue #110856, where a borrowck error for a MIR tainted
+// all promoteds within. This in turn generated a spurious "erroneous constant
+// used" note when trying to evaluate a promoted.
+
+pub fn f() -> u32 {
+    let a = 0;
+    a = &0 * &1 * &2 * &3;
+    //~^ ERROR: cannot assign twice to immutable variable
+    a
+}
+
+fn main() {}
diff --git a/tests/ui/borrowck/tainted-promoteds.stderr b/tests/ui/borrowck/tainted-promoteds.stderr
new file mode 100644
index 00000000000..b276ea9aceb
--- /dev/null
+++ b/tests/ui/borrowck/tainted-promoteds.stderr
@@ -0,0 +1,14 @@
+error[E0384]: cannot assign twice to immutable variable `a`
+  --> $DIR/tainted-promoteds.rs:7:5
+   |
+LL |     let a = 0;
+   |         -
+   |         |
+   |         first assignment to `a`
+   |         help: consider making this binding mutable: `mut a`
+LL |     a = &0 * &1 * &2 * &3;
+   |     ^^^^^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0384`.