Skip to content

Add missing inline attribute to Not impl for Wrapping<T> #25159

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

Merged
merged 1 commit into from
May 9, 2015

Conversation

inrustwetrust
Copy link
Contributor

This was causing function calls to be emitted for bitwise complements, even with optimizations on.
Steps to reproduce:

$ cat wrapping.rs
fn main() {
    let a = std::num::Wrapping(std::env::args().len() as u32);
    let b = !a;
    println!("{}", b.0);
}
$ rustc -O wrapping.rs --emit=asm,link
$ grep Not wrapping.s
        callq   _ZN3num8wrapping23Wrapping$LT$u32$GT$.Not3not20hba4b266232e02b1dHkbE

@rust-highfive
Copy link
Contributor

r? @alexcrichton

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

@alexcrichton
Copy link
Member

Could this be reduced down to just #[inline]? The reason it's not inlined today is that it's just not available across crates, and #[inline(always)] may be a bit too strong of a hint to LLVM in all cases.

@inrustwetrust
Copy link
Contributor Author

I have no problem with changing it, though I was just following the pattern of what was already there for the other traits (BitXor, BitOr, etc.). The missing #[inline(always)] on the Not trait seemed like it was just an accidental omission to me. Should I change all of the arithmetic-related traits fn:s to just #[inline]?

@alexcrichton
Copy link
Member

Ah sorry I hadn't noticed the surrounding pattern of all using inline(always), my mistake! In that case:

@alexcrichton
Copy link
Member

@bors: r+ 48636f3

bors added a commit that referenced this pull request May 9, 2015
This was causing function calls to be emitted for bitwise complements, even with optimizations on.
Steps to reproduce:
```
$ cat wrapping.rs
fn main() {
    let a = std::num::Wrapping(std::env::args().len() as u32);
    let b = !a;
    println!("{}", b.0);
}
$ rustc -O wrapping.rs --emit=asm,link
$ grep Not wrapping.s
        callq   _ZN3num8wrapping23Wrapping$LT$u32$GT$.Not3not20hba4b266232e02b1dHkbE
```
@bors
Copy link
Collaborator

bors commented May 9, 2015

⌛ Testing commit 48636f3 with merge 50aada7...

@bors
Copy link
Collaborator

bors commented May 9, 2015

@bors bors merged commit 48636f3 into rust-lang:master May 9, 2015
@inrustwetrust inrustwetrust deleted the wrapping_inline branch May 9, 2015 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants