Skip to content

Commit 73fa9b2

Browse files
committed
[breaking-change] don't glob export ast::Mutablity variants
1 parent 14e09ad commit 73fa9b2

File tree

21 files changed

+87
-73
lines changed

21 files changed

+87
-73
lines changed

src/librustc/middle/ty/relate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ impl<'a,'tcx:'a> Relate<'a,'tcx> for ty::TypeAndMut<'tcx> {
105105
} else {
106106
let mutbl = a.mutbl;
107107
let variance = match mutbl {
108-
ast::MutImmutable => ty::Covariant,
109-
ast::MutMutable => ty::Invariant,
108+
ast::Mutability::MutImmutable => ty::Covariant,
109+
ast::Mutability::MutMutable => ty::Invariant,
110110
};
111111
let ty = try!(relation.relate_with_variance(variance, &a.ty, &b.ty));
112112
Ok(ty::TypeAndMut {ty: ty, mutbl: mutbl})

src/librustc_front/lowering.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,8 @@ pub fn lower_explicit_self_underscore(lctx: &LoweringContext,
427427

428428
pub fn lower_mutability(_lctx: &LoweringContext, m: Mutability) -> hir::Mutability {
429429
match m {
430-
MutMutable => hir::MutMutable,
431-
MutImmutable => hir::MutImmutable,
430+
Mutability::Mutable => hir::MutMutable,
431+
Mutability::Immutable => hir::MutImmutable,
432432
}
433433
}
434434

src/librustc_passes/const_fn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl<'a, 'v> Visitor<'v> for CheckConstFn<'a> {
105105
for arg in &fd.inputs {
106106
match arg.pat.node {
107107
ast::PatWild => {}
108-
ast::PatIdent(ast::BindingMode::ByValue(ast::MutImmutable), _, None) => {}
108+
ast::PatIdent(ast::BindingMode::ByValue(ast::Mutability::Immutable), _, None) => {}
109109
_ => {
110110
span_err!(self.sess, arg.pat.span, E0022,
111111
"arguments of constant functions can only \

src/librustc_trans/save/dump_csv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
807807
self.visit_pat(&p);
808808

809809
for &(id, ref p, immut, _) in &collector.collected_paths {
810-
let value = if immut == ast::MutImmutable {
810+
let value = if immut == ast::Mutability::Immutable {
811811
value.to_string()
812812
} else {
813813
"<mutable>".to_string()
@@ -1200,7 +1200,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
12001200
let def = def_map.get(&id).unwrap().full_def();
12011201
match def {
12021202
Def::Local(_, id) => {
1203-
let value = if immut == ast::MutImmutable {
1203+
let value = if immut == ast::Mutability::Immutable {
12041204
self.span.snippet(p.span).to_string()
12051205
} else {
12061206
"<mutable>".to_string()

src/librustc_trans/save/mod.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,10 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
248248

249249
// If the variable is immutable, save the initialising expression.
250250
let (value, keyword) = match mt {
251-
ast::MutMutable => (String::from("<mutable>"), keywords::Mut),
252-
ast::MutImmutable => (self.span_utils.snippet(expr.span), keywords::Static),
251+
ast::Mutability::Mutable => (String::from("<mutable>"), keywords::Mut),
252+
ast::Mutability::Immutable => {
253+
(self.span_utils.snippet(expr.span), keywords::Static)
254+
},
253255
};
254256

255257
let sub_span = self.span_utils.sub_span_after_keyword(item.span, keyword);
@@ -758,12 +760,12 @@ impl<'v> Visitor<'v> for PathCollector {
758760
match p.node {
759761
ast::PatStruct(ref path, _, _) => {
760762
self.collected_paths.push((p.id, path.clone(),
761-
ast::MutMutable, recorder::TypeRef));
763+
ast::Mutability::Mutable, recorder::TypeRef));
762764
}
763765
ast::PatEnum(ref path, _) |
764766
ast::PatQPath(_, ref path) => {
765767
self.collected_paths.push((p.id, path.clone(),
766-
ast::MutMutable, recorder::VarRef));
768+
ast::Mutability::Mutable, recorder::VarRef));
767769
}
768770
ast::PatIdent(bm, ref path1, _) => {
769771
debug!("PathCollector, visit ident in pat {}: {:?} {:?}",
@@ -774,7 +776,7 @@ impl<'v> Visitor<'v> for PathCollector {
774776
// Even if the ref is mut, you can't change the ref, only
775777
// the data pointed at, so showing the initialising expression
776778
// is still worthwhile.
777-
ast::BindingMode::ByRef(_) => ast::MutImmutable,
779+
ast::BindingMode::ByRef(_) => ast::Mutability::Immutable,
778780
ast::BindingMode::ByValue(mt) => mt,
779781
};
780782
// collect path for either visit_local or visit_arm

src/libsyntax/ast.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
// The Rust abstract syntax tree.
1212

13-
pub use self::Mutability::*;
1413
pub use self::Pat_::*;
1514
pub use self::PathListItem_::*;
1615
pub use self::StrStyle::*;
@@ -602,8 +601,8 @@ pub enum Pat_ {
602601

603602
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
604603
pub enum Mutability {
605-
MutMutable,
606-
MutImmutable,
604+
Mutable,
605+
Immutable,
607606
}
608607

609608
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]

src/libsyntax/ast_util.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ pub fn path_to_ident(path: &Path) -> Option<Ident> {
6666
}
6767

6868
pub fn ident_to_pat(id: NodeId, s: Span, i: Ident) -> P<Pat> {
69+
let spanned = codemap::Spanned{ span: s, node: i };
6970
P(Pat {
7071
id: id,
71-
node: PatIdent(BindingMode::ByValue(MutImmutable), codemap::Spanned{span:s, node:i}, None),
72+
node: PatIdent(BindingMode::ByValue(Mutability::Immutable), spanned, None),
7273
span: s
7374
})
7475
}

src/libsyntax/diagnostics/plugin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
207207
span,
208208
ecx.ty_ident(span, ecx.ident_of("str")),
209209
Some(static_),
210-
ast::MutImmutable,
210+
ast::Mutability::Immutable,
211211
);
212212

213213
let ty = ecx.ty(

src/libsyntax/ext/build.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,8 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
512512
fn stmt_let(&self, sp: Span, mutbl: bool, ident: ast::Ident,
513513
ex: P<ast::Expr>) -> P<ast::Stmt> {
514514
let pat = if mutbl {
515-
self.pat_ident_binding_mode(sp, ident, ast::BindingMode::ByValue(ast::MutMutable))
515+
let binding_mode = ast::BindingMode::ByValue(ast::Mutability::Mutable);
516+
self.pat_ident_binding_mode(sp, ident, binding_mode)
516517
} else {
517518
self.pat_ident(sp, ident)
518519
};
@@ -536,7 +537,8 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
536537
ex: P<ast::Expr>)
537538
-> P<ast::Stmt> {
538539
let pat = if mutbl {
539-
self.pat_ident_binding_mode(sp, ident, ast::BindingMode::ByValue(ast::MutMutable))
540+
let binding_mode = ast::BindingMode::ByValue(ast::Mutability::Mutable);
541+
self.pat_ident_binding_mode(sp, ident, binding_mode)
540542
} else {
541543
self.pat_ident(sp, ident)
542544
};
@@ -636,10 +638,10 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
636638
self.expr(sp, ast::ExprKind::TupField(expr, id))
637639
}
638640
fn expr_addr_of(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr> {
639-
self.expr(sp, ast::ExprKind::AddrOf(ast::MutImmutable, e))
641+
self.expr(sp, ast::ExprKind::AddrOf(ast::Mutability::Immutable, e))
640642
}
641643
fn expr_mut_addr_of(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr> {
642-
self.expr(sp, ast::ExprKind::AddrOf(ast::MutMutable, e))
644+
self.expr(sp, ast::ExprKind::AddrOf(ast::Mutability::Mutable, e))
643645
}
644646

645647
fn expr_call(&self, span: Span, expr: P<ast::Expr>, args: Vec<P<ast::Expr>>) -> P<ast::Expr> {
@@ -813,7 +815,8 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
813815
self.pat(span, ast::PatLit(expr))
814816
}
815817
fn pat_ident(&self, span: Span, ident: ast::Ident) -> P<ast::Pat> {
816-
self.pat_ident_binding_mode(span, ident, ast::BindingMode::ByValue(ast::MutImmutable))
818+
let binding_mode = ast::BindingMode::ByValue(ast::Mutability::Immutable);
819+
self.pat_ident_binding_mode(span, ident, binding_mode)
817820
}
818821

819822
fn pat_ident_binding_mode(&self,

src/libsyntax/parse/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ mod tests {
896896
assert!(panictry!(parser.parse_pat())
897897
== P(ast::Pat{
898898
id: ast::DUMMY_NODE_ID,
899-
node: ast::PatIdent(ast::BindingMode::ByValue(ast::MutImmutable),
899+
node: ast::PatIdent(ast::BindingMode::ByValue(ast::Mutability::Immutable),
900900
Spanned{ span:sp(0, 1),
901901
node: str_to_ident("b")
902902
},
@@ -932,7 +932,7 @@ mod tests {
932932
pat: P(ast::Pat {
933933
id: ast::DUMMY_NODE_ID,
934934
node: ast::PatIdent(
935-
ast::BindingMode::ByValue(ast::MutImmutable),
935+
ast::BindingMode::ByValue(ast::Mutability::Immutable),
936936
Spanned{
937937
span: sp(6,7),
938938
node: str_to_ident("b")},

0 commit comments

Comments
 (0)