From 6848ba2665d10380f259addbd9f60d0ab8d3542a Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 17 Aug 2022 06:17:36 +0000 Subject: Comment a bit, use find_ancestor_in_same_ctxt to suppress some weird macro notes --- compiler/rustc_span/src/lib.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'compiler/rustc_span/src') diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index d14e28e85be..a624e3ab142 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -664,6 +664,13 @@ impl Span { Some(self) } + pub fn find_ancestor_in_same_ctxt(mut self, other: Span) -> Option { + while !Span::eq_ctxt(self, other) { + self = self.parent_callsite()?; + } + Some(self) + } + /// Edition of the crate from which this span came. pub fn edition(self) -> edition::Edition { self.ctxt().edition() -- cgit 1.4.1-3-g733a5