mirror of https://github.com/zkat/miette.git
fix(misc): Improve ci and fix clippy (#290)
* ci: Update actions, replace actions-rs. * `actions/checkout` is updated from `v1` to the current `v4`. * `actions-rs/toolchain` is replaced by `dtolnay/rust-toolchain` as the `actions-rs` actions haven't been maintained in a long time. * clippy: Remove unnecessary call to `into_iter`. The parameter takes `IntoIterator`, so we don't have to call `into_iter` at the call site. * clippy: Remove explicit lifetime that can be elided. * clippy: tests: Fix useless conversion warnings. * clippy: tests: Remove call to `format!`. * Fix minimal-versions build. Due to changes in the nightly compiler, using a recent nightly requires proc-macro2 1.0.60 or later: https://github.com/dtolnay/proc-macro2/issues/356 * ci: Use is-terminal 0.4.7 for MSRV builds. is-terminal 0.4.8 updated its MSRV to 1.63, so we can't use it with our MSRV of 1.56. Force usage of the older version which has an older MSRV.
This commit is contained in:
parent
a9c2bae9dc
commit
cc81382a60
|
|
@ -10,14 +10,12 @@ jobs:
|
||||||
name: Check fmt & build docs
|
name: Check fmt & build docs
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v4
|
||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
uses: actions-rs/toolchain@v1
|
uses: dtolnay/rust-toolchain@master
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
|
||||||
toolchain: stable
|
toolchain: stable
|
||||||
components: rustfmt
|
components: rustfmt
|
||||||
override: true
|
|
||||||
- name: rustfmt
|
- name: rustfmt
|
||||||
run: cargo fmt --all -- --check
|
run: cargo fmt --all -- --check
|
||||||
- name: docs
|
- name: docs
|
||||||
|
|
@ -32,14 +30,15 @@ jobs:
|
||||||
os: [ubuntu-latest, macOS-latest, windows-latest]
|
os: [ubuntu-latest, macOS-latest, windows-latest]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v4
|
||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
uses: actions-rs/toolchain@v1
|
uses: dtolnay/rust-toolchain@master
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
|
||||||
toolchain: ${{ matrix.rust }}
|
toolchain: ${{ matrix.rust }}
|
||||||
components: clippy
|
components: clippy
|
||||||
override: true
|
- name: Force older version of is-terminal for MSRV builds
|
||||||
|
if: matrix.rust == '1.56.0'
|
||||||
|
run: cargo update -p is-terminal --precise 0.4.7
|
||||||
- name: Clippy
|
- name: Clippy
|
||||||
run: cargo clippy --all -- -D warnings
|
run: cargo clippy --all -- -D warnings
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
|
|
@ -54,14 +53,12 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v4
|
||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
uses: actions-rs/toolchain@v1
|
uses: dtolnay/rust-toolchain@master
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
|
||||||
toolchain: nightly
|
toolchain: nightly
|
||||||
components: miri,rust-src
|
components: miri,rust-src
|
||||||
override: true
|
|
||||||
- name: Run tests with miri
|
- name: Run tests with miri
|
||||||
env:
|
env:
|
||||||
MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-strict-provenance
|
MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-strict-provenance
|
||||||
|
|
@ -75,13 +72,11 @@ jobs:
|
||||||
os: [ubuntu-latest, macOS-latest, windows-latest]
|
os: [ubuntu-latest, macOS-latest, windows-latest]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v4
|
||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
uses: actions-rs/toolchain@v1
|
uses: dtolnay/rust-toolchain@master
|
||||||
with:
|
with:
|
||||||
profile: minimal
|
|
||||||
toolchain: nightly
|
toolchain: nightly
|
||||||
override: true
|
|
||||||
- name: Run minimal version build
|
- name: Run minimal version build
|
||||||
run: cargo build -Z minimal-versions --all-features
|
run: cargo build -Z minimal-versions --all-features
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,6 @@ repository = "https://github.com/zkat/miette"
|
||||||
proc-macro = true
|
proc-macro = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
proc-macro2 = "1.0"
|
proc-macro2 = "1.0.60"
|
||||||
quote = "1.0"
|
quote = "1.0"
|
||||||
syn = "2.0.11"
|
syn = "2.0.11"
|
||||||
|
|
|
||||||
|
|
@ -382,10 +382,10 @@ impl GraphicalReportHandler {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_context<'a>(
|
fn render_context(
|
||||||
&self,
|
&self,
|
||||||
f: &mut impl fmt::Write,
|
f: &mut impl fmt::Write,
|
||||||
source: &'a dyn SourceCode,
|
source: &dyn SourceCode,
|
||||||
context: &LabeledSpan,
|
context: &LabeledSpan,
|
||||||
labels: &[LabeledSpan],
|
labels: &[LabeledSpan],
|
||||||
) -> fmt::Result {
|
) -> fmt::Result {
|
||||||
|
|
|
||||||
|
|
@ -252,7 +252,7 @@ impl MietteDiagnostic {
|
||||||
/// ```
|
/// ```
|
||||||
pub fn and_labels(mut self, labels: impl IntoIterator<Item = LabeledSpan>) -> Self {
|
pub fn and_labels(mut self, labels: impl IntoIterator<Item = LabeledSpan>) -> Self {
|
||||||
let mut all_labels = self.labels.unwrap_or_default();
|
let mut all_labels = self.labels.unwrap_or_default();
|
||||||
all_labels.extend(labels.into_iter());
|
all_labels.extend(labels);
|
||||||
self.labels = Some(all_labels);
|
self.labels = Some(all_labels);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ fn fmt_help() {
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
"1 x hello x \"2\"".to_string(),
|
"1 x hello x \"2\"".to_string(),
|
||||||
FooStruct("hello".into()).help().unwrap().to_string()
|
FooStruct("hello").help().unwrap().to_string()
|
||||||
);
|
);
|
||||||
|
|
||||||
#[derive(Debug, Diagnostic, Error)]
|
#[derive(Debug, Diagnostic, Error)]
|
||||||
|
|
@ -201,12 +201,7 @@ fn fmt_help() {
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
"1 x hello x \"2\"".to_string(),
|
"1 x hello x \"2\"".to_string(),
|
||||||
BarStruct {
|
BarStruct { my_field: "hello" }.help().unwrap().to_string()
|
||||||
my_field: "hello".into()
|
|
||||||
}
|
|
||||||
.help()
|
|
||||||
.unwrap()
|
|
||||||
.to_string()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
#[derive(Debug, Diagnostic, Error)]
|
#[derive(Debug, Diagnostic, Error)]
|
||||||
|
|
@ -224,7 +219,7 @@ fn fmt_help() {
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
"1 x bar x \"2\"".to_string(),
|
"1 x bar x \"2\"".to_string(),
|
||||||
FooEnum::X("bar".into()).help().unwrap().to_string()
|
FooEnum::X("bar").help().unwrap().to_string()
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
@ -250,12 +245,7 @@ fn help_field() {
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
"x".to_string(),
|
"x".to_string(),
|
||||||
Foo {
|
Foo { do_this: Some("x") }.help().unwrap().to_string()
|
||||||
do_this: Some("x".into())
|
|
||||||
}
|
|
||||||
.help()
|
|
||||||
.unwrap()
|
|
||||||
.to_string()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
#[derive(Debug, Diagnostic, Error)]
|
#[derive(Debug, Diagnostic, Error)]
|
||||||
|
|
@ -271,16 +261,11 @@ fn help_field() {
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
"x".to_string(),
|
"x".to_string(),
|
||||||
Bar::A(Some("x".into())).help().unwrap().to_string()
|
Bar::A(Some("x")).help().unwrap().to_string()
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
"x".to_string(),
|
"x".to_string(),
|
||||||
Bar::B {
|
Bar::B { do_this: Some("x") }.help().unwrap().to_string()
|
||||||
do_this: Some("x".into())
|
|
||||||
}
|
|
||||||
.help()
|
|
||||||
.unwrap()
|
|
||||||
.to_string()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
#[derive(Debug, Diagnostic, Error)]
|
#[derive(Debug, Diagnostic, Error)]
|
||||||
|
|
@ -288,20 +273,14 @@ fn help_field() {
|
||||||
#[diagnostic()]
|
#[diagnostic()]
|
||||||
struct Baz<'a>(#[help] Option<&'a str>);
|
struct Baz<'a>(#[help] Option<&'a str>);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!("x".to_string(), Baz(Some("x")).help().unwrap().to_string());
|
||||||
"x".to_string(),
|
|
||||||
Baz(Some("x".into())).help().unwrap().to_string()
|
|
||||||
);
|
|
||||||
|
|
||||||
#[derive(Debug, Diagnostic, Error)]
|
#[derive(Debug, Diagnostic, Error)]
|
||||||
#[error("welp")]
|
#[error("welp")]
|
||||||
#[diagnostic()]
|
#[diagnostic()]
|
||||||
struct Quux<'a>(#[help] &'a str);
|
struct Quux<'a>(#[help] &'a str);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!("x".to_string(), Quux("x").help().unwrap().to_string());
|
||||||
"x".to_string(),
|
|
||||||
Quux("x".into()).help().unwrap().to_string()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,7 @@ fn test_diagnostic_source() {
|
||||||
fn test_diagnostic_source_pass_extra_info() {
|
fn test_diagnostic_source_pass_extra_info() {
|
||||||
let diag = TestBoxedError(Box::new(SourceError {
|
let diag = TestBoxedError(Box::new(SourceError {
|
||||||
code: String::from("Hello\nWorld!"),
|
code: String::from("Hello\nWorld!"),
|
||||||
help: format!("Have you tried turning it on and off again?"),
|
help: String::from("Have you tried turning it on and off again?"),
|
||||||
label: (1, 4),
|
label: (1, 4),
|
||||||
}));
|
}));
|
||||||
let mut out = String::new();
|
let mut out = String::new();
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,6 @@ mod json_report_handler {
|
||||||
"related": []
|
"related": []
|
||||||
}"#
|
}"#
|
||||||
.lines()
|
.lines()
|
||||||
.into_iter()
|
|
||||||
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
||||||
.collect();
|
.collect();
|
||||||
assert_eq!(expected, out);
|
assert_eq!(expected, out);
|
||||||
|
|
@ -98,7 +97,6 @@ mod json_report_handler {
|
||||||
"related": []
|
"related": []
|
||||||
}"#
|
}"#
|
||||||
.lines()
|
.lines()
|
||||||
.into_iter()
|
|
||||||
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
||||||
.collect();
|
.collect();
|
||||||
assert_eq!(expected, out);
|
assert_eq!(expected, out);
|
||||||
|
|
@ -144,7 +142,6 @@ mod json_report_handler {
|
||||||
"related": []
|
"related": []
|
||||||
}"#
|
}"#
|
||||||
.lines()
|
.lines()
|
||||||
.into_iter()
|
|
||||||
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
||||||
.collect();
|
.collect();
|
||||||
assert_eq!(expected, out);
|
assert_eq!(expected, out);
|
||||||
|
|
@ -190,7 +187,6 @@ mod json_report_handler {
|
||||||
"related": []
|
"related": []
|
||||||
}"#
|
}"#
|
||||||
.lines()
|
.lines()
|
||||||
.into_iter()
|
|
||||||
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
||||||
.collect();
|
.collect();
|
||||||
assert_eq!(expected, out);
|
assert_eq!(expected, out);
|
||||||
|
|
@ -235,7 +231,6 @@ mod json_report_handler {
|
||||||
"related": []
|
"related": []
|
||||||
}"#
|
}"#
|
||||||
.lines()
|
.lines()
|
||||||
.into_iter()
|
|
||||||
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
||||||
.collect();
|
.collect();
|
||||||
assert_eq!(expected, out);
|
assert_eq!(expected, out);
|
||||||
|
|
@ -281,7 +276,6 @@ mod json_report_handler {
|
||||||
"related": []
|
"related": []
|
||||||
}"#
|
}"#
|
||||||
.lines()
|
.lines()
|
||||||
.into_iter()
|
|
||||||
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
||||||
.collect();
|
.collect();
|
||||||
assert_eq!(expected, out);
|
assert_eq!(expected, out);
|
||||||
|
|
@ -347,7 +341,6 @@ mod json_report_handler {
|
||||||
"related": []
|
"related": []
|
||||||
}"#
|
}"#
|
||||||
.lines()
|
.lines()
|
||||||
.into_iter()
|
|
||||||
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
||||||
.collect();
|
.collect();
|
||||||
assert_eq!(expected, out);
|
assert_eq!(expected, out);
|
||||||
|
|
@ -393,7 +386,6 @@ mod json_report_handler {
|
||||||
"related": []
|
"related": []
|
||||||
}"#
|
}"#
|
||||||
.lines()
|
.lines()
|
||||||
.into_iter()
|
|
||||||
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
||||||
.collect();
|
.collect();
|
||||||
assert_eq!(expected, out);
|
assert_eq!(expected, out);
|
||||||
|
|
@ -456,7 +448,6 @@ mod json_report_handler {
|
||||||
"related": []
|
"related": []
|
||||||
}"#
|
}"#
|
||||||
.lines()
|
.lines()
|
||||||
.into_iter()
|
|
||||||
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
||||||
.collect();
|
.collect();
|
||||||
assert_eq!(expected, out);
|
assert_eq!(expected, out);
|
||||||
|
|
@ -532,7 +523,6 @@ mod json_report_handler {
|
||||||
"related": []
|
"related": []
|
||||||
}"#
|
}"#
|
||||||
.lines()
|
.lines()
|
||||||
.into_iter()
|
|
||||||
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
||||||
.collect();
|
.collect();
|
||||||
assert_eq!(expected, out);
|
assert_eq!(expected, out);
|
||||||
|
|
@ -588,7 +578,6 @@ mod json_report_handler {
|
||||||
"related": []
|
"related": []
|
||||||
}"#
|
}"#
|
||||||
.lines()
|
.lines()
|
||||||
.into_iter()
|
|
||||||
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
||||||
.collect();
|
.collect();
|
||||||
assert_eq!(expected, out);
|
assert_eq!(expected, out);
|
||||||
|
|
@ -644,7 +633,6 @@ mod json_report_handler {
|
||||||
"related": []
|
"related": []
|
||||||
}"#
|
}"#
|
||||||
.lines()
|
.lines()
|
||||||
.into_iter()
|
|
||||||
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
||||||
.collect();
|
.collect();
|
||||||
assert_eq!(expected, out);
|
assert_eq!(expected, out);
|
||||||
|
|
@ -700,7 +688,6 @@ mod json_report_handler {
|
||||||
"related": []
|
"related": []
|
||||||
}"#
|
}"#
|
||||||
.lines()
|
.lines()
|
||||||
.into_iter()
|
|
||||||
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
||||||
.collect();
|
.collect();
|
||||||
assert_eq!(expected, out);
|
assert_eq!(expected, out);
|
||||||
|
|
@ -728,7 +715,6 @@ mod json_report_handler {
|
||||||
"related": []
|
"related": []
|
||||||
}"#
|
}"#
|
||||||
.lines()
|
.lines()
|
||||||
.into_iter()
|
|
||||||
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
||||||
.collect();
|
.collect();
|
||||||
assert_eq!(expected, out);
|
assert_eq!(expected, out);
|
||||||
|
|
@ -822,7 +808,6 @@ mod json_report_handler {
|
||||||
}]
|
}]
|
||||||
}"#
|
}"#
|
||||||
.lines()
|
.lines()
|
||||||
.into_iter()
|
|
||||||
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
||||||
.collect();
|
.collect();
|
||||||
assert_eq!(expected, out);
|
assert_eq!(expected, out);
|
||||||
|
|
@ -920,7 +905,6 @@ mod json_report_handler {
|
||||||
}]
|
}]
|
||||||
}"#
|
}"#
|
||||||
.lines()
|
.lines()
|
||||||
.into_iter()
|
|
||||||
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
|
||||||
.collect();
|
.collect();
|
||||||
assert_eq!(expected, out);
|
assert_eq!(expected, out);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue