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() {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
328328
let trait_predicate = self.resolve_vars_if_possible(trait_predicate);
329329

330330
let predicate_is_const =
331-
ty::ConstnessArg::Required == trait_predicate.skip_binder().constness();
331+
ty::ConstnessArg::Const == trait_predicate.skip_binder().constness();
332332

333333
if self.tcx.sess.has_errors().is_some()
334334
&& trait_predicate.references_error()

compiler/rustc_trait_selection/src/traits/select/confirmation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
12071207
.require_lang_item(LangItem::Destruct, None),
12081208
substs: self.tcx().mk_substs_trait(
12091209
nested_ty,
1210-
&[ty::ConstnessArg::Param.into()],
1210+
&[ty::ConstnessArg::Const.into()],
12111211
),
12121212
},
12131213
polarity: ty::ImplPolarity::Positive,
@@ -1235,7 +1235,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
12351235
def_id: self.tcx().require_lang_item(LangItem::Destruct, None),
12361236
substs: self.tcx().mk_substs_trait(
12371237
nested_ty,
1238-
&[ty::ConstnessArg::Param.into()],
1238+
&[ty::ConstnessArg::Const.into()],
12391239
),
12401240
},
12411241
polarity: ty::ImplPolarity::Positive,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
11991199
ParamCandidate(trait_pred)
12001200
if trait_pred.constness() != ty::ConstnessArg::Not =>
12011201
{
1202-
debug_assert_eq!(trait_pred.constness(), ty::ConstnessArg::Param);
1202+
debug_assert_eq!(trait_pred.constness(), ty::ConstnessArg::Const);
12031203
}
12041204
// auto trait impl
12051205
AutoImplCandidate(..) => {}

compiler/rustc_traits/src/chalk/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ fn bound_vars_for_item<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> SubstsRef<'tcx
741741
})
742742
.into(),
743743
ty::GenericParamDefKind::Constness => {
744-
ty::ConstnessArg::Param.into() // TODO Confirm
744+
ty::ConstnessArg::Not.into() // TODO Confirm
745745
}
746746
})
747747
}

compiler/rustc_typeck/src/astconv/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -574,10 +574,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
574574
.unwrap_or_else(|| match self.astconv.item_def_id() {
575575
// no information available
576576
// TODO: fall back to `Not`?
577-
None => if infer_args { ty::ConstnessArg::Infer } else { ty::ConstnessArg::Param },
577+
None => if infer_args { ty::ConstnessArg::Infer } else { ty::ConstnessArg::Not },
578578
Some(context) => {
579579
if tcx.generics_of(context).has_constness_param() {
580-
ty::ConstnessArg::Param
580+
ty::ConstnessArg::Const
581581
} else {
582582
// TODO: should use `Required` if we're in a const context
583583
// like `const`/`static` item initializers.
@@ -724,8 +724,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
724724
self_ty,
725725
trait_ref.path.segments.last().unwrap(),
726726
true,
727-
match constness { // TODO check this again
728-
hir::Constness::Const => ty::ConstnessArg::Param,
727+
match constness {
728+
// TODO check this again
729+
hir::Constness::Const => ty::ConstnessArg::Const,
729730
hir::Constness::NotConst => ty::ConstnessArg::Not,
730731
},
731732
)
@@ -1028,7 +1029,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
10281029
match ast_bound {
10291030
hir::GenericBound::Trait(poly_trait_ref, modifier) => {
10301031
let constness = match modifier {
1031-
hir::TraitBoundModifier::MaybeConst => ty::ConstnessArg::Param,
1032+
hir::TraitBoundModifier::MaybeConst => ty::ConstnessArg::Const,
10321033
hir::TraitBoundModifier::None => ty::ConstnessArg::Not,
10331034
hir::TraitBoundModifier::Maybe => continue,
10341035
};

compiler/rustc_typeck/src/check/compare_method.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,7 @@ pub fn check_type_bounds<'tcx>(
13781378
})
13791379
.into()
13801380
}
1381-
GenericParamDefKind::Constness => ty::ConstnessArg::Param.into(),
1381+
GenericParamDefKind::Constness => ty::ConstnessArg::Const.into(),
13821382
});
13831383
let bound_vars = tcx.mk_bound_variable_kinds(bound_vars.into_iter());
13841384
let impl_ty_substs = tcx.intern_substs(&substs);

compiler/rustc_typeck/src/check/fn_ctxt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
150150
if body_id.is_owner() {
151151
let did = body_id.expect_owner();
152152
if inh.tcx.is_const_fn_raw(did.to_def_id()) || inh.tcx.is_const_default_method(did.to_def_id()) || inh.tcx.def_kind(did.to_def_id()) == hir::def::DefKind::Const {
153-
ty::ConstnessArg::Param
153+
ty::ConstnessArg::Const
154154
} else {
155155
ty::ConstnessArg::Not
156156
}

src/test/ui/rfc-2632-const-trait-impl/const-trait-bound.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// check-pass
12
#![feature(const_trait_impl)]
23

34
#[const_trait]

0 commit comments

Comments
 (0)