about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-03-22 08:31:01 +0100
committerMatthias Krüger <matthias.krueger@famsik.de>2024-03-22 08:31:01 +0100
commitd7e166d408c6c9f86ef2087c5a013c1600ca94f3 (patch)
tree335631c21b0eb908d752835cf1a3e7e329a43b75
parent2b5740371c42c632efb3dbe46150798baf56a8d1 (diff)
downloadrust-d7e166d408c6c9f86ef2087c5a013c1600ca94f3.tar.gz
rust-d7e166d408c6c9f86ef2087c5a013c1600ca94f3.zip
add test for ice "type mismatching when copying!"
Fixes #112824
-rw-r--r--tests/ui/const_prop/ice-type-mismatch-when-copying-112824.rs20
-rw-r--r--tests/ui/const_prop/ice-type-mismatch-when-copying-112824.stderr29
2 files changed, 49 insertions, 0 deletions
diff --git a/tests/ui/const_prop/ice-type-mismatch-when-copying-112824.rs b/tests/ui/const_prop/ice-type-mismatch-when-copying-112824.rs
new file mode 100644
index 00000000000..dc9782295c1
--- /dev/null
+++ b/tests/ui/const_prop/ice-type-mismatch-when-copying-112824.rs
@@ -0,0 +1,20 @@
+// test for #112824 ICE type mismatching when copying!
+
+pub struct Opcode(pub u8);
+
+pub struct Opcode2(&'a S);
+//~^ ERROR use of undeclared lifetime name `'a`
+//~^^ ERROR cannot find type `S` in this scope
+
+impl Opcode2 {
+    pub const OP2: Opcode2 = Opcode2(Opcode(0x1));
+}
+
+pub fn example2(msg_type: Opcode2) -> impl FnMut(&[u8]) {
+    move |i| match msg_type {
+        Opcode2::OP2 => unimplemented!(),
+        //~^ ERROR could not evaluate constant pattern
+    }
+}
+
+pub fn main() {}
diff --git a/tests/ui/const_prop/ice-type-mismatch-when-copying-112824.stderr b/tests/ui/const_prop/ice-type-mismatch-when-copying-112824.stderr
new file mode 100644
index 00000000000..9442eac0cf5
--- /dev/null
+++ b/tests/ui/const_prop/ice-type-mismatch-when-copying-112824.stderr
@@ -0,0 +1,29 @@
+error[E0261]: use of undeclared lifetime name `'a`
+  --> $DIR/ice-type-mismatch-when-copying-112824.rs:5:21
+   |
+LL | pub struct Opcode2(&'a S);
+   |                   - ^^ undeclared lifetime
+   |                   |
+   |                   help: consider introducing lifetime `'a` here: `<'a>`
+
+error[E0412]: cannot find type `S` in this scope
+  --> $DIR/ice-type-mismatch-when-copying-112824.rs:5:24
+   |
+LL | pub struct Opcode2(&'a S);
+   |                        ^ not found in this scope
+   |
+help: you might be missing a type parameter
+   |
+LL | pub struct Opcode2<S>(&'a S);
+   |                   +++
+
+error: could not evaluate constant pattern
+  --> $DIR/ice-type-mismatch-when-copying-112824.rs:15:9
+   |
+LL |         Opcode2::OP2 => unimplemented!(),
+   |         ^^^^^^^^^^^^
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0261, E0412.
+For more information about an error, try `rustc --explain E0261`.