summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2022-02-21Destabilise entry_insert5225225-2/+4
2022-02-12Fix hashing for windows paths containing a CurDir componentThe 8472-9/+52
* the logic only checked for / but not for \ * verbatim paths shouldn't skip items at all since they don't get normalized * the extra branches get optimized out on unix since is_sep_byte is a trivial comparison and is_verbatim is always-false * tests lacked windows coverage for these cases That lead to equal paths not having equal hashes and to unnecessary collisions.
2022-01-20Fix compilation for a few tier 2 targetsHans Kratz-8/+5
2022-01-19Update std::fs::remove_dir_all documentationPietro Albini-4/+8
2022-01-19Fix CVE-2022-21658 for WASIAlex Crichton-8/+63
2022-01-19Fix CVE-2022-21658 for UNIX-likeHans Kratz-13/+351
2022-01-19Fix CVE-2022-21658 for WindowsChris Denton-27/+419
2022-01-11add dummy feature gate to make racer compilePietro Albini-0/+4
2022-01-07Rollup merge of #92632 - yoshuawuyts:stabilize-available-parallelism, ↵Eric Huss-2/+1
r=joshtriplett Implement stabilization of `#[feature(available_parallelism)]` Stabilized in https://github.com/rust-lang/rust/issues/74479#issuecomment-984379800. Closes https://github.com/rust-lang/rust/issues/74479. Thanks! cc/ ``@rust-lang/libs-api``
2022-01-07Implement `TryFrom<char>` for `u8`Ian Douglas Scott-0/+3
Previously suggested in https://github.com/rust-lang/rfcs/issues/2854. It makes sense to have this since `char` implements `From<u8>`. Likewise `u32`, `u64`, and `u128` (since #79502) implement `From<char>`.
2022-01-07Stabilize `#[feature(available_parallelism)]`Yoshua Wuyts-2/+1
2022-01-06Rollup merge of #92288 - yescallop:patch-1, r=m-ou-seMatthias Krüger-2/+2
Fix a pair of mistyped test cases in `std::net::ip` These two test cases are not consistent with their comments, which I believe is unintended.
2022-01-05Auto merge of #92587 - matthiaskrgr:rollup-qnwa8qx, r=matthiaskrgrbors-0/+1
Rollup of 7 pull requests Successful merges: - #92092 (Drop guards in slice sorting derive src pointers from &mut T, which is invalidated by interior mutation in comparison) - #92388 (Fix a minor mistake in `String::try_reserve_exact` examples) - #92442 (Add negative `impl` for `Ord`, `PartialOrd` on `LocalDefId`) - #92483 (Stabilize `result_cloned` and `result_copied`) - #92574 (Add RISC-V detection macro and more architecture instructions) - #92575 (ast: Always keep a `NodeId` in `ast::Crate`) - #92583 (:arrow_up: rust-analyzer) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-01-05Rollup merge of #92517 - ChrisDenton:explicit-path, r=dtolnayMatthias Krüger-33/+37
Explicitly pass `PATH` to the Windows exe resolver This allows for testing different `PATH`s without using the actual environment.
2022-01-05Add is_riscv_feature_detected!; modify impl of hint::spin_loopluojia65-0/+1
Update library/core/src/hint.rs Co-authored-by: Amanieu d'Antras <amanieu@gmail.com> Remove redundant config gate
2022-01-04Rollup merge of #92525 - zohnannor:patch-1, r=camelidMatthias Krüger-1/+2
intra-doc: Make `Receiver::into_iter` into a clickable link 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-04Rollup merge of #92456 - danielhenrymantilla:patch-1, r=petrochenkovMatthias Krüger-11/+8
Make the documentation of builtin macro attributes accessible `use ::std::prelude::v1::derive;` compiles on stable, so, AFAIK, there is no reason to have it be `#[doc(hidden)]`. - What it currently looks like for things such as `#[test]`, `#[derive]`, `#[global_allocator]`: https://doc.rust-lang.org/1.57.0/core/prelude/v1/index.html#:~:text=Experimental-,pub,-use%20crate%3A%3Amacros%3A%3Abuiltin%3A%3Aglobal_allocator <img width="767" alt="Screen Shot 2021-12-31 at 17 49 46" src="https://user-images.githubusercontent.com/9920355/147832999-cbd747a6-4607-4df6-8e57-c1675dcbc1c3.png"> and in `::std` they're just straight `hidden`. <img width="452" alt="Screen Shot 2021-12-31 at 17 53 18" src="https://user-images.githubusercontent.com/9920355/147833105-c5ff8cd1-9e4d-4d2b-9621-b36aa3cfcb28.png"> - Here is how it looks like with this PR (assuming the `Rustc{De,En}codable` ones are not reverted): <img width="778" alt="Screen Shot 2021-12-31 at 17 50 55" src="https://user-images.githubusercontent.com/9920355/147833034-84286342-dbf7-4e6e-9062-f39cd6c286a4.png"> <img width="291" alt="Screen Shot 2021-12-31 at 17 52 54" src="https://user-images.githubusercontent.com/9920355/147833109-c92ed55c-51c6-40a2-9205-f834d1e349c0.png"> Since this involves doc people to chime in, and since `jyn` is on vacation, I'll cc `@GuillaumeGomez` and tag the `rustdoc` team as well
2022-01-04Rollup merge of #91754 - Patrick-Poitras:rm-4byte-minimum-stdio-windows, ↵Matthias Krüger-18/+54
r=Mark-Simulacrum Modifications to `std::io::Stdin` on Windows so that there is no longer a 4-byte buffer minimum in read(). This is an attempted fix of issue #91722, where a too-small buffer was passed to the read function of stdio on Windows. This caused an error to be returned when `read_to_end` or `read_to_string` were called. Both delegate to `std::io::default_read_to_end`, which creates a buffer that is of length >0, and forwards it to `std::io::Stdin::read()`. The latter method returns an error if the length of the buffer is less than 4, as there might not be enough space to allocate a UTF-16 character. This creates a problem when the buffer length is in `0 < N < 4`, causing the bug. The current modification creates an internal buffer, much like the one used for the write functions I'd also like to acknowledge the help of ``@agausmann`` and ``@hkratz`` in detecting and isolating the bug, and for suggestions that made the fix possible. Couple disclaimers: - Firstly, I didn't know where to put code to replicate the bug found in the issue. It would probably be wise to add that case to the testing suite, but I'm afraid that I don't know _where_ that test should be added. - Secondly, the code is fairly fundamental to IO operations, so my fears are that this may cause some undesired side effects ~or performance loss in benchmarks.~ The testing suite runs on my computer, and it does fix the issue noted in #91722. - Thirdly, I left the "surrogate" field in the Stdin struct, but from a cursory glance, it seems to be serving the same purpose for other functions. Perhaps merging the two would be appropriate. Finally, this is my first pull request to the rust language, and as such some things may be weird/unidiomatic/plain out bad. If there are any obvious improvements I could do to the code, or any other suggestions, I would appreciate them. Edit: Closes #91722
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-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-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