Skip to content

[ui tests]: Normalize away THIR end span for output stability#151693

Closed
jyn514 wants to merge 1 commit intorust-lang:mainfrom
ferrocene:jyn/normalize-offset_of-span
Closed

[ui tests]: Normalize away THIR end span for output stability#151693
jyn514 wants to merge 1 commit intorust-lang:mainfrom
ferrocene:jyn/normalize-offset_of-span

Conversation

@jyn514
Copy link
Member

@jyn514 jyn514 commented Jan 26, 2026

Spans for the offset_of! builtin macro point into an arbitrary place in core::mem. This means that the test has to be re-blessed whenever core/src/mem/mod.rs line numbers change.

Ideally, Span printing would be smarter and wouldn't show an end span if it came from a different crate than the start span (or maybe truncated the span to the last place in the start's crate). But that's a more involved fix and this avoids the immediate problem.

For transparency: This PR is mostly to make Ferrocene's CI break less often. But I expect it to also be useful upstream.

Spans for the `offset_of!` builtin macro point into an arbitrary place
in `core::mem`. This means that the test has to be re-blessed whenever
`core/src/mem/mod.rs` line numbers change.

Ideally, Span printing would be smarter and wouldn't show an end span if
it came from a different crate than the start span (or maybe truncated
the span to the last place in the start's crate). But that's a more
involved fix and this avoids the immediate problem.
@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 Jan 26, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 26, 2026

r? @madsmtm

rustbot has assigned @madsmtm.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

rust-bors bot pushed a commit that referenced this pull request Feb 8, 2026
Avoid a bogus THIR span for `let x = offset_of!(..)`

The code that creates spans for THIR `let` statements was doing span endpoint manipulation without checking for inclusion/context, resulting in bogus spans observed in #151693.

The incorrect spans are easiest to observe with `-Zunpretty=thir-tree`, but they also cause strange user-facing diagnostics for irrefutable let-else.
Zalathar added a commit to Zalathar/rust that referenced this pull request Feb 8, 2026
…cote

Avoid a bogus THIR span for `let x = offset_of!(..)`

The code that creates spans for THIR `let` statements was doing span endpoint manipulation without checking for inclusion/context, resulting in bogus spans observed in rust-lang#151693.

The incorrect spans are easiest to observe with `-Zunpretty=thir-tree`, but they also cause strange user-facing diagnostics for irrefutable let-else.
rust-timer added a commit that referenced this pull request Feb 8, 2026
Rollup merge of #152284 - Zalathar:bogus-thir-let, r=nnethercote

Avoid a bogus THIR span for `let x = offset_of!(..)`

The code that creates spans for THIR `let` statements was doing span endpoint manipulation without checking for inclusion/context, resulting in bogus spans observed in #151693.

The incorrect spans are easiest to observe with `-Zunpretty=thir-tree`, but they also cause strange user-facing diagnostics for irrefutable let-else.
@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 8, 2026

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

@jyn514
Copy link
Member Author

jyn514 commented Feb 8, 2026

fixed more thoroughly in #152284

@jyn514 jyn514 closed this Feb 8, 2026
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 8, 2026
@tshepang tshepang deleted the jyn/normalize-offset_of-span branch February 8, 2026 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

3 participants

Comments