mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
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:
parent
e265e3d518
commit
2dfe7de8b6
3 changed files with 56 additions and 40 deletions
|
@ -2317,7 +2317,7 @@ impl Evaluator<'_> {
|
|||
|
||||
fn exec_fn_with_args(
|
||||
&mut self,
|
||||
def: FunctionId,
|
||||
mut def: FunctionId,
|
||||
args: &[IntervalAndTy],
|
||||
generic_args: Substitution,
|
||||
locals: &Locals,
|
||||
|
@ -2335,6 +2335,9 @@ impl Evaluator<'_> {
|
|||
)? {
|
||||
return Ok(None);
|
||||
}
|
||||
if let Some(redirect_def) = self.detect_and_redirect_special_function(def)? {
|
||||
def = redirect_def;
|
||||
}
|
||||
let arg_bytes = args.iter().map(|it| IntervalOrOwned::Borrowed(it.interval));
|
||||
match self.get_mir_or_dyn_index(def, generic_args.clone(), locals, span)? {
|
||||
MirOrDynIndex::Dyn(self_ty_idx) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue