Skip to content

rustc panic - tuple struct pattern didn't resolve to variant or struct Err #42880

Closed
@dvec

Description

@dvec

I got rustc panic with this code (old version):

// I confused "type" with "enum" and wrote it:
type Value = String;
// When it was correct to write this:
// enum Value { String(String) }

fn main() {
    let f = |&Value::String(_)| ();

    let vec: Vec<Value> = Vec::new();
    vec.last().map(f);
}

Backtrace:

thread 'rustc' panicked at 'Box<Any>', /checkout/src/librustc_errors/lib.rs:375
stack backtrace:
   0:     0x7f3e2689a5c3 - std::sys::imp::backtrace::tracing::imp::unwind_backtrace::hab274209b3900f9c
                               at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1:     0x7f3e26895262 - std::sys_common::backtrace::_print::h8f655fc4b25b9b70
                               at /checkout/src/libstd/sys_common/backtrace.rs:71
   2:     0x7f3e268a84c7 - std::panicking::default_hook::{{closure}}::hd0f0fde26cdd4a91
                               at /checkout/src/libstd/sys_common/backtrace.rs:60
                               at /checkout/src/libstd/panicking.rs:355
   3:     0x7f3e268a802c - std::panicking::default_hook::h123df66825ae8c79
                               at /checkout/src/libstd/panicking.rs:365
   4:     0x7f3e268a899b - std::panicking::rust_panic_with_hook::h3635757261b59272
                               at /checkout/src/libstd/panicking.rs:549
   5:     0x7f3e23652a68 - std::panicking::begin_panic::hfd3f08fcd3845370
   6:     0x7f3e23642b17 - rustc_errors::Handler::span_bug::h7c196f95e5041943
   7:     0x7f3e23865754 - rustc::session::opt_span_bug_fmt::{{closure}}::hfbfe9f66fec7d051
   8:     0x7f3e23865259 - rustc::session::opt_span_bug_fmt::h4aac6d7f7dbc3512
   9:     0x7f3e23864fa4 - rustc::session::span_bug_fmt::h20665e95c8d4d339
  10:     0x7f3e23821ba7 - rustc::middle::mem_categorization::MemCategorizationContext::cat_pattern_::hda1146e1a4294a65
  11:     0x7f3e23820e67 - rustc::middle::mem_categorization::MemCategorizationContext::cat_pattern_::hda1146e1a4294a65
  12:     0x7f3e23804968 - rustc::middle::expr_use_visitor::ExprUseVisitor::walk_irrefutable_pat::h55366a16a8c5a817
  13:     0x7f3e2380257b - rustc::middle::expr_use_visitor::ExprUseVisitor::consume_body::he345b3e052bf4252
  14:     0x7f3e2523de68 - <rustc_typeck::check::upvar::AdjustBorrowKind<'a, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::visit_fn::h1f91cf1c26d57eb8
  15:     0x7f3e251e13f7 - rustc::hir::intravisit::walk_expr::hdf4b619bf2de5f4b
  16:     0x7f3e251e12c0 - rustc::hir::intravisit::walk_expr::hdf4b619bf2de5f4b
  17:     0x7f3e2523c4b1 - rustc_typeck::check::upvar::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::closure_analyze::h429dc7e4810a0ff7
  18:     0x7f3e25262826 - rustc_typeck::check::typeck_tables::{{closure}}::h166a120a5120b562
  19:     0x7f3e25261e1a - rustc_typeck::check::typeck_tables::h7c308feeeae280ae
  20:     0x7f3e2394455d - rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables<'tcx>>::try_get::h794ae45d5584fb14
  21:     0x7f3e23944721 - rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables<'tcx>>::get::h0e95165ce2218687
  22:     0x7f3e238f3892 - rustc::ty::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::item_tables::h5092397c1edc0916
  23:     0x7f3e25261164 - rustc_typeck::check::typeck_item_bodies::h9ad82d5ce3097452
  24:     0x7f3e23943893 - rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_item_bodies<'tcx>>::try_get::heb2076eb001e5002
  25:     0x7f3e23943aa0 - rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_item_bodies<'tcx>>::get::hb2ce81d558718fc3
  26:     0x7f3e252ba243 - rustc_typeck::check_crate::h16f92e6a986fd98b
  27:     0x7f3e26c52b33 - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::ha83538a03579857c
  28:     0x7f3e26bb0dbb - rustc::ty::context::TyCtxt::create_and_enter::hd9482ac47b3dbb7c
  29:     0x7f3e26c4a95a - rustc_driver::driver::phase_3_run_analysis_passes::hfea44285662197cc
  30:     0x7f3e26c238ea - rustc_driver::driver::compile_input::hc74994fea2a7b3d8
  31:     0x7f3e26c767f5 - rustc_driver::run_compiler::hccc057d367b00a4b
  32:     0x7f3e26b7b32b - std::panicking::try::do_call::hbc2a3c31903904db
  33:     0x7f3e268b1a0a - __rust_maybe_catch_panic
                               at /checkout/src/libpanic_unwind/lib.rs:98
  34:     0x7f3e26ba69e1 - <F as alloc::boxed::FnBox<A>>::call_box::h28281d8d856d67df
  35:     0x7f3e268a7294 - std::sys::imp::thread::Thread::new::thread_start::h1b316ba1f093c5a7
                               at /checkout/src/liballoc/boxed.rs:650
                               at /checkout/src/libstd/sys_common/thread.rs:21
                               at /checkout/src/libstd/sys/unix/thread.rs:84
  36:     0x7f3e1f42a6b9 - start_thread
  37:     0x7f3e265563dc - clone
  38:                0x0 - <unknown>

My rust version:

xxx@xxx ~ $ rustc --version
rustc 1.18.0 (03fc9d622 2017-06-06)

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions