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 in nightly with patterns and nested enums #39362

Closed
tomaka opened this issue Jan 28, 2017 · 7 comments · Fixed by #42230
Closed

ICE in nightly with patterns and nested enums #39362

tomaka opened this issue Jan 28, 2017 · 7 comments · Fixed by #42230
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

@tomaka
Copy link
Contributor

tomaka commented Jan 28, 2017

enum Foo {
    Bar { bar: Bar, id: usize }
}

enum Bar {
    A, B, C, D, E, F
}

fn test(f: Foo) {
    match f {
        Foo::Bar { bar: Bar::A, .. } => (),
        Foo::Bar { bar: Bar::B, .. } => (),
    }
}

The match doesn't cover all patterns, but instead of triggering an error (like stable does) it panics.

Playpen link
Version: c8af93f 2017-01-18
Backtrace:

thread 'rustc' panicked at 'assertion failed: !self.is_enum()', C:\bot\slave\nightly-dist-rustc-win-msvc-64\build\src\librustc\ty/mod.rs:1497
stack backtrace:
   0:     0x7ffa070208f8 - std::panicking::Location::line::h8c528bbdf4eef8a3
   1:     0x7ffa0701fd82 - std::panicking::Location::line::h8c528bbdf4eef8a3
   2:     0x7ffa070237bd - std::panicking::rust_panic_with_hook::h7abc6e334345e341
   3:     0x7ffa00a82293 - <unknown>
   4:     0x7ffa00cfe5d1 - rustc::ty::AdtDef::struct_variant::h3407c5d1765959c4
   5:     0x7ffa14c5bbf2 - <rustc_const_eval::pattern::Pattern<'tcx> as core::fmt::Display>::fmt::hd436f1763f102376
   6:     0x7ffa07036f31 - core::fmt::write::h17329881d672cff3
   7:     0x7ffa14c5617d - <rustc_const_eval::check_match::MatchVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_body::heaaeacf8d46cf425
   8:     0x7ffa14c52dc9 - <rustc_const_eval::check_match::MatchVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr::h8a811e2d6152dd49
   9:     0x7ffa14c51ae5 - <rustc_const_eval::check_match::MatchVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr::h8a811e2d6152dd49
  10:     0x7ffa14c54130 - <rustc_const_eval::check_match::MatchVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_body::heaaeacf8d46cf425
  11:     0x7ffa14c5056d - <rustc_const_eval::check_match::OuterVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_fn::he57f23671b55c8bb
  12:     0x7ffa14c3042f - <unknown>
  13:     0x7ffa14c3009e - <unknown>
  14:     0x7ffa14c2e8d5 - <unknown>
  15:     0x7ffa14c50503 - <rustc_const_eval::check_match::OuterVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_fn::he57f23671b55c8bb
  16:     0x7ffa14c31ad3 - <unknown>
  17:     0x7ffa14c50a7a - rustc_const_eval::check_match::check_crate::h80f0ce25c2e773dc
  18:     0x7ffa0cbf6c0e - rustc_driver::driver::count_nodes::h761a1dba824a4f1e
  19:     0x7ffa0cb3ad9b - <unknown>
  20:     0x7ffa0cbd137c - rustc_driver::driver::compile_input::h44e43be0fc34a1a1
  21:     0x7ffa0cc22cdb - rustc_driver::run_compiler::h5e34a930c0929e5c
  22:     0x7ffa0caff0ae - <unknown>
  23:     0x7ffa07026801 - _rust_maybe_catch_panic
  24:     0x7ffa0cb2c6e6 - <unknown>
  25:     0x7ffa0701dd2e - std::sys::imp::thread::Thread::new::h7a1b2b1b6bab390a
  26:     0x7ffa2a998363 - BaseThreadInitThunk
@sanxiyn sanxiyn added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Feb 14, 2017
@Mark-Simulacrum
Copy link
Member

This no longer ICEs. E-needstest.

@Mark-Simulacrum Mark-Simulacrum added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label May 23, 2017
@venkatagiri
Copy link
Contributor

venkatagiri commented May 25, 2017

Have created a test for this - https://is.gd/8rwE7u but tidy is failing for the ERROR check.
How do I make it multi-line?
Can I re-write the error check from

//~^ ERROR non-exhaustive patterns: `Bar { bar: C, .. }`, `Bar { bar: D, .. }`, `Bar { bar: E, .. }` and 1 more not covered

as

//~^ ERROR non-exhaustive patterns
//~| `Bar { bar: C, .. }`, `Bar { bar: D, .. }`, `Bar { bar: E, .. }` and 1 more not covered

Edit: Even splitting into two lines, it is exactly at width 100.

@Mark-Simulacrum
Copy link
Member

You can cut it short at non-exhaustive patterns; we check for substring not exact match.

@venkatagiri
Copy link
Contributor

How is this different compared to #42217 (comment)?
Was that just being explicit when possible?

@Mark-Simulacrum
Copy link
Member

That one needs both since the original error is reported on two lines, IIRC; here, it's a single line with no additional information (other than the span) from what I can tell.

@venkatagiri
Copy link
Contributor

I am still not clear on the differences.
Here's the playpen for #42217 and playpen for this issue.
Except for the exact error, both look quite similar to me.

@Mark-Simulacrum
Copy link
Member

Hm, yeah, you might need two lines here too, actually, now that I look at it. Sorry for the confusion; something like the following should work for this issue (similar to how to format the other issue).

fn test(f: Foo) {
    match f {
        //~^ ERROR non-exhaustive patterns
        //~| patterns
        Foo::Bar { bar: Bar::A, .. } => (),
        Foo::Bar { bar: Bar::B, .. } => (),
    }
}

venkatagiri added a commit to venkatagiri/rust that referenced this issue May 25, 2017
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue May 26, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this issue May 26, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this issue May 26, 2017
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.

4 participants