-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
kmc-solid: std::sys
code maintenance
#105120
Conversation
…ger casts Pointer-integer casts are required for conversion between `EXINF` (ITRON task entry point parameter) and `*const ThreadInner`. Addresses the deny-level lint `fuzzy_provenance_casts`.
Copied from `unsupported/io.rs`. Fixes build failure.
Addresses the warn-by-default lints `unused_imports` and `unused_unsafe`.
r? @thomcc (rustbot has picked a reviewer for you, use r? to override) |
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
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 have some small questions, as I would like to understand the various implementations of std::sys
code better, if you don't mind?
// Safety: `Thread` provides no methods that take `&self`. | ||
unsafe impl Sync for Thread {} |
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.
It's not intuitive to me that implementing a function or not that takes &self
affects safety for this case, as borrowing is a primitive notion in Rust, so anyone can hypothetically take &Thread
from a given Thread
and run off with it? Could you explain that one?
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 is the same reasoning as the one for Exclusive
: since you cannot do anything with the reference, the struct can be Sync
without causing any UB.
I'm not sure this is the best reasoning here, but it is correct.
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.
Oh I see, so it's actually talking about Thread
as a "smart pointer" (wrapper around the pointer). It interposes and blocks access to the pointer inside, and then never allows you to touch that inner pointer using a method that would take &Thread
. Thus it's correct to unsafe impl Sync for Thread
, since the behavior of the type can only be accessed via &mut Thread
or Thread
.
Yeah for some reason that didn't actually register immediately when I read it.
This pattern seems to be considered illegal by Miri.
f7e0d3d
to
ae7633f
Compare
Sorry for the delay. This looks fine to me. @bors r+ |
⌛ Testing commit ae7633f with merge a1b3b216ea701185366880c7c45c75727bd8c630... |
💔 Test failed - checks-actions |
@bors retry Failed to update toolstate |
…nce, r=thomcc kmc-solid: `std::sys` code maintenance Includes a set of changes to fix the [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets and make some other improvements. - Address `fuzzy_provenance_casts` by using `expose_addr` and `from_exposed_addr` for pointer-integer casts - Add a stub implementation of `is_terminal` (rust-lang#98070) - Address `unused_imports` and `unused_unsafe` - Stop doing `Box::from_raw(&*(x: Box<T>) as *const T as *mut T)`
…nce, r=thomcc kmc-solid: `std::sys` code maintenance Includes a set of changes to fix the [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets and make some other improvements. - Address `fuzzy_provenance_casts` by using `expose_addr` and `from_exposed_addr` for pointer-integer casts - Add a stub implementation of `is_terminal` (rust-lang#98070) - Address `unused_imports` and `unused_unsafe` - Stop doing `Box::from_raw(&*(x: Box<T>) as *const T as *mut T)`
…iaskrgr Rollup of 10 pull requests Successful merges: - rust-lang#104922 (Detect long types in E0308 and write them to disk) - rust-lang#105120 (kmc-solid: `std::sys` code maintenance) - rust-lang#105255 (Make nested RPIT inherit the parent opaque's generics.) - rust-lang#105317 (make retagging work even with 'unstable' places) - rust-lang#105405 (Stop passing -export-dynamic to wasm-ld.) - rust-lang#105408 (Add help for `#![feature(impl_trait_in_fn_trait_return)]`) - rust-lang#105423 (Use `Symbol` for the crate name instead of `String`/`str`) - rust-lang#105433 (CI: add missing line continuation marker) - rust-lang#105434 (Fix warning when libcore is compiled with no_fp_fmt_parse) - rust-lang#105441 (Remove `UnsafetyState`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
The job Click to see the possible cause of the failure (guessed by this bot)
|
…nce, r=thomcc kmc-solid: `std::sys` code maintenance Includes a set of changes to fix the [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets and make some other improvements. - Address `fuzzy_provenance_casts` by using `expose_addr` and `from_exposed_addr` for pointer-integer casts - Add a stub implementation of `is_terminal` (rust-lang#98070) - Address `unused_imports` and `unused_unsafe` - Stop doing `Box::from_raw(&*(x: Box<T>) as *const T as *mut T)`
…iaskrgr Rollup of 10 pull requests Successful merges: - rust-lang#104922 (Detect long types in E0308 and write them to disk) - rust-lang#105120 (kmc-solid: `std::sys` code maintenance) - rust-lang#105255 (Make nested RPIT inherit the parent opaque's generics.) - rust-lang#105317 (make retagging work even with 'unstable' places) - rust-lang#105405 (Stop passing -export-dynamic to wasm-ld.) - rust-lang#105408 (Add help for `#![feature(impl_trait_in_fn_trait_return)]`) - rust-lang#105423 (Use `Symbol` for the crate name instead of `String`/`str`) - rust-lang#105433 (CI: add missing line continuation marker) - rust-lang#105434 (Fix warning when libcore is compiled with no_fp_fmt_parse) - rust-lang#105441 (Remove `UnsafetyState`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Includes a set of changes to fix the
*-kmc-solid_*
Tier 3 targets and make some other improvements.fuzzy_provenance_casts
by usingexpose_addr
andfrom_exposed_addr
for pointer-integer castsis_terminal
(Tracking Issue for IsTerminal / is_terminal #98070)unused_imports
andunused_unsafe
Box::from_raw(&*(x: Box<T>) as *const T as *mut T)