@@ -4,14 +4,14 @@ use crate::module::DirectoryOwnership;
44use rustc_ast:: ast:: { self , Attribute , NodeId , PatKind } ;
55use rustc_ast:: mut_visit:: { self , MutVisitor } ;
66use rustc_ast:: ptr:: P ;
7- use rustc_ast:: token:: { self , FlattenGroup } ;
8- use rustc_ast:: tokenstream:: { self , TokenStream , TokenTree } ;
7+ use rustc_ast:: token;
8+ use rustc_ast:: tokenstream:: { self , TokenStream } ;
99use rustc_ast:: visit:: { AssocCtxt , Visitor } ;
1010use rustc_attr:: { self as attr, Deprecation , HasAttrs , Stability } ;
1111use rustc_data_structures:: fx:: FxHashMap ;
1212use rustc_data_structures:: sync:: { self , Lrc } ;
1313use rustc_errors:: { DiagnosticBuilder , ErrorReported } ;
14- use rustc_parse:: { self , parser, MACRO_ARGUMENTS } ;
14+ use rustc_parse:: { self , nt_to_tokenstream , parser, MACRO_ARGUMENTS } ;
1515use rustc_session:: { parse:: ParseSess , Limit } ;
1616use rustc_span:: def_id:: DefId ;
1717use rustc_span:: edition:: Edition ;
@@ -120,10 +120,7 @@ impl Annotatable {
120120 }
121121 }
122122
123- crate fn into_tokens ( self ) -> TokenStream {
124- // `Annotatable` can be converted into tokens directly, but we
125- // are packing it into a nonterminal as a piece of AST to make
126- // the produced token stream look nicer in pretty-printed form.
123+ crate fn into_tokens ( self , sess : & ParseSess ) -> TokenStream {
127124 let nt = match self {
128125 Annotatable :: Item ( item) => token:: NtItem ( item) ,
129126 Annotatable :: TraitItem ( item) | Annotatable :: ImplItem ( item) => {
@@ -142,7 +139,7 @@ impl Annotatable {
142139 | Annotatable :: StructField ( ..)
143140 | Annotatable :: Variant ( ..) => panic ! ( "unexpected annotatable" ) ,
144141 } ;
145- TokenTree :: token ( token :: Interpolated ( Lrc :: new ( nt ) , FlattenGroup :: Yes ) , DUMMY_SP ) . into ( )
142+ nt_to_tokenstream ( & nt , sess , DUMMY_SP )
146143 }
147144
148145 pub fn expect_item ( self ) -> P < ast:: Item > {
0 commit comments