about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2022-03-01Provide C FFI types via core::ffi, not just in stdJosh Triplett-220/+27
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-01Rollup merge of #94094 - chrisnc:tcp-nodelay-windows-bool, r=dtolnayDylan DPC-11/+26
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]: https://source.winehq.org/git/wine.git/commit/d6ea38f32dfd3edbe107a255c37e9f7f3da06ae7 [^2]: https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-setsockopt
2022-02-27Auto merge of #94373 - erikdesjardins:getitinl, r=Mark-Simulacrumbors-2/+2
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-25Make TLS __getit #[inline(always)] on non-WindowsErik Desjardins-2/+2
This may improve perf.
2022-02-25Auto merge of #94290 - Mark-Simulacrum:bump-bootstrap, r=pietroalbinibors-21/+20
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-25Switch bootstrap cfgsMark Rousskov-21/+20
2022-02-25Fix SGX docs buildJethro Beekman-1/+1
2022-02-24Rollup merge of #94273 - Dylan-DPC:doc/errorkind, r=joshtriplettMatthias Krüger-0/+13
add matching doc to errorkind Rework of #90706
2022-02-24word wrpaDylan DPC-5/+5
2022-02-24word wrpaDylan DPC-6/+9
2022-02-23Update library/std/src/io/error.rsDylan DPC-1/+1
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2022-02-23add some more summary from pr discussionDylan DPC-1/+1
2022-02-23add some more summary from pr discussionDylan DPC-2/+4
2022-02-23add matching to errorkindDylan DPC-0/+8
2022-02-22Fix typo.NyantasticUwU-1/+1
Yeah just a typo (probably some breaking changes in here be careful) :)
2022-02-22Rollup merge of #94179 - devnexen:getexecname_directcall, r=kennytmMatthias Krüger-4/+1
solarish current_exe using libc call directly
2022-02-21Rollup merge of #94220 - GuillaumeGomez:miniz-oxide-decl, r=AmanieuMatthias Krüger-0/+1
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-21Rollup merge of #91192 - r00ster91:futuredocs, r=GuillaumeGomezMatthias Krüger-6/+8
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-21Correctly handle miniz_oxide extern crate declarationGuillaume Gomez-0/+1
2022-02-20use `BOOL` for `TCP_NODELAY` `setsockopt` value on WindowsChris Copeland-2/+2
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]: https://source.winehq.org/git/wine.git/commit/d6ea38f32dfd3edbe107a255c37e9f7f3da06ae7 [2]: https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-setsockopt
2022-02-20Remove assertion on output length for `getsockopt`.Chris Copeland-1/+0
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-20Fix `setsockopt` and `getsockopt` parameter names.Chris Copeland-9/+25
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-20solarish current_exe using libc call directlyDavid Carlier-4/+1
2022-02-20Rollup merge of #94122 - GuillaumeGomez:miniz-oxide-std, r=notriddleMatthias Krüger-0/+4
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-20Rollup merge of #94019 - hermitcore:target, r=Mark-SimulacrumMatthias Krüger-1/+1
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-20Rollup merge of #93580 - m-ou-se:stabilize-pin-static-ref, r=scottmcmMatthias Krüger-1/+0
Stabilize pin_static_ref. FCP finished here: https://github.com/rust-lang/rust/issues/78186#issuecomment-1024987221 Closes #78186
2022-02-19Some improvements to the async docsr00ster91-6/+8
2022-02-19Auto merge of #94148 - matthiaskrgr:rollup-jgea68f, r=matthiaskrgrbors-21/+39
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-19Rollup merge of #93979 - SUPERCILEX:debug_check, r=dtolnayMatthias Krüger-20/+29
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-19Rollup merge of #92902 - ssomers:docter_drain, r=yaahcMatthias Krüger-1/+10
Improve the documentation of drain members hopefully fixes #92765
2022-02-19Auto merge of #94105 - 5225225:destabilise-entry-insert, r=Mark-Simulacrumbors-2/+4
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-19Collections: improve the documentation of drain membersStein Somers-1/+10
2022-02-18Rollup merge of #93847 - solid-rs:fix-kmc-solid-fs-ts, r=yaahcMatthias Krüger-1/+20
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-18Fix miniz_oxide types showing up in stdGuillaume Gomez-0/+4
2022-02-18Rollup merge of #93613 - crlf0710:rename_to_async_iter, r=yaahcMatthias Krüger-3/+3
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-17Destabilise entry_insert5225225-2/+4
2022-02-17Rollup merge of #93976 - SUPERCILEX:separator_str, r=yaahcMatthias Krüger-0/+6
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-17Rollup merge of #89869 - kpreid:from-doc, r=yaahcMatthias Krüger-7/+30
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-16Add MAIN_SEPARATOR_STRAlex Saveau-0/+6
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2022-02-16Add debug asserts to validate NUL terminator in c stringsAlex Saveau-20/+29
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2022-02-15remove compiler warningsStefan Lankes-1/+1
2022-02-14Maintain broken symlink behaviour for the Windows exe resolverChris Denton-2/+30
2022-02-13Auto merge of #91673 - ChrisDenton:path-absolute, r=Mark-Simulacrumbors-4/+209
`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-13Capitalize "Rust"Josh Triplett-1/+1
Co-authored-by: Mark Rousskov <mark.simulacrum@gmail.com>
2022-02-13Add panic docs describing old, current and possible future behaviorThe 8472-3/+31
2022-02-13Add caveat about the monotonicity guarantee by linking to the later sectionThe 8472-2/+4
2022-02-13make Instant::{duration_since, elapsed, sub} saturating and remove workaroundsThe8472-270/+30
This removes all mutex/atomics based workarounds for non-monotonic clocks and makes the previously panicking methods saturating instead. Effectively this moves the monotonization from `Instant` construction to the comparisons. This has some observable effects, especially on platforms without monotonic clocks: * Incorrectly ordered Instant comparisons no longer panic. This may hide some programming errors until someone actually looks at the resulting `Duration` * `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. The upside is reduced complexity and lower overhead of `Instant::now`.
2022-02-12Auto merge of #93697 - the8472:fix-windows-path-hash, r=Mark-Simulacrumbors-9/+52
Fix hashing for windows paths containing a CurDir component * the logic only checked for / but not for \ * verbatim paths shouldn't skip items at all since they don't get normalized * the extra branches get optimized out on unix since is_sep_byte is a trivial comparison and is_verbatim is always-false * tests lacked windows coverage for these cases That lead to equal paths not having equal hashes and to unnecessary collisions.
2022-02-11Auto merge of #93921 - matthiaskrgr:rollup-wn3jlxj, r=matthiaskrgrbors-9/+67
Rollup of 10 pull requests Successful merges: - #90955 (Rename `FilenameTooLong` to `InvalidFilename` and also use it for Windows' `ERROR_INVALID_NAME`) - #91607 (Make `span_extend_to_prev_str()` more robust) - #92895 (Remove some unused functionality) - #93635 (Add missing platform-specific information on current_dir and set_current_dir) - #93660 (rustdoc-json: Add some tests for typealias item) - #93782 (Split `pauth` target feature) - #93868 (Fix incorrect register conflict detection in asm!) - #93888 (Implement `AsFd` for `&T` and `&mut T`.) - #93909 (Fix typo: explicitely -> explicitly) - #93910 (fix mention of moved function in `rustc_hir` docs) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-02-11Rollup merge of #93888 - sunfishcode:sunfishcode/impl-asfd-for-ref, ↵Matthias Krüger-1/+49
r=joshtriplett Implement `AsFd` for `&T` and `&mut T`. Add implementations of `AsFd` for `&T` and `&mut T`, so that users can write code like this: ```rust pub fn fchown<F: AsFd>(fd: F, uid: Option<u32>, gid: Option<u32>) -> io::Result<()> { ``` with `fd: F` rather than `fd: &F`. And similar for `AsHandle` and `AsSocket` on Windows. Also, adjust the `fchown` example to pass the file by reference. The code can work either way now, but passing by reference is more likely to be what users will want to do. This is an alternative to #93869, and is a simpler way to achieve the same goals: users don't need to pass borrowed-`BorrowedFd` arguments, and it prevents a pitfall in the case where users write `fd: F` instead of `fd: &F`. r? ```@joshtriplett```