Skip to content

Commit 709d00a

Browse files
committed
Auto merge of #30460 - Ms2ger:BindingMode, r=alexcrichton
2 parents 8cd034d + 143b9d8 commit 709d00a

File tree

9 files changed

+26
-27
lines changed

9 files changed

+26
-27
lines changed

src/librustc_front/lowering.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1571,8 +1571,8 @@ pub fn lower_block_check_mode(lctx: &LoweringContext, b: &BlockCheckMode) -> hir
15711571

15721572
pub fn lower_binding_mode(lctx: &LoweringContext, b: &BindingMode) -> hir::BindingMode {
15731573
match *b {
1574-
BindByRef(m) => hir::BindByRef(lower_mutability(lctx, m)),
1575-
BindByValue(m) => hir::BindByValue(lower_mutability(lctx, m)),
1574+
BindingMode::ByRef(m) => hir::BindByRef(lower_mutability(lctx, m)),
1575+
BindingMode::ByValue(m) => hir::BindByValue(lower_mutability(lctx, m)),
15761576
}
15771577
}
15781578

src/librustc_trans/save/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -697,8 +697,8 @@ impl<'v> Visitor<'v> for PathCollector {
697697
// Even if the ref is mut, you can't change the ref, only
698698
// the data pointed at, so showing the initialising expression
699699
// is still worthwhile.
700-
ast::BindByRef(_) => ast::MutImmutable,
701-
ast::BindByValue(mt) => mt,
700+
ast::BindingMode::ByRef(_) => ast::MutImmutable,
701+
ast::BindingMode::ByValue(mt) => mt,
702702
};
703703
// collect path for either visit_local or visit_arm
704704
let path = ast_util::ident_to_path(path1.span, path1.node);

src/libsyntax/ast.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// The Rust abstract syntax tree.
1212

13-
pub use self::BindingMode::*;
1413
pub use self::BinOp_::*;
1514
pub use self::BlockCheckMode::*;
1615
pub use self::CaptureClause::*;
@@ -574,8 +573,8 @@ pub struct FieldPat {
574573

575574
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
576575
pub enum BindingMode {
577-
BindByRef(Mutability),
578-
BindByValue(Mutability),
576+
ByRef(Mutability),
577+
ByValue(Mutability),
579578
}
580579

581580
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
@@ -1655,7 +1654,7 @@ impl Arg {
16551654
}),
16561655
pat: P(Pat {
16571656
id: DUMMY_NODE_ID,
1658-
node: PatIdent(BindByValue(mutability), path, None),
1657+
node: PatIdent(BindingMode::ByValue(mutability), path, None),
16591658
span: span
16601659
}),
16611660
id: DUMMY_NODE_ID

src/libsyntax/ast_util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub fn path_to_ident(path: &Path) -> Option<Ident> {
6868
pub fn ident_to_pat(id: NodeId, s: Span, i: Ident) -> P<Pat> {
6969
P(Pat {
7070
id: id,
71-
node: PatIdent(BindByValue(MutImmutable), codemap::Spanned{span:s, node:i}, None),
71+
node: PatIdent(BindingMode::ByValue(MutImmutable), codemap::Spanned{span:s, node:i}, None),
7272
span: s
7373
})
7474
}

src/libsyntax/ext/build.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
513513
fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident,
514514
ex: P<ast::Expr>) -> P<ast::Stmt> {
515515
let pat = if mutbl {
516-
self.pat_ident_binding_mode(sp, ident, ast::BindByValue(ast::MutMutable))
516+
self.pat_ident_binding_mode(sp, ident, ast::BindingMode::ByValue(ast::MutMutable))
517517
} else {
518518
self.pat_ident(sp, ident)
519519
};
@@ -537,7 +537,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
537537
ex: P<ast::Expr>)
538538
-> P<ast::Stmt> {
539539
let pat = if mutbl {
540-
self.pat_ident_binding_mode(sp, ident, ast::BindByValue(ast::MutMutable))
540+
self.pat_ident_binding_mode(sp, ident, ast::BindingMode::ByValue(ast::MutMutable))
541541
} else {
542542
self.pat_ident(sp, ident)
543543
};
@@ -808,7 +808,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
808808
self.pat(span, ast::PatLit(expr))
809809
}
810810
fn pat_ident(&self, span: Span, ident: ast::Ident) -> P<ast::Pat> {
811-
self.pat_ident_binding_mode(span, ident, ast::BindByValue(ast::MutImmutable))
811+
self.pat_ident_binding_mode(span, ident, ast::BindingMode::ByValue(ast::MutImmutable))
812812
}
813813

