Skip to content

Conversation

matthiaskrgr
Copy link
Member

@matthiaskrgr matthiaskrgr commented Sep 9, 2025

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

jieyouxu and others added 15 commits August 18, 2025 21:57
To make it more obvious what it's testing.

This is its own commit to make git blame easier.
Actually, the accidentally accepted invalid suffixes also include tuple
struct indexing positions, struct numeral field name positions. So
before changing anything, first expand test coverage, so we can observe
the effect of bumping the non-lint pseudo-FCW warning into a hard error.
Reject invalid literal suffixes in tuple indexing, tuple struct indexing, and struct field name position

Tracking issue: rust-lang#60210
Closes rust-lang#60210

## Summary

Bump the ["suffixes on a tuple index are invalid" non-lint pseudo future-incompatibility warning (rust-lang#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 rust-lang#59418.
- We tried to hard reject all invalid suffixes in rust-lang#59421, but unfortunately it turns out there were proc macros accidentally relying on it: rust-lang#60138.
- We temporarily accepted `{i,u}{32,size}` in rust-lang#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#60186 as an ecosystem impact mitigation measure (cf. rust-lang#60138). Specifically, the following cases (particularly the construction of these forms in proc macros like reported in rust-lang#60138):

### Position 1: Invalid `{i,u}{32,size}` suffixes in tuple indexing

```rs
fn main() {
    let _x = (42,).0invalid; // Already error, already rejected by rust-lang#59421
    let _x = (42,).0i8;      // Already error, not one of the rust-lang#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 rust-lang#59421
    let _x = _x.0i8;      // Already error, not one of the rust-lang#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#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 (rust-lang#145463 (comment)).

- 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 AmlingPalantir/r4#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

- rust-lang/reference#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 rust-lang#60186 (comment).

[issue-60210]: rust-lang#60210
fix APITIT being treated as a normal generic parameter in suggestions

closes rust-lang#126395
Update getopts to remove unicode-width dependency

Pulls in rust-lang/getopts#133. This saves 1.5MB on the vendored size of the standard library.
…_const_stable_indirect, r=jieyouxu

triagebot: warn about #[rustc_intrinsic_const_stable_indirect]

Also make the warnings a bit more noticeable by adding a ⚠️.
…fJung

add approx_delta to all gamma tests

f32::gamma tests are less precise in CI, so we increase the tolerance for these tests. See [#miri > Miri test-libstd Failure (2025-09) @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/269128-miri/topic/Miri.20test-libstd.20Failure.20.282025-09.29/near/538138742)

r? `@RalfJung`
…ad-docs, r=lcnr

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
@rustbot rustbot added A-meta Area: Issues & PRs about the rust-lang/rust repository itself A-tidy Area: The tidy tool S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. rollup A PR which is a rollup labels Sep 9, 2025
@matthiaskrgr
Copy link
Member Author

@bors r+ rollup=never p=5

@bors
Copy link
Collaborator

bors commented Sep 9, 2025

📌 Commit a40ec4c has been approved by matthiaskrgr

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 9, 2025
@bors
Copy link
Collaborator

bors commented Sep 9, 2025

⌛ Testing commit a40ec4c with merge 7ad23f4...

@bors
Copy link
Collaborator

bors commented Sep 9, 2025

☀️ Test successful - checks-actions
Approved by: matthiaskrgr
Pushing 7ad23f4 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 9, 2025
@bors bors merged commit 7ad23f4 into rust-lang:master Sep 9, 2025
11 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Sep 9, 2025
@rust-timer
Copy link
Collaborator

📌 Perf builds for each rolled up PR:

PR# Message Perf Build Sha
#145463 Reject invalid literal suffixes in tuple indexing, tuple st… 3f95507920bd3f333bbf90d628b6ed9f6c0cc536 (link)
#145929 fix APITIT being treated as a normal generic parameter in s… b79f1784c29281d83c7e738a2f6e843bed29a23f (link)
#146001 Update getopts to remove unicode-width dependency dfff02dc460abbe5d47f29c0b0c83db18cc5e6f8 (link)
#146365 triagebot: warn about #[rustc_intrinsic_const_stable_indire… 9843200c12d4f20064c48d3e07e0a1d7aa320a2d (link)
#146366 add approx_delta to all gamma tests 6cfe2c7496d8cd5bea4a29dd8ae314cbbac9e032 (link)
#146373 fix comments about trait solver cycle heads 7141af8f7b12074ac690793a5461e46df7bc123f (link)

previous master: 364da5d88d

In the case of a perf regression, run the following command for each PR you suspect might be the cause: @rust-timer build $SHA

Copy link
Contributor

github-actions bot commented Sep 9, 2025

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 364da5d (parent) -> 7ad23f4 (this PR)

Test differences

Show 12 test diffs

Stage 1

  • [ui] tests/ui/parser/issues/issue-59418.rs: pass -> [missing] (J0)
  • [ui] tests/ui/parser/tuple-index-suffix-proc-macro.rs: [missing] -> pass (J0)
  • [ui] tests/ui/parser/tuple-index-suffix.rs: [missing] -> pass (J0)
  • [ui] tests/ui/suggestions/apitit-unimplemented-method.rs: [missing] -> pass (J0)

Stage 2

  • [ui] tests/ui/parser/issues/issue-59418.rs: pass -> [missing] (J1)
  • [ui] tests/ui/parser/tuple-index-suffix-proc-macro.rs: [missing] -> pass (J1)
  • [ui] tests/ui/parser/tuple-index-suffix.rs: [missing] -> pass (J1)
  • [ui] tests/ui/suggestions/apitit-unimplemented-method.rs: [missing] -> pass (J1)

Additionally, 4 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 7ad23f43a225546c095123de52cc07d8719f8e2b --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-aarch64-apple: 8344.1s -> 5412.8s (-35.1%)
  2. dist-x86_64-apple: 8367.5s -> 5633.1s (-32.7%)
  3. pr-check-1: 1776.8s -> 1363.6s (-23.3%)
  4. i686-gnu-2: 5420.7s -> 6391.7s (17.9%)
  5. armhf-gnu: 4822.9s -> 5354.9s (11.0%)
  6. dist-aarch64-msvc: 6400.3s -> 5736.1s (-10.4%)
  7. dist-various-1: 3789.9s -> 4147.4s (9.4%)
  8. x86_64-rust-for-linux: 2843.3s -> 2576.2s (-9.4%)
  9. x86_64-gnu-llvm-20-1: 3605.4s -> 3286.1s (-8.9%)
  10. i686-msvc-2: 8299.7s -> 7741.6s (-6.7%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (7ad23f4): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (secondary -3.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.8% [1.8%, 1.8%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-8.0% [-8.0%, -8.0%] 1
All ❌✅ (primary) - - 0

Cycles

Results (secondary 2.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.3% [2.3%, 2.3%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 468.052s -> 469.26s (0.26%)
Artifact size: 387.52 MiB -> 387.51 MiB (-0.00%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-meta Area: Issues & PRs about the rust-lang/rust repository itself A-tidy Area: The tidy tool merged-by-bors This PR was explicitly merged by bors. rollup A PR which is a rollup S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants