]> git.lizzy.rs Git - rust.git/commitdiff
syntax: Remove uses of #[feature(slice_patterns)]
authorErick Tryzelaar <erick.tryzelaar@gmail.com>
Thu, 16 Apr 2015 05:12:12 +0000 (22:12 -0700)
committerErick Tryzelaar <erick.tryzelaar@gmail.com>
Tue, 21 Apr 2015 17:08:26 +0000 (10:08 -0700)
src/libsyntax/config.rs
src/libsyntax/diagnostics/plugin.rs
src/libsyntax/ext/deriving/cmp/ord.rs
src/libsyntax/ext/deriving/cmp/partial_eq.rs
src/libsyntax/ext/deriving/cmp/partial_ord.rs
src/libsyntax/ext/deriving/hash.rs
src/libsyntax/ext/deriving/primitive.rs
src/libsyntax/ext/expand.rs
src/libsyntax/ext/trace_macros.rs
src/libsyntax/lib.rs
src/libsyntax/parse/mod.rs

index 489a7721d7ba770a117add88db41d25b25353fe8..366806bc19b4962882552eb27725679acb9d1177 100644 (file)
@@ -284,8 +284,15 @@ fn fold_attribute(&mut self, attr: ast::Attribute) -> Option<ast::Attribute> {
             return fold::noop_fold_attribute(attr, self);
         }
 
