diff options
| author | bors <bors@rust-lang.org> | 2024-06-05 11:32:18 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-06-05 11:32:18 +0000 |
| commit | db8aca48129d86b2623e3ac8cbcf2902d4d313ad (patch) | |
| tree | 637294c8b1a43817f408a70a5da24d9b64d672a4 /compiler/rustc_parse/src/parser | |
| parent | 5ee2dfd2bcbb66a69a46aaa342204e0dfdb70516 (diff) | |
| parent | f12fe3a33e5e94f1f49cd6d4a785d1cf7a0a02b9 (diff) | |
Auto merge of #126016 - workingjubilee:rollup-nh6ehbz, r=workingjubilee
Rollup of 12 pull requests Successful merges: - #123168 (Add `size_of` and `size_of_val` and `align_of` and `align_of_val` to the prelude) - #125273 (bootstrap: implement new feature `bootstrap-self-test`) - #125683 (Rewrite `suspicious-library`, `resolve-rename` and `incr-prev-body-beyond-eof` `run-make` tests in `rmake.rs` format) - #125815 (`rustc_parse` top-level cleanups) - #125903 (rustc_span: Inline some hot functions) - #125906 (Remove a bunch of redundant args from `report_method_error`) - #125920 (Allow static mut definitions with #[linkage]) - #125982 (Make deleting on LinkedList aware of the allocator) - #125995 (Use inline const blocks to create arrays of `MaybeUninit`.) - #125996 (Closures are recursively reachable) - #126003 (Add a co-maintainer for the two ARMv4T targets) - #126004 (Add another test for hidden types capturing lifetimes that outlive but arent mentioned in substs) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/attr.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_parse/src/parser/tests.rs | 22 |
2 files changed, 16 insertions, 8 deletions
diff --git a/compiler/rustc_parse/src/parser/attr.rs b/compiler/rustc_parse/src/parser/attr.rs index a57eb70c705..4acc610d8c4 100644 --- a/compiler/rustc_parse/src/parser/attr.rs +++ b/compiler/rustc_parse/src/parser/attr.rs @@ -265,7 +265,7 @@ impl<'a> Parser<'a> { /// terminated by a semicolon. /// /// Matches `inner_attrs*`. - pub(crate) fn parse_inner_attributes(&mut self) -> PResult<'a, ast::AttrVec> { + pub fn parse_inner_attributes(&mut self) -> PResult<'a, ast::AttrVec> { let mut attrs = ast::AttrVec::new(); loop { let start_pos: u32 = self.num_bump_calls.try_into().unwrap(); diff --git a/compiler/rustc_parse/src/parser/tests.rs b/compiler/rustc_parse/src/parser/tests.rs index a31e350541a..79a6cf1b541 100644 --- a/compiler/rustc_parse/src/parser/tests.rs +++ b/compiler/rustc_parse/src/parser/tests.rs @@ -1,5 +1,7 @@ use crate::parser::ForceCollect; -use crate::{new_parser_from_source_str, parser::Parser, source_file_to_stream}; +use crate::{ + new_parser_from_source_str, parser::Parser, source_str_to_stream, unwrap_or_emit_fatal, +}; use ast::token::IdentIsRaw; use rustc_ast::ptr::P; use rustc_ast::token::{self, Delimiter, Token}; @@ -29,7 +31,11 @@ fn psess() -> ParseSess { /// Map string to parser (via tts). fn string_to_parser(psess: &ParseSess, source_str: String) -> Parser<'_> { - new_parser_from_source_str(psess, PathBuf::from("bogofile").into(), source_str) + unwrap_or_emit_fatal(new_parser_from_source_str( + psess, + PathBuf::from("bogofile").into(), + source_str, + )) } fn create_test_handler() -> (DiagCtxt, Lrc<SourceMap>, Arc<Mutex<Vec<u8>>>) { @@ -82,11 +88,12 @@ where /// Maps a string to tts, using a made-up filename. pub(crate) fn string_to_stream(source_str: String) -> TokenStream { let psess = psess(); - source_file_to_stream( + unwrap_or_emit_fatal(source_str_to_stream( &psess, - psess.source_map().new_source_file(PathBuf::from("bogofile").into(), source_str), + PathBuf::from("bogofile").into(), + source_str, None, - ) + )) } /// Parses a string, returns a crate. @@ -1068,7 +1075,8 @@ fn parse_item_from_source_str( source: String, psess: &ParseSess, ) -> PResult<'_, Option<P<ast::Item>>> { - new_parser_from_source_str(psess, name, source).parse_item(ForceCollect::No) + unwrap_or_emit_fatal(new_parser_from_source_str(psess, name, source)) + .parse_item(ForceCollect::No) } // Produces a `rustc_span::span`. @@ -1349,7 +1357,7 @@ fn ttdelim_span() { source: String, psess: &ParseSess, ) -> PResult<'_, P<ast::Expr>> { - new_parser_from_source_str(psess, name, source).parse_expr() + unwrap_or_emit_fatal(new_parser_from_source_str(psess, name, source)).parse_expr() } create_default_session_globals_then(|| { |
