325084 Commits

Author SHA1 Message Date
Scott McMurray
ba1a33e105 Prefer -1 for None
Currently we pick "weird" numbers like `1114112` for `None::<char>`.  While that's not *wrong*, it's kinda *unnatural* -- a human wouldn't make that choice.

This PR instead picks `-1` for thinge like `None::<char>` -- like clang's `WEOF` -- and `None::<bool>` and such.

Any enums with more than one niched value (so not `Result` nor `Option`) remain as they were before.
2026-04-25 14:57:23 -07:00
bors
68ffae46b5 Auto merge of #155796 - JonathanBrouwer:rollup-uKXw9ZB, r=JonathanBrouwer
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#146181 (Add intrinsic for launch-sized workgroup memory on GPUs)
 - rust-lang/rust#154803 (Fix ICE from cfg_attr_trace )
 - rust-lang/rust#155065 (Error on invalid macho section specifier)
 - rust-lang/rust#155485 (Add an edge-case test for `--remap-path-prefix` for `rustc` & `rustdoc`)
 - rust-lang/rust#155659 (cleanup, restructure and merge `tests/ui/deriving` into `tests/ui/derives`)
 - rust-lang/rust#155676 ( Reject implementing const Drop for types that are not const `Destruct` already)
 - rust-lang/rust#155696 (Add a higher-level API for parsing attributes)
 - rust-lang/rust#155769 (triagebot.toml: Ping Enselic when tests/debuginfo/basic-stepping.rs changes)
 - rust-lang/rust#155783 (Do not suggest internal cfg trace attributes)
2026-04-25 21:08:31 +00:00
Jonathan Brouwer
3b59d9d58e Rollup merge of #155783 - qaijuang:issue-150566-cfg-trace-suggestions, r=JonathanBrouwer
Do not suggest internal cfg trace attributes

Fixes rust-lang/rust#150566.
2026-04-25 23:07:53 +02:00
Jonathan Brouwer
730b6766c6 Rollup merge of #155769 - Enselic:ping-enselic, r=Urgau
triagebot.toml: Ping Enselic when tests/debuginfo/basic-stepping.rs changes

The test `tests/debuginfo/basic-stepping.rs` has a history of [regressing for subtle reasons](https://github.com/rust-lang/rust/issues/33013#issuecomment-3121579216) ([retroactively](https://github.com/rust-lang/rust/pull/144497)), and has [expected behavior](https://github.com/rust-lang/rust/pull/153941) that is [not obvious](https://github.com/rust-lang/rust/pull/155377). So I'd like to keep an extra eye one it.
2026-04-25 23:07:53 +02:00
Jonathan Brouwer
97dd613234 Rollup merge of #155696 - scrabsha:push-kxqstpltlwzn, r=JonathanBrouwer
Add a higher-level API for parsing attributes
2026-04-25 23:07:52 +02:00
Jonathan Brouwer
2c639cc7fe Rollup merge of #155676 - oli-obk:const-drop-non-const-destruct, r=fee1-dead
Reject implementing const Drop for types that are not const `Destruct` already

fixes rust-lang/rust#155618

While there is no soundness or otherwise issue currently, this PR ensures that people get what they expect. It seems wrong to allow implementing `const Drop`, but then the type still can't be dropped at compile-time.

r? @fee1-dead
2026-04-25 23:07:51 +02:00
Jonathan Brouwer
0e9c586699 Rollup merge of #155659 - cyrgani:deriving-2, r=Kivooeo
cleanup, restructure and merge `tests/ui/deriving` into `tests/ui/derives`

As a followup to https://github.com/rust-lang/rust/pull/155615, this PR deletes some outdated tests from these directories, splits up `ui/derives` into smaller directories to roughly group tests by the derive macros they use and moves over all tests from `ui/deriving` into `ui/derives`.
r? @Kivooeo
2026-04-25 23:07:51 +02:00
Jonathan Brouwer
7050d618af Rollup merge of #155485 - Urgau:remap-edge-case-test, r=GuillaumeGomez
Add an edge-case test for `--remap-path-prefix` for `rustc` & `rustdoc`

Intended to resolve @lolbinarycat concern https://github.com/rust-lang/rust/pull/155307#issuecomment-4270904667
2026-04-25 23:07:50 +02:00
Jonathan Brouwer
1fe66ee46e Rollup merge of #155065 - folkertdev:macho-section-specifier, r=JonathanBrouwer
Error on invalid macho section specifier

The macho section specifier used by `#[link_section = "..."]` is more strict than e.g. the one for elf. LLVM will error when you get it wrong, which is easy to do if you're used to elf. So, provide some guidance for the simplest mistakes, based on the LLVM validation.

Currently compilation fails with an LLVM error, see https://godbolt.org/z/WoE8EdK1K.

The LLVM validation logic is at

a0f0d6342e/llvm/lib/MC/MCSectionMachO.cpp (L199-L203)

LLVM validates the other components of the section specifier too, but it feels a bit fragile to duplicate those checks. If you get that far, hopefully the LLVM errors will be sufficient to get unstuck.

---

sidequest from https://github.com/rust-lang/rust/pull/147811

r? JonathanBrouwer

specifically, is this the right place for this sort of validation? `rustc_attr_parsing` also does some validation.
2026-04-25 23:07:50 +02:00
Jonathan Brouwer
76a365523f Rollup merge of #154803 - chenyukang:yukang-fix-154801-cfg-attr-span, r=JonathanBrouwer
Fix ICE from cfg_attr_trace

Fixes rust-lang/rust#154801
Fixes https://github.com/rust-lang/rust/issues/143094

r? @JonathanBrouwer

The root cause is we recovery from parsing attribute error here:
ed6f9af7d4/compiler/rustc_attr_parsing/src/parser.rs (L550)
while the later suggestion code from type checking try to inspect the attr span of the `expr` in the second error, keep the span seems reasonable.
2026-04-25 23:07:49 +02:00
Jonathan Brouwer
dde4886801 Rollup merge of #146181 - Flakebi:dynamic-shared-memory, r=ZuseZ4,Sa4dus,workingjubilee,RalfJung,nikic,kjetilkjeka,kulst
Add intrinsic for launch-sized workgroup memory on GPUs

Workgroup memory is a memory region that is shared between all
threads in a workgroup on GPUs. Workgroup memory can be allocated
statically or after compilation, when launching a gpu-kernel.
The intrinsic added here returns the pointer to the memory that is
allocated at launch-time.

# Interface

With this change, workgroup memory can be accessed in Rust by
calling the new `gpu_launch_sized_workgroup_mem<T>() -> *mut T`
intrinsic.

It returns the pointer to workgroup memory guaranteeing that it is
aligned to at least the alignment of `T`.
The pointer is dereferencable for the size specified when launching the
current gpu-kernel (which may be the size of `T` but can also be larger
or smaller or zero).

All calls to this intrinsic return a pointer to the same address.

See the intrinsic documentation for more details.

## Alternative Interfaces

It was also considered to expose dynamic workgroup memory as extern
static variables in Rust, like they are represented in LLVM IR.
However, due to the pointer not being guaranteed to be dereferencable
(that depends on the allocated size at runtime), such a global must be
zero-sized, which makes global variables a bad fit.

# Implementation Details

Workgroup memory in amdgpu and nvptx lives in address space 3.
Workgroup memory from a launch is implemented by creating an
external global variable in address space 3. The global is declared with
size 0, as the actual size is only known at runtime. It is defined
behavior in LLVM to access an external global outside the defined size.

There is no similar way to get the allocated size of launch-sized
workgroup memory on amdgpu an nvptx, so users have to pass this
out-of-band or rely on target specific ways for now.

Tracking issue: rust-lang/rust#135516
2026-04-25 23:07:48 +02:00
Scott McMurray
9bc1313507 Add dump_layout tests for options of bool and char 2026-04-25 13:46:42 -07:00
Jonathan Brouwer
e3b0e9db08 Remove deprecation_note from AttributeExt 2026-04-25 21:26:00 +02:00
Jonathan Brouwer
f113540cec Remove unnecessary uses of AttributeExt 2026-04-25 21:25:43 +02:00
Oli Scherer
7dcedafff2 Reject implementing const Drop for types that are not const Destruct already 2026-04-25 20:56:32 +02:00
Oli Scherer
642ee63c22 Add regression test 2026-04-25 20:55:51 +02:00
Folkert de Vries
a4f5c6e971 error on invalid macho section specifier 2026-04-25 20:06:30 +02:00
mejrs
b6c6dd1fa0 macro_metavar_expr_concat: explain why idents are invalid 2026-04-25 19:56:05 +02:00
bors
9838411cb7 Auto merge of #155257 - petrochenkov:visatleast, r=adwinwhite
privacy: Assert that compared visibilities are (usually) ordered



And make "greater than" (`>`) the new primary operation for comparing visibilities instead of "is at least" (`>=`).
2026-04-25 16:15:55 +00:00
Qai Juang
b17822575c Do not suggest internal cfg trace attributes 2026-04-25 11:47:34 -04:00
human9000
29d58f8b4c Utilize if let guards where aproppriate 2026-04-25 19:42:57 +05:00
Kevin Heavey
5cd9d929a9 Avoid Vec allocation in TyCtxt::mk_place_elem
`mk_place_elem` appends a single `PlaceElem` to an existing (interned)
projection. The current implementation copies the projection into a
fresh `Vec`, pushes the new element, and re-interns the slice, which
allocates on the heap on every call.

Feed the elements through `mk_place_elems_from_iter` so that
`CollectAndApply`'s hand-unrolled stack fast path (up to 9 elements,
in `rustc_type_ir::interner`) kicks in for the common case of short
projections and the `Vec` allocation is skipped entirely. The behavior
is identical for longer projections (the fast path falls back to a
`Vec` internally).
2026-04-25 15:05:59 +01:00
joboet
bab4983f6c std: maintain CStringArray null-termination even if Vec::push panics 2026-04-25 15:17:36 +02:00
bors
fb76025f2f Auto merge of #155460 - cjgillot:unmut-resolver-ast, r=oli-obk
Do not modify resolver outputs during lowering



Split from https://github.com/rust-lang/rust/pull/142830

I believe this achieves the same thing as https://github.com/rust-lang/rust/pull/153656 but in a much simpler way. 

This PR forces AST->HIR lowering to stop mutating resolver outputs. Instead, it manages a few override maps that only live during lowering and are dropped afterwards.

r? @petrochenkov 
cc @aerooneqq
2026-04-25 10:01:32 +00:00
yukang
5e00484c38 Avoid misleading closure return type note 2026-04-25 16:27:05 +08:00
Martin Nordholts
ff73b8ac2b triagebot.toml: Ping Enselic when tests/debuginfo/basic-stepping.rs changes
The test `tests/debuginfo/basic-stepping.rs` has a history of regressing
for subtle reasons, and has non-obvious expectations. So I'd like to
keep an extra eye on it.
2026-04-25 10:11:10 +02:00
bors
7e0430fafc Auto merge of #155766 - jhpratt:rollup-EcXAaqS, r=jhpratt
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#155643 (Improve suggestion for $-prefixed fragment specifiers)
 - rust-lang/rust#154197 (Avoid redundant clone suggestions in borrowck diagnostics)
 - rust-lang/rust#154372 (Exposing Float Masks)
 - rust-lang/rust#155680 (Handle index projections in call destinations in DSE)
 - rust-lang/rust#155732 (bootstrap: Don't clone submodules unconditionally in dry-run)
 - rust-lang/rust#155737 (Account for `GetSyntheticValue` failures)
 - rust-lang/rust#155738 (Pass fields to `is_tuple_fields` instead of `SBValue` object)
2026-04-25 06:41:56 +00:00
Jacob Pratt
84fd561f22 Rollup merge of #155738 - Walnut356:tuple_fields, r=jieyouxu
Pass fields to `is_tuple_fields` instead of `SBValue` object

straightforward fix for a logic error. `is_tuple_fields` expects a `list`, so we pass that in instead of the value object.

Coincidentally, this also fixes one of the 3 DI tests that fails on `x86_64-pc-windows-gnu` (`tests/debuginfo/union-smoke.rs`)
2026-04-25 01:21:54 -04:00
Jacob Pratt
0c27f91e04 Rollup merge of #155737 - Walnut356:getsyntheticvalue, r=jieyouxu
Account for `GetSyntheticValue` failures

`GetSyntheticValue` returns an invalid `SBValue` if no synthetic is present. That wasn't a problem before when we  were attaching synthetics to every type, but it won't be the case once github.com/rust-lang/rust/pull/155336 or similar lands. Additionally, codelldb subverts `lldb_commands` to apply similar behavior that doesn't attach synthetics to every type, so this fixes a regression there too.

Additionally, I removed 1 useless instance of `GetSyntheticValue`, since pointers should always be `IndirectionSyntheticProvider`, not `DefaultSyntheticProvider`.
2026-04-25 01:21:54 -04:00
Jacob Pratt
780e699707 Rollup merge of #155732 - ferrocene:jyn/dry-run, r=jieyouxu
bootstrap: Don't clone submodules unconditionally in dry-run

This made it very annoying to debug bootstrap itself, because every `--dry-run` invocation would start out by cloning LLVM, which is almost never necessary. Instead change a few Steps to properly support dry_run when no submodule is checked out.

I tested this by running all of `check`, `build`, `doc`, `dist`, `install`, `vendor`, `clippy`, `fix`, and `miri` with `--dry-run`.
2026-04-25 01:21:53 -04:00
Jacob Pratt
fa82155e54 Rollup merge of #155680 - Amanieu:call-arg-move-index, r=cjgillot
Handle index projections in call destinations in DSE

Since call destinations are evaluated after call arguments, we can't turn copy arguments into moves if the same local is later used as an index projection in the call destination.

DSE call arg optimization: rust-lang/rust#113758

r? @cjgillot
cc @RalfJung
2026-04-25 01:21:52 -04:00
Jacob Pratt
b3ccc964d5 Rollup merge of #154372 - Apersoma:float_masks, r=tgross35
Exposing Float Masks

Tracking issue: rust-lang/rust#154064
ACP: rust-lang/libs-team#753
2026-04-25 01:21:52 -04:00
Jacob Pratt
0af72af1b8 Rollup merge of #154197 - yuk1ty:fix-redundant-clone-error2, r=adwinwhite
Avoid redundant clone suggestions in borrowck diagnostics

Fixes rust-lang/rust#153886

Removed redundant `.clone()` suggestions.

I found that there are two patterns to handle this issue while I was implementing:

- Should suggest only UFCS
- Should suggest only simple `.clone()`

For the target issue, we can just remove the UFCS (`<Option<String> as Clone>::clone(&selection.1)`) side.

However, for the `BorrowedContentSource::OverloadedDeref` pattern like `Rc<Vec<i32>>`, for instance the `borrowck-move-out-of-overloaded-auto-deref.rs` test case, I think we need to employ the UFCS way. The actual test case is:

```rust
//@ run-rustfix
use std::rc::Rc;

pub fn main() {
    let _x = Rc::new(vec![1, 2]).into_iter();
    //~^ ERROR [E0507]
}
```

And another error will be shown if we simply use the simple `.clone()` pattern. Like:

```rust
use std::rc::Rc;

pub fn main() {
    let _x = Rc::new(vec![1, 2]).clone().into_iter();
}
```

then we will get

```
error[E0507]: cannot move out of an `Rc`
   --> src/main.rs:5:14
    |
  5 |     let _x = Rc::new(vec![1, 2]).clone().into_iter();
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ----------- value moved due to this method call
    |              |
    |              move occurs because value has type `Vec<i32>`, which does not implement the `Copy` trait
    |
note: `into_iter` takes ownership of the receiver `self`, which moves value
   --> /playground/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/collect.rs:310:18
    |
310 |     fn into_iter(self) -> Self::IntoIter;
    |                  ^^^^
help: you can `clone` the value and consume it, but this might not be your desired behavior
    |
  5 -     let _x = Rc::new(vec![1, 2]).clone().into_iter();
  5 +     let _x = <Vec<i32> as Clone>::clone(&Rc::new(vec![1, 2])).into_iter();
    |

For more information about this error, try `rustc --explain E0507`.
```

[Rust Playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=7e767bed3f1c573c03642f20f454ed03)

In this case, `Rc::clone` only increments the reference count and returns a new `Rc<Vec<i32>>`; it does not grant ownership of the inner `Vec<i32>`. As a result, calling into_iter() attempts to move the `Vec<i32>`, leading to the same E0507 error again.

On the other hand, in UFCS form:

```
<Vec<i32> as Clone>::clone(&Rc::new(vec![1, 2])).into_iter()
```

This explicitly calls `<Vec<i32> as Clone>::clone`, and the argument `&Rc<Vec<i32>>` is treated as `&Vec<i32>` via Rc’s `Deref` implementation. As a result, the `Vec<i32>` itself is cloned, yielding an owned `Vec<i32>`, which allows `into_iter()` to succeed, if my understanding is correct.

I addressed the issue as far as I could find the edge cases but please advice me if I'm overlooking something.
2026-04-25 01:21:51 -04:00
Jacob Pratt
d3eddcff9e Rollup merge of #155643 - qaijuang:fix-macro-missing-fragment-dollar-suggestion, r=eholk
Improve suggestion for $-prefixed fragment specifiers

Fixes rust-lang/rust#155505
2026-04-25 01:21:50 -04:00
bors
0a4ee3f74b Auto merge of #155756 - weihanglo:update-cargo, r=weihanglo
Update cargo submodule

