Skip to content

Commit

Permalink
Auto merge of #110027 - nbdd0121:dieting, r=m-ou-se
Browse files Browse the repository at this point in the history
Add `#[inline]` to functions that are never called

This makes libcore binary size reduce by ~300 bytes. Not much, but these functions are never called so it doesn't make sense for them to get into the binary anyway.
  • Loading branch information
bors committed May 9, 2023
2 parents 90c02c1 + 8bafcde commit 33a01e2
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions library/core/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,7 @@ mod impls {

#[unstable(feature = "never_type", issue = "35121")]
impl PartialEq for ! {
#[inline]
fn eq(&self, _: &!) -> bool {
*self
}
Expand All @@ -1422,13 +1423,15 @@ mod impls {

#[unstable(feature = "never_type", issue = "35121")]
impl PartialOrd for ! {
#[inline]
fn partial_cmp(&self, _: &!) -> Option<Ordering> {
*self
}
}

#[unstable(feature = "never_type", issue = "35121")]
impl Ord for ! {
#[inline]
fn cmp(&self, _: &!) -> Ordering {
*self
}
Expand Down
1 change: 1 addition & 0 deletions library/core/src/convert/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 2 additions & 0 deletions library/core/src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2267,13 +2267,15 @@ 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
}
}

#[unstable(feature = "never_type", issue = "35121")]
impl Display for ! {
#[inline]
fn fmt(&self, _: &mut Formatter<'_>) -> Result {
*self
}
Expand Down
1 change: 1 addition & 0 deletions library/core/src/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions library/core/src/intrinsics/mir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ pub struct BasicBlock;
macro_rules! define {
($name:literal, $( #[ $meta:meta ] )* fn $($sig:tt)*) => {
#[rustc_diagnostic_item = $name]
#[inline]
$( #[ $meta ] )*
pub fn $($sig)* { panic!() }
}
Expand Down
1 change: 1 addition & 0 deletions library/core/src/num/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ impl From<Infallible> 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<Infallible> for TryFromIntError` above will keep working
Expand Down

0 comments on commit 33a01e2

Please sign in to comment.