about summary refs log tree commit diff
path: root/compiler/rustc_builtin_macros/src/derive.rs
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2021-03-06 21:06:01 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2021-03-06 21:19:31 +0300
commit069e612e73f3fabb1184d9df009ea064118fffd8 (patch)
treeac21d786ac7200ce5e26de78a10cc595b211aa68 /compiler/rustc_builtin_macros/src/derive.rs
parent51748a8fc77283914d4135f31b5966a407208187 (diff)
downloadrust-069e612e73f3fabb1184d9df009ea064118fffd8.tar.gz
rust-069e612e73f3fabb1184d9df009ea064118fffd8.zip
rustc_ast: Replace `AstLike::finalize_tokens` with a getter `tokens_mut`
Diffstat (limited to 'compiler/rustc_builtin_macros/src/derive.rs')
-rw-r--r--compiler/rustc_builtin_macros/src/derive.rs12
1 files changed, 3 insertions, 9 deletions
diff --git a/compiler/rustc_builtin_macros/src/derive.rs b/compiler/rustc_builtin_macros/src/derive.rs
index fad64858ce3..c307d8b2f53 100644
--- a/compiler/rustc_builtin_macros/src/derive.rs
+++ b/compiler/rustc_builtin_macros/src/derive.rs
@@ -1,4 +1,4 @@
-use rustc_ast::{self as ast, token, ItemKind, MetaItemKind, NestedMetaItem, StmtKind};
+use rustc_ast::{self as ast, token, AstLike, ItemKind, MetaItemKind, NestedMetaItem, StmtKind};
 use rustc_errors::{struct_span_err, Applicability};
 use rustc_expand::base::{Annotatable, ExpandResult, ExtCtxt, Indeterminate, MultiItemModifier};
 use rustc_expand::config::StripUnconfigured;
@@ -59,15 +59,9 @@ impl MultiItemModifier for Expander {
                     // Erase the tokens if cfg-stripping modified the item
                     // This will cause us to synthesize fake tokens
                     // when `nt_to_tokenstream` is called on this item.
-                    match &mut item {
-                        Annotatable::Item(item) => item,
-                        Annotatable::Stmt(stmt) => match &mut stmt.kind {
-                            StmtKind::Item(item) => item,
-                            _ => unreachable!(),
-                        },
-                        _ => unreachable!(),
+                    if let Some(tokens) = item.tokens_mut() {
+                        *tokens = None;
                     }
-                    .tokens = None;
                 }
                 ExpandResult::Ready(vec![item])
             }