Auto merge of #14092 - Veykril:inlay-hint-panic, r=Veykril
fix: Don't panic on broken syntax trees in adjustment inlay hints These should be unreachable, but apparently with broken enough syntax trees (I assume mismatched parens), we do reach these unreachable calls. Haven't quite figured out when this happens though.
This commit is contained in:
commit
e9d0bfc799
@ -6,6 +6,7 @@
|
|||||||
use hir::{Adjust, Adjustment, AutoBorrow, HirDisplay, Mutability, PointerCast, Safety, Semantics};
|
use hir::{Adjust, Adjustment, AutoBorrow, HirDisplay, Mutability, PointerCast, Safety, Semantics};
|
||||||
use ide_db::RootDatabase;
|
use ide_db::RootDatabase;
|
||||||
|
|
||||||
|
use stdx::never;
|
||||||
use syntax::{
|
use syntax::{
|
||||||
ast::{self, make, AstNode},
|
ast::{self, make, AstNode},
|
||||||
ted,
|
ted,
|
||||||
@ -210,16 +211,21 @@ fn needs_parens_for_adjustment_hints(expr: &ast::Expr, postfix: bool) -> (bool,
|
|||||||
ted::replace(expr.syntax(), dummy_expr.syntax());
|
ted::replace(expr.syntax(), dummy_expr.syntax());
|
||||||
|
|
||||||
let parent = dummy_expr.syntax().parent();
|
let parent = dummy_expr.syntax().parent();
|
||||||
let expr = if postfix {
|
let Some(expr) = (|| {
|
||||||
let ast::Expr::TryExpr(e) = &dummy_expr else { unreachable!() };
|
if postfix {
|
||||||
let Some(ast::Expr::ParenExpr(e)) = e.expr() else { unreachable!() };
|
let ast::Expr::TryExpr(e) = &dummy_expr else { return None };
|
||||||
|
let Some(ast::Expr::ParenExpr(e)) = e.expr() else { return None };
|
||||||
|
|
||||||
e.expr().unwrap()
|
e.expr()
|
||||||
} else {
|
} else {
|
||||||
let ast::Expr::RefExpr(e) = &dummy_expr else { unreachable!() };
|
let ast::Expr::RefExpr(e) = &dummy_expr else { return None };
|
||||||
let Some(ast::Expr::ParenExpr(e)) = e.expr() else { unreachable!() };
|
let Some(ast::Expr::ParenExpr(e)) = e.expr() else { return None };
|
||||||
|
|
||||||
e.expr().unwrap()
|
e.expr()
|
||||||
|
}
|
||||||
|
})() else {
|
||||||
|
never!("broken syntax tree?\n{:?}\n{:?}", expr, dummy_expr);
|
||||||
|
return (true, true)
|
||||||
};
|
};
|
||||||
|
|
||||||
// At this point
|
// At this point
|
||||||
|
Loading…
Reference in New Issue
Block a user