about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2023-04-14Add Lazy{Cell,Lock}::into_innerAlex Saveau-1/+37
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2023-04-14Rollup merge of #110244 - kadiwa4:unnecessary_imports, r=JohnTitorMatthias Krüger-46/+23
Remove some unneeded imports / qualified paths Continuation of #105537.
2023-04-14Rollup merge of #110154 - DaniPopes:library-typos, r=JohnTitorMatthias Krüger-3/+3
Fix typos in library I ran [`typos -w library`](https://github.com/crate-ci/typos) to fix typos in the `library` directory. Refs #110150
2023-04-14Rollup merge of #109272 - schneems:schneems/add-docs-to-command-env-methods, ↵Matthias Krüger-15/+61
r=Amanieu Add Command environment variable inheritance docs The interaction between the environment variable methods can be confusing. Specifically `env_clear` and `remove_env` have a side effects not mentioned: they disable inheriting environment variables from the parent process. I wanted to fully document this behavior as well as explain relevant edge cases in each of the `Command` env methods. This is further confused by the return of `get_envs` which will return key/None if `remove_env` has been used, but an empty iterator if `env_clear` has been called. Or a non-empty iterator if `env_clear` was called and later explicit mappings are added. Currently there is no way (that I'm able to find) of observing whether or not the internal `env_clear=true` been toggled on the `Command` struct via its public API. Ultimately environment variable mappings can be in one of several states: - Explicitly set value (via `envs` / `env`) will take precedence over parent mapping - Not explicitly set, will inherit mapping from parent - Explicitly removed via `remove_env`, this single mapping will not inherit from parent - Implicitly removed via `env_clear`, no mappings will inherit from parent I tried to represent this in the relevant sections of the docs. This is my second-ever doc PR (whoop!). I'm happy to take specific or general doc feedback. Also happy to explain the logic behind any changes or additions I made.
2023-04-14Rollup merge of #110292 - scottmcm:sort-features-2, r=jyn514Yuki Okushi-7/+19
Add `tidy-alphabetical` to features in `alloc` & `std` So that people have to keep them sorted in future, rather than just sticking them on the end where they conflict more often. Follow-up to #110269 cc `@jyn514`
2023-04-14Rollup merge of #110047 - skaunov:patch-1, r=ChrisDentonYuki Okushi-2/+5
Add link to `collections` docs to `extend` trait I believe it would be useful here.
2023-04-14Add links to docs to `Iterator`Sergey Kaunov-2/+5
and couple of its methods
2023-04-14Auto merge of #110311 - matthiaskrgr:rollup-kn2k5bq, r=matthiaskrgrbors-5/+10
Rollup of 9 pull requests Successful merges: - #109225 (Clarify that RUST_MIN_STACK may be internally cached) - #109800 (Improve safe transmute error reporting) - #110158 (Remove obsolete test case) - #110180 (don't uniquify regions when canonicalizing) - #110207 (Assemble `Unpin` candidates specially for generators in new solver) - #110276 (Remove all but one of the spans in `BoundRegionKind::BrAnon`) - #110279 (rustdoc: Correctly handle built-in compiler proc-macros as proc-macro and not macro) - #110298 (Cover edge cases for {f32, f64}.hypot() docs) - #110299 (Switch to `EarlyBinder` for `impl_subject` query) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-04-14Rollup merge of #110298 - jmaargh:jmaargh/hypot-docs-edge-cases, r=thomccMatthias Krüger-4/+8
Cover edge cases for {f32, f64}.hypot() docs Fixes #88944 The Euclidean distance is a more general way to express what these functions do, and covers the edge cases of zero and negative inputs. Does not cover the case of non-normal input values (as the [POSIX docs](https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/) do), but the docs for the rest of the functions in these modules do not address this, I assumed it was not desired.
2023-04-14Rollup merge of #109225 - seanlinsley:patch-1, r=ChrisDentonMatthias Krüger-1/+2
Clarify that RUST_MIN_STACK may be internally cached For larger applications it's important that users set `RUST_MIN_STACK` at the start of their program because [`min_stack`](https://github.com/rust-lang/rust/blob/7d3e03666a93bd2b0f78b3933f9305832af771a5/library/std/src/sys_common/thread.rs) caches the value. Not doing so can lead to their `env::set_var` call surprisingly not having any effect. In my own testing `RUST_MIN_STACK` had no effect until I moved it to the top of `main()`. Hopefully this clarification in the docs will help others going forward.
2023-04-14Auto merge of #105007 - dlaugt:solaris-fs-link, r=ChrisDentonbors-3/+4
linkat() not available in the system headers of Solaris 10 I've installed rustup on x86_64-unknown-linux-gnu and would like to use the target sparcv9-sun-solaris. For this, I have built a gcc from the source code for cross-compiling to sparcv9-sun-solaris2.10 with system headers of Solaris 10. With the following hello word example: main.rs: ```rust fn main() { println!("Hello, world!"); } ``` I had a compilation error: ``` $ rustc -v --target sparcv9-sun-solaris -C linker=/opt/cross-solaris/gcc730/bin/sparcv9-sun-solaris2.10-gcc main.rs error: linking with `/opt/cross-solaris/gcc730/bin/sparcv9-sun-solaris2.10-gcc` failed: exit status: 1 | = note: "/opt/cross-solaris/gcc730/bin/sparcv9-sun-solaris2.10-gcc" "-m64" "/tmp/rustcgebYgj/symbols.o" "main.main.89363361-cgu.0.rcgu.o" "main.main.89363361-cgu.1.rcgu.o" "main.main.89363361-cgu.2.rcgu.o" "main.main.89363361-cgu.3.rcgu.o" "main.main.89363361-cgu.4.rcgu.o" "main.main.89363361-cgu.5.rcgu.o" "main.csypsau9u2r8348.rcgu.o" "-Wl,-z,ignore" "-L" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib" "-Wl,-Bstatic" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libstd-fa47c8247d587714.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libpanic_unwind-5c87bbe223e6c2a3.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libobject-d484934062ff9fbb.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libmemchr-e8dbd5835abcbf43.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libaddr2line-909ad09329bde2f9.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libgimli-4d74a3be929697ac.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/librustc_demangle-47cbe1d7f7271ae1.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libstd_detect-239fd2d25fb32a00.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libhashbrown-c4a7ce45fb9dec19.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libminiz_oxide-fa6bc3d9bfb4e402.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libadler-419f5a82ddd339a3.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/librustc_std_workspace_alloc-7672b378962c11be.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libunwind-0f9e07f0a032c000.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libcfg_if-ede7757c356dfb28.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/liblibc-808d56fbc668148a.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/liballoc-784767fe059ad3fe.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/librustc_std_workspace_core-aa31d7ef0556bbe1.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libcore-81d07df07db18847.rlib" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libcompiler_builtins-313a510e63006db2.rlib" "-Wl,-Bdynamic" "-lsocket" "-lposix4" "-lpthread" "-lresolv" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lsendfile" "-llgrp" "-L" "/home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib" "-o" "main" "-nodefaultlibs" = note: /opt/cross-solaris/gcc730/lib/gcc/sparcv9-sun-solaris2.10/7.3.0/../../../../sparcv9-sun-solaris2.10/bin/ld: warning: -z ignore ignored. /home/dlaugt/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/sparcv9-sun-solaris/lib/libstd-fa47c8247d587714.rlib(std-fa47c8247d587714.std.5c42d2c1-cgu.0.rcgu.o): In function `std::sys::unix::fs::link::h3683dfbfbb4995cb': /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sys/unix/fs.rs:1407: undefined reference to `linkat' collect2: error: ld returned 1 exit status = help: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified = note: use the `-l` flag to specify native libraries to link = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname) ``` linkat() is not available in the system headers of Solaris 10. The hello word example works fine when I build/use rust with this PR change.
2023-04-13Update documentation wording on path 'try_exists' functionsTrevor Gross-6/+9
2023-04-13Cover edge cases for {f32, f64}.hypot() docsjmaargh-4/+8
Re-phrase in a way that handles input values being either 0 or negative.
2023-04-13Rollup merge of #110233 - nbdd0121:intrinsic, r=tmiaskoMatthias Krüger-0/+1
Make rust-intrinsic ABI unwindable Fix #104451, fix https://github.com/rust-lang/miri/issues/2839 r? `@RalfJung`
2023-04-13Add `tidy-alphabetical` to features in `alloc` & `std`Scott McMurray-7/+19
So that people have to keep them sorted in future, rather than just sticking them on the end where they conflict more often.
2023-04-13Document catch_fn in r#try cannot unwindGary Guo-0/+1
2023-04-13Rollup merge of #110072 - joshtriplett:stabilize-is-terminal, r=Mark-SimulacrumMatthias Krüger-6/+6
Stabilize IsTerminal FCP completed in https://github.com/rust-lang/rust/issues/98070 . closes: https://github.com/rust-lang/rust/issues/98070
2023-04-13Auto merge of #108283 - the8472:remove-splice-into-pipe, r=ChrisDentonbors-16/+88
don't splice from files into pipes in io::copy This fixes potential data ordering issue where a write performed after a copy operation could become visible in the copy even though it signaled completion. I assumed that by not setting `SPLICE_F_MOVE` we would be safe and the kernel would do a copy in kernel space and we could avoid the read-write syscall and copy-to/from-userspace costs. But apparently that flag only makes a difference when splicing from a pipe, but not when splicing into it. Context: https://lkml.org/lkml/2023/2/9/673
2023-04-12Rollup merge of #110089 - petrosagg:mpsc-ub, r=m-ou-seMatthias Krüger-0/+12
sync::mpsc: synchronize receiver disconnect with initialization Receiver disconnection relies on the incorrect assumption that `head.index != tail.index` implies that the channel is initialized (i.e `head.block` and `tail.block` point to allocated blocks). However, it can happen that `head.index != tail.index` and `head.block == null` at the same time which leads to a segfault when a channel is dropped in that state. This can happen because initialization is performed in two steps. First, the tail block is allocated and the `tail.block` is set. If that is successful `head.block` is set to the same pointer. Importantly, initialization is skipped if `tail.block` is not null. Therefore we can have the following situation: 1. Thread A starts to send the first value of the channel, observes that `tail.block` is null and begins initialization. It sets `tail.block` to point to a newly allocated block and then gets preempted. `head.block` is still null at this point. 2. Thread B starts to send the second value of the channel, observes that `tail.block` *is not* null and proceeds with writing its value in the allocated tail block and sets `tail.index` to 1. 3. Thread B drops the receiver of the channel which observes that `head.index != tail.index` (0 and 1 respectively), therefore there must be messages to drop. It starts traversing the linked list from `head.block` which is still a null pointer, leading to a segfault. This PR fixes this problem by waiting for initialization to complete when `head.index != tail.index` and the `head.block` is still null. A similar check exists in `start_recv` for similar reasons. Fixes #110001
2023-04-12remove some unneeded importsKaDiWa-46/+23
2023-04-11Rollup merge of #110173 - solid-rs:patch/kmc-solid/socket-read-buf, r=cuviperMichael Goulet-6/+17
kmc-solid: Implement `Socket::read_buf` Follow-up to #108326. Implements `Socket::read_buf` for the [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets.
2023-04-11Rollup merge of #109894 - ↵Michael Goulet-12/+5
fleetingbytes:109893-var_os-never-returns-an-error, r=cuviper Remove Errors section from var_os docs Remove `Errors` section from `var_os` documentation, fixes #109893
2023-04-11Rollup merge of #96971 - zhaixiaojuan:master, r=wesleywiserMichael Goulet-0/+6
Initial support for loongarch64-unknown-linux-gnu Hi, We hope to add a new port in rust for LoongArch. LoongArch intro LoongArch is a RISC style ISA which is independently designed by Loongson Technology in China. It is divided into two versions, the 32-bit version (LA32) and the 64-bit version (LA64). LA64 applications have application-level backward binary compatibility with LA32 applications. LoongArch is composed of a basic part (Loongson Base) and an expanded part. The expansion part includes Loongson Binary Translation (LBT), Loongson VirtualiZation (LVZ), Loongson SIMD EXtension (LSX) and Loongson Advanced SIMD EXtension(LASX). Currently the LA464 processor core supports LoongArch ISA and the Loongson 3A5000 processor integrates 4 64-bit LA464 cores. LA464 is a four-issue 64-bit high-performance processor core. It can be used as a single core for high-end embedded and desktop applications, or as a basic processor core to form an on-chip multi-core system for server and high-performance machine applications. Documentations: ISA: https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html ABI: https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html More docs can be found at: https://loongson.github.io/LoongArch-Documentation/README-EN.html Since last year, we have locally adapted two versions of rust, rust1.41 and rust1.57, and completed the test locally. I'm not sure if I'm submitting all the patches at once, so I split up the patches and here's one of the commits
2023-04-11clarify wording around spurious wakeups from `thread::park`Ibraheem Ahmed-2/+2
2023-04-11kmc-solid: Implement `Socket::read_buf`Tomoaki Kawada-6/+17
2023-04-11Break up long first paragraphfleetingbytes-3/+4
Further referring to `var_os` as a "function" (like in `var`), rather than "method".
2023-04-10Fix typos in libraryDaniPopes-3/+3
2023-04-10Stabilize IsTerminalJosh Triplett-6/+6
closes: https://github.com/rust-lang/rust/issues/98070
2023-04-09Apply suggestions from code review Richard Schneeman-1/+1
Fixes documentation. I wrote `env_clear` when I meant `env_remove`. Good catch. Co-authored-by: Josh Stone <cuviper@gmail.com>
2023-04-09Auto merge of #109500 - petrochenkov:modchainld, r=oli-obkbors-0/+2
resolve: Preserve reexport chains in `ModChild`ren This may be potentially useful for - avoiding uses of `hir::ItemKind::Use` (which usually lead to correctness issues) - preserving documentation comments on all reexports, including those from other crates - preserving and checking stability/deprecation info on reexports - all kinds of diagnostics The second commit then migrates some hacky logic from rustdoc to `module_reexports` to make it simpler and more correct. Ideally rustdoc should use `module_reexports` immediately at the top level, so `hir::ItemKind::Use`s are never used. The second commit also fixes issues with https://github.com/rust-lang/rust/pull/109330 and therefore Fixes https://github.com/rust-lang/rust/issues/109631 Fixes https://github.com/rust-lang/rust/issues/109614 Fixes https://github.com/rust-lang/rust/issues/109424
2023-04-09Rollup merge of #110060 - WaffleLapkin:sync_refs, r=jyn514Yuki Okushi-0/+1
Document that `&T` and `&mut T` are `Sync` if `T` is Proof: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=fec8dc9ec36e873bf2962a2367d67045
2023-04-08Add 64-bit `time_t` support on 32-bit glibc Linux to `set_times`beetrees-2/+39
2023-04-08sync::mpsc: synchronize receiver disconnect with initializationPetros Angelatos-0/+12
Receiver disconnection relies on the incorrect assumption that `head.index != tail.index` implies that the channel is initialized (i.e `head.block` and `tail.block` point to allocated blocks). However, it can happen that `head.index != tail.index` and `head.block == null` at the same time which leads to a segfault when a channel is dropped in that state. This can happen because initialization is performed in two steps. First, the tail block is allocated and the `tail.block` is set. If that is successful `head.block` is set to the same pointer. Importantly, initialization is skipped if `tail.block` is not null. Therefore we can have the following situation: 1. Thread A starts to send the first value of the channel, observes that `tail.block` is null and begins initialization. It sets `tail.block` to point to a newly allocated block and then gets preempted. `head.block` is still null at this point. 2. Thread B starts to send the second value of the channel, observes that `tail.block` *is not* null and proceeds with writing its value in the allocated tail block and sets `tail.index` to 1. 3. Thread B drops the receiver of the channel which observes that `head.index != tail.index` (0 and 1 respectively), therefore there must be messages to drop. It starts traversing the linked list from `head.block` which is still a null pointer, leading to a segfault. This PR fixes this problem by waiting for initialization to complete when `head.index != tail.index` and the `head.block` is still null. A similar check exists in `start_recv` for similar reasons. Fixes #110001 Signed-off-by: Petros Angelatos <petrosagg@gmail.com>
2023-04-08std: Mark two reexports that should be inlined as `doc(inline)`Vadim Petrochenkov-0/+2
2023-04-08Auto merge of #109995 - ↵bors-1/+1
enkron:u/enkron/substitute-hardcoded-port-num-in-listen-on-fn, r=the8472 chore(tcp): change a hardcoded port number in a doctest to `port` var The `listen_on` function in the example has a `port` option but doesn't use it
2023-04-08fix(tcp): remove redundant `format!` macro callSergei Belokon-1/+1
2023-04-07Document that `&T` and `&mut T` are `Sync` if `T` isMaybe Waffle-0/+1
2023-04-08Define UNWIND_DATA_REG for loongarch64zhaixiaojuan-0/+3
2023-04-07Don't claim LocalKey::with prevents a reference to be sent across threadsGiacomo Stevanato-2/+2
2023-04-07Auto merge of #110019 - jplatte:jplatte/stabilize-is-some-and, r=Amanieubors-1/+0
Stabilize is_some_and This stabilizes the following public API: ```rust impl<T> Option<T> { pub fn is_some_and(self, f: impl FnOnce(T) -> bool) -> bool; } impl<T, E> Result<T, E> { pub fn is_ok_and(self, f: impl FnOnce(T) -> bool) -> bool; pub fn is_err_and(self, f: impl FnOnce(E) -> bool) -> bool; } ``` Closes #93050 (tracking issue). `@rustbot` label +T-libs-api -T-libs
2023-04-07Auto merge of #109990 - gwy15:remove-bufwriter-useless-mut-pointer, r=jyn514bors-1/+1
Remove an unnecessary `mut` in `BufWriter::into_parts`. `ptr::read` takes `*const T` so `&mut` is not necessary.
2023-04-07Rollup merge of #109960 - thomcc:symlink-junction-buffer-overrun, r=ChrisDentonMatthias Krüger-9/+25
Fix buffer overrun in bootstrap and (test-only) symlink_junction I don't think these can be hit in practice, due to their inputs being valid paths. It's also not security-sensitive code, but just... bad vibes. I think this is still not really the right way to do this (in terms of path correctness), but is no worse than it was. r? `@ChrisDenton`
2023-04-07Rollup merge of #109806 - Zoxc:gnu-tls, r=pnkfelixMatthias Krüger-1/+3
Workaround #109797 on windows-gnu The addition of `#[inline]` here in https://github.com/rust-lang/rust/pull/108089 caused an unrelated linking issue (https://github.com/rust-lang/rust/issues/109797). This PR removes this attribute again on Windows to avoid regressions.
2023-04-06Stabilize is_some_andJonas Platte-1/+0
2023-04-06chore(tcp): change the hardcoded port number to `port` varSergei Belokon-1/+1
The `listen_on` function in the example has a `port` option but doesn't use it
2023-04-06Remove an unnecessary `mut` in `BufWriter::into_parts`.管唯宇-1/+1
`ptr::read` takes `*const T` so `&mut` is not necessary.
2023-04-05Fix buffer overrun in (test-only) symlink_junctionThom Chiovoloni-9/+25
2023-04-04library/std: Add support for loongarch64zhaixiaojuan-0/+3
2023-04-03avoid zero-copy ops for File->Pipe and File->Socket in io::copyThe 8472-16/+46
2023-04-03test that modifications to the source don't become visible after io::copyThe 8472-0/+42