Skip to content

References with lifetime parameters in constant call to size_of crashses rustc #46511

Closed
@IsaacOscar

Description

@IsaacOscar

The following simpl file causes rustc to panic when compiling:

struct Foo<'a>
{
    a: [u8; std::mem::size_of::<&'a mut u8>()]
}
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/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.24.0-nightly (1956d5535 2017-12-03) running on x86_64-unknown-linux-gnu

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'assertion failed: `(left == right)`
  left: `Some(NodeId(4))`,
 right: `None`: free_scope: DefId(0/0:3 ~ test[8787]::Foo[0]) not recognized by the region scope tree for None / Some(DefId(0/0:3 ~ test[8787]::Foo[0]))', /checkout/src/librustc/middle/region.rs:729:12
stack backtrace:
   0:     0x7f30a88a422b - std::sys::unix::backtrace::tracing::imp::unwind_backtrace::h5b4810cf3f989436
                               at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1:     0x7f30a88b249e - std::sys_common::backtrace::print::h3b53e4c635feb021
                               at /checkout/src/libstd/sys_common/backtrace.rs:68
                               at /checkout/src/libstd/sys_common/backtrace.rs:57
   2:     0x7f30a88abe80 - std::panicking::default_hook::{{closure}}::h85174a1eef1567b5
                               at /checkout/src/libstd/panicking.rs:381
   3:     0x7f30a88abb85 - std::panicking::default_hook::h7c9e2064ca2f0334
                               at /checkout/src/libstd/panicking.rs:391
   4:     0x7f30a88ac35b - std::panicking::rust_panic_with_hook::hac6d47cdcf57440c
                               at /checkout/src/libstd/panicking.rs:577
   5:     0x7f30a88ac21e - std::panicking::begin_panic::hd4e35623276e62c8
                               at /checkout/src/libstd/panicking.rs:538
   6:     0x7f30a88ac11a - std::panicking::begin_panic_fmt::hc28cf1cb19411aba
                               at /checkout/src/libstd/panicking.rs:522
   7:     0x7f30a4c02d1f - rustc::middle::region::ScopeTree::early_free_scope::had6aa3ca531e79d3
   8:     0x7f30a4806146 - rustc::middle::free_region::RegionRelations::is_subregion_of::hc6a5729b8838ddc5
   9:     0x7f30a4772c82 - rustc::infer::lexical_region_resolve::resolve::h155d153f0d92eaca
  10:     0x7f30a4b53167 - rustc::infer::InferCtxt::resolve_regions_and_report_errors::h0eb41d3089d59fae
  11:     0x7f30a518d9e7 - rustc_typeck::check::regionck::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::regionck_expr::hefe650df91a084e4
  12:     0x7f30a5210101 - rustc::ty::context::tls::enter::hd4232f3516740e80
  13:     0x7f30a51da4f0 - rustc::infer::InferCtxtBuilder::enter::hb3933c33439a68dd
  14:     0x7f30a51a2a2f - rustc_typeck::check::typeck_tables_of::hc3edaa44dce267f5
  15:     0x7f30a484c818 - rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::compute_result::h759075042e29bf16
  16:     0x7f30a4a99ed3 - rustc::dep_graph::graph::DepGraph::with_task_impl::h8bac7ff46ae062fd
  17:     0x7f30a46ea7c4 - rustc_errors::Handler::track_diagnostics::h255c8d65952149f3
  18:     0x7f30a4c61e9f - rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check::hfe29f35b55fd694c
  19:     0x7f30a484c8ae - rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::force::h7ca40ef69975d59a
  20:     0x7f30a484cf15 - rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::try_get::he81c78cbaac62ea2
  21:     0x7f30a49daaea - rustc::ty::maps::TyCtxtAt::typeck_tables_of::h65ade909e7e372e8
  22:     0x7f30a4c75d00 - rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_tables_of::hbe5c73407a3cca25
  23:     0x7f30a5542c45 - rustc_const_eval::eval::const_eval::h7b9859f54d99de37
  24:     0x7f30a4856bf1 - rustc::ty::maps::<impl rustc::ty::maps::queries::const_eval<'tcx>>::compute_result::hce4fa31ed2cbe277
  25:     0x7f30a4aaee04 - rustc::dep_graph::graph::DepGraph::with_task_impl::hc953def9601f2c65
  26:     0x7f30a46f516f - rustc_errors::Handler::track_diagnostics::h5ec400a6716539ac
  27:     0x7f30a4c5653f - rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check::hd64eba805d415ebd
  28:     0x7f30a4856c8b - rustc::ty::maps::<impl rustc::ty::maps::queries::const_eval<'tcx>>::force::h28129652f66cbecf
  29:     0x7f30a48576b6 - rustc::ty::maps::<impl rustc::ty::maps::queries::const_eval<'tcx>>::try_get::h1f2af82281350997
  30:     0x7f30a49db208 - rustc::ty::maps::TyCtxtAt::const_eval::h419930ff136be9e0
  31:     0x7f30a49b65fd - <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_const::he3cd1e895b4d98f0
  32:     0x7f30a46be219 - rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable<'tcx> for &'tcx rustc::ty::TyS<'tcx>>::super_fold_with::he07ff5dfae099844
  33:     0x7f30a49b5d85 - <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty::hee946cf30d19dcd8
  34:     0x7f30a523ccd3 - rustc::traits::project::normalize::ha12fc2dec03fecb5
  35:     0x7f30a51aa538 - rustc_typeck::check::FnCtxt::normalize_associated_types_in::h172cba3b2b629593
  36:     0x7f30a51409ca - <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T, I>>::from_iter::h87274162f49a70de
  37:     0x7f30a5208425 - rustc::ty::context::tls::enter::h9396c3eb1303ae8f
  38:     0x7f30a51d9daa - rustc::infer::InferCtxtBuilder::enter::h55d3c95d83174f1f
  39:     0x7f30a51c9aac - <rustc_typeck::check::wfcheck::CheckTypeWellFormedVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'v>>::visit_item::h26130b2728822ab7
  40:     0x7f30a51525cc - rustc::hir::Crate::visit_all_item_likes::hb7dfd35541e5f235
  41:     0x7f30a522b777 - rustc::session::Session::track_errors::hadc7018ef876a031
  42:     0x7f30a522b0d9 - rustc::util::common::time::hebc1b7f7eb9431c4
  43:     0x7f30a5259b36 - rustc_typeck::check_crate::h8e2ba9a6dc95c78b
  44:     0x7f30a8ccf5d4 - <std::thread::local::LocalKey<T>>::with::h2125eb63cb8c7d3f
  45:     0x7f30a8cd3406 - <std::thread::local::LocalKey<T>>::with::h85df9df25b294a8a
  46:     0x7f30a8d1e8a7 - rustc::ty::context::TyCtxt::create_and_enter::hd7b37e3cca6ed7bf
  47:     0x7f30a8c92194 - rustc_driver::driver::compile_input::h5d7261585c22d999
  48:     0x7f30a8d2bca3 - rustc_driver::run_compiler::h1652a09c05ba4338
  49:     0x7f30a8c70ed1 - std::sys_common::backtrace::__rust_begin_short_backtrace::h214ac49db544d57f
  50:     0x7f30a88de55e - __rust_maybe_catch_panic
                               at /checkout/src/libpanic_unwind/lib.rs:101
  51:     0x7f30a8ced822 - <F as alloc::boxed::FnBox<A>>::call_box::h0e9993d6bfdfc927
  52:     0x7f30a889a65b - std::sys::unix::thread::Thread::new::thread_start::hdb8aa1ccbf1cfbf3
                               at /checkout/src/liballoc/boxed.rs:827
                               at /checkout/src/libstd/sys/unix/thread.rs:90
  53:     0x7f30a289c608 - start_thread
  54:     0x7f30a8580e6e - __clone
  55:                0x0 - <unknown>

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-borrow-checkerArea: The borrow checkerA-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions