about summary refs log tree commit diff
path: root/src/test/ui
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-01-06 15:30:46 +0000
committerbors <bors@rust-lang.org>2022-01-06 15:30:46 +0000
commitcfa4ac66c194046f631ce076c75516ecfdeb77ee (patch)
tree10ace45fd5a86349c627f743747c097c5cdb7256 /src/test/ui
parenta77cc64af491a31db224109a76b9b81cd26cd07c (diff)
parent26a90e4cd780175dd2d9dbf061eccd53eb9a2489 (diff)
downloadrust-cfa4ac66c194046f631ce076c75516ecfdeb77ee.tar.gz
rust-cfa4ac66c194046f631ce076c75516ecfdeb77ee.zip
Auto merge of #92609 - matthiaskrgr:rollup-ldp47ot, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #92058 (Make Run button visible on hover)
 - #92288 (Fix a pair of mistyped test cases in `std::net::ip`)
 - #92349 (Fix rustdoc::private_doc_tests lint for public re-exported items)
 - #92360 (Some cleanups around check_argument_types)
 - #92389 (Regression test for borrowck ICE #92015)
 - #92404 (Fix font size for [src] links in headers)
 - #92443 (Rustdoc: resolve associated traits for non-generic primitive types)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'src/test/ui')
-rw-r--r--src/test/ui/borrowck/issue-92015.rs7
-rw-r--r--src/test/ui/borrowck/issue-92015.stderr11
-rw-r--r--src/test/ui/c-variadic/variadic-unreachable-arg-error.rs14
3 files changed, 32 insertions, 0 deletions
diff --git a/src/test/ui/borrowck/issue-92015.rs b/src/test/ui/borrowck/issue-92015.rs
new file mode 100644
index 00000000000..16d651717ff
--- /dev/null
+++ b/src/test/ui/borrowck/issue-92015.rs
@@ -0,0 +1,7 @@
+// Regression test for #92105.
+// ICE when mutating immutable reference from last statement of a block.
+
+fn main() {
+    let foo = Some(&0).unwrap();
+    *foo = 1; //~ ERROR cannot assign
+}
diff --git a/src/test/ui/borrowck/issue-92015.stderr b/src/test/ui/borrowck/issue-92015.stderr
new file mode 100644
index 00000000000..32a65d3b5bb
--- /dev/null
+++ b/src/test/ui/borrowck/issue-92015.stderr
@@ -0,0 +1,11 @@
+error[E0594]: cannot assign to `*foo`, which is behind a `&` reference
+  --> $DIR/issue-92015.rs:6:5
+   |
+LL |     let foo = Some(&0).unwrap();
+   |         --- help: consider changing this to be a mutable reference: `&mut i32`
+LL |     *foo = 1;
+   |     ^^^^^^^^ `foo` is a `&` reference, so the data it refers to cannot be written
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0594`.
diff --git a/src/test/ui/c-variadic/variadic-unreachable-arg-error.rs b/src/test/ui/c-variadic/variadic-unreachable-arg-error.rs
new file mode 100644
index 00000000000..f60f6f3e808
--- /dev/null
+++ b/src/test/ui/c-variadic/variadic-unreachable-arg-error.rs
@@ -0,0 +1,14 @@
+// check-pass
+
+#![feature(c_variadic)]
+
+extern "C" {
+    fn foo(f: isize, x: u8, ...);
+}
+
+fn main() {
+    unsafe {
+        // FIXME: Ideally we could give an unreachable warning
+        foo(1, loop {}, 1usize);
+    }
+}