From d812965460986ddb409ba4ef7ffa57ce614eeb01 Mon Sep 17 00:00:00 2001 From: tyranron Date: Fri, 29 Nov 2024 14:03:14 +0100 Subject: [PATCH 1/3] Fix `compile_fail` tests --- tests/compile_fail/as_mut/renamed_generic.stderr | 3 +++ tests/compile_fail/as_ref/renamed_generic.stderr | 3 +++ 2 files changed, 6 insertions(+) diff --git a/tests/compile_fail/as_mut/renamed_generic.stderr b/tests/compile_fail/as_mut/renamed_generic.stderr index 190faaed..08e2cb40 100644 --- a/tests/compile_fail/as_mut/renamed_generic.stderr +++ b/tests/compile_fail/as_mut/renamed_generic.stderr @@ -13,6 +13,9 @@ error[E0599]: the method `as_mut` exists for struct `Baz`, but its trait bo = note: trait bound `Foo: AsMut>` was not satisfied note: the trait `AsMut` must be implemented --> $RUST/core/src/convert/mod.rs + | + | pub trait AsMut { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `as_mut`, perhaps you need to implement it: candidate #1: `AsMut` diff --git a/tests/compile_fail/as_ref/renamed_generic.stderr b/tests/compile_fail/as_ref/renamed_generic.stderr index 07311720..445e89af 100644 --- a/tests/compile_fail/as_ref/renamed_generic.stderr +++ b/tests/compile_fail/as_ref/renamed_generic.stderr @@ -13,6 +13,9 @@ error[E0599]: the method `as_ref` exists for struct `Baz`, but its trait bo = note: trait bound `Foo: AsRef>` was not satisfied note: the trait `AsRef` must be implemented --> $RUST/core/src/convert/mod.rs + | + | pub trait AsRef { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `as_ref`, perhaps you need to implement it: candidate #1: `AsRef` From 22360ea15cdec2c069091eb73fc7cc5a155acfb8 Mon Sep 17 00:00:00 2001 From: tyranron Date: Fri, 29 Nov 2024 14:15:58 +0100 Subject: [PATCH 2/3] Make Clippy happy --- impl/src/as/mod.rs | 2 +- impl/src/error.rs | 2 +- impl/src/fmt/debug.rs | 2 +- impl/src/fmt/display.rs | 2 +- impl/src/from.rs | 2 +- impl/src/into.rs | 2 +- impl/src/utils.rs | 8 ++++---- src/fmt.rs | 2 +- src/vendor/thiserror/README.md | 2 +- src/vendor/thiserror/aserror.rs | 12 +++++++----- 10 files changed, 19 insertions(+), 17 deletions(-) diff --git a/impl/src/as/mod.rs b/impl/src/as/mod.rs index c9a1cc8f..5dfe6bac 100644 --- a/impl/src/as/mod.rs +++ b/impl/src/as/mod.rs @@ -176,7 +176,7 @@ struct Expansion<'a> { conversions: Option, } -impl<'a> ToTokens for Expansion<'a> { +impl ToTokens for Expansion<'_> { fn to_tokens(&self, tokens: &mut TokenStream) { let field_ty = &self.field.ty; let field_ident = self.field.ident.as_ref().map_or_else( diff --git a/impl/src/error.rs b/impl/src/error.rs index de71c4ee..76382d18 100644 --- a/impl/src/error.rs +++ b/impl/src/error.rs @@ -203,7 +203,7 @@ impl<'input, 'state> ParsedFields<'input, 'state> { } } -impl<'input, 'state> ParsedFields<'input, 'state> { +impl ParsedFields<'_, '_> { fn render_source_as_struct(&self) -> Option { let source = self.source?; let ident = &self.data.members[source]; diff --git a/impl/src/fmt/debug.rs b/impl/src/fmt/debug.rs index 42e115f1..9d4dc0d3 100644 --- a/impl/src/fmt/debug.rs +++ b/impl/src/fmt/debug.rs @@ -222,7 +222,7 @@ struct Expansion<'a> { attr_name: &'a syn::Ident, } -impl<'a> Expansion<'a> { +impl Expansion<'_> { /// Validates attributes of this [`Expansion`] to be consistent. fn validate_attrs(&self) -> syn::Result<()> { if self.attr.fmt.is_some() { diff --git a/impl/src/fmt/display.rs b/impl/src/fmt/display.rs index b1c656b3..2f6c52fd 100644 --- a/impl/src/fmt/display.rs +++ b/impl/src/fmt/display.rs @@ -254,7 +254,7 @@ struct Expansion<'a> { trait_ident: &'a syn::Ident, } -impl<'a> Expansion<'a> { +impl Expansion<'_> { /// Generates [`Display::fmt()`] implementation for a struct or an enum variant. /// /// # Errors diff --git a/impl/src/from.rs b/impl/src/from.rs index 46a16bd3..d2f9c21c 100644 --- a/impl/src/from.rs +++ b/impl/src/from.rs @@ -143,7 +143,7 @@ struct Expansion<'a> { has_explicit_from: bool, } -impl<'a> Expansion<'a> { +impl Expansion<'_> { /// Expands [`From`] implementations for a struct or an enum variant. fn expand(&self) -> syn::Result { use crate::utils::FieldsExt as _; diff --git a/impl/src/into.rs b/impl/src/into.rs index 0f4601d2..0c699755 100644 --- a/impl/src/into.rs +++ b/impl/src/into.rs @@ -123,7 +123,7 @@ struct Expansion<'a> { convs: ConversionsAttribute, } -impl<'a> Expansion<'a> { +impl Expansion<'_> { fn expand(self) -> syn::Result { let Self { input_ident, diff --git a/impl/src/utils.rs b/impl/src/utils.rs index 28205bd0..7485d2b9 100644 --- a/impl/src/utils.rs +++ b/impl/src/utils.rs @@ -770,7 +770,7 @@ pub struct MultiVariantData<'input, 'state> { pub infos: Vec, } -impl<'input, 'state> MultiFieldData<'input, 'state> { +impl MultiFieldData<'_, '_> { pub fn initializer(&self, initializers: &[T]) -> TokenStream { let MultiFieldData { variant_type, @@ -804,7 +804,7 @@ impl<'input, 'state> MultiFieldData<'input, 'state> { } } -impl<'input, 'state> SingleFieldData<'input, 'state> { +impl SingleFieldData<'_, '_> { pub fn initializer(&self, initializers: &[T]) -> TokenStream { self.multi_field_data.initializer(initializers) } @@ -2306,7 +2306,7 @@ mod generics_search { pub(crate) consts: HashSet<&'s syn::Ident>, } - impl<'s> GenericsSearch<'s> { + impl GenericsSearch<'_> { /// Checks the provided [`syn::Type`] to contain anything from this [`GenericsSearch`]. pub(crate) fn any_in(&self, ty: &syn::Type) -> bool { let mut visitor = Visitor { @@ -2327,7 +2327,7 @@ mod generics_search { found: bool, } - impl<'s, 'ast> Visit<'ast> for Visitor<'s> { + impl<'ast> Visit<'ast> for Visitor<'_> { fn visit_type_path(&mut self, tp: &'ast syn::TypePath) { self.found |= tp.path.get_ident().map_or(false, |ident| { self.search.types.contains(ident) || self.search.consts.contains(ident) diff --git a/src/fmt.rs b/src/fmt.rs index 0acd4ca2..afe125a3 100644 --- a/src/fmt.rs +++ b/src/fmt.rs @@ -173,7 +173,7 @@ impl<'a, 'b> Padded<'a, 'b> { } } -impl<'a, 'b> Write for Padded<'a, 'b> { +impl Write for Padded<'_, '_> { fn write_str(&mut self, s: &str) -> Result { for s in s.split_inclusive('\n') { if self.on_newline { diff --git a/src/vendor/thiserror/README.md b/src/vendor/thiserror/README.md index 0c7f1247..6fa82a92 100644 --- a/src/vendor/thiserror/README.md +++ b/src/vendor/thiserror/README.md @@ -3,4 +3,4 @@ These are vendored files from the [`thiserror`] crate. The license files in this directory only apply to the files in this subdirectory of `derive_more`. -[`thiserror`]: https://github.com/dtolnay/thiserror +[`thiserror`]: https://github.com/dtolnay/thiserror/blob/2.0.3 diff --git a/src/vendor/thiserror/aserror.rs b/src/vendor/thiserror/aserror.rs index c3e086f0..dd223fea 100644 --- a/src/vendor/thiserror/aserror.rs +++ b/src/vendor/thiserror/aserror.rs @@ -5,6 +5,7 @@ use std::error::Error; use core::panic::UnwindSafe; +#[doc(hidden)] pub trait AsDynError<'a>: Sealed { fn as_dyn_error(&self) -> &(dyn Error + 'a); } @@ -44,9 +45,10 @@ impl<'a> AsDynError<'a> for dyn Error + Send + Sync + UnwindSafe + 'a { } } +#[doc(hidden)] pub trait Sealed {} -impl<'a, T: Error + 'a> Sealed for T {} -impl<'a> Sealed for dyn Error + 'a {} -impl<'a> Sealed for dyn Error + Send + 'a {} -impl<'a> Sealed for dyn Error + Send + Sync + 'a {} -impl<'a> Sealed for dyn Error + Send + Sync + UnwindSafe + 'a {} +impl Sealed for T {} +impl Sealed for dyn Error + '_ {} +impl Sealed for dyn Error + Send + '_ {} +impl Sealed for dyn Error + Send + Sync + '_ {} +impl Sealed for dyn Error + Send + Sync + UnwindSafe + '_ {} From 616d77ec0bc92710c1f0d925611050a2ac831204 Mon Sep 17 00:00:00 2001 From: tyranron Date: Fri, 29 Nov 2024 14:17:46 +0100 Subject: [PATCH 3/3] Revert --- tests/compile_fail/as_mut/renamed_generic.stderr | 3 --- tests/compile_fail/as_ref/renamed_generic.stderr | 3 --- 2 files changed, 6 deletions(-) diff --git a/tests/compile_fail/as_mut/renamed_generic.stderr b/tests/compile_fail/as_mut/renamed_generic.stderr index 08e2cb40..190faaed 100644 --- a/tests/compile_fail/as_mut/renamed_generic.stderr +++ b/tests/compile_fail/as_mut/renamed_generic.stderr @@ -13,9 +13,6 @@ error[E0599]: the method `as_mut` exists for struct `Baz`, but its trait bo = note: trait bound `Foo: AsMut>` was not satisfied note: the trait `AsMut` must be implemented --> $RUST/core/src/convert/mod.rs - | - | pub trait AsMut { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `as_mut`, perhaps you need to implement it: candidate #1: `AsMut` diff --git a/tests/compile_fail/as_ref/renamed_generic.stderr b/tests/compile_fail/as_ref/renamed_generic.stderr index 445e89af..07311720 100644 --- a/tests/compile_fail/as_ref/renamed_generic.stderr +++ b/tests/compile_fail/as_ref/renamed_generic.stderr @@ -13,9 +13,6 @@ error[E0599]: the method `as_ref` exists for struct `Baz`, but its trait bo = note: trait bound `Foo: AsRef>` was not satisfied note: the trait `AsRef` must be implemented --> $RUST/core/src/convert/mod.rs - | - | pub trait AsRef { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: items from traits can only be used if the trait is implemented and in scope = note: the following trait defines an item `as_ref`, perhaps you need to implement it: candidate #1: `AsRef`