Skip to content

Conversation

jdonszelmann
Copy link
Contributor

@jdonszelmann jdonszelmann commented Oct 18, 2025

r? @ghost

introduces a new compiletest directive: //@ rustfix-dont-test-fixed which is needed because I want to run rustfix, making sure rustfix doesn't crash, but then I don't expect the fixed code to compile since the suggestion was omitted and nothing was fixed.

@rustbot
Copy link
Collaborator

rustbot commented Oct 18, 2025

rustc_errors::emitter was changed

cc @Muscraft

Some changes occurred in src/tools/compiletest

cc @jieyouxu

@rustbot rustbot added A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc 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. labels Oct 18, 2025
@jdonszelmann
Copy link
Contributor Author

related MCP: rust-lang/compiler-team#929


#[proc_macro_attribute]
pub fn all_spans_same(_: TokenStream, ts: TokenStream) -> TokenStream {
spans_callsite(ts)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

recursively set all spans in the output to the callsite

@rust-log-analyzer

This comment has been minimized.


#[all_spans_same::all_spans_same]
//~^ ERROR wrong meta list delimiters
#[allow{}]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

crashes, because we suggest changing {} to () but the suggestion consists of two parts ( and ) with both the same span

.substitutions
.iter()
.filter_map(|substitution| {
let mut parts = substitution.parts.clone();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skip outputting suggestions with overlapping spans to JSON, same check as in lib.rs

// handed approach to avoid ICEs by ignoring the suggestion outright.
let invalid = subst.parts.iter().any(|item| sm.is_valid_span(item.span).is_err());
if invalid {
num_omitted.update(|i| i + 1);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some suggestions were already silently dropped, change this to count them

if substitution
.parts
.array_windows()
.find(|[a, b]| a.span.overlaps(b.span))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of failing an assertion, count how many times this happens and show this to the user

@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-20-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
test [crashes] tests/crashes/118038.rs ... ok
test [crashes] tests/crashes/118244.rs ... ok
test [crashes] tests/crashes/118603.rs ... ok
test [crashes] tests/crashes/118778.rs ... ok
2025-10-18T16:02:54.425429Z ERROR compiletest::runtest: fatal error, panic: "crashtest no longer crashes/triggers ICE, hooray! Please give it a meaningful name, add a doc-comment to the start of the test explaining why it exists and move it to tests/ui or wherever you see fit. Adding 'Fixes #<issueNr>' to your PR description ensures that the corresponding ticket is auto-closed upon merge. If you want to see verbose output, set `COMPILETEST_VERBOSE_CRASHES=1`."
test [crashes] tests/crashes/118784.rs ... FAILED
test [crashes] tests/crashes/118952-2.rs ... ok
test [crashes] tests/crashes/118952.rs ... ok
test [crashes] tests/crashes/119095.rs ... ok
test [crashes] tests/crashes/119729.rs ... ok
---
test [crashes] tests/crashes/123629.rs ... ok
test [crashes] tests/crashes/123690.rs ... ok
test [crashes] tests/crashes/123157.rs ... ok
test [crashes] tests/crashes/123810.rs ... ok
2025-10-18T16:02:55.179622Z ERROR compiletest::runtest: fatal error, panic: "crashtest no longer crashes/triggers ICE, hooray! Please give it a meaningful name, add a doc-comment to the start of the test explaining why it exists and move it to tests/ui or wherever you see fit. Adding 'Fixes #<issueNr>' to your PR description ensures that the corresponding ticket is auto-closed upon merge. If you want to see verbose output, set `COMPILETEST_VERBOSE_CRASHES=1`."
test [crashes] tests/crashes/123862.rs ... FAILED
test [crashes] tests/crashes/123959.rs ... ok
test [crashes] tests/crashes/123887.rs ... ok
test [crashes] tests/crashes/124189.rs ... ok
test [crashes] tests/crashes/124340.rs ... ok
---
test [crashes] tests/crashes/129209.rs ... ok
test [crashes] tests/crashes/129556.rs ... ok
test [crashes] tests/crashes/125323.rs ... ok
test [crashes] tests/crashes/130346.rs ... ok
2025-10-18T16:02:56.208296Z ERROR compiletest::runtest: fatal error, panic: "crashtest no longer crashes/triggers ICE, hooray! Please give it a meaningful name, add a doc-comment to the start of the test explaining why it exists and move it to tests/ui or wherever you see fit. Adding 'Fixes #<issueNr>' to your PR description ensures that the corresponding ticket is auto-closed upon merge. If you want to see verbose output, set `COMPILETEST_VERBOSE_CRASHES=1`."
test [crashes] tests/crashes/130395.rs ... FAILED
test [crashes] tests/crashes/130104.rs ... ok
test [crashes] tests/crashes/130411.rs ... ok
test [crashes] tests/crashes/130797.rs ... ok
test [crashes] tests/crashes/130310.rs ... ok
---

---- [crashes] tests/crashes/118784.rs stdout ----
------rustc stdout------------------------------

------rustc stderr------------------------------
error: unexpected token: `expr` metavariable
##[error]  --> /checkout/tests/crashes/118784.rs:10:23
   |
10 |             is_sync(x.$iter());
   |                       ^^^^^
...
18 |     all_sync_send!(HashMap, HashMap);
   |     -------------------------------- in this macro invocation
   |
   = note: this error originates in the macro `all_sync_send` (in Nightly builds, run with -Z macro-backtrace for more info)

error: expected one of `)`, `,`, `.`, `?`, or an operator, found `expr` metavariable
##[error]  --> /checkout/tests/crashes/118784.rs:10:23
   |
10 |             is_sync(x.$iter());
   |                       -^^^^
   |                       |
   |                       expected one of `)`, `,`, `.`, `?`, or an operator
   |                       help: missing `,`
...
18 |     all_sync_send!(HashMap, HashMap);
   |     -------------------------------- in this macro invocation
   |
   = note: this error originates in the macro `all_sync_send` (in Nightly builds, run with -Z macro-backtrace for more info)

error: unexpected token: `expr` metavariable
##[error]  --> /checkout/tests/crashes/118784.rs:12:23
   |
12 |             is_send(y.$iter());
   |                       ^^^^^
...
18 |     all_sync_send!(HashMap, HashMap);
   |     -------------------------------- in this macro invocation
   |
   = note: this error originates in the macro `all_sync_send` (in Nightly builds, run with -Z macro-backtrace for more info)

error: expected one of `)`, `,`, `.`, `?`, or an operator, found `expr` metavariable
##[error]  --> /checkout/tests/crashes/118784.rs:12:23
   |
12 |             is_send(y.$iter());
   |                       -^^^^
   |                       |
   |                       expected one of `)`, `,`, `.`, `?`, or an operator
   |                       help: missing `,`
...
18 |     all_sync_send!(HashMap, HashMap);
   |     -------------------------------- in this macro invocation
   |
   = note: this error originates in the macro `all_sync_send` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0423]: expected value, found struct `HashMap`
##[error]  --> /checkout/tests/crashes/118784.rs:18:20
   |
18 |     all_sync_send!(HashMap, HashMap);
   |                    ^^^^^^^
   |
  --> /rustc/FAKE_PREFIX/library/std/src/collections/hash/map.rs:246:1
   |
   = note: `HashMap` defined here

error[E0423]: expected function, tuple struct or tuple variant, found struct `HashMap`
##[error]  --> /checkout/tests/crashes/118784.rs:12:23
   |
12 |             is_send(y.$iter());
   |                       ^^^^^^^
...
18 |     all_sync_send!(HashMap, HashMap);
   |     -------------------------------- in this macro invocation
   |
  --> /rustc/FAKE_PREFIX/library/std/src/collections/hash/map.rs:246:1
   |
   = note: `HashMap` defined here
   |
   = note: this error originates in the macro `all_sync_send` (in Nightly builds, run with -Z macro-backtrace for more info)
help: you might have meant to use an associated function to build this type
   |
12 -             is_send(y.$iter());
13 -         )+
14 -     })
15 - }
16 - 
17 - fn main() {
18 -     all_sync_send!(HashMap, HashMap);
12 +             is_send(y.$iter()::new());
   |
12 -             is_send(y.$iter());
13 -         )+
14 -     })
15 - }
16 - 
17 - fn main() {
18 -     all_sync_send!(HashMap, HashMap);
12 +             is_send(y.$iter()::with_capacity(_));
   |
12 -             is_send(y.$iter());
13 -         )+
14 -     })
15 - }
16 - 
17 - fn main() {
18 -     all_sync_send!(HashMap, HashMap);
12 +             is_send(y.$iter()::with_hasher(_));
   |
12 -             is_send(y.$iter());
13 -         )+
14 -     })
15 - }
16 - 
17 - fn main() {
18 -     all_sync_send!(HashMap, HashMap);
12 +             is_send(y.$iter()::with_capacity_and_hasher(_, _));
   |
rendering error: omitted 1 suggestion that failed to render, likely because of macro expansions

error[E0425]: cannot find function `is_sync` in this scope
##[error]  --> /checkout/tests/crashes/118784.rs:10:13
   |
10 |             is_sync(x.$iter());
   |             ^^^^^^^ not found in this scope
...
18 |     all_sync_send!(HashMap, HashMap);
   |     -------------------------------- in this macro invocation
   |
   = note: this error originates in the macro `all_sync_send` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `is_send` in this scope
##[error]  --> /checkout/tests/crashes/118784.rs:12:13
   |
12 |             is_send(y.$iter());
   |             ^^^^^^^ not found in this scope
...
18 |     all_sync_send!(HashMap, HashMap);
   |     -------------------------------- in this macro invocation
   |
   = note: this error originates in the macro `all_sync_send` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 8 previous errors

Some errors have detailed explanations: E0423, E0425.
For more information about an error, try `rustc --explain E0423`.

------------------------------------------

error: crashtest no longer crashes/triggers ICE, hooray! Please give it a meaningful name, add a doc-comment to the start of the test explaining why it exists and move it to tests/ui or wherever you see fit. Adding 'Fixes #<issueNr>' to your PR description ensures that the corresponding ticket is auto-closed upon merge. If you want to see verbose output, set `COMPILETEST_VERBOSE_CRASHES=1`.

thread '[crashes] tests/crashes/118784.rs' panicked at src/tools/compiletest/src/runtest/crashes.rs:17:18:
fatal error
stack backtrace:
   5: __rustc::rust_begin_unwind
---
---- [crashes] tests/crashes/118784.rs stdout end ----
---- [crashes] tests/crashes/123862.rs stdout ----
------rustc stdout------------------------------

------rustc stderr------------------------------
error: attempted to repeat an expression containing no syntax variables matched as repeating at this depth
##[error] --> /checkout/tests/crashes/123862.rs:6:17
  |
6 |         (file![$($pos,)* pos!()], line!())
  |                 ^^^^^^^

error[E0425]: cannot find value `main_pos` in this scope
##[error]  --> /checkout/tests/crashes/123862.rs:11:19
   |
11 |     inner_inlined(main_pos, pos!());
   |                   ^^^^^^^^ not found in this scope

error[E0601]: `main` function not found in crate `123862`
##[error]  --> /checkout/tests/crashes/123862.rs:14:22
   |
---
##[error]  --> /checkout/tests/crashes/123862.rs:11:5
   |
 5 |       () => {
   |  ___________-
 6 | |         (file![$($pos,)* pos!()], line!())
 7 | |     };
   | |_____- unexpected argument #2
...
11 |       inner_inlined(main_pos, pos!());
   |       ^^^^^^^^^^^^^ -------- unexpected argument #1
   |
note: function defined here
  --> /checkout/tests/crashes/123862.rs:14:4
   |
14 | fn inner_inlined() {}
---
For more information about an error, try `rustc --explain E0061`.

------------------------------------------

error: crashtest no longer crashes/triggers ICE, hooray! Please give it a meaningful name, add a doc-comment to the start of the test explaining why it exists and move it to tests/ui or wherever you see fit. Adding 'Fixes #<issueNr>' to your PR description ensures that the corresponding ticket is auto-closed upon merge. If you want to see verbose output, set `COMPILETEST_VERBOSE_CRASHES=1`.

thread '[crashes] tests/crashes/123862.rs' panicked at src/tools/compiletest/src/runtest/crashes.rs:17:18:
fatal error
stack backtrace:
   5: __rustc::rust_begin_unwind
---
---- [crashes] tests/crashes/123862.rs stdout end ----
---- [crashes] tests/crashes/130395.rs stdout ----
------rustc stdout------------------------------

------rustc stderr------------------------------
error[E0433]: failed to resolve: use of undeclared type `T`
##[error] --> /checkout/tests/crashes/130395.rs:9:13
  |
9 |     let x = T::A(U::C);
  |             ^
  |             |
  |             use of undeclared type `T`
  |             help: an enum with a similar name exists: `U`

error[E0599]: no variant or associated item named `C` found for enum `U` in the current scope
##[error] --> /checkout/tests/crashes/130395.rs:9:21
  |
4 | enum U {
  | ------ variant or associated item `C` not found for this enum
...
9 |     let x = T::A(U::C);
  |                     ^ variant or associated item not found in `U`
  |
rendering error: omitted 1 suggestion that failed to render, likely because of macro expansions

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0433, E0599.
For more information about an error, try `rustc --explain E0433`.

------------------------------------------

error: crashtest no longer crashes/triggers ICE, hooray! Please give it a meaningful name, add a doc-comment to the start of the test explaining why it exists and move it to tests/ui or wherever you see fit. Adding 'Fixes #<issueNr>' to your PR description ensures that the corresponding ticket is auto-closed upon merge. If you want to see verbose output, set `COMPILETEST_VERBOSE_CRASHES=1`.

thread '[crashes] tests/crashes/130395.rs' panicked at src/tools/compiletest/src/runtest/crashes.rs:17:18:
fatal error
stack backtrace:
   5: __rustc::rust_begin_unwind

@jieyouxu jieyouxu self-assigned this Oct 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants