diff options
| author | F001 <changchun.fan@qq.com> | 2018-05-20 10:08:54 +0800 |
|---|---|---|
| committer | F001 <changchun.fan@qq.com> | 2018-05-20 10:16:33 +0800 |
| commit | f837c34a865c46faef122e2c65b5f78c3fb954f8 (patch) | |
| tree | d7d671e9a1bdae135316af73408a5cd0f8e97f68 | |
| parent | c3322556f50fbdcdbd235e5d15406f1dea77048c (diff) | |
| download | rust-f837c34a865c46faef122e2c65b5f78c3fb954f8.tar.gz rust-f837c34a865c46faef122e2c65b5f78c3fb954f8.zip | |
avoid reporting twice
| -rw-r--r-- | src/librustc_typeck/astconv.rs | 30 | ||||
| -rw-r--r-- | src/test/ui/lint/issue-50589-multiple-associated-types.stderr | 11 |
2 files changed, 16 insertions, 25 deletions
diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 677244b612a..35d5619969d 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -568,20 +568,22 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { } 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 { diff --git a/src/test/ui/lint/issue-50589-multiple-associated-types.stderr b/src/test/ui/lint/issue-50589-multiple-associated-types.stderr index 7f0a1ee1f33..e115e523d87 100644 --- a/src/test/ui/lint/issue-50589-multiple-associated-types.stderr +++ b/src/test/ui/lint/issue-50589-multiple-associated-types.stderr @@ -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> - |
