Skip to content

coverage: Add a test case for a previously-unknown span mismatch#152039

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Zalathar:context-mismatch
Feb 3, 2026
Merged

coverage: Add a test case for a previously-unknown span mismatch#152039
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Zalathar:context-mismatch

Conversation

@Zalathar
Copy link
Member

@Zalathar Zalathar commented Feb 3, 2026


In #145643, a defensive check was added to detect spans that unexpectedly don't match the context of the function body span. There was no known way to trigger that condition, so a debug_assert! was added to make violations easier to notice.

A way to trigger the condition using nested macro expansions was subsequently found and reported as an ICE (in debug-assertion builds) in #147339.

Now that we have a concrete example to investigate, we can remove the debug_assert! so that there is no ICE in debug-assertion builds.

r? chenyukang

@Zalathar Zalathar added the A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) label Feb 3, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 3, 2026

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 3, 2026
@Zalathar
Copy link
Member Author

Zalathar commented Feb 3, 2026

The main differences from #152036 are:

  • This PR deletes the debug_assert! without changing the surrounding condition, because it's still important for the contexts to actually match, and it's safe to defensively discard spans that don't match.
  • The new test is added as a coverage test instead of a UI test, because that makes testing and investigation easier.

"span context mismatch: body_span={body_span:?}, covspan.span={covspan_span:?}"
);
// FIXME(Zalathar): Investigate how and why this is triggered
// by `tests/coverage/macros/context-mismatch-issue-147339.rs`.
Copy link
Member

Choose a reason for hiding this comment

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

so do we need an issue to track it?

@chenyukang
Copy link
Member

@bors r=chenyukang

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 3, 2026

📌 Commit 0418f9a has been approved by chenyukang

It is now in the queue for this repository.

@rust-bors rust-bors bot 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 Feb 3, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 3, 2026
…ukang

coverage: Add a test case for a previously-unknown span mismatch

- This is a revised version of rust-lang#152036.
---

In rust-lang#145643, a defensive check was added to detect spans that unexpectedly don't match the context of the function body span. There was no known way to trigger that condition, so a `debug_assert!` was added to make violations easier to notice.

A way to trigger the condition using nested macro expansions was subsequently found and reported as an ICE (in debug-assertion builds) in rust-lang#147339.

Now that we have a concrete example to investigate, we can remove the `debug_assert!` so that there is no ICE in debug-assertion builds.

- Fixes rust-lang#147339.

r? chenyukang
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 3, 2026
…ukang

coverage: Add a test case for a previously-unknown span mismatch

- This is a revised version of rust-lang#152036.
---

In rust-lang#145643, a defensive check was added to detect spans that unexpectedly don't match the context of the function body span. There was no known way to trigger that condition, so a `debug_assert!` was added to make violations easier to notice.

A way to trigger the condition using nested macro expansions was subsequently found and reported as an ICE (in debug-assertion builds) in rust-lang#147339.

Now that we have a concrete example to investigate, we can remove the `debug_assert!` so that there is no ICE in debug-assertion builds.

- Fixes rust-lang#147339.

r? chenyukang
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 3, 2026
…ukang

coverage: Add a test case for a previously-unknown span mismatch

- This is a revised version of rust-lang#152036.
---

In rust-lang#145643, a defensive check was added to detect spans that unexpectedly don't match the context of the function body span. There was no known way to trigger that condition, so a `debug_assert!` was added to make violations easier to notice.

A way to trigger the condition using nested macro expansions was subsequently found and reported as an ICE (in debug-assertion builds) in rust-lang#147339.

Now that we have a concrete example to investigate, we can remove the `debug_assert!` so that there is no ICE in debug-assertion builds.

- Fixes rust-lang#147339.

r? chenyukang
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 3, 2026
…ukang

coverage: Add a test case for a previously-unknown span mismatch

- This is a revised version of rust-lang#152036.
---

In rust-lang#145643, a defensive check was added to detect spans that unexpectedly don't match the context of the function body span. There was no known way to trigger that condition, so a `debug_assert!` was added to make violations easier to notice.

A way to trigger the condition using nested macro expansions was subsequently found and reported as an ICE (in debug-assertion builds) in rust-lang#147339.

