Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add #[inline] to functions that are never called #110027

Merged
merged 1 commit into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -2269,13 +2269,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 @@ -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!() }
}
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