about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJeffrey Seyfried <jeffrey.seyfried@gmail.com>2016-02-09 06:26:27 +0000
committerJeffrey Seyfried <jeffrey.seyfried@gmail.com>2016-02-09 17:30:45 +0000
commit3df40c09ec5efb74e16c3da84fef6ce142dae73a (patch)
treeaab55bbfdb783b55f6d6e7d50e7d48cf49a53c6e /src
parent3c62d90202ce3750d3278746c89f1a1d2908b6f9 (diff)
downloadrust-3df40c09ec5efb74e16c3da84fef6ce142dae73a.tar.gz
rust-3df40c09ec5efb74e16c3da84fef6ce142dae73a.zip
Allow prelude imports to shadow eachother (needed for the [pretty] tests)
Derive the Default impl for NameResolution
Diffstat (limited to 'src')
-rw-r--r--src/librustc_resolve/resolve_imports.rs12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs
index 0eab53260a5..6667e489870 100644
--- a/src/librustc_resolve/resolve_imports.rs
+++ b/src/librustc_resolve/resolve_imports.rs
@@ -99,7 +99,7 @@ impl ImportDirective {
     }
 }
 
-#[derive(Clone, Copy)]
+#[derive(Clone, Default)]
 /// Records information about the resolution of a name in a module.
 pub struct NameResolution<'a> {
     /// The number of unresolved single imports that could define the name.
@@ -108,12 +108,6 @@ pub struct NameResolution<'a> {
     pub binding: Option<&'a NameBinding<'a>>,
 }
 
-impl<'a> Default for NameResolution<'a> {
-    fn default() -> Self {
-        NameResolution { outstanding_references: 0, binding: None }
-    }
-}
-
 impl<'a> NameResolution<'a> {
     pub fn result(&self, outstanding_globs: usize) -> ResolveResult<&'a NameBinding<'a>> {
         // If no unresolved imports (single or glob) can define the name, self.binding is final.
@@ -137,8 +131,8 @@ impl<'a> NameResolution<'a> {
     pub fn try_define(&mut self, binding: &'a NameBinding<'a>) -> Result<(), &'a NameBinding<'a>> {
         let is_prelude = |binding: &NameBinding| binding.defined_with(DefModifiers::PRELUDE);
         let old_binding = match self.binding {
-            Some(old_binding) if is_prelude(binding) && !is_prelude(old_binding) => return Ok(()),
-            Some(old_binding) if is_prelude(old_binding) == is_prelude(binding) => old_binding,
+            Some(_) if is_prelude(binding) => return Ok(()),
+            Some(old_binding) if !is_prelude(old_binding) => old_binding,
             _ => { self.binding = Some(binding); return Ok(()); }
         };