about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2022-01-03Make the documentation of builtin macro attributes accessibleDaniel Henry-Mantilla-11/+8
- Do not `#[doc(hidden)]` the `#[derive]` macro attribute - Add a link to the reference section to `derive`'s inherent docs - Do the same for `#[test]` and `#[global_allocator]` - Fix `GlobalAlloc` link (why is it on `core` and not `alloc`?) - Try `no_inline`-ing the `std` reexports from `core` - Revert "Try `no_inline`-ing the `std` reexports from `core`" - Address PR review - Also document the unstable macros
2022-01-03Make `Receiver::into_iter` into a clickable linkzohnannor-1/+2
The documentation on `std::sync::mpsc::Iter` and `std::sync::mpsc::TryIter` provides links to the corresponding `Receiver` methods, unlike `std::sync::mpsc::IntoIter` does. This was left out in c59b188aaeadea32625534250d1f5120420be000 Related to #29377
2022-01-03Explicitly pass `PATH` to the Windows exe resolverChris Denton-33/+37
2022-01-03std: Implement try_reserve and try_reserve_exact on PathBufXuanwo-0/+19
Signed-off-by: Xuanwo <github@xuanwo.io>
2022-01-02Auto merge of #92482 - matthiaskrgr:rollup-uso1zi0, r=matthiaskrgrbors-103/+106
Rollup of 7 pull requests Successful merges: - #84083 (Clarify the guarantees that ThreadId does and doesn't make.) - #91593 (Remove unnecessary bounds for some Hash{Map,Set} methods) - #92297 (Reduce compile time of rustbuild) - #92332 (Add test for where clause order) - #92438 (Enforce formatting for rustc_codegen_cranelift) - #92463 (Remove pronunciation guide from Vec<T>) - #92468 (Emit an error for `--cfg=)`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-01-01Rollup merge of #91593 - upsuper-forks:hashmap-set-methods-bound, r=dtolnayMatthias Krüger-99/+99
Remove unnecessary bounds for some Hash{Map,Set} methods This PR moves `HashMap::{into_keys,into_values,retain}` and `HashSet::retain` from `impl` blocks with `K: Eq + Hash, S: BuildHasher` into the blocks without them. It doesn't seem to me there is any reason these methods need to be bounded by that. This change brings `HashMap::{into_keys,into_values}` on par with `HashMap::{keys,values,values_mut}` which are not bounded either.
2022-01-01Rollup merge of #84083 - ltratt:threadid_doc_tweak, r=dtolnayMatthias Krüger-4/+7
Clarify the guarantees that ThreadId does and doesn't make. The existing documentation does not spell out whether `ThreadId`s are unique during the lifetime of a thread or of a process. I had to examine the source code to realise (pleasingly!) that they're unique for the lifetime of a process. That seems worth documenting clearly, as it's a strong guarantee. Examining the way `ThreadId`s are created also made me realise that the `as_u64` method on `ThreadId` could be a trap for the unwary on those platforms where the platform's notion of a thread identifier is also a 64 bit integer (particularly if they happen to use a similar identifier scheme to `ThreadId`). I therefore think it's worth being even clearer that there's no relationship between the two.
2022-01-01Auto merge of #92396 - xfix:remove-commandenv-apply, r=Mark-Simulacrumbors-16/+0
Remove CommandEnv::apply It's not being used and uses unsound set_var and remove_var functions. This is an internal function that isn't exported (even with `process_internals` feature), so this shouldn't break anything. Also see #92365. Note that this isn't the only use of those methods in standard library, so that particular pull request will need more changes than just this to work (in particular, `test_capture_env_at_spawn` is using `set_var` and `remove_var`).
2021-12-31Make tidy check for magic numbers that spell thingsJosh Triplett-4/+4
Remove existing problematic cases.
2021-12-30Remove needless allocation from example code of OsStringDavid Tolnay-4/+4
2021-12-30Fix some copy/paste hysteresis in OsString try_reserve docsDavid Tolnay-4/+4
It appears `find_max_slow` comes from the BinaryHeap docs, where the try_reserve example is a slow implementation of find_max. It has no relevance to this code in OsString though.
2021-12-29Remove CommandEnv::applyKonrad Borowski-16/+0
It's not being used and uses unsound set_var and remove_var functions.
2021-12-29Address commentsXuanwo-10/+10
Signed-off-by: Xuanwo <github@xuanwo.io>
2021-12-29Update library/std/src/ffi/os_str.rsXuanwo-1/+1
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2021-12-28Implement support in wtf8Xuanwo-0/+37
Signed-off-by: Xuanwo <github@xuanwo.io>
2021-12-28Fix windows buildXuanwo-0/+9
Signed-off-by: Xuanwo <github@xuanwo.io>
2021-12-28Add try_reserve for OsStringXuanwo-0/+92
Signed-off-by: Xuanwo <github@xuanwo.io>
2021-12-27Little improves in CString `new` when creating from sliceAngelicosPhosphoros-22/+45
Old code already contain optimization for cases with `&str` and `&[u8]` args. This commit adds a specialization for `&mut[u8]` too. Also, I added usage of old slice in search for zero bytes instead of new buffer because it produce better code for Windows on LTO builds. For other platforms, this wouldn't cause any difference because it calls `libc` anyway. Inlined `_new` method into spec trait to reduce amount of code generated to `CString::new` callers.
2021-12-26fix typo: intialized -> initializedHiroshi Kori-2/+2
2021-12-26fix typo: the use f.pad -> then use f.padHiroshi Kori-1/+1
2021-12-26Fix a pair of mistyped test cases in std::net::ipScallop Ye-2/+2
2021-12-25Language tweak.Laurence Tratt-2/+2
2021-12-23Rollup merge of #90625 - Milo123459:ref-unwind-safe, r=dtolnayMatthias Krüger-0/+7
Add `UnwindSafe` to `Once` Fixes #43469
2021-12-23Rollup merge of #92208 - ChrisDenton:win-bat-cmd, r=dtolnayMatthias Krüger-0/+35
Quote bat script command line Fixes #91991 [`CreateProcessW`](https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw#parameters) should only be used to run exe files but it does have some (undocumented) special handling for files with `.bat` and `.cmd` extensions. Essentially those magic extensions will cause the parameters to be automatically rewritten. Example pseudo Rust code (note that `CreateProcess` starts with an optional application name followed by the application arguments): ```rust // These arguments... CreateProcess(None, `@"foo.bat` "hello world""`@,` ...); // ...are rewritten as CreateProcess(Some(r"C:\Windows\System32\cmd.exe"), `@""foo.bat` "hello world"""`@,` ...); ``` However, when setting the first parameter (the application name) as we now do, it will omit the extra level of quotes around the arguments: ```rust // These arguments... CreateProcess(Some("foo.bat"), `@"foo.bat` "hello world""`@,` ...); // ...are rewritten as CreateProcess(Some(r"C:\Windows\System32\cmd.exe"), `@"foo.bat` "hello world""`@,` ...); ``` This means the arguments won't be passed to the script as intended. Note that running batch files this way is undocumented but people have relied on this so we probably shouldn't break it.
2021-12-23Rollup merge of #92139 - dtolnay:backtrace, r=m-ou-seMatthias Krüger-3/+3
Change Backtrace::enabled atomic from SeqCst to Relaxed This atomic is not synchronizing anything outside of its own value, so we don't need the `Acquire`/`Release` guarantee that all memory operations prior to the store are visible after the subsequent load, nor the `SeqCst` guarantee of all threads seeing all of the sequentially consistent operations in the same order. Using `Relaxed` reduces the overhead of `Backtrace::capture()` in the case that backtraces are not enabled. ## Benchmark ```rust #![feature(backtrace)] use std::backtrace::Backtrace; use std::sync::atomic::{AtomicUsize, Ordering}; use std::thread; use std::time::Instant; fn main() { let begin = Instant::now(); let mut threads = Vec::new(); for _ in 0..64 { threads.push(thread::spawn(|| { for _ in 0..10_000_000 { let _ = Backtrace::capture(); static LOL: AtomicUsize = AtomicUsize::new(0); LOL.store(1, Ordering::Release); } })); } for thread in threads { let _ = thread.join(); } println!("{:?}", begin.elapsed()); } ``` **Before:**&ensp;6.73 seconds **After:**&ensp;5.18 seconds
2021-12-23Rollup merge of #92117 - solid-rs:fix-kmc-solid-read-buf, r=yaahcMatthias Krüger-1/+27
kmc-solid: Add `std::sys::solid::fs::File::read_buf` This PR adds `std::sys::solid::fs::File::read_buf` to catch up with the changes introduced by #81156 and fix the [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets..
2021-12-22Fix testsChris Denton-3/+11
2021-12-21Rollup merge of #92129 - RalfJung:join-handle-docs, r=jyn514Matthias Krüger-1/+1
JoinHandle docs: add missing 'the'
2021-12-21Rollup merge of #90345 - passcod:entry-insert, r=dtolnayMatthias Krüger-6/+6
Stabilise entry_insert This stabilises `HashMap:Entry::insert_entry` etc. Tracking issue #65225. It will need an FCP. This was implemented in #64656 two years ago. This PR includes the rename and change discussed in https://github.com/rust-lang/rust/issues/65225#issuecomment-910652430, happy to split if needed.
2021-12-21kmc-solid: Add `std::sys::solid::fs::File::read_buf`Tomoaki Kawada-1/+27
Catching up with commit 3b263ceb5cb89b6d53b5a03b47ec447c3a7f7765
2021-12-20Bump insert_entry stabilization to Rust 1.59David Tolnay-2/+2
2021-12-20Change Backtrace::enabled atomic from SeqCst to RelaxedDavid Tolnay-3/+3
2021-12-20impl RefUnwindSafe for OnceDavid Tolnay-2/+5
2021-12-20JoinHandle docs: add missing 'the'Ralf Jung-1/+1
2021-12-18Rollup merge of #92030 - rukai:stdlib2021, r=m-ou-seMatthias Krüger-13/+12
Update stdlib to the 2021 edition progress towards https://github.com/rust-lang/rust/issues/88638 I couldnt find a way to run the 2018 style panic tests against 2018 so I just deleted them, maybe theres a way to do it that I missed though?
2021-12-18Rollup merge of #92025 - devnexen:revert-91553-anc_data_dfbsd, r=kennytmMatthias Krüger-92/+8
Revert "socket ancillary data implementation for dragonflybsd." Reverts rust-lang/rust#91553
2021-12-18Update stdlib to the 2021 editionLucas Kent-13/+12
2021-12-16attempt to make Report usable with Box dyn Error and fn mainJane Lusby-103/+201
2021-12-16more docs improvementsJane Lusby-35/+207
2021-12-16add a panicking exampleJane Lusby-4/+51
2021-12-16Update report output and fix examplesJane Lusby-82/+245
2021-12-16Revert "socket ancillary data implementation for dragonflybsd."David CARLIER-92/+8
2021-12-16Quote bat script command lineChris Denton-0/+35
2021-12-16Rollup merge of #91947 - ibraheemdev:io-error-other, r=joshtriplettMatthias Krüger-0/+27
Add `io::Error::other` This PR adds a small utility constructor, `io::Error::other`, a shorthand for `io::Error::new(io::ErrorKind::Other, err)`, something I find myself writing often. For some concrete stats, a quick search on [grep.app](https://grep.app) shows that more than half of the uses of `io::Error::new` use `ErrorKind::Other`: ``` Error::new\((?:std::)?(?:io::)?ErrorKind:: => 3,898 results Error::new\((?:std::)?(?:io::)?ErrorKind::Other => 2,186 results ```
2021-12-15Modifications to buffer UTF-16 internally so that there is no longer a ↵PFPoitras-18/+54
4-byte buffer minimum. Include suggestions from @agausmann and @Mark-Simulacrum.
2021-12-15Rollup merge of #91916 - steffahn:fix-typos, r=dtolnayMatthias Krüger-28/+28
Fix a bunch of typos I hope that none of these files is not supposed to be modified. FYI, I opened separate PRs for typos in submodules, in the respective repositories * https://github.com/rust-lang/stdarch/pull/1267 * https://github.com/rust-lang/backtrace-rs/pull/455
2021-12-14add `io::Error::other` constructorIbraheem Ahmed-0/+27
2021-12-15Rollup merge of #91881 - Patrick-Poitras:stabilize-iter-zip, r=scottmcmMatthias Krüger-1/+0
Stabilize `iter::zip` Hello all! As the tracking issue (#83574) for `iter::zip` completed the final commenting period without any concerns being raised, I hereby submit this stabilization PR on the issue. As the pull request that introduced the feature (#82917) states, the `iter::zip` function is a shorter way to zip two iterators. As it's generally a quality-of-life/ergonomic improvement, it has been integrated into the codebase without any trouble, and has been used in many places across the rust compiler and standard library since March without any issues. For more details, I would refer to `@cuviper's` original PR, or the [function's documentation](https://doc.rust-lang.org/std/iter/fn.zip.html).
2021-12-14Stabilize iter::zip.PFPoitras-1/+0
2021-12-14Update std::error::Report based on feedbackJane Lusby-81/+171