mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
[breaking-change] don't glob export ast::Decl_ variants
This commit is contained in:
parent
8516ba367d
commit
79fa657abc
@ -247,11 +247,11 @@ pub fn lower_arm(lctx: &LoweringContext, arm: &Arm) -> hir::Arm {
|
||||
|
||||
pub fn lower_decl(lctx: &LoweringContext, d: &Decl) -> P<hir::Decl> {
|
||||
match d.node {
|
||||
DeclLocal(ref l) => P(Spanned {
|
||||
DeclKind::Local(ref l) => P(Spanned {
|
||||
node: hir::DeclLocal(lower_local(lctx, l)),
|
||||
span: d.span,
|
||||
}),
|
||||
DeclItem(ref it) => P(Spanned {
|
||||
DeclKind::Item(ref it) => P(Spanned {
|
||||
node: hir::DeclItem(lower_item_id(lctx, it)),
|
||||
span: d.span,
|
||||
}),
|
||||
|
@ -365,7 +365,7 @@ impl EarlyLintPass for UnusedParens {
|
||||
fn check_stmt(&mut self, cx: &EarlyContext, s: &ast::Stmt) {
|
||||
let (value, msg) = match s.node {
|
||||
ast::StmtDecl(ref decl, _) => match decl.node {
|
||||
ast::DeclLocal(ref local) => match local.init {
|
||||
ast::DeclKind::Local(ref local) => match local.init {
|
||||
Some(ref value) => (value, "assigned value"),
|
||||
None => return
|
||||
},
|
||||
|
@ -59,10 +59,10 @@ fn check_block(sess: &Session, b: &ast::Block, kind: &'static str) {
|
||||
let span = match stmt.node {
|
||||
ast::StmtDecl(ref decl, _) => {
|
||||
match decl.node {
|
||||
ast::DeclLocal(_) => decl.span,
|
||||
ast::DeclKind::Local(_) => decl.span,
|
||||
|
||||
// Item statements are allowed
|
||||
ast::DeclItem(_) => continue,
|
||||
ast::DeclKind::Item(_) => continue,
|
||||
}
|
||||
}
|
||||
ast::StmtExpr(ref expr, _) => expr.span,
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
// The Rust abstract syntax tree.
|
||||
|
||||
pub use self::Decl_::*;
|
||||
pub use self::ExplicitSelf_::*;
|
||||
pub use self::Expr_::*;
|
||||
pub use self::FloatTy::*;
|
||||
@ -829,21 +828,21 @@ impl Local {
|
||||
}
|
||||
}
|
||||
|
||||
pub type Decl = Spanned<Decl_>;
|
||||
pub type Decl = Spanned<DeclKind>;
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||
pub enum Decl_ {
|
||||
pub enum DeclKind {
|
||||
/// A local (let) binding:
|
||||
DeclLocal(P<Local>),
|
||||
Local(P<Local>),
|
||||
/// An item binding:
|
||||
DeclItem(P<Item>),
|
||||
Item(P<Item>),
|
||||
}
|
||||
|
||||
impl Decl {
|
||||
pub fn attrs(&self) -> &[Attribute] {
|
||||
match self.node {
|
||||
DeclLocal(ref l) => l.attrs(),
|
||||
DeclItem(ref i) => i.attrs(),
|
||||
DeclKind::Local(ref l) => l.attrs(),
|
||||
DeclKind::Item(ref i) => i.attrs(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ pub use self::IntType::*;
|
||||
|
||||
use ast;
|
||||
use ast::{AttrId, Attribute, Attribute_, MetaItem, MetaWord, MetaNameValue, MetaList};
|
||||
use ast::{Stmt, StmtDecl, StmtExpr, StmtMac, StmtSemi, DeclItem, DeclLocal};
|
||||
use ast::{Stmt, StmtDecl, StmtExpr, StmtMac, StmtSemi, DeclKind};
|
||||
use ast::{Expr, Item, Local, Decl};
|
||||
use codemap::{Span, Spanned, spanned, dummy_spanned};
|
||||
use codemap::BytePos;
|
||||
@ -933,8 +933,8 @@ impl WithAttrs for P<Decl> {
|
||||
Spanned {
|
||||
span: span,
|
||||
node: match node {
|
||||
DeclLocal(local) => DeclLocal(local.with_attrs(attrs)),
|
||||
DeclItem(item) => DeclItem(item.with_attrs(attrs)),
|
||||
DeclKind::Local(local) => DeclKind::Local(local.with_attrs(attrs)),
|
||||
DeclKind::Item(item) => DeclKind::Item(item.with_attrs(attrs)),
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -373,7 +373,7 @@ impl<'v, 'a, 'b> visit::Visitor<'v> for StmtExprAttrFeatureVisitor<'a, 'b> {
|
||||
if stmt_attrs.len() > 0 {
|
||||
// attributes on items are fine
|
||||
if let ast::StmtDecl(ref decl, _) = s.node {
|
||||
if let ast::DeclItem(_) = decl.node {
|
||||
if let ast::DeclKind::Item(_) = decl.node {
|
||||
visit::walk_stmt(self, s);
|
||||
return;
|
||||
}
|
||||
|
@ -524,7 +524,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||
span: sp,
|
||||
attrs: None,
|
||||
});
|
||||
let decl = respan(sp, ast::DeclLocal(local));
|
||||
let decl = respan(sp, ast::DeclKind::Local(local));
|
||||
P(respan(sp, ast::StmtDecl(P(decl), ast::DUMMY_NODE_ID)))
|
||||
}
|
||||
|
||||
@ -548,7 +548,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||
span: sp,
|
||||
attrs: None,
|
||||
});
|
||||
let decl = respan(sp, ast::DeclLocal(local));
|
||||
let decl = respan(sp, ast::DeclKind::Local(local));
|
||||
P(respan(sp, ast::StmtDecl(P(decl), ast::DUMMY_NODE_ID)))
|
||||
}
|
||||
|
||||
@ -558,7 +558,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||
}
|
||||
|
||||
fn stmt_item(&self, sp: Span, item: P<ast::Item>) -> P<ast::Stmt> {
|
||||
let decl = respan(sp, ast::DeclItem(item));
|
||||
let decl = respan(sp, ast::DeclKind::Item(item));
|
||||
P(respan(sp, ast::StmtDecl(P(decl), ast::DUMMY_NODE_ID)))
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use ast::{Block, Crate, DeclLocal, PatMac};
|
||||
use ast::{Block, Crate, DeclKind, PatMac};
|
||||
use ast::{Local, Ident, Mac_, Name};
|
||||
use ast::{ItemMac, MacStmtWithSemicolon, Mrk, Stmt, StmtDecl, StmtMac};
|
||||
use ast::{StmtExpr, StmtSemi};
|
||||
@ -559,7 +559,7 @@ fn expand_non_macro_stmt(Spanned {node, span: stmt_span}: Stmt, fld: &mut MacroE
|
||||
// is it a let?
|
||||
match node {
|
||||
StmtDecl(decl, node_id) => decl.and_then(|Spanned {node: decl, span}| match decl {
|
||||
DeclLocal(local) => {
|
||||
DeclKind::Local(local) => {
|
||||
// take it apart:
|
||||
let rewritten_local = local.map(|Local {id, pat, ty, init, span, attrs}| {
|
||||
// expand the ty since TyFixedLengthVec contains an Expr
|
||||
@ -597,7 +597,7 @@ fn expand_non_macro_stmt(Spanned {node, span: stmt_span}: Stmt, fld: &mut MacroE
|
||||
});
|
||||
SmallVector::one(P(Spanned {
|
||||
node: StmtDecl(P(Spanned {
|
||||
node: DeclLocal(rewritten_local),
|
||||
node: DeclKind::Local(rewritten_local),
|
||||
span: span
|
||||
}),
|
||||
node_id),
|
||||
|
@ -356,12 +356,12 @@ pub fn noop_fold_arm<T: Folder>(Arm {attrs, pats, guard, body}: Arm, fld: &mut T
|
||||
|
||||
pub fn noop_fold_decl<T: Folder>(d: P<Decl>, fld: &mut T) -> SmallVector<P<Decl>> {
|
||||
d.and_then(|Spanned {node, span}| match node {
|
||||
DeclLocal(l) => SmallVector::one(P(Spanned {
|
||||
node: DeclLocal(fld.fold_local(l)),
|
||||
DeclKind::Local(l) => SmallVector::one(P(Spanned {
|
||||
node: DeclKind::Local(fld.fold_local(l)),
|
||||
span: fld.new_span(span)
|
||||
})),
|
||||
DeclItem(it) => fld.fold_item(it).into_iter().map(|i| P(Spanned {
|
||||
node: DeclItem(i),
|
||||
DeclKind::Item(it) => fld.fold_item(it).into_iter().map(|i| P(Spanned {
|
||||
node: DeclKind::Item(i),
|
||||
span: fld.new_span(span)
|
||||
})).collect()
|
||||
})
|
||||
|
@ -49,8 +49,8 @@ pub fn stmt_ends_with_semi(stmt: &ast::Stmt_) -> bool {
|
||||
match *stmt {
|
||||
ast::StmtDecl(ref d, _) => {
|
||||
match d.node {
|
||||
ast::DeclLocal(_) => true,
|
||||
ast::DeclItem(_) => false,
|
||||
ast::DeclKind::Local(_) => true,
|
||||
ast::DeclKind::Item(_) => false,
|
||||
}
|
||||
}
|
||||
ast::StmtExpr(ref e, _) => expr_requires_semi_to_be_stmt(e),
|
||||
|
@ -18,7 +18,7 @@ use ast::{Mod, Arg, Arm, Attribute, BindingMode};
|
||||
use ast::Block;
|
||||
use ast::{BlockCheckMode, CaptureBy};
|
||||
use ast::{Constness, ConstTraitItem, Crate, CrateConfig};
|
||||
use ast::{Decl, DeclItem, DeclLocal};
|
||||
use ast::{Decl, DeclKind};
|
||||
use ast::{EMPTY_CTXT, EnumDef, ExplicitSelf};
|
||||
use ast::{Expr, Expr_, ExprAddrOf, ExprMatch, ExprAgain};
|
||||
use ast::{ExprAssign, ExprAssignOp, ExprBinary, ExprBlock, ExprBox};
|
||||
@ -3636,7 +3636,7 @@ impl<'a> Parser<'a> {
|
||||
fn parse_let(&mut self, attrs: ThinAttributes) -> PResult<'a, P<Decl>> {
|
||||
let lo = self.span.lo;
|
||||
let local = try!(self.parse_local(attrs));
|
||||
Ok(P(spanned(lo, self.last_span.hi, DeclLocal(local))))
|
||||
Ok(P(spanned(lo, self.last_span.hi, DeclKind::Local(local))))
|
||||
}
|
||||
|
||||
/// Parse a structure field
|
||||
@ -3759,7 +3759,7 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
}
|
||||
spanned(lo, hi, StmtDecl(
|
||||
P(spanned(lo, hi, DeclItem(
|
||||
P(spanned(lo, hi, DeclKind::Item(
|
||||
self.mk_item(
|
||||
lo, hi, id /*id is good here*/,
|
||||
ItemMac(spanned(lo, hi,
|
||||
@ -3772,7 +3772,7 @@ impl<'a> Parser<'a> {
|
||||
match try!(self.parse_item_(attrs.clone(), false, true)) {
|
||||
Some(i) => {
|
||||
let hi = i.span.hi;
|
||||
let decl = P(spanned(lo, hi, DeclItem(i)));
|
||||
let decl = P(spanned(lo, hi, DeclKind::Item(i)));
|
||||
spanned(lo, hi, StmtDecl(decl, ast::DUMMY_NODE_ID))
|
||||
}
|
||||
None => {
|
||||
|
@ -2299,7 +2299,7 @@ impl<'a> State<'a> {
|
||||
pub fn print_decl(&mut self, decl: &ast::Decl) -> io::Result<()> {
|
||||
try!(self.maybe_print_comment(decl.span.lo));
|
||||
match decl.node {
|
||||
ast::DeclLocal(ref loc) => {
|
||||
ast::DeclKind::Local(ref loc) => {
|
||||
try!(self.print_outer_attributes(loc.attrs.as_attr_slice()));
|
||||
try!(self.space_if_not_bol());
|
||||
try!(self.ibox(INDENT_UNIT));
|
||||
@ -2315,7 +2315,7 @@ impl<'a> State<'a> {
|
||||
}
|
||||
self.end()
|
||||
}
|
||||
ast::DeclItem(ref item) => self.print_item(&**item)
|
||||
ast::DeclKind::Item(ref item) => self.print_item(&**item)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -640,8 +640,8 @@ pub fn walk_stmt<'v, V: Visitor<'v>>(visitor: &mut V, statement: &'v Stmt) {
|
||||
|
||||
pub fn walk_decl<'v, V: Visitor<'v>>(visitor: &mut V, declaration: &'v Decl) {
|
||||
match declaration.node {
|
||||
DeclLocal(ref local) => visitor.visit_local(local),
|
||||
DeclItem(ref item) => visitor.visit_item(item),
|
||||
DeclKind::Local(ref local) => visitor.visit_local(local),
|
||||
DeclKind::Item(ref item) => visitor.visit_item(item),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,6 +151,6 @@ fn stmt_let_undescore(cx: &mut ExtCtxt,
|
||||
span: sp,
|
||||
attrs: None,
|
||||
});
|
||||
let decl = respan(sp, ast::DeclLocal(local));
|
||||
let decl = respan(sp, ast::DeclKind::Local(local));
|
||||
P(respan(sp, ast::StmtDecl(P(decl), ast::DUMMY_NODE_ID)))
|
||||
}
|
||||
|
@ -457,7 +457,7 @@ impl<'a, 'b> Context<'a, 'b> {
|
||||
|
||||
let name = ecx.ident_of(name);
|
||||
let item = ecx.item(sp, name, vec![], st);
|
||||
let decl = respan(sp, ast::DeclItem(item));
|
||||
let decl = respan(sp, ast::DeclKind::Item(item));
|
||||
|
||||
// Wrap the declaration in a block so that it forms a single expression.
|
||||
ecx.expr_block(ecx.block(sp,
|
||||
|
Loading…
Reference in New Issue
Block a user