about summary refs log tree commit diff
path: root/library
AgeCommit message (Collapse)AuthorLines
2023-09-21offset_from: docs improvementsRalf Jung-4/+20
2023-09-21Auto merge of #116013 - matthiaskrgr:rollup-mv5i4fd, r=matthiaskrgrbors-29/+29
Rollup of 4 pull requests Successful merges: - #114394 (style-guide: Document formatting of `as` casts (mostly like a binary operator)) - #115990 (Allow anyone to set llvm-fixed-upstream) - #116008 (Rename BoxMeUp to PanicPayload.) - #116011 (Update browser-ui-test version to 0.16.10) r? `@ghost` `@rustbot` modify labels: rollup
2023-09-21Rollup merge of #116008 - m-ou-se:boxmeup, r=oli-obkMatthias Krüger-29/+29
Rename BoxMeUp to PanicPayload. "BoxMeUp" is not very clear. Let's rename that to a description of what it actually represents: a panic payload. This PR also renames the structs that implement this trait to have more descriptive names. Part of https://github.com/rust-lang/rust/issues/116005 r? `@oli-obk`
2023-09-20Auto merge of #115542 - saethlin:fileencoder-is-bufwriter, r=WaffleLapkinbors-0/+1
Simplify/Optimize FileEncoder FileEncoder is basically a BufWriter except that it exposes access to the not-written-to-yet region of the buffer so that some users can write directly to the buffer. This strategy is awesome because it lets us avoid calling memcpy for small copies, but the previous strategy was based on the writer accessing a `&mut [MaybeUninit<u8>; N]` and returning a `&[u8]` which is an API which currently mandates the use of unsafe code, making that interface in general not that appealing. So this PR cleans up the FileEncoder implementation and builds on that general idea of direct buffer access in order to prevent `memcpy` calls in a few key places when encoding the dep graph and rmeta tables. The interface used here is now 100% safe, but with the caveat that internally we need to avoid trusting the number of bytes that the provided function claims to have written. The original primary objective of this PR was to clean up the FileEncoder implementation so that the fix for the following issues would be easy to implement. The fix for these issues is to correctly update self.buffered even when writes fail, which I think it's easy to verify manually is now done, because all the FileEncoder methods are small. Fixes https://github.com/rust-lang/rust/issues/115298 Fixes https://github.com/rust-lang/rust/issues/114671 Fixes https://github.com/rust-lang/rust/issues/114045 Fixes https://github.com/rust-lang/rust/issues/108100 Fixes https://github.com/rust-lang/rust/issues/106787
2023-09-20PR feedbackBen Kimock-0/+1
2023-09-20Fix typo.Mara Bos-1/+1
2023-09-20Rename BoxMeUp to PanicPayload.Mara Bos-29/+29
2023-09-20Call panic_display directly in const_panic_fmt.Mara Bos-1/+2
2023-09-20Auto merge of #115753 - tgross35:threadinfo-refactor, r=thomccbors-16/+21
Refactor `thread_info` to remove the `RefCell` `thread_info` currently uses `RefCell`-based initialization. Refactor this to use `OnceCell` instead which is more performant and better suits the needs of one-time initialization. This is nobody's bottleneck but OnceCell checks are a single `cmp` vs. `RefCell<Option>` needing runtime logic
2023-09-20fix rustdoc testsDeadbeef-1/+1
2023-09-20Enable effects for libcoreDeadbeef-5/+6
2023-09-20Auto merge of #114443 - tgross35:cstr-len, r=dtolnaybors-34/+72
Implement `cstr_count_bytes` This has not yet been approved via ACP, but it's simple enough to get started on. - ACP: https://github.com/rust-lang/libs-team/issues/256 - Tracking issue: https://github.com/rust-lang/rust/issues/114441 `@rustbot` label +T-libs-api
2023-09-19Auto merge of #115979 - GuillaumeGomez:rollup-06ujzgh, r=GuillaumeGomezbors-0/+2
Rollup of 6 pull requests Successful merges: - #113383 (style-guide: Add section on bugs, and resolving bugs) - #115499 (rustc_target/riscv: Fix passing of transparent unions with only one non-ZST member) - #115801 (Detect cycle errors hidden by opaques during monomorphization) - #115947 (Custom code classes in docs warning) - #115957 (fix mismatched symbols) - #115958 (explain mysterious addition in float minimum/maximum) r? `@ghost` `@rustbot` modify labels: rollup
2023-09-19Rollup merge of #115958 - RalfJung:mystery-plus, r=Mark-Simulacrum,notriddleGuillaume Gomez-0/+2
explain mysterious addition in float minimum/maximum Thanks to `@programmerjake` for mentioning this.
2023-09-19explain mysterious addition in float minimum/maximumRalf Jung-0/+2
2023-09-19Auto merge of #115627 - compiler-errors:icedump-no-std, r=m-ou-sebors-32/+7
Don't modify libstd to dump rustc ICEs Do a much simpler thing and just dump a `std::backtrace::Backtrace` to file. r? `@estebank` `@oli-obk` Fixes #115610
2023-09-19Replace 'mutex' with 'lock' in RwLock documentationKriskras99-2/+2
When copying the documentation for `clear_poison` from Mutex, not every occurence of 'mutex' was replaced with 'lock'.
2023-09-19Rollup merge of #115946 - the8472:panic-on-sched_getaffinity-bug, ↵Guillaume Gomez-2/+4
r=Mark-Simulacrum panic when encountering an illegal cpumask in thread::available_parallelism Fixes #115868 by panicking instead of returning an invalid `NonZeroUsize`
2023-09-19Rollup merge of #115839 - Dirreke:bump-libc, r=dtolnayGuillaume Gomez-1/+1
Bump libc to 0.2.148
2023-09-19Auto merge of #104101 - betrusted-io:xous-libstd-initial, r=bjorn3bors-7/+2478
Add initial libstd support for Xous This patchset adds some minimal support to the tier-3 target `riscv32imac-unknown-xous-elf`. The following features are supported: * alloc * thread creation and joining * thread sleeping * thread_local * panic_abort * mutex * condvar * stdout Additionally, internal support for the various Xous primitives surrounding IPC have been added as part of the Xous FFI. These may be exposed as part of `std::os::xous::ffi` in the future, however for now they are not public. This represents the minimum viable product. A future patchset will add support for networking and filesystem support.
2023-09-18Stabilize `{IpAddr, Ipv6Addr}::to_canonical`Trevor Gross-10/+13
Make `IpAddr::to_canonical` and `IpV6Addr::to_canonical` stable, as well as const stabilize `Ipv6Addr::to_ipv4_mapped`. Newly stable API: impl IpAddr { // Now stable under `ip_to_canonical` const fn to_canonical(&self) -> IpAddr; } impl Ipv6Addr { // Now stable under `ip_to_canonical` const fn to_canonical(&self) -> IpAddr; // Already stable, this makes it const stable under // `const_ipv6_to_ipv4_mapped` const fn to_ipv4_mapped(&self) -> Option<Ipv4Addr> } These stabilize a subset of the following tracking issues: - https://github.com/rust-lang/rust/issues/27709 - https://github.com/rust-lang/rust/issues/76205
2023-09-18panic when encountering an illegal cpumaskThe 8472-2/+4
2023-09-18Rollup merge of #115494 - RalfJung:primitive_docs, r=Mark-SimulacrumMatthias Krüger-1626/+12
get rid of duplicate primitive_docs Having this duplicate makes editing that file very annoying. And at least locally the generated docs still look perfectly fine...
2023-09-18Rollup merge of #109409 - WaffleLapkin:progamer, r=dtolnayMatthias Krüger-0/+85
Add `minmax{,_by,_by_key}` functions to `core::cmp` This PR adds the following functions: ```rust // mod core::cmp #![unstable(feature = "cmp_minmax")] pub fn minmax<T>(v1: T, v2: T) -> [T; 2] where T: Ord; pub fn minmax_by<T, F>(v1: T, v2: T, compare: F) -> [T; 2] where F: FnOnce(&T, &T) -> Ordering; pub fn minmax_by_key<T, F, K>(v1: T, v2: T, mut f: F) -> [T; 2] where F: FnMut(&T) -> K, K: Ord; ``` (they are also `const` under `#[feature(const_cmp)]`, I've omitted `const` stuff for simplicity/readability) ---- Semantically these functions are equivalent to `{ let mut arr = [v1, v2]; arr.sort(); arr }`, but since they operate on 2 elements only, they are implemented as a single comparison. Even though that's basically a sort, I think "sort 2 elements" operation is useful on it's own in many cases. Namely, it's a common pattern when you have 2 things, and need to know which one is smaller/bigger to operate on them differently. I've wanted such functions countless times, most recently in #109402, so I thought I'd propose them. ---- r? libs-api
2023-09-18Fill-in tracking issue for `feature(cmp_minmax)`Maybe Waffle-3/+3
2023-09-18Add `minmax*` functions to `core::cmp`Maybe Waffle-0/+85
2023-09-18get rid of duplicate primitive_docsRalf Jung-1626/+12
2023-09-18Auto merge of #108043 - a1phyr:string_write_fmt, r=workingjubileebors-2/+22
Small wins for formatting-related code This PR does two small wins in fmt code: - Override `write_char` for `PadAdapter` to use inner buffer's `write_char` - Override some `write_fmt` implementations to avoid avoid the additional indirection and vtable generated by the default impl.
2023-09-18Auto merge of #115547 - WaffleLapkin:spin_looping, r=Mark-Simulacrumbors-24/+17
Simplify `core::hint::spin_loop` The grouping was inconsistent and not really helpful. r? t-libs
2023-09-17Specialize `fmt::Write::write_fmt` for `Sized` typesBenoît du Garreau-2/+22
2023-09-17Rollup merge of #115477 - kellerkindt:stabilized_int_impl, r=dtolnayDylan DPC-225/+219
Stabilize the `Saturating` type Closes #87920 Closes #92354 Stabilization report https://github.com/rust-lang/rust/issues/87920#issuecomment-1652346124 FCP https://github.com/rust-lang/rust/issues/87920#issuecomment-1676438885
2023-09-17Rollup merge of #115434 - soqb:ascii-char-manual-debug, r=dtolnayDylan DPC-2/+39
make `Debug` impl for `ascii::Char` match that of `char` # Objective use a more recognisable format for the `Debug` impl on `ascii::Char` than the derived one based off the enum variants. The alogorithm used is the following: - escape `ascii::Char::{Null, CharacterTabulation, CarraigeReturn, LineFeed, ReverseSolidus, Apostrophe}` to `'\0'`, `'\t'`, `'\r'`, `'\n'`, `'\\'` and `'\''` respectively. these are the same escape codes as `<char as Debug>::fmt` uses. - if `u8::is_ascii_control` is false, print the character wrapped in single quotes. - otherwise, print in the format `'\xAB'` where `A` and `B` are the hex nibbles of the byte. (`char` uses unicode escapes and this seems like the corresponding ascii format). Tracking issue: https://github.com/rust-lang/rust/issues/110998
2023-09-17Rollup merge of #114965 - benschulz:mpsc-drop, r=dtolnayDylan DPC-15/+0
Remove Drop impl of mpsc Receiver and (Sync)Sender This change removes the empty `Drop` implementations for `mpsc::Receiver`, `mpsc::Sender` and `mpsc::SyncSender`. These implementations do not specify `#[may_dangle]`, so by removing them we make `mpsc` types play nice with drop check. This was previously attempted in [#105243](https://github.com/rust-lang/rust/pull/105243#issuecomment-1337188646) but then [abandoned due to a test failure](https://github.com/rust-lang/rust/pull/105243#issuecomment-1337227970). I've aligned the test with those for `Mutex` and `RwLock`.
2023-09-17Auto merge of #113748 - clarfonthey:ip-step, r=dtolnaybors-1/+66
impl Step for IP addresses ACP: rust-lang/libs-team#235 Note: since this is insta-stable, it requires an FCP. Separating out from the bit operations PR since it feels logically disjoint, and so their FCPs can be separate.
2023-09-17Auto merge of #115782 - a1phyr:improve_pad_adapter, r=dtolnaybors-0/+8
Improve `PadAdapter::write_char` Split from #108043
2023-09-17Auto merge of #113753 - dvdsk:master, r=dtolnaybors-1/+81
Add implementation for thread::sleep_until - Feature gate is `thread::sleep_until` - Tracking issue is: #113752 - APC: https://github.com/rust-lang/libs-team/issues/237
2023-09-16Rollup merge of #115895 - 52:patch-docs-vec-truncate, r=dtolnayMatthias Krüger-4/+4
Improve Vec(Deque)::truncate documentation Fixes #115784
2023-09-16Rollup merge of #115560 - ShE3py:format-results, r=dtolnayMatthias Krüger-6/+10
Update doc for `alloc::format!` and `core::concat!` Closes #115551. Used comments instead of `assert!`s as [`std::fmt`](https://doc.rust-lang.org/std/fmt/index.html#usage) uses comments. Should all the str-related macros (`format!`, `format_args!`, `concat!`, `stringify!`, `println!`, `writeln!`, etc.) references each others? For instance, [`concat!`](https://doc.rust-lang.org/core/macro.concat.html) mentions that integers are stringified, but don't link to `stringify!`. `@rustbot` label +A-docs +A-fmt
2023-09-16Rollup merge of #115487 - ModProg:patch-1, r=dtolnayMatthias Krüger-2/+2
Improve documentation on when signes are printed by default I found the original formulation a bit irritating, but not sure if I really improved it.
2023-09-16Rollup merge of #115329 - xzmeng:fix-std-doc, r=dtolnayMatthias Krüger-7/+7
fix std::primitive doc: homogenous -> homogeneous replace "homogenous" with the more commonly used "homogeneous".
2023-09-16Rollup merge of #115247 - the8472:life-before-main, r=dtolnayMatthias Krüger-1/+25
Document std limitations before/after main Solves #110708
2023-09-16Auto merge of #112229 - clarfonthey:range-iter-count, r=dtolnaybors-0/+20
Specialize count for range iterators Since `size_hint` is already specialized, it feels apt to specialize `count` as well. Without any specialized version of `ExactSizeIterator::len` or `Step::steps_between`, this feels like a more reliable way of accessing this without having to rely on knowing that `size_hint` is correct. In my case, this is particularly useful to access the `steps_between` implementation for `char` from the standard library without having to compute it manually. I didn't think it was worth modifying the `Step` trait to add a version of `steps_between` that used native overflow checks since this is just doing one subtraction in most cases anyway, and so I decided to make the inclusive version use `checked_add` so it didn't have this lopsided overflow-checks-but-only-sometimes logic.
2023-09-16edit `std::collections::VecDeque` docsmxnkarou-2/+2
2023-09-16edit `std::vec::Vec::truncate` docsmxnkarou-2/+2
2023-09-16Rollup merge of #115607 - RalfJung:safe-traits-unsafe-code, r=dtolnayMatthias Krüger-0/+35
clarify that unsafe code must not rely on our safe traits This adds a disclaimer to PartialEq, Eq, PartialOrd, Ord, Hash, Deref, DerefMut. We already have a similar disclaimer in ExactSizeIterator (worded a bit differently): ``` /// Note that this trait is a safe trait and as such does *not* and *cannot* /// guarantee that the returned length is correct. This means that `unsafe` /// code **must not** rely on the correctness of [`Iterator::size_hint`]. The /// unstable and unsafe [`TrustedLen`](super::marker::TrustedLen) trait gives /// this additional guarantee. ``` If there are any other traits that should carry such a disclaimer, please let me know. Fixes https://github.com/rust-lang/rust/issues/73682
2023-09-16fix a comment about assert_receiver_is_total_eqRalf Jung-3/+3
2023-09-16Specialize count for range iteratorsltdk-0/+20
2023-09-16impl Step for IP addressesltdk-1/+66
2023-09-16Auto merge of #114494 - est31:extend_useless_ptr_null_checks, r=jackh726bors-1/+22
Make useless_ptr_null_checks smarter about some std functions This teaches the `useless_ptr_null_checks` lint that some std functions can't ever return null pointers, because they need to point to valid data, get references as input, etc. This is achieved by introducing an `#[rustc_never_returns_null_ptr]` attribute and adding it to these std functions (gated behind bootstrap `cfg_attr`). Later on, the attribute could maybe be used to tell LLVM that the returned pointer is never null. I don't expect much impact of that though, as the functions are pretty shallow and usually the input data is already never null. Follow-up of PR #113657 Fixes #114442
2023-09-16Auto merge of #115520 - Finomnis:const_transmute_copy, r=dtolnaybors-2/+1
Stabilize const_transmute_copy Closes #83165