Commit Graph

5707 Commits

Author SHA1 Message Date
Jubilee
48b2a517fc
Rollup merge of #123323 - devnexen:thread_set_name_solaris_fix, r=workingjubilee
std:🧵 set_name change for solaris/illumos.

truncate down to 32 (31 + 1) for solaris/illumos.
2024-04-01 17:22:10 -07:00
David Carlier
ca36fe310e
std:🧵 set_name change for solaris/illumos.
truncate down to 32 (31 + 1) for solaris/illumos.
2024-04-01 22:16:13 +01:00
bors
a7e3b1c8c5 Auto merge of #123315 - devnexen:thread_get_name_solaris, r=ChrisDenton
std:🧵 adding get_name implementation for solaris/illumos.

THREAD_NAME_MAX is 32 (31 max + 1 for the null terminator).
2024-04-01 16:38:55 +00:00
bors
c518e5aeec Auto merge of #123265 - joboet:guardians_of_the_unix, r=ChrisDenton
Refactor stack overflow handling

Currently, every platform must implement a `Guard` that protects a thread from stack overflow. However, UNIX is the only platform that actually does so. Windows has a different mechanism for detecting stack overflow, while the other platforms don't detect it at all. Also, the UNIX stack overflow handling is split between `sys::pal::unix::stack_overflow`, which implements the signal handler, and `sys::pal::unix::thread`, which detects/installs guard pages.

This PR cleans this by getting rid of `Guard` and unifying UNIX stack overflow handling inside `stack_overflow` (commit 1). Therefore we can get rid of `sys_common::thread_info`, which stores `Guard` and the current `Thread` handle and move the `thread::current` TLS variable into `thread` (commit 2).

The second commit is not strictly speaking necessary. To keep the implementation clean, I've included it here, but if it causes too much noise, I can split it out without any trouble.
2024-04-01 14:35:38 +00:00
joboet
d7b55e4c90
update comment 2024-04-01 15:28:27 +02:00
David Carlier
747d19326b
std:🧵 adding get_name implementation for solaris/illumos.
THREAD_NAME_MAX is 32 (31 max + 1 for the null terminator).
2024-04-01 10:01:21 +01:00
bors
8058136502 Auto merge of #123299 - workingjubilee:rollup-2z8amaj, r=workingjubilee
Rollup of 5 pull requests

Successful merges:

 - #123180 (Rewrite `core-no-fp-fmt-parse` test in Rust)
 - #123267 (std:🧵 adding get_name haiku implementation.)
 - #123268 (warn against implementing Freeze)
 - #123271 (doc: describe panic conditions for SliceIndex implementations)
 - #123295 (add myself to compiler review rotation)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-31 20:35:15 +00:00
David Carlier
e5c5ed00a5 std:🧵 adding get_name haiku implementation.
follow-up #123233
2024-03-31 17:47:44 +01:00
Ralf Jung
42972f52de catch_panic: warn about panicking payload drop 2024-03-31 11:54:16 +02:00
joboet
7668418101
std: move thread::current TLS variable out of thread_info 2024-03-31 11:28:24 +02:00
joboet
5b9d7ab558
std: move UNIX stack overflow guard page handling into stack_overflow.rs 2024-03-31 11:24:33 +02:00
David Carlier
c749483e26 std:🧵 adding freebsd/netbsd to the linux's get_name implementation. 2024-03-30 16:01:47 +00:00
Aria Beingessner
ea92faec49 stabilize ptr.is_aligned, move ptr.is_aligned_to to a new feature gate
This is an alternative to #121920
2024-03-29 19:59:46 -04:00
bors
760e567af5 Auto merge of #122975 - DianQK:simplify_ub_check, r=saethlin
Eliminate `UbChecks` for non-standard libraries

 The purpose of this PR is to allow other passes to treat `UbChecks` as constants in MIR for optimization after #122629.

r? RalfJung
2024-03-29 02:25:43 +00:00
Vagelis Prokopiou
cc4a1f42e6 Some wording improvement 2024-03-27 17:26:18 +02:00
DianQK
47ed73a7b5
Eliminate UbCheck for non-standard libraries 2024-03-27 21:02:40 +08:00
bors
10a7aa14fe Auto merge of #123128 - GuillaumeGomez:rollup-3l3zu6s, r=GuillaumeGomez
Rollup of 6 pull requests

