Skip to content

Commit ff3a644

Browse files
committed
Add struct AmbiguityError.
1 parent 888a968 commit ff3a644

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/librustc_resolve/lib.rs

+11-4
Original file line numberDiff line numberDiff line change
@@ -879,9 +879,15 @@ enum NameBindingKind<'a> {
879879
}
880880
}
881881

882-
#[derive(Clone, Debug)]
883882
struct PrivacyError<'a>(Span, Name, &'a NameBinding<'a>);
884883

884+
struct AmbiguityError<'a> {
885+
span: Span,
886+
name: Name,
887+
b1: &'a NameBinding<'a>,
888+
b2: &'a NameBinding<'a>,
889+
}
890+
885891
impl<'a> NameBinding<'a> {
886892
fn module(&self) -> Result<Module<'a>, bool /* true if an error has already been reported */> {
887893
match self.kind {
@@ -1057,7 +1063,7 @@ pub struct Resolver<'a> {
10571063
pub maybe_unused_trait_imports: NodeSet,
10581064

10591065
privacy_errors: Vec<PrivacyError<'a>>,
1060-
ambiguity_errors: Vec<(Span, Name, &'a NameBinding<'a>, &'a NameBinding<'a>)>,
1066+
ambiguity_errors: Vec<AmbiguityError<'a>>,
10611067

10621068
arenas: &'a ResolverArenas<'a>,
10631069
dummy_binding: &'a NameBinding<'a>,
@@ -1278,7 +1284,8 @@ impl<'a> Resolver<'a> {
12781284
}
12791285
NameBindingKind::Import { .. } => false,
12801286
NameBindingKind::Ambiguity { b1, b2 } => {
1281-
self.ambiguity_errors.push((span, name, b1, b2));
1287+
let ambiguity_error = AmbiguityError { span: span, name: name, b1: b1, b2: b2 };
1288+
self.ambiguity_errors.push(ambiguity_error);
12821289
true
12831290
}
12841291
_ => false
@@ -3302,7 +3309,7 @@ impl<'a> Resolver<'a> {
33023309
fn report_errors(&self) {
33033310
let mut reported_spans = FnvHashSet();
33043311

3305-
for &(span, name, b1, b2) in &self.ambiguity_errors {
3312+
for &AmbiguityError { span, name, b1, b2 } in &self.ambiguity_errors {
33063313
if !reported_spans.insert(span) { continue }
33073314
let msg1 = format!("`{}` could resolve to the name imported here", name);
33083315
let msg2 = format!("`{}` could also resolve to the name imported here", name);

0 commit comments

Comments
 (0)