use pattern matching for slices destructuring

This commit is contained in:
Cedric
2019-06-08 10:49:46 +02:00
parent c1c60d292e
commit 5fb099dc78
7 changed files with 45 additions and 59 deletions

View File

@@ -16,11 +16,11 @@ pub fn expand_trace_macros(cx: &mut ExtCtxt<'_>,
feature_gate::EXPLAIN_TRACE_MACROS);
}
match (tt.len(), tt.first()) {
(1, Some(TokenTree::Token(token))) if token.is_keyword(kw::True) => {
match tt {
[TokenTree::Token(token)] if token.is_keyword(kw::True) => {
cx.set_trace_macros(true);
}
(1, Some(TokenTree::Token(token))) if token.is_keyword(kw::False) => {
[TokenTree::Token(token)] if token.is_keyword(kw::False) => {
cx.set_trace_macros(false);
}
_ => cx.span_err(sp, "trace_macros! accepts only `true` or `false`"),