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

Refactor the const eval diagnostic API #51316

Merged
merged 8 commits into from
Jun 6, 2018
Merged

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Jun 2, 2018

  • no longer report "const eval error" for things that have typeck errors
  • errors and lints have saner spans and messages
  • unified the diagnostic logic (const eval errors were slightly different depending on where they were reported, and there was also code duplication between the different reporters)
  • report errors if an erroneous constant is used inside a promoted (fixes most of Segfault or wrong values from const FOO: u32 = 0 - 1; println!("{}", FOO); #50814)

@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 2, 2018
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-3.9 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.

[00:05:45] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:05:45] tidy error: /checkout/src/test/ui/const-eval/issue-50814.rs: missing trailing newline
[00:05:45] tidy error: /checkout/src/test/ui/const-eval/issue-50814-2.rs: missing trailing newline
[00:05:47] some tidy checks failed
[00:05:47] 
[00:05:47] 
[00:05:47] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:05:47] 
[00:05:47] 
[00:05:47] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:05:47] Build completed unsuccessfully in 0:02:41
[00:05:47] Build completed unsuccessfully in 0:02:41
[00:05:47] make: *** [tidy] Error 1
[00:05:47] Makefile:79: recipe for target 'tidy' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0a95a96e
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@nikomatsakis
Copy link
Contributor

@bors r+

cc @eddyb, you may want to take a look too

@bors
Copy link
Contributor

bors commented Jun 5, 2018

📌 Commit 0cc9e7b has been approved by nikomatsakis

@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 Jun 5, 2018
pub enum ErrKind<'tcx> {

NonConstPath,
UnimplementedConstVal(&'static str),
CouldNotResolve,
IndexOutOfBounds { len: u64, index: u64 },
Copy link
Member

Choose a reason for hiding this comment

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

Is this still needed? I think Miri covers it already.

@oli-obk
Copy link
Contributor Author

oli-obk commented Jun 5, 2018

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Jun 5, 2018

📌 Commit 50ebd33 has been approved by nikomatsakis

@oli-obk
Copy link
Contributor Author

oli-obk commented Jun 5, 2018

@bors r=nikomatsakis

These keep dropping like flies. We should be able to remove const_val::ErrKind soonish

@bors
Copy link
Contributor

bors commented Jun 5, 2018

📌 Commit 13496ff has been approved by nikomatsakis

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-3.9 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[00:13:46]    Compiling rustc_mir v0.0.0 (file:///checkout/src/librustc_mir)
[00:13:54] error[E0308]: mismatched types
[00:13:54]    --> librustc_mir/transform/const_prop.rs:243:46
[00:13:54]     |
[00:13:54] 243 |                     let valty = self.use_ecx(span, |this| {
[00:13:54]     |                                              ^^^^ expected struct `rustc::mir::SourceInfo`, found struct `syntax_pos::Span`
[00:13:54]     = note: expected type `rustc::mir::SourceInfo`
[00:13:54]                found type `syntax_pos::Span`
[00:13:54] 
[00:13:57] error: aborting due to previous error
[00:13:57] error: aborting due to previous error
[00:13:57] 
[00:13:57] For more information about this error, try `rustc --explain E0308`.
[00:13:57] error: Could not compile `rustc_mir`.
[00:13:57] 
[00:13:57] Caused by:
[00:13:57]   process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc --crate-name rustc_mir librustc_mir/lib.rs --color always --error-format json --crate-type dylib --emit=dep-info,link -C prefer-dynamic -C opt-level=2 -C metadata=514ebd12ea876458 -C extra-filename=-514ebd12ea876458 --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/release/deps --extern rustc_data_structures=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_data_structures-05d59ed98ebd8949.so --extern syntax=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libsyntax-4c5434c80172b18c.so --extern polonius_engine=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libpolonius_engine-6e0be5cf77966185.rlib --extern rustc_errors=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_errors-41b116eaee1e5535.so --extern graphviz=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libgraphviz-be994de8b3050feb.so --extern syntax_pos=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libsyntax_pos-0404335fb4ae3dc1.so --extern rustc_target=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_target-58741ed9de9aae4f.so --extern log=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/liblog-5073f1296cd24b67.rlib --extern rustc_apfloat=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_apfloat-642a7efe79e24835.rlib --extern bitflags=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libbitflags-99b4534960f92449.rlib --extern byteorder=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libbyteorder-78ebc049d4f53f46.rlib --extern arena=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libarena-9f4c7501a8934cc5.so --extern rustc=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc-a30c37d59a6fc275.so --extern serialize=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libserialize-5d0a8a65bb9fe29f.so --extern serialize=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libserialize-5d0a8a65bb9fe29f.rlib --extern log_settings=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/liblog_settings-f16e9eee09cda644.rlib --extern either=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libeither-11fcd35bf55f48b3.rlib -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/backtrace-sys-88673787176f9d86/out -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/miniz-sys-62d80197b9ec531e/out` (exit code: 101)
[00:15:39] error: build failed
[00:15:39] error: build failed
[00:15:39] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" " jemalloc" "--manifest-path" "/checkout/src/rustc/Cargo.toml" "--message-format" "json"
[00:15:39] expected success, got: exit code: 101
[00:15:39] thread 'main' panicked at 'cargo must succeed', bootstrap/compile.rs:1091:9
[00:15:39] travis_fold:end:stage0-rustc

[00:15:39] travis_time:end:stage0-rustc:start=1528218883241472900,finish=1528219484473491909,duration=601232019009


[00:15:39] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap build
[00:15:39] Build completed unsuccessfully in 0:10:13
[00:15:39] make: *** [all] Error 1
[00:15:39] Makefile:28: recipe for target 'all' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:00b3006a
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@oli-obk
Copy link
Contributor Author

oli-obk commented Jun 5, 2018

@bors r-

needs a rebase

@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 Jun 5, 2018
@bors
Copy link
Contributor

bors commented Jun 5, 2018

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

@oli-obk
Copy link
Contributor Author

oli-obk commented Jun 5, 2018

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Jun 5, 2018

📌 Commit 14d08e5 has been approved by nikomatsakis

@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 Jun 5, 2018
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request Jun 5, 2018
Refactor the const eval diagnostic API

* no longer report "const eval error" for things that have typeck errors
* errors and lints have saner spans and messages
* unified the diagnostic logic (const eval errors were slightly different depending on where they were reported, and there was also code duplication between the different reporters)
* report errors if an erroneous constant is used inside a promoted (fixes most of rust-lang#50814)
@@ -534,8 +534,7 @@ fn process_predicate<'a, 'gcx, 'tcx>(
} else {
Err(CodeSelectionError(ConstEvalFailure(ConstEvalErr {
span: obligation.cause.span,
kind: ErrKind::UnimplementedConstVal("could not resolve")
.into(),
kind: ErrKind::CouldNotResolve.into(),
Copy link
Member

Choose a reason for hiding this comment

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

Wait, what error does miri produce from its own failed Instance::resolve?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

That's... disappointing. I believe failing to resolve means "still too polymorphic", does miri not have any general errors for that, short of the layout ones?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, but I will add one when refactoring away the old ctfe error enum

@bors
Copy link
Contributor

bors commented Jun 6, 2018

⌛ Testing commit 14d08e5 with merge 9ac3725...

bors added a commit that referenced this pull request Jun 6, 2018
Refactor the const eval diagnostic API

* no longer report "const eval error" for things that have typeck errors
* errors and lints have saner spans and messages
* unified the diagnostic logic (const eval errors were slightly different depending on where they were reported, and there was also code duplication between the different reporters)
* report errors if an erroneous constant is used inside a promoted (fixes most of #50814)
@bors
Copy link
Contributor

bors commented Jun 6, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing 9ac3725 to master...

@bors bors merged commit 14d08e5 into rust-lang:master Jun 6, 2018
@oli-obk oli-obk deleted the const_err branch June 15, 2020 15:27
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants