Commit graph

316064 commits

Author SHA1 Message Date
Jonathan Brouwer
5cccc7ca02
Rollup merge of #151441 - Keith-Cancel:mgca3, r=BoxyUwU
Fix ICE: Don't try to evaluate type_consts when eagerly collecting items

This fixes https://github.com/rust-lang/rust/issues/151246

The change is pretty straightforward if the Monomorphization strategy is eager which `-Clink-dead-code=true` sets. This then would lead to the existing code to try and evaluate a `type const` which does not have a body to evaluate leading to an ICE. The change is pretty straight forward just skip over type consts.

This also seems like a sensible choice to me since a MonoItem can only be a Fn, Static, or Asm. A type const is none of the aforementioned.

And even if it was added to the MonoItems list it would then later fail this check:
fe98ddcfcf/compiler/rustc_monomorphize/src/collector.rs (L438-L440)
Since that explicitly checks that the MonoItem's `DefKind` is static and not anything else.

One more change is the addition of a simple test of the example code from https://github.com/rust-lang/rust/issues/151246 that checks that code compiles successfully with `-Clink-dead-code=true`.

The only other change was to make the guard checks a little easier to read by making the logic more linear instead of one big if statement.

r? @BoxyUwU
@rustbot label +F-associated_const_equality +F-min_generic_const_args
2026-01-22 13:35:42 +01:00
Jonathan Brouwer
f03c1a2bd3
Rollup merge of #151423 - Voultapher:move-assert-matches, r=Amanieu
Move assert_matches to planned stable path

Another prep PR for https://github.com/rust-lang/rust/pull/137487
2026-01-22 13:35:41 +01:00
Jonathan Brouwer
96a40e9ac3
Rollup merge of #151296 - Human9000-bit:const-array-mir-dump-fix, r=BoxyUwU
MGCA: Fix incorrect pretty printing of valtree arrays

Fixes rust-lang/rust#151126

- **add failing test**
- **fix: additional check whether const array could be printed as raw bytes**

As I figured out, the problem was in `pretty_print_const_valtree`, where it tried to print unevaluated consts as if they were evaluated, which resulted in ICE.
2026-01-22 13:35:41 +01:00
Jonathan Brouwer
0fc86d8fa0
Rollup merge of #151260 - reddevilmidzy:type_const, r=BoxyUwU
Handle unevaluated ConstKind in in_operand

fix: rust-lang/rust#151248

r? BoxyUwU
~~I can't reproduce rust-lang/rust#151246 in my local(x86_64-pc-windows-msvc) even before this change. 🤔
create a draft and test it in different environments.~~
2026-01-22 13:35:40 +01:00
Jonathan Brouwer
4fb420afa5
Rollup merge of #151220 - cvengler:map-option, r=tgross35
option: Use Option::map in Option::cloned

This commit removes a repetitive match statement in favor of Option::map for Option::cloned.
2026-01-22 13:35:39 +01:00
Jonathan Brouwer
ddd8965d79
Rollup merge of #151042 - RedDaedalus:fix-select-unpredictable-fallback, r=RalfJung
fix fallback impl for select_unpredictable intrinsic

`intrinsics::select_unpredictable` does not drop the value that is not selected, but the fallback impl did not consider this behavior. This creates an observable difference between Miri and actual execution, and possibly does not play well with the `core::hint` version which has extra logic to drop the value that was not selected.
```rust
#![feature(core_intrinsics)]

fn main() {
    core::intrinsics::select_unpredictable(true, LoudDrop(0), LoudDrop(1));
    // cargo run: "0"; cargo miri run: "1 0"
}

struct LoudDrop(u8);

impl Drop for LoudDrop {
    fn drop(&mut self) {
        print!("{} ", self.0);
    }
}
```

This change let me remove the `T: [const] Destruct` bound as well, since the destructor is no longer relevant.
2026-01-22 13:35:39 +01:00
Jonathan Brouwer
83ffa35979
Rollup merge of #151001 - chojs23:fix/hidden-attr-docs, r=GuillaumeGomez
rustdoc: render doc(hidden) as a code attribute

Move `#[doc(hidden)]` into the shared code-attribute renderer so it matches the styling and placement of other attributes in rustdoc HTML.

Closes rust-lang/rust#132304
2026-01-22 13:35:38 +01:00
human9000
ff97a6a7f4 fix: allow to print const array as raw bytes only if possible to do so 2026-01-22 15:06:22 +05:00
bors
d29e4783df Auto merge of #151480 - jhpratt:rollup-kUkiF2m, r=jhpratt
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#151118 (Support slices in type reflection)
 - rust-lang/rust#151439 (Bump bootstrap compiler to 1.94)
 - rust-lang/rust#151442 (Port `#![crate_type]` to the attribute parser)
 - rust-lang/rust#151457 (Improve error message for assert!() macro in functions returning bool)

