about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-08-31 19:55:51 +0000
committerbors <bors@rust-lang.org>2014-08-31 19:55:51 +0000
commit5dfb7a6ec1c1b7827a1f019b276c4d959cf2d71e (patch)
tree05786d52abbbe15e26582f035238081023edbe36
parent08176a356124322dfe9ec33b7846a517fc7ae532 (diff)
parent539237372a81c377ace29519381a8e09bfa6c451 (diff)
downloadrust-5dfb7a6ec1c1b7827a1f019b276c4d959cf2d71e.tar.gz
rust-5dfb7a6ec1c1b7827a1f019b276c4d959cf2d71e.zip
auto merge of #16809 : nick29581/rust/dst-bug-3, r=alexcrichton
This corrects a rebasing error. Also adds a test so it won't happen again.

r?
-rw-r--r--src/libsyntax/parse/parser.rs19
-rw-r--r--src/test/compile-fail/obsolete-tilde.rs21
2 files changed, 27 insertions, 13 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index fc93e482adc..d3700059862 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -1416,14 +1416,10 @@ impl<'a> Parser<'a> {
         } else if self.token == token::TILDE {
             // OWNED POINTER
             self.bump();
-            let span = self.last_span;
+            let last_span = self.last_span;
             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(span, ObsoleteOwnedType)
+                token::LBRACKET => self.obsolete(last_span, ObsoleteOwnedVector),
+                _ => self.obsolete(last_span, ObsoleteOwnedType)
             }
             TyUniq(self.parse_ty(false))
         } else if self.token == token::BINOP(token::STAR) {
@@ -2561,13 +2557,10 @@ impl<'a> Parser<'a> {
           }
           token::TILDE => {
             self.bump();
-            let span = self.last_span;
+            let last_span = self.last_span;
             match self.token {
-                token::LIT_STR(_) => {
-                    // This is OK (for now).
-                }
-                token::LBRACKET => {}   // Also OK.
-                _ => self.obsolete(span, ObsoleteOwnedExpr)
+                token::LBRACKET => self.obsolete(last_span, ObsoleteOwnedVector),
+                _ => self.obsolete(last_span, ObsoleteOwnedExpr)
             }
 
             let e = self.parse_prefix_expr();
diff --git a/src/test/compile-fail/obsolete-tilde.rs b/src/test/compile-fail/obsolete-tilde.rs
new file mode 100644
index 00000000000..fa59798c1d5
--- /dev/null
+++ b/src/test/compile-fail/obsolete-tilde.rs
@@ -0,0 +1,21 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test that ~ pointers give an obsolescence message.
+
+fn foo(x: ~int) {} //~ ERROR obsolete syntax: `~` notation for owned pointers
+fn bar(x: ~str) {} //~ ERROR obsolete syntax: `~` notation for owned pointers
+fn baz(x: ~[int]) {} //~ ERROR obsolete syntax: `~[T]` is no longer a type
+
+fn main() {
+    let x = ~4i; //~ ERROR obsolete syntax: `~` notation for owned pointer allocation
+    let y = ~"hello"; //~ ERROR obsolete syntax: `~` notation for owned pointer allocation
+    let z = ~[1i, 2, 3]; //~ ERROR obsolete syntax: `~[T]` is no longer a type
+}