Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve ci and fix clippy #290

Merged
merged 7 commits into from
Sep 20, 2023
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
27 changes: 11 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ jobs:
name: Check fmt & build docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@master
with:
profile: minimal
toolchain: stable
components: rustfmt
override: true
- name: rustfmt
run: cargo fmt --all -- --check
- name: docs
Expand All @@ -32,14 +30,15 @@ jobs:
os: [ubuntu-latest, macOS-latest, windows-latest]

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@master
with:
profile: minimal
toolchain: ${{ matrix.rust }}
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
run: cargo clippy --all -- -D warnings
- name: Run tests
Expand All @@ -54,14 +53,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@master
with:
profile: minimal
toolchain: nightly
components: miri,rust-src
override: true
- name: Run tests with miri
env:
MIRIFLAGS: -Zmiri-disable-isolation -Zmiri-strict-provenance
Expand All @@ -75,13 +72,11 @@ jobs:
os: [ubuntu-latest, macOS-latest, windows-latest]

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@master
with:
profile: minimal
toolchain: nightly
override: true
- name: Run minimal version build
run: cargo build -Z minimal-versions --all-features

2 changes: 1 addition & 1 deletion miette-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ repository = "https://github.com/zkat/miette"
proc-macro = true

[dependencies]
proc-macro2 = "1.0"
proc-macro2 = "1.0.60"
quote = "1.0"
syn = "2.0.11"
4 changes: 2 additions & 2 deletions src/handlers/graphical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,10 @@ impl GraphicalReportHandler {
Ok(())
}

