about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2022-12-07 12:25:49 -0800
committerEsteban Küber <esteban@kuber.com.ar>2022-12-11 09:46:02 -0800
commitaff0ab43c8fecbf9473d60d30e5d03f8612efd91 (patch)
tree2ae07e26f5827e8cc46476c2022b5c79c7b43bcb
parentc77ad2d76576b97f6b2ea8c8b5ddb672c3383512 (diff)
downloadrust-aff0ab43c8fecbf9473d60d30e5d03f8612efd91.tar.gz
rust-aff0ab43c8fecbf9473d60d30e5d03f8612efd91.zip
Add label to method chains where assoc type remains the same
-rw-r--r--compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs5
-rw-r--r--src/test/ui/iterators/invalid-iterator-chain.stderr10
2 files changed, 10 insertions, 5 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 bef2a067ae3..1d6e749b9e3 100644
--- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
+++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs
@@ -3027,6 +3027,11 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
                                                 span,
                                                 format!("`{assoc}` changed to `{ty}` here"),
                                             ));
+                                        } else {
+                                            span_labels.push((
+                                                span,
+                                                format!("`{assoc}` remains `{ty}` here"),
+                                            ));
                                         }
                                     }
                                     (Some((span, (assoc, ty))), None) => {
diff --git a/src/test/ui/iterators/invalid-iterator-chain.stderr b/src/test/ui/iterators/invalid-iterator-chain.stderr
index 0505dd86af3..14e430726f6 100644
--- a/src/test/ui/iterators/invalid-iterator-chain.stderr
+++ b/src/test/ui/iterators/invalid-iterator-chain.stderr
@@ -58,9 +58,9 @@ LL |             .map(|x| x as f64)
 LL |             .map(|x| x as i64)
    |              ^^^^^^^^^^^^^^^^^ `std::iter::Iterator::Item` changed to `i64` here
 LL |             .filter(|x| *x > 0)
-   |              ------------------
+   |              ------------------ `std::iter::Iterator::Item` remains `i64` here
 LL |             .map(|x| { x + 1 })
-   |              ------------------
+   |              ------------------ `std::iter::Iterator::Item` remains `i64` here
 LL |             .map(|x| { x; })
    |              ^^^^^^^^^^^^^^^ `std::iter::Iterator::Item` changed to `()` here
 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();
    |                 ^^^^^^^^^^^ `std::iter::Iterator::Item` is `{integer}` here
 LL |       let c = b.map(|x| x + 1);
-   |                 --------------
+   |                 -------------- `std::iter::Iterator::Item` remains `{integer}` here
 LL |       let d = c.filter(|x| *x > 10 );
-   |                 --------------------
+   |                 -------------------- `std::iter::Iterator::Item` remains `{integer}` here
 LL |       let e = d.map(|x| {
    |  _______________^
 LL | |         x + 1;
 LL | |     });
    | |______^ `std::iter::Iterator::Item` changed to `()` here
 LL |       let f = e.filter(|_| false);
-   |                 -----------------
+   |                 ----------------- `std::iter::Iterator::Item` remains `()` here
 note: required by a bound in `collect`
   --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
    |