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