Skip to content

Commit ca9f063

Browse files
Rename ast::StmtKind::Local into ast::StmtKind::Let
1 parent 6f3eb1c commit ca9f063

File tree

17 files changed

+24
-24
lines changed

17 files changed

+24
-24
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ impl Stmt {
10211021
#[derive(Clone, Encodable, Decodable, Debug)]
10221022
pub enum StmtKind {
10231023
/// A local (let) binding.
1024-
Local(P<Local>),
1024+
Let(P<Local>),
10251025
/// An item definition.
10261026
Item(P<Item>),
10271027
/// Expr without trailing semi-colon.

compiler/rustc_ast/src/ast_traits.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl<T: HasTokens> HasTokens for Option<T> {
182182
impl HasTokens for StmtKind {
183183
fn tokens(&self) -> Option<&LazyAttrTokenStream> {
184184
match self {
185-
StmtKind::Local(local) => local.tokens.as_ref(),
185+
StmtKind::Let(local) => local.tokens.as_ref(),
186186
StmtKind::Item(item) => item.tokens(),
187187
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.tokens(),
188188
StmtKind::Empty => return None,
@@ -191,7 +191,7 @@ impl HasTokens for StmtKind {
191191
}
192192
fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>> {
193193
match self {
194-
StmtKind::Local(local) => Some(&mut local.tokens),
194+
StmtKind::Let(local) => Some(&mut local.tokens),
195195
StmtKind::Item(item) => item.tokens_mut(),
196196
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.tokens_mut(),
197197
StmtKind::Empty => return None,
@@ -355,7 +355,7 @@ impl HasAttrs for StmtKind {
355355

356356
fn attrs(&self) -> &[Attribute] {
357357
match self {
358-
StmtKind::Local(local) => &local.attrs,
358+
StmtKind::Let(local) => &local.attrs,
359359
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.attrs(),
360360
StmtKind::Item(item) => item.attrs(),
361361
StmtKind::Empty => &[],
@@ -365,7 +365,7 @@ impl HasAttrs for StmtKind {
365365

366366
fn visit_attrs(&mut self, f: impl FnOnce(&mut AttrVec)) {
367367
match self {
368-
StmtKind::Local(local) => f(&mut local.attrs),
368+
StmtKind::Let(local) => f(&mut local.attrs),
369369
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.visit_attrs(f),
370370
StmtKind::Item(item) => item.visit_attrs(f),
371371
StmtKind::Empty => {}

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,7 @@ pub fn noop_flat_map_stmt_kind<T: MutVisitor>(
15671567
vis: &mut T,
15681568
) -> SmallVec<[StmtKind; 1]> {
15691569
match kind {
1570-
StmtKind::Local(mut local) => smallvec![StmtKind::Local({
1570+
StmtKind::Let(mut local) => smallvec![StmtKind::Let({
15711571
vis.visit_local(&mut local);
15721572
local
15731573
})],

compiler/rustc_ast/src/visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ pub fn walk_block<'a, V: Visitor<'a>>(visitor: &mut V, block: &'a Block) -> V::R
787787

788788
pub fn walk_stmt<'a, V: Visitor<'a>>(visitor: &mut V, statement: &'a Stmt) -> V::Result {
789789
match &statement.kind {
790-
StmtKind::Local(local) => try_visit!(visitor.visit_local(local)),
790+
StmtKind::Let(local) => try_visit!(visitor.visit_local(local)),
791791
StmtKind::Item(item) => try_visit!(visitor.visit_item(item)),
792792
StmtKind::Expr(expr) | StmtKind::Semi(expr) => try_visit!(visitor.visit_expr(expr)),
793793
StmtKind::Empty => {}

compiler/rustc_ast_lowering/src/block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
3232
let mut expr = None;
3333
while let [s, tail @ ..] = ast_stmts {
3434
match &s.kind {
35-
StmtKind::Local(local) => {
35+
StmtKind::Let(local) => {
3636
let hir_id = self.lower_node_id(s.id);
3737
let local = self.lower_local(local);
3838
self.alias_attrs(hir_id, local.hir_id);

compiler/rustc_ast_pretty/src/pprust/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ impl<'a> State<'a> {
12121212
fn print_stmt(&mut self, st: &ast::Stmt) {
12131213
self.maybe_print_comment(st.span.lo());
12141214
match &st.kind {
1215-
ast::StmtKind::Local(loc) => {
1215+
ast::StmtKind::Let(loc) => {
12161216
self.print_outer_attributes(&loc.attrs);
12171217
self.space_if_not_bol();
12181218
self.ibox(INDENT_UNIT);

compiler/rustc_expand/src/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ impl<'a> ExtCtxt<'a> {
218218
}
219219

220220
pub fn stmt_local(&self, local: P<ast::Local>, span: Span) -> ast::Stmt {
221-
ast::Stmt { id: ast::DUMMY_NODE_ID, kind: ast::StmtKind::Local(local), span }
221+
ast::Stmt { id: ast::DUMMY_NODE_ID, kind: ast::StmtKind::Let(local), span }
222222
}
223223

224224
pub fn stmt_item(&self, sp: Span, item: P<ast::Item>) -> ast::Stmt {

compiler/rustc_expand/src/expand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ impl InvocationCollectorNode for ast::Stmt {
13891389
StmtKind::Item(item) => matches!(item.kind, ItemKind::MacCall(..)),
13901390
StmtKind::Semi(expr) => matches!(expr.kind, ExprKind::MacCall(..)),
13911391
StmtKind::Expr(..) => unreachable!(),
1392-
StmtKind::Local(..) | StmtKind::Empty => false,
1392+
StmtKind::Let(..) | StmtKind::Empty => false,
13931393
}
13941394
}
13951395
fn take_mac_call(self) -> (P<ast::MacCall>, Self::AttrsTy, AddSemicolon) {

compiler/rustc_lint/src/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -989,7 +989,7 @@ fn warn_if_doc(cx: &EarlyContext<'_>, node_span: Span, node_kind: &str, attrs: &
989989
impl EarlyLintPass for UnusedDocComment {
990990
fn check_stmt(&mut self, cx: &EarlyContext<'_>, stmt: &ast::Stmt) {
991991
let kind = match stmt.kind {
992-
ast::StmtKind::Local(..) => "statements",
992+
ast::StmtKind::Let(..) => "statements",
993993
// Disabled pending discussion in #78306
994994
ast::StmtKind::Item(..) => return,
995995
// expressions will be reported by `check_expr`.

compiler/rustc_lint/src/unused.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ trait UnusedDelimLint {
914914

915915
fn check_stmt(&mut self, cx: &EarlyContext<'_>, s: &ast::Stmt) {
916916
match s.kind {
917-
StmtKind::Local(ref local) if Self::LINT_EXPR_IN_PATTERN_MATCHING_CTX => {
917+
StmtKind::Let(ref local) if Self::LINT_EXPR_IN_PATTERN_MATCHING_CTX => {
918918
if let Some((init, els)) = local.kind.init_else_opt() {
919919
let ctx = match els {
920920
None => UnusedDelimsCtx::AssignedValue,
@@ -1189,7 +1189,7 @@ impl EarlyLintPass for UnusedParens {
11891189
}
11901190

11911191
fn check_stmt(&mut self, cx: &EarlyContext<'_>, s: &ast::Stmt) {
1192-
if let StmtKind::Local(ref local) = s.kind {
1192+
if let StmtKind::Let(ref local) = s.kind {
11931193
self.check_unused_parens_pat(cx, &local.pat, true, false, (true, false));
11941194
}
11951195

compiler/rustc_parse/src/parser/stmt.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ impl<'a> Parser<'a> {
254254
let local = this.parse_local(attrs)?;
255255
// FIXME - maybe capture semicolon in recovery?
256256
Ok((
257-
this.mk_stmt(lo.to(this.prev_token.span), StmtKind::Local(local)),
257+
this.mk_stmt(lo.to(this.prev_token.span), StmtKind::Let(local)),
258258
TrailingToken::None,
259259
))
260260
})?;
@@ -278,7 +278,7 @@ impl<'a> Parser<'a> {
278278
} else {
279279
TrailingToken::None
280280
};
281-
Ok((this.mk_stmt(lo.to(this.prev_token.span), StmtKind::Local(local)), trailing))
281+
Ok((this.mk_stmt(lo.to(this.prev_token.span), StmtKind::Let(local)), trailing))
282282
})
283283
}
284284

@@ -764,7 +764,7 @@ impl<'a> Parser<'a> {
764764
}
765765
}
766766
StmtKind::Expr(_) | StmtKind::MacCall(_) => {}
767-
StmtKind::Local(local) if let Err(mut e) = self.expect_semi() => {
767+
StmtKind::Let(local) if let Err(mut e) = self.expect_semi() => {
768768
// We might be at the `,` in `let x = foo<bar, baz>;`. Try to recover.
769769
match &mut local.kind {
770770
LocalKind::Init(expr) | LocalKind::InitElse(expr, _) => {
@@ -820,7 +820,7 @@ impl<'a> Parser<'a> {
820820
}
821821
eat_semi = false;
822822
}
823-
StmtKind::Empty | StmtKind::Item(_) | StmtKind::Local(_) | StmtKind::Semi(_) => {
823+
StmtKind::Empty | StmtKind::Item(_) | StmtKind::Let(_) | StmtKind::Semi(_) => {
824824
eat_semi = false
825825
}
826826
}

compiler/rustc_passes/src/hir_stats.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> {
539539
fn visit_stmt(&mut self, s: &'v ast::Stmt) {
540540
record_variants!(
541541
(self, s, s.kind, Id::None, ast, Stmt, StmtKind),
542-
[Local, Item, Expr, Semi, Empty, MacCall]
542+
[Let, Item, Expr, Semi, Empty, MacCall]
543543
);
544544
ast_visit::walk_stmt(self, s)
545545
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ pub fn eq_block(l: &Block, r: &Block) -> bool {
267267
pub fn eq_stmt(l: &Stmt, r: &Stmt) -> bool {
268268
use StmtKind::*;
269269
match (&l.kind, &r.kind) {
270-
(Local(l), Local(r)) => {
270+
(Let(l), Let(r)) => {
271271
eq_pat(&l.pat, &r.pat)
272272
&& both(&l.ty, &r.ty, |l, r| eq_ty(l, r))
273273
&& eq_local_kind(&l.kind, &r.kind)

src/tools/rustfmt/src/attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub(crate) fn get_attrs_from_stmt(stmt: &ast::Stmt) -> &[ast::Attribute] {
2626

2727
pub(crate) fn get_span_without_attrs(stmt: &ast::Stmt) -> Span {
2828
match stmt.kind {
29-
ast::StmtKind::Local(ref local) => local.span,
29+
ast::StmtKind::Let(ref local) => local.span,
3030
ast::StmtKind::Item(ref item) => item.span,
3131
ast::StmtKind::Expr(ref expr) | ast::StmtKind::Semi(ref expr) => expr.span,
3232
ast::StmtKind::MacCall(ref mac_stmt) => mac_stmt.mac.span(),

src/tools/rustfmt/src/spanned.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ implement_spanned!(ast::Local);
6161
impl Spanned for ast::Stmt {
6262
fn span(&self) -> Span {
6363
match self.kind {
64-
ast::StmtKind::Local(ref local) => mk_sp(local.span().lo(), self.span.hi()),
64+
ast::StmtKind::Let(ref local) => mk_sp(local.span().lo(), self.span.hi()),
6565
ast::StmtKind::Item(ref item) => mk_sp(item.span().lo(), self.span.hi()),
6666
ast::StmtKind::Expr(ref expr) | ast::StmtKind::Semi(ref expr) => {
6767
mk_sp(expr.span().lo(), self.span.hi())

src/tools/rustfmt/src/stmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ fn format_stmt(
115115
skip_out_of_file_lines_range!(context, stmt.span());
116116

117117
let result = match stmt.kind {
118-
ast::StmtKind::Local(ref local) => local.rewrite(context, shape),
118+
ast::StmtKind::Let(ref local) => local.rewrite(context, shape),
119119
ast::StmtKind::Expr(ref ex) | ast::StmtKind::Semi(ref ex) => {
120120
let suffix = if semicolon_for_stmt(context, stmt, is_last_expr) {
121121
";"

src/tools/rustfmt/src/visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
150150
self.visit_item(item);
151151
self.last_pos = stmt.span().hi();
152152
}
153-
ast::StmtKind::Local(..) | ast::StmtKind::Expr(..) | ast::StmtKind::Semi(..) => {
153+
ast::StmtKind::Let(..) | ast::StmtKind::Expr(..) | ast::StmtKind::Semi(..) => {
154154
let attrs = get_attrs_from_stmt(stmt.as_ast_node());
155155
if contains_skip(attrs) {
156156
self.push_skipped_with_span(

0 commit comments

Comments
 (0)