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

kmc-solid: std::sys code maintenance #105120

Merged
merged 4 commits into from
Dec 9, 2022

Conversation

kawadakk
Copy link
Contributor

@kawadakk kawadakk commented Dec 1, 2022

Includes a set of changes to fix the *-kmc-solid_* 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 (Tracking Issue for IsTerminal / is_terminal #98070)
  • Address unused_imports and unused_unsafe
  • Stop doing Box::from_raw(&*(x: Box<T>) as *const T as *mut T)

…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`.
@rustbot
Copy link
Collaborator

rustbot commented Dec 1, 2022

r? @thomcc

(rustbot has picked a reviewer for you, use r? to override)

@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 Dec 1, 2022
@rustbot
Copy link
Collaborator

rustbot commented Dec 1, 2022

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

Copy link
Member

@workingjubilee workingjubilee left a 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?

library/std/src/sys/itron/thread.rs Outdated Show resolved Hide resolved
Comment on lines +29 to +31
// Safety: `Thread` provides no methods that take `&self`.
unsafe impl Sync for Thread {}
Copy link
Member

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?

Copy link
Member

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.

Copy link
Member

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.

library/std/src/sys/itron/thread.rs Outdated Show resolved Hide resolved
This pattern seems to be considered illegal by Miri.
@thomcc
Copy link
Member

thomcc commented Dec 7, 2022

Sorry for the delay. This looks fine to me.

@bors r+

@bors
Copy link
Contributor

bors commented Dec 7, 2022

📌 Commit ae7633f has been approved by thomcc

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 Dec 7, 2022
@bors
Copy link
Contributor

bors commented Dec 8, 2022

⌛ Testing commit ae7633f with merge a1b3b216ea701185366880c7c45c75727bd8c630...

@bors
Copy link
Contributor

bors commented Dec 8, 2022

💔 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 Dec 8, 2022
@ehuss
Copy link
Contributor

ehuss commented Dec 8, 2022

@bors retry

Failed to update toolstate
(has been fixed)

@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 Dec 8, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 8, 2022
…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)`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 8, 2022
…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)`
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 9, 2022
…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
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-tools failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
 * branch            master     -> FETCH_HEAD
HEAD is now at 496fb40 (windows CI update)
[master 5284f17] (linux CI update)
 1 file changed, 1 insertion(+)
fatal: could not read Username for 'https://github.com': No such device or address
Sleeping for 3 seconds before retrying push
 * branch            master     -> FETCH_HEAD
HEAD is now at 496fb40 (windows CI update)
[master 5f5033b] (linux CI update)
 1 file changed, 1 insertion(+)
 1 file changed, 1 insertion(+)
fatal: could not read Username for 'https://github.com': No such device or address
Sleeping for 3 seconds before retrying push
 * branch            master     -> FETCH_HEAD
HEAD is now at 496fb40 (windows CI update)
[master e34230a] (linux CI update)
 1 file changed, 1 insertion(+)
 1 file changed, 1 insertion(+)
fatal: could not read Username for 'https://github.com': No such device or address
Sleeping for 3 seconds before retrying push
 * branch            master     -> FETCH_HEAD
HEAD is now at 496fb40 (windows CI update)
[master 87448e3] (linux CI update)
 1 file changed, 1 insertion(+)
 1 file changed, 1 insertion(+)
fatal: could not read Username for 'https://github.com': No such device or address
Sleeping for 3 seconds before retrying push
 * branch            master     -> FETCH_HEAD
 * branch            master     -> FETCH_HEAD
thread 'main' panicked at 'Failed to update toolstate repository with new data', toolstate.rs:436:9
HEAD is now at 496fb40 (windows CI update)
Build completed unsuccessfully in 0:00:19

@bors bors merged commit cd936cc into rust-lang:master Dec 9, 2022
@rustbot rustbot added this to the 1.67.0 milestone Dec 9, 2022
@kawadakk kawadakk deleted the patch/kmc-solid/maintainance branch December 9, 2022 06:25
Aaron1011 pushed a commit to Aaron1011/rust that referenced this pull request Jan 6, 2023
…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)`
Aaron1011 pushed a commit to Aaron1011/rust that referenced this pull request Jan 6, 2023
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

9 participants