Commit Graph

3514 Commits

Author SHA1 Message Date
Ben Kimock
761ddf3e7f Remove some redundant checks from BufReader
The implementation of BufReader contains a lot of redundant checks.
While any one of these checks is not particularly expensive to execute,
especially when taken together they dramatically inhibit LLVM's ability
to make subsequent optimizations.
2022-07-24 12:50:05 -04:00
bors
e55c53c57e Auto merge of #97925 - the8472:cgroupv1, r=joshtriplett
Add cgroupv1 support to available_parallelism

Fixes #97549

My dev machine uses cgroup v2 so I was only able to test that code path. So the v1 code path is written only based on documentation. I could use some help testing that it works on a machine with cgroups v1:

```
$ x.py build --stage 1

# quota.rs
fn main() {
    println!("{:?}", std:🧵:available_parallelism());
}

# assuming stage1 is linked in rustup
$ rust +stage1 quota.rs

# spawn a new cgroup scope for the current user
$ sudo systemd-run -p CPUQuota="300%" --uid=$(id -u) -tdS

# should print Ok(3)
$ ./quota
```

If it doesn't work as expected an strace, the contents of `/proc/self/cgroups` and the structure of `/sys/fs/cgroups` would help.
2022-07-23 13:33:56 +00:00
the8472
2e33c812e8
[review] mention that runtime may scale with # of mountpoints
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2022-07-22 22:18:07 +02:00
Matthias Krüger
84a7b23fd7
Rollup merge of #99523 - cuviper:asfd_ptrs-1.64, r=jyn514
Fix the stable version of `AsFd for Arc<T>` and `Box<T>`

These merged in #97437 for 1.64.0, apart from the main `io_safety`
feature that stabilized in 1.63.0.
2022-07-21 18:42:05 +02:00
Matthias Krüger
c5df2f02d3
Rollup merge of #98707 - joboet:fuchsia_locks, r=m-ou-se
std: use futex-based locks on Fuchsia

This switches `Condvar` and `RwLock` to the futex-based implementation currently used on Linux and some BSDs. Additionally, `Mutex` now has its own, priority-inheriting implementation based on the mutex in Fuchsia's `libsync`. It differs from the original in that it panics instead of aborting when reentrant locking is detected.

````@rustbot```` ping fuchsia
r? ````@m-ou-se````
2022-07-21 18:42:02 +02:00
joboet
8ba02f18b8
remove unused import 2022-07-21 11:51:26 +02:00
Josh Stone
bd0474d24a Fix the stable version of AsFd for Arc<T> and Box<T>
These merged in #97437 for 1.64.0, apart from the main `io_safety`
feature that stabilized in 1.63.0.
2022-07-20 12:09:49 -07:00
joboet
c72a77e093
owner is not micro (correct typo) 2022-07-20 16:11:31 +02:00
Dylan DPC
90c59e736b
Rollup merge of #98101 - vladimir-ea:stdlib_watch_os, r=thomcc
stdlib support for Apple WatchOS

This is a follow-up to https://github.com/rust-lang/rust/pull/95243 (Add Apple WatchOS compiler targets) that adds stdlib support for Apple WatchOS.

`@deg4uss3r`
`@nagisa`
2022-07-20 16:17:17 +05:30
Vladimir Michael Eatwell
439d64a83c Library changes for Apple WatchOS 2022-07-20 08:57:36 +01:00
Dylan DPC
80395679cb
Rollup merge of #98916 - ChrisDenton:hiberfil.sys, r=thomcc
Windows: Use `FindFirstFileW` for getting the metadata of locked system files

Fixes #96980

Usually opening a file handle with access set to metadata only will always succeed, even if the file is locked. However some special system files, such as `C:\hiberfil.sys`, are locked by the system in a way that denies even that. So as a fallback we try reading the cached metadata from the directory.

Note that the test is a bit iffy. I don't know if `hiberfil.sys` actually exists in the CI.

r? rust-lang/libs
2022-07-20 11:29:38 +05:30
Michael Howell
5271e32c46 Improve the function pointer docs
* Reduce duplicate impls; show only the `fn (T)` and include a sentence
  saying that there exists up to twelve of them.
* Show `Copy` and `Clone`.
* Show auto traits like `Send` and `Sync`, and blanket impls like `Any`.
2022-07-19 08:52:24 -07:00
Chris Denton
eee8ca9a44
Ignore hiberfil_sys test in CI
The file it's testing does not exist in the CI environment.
2022-07-18 15:06:07 +01:00
joboet
f357926837
std: panic instead of deadlocking in mutex implementation on Fuchsia 2022-07-18 10:56:10 +02:00
Michael Howell
1169832f2f rustdoc: extend #[doc(tuple_variadic)] to fn pointers
The attribute is also renamed `fake_variadic`.
2022-07-17 16:32:06 -07:00
Yuki Okushi
28cce683ad
Rollup merge of #99302 - yaahc:gma-tracking-issue, r=joshtriplett
add tracking issue to generic member access APIs

Missed as part of https://github.com/rust-lang/rust/pull/98072
2022-07-17 13:08:51 +09:00
Yuki Okushi
f49d267136
Rollup merge of #99088 - niklasf:stabilize-process_set_process_group, r=joshtriplett
Document and stabilize process_set_process_group

Tracking issue: https://github.com/rust-lang/rust/issues/93857

FCP finished here: https://github.com/rust-lang/rust/issues/93857#issuecomment-1179551697
2022-07-17 13:08:50 +09:00
Yuki Okushi
48cf43b752
Rollup merge of #97915 - tbu-:pr_os_string_fmt_write, r=joshtriplett
Implement `fmt::Write` for `OsString`

This allows to format into an `OsString` without unnecessary
allocations. E.g.

```
let mut temp_filename = path.into_os_string();
write!(&mut temp_filename, ".tmp.{}", process::id());
```
2022-07-17 13:08:48 +09:00
Caio
3266460749 Stabilize let_chains 2022-07-16 20:17:58 -03:00
Josh Triplett
629b0b488b
Expand documentation for process_group
Explain PGID 0, and provide the acronym PGID.
2022-07-16 14:45:16 -07:00
Josh Triplett
3855e86873
Update since version to 1.64 2022-07-16 14:36:48 -07:00
Yuki Okushi
083a253e53
Rollup merge of #99277 - joshtriplett:stabilize-core-cstr-alloc-cstring, r=Mark-Simulacrum
Stabilize `core::ffi::CStr`, `alloc::ffi::CString`, and friends

Stabilize the `core_c_str` and `alloc_c_string` feature gates.

Change `std::ffi` to re-export these types rather than creating type
aliases, since they now have matching stability.
2022-07-16 17:53:04 +09:00
Yuki Okushi
8a64529763
Rollup merge of #99264 - eltociear:patch-14, r=compiler-errors
Fix typo in mod.rs

constuct -> construct
2022-07-16 17:53:02 +09:00
Yuki Okushi
06eb90ef63
Rollup merge of #98662 - LucasDumont:document_fs_write, r=thomcc
Add std::fs::write documentation precision

Fixes #97947.

As mentioned in #97947, the documentation is updated
2022-07-16 17:53:00 +09:00
Yuki Okushi
bf9ed99496
Rollup merge of #98387 - NobodyXu:feature/std_io_Error_try_downgrade_inner, r=yaahc
Add new unstable API `downcast` to `std::io::Error`

https://github.com/rust-lang/libs-team/issues/57

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-16 17:52:59 +09:00
Jane Losare-Lusby
a9d2ed2ab1 add tracking issue to generic member access APIs 2022-07-15 22:13:43 +00:00
Jane Losare-Lusby
8e8a3be22f
Apply suggestions from code review 2022-07-15 13:17:44 -07:00
Josh Triplett
d6b7480c2a Stabilize core::ffi::CStr, alloc::ffi::CString, and friends
Stabilize the `core_c_str` and `alloc_c_string` feature gates.

