1
Fork 0

Allow iterators instead of requiring slices that will get turned into iterators

This commit is contained in:
Oli Scherer 2022-11-17 13:00:35 +00:00
parent bd40c10751
commit ec8d01fdcc
35 changed files with 69 additions and 68 deletions

View file

@ -550,7 +550,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
let trait_ref = tcx.mk_trait_ref( let trait_ref = tcx.mk_trait_ref(
tcx.require_lang_item(LangItem::Copy, Some(self.last_span)), tcx.require_lang_item(LangItem::Copy, Some(self.last_span)),
place_ty.ty, place_ty.ty,
&[], [],
); );
// To have a `Copy` operand, the type `T` of the // To have a `Copy` operand, the type `T` of the
@ -1277,7 +1277,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
let trait_ref = tcx.mk_trait_ref( let trait_ref = tcx.mk_trait_ref(
tcx.require_lang_item(LangItem::Sized, Some(self.last_span)), tcx.require_lang_item(LangItem::Sized, Some(self.last_span)),
place_ty, place_ty,
&[], [],
); );
self.prove_trait_ref( self.prove_trait_ref(
trait_ref, trait_ref,
@ -1870,7 +1870,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
let trait_ref = tcx.mk_trait_ref( let trait_ref = tcx.mk_trait_ref(
tcx.require_lang_item(LangItem::Copy, Some(span)), tcx.require_lang_item(LangItem::Copy, Some(span)),
ty, ty,
&[], [],
); );
self.prove_trait_ref( self.prove_trait_ref(
@ -1887,7 +1887,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
let trait_ref = tcx.mk_trait_ref( let trait_ref = tcx.mk_trait_ref(
tcx.require_lang_item(LangItem::Sized, Some(self.last_span)), tcx.require_lang_item(LangItem::Sized, Some(self.last_span)),
ty, ty,
&[], [],
); );
self.prove_trait_ref( self.prove_trait_ref(
@ -1903,7 +1903,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
let trait_ref = tcx.mk_trait_ref( let trait_ref = tcx.mk_trait_ref(
tcx.require_lang_item(LangItem::Sized, Some(self.last_span)), tcx.require_lang_item(LangItem::Sized, Some(self.last_span)),
*ty, *ty,
&[], [],
); );
self.prove_trait_ref( self.prove_trait_ref(
@ -2004,7 +2004,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
let trait_ref = tcx.mk_trait_ref( let trait_ref = tcx.mk_trait_ref(
tcx.require_lang_item(LangItem::CoerceUnsized, Some(self.last_span)), tcx.require_lang_item(LangItem::CoerceUnsized, Some(self.last_span)),
op.ty(body, tcx), op.ty(body, tcx),
&[ty.into()], [ty.into()],
); );
self.prove_trait_ref( self.prove_trait_ref(

View file

@ -160,7 +160,7 @@ impl Qualif for NeedsNonConstDrop {
ObligationCause::dummy(), ObligationCause::dummy(),
cx.param_env, cx.param_env,
ty::Binder::dummy(ty::TraitPredicate { ty::Binder::dummy(ty::TraitPredicate {
trait_ref: cx.tcx.mk_trait_ref(destruct, ty, &[]), trait_ref: cx.tcx.mk_trait_ref(destruct, ty, []),
constness: ty::BoundConstness::ConstIfConst, constness: ty::BoundConstness::ConstIfConst,
polarity: ty::ImplPolarity::Positive, polarity: ty::ImplPolarity::Positive,
}), }),

View file

@ -61,7 +61,7 @@ impl<'tcx> Bounds<'tcx> {
// If it could be sized, and is, add the `Sized` predicate. // If it could be sized, and is, add the `Sized` predicate.
let sized_predicate = self.implicitly_sized.and_then(|span| { let sized_predicate = self.implicitly_sized.and_then(|span| {
tcx.lang_items().sized_trait().map(move |sized| { tcx.lang_items().sized_trait().map(move |sized| {
let trait_ref = ty::Binder::dummy(tcx.mk_trait_ref(sized, param_ty, &[])); let trait_ref = ty::Binder::dummy(tcx.mk_trait_ref(sized, param_ty, []));
(trait_ref.without_const().to_predicate(tcx), span) (trait_ref.without_const().to_predicate(tcx), span)
}) })
}); });

View file

@ -1782,7 +1782,7 @@ fn receiver_is_implemented<'tcx>(
receiver_ty: Ty<'tcx>, receiver_ty: Ty<'tcx>,
) -> bool { ) -> bool {
let tcx = wfcx.tcx(); 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(tcx.mk_trait_ref(receiver_trait_def_id, receiver_ty, []));
let obligation = traits::Obligation::new(tcx, cause, wfcx.param_env, trait_ref.without_const()); let obligation = traits::Obligation::new(tcx, cause, wfcx.param_env, trait_ref.without_const());

View file

@ -545,9 +545,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} }
ty::PredicateKind::Projection(mut proj_pred) => { ty::PredicateKind::Projection(mut proj_pred) => {
assert_eq!(proj_pred.projection_ty.self_ty(), opaque_ty); assert_eq!(proj_pred.projection_ty.self_ty(), opaque_ty);
proj_pred.projection_ty.substs = self proj_pred.projection_ty.substs = self.tcx.mk_substs_trait(
.tcx ty,
.mk_substs_trait(ty, &proj_pred.projection_ty.substs[1..]); proj_pred.projection_ty.substs.iter().skip(1),
);
ty::PredicateKind::Projection(proj_pred) ty::PredicateKind::Projection(proj_pred)
} }
_ => continue, _ => continue,

View file

@ -807,7 +807,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
self.param_env, self.param_env,
ty::Binder::dummy(ty::TraitRef::new( ty::Binder::dummy(ty::TraitRef::new(
self.tcx.require_lang_item(hir::LangItem::PointerSized, Some(self.cause.span)), self.tcx.require_lang_item(hir::LangItem::PointerSized, Some(self.cause.span)),
self.tcx.mk_substs_trait(a, &[]), self.tcx.mk_substs_trait(a, []),
)) ))
.to_poly_trait_predicate(), .to_poly_trait_predicate(),
)); ));

View file

@ -1095,7 +1095,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.param_env, self.param_env,
ty::Binder::dummy(self.tcx.mk_trait_ref( ty::Binder::dummy(self.tcx.mk_trait_ref(
into_def_id, into_def_id,
expr_ty, &[expected_ty.into()] expr_ty, [expected_ty.into()]
)) ))
.to_poly_trait_predicate(), .to_poly_trait_predicate(),
)) ))

View file

@ -71,7 +71,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let trait_ref = tcx.mk_trait_ref( let trait_ref = tcx.mk_trait_ref(
fn_once, fn_once,
ty, ty,
&[self [self
.next_ty_var(TypeVariableOrigin { .next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::MiscVariable, kind: TypeVariableOriginKind::MiscVariable,
span, span,

View file

@ -27,7 +27,7 @@ pub trait TraitEngine<'tcx>: 'tcx {
def_id: DefId, def_id: DefId,
cause: ObligationCause<'tcx>, cause: ObligationCause<'tcx>,
) { ) {
let trait_ref = infcx.tcx.mk_trait_ref(def_id, ty, &[]); let trait_ref = infcx.tcx.mk_trait_ref(def_id, ty, []);
self.register_predicate_obligation( self.register_predicate_obligation(
infcx, infcx,
Obligation { Obligation {

View file

@ -131,7 +131,7 @@ impl<'tcx> OverloadedDeref<'tcx> {
.find(|m| m.kind == ty::AssocKind::Fn) .find(|m| m.kind == ty::AssocKind::Fn)
.unwrap() .unwrap()
.def_id; .def_id;
tcx.mk_fn_def(method_def_id, tcx.mk_substs_trait(source, &[])) tcx.mk_fn_def(method_def_id, tcx.mk_substs_trait(source, []))
} }
} }

View file

@ -2809,20 +2809,26 @@ impl<'tcx> TyCtxt<'tcx> {
iter.intern_with(|xs| self.intern_place_elems(xs)) iter.intern_with(|xs| self.intern_place_elems(xs))
} }
pub fn mk_substs_trait(self, self_ty: Ty<'tcx>, rest: &[GenericArg<'tcx>]) -> SubstsRef<'tcx> { pub fn mk_substs_trait(
self.mk_substs(iter::once(self_ty.into()).chain(rest.iter().cloned())) self,
self_ty: Ty<'tcx>,
rest: impl IntoIterator<Item = GenericArg<'tcx>>,
) -> SubstsRef<'tcx> {
self.mk_substs(iter::once(self_ty.into()).chain(rest))
} }
pub fn mk_trait_ref( pub fn mk_trait_ref(
self, self,
trait_def_id: DefId, trait_def_id: DefId,
self_ty: Ty<'tcx>, self_ty: Ty<'tcx>,
rest: &[GenericArg<'tcx>], rest: impl IntoIterator<Item = GenericArg<'tcx>, IntoIter: ExactSizeIterator>,
) -> ty::TraitRef<'tcx> { ) -> ty::TraitRef<'tcx> {
let rest = rest.into_iter();
debug_assert_eq!( debug_assert_eq!(
self.generics_of(trait_def_id).count() - 1, self.generics_of(trait_def_id).count() - 1,
rest.len(), rest.len(),
"wrong number of generic parameters for {trait_def_id:?} on self type {self_ty:?}: {rest:?} \nDid you accidentally include the self-type in the params list?" "wrong number of generic parameters for {trait_def_id:?} on self type {self_ty:?}: {:?} \nDid you accidentally include the self-type in the params list?",
rest.collect::<Vec<_>>(),
); );
let substs = self.mk_substs_trait(self_ty, rest); let substs = self.mk_substs_trait(self_ty, rest);
ty::TraitRef::new(trait_def_id, substs) ty::TraitRef::new(trait_def_id, substs)

View file

@ -551,7 +551,7 @@ impl<'tcx> Instance<'tcx> {
let sig = let sig =
tcx.try_normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), sig).ok()?; tcx.try_normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), sig).ok()?;
assert_eq!(sig.inputs().len(), 1); assert_eq!(sig.inputs().len(), 1);
let substs = tcx.mk_substs_trait(self_ty, &[sig.inputs()[0].into()]); let substs = tcx.mk_substs_trait(self_ty, [sig.inputs()[0].into()]);
debug!(?self_ty, ?sig); debug!(?self_ty, ?sig);
Some(Instance { def, substs }) Some(Instance { def, substs })

View file

@ -719,7 +719,7 @@ impl<'tcx> PolyExistentialPredicate<'tcx> {
self.rebind(p.with_self_ty(tcx, self_ty)).to_predicate(tcx) self.rebind(p.with_self_ty(tcx, self_ty)).to_predicate(tcx)
} }
ExistentialPredicate::AutoTrait(did) => { ExistentialPredicate::AutoTrait(did) => {
let trait_ref = self.rebind(tcx.mk_trait_ref(did, self_ty, &[])); let trait_ref = self.rebind(tcx.mk_trait_ref(did, self_ty, []));
trait_ref.without_const().to_predicate(tcx) trait_ref.without_const().to_predicate(tcx)
} }
} }
@ -812,7 +812,7 @@ impl<'tcx> TraitRef<'tcx> {
} }
pub fn with_self_type(self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> Self { pub fn with_self_type(self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> Self {
tcx.mk_trait_ref(self.def_id, self_ty, &self.substs[1..]) tcx.mk_trait_ref(self.def_id, self_ty, self.substs.iter().skip(1))
} }
/// Returns a `TraitRef` of the form `P0: Foo<P1..Pn>` where `Pi` /// Returns a `TraitRef` of the form `P0: Foo<P1..Pn>` where `Pi`
@ -910,7 +910,7 @@ impl<'tcx> ExistentialTraitRef<'tcx> {
// otherwise the escaping vars would be captured by the binder // otherwise the escaping vars would be captured by the binder
// debug_assert!(!self_ty.has_escaping_bound_vars()); // debug_assert!(!self_ty.has_escaping_bound_vars());
tcx.mk_trait_ref(self.def_id, self_ty, self.substs) tcx.mk_trait_ref(self.def_id, self_ty, self.substs.iter())
} }
} }

