Skip to content

Borrow Checker Paniced Upon Gifted Code #80767

Closed
@tommythorn

Description

@tommythorn

"Look Pal, it's either borrowed or taken. No gifting or buying stuff here."

Code

type G<'a> = [(O, &'a [u8]); 64];
enum O {O1}
fn main() {let p: [G; 4]; let _g: G = [(O::O1, &[]); 64]; f(p);}
fn f(_p: [G; 4]) {}

Meta

It reproduces on nightly and two other versions

rustc 1.49.0 (e1884a8e3 2020-12-29)
binary: rustc
commit-hash: e1884a8e3c3e813aada8254edfa120e85bf5ffca
commit-date: 2020-12-29
host: x86_64-unknown-linux-gnu
release: 1.49.0

Error output


Backtrace

RUST_BACKTRACE=1 cargo build
   Compiling edgesim v0.1.0 (/Users/tommy/projects/Rust/edgesim)
thread 'rustc' panicked at 'assertion failed: promoted.is_none()', compiler/rustc_mir/src/transform/check_consts/qualifs.rs:254:9
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: rustc_mir::transform::check_consts::qualifs::in_operand
   4: rustc_mir::transform::promote_consts::Validator::qualif_local
   5: rustc_mir::transform::promote_consts::Validator::validate_ref
   6: rustc_mir::transform::promote_consts::Validator::validate_local
   7: rustc_mir::transform::promote_consts::Validator::validate_local
   8: rustc_mir::transform::promote_consts::Validator::validate_local
   9: rustc_mir::transform::promote_consts::Validator::validate_local
  10: rustc_mir::transform::promote_consts::should_suggest_const_in_array_repeat_expressions_attribute
  11: rustc_mir::borrow_check::type_check::TypeChecker::check_rvalue
  12: rustc_mir::borrow_check::type_check::TypeChecker::typeck_mir
  13: rustc_mir::borrow_check::type_check::type_check
  14: rustc_mir::borrow_check::nll::compute_regions
  15: rustc_mir::borrow_check::do_mir_borrowck
  16: rustc_infer::infer::InferCtxtBuilder::enter
  17: rustc_mir::borrow_check::mir_borrowck
  18: core::ops::function::FnOnce::call_once
  19: 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
  20: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  21: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  22: rustc_data_structures::stack::ensure_sufficient_stack
  23: rustc_query_system::query::plumbing::get_query_impl
  24: rustc_query_system::query::plumbing::ensure_query_impl
  25: rustc_session::utils::<impl rustc_session::session::Session>::time
  26: rustc_interface::passes::analysis
  27: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  28: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  29: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  30: rustc_data_structures::stack::ensure_sufficient_stack
  31: rustc_query_system::query::plumbing::get_query_impl
  32: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  33: rustc_span::with_source_map
  34: rustc_interface::interface::create_compiler_and_run
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.51.0-nightly (da305a2b0 2021-01-05) running on aarch64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

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

query stack during panic:
#0 [mir_borrowck] borrow-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-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