176 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
Scott McMurray 9bc1313507 Add dump_layout tests for options of bool and char 2026-04-25 13:46:42 -07:00
León Orell Valerian Liehr 7025605b8c Rename #[rustc_dump_layout]'s abi option to backend_repr
Moreover, dereference `ty_layout.align` for `#[rustc_dump_layout(align)]`
to render `align: Align($N bytes)` instead of `align: AbiAlign { abi: Align($N bytes) }`
which contains the same amount of information but it more concise and legible.
2026-04-10 12:13:52 +02:00
León Orell Valerian Liehr 357f670fde Rename #[rustc_layout] to #[rustc_dump_layout] 2026-04-10 12:13:48 +02:00
Jonathan Brouwer 0b7a11ff96 Rollup merge of #154615 - aryannrd:moving-issues, r=Kivooeo
Moving issues
2026-04-02 22:13:56 +02:00
Aryan Dubey 147d11099f fixing tidy issues 2026-03-31 15:36:37 -04:00
Aryan Dubey 49ea8ce8f5 Added link and test description for opt-repr-i32-min.rs 2026-03-28 21:03:45 -04:00
Aryan Dubey 09e48be115 Moved and renamed issue-49973.rs to layout/opt-repr-i32-min.rs 2026-03-28 20:58:22 -04:00
John Kåre Alsaker 043bd76768 Make layout_of cycles fatal errors 2026-03-24 18:25:21 +01:00
cyrgani 9b0be7857a allow incomplete_features in most UI tests 2026-03-21 20:10:07 +00:00
cyrgani 72732f2013 move tests/ui/invalid tests to new folders 2026-03-17 10:07:52 +00:00
Jonathan Brouwer b42920d71f Rollup merge of #146989 - zachs18:fix-146984, r=SparrowLii
Inhibit all-absent-variant optimization for all enum reprs that inhibit layout optimization, not just repr(C).

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/146989)*

Fixes https://github.com/rust-lang/rust/issues/146984
2026-02-28 19:55:49 +01:00
lcnr b3d9fbc172 ICE to delayed bug 2026-02-13 13:50:43 +00:00
lcnr b4f38c1da4 add regression test 2026-02-13 13:50:43 +00:00
Jacob Pratt 3db13e22b7 Rollup merge of #151814 - lcnr:silent-layout-error, r=jackh726
layout: handle rigid aliases without params

fixes rust-lang/rust#151791

r? types
2026-02-12 00:41:07 -05:00
Jonathan Brouwer c1091da34c Fix existing messages in stderrs 2026-02-07 09:13:42 +01:00
Jamie Hill-Daniel 72338fafb2 Port rustc_layout to attribute parser 2026-01-29 22:23:58 +00:00
lcnr d4454e59d3 add regression test 2026-01-29 11:55:26 +01:00
Esteban Küber cafe91749f On unmet trait bound, mention if trait is unstable 2026-01-13 01:16:58 +00:00
Oli Scherer a3359bdd4f Compile-Time Reflection MVP: tuples 2026-01-08 11:41:00 +00:00
Moulins b31ee3af9c layout: Store inverse memory index in FieldsShape::Arbitrary
All usages of `memory_index` start by calling `invert_bijective_mapping`, so
storing the inverted mapping directly saves some work and simplifies the code.
2025-12-18 22:25:34 +01:00
xonx4l 4b000cfacd Merge E0412 into E0425 2025-12-02 18:25:13 +00:00
Ralf Jung 3796f7de57 compiletest: rename add-core-stubs to add-minicore 2025-11-02 16:20:06 +01:00
Oli Scherer cac6f8760a Do not emit solver errors that contain error types 2025-10-31 08:17:44 +00:00
Camille Gillot 5dfbf67f94 Replace NullOp::SizeOf and NullOp::AlignOf by lang items. 2025-10-23 00:38:28 +00:00
David Wood efaeacfc96 revert: PR144016 - MetaSized does not always hold 2025-10-15 09:35:04 +01:00
Guillaume Gomez a8051a6ca3 Ignore more failing ui tests for GCC backend 2025-10-13 15:30:26 +02:00
Folkert de Vries 5a0ea3bfba power align: ignore repr(C) unions and enums 2025-10-05 14:18:17 +02:00
Folkert de Vries 87e8ec8114 power align: format test file 2025-10-05 14:15:40 +02:00
Zachary S 85872cfaa2 Inhibit all-absent-variant optimization for all enum reprs that inhibit layout optimization, not just repr(C). 2025-09-28 15:22:05 -05:00
tiif 0bd2ee3a0c Fix the testcases to not use UnsizedConstParamTy 2025-09-15 09:01:22 +00:00
Camille Gillot a3c878f813 Separate transmute checking from typeck. 2025-08-22 20:10:27 +00:00
Trevor Gross 289fe36d37 Print thread ID in panic message if thread name is unknown
`panic!` does not print any identifying information for threads that are
unnamed. However, in many cases, the thread ID can be determined.

This changes the panic message from something like this:

    thread '<unnamed>' panicked at src/main.rs:3:5:
    explicit panic

To something like this:

    thread '<unnamed>' (0xff9bf) panicked at src/main.rs:3:5:
    explicit panic

Stack overflow messages are updated as well.

