about summary refs log tree commit diff
path: root/compiler/rustc_resolve/src/lib.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-12-22 11:06:51 +0000
committerbors <bors@rust-lang.org>2022-12-22 11:06:51 +0000
commit2d8651a92761421b0437ffb44ba5670bea5ee1df (patch)
treeeaeaa01be5cc193d6bdc3cbcf302484992bd879a /compiler/rustc_resolve/src/lib.rs
parentcce9e72c55994335f8d1dac892cca755b65c8f43 (diff)
parentd2130e42749ae6144edead4427eb66fa458d8a67 (diff)
downloadrust-2d8651a92761421b0437ffb44ba5670bea5ee1df.tar.gz
rust-2d8651a92761421b0437ffb44ba5670bea5ee1df.zip
Auto merge of #106034 - matthiaskrgr:rollup-2zpql33, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #104741 (Switch `#[track_caller]` back to a no-op unless feature gate is enabled)
 - #105769 (add function to tell the identical errors for ambiguity_errors)
 - #105843 (Suggest associated const on possible capitalization mistake)
 - #105966 (Re-enable `Fn` trait call notation error for non-tuple argument)
 - #106002 (codegen tests: adapt patterns to also work with v0 symbol mangling)
 - #106010 (Give opaque types a better coherence error)
 - #106016 (rustdoc: simplify link anchor to section expand JS)
 - #106024 (Fix ICE due to `todo!()` in `rustdoc` for `Term`s)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_resolve/src/lib.rs')
-rw-r--r--compiler/rustc_resolve/src/lib.rs26
1 files changed, 24 insertions, 2 deletions
diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs
index 4861ee746aa..2182b736937 100644
--- a/compiler/rustc_resolve/src/lib.rs
+++ b/compiler/rustc_resolve/src/lib.rs
@@ -1686,6 +1686,24 @@ impl<'a> Resolver<'a> {
             .or_insert_with(|| self.arenas.alloc_name_resolution())
     }
 
+    /// Test if AmbiguityError ambi is any identical to any one inside ambiguity_errors
+    fn matches_previous_ambiguity_error(&mut self, ambi: &AmbiguityError<'_>) -> bool {
+        for ambiguity_error in &self.ambiguity_errors {
+            // if the span location and ident as well as its span are the same
+            if ambiguity_error.kind == ambi.kind
+                && ambiguity_error.ident == ambi.ident
+                && ambiguity_error.ident.span == ambi.ident.span
+                && ambiguity_error.b1.span == ambi.b1.span
+                && ambiguity_error.b2.span == ambi.b2.span
+                && ambiguity_error.misc1 == ambi.misc1
+                && ambiguity_error.misc2 == ambi.misc2
+            {
+                return true;
+            }
+        }
+        false
+    }
+
     fn record_use(
         &mut self,
         ident: Ident,
@@ -1693,14 +1711,18 @@ impl<'a> Resolver<'a> {
         is_lexical_scope: bool,
     ) {
         if let Some((b2, kind)) = used_binding.ambiguity {
-            self.ambiguity_errors.push(AmbiguityError {
+            let ambiguity_error = AmbiguityError {
                 kind,
                 ident,
                 b1: used_binding,
                 b2,
                 misc1: AmbiguityErrorMisc::None,
                 misc2: AmbiguityErrorMisc::None,
-            });
+            };
+            if !self.matches_previous_ambiguity_error(&ambiguity_error) {
+                // avoid dumplicated span information to be emitt out
+                self.ambiguity_errors.push(ambiguity_error);
+            }
         }
         if let NameBindingKind::Import { import, binding, ref used } = used_binding.kind {
             // Avoid marking `extern crate` items that refer to a name from extern prelude,