Commit graph

2763 commits

Author SHA1 Message Date
bstrie 9aed829fe6 Re-export core::ffi types from std::ffi 2022-03-02 13:52:31 -05:00
Josh Triplett 335c9609c6 Provide C FFI types via core::ffi, not just in std
The ability to interoperate with C code via FFI is not limited to crates
using std; this allows using these types without std.

The existing types in `std::os::raw` become type aliases for the ones in
`core::ffi`. This uses type aliases rather than re-exports, to allow the
std types to remain stable while the core types are unstable.

This also moves the currently unstable `NonZero_` variants and
`c_size_t`/`c_ssize_t`/`c_ptrdiff_t` types to `core::ffi`, while leaving
them unstable.
2022-03-01 17:16:05 -08:00
Dylan DPC 06d47a414b
Rollup merge of #94094 - chrisnc:tcp-nodelay-windows-bool, r=dtolnay
use BOOL for TCP_NODELAY setsockopt value on Windows

This issue was found by the Wine project and mitigated there [^1].

Windows' setsockopt expects a BOOL (a typedef for int) for TCP_NODELAY
[^2]. Windows itself is forgiving and will accept any positive optlen and
interpret the first byte of *optval as the value, so this bug does not
affect Windows itself, but does affect systems implementing Windows'
interface more strictly, such as Wine. Wine was previously passing this
through to the host's setsockopt, where, e.g., Linux requires that
optlen be correct for the chosen option, and TCP_NODELAY expects an int.

[^1]: d6ea38f32d
[^2]: https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-setsockopt
2022-03-01 03:41:50 +01:00
bors 035a717ee8 Auto merge of #94373 - erikdesjardins:getitinl, r=Mark-Simulacrum
Make TLS __getit #[inline(always)] on non-Windows

This may improve perf, and/or stop `externs` perf benchmarks from being flaky.

r? `@ghost`
2022-02-27 01:23:48 +00:00
Erik Desjardins 2d6d30f4a8 Make TLS __getit #[inline(always)] on non-Windows
This may improve perf.
2022-02-25 15:21:27 -05:00
bors d981633ed6 Auto merge of #94290 - Mark-Simulacrum:bump-bootstrap, r=pietroalbini
Bump bootstrap to 1.60

This bumps the bootstrap compiler to 1.60 and cleans up cfgs and Span's rustc_pass_by_value (enabled by the bootstrap bump).
2022-02-25 18:34:02 +00:00
Mark Rousskov 22c3a71de1 Switch bootstrap cfgs 2022-02-25 08:00:52 -05:00
Jethro Beekman 355d503ace Fix SGX docs build 2022-02-25 12:12:37 +01:00
Matthias Krüger aa0b7ac0bf
Rollup merge of #94273 - Dylan-DPC:doc/errorkind, r=joshtriplett
add matching doc to errorkind

Rework of #90706
2022-02-24 07:48:07 +01:00
Dylan DPC 3f4b039e33 word wrpa 2022-02-24 00:37:06 +01:00
Dylan DPC eb795c24fb word wrpa 2022-02-24 00:30:07 +01:00
Dylan DPC c46d9f6c89
Update library/std/src/io/error.rs
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2022-02-23 23:18:42 +01:00
Dylan DPC 057dc09eae add some more summary from pr discussion 2022-02-23 03:29:02 +01:00
Dylan DPC 37cbc7d120 add some more summary from pr discussion 2022-02-23 03:28:27 +01:00
Dylan DPC 4905814249 add matching to errorkind 2022-02-23 03:22:23 +01:00
NyantasticUwU c61d5923f2
Fix typo.
Yeah just a typo (probably some breaking changes in here be careful) :)
2022-02-22 11:44:45 -06:00
Matthias Krüger 21fb81405e
Rollup merge of #94179 - devnexen:getexecname_directcall, r=kennytm
solarish current_exe using libc call directly
2022-02-22 12:16:30 +01:00
Matthias Krüger ed3530925e
Rollup merge of #94220 - GuillaumeGomez:miniz-oxide-decl, r=Amanieu
Correctly handle miniz_oxide extern crate declaration

Fixes https://github.com/rust-lang/rust/issues/94219.

Follow-up of https://github.com/rust-lang/rust/pull/94122.

The `miniz_oxide` dependency is optional and therefore should allow be "imported" when it makes sense.

