Handle panicking like rustc CTFE does

Instead of using `core::fmt::format` to format panic messages, which may in turn
panic too and cause recursive panics and other messy things, redirect
`panic_fmt` to `const_panic_fmt` like CTFE, which in turn goes to
`panic_display` and does the things normally. See the tests for the full
call stack.
This commit is contained in:
Nilstrieb 2024-03-24 15:39:15 +01:00
parent e265e3d518
commit 2dfe7de8b6
3 changed files with 56 additions and 40 deletions

View file

@ -5105,6 +5105,32 @@ fn foo(e: E) {
);
}
#[test]
fn hover_const_value() {
check(
r#"
pub enum AA {
BB,
}
const CONST: AA = AA::BB;
pub fn the_function() -> AA {
CON$0ST
}
"#,
expect![[r#"
*CONST*
```rust
test
```
```rust
const CONST: AA = BB
```
"#]],
);
}
#[test]
fn array_repeat_exp() {
check(