]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/middle/def_id.rs
Rollup merge of #31007 - pra85:license, r=aturon
[rust.git] / src / librustc / middle / def_id.rs
index ed7a1d75a52e929fafb929de196f9ef53dafe667..4d0005f47c4f200d9e210278b18e52ef95668bea 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use metadata::cstore::LOCAL_CRATE;
+use middle::cstore::LOCAL_CRATE;
 use middle::ty;
 use syntax::ast::CrateNum;
 use std::fmt;
@@ -61,12 +61,16 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         // Unfortunately, there seems to be no way to attempt to print
         // a path for a def-id, so I'll just make a best effort for now
         // and otherwise fallback to just printing the crate/node pair
-        try!(ty::tls::with_opt(|opt_tcx| {
-            if let Some(tcx) = opt_tcx {
-                try!(write!(f, " => {}", tcx.item_path_str(*self)));
-            }
-            Ok(())
-        }));
+        if self.is_local() { // (1)
+            // (1) side-step fact that not all external things have paths at
+            // the moment, such as type parameters
+            try!(ty::tls::with_opt(|opt_tcx| {
+                if let Some(tcx) = opt_tcx {
+                    try!(write!(f, " => {}", tcx.item_path_str(*self)));
+                }
+                Ok(())
+            }));
+        }
 
         write!(f, " }}")
     }
@@ -82,5 +86,3 @@ pub fn is_local(&self) -> bool {
         self.krate == LOCAL_CRATE
     }
 }
-
-