Skip to content
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

Improve CTFE UB validation error messages #86275

Merged
merged 4 commits into from
Jun 14, 2021
Merged

Conversation

lqd
Copy link
Member

@lqd lqd commented Jun 13, 2021

As mentioned in #86245 (comment) this PR slightly improves the formatting of validation errors, to move the path to the error prefix.

From:
type validation failed: encountered invalid vtable: size is bigger than largest supported object at .0

To:
type validation failed at .0: encountered invalid vtable: size is bigger than largest supported object.

@lqd
Copy link
Member Author

lqd commented Jun 13, 2021

r? @RalfJung cc @oli-obk

@@ -26,23 +26,27 @@ use super::{

macro_rules! throw_validation_failure {
($where:expr, { $( $what_fmt:expr ),+ } $( expected { $( $expected_fmt:expr ),+ } )?) => {{
let msg = rustc_middle::ty::print::with_no_trimmed_paths(|| {
let (path, msg) = rustc_middle::ty::print::with_no_trimmed_paths(|| {
Copy link
Member

Choose a reason for hiding this comment

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

Why a single big let for both of them, and not two separate lets?

Copy link
Member Author

Choose a reason for hiding this comment

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

it was just not to have two separate rustc_middle::ty::print::with_no_trimmed_path calls: I'm unsure whether the non-path expressions actually required being wrapped by it when they are serialized into strings (and was unsure of the costs), and so found it safer to not change this macro too much.

I can try changing this to have 2 lets but a single with_no_trimmed_path() call for the actual path, and see whether it changes the test output. Or have 2 lets and 2 calls. Let me know what you prefer and I'll do it.

Copy link
Member

Choose a reason for hiding this comment

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

The msg part should not need that with_no_trimmed_paths thing, so maybe try two lets with just the path part having with_no_trimmed_paths and then the test suite will tell us if that works or not.

Copy link
Member Author

Choose a reason for hiding this comment

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

alright, I'll try that tonight, thanks for the review !

Copy link
Member Author

Choose a reason for hiding this comment

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

The ui test suite seems to agree that the msg doesn't need anything related to path trimming, so I've pushed a separate commit (to help with review) to address this point.

@RalfJung
Copy link
Member

Thanks, this looks great. :)
r=me once CI is green.
@bors delegate+

@bors
Copy link
Contributor

bors commented Jun 14, 2021

✌️ @lqd can now approve this pull request

@lqd
Copy link
Member Author

lqd commented Jun 14, 2021

thanks I already have bors rights ^^

I'll monitor CI and get this landed :)

@RalfJung
Copy link
Member

thanks I already have bors rights ^^

Nice. :) I cannot remember who does so I usually err on the side of delegating. ;)

@lqd
Copy link
Member Author

lqd commented Jun 14, 2021

@bors r=RalfJung

@bors
Copy link
Contributor

bors commented Jun 14, 2021

📌 Commit 5af1c72 has been approved by RalfJung

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jun 14, 2021
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Jun 14, 2021
Improve CTFE UB validation error messages

As mentioned in rust-lang#86245 (comment) this PR slightly improves the formatting of validation errors, to move the path to the error prefix.

From:
`type validation failed: encountered invalid vtable: size is bigger than largest supported object at .0`

To:
`type validation failed at .0: encountered invalid vtable: size is bigger than largest supported object`.
@bors
Copy link
Contributor

bors commented Jun 14, 2021

⌛ Testing commit 5af1c72 with merge 539d7bd...

@bors
Copy link
Contributor

bors commented Jun 14, 2021

☀️ Test successful - checks-actions
Approved by: RalfJung
Pushing 539d7bd to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 14, 2021
@bors bors merged commit 539d7bd into rust-lang:master Jun 14, 2021
@rustbot rustbot added this to the 1.55.0 milestone Jun 14, 2021
@rust-highfive
Copy link
Collaborator

📣 Toolstate changed by #86275!

Tested on commit 539d7bd.
Direct link to PR: #86275

💔 miri on windows: test-pass → test-fail (cc @eddyb @RalfJung @oli-obk).
💔 miri on linux: test-pass → test-fail (cc @eddyb @RalfJung @oli-obk).

rust-highfive added a commit to rust-lang-nursery/rust-toolstate that referenced this pull request Jun 14, 2021
Tested on commit rust-lang/rust@539d7bd.
Direct link to PR: <rust-lang/rust#86275>

💔 miri on windows: test-pass → test-fail (cc @eddyb @RalfJung @oli-obk).
💔 miri on linux: test-pass → test-fail (cc @eddyb @RalfJung @oli-obk).
@lqd lqd deleted the ctfe-validation branch June 15, 2021 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants