-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
A few cleanups for rustc_data_structures #53223
Conversation
r? @oli-obk |
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.
just some nits, lgtm otherwise
// | ||
// WARNING: Mapping a `&IdxSetBuf<T>` to `&IdxSet<T>` (at least today) | ||
// requires a transmute relying on representation guarantees that may | ||
// not hold in the future. |
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.
Can we make the IdxSet
#[transparent]
to actually solve this issue?
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'm not familiar with this attribute; is it sufficient that I additionally apply it to IdxSet
?
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.
yes, just apply it to IdxSet
and we should be good.
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'm getting an error that The attribute transparent is currently unknown to the compiler
during check
; is it already available?
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.
sorry, it's #[repr(transparent)]
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.
Ah, that one I do know 👍.
src/librustc_data_structures/sync.rs
Outdated
pub fn into_inner(value: Self) -> T { | ||
value.check(); | ||
value.inner | ||
pub fn into_inner(self) -> T { |
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.
That's not quite the same thing. Now you can call this via value.into_inner()
. I'm presuming the original author wanted it to be called as T::into_inner(value)
.
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 didn't get any errors when running stage 1 tests, so it might not even be used. I can change it back, of course.
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.
T::into_inner(value)
would still work after your change, but now value.into_inner()
would also work, which is something we try to avoid in certain situations.
Yea, please revert it.
return None; | ||
} | ||
|
||
r?; |
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.
remove the local variable r
entirely and add the question mark to the function call
be08838
to
db39943
Compare
@oli-obk Thanks, I addressed your remarks. |
@bors r+ rollup |
📌 Commit db399434ed27dfd9ccfdd5e29ef814623e1e0d6e has been approved by |
} | ||
|
||
unsafe fn from_slice_mut(s: &mut [Word]) -> &mut Self { | ||
mem::transmute(s) // (see above WARNING) | ||
&mut *(s as *mut [usize] as *mut Self) |
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.
This should probably be casting to *mut [Word]
instead.
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.
Good call; I'll update the applicable commit.
db39943
to
b0246e3
Compare
@bors r=oli-obk |
📌 Commit b0246e3f655aec44c1a253204b70f822cca6fa13 has been approved by |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@bors r- |
b0246e3
to
94c3856
Compare
Oof 😐; test fixed. |
It's already fixed, can I get an r? |
@bors r=oli-obk |
📌 Commit 94c3856 has been approved by |
🌲 The tree is currently closed for pull requests below priority 10, this pull request will be tested once the tree is reopened |
…li-obk A few cleanups for rustc_data_structures - remove a redundant `clone()` - make some calls to `.iter()` implicit - collapse/simplify a few operations - remove some explicit `return`s - make `SnapshotMap::{commit, rollback_to}` take references - remove unnecessary struct field names - change `transmute()`s in `IdxSet::{from_slice, from_slice_mut}` to casts - remove some unnecessary lifetime annotations - split 2 long literals
…li-obk A few cleanups for rustc_data_structures - remove a redundant `clone()` - make some calls to `.iter()` implicit - collapse/simplify a few operations - remove some explicit `return`s - make `SnapshotMap::{commit, rollback_to}` take references - remove unnecessary struct field names - change `transmute()`s in `IdxSet::{from_slice, from_slice_mut}` to casts - remove some unnecessary lifetime annotations - split 2 long literals
Rollup of 15 pull requests Successful merges: - #52955 (Update compiler test documentation) - #53019 (Don't collect() when size_hint is useless) - #53025 (Consider changing assert! to debug_assert! when it calls visit_with) - #53059 (Remove explicit returns where unnecessary) - #53165 ( Add aarch64-unknown-netbsd target) - #53210 (Deny future duplication of rustc-ap-syntax) - #53223 (A few cleanups for rustc_data_structures) - #53230 ([nll] enable feature(nll) on various crates for bootstrap: part 4) - #53231 (Add let keyword doc) - #53240 (Add individual documentation for <integer>`.swap_bytes`/.`reverse_bits`) - #53253 (Remove unwanted console log) - #53264 (Show that Command can be reused and remodified) - #53267 (Fix styles) - #53273 (Add links to std::char::REPLACEMENT_CHARACTER from docs.) - #53283 (wherein we suggest float for integer literals where a float was expected) Failed merges: r? @ghost
clone()
.iter()
implicitreturn
sSnapshotMap::{commit, rollback_to}
take referencestransmute()
s inIdxSet::{from_slice, from_slice_mut}
to casts