Commit Graph

2796 Commits

Author SHA1 Message Date
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
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
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
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
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