Add comment about how we find the right span in non_fmt_panic.

This commit is contained in:
Mara Bos 2021-02-17 10:51:22 +01:00
parent daa371d189
commit ad93f48d77
1 changed files with 3 additions and 0 deletions

View File

@ -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) {