@@ -37,9 +37,7 @@ pub trait MutVisitor: Sized {
3737 /// Mutable token visiting only exists for the `macro_rules` token marker and should not be
3838 /// used otherwise. Token visitor would be entirely separate from the regular visitor if
3939 /// the marker didn't have to visit AST fragments in nonterminal tokens.
40- fn token_visiting_enabled ( & self ) -> bool {
41- false
42- }
40+ const VISIT_TOKENS : bool = false ;
4341
4442 // Methods in this trait have one of three forms:
4543 //
@@ -363,7 +361,7 @@ pub fn visit_mac_args<T: MutVisitor>(args: &mut MacArgs, vis: &mut T) {
363361 }
364362 MacArgs :: Eq ( eq_span, token) => {
365363 vis. visit_span ( eq_span) ;
366- if vis . token_visiting_enabled ( ) {
364+ if T :: VISIT_TOKENS {
367365 visit_token ( token, vis) ;
368366 } else {
369367 // The value in `#[key = VALUE]` must be visited as an expression for backward
@@ -682,7 +680,7 @@ pub fn visit_tt<T: MutVisitor>(tt: &mut TokenTree, vis: &mut T) {
682680
683681// No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
684682pub fn visit_tts < T : MutVisitor > ( TokenStream ( tts) : & mut TokenStream , vis : & mut T ) {
685- if vis . token_visiting_enabled ( ) && !tts. is_empty ( ) {
683+ if T :: VISIT_TOKENS && !tts. is_empty ( ) {
686684 let tts = Lrc :: make_mut ( tts) ;
687685 visit_vec ( tts, |( tree, _is_joint) | visit_tt ( tree, vis) ) ;
688686 }
@@ -692,14 +690,14 @@ pub fn visit_attr_annotated_tts<T: MutVisitor>(
692690 AttrAnnotatedTokenStream ( tts) : & mut AttrAnnotatedTokenStream ,
693691 vis : & mut T ,
694692) {
695- if vis . token_visiting_enabled ( ) && !tts. is_empty ( ) {
693+ if T :: VISIT_TOKENS && !tts. is_empty ( ) {
696694 let tts = Lrc :: make_mut ( tts) ;
697695 visit_vec ( tts, |( tree, _is_joint) | visit_attr_annotated_tt ( tree, vis) ) ;
698696 }
699697}
700698
701699pub fn visit_lazy_tts_opt_mut < T : MutVisitor > ( lazy_tts : Option < & mut LazyTokenStream > , vis : & mut T ) {
702- if vis . token_visiting_enabled ( ) {
700+ if T :: VISIT_TOKENS {
703701 if let Some ( lazy_tts) = lazy_tts {
704702 let mut tts = lazy_tts. create_token_stream ( ) ;
705703 visit_attr_annotated_tts ( & mut tts, vis) ;
0 commit comments