diff --git a/CHANGELOG.md b/CHANGELOG.md index 81ce2aba..270eee3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,6 +69,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ([#298](https://github.com/JelteF/derive_more/pull/298)) - Add `TryFrom` derive for enums to convert from their discriminant. ([#300](https://github.com/JelteF/derive_more/pull/300)) +- `#[inline]` attributes to `IsVariant` and `Debug` implementations. + ([#334](https://github.com/JelteF/derive_more/pull/334) ### Changed diff --git a/impl/src/error.rs b/impl/src/error.rs index cc8e76f7..f02f90a4 100644 --- a/impl/src/error.rs +++ b/impl/src/error.rs @@ -37,6 +37,8 @@ pub fn expand( }; let source = source.map(|source| { + // Not using `#[inline]` here on purpose, since this is almost never part + // of a hot codepath. quote! { fn source(&self) -> Option<&(dyn ::derive_more::Error + 'static)> { use ::derive_more::__private::AsDynError; @@ -46,6 +48,8 @@ pub fn expand( }); let provide = provide.map(|provide| { + // Not using `#[inline]` here on purpose, since this is almost never part + // of a hot codepath. quote! { fn provide<'_request>(&'_request self, request: &mut ::derive_more::core::error::Request<'_request>) { #provide diff --git a/impl/src/fmt/debug.rs b/impl/src/fmt/debug.rs index 15d59bfc..b09c9c35 100644 --- a/impl/src/fmt/debug.rs +++ b/impl/src/fmt/debug.rs @@ -47,6 +47,7 @@ pub fn expand(input: &syn::DeriveInput, _: &str) -> syn::Result { Ok(quote! { #[automatically_derived] impl #impl_gens ::derive_more::Debug for #ident #ty_gens #where_clause { + #[inline] fn fmt( &self, __derive_more_f: &mut ::derive_more::core::fmt::Formatter<'_> ) -> ::derive_more::core::fmt::Result { diff --git a/impl/src/is_variant.rs b/impl/src/is_variant.rs index 123e3fb7..d667fc2e 100644 --- a/impl/src/is_variant.rs +++ b/impl/src/is_variant.rs @@ -44,6 +44,7 @@ pub fn expand(input: &DeriveInput, trait_name: &'static str) -> Result bool { match self { #enum_name ::#variant_ident #data_pattern => true,