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

@ -122,7 +122,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 = tcx.mk_trait_ref(tcx.lang_items().deref_trait()?, ty, []);
let cause = traits::ObligationCause::misc(self.span, self.body_id);

View file

@ -86,7 +86,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
) -> AutoTraitResult<A> {
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);
@ -260,7 +260,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
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: infcx.tcx.mk_trait_ref(trait_did, ty, []),
constness: ty::BoundConstness::NotConst,
// Auto traits are positive

View file

@ -93,7 +93,7 @@ impl<'a, 'tcx> ObligationCtxt<'a, 'tcx> {
def_id: DefId,
) {
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 {
cause,
recursion_depth: 0,

View file

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

View file

@ -2985,7 +2985,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
self.tcx.mk_projection(
item_def_id,
// 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(
@ -3068,13 +3068,11 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
// Ensure all fields impl the trait.
adt.all_fields().all(|field| {
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 => {
trait_substs = [field_ty.into()];
&trait_substs
Some(field_ty.into())
}
_ => &[],
_ => None,
};
let trait_pred = trait_pred.map_bound_ref(|tr| ty::TraitPredicate {
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,
span: Span,
) -> 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)
}
@ -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.
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))) {
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(
unsize_did,
tcx.types.self_param,
&[unsized_self_ty.into()],
[unsized_self_ty.into()],
))
.without_const()
.to_predicate(tcx);
@ -724,7 +724,7 @@ fn receiver_is_dispatchable<'tcx>(
let predicate = ty::Binder::dummy(tcx.mk_trait_ref(
dispatch_from_dyn_did,
receiver_ty,
&[unsized_receiver_ty.into()],
[unsized_receiver_ty.into()],
))
.without_const();

View file

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

View file

@ -714,7 +714,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
}
// <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(
tcx,

View file

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

View file

@ -241,7 +241,7 @@ pub fn predicate_for_trait_def<'tcx>(
self_ty: Ty<'tcx>,
params: &[GenericArg<'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)
}
@ -304,7 +304,7 @@ pub fn closure_trait_ref_and_return_type<'tcx>(
TupleArgumentsFlag::Yes => tcx.intern_tup(sig.skip_binder().inputs()),
};
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()))
}
@ -316,7 +316,7 @@ pub fn generator_trait_ref_and_outputs<'tcx>(
) -> ty::Binder<'tcx, (ty::TraitRef<'tcx>, Ty<'tcx>, Ty<'tcx>)> {
debug_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.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))
}

View file

@ -421,11 +421,8 @@ impl<'tcx> WfPredicates<'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.mk_trait_ref(
self.tcx.require_lang_item(LangItem::Sized, None),
subty,
&[],
);
let trait_ref =
self.tcx.mk_trait_ref(self.tcx.require_lang_item(LangItem::Sized, None), subty, []);
self.out.push(traits::Obligation::with_depth(
self.tcx,
cause,