814814
fn pat_ident_binding_mode(&self,

src/libsyntax/parse/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ mod tests {
892892
assert!(panictry!(parser.parse_pat())
893893
== P(ast::Pat{
894894
id: ast::DUMMY_NODE_ID,
895-
node: ast::PatIdent(ast::BindByValue(ast::MutImmutable),
895+
node: ast::PatIdent(ast::BindingMode::ByValue(ast::MutImmutable),
896896
Spanned{ span:sp(0, 1),
897897
node: str_to_ident("b")
898898
},
@@ -928,7 +928,7 @@ mod tests {
928928
pat: P(ast::Pat {
929929
id: ast::DUMMY_NODE_ID,
930930
node: ast::PatIdent(
931-
ast::BindByValue(ast::MutImmutable),
931+
ast::BindingMode::ByValue(ast::MutImmutable),
932932
Spanned{
933933
span: sp(6,7),
934934
node: str_to_ident("b")},

src/libsyntax/parse/parser.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use abi;
1414
use ast::BareFnTy;
1515
use ast::{RegionTyParamBound, TraitTyParamBound, TraitBoundModifier};
1616
use ast::{Public, Unsafety};
17-
use ast::{Mod, BiAdd, Arg, Arm, Attribute, BindByRef, BindByValue};
17+
use ast::{Mod, BiAdd, Arg, Arm, Attribute, BindingMode};
1818
use ast::{BiBitAnd, BiBitOr, BiBitXor, BiRem, BiLt, Block};
1919
use ast::{BlockCheckMode, CaptureByRef, CaptureByValue, CaptureClause};
2020
use ast::{Constness, ConstTraitItem, Crate, CrateConfig};
@@ -3278,10 +3278,10 @@ impl<'a> Parser<'a> {
32783278
hi = self.last_span.hi;
32793279

32803280
let bind_type = match (is_ref, is_mut) {
3281-
(true, true) => BindByRef(MutMutable),
3282-
(true, false) => BindByRef(MutImmutable),
3283-
(false, true) => BindByValue(MutMutable),
3284-
(false, false) => BindByValue(MutImmutable),
3281+
(true, true) => BindingMode::ByRef(MutMutable),
3282+
(true, false) => BindingMode::ByRef(MutImmutable),
3283+
(false, true) => BindingMode::ByValue(MutMutable),
3284+
(false, false) => BindingMode::ByValue(MutImmutable),
32853285
};
32863286
let fieldpath = codemap::Spanned{span:self.last_span, node:fieldname};
32873287
let fieldpat = P(ast::Pat{
@@ -3376,11 +3376,11 @@ impl<'a> Parser<'a> {
33763376
// At this point, token != _, &, &&, (, [
33773377
if try!(self.eat_keyword(keywords::Mut)) {
33783378
// Parse mut ident @ pat
3379-
pat = try!(self.parse_pat_ident(BindByValue(MutMutable)));
3379+
pat = try!(self.parse_pat_ident(BindingMode::ByValue(MutMutable)));
33803380
} else if try!(self.eat_keyword(keywords::Ref)) {
33813381
// Parse ref ident @ pat / ref mut ident @ pat
33823382
let mutbl = try!(self.parse_mutability());
3383-
pat = try!(self.parse_pat_ident(BindByRef(mutbl)));
3383+
pat = try!(self.parse_pat_ident(BindingMode::ByRef(mutbl)));
33843384
} else if try!(self.eat_keyword(keywords::Box)) {
33853385
// Parse box pat
33863386
let subpat = try!(self.parse_pat());
@@ -3409,7 +3409,7 @@ impl<'a> Parser<'a> {
34093409
// Parse ident @ pat
34103410
// This can give false positives and parse nullary enums,
34113411
// they are dealt with later in resolve
3412-
pat = try!(self.parse_pat_ident(BindByValue(MutImmutable)));
3412+
pat = try!(self.parse_pat_ident(BindingMode::ByValue(MutImmutable)));
34133413
}
34143414
} else {
34153415
let (qself, path) = if try!(self.eat_lt()) {

src/libsyntax/print/pprust.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2471,12 +2471,12 @@ impl<'a> State<'a> {
24712471
ast::PatWild => try!(word(&mut self.s, "_")),
24722472
ast::PatIdent(binding_mode, ref path1, ref sub) => {
24732473
match binding_mode {
2474-
ast::BindByRef(mutbl) => {
2474+
ast::BindingMode::ByRef(mutbl) => {
24752475
try!(self.word_nbsp("ref"));
24762476
try!(self.print_mutability(mutbl));
24772477
}
2478-
ast::BindByValue(ast::MutImmutable) => {}
2479-
ast::BindByValue(ast::MutMutable) => {
2478+
ast::BindingMode::ByValue(ast::MutImmutable) => {}
2479+
ast::BindingMode::ByValue(ast::MutMutable) => {
24802480
try!(self.word_nbsp("mut"));
24812481
}
24822482
}
@@ -2682,7 +2682,7 @@ impl<'a> State<'a> {
26822682
let m = match *explicit_self {
26832683
ast::SelfStatic => ast::MutImmutable,
26842684
_ => match decl.inputs[0].pat.node {
2685-
ast::PatIdent(ast::BindByValue(m), _, _) => m,
2685+
ast::PatIdent(ast::BindingMode::ByValue(m), _, _) => m,
26862686
_ => ast::MutImmutable
26872687
}
26882688
};

src/libsyntax_ext/deriving/generic/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1470,7 +1470,7 @@ impl<'a> TraitDef<'a> {
14701470
-> Vec<P<ast::Pat>> {
14711471
field_paths.iter().map(|path| {
14721472
cx.pat(path.span,
1473-
ast::PatIdent(ast::BindByRef(mutbl), (*path).clone(), None))
1473+
ast::PatIdent(ast::BindingMode::ByRef(mutbl), (*path).clone(), None))
14741474
}).collect()
14751475
}
14761476

0 commit comments

Comments
 (0)