From 9f6ae8828e5509ccf4e01736dadcb80919a88988 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Tue, 13 Dec 2022 11:59:15 +0000 Subject: [PATCH] Fix a freshly detected wrong TraitRef --- .../src/traits/object_safety.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/object_safety.rs b/compiler/rustc_trait_selection/src/traits/object_safety.rs index 71919b2078ef..8b1ced78f4e8 100644 --- a/compiler/rustc_trait_selection/src/traits/object_safety.rs +++ b/compiler/rustc_trait_selection/src/traits/object_safety.rs @@ -694,16 +694,12 @@ fn receiver_is_dispatchable<'tcx>( // U: Trait let trait_predicate = { - let substs = - InternalSubsts::for_item(tcx, method.trait_container(tcx).unwrap(), |param, _| { - if param.index == 0 { - unsized_self_ty.into() - } else { - tcx.mk_param_from_def(param) - } - }); + let trait_def_id = method.trait_container(tcx).unwrap(); + let substs = InternalSubsts::for_item(tcx, trait_def_id, |param, _| { + if param.index == 0 { unsized_self_ty.into() } else { tcx.mk_param_from_def(param) } + }); - ty::Binder::dummy(tcx.mk_trait_ref(unsize_did, substs)).to_predicate(tcx) + ty::Binder::dummy(tcx.mk_trait_ref(trait_def_id, substs)).to_predicate(tcx) }; let caller_bounds: Vec> =