Skip to content

Commit 7c2a26a

Browse files
committed
syntax: Remove uses of #[feature(slice_patterns)]
1 parent 1114bc4 commit 7c2a26a

File tree

9 files changed

+35
-30
lines changed

9 files changed

+35
-30
lines changed

src/libsyntax/config.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,15 @@ impl<'a> fold::Folder for CfgAttrFolder<'a> {
284284
return fold::noop_fold_attribute(attr, self);
285285
}
286286

287-
let (cfg, mi) = match attr.meta_item_list() {
288-
Some([ref cfg, ref mi]) => (cfg, mi),
287+
let attr_list = match attr.meta_item_list() {
288+
Some(attr_list) => attr_list,
289+
None => {
290+
self.diag.span_err(attr.span, "expected `#[cfg_attr(<cfg pattern>, <attr>)]`");
291+
return None;
292+
}
293+
};
294+
let (cfg, mi) = match (attr_list.len(), attr_list.get(0), attr_list.get(1)) {
295+
(2, Some(cfg), Some(mi)) => (cfg, mi),
289296
_ => {
290297
self.diag.span_err(attr.span, "expected `#[cfg_attr(<cfg pattern>, <attr>)]`");
291298
return None;

src/libsyntax/diagnostics/plugin.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ pub fn expand_diagnostic_used<'cx>(ecx: &'cx mut ExtCtxt,
5151
span: Span,
5252
token_tree: &[TokenTree])
5353
-> Box<MacResult+'cx> {
54-
let code = match token_tree {
55-
[ast::TtToken(_, token::Ident(code, _))] => code,
54+
let code = match (token_tree.len(), token_tree.get(0)) {
55+
(1, Some(&ast::TtToken(_, token::Ident(code, _)))) => code,
5656
_ => unreachable!()
5757
};
5858
with_used_diagnostics(|diagnostics| {
@@ -81,13 +81,13 @@ pub fn expand_register_diagnostic<'cx>(ecx: &'cx mut ExtCtxt,
8181
span: Span,
8282
token_tree: &[TokenTree])
8383
-> Box<MacResult+'cx> {
84-
let (code, description) = match token_tree {
85-
[ast::TtToken(_, token::Ident(ref code, _))] => {
84+
let (code, description) = match (token_tree.len(), token_tree.get(0), token_tree.get(1), token_tree.get(2)) {
85+
(1, Some(&ast::TtToken(_, token::Ident(ref code, _))), None, None) => {
8686
(code, None)
8787
},
88-
[ast::TtToken(_, token::Ident(ref code, _)),
89-
ast::TtToken(_, token::Comma),
90-
ast::TtToken(_, token::Literal(token::StrRaw(description, _), None))] => {
88+
(3, Some(&ast::TtToken(_, token::Ident(ref code, _))),
89+
Some(&ast::TtToken(_, token::Comma)),
90+
Some(&ast::TtToken(_, token::Literal(token::StrRaw(description, _), None)))) => {
9191
(code, Some(description))
9292
}
9393
_ => unreachable!()
@@ -109,8 +109,8 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt,
109109
span: Span,
110110
token_tree: &[TokenTree])
111111
-> Box<MacResult+'cx> {
112-
let name = match token_tree {
113-
[ast::TtToken(_, token::Ident(ref name, _))] => name,
112+
let name = match (token_tree.len(), token_tree.get(0)) {
113+
(1, Some(&ast::TtToken(_, token::Ident(ref name, _)))) => name,
114114
_ => unreachable!()
115115
};
116116

src/libsyntax/ext/deriving/cmp/eq.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ pub fn expand_deriving_eq<F>(cx: &mut ExtCtxt,
3030
cs_fold(
3131
true, // use foldl
3232
|cx, span, subexpr, self_f, other_fs| {
33-
let other_f = match other_fs {
34-
[ref o_f] => o_f,
33+
let other_f = match (other_fs.len(), other_fs.get(0)) {
34+
(1, Some(o_f)) => o_f,
3535
_ => cx.span_bug(span, "not exactly 2 arguments in `derive(PartialEq)`")
3636
};
3737

@@ -47,8 +47,8 @@ pub fn expand_deriving_eq<F>(cx: &mut ExtCtxt,
4747
cs_fold(
4848
true, // use foldl
4949
|cx, span, subexpr, self_f, other_fs| {
50-
let other_f = match other_fs {
51-
[ref o_f] => o_f,
50+
let other_f = match (other_fs.len(), other_fs.get(0)) {
51+
(1, Some(o_f)) => o_f,
5252
_ => cx.span_bug(span, "not exactly 2 arguments in `derive(PartialEq)`")
5353
};
5454

src/libsyntax/ext/deriving/cmp/ord.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt, span: Span,
151151
// }
152152

153153
let new = {
154-
let other_f = match other_fs {
155-
[ref o_f] => o_f,
154+
let other_f = match (other_fs.len(), other_fs.get(0)) {
155+
(1, Some(o_f)) => o_f,
156156
_ => cx.span_bug(span, "not exactly 2 arguments in `derive(PartialOrd)`"),
157157
};
158158

@@ -209,8 +209,8 @@ fn cs_op(less: bool, equal: bool, cx: &mut ExtCtxt,
209209
get use the binops to avoid auto-deref dereferencing too many
210210
layers of pointers, if the type includes pointers.
211211
*/
212-
let other_f = match other_fs {
213-
[ref o_f] => o_f,
212+
let other_f = match (other_fs.len(), other_fs.get(0)) {
213+
(1, Some(o_f)) => o_f,
214214
_ => cx.span_bug(span, "not exactly 2 arguments in `derive(PartialOrd)`")
215215
};
216216

src/libsyntax/ext/deriving/cmp/totalord.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ pub fn cs_cmp(cx: &mut ExtCtxt, span: Span,
107107
// }
108108

109109
let new = {
110-
let other_f = match other_fs {
111-
[ref o_f] => o_f,
110+
let other_f = match (other_fs.len(), other_fs.get(0)) {
111+
(1, Some(o_f)) => o_f,
112112
_ => cx.span_bug(span, "not exactly 2 arguments in `derive(PartialOrd)`"),
113113
};
114114

src/libsyntax/ext/deriving/hash.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ pub fn expand_deriving_hash<F>(cx: &mut ExtCtxt,
5757
}
5858

5959
fn hash_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> P<Expr> {
60-
let state_expr = match substr.nonself_args {
61-
[ref state_expr] => state_expr,
60+
let state_expr = match (substr.nonself_args.len(), substr.nonself_args.get(0)) {
61+
(1, Some(o_f)) => o_f,
6262
_ => cx.span_bug(trait_span, "incorrect number of arguments in `derive(Hash)`")
6363
};
6464
let call_hash = |span, thing_expr| {

src/libsyntax/ext/deriving/primitive.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ pub fn expand_deriving_from_primitive<F>(cx: &mut ExtCtxt,
7272
}
7373

7474
fn cs_from(name: &str, cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> P<Expr> {
75-
let n = match substr.nonself_args {
76-
[ref n] => n,
75+
let n = match (substr.nonself_args.len(), substr.nonself_args.get(0)) {
76+
(1, Some(o_f)) => o_f,
7777
_ => cx.span_bug(trait_span, "incorrect number of arguments in `derive(FromPrimitive)`")
7878
};
7979

src/libsyntax/ext/trace_macros.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@ pub fn expand_trace_macros(cx: &mut ExtCtxt,
2828
return base::DummyResult::any(sp);
2929
}
3030

31-
32-
match tt {
33-
[ast::TtToken(_, ref tok)] if tok.is_keyword(keywords::True) => {
31+
match (tt.len(), tt.first()) {
32+
(1, Some(&ast::TtToken(_, ref tok))) if tok.is_keyword(keywords::True) => {
3433
cx.set_trace_macros(true);
3534
}
36-
[ast::TtToken(_, ref tok)] if tok.is_keyword(keywords::False) => {
35+
(1, Some(&ast::TtToken(_, ref tok))) if tok.is_keyword(keywords::False) => {
3736
cx.set_trace_macros(false);
3837
}
3938
_ => cx.span_err(sp, "trace_macros! accepts only `true` or `false`"),

src/libsyntax/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#![feature(path_ext)]
3636
#![feature(str_char)]
3737
#![feature(into_cow)]
38-
#![feature(slice_patterns)]
3938

4039
extern crate arena;
4140
extern crate fmt_macros;

0 commit comments

Comments
 (0)