diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-11-17 13:00:35 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-11-21 20:33:55 +0000 |
| commit | ec8d01fdccbe68d9a2ad6f2c2fbe000a9a6da530 (patch) | |
| tree | 1c7aced8f51ff8c698b9218529b5bfc168c1159f /compiler/rustc_trait_selection/src/traits | |
| parent | bd40c10751baf6c0c5fc52c99900c0b9066ed11b (diff) | |
| download | rust-ec8d01fdccbe68d9a2ad6f2c2fbe000a9a6da530.tar.gz rust-ec8d01fdccbe68d9a2ad6f2c2fbe000a9a6da530.zip | |
Allow iterators instead of requiring slices that will get turned into iterators
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits')
11 files changed, 24 insertions, 30 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/auto_trait.rs b/compiler/rustc_trait_selection/src/traits/auto_trait.rs index 3dab34747f7..c7dc7b1049c 100644 --- a/compiler/rustc_trait_selection/src/traits/auto_trait.rs +++ b/compiler/rustc_trait_selection/src/traits/auto_trait.rs @@ -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 diff --git a/compiler/rustc_trait_selection/src/traits/engine.rs b/compiler/rustc_trait_selection/src/traits/engine.rs index 97f4f7d795d..09c2449bdae 100644 --- a/compiler/rustc_trait_selection/src/traits/engine.rs +++ b/compiler/rustc_trait_selection/src/traits/engine.rs @@ -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, diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index cb9902bed54..3d0f87942c3 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -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(), diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 445b5696d20..4b6d8177381 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -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( diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index 227a7f0a112..7eb21e156fd 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -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)) => { diff --git a/compiler/rustc_trait_selection/src/traits/object_safety.rs b/compiler/rustc_trait_selection/src/traits/object_safety.rs index 20826f2c541..29b315bff16 100644 --- a/compiler/rustc_trait_selection/src/traits/object_safety.rs +++ b/compiler/rustc_trait_selection/src/traits/object_safety.rs @@ -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(); diff --git a/compiler/rustc_trait_selection/src/traits/project.rs b/compiler/rustc_trait_selection/src/traits/project.rs index e1b30112e39..b8fe4c86405 100644 --- a/compiler/rustc_trait_selection/src/traits/project.rs +++ b/compiler/rustc_trait_selection/src/traits/project.rs @@ -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)); diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs index 6b19b9297c5..b11f2c8e6a4 100644 --- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs +++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs @@ -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, diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index 6d737b455bf..5c3a132bb5c 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -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, diff --git a/compiler/rustc_trait_selection/src/traits/util.rs b/compiler/rustc_trait_selection/src/traits/util.rs index 21c79461eda..41798e00caa 100644 --- a/compiler/rustc_trait_selection/src/traits/util.rs +++ b/compiler/rustc_trait_selection/src/traits/util.rs @@ -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)) } diff --git a/compiler/rustc_trait_selection/src/traits/wf.rs b/compiler/rustc_trait_selection/src/traits/wf.rs index 3fe019cb7de..378e6738795 100644 --- a/compiler/rustc_trait_selection/src/traits/wf.rs +++ b/compiler/rustc_trait_selection/src/traits/wf.rs @@ -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, |
