Skip to content

Commit 84054f7

Browse files
committed
Merge ::Required and ::Param
1 parent ad467ae commit 84054f7

File tree

18 files changed

+32
-40
lines changed

18 files changed

+32
-40
lines changed

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ fn check_opaque_type_parameter_valid(
381381
matches!(*lt, ty::ReEarlyBound(_) | ty::ReFree(_))
382382
}
383383
GenericArgKind::Const(ct) => matches!(ct.kind(), ty::ConstKind::Param(_)),
384-
GenericArgKind::Constness(ct) => matches!(ct, ty::ConstnessArg::Param),
384+
GenericArgKind::Constness(_) => false,
385385
};
386386

387387
if arg_is_param {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
736736
});
737737

738738
match implsrc {
739-
Ok(Some(ImplSource::Param(_, ty::ConstnessArg::Required | ty::ConstnessArg::Param))) => {
739+
Ok(Some(ImplSource::Param(_, ty::ConstnessArg::Const))) => {
740740
debug!(
741741
"const_trait_impl: provided {:?} via where-clause in {:?}",
742742
trait_ref, param_env

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

Lines changed: 2 additions & 2 deletions
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::Param.into()]),
164+
substs: cx.tcx.mk_substs_trait(ty, &[ty::ConstnessArg::Const.into()]),
165165
},
166166
polarity: ty::ImplPolarity::Positive,
167167
}),
@@ -176,7 +176,7 @@ impl Qualif for NeedsNonConstDrop {
176176

177177
if !matches!(
178178
impl_src,
179-
ImplSource::ConstDestruct(_) | ImplSource::Param(_, ty::ConstnessArg::Required | ty::ConstnessArg::Param)
179+
ImplSource::ConstDestruct(_) | ImplSource::Param(_, ty::ConstnessArg::Const)
180180
) {
181181
// If our const destruct candidate is not ConstDestruct or implied by the param env,
182182
// then it's bad

compiler/rustc_infer/src/infer/sub.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ impl<'tcx> TypeRelation<'tcx> for Sub<'_, '_, 'tcx> {
209209
) -> RelateResult<'tcx, ty::ConstnessArg> {
210210
trace!(?a, ?b);
211211
match (a, b) {
212-
(ty::ConstnessArg::Required, _) => Ok(a),
212+
(ty::ConstnessArg::Const, _) => Ok(a),
213213
(a, ty::ConstnessArg::Infer) => Ok(a),
214214
(ty::ConstnessArg::Infer, b) => Ok(b),
215215
(a, ty::ConstnessArg::Not) => Ok(a),

compiler/rustc_middle/src/ty/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2629,7 +2629,7 @@ impl<'tcx> TyCtxt<'tcx> {
26292629
GenericParamDefKind::Const { .. } => {
26302630
self.mk_const_param(param.index, param.name, self.type_of(param.def_id)).into()
26312631
}
2632-
GenericParamDefKind::Constness => ty::ConstnessArg::Param.into(),
2632+
GenericParamDefKind::Constness => ty::ConstnessArg::Not.into(), // TODO sus
26332633
}
26342634
}
26352635

compiler/rustc_middle/src/ty/fast_reject.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -412,13 +412,8 @@ impl DeepRejectCtxt {
412412
impl_ct: ty::ConstnessArg,
413413
) -> bool {
414414
match (obligation_ct, impl_ct) {
415-
(_, ty::ConstnessArg::Param) => true,
416-
(ty::ConstnessArg::Param, _) => match self.treat_obligation_params {
417-
TreatParams::AsPlaceholder => false,
418-
TreatParams::AsInfer => true,
419-
},
415+
(_, ty::ConstnessArg::Const) => true,
420416
(ty::ConstnessArg::Infer, _) => true,
421-
(ty::ConstnessArg::Not, ty::ConstnessArg::Required) => true,
422417
_ => obligation_ct == impl_ct,
423418
}
424419
}

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -312,19 +312,17 @@ impl fmt::Display for BoundConstness {
312312
Ord
313313
)]
314314
pub enum ConstnessArg {
315-
Required,
315+
Const,
316316
Not,
317-
Param,
318317
Infer,
319318
}
320319

321320
impl fmt::Display for ConstnessArg {
322321
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
323322
f.write_str(match self {
324-
Self::Required => "(constness: required)",
325323
Self::Not => "(constness: not)",
326-
Self::Param => "(constness: parameterized)",
327-
Self::Infer => "(constness: infer)"
324+
Self::Const => "(constness: const)",
325+
Self::Infer => "(constness: infer)",
328326
})
329327
}
330328
}

compiler/rustc_middle/src/ty/print/pretty.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2522,8 +2522,7 @@ define_print_and_forward_display! {
25222522
if cx.tcx().sess.verbose() {
25232523
match self.0.constness() {
25242524
ty::ConstnessArg::Not => {},
2525-
ty::ConstnessArg::Required => p!(write("const ")),
2526-
ty::ConstnessArg::Param => p!(write("~const ")),
2525+
ty::ConstnessArg::Const => p!(write("~const ")),
25272526
ty::ConstnessArg::Infer => p!(write("_const ")), // TODO wonky
25282527
}
25292528
}

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,9 +847,9 @@ impl<'tcx> TraitRef<'tcx> {
847847
}
848848

849849
pub fn with_const(mut self, tcx: TyCtxt<'tcx>) -> Self {
850-
if self.constness() != ty::ConstnessArg::Required {
850+
if self.constness() != ty::ConstnessArg::Const {
851851
self.substs = tcx.mk_substs(self.substs.iter().map(|arg| match arg.unpack() {
852-
ty::subst::GenericArgKind::Constness(_) => ty::ConstnessArg::Required.into(),
852+
ty::subst::GenericArgKind::Constness(_) => ty::ConstnessArg::Const.into(),
853853
_ => arg,
854854
}));
855855
}

compiler/rustc_middle/src/ty/subst.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,8 @@ impl<'tcx> GenericArgKind<'tcx> {
9999
CONSTNESS_TAG,
100100
match carg {
101101
ty::ConstnessArg::Not => 0,
102-
ty::ConstnessArg::Required => 0b100,
103-
ty::ConstnessArg::Param => 0b1000,
104-
ty::ConstnessArg::Infer => 0b10000,
102+
ty::ConstnessArg::Const => 0b100,
103+
ty::ConstnessArg::Infer => 0b1000,
105104
},
106105
),
107106
};
@@ -181,9 +180,8 @@ impl<'tcx> GenericArg<'tcx> {
181180
))),
182181
CONSTNESS_TAG => GenericArgKind::Constness(match ptr & (!TAG_MASK) {
183182
0 => ty::ConstnessArg::Not,
184-
0b100 => ty::ConstnessArg::Required,
185-
0b1000 => ty::ConstnessArg::Param,
186-
0b10000 => ty::ConstnessArg::Infer,
183+
0b100 => ty::ConstnessArg::Const,
184+
0b1000 => ty::ConstnessArg::Infer,
187185
_ => intrinsics::unreachable(),
188186
}),
189187
_ => intrinsics::unreachable(),
@@ -613,7 +611,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for SubstFolder<'a, 'tcx> {
613611
}
614612

615613
fn fold_constness(&mut self, c: ty::ConstnessArg) -> ty::ConstnessArg {
616-
if let ty::ConstnessArg::Param | ty::ConstnessArg::Infer = c {
614+
if let ty::ConstnessArg::Const | ty::ConstnessArg::Infer = c {
617615
self.substs
618616
.iter()
619617
.find_map(|param| match param.unpack() {

0 commit comments

Comments
 (0)