about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2023-02-05Clarify wording on f64::round() and f32::round()Wilfred Hughes-4/+4
"Round half-way cases" is a little confusing (it's a 'garden path sentence' as it's not immediately clear whether round is an adjective or verb). Make this sentence longer and clearer.
2023-02-05Fix typo in HashMap::with_capacityKiran Shila-1/+1
2023-02-03Rollup merge of #107519 - joboet:raw_os_error_ty, r=AmanieuMichael Goulet-10/+26
Add type alias for raw OS errors Implement rust-lang/libs-team#173. `@rustbot` label +S-waiting-on-ACP +T-libs-api
2023-02-03Update library/std/src/io/mod.rsMichal Nazarewicz-4/+4
2023-02-03Specify behavior of HashSet::insertStiopa Koltsov-1/+23
`HashSet::insert` does not replace the value with equal value. Fixes #107581.
2023-02-01Stabilize feature 'cstr_from_bytes_until_nul'Trevor Gross-1/+0
2023-01-31Rollup merge of #107535 - dcompoze:tcp-doc-unwrap, r=cuviperGuillaume Gomez-1/+1
Replace unwrap with ? in TcpListener doc The example in TcpListener doc returns `std::io::Result<()>` but the code inside the function uses `unwrap()` instead of `?`.
2023-01-31Replace unwrap with ? in TcpListener docDaniel Chmielewski-1/+1
2023-01-31Auto merge of #107297 - Mark-Simulacrum:bump-bootstrap, r=pietroalbinibors-2/+2
Bump bootstrap compiler to 1.68 This also changes our stage0.json to include the rustc component for the rustfmt pinned nightly toolchain, which is currently necessary due to rustfmt dynamically linking to that toolchain's librustc_driver and libstd. r? `@pietroalbini`
2023-01-31std: add type alias for raw OS errorsjoboet-10/+26
Implement rust-lang/libs-team#173.
2023-01-31fix link in std::path::Path::display()Lucius Hu-0/+1
The link `Debug` points to should be the trait `Debug`, not the macro `Debug`.
2023-01-30Auto merge of #107080 - Urgau:cleanup-bootstrap-extra-check-cfgs, ↵bors-8/+1
r=Mark-Simulacrum bootstrap: cleanup the list of extra check cfgs This PR performs some cleanups on the `EXTRA_CHECK_CFGS` list in bootstrap. - `target_os=watchos`: no longer relevant because there are now proper targets `*-apple-watchos` - `target_arch=nvptx64`: target `nvptx64-nvidia-cuda` makes it useless - `target_arch=le32`: target was removed (https://github.com/rust-lang/rust/pull/45041) - `release`: was removed from rustfmt (https://github.com/rust-lang/rustfmt/pull/5375 and https://github.com/rust-lang/rustfmt/pull/5449) - `dont_compile_me`: was removed from stdarch (https://github.com/rust-lang/stdarch/pull/1308) Also made some external cfg exception mode clear and only activated for rustc and rustc tools (as to not have the Standard Library unintentionally depend on them).
2023-01-29Rollup merge of #107431 - notriddle:notriddle/colon, r=thomccMatthias Krüger-1/+1
docs: remove colon from time header It's not used anywhere else; the inconsistency is weird.
2023-01-29Rollup merge of #107154 - glaubitz:m68k-alloc, r=JohnTitorMatthias Krüger-0/+1
library/std/sys_common: Define MIN_ALIGN for m68k-unknown-linux-gnu This PR adds the missing definition of MIN_ALIGN for the m68k-unknown-linux target.
2023-01-29Rollup merge of #106618 - jmillikin:os-net-rustdoc-wasm32, r=JohnTitorMatthias Krüger-0/+9
Disable `linux_ext` in wasm32 and fortanix rustdoc builds. The `std::os::unix` module is stubbed out when building docs for these target platforms. The introduction of Linux-specific extension traits caused `std::os::net` to depend on sub-modules of `std::os::unix`, which broke rustdoc for the `wasm32-unknown-unknown` target. Adding an additional `#[cfg]` guard solves that rustdoc failure by not declaring `linux_ext` on targets with a stubbed `std::os::unix`. Fixes #105467
2023-01-28docs: remove colon from time headerMichael Howell-1/+1
It's not used anywhere else; the inconsistency is weird.
2023-01-28Rollup merge of #105524 - Ayush1325:libc-free, r=ChrisDentonMatthias Krüger-9/+10
Replace libc::{type} with crate::ffi::{type} Replace libc::{type} imports with crate::ffi::{type} outside of `std::sys` and `std::os`. Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-01-28Rollup merge of #104252 - faern:stabilize-const_socketaddr, r=JohnTitorMatthias Krüger-14/+13
Stabilize the const_socketaddr feature Stabilizes `#![feature(const_socketaddr)]`. Tracking issue: #82485 Closes #82485 This has been unstably const for over a year now. And the code change simplifying the constness of the `new` constructors has been in stable Rust since 1.64 (a bit over a full release cycle). I'm not aware of any blockers to this stabilization.
2023-01-28Replace libc::{type} with crate::ffi::{type}Ayush Singh-9/+10
Replace libc::{type} imports with crate::ffi::{type} outside of `std::sys` and `std::os`. Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-01-27std: add safety comment in `LazyLock::get`joboet-1/+8
2023-01-27std: fix `Debug` implementation on `LazyLock`joboet-8/+5
2023-01-26Implement `AsFd` and `AsRawFd` for `Rc`Ian Douglas Scott-0/+16
Fixes https://github.com/rust-lang/rust/issues/105931.
2023-01-26std: optimize `LazyLock` sizejoboet-17/+116
2023-01-26Rollup merge of #106836 - ibraheemdev:sync-sender-spin, r=AmanieuMatthias Krüger-23/+7
Remove optimistic spinning from `mpsc::SyncSender` Per https://github.com/rust-lang/rust/pull/106701#issuecomment-1381649679. Closes #106804 r? `@Amanieu`
2023-01-26Rollup merge of #106779 - RReverser:patch-2, r=Mark-SimulacrumMatthias Krüger-8/+3
Avoid __cxa_thread_atexit_impl on Emscripten - Fixes https://github.com/rust-lang/rust/issues/91628. - Fixes https://github.com/emscripten-core/emscripten/issues/15722. See discussion in both issues. The TL;DR is that weak linkage causes LLVM to produce broken Wasm, presumably due to pointer mismatch. The code is casting a void pointer to a function pointer with specific signature, but Wasm is very strict about function pointer compatibility, so the resulting code is invalid. Ideally LLVM should catch this earlier in the process rather than emit invalid Wasm, but it currently doesn't and this is an easy and valid fix, given that Emcripten doesn't have `__cxa_thread_atexit_impl` these days anyway. Unfortunately, I can't add a regression test as even after looking into this issue for a long time, I couldn't reproduce it with any minimal Rust example, only with extracted LLVM IR or on a large project involving Rust + C++.
2023-01-25Stabilize the const_socketaddr featureLinus Färnstrand-14/+13
2023-01-25Set version placeholders to 1.68Mark Rousskov-2/+2
2023-01-25Remove outdated cfg on `le32`Urgau-8/+1
See https://github.com/rust-lang/rust/pull/45041 for the removal of the target (le32-unknown-nacl).
2023-01-24io: soften ‘at most one write attempt’ requirement in io::Write::writeMichal Nazarewicz-5/+6
At the moment, documentation of std::io::Write::write indicates that call to it ‘represents at most one attempt to write to any wrapped object’. It seems that such wording was put there to contrast it with pre-1.0 interface which attempted to write all the data (it has since been changed in [RFC 517]). However, the requirement puts unnecessary constraints and may complicate adaptors which perform non-trivial transformations on the data. For example, they may maintain an internal buffer which needs to be written out before the write method accepts more data. It might be natural to code the method such that it flushes the buffer and then grabs another chunk of user data. With the current wording in the documentation, the adaptor would be forced to return Ok(0). This commit softens the wording such that implementations can choose code structure which makes most sense for their particular use case. While at it, elaborate on the meaning of `Ok(0)` return pointing out that the write_all methods interprets it as an error. [RFC 517]: https://rust-lang.github.io/rfcs/0517-io-os-reform.html
2023-01-23Auto merge of #106981 - joboet:std_remove_box_syntax, r=thomccbors-59/+35
Do not use box syntax in `std` See #94970 and #49733. About half of the `box` instances in `std` do not even need to allocate, the other half can simply be replaced with `Box::new`. `@rustbot` label +T-libs r? rust-lang/libs
2023-01-22Rollup merge of #107180 - nvzqz:rm-fmt-ref, r=joshtriplettMatthias Krüger-9/+9
Remove unnecessary `&format!` These were likely from before the `PartialEq<str>` impl for `&String`.
2023-01-22Rollup merge of #107114 - Erk-:add-absolute-note-to-path-join, r=m-ou-seMatthias Krüger-0/+3
Add note about absolute paths to Path::join The note already exists on `PathBuf::push`, but I think it is good to have it on `Path::join` as well since it can cause issues if you are not careful with your input.
2023-01-21Remove unnecessary `&format!`Nikolai Vazquez-9/+9
These were likely from before the `PartialEq<str>` impl for `&String`.
2023-01-21library/std/sys_common: Define MIN_ALIGN for m68k-unknown-linux-gnuJohn Paul Adrian Glaubitz-0/+1
2023-01-20add example of joining with a absolute pathValdemar Erk-0/+1
2023-01-20Add note about absolute paths to Path::joinValdemar Erk-0/+2
2023-01-18signal update string representation for haiku.David Carlier-0/+2
2023-01-18Rollup merge of #106441 - mllken:abstract-socket-noref, r=joshtriplettDylan DPC-2/+2
relax reference requirement on SocketAddrExt::from_abstract_name Reference: https://github.com/rust-lang/rust/issues/85410#issuecomment-1369544671
2023-01-17Rollup merge of #106148 - chenyukang:yukang/fix-105061-unused, r=lcnrDylan DPC-4/+4
Fix unused_parens issue for higher ranked function pointers fixes #105061 r? `@lcnr`
2023-01-17refactor[std]: do not use box syntaxjoboet-59/+35
2023-01-16Explain the "no-error" io::Error caseJubilee Young-2/+16
Fundamentally, querying the OS for error codes is a process that is deeply subject to the whims of chance and fortune. We can account for OS, but not for every combination of platform APIs. A compiled binary may not recognize new errors introduced years later. We should clarify a few especially odd situations, and what they mean: We can effectively promise nothing. This allows removing mention of ErrorKind::Uncategorized. That error variant is hidden quite deliberately, so we should not explicitly mention it.
2023-01-15Rollup merge of #106867 - sunfishcode:sunfishcode/std-os-fd-stable-version, ↵Matthias Krüger-3/+3
r=m-ou-se Fix the stability attributes for `std::os::fd`. As `@bjorn3` pointed out [here], I used the wrong stability attribute in #98368 when making `std::os::fd` public. I set it to Rust 1.63, which was when io-safety was stabilized, but it should be Rust 1.66, which was when `std::os::fd` was stabilized. [here]: https://github.com/rust-lang/rust/pull/98368#discussion_r1063721420
2023-01-14Fix the stability attributes for `std::os::fd`.Dan Gohman-3/+3
As @bjorn3 pointed out [here], I used the wrong stability attribute in #98368 when making `std::os::fd` public. I set it to Rust 1.63, which was when io-safety was stabilized, but it should be Rust 1.66, which was when `std::os::fd` was stabilized. [here]: https://github.com/rust-lang/rust/pull/98368#discussion_r1063721420
2023-01-14Rollup merge of #106860 - anden3:doc-double-spaces, r=Dylan-DPCMatthias Krüger-35/+35
Remove various double spaces in the libraries. I was just pretty bothered by this when reading the source for a function, and was suggested to check if this happened elsewhere.
2023-01-14Rollup merge of #106661 - mjguzik:linux_statx, r=Mark-SimulacrumMatthias Krüger-27/+41
Stop probing for statx unless necessary As is the current toy program: fn main() -> std::io::Result<()> { use std::fs; let metadata = fs::metadata("foo.txt")?; assert!(!metadata.is_dir()); Ok(()) } ... observed under strace will issue: [snip] statx(0, NULL, AT_STATX_SYNC_AS_STAT, STATX_ALL, NULL) = -1 EFAULT (Bad address) statx(AT_FDCWD, "foo.txt", AT_STATX_SYNC_AS_STAT, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0644, stx_size=0, ...}) = 0 While statx is not necessarily always present, checking for it can be delayed to the first error condition. Said condition may very well never happen, in which case the check got avoided altogether. Note this is still suboptimal as there still will be programs issuing it, but bulk of the problem is removed. Tested by forbidding the syscall for the binary and observing it correctly falls back to newfstatat. While here tidy up the commentary, in particular by denoting some problems with the current approach.
2023-01-14Fix some missed double spaces.André Vennberg-1/+1
2023-01-14Remove various double spaces in source comments.André Vennberg-34/+34
2023-01-14Re-add #[allow(unused)] attrIngvar Stepanyan-0/+1
2023-01-14Use associated items of `char` instead of freestanding items in `core::char`Lukas Markeffsky-5/+4
2023-01-14fix issues in unused lintyukang-4/+4