Stop re-exporting the ast::BindingMode variants.

This commit is contained in:
Ms2ger 2015-12-18 14:23:01 +01:00
parent f963eb2870
commit 143b9d80d0
9 changed files with 26 additions and 27 deletions

View file

@ -1563,8 +1563,8 @@ pub fn lower_block_check_mode(lctx: &LoweringContext, b: &BlockCheckMode) -> hir
pub fn lower_binding_mode(lctx: &LoweringContext, b: &BindingMode) -> hir::BindingMode { pub fn lower_binding_mode(lctx: &LoweringContext, b: &BindingMode) -> hir::BindingMode {
match *b { match *b {
BindByRef(m) => hir::BindByRef(lower_mutability(lctx, m)), BindingMode::ByRef(m) => hir::BindByRef(lower_mutability(lctx, m)),
BindByValue(m) => hir::BindByValue(lower_mutability(lctx, m)), BindingMode::ByValue(m) => hir::BindByValue(lower_mutability(lctx, m)),
} }
} }

View file

@ -697,8 +697,8 @@ fn visit_pat(&mut self, p: &ast::Pat) {
// Even if the ref is mut, you can't change the ref, only // Even if the ref is mut, you can't change the ref, only
// the data pointed at, so showing the initialising expression // the data pointed at, so showing the initialising expression
// is still worthwhile. // is still worthwhile.
ast::BindByRef(_) => ast::MutImmutable, ast::BindingMode::ByRef(_) => ast::MutImmutable,
ast::BindByValue(mt) => mt, ast::BindingMode::ByValue(mt) => mt,
}; };
// collect path for either visit_local or visit_arm // collect path for either visit_local or visit_arm
let path = ast_util::ident_to_path(path1.span, path1.node); let path = ast_util::ident_to_path(path1.span, path1.node);

View file

@ -10,7 +10,6 @@
// The Rust abstract syntax tree. // The Rust abstract syntax tree.
pub use self::BindingMode::*;
pub use self::BinOp_::*; pub use self::BinOp_::*;
pub use self::BlockCheckMode::*; pub use self::BlockCheckMode::*;
pub use self::CaptureClause::*; pub use self::CaptureClause::*;
@ -575,8 +574,8 @@ pub struct FieldPat {
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
pub enum BindingMode { pub enum BindingMode {
BindByRef(Mutability), ByRef(Mutability),
BindByValue(Mutability), ByValue(Mutability),
} }
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
@ -1655,7 +1654,7 @@ pub fn new_self(span: Span, mutability: Mutability, self_ident: Ident) -> Arg {
}), }),
pat: P(Pat { pat: P(Pat {
id: DUMMY_NODE_ID, id: DUMMY_NODE_ID,
node: PatIdent(BindByValue(mutability), path, None), node: PatIdent(BindingMode::ByValue(mutability), path, None),
span: span span: span
}), }),
id: DUMMY_NODE_ID id: DUMMY_NODE_ID

View file

