Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ jobs:
strategy:
matrix:
features: [fancy, syntect-highlighter]
rust: [1.70.0, stable]
rust: [1.82.0, stable]
os: [ubuntu-latest, macOS-latest, windows-latest]
exclude:
- features: syntect-highlighter
rust: 1.70.0
rust: 1.82.0

steps:
- uses: actions/checkout@v4
Expand All @@ -52,7 +52,7 @@ jobs:
if: matrix.rust == 'stable'
run: cargo test --all --verbose --features ${{matrix.features}}
- name: Run tests
if: matrix.rust == '1.70.0'
if: matrix.rust == '1.82.0'
run: cargo test --all --verbose --features ${{matrix.features}} no-format-args-capture

wasm:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ documentation = "https://docs.rs/miette"
license = "Apache-2.0"
readme = "README.md"
edition = "2018"
rust-version = "1.70.0"
rust-version = "1.82.0"
exclude = ["images/", "tests/", "miette-derive/"]

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ println!("{:?}", report.with_source_code("About something or another or yet anot

### MSRV

This crate requires rustc 1.70.0 or later.
This crate requires rustc 1.82.0 or later.

### Acknowledgements

Expand Down
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
msrv = "1.70.0"
msrv = "1.82.0"
2 changes: 1 addition & 1 deletion miette-derive/src/forward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ impl Forward {
Self::#variant { #field_name, .. } => #field_name.#method_call,
},
Forward::Unnamed(index) => {
let underscores: Vec<_> = core::iter::repeat(quote! { _, }).take(*index).collect();
let underscores: Vec<_> = std::iter::repeat_n(quote! { _, }, *index).collect();
let unnamed = format_ident!("unnamed");
quote! {
Self::#variant ( #(#underscores)* #unnamed, .. ) => #unnamed.#method_call,
Expand Down
38 changes: 2 additions & 36 deletions miette-derive/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,40 +1,6 @@
use proc_macro2::TokenStream;
use quote::{format_ident, quote, ToTokens};
use syn::{
parse::{Parse, ParseStream},
spanned::Spanned,
};

pub(crate) enum MemberOrString {
Member(syn::Member),
String(syn::LitStr),
}

impl ToTokens for MemberOrString {
fn to_tokens(&self, tokens: &mut TokenStream) {
use MemberOrString::*;
match self {
Member(member) => member.to_tokens(tokens),
String(string) => string.to_tokens(tokens),
}
}
}

impl Parse for MemberOrString {
fn parse(input: ParseStream) -> syn::Result<Self> {
let lookahead = input.lookahead1();
if lookahead.peek(syn::Ident) || lookahead.peek(syn::LitInt) {
Ok(MemberOrString::Member(input.parse()?))
} else if lookahead.peek(syn::LitStr) {
Ok(MemberOrString::String(input.parse()?))
} else {
Err(syn::Error::new(
input.span(),
"Expected a string or a field reference.",
))
}
}
}
use quote::{format_ident, quote};
use syn::spanned::Spanned;

use crate::{
diagnostic::{DiagnosticConcreteArgs, DiagnosticDef},
Expand Down
6 changes: 1 addition & 5 deletions src/eyreish/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,7 @@ pub trait ReportHandler: core::any::Any + Send + Sync {
/// }
/// }
/// ```
fn debug(
&self,
error: &(dyn Diagnostic),
f: &mut core::fmt::Formatter<'_>,
) -> core::fmt::Result;
fn debug(&self, error: &dyn Diagnostic, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result;

/// Override for the `Display` format
fn display(
Expand Down
2 changes: 1 addition & 1 deletion src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ impl Default 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() {
return fmt::Debug::fmt(diagnostic, f);
}
Expand Down
4 changes: 2 additions & 2 deletions src/handlers/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl DebugReportHandler {
pub fn render_report(
&self,
f: &mut fmt::Formatter<'_>,
diagnostic: &(dyn Diagnostic),
diagnostic: &dyn Diagnostic,
) -> fmt::Result {
let mut diag = f.debug_struct("Diagnostic");
diag.field("message", &format!("{}", diagnostic));
Expand Down Expand Up @@ -61,7 +61,7 @@ impl 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() {
return fmt::Debug::fmt(diagnostic, f);
}
Expand Down
16 changes: 8 additions & 8 deletions src/handlers/graphical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,15 @@ impl GraphicalReportHandler {
pub fn render_report(
&self,
f: &mut impl fmt::Write,
diagnostic: &(dyn Diagnostic),
diagnostic: &dyn Diagnostic,
) -> fmt::Result {
self.render_report_inner(f, diagnostic, diagnostic.source_code())
}

fn render_report_inner(
&self,
f: &mut impl fmt::Write,
diagnostic: &(dyn Diagnostic),
diagnostic: &dyn Diagnostic,
parent_src: Option<&dyn SourceCode>,
) -> fmt::Result {
let src = diagnostic.source_code().or(parent_src);
Expand Down Expand Up @@ -281,7 +281,7 @@ impl GraphicalReportHandler {
fn render_header(
&self,
f: &mut impl fmt::Write,
diagnostic: &(dyn Diagnostic),
diagnostic: &dyn Diagnostic,
is_nested: bool,
) -> fmt::Result {
let severity_style = match diagnostic.severity() {
Expand Down Expand Up @@ -326,7 +326,7 @@ impl GraphicalReportHandler {
fn render_causes(
&self,
f: &mut impl fmt::Write,
diagnostic: &(dyn Diagnostic),
diagnostic: &dyn Diagnostic,
parent_src: Option<&dyn SourceCode>,
) -> fmt::Result {
let src = diagnostic.source_code().or(parent_src);
Expand Down Expand Up @@ -424,7 +424,7 @@ impl GraphicalReportHandler {
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() {
let width = self.termwidth.saturating_sub(2);
let initial_indent = " help: ".style(self.theme.styles.help).to_string();
Expand All @@ -447,7 +447,7 @@ impl GraphicalReportHandler {
fn render_related(
&self,
f: &mut impl fmt::Write,
diagnostic: &(dyn Diagnostic),
diagnostic: &dyn Diagnostic,
parent_src: Option<&dyn SourceCode>,
) -> fmt::Result {
let src = diagnostic.source_code().or(parent_src);
Expand Down Expand Up @@ -535,7 +535,7 @@ impl GraphicalReportHandler {
fn render_snippets(
&self,
f: &mut impl fmt::Write,
diagnostic: &(dyn Diagnostic),
diagnostic: &dyn Diagnostic,
opt_source: Option<&dyn SourceCode>,
) -> fmt::Result {
let source = match opt_source {
Expand Down Expand Up @@ -1361,7 +1361,7 @@ impl 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() {
return fmt::Debug::fmt(diagnostic, f);
}
Expand Down
8 changes: 4 additions & 4 deletions src/handlers/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ impl JSONReportHandler {
pub fn render_report(
&self,
f: &mut impl fmt::Write,
diagnostic: &(dyn Diagnostic),
diagnostic: &dyn Diagnostic,
) -> fmt::Result {
self._render_report(f, diagnostic, None)
}

fn _render_report(
&self,
f: &mut impl fmt::Write,
diagnostic: &(dyn Diagnostic),
diagnostic: &dyn Diagnostic,
parent_src: Option<&dyn SourceCode>,
) -> fmt::Result {
write!(f, r#"{{"message": "{}","#, escape(&diagnostic.to_string()))?;
Expand Down Expand Up @@ -154,7 +154,7 @@ impl JSONReportHandler {
fn render_snippets(
&self,
f: &mut impl fmt::Write,
diagnostic: &(dyn Diagnostic),
diagnostic: &dyn Diagnostic,
source: &dyn SourceCode,
) -> fmt::Result {
if let Some(mut labels) = diagnostic.labels() {
Expand All @@ -170,7 +170,7 @@ impl 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)
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/handlers/narratable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl NarratableReportHandler {
pub fn render_report(
&self,
f: &mut impl fmt::Write,
diagnostic: &(dyn Diagnostic),
diagnostic: &dyn Diagnostic,
) -> fmt::Result {
self.render_header(f, diagnostic)?;
if self.with_cause_chain {
Expand All @@ -85,7 +85,7 @@ impl NarratableReportHandler {
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)?;
let severity = match diagnostic.severity() {
Some(Severity::Error) | None => "error",
Expand All @@ -96,7 +96,7 @@ impl NarratableReportHandler {
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
.diagnostic_source()
.map(DiagnosticChain::from_diagnostic)
Expand All @@ -110,7 +110,7 @@ impl NarratableReportHandler {
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() {
writeln!(f, "diagnostic help: {}", help)?;
}
Expand All @@ -126,7 +126,7 @@ impl NarratableReportHandler {
fn render_related(
&self,
f: &mut impl fmt::Write,
diagnostic: &(dyn Diagnostic),
diagnostic: &dyn Diagnostic,
parent_src: Option<&dyn SourceCode>,
) -> fmt::Result {
if let Some(related) = diagnostic.related() {
Expand All @@ -152,7 +152,7 @@ impl NarratableReportHandler {
fn render_snippets(
&self,
f: &mut impl fmt::Write,
diagnostic: &(dyn Diagnostic),
diagnostic: &dyn Diagnostic,
source_code: Option<&dyn SourceCode>,
) -> fmt::Result {
if let Some(source) = source_code {
Expand Down Expand Up @@ -344,7 +344,7 @@ impl 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() {
return fmt::Debug::fmt(diagnostic, f);
}
Expand Down
2 changes: 1 addition & 1 deletion src/highlighters/syntect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl HighlighterState for SyntectHighlighterState<'_> {
line,
&self.highlighter,
)
.map(|(style, str)| (convert_style(style, use_bg_color).style(str)))
.map(|(style, str)| convert_style(style, use_bg_color).style(str))
.collect()
} else {
vec![Style::default().style(line)]
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@
//!
//! ## MSRV
//!
//! This crate requires rustc 1.70.0 or later.
//! This crate requires rustc 1.82.0 or later.
//!
//! ## Acknowledgements
//!
Expand Down
1 change: 0 additions & 1 deletion tests/color_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ impl Drop for EnvVarGuard<'_> {

static COLOR_ENV_VARS: Mutex<()> = Mutex::new(());


/// Assert the color format used by a handler with different levels of terminal
/// support.
fn check_colors<F: Fn(MietteHandlerOpts) -> MietteHandlerOpts>(
Expand Down
1 change: 1 addition & 0 deletions tests/test_diagnostic_source_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ enum NestedEnumError {
},
}

#[cfg(feature = "fancy-no-backtrace")]
#[derive(Debug, miette::Diagnostic, thiserror::Error)]
#[error("I am the inner error")]
struct Case1Inner {
Expand Down
Loading