Skip to content

const generics: rustc panicked at 'already borrowed: BorrowMutError' #69654

@is8ac

Description

@is8ac

Source code

#![feature(const_generics)] trait Bar<O> {} impl<O> Bar<O> for [u8; O] {} struct Foo<const O: usize> {} impl<const O: usize> Foo<O> where [u8; O]: Bar<[(); O]>, { fn foo() {} } fn main() { Foo::foo(); }

Result

$ rustc src/bin/borrow_mut_error_demo.rs error[E0423]: expected value, found type parameter `O` --> src/bin/borrow_mut_error_demo.rs:4:25 | 4 | impl<O> Bar<O> for [u8; O] {} | ^ help: a tuple variant with a similar name exists: `Ok` warning: the feature `const_generics` is incomplete and may cause the compiler to crash --> src/bin/borrow_mut_error_demo.rs:1:12 | 1 | #![feature(const_generics)] | ^^^^^^^^^^^^^^ | = note: `#[warn(incomplete_features)]` on by default thread 'rustc' panicked at 'already borrowed: BorrowMutError', /rustc/18c275b423f9f13c0e404ae3804967d2ab66337c/src/libcore/cell.rs:878:9 stack backtrace: 0: backtrace::backtrace::libunwind::trace at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/libunwind.rs:86 1: backtrace::backtrace::trace_unsynchronized at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/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:1053 5: std::io::Write::write_fmt at src/libstd/io/mod.rs:1428 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:204 9: std::panicking::default_hook at src/libstd/panicking.rs:224 10: rustc_driver::report_ice 11: std::panicking::rust_panic_with_hook at src/libstd/panicking.rs:474 12: rust_begin_unwind at src/libstd/panicking.rs:378 13: core::panicking::panic_fmt at src/libcore/panicking.rs:85 14: core::option::expect_none_failed at src/libcore/option.rs:1211 15: <rustc_infer::infer::combine::Generalizer as rustc::ty::relate::TypeRelation>::tys 16: <rustc::ty::subst::GenericArg as rustc::ty::relate::Relate>::relate 17: <I as rustc::ty::context::InternAs<[T],R>>::intern_with 18: rustc::ty::relate::super_relate_consts 19: <rustc_infer::infer::combine::Generalizer as rustc::ty::relate::TypeRelation>::consts 20: <rustc_infer::infer::combine::Generalizer as rustc::ty::relate::TypeRelation>::consts 21: rustc::ty::relate::super_relate_tys 22: <rustc_infer::infer::combine::Generalizer as rustc::ty::relate::TypeRelation>::tys 23: rustc_infer::infer::combine::CombineFields::instantiate 24: <rustc_infer::infer::equate::Equate as rustc::ty::relate::TypeRelation>::tys 25: <rustc::ty::subst::GenericArg as rustc::ty::relate::Relate>::relate 26: <I as rustc::ty::context::InternAs<[T],R>>::intern_with 27: <rustc::ty::sty::TraitRef as rustc::ty::relate::Relate>::relate 28: rustc_infer::infer::InferCtxt::commit_if_ok 29: rustc_infer::traits::select::SelectionContext::match_impl 30: rustc_infer::infer::InferCtxt::probe 31: rustc::ty::trait_def::<impl rustc::ty::context::TyCtxt>::for_each_relevant_impl 32: rustc_infer::traits::select::SelectionContext::assemble_candidates_from_impls 33: rustc_infer::traits::select::SelectionContext::assemble_candidates 34: rustc_infer::traits::select::SelectionContext::candidate_from_obligation_no_cache 35: rustc::dep_graph::graph::DepGraph::with_anon_task 36: rustc_infer::traits::select::SelectionContext::candidate_from_obligation 37: rustc_infer::traits::select::SelectionContext::evaluate_stack 38: rustc::dep_graph::graph::DepGraph::with_anon_task 39: rustc_infer::traits::select::SelectionContext::evaluate_predicate_recursively 40: rustc_infer::infer::InferCtxt::probe 41: rustc_infer::traits::select::SelectionContext::evaluate_root_obligation 42: rustc::ty::context::GlobalCtxt::enter_local 43: rustc_traits::evaluate_obligation::evaluate_obligation 44: rustc::ty::query::__query_compute::evaluate_obligation 45: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::evaluate_obligation>::compute 46: rustc::dep_graph::graph::DepGraph::with_task_impl 47: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query 48: rustc_infer::traits::query::evaluate_obligation::<impl rustc_infer::infer::InferCtxt>::evaluate_obligation 49: rustc_infer::traits::query::evaluate_obligation::<impl rustc_infer::infer::InferCtxt>::predicate_may_hold 50: rustc_infer::infer::InferCtxt::probe 51: <alloc::vec::Vec<T> as alloc::vec::SpecExtend<T,I>>::from_iter 52: rustc_typeck::check::method::probe::ProbeContext::pick_method 53: rustc_typeck::check::method::probe::ProbeContext::pick_core 54: rustc_typeck::check::method::probe::ProbeContext::pick 55: rustc_infer::infer::InferCtxt::probe 56: rustc_typeck::check::method::probe::<impl rustc_typeck::check::FnCtxt>::probe_for_name 57: rustc_typeck::check::method::<impl rustc_typeck::check::FnCtxt>::resolve_ufcs 58: rustc_typeck::check::FnCtxt::resolve_ty_and_res_ufcs 59: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind 60: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs 61: rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt>::check_call 62: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind 63: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs 64: rustc_typeck::check::FnCtxt::check_stmt 65: rustc_typeck::check::FnCtxt::check_block_with_expected 66: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind 67: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs 68: rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_return_expr 69: rustc_typeck::check::check_fn 70: rustc::ty::context::GlobalCtxt::enter_local 71: rustc_typeck::check::typeck_tables_of 72: rustc::ty::query::__query_compute::typeck_tables_of 73: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute 74: rustc::dep_graph::graph::DepGraph::with_task_impl 75: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query 76: rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners 77: rustc_typeck::check::typeck_item_bodies 78: rustc::ty::query::__query_compute::typeck_item_bodies 79: rustc::dep_graph::graph::DepGraph::with_task_impl 80: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query 81: rustc_typeck::check_crate 82: rustc_interface::passes::analysis 83: rustc::ty::query::__query_compute::analysis 84: rustc::dep_graph::graph::DepGraph::with_task_impl 85: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query 86: rustc::ty::context::tls::enter_global 87: rustc_interface::interface::run_compiler_in_existing_thread_pool 88: rustc_ast::attr::with_globals 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/blob/master/CONTRIBUTING.md#bug-reports note: rustc 1.43.0-nightly (18c275b42 2020-03-02) running on x86_64-unknown-linux-gnu query stack during panic: #0 [evaluate_obligation] evaluating trait selection obligation `[u8; _]: Bar<[(); _]>` #1 [typeck_tables_of] type-checking `main` #2 [typeck_item_bodies] type-checking all item bodies #3 [analysis] running analysis passes on this crate end of query stack error: aborting due to previous error For more information about this error, try `rustc --explain E0423`. 

Meta

$ rustc --version --verbose rustc 1.43.0-nightly (18c275b42 2020-03-02) binary: rustc commit-hash: 18c275b423f9f13c0e404ae3804967d2ab66337c commit-date: 2020-03-02 host: x86_64-unknown-linux-gnu release: 1.43.0-nightly LLVM version: 9.0 

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)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.F-const_generics`#![feature(const_generics)]`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.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions