@@ -36,7 +36,7 @@ impl<'a> Module<'a> {
36
36
mod_span : Span ,
37
37
ast_mod_kind : Option < Cow < ' a , ast:: ModKind > > ,
38
38
mod_items : Cow < ' a , ThinVec < rustc_ast:: ptr:: P < ast:: Item > > > ,
39
- mod_attrs : Cow < ' a , ast:: AttrVec > ,
39
+ mod_attrs : & [ ast:: Attribute ] ,
40
40
) -> Self {
41
41
let inner_attr = mod_attrs
42
42
. iter ( )
@@ -141,16 +141,16 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
141
141
mk_sp ( snippet_provider. start_pos ( ) , snippet_provider. end_pos ( ) ) ,
142
142
None ,
143
143
Cow :: Borrowed ( & krate. items ) ,
144
- Cow :: Borrowed ( & krate. attrs ) ,
144
+ & krate. attrs ,
145
145
) ,
146
146
) ;
147
147
Ok ( self . file_map )
148
148
}
149
149
150
150
/// Visit `cfg_if` macro and look for module declarations.
151
- fn visit_cfg_if ( & mut self , item : Cow < ' ast , ast :: Item > ) -> Result < ( ) , ModuleResolutionError > {
151
+ fn visit_cfg_if ( & mut self , item : & ast:: Item ) -> Result < ( ) , ModuleResolutionError > {
152
152
let mut visitor = visitor:: CfgIfVisitor :: new ( self . parse_sess ) ;
153
- visitor. visit_item ( & item) ;
153
+ visitor. visit_item ( item) ;
154
154
for module_item in visitor. mods ( ) {
155
155
if let ast:: ItemKind :: Mod ( _, ref sub_mod_kind) = module_item. item . kind {
156
156
self . visit_sub_mod (
@@ -159,7 +159,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
159
159
module_item. item . span ,
160
160
Some ( Cow :: Owned ( sub_mod_kind. clone ( ) ) ) ,
161
161
Cow :: Owned ( ThinVec :: new ( ) ) ,
162
- Cow :: Owned ( ast :: AttrVec :: new ( ) ) ,
162
+ & [ ] ,
163
163
) ,
164
164
) ?;
165
165
}
@@ -170,11 +170,11 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
170
170
/// Visit modules defined inside macro calls.
171
171
fn visit_mod_outside_ast (
172
172
& mut self ,
173
- items : ThinVec < rustc_ast:: ptr:: P < ast:: Item > > ,
173
+ items : & [ rustc_ast:: ptr:: P < ast:: Item > ] ,
174
174
) -> Result < ( ) , ModuleResolutionError > {
175
175
for item in items {
176
- if is_cfg_if ( & item) {
177
- self . visit_cfg_if ( Cow :: Owned ( item. into_inner ( ) ) ) ?;
176
+ if is_cfg_if ( item) {
177
+ self . visit_cfg_if ( item) ?;
178
178
continue ;
179
179
}
180
180
@@ -186,7 +186,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
186
186
span,
187
187
Some ( Cow :: Owned ( sub_mod_kind. clone ( ) ) ) ,
188
188
Cow :: Owned ( ThinVec :: new ( ) ) ,
189
- Cow :: Owned ( ast :: AttrVec :: new ( ) ) ,
189
+ & [ ] ,
190
190
) ,
191
191
) ?;
192
192
}
@@ -201,7 +201,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
201
201
) -> Result < ( ) , ModuleResolutionError > {
202
202
for item in items {
203
203
if is_cfg_if ( item) {
204
- self . visit_cfg_if ( Cow :: Borrowed ( item) ) ?;
204
+ self . visit_cfg_if ( item) ?;
205
205
}
206
206
207
207
if let ast:: ItemKind :: Mod ( _, ref sub_mod_kind) = item. kind {
@@ -212,7 +212,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
212
212
span,
213
213
Some ( Cow :: Borrowed ( sub_mod_kind) ) ,
214
214
Cow :: Owned ( ThinVec :: new ( ) ) ,
215
- Cow :: Owned ( ast :: AttrVec :: new ( ) ) ,
215
+ & [ ] ,
216
216
) ,
217
217
) ?;
218
218
}
@@ -320,7 +320,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
320
320
self . visit_mod_from_ast ( items)
321
321
}
322
322
( Some ( Cow :: Owned ( ast:: ModKind :: Loaded ( items, _, _) ) ) , _) | ( _, Cow :: Owned ( items) ) => {
323
- self . visit_mod_outside_ast ( items)
323
+ self . visit_mod_outside_ast ( & items)
324
324
}
325
325
( _, _) => Ok ( ( ) ) ,
326
326
}
@@ -350,7 +350,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
350
350
span,
351
351
Some ( Cow :: Owned ( ast:: ModKind :: Unloaded ) ) ,
352
352
Cow :: Owned ( items) ,
353
- Cow :: Owned ( attrs) ,
353
+ & attrs,
354
354
) ,
355
355
) ) ) ,
356
356
Err ( ParserError :: ParseError ) => Err ( ModuleResolutionError {
@@ -400,7 +400,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
400
400
span,
401
401
Some ( Cow :: Owned ( ast:: ModKind :: Unloaded ) ) ,
402
402
Cow :: Owned ( items) ,
403
- Cow :: Owned ( attrs) ,
403
+ & attrs,
404
404
) ,
405
405
) ) )
406
406
}
@@ -412,7 +412,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
412
412
span,
413
413
Some ( Cow :: Owned ( ast:: ModKind :: Unloaded ) ) ,
414
414
Cow :: Owned ( items) ,
415
- Cow :: Owned ( attrs) ,
415
+ & attrs,
416
416
) ,
417
417
) ) ;
418
418
if should_insert {
@@ -550,7 +550,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
550
550
span,
551
551
Some ( Cow :: Owned ( ast:: ModKind :: Unloaded ) ) ,
552
552
Cow :: Owned ( items) ,
553
- Cow :: Owned ( attrs) ,
553
+ & attrs,
554
554
) ,
555
555
) )
556
556
}
0 commit comments