Skip to content

Stop re-exporting the ast::BindingMode variants. #30460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/librustc_front/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
match *b {
BindByRef(m) => hir::BindByRef(lower_mutability(lctx, m)),
BindByValue(m) => hir::BindByValue(lower_mutability(lctx, m)),
BindingMode::ByRef(m) => hir::BindByRef(lower_mutability(lctx, m)),
BindingMode::ByValue(m) => hir::BindByValue(lower_mutability(lctx, m)),
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_trans/save/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,8 +697,8 @@ impl<'v> Visitor<'v> for PathCollector {
// Even if the ref is mut, you can't change the ref, only
// the data pointed at, so showing the initialising expression
// is still worthwhile.
ast::BindByRef(_) => ast::MutImmutable,
ast::BindByValue(mt) => mt,
ast::BindingMode::ByRef(_) => ast::MutImmutable,
ast::BindingMode::ByValue(mt) => mt,
};
// collect path for either visit_local or visit_arm
let path = ast_util::ident_to_path(path1.span, path1.node);
Expand Down
7 changes: 3 additions & 4 deletions src/libsyntax/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

// The Rust abstract syntax tree.

pub use self::BindingMode::*;
pub use self::BinOp_::*;
pub use self::BlockCheckMode::*;
pub use self::CaptureClause::*;
Expand Down Expand Up @@ -575,8 +574,8 @@ pub struct FieldPat {

#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
pub enum BindingMode {
BindByRef(Mutability),
BindByValue(Mutability),
ByRef(Mutability),
ByValue(Mutability),
}

#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
Expand Down Expand Up @@ -1655,7 +1654,7 @@ impl Arg {
}),
pat: P(Pat {
id: DUMMY_NODE_ID,
node: PatIdent(BindByValue(mutability), path, None),
node: PatIdent(BindingMode::ByValue(mutability), path, None),
span: span
}),
id: DUMMY_NODE_ID
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/ast_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
P(Pat {
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
})
}
Expand Down
6 changes: 3 additions & 3 deletions src/libsyntax/ext/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident,
ex: P<ast::Expr>) -> P<ast::Stmt> {
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 {
self.pat_ident(sp, ident)
};
Expand All @@ -538,7 +538,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
ex: P<ast::Expr>)
-> P<ast::Stmt> {
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 {
self.pat_ident(sp, ident)
};
Expand Down Expand Up @@ -809,7 +809,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
self.pat(span, ast::PatLit(expr))
}
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,
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ mod tests {
assert!(panictry!(parser.parse_pat())
== P(ast::Pat{
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),
node: str_to_ident("b")
},
Expand Down Expand Up @@ -926,7 +926,7 @@ mod tests {
pat: P(ast::Pat {
id: ast::DUMMY_NODE_ID,
node: ast::PatIdent(
ast::BindByValue(ast::MutImmutable),
ast::BindingMode::ByValue(ast::MutImmutable),
Spanned{
span: sp(6,7),
node: str_to_ident("b")},
Expand Down
16 changes: 8 additions & 8 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use abi;
use ast::BareFnTy;
use ast::{RegionTyParamBound, TraitTyParamBound, TraitBoundModifier};
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::{BlockCheckMode, CaptureByRef, CaptureByValue, CaptureClause};
use ast::{Constness, ConstTraitItem, Crate, CrateConfig};
Expand Down Expand Up @@ -3274,10 +3274,10 @@ impl<'a> Parser<'a> {
hi = self.last_span.hi;

let bind_type = match (is_ref, is_mut) {
(true, true) => BindByRef(MutMutable),
(true, false) => BindByRef(MutImmutable),
(false, true) => BindByValue(MutMutable),
(false, false) => BindByValue(MutImmutable),
(true, true) => BindingMode::ByRef(MutMutable),
(true, false) => BindingMode::ByRef(MutImmutable),
(false, true) => BindingMode::ByValue(MutMutable),
(false, false) => BindingMode::ByValue(MutImmutable),
};
let fieldpath = codemap::Spanned{span:self.last_span, node:fieldname};
let fieldpat = P(ast::Pat{
Expand Down Expand Up @@ -3372,11 +3372,11 @@ impl<'a> Parser<'a> {
// At this point, token != _, &, &&, (, [
if try!(self.eat_keyword(keywords::Mut)) {
// 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)) {
// Parse ref ident @ pat / ref mut ident @ pat
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)) {
// Parse box pat
let subpat = try!(self.parse_pat());
Expand Down Expand Up @@ -3405,7 +3405,7 @@ impl<'a> Parser<'a> {
// Parse ident @ pat
// This can give false positives and parse nullary enums,
// 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 {
let (qself, path) = if try!(self.eat_lt()) {
Expand Down
8 changes: 4 additions & 4 deletions src/libsyntax/print/pprust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2467,12 +2467,12 @@ impl<'a> State<'a> {
ast::PatWild => try!(word(&mut self.s, "_")),
ast::PatIdent(binding_mode, ref path1, ref sub) => {
match binding_mode {
ast::BindByRef(mutbl) => {
ast::BindingMode::ByRef(mutbl) => {
try!(self.word_nbsp("ref"));
try!(self.print_mutability(mutbl));
}
ast::BindByValue(ast::MutImmutable) => {}
ast::BindByValue(ast::MutMutable) => {
ast::BindingMode::ByValue(ast::MutImmutable) => {}
ast::BindingMode::ByValue(ast::MutMutable) => {
try!(self.word_nbsp("mut"));
}
}
Expand Down Expand Up @@ -2678,7 +2678,7 @@ impl<'a> State<'a> {
let m = match *explicit_self {
ast::SelfStatic => ast::MutImmutable,
_ => match decl.inputs[0].pat.node {
ast::PatIdent(ast::BindByValue(m), _, _) => m,
ast::PatIdent(ast::BindingMode::ByValue(m), _, _) => m,
_ => ast::MutImmutable
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax_ext/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1471,7 +1471,7 @@ impl<'a> TraitDef<'a> {
-> Vec<P<ast::Pat>> {
field_paths.iter().map(|path| {
cx.pat(path.span,
ast::PatIdent(ast::BindByRef(mutbl), (*path).clone(), None))
ast::PatIdent(ast::BindingMode::ByRef(mutbl), (*path).clone(), None))
}).collect()
}

Expand Down