Skip to content

Commit

Permalink
add test for ice "type mismatching when copying!"
Browse files Browse the repository at this point in the history
Fixes #112824
  • Loading branch information
matthiaskrgr committed Mar 22, 2024
1 parent 2b57403 commit d7e166d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/ui/const_prop/ice-type-mismatch-when-copying-112824.rs
Original file line number Diff line number Diff line change
@@ -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() {}
29 changes: 29 additions & 0 deletions tests/ui/const_prop/ice-type-mismatch-when-copying-112824.stderr
Original file line number Diff line number Diff line change
@@ -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`.

0 comments on commit d7e166d

Please sign in to comment.