]> git.lizzy.rs Git - rust.git/commitdiff
Refactor away resolve_imports::Shadowable and rename shadowable -> is_prelude
authorJeffrey Seyfried <jeffrey.seyfried@gmail.com>
Tue, 1 Mar 2016 01:43:10 +0000 (01:43 +0000)
committerJeffrey Seyfried <jeffrey.seyfried@gmail.com>
Fri, 25 Mar 2016 22:18:30 +0000 (22:18 +0000)
src/librustc_resolve/build_reduced_graph.rs
src/librustc_resolve/resolve_imports.rs

index 08b5e51729013dab28172b63fd54c8d8303c4087..c30e6b8e2cfd67ceb9c40a703517e0c12c31237a 100644 (file)
@@ -22,7 +22,6 @@
 use module_to_string;
 use ParentLink::{ModuleParentLink, BlockParentLink};
 use Resolver;
-use resolve_imports::Shadowable;
 use {resolve_error, resolve_struct_error, ResolutionError};
 
 use rustc::middle::cstore::{CrateStore, ChildItem, DlDef, DlField, DlImpl};
@@ -161,14 +160,9 @@ fn build_reduced_graph_for_item(&mut self, item: &Item, parent: Module<'b>) -> M
                 };
 
                 // Build up the import directives.
-                let shadowable = item.attrs.iter().any(|attr| {
+                let is_prelude = item.attrs.iter().any(|attr| {
                     attr.name() == special_idents::prelude_import.name.as_str()
                 });
-                let shadowable = if shadowable {
-                    Shadowable::Always
-                } else {
-                    Shadowable::Never
-                };
 
                 match view_path.node {
                     ViewPathSimple(binding, ref full_path) => {
@@ -186,7 +180,7 @@ fn build_reduced_graph_for_item(&mut self, item: &Item, parent: Module<'b>) -> M
                                                     view_path.span,
                                                     item.id,
                                                     is_public,
-                                                    shadowable);
+                                                    is_prelude);
                     }
                     ViewPathList(_, ref source_items) => {
                         // Make sure there's at most one `mod` import in the list.
@@ -237,7 +231,7 @@ fn build_reduced_graph_for_item(&mut self, item: &Item, parent: Module<'b>) -> M
                                                         source_item.span,
                                                         source_item.node.id(),
                                                         is_public,
-                                                        shadowable);
+                                                        is_prelude);
                         }
                     }
                     ViewPathGlob(_) => {
@@ -247,7 +241,7 @@ fn build_reduced_graph_for_item(&mut self, item: &Item, parent: Module<'b>) -> M
                                                     view_path.span,
                                                     item.id,
                                                     is_public,
-                                                    shadowable);
+                                                    is_prelude);
                     }
                 }
                 parent
@@ -631,7 +625,7 @@ fn build_import_directive(&mut self,
                               span: Span,
                               id: NodeId,
                               is_public: bool,
-                              shadowable: Shadowable) {
+                              is_prelude: bool) {
         // Bump the reference count on the name. Or, if this is a glob, set
         // the appropriate flag.
 
@@ -648,7 +642,7 @@ fn build_import_directive(&mut self,
         }
 
         let directive =
-            ImportDirective::new(module_path, subclass, span, id, is_public, shadowable);
+            ImportDirective::new(module_path, subclass, span, id, is_public, is_prelude);
         module_.add_import_directive(directive);
         self.unresolved_imports += 1;
     }
index 61e0add86020e9b4305505cc7f91f81270140a1d..eaa0753b8ce15844933761a72769da48f0302bd5 100644 (file)
@@ -57,13 +57,6 @@ pub fn single(target: Name, source: Name) -> Self {
     }
 }
 
-/// Whether an import can be shadowed by another import.
-#[derive(Debug,PartialEq,Clone,Copy)]
-pub enum Shadowable {
-    Always,
-    Never,
-}
-
 /// One import directive.
 #[derive(Debug,Clone)]
 pub struct ImportDirective {
@@ -72,7 +65,7 @@ pub struct ImportDirective {
     pub span: Span,
     pub id: NodeId,
     pub is_public: bool, // see note in ImportResolutionPerNamespace about how to use this
-    pub shadowable: Shadowable,
+    pub is_prelude: bool,
 }
 
 impl ImportDirective {
@@ -81,7 +74,7 @@ pub fn new(module_path: Vec<Name>,
                span: Span,
                id: NodeId,
                is_public: bool,
-               shadowable: Shadowable)
+               is_prelude: bool)
                -> ImportDirective {
         ImportDirective {
             module_path: module_path,
@@ -89,7 +82,7 @@ pub fn new(module_path: Vec<Name>,
             span: span,
             id: id,
             is_public: is_public,
-            shadowable: shadowable,
+            is_prelude: is_prelude,
         }
     }
 
@@ -105,7 +98,7 @@ fn import<'a>(&self,
         if let GlobImport = self.subclass {
             modifiers = modifiers | DefModifiers::GLOB_IMPORTED;
         }
-        if self.shadowable == Shadowable::Always {
+        if self.is_prelude {
             modifiers = modifiers | DefModifiers::PRELUDE;
         }