Skip to content

Commit da63f2f

Browse files
committed
Rename Constness variants to match BoundConstness
1 parent af65f18 commit da63f2f

File tree

23 files changed

+80
-80
lines changed

23 files changed

+80
-80
lines changed

compiler/rustc_ast_lowering/src/delegation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
426426
fn generate_header_error(&self) -> hir::FnHeader {
427427
hir::FnHeader {
428428
safety: hir::Safety::Safe.into(),
429-
constness: hir::Constness::NotConst,
429+
constness: hir::Constness::Never,
430430
asyncness: hir::IsAsync::NotAsync,
431431
abi: ExternAbi::Rust,
432432
}

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
766766
fn_decl_span: self.lower_span(fn_decl_span),
767767
fn_arg_span: None,
768768
kind: hir::ClosureKind::Coroutine(coroutine_kind),
769-
constness: hir::Constness::NotConst,
769+
constness: hir::Constness::Never,
770770
}))
771771
}
772772

@@ -1193,7 +1193,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
11931193
// knows that a `FnDecl` output type like `-> &str` actually means
11941194
// "coroutine that returns &str", rather than directly returning a `&str`.
11951195
kind: hir::ClosureKind::CoroutineClosure(coroutine_desugaring),
1196-
constness: hir::Constness::NotConst,
1196+
constness: hir::Constness::Never,
11971197
});
11981198
hir::ExprKind::Closure(c)
11991199
}

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,17 +1540,17 @@ impl<'hir> LoweringContext<'_, 'hir> {
15401540

