From ad93f48d770cc8cfe473e809700201c31550bc68 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 17 Feb 2021 10:51:22 +0100 Subject: [PATCH] Add comment about how we find the right span in non_fmt_panic. --- compiler/rustc_lint/src/non_fmt_panic.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compiler/rustc_lint/src/non_fmt_panic.rs b/compiler/rustc_lint/src/non_fmt_panic.rs index 0c7c8b78845..bfe37ce6959 100644 --- a/compiler/rustc_lint/src/non_fmt_panic.rs +++ b/compiler/rustc_lint/src/non_fmt_panic.rs @@ -71,6 +71,9 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc // Find the span of the argument to `panic!()`, before expansion in the // case of `panic!(some_macro!())`. + // We don't use source_callsite(), because this `panic!(..)` might itself + // be expanded from another macro, in which case we want to stop at that + // expansion. let mut arg_span = arg.span; let mut arg_macro = None; while !span.contains(arg_span) {