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

ICE: unwrap None in type_of.rs (associated_const_equality) #93835

Closed
Badel2 opened this issue Feb 9, 2022 · 0 comments · Fixed by #93861
Closed

ICE: unwrap None in type_of.rs (associated_const_equality) #93835

Badel2 opened this issue Feb 9, 2022 · 0 comments · Fixed by #93861
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Badel2
Copy link
Contributor

Badel2 commented Feb 9, 2022

I'm seeing an internal compiler error on the following input, found by fuzz-rustc:

Code

fn e() {
    p:a<p:p<e=6>>
}

Error output

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_typeck/src/collect/type_of.rs:512:63

Affected versions: nightly since around 2022-02-08. Stable 1.58.1 doesn't ICE.

Backtrace

Compiling playground v0.0.1 (/playground)
error: comparison operators cannot be chained
 [--> src/lib.rs:2:8
](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021#)  |
1 | fn e() {
  |        - while parsing this struct
2 |     p:a<p:p<e=6>>
  |        ^        ^
  |
  = help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments
  = help: or use `(...)` if you meant to specify fn arguments

error[[E0425]](https://doc.rust-lang.org/nightly/error-index.html#E0425): cannot find value `p` in this scope
 [--> src/lib.rs:2:5
](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021#)  |
2 |     p:a<p:p<e=6>>
  |     ^ not found in this scope
  |
help: you might have meant to write a `struct` literal
  |
1 ~ fn e() { SomeStruct {
2 |     p:a<p:p<e=6>>
3 ~ }}
  |
help: maybe you meant to write a path separator here
  |
2 |     p::a<p:p<e=6>>
  |      ~~
help: maybe you meant to write an assignment here
  |
2 |     let p:a<p:p<e=6>>
  |     ~~~~~

error[[E0658]](https://doc.rust-lang.org/nightly/error-index.html#E0658): associated const equality is incomplete
 [--> src/lib.rs:2:13
](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021#)  |
2 |     p:a<p:p<e=6>>
  |             ^^^
  |
  = note: [see issue #92827 <https://github.com/rust-lang/rust/issues/92827>](https://github.com/rust-lang/rust/issues/92827) for more information
  = help: [add `#![feature(associated_const_equality)]`](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021#) to the crate attributes to enable

error[[E0658]](https://doc.rust-lang.org/nightly/error-index.html#E0658): associated type bounds are unstable
 [--> src/lib.rs:2:9
](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021#)  |
2 |     p:a<p:p<e=6>>
  |         ^^^^^^^^
  |
  = note: [see issue #52662 <https://github.com/rust-lang/rust/issues/52662>](https://github.com/rust-lang/rust/issues/52662) for more information
  = help: [add `#![feature(associated_type_bounds)]`](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021#) to the crate attributes to enable

thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', compiler/rustc_typeck/src/collect/type_of.rs:512:63
stack backtrace:
   0:     0x7f9068d5f9fc - std::backtrace_rs::backtrace::libunwind::trace::hef696c91488c46df
                               at /rustc/0c292c9667f1b202a9150d58bdd2e89e3e803996/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f9068d5f9fc - std::backtrace_rs::backtrace::trace_unsynchronized::h76c93ef0698d26b2
                               at /rustc/0c292c9667f1b202a9150d58bdd2e89e3e803996/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f9068d5f9fc - std::sys_common::backtrace::_print_fmt::h93575aa503bf6e1b
                               at /rustc/0c292c9667f1b202a9150d58bdd2e89e3e803996/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f9068d5f9fc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h40967adecfbc037b
                               at /rustc/0c292c9667f1b202a9150d58bdd2e89e3e803996/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f9068dc10dc - core::fmt::write::h03044e853df7d223
                               at /rustc/0c292c9667f1b202a9150d58bdd2e89e3e803996/library/core/src/fmt/mod.rs:1190:17
   5:     0x7f9068d4fd28 - std::io::Write::write_fmt::h86bffabfad56f13c
                               at /rustc/0c292c9667f1b202a9150d58bdd2e89e3e803996/library/std/src/io/mod.rs:1657:15
   6:     0x7f9068d63977 - std::sys_common::backtrace::_print::hd28d8aed16472cc0
                               at /rustc/0c292c9667f1b202a9150d58bdd2e89e3e803996/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f9068d63977 - std::sys_common::backtrace::print::h8f98cdd641cb45a3
                               at /rustc/0c292c9667f1b202a9150d58bdd2e89e3e803996/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f9068d63977 - std::panicking::default_hook::{{closure}}::h729dcf0a13bd0685
                               at /rustc/0c292c9667f1b202a9150d58bdd2e89e3e803996/library/std/src/panicking.rs:295:22
   9:     0x7f9068d6363f - std::panicking::default_hook::h5f6c637024d9ad69
                               at /rustc/0c292c9667f1b202a9150d58bdd2e89e3e803996/library/std/src/panicking.rs:314:9
  10:     0x7f9069545681 - rustc_driver[a83f25a8e01ca780]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f9068d64255 - std::panicking::rust_panic_with_hook::h46cff6766bf99e7c
                               at /rustc/0c292c9667f1b202a9150d58bdd2e89e3e803996/library/std/src/panicking.rs:702:17
  12:     0x7f9068d63ec9 - std::panicking::begin_panic_handler::{{closure}}::h0e775b2aa2b67693
                               at /rustc/0c292c9667f1b202a9150d58bdd2e89e3e803996/library/std/src/panicking.rs:586:13
  13:     0x7f9068d5fea4 - std::sys_common::backtrace::__rust_end_short_backtrace::h1863dd104b065b9d
                               at /rustc/0c292c9667f1b202a9150d58bdd2e89e3e803996/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7f9068d63c09 - rust_begin_unwind
                               at /rustc/0c292c9667f1b202a9150d58bdd2e89e3e803996/library/std/src/panicking.rs:584:5
  15:     0x7f9068d2bb93 - core::panicking::panic_fmt::hfdeb0fcb6ce506f4
                               at /rustc/0c292c9667f1b202a9150d58bdd2e89e3e803996/library/core/src/panicking.rs:143:14
  16:     0x7f9068d2ba5d - core::panicking::panic::h5c52da89bea060e6
                               at /rustc/0c292c9667f1b202a9150d58bdd2e89e3e803996/library/core/src/panicking.rs:48:5
  17:     0x7f906a9f4d13 - rustc_typeck[6ad013c86309b894]::collect::type_of::type_of
  18:     0x7f906ae78d9d - <rustc_query_impl[d4f8e842d33b757d]::Queries as rustc_middle[65c9065df24d66dd]::ty::query::QueryEngine>::type_of
  19:     0x7f906a9a3bfc - <rustc_infer[5ecc931dbc9d1bd2]::infer::InferCtxtBuilder>::enter::<&rustc_middle[65c9065df24d66dd]::ty::context::TypeckResults, <rustc_typeck[6ad013c86309b894]::check::inherited::InheritedBuilder>::enter<rustc_typeck[6ad013c86309b894]::check::typeck_with_fallback<rustc_typeck[6ad013c86309b894]::check::typeck::{closure#0}>::{closure#1}, &rustc_middle[65c9065df24d66dd]::ty::context::TypeckResults>::{closure#0}>
  20:     0x7f906a95d5b9 - rustc_typeck[6ad013c86309b894]::check::typeck
  21:     0x7f906ae21067 - rustc_query_system[7ba0bb8d62d59e6f]::query::plumbing::try_execute_query::<rustc_query_impl[d4f8e842d33b757d]::plumbing::QueryCtxt, rustc_query_system[7ba0bb8d62d59e6f]::query::caches::DefaultCache<rustc_span[20d03c4744d90449]::def_id::LocalDefId, &rustc_middle[65c9065df24d66dd]::ty::context::TypeckResults>>
  22:     0x7f906ae8262c - <rustc_query_impl[d4f8e842d33b757d]::Queries as rustc_middle[65c9065df24d66dd]::ty::query::QueryEngine>::typeck
  23:     0x7f906a9d8fee - <rustc_middle[65c9065df24d66dd]::hir::map::Map>::par_body_owners::<rustc_typeck[6ad013c86309b894]::check::typeck_item_bodies::{closure#0}>
  24:     0x7f906b63e68c - rustc_typeck[6ad013c86309b894]::check::typeck_item_bodies
  25:     0x7f906b89878a - rustc_query_system[7ba0bb8d62d59e6f]::query::plumbing::try_execute_query::<rustc_query_impl[d4f8e842d33b757d]::plumbing::QueryCtxt, rustc_query_system[7ba0bb8d62d59e6f]::query::caches::DefaultCache<(), ()>>
  26:     0x7f906b8c0698 - rustc_query_system[7ba0bb8d62d59e6f]::query::plumbing::get_query::<rustc_query_impl[d4f8e842d33b757d]::queries::typeck_item_bodies, rustc_query_impl[d4f8e842d33b757d]::plumbing::QueryCtxt>
  27:     0x7f906b654c19 - <rustc_session[3b88a4bcbf196e76]::session::Session>::time::<(), rustc_typeck[6ad013c86309b894]::check_crate::{closure#7}>
  28:     0x7f906b651af3 - rustc_typeck[6ad013c86309b894]::check_crate
  29:     0x7f906b3f3127 - rustc_interface[9582d0c3479cfa46]::passes::analysis
  30:     0x7f906b890209 - rustc_query_system[7ba0bb8d62d59e6f]::query::plumbing::try_execute_query::<rustc_query_impl[d4f8e842d33b757d]::plumbing::QueryCtxt, rustc_query_system[7ba0bb8d62d59e6f]::query::caches::DefaultCache<(), core[efe43fe86f1c620a]::result::Result<(), rustc_errors[6e799cab4439a167]::ErrorReported>>>
  31:     0x7f906b8ce3f5 - rustc_query_system[7ba0bb8d62d59e6f]::query::plumbing::get_query::<rustc_query_impl[d4f8e842d33b757d]::queries::analysis, rustc_query_impl[d4f8e842d33b757d]::plumbing::QueryCtxt>
  32:     0x7f906b3c986d - <rustc_interface[9582d0c3479cfa46]::passes::QueryContext>::enter::<rustc_driver[a83f25a8e01ca780]::run_compiler::{closure#1}::{closure#2}::{closure#3}, core[efe43fe86f1c620a]::result::Result<(), rustc_errors[6e799cab4439a167]::ErrorReported>>
  33:     0x7f906b3c792a - <rustc_interface[9582d0c3479cfa46]::interface::Compiler>::enter::<rustc_driver[a83f25a8e01ca780]::run_compiler::{closure#1}::{closure#2}, core[efe43fe86f1c620a]::result::Result<core[efe43fe86f1c620a]::option::Option<rustc_interface[9582d0c3479cfa46]::queries::Linker>, rustc_errors[6e799cab4439a167]::ErrorReported>>
  34:     0x7f906b3ca8dc - rustc_span[20d03c4744d90449]::with_source_map::<core[efe43fe86f1c620a]::result::Result<(), rustc_errors[6e799cab4439a167]::ErrorReported>, rustc_interface[9582d0c3479cfa46]::interface::create_compiler_and_run<core[efe43fe86f1c620a]::result::Result<(), rustc_errors[6e799cab4439a167]::ErrorReported>, rustc_driver[a83f25a8e01ca780]::run_compiler::{closure#1}>::{closure#1}>
  35:     0x7f906b3c72d3 - rustc_interface[9582d0c3479cfa46]::interface::create_compiler_and_run::<core[efe43fe86f1c620a]::result::Result<(), rustc_errors[6e799cab4439a167]::ErrorReported>, rustc_driver[a83f25a8e01ca780]::run_compiler::{closure#1}>
  36:     0x7f906b3ad4e2 - std[3d6e7d7423cf4afe]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[9582d0c3479cfa46]::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface[9582d0c3479cfa46]::interface::run_compiler<core[efe43fe86f1c620a]::result::Result<(), rustc_errors[6e799cab4439a167]::ErrorReported>, rustc_driver[a83f25a8e01ca780]::run_compiler::{closure#1}>::{closure#0}, core[efe43fe86f1c620a]::result::Result<(), rustc_errors[6e799cab4439a167]::ErrorReported>>::{closure#0}, core[efe43fe86f1c620a]::result::Result<(), rustc_errors[6e799cab4439a167]::ErrorReported>>
  37:     0x7f906b3aac29 - <<std[3d6e7d7423cf4afe]::thread::Builder>::spawn_unchecked_<rustc_interface[9582d0c3479cfa46]::util::setup_callbacks_and_run_in_thread_pool_with_globals<rustc_interface[9582d0c3479cfa46]::interface::run_compiler<core[efe43fe86f1c620a]::result::Result<(), rustc_errors[6e799cab4439a167]::ErrorReported>, rustc_driver[a83f25a8e01ca780]::run_compiler::{closure#1}>::{closure#0}, core[efe43fe86f1c620a]::result::Result<(), rustc_errors[6e799cab4439a167]::ErrorReported>>::{closure#0}, core[efe43fe86f1c620a]::result::Result<(), rustc_errors[6e799cab4439a167]::ErrorReported>>::{closure#1} as core[efe43fe86f1c620a]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  38:     0x7f9068d6fca3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hf9ab37ec9b510857
                               at /rustc/0c292c9667f1b202a9150d58bdd2e89e3e803996/library/alloc/src/boxed.rs:1854:9
  39:     0x7f9068d6fca3 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha1991051ebf83b9d
                               at /rustc/0c292c9667f1b202a9150d58bdd2e89e3e803996/library/alloc/src/boxed.rs:1854:9
  40:     0x7f9068d6fca3 - std::sys::unix::thread::Thread::new::thread_start::h5d1d180c2a38668b
                               at /rustc/0c292c9667f1b202a9150d58bdd2e89e3e803996/library/std/src/sys/unix/thread.rs:108:17
  41:     0x7f9068ca4609 - start_thread
  42:     0x7f9068bbe293 - clone
  43:                0x0 - <unknown>

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.60.0-nightly (0c292c966 2022-02-08) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [type_of] computing type of `e::{constant#0}`
#1 [typeck] type-checking `e::{constant#0}`
#2 [typeck_item_bodies] type-checking all item bodies
#3 [analysis] running analysis passes on this crate
end of query stack
Some errors have detailed explanations: E0425, E0658.
For more information about an error, try `rustc --explain E0425`.
error: could not compile `playground` due to 4 previous errors

The relevant code has the following comment:

// FIXME(associated_const_equality) when does this unwrap fail? I have no idea what case it would.
let trait_def_id = trait_ref.trait_def_id().unwrap();

Now we do have a test case, so good luck.

cc @JulianKnodt, author of #93285, which introduced this line.

@Badel2 Badel2 added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 9, 2022
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Feb 10, 2022
@bors bors closed this as completed in a59d312 Feb 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants