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 'assertion failed: !value.needs_subst()', librustc/traits/query/normalize_erasing_regions.rs:69:9 #55266

Closed
SimonSapin opened this issue Oct 22, 2018 · 2 comments · Fixed by #61666

Comments

@SimonSapin
Copy link
Contributor

commented Oct 22, 2018

I don’t know how related this is to #55265, the assertion is different.

struct VTable<DST: ?Sized> {
    _to_dst_ptr: fn(*mut ()) -> *mut DST,
}

trait HasVTableFor<DST: ?Sized + 'static> {
    const VTABLE: &'static VTable<DST>;
}

impl<T, DST: ?Sized + 'static> HasVTableFor<DST> for T {
    const VTABLE: &'static VTable<DST> = &VTable {
        _to_dst_ptr: |_: *mut ()| unsafe { std::mem::zeroed() },
    };
}

pub fn push<DST: ?Sized + 'static, T>() {
    <T as HasVTableFor<DST>>::VTABLE;
}

(Playground)

Errors:

thread 'main' panicked at 'assertion failed: !value.needs_subst()', librustc/traits/query/normalize_erasing_regions.rs:69:9
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:480
   6: std::panicking::begin_panic
   7: rustc::traits::query::normalize_erasing_regions::<impl rustc::ty::context::TyCtxt<'cx, 'tcx, 'tcx>>::normalize_erasing_late_bound_regions
   8: rustc::ty::instance::Instance::resolve_closure
   9: rustc_mir::interpret::cast::<impl rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::cast
  10: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::run
  11: rustc_mir::const_eval::eval_body_using_ecx
  12: rustc_mir::const_eval::const_eval_provider
  13: rustc::ty::query::__query_compute::const_eval
  14: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::const_eval<'tcx>>::compute
  15: rustc::dep_graph::graph::DepGraph::with_task_impl
  16: rustc::ty::context::tls::with_related_context
  17: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  18: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  19: rustc::ty::query::TyCtxtAt::const_eval
  20: rustc_mir::interpret::operand::<impl rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::global_to_op
  21: rustc_mir::interpret::operand::<impl rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::const_value_to_op
  22: rustc_mir::interpret::operand::<impl rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::const_to_op
  23: rustc_mir::transform::const_prop::ConstPropagator::eval_constant
  24: rustc_mir::transform::const_prop::ConstPropagator::const_prop
  25: <rustc_mir::transform::const_prop::ConstPropagator<'b, 'a, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_statement
  26: <rustc_mir::transform::const_prop::ConstProp as rustc_mir::transform::MirPass>::run_pass
  27: rustc_mir::transform::optimized_mir::{{closure}}
  28: rustc_mir::transform::optimized_mir
  29: rustc::ty::query::__query_compute::optimized_mir
  30: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::optimized_mir<'tcx>>::compute
  31: rustc::dep_graph::graph::DepGraph::with_task_impl
  32: rustc::ty::context::tls::with_related_context
  33: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  34: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_get_query
  35: rustc::ty::query::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::optimized_mir
  36: rustc_metadata::encoder::<impl rustc_metadata::isolated_encoder::IsolatedEncoder<'a, 'b, 'tcx>>::encode_optimized_mir
  37: rustc_metadata::encoder::<impl rustc_metadata::isolated_encoder::IsolatedEncoder<'a, 'b, 'tcx>>::encode_info_for_item
  38: rustc::ty::context::tls::with_context
  39: <rustc_metadata::encoder::EncodeVisitor<'a, 'b, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
  40: rustc::hir::Crate::visit_all_item_likes
  41: rustc_metadata::encoder::encode_metadata
  42: rustc_metadata::cstore_impl::<impl rustc::middle::cstore::CrateStore for rustc_metadata::cstore::CStore>::encode_metadata
  43: rustc::ty::context::TyCtxt::encode_metadata
  44: rustc_codegen_llvm::base::write_metadata
  45: rustc::util::common::time
  46: rustc_codegen_llvm::base::codegen_crate
  47: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate
  48: rustc::util::common::time
  49: rustc_driver::driver::phase_4_codegen
  50: rustc_driver::driver::compile_input::{{closure}}
  51: rustc::ty::context::tls::enter_context
  52: <std::thread::local::LocalKey<T>>::with
  53: rustc::ty::context::TyCtxt::create_and_enter
  54: rustc_driver::driver::compile_input
  55: rustc_driver::run_compiler_with_pool
  56: rustc_driver::driver::spawn_thread_pool
  57: rustc_driver::run_compiler
  58: <scoped_tls::ScopedKey<T>>::set
  59: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  60: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:102
  61: rustc_driver::run
  62: rustc_driver::main
  63: std::rt::lang_start::{{closure}}
  64: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  65: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:102
  66: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:392
             at libstd/rt.rs:58
  67: main
  68: __libc_start_main
  69: <unknown>
query stack during panic:
#0 [const_eval] const-evaluating `<T as HasVTableFor<DST>>::VTABLE`
  --> src/lib.rs:16:5
   |
16 |     <T as HasVTableFor<DST>>::VTABLE;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#1 [optimized_mir] processing `push`
end of query stack

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.31.0-nightly (424a749a0 2018-10-21) 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

error: Could not compile `playground`.

@SimonSapin SimonSapin added the I-ICE label Oct 22, 2018

@SimonSapin

This comment has been minimized.

Copy link
Contributor Author

commented Oct 22, 2018

Adding a field to the struct works around this:

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2015&gist=67b1d78546132d843c7652437c70406f

struct VTable<DST: ?Sized> {
    _size: usize,
    _to_dst_ptr: fn(*mut ()) -> *mut DST,
}

trait HasVTableFor<DST: ?Sized + 'static> {
    const VTABLE: &'static VTable<DST>;
}

impl<T, DST: ?Sized + 'static> HasVTableFor<DST> for T {
    const VTABLE: &'static VTable<DST> = &VTable {
        _size: std::mem::size_of::<T>(),
        _to_dst_ptr: |_: *mut ()| unsafe { std::mem::zeroed() },
    };
}

pub fn push<DST: ?Sized + 'static, T>() {
    <T as HasVTableFor<DST>>::VTABLE;
}
@estebank

This comment has been minimized.

Copy link
Contributor

commented May 11, 2019

No longer reproduces.

Centril added a commit to Centril/rust that referenced this issue Jun 8, 2019

@bors bors closed this in #61666 Jun 9, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.