Skip to content

Commit 56a16f8

Browse files
oli-obkfee1-dead
authored andcommitted
Remove constness arg from mk_substs_trait
this is now handled in compiler/rustc_typeck/src/astconv/mod.rs
1 parent 0fe3432 commit 56a16f8

File tree

24 files changed

+47
-70
lines changed

24 files changed

+47
-70
lines changed

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
572572
let tcx = self.tcx();
573573
let trait_ref = ty::TraitRef {
574574
def_id: tcx.require_lang_item(LangItem::Copy, Some(self.last_span)),
575-
substs: tcx.mk_substs_trait(place_ty.ty, &[], ty::ConstnessArg::Not),
575+
substs: tcx.mk_substs_trait(place_ty.ty, &[]),
576576
};
577577

578578
// To have a `Copy` operand, the type `T` of the
@@ -1304,7 +1304,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
13041304
if !self.unsized_feature_enabled() {
13051305
let trait_ref = ty::TraitRef {
13061306
def_id: tcx.require_lang_item(LangItem::Sized, Some(self.last_span)),
1307-
substs: tcx.mk_substs_trait(place_ty, &[], ty::ConstnessArg::Not),
1307+
substs: tcx.mk_substs_trait(place_ty, &[]),
13081308
};
13091309
self.prove_trait_ref(
13101310
trait_ref,
@@ -1894,7 +1894,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
18941894
let ty = place.ty(body, tcx).ty;
18951895
let trait_ref = ty::TraitRef::new(
18961896
tcx.require_lang_item(LangItem::Copy, Some(span)),
1897-
tcx.mk_substs_trait(ty, &[], ty::ConstnessArg::Not),
1897+
tcx.mk_substs_trait(ty, &[]),
18981898
);
18991899

19001900
self.prove_trait_ref(
@@ -1910,7 +1910,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
19101910
&Rvalue::NullaryOp(_, ty) => {
19111911
let trait_ref = ty::TraitRef {
19121912
def_id: tcx.require_lang_item(LangItem::Sized, Some(self.last_span)),
1913-
substs: tcx.mk_substs_trait(ty, &[], ty::ConstnessArg::Not),
1913+
substs: tcx.mk_substs_trait(ty, &[]),
19141914
};
19151915

19161916
self.prove_trait_ref(
@@ -1925,7 +1925,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
19251925

19261926
let trait_ref = ty::TraitRef {
19271927
def_id: tcx.require_lang_item(LangItem::Sized, Some(self.last_span)),
1928-
substs: tcx.mk_substs_trait(*ty, &[], ty::ConstnessArg::Not),
1928+
substs: tcx.mk_substs_trait(*ty, &[]),
19291929
};
19301930

19311931
self.prove_trait_ref(
@@ -2027,11 +2027,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
20272027
def_id: tcx
20282028
.require_lang_item(LangItem::CoerceUnsized, Some(self.last_span)),
20292029
// TODO: pick constness arg from context
2030-
substs: tcx.mk_substs_trait(
2031-
op.ty(body, tcx),
2032-
&[ty.into()],
2033-
ty::ConstnessArg::Not,
2034-
),
2030+
substs: tcx.mk_substs_trait(op.ty(body, tcx), &[ty.into()]),
20352031
};
20362032

20372033
self.prove_trait_ref(

compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl Qualif for NeedsNonConstDrop {
161161
ty::Binder::dummy(ty::TraitPredicate {
162162
trait_ref: ty::TraitRef {
163163
def_id: destruct,
164-
substs: cx.tcx.mk_substs_trait(ty, &[], ty::ConstnessArg::Required),
164+
substs: cx.tcx.mk_substs_trait(ty, &[ty::ConstnessArg::Required.into()]),
165165
},
166166
polarity: ty::ImplPolarity::Positive,
167167
}),

compiler/rustc_infer/src/traits/engine.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ pub trait TraitEngine<'tcx>: 'tcx {
2727
def_id: DefId,
2828
cause: ObligationCause<'tcx>,
2929
) {
30-
let trait_ref = ty::TraitRef {
31-
def_id,
32-
substs: infcx.tcx.mk_substs_trait(ty, &[], ty::ConstnessArg::Param),
33-
};
30+
let trait_ref = ty::TraitRef { def_id, substs: infcx.tcx.mk_substs_trait(ty, &[]) };
3431
self.register_predicate_obligation(
3532
infcx,
3633
Obligation {

compiler/rustc_middle/src/ty/adjustment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ impl<'tcx> OverloadedDeref<'tcx> {
129129
.find(|m| m.kind == ty::AssocKind::Fn)
130130
.unwrap()
131131
.def_id;
132-
(method_def_id, tcx.mk_substs_trait(source, &[], ty::ConstnessArg::Not))
132+
(method_def_id, tcx.mk_substs_trait(source, &[]))
133133
}
134134
}
135135

compiler/rustc_middle/src/ty/context.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2817,20 +2817,11 @@ impl<'tcx> TyCtxt<'tcx> {
28172817
self_ty: Ty<'tcx>,
28182818
rest: &[GenericArg<'tcx>],
28192819
) -> SubstsRef<'tcx> {
2820-
self.mk_substs_trait(self_ty, rest, ty::ConstnessArg::Not)
2820+
self.mk_substs_trait(self_ty, rest)
28212821
}
28222822

2823-
pub fn mk_substs_trait(
2824-
self,
2825-
self_ty: Ty<'tcx>,
2826-
rest: &[GenericArg<'tcx>],
2827-
constness: ty::ConstnessArg,
2828-
) -> SubstsRef<'tcx> {
2829-
self.mk_substs(
2830-
iter::once(self_ty.into())
2831-
.chain(rest.iter().cloned())
2832-
.chain(iter::once(constness.into())),
2833-
)
2823+
pub fn mk_substs_trait(self, self_ty: Ty<'tcx>, rest: &[GenericArg<'tcx>]) -> SubstsRef<'tcx> {
2824+
self.mk_substs(iter::once(self_ty.into()).chain(rest.iter().cloned()))
28342825
}
28352826

28362827
pub fn mk_bound_variable_kinds<

compiler/rustc_middle/src/ty/instance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ impl<'tcx> Instance<'tcx> {
537537
let sig =
538538
tcx.try_normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), sig).ok()?;
539539
assert_eq!(sig.inputs().len(), 1);
540-
let substs = tcx.mk_substs_trait(self_ty, &[sig.inputs()[0].into()], ty::ConstnessArg::Not);
540+
let substs = tcx.mk_substs_trait(self_ty, &[sig.inputs()[0].into()]);
541541

542542
debug!("fn_once_adapter_shim: self_ty={:?} sig={:?}", self_ty, sig);
543543
Some(Instance { def, substs })

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -916,10 +916,7 @@ impl<'tcx> ExistentialTraitRef<'tcx> {
916916
// otherwise the escaping vars would be captured by the binder
917917
// debug_assert!(!self_ty.has_escaping_bound_vars());
918918

919-
ty::TraitRef {
920-
def_id: self.def_id,
921-
substs: tcx.mk_substs_trait(self_ty, self.substs, ty::ConstnessArg::Not),
922-
}
919+
ty::TraitRef { def_id: self.def_id, substs: tcx.mk_substs_trait(self_ty, self.substs) }
923920
}
924921
}
925922

@@ -1460,7 +1457,7 @@ impl<'tcx> ExistentialProjection<'tcx> {
14601457
ty::ProjectionPredicate {
14611458
projection_ty: ty::ProjectionTy {
14621459
item_def_id: self.item_def_id,
1463-
substs: tcx.mk_substs_trait(self_ty, self.substs, ty::ConstnessArg::Not),
1460+
substs: tcx.mk_substs_trait(self_ty, self.substs),
14641461
},
14651462
term: self.term,
14661463
}

compiler/rustc_mir_build/src/build/matches/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ fn trait_method<'tcx>(
820820
self_ty: Ty<'tcx>,
821821
params: &[GenericArg<'tcx>],
822822
) -> ConstantKind<'tcx> {
823-
let substs = tcx.mk_substs_trait(self_ty, params, ty::ConstnessArg::Not);
823+
let substs = tcx.mk_substs_trait(self_ty, params);
824824

825825
// The unhygienic comparison here is acceptable because this is only
826826
// used on known traits.

compiler/rustc_mir_dataflow/src/elaborate_drops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ where
616616
let drop_trait = tcx.require_lang_item(LangItem::Drop, None);
617617
let drop_fn = tcx.associated_item_def_ids(drop_trait)[0];
618618
let ty = self.place_ty(self.place);
619-
let substs = tcx.mk_substs_trait(ty, &[], ty::ConstnessArg::Not);
619+
let substs = tcx.mk_substs_trait(ty, &[]);
620620

621621
let ref_ty =
622622
tcx.mk_ref(tcx.lifetimes.re_erased, ty::TypeAndMut { ty, mutbl: hir::Mutability::Mut });

compiler/rustc_mir_transform/src/shim.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ impl<'tcx> CloneShimBuilder<'tcx> {
342342
// we must subst the self_ty because it's
343343
// otherwise going to be TySelf and we can't index
344344
// or access fields of a Place of type TySelf.
345-
let substs = tcx.mk_substs_trait(self_ty, &[], ty::ConstnessArg::Not);
345+
let substs = tcx.mk_substs_trait(self_ty, &[]);
346346
let sig = tcx.bound_fn_sig(def_id).subst(tcx, substs);
347347
let sig = tcx.erase_late_bound_regions(sig);
348348
let span = tcx.def_span(def_id);
@@ -423,7 +423,7 @@ impl<'tcx> CloneShimBuilder<'tcx> {
423423
) {
424424
let tcx = self.tcx;
425425

426-
let substs = tcx.mk_substs_trait(ty, &[], ty::ConstnessArg::Not);
426+
let substs = tcx.mk_substs_trait(ty, &[]);
427427

428428
// `func == Clone::clone(&ty) -> ty`
429429
let func_ty = tcx.mk_fn_def(self.def_id, substs);
@@ -529,8 +529,7 @@ fn build_call_shim<'tcx>(
529529

530530
// Create substitutions for the `Self` and `Args` generic parameters of the shim body.
531531
let arg_tup = tcx.mk_tup(untuple_args.iter());
532-
let sig_substs =
533-
tcx.mk_substs_trait(ty, &[ty::subst::GenericArg::from(arg_tup)], ty::ConstnessArg::Not);
532+
let sig_substs = tcx.mk_substs_trait(ty, &[ty::subst::GenericArg::from(arg_tup)]);
534533

535534
(Some(sig_substs), Some(untuple_args))
536535
} else {

0 commit comments

Comments
 (0)