diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-01-11 16:24:31 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-01-11 16:55:10 +1100 |
| commit | d5aafb846b7d77aee03511059ea21cb1041d62f9 (patch) | |
| tree | c92c9fa9b5c6e7158dd46f7576c4692d1e85d752 /compiler/rustc_parse/src | |
| parent | f5c0cd0bd1c564985788fb72d73ee3c8d8beb1d7 (diff) | |
| download | rust-d5aafb846b7d77aee03511059ea21cb1041d62f9.tar.gz rust-d5aafb846b7d77aee03511059ea21cb1041d62f9.zip | |
Use `struct_fatal` in `new_parser_from_file`.
It's a little more concise, and the standard way to do it.
Diffstat (limited to 'compiler/rustc_parse/src')
| -rw-r--r-- | compiler/rustc_parse/src/lib.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/compiler/rustc_parse/src/lib.rs b/compiler/rustc_parse/src/lib.rs index 106137299b4..55437de72b5 100644 --- a/compiler/rustc_parse/src/lib.rs +++ b/compiler/rustc_parse/src/lib.rs @@ -19,7 +19,7 @@ use rustc_ast::tokenstream::TokenStream; use rustc_ast::{AttrItem, Attribute, MetaItem}; use rustc_ast_pretty::pprust; use rustc_data_structures::sync::Lrc; -use rustc_errors::{Diagnostic, FatalError, Level, PResult}; +use rustc_errors::{Diagnostic, PResult}; use rustc_session::parse::ParseSess; use rustc_span::{FileName, SourceFile, Span}; @@ -118,12 +118,11 @@ pub fn maybe_new_parser_from_source_str( pub fn new_parser_from_file<'a>(sess: &'a ParseSess, path: &Path, sp: Option<Span>) -> Parser<'a> { let source_file = sess.source_map().load_file(path).unwrap_or_else(|e| { let msg = format!("couldn't read {}: {}", path.display(), e); - let mut diag = Diagnostic::new(Level::Fatal, msg); + let mut err = sess.dcx.struct_fatal(msg); if let Some(sp) = sp { - diag.span(sp); + err.span(sp); } - sess.dcx.emit_diagnostic(diag); - FatalError.raise(); + err.emit(); }); panictry_buffer!(&sess.dcx, maybe_source_file_to_parser(sess, source_file)) |