r? `@ivmarkov`
2022-02-21 19:36:55 +01:00
Matthias Krüger 12705b4700
Rollup merge of #91192 - r00ster91:futuredocs, r=GuillaumeGomez
Some improvements to the async docs

The goal here is to make the docs overall a little bit more comprehensive and add more links between the things.

One thing that's not working yet is the links to the keywords. Somehow I couldn't get them to work.

r? ````@GuillaumeGomez```` do you know how I could get the keyword links to work?
2022-02-21 19:36:46 +01:00
Guillaume Gomez 910d46fd60 Correctly handle miniz_oxide extern crate declaration 2022-02-21 17:27:55 +01:00
Chris Copeland b02698c7e6
use BOOL for TCP_NODELAY setsockopt value on Windows
This issue was found by the Wine project and mitigated there [1].

Windows' documented interface for `setsockopt` expects a `BOOL` (a
`typedef` for `int`) for `TCP_NODELAY` [2]. Windows is forgiving and
will accept any positive length and interpret the first byte of
`*option_value` as the value, so this bug does not affect Windows
itself, but does affect systems implementing Windows' interface more
strictly, such as Wine. Wine was previously passing this through to the
host's `setsockopt`, where, e.g., Linux requires that `option_len` be
correct for the chosen option, and `TCP_NODELAY` expects an `int`.

[1]: d6ea38f32d
[2]: https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-setsockopt
2022-02-20 21:27:36 -08:00
Chris Copeland f2ebd0a11f
Remove assertion on output length for getsockopt.
POSIX allows `getsockopt` to set `*option_len` to a smaller value if
necessary. Windows will set `*option_len` to 1 for boolean options even
when the caller passes a `BOOL` (`int`) with `*option_len` as 4.
2022-02-20 21:27:36 -08:00
Chris Copeland 3eb983ed99
Fix setsockopt and getsockopt parameter names.
Previously `level` was named `opt` and `option_name` was named `val`,
then extra names of `payload` or `slot` were used for the option value.
This change aligns the wrapper parameters with their names in POSIX.
Winsock uses similar but more abbreviated names: `level`, `optname`,
`optval`, `optlen`.
2022-02-20 21:27:22 -08:00
David Carlier f810314bc6 solarish current_exe using libc call directly 2022-02-20 08:53:18 +00:00
Matthias Krüger a69aaf4aee
Rollup merge of #94122 - GuillaumeGomez:miniz-oxide-std, r=notriddle
Fix miniz_oxide types showing up in std docs

Fixes #90526.

Thanks to ```````@camelid,``````` I rediscovered `doc(masked)`, allowing us to prevent `miniz_oxide` type to show up in std docs.

r? ```````@notriddle```````
2022-02-20 00:37:32 +01:00
Matthias Krüger 6b69121d0d
Rollup merge of #94019 - hermitcore:target, r=Mark-Simulacrum
removing architecture requirements for RustyHermit

RustHermit and HermitCore is able to run on aarch64 and x86_64. In the future these operating systems will also support RISC-V. Consequently, the dependency to a specific target should be removed.

The build process of `hermit-abi` fails if the architecture isn't supported.
2022-02-20 00:37:25 +01:00
Matthias Krüger 7977af5975
Rollup merge of #93580 - m-ou-se:stabilize-pin-static-ref, r=scottmcm
Stabilize pin_static_ref.

FCP finished here: https://github.com/rust-lang/rust/issues/78186#issuecomment-1024987221

Closes #78186
2022-02-20 00:37:21 +01:00
r00ster91 297364eb07 Some improvements to the async docs 2022-02-19 17:17:40 +01:00
bors e08d569360 Auto merge of #94148 - matthiaskrgr:rollup-jgea68f, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #92902 (Improve the documentation of drain members)
 - #93658 (Stabilize `#[cfg(panic = "...")]`)
 - #93954 (rustdoc-json: buffer output)
 - #93979 (Add debug assertions to validate NUL terminator in c strings)
 - #93990 (pre #89862 cleanup)
 - #94006 (Use a `Field` in `ConstraintCategory::ClosureUpvar`)
 - #94086 (Fix ScalarInt to char conversion)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-02-19 12:15:10 +00:00
Matthias Krüger 26dd6ac830
Rollup merge of #93979 - SUPERCILEX:debug_check, r=dtolnay
Add debug assertions to validate NUL terminator in c strings

