From 8bafcdeac3918035a9df68b025ac31cc176f8ef8 Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Thu, 6 Apr 2023 23:42:38 +0100 Subject: [PATCH] Add `#[inline]` to functions that are never called --- library/core/src/cmp.rs | 3 +++ library/core/src/convert/mod.rs | 1 + library/core/src/fmt/mod.rs | 2 ++ library/core/src/intrinsics.rs | 1 + library/core/src/intrinsics/mir.rs | 1 + library/core/src/num/error.rs | 1 + 6 files changed, 9 insertions(+) diff --git a/library/core/src/cmp.rs b/library/core/src/cmp.rs index 48b127716f50d..faf48ae570fdd 100644 --- a/library/core/src/cmp.rs +++ b/library/core/src/cmp.rs @@ -1412,6 +1412,7 @@ mod impls { #[unstable(feature = "never_type", issue = "35121")] impl PartialEq for ! { + #[inline] fn eq(&self, _: &!) -> bool { *self } @@ -1422,6 +1423,7 @@ mod impls { #[unstable(feature = "never_type", issue = "35121")] impl PartialOrd for ! { + #[inline] fn partial_cmp(&self, _: &!) -> Option { *self } @@ -1429,6 +1431,7 @@ mod impls { #[unstable(feature = "never_type", issue = "35121")] impl Ord for ! { + #[inline] fn cmp(&self, _: &!) -> Ordering { *self } diff --git a/library/core/src/convert/mod.rs b/library/core/src/convert/mod.rs index 3ae787cac71f8..38a6d1ccdb552 100644 --- a/library/core/src/convert/mod.rs +++ b/library/core/src/convert/mod.rs @@ -915,6 +915,7 @@ impl Ord for Infallible { #[stable(feature = "convert_infallible", since = "1.34.0")] impl From for Infallible { + #[inline] fn from(x: !) -> Self { x } diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index e193332f155be..7db9f40dd9860 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -2269,6 +2269,7 @@ fmt_refs! { Debug, Display, Octal, Binary, LowerHex, UpperHex, LowerExp, UpperEx #[unstable(feature = "never_type", issue = "35121")] impl Debug for ! { + #[inline] fn fmt(&self, _: &mut Formatter<'_>) -> Result { *self } @@ -2276,6 +2277,7 @@ impl Debug for ! { #[unstable(feature = "never_type", issue = "35121")] impl Display for ! { + #[inline] fn fmt(&self, _: &mut Formatter<'_>) -> Result { *self } diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 077c0fdc380bc..3f2b1595d62b2 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -2523,6 +2523,7 @@ macro_rules! assert_unsafe_precondition { } } #[allow(non_snake_case)] + #[inline] const fn comptime$(<$($tt)*>)?($(_:$ty),*) {} ::core::intrinsics::const_eval_select(($($i,)*), comptime, runtime); diff --git a/library/core/src/intrinsics/mir.rs b/library/core/src/intrinsics/mir.rs index 45498a54b25dc..b95c01b0af7bb 100644 --- a/library/core/src/intrinsics/mir.rs +++ b/library/core/src/intrinsics/mir.rs @@ -265,6 +265,7 @@ pub struct BasicBlock; macro_rules! define { ($name:literal, $( #[ $meta:meta ] )* fn $($sig:tt)*) => { #[rustc_diagnostic_item = $name] + #[inline] $( #[ $meta ] )* pub fn $($sig)* { panic!() } } diff --git a/library/core/src/num/error.rs b/library/core/src/num/error.rs index 2ad0f1dc5063e..14e99578a7c7d 100644 --- a/library/core/src/num/error.rs +++ b/library/core/src/num/error.rs @@ -34,6 +34,7 @@ impl From for TryFromIntError { #[unstable(feature = "never_type", issue = "35121")] impl From for TryFromIntError { + #[inline] fn from(never: !) -> TryFromIntError { // Match rather than coerce to make sure that code like // `From for TryFromIntError` above will keep working