Commit Graph

327442 Commits

Author SHA1 Message Date
Jacob Pratt 445a129436 Rollup merge of #156833 - onehr:ice-test-142913, r=TaKO8Ki
Add regression test for const parameter default ICE

Closes rust-lang/rust#142913

This adds a UI regression test for a fixed ICE where a const generic parameter
type mentioned an earlier lifetime and also had a default value.

The reproducer is the minimized version posted in the issue.

Tested:
- ./x test tests/ui/const-generics/generic_const_parameter_types/region-parameter-out-of-range-ice-142913.rs --force-rerun
- ./x test tidy --bless
2026-05-24 16:39:42 +02:00
Jacob Pratt 9c63e94ef7 Rollup merge of #156810 - Teufelchen1:fix_doc_typo, r=SimonSapin
Fix doc typo in Vec::into_array and convert Arc/Box/Rc::into_arry to -> Result

Hello 🪼,

the first commit fixes a documentation mistake added in the recent PR rust-lang/rust#156234

The second commit addresses three function signature changes as defined by the tracking issue rust-lang/rust#148082
It converts all `.into_array() -> Option<>` into `.into_array() -> Result<>`

The third commit is a fixup for the second. The change is needed as calling `unwrap()` on `Err(E)` requires `E` to implement `Debug`. I thought `Vec<T, A> where T: Debug` is not an acceptable solution, so I tried to come up with my own. I am *NOT* confident in my `unsafe {}`  code due to lack of expierence, please check extra carefully.

Appreciating feedback & greetings from the RustWeek,
Thanks!
2026-05-24 16:39:41 +02:00
Jacob Pratt 81eb844071 Rollup merge of #156824 - CoCo-Japan-pan:mut-restriction-parse, r=Urgau,jhpratt
Parse `mut` restrictions

