Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

make copy_within #[inline] - #56886

Closed
oconnor663 wants to merge 1 commit into
rust-lang:masterfrom
oconnor663:copy_within_inline
Closed

oconnor663 wants to merge 1 commit into
rust-lang:masterfrom
oconnor663:copy_within_inline

Conversation

@oconnor663

Copy link
Copy Markdown
Contributor

@briansmith suggested this in
#54236 (comment).

@rust-highfive

Copy link
Copy Markdown
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 done
@sfackler

Copy link
Copy Markdown
Member

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

@oconnor663

Copy link
Copy Markdown
Contributor Author

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

@briansmith

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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