Commit graph

7609 commits

Author SHA1 Message Date
bors ddb7fbe843 Auto merge of #96441 - ChrisDenton:sync-pipes, r=m-ou-se
Windows: Make stdin pipes synchronous

Stdin pipes do not need to be used asynchronously within the standard library. This is a first step in making pipes mostly synchronous.

r? `@m-ou-se`
2022-04-29 03:06:45 +00:00
bors baaa3b6829 Auto merge of #96393 - joboet:pthread_parker, r=thomcc
std: directly use pthread in UNIX parker implementation

`Mutex` and `Condvar` are being replaced by more efficient implementations, which need thread parking themselves (see #93740). Therefore we should use the `pthread` synchronization primitives directly. Also, we can avoid allocating the mutex and condition variable because the `Parker` struct is being placed in an `Arc` anyways.

This basically is just a copy of the current `Mutex` and `Condvar` code, which will however be removed (again, see #93740). An alternative implementation could be to use dedicated private `OsMutex` and `OsCondvar` types, but all the other platforms supported by std actually have their own thread parking primitives.

I used `Pin` to guarantee a stable address for the `Parker` struct, while the current implementation does not, rather using extra unsafe declaration. Since the thread struct is shared anyways, I assumed this would not add too much clutter while being clearer.
2022-04-28 21:58:08 +00:00
Dylan DPC 2c1d58b8cc
Rollup merge of #96480 - user-simon:patch-1, r=Dylan-DPC
Fixed grammatical error in example comment

Added missing "we" in sentence.
2022-04-28 20:13:03 +02:00
Dylan DPC 0cbf3b2b30
Rollup merge of #96433 - petrochenkov:delim, r=nnethercote
rustc_ast: Harmonize delimiter naming with `proc_macro::Delimiter`

Compiler cannot reuse `proc_macro::Delimiter` directly due to extra impls, but can at least use the same naming.

After this PR the only difference between these two enums is that `proc_macro::Delimiter::None` is turned into `token::Delimiter::Invisible`.
It's my mistake that the invisible delimiter is called `None` on stable, during the stabilization I audited the naming and wrote the docs, but missed the fact that the `None` naming gives a wrong and confusing impression about what this thing is.

cc https://github.com/rust-lang/rust/pull/96421
r? ``@nnethercote``
2022-04-28 20:13:02 +02:00
joboet 550273361d
std: simplify UNIX parker timeouts 2022-04-28 12:31:19 +02:00
bors 3bfeffd55b Auto merge of #95904 - paolobarbolini:vecdeque-specextend, r=the8472
Add VecDeque::extend from vec::IntoIter and slice::Iter specializations

Inspired from the [`Vec` `SpecExtend` implementation](027a232755/library/alloc/src/vec/spec_extend.rs), but without the specialization for `TrustedLen` which I'll look into in the future.

Should help #95632 and https://github.com/KillingSpark/zstd-rs/pull/17

## Benchmarks

Before

```
test vec_deque::bench_extend_bytes    ... bench:         862 ns/iter (+/- 10)
test vec_deque::bench_extend_vec      ... bench:         883 ns/iter (+/- 19)
```

After

```
test vec_deque::bench_extend_bytes    ... bench:           8 ns/iter (+/- 0)
test vec_deque::bench_extend_vec      ... bench:          24 ns/iter (+/- 1)

```
2022-04-28 09:27:21 +00:00
Vadim Petrochenkov 2733ec1be3 rustc_ast: Harmonize delimiter naming with proc_macro::Delimiter 2022-04-28 10:04:29 +03:00
Paolo Barbolini c126f7fc8b Add VecDeque::extend from vec::IntoIter and slice::Iter specializations 2022-04-28 06:13:54 +02:00
Dylan DPC 6f6fe3e651
Rollup merge of #96466 - compiler-errors:error-collect-array, r=davidtwco
Better error messages when collecting into `[T; n]`

Fixes #96461
2022-04-28 02:40:35 +02:00
Dylan DPC c4dd0d3bb7
Rollup merge of #96397 - AronParker:issue-96368-fix, r=dtolnay
Make EncodeWide implement FusedIterator

[`EncodeUtf16`](https://doc.rust-lang.org/std/str/struct.EncodeUtf16.html) and [`EncodeWide`](https://doc.rust-lang.org/std/os/windows/ffi/struct.EncodeWide.html) currently serve similar purposes: They convert from UTF-8 to UTF-16 and WTF-8 to WTF-16, respectively. `EncodeUtf16` wraps a &str, whereas `EncodeWide` wraps an &OsStr.

When Iteration has concluded, these iterators wrap an empty slice, which will forever yield `None` values. Hence, `EncodeUtf16` rightfully implements `FusedIterator`. However, `EncodeWide` in contrast does not, even though it serves an almost identical purpose.

This PR attempts to fix that issue. I consider this change minor and non-controversial, hence why I have not added a RFC/FCP. Please let me know if the stability attribute is wrong or contains a wrong version number. Thanks in advance.

Fixes https://github.com/rust-lang/rust/issues/96368
2022-04-28 02:40:33 +02:00
Paolo Barbolini 84b8898d63 Add VecDeque::extend benchmark 2022-04-27 21:10:20 +02:00
Simon 332f326334
Fixed grammatical error in example comment 2022-04-27 17:27:02 +02:00
Chris Denton 1e7c15634d
Note the importance of using sync pipes 2022-04-27 13:56:59 +01:00
Michael Goulet 83d701e569 Better error messages when collecting into [T; n] 2022-04-26 21:37:10 -07:00
bors bb85bcaca9 Auto merge of #96195 - sunfishcode:sunfishcode/handle-or-error-type, r=joshtriplett
Define a dedicated error type for `HandleOrNull` and `HandleOrInvalid`.

Define `NullHandleError` and `InvalidHandleError` types, that implement std::error::Error, and use them as the error types in `HandleOrNull` and `HandleOrInvalid`,

This addresses [this concern](https://github.com/rust-lang/rust/issues/87074#issuecomment-1080031167).

This is the same as #95387.

r? `@joshtriplett`
2022-04-27 03:42:59 +00:00
Chris Denton 949b978ec9
Windows: Make stdin pipes synchronous
Stdin pipes do not need to be used asynchronously within the standard library.
2022-04-26 16:31:27 +01:00
Chris Denton b89b056742
Add set_inheritable for Windows Handles 2022-04-26 15:56:26 +01:00
Guillaume Gomez 223f107b48
Rollup merge of #96415 - ehuss:git-io, r=bjorn3
Remove references to git.io

The git.io service is shutting down soon (see https://github.blog/changelog/2022-04-25-git-io-deprecation/). This removes the references of those short links with the actual destination.
2022-04-26 13:22:31 +02:00
Guillaume Gomez 2b8bf0d530
Rollup merge of #95949 - SoniEx2:patch-5, r=m-ou-se
Implement Default for AssertUnwindSafe

Trait impls are still insta-stable yeah...?
2022-04-26 13:22:27 +02:00
Guillaume Gomez eaf8beb3f3
Rollup merge of #94022 - jongiddy:cow-into-owned-docs, r=Dylan-DPC
Clarify that `Cow::into_owned` returns owned data

Two sections of the `Cow::into_owned` docs imply that `into_owned` returns a `Cow`. Clarify that it returns the underlying owned object, either cloned or extracted from the `Cow`.
2022-04-26 13:22:26 +02:00
Eric Huss 159b95d5bb Remove references to git.io 2022-04-25 17:05:58 -07:00
Dylan DPC 93db30aa7f
Rollup merge of #96149 - est31:remove_unused_macro_matchers, r=petrochenkov
Remove unused macro rules

Removes rules of internal macros that weren't triggered.
2022-04-26 01:21:20 +02:00
Dylan DPC 51b86848ff
Rollup merge of #90312 - r00ster91:search, r=Dylan-DPC
Fix some confusing wording and improve slice-search-related docs

This adds more links between `contains` and `binary_search` because I do think they have some relevant connections. If your (big) slice happens to be sorted and you know it, surely you should be using `[3; 100].binary_search(&5).is_ok()` over `[3; 100].contains(&5)`?
This also fixes the confusing "searches this sorted X" wording which just sounds really weird because it doesn't know whether it's actually sorted. It should be but it may not be. The new wording should make it clearer that you will probably want to sort it and in the same sentence it also mentions the related function `contains`.
Similarly, this mentions `binary_search` on `contains`' docs.
This also fixes some other minor stuff and inconsistencies.
2022-04-26 01:21:20 +02:00
Aron Parker fc6af819c4 Make EncodeWide implement FusedIterator 2022-04-25 18:38:47 +02:00
joboet 54daf496e2
std: directly use pthread in UNIX parker implementation
Mutex and Condvar are being replaced by more efficient implementations, which need thread parking themselves (see #93740). Therefore use the pthread synchronization primitives directly. Also, avoid allocating because the Parker struct is being placed in an Arc anyways.
2022-04-25 15:19:50 +02:00
bors 756ffb8d0b Auto merge of #95246 - ChrisDenton:command-args, r=joshtriplett
Windows Command: Don't run batch files using verbatim paths

Fixes #95178

Note that the first commit does some minor refactoring (moving command line argument building to args.rs). The actual changes are in the second.
2022-04-25 07:28:09 +00:00
Matthias Krüger b7e67a6ad9
Rollup merge of #96107 - Gumichocopengin8:test/vec-deque, r=Mark-Simulacrum
[test] Add test cases for untested functions for VecDeque

Added test cases of the following functions
- get
- get_mut
- swap
- reserve_exact
- try_reserve_exact
- try_reserve
- contains
- rotate_left
- rotate_right
- binary_search
- binary_search_by
- binary_search_by_key
2022-04-25 00:11:00 +02:00
bors 18f314e702 Auto merge of #94609 - esp-rs:esp-idf-stat-type-fixes, r=Mark-Simulacrum
espidf: fix stat

Marking as draft as currently dependant on [a libc fix](https://github.com/rust-lang/libc/pull/2708) and release.
2022-04-24 19:16:20 +00:00
Keita Nonaka a40cd2aa8b test: add test cases for VecDeque 2022-04-24 11:43:07 -07:00
bors 6b4563bf93 Auto merge of #90602 - mbartlett21:const-intoiterator, r=oli-obk
Unstably constify `impl<I: Iterator> IntoIterator for I`

This constifies the default `IntoIterator` implementation under the `const_intoiterator_identity` feature.

Tracking Issue: #90603
2022-04-23 15:41:45 +00:00
bors 1e9aa8a96b Auto merge of #95971 - workingjubilee:no-weird-fp-in-const, r=oli-obk
No "weird" floats in const fn {from,to}_bits

I suspect this code is subtly incorrect and that we don't even e.g. use x87-style floats in CTFE, so I don't have to guard against that case. A future PR will be hopefully removing them from concern entirely, anyways. But at the moment I wanted to get this rolling because small questions like that one seem best answered by review.

r? `@oli-obk`
cc `@eddyb` `@thomcc`
2022-04-23 13:00:54 +00:00
bors 64c5deb0e3 Auto merge of #96314 - AronParker:issue-96297-fix, r=thomcc
Reduce allocations for path conversions on Windows

Previously, UTF-8 to UTF-16 Path conversions on Windows unnecessarily allocate twice, as described in #96297. This commit fixes that issue.
2022-04-23 04:17:50 +00:00
Jubilee Young 4da8682523 Remove unnecessary const-time x87-related checks 2022-04-22 19:34:33 -07:00
Jubilee Young bb555b828c Fix comments for float classify 2022-04-22 18:34:34 -07:00
bors 8834629b86 Auto merge of #94887 - dylni:move-normpath-crate-impl-to-libstd, r=ChrisDenton
Improve Windows path prefix parsing

This PR fixes improves parsing of Windows path prefixes. `parse_prefix` now supports both types of separators on Windows (`/` and `\`).
2022-04-23 00:58:22 +00:00
Aron Parker 6cfdeaf1a1 Remove redundant type annotation 2022-04-22 11:42:53 +02:00
Aron Parker 9a9d5534f0 Reduce allocations for path conversions on Windows
Previously, UTF-8 to UTF-16 Path conversions on Windows unnecessarily allocate twice, as described in #96297. This commit fixes that issue.
2022-04-22 11:02:04 +02:00
Dylan DPC e2543d7a4e
Rollup merge of #96228 - mbartlett21:patch-4, r=thomcc
Fix locations for intrinsics impls and change to links

These still referred to `rustc_mir`.
2022-04-21 01:14:16 +02:00
Dylan DPC 1e43aae0ef
Rollup merge of #96193 - djkoloski:fuchsia_current_exe, r=tmandry
[fuchsia] Add implementation for `current_exe`

This implementation returns a best attempt at the current exe path. On
fuchsia, fdio will always use `argv[0]` as the process name and if it is
not set then an error will be returned. Because this is not guaranteed
to be the case, this implementation returns an error if `argv` does not
contain any elements.
2022-04-21 01:14:14 +02:00
Dylan DPC 2443cf2c6a
Rollup merge of #96234 - goffrie:eloop, r=thomcc
remove_dir_all_recursive: treat ELOOP the same as ENOTDIR

On older Linux kernels (I tested on 4.4, corresponding to Ubuntu 16.04), opening a symlink using `O_DIRECTORY | O_NOFOLLOW` returns `ELOOP` instead of `ENOTDIR`. We should handle it the same, since a symlink is still not a directory and needs to be `unlink`ed.
2022-04-20 18:26:06 +02:00
Dylan DPC 41235ef98a
Rollup merge of #96206 - m-ou-se:wasm-futex-locks, r=alexcrichton
Use sys::unix::locks::futex* on wasm+atomics.

This removes the wasm-specific lock implementations and instead re-uses the implementations from sys::unix.

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

cc ``@alexcrichton``
2022-04-20 18:26:05 +02:00
Dylan DPC 01d4731735
Rollup merge of #96168 - chris-morgan:AddrParseError-description-improvements, r=joshtriplett
Improve AddrParseError description

The existing description was incorrect for socket addresses, and misleading: users would see “invalid IP address syntax” and suppose they were supposed to provide an IP address rather than a socket address.

I contemplated making it two variants (IP, socket), but realised we can do still better for the IPv4 and IPv6 types, so here it is as six.

I contemplated more precise error descriptions (e.g. “invalid IPv6 socket address syntax: expected a decimal scope ID after %”), but that’s a more invasive change, and probably not worthwhile anyway.
2022-04-20 18:26:04 +02:00
Dylan DPC 53f028d790
Rollup merge of #96167 - CAD97:weak-dlsym-less-ptr-crime, r=thomcc
Replace sys/unix/weak AtomicUsize with AtomicPtr

Should fix #96163. Can't easily test on Windows though...
2022-04-20 18:26:03 +02:00
bors d39864d64e Auto merge of #96135 - petrochenkov:doclink6, r=GuillaumeGomez
rustdoc: Optimize and refactor doc link resolution

One more subset of https://github.com/rust-lang/rust/pull/94857 that should bring perf improvements rather than regressions + a couple more optimizations on top of it.
It's better to read individual commits and their descriptions to understand the changes.
The `may_have_doc_links` optimization is not *very* useful here, but it's much more important for https://github.com/rust-lang/rust/pull/94857.

Closes https://github.com/rust-lang/rust/issues/96079
2022-04-20 13:34:48 +00:00
mbartlett21 4879875c76
Change file locations to be links to GitHub 2022-04-20 13:14:32 +10:00
Geoffry Song cff3f1e8d5 remove_dir_all_recursive: treat ELOOP the same as ENOTDIR 2022-04-20 00:50:03 +00:00
mbartlett21 671a8723c6
Fix locations for intrinsics impls 2022-04-20 09:28:07 +10:00
Dylan DPC da1ddf371c
Rollup merge of #96205 - m-ou-se:emscripten-futex-locks, r=thomcc
Use futex locks on emscripten.

This switches Emscripten to the futex-based lock implementations, away from pthread.

Tracking issue: https://github.com/rust-lang/rust/issues/93740
2022-04-19 22:57:44 +02:00
David Koloski eb6b6a877e [fuchsia] Add implementation for current_exe
This implementation returns a best attempt at the current exe path. On
fuchsia, fdio will always use `argv[0]` as the process name and if it is
not set then an error will be returned. Because this is not guaranteed
to be the case, this implementation returns an error if `argv` does not
contain any elements.
2022-04-19 16:50:24 -04:00
Vadim Petrochenkov f5ca02c334 proc_macro: Add a workaround for rustdoc 2022-04-19 22:49:27 +03:00