diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd12a0f..03b994a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,4 +39,4 @@ jobs: steps: - uses: actions/checkout@v2 - uses: dtolnay/rust-toolchain@clippy - - run: cargo clippy -- -Dclippy::all + - run: cargo clippy --tests -- -Dclippy::all diff --git a/impl/src/expand.rs b/impl/src/expand.rs index 3da8f41..40ed247 100644 --- a/impl/src/expand.rs +++ b/impl/src/expand.rs @@ -114,6 +114,7 @@ fn impl_struct(input: Struct) -> TokenStream { let display_impl = display_body.map(|body| { quote! { impl #impl_generics std::fmt::Display for #ty #ty_generics #where_clause { + #[allow(clippy::used_underscore_binding)] fn fmt(&self, __formatter: &mut std::fmt::Formatter) -> std::fmt::Result { #body } @@ -296,7 +297,7 @@ fn impl_enum(input: Enum) -> TokenStream { impl #impl_generics std::fmt::Display for #ty #ty_generics #where_clause { fn fmt(&self, __formatter: &mut std::fmt::Formatter) -> std::fmt::Result { #use_as_display - #[allow(unused_variables, deprecated)] + #[allow(unused_variables, deprecated, clippy::used_underscore_binding)] match #void_deref self { #(#arms,)* } diff --git a/tests/compiletest.rs b/tests/compiletest.rs index f9aea23..641d03c 100644 --- a/tests/compiletest.rs +++ b/tests/compiletest.rs @@ -1,3 +1,5 @@ +#![deny(clippy::all, clippy::pedantic)] + #[rustversion::attr(not(nightly), ignore)] #[test] fn ui() { diff --git a/tests/test_deprecated.rs b/tests/test_deprecated.rs index d03cdba..5524666 100644 --- a/tests/test_deprecated.rs +++ b/tests/test_deprecated.rs @@ -1,4 +1,4 @@ -#![deny(deprecated)] +#![deny(deprecated, clippy::all, clippy::pedantic)] use thiserror::Error; diff --git a/tests/test_display.rs b/tests/test_display.rs index 34cce94..cae1dc8 100644 --- a/tests/test_display.rs +++ b/tests/test_display.rs @@ -1,3 +1,5 @@ +#![deny(clippy::all, clippy::pedantic)] + use std::fmt::Display; use thiserror::Error; @@ -114,6 +116,7 @@ fn test_nested() { #[error("!bool = {}", not(.0))] struct Error(bool); + #[allow(clippy::trivially_copy_pass_by_ref)] fn not(bool: &bool) -> bool { !*bool } @@ -126,7 +129,7 @@ fn test_match() { #[derive(Error, Debug)] #[error("{}: {0}", match .1 { Some(n) => format!("error occurred with {}", n), - None => format!("there was an empty error"), + None => "there was an empty error".to_owned(), })] struct Error(String, Option); @@ -142,6 +145,7 @@ fn test_match() { #[test] fn test_void() { + #[allow(clippy::empty_enum)] #[derive(Error, Debug)] #[error("...")] pub enum Error {} diff --git a/tests/test_error.rs b/tests/test_error.rs index fab934d..ece7f91 100644 --- a/tests/test_error.rs +++ b/tests/test_error.rs @@ -1,3 +1,4 @@ +#![deny(clippy::all, clippy::pedantic)] #![allow(dead_code)] use std::fmt::{self, Display}; diff --git a/tests/test_expr.rs b/tests/test_expr.rs index e86d33a..add5811 100644 --- a/tests/test_expr.rs +++ b/tests/test_expr.rs @@ -1,3 +1,5 @@ +#![deny(clippy::all, clippy::pedantic)] + use std::fmt::Display; use thiserror::Error; @@ -39,8 +41,7 @@ pub enum RustupError { "toolchain '{name}' does not contain component {component}{}", .suggestion .as_ref() - .map(|s| format!("; did you mean '{}'?", s)) - .unwrap_or_else(String::new), + .map_or_else(String::new, |s| format!("; did you mean '{}'?", s)), )] UnknownComponent { name: String, diff --git a/tests/test_from.rs b/tests/test_from.rs index f1755fb..e8f0161 100644 --- a/tests/test_from.rs +++ b/tests/test_from.rs @@ -1,3 +1,5 @@ +#![deny(clippy::all, clippy::pedantic)] + use std::io; use thiserror::Error; diff --git a/tests/test_option.rs b/tests/test_option.rs index 4b41cc1..ca21713 100644 --- a/tests/test_option.rs +++ b/tests/test_option.rs @@ -1,4 +1,5 @@ #![cfg_attr(thiserror_nightly_testing, feature(backtrace))] +#![deny(clippy::all, clippy::pedantic)] #[cfg(thiserror_nightly_testing)] pub mod structs { diff --git a/tests/test_path.rs b/tests/test_path.rs index a34a3d7..a10b1f3 100644 --- a/tests/test_path.rs +++ b/tests/test_path.rs @@ -1,3 +1,5 @@ +#![deny(clippy::all, clippy::pedantic)] + use ref_cast::RefCast; use std::fmt::Display; use std::path::{Path, PathBuf}; diff --git a/tests/test_source.rs b/tests/test_source.rs index 7c68a3e..66d9dad 100644 --- a/tests/test_source.rs +++ b/tests/test_source.rs @@ -1,3 +1,5 @@ +#![deny(clippy::all, clippy::pedantic)] + use std::error::Error as StdError; use std::io; use thiserror::Error; diff --git a/tests/test_transparent.rs b/tests/test_transparent.rs index 8fba5fe..b862b25 100644 --- a/tests/test_transparent.rs +++ b/tests/test_transparent.rs @@ -1,3 +1,5 @@ +#![deny(clippy::all, clippy::pedantic)] + use anyhow::anyhow; use std::error::Error as _; use std::io;