]> git.lizzy.rs Git - rust.git/commitdiff
Refactor away DefModifiers::PRELUDE
authorJeffrey Seyfried <jeffrey.seyfried@gmail.com>
Wed, 9 Mar 2016 01:55:21 +0000 (01:55 +0000)
committerJeffrey Seyfried <jeffrey.seyfried@gmail.com>
Fri, 25 Mar 2016 22:22:15 +0000 (22:22 +0000)
src/librustc_resolve/lib.rs
src/librustc_resolve/resolve_imports.rs

index 65d40edd9584c3d0d6f4b7715991f63d294c2e0a..763fa32795daae007539500fedc657abec24d3d7 100644 (file)
@@ -932,8 +932,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         // Variants are considered `PUBLIC`, but some of them live in private enums.
         // We need to track them to prohibit reexports like `pub use PrivEnum::Variant`.
         const PRIVATE_VARIANT = 1 << 2,
-        const PRELUDE = 1 << 3,
-        const GLOB_IMPORTED = 1 << 4,
+        const GLOB_IMPORTED = 1 << 3,
     }
 }
 
index 91bbb154bbeb716553622fb883de73c658d56fa2..a29954ade184a494cb6a494cffea14dd87638c20 100644 (file)
@@ -125,18 +125,17 @@ pub struct NameResolution<'a> {
 
 impl<'a> NameResolution<'a> {
     fn try_define(&mut self, binding: &'a NameBinding<'a>) -> Result<(), &'a NameBinding<'a>> {
-        match self.binding {
-            Some(old_binding) if !old_binding.defined_with(DefModifiers::PRELUDE) => {
-                if binding.defined_with(DefModifiers::GLOB_IMPORTED) {
-                    self.duplicate_globs.push(binding);
-                } else if old_binding.defined_with(DefModifiers::GLOB_IMPORTED) {
-                    self.duplicate_globs.push(old_binding);
-                    self.binding = Some(binding);
-                } else {
-                    return Err(old_binding);
-                }
+        if let Some(old_binding) = self.binding {
+            if binding.defined_with(DefModifiers::GLOB_IMPORTED) {
+                self.duplicate_globs.push(binding);
+            } else if old_binding.defined_with(DefModifiers::GLOB_IMPORTED) {
+                self.duplicate_globs.push(old_binding);
+                self.binding = Some(binding);
+            } else {
+                return Err(old_binding);
             }
-            _ => self.binding = Some(binding),
+        } else {
+            self.binding = Some(binding);
         }
 
         Ok(())
@@ -160,7 +159,6 @@ fn result(&self, allow_private_imports: bool) -> ResolveResult<&'a NameBinding<'
     fn try_result(&self, allow_private_imports: bool)
                   -> Option<ResolveResult<&'a NameBinding<'a>>> {
         match self.result(allow_private_imports) {
-            Success(binding) if binding.defined_with(DefModifiers::PRELUDE) => None,
             Failed(_) => None,
             result @ _ => Some(result),
         }
@@ -192,8 +190,6 @@ fn report_conflicts<F: FnMut(&NameBinding, &NameBinding)>(&self, mut report: F)
         };
 
         for duplicate_glob in self.duplicate_globs.iter() {
-            if duplicate_glob.defined_with(DefModifiers::PRELUDE) { continue }
-
             // FIXME #31337: We currently allow items to shadow glob-imported re-exports.
             if !binding.is_import() {
                 if let NameBindingKind::Import { binding, .. } = duplicate_glob.kind {
@@ -360,7 +356,7 @@ fn import_resolving_error(&self, e: ImportResolvingError<'b>) {
         // resolution for it so that later resolve stages won't complain.
         if let SingleImport { target, .. } = e.import_directive.subclass {
             let dummy_binding = self.resolver.arenas.alloc_name_binding(NameBinding {
-                modifiers: DefModifiers::PRELUDE,
+                modifiers: DefModifiers::GLOB_IMPORTED,
                 kind: NameBindingKind::Def(Def::Err),
                 span: None,
             });