15411541
let mut constness = self.lower_constness(h.constness);
15421542
if let Some(&attr_span) = find_attr!(attrs, AttributeKind::Comptime(span) => span) {
1543-
match std::mem::replace(&mut constness, rustc_hir::Constness::Comptime) {
1544-
rustc_hir::Constness::Comptime => {
1543+
match std::mem::replace(&mut constness, rustc_hir::Constness::Always) {
1544+
rustc_hir::Constness::Always => {
15451545
unreachable!("lower_constness cannot produce comptime")
15461546
}
15471547
// A function can't be `const` and `comptime` at the same time
1548-
rustc_hir::Constness::Const => {
1548+
rustc_hir::Constness::Maybe => {
15491549
let Const::Yes(span) = h.constness else { unreachable!() };
15501550
self.dcx().emit_err(ConstComptimeFn { span, attr_span });
15511551
}
15521552
// Good
1553-
rustc_hir::Constness::NotConst => {}
1553+
rustc_hir::Constness::Never => {}
15541554
}
15551555
}
15561556

@@ -1616,8 +1616,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
16161616

16171617
pub(super) fn lower_constness(&mut self, c: Const) -> hir::Constness {
16181618
match c {
1619-
Const::Yes(_) => hir::Constness::Const,
1620-
Const::No => hir::Constness::NotConst,
1619+
Const::Yes(_) => hir::Constness::Maybe,
1620+
Const::No => hir::Constness::Never,
16211621
}
16221622
}
16231623

compiler/rustc_const_eval/src/check_consts/ops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ fn build_error_for_const_call<'tcx>(
402402
err.help("const traits are not yet supported on stable Rust");
403403
}
404404
}
405-
} else if ccx.tcx.constness(callee) != hir::Constness::Const {
405+
} else if ccx.tcx.constness(callee) != hir::Constness::Maybe {
406406
let name = ccx.tcx.item_name(callee);
407407
err.span_note(
408408
ccx.tcx.def_span(callee),

compiler/rustc_const_eval/src/const_eval/fn_queries.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ fn parent_impl_or_trait_constness(tcx: TyCtxt<'_>, def_id: LocalDefId) -> hir::C
1111
DefKind::Impl { of_trait: false } => tcx.constness(parent_id),
1212
DefKind::Trait => {
1313
if tcx.is_const_trait(parent_id.into()) {
14-
hir::Constness::Const
14+
hir::Constness::Maybe
1515
} else {
16-
hir::Constness::NotConst
16+
hir::Constness::Never
1717
}
1818
}
19-
_ => hir::Constness::NotConst,
19+
_ => hir::Constness::Never,
2020
}
2121
}
2222

@@ -25,16 +25,16 @@ fn constness(tcx: TyCtxt<'_>, def_id: LocalDefId) -> hir::Constness {
2525
let node = tcx.hir_node_by_def_id(def_id);
2626

2727
match node {
28-
hir::Node::Ctor(hir::VariantData::Tuple(..)) => hir::Constness::Const,
28+
hir::Node::Ctor(hir::VariantData::Tuple(..)) => hir::Constness::Maybe,
2929
hir::Node::ForeignItem(item) if let hir::ForeignItemKind::Fn(..) = item.kind => {
3030
// Foreign functions cannot be evaluated at compile-time.
31-
hir::Constness::NotConst
31+
hir::Constness::Never
3232
}
3333
hir::Node::Expr(e) if let hir::ExprKind::Closure(c) = e.kind => c.constness,
3434
hir::Node::Item(i) if let hir::ItemKind::Impl(impl_) = i.kind => impl_.constness,
3535
_ => {
3636
if let Some(fn_kind) = node.fn_kind() {
37-
if fn_kind.constness() != hir::Constness::NotConst {
37+
if fn_kind.constness() != hir::Constness::Never {
3838
return fn_kind.constness();
3939
}
4040

compiler/rustc_hir/src/hir.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4228,18 +4228,18 @@ impl fmt::Display for Safety {
42284228
#[derive(Copy, Clone, PartialEq, Eq, Debug, Encodable, Decodable, HashStable_Generic)]
42294229
#[derive(Default)]
42304230
pub enum Constness {
4231-
Comptime,
4232-
Const,
4231+
Always,
4232+
Maybe,
42334233
#[default]
4234-
NotConst,
4234+
Never,
42354235
}
42364236

42374237
impl fmt::Display for Constness {
42384238
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
42394239
f.write_str(match *self {
4240-
Self::Comptime => "comptime",
4241-
Self::Const => "const",
4242-
Self::NotConst => "non-const",
4240+
Self::Always => "comptime",
4241+
Self::Maybe => "const",
4242+
Self::Never => "non-const",
42434243
})
42444244
}
42454245
}
@@ -4279,7 +4279,7 @@ impl FnHeader {
42794279
}
42804280

42814281
pub fn is_const(&self) -> bool {
4282-
matches!(self.constness, Constness::Const)
4282+
matches!(self.constness, Constness::Maybe)
42834283
}
42844284

42854285
pub fn is_unsafe(&self) -> bool {

compiler/rustc_hir/src/intravisit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl<'a> FnKind<'a> {
9898
}
9999

100100
pub fn constness(self) -> Constness {
101-
self.header().map_or(Constness::NotConst, |header| header.constness)
101+
self.header().map_or(Constness::Never, |header| header.constness)
102102
}
103103

104104
pub fn asyncness(self) -> IsAsync {

compiler/rustc_hir_analysis/src/collect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,7 @@ fn check_impl_constness(
13631363
constness: hir::Constness,
13641364
hir_trait_ref: &hir::TraitRef<'_>,
13651365
) {
1366-
if let hir::Constness::NotConst = constness {
1366+
if let hir::Constness::Never = constness {
13671367
return;
13681368
}
13691369

compiler/rustc_hir_pretty/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ impl<'a> State<'a> {
703703

704704
match of_trait {
705705
None => {
706-
if let hir::Constness::Const = constness {
706+
if let hir::Constness::Maybe = constness {
707707
self.word_nbsp("const");
708708
}
709709
impl_generics(self)
@@ -720,7 +720,7 @@ impl<'a> State<'a> {
720720

721721
impl_generics(self);
722722

723-
if let hir::Constness::Const = constness {
723+
if let hir::Constness::Maybe = constness {
724724
self.word_nbsp("const");
725725
}
726726

@@ -2529,7 +2529,7 @@ impl<'a> State<'a> {
25292529
hir::FnHeader {
25302530
safety: safety.into(),
25312531
abi,
2532-
constness: hir::Constness::NotConst,
2532+
constness: hir::Constness::Never,
25332533
asyncness: hir::IsAsync::NotAsync,
25342534
},
25352535
name,
@@ -2569,9 +2569,9 @@ impl<'a> State<'a> {
25692569

25702570
fn print_constness(&mut self, s: hir::Constness) {
25712571
match s {
2572-
hir::Constness::NotConst => {}
2573-
hir::Constness::Const => self.word_nbsp("const"),
2574-
hir::Constness::Comptime => { /* printed as an attribute */ }
2572+
hir::Constness::Never => {}
2573+
hir::Constness::Maybe => self.word_nbsp("const"),
2574+
hir::Constness::Always => { /* printed as an attribute */ }
25752575
}
25762576
}
25772577

compiler/rustc_hir_typeck/src/callee.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
906906
) {
907907
let const_context = self.tcx.hir_body_const_context(self.body_id);
908908

909-
if let hir::Constness::Comptime = self.tcx.constness(callee_did) {
909+
if let hir::Constness::Always = self.tcx.constness(callee_did) {
910910
match const_context {
911911
Some(hir::ConstContext::Const { .. } | hir::ConstContext::Static(_)) => {}
912912
Some(hir::ConstContext::ConstFn) | None => {

0 commit comments

Comments
 (0)