fix: 1.90 errors

This commit is contained in:
Charlie Gettys 2025-09-25 22:56:41 -07:00
parent 98e0ac97f3
commit 22494897b1
7 changed files with 24 additions and 30 deletions

View File

@ -1,8 +1,6 @@
use proc_macro2::TokenStream; use proc_macro2::TokenStream;
use quote::{format_ident, quote}; use quote::{format_ident, quote};
use syn::{ use syn::spanned::Spanned;
spanned::Spanned,
};
use crate::{ use crate::{
diagnostic::{DiagnosticConcreteArgs, DiagnosticDef}, diagnostic::{DiagnosticConcreteArgs, DiagnosticDef},

View File

@ -172,11 +172,7 @@ pub trait ReportHandler: core::any::Any + Send + Sync {
/// } /// }
/// } /// }
/// ``` /// ```
fn debug( fn debug(&self, error: &dyn Diagnostic, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result;
&self,
error: &(dyn Diagnostic),
f: &mut core::fmt::Formatter<'_>,
) -> core::fmt::Result;
/// Override for the `Display` format /// Override for the `Display` format
fn display( fn display(

View File

@ -402,7 +402,7 @@ impl Default for MietteHandler {
} }
impl ReportHandler for MietteHandler { impl ReportHandler for MietteHandler {
fn debug(&self, diagnostic: &(dyn Diagnostic), f: &mut fmt::Formatter<'_>) -> fmt::Result { fn debug(&self, diagnostic: &dyn Diagnostic, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if f.alternate() { if f.alternate() {
return fmt::Debug::fmt(diagnostic, f); return fmt::Debug::fmt(diagnostic, f);
} }

View File

@ -31,7 +31,7 @@ impl DebugReportHandler {
pub fn render_report( pub fn render_report(
&self, &self,
f: &mut fmt::Formatter<'_>, f: &mut fmt::Formatter<'_>,
diagnostic: &(dyn Diagnostic), diagnostic: &dyn Diagnostic,
) -> fmt::Result { ) -> fmt::Result {
let mut diag = f.debug_struct("Diagnostic"); let mut diag = f.debug_struct("Diagnostic");
diag.field("message", &format!("{}", diagnostic)); diag.field("message", &format!("{}", diagnostic));
@ -61,7 +61,7 @@ impl DebugReportHandler {
} }
impl ReportHandler for DebugReportHandler { impl ReportHandler for DebugReportHandler {
fn debug(&self, diagnostic: &(dyn Diagnostic), f: &mut fmt::Formatter<'_>) -> fmt::Result { fn debug(&self, diagnostic: &dyn Diagnostic, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if f.alternate() { if f.alternate() {
return fmt::Debug::fmt(diagnostic, f); return fmt::Debug::fmt(diagnostic, f);
} }

View File

@ -242,7 +242,7 @@ impl GraphicalReportHandler {
pub fn render_report( pub fn render_report(
&self, &self,
f: &mut impl fmt::Write, f: &mut impl fmt::Write,
diagnostic: &(dyn Diagnostic), diagnostic: &dyn Diagnostic,
) -> fmt::Result { ) -> fmt::Result {
self.render_report_inner(f, diagnostic, diagnostic.source_code()) self.render_report_inner(f, diagnostic, diagnostic.source_code())
} }
@ -250,7 +250,7 @@ impl GraphicalReportHandler {
fn render_report_inner( fn render_report_inner(
&self, &self,
f: &mut impl fmt::Write, f: &mut impl fmt::Write,
diagnostic: &(dyn Diagnostic), diagnostic: &dyn Diagnostic,
parent_src: Option<&dyn SourceCode>, parent_src: Option<&dyn SourceCode>,
) -> fmt::Result { ) -> fmt::Result {
let src = diagnostic.source_code().or(parent_src); let src = diagnostic.source_code().or(parent_src);
@ -281,7 +281,7 @@ impl GraphicalReportHandler {
fn render_header( fn render_header(
&self, &self,
f: &mut impl fmt::Write, f: &mut impl fmt::Write,
diagnostic: &(dyn Diagnostic), diagnostic: &dyn Diagnostic,
is_nested: bool, is_nested: bool,
) -> fmt::Result { ) -> fmt::Result {
let severity_style = match diagnostic.severity() { let severity_style = match diagnostic.severity() {
@ -326,7 +326,7 @@ impl GraphicalReportHandler {
fn render_causes( fn render_causes(
&self, &self,
f: &mut impl fmt::Write, f: &mut impl fmt::Write,
diagnostic: &(dyn Diagnostic), diagnostic: &dyn Diagnostic,
parent_src: Option<&dyn SourceCode>, parent_src: Option<&dyn SourceCode>,
) -> fmt::Result { ) -> fmt::Result {
let src = diagnostic.source_code().or(parent_src); let src = diagnostic.source_code().or(parent_src);
@ -424,7 +424,7 @@ impl GraphicalReportHandler {
Ok(()) Ok(())
} }
fn render_footer(&self, f: &mut impl fmt::Write, diagnostic: &(dyn Diagnostic)) -> fmt::Result { fn render_footer(&self, f: &mut impl fmt::Write, diagnostic: &dyn Diagnostic) -> fmt::Result {
if let Some(help) = diagnostic.help() { if let Some(help) = diagnostic.help() {
let width = self.termwidth.saturating_sub(2); let width = self.termwidth.saturating_sub(2);
let initial_indent = " help: ".style(self.theme.styles.help).to_string(); let initial_indent = " help: ".style(self.theme.styles.help).to_string();
@ -447,7 +447,7 @@ impl GraphicalReportHandler {
fn render_related( fn render_related(
&self, &self,
f: &mut impl fmt::Write, f: &mut impl fmt::Write,
diagnostic: &(dyn Diagnostic), diagnostic: &dyn Diagnostic,
parent_src: Option<&dyn SourceCode>, parent_src: Option<&dyn SourceCode>,
) -> fmt::Result { ) -> fmt::Result {
let src = diagnostic.source_code().or(parent_src); let src = diagnostic.source_code().or(parent_src);
@ -535,7 +535,7 @@ impl GraphicalReportHandler {
fn render_snippets( fn render_snippets(
&self, &self,
f: &mut impl fmt::Write, f: &mut impl fmt::Write,
diagnostic: &(dyn Diagnostic), diagnostic: &dyn Diagnostic,
opt_source: Option<&dyn SourceCode>, opt_source: Option<&dyn SourceCode>,
) -> fmt::Result { ) -> fmt::Result {
let source = match opt_source { let source = match opt_source {
@ -1361,7 +1361,7 @@ impl GraphicalReportHandler {
} }
impl ReportHandler for GraphicalReportHandler { impl ReportHandler for GraphicalReportHandler {
fn debug(&self, diagnostic: &(dyn Diagnostic), f: &mut fmt::Formatter<'_>) -> fmt::Result { fn debug(&self, diagnostic: &dyn Diagnostic, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if f.alternate() { if f.alternate() {
return fmt::Debug::fmt(diagnostic, f); return fmt::Debug::fmt(diagnostic, f);
} }

View File

@ -60,7 +60,7 @@ impl JSONReportHandler {
pub fn render_report( pub fn render_report(
&self, &self,
f: &mut impl fmt::Write, f: &mut impl fmt::Write,
diagnostic: &(dyn Diagnostic), diagnostic: &dyn Diagnostic,
) -> fmt::Result { ) -> fmt::Result {
self._render_report(f, diagnostic, None) self._render_report(f, diagnostic, None)
} }
@ -68,7 +68,7 @@ impl JSONReportHandler {
fn _render_report( fn _render_report(
&self, &self,
f: &mut impl fmt::Write, f: &mut impl fmt::Write,
diagnostic: &(dyn Diagnostic), diagnostic: &dyn Diagnostic,
parent_src: Option<&dyn SourceCode>, parent_src: Option<&dyn SourceCode>,
) -> fmt::Result { ) -> fmt::Result {
write!(f, r#"{{"message": "{}","#, escape(&diagnostic.to_string()))?; write!(f, r#"{{"message": "{}","#, escape(&diagnostic.to_string()))?;
@ -154,7 +154,7 @@ impl JSONReportHandler {
fn render_snippets( fn render_snippets(
&self, &self,
f: &mut impl fmt::Write, f: &mut impl fmt::Write,
diagnostic: &(dyn Diagnostic), diagnostic: &dyn Diagnostic,
source: &dyn SourceCode, source: &dyn SourceCode,
) -> fmt::Result { ) -> fmt::Result {
if let Some(mut labels) = diagnostic.labels() { if let Some(mut labels) = diagnostic.labels() {
@ -170,7 +170,7 @@ impl JSONReportHandler {
} }
impl ReportHandler for JSONReportHandler { impl ReportHandler for JSONReportHandler {
fn debug(&self, diagnostic: &(dyn Diagnostic), f: &mut fmt::Formatter<'_>) -> fmt::Result { fn debug(&self, diagnostic: &dyn Diagnostic, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.render_report(f, diagnostic) self.render_report(f, diagnostic)
} }
} }

View File

@ -69,7 +69,7 @@ impl NarratableReportHandler {
pub fn render_report( pub fn render_report(
&self, &self,
f: &mut impl fmt::Write, f: &mut impl fmt::Write,
diagnostic: &(dyn Diagnostic), diagnostic: &dyn Diagnostic,
) -> fmt::Result { ) -> fmt::Result {
self.render_header(f, diagnostic)?; self.render_header(f, diagnostic)?;
if self.with_cause_chain { if self.with_cause_chain {
@ -85,7 +85,7 @@ impl NarratableReportHandler {
Ok(()) Ok(())
} }
fn render_header(&self, f: &mut impl fmt::Write, diagnostic: &(dyn Diagnostic)) -> fmt::Result { fn render_header(&self, f: &mut impl fmt::Write, diagnostic: &dyn Diagnostic) -> fmt::Result {
writeln!(f, "{}", diagnostic)?; writeln!(f, "{}", diagnostic)?;
let severity = match diagnostic.severity() { let severity = match diagnostic.severity() {
Some(Severity::Error) | None => "error", Some(Severity::Error) | None => "error",
@ -96,7 +96,7 @@ impl NarratableReportHandler {
Ok(()) Ok(())
} }
fn render_causes(&self, f: &mut impl fmt::Write, diagnostic: &(dyn Diagnostic)) -> fmt::Result { fn render_causes(&self, f: &mut impl fmt::Write, diagnostic: &dyn Diagnostic) -> fmt::Result {
if let Some(cause_iter) = diagnostic if let Some(cause_iter) = diagnostic
.diagnostic_source() .diagnostic_source()
.map(DiagnosticChain::from_diagnostic) .map(DiagnosticChain::from_diagnostic)
@ -110,7 +110,7 @@ impl NarratableReportHandler {
Ok(()) Ok(())
} }
fn render_footer(&self, f: &mut impl fmt::Write, diagnostic: &(dyn Diagnostic)) -> fmt::Result { fn render_footer(&self, f: &mut impl fmt::Write, diagnostic: &dyn Diagnostic) -> fmt::Result {
if let Some(help) = diagnostic.help() { if let Some(help) = diagnostic.help() {
writeln!(f, "diagnostic help: {}", help)?; writeln!(f, "diagnostic help: {}", help)?;
} }
@ -126,7 +126,7 @@ impl NarratableReportHandler {
fn render_related( fn render_related(
&self, &self,
f: &mut impl fmt::Write, f: &mut impl fmt::Write,
diagnostic: &(dyn Diagnostic), diagnostic: &dyn Diagnostic,
parent_src: Option<&dyn SourceCode>, parent_src: Option<&dyn SourceCode>,
) -> fmt::Result { ) -> fmt::Result {
if let Some(related) = diagnostic.related() { if let Some(related) = diagnostic.related() {
@ -152,7 +152,7 @@ impl NarratableReportHandler {
fn render_snippets( fn render_snippets(
&self, &self,
f: &mut impl fmt::Write, f: &mut impl fmt::Write,
diagnostic: &(dyn Diagnostic), diagnostic: &dyn Diagnostic,
source_code: Option<&dyn SourceCode>, source_code: Option<&dyn SourceCode>,
) -> fmt::Result { ) -> fmt::Result {
if let Some(source) = source_code { if let Some(source) = source_code {
@ -344,7 +344,7 @@ impl NarratableReportHandler {
} }
impl ReportHandler for NarratableReportHandler { impl ReportHandler for NarratableReportHandler {
fn debug(&self, diagnostic: &(dyn Diagnostic), f: &mut fmt::Formatter<'_>) -> fmt::Result { fn debug(&self, diagnostic: &dyn Diagnostic, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if f.alternate() { if f.alternate() {
return fmt::Debug::fmt(diagnostic, f); return fmt::Debug::fmt(diagnostic, f);
} }