Skip to content

Commit

Permalink
[xt-ui] underway
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed Feb 2, 2024
1 parent ce3440f commit a9e8c80
Show file tree
Hide file tree
Showing 29 changed files with 802 additions and 783 deletions.
11 changes: 7 additions & 4 deletions compiler/rustc_ast_lowering/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use rustc_errors::{codes::*, DiagnosticArgFromDisplay};
use rustc_errors::{codes::*, DiagnosticArgFromDisplay, EmissionGuarantee};
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::{symbol::Ident, Span, Symbol};

Expand Down Expand Up @@ -39,10 +39,13 @@ pub struct InvalidAbi {
pub struct InvalidAbiReason(pub &'static str);

impl rustc_errors::AddToDiagnostic for InvalidAbiReason {
fn add_to_diagnostic_with<F>(self, diag: &mut rustc_errors::Diagnostic, _: F)
where
fn add_to_diagnostic_with<G: EmissionGuarantee, F>(
self,
diag: &mut rustc_errors::DiagnosticBuilder<'_, G>,
_: F,
) where
F: Fn(
&mut rustc_errors::Diagnostic,
&mut rustc_errors::DiagnosticBuilder<'_, G>,
rustc_errors::SubdiagnosticMessage,
) -> rustc_errors::SubdiagnosticMessage,
{
Expand Down
20 changes: 13 additions & 7 deletions compiler/rustc_ast_passes/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Errors emitted by ast_passes.
use rustc_ast::ParamKindOrd;
use rustc_errors::{codes::*, AddToDiagnostic, Applicability};
use rustc_errors::{codes::*, AddToDiagnostic, Applicability, EmissionGuarantee};
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::{symbol::Ident, Span, Symbol};

Expand Down Expand Up @@ -372,10 +372,13 @@ pub struct EmptyLabelManySpans(pub Vec<Span>);

// The derive for `Vec<Span>` does multiple calls to `span_label`, adding commas between each
impl AddToDiagnostic for EmptyLabelManySpans {
fn add_to_diagnostic_with<F>(self, diag: &mut rustc_errors::Diagnostic, _: F)
where
fn add_to_diagnostic_with<G: EmissionGuarantee, F>(
self,
diag: &mut rustc_errors::DiagnosticBuilder<'_, G>,
_: F,
) where
F: Fn(
&mut rustc_errors::Diagnostic,
&mut rustc_errors::DiagnosticBuilder<'_, G>,
rustc_errors::SubdiagnosticMessage,
) -> rustc_errors::SubdiagnosticMessage,
{
Expand Down Expand Up @@ -735,10 +738,13 @@ pub struct StableFeature {
}

impl AddToDiagnostic for StableFeature {
fn add_to_diagnostic_with<F>(self, diag: &mut rustc_errors::Diagnostic, _: F)
where
fn add_to_diagnostic_with<G: EmissionGuarantee, F>(
self,
diag: &mut rustc_errors::DiagnosticBuilder<'_, G>,
_: F,
) where
F: Fn(
&mut rustc_errors::Diagnostic,
&mut rustc_errors::DiagnosticBuilder<'_, G>,
rustc_errors::SubdiagnosticMessage,
) -> rustc_errors::SubdiagnosticMessage,
{
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_borrowck/src/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
// For generic associated types (GATs) which implied 'static requirement
// from higher-ranked trait bounds (HRTB). Try to locate span of the trait
// and the span which bounded to the trait for adding 'static lifetime suggestion
#[allow(rustc::diagnostic_outside_of_impl)] // njn: ugh
#[allow(rustc::untranslatable_diagnostic)]
fn suggest_static_lifetime_for_gat_from_hrtb(
&self,
diag: &mut DiagnosticBuilder<'_>,
Expand Down Expand Up @@ -419,6 +421,8 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
/// ```
///
/// Here we would be invoked with `fr = 'a` and `outlived_fr = 'b`.
#[allow(rustc::diagnostic_outside_of_impl)] // njn: ugh
#[allow(rustc::untranslatable_diagnostic)]
pub(crate) fn report_region_error(
&mut self,
fr: RegionVid,
Expand Down
23 changes: 12 additions & 11 deletions compiler/rustc_builtin_macros/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rustc_errors::{
codes::*, AddToDiagnostic, DiagCtxt, DiagnosticBuilder, EmissionGuarantee, IntoDiagnostic,
Level, MultiSpan, SingleLabelManySpans,
Level, MultiSpan, SingleLabelManySpans, SubdiagnosticMessage,
};
use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::{symbol::Ident, Span, Symbol};
Expand Down Expand Up @@ -449,10 +449,11 @@ pub(crate) struct EnvNotDefinedWithUserMessage {
impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for EnvNotDefinedWithUserMessage {
#[track_caller]
fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> DiagnosticBuilder<'a, G> {
#[expect(
rustc::untranslatable_diagnostic,
reason = "cannot translate user-provided messages"
)]
// njn: ugh
// #[expect(
// rustc::untranslatable_diagnostic,
// reason = "cannot translate user-provided messages"
// )]
let mut diag = DiagnosticBuilder::new(dcx, level, self.msg_from_user.to_string());
diag.span(self.span);
diag
Expand Down Expand Up @@ -611,12 +612,12 @@ pub(crate) struct FormatUnusedArg {
// Allow the singular form to be a subdiagnostic of the multiple-unused
// form of diagnostic.
impl AddToDiagnostic for FormatUnusedArg {
fn add_to_diagnostic_with<F>(self, diag: &mut rustc_errors::Diagnostic, f: F)
where
F: Fn(
&mut rustc_errors::Diagnostic,
rustc_errors::SubdiagnosticMessage,
) -> rustc_errors::SubdiagnosticMessage,
fn add_to_diagnostic_with<G: EmissionGuarantee, F>(
self,
diag: &mut DiagnosticBuilder<'_, G>,
f: F,
) where
F: Fn(&mut DiagnosticBuilder<'_, G>, SubdiagnosticMessage) -> SubdiagnosticMessage,
{
diag.arg("named", self.named);
let msg = f(diag, crate::fluent_generated::builtin_macros_format_unused_arg.into());
Expand Down
Loading

0 comments on commit a9e8c80

Please sign in to comment.