|
3 | 3 |
|
4 | 4 | use crate::config::CheckCfg;
|
5 | 5 | use crate::lint::{BufferedEarlyLint, BuiltinLintDiagnostics, Lint, LintId};
|
| 6 | +use crate::SessionDiagnostic; |
6 | 7 | use rustc_ast::node_id::NodeId;
|
7 | 8 | use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
8 | 9 | use rustc_data_structures::sync::{Lock, Lrc};
|
9 | 10 | use rustc_errors::{emitter::SilentEmitter, ColorConfig, Handler};
|
10 | 11 | use rustc_errors::{
|
11 | 12 | error_code, fallback_fluent_bundle, Applicability, Diagnostic, DiagnosticBuilder,
|
12 |
| - ErrorGuaranteed, MultiSpan, |
| 13 | + DiagnosticMessage, ErrorGuaranteed, MultiSpan, |
13 | 14 | };
|
14 | 15 | use rustc_feature::{find_feature_issue, GateIssue, UnstableFeatures};
|
15 | 16 | use rustc_span::edition::Edition;
|
@@ -287,4 +288,23 @@ impl ParseSess {
|
287 | 288 | pub fn proc_macro_quoted_spans(&self) -> Vec<Span> {
|
288 | 289 | self.proc_macro_quoted_spans.lock().clone()
|
289 | 290 | }
|
| 291 | + |
| 292 | + pub fn emit_err<'a>(&'a self, err: impl SessionDiagnostic<'a>) -> ErrorGuaranteed { |
| 293 | + err.into_diagnostic(self).emit() |
| 294 | + } |
| 295 | + |
| 296 | + pub fn emit_warning<'a>(&'a self, warning: impl SessionDiagnostic<'a, ()>) { |
| 297 | + warning.into_diagnostic(self).emit() |
| 298 | + } |
| 299 | + |
| 300 | + pub fn struct_err( |
| 301 | + &self, |
| 302 | + msg: impl Into<DiagnosticMessage>, |
| 303 | + ) -> DiagnosticBuilder<'_, ErrorGuaranteed> { |
| 304 | + self.span_diagnostic.struct_err(msg) |
| 305 | + } |
| 306 | + |
| 307 | + pub fn struct_warn(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> { |
| 308 | + self.span_diagnostic.struct_warn(msg) |
| 309 | + } |
290 | 310 | }
|
0 commit comments