Skip to content

ICE during codegen of function that can't be codegened #75961

Closed
@vandenheuvel

Description

@vandenheuvel

On stable 1.45.2, 1.47.0-beta.1 (2020-08-25 0f91f5c284c72e69bb71) and 1.47.0-nightly (2020-08-25 bf4342114e357f2934d5)

From the docstring of librustc_middle::mir::mono::MonoItem::is_instantiable:

pub fn foo<'a>(s: &'a mut ()) where &'a mut (): Clone {
    <&mut () as Clone>::clone(&s);
}

Possible related or duplicate issues are #69121 (doesn't seem to be as general) and #58375 (currently marked as solved).

Backtrace on stable 1.45.2

error: internal compiler error: src/librustc_trait_selection/traits/codegen/mod.rs:62: Encountered error `Unimplemented` selecting `Binder(<&mut () as std::clone::Clone>)` during codegen

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:907:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1076
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1537
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:198
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:218
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:490
  12: std::panicking::begin_panic
  13: rustc_errors::HandlerInner::bug
  14: rustc_errors::Handler::bug
  15: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
  16: rustc_middle::ty::context::tls::with_opt::{{closure}}
  17: rustc_middle::ty::context::tls::with_opt
  18: rustc_middle::util::bug::opt_span_bug_fmt
  19: rustc_middle::util::bug::bug_fmt
  20: rustc_middle::ty::context::GlobalCtxt::enter_local
  21: rustc_trait_selection::traits::codegen::codegen_fulfill_obligation
  22: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::codegen_fulfill_obligation>::compute
  23: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  24: rustc_data_structures::stack::ensure_sufficient_stack
  25: rustc_query_system::query::plumbing::get_query_impl
  26: rustc_ty::instance::resolve_instance
  27: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::resolve_instance>::compute
  28: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  29: rustc_data_structures::stack::ensure_sufficient_stack
  30: rustc_query_system::query::plumbing::get_query_impl
  31: rustc_middle::ty::instance::Instance::resolve
  32: rustc_mir_build::lints::Search::is_recursive_call
  33: rustc_data_structures::graph::iterate::TriColorDepthFirstSearch<G>::run_from_start
  34: rustc_infer::infer::InferCtxtBuilder::enter
  35: rustc_mir_build::build::mir_built
  36: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_built>::compute
  37: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  38: rustc_data_structures::stack::ensure_sufficient_stack
  39: rustc_query_system::query::plumbing::get_query_impl
  40: rustc_mir::transform::check_unsafety::unsafety_check_result
  41: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::unsafety_check_result>::compute
  42: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  43: rustc_data_structures::stack::ensure_sufficient_stack
  44: rustc_query_system::query::plumbing::get_query_impl
  45: rustc_mir::transform::mir_const
  46: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_const>::compute
  47: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  48: rustc_data_structures::stack::ensure_sufficient_stack
  49: rustc_query_system::query::plumbing::get_query_impl
  50: rustc_mir::transform::mir_validated
  51: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_validated>::compute
  52: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  53: rustc_data_structures::stack::ensure_sufficient_stack
  54: rustc_query_system::query::plumbing::get_query_impl
  55: rustc_mir::borrow_check::mir_borrowck
  56: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::mir_borrowck>::compute
  57: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  58: rustc_data_structures::stack::ensure_sufficient_stack
  59: rustc_query_system::query::plumbing::get_query_impl
  60: rustc_query_system::query::plumbing::ensure_query_impl
  61: rustc_session::utils::<impl rustc_session::session::Session>::time
  62: rustc_interface::passes::analysis
  63: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  64: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  65: rustc_query_system::query::plumbing::get_query_impl
  66: rustc_middle::ty::context::tls::enter_global
  67: rustc_interface::interface::run_compiler_in_existing_thread_pool
  68: rustc_ast::attr::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose 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.45.2 (d3fb005a3 2020-07-31) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
#0 [codegen_fulfill_obligation] checking if `std::clone::Clone` fulfills its obligations
#1 [resolve_instance] resolving instance `<&mut () as std::clone::Clone>::clone`
#2 [mir_built] building MIR for `foo`
#3 [unsafety_check_result] unsafety-checking `foo`
#4 [mir_const] processing MIR for `foo`
#5 [mir_validated] processing `foo`
#6 [mir_borrowck] borrow-checking `foo`
#7 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

Backtrace on 1.47.0-beta.1 (2020-08-25 0f91f5c)

error: internal compiler error: Encountered error `Unimplemented` selecting `Binder(<&mut () as std::clone::Clone>)` during codegen
  |
  = note: delayed at src/librustc_trait_selection/traits/codegen/mod.rs:65:32

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:369:17
stack backtrace:
   0: std::panicking::begin_panic
   1: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   2: core::ptr::drop_in_place
   3: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop
   4: core::ptr::drop_in_place
   5: rustc_span::with_source_map
   6: rustc_interface::interface::create_compiler_and_run
   7: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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.47.0-beta.1 (0f91f5c28 2020-08-25) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
end of query stack

Backtrace on 1.47.0-nightly (2020-08-25 bf43421)

error: internal compiler error: Encountered error `Unimplemented` selecting `Binder(<&mut () as std::clone::Clone>)` during codegen
  |
  = note: delayed at src/librustc_trait_selection/traits/codegen/mod.rs:65:32

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:369:17
stack backtrace:
   0: std::panicking::begin_panic
   1: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   2: core::ptr::drop_in_place
   3: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop
   4: core::ptr::drop_in_place
   5: rustc_span::with_source_map
   6: rustc_interface::interface::create_compiler_and_run
   7: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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.47.0-nightly (bf4342114 2020-08-25) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
end of query stack

Metadata

Metadata

Assignees

No one assigned

    Labels

    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) ❄️ICEBreaker-Cleanup-CrewHelping to "clean up" bugs with minimal examples and bisectionsP-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.glacierICE tracked in rust-lang/glacier.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions