about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ast_map/mod.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libsyntax/ast_map/mod.rs b/src/libsyntax/ast_map/mod.rs
index 60e4db405d7..b82a4a0b997 100644
--- a/src/libsyntax/ast_map/mod.rs
+++ b/src/libsyntax/ast_map/mod.rs
@@ -536,6 +536,14 @@ impl<'ast> Map<'ast> {
             .unwrap_or_else(|| fail!("AstMap.span: could not find span for id {}", id))
     }
 
+    pub fn def_id_span(&self, def_id: DefId, fallback: Span) -> Span {
+        if def_id.krate == LOCAL_CRATE {
+            self.span(def_id.node)
+        } else {
+            fallback
+        }
+    }
+
     pub fn node_to_string(&self, id: NodeId) -> String {
         node_id_to_string(self, id)
     }