Skip to content

Commit

Permalink
Auto merge of #96924 - petrochenkov:nonon, r=nnethercote
Browse files Browse the repository at this point in the history
ast: Introduce some traits to get AST node properties generically

And use them to avoid constructing some artificial `Nonterminal` tokens during expansion
r? `@nnethercote` `@Aaron1011`
  • Loading branch information
bors committed May 11, 2022
2 parents f296b9a + f2b7fa4 commit a85de16
Show file tree
Hide file tree
Showing 24 changed files with 593 additions and 500 deletions.
17 changes: 0 additions & 17 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -929,16 +929,6 @@ pub struct Stmt {
}

impl Stmt {
pub fn tokens(&self) -> Option<&LazyTokenStream> {
match self.kind {
StmtKind::Local(ref local) => local.tokens.as_ref(),
StmtKind::Item(ref item) => item.tokens.as_ref(),
StmtKind::Expr(ref expr) | StmtKind::Semi(ref expr) => expr.tokens.as_ref(),
StmtKind::Empty => None,
StmtKind::MacCall(ref mac) => mac.tokens.as_ref(),
}
}

pub fn has_trailing_semicolon(&self) -> bool {
match &self.kind {
StmtKind::Semi(_) => true,
Expand Down Expand Up @@ -2684,13 +2674,6 @@ impl Item {
}
}

impl<K: Into<ItemKind>> Item<K> {
pub fn into_item(self) -> Item {
let Item { attrs, id, span, vis, ident, kind, tokens } = self;
Item { attrs, id, span, vis, ident, kind: kind.into(), tokens }
}
}

/// `extern` qualifier on a function item or function type.
#[derive(Clone, Copy, Encodable, Decodable, Debug)]
pub enum Extern {
Expand Down
320 changes: 0 additions & 320 deletions compiler/rustc_ast/src/ast_like.rs

This file was deleted.

Loading

0 comments on commit a85de16

Please sign in to comment.