Skip to content

make copy_within #[inline] #56886

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

Closed
wants to merge 1 commit into from

Conversation

oconnor663
Copy link
Contributor

@briansmith suggested this in
#54236 (comment).

@rust-highfive
Copy link
Contributor

r? @sfackler

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 16, 2018
@oconnor663 oconnor663 mentioned this pull request Dec 16, 2018
4 tasks
@sfackler
Copy link
Member

We generally do not add #[inline] to methods that are already inlined.

@oconnor663
Copy link
Contributor Author

@briansmith what do you think here? I don't know enough about the compiler to have a real opinion.

@briansmith
Copy link
Contributor

I don't know under what circumstances the compiler automatically inlines functions. It seems reasonable to me to think that, although the compiler might inline something without a hint today, it might choose to not do so tomorrow. OTOH if the compiler is guaranteed to always inline the function (why?) then I agree it is redundant.

@sfackler
Copy link
Member

it might choose to not do so tomorrow.

This is the compiler. We know exactly how it behaves, and if it stops behaving that way, we'll deal with this at that time. There are literally thousands of functions that we expect to be inlined without an explicit #[inline].

@oconnor663
Copy link
Contributor Author

I'll close this PR on that basis. I'm curious to know more, though: Is inlining something that's determined only by looking at the inlined function itself? Like if the compiler inlines foo in one case, should I expect it to inline foo in all cases?

@hudson-ayers
Copy link
Contributor

FWIW, I have run into several places where copy_within is not inlined when using opt-level=s. I suspect this may be related to the addition of #[track_caller] to the method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants