]> git.lizzy.rs Git - rust.git/blobdiff - src/libsyntax/parse/obsolete.rs
use TotalEq for HashMap
[rust.git] / src / libsyntax / parse / obsolete.rs
index dba4f62aa9c7e6a5858f80114c648c34330a046b..63b3fb09ee3cd55da52b8badc91fc3c81540b1ba 100644 (file)
 use parse::parser::Parser;
 use parse::token;
 
-use std::str;
-use std::to_bytes;
-
 /// The specific types of unsupported syntax
-#[deriving(Eq)]
+#[deriving(Eq, TotalEq, Hash)]
 pub enum ObsoleteSyntax {
     ObsoleteSwap,
     ObsoleteUnsafeBlock,
     ObsoleteBareFnType,
-    ObsoleteNamedExternModule,
     ObsoleteMultipleLocalDecl,
     ObsoleteUnsafeExternFn,
     ObsoleteTraitFuncVisibility,
     ObsoleteConstPointer,
-    ObsoleteEmptyImpl,
     ObsoleteLoopAsContinue,
     ObsoleteEnumWildcard,
     ObsoleteStructWildcard,
@@ -44,14 +39,9 @@ pub enum ObsoleteSyntax {
     ObsoleteBoxedClosure,
     ObsoleteClosureType,
     ObsoleteMultipleImport,
-    ObsoleteExternModAttributesInParens
-}
-
-impl to_bytes::IterBytes for ObsoleteSyntax {
-    #[inline]
-    fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
-        (*self as uint).iter_bytes(lsb0, f)
-    }
+    ObsoleteManagedPattern,
+    ObsoleteManagedString,
+    ObsoleteManagedVec,
 }
 
 pub trait ParserObsoleteMethods {
@@ -69,13 +59,13 @@ fn report(&mut self,
     fn eat_obsolete_ident(&mut self, ident: &str) -> bool;
 }
 
-impl ParserObsoleteMethods for Parser {
+impl<'a> ParserObsoleteMethods for Parser<'a> {
     /// Reports an obsolete syntax non-fatal error.
     fn obsolete(&mut self, sp: Span, kind: ObsoleteSyntax) {
         let (kind_str, desc) = match kind {
             ObsoleteSwap => (
                 "swap",
-                "Use std::util::{swap, replace} instead"
+                "use std::mem::{swap, replace} instead"
             ),
             ObsoleteUnsafeBlock => (
                 "non-standalone unsafe block",
@@ -85,11 +75,6 @@ fn obsolete(&mut self, sp: Span, kind: ObsoleteSyntax) {
                 "bare function type",
                 "use `|A| -> B` or `extern fn(A) -> B` instead"
             ),
-            ObsoleteNamedExternModule => (
-                "named external module",
-                "instead of `extern mod foo { ... }`, write `mod foo { \
-                 extern { ... } }`"
-            ),
             ObsoleteMultipleLocalDecl => (
                 "declaration of multiple locals at once",
                 "instead of e.g. `let a = 1, b = 2`, write \
@@ -109,10 +94,6 @@ fn obsolete(&mut self, sp: Span, kind: ObsoleteSyntax) {
                 "instead of `&const Foo` or `@const Foo`, write `&Foo` or \
                  `@Foo`"
             ),
-            ObsoleteEmptyImpl => (
-                "empty implementation",
-                "instead of `impl A;`, write `impl A {}`"
-            ),
             ObsoleteLoopAsContinue => (
                 "`loop` instead of `continue`",
                 "`loop` is now only used for loops and `continue` is used for \
@@ -144,11 +125,19 @@ fn obsolete(&mut self, sp: Span, kind: ObsoleteSyntax) {
                 "multiple imports",
                 "only one import is allowed per `use` statement"
             ),
-            ObsoleteExternModAttributesInParens => (
-                "`extern mod` with linkage attribute list",
-                "use `extern mod foo = \"bar\";` instead of \
-                `extern mod foo (name = \"bar\")`"
-            )
+            ObsoleteManagedPattern => (
+                "managed pointer pattern",
+                "use a nested `match` expression instead of a managed box \
+                 pattern"
+            ),
+            ObsoleteManagedString => (
+                "managed string",
+                "use `Rc<~str>` instead of a managed string"
+            ),
+            ObsoleteManagedVec => (
+                "managed vector",
+                "use `Rc<~[T]>` instead of a managed vector"
+            ),
         };
 
         self.report(sp, kind, kind_str, desc);
@@ -177,7 +166,7 @@ fn report(&mut self,
     fn is_obsolete_ident(&mut self, ident: &str) -> bool {
         match self.token {
             token::IDENT(sid, _) => {
-                str::eq_slice(self.id_to_str(sid), ident)
+                token::get_ident(sid).equiv(&ident)
             }
             _ => false
         }