about summary refs log tree commit diff
path: root/compiler/rustc_span/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-12-10 09:24:44 +0100
committerGitHub <noreply@github.com>2022-12-10 09:24:44 +0100
commitcf840069f3975ad628c3e7cfa8353cbfa9e40cf7 (patch)
tree346297e2d15dab0abf6a6a5afcb4687914363efb /compiler/rustc_span/src
parent9e87dd907e1cb29ca77a18f3888ee6980b625647 (diff)
parentb9da55afb5c2773b6fb50141aa71305891583526 (diff)
downloadrust-cf840069f3975ad628c3e7cfa8353cbfa9e40cf7.tar.gz
rust-cf840069f3975ad628c3e7cfa8353cbfa9e40cf7.zip
Rollup merge of #105514 - estebank:is_visible, r=oli-obk
Introduce `Span::is_visible`

r? `@oli-obk`
Diffstat (limited to 'compiler/rustc_span/src')
-rw-r--r--compiler/rustc_span/src/lib.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs
index cef4c6f79ce..335bfc3302f 100644
--- a/compiler/rustc_span/src/lib.rs
+++ b/compiler/rustc_span/src/lib.rs
@@ -491,6 +491,10 @@ impl SpanData {
     pub fn is_dummy(self) -> bool {
         self.lo.0 == 0 && self.hi.0 == 0
     }
+    #[inline]
+    pub fn is_visible(self, sm: &SourceMap) -> bool {
+        !self.is_dummy() && sm.is_span_accessible(self.span())
+    }
     /// Returns `true` if `self` fully encloses `other`.
     pub fn contains(self, other: Self) -> bool {
         self.lo <= other.lo && other.hi <= self.hi
@@ -556,6 +560,11 @@ impl Span {
         self.data_untracked().is_dummy()
     }
 
+    #[inline]
+    pub fn is_visible(self, sm: &SourceMap) -> bool {
+        self.data_untracked().is_visible(sm)
+    }
+
     /// Returns `true` if this span comes from any kind of macro, desugaring or inlining.
     #[inline]
     pub fn from_expansion(self) -> bool {