|
1 |
| -use rustc_ast::{self as ast, token}; |
| 1 | +use rustc_ast as ast; |
2 | 2 | use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
3 | 3 | use rustc_data_structures::sync::Lrc;
|
4 | 4 | use rustc_errors::{ColorConfig, ErrorReported, FatalError};
|
@@ -537,6 +537,7 @@ crate fn make_test(
|
537 | 537 | use rustc_errors::emitter::{Emitter, EmitterWriter};
|
538 | 538 | use rustc_errors::Handler;
|
539 | 539 | use rustc_parse::maybe_new_parser_from_source_str;
|
| 540 | + use rustc_parse::parser::ForceCollect; |
540 | 541 | use rustc_session::parse::ParseSess;
|
541 | 542 | use rustc_span::source_map::FilePathMapping;
|
542 | 543 |
|
@@ -572,9 +573,9 @@ crate fn make_test(
|
572 | 573 | }
|
573 | 574 | };
|
574 | 575 |
|
575 |
| - match parser.parse_mod(&token::Eof) { |
576 |
| - Ok((_attrs, items, _span)) => { |
577 |
| - for item in items { |
| 576 | + loop { |
| 577 | + match parser.parse_item(ForceCollect::No) { |
| 578 | + Ok(Some(item)) => { |
578 | 579 | if !found_main {
|
579 | 580 | if let ast::ItemKind::Fn(..) = item.kind {
|
580 | 581 | if item.ident.name == sym::main {
|
@@ -606,10 +607,16 @@ crate fn make_test(
|
606 | 607 | break;
|
607 | 608 | }
|
608 | 609 | }
|
| 610 | + Ok(None) => break, |
| 611 | + Err(mut e) => { |
| 612 | + e.cancel(); |
| 613 | + break; |
| 614 | + } |
609 | 615 | }
|
610 |
| - Err(mut e) => { |
611 |
| - e.cancel(); |
612 |
| - } |
| 616 | + |
| 617 | + // The supplied slice is only used for diagnostics, |
| 618 | + // which are swallowed here anyway. |
| 619 | + parser.maybe_consume_incorrect_semicolon(&[]); |
613 | 620 | }
|
614 | 621 |
|
615 | 622 | // Reset errors so that they won't be reported as compiler bugs when dropping the
|
|
0 commit comments