-        let (cfg, mi) = match attr.meta_item_list() {
-            Some([ref cfg, ref mi]) => (cfg, mi),
+        let attr_list = match attr.meta_item_list() {
+            Some(attr_list) => attr_list,
+            None => {
+                self.diag.span_err(attr.span, "expected `#[cfg_attr(<cfg pattern>, <attr>)]`");
+                return None;
+            }
+        };
+        let (cfg, mi) = match (attr_list.len(), attr_list.get(0), attr_list.get(1)) {
+            (2, Some(cfg), Some(mi)) => (cfg, mi),
             _ => {
                 self.diag.span_err(attr.span, "expected `#[cfg_attr(<cfg pattern>, <attr>)]`");
                 return None;
index 6fcf39f0b174bf5ec4b57626740b707fc4fe9029..ac25a303182c57b68fbafa5c96024ca7d44f97f0 100644 (file)
@@ -54,8 +54,8 @@ pub fn expand_diagnostic_used<'cx>(ecx: &'cx mut ExtCtxt,
                                    span: Span,
                                    token_tree: &[TokenTree])
                                    -> Box<MacResult+'cx> {
-    let code = match token_tree {
-        [ast::TtToken(_, token::Ident(code, _))] => code,
+    let code = match (token_tree.len(), token_tree.get(0)) {
+        (1, Some(&ast::TtToken(_, token::Ident(code, _)))) => code,
         _ => unreachable!()
     };
     with_used_diagnostics(|diagnostics| {
@@ -84,13 +84,18 @@ pub fn expand_register_diagnostic<'cx>(ecx: &'cx mut ExtCtxt,
                                        span: Span,
                                        token_tree: &[TokenTree])
                                        -> Box<MacResult+'cx> {
-    let (code, description) = match token_tree {
-        [ast::TtToken(_, token::Ident(ref code, _))] => {
+    let (code, description) = match (
+        token_tree.len(),
+        token_tree.get(0),
+        token_tree.get(1),
+        token_tree.get(2)
+    ) {
+        (1, Some(&ast::TtToken(_, token::Ident(ref code, _))), None, None) => {
             (code, None)
         },
-        [ast::TtToken(_, token::Ident(ref code, _)),
-         ast::TtToken(_, token::Comma),
-         ast::TtToken(_, token::Literal(token::StrRaw(description, _), None))] => {
+        (3, Some(&ast::TtToken(_, token::Ident(ref code, _))),
+            Some(&ast::TtToken(_, token::Comma)),
+            Some(&ast::TtToken(_, token::Literal(token::StrRaw(description, _), None)))) => {
             (code, Some(description))
         }
         _ => unreachable!()
@@ -130,8 +135,8 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
                                           span: Span,
                                           token_tree: &[TokenTree])
                                           -> Box<MacResult+'cx> {
-    let name = match token_tree {
-        [ast::TtToken(_, token::Ident(ref name, _))] => name,
+    let name = match (token_tree.len(), token_tree.get(0)) {
+        (1, Some(&ast::TtToken(_, token::Ident(ref name, _)))) => name,
         _ => unreachable!()
     };
 
index b2a4ef1dafbc8ee7415e499e562122684b72cfd3..94cc0d9c493f21dc0abfe6e09b1082138fb26f27 100644 (file)
@@ -106,8 +106,8 @@ pub fn cs_cmp(cx: &mut ExtCtxt, span: Span,
             // }
 
             let new = {
-                let other_f = match other_fs {
-                    [ref o_f] => o_f,
+                let other_f = match (other_fs.len(), other_fs.get(0)) {
+                    (1, Some(o_f)) => o_f,
                     _ => cx.span_bug(span, "not exactly 2 arguments in `derive(PartialOrd)`"),
                 };
 
index f02e5ee14126d57c77ff5eff8e83920a07d7d97d..61eb81c6755e2663e37baf05b61c1804dd5f6902 100644 (file)
@@ -29,8 +29,8 @@ fn cs_eq(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> P<Expr> {
         cs_fold(
             true,  // use foldl
             |cx, span, subexpr, self_f, other_fs| {
-                let other_f = match other_fs {
-                    [ref o_f] => o_f,
+                let other_f = match (other_fs.len(), other_fs.get(0)) {
+                    (1, Some(o_f)) => o_f,
                     _ => cx.span_bug(span, "not exactly 2 arguments in `derive(PartialEq)`")
                 };
 
@@ -46,8 +46,8 @@ fn cs_ne(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> P<Expr> {
         cs_fold(
             true,  // use foldl
             |cx, span, subexpr, self_f, other_fs| {
-                let other_f = match other_fs {
-                    [ref o_f] => o_f,
+                let other_f = match (other_fs.len(), other_fs.get(0)) {
+                    (1, Some(o_f)) => o_f,
                     _ => cx.span_bug(span, "not exactly 2 arguments in `derive(PartialEq)`")
                 };
 
index fe6a8fea78c702d26de96b08ec2ac30bb3ab0305..dbb779decace27715f6eab03ff5ac36299a91a58 100644 (file)
@@ -150,8 +150,8 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt, span: Span,
             // }
 
             let new = {
-                let other_f = match other_fs {
-                    [ref o_f] => o_f,
+                let other_f = match (other_fs.len(), other_fs.get(0)) {
+                    (1, Some(o_f)) => o_f,
                     _ => cx.span_bug(span, "not exactly 2 arguments in `derive(PartialOrd)`"),
                 };
 
@@ -208,8 +208,8 @@ fn cs_op(less: bool, equal: bool, cx: &mut ExtCtxt,
             get use the binops to avoid auto-deref dereferencing too many
             layers of pointers, if the type includes pointers.
             */
-            let other_f = match other_fs {
-                [ref o_f] => o_f,
+            let other_f = match (other_fs.len(), other_fs.get(0)) {
+                (1, Some(o_f)) => o_f,
                 _ => cx.span_bug(span, "not exactly 2 arguments in `derive(PartialOrd)`")
             };
 
index 915d99796152d8091db2b7269673462f9f2071d0..b9835eda791f7f004589c170bc7b600d76eb1fab 100644 (file)
@@ -56,8 +56,8 @@ pub fn expand_deriving_hash(cx: &mut ExtCtxt,
 }
 
 fn hash_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> P<Expr> {
-    let state_expr = match substr.nonself_args {
-        [ref state_expr] => state_expr,
+    let state_expr = match (substr.nonself_args.len(), substr.nonself_args.get(0)) {
+        (1, Some(o_f)) => o_f,
         _ => cx.span_bug(trait_span, "incorrect number of arguments in `derive(Hash)`")
     };
     let call_hash = |span, thing_expr| {
index 3d0645fd6e3cffd64ba4737af5d48939ce0164d8..a972cfe135511d99f6961edc9bc6fc37ad5a4dd7 100644 (file)
@@ -71,8 +71,8 @@ pub fn expand_deriving_from_primitive(cx: &mut ExtCtxt,
 }
 
 fn cs_from(name: &str, cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> P<Expr> {
-    let n = match substr.nonself_args {
-        [ref n] => n,
+    let n = match (substr.nonself_args.len(), substr.nonself_args.get(0)) {
+        (1, Some(o_f)) => o_f,
         _ => cx.span_bug(trait_span, "incorrect number of arguments in `derive(FromPrimitive)`")
     };
 
index 0945f8dd02103ac026565878beb0df6f24995a08..d1db956adb3f5a13f28576ff6ac5ceab1802a800 100644 (file)
@@ -1962,8 +1962,8 @@ fn fmt_in_macro_used_inside_module_macro() {
                 "xx" == string
             }).collect();
         let cxbinds: &[&ast::Ident] = &cxbinds[..];
-        let cxbind = match cxbinds {
-            [b] => b,
+        let cxbind = match (cxbinds.len(), cxbinds.get(0)) {
+            (1, Some(b)) => *b,
             _ => panic!("expected just one binding for ext_cx")
         };
         let resolved_binding = mtwt::resolve(*cxbind);
index 3fcc6a8d69241b7cb2bfa80258589457f176dcf5..646e6fec405534de3f62a18ae55dc8f57b6ff83c 100644 (file)
@@ -28,12 +28,11 @@ pub fn expand_trace_macros(cx: &mut ExtCtxt,
         return base::DummyResult::any(sp);
     }
 
-
-    match tt {
-        [ast::TtToken(_, ref tok)] if tok.is_keyword(keywords::True) => {
+    match (tt.len(), tt.first()) {
+        (1, Some(&ast::TtToken(_, ref tok))) if tok.is_keyword(keywords::True) => {
             cx.set_trace_macros(true);
         }
-        [ast::TtToken(_, ref tok)] if tok.is_keyword(keywords::False) => {
+        (1, Some(&ast::TtToken(_, ref tok))) if tok.is_keyword(keywords::False) => {
             cx.set_trace_macros(false);
         }
         _ => cx.span_err(sp, "trace_macros! accepts only `true` or `false`"),
index 99fb2798e7a3a77757ff0a5ce287697bac004298..a70707b3ea146bc1dd08a1ee32185a455232d1e4 100644 (file)
@@ -35,7 +35,6 @@
 #![feature(path_ext)]
 #![feature(str_char)]
 #![feature(into_cow)]
-#![feature(slice_patterns)]
 
 extern crate arena;
 extern crate fmt_macros;
index c078787120f9e433b78cbccee3d97f222f8eaaba..51fb09a7526e6f9e3d9596b334cfda981e81814e 100644 (file)
@@ -834,28 +834,44 @@ fn sp(a: u32, b: u32) -> Span {
     fn string_to_tts_macro () {
         let tts = string_to_tts("macro_rules! zip (($a)=>($a))".to_string());
         let tts: &[ast::TokenTree] = &tts[..];
-        match tts {
-            [ast::TtToken(_, token::Ident(name_macro_rules, token::Plain)),
-             ast::TtToken(_, token::Not),
-             ast::TtToken(_, token::Ident(name_zip, token::Plain)),
-             ast::TtDelimited(_, ref macro_delimed)]
+
+        match (tts.len(), tts.get(0), tts.get(1), tts.get(2), tts.get(3)) {
+            (
+                4,
+                Some(&ast::TtToken(_, token::Ident(name_macro_rules, token::Plain))),
+                Some(&ast::TtToken(_, token::Not)),
+                Some(&ast::TtToken(_, token::Ident(name_zip, token::Plain))),
+                Some(&ast::TtDelimited(_, ref macro_delimed)),
+            )
             if name_macro_rules.as_str() == "macro_rules"
             && name_zip.as_str() == "zip" => {
-                match &macro_delimed.tts[..] {
-                    [ast::TtDelimited(_, ref first_delimed),
-                     ast::TtToken(_, token::FatArrow),
-                     ast::TtDelimited(_, ref second_delimed)]
+                let tts = &macro_delimed.tts[..];
+                match (tts.len(), tts.get(0), tts.get(1), tts.get(2)) {
+                    (
+                        3,
+                        Some(&ast::TtDelimited(_, ref first_delimed)),
+                        Some(&ast::TtToken(_, token::FatArrow)),
+                        Some(&ast::TtDelimited(_, ref second_delimed)),
+                    )
                     if macro_delimed.delim == token::Paren => {
-                        match &first_delimed.tts[..] {
-                            [ast::TtToken(_, token::Dollar),
-                             ast::TtToken(_, token::Ident(name, token::Plain))]
+                        let tts = &first_delimed.tts[..];
+                        match (tts.len(), tts.get(0), tts.get(1)) {
+                            (
+                                2,
+                                Some(&ast::TtToken(_, token::Dollar)),
+                                Some(&ast::TtToken(_, token::Ident(name, token::Plain))),
+                            )
                             if first_delimed.delim == token::Paren
                             && name.as_str() == "a" => {},
                             _ => panic!("value 3: {:?}", **first_delimed),
                         }
-                        match &second_delimed.tts[..] {
-                            [ast::TtToken(_, token::Dollar),
-                             ast::TtToken(_, token::Ident(name, token::Plain))]
+                        let tts = &second_delimed.tts[..];
+                        match (tts.len(), tts.get(0), tts.get(1)) {
+                            (
+                                2,
+                                Some(&ast::TtToken(_, token::Dollar)),
+                                Some(&ast::TtToken(_, token::Ident(name, token::Plain))),
+                            )
                             if second_delimed.delim == token::Paren
                             && name.as_str() == "a" => {},
                             _ => panic!("value 4: {:?}", **second_delimed),