Skip to content

Commit 2b79495

Browse files
fix(ci, clippy): raise MSRV to 1.82, fix rust 1.90 warnings (#451)
* fix: remove unused code * fix: 1.90 errors * MSRV: 1.82.0 * fix: warnings exposed by increasing MSRV
1 parent 7a4d759 commit 2b79495

File tree

16 files changed

+35
-73
lines changed

16 files changed

+35
-73
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ jobs:
3333
strategy:
3434
matrix:
3535
features: [fancy, syntect-highlighter]
36-
rust: [1.70.0, stable]
36+
rust: [1.82.0, stable]
3737
os: [ubuntu-latest, macOS-latest, windows-latest]
3838
exclude:
3939
- features: syntect-highlighter
40-
rust: 1.70.0
40+
rust: 1.82.0
4141

4242
steps:
4343
- uses: actions/checkout@v4
@@ -52,7 +52,7 @@ jobs:
5252
if: matrix.rust == 'stable'
5353
run: cargo test --all --verbose --features ${{matrix.features}}
5454
- name: Run tests
55-
if: matrix.rust == '1.70.0'
55+
if: matrix.rust == '1.82.0'
5656
run: cargo test --all --verbose --features ${{matrix.features}} no-format-args-capture
5757

5858
wasm:

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ documentation = "https://docs.rs/miette"
99
license = "Apache-2.0"
1010
readme = "README.md"
1111
edition = "2018"
12-
rust-version = "1.70.0"
12+
rust-version = "1.82.0"
1313
exclude = ["images/", "tests/", "miette-derive/"]
1414

1515
[dependencies]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ println!("{:?}", report.with_source_code("About something or another or yet anot
785785

786786
### MSRV
787787

788-
This crate requires rustc 1.70.0 or later.
788+
This crate requires rustc 1.82.0 or later.
789789

790790
### Acknowledgements
791791

clippy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
msrv = "1.70.0"
1+
msrv = "1.82.0"

miette-derive/src/forward.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl Forward {
150150
Self::#variant { #field_name, .. } => #field_name.#method_call,
151151
},
152152
Forward::Unnamed(index) => {
153-
let underscores: Vec<_> = core::iter::repeat(quote! { _, }).take(*index).collect();
153+
let underscores: Vec<_> = std::iter::repeat_n(quote! { _, }, *index).collect();
154154
let unnamed = format_ident!("unnamed");
155155
quote! {
156156
Self::#variant ( #(#underscores)* #unnamed, .. ) => #unnamed.#method_call,

miette-derive/src/utils.rs

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,6 @@
11
use proc_macro2::TokenStream;
2-
use quote::{format_ident, quote, ToTokens};
3-
use syn::{
4-
parse::{Parse, ParseStream},
5-
spanned::Spanned,
6-
};
7-
8-
pub(crate) enum MemberOrString {
9-
Member(syn::Member),
10-
String(syn::LitStr),
11-
}
12-
13-
impl ToTokens for MemberOrString {
14-
fn to_tokens(&self, tokens: &mut TokenStream) {
15-
use MemberOrString::*;
16-
match self {
17-
Member(member) => member.to_tokens(tokens),
18-
String(string) => string.to_tokens(tokens),
19-
}
20-
}
21-
}
22-
23-
impl Parse for MemberOrString {
24-
fn parse(input: ParseStream) -> syn::Result<Self> {
25-
let lookahead = input.lookahead1();
26-
if lookahead.peek(syn::Ident) || lookahead.peek(syn::LitInt) {
27-
Ok(MemberOrString::Member(input.parse()?))
28-
} else if lookahead.peek(syn::LitStr) {
29-
Ok(MemberOrString::String(input.parse()?))
30-
} else {
31-
Err(syn::Error::new(
32-
input.span(),
33-
"Expected a string or a field reference.",
34-
))
35-
}
36-
}
37-
}
2+
use quote::{format_ident, quote};
3+
use syn::spanned::Spanned;
384

395
use crate::{
406
diagnostic::{DiagnosticConcreteArgs, DiagnosticDef},

src/eyreish/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,7 @@ pub trait ReportHandler: core::any::Any + Send + Sync {
172172
/// }
173173
/// }
174174
/// ```
175-
fn debug(
176-
&self,
177-
error: &(dyn Diagnostic),
178-
f: &mut core::fmt::Formatter<'_>,
179-
) -> core::fmt::Result;
175+
fn debug(&self, error: &dyn Diagnostic, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result;
180176

181177
/// Override for the `Display` format
182178
fn display(

src/handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ impl Default for MietteHandler {
402402
}
403403

404404
impl ReportHandler for MietteHandler {
405-
fn debug(&self, diagnostic: &(dyn Diagnostic), f: &mut fmt::Formatter<'_>) -> fmt::Result {
405+
fn debug(&self, diagnostic: &dyn Diagnostic, f: &mut fmt::Formatter<'_>) -> fmt::Result {
406406
if f.alternate() {
407407
return fmt::Debug::fmt(diagnostic, f);
408408
}

src/handlers/debug.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl DebugReportHandler {
3131
pub fn render_report(
3232
&self,
3333
f: &mut fmt::Formatter<'_>,
34-
diagnostic: &(dyn Diagnostic),
34+
diagnostic: &dyn Diagnostic,
3535
) -> fmt::Result {
3636
let mut diag = f.debug_struct("Diagnostic");
3737
diag.field("message", &format!("{}", diagnostic));
@@ -61,7 +61,7 @@ impl DebugReportHandler {
6161
}
6262

6363
impl ReportHandler for DebugReportHandler {
64-
fn debug(&self, diagnostic: &(dyn Diagnostic), f: &mut fmt::Formatter<'_>) -> fmt::Result {
64+
fn debug(&self, diagnostic: &dyn Diagnostic, f: &mut fmt::Formatter<'_>) -> fmt::Result {
6565
if f.alternate() {
6666
return fmt::Debug::fmt(diagnostic, f);
6767
}

src/handlers/graphical.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -242,15 +242,15 @@ impl GraphicalReportHandler {
242242
pub fn render_report(
243243
&self,
244244
f: &mut impl fmt::Write,
245-
diagnostic: &(dyn Diagnostic),
245+
diagnostic: &dyn Diagnostic,
246246
) -> fmt::Result {
247247
self.render_report_inner(f, diagnostic, diagnostic.source_code())
248248
}
249249

250250
fn render_report_inner(
251251
&self,
252252
f: &mut impl fmt::Write,
253-
diagnostic: &(dyn Diagnostic),
253+
diagnostic: &dyn Diagnostic,
254254
parent_src: Option<&dyn SourceCode>,
255255
) -> fmt::Result {
256256
let src = diagnostic.source_code().or(parent_src);
@@ -281,7 +281,7 @@ impl GraphicalReportHandler {
281281
fn render_header(
282282
&self,
283283
f: &mut impl fmt::Write,
284-
diagnostic: &(dyn Diagnostic),
284+
diagnostic: &dyn Diagnostic,
285285
is_nested: bool,
286286
) -> fmt::Result {
287287
let severity_style = match diagnostic.severity() {
@@ -326,7 +326,7 @@ impl GraphicalReportHandler {
326326
fn render_causes(
327327
&self,
328328
f: &mut impl fmt::Write,
329-
diagnostic: &(dyn Diagnostic),
329+
diagnostic: &dyn Diagnostic,
330330
parent_src: Option<&dyn SourceCode>,
331331
) -> fmt::Result {
332332
let src = diagnostic.source_code().or(parent_src);
@@ -424,7 +424,7 @@ impl GraphicalReportHandler {
424424
Ok(())
425425
}
426426

427-
fn render_footer(&self, f: &mut impl fmt::Write, diagnostic: &(dyn Diagnostic)) -> fmt::Result {
427+
fn render_footer(&self, f: &mut impl fmt::Write, diagnostic: &dyn Diagnostic) -> fmt::Result {
428428
if let Some(help) = diagnostic.help() {
429429
let width = self.termwidth.saturating_sub(2);
430430
let initial_indent = " help: ".style(self.theme.styles.help).to_string();
@@ -447,7 +447,7 @@ impl GraphicalReportHandler {
447447
fn render_related(
448448
&self,
449449
f: &mut impl fmt::Write,
450-
diagnostic: &(dyn Diagnostic),
450+
diagnostic: &dyn Diagnostic,
451451
parent_src: Option<&dyn SourceCode>,
452452
) -> fmt::Result {
453453
let src = diagnostic.source_code().or(parent_src);
@@ -535,7 +535,7 @@ impl GraphicalReportHandler {
535535
fn render_snippets(
536536
&self,
537537
f: &mut impl fmt::Write,
538-
diagnostic: &(dyn Diagnostic),
538+
diagnostic: &dyn Diagnostic,
539539
opt_source: Option<&dyn SourceCode>,
540540
) -> fmt::Result {
541541
let source = match opt_source {
@@ -1361,7 +1361,7 @@ impl GraphicalReportHandler {
13611361
}
13621362

13631363
impl ReportHandler for GraphicalReportHandler {
1364-
fn debug(&self, diagnostic: &(dyn Diagnostic), f: &mut fmt::Formatter<'_>) -> fmt::Result {
1364+
fn debug(&self, diagnostic: &dyn Diagnostic, f: &mut fmt::Formatter<'_>) -> fmt::Result {
13651365
if f.alternate() {
13661366
return fmt::Debug::fmt(diagnostic, f);
13671367
}

0 commit comments

Comments
 (0)