Successful merges:

 - #121843 (Implement `-L KIND=`@RUSTC_BUILTIN/...`)`
 - #122860 (coverage: Re-enable `UnreachablePropagation` for coverage builds)
 - #123021 (Make `TyCtxt::coroutine_layout` take coroutine's kind parameter)
 - #123024 (CFI: Enable KCFI testing of run-pass tests)
 - #123083 (lib: fix some unnecessary_cast clippy lint)
 - #123116 (rustdoc: Swap fields and variant documentations)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-03-27 09:32:38 +00:00
Guillaume Gomez
64a9360d3f
Rollup merge of #123083 - klensy:clippy-me, r=workingjubilee
lib: fix some unnecessary_cast clippy lint

Fixes few instances of `unnecessary_cast` clippy lint
2024-03-27 10:13:44 +01:00
bors
0dcc1309d0 Auto merge of #116016 - jhpratt:kill-rustc-serialize, r=ehuss
Soft-destabilize `RustcEncodable` & `RustcDecodable`, remove from prelude in next edition

cc rust-lang/libs-team#272

Any use of `RustcEncodable` and `RustcDecodable` now triggers a deny-by-default lint. The derives have been removed from the 2024 prelude. I specifically chose **not** to document this in the module-level documentation, as the presence in existing preludes is not documented (which I presume is intentional).

This does not implement the proposed change for `rustfix`, which I will be looking into shortly.

With regard to the items in the preludes being stable, this should not be an issue because #15702 has been resolved.

r? libs-api
2024-03-27 07:30:36 +00:00
Matthias Krüger
bce525323d
Rollup merge of #123118 - tgross35:rwlock-docs, r=workingjubilee
Update `RwLock` deadlock example to not use shadowing

Tweak variable names in the deadlock example to remove any potential confusion that the behavior is somehow shadowing-related.
2024-03-27 05:21:18 +01:00
Matthias Krüger
910e23bbbb
Rollup merge of #123084 - a1phyr:unixstream_read_buf, r=workingjubilee
`UnixStream`: override `read_buf`

Split from #122441

r? ``@workingjubilee``
2024-03-27 05:21:17 +01:00
Matthias Krüger
d589021b4b
Rollup merge of #123038 - he32:netbsd-ilp32-fix, r=workingjubilee
std library thread.rs: fix NetBSD code for ILP32 CPUs.
2024-03-27 05:21:16 +01:00
Matthias Krüger
4bdf1711c6
Rollup merge of #122880 - a1phyr:preadv_more_platform, r=workingjubilee
Unix: Support more platforms with `preadv` and `pwritev`

- `aix`, `dragonfly` and `openbsd` with direct call
- `watchos` with weak linkage

cc #89517
2024-03-27 05:21:15 +01:00
Trevor Gross
0cd57725f9 Update RwLock deadlock example to not use shadowing
Tweak variable names in the deadlock example to remove any potential
confusion that the behavior is somehow shadowing-related.
2024-03-26 21:40:31 -04:00
Matthias Krüger
ac5ffa51cd
Rollup merge of #123057 - sthibaul:systemtime, r=jhpratt
unix fs: Make hurd using explicit new rather than From

408c0ea216 ("unix time module now return result") dropped the From impl for SystemTime, breaking the hurd build (and probably the horizon build)

Fixes #123032
2024-03-26 21:23:50 +01:00
Samuel Thibault
7b4e507961 unix fs: Make hurd and horizon using explicit new rather than From
408c0ea216 ("unix time module now return result") dropped the From
impl for SystemTime, breaking the hurd and horizon builds.

Fixes #123032
2024-03-26 15:58:00 +01:00
Benoît du Garreau
ff6d9f79ae Unix: Support more platforms with preadv and pwritev 2024-03-26 10:39:14 +01:00
Benoît du Garreau
bff13e98ad UnixStream: override read_buf 2024-03-26 10:11:29 +01:00
ding-young
a241ffc6b6 Fix link to BufWriter 2024-03-26 18:04:19 +09:00
Havard Eidnes
1ad3954668 std library unix/thread.rs: fix NetBSD code for ILP32 CPUs. 2024-03-26 08:39:42 +00:00
klensy
8560d01a96 lib: fix some unnecessary_cast clippy lint
warning: casting raw pointers to the same type and constness is unnecessary (`*mut V` -> `*mut V`)
   --> library\alloc\src\collections\btree\map\entry.rs:357:31
    |
