about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-09-13Rollup merge of #146403 - cyrgani:array-sugg-sorting, r=fee1-deadJana Dönszelmann-3/+15
sort array trait implementation suggestions correctly Fixes rust-lang/rust#135098. Previously tried in rust-lang/rust#137428.
2025-09-13Rollup merge of #146389 - jdonszelmann:no-std, r=oli-obkJana Dönszelmann-3/+39
Convert `no_std` and `no_core` to the new attribute infrastructure r? ```@oli-obk``` Also added a test for these, since we didn't have any and I was kind of surprised new diagnostics didn't break anything hehe
2025-09-12Auto merge of #146329 - lcnr:opaque-type-infer-alias-candidates, r=BoxyUwUbors-38/+207
consider item bounds for non-yet-defined opaque types Based on rust-lang/rust#140405. fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/182 fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/196 fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/205 there's some jank here, see https://github.com/rust-lang/trait-system-refactor-initiative/issues/229 ## Design If the self type is an inference variable which has been sub-unified with am opaque type, we need to incompletely guide inference to avoid breakage. In this case, we - look at the item bounds of all sub-unified opaque types, and - blanket impls which do not constrain the self type Even if there are applicable candidates, we always force their certainty to be `Maybe`, so they will always have to be reproven once we've constrained the inference variable. This is a bit iffy, see the added tests. r? `@BoxyUwU`
2025-09-12sort array trait implementation suggestions correctlycyrgani-3/+15
2025-09-12Rollup merge of #146308 - cyrgani:concat-integer-literals, r=jackh726Stuart Cook-1/+17
support integer literals in `${concat()}` Tracking issue: rust-lang/rust#124225 Adds support for using integer literals as arguments to `${concat()}` macro expressions. Integer formatting such as `1_000` is preserved by this.
2025-09-12Rollup merge of #144549 - folkertdev:va-arg-arm, r=saethlinStuart Cook-1/+20
match clang's `va_arg` assembly on arm targets tracking issue: https://github.com/rust-lang/rust/issues/44930 For this example ```rust #![feature(c_variadic)] #[unsafe(no_mangle)] unsafe extern "C" fn variadic(a: f64, mut args: ...) -> f64 { let b = args.arg::<f64>(); let c = args.arg::<f64>(); a + b + c } ``` We currently generate (via llvm): ```asm variadic: sub sp, sp, #12 stmib sp, {r2, r3} vmov d0, r0, r1 add r0, sp, #4 vldr d1, [sp, #4] add r0, r0, #15 bic r0, r0, #7 vadd.f64 d0, d0, d1 add r1, r0, #8 str r1, [sp] vldr d1, [r0] vadd.f64 d0, d0, d1 vmov r0, r1, d0 add sp, sp, #12 bx lr ``` LLVM is not doing a good job. In fact, it's well-known that LLVM's implementation of `va_arg` is kind of bad, and we implement it ourselves (based on clang) for many targets already. For arm, our own `emit_ptr_va_arg` saves 3 instructions. Next, it turns out it's important for LLVM to explicitly start and end the lifetime of the `va_list`. In https://github.com/rust-lang/rust/pull/146059 I already end the lifetime, but when looking at this again, I noticed that it is important to also start it, see https://godbolt.org/z/EGqvKTTsK: failing to explicitly start the lifetime uses an extra register. So, the combination of `emit_ptr_va_arg` with starting/ending the lifetime makes rustc emit exactly the instructions that clang generates:: ```asm variadic: sub sp, sp, #12 stmib sp, {r2, r3} vmov d16, r0, r1 vldr d17, [sp, #4] vadd.f64 d16, d16, d17 vldr d17, [sp, #12] vadd.f64 d16, d16, d17 vmov r0, r1, d16 add sp, sp, #12 bx lr ``` The arguments to `emit_ptr_va_arg` are based on [the clang implementation](https://github.com/llvm/llvm-project/blob/03dc2a41f3d9a500e47b513de5c5008c06860d65/clang/lib/CodeGen/Targets/ARM.cpp#L798-L844). r? ``@workingjubilee`` (I can re-roll if your queue is too full, but you do seem like the right person here) try-job: armhf-gnu
2025-09-12Auto merge of #146328 - zetanumbers:fix-141951, r=lcnrbors-5/+40
Skip typeck for items w/o their own typeck context Skip items which forward typeck to their ancestor. Should remove some potential but unnecessary typeck query waits, hence might improve performance for the parallel frontend. Thanks to `@ywxt` for a fix suggestion Fixes rust-lang/rust#141951
2025-09-11incompletely prefer opaque type bounds when self type bottoms out in inferMichael Goulet-14/+174
2025-09-11consider the `sub_unification_table` in `stalled_on`lcnr-24/+33
2025-09-11Rollup merge of #146428 - jieyouxu:revert-assert-desugaring, r=estebank,jackh726Stuart Cook-57/+18
Revert `assert!` desugaring changes (#122661) Reverts rust-lang/rust#122661 to prevent rust-lang/rust#145770 slipping into beta. cc `@estebank` (FYI) ### Review remarks - Commit 1 is the MCVE reported in rust-lang/rust#145770 added as a regression test `tests/ui/macros/assert-desugaring-145770.rs`. Against `master`, this test fails. - Commit 2 reverts rust-lang/rust#122661 (with a merge conflict fixed). `tests/ui/macros/assert-desugaring-145770.rs` now passes.
2025-09-11Rollup merge of #146422 - fmease:less-greedy-maybe-const-bounds, r=estebankStuart Cook-8/+11
Less greedily parse `[const]` bounds > [!IMPORTANT] > If you're coming here from any beta backport nomination thread on Zulip, only the last commit is truly relevant (the first commit doesn't need to be backported, it only contains test modifications)! Don't consider `[` to start a bound, only consider `[const]` in its entirety to do so. This drastically reduces (but doesn't eliminate!) the chance of *real* breakages. Like `const`, `~const` and `async` before, `[const]` unavoidably brings along theoretical breakages, see preexisting tests: `macro-const-trait-bound-theoretical-regression.rs` and `macro-async-trait-bound-theoretical-regression.rs`. Side note: It's unfortunate that we have to do this but apart from the known fact that MBE hurts forward compatibility, the `[const]` syntax is simply a bit scuffed (also CC'ing https://github.com/rust-lang/rust/issues/146122, section (3)). Fixes [after beta backport] rust-lang/rust#146417. * 1st commit: Restore the original test intentions of several preexisting related tests that were unfortunately lost over time * I've added a bunch of SCREAMING comments to make it less likely to be lost again * CC PR rust-lang/rust#119099 which added most of these tests * CC [#144409 (comment)](https://github.com/rust-lang/rust/pull/144409#discussion_r2337587513) for further context (NB: It's not the only PR that negatively affected the test intention) * 2nd commit: Actually address the regression r? `@oli-obk` or anyone
2025-09-11Rollup merge of #146415 - RalfJung:s390x-softfloat, r=workingjubileeStuart Cook-0/+8
s390x: mark soft-float target feature as incompatible This provides a more informative warning when someone manually sets `+soft-float` on s390x.
2025-09-11Rollup merge of #146347 - folkertdev:duplicate-symbol-panic, r=fee1-deadStuart Cook-6/+15
report duplicate symbols added by the driver The panic message did not mention what symbols were duplicates, which made the panic hard to debug. This came up in [#t-compiler/help > Easiest way to find offending duplicate symbols](https://rust-lang.zulipchat.com/#narrow/channel/182449-t-compiler.2Fhelp/topic/Easiest.20way.20to.20find.20offending.20duplicate.20symbols/with/538295740). This behavior was introduced in https://github.com/rust-lang/rust/pull/138682. r? ```@fee1-dead```
2025-09-11Revert "Rollup merge of #122661 - estebank:assert-macro-span, r=petrochenkov"Jieyou Xu-57/+18
This reverts commit 1eeb8e8b151d1da7daa73837a25dc5f7a1a7fa28, reversing changes made to 324bf2b9fd8bf9661e7045c8a93f5ff0ec1a8ca5. Unfortunately the assert desugaring change is not backwards compatible, see RUST-145770. Code such as ```rust #[derive(Debug)] struct F { data: bool } impl std::ops::Not for F { type Output = bool; fn not(self) -> Self::Output { !self.data } } fn main() { let f = F { data: true }; assert!(f); } ``` would be broken by the assert desugaring change. We may need to land the change over an edition boundary, or limit the editions that the desugaring change impacts.
2025-09-10Less greedily parse `[const]` boundsLeón Orell Valerian Liehr-5/+8
2025-09-10Restore the test intention of several MBE trait bound modifier testsLeón Orell Valerian Liehr-3/+3
2025-09-10s390x: mark soft-float target feature as incompatibleRalf Jung-0/+8
2025-09-10fixup no_{core,std} handling codeJana Dönszelmann-4/+5
2025-09-10Rollup merge of #146342 - folkertdev:c-variadic-errors-take-3, r=workingjubileeMatthias Krüger-52/+167
Improve C-variadic error messages: part 2 tracking issue: https://github.com/rust-lang/rust/issues/44930 a reimplementation of https://github.com/rust-lang/rust/pull/143546 that builds on https://github.com/rust-lang/rust/pull/146165. This PR - disallows coroutines (e.g. `async fn`) from having a `...` argument - disallows associated functions (both in traits and standard impl blocks) from having a `...` argument - splits up a generic "ill-formed C-variadic function" into specific errors about using an incorrect ABI, not specifying an ABI, or missing the unsafe keyword C-variadic coroutines probably don't make sense? C-variadic functions are for FFI purposes, combining that with async functions seems weird. For associated functions, we're just cutting scope. It's probably fine, but it's probably better to explicitly allow it. So for now, at least give a more targeted error message. Made to be reviewed commit-by-commit. cc `@workingjubilee` r? compiler
2025-09-10Rollup merge of #146340 - fmease:frontmatter-containment, r=fee1-dead,UrgauMatthias Krüger-82/+134
Strip frontmatter in fewer places * Stop stripping frontmatter in `proc_macro::Literal::from_str` (RUST-146132) * Stop stripping frontmatter in expr-ctxt (but not item-ctxt!) `include`s (RUST-145945) * Stop stripping shebang (!) in `proc_macro::Literal::from_str` * Not a breaking change because it did compare spans already to ensure there wasn't extra whitespace or comments (`Literal::from_str("#!\n0")` already yields `Err(_)` thankfully!) * Stop stripping frontmatter+shebang inside some rustdoc code where it doesn't make any observable difference (see self review comments) * (Stop stripping frontmatter+shebang inside internal test code) Fixes https://github.com/rust-lang/rust/issues/145945. Fixes https://github.com/rust-lang/rust/issues/146132. r? fee1-dead
2025-09-10Rollup merge of #146311 - nnethercote:symbol-comments, r=petrochenkovMatthias Krüger-7/+6
Minor symbol comment fixes. - The empty symbol is no longer a keyword. - I don't think any of the special reserved identifiers are used for error recovery. r? ```@petrochenkov```
2025-09-10Rollup merge of #146123 - IoaNNUwU:issue-68293, r=estebankMatthias Krüger-0/+27
Suggest examples of format specifiers in error messages Format macro now suggests adding `{}` if no formatting specifiers are present. It also gives an example: ```rust LL | println!("Hello", "World"); | ------- ^^^^^^^ argument never used | | | formatting specifier missing | = note: format specifiers use curly braces: `{}` help: consider adding format specifier | LL | println!("Hello{}", "World"); | ++ ``` When one or more `{}` are present, it doesn't show 'format specifiers use curly braces: `{}`' and example, just small hint on how many you missing: ```rust LL | println!("list: {}", 1, 2, 3); | ---------- ^ ^ argument never used | | | | | argument never used | multiple missing formatting specifiers | = help: consider adding 2 format specifiers ``` Original issue: rust-lang/rust#68293 Based on discussion in this PR: rust-lang/rust#76443 Let me know if something is missing
2025-09-10Rollup merge of #145879 - Bryanskiy:supertraits-2, r=lcnrMatthias Krüger-143/+25
default auto traits: use default supertraits instead of `Self: Trait` bounds on associated items First commit: the motivation has been discussed [here](https://github.com/rust-lang/rust/pull/144679). Second commit: the only new places where new implicit `DefaultAutoTrait` bounds are generated are supertraits and trait object so `?Trait` syntax should be extended to these places only. r? `@lcnr`
2025-09-10Rollup merge of #146391 - beepster4096:trimnt, r=saethlinMatthias Krüger-5/+7
Trim paths less in MIR dumping With this PR, the paths MIR dump filters and that are printed at the start of a dump file are no longer trimmed. They don't include the crate that is being compiled, however.
2025-09-10Rollup merge of #146178 - folkertdev:static-align, ↵Matthias Krüger-5/+79
r=jdonszelmann,ralfjung,traviscross Implement `#[rustc_align_static(N)]` on `static`s Tracking issue: https://github.com/rust-lang/rust/issues/146177 ```rust #![feature(static_align)] #[rustc_align_static(64)] static SO_ALIGNED: u64 = 0; ``` We need a different attribute than `rustc_align` because unstable attributes are tied to their feature (we can't have two unstable features use the same unstable attribute). Otherwise this uses all of the same infrastructure as `#[rustc_align]`. r? `@traviscross`
2025-09-10Rollup merge of #144765 - Qelxiros:range-inclusive-last, r=jhprattMatthias Krüger-6/+56
inclusive `Range`s: change `end` to `last` Tracking issue: rust-lang/rust#125687 ACP: rust-lang/libs-team#511
2025-09-10Permit `more_maybe_bounds` in supertraits and trait objects onlyBryanskiy-7/+8
2025-09-10Default auto traits: revert to the default supertraitsBryanskiy-136/+17
2025-09-09don't trim paths in mir dumping when filtering and at the top of the filebeepster4096-5/+7
2025-09-09port `#[no_std]` to the new attribute parsing infrastructureJana Dönszelmann-2/+19
2025-09-09port `#[no_core]` to the new attribute parsing infrastructureJana Dönszelmann-2/+20
2025-09-09allow `#[rustc_align_static(N)]` on `static`sFolkert de Vries-5/+79
We need a different attribute than `rustc_align` because unstable attributes are tied to their feature (we can't have two unstable features use the same unstable attribute). Otherwise this uses all of the same infrastructure as `#[rustc_align]`.
2025-09-09c-variadic: reject functions with unsupported extern ABIFolkert de Vries-6/+22
2025-09-09c-variadic: reject non-unsafe functionsFolkert de Vries-9/+56
2025-09-09Auto merge of #146375 - matthiaskrgr:rollup-utik9zj, r=matthiaskrgrbors-59/+60
Rollup of 6 pull requests Successful merges: - rust-lang/rust#145463 (Reject invalid literal suffixes in tuple indexing, tuple struct indexing, and struct field name position) - rust-lang/rust#145929 (fix APITIT being treated as a normal generic parameter in suggestions) - rust-lang/rust#146001 (Update getopts to remove unicode-width dependency) - rust-lang/rust#146365 (triagebot: warn about #[rustc_intrinsic_const_stable_indirect]) - rust-lang/rust#146366 (add approx_delta to all gamma tests) - rust-lang/rust#146373 (fix comments about trait solver cycle heads) r? `@ghost` `@rustbot` modify labels: rollup
2025-09-09Strip frontmatter in fewer placesLeón Orell Valerian Liehr-69/+116
2025-09-09Rollup merge of #146373 - calvinhirsch:trait-solver-cycle-head-docs, r=lcnrMatthias Krüger-4/+4
fix comments about trait solver cycle heads update some comments that use "cycle root" rather than "cycle head" also fixed a random other nearby typo in `StackEntry` docs zulip thread: https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/quick.20question.20about.20SearchGraph.3A.3Aevaluate_goal_in_task/with/538004295 ?r lcnr
2025-09-09Rollup merge of #145929 - Qelxiros:apitit-suggestion, r=BoxyUwUMatthias Krüger-27/+46
fix APITIT being treated as a normal generic parameter in suggestions closes rust-lang/rust#126395
2025-09-09Rollup merge of #145463 - jieyouxu:error-suffix, r=fmeaseMatthias Krüger-28/+10
Reject invalid literal suffixes in tuple indexing, tuple struct indexing, and struct field name position Tracking issue: rust-lang/rust#60210 Closes rust-lang/rust#60210 ## Summary Bump the ["suffixes on a tuple index are invalid" non-lint pseudo future-incompatibility warning (#60210)][issue-60210][^non-lint] to a **hard error** across all editions, rejecting the remaining carve outs from accidentally accepted invalid suffixes since Rust **1.27**. - We accidentally accepted invalid suffixes in tuple indexing positions in Rust **1.27**. Originally reported at https://github.com/rust-lang/rust/issues/59418. - We tried to hard reject all invalid suffixes in https://github.com/rust-lang/rust/pull/59421, but unfortunately it turns out there were proc macros accidentally relying on it: https://github.com/rust-lang/rust/issues/60138. - We temporarily accepted `{i,u}{32,size}` in https://github.com/rust-lang/rust/pull/60186 (the "*carve outs*") to mitigate *immediate* ecosystem impact, but it came with an FCW warning indicating that we wanted to reject it after a few Rust releases. - Now (1.89.0) is a few Rust releases later (1.35.0), thus I'm proposing to **also reject the carve outs**. - `std::mem::offset_of!` stabilized in Rust **1.77.0** happens to use the same "don't expect suffix" code path which has the carve outs, so it also accepted the carve out suffixes. I'm proposing to **reject this case as well**. ## What specifically breaks? Code that still relied on invalid `{i,u}{32,size}` suffixes being temporarily accepted by rust-lang/rust#60186 as an ecosystem impact mitigation measure (cf. rust-lang/rust#60138). Specifically, the following cases (particularly the construction of these forms in proc macros like reported in rust-lang/rust#60138): ### Position 1: Invalid `{i,u}{32,size}` suffixes in tuple indexing ```rs fn main() { let _x = (42,).0invalid; // Already error, already rejected by #59421 let _x = (42,).0i8; // Already error, not one of the #60186 carve outs. let _x = (42,).0usize; // warning: suffixes on a tuple index are invalid } ``` ### Position 2: Invalid `{i,u}{32,size}` suffixes in tuple struct indexing ```rs fn main() { struct X(i32); let _x = X(42); let _x = _x.0invalid; // Already error, already rejected by #59421 let _x = _x.0i8; // Already error, not one of the #60186 carve outs. let _x = _x.0usize; // warning: suffixes on a tuple index are invalid } ``` ### Position 3: Invalid `{i,u}{32,size}` suffixes in numeric struct field names ```rs fn main() { struct X(i32, i32, i32); let _x = X(1, 2, 3); let _y = X { 0usize: 42, 1: 42, 2: 42 }; // warning: suffixes on a tuple index are invalid match _x { X { 0usize: 1, 1: 2, 2: 3 } => todo!(), // warning: suffixes on a tuple index are invalid _ => {} } } ``` ### Position 4: Invalid `{i,u}{32,size}` suffixes in `std::mem::offset_of!` While investigating the warning, unfortunately I noticed `std::mem::offset_of!` also happens to use the "expect no suffix" code path which had the carve outs. So this was accepted since Rust **1.77.0** with the same FCW: ```rs fn main() { #[repr(C)] pub struct Struct<T>(u8, T); assert_eq!(std::mem::offset_of!(Struct<u32>, 0usize), 0); //~^ WARN suffixes on a tuple index are invalid } ``` ### The above forms in proc macros For instance, constructions like (see tracking issue rust-lang/rust#60210): ```rs let i = 0; quote! { foo.$i } ``` where the user needs to actually write ```rs let i = syn::Index::from(0); quote! { foo.$i } ``` ### Crater results Conducted a crater run (https://github.com/rust-lang/rust/pull/145463#issuecomment-3194920383). - https://github.com/AmlingPalantir/r4/tree/256af3c72f094b298cd442097ef7c571d8001f29: genuine regression; "invalid suffix `usize`" in derive macro. Has a ton of other build warnings, last updated 6 years ago. - Exactly the kind of intended breakage. Minimized down to https://github.com/AmlingPalantir/r4/blob/256af3c72f094b298cd442097ef7c571d8001f29/validates_derive/src/lib.rs#L71-L75, where when interpolation uses `quote`'s `ToTokens` on a `usize` index (i.e. on tuple struct `Tup(())`), the generated suffix becomes `.0usize` (cf. Position 2). - Notified crate author of breakage in https://github.com/AmlingPalantir/r4/issues/1. - Other failures are unrelated or spurious. ## Review remarks - Commits 1-3 expands the test coverage to better reflect the current situation before doing any functional changes. - Commit 4 is an intentional **breaking change**. We bump the non-lint "suffixes on a tuple index are invalid" warning into a hard error. Thus, this will need a crater run and a T-lang FCP. ## Tasks - [x] Run crater to check if anyone is still relying on this being not a hard error. Determine degree of ecosystem breakage. - [x] If degree of breakage seems acceptable, draft nomination report for T-lang for FCP. - [x] Determine hard error on Edition 2024+, or on all editions. ## Accompanying Reference update - https://github.com/rust-lang/reference/pull/1966 [^non-lint]: The FCW was implemented as a *non-lint* warning (meaning it has no associated lint name, and you can't `#![deny(..)]` it) because spans coming from proc macros could not be distinguished from regular field access. This warning was also intentionally impossible to silence. See https://github.com/rust-lang/rust/pull/60186#issuecomment-485581694. [issue-60210]: https://github.com/rust-lang/rust/issues/60210
2025-09-09Improve docs of certain built-in macro expandersLeón Orell Valerian Liehr-13/+18
2025-09-09Auto merge of #145717 - BoxyUwU:erase_regions_rename, r=lcnrbors-129/+154
rename erase_regions to erase_and_anonymize_regions I find it consistently confusing that `erase_regions` does more than replacing regions with `'erased`. it also makes some code look real goofy to be writing manual folders to erase regions with a comment saying "we cant use erase regions" :> or code that re-calls erase_regions on types with regions already erased just to anonymize all the bound regions. r? lcnr idk how i feel about the name being almost twice as long now
2025-09-09fix comments about trait solver cycle headscalvinhirsch-4/+4
2025-09-09Add assertionBoxy-1/+1
2025-09-09Driveby fixesBoxy-10/+9
2025-09-09erase_regions to erase_and_anonymize_regionsBoxy-124/+150
2025-09-09Auto merge of #146360 - Zalathar:rollup-qc2hhrd, r=Zalatharbors-218/+369
Rollup of 11 pull requests Successful merges: - rust-lang/rust#139593 (add sitemap to rust docs) - rust-lang/rust#145819 (Port limit attributes to the new attribute parsing infrastructure) - rust-lang/rust#146025 (compiler: Include span of too huge array with `-Cdebuginfo=2`) - rust-lang/rust#146184 (In the rustc_llvm build script, don't consider arm64* to be 32-bit) - rust-lang/rust#146195 (fix partial urlencoded link support) - rust-lang/rust#146300 (Implement `Sum` and `Product` for `f16` and `f128`.) - rust-lang/rust#146314 (mark `format_args_nl!` as `#[doc(hidden)]`) - rust-lang/rust#146324 (const-eval: disable pointer fragment support) - rust-lang/rust#146326 (simplify the declaration of the legacy integer modules (`std::u32` etc.)) - rust-lang/rust#146339 (Update books) - rust-lang/rust#146343 (Weakly export `platform_version` symbols) r? `@ghost` `@rustbot` modify labels: rollup
2025-09-09Rollup merge of #146324 - RalfJung:no-ptr-fragment, r=oli-obkStuart Cook-4/+23
const-eval: disable pointer fragment support This fixes https://github.com/rust-lang/rust/issues/146291 by disabling pointer fragment support for const-eval. I want to properly fix this eventually, but won't get to it in the next few weeks, so this is an emergency patch to prevent the buggy implementation from landing on stable. The beta cutoff is on Sep 12th so if this PR lands after that, we'll need a backport.
2025-09-09Rollup merge of #146184 - dpaoliello:llvmbuildarm64, r=cuviperStuart Cook-1/+4
In the rustc_llvm build script, don't consider arm64* to be 32-bit The build script for `rustc_llvm` needs to detect 32-bit targets so that it links against `libatomics`. To do this, it matches the target architecture against `arm`, unfortunately incorrectly matches Arm64EC, Arm64E, etc. This change adds a check that the target arch doesn't match `arm64`.
2025-09-09Rollup merge of #146025 - Enselic:big-array-debuginfo-span, r=wesleywiserStuart Cook-4/+10
compiler: Include span of too huge array with `-Cdebuginfo=2` We have a few ui tests to ensure we emit an error if we encounter too big arrays. Before this fix, compiling the tests with `-Cdebuginfo=2` would not include the spans of the instantiation sites, because the error is then emitted from a different code path that does not include the span. Propagate the span to the error also in the debuginfo case, so the tests passes regardless of debuginfo level. r? ``@wesleywiser`` since this is a natural continuation of https://github.com/rust-lang/rust/pull/145967 that you approved (thanks!). cc https://github.com/rust-lang/rust/issues/61117 since this takes is one step closer to increasing `rust.debuginfo-level-tests` to `2` in the **x86_64-gnu-debug** CI job. ## Test failure output without the fix <details> <summary> Here is what the test failures look like if you run the tests without the fix. (Click to expand.) </summary> ``` $ ./x test --set rust.debuginfo-level-tests=2 tests/ui/limits/huge-array-simple-64.rs tests/ui/limits/huge-array.rs tests/ui/limits/issue-15919-64.rs Building bootstrap Finished `dev` profile [unoptimized] target(s) in 0.16s /home/martin/src/rust/build/x86_64-unknown-linux-gnu/ci-llvm/bin/llvm-strip does not exist; skipping copy Building stage1 compiler artifacts (stage0 -> stage1, x86_64-unknown-linux-gnu) Finished `release` profile [optimized + debuginfo] target(s) in 0.40s Creating a sysroot for stage1 compiler (use `rustup toolchain link 'name' build/host/stage1`) Building stage1 lld-wrapper (stage0 -> stage1, x86_64-unknown-linux-gnu) Finished `release` profile [optimized + debuginfo] target(s) in 0.08s Building stage1 library artifacts (stage1 -> stage1, x86_64-unknown-linux-gnu) Compiling addr2line v0.25.0 Compiling std v0.0.0 (/home/martin/src/rust/library/std) Compiling rustc-std-workspace-std v1.99.0 (/home/martin/src/rust/library/rustc-std-workspace-std) Compiling unicode-width v0.2.1 Compiling rustc-literal-escaper v0.0.5 Compiling proc_macro v0.0.0 (/home/martin/src/rust/library/proc_macro) Compiling getopts v0.2.23 Compiling test v0.0.0 (/home/martin/src/rust/library/test) Compiling sysroot v0.0.0 (/home/martin/src/rust/library/sysroot) Finished `release` profile [optimized + debuginfo] target(s) in 14.43s Building stage1 compiletest (stage0 -> stage1, x86_64-unknown-linux-gnu) Finished `release` profile [optimized + debuginfo] target(s) in 0.14s Testing stage2 compiletest suite=ui mode=ui (stage1 -> stage2, x86_64-unknown-linux-gnu) running 6 tests [ui] tests/ui/limits/huge-array.rs#full-debuginfo ... F [ui] tests/ui/limits/issue-15919-64.rs#full-debuginfo ... F [ui] tests/ui/limits/huge-array-simple-64.rs#full-debuginfo ... F ... failures: ---- [ui] tests/ui/limits/huge-array.rs#full-debuginfo stdout ---- Saved the actual stderr to `/home/martin/src/rust/build/x86_64-unknown-linux-gnu/test/ui/limits/huge-array.full-debuginfo/huge-array.full-debuginfo.stderr` diff of stderr: 1 error: values of the type `[[u8; 1518599999]; 1518600000]` are too big for the target architecture - --> $DIR/huge-array.rs:9:9 - | - LL | let s: [T; 1518600000] = [t; 1518600000]; - | ^ 6 7 error: aborting due to 1 previous error 8 The actual stderr differed from the expected stderr To update references, rerun the tests and pass the `--bless` flag To only update this specific test, also pass `--test-args limits/huge-array.rs` error in revision `full-debuginfo`: 1 errors occurred comparing output. status: exit status: 1 command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/home/martin/src/rust/build/x86_64-unknown-linux-gnu/stage1/bin/rustc" "/home/martin/src/rust/tests/ui/limits/huge-array.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/home/martin/.cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/home/martin/src/rust/vendor" "--sysroot" "/home/martin/src/rust/build/x86_64-unknown-linux-gnu/stage1" "--target=x86_64-unknown-linux-gnu" "--cfg" "full_debuginfo" "--check-cfg" "cfg(test,FALSE,no_debuginfo,full_debuginfo)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "--out-dir" "/home/martin/src/rust/build/x86_64-unknown-linux-gnu/test/ui/limits/huge-array.full-debuginfo" "-A" "unused" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Lnative=/home/martin/src/rust/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Cdebuginfo=2" stdout: none --- stderr ------------------------------- error: values of the type `[[u8; 1518599999]; 1518600000]` are too big for the target architecture error: aborting due to 1 previous error ------------------------------------------ ---- [ui] tests/ui/limits/huge-array.rs#full-debuginfo stdout end ---- ---- [ui] tests/ui/limits/issue-15919-64.rs#full-debuginfo stdout ---- Saved the actual stderr to `/home/martin/src/rust/build/x86_64-unknown-linux-gnu/test/ui/limits/issue-15919-64.full-debuginfo/issue-15919-64.full-debuginfo.stderr` diff of stderr: 1 error: values of the type `[usize; usize::MAX]` are too big for the target architecture - --> $DIR/issue-15919-64.rs:10:9 - | - LL | let x = [0usize; 0xffff_ffff_ffff_ffff]; - | ^ 6 7 error: aborting due to 1 previous error 8 The actual stderr differed from the expected stderr To update references, rerun the tests and pass the `--bless` flag To only update this specific test, also pass `--test-args limits/issue-15919-64.rs` error in revision `full-debuginfo`: 1 errors occurred comparing output. status: exit status: 1 command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/home/martin/src/rust/build/x86_64-unknown-linux-gnu/stage1/bin/rustc" "/home/martin/src/rust/tests/ui/limits/issue-15919-64.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/home/martin/.cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/home/martin/src/rust/vendor" "--sysroot" "/home/martin/src/rust/build/x86_64-unknown-linux-gnu/stage1" "--target=x86_64-unknown-linux-gnu" "--cfg" "full_debuginfo" "--check-cfg" "cfg(test,FALSE,no_debuginfo,full_debuginfo)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "--out-dir" "/home/martin/src/rust/build/x86_64-unknown-linux-gnu/test/ui/limits/issue-15919-64.full-debuginfo" "-A" "unused" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Lnative=/home/martin/src/rust/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Cdebuginfo=2" stdout: none --- stderr ------------------------------- error: values of the type `[usize; usize::MAX]` are too big for the target architecture error: aborting due to 1 previous error ------------------------------------------ ---- [ui] tests/ui/limits/issue-15919-64.rs#full-debuginfo stdout end ---- ---- [ui] tests/ui/limits/huge-array-simple-64.rs#full-debuginfo stdout ---- Saved the actual stderr to `/home/martin/src/rust/build/x86_64-unknown-linux-gnu/test/ui/limits/huge-array-simple-64.full-debuginfo/huge-array-simple-64.full-debuginfo.stderr` diff of stderr: 1 error: values of the type `[u8; 2305843011361177600]` are too big for the target architecture - --> $DIR/huge-array-simple-64.rs:12:9 - | - LL | let _fat: [u8; (1<<61)+(1<<31)] = - | ^^^^ 6 7 error: aborting due to 1 previous error 8 The actual stderr differed from the expected stderr To update references, rerun the tests and pass the `--bless` flag To only update this specific test, also pass `--test-args limits/huge-array-simple-64.rs` error in revision `full-debuginfo`: 1 errors occurred comparing output. status: exit status: 1 command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/home/martin/src/rust/build/x86_64-unknown-linux-gnu/stage1/bin/rustc" "/home/martin/src/rust/tests/ui/limits/huge-array-simple-64.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/home/martin/.cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/home/martin/src/rust/vendor" "--sysroot" "/home/martin/src/rust/build/x86_64-unknown-linux-gnu/stage1" "--target=x86_64-unknown-linux-gnu" "--cfg" "full_debuginfo" "--check-cfg" "cfg(test,FALSE,no_debuginfo,full_debuginfo)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "--out-dir" "/home/martin/src/rust/build/x86_64-unknown-linux-gnu/test/ui/limits/huge-array-simple-64.full-debuginfo" "-A" "unused" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Lnative=/home/martin/src/rust/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Cdebuginfo=2" stdout: none --- stderr ------------------------------- error: values of the type `[u8; 2305843011361177600]` are too big for the target architecture error: aborting due to 1 previous error ------------------------------------------ ---- [ui] tests/ui/limits/huge-array-simple-64.rs#full-debuginfo stdout end ---- failures: [ui] tests/ui/limits/huge-array.rs#full-debuginfo [ui] tests/ui/limits/issue-15919-64.rs#full-debuginfo [ui] tests/ui/limits/huge-array-simple-64.rs#full-debuginfo test result: FAILED. 3 passed; 3 failed; 0 ignored; 0 measured; 19720 filtered out; finished in 117.18ms Some tests failed in compiletest suite=ui mode=ui host=x86_64-unknown-linux-gnu target=x86_64-unknown-linux-gnu Build completed unsuccessfully in 0:00:17 ``` </details> As can be seen, the span info is missing with debuginfo=2 without the fix.
2025-09-09Rollup merge of #145819 - jdonszelmann:convert-limits, r=fmeaseStuart Cook-209/+332
Port limit attributes to the new attribute parsing infrastructure Doesn't pass tests, to be rebased on https://github.com/rust-lang/rust/pull/145792 which will solve that r? `@fmease`