View file

@ -840,7 +840,7 @@ fn trait_method<'tcx>(
self_ty: Ty<'tcx>, self_ty: Ty<'tcx>,
params: &[GenericArg<'tcx>], params: &[GenericArg<'tcx>],
) -> ConstantKind<'tcx> { ) -> ConstantKind<'tcx> {
let substs = tcx.mk_substs_trait(self_ty, params); let substs = tcx.mk_substs_trait(self_ty, params.iter().copied());
// The unhygienic comparison here is acceptable because this is only // The unhygienic comparison here is acceptable because this is only
// used on known traits. // used on known traits.

View file

@ -615,7 +615,7 @@ where
let drop_trait = tcx.require_lang_item(LangItem::Drop, None); let drop_trait = tcx.require_lang_item(LangItem::Drop, None);
let drop_fn = tcx.associated_item_def_ids(drop_trait)[0]; let drop_fn = tcx.associated_item_def_ids(drop_trait)[0];
let ty = self.place_ty(self.place); let ty = self.place_ty(self.place);
let substs = tcx.mk_substs_trait(ty, &[]); let substs = tcx.mk_substs_trait(ty, []);
let ref_ty = let ref_ty =
tcx.mk_ref(tcx.lifetimes.re_erased, ty::TypeAndMut { ty, mutbl: hir::Mutability::Mut }); tcx.mk_ref(tcx.lifetimes.re_erased, ty::TypeAndMut { ty, mutbl: hir::Mutability::Mut });

View file

@ -346,7 +346,7 @@ impl<'tcx> CloneShimBuilder<'tcx> {
// we must subst the self_ty because it's // we must subst the self_ty because it's
// otherwise going to be TySelf and we can't index // otherwise going to be TySelf and we can't index
// or access fields of a Place of type TySelf. // or access fields of a Place of type TySelf.
let substs = tcx.mk_substs_trait(self_ty, &[]); let substs = tcx.mk_substs_trait(self_ty, []);
let sig = tcx.bound_fn_sig(def_id).subst(tcx, substs); let sig = tcx.bound_fn_sig(def_id).subst(tcx, substs);
let sig = tcx.erase_late_bound_regions(sig); let sig = tcx.erase_late_bound_regions(sig);
let span = tcx.def_span(def_id); let span = tcx.def_span(def_id);
@ -427,7 +427,7 @@ impl<'tcx> CloneShimBuilder<'tcx> {
) { ) {
let tcx = self.tcx; let tcx = self.tcx;
let substs = tcx.mk_substs_trait(ty, &[]); let substs = tcx.mk_substs_trait(ty, []);
// `func == Clone::clone(&ty) -> ty` // `func == Clone::clone(&ty) -> ty`
let func_ty = tcx.mk_fn_def(self.def_id, substs); let func_ty = tcx.mk_fn_def(self.def_id, substs);
@ -586,7 +586,7 @@ fn build_call_shim<'tcx>(
// Create substitutions for the `Self` and `Args` generic parameters of the shim body. // Create substitutions for the `Self` and `Args` generic parameters of the shim body.
let arg_tup = tcx.mk_tup(untuple_args.iter()); let arg_tup = tcx.mk_tup(untuple_args.iter());
let sig_substs = tcx.mk_substs_trait(ty, &[ty::subst::GenericArg::from(arg_tup)]); let sig_substs = tcx.mk_substs_trait(ty, [ty::subst::GenericArg::from(arg_tup)]);
(Some(sig_substs), Some(untuple_args)) (Some(sig_substs), Some(untuple_args))
} else { } else {

View file

@ -29,7 +29,7 @@ fn custom_coerce_unsize_info<'tcx>(
) -> CustomCoerceUnsized { ) -> CustomCoerceUnsized {
let def_id = tcx.require_lang_item(LangItem::CoerceUnsized, None); let def_id = tcx.require_lang_item(LangItem::CoerceUnsized, None);
let trait_ref = ty::Binder::dummy(tcx.mk_trait_ref(def_id, source_ty, &[target_ty.into()])); let trait_ref = ty::Binder::dummy(tcx.mk_trait_ref(def_id, source_ty, [target_ty.into()]));
match tcx.codegen_select_candidate((ty::ParamEnv::reveal_all(), trait_ref)) { match tcx.codegen_select_candidate((ty::ParamEnv::reveal_all(), trait_ref)) {
Ok(traits::ImplSource::UserDefined(traits::ImplSourceUserDefinedData { Ok(traits::ImplSource::UserDefined(traits::ImplSourceUserDefinedData {

View file

@ -122,7 +122,7 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
let tcx = self.infcx.tcx; let tcx = self.infcx.tcx;
// <ty as Deref> // <ty as Deref>
let trait_ref = tcx.mk_trait_ref(tcx.lang_items().deref_trait()?, ty, &[]); let trait_ref = tcx.mk_trait_ref(tcx.lang_items().deref_trait()?, ty, []);
let cause = traits::ObligationCause::misc(self.span, self.body_id); let cause = traits::ObligationCause::misc(self.span, self.body_id);

View file

@ -86,7 +86,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
) -> AutoTraitResult<A> { ) -> AutoTraitResult<A> {
let tcx = self.tcx; let tcx = self.tcx;
let trait_ref = tcx.mk_trait_ref(trait_did, ty, &[]); let trait_ref = tcx.mk_trait_ref(trait_did, ty, []);
let trait_pred = ty::Binder::dummy(trait_ref); let trait_pred = ty::Binder::dummy(trait_ref);
@ -260,7 +260,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
let mut already_visited = FxHashSet::default(); let mut already_visited = FxHashSet::default();
let mut predicates = VecDeque::new(); let mut predicates = VecDeque::new();
predicates.push_back(ty::Binder::dummy(ty::TraitPredicate { predicates.push_back(ty::Binder::dummy(ty::TraitPredicate {
trait_ref: infcx.tcx.mk_trait_ref(trait_did, ty, &[]), trait_ref: infcx.tcx.mk_trait_ref(trait_did, ty, []),
constness: ty::BoundConstness::NotConst, constness: ty::BoundConstness::NotConst,
// Auto traits are positive // Auto traits are positive

View file

@ -93,7 +93,7 @@ impl<'a, 'tcx> ObligationCtxt<'a, 'tcx> {
def_id: DefId, def_id: DefId,
) { ) {
let tcx = self.infcx.tcx; let tcx = self.infcx.tcx;
let trait_ref = tcx.mk_trait_ref(def_id, ty, &[]); let trait_ref = tcx.mk_trait_ref(def_id, ty, []);
self.register_obligation(Obligation { self.register_obligation(Obligation {
cause, cause,
recursion_depth: 0, recursion_depth: 0,

View file

@ -347,8 +347,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
span: DUMMY_SP, span: DUMMY_SP,
kind: TypeVariableOriginKind::MiscVariable, kind: TypeVariableOriginKind::MiscVariable,
}); });
let trait_ref = let trait_ref = self.tcx.mk_trait_ref(trait_def_id, ty.skip_binder(), [var.into()]);
self.tcx.mk_trait_ref(trait_def_id, ty.skip_binder(), &[var.into()]);
let obligation = Obligation::new( let obligation = Obligation::new(
self.tcx, self.tcx,
ObligationCause::dummy(), ObligationCause::dummy(),

View file

@ -2985,7 +2985,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
self.tcx.mk_projection( self.tcx.mk_projection(
item_def_id, item_def_id,
// Future::Output has no substs // Future::Output has no substs
self.tcx.mk_substs_trait(trait_pred.self_ty(), &[]), self.tcx.mk_substs_trait(trait_pred.self_ty(), []),
) )
}); });
let projection_ty = normalize_to( let projection_ty = normalize_to(
@ -3068,13 +3068,11 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
// Ensure all fields impl the trait. // Ensure all fields impl the trait.
adt.all_fields().all(|field| { adt.all_fields().all(|field| {
let field_ty = field.ty(self.tcx, substs); let field_ty = field.ty(self.tcx, substs);
let trait_substs; let trait_substs = match diagnostic_name {
let trait_substs: &[_] = match diagnostic_name {
sym::PartialEq | sym::PartialOrd => { sym::PartialEq | sym::PartialOrd => {
trait_substs = [field_ty.into()]; Some(field_ty.into())
&trait_substs
} }
_ => &[], _ => None,
}; };
let trait_pred = trait_pred.map_bound_ref(|tr| ty::TraitPredicate { let trait_pred = trait_pred.map_bound_ref(|tr| ty::TraitPredicate {
trait_ref: self.tcx.mk_trait_ref( trait_ref: self.tcx.mk_trait_ref(

View file

@ -143,7 +143,7 @@ pub fn type_known_to_meet_bound_modulo_regions<'tcx>(
def_id: DefId, def_id: DefId,
span: Span, span: Span,
) -> bool { ) -> bool {
let trait_ref = ty::Binder::dummy(infcx.tcx.mk_trait_ref(def_id, ty, &[])); let trait_ref = ty::Binder::dummy(infcx.tcx.mk_trait_ref(def_id, ty, []));
pred_known_to_hold_modulo_regions(infcx, param_env, trait_ref.without_const(), span) pred_known_to_hold_modulo_regions(infcx, param_env, trait_ref.without_const(), span)
} }
@ -902,7 +902,7 @@ pub fn vtable_trait_upcasting_coercion_new_vptr_slot<'tcx>(
// this has been typecked-before, so diagnostics is not really needed. // this has been typecked-before, so diagnostics is not really needed.
let unsize_trait_did = tcx.require_lang_item(LangItem::Unsize, None); let unsize_trait_did = tcx.require_lang_item(LangItem::Unsize, None);
let trait_ref = tcx.mk_trait_ref(unsize_trait_did, source, &[target.into()]); let trait_ref = tcx.mk_trait_ref(unsize_trait_did, source, [target.into()]);
match tcx.codegen_select_candidate((ty::ParamEnv::reveal_all(), ty::Binder::dummy(trait_ref))) { match tcx.codegen_select_candidate((ty::ParamEnv::reveal_all(), ty::Binder::dummy(trait_ref))) {
Ok(ImplSource::TraitUpcasting(implsrc_traitcasting)) => { Ok(ImplSource::TraitUpcasting(implsrc_traitcasting)) => {

View file

@ -688,7 +688,7 @@ fn receiver_is_dispatchable<'tcx>(
let unsize_predicate = ty::Binder::dummy(tcx.mk_trait_ref( let unsize_predicate = ty::Binder::dummy(tcx.mk_trait_ref(
unsize_did, unsize_did,
tcx.types.self_param, tcx.types.self_param,
&[unsized_self_ty.into()], [unsized_self_ty.into()],
)) ))
.without_const() .without_const()
.to_predicate(tcx); .to_predicate(tcx);
@ -724,7 +724,7 @@ fn receiver_is_dispatchable<'tcx>(
let predicate = ty::Binder::dummy(tcx.mk_trait_ref( let predicate = ty::Binder::dummy(tcx.mk_trait_ref(
dispatch_from_dyn_did, dispatch_from_dyn_did,
receiver_ty, receiver_ty,
&[unsized_receiver_ty.into()], [unsized_receiver_ty.into()],
)) ))
.without_const(); .without_const();

View file

@ -1712,7 +1712,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
selcx.tcx(), selcx.tcx(),
ty::Binder::dummy(selcx.tcx().mk_trait_ref( ty::Binder::dummy(selcx.tcx().mk_trait_ref(
selcx.tcx().require_lang_item(LangItem::Sized, None), selcx.tcx().require_lang_item(LangItem::Sized, None),
self_ty, &[], self_ty, [],
)) ))
.without_const(), .without_const(),
), ),
@ -1969,7 +1969,7 @@ fn confirm_pointee_candidate<'cx, 'tcx>(
let sized_predicate = ty::Binder::dummy(tcx.mk_trait_ref( let sized_predicate = ty::Binder::dummy(tcx.mk_trait_ref(
tcx.require_lang_item(LangItem::Sized, None), tcx.require_lang_item(LangItem::Sized, None),
self_ty, self_ty,
&[], [],
)) ))
.without_const(); .without_const();
obligations.push(obligation.with(tcx, sized_predicate)); obligations.push(obligation.with(tcx, sized_predicate));

View file

@ -714,7 +714,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
} }
// <ty as Deref> // <ty as Deref>
let trait_ref = tcx.mk_trait_ref(tcx.lang_items().deref_trait()?, ty, &[]); let trait_ref = tcx.mk_trait_ref(tcx.lang_items().deref_trait()?, ty, []);
let obligation = traits::Obligation::new( let obligation = traits::Obligation::new(
tcx, tcx,

View file

@ -635,7 +635,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let tr = ty::Binder::dummy(self.tcx().mk_trait_ref( let tr = ty::Binder::dummy(self.tcx().mk_trait_ref(
self.tcx().require_lang_item(LangItem::Sized, None), self.tcx().require_lang_item(LangItem::Sized, None),
output_ty, output_ty,
&[], [],
)); ));
nested.push(Obligation::new( nested.push(Obligation::new(
self.infcx.tcx, self.infcx.tcx,
@ -1000,7 +1000,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let tr = ty::Binder::dummy(tcx.mk_trait_ref( let tr = ty::Binder::dummy(tcx.mk_trait_ref(
tcx.require_lang_item(LangItem::Sized, None), tcx.require_lang_item(LangItem::Sized, None),
source, source,
&[], [],
)); ));
nested.push(predicate_to_obligation(tr.without_const().to_predicate(tcx))); nested.push(predicate_to_obligation(tr.without_const().to_predicate(tcx)));
@ -1258,7 +1258,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
trait_ref: self.tcx().mk_trait_ref( trait_ref: self.tcx().mk_trait_ref(
self.tcx().require_lang_item(LangItem::Destruct, None), self.tcx().require_lang_item(LangItem::Destruct, None),
nested_ty, nested_ty,
&[], [],
), ),
constness: ty::BoundConstness::ConstIfConst, constness: ty::BoundConstness::ConstIfConst,
polarity: ty::ImplPolarity::Positive, polarity: ty::ImplPolarity::Positive,
@ -1283,7 +1283,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
trait_ref: self.tcx().mk_trait_ref( trait_ref: self.tcx().mk_trait_ref(
self.tcx().require_lang_item(LangItem::Destruct, None), self.tcx().require_lang_item(LangItem::Destruct, None),
nested_ty, nested_ty,
&[], [],
), ),
constness: ty::BoundConstness::ConstIfConst, constness: ty::BoundConstness::ConstIfConst,
polarity: ty::ImplPolarity::Positive, polarity: ty::ImplPolarity::Positive,

View file

@ -241,7 +241,7 @@ pub fn predicate_for_trait_def<'tcx>(
self_ty: Ty<'tcx>, self_ty: Ty<'tcx>,
params: &[GenericArg<'tcx>], params: &[GenericArg<'tcx>],
) -> PredicateObligation<'tcx> { ) -> PredicateObligation<'tcx> {
let trait_ref = tcx.mk_trait_ref(trait_def_id, self_ty, params); let trait_ref = tcx.mk_trait_ref(trait_def_id, self_ty, params.iter().copied());
predicate_for_trait_ref(tcx, cause, param_env, trait_ref, recursion_depth) predicate_for_trait_ref(tcx, cause, param_env, trait_ref, recursion_depth)
} }
@ -304,7 +304,7 @@ pub fn closure_trait_ref_and_return_type<'tcx>(
TupleArgumentsFlag::Yes => tcx.intern_tup(sig.skip_binder().inputs()), TupleArgumentsFlag::Yes => tcx.intern_tup(sig.skip_binder().inputs()),
}; };
debug_assert!(!self_ty.has_escaping_bound_vars()); debug_assert!(!self_ty.has_escaping_bound_vars());
let trait_ref = tcx.mk_trait_ref(fn_trait_def_id, self_ty, &[arguments_tuple.into()]); let trait_ref = tcx.mk_trait_ref(fn_trait_def_id, self_ty, [arguments_tuple.into()]);
sig.map_bound(|sig| (trait_ref, sig.output())) sig.map_bound(|sig| (trait_ref, sig.output()))
} }
@ -316,7 +316,7 @@ pub fn generator_trait_ref_and_outputs<'tcx>(
) -> ty::Binder<'tcx, (ty::TraitRef<'tcx>, Ty<'tcx>, Ty<'tcx>)> { ) -> ty::Binder<'tcx, (ty::TraitRef<'tcx>, Ty<'tcx>, Ty<'tcx>)> {
debug_assert!(!self_ty.has_escaping_bound_vars()); debug_assert!(!self_ty.has_escaping_bound_vars());
let trait_ref = let trait_ref =
tcx.mk_trait_ref(fn_trait_def_id, self_ty, &[sig.skip_binder().resume_ty.into()]); tcx.mk_trait_ref(fn_trait_def_id, self_ty, [sig.skip_binder().resume_ty.into()]);
sig.map_bound(|sig| (trait_ref, sig.yield_ty, sig.return_ty)) sig.map_bound(|sig| (trait_ref, sig.yield_ty, sig.return_ty))
} }

View file

@ -421,11 +421,8 @@ impl<'tcx> WfPredicates<'tcx> {
fn require_sized(&mut self, subty: Ty<'tcx>, cause: traits::ObligationCauseCode<'tcx>) { fn require_sized(&mut self, subty: Ty<'tcx>, cause: traits::ObligationCauseCode<'tcx>) {
if !subty.has_escaping_bound_vars() { if !subty.has_escaping_bound_vars() {
let cause = self.cause(cause); let cause = self.cause(cause);
let trait_ref = self.tcx.mk_trait_ref( let trait_ref =
self.tcx.require_lang_item(LangItem::Sized, None), self.tcx.mk_trait_ref(self.tcx.require_lang_item(LangItem::Sized, None), subty, []);
subty,
&[],
);
self.out.push(traits::Obligation::with_depth( self.out.push(traits::Obligation::with_depth(
self.tcx, self.tcx,
cause, cause,

View file

@ -689,7 +689,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Binders<chalk_ir::QuantifiedWhereClauses<Ru
trait_id: chalk_ir::TraitId(def_id), trait_id: chalk_ir::TraitId(def_id),
substitution: interner substitution: interner
.tcx .tcx
.mk_substs_trait(self_ty, &[]) .mk_substs_trait(self_ty, [])
.lower_into(interner), .lower_into(interner),
}), }),
), ),

View file

@ -49,7 +49,7 @@ fn sized_constraint_for_ty<'tcx>(
// it on the impl. // it on the impl.
let Some(sized_trait) = tcx.lang_items().sized_trait() else { return vec![ty] }; 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(tcx.mk_trait_ref(sized_trait, ty, []))
.without_const() .without_const()
.to_predicate(tcx); .to_predicate(tcx);
let predicates = tcx.predicates_of(adtdef.did()).predicates; let predicates = tcx.predicates_of(adtdef.did()).predicates;

View file

@ -44,7 +44,7 @@ where
discard_positive_impl: bool, discard_positive_impl: bool,
) -> Option<Item> { ) -> Option<Item> {
let tcx = self.cx.tcx; let tcx = self.cx.tcx;
let trait_ref = tcx.mk_trait_ref(trait_def_id, ty, &[]); let trait_ref = tcx.mk_trait_ref(trait_def_id, ty, []);
if !self.cx.generated_synthetics.insert((ty, trait_def_id)) { if !self.cx.generated_synthetics.insert((ty, trait_def_id)) {
debug!("get_auto_trait_impl_for({:?}): already generated, aborting", trait_ref); debug!("get_auto_trait_impl_for({:?}): already generated, aborting", trait_ref);
return None; return None;

View file

@ -59,7 +59,7 @@ fn is_impl_not_trait_with_bool_out(cx: &LateContext<'_>, e: &Expr<'_>) -> bool {
) )
}) })
.map_or(false, |assoc_item| { .map_or(false, |assoc_item| {
let proj = cx.tcx.mk_projection(assoc_item.def_id, cx.tcx.mk_substs_trait(ty, &[])); let proj = cx.tcx.mk_projection(assoc_item.def_id, cx.tcx.mk_substs_trait(ty, []));
let nty = cx.tcx.normalize_erasing_regions(cx.param_env, proj); let nty = cx.tcx.normalize_erasing_regions(cx.param_env, proj);
nty.is_bool() nty.is_bool()

View file

@ -1263,7 +1263,7 @@ fn replace_types<'tcx>(
let item_def_id = projection_predicate.projection_ty.item_def_id; let item_def_id = projection_predicate.projection_ty.item_def_id;
let assoc_item = cx.tcx.associated_item(item_def_id); let assoc_item = cx.tcx.associated_item(item_def_id);
let projection = cx.tcx let projection = cx.tcx
.mk_projection(assoc_item.def_id, cx.tcx.mk_substs_trait(new_ty, &[])); .mk_projection(assoc_item.def_id, cx.tcx.mk_substs_trait(new_ty, []));
if let Ok(projected_ty) = cx.tcx.try_normalize_erasing_regions(cx.param_env, projection) if let Ok(projected_ty) = cx.tcx.try_normalize_erasing_regions(cx.param_env, projection)
&& substs[term_param_ty.index as usize] != ty::GenericArg::from(projected_ty) && substs[term_param_ty.index as usize] != ty::GenericArg::from(projected_ty)

View file

@ -79,7 +79,7 @@ pub fn get_associated_type<'tcx>(
.associated_items(trait_id) .associated_items(trait_id)
.find_by_name_and_kind(cx.tcx, Ident::from_str(name), ty::AssocKind::Type, trait_id) .find_by_name_and_kind(cx.tcx, Ident::from_str(name), ty::AssocKind::Type, trait_id)
.and_then(|assoc| { .and_then(|assoc| {
let proj = cx.tcx.mk_projection(assoc.def_id, cx.tcx.mk_substs_trait(ty, &[])); let proj = cx.tcx.mk_projection(assoc.def_id, cx.tcx.mk_substs_trait(ty, []));
cx.tcx.try_normalize_erasing_regions(cx.param_env, proj).ok() cx.tcx.try_normalize_erasing_regions(cx.param_env, proj).ok()
}) })
} }