-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Reduces Code Repetitions like !n >> amt
#59101
Changes from 2 commits
749e9d4
4c9f7a0
0ede9e6
18b40c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ use rustc::ty; | |
use rustc::ty::layout::{Integer, IntegerExt, Size}; | ||
use syntax::attr::{SignedInt, UnsignedInt}; | ||
use rustc::hir::RangeEnd; | ||
use rustc::mir::interpret::mask; | ||
|
||
use std::mem; | ||
|
||
|
@@ -115,14 +116,14 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { | |
ty::Int(ity) => { | ||
// FIXME(49937): refactor these bit manipulations into interpret. | ||
let size = Integer::from_attr(&tcx, SignedInt(ity)).size(); | ||
let max = !0u128 >> (128 - size.bits()); | ||
let max = mask(size); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this could be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for your review. Then, should I replace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, I think that's for the best, unless you see a lot of other sites in the compiler where using |
||
let bias = 1u128 << (size.bits() - 1); | ||
(Some((0, max, size)), bias) | ||
} | ||
ty::Uint(uty) => { | ||
// FIXME(49937): refactor these bit manipulations into interpret. | ||
let size = Integer::from_attr(&tcx, UnsignedInt(uty)).size(); | ||
let max = !0u128 >> (128 - size.bits()); | ||
let max = mask(size); | ||
(Some((0, max, size)), 0) | ||
} | ||
_ => (None, 0), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These
FIXME
s look resolved now.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for reporting. I forgot to remove this comment out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
let bias = 1u128 << (size.bits() - 1);
is not resolved.