r? @ghost
2026-01-22 07:33:21 +00:00
Jacob Pratt
d43b667377
Rollup merge of #151457 - enthropy7:fix-assert-macro-only, r=enthropy7
Improve error message for assert!() macro in functions returning bool

Detect `assert!()` macro in error messages and provide clearer diagnostics

When `assert!()` is used in a function returning a value, show a message explaining that `assert!()` doesn't return a value, instead of the generic "if may be missing an else clause" error.

Fixes rust-lang/rust#151446
2026-01-22 00:37:44 -05:00
Jacob Pratt
512cc8d785
Rollup merge of #151442 - clubby789:crate-type-port, r=JonathanBrouwer
Port `#![crate_type]` to the attribute parser

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

~~Note that the actual parsing that is used in the compiler session is unchanged, as it must happen very early on; this just ports the validation logic.~~

Also added `// tidy-alphabetical-start` to `check_attr.rs` to make it a bit less conflict-prone
2026-01-22 00:37:43 -05:00
Jacob Pratt
4a983e0900
Rollup merge of #151439 - Mark-Simulacrum:bootstrap-bump, r=nnethercote
Bump bootstrap compiler to 1.94

https://forge.rust-lang.org/release/process.html#default-branch-bootstrap-update-tuesday
2026-01-22 00:37:43 -05:00
Jacob Pratt
a4cf93bccc
Rollup merge of #151118 - BD103:reflect-slices, r=oli-obk
Support slices in type reflection

Tracking issue: rust-lang/rust#146922

This PR adds support for inspecting slices `[T]` through type reflection. It does so by adding the new `Slice` struct + variant, which is very similar to `Array` but without the `len` field:

```rust
pub struct Slice {
    pub element_ty: TypeId,
}
```

Here is an example reflecting a slice:

```rust
match const { Type::of::<[u8]>() }.kind {
    TypeKind::Slice(slice) => assert_eq!(slice.element_ty, TypeId::of::<u8>()),
    _ => unreachable!(),
}
```

In addition to this, I also re-arranged the type info unit tests.

r? @oli-obk
2026-01-22 00:37:42 -05:00
Jamie Hill-Daniel
e73dfaa62f Move collect_crate_types to rustc_interface, and use new attribute parser 2026-01-22 02:34:28 +00:00
Jamie Hill-Daniel
66b78b700b Port crate_type to attribute parser 2026-01-22 02:34:28 +00:00
Jamie Hill-Daniel
8a1d6d319b Add test for malformed and misapplied crate_type 2026-01-22 02:30:56 +00:00
Jamie Hill-Daniel
e902d0512c Sort do-nothing attributes in check_attributes 2026-01-22 02:30:55 +00:00
bors
b765963267 Auto merge of #150843 - fmease:dyn-ace, r=BoxyUwU
mGCA: Make trait object types with type-level associated consts dyn compatible

Under feature `min_generic_const_args` (mGCA) (rust-lang/rust#132980), render traits with non-parametrized type-level associated constants (i.e., `#[type_const]` ones) dyn compatible but force the user to specify all type-level associated consts in the trait object type via bindings (either directly, via supertrait bounds and/or behind trait aliases) just like associated types, their sibling.

Fixes rust-lang/rust#130300 (feature request).
Fixes rust-lang/rust#136063 (bug).
Fixes rust-lang/rust#137260 (bug).
Fixes rust-lang/rust#137514 (bug).

While I'm accounting for most illegal `Self` references via const projections & params, I'm intentionally ignoring RUST-123140 (and duplicates) in this PR which is to be tackled some other time.

Additional context: Crate `rustc-demangle` had to be updated to fix v0 demangling. I've patched it in PR https://github.com/rust-lang/rustc-demangle/pull/87 which was was released in version 0.1.27 via PR https://github.com/rust-lang/rustc-demangle/pull/88.
2026-01-22 01:56:41 +00:00
Mark Rousskov
3dc7a1f33b Bump stage0 2026-01-21 20:03:56 -05:00
neo
b4c4d95950 rustdoc: render doc(hidden) as a code attribute
Move `#[doc(hidden)]` into the shared code-attribute renderer so it
matches the styling and placement of other attributes in rustdoc HTML.
2026-01-22 09:15:53 +09:00
bors
004d710faf Auto merge of #151471 - JonathanBrouwer:rollup-EgxENYU, r=JonathanBrouwer
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#151010 (std: use `ByteStr`'s `Display` for `OsStr`)
 - rust-lang/rust#151156 (Add GCC and the GCC codegen backend to build-manifest and rustup)
 - rust-lang/rust#151219 (Fixed ICE when using function pointer as const generic parameter)
 - rust-lang/rust#151343 (Port some crate level attrs to the attribute parser)
 - rust-lang/rust#151463 (add x86_64-unknown-linux-gnuasan to CI)

r? @ghost
2026-01-21 22:38:46 +00:00
Lukas Bergdoll
58be5d6620 Move assert_matches to planned stable path 2026-01-21 23:17:24 +01:00
BD103
a509588fa9 feat: support slices in reflection type info 2026-01-21 16:03:00 -06:00
enthropy7
95b58ac6ac
Improve error message for assert!() macro in functions returning bool 2026-01-22 00:49:56 +03:00
Jonathan Brouwer
5be6218b7f
Rollup merge of #151463 - jakos-sec:create-asan-target, r=Kobzol
add x86_64-unknown-linux-gnuasan to CI

Since it is a tier 2 target it should also be built by the CI workflow.
2026-01-21 22:24:04 +01:00
Jonathan Brouwer
18504a1f7b
Rollup merge of #151343 - Ozzy1423:attrs2, r=JonathanBrouwer
Port some crate level attrs to the attribute parser

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

Ports compiler_builtins, panic_runtime, needs_panic_runtime, profiler_runtime and no_builtins to the attribute parsing infrastructure.

r? @JonathanBrouwer
2026-01-21 22:24:03 +01:00
Jonathan Brouwer
afc18426cb
Rollup merge of #151219 - enthropy7:main, r=BoxyUwU
Fixed ICE when using function pointer as const generic parameter

added bounds check in prohibit_explicit_late_bound_lifetimes to prevent index out of bounds panic when args.args is empty. also regression test here to ensure function pointers in const generics produce proper error messages instead of ICE.

Fixes rust-lang/rust#151186
Fixes rust-lang/rust#137084
2026-01-21 22:24:03 +01:00
Jonathan Brouwer
d6c786165b
Rollup merge of #151156 - Kobzol:build-manifest-cg-gcc, r=Mark-Simulacrum
Add GCC and the GCC codegen backend to build-manifest and rustup

This PR adds the GCC codegen backend, and the GCC (libgccjit) component upon which it depends, to build-manifest, and thus also to (nightly) Rustup. I added both components in a single PR, because one can't work/isn't useful without the other.

Both components are marked as nightly-only and as `-preview`.

As a reminder, the GCC component is special; we need a separate component for every (host, target) compilation pair. This is not something that is really supported by rustup today, so we work around that by creating a separate component/package for each compilation target. So if we want to distribute GCC that can compile from {T1, T2} to {T2, T3}, we will create two separate components (`gcc-T2` and `gcc-T3`), and make both of them available on T1 and T2 hosts.

I tried to reuse the existing structure of `PkgType` in `build-manifest`, but added a target field to the `Gcc` package variant. This required some macro hackery, but at least it doesn't require making larger changes to `build-manifest`.

After this PR lands, unless I messed something up, starting with the following nightly, the following should work:
```bash
rustup +nightly component add rustc-codegen-gcc-preview gcc-x86_64-unknown-linux-gnu-preview
RUSTFLAGS="-Zcodegen-backend=gcc" cargo +nightly build
```

Note that it will work currently only on `x86_64-unknown-linux-gnu`, and only if not cross-compiling.

r? @Mark-Simulacrum
2026-01-21 22:24:02 +01:00
Jonathan Brouwer
76baf2c803
Rollup merge of #151010 - joboet:osstr-bytestr-display, r=jhpratt
std: use `ByteStr`'s `Display` for `OsStr`

Besides reducing duplication, this also results in formatting parameters like padding, align and fill being respected.
2026-01-21 22:24:01 +01:00
Oscar Bray
f6d76385e2 Port #![no_builtins] to the attribute parser. 2026-01-21 21:08:28 +00:00
Oscar Bray
54385b52b4 Port #![profiler_runtime] to the attribute parser. 2026-01-21 21:07:57 +00:00
Oscar Bray
1143cb2bb2 Port two panic attrs to the attr parser.
Ports #![panic_runtime] and #![needs_panic_runtime]
2026-01-21 21:07:19 +00:00
Oscar Bray
8c4e48e9b5 Port #![compiler_builtins] to the attribute parser. 2026-01-21 21:06:39 +00:00
bors
eda76d9d1d Auto merge of #149514 - adamgemmell:dev/adagem01/bootstrap-to-library, r=Kobzol
Move bootstrap configuration to library workspace

This creates a new "dist" profile in the standard library which contains configuration for the distributed std artifacts previously contained in bootstrap, in order for a future build-std implementation to use. bootstrap.toml settings continue to override these defaults, as would any RUSTFLAGS provided. I've left some cargo features driven by bootstrap for a future patch.

Unfortunately, profiles aren't expressive enough to express per-target overrides, so [this risc-v example](c8f22ca269/src/bootstrap/src/core/build_steps/compile.rs (L692)) was not able to be moved across. This could go in its own profile which Cargo would have to know to use, and then the panic-abort rustflags overrides would need duplicating again. Doesn't seem like a sustainable solution as a couple similar overrides would explode the number of lines here.

We could use a cargo config in the library workspace for this, but this then would have to be respected by Cargo's build-std implementation and I'm not yet sure about the tradeoffs there.

This patch also introduces a build probe to deal with the test crate's stability which is obviously not ideal, I'm open to other solutions here or can back that change out for now if anyone prefers.

cc @Mark-Simulacrum https://github.com/rust-lang/rfcs/pull/3874
2026-01-21 19:11:41 +00:00
León Orell Valerian Liehr
558a59258e
Support debuginfo for assoc const bindings 2026-01-21 18:52:08 +01:00
Jakob Koschel
1521f88c90 add x86_64-unknown-linux-gnuasan to CI
Since it is a tier 2 target it should also be built by the CI workflow.
2026-01-21 16:30:26 +00:00
bors
daa90b96dd Auto merge of #151459 - JonathanBrouwer:rollup-VecWQ0g, r=JonathanBrouwer
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#147426 ( tests/debuginfo/basic-stepping.rs: Add revisions `default-mir-passes`, `no-SingleUseConsts-mir-pass`)
 - rust-lang/rust#150880 (Remove old error emitter)
 - rust-lang/rust#151432 (use `deny(missing_docs)` for non-mir intrinsics)
 - rust-lang/rust#151444 (Move UI tests)
 - rust-lang/rust#151445 (Derive `Default` for `QueryArenas`)
 - rust-lang/rust#151453 (make `simd_insert_dyn` and `simd_extract_dyn` const)

r? @ghost
2026-01-21 15:54:16 +00:00
Jonathan Brouwer
530eeff929
Rollup merge of #151453 - folkertdev:simd-dyn-const, r=RalfJung
make `simd_insert_dyn` and `simd_extract_dyn` const

For use in `stdarch`. We currently use an equivalent of the fallback body here, but on some targets the intrinsic generate better code.

r? RalfJung
2026-01-21 16:39:43 +01:00
Jonathan Brouwer
f87b84ce3d
Rollup merge of #151445 - Zalathar:arenas-default, r=mati865
Derive `Default` for `QueryArenas`

There's no need to manually implement Default for this struct, because the fields are all `TypeArena<_>` or `()`, which both implement Default already.

This lets us avoid one occurrence of the `query_if_arena!` macro.
2026-01-21 16:39:42 +01:00
Jonathan Brouwer
6cd3cfd221
Rollup merge of #151444 - Delta17920:move-ui-tests, r=Kivooeo
Move UI tests

Moved several regression tests from `tests/ui/issues` to specific folders
2026-01-21 16:39:41 +01:00
Jonathan Brouwer
e937bdde41
Rollup merge of #151432 - folkertdev:intrinsics-require-docs, r=RalfJung
use `deny(missing_docs)` for non-mir intrinsics
2026-01-21 16:39:41 +01:00
Jonathan Brouwer
1fd85437a1
Rollup merge of #150880 - bjorn3:remove_old_error_emitter, r=nnethercote
Remove old error emitter

This completes the transition to annotate-snippets and cuts 3600 lines of code.
2026-01-21 16:39:40 +01:00
Jonathan Brouwer
74ff006ce6
Rollup merge of #147426 - Enselic:better-stepping, r=saethlin
tests/debuginfo/basic-stepping.rs: Add revisions `default-mir-passes`, `no-SingleUseConsts-mir-pass`

To prevent regressions our test must cover the code both inside and outside of the `SingleUseConsts` MIR pass. Use revisions for that.

We know this use case is sensitive to regressions because it already happened at least once. See https://github.com/rust-lang/rust/issues/33013#issuecomment-3121579216.

CC https://github.com/rust-lang/rust/issues/130896
2026-01-21 16:39:39 +01:00
reddevilmidzy
a158e2e8d6 Handle unevaluated Const::Ty (#[type_const]) 2026-01-22 00:35:12 +09:00
Folkert de Vries
b4220ecb68
make simd_insert_dyn and simd_extract_dyn const 2026-01-21 14:57:33 +01:00
delta17920
0d6d0fad34 fix error 2026-01-21 13:54:00 +00:00
delta17920
7ba1e3ec7d filename changes 2026-01-21 13:44:01 +00:00
delta17920
b786aa8d68 moved tests/ui/issues/issue-2150.rs -> tests/ui/reachable/loop-after-panic.rs 2026-01-21 13:35:20 +00:00
delta17920
b7d7dcebce added issue link 2026-01-21 13:35:20 +00:00
delta17920
6fd6ff3a4a moved 6 tests to organized locations 2026-01-21 13:35:20 +00:00