diff --git a/README.md b/README.md index 4ce210fc..d92e8f88 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![Latest Version](https://img.shields.io/crates/v/derive_more.svg)](https://crates.io/crates/derive_more) [![Rust Documentation](https://docs.rs/derive_more/badge.svg)](https://docs.rs/derive_more) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/JelteF/derive_more/master/LICENSE) -[![Rust 1.70+](https://img.shields.io/badge/rustc-1.70+-lightgray.svg)](https://blog.rust-lang.org/2022/11/03/Rust-1.70.0.html) +[![Rust 1.70+](https://img.shields.io/badge/rustc-1.70+-lightgray.svg)](https://blog.rust-lang.org/2023/06/01/Rust-1.70.0.html) [![Unsafe Forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg)](https://github.com/rust-secure-code/safety-dance) Rust has lots of builtin traits that are implemented for its basic types, such diff --git a/clippy.toml b/clippy.toml index ca697fd7..2487d144 100644 --- a/clippy.toml +++ b/clippy.toml @@ -2,8 +2,6 @@ # See full lints list at: # https://rust-lang.github.io/rust-clippy/master/index.html -msrv = "1.70.0" - # Ensures consistent bracing for macro calls in the codebase. # Extends default settings: # https://github.com/rust-lang/rust-clippy/blob/master/clippy_lints/src/nonstandard_macro_braces.rs#L143-L184 diff --git a/impl/src/fmt/display.rs b/impl/src/fmt/display.rs index f70c99c5..089f44dc 100644 --- a/impl/src/fmt/display.rs +++ b/impl/src/fmt/display.rs @@ -225,7 +225,6 @@ impl<'a> Expansion<'a> { /// greater than 1. /// /// [`Display::fmt()`]: fmt::Display::fmt() - /// [`FmtAttribute`]: super::FmtAttribute fn generate_body(&self) -> syn::Result { if self.shared_format.is_none() { return self.generate_body_impl(); @@ -234,7 +233,8 @@ impl<'a> Expansion<'a> { if !shared_format.args.is_empty() { return Err(syn::Error::new( shared_format.args.span(), - "shared format string does not support positional placeholders, use named placeholders instead", + "shared format string does not support positional placeholders, use named \ + placeholders instead", )); } let mut tokens = TokenStream::new(); @@ -243,12 +243,15 @@ impl<'a> Expansion<'a> { let fmt_string = shared_format.lit.value(); let maybe_format_string = parsing::format_string(&fmt_string); let Some(format_string) = maybe_format_string else { - // If we could not parse the format string, we just use the original string so - // we get a nice error message. We also panic as a safety precaution in case our - // parsing fails to parse something that write! allows. + // If we could not parse the format string, we just use the original string, so we get + // a nice error message. We also panic as a safety precaution in case our parsing fails + // to parse something that `write!()` allows. return Ok(quote! { derive_more::core::write!(__derive_more_f, #shared_format); - unreachable!("derive_more could not parse shared format string, but rust could: {:?}", #fmt_string); + unreachable!( + "`derive_more` could not parse shared format string, but Rust could: {:?}", + #fmt_string, + ); }); }; for part in format_string.elements { @@ -261,7 +264,8 @@ impl<'a> Expansion<'a> { if format.spec.is_some() { return Err(syn::Error::new( shared_format.span(), - "shared format _variant placeholder cannot contain format specifiers", + "shared format `_variant` placeholder cannot contain format \ + specifiers", )); } if !current_format.is_empty() { @@ -279,7 +283,8 @@ impl<'a> Expansion<'a> { { return Err(syn::Error::new( shared_format.span(), - "shared format string cannot contain positional placeholders, use named placeholders instead", + "shared format string cannot contain positional placeholders, use \ + named placeholders instead", )); } current_format.push_str(raw); diff --git a/tests/display.rs b/tests/display.rs index 9a91afbd..e5f6fa8e 100644 --- a/tests/display.rs +++ b/tests/display.rs @@ -1281,6 +1281,7 @@ mod enums { mod shared_format { use super::*; + mod single { use super::*; @@ -1299,8 +1300,8 @@ mod enums { #[test] fn assert() { assert_eq!(Enum::A(1).to_string(), "Variant: A 1"); - assert_eq!(Enum::B { field: 2 }.to_string(), "Variant: B 2",); - assert_eq!(Enum::C.to_string(), "Variant: C",); + assert_eq!(Enum::B { field: 2 }.to_string(), "Variant: B 2"); + assert_eq!(Enum::C.to_string(), "Variant: C"); } } @@ -1308,7 +1309,7 @@ mod enums { use super::*; #[derive(Display)] - #[display("{_variant} Variant: {_variant} {_variant}")] + #[display("{} Variant: {} {}", _variant)] enum Enum { #[display("A {_0}")] A(i32), @@ -1326,15 +1327,14 @@ mod enums { Enum::B { field: 2 }.to_string(), "B 2 Variant: B 2 B 2", ); - assert_eq!(Enum::C.to_string(), "C Variant: C C",); + assert_eq!(Enum::C.to_string(), "C Variant: C C"); } } mod none { use super::*; - /// Make sure that variant specific bounds are not added if _variant is - /// not used. + /// Make sure that variant-specific bounds are not added if `_variant` is not used. struct NoDisplay; #[derive(Display)]