Commit Graph

2924 Commits

Author SHA1 Message Date
Stuart Cook
c11505f218
Rollup merge of #130061 - theemathas:box_vec_non_null, r=MarkSimulacrum,workingjubilee
Add `NonNull` convenience methods to `Box` and `Vec`

Implements the ACP: https://github.com/rust-lang/libs-team/issues/418.

The docs for the added methods are mostly copied from the existing methods that use raw pointers instead of `NonNull`.

I'm new to this "contributing to rustc" thing, so I'm sorry if I did something wrong. In particular, I don't know what the process is for creating a new unstable feature. Please advise me if I should do something. Thank you.
2024-09-15 12:14:55 +10:00
Tim (Theemathas) Chirananthavat
811ee38ff0 Add tracking issue number for box_vec_non_null 2024-09-15 01:11:18 +07:00
Obei Sideg
3b0ce1bc33
Update tests for hidden references to mutable static 2024-09-13 14:10:56 +03:00
Stuart Cook
368718961c
Rollup merge of #130245 - RalfJung:miri-alloc-backtrace, r=Amanieu
make basic allocation functions track_caller in Miri for nicer backtraces

This matches what we did with basic pointer and atomic operations.
2024-09-13 19:37:59 +10:00
bors
2e8db5e9e3 Auto merge of #130281 - matthiaskrgr:rollup-1b2ibs8, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #130101 (some const cleanup: remove unnecessary attributes, add const-hack indications)
 - #130208 (Introduce `'ra` lifetime name.)
 - #130263 (coverage: Simplify creation of sum counters)
 - #130273 (more eagerly discard constraints on overflow)
 - #130276 (Add test for nalgebra hang in coherence)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-12 18:27:55 +00:00
Matthias Krüger
4428d6f363
Rollup merge of #130101 - RalfJung:const-cleanup, r=fee1-dead
some const cleanup: remove unnecessary attributes, add const-hack indications

I learned that we use `FIXME(const-hack)` on top of the "const-hack" label. That seems much better since it marks the right place in the code and moves around with the code. So I went through the PRs with that label and added appropriate FIXMEs in the code. IMO this means we can then remove the label -- Cc ``@rust-lang/wg-const-eval.``

I also noticed some const stability attributes that don't do anything useful, and removed them.

r? ``@fee1-dead``
2024-09-12 19:03:41 +02:00
bors
8c0ec05f7d Auto merge of #129992 - alexcrichton:update-compiler-builtins, r=tgross35
Update compiler-builtins to 0.1.125

This commit updates the compiler-builtins crate from 0.1.123 to 0.1.125. The changes in this update are:

* https://github.com/rust-lang/compiler-builtins/pull/682
* https://github.com/rust-lang/compiler-builtins/pull/678
* https://github.com/rust-lang/compiler-builtins/pull/685
2024-09-12 15:28:40 +00:00
Ralf Jung
03e8c95809 make basic allocation functions track_caller in Miri for nicer backtraces 2024-09-11 22:38:21 +02:00
bors
6f7229c4da Auto merge of #129403 - scottmcm:only-array-simd, r=compiler-errors
Ban non-array SIMD

Nearing the end of https://github.com/rust-lang/compiler-team/issues/621 !

Currently blocked on ~~https://github.com/rust-lang/compiler-builtins/pull/673~~ ~~https://github.com/rust-lang/compiler-builtins/pull/674~~ ~~https://github.com/rust-lang/rust/pull/129400~~ ~~https://github.com/rust-lang/rust/pull/129481~~ for windows.
2024-09-10 22:47:40 +00:00
bors
33855f80d4 Auto merge of #130025 - Urgau:missing_docs-expect, r=petrochenkov
Also emit `missing_docs` lint with `--test` to fulfil expectations

This PR removes the "test harness" suppression of the `missing_docs` lint to be able to fulfil `#[expect]` (expectations) as it is now "relevant".

I think the goal was to maybe avoid false-positive while linting on public items under `#[cfg(test)]` but with effective visibility we should no longer have any false-positive.

Another possibility would be to query the lint level and only emit the lint if it's of expect level, but that is even more hacky.

Fixes https://github.com/rust-lang/rust/issues/130021

try-job: x86_64-gnu-aux
2024-09-10 14:54:09 +00:00
Scott McMurray
d2309c2a9d Ban non-array SIMD 2024-09-09 19:39:43 -07:00
Urgau
843708a32e Add missing #[allow(missing_docs)] on hack functions in alloc 2024-09-09 13:44:09 +02:00
Ralf Jung
332fa6aa6e add FIXME(const-hack) 2024-09-08 23:08:40 +02:00
Eduardo Sánchez Muñoz
5f3fdd14df Remove needless returns detected by clippy in libraries 2024-09-08 21:51:00 +02:00
bors
12b26c13fb Auto merge of #129941 - BoxyUwU:bump-boostrap, r=albertlarsan68
Bump boostrap compiler to new beta

Accidentally left some comments on the update cfgs commit directly xd
2024-09-07 20:37:30 +00:00
Tim (Theemathas) Chirananthavat
8230a90c49 Add NonNull convenience methods to Vec 2024-09-07 14:48:25 +07:00
Tim (Theemathas) Chirananthavat
8e3e20ac2f Add NonNull convenience methods to Box 2024-09-07 14:45:19 +07:00
Matthew Giordano
550e55fec5 Remove duplicate impl 2024-09-06 15:20:41 -07:00
Matthew Giordano
97df334d5f remove the Clone requirement 2024-09-06 14:24:25 -07:00
Alex Crichton
5396124aa3 Update compiler-builtins to 0.1.125
This commit updates the compiler-builtins crate from 0.1.123 to 0.1.125.
The changes in this update are:

* https://github.com/rust-lang/compiler-builtins/pull/682
* https://github.com/rust-lang/compiler-builtins/pull/678
* https://github.com/rust-lang/compiler-builtins/pull/685
2024-09-05 09:31:17 -07:00
Boxy
0091b8ab2a update cfgs 2024-09-05 17:24:01 +01:00
Matthias Krüger
8a60d0a5ec
Rollup merge of #101339 - the8472:ci-randomize-debug, r=Mark-Simulacrum
enable -Zrandomize-layout in debug CI builds

This builds rustc/libs/tools with `-Zrandomize-layout` on *-debug CI runners.

Only a handful of tests and asserts break with that enabled, which is promising. One test was fixable, the rest is dealt with by disabling them through new cargo features or compiletest directives.

The config.toml flag `rust.randomize-layout` defaults to false, so it has to be explicitly enabled for now.
2024-09-05 03:47:39 +02:00
Boxy
3dca90946f replace placeholder version 2024-09-03 20:54:02 +01:00
Matthias Krüger
003ddec7a6
Rollup merge of #129748 - RalfJung:box-validity, r=workingjubilee
Box validity: update for new zero-sized rules

Fixes https://github.com/rust-lang/unsafe-code-guidelines/issues/529

Cc `@joshlf` `@rust-lang/opsem`
2024-09-02 22:35:18 +02:00
bors
a4601859ae Auto merge of #129873 - matthiaskrgr:rollup-bv849ud, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #127474 (doc: Make block of inline Deref methods foldable)
 - #129678 (Deny imports of `rustc_type_ir::inherent` outside of type ir + new trait solver)
 - #129738 (`rustc_mir_transform` cleanups)
 - #129793 (add extra linebreaks so rustdoc can identify the first sentence)
 - #129804 (Fixed some typos in the standard library documentation/comments)
 - #129837 (Actually parse stdout json, instead of using hacky contains logic.)
 - #129842 (Fix LLVM ABI NAME for riscv64imac-unknown-nuttx-elf)
 - #129843 (Mark myself as on vacation for triagebot)
 - #129858 (Replace walk with visit so we dont skip outermost expr kind in def collector)

Failed merges:

 - #129777 (Add `unreachable_pub`, round 4)
 - #129868 (Remove kobzol vacation status)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-09-02 13:41:42 +00:00
Matthias Krüger
820540aaa0
Rollup merge of #129804 - ranger-ross:fixed-documentation-typos, r=Noratrieb
Fixed some typos in the standard library documentation/comments

I spent some time to fix a few typos in `library/std` and `library/core`
2024-09-02 04:19:29 +02:00
bors
e71f952912 Auto merge of #129063 - the8472:cold-opt-size, r=Amanieu
Apply size optimizations to panic machinery and some cold functions

* std dependencies gimli and addr2line are now built with opt-level=s
* various panic-related methods and `#[cold]` methods are now marked `#[optimize(size)]`

Panics should be cold enough that it doesn't make sense to optimize them for speed. The only tradeoff here is if someone does a lot of backtrace captures (without panics) and printing then the opt-level change might impact their perf.

Seems to be the first use of the optimize attribute. Tracking issue #54882
2024-09-02 00:58:50 +00:00
Ralf Jung
0e5628d7de tweak wording regarding Box validity 2024-09-01 11:21:37 +02:00
Matthias Krüger
1063c0dd37
Rollup merge of #129207 - GrigorenkoPV:elided-is-named, r=cjgillot
Lint that warns when an elided lifetime ends up being a named lifetime

As suggested in https://github.com/rust-lang/rust/issues/48686#issuecomment-1817334575

Fixes #48686
2024-09-01 03:58:03 +02:00
The 8472
e3169f76e6 when -Zrandomize-layout is enabled disable alloc test testing internal struct sizes 2024-08-31 23:56:45 +02:00
Pavel Grigorenko
f7b0b22137 Fix elided_named_lifetimes in code 2024-08-31 15:35:41 +03:00
Matthias Krüger
385ffaedbf
Rollup merge of #129640 - saethlin:unignore-android-in-alloc, r=tgross35
Re-enable android tests/benches in alloc/core

This is basically a revert of https://github.com/rust-lang/rust/pull/73729. These tests better work on android now; it's been 4 years and we don't use dlmalloc on that target anymore.

And I've validated that they should pass now with a try-build :)
2024-08-31 10:08:54 +02:00
ranger-ross
92f45900bb
Fixed typos in btree map docs 2024-08-31 14:50:37 +09:00
Matthew Giordano
68169d3103 add new_cyclic_in for Arc 2024-08-29 13:41:57 -07:00
Matthew Giordano
2383cc9910 improve comments 2024-08-29 13:41:37 -07:00
Matthew Giordano
4abb8e2d0d fix new_cyclic_in for rc 2024-08-29 13:26:39 -07:00
Matthew Giordano
21cb84763c fix fmt 2024-08-29 12:32:33 -07:00
Ralf Jung
05ffd446a9 Box validity: update for new zero-sized rules 2024-08-29 16:06:20 +02:00
Jubilee
bd66fadd79
Rollup merge of #129715 - Amjad50:update-compiler-builtins, r=tgross35
Update `compiler_builtins` to `0.1.123`

Includes https://github.com/rust-lang/compiler-builtins/pull/680 and fixes https://github.com/rust-lang/rust/issues/128386.

Fixed by not including math symbols of `compiler_builtins` into any `unix` target or `wasi`, old behavior is restored

r? tgross35
2024-08-28 19:12:56 -07:00
Jubilee
9ddb45e81a
Rollup merge of #129673 - matthewpipie:arc-weak-debug-trait, r=dtolnay
Add fmt::Debug to sync::Weak<T, A>

Currently, `sync::Weak<T>` implements `Debug`, but `sync::Weak<T, A>` does not. This appears to be an oversight, as `rc::Weak<T, A>` implements `Debug`. (Note: `sync::Weak` is the weak for `Arc`, and `rc::Weak` is the weak for `Rc`.)

This PR adds the Debug trait for `sync::Weak<T, A>`. The issue was initially brought up here: https://github.com/rust-lang/wg-allocators/issues/131
2024-08-28 19:12:54 -07:00
Amjad Alsharafi
555414e683
Update compiler_builtins to 0.1.123
Signed-off-by: Amjad Alsharafi <26300843+Amjad50@users.noreply.github.com>
2024-08-29 08:38:19 +08:00
Ben Kimock
ee05de8e5e Re-enable android tests/benches in alloc 2024-08-28 10:45:30 -04:00
Matthew Giordano
13e36cf887 add new_cyclic_in for rc 2024-08-27 18:06:00 -07:00
Matthew Giordano
c11d46f045 Add fmt::Debug to sync::Weak<T, A> 2024-08-27 17:38:51 -07:00
Jubilee Young
169b2f0e6d library: Stabilize new_uninit for Box, Rc, and Arc
A partial stabilization that only affects:
- AllocType<T>::new_uninit
- AllocType<T>::assume_init
- AllocType<[T]>::new_uninit_slice
- AllocType<[T]>::assume_init
where "AllocType" is Box, Rc, or Arc
2024-08-27 10:17:05 -07:00
Matthias Krüger
c6e00680ac
Rollup merge of #129544 - mu001999-contrib:dead-code/clean, r=compiler-errors
Removes dead code from the compiler

Detected by #128637
2024-08-26 01:49:03 +02:00
Matthias Krüger
0e2523eaf8
Rollup merge of #129416 - workingjubilee:partial-move-from-stabilization, r=dtolnay
library: Move unstable API of new_uninit to new features

- `new_zeroed` variants move to `new_zeroed_alloc`
- the `write` fn moves to `box_uninit_write`

The remainder will be stabilized in upcoming patches, as it was decided to only stabilize `uninit*` and `assume_init`.
2024-08-25 16:51:04 +02:00
Matthias Krüger
7edbd6353b
Rollup merge of #129091 - RalfJung:box_as_ptr, r=Amanieu
add Box::as_ptr and Box::as_mut_ptr methods

