-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Marked Debug implementations for primitive types as #[inline] #47840
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @bluss (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
@@ -157,6 +157,7 @@ macro_rules! debug { | |||
($T:ident) => { | |||
#[stable(feature = "rust1", since = "1.0.0")] | |||
impl fmt::Debug for $T { | |||
#[inline] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one, definitely
src/libcore/fmt/mod.rs
Outdated
@@ -1718,6 +1725,7 @@ macro_rules! tuple { | |||
#[stable(feature = "rust1", since = "1.0.0")] | |||
impl<$($name:Debug),*> Debug for ($($name,)*) where last_type!($($name,)+): ?Sized { | |||
#[allow(non_snake_case, unused_assignments, deprecated)] | |||
#[inline] | |||
fn fmt(&self, f: &mut Formatter) -> Result { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an example of one we don't need to mark inline. We want to mark those that are not generic and forwarding directly to another non-generic function as inline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! With those conditions, should the only ones that I mark inline be non-float numbers, the unit type and bools? Just making sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree.
I'm not 100% sure which trade off is the best for the function pointers, ideas welcome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd even skip the unit type if pad is a method that inlines. We don't want to inline a bigger function with this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The unit type's pad method doesn't inline, so I think I'll inline the unit type's fmt function. For function pointers, I think I'll avoid marking them as inline them for now.
src/libcore/fmt/mod.rs
Outdated
@@ -1628,6 +1632,7 @@ impl Display for str { | |||
|
|||
#[stable(feature = "rust1", since = "1.0.0")] | |||
impl Debug for char { | |||
#[inline] | |||
fn fmt(&self, f: &mut Formatter) -> Result { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, this one should not be inline.
This PR caused a linker error in the |
Thanks a lot! @bors r+ rollup |
📌 Commit deba389 has been approved by |
Before bors gets around to merging this, you can change the PR message (first comment in this issue) to use one of the command forms for closing the issue that github likes |
Marked Debug implementations for primitive types as #[inline] Change for issue rust-lang#47792.
Fixes #47792.