about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2018-09-19 01:01:09 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2018-10-05 11:40:40 +0400
commit60a1d4e6c2b23eeed79ea7ca2cbc43713d10197e (patch)
tree92660e050b79e5aa96b049aecd41aaa5eb45aeb1 /src
parent050bd32958dac4413bfc1de0f48073dfbc06c278 (diff)
downloadrust-60a1d4e6c2b23eeed79ea7ca2cbc43713d10197e.tar.gz
rust-60a1d4e6c2b23eeed79ea7ca2cbc43713d10197e.zip
resolve: Keep more precise traces for expanded macro resolutions
`NameBinding`s instead of `Def`s
Diffstat (limited to 'src')
-rw-r--r--src/librustc_resolve/lib.rs3
-rw-r--r--src/librustc_resolve/macros.rs29
2 files changed, 16 insertions, 16 deletions
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs
index b41e9625e4e..a93cc7ad751 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -1014,7 +1014,8 @@ pub struct ModuleData<'a> {
     normal_ancestor_id: DefId,
 
     resolutions: RefCell<FxHashMap<(Ident, Namespace), &'a RefCell<NameResolution<'a>>>>,
-    legacy_macro_resolutions: RefCell<Vec<(Ident, MacroKind, ParentScope<'a>, Option<Def>)>>,
+    legacy_macro_resolutions: RefCell<Vec<(Ident, MacroKind, ParentScope<'a>,
+                                           Option<&'a NameBinding<'a>>)>>,
     macro_resolutions: RefCell<Vec<(Box<[Ident]>, Span)>>,
     builtin_attrs: RefCell<Vec<(Ident, ParentScope<'a>)>>,
 
diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs
index 6c067c669cb..e0ef286a43e 100644
--- a/src/librustc_resolve/macros.rs
+++ b/src/librustc_resolve/macros.rs
@@ -506,21 +506,19 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
 
             def
         } else {
-            let def = match self.early_resolve_ident_in_lexical_scope(path[0], MacroNS, Some(kind),
-                                                                      parent_scope, false, force,
-                                                                      span) {
-                Ok(binding) => Ok(binding.def_ignoring_ambiguity()),
+            let binding = self.early_resolve_ident_in_lexical_scope(
+                path[0], MacroNS, Some(kind), parent_scope, false, force, span
+            );
+            match binding {
+                Ok(..) => {}
+                Err(Determinacy::Determined) => self.found_unresolved_macro = true,
                 Err(Determinacy::Undetermined) => return Err(Determinacy::Undetermined),
-                Err(Determinacy::Determined) => {
-                    self.found_unresolved_macro = true;
-                    Err(Determinacy::Determined)
-                }
-            };
+            }
 
             parent_scope.module.legacy_macro_resolutions.borrow_mut()
-                .push((path[0], kind, parent_scope.clone(), def.ok()));
+                .push((path[0], kind, parent_scope.clone(), binding.ok()));
 
-            def
+            binding.map(|binding| binding.def_ignoring_ambiguity())
         }
     }
 
@@ -866,15 +864,16 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
 
         let legacy_macro_resolutions =
             mem::replace(&mut *module.legacy_macro_resolutions.borrow_mut(), Vec::new());
-        for (ident, kind, parent_scope, initial_def) in legacy_macro_resolutions {
+        for (ident, kind, parent_scope, initial_binding) in legacy_macro_resolutions {
             let binding = self.early_resolve_ident_in_lexical_scope(
                 ident, MacroNS, Some(kind), &parent_scope, true, true, ident.span
             );
             match binding {
                 Ok(binding) => {
-                    self.record_use(ident, MacroNS, binding);
                     let def = binding.def_ignoring_ambiguity();
-                    if let Some(initial_def) = initial_def {
+                    if let Some(initial_binding) = initial_binding {
+                        self.record_use(ident, MacroNS, initial_binding);
+                        let initial_def = initial_binding.def_ignoring_ambiguity();
                         if self.ambiguity_errors.is_empty() &&
                            def != initial_def && def != Def::Err {
                             // Make sure compilation does not succeed if preferred macro resolution
@@ -894,7 +893,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> {
                     }
                 }
                 Err(..) => {
-                    assert!(initial_def.is_none());
+                    assert!(initial_binding.is_none());
                     let bang = if kind == MacroKind::Bang { "!" } else { "" };
                     let msg =
                         format!("cannot find {} `{}{}` in this scope", kind.descr(), ident, bang);