diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-01-11 14:22:44 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2024-01-11 18:37:56 +1100 |
| commit | 381ef817b72ce951fb4e28f26a94c1fd7e5c9635 (patch) | |
| tree | 7d5e9dae1363a7ad851b3f98a61843eaa8233d04 /src | |
| parent | 192c4a0cf40adc752daa4fa37ca85300fbe70ab4 (diff) | |
| download | rust-381ef817b72ce951fb4e28f26a94c1fd7e5c9635.tar.gz rust-381ef817b72ce951fb4e28f26a94c1fd7e5c9635.zip | |
Stop using `DiagnosticBuilder::buffer` in the parser.
One consequence is that errors returned by `maybe_new_parser_from_source_str` now must be consumed, so a bunch of places that previously ignored those errors now cancel them. (Most of them explicitly dropped the errors before. I guess that was to indicate "we are explicitly ignoring these", though I'm not 100% sure.)
Diffstat (limited to 'src')
| -rw-r--r-- | src/parse/parser.rs | 4 | ||||
| -rw-r--r-- | src/parse/session.rs | 8 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/parse/parser.rs b/src/parse/parser.rs index 7045a7dd9ce..31226cf8c30 100644 --- a/src/parse/parser.rs +++ b/src/parse/parser.rs @@ -3,7 +3,7 @@ use std::path::{Path, PathBuf}; use rustc_ast::token::TokenKind; use rustc_ast::{ast, attr, ptr}; -use rustc_errors::Diagnostic; +use rustc_errors::DiagnosticBuilder; use rustc_parse::{new_parser_from_file, parser::Parser as RawParser}; use rustc_span::{sym, Span}; use thin_vec::ThinVec; @@ -65,7 +65,7 @@ impl<'a> ParserBuilder<'a> { fn parser( sess: &'a rustc_session::parse::ParseSess, input: Input, - ) -> Result<rustc_parse::parser::Parser<'a>, Option<Vec<Diagnostic>>> { + ) -> Result<rustc_parse::parser::Parser<'a>, Option<Vec<DiagnosticBuilder<'a>>>> { match input { Input::File(ref file) => catch_unwind(AssertUnwindSafe(move || { new_parser_from_file(sess, file, None) diff --git a/src/parse/session.rs b/src/parse/session.rs index f4fb5073dfd..6dc3eac44d4 100644 --- a/src/parse/session.rs +++ b/src/parse/session.rs @@ -4,7 +4,9 @@ use std::sync::atomic::{AtomicBool, Ordering}; use rustc_data_structures::sync::{IntoDynSyncSend, Lrc}; use rustc_errors::emitter::{DynEmitter, Emitter, HumanEmitter}; use rustc_errors::translation::Translate; -use rustc_errors::{ColorConfig, DiagCtxt, Diagnostic, Level as DiagnosticLevel}; +use rustc_errors::{ + ColorConfig, DiagCtxt, Diagnostic, DiagnosticBuilder, Level as DiagnosticLevel, +}; use rustc_session::parse::ParseSess as RawParseSess; use rustc_span::{ source_map::{FilePathMapping, SourceMap}, @@ -283,9 +285,9 @@ impl ParseSess { // Methods that should be restricted within the parse module. impl ParseSess { - pub(super) fn emit_diagnostics(&self, diagnostics: Vec<Diagnostic>) { + pub(super) fn emit_diagnostics(&self, diagnostics: Vec<DiagnosticBuilder<'_>>) { for diagnostic in diagnostics { - self.parse_sess.dcx.emit_diagnostic(diagnostic); + diagnostic.emit(); } } |
