]> git.lizzy.rs Git - rust.git/commitdiff
avoid reporting twice
authorF001 <changchun.fan@qq.com>
Sun, 20 May 2018 02:08:54 +0000 (10:08 +0800)
committerF001 <changchun.fan@qq.com>
Sun, 20 May 2018 02:16:33 +0000 (10:16 +0800)
src/librustc_typeck/astconv.rs
src/test/ui/lint/issue-50589-multiple-associated-types.stderr

index 677244b612a820bfbc11021dbc4252d1c4fd5cd7..35d5619969dbb883df0e256451dabf0b89de1778 100644 (file)
@@ -568,20 +568,22 @@ fn ast_type_binding_to_poly_projection_predicate(
         }
         tcx.check_stability(assoc_ty.def_id, Some(ref_id), binding.span);
 
-        dup_bindings.entry(assoc_ty.def_id)
-            .and_modify(|prev_span| {
-                let mut err = self.tcx().struct_span_lint_node(
-                    ::rustc::lint::builtin::DUPLICATE_ASSOCIATED_TYPE_BINDINGS,
-                    ref_id,
-                    binding.span,
-                    &format!("associated type binding `{}` specified more than once",
-                            binding.item_name)
-                );
-                err.span_label(binding.span, "used more than once");
-                err.span_label(*prev_span, format!("first use of `{}`", binding.item_name));
-                err.emit();
-            })
-            .or_insert(binding.span);
+        if speculative {
+            dup_bindings.entry(assoc_ty.def_id)
+                .and_modify(|prev_span| {
+                    let mut err = self.tcx().struct_span_lint_node(
+                        ::rustc::lint::builtin::DUPLICATE_ASSOCIATED_TYPE_BINDINGS,
+                        ref_id,
+                        binding.span,
+                        &format!("associated type binding `{}` specified more than once",
+                                binding.item_name)
+                    );
+                    err.span_label(binding.span, "used more than once");
+                    err.span_label(*prev_span, format!("first use of `{}`", binding.item_name));
+                    err.emit();
+                })
+                .or_insert(binding.span);
+        }
 
         Ok(candidate.map_bound(|trait_ref| {
             ty::ProjectionPredicate {
index 7f0a1ee1f3307b2a4f3f226d88f715a50af84def..e115e523d8735e7e585155a4ed60b4c71c77ca00 100644 (file)
@@ -10,14 +10,3 @@ LL | fn test() ->  Box<Iterator<Item = (), Item = Unit>> {
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #50589 <https://github.com/rust-lang/rust/issues/50589>
 
-warning: associated type binding `Item` specified more than once
-  --> $DIR/issue-50589-multiple-associated-types.rs:17:39
-   |
-LL | fn test() ->  Box<Iterator<Item = (), Item = Unit>> {
-   |                            ---------  ^^^^^^^^^^^ used more than once
-   |                            |
-   |                            first use of `Item`
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-   = note: for more information, see issue #50589 <https://github.com/rust-lang/rust/issues/50589>
-