The `unchecked` variants from the stdlib usually perform the check anyway if debug assertions are on (for example, `unwrap_unchecked`). This PR does the same thing for `CStr` and `CString`, validating the correctness for the NUL byte in debug mode.
2022-02-19 06:45:30 +01:00
Matthias Krüger 4fa71ed0f0
Rollup merge of #92902 - ssomers:docter_drain, r=yaahc
Improve the documentation of drain members

hopefully fixes #92765
2022-02-19 06:45:28 +01:00
bors cb4ee81ef5 Auto merge of #94105 - 5225225:destabilise-entry-insert, r=Mark-Simulacrum
Destabilise entry_insert

See: https://github.com/rust-lang/rust/pull/90345

I didn't revert the rename that was done in that PR, I left it as `entry_insert`.

Additionally, before that PR, `VacantEntry::insert_entry` seemingly had no stability attribute on it? I kept the attribute, just made it an unstable one, same as the one on `Entry`.

There didn't seem to be any mention of this in the RELEASES.md, so I don't think there's anything for me to do other than this?
2022-02-19 05:08:13 +00:00
Stein Somers a677e60840 Collections: improve the documentation of drain members 2022-02-19 00:55:31 +01:00
Matthias Krüger 724cca6d7f
Rollup merge of #93847 - solid-rs:fix-kmc-solid-fs-ts, r=yaahc
kmc-solid: Use the filesystem thread-safety wrapper

