From c77ad2d76576b97f6b2ea8c8b5ddb672c3383512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 7 Dec 2022 11:32:26 -0800 Subject: [PATCH] Remove mention of "assoc type" in label as it is already in the `note` message --- .../src/traits/error_reporting/suggestions.rs | 12 ++++------ src/test/ui/issues/issue-34334.stderr | 4 ++-- ...e-66923-show-error-for-correct-call.stderr | 4 ++-- .../iterators/invalid-iterator-chain.stderr | 24 +++++++++---------- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 87ab863fa7bc..bef2a067ae31 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -3011,7 +3011,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { primary_spans.push(span); span_labels.push(( span, - format!("associated type `{assoc}` is `{ty}` here"), + format!("`{assoc}` is `{ty}` here"), )); } break; @@ -3025,15 +3025,13 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { primary_spans.push(span); span_labels.push(( span, - format!("associated type `{assoc}` changed to `{ty}` here"), + format!("`{assoc}` changed to `{ty}` here"), )); } } (Some((span, (assoc, ty))), None) => { - span_labels.push(( - span, - format!("associated type `{assoc}` is `{ty}` here"), - )); + span_labels + .push((span, format!("`{assoc}` is `{ty}` here"))); } (None, Some(_)) | (None, None) => {} } @@ -3055,7 +3053,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> { multi_span, format!( "the method call chain might not have had the expected \ - associated types", + associated types", ), ); } diff --git a/src/test/ui/issues/issue-34334.stderr b/src/test/ui/issues/issue-34334.stderr index 89f5c45d7a97..ac3b3e95faf3 100644 --- a/src/test/ui/issues/issue-34334.stderr +++ b/src/test/ui/issues/issue-34334.stderr @@ -29,9 +29,9 @@ LL | let sr: Vec<(u32, _, _) = vec![]; | ------ this expression has type `Vec<(_, _, _)>` ... LL | let sr2: Vec<(u32, _, _)> = sr.iter().map(|(faction, th_sender, th_receiver)| {}).collect(); - | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ associated type `std::iter::Iterator::Item` changed to `()` here + | ^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::iter::Iterator::Item` changed to `()` here | | - | associated type `std::iter::Iterator::Item` is `&(_, _, _)` here + | `std::iter::Iterator::Item` is `&(_, _, _)` here note: required by a bound in `collect` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL | diff --git a/src/test/ui/issues/issue-66923-show-error-for-correct-call.stderr b/src/test/ui/issues/issue-66923-show-error-for-correct-call.stderr index 7fe786dcfb50..9a560c631fec 100644 --- a/src/test/ui/issues/issue-66923-show-error-for-correct-call.stderr +++ b/src/test/ui/issues/issue-66923-show-error-for-correct-call.stderr @@ -14,7 +14,7 @@ note: the method call chain might not have had the expected associated types LL | let x1: &[f64] = &v; | -- this expression has type `&Vec` LL | let x2: Vec = x1.into_iter().collect(); - | ^^^^^^^^^^^ associated type `std::iter::Iterator::Item` is `&f64` here + | ^^^^^^^^^^^ `std::iter::Iterator::Item` is `&f64` here note: required by a bound in `collect` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL | @@ -38,7 +38,7 @@ LL | let x1: &[f64] = &v; | -- this expression has type `&Vec` ... LL | let x3 = x1.into_iter().collect::>(); - | ^^^^^^^^^^^ associated type `std::iter::Iterator::Item` is `&f64` here + | ^^^^^^^^^^^ `std::iter::Iterator::Item` is `&f64` here note: required by a bound in `collect` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL | diff --git a/src/test/ui/iterators/invalid-iterator-chain.stderr b/src/test/ui/iterators/invalid-iterator-chain.stderr index 8bf7eb93a720..0505dd86af32 100644 --- a/src/test/ui/iterators/invalid-iterator-chain.stderr +++ b/src/test/ui/iterators/invalid-iterator-chain.stderr @@ -15,12 +15,12 @@ note: the method call chain might not have had the expected associated types LL | let scores = vec![(0, 0)] | ------------ this expression has type `Vec<({integer}, {integer})>` LL | .iter() - | ^^^^^^ associated type `std::iter::Iterator::Item` is `&({integer}, {integer})` here + | ^^^^^^ `std::iter::Iterator::Item` is `&({integer}, {integer})` here LL | .map(|(a, b)| { | __________^ LL | | a + b; LL | | }); - | |__________^ associated type `std::iter::Iterator::Item` changed to `()` here + | |__________^ `std::iter::Iterator::Item` changed to `()` here note: required by a bound in `std::iter::Iterator::sum` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL | @@ -50,19 +50,19 @@ note: the method call chain might not have had the expected associated types LL | vec![0, 1] | ---------- this expression has type `Vec<{integer}>` LL | .iter() - | ^^^^^^ associated type `std::iter::Iterator::Item` is `&{integer}` here + | ^^^^^^ `std::iter::Iterator::Item` is `&{integer}` here LL | .map(|x| x * 2) - | ^^^^^^^^^^^^^^ associated type `std::iter::Iterator::Item` changed to `{integer}` here + | ^^^^^^^^^^^^^^ `std::iter::Iterator::Item` changed to `{integer}` here LL | .map(|x| x as f64) - | ^^^^^^^^^^^^^^^^^ associated type `std::iter::Iterator::Item` changed to `f64` here + | ^^^^^^^^^^^^^^^^^ `std::iter::Iterator::Item` changed to `f64` here LL | .map(|x| x as i64) - | ^^^^^^^^^^^^^^^^^ associated type `std::iter::Iterator::Item` changed to `i64` here + | ^^^^^^^^^^^^^^^^^ `std::iter::Iterator::Item` changed to `i64` here LL | .filter(|x| *x > 0) | ------------------ LL | .map(|x| { x + 1 }) | ------------------ LL | .map(|x| { x; }) - | ^^^^^^^^^^^^^^^ associated type `std::iter::Iterator::Item` changed to `()` here + | ^^^^^^^^^^^^^^^ `std::iter::Iterator::Item` changed to `()` here note: required by a bound in `std::iter::Iterator::sum` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL | @@ -84,9 +84,9 @@ note: the method call chain might not have had the expected associated types --> $DIR/invalid-iterator-chain.rs:20:31 | LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::()); - | ---------- ^^^^^^ ^^^^^^^^^^^^^^^ associated type `std::iter::Iterator::Item` changed to `()` here + | ---------- ^^^^^^ ^^^^^^^^^^^^^^^ `std::iter::Iterator::Item` changed to `()` here | | | - | | associated type `std::iter::Iterator::Item` is `&{integer}` here + | | `std::iter::Iterator::Item` is `&{integer}` here | this expression has type `Vec<{integer}>` note: required by a bound in `std::iter::Iterator::sum` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL @@ -109,7 +109,7 @@ note: the method call chain might not have had the expected associated types --> $DIR/invalid-iterator-chain.rs:21:33 | LL | println!("{}", vec![(), ()].iter().sum::()); - | ------------ ^^^^^^ associated type `std::iter::Iterator::Item` is `&()` here + | ------------ ^^^^^^ `std::iter::Iterator::Item` is `&()` here | | | this expression has type `Vec<()>` note: required by a bound in `std::iter::Iterator::sum` @@ -134,7 +134,7 @@ note: the method call chain might not have had the expected associated types LL | let a = vec![0]; | ------- this expression has type `Vec<{integer}>` LL | let b = a.into_iter(); - | ^^^^^^^^^^^ associated type `std::iter::Iterator::Item` is `{integer}` here + | ^^^^^^^^^^^ `std::iter::Iterator::Item` is `{integer}` here LL | let c = b.map(|x| x + 1); | -------------- LL | let d = c.filter(|x| *x > 10 ); @@ -143,7 +143,7 @@ LL | let e = d.map(|x| { | _______________^ LL | | x + 1; LL | | }); - | |______^ associated type `std::iter::Iterator::Item` changed to `()` here + | |______^ `std::iter::Iterator::Item` changed to `()` here LL | let f = e.filter(|_| false); | ----------------- note: required by a bound in `collect`