Skip to content

Borrow Checker (?) panics #47189

Closed
Closed
@manuels

Description

@manuels

While investigating bug in generators (#45259), I ran into an issue that seems to exist since non-lexical lifetimes landed. I guess it's a bug in the borrow checker - at least, that's what the backtrace says.

The code that raises the compiler panic is:

#![feature(generators, nll)]

fn foo(x: &mut u32) {
    // both `s` and `t` are live for the generator's lifetime, but within
    // the generator they have distinct lifetimes.
    move || {
        {
            let s = &mut *x;
            yield;
            *s += 1;
        }

        let t = &mut *x;
        yield;
        *t += 1;
    };
}

fn main() {
  foo(&mut 0);
}

The compiler's backtrace reads:

error: internal compiler error: /checkout/src/librustc_mir/borrow_check/error_reporting.rs:738: End-user description not implemented for field access on `TyGenerator(DefId(0/1:9 ~ foo[317d]::foo[0]::{{closure}}[0]), ClosureSubsts { substs: Slice([(), (), &mut u32]) }, GeneratorInterior { witness: (&mut u32, u32, &mut u32, (), &mut u32) })`

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 (687d3d15b 2018-01-02) running on x86_64-unknown-linux-gnu
note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'Box<Any>', /checkout/src/librustc_errors/lib.rs:504:9
stack backtrace:
   0:     0x7f5662eb6bdb - std::sys::unix::backtrace::tracing::imp::unwind_backtrace::h1566ac160e99a5cb
                               at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1:     0x7f5662ec579e - std::sys_common::backtrace::print::h7e125faafaec0730
                               at /checkout/src/libstd/sys_common/backtrace.rs:68
                               at /checkout/src/libstd/sys_common/backtrace.rs:57
   2:     0x7f5662ea2660 - std::panicking::default_hook::{{closure}}::hd0e9c262265a893e
                               at /checkout/src/libstd/panicking.rs:381
   3:     0x7f5662ea2123 - std::panicking::default_hook::h158ff347dc6943ee
                               at /checkout/src/libstd/panicking.rs:391
   4:     0x7f5662ea2aab - std::panicking::rust_panic_with_hook::h2754d947e96f732e
                               at /checkout/src/libstd/panicking.rs:577
   5:     0x7f565d879c97 - std::panicking::begin_panic::h31051ac2f3ce0711
   6:     0x7f565d894722 - rustc_errors::Handler::bug::h1d9869230db0d92f
   7:     0x7f565ec658ef - <std::thread::local::LocalKey<T>>::with::h57fcb1ddb3467c90
   8:     0x7f565f052aae - rustc::ty::context::tls::with_opt::h8ed9a4c5819c9e5e
   9:     0x7f565eb95e17 - rustc::session::opt_span_bug_fmt::hdc7c48ea259be04b
  10:     0x7f565eb95d26 - rustc::session::bug_fmt::ha284643e7da7e7e3
  11:     0x7f56605b07f2 - rustc_mir::borrow_check::error_reporting::<impl rustc_mir::borrow_check::MirBorrowckCtxt<'cx, 'gcx, 'tcx>>::describe_field_from_ty::ha17fe807f60896bb
  12:     0x7f56605b0362 - rustc_mir::borrow_check::error_reporting::<impl rustc_mir::borrow_check::MirBorrowckCtxt<'cx, 'gcx, 'tcx>>::describe_field::h9c58a4703cfb5c3f
  13:     0x7f56605afd62 - rustc_mir::borrow_check::error_reporting::<impl rustc_mir::borrow_check::MirBorrowckCtxt<'cx, 'gcx, 'tcx>>::append_place_to_string::ha671b2657748c9a6
  14:     0x7f56605afdd0 - rustc_mir::borrow_check::error_reporting::<impl rustc_mir::borrow_check::MirBorrowckCtxt<'cx, 'gcx, 'tcx>>::append_place_to_string::ha671b2657748c9a6
  15:     0x7f56605aed3a - rustc_mir::borrow_check::error_reporting::<impl rustc_mir::borrow_check::MirBorrowckCtxt<'cx, 'gcx, 'tcx>>::report_borrowed_value_does_not_live_long_enough::he0d258764a1d83c5
  16:     0x7f56605b7d81 - rustc_mir::borrow_check::MirBorrowckCtxt::access_place::hf9a2f24cbe56b497
  17:     0x7f56605b66c9 - <rustc_mir::borrow_check::MirBorrowckCtxt<'cx, 'gcx, 'tcx> as rustc_mir::dataflow::DataflowResultsConsumer<'cx, 'tcx>>::visit_terminator_entry::h3ade4cfed755a6d6
  18:     0x7f56605b53a9 - rustc_mir::borrow_check::do_mir_borrowck::hac81aa5201d63a65
  19:     0x7f5660468a6c - rustc::ty::context::tls::enter::h642ed5915575a2d0
  20:     0x7f5660543c6d - rustc::infer::InferCtxtBuilder::enter::h93bf2ac5a0f0e2bf
  21:     0x7f56605b43cc - rustc_mir::borrow_check::mir_borrowck::h9ce0d2eba2dc1724
  22:     0x7f565eed886e - rustc::ty::maps::<impl rustc::ty::maps::queries::mir_borrowck<'tcx>>::compute_result::hf2fd1ec56456a34d
  23:     0x7f565ee529fa - rustc::dep_graph::graph::DepGraph::with_task_impl::ha99d584b462f7361
  24:     0x7f565eb44a90 - rustc_errors::Handler::track_diagnostics::hdb1fd5f71819c294
  25:     0x7f565ea42570 - rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check::hda0dc39cd1541c00
  26:     0x7f565eed890f - rustc::ty::maps::<impl rustc::ty::maps::queries::mir_borrowck<'tcx>>::force::he7ca8ee14cae8092
  27:     0x7f565eed91d3 - rustc::ty::maps::<impl rustc::ty::maps::queries::mir_borrowck<'tcx>>::try_get::hcc4b25da4c8edf5b
  28:     0x7f565ed0246e - rustc::ty::maps::TyCtxtAt::mir_borrowck::h54dd3692e5821103
  29:     0x7f565ea65d58 - rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::mir_borrowck::h76c68fe1d3411521
  30:     0x7f566044b292 - rustc_mir::transform::optimized_mir::hac5573c786cae4f7
  31:     0x7f565eec87e8 - rustc::ty::maps::<impl rustc::ty::maps::queries::optimized_mir<'tcx>>::compute_result::h3f083e6388044b38
  32:     0x7f565ee5d679 - rustc::dep_graph::graph::DepGraph::with_task_impl::he84dacd9c4df3b3f
  33:     0x7f565eb3a344 - rustc_errors::Handler::track_diagnostics::hab8a29d094d51986
  34:     0x7f565ea17e70 - rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check::h52bfd31279321483
  35:     0x7f565eec887e - rustc::ty::maps::<impl rustc::ty::maps::queries::optimized_mir<'tcx>>::force::h37f8a5d3c0eaf4cb
  36:     0x7f565eec8f99 - rustc::ty::maps::<impl rustc::ty::maps::queries::optimized_mir<'tcx>>::try_get::h5b26dec4d8915957
  37:     0x7f565ed01a9a - rustc::ty::maps::TyCtxtAt::optimized_mir::h1b7ef3c9f35af611
  38:     0x7f565f0580b8 - rustc::ty::sty::ClosureSubsts::field_tys::h5d29a42daaea5063
  39:     0x7f5660529a7d - rustc_mir::borrow_check::nll::type_check::type_check_internal::ha1f1c6f08948766c
  40:     0x7f5660469925 - rustc::ty::context::tls::enter::h865e06d830bf98c4
  41:     0x7f5660543bbb - rustc::infer::InferCtxtBuilder::enter::h75bde932c0ecfb7d
  42:     0x7f56605360a6 - <rustc_mir::borrow_check::nll::type_check::TypeckMir as rustc_mir::transform::MirPass>::run_pass::he676413266873fb1
  43:     0x7f5660453e9e - rustc_mir::transform::mir_const::{{closure}}::h17f73615c9fd6a32
  44:     0x7f566044af3a - rustc_mir::transform::mir_const::h98f11695d2a0115d
  45:     0x7f565eec5c68 - rustc::ty::maps::<impl rustc::ty::maps::queries::mir_const<'tcx>>::compute_result::h72e861f076ce6442
  46:     0x7f565ee428e9 - rustc::dep_graph::graph::DepGraph::with_task_impl::h65c8c0af599cf52e
  47:     0x7f565eb4ae74 - rustc_errors::Handler::track_diagnostics::hfd314462a46654a9
  48:     0x7f565ea2a540 - rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check::h928465c849d18cf5
  49:     0x7f565eec5cfe - rustc::ty::maps::<impl rustc::ty::maps::queries::mir_const<'tcx>>::force::h290901aec7d14331
  50:     0x7f565eec6439 - rustc::ty::maps::<impl rustc::ty::maps::queries::mir_const<'tcx>>::try_get::h5d75a326a70659b5
  51:     0x7f565ed018da - rustc::ty::maps::TyCtxtAt::mir_const::h33052c72cfb354cd
  52:     0x7f565ea65ab0 - rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::mir_const::h5c9469f59a685fd8
  53:     0x7f566044b119 - rustc_mir::transform::mir_validated::h8a410f8efb9531e6
  54:     0x7f565eec7228 - rustc::ty::maps::<impl rustc::ty::maps::queries::mir_validated<'tcx>>::compute_result::hc629988bb87ae547
  55:     0x7f565ee428e9 - rustc::dep_graph::graph::DepGraph::with_task_impl::h65c8c0af599cf52e
  56:     0x7f565eb305e4 - rustc_errors::Handler::track_diagnostics::h72f70f4043bfe631
  57:     0x7f565ea428b0 - rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check::hdbc5e8cd93946a0e
  58:     0x7f565eec72be - rustc::ty::maps::<impl rustc::ty::maps::queries::mir_validated<'tcx>>::force::hf2dd59b30a8d9801
  59:     0x7f565eec79f9 - rustc::ty::maps::<impl rustc::ty::maps::queries::mir_validated<'tcx>>::try_get::h597822d239a5813e
  60:     0x7f565ed019ba - rustc::ty::maps::TyCtxtAt::mir_validated::hee096a7a83969778
  61:     0x7f565ea65ae0 - rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::mir_validated::h68d4825181cee416
  62:     0x7f566286f0f7 - rustc_borrowck::borrowck::borrowck::he977a92684bb80ce
  63:     0x7f565ee27cc0 - rustc::dep_graph::graph::DepGraph::with_task_impl::h041bb0d419f66155
  64:     0x7f565eb270de - rustc_errors::Handler::track_diagnostics::h47774c015bb76af4
  65:     0x7f565ea1c820 - rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check::h5e93bc4e0263f657
  66:     0x7f565eed6ebf - rustc::ty::maps::<impl rustc::ty::maps::queries::borrowck<'tcx>>::force::h50ead84b561acf03
  67:     0x7f565eed76ce - rustc::ty::maps::<impl rustc::ty::maps::queries::borrowck<'tcx>>::try_get::hba8b01b07a0109bc
  68:     0x7f565ed0235c - rustc::ty::maps::TyCtxtAt::borrowck::h227dd66275277b95
  69:     0x7f565ea65d20 - rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::borrowck::h6a84f994c96fbbec
  70:     0x7f566286ed71 - rustc_borrowck::borrowck::check_crate::hfc72a7067f1ed908
  71:     0x7f56632df501 - <std::thread::local::LocalKey<T>>::with::h314b95a705981850
  72:     0x7f56632e1e46 - <std::thread::local::LocalKey<T>>::with::h66de21815ebba7c9
  73:     0x7f566333ac37 - rustc::ty::context::TyCtxt::create_and_enter::h8bd3ff6ccc9dbd9f
  74:     0x7f5663299e7a - rustc_driver::driver::compile_input::h5da4e74c985f17d8
  75:     0x7f566330f1b0 - rustc_driver::run_compiler::h8c1ba0b94bb19857
  76:     0x7f5663254b71 - std::sys_common::backtrace::__rust_begin_short_backtrace::h8245a8c34ed63797
  77:     0x7f5662eee38e - __rust_maybe_catch_panic
                               at /checkout/src/libpanic_unwind/lib.rs:101
  78:     0x7f5663233bb2 - <F as alloc::boxed::FnBox<A>>::call_box::h7388440a6f732841
  79:     0x7f5662ec8067 - std::sys_common::thread::start_thread::h0ff8375a6ab48652
                               at /checkout/src/liballoc/boxed.rs:827
                               at /checkout/src/libstd/sys_common/thread.rs:24
  80:     0x7f5662ecc478 - std::sys::unix::thread::Thread::new::thread_start::h92ae5e7fea8a1d0f
                               at /checkout/src/libstd/sys/unix/thread.rs:90
  81:     0x7f565cdbf519 - start_thread
  82:     0x7f5662b9737e - clone
  83:                0x0 - <unknown>

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-NLLArea: Non-lexical lifetimes (NLL)A-borrow-checkerArea: The borrow checkerA-coroutinesArea: CoroutinesI-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions