diff options
| author | bors <bors@rust-lang.org> | 2014-01-14 12:32:11 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-01-14 12:32:11 -0800 |
| commit | 9075025c7b48ffc028b3bddbb983ceac98ce9636 (patch) | |
| tree | e3e7c8832f1d8ecf7700665f91b2938e8bcb01b6 /src/libsyntax | |
| parent | b77a7e76a18f0d2237813428425c80bf78faf772 (diff) | |
| parent | 509fc92a9bb6f9a251308476ebf4e76795df60bf (diff) | |
| download | rust-9075025c7b48ffc028b3bddbb983ceac98ce9636.tar.gz rust-9075025c7b48ffc028b3bddbb983ceac98ce9636.zip | |
auto merge of #11485 : eddyb/rust/sweep-old-rust, r=nikomatsakis
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 8 | ||||
| -rw-r--r-- | src/libsyntax/ext/deriving/ty.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/fold.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 98 | ||||
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/visit.rs | 2 |
6 files changed, 50 insertions, 66 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index ab16ab153d9..b113308ca51 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -959,10 +959,10 @@ pub enum RetStyle { #[deriving(Clone, Eq, Encodable, Decodable, IterBytes)] pub enum ExplicitSelf_ { SelfStatic, // no self - SelfValue(Mutability), // `self` - SelfRegion(Option<Lifetime>, Mutability), // `&'lt self` - SelfBox(Mutability), // `@self` - SelfUniq(Mutability) // `~self` + SelfValue(Mutability), // `self`, `mut self` + SelfRegion(Option<Lifetime>, Mutability), // `&'lt self`, `&'lt mut self` + SelfBox, // `@self` + SelfUniq(Mutability) // `~self`, `mut ~self` } pub type ExplicitSelf = Spanned<ExplicitSelf_>; diff --git a/src/libsyntax/ext/deriving/ty.rs b/src/libsyntax/ext/deriving/ty.rs index a2e69cd377a..c2b32b45ce4 100644 --- a/src/libsyntax/ext/deriving/ty.rs +++ b/src/libsyntax/ext/deriving/ty.rs @@ -251,7 +251,7 @@ pub fn get_explicit_self(cx: &ExtCtxt, span: Span, self_ptr: &Option<PtrTy>) span, match *ptr { Send => ast::SelfUniq(ast::MutImmutable), - Managed => ast::SelfBox(ast::MutImmutable), + Managed => ast::SelfBox, Borrowed(ref lt, mutbl) => { let lt = lt.map(|s| cx.lifetime(span, cx.ident_of(s))); ast::SelfRegion(lt, mutbl) diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index d3862cdf1a1..35b29783b67 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -319,7 +319,7 @@ pub trait Folder { fn fold_explicit_self_(&mut self, es: &ExplicitSelf_) -> ExplicitSelf_ { match *es { - SelfStatic | SelfValue(_) | SelfUniq(_) | SelfBox(_) => { + SelfStatic | SelfValue(_) | SelfUniq(_) | SelfBox => { *es } SelfRegion(ref lifetime, m) => { diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 715ce644726..6945eea285d 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -142,8 +142,6 @@ at INTERPOLATED tokens */ macro_rules! maybe_whole_expr ( ($p:expr) => ( { - // This horrible convolution is brought to you by - // @mut, have a terrible day let mut maybe_path = match ($p).token { INTERPOLATED(token::NtPath(ref pt)) => Some((**pt).clone()), _ => None, @@ -3647,20 +3645,14 @@ impl Parser { // that may have a self type. fn parse_fn_decl_with_self(&mut self, parse_arg_fn: |&mut Parser| -> Arg) -> (ExplicitSelf, P<FnDecl>) { - fn maybe_parse_explicit_self(cnstr: |v: Mutability| -> - ast::ExplicitSelf_, + fn maybe_parse_explicit_self(explicit_self: ast::ExplicitSelf_, p: &mut Parser) -> ast::ExplicitSelf_ { // We need to make sure it isn't a type - if p.look_ahead(1, |t| token::is_keyword(keywords::Self, t)) || - ((p.look_ahead(1, |t| token::is_keyword(keywords::Const, t)) || - p.look_ahead(1, |t| token::is_keyword(keywords::Mut, t))) && - p.look_ahead(2, |t| token::is_keyword(keywords::Self, t))) { - + if p.look_ahead(1, |t| token::is_keyword(keywords::Self, t)) { p.bump(); - let mutability = p.parse_mutability(); p.expect_self_ident(); - cnstr(mutability) + explicit_self } else { SelfStatic } @@ -3719,55 +3711,47 @@ impl Parser { // backwards compatible. let lo = self.span.lo; let explicit_self = match self.token { - token::BINOP(token::AND) => { - maybe_parse_borrowed_explicit_self(self) - } - token::AT => { - maybe_parse_explicit_self(SelfBox, self) - } - token::TILDE => { - maybe_parse_explicit_self(|mutability| { - if mutability != MutImmutable { - self.span_err(self.last_span, - "mutability declaration not allowed here"); + token::BINOP(token::AND) => { + maybe_parse_borrowed_explicit_self(self) + } + token::AT => { + maybe_parse_explicit_self(SelfBox, self) + } + token::TILDE => { + maybe_parse_explicit_self(SelfUniq(MutImmutable), self) + } + token::IDENT(..) if self.is_self_ident() => { + self.bump(); + SelfValue(MutImmutable) + } + token::BINOP(token::STAR) => { + // Possibly "*self" or "*mut self" -- not supported. Try to avoid + // emitting cryptic "unexpected token" errors. + self.bump(); + let mutability = if Parser::token_is_mutability(&self.token) { + self.parse_mutability() + } else { MutImmutable }; + if self.is_self_ident() { + self.span_err(self.span, "cannot pass self by unsafe pointer"); + self.bump(); } - SelfUniq(MutImmutable) - }, self) - } - token::IDENT(..) if self.is_self_ident() => { - self.bump(); - SelfValue(MutImmutable) - } - token::BINOP(token::STAR) => { - // Possibly "*self" or "*mut self" -- not supported. Try to avoid - // emitting cryptic "unexpected token" errors. - self.bump(); - let mutability = if Parser::token_is_mutability(&self.token) { - self.parse_mutability() - } else { MutImmutable }; - if self.is_self_ident() { - self.span_err(self.span, "cannot pass self by unsafe pointer"); + SelfValue(mutability) + } + _ if Parser::token_is_mutability(&self.token) && + self.look_ahead(1, |t| token::is_keyword(keywords::Self, t)) => { + let mutability = self.parse_mutability(); + self.expect_self_ident(); + SelfValue(mutability) + } + _ if Parser::token_is_mutability(&self.token) && + self.look_ahead(1, |t| *t == token::TILDE) && + self.look_ahead(2, |t| token::is_keyword(keywords::Self, t)) => { + let mutability = self.parse_mutability(); self.bump(); + self.expect_self_ident(); + SelfUniq(mutability) } - SelfValue(mutability) - } - _ if Parser::token_is_mutability(&self.token) && - self.look_ahead(1, |t| token::is_keyword(keywords::Self, t)) => { - let mutability = self.parse_mutability(); - self.expect_self_ident(); - SelfValue(mutability) - } - _ if Parser::token_is_mutability(&self.token) && - self.look_ahead(1, |t| *t == token::TILDE) && - self.look_ahead(2, |t| token::is_keyword(keywords::Self, t)) => { - let mutability = self.parse_mutability(); - self.bump(); - self.expect_self_ident(); - SelfUniq(mutability) - } - _ => { - SelfStatic - } + _ => SelfStatic }; // If we parsed a self type, expect a comma before the argument list. diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index b6db827f7b8..02c7b3f2086 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1770,8 +1770,8 @@ pub fn print_explicit_self(s: &mut State, explicit_self: ast::ExplicitSelf_) -> print_mutability(s, m); word(&mut s.s, "self"); } - ast::SelfBox(m) => { - word(&mut s.s, "@"); print_mutability(s, m); word(&mut s.s, "self"); + ast::SelfBox => { + word(&mut s.s, "@self"); } } return true; diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index ffea4b6dc75..d79522b7103 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -175,7 +175,7 @@ fn walk_explicit_self<E: Clone, V: Visitor<E>>(visitor: &mut V, explicit_self: &ExplicitSelf, env: E) { match explicit_self.node { - SelfStatic | SelfValue(_) | SelfBox(_) | SelfUniq(_) => {} + SelfStatic | SelfValue(_) | SelfBox | SelfUniq(_) => {} SelfRegion(ref lifetime, _) => { visitor.visit_opt_lifetime_ref(explicit_self.span, lifetime, env) } |
