From ed25cf70d5e0df9c7a33deb503ea14c2d97bd7a7 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 31 Jan 2020 16:52:43 +0100 Subject: Change Ty::Param to contain param ID --- crates/ra_hir_ty/src/infer/coerce.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'crates/ra_hir_ty/src/infer/coerce.rs') diff --git a/crates/ra_hir_ty/src/infer/coerce.rs b/crates/ra_hir_ty/src/infer/coerce.rs index 83c0c2c3f..2a9567898 100644 --- a/crates/ra_hir_ty/src/infer/coerce.rs +++ b/crates/ra_hir_ty/src/infer/coerce.rs @@ -57,8 +57,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { let trait_ref = db.impl_trait(impl_id)?; // `CoerseUnsized` has one generic parameter for the target type. - let cur_from_ty = trait_ref.substs.0.get(0)?; - let cur_to_ty = trait_ref.substs.0.get(1)?; + let cur_from_ty = trait_ref.value.substs.0.get(0)?; + let cur_to_ty = trait_ref.value.substs.0.get(1)?; match (&cur_from_ty, cur_to_ty) { (ty_app!(ctor1, st1), ty_app!(ctor2, st2)) => { @@ -66,8 +66,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { // This works for smart-pointer-like coercion, which covers all impls from std. st1.iter().zip(st2.iter()).enumerate().find_map(|(i, (ty1, ty2))| { match (ty1, ty2) { - (Ty::Param { idx: p1, .. }, Ty::Param { idx: p2, .. }) - if p1 != p2 => + (Ty::Bound(idx1), Ty::Bound(idx2)) + if idx1 != idx2 => { Some(((*ctor1, *ctor2), i)) } @@ -256,8 +256,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { let unsize_generic_index = { let mut index = None; let mut multiple_param = false; - field_tys[last_field_id].walk(&mut |ty| match ty { - &Ty::Param { idx, .. } => { + field_tys[last_field_id].value.walk(&mut |ty| match ty { + &Ty::Bound(idx) => { if index.is_none() { index = Some(idx); } else if Some(idx) != index { @@ -276,8 +276,8 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { // Check other fields do not involve it. let mut multiple_used = false; fields.for_each(|(field_id, _data)| { - field_tys[field_id].walk(&mut |ty| match ty { - &Ty::Param { idx, .. } if idx == unsize_generic_index => { + field_tys[field_id].value.walk(&mut |ty| match ty { + &Ty::Bound(idx) if idx == unsize_generic_index => { multiple_used = true } _ => {} -- cgit v1.2.3 From dded90a748737c3661aad043524f2248e324c867 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 7 Feb 2020 15:13:15 +0100 Subject: Formatting --- crates/ra_hir_ty/src/infer/coerce.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'crates/ra_hir_ty/src/infer/coerce.rs') diff --git a/crates/ra_hir_ty/src/infer/coerce.rs b/crates/ra_hir_ty/src/infer/coerce.rs index 2a9567898..f68a1439f 100644 --- a/crates/ra_hir_ty/src/infer/coerce.rs +++ b/crates/ra_hir_ty/src/infer/coerce.rs @@ -66,9 +66,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { // This works for smart-pointer-like coercion, which covers all impls from std. st1.iter().zip(st2.iter()).enumerate().find_map(|(i, (ty1, ty2))| { match (ty1, ty2) { - (Ty::Bound(idx1), Ty::Bound(idx2)) - if idx1 != idx2 => - { + (Ty::Bound(idx1), Ty::Bound(idx2)) if idx1 != idx2 => { Some(((*ctor1, *ctor2), i)) } _ => None, @@ -277,9 +275,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { let mut multiple_used = false; fields.for_each(|(field_id, _data)| { field_tys[field_id].value.walk(&mut |ty| match ty { - &Ty::Bound(idx) if idx == unsize_generic_index => { - multiple_used = true - } + &Ty::Bound(idx) if idx == unsize_generic_index => multiple_used = true, _ => {} }) }); -- cgit v1.2.3