fn render_context<'a>(
fn render_context(
&self,
f: &mut impl fmt::Write,
source: &'a dyn SourceCode,
source: &dyn SourceCode,
context: &LabeledSpan,
labels: &[LabeledSpan],
) -> fmt::Result {
Expand Down
2 changes: 1 addition & 1 deletion src/miette_diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ impl MietteDiagnostic {
/// ```
pub fn and_labels(mut self, labels: impl IntoIterator<Item = LabeledSpan>) -> Self {
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
}
Expand Down
37 changes: 8 additions & 29 deletions tests/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ fn fmt_help() {

assert_eq!(
"1 x hello x \"2\"".to_string(),
FooStruct("hello".into()).help().unwrap().to_string()
FooStruct("hello").help().unwrap().to_string()
);

#[derive(Debug, Diagnostic, Error)]
Expand All @@ -201,12 +201,7 @@ fn fmt_help() {

assert_eq!(
"1 x hello x \"2\"".to_string(),
BarStruct {
my_field: "hello".into()
}
.help()
.unwrap()
.to_string()
BarStruct { my_field: "hello" }.help().unwrap().to_string()
);

#[derive(Debug, Diagnostic, Error)]
Expand All @@ -224,7 +219,7 @@ fn fmt_help() {

assert_eq!(
"1 x bar x \"2\"".to_string(),
FooEnum::X("bar".into()).help().unwrap().to_string()
FooEnum::X("bar").help().unwrap().to_string()
);

assert_eq!(
Expand All @@ -250,12 +245,7 @@ fn help_field() {

assert_eq!(
"x".to_string(),
Foo {
do_this: Some("x".into())
}
.help()
.unwrap()
.to_string()
Foo { do_this: Some("x") }.help().unwrap().to_string()
);

#[derive(Debug, Diagnostic, Error)]
Expand All @@ -271,37 +261,26 @@ fn help_field() {

assert_eq!(
"x".to_string(),
Bar::A(Some("x".into())).help().unwrap().to_string()
Bar::A(Some("x")).help().unwrap().to_string()
);
assert_eq!(
"x".to_string(),
Bar::B {
do_this: Some("x".into())
}
.help()
.unwrap()
.to_string()
Bar::B { do_this: Some("x") }.help().unwrap().to_string()
);

#[derive(Debug, Diagnostic, Error)]
#[error("welp")]
#[diagnostic()]
struct Baz<'a>(#[help] Option<&'a str>);

assert_eq!(
"x".to_string(),
Baz(Some("x".into())).help().unwrap().to_string()
);
assert_eq!("x".to_string(), Baz(Some("x")).help().unwrap().to_string());

#[derive(Debug, Diagnostic, Error)]
#[error("welp")]
#[diagnostic()]
struct Quux<'a>(#[help] &'a str);

assert_eq!(
"x".to_string(),
Quux("x".into()).help().unwrap().to_string()
);
assert_eq!("x".to_string(), Quux("x").help().unwrap().to_string());
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_diagnostic_source_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fn test_diagnostic_source() {
fn test_diagnostic_source_pass_extra_info() {
let diag = TestBoxedError(Box::new(SourceError {
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),
}));
let mut out = String::new();
Expand Down
16 changes: 0 additions & 16 deletions tests/test_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ mod json_report_handler {
"related": []
}"#
.lines()
.into_iter()
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
.collect();
assert_eq!(expected, out);
Expand Down Expand Up @@ -98,7 +97,6 @@ mod json_report_handler {
"related": []
}"#
.lines()
.into_iter()
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
.collect();
assert_eq!(expected, out);
Expand Down Expand Up @@ -144,7 +142,6 @@ mod json_report_handler {
"related": []
}"#
.lines()
.into_iter()
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
.collect();
assert_eq!(expected, out);
Expand Down Expand Up @@ -190,7 +187,6 @@ mod json_report_handler {
"related": []
}"#
.lines()
.into_iter()
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
.collect();
assert_eq!(expected, out);
Expand Down Expand Up @@ -235,7 +231,6 @@ mod json_report_handler {
"related": []
}"#
.lines()
.into_iter()
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
.collect();
assert_eq!(expected, out);
Expand Down Expand Up @@ -281,7 +276,6 @@ mod json_report_handler {
"related": []
}"#
.lines()
.into_iter()
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
.collect();
assert_eq!(expected, out);
Expand Down Expand Up @@ -347,7 +341,6 @@ mod json_report_handler {
"related": []
}"#
.lines()
.into_iter()
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
.collect();
assert_eq!(expected, out);
Expand Down Expand Up @@ -393,7 +386,6 @@ mod json_report_handler {
"related": []
}"#
.lines()
.into_iter()
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
.collect();
assert_eq!(expected, out);
Expand Down Expand Up @@ -456,7 +448,6 @@ mod json_report_handler {
"related": []
}"#
.lines()
.into_iter()
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
.collect();
assert_eq!(expected, out);
Expand Down Expand Up @@ -532,7 +523,6 @@ mod json_report_handler {
"related": []
}"#
.lines()
.into_iter()
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
.collect();
assert_eq!(expected, out);
Expand Down Expand Up @@ -588,7 +578,6 @@ mod json_report_handler {
"related": []
}"#
.lines()
.into_iter()
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
.collect();
assert_eq!(expected, out);
Expand Down Expand Up @@ -644,7 +633,6 @@ mod json_report_handler {
"related": []
}"#
.lines()
.into_iter()
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
.collect();
assert_eq!(expected, out);
Expand Down Expand Up @@ -700,7 +688,6 @@ mod json_report_handler {
"related": []
}"#
.lines()
.into_iter()
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
.collect();
assert_eq!(expected, out);
Expand Down Expand Up @@ -728,7 +715,6 @@ mod json_report_handler {
"related": []
}"#
.lines()
.into_iter()
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
.collect();
assert_eq!(expected, out);
Expand Down Expand Up @@ -822,7 +808,6 @@ mod json_report_handler {
}]
}"#
.lines()
.into_iter()
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
.collect();
assert_eq!(expected, out);
Expand Down Expand Up @@ -920,7 +905,6 @@ mod json_report_handler {
}]
}"#
.lines()
.into_iter()
.map(|s| s.trim_matches(|c| c == ' ' || c == '\n'))
.collect();
assert_eq!(expected, out);
Expand Down