Skip to content
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

Merged
merged 1 commit into from
Feb 23, 2024

Conversation

GrigorenkoPV
Copy link
Contributor

No description provided.

@rustbot
Copy link
Collaborator

rustbot commented Feb 19, 2024

r? @ChrisDenton

rustbot has assigned @ChrisDenton.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 19, 2024
@rustbot
Copy link
Collaborator

rustbot commented Feb 19, 2024

The Miri subtree was changed

cc @rust-lang/miri

@oli-obk
Copy link
Contributor

oli-obk commented Feb 19, 2024

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

@rustbot rustbot assigned RalfJung and unassigned ChrisDenton Feb 19, 2024
@RalfJung
Copy link
Member

Miri changes LGTM, thanks!
@bors r=oli-obk,RalfJung

@bors
Copy link
Contributor

bors commented Feb 22, 2024

📌 Commit 859c122 has been approved by oli-obk,RalfJung

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 22, 2024
@bors
Copy link
Contributor

bors commented Feb 23, 2024

⌛ Testing commit 859c122 with merge daa4264...

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 23, 2024
…obk,RalfJung

Get rid of some `#![allow(static_mut_refs)]`
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Feb 23, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 23, 2024
@RalfJung
Copy link
Member

RalfJung commented Feb 23, 2024

Some of the allow that you removed do seem to be necessary on Windows builds.

@GrigorenkoPV
Copy link
Contributor Author

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.

@RalfJung
Copy link
Member

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 _,
Copy link
Member

@RalfJung RalfJung Feb 23, 2024

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.

Copy link
Contributor Author

@GrigorenkoPV GrigorenkoPV Feb 23, 2024

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)

Copy link
Contributor Author

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

Copy link
Member

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!

Copy link
Contributor Author

@GrigorenkoPV GrigorenkoPV Feb 23, 2024

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.

Copy link
Member

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))]
Copy link
Member

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... 🤷

@RalfJung
Copy link
Member

@bors r=oli-obk,RalfJung rollup=iffy

@bors
Copy link
Contributor

bors commented Feb 23, 2024

📌 Commit 58c8c08 has been approved by oli-obk,RalfJung

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 23, 2024
@saethlin
Copy link
Member

saethlin commented Feb 23, 2024

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.

To be clear, x check library --target=aarch64-pc-windows-msvc just works. You should be able to set various targets for x check without worrying about what host you're on, though this is of course not tested in all the various ways that bootstrap can be used. (actually doing cross-builds still doesn't work, which is what I often end up needing 🙃 )

@RalfJung
Copy link
Member

RalfJung commented Feb 23, 2024

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

@bors
Copy link
Contributor

bors commented Feb 23, 2024

⌛ Testing commit 58c8c08 with merge 2dbd623...

@bors
Copy link
Contributor

bors commented Feb 23, 2024

☀️ Test successful - checks-actions
Approved by: oli-obk,RalfJung
Pushing 2dbd623 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 23, 2024
@bors bors merged commit 2dbd623 into rust-lang:master Feb 23, 2024
12 checks passed
@rustbot rustbot added this to the 1.78.0 milestone Feb 23, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (2dbd623): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This 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.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.4% [-3.4%, -3.4%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -3.4% [-3.4%, -3.4%] 1

Cycles

Results

This 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.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
5.3% [5.2%, 5.5%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 650.563s -> 650.231s (-0.05%)
Artifact size: 310.99 MiB -> 310.96 MiB (-0.01%)

@GrigorenkoPV GrigorenkoPV deleted the static_mut_refs branch February 23, 2024 23:58
@GrigorenkoPV GrigorenkoPV mentioned this pull request Feb 24, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 24, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 24, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 25, 2024
Rollup merge of rust-lang#121556 - GrigorenkoPV:addr_of, r=Nilstrieb

Use `addr_of!`

As per rust-lang#121303 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants