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

Marked Debug implementations for primitive types as #[inline] #47840

Merged
merged 2 commits into from Jan 31, 2018
Merged

Marked Debug implementations for primitive types as #[inline] #47840

merged 2 commits into from Jan 31, 2018

Conversation

ghost
Copy link

@ghost ghost commented Jan 29, 2018

Fixes #47792.

@rust-highfive
Copy link
Collaborator

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]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one, definitely

@@ -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 {
Copy link
Member

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.

Copy link
Author

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Author

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.

@@ -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 {
Copy link
Member

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.

@kennytm kennytm added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 29, 2018
@kennytm
Copy link
Member

kennytm commented Jan 29, 2018

This PR caused a linker error in the ui/nll/constant.rs test (undefined reference to _$LT$core..fmt..Formatter$LT$ReEarlyBound$LP$0$C$$u20$$u27$a$RP$$GT$$u20$as$u20$core..fmt..Write$GT$::write_char::hb364ee25624bc6ea), probably caused by #47840 (comment).

@kennytm kennytm added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 30, 2018
@bluss
Copy link
Member

bluss commented Jan 30, 2018

Thanks a lot!

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jan 30, 2018

📌 Commit deba389 has been approved by bluss

@bluss
Copy link
Member

bluss commented Jan 30, 2018

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

@kennytm kennytm added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 30, 2018
kennytm added a commit to kennytm/rust that referenced this pull request Jan 31, 2018
Marked Debug implementations for primitive types as #[inline]

Change for issue rust-lang#47792.
bors added a commit that referenced this pull request Jan 31, 2018
Rollup of 16 pull requests

- Successful merges: #47838, #47840, #47844, #47874, #47875, #47876, #47884, #47886, #47889, #47890, #47891, #47795, #47677, #47893, #47895, #47552
- Failed merges:
@bors bors merged commit deba389 into rust-lang:master Jan 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants