@@ -73,6 +73,10 @@ pub struct State<'a> {
7373}
7474
7575impl < ' a > State < ' a > {
76+ fn attrs ( & self , id : hir:: HirId ) -> & ' a [ ast:: Attribute ] {
77+ ( self . attrs ) ( id)
78+ }
79+
7680 fn print_node ( & mut self , node : Node < ' _ > ) {
7781 match node {
7882 Node :: Param ( a) => self . print_param ( a) ,
@@ -154,7 +158,12 @@ pub fn print_crate<'a>(
154158 attrs : & ' a dyn Fn ( hir:: HirId ) -> & ' a [ ast:: Attribute ] ,
155159 ann : & ' a dyn PpAnn ,
156160) -> String {
157- let mut s = State :: new_from_input ( sm, filename, input, attrs, ann) ;
161+ let mut s = State {
162+ s : pp:: Printer :: new ( ) ,
163+ comments : Some ( Comments :: new ( sm, filename, input) ) ,
164+ attrs,
165+ ann,
166+ } ;
158167
159168 // When printing the AST, we sometimes need to inject `#[no_std]` here.
160169 // Since you can't compile the HIR, it's not necessary.
@@ -164,27 +173,6 @@ pub fn print_crate<'a>(
164173 s. s . eof ( )
165174}
166175
167- impl < ' a > State < ' a > {
168- fn new_from_input (
169- sm : & ' a SourceMap ,
170- filename : FileName ,
171- input : String ,
172- attrs : & ' a dyn Fn ( hir:: HirId ) -> & ' a [ ast:: Attribute ] ,
173- ann : & ' a dyn PpAnn ,
174- ) -> State < ' a > {
175- State {
176- s : pp:: Printer :: new ( ) ,
177- comments : Some ( Comments :: new ( sm, filename, input) ) ,
178- attrs,
179- ann,
180- }
181- }
182-
183- fn attrs ( & self , id : hir:: HirId ) -> & ' a [ ast:: Attribute ] {
184- ( self . attrs ) ( id)
185- }
186- }
187-
188176fn to_string < F > ( ann : & dyn PpAnn , f : F ) -> String
189177where
190178 F : FnOnce ( & mut State < ' _ > ) ,
0 commit comments