Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 12 pull requests #126016

Merged
merged 41 commits into from
Jun 5, 2024
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
a5a60d7
Add `size_of`, `size_of_val`, `align_of`, and `align_of_val` to the p…
joshtriplett Mar 28, 2024
b4834a1
rewrite resolve-rename in rmake
Oneirical May 28, 2024
d553d5b
rewrite incr-prev-body-beyond-eof in rmake
Oneirical May 28, 2024
8530285
rustc_span: Inline some hot functions
petrochenkov Jun 2, 2024
07dc3eb
Allow static mut definitions with #[linkage]
bjorn3 Jun 3, 2024
8f08625
Remove a bunch of redundant args from report_method_error
compiler-errors Jun 3, 2024
e9957b9
Stop passing empty args to check_expr_path
compiler-errors Jun 3, 2024
8f677e8
bootstrap: implement new feature `bootstrap-self-test`
onur-ozkan May 19, 2024
2bad3d1
Make deleting on LinkedList aware of the allocator
xTachyon Jun 4, 2024
59e2074
rewrite suspicious-library in rmake
Oneirical May 28, 2024
5d26f58
Closures are recursively reachable
tmiasko Jun 4, 2024
ac96fa4
Use inline const instead of unsafe to construct arrays in `MaybeUnini…
kpreid May 13, 2024
ec8fa17
Use inline const instead of unsafe to implement `MaybeUninit::uninit_…
kpreid May 13, 2024
2a21937
Add a co-maintainer for the two ARMv4T targets
Lokathor Jun 4, 2024
e1ae0fa
`UNICODE_ARRAY` and `ASCII_ARRAY` fixes.
nnethercote May 29, 2024
d1215da
Don't use the word "parse" for lexing operations.
nnethercote May 30, 2024
f657624
Inline and remove `error_malformed_cfg_attr_missing`.
nnethercote May 31, 2024
769ca3f
Rename `maybe_file_to_stream` as `maybe_source_file_to_stream`.
nnethercote May 31, 2024
3c321b9
Remove `stream_to_parser`.
nnethercote May 31, 2024
af13b48
Improve `panictry_buffer!`.
nnethercote May 31, 2024
29e6e28
Remove low-value comments.
nnethercote May 31, 2024
191b76e
Rename `maybe_source_file_to_parser` as `maybe_new_parser_from_source…
nnethercote May 31, 2024
8964106
Use `source_str_to_stream` in a test file.
nnethercote May 31, 2024
25972ae
Inline and remove `parse_crate{,_attrs}_from_{file,source_str}`.
nnethercote May 31, 2024
ab192a0
Reorder `source_str_to_stream` arguments.
nnethercote May 31, 2024
264dbe4
Inline and remove `source_file_to_stream`.
nnethercote May 31, 2024
b903733
Make top-level `rustc_parse` functions fallible.
nnethercote May 31, 2024
2d4e7df
rustfmt: Remove an unnecessary `catch_unwind` use.
nnethercote Jun 3, 2024
dd6bca5
Add another test for hidden types capturing lifetimes that outlive bu…
compiler-errors Jun 5, 2024
9ccc7b7
Rollup merge of #123168 - joshtriplett:size-of-prelude, r=Amanieu
workingjubilee Jun 5, 2024
0f86182
Rollup merge of #125273 - onur-ozkan:bootstrap-self-test, r=albertlar…
workingjubilee Jun 5, 2024
0f2b34a
Rollup merge of #125683 - Oneirical:patience-testing-test, r=jieyouxu
workingjubilee Jun 5, 2024
05b4674
Rollup merge of #125815 - nnethercote:rustc_parse-top-level-cleanups,…
workingjubilee Jun 5, 2024
0096138
Rollup merge of #125903 - petrochenkov:upctxt3, r=nnethercote
workingjubilee Jun 5, 2024
78d9a7e
Rollup merge of #125906 - compiler-errors:simplify-method-error-args,…
workingjubilee Jun 5, 2024
2b89c1b
Rollup merge of #125920 - bjorn3:allow_static_mut_linkage_def, r=Urgau
workingjubilee Jun 5, 2024
448159c
Rollup merge of #125982 - xTachyon:fix-linked-list, r=jhpratt
workingjubilee Jun 5, 2024
6b6b698
Rollup merge of #125995 - kpreid:const-uninit-stable, r=Nilstrieb
workingjubilee Jun 5, 2024
eb2819e
Rollup merge of #125996 - tmiasko:closure-recursively-reachable, r=ol…
workingjubilee Jun 5, 2024
669935e
Rollup merge of #126003 - Lokathor:new-co-maintainer, r=compiler-errors
workingjubilee Jun 5, 2024
f12fe3a
Rollup merge of #126004 - compiler-errors:captures-soundness-test, r=…
workingjubilee Jun 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve panictry_buffer!.
- Convert it from a macro to a function, which is nicer.
- Rename it as `unwrap_or_emit_fatal`, which is clearer.
- Fix the comment. In particular, `panictry!` no longer exists.
- Remove the unnecessary `use` declaration.
  • Loading branch information
nnethercote committed Jun 5, 2024
commit af13b4892786a3f77d440016409414eeadd7d37e
27 changes: 12 additions & 15 deletions compiler/rustc_parse/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,17 @@ rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
// uses a HOF to parse anything, and <source> includes file and
// `source_str`.

/// A variant of 'panictry!' that works on a `Vec<Diag>` instead of a single `Diag`.
macro_rules! panictry_buffer {
($e:expr) => {{
use std::result::Result::{Err, Ok};
match $e {
Ok(e) => e,
Err(errs) => {
for e in errs {
e.emit();
}
FatalError.raise()
// Unwrap the result if `Ok`, otherwise emit the diagnostics and abort.
fn unwrap_or_emit_fatal<T>(expr: Result<T, Vec<Diag<'_>>>) -> T {
match expr {
Ok(expr) => expr,
Err(errs) => {
for err in errs {
err.emit();
}
FatalError.raise()
}
}};
}
}

pub fn parse_crate_from_file<'a>(input: &Path, psess: &'a ParseSess) -> PResult<'a, ast::Crate> {
Expand Down Expand Up @@ -86,7 +83,7 @@ pub fn parse_crate_attrs_from_source_str(

/// Creates a new parser from a source string.
pub fn new_parser_from_source_str(psess: &ParseSess, name: FileName, source: String) -> Parser<'_> {
panictry_buffer!(maybe_new_parser_from_source_str(psess, name, source))
unwrap_or_emit_fatal(maybe_new_parser_from_source_str(psess, name, source))
}

/// Creates a new parser from a source string. Returns any buffered errors from lexing the initial
Expand All @@ -112,7 +109,7 @@ pub fn new_parser_from_file<'a>(psess: &'a ParseSess, path: &Path, sp: Option<Sp
err.emit();
});

panictry_buffer!(maybe_source_file_to_parser(psess, source_file))
unwrap_or_emit_fatal(maybe_source_file_to_parser(psess, source_file))
}

/// Given a session and a `source_file`, return a parser. Returns any buffered errors from lexing
Expand Down Expand Up @@ -148,7 +145,7 @@ pub fn source_file_to_stream(
source_file: Lrc<SourceFile>,
override_span: Option<Span>,
) -> TokenStream {
panictry_buffer!(maybe_source_file_to_stream(psess, source_file, override_span))
unwrap_or_emit_fatal(maybe_source_file_to_stream(psess, source_file, override_span))
}

/// Given a source file, produces a sequence of token trees. Returns any buffered errors from
Expand Down