Auto merge of #110806 - WaffleLapkin:unmkI, r=lcnr
Replace `tcx.mk_trait_ref` with `TraitRef::new` First step in implementing https://github.com/rust-lang/compiler-team/issues/616 r? `@lcnr`
This commit is contained in:
commit
6f8c0557e0
49 changed files with 246 additions and 181 deletions
|
@ -694,7 +694,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
let assoc_bindings = self.create_assoc_bindings_for_generic_args(args);
|
||||
|
||||
let poly_trait_ref =
|
||||
ty::Binder::bind_with_vars(tcx.mk_trait_ref(trait_def_id, substs), bound_vars);
|
||||
ty::Binder::bind_with_vars(ty::TraitRef::new(tcx, trait_def_id, substs), bound_vars);
|
||||
|
||||
debug!(?poly_trait_ref, ?assoc_bindings);
|
||||
bounds.push_trait_bound(tcx, poly_trait_ref, span, constness, polarity);
|
||||
|
@ -846,7 +846,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
if let Some(b) = trait_segment.args().bindings.first() {
|
||||
prohibit_assoc_ty_binding(self.tcx(), b.span, Some((trait_segment, span)));
|
||||
}
|
||||
self.tcx().mk_trait_ref(trait_def_id, substs)
|
||||
ty::TraitRef::new(self.tcx(), trait_def_id, substs)
|
||||
}
|
||||
|
||||
#[instrument(level = "debug", skip(self, span))]
|
||||
|
|
|
@ -123,7 +123,7 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
|
|||
let tcx = self.infcx.tcx;
|
||||
|
||||
// <ty as Deref>
|
||||
let trait_ref = tcx.mk_trait_ref(tcx.lang_items().deref_trait()?, [ty]);
|
||||
let trait_ref = ty::TraitRef::new(tcx, tcx.lang_items().deref_trait()?, [ty]);
|
||||
|
||||
let cause = traits::ObligationCause::misc(self.span, self.body_id);
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ impl<'tcx> Bounds<'tcx> {
|
|||
|
||||
pub fn push_sized(&mut self, tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, span: Span) {
|
||||
let sized_def_id = tcx.require_lang_item(LangItem::Sized, Some(span));
|
||||
let trait_ref = ty::Binder::dummy(tcx.mk_trait_ref(sized_def_id, [ty]));
|
||||
let trait_ref = ty::TraitRef::new(tcx, sized_def_id, [ty]);
|
||||
// Preferable to put this obligation first, since we report better errors for sized ambiguity.
|
||||
self.predicates.insert(0, (trait_ref.without_const().to_predicate(tcx), span));
|
||||
}
|
||||
|
|
|
@ -536,7 +536,7 @@ fn check_item_type(tcx: TyCtxt<'_>, id: hir::ItemId) {
|
|||
tcx,
|
||||
assoc_item,
|
||||
assoc_item,
|
||||
tcx.mk_trait_ref(id.owner_id.to_def_id(), trait_substs),
|
||||
ty::TraitRef::new(tcx, id.owner_id.to_def_id(), trait_substs),
|
||||
);
|
||||
}
|
||||
_ => {}
|
||||
|
|
|
@ -1779,7 +1779,7 @@ fn receiver_is_implemented<'tcx>(
|
|||
receiver_ty: Ty<'tcx>,
|
||||
) -> bool {
|
||||
let tcx = wfcx.tcx();
|
||||
let trait_ref = ty::Binder::dummy(tcx.mk_trait_ref(receiver_trait_def_id, [receiver_ty]));
|
||||
let trait_ref = ty::TraitRef::new(tcx, receiver_trait_def_id, [receiver_ty]);
|
||||
|
||||
let obligation = traits::Obligation::new(tcx, cause, wfcx.param_env, trait_ref);
|
||||
|
||||
|
|
|
@ -265,10 +265,11 @@ fn visit_implementation_of_dispatch_from_dyn(tcx: TyCtxt<'_>, impl_did: LocalDef
|
|||
tcx,
|
||||
cause.clone(),
|
||||
param_env,
|
||||
ty::Binder::dummy(tcx.mk_trait_ref(
|
||||
ty::TraitRef::new(
|
||||
tcx,
|
||||
dispatch_from_dyn_trait,
|
||||
[field.ty(tcx, substs_a), field.ty(tcx, substs_b)],
|
||||
)),
|
||||
),
|
||||
));
|
||||
}
|
||||
let errors = ocx.select_all_or_error();
|
||||
|
@ -504,8 +505,12 @@ pub fn coerce_unsized_info<'tcx>(tcx: TyCtxt<'tcx>, impl_did: LocalDefId) -> Coe
|
|||
// Register an obligation for `A: Trait<B>`.
|
||||
let ocx = ObligationCtxt::new(&infcx);
|
||||
let cause = traits::ObligationCause::misc(span, impl_did);
|
||||
let obligation =
|
||||
Obligation::new(tcx, cause, param_env, tcx.mk_trait_ref(trait_def_id, [source, target]));
|
||||
let obligation = Obligation::new(
|
||||
tcx,
|
||||
cause,
|
||||
param_env,
|
||||
ty::TraitRef::new(tcx, trait_def_id, [source, target]),
|
||||
);
|
||||
ocx.register_obligation(obligation);
|
||||
let errors = ocx.select_all_or_error();
|
||||
if !errors.is_empty() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue