Skip to content

Commit 66267da

Browse files
committed
Use "rhs" terminology instead of "body"
1 parent dbb33c7 commit 66267da

File tree

15 files changed

+76
-91
lines changed

15 files changed

+76
-91
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3746,7 +3746,7 @@ pub struct ConstItem {
37463746
pub ident: Ident,
37473747
pub generics: Generics,
37483748
pub ty: Box<Ty>,
3749-
pub body: Option<ConstItemRhs>,
3749+
pub rhs: Option<ConstItemRhs>,
37503750
pub define_opaque: Option<ThinVec<(NodeId, Path)>>,
37513751
}
37523752

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -184,27 +184,22 @@ impl<'hir> LoweringContext<'_, 'hir> {
184184
hir::ItemKind::Static(*m, ident, ty, body_id)
185185
}
186186
ItemKind::Const(box ast::ConstItem {
187-
ident,
188-
generics,
189-
ty,
190-
body,
191-
define_opaque,
192-
..
187+
ident, generics, ty, rhs, define_opaque, ..
193188
}) => {
194189
let ident = self.lower_ident(*ident);
195-
let (generics, (ty, body)) = self.lower_generics(
190+
let (generics, (ty, rhs)) = self.lower_generics(
196191
generics,
197192
id,
198193
ImplTraitContext::Disallowed(ImplTraitPosition::Generic),
199194
|this| {
200195
let ty = this
201196
.lower_ty(ty, ImplTraitContext::Disallowed(ImplTraitPosition::ConstTy));
202-
let body = this.lower_const_item_rhs(attrs, body.as_ref(), span);
203-
(ty, body)
197+
let rhs = this.lower_const_item_rhs(attrs, rhs.as_ref(), span);
198+
(ty, rhs)
204199
},
205200
);
206201
self.lower_define_opaque(hir_id, &define_opaque);
207-
hir::ItemKind::Const(ident, generics, ty, body)
202+
hir::ItemKind::Const(ident, generics, ty, rhs)
208203
}
209204
ItemKind::Fn(box Fn {
210205
sig: FnSig { decl, header, span: fn_sig_span },
@@ -797,12 +792,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
797792

798793
let (ident, generics, kind, has_default) = match &i.kind {
799794
AssocItemKind::Const(box ConstItem {
800-
ident,
801-
generics,
802-
ty,
803-
body,
804-
define_opaque,
805-
..
795+
ident, generics, ty, rhs, define_opaque, ..
806796
}) => {
807797
let (generics, kind) = self.lower_generics(
808798
generics,
@@ -811,15 +801,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
811801
|this| {
812802
let ty = this
813803
.lower_ty(ty, ImplTraitContext::Disallowed(ImplTraitPosition::ConstTy));
814-
let body = body
804+
let rhs = rhs
815805
.as_ref()
816-
.map(|body| this.lower_const_item_rhs(attrs, Some(body), i.span));
817-
hir::TraitItemKind::Const(ty, body)
806+
.map(|rhs| this.lower_const_item_rhs(attrs, Some(rhs), i.span));
807+
hir::TraitItemKind::Const(ty, rhs)
818808
},
819809
);
820810

821811
if define_opaque.is_some() {
822-
if body.is_some() {
812+
if rhs.is_some() {
823813
self.lower_define_opaque(hir_id, &define_opaque);
824814
} else {
825815
self.dcx().span_err(
@@ -829,7 +819,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
829819
}
830820
}
831821

832-
(*ident, generics, kind, body.is_some())
822+
(*ident, generics, kind, rhs.is_some())
833823
}
834824
AssocItemKind::Fn(box Fn {
835825
sig, ident, generics, body: None, define_opaque, ..
@@ -1016,12 +1006,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10161006

10171007
let (ident, (generics, kind)) = match &i.kind {
10181008
AssocItemKind::Const(box ConstItem {
1019-
ident,
1020-
generics,
1021-
ty,
1022-
body,
1023-
define_opaque,
1024-
..
1009+
ident, generics, ty, rhs, define_opaque, ..
10251010
}) => (
10261011
*ident,
10271012
self.lower_generics(
@@ -1032,8 +1017,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
10321017
let ty = this
10331018
.lower_ty(ty, ImplTraitContext::Disallowed(ImplTraitPosition::ConstTy));
10341019
this.lower_define_opaque(hir_id, &define_opaque);
1035-
let body = this.lower_const_item_rhs(attrs, body.as_ref(), i.span);
1036-
hir::ImplItemKind::Const(ty, body)
1020+
let rhs = this.lower_const_item_rhs(attrs, rhs.as_ref(), i.span);
1021+
hir::ImplItemKind::Const(ty, rhs)
10371022
},
10381023
),
10391024
),

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,9 +1239,9 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
12391239
}
12401240
});
12411241
}
1242-
ItemKind::Const(box ConstItem { defaultness, body, .. }) => {
1242+
ItemKind::Const(box ConstItem { defaultness, rhs, .. }) => {
12431243
self.check_defaultness(item.span, *defaultness);
1244-
if body.is_none() {
1244+
if rhs.is_none() {
12451245
self.dcx().emit_err(errors::ConstWithoutBody {
12461246
span: item.span,
12471247
replace_span: self.ending_semi_or_hi(item.span),
@@ -1581,7 +1581,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
15811581

15821582
if let AssocCtxt::Impl { .. } = ctxt {
15831583
match &item.kind {
1584-
AssocItemKind::Const(box ConstItem { body: None, .. }) => {
1584+
AssocItemKind::Const(box ConstItem { rhs: None, .. }) => {
15851585
self.dcx().emit_err(errors::AssocConstWithoutBody {
15861586
span: item.span,
15871587
replace_span: self.ending_semi_or_hi(item.span),

compiler/rustc_ast_pretty/src/pprust/state/item.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,15 +210,15 @@ impl<'a> State<'a> {
210210
ident,
211211
generics,
212212
ty,
213-
body,
213+
rhs,
214214
define_opaque,
215215
}) => {
216216
self.print_item_const(
217217
*ident,
218218
None,
219219
generics,
220220
ty,
221-
body.as_ref().map(|ct| ct.expr()),
221+
rhs.as_ref().map(|ct| ct.expr()),
222222
&item.vis,
223223
ast::Safety::Default,
224224
*defaultness,
@@ -566,15 +566,15 @@ impl<'a> State<'a> {
566566
ident,
567567
generics,
568568
ty,
569-
body,
569+
rhs,
570570
define_opaque,
571571
}) => {
572572
self.print_item_const(
573573
*ident,
574574
None,
575575
generics,
576576
ty,
577-
body.as_ref().map(|ct| ct.expr()),
577+
rhs.as_ref().map(|ct| ct.expr()),
578578
vis,
579579
ast::Safety::Default,
580580
*defaultness,

compiler/rustc_builtin_macros/src/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ pub(crate) fn expand_test_or_bench(
289289
ty: cx.ty(sp, ast::TyKind::Path(None, test_path("TestDescAndFn"))),
290290
define_opaque: None,
291291
// test::TestDescAndFn {
292-
body: Some(ast::ConstItemRhs::Body(
292+
rhs: Some(ast::ConstItemRhs::Body(
293293
cx.expr_struct(
294294
sp,
295295
test_path("TestDescAndFn"),

compiler/rustc_expand/src/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ impl<'a> ExtCtxt<'a> {
726726
span: Span,
727727
ident: Ident,
728728
ty: Box<ast::Ty>,
729-
body: ast::ConstItemRhs,
729+
rhs: ast::ConstItemRhs,
730730
) -> Box<ast::Item> {
731731
let defaultness = ast::Defaultness::Final;
732732
self.item(
@@ -739,7 +739,7 @@ impl<'a> ExtCtxt<'a> {
739739
// FIXME(generic_const_items): Pass the generics as a parameter.
740740
generics: ast::Generics::default(),
741741
ty,
742-
body: Some(body),
742+
rhs: Some(rhs),
743743
define_opaque: None,
744744
}
745745
.into(),

compiler/rustc_hir/src/hir.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3102,7 +3102,7 @@ impl<'hir> TraitItem<'hir> {
31023102

31033103
expect_methods_self_kind! {
31043104
expect_const, (&'hir Ty<'hir>, Option<ConstItemRhs<'hir>>),
3105-
TraitItemKind::Const(ty, body), (ty, *body);
3105+
TraitItemKind::Const(ty, rhs), (ty, *rhs);
31063106

31073107
expect_fn, (&FnSig<'hir>, &TraitFn<'hir>),
31083108
TraitItemKind::Fn(ty, trfn), (ty, trfn);
@@ -3195,9 +3195,9 @@ impl<'hir> ImplItem<'hir> {
31953195
}
31963196

31973197
expect_methods_self_kind! {
3198-
expect_const, (&'hir Ty<'hir>, ConstItemRhs<'hir>), ImplItemKind::Const(ty, body), (ty, *body);
3199-
expect_fn, (&FnSig<'hir>, BodyId), ImplItemKind::Fn(ty, body), (ty, *body);
3200-
expect_type, &'hir Ty<'hir>, ImplItemKind::Type(ty), ty;
3198+
expect_const, (&'hir Ty<'hir>, ConstItemRhs<'hir>), ImplItemKind::Const(ty, rhs), (ty, *rhs);
3199+
expect_fn, (&FnSig<'hir>, BodyId), ImplItemKind::Fn(ty, body), (ty, *body);
3200+
expect_type, &'hir Ty<'hir>, ImplItemKind::Type(ty), ty;
32013201
}
32023202
}
32033203

@@ -4136,7 +4136,7 @@ impl<'hir> Item<'hir> {
41364136
ItemKind::Static(mutbl, ident, ty, body), (*mutbl, *ident, ty, *body);
41374137

41384138
expect_const, (Ident, &'hir Generics<'hir>, &'hir Ty<'hir>, ConstItemRhs<'hir>),
4139-
ItemKind::Const(ident, generics, ty, ct_arg), (*ident, generics, ty, *ct_arg);
4139+
ItemKind::Const(ident, generics, ty, rhs), (*ident, generics, ty, *rhs);
41404140

41414141
expect_fn, (Ident, &FnSig<'hir>, &'hir Generics<'hir>, BodyId),
41424142
ItemKind::Fn { ident, sig, generics, body, .. }, (*ident, sig, generics, *body);

compiler/rustc_hir/src/intravisit.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -551,11 +551,11 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) -> V::
551551
try_visit!(visitor.visit_ty_unambig(typ));
552552
try_visit!(visitor.visit_nested_body(body));
553553
}
554-
ItemKind::Const(ident, ref generics, ref typ, body) => {
554+
ItemKind::Const(ident, ref generics, ref typ, rhs) => {
555555
try_visit!(visitor.visit_ident(ident));
556556
try_visit!(visitor.visit_generics(generics));
557557
try_visit!(visitor.visit_ty_unambig(typ));
558-
try_visit!(visitor.visit_const_item_rhs(body));
558+
try_visit!(visitor.visit_const_item_rhs(rhs));
559559
}
560560
ItemKind::Fn { ident, sig, generics, body: body_id, .. } => {
561561
try_visit!(visitor.visit_ident(ident));
@@ -1288,9 +1288,9 @@ pub fn walk_impl_item<'v, V: Visitor<'v>>(
12881288
}
12891289
}
12901290
match *kind {
1291-
ImplItemKind::Const(ref ty, body) => {
1291+
ImplItemKind::Const(ref ty, rhs) => {
12921292
try_visit!(visitor.visit_ty_unambig(ty));
1293-
visitor.visit_const_item_rhs(body)
1293+
visitor.visit_const_item_rhs(rhs)
12941294
}
12951295
ImplItemKind::Fn(ref sig, body_id) => visitor.visit_fn(
12961296
FnKind::Method(impl_item.ident, sig),

compiler/rustc_hir_analysis/src/collect/type_of.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,15 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_
158158
let args = ty::GenericArgs::identity_for_item(tcx, def_id);
159159
Ty::new_fn_def(tcx, def_id.to_def_id(), args)
160160
}
161-
TraitItemKind::Const(ty, body) => body
162-
.and_then(|ct_arg| {
161+
TraitItemKind::Const(ty, rhs) => rhs
162+
.and_then(|rhs| {
163163
ty.is_suggestable_infer_ty().then(|| {
164164
infer_placeholder_type(
165165
icx.lowerer(),
166166
def_id,
167-
ct_arg.hir_id(),
167+
rhs.hir_id(),
168168
ty.span,
169-
ct_arg.span(tcx),
169+
rhs.span(tcx),
170170
item.ident,
171171
"associated constant",
172172
)
@@ -184,14 +184,14 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_
184184
let args = ty::GenericArgs::identity_for_item(tcx, def_id);
185185
Ty::new_fn_def(tcx, def_id.to_def_id(), args)
186186
}
187-
ImplItemKind::Const(ty, ct_arg) => {
187+
ImplItemKind::Const(ty, rhs) => {
188188
if ty.is_suggestable_infer_ty() {
189189
infer_placeholder_type(
190190
icx.lowerer(),
191191
def_id,
192-
ct_arg.hir_id(),
192+
rhs.hir_id(),
193193
ty.span,
194-
ct_arg.span(tcx),
194+
rhs.span(tcx),
195195
item.ident,
196196
"associated constant",
197197
)
@@ -232,14 +232,14 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_
232232
}
233233
}
234234
}
235-
ItemKind::Const(ident, _, ty, body) => {
235+
ItemKind::Const(ident, _, ty, rhs) => {
236236
if ty.is_suggestable_infer_ty() {
237237
infer_placeholder_type(
238238
icx.lowerer(),
239239
def_id,
240-
body.hir_id(),
240+
rhs.hir_id(),
241241
ty.span,
242-
body.span(tcx),
242+
rhs.span(tcx),
243243
ident,
244244
"constant",
245245
)

compiler/rustc_lint/src/unused.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,8 +1032,8 @@ trait UnusedDelimLint {
10321032
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &ast::Item) {
10331033
use ast::ItemKind::*;
10341034

1035-
let expr = if let Const(box ast::ConstItem { body: Some(body), .. }) = &item.kind {
1036-
body.expr()
1035+
let expr = if let Const(box ast::ConstItem { rhs: Some(rhs), .. }) = &item.kind {
1036+
rhs.expr()
10371037
} else if let Static(box ast::StaticItem { expr: Some(expr), .. }) = &item.kind {
10381038
expr
10391039
} else {

0 commit comments

Comments
 (0)