-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-type-systemArea: Type systemArea: Type systemC-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.ICE tracked in rust-lang/glacier.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Description
Offending snippet using serde_json
:
pub const JSON: serde_json::Value = serde_json::json!({
"foo": "bar"
});
The code shouldn't build, as per the first few errors below, but currently on nightly it also causes the compiler to panic. It does not panic on stable or beta.
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
--> src/lib.rs:1:37
|
1 | pub const JSON: serde_json::Value = serde_json::json!({
| _____________________________________^
2 | | "foo": "bar"
3 | | });
| |__^
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0017]: references in constants may only refer to immutable values
--> src/lib.rs:1:37
|
1 | pub const JSON: serde_json::Value = serde_json::json!({
| _____________________________________^
2 | | "foo": "bar"
3 | | });
| |__^ constants require immutable values
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
--> src/lib.rs:1:37
|
1 | pub const JSON: serde_json::Value = serde_json::json!({
| _____________________________________^
2 | | "foo": "bar"
3 | | });
| |__^
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
--> src/lib.rs:1:37
|
1 | pub const JSON: serde_json::Value = serde_json::json!({
| _____________________________________^
2 | | "foo": "bar"
3 | | });
| |__^
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
--> src/lib.rs:1:37
|
1 | pub const JSON: serde_json::Value = serde_json::json!({
| _____________________________________^
2 | | "foo": "bar"
3 | | });
| |__^
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
--> src/lib.rs:1:37
|
1 | pub const JSON: serde_json::Value = serde_json::json!({
| _____________________________________^
2 | | "foo": "bar"
3 | | });
| |__^
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0493]: destructors cannot be evaluated at compile-time
--> src/lib.rs:1:37
|
1 | pub const JSON: serde_json::Value = serde_json::json!({
| _____________________________________^
2 | | "foo": "bar"
3 | | });
| |__^ constants cannot evaluate destructors
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[ERROR rustc_mir::transform::qualify_consts] old validator: [(<::serde_json::macros::json_internal macros>:120:27: 120:51, "FnCallNonConst(DefId(15:468 ~ serde_json[1ca2]::map[0]::{{impl}}[0]::new[0]))"), (<::serde_json::macros::json_internal macros>:46:11: 121:26, "MutBorrow(Mut { allow_two_phase_borrow: true })"), (<::serde_json::macros::json_internal macros>:46:30: 46:53, "FnCallNonConst(DefId(2:2220 ~ core[f8ef]::convert[0]::Into[0]::into[0]))"), (<::serde_json::macros::json_internal macros>:123:27: 123:58, "FnCallNonConst(DefId(15:1765 ~ serde_json[1ca2]::value[0]::to_value[0]))"), (<::serde_json::macros::json_internal macros>:123:27: 123:70, "FnCallNonConst(DefId(2:5319 ~ core[f8ef]::result[0]::{{impl}}[5]::unwrap[0]))"), (<::serde_json::macros::json_internal macros>:46:11: 121:26, "FnCallNonConst(DefId(15:477 ~ serde_json[1ca2]::map[0]::{{impl}}[0]::insert[0]))"), (<::serde_json::macros::json_internal macros>:46:11: 121:26, "LiveDrop")]
[ERROR rustc_mir::transform::qualify_consts] new validator: [(<::serde_json::macros::json_internal macros>:120:27: 120:51, "FnCallNonConst(DefId(15:468 ~ serde_json[1ca2]::map[0]::{{impl}}[0]::new[0]))"), (<::serde_json::macros::json_internal macros>:46:11: 121:26, "MutBorrow(Mut { allow_two_phase_borrow: true })"), (<::serde_json::macros::json_internal macros>:46:30: 46:53, "FnCallNonConst(DefId(2:2220 ~ core[f8ef]::convert[0]::Into[0]::into[0]))"), (<::serde_json::macros::json_internal macros>:123:27: 123:58, "FnCallNonConst(DefId(15:1765 ~ serde_json[1ca2]::value[0]::to_value[0]))"), (<::serde_json::macros::json_internal macros>:123:27: 123:70, "FnCallNonConst(DefId(2:5319 ~ core[f8ef]::result[0]::{{impl}}[5]::unwrap[0]))"), (<::serde_json::macros::json_internal macros>:46:11: 121:26, "FnCallNonConst(DefId(15:477 ~ serde_json[1ca2]::map[0]::{{impl}}[0]::insert[0]))"), (<::serde_json::macros::json_internal macros>:46:11: 121:26, "LiveDrop"), (<::serde_json::macros::json_internal macros>:120:14: 120:24, "LiveDrop")]
error: internal compiler error: src/librustc_mir/transform/qualify_consts.rs:1038: Disagreement between legacy and dataflow-based const validators.
After filing an issue, use `-Zsuppress-const-validation-back-compat-ice` to compile your code.
--> src/lib.rs:1:1
|
1 | / pub const JSON: serde_json::Value = serde_json::json!({
2 | | "foo": "bar"
3 | | });
| |___^
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:876:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.40.0-nightly (1721c9685 2019-10-12) running on x86_64-unknown-linux-gnu
note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type lib
note: some of the compiler flags provided by cargo are hidden
Version: 1.40.0-nightly (2019-10-12 1721c96)
Playground: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=5558c5ebe1ea55f66650422dffcf6d88
Quite possibly a duplicate of #65348 just buried inside the macro expansion but I'm not familiar enough with Rust compiler internals to make that determination.
ecstatic-morse
Metadata
Metadata
Assignees
Labels
A-type-systemArea: Type systemArea: Type systemC-bugCategory: This is a bug.Category: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.ICE tracked in rust-lang/glacier.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.