about summary refs log tree commit diff
path: root/library/std
AgeCommit message (Collapse)AuthorLines
2022-04-07Auto merge of #95678 - pietroalbini:pa-1.62.0-bootstrap, r=Mark-Simulacrumbors-87/+80
Bump bootstrap compiler to 1.61.0 beta This PR bumps the bootstrap compiler to the 1.61.0 beta. The first commit changes the stage0 compiler, the second commit applies the "mechanical" changes and the third and fourth commits apply changes explained in the relevant comments. r? `@Mark-Simulacrum`
2022-04-07Auto merge of #95688 - pfmooney:libc-update, r=Mark-Simulacrumbors-17/+1
Update libc to 0.2.121 With the updated libc, UNIX stack overflow handling in libstd can now use the common `si_addr` accessor function, rather than attempting to use a field from that name in `siginfo_t`. This simplifies the collection of the fault address, particularly on platforms where that data resides within a union in `siginfo_t`.
2022-04-07Rollup merge of #95626 - saethlin:pass-pointer-to-prctl, r=cuviperDylan DPC-1/+7
Don't cast thread name to an integer for prctl `libc::prctl` and the `prctl` definitions in glibc, musl, and the kernel headers are C variadic functions. Therefore, all the arguments (except for the first) are untyped. It is only the Linux man page which says that `prctl` takes 4 `unsigned long` arguments. I have no idea why it says this. In any case, the upshot is that we don't need to cast the pointer to an integer and confuse Miri. But in light of this... what are we doing with those three `0`s? We're passing 3 `i32`s to `prctl`, which doesn't fill me with confidence. The man page says `unsigned long` and all the constants in the linux kernel are macros for expressions of the form `1UL << N`. I'm mostly commenting on this because looks a whole lot like some UB that was found in SQLite a few years ago: <https://youtu.be/LbzbHWdLAI0?t=1925> that was related to accidentally passing a 32-bit value from a literal `0` instead of a pointer-sized value. This happens to work on x86 due to the size of pointers and happens to work on x86_64 due to the calling convention. But also, there is no good reason for an implementation to be looking at those arguments. Some other calls to `prctl` require that other arguments be zeroed, but not `PR_SET_NAME`... so why are we even passing them? I would prefer to end such questions by either passing 3 `libc::c_ulong`, or not passing those at all, but I'm not sure which is better.
2022-04-07Rollup merge of #95185 - m-ou-se:stabilize-stdin-lines, r=Mark-SimulacrumDylan DPC-2/+1
Stabilize Stdin::lines. Closes https://github.com/rust-lang/rust/issues/87096 Fcp completed here: https://github.com/rust-lang/rust/issues/87096#issuecomment-1028792980
2022-04-06Change trailing prctl arguments to c_ulongBen Kimock-1/+7
2022-04-06Bump stabilization of stdin_forwarders to 1.62.0.Mara Bos-1/+1
2022-04-06Rename RWLock to RwLock in std::sys.Mara Bos-88/+88
2022-04-06Auto merge of #95469 - ChrisDenton:unsound-read-write, r=joshtriplettbors-78/+155
Fix unsound `File` methods This is a draft attempt to fix #81357. *EDIT*: this PR now tackles `read()`, `write()`, `read_at()`, `write_at()` and `read_buf`. Still needs more testing though. cc `@jstarks,` can you confirm the the Windows team is ok with the Rust stdlib using `NtReadFile` and `NtWriteFile`? ~Also, I'm provisionally using `CancelIo` in a last ditch attempt to recover but I'm not sure that this is actually a good idea. Especially as getting into this state would be a programmer error so aborting the process is justified in any case.~ *EDIT*: removed, see comments.
2022-04-05Auto merge of #95702 - Dylan-DPC:rollup-793rz6v, r=Dylan-DPCbors-13/+103
Rollup of 8 pull requests Successful merges: - #88025 (ScmCredentials netbsd implementation.) - #95473 (track individual proc-macro expansions in the self-profiler) - #95547 (caution against ptr-to-int transmutes) - #95585 (Explain why `&T` is cloned when `T` is not `Clone`) - #95591 (Use revisions to track NLL test output (part 1)) - #95663 (diagnostics: give a special note for unsafe fn / Fn/FnOnce/FnMut) - #95673 (:arrow_up: rust-analyzer) - #95681 (resolve: Fix resolution of empty paths passed from rustdoc) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-04-05trivial cfg(bootstrap) changesPietro Albini-87/+80
2022-04-05Rollup merge of #88025 - devnexen:netbsd_scm_creds, r=AmanieuDylan DPC-13/+103
ScmCredentials netbsd implementation.
2022-04-05Auto merge of #95035 - m-ou-se:futex-locks-on-linux, r=Amanieubors-41/+251
Replace Linux Mutex and Condvar with futex based ones. Tracking issue: https://github.com/rust-lang/rust/issues/93740
2022-04-05Update libc to 0.2.121Patrick Mooney-17/+1
With the updated libc, UNIX stack overflow handling in libstd can now use the common `si_addr` accessor function, rather than attempting to use a field from that name in `siginfo_t`. This simplifies the collection of the fault address, particularly on platforms where that data resides within a union in `siginfo_t`.
2022-04-05Reword comment in futex condvar implementation.Mara Bos-1/+1
2022-04-05Mark unix::locks::futex::Mutex::new as #[inline].Mara Bos-0/+1
2022-04-05Use rtabortChris Denton-2/+1
2022-04-05Make `synchronous_write` safe to callChris Denton-23/+18
2022-04-05Document synchronicityChris Denton-0/+6
2022-04-05Complete reads and writes synchronously or abortChris Denton-66/+137
2022-04-05Correct definition of `IO_STATUS_BLOCK`Chris Denton-5/+11
2022-04-04Rollup merge of #95467 - ChrisDenton:async-read-pipe, r=joshtriplettDylan DPC-2/+140
Windows: Synchronize asynchronous pipe reads and writes On Windows, the pipes used for spawned processes are opened for asynchronous access but `read` and `write` are done using the standard methods that assume synchronous access. This means that the buffer (and variables on the stack) may be read/written to after the function returns. This PR ensures reads/writes complete before returning. Note that this only applies to pipes we create and does not affect the standard file read/write methods. Fixes #95411
2022-04-04Rollup merge of #95431 - golddranks:stabilize_total_cmp, r=scottmcmDylan DPC-1/+0
Stabilize total_cmp Stabilises `total_cmp` for Rust 1.61.0. Tracking issue: https://github.com/rust-lang/rust/issues/72599
2022-04-04Rollup merge of #92942 - Xaeroxe:raw_arg, r=dtolnayDylan DPC-1/+1
stabilize windows_process_extensions_raw_arg Stabilizes the feature tracked at https://github.com/rust-lang/rust/issues/92939
2022-04-04Correct calling conventionChris Denton-2/+2
2022-04-04Bump windows CommandExt::raw_arg to 1.62David Tolnay-1/+1
2022-04-04Stabilize total_cmpPyry Kontio-1/+0
2022-04-04Update library/std/src/sys/windows/pipe.rsChris Denton-4/+6
2022-04-04ScmCredentials netbsd implementation.David Carlier-13/+103
2022-04-03Don't cast thread name to an integer for prctlBen Kimock-1/+1
libc::prctl and the prctl definitions in glibc, musl, and the kernel headers are C variadic functions. Therefore, all the arguments (except for the first) are untyped. It is only the Linux man page which says that prctl takes 4 unsigned long arguments. I have no idea why it says this. In any case, the upshot is that we don't need to cast the pointer to an integer and confuse Miri.
2022-04-02Rollup merge of #95597 - dtolnay:threadlocalu8, r=Dylan-DPCDylan DPC-3/+3
Refer to u8 by absolute path in expansion of thread_local The standard library's `thread_local!` macro previously referred to `u8` just as `u8`, resolving to whatever `u8` existed in the type namespace at the call site. This PR replaces those with `$crate::primitive::u8` which always refers to `std::primitive::u8` regardless of what's in scope at the call site. Unambiguously naming primitives inside macro-generated code is the reason that std::primitive was introduced in the first place. <details> <summary>Here is the error message prior to this PR ⬇️</summary> ```console error[E0308]: mismatched types --> src/main.rs:6:1 | 6 | / std::thread_local! { 7 | | pub static A: i32 = f(); 8 | | pub static B: i32 = const { 0 }; 9 | | } | |_^ expected struct `u8`, found integer | = note: this error originates in the macro `$crate::__thread_local_inner` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types --> src/main.rs:6:1 | 6 | / std::thread_local! { 7 | | pub static A: i32 = f(); 8 | | pub static B: i32 = const { 0 }; 9 | | } | | ^ | | | | |_expected struct `u8`, found integer | this expression has type `u8` | = note: this error originates in the macro `$crate::__thread_local_inner` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types --> src/main.rs:6:1 | 6 | / std::thread_local! { 7 | | pub static A: i32 = f(); 8 | | pub static B: i32 = const { 0 }; 9 | | } | |_^ expected `u8`, found struct `u8` | = note: expected raw pointer `*mut u8` (`u8`) found raw pointer `*mut u8` (struct `u8`) = note: this error originates in the macro `$crate::__thread_local_inner` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types --> src/main.rs:6:1 | 6 | / std::thread_local! { 7 | | pub static A: i32 = f(); 8 | | pub static B: i32 = const { 0 }; 9 | | } | |_^ expected `u8`, found struct `u8` | = note: expected fn pointer `unsafe extern "C" fn(*mut u8)` found fn item `unsafe extern "C" fn(*mut u8) {destroy}` = note: this error originates in the macro `$crate::__thread_local_inner` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0308]: mismatched types --> src/main.rs:6:1 | 6 | / std::thread_local! { 7 | | pub static A: i32 = f(); 8 | | pub static B: i32 = const { 0 }; 9 | | } | | ^ | | | | |_expected struct `u8`, found integer | expected due to this type | = note: this error originates in the macro `$crate::__thread_local_inner` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0369]: binary operation `==` cannot be applied to type `u8` --> src/main.rs:6:1 | 6 | / std::thread_local! { 7 | | pub static A: i32 = f(); 8 | | pub static B: i32 = const { 0 }; 9 | | } | | ^ | | | | |_u8 | {integer} | note: an implementation of `PartialEq<_>` might be missing for `u8` --> src/main.rs:4:1 | 4 | struct u8; | ^^^^^^^^^^ must implement `PartialEq<_>` = note: this error originates in the macro `$crate::assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `u8` with `#[derive(PartialEq)]` | 4 | #[derive(PartialEq)] | error[E0277]: `u8` doesn't implement `Debug` --> src/main.rs:6:1 | 6 | / std::thread_local! { 7 | | pub static A: i32 = f(); 8 | | pub static B: i32 = const { 0 }; 9 | | } | |_^ `u8` cannot be formatted using `{:?}` | = help: the trait `Debug` is not implemented for `u8` = note: add `#[derive(Debug)]` to `u8` or manually `impl Debug for u8` = note: this error originates in the macro `$crate::assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) ``` </details>
2022-04-02Rollup merge of #95587 - m-ou-se:std-remove-associated-type-bounds, r=Dylan-DPCDylan DPC-3/+4
Remove need for associated_type_bounds in std.
2022-04-02Refer to u8 by absolute path in expansion of thread_localDavid Tolnay-3/+3
2022-04-02Create 2024 editionJacob Pratt-0/+15
2022-04-02Rollup merge of #95557 - niluxv:issue-95533, r=dtolnayDylan DPC-8/+8
Fix `thread_local!` macro to be compatible with `no_implicit_prelude` Fixes issue #95533.
2022-04-02Rollup merge of #95354 - dtolnay:rustc_const_stable, r=lcnrDylan DPC-23/+23
Handle rustc_const_stable attribute in library feature collector The library feature collector in [compiler/rustc_passes/src/lib_features.rs](https://github.com/rust-lang/rust/blob/551b4fa395fa588d91cbecfb0cdfe1baa02670cf/compiler/rustc_passes/src/lib_features.rs) has only been looking at `#[stable(…)]`, `#[unstable(…)]`, and `#[rustc_const_unstable(…)]` attributes, while ignoring `#[rustc_const_stable(…)]`. The consequences of this were: - When any const feature got stabilized (changing one or more `rustc_const_unstable` to `rustc_const_stable`), users who had previously enabled that unstable feature using `#![feature(…)]` would get told "unknown feature", rather than rustc's nicer "the feature … has been stable since … and no longer requires an attribute to enable". This can be seen in the way that https://github.com/rust-lang/rust/pull/93957#issuecomment-1079794660 failed after rebase: ```console error[E0635]: unknown feature `const_ptr_offset` --> $DIR/offset_from_ub.rs:1:35 | LL | #![feature(const_ptr_offset_from, const_ptr_offset)] | ^^^^^^^^^^^^^^^^ ``` - We weren't enforcing that a particular feature is either stable everywhere or unstable everywhere, and that a feature that has been stabilized has the same stabilization version everywhere, both of which we enforce for the other stability attributes. This PR updates the library feature collector to handle `rustc_const_stable`, and fixes places in the standard library and test suite where `rustc_const_stable` was being used in a way that does not meet the rules for a stability attribute.
2022-04-01Use MaybeUninit for clock_gettime's timespec.Mara Bos-3/+4
2022-04-01Don't spin on contended mutexes.Mara Bos-1/+3
2022-04-01Shuffle around #[inline] and #[cold] in mutex impl.Mara Bos-5/+7
2022-04-01Add comment about futex_wait timeout.Mara Bos-0/+2
2022-04-01Fix `thread_local!` macro to be compatible with `no_implicit_prelude`niluxv-8/+8
Fixes issue #95533
2022-04-01Remove need for associated_type_bounds in std.Mara Bos-3/+4
2022-04-01Rollup merge of #95032 - m-ou-se:std-features, r=yaahcMatthias Krüger-63/+74
Clean up, categorize and sort unstable features in std.
2022-03-31Adjust feature names that disagree on const stabilization versionDavid Tolnay-23/+23
2022-03-31Categorize and sort unstable features in std.Mara Bos-63/+74
2022-03-31Rollup merge of #95505 - sunfishcode:sunfishcode/fix-openbsd, r=dtolnayDylan DPC-1/+1
Fix library/std compilation on openbsd. Fix a minor typo from #95241 which prevented compilation on x86_64-unknown-openbsd.
2022-03-31match std f32 primitive docs to core f32 primitive docsPyry Kontio-2/+3
2022-03-31Rollup merge of #95130 - workingjubilee:stably-finished, r=m-ou-seDylan DPC-2/+1
Stabilize thread::is_finished Closes #90470. r? `@m-ou-se`
2022-03-30Remove antipattern from process::exit docsNoa-28/+13
2022-03-30Add ExitCode::exit_process()Noa-0/+20
2022-03-31Improve wording of "NaN as a special value" top level explanationPyry Kontio-4/+5