Repository navigation
ICE in nightly with patterns and nested enums #39362
Copy link
Copy link
Closed
Labels
E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Description
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Activity
Mark-Simulacrum commentedon May 23, 2017
This no longer ICEs. E-needstest.
venkatagiri commentedon 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 coveredas
Edit: Even splitting into two lines, it is exactly at width 100.
Mark-Simulacrum commentedon May 25, 2017
You can cut it short at non-exhaustive patterns; we check for substring not exact match.
venkatagiri commentedon May 25, 2017
How is this different compared to #42217 (comment)?
Was that just being explicit when possible?
Mark-Simulacrum commentedon May 25, 2017
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 commentedon May 25, 2017
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 commentedon May 25, 2017
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).
regression test for rust-lang#39362
Rollup merge of rust-lang#42230 - venkatagiri:ice_regression_tests, r…
Rollup merge of rust-lang#42230 - venkatagiri:ice_regression_tests, r…
Rollup merge of rust-lang#42230 - venkatagiri:ice_regression_tests, r…