]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_save_analysis/lib.rs
Auto merge of #45709 - nrc:rls-bugs-2, r=eddyb
[rust.git] / src / librustc_save_analysis / lib.rs
index 63dde756787197a7efe15ea361917362e6aea733..5ae1ba92262f5cc0e8202e024943de961076e7c5 100644 (file)
@@ -63,7 +63,7 @@
 use span_utils::SpanUtils;
 
 use rls_data::{Ref, RefKind, SpanData, MacroRef, Def, DefKind, Relation, RelationKind,
-               ExternalCrateData};
+               ExternalCrateData, GlobalCrateId};
 use rls_data::config::Config;
 
 
@@ -82,10 +82,6 @@ pub enum Data {
     RelationData(Relation),
 }
 
-macro_rules! option_try(
-    ($e:expr) => (match $e { Some(e) => e, None => return None })
-);
-
 impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
     fn span_from_span(&self, span: Span) -> SpanData {
         use rls_span::{Row, Column};
@@ -119,9 +115,13 @@ pub fn get_external_crates(&self) -> Vec<ExternalCrateData> {
             };
             let lo_loc = self.span_utils.sess.codemap().lookup_char_pos(span.lo());
             result.push(ExternalCrateData {
-                name: self.tcx.crate_name(n).to_string(),
-                num: n.as_u32(),
                 file_name: SpanUtils::make_path_string(&lo_loc.file.name),
+                num: n.as_u32(),
+                id: GlobalCrateId {
+                    name: self.tcx.crate_name(n).to_string(),
+                    disambiguator: self.tcx.crate_disambiguator(n)
+                                       .to_fingerprint().as_value(),
+                },
             });
         }
 
@@ -762,8 +762,8 @@ pub fn get_macro_use_data(&self, span: Span) -> Option<MacroRef> {
         // macro uses.
         let callsite = span.source_callsite();
         let callsite_span = self.span_from_span(callsite);
-        let callee = option_try!(span.source_callee());
-        let callee_span = option_try!(callee.span);
+        let callee = span.source_callee()?;
+        let callee_span = callee.span?;
 
         // Ignore attribute macros, their spans are usually mangled
         if let MacroAttribute(_) = callee.format {