about summary refs log tree commit diff
path: root/library/std
AgeCommit message (Collapse)AuthorLines
2023-05-30add FromOwnedFd/FromOwnedHandle for ChildStdin/out/errVincent Thiberville-2/+71
2023-05-30Swap out CURRENT_RUSTC_VERSION to 1.71.0Mark Rousskov-6/+6
2023-05-27Rework handling of recursive panicsAmanieu d'Antras-53/+67
2023-05-26Fix incorrect documented default bufsize in bufreader/writerKathryn R-2/+2
2023-05-26Rollup merge of #111940 - zirconium-n:io-read-doc-change, r=thomccMatthias Krüger-3/+4
Clarify safety concern of `io::Read::read` is only relevant in unsafe code We have this clarification note in other similar place like [Iterator::size_hint](https://doc.rust-lang.org/stable/std/iter/trait.Iterator.html#method.size_hint). The lack of clarification might lead to confusion to Rust beginners. [Relevant URLO post](https://users.rust-lang.org/t/can-read-overflow-a-buffer/94347).
2023-05-25std: make `fortanix-sgx-abi` a public depedencenyMichael Howell-1/+1
It's exported publicly, so it should not be linted.
2023-05-25std: make internal-only items `pub(crate)`Michael Howell-5/+5
This works around a weird problem that looks like a bug in the `exported_private_dependencies` lint.
2023-05-25std: mark common functions in test crate `pub(crate)`Michael Howell-6/+4
This is not a library, so there's no reason for them to be `pub`. Without doing this, compiling the test crates causes private dep lint errors: error: type `PathBuf` from private dependency 'std' in public interface --> library/std/tests/common/mod.rs:26:5 | 26 | pub fn join(&self, path: &str) -> PathBuf { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D exported-private-dependencies` implied by `-D warnings` error: type `Path` from private dependency 'std' in public interface --> library/std/tests/common/mod.rs:31:5 | 31 | pub fn path(&self) -> &Path { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: could not compile `std` (test "create_dir_all_bare") due to 2 previous errors This happens because Cargo passes `--extern 'priv:std=...` when compiling the test crate. I'm not sure if these warnings are desirable or not. They seem correct in a very pedantic way (the dependency on `std` is not marked public, since it's implicit), but also pointless (the test crate is not an API, so who cares what it does).
2023-05-25bootstrap: enable Cargo `public-dependency` feature for `libstd`Michael Howell-4/+8
2023-05-25Clarify safety concern of `io::Read::read` is only relevant in unsafe codeZiru Niu-3/+4
2023-05-23Roll compiler_builtins to 0.1.92danakj-1/+1
This pulls in the weak-intrinsics feature (which currently defaults off), and a minor version update to libm for the compiler_builtins crate to 0.2.7.
2023-05-23Rollup merge of #111609 - LegionMammal978:internal-unsafe, r=thomccDylan DPC-4/+7
Mark internal functions and traits unsafe to reflect preconditions No semantics are changed in this PR; I only mark some functions and and a trait `unsafe` which already had implicit preconditions. Although it seems somewhat redundant for `numfmt::Part::Copy` to contain a `&[u8]` instead of a `&str`, given that all of its current consumers ultimately expect valid UTF-8. Is the type also intended to work for byte-slice formatting in the future?
2023-05-19docs: Add missing periodEd Page-1/+1
2023-05-19Auto merge of #109773 - beetrees:set-file-time-improvements, r=Amanieubors-28/+196
Add creation time support to `FileTimes` on apple and windows Adds support for setting file creation times on platforms which support changing it directly (currently only Apple and Windows). Based on top of #110093 (which was split from this PR). ACP: rust-lang/libs-team#199 (currently still in progress) Tracking issue: #98245 `@rustbot` label +T-libs-api -T-libs
2023-05-19Auto merge of #111590 - dtolnay:panictemporaries, r=bjorn3bors-2/+2
Shorten even more panic temporary lifetimes Followup to #104134. As pointed out by `@bjorn3` in https://github.com/rust-lang/rust/pull/104134#pullrequestreview-1425585948, there are other cases in the panic macros which would also benefit from dropping their non-Send temporaries as soon as possible, avoiding pointlessly holding them across an await point. For the tests added in this PR, here are the failures you get today on master without the macro changes in this PR: <details> <summary>tests/ui/macros/panic-temporaries-2018.rs</summary> ```console error: future cannot be sent between threads safely --> tests/ui/macros/panic-temporaries-2018.rs:52:18 | LL | require_send(panic_display()); | ^^^^^^^^^^^^^^^ future returned by `panic_display` is not `Send` | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `*const u8` note: future is not `Send` as this value is used across an await --> tests/ui/macros/panic-temporaries-2018.rs:35:31 | LL | f(panic!("{}", NOT_SEND)).await; | -------- ^^^^^- `NOT_SEND` is later dropped here | | | | | await occurs here, with `NOT_SEND` maybe used later | has type `NotSend` which is not `Send` note: required by a bound in `require_send` --> tests/ui/macros/panic-temporaries-2018.rs:48:25 | LL | fn require_send(_: impl Send) {} | ^^^^ required by this bound in `require_send` error: future cannot be sent between threads safely --> tests/ui/macros/panic-temporaries-2018.rs:52:18 | LL | require_send(panic_display()); | ^^^^^^^^^^^^^^^ future returned by `panic_display` is not `Send` | = help: within `NotSend`, the trait `Sync` is not implemented for `*const u8` note: future is not `Send` as this value is used across an await --> tests/ui/macros/panic-temporaries-2018.rs:35:31 | LL | f(panic!("{}", NOT_SEND)).await; | ---------------------- ^^^^^- the value is later dropped here | | | | | await occurs here, with the value maybe used later | has type `&NotSend` which is not `Send` note: required by a bound in `require_send` --> tests/ui/macros/panic-temporaries-2018.rs:48:25 | LL | fn require_send(_: impl Send) {} | ^^^^ required by this bound in `require_send` error: future cannot be sent between threads safely --> tests/ui/macros/panic-temporaries-2018.rs:53:18 | LL | require_send(panic_str()); | ^^^^^^^^^^^ future returned by `panic_str` is not `Send` | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `*const u8` note: future is not `Send` as this value is used across an await --> tests/ui/macros/panic-temporaries-2018.rs:40:36 | LL | f(panic!((NOT_SEND, "...").1)).await; | -------- ^^^^^- `NOT_SEND` is later dropped here | | | | | await occurs here, with `NOT_SEND` maybe used later | has type `NotSend` which is not `Send` note: required by a bound in `require_send` --> tests/ui/macros/panic-temporaries-2018.rs:48:25 | LL | fn require_send(_: impl Send) {} | ^^^^ required by this bound in `require_send` error: future cannot be sent between threads safely --> tests/ui/macros/panic-temporaries-2018.rs:54:18 | LL | require_send(unreachable_display()); | ^^^^^^^^^^^^^^^^^^^^^ future returned by `unreachable_display` is not `Send` | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `*const u8` note: future is not `Send` as this value is used across an await --> tests/ui/macros/panic-temporaries-2018.rs:45:31 | LL | f(unreachable!(NOT_SEND)).await; | -------- ^^^^^- `NOT_SEND` is later dropped here | | | | | await occurs here, with `NOT_SEND` maybe used later | has type `NotSend` which is not `Send` note: required by a bound in `require_send` --> tests/ui/macros/panic-temporaries-2018.rs:48:25 | LL | fn require_send(_: impl Send) {} | ^^^^ required by this bound in `require_send` error: future cannot be sent between threads safely --> tests/ui/macros/panic-temporaries-2018.rs:54:18 | LL | require_send(unreachable_display()); | ^^^^^^^^^^^^^^^^^^^^^ future returned by `unreachable_display` is not `Send` | = help: within `NotSend`, the trait `Sync` is not implemented for `*const u8` note: future is not `Send` as this value is used across an await --> tests/ui/macros/panic-temporaries-2018.rs:45:31 | LL | f(unreachable!(NOT_SEND)).await; | ---------------------- ^^^^^- the value is later dropped here | | | | | await occurs here, with the value maybe used later | has type `&NotSend` which is not `Send` note: required by a bound in `require_send` --> tests/ui/macros/panic-temporaries-2018.rs:48:25 | LL | fn require_send(_: impl Send) {} | ^^^^ required by this bound in `require_send` error: aborting due to 5 previous errors ``` </details> <details> <summary>tests/ui/macros/panic-temporaries.rs</summary> ```console error: future cannot be sent between threads safely --> tests/ui/macros/panic-temporaries.rs:42:18 | LL | require_send(panic_display()); | ^^^^^^^^^^^^^^^ future returned by `panic_display` is not `Send` | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `*const u8` note: future is not `Send` as this value is used across an await --> tests/ui/macros/panic-temporaries.rs:35:31 | LL | f(panic!("{}", NOT_SEND)).await; | -------- ^^^^^- `NOT_SEND` is later dropped here | | | | | await occurs here, with `NOT_SEND` maybe used later | has type `NotSend` which is not `Send` note: required by a bound in `require_send` --> tests/ui/macros/panic-temporaries.rs:38:25 | LL | fn require_send(_: impl Send) {} | ^^^^ required by this bound in `require_send` error: future cannot be sent between threads safely --> tests/ui/macros/panic-temporaries.rs:42:18 | LL | require_send(panic_display()); | ^^^^^^^^^^^^^^^ future returned by `panic_display` is not `Send` | = help: within `NotSend`, the trait `Sync` is not implemented for `*const u8` note: future is not `Send` as this value is used across an await --> tests/ui/macros/panic-temporaries.rs:35:31 | LL | f(panic!("{}", NOT_SEND)).await; | ---------------------- ^^^^^- the value is later dropped here | | | | | await occurs here, with the value maybe used later | has type `&NotSend` which is not `Send` note: required by a bound in `require_send` --> tests/ui/macros/panic-temporaries.rs:38:25 | LL | fn require_send(_: impl Send) {} | ^^^^ required by this bound in `require_send` error: aborting due to 2 previous errors ``` </details> r? bjorn3
2023-05-18Add tracking issue ID for `bufread_skip_until` feature gateWilliam Venner-1/+1
2023-05-18Move `BufRead::skip_until` test to a more appropriate locationWilliam Venner-28/+28
2023-05-18Add `BufRead::skip_until` testWilliam Venner-0/+28
2023-05-18Auto merge of #111710 - Dylan-DPC:rollup-eutrx54, r=Dylan-DPCbors-0/+18
Rollup of 7 pull requests Successful merges: - #110884 (Support RISC-V unaligned-scalar-mem target feature) - #111160 (Update serde in workspace and non-synced dependencies) - #111168 (Specialize ToString implementation for fmt::Arguments) - #111527 (add examples of port 0 binding behavior) - #111561 (Include better context for "already exists" error in compiletest) - #111633 (Avoid `&format("...")` calls in error message code.) - #111679 (Remove libs message about ACPs from triagebot) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-05-18Rollup merge of #111527 - knickish:bind_port_0_documentation, r=Mark-SimulacrumDylan DPC-0/+18
add examples of port 0 binding behavior Was trying to find the method to specify the IP address but not the port, and there wasn't information easily accessible about it in the `TcpListener` or `SocketAddr`. Adding examples to `TcpListener` and `UdpSocket` for clarity.
2023-05-17docs: Clarify OsStr is self-synchronizingEd Page-7/+15
2023-05-17Fix #107910, Shorten backtraces in ICEsyukang-5/+6
2023-05-16docs: Add examples of OsStr safety violationEd Page-4/+7
2023-05-16Auto merge of #111134 - GilShoshan94:remove-send-bound-on-error, r=dtolnaybors-3/+3
Remove unnecessary Send bound Hi, While working on a [PR on Tokio](https://github.com/tokio-rs/tokio/pull/5666), I took inspiration from the std channel mpsc and stumbled on a `Send` bound for a `Error` impl. Tokio's maintainer `@Darksonn` pointed out to me that `Error` used to required the `Send` bound long time ago (here https://github.com/rust-lang/rust/pull/23541). In the meantime, the `Send` bound `Error` got removed (see https://github.com/rust-lang/rust/pull/21312 and https://github.com/rust-lang/rust/pull/23799). So here a PR to removed this bound for `SendError<T>`, `TrySendError<T>` and `SendTimeoutError<T>`.
2023-05-15Mark internal functions and traits unsafeLegionMammal978-4/+7
2023-05-15Rollup merge of #110049 - SkiFire13:localkey-with-docs-fix, r=workingjubileeMatthias Krüger-2/+2
Don't claim `LocalKey::with` prevents a reference to be sent across threads The documentation for `LocalKey` claims that `with` yields a reference that cannot be sent across threads, but this is false since you can easily do that with scoped threads. What it actually prevents is the reference from outliving the current thread.
2023-05-15Add test for `FileTimes`beetrees-2/+52
2023-05-15Add creation time support to `FileTimes` on apple and windowsbeetrees-26/+144
2023-05-15Shorten lifetime of even more panic temporariesDavid Tolnay-2/+2
2023-05-15wanting => wantVagelis Prokopiou-2/+2
2023-05-14Auto merge of #108196 - sunfishcode:sunfishcode/windows-as-socket-impls, ↵bors-0/+72
r=dtolnay Implement `AsHandle`/`AsSocket` for `Arc`/`Rc`/`Box` on Windows Implement the Windows counterpart to #97437 and #107317: Implement `AsHandle` and `AsSocket` for `Arc<T>`, `Rc<T>`, and `Box<T>`.
2023-05-14Shorten lifetime of panic temporaries in panic_fmt caseDavid Tolnay-1/+3
2023-05-13refactor: Remove bespoke from_os_str_bytes_uncheckedEd Page-33/+23
2023-05-13refactor: Remove redundant, private OsStr::bytesEd Page-48/+41
2023-05-13add examples of port 0 binding behaviorkirk-0/+18
2023-05-12Auto merge of #109732 - Urgau:uplift_drop_forget_ref_lints, r=davidtwcobors-6/+18
Uplift `clippy::{drop,forget}_{ref,copy}` lints This PR aims at uplifting the `clippy::drop_ref`, `clippy::drop_copy`, `clippy::forget_ref` and `clippy::forget_copy` lints. Those lints are/were declared in the correctness category of clippy because they lint on useless and most probably is not what the developer wanted. ## `drop_ref` and `forget_ref` The `drop_ref` and `forget_ref` lint checks for calls to `std::mem::drop` or `std::mem::forget` with a reference instead of an owned value. ### Example ```rust let mut lock_guard = mutex.lock(); std::mem::drop(&lock_guard) // Should have been drop(lock_guard), mutex // still locked operation_that_requires_mutex_to_be_unlocked(); ``` ### Explanation Calling `drop` or `forget` on a reference will only drop the reference itself, which is a no-op. It will not call the `drop` or `forget` method on the underlying referenced value, which is likely what was intended. ## `drop_copy` and `forget_copy` The `drop_copy` and `forget_copy` lint checks for calls to `std::mem::forget` or `std::mem::drop` with a value that derives the Copy trait. ### Example ```rust let x: i32 = 42; // i32 implements Copy std::mem::forget(x) // A copy of x is passed to the function, leaving the // original unaffected ``` ### Explanation Calling `std::mem::forget` [does nothing for types that implement Copy](https://doc.rust-lang.org/std/mem/fn.drop.html) since the value will be copied and moved into the function on invocation. ----- Followed the instructions for uplift a clippy describe here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751 cc `@m-ou-se` (as T-libs-api leader because the uplifting was discussed in a recent meeting)
2023-05-11Improve code around SGX waitqueueUrgau-3/+13
Followed up of d36e390d8176babedcf326581959958d447170cd See https://github.com/rust-lang/rust/pull/109732#issuecomment-1543574908 for more details. Co-authored-by: Jethro Beekman <jethro@fortanix.com>
2023-05-10Remove useless drop of copy typeUrgau-1/+1
2023-05-10Remove and fix useless drop of referenceUrgau-3/+5
2023-05-09Don't force include Windows goop when documentingChris Denton-59/+40
2023-05-09Auto merge of #110285 - KisaragiEffective:sync-stdarch, r=Amanieubors-1/+0
stdarch: update submodule We need [this commit](https://github.com/rust-lang/stdarch/commit/cf3deeae3a420fc8b409b596aeda6ce7027067d3) introduced by [stdarch#1411](https://github.com/rust-lang/stdarch/pull/1411) in order to merge #110189. Note to myself: `git pull && git submodule update --remote library/stdarch`
2023-05-09Auto merge of #110152 - ChrisDenton:windows-sys, r=thomccbors-3098/+7089
Start using `windows sys` for Windows FFI bindings in std Switch to using windows-sys for FFI. In order to avoid some currently contentious issues, this uses windows-bindgen to generate a smaller set of bindings instead of using the full crate. Unlike the windows-sys crate, the generated bindings uses `*mut c_void` for handle types instead of `isize`. This to sidestep opsem concerns about mixing pointer types and integers between languages. Note that `SOCKET` remains defined as an integer but instead of being a usize, it's changed to fit the [standard library definition](https://github.com/rust-lang/rust/blob/a41fc00eaf352541008965fec0dee811e44373b3/library/std/src/os/windows/raw.rs#L12-L16): ```rust #[cfg(target_pointer_width = "32")] pub type SOCKET = u32; #[cfg(target_pointer_width = "64")] pub type SOCKET = u64; ``` The generated bindings also customizes the `#[link]` imports. I hope to switch to using raw-dylib but I don't want to tie that too closely with the switch to windows-sys. --- Changes outside of the bindings are, for the most part, fairly minimal (e.g. some differences in `*mut` vs. `*const` or a few types differ). One issue is that our own bindings sometimes mix in higher level types, like `BorrowedHandle`. This is pretty adhoc though.
2023-05-08Rollup merge of #104070 - nbdd0121:unwind, r=AmanieuMichael Goulet-5/+11
Prevent aborting guard from aborting the process in a forced unwind Fix #101469
2023-05-08Rollup merge of #110638 - nikarh:vita, r=Mark-SimulacrumYuki Okushi-23/+235
STD support for PSVita This PR adds std support for `armv7-sony-vita-newlibeabihf` target. The work here is fairly similar to #95897, just for a different target platform. This depends on the following pull requests: rust-lang/backtrace-rs#523 rust-lang/libc#3209
2023-05-08std: remove test for arm's crypto featureKisaragi Marine-1/+0
please see https://github.com/rust-lang/rust/pull/110285#issuecomment-1521201953 for more details
2023-05-08Auto merge of #106621 - ozkanonur:enable-elided-lifetimes-for-doctests, ↵bors-4/+5
r=Mark-Simulacrum enable `rust_2018_idioms` lint group for doctests With this change, `rust_2018_idioms` lint group will be enabled for compiler/libstd doctests. Resolves #106086 Resolves #99144 Signed-off-by: ozkanonur <work@onurozkan.dev>
2023-05-07Auto merge of #111306 - Urgau:hashbrown-std-0.13, r=Amanieubors-1/+1
Update hashbrown from 0.12.3 to 0.13.1 for std This PR updates hashbrown from 0.12.3 to 0.13.1 for std. r? `@Amanieu`
2023-05-07PS Vita std supportNikolay Arhipov-23/+235
2023-05-07Prevent aborting guard from aborting the process in a forced unwindGary Guo-0/+3
2023-05-07Parse catch filter in personality functionGary Guo-5/+8