Skip to content

rustc crashes matching Option<&S> when S is a struct with no fields. #12285

Closed
@jakerr

Description

@jakerr

Version: f0bad90

OSX 10.9.1
rustc 0.10-pre
host: x86_64-apple-darwin

Minimal reproduction:

struct S;

fn main() {
  let s = &S;
  let opt_s: Option<&S> = Some(s);
  match  opt_s {
    Some(&S) => println!("{:?}", S),
    _ => {}
  }
}

causes crash: error: internal compiler error: only scalars and strings supported in compare_values

back trace:

Breakpoint 1, 0x00000001000dcf10 in rust_fail ()
(gdb) bt
#0  0x00000001000dcf10 in rust_fail ()
#1  0x00000001000dceee in rt::unwind::Unwinder::begin_unwind::h5bab6b74dc9914dcZVi::v0.10.pre ()
#2  0x00000001000131a9 in rt::unwind::begin_unwind_inner::h49aeb912c6a4ce4eQ4i::v0.10.pre ()
#3  0x0000000100a42202 in rt::unwind::begin_unwind::h2c64224fbfd78a986q5::v0.10.pre ()
#4  0x0000000100a42be0 in diagnostic::Handler::fatal::h41c181a6acba83c3L2b::v0.10.pre ()
#5  0x0000000100a43158 in diagnostic::Handler::bug::h59bf254d007669aar6b::v0.10.pre ()
#6  0x0000000100ff20f1 in driver::session::Session_::bug::h1251c6a7576ff383qEj::v0.10.pre ()
#7  0x00000001011203df in middle::trans::_match::compile_submatch_continue::hd376baa48abf54ad6Mt::v0.10.pre ()
#8  0x0000000101115e6f in middle::trans::_match::compile_submatch::h9b25cc24b7fe47d0vFt::v0.10.pre ()
#9  0x000000010111c5dc in middle::trans::_match::compile_submatch_continue::hd376baa48abf54ad6Mt::v0.10.pre ()
#10 0x0000000101115e6f in middle::trans::_match::compile_submatch::h9b25cc24b7fe47d0vFt::v0.10.pre ()
#11 0x000000010111ee47 in middle::trans::_match::compile_submatch_continue::hd376baa48abf54ad6Mt::v0.10.pre ()
#12 0x0000000101115e6f in middle::trans::_match::compile_submatch::h9b25cc24b7fe47d0vFt::v0.10.pre ()
#13 0x00000001010a9067 in middle::trans::_match::trans_match::h804a8fd442d5bb1aEcu::v0.10.pre ()
#14 0x000000010109795d in middle::trans::expr::trans_rvalue_dps_unadjusted::hce8904b279cf7d8amuf::v0.10.pre ()
#15 0x000000010101a312 in middle::trans::expr::trans_into::hced97041bceb57efdAe::v0.10.pre ()
#16 0x000000010101b027 in middle::trans::controlflow::trans_block::h830e6540e96f62b384a::v0.10.pre ()
#17 0x00000001010f7f42 in middle::trans::base::trans_closure::h356b84d4c18f206ePep::v0.10.pre ()
#18 0x0000000100ff2a5a in middle::trans::base::trans_fn::he7de539c4580c505Jmp::v0.10.pre ()
#19 0x0000000100fee4c2 in middle::trans::base::trans_item::hc20a2c61f41ea0d4vyp::v0.10.pre ()
#20 0x00000001010feb6f in middle::trans::base::trans_mod::h69d707bdeb3376956Dp::v0.10.pre ()
#21 0x00000001011072ee in middle::trans::base::trans_crate::h12811b8fac70f7c81pr::v0.10.pre ()
#22 0x0000000101613a58 in driver::driver::phase_4_translate_to_llvm::h784570c37ae178b9q6h::v0.10.pre ()
#23 0x0000000101617196 in driver::driver::compile_input::h794f8e6e3126fa9dpli::v0.10.pre ()
#24 0x000000010163ab82 in run_compiler::h5cec0c25fef797c6Rcq::v0.10.pre ()
#25 0x000000010164cbbd in main_args::closure ()
#26 0x000000010164b1f2 in monitor::closure ()
#27 0x000000010164620b in task::TaskBuilder::try::closure ()
#28 0x000000010060e60c in task::bootstrap_green_task::closure ()
#29 0x00000001000d5d78 in rt::task::Task::run::closure ()
#30 0x00000001000dfc2c in rust_try ()
#31 0x000000010060e4c5 in task::bootstrap_green_task::hbb0150eeae2a78081bc::v0.10.pre ()

If a field is added to the struct in the above repro case the crash does not occur.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions