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

This comment has been minimized.

@jieyouxu jieyouxu self-assigned this Oct 18, 2025
@@ -259,6 +259,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"run-pass",
"run-rustfix",
"rustc-env",
"rustfix-dont-test-fixed",
Copy link
Member

@jieyouxu jieyouxu Oct 19, 2025

Choose a reason for hiding this comment

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

Suggestion: if we do go with this, can you please describe this new directive in src/doc/rustc-dev-guide, and also in the UI test chapter perhaps add a little remark on what this intended to be used for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absolutely

@jieyouxu jieyouxu removed their assignment Oct 20, 2025
@bors
Copy link
Collaborator

bors commented Oct 20, 2025

☔ The latest upstream changes (presumably #147913) made this pull request unmergeable. Please resolve the merge conflicts.

bors added a commit that referenced this pull request Oct 24, 2025
Revert "fix: Filter suggestion parts that match existing code"

As requested by `@wesleywiser` in #147973 (comment) this is a revert of #146121 due to the handful of diagnostics ICEs that have been since reported, and found in the beta crater run.

This should thus also be backported to beta so the ICEs don't make it to next week's stable.

Works around (after backport)
- #146261
- #146706
- #146834 but I didn't add a test for this allowed-by-default lint
- as well as the crater run regressions from #147973 of which I only added the MCVE as a test.

The proper fix would likely be #147849 but it's still currently at the MCP stage. In the meantime, this PR would still emit the same overlapping suggestions, but still use a debug-assert...

r? `@wesleywiser`
bors added a commit that referenced this pull request Oct 24, 2025
Revert "fix: Filter suggestion parts that match existing code"

As requested by `@wesleywiser` in #147973 (comment) this is a revert of #146121 due to the handful of diagnostics ICEs that have been since reported, and found in the beta crater run.

This should thus also be backported to beta so the ICEs don't make it to next week's stable.

Works around (after backport)
- #146261
- #146706
- #146834 but I didn't add a test for this allowed-by-default lint
- as well as the crater run regressions from #147973 of which I only added the MCVE as a test.

The proper fix would likely be #147849 but it's still currently at the MCP stage. In the meantime, this PR would still emit the same overlapping suggestions, but still use a debug-assert...

r? `@wesleywiser`
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Oct 27, 2025
Revert "fix: Filter suggestion parts that match existing code"

As requested by `@wesleywiser` in rust-lang/rust#147973 (comment) this is a revert of rust-lang/rust#146121 due to the handful of diagnostics ICEs that have been since reported, and found in the beta crater run.

This should thus also be backported to beta so the ICEs don't make it to next week's stable.

Works around (after backport)
- rust-lang/rust#146261
- rust-lang/rust#146706
- rust-lang/rust#146834 but I didn't add a test for this allowed-by-default lint
- as well as the crater run regressions from rust-lang/rust#147973 of which I only added the MCVE as a test.

The proper fix would likely be rust-lang/rust#147849 but it's still currently at the MCP stage. In the meantime, this PR would still emit the same overlapping suggestions, but still use a debug-assert...

r? `@wesleywiser`
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-gcc 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/131406.rs ... ok
test [crashes] tests/crashes/131373.rs ... ok
test [crashes] tests/crashes/131295.rs ... ok
test [crashes] tests/crashes/131534.rs ... ok
2025-10-28T15:56:36.236679Z 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/131762.rs ... FAILED
test [crashes] tests/crashes/131886.rs ... ok
test [crashes] tests/crashes/131787.rs ... ok
test [crashes] tests/crashes/132126.rs ... ok
test [crashes] tests/crashes/132960.rs ... ok
---

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

------rustc stderr------------------------------
error[E0061]: this struct takes 1 argument but 3 arguments were supplied
##[error] --> /checkout/tests/crashes/131762.rs:8:63
  |
8 | ...) >= FloatWrapper(size_of::<u8>, size_of::<u16>, size_of::<usize> as fn() -> usize)))
  |         ^^^^^^^^^^^^                --------------  --------------------------------- unexpected argument #3 of type `fn() -> usize`
  |                                     |
  |                                     unexpected argument #2 of type `fn() -> usize {std::mem::size_of::<u16>}`
  |
note: expected `f64`, found fn item
 --> /checkout/tests/crashes/131762.rs:8:5
  |
8 |     assert!((0.0 / 0.0 >= 0.0) == (FloatWrapper(0.0 / 0.0) >= FloatWrapper(size_of::<u8>, size_of::<u16>, size_of::<usize> as fn() -> usize)))
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  = note: expected type `f64`
          found fn item `fn() -> usize {std::mem::size_of::<u8>}`
note: tuple struct defined here
 --> /checkout/tests/crashes/131762.rs:5:8
  |
5 | struct FloatWrapper(f64);
  |        ^^^^^^^^^^^^
rendering error: omitted 1 suggestion that failed to render, likely because of macro expansions

error[E0369]: binary operation `>=` cannot be applied to type `FloatWrapper`
##[error] --> /checkout/tests/crashes/131762.rs:8:60
  |
8 | ....0) == (FloatWrapper(0.0 / 0.0) >= FloatWrapper(size_of::<u8>, size_of::<u16>, size_of::<usize> as fn() -> usize)))
  |            ----------------------- ^^ ------------------------------------------------------------------------------ FloatWrapper
  |            |
  |            FloatWrapper
  |
note: an implementation of `PartialOrd` might be missing for `FloatWrapper`
 --> /checkout/tests/crashes/131762.rs:5:1
  |
5 | struct FloatWrapper(f64);
  | ^^^^^^^^^^^^^^^^^^^ must implement `PartialOrd`
help: consider annotating `FloatWrapper` with `#[derive(PartialEq, PartialOrd)]`
  |
5 + #[derive(PartialEq, PartialOrd)]
6 | struct FloatWrapper(f64);
  |

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0061, E0369.
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/131762.rs' panicked at src/tools/compiletest/src/runtest/crashes.rs:17:18:
fatal error
stack backtrace:
   5: __rustc::rust_begin_unwind

For more information how to resolve CI failures of this job, visit this link.

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.

5 participants