-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Get rid of some #![allow(static_mut_refs)]
#121303
Conversation
r? @ChrisDenton rustbot has assigned @ChrisDenton. Use r? to explicitly pick a reviewer |
The Miri subtree was changed cc @rust-lang/miri |
r=me on the compiler changes r? @RalfJung on the miri test changes. They lgtm, but maybe there are subtle interactions that should have been handled differently |
Miri changes LGTM, thanks! |
…obk,RalfJung Get rid of some `#![allow(static_mut_refs)]`
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
Some of the |
859c122
to
58c8c08
Compare
Hopefully this is fixed now. I have also rebased on top of master and squashed all the changes in one commit. Will probably look into the ways of setting up a win-msvc toolchain on linux, with some terrible wine hacking, because the experience I have just had with a Windows VM was not very pleasant. But at least more responsive than a CI failure. |
The stuff @saethlin did for mir-opt tests should let us do check-builds for MSVC targets on a Linux host, without any Windows tools around. |
@@ -220,7 +220,7 @@ extern "C" { | |||
// This is fine since the MSVC runtime uses string comparison on the type name | |||
// to match TypeDescriptors rather than pointer equality. | |||
static mut TYPE_DESCRIPTOR: _TypeDescriptor = _TypeDescriptor { | |||
pVFTable: unsafe { &TYPE_INFO_VTABLE } as *const _ as *const _, |
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.
Strange, did this one not trigger the warning? It doesn't seem to be inside any of the allow
.
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, it said something about external statics iirc
(If you mean why I left the unsafe block in place)
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.
Strange, did this one not trigger the warning? It doesn't seem to be inside any of the
allow
.
Ah, I guess this is because it is not a mut
static:
https://github.com/rust-lang/rust/pull/121303/files#diff-1308e363d41cbb1f3f93d560e000263610240cc456596918347038d303dac7b6L214
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 I see, you just made them all use addr_of for good measure. Makes sense!
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 I see, you just made them all use addr_of for good measure. Makes sense!
I think there are many more places where & ... as *const ...
is used. Would it make sense to implement a lint (probably allow-by-default) suggesting to replace those with addr_of!
? Or maybe at least for me to go through the libs and change those manually?
UPD: Apparently (and honestly unsurprisingly) there is already a clippy lint for that: borrow_as_ptr
.
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.
Yeah those should all be addr_of ideally.
@@ -337,9 +337,6 @@ pub mod panic_count { | |||
#[doc(hidden)] | |||
#[cfg(not(feature = "panic_immediate_abort"))] | |||
#[unstable(feature = "update_panic_count", issue = "none")] | |||
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint | |||
#[cfg_attr(bootstrap, allow(static_mut_ref))] | |||
#[cfg_attr(not(bootstrap), allow(static_mut_refs))] |
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.
Looks like no fix was needed for these. This does make me wonder why they were ever added... 🤷
@bors r=oli-obk,RalfJung rollup=iffy |
To be clear, |
Ah, great. :) We should add that to PR CI for some targets... currently e.g. macOS is only covered by the Miri tests I think. EDIT: filed an issue: #121519 |
☀️ Test successful - checks-actions |
Finished benchmarking commit (2dbd623): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 650.563s -> 650.231s (-0.05%) |
Use `addr_of!` As per rust-lang#121303 (comment)
Use `addr_of!` As per rust-lang#121303 (comment)
Rollup merge of rust-lang#121556 - GrigorenkoPV:addr_of, r=Nilstrieb Use `addr_of!` As per rust-lang#121303 (comment)
No description provided.