This PR is part of the progress implementing `mut` restrictions proposed in [RFC 3323](https://rust-lang.github.io/rfcs/3323-restrictions.html), and linked to a [GSoC proposal](https://rust-lang.zulipchat.com/#narrow/channel/421156-gsoc/topic/Project.3A.20Implementing.20impl.20and.20mut.20restrictions/with/592352432).
This PR focuses solely on the parsing of `mut` restrictions.
The keyword order is `pub(...) mut(...) unsafe field`.
The new syntax is guared by `#[feature(mut_restriction)]` feature gate.
Tracking Issue: rust-lang/rust#105077

r? @Urgau
cc @jhpratt
2026-05-24 16:39:41 +02:00
bors a06c1ca53a Auto merge of #156839 - qaijuang:fix-single-use-lifetimes-impl-bounds, r=mu001999
[single_use_lifetimes]: Account for lifetime bounds

This PR makes `single_use_lifetimes` account for bounds on lifetime parameters, so a lifetime such as `'b` in `<'a, 'b: 'a>` is not treated as single-use just because its bound is stored separately from ordinary lifetime uses.

Fixes rust-lang/rust#153836
2026-05-24 09:47:31 +00:00
Bennet Blischke 8b382d62df Return result instead of option by Arc/Rc/Box::into_array 2026-05-24 11:39:35 +02:00
Haoran Wang 3e247a8ff4 Add regression test for const parameter default ICE 2026-05-24 17:14:33 +08:00
CoCo-Japan-pan 572a2e4177 Bless UI test for input-stats.rs 2026-05-24 17:34:01 +09:00
CoCo-Japan-pan d3bb7198e7 Add stringify! tests 2026-05-24 17:34:01 +09:00
CoCo-Japan-pan cb3173473c Add UI tests 2026-05-24 17:34:01 +09:00
CoCo-Japan-pan dbb7b811ee rustfmt mut restriction 2026-05-24 17:34:01 +09:00
CoCo-Japan-pan 9aa5a17cee Add eq_mut_restriction to clippy_utils 2026-05-24 17:34:01 +09:00
CoCo-Japan-pan a8a6aa8f59 Pretty print mut restrictions 2026-05-24 17:34:01 +09:00
CoCo-Japan-pan c43fa7a8bb Parse mut restrictions 2026-05-24 17:33:46 +09:00
Qai Juang ccb9e9e84a account for lifetime bounds in single_use_lifetimes 2026-05-24 04:15:17 -04:00
bors 06b13d50ca Auto merge of #156870 - JonathanBrouwer:rollup-PbM4nVA, r=JonathanBrouwer
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#156769 (Use print instead of po in debuginfo path test)
 - rust-lang/rust#156784 (Fix reborrow_info early return skipping field validation)
 - rust-lang/rust#156827 (float_literal_f32_fallback: Don't suggest invalid code)
 - rust-lang/rust#156828 (Add unstable Share trait)
 - rust-lang/rust#156830 (Add `#[doc(alias = "phi")]` for float `GOLDEN_RATIO` constants)
 - rust-lang/rust#156860 (Fix Pieter-Louis Schoeman mailmap entry)
2026-05-24 06:29:32 +00:00
Jonathan Brouwer 28436418fa Rollup merge of #156860 - P8L1:fix/pieter-louis-schoeman-mailmap, r=jieyouxu
Fix Pieter-Louis Schoeman mailmap entry

I'm listed twice on thanks.rust-lang
2026-05-24 08:27:22 +02:00
Jonathan Brouwer e8d2321b41 Rollup merge of #156830 - okaneco:phi_doc_alias, r=SimonSapin
Add `#[doc(alias = "phi")]` for float `GOLDEN_RATIO` constants

- Adds "phi" doc alias for `f16`, `f32`, `f64`, and `f128`

I knew this constant was stabilized but I couldn't remember what it was called.
Searching "phi" in the docs only surfaces the π constant, `is_ascii_graphic`, and `spin_loop_hint` methods. This alias would make it much easier to find.
https://doc.rust-lang.org/nightly/std/?search=phi
2026-05-24 08:27:21 +02:00
Jonathan Brouwer eb68b36521 Rollup merge of #156828 - P8L1:share-trait-core-bootstrap, r=SimonSapin
Add unstable Share trait

Tracking issue: rust-lang/rust#156756

This adds an initial unstable `Share` trait for clone-as-alias types, as part of the 2026 ergonomic ref-counting project goal.

```rust
pub trait Share: Clone {
    fn share(&self) -> Self {
        Clone::clone(self)
    }
}
```

This PR adds a separate unstable feature gate:

```rust
#![feature(share_trait)]
```

and places the trait next to `Clone` in `core::clone`.

Implemented initial impls:

- `impl<T: ?Sized> Share for &T`
- `impl<T: ?Sized, A: Allocator + Clone> Share for Rc<T, A>`
- `impl<T: ?Sized, A: Allocator + Clone> Share for Arc<T, A>`
- `impl<T> Share for std::sync::mpsc::Sender<T>`
- `impl<T> Share for std::sync::mpsc::SyncSender<T>`

The PR deliberately does not add `Share` to the prelude.

r? @nikomatsakis
@rustbot label F-ergonomic_clones
2026-05-24 08:27:21 +02:00
Jonathan Brouwer e938cd8409 Rollup merge of #156827 - SpecificProtagonist:float_literal_f32_fallback-suggestion, r=Kivooeo
float_literal_f32_fallback: Don't suggest invalid code

When a float literal ended with a dot, `float_literal_f32_fallback` should not include it in its suggestion, as that would result in invalid syntax ([playgound](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=de47274bf2b07070b79a97ce6744ffcbO)):

```
2 |     let _: f32 = From::from(0.);
  |                             ^^ help: explicitly specify the type as `f32`: `0._f32`
```

Relevant tracking issue: rust-lang/rust#154024
2026-05-24 08:27:20 +02:00
Jonathan Brouwer f38e177068 Rollup merge of #156784 - ikow:fix/reborrow-early-return, r=dingxiangfei2009
Fix reborrow_info early return skipping field validation

`reborrow_info` validates that all data fields of a struct implementing `Reborrow` are either `Copy` or themselves `Reborrow`. When iterating the fields, finding a `Reborrow` field returned `Ok(())` immediately, so any remaining fields were never validated. This let a struct with a non-`Copy`, non-`Reborrow` second field implement `Reborrow`.

Changing the early `return Ok(())` to `continue` makes the loop validate every field.

Tracking issue: rust-lang/rust#145612
2026-05-24 08:27:19 +02:00
Jonathan Brouwer 447466869a Rollup merge of #156769 - fallofpheonix:fix-path-lldb-macos, r=jieyouxu
Use print instead of po in debuginfo path test

Fixes rust-lang/rust#156660

This fixes `tests/debuginfo/path.rs` failing on newer Apple LLDB versions.

Root cause:
Apple LLDB 2100 reports missing Rust language plugin support:

warning: `po` was unsuccessful, running `p` instead

As a result, `po` falls back to `p`, producing expanded output that no longer matches the existing `lldb-check` directives.

Changes:
- replace `po` with `print`
- relax `lldb-check` expectations using `[...]`
- preserve validation of the displayed path value

This also aligns `path.rs` with the rest of the debuginfo tests, as it appears to be the only test using `po`.

---

EDIT(@jieyouxu): see digging https://github.com/rust-lang/rust/pull/156769#discussion_r3293345899
2026-05-24 08:27:18 +02:00
bors e1ff77d898 Auto merge of #156736 - GuillaumeGomez:primitive-assoc-methods, r=fmease
Fix jump to def link generation on primitive type associated methods

Fixes rust-lang/rust#156707.

Interestingly enough, the inference fails on primitive type, so instead I go around a bit by generating a `PrimitiveType` and then tweak a bit the `href` generation.

r? @fmease
2026-05-24 03:17:11 +00:00
bors dd8b2d6162 Auto merge of #155598 - makai410:partial-ord, r=nnethercote
Implement fast path for `derive(PartialOrd)` when deriving `Ord`



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

Unfortunately, this PR shares the same issue with https://github.com/rust-lang/rust/issues/124794, which doesn't work when `derive(PartialOrd)` is before `derive(Ord)`.
2026-05-24 00:06:21 +00:00
Pieter-Louis Schoeman 0ff74c976a Fix Pieter-Louis Schoeman mailmap entry 2026-05-23 21:24:21 +02:00
bors 23a3312d92 Auto merge of #156116 - scottmcm:tweak-layout-of-alternative, r=dianqk
Stop needing materialized places for most intrinsics



Today even to return a constant from `size_of_val` it takes an `alloca`.  That's wasteful.

This updates the cg_ssa traits to allow returning an `OperandValue` instead, which is possible for the vast majority of intrinsics -- this PR moves all but 5 over to doing that in LLVM.

The first commit adds a test to help show the difference here.

cc https://github.com/rust-lang/compiler-team/issues/970 https://github.com/rust-lang/rust/issues/153250
2026-05-23 19:23:06 +00:00
fallofpheonix 6ed5bf2f52 Remove po checks from debuginfo path test 2026-05-24 00:43:32 +05:30
Guillaume Gomez 0c7388c750 Fix jump to def link generation on primitive type associated methods 2026-05-23 19:07:36 +02:00
Pieter-Louis Schoeman 2f953da599 Remove unnecessary Share feature gate plumbing 2026-05-23 17:33:22 +02:00
Makai 766428b312 Avoid regression in derive(PartialOrd) for single fieldless variant enums 2026-05-23 20:32:20 +08:00
Scott McMurray d3d3485dd4 Let intrinsics use the SSA operand path 2026-05-22 22:02:06 -07:00
bors 54333ff079 Auto merge of #156835 - yotamofek:pr/positive-dyn-compatible, r=fmease
Also emit "Dyn Compatibility" section for traits that *are* dyn compatible

I was using the std docs to check if a trait was dyn compatible, and was very confused that it had no info about dyn compatibility. I had to go look at a trait that I knew for certain was *not* dyn compatible (`Clone`) to verify that we still had the dyn compatibility section, and that its omission meant a trait *was* compatible.

(also removed the "..., so this trait is not object safe" text because it seemed pretty redundant)


r? @fmease
2026-05-22 18:01:46 +00:00
qaijuang 1ac7072415 add regression test 2026-05-22 13:49:03 -04:00
Mira Morgana fb2751b2e6 float_literal_f32_fallback: Don't suggest invalid code
When a float literal ended with a dot, `float_literal_f32_fallback`
should not include it in its suggestion.
2026-05-22 17:58:46 +02:00
Yotam Ofek 877d57c2c2 Also emit "Dyn Compatibility" section for traits that *are* dyn compatible 2026-05-22 18:08:11 +03:00
bors b52edc25bf Auto merge of #156834 - JonathanBrouwer:rollup-TdEisIq, r=JonathanBrouwer
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#155509 ([Debug Info] Gracefully handle invalid `String`/`Vec`)
 - rust-lang/rust#156229 (Install additional LLVM DLL on Windows)
 - rust-lang/rust#152821 (Allow forbidden target features to be hard errors)
 - rust-lang/rust#156560 (compiler: fix duplicated "the" in two doc-comments)
 - rust-lang/rust#156725 (Remove stale RTN FIXME for assoc item constraint fallback)
 - rust-lang/rust#156803 (Fix reborrow ICE in MIR place lowering)
 - rust-lang/rust#156815 (rustfmt: format const trait impls to `const impl` for syntax transition)
 - rust-lang/rust#156818 (Privacy: enqueue type alias)
 - rust-lang/rust#156820 (delegation: visit body under elided-infer lifetime rib)
 - rust-lang/rust#156829 (Turn `lint_index` from `Option<u16>` to `u16` for LintExpectationId)
2026-05-22 14:50:17 +00:00
Pieter-Louis Schoeman 501ab4e8c5 Clarify Share trait docs 2026-05-22 16:21:32 +02:00
Jonathan Brouwer 29eaf53904 Rollup merge of #156829 - Bryntet:levels_options_removal, r=nnethercote
Turn `lint_index` from `Option<u16>` to `u16` for LintExpectationId

While doing lint attributes PR, I realised that the field `lint_index` didn't need to be Optional

(this PR is part of a series of PRs that will make the lint attrs PR more easily reviewable)

r? @nnethercote because you did rust-lang/rust#156596 recently
2026-05-22 16:21:32 +02:00
Jonathan Brouwer 7908120a29 Rollup merge of #156820 - aerooneqq:delegation-visit-body-elided-infer-lt-rib, r=petrochenkov
delegation: visit body under elided-infer lifetime rib

Fixes rust-lang/rust#156806. Part of rust-lang/rust#118212.

r? @petrochenkov
2026-05-22 16:21:31 +02:00
Jonathan Brouwer fc73322ab8 Rollup merge of #156818 - Bryanskiy:privacy_alias, r=petrochenkov
Privacy: enqueue type alias

fixes https://github.com/rust-lang/rust/issues/156778

r? @petrochenkov
2026-05-22 16:21:30 +02:00
Jonathan Brouwer 1dcd2aef19 Rollup merge of #156815 - fee1-dead-contrib:rustfmt-const-traits, r=ytmimi
rustfmt: format const trait impls to `const impl` for syntax transition

Because this concerns rustc development (we want this in next beta) so that we can ensure by the next beta rustc can remove the parser support for `impl const Trait`, this PR is made against the r-l/r repo :)
2026-05-22 16:21:30 +02:00
Jonathan Brouwer 59a0d08a77 Rollup merge of #156803 - P8L1:fix/reborrow-thir-mir-rvalue-contract, r=jackh726
Fix reborrow ICE in MIR place lowering

## Summary

Fixes rust-lang/rust#156482.

This fixes an internal THIR/MIR contract inconsistency for generic reborrow expressions.

`ExprKind::Reborrow` is lowered into MIR as `Rvalue::Reborrow`, but MIR expression categorization treated it as place-like while `expr_as_place` treated evaluating it as a place as unreachable. That caused the rust-lang/rust#156482 ICE, where the compiler panicked with `entered unreachable code` in `expr_as_place` while building MIR for a generic reborrow expression.

The fix makes the MIR builder contract explicit: a reborrow expression is rvalue-producing. Its source may be a place, but the reborrow expression itself is not an assignable place.

## What changed

- Updated MIR expression categorization so `ExprKind::Reborrow` is categorized as rvalue-producing rather than place-like.
- Updated place lowering so reborrow follows the normal rvalue temporary-materialization path if a place is needed.
- Added a targeted UI regression test covering the exact rust-lang/rust#156482 repro.

cc @aapoalas
2026-05-22 16:21:29 +02:00
Jonathan Brouwer 5b0cfaf5b1 Rollup merge of #156725 - P8L1:fix/rtn-assoc-ty-parentheses-diagnostic, r=jackh726
Remove stale RTN FIXME for assoc item constraint fallback

The old FIXME suggested that this diagnostic path should emit a `return_type_notation` feature-gate diagnostic.

