Commit Graph

2652 Commits

Author SHA1 Message Date
Yara
2b7d180842 reflection: add non-exhaustive to meme::type_info::Variant 2026-08-15 01:03:06 +02:00
Yara
b685be1643 reflection: Add TypeId::variant() returning new Variant 2026-08-15 01:02:32 +02:00
Jacob Pratt
9e0b9bc6cd Rollup merge of #158885 - folkertdev:complex-layout, r=workingjubilee
Add `core::num::Complex`

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

See also [#t-compiler > representing `_Complex`](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/representing.20.60_Complex.60/with/608308993). The RFC states that the `Complex` type should match the ABI of `_Complex` in C, but provides little detail on how to actually achieve this. We concluded that `repr(complex)` is probably the best approach. Like clang, that means we "desugar" the representation early: `_Complex` is not natively represented in LLVM IR.

I've derived the ABI from `clang` for 28 targets, a decent sample of what we actually support. For now I'm only actually testing `x86_64` because (as you'll see) updating the tests is quite labor-intensive. If we're happy with this direction I can fill more of them in, likely in a separate PR.

The libs side of the type is very bare-bones: I'm not as interested in that part. Others can fill in the various instances, methods, write tests for those, and improve the docs.

r? workingjubilee
2026-08-13 18:16:12 -04:00
Jacob Pratt
a2424855c6 Rollup merge of #160950 - mejrs:unknown_symbol, r=chenyukang
dogfood `#[diagnostic::unknown]` in the compiler

This makes the error for not-found symbols a lot nicer :)

```
error[E0425]: cannot find value `better_rust` in module `sym`
   --> compiler\rustc_feature\src\unstable.rs:799:16
    |
157 |                 name: sym::$feature,
    |                            -------- due to this macro variable
...
799 |     (unstable, better_rust, "2.0.0", Some(42)),
    |                ^^^^^^^^^^^ `better_rust` is not a pre-interned symbol
    |
    = note: consider adding `better_rust` to the `symbols!` invocation in compiler/rustc_span/src/symbol.rs
```

(only works when building stage 2 for now, the necessary changes haven't landed in beta yet)
2026-08-12 23:38:38 -04:00
Folkert de Vries
5b66cc1ab2 add Complex type 2026-08-12 22:50:00 +02:00
Jonathan Brouwer
5d8a3c9f20 Rollup merge of #160925 - yara-blue:is_signed, r=oli-obk
Add `TypeId::is_signed` method

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

r? @oli-obk
2026-08-12 13:52:41 +02:00
mejrs
77d3d5bc5d Fix macro_rules symbol comment 2026-08-11 23:53:39 +02:00
mejrs
47e7f7e9e9 dogfood diagnostic::on_unknown 2026-08-11 23:41:23 +02:00
Yara
0ea82de957 Add TypeId::is_signed method 2026-08-11 18:36:33 +02:00
Jonathan Brouwer
8cd8b73209 Rollup merge of #156338 - P8L1:derive-reborrow-coerce-shared, r=oli-obk
Implement derives for Reborrow and CoerceShared

This adds built-in derive support for the experimental `Reborrow` and `CoerceShared` marker traits behind `#![feature(reborrow)]`.

The derives generate the same marker impls users would write manually, while preserving the existing coherence and structural validation path for the experimental reborrow traits.

## Please note this impl:

- Preserves generics, lifetimes, const params, and where clauses in generated impls.
- Preserves multiple lifetime parameters in generated impls instead of duplicating the current experimental one-lifetime limitation in the derive layer.
- Requires an explicit `CoerceShared` target type through the derive helper attribute.
- Adds UI coverage for valid derives, feature gating, malformed helper attributes, unsupported item kinds, validation failures, and multiple-lifetime derive behavior.
- Makes the derive layer future-proof for multiple lifetimes: it preserves all lifetime parameters and generates the same impl shape as a manual impl.

@rustbot label F-reborrow
Tracking: https://github.com/rust-lang/rust/issues/145612
2026-08-11 11:14:51 +02:00
Pieter-Louis Schoeman
599fbed7fe Implement derives for Reborrow and CoerceShared 2026-08-11 06:48:53 +00:00
Jonathan Brouwer
92114e1e80 Rollup merge of #160782 - mejrs:attr_imports, r=JonathanBrouwer
rustc_attr_ir: fix up `lang_items` imports

Cleanup after splitting attributes from rustc_hir.

It's a big one and maybe annoying to merge without conflicts but I figured it's best to just get it done and over with. If it turns out to be too big to merge at once it should be possible to split it up tho :>

r? @JonathanBrouwer
2026-08-09 18:22:24 +02:00
mejrs
196dd2a174 Fix up lang_items import paths 2026-08-09 15:20:29 +02:00
Jacob Pratt
3820cc943d Rollup merge of #158517 - JonathanBrouwer:named_fn_trait_parameters, r=JohnTitor
Initial implementation of named `Fn` trait parameters

This is an initial implementation of the feature `named_fn_trait_parameters`.
This implementation is incomplete (and also marked as such) , and needs significant further changes to be implemented correctly. To keep the size of this PR managable, I propose we do this in follow-up PRs.
I've added a test that shows the current behaviour, with `FIXME` comments where the test output is currently incorrect.

Tracking issue: https://github.com/rust-lang/rust/issues/158499
Accepted RFC: https://github.com/rust-lang/rfcs/pull/3955
2026-08-08 23:51:55 -04:00
Jonathan Brouwer
24780bef55 Rollup merge of #160644 - mejrs:debug-impls, r=khyperia
Clean up some manual debug impls

Some of these can just be derives. Others omitted fields, deliberately or not.

For example, the annotate emitter debug now looks like:
```rust
AnnotateSnippetEmitter {
    dst: <writer@0x9069b55c60>,
    sm: Some(
        SourceMap {
            files: RwLock(
                RwLock {
                    data: [
                        "C:\\Users\\bruno\\Rust\\rust\\tests\\ui\\consts\\bad-array-size-in-type-err.rs",
                        "/rustc/FAKE_PREFIX\\library\\std\\src\\lib.rs",
                        "/rustc/FAKE_PREFIX\\library\\std\\src\\../../core/src/attribute_docs.rs",
                        "/rustc/FAKE_PREFIX\\library\\std\\src\\../../core/src/keyword_docs.rs",
                        "/rustc/FAKE_PREFIX\\library\\std\\src\\../../core/src/primitive_docs.rs",
                        "/rustc/FAKE_PREFIX\\library\\std\\src\\macros.rs",
                        "/rustc/FAKE_PREFIX\\library\\std\\src\\thread\\local.rs",
                        "/rustc/FAKE_PREFIX\\library\\std\\src\\prelude\\mod.rs",
                        "/rustc/FAKE_PREFIX\\library\\std\\src\\prelude\\v1.rs",
                        "/rustc/FAKE_PREFIX\\library\\core\\src\\lib.rs",
                        "/rustc/FAKE_PREFIX\\library\\core\\src\\clone.rs",
                        "/rustc/FAKE_PREFIX\\library\\core\\src\\marker.rs",
                        "/rustc/FAKE_PREFIX\\library\\core\\src\\default.rs",
                        "/rustc/FAKE_PREFIX\\library\\core\\src\\cmp.rs",
                        "/rustc/FAKE_PREFIX\\library\\core\\src\\ops\\mod.rs",
                        "/rustc/FAKE_PREFIX\\library\\core\\src\\ops\\drop.rs",
                        "/rustc/FAKE_PREFIX\\library\\core\\src\\ops\\function.rs",
                        "/rustc/FAKE_PREFIX\\library\\core\\src\\ops\\async_function.rs",
                        "/rustc/FAKE_PREFIX\\library\\core\\src\\convert\\mod.rs",
                        "/rustc/FAKE_PREFIX\\library\\core\\src\\iter\\mod.rs",
                        "/rustc/FAKE_PREFIX\\library\\core\\src\\iter\\traits\\mod.rs",
                        "/rustc/FAKE_PREFIX\\library\\core\\src\\iter\\traits\\double_ended.rs",
                        "/rustc/FAKE_PREFIX\\library\\core\\src\\iter\\traits\\exact_size.rs",
                        "/rustc/FAKE_PREFIX\\library\\core\\src\\iter\\traits\\collect.rs",
                        "/rustc/FAKE_PREFIX\\library\\core\\src\\iter\\traits\\iterator.rs",
                        "/rustc/FAKE_PREFIX\\library\\alloc\\src\\lib.rs",
                        "/rustc/FAKE_PREFIX\\library\\alloc\\src\\borrow.rs",
                        "/rustc/FAKE_PREFIX\\library\\alloc\\src\\string.rs",
                    ],
                },
            ),
            file_loader: <file_loader@0x1f813386448>,
            path_mapping: FilePathMapping {
                mapping: [],
                filename_remapping_scopes: RemapPathScopeComponents(
                    MACRO | DIAGNOSTICS | DEBUGINFO | COVERAGE | DOCUMENTATION,
                ),
            },
            working_dir: RealFileName {
                local: Some(
                    InnerRealFileName {
                        name: "C:\\Users\\bruno\\Rust\\rust",
                        working_directory: "",
                        embeddable_name: "C:\\Users\\bruno\\Rust\\rust",
                    },
                ),
                maybe_remapped: InnerRealFileName {
                    name: "C:\\Users\\bruno\\Rust\\rust",
                    working_directory: "",
                    embeddable_name: "C:\\Users\\bruno\\Rust\\rust",
                },
                scopes: RemapPathScopeComponents(
                    0x0,
                ),
            },
            hash_kind: Sha256,
            checksum_hash_kind: None,
        },
    ),
    short_message: false,
    ui_testing: true,
    ignored_directories_in_source_blocks: [
        "C:\\Users\\bruno\\.cargo",
        "C:\\Users\\bruno\\Rust\\rust\\vendor",
    ],
    diagnostic_width: None,
    macro_backtrace: false,
    track_diagnostics: false,
    terminal_url: No,
    theme: Ascii,
}
```
2026-08-08 00:38:34 +02:00
mejrs
b5c330c30e snippet emitter: rework debug impls 2026-08-06 23:38:00 +02:00
Jonathan Brouwer
25fd4830db Rollup merge of #160211 - jieyouxu:froot-loops, r=mati865
Rename `#[unroll]` => `#[rustc_unroll]` to mitigate nameres ambiguity

## Summary

Mitigate rust-lang/rust#159429 by renaming `#[unroll]` => `#[rustc_unroll]`.

Did not bother with a regression test, because a regression test would be hedging against an unknown attribute if `#[unroll]` later proceeds to get a different name.

Tracking issue for `#![feature(loop_hints)]`: rust-lang/rust#156874.

## Rationale

Even while the crater-observed fallout seems to be relatively small, we'd like such nameres ambiguity breakages to be *deliberate* (read: T-lang FCP'd) rather than accidental (discovered through beta crater runs).

See discussions around [last week's compiler triage meeting](https://rust-lang.zulipchat.com/#narrow/channel/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202026-07-23/near/612371735).

## Background context

The recurring problem is that built-in attributes are treated differently compared to ordinary prelude attributes, built-in attributes, even while unstable, can name-collide with stable macro re-exports of the same name (and proc-macro helper attributes of the same name), which can break stable code. See rust-lang/rust#134964.

See also:

- https://github.com/rust-lang/rust/issues/133708
- https://github.com/rust-lang/rust/pull/53913#issuecomment-418204136
- https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/Name.20Res.3A.20questions.20on.20intended.20behavior/near/562001319
- https://github.com/rust-lang/rust/issues/143834#issuecomment-3084415277

## Prior Art

- For `#[align]`, breakage was more wide-spread, so we posted this same mitigation here: https://github.com/rust-lang/rust/pull/144080.
- For `#[sanitize]`, T-lang explicitly FCP'd the breakage stemming from renaming `#[no_sanitize]` (old name) to `#[sanitize]` (new name) that regressed a couple of crates: https://github.com/rust-lang/rust/pull/142681#issuecomment-3115226820.

## Alternatives to this PR

Generally:

- We let it slide.
- T-lang FCP on `#[unroll]` breakage (in which case this PR should be closed).
- FCP another name (and associated breakages).
- (Hard) Fix the built-in attribute name resolution behavior.

I have no particular preference on the approaches myself, any of this PR and the alternatives seem fine so as long as the breakage is *deliberate* not accidental.
2026-08-06 12:41:05 +02:00
Jonathan Brouwer
3657c82cdc Rollup merge of #160006 - estebank:issue-89567, r=chenyukang
Account for desugaring in method call move errors

When encountering a move error caused by a desugared method call, talk about the user-facing feature (`await`/`?`/`for`-loop), instead of only the internal API it got desugared to.

```
error[E0382]: use of moved value: `entry`
  --> $DIR/moved-into-question-mark.rs:11:18
   |
LL |     for entry in fs::read_dir(".")? {
   |         ----- move occurs because `entry` has type `Result<DirEntry, std::io::Error>`, which does not implement the `Copy` trait
LL |
LL |         let file_type = entry?.file_type()?;
   |                         ------ `entry` moved due to usage in the question mark operator
...
LL |             dbg!(entry?.file_name());
   |                  ^^^^^ value used here after move
   |
note: the question mark operator is expanded into a call to `branch`, which takes ownership of the receiver `self`, which moves `entry`
  --> $SRC_DIR/core/src/ops/try_trait.rs:LL:COL
help: you could `clone` the value and consume it, if the following trait bounds could be satisfied: `DirEntry: Clone` and `std::io::Error: Clone`
   |
LL |         let file_type = entry.clone()?.file_type()?;
   |                              ++++++++
```

Fix rust-lang/rust#89567.
2026-08-06 12:40:59 +02:00
Jieyou Xu
0a0f6df1d5 Rename #[unroll] => #[rustc_unroll] to mitigate nameres ambiguity
Mitigation for [RUST-159429].

The recurring problem is that built-in attributes are treated
differently compared to ordinary prelude attributes, built-in
attributes, even while unstable, can name-collide with stable macro
re-exports of the same name (and proc-macro helper attributes of the
same name), which can break stable code. See [RUST-134964].

[RUST-159429]: https://github.com/rust-lang/rust/issues/159429
[RUST-134963]: https://github.com/rust-lang/rust/issues/134963
2026-08-06 09:23:24 +08:00
bors
f73951df0a Auto merge of #160494 - xmakro:perf/hygiene-root-fastpaths, r=petrochenkov
perf: Lock-free root fast paths for hygiene queries

`normalize_to_macros_2_0`, `normalize_to_macro_rules` and `outer_expn_is_descendant_of` take the `HygieneData` lock even for the root syntax context, the common case, where the answer is fixed: the root normalizes to itself, and everything descends from the root expansion. This PR avoids the lock, like the existing fast paths in `ExpnId::is_descendant_of`.
2026-08-06 00:51:08 +00:00
Jonathan Brouwer
6dc8c7c852 Rollup merge of #159820 - mejrs:specialization_marker, r=JonathanBrouwer
Make the `rustc_unsafe_specialization_marker` attribute actually `unsafe`

Also renames it to `rustc_specialization_marker`.

The "some internal attributes should probably be unsafe" discussion came up in [#t-compiler/major changes > Implement a naming convention for lint/d… compiler-team#1021](https://rust-lang.zulipchat.com/#narrow/channel/233931-t-compiler.2Fmajor-changes/topic/Implement.20a.20naming.20convention.20for.20lint.2Fd.E2.80.A6.20compiler-team.231021/with/612510054). This is one of those attributes.

cc @RalfJung
2026-08-05 13:36:12 +02:00
mejrs
73f94b6b9f Make the rustc_unsafe_specialization_marker attribute actually unsafe
Also renames it to `rustc_specialization_ignore_lifetime_constraints`
2026-08-04 19:04:05 +02:00
Oli Scherer
cecd4a4fcb Add reflection method for getting a type's generic args 2026-08-04 11:20:25 +02:00
Oli Scherer
20d5e784af Add reflection method for field offsets 2026-08-04 11:20:06 +02:00
Oli Scherer
c7fc5f2646 Add reflection method for field names 2026-08-04 11:13:53 +02:00
Makro
7c901eb266 Add lock-free root fast paths to hygiene queries 2026-08-04 06:12:01 +00:00
bors
22057b88b0 Auto merge of #155452 - makai410:enum-debug-array, r=nnethercote
Implement `Debug` for C-like enums with a concatenated string



Fixes: rust-lang/rust#133945 

Related to: rust-lang/rust#88793 rust-lang/rust#114106

Continuation of: rust-lang/rust#109615 rust-lang/rust#114190 

This optimizes the expansion of `derive(Debug)` for C-like enums with 10 or more variants to:
```rust
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
    const __NAMES: &str =
        "AAAAABBBBCCDDDDDDDDEFFFFFFFFFFFFFGGGGGGHatsuneIIIIIIIJJJJJJJJJ";
    const __OFFSET: [usize; 11] =
        [0usize, 5usize, 9usize, 11usize, 19usize, 20usize, 33usize,
                39usize, 46usize, 53usize, 62usize];
    let __d = ::core::intrinsics::discriminant_value(self) as usize;
    ::core::fmt::Formatter::debug_c_like_enum_write_str(f, __NAMES,
        &__OFFSET, __d)
}
```

The number 10 was decided based on both [the rustc perf result](https://github.com/rust-lang/rust/pull/155452#issuecomment-5080104400) and the results from the dedicated perf tool for this scenario:

<img width="1920" height="1280" alt="chart-link" src="https://github.com/user-attachments/assets/1327ee63-ce05-482b-a1fd-c56e919250ea" />
<img width="1920" height="1280" alt="chart-obj" src="https://github.com/user-attachments/assets/1cb831d3-c9dc-469f-b87d-03cf633f8335" />


See https://codeberg.org/makai410/debug-fmt-perf for more details.

r? @ghost (I want to see the perf first)
2026-08-02 23:16:20 +00:00
Jonathan Brouwer
0efc299ce6 Add named_fn_trait_parameters feature gate 2026-07-31 13:27:22 +02:00
bors
8ab9fdff5a Auto merge of #159817 - teor2345:splat-rename-nightly, r=jieyouxu
Rename splat to avoid stable name collisions

Tracking issue: rust-lang/rust#153629



This PR renames `#[splat]` to `#[rustc_splat]`, in a mostly automated way (using `fastmod`).

The rename commands I used were:
```sh
fastmod --fixed-strings '#[splat]' '#[rustc_splat]'
fastmod --fixed-strings '`splat` attribute' '`rustc_splat` attribute'
# I'm pretty sure the symbol demangling commands are no-ops on beta
# Legacy symbol demangling
fastmod --fixed-strings '$splat$' '$rustc_splat$'
# Revert some changes that aren't in rustc_demangle yet
fastmod 'v0(.*)#\[rustc_splat\]' 'v0${1}#[splat]' tests/ui/splat/splat-mangling.rs
```

Part of rust-lang/rust#159428

#### Backport Advice

Cherry-pick the first commit to the beta branch, then run the fastmod commands above.
I've tested this locally (with a slightly different name), and it works, see my [`splat-rename-beta` branch](https://github.com/teor2345/rust/tree/splat-rename-beta).

#### Remaining Work

rustc_demangle needs an update to the attribute name, a release, and then a version bump in rust-lang/rust. I'll do that separately. It doesn't need to be backported, because the last version bump was after beta branched.

There's also some external code that needs updates, the full list is in the ticket: https://github.com/rust-lang/rust/issues/159428#issuecomment-5040163201

@rustbot label +beta-nominated +A-attributes +A-macros +A-resolve +C-bug +F-splat +P-high +T-compiler
2026-07-30 19:53:05 +00:00
Esteban Küber
2713b5fc27 Account for for await in move errors 2026-07-30 12:47:59 +00:00
teor
cb797b89ce Rename splat attribute to rustc_splat 2026-07-30 10:58:18 +10:00
Jacob Pratt
f4797c0f6b Rollup merge of #160178 - beetrees:remove-unused-va-start, r=folkertdev
Remove unused `va_start` intrinsic

The `va_start` intrinsic isn't declared in `core::intrinsics` or used to implement Rust `VaList` support ([the compiler calls `bx.va_start` directly in `rustc_codegen_ssa`](b5be620d5a/compiler/rustc_codegen_ssa/src/mir/mod.rs (L523))), therefore this PR removes it.
2026-07-29 20:48:23 -04:00
beetrees
24fefc3c45 Remove unused va_start intrinsic 2026-07-29 20:25:11 +01:00
Jonathan Brouwer
bb97a9c5ac Rollup merge of #159509 - scottmcm:redo-valid-range, r=oli-obk
Generate `valid_range`s for enums sign-agnostically

Prompted by https://github.com/rust-lang/rust/issues/159438#issuecomment-5007170897, this reworks the generation of the tag layout information for enums.

Having gone down the wrong path at first here, I think the core trouble this is having is that the current calculation is trying to serve two incompatible desires:
- When picking the `value: Primitive`, we need to respect the signedness of the original *discriminant* numbers as typed in Rust.
- When picking the `valid_range: WrappingRange`, we want to *ignore* the signedness (and size!) of the discriminants and look only at the bit values (and size) of the *tags* themselves.

This thus splits the handling in `layout_of_enum` into those two parts, handled differently.
- When looking at *discriminants* (to eventually call [`discr_range_of_repr`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/layout/trait.IntegerExt.html#tymethod.discr_range_of_repr)), we obey the signedness of the inputs to find the smallest negative discriminant and largest positive discriminant -- notably *without* any wraparound logic.
- Then after having used the discriminants to pick a *tag* size, then we run a wrapping-aware check to pick the best `WrappingRange` to represent those tags (which can be a different range than we'd have picked on the discriminants, especially for `repr(Rust)` where the discriminants are `isize`).

With apologies for sending this when you'd said you'd look at it, but I got inspired 😅
r? @oli-obk

Fixes rust-lang/rust#159438

---

I have a bunch of commits in here; it's probably best reviewed one at a time.

1. Just moving `WrappingRange` to its own file, since the `lib.rs` is over 2000 lines already so if I was going to add stuff I figured some reorganizing could help.
2. Adding a new constructor to `WrappingRange` that takes an iterator of values and returns a range containing those values.  Dealing just in `u128` + `Size`, like `WrappingRange` does in other places, it doesn't even *have* signedness information so structurally is prevented from having any "why are `repr(u8)` and `repr(i8) picking different ranges?" issues.  I found it helpful to have this split out from the layout code, for example that it let me put some examples on the doc-comment.  Nothing actually *uses* the new function in this commit though.
3. Stop giving layout discriminants as `i128` since <https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/util/struct.Discr.html#structfield.val> points out that they're generated as `u128` in the same way that `WrappingRange` uses already -- even with the field doc that `-1_i8` is generated as `255_u128`, so the `as i128`ing was probably just making everything more confusing here than it needed to be.
4. Adding some tests looking at the generated `Primitive` and `valid_range`, along with rustc support for `#[rustc_dump_layout(largest_niche)]` to help have these tests include specific ERROR annotations rather than just the stderr.  The tests pass at this point, so the next commit can update them to show the change.
5. This one actually updates layout code, including using the `WrappingRange` constructor added earlier.
2026-07-29 14:10:30 +02:00
Jonathan Brouwer
bca856424e Rollup merge of #158038 - nbdd0121:register_tool, r=mejrs
Split register_tool into register_attribute_tool and register_lint_tool

Tracking issue: rust-lang/rust#66079

This implements the attribute parsing part of RFC 3808. The resolution part is yet to be implemented.

cc @jyn514
2026-07-28 21:07:45 +02:00
Jacob Pratt
f8ee207a51 Rollup merge of #153563 - Urgau:lint-panics-when-n-is-zero, r=fee1-dead,ShoyuVanilla
Lint against iterator functions that panic when `N` is zero

This PR extends the deny-by-default `unconditional_panic` lint, by linting on iterator functions that panics when `N` (chunks/windows size) is zero[^attr].

Those methods are [documented](https://doc.rust-lang.org/std/primitive.slice.html#panics-11) to panic if `N` is zero.

```
error: this operation will panic at runtime
  --> $DIR/const-n-is-zero.rs:11:13
   |
LL |     let _ = s.array_windows::<0>();
   |             ^^^^^^^^^^^^^^^^^^^^^^ const parameter `N` is zero
   |
   = note: `#[deny(unconditional_panic)]` on by default
```

cc @rust-lang/libs-api

[^attr]: this is done by introducing a new internal attribute on the const parameter: `#[rustc_panics_when_zero]`
2026-07-28 01:38:30 -04:00
Urgau
73d7d8dc85 Add #[rustc_panics_when_zero] attribute 2026-07-27 22:44:12 +02:00
Gary Guo
75999c498f Split register_tool into register_attribute_tool and register_lint_tool
This splits the functionality to two parts per RFC. The `#![register_tool]`
attribute registers the tool in both ways.

Semantics remain unchanged and will be adjusted in later commit.
2026-07-27 19:06:33 +01:00
Jonathan Brouwer
2d66d7444b Rollup merge of #159891 - mejrs:split_derives, r=JonathanBrouwer
Split multiline derives into std/rustc macros

Misc cleanup
2026-07-26 15:47:23 +02:00
Jacob Pratt
c82e22a273 Rollup merge of #159738 - WaffleLapkin:covariant-unsafe-cell, r=jhpratt
implement `CovariantUnsafeCell`

Implements https://github.com/rust-lang/rust/issues/159735 / https://github.com/rust-lang/libs-team/issues/815.
2026-07-26 00:21:46 -04:00
Jacob Pratt
0e238fd6c3 Rollup merge of #138618 - nbdd0121:asm_const_ptr, r=bjorn3
Support using const pointers in asm `const` operand

Implements [RFC#3848](https://github.com/rust-lang/rfcs/pull/3848) with tracking issue rust-lang/rust#128464

This adds support of const pointers for asm `const` in addition to plain integers.

The inline `asm!` support is implemented using `i` constraint, and the `global_asm!` and `naked_asm!` support is implemented by inserting `symbol + offset` and make `symbol` compiler-used. For unnamed consts, it will create additional internal & hidden symbols so that they can be referenced by global_asm.

~~The feature is also implemented for GCC backend but it's untested.~~ Tested now.
2026-07-26 00:21:39 -04:00
Makai
5d12b9bc28 Implement Debug for C-like enums with a concatenated string
- Add `debug_c_like_enum_write_str` to avoid duplicating similar code
2026-07-25 23:57:48 +08:00
mejrs
acb9407597 Split multiline derives into std/rustc macros 2026-07-25 12:01:39 +02:00
Gary Guo
73ff59fce9 Implement asm_const_ptr feature
The backend now fully supports codegen of const pointers, remove the
block inside typeck behind a new feature gate. Tests are also added.
2026-07-23 18:51:29 +01:00
Oli Scherer
b111aec99d Add helper trait that restricts lifetimes and extra predicates to ensure soundness 2026-07-23 11:36:11 +02:00
Waffle Lapkin
77977f9966 implement CovariantUnsafeCell 2026-07-22 21:48:57 +02:00
Scott McMurray
934f93bb55 Add some enum niche choice tests 2026-07-21 20:40:04 -07:00
Jonathan Brouwer
fd4b1d563d Rollup merge of #159058 - khyperia:macroless_generic_const_args, r=BoxyUwU
implement #![feature(macroless_generic_const_args)]

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

lots of description of what is happening here in the tracking issue, not gonna copypaste it into here :)

the test situation is that after discussion with boxy of whether our mgca tests should be:

- keep them under only `min_generic_const_args`, and add `direct_const_arg!()` where it's needed
- keep the code contents as-is, and add `#![feature(macroless_generic_const_args)]` where it's needed

the second seems more desirable, so that's what I did. There are still quite a few tests that only have `min_generic_const_args` without `macroless_generic_const_args` (140 of them, to be exact - `rg --files-without-match macroless_generic_const_args $(rg -g '*.rs' --files-with-matches min_generic_const_args tests) | wc -l`, and now 90 with `macroless_generic_const_args`)

r? @BoxyUwU
2026-07-21 12:24:55 +02:00
bors
87e5904f5e Auto merge of #159610 - JonathanBrouwer:rollup-Wil0K5d, r=JonathanBrouwer
Rollup of 18 pull requests

Successful merges:

 - rust-lang/rust#159600 (`rust-analyzer` subtree update)
 - rust-lang/rust#158046 (proc_macro: preserve file module spans for inner attrs)
 - rust-lang/rust#159000 (Small cleanups to the incr comp session code)
 - rust-lang/rust#159189 (Account for type alias projections in E0308 "expected/found" shortening logic)
 - rust-lang/rust#159449 (Enable single Location to issue multiple borrows)
 - rust-lang/rust#159544 (Suggest valid command-line crate names)
 - rust-lang/rust#159587 (Improve `AttrItem::span`)
 - rust-lang/rust#159594 (feat(rustc_hir_typeck): suggest `impl Fn` return for capturing closures)
 - rust-lang/rust#159597 (std: use `arc4random_buf` from libc)
 - rust-lang/rust#159599 (Resolver: Record at least 1 ambiguous trait if main decl is not a trait.)
 - rust-lang/rust#158061 (Make `pin!()` more foolproof.)
 - rust-lang/rust#159460 (Do not mark unnormalized const aliases as rigid when normalizing param env)
 - rust-lang/rust#159529 (Add regression test for nested replacement ranges in `collect_tokens`)
 - rust-lang/rust#159571 (Remove unused bundled library lookup for the local crate)
 - rust-lang/rust#159585 (Minor `TokenStream` improvements)
 - rust-lang/rust#159586 (Separate `InterpCx` usage by `ConstAnalysis` phases)
 - rust-lang/rust#159602 (Remove `ItemLike`)
 - rust-lang/rust#159603 (Clarify `push_stream`/`push_tree`)

Failed merges:

 - rust-lang/rust#159590 (Remove some dead code)
2026-07-20 19:20:00 +00:00
khyperia
a388f03123 macroless_generic_const_args 2026-07-20 18:24:17 +02:00