@ -69,7 +69,7 @@ pub fn path_to_ident(path: &Path) -> Option<Ident> {
pub fn ident_to_pat(id: NodeId, s: Span, i: Ident) -> P<Pat> { pub fn ident_to_pat(id: NodeId, s: Span, i: Ident) -> P<Pat> {
P(Pat { P(Pat {
id: id, id: id,
node: PatIdent(BindByValue(MutImmutable), codemap::Spanned{span:s, node:i}, None), node: PatIdent(BindingMode::ByValue(MutImmutable), codemap::Spanned{span:s, node:i}, None),
span: s span: s
}) })
} }

View file

@ -514,7 +514,7 @@ fn stmt_expr(&self, expr: P<ast::Expr>) -> P<ast::Stmt> {
fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident, fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident,
ex: P<ast::Expr>) -> P<ast::Stmt> { ex: P<ast::Expr>) -> P<ast::Stmt> {
let pat = if mutbl { let pat = if mutbl {
self.pat_ident_binding_mode(sp, ident, ast::BindByValue(ast::MutMutable)) self.pat_ident_binding_mode(sp, ident, ast::BindingMode::ByValue(ast::MutMutable))
} else { } else {
self.pat_ident(sp, ident) self.pat_ident(sp, ident)
}; };
@ -538,7 +538,7 @@ fn stmt_let_typed(&self,
ex: P<ast::Expr>) ex: P<ast::Expr>)
-> P<ast::Stmt> { -> P<ast::Stmt> {
let pat = if mutbl { let pat = if mutbl {
self.pat_ident_binding_mode(sp, ident, ast::BindByValue(ast::MutMutable)) self.pat_ident_binding_mode(sp, ident, ast::BindingMode::ByValue(ast::MutMutable))
} else { } else {
self.pat_ident(sp, ident) self.pat_ident(sp, ident)
}; };
@ -809,7 +809,7 @@ fn pat_lit(&self, span: Span, expr: P<ast::Expr>) -> P<ast::Pat> {
self.pat(span, ast::PatLit(expr)) self.pat(span, ast::PatLit(expr))
} }
fn pat_ident(&self, span: Span, ident: ast::Ident) -> P<ast::Pat> { fn pat_ident(&self, span: Span, ident: ast::Ident) -> P<ast::Pat> {
self.pat_ident_binding_mode(span, ident, ast::BindByValue(ast::MutImmutable)) self.pat_ident_binding_mode(span, ident, ast::BindingMode::ByValue(ast::MutImmutable))
} }
fn pat_ident_binding_mode(&self, fn pat_ident_binding_mode(&self,

View file

@ -890,7 +890,7 @@ fn parser_done(p: Parser){
assert!(panictry!(parser.parse_pat()) assert!(panictry!(parser.parse_pat())
== P(ast::Pat{ == P(ast::Pat{
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
node: ast::PatIdent(ast::BindByValue(ast::MutImmutable), node: ast::PatIdent(ast::BindingMode::ByValue(ast::MutImmutable),
Spanned{ span:sp(0, 1), Spanned{ span:sp(0, 1),
node: str_to_ident("b") node: str_to_ident("b")
}, },
@ -926,7 +926,7 @@ fn parser_done(p: Parser){
pat: P(ast::Pat { pat: P(ast::Pat {
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
node: ast::PatIdent( node: ast::PatIdent(
ast::BindByValue(ast::MutImmutable), ast::BindingMode::ByValue(ast::MutImmutable),
Spanned{ Spanned{
span: sp(6,7), span: sp(6,7),
node: str_to_ident("b")}, node: str_to_ident("b")},

View file

@ -14,7 +14,7 @@
use ast::BareFnTy; use ast::BareFnTy;
use ast::{RegionTyParamBound, TraitTyParamBound, TraitBoundModifier}; use ast::{RegionTyParamBound, TraitTyParamBound, TraitBoundModifier};
use ast::{Public, Unsafety}; use ast::{Public, Unsafety};
use ast::{Mod, BiAdd, Arg, Arm, Attribute, BindByRef, BindByValue}; use ast::{Mod, BiAdd, Arg, Arm, Attribute, BindingMode};
use ast::{BiBitAnd, BiBitOr, BiBitXor, BiRem, BiLt, Block}; use ast::{BiBitAnd, BiBitOr, BiBitXor, BiRem, BiLt, Block};
use ast::{BlockCheckMode, CaptureByRef, CaptureByValue, CaptureClause}; use ast::{BlockCheckMode, CaptureByRef, CaptureByValue, CaptureClause};
use ast::{Constness, ConstTraitItem, Crate, CrateConfig}; use ast::{Constness, ConstTraitItem, Crate, CrateConfig};
@ -3274,10 +3274,10 @@ fn parse_pat_fields(&mut self) -> PResult<(Vec<codemap::Spanned<ast::FieldPat>>
hi = self.last_span.hi; hi = self.last_span.hi;
let bind_type = match (is_ref, is_mut) { let bind_type = match (is_ref, is_mut) {
(true, true) => BindByRef(MutMutable), (true, true) => BindingMode::ByRef(MutMutable),
(true, false) => BindByRef(MutImmutable), (true, false) => BindingMode::ByRef(MutImmutable),
(false, true) => BindByValue(MutMutable), (false, true) => BindingMode::ByValue(MutMutable),
(false, false) => BindByValue(MutImmutable), (false, false) => BindingMode::ByValue(MutImmutable),
}; };
let fieldpath = codemap::Spanned{span:self.last_span, node:fieldname}; let fieldpath = codemap::Spanned{span:self.last_span, node:fieldname};
let fieldpat = P(ast::Pat{ let fieldpat = P(ast::Pat{
@ -3372,11 +3372,11 @@ pub fn parse_pat(&mut self) -> PResult<P<Pat>> {
// At this point, token != _, &, &&, (, [ // At this point, token != _, &, &&, (, [
if try!(self.eat_keyword(keywords::Mut)) { if try!(self.eat_keyword(keywords::Mut)) {
// Parse mut ident @ pat // Parse mut ident @ pat
pat = try!(self.parse_pat_ident(BindByValue(MutMutable))); pat = try!(self.parse_pat_ident(BindingMode::ByValue(MutMutable)));
} else if try!(self.eat_keyword(keywords::Ref)) { } else if try!(self.eat_keyword(keywords::Ref)) {
// Parse ref ident @ pat / ref mut ident @ pat // Parse ref ident @ pat / ref mut ident @ pat
let mutbl = try!(self.parse_mutability()); let mutbl = try!(self.parse_mutability());
pat = try!(self.parse_pat_ident(BindByRef(mutbl))); pat = try!(self.parse_pat_ident(BindingMode::ByRef(mutbl)));
} else if try!(self.eat_keyword(keywords::Box)) { } else if try!(self.eat_keyword(keywords::Box)) {
// Parse box pat // Parse box pat
let subpat = try!(self.parse_pat()); let subpat = try!(self.parse_pat());
@ -3405,7 +3405,7 @@ pub fn parse_pat(&mut self) -> PResult<P<Pat>> {
// Parse ident @ pat // Parse ident @ pat
// This can give false positives and parse nullary enums, // This can give false positives and parse nullary enums,
// they are dealt with later in resolve // they are dealt with later in resolve
pat = try!(self.parse_pat_ident(BindByValue(MutImmutable))); pat = try!(self.parse_pat_ident(BindingMode::ByValue(MutImmutable)));
} }
} else { } else {
let (qself, path) = if try!(self.eat_lt()) { let (qself, path) = if try!(self.eat_lt()) {

View file

@ -2467,12 +2467,12 @@ pub fn print_pat(&mut self, pat: &ast::Pat) -> io::Result<()> {
ast::PatWild => try!(word(&mut self.s, "_")), ast::PatWild => try!(word(&mut self.s, "_")),
ast::PatIdent(binding_mode, ref path1, ref sub) => { ast::PatIdent(binding_mode, ref path1, ref sub) => {
match binding_mode { match binding_mode {
ast::BindByRef(mutbl) => { ast::BindingMode::ByRef(mutbl) => {
try!(self.word_nbsp("ref")); try!(self.word_nbsp("ref"));
try!(self.print_mutability(mutbl)); try!(self.print_mutability(mutbl));
} }
ast::BindByValue(ast::MutImmutable) => {} ast::BindingMode::ByValue(ast::MutImmutable) => {}
ast::BindByValue(ast::MutMutable) => { ast::BindingMode::ByValue(ast::MutMutable) => {
try!(self.word_nbsp("mut")); try!(self.word_nbsp("mut"));
} }
} }
@ -2678,7 +2678,7 @@ pub fn print_fn_args(&mut self, decl: &ast::FnDecl,
let m = match *explicit_self { let m = match *explicit_self {
ast::SelfStatic => ast::MutImmutable, ast::SelfStatic => ast::MutImmutable,
_ => match decl.inputs[0].pat.node { _ => match decl.inputs[0].pat.node {
ast::PatIdent(ast::BindByValue(m), _, _) => m, ast::PatIdent(ast::BindingMode::ByValue(m), _, _) => m,
_ => ast::MutImmutable _ => ast::MutImmutable
} }
}; };

View file

@ -1471,7 +1471,7 @@ fn create_subpatterns(&self,
-> Vec<P<ast::Pat>> { -> Vec<P<ast::Pat>> {
field_paths.iter().map(|path| { field_paths.iter().map(|path| {
cx.pat(path.span, cx.pat(path.span,
ast::PatIdent(ast::BindByRef(mutbl), (*path).clone(), None)) ast::PatIdent(ast::BindingMode::ByRef(mutbl), (*path).clone(), None))
}).collect() }).collect()
} }