[breaking-change] don't glob export ast::Mutablity variants
This commit is contained in:
parent
14e09ad468
commit
73fa9b2da2
21 changed files with 87 additions and 73 deletions
|
@ -105,8 +105,8 @@ impl<'a,'tcx:'a> Relate<'a,'tcx> for ty::TypeAndMut<'tcx> {
|
||||||
} else {
|
} else {
|
||||||
let mutbl = a.mutbl;
|
let mutbl = a.mutbl;
|
||||||
let variance = match mutbl {
|
let variance = match mutbl {
|
||||||
ast::MutImmutable => ty::Covariant,
|
ast::Mutability::MutImmutable => ty::Covariant,
|
||||||
ast::MutMutable => ty::Invariant,
|
ast::Mutability::MutMutable => ty::Invariant,
|
||||||
};
|
};
|
||||||
let ty = try!(relation.relate_with_variance(variance, &a.ty, &b.ty));
|
let ty = try!(relation.relate_with_variance(variance, &a.ty, &b.ty));
|
||||||
Ok(ty::TypeAndMut {ty: ty, mutbl: mutbl})
|
Ok(ty::TypeAndMut {ty: ty, mutbl: mutbl})
|
||||||
|
|
|
@ -427,8 +427,8 @@ pub fn lower_explicit_self_underscore(lctx: &LoweringContext,
|
||||||
|
|
||||||
pub fn lower_mutability(_lctx: &LoweringContext, m: Mutability) -> hir::Mutability {
|
pub fn lower_mutability(_lctx: &LoweringContext, m: Mutability) -> hir::Mutability {
|
||||||
match m {
|
match m {
|
||||||
MutMutable => hir::MutMutable,
|
Mutability::Mutable => hir::MutMutable,
|
||||||
MutImmutable => hir::MutImmutable,
|
Mutability::Immutable => hir::MutImmutable,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ impl<'a, 'v> Visitor<'v> for CheckConstFn<'a> {
|
||||||
for arg in &fd.inputs {
|
for arg in &fd.inputs {
|
||||||
match arg.pat.node {
|
match arg.pat.node {
|
||||||
ast::PatWild => {}
|
ast::PatWild => {}
|
||||||
ast::PatIdent(ast::BindingMode::ByValue(ast::MutImmutable), _, None) => {}
|
ast::PatIdent(ast::BindingMode::ByValue(ast::Mutability::Immutable), _, None) => {}
|
||||||
_ => {
|
_ => {
|
||||||
span_err!(self.sess, arg.pat.span, E0022,
|
span_err!(self.sess, arg.pat.span, E0022,
|
||||||
"arguments of constant functions can only \
|
"arguments of constant functions can only \
|
||||||
|
|
|
@ -807,7 +807,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
|
||||||
self.visit_pat(&p);
|
self.visit_pat(&p);
|
||||||
|
|
||||||
for &(id, ref p, immut, _) in &collector.collected_paths {
|
for &(id, ref p, immut, _) in &collector.collected_paths {
|
||||||
let value = if immut == ast::MutImmutable {
|
let value = if immut == ast::Mutability::Immutable {
|
||||||
value.to_string()
|
value.to_string()
|
||||||
} else {
|
} else {
|
||||||
"<mutable>".to_string()
|
"<mutable>".to_string()
|
||||||
|
@ -1200,7 +1200,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
|
||||||
let def = def_map.get(&id).unwrap().full_def();
|
let def = def_map.get(&id).unwrap().full_def();
|
||||||
match def {
|
match def {
|
||||||
Def::Local(_, id) => {
|
Def::Local(_, id) => {
|
||||||
let value = if immut == ast::MutImmutable {
|
let value = if immut == ast::Mutability::Immutable {
|
||||||
self.span.snippet(p.span).to_string()
|
self.span.snippet(p.span).to_string()
|
||||||
} else {
|
} else {
|
||||||
"<mutable>".to_string()
|
"<mutable>".to_string()
|
||||||
|
|
|
@ -248,8 +248,10 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
||||||
|
|
||||||
// If the variable is immutable, save the initialising expression.
|
// If the variable is immutable, save the initialising expression.
|
||||||
let (value, keyword) = match mt {
|
let (value, keyword) = match mt {
|
||||||
ast::MutMutable => (String::from("<mutable>"), keywords::Mut),
|
ast::Mutability::Mutable => (String::from("<mutable>"), keywords::Mut),
|
||||||
ast::MutImmutable => (self.span_utils.snippet(expr.span), keywords::Static),
|
ast::Mutability::Immutable => {
|
||||||
|
(self.span_utils.snippet(expr.span), keywords::Static)
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let sub_span = self.span_utils.sub_span_after_keyword(item.span, keyword);
|
let sub_span = self.span_utils.sub_span_after_keyword(item.span, keyword);
|
||||||
|
@ -758,12 +760,12 @@ impl<'v> Visitor<'v> for PathCollector {
|
||||||
match p.node {
|
match p.node {
|
||||||
ast::PatStruct(ref path, _, _) => {
|
ast::PatStruct(ref path, _, _) => {
|
||||||
self.collected_paths.push((p.id, path.clone(),
|
self.collected_paths.push((p.id, path.clone(),
|
||||||
ast::MutMutable, recorder::TypeRef));
|
ast::Mutability::Mutable, recorder::TypeRef));
|
||||||
}
|
}
|
||||||
ast::PatEnum(ref path, _) |
|
ast::PatEnum(ref path, _) |
|
||||||
ast::PatQPath(_, ref path) => {
|
ast::PatQPath(_, ref path) => {
|
||||||
self.collected_paths.push((p.id, path.clone(),
|
self.collected_paths.push((p.id, path.clone(),
|
||||||
ast::MutMutable, recorder::VarRef));
|
ast::Mutability::Mutable, recorder::VarRef));
|
||||||
}
|
}
|
||||||
ast::PatIdent(bm, ref path1, _) => {
|
ast::PatIdent(bm, ref path1, _) => {
|
||||||
debug!("PathCollector, visit ident in pat {}: {:?} {:?}",
|
debug!("PathCollector, visit ident in pat {}: {:?} {:?}",
|
||||||
|
@ -774,7 +776,7 @@ impl<'v> Visitor<'v> for PathCollector {
|
||||||
// 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::BindingMode::ByRef(_) => ast::MutImmutable,
|
ast::BindingMode::ByRef(_) => ast::Mutability::Immutable,
|
||||||
ast::BindingMode::ByValue(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
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
// The Rust abstract syntax tree.
|
// The Rust abstract syntax tree.
|
||||||
|
|
||||||
pub use self::Mutability::*;
|
|
||||||
pub use self::Pat_::*;
|
pub use self::Pat_::*;
|
||||||
pub use self::PathListItem_::*;
|
pub use self::PathListItem_::*;
|
||||||
pub use self::StrStyle::*;
|
pub use self::StrStyle::*;
|
||||||
|
@ -602,8 +601,8 @@ pub enum Pat_ {
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
|
||||||
pub enum Mutability {
|
pub enum Mutability {
|
||||||
MutMutable,
|
Mutable,
|
||||||
MutImmutable,
|
Immutable,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
|
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
|
||||||
|
|
|
@ -66,9 +66,10 @@ 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> {
|
||||||
|
let spanned = codemap::Spanned{ span: s, node: i };
|
||||||
P(Pat {
|
P(Pat {
|
||||||
id: id,
|
id: id,
|
||||||
node: PatIdent(BindingMode::ByValue(MutImmutable), codemap::Spanned{span:s, node:i}, None),
|
node: PatIdent(BindingMode::ByValue(Mutability::Immutable), spanned, None),
|
||||||
span: s
|
span: s
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,7 +207,7 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
|
||||||
span,
|
span,
|
||||||
ecx.ty_ident(span, ecx.ident_of("str")),
|
ecx.ty_ident(span, ecx.ident_of("str")),
|
||||||
Some(static_),
|
Some(static_),
|
||||||
ast::MutImmutable,
|
ast::Mutability::Immutable,
|
||||||
);
|
);
|
||||||
|
|
||||||
let ty = ecx.ty(
|
let ty = ecx.ty(
|
||||||
|
|
|
@ -512,7 +512,8 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||||
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::BindingMode::ByValue(ast::MutMutable))
|
let binding_mode = ast::BindingMode::ByValue(ast::Mutability::Mutable);
|
||||||
|
self.pat_ident_binding_mode(sp, ident, binding_mode)
|
||||||
} else {
|
} else {
|
||||||
self.pat_ident(sp, ident)
|
self.pat_ident(sp, ident)
|
||||||
};
|
};
|
||||||
|
@ -536,7 +537,8 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||||
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::BindingMode::ByValue(ast::MutMutable))
|
let binding_mode = ast::BindingMode::ByValue(ast::Mutability::Mutable);
|
||||||
|
self.pat_ident_binding_mode(sp, ident, binding_mode)
|
||||||
} else {
|
} else {
|
||||||
self.pat_ident(sp, ident)
|
self.pat_ident(sp, ident)
|
||||||
};
|
};
|
||||||
|
@ -636,10 +638,10 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
||||||
self.expr(sp, ast::ExprKind::TupField(expr, id))
|
self.expr(sp, ast::ExprKind::TupField(expr, id))
|
||||||
}
|
}
|
||||||
fn expr_addr_of(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr> {
|
fn expr_addr_of(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr> {
|
||||||
self.expr(sp, ast::ExprKind::AddrOf(ast::MutImmutable, e))
|
self.expr(sp, ast::ExprKind::AddrOf(ast::Mutability::Immutable, e))
|
||||||
}
|
}
|
||||||
fn expr_mut_addr_of(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr> {
|
fn expr_mut_addr_of(&self, sp: Span, e: P<ast::Expr>) -> P<ast::Expr> {
|
||||||
self.expr(sp, ast::ExprKind::AddrOf(ast::MutMutable, e))
|
self.expr(sp, ast::ExprKind::AddrOf(ast::Mutability::Mutable, e))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn expr_call(&self, span: Span, expr: P<ast::Expr>, args: Vec<P<ast::Expr>>) -> P<ast::Expr> {
|
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> {
|
||||||
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::BindingMode::ByValue(ast::MutImmutable))
|
let binding_mode = ast::BindingMode::ByValue(ast::Mutability::Immutable);
|
||||||
|
self.pat_ident_binding_mode(span, ident, binding_mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pat_ident_binding_mode(&self,
|
fn pat_ident_binding_mode(&self,
|
||||||
|
|
|
@ -896,7 +896,7 @@ mod tests {
|
||||||
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::BindingMode::ByValue(ast::MutImmutable),
|
node: ast::PatIdent(ast::BindingMode::ByValue(ast::Mutability::Immutable),
|
||||||
Spanned{ span:sp(0, 1),
|
Spanned{ span:sp(0, 1),
|
||||||
node: str_to_ident("b")
|
node: str_to_ident("b")
|
||||||
},
|
},
|
||||||
|
@ -932,7 +932,7 @@ mod tests {
|
||||||
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::BindingMode::ByValue(ast::MutImmutable),
|
ast::BindingMode::ByValue(ast::Mutability::Immutable),
|
||||||
Spanned{
|
Spanned{
|
||||||
span: sp(6,7),
|
span: sp(6,7),
|
||||||
node: str_to_ident("b")},
|
node: str_to_ident("b")},
|
||||||
|
|
|
@ -27,7 +27,7 @@ use ast::{Ident, Inherited, ImplItem, Item, ItemKind};
|
||||||
use ast::{Lit, LitKind, UintTy};
|
use ast::{Lit, LitKind, UintTy};
|
||||||
use ast::Local;
|
use ast::Local;
|
||||||
use ast::MacStmtStyle;
|
use ast::MacStmtStyle;
|
||||||
use ast::{MutImmutable, MutMutable, Mac_};
|
use ast::Mac_;
|
||||||
use ast::{MutTy, Mutability};
|
use ast::{MutTy, Mutability};
|
||||||
use ast::NamedField;
|
use ast::NamedField;
|
||||||
use ast::{Pat, PatBox, PatEnum, PatIdent, PatLit, PatQPath, PatMac, PatRange};
|
use ast::{Pat, PatBox, PatEnum, PatIdent, PatLit, PatQPath, PatMac, PatRange};
|
||||||
|
@ -1417,16 +1417,16 @@ impl<'a> Parser<'a> {
|
||||||
|
|
||||||
pub fn parse_ptr(&mut self) -> PResult<'a, MutTy> {
|
pub fn parse_ptr(&mut self) -> PResult<'a, MutTy> {
|
||||||
let mutbl = if self.eat_keyword(keywords::Mut) {
|
let mutbl = if self.eat_keyword(keywords::Mut) {
|
||||||
MutMutable
|
Mutability::Mutable
|
||||||
} else if self.eat_keyword(keywords::Const) {
|
} else if self.eat_keyword(keywords::Const) {
|
||||||
MutImmutable
|
Mutability::Immutable
|
||||||
} else {
|
} else {
|
||||||
let span = self.last_span;
|
let span = self.last_span;
|
||||||
self.span_err(span,
|
self.span_err(span,
|
||||||
"bare raw pointers are no longer allowed, you should \
|
"bare raw pointers are no longer allowed, you should \
|
||||||
likely use `*mut T`, but otherwise `*T` is now \
|
likely use `*mut T`, but otherwise `*T` is now \
|
||||||
known as `*const T`");
|
known as `*const T`");
|
||||||
MutImmutable
|
Mutability::Immutable
|
||||||
};
|
};
|
||||||
let t = try!(self.parse_ty());
|
let t = try!(self.parse_ty());
|
||||||
Ok(MutTy { ty: t, mutbl: mutbl })
|
Ok(MutTy { ty: t, mutbl: mutbl })
|
||||||
|
@ -1924,9 +1924,9 @@ impl<'a> Parser<'a> {
|
||||||
/// Parse mutability declaration (mut/const/imm)
|
/// Parse mutability declaration (mut/const/imm)
|
||||||
pub fn parse_mutability(&mut self) -> PResult<'a, Mutability> {
|
pub fn parse_mutability(&mut self) -> PResult<'a, Mutability> {
|
||||||
if self.eat_keyword(keywords::Mut) {
|
if self.eat_keyword(keywords::Mut) {
|
||||||
Ok(MutMutable)
|
Ok(Mutability::Mutable)
|
||||||
} else {
|
} else {
|
||||||
Ok(MutImmutable)
|
Ok(Mutability::Immutable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3350,10 +3350,10 @@ impl<'a> Parser<'a> {
|
||||||
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) => BindingMode::ByRef(MutMutable),
|
(true, true) => BindingMode::ByRef(Mutability::Mutable),
|
||||||
(true, false) => BindingMode::ByRef(MutImmutable),
|
(true, false) => BindingMode::ByRef(Mutability::Immutable),
|
||||||
(false, true) => BindingMode::ByValue(MutMutable),
|
(false, true) => BindingMode::ByValue(Mutability::Mutable),
|
||||||
(false, false) => BindingMode::ByValue(MutImmutable),
|
(false, false) => BindingMode::ByValue(Mutability::Immutable),
|
||||||
};
|
};
|
||||||
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{
|
||||||
|
@ -3448,7 +3448,7 @@ impl<'a> Parser<'a> {
|
||||||
// At this point, token != _, &, &&, (, [
|
// At this point, token != _, &, &&, (, [
|
||||||
if self.eat_keyword(keywords::Mut) {
|
if self.eat_keyword(keywords::Mut) {
|
||||||
// Parse mut ident @ pat
|
// Parse mut ident @ pat
|
||||||
pat = try!(self.parse_pat_ident(BindingMode::ByValue(MutMutable)));
|
pat = try!(self.parse_pat_ident(BindingMode::ByValue(Mutability::Mutable)));
|
||||||
} else if self.eat_keyword(keywords::Ref) {
|
} else if 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());
|
||||||
|
@ -3481,7 +3481,8 @@ impl<'a> Parser<'a> {
|
||||||
// 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(BindingMode::ByValue(MutImmutable)));
|
let binding_mode = BindingMode::ByValue(Mutability::Immutable);
|
||||||
|
pat = try!(self.parse_pat_ident(binding_mode));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let (qself, path) = if self.eat_lt() {
|
let (qself, path) = if self.eat_lt() {
|
||||||
|
@ -4408,7 +4409,7 @@ impl<'a> Parser<'a> {
|
||||||
|
|
||||||
if this.look_ahead(1, |t| t.is_keyword(keywords::SelfValue)) {
|
if this.look_ahead(1, |t| t.is_keyword(keywords::SelfValue)) {
|
||||||
this.bump();
|
this.bump();
|
||||||
Ok(SelfKind::Region(None, MutImmutable, try!(this.expect_self_ident())))
|
Ok(SelfKind::Region(None, Mutability::Immutable, try!(this.expect_self_ident())))
|
||||||
} else if this.look_ahead(1, |t| t.is_mutability()) &&
|
} else if this.look_ahead(1, |t| t.is_mutability()) &&
|
||||||
this.look_ahead(2, |t| t.is_keyword(keywords::SelfValue)) {
|
this.look_ahead(2, |t| t.is_keyword(keywords::SelfValue)) {
|
||||||
this.bump();
|
this.bump();
|
||||||
|
@ -4418,7 +4419,8 @@ impl<'a> Parser<'a> {
|
||||||
this.look_ahead(2, |t| t.is_keyword(keywords::SelfValue)) {
|
this.look_ahead(2, |t| t.is_keyword(keywords::SelfValue)) {
|
||||||
this.bump();
|
this.bump();
|
||||||
let lifetime = try!(this.parse_lifetime());
|
let lifetime = try!(this.parse_lifetime());
|
||||||
Ok(SelfKind::Region(Some(lifetime), MutImmutable, try!(this.expect_self_ident())))
|
let ident = try!(this.expect_self_ident());
|
||||||
|
Ok(SelfKind::Region(Some(lifetime), Mutability::Immutable, ident))
|
||||||
} else if this.look_ahead(1, |t| t.is_lifetime()) &&
|
} else if this.look_ahead(1, |t| t.is_lifetime()) &&
|
||||||
this.look_ahead(2, |t| t.is_mutability()) &&
|
this.look_ahead(2, |t| t.is_mutability()) &&
|
||||||
this.look_ahead(3, |t| t.is_keyword(keywords::SelfValue)) {
|
this.look_ahead(3, |t| t.is_keyword(keywords::SelfValue)) {
|
||||||
|
@ -4439,7 +4441,7 @@ impl<'a> Parser<'a> {
|
||||||
let mut self_ident_lo = self.span.lo;
|
let mut self_ident_lo = self.span.lo;
|
||||||
let mut self_ident_hi = self.span.hi;
|
let mut self_ident_hi = self.span.hi;
|
||||||
|
|
||||||
let mut mutbl_self = MutImmutable;
|
let mut mutbl_self = Mutability::Immutable;
|
||||||
let explicit_self = match self.token {
|
let explicit_self = match self.token {
|
||||||
token::BinOp(token::And) => {
|
token::BinOp(token::And) => {
|
||||||
let eself = try!(maybe_parse_borrowed_explicit_self(self));
|
let eself = try!(maybe_parse_borrowed_explicit_self(self));
|
||||||
|
@ -4454,7 +4456,7 @@ impl<'a> Parser<'a> {
|
||||||
let _mutability = if self.token.is_mutability() {
|
let _mutability = if self.token.is_mutability() {
|
||||||
try!(self.parse_mutability())
|
try!(self.parse_mutability())
|
||||||
} else {
|
} else {
|
||||||
MutImmutable
|
Mutability::Immutable
|
||||||
};
|
};
|
||||||
if self.is_self_ident() {
|
if self.is_self_ident() {
|
||||||
let span = self.span;
|
let span = self.span;
|
||||||
|
@ -5527,7 +5529,11 @@ impl<'a> Parser<'a> {
|
||||||
|
|
||||||
if self.eat_keyword(keywords::Static) {
|
if self.eat_keyword(keywords::Static) {
|
||||||
// STATIC ITEM
|
// STATIC ITEM
|
||||||
let m = if self.eat_keyword(keywords::Mut) {MutMutable} else {MutImmutable};
|
let m = if self.eat_keyword(keywords::Mut) {
|
||||||
|
Mutability::Mutable
|
||||||
|
} else {
|
||||||
|
Mutability::Immutable
|
||||||
|
};
|
||||||
let (ident, item_, extra_attrs) = try!(self.parse_item_const(Some(m)));
|
let (ident, item_, extra_attrs) = try!(self.parse_item_const(Some(m)));
|
||||||
let last_span = self.last_span;
|
let last_span = self.last_span;
|
||||||
let item = self.mk_item(lo,
|
let item = self.mk_item(lo,
|
||||||
|
|
|
@ -417,7 +417,7 @@ pub fn lit_to_string(l: &ast::Lit) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn explicit_self_to_string(explicit_self: &ast::SelfKind) -> String {
|
pub fn explicit_self_to_string(explicit_self: &ast::SelfKind) -> String {
|
||||||
to_string(|s| s.print_explicit_self(explicit_self, ast::MutImmutable).map(|_| {}))
|
to_string(|s| s.print_explicit_self(explicit_self, ast::Mutability::Immutable).map(|_| {}))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn variant_to_string(var: &ast::Variant) -> String {
|
pub fn variant_to_string(var: &ast::Variant) -> String {
|
||||||
|
@ -965,8 +965,8 @@ impl<'a> State<'a> {
|
||||||
ast::TyKind::Ptr(ref mt) => {
|
ast::TyKind::Ptr(ref mt) => {
|
||||||
try!(word(&mut self.s, "*"));
|
try!(word(&mut self.s, "*"));
|
||||||
match mt.mutbl {
|
match mt.mutbl {
|
||||||
ast::MutMutable => try!(self.word_nbsp("mut")),
|
ast::Mutability::Mutable => try!(self.word_nbsp("mut")),
|
||||||
ast::MutImmutable => try!(self.word_nbsp("const")),
|
ast::Mutability::Immutable => try!(self.word_nbsp("const")),
|
||||||
}
|
}
|
||||||
try!(self.print_type(&*mt.ty));
|
try!(self.print_type(&*mt.ty));
|
||||||
}
|
}
|
||||||
|
@ -1147,7 +1147,7 @@ impl<'a> State<'a> {
|
||||||
ast::ItemKind::Static(ref ty, m, ref expr) => {
|
ast::ItemKind::Static(ref ty, m, ref expr) => {
|
||||||
try!(self.head(&visibility_qualified(item.vis,
|
try!(self.head(&visibility_qualified(item.vis,
|
||||||
"static")));
|
"static")));
|
||||||
if m == ast::MutMutable {
|
if m == ast::Mutability::Mutable {
|
||||||
try!(self.word_space("mut"));
|
try!(self.word_space("mut"));
|
||||||
}
|
}
|
||||||
try!(self.print_ident(item.ident));
|
try!(self.print_ident(item.ident));
|
||||||
|
@ -2464,8 +2464,8 @@ impl<'a> State<'a> {
|
||||||
try!(self.word_nbsp("ref"));
|
try!(self.word_nbsp("ref"));
|
||||||
try!(self.print_mutability(mutbl));
|
try!(self.print_mutability(mutbl));
|
||||||
}
|
}
|
||||||
ast::BindingMode::ByValue(ast::MutImmutable) => {}
|
ast::BindingMode::ByValue(ast::Mutability::Immutable) => {}
|
||||||
ast::BindingMode::ByValue(ast::MutMutable) => {
|
ast::BindingMode::ByValue(ast::Mutability::Mutable) => {
|
||||||
try!(self.word_nbsp("mut"));
|
try!(self.word_nbsp("mut"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2534,7 +2534,7 @@ impl<'a> State<'a> {
|
||||||
}
|
}
|
||||||
ast::PatRegion(ref inner, mutbl) => {
|
ast::PatRegion(ref inner, mutbl) => {
|
||||||
try!(word(&mut self.s, "&"));
|
try!(word(&mut self.s, "&"));
|
||||||
if mutbl == ast::MutMutable {
|
if mutbl == ast::Mutability::Mutable {
|
||||||
try!(word(&mut self.s, "mut "));
|
try!(word(&mut self.s, "mut "));
|
||||||
}
|
}
|
||||||
try!(self.print_pat(&**inner));
|
try!(self.print_pat(&**inner));
|
||||||
|
@ -2669,10 +2669,10 @@ impl<'a> State<'a> {
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
if let Some(explicit_self) = opt_explicit_self {
|
if let Some(explicit_self) = opt_explicit_self {
|
||||||
let m = match *explicit_self {
|
let m = match *explicit_self {
|
||||||
ast::SelfKind::Static => ast::MutImmutable,
|
ast::SelfKind::Static => ast::Mutability::Immutable,
|
||||||
_ => match decl.inputs[0].pat.node {
|
_ => match decl.inputs[0].pat.node {
|
||||||
ast::PatIdent(ast::BindingMode::ByValue(m), _, _) => m,
|
ast::PatIdent(ast::BindingMode::ByValue(m), _, _) => m,
|
||||||
_ => ast::MutImmutable
|
_ => ast::Mutability::Immutable
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
first = !try!(self.print_explicit_self(explicit_self, m));
|
first = !try!(self.print_explicit_self(explicit_self, m));
|
||||||
|
@ -2946,8 +2946,8 @@ impl<'a> State<'a> {
|
||||||
pub fn print_mutability(&mut self,
|
pub fn print_mutability(&mut self,
|
||||||
mutbl: ast::Mutability) -> io::Result<()> {
|
mutbl: ast::Mutability) -> io::Result<()> {
|
||||||
match mutbl {
|
match mutbl {
|
||||||
ast::MutMutable => self.word_nbsp("mut"),
|
ast::Mutability::Mutable => self.word_nbsp("mut"),
|
||||||
ast::MutImmutable => Ok(()),
|
ast::Mutability::Immutable => Ok(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -593,7 +593,7 @@ fn mk_tests(cx: &TestCtxt) -> P<ast::Item> {
|
||||||
let static_type = ecx.ty_rptr(sp,
|
let static_type = ecx.ty_rptr(sp,
|
||||||
ecx.ty(sp, ast::TyKind::Vec(struct_type)),
|
ecx.ty(sp, ast::TyKind::Vec(struct_type)),
|
||||||
Some(static_lt),
|
Some(static_lt),
|
||||||
ast::MutImmutable);
|
ast::Mutability::Immutable);
|
||||||
// static TESTS: $static_type = &[...];
|
// static TESTS: $static_type = &[...];
|
||||||
ecx.item_const(sp,
|
ecx.item_const(sp,
|
||||||
ecx.ident_of("TESTS"),
|
ecx.ident_of("TESTS"),
|
||||||
|
@ -613,7 +613,7 @@ fn mk_test_descs(cx: &TestCtxt) -> P<ast::Expr> {
|
||||||
|
|
||||||
P(ast::Expr {
|
P(ast::Expr {
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
node: ast::ExprKind::AddrOf(ast::MutImmutable,
|
node: ast::ExprKind::AddrOf(ast::Mutability::Immutable,
|
||||||
P(ast::Expr {
|
P(ast::Expr {
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
node: ast::ExprKind::Vec(cx.testfns.iter().map(|test| {
|
node: ast::ExprKind::Vec(cx.testfns.iter().map(|test| {
|
||||||
|
|
|
@ -27,7 +27,7 @@ pub fn expand_deriving_debug(cx: &mut ExtCtxt,
|
||||||
{
|
{
|
||||||
// &mut ::std::fmt::Formatter
|
// &mut ::std::fmt::Formatter
|
||||||
let fmtr = Ptr(Box::new(Literal(path_std!(cx, core::fmt::Formatter))),
|
let fmtr = Ptr(Box::new(Literal(path_std!(cx, core::fmt::Formatter))),
|
||||||
Borrowed(None, ast::MutMutable));
|
Borrowed(None, ast::Mutability::Mutable));
|
||||||
|
|
||||||
let trait_def = TraitDef {
|
let trait_def = TraitDef {
|
||||||
span: span,
|
span: span,
|
||||||
|
|
|
@ -14,7 +14,7 @@ use deriving::generic::*;
|
||||||
use deriving::generic::ty::*;
|
use deriving::generic::ty::*;
|
||||||
|
|
||||||
use syntax::ast;
|
use syntax::ast;
|
||||||
use syntax::ast::{MetaItem, Expr, MutMutable};
|
use syntax::ast::{MetaItem, Expr, Mutability};
|
||||||
use syntax::codemap::Span;
|
use syntax::codemap::Span;
|
||||||
use syntax::ext::base::{ExtCtxt, Annotatable};
|
use syntax::ext::base::{ExtCtxt, Annotatable};
|
||||||
use syntax::ext::build::AstBuilder;
|
use syntax::ext::build::AstBuilder;
|
||||||
|
@ -72,7 +72,7 @@ fn expand_deriving_decodable_imp(cx: &mut ExtCtxt,
|
||||||
},
|
},
|
||||||
explicit_self: None,
|
explicit_self: None,
|
||||||
args: vec!(Ptr(Box::new(Literal(Path::new_local("__D"))),
|
args: vec!(Ptr(Box::new(Literal(Path::new_local("__D"))),
|
||||||
Borrowed(None, MutMutable))),
|
Borrowed(None, Mutability::Mutable))),
|
||||||
ret_ty: Literal(Path::new_(
|
ret_ty: Literal(Path::new_(
|
||||||
pathvec_std!(cx, core::result::Result),
|
pathvec_std!(cx, core::result::Result),
|
||||||
None,
|
None,
|
||||||
|
|
|
@ -91,7 +91,7 @@
|
||||||
use deriving::generic::*;
|
use deriving::generic::*;
|
||||||
use deriving::generic::ty::*;
|
use deriving::generic::ty::*;
|
||||||
|
|
||||||
use syntax::ast::{MetaItem, Expr, ExprKind, MutMutable};
|
use syntax::ast::{MetaItem, Expr, ExprKind, Mutability};
|
||||||
use syntax::codemap::Span;
|
use syntax::codemap::Span;
|
||||||
use syntax::ext::base::{ExtCtxt,Annotatable};
|
use syntax::ext::base::{ExtCtxt,Annotatable};
|
||||||
use syntax::ext::build::AstBuilder;
|
use syntax::ext::build::AstBuilder;
|
||||||
|
@ -148,7 +148,7 @@ fn expand_deriving_encodable_imp(cx: &mut ExtCtxt,
|
||||||
},
|
},
|
||||||
explicit_self: borrowed_explicit_self(),
|
explicit_self: borrowed_explicit_self(),
|
||||||
args: vec!(Ptr(Box::new(Literal(Path::new_local("__S"))),
|
args: vec!(Ptr(Box::new(Literal(Path::new_local("__S"))),
|
||||||
Borrowed(None, MutMutable))),
|
Borrowed(None, Mutability::Mutable))),
|
||||||
ret_ty: Literal(Path::new_(
|
ret_ty: Literal(Path::new_(
|
||||||
pathvec_std!(cx, core::result::Result),
|
pathvec_std!(cx, core::result::Result),
|
||||||
None,
|
None,
|
||||||
|
|
|
@ -864,7 +864,9 @@ impl<'a> MethodDef<'a> {
|
||||||
let self_arg = match explicit_self.node {
|
let self_arg = match explicit_self.node {
|
||||||
ast::SelfKind::Static => None,
|
ast::SelfKind::Static => None,
|
||||||
// creating fresh self id
|
// creating fresh self id
|
||||||
_ => Some(ast::Arg::new_self(trait_.span, ast::MutImmutable, special_idents::self_))
|
_ => Some(ast::Arg::new_self(trait_.span,
|
||||||
|
ast::Mutability::Immutable,
|
||||||
|
special_idents::self_))
|
||||||
};
|
};
|
||||||
let args = {
|
let args = {
|
||||||
let args = arg_types.into_iter().map(|(name, ty)| {
|
let args = arg_types.into_iter().map(|(name, ty)| {
|
||||||
|
@ -942,7 +944,7 @@ impl<'a> MethodDef<'a> {
|
||||||
struct_def,
|
struct_def,
|
||||||
&format!("__self_{}",
|
&format!("__self_{}",
|
||||||
i),
|
i),
|
||||||
ast::MutImmutable);
|
ast::Mutability::Immutable);
|
||||||
patterns.push(pat);
|
patterns.push(pat);
|
||||||
raw_fields.push(ident_expr);
|
raw_fields.push(ident_expr);
|
||||||
}
|
}
|
||||||
|
@ -1135,11 +1137,12 @@ impl<'a> MethodDef<'a> {
|
||||||
let mut match_arms: Vec<ast::Arm> = variants.iter().enumerate()
|
let mut match_arms: Vec<ast::Arm> = variants.iter().enumerate()
|
||||||
.map(|(index, variant)| {
|
.map(|(index, variant)| {
|
||||||
let mk_self_pat = |cx: &mut ExtCtxt, self_arg_name: &str| {
|
let mk_self_pat = |cx: &mut ExtCtxt, self_arg_name: &str| {
|
||||||
let (p, idents) = trait_.create_enum_variant_pattern(cx, type_ident,
|
let (p, idents) = trait_.create_enum_variant_pattern(
|
||||||
|
cx, type_ident,
|
||||||
&**variant,
|
&**variant,
|
||||||
self_arg_name,
|
self_arg_name,
|
||||||
ast::MutImmutable);
|
ast::Mutability::Immutable);
|
||||||
(cx.pat(sp, ast::PatRegion(p, ast::MutImmutable)), idents)
|
(cx.pat(sp, ast::PatRegion(p, ast::Mutability::Immutable)), idents)
|
||||||
};
|
};
|
||||||
|
|
||||||
// A single arm has form (&VariantK, &VariantK, ...) => BodyK
|
// A single arm has form (&VariantK, &VariantK, ...) => BodyK
|
||||||
|
|
|
@ -98,7 +98,7 @@ pub enum Ty<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn borrowed_ptrty<'r>() -> PtrTy<'r> {
|
pub fn borrowed_ptrty<'r>() -> PtrTy<'r> {
|
||||||
Borrowed(None, ast::MutImmutable)
|
Borrowed(None, ast::Mutability::Immutable)
|
||||||
}
|
}
|
||||||
pub fn borrowed<'r>(ty: Box<Ty<'r>>) -> Ty<'r> {
|
pub fn borrowed<'r>(ty: Box<Ty<'r>>) -> Ty<'r> {
|
||||||
Ptr(ty, borrowed_ptrty())
|
Ptr(ty, borrowed_ptrty())
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
use deriving::generic::*;
|
use deriving::generic::*;
|
||||||
use deriving::generic::ty::*;
|
use deriving::generic::ty::*;
|
||||||
|
|
||||||
use syntax::ast::{MetaItem, Expr, MutMutable};
|
use syntax::ast::{MetaItem, Expr, Mutability};
|
||||||
use syntax::codemap::Span;
|
use syntax::codemap::Span;
|
||||||
use syntax::ext::base::{ExtCtxt, Annotatable};
|
use syntax::ext::base::{ExtCtxt, Annotatable};
|
||||||
use syntax::ext::build::AstBuilder;
|
use syntax::ext::build::AstBuilder;
|
||||||
|
@ -43,7 +43,7 @@ pub fn expand_deriving_hash(cx: &mut ExtCtxt,
|
||||||
vec![path_std!(cx, core::hash::Hasher)])],
|
vec![path_std!(cx, core::hash::Hasher)])],
|
||||||
},
|
},
|
||||||
explicit_self: borrowed_explicit_self(),
|
explicit_self: borrowed_explicit_self(),
|
||||||
args: vec!(Ptr(Box::new(Literal(arg)), Borrowed(None, MutMutable))),
|
args: vec!(Ptr(Box::new(Literal(arg)), Borrowed(None, Mutability::Mutable))),
|
||||||
ret_ty: nil_ty(),
|
ret_ty: nil_ty(),
|
||||||
attributes: vec![],
|
attributes: vec![],
|
||||||
is_unsafe: false,
|
is_unsafe: false,
|
||||||
|
|
|
@ -42,7 +42,7 @@ pub fn expand_option_env<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenT
|
||||||
Some(cx.lifetime(sp,
|
Some(cx.lifetime(sp,
|
||||||
cx.ident_of(
|
cx.ident_of(
|
||||||
"'static").name)),
|
"'static").name)),
|
||||||
ast::MutImmutable)),
|
ast::Mutability::Immutable)),
|
||||||
Vec::new()))
|
Vec::new()))
|
||||||
}
|
}
|
||||||
Ok(s) => {
|
Ok(s) => {
|
||||||
|
|
|
@ -450,10 +450,10 @@ impl<'a, 'b> Context<'a, 'b> {
|
||||||
let ty = ecx.ty_rptr(sp,
|
let ty = ecx.ty_rptr(sp,
|
||||||
ecx.ty(sp, ast::TyKind::Vec(piece_ty)),
|
ecx.ty(sp, ast::TyKind::Vec(piece_ty)),
|
||||||
Some(ecx.lifetime(sp, special_idents::static_lifetime.name)),
|
Some(ecx.lifetime(sp, special_idents::static_lifetime.name)),
|
||||||
ast::MutImmutable);
|
ast::Mutability::Immutable);
|
||||||
let slice = ecx.expr_vec_slice(sp, pieces);
|
let slice = ecx.expr_vec_slice(sp, pieces);
|
||||||
// static instead of const to speed up codegen by not requiring this to be inlined
|
// static instead of const to speed up codegen by not requiring this to be inlined
|
||||||
let st = ast::ItemKind::Static(ty, ast::MutImmutable, slice);
|
let st = ast::ItemKind::Static(ty, ast::Mutability::Immutable, slice);
|
||||||
|
|
||||||
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);
|
||||||
|
@ -480,7 +480,7 @@ impl<'a, 'b> Context<'a, 'b> {
|
||||||
self.fmtsp,
|
self.fmtsp,
|
||||||
self.ecx.ty_ident(self.fmtsp, self.ecx.ident_of("str")),
|
self.ecx.ty_ident(self.fmtsp, self.ecx.ident_of("str")),
|
||||||
Some(static_lifetime),
|
Some(static_lifetime),
|
||||||
ast::MutImmutable);
|
ast::Mutability::Immutable);
|
||||||
let pieces = Context::static_array(self.ecx,
|
let pieces = Context::static_array(self.ecx,
|
||||||
"__STATIC_FMTSTR",
|
"__STATIC_FMTSTR",
|
||||||
piece_ty,
|
piece_ty,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue