9295 Commits

Author SHA1 Message Date
Marijn Schouten
b315e9a2ce clippy fix: rely on autoderef 2025-07-04 11:35:00 +00:00
Jacob Pratt
e4e26d2acb
Rollup merge of #143395 - Urgau:llvm-fallback-minimum-maximum, r=tgross35
Always use the pure Rust fallback instead of `llvm.{maximum,minimum}`

While https://github.com/llvm/llvm-project/pull/142170 was merged, it was reverted and next attempt (https://github.com/llvm/llvm-project/pull/140193) at fixing the LLVM implementation seems to have stall, so let's reverted back to pure Rust with the LLVM codegen.

cc [#t-compiler/llvm > `llvm.minimum`/`llvm.maximum` issues @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/187780-t-compiler.2Fllvm/topic/.60llvm.2Eminimum.60.2F.60llvm.2Emaximum.60.20issues/near/527044712)

Fixes https://github.com/rust-lang/rust/issues/141087
r? `@tgross35`
2025-07-04 05:47:29 +02:00
Jacob Pratt
e55514bbbe
Rollup merge of #143378 - hkBst:clippy-fix-6, r=tgross35
simplify receivers for some array method calls
2025-07-04 05:47:26 +02:00
Jacob Pratt
5adf3ef339
Rollup merge of #143370 - hkBst:clippy-fix-4, r=tgross35
remove redundant #[must_use]

Fixes these clippy warnings:
```
warning: this function has a `#[must_use]` attribute with no message, but returns a type already marked as `#[must_use]`
    --> library/core/src/cmp.rs:1456:5
     |
1456 |     fn __chaining_lt(&self, other: &Rhs) -> ControlFlow<bool> {
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = help: either add some descriptive message or remove the attribute
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#double_must_use
     = note: `-D clippy::double-must-use` implied by `-D warnings`
     = help: to override `-D warnings` add `#[allow(clippy::double_must_use)]`

warning: this function has a `#[must_use]` attribute with no message, but returns a type already marked as `#[must_use]`
    --> library/core/src/cmp.rs:1465:5
     |
1465 |     fn __chaining_le(&self, other: &Rhs) -> ControlFlow<bool> {
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = help: either add some descriptive message or remove the attribute
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#double_must_use

warning: this function has a `#[must_use]` attribute with no message, but returns a type already marked as `#[must_use]`
    --> library/core/src/cmp.rs:1474:5
     |
1474 |     fn __chaining_gt(&self, other: &Rhs) -> ControlFlow<bool> {
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = help: either add some descriptive message or remove the attribute
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#double_must_use

warning: this function has a `#[must_use]` attribute with no message, but returns a type already marked as `#[must_use]`
    --> library/core/src/cmp.rs:1483:5
     |
1483 |     fn __chaining_ge(&self, other: &Rhs) -> ControlFlow<bool> {
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = help: either add some descriptive message or remove the attribute
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#double_must_use
```
2025-07-04 05:47:26 +02:00
Jacob Pratt
7c68a8db3e
Rollup merge of #143356 - hkBst:clippy-fix-2, r=scottmcm
use unsigned_abs instead of `abs` on signed int to silence clippy

Use `unsigned_abs` instead of `abs` on signed int to silence clippy. Alternatively we could allow the lint, but if codegen is not affected, then this seems preferable.
2025-07-04 05:47:25 +02:00
Jacob Pratt
e080bc8751
Rollup merge of #142749 - LimpSquid:bool_to_result, r=scottmcm
Add methods for converting bool to `Result<(), E>`

## Tracking Issue

https://github.com/rust-lang/rust/issues/142748

## ACP

https://github.com/rust-lang/libs-team/issues/606
2025-07-04 05:47:22 +02:00
Michael Goulet
e2e3f5809b Remove PointerLike trait 2025-07-03 20:03:49 +00:00
Urgau
51857ade80 Always use the pure Rust fallback instead of llvm.{maximum,minimum} 2025-07-03 21:04:18 +02:00
Guillaume Gomez
9943c1933d Use slice_buffer_to_str in GenericRadix::fmt_int 2025-07-03 18:57:16 +02:00
Guillaume Gomez
82c6037b2a Implement int_format_into feature 2025-07-03 18:57:16 +02:00
Deadbeef
3c56c2ecf5 stabilize const_slice_reverse 2025-07-03 23:39:58 +08:00
Marijn Schouten
d3f2e2ec6e simplify receivers for some array method calls 2025-07-03 14:39:27 +00:00
Marijn Schouten
1c3454af55 remove redundant #[must_use] 2025-07-03 13:44:35 +00:00
Jana Dönszelmann
f85283b0d4
Rollup merge of #143329 - folkertdev:minicore-diagnostic-on-unimplemented, r=jieyouxu
minicore: use core's `diagnostic::on_unimplemented` messages

Without these attributes, the error message is different. Keeping the diagnostics up-to-date seems related to https://github.com/rust-lang/rust/issues/137531.

The modified test files are reported in https://github.com/rust-lang/rust/issues/143319 as failing for `--target=riscv64gc-unknown-linux-gnu`. Using `minicore` for them makes it easier to troubleshoot this sort of issue.

r? ``@jieyouxu``
2025-07-03 13:29:39 +02:00
Jana Dönszelmann
f6d37a25a9
Rollup merge of #134006 - klensy:typos, r=nnethercote
setup typos check in CI

This allows to check typos in CI, currently for compiler only (to reduce commit size with fixes). With current setup, exclude list is quite short, so it worth trying?

Also includes commits with actual typo fixes.

MCP: https://github.com/rust-lang/compiler-team/issues/817

typos check currently turned for:
* ./compiler
* ./library
* ./src/bootstrap
* ./src/librustdoc

After merging, PRs which enables checks for other crates (tools) can be implemented too.

Found typos will **not break** other jobs immediately: (tests, building compiler for perf run). Job will be marked as red on completion in ~ 20 secs, so you will not forget to fix it whenever you want, before merging pr.

Check typos: `python x.py test tidy --extra-checks=spellcheck`
Apply typo fixes: `python x.py test tidy --extra-checks=spellcheck:fix` (in case if there only 1 suggestion of each typo)

Current fail in this pr is expected and shows how typo errors emitted. Commit with error will be removed after r+.
2025-07-03 13:29:35 +02:00
clubby789
21c8715bf7 Link to 2024 edition page for ! fallback changes 2025-07-03 10:20:53 +00:00
Marijn Schouten
d9505f0b32 use unsigned_abs instead of abs on signed int to silence clippy 2025-07-03 09:20:57 +00:00
Marijn Schouten
f1b5a5638e wrapping shift: remove first bitmask and table 2025-07-03 09:05:50 +00:00
Folkert de Vries
8512e39769
minicore: use core's diagnostic::on_unimplemented messages 2025-07-03 10:22:40 +02:00
klensy
c76d032f01 setup CI and tidy to use typos for spellchecking and fix few typos 2025-07-03 10:51:06 +03:00
Matthias Krüger
bc0262d0f1
Rollup merge of #143327 - RalfJung:miri-type-validity-error, r=oli-obk
miri: improve errors for type validity assertion failures

Miri has pretty nice errors for type validity violations, printing which field in the type the problem occurs at and so on.

However, we don't see these errors when using e.g. `mem::zeroed` as that uses `assert_zero_valid` to bail out before Miri can detect the UB.

Similar to what we did with `@saethlin's` UB checks, I think we should disable such language UB checks in Miri so that we can get better error messages. If we go for this we should probably say this in the intrinsic docs as well so that people don't think they can rely on these intrinsics catching anything.

Furthermore, I slightly changed `MaybeUninit::assume_init` so that the `.value` field does not show up in error messages any more.

`@rust-lang/miri` what do you think?
2025-07-03 05:21:36 +02:00
Matthias Krüger
f000754761
Rollup merge of #143321 - hkBst:typo-1, r=compiler-errors
byte-addresses memory -> byte-addressed memory

Small typo fix
2025-07-03 05:21:34 +02:00
Matthias Krüger
6ebf642a04
Rollup merge of #142237 - benschulz:unused-parens-fn, r=fee1-dead
Detect more cases of unused_parens around types

With this change, more unused parentheses around bounds and types nested within bounds are detected.
2025-07-02 19:29:35 +02:00
Matthias Krüger
7c9a03b969
Rollup merge of #138340 - oli-obk:one-size-fits-all, r=m-ou-se
Remove some unsized tuple impls now that we don't support unsizing tuples anymore

Since https://github.com/rust-lang/rust/pull/137728 there is no sound way to create unsized tuples anymore. While we can't remove them from the language (tried here: https://github.com/rust-lang/rust/pull/138093) due to people using `PhantomData<(T, U)>` where `U: ?Sized` (they'd have to use `(PhantomData<T>, PhantomData<U>)` now), we can remove the impls from libcore I believe.

r? libs I guess?
2025-07-02 19:29:34 +02:00
Matthias Krüger
e0499e4583
Rollup merge of #131923 - ranger-ross:impl-copy-hash-interrorkind, r=tgross35
Derive `Copy` and `Hash` for `IntErrorKind`

This PR derives `Copy` and `Hash` for `IntErrorKind` to make it easier to work with. (see #131826)

I think an argument could be made to also derive `PartialOrd` + `Ord` as well given that other error kinds in the std like [`io::ErrorKind`](https://doc.rust-lang.org/src/std/io/error.rs.html#212-428) do this. Granted these seem much less useful for errors.

Fixes https://github.com/rust-lang/rust/issues/131826
2025-07-02 19:29:33 +02:00
Ralf Jung
8362508989 miri: improve errors for type validity assertion failures 2025-07-02 17:47:46 +02:00
Oli Scherer
845d9ff963 Remove some unsized tuple impls now that we don't support unsizing tuples anymore 2025-07-02 14:17:54 +00:00
Marijn Schouten
674724c741 remove deprecated from core::ffi::c_str 2025-07-02 12:30:05 +00:00
Marijn Schouten
626ca82faf byte-addresses memory -> byte-addressed memory 2025-07-02 11:18:02 +00:00
bors
f51c9870ba Auto merge of #142974 - cuviper:stage0-bump, r=Mark-Simulacrum
Update stage0 to 1.89.0-beta.1

- Update version placeholders
- Update stage0 to 1.89.0-beta.1
- Update `STAGE0_MISSING_TARGETS`
- Update `cfg(bootstrap)`

r? `@Mark-Simulacrum`

try-job: dist-i586-gnu-i586-i686-musl
2025-07-02 01:41:18 +00:00
Nurzhan Saken
79ed7c1f41
Test upper overflow in strict_sub_signed
Co-authored-by: zachs18 <8355914+zachs18@users.noreply.github.com>
2025-07-01 22:32:19 +04:00
Josh Stone
5b073e5ba6 Ignore float_minimum_maximum doctests on i586 2025-07-01 10:55:49 -07:00
Josh Stone
e851e3e16e Update cfg(bootstrap) 2025-07-01 10:55:49 -07:00
Josh Stone
9ce8930da6 Update version placeholders 2025-07-01 10:54:33 -07:00
Guillaume Gomez
988710840b
Rollup merge of #141867 - Diggsey:db-improve-future-docs, r=tgross35
Describe Future invariants more precisely
2025-07-01 17:47:00 +02:00
Guillaume Gomez
ad6503983d
Rollup merge of #136801 - sorairolake:add-random-for-tuple, r=joshtriplett
Implement `Random` for tuple

Implement `Random` for tuples of arity 12 or less. Each element is expected to implement `Random`.

I think it's OK to implement this trait for the following types:

- Primitive integer types and `bool`
- Arrays and tuples of the above values
- ~~`NonZero<T>`~~, `Saturating<T>` and `Wrapping<T>`

The necessity of this trait is debated (<https://github.com/rust-lang/rust/issues/130703#issuecomment-2508889577>), but if we decide to keep it in the future when the `random` module is stabilized, I think it would be useful to have this trait implemented for tuples.

Tracking issue: #130703

r? `@joboet`
2025-07-01 17:46:59 +02:00
Nurzhan Sakén
c42b1773fe Add uX::strict_sub_signed 2025-07-01 17:02:32 +04:00
Benoît du Garreau
136d24fd7f core: Add BorrowedCursor::with_unfilled_buf
Implementation of https://github.com/rust-lang/libs-team/issues/367.

This mainly adds `BorrowedCursor::with_unfilled_buf`, with enables using
the unfilled part of a cursor as a `BorrowedBuf`.

Note that unlike the ACP, `BorrowedCursor::unfilled_buf` was moved to a
`From` conversion. This is more consistent with other ways of creating a
`BorrowedBuf` and hides a bit this conversion that requires unsafe code
to be used correctly.
2025-07-01 14:03:54 +02:00
Benjamin Schulz
7d6764a45b Detect more cases of unused_parens around types 2025-07-01 08:56:20 +02:00
Scott McMurray
fd3161c201 Mention as_chunks in the docs for chunks 2025-06-30 18:58:43 -07:00
bors
c65dccabac Auto merge of #143233 - dianqk:rollup-lcx3278, r=dianqk
Rollup of 14 pull requests

Successful merges:

 - rust-lang/rust#142429 (`tests/ui`: A New Order [13/N])
 - rust-lang/rust#142514 (Miri: handling of SNaN inputs in `f*::pow` operations)
 - rust-lang/rust#143066 (Use let chains in the new solver)
 - rust-lang/rust#143090 (Workaround for memory unsafety in third party DLLs)
 - rust-lang/rust#143118 (`tests/ui`: A New Order [15/N])
 - rust-lang/rust#143159 (Do not freshen `ReError`)
 - rust-lang/rust#143168 (`tests/ui`: A New Order [16/N])
 - rust-lang/rust#143176 (fix typos and improve clarity in documentation)
 - rust-lang/rust#143187 (Add my work email to mailmap)
 - rust-lang/rust#143190 (Use the `new` method for `BasicBlockData` and `Statement`)
 - rust-lang/rust#143195 (`tests/ui`: A New Order [17/N])
 - rust-lang/rust#143196 (Port #[link_section] to the new attribute parsing infrastructure)
 - rust-lang/rust#143199 (Re-disable `tests/run-make/short-ice` on Windows MSVC again)
 - rust-lang/rust#143219 (Show auto trait and blanket impls for `!`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-30 14:28:58 +00:00
Nurzhan Sakén
468f91314b Stabilize mixed_integer_ops_unsigned_sub 2025-06-30 17:37:38 +04:00
Oli Scherer
d37a04d09d Remove the nullary intrinsic const eval logic and treat them like other intrinsics 2025-06-30 08:04:40 +00:00
Oli Scherer
672e0bec9e Stop backends from needing to support nullary intrinsics 2025-06-30 08:04:19 +00:00
zachs18
d98aaf7f80
Show auto trait and blanket impls for !
Add an empty `impl ! {}` so `rustdoc` generates auto trait impls and blanket impls on `!`'s documentation page.
2025-06-29 18:38:46 -05:00
Guillaume Gomez
66ad1f2abf
Rollup merge of #142078 - sayantn:more-intrinsics, r=workingjubilee
Add SIMD funnel shift and round-to-even intrinsics

This PR adds 3 new SIMD intrinsics

 - `simd_funnel_shl` - funnel shift left
 - `simd_funnel_shr` - funnel shift right
 - `simd_round_ties_even` (vector version of `round_ties_even_fN`)

TODO (future PR): implement `simd_fsh{l,r}` in miri, cg_gcc and cg_clif (it is surprisingly hard to implement without branches, the common tricks that rotate uses doesn't work because we have 2 elements now. e.g, the `-n&31` trick used by cg_gcc to implement rotate doesn't work with this because then `fshl(a, b, 0)` will be `a | b`)

[#t-compiler > More SIMD intrinsics](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/More.20SIMD.20intrinsics/with/522130286)

`@rustbot` label T-compiler T-libs A-intrinsics F-core_intrinsics
r? `@workingjubilee`
2025-06-29 12:29:53 +02:00
Matthias Krüger
c6de7ca41a
Rollup merge of #142708 - Darksonn:location-len-without-nul, r=Mark-Simulacrum
Do not include NUL-terminator in computed length

This PR contains just the first commit of rust-lang/rust#142579 which changes it so that the string length stored in the `Location` is the length of the `&str` rather than the length of the `&CStr`. Since most users will want the `&str` length, it seems better to optimize for that use-case.

There should be no visible changes in the behavior or API.
2025-06-28 22:05:28 +02:00
bors
b63223c152 Auto merge of #141759 - 1c3t3a:discriminants-query, r=saethlin
Insert checks for enum discriminants when debug assertions are enabled

Similar to the existing null-pointer and alignment checks, this checks for valid enum discriminants on creation of enums through unsafe transmutes. Essentially this sanitizes patterns like the following:
```rust
let val: MyEnum = unsafe { std::mem::transmute<u32, MyEnum>(42) };
```

An extension of this check will be done in a follow-up that explicitly sanitizes for extern enum values that come into Rust from e.g. C/C++.

This check is similar to Miri's capabilities of checking for valid construction of enum values.

This PR is inspired by saethlin@'s PR
https://github.com/rust-lang/rust/pull/104862. Thank you so much for keeping this code up and the detailed comments!

I also pair-programmed large parts of this together with vabr-g@.

r? `@saethlin`
2025-06-28 10:25:00 +00:00
Bastian Kersting
1087042e22 Insert checks for enum discriminants when debug assertions are enabled
Similar to the existing nullpointer and alignment checks, this checks
for valid enum discriminants on creation of enums through unsafe
transmutes. Essentially this sanitizes patterns like the following:
```rust
let val: MyEnum = unsafe { std::mem::transmute<u32, MyEnum>(42) };
```
An extension of this check will be done in a follow-up that explicitly
sanitizes for extern enum values that come into Rust from e.g. C/C++.

This check is similar to Miri's capabilities of checking for valid
construction of enum values.

This PR is inspired by saethlin@'s PR
https://github.com/rust-lang/rust/pull/104862. Thank you so much for
keeping this code up and the detailed comments!

I also pair-programmed large parts of this together with vabr-g@.
2025-06-27 09:37:36 +00:00
bors
e61dd437f3 Auto merge of #143074 - compiler-errors:rollup-cv64hdh, r=compiler-errors
Rollup of 18 pull requests

Successful merges:

 - rust-lang/rust#137843 (make RefCell unstably const)
 - rust-lang/rust#140942 (const-eval: allow constants to refer to mutable/external memory, but reject such constants as patterns)
 - rust-lang/rust#142549 (small iter.intersperse.fold() optimization)
 - rust-lang/rust#142637 (Remove some glob imports from the type system)
 - rust-lang/rust#142647 ([perf] Compute hard errors without diagnostics in impl_intersection_has_impossible_obligation)
 - rust-lang/rust#142700 (Remove incorrect comments in `Weak`)
 - rust-lang/rust#142927 (Add note to `find_const_ty_from_env`)
 - rust-lang/rust#142967 (Fix RwLock::try_write documentation for WouldBlock condition)
 - rust-lang/rust#142986 (Port `#[export_name]` to the new attribute parsing infrastructure)
 - rust-lang/rust#143001 (Rename run always )
 - rust-lang/rust#143010 (Update `browser-ui-test` version to `0.20.7`)
 - rust-lang/rust#143015 (Add `sym::macro_pin` diagnostic item for `core::pin::pin!()`)
 - rust-lang/rust#143033 (Expand const-stabilized API links in relnotes)
 - rust-lang/rust#143041 (Remove cache for citool)
 - rust-lang/rust#143056 (Move an ACE test out of the GCI directory)
 - rust-lang/rust#143059 (Fix 1.88 relnotes)
 - rust-lang/rust#143067 (Tracking issue number for `iter_macro`)
 - rust-lang/rust#143073 (Fix some fixmes that were waiting for let chains)

Failed merges:

 - rust-lang/rust#143020 (codegen_fn_attrs: make comment more precise)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-27 00:44:20 +00:00