about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJeffrey Seyfried <jeffrey.seyfried@gmail.com>2016-09-06 03:47:11 +0000
committerJeffrey Seyfried <jeffrey.seyfried@gmail.com>2016-09-06 03:52:36 +0000
commitff3a6449512e9e6fd1ea455c64cd02a7fa4cc7e2 (patch)
tree777048266adfafdeb3c125e22e6a57d5f7af712d /src
parent888a968139986847623bc40b5a7dc308cf44f988 (diff)
downloadrust-ff3a6449512e9e6fd1ea455c64cd02a7fa4cc7e2.tar.gz
rust-ff3a6449512e9e6fd1ea455c64cd02a7fa4cc7e2.zip
Add struct `AmbiguityError`.
Diffstat (limited to 'src')
-rw-r--r--src/librustc_resolve/lib.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs
index f3044e1847d..c5b505fba38 100644
--- a/src/librustc_resolve/lib.rs
+++ b/src/librustc_resolve/lib.rs
@@ -879,9 +879,15 @@ enum NameBindingKind<'a> {
     }
 }
 
-#[derive(Clone, Debug)]
 struct PrivacyError<'a>(Span, Name, &'a NameBinding<'a>);
 
+struct AmbiguityError<'a> {
+    span: Span,
+    name: Name,
+    b1: &'a NameBinding<'a>,
+    b2: &'a NameBinding<'a>,
+}
+
 impl<'a> NameBinding<'a> {
     fn module(&self) -> Result<Module<'a>, bool /* true if an error has already been reported */> {
         match self.kind {
@@ -1057,7 +1063,7 @@ pub struct Resolver<'a> {
     pub maybe_unused_trait_imports: NodeSet,
 
     privacy_errors: Vec<PrivacyError<'a>>,
-    ambiguity_errors: Vec<(Span, Name, &'a NameBinding<'a>, &'a NameBinding<'a>)>,
+    ambiguity_errors: Vec<AmbiguityError<'a>>,
 
     arenas: &'a ResolverArenas<'a>,
     dummy_binding: &'a NameBinding<'a>,
@@ -1278,7 +1284,8 @@ impl<'a> Resolver<'a> {
             }
             NameBindingKind::Import { .. } => false,
             NameBindingKind::Ambiguity { b1, b2 } => {
-                self.ambiguity_errors.push((span, name, b1, b2));
+                let ambiguity_error = AmbiguityError { span: span, name: name, b1: b1, b2: b2 };
+                self.ambiguity_errors.push(ambiguity_error);
                 true
             }
             _ => false
@@ -3302,7 +3309,7 @@ impl<'a> Resolver<'a> {
     fn report_errors(&self) {
         let mut reported_spans = FnvHashSet();
 
-        for &(span, name, b1, b2) in &self.ambiguity_errors {
+        for &AmbiguityError { span, name, b1, b2 } in &self.ambiguity_errors {
             if !reported_spans.insert(span) { continue }
             let msg1 = format!("`{}` could resolve to the name imported here", name);
             let msg2 = format!("`{}` could also resolve to the name imported here", name);