diff options
35 files changed, 69 insertions, 68 deletions
diff --git a/compiler/rustc_borrowck/src/type_check/mod.rs b/compiler/rustc_borrowck/src/type_check/mod.rs index e63c0699d40..750d57b9c8c 100644 --- a/compiler/rustc_borrowck/src/type_check/mod.rs +++ b/compiler/rustc_borrowck/src/type_check/mod.rs @@ -550,7 +550,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> { let trait_ref = tcx.mk_trait_ref( tcx.require_lang_item(LangItem::Copy, Some(self.last_span)), place_ty.ty, - &[], + [], ); // 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( tcx.require_lang_item(LangItem::Sized, Some(self.last_span)), place_ty, - &[], + [], ); self.prove_trait_ref( trait_ref, @@ -1870,7 +1870,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { let trait_ref = tcx.mk_trait_ref( tcx.require_lang_item(LangItem::Copy, Some(span)), ty, - &[], + [], ); self.prove_trait_ref( @@ -1887,7 +1887,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { let trait_ref = tcx.mk_trait_ref( tcx.require_lang_item(LangItem::Sized, Some(self.last_span)), ty, - &[], + [], ); self.prove_trait_ref( @@ -1903,7 +1903,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { let trait_ref = tcx.mk_trait_ref( tcx.require_lang_item(LangItem::Sized, Some(self.last_span)), *ty, - &[], + [], ); self.prove_trait_ref( @@ -2004,7 +2004,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { let trait_ref = tcx.mk_trait_ref( tcx.require_lang_item(LangItem::CoerceUnsized, Some(self.last_span)), op.ty(body, tcx), - &[ty.into()], + [ty.into()], ); self.prove_trait_ref( diff --git a/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs b/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs index 8c43f93a917..4f1878a3f25 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs @@ -160,7 +160,7 @@ impl Qualif for NeedsNonConstDrop { ObligationCause::dummy(), cx.param_env, 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, polarity: ty::ImplPolarity::Positive, }), diff --git a/compiler/rustc_hir_analysis/src/bounds.rs b/compiler/rustc_hir_analysis/src/bounds.rs index 9944114f495..17cdbdb70fb 100644 --- a/compiler/rustc_hir_analysis/src/bounds.rs +++ b/compiler/rustc_hir_analysis/src/bounds.rs @@ -61,7 +61,7 @@ impl<'tcx> Bounds<'tcx> { // If it could be sized, and is, add the `Sized` predicate. let sized_predicate = self.implicitly_sized.and_then(|span| { 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) }) }); diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index 3246397d82f..1538d0a1bbb 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -1782,7 +1782,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(tcx.mk_trait_ref(receiver_trait_def_id, receiver_ty, [])); let obligation = traits::Obligation::new(tcx, cause, wfcx.param_env, trait_ref.without_const()); diff --git a/compiler/rustc_hir_typeck/src/_match.rs b/compiler/rustc_hir_typeck/src/_match.rs index 7d081bac3bd..31432bb6e41 100644 --- a/compiler/rustc_hir_typeck/src/_match.rs +++ b/compiler/rustc_hir_typeck/src/_match.rs @@ -545,9 +545,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } ty::PredicateKind::Projection(mut proj_pred) => { assert_eq!(proj_pred.projection_ty.self_ty(), opaque_ty); - proj_pred.projection_ty.substs = self - .tcx - .mk_substs_trait(ty, &proj_pred.projection_ty.substs[1..]); + proj_pred.projection_ty.substs = self.tcx.mk_substs_trait( + ty, + proj_pred.projection_ty.substs.iter().skip(1), + ); ty::PredicateKind::Projection(proj_pred) } _ => continue, diff --git a/compiler/rustc_hir_typeck/src/coercion.rs b/compiler/rustc_hir_typeck/src/coercion.rs index cf3b37f0a25..12cbc743bf9 100644 --- a/compiler/rustc_hir_typeck/src/coercion.rs +++ b/compiler/rustc_hir_typeck/src/coercion.rs @@ -807,7 +807,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { self.param_env, ty::Binder::dummy(ty::TraitRef::new( 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(), )); diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs index 2c5a88225e9..fcef6f32e10 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs @@ -1095,7 +1095,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.param_env, ty::Binder::dummy(self.tcx.mk_trait_ref( into_def_id, - expr_ty, &[expected_ty.into()] + expr_ty, [expected_ty.into()] )) .to_poly_trait_predicate(), )) diff --git a/compiler/rustc_hir_typeck/src/method/suggest.rs b/compiler/rustc_hir_typeck/src/method/suggest.rs index b55e3a114d3..6b228377ed0 100644 --- a/compiler/rustc_hir_typeck/src/method/suggest.rs +++ b/compiler/rustc_hir_typeck/src/method/suggest.rs @@ -71,7 +71,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let trait_ref = tcx.mk_trait_ref( fn_once, ty, - &[self + [self .next_ty_var(TypeVariableOrigin { kind: TypeVariableOriginKind::MiscVariable, span, diff --git a/compiler/rustc_infer/src/traits/engine.rs b/compiler/rustc_infer/src/traits/engine.rs index d26f0cf3851..a25929330f8 100644 --- a/compiler/rustc_infer/src/traits/engine.rs +++ b/compiler/rustc_infer/src/traits/engine.rs @@ -27,7 +27,7 @@ pub trait TraitEngine<'tcx>: 'tcx { def_id: DefId, 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( infcx, Obligation { diff --git a/compiler/rustc_middle/src/ty/adjustment.rs b/compiler/rustc_middle/src/ty/adjustment.rs index 458cbfa6e35..b8e6f0258d0 100644 --- a/compiler/rustc_middle/src/ty/adjustment.rs +++ b/compiler/rustc_middle/src/ty/adjustment.rs @@ -131,7 +131,7 @@ impl<'tcx> OverloadedDeref<'tcx> { .find(|m| m.kind == ty::AssocKind::Fn) .unwrap() .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, [])) } } diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index cf0d201cbb7..c43447ae05d 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -2809,20 +2809,26 @@ impl<'tcx> TyCtxt<'tcx> { iter.intern_with(|xs| self.intern_place_elems(xs)) } - pub fn mk_substs_trait(self, self_ty: Ty<'tcx>, rest: &[GenericArg<'tcx>]) -> SubstsRef<'tcx> { - self.mk_substs(iter::once(self_ty.into()).chain(rest.iter().cloned())) + pub fn mk_substs_trait( + 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( self, trait_def_id: DefId, self_ty: Ty<'tcx>, - rest: &[GenericArg<'tcx>], + rest: impl IntoIterator<Item = GenericArg<'tcx>, IntoIter: ExactSizeIterator>, ) -> ty::TraitRef<'tcx> { + let rest = rest.into_iter(); debug_assert_eq!( self.generics_of(trait_def_id).count() - 1, 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); ty::TraitRef::new(trait_def_id, substs) diff --git a/compiler/rustc_middle/src/ty/instance.rs b/compiler/rustc_middle/src/ty/instance.rs index a792d2694b3..586460986dd 100644 --- a/compiler/rustc_middle/src/ty/instance.rs +++ b/compiler/rustc_middle/src/ty/instance.rs @@ -551,7 +551,7 @@ impl<'tcx> Instance<'tcx> { let sig = tcx.try_normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), sig).ok()?; 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); Some(Instance { def, substs }) diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 47cdabb5f81..35ab8b2af6b 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -719,7 +719,7 @@ impl<'tcx> PolyExistentialPredicate<'tcx> { self.rebind(p.with_self_ty(tcx, self_ty)).to_predicate(tcx) } 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) } } @@ -812,7 +812,7 @@ impl<'tcx> TraitRef<'tcx> { } 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` @@ -910,7 +910,7 @@ impl<'tcx> ExistentialTraitRef<'tcx> { // 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, self.substs) + tcx.mk_trait_ref(self.def_id, self_ty, self.substs.iter()) } } diff --git a/compiler/rustc_mir_build/src/build/matches/test.rs b/compiler/rustc_mir_build/src/build/matches/test.rs index af0d7879c57..0a6a8859d2f 100644 --- a/compiler/rustc_mir_build/src/build/matches/test.rs +++ b/compiler/rustc_mir_build/src/build/matches/test.rs @@ -840,7 +840,7 @@ fn trait_method<'tcx>( self_ty: Ty<'tcx>, params: &[GenericArg<'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 // used on known traits. diff --git a/compiler/rustc_mir_dataflow/src/elaborate_drops.rs b/compiler/rustc_mir_dataflow/src/elaborate_drops.rs index 14d265a402e..ce87a1916b4 100644 --- a/compiler/rustc_mir_dataflow/src/elaborate_drops.rs +++ b/compiler/rustc_mir_dataflow/src/elaborate_drops.rs @@ -615,7 +615,7 @@ where let drop_trait = tcx.require_lang_item(LangItem::Drop, None); let drop_fn = tcx.associated_item_def_ids(drop_trait)[0]; let ty = self.place_ty(self.place); - let substs = tcx.mk_substs_trait(ty, &[]); + let substs = tcx.mk_substs_trait(ty, []); let ref_ty = tcx.mk_ref(tcx.lifetimes.re_erased, ty::TypeAndMut { ty, mutbl: hir::Mutability::Mut }); diff --git a/compiler/rustc_mir_transform/src/shim.rs b/compiler/rustc_mir_transform/src/shim.rs index a0ff7550fae..68703eb0a23 100644 --- a/compiler/rustc_mir_transform/src/shim.rs +++ b/compiler/rustc_mir_transform/src/shim.rs @@ -346,7 +346,7 @@ impl<'tcx> CloneShimBuilder<'tcx> { // we must subst the self_ty because it's // otherwise going to be TySelf and we can't index // 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.erase_late_bound_regions(sig); let span = tcx.def_span(def_id); @@ -427,7 +427,7 @@ impl<'tcx> CloneShimBuilder<'tcx> { ) { let tcx = self.tcx; - let substs = tcx.mk_substs_trait(ty, &[]); + let substs = tcx.mk_substs_trait(ty, []); // `func == Clone::clone(&ty) -> ty` 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. 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)) } else { diff --git a/compiler/rustc_monomorphize/src/lib.rs b/compiler/rustc_monomorphize/src/lib.rs index 669599a424a..8eb489bb596 100644 --- a/compiler/rustc_monomorphize/src/lib.rs +++ b/compiler/rustc_monomorphize/src/lib.rs @@ -29,7 +29,7 @@ fn custom_coerce_unsize_info<'tcx>( ) -> CustomCoerceUnsized { 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)) { Ok(traits::ImplSource::UserDefined(traits::ImplSourceUserDefinedData { diff --git a/compiler/rustc_trait_selection/src/autoderef.rs b/compiler/rustc_trait_selection/src/autoderef.rs index adef967b0a1..415bd8de145 100644 --- a/compiler/rustc_trait_selection/src/autoderef.rs +++ b/compiler/rustc_trait_selection/src/autoderef.rs @@ -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); 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, diff --git a/compiler/rustc_traits/src/chalk/lowering.rs b/compiler/rustc_traits/src/chalk/lowering.rs index 36bd466496e..06a42a95d60 100644 --- a/compiler/rustc_traits/src/chalk/lowering.rs +++ b/compiler/rustc_traits/src/chalk/lowering.rs @@ -689,7 +689,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Binders<chalk_ir::QuantifiedWhereClauses<Ru trait_id: chalk_ir::TraitId(def_id), substitution: interner .tcx - .mk_substs_trait(self_ty, &[]) + .mk_substs_trait(self_ty, []) .lower_into(interner), }), ), diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index e88d39cd271..26db9768206 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -49,7 +49,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(tcx.mk_trait_ref(sized_trait, ty, [])) .without_const() .to_predicate(tcx); let predicates = tcx.predicates_of(adtdef.did()).predicates; diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs index 03ac2f14f7a..bd55517311d 100644 --- a/src/librustdoc/clean/auto_trait.rs +++ b/src/librustdoc/clean/auto_trait.rs @@ -44,7 +44,7 @@ where discard_positive_impl: bool, ) -> Option<Item> { 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)) { debug!("get_auto_trait_impl_for({:?}): already generated, aborting", trait_ref); return None; diff --git a/src/tools/clippy/clippy_lints/src/bool_assert_comparison.rs b/src/tools/clippy/clippy_lints/src/bool_assert_comparison.rs index 4bd55c1429c..82d368bb8bc 100644 --- a/src/tools/clippy/clippy_lints/src/bool_assert_comparison.rs +++ b/src/tools/clippy/clippy_lints/src/bool_assert_comparison.rs @@ -59,7 +59,7 @@ fn is_impl_not_trait_with_bool_out(cx: &LateContext<'_>, e: &Expr<'_>) -> bool { ) }) .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); nty.is_bool() diff --git a/src/tools/clippy/clippy_lints/src/dereference.rs b/src/tools/clippy/clippy_lints/src/dereference.rs index 218dbeaddca..03d865af374 100644 --- a/src/tools/clippy/clippy_lints/src/dereference.rs +++ b/src/tools/clippy/clippy_lints/src/dereference.rs @@ -1263,7 +1263,7 @@ fn replace_types<'tcx>( let item_def_id = projection_predicate.projection_ty.item_def_id; let assoc_item = cx.tcx.associated_item(item_def_id); 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) && substs[term_param_ty.index as usize] != ty::GenericArg::from(projected_ty) diff --git a/src/tools/clippy/clippy_utils/src/ty.rs b/src/tools/clippy/clippy_utils/src/ty.rs index 3a144c2bb22..a1698a61e60 100644 --- a/src/tools/clippy/clippy_utils/src/ty.rs +++ b/src/tools/clippy/clippy_utils/src/ty.rs @@ -79,7 +79,7 @@ pub fn get_associated_type<'tcx>( .associated_items(trait_id) .find_by_name_and_kind(cx.tcx, Ident::from_str(name), ty::AssocKind::Type, trait_id) .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() }) } |