Change `std::ffi` to re-export these types rather than creating type
aliases, since they now have matching stability.
2022-07-15 03:10:35 -07:00
Ikko Ashimine
67a6c0a7ee
Fix typo in mod.rs
constuct -> construct
2022-07-15 12:57:46 +09:00
Jiahao XU
d8aba1002a
Improve example of downcast
Co-authored-by: Jane Losare-Lusby <jlusby42@gmail.com>
2022-07-15 13:04:06 +10:00
bors
74621c764e Auto merge of #99242 - Dylan-DPC:rollup-34bqdh8, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #98072 (Add provider API to error trait)
 - #98580 (Emit warning when named arguments are used positionally in format)
 - #99000 (Move abstract const to middle)
 - #99192 (Fix spans for asm diagnostics)
 - #99222 (Better error message for generic_const_exprs inference failure)
 - #99236 (solaris: unbreak build on native platform)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-07-14 16:23:07 +00:00
Dylan DPC
2b17aa67fc
Rollup merge of #98072 - yaahc:generic-member-access, r=thomcc
Add provider API to error trait

Implements https://github.com/rust-lang/rfcs/pull/2895
2022-07-14 19:24:02 +05:30
bors
24699bcbad Auto merge of #95956 - yaahc:stable-in-unstable, r=cjgillot
Support unstable moves via stable in unstable items

part of https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/moving.20items.20to.20core.20unstably and a blocker of https://github.com/rust-lang/rust/pull/90328.

The libs-api team needs the ability to move an already stable item to a new location unstably, in this case for Error in core. Otherwise these changes are insta-stable making them much harder to merge.

This PR attempts to solve the problem by checking the stability of path segments as well as the last item in the path itself, which is currently the only thing checked.
2022-07-14 13:42:09 +00:00
Dylan DPC
103b8602b7
Rollup merge of #98315 - joshtriplett:stabilize-core-ffi-c, r=Mark-Simulacrum
Stabilize `core::ffi:c_*` and rexport in `std::ffi`

This only stabilizes the base types, not the non-zero variants, since
those have their own separate tracking issue and have not gone through
FCP to stabilize.
2022-07-14 14:14:20 +05:30
Josh Triplett
d431338b25 Stabilize core::ffi:c_* and rexport in std::ffi
This only stabilizes the base types, not the non-zero variants, since
those have their own separate tracking issue and have not gone through
FCP to stabilize.
2022-07-13 19:28:20 -07:00
Jiahao XU
111253c519
Rename std::io::Error::try_downcast_inner to downcast
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-14 11:24:44 +10:00
joboet
0d91b08970
std: fix issue with perma-locked mutexes on Fuchsia 2022-07-12 12:25:43 +02:00
Jane Losare-Lusby
655d6e82e3 apply suggestions from code review 2022-07-11 19:18:56 +00:00
bors
7d1f57a757 Auto merge of #97841 - nvzqz:inline-encode-wide, r=thomcc
Inline Windows `OsStrExt::encode_wide`

User crates currently produce much more code than necessary because the optimizer fails to make assumptions about this method.
2022-07-11 09:30:54 +00:00
Lucas Dumont
07a0fd2c1e Add std::fs::write documentation precision
As mentioned in #97947, the documentation is updated
2022-07-11 09:48:47 +02:00
bors
17355a3b9f Auto merge of #98950 - ChrisDenton:getoverlapped-io, r=thomcc
Windows: Fallback for overlapped I/O

Fixes #98947
2022-07-09 22:37:56 +00:00
Niklas Fiekas
b028bbf9d0 Document and stabilize process_set_process_group
Tracking issue: https://github.com/rust-lang/rust/issues/93857