Now that we have a concrete example to investigate, we can remove the `debug_assert!` so that there is no ICE in debug-assertion builds.

- Fixes rust-lang#147339.

r? chenyukang
rust-bors bot pushed a commit that referenced this pull request Feb 3, 2026
…uwer

Rollup of 13 pull requests

Successful merges:

 - #152034 (Show largest job duration changes in hours and minutes in the post-merge report)
 - #152039 (coverage: Add a test case for a previously-unknown span mismatch)
 - #152045 (Convert to inline diagnostics in `rustc_infer`)
 - #149263 (Forbid manual `Unpin` impls for structurally pinned types)
 - #151754 (Check proj's parent is trait or not when checking dyn compatibility)
 - #151848 (Port `rustc_mir` to attribute parser)
 - #151874 (error on unsized AnonConsts)
 - #151944 (Convert to inline diagnostics in `rustc_attr_parsing`)
 - #152012 (Use `DEVELOPER_DIR` instead of a custom `xcode-select` script)
 - #152019 (`NativeLib` cleanups)
 - #152029 (disable socket tests in Miri)
 - #152041 (Convert to inline diagnostics in `rustc_query_system`)
 - #152050 (Try to fix `rustdoc-gui/globals.goml` flakyness)

Failed merges:

 - #152046 (Use glob imports for attribute parsers)
rust-bors bot pushed a commit that referenced this pull request Feb 3, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - #152034 (Show largest job duration changes in hours and minutes in the post-merge report)
 - #152039 (coverage: Add a test case for a previously-unknown span mismatch)
 - #152045 (Convert to inline diagnostics in `rustc_infer`)
 - #149263 (Forbid manual `Unpin` impls for structurally pinned types)
 - #151754 (Check proj's parent is trait or not when checking dyn compatibility)
 - #151848 (Port `rustc_mir` to attribute parser)
 - #151874 (error on unsized AnonConsts)
 - #151944 (Convert to inline diagnostics in `rustc_attr_parsing`)
 - #152019 (`NativeLib` cleanups)
 - #152029 (disable socket tests in Miri)
 - #152041 (Convert to inline diagnostics in `rustc_query_system`)
 - #152050 (Try to fix `rustdoc-gui/globals.goml` flakyness)

Failed merges:

 - #152046 (Use glob imports for attribute parsers)
rust-bors bot pushed a commit that referenced this pull request Feb 3, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - #152034 (Show largest job duration changes in hours and minutes in the post-merge report)
 - #152039 (coverage: Add a test case for a previously-unknown span mismatch)
 - #152045 (Convert to inline diagnostics in `rustc_infer`)
 - #149263 (Forbid manual `Unpin` impls for structurally pinned types)
 - #151754 (Check proj's parent is trait or not when checking dyn compatibility)
 - #151848 (Port `rustc_mir` to attribute parser)
 - #151874 (error on unsized AnonConsts)
 - #151944 (Convert to inline diagnostics in `rustc_attr_parsing`)
 - #152019 (`NativeLib` cleanups)
 - #152029 (disable socket tests in Miri)
 - #152041 (Convert to inline diagnostics in `rustc_query_system`)
 - #152050 (Try to fix `rustdoc-gui/globals.goml` flakyness)

Failed merges:

 - #152046 (Use glob imports for attribute parsers)
@rust-bors rust-bors bot merged commit 4609007 into rust-lang:main Feb 3, 2026
11 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Feb 3, 2026
@Zalathar Zalathar deleted the context-mismatch branch February 3, 2026 22:21
rust-timer added a commit that referenced this pull request Feb 3, 2026
Rollup merge of #152039 - Zalathar:context-mismatch, r=chenyukang

coverage: Add a test case for a previously-unknown span mismatch

- This is a revised version of #152036.
---

In #145643, a defensive check was added to detect spans that unexpectedly don't match the context of the function body span. There was no known way to trigger that condition, so a `debug_assert!` was added to make violations easier to notice.

A way to trigger the condition using nested macro expansions was subsequently found and reported as an ICE (in debug-assertion builds) in #147339.

Now that we have a concrete example to investigate, we can remove the `debug_assert!` so that there is no ICE in debug-assertion builds.

- Fixes #147339.

r? chenyukang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

ICE: span context mismatch

3 participants