Skip to content

Commit 2469ab1

Browse files
committed
Use Option<Symbol> in panic_call.
Instead of `kw::Empty`. It makes it clearer that this is a name that is searched for and might not be found.
1 parent bd61e01 commit 2469ab1

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

compiler/rustc_lint/src/non_fmt_panic.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_parse_format::{ParseMode, Parser, Piece};
77
use rustc_session::lint::FutureIncompatibilityReason;
88
use rustc_session::{declare_lint, declare_lint_pass};
99
use rustc_span::edition::Edition;
10-
use rustc_span::{InnerSpan, Span, Symbol, hygiene, kw, sym};
10+
use rustc_span::{InnerSpan, Span, Symbol, hygiene, sym};
1111
use rustc_trait_selection::infer::InferCtxtExt;
1212

1313
use crate::lints::{NonFmtPanicBraces, NonFmtPanicUnused};
@@ -167,7 +167,7 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
167167
.get_diagnostic_item(sym::Debug)
168168
.is_some_and(|t| infcx.type_implements_trait(t, [ty], param_env).may_apply());
169169

170-
let suggest_panic_any = !is_str && panic == sym::std_panic_macro;
170+
let suggest_panic_any = !is_str && panic == Some(sym::std_panic_macro);
171171

172172
let fmt_applicability = if suggest_panic_any {
173173
// If we can use panic_any, use that as the MachineApplicable suggestion.
@@ -297,10 +297,13 @@ fn find_delimiters(cx: &LateContext<'_>, span: Span) -> Option<(Span, Span, char
297297
))
298298
}
299299

300-
fn panic_call<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>) -> (Span, Symbol, Symbol) {
300+
fn panic_call<'tcx>(
301+
cx: &LateContext<'tcx>,
302+
f: &'tcx hir::Expr<'tcx>,
303+
) -> (Span, Option<Symbol>, Symbol) {
301304
let mut expn = f.span.ctxt().outer_expn_data();
302305

303-
let mut panic_macro = kw::Empty;
306+
let mut panic_macro = None;
304307

305308
// Unwrap more levels of macro expansion, as panic_2015!()
306309
// was likely expanded from panic!() and possibly from
@@ -320,7 +323,7 @@ fn panic_call<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>) -> (Span,
320323
break;
321324
}
322325
expn = parent;
323-
panic_macro = name;
326+
panic_macro = Some(name);
324327
}
325328

326329
let macro_symbol =

0 commit comments

Comments
 (0)