Skip to content

Commit 1727172

Browse files
oli-obkfee1-dead
authored andcommitted
Remove the helper-methods for mk_substs_trait
1 parent 56a16f8 commit 1727172

File tree

19 files changed

+32
-49
lines changed

19 files changed

+32
-49
lines changed

compiler/rustc_middle/src/ty/context.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2803,23 +2803,6 @@ impl<'tcx> TyCtxt<'tcx> {
28032803
iter.intern_with(|xs| self.intern_place_elems(xs))
28042804
}
28052805

2806-
pub fn mk_substs_trait_no_append(
2807-
self,
2808-
self_ty: Ty<'tcx>,
2809-
rest: &[GenericArg<'tcx>],
2810-
) -> SubstsRef<'tcx> {
2811-
assert!(matches!(rest.last().unwrap().unpack(), GenericArgKind::Constness(_)));
2812-
self.mk_substs(iter::once(self_ty.into()).chain(rest.iter().cloned()))
2813-
}
2814-
2815-
pub fn mk_substs_trait_non_const(
2816-
self,
2817-
self_ty: Ty<'tcx>,
2818-
rest: &[GenericArg<'tcx>],
2819-
) -> SubstsRef<'tcx> {
2820-
self.mk_substs_trait(self_ty, rest)
2821-
}
2822-
28232806
pub fn mk_substs_trait(self, self_ty: Ty<'tcx>, rest: &[GenericArg<'tcx>]) -> SubstsRef<'tcx> {
28242807
self.mk_substs(iter::once(self_ty.into()).chain(rest.iter().cloned()))
28252808
}

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ impl<'tcx> Binder<'tcx, ExistentialPredicate<'tcx>> {
699699
ExistentialPredicate::AutoTrait(did) => {
700700
let trait_ref = self.rebind(ty::TraitRef {
701701
def_id: did,
702-
substs: tcx.mk_substs_trait_non_const(self_ty, &[]),
702+
substs: tcx.mk_substs_trait(self_ty, &[]),
703703
});
704704
trait_ref.to_predicate(tcx)
705705
}

compiler/rustc_trait_selection/src/autoderef.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl<'a, 'tcx> Autoderef<'a, 'tcx> {
127127
// <ty as Deref>
128128
let trait_ref = TraitRef {
129129
def_id: tcx.lang_items().deref_trait()?,
130-
substs: tcx.mk_substs_trait_non_const(ty, &[]),
130+
substs: tcx.mk_substs_trait(ty, &[]),
131131
};
132132

133133
let cause = traits::ObligationCause::misc(self.span, self.body_id);

compiler/rustc_trait_selection/src/infer.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,8 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'tcx> {
108108
trait_def_id, ty, params, param_env
109109
);
110110

111-
let trait_ref = ty::TraitRef {
112-
def_id: trait_def_id,
113-
substs: self.tcx.mk_substs_trait_non_const(ty, params),
114-
};
111+
let trait_ref =
112+
ty::TraitRef { def_id: trait_def_id, substs: self.tcx.mk_substs_trait(ty, params) };
115113

