提交 ff3a6449 编写于 作者: J Jeffrey Seyfried

Add struct `AmbiguityError`.

上级 888a9681
......@@ -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 @@ fn record_use(&mut self, name: Name, ns: Namespace, binding: &'a NameBinding<'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 @@ fn is_accessible_from(&self, vis: ty::Visibility, module: Module<'a>) -> bool {
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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册