Unstably implements https://github.com/rust-lang/libs-team/issues/355. Tracking issue: https://github.com/rust-lang/rust/issues/129090.

r? libs-api
2024-08-25 16:51:03 +02:00
mu001999
e7f11b6913 Removes dead code from the compiler 2024-08-25 13:41:39 +08:00
Jubilee Young
9ccd7abefe library: Move unstable API of new_uninit to new features
- `new_zeroed` variants move to `new_zeroed_alloc`
- the `write` fn moves to `box_uninit_write`

The remainder will be stabilized in upcoming patches, as
it was decided to only stabilize `uninit*` and `assume_init`.
2024-08-23 20:52:02 -07:00
Scott McMurray
62f7d5305e Update compiler_builtins to 0.1.121 2024-08-23 12:02:26 -07:00
okaneco
65abcc2bcc Implement feature string_from_utf8_lossy_owned
Implement feature for lossily converting from `Vec<u8>` to `String`
- Add `String::from_utf8_lossy_owned`
- Add `FromUtf8Error::into_utf8_lossy`
2024-08-22 23:37:52 -04:00
Amjad Alsharafi
57b164a9d2
Update compiler_builtins to 0.1.120
Signed-off-by: Amjad Alsharafi <26300843+Amjad50@users.noreply.github.com>
2024-08-22 14:26:31 +08:00
Scott McMurray
dfea11d620 Stabilize iter::repeat_n 2024-08-19 22:39:04 -07:00
The 8472
6d8f0bd930 apply #[optimize(size)] to #[cold] ones and part of the panick machinery 2024-08-14 20:50:04 +02:00
Ralf Jung
6eaf531432 add Box::as_ptr and Box::as_mut_ptr methods 2024-08-14 14:30:31 +02:00
Matthias Krüger
85180cd365
Rollup merge of #128759 - notriddle:notriddle/spec-to-string, r=workingjubilee,compiler-errors
alloc: add ToString specialization for `&&str`

Fixes #128690
2024-08-14 05:05:51 +02:00
bors
591ecb88df Auto merge of #128742 - RalfJung:miri-vtable-uniqueness, r=saethlin
miri: make vtable addresses not globally unique

Miri currently gives vtables a unique global address. That's not actually matching reality though. So this PR enables Miri to generate different addresses for the same type-trait pair.

To avoid generating an unbounded number of `AllocId` (and consuming unbounded amounts of memory), we use the "salt" technique that we also already use for giving constants non-unique addresses: the cache is keyed on a "salt" value n top of the actually relevant key, and Miri picks a random salt (currently in the range `0..16`) each time it needs to choose an `AllocId` for one of these globals -- that means we'll get up to 16 different addresses for each vtable. The salt scheme is integrated into the global allocation deduplication logic in `tcx`, and also used for functions and string literals. (So this also fixes the problem that casting the same function to a fn ptr over and over will consume unbounded memory.)

r? `@saethlin`
Fixes https://github.com/rust-lang/miri/issues/3737
2024-08-13 04:32:34 +00:00
schvv31n
027b19fa9b std::fmt::FormatterFn -> std::fmt::FromFn 2024-08-12 18:33:30 +01:00
Ralf Jung
4763d12207 ignore some vtable/fn ptr equality tests in Miri, their result is not fully predictable 2024-08-12 10:39:11 +02:00
bors
13f8a57cfb Auto merge of #126793 - saethlin:mono-rawvec, r=scottmcm
Apply "polymorphization at home" to RawVec

The idea here is to move all the logic in RawVec into functions with explicit size and alignment parameters. This should eliminate all the fussing about how tweaking RawVec code produces large swings in compile times.

This uncovered https://github.com/rust-lang/rust-clippy/issues/12979, so I've modified the relevant test in a way that tries to preserve the spirit of the test without tripping the ICE.
2024-08-12 01:47:06 +00:00
bors
04ba50e823 Auto merge of #128927 - GuillaumeGomez:rollup-ei2lr0f, r=GuillaumeGomez
Rollup of 8 pull requests

Successful merges:

 - #128273 (Improve `Ord` violation help)
 - #128807 (run-make: explaing why fmt-write-bloat is ignore-windows)
 - #128903 (rustdoc-json-types `Discriminant`: fix typo)
 - #128905 (gitignore: Add Zed and Helix editors)
 - #128908 (diagnostics: do not warn when a lifetime bound infers itself)
 - #128909 (Fix dump-ice-to-disk for RUSTC_ICE=0 users)
 - #128910 (Differentiate between methods and associated functions in diagnostics)
 - #128923 ([rustdoc] Stop showing impl items for negative impls)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-10 15:13:38 +00:00
Guillaume Gomez
65875b2f5a
Rollup merge of #128273 - Voultapher:improve-ord-violation-help, r=workingjubilee
Improve `Ord` violation help

Recent experience in #128083 showed that the panic message when an Ord violation is detected by the new sort implementations can be confusing. So this PR aims to improve it, together with minor bug fixes in the doc comments for sort*, sort_unstable* and select_nth_unstable*.

Is it possible to get these changes into the 1.81 release? It doesn't change behavior and would greatly help when users encounter this panic for the first time, which they may after upgrading to 1.81.

Tagging `@orlp`
2024-08-10 16:23:51 +02:00
Nadrieril
cd40769c02 Stabilize min_exhaustive_patterns 2024-08-10 12:07:17 +02:00
Ben Kimock
da15248d26 Add an optimizer hint for the capacity that with_capacity_in returns 2024-08-09 20:06:27 -04:00
Ben Kimock
4e98bc6730 Hoist IS_ZST check out of RawVecInner::from_*_in 2024-08-09 20:06:27 -04:00
Ben Kimock
d6c0ebef50 Polymorphize RawVec 2024-08-09 20:06:26 -04:00
Lukas Bergdoll
1be60b5d2b Fix linkchecker issue 2024-08-09 15:05:37 +02:00
Guillaume Gomez
6d69b2e408 Update compiler-builtins version to 0.1.118 2024-08-08 14:47:49 +02:00
Trevor Gross
1d820dc9a6
Rollup merge of #128691 - tgross35:update-builtins, r=Amanieu
Update `compiler-builtins` to 0.1.117

This includes [1] which means we can remove the (nonworking) configuration of `no-f16-f128`.

Fixes https://github.com/rust-lang/rust/issues/128401.

[1]: https://github.com/rust-lang/compiler-builtins/pull/652

try-job: dist-various-1
2024-08-07 20:49:03 -05:00
Matthias Krüger
2ee9678338
Rollup merge of #128261 - clarfonthey:iter-default, r=dtolnay
impl `Default` for collection iterators that don't already have it

There is a pretty strong precedent for implementing `Default` for collection iterators, and this does so for some where this implementation was missed.

I don't think this needs a separate ACP (since this precedent already exists, and these feel like they were just missed), however, it *will* need an FCP since these implementations are instantly stable.
2024-08-07 20:28:16 +02:00
Michael Howell
3312f5d652 alloc: make to_string_str! a bit less complex 2024-08-07 10:06:54 -07:00
Trevor Gross
51e68c3006 Update compiler-builtins to 0.1.117
This includes [1] which means we can remove the (nonworking)
configuration of `no-f16-f128`.

Fixes https://github.com/rust-lang/rust/issues/128401.

[1]: https://github.com/rust-lang/compiler-builtins/pull/652
2024-08-06 21:48:32 -05:00
Matthias Krüger
16b251be10
Rollup merge of #125048 - dingxiangfei2009:stable-deref, r=amanieu
PinCoerceUnsized trait into core

cc ``@Darksonn`` ``@wedsonaf`` ``@ojeda``

This is a PR to introduce a `PinCoerceUnsized` trait in order to make trait impls generated by the proc-macro `#[derive(SmartPointer)]`, proposed by [RFC](e17e19ac7a/text/3621-derive-smart-pointer.md (pincoerceunsized-1)), sound. There you may find explanation, justification and discussion about the alternatives.

Note that we do not seek stabilization of this `PinCoerceUnsized` trait in the near future. The stabilisation of this trait does not block the eventual stabilization process of the `#[derive(SmartPointer)]` macro. Ideally, use of `DerefPure` is more preferrable except this will actually constitute a breaking change. `PinCoerceUnsized` emerges as a solution to the said soundness hole while avoiding the breaking change. More details on the `DerefPure` option have been described in this [section](e17e19ac7a/text/3621-derive-smart-pointer.md (derefpure)) of the RFC linked above.

