Skip to content

Commit d7e166d

Browse files
committed
add test for ice "type mismatching when copying!"
Fixes #112824
1 parent 2b57403 commit d7e166d

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// test for #112824 ICE type mismatching when copying!
2+
3+
pub struct Opcode(pub u8);
4+
5+
pub struct Opcode2(&'a S);
6+
//~^ ERROR use of undeclared lifetime name `'a`
7+
//~^^ ERROR cannot find type `S` in this scope
8+
9+
impl Opcode2 {
10+
pub const OP2: Opcode2 = Opcode2(Opcode(0x1));
11+
}
12+
13+
pub fn example2(msg_type: Opcode2) -> impl FnMut(&[u8]) {
14+
move |i| match msg_type {
15+
Opcode2::OP2 => unimplemented!(),
16+
//~^ ERROR could not evaluate constant pattern
17+
}
18+
}
19+
20+
pub fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
error[E0261]: use of undeclared lifetime name `'a`
2+
--> $DIR/ice-type-mismatch-when-copying-112824.rs:5:21
3+
|
4+
LL | pub struct Opcode2(&'a S);
5+
| - ^^ undeclared lifetime
6+
| |
7+
| help: consider introducing lifetime `'a` here: `<'a>`
8+
9+
error[E0412]: cannot find type `S` in this scope
10+
--> $DIR/ice-type-mismatch-when-copying-112824.rs:5:24
11+
|
12+
LL | pub struct Opcode2(&'a S);
13+
| ^ not found in this scope
14+
|
15+
help: you might be missing a type parameter
16+
|
17+
LL | pub struct Opcode2<S>(&'a S);
18+
| +++
19+
20+
error: could not evaluate constant pattern
21+
--> $DIR/ice-type-mismatch-when-copying-112824.rs:15:9
22+
|
23+
LL | Opcode2::OP2 => unimplemented!(),
24+
| ^^^^^^^^^^^^
25+
26+
error: aborting due to 3 previous errors
27+
28+
Some errors have detailed explanations: E0261, E0412.
29+
For more information about an error, try `rustc --explain E0261`.

0 commit comments

Comments
 (0)