about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2022-01-13Remove `&mut` from `io::read_to_string` signatureNoah Lev-2/+2
`@m-ou-se` [realized][1] that because `Read` is implemented for `&mut impl Read`, there's no need to take `&mut` in `io::read_to_string`. Removing the `&mut` from the signature allows users to remove the `&mut` from their calls (and thus pass an owned reader) if they don't use the reader later. [1]: https://github.com/rust-lang/rust/issues/80218#issuecomment-874322129
2022-01-13Rollup merge of #91938 - yaahc:error-reporter, r=m-ou-seMatthias Krüger-4/+1048
Add `std::error::Report` type This is a continuation of https://github.com/rust-lang/rust/pull/90174, split into a separate PR since I cannot push to ```````@seanchen1991``````` 's fork
2022-01-13Auto merge of #92553 - m-ou-se:thread-join-simplify, r=Mark-Simulacrumbors-9/+9
Simpilfy thread::JoinInner. `JoinInner`'s `native` field was an `Option`, but that's unnecessary. Also, thanks to `Arc::get_mut`, there's no unsafety needed in `JoinInner::join()`.
2022-01-12Use the correct `cvt` for converting socket errors on Windows.Dan Gohman-1/+2
`WSADuplicateSocketW` returns 0 on success, which differs from handle-oriented functions which return 0 on error. Use `sys::net::cvt` to handle its return value, which handles the socket convention of returning 0 on success, rather than `sys::cvt`, which handles the handle-oriented convention of returning 0 on failure.
2022-01-12Remove deprecated LLVM-style inline assemblyTomasz Miąsko-6/+4
2022-01-12Rollup merge of #92748 - david-perez:eliminate-boxed-wording-std-error, ↵Matthias Krüger-6/+6
r=Mark-Simulacrum Eliminate "boxed" wording in `std::error::Error` documentation In commit 29403ee, documentation for the methods on `std::any::Any` was modified so that they referred to the concrete value behind the trait object as the "inner" value. This is a more accurate wording than "boxed": while putting trait objects inside boxes is arguably the most common use, they can also be placed behind other pointer types like `&mut` or `std::sync::Arc`. This commit does the same documentation changes for `std::error::Error`.
2022-01-12Rollup merge of #92720 - rosik:patch-1, r=m-ou-seMatthias Krüger-1/+1
Fix doc formatting for time.rs The doc states that instants are not steady, but the word "not" wasn't highlighted in bold.
2022-01-12Rollup merge of #92709 - joshtriplett:file-options-docs, r=Mark-SimulacrumMatthias Krüger-4/+5
Improve documentation for File::options to give a more likely example `File::options().read(true).open(...)` is equivalent to just `File::open`. Change the example to set the `append` flag instead, and then change the filename to something more likely to be written in append mode.
2022-01-11Inline std::os::unix::ffi::OsStringExt methodsKonrad Borowski-0/+2
2022-01-11Partially stabilize `maybe_uninit_extra`Miguel Ojeda-1/+0
This covers: impl<T> MaybeUninit<T> { pub unsafe fn assume_init_read(&self) -> T { ... } pub unsafe fn assume_init_drop(&mut self) { ... } } It does not cover the const-ness of `write` under `const_maybe_uninit_write` nor the const-ness of `assume_init_read` (this commit adds `const_maybe_uninit_assume_init_read` for that). FCP: https://github.com/rust-lang/rust/issues/63567#issuecomment-958590287. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2022-01-11Auto merge of #92070 - rukai:replace_vec_into_iter_with_array_into_iter, ↵bors-12/+12
r=Mark-Simulacrum Replace usages of vec![].into_iter with [].into_iter `[].into_iter` is idiomatic over `vec![].into_iter` because its simpler and faster (unless the vec is optimized away in which case it would be the same) So we should change all the implementation, documentation and tests to use it. I skipped: * `src/tools` - Those are copied in from upstream * `src/test/ui` - Hard to tell if `vec![].into_iter` was used intentionally or not here and not much benefit to changing it. * any case where `vec![].into_iter` was used because we specifically needed a `Vec::IntoIter<T>` * any case where it looked like we were intentionally using `vec![].into_iter` to test it.
2022-01-10Improve documentation for File::options to give a more likely exampleJosh Triplett-4/+5
`File::options().read(true).open(...)` is equivalent to just `File::open`. Change the example to set the `append` flag instead, and then change the filename to something more likely to be written in append mode.
2022-01-10Eliminate "boxed" wording in `std::error::Error` documentationdavid-perez-6/+6
In commit 29403ee, documentation for the methods on `std::any::Any` was modified so that they referred to the concrete value behind the trait object as the "inner" value. This is a more accurate wording than "boxed": while putting trait objects inside boxes is arguably the most common use, they can also be placed behind other pointer types like `&mut` or `std::sync::Arc`. This commit does the same documentation changes for `std::error::Error`.
2022-01-10Auto merge of #92719 - matthiaskrgr:rollup-tc7oqys, r=matthiaskrgrbors-2/+2
Rollup of 7 pull requests Successful merges: - #92248 (Normalize struct tail type when checking Pointee trait) - #92357 (Fix invalid removal of newlines from doc comments) - #92602 (Make source links look cleaner) - #92636 (Normalize generator-local types with unevaluated constants) - #92693 (Release notes: add `Result::unwrap_{,err_}unchecked`) - #92702 (Clean up lang_items::extract) - #92717 (update miri) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-01-10Fix doc formatting for time.rs Yaroslav Dynnikov-1/+1
The doc states that instants are not steady, but the word "not" wasn't highlighted in bold.
2022-01-10Rollup merge of #92602 - jsha:source-link-2, r=GuillaumeGomezMatthias Krüger-2/+2
Make source links look cleaner Change from syntaxy-looking [src] to the plain word "source". Change the syntaxy-looking `[-]` at the top of the page to say "collapse". Reduce opacity of rightside content. Part of #59851 r? `@GuillaumeGomez` Demo: https://rustdoc.crud.net/jsha/source-link-2/std/string/struct.String.html [Discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/display.20of.20source.20link).
2022-01-09Compute most of Public/Exported access level in rustc_resolveLamb-21/+16
Mak DefId to AccessLevel map in resolve for export hir_id to accesslevel in resolve and applied in privacy using local def id removing tracing probes making function not recursive and adding comments Move most of Exported/Public res to rustc_resolve moving public/export res to resolve fix missing stability attributes in core, std and alloc move code to access_levels.rs return for some kinds instead of going through them Export correctness, macro changes, comments add comment for import binding add comment for import binding renmae to access level visitor, remove comments, move fn as closure, remove new_key fmt fix rebase fix rebase fmt fmt fix: move macro def to rustc_resolve fix: reachable AccessLevel for enum variants fmt fix: missing stability attributes for other architectures allow unreachable pub in rustfmt fix: missing impl access level + renaming export to reexport Missing impl access level was found thanks to a test in clippy
2022-01-08export `tcp::IntoIncoming`Ibraheem Ahmed-1/+1
2022-01-09eplace usages of vec![].into_iter with [].into_iterLucas Kent-12/+12
2022-01-08Make source links look cleanerJacob Hoffman-Andrews-2/+2
Change from syntaxy-looking [src] to the plain word "source".
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-08Add safety comments to panic::(set/take/update)_hookBadel2-0/+15
2022-01-08Change panic::update_hook to simplify usageBadel2-22/+23
And to remove possibility of panics while changing the panic handler, because that resulted in a double panic.
2022-01-07silence tidy errorsJane Lusby-27/+27
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-07Implement panic::update_hookBadel2-0/+66
2022-01-07Stabilize `#[feature(available_parallelism)]`Yoshua Wuyts-2/+1
2022-01-06Add diagnostic items for macrosAlex Macleod-0/+6
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-05Mention *scoped* thread in panic message.Mara Bos-1/+1
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2022-01-05Note the invariance over 'env in Scope<'env>.Mara Bos-0/+2
2022-01-05Fix missing .load() in Scope's Debug impl.Mara Bos-1/+1
2022-01-05Rename n_running_threads to num_running_threads.Mara Bos-11/+11
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-04Fix typo in Scope::spawn docs.Mara Bos-1/+1
Co-authored-by: deltragon <m@dafert.at>
2022-01-04Fix typo in is_running() docs.Mara Bos-2/+2
Co-authored-by: Mattias Buelens <649348+MattiasBuelens@users.noreply.github.com>
2022-01-04Fix typo in documentation.Mara Bos-1/+1
2022-01-04Use > rather than == for overflow check in scoped threads.Mara Bos-1/+1
Co-authored-by: Jacob Lifshay <programmerjake@gmail.com>
2022-01-04Fix variance of thread::Scope.Mara Bos-1/+1
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-04Formatting.Mara Bos-1/+3
2022-01-04Simplify panicking mechanism of thread::scope.Mara Bos-31/+22
It now panic!()s on its own, rather than resume_unwind'ing the panic payload from the thread. Using resume_unwind skips the panic_handler, meaning that the main thread would never have a panic handler run, which can get confusing.
2022-01-04Add documentation for scoped threads.Mara Bos-11/+175
2022-01-04Add ScopedJoinHandle::is_running().Mara Bos-1/+10
2022-01-04Implement RFC 3151: Scoped threads.Mara Bos-26/+202
2022-01-04Simpilfy thread::JoinInner.Mara Bos-9/+9