Fixes the thread unsafety of the `std::fs` implementation used by the [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets.

Neither the SOLID filesystem API nor built-in filesystem drivers guarantee thread safety by default. Although this may suffice in general embedded-system use cases, and in fact the API can be used from multiple threads without any problems in many cases, this has been a source of unsoundness in `std::sys::solid::fs`.

This commit updates the implementation to leverage the filesystem thread-safety wrapper (which uses a pluggable synchronization mechanism) to enforce thread safety. This is done by prefixing all paths passed to the filesystem API with `\TS`. (Note that relative paths aren't supported in this platform.)
2022-02-18 23:23:07 +01:00
Guillaume Gomez b78123cdcf Fix miniz_oxide types showing up in std 2022-02-18 17:31:38 +01:00
Matthias Krüger f1c918f1f3
Rollup merge of #93613 - crlf0710:rename_to_async_iter, r=yaahc
Move `{core,std}::stream::Stream` to `{core,std}::async_iter::AsyncIterator`

Following amendments in https://github.com/rust-lang/rfcs/pull/3208/.

cc #79024
cc ``@yoshuawuyts`` ``@joshtriplett``
2022-02-18 16:23:32 +01:00
5225225 319dd150fc Destabilise entry_insert 2022-02-17 22:23:31 +00:00
Matthias Krüger 09350d2cf0
Rollup merge of #93976 - SUPERCILEX:separator_str, r=yaahc
Add MAIN_SEPARATOR_STR

Currently, if someone needs access to the path separator as a str, they need to go through this mess:

```rust
unsafe {
    std::str::from_utf8_unchecked(slice::from_ref(&(MAIN_SEPARATOR as u8)))
}
```

This PR just re-exports an existing path separator str API.
2022-02-17 23:00:58 +01:00
Matthias Krüger 1cc0ae4cbb
Rollup merge of #89869 - kpreid:from-doc, r=yaahc
Add documentation to more `From::from` implementations.

For users looking at documentation through IDE popups, this gives them relevant information rather than the generic trait documentation wording “Performs the conversion”. For users reading the documentation for a specific type for any reason, this informs them when the conversion may allocate or copy significant memory versus when it is always a move or cheap copy.

Notes on specific cases:
* The new documentation for `From<T> for T` explains that it is not a conversion at all.
* Also documented `impl<T, U> Into<U> for T where U: From<T>`, the other central blanket implementation of conversion.
* The new documentation for construction of maps and sets from arrays of keys mentions the handling of duplicates. Future work could be to do this for *all* code paths that convert an iterable to a map or set.
* I did not add documentation to conversions of a specific error type to a more general error type.
* I did not add documentation to unstable code.

This change was prepared by searching for the text "From<... for" and so may have missed some cases that for whatever reason did not match. I also looked for `Into` impls but did not find any worth documenting by the above criteria.
2022-02-17 06:29:57 +01:00
Alex Saveau 80fde23a75
Add MAIN_SEPARATOR_STR
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2022-02-16 19:38:12 -08:00
Alex Saveau 897c8d0ab9
Add debug asserts to validate NUL terminator in c strings
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2022-02-16 18:34:17 -08:00
Stefan Lankes 227d106aec remove compiler warnings 2022-02-15 14:03:26 +01:00
Stefan Lankes 1ab5b0bc05 removing architecture requirements for RustyHermit
RustHermit and HermitCore is able to run on aarch64 and x86_64.
In the future these operating systems will also support RISC-V.
Consequently, the dependency to a specific target should be removed.
Building hermit-abi fails if the architecture isn't supported.
2022-02-15 13:57:07 +01:00
Chris Denton 9a7a8b9255
Maintain broken symlink behaviour for the Windows exe resolver 2022-02-14 12:50:18 +00:00
bors 1f4681ad7a Auto merge of #91673 - ChrisDenton:path-absolute, r=Mark-Simulacrum
`std::path::absolute`

Implements #59117 by adding a `std::path::absolute` function that creates an absolute path without reading the filesystem. This is intended to be a drop-in replacement for [`std::fs::canonicalize`](https://doc.rust-lang.org/std/fs/fn.canonicalize.html) in cases where it isn't necessary to resolve symlinks. It can be used on paths that don't exist or where resolving symlinks is unwanted. It can also be used to avoid circumstances where `canonicalize` might otherwise fail.

On Windows this is a wrapper around [`GetFullPathNameW`](https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfullpathnamew). On Unix it partially implements the POSIX [pathname resolution](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13) specification, stopping just short of actually resolving symlinks.
2022-02-13 12:03:52 +00:00
Matthias Krüger 92613a25fc
Rollup merge of #89926 - the8472:saturate-instant, r=Mark-Simulacrum
make `Instant::{duration_since, elapsed, sub}` saturating and remove workarounds

This removes all mutex/atomic-based workarounds for non-monotonic clocks and makes the previously panicking methods saturating instead. Additionally `saturating_duration_since` becomes deprecated since `duration_since` now fills that role.

Effectively this moves the fixup from `Instant` construction to the comparisons.

This has some observable effects, especially on platforms without monotonic clocks:

* Incorrectly ordered Instant comparisons no longer panic in release mode. This could hide some programming errors, but since debug mode still panics tests can still catch them.
* `checked_duration_since` will now return `None` in more cases. Previously it only happened when one compared instants obtained in the wrong order or manually created ones. Now it also does on backslides.
* non-monotonic intervals will not be transitive, i.e. `b.duration_since(a) + c.duration_since(b) != c.duration_since(a)`

The upsides are reduced complexity and lower overhead of `Instant::now`.

## Motivation

Currently we must choose between two poisons. One is high worst-case latency and jitter of `Instant::now()` due to explicit synchronization; see #83093 for benchmarks, the worst-case overhead is > 100x. The other is sporadic panics on specific, rare combinations of CPU/hypervisor/operating system due to platform bugs.

Use-cases where low-overhead, fine-grained timestamps are needed - such as syscall tracing, performance profiles or sensor data acquisition (drone flight controllers were mentioned in a libs meeting) in multi-threaded programs - are negatively impacted by the synchronization.

The panics are user-visible (program crashes), hard to reproduce and can be triggered by any dependency that might be using Instants for any reason.

A solution that is fast _and_ doesn't panic is desirable.

----

closes #84448
closes #86470
2022-02-13 06:44:12 +01:00
bors 01c4c41301 Auto merge of #93696 - Amanieu:compiler-builtins-0.1.68, r=Mark-Simulacrum
Bump compiler-builtins to 0.1.69

This includes https://github.com/rust-lang/compiler-builtins/pull/452 which should fix some issues with duplicate symbol defintions of some intrinsics.
2022-02-13 02:40:56 +00:00
Josh Triplett 37a1fc542f Capitalize "Rust"
Co-authored-by: Mark Rousskov <mark.simulacrum@gmail.com>
2022-02-13 01:06:36 +01:00
The 8472 376d955a32 Add panic docs describing old, current and possible future behavior 2022-02-13 01:06:34 +01:00
The 8472 bda2693e9b Add caveat about the monotonicity guarantee by linking to the later section 2022-02-13 01:05:00 +01:00