1
Fork 0

syntax: Remove uses of #[feature(slice_patterns)]

This commit is contained in:
Erick Tryzelaar 2015-04-15 22:12:12 -07:00
parent a4541b02a3
commit ca0ee4c645
11 changed files with 73 additions and 47 deletions

View 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!()
};