Earlier discussion can be found in this [Zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/Pin.20and.20soundness.20of.20unsizing.20coercions) and [rust-for-linux thread](https://rust-lang.zulipchat.com/#narrow/stream/425075-rust-for-linux/topic/.23.5Bderive.28SmartPointer.29.5D.20and.20pin.20unsoundness.20rfc.233621).

try-job: dist-various-2
2024-08-07 00:34:11 +02:00
Michael Howell
1b587a6e76 alloc: add ToString specialization for &&str
Fixes #128690
2024-08-06 14:37:33 -07:00
Matthias Krüger
e4367cec5e
Rollup merge of #128309 - kmicklas:btreeset-cursor, r=Amanieu
Implement cursors for `BTreeSet`

Tracking issue: https://github.com/rust-lang/rust/issues/107540

This is a straightforward wrapping of the map API, except that map's `CursorMut` does not make sense, because there is no value to mutate. Hence, map's `CursorMutKey` is wrapped here as just `CursorMut`, since it's unambiguous for sets and we don't normally speak of "keys". On the other hand, I can see some potential for confusion with `CursorMut` meaning different things in each module. I'm happy to take suggestions to improve that.

r? ````@Amanieu````
2024-08-05 05:40:20 +02:00
Lukas Bergdoll
613155c96a Apply review comments to PartialOrd section 2024-08-03 15:10:27 +02:00
Matthias Krüger
1f700139f8
Rollup merge of #127586 - zachs18:more-must-use, r=cuviper
Add `#[must_use]` to some `into_raw*` functions.

cc #121287

r? ``@cuviper``

Adds `#[must_use = "losing the pointer will leak memory"]`[^1] to `Box::into_raw(_with_allocator)`, `Vec::into_raw_parts(_with_alloc)`, `String::into_raw_parts`[^2], and `rc::{Rc, Weak}::into_raw_with_allocator` (Rc's normal `into_raw` and all of `Arc`'s `into_raw*`s are already `must_use`).

Adds `#[must_use = "losing the raw <resource name may leak resources"]` to `IntoRawFd::into_raw_fd`, `IntoRawSocket::into_raw_socket`, and `IntoRawHandle::into_raw_handle`.

[^1]: "*will* leak memory" may be too-strong wording (since `Box`/`Vec`/`String`/`rc::Weak` might not have a backing allocation), but I left it as-is for simplicity and consistency.

[^2]: `String::into_raw_parts`'s `must_use` message is changed from the previous (possibly misleading) "`self` will be dropped if the result is not used".
2024-08-03 11:17:42 +02:00
Ken Micklas
0bc501e0ad Fix mutability in doc tests for BTreeSet cursors 2024-08-01 21:02:51 +01:00
Ken Micklas
cbdc377866 Introduce Cursor/CursorMut/CursorMutKey thrichotomy for BTreeSet like map API 2024-08-01 19:49:26 +01:00
Ken Micklas
4560770451 Fix some uses of "map" instead of "set" in BTreeSet cursor API docs 2024-08-01 19:48:23 +01:00
Ken Micklas
020476296b Share UnorderedKeyError with BTReeMap for set API 2024-08-01 19:47:57 +01:00
Lukas Bergdoll
afc404fdfc Apply review comments
- Use if the implementation of [`Ord`] for `T`
  language
- Link to total order wiki page
- Rework total order help and examples
- Improve language to be more precise and less
  prone to misunderstandings.
- Fix usage of `sort_unstable_by` in `sort_by`
  example
- Fix missing author mention
- Use more consistent example input for sort
- Use more idiomatic assert_eq! in examples
- Use more natural "comparison function" language
  instead of "comparator function"
2024-07-31 11:36:57 +02:00
Xiangfei Ding
d495b84a9a
PinCoerceUnsized trait into core 2024-07-31 17:10:55 +08:00
bors
f8060d282d Auto merge of #128083 - Mark-Simulacrum:bump-bootstrap, r=albertlarsan68
Bump bootstrap compiler to new beta

https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2024-07-30 17:49:08 +00:00
bors
dba8e2d2c2 Auto merge of #128234 - jcsp:retain-empty-case, r=tgross35
Optimize empty case in Vec::retain

While profiling some code that happens to call Vec::retain() in a tight loop, I noticed more runtime than expected in retain, even in a bench case where the vector was always empty.  When I wrapped my call to retain in `if !myvec.is_empty()` I saw faster execution compared with doing retain on an empty vector.

On closer inspection, Vec::retain is doing set_len(0) on itself even when the vector is empty, and then resetting the length again in BackshiftOnDrop::drop.

Unscientific screengrab of a flamegraph illustrating how we end up spending time in set_len and drop:
![image](https://github.com/user-attachments/assets/ebc72ace-84a0-4432-9b6f-1b3c96d353ba)
2024-07-30 00:55:52 +00:00
bors
56c698c711 Auto merge of #128334 - matthiaskrgr:rollup-nhxdt0c, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #128182 (handle no_std targets on std builds)
 - #128277 (miri: fix offset_from behavior on wildcard pointers)
 - #128304 (Isolate the diagnostic code that expects `thir::Pat` to be printable)
 - #128307 (Clean and enable `rustdoc::unescaped_backticks` for `core/alloc/std/test/proc_macro`)
 - #128322 (CI: move RFL job forward to v6.11-rc1)
 - #128333 (Miri subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-07-29 10:05:42 +00:00
Matthias Krüger
8f7af88b33
Rollup merge of #128307 - ojeda:unescaped_backticks, r=GuillaumeGomez
Clean and enable `rustdoc::unescaped_backticks` for `core/alloc/std/test/proc_macro`

I am not sure if the lint is supposed to be "ready enough" (since it is `allow` by default), but it does catch a couple issues in `core` (`alloc`, `std`, `test` and `proc_macro` are already clean), so I propose making it `warn` in all the crates rendered in the website.

Cc: `@GuillaumeGomez`
2024-07-29 11:42:35 +02:00
John Spray
6a6824a0ab Optimize empty case in Vec::retain 2024-07-29 09:40:51 +01:00
bors
80d8270d84 Auto merge of #125016 - nicholasbishop:bishop-cb-112, r=tgross35
Update compiler_builtins to 0.1.114

The `weak-intrinsics` feature was removed from compiler_builtins in https://github.com/rust-lang/compiler-builtins/pull/598, so dropped the `compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In https://github.com/rust-lang/compiler-builtins/pull/593, some builtins for f16/f128 were added. These don't work for all compiler backends, so add a `compiler-builtins-no-f16-f128` feature and disable it for cranelift and gcc.
2024-07-29 07:41:33 +00:00
Matthias Krüger
0c6d2fb3dc
Rollup merge of #128310 - kmicklas:btree-map-peek-next-docs, r=tgross35
Add missing periods on `BTreeMap` cursor `peek_next` docs

Tracking issue: https://github.com/rust-lang/rust/issues/107540
2024-07-29 07:11:16 +02:00
Nicholas Bishop
ecf2963baf Update compiler_builtins to 0.1.114
The `weak-intrinsics` feature was removed from compiler_builtins in
https://github.com/rust-lang/compiler-builtins/pull/598, so dropped the
`compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In https://github.com/rust-lang/compiler-builtins/pull/593, some
builtins for f16/f128 were added. These don't work for all compiler
backends, so add a `compiler-builtins-no-f16-f128` feature and disable
it for cranelift and gcc. Also disable it for LLVM targets that don't
support it.
2024-07-28 20:43:07 -04:00
Miguel Ojeda
dc815df1e1 Warn on rustdoc::unescaped_backticks for core/alloc/std/test/proc_macro
They are all clean now, so enable the lint to keep them clean going forward.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2024-07-29 00:58:45 +02:00
Nicholas Nethercote
84ac80f192 Reformat use declarations.
The previous commit updated `rustfmt.toml` appropriately. This commit is
the outcome of running `x fmt --all` with the new formatting options.
2024-07-29 08:26:52 +10:00
Mark Rousskov
5eca36d27a step cfg(bootstrap) 2024-07-28 14:46:29 -04:00
Guillaume Gomez
ee5956fd8a
Rollup merge of #128228 - slanterns:const_waker, r=dtolnay,oli-obk
Stabilize `const_waker`

Closes: https://github.com/rust-lang/rust/issues/102012.

For `local_waker` and `context_ext` related things, I just ~~moved them to dedicated feature gates and reused their own tracking issue (maybe it's better to open a new one later, but at least they should not be tracked under https://github.com/rust-lang/rust/issues/102012 from the beginning IMO.)~~ reused their own feature gates as suggested by ``@tgross35.``

``@rustbot`` label: +T-libs-api

r? libs-api
2024-07-28 20:07:46 +02:00
Guillaume Gomez
506a6317be
Rollup merge of #127765 - bitfield:fix_stdlib_doc_nits, r=dtolnay
Fix doc nits

Many tiny changes to stdlib doc comments to make them consistent (for example "Returns foo", rather than "Return foo"), adding missing periods, paragraph breaks, backticks for monospace style, and other minor nits.
2024-07-28 20:07:44 +02:00
Slanterns
0a6ebbaf2e
stabilize const_waker 2024-07-28 22:31:13 +08:00
Ken Micklas
0468983eae Add missing periods on BTreeMap cursor peek_next docs 2024-07-28 15:28:35 +01:00
Ken Micklas
9b165a1600 Implement cursors for BTreeSet 2024-07-28 15:25:40 +01:00
Matthias Krüger
99204047c9
Rollup merge of #128279 - slanterns:is_sorted, r=dtolnay
Stabilize `is_sorted`

Closes: https://github.com/rust-lang/rust/issues/53485.

~~Question: does~~ 8fe0c753f2/compiler/rustc_lint_defs/src/builtin.rs (L1986-L1994) ~~need a new example?~~
edit: It causes a test failure and needs to be changed anyway.

``@rustbot`` label: +T-libs-api

r? libs-api
2024-07-28 08:57:17 +02:00
Slanterns
ec0b354092
stabilize is_sorted 2024-07-28 03:11:54 +08:00
Trevor Gross
51734a8a6d
Rollup merge of #125897 - RalfJung:from-ref, r=Amanieu
from_ref, from_mut: clarify documentation

This was brought up [here](https://github.com/rust-lang/rust/issues/56604#issuecomment-2143193486). The domain of quantification is generally always constrained by the type in the type signature, and I am not sure it's always worth spelling that out explicitly as that makes things exceedingly verbose. But since this was explicitly brought up, let's clarify.
2024-07-27 13:32:56 -04:00
Lukas Bergdoll
00ce238885 Improve panic sections for sort*, sort_unstable* and select_nth_unstable*
- Move panic information into # Panics section
- Fix mentions of T: Ord that should be compare
- Add missing information
2024-07-27 16:48:42 +02:00
ltdk
0b99720497 Okay, I guess I have to give these a different feature name 2024-07-27 02:48:55 -04:00
ltdk
50835bf194 impl Default for collection iterators that don't already have it 2024-07-27 02:04:32 -04:00
John Arundel
a19472a93e Fix doc nits
Many tiny changes to stdlib doc comments to make them consistent (for example
"Returns foo", rather than "Return foo", per RFC1574), adding missing periods, paragraph
breaks, backticks for monospace style, and other minor nits.

https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text
2024-07-26 13:26:33 +01:00
Matthias Krüger
e342efe545
Rollup merge of #128120 - compiler-errors:async-fn-name, r=oli-obk
Gate `AsyncFn*` under `async_closure` feature

T-lang has not come to a consensus on the naming of async closure callable bounds, and as part of allowing the async closures RFC merge, we agreed to place `AsyncFn` under the same gate as `async Fn` so that these syntaxes can be evaluated in parallel.

See https://github.com/rust-lang/rfcs/pull/3668#issuecomment-2246435537

r? oli-obk
2024-07-24 18:00:40 +02:00
Matthias Krüger
34abb9647c
Rollup merge of #127733 - GrigorenkoPV:don't-forget, r=Amanieu
Replace some `mem::forget`'s with `ManuallyDrop`

              > but I would like to see a larger effort to replace all uses of `mem::forget`.

_Originally posted by `@saethlin` in https://github.com/rust-lang/rust/issues/127584#issuecomment-2226087767_

So,
r? `@saethlin`

Sorry, I have finished writing all of this before I got your response.
2024-07-24 18:00:39 +02:00
Matthias Krüger
6f696257cb
Rollup merge of #127481 - a1phyr:pattern_gat, r=Amanieu
Remove generic lifetime parameter of trait `Pattern`

Use a GAT for `Searcher` associated type because this trait is always implemented for every lifetime anyway.

cc #27721
2024-07-24 05:05:32 +02:00
Matthias Krüger
0666eee2a1
Rollup merge of #125962 - Coekjan:const-binary-heap, r=Amanieu
Update tracking issue for `const_binary_heap_new_in`

This PR updates the tracking issue of `const_binary_heap_new_in` feature:
- Old issue: #112353
- New issue: #125961
2024-07-24 05:05:30 +02:00
Michael Goulet
b82f878f03 Gate AsyncFn* under async_closure feature 2024-07-23 19:56:06 -04:00
许杰友 Jieyou Xu (Joe)
9f4039fcd5
Rollup merge of #127415 - AljoschaMeyer:master, r=dtolnay
Add missing try_new_uninit_slice_in and try_new_zeroed_slice_in

The methods for fallible slice allocation in a given allocator were missing from `Box`, which was an oversight according to https://github.com/rust-lang/wg-allocators/issues/130

This PR adds them as `try_new_uninit_slice_in` and `try_new_zeroed_slice_in`. I simply copy-pasted the implementations of `try_new_uninit_slice` and `try_new_zeroed_slice` and adusted doc comment, typings, and the allocator it uses internally.

Also adds missing punctuation to the doc comments of `try_new_uninit_slice` and `try_new_zeroed_slice`.

Related issue is https://github.com/rust-lang/rust/issues/32838 (Allocator traits and std::heap) *I think*. Also relevant is https://github.com/rust-lang/rust/issues/63291, but I did not add the corresponding `#[unstable]` proc macro, since `try_new_uninit_slice` and `try_new_zeroed_slice` are also not annotated with it.
2024-07-22 16:44:03 +08:00
Aljoscha Meyer
351fe27354
Use given allocator instad of Global 2024-07-22 08:17:46 +02:00
Nicholas Nethercote
7f0ccfe69d Adjust some comments on individual use declarations.
When we do the big `use` reformatting there are a tiny number of cases
where rustfmt moves a comment from one `use` item to another in an
undesirable way. This commit pre-emptively rearranges things to prevent
this from happening.
2024-07-17 08:05:39 +10:00
Pavel Grigorenko
f6fe7e49a2 lib: replace some mem::forget's with ManuallyDrop 2024-07-15 22:01:09 +03:00
Benoît du Garreau
772315de7c Remove generic lifetime parameter of trait Pattern
Use a GAT for `Searcher` associated type because this trait is always
implemented for every lifetime anyway.
2024-07-15 12:12:44 +02:00
Jubilee
285d45d299
Rollup merge of #127446 - zachs18:miri-stdlib-leaks-core-alloc, r=Mark-Simulacrum
Remove memory leaks in doctests in `core`, `alloc`, and `std`

cc `@RalfJung`  https://github.com/rust-lang/rust/issues/126067 https://github.com/rust-lang/miri/issues/3670

Should be no actual *documentation* changes[^1], all added/modified lines in the doctests are hidden with `#`,

This PR splits the existing memory leaks in doctests in `core`, `alloc`, and `std` into two general categories:

1. "Non-focused" memory leaks that are incidental to the thing being documented, and/or are easy to remove, i.e. they are only there because preventing the leak would make the doctest less clear and/or concise.
    - These doctests simply have a comment like `# // Prevent leaks for Miri.` above the added line that removes the memory leak.
    - [^2]Some of these would perhaps be better as part of the public documentation part of the doctest, to clarify that a memory leak can happen if it is not otherwise mentioned explicitly in the documentation  (specifically the ones in `(A)Rc::increment_strong_count(_in)`).
2. "Focused" memory leaks that are intentional and documented, and/or are possibly fragile to remove.
    - These doctests have a `# // FIXME` comment above the line that removes the memory leak, with a note that once `-Zmiri-disable-leak-check` can be applied at test granularity, these tests should be "un-unleakified" and have `-Zmiri-disable-leak-check` enabled.
    - Some of these are possibly fragile (e.g. unleaking the result of `Vec::leak`) and thus should definitely not be made part of the documentation.

This should be all of the leaks currently in `core` and `alloc`. I only found one leak in `std`, and it was in the first category (excluding the modules `@RalfJung` mentioned in https://github.com/rust-lang/rust/issues/126067 , and reducing the number of iterations of [one test](https://github.com/rust-lang/rust/blob/master/library/std/src/sync/once_lock.rs#L49-L94) from 1000 to 10)

[^1]: assuming [^2] is not added
[^2]: backlink
2024-07-13 20:18:23 -07:00
Matthias Krüger
65ea92d4a1
Rollup merge of #124980 - zachs18:rc-allocator, r=Amanieu
Generalize `fn allocator` for Rc/Arc.

Split out from #119761

- For `Rc`/`Arc`, the existing associated `fn`s are changed to allow unsized pointees.
 - For `Weak`s, new methods are added.

`````@rustbot````` label +A-allocators
2024-07-12 14:37:56 +02:00
Zachary S
0d49862998 Clarify/add must_use messages for more into_raw* functions of alloc types. 2024-07-10 13:05:03 -05:00
Matthias Krüger
aae262cafa
Rollup merge of #127554 - ferrocene:tshepang-add-missing-attribute, r=pietroalbini
do not run test where it cannot run

This was seen on Ferrocene, where we have a custom test target that does not have unwind support
2024-07-10 17:54:26 +02:00
Tshepang Mbambo
af3aa36d60
do not run test where it cannot run
This was seen on Ferrocene, where we have a custom test target that does not have unwind support
2024-07-10 01:00:55 +02:00
Matthias Krüger
5b6eb28bda
Rollup merge of #127355 - aceArt-GmbH:126475, r=oli-obk
Mark format! with must_use hint

Uses unstable feature https://github.com/rust-lang/rust/issues/94745

Part of #126475

First contribution to rust, please let me know if the blessing of tests is correct
Thanks `@bjorn3` for the help
2024-07-08 16:28:15 +02:00
Matthias Krüger
c4ee2df539
Rollup merge of #120248 - WaffleLapkin:bonk-ptr-object-casts, r=compiler-errors,oli-obk,lnicola
Make casts of pointers to trait objects stricter

This is an attempt to `fix` https://github.com/rust-lang/rust/issues/120222 and https://github.com/rust-lang/rust/issues/120217.

This is done by adding restrictions on casting pointers to trait objects.

Before this PR the rules were as follows:

> When casting `*const X<dyn A>` -> `*const Y<dyn B>`, principal traits in `A` and `B` must refer to the same trait definition (or no trait).

With this PR the rules are changed to

> When casting `*const X<dyn Src>` -> `*const Y<dyn Dst>`
> - if `Dst` has a principal trait `DstP`,
>   - `Src` must have a principal trait `SrcP`
>   - `dyn SrcP` and `dyn DstP` must be the same type (modulo the trait object lifetime, `dyn T+'a` -> `dyn T+'b` is allowed)
>   - Auto traits in `Dst` must be a subset of auto traits in `Src`
>     - Not adhering to this is currently a FCW (warn-by-default + `FutureReleaseErrorReportInDeps`), instead of an error
> - if `Src` has a principal trait `Dst` must as well
>   - this restriction will be removed in a follow up PR

This ensures that
1. Principal trait's generic arguments match (no `*const dyn Tr<A>` -> `*const dyn Tr<B>` casts, which are a problem for [#120222](https://github.com/rust-lang/rust/issues/120222))
2. Principal trait's lifetime arguments match (no `*const dyn Tr<'a>` -> `*const dyn Tr<'b>` casts, which are a problem for [#120217](https://github.com/rust-lang/rust/issues/120217))
3. No auto traits can be _added_ (this is a problem for arbitrary self types, see [this comment](https://github.com/rust-lang/rust/pull/120248#discussion_r1463835350))

Some notes:
 - We only care about the metadata/last field, so you can still cast `*const dyn T` to `*const WithHeader<dyn T>`, etc
- The lifetime of the trait object itself (`dyn A + 'lt`) is not checked, so you can still cast `*mut FnOnce() + '_` to `*mut FnOnce() + 'static`, etc
  - This feels fishy, but I couldn't come up with a reason it must be checked

The diagnostics are currently not great, to say the least, but as far as I can tell this correctly fixes the issues.

cc `@oli-obk` `@compiler-errors` `@lcnr`
2024-07-08 16:28:15 +02:00
许杰友 Jieyou Xu (Joe)
e76b01775c
Rollup merge of #127367 - ChrisDenton:run-sync, r=Nilstrieb
Run alloc sync tests

I was browsing the code and this struck me as weird. We're not running some doc tests because, the comment says, Windows builders deadlock. That should absolutely not happen, at least with our current implementation. And if it does happen I'd like to know.

Just to be sure though I'll do some try builds.

try-job: x86_64-msvc
try-job: i686-msvc
try-job: i686-mingw
try-job: x86_64-mingw
2024-07-08 13:04:31 +08:00
bors
0ca92de473 Auto merge of #127454 - matthiaskrgr:rollup-k3vfen2, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #127179 (Print `TypeId` as hex for debugging)
 - #127189 (LinkedList's Cursor: method to get a ref to the cursor's list)
 - #127236 (doc: update config file path in platform-support/wasm32-wasip1-threads.md)
 - #127297 (Improve std::Path's Hash quality by avoiding prefix collisions)
 - #127308 (Attribute cleanups)
 - #127354 (Describe Sized requirements for mem::offset_of)
 - #127409 (Emit a wrap expr span_bug only if context is not tainted)
 - #127447 (once_lock: make test not take as long in Miri)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-07-07 16:29:52 +00:00
Matthias Krüger
94d07befe7
Rollup merge of #127189 - GrigorenkoPV:linkedlist-cursor-list, r=Nilstrieb
LinkedList's Cursor: method to get a ref to the cursor's list

We're already providing `.back()` & `.front()`, for which we hold onto a reference to the parent list, so why not share it? Useful for when you got `LinkedList` -> `CursorMut` -> `Cursor` and cannot take another ref to the list, even though you should be able to. This seems to be completely safe & sound.

The name is, of course, bikesheddable.
2024-07-07 14:21:59 +02:00
Chayim Refael Friedman
54556f49d3 Specialize TrustedLen for Iterator::unzip()
Don't check the capacity every time (and also for `Extend` for tuples, as this is how `unzip()` is implemented).

I did this with an unsafe method on `Extend` that doesn't check for growth (`extend_one_unchecked()`). I've marked it as perma-unstable currently, although we may want to expose it in the future so collections outside of std can benefit from it. Then specialize `Extend for (A, B)` for `TrustedLen` to call it.

It may seem that an alternative way of implementing this is to have a semi-public trait (`#[doc(hidden)]` public, so collections outside of core can implement it) for `extend()` inside tuples, and specialize it from collections. However, it is impossible due to limitations of `min_specialization`.

A concern that may arise with the current approach is that implementing `extend_one_unchecked()` correctly must also incur implementing `extend_reserve()`, otherwise you can have UB. This is a somewhat non-local safety invariant. However, I believe this is fine, since to have actual UB you must have unsafe code inside your `extend_one_unchecked()` that makes incorrect assumption, *and* not implement `extend_reserve()`. I've also documented this requirement.
2024-07-07 06:58:52 +03:00
Zachary S
e0ed696d2f Mitigate focused memory leaks in alloc doctests for Miri.
If/when `-Zmiri-disable-leak-check` is able to be used at test-granularity, it should applied to these tests instead of unleaking.
2024-07-06 22:35:19 -05:00
Zachary S
93e3c00670 Remove non-focused memory leaks in alloc doctests for Miri. 2024-07-06 22:24:00 -05:00
Aljoscha Meyer
497ef49805
Fix them doc examples some more
Apologies for the many attempts, my dev loop for this consists of editing on github, committing, and then waiting for the CI failure log to yell at me.
2024-07-06 19:13:53 +02:00
Aljoscha Meyer
6b5da82d12
Fix doc examples 2024-07-06 18:50:03 +02:00
Aljoscha Meyer
9bfdeb592c
Run formatter on alloc/src/boxed.rs 2024-07-06 14:38:00 +02:00
lukas
3e9c9a05a8 Mark format! with must_use hint 2024-07-06 14:24:20 +02:00
Aljoscha Meyer
2c14dd3b12
Add missing try_new_uninit_slice_in and try_new_zeroed_slice_in
The methods for fallible slice allocation in a given allocator were missing, which was an oversight according to https://github.com/rust-lang/wg-allocators/issues/130

This PR adds them as `try_new_uninit_slice_in` and `try_new_zeroed_slice_in`.

Also adds missing punctuation to the doc comments of ` try_new_uninit_slice` and `try_new_zeroed_slice`
2024-07-06 09:09:10 +02:00
Chris Denton
7566f41209
Run alloc sync tests 2024-07-05 14:48:39 +00:00
Maybe Waffle
5645e8e285 Add more checks for pointers with vtable meta
The rules for casting `*mut X<dyn A>` -> `*mut Y<dyn B>` are as follows:
- If `B` has a principal
  - `A` must have exactly the same principal (including generics)
  - Auto traits of `B` must be a subset of autotraits in `A`

Note that `X<_>` and `Y<_>` can be identity, or arbitrary structs with last field being the dyn type.
The lifetime of the trait object itself (`dyn ... + 'a`) is not checked.

This prevents a few soundness issues with `#![feature(arbitrary_self_types)]` and trait upcasting.
Namely, these checks make sure that vtable is always valid for the pointee.
2024-07-04 17:56:09 +02:00
Jacob Pratt
db592253a6
Rollup merge of #123588 - tgross35:stabilize-assert_unchecked, r=dtolnay
Stabilize `hint::assert_unchecked`

Make the following API stable, including const:

```rust
// core::hint, std::hint

pub const unsafe fn assert_unchecked(p: bool);
```

This PR also reworks some of the documentation and adds an example.

Tracking issue: https://github.com/rust-lang/rust/issues/119131
FCP: https://github.com/rust-lang/rust/issues/119131#issuecomment-1906394087. The docs update should resolve the remaining concern.
2024-07-03 03:03:13 -04:00
Scott McMurray
23c8ed14c9 Avoid MIR bloat in inlining
In 126578 we ended up with more binary size increases than expected.

This change attempts to avoid inlining large things into small things, to avoid that kind of increase, in cases when top-down inlining will still be able to do that inlining later.
2024-07-01 05:17:13 -07:00
bors
b8d7dd8d69 Auto merge of #127026 - Urgau:cleanup-bootstrap-check-cfg, r=Kobzol
Cleanup bootstrap check-cfg

This PR cleanup many custom `check-cfg` in bootstrap that have been accumulated over the years.

As well as updating some outdated comments.
2024-06-30 22:27:29 +00:00
Pavel Grigorenko
23e5468a09 LinkedList's Cursor: method to get a ref to the cursor's list 2024-07-01 00:22:09 +03:00
Matthias Krüger
2c228260dc
Rollup merge of #126970 - DaniPopes:simplify-str-clone_into, r=cuviper
Simplify `str::clone_into`

Removes an `unsafe` in favor of just using `String` methods.
2024-06-28 08:34:09 +02:00
Urgau
f026e0bfc1 Cleanup bootstrap check-cfg 2024-06-27 11:30:03 +02:00
Jacob Pratt
d3debc0037
Rollup merge of #126929 - nnethercote:rm-__rust_force_expr, r=oli-obk
Remove `__rust_force_expr`.

This was added (with a different name) to improve an error message. It is no longer needed -- removing it changes the error message, but overall I think the new message is no worse:
- the mention of `#` in the first line is a little worse,
- but the extra context makes it very clear what the problem is, perhaps even clearer than the old message,
- and the removal of the note about the `expr` fragment (an internal detail of `__rust_force_expr`) is an improvement.

Overall I think the error is quite clear and still far better than the old message that prompted #61933, which didn't even mention patterns.

The motivation for this is #124141, which will cause pasted metavariables to be tokenized and reparsed instead of the AST node being cached. This change in behaviour occasionally has a non-zero perf cost, and `__rust_force_expr` causes the tokenize/reparse step to occur twice. Removing `__rust_force_expr` greatly reduces the extra overhead for the `deep-vector` benchmark.

r? ```@oli-obk```
2024-06-27 02:06:19 -04:00
DaniPopes
d5ff4f4f65
Simplify str::clone_into
Removes an `unsafe` in favor of just using `String` methods.
2024-06-25 22:34:41 +02:00
Matthias Krüger
58bbade921
Rollup merge of #126302 - mu001999-contrib:ignore/default, r=michaelwoerister
Detect unused structs which derived Default

<!--
If this PR is related to an unstable feature or an otherwise tracked effort,
please link to the relevant tracking issue here. If you don't know of a related
tracking issue or there are none, feel free to ignore this.

This PR will get automatically assigned to a reviewer. In case you would like
a specific user to review your work, you can assign it to them by using

    r​? <reviewer name>
-->

Fixes #98871
2024-06-25 21:33:41 +02:00
mu001999
6997b6876d Detect unused structs which derived Default 2024-06-25 23:29:44 +08:00
Nicholas Nethercote
9828e960ab Remove __rust_force_expr.
This was added (with a different name) to improve an error message. It
is no longer needed -- removing it changes the error message, but overall
I think the new message is no worse:
- the mention of `#` in the first line is a little worse,
- but the extra context makes it very clear what the problem is, perhaps
  even clearer than the old message,
- and the removal of the note about the `expr` fragment (an internal
  detail of `__rust_force_expr`) is an improvement.

Overall I think the error is quite clear and still far better than the
old message that prompted #61933, which didn't even mention patterns.

The motivation for this is #124141, which will cause pasted
metavariables to be tokenized and reparsed instead of the AST node being
cached. This change in behaviour occasionally has a non-zero perf cost,
and `__rust_force_expr` causes the tokenize/reparse step to occur twice.
Removing `__rust_force_expr` greatly reduces the extra overhead for the
`deep-vector` benchmark.
2024-06-25 14:35:09 +10:00
Kevin Reid
13fca73f49 Replace MaybeUninit::uninit_array() with array repeat expression.
This is possible now that inline const blocks are stable; the idea was
even mentioned as an alternative when `uninit_array()` was added:
<https://github.com/rust-lang/rust/pull/65580#issuecomment-544200681>

> if it’s stabilized soon enough maybe it’s not worth having a
> standard library method that will be replaceable with
> `let buffer = [MaybeUninit::<T>::uninit(); $N];`

Const array repetition and inline const blocks are now stable (in the
next release), so that circumstance has come to pass, and we no longer
have reason to want `uninit_array()` other than convenience. Therefore,
let’s evaluate the inconvenience by not using `uninit_array()` in
the standard library, before potentially deleting it entirely.
2024-06-24 10:23:50 -07:00
bors
a0f01c3c10 Auto merge of #126838 - matthiaskrgr:rollup-qkop22o, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #126140 (Rename `std::fs::try_exists` to  `std::fs::exists` and stabilize fs_try_exists)
 - #126318 (Add a `x perf` command for integrating bootstrap with `rustc-perf`)
 - #126552 (Remove use of const traits (and `feature(effects)`) from stdlib)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-22 18:48:10 +00:00