about summary refs log tree commit diff
path: root/src/libsyntax_pos/lib.rs
diff options
context:
space:
mode:
authorAriel Ben-Yehuda <ariel.byd@gmail.com>2017-08-31 00:12:34 +0300
committerAriel Ben-Yehuda <ariel.byd@gmail.com>2017-09-03 13:10:54 +0300
commit02b3ae63e2d3fd2fe7496eaa8b6862322aaf38b3 (patch)
tree6e1a3525e66f0c7a6da07c26769bcda7d0eaf4d1 /src/libsyntax_pos/lib.rs
parent6866aea5af0cebe3c3a942585e36c9033e1122ef (diff)
downloadrust-02b3ae63e2d3fd2fe7496eaa8b6862322aaf38b3.tar.gz
rust-02b3ae63e2d3fd2fe7496eaa8b6862322aaf38b3.zip
enable desugaring-sensitive error messages and use them in Try
Maybe I should allow error messages to check the *specific* desugaring?
Thanks @huntiep for the idea!
Diffstat (limited to 'src/libsyntax_pos/lib.rs')
-rw-r--r--src/libsyntax_pos/lib.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs
index 24842ff29d4..cba5c812b07 100644
--- a/src/libsyntax_pos/lib.rs
+++ b/src/libsyntax_pos/lib.rs
@@ -205,6 +205,18 @@ impl Span {
         }
     }
 
+    /// Return the compiler desugaring that created this span, or None
+    /// if this span is not from a desugaring.
+    pub fn compiler_desugaring_kind(&self) -> Option<CompilerDesugaringKind> {
+        match self.ctxt().outer().expn_info() {
+            Some(info) => match info.callee.format {
+                ExpnFormat::CompilerDesugaring(k) => Some(k),
+                _ => None
+            },
+            None => None
+        }
+    }
+
     /// Check if a span is "internal" to a macro in which `unsafe`
     /// can be used without triggering the `unsafe_code` lint
     //  (that is, a macro marked with `#[allow_internal_unsafe]`).