Skip to content

Give a message with a span on MIR validation error #144190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 20, 2025

Conversation

scottmcm
Copy link
Member

@scottmcm scottmcm commented Jul 19, 2025

It was handy to get a source+line link for #143833, even if it's just to the function and not necessarily to the statement.

r? mir

@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 Jul 19, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 19, 2025

The Miri subtree was changed

cc @rust-lang/miri

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@@ -1,11 +1,20 @@
error: internal compiler error: compiler/rustc_mir_transform/src/validate.rs:LL:CC: broken MIR in Item(DefId) (after phase change to runtime-optimized) at bb0[1]:
place (*(_2.0: *mut i32)) has deref as a later projection (it is only permitted as the first projection)
Copy link
Member

Choose a reason for hiding this comment

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

Odd that there are so many leading spaces now... 🤷

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that's because a \n in a bug message gets padded out to align vertically.

);
if self.tcx.dcx().has_errors().is_none() {
span_bug!(
self.body.span,
Copy link
Member

Choose a reason for hiding this comment

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

You could use the location to get a better span -- might be worth it?
Specifically, body.source_info(location).span.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's so much better, thank you. I wish I had it when I was looking through 80-line test functions :P

@scottmcm scottmcm force-pushed the spanned-errors-in-mir-validation branch from 12f12de to 15fe203 Compare July 19, 2025 21:09
@RalfJung
Copy link
Member

Thanks! Nice little papercut fixed. r? @RalfJung
r=me when CI is happy
(won't that Miri test need re-blessing with the more precise span?)

@rustbot rustbot assigned RalfJung and unassigned matthewjasper Jul 19, 2025
@scottmcm scottmcm force-pushed the spanned-errors-in-mir-validation branch from 15fe203 to 14d097f Compare July 19, 2025 21:14
@scottmcm
Copy link
Member Author

(won't that Miri test need re-blessing with the more precise span?)

Yup, 100%, just forgot it's ignore-windows so my run didn't notice.

@scottmcm
Copy link
Member Author

Ok, CI's happy other than the spellcheck that's failing everything.

@bors r=RalfJung (WARNING for rollups: will conflict with 143833)

@bors
Copy link
Collaborator

bors commented Jul 20, 2025

📌 Commit 14d097f has been approved by RalfJung

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 Jul 20, 2025
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 20, 2025
@RalfJung
Copy link
Member

RalfJung commented Jul 20, 2025 via email

@bors
Copy link
Collaborator

bors commented Jul 20, 2025

💡 This pull request was already approved, no need to approve it again.

@bors
Copy link
Collaborator

bors commented Jul 20, 2025

📌 Commit 14d097f has been approved by RalfJung

It is now in the queue for this repository.

@bors bors removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 20, 2025
@RalfJung
Copy link
Member

Apparently not :)

@scottmcm
Copy link
Member Author

Looks like doing that fixed the labels, at least :)

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jul 20, 2025
…idation, r=RalfJung

Give a message with a span on MIR validation error

It was handy to get a source+line link for rust-lang#143833, even if it's just to the function and not necessarily to the statement.

r? mir
bors added a commit that referenced this pull request Jul 20, 2025
Rollup of 9 pull requests

Successful merges:

 - #143282 (Add `uX::strict_sub_signed`)
 - #143423 (address clippy formatting nits)
 - #143720 (Allow `Rvalue::Repeat` to return true in `rvalue_creates_operand` too)
 - #144011 (bootstrap: Don't trigger an unnecessary LLVM build from check builds)
 - #144112 (bootstrap: Ignore `rust.debuginfo-level-tests` for codegen tests)
 - #144125 (Add new `ignore-backends` and `needs-backends` tests annotations)
 - #144143 (Fix `-Ctarget-feature`s getting ignored after `crt-static`)
 - #144150 (tests: assembly: cstring-merging: Disable GlobalMerge pass)
 - #144190 (Give a message with a span on MIR validation error)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit ae3708e into rust-lang:master Jul 20, 2025
21 of 22 checks passed
rust-timer added a commit that referenced this pull request Jul 20, 2025
Rollup merge of #144190 - scottmcm:spanned-errors-in-mir-validation, r=RalfJung

Give a message with a span on MIR validation error

It was handy to get a source+line link for #143833, even if it's just to the function and not necessarily to the statement.

r? mir
@rustbot rustbot added this to the 1.90.0 milestone Jul 20, 2025
@scottmcm scottmcm deleted the spanned-errors-in-mir-validation branch July 20, 2025 17:14
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Jul 21, 2025
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#143282 (Add `uX::strict_sub_signed`)
 - rust-lang/rust#143423 (address clippy formatting nits)
 - rust-lang/rust#143720 (Allow `Rvalue::Repeat` to return true in `rvalue_creates_operand` too)
 - rust-lang/rust#144011 (bootstrap: Don't trigger an unnecessary LLVM build from check builds)
 - rust-lang/rust#144112 (bootstrap: Ignore `rust.debuginfo-level-tests` for codegen tests)
 - rust-lang/rust#144125 (Add new `ignore-backends` and `needs-backends` tests annotations)
 - rust-lang/rust#144143 (Fix `-Ctarget-feature`s getting ignored after `crt-static`)
 - rust-lang/rust#144150 (tests: assembly: cstring-merging: Disable GlobalMerge pass)
 - rust-lang/rust#144190 (Give a message with a span on MIR validation error)

r? `@ghost`
`@rustbot` modify labels: rollup
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jul 21, 2025
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#143282 (Add `uX::strict_sub_signed`)
 - rust-lang/rust#143423 (address clippy formatting nits)
 - rust-lang/rust#143720 (Allow `Rvalue::Repeat` to return true in `rvalue_creates_operand` too)
 - rust-lang/rust#144011 (bootstrap: Don't trigger an unnecessary LLVM build from check builds)
 - rust-lang/rust#144112 (bootstrap: Ignore `rust.debuginfo-level-tests` for codegen tests)
 - rust-lang/rust#144125 (Add new `ignore-backends` and `needs-backends` tests annotations)
 - rust-lang/rust#144143 (Fix `-Ctarget-feature`s getting ignored after `crt-static`)
 - rust-lang/rust#144150 (tests: assembly: cstring-merging: Disable GlobalMerge pass)
 - rust-lang/rust#144190 (Give a message with a span on MIR validation error)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

6 participants