]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_resolve/build_reduced_graph.rs
Rollup merge of #33045 - jseyfried:no_def_modifiers, r=eddyb
[rust.git] / src / librustc_resolve / build_reduced_graph.rs
index 15ad049cbe3d454dfc32ffb114320c3d4d8395d4..2547c756b9d6a1c21a430982a72aae25345dd584 100644 (file)
@@ -13,7 +13,6 @@
 //! Here we build the "reduced graph": the graph of the module tree without
 //! any imports resolved.
 
-use DefModifiers;
 use resolve_imports::ImportDirectiveSubclass::{self, GlobImport};
 use Module;
 use Namespace::{self, TypeNS, ValueNS};
@@ -53,10 +52,9 @@ fn to_name_binding(self) -> NameBinding<'a> {
     }
 }
 
-impl<'a> ToNameBinding<'a> for (Def, Span, DefModifiers, ty::Visibility) {
+impl<'a> ToNameBinding<'a> for (Def, Span, ty::Visibility) {
     fn to_name_binding(self) -> NameBinding<'a> {
-        let kind = NameBindingKind::Def(self.0);
-        NameBinding { modifiers: self.2, kind: kind, span: Some(self.1), vis: self.3 }
+        NameBinding { kind: NameBindingKind::Def(self.0), span: Some(self.1), vis: self.2 }
     }
 }
 
@@ -136,7 +134,6 @@ fn build_reduced_graph_for_item(&mut self, item: &Item, parent_ref: &mut Module<
         let parent = *parent_ref;
         let name = item.name;
         let sp = item.span;
-        let modifiers = DefModifiers::IMPORTABLE;
         self.current_module = parent;
         let vis = self.resolve_visibility(&item.vis);
 
@@ -284,21 +281,21 @@ fn build_reduced_graph_for_item(&mut self, item: &Item, parent_ref: &mut Module<
             ItemStatic(_, m, _) => {
                 let mutbl = m == hir::MutMutable;
                 let def = Def::Static(self.ast_map.local_def_id(item.id), mutbl);
-                self.define(parent, name, ValueNS, (def, sp, modifiers, vis));
+                self.define(parent, name, ValueNS, (def, sp, vis));
             }
             ItemConst(_, _) => {
                 let def = Def::Const(self.ast_map.local_def_id(item.id));
-                self.define(parent, name, ValueNS, (def, sp, modifiers, vis));
+                self.define(parent, name, ValueNS, (def, sp, vis));
             }
             ItemFn(_, _, _, _, _, _) => {
                 let def = Def::Fn(self.ast_map.local_def_id(item.id));
-                self.define(parent, name, ValueNS, (def, sp, modifiers, vis));
+                self.define(parent, name, ValueNS, (def, sp, vis));
             }
 
             // These items live in the type namespace.
             ItemTy(..) => {
                 let def = Def::TyAlias(self.ast_map.local_def_id(item.id));
-                self.define(parent, name, TypeNS, (def, sp, modifiers, vis));
+                self.define(parent, name, TypeNS, (def, sp, vis));
             }
 
             ItemEnum(ref enum_definition, _) => {
@@ -317,13 +314,13 @@ fn build_reduced_graph_for_item(&mut self, item: &Item, parent_ref: &mut Module<
             ItemStruct(ref struct_def, _) => {
                 // Define a name in the type namespace.
                 let def = Def::Struct(self.ast_map.local_def_id(item.id));
-                self.define(parent, name, TypeNS, (def, sp, modifiers, vis));
+                self.define(parent, name, TypeNS, (def, sp, vis));
 
                 // If this is a newtype or unit-like struct, define a name
                 // in the value namespace as well
                 if !struct_def.is_struct() {
                     let def = Def::Struct(self.ast_map.local_def_id(struct_def.id()));
-                    self.define(parent, name, ValueNS, (def, sp, modifiers, vis));
+                    self.define(parent, name, ValueNS, (def, sp, vis));
                 }
 
                 // Record the def ID and fields of this struct.
@@ -355,8 +352,7 @@ fn build_reduced_graph_for_item(&mut self, item: &Item, parent_ref: &mut Module<
                         hir::TypeTraitItem(..) => (Def::AssociatedTy(def_id, item_def_id), TypeNS),
                     };
 
-                    let modifiers = DefModifiers::empty(); // NB: not DefModifiers::IMPORTABLE
-                    self.define(module_parent, item.name, ns, (def, item.span, modifiers, vis));
+                    self.define(module_parent, item.name, ns, (def, item.span, vis));
 
                     self.trait_item_map.insert((item.name, def_id), item_def_id);
                 }
@@ -379,11 +375,9 @@ fn build_reduced_graph_for_variant(&mut self,
 
         // Variants are always treated as importable to allow them to be glob used.
         // All variants are defined in both type and value namespaces as future-proofing.
-        let modifiers = DefModifiers::IMPORTABLE;
         let def = Def::Variant(item_id, self.ast_map.local_def_id(variant.node.data.id()));
-
-        self.define(parent, name, ValueNS, (def, variant.span, modifiers, parent.vis));
-        self.define(parent, name, TypeNS, (def, variant.span, modifiers, parent.vis));
+        self.define(parent, name, ValueNS, (def, variant.span, parent.vis));
+        self.define(parent, name, TypeNS, (def, variant.span, parent.vis));
     }
 
     /// Constructs the reduced graph for one foreign item.
@@ -391,7 +385,6 @@ fn build_reduced_graph_for_foreign_item(&mut self,
                                             foreign_item: &ForeignItem,
                                             parent: Module<'b>) {
         let name = foreign_item.name;
-        let modifiers = DefModifiers::IMPORTABLE;
 
         let def = match foreign_item.node {
             ForeignItemFn(..) => {
@@ -403,7 +396,7 @@ fn build_reduced_graph_for_foreign_item(&mut self,
         };
         self.current_module = parent;
         let vis = self.resolve_visibility(&foreign_item.vis);
-        self.define(parent, name, ValueNS, (def, foreign_item.span, modifiers, vis));
+        self.define(parent, name, ValueNS, (def, foreign_item.span, vis));
     }
 
     fn build_reduced_graph_for_block(&mut self, block: &Block, parent: &mut Module<'b>) {
@@ -438,10 +431,6 @@ fn build_reduced_graph_for_external_crate_def(&mut self, parent: Module<'b>, xcd
 
         let name = xcdef.name;
         let vis = if parent.is_trait() { ty::Visibility::Public } else { xcdef.vis };
-        let modifiers = match parent.is_normal() {
-            true => DefModifiers::IMPORTABLE,
-            false => DefModifiers::empty(),
-        };
 
         match def {
             Def::Mod(_) | Def::ForeignMod(_) | Def::Enum(..) => {
@@ -455,9 +444,8 @@ fn build_reduced_graph_for_external_crate_def(&mut self, parent: Module<'b>, xcd
                 debug!("(building reduced graph for external crate) building variant {}", name);
                 // Variants are always treated as importable to allow them to be glob used.
                 // All variants are defined in both type and value namespaces as future-proofing.
-                let modifiers = DefModifiers::IMPORTABLE;
-                self.try_define(parent, name, TypeNS, (def, DUMMY_SP, modifiers, vis));
-                self.try_define(parent, name, ValueNS, (def, DUMMY_SP, modifiers, vis));
+                self.try_define(parent, name, TypeNS, (def, DUMMY_SP, vis));
+                self.try_define(parent, name, ValueNS, (def, DUMMY_SP, vis));
                 if self.session.cstore.variant_kind(variant_id) == Some(VariantKind::Struct) {
                     // Not adding fields for variants as they are not accessed with a self receiver
                     self.structs.insert(variant_id, Vec::new());
@@ -470,7 +458,7 @@ fn build_reduced_graph_for_external_crate_def(&mut self, parent: Module<'b>, xcd
             Def::Method(..) => {
                 debug!("(building reduced graph for external crate) building value (fn/static) {}",
                        name);
-                self.try_define(parent, name, ValueNS, (def, DUMMY_SP, modifiers, vis));
+                self.try_define(parent, name, ValueNS, (def, DUMMY_SP, vis));
             }
             Def::Trait(def_id) => {
                 debug!("(building reduced graph for external crate) building type {}", name);
@@ -496,16 +484,16 @@ fn build_reduced_graph_for_external_crate_def(&mut self, parent: Module<'b>, xcd
             }
             Def::TyAlias(..) | Def::AssociatedTy(..) => {
                 debug!("(building reduced graph for external crate) building type {}", name);
-                self.try_define(parent, name, TypeNS, (def, DUMMY_SP, modifiers, vis));
+                self.try_define(parent, name, TypeNS, (def, DUMMY_SP, vis));
             }
             Def::Struct(def_id)
                 if self.session.cstore.tuple_struct_definition_if_ctor(def_id).is_none() => {
                 debug!("(building reduced graph for external crate) building type and value for {}",
                        name);
-                self.try_define(parent, name, TypeNS, (def, DUMMY_SP, modifiers, vis));
+                self.try_define(parent, name, TypeNS, (def, DUMMY_SP, vis));
                 if let Some(ctor_def_id) = self.session.cstore.struct_ctor_def_id(def_id) {
                     let def = Def::Struct(ctor_def_id);
-                    self.try_define(parent, name, ValueNS, (def, DUMMY_SP, modifiers, vis));
+                    self.try_define(parent, name, ValueNS, (def, DUMMY_SP, vis));
                 }
 
                 // Record the def ID and fields of this struct.