From 93e0d479945d19ead144d3d1cc5a5c4a3c459828 Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Thu, 16 Apr 2020 09:33:02 -0700 Subject: [PATCH 1/2] Mark some `Serialize::Encoder` impls as `#[inline]` Some trivial methods in impls of the `Serialize::Encoder` trait are not marked `#[inline]` but are not generic and are (I believe) used cross-crate. --- src/librustc_metadata/rmeta/encoder.rs | 10 +++++++--- src/librustc_middle/ty/query/on_disk_cache.rs | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/librustc_metadata/rmeta/encoder.rs b/src/librustc_metadata/rmeta/encoder.rs index d75298fae0032..f15ac9097daa2 100644 --- a/src/librustc_metadata/rmeta/encoder.rs +++ b/src/librustc_metadata/rmeta/encoder.rs @@ -59,15 +59,19 @@ struct EncodeContext<'tcx> { macro_rules! encoder_methods { ($($name:ident($ty:ty);)*) => { - $(fn $name(&mut self, value: $ty) -> Result<(), Self::Error> { - self.opaque.$name(value) - })* + $( + #[inline] + fn $name(&mut self, value: $ty) -> Result<(), Self::Error> { + self.opaque.$name(value) + } + )* } } impl<'tcx> Encoder for EncodeContext<'tcx> { type Error = ::Error; + #[inline] fn emit_unit(&mut self) -> Result<(), Self::Error> { Ok(()) } diff --git a/src/librustc_middle/ty/query/on_disk_cache.rs b/src/librustc_middle/ty/query/on_disk_cache.rs index 8aecc0e698a8e..e9bb659d5c839 100644 --- a/src/librustc_middle/ty/query/on_disk_cache.rs +++ b/src/librustc_middle/ty/query/on_disk_cache.rs @@ -922,6 +922,7 @@ where { type Error = E::Error; + #[inline] fn emit_unit(&mut self) -> Result<(), Self::Error> { Ok(()) } From 99cca04ca33e0eb50de665870087b1b80375c898 Mon Sep 17 00:00:00 2001 From: Dylan MacKenzie Date: Thu, 16 Apr 2020 09:38:18 -0700 Subject: [PATCH 2/2] Put `#[inline]` in the correct place At present, the macro only adds `#[inline]` to the first method. --- src/librustc_middle/ty/query/on_disk_cache.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/librustc_middle/ty/query/on_disk_cache.rs b/src/librustc_middle/ty/query/on_disk_cache.rs index e9bb659d5c839..54b2d9e5ddc38 100644 --- a/src/librustc_middle/ty/query/on_disk_cache.rs +++ b/src/librustc_middle/ty/query/on_disk_cache.rs @@ -909,10 +909,12 @@ where macro_rules! encoder_methods { ($($name:ident($ty:ty);)*) => { - #[inline] - $(fn $name(&mut self, value: $ty) -> Result<(), Self::Error> { - self.encoder.$name(value) - })* + $( + #[inline] + fn $name(&mut self, value: $ty) -> Result<(), Self::Error> { + self.encoder.$name(value) + } + )* } }