diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2014-05-05 18:56:44 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2014-05-06 23:12:54 -0700 |
| commit | 090040bf4037a094e50b03d79e4baf5cd89c912b (patch) | |
| tree | 27fa91d623889d59260d3db167abdfa8c4288849 /src/libsyntax/parse | |
| parent | 24f6f26e633e50b5b59f9d0f6cca0b1e49e215d9 (diff) | |
| download | rust-090040bf4037a094e50b03d79e4baf5cd89c912b.tar.gz rust-090040bf4037a094e50b03d79e4baf5cd89c912b.zip | |
librustc: Remove `~EXPR`, `~TYPE`, and `~PAT` from the language, except
for `~str`/`~[]`. Note that `~self` still remains, since I forgot to add support for `Box<self>` before the snapshot. How to update your code: * Instead of `~EXPR`, you should write `box EXPR`. * Instead of `~TYPE`, you should write `Box<Type>`. * Instead of `~PATTERN`, you should write `box PATTERN`. [breaking-change]
Diffstat (limited to 'src/libsyntax/parse')
| -rw-r--r-- | src/libsyntax/parse/obsolete.rs | 15 | ||||
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 26 | ||||
| -rw-r--r-- | src/libsyntax/parse/token.rs | 4 |
3 files changed, 38 insertions, 7 deletions
diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index d09a002e117..b9157e0043d 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -40,6 +40,9 @@ pub enum ObsoleteSyntax { ObsoleteManagedPattern, ObsoleteManagedString, ObsoleteManagedVec, + ObsoleteOwnedType, + ObsoleteOwnedExpr, + ObsoleteOwnedPattern, } pub trait ParserObsoleteMethods { @@ -126,6 +129,18 @@ impl<'a> ParserObsoleteMethods for Parser<'a> { "managed vector", "use `Rc<~[T]>` instead of a managed vector" ), + ObsoleteOwnedType => ( + "`~` notation for owned pointers", + "use `Box<T>` in `std::owned` instead" + ), + ObsoleteOwnedExpr => ( + "`~` notation for owned pointer allocation", + "use the `box` operator instead of `~`" + ), + ObsoleteOwnedPattern => ( + "`~` notation for owned pointer patterns", + "use the `box` operator instead of `~`" + ), }; self.report(sp, kind, kind_str, desc); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 11a773a7f09..74c2ab9c494 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -273,7 +273,10 @@ struct ParsedItemsAndViewItems { /* ident is handled by common.rs */ -pub fn Parser<'a>(sess: &'a ParseSess, cfg: ast::CrateConfig, mut rdr: ~Reader:) +pub fn Parser<'a>( + sess: &'a ParseSess, + cfg: ast::CrateConfig, + mut rdr: Box<Reader:>) -> Parser<'a> { let tok0 = rdr.next_token(); let span = tok0.sp; @@ -318,14 +321,14 @@ pub struct Parser<'a> { pub last_span: Span, pub cfg: CrateConfig, // the previous token or None (only stashed sometimes). - pub last_token: Option<~token::Token>, + pub last_token: Option<Box<token::Token>>, pub buffer: [TokenAndSpan, ..4], pub buffer_start: int, pub buffer_end: int, pub tokens_consumed: uint, pub restriction: restriction, pub quote_depth: uint, // not (yet) related to the quasiquoter - pub reader: ~Reader:, + pub reader: Box<Reader:>, pub interner: Rc<token::IdentInterner>, /// The set of seen errors about obsolete syntax. Used to suppress /// extra detail when the same error is seen twice @@ -1221,6 +1224,14 @@ impl<'a> Parser<'a> { } else if self.token == token::TILDE { // OWNED POINTER self.bump(); + match self.token { + token::IDENT(ref ident, _) + if "str" == token::get_ident(*ident).get() => { + // This is OK (for now). + } + token::LBRACKET => {} // Also OK. + _ => self.obsolete(self.last_span, ObsoleteOwnedType), + }; TyUniq(self.parse_ty(false)) } else if self.token == token::BINOP(token::STAR) { // STAR POINTER (bare pointer?) @@ -1445,7 +1456,7 @@ impl<'a> Parser<'a> { _ => None, }; match found { - Some(INTERPOLATED(token::NtPath(~path))) => { + Some(INTERPOLATED(token::NtPath(box path))) => { return PathAndBounds { path: path, bounds: None, @@ -2258,9 +2269,13 @@ impl<'a> Parser<'a> { ex = match e.node { ExprVec(..) | ExprRepeat(..) => ExprVstore(e, ExprVstoreUniq), ExprLit(lit) if lit_is_str(lit) => { + self.obsolete(self.last_span, ObsoleteOwnedExpr); ExprVstore(e, ExprVstoreUniq) } - _ => self.mk_unary(UnUniq, e) + _ => { + self.obsolete(self.last_span, ObsoleteOwnedExpr); + self.mk_unary(UnUniq, e) + } }; } token::IDENT(_, _) if self.is_keyword(keywords::Box) => { @@ -2772,6 +2787,7 @@ impl<'a> Parser<'a> { let sub = self.parse_pat(); pat = PatUniq(sub); hi = self.last_span.hi; + self.obsolete(self.last_span, ObsoleteOwnedPattern); return @ast::Pat { id: ast::DUMMY_NODE_ID, node: pat, diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 519a7d141d3..e4e71baad44 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -113,9 +113,9 @@ pub enum Nonterminal { NtPat( @ast::Pat), NtExpr(@ast::Expr), NtTy( P<ast::Ty>), - NtIdent(~ast::Ident, bool), + NtIdent(Box<ast::Ident>, bool), NtMeta(@ast::MetaItem), // stuff inside brackets for attributes - NtPath(~ast::Path), + NtPath(Box<ast::Path>), NtTT( @ast::TokenTree), // needs @ed to break a circularity NtMatchers(Vec<ast::Matcher> ) } |
