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

const validation: point at where we found a pointer but expected an integer #114372

Merged
merged 1 commit into from
Aug 3, 2023

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented Aug 2, 2023

Instead of validation just printing "unable to turn pointer into bytes", make this a regular validation error that says where in the value the bad pointer was found. Also distinguish "expected integer, got pointer" from "expected pointer, got partial pointer or mix of pointers".

To avoid duplicating things too much I refactored the diagnostics for validity a bit, so that "got uninit, expected X" and "got pointer, expected X" can share the "X" part. Also all the errors emitted for validation are now grouped under const_eval_validation so that they are in a single group in the ftl file.

r? @oli-obk

@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 Aug 2, 2023
@rustbot
Copy link
Collaborator

rustbot commented Aug 2, 2023

Some changes occurred to the CTFE / Miri engine

cc @rust-lang/miri

Some changes occurred to the CTFE / Miri engine

cc @rust-lang/miri

The Miri subtree was changed

cc @rust-lang/miri

@rust-log-analyzer

This comment has been minimized.

@RalfJung RalfJung force-pushed the const-pointer-as-int branch from 180fdd3 to 3b87fa6 Compare August 2, 2023 14:47

use std::mem;
struct MyStr(str);
const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) };
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 deleted this test since this exact const is also tested in "raw-bytes", in a test case called MYSTR_NO_INIT_ISSUE83182.

1u8,
MaybeUninit { uninit: () }.init,
//~^ ERROR evaluation of constant value failed
//~| uninitialized
Copy link
Member Author

Choose a reason for hiding this comment

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

At some point these got changed to longer test what they were actually meant to test: reporting the right index in the error message. So I changed the test to fix that again.

@bors
Copy link
Contributor

bors commented Aug 2, 2023

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

@RalfJung RalfJung force-pushed the const-pointer-as-int branch from 3b87fa6 to 7767cbb Compare August 2, 2023 16:52
@oli-obk
Copy link
Contributor

oli-obk commented Aug 3, 2023

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Aug 3, 2023

📌 Commit 7767cbb has been approved by oli-obk

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 Aug 3, 2023
@bors
Copy link
Contributor

bors commented Aug 3, 2023

⌛ Testing commit 7767cbb with merge 5867b0dee32588e906201478181562b7dd81ebdb...

@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Attempting with retry: docker build --rm -t rust-ci -f /home/runner/work/rust/rust/src/ci/docker/host-x86_64/dist-powerpc-linux/Dockerfile /home/runner/work/rust/rust/src/ci/docker
Sending build context to Docker daemon  430.1kB

Step 1/18 : FROM ubuntu:22.04
error parsing HTTP 429 response body: invalid character 'T' looking for beginning of value: "Too Many Requests (HAP429).\n"
Sending build context to Docker daemon  430.1kB

Step 1/18 : FROM ubuntu:22.04
Step 1/18 : FROM ubuntu:22.04
error parsing HTTP 429 response body: invalid character 'T' looking for beginning of value: "Too Many Requests (HAP429).\n"
Sending build context to Docker daemon  430.1kB

Step 1/18 : FROM ubuntu:22.04
Step 1/18 : FROM ubuntu:22.04
error parsing HTTP 429 response body: invalid character 'T' looking for beginning of value: "Too Many Requests (HAP429).\n"
Sending build context to Docker daemon  430.1kB

Step 1/18 : FROM ubuntu:22.04
Step 1/18 : FROM ubuntu:22.04
error parsing HTTP 429 response body: invalid character 'T' looking for beginning of value: "Too Many Requests (HAP429).\n"
Sending build context to Docker daemon  430.1kB

Step 1/18 : FROM ubuntu:22.04
unauthorized: authentication required

@bors
Copy link
Contributor

bors commented Aug 3, 2023

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 3, 2023
@RalfJung
Copy link
Member Author

RalfJung commented Aug 3, 2023

@bors retry "Too Many Requests" fetching some docker image

@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 Aug 3, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 3, 2023
…li-obk

const validation: point at where we found a pointer but expected an integer

Instead of validation just printing "unable to turn pointer into bytes", make this a regular validation error that says where in the value the bad pointer was found. Also distinguish "expected integer, got pointer" from "expected pointer, got partial pointer or mix of pointers".

To avoid duplicating things too much I refactored the diagnostics for validity a bit, so that "got uninit, expected X" and "got pointer, expected X" can share the "X" part. Also all the errors emitted for validation are now grouped under `const_eval_validation` so that they are in a single group in the ftl file.

r? `@oli-obk`
@matthiaskrgr
Copy link
Member

@bors r-
#114419 (comment)

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 3, 2023
@matthiaskrgr
Copy link
Member

@bors r=oli-obk
Looks like something different is actually the cause

@bors
Copy link
Contributor

bors commented Aug 3, 2023

📌 Commit 7767cbb has been approved by oli-obk

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 3, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 3, 2023
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#113657 (Expand, rename and improve `incorrect_fn_null_checks` lint)
 - rust-lang#114237 (parser: more friendly hints for handling `async move` in the 2015 edition)
 - rust-lang#114300 (Suggests turbofish in patterns)
 - rust-lang#114372 (const validation: point at where we found a pointer but expected an integer)
 - rust-lang#114395 ([rustc_span][perf] Hoist lookup sorted by words out of the loop.)
 - rust-lang#114403 (fix the span in the suggestion of remove question mark)
 - rust-lang#114408 (Temporary remove myself from review rotation)
 - rust-lang#114415 (Skip checking of `rustc_codegen_gcc` with vendoring enabled)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 00dcc7b into rust-lang:master Aug 3, 2023
@rustbot rustbot added this to the 1.73.0 milestone Aug 3, 2023
@RalfJung RalfJung deleted the const-pointer-as-int branch August 6, 2023 12:02
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