@@ -342,32 +342,20 @@ fn parse_source(source: &str, crate_name: &Option<&str>) -> Result<ParseSourceIn
342
342
// Recurse through functions body. It is necessary because the doctest source code is
343
343
// wrapped in a function to limit the number of AST errors. If we don't recurse into
344
344
// functions, we would thing all top-level items (so basically nothing).
345
- fn check_item (
346
- item : & ast:: Item ,
347
- info : & mut ParseSourceInfo ,
348
- crate_name : & Option < & str > ,
349
- is_top_level : bool ,
350
- ) -> bool {
345
+ fn check_item ( item : & ast:: Item , info : & mut ParseSourceInfo , crate_name : & Option < & str > ) -> bool {
351
346
let mut is_extern_crate = false ;
352
347
if !info. has_global_allocator
353
348
&& item. attrs . iter ( ) . any ( |attr| attr. name_or_empty ( ) == sym:: global_allocator)
354
349
{
355
350
info. has_global_allocator = true ;
356
351
}
357
352
match item. kind {
358
- ast:: ItemKind :: Fn ( ref fn_item ) if !info. has_main_fn => {
353
+ ast:: ItemKind :: Fn ( _ ) if !info. has_main_fn => {
359
354
// We only push if it's the top item because otherwise, we would duplicate
360
355
// its content since the top-level item was already added.
361
- if item. ident . name == sym:: main && is_top_level {
356
+ if item. ident . name == sym:: main {
362
357
info. has_main_fn = true ;
363
358
}
364
- if let Some ( ref body) = fn_item. body {
365
- for stmt in & body. stmts {
366
- if let StmtKind :: Item ( ref item) = stmt. kind {
367
- is_extern_crate |= check_item ( item, info, crate_name, false ) ;
368
- }
369
- }
370
- }
371
359
}
372
360
ast:: ItemKind :: ExternCrate ( original) => {
373
361
is_extern_crate = true ;
@@ -427,7 +415,7 @@ fn parse_source(source: &str, crate_name: &Option<&str>) -> Result<ParseSourceIn
427
415
let mut is_extern_crate = false ;
428
416
match stmt. kind {
429
417
StmtKind :: Item ( ref item) => {
430
- is_extern_crate = check_item ( & item, & mut info, crate_name, true ) ;
418
+ is_extern_crate = check_item ( & item, & mut info, crate_name) ;
431
419
}
432
420
StmtKind :: Expr ( ref expr) if matches ! ( expr. kind, ast:: ExprKind :: Err ( _) ) => {
433
421
reset_error_count ( & psess) ;
0 commit comments