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 when break and enum variants mixed in match arms #41213

Closed
KeenS opened this issue Apr 11, 2017 · 7 comments
Closed

ICE when break and enum variants mixed in match arms #41213

KeenS opened this issue Apr 11, 2017 · 7 comments
Assignees
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@KeenS
Copy link

KeenS commented Apr 11, 2017

I tried this code:

enum A {
    A1,
    A2,
    A3,
}

enum B {
    B1(String, String),
    B2(String, String),
}


fn consume_b(_b: B) {}

fn main() {
    let a = A::A1;
    loop {
        let ctor = match a {
            A3 => break,
            A1 => B::B1,
            A2 => B::B2,
        };
        consume_b(ctor("1".into(), "2".into()));
        break;
    }
}

then, rustc crashes with this message.

error: internal compiler error: unexpected panic

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: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'assertion failed: !self.tables.borrow().adjustments.contains_key(&expr.id)', /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/librustc_typeck/check/coercion.rs:695
stack backtrace:
   1:     0x7f363c0fe40c - std::sys::imp::backtrace::tracing::imp::write::hf33ae72d0baa11ed
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:42
   2:     0x7f363c10c9ae - std::panicking::default_hook::{{closure}}::h59672b733cc6a455
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:351
   3:     0x7f363c10c553 - std::panicking::default_hook::h1670459d2f3f8843
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:361
   4:     0x7f363c10ce4b - std::panicking::rust_panic_with_hook::hcf0ddb069e7beee7
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:555
   5:     0x7f363aa3e1af - std::panicking::begin_panic::he1a21c7d2bfbc925
   6:     0x7f363aaa557b - rustc_typeck::check::_match::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::check_match::h9b6e1aca41975d59
   7:     0x7f363ab1c936 - rustc_typeck::check::FnCtxt::check_expr_kind::h34a8082c3fb5738a
   8:     0x7f363ab1c1ed - rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref::h7ef9ef0888ee8a49
   9:     0x7f363ab2dbdd - rustc_typeck::check::FnCtxt::check_decl_initializer::haaea47c4d358654e
  10:     0x7f363ab2dce4 - rustc_typeck::check::FnCtxt::check_decl_local::h1b35be9466600360
  11:     0x7f363ab2e016 - rustc_typeck::check::FnCtxt::check_stmt::h432c28cb9771ab73
  12:     0x7f363ab2e36e - rustc_typeck::check::FnCtxt::check_block_with_expected::h5a97aba5369a0e70
  13:     0x7f363ab1c7db - rustc_typeck::check::FnCtxt::check_expr_kind::h34a8082c3fb5738a
  14:     0x7f363ab1c1ed - rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref::h7ef9ef0888ee8a49
  15:     0x7f363ab2e3b7 - rustc_typeck::check::FnCtxt::check_block_with_expected::h5a97aba5369a0e70
  16:     0x7f363ab1c62e - rustc_typeck::check::FnCtxt::check_expr_kind::h34a8082c3fb5738a
  17:     0x7f363ab1c1ed - rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_lvalue_pref::h7ef9ef0888ee8a49
  18:     0x7f363ab02671 - rustc_typeck::check::check_fn::ha6fc77ffa200fbd2
  19:     0x7f363ab01684 - rustc_typeck::check::check_bare_fn::h9f0916104d636ee0
  20:     0x7f363aafe875 - rustc_typeck::check::check_item_bodies::hd9e8c6a8692f314b
  21:     0x7f363ab6c497 - rustc_typeck::check_crate::h8c159f70d1009b33
  22:     0x7f363c4aacd7 - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::h040eea107b0d299b
  23:     0x7f363c4a76c6 - rustc_driver::driver::phase_3_run_analysis_passes::haec055f3322a38aa
  24:     0x7f363c48b150 - rustc_driver::driver::compile_input::hd9f060ee16a643fb
  25:     0x7f363c4d5844 - rustc_driver::run_compiler::h762802568c0e140e
  26:     0x7f363c3e1edb - std::panicking::try::do_call::h935e2f773deaf841
  27:     0x7f363c115c8a - __rust_maybe_catch_panic
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libpanic_unwind/lib.rs:98
  28:     0x7f363c40a112 - <F as alloc::boxed::FnBox<A>>::call_box::he43811d1f6894655
  29:     0x7f363c10b804 - std::sys::imp::thread::Thread::new::thread_start::he668872ac11287ba
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/liballoc/boxed.rs:624
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/sys_common/thread.rs:21
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/sys/unix/thread.rs:84
  30:     0x7f3634bc66c9 - start_thread
  31:     0x7f363bdc50ae - __clone
  32:                0x0 - <unknown>

Meta

rustc --version --verbose:

rustc 1.16.0 (30cf806ef 2017-03-10)
binary: rustc
commit-hash: 30cf806ef8881c41821fbd43e5cf3699c5290c16
commit-date: 2017-03-10
host: x86_64-unknown-linux-gnu
release: 1.16.0
LLVM version: 3.9

Note

  • When the break arm isn't the first, ICE doesn't occur.
  • When the arms are only 2, ICE doesn't occure
@TimNN TimNN added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 11, 2017
@TimNN
Copy link
Contributor

TimNN commented Apr 11, 2017

This was introduced between 1.11 and 1.12.

@eddyb
Copy link
Member

eddyb commented Apr 11, 2017

cc @nikomatsakis @canndrew This looks like it has something to do with the ! -> _ coercion.

@arielb1
Copy link
Contributor

arielb1 commented Apr 11, 2017

looking at it.

@nikomatsakis
Copy link
Contributor

Indeed, probably something I introduced.

@nikomatsakis
Copy link
Contributor

@arielb1 are you going to have time to investigate, or you want me to?

@arielb1
Copy link
Contributor

arielb1 commented Apr 13, 2017

@nikomatsakis

Sorry. Was busy yesterday. I'll look at it today or tommorow.

@arielb1
Copy link
Contributor

arielb1 commented Apr 13, 2017

Wrong comment:

                    // No adjustments can produce a fn item, so this should never trip.

arielb1 added a commit to arielb1/rust that referenced this issue Apr 13, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this issue Apr 14, 2017
…ikomatsakis

rustc_typeck: consolidate adjustment composition

Instead of having `write_adjustment` overwrite the previous adjustment, have `apply_adjustment` compose a new adjustment on top of the previous one. This is important because `NeverToAny` adjustments can be present on expressions during coercion.

Fixes rust-lang#41213.

r? @nikomatsakis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants