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

ICE with byte char literal in match #17631

Closed
lilyball opened this issue Sep 29, 2014 · 6 comments
Closed

ICE with byte char literal in match #17631

lilyball opened this issue Sep 29, 2014 · 6 comments
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@lilyball
Copy link
Contributor

Using a b'x' literal in a match in one arm when another arm uses an integral literal causes an ICE.

Code:

pub fn main() {
    let (a, b) = (1u8, 2u8);

    let _x = match (a, b) {
        (0x1b, b'\\') => 1u,
        (_, 0x05) => 2u,
        _ => 5u
    };
}

Results:

error: internal compiler error: unexpected failure
note: the compiler hit an unexpected failure path. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
task 'rustc' failed at 'compare_list_exprs: type mismatch', /Volumes/Himling/Users/kevin/Dev/rust/rust/src/librustc/middle/trans/_match.rs:236

stack backtrace:
   1:        0x10b611c19 - rt::backtrace::imp::write::h49e167be6c35c7a6I3q
   2:        0x10b614f71 - failure::on_fail::h2de262f0fa07a6d1mkr
   3:        0x10b89c025 - unwind::begin_unwind_inner::h9dd2b45e3189ab76PQd
   4:        0x10825d84c - unwind::begin_unwind::h17200107724015028583
   5:        0x1086bb033 - middle::trans::_match::Opt<'a>::eq::ha0347177cb74f650KDg
   6:        0x1086c7908 - middle::trans::_match::compile_submatch_continue::h2c95eff2a4dfe45ejHh
   7:        0x1086c42f0 - middle::trans::_match::compile_submatch::he72af60857c57ca2yBh
   8:        0x1086c729f - middle::trans::_match::compile_submatch_continue::h2c95eff2a4dfe45ejHh
   9:        0x1086c42f0 - middle::trans::_match::compile_submatch::he72af60857c57ca2yBh
  10:        0x10864fb8b - middle::trans::_match::trans_match::h01258bca90f67af8E0h
  11:        0x10863cc1c - middle::trans::expr::trans_rvalue_dps_unadjusted::h27302feaf01beb5aZ03
  12:        0x1085fe8ed - middle::trans::expr::trans_into::h148e25892fc50848QC2
  13:        0x1086d76fe - middle::trans::_match::store_local::closure.127410
  14:        0x1086d7565 - middle::trans::_match::mk_binding_alloca::h10952157501536158966
  15:        0x1086a375d - middle::trans::_match::store_local::h4bc417dc83908137Xdi
  16:        0x1085fde6a - middle::trans::base::init_local::hc06087db4c732c66eYd
  17:        0x1085fd331 - middle::trans::controlflow::trans_stmt::h4fb6e8ab2ae05364OEY
  18:        0x1085feb98 - middle::trans::controlflow::trans_block::h4903f12a15b4b417UJY
  19:        0x1086ac572 - middle::trans::base::trans_closure::hcc72f0bf6b75cf89EPe
  20:        0x1085f17f8 - middle::trans::base::trans_fn::h50dd8cb21b7d227f20e
  21:        0x1085eec9a - middle::trans::base::trans_item::h2481520530d8b2c5lkf
  22:        0x1086b5d78 - middle::trans::base::trans_crate::h2d09203b93180fb4Bkg
  23:        0x108abc895 - driver::driver::phase_4_translate_to_llvm::h480b949b4d48af47pJw
  24:        0x108ab5613 - driver::driver::compile_input::h7ecbeb2017ef3606rgw
  25:        0x108b33b34 - driver::run_compiler::ha722889403f0b6bdn6z
  26:        0x108b31d26 - driver::main_args::closure.146118
  27:        0x1082949ab - task::TaskBuilder<S>::try_future::closure.101380
  28:        0x1082948a3 - task::TaskBuilder<S>::spawn_internal::closure.101351
  29:        0x10b4e44bd - task::spawn_opts::closure.8577
  30:        0x10b903ecc - rust_try_inner
  31:        0x10b903eb6 - rust_try
  32:        0x10b899437 - unwind::try::h493476c01d8d39d6xFd
  33:        0x10b8992ac - task::Task::run::hd474352d5be20d9fMVc
  34:        0x10b4e4312 - task::spawn_opts::closure.8516
  35:        0x10b89af6a - thread::thread_start::hf69b37c15c1d48651fd
  36:     0x7fff8d29d2fc - _pthread_body
  37:     0x7fff8d29d279 - _pthread_body
rustc 0.12.0-pre (496b68d48 2014-09-29 01:03:06 +0000)
@lilyball lilyball added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Sep 29, 2014
@lilyball
Copy link
Contributor Author

Doesn't require byte literals. It just requires two integral literals, one which is known at const-eval time to be unsigned, and one which is unknown (and therefore defaults to signed):

pub fn main() {
    let (a, b) = (1u8, 2u8);

    let _x = match (a, b) {
        (0x1b, 0x01) => 1u,
        (_, 0x05u8) => 2u,
        _ => 5u
    };
}

@lilyball
Copy link
Contributor Author

Oddly, if I try a simpler version:

pub fn main() {
    match 5u8 {
        1 => (),
        2u8 => (),
        _ => ()
    }
}

I get a type error:

<anon>:3:9: 3:10 error: mismatched types between arms
<anon>:3         1 => (),
                 ^
error: aborting due to previous error

Even though it seems like this should work just fine. I don't know why the previous version works.

@mahkoh
Copy link
Contributor

mahkoh commented Sep 29, 2014

cc #16745

@steveklabnik
Copy link
Member

Triage: I still get an ICE today.

@tamird
Copy link
Contributor

tamird commented Apr 21, 2015

Compiles without issue.

pub fn main() {
    let (a, b) = (1u8, 2u8);

    let _x = match (a, b) {
        (0x1b, b'\\') => 1u8,
        (_, 0x05) => 2u8,
        _ => 5u8,
    };
}

@tamird
Copy link
Contributor

tamird commented Apr 21, 2015

cc @jakub- because #18538

@alexcrichton alexcrichton added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Apr 21, 2015
lnicola pushed a commit to lnicola/rust that referenced this issue Sep 25, 2024
feat: better name suggestions for fn

fix rust-lang#17631.

Better name suggestions for fn-calls / method-calls in the form of `from()`, `from_xxx()`, `into()`, etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants