@@ -73,6 +73,10 @@ pub struct State<'a> {
73
73
}
74
74
75
75
impl < ' a > State < ' a > {
76
+ fn attrs ( & self , id : hir:: HirId ) -> & ' a [ ast:: Attribute ] {
77
+ ( self . attrs ) ( id)
78
+ }
79
+
76
80
fn print_node ( & mut self , node : Node < ' _ > ) {
77
81
match node {
78
82
Node :: Param ( a) => self . print_param ( a) ,
@@ -154,7 +158,12 @@ pub fn print_crate<'a>(
154
158
attrs : & ' a dyn Fn ( hir:: HirId ) -> & ' a [ ast:: Attribute ] ,
155
159
ann : & ' a dyn PpAnn ,
156
160
) -> 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
+ } ;
158
167
159
168
// When printing the AST, we sometimes need to inject `#[no_std]` here.
160
169
// Since you can't compile the HIR, it's not necessary.
@@ -164,27 +173,6 @@ pub fn print_crate<'a>(
164
173
s. s . eof ( )
165
174
}
166
175
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
-
188
176
fn to_string < F > ( ann : & dyn PpAnn , f : F ) -> String
189
177
where
190
178
F : FnOnce ( & mut State < ' _ > ) ,
0 commit comments