]> git.lizzy.rs Git - rust.git/commitdiff
Add comment about how we find the right span in non_fmt_panic.
authorMara Bos <m-ou.se@m-ou.se>
Wed, 17 Feb 2021 09:51:22 +0000 (10:51 +0100)
committerMara Bos <m-ou.se@m-ou.se>
Wed, 17 Feb 2021 09:51:22 +0000 (10:51 +0100)
compiler/rustc_lint/src/non_fmt_panic.rs

index 0c7c8b78845cff9b3f81b28dc800ff7dc356cb79..bfe37ce6959e7d59f56e8f6e520c48f473f05815 100644 (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) {