This change applies to both named and unnamed threads. The ID printed is
the OS integer thread ID rather than the Rust thread ID, which should
also be what debuggers print.
2025-08-06 23:59:47 +00:00
Camille GILLOT 7c6496145f Check statics' type in type_of. 2025-07-25 23:39:26 +00:00
Camille GILLOT 1987471d05 Consider parent predicates in ImpossiblePredicates pass. 2025-07-20 22:45:07 +00:00
David Wood 8d64937dc2 trait_sel: MetaSized always holds temporarily
As a temporary measure while a proper fix for
`tests/ui/sized-hierarchy/incomplete-inference-issue-143992.rs`
is implemented, make `MetaSized` obligations always hold. In effect,
temporarily reverting the `sized_hierarchy` feature. This is a small
change that can be backported.
2025-07-16 12:35:44 +00:00
Jubilee 19a7f0fb7d Rollup merge of #143296 - Kivooeo:tf21, r=tgross35
`tests/ui`: A New Order [21/N]

> [!NOTE]
>
> Intermediate commits are intended to help review, but will be squashed prior to merge.

Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of rust-lang/rust#133895.

r? `@tgross35`
2025-07-04 23:26:21 -07:00
Kivooeo 62ada47328 cleaned up some tests 2025-07-05 01:25:48 +05:00
Kivooeo 9ad98f78d4 moved tests 2025-07-05 00:39:50 +05:00
Oli Scherer 9b5d57d0a9 Unconditionally run check_item_type on all items 2025-06-30 08:06:08 +00:00
David Wood cb711504bd tests: update tests with unconstrained parameters
With the addition of new bounds to the unconstrained parameters, there
are more errors which just need blessed.
2025-06-16 23:04:35 +00:00
Ralf Jung 62418f4c56 intrinsics: rename min_align_of to align_of 2025-06-12 17:50:25 +02:00
bors 334ba81275 Auto merge of #142220 - workingjubilee:rollup-idgfpof, r=workingjubilee
Rollup of 12 pull requests

Successful merges:

 - rust-lang/rust#141803 (Remove rustc's notion of "preferred" alignment AKA `__alignof`)
 - rust-lang/rust#142053 (Add new Tier-3 targets: `loongarch32-unknown-none*`)
 - rust-lang/rust#142089 (Replace all uses of sysroot_candidates with get_or_default_sysroot)
 - rust-lang/rust#142108 (compiler: Add track_caller to AbiMapping::unwrap)
 - rust-lang/rust#142132 (`tests/ui`: A New Order [6/N])
 - rust-lang/rust#142162 (UnsafePinned: update get() docs and signature to allow shared mutation)
 - rust-lang/rust#142171 (`tests/ui`: A New Order [7/N])
 - rust-lang/rust#142179 (store `target.min_global_align` as an `Align`)
 - rust-lang/rust#142183 (Added test for 30904)
 - rust-lang/rust#142194 (Remove all unused feature gates from the compiler)
 - rust-lang/rust#142199 (Do not free disk space in the `mingw-check-tidy` job)
 - rust-lang/rust#142210 (Run `mingw-check-tidy` on auto builds)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-09 02:20:44 +00:00
Jubilee Young 2e19658315 Remove rustc's notion of "preferred" alignment AKA __alignof
In PR 90877 T-lang decided not to remove `intrinsics::pref_align_of`.
However, the intrinsic and its supporting code
1.  is a nightly feature, so can be removed at compiler/libs discretion
2.  requires considerable effort in the compiler to support, as it
    necessarily complicates every single site reasoning about alignment
3.  has been justified based on relevance to codegen, but it is only a
    requirement for C++ (not C, not Rust) stack frame layout for AIX,
    in ways Rust would not consider even with increased C++ interop
4.  is only used by rustc to overalign some globals, not correctness
5.  can be adequately replaced by other rules for globals, as it mostly
    affects alignments for a few types under 16 bytes of alignment
6.  has only one clear benefactor: automating C -> Rust translation
    for GNU extensions like `__alignof`
7.  such code was likely intended to be `alignof` or `_Alignof`,
    because the GNU extension is a "false friend" of the C keyword,
    which makes the choice to support such a mapping very questionable
8.  makes it easy to do incorrect codegen in the compiler by its mere
    presence as usual Rust rules of alignment (e.g. `size == align * N`)
    do not hold with preferred alignment

The implementation is clearly damaging the code quality of the compiler.
Thus it is within the compiler team's purview to simply rip it out.
If T-lang wishes to have this intrinsic restored for c2rust's benefit,
it would have to use a radically different implementation that somehow
does not cause internal incorrectness.

Until then, remove the intrinsic and its supporting code, as one tool
and an ill-considered GCC extension cannot justify risking correctness.

Because we touch a fair amount of the compiler to change this at all,
and unfortunately the duplication of AbiAndPrefAlign is deep-rooted,
we keep an "AbiAlign" type which we can wean code off later.
2025-06-08 16:41:46 -07:00
Ralf Jung 17946c22b1 const-eval error: always say in which item the error occurred
also adjust the wording a little so that we don't say "the error occurred here" for two different spans
2025-06-07 13:42:30 +02:00
Oli Scherer 020216c31c Clarify why we are talking about a failed const eval at a random place 2025-06-02 15:37:15 +00:00
Oli Scherer b331b8b96d Use the informative error as the main const eval error message 2025-06-02 15:37:15 +00:00
Michael Goulet df47958894 Remove manual WF hack 2025-05-07 16:29:59 +00:00
Vadim Petrochenkov 93bee0789a UI tests: migrate remaining compile time error-patterns to line annotations
when possible.
2025-04-13 21:48:53 +03:00
Vadim Petrochenkov b3f75353a2 UI tests: add missing diagnostic kinds where possible 2025-04-08 23:06:31 +03:00