That is no longer correct: RTN associated item constraints now use `(..)`, so a form like `Trait<method(): Bound>` is not made valid by enabling `return_type_notation`.

This PR removes the stale FIXME without changing the diagnostic behavior.
2026-05-22 16:21:28 +02:00
Jonathan Brouwer 2ad4f8320f Rollup merge of #156560 - lphuc2250gma:fix/duplicated-the-in-compiler-doc-comments, r=jackh726
compiler: fix duplicated "the" in two doc-comments

Two one-line typo fixes for duplicated "the" in compiler doc-comments:
- `compiler/rustc_type_ir/src/solve/mod.rs` — "only if any of the the opaques in the opaque type storage has a hidden type" → "...any of the opaques in..."
- `compiler/rustc_borrowck/src/diagnostics/var_name.rs` — "/// Find the the name and span of the variable corresponding to the given region." → "/// Find the name and span of the variable corresponding to the given region."

No code/behavior change.
2026-05-22 16:21:27 +02:00
Jonathan Brouwer 7ab3168371 Rollup merge of #152821 - wesleywiser:add_forbidden_ctarget_feature_hard_error_option, r=dingxiangfei2009
Allow forbidden target features to be hard errors

Sometimes when adding a new target features to the list of known target features, we want to completely forbid them from being used because they are ABI affecting and should be target modifiers instead. As such, we want to issue an error rather than a warning since there are no future compatibility concerns .

