Skip to content

Make overflowing and wrapping negation const #58044

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 6 commits into from
Feb 20, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
const-int-wrapping.rs += wrapping_neg
  • Loading branch information
Lokathor committed Feb 2, 2019
commit 31bf7e1b51ebb932036dd632396cd98c1e115a6b
7 changes: 5 additions & 2 deletions src/test/run-pass/const-int-wrapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const SHL_B: u32 = 1u32.wrapping_shl(128);
const SHR_A: u32 = 128u32.wrapping_shr(7);
const SHR_B: u32 = 128u32.wrapping_shr(128);

const NEG_A: u32 = 5u32.wrapping_neg();
const NEG_B: u32 = 1234567890u32.wrapping_neg();

fn ident<T>(ident: T) -> T {
ident
}
Expand All @@ -30,6 +33,6 @@ fn main() {
assert_eq!(SHL_A, ident(128));
assert_eq!(SHL_B, ident(1));

assert_eq!(SHR_A, ident(1));
assert_eq!(SHR_B, ident(128));
assert_eq!(SHR_A, ident(4294967291));
assert_eq!(SHR_B, ident(3060399406));
}