This compiles:
fn main() {
let x = &5;
x = &std::panic!()
}
This does not:
fn main() {
let x = &5;
x = &core::panic!()
}
error[E0308]: mismatched types
--> src/main.rs:3:9
|
3 | x = &core::panic!()
| ^^^^^^^^^^^^^^^ expected integer, found `!`
|
= note: expected reference `&{integer}`
found reference `&!`
The cause seems to be that std::panic!() expands to { some_function(..) } while core::panic!() expands to some_function(..), without { .. }. Adding { .. } in the core::panic!() macro_rules 'fixes' it.