mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Rename ast::StmtKind::Local
into ast::StmtKind::Let
This commit is contained in:
parent
6f3eb1ce3d
commit
ca9f0630a9
@ -1021,7 +1021,7 @@ impl Stmt {
|
||||
#[derive(Clone, Encodable, Decodable, Debug)]
|
||||
pub enum StmtKind {
|
||||
/// A local (let) binding.
|
||||
Local(P<Local>),
|
||||
Let(P<Local>),
|
||||
/// An item definition.
|
||||
Item(P<Item>),
|
||||
/// Expr without trailing semi-colon.
|
||||
|
@ -182,7 +182,7 @@ impl<T: HasTokens> HasTokens for Option<T> {
|
||||
impl HasTokens for StmtKind {
|
||||
fn tokens(&self) -> Option<&LazyAttrTokenStream> {
|
||||
match self {
|
||||
StmtKind::Local(local) => local.tokens.as_ref(),
|
||||
StmtKind::Let(local) => local.tokens.as_ref(),
|
||||
StmtKind::Item(item) => item.tokens(),
|
||||
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.tokens(),
|
||||
StmtKind::Empty => return None,
|
||||
@ -191,7 +191,7 @@ impl HasTokens for StmtKind {
|
||||
}
|
||||
fn tokens_mut(&mut self) -> Option<&mut Option<LazyAttrTokenStream>> {
|
||||
match self {
|
||||
StmtKind::Local(local) => Some(&mut local.tokens),
|
||||
StmtKind::Let(local) => Some(&mut local.tokens),
|
||||
StmtKind::Item(item) => item.tokens_mut(),
|
||||
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.tokens_mut(),
|
||||
StmtKind::Empty => return None,
|
||||
@ -355,7 +355,7 @@ impl HasAttrs for StmtKind {
|
||||
|
||||
fn attrs(&self) -> &[Attribute] {
|
||||
match self {
|
||||
StmtKind::Local(local) => &local.attrs,
|
||||
StmtKind::Let(local) => &local.attrs,
|
||||
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.attrs(),
|
||||
StmtKind::Item(item) => item.attrs(),
|
||||
StmtKind::Empty => &[],
|
||||
@ -365,7 +365,7 @@ impl HasAttrs for StmtKind {
|
||||
|
||||
fn visit_attrs(&mut self, f: impl FnOnce(&mut AttrVec)) {
|
||||
match self {
|
||||
StmtKind::Local(local) => f(&mut local.attrs),
|
||||
StmtKind::Let(local) => f(&mut local.attrs),
|
||||
StmtKind::Expr(expr) | StmtKind::Semi(expr) => expr.visit_attrs(f),
|
||||
StmtKind::Item(item) => item.visit_attrs(f),
|
||||
StmtKind::Empty => {}
|
||||
|
@ -1567,7 +1567,7 @@ pub fn noop_flat_map_stmt_kind<T: MutVisitor>(
|
||||
vis: &mut T,
|
||||
) -> SmallVec<[StmtKind; 1]> {
|
||||
match kind {
|
||||
StmtKind::Local(mut local) => smallvec![StmtKind::Local({
|
||||
StmtKind::Let(mut local) => smallvec![StmtKind::Let({
|
||||
vis.visit_local(&mut local);
|
||||
local
|
||||
})],
|
||||
|
@ -787,7 +787,7 @@ pub fn walk_block<'a, V: Visitor<'a>>(visitor: &mut V, block: &'a Block) -> V::R
|
||||
|
||||
pub fn walk_stmt<'a, V: Visitor<'a>>(visitor: &mut V, statement: &'a Stmt) -> V::Result {
|
||||
match &statement.kind {
|
||||
StmtKind::Local(local) => try_visit!(visitor.visit_local(local)),
|
||||
StmtKind::Let(local) => try_visit!(visitor.visit_local(local)),
|
||||
StmtKind::Item(item) => try_visit!(visitor.visit_item(item)),
|
||||
StmtKind::Expr(expr) | StmtKind::Semi(expr) => try_visit!(visitor.visit_expr(expr)),
|
||||
StmtKind::Empty => {}
|
||||
|
@ -32,7 +32,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||
let mut expr = None;
|
||||
while let [s, tail @ ..] = ast_stmts {
|
||||
match &s.kind {
|
||||
StmtKind::Local(local) => {
|
||||
StmtKind::Let(local) => {
|
||||
let hir_id = self.lower_node_id(s.id);
|
||||
let local = self.lower_local(local);
|
||||
self.alias_attrs(hir_id, local.hir_id);
|
||||
|
@ -1212,7 +1212,7 @@ impl<'a> State<'a> {
|
||||
fn print_stmt(&mut self, st: &ast::Stmt) {
|
||||
self.maybe_print_comment(st.span.lo());
|
||||
match &st.kind {
|
||||
ast::StmtKind::Local(loc) => {
|
||||
ast::StmtKind::Let(loc) => {
|
||||
self.print_outer_attributes(&loc.attrs);
|
||||
self.space_if_not_bol();
|
||||
self.ibox(INDENT_UNIT);
|
||||
|
@ -218,7 +218,7 @@ impl<'a> ExtCtxt<'a> {
|
||||
}
|
||||
|
||||
pub fn stmt_local(&self, local: P<ast::Local>, span: Span) -> ast::Stmt {
|
||||
ast::Stmt { id: ast::DUMMY_NODE_ID, kind: ast::StmtKind::Local(local), span }
|
||||
ast::Stmt { id: ast::DUMMY_NODE_ID, kind: ast::StmtKind::Let(local), span }
|
||||
}
|
||||
|
||||
pub fn stmt_item(&self, sp: Span, item: P<ast::Item>) -> ast::Stmt {
|
||||
|
@ -1389,7 +1389,7 @@ impl InvocationCollectorNode for ast::Stmt {
|
||||
StmtKind::Item(item) => matches!(item.kind, ItemKind::MacCall(..)),
|
||||
StmtKind::Semi(expr) => matches!(expr.kind, ExprKind::MacCall(..)),
|
||||
StmtKind::Expr(..) => unreachable!(),
|
||||
StmtKind::Local(..) | StmtKind::Empty => false,
|
||||
StmtKind::Let(..) | StmtKind::Empty => false,
|
||||
}
|
||||
}
|
||||
fn take_mac_call(self) -> (P<ast::MacCall>, Self::AttrsTy, AddSemicolon) {
|
||||
|
@ -989,7 +989,7 @@ fn warn_if_doc(cx: &EarlyContext<'_>, node_span: Span, node_kind: &str, attrs: &
|
||||
impl EarlyLintPass for UnusedDocComment {
|
||||
fn check_stmt(&mut self, cx: &EarlyContext<'_>, stmt: &ast::Stmt) {
|
||||
let kind = match stmt.kind {
|
||||
ast::StmtKind::Local(..) => "statements",
|
||||
ast::StmtKind::Let(..) => "statements",
|
||||
// Disabled pending discussion in #78306
|
||||
ast::StmtKind::Item(..) => return,
|
||||
// expressions will be reported by `check_expr`.
|
||||
|
@ -914,7 +914,7 @@ trait UnusedDelimLint {
|
||||
|
||||
fn check_stmt(&mut self, cx: &EarlyContext<'_>, s: &ast::Stmt) {
|
||||
match s.kind {
|
||||
StmtKind::Local(ref local) if Self::LINT_EXPR_IN_PATTERN_MATCHING_CTX => {
|
||||
StmtKind::Let(ref local) if Self::LINT_EXPR_IN_PATTERN_MATCHING_CTX => {
|
||||
if let Some((init, els)) = local.kind.init_else_opt() {
|
||||
let ctx = match els {
|
||||
None => UnusedDelimsCtx::AssignedValue,
|
||||
@ -1189,7 +1189,7 @@ impl EarlyLintPass for UnusedParens {
|
||||
}
|
||||
|
||||
fn check_stmt(&mut self, cx: &EarlyContext<'_>, s: &ast::Stmt) {
|
||||
if let StmtKind::Local(ref local) = s.kind {
|
||||
if let StmtKind::Let(ref local) = s.kind {
|
||||
self.check_unused_parens_pat(cx, &local.pat, true, false, (true, false));
|
||||
}
|
||||
|
||||
|
@ -254,7 +254,7 @@ impl<'a> Parser<'a> {
|
||||
let local = this.parse_local(attrs)?;
|
||||
// FIXME - maybe capture semicolon in recovery?
|
||||
Ok((
|
||||
this.mk_stmt(lo.to(this.prev_token.span), StmtKind::Local(local)),
|
||||
this.mk_stmt(lo.to(this.prev_token.span), StmtKind::Let(local)),
|
||||
TrailingToken::None,
|
||||
))
|
||||
})?;
|
||||
@ -278,7 +278,7 @@ impl<'a> Parser<'a> {
|
||||
} else {
|
||||
TrailingToken::None
|
||||
};
|
||||
Ok((this.mk_stmt(lo.to(this.prev_token.span), StmtKind::Local(local)), trailing))
|
||||
Ok((this.mk_stmt(lo.to(this.prev_token.span), StmtKind::Let(local)), trailing))
|
||||
})
|
||||
}
|
||||
|
||||
@ -764,7 +764,7 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
}
|
||||
StmtKind::Expr(_) | StmtKind::MacCall(_) => {}
|
||||
StmtKind::Local(local) if let Err(mut e) = self.expect_semi() => {
|
||||
StmtKind::Let(local) if let Err(mut e) = self.expect_semi() => {
|
||||
// We might be at the `,` in `let x = foo<bar, baz>;`. Try to recover.
|
||||
match &mut local.kind {
|
||||
LocalKind::Init(expr) | LocalKind::InitElse(expr, _) => {
|
||||
@ -820,7 +820,7 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
eat_semi = false;
|
||||
}
|
||||
StmtKind::Empty | StmtKind::Item(_) | StmtKind::Local(_) | StmtKind::Semi(_) => {
|
||||
StmtKind::Empty | StmtKind::Item(_) | StmtKind::Let(_) | StmtKind::Semi(_) => {
|
||||
eat_semi = false
|
||||
}
|
||||
}
|
||||
|
@ -539,7 +539,7 @@ impl<'v> ast_visit::Visitor<'v> for StatCollector<'v> {
|
||||
fn visit_stmt(&mut self, s: &'v ast::Stmt) {
|
||||
record_variants!(
|
||||
(self, s, s.kind, Id::None, ast, Stmt, StmtKind),
|
||||
[Local, Item, Expr, Semi, Empty, MacCall]
|
||||
[Let, Item, Expr, Semi, Empty, MacCall]
|
||||
);
|
||||
ast_visit::walk_stmt(self, s)
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ pub fn eq_block(l: &Block, r: &Block) -> bool {
|
||||
pub fn eq_stmt(l: &Stmt, r: &Stmt) -> bool {
|
||||
use StmtKind::*;
|
||||
match (&l.kind, &r.kind) {
|
||||
(Local(l), Local(r)) => {
|
||||
(Let(l), Let(r)) => {
|
||||
eq_pat(&l.pat, &r.pat)
|
||||
&& both(&l.ty, &r.ty, |l, r| eq_ty(l, r))
|
||||
&& eq_local_kind(&l.kind, &r.kind)
|
||||
|
@ -26,7 +26,7 @@ pub(crate) fn get_attrs_from_stmt(stmt: &ast::Stmt) -> &[ast::Attribute] {
|
||||
|
||||
pub(crate) fn get_span_without_attrs(stmt: &ast::Stmt) -> Span {
|
||||
match stmt.kind {
|
||||
ast::StmtKind::Local(ref local) => local.span,
|
||||
ast::StmtKind::Let(ref local) => local.span,
|
||||
ast::StmtKind::Item(ref item) => item.span,
|
||||
ast::StmtKind::Expr(ref expr) | ast::StmtKind::Semi(ref expr) => expr.span,
|
||||
ast::StmtKind::MacCall(ref mac_stmt) => mac_stmt.mac.span(),
|
||||
|
@ -61,7 +61,7 @@ implement_spanned!(ast::Local);
|
||||
impl Spanned for ast::Stmt {
|
||||
fn span(&self) -> Span {
|
||||
match self.kind {
|
||||
ast::StmtKind::Local(ref local) => mk_sp(local.span().lo(), self.span.hi()),
|
||||
ast::StmtKind::Let(ref local) => mk_sp(local.span().lo(), self.span.hi()),
|
||||
ast::StmtKind::Item(ref item) => mk_sp(item.span().lo(), self.span.hi()),
|
||||
ast::StmtKind::Expr(ref expr) | ast::StmtKind::Semi(ref expr) => {
|
||||
mk_sp(expr.span().lo(), self.span.hi())
|
||||
|
@ -115,7 +115,7 @@ fn format_stmt(
|
||||
skip_out_of_file_lines_range!(context, stmt.span());
|
||||
|
||||
let result = match stmt.kind {
|
||||
ast::StmtKind::Local(ref local) => local.rewrite(context, shape),
|
||||
ast::StmtKind::Let(ref local) => local.rewrite(context, shape),
|
||||
ast::StmtKind::Expr(ref ex) | ast::StmtKind::Semi(ref ex) => {
|
||||
let suffix = if semicolon_for_stmt(context, stmt, is_last_expr) {
|
||||
";"
|
||||
|
@ -150,7 +150,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
|
||||
self.visit_item(item);
|
||||
self.last_pos = stmt.span().hi();
|
||||
}
|
||||
ast::StmtKind::Local(..) | ast::StmtKind::Expr(..) | ast::StmtKind::Semi(..) => {
|
||||
ast::StmtKind::Let(..) | ast::StmtKind::Expr(..) | ast::StmtKind::Semi(..) => {
|
||||
let attrs = get_attrs_from_stmt(stmt.as_ast_node());
|
||||
if contains_skip(attrs) {
|
||||
self.push_skipped_with_span(
|
||||
|
Loading…
Reference in New Issue
Block a user