Replace tcx.mk_trait_ref
with ty::TraitRef::new
This commit is contained in:
parent
2d8c905e15
commit
46b01abbcd
@ -1111,7 +1111,7 @@ fn explain_captures(
|
||||
});
|
||||
}
|
||||
if let Some(clone_trait) = tcx.lang_items().clone_trait()
|
||||
&& let trait_ref = tcx.mk_trait_ref(clone_trait, [ty])
|
||||
&& let trait_ref = ty::TraitRef::new(tcx, clone_trait, [ty])
|
||||
&& let o = Obligation::new(
|
||||
tcx,
|
||||
ObligationCause::dummy(),
|
||||
|
@ -538,7 +538,8 @@ fn sanitize_place(
|
||||
|
||||
if let PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy) = context {
|
||||
let tcx = self.tcx();
|
||||
let trait_ref = tcx.at(self.last_span).mk_trait_ref(LangItem::Copy, [place_ty.ty]);
|
||||
let trait_ref =
|
||||
ty::TraitRef::from_lang_item(tcx.at(self.last_span), LangItem::Copy, [place_ty.ty]);
|
||||
|
||||
// To have a `Copy` operand, the type `T` of the
|
||||
// value must be `Copy`. Note that we prove that `T: Copy`,
|
||||
@ -1237,8 +1238,11 @@ fn check_stmt(&mut self, body: &Body<'tcx>, stmt: &Statement<'tcx>, location: Lo
|
||||
|
||||
self.check_rvalue(body, rv, location);
|
||||
if !self.unsized_feature_enabled() {
|
||||
let trait_ref =
|
||||
tcx.at(self.last_span).mk_trait_ref(LangItem::Sized, [place_ty]);
|
||||
let trait_ref = ty::TraitRef::from_lang_item(
|
||||
tcx.at(self.last_span),
|
||||
LangItem::Sized,
|
||||
[place_ty],
|
||||
);
|
||||
self.prove_trait_ref(
|
||||
trait_ref,
|
||||
location.to_locations(),
|
||||
@ -1810,7 +1814,8 @@ fn check_rvalue(&mut self, body: &Body<'tcx>, rvalue: &Rvalue<'tcx>, location: L
|
||||
Operand::Move(place) => {
|
||||
// Make sure that repeated elements implement `Copy`.
|
||||
let ty = place.ty(body, tcx).ty;
|
||||
let trait_ref = tcx.at(span).mk_trait_ref(LangItem::Copy, [ty]);
|
||||
let trait_ref =
|
||||
ty::TraitRef::from_lang_item(tcx.at(span), LangItem::Copy, [ty]);
|
||||
|
||||
self.prove_trait_ref(
|
||||
trait_ref,
|
||||
@ -1823,7 +1828,7 @@ fn check_rvalue(&mut self, body: &Body<'tcx>, rvalue: &Rvalue<'tcx>, location: L
|
||||
}
|
||||
|
||||
&Rvalue::NullaryOp(NullOp::SizeOf | NullOp::AlignOf, ty) => {
|
||||
let trait_ref = tcx.at(span).mk_trait_ref(LangItem::Sized, [ty]);
|
||||
let trait_ref = ty::TraitRef::from_lang_item(tcx.at(span), LangItem::Sized, [ty]);
|
||||
|
||||
self.prove_trait_ref(
|
||||
trait_ref,
|
||||
@ -1835,7 +1840,7 @@ fn check_rvalue(&mut self, body: &Body<'tcx>, rvalue: &Rvalue<'tcx>, location: L
|
||||
Rvalue::ShallowInitBox(operand, ty) => {
|
||||
self.check_operand(operand, location);
|
||||
|
||||
let trait_ref = tcx.at(span).mk_trait_ref(LangItem::Sized, [*ty]);
|
||||
let trait_ref = ty::TraitRef::from_lang_item(tcx.at(span), LangItem::Sized, [*ty]);
|
||||
|
||||
self.prove_trait_ref(
|
||||
trait_ref,
|
||||
@ -1932,9 +1937,11 @@ fn check_rvalue(&mut self, body: &Body<'tcx>, rvalue: &Rvalue<'tcx>, location: L
|
||||
|
||||
CastKind::Pointer(PointerCast::Unsize) => {
|
||||
let &ty = ty;
|
||||
let trait_ref = tcx
|
||||
.at(span)
|
||||
.mk_trait_ref(LangItem::CoerceUnsized, [op.ty(body, tcx), ty]);
|
||||
let trait_ref = ty::TraitRef::from_lang_item(
|
||||
tcx.at(span),
|
||||
LangItem::CoerceUnsized,
|
||||
[op.ty(body, tcx), ty],
|
||||
);
|
||||
|
||||
self.prove_trait_ref(
|
||||
trait_ref,
|
||||
|
@ -157,8 +157,12 @@ fn in_any_value_of_ty<'tcx>(cx: &ConstCx<'_, 'tcx>, ty: Ty<'tcx>) -> bool {
|
||||
cx.tcx,
|
||||
ObligationCause::dummy_with_span(cx.body.span),
|
||||
cx.param_env,
|
||||
ty::Binder::dummy(cx.tcx.at(cx.body.span).mk_trait_ref(LangItem::Destruct, [ty]))
|
||||
.with_constness(ty::BoundConstness::ConstIfConst),
|
||||
ty::Binder::dummy(ty::TraitRef::from_lang_item(
|
||||
cx.tcx.at(cx.body.span),
|
||||
LangItem::Destruct,
|
||||
[ty],
|
||||
))
|
||||
.with_constness(ty::BoundConstness::ConstIfConst),
|
||||
);
|
||||
|
||||
let infcx = cx.tcx.infer_ctxt().build();
|
||||
|
@ -689,7 +689,7 @@ fn instantiate_poly_trait_ref_inner(
|
||||
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);
|
||||
@ -822,7 +822,7 @@ fn ast_path_to_mono_trait_ref(
|
||||
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 @@ fn overloaded_deref_ty(&mut self, ty: Ty<'tcx>) -> Option<Ty<'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);
|
||||
|
||||
|
@ -57,7 +57,7 @@ pub fn push_projection_bound(
|
||||
|
||||
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::Binder::dummy(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));
|
||||
}
|
||||
|
@ -538,7 +538,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),
|
||||
);
|
||||
}
|
||||
_ => {}
|
||||
|
@ -1784,7 +1784,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::Binder::dummy(ty::TraitRef::new(tcx, receiver_trait_def_id, [receiver_ty]));
|
||||
|
||||
let obligation = traits::Obligation::new(tcx, cause, wfcx.param_env, trait_ref);
|
||||
|
||||
|
@ -340,7 +340,8 @@ 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::Binder::dummy(ty::TraitRef::new(
|
||||
tcx,
|
||||
dispatch_from_dyn_trait,
|
||||
[field.ty(tcx, substs_a), field.ty(tcx, substs_b)],
|
||||
)),
|
||||
@ -579,8 +580,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() {
|
||||
|
@ -601,7 +601,7 @@ fn coerce_unsized(&self, mut source: Ty<'tcx>, mut target: Ty<'tcx>) -> CoerceRe
|
||||
self.tcx,
|
||||
cause,
|
||||
self.fcx.param_env,
|
||||
self.tcx.mk_trait_ref(coerce_unsized_did, [coerce_source, coerce_target])
|
||||
ty::TraitRef::new(self.tcx, coerce_unsized_did, [coerce_source, coerce_target])
|
||||
)];
|
||||
|
||||
let mut has_unsized_tuple_coercion = false;
|
||||
@ -764,9 +764,11 @@ fn coerce_dyn_star(
|
||||
self.tcx,
|
||||
self.cause.clone(),
|
||||
self.param_env,
|
||||
ty::Binder::dummy(
|
||||
self.tcx.at(self.cause.span).mk_trait_ref(hir::LangItem::PointerLike, [a]),
|
||||
),
|
||||
ty::Binder::dummy(ty::TraitRef::from_lang_item(
|
||||
self.tcx.at(self.cause.span),
|
||||
hir::LangItem::PointerLike,
|
||||
[a],
|
||||
)),
|
||||
));
|
||||
|
||||
Ok(InferOk {
|
||||
|
@ -481,7 +481,8 @@ fn blame_specific_expr_if_possible_for_derived_predicate_obligation(
|
||||
// For the purposes of this function, we hope that it is a `struct` type, and that our current `expr` is a literal of
|
||||
// that struct type.
|
||||
let impl_trait_self_ref = if self.tcx.is_trait_alias(obligation.impl_or_alias_def_id) {
|
||||
self.tcx.mk_trait_ref(
|
||||
ty::TraitRef::new(
|
||||
self.tcx,
|
||||
obligation.impl_or_alias_def_id,
|
||||
ty::InternalSubsts::identity_for_item(self.tcx, obligation.impl_or_alias_def_id),
|
||||
)
|
||||
|
@ -1911,7 +1911,7 @@ fn label_fn_like(
|
||||
_ => {
|
||||
// Look for a user-provided impl of a `Fn` trait, and point to it.
|
||||
let new_def_id = self.probe(|_| {
|
||||
let trait_ref = self.tcx.mk_trait_ref(
|
||||
let trait_ref = ty::TraitRef::new(self.tcx,
|
||||
call_kind.to_def_id(self.tcx),
|
||||
[
|
||||
callee_ty,
|
||||
|
@ -1096,7 +1096,7 @@ pub(crate) fn suggest_into(
|
||||
self.tcx,
|
||||
self.misc(expr.span),
|
||||
self.param_env,
|
||||
ty::Binder::dummy(self.tcx.mk_trait_ref(
|
||||
ty::Binder::dummy(ty::TraitRef::new(self.tcx,
|
||||
into_def_id,
|
||||
[expr_ty, expected_ty]
|
||||
)),
|
||||
@ -1438,7 +1438,7 @@ pub(crate) fn note_type_is_not_clone(
|
||||
&& !results.expr_adjustments(callee_expr).iter().any(|adj| matches!(adj.kind, ty::adjustment::Adjust::Deref(..)))
|
||||
// Check that we're in fact trying to clone into the expected type
|
||||
&& self.can_coerce(*pointee_ty, expected_ty)
|
||||
&& let trait_ref = ty::Binder::dummy(self.tcx.mk_trait_ref(clone_trait_did, [expected_ty]))
|
||||
&& let trait_ref = ty::Binder::dummy(ty::TraitRef::new(self.tcx, clone_trait_did, [expected_ty]))
|
||||
// And the expected type doesn't implement `Clone`
|
||||
&& !self.predicate_must_hold_considering_regions(&traits::Obligation::new(
|
||||
self.tcx,
|
||||
|
@ -316,7 +316,7 @@ pub(super) fn obligation_for_method(
|
||||
self.var_for_def(cause.span, param)
|
||||
});
|
||||
|
||||
let trait_ref = self.tcx.mk_trait_ref(trait_def_id, substs);
|
||||
let trait_ref = ty::TraitRef::new(self.tcx, trait_def_id, substs);
|
||||
|
||||
// Construct an obligation
|
||||
let poly_trait_ref = ty::Binder::dummy(trait_ref);
|
||||
|
@ -954,7 +954,7 @@ fn assemble_extension_candidates_for_trait(
|
||||
) {
|
||||
debug!("assemble_extension_candidates_for_trait(trait_def_id={:?})", trait_def_id);
|
||||
let trait_substs = self.fresh_item_substs(trait_def_id);
|
||||
let trait_ref = self.tcx.mk_trait_ref(trait_def_id, trait_substs);
|
||||
let trait_ref = ty::TraitRef::new(self.tcx, trait_def_id, trait_substs);
|
||||
|
||||
if self.tcx.is_trait_alias(trait_def_id) {
|
||||
// For trait aliases, recursively assume all explicitly named traits are relevant
|
||||
|
@ -72,7 +72,8 @@ fn is_fn_ty(&self, ty: Ty<'tcx>, span: Span) -> bool {
|
||||
self.autoderef(span, ty).any(|(ty, _)| {
|
||||
info!("check deref {:?} impl FnOnce", ty);
|
||||
self.probe(|_| {
|
||||
let trait_ref = tcx.mk_trait_ref(
|
||||
let trait_ref = ty::TraitRef::new(
|
||||
tcx,
|
||||
fn_once,
|
||||
[
|
||||
ty,
|
||||
|
@ -261,11 +261,16 @@ fn report_trait_placeholder_mismatch(
|
||||
(false, None, None, Some(span), String::new())
|
||||
};
|
||||
|
||||
let expected_trait_ref = self
|
||||
.cx
|
||||
.resolve_vars_if_possible(self.cx.tcx.mk_trait_ref(trait_def_id, expected_substs));
|
||||
let actual_trait_ref =
|
||||
self.cx.resolve_vars_if_possible(self.cx.tcx.mk_trait_ref(trait_def_id, actual_substs));
|
||||
let expected_trait_ref = self.cx.resolve_vars_if_possible(ty::TraitRef::new(
|
||||
self.cx.tcx,
|
||||
trait_def_id,
|
||||
expected_substs,
|
||||
));
|
||||
let actual_trait_ref = self.cx.resolve_vars_if_possible(ty::TraitRef::new(
|
||||
self.cx.tcx,
|
||||
trait_def_id,
|
||||
actual_substs,
|
||||
));
|
||||
|
||||
// Search the expected and actual trait references to see (a)
|
||||
// whether the sub/sup placeholders appear in them (sometimes
|
||||
|
@ -18,7 +18,7 @@ fn register_bound(
|
||||
def_id: DefId,
|
||||
cause: ObligationCause<'tcx>,
|
||||
) {
|
||||
let trait_ref = infcx.tcx.mk_trait_ref(def_id, [ty]);
|
||||
let trait_ref = ty::TraitRef::new(infcx.tcx, def_id, [ty]);
|
||||
self.register_predicate_obligation(
|
||||
infcx,
|
||||
Obligation {
|
||||
|
@ -169,8 +169,11 @@ fn default_print_def_path(
|
||||
self.path_append(
|
||||
|cx: Self| {
|
||||
if trait_qualify_parent {
|
||||
let trait_ref =
|
||||
cx.tcx().mk_trait_ref(parent_def_id, parent_substs.iter().copied());
|
||||
let trait_ref = ty::TraitRef::new(
|
||||
cx.tcx(),
|
||||
parent_def_id,
|
||||
parent_substs.iter().copied(),
|
||||
);
|
||||
cx.path_qualified(trait_ref.self_ty(), Some(trait_ref))
|
||||
} else {
|
||||
cx.print_def_path(parent_def_id, parent_substs)
|
||||
|
@ -315,7 +315,7 @@ fn relate<R: TypeRelation<'tcx>>(
|
||||
Err(TypeError::Traits(expected_found(relation, a.def_id, b.def_id)))
|
||||
} else {
|
||||
let substs = relate_substs(relation, a.substs, b.substs)?;
|
||||
Ok(relation.tcx().mk_trait_ref(a.def_id, substs))
|
||||
Ok(ty::TraitRef::new(relation.tcx(), a.def_id, substs))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -728,13 +728,13 @@ pub fn with_self_ty(&self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> ty::Predicat
|
||||
ExistentialPredicate::AutoTrait(did) => {
|
||||
let generics = tcx.generics_of(did);
|
||||
let trait_ref = if generics.params.len() == 1 {
|
||||
tcx.mk_trait_ref(did, [self_ty])
|
||||
ty::TraitRef::new(tcx, did, [self_ty])
|
||||
} else {
|
||||
// If this is an ill-formed auto trait, then synthesize
|
||||
// new error substs for the missing generics.
|
||||
let err_substs =
|
||||
ty::InternalSubsts::extend_with_error(tcx, did, &[self_ty.into()]);
|
||||
tcx.mk_trait_ref(did, err_substs)
|
||||
ty::TraitRef::new(tcx, did, err_substs)
|
||||
};
|
||||
self.rebind(trait_ref).without_const().to_predicate(tcx)
|
||||
}
|
||||
@ -850,17 +850,22 @@ pub fn from_method(
|
||||
substs: SubstsRef<'tcx>,
|
||||
) -> ty::TraitRef<'tcx> {
|
||||
let defs = tcx.generics_of(trait_id);
|
||||
tcx.mk_trait_ref(trait_id, tcx.mk_substs(&substs[..defs.params.len()]))
|
||||
ty::TraitRef::new(tcx, trait_id, tcx.mk_substs(&substs[..defs.params.len()]))
|
||||
}
|
||||
|
||||
/// Returns a `TraitRef` of the form `P0: Foo<P1..Pn>` where `Pi`
|
||||
/// are the parameters defined on trait.
|
||||
pub fn identity(tcx: TyCtxt<'tcx>, def_id: DefId) -> Binder<'tcx, TraitRef<'tcx>> {
|
||||
ty::Binder::dummy(tcx.mk_trait_ref(def_id, InternalSubsts::identity_for_item(tcx, def_id)))
|
||||
ty::Binder::dummy(ty::TraitRef::new(
|
||||
tcx,
|
||||
def_id,
|
||||
InternalSubsts::identity_for_item(tcx, def_id),
|
||||
))
|
||||
}
|
||||
|
||||
pub fn with_self_ty(self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> Self {
|
||||
tcx.mk_trait_ref(
|
||||
ty::TraitRef::new(
|
||||
tcx,
|
||||
self.def_id,
|
||||
[self_ty.into()].into_iter().chain(self.substs.iter().skip(1)),
|
||||
)
|
||||
@ -926,7 +931,7 @@ pub fn with_self_ty(&self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> ty::TraitRef
|
||||
// otherwise the escaping vars would be captured by the binder
|
||||
// debug_assert!(!self_ty.has_escaping_bound_vars());
|
||||
|
||||
tcx.mk_trait_ref(self.def_id, [self_ty.into()].into_iter().chain(self.substs.iter()))
|
||||
ty::TraitRef::new(tcx, self.def_id, [self_ty.into()].into_iter().chain(self.substs.iter()))
|
||||
}
|
||||
}
|
||||
|
||||
@ -1245,7 +1250,7 @@ pub fn trait_ref_and_own_substs(
|
||||
let trait_def_id = self.trait_def_id(tcx);
|
||||
let trait_generics = tcx.generics_of(trait_def_id);
|
||||
(
|
||||
tcx.mk_trait_ref(trait_def_id, self.substs.truncate_to(tcx, trait_generics)),
|
||||
ty::TraitRef::new(tcx, trait_def_id, self.substs.truncate_to(tcx, trait_generics)),
|
||||
&self.substs[trait_generics.count()..],
|
||||
)
|
||||
}
|
||||
@ -1259,7 +1264,7 @@ pub fn trait_ref_and_own_substs(
|
||||
/// as well.
|
||||
pub fn trait_ref(self, tcx: TyCtxt<'tcx>) -> ty::TraitRef<'tcx> {
|
||||
let def_id = self.trait_def_id(tcx);
|
||||
tcx.mk_trait_ref(def_id, self.substs.truncate_to(tcx, tcx.generics_of(def_id)))
|
||||
ty::TraitRef::new(tcx, def_id, self.substs.truncate_to(tcx, tcx.generics_of(def_id)))
|
||||
}
|
||||
|
||||
pub fn self_ty(self) -> Ty<'tcx> {
|
||||
|
@ -191,7 +191,7 @@ fn type_may_have_partial_eq_impl(&self, ty: Ty<'tcx>) -> bool {
|
||||
self.tcx(),
|
||||
ObligationCause::dummy(),
|
||||
self.param_env,
|
||||
self.tcx().mk_trait_ref(partial_eq_trait_id, [ty, ty]),
|
||||
ty::TraitRef::new(self.tcx(), partial_eq_trait_id, [ty, ty]),
|
||||
);
|
||||
|
||||
// FIXME: should this call a `predicate_must_hold` variant instead?
|
||||
|
@ -30,8 +30,11 @@ fn custom_coerce_unsize_info<'tcx>(
|
||||
source_ty: Ty<'tcx>,
|
||||
target_ty: Ty<'tcx>,
|
||||
) -> CustomCoerceUnsized {
|
||||
let trait_ref =
|
||||
ty::Binder::dummy(tcx.mk_trait_ref(LangItem::CoerceUnsized, [source_ty, target_ty]));
|
||||
let trait_ref = ty::Binder::dummy(ty::TraitRef::from_lang_item(
|
||||
tcx,
|
||||
LangItem::CoerceUnsized,
|
||||
[source_ty, target_ty],
|
||||
));
|
||||
|
||||
match tcx.codegen_select_candidate((ty::ParamEnv::reveal_all(), trait_ref)) {
|
||||
Ok(traits::ImplSource::UserDefined(traits::ImplSourceUserDefinedData {
|
||||
|
@ -127,18 +127,19 @@ fn visit_trait(&mut self, trait_ref: TraitRef<'tcx>) -> ControlFlow<V::BreakTy>
|
||||
|
||||
fn visit_projection_ty(&mut self, projection: ty::AliasTy<'tcx>) -> ControlFlow<V::BreakTy> {
|
||||
let tcx = self.def_id_visitor.tcx();
|
||||
let (trait_ref, assoc_substs) =
|
||||
if tcx.def_kind(projection.def_id) != DefKind::ImplTraitPlaceholder {
|
||||
projection.trait_ref_and_own_substs(tcx)
|
||||
} else {
|
||||
// HACK(RPITIT): Remove this when RPITITs are lowered to regular assoc tys
|
||||
let def_id = tcx.impl_trait_in_trait_parent_fn(projection.def_id);
|
||||
let trait_generics = tcx.generics_of(def_id);
|
||||
(
|
||||
tcx.mk_trait_ref(def_id, projection.substs.truncate_to(tcx, trait_generics)),
|
||||
&projection.substs[trait_generics.count()..],
|
||||
)
|
||||
};
|
||||
let (trait_ref, assoc_substs) = if tcx.def_kind(projection.def_id)
|
||||
!= DefKind::ImplTraitPlaceholder
|
||||
{
|
||||
projection.trait_ref_and_own_substs(tcx)
|
||||
} else {
|
||||
// HACK(RPITIT): Remove this when RPITITs are lowered to regular assoc tys
|
||||
let def_id = tcx.impl_trait_in_trait_parent_fn(projection.def_id);
|
||||
let trait_generics = tcx.generics_of(def_id);
|
||||
(
|
||||
ty::TraitRef::new(tcx, def_id, projection.substs.truncate_to(tcx, trait_generics)),
|
||||
&projection.substs[trait_generics.count()..],
|
||||
)
|
||||
};
|
||||
self.visit_trait(trait_ref)?;
|
||||
if self.def_id_visitor.shallow() {
|
||||
ControlFlow::Continue(())
|
||||
|
@ -66,7 +66,7 @@ fn type_implements_trait(
|
||||
params: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
) -> traits::EvaluationResult {
|
||||
let trait_ref = self.tcx.mk_trait_ref(trait_def_id, params);
|
||||
let trait_ref = ty::TraitRef::new(self.tcx, trait_def_id, params);
|
||||
|
||||
let obligation = traits::Obligation {
|
||||
cause: traits::ObligationCause::dummy(),
|
||||
|
@ -274,8 +274,9 @@ fn consider_builtin_fn_trait_candidates(
|
||||
.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS);
|
||||
}
|
||||
};
|
||||
let output_is_sized_pred = tupled_inputs_and_output
|
||||
.map_bound(|(_, output)| tcx.at(DUMMY_SP).mk_trait_ref(LangItem::Sized, [output]));
|
||||
let output_is_sized_pred = tupled_inputs_and_output.map_bound(|(_, output)| {
|
||||
ty::TraitRef::from_lang_item(tcx.at(DUMMY_SP), LangItem::Sized, [output])
|
||||
});
|
||||
|
||||
let pred = tupled_inputs_and_output
|
||||
.map_bound(|(inputs, output)| ty::ProjectionPredicate {
|
||||
@ -333,7 +334,8 @@ fn consider_builtin_pointee_candidate(
|
||||
|
||||
ty::Alias(_, _) | ty::Param(_) | ty::Placeholder(..) => {
|
||||
// FIXME(ptr_metadata): It would also be possible to return a `Ok(Ambig)` with no constraints.
|
||||
let sized_predicate = ty::Binder::dummy(tcx.at(DUMMY_SP).mk_trait_ref(
|
||||
let sized_predicate = ty::Binder::dummy(ty::TraitRef::from_lang_item(
|
||||
tcx.at(DUMMY_SP),
|
||||
LangItem::Sized,
|
||||
[ty::GenericArg::from(goal.predicate.self_ty())],
|
||||
));
|
||||
|
@ -242,12 +242,13 @@ fn consider_builtin_fn_trait_candidates(
|
||||
.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS);
|
||||
}
|
||||
};
|
||||
let output_is_sized_pred = tupled_inputs_and_output
|
||||
.map_bound(|(_, output)| tcx.at(DUMMY_SP).mk_trait_ref(LangItem::Sized, [output]));
|
||||
let output_is_sized_pred = tupled_inputs_and_output.map_bound(|(_, output)| {
|
||||
ty::TraitRef::from_lang_item(tcx.at(DUMMY_SP), LangItem::Sized, [output])
|
||||
});
|
||||
|
||||
let pred = tupled_inputs_and_output
|
||||
.map_bound(|(inputs, _)| {
|
||||
tcx.mk_trait_ref(goal.predicate.def_id(), [goal.predicate.self_ty(), inputs])
|
||||
ty::TraitRef::new(tcx, goal.predicate.def_id(), [goal.predicate.self_ty(), inputs])
|
||||
})
|
||||
.to_predicate(tcx);
|
||||
// A built-in `Fn` impl only holds if the output is sized.
|
||||
@ -312,9 +313,11 @@ fn consider_builtin_generator_candidate(
|
||||
Self::consider_implied_clause(
|
||||
ecx,
|
||||
goal,
|
||||
ty::Binder::dummy(
|
||||
tcx.mk_trait_ref(goal.predicate.def_id(), [self_ty, generator.resume_ty()]),
|
||||
)
|
||||
ty::Binder::dummy(ty::TraitRef::new(
|
||||
tcx,
|
||||
goal.predicate.def_id(),
|
||||
[self_ty, generator.resume_ty()],
|
||||
))
|
||||
.to_predicate(tcx),
|
||||
// Technically, we need to check that the generator types are Sized,
|
||||
// but that's already proven by the generator being WF.
|
||||
@ -360,9 +363,10 @@ fn consider_builtin_unsize_candidate(
|
||||
data.iter().map(|pred| goal.with(tcx, pred.with_self_ty(tcx, a_ty))),
|
||||
);
|
||||
// The type must be Sized to be unsized.
|
||||
ecx.add_goal(
|
||||
goal.with(tcx, ty::Binder::dummy(tcx.mk_trait_ref(sized_def_id, [a_ty]))),
|
||||
);
|
||||
ecx.add_goal(goal.with(
|
||||
tcx,
|
||||
ty::Binder::dummy(ty::TraitRef::new(tcx, sized_def_id, [a_ty])),
|
||||
));
|
||||
// The type must outlive the lifetime of the `dyn` we're unsizing into.
|
||||
ecx.add_goal(
|
||||
goal.with(tcx, ty::Binder::dummy(ty::OutlivesPredicate(a_ty, region))),
|
||||
@ -411,9 +415,11 @@ fn consider_builtin_unsize_candidate(
|
||||
ecx.eq(goal.param_env, unsized_a_ty, b_ty)?;
|
||||
ecx.add_goal(goal.with(
|
||||
tcx,
|
||||
ty::Binder::dummy(
|
||||
tcx.mk_trait_ref(goal.predicate.def_id(), [a_tail_ty, b_tail_ty]),
|
||||
),
|
||||
ty::Binder::dummy(ty::TraitRef::new(
|
||||
tcx,
|
||||
goal.predicate.def_id(),
|
||||
[a_tail_ty, b_tail_ty],
|
||||
)),
|
||||
));
|
||||
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
|
||||
}
|
||||
@ -432,9 +438,11 @@ fn consider_builtin_unsize_candidate(
|
||||
// Similar to ADTs, require that the rest of the fields are equal.
|
||||
ecx.add_goal(goal.with(
|
||||
tcx,
|
||||
ty::Binder::dummy(
|
||||
tcx.mk_trait_ref(goal.predicate.def_id(), [*a_last_ty, *b_last_ty]),
|
||||
),
|
||||
ty::Binder::dummy(ty::TraitRef::new(
|
||||
tcx,
|
||||
goal.predicate.def_id(),
|
||||
[*a_last_ty, *b_last_ty],
|
||||
)),
|
||||
));
|
||||
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ pub fn find_auto_trait_generics<A>(
|
||||
) -> AutoTraitResult<A> {
|
||||
let tcx = self.tcx;
|
||||
|
||||
let trait_ref = tcx.mk_trait_ref(trait_did, [ty]);
|
||||
let trait_ref = ty::TraitRef::new(tcx, trait_did, [ty]);
|
||||
|
||||
let infcx = tcx.infer_ctxt().build();
|
||||
let mut selcx = SelectionContext::new(&infcx);
|
||||
@ -263,7 +263,7 @@ fn evaluate_predicates(
|
||||
let mut already_visited = FxHashSet::default();
|
||||
let mut predicates = VecDeque::new();
|
||||
predicates.push_back(ty::Binder::dummy(ty::TraitPredicate {
|
||||
trait_ref: infcx.tcx.mk_trait_ref(trait_did, [ty]),
|
||||
trait_ref: ty::TraitRef::new(infcx.tcx, trait_did, [ty]),
|
||||
|
||||
constness: ty::BoundConstness::NotConst,
|
||||
// Auto traits are positive
|
||||
|
@ -97,7 +97,7 @@ pub fn register_bound(
|
||||
def_id: DefId,
|
||||
) {
|
||||
let tcx = self.infcx.tcx;
|
||||
let trait_ref = tcx.mk_trait_ref(def_id, [ty]);
|
||||
let trait_ref = ty::TraitRef::new(tcx, def_id, [ty]);
|
||||
self.register_obligation(Obligation {
|
||||
cause,
|
||||
recursion_depth: 0,
|
||||
|
@ -358,7 +358,7 @@ fn type_implements_fn_trait(
|
||||
span: DUMMY_SP,
|
||||
kind: TypeVariableOriginKind::MiscVariable,
|
||||
});
|
||||
let trait_ref = self.tcx.mk_trait_ref(trait_def_id, [ty.skip_binder(), var]);
|
||||
let trait_ref = ty::TraitRef::new(self.tcx, trait_def_id, [ty.skip_binder(), var]);
|
||||
let obligation = Obligation::new(
|
||||
self.tcx,
|
||||
ObligationCause::dummy(),
|
||||
|
@ -3485,7 +3485,7 @@ fn suggest_derive(
|
||||
_ => None,
|
||||
};
|
||||
let trait_pred = trait_pred.map_bound_ref(|tr| ty::TraitPredicate {
|
||||
trait_ref: self.tcx.mk_trait_ref(
|
||||
trait_ref: ty::TraitRef::new(self.tcx,
|
||||
trait_pred.def_id(),
|
||||
[field_ty].into_iter().chain(trait_substs),
|
||||
),
|
||||
|
@ -127,7 +127,7 @@ pub fn type_known_to_meet_bound_modulo_regions<'tcx>(
|
||||
ty: Ty<'tcx>,
|
||||
def_id: DefId,
|
||||
) -> bool {
|
||||
let trait_ref = ty::Binder::dummy(infcx.tcx.mk_trait_ref(def_id, [ty]));
|
||||
let trait_ref = ty::Binder::dummy(ty::TraitRef::new(infcx.tcx, def_id, [ty]));
|
||||
pred_known_to_hold_modulo_regions(infcx, param_env, trait_ref.without_const())
|
||||
}
|
||||
|
||||
|
@ -769,9 +769,11 @@ fn receiver_is_dispatchable<'tcx>(
|
||||
let param_env = tcx.param_env(method.def_id);
|
||||
|
||||
// Self: Unsize<U>
|
||||
let unsize_predicate = ty::Binder::dummy(
|
||||
tcx.mk_trait_ref(unsize_did, [tcx.types.self_param, unsized_self_ty]),
|
||||
)
|
||||
let unsize_predicate = ty::Binder::dummy(ty::TraitRef::new(
|
||||
tcx,
|
||||
unsize_did,
|
||||
[tcx.types.self_param, unsized_self_ty],
|
||||
))
|
||||
.without_const()
|
||||
.to_predicate(tcx);
|
||||
|
||||
@ -782,7 +784,7 @@ fn receiver_is_dispatchable<'tcx>(
|
||||
if param.index == 0 { unsized_self_ty.into() } else { tcx.mk_param_from_def(param) }
|
||||
});
|
||||
|
||||
ty::Binder::dummy(tcx.mk_trait_ref(trait_def_id, substs)).to_predicate(tcx)
|
||||
ty::Binder::dummy(ty::TraitRef::new(tcx, trait_def_id, substs)).to_predicate(tcx)
|
||||
};
|
||||
|
||||
let caller_bounds =
|
||||
@ -797,9 +799,11 @@ fn receiver_is_dispatchable<'tcx>(
|
||||
|
||||
// Receiver: DispatchFromDyn<Receiver[Self => U]>
|
||||
let obligation = {
|
||||
let predicate = ty::Binder::dummy(
|
||||
tcx.mk_trait_ref(dispatch_from_dyn_did, [receiver_ty, unsized_receiver_ty]),
|
||||
);
|
||||
let predicate = ty::Binder::dummy(ty::TraitRef::new(
|
||||
tcx,
|
||||
dispatch_from_dyn_did,
|
||||
[receiver_ty, unsized_receiver_ty],
|
||||
));
|
||||
|
||||
Obligation::new(tcx, ObligationCause::dummy(), param_env, predicate)
|
||||
};
|
||||
|
@ -1319,7 +1319,7 @@ fn assemble_candidate_for_impl_trait_in_trait<'cx, 'tcx>(
|
||||
let trait_substs =
|
||||
obligation.predicate.substs.truncate_to(tcx, tcx.generics_of(trait_def_id));
|
||||
// FIXME(named-returns): Binders
|
||||
let trait_predicate = ty::Binder::dummy(tcx.mk_trait_ref(trait_def_id, trait_substs));
|
||||
let trait_predicate = ty::Binder::dummy(ty::TraitRef::new(tcx, trait_def_id, trait_substs));
|
||||
|
||||
let _ = selcx.infcx.commit_if_ok(|_| {
|
||||
match selcx.select(&obligation.with(tcx, trait_predicate)) {
|
||||
@ -1683,7 +1683,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
|
||||
&obligation.with(
|
||||
selcx.tcx(),
|
||||
ty::Binder::dummy(
|
||||
selcx.tcx().at(obligation.cause.span()).mk_trait_ref(LangItem::Sized, [self_ty]),
|
||||
ty::TraitRef::from_lang_item(selcx.tcx().at(obligation.cause.span()), LangItem::Sized, [self_ty]),
|
||||
)
|
||||
.without_const(),
|
||||
),
|
||||
@ -1948,9 +1948,11 @@ fn confirm_builtin_candidate<'cx, 'tcx>(
|
||||
)
|
||||
});
|
||||
if check_is_sized {
|
||||
let sized_predicate = ty::Binder::dummy(
|
||||
tcx.at(obligation.cause.span()).mk_trait_ref(LangItem::Sized, [self_ty]),
|
||||
)
|
||||
let sized_predicate = ty::Binder::dummy(ty::TraitRef::from_lang_item(
|
||||
tcx.at(obligation.cause.span()),
|
||||
LangItem::Sized,
|
||||
[self_ty],
|
||||
))
|
||||
.without_const();
|
||||
obligations.push(obligation.with(tcx, sized_predicate));
|
||||
}
|
||||
|
@ -454,7 +454,7 @@ fn reject_fn_ptr_impls(
|
||||
obligation.param_env,
|
||||
self.tcx().mk_predicate(obligation.predicate.map_bound(|mut pred| {
|
||||
pred.trait_ref =
|
||||
self.tcx().mk_trait_ref(fn_ptr_trait, [pred.trait_ref.self_ty()]);
|
||||
ty::TraitRef::new(self.tcx(), fn_ptr_trait, [pred.trait_ref.self_ty()]);
|
||||
ty::PredicateKind::Clause(ty::Clause::Trait(pred))
|
||||
})),
|
||||
);
|
||||
@ -629,7 +629,7 @@ fn need_migrate_deref_output_trait_object(
|
||||
}
|
||||
|
||||
// <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 obligation =
|
||||
traits::Obligation::new(tcx, cause.clone(), param_env, ty::Binder::dummy(trait_ref));
|
||||
|
@ -646,8 +646,11 @@ fn confirm_fn_pointer_candidate(
|
||||
output_ty,
|
||||
&mut nested,
|
||||
);
|
||||
let tr =
|
||||
ty::Binder::dummy(self.tcx().at(cause.span).mk_trait_ref(LangItem::Sized, [output_ty]));
|
||||
let tr = ty::Binder::dummy(ty::TraitRef::from_lang_item(
|
||||
self.tcx().at(cause.span),
|
||||
LangItem::Sized,
|
||||
[output_ty],
|
||||
));
|
||||
nested.push(Obligation::new(self.infcx.tcx, cause, obligation.param_env, tr));
|
||||
|
||||
Ok(ImplSourceFnPointerData { fn_ty: self_ty, nested })
|
||||
@ -1050,8 +1053,11 @@ fn confirm_builtin_unsize_candidate(
|
||||
);
|
||||
|
||||
// We can only make objects from sized types.
|
||||
let tr =
|
||||
ty::Binder::dummy(tcx.at(cause.span).mk_trait_ref(LangItem::Sized, [source]));
|
||||
let tr = ty::Binder::dummy(ty::TraitRef::from_lang_item(
|
||||
tcx.at(cause.span),
|
||||
LangItem::Sized,
|
||||
[source],
|
||||
));
|
||||
nested.push(predicate_to_obligation(tr.without_const().to_predicate(tcx)));
|
||||
|
||||
// If the type is `Foo + 'a`, ensure that the type
|
||||
@ -1121,7 +1127,11 @@ fn confirm_builtin_unsize_candidate(
|
||||
// Construct the nested `TailField<T>: Unsize<TailField<U>>` predicate.
|
||||
let tail_unsize_obligation = obligation.with(
|
||||
tcx,
|
||||
tcx.mk_trait_ref(obligation.predicate.def_id(), [source_tail, target_tail]),
|
||||
ty::TraitRef::new(
|
||||
tcx,
|
||||
obligation.predicate.def_id(),
|
||||
[source_tail, target_tail],
|
||||
),
|
||||
);
|
||||
nested.push(tail_unsize_obligation);
|
||||
}
|
||||
@ -1146,8 +1156,10 @@ fn confirm_builtin_unsize_candidate(
|
||||
nested.extend(obligations);
|
||||
|
||||
// Add a nested `T: Unsize<U>` predicate.
|
||||
let last_unsize_obligation = obligation
|
||||
.with(tcx, tcx.mk_trait_ref(obligation.predicate.def_id(), [a_last, b_last]));
|
||||
let last_unsize_obligation = obligation.with(
|
||||
tcx,
|
||||
ty::TraitRef::new(tcx, obligation.predicate.def_id(), [a_last, b_last]),
|
||||
);
|
||||
nested.push(last_unsize_obligation);
|
||||
}
|
||||
|
||||
@ -1271,10 +1283,11 @@ fn confirm_const_destruct_candidate(
|
||||
cause.clone(),
|
||||
obligation.recursion_depth + 1,
|
||||
self_ty.rebind(ty::TraitPredicate {
|
||||
trait_ref: self
|
||||
.tcx()
|
||||
.at(cause.span)
|
||||
.mk_trait_ref(LangItem::Destruct, [nested_ty]),
|
||||
trait_ref: ty::TraitRef::from_lang_item(
|
||||
self.tcx().at(cause.span),
|
||||
LangItem::Destruct,
|
||||
[nested_ty],
|
||||
),
|
||||
constness: ty::BoundConstness::ConstIfConst,
|
||||
polarity: ty::ImplPolarity::Positive,
|
||||
}),
|
||||
@ -1295,10 +1308,11 @@ fn confirm_const_destruct_candidate(
|
||||
// or it's an ADT (and we need to check for a custom impl during selection)
|
||||
_ => {
|
||||
let predicate = self_ty.rebind(ty::TraitPredicate {
|
||||
trait_ref: self
|
||||
.tcx()
|
||||
.at(cause.span)
|
||||
.mk_trait_ref(LangItem::Destruct, [nested_ty]),
|
||||
trait_ref: ty::TraitRef::from_lang_item(
|
||||
self.tcx().at(cause.span),
|
||||
LangItem::Destruct,
|
||||
[nested_ty],
|
||||
),
|
||||
constness: ty::BoundConstness::ConstIfConst,
|
||||
polarity: ty::ImplPolarity::Positive,
|
||||
});
|
||||
|
@ -2412,7 +2412,7 @@ fn collect_predicates_for_types(
|
||||
self.tcx(),
|
||||
cause.clone(),
|
||||
param_env,
|
||||
self.tcx().mk_trait_ref(trait_def_id, [normalized_ty]),
|
||||
ty::TraitRef::new(self.tcx(), trait_def_id, [normalized_ty]),
|
||||
);
|
||||
obligations.push(obligation);
|
||||
obligations
|
||||
|
@ -262,7 +262,7 @@ pub fn closure_trait_ref_and_return_type<'tcx>(
|
||||
TupleArgumentsFlag::No => sig.skip_binder().inputs()[0],
|
||||
TupleArgumentsFlag::Yes => tcx.mk_tup(sig.skip_binder().inputs()),
|
||||
};
|
||||
let trait_ref = tcx.mk_trait_ref(fn_trait_def_id, [self_ty, arguments_tuple]);
|
||||
let trait_ref = ty::TraitRef::new(tcx, fn_trait_def_id, [self_ty, arguments_tuple]);
|
||||
sig.map_bound(|sig| (trait_ref, sig.output()))
|
||||
}
|
||||
|
||||
@ -273,7 +273,7 @@ pub fn generator_trait_ref_and_outputs<'tcx>(
|
||||
sig: ty::PolyGenSig<'tcx>,
|
||||
) -> ty::Binder<'tcx, (ty::TraitRef<'tcx>, Ty<'tcx>, Ty<'tcx>)> {
|
||||
assert!(!self_ty.has_escaping_bound_vars());
|
||||
let trait_ref = tcx.mk_trait_ref(fn_trait_def_id, [self_ty, sig.skip_binder().resume_ty]);
|
||||
let trait_ref = ty::TraitRef::new(tcx, fn_trait_def_id, [self_ty, sig.skip_binder().resume_ty]);
|
||||
sig.map_bound(|sig| (trait_ref, sig.yield_ty, sig.return_ty))
|
||||
}
|
||||
|
||||
@ -284,7 +284,7 @@ pub fn future_trait_ref_and_outputs<'tcx>(
|
||||
sig: ty::PolyGenSig<'tcx>,
|
||||
) -> ty::Binder<'tcx, (ty::TraitRef<'tcx>, Ty<'tcx>)> {
|
||||
assert!(!self_ty.has_escaping_bound_vars());
|
||||
let trait_ref = tcx.mk_trait_ref(fn_trait_def_id, [self_ty]);
|
||||
let trait_ref = ty::TraitRef::new(tcx, fn_trait_def_id, [self_ty]);
|
||||
sig.map_bound(|sig| (trait_ref, sig.return_ty))
|
||||
}
|
||||
|
||||
|
@ -359,7 +359,7 @@ pub(crate) fn vtable_trait_upcasting_coercion_new_vptr_slot<'tcx>(
|
||||
// this has been typecked-before, so diagnostics is not really needed.
|
||||
let unsize_trait_did = tcx.require_lang_item(LangItem::Unsize, None);
|
||||
|
||||
let trait_ref = tcx.mk_trait_ref(unsize_trait_did, [source, target]);
|
||||
let trait_ref = ty::TraitRef::new(tcx, unsize_trait_did, [source, target]);
|
||||
|
||||
match tcx.codegen_select_candidate((ty::ParamEnv::reveal_all(), ty::Binder::dummy(trait_ref))) {
|
||||
Ok(ImplSource::TraitUpcasting(implsrc_traitcasting)) => {
|
||||
|
@ -448,7 +448,8 @@ fn compute_projection(&mut self, data: ty::AliasTy<'tcx>) {
|
||||
fn require_sized(&mut self, subty: Ty<'tcx>, cause: traits::ObligationCauseCode<'tcx>) {
|
||||
if !subty.has_escaping_bound_vars() {
|
||||
let cause = self.cause(cause);
|
||||
let trait_ref = self.tcx.at(cause.span).mk_trait_ref(LangItem::Sized, [subty]);
|
||||
let trait_ref =
|
||||
ty::TraitRef::from_lang_item(self.tcx.at(cause.span), LangItem::Sized, [subty]);
|
||||
self.out.push(traits::Obligation::with_depth(
|
||||
self.tcx,
|
||||
cause,
|
||||
|
@ -62,7 +62,7 @@ fn sized_constraint_for_ty<'tcx>(
|
||||
// it on the impl.
|
||||
|
||||
let Some(sized_trait) = tcx.lang_items().sized_trait() else { return vec![ty] };
|
||||
let sized_predicate = ty::Binder::dummy(tcx.mk_trait_ref(sized_trait, [ty]))
|
||||
let sized_predicate = ty::Binder::dummy(ty::TraitRef::new(tcx, sized_trait, [ty]))
|
||||
.without_const()
|
||||
.to_predicate(tcx);
|
||||
let predicates = tcx.predicates_of(adtdef.did()).predicates;
|
||||
|
Loading…
Reference in New Issue
Block a user