Add label to method chains where assoc type remains the same

This commit is contained in:
Esteban Küber 2022-12-07 12:25:49 -08:00
parent c77ad2d765
commit aff0ab43c8
2 changed files with 10 additions and 5 deletions

View File

@ -3027,6 +3027,11 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
span, span,
format!("`{assoc}` changed to `{ty}` here"), format!("`{assoc}` changed to `{ty}` here"),
)); ));
} else {
span_labels.push((
span,
format!("`{assoc}` remains `{ty}` here"),
));
} }
} }
(Some((span, (assoc, ty))), None) => { (Some((span, (assoc, ty))), None) => {

View File

@ -58,9 +58,9 @@ LL | .map(|x| x as f64)
LL | .map(|x| x as i64) LL | .map(|x| x as i64)
| ^^^^^^^^^^^^^^^^^ `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)
| ------------------ | ------------------ `std::iter::Iterator::Item` remains `i64` here
LL | .map(|x| { x + 1 }) LL | .map(|x| { x + 1 })
| ------------------ | ------------------ `std::iter::Iterator::Item` remains `i64` here
LL | .map(|x| { x; }) LL | .map(|x| { x; })
| ^^^^^^^^^^^^^^^ `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`
@ -136,16 +136,16 @@ LL | let a = vec![0];
LL | let b = a.into_iter(); LL | let b = a.into_iter();
| ^^^^^^^^^^^ `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);
| -------------- | -------------- `std::iter::Iterator::Item` remains `{integer}` here
LL | let d = c.filter(|x| *x > 10 ); LL | let d = c.filter(|x| *x > 10 );
| -------------------- | -------------------- `std::iter::Iterator::Item` remains `{integer}` here
LL | let e = d.map(|x| { LL | let e = d.map(|x| {
| _______________^ | _______________^
LL | | x + 1; LL | | x + 1;
LL | | }); LL | | });
| |______^ `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);
| ----------------- | ----------------- `std::iter::Iterator::Item` remains `()` 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
| |