Substitute things correctly

This commit is contained in:
Michael Goulet 2022-12-21 05:36:26 +00:00
parent c8ebff6aee
commit 0c09e2bf5a
2 changed files with 6 additions and 5 deletions

View file

@ -3182,7 +3182,8 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
let mut type_diffs = vec![]; let mut type_diffs = vec![];
if let ObligationCauseCode::ExprBindingObligation(def_id, _, _, idx) = parent_code.deref() if let ObligationCauseCode::ExprBindingObligation(def_id, _, _, idx) = parent_code.deref()
&& let predicates = self.tcx.predicates_of(def_id).instantiate_identity(self.tcx) && let Some(node_substs) = typeck_results.node_substs_opt(call_hir_id)
&& let predicates = self.tcx.predicates_of(def_id).instantiate(self.tcx, node_substs)
&& let Some(pred) = predicates.predicates.get(*idx) && let Some(pred) = predicates.predicates.get(*idx)
{ {
if let Some(trait_pred) = pred.to_opt_poly_trait_pred() if let Some(trait_pred) = pred.to_opt_poly_trait_pred()

View file

@ -52,14 +52,14 @@ LL | .sum::<i32>(),
<i32 as Sum<&'a i32>> <i32 as Sum<&'a i32>>
<i32 as Sum> <i32 as Sum>
note: the method call chain might not have had the expected associated types note: the method call chain might not have had the expected associated types
--> $DIR/invalid-iterator-chain.rs:20:14 --> $DIR/invalid-iterator-chain.rs:25:14
| |
LL | vec![0, 1] LL | vec![0, 1]
| ---------- this expression has type `Vec<{integer}>` | ---------- this expression has type `Vec<{integer}>`
LL | .iter() LL | .iter()
| ------ `Iterator::Item` is `&{integer}` here | ------ `Iterator::Item` is `&{integer}` here
LL | .map(|x| x * 2) LL | .map(|x| x * 2)
| ^^^^^^^^^^^^^^ `Iterator::Item` changed to `{integer}` here | -------------- `Iterator::Item` changed to `{integer}` here
LL | .map(|x| x as f64) LL | .map(|x| x as f64)
| ----------------- `Iterator::Item` changed to `f64` here | ----------------- `Iterator::Item` changed to `f64` here
LL | .map(|x| x as i64) LL | .map(|x| x as i64)
@ -84,14 +84,14 @@ LL | .sum::<i32>(),
<i32 as Sum<&'a i32>> <i32 as Sum<&'a i32>>
<i32 as Sum> <i32 as Sum>
note: the method call chain might not have had the expected associated types note: the method call chain might not have had the expected associated types
--> $DIR/invalid-iterator-chain.rs:32:14 --> $DIR/invalid-iterator-chain.rs:33:14
| |
LL | vec![0, 1] LL | vec![0, 1]
| ---------- this expression has type `Vec<{integer}>` | ---------- this expression has type `Vec<{integer}>`
LL | .iter() LL | .iter()
| ------ `Iterator::Item` is `&{integer}` here | ------ `Iterator::Item` is `&{integer}` here
LL | .map(|x| x * 2) LL | .map(|x| x * 2)
| ^^^^^^^^^^^^^^ `Iterator::Item` changed to `{integer}` here | -------------- `Iterator::Item` changed to `{integer}` here
LL | .map(|x| x as f64) LL | .map(|x| x as f64)
| ^^^^^^^^^^^^^^^^^ `Iterator::Item` changed to `f64` here | ^^^^^^^^^^^^^^^^^ `Iterator::Item` changed to `f64` here
LL | .filter(|x| *x > 0.0) LL | .filter(|x| *x > 0.0)