about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorTyler Mandry <tmandry@gmail.com>2019-10-05 21:54:54 -0700
committerGitHub <noreply@github.com>2019-10-05 21:54:54 -0700
commit2b225bab136aa844d5052b26f942e07bf048bf0a (patch)
tree8b82dfa8aa90899c6be9f23dccb5ed1072e62017 /src/test
parentc7d7e3730aa211bec291f31d5318628411c1ba77 (diff)
parente8796cada9d962e30417a8f4f973f2c99727d0da (diff)
downloadrust-2b225bab136aa844d5052b26f942e07bf048bf0a.tar.gz
rust-2b225bab136aa844d5052b26f942e07bf048bf0a.zip
Rollup merge of #65011 - estebank:ice-o-matic, r=zackmdavis
Do not ICE when dereferencing non-Copy raw pointer

CC #52262. Confirmed to remove the unnecessary ICE, but without a repro case.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/issues/issue-52262.rs25
-rw-r--r--src/test/ui/issues/issue-52262.stderr9
2 files changed, 34 insertions, 0 deletions
diff --git a/src/test/ui/issues/issue-52262.rs b/src/test/ui/issues/issue-52262.rs
new file mode 100644
index 00000000000..2195b895557
--- /dev/null
+++ b/src/test/ui/issues/issue-52262.rs
@@ -0,0 +1,25 @@
+// compile-flags:-Ztreat-err-as-bug=5
+#[derive(Debug)]
+enum MyError {
+    NotFound { key: Vec<u8> },
+    Err41,
+}
+
+impl std::error::Error for MyError {}
+
+impl std::fmt::Display for MyError {
+    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+        match self {
+            MyError::NotFound { key } => write!(
+                f,
+                "unknown error with code {}.",
+                String::from_utf8(*key).unwrap()
+                //~^ ERROR cannot move out of `*key` which is behind a shared reference
+            ),
+            MyError::Err41 => write!(f, "Sit by a lake"),
+        }
+    }
+}
+fn main() {
+    println!("Hello, world!");
+}
diff --git a/src/test/ui/issues/issue-52262.stderr b/src/test/ui/issues/issue-52262.stderr
new file mode 100644
index 00000000000..7312976c801
--- /dev/null
+++ b/src/test/ui/issues/issue-52262.stderr
@@ -0,0 +1,9 @@
+error[E0507]: cannot move out of `*key` which is behind a shared reference
+  --> $DIR/issue-52262.rs:16:35
+   |
+LL |                 String::from_utf8(*key).unwrap()
+   |                                   ^^^^ move occurs because `*key` has type `std::vec::Vec<u8>`, which does not implement the `Copy` trait
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0507`.