1
Fork 0

Rollup merge of #96405 - pvdrz:ambiguous-plus-diagnostic, r=davidtwco

Migrate ambiguous plus diagnostic to the new derive macro

r? ````@davidtwco```` ````@jyn514````
This commit is contained in:
Dylan DPC 2022-04-28 20:12:59 +02:00 committed by GitHub
commit b3329f84f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 44 additions and 15 deletions

View file

@ -3,13 +3,14 @@
use crate::config::CheckCfg;
use crate::lint::{BufferedEarlyLint, BuiltinLintDiagnostics, Lint, LintId};
use crate::SessionDiagnostic;
use rustc_ast::node_id::NodeId;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::sync::{Lock, Lrc};
use rustc_errors::{emitter::SilentEmitter, ColorConfig, Handler};
use rustc_errors::{
error_code, fallback_fluent_bundle, Applicability, Diagnostic, DiagnosticBuilder,
ErrorGuaranteed, MultiSpan,
DiagnosticMessage, ErrorGuaranteed, MultiSpan,
};
use rustc_feature::{find_feature_issue, GateIssue, UnstableFeatures};
use rustc_span::edition::Edition;
@ -287,4 +288,23 @@ impl ParseSess {
pub fn proc_macro_quoted_spans(&self) -> Vec<Span> {
self.proc_macro_quoted_spans.lock().clone()
}
pub fn emit_err<'a>(&'a self, err: impl SessionDiagnostic<'a>) -> ErrorGuaranteed {
err.into_diagnostic(self).emit()
}
pub fn emit_warning<'a>(&'a self, warning: impl SessionDiagnostic<'a, ()>) {
warning.into_diagnostic(self).emit()
}
pub fn struct_err(
&self,
msg: impl Into<DiagnosticMessage>,
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
self.span_diagnostic.struct_err(msg)
}
pub fn struct_warn(&self, msg: impl Into<DiagnosticMessage>) -> DiagnosticBuilder<'_, ()> {
self.span_diagnostic.struct_warn(msg)
}
}

View file

@ -212,7 +212,7 @@ pub struct PerfStats {
pub trait SessionDiagnostic<'a, T: EmissionGuarantee = ErrorGuaranteed> {
/// Write out as a diagnostic out of `sess`.
#[must_use]
fn into_diagnostic(self, sess: &'a Session) -> DiagnosticBuilder<'a, T>;
fn into_diagnostic(self, sess: &'a ParseSess) -> DiagnosticBuilder<'a, T>;
}
impl Session {
@ -334,7 +334,7 @@ impl Session {
&self,
msg: impl Into<DiagnosticMessage>,
) -> DiagnosticBuilder<'_, ErrorGuaranteed> {
self.diagnostic().struct_err(msg)
self.parse_sess.struct_err(msg)
}
pub fn struct_err_with_code(
&self,
@ -414,10 +414,10 @@ impl Session {
self.diagnostic().err(msg)
}
pub fn emit_err<'a>(&'a self, err: impl SessionDiagnostic<'a>) -> ErrorGuaranteed {
err.into_diagnostic(self).emit()
self.parse_sess.emit_err(err)
}
pub fn emit_warning<'a>(&'a self, warning: impl SessionDiagnostic<'a, ()>) {
warning.into_diagnostic(self).emit()
self.parse_sess.emit_warning(warning)
}
#[inline]
pub fn err_count(&self) -> usize {