]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_builtin_macros/src/cfg_eval.rs
Remove `crate` visibility usage in compiler
[rust.git] / compiler / rustc_builtin_macros / src / cfg_eval.rs
index 7637bf7edc825cbd571d29d5b2056155eef2a6cc..6485c82a119e2c00d0ce8e25abd5fcb38d1ea42a 100644 (file)
@@ -7,7 +7,7 @@
 use rustc_ast::visit::Visitor;
 use rustc_ast::NodeId;
 use rustc_ast::{mut_visit, visit};
-use rustc_ast::{AstLike, Attribute};
+use rustc_ast::{Attribute, HasAttrs, HasTokens};
 use rustc_expand::base::{Annotatable, ExtCtxt};
 use rustc_expand::config::StripUnconfigured;
 use rustc_expand::configure;
@@ -19,7 +19,7 @@
 use rustc_span::Span;
 use smallvec::SmallVec;
 
-crate fn expand(
+pub(crate) fn expand(
     ecx: &mut ExtCtxt<'_>,
     _span: Span,
     meta_item: &ast::MetaItem,
@@ -30,7 +30,7 @@
     vec![cfg_eval(ecx.sess, ecx.ecfg.features, annotatable, ecx.current_expansion.lint_node_id)]
 }
 
-crate fn cfg_eval(
+pub(crate) fn cfg_eval(
     sess: &Session,
     features: Option<&Features>,
     annotatable: Annotatable,
@@ -125,7 +125,7 @@ fn visit_attribute(&mut self, attr: &'ast Attribute) {
 }
 
 impl CfgEval<'_, '_> {
-    fn configure<T: AstLike>(&mut self, node: T) -> Option<T> {
+    fn configure<T: HasAttrs + HasTokens>(&mut self, node: T) -> Option<T> {
         self.cfg.configure(node)
     }
 
@@ -173,13 +173,8 @@ fn configure_annotatable(&mut self, mut annotatable: Annotatable) -> Option<Anno
             }
             _ => unreachable!(),
         };
-        let nt = annotatable.into_nonterminal();
 
-        let mut orig_tokens = rustc_parse::nt_to_tokenstream(
-            &nt,
-            &self.cfg.sess.parse_sess,
-            CanSynthesizeMissingTokens::No,
-        );
+        let mut orig_tokens = annotatable.to_tokens(&self.cfg.sess.parse_sess);
 
         // 'Flatten' all nonterminals (i.e. `TokenKind::Interpolated`)
         // to `None`-delimited groups containing the corresponding tokens. This