Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jakerr opened this issue Feb 15, 2014 · 1 comment
Closed

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

jakerr opened this issue Feb 15, 2014 · 1 comment

Comments

@jakerr
Copy link
Contributor

jakerr commented Feb 15, 2014

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.

@eddyb
Copy link
Member

eddyb commented Feb 15, 2014

This fails:

struct S;
match Some(&S) {
    Some(&S) => {},
    _x => {}
}

This doesn't:

struct S;
match Some(&S) {
    Some(&S) => {},
    None => {}
}

It also doesn't trigger if I replace S with () or &S with _ (or &_).

@bors bors closed this as completed in c2c27fa Jul 4, 2014
flip1995 pushed a commit to flip1995/rust that referenced this issue Feb 26, 2024
Ignore imported items in `min_ident_chars`

Suppress the `min_ident_chars` warning for items whose name we cannot control. Do not warn for `use a::b`, but warn for `use a::b as c`, since `c` is a local identifier.

Fixes rust-lang#12232

---

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: [`min_ident_chars`]: Do not warn on non-local identifiers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants