diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs index c6f2b16ca2102..2da98d3342984 100644 --- a/compiler/rustc_ty_utils/src/instance.rs +++ b/compiler/rustc_ty_utils/src/instance.rs @@ -44,7 +44,13 @@ fn inner_resolve_instance<'tcx>( let result = if let Some(trait_def_id) = tcx.trait_of_item(def.did) { debug!(" => associated item, attempting to find impl in param_env {:#?}", param_env); - resolve_associated_item(tcx, def.did, param_env, trait_def_id, substs) + resolve_associated_item( + tcx, + def.did, + param_env, + trait_def_id, + tcx.normalize_erasing_regions(param_env, substs), + ) } else { let ty = tcx.type_of(def.def_id_for_type_of()); let item_type = tcx.subst_and_normalize_erasing_regions(substs, param_env, ty); diff --git a/src/test/ui/associated-item/issue-105449.rs b/src/test/ui/associated-item/issue-105449.rs new file mode 100644 index 0000000000000..dd14e05fd49b2 --- /dev/null +++ b/src/test/ui/associated-item/issue-105449.rs @@ -0,0 +1,59 @@ +// check-pass +// compile-flags: -C debug_assertions=yes -Zunstable-options + +#[allow(dead_code)] +fn problematic_function() +where + DefaultAlloc: FinAllok, +{ + let e = Edge2dElement; + let _ = Into::::into(e.map_reference_coords()); +} +impl Allocator for DefaultAlloc { + type Buffer = MStorage; +} +impl Allocator for DefaultAlloc { + type Buffer = MStorage; +} +impl From> for Point +where + DefaultAlloc: Allocator, +{ + fn from(_: VectorN) -> Self { + unimplemented!() + } +} +impl FinAllok for DefaultAlloc +where + DefaultAlloc: Allocator, + DefaultAlloc: Allocator +{ +} +impl FiniteElement for Edge2dElement { + fn map_reference_coords(&self) -> VectorN { + unimplemented!() + } +} +type VectorN = (N, R, >::Buffer); +struct DefaultAlloc; +struct R0; +struct R1; +struct MStorage; +struct Point; +struct Edge2dElement; +struct Ure; +trait Allocator { + type Buffer; +} +trait FinAllok: + Allocator + + Allocator + +{ +} +trait FiniteElement +where + DefaultAlloc: FinAllok, +{ + fn map_reference_coords(&self) -> VectorN; +} +fn main() {}