about summary refs log tree commit diff
path: root/library/std
AgeCommit message (Collapse)AuthorLines
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-3/+3
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-17Keep the path after `program_exists` succeedsChris Denton-22/+23
2022-02-17Use verbatim paths for `process::Command` if necessaryChris Denton-13/+26
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-15removing architecture requirements for RustyHermitStefan Lankes-2/+2
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-14Maintain broken symlink behaviour for the Windows exe resolverChris Denton-2/+30
2022-02-13Make default stdio lock() return 'static handlesMark Rousskov-228/+18
This also deletes the unstable API surface area previously added to expose this functionality on new methods rather than built into the current set.
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-13Rollup merge of #89926 - the8472:saturate-instant, r=Mark-SimulacrumMatthias Krüger-267/+57
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-13Auto merge of #93696 - Amanieu:compiler-builtins-0.1.68, r=Mark-Simulacrumbors-1/+1
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-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```
2022-02-11Rollup merge of #93635 - GuillaumeGomez:missing-platform-spec-info, r=AmanieuMatthias Krüger-0/+10
Add missing platform-specific information on current_dir and set_current_dir Fixes #93598.
2022-02-11Rollup merge of #90955 - JohnTitor:os-error-123-as-invalid-input, r=m-ou-seMatthias Krüger-8/+8
Rename `FilenameTooLong` to `InvalidFilename` and also use it for Windows' `ERROR_INVALID_NAME` Address https://github.com/rust-lang/rust/issues/90940#issuecomment-970157931 `ERROR_INVALID_NAME` (i.e. "The filename, directory name, or volume label syntax is incorrect") happens if we pass an invalid filename, directory name, or label syntax, so mapping as `InvalidInput` is reasonable to me.
2022-02-11Auto merge of #90271 - adamgemmell:dev/feat-detect-stabilise, r=Amanieubors-6/+7
Stabilise `is_aarch64_feature_detected!` under `simd_aarch64` feature Initial implementation, looking for feedback on the approach here. https://github.com/rust-lang/rust/issues/86941 One point I noticed was that I haven't seen different "since" versions for the same feature - does this mean that other features can't be added to to the `simd_aarch64` feature once this is in stable? If so it might need a more specific name. r? `@Amanieu`
2022-02-11Add missing platform-specific information on current_dir and set_current_dirGuillaume Gomez-0/+10
2022-02-10Implement `AsFd` for `&T` and `&mut T`.Dan Gohman-1/+49
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`.
2022-02-10Move `is_aarch64_feature_detected!` to `simd_aarch64` feature and stabiliseAdam Gemmell-6/+7
2022-02-10Rename to `InvalidFilename`Yuki Okushi-9/+8
2022-02-10Fix description of FilenameInvalidJosh Triplett-1/+1
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2022-02-10Map `ERROR_INVALID_NAME` to `FilenameInvalid`Yuki Okushi-1/+2
2022-02-10Rename `FilenameTooLong` to `FilenameInvalid`Yuki Okushi-4/+4
2022-02-10windows: Map `ERROR_INVALID_NAME` as `InvalidInput`Yuki Okushi-1/+1
2022-02-10Rollup merge of #93843 - solid-rs:fix-kmc-solid-condvar, r=m-ou-seMatthias Krüger-4/+9
kmc-solid: Fix wait queue manipulation errors in the `Condvar` implementation This PR fixes a number of bugs in the `Condvar` wait queue implementation used by the [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets. These bugs can occur when there are multiple threads waiting on the same `Condvar` and sometimes manifest as an `unwrap` failure.
2022-02-10kmc-solid: Use the filesystem thread-safety wrapperTomoaki Kawada-1/+20
Neither the SOLID filesystem API nor built-in filesystems 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 `std` code to leverage the filesystem thread- safety wrapper 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-10kmc-solid: Wait queue should be sorted in the descending order of task ↵Tomoaki Kawada-1/+1
priorities In ITRON, lower priority values mean higher priorities.
2022-02-10kmc-solid: Fix wait queue manipulation errors in the `Condvar` implementationTomoaki Kawada-3/+8