about summary refs log tree commit diff
path: root/library/std
AgeCommit message (Collapse)AuthorLines
2023-02-11Auto merge of #106677 - tbu-:pr_less_doc_hidden_pub, r=scottmcmbors-4/+0
Remove a couple of `#[doc(hidden)] pub fn` and their `#[feature]` gates
2023-02-11Rollup merge of #107900 - ChrisDenton:zero-header, r=thomccDylan DPC-0/+2
Zero the `REPARSE_MOUNTPOINT_DATA_BUFFER` header Makes sure the full header is correctly initialized. Fixes #107884
2023-02-11Rollup merge of #106001 - sdroege:glibc-skip-over-null-argv, r=ChrisDentonDylan DPC-6/+22
Stop at the first `NULL` argument when iterating `argv` Some C commandline parsers (e.g. GLib and Qt) are replacing already handled arguments in `argv` with `NULL` and move them to the end. That means that `argc` might be bigger than the actual number of non-`NULL` pointers in `argv` at this point. To handle this we simply stop iterating at the first `NULL` argument. `argv` is also guaranteed to be `NULL`-terminated so any non-`NULL` arguments after the first `NULL` can safely be ignored. Fixes https://github.com/rust-lang/rust/issues/105999
2023-02-10Rename atomic 'as_mut_ptr' to 'as_ptr' to match Cell (ref #66893)Trevor Gross-3/+3
2023-02-10Drop llvm14-builtins-abi with compiler_builtins 0.1.87Josh Stone-1/+1
2023-02-10Zero the `REPARSE_MOUNTPOINT_DATA_BUFFER` headerChris Denton-0/+2
Makes sure the full header is correctly initialized, including reserve parameters.
2023-02-10Remove a couple of `#[doc(hidden)] pub fn` and their `#[feature]` gatesTobias Bucher-4/+0
2023-02-09Allow wasi-libc to initialize its environment variables lazily.Dan Gohman-1/+7
Use `__wasilibc_get_environ()` to read the environment variable list from wasi-libc instead of using `environ`. `environ` is a global variable which effectively requires wasi-libc to initialize the environment variables eagerly, and `__wasilibc_get_environ()` is specifically designed to be an alternative that lets wasi-libc intiailize its environment variables lazily. This should have the side effect of fixing at least some of the cases of #107635.
2023-02-08Rollup merge of #107429 - tgross35:from-bytes-until-null-stabilization, ↵Michael Goulet-1/+0
r=dtolnay Stabilize feature `cstr_from_bytes_until_nul` This PR seeks to stabilize `cstr_from_bytes_until_nul`. Partially addresses #95027 This function has only been on nightly for about 10 months, but I think it is simple enough that there isn't harm discussing stabilization. It has also had at least a handful of mentions on both the user forum and the discord, so it seems like it's already in use or at least known. This needs FCP still. Comment on potential discussion points: - eventual conversion of `CStr` to be a single thin pointer: this function will still be useful to provide a safe way to create a `CStr` after this change. - should this return a length too, to address concerns about the `CStr` change? I don't see it as being particularly useful, and it seems less ergonomic (i.e. returning `Result<(&CStr, usize), FromBytesUntilNulError>`). I think users that also need this length without the additional `strlen` call are likely better off using a combination of other methods, but this is up for discussion - `CString::from_vec_until_nul`: this is also useful, but it doesn't even have a nightly implementation merged yet. I propose feature gating that separately, as opposed to blocking this `CStr` implementation on that Possible alternatives: A user can use `from_bytes_with_nul` on a slice up to `my_slice[..my_slice.iter().find(|c| c == 0).unwrap()]`. However; that is significantly less ergonomic, and is a bit more work for the compiler to optimize compared the direct `memchr` call that this wraps. ## New stable API ```rs // both in core::ffi pub struct FromBytesUntilNulError(()); impl CStr { pub const fn from_bytes_until_nul( bytes: &[u8] ) -> Result<&CStr, FromBytesUntilNulError> } ``` cc ```@ericseppanen``` original author, ```@Mark-Simulacrum``` original reviewer, ```@m-ou-se``` brought up some issues on the thin pointer CStr ```@rustbot``` modify labels: +T-libs-api +needs-fcp
2023-02-08Rollup merge of #107317 - ids1024:asfd-rc, r=dtolnayMichael Goulet-0/+16
Implement `AsFd` and `AsRawFd` for `Rc` Fixes https://github.com/rust-lang/rust/issues/105931.
2023-02-08std: add tracking issue for `RawOsError`joboet-2/+2
2023-02-06Rollup merge of #107714 - Wilfred:round_docs, r=m-ou-seMatthias Krüger-4/+4
Clarify wording on f64::round() and f32::round() "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-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-27Rollup merge of #105784 - yanns:update_stdarch, r=AmanieuYuki Okushi-3/+3
update stdarch This will allow using miri on simd instructions https://github.com/rust-lang/stdarch/issues/1347#issuecomment-1353664361
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-26fix alphabetical sortYann Simon-3/+3
2023-01-26remove avx512 prefix for gfni, vaes and vpclmulqdqYann Simon-3/+3
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