]> git.lizzy.rs Git - rust.git/blobdiff - src/librustdoc/doctest.rs
Auto merge of #91159 - matthiaskrgr:rollup-91mgg5v, r=matthiaskrgr
[rust.git] / src / librustdoc / doctest.rs
index c10eebf49fc8d657af5b333fcccf83af486d678d..37db20aaefa8d327311e91bf9f6e7234af0f5f8f 100644 (file)
@@ -1,4 +1,4 @@
-use rustc_ast as ast;
+use rustc_ast::{self as ast, token};
 use rustc_data_structures::fx::{FxHashMap, FxHashSet};
 use rustc_data_structures::sync::Lrc;
 use rustc_errors::{ColorConfig, ErrorReported, FatalError};
@@ -537,7 +537,6 @@ fn drop(&mut self) {
             use rustc_errors::emitter::{Emitter, EmitterWriter};
             use rustc_errors::Handler;
             use rustc_parse::maybe_new_parser_from_source_str;
-            use rustc_parse::parser::ForceCollect;
             use rustc_session::parse::ParseSess;
             use rustc_span::source_map::FilePathMapping;
 
@@ -573,9 +572,9 @@ fn drop(&mut self) {
                 }
             };
 
-            loop {
-                match parser.parse_item(ForceCollect::No) {
-                    Ok(Some(item)) => {
+            match parser.parse_mod(&token::Eof) {
+                Ok((_attrs, items, _span)) => {
+                    for item in items {
                         if !found_main {
                             if let ast::ItemKind::Fn(..) = item.kind {
                                 if item.ident.name == sym::main {
@@ -607,11 +606,9 @@ fn drop(&mut self) {
                             break;
                         }
                     }
-                    Ok(None) => break,
-                    Err(mut e) => {
-                        e.cancel();
-                        break;
-                    }
+                }
+                Err(mut e) => {
+                    e.cancel();
                 }
             }