116114
let obligation = traits::Obligation {
117115
cause: traits::ObligationCause::dummy(),

compiler/rustc_trait_selection/src/traits/auto_trait.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
8585
) -> AutoTraitResult<A> {
8686
let tcx = self.tcx;
8787

88-
let trait_ref =
89-
ty::TraitRef { def_id: trait_did, substs: tcx.mk_substs_trait_non_const(ty, &[]) };
88+
let trait_ref = ty::TraitRef { def_id: trait_did, substs: tcx.mk_substs_trait(ty, &[]) };
9089

9190
let trait_pred = ty::Binder::dummy(trait_ref);
9291

@@ -298,7 +297,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
298297
predicates.push_back(ty::Binder::dummy(ty::TraitPredicate {
299298
trait_ref: ty::TraitRef {
300299
def_id: trait_did,
301-
substs: infcx.tcx.mk_substs_trait_non_const(ty, &[]),
300+
substs: infcx.tcx.mk_substs_trait(ty, &[]),
302301
},
303302
// Auto traits are positive
304303
polarity: ty::ImplPolarity::Positive,

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
728728
&& fallback_has_occurred
729729
{
730730
let predicate = trait_predicate.map_bound(|mut trait_pred| {
731-
trait_pred.trait_ref.substs = self.tcx.mk_substs_trait_no_append(
731+
trait_pred.trait_ref.substs = self.tcx.mk_substs_trait(
732732
self.tcx.mk_unit(),
733733
&trait_pred.trait_ref.substs[1..],
734734
);
@@ -1934,7 +1934,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
19341934
) -> PredicateObligation<'tcx> {
19351935
let trait_pred = trait_ref_and_ty.map_bound_ref(|(tr, new_self_ty)| ty::TraitPredicate {
19361936
trait_ref: ty::TraitRef {
1937-
substs: self.tcx.mk_substs_trait_no_append(*new_self_ty, &tr.trait_ref.substs[1..]),
1937+
substs: self.tcx.mk_substs_trait(*new_self_ty, &tr.trait_ref.substs[1..]),
19381938
..tr.trait_ref
19391939
},
19401940
..*tr

compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2784,7 +2784,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
27842784
self.tcx.mk_projection(
27852785
item_def_id,
27862786
// Future::Output has no substs
2787-
self.tcx.mk_substs_trait(trait_pred.self_ty(), &[], ty::ConstnessArg::Not),
2787+
self.tcx.mk_substs_trait(trait_pred.self_ty(), &[]),
27882788
)
27892789
});
27902790
let projection_ty = normalize_to(
@@ -2873,9 +2873,9 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
28732873
let field_ty = field.ty(self.tcx, substs);
28742874
let trait_substs = match diagnostic_name {
28752875
sym::PartialEq | sym::PartialOrd => {
2876-
self.tcx.mk_substs_trait_non_const(field_ty, &[field_ty.into()])
2876+
self.tcx.mk_substs_trait(field_ty, &[field_ty.into()])
28772877
}
2878-
_ => self.tcx.mk_substs_trait_non_const(field_ty, &[]),
2878+
_ => self.tcx.mk_substs_trait(field_ty, &[]),
28792879
};
28802880
let trait_pred = trait_pred.map_bound_ref(|tr| ty::TraitPredicate {
28812881
trait_ref: ty::TraitRef {

compiler/rustc_trait_selection/src/traits/object_safety.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ fn receiver_is_dispatchable<'tcx>(
682682
// Self: Unsize<U>
683683
let unsize_predicate = ty::Binder::dummy(ty::TraitRef {
684684
def_id: unsize_did,
685-
substs: tcx.mk_substs_trait_non_const(tcx.types.self_param, &[unsized_self_ty.into()]),
685+
substs: tcx.mk_substs_trait(tcx.types.self_param, &[unsized_self_ty.into()]),
686686
})
687687
.to_predicate(tcx);
688688

@@ -712,7 +712,7 @@ fn receiver_is_dispatchable<'tcx>(
712712
let obligation = {
713713
let predicate = ty::Binder::dummy(ty::TraitRef {
714714
def_id: dispatch_from_dyn_did,
715-
substs: tcx.mk_substs_trait_non_const(receiver_ty, &[unsized_receiver_ty.into()]),
715+
substs: tcx.mk_substs_trait(receiver_ty, &[unsized_receiver_ty.into()]),
716716
})
717717
.to_predicate(tcx);
718718

compiler/rustc_trait_selection/src/traits/project.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,7 +1563,7 @@ fn assemble_candidates_from_impls<'cx, 'tcx>(
15631563
&obligation.with(
15641564
ty::Binder::dummy(ty::TraitRef::new(
15651565
selcx.tcx().require_lang_item(LangItem::Sized, None),
1566-
selcx.tcx().mk_substs_trait_non_const(self_ty, &[]),
1566+
selcx.tcx().mk_substs_trait(self_ty, &[]),
15671567
))
15681568
.to_predicate(selcx.tcx()),
15691569
),
@@ -1807,7 +1807,7 @@ fn confirm_pointee_candidate<'cx, 'tcx>(
18071807
if check_is_sized {
18081808
let sized_predicate = ty::Binder::dummy(ty::TraitRef::new(
18091809
tcx.require_lang_item(LangItem::Sized, None),
1810-
tcx.mk_substs_trait_non_const(self_ty, &[]),
1810+
tcx.mk_substs_trait(self_ty, &[]),
18111811
))
18121812
.to_poly_trait_predicate()
18131813
.to_predicate(tcx);

compiler/rustc_trait_selection/src/traits/relationships.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub(crate) fn update<'tcx, T>(
1919
let new_self_ty = infcx.tcx.types.unit;
2020

2121
let trait_ref = ty::TraitRef {
22-
substs: infcx.tcx.mk_substs_trait_no_append(new_self_ty, &tpred.trait_ref.substs[1..]),
22+
substs: infcx.tcx.mk_substs_trait(new_self_ty, &tpred.trait_ref.substs[1..]),
2323
..tpred.trait_ref
2424
};
2525

0 commit comments

Comments
 (0)