r? @workingjubilee since you're familiar with the motivating case in rust-lang/rust#136597

If I rebase that PR on top of this locally, then we get the following error messages when trying to activate the SLS target feature (note that they are *errors* not *warnings* and we've omitted the usual note about future compatibility):

```
error: target feature `harden-sls-ijmp` cannot be enabled with `-Ctarget-feature`: use `harden-sls` compiler flag instead

error: target feature `harden-sls-ret` cannot be enabled with `-Ctarget-feature`: use `harden-sls` compiler flag instead

error: aborting due to 2 previous errors
```
2026-05-22 16:21:26 +02:00
Jonathan Brouwer 827f6925d1 Rollup merge of #156229 - mati865:llvm-mingw-libllvm-fix, r=clubby789
Install additional LLVM DLL on Windows

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

The problem is that with shared linking to LLVM lib we have binaries requiring it in `$sysroot/bin` and `$sysroot/lib/rustlib/triple/bin`, but place the DLL only in the first location. On Unix systems rpath would take care of that, but on Windows the required DLL must be next to the binary or be found in PATH.

This PR puts another copy of the library into that second location. The size overhead of such copy compared to static linking is much lower than I anticipated even though I couldn't manage to make bootstrap create hard links.

The sizes without and with `llvm-tools` component:
```
❯ du --summarize -h .rustup/toolchains/{additional-dll,static}*
638M    .rustup/toolchains/additional-dll
800M    .rustup/toolchains/additional-dll-tools
608M    .rustup/toolchains/static-link
1.1G    .rustup/toolchains/static-link-tools
```
Statically linked LLD sits at 139M while dynamically linked one is 7.5M + 150M for the libLLVM, so the difference is minor.

Alternatively, we could require that on Windows, binaries located in `$sysroot/lib/rustlib/triple/bin` must always be called with `$sysroot/bin` in the PATH. However, that sounds like something that would require an announcement and some grace period.
2026-05-22 16:21:26 +02:00
Jonathan Brouwer 42bd6def23 Rollup merge of #155509 - Walnut356:string_crash, r=Mark-Simulacrum
[Debug Info] Gracefully handle invalid `String`/`Vec`

Somewhat related to https://github.com/rust-lang/rust/issues/150392.

Currently the handling can throw an exception, which we should absolutely not do. It causes issues with debugger adapters (e.g. CodeLLDB will hang forever. Trying to stop the debugger via vscode's interface causes a CodeLLDB to leak memory constantly until RAM is depleted and the OS starts killing processes). The exception has been replaced with a printed error message and a placeholder value.

Additionally, if a String/Vec is in an "invalid" state due to niche optimization (`capacity >= (1 << 63)`, common with `Option<String>`/`Option<Vec<T>>`), the pointer and length values will be meaningless, but are not guaranteed to be 0'd. The debugger will happily proceed as if they are useful values, and often do things like \<try to read multiple GB of data from the debugee\>.

I added simple checks to ensure that the capacity and length are within bounds, and that the pointer is non-null. If any check fails, the string/vec just acts as if it's empty.

Eventually this problem will be solved on LLDB's end via https://github.com/llvm/llvm-project/pull/188487/ or similar, but preventing issues on our end in the short term will help a lot.

---

try-job: aarch64-apple
2026-05-22 16:21:25 +02:00
Edvin Bryntesson 4f12864fab make lint_index field not Optional in LintExpectationId 2026-05-22 15:21:07 +02:00
okaneco 3a6cb0519d Add #[doc(alias = "phi")] for float GOLDEN_RATIO constants 2026-05-22 09:15:36 -04:00
CoCo-Japan-pan 41c61112a7 Introduce mut restrictions to AST 2026-05-22 19:40:23 +09:00
CoCo-Japan-pan 3c3027d59a Add mut_restriction feature 2026-05-22 19:40:22 +09:00