@@ -342,32 +342,20 @@ fn parse_source(source: &str, crate_name: &Option<&str>) -> Result<ParseSourceIn
342342 // Recurse through functions body. It is necessary because the doctest source code is
343343 // wrapped in a function to limit the number of AST errors. If we don't recurse into
344344 // 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 {
351346 let mut is_extern_crate = false ;
352347 if !info. has_global_allocator
353348 && item. attrs . iter ( ) . any ( |attr| attr. name_or_empty ( ) == sym:: global_allocator)
354349 {
355350 info. has_global_allocator = true ;
356351 }
357352 match item. kind {
358- ast:: ItemKind :: Fn ( ref fn_item ) if !info. has_main_fn => {
353+ ast:: ItemKind :: Fn ( _ ) if !info. has_main_fn => {
359354 // We only push if it's the top item because otherwise, we would duplicate
360355 // 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 {
362357 info. has_main_fn = true ;
363358 }
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- }
371359 }
372360 ast:: ItemKind :: ExternCrate ( original) => {
373361 is_extern_crate = true ;
@@ -427,7 +415,7 @@ fn parse_source(source: &str, crate_name: &Option<&str>) -> Result<ParseSourceIn
427415 let mut is_extern_crate = false ;
428416 match stmt. kind {
429417 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) ;
431419 }
432420 StmtKind :: Expr ( ref expr) if matches ! ( expr. kind, ast:: ExprKind :: Err ( _) ) => {
433421 reset_error_count ( & psess) ;
0 commit comments