1
Fork 0

Remove mention of "assoc type" in label as it is already in the note message

This commit is contained in:
Esteban Küber 2022-12-07 11:32:26 -08:00
parent 71db025cfa
commit c77ad2d765
4 changed files with 21 additions and 23 deletions

View file

@ -3011,7 +3011,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
primary_spans.push(span); primary_spans.push(span);
span_labels.push(( span_labels.push((
span, span,
format!("associated type `{assoc}` is `{ty}` here"), format!("`{assoc}` is `{ty}` here"),
)); ));
} }
break; break;
@ -3025,15 +3025,13 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
primary_spans.push(span); primary_spans.push(span);
span_labels.push(( span_labels.push((
span, span,
format!("associated type `{assoc}` changed to `{ty}` here"), format!("`{assoc}` changed to `{ty}` here"),
)); ));
} }
} }
(Some((span, (assoc, ty))), None) => { (Some((span, (assoc, ty))), None) => {
span_labels.push(( span_labels
span, .push((span, format!("`{assoc}` is `{ty}` here")));
format!("associated type `{assoc}` is `{ty}` here"),
));
} }
(None, Some(_)) | (None, None) => {} (None, Some(_)) | (None, None) => {}
} }

View file

@ -29,9 +29,9 @@ LL | let sr: Vec<(u32, _, _) = vec![];
| ------ this expression has type `Vec<(_, _, _)>` | ------ this expression has type `Vec<(_, _, _)>`
... ...
LL | let sr2: Vec<(u32, _, _)> = sr.iter().map(|(faction, th_sender, th_receiver)| {}).collect(); 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` note: required by a bound in `collect`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
| |

View file

@ -14,7 +14,7 @@ note: the method call chain might not have had the expected associated types
LL | let x1: &[f64] = &v; LL | let x1: &[f64] = &v;
| -- this expression has type `&Vec<f64>` | -- this expression has type `&Vec<f64>`
LL | let x2: Vec<f64> = x1.into_iter().collect(); LL | let x2: Vec<f64> = 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` note: required by a bound in `collect`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
| |
@ -38,7 +38,7 @@ LL | let x1: &[f64] = &v;
| -- this expression has type `&Vec<f64>` | -- this expression has type `&Vec<f64>`
... ...
LL | let x3 = x1.into_iter().collect::<Vec<f64>>(); LL | let x3 = x1.into_iter().collect::<Vec<f64>>();
| ^^^^^^^^^^^ associated type `std::iter::Iterator::Item` is `&f64` here | ^^^^^^^^^^^ `std::iter::Iterator::Item` is `&f64` here
note: required by a bound in `collect` note: required by a bound in `collect`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
| |

View file

@ -15,12 +15,12 @@ note: the method call chain might not have had the expected associated types
LL | let scores = vec![(0, 0)] LL | let scores = vec![(0, 0)]
| ------------ this expression has type `Vec<({integer}, {integer})>` | ------------ this expression has type `Vec<({integer}, {integer})>`
LL | .iter() 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 | .map(|(a, b)| {
| __________^ | __________^
LL | | a + b; LL | | a + b;
LL | | }); 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` note: required by a bound in `std::iter::Iterator::sum`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL --> $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] LL | vec![0, 1]
| ---------- this expression has type `Vec<{integer}>` | ---------- this expression has type `Vec<{integer}>`
LL | .iter() LL | .iter()
| ^^^^^^ associated type `std::iter::Iterator::Item` is `&{integer}` here | ^^^^^^ `std::iter::Iterator::Item` is `&{integer}` here
LL | .map(|x| x * 2) 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) 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) 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 | .filter(|x| *x > 0)
| ------------------ | ------------------
LL | .map(|x| { x + 1 }) LL | .map(|x| { x + 1 })
| ------------------ | ------------------
LL | .map(|x| { x; }) 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` note: required by a bound in `std::iter::Iterator::sum`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL --> $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 --> $DIR/invalid-iterator-chain.rs:20:31
| |
LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>()); LL | println!("{}", vec![0, 1].iter().map(|x| { x; }).sum::<i32>());
| ---------- ^^^^^^ ^^^^^^^^^^^^^^^ 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}>` | this expression has type `Vec<{integer}>`
note: required by a bound in `std::iter::Iterator::sum` note: required by a bound in `std::iter::Iterator::sum`
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL --> $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 --> $DIR/invalid-iterator-chain.rs:21:33
| |
LL | println!("{}", vec![(), ()].iter().sum::<i32>()); LL | println!("{}", vec![(), ()].iter().sum::<i32>());
| ------------ ^^^^^^ associated type `std::iter::Iterator::Item` is `&()` here | ------------ ^^^^^^ `std::iter::Iterator::Item` is `&()` here
| | | |
| this expression has type `Vec<()>` | this expression has type `Vec<()>`
note: required by a bound in `std::iter::Iterator::sum` 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]; LL | let a = vec![0];
| ------- this expression has type `Vec<{integer}>` | ------- this expression has type `Vec<{integer}>`
LL | let b = a.into_iter(); 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 c = b.map(|x| x + 1);
| -------------- | --------------
LL | let d = c.filter(|x| *x > 10 ); LL | let d = c.filter(|x| *x > 10 );
@ -143,7 +143,7 @@ LL | let e = d.map(|x| {
| _______________^ | _______________^
LL | | x + 1; LL | | x + 1;
LL | | }); LL | | });
| |______^ associated type `std::iter::Iterator::Item` changed to `()` here | |______^ `std::iter::Iterator::Item` changed to `()` here
LL | let f = e.filter(|_| false); LL | let f = e.filter(|_| false);
| ----------------- | -----------------
note: required by a bound in `collect` note: required by a bound in `collect`