diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-11-17 11:21:39 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-11-21 20:31:59 +0000 |
| commit | 6f77c97b386f05083f039f0130146addf99eefd9 (patch) | |
| tree | 4bebb22479b94e1134ee458f5f45efaea839ca26 /compiler/rustc_trait_selection/src/traits/util.rs | |
| parent | d9a02b0fb728ac994883845b1c53630c2dec4657 (diff) | |
| download | rust-6f77c97b386f05083f039f0130146addf99eefd9.tar.gz rust-6f77c97b386f05083f039f0130146addf99eefd9.zip | |
Assert that various types have the right amount of generic args and fix the sites that used the wrong amount
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits/util.rs')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/util.rs | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/util.rs b/compiler/rustc_trait_selection/src/traits/util.rs index ed47d2f83df..21c79461eda 100644 --- a/compiler/rustc_trait_selection/src/traits/util.rs +++ b/compiler/rustc_trait_selection/src/traits/util.rs @@ -241,8 +241,7 @@ pub fn predicate_for_trait_def<'tcx>( self_ty: Ty<'tcx>, params: &[GenericArg<'tcx>], ) -> PredicateObligation<'tcx> { - let trait_ref = - ty::TraitRef { def_id: trait_def_id, substs: tcx.mk_substs_trait(self_ty, params) }; + let trait_ref = tcx.mk_trait_ref(trait_def_id, self_ty, params); predicate_for_trait_ref(tcx, cause, param_env, trait_ref, recursion_depth) } @@ -305,10 +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 = ty::TraitRef { - def_id: fn_trait_def_id, - substs: tcx.mk_substs_trait(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())) } @@ -319,10 +315,8 @@ pub fn generator_trait_ref_and_outputs<'tcx>( sig: ty::PolyGenSig<'tcx>, ) -> ty::Binder<'tcx, (ty::TraitRef<'tcx>, Ty<'tcx>, Ty<'tcx>)> { debug_assert!(!self_ty.has_escaping_bound_vars()); - let trait_ref = ty::TraitRef { - def_id: fn_trait_def_id, - substs: tcx.mk_substs_trait(self_ty, &[sig.skip_binder().resume_ty.into()]), - }; + let trait_ref = + 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)) } |
