From d7e166d408c6c9f86ef2087c5a013c1600ca94f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Fri, 22 Mar 2024 08:31:01 +0100 Subject: [PATCH] add test for ice "type mismatching when copying!" Fixes #112824 --- .../ice-type-mismatch-when-copying-112824.rs | 20 +++++++++++++ ...e-type-mismatch-when-copying-112824.stderr | 29 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 tests/ui/const_prop/ice-type-mismatch-when-copying-112824.rs create mode 100644 tests/ui/const_prop/ice-type-mismatch-when-copying-112824.stderr 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 0000000000000..dc9782295c136 --- /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 0000000000000..9442eac0cf54a --- /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(&'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`.