Skip to content

Commit 373807a

Browse files
committed
Rename ast::Static to ast::StaticItem to match ast::ConstItem
1 parent 4bebdd7 commit 373807a

File tree

15 files changed

+68
-68
lines changed

15 files changed

+68
-68
lines changed

compiler/rustc_ast/src/ast.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2891,7 +2891,7 @@ pub struct Fn {
28912891
}
28922892

28932893
#[derive(Clone, Encodable, Decodable, Debug)]
2894-
pub struct Static {
2894+
pub struct StaticItem {
28952895
pub ty: P<Ty>,
28962896
pub mutability: Mutability,
28972897
pub expr: Option<P<Expr>>,
@@ -2917,7 +2917,7 @@ pub enum ItemKind {
29172917
/// A static item (`static`).
29182918
///
29192919
/// E.g., `static FOO: i32 = 42;` or `static FOO: &'static str = "bar";`.
2920-
Static(Box<Static>),
2920+
Static(Box<StaticItem>),
29212921
/// A constant item (`const`).
29222922
///
29232923
/// E.g., `const FOO: i32 = 42;`.
@@ -3099,7 +3099,7 @@ impl From<ForeignItemKind> for ItemKind {
30993099
fn from(foreign_item_kind: ForeignItemKind) -> ItemKind {
31003100
match foreign_item_kind {
31013101
ForeignItemKind::Static(a, b, c) => {
3102-
ItemKind::Static(Static { ty: a, mutability: b, expr: c }.into())
3102+
ItemKind::Static(StaticItem { ty: a, mutability: b, expr: c }.into())
31033103
}
31043104
ForeignItemKind::Fn(fn_kind) => ItemKind::Fn(fn_kind),
31053105
ForeignItemKind::TyAlias(ty_alias_kind) => ItemKind::TyAlias(ty_alias_kind),
@@ -3113,7 +3113,7 @@ impl TryFrom<ItemKind> for ForeignItemKind {
31133113

31143114
fn try_from(item_kind: ItemKind) -> Result<ForeignItemKind, ItemKind> {
31153115
Ok(match item_kind {
3116-
ItemKind::Static(box Static { ty: a, mutability: b, expr: c }) => {
3116+
ItemKind::Static(box StaticItem { ty: a, mutability: b, expr: c }) => {
31173117
ForeignItemKind::Static(a, b, c)
31183118
}
31193119
ItemKind::Fn(fn_kind) => ForeignItemKind::Fn(fn_kind),

compiler/rustc_ast/src/mut_visit.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use crate::ptr::P;
1111
use crate::token::{self, Token};
1212
use crate::tokenstream::*;
13-
use crate::{ast::*, Static};
13+
use crate::{ast::*, StaticItem};
1414

1515
use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
1616
use rustc_data_structures::sync::Lrc;
@@ -1030,7 +1030,7 @@ pub fn noop_visit_item_kind<T: MutVisitor>(kind: &mut ItemKind, vis: &mut T) {
10301030
match kind {
10311031
ItemKind::ExternCrate(_orig_name) => {}
10321032
ItemKind::Use(use_tree) => vis.visit_use_tree(use_tree),
1033-
ItemKind::Static(box Static { ty, mutability: _, expr }) => {
1033+
ItemKind::Static(box StaticItem { ty, mutability: _, expr }) => {
10341034
vis.visit_ty(ty);
10351035
visit_opt(expr, |expr| vis.visit_expr(expr));
10361036
}

compiler/rustc_ast/src/visit.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//! instance, a walker looking for item names in a module will miss all of
1414
//! those that are created by the expansion of a macro.
1515
16-
use crate::{ast::*, Static};
16+
use crate::{ast::*, StaticItem};
1717

1818
use rustc_span::symbol::Ident;
1919
use rustc_span::Span;
@@ -305,7 +305,7 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) {
305305
match &item.kind {
306306
ItemKind::ExternCrate(_) => {}
307307
ItemKind::Use(use_tree) => visitor.visit_use_tree(use_tree, item.id, false),
308-
ItemKind::Static(box Static { ty, mutability: _, expr })
308+
ItemKind::Static(box StaticItem { ty, mutability: _, expr })
309309
| ItemKind::Const(box ConstItem { ty, expr, .. }) => {
310310
visitor.visit_ty(ty);
311311
walk_list!(visitor, visit_expr, expr);

compiler/rustc_ast_lowering/src/item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
229229

230230
self.lower_use_tree(use_tree, &prefix, id, vis_span, ident, attrs)
231231
}
232-
ItemKind::Static(box ast::Static { ty: t, mutability: m, expr: e }) => {
232+
ItemKind::Static(box ast::StaticItem { ty: t, mutability: m, expr: e }) => {
233233
let (ty, body_id) = self.lower_const_item(t, span, e.as_deref());
234234
hir::ItemKind::Static(ty, *m, body_id)
235235
}

compiler/rustc_ast_passes/src/ast_validation.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use itertools::{Either, Itertools};
1010
use rustc_ast::ptr::P;
1111
use rustc_ast::visit::{self, AssocCtxt, BoundKind, FnCtxt, FnKind, Visitor};
1212
use rustc_ast::*;
13-
use rustc_ast::{walk_list, Static};
13+
use rustc_ast::{walk_list, StaticItem};
1414
use rustc_ast_pretty::pprust::{self, State};
1515
use rustc_data_structures::fx::FxIndexMap;
1616
use rustc_macros::Subdiagnostic;
@@ -990,7 +990,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
990990
replace_span: self.ending_semi_or_hi(item.span),
991991
});
992992
}
993-
ItemKind::Static(box Static { expr: None, .. }) => {
993+
ItemKind::Static(box StaticItem { expr: None, .. }) => {
994994
self.session.emit_err(errors::StaticWithoutBody {
995995
span: item.span,
996996
replace_span: self.ending_semi_or_hi(item.span),

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::pp::Breaks::Inconsistent;
22
use crate::pprust::state::delimited::IterDelimited;
33
use crate::pprust::state::{AnnNode, PrintState, State, INDENT_UNIT};
44

5-
use ast::Static;
5+
use ast::StaticItem;
66
use rustc_ast as ast;
77
use rustc_ast::GenericBound;
88
use rustc_ast::ModKind;
@@ -157,7 +157,7 @@ impl<'a> State<'a> {
157157
self.print_use_tree(tree);
158158
self.word(";");
159159
}
160-
ast::ItemKind::Static(box Static { ty, mutability: mutbl, expr: body }) => {
160+
ast::ItemKind::Static(box StaticItem { ty, mutability: mutbl, expr: body }) => {
161161
let def = ast::Defaultness::Final;
162162
self.print_item_const(
163163
item.ident,

compiler/rustc_builtin_macros/src/global_allocator.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ pub fn expand(
2525
// FIXME - if we get deref patterns, use them to reduce duplication here
2626
let (item, is_stmt, ty_span) =
2727
if let Annotatable::Item(item) = &item
28-
&& let ItemKind::Static(box ast::Static { ty, ..}) = &item.kind
28+
&& let ItemKind::Static(box ast::StaticItem { ty, ..}) = &item.kind
2929
{
3030
(item, false, ecx.with_def_site_ctxt(ty.span))
3131
} else if let Annotatable::Stmt(stmt) = &item
3232
&& let StmtKind::Item(item) = &stmt.kind
33-
&& let ItemKind::Static(box ast::Static { ty, ..}) = &item.kind
33+
&& let ItemKind::Static(box ast::StaticItem { ty, ..}) = &item.kind
3434
{
3535
(item, true, ecx.with_def_site_ctxt(ty.span))
3636
} else {

compiler/rustc_expand/src/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ impl<'a> ExtCtxt<'a> {
627627
span,
628628
name,
629629
AttrVec::new(),
630-
ast::ItemKind::Static(ast::Static { ty, mutability, expr: Some(expr) }.into()),
630+
ast::ItemKind::Static(ast::StaticItem { ty, mutability, expr: Some(expr) }.into()),
631631
)
632632
}
633633

compiler/rustc_lint/src/unused.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ trait UnusedDelimLint {
806806
use ast::ItemKind::*;
807807

808808
if let Const(box ast::ConstItem { expr: Some(expr), .. })
809-
| Static(box ast::Static { expr: Some(expr), .. }) = &item.kind
809+
| Static(box ast::StaticItem { expr: Some(expr), .. }) = &item.kind
810810
{
811811
self.check_unused_delims_expr(
812812
cx,

compiler/rustc_parse/src/parser/item.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::errors;
33
use super::diagnostics::{dummy_arg, ConsumeClosingDelim};
44
use super::ty::{AllowPlus, RecoverQPath, RecoverReturnSign};
55
use super::{AttrWrapper, FollowedByType, ForceCollect, Parser, PathStyle, TrailingToken};
6-
use ast::Static;
6+
use ast::StaticItem;
77
use rustc_ast::ast::*;
88
use rustc_ast::ptr::P;
99
use rustc_ast::token::{self, Delimiter, TokenKind};
@@ -228,7 +228,7 @@ impl<'a> Parser<'a> {
228228
self.bump(); // `static`
229229
let m = self.parse_mutability();
230230
let (ident, ty, expr) = self.parse_item_global(Some(m))?;
231-
(ident, ItemKind::Static(Box::new(Static { ty, mutability: m, expr })))
231+
(ident, ItemKind::Static(Box::new(StaticItem { ty, mutability: m, expr })))
232232
} else if let Const::Yes(const_span) = self.parse_constness(Case::Sensitive) {
233233
// CONST ITEM
234234
if self.token.is_keyword(kw::Impl) {
@@ -863,7 +863,7 @@ impl<'a> Parser<'a> {
863863
let kind = match AssocItemKind::try_from(kind) {
864864
Ok(kind) => kind,
865865
Err(kind) => match kind {
866-
ItemKind::Static(box Static { ty, mutability: _, expr }) => {
866+
ItemKind::Static(box StaticItem { ty, mutability: _, expr }) => {
867867
self.sess.emit_err(errors::AssociatedStaticItemNotAllowed { span });
868868
AssocItemKind::Const(Box::new(ConstItem {
869869
defaultness: Defaultness::Final,

compiler/rustc_resolve/src/build_reduced_graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ impl<'a, 'b, 'tcx> BuildReducedGraphVisitor<'a, 'b, 'tcx> {
688688
}
689689

690690
// These items live in the value namespace.
691-
ItemKind::Static(box ast::Static { mutability, .. }) => {
691+
ItemKind::Static(box ast::StaticItem { mutability, .. }) => {
692692
let res = Res::Def(DefKind::Static(mutability), def_id);
693693
self.r.define(parent, ident, ValueNS, (res, vis, sp, expansion));
694694
}

compiler/rustc_resolve/src/late.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2346,7 +2346,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
23462346
});
23472347
}
23482348

2349-
ItemKind::Static(box ast::Static { ref ty, ref expr, .. })
2349+
ItemKind::Static(box ast::StaticItem { ref ty, ref expr, .. })
23502350
| ItemKind::Const(box ast::ConstItem { ref ty, ref expr, .. }) => {
23512351
self.with_static_rib(|this| {
23522352
this.with_lifetime_rib(LifetimeRibKind::Elided(LifetimeRes::Static), |this| {

src/tools/clippy/clippy_lints/src/redundant_static_lifetimes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::span_lint_and_then;
22
use clippy_utils::msrvs::{self, Msrv};
33
use clippy_utils::source::snippet;
4-
use rustc_ast::ast::{Item, ItemKind, Ty, TyKind, Static, ConstItem};
4+
use rustc_ast::ast::{Item, ItemKind, Ty, TyKind, StaticItem, ConstItem};
55
use rustc_errors::Applicability;
66
use rustc_lint::{EarlyContext, EarlyLintPass};
77
use rustc_session::{declare_tool_lint, impl_lint_pass};
@@ -106,7 +106,7 @@ impl EarlyLintPass for RedundantStaticLifetimes {
106106
// #2438)
107107
}
108108

109-
if let ItemKind::Static(box Static { ty: ref var_type,.. }) = item.kind {
109+
if let ItemKind::Static(box StaticItem { ty: ref var_type,.. }) = item.kind {
110110
Self::visit_type(var_type, cx, "statics have by default a `'static` lifetime");
111111
}
112112
}

src/tools/clippy/clippy_utils/src/ast_utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
286286
match (l, r) {
287287
(ExternCrate(l), ExternCrate(r)) => l == r,
288288
(Use(l), Use(r)) => eq_use_tree(l, r),
289-
(Static(box ast::Static{ ty: lt, mutability: lm, expr: le}), Static(box ast::Static { ty: rt, mutability: rm, expr: re})) => lm == rm && eq_ty(lt, rt) && eq_expr_opt(le, re),
289+
(Static(box ast::StaticItem { ty: lt, mutability: lm, expr: le}), Static(box ast::StaticItem { ty: rt, mutability: rm, expr: re})) => lm == rm && eq_ty(lt, rt) && eq_expr_opt(le, re),
290290
(Const(box ast::ConstItem { defaultness: ld, ty: lt, expr: le}), Const(box ast::ConstItem { defaultness: rd, ty: rt, expr: re} )) => eq_defaultness(*ld, *rd) && eq_ty(lt, rt) && eq_expr_opt(le, re),
291291
(
292292
Fn(box ast::Fn {

0 commit comments

Comments
 (0)