about summary refs log tree commit diff
path: root/library/std
AgeCommit message (Collapse)AuthorLines
2022-03-09fix return values in L4Re networking stubSebastian Humenda-4/+4
[Benjamin Lamowski: Reworded commit message after split commit.]
2022-03-09Add soundness test for dropping scoped thread results before joining.Mara Bos-1/+24
2022-03-09Remove outdated comment.Mara Bos-2/+0
2022-03-09Properly abort when thread result panics on drop.Mara Bos-24/+26
2022-03-09Fix soundness issue in scoped threads.Mara Bos-0/+17
2022-03-09Rollup merge of #94756 - ChrisDenton:unreachable, r=yaahcDylan DPC-1/+7
Use `unreachable!` for an unreachable code path Closes #73212
2022-03-09Auto merge of #94750 - cuviper:dirent64_min, r=joshtriplettbors-10/+47
unix: reduce the size of DirEntry On platforms where we call `readdir` instead of `readdir_r`, we store the name as an allocated `CString` for variable length. There's no point carrying around a full `dirent64` with its fixed-length `d_name` too.
2022-03-08docsRalf Jung-3/+4
2022-03-09Use `unreachable!` for an unreachable code pathChris Denton-1/+7
2022-03-08Rollup merge of #94730 - msabansal:sabansal/b-atomic-mut-ptr, r=Dylan-DPCDylan DPC-0/+1
Reverted atomic_mut_ptr feature removal causing compilation break Fixes a regression introduced as part of https://github.com/rust-lang/rust/pull/94546 Std no longer compiles on nightly while using the following commnd: export RUSTFLAGS='-C target-feature=+atomics,+bulk-memory' cargo build --target wasm32-unknown-unknown -Z build-std=panic_abort,std I can help add tests to avoid future breaks but i couldn't understand the test framework
2022-03-08Rollup merge of #94724 - cuviper:rmdirall-cstr, r=Dylan-DPCDylan DPC-10/+9
unix: Avoid name conversions in `remove_dir_all_recursive` Each recursive call was creating an `OsString` for a `&Path`, only for it to be turned into a `CString` right away. Instead we can directly pass `.name_cstr()`, saving two allocations each time.
2022-03-08Rollup merge of #94714 - ChrisDenton:win-close_read_wakes_up, r=Mark-SimulacrumDylan DPC-1/+0
Enable `close_read_wakes_up` test on Windows I wonder if we could/should try enabling this again? It was closed by #38867 due to #31657. I've tried running this test (along with other tests) on my machine a number of times and haven't seen this fail yet, Caveat: the worst that can happen is this succeeds initially but then causes random hangs in CI. This is not a great failure mode and would be a reason not to do this. If this does work out, closes #39006 r? `@Mark-Simulacrum`
2022-03-08unix: reduce the size of DirEntryJosh Stone-10/+47
On platforms where we call `readdir` instead of `readdir_r`, we store the name as an allocated `CString` for variable length. There's no point carrying around a full `dirent64` with its fixed-length `d_name` too.
2022-03-08remove_dir_all: use fallback implementation on MiriRalf Jung-3/+3
2022-03-08Rollup merge of #94712 - kckeiks:remove-rwlock-read-error-assumption, ↵Matthias Krüger-3/+3
r=Mark-Simulacrum promot debug_assert to assert Fixes #94705
2022-03-08Rollup merge of #94559 - m-ou-se:thread-scope-spawn-closure-without-arg, ↵Matthias Krüger-21/+23
r=Mark-Simulacrum Remove argument from closure in thread::Scope::spawn. This implements ```@danielhenrymantilla's``` [suggestion](https://github.com/rust-lang/rust/issues/93203#issuecomment-1040798286) for improving the scoped threads interface. Summary: The `Scope` type gets an extra lifetime argument, which represents basically its own lifetime that will be used in `&'scope Scope<'scope, 'env>`: ```diff - pub struct Scope<'env> { .. }; + pub struct Scope<'scope, 'env: 'scope> { .. } pub fn scope<'env, F, T>(f: F) -> T where - F: FnOnce(&Scope<'env>) -> T; + F: for<'scope> FnOnce(&'scope Scope<'scope, 'env>) -> T; ``` This simplifies the `spawn` function, which now no longer passes an argument to the closure you give it, and now uses the `'scope` lifetime for everything: ```diff - pub fn spawn<'scope, F, T>(&'scope self, f: F) -> ScopedJoinHandle<'scope, T> + pub fn spawn<F, T>(&'scope self, f: F) -> ScopedJoinHandle<'scope, T> where - F: FnOnce(&Scope<'env>) -> T + Send + 'env, + F: FnOnce() -> T + Send + 'scope, - T: Send + 'env; + T: Send + 'scope; ``` The only difference the user will notice, is that their closure now takes no arguments anymore, even when spawning threads from spawned threads: ```diff thread::scope(|s| { - s.spawn(|_| { + s.spawn(|| { ... }); - s.spawn(|s| { + s.spawn(|| { ... - s.spawn(|_| ...); + s.spawn(|| ...); }); }); ``` <details><summary>And, as a bonus, errors get <em>slightly</em> better because now any lifetime issues point to the outermost <code>s</code> (since there is only one <code>s</code>), rather than the innermost <code>s</code>, making it clear that the lifetime lasts for the entire <code>thread::scope</code>. </summary> ```diff error[E0373]: closure may outlive the current function, but it borrows `a`, which is owned by the current function --> src/main.rs:9:21 | - 7 | s.spawn(|s| { - | - has type `&Scope<'1>` + 6 | thread::scope(|s| { + | - lifetime `'1` appears in the type of `s` 9 | s.spawn(|| println!("{:?}", a)); // might run after `a` is dropped | ^^ - `a` is borrowed here | | | may outlive borrowed value `a` | note: function requires argument type to outlive `'1` --> src/main.rs:9:13 | 9 | s.spawn(|| println!("{:?}", a)); // might run after `a` is dropped | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: to force the closure to take ownership of `a` (and any other referenced variables), use the `move` keyword | 9 | s.spawn(move || println!("{:?}", a)); // might run after `a` is dropped | ++++ " ``` </details> The downside is that the signature of `scope` and `Scope` gets slightly more complex, but in most cases the user wouldn't need to write those, as they just use the argument provided by `thread::scope` without having to name its type. Another downside is that this does not work nicely in Rust 2015 and Rust 2018, since in those editions, `s` would be captured by reference and not by copy. In those editions, the user would need to use `move ||` to capture `s` by copy. (Which is what the compiler suggests in the error.)
2022-03-08Fix for issue #93283Miguel Perez-1/+9
2022-03-07Reverted atomic-mut-ptr feature removal causing compilation breakSandeep Bansal-0/+1
2022-03-07unix: Avoid name conversions in `remove_dir_all_recursive`Josh Stone-10/+9
Each recursive call was creating an `OsString` for a `&Path`, only for it to be turned into a `CString` right away. Instead we can directly pass `.name_cstr()`, saving two allocations each time.
2022-03-07Enable `close_read_wakes_up` on WindowsChris Denton-1/+0
2022-03-07Use `f` instead of `|| f()`.Mara Bos-1/+1
Co-authored-by: Mark Rousskov <mark.simulacrum@gmail.com>
2022-03-07promot debug_assert to assertFausto-3/+3
2022-03-07Stabilize const_fn_fn_ptr_basics and const_fn_trait_boundEric Holk-2/+2
2022-03-07Auto merge of #94272 - tavianator:readdir-reclen-for-real, r=cuviperbors-5/+9
fs: Don't dereference a pointer to a too-small allocation ptr::addr_of!((*ptr).field) still requires ptr to point to an appropriate allocation for its type. Since the pointer returned by readdir() can be smaller than sizeof(struct dirent), we need to entirely avoid dereferencing it as that type. Link: https://github.com/rust-lang/miri/pull/1981#issuecomment-1048278492 Link: https://github.com/rust-lang/rust/pull/93459#discussion_r795089971
2022-03-06Rollup merge of #94649 - ChrisDenton:unix-absolute-fix, r=Dylan-DPCfee1-dead-8/+17
Unix path::absolute: Fix leading "." component Testing leading `.` and `..` components were missing from the unix tests. This PR adds them and fixes the leading `.` case. It also fixes the test cases so that they do an exact comparison. This problem reported by ``@axetroy``
2022-03-05Auto merge of #94648 - RalfJung:rollup-4iorcrd, r=RalfJungbors-0/+5
Rollup of 4 pull requests Successful merges: - #94630 (Update note about tier 2 docs.) - #94633 (Suggest removing a semicolon after derive attributes) - #94642 (Fix source code pages scroll) - #94645 (do not attempt to open cgroup files under Miri) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-03-05Use as_os_str to compare exact pathsChris Denton-3/+6
2022-03-05Relax tests for Windows dos device namesChris Denton-4/+1
Windows 11 no longer turn paths ending with dos device names into device paths. E.g. `C:\path\to\COM1.txt` used to get turned into `\\.\COM1`. Whereas now the path is left as is.
2022-03-05Use `as_os_str` to compare exact pathsChris Denton-7/+10
2022-03-05Unix `path::absolute`: Fix leading "." componentChris Denton-1/+7
Testing leading `.` and `..` components were missing from the unix tests.
2022-03-05do not attempt to open cgroup files under MiriRalf Jung-0/+5
2022-03-05Small fixes in thread local code.Mara Bos-2/+2
2022-03-05Update documentation in thread/local.rs.Mara Bos-6/+26
2022-03-05Add debug asserts in thread local cell set methods.Mara Bos-0/+4
2022-03-05Add tracking issue number for local_key_cell_methods.Mara Bos-9/+9
2022-03-05Rename LocalKey's with_{ref,mut} to with_borrow{,_mut}.Mara Bos-9/+9
2022-03-05Implement RFC 3184 - thread local cell methods.Mara Bos-10/+348
2022-03-05Auto merge of #94546 - JmPotato:std-features-cleanup, r=m-ou-sebors-23/+0
Clean up the std library's #![feature]s Signed-off-by: JmPotato <ghzpotato@gmail.com> This is part of https://github.com/rust-lang/rust/issues/87766. r? `@m-ou-se`
2022-03-05Rollup merge of #94446 - rusticstuff:remove_dir_all-illumos-fix, r=cuviperDylan DPC-131/+74
UNIX `remove_dir_all()`: Try recursing first on the slow path This only affects the _slow_ code path - if there is no `dirent.d_type` or if it is `DT_UNKNOWN`. POSIX specifies that calling `unlink()` or `unlinkat(..., 0)` on a directory is allowed to succeed: > The _path_ argument shall not name a directory unless the process has appropriate privileges and the implementation supports using _unlink()_ on directories. This however can cause dangling inodes requiring an fsck e.g. on Illumos UFS, so we have to avoid that in the common case. We now just try to recurse into it first and unlink() if we can't open it as a directory. The other two commits integrate the Macos x86-64 implementation reducing redundancy. Split into two commits for better reviewing. Fixes #94335.
2022-03-05Clean up the std library's #![feature]sJmPotato-23/+0
Signed-off-by: JmPotato <ghzpotato@gmail.com>
2022-03-05Auto merge of #94628 - Dylan-DPC:rollup-v2slupe, r=Dylan-DPCbors-4/+1
Rollup of 5 pull requests Successful merges: - #94362 (Add well known values to `--check-cfg` implementation) - #94577 (only disable SIMD for doctests in Miri (not for the stdlib build itself)) - #94595 (Fix invalid `unresolved imports` errors for a single-segment import) - #94596 (Delay bug in expr adjustment when check_expr is called multiple times) - #94618 (Don't round stack size up for created threads in Windows) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-03-04Rollup merge of #94618 - lewisclark:remove-stack-size-rounding, r=yaahcDylan DPC-4/+1
Don't round stack size up for created threads in Windows Fixes #94454 Windows does the rounding itself, so there isn't a need to explicity do the rounding beforehand, as mentioned by ```@ChrisDenton``` in #94454 > The operating system rounds up the specified size to the nearest multiple of the system's allocation granularity (typically 64 KB). To retrieve the allocation granularity of the current system, use the [GetSystemInfo](https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsysteminfo) function. https://docs.microsoft.com/en-us/windows/win32/procthread/thread-stack-size
2022-03-04Auto merge of #94298 - Urgau:rustbuild-check-cfg, r=Mark-Simulacrumbors-0/+3
Enable conditional compilation checking on the Rust codebase This pull-request enable conditional compilation checking on every rust project build by the `bootstrap` tool. To be more specific, this PR only enable well known names checking + extra names (bootstrap, parallel_compiler, ...). r? `@Mark-Simulacrum`
2022-03-04Don't round stack size up for created threadsLewis Clark-4/+1
2022-03-04Rollup merge of #94549 - m-ou-se:thread-is-finished, r=yaahcMatthias Krüger-14/+22
Rename JoinHandle::is_running to is_finished. This is renaming `is_running` to `is_finished` as discussed on the tracking issue here: https://github.com/rust-lang/rust/issues/90470#issuecomment-1050188499 Taking some of the docs suggestions from https://github.com/rust-lang/rust/pull/94033
2022-03-04Rollup merge of #94236 - reez12g:add_track_caller_87707, r=yaahcMatthias Krüger-0/+2
Add #[track_caller] to track callers when initializing poisoned Once This PR is for this Issue. https://github.com/rust-lang/rust/issues/87707 With this fix, we expect to be able to track the caller when poisoned Once is initialized.
2022-03-04Remove redundant code for handling NULL handles on Windows.Dan Gohman-13/+0
Before calling `CreateProcessW`, stdio handles are passed through `stdio::get_handle`, which already converts NULL to `INVALID_HANDLE_VALUE`, so we don't need extra checks for NULL after that point.
2022-03-04Fix a compilation error.Dan Gohman-1/+1
2022-03-04Consistently present absent stdio handles on Windows as NULL handles.Dan Gohman-16/+113
This addresses #90964 by making the std API consistent about presenting absent stdio handles on Windows as NULL handles. Stdio handles may be absent due to `#![windows_subsystem = "windows"]`, due to the console being detached, or due to a child process having been launched from a parent where stdio handles are absent. Specifically, this fixes the case of child processes of parents with absent stdio, which previously ended up with `stdin().as_raw_handle()` returning `INVALID_HANDLE_VALUE`, which was surprising, and which overlapped with an unrelated valid handle value. With this patch, `stdin().as_raw_handle()` now returns null in these situation, which is consistent with what it does in the parent process. And, document this in the "Windows Portability Considerations" sections of the relevant documentation.
2022-03-04Integrate macos x86-64 remove_dir_all() impl. Step 2: readdHans Kratz-6/+60