357 |                 let val_ptr = root.borrow_mut().push(self.key, value) as *mut V;
    |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `root.borrow_mut().push
(self.key, value)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast

warning: casting to the same type is unnecessary (`usize` -> `usize`)
   --> library\alloc\src\ffi\c_str.rs:411:56
    |
411 |             let slice = slice::from_raw_parts_mut(ptr, len as usize);
    |                                                        ^^^^^^^^^^^^ help: try: `len`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast

warning: casting raw pointers to the same type and constness is unnecessary (`*mut T` -> `*mut T`)
   --> library\alloc\src\slice.rs:516:25
    |
516 |                         (buf.as_mut_ptr() as *mut T).add(buf.len()),
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `buf.as_mut_ptr()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast

warning: casting raw pointers to the same type and constness is unnecessary (`*mut T` -> `*mut T`)
   --> library\alloc\src\slice.rs:537:21
    |
537 |                     (buf.as_mut_ptr() as *mut T).add(buf.len()),
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `buf.as_mut_ptr()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast

warning: casting raw pointers to the same type and constness is unnecessary (`*const ()` -> `*const ()`)
   --> library\alloc\src\task.rs:151:13
    |
151 |             waker as *const (),
    |             ^^^^^^^^^^^^^^^^^^ help: try: `waker`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast

warning: casting raw pointers to the same type and constness is unnecessary (`*const ()` -> `*const ()`)
   --> library\alloc\src\task.rs:323:13
    |
323 |             waker as *const (),
    |             ^^^^^^^^^^^^^^^^^^ help: try: `waker`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast

warning: casting to the same type is unnecessary (`usize` -> `usize`)
   --> library\std\src\sys_common\net.rs:110:21
    |
110 |             assert!(len as usize >= mem::size_of::<c::sockaddr_in>());
    |                     ^^^^^^^^^^^^ help: try: `len`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast

warning: casting to the same type is unnecessary (`usize` -> `usize`)
   --> library\std\src\sys_common\net.rs:116:21
    |
116 |             assert!(len as usize >= mem::size_of::<c::sockaddr_in6>());
    |                     ^^^^^^^^^^^^ help: try: `len`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
2024-03-25 23:19:40 +03:00
Matthias Krüger
cdf86bf443
Rollup merge of #122992 - devnexen:available_parallelism_sol_upd, r=Amanieu
std:🧵 refine available_parallelism for solaris/illumos.

Rather than the system-wide available cpus fallback solution, we fetch the cpus bound to the current process.
2024-03-24 17:08:19 +01:00
Matthias Krüger
f67fb08605
Rollup merge of #122984 - RalfJung:panic-in-hook, r=Amanieu
panic-in-panic-hook: formatting a message that's just a string is risk-free

This slightly improves the output in the 'panic while processing panic' case if the panic message does not involve any formatting. Follow-up to https://github.com/rust-lang/rust/pull/122930.

r? ``@Amanieu``
2024-03-24 17:08:19 +01:00
Matthias Krüger
a5852ef941
Rollup merge of #122983 - taiki-e:bsd, r=workingjubilee
Fix build failure on ARM/AArch64/PowerPC/RISC-V FreeBSD/NetBSD

Fixes https://github.com/rust-lang/rust/pull/121881#discussion_r1536764650

Checked targets: aarch64-unknown-freebsd, powerpc64-unknown-freebsd, armv7-unknown-freebsd, riscv64gc-unknown-freebsd, aarch64-unknown-netbsd.

r? ``@Amanieu``
cc ``@devnexen``
2024-03-24 17:08:18 +01:00
David Carlier
1871ea5710 fix build. 2024-03-24 16:02:02 +00:00
David Carlier
4b84df9ea3 std:🧵 refine available_parallelism for solaris/illumos.
Rather than the system-wide available cpus fallback solution, we fetch
the cpus bound to the current process.
2024-03-24 10:57:17 +00:00
Ralf Jung
0727b6ad0d panic-in-panic-hook: formatting a message that's just a string is risk-free 2024-03-24 10:29:44 +01:00
Taiki Endo
7aa76a7ac3 Fix build failure on ARM/AArch64/PowerPC/RISC-V FreeBSD/NetBSD 2024-03-24 17:26:48 +09:00
Jubilee
343c916332
Rollup merge of #120419 - Ayush1325:uefi-sys-os, r=nicholasbishop,workingjubilee
Expand sys/os for UEFI

- Implement current_exe() and getcwd()
2024-03-23 22:59:40 -07:00
Matthias Krüger
691d5f533d
Rollup merge of #122930 - RalfJung:panic-in-panic-fmt, r=Amanieu
add panic location to 'panicked while processing panic'

Fixes https://github.com/rust-lang/rust/issues/97181

r? `@Amanieu`
2024-03-23 15:00:20 +01:00
Matthias Krüger
eee0cd11a4
Rollup merge of #122916 - MultisampledNight:docs-sync-typo, r=jhpratt
docs(sync): normalize dot in fn summaries

All other functions in e.g. [`Mutex`](https://doc.rust-lang.org/std/sync/struct.Mutex.html) have a dot at the end of their first doc line, except for the newly stabilized [`Mutex::clear_poison`](https://doc.rust-lang.org/std/sync/struct.Mutex.html#method.clear_poison) (and its friend [`RwLock::clear_poison`](https://doc.rust-lang.org/std/sync/struct.RwLock.html#method.clear_poison)).

This PR remedies that by adding a normalizing dot.
2024-03-23 15:00:19 +01:00
Ralf Jung
fc257fae3c add panic location to 'panicked while processing panic' 2024-03-23 09:44:04 +01:00
bors
c308726599 Auto merge of #119552 - krtab:dead_code_priv_mod_pub_field, r=cjgillot,saethlin
Replace visibility test with reachability test in dead code detection

Fixes https://github.com/rust-lang/rust/issues/119545

Also included is a fix for an error now flagged by the lint
2024-03-23 00:37:05 +00:00
MultisampledNight
e853b50a72
docs(sync): normalize dot in fn summaries 2024-03-22 23:04:20 +01:00
Jacob Pratt
fbf21c5763
Remove RustcEncodable/Decodable from 2024 prelude 2024-03-22 13:30:48 -07:00
Jacob Pratt
2624e9183d
Soft-destabilize RustcEncodable/RustcDecodable 2024-03-22 13:24:35 -07:00
Matthias Krüger
f0feebb270
Rollup merge of #121881 - devnexen:bsd_acceptfilter, r=Amanieu
std::net: adding acceptfilter feature for netbsd/freebsd.

similar to linux's ext deferaccept, to filter incoming connections before accept.
2024-03-22 01:07:30 +01:00
Michael Goulet
2d633317f3 Implement macro-based deref!() syntax for deref patterns
Stop using `box PAT` syntax for deref patterns, as it's misleading and
also causes their semantics being tangled up.
2024-03-21 11:42:49 -04:00
Jacob Pratt
43ad753adb
Rollup merge of #122729 - m-ou-se:relax, r=Amanieu
Relax SeqCst ordering in standard library.

Every single SeqCst in the standard library is unnecessary. In all cases, Relaxed or Release+Acquire was sufficient.

As I [wrote](https://marabos.nl/atomics/memory-ordering.html#common-misconceptions) in my book on atomics:

> [..] when reading code, SeqCst basically tells the reader: "this operation depends on the total order of every single SeqCst operation in the program," which is an incredibly far-reaching claim. The same code would likely be easier to review and verify if it used weaker memory ordering instead, if possible. For example, Release effectively tells the reader: "this relates to an acquire operation on the same variable," which involves far fewer considerations when forming an understanding of the code.
>
> It is advisable to see SeqCst as a warning sign. Seeing it in the wild often means that either something complicated is going on, or simply that the author did not take the time to analyze their memory ordering related assumptions, both of which are reasons for extra scrutiny.

r? ````@Amanieu```` ````@joboet````
2024-03-20 20:29:44 -04:00
David Carlier
19cb05fd78 std::net: adding acceptfilter feature for netbsd/freebsd.
similar to linux's ext deferaccept, to filter incoming connections
before accept.
2024-03-20 18:15:31 +00:00