Commit Graph

3101 Commits

Author SHA1 Message Date
bors
4dd8b420c0 Auto merge of #96521 - petrochenkov:docrules, r=notriddle,GuillaumeGomez
rustdoc: Resolve doc links referring to `macro_rules` items

cc https://github.com/rust-lang/rust/issues/81633

UPD: the fallback to considering *all* `macro_rules` in the crate for unresolved names is not removed in this PR, it will be removed separately and will be run through crater.
2022-05-01 20:28:10 +00:00
bors
61469b682c Auto merge of #96490 - dtolnay:writetmpbackport, r=Mark-Simulacrum
Make [e]println macros eagerly drop temporaries (for backport)

This PR extracts the subset of #96455 which is only the parts necessary for fixing the 1.61-beta regressions in #96434.

My larger PR #96455 contains a few other changes relative to the pre-#94868 behavior; those are not necessary to backport into 1.61.

argument position | before #94868 | after #94868 | after this PR
--- |:---:|:---:|:---:
`write!($tmp, "…", …)` | 😡 | 😡 | 😡
`write!(…, "…", $tmp)` | 😡 | 😡 | 😡
`writeln!($tmp, "…", …)` | 😡 | 😡 | 😡
`writeln!(…, "…", $tmp)` | 😡 | 😡 | 😡
`print!("…", $tmp)` | 😡 | 😡 | 😡
`println!("…", $tmp)` | 😺 | 😡 | 😺
`eprint!("…", $tmp)` | 😡 | 😡 | 😡
`eprintln!("…", $tmp)` | 😺 | 😡 | 😺
`panic!("…", $tmp)` | 😺 | 😺 | 😺
2022-05-01 03:18:53 +00:00
Vadim Petrochenkov
6083db7c4e Fix some links in the standard library 2022-05-01 00:02:34 +03:00
Dylan DPC
cd5dc49379
Rollup merge of #96492 - joshtriplett:revert-std-ffi-re-export, r=yaahc
Revert "Re-export core::ffi types from std::ffi"

This reverts commit 9aed829fe6.

Fixes https://github.com/rust-lang/rust/issues/96435 , a regression
in crates doing `use std::ffi::*;` and `use std::os::raw::*;`.

We can re-add this re-export once the `core::ffi` types
are stable, and thus the `std::os::raw` types can become re-exports as
well, which will avoid the conflict. (Type aliases to the same type
still conflict, but re-exports of the same type don't.)
2022-04-29 11:23:14 +02:00
Dylan DPC
db1ec25224
Rollup merge of #96481 - aDotInTheVoid:hashmap-docs-monospace, r=joshtriplett
HashMap doc: Don't use monospace font for 'Entry Api'
2022-04-29 11:23:13 +02:00
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
joboet
550273361d
std: simplify UNIX parker timeouts 2022-04-28 12:31:19 +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
Josh Triplett
07ea143f96 Revert "Re-export core::ffi types from std::ffi"
This reverts commit 9aed829fe6.

Fixes https://github.com/rust-lang/rust/issues/96435 , a regression
in crates doing `use std::ffi::*;` and `use std::os::raw::*;`.

We can re-add this re-export once the `core::ffi` types
are stable, and thus the `std::os::raw` types can become re-exports as
well, which will avoid the conflict. (Type aliases to the same type
still conflict, but re-exports of the same type don't.)
2022-04-27 14:01:04 -07:00
David Tolnay
3a8f81aac9
Make [e]println macros eagerly drop temporaries (for backport) 2022-04-27 13:22:41 -07:00
Nixon Enraght-Moony
d34f8d269a HashMap doc: Don't use monospace font for 'Entry Api' 2022-04-27 17:59:29 +01:00
Chris Denton
1e7c15634d
Note the importance of using sync pipes 2022-04-27 13:56:59 +01: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
Eric Huss
159b95d5bb Remove references to git.io 2022-04-25 17:05:58 -07: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
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
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
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
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
Geoffry Song
cff3f1e8d5 remove_dir_all_recursive: treat ELOOP the same as ENOTDIR 2022-04-20 00:50:03 +00: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
Scott Mabin
3569d43b50 espidf: fix stat
* corect type usage with new type definitions in libc
2022-04-19 17:00:09 +01:00
Mara Bos
06a8f05b0c Use futex locks on emscripten. 2022-04-19 09:24:51 +02:00
Mara Bos
8f2913cc24 Use futex locks on wasm+atomics. 2022-04-19 09:21:54 +02:00
Mara Bos
65987ae8f5 Make std::sys::wasm::futex consistent with unix::futex. 2022-04-19 09:21:54 +02:00
Mara Bos
6abdd0b6d4 Make std::sys::unix::futex consistent on emscripten. 2022-04-19 09:19:29 +02:00
Chris Morgan
0255398ff7 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-19 13:02:20 +10:00
Dan Gohman
890125d73e Add a comment explaining the (()) idiom for empty structs. 2022-04-18 16:53:50 -07:00
Dan Gohman
f934043c17 Split NotHandle into NullHandleError and InvalidHandleError.
Also, make the display messages more specific, and remove the `Copy`
implementation.
2022-04-18 16:53:50 -07:00
Dan Gohman
67994b77fd Move the Error impl for NotHandle out of platform-independent code. 2022-04-18 16:53:49 -07:00
Dan Gohman
5b3023c564 Fix an incorrect word in a comment. 2022-04-18 16:53:38 -07:00
Dan Gohman
703a33673d Define a dedicated error type for HandleOrNull and HandleOrInvalid.
Define a `NotHandle` type, that implements `std::error::Error`, and use
it as the error type in `HandleOrNull` and `HandleOrInvalid`.
2022-04-18 16:53:36 -07:00
bors
6fd7e9010d Auto merge of #96042 - m-ou-se:one-reentrant-mutex, r=Amanieu
Use a single ReentrantMutex implementation on all platforms.

This replaces all platform specific ReentrantMutex implementations by the one I added in #95727 for Linux, since that one does not depend on any platform specific details.

r? `@Amanieu`
2022-04-18 12:15:39 +00:00
Mara Bos
94f00e396a Remove forgotten reexport of ReentrantMutex in sys::unsupported. 2022-04-18 13:10:36 +02:00
CAD97
620c0a4d5b Replace sys/unix/weak AtomicUsize with AtomicPtr 2022-04-17 23:33:56 -05:00
bors
e27d9df431 Auto merge of #93530 - anonion0:pthread_sigmask_fix, r=JohnTitor
fix error handling for pthread_sigmask(3)

Errors from `pthread_sigmask(3)` were handled using `cvt()`, which expects a return value of `-1` on error and uses `errno`.
However, `pthread_sigmask(3)` returns `0` on success and an error number otherwise.

Fix it by replacing `cvt()` with `cvt_nz()`.
2022-04-17 22:54:55 +00:00
Ralf Sager
e6aafbc707 move import to fix warning with emscripten target 2022-04-17 09:42:15 +02:00
Erik Desjardins
b0d9c42c46 Revert "Auto merge of #94373 - erikdesjardins:getitinl, r=Mark-Simulacrum"
This reverts commit 035a717ee8, reversing
changes made to 761e888485.
2022-04-17 02:15:45 -04:00
dylni
fb9731ea13 Remove unnecessary function 2022-04-17 01:23:47 -04:00