FCP finished here:
https://github.com/rust-lang/rust/issues/93857#issuecomment-1179551697
2022-07-09 12:40:33 +02:00
Jane Lusby
e7fe5456c5 Support unstable moves via stable in unstable items 2022-07-08 21:18:13 +00:00
Matthias Krüger
6826f33168
Rollup merge of #97917 - AronParker:master, r=ChrisDenton
Implement ExitCodeExt for Windows

Fixes #97914

### Motivation:

On Windows it is common for applications to return `HRESULT` (`i32`) or `DWORD` (`u32`) values. These stem from COM based components ([HRESULTS](https://docs.microsoft.com/en-us/windows/win32/api/objbase/nf-objbase-coinitialize)), Win32 errors ([GetLastError](https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-getlasterror)), GUI applications ([WM_QUIT](https://docs.microsoft.com/en-us/windows/win32/winmsg/wm-quit)) and more. The newly stabilized `ExitCode` provides an excellent fit for propagating these values, because `std::process::exit` does not run deconstructors which can result in errors. However, `ExitCode` currently only implements `From<u8> for ExitCode`, which disallows the full range of `i32`/`u32` values. This pull requests attempts to address that shortcoming by providing windows specific extensions that accept a `u32` value (which covers all possible `HRESULTS` and Win32 errors) analog to [ExitStatusExt::from_raw](https://doc.rust-lang.org/std/os/windows/process/trait.ExitStatusExt.html#tymethod.from_raw).

This was also intended by the original Stabilization https://github.com/rust-lang/rust/pull/93840#issue-1129209143=  as pointed out by ``@eggyal`` in https://github.com/rust-lang/rust/issues/97914#issuecomment-1151076755:

> Issues around platform specific representations: We resolved this issue by changing the return type of report from i32 to the opaque type ExitCode. __That way we can change the underlying representation without affecting the API, letting us offer full support for platform specific exit code APIs in the future.__

[Emphasis added]

### API

```rust
/// Windows-specific extensions to [`process::ExitCode`].
///
/// This trait is sealed: it cannot be implemented outside the standard library.
/// This is so that future additional methods are not breaking changes.
#[stable(feature = "windows_process_exit_code_from", since = "1.63.0")]
pub trait ExitCodeExt: Sealed {
    /// Creates a new `ExitCode` from the raw underlying `u32` return value of
    /// a process.
    #[stable(feature = "windows_process_exit_code_from", since = "1.63.0")]
    fn from_raw(raw: u32) -> Self;
}

#[stable(feature = "windows_process_exit_code_from", since = "1.63.0")]
impl ExitCodeExt for process::ExitCode {
    fn from_raw(raw: u32) -> Self {
        process::ExitCode::from_inner(From::from(raw))
    }
}
```

### Misc

I apologize in advance if I misplaced any attributes regarding stabilzation, as far as I learned traits are insta-stable so I chose to make them stable. If this is an error, please let me know and I'll correct it. I also added some additional machinery to make it work, analog to [ExitStatus](https://doc.rust-lang.org/std/process/struct.ExitStatus.html#).

EDIT: Proposal: https://github.com/rust-lang/libs-team/issues/48
2022-07-07 20:33:23 +02:00
Chris Denton
a8ffc7fd45
Tests for unsound Windows file methods 2022-07-06 17:40:21 +01:00
Chris Denton
3ae47e76a8
Windows: Fallback for overlapped I/O
Try waiting on the file handle once. If that fails then give up.
2022-07-06 17:06:33 +01:00
Chris Denton
ae60dbdcac
Use rtabort! instead of process::abort 2022-07-06 16:36:52 +01:00
Florian Spieß
75967cdad5
Fix typo in file descriptor docs 2022-07-06 11:57:58 +02:00
Chris Denton
5f5bcb3697
Test if [try_]exists can find hiberfil.sys 2022-07-05 12:24:01 +01:00
Chris Denton
2d0650457f
Add comment and simplify hiberfil_sys test 2022-07-05 12:05:51 +01:00