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 when trying to use typeof(reference_expr) in a struct #100183

Closed
PatchMixolydic opened this issue Aug 5, 2022 · 1 comment · Fixed by #100185
Closed

ICE when trying to use typeof(reference_expr) in a struct #100183

PatchMixolydic opened this issue Aug 5, 2022 · 1 comment · Fixed by #100185
Assignees
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

@PatchMixolydic
Copy link
Contributor

PatchMixolydic commented Aug 5, 2022

Code

Playground

struct Struct {
    y: (typeof("hey"),),
}

Meta

Initially encountered on a modified build of rustc based on affe0d3. Reproduces on the playground using 1.64.0-nightly (2022-08-04 f6f9d5e73d5524b6281c).

Error output

error[E0516]: `typeof` is a reserved keyword but unimplemented
 --> src/lib.rs:2:9
  |
2 |     y: (typeof("hey"),),
  |         ^^^^^^^^^^^^^ reserved keyword
  |
help: consider replacing `typeof(...)` with an actual type
  |
2 |     y: (&str,),
  |         ~~~~

error: internal compiler error: compiler/rustc_typeck/src/outlives/utils.rs:172:13: unexpected region in outlives inference: ReErased

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/f6f9d5e73d5524b6281c10a5c89b7db35c330634/compiler/rustc_errors/src/lib.rs:1392:9
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.64.0-nightly (f6f9d5e73 2022-08-04) 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 [inferred_outlives_crate] computing the inferred outlives predicates for items in this crate
#1 [inferred_outlives_of] computing inferred outlives predicates of `Struct`
#2 [predicates_defined_on] computing predicates of `Struct`
#3 [predicates_of] computing predicates of `Struct`
#4 [collect_mod_item_types] collecting item types in top-level module
#5 [analysis] running analysis passes on this crate
end of query stack
For more information about this error, try `rustc --explain E0516`.
Backtrace

error[E0516]: `typeof` is a reserved keyword but unimplemented
 --> src/lib.rs:2:9
  |
2 |     y: (typeof("hey"),),
  |         ^^^^^^^^^^^^^ reserved keyword
  |
help: consider replacing `typeof(...)` with an actual type
  |
2 |     y: (&str,),
  |         ~~~~

error: internal compiler error: compiler/rustc_typeck/src/outlives/utils.rs:172:13: unexpected region in outlives inference: ReErased

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/f6f9d5e73d5524b6281c10a5c89b7db35c330634/compiler/rustc_errors/src/lib.rs:1392:9
stack backtrace:
   0:     0x7f9a2b808280 - std::backtrace_rs::backtrace::libunwind::trace::hab2dda36063124c3
                               at /rustc/f6f9d5e73d5524b6281c10a5c89b7db35c330634/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   1:     0x7f9a2b808280 - std::backtrace_rs::backtrace::trace_unsynchronized::hcceb752f85cfa87b
                               at /rustc/f6f9d5e73d5524b6281c10a5c89b7db35c330634/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f9a2b808280 - std::sys_common::backtrace::_print_fmt::h0e9d0262342baace
                               at /rustc/f6f9d5e73d5524b6281c10a5c89b7db35c330634/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f9a2b808280 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h16a74e196dd5077b
                               at /rustc/f6f9d5e73d5524b6281c10a5c89b7db35c330634/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f9a2b863c4c - core::fmt::write::hbb9e691f36871243
                               at /rustc/f6f9d5e73d5524b6281c10a5c89b7db35c330634/library/core/src/fmt/mod.rs:1198:17
   5:     0x7f9a2b7f92c5 - std::io::Write::write_fmt::h098aec398eb40161
                               at /rustc/f6f9d5e73d5524b6281c10a5c89b7db35c330634/library/std/src/io/mod.rs:1672:15
   6:     0x7f9a2b80af61 - std::sys_common::backtrace::_print::h284aee4d81274e4f
                               at /rustc/f6f9d5e73d5524b6281c10a5c89b7db35c330634/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f9a2b80af61 - std::sys_common::backtrace::print::h2c7454bbc55c2000
                               at /rustc/f6f9d5e73d5524b6281c10a5c89b7db35c330634/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f9a2b80af61 - std::panicking::default_hook::{{closure}}::h35b7d0fe099d327f
                               at /rustc/f6f9d5e73d5524b6281c10a5c89b7db35c330634/library/std/src/panicking.rs:295:22
   9:     0x7f9a2b80ac2e - std::panicking::default_hook::haf0097ec97f4ec53
                               at /rustc/f6f9d5e73d5524b6281c10a5c89b7db35c330634/library/std/src/panicking.rs:314:9
  10:     0x7f9a2e0a6644 - <rustc_driver[3393288ea587fde1]::DEFAULT_HOOK::{closure#0}::{closure#0} as core[cf12008db1f287dd]::ops::function::FnOnce<(&core[cf12008db1f287dd]::panic::panic_info::PanicInfo,)>>::call_once::{shim:vtable#0}
  11:     0x7f9a2b80b796 - std::panicking::rust_panic_with_hook::h8cf739b41fb4fc41
                               at /rustc/f6f9d5e73d5524b6281c10a5c89b7db35c330634/library/std/src/panicking.rs:702:17
  12:     0x7f9a2f046eb1 - std[d7ed4e80e4c53f16]::panicking::begin_panic::<rustc_errors[5ed51ff323b23383]::ExplicitBug>::{closure#0}
  13:     0x7f9a2f0463a6 - std[d7ed4e80e4c53f16]::sys_common::backtrace::__rust_end_short_backtrace::<std[d7ed4e80e4c53f16]::panicking::begin_panic<rustc_errors[5ed51ff323b23383]::ExplicitBug>::{closure#0}, !>
  14:     0x7f9a2f027c36 - std[d7ed4e80e4c53f16]::panicking::begin_panic::<rustc_errors[5ed51ff323b23383]::ExplicitBug>
  15:     0x7f9a2f06c5a6 - std[d7ed4e80e4c53f16]::panic::panic_any::<rustc_errors[5ed51ff323b23383]::ExplicitBug>
  16:     0x7f9a2f06bc65 - <rustc_errors[5ed51ff323b23383]::HandlerInner>::bug::<&alloc[d809252dfc360bb1]::string::String>
  17:     0x7f9a2f06b9c0 - <rustc_errors[5ed51ff323b23383]::Handler>::bug::<&alloc[d809252dfc360bb1]::string::String>
  18:     0x7f9a2f08e8dd - rustc_middle[a03dc3dc4d139cb1]::ty::context::tls::with_context_opt::<rustc_middle[a03dc3dc4d139cb1]::ty::context::tls::with_opt<rustc_middle[a03dc3dc4d139cb1]::util::bug::opt_span_bug_fmt<rustc_span[e9f3bd52d8d475a5]::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
  19:     0x7f9a2f091996 - rustc_middle[a03dc3dc4d139cb1]::util::bug::opt_span_bug_fmt::<rustc_span[e9f3bd52d8d475a5]::span_encoding::Span>
  20:     0x7f9a2caf79b3 - rustc_middle[a03dc3dc4d139cb1]::util::bug::bug_fmt
  21:     0x7f9a2dd2b14f - rustc_typeck[69e1e81ea6b11836]::outlives::utils::insert_outlives_predicate
  22:     0x7f9a2dd29287 - rustc_typeck[69e1e81ea6b11836]::outlives::implicit_infer::infer_predicates
  23:     0x7f9a2dd280f6 - rustc_typeck[69e1e81ea6b11836]::outlives::inferred_outlives_crate
  24:     0x7f9a2d5e0951 - rustc_query_system[effc9dc2dc8de440]::query::plumbing::try_execute_query::<rustc_query_impl[c5280860944bf7cb]::plumbing::QueryCtxt, rustc_query_system[effc9dc2dc8de440]::query::caches::ArenaCache<(), rustc_middle[a03dc3dc4d139cb1]::ty::CratePredicatesMap>>
  25:     0x7f9a2d5e06d1 - rustc_query_system[effc9dc2dc8de440]::query::plumbing::get_query::<rustc_query_impl[c5280860944bf7cb]::queries::inferred_outlives_crate, rustc_query_impl[c5280860944bf7cb]::plumbing::QueryCtxt>
  26:     0x7f9a2df13b48 - rustc_typeck[69e1e81ea6b11836]::outlives::inferred_outlives_of
  27:     0x7f9a2d59f56c - rustc_query_system[effc9dc2dc8de440]::query::plumbing::get_query::<rustc_query_impl[c5280860944bf7cb]::queries::inferred_outlives_of, rustc_query_impl[c5280860944bf7cb]::plumbing::QueryCtxt>
  28:     0x7f9a2dcf096a - rustc_typeck[69e1e81ea6b11836]::collect::predicates_defined_on
  29:     0x7f9a2d64c43a - rustc_query_system[effc9dc2dc8de440]::query::plumbing::get_query::<rustc_query_impl[c5280860944bf7cb]::queries::predicates_defined_on, rustc_query_impl[c5280860944bf7cb]::plumbing::QueryCtxt>
  30:     0x7f9a2d64c06e - <rustc_query_impl[c5280860944bf7cb]::Queries as rustc_middle[a03dc3dc4d139cb1]::ty::query::QueryEngine>::predicates_defined_on
  31:     0x7f9a2ce604b2 - rustc_typeck[69e1e81ea6b11836]::collect::predicates_of
  32:     0x7f9a2d2e1452 - rustc_query_system[effc9dc2dc8de440]::query::plumbing::get_query::<rustc_query_impl[c5280860944bf7cb]::queries::predicates_of, rustc_query_impl[c5280860944bf7cb]::plumbing::QueryCtxt>
  33:     0x7f9a2d2e107e - <rustc_query_impl[c5280860944bf7cb]::Queries as rustc_middle[a03dc3dc4d139cb1]::ty::query::QueryEngine>::predicates_of
  34:     0x7f9a2d002d02 - rustc_typeck[69e1e81ea6b11836]::collect::convert_item
  35:     0x7f9a2cffecf3 - <rustc_middle[a03dc3dc4d139cb1]::hir::map::Map>::visit_item_likes_in_module::<rustc_typeck[69e1e81ea6b11836]::collect::CollectItemTypesVisitor>
  36:     0x7f9a2cffea5c - rustc_typeck[69e1e81ea6b11836]::collect::collect_mod_item_types
  37:     0x7f9a2d2da86b - rustc_query_system[effc9dc2dc8de440]::query::plumbing::try_execute_query::<rustc_query_impl[c5280860944bf7cb]::plumbing::QueryCtxt, rustc_query_system[effc9dc2dc8de440]::query::caches::DefaultCache<rustc_span[e9f3bd52d8d475a5]::def_id::LocalDefId, ()>>
  38:     0x7f9a2daeb5f3 - rustc_query_system[effc9dc2dc8de440]::query::plumbing::get_query::<rustc_query_impl[c5280860944bf7cb]::queries::collect_mod_item_types, rustc_query_impl[c5280860944bf7cb]::plumbing::QueryCtxt>
  39:     0x7f9a2da82caf - <rustc_middle[a03dc3dc4d139cb1]::hir::map::Map>::for_each_module::<rustc_typeck[69e1e81ea6b11836]::check_crate::{closure#0}::{closure#0}::{closure#0}>
  40:     0x7f9a2da81b82 - <rustc_session[13e95720f90c9afe]::session::Session>::track_errors::<rustc_typeck[69e1e81ea6b11836]::check_crate::{closure#0}, ()>
  41:     0x7f9a2da818a2 - rustc_typeck[69e1e81ea6b11836]::check_crate
  42:     0x7f9a2da80fa7 - rustc_interface[9abb0ec733a49cad]::passes::analysis
  43:     0x7f9a2de3a0e5 - rustc_query_system[effc9dc2dc8de440]::query::plumbing::try_execute_query::<rustc_query_impl[c5280860944bf7cb]::plumbing::QueryCtxt, rustc_query_system[effc9dc2dc8de440]::query::caches::DefaultCache<(), core[cf12008db1f287dd]::result::Result<(), rustc_errors[5ed51ff323b23383]::ErrorGuaranteed>>>
  44:     0x7f9a2de39e6e - rustc_query_system[effc9dc2dc8de440]::query::plumbing::get_query::<rustc_query_impl[c5280860944bf7cb]::queries::analysis, rustc_query_impl[c5280860944bf7cb]::plumbing::QueryCtxt>
  45:     0x7f9a2d87c5aa - <rustc_interface[9abb0ec733a49cad]::interface::Compiler>::enter::<rustc_driver[3393288ea587fde1]::run_compiler::{closure#1}::{closure#2}, core[cf12008db1f287dd]::result::Result<core[cf12008db1f287dd]::option::Option<rustc_interface[9abb0ec733a49cad]::queries::Linker>, rustc_errors[5ed51ff323b23383]::ErrorGuaranteed>>
  46:     0x7f9a2d86ffda - rustc_span[e9f3bd52d8d475a5]::with_source_map::<core[cf12008db1f287dd]::result::Result<(), rustc_errors[5ed51ff323b23383]::ErrorGuaranteed>, rustc_interface[9abb0ec733a49cad]::interface::create_compiler_and_run<core[cf12008db1f287dd]::result::Result<(), rustc_errors[5ed51ff323b23383]::ErrorGuaranteed>, rustc_driver[3393288ea587fde1]::run_compiler::{closure#1}>::{closure#1}>
  47:     0x7f9a2d86f9b0 - rustc_interface[9abb0ec733a49cad]::interface::create_compiler_and_run::<core[cf12008db1f287dd]::result::Result<(), rustc_errors[5ed51ff323b23383]::ErrorGuaranteed>, rustc_driver[3393288ea587fde1]::run_compiler::{closure#1}>
  48:     0x7f9a2d86dd21 - <scoped_tls[f61fff4efaa6a02b]::ScopedKey<rustc_span[e9f3bd52d8d475a5]::SessionGlobals>>::set::<rustc_interface[9abb0ec733a49cad]::interface::run_compiler<core[cf12008db1f287dd]::result::Result<(), rustc_errors[5ed51ff323b23383]::ErrorGuaranteed>, rustc_driver[3393288ea587fde1]::run_compiler::{closure#1}>::{closure#0}, core[cf12008db1f287dd]::result::Result<(), rustc_errors[5ed51ff323b23383]::ErrorGuaranteed>>
  49:     0x7f9a2d86da0f - std[d7ed4e80e4c53f16]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[9abb0ec733a49cad]::util::run_in_thread_pool_with_globals<rustc_interface[9abb0ec733a49cad]::interface::run_compiler<core[cf12008db1f287dd]::result::Result<(), rustc_errors[5ed51ff323b23383]::ErrorGuaranteed>, rustc_driver[3393288ea587fde1]::run_compiler::{closure#1}>::{closure#0}, core[cf12008db1f287dd]::result::Result<(), rustc_errors[5ed51ff323b23383]::ErrorGuaranteed>>::{closure#0}, core[cf12008db1f287dd]::result::Result<(), rustc_errors[5ed51ff323b23383]::ErrorGuaranteed>>
  50:     0x7f9a2dec89c9 - <<std[d7ed4e80e4c53f16]::thread::Builder>::spawn_unchecked_<rustc_interface[9abb0ec733a49cad]::util::run_in_thread_pool_with_globals<rustc_interface[9abb0ec733a49cad]::interface::run_compiler<core[cf12008db1f287dd]::result::Result<(), rustc_errors[5ed51ff323b23383]::ErrorGuaranteed>, rustc_driver[3393288ea587fde1]::run_compiler::{closure#1}>::{closure#0}, core[cf12008db1f287dd]::result::Result<(), rustc_errors[5ed51ff323b23383]::ErrorGuaranteed>>::{closure#0}, core[cf12008db1f287dd]::result::Result<(), rustc_errors[5ed51ff323b23383]::ErrorGuaranteed>>::{closure#1} as core[cf12008db1f287dd]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  51:     0x7f9a2b815763 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hdccf4869fd0d937f
                               at /rustc/f6f9d5e73d5524b6281c10a5c89b7db35c330634/library/alloc/src/boxed.rs:1935:9
  52:     0x7f9a2b815763 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h94e960bb85d0cf38
                               at /rustc/f6f9d5e73d5524b6281c10a5c89b7db35c330634/library/alloc/src/boxed.rs:1935:9
  53:     0x7f9a2b815763 - std::sys::unix::thread::Thread::new::thread_start::hbe484820259606ea
                               at /rustc/f6f9d5e73d5524b6281c10a5c89b7db35c330634/library/std/src/sys/unix/thread.rs:108:17
  54:     0x7f9a2b6e2609 - start_thread
  55:     0x7f9a2b605133 - clone
  56:                0x0 - <unknown>

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.64.0-nightly (f6f9d5e73 2022-08-04) 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 [inferred_outlives_crate] computing the inferred outlives predicates for items in this crate
#1 [inferred_outlives_of] computing inferred outlives predicates of `Struct`
#2 [predicates_defined_on] computing predicates of `Struct`
#3 [predicates_of] computing predicates of `Struct`
#4 [collect_mod_item_types] collecting item types in top-level module
#5 [analysis] running analysis passes on this crate
end of query stack
For more information about this error, try `rustc --explain E0516`.

@PatchMixolydic PatchMixolydic 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 Aug 5, 2022
@PatchMixolydic PatchMixolydic changed the title ICE when trying to use a tuple type containing typeof in a struct ICE when trying to use a tuple type containing typeof(reference_expr) in a struct Aug 5, 2022
@PatchMixolydic PatchMixolydic changed the title ICE when trying to use a tuple type containing typeof(reference_expr) in a struct ICE when trying to use typeof(reference_expr) in a struct Aug 5, 2022
@compiler-errors
Copy link
Member

We should probably replace the lifetimes in the typeof recovery with 'static

@compiler-errors compiler-errors self-assigned this Aug 5, 2022
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Aug 6, 2022
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Sep 12, 2022
…sleywiser

Fix `ReErased` leaking into typeck due to `typeof(...)` recovery

Fixes rust-lang#100183
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Sep 12, 2022
…sleywiser

Fix `ReErased` leaking into typeck due to `typeof(...)` recovery

Fixes rust-lang#100183
@bors bors closed this as completed in b7504d6 Sep 13, 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.

3 participants