about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2020-03-07 19:02:32 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2020-03-07 19:30:57 +0300
commit66d7a88c41ebcc25e499babd103177a9d8df6cdb (patch)
tree9b459b825b413539c570c46c32f661eea449fd4c
parent1915bf122e488ce540cdb7782550e907f269b9e3 (diff)
downloadrust-66d7a88c41ebcc25e499babd103177a9d8df6cdb.tar.gz
rust-66d7a88c41ebcc25e499babd103177a9d8df6cdb.zip
resolve: `directive` -> `import`
-rw-r--r--src/librustc_resolve/build_reduced_graph.rs51
-rw-r--r--src/librustc_resolve/check_unused.rs30
-rw-r--r--src/librustc_resolve/diagnostics.rs18
-rw-r--r--src/librustc_resolve/imports.rs264
-rw-r--r--src/librustc_resolve/late.rs8
-rw-r--r--src/librustc_resolve/lib.rs77
-rw-r--r--src/test/ui/rust-2018/macro-use-warned-against.rs2
-rw-r--r--src/test/ui/rust-2018/macro-use-warned-against.stderr2
8 files changed, 215 insertions, 237 deletions
diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs
index 32cf1af60ec..ec5a8c4a0b8 100644
--- a/src/librustc_resolve/build_reduced_graph.rs
+++ b/src/librustc_resolve/build_reduced_graph.rs
@@ -307,8 +307,8 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
         })
     }
 
-    // Add an import directive to the current module.
-    fn add_import_directive(
+    // Add an import to the current module.
+    fn add_import(
         &mut self,
         module_path: Vec<Segment>,
         kind: ImportKind<'a>,
@@ -320,7 +320,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
         vis: ty::Visibility,
     ) {
         let current_module = self.parent_scope.module;
-        let directive = self.r.arenas.alloc_import_directive(Import {
+        let import = self.r.arenas.alloc_import(Import {
             kind,
             parent_scope: self.parent_scope,
             module_path,
@@ -336,10 +336,10 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
             used: Cell::new(false),
         });
 
-        debug!("add_import_directive({:?})", directive);
+        debug!("add_import({:?})", import);
 
-        self.r.indeterminate_imports.push(directive);
-        match directive.kind {
+        self.r.indeterminate_imports.push(import);
+        match import.kind {
             // Don't add unresolved underscore imports to modules
             ImportKind::Single { target: Ident { name: kw::Underscore, .. }, .. } => {}
             ImportKind::Single { target, type_ns_only, .. } => {
@@ -347,14 +347,14 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
                     if !type_ns_only || ns == TypeNS {
                         let key = this.new_key(target, ns);
                         let mut resolution = this.resolution(current_module, key).borrow_mut();
-                        resolution.add_single_import(directive);
+                        resolution.add_single_import(import);
                     }
                 });
             }
             // We don't add prelude imports to the globs since they only affect lexical scopes,
             // which are not relevant to import resolution.
             ImportKind::Glob { is_prelude: true, .. } => {}
-            ImportKind::Glob { .. } => current_module.globs.borrow_mut().push(directive),
+            ImportKind::Glob { .. } => current_module.globs.borrow_mut().push(import),
             _ => unreachable!(),
         }
     }
@@ -495,7 +495,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
                     type_ns_only,
                     nested,
                 };
-                self.add_import_directive(
+                self.add_import(
                     module_path,
                     kind,
                     use_tree.span,
@@ -511,16 +511,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
                     is_prelude: attr::contains_name(&item.attrs, sym::prelude_import),
                     max_vis: Cell::new(ty::Visibility::Invisible),
                 };
-                self.add_import_directive(
-                    prefix,
-                    kind,
-                    use_tree.span,
-                    id,
-                    item,
-                    root_span,
-                    item.id,
-                    vis,
-                );
+                self.add_import(prefix, kind, use_tree.span, id, item, root_span, item.id, vis);
             }
             ast::UseTreeKind::Nested(ref items) => {
                 // Ensure there is at most one `self` in the list
@@ -636,7 +627,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
                 let used = self.process_legacy_macro_imports(item, module);
                 let binding =
                     (module, ty::Visibility::Public, sp, expansion).to_name_binding(self.r.arenas);
-                let directive = self.r.arenas.alloc_import_directive(Import {
+                let import = self.r.arenas.alloc_import(Import {
                     kind: ImportKind::ExternCrate { source: orig_name, target: ident },
                     root_id: item.id,
                     id: item.id,
@@ -651,8 +642,8 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
                     vis: Cell::new(vis),
                     used: Cell::new(used),
                 });
-                self.r.potentially_unused_imports.push(directive);
-                let imported_binding = self.r.import(binding, directive);
+                self.r.potentially_unused_imports.push(import);
+                let imported_binding = self.r.import(binding, import);
                 if ptr::eq(parent, self.r.graph_root) {
                     if let Some(entry) = self.r.extern_prelude.get(&ident.modern()) {
                         if expansion != ExpnId::root()
@@ -988,8 +979,8 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
             }
         }
 
-        let macro_use_directive = |this: &Self, span| {
-            this.r.arenas.alloc_import_directive(Import {
+        let macro_use_import = |this: &Self, span| {
+            this.r.arenas.alloc_import(Import {
                 kind: ImportKind::MacroUse,
                 root_id: item.id,
                 id: item.id,
@@ -1008,11 +999,11 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
 
         let allow_shadowing = self.parent_scope.expansion == ExpnId::root();
         if let Some(span) = import_all {
-            let directive = macro_use_directive(self, span);
-            self.r.potentially_unused_imports.push(directive);
+            let import = macro_use_import(self, span);
+            self.r.potentially_unused_imports.push(import);
             module.for_each_child(self, |this, ident, ns, binding| {
                 if ns == MacroNS {
-                    let imported_binding = this.r.import(binding, directive);
+                    let imported_binding = this.r.import(binding, import);
                     this.legacy_import_macro(ident.name, imported_binding, span, allow_shadowing);
                 }
             });
@@ -1027,9 +1018,9 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
                     ident.span,
                 );
                 if let Ok(binding) = result {
-                    let directive = macro_use_directive(self, ident.span);
-                    self.r.potentially_unused_imports.push(directive);
-                    let imported_binding = self.r.import(binding, directive);
+                    let import = macro_use_import(self, ident.span);
+                    self.r.potentially_unused_imports.push(import);
+                    let imported_binding = self.r.import(binding, import);
                     self.legacy_import_macro(
                         ident.name,
                         imported_binding,
diff --git a/src/librustc_resolve/check_unused.rs b/src/librustc_resolve/check_unused.rs
index 5d45fcb3934..722f843ab6e 100644
--- a/src/librustc_resolve/check_unused.rs
+++ b/src/librustc_resolve/check_unused.rs
@@ -3,7 +3,7 @@
 //
 // Although this is mostly a lint pass, it lives in here because it depends on
 // resolve data structures and because it finalises the privacy information for
-// `use` directives.
+// `use` items.
 //
 // Unused trait imports can't be checked until the method resolution. We save
 // candidates here, and do the actual check in librustc_typeck/check_unused.rs.
@@ -58,7 +58,7 @@ struct UnusedImportCheckVisitor<'a, 'b> {
 }
 
 impl<'a, 'b> UnusedImportCheckVisitor<'a, 'b> {
-    // We have information about whether `use` (import) directives are actually
+    // We have information about whether `use` (import) items are actually
     // used now. If an import is not used at all, we signal a lint error.
     fn check_import(&mut self, id: ast::NodeId) {
         let mut used = false;
@@ -223,33 +223,33 @@ fn calc_unused_spans(
 
 impl Resolver<'_> {
     crate fn check_unused(&mut self, krate: &ast::Crate) {
-        for directive in self.potentially_unused_imports.iter() {
-            match directive.kind {
-                _ if directive.used.get()
-                    || directive.vis.get() == ty::Visibility::Public
-                    || directive.span.is_dummy() =>
+        for import in self.potentially_unused_imports.iter() {
+            match import.kind {
+                _ if import.used.get()
+                    || import.vis.get() == ty::Visibility::Public
+                    || import.span.is_dummy() =>
                 {
-                    if let ImportKind::MacroUse = directive.kind {
-                        if !directive.span.is_dummy() {
+                    if let ImportKind::MacroUse = import.kind {
+                        if !import.span.is_dummy() {
                             self.lint_buffer.buffer_lint(
                                 lint::builtin::MACRO_USE_EXTERN_CRATE,
-                                directive.id,
-                                directive.span,
-                                "deprecated `#[macro_use]` directive used to \
+                                import.id,
+                                import.span,
+                                "deprecated `#[macro_use]` attribute used to \
                                 import macros should be replaced at use sites \
-                                with a `use` statement to import the macro \
+                                with a `use` item to import the macro \
                                 instead",
                             );
                         }
                     }
                 }
                 ImportKind::ExternCrate { .. } => {
-                    self.maybe_unused_extern_crates.push((directive.id, directive.span));
+                    self.maybe_unused_extern_crates.push((import.id, import.span));
                 }
                 ImportKind::MacroUse => {
                     let lint = lint::builtin::UNUSED_IMPORTS;
                     let msg = "unused `#[macro_use]` import";
-                    self.lint_buffer.buffer_lint(lint, directive.id, directive.span, msg);
+                    self.lint_buffer.buffer_lint(lint, import.id, import.span, msg);
                 }
                 _ => {}
             }
diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs
index 52d50b95000..38efc907ff0 100644
--- a/src/librustc_resolve/diagnostics.rs
+++ b/src/librustc_resolve/diagnostics.rs
@@ -1126,7 +1126,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
     /// ```
     pub(crate) fn check_for_module_export_macro(
         &mut self,
-        directive: &'b Import<'b>,
+        import: &'b Import<'b>,
         module: ModuleOrUniformRoot<'b>,
         ident: Ident,
     ) -> Option<(Option<Suggestion>, Vec<String>)> {
@@ -1151,7 +1151,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
         let binding = resolution.borrow().binding()?;
         if let Res::Def(DefKind::Macro(MacroKind::Bang), _) = binding.res() {
             let module_name = crate_module.kind.name().unwrap();
-            let import = match directive.kind {
+            let import_snippet = match import.kind {
                 ImportKind::Single { source, target, .. } if source != target => {
                     format!("{} as {}", source, target)
                 }
@@ -1159,18 +1159,18 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
             };
 
             let mut corrections: Vec<(Span, String)> = Vec::new();
-            if !directive.is_nested() {
+            if !import.is_nested() {
                 // Assume this is the easy case of `use issue_59764::foo::makro;` and just remove
                 // intermediate segments.
-                corrections.push((directive.span, format!("{}::{}", module_name, import)));
+                corrections.push((import.span, format!("{}::{}", module_name, import_snippet)));
             } else {
                 // Find the binding span (and any trailing commas and spaces).
                 //   ie. `use a::b::{c, d, e};`
                 //                      ^^^
                 let (found_closing_brace, binding_span) = find_span_of_binding_until_next_binding(
                     self.r.session,
-                    directive.span,
-                    directive.use_span,
+                    import.span,
+                    import.use_span,
                 );
                 debug!(
                     "check_for_module_export_macro: found_closing_brace={:?} binding_span={:?}",
@@ -1207,7 +1207,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
                 let (has_nested, after_crate_name) = find_span_immediately_after_crate_name(
                     self.r.session,
                     module_name,
-                    directive.use_span,
+                    import.use_span,
                 );
                 debug!(
                     "check_for_module_export_macro: has_nested={:?} after_crate_name={:?}",
@@ -1223,11 +1223,11 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
                         start_point,
                         if has_nested {
                             // In this case, `start_snippet` must equal '{'.
-                            format!("{}{}, ", start_snippet, import)
+                            format!("{}{}, ", start_snippet, import_snippet)
                         } else {
                             // In this case, add a `{`, then the moved import, then whatever
                             // was there before.
-                            format!("{{{}, {}", import, start_snippet)
+                            format!("{{{}, {}", import_snippet, start_snippet)
                         },
                     ));
                 }
diff --git a/src/librustc_resolve/imports.rs b/src/librustc_resolve/imports.rs
index a43ef4ffee4..81c1e496c9d 100644
--- a/src/librustc_resolve/imports.rs
+++ b/src/librustc_resolve/imports.rs
@@ -34,7 +34,7 @@ use std::{mem, ptr};
 
 type Res = def::Res<NodeId>;
 
-/// Contains data for specific types of import directives.
+/// Contains data for specific kinds of imports.
 #[derive(Clone, Debug)]
 pub enum ImportKind<'a> {
     Single {
@@ -63,7 +63,7 @@ pub enum ImportKind<'a> {
     MacroUse,
 }
 
-/// One import directive.
+/// One import.
 #[derive(Debug, Clone)]
 crate struct Import<'a> {
     pub kind: ImportKind<'a>,
@@ -77,7 +77,7 @@ crate struct Import<'a> {
     /// use foo::bar::{a, b}
     /// ```
     ///
-    /// If this is the import directive for `foo::bar::a`, we would have the ID of the `UseTree`
+    /// If this is the import for `foo::bar::a`, we would have the ID of the `UseTree`
     /// for `a` in this field.
     pub id: NodeId,
 
@@ -135,7 +135,7 @@ impl<'a> Import<'a> {
 /// Records information about the resolution of a name in a namespace of a module.
 pub struct NameResolution<'a> {
     /// Single imports that may define the name in the namespace.
-    /// Import directives are arena-allocated, so it's ok to use pointers as keys.
+    /// Imports are arena-allocated, so it's ok to use pointers as keys.
     single_imports: FxHashSet<PtrKey<'a, Import<'a>>>,
     /// The least shadowable known binding for this name, or None if there are no known bindings.
     pub binding: Option<&'a NameBinding<'a>>,
@@ -154,8 +154,8 @@ impl<'a> NameResolution<'a> {
         })
     }
 
-    crate fn add_single_import(&mut self, directive: &'a Import<'a>) {
-        self.single_imports.insert(PtrKey(directive));
+    crate fn add_single_import(&mut self, import: &'a Import<'a>) {
+        self.single_imports.insert(PtrKey(import));
     }
 }
 
@@ -450,34 +450,34 @@ impl<'a> Resolver<'a> {
         Err((Determined, Weak::No))
     }
 
-    // Given a binding and an import directive that resolves to it,
-    // return the corresponding binding defined by the import directive.
+    // Given a binding and an import that resolves to it,
+    // return the corresponding binding defined by the import.
     crate fn import(
         &self,
         binding: &'a NameBinding<'a>,
-        directive: &'a Import<'a>,
+        import: &'a Import<'a>,
     ) -> &'a NameBinding<'a> {
-        let vis = if binding.pseudo_vis().is_at_least(directive.vis.get(), self) ||
+        let vis = if binding.pseudo_vis().is_at_least(import.vis.get(), self) ||
                      // cf. `PUB_USE_OF_PRIVATE_EXTERN_CRATE`
-                     !directive.is_glob() && binding.is_extern_crate()
+                     !import.is_glob() && binding.is_extern_crate()
         {
-            directive.vis.get()
+            import.vis.get()
         } else {
             binding.pseudo_vis()
         };
 
-        if let ImportKind::Glob { ref max_vis, .. } = directive.kind {
-            if vis == directive.vis.get() || vis.is_at_least(max_vis.get(), self) {
+        if let ImportKind::Glob { ref max_vis, .. } = import.kind {
+            if vis == import.vis.get() || vis.is_at_least(max_vis.get(), self) {
                 max_vis.set(vis)
             }
         }
 
         self.arenas.alloc_name_binding(NameBinding {
-            kind: NameBindingKind::Import { binding, directive, used: Cell::new(false) },
+            kind: NameBindingKind::Import { binding, import, used: Cell::new(false) },
             ambiguity: None,
-            span: directive.span,
+            span: import.span,
             vis,
-            expansion: directive.parent_scope.expansion,
+            expansion: import.parent_scope.expansion,
         })
     }
 
@@ -576,17 +576,17 @@ impl<'a> Resolver<'a> {
         };
 
         // Define `binding` in `module`s glob importers.
-        for directive in module.glob_importers.borrow_mut().iter() {
+        for import in module.glob_importers.borrow_mut().iter() {
             let mut ident = key.ident;
-            let scope = match ident.span.reverse_glob_adjust(module.expansion, directive.span) {
+            let scope = match ident.span.reverse_glob_adjust(module.expansion, import.span) {
                 Some(Some(def)) => self.macro_def_scope(def),
-                Some(None) => directive.parent_scope.module,
+                Some(None) => import.parent_scope.module,
                 None => continue,
             };
             if self.is_accessible_from(binding.vis, scope) {
-                let imported_binding = self.import(binding, directive);
+                let imported_binding = self.import(binding, import);
                 let key = BindingKey { ident, ..key };
-                let _ = self.try_define(directive.parent_scope.module, key, imported_binding);
+                let _ = self.try_define(import.parent_scope.module, key, imported_binding);
             }
         }
 
@@ -595,13 +595,13 @@ impl<'a> Resolver<'a> {
 
     // Define a "dummy" resolution containing a Res::Err as a placeholder for a
     // failed resolution
-    fn import_dummy_binding(&mut self, directive: &'a Import<'a>) {
-        if let ImportKind::Single { target, .. } = directive.kind {
+    fn import_dummy_binding(&mut self, import: &'a Import<'a>) {
+        if let ImportKind::Single { target, .. } = import.kind {
             let dummy_binding = self.dummy_binding;
-            let dummy_binding = self.import(dummy_binding, directive);
+            let dummy_binding = self.import(dummy_binding, import);
             self.per_ns(|this, ns| {
                 let key = this.new_key(target, ns);
-                let _ = this.try_define(directive.parent_scope.module, key, dummy_binding);
+                let _ = this.try_define(import.parent_scope.module, key, dummy_binding);
                 // Consider erroneous imports used to avoid duplicate diagnostics.
                 this.record_use(target, ns, dummy_binding, false);
             });
@@ -766,28 +766,28 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
 
     /// Attempts to resolve the given import, returning true if its resolution is determined.
     /// If successful, the resolved bindings are written into the module.
-    fn resolve_import(&mut self, directive: &'b Import<'b>) -> bool {
+    fn resolve_import(&mut self, import: &'b Import<'b>) -> bool {
         debug!(
             "(resolving import for module) resolving import `{}::...` in `{}`",
-            Segment::names_to_string(&directive.module_path),
-            module_to_string(directive.parent_scope.module).unwrap_or_else(|| "???".to_string()),
+            Segment::names_to_string(&import.module_path),
+            module_to_string(import.parent_scope.module).unwrap_or_else(|| "???".to_string()),
         );
 
-        let module = if let Some(module) = directive.imported_module.get() {
+        let module = if let Some(module) = import.imported_module.get() {
             module
         } else {
             // For better failure detection, pretend that the import will
             // not define any names while resolving its module path.
-            let orig_vis = directive.vis.replace(ty::Visibility::Invisible);
+            let orig_vis = import.vis.replace(ty::Visibility::Invisible);
             let path_res = self.r.resolve_path(
-                &directive.module_path,
+                &import.module_path,
                 None,
-                &directive.parent_scope,
+                &import.parent_scope,
                 false,
-                directive.span,
-                directive.crate_lint(),
+                import.span,
+                import.crate_lint(),
             );
-            directive.vis.set(orig_vis);
+            import.vis.set(orig_vis);
 
             match path_res {
                 PathResult::Module(module) => module,
@@ -796,9 +796,8 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
             }
         };
 
-        directive.imported_module.set(Some(module));
-        let (source, target, source_bindings, target_bindings, type_ns_only) = match directive.kind
-        {
+        import.imported_module.set(Some(module));
+        let (source, target, source_bindings, target_bindings, type_ns_only) = match import.kind {
             ImportKind::Single {
                 source,
                 target,
@@ -808,7 +807,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
                 ..
             } => (source, target, source_bindings, target_bindings, type_ns_only),
             ImportKind::Glob { .. } => {
-                self.resolve_glob_import(directive);
+                self.resolve_glob_import(import);
                 return true;
             }
             _ => unreachable!(),
@@ -820,23 +819,23 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
                 if let Err(Undetermined) = source_bindings[ns].get() {
                     // For better failure detection, pretend that the import will
                     // not define any names while resolving its module path.
-                    let orig_vis = directive.vis.replace(ty::Visibility::Invisible);
+                    let orig_vis = import.vis.replace(ty::Visibility::Invisible);
                     let binding = this.resolve_ident_in_module(
                         module,
                         source,
                         ns,
-                        &directive.parent_scope,
+                        &import.parent_scope,
                         false,
-                        directive.span,
+                        import.span,
                     );
-                    directive.vis.set(orig_vis);
+                    import.vis.set(orig_vis);
 
                     source_bindings[ns].set(binding);
                 } else {
                     return;
                 };
 
-                let parent = directive.parent_scope.module;
+                let parent = import.parent_scope.module;
                 match source_bindings[ns].get() {
                     Err(Undetermined) => indeterminate = true,
                     // Don't update the resolution, because it was never added.
@@ -844,20 +843,20 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
                     Err(Determined) => {
                         let key = this.new_key(target, ns);
                         this.update_resolution(parent, key, |_, resolution| {
-                            resolution.single_imports.remove(&PtrKey(directive));
+                            resolution.single_imports.remove(&PtrKey(import));
                         });
                     }
                     Ok(binding) if !binding.is_importable() => {
                         let msg = format!("`{}` is not directly importable", target);
-                        struct_span_err!(this.session, directive.span, E0253, "{}", &msg)
-                            .span_label(directive.span, "cannot be imported directly")
+                        struct_span_err!(this.session, import.span, E0253, "{}", &msg)
+                            .span_label(import.span, "cannot be imported directly")
                             .emit();
                         // Do not import this illegal binding. Import a dummy binding and pretend
                         // everything is fine
-                        this.import_dummy_binding(directive);
+                        this.import_dummy_binding(import);
                     }
                     Ok(binding) => {
-                        let imported_binding = this.import(binding, directive);
+                        let imported_binding = this.import(binding, import);
                         target_bindings[ns].set(Some(imported_binding));
                         this.define(parent, target, ns, imported_binding);
                     }
@@ -872,35 +871,35 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
     ///
     /// Optionally returns an unresolved import error. This error is buffered and used to
     /// consolidate multiple unresolved import errors into a single diagnostic.
-    fn finalize_import(&mut self, directive: &'b Import<'b>) -> Option<UnresolvedImportError> {
-        let orig_vis = directive.vis.replace(ty::Visibility::Invisible);
+    fn finalize_import(&mut self, import: &'b Import<'b>) -> Option<UnresolvedImportError> {
+        let orig_vis = import.vis.replace(ty::Visibility::Invisible);
         let prev_ambiguity_errors_len = self.r.ambiguity_errors.len();
         let path_res = self.r.resolve_path(
-            &directive.module_path,
+            &import.module_path,
             None,
-            &directive.parent_scope,
+            &import.parent_scope,
             true,
-            directive.span,
-            directive.crate_lint(),
+            import.span,
+            import.crate_lint(),
         );
         let no_ambiguity = self.r.ambiguity_errors.len() == prev_ambiguity_errors_len;
-        directive.vis.set(orig_vis);
+        import.vis.set(orig_vis);
         if let PathResult::Failed { .. } | PathResult::NonModule(..) = path_res {
             // Consider erroneous imports used to avoid duplicate diagnostics.
-            self.r.used_imports.insert((directive.id, TypeNS));
+            self.r.used_imports.insert((import.id, TypeNS));
         }
         let module = match path_res {
             PathResult::Module(module) => {
                 // Consistency checks, analogous to `finalize_macro_resolutions`.
-                if let Some(initial_module) = directive.imported_module.get() {
+                if let Some(initial_module) = import.imported_module.get() {
                     if !ModuleOrUniformRoot::same_def(module, initial_module) && no_ambiguity {
-                        span_bug!(directive.span, "inconsistent resolution for an import");
+                        span_bug!(import.span, "inconsistent resolution for an import");
                     }
                 } else {
                     if self.r.privacy_errors.is_empty() {
                         let msg = "cannot determine resolution for the import";
                         let msg_note = "import resolution is stuck, try simplifying other imports";
-                        self.r.session.struct_span_err(directive.span, msg).note(msg_note).emit();
+                        self.r.session.struct_span_err(import.span, msg).note(msg_note).emit();
                     }
                 }
 
@@ -908,7 +907,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
             }
             PathResult::Failed { is_error_from_last_segment: false, span, label, suggestion } => {
                 if no_ambiguity {
-                    assert!(directive.imported_module.get().is_none());
+                    assert!(import.imported_module.get().is_none());
                     self.r
                         .report_error(span, ResolutionError::FailedToResolve { label, suggestion });
                 }
@@ -916,11 +915,11 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
             }
             PathResult::Failed { is_error_from_last_segment: true, span, label, suggestion } => {
                 if no_ambiguity {
-                    assert!(directive.imported_module.get().is_none());
+                    assert!(import.imported_module.get().is_none());
                     let err = match self.make_path_suggestion(
                         span,
-                        directive.module_path.clone(),
-                        &directive.parent_scope,
+                        import.module_path.clone(),
+                        &import.parent_scope,
                     ) {
                         Some((suggestion, note)) => UnresolvedImportError {
                             span,
@@ -945,7 +944,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
             }
             PathResult::NonModule(path_res) if path_res.base_res() == Res::Err => {
                 if no_ambiguity {
-                    assert!(directive.imported_module.get().is_none());
+                    assert!(import.imported_module.get().is_none());
                 }
                 // The error was already reported earlier.
                 return None;
@@ -953,7 +952,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
             PathResult::Indeterminate | PathResult::NonModule(..) => unreachable!(),
         };
 
-        let (ident, target, source_bindings, target_bindings, type_ns_only) = match directive.kind {
+        let (ident, target, source_bindings, target_bindings, type_ns_only) = match import.kind {
             ImportKind::Single {
                 source,
                 target,
@@ -963,24 +962,24 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
                 ..
             } => (source, target, source_bindings, target_bindings, type_ns_only),
             ImportKind::Glob { is_prelude, ref max_vis } => {
-                if directive.module_path.len() <= 1 {
+                if import.module_path.len() <= 1 {
                     // HACK(eddyb) `lint_if_path_starts_with_module` needs at least
                     // 2 segments, so the `resolve_path` above won't trigger it.
-                    let mut full_path = directive.module_path.clone();
+                    let mut full_path = import.module_path.clone();
                     full_path.push(Segment::from_ident(Ident::invalid()));
                     self.r.lint_if_path_starts_with_module(
-                        directive.crate_lint(),
+                        import.crate_lint(),
                         &full_path,
-                        directive.span,
+                        import.span,
                         None,
                     );
                 }
 
                 if let ModuleOrUniformRoot::Module(module) = module {
-                    if module.def_id() == directive.parent_scope.module.def_id() {
+                    if module.def_id() == import.parent_scope.module.def_id() {
                         // Importing a module into itself is not allowed.
                         return Some(UnresolvedImportError {
-                            span: directive.span,
+                            span: import.span,
                             label: Some(String::from("cannot glob-import a module into itself")),
                             note: Vec::new(),
                             suggestion: None,
@@ -989,15 +988,10 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
                 }
                 if !is_prelude &&
                    max_vis.get() != ty::Visibility::Invisible && // Allow empty globs.
-                   !max_vis.get().is_at_least(directive.vis.get(), &*self)
+                   !max_vis.get().is_at_least(import.vis.get(), &*self)
                 {
                     let msg = "glob import doesn't reexport anything because no candidate is public enough";
-                    self.r.lint_buffer.buffer_lint(
-                        UNUSED_IMPORTS,
-                        directive.id,
-                        directive.span,
-                        msg,
-                    );
+                    self.r.lint_buffer.buffer_lint(UNUSED_IMPORTS, import.id, import.span, msg);
                 }
                 return None;
             }
@@ -1007,7 +1001,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
         let mut all_ns_err = true;
         self.r.per_ns(|this, ns| {
             if !type_ns_only || ns == TypeNS {
-                let orig_vis = directive.vis.replace(ty::Visibility::Invisible);
+                let orig_vis = import.vis.replace(ty::Visibility::Invisible);
                 let orig_blacklisted_binding =
                     mem::replace(&mut this.blacklisted_binding, target_bindings[ns].get());
                 let orig_last_import_segment = mem::replace(&mut this.last_import_segment, true);
@@ -1015,13 +1009,13 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
                     module,
                     ident,
                     ns,
-                    &directive.parent_scope,
+                    &import.parent_scope,
                     true,
-                    directive.span,
+                    import.span,
                 );
                 this.last_import_segment = orig_last_import_segment;
                 this.blacklisted_binding = orig_blacklisted_binding;
-                directive.vis.set(orig_vis);
+                import.vis.set(orig_vis);
 
                 match binding {
                     Ok(binding) => {
@@ -1038,7 +1032,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
                                         ident,
                                         ns,
                                         target_binding,
-                                        directive.module_path.is_empty(),
+                                        import.module_path.is_empty(),
                                     );
                                 }
                             }
@@ -1047,7 +1041,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
                         let res = binding.res();
                         if let Ok(initial_res) = initial_res {
                             if res != initial_res && this.ambiguity_errors.is_empty() {
-                                span_bug!(directive.span, "inconsistent resolution for an import");
+                                span_bug!(import.span, "inconsistent resolution for an import");
                             }
                         } else {
                             if res != Res::Err
@@ -1058,7 +1052,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
                                 let msg_note =
                                     "import resolution is stuck, try simplifying other imports";
                                 this.session
-                                    .struct_span_err(directive.span, msg)
+                                    .struct_span_err(import.span, msg)
                                     .note(msg_note)
                                     .emit();
                             }
@@ -1084,9 +1078,9 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
                         module,
                         ident,
                         ns,
-                        &directive.parent_scope,
+                        &import.parent_scope,
                         true,
-                        directive.span,
+                        import.span,
                     );
                     if binding.is_ok() {
                         all_ns_failed = false;
@@ -1137,7 +1131,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
                     });
 
                 let (suggestion, note) =
-                    match self.check_for_module_export_macro(directive, module, ident) {
+                    match self.check_for_module_export_macro(import, module, ident) {
                         Some((suggestion, note)) => (suggestion.or(lev_suggestion), note),
                         _ => (lev_suggestion, Vec::new()),
                     };
@@ -1163,14 +1157,14 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
                 };
 
                 Some(UnresolvedImportError {
-                    span: directive.span,
+                    span: import.span,
                     label: Some(label),
                     note,
                     suggestion,
                 })
             } else {
                 // `resolve_ident_in_module` reported a privacy error.
-                self.r.import_dummy_binding(directive);
+                self.r.import_dummy_binding(import);
                 None
             };
         }
@@ -1179,7 +1173,7 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
         let mut any_successful_reexport = false;
         self.r.per_ns(|this, ns| {
             if let Ok(binding) = source_bindings[ns].get() {
-                let vis = directive.vis.get();
+                let vis = import.vis.get();
                 if !binding.pseudo_vis().is_at_least(vis, &*this) {
                     reexport_error = Some((ns, binding));
                 } else {
@@ -1200,42 +1194,42 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
                 );
                 self.r.lint_buffer.buffer_lint(
                     PUB_USE_OF_PRIVATE_EXTERN_CRATE,
-                    directive.id,
-                    directive.span,
+                    import.id,
+                    import.span,
                     &msg,
                 );
             } else if ns == TypeNS {
                 struct_span_err!(
                     self.r.session,
-                    directive.span,
+                    import.span,
                     E0365,
                     "`{}` is private, and cannot be re-exported",
                     ident
                 )
-                .span_label(directive.span, format!("re-export of private `{}`", ident))
+                .span_label(import.span, format!("re-export of private `{}`", ident))
                 .note(&format!("consider declaring type or module `{}` with `pub`", ident))
                 .emit();
             } else {
                 let msg = format!("`{}` is private, and cannot be re-exported", ident);
                 let note_msg =
                     format!("consider marking `{}` as `pub` in the imported module", ident,);
-                struct_span_err!(self.r.session, directive.span, E0364, "{}", &msg)
-                    .span_note(directive.span, &note_msg)
+                struct_span_err!(self.r.session, import.span, E0364, "{}", &msg)
+                    .span_note(import.span, &note_msg)
                     .emit();
             }
         }
 
-        if directive.module_path.len() <= 1 {
+        if import.module_path.len() <= 1 {
             // HACK(eddyb) `lint_if_path_starts_with_module` needs at least
             // 2 segments, so the `resolve_path` above won't trigger it.
-            let mut full_path = directive.module_path.clone();
+            let mut full_path = import.module_path.clone();
             full_path.push(Segment::from_ident(ident));
             self.r.per_ns(|this, ns| {
                 if let Ok(binding) = source_bindings[ns].get() {
                     this.lint_if_path_starts_with_module(
-                        directive.crate_lint(),
+                        import.crate_lint(),
                         &full_path,
-                        directive.span,
+                        import.span,
                         Some(binding),
                     );
                 }
@@ -1247,17 +1241,11 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
         // purposes it's good enough to just favor one over the other.
         self.r.per_ns(|this, ns| {
             if let Ok(binding) = source_bindings[ns].get() {
-                this.import_res_map.entry(directive.id).or_default()[ns] = Some(binding.res());
+                this.import_res_map.entry(import.id).or_default()[ns] = Some(binding.res());
             }
         });
 
-        self.check_for_redundant_imports(
-            ident,
-            directive,
-            source_bindings,
-            target_bindings,
-            target,
-        );
+        self.check_for_redundant_imports(ident, import, source_bindings, target_bindings, target);
 
         debug!("(resolving single import) successfully resolved import");
         None
@@ -1266,19 +1254,19 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
     fn check_for_redundant_imports(
         &mut self,
         ident: Ident,
-        directive: &'b Import<'b>,
+        import: &'b Import<'b>,
         source_bindings: &PerNS<Cell<Result<&'b NameBinding<'b>, Determinacy>>>,
         target_bindings: &PerNS<Cell<Option<&'b NameBinding<'b>>>>,
         target: Ident,
     ) {
         // Skip if the import was produced by a macro.
-        if directive.parent_scope.expansion != ExpnId::root() {
+        if import.parent_scope.expansion != ExpnId::root() {
             return;
         }
 
         // Skip if we are inside a named module (in contrast to an anonymous
         // module defined by a block).
-        if let ModuleKind::Def(..) = directive.parent_scope.module.kind {
+        if let ModuleKind::Def(..) = import.parent_scope.module.kind {
             return;
         }
 
@@ -1298,10 +1286,10 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
                 match this.early_resolve_ident_in_lexical_scope(
                     target,
                     ScopeSet::All(ns, false),
-                    &directive.parent_scope,
+                    &import.parent_scope,
                     false,
                     false,
-                    directive.span,
+                    import.span,
                 ) {
                     Ok(other_binding) => {
                         is_redundant[ns] = Some(
@@ -1323,35 +1311,35 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
             redundant_spans.dedup();
             self.r.lint_buffer.buffer_lint_with_diagnostic(
                 UNUSED_IMPORTS,
-                directive.id,
-                directive.span,
+                import.id,
+                import.span,
                 &format!("the item `{}` is imported redundantly", ident),
                 BuiltinLintDiagnostics::RedundantImport(redundant_spans, ident),
             );
         }
     }
 
-    fn resolve_glob_import(&mut self, directive: &'b Import<'b>) {
-        let module = match directive.imported_module.get().unwrap() {
+    fn resolve_glob_import(&mut self, import: &'b Import<'b>) {
+        let module = match import.imported_module.get().unwrap() {
             ModuleOrUniformRoot::Module(module) => module,
             _ => {
-                self.r.session.span_err(directive.span, "cannot glob-import all possible crates");
+                self.r.session.span_err(import.span, "cannot glob-import all possible crates");
                 return;
             }
         };
 
         if module.is_trait() {
-            self.r.session.span_err(directive.span, "items in traits are not importable.");
+            self.r.session.span_err(import.span, "items in traits are not importable.");
             return;
-        } else if module.def_id() == directive.parent_scope.module.def_id() {
+        } else if module.def_id() == import.parent_scope.module.def_id() {
             return;
-        } else if let ImportKind::Glob { is_prelude: true, .. } = directive.kind {
+        } else if let ImportKind::Glob { is_prelude: true, .. } = import.kind {
             self.r.prelude = Some(module);
             return;
         }
 
         // Add to module's glob_importers
-        module.glob_importers.borrow_mut().push(directive);
+        module.glob_importers.borrow_mut().push(import);
 
         // Ensure that `resolutions` isn't borrowed during `try_define`,
         // since it might get updated via a glob cycle.
@@ -1365,19 +1353,19 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
             })
             .collect::<Vec<_>>();
         for (mut key, binding) in bindings {
-            let scope = match key.ident.span.reverse_glob_adjust(module.expansion, directive.span) {
+            let scope = match key.ident.span.reverse_glob_adjust(module.expansion, import.span) {
                 Some(Some(def)) => self.r.macro_def_scope(def),
-                Some(None) => directive.parent_scope.module,
+                Some(None) => import.parent_scope.module,
                 None => continue,
             };
             if self.r.is_accessible_from(binding.pseudo_vis(), scope) {
-                let imported_binding = self.r.import(binding, directive);
-                let _ = self.r.try_define(directive.parent_scope.module, key, imported_binding);
+                let imported_binding = self.r.import(binding, import);
+                let _ = self.r.try_define(import.parent_scope.module, key, imported_binding);
             }
         }
 
         // Record the destination of this import
-        self.r.record_partial_res(directive.id, PartialRes::new(module.res().unwrap()));
+        self.r.record_partial_res(import.id, PartialRes::new(module.res().unwrap()));
     }
 
     // Miscellaneous post-processing, including recording re-exports,
@@ -1401,12 +1389,12 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
                 }
             }
 
-            if let NameBindingKind::Import { binding: orig_binding, directive, .. } = binding.kind {
+            if let NameBindingKind::Import { binding: orig_binding, import, .. } = binding.kind {
                 if ns == TypeNS
                     && orig_binding.is_variant()
                     && !orig_binding.vis.is_at_least(binding.vis, &*this)
                 {
-                    let msg = match directive.kind {
+                    let msg = match import.kind {
                         ImportKind::Single { .. } => {
                             format!("variant `{}` is private and cannot be re-exported", ident)
                         }
@@ -1430,14 +1418,14 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
                     };
                     let mut err = this.session.struct_span_err(binding.span, &msg);
 
-                    let imported_module = match directive.imported_module.get() {
+                    let imported_module = match import.imported_module.get() {
                         Some(ModuleOrUniformRoot::Module(module)) => module,
                         _ => bug!("module should exist"),
                     };
                     let parent_module = imported_module.parent.expect("parent should exist");
                     let resolutions = this.resolutions(parent_module).borrow();
-                    let enum_path_segment_index = directive.module_path.len() - 1;
-                    let enum_ident = directive.module_path[enum_path_segment_index].ident;
+                    let enum_path_segment_index = import.module_path.len() - 1;
+                    let enum_ident = import.module_path[enum_path_segment_index].ident;
 
                     let key = this.new_key(enum_ident, TypeNS);
                     let enum_resolution = resolutions.get(&key).expect("resolution should exist");
@@ -1484,18 +1472,18 @@ fn import_path_to_string(names: &[Ident], import_kind: &ImportKind<'_>, span: Sp
     } else {
         let names = if global { &names[1..] } else { names };
         if names.is_empty() {
-            import_directive_subclass_to_string(import_kind)
+            import_kind_to_string(import_kind)
         } else {
             format!(
                 "{}::{}",
                 names_to_string(&names.iter().map(|ident| ident.name).collect::<Vec<_>>()),
-                import_directive_subclass_to_string(import_kind),
+                import_kind_to_string(import_kind),
             )
         }
     }
 }
 
-fn import_directive_subclass_to_string(import_kind: &ImportKind<'_>) -> String {
+fn import_kind_to_string(import_kind: &ImportKind<'_>) -> String {
     match import_kind {
         ImportKind::Single { source, .. } => source.to_string(),
         ImportKind::Glob { .. } => "*".to_string(),
diff --git a/src/librustc_resolve/late.rs b/src/librustc_resolve/late.rs
index 6b5e927214f..98bb98a3a8d 100644
--- a/src/librustc_resolve/late.rs
+++ b/src/librustc_resolve/late.rs
@@ -2189,10 +2189,10 @@ impl<'a, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
         trait_name: Ident,
     ) -> SmallVec<[NodeId; 1]> {
         let mut import_ids = smallvec![];
-        while let NameBindingKind::Import { directive, binding, .. } = kind {
-            self.r.maybe_unused_trait_imports.insert(directive.id);
-            self.r.add_to_glob_map(&directive, trait_name);
-            import_ids.push(directive.id);
+        while let NameBindingKind::Import { import, binding, .. } = kind {
+            self.r.maybe_unused_trait_imports.insert(import.id);
+            self.r.add_to_glob_map(&import, trait_name);
+            import_ids.push(import.id);
             kind = &binding.kind;
         }
         import_ids
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs
index 2ffcf340b9a..492ac6ed839 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -584,7 +584,7 @@ impl<'a> ToNameBinding<'a> for &'a NameBinding<'a> {
 enum NameBindingKind<'a> {
     Res(Res, /* is_macro_export */ bool),
     Module(Module<'a>),
-    Import { binding: &'a NameBinding<'a>, directive: &'a Import<'a>, used: Cell<bool> },
+    Import { binding: &'a NameBinding<'a>, import: &'a Import<'a>, used: Cell<bool> },
 }
 
 impl<'a> NameBindingKind<'a> {
@@ -713,7 +713,7 @@ impl<'a> NameBinding<'a> {
     fn is_extern_crate(&self) -> bool {
         match self.kind {
             NameBindingKind::Import {
-                directive: &Import { kind: ImportKind::ExternCrate { .. }, .. },
+                import: &Import { kind: ImportKind::ExternCrate { .. }, .. },
                 ..
             } => true,
             NameBindingKind::Module(&ModuleData {
@@ -733,7 +733,7 @@ impl<'a> NameBinding<'a> {
 
     fn is_glob_import(&self) -> bool {
         match self.kind {
-            NameBindingKind::Import { directive, .. } => directive.is_glob(),
+            NameBindingKind::Import { import, .. } => import.is_glob(),
             _ => false,
         }
     }
@@ -970,7 +970,7 @@ pub struct ResolverArenas<'a> {
     modules: arena::TypedArena<ModuleData<'a>>,
     local_modules: RefCell<Vec<Module<'a>>>,
     name_bindings: arena::TypedArena<NameBinding<'a>>,
-    import_directives: arena::TypedArena<Import<'a>>,
+    imports: arena::TypedArena<Import<'a>>,
     name_resolutions: arena::TypedArena<RefCell<NameResolution<'a>>>,
     legacy_bindings: arena::TypedArena<LegacyBinding<'a>>,
     ast_paths: arena::TypedArena<ast::Path>,
@@ -990,8 +990,8 @@ impl<'a> ResolverArenas<'a> {
     fn alloc_name_binding(&'a self, name_binding: NameBinding<'a>) -> &'a NameBinding<'a> {
         self.name_bindings.alloc(name_binding)
     }
-    fn alloc_import_directive(&'a self, import_directive: Import<'a>) -> &'a Import<'_> {
-        self.import_directives.alloc(import_directive)
+    fn alloc_import(&'a self, import: Import<'a>) -> &'a Import<'_> {
+        self.imports.alloc(import)
     }
     fn alloc_name_resolution(&'a self) -> &'a RefCell<NameResolution<'a>> {
         self.name_resolutions.alloc(Default::default())
@@ -1406,7 +1406,7 @@ impl<'a> Resolver<'a> {
                 misc2: AmbiguityErrorMisc::None,
             });
         }
-        if let NameBindingKind::Import { directive, binding, ref used } = used_binding.kind {
+        if let NameBindingKind::Import { import, binding, ref used } = used_binding.kind {
             // Avoid marking `extern crate` items that refer to a name from extern prelude,
             // but not introduce it, as used if they are accessed from lexical scope.
             if is_lexical_scope {
@@ -1419,17 +1419,17 @@ impl<'a> Resolver<'a> {
                 }
             }
             used.set(true);
-            directive.used.set(true);
-            self.used_imports.insert((directive.id, ns));
-            self.add_to_glob_map(&directive, ident);
+            import.used.set(true);
+            self.used_imports.insert((import.id, ns));
+            self.add_to_glob_map(&import, ident);
             self.record_use(ident, ns, binding, false);
         }
     }
 
     #[inline]
-    fn add_to_glob_map(&mut self, directive: &Import<'_>, ident: Ident) {
-        if directive.is_glob() {
-            self.glob_map.entry(directive.id).or_default().insert(ident.name);
+    fn add_to_glob_map(&mut self, import: &Import<'_>, ident: Ident) {
+        if import.is_glob() {
+            self.glob_map.entry(import.id).or_default().insert(ident.name);
         }
     }
 
@@ -2254,10 +2254,9 @@ impl<'a> Resolver<'a> {
         // `ExternCrate` (also used for `crate::...`) then no need to issue a
         // warning, this looks all good!
         if let Some(binding) = second_binding {
-            if let NameBindingKind::Import { directive: d, .. } = binding.kind {
-                // Careful: we still want to rewrite paths from
-                // renamed extern crates.
-                if let ImportKind::ExternCrate { source: None, .. } = d.kind {
+            if let NameBindingKind::Import { import, .. } = binding.kind {
+                // Careful: we still want to rewrite paths from renamed extern crates.
+                if let ImportKind::ExternCrate { source: None, .. } = import.kind {
                     return;
                 }
             }
@@ -2560,10 +2559,10 @@ impl<'a> Resolver<'a> {
 
         // See https://github.com/rust-lang/rust/issues/32354
         use NameBindingKind::Import;
-        let directive = match (&new_binding.kind, &old_binding.kind) {
+        let import = match (&new_binding.kind, &old_binding.kind) {
             // If there are two imports where one or both have attributes then prefer removing the
             // import without attributes.
-            (Import { directive: new, .. }, Import { directive: old, .. })
+            (Import { import: new, .. }, Import { import: old, .. })
                 if {
                     !new_binding.span.is_dummy()
                         && !old_binding.span.is_dummy()
@@ -2577,11 +2576,11 @@ impl<'a> Resolver<'a> {
                 }
             }
             // Otherwise prioritize the new binding.
-            (Import { directive, .. }, other) if !new_binding.span.is_dummy() => {
-                Some((directive, new_binding.span, other.is_import()))
+            (Import { import, .. }, other) if !new_binding.span.is_dummy() => {
+                Some((import, new_binding.span, other.is_import()))
             }
-            (other, Import { directive, .. }) if !old_binding.span.is_dummy() => {
-                Some((directive, old_binding.span, other.is_import()))
+            (other, Import { import, .. }) if !old_binding.span.is_dummy() => {
+                Some((import, old_binding.span, other.is_import()))
             }
             _ => None,
         };
@@ -2598,22 +2597,22 @@ impl<'a> Resolver<'a> {
             && !has_dummy_span
             && ((new_binding.is_extern_crate() || old_binding.is_extern_crate()) || from_item);
 
-        match directive {
-            Some((directive, span, true)) if should_remove_import && directive.is_nested() => {
-                self.add_suggestion_for_duplicate_nested_use(&mut err, directive, span)
+        match import {
+            Some((import, span, true)) if should_remove_import && import.is_nested() => {
+                self.add_suggestion_for_duplicate_nested_use(&mut err, import, span)
             }
-            Some((directive, _, true)) if should_remove_import && !directive.is_glob() => {
+            Some((import, _, true)) if should_remove_import && !import.is_glob() => {
                 // Simple case - remove the entire import. Due to the above match arm, this can
                 // only be a single use so just remove it entirely.
                 err.tool_only_span_suggestion(
-                    directive.use_span_with_attributes,
+                    import.use_span_with_attributes,
                     "remove unnecessary import",
                     String::new(),
                     Applicability::MaybeIncorrect,
                 );
             }
-            Some((directive, span, _)) => {
-                self.add_suggestion_for_rename_of_use(&mut err, name, directive, span)
+            Some((import, span, _)) => {
+                self.add_suggestion_for_rename_of_use(&mut err, name, import, span)
             }
             _ => {}
         }
@@ -2635,7 +2634,7 @@ impl<'a> Resolver<'a> {
         &self,
         err: &mut DiagnosticBuilder<'_>,
         name: Name,
-        directive: &Import<'_>,
+        import: &Import<'_>,
         binding_span: Span,
     ) {
         let suggested_name = if name.as_str().chars().next().unwrap().is_uppercase() {
@@ -2645,7 +2644,7 @@ impl<'a> Resolver<'a> {
         };
 
         let mut suggestion = None;
-        match directive.kind {
+        match import.kind {
             ImportKind::Single { type_ns_only: true, .. } => {
                 suggestion = Some(format!("self as {}", suggested_name))
             }
@@ -2707,27 +2706,27 @@ impl<'a> Resolver<'a> {
     /// If the nested use contains only one import then the suggestion will remove the entire
     /// line.
     ///
-    /// It is expected that the directive provided is a nested import - this isn't checked by the
+    /// It is expected that the provided import is nested - this isn't checked by the
     /// function. If this invariant is not upheld, this function's behaviour will be unexpected
     /// as characters expected by span manipulations won't be present.
     fn add_suggestion_for_duplicate_nested_use(
         &self,
         err: &mut DiagnosticBuilder<'_>,
-        directive: &Import<'_>,
+        import: &Import<'_>,
         binding_span: Span,
     ) {
-        assert!(directive.is_nested());
+        assert!(import.is_nested());
         let message = "remove unnecessary import";
 
         // Two examples will be used to illustrate the span manipulations we're doing:
         //
         // - Given `use issue_52891::{d, a, e};` where `a` is a duplicate then `binding_span` is
-        //   `a` and `directive.use_span` is `issue_52891::{d, a, e};`.
+        //   `a` and `import.use_span` is `issue_52891::{d, a, e};`.
         // - Given `use issue_52891::{d, e, a};` where `a` is a duplicate then `binding_span` is
-        //   `a` and `directive.use_span` is `issue_52891::{d, e, a};`.
+        //   `a` and `import.use_span` is `issue_52891::{d, e, a};`.
 
         let (found_closing_brace, span) =
-            find_span_of_binding_until_next_binding(self.session, binding_span, directive.use_span);
+            find_span_of_binding_until_next_binding(self.session, binding_span, import.use_span);
 
         // If there was a closing brace then identify the span to remove any trailing commas from
         // previous imports.
@@ -2743,7 +2742,7 @@ impl<'a> Resolver<'a> {
                 // Remove the entire line if we cannot extend the span back, this indicates a
                 // `issue_52891::{self}` case.
                 err.span_suggestion(
-                    directive.use_span_with_attributes,
+                    import.use_span_with_attributes,
                     message,
                     String::new(),
                     Applicability::MaybeIncorrect,
diff --git a/src/test/ui/rust-2018/macro-use-warned-against.rs b/src/test/ui/rust-2018/macro-use-warned-against.rs
index 6cd54aa68ae..65400163ddd 100644
--- a/src/test/ui/rust-2018/macro-use-warned-against.rs
+++ b/src/test/ui/rust-2018/macro-use-warned-against.rs
@@ -4,7 +4,7 @@
 
 #![warn(macro_use_extern_crate, unused)]
 
-#[macro_use] //~ WARN should be replaced at use sites with a `use` statement
+#[macro_use] //~ WARN should be replaced at use sites with a `use` item
 extern crate macro_use_warned_against;
 #[macro_use] //~ WARN unused `#[macro_use]`
 extern crate macro_use_warned_against2;
diff --git a/src/test/ui/rust-2018/macro-use-warned-against.stderr b/src/test/ui/rust-2018/macro-use-warned-against.stderr
index 611b9d5dac9..ef00b865815 100644
--- a/src/test/ui/rust-2018/macro-use-warned-against.stderr
+++ b/src/test/ui/rust-2018/macro-use-warned-against.stderr
@@ -1,4 +1,4 @@
-warning: deprecated `#[macro_use]` directive used to import macros should be replaced at use sites with a `use` statement to import the macro instead
+warning: deprecated `#[macro_use]` attribute used to import macros should be replaced at use sites with a `use` item to import the macro instead
   --> $DIR/macro-use-warned-against.rs:7:1
    |
 LL | #[macro_use]