10 commits in 06ac0e7c05770a8c7bbf67bdd12fa1a1eefdc8ae..eb9b60f1f6604b5e022c56be31692c215b8ba11d
2026-04-21 15:33:56 +0000 to 2026-04-24 20:52:07 +0000
- chore: Remove unused deps (rust-lang/cargo#16938)
- feat(compile): Stabilize `build.warnings` (rust-lang/cargo#16796)
- cargo clean: do not error if explicitly specified target-dir does not exist (rust-lang/cargo#16934)
- Revert "feat(lints): Add unused deps ignore list" (rust-lang/cargo#16937)
- fix(compile): Ignore unused deps if also transitive  (rust-lang/cargo#16935)
- Update rustls (rust-lang/cargo#16932)
- chore(deps): update rust crate openssl to v0.10.78 [security] (rust-lang/cargo#16931)
- chore(build-rs): Ensure we lint the crate (rust-lang/cargo#16930)
- Fix flaky test: proc_macro_in_artifact_dep (rust-lang/cargo#16922)
- refactor(compile): Log all ignored unused externs (rust-lang/cargo#16920)

r? ghost
2026-04-25 03:28:50 +00:00
yukang
45b4e3c52b Fix ICE of trying to get span from all attrs 2026-04-25 11:11:23 +08:00
bors
597d9e43be Auto merge of #155755 - JonathanBrouwer:rollup-oG1Wz3V, r=JonathanBrouwer
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#155754 (make the `core::ffi::va_list` module private)
 - rust-lang/rust#155522 (cmse: test returning `MaybeUninit<T>`)
 - rust-lang/rust#155741 (std: Refactor BufWriter::flush to use the `?` operator)
2026-04-25 00:13:26 +00:00
Camille Gillot
4433512e90 Lighten and document partial_res_overrides. 2026-04-24 23:58:52 +00:00
Camille Gillot
9044aba8e1 Use imported NodeId. 2026-04-24 23:58:52 +00:00
Camille Gillot
0705bbac94 Do not modify resolver outputs during lowering
Co-authored-by: Camille Gillot <gillot.camille@gmail.com>
2026-04-24 23:58:52 +00:00
yuk1ty
61ff157bd4 Address custom type implementing Derefs to suggest UFCS clone 2026-04-25 08:46:06 +09:00
Apersoma
d5b941d163 added float masks feature 2026-04-24 23:06:04 +00:00
Jonathan Brouwer
6f536cf8f4 Rollup merge of #155741 - xtqqczze:question-mark-bufwriter-flush, r=WaffleLapkin
std: Refactor BufWriter::flush to use the `?` operator

Functionally, this is equivalent and may     be slightly more amenable to inlining.
2026-04-25 00:08:11 +02:00
Jonathan Brouwer
39d84243b2 Rollup merge of #155522 - folkertdev:cmse-test-maybe-uninit, r=WaffleLapkin
cmse: test returning `MaybeUninit<T>`

tracking issue: https://github.com/rust-lang/rust/issues/81391
tracking issue: https://github.com/rust-lang/rust/issues/75835

Some tests from https://github.com/rust-lang/rust/pull/147697 that already work and are useful. Extracting them shrinks that (currently blocked) PR.

The code in `tests/ui/cmse-nonsecure/cmse-nonsecure-call/return-via-stack.rs` checks that `MaybeUninit<T>` is considered abi-compatible with `T`. The code in `tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-via-stack.rs` really only tests that no errors/warnings are emitted.

r? davidtwco
2026-04-25 00:08:10 +02:00
Jonathan Brouwer
6d6b99eab2 Rollup merge of #155754 - folkertdev:hide-core-ffi-va-list, r=tgross35
make the `core::ffi::va_list` module private

tracking issue: https://github.com/rust-lang/rust/issues/44930

the types are exported from `core::ffi` itself.

T-libs-api decided that we should only export the types from `core::ffi`, and should not make `core::ffi::va_list` public, see https://github.com/rust-lang/rust/issues/44930#issuecomment-4289951633.

r? tgross35
2026-04-25 00:08:09 +02:00
Weihang Lo
d439d07af2 Update cargo submodule 2026-04-24 17:43:12 -04:00
bors
80729d7ce0 Auto merge of #155662 - mejrs:this_the_thing, r=petrochenkov
Permit `{This}` in diagnostic attribute format literals

My motivation was that yesterday I wanted to write something like this and reference `$name` in the string literal.

```rust
pub mod sym {
   // stuff here
}

macro_rules! my_macro {
    ($name:ident $(,)?) => {{
        #[diagnostic::on_unknown(
            message = "this is not present in symbol table",
            note = "you must add it to rustc_span::symbol::symbol!"
        )]
        use sym::$name as name;
        // ...
    }}
}
```

That is (as far as I can tell) impossible or at least very unergonomic. This adds the ability to just reference the name of the item the attribute is on. I imagine that's useful for use inside macros generally, so it's also added for some other attributes.

The affected attributes are all unstable, it is not implemented for diagnostic::on_unimplemented (will do in its own PR).

Note that `{This}` is already usable in `#[rustc_on_unimplemented]`, so this does not implement it but just enables some more.

This PR also migrates one lint away from AttributeLintKind, and improves the messages for that lint.
2026-04-24 20:46:55 +00:00
Folkert de Vries
3851c60cf8 make the core::ffi::va_list module private
the types are exported from `core::ffi` itself
2026-04-24 22:18:22 +02:00
Qai Juang
2b46d9204a Improve suggestion for $-prefixed fragment specifiers 2026-04-24 14:59:01 -04:00
mejrs
c2916be8d7 Permit {This} in diagnostic attribute format literals 2026-04-24 19:59:32 +02:00