Skip to content

Commit 0c09e2b

Browse files
Substitute things correctly
1 parent c8ebff6 commit 0c09e2b

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -3182,7 +3182,8 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
31823182
let mut type_diffs = vec![];
31833183

31843184
if let ObligationCauseCode::ExprBindingObligation(def_id, _, _, idx) = parent_code.deref()
3185-
&& let predicates = self.tcx.predicates_of(def_id).instantiate_identity(self.tcx)
3185+
&& let Some(node_substs) = typeck_results.node_substs_opt(call_hir_id)
3186+
&& let predicates = self.tcx.predicates_of(def_id).instantiate(self.tcx, node_substs)
31863187
&& let Some(pred) = predicates.predicates.get(*idx)
31873188
{
31883189
if let Some(trait_pred) = pred.to_opt_poly_trait_pred()

src/test/ui/iterators/invalid-iterator-chain.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ LL | .sum::<i32>(),
5252
<i32 as Sum<&'a i32>>
5353
<i32 as Sum>
5454
note: the method call chain might not have had the expected associated types
55-
--> $DIR/invalid-iterator-chain.rs:20:14
55+
--> $DIR/invalid-iterator-chain.rs:25:14
5656
|
5757
LL | vec![0, 1]
5858
| ---------- this expression has type `Vec<{integer}>`
5959
LL | .iter()
6060
| ------ `Iterator::Item` is `&{integer}` here
6161
LL | .map(|x| x * 2)
62-
| ^^^^^^^^^^^^^^ `Iterator::Item` changed to `{integer}` here
62+
| -------------- `Iterator::Item` changed to `{integer}` here
6363
LL | .map(|x| x as f64)
6464
| ----------------- `Iterator::Item` changed to `f64` here
6565
LL | .map(|x| x as i64)
@@ -84,14 +84,14 @@ LL | .sum::<i32>(),
8484
<i32 as Sum<&'a i32>>
8585
<i32 as Sum>
8686
note: the method call chain might not have had the expected associated types
87-
--> $DIR/invalid-iterator-chain.rs:32:14
87+
--> $DIR/invalid-iterator-chain.rs:33:14
8888
|
8989
LL | vec![0, 1]
9090
| ---------- this expression has type `Vec<{integer}>`
9191
LL | .iter()
9292
| ------ `Iterator::Item` is `&{integer}` here
9393
LL | .map(|x| x * 2)
94-
| ^^^^^^^^^^^^^^ `Iterator::Item` changed to `{integer}` here
94+
| -------------- `Iterator::Item` changed to `{integer}` here
9595
LL | .map(|x| x as f64)
9696
| ^^^^^^^^^^^^^^^^^ `Iterator::Item` changed to `f64` here
9797
LL | .filter(|x| *x > 0.0)

0 commit comments

Comments
 (0)