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

error: internal compiler error: librustc_mir/hair/pattern/mod.rs:465: unexpected type for tuple pattern: TyError #50577

Closed
vegard opened this issue May 9, 2018 · 0 comments
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@vegard
Copy link

vegard commented May 9, 2018

Input:

fn main() {
    enum Foo {
        Drop = assert_eq!(1, 1)
    }
}

Output:

...
error: internal compiler error: librustc_mir/hair/pattern/mod.rs:465: unexpected type for tuple pattern: TyError
...
  --> <assert_eq macros>:7:1
   |
1  |   /  ( $ left : expr , $ right : expr ) => (
2  |   |  {
3  |   |  match ( & $ left , & $ right ) {
4  |   |  ( left_val , right_val ) => {
5  |   |  if ! ( * left_val == * right_val ) {
6  |  /|  panic ! (
7  |  ||  r#"assertion failed: `(left == right)`
   |  ||__^
8  | |||    left: `{:?}`,
9  | |||   right: `{:?}`"# ,
   | |||_________________^
10 |  ||  left_val , right_val ) } } } } ) ; ( $ left : expr , $ right : expr , ) => (
   |  ||_______________________- in this macro invocation (#2)
...    |
20 |   |   right: `{:?}`: {}"# ,
21 |   |  left_val , right_val , format_args ! ( $ ( $ arg ) + ) ) } } } } ) ;
   |   |_____________________________________________________________________- in this expansion of `assert_eq!` (#1)

thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:499:9
stack backtrace:
...
  13: rustc::session::span_bug_fmt
             at /home/vegard/rust/src/librustc/session/mod.rs:1267
  14: rustc_mir::hair::pattern::PatternContext::lower_pattern
             at librustc_mir/hair/pattern/mod.rs:465
             at librustc_mir/hair/pattern/mod.rs:344
  15: rustc_mir::hair::pattern::check_match::MatchVisitor::check_match::{{closure}}
             at librustc_mir/hair/pattern/check_match.rs:202
             at /home/vegard/rust/src/libcore/ops/function.rs:271
             at /home/vegard/rust/src/libcore/option.rs:404
             at /home/vegard/rust/src/libcore/iter/mod.rs:1347
             at /home/vegard/rust/src/liballoc/vec.rs:1883
             at /home/vegard/rust/src/liballoc/vec.rs:1866
             at /home/vegard/rust/src/liballoc/vec.rs:1752
             at /home/vegard/rust/src/libcore/iter/iterator.rs:1375
             at librustc_mir/hair/pattern/check_match.rs:198
             at /home/vegard/rust/src/libcore/ops/function.rs:271
             at /home/vegard/rust/src/libcore/option.rs:404
             at /home/vegard/rust/src/libcore/iter/mod.rs:1347
             at /home/vegard/rust/src/liballoc/vec.rs:1883
             at /home/vegard/rust/src/liballoc/vec.rs:1866
             at /home/vegard/rust/src/liballoc/vec.rs:1752
             at /home/vegard/rust/src/libcore/iter/iterator.rs:1375
             at librustc_mir/hair/pattern/check_match.rs:197
...
Complete output
$ rustc -Z external-macro-backtrace -
error[E0317]: if may be missing an else clause
  --> <assert_eq macros>:5:1
   |
1  |  / ( $ left : expr , $ right : expr ) => (
2  |  | {
3  |  | match ( & $ left , & $ right ) {
4  |  | ( left_val , right_val ) => {
5  | /| if ! ( * left_val == * right_val ) {
6  | || panic ! (
7  | || r#"assertion failed: `(left == right)`
8  | ||   left: `{:?}`,
9  | ||  right: `{:?}`"# ,
10 | || left_val , right_val ) } } } } ) ; ( $ left : expr , $ right : expr , ) => (
   | ||________________________^ expected (), found isize
...   |
20 |  |  right: `{:?}`: {}"# ,
21 |  | left_val , right_val , format_args ! ( $ ( $ arg ) + ) ) } } } } ) ;
   |  |____________________________________________________________________- in this expansion of `assert_eq!`
   | 
  ::: <anon>:3:16
   |
3  |            Drop = assert_eq!(1, 1)
   |                   ---------------- in this macro invocation
   |
   = note: expected type `()`
              found type `isize`

error: internal compiler error: librustc_mir/hair/pattern/mod.rs:465: unexpected type for tuple pattern: TyError
   | 
  ::: <anon>:3:16
   |
3  |              Drop = assert_eq!(1, 1)
   |                     ---------------- in this macro invocation (#1)
   | 
  ::: <panic macros>:1:1
   |
1  |    / (  ) => ( { panic ! ( "explicit panic" ) } ) ; ( $ msg : expr ) => (
2  |    | {
3  |    | $ crate :: rt :: begin_panic (
4  |    | $ msg , & ( file ! (  ) , line ! (  ) , __rust_unstable_column ! (  ) ) ) } )
...     |
9  |    | & format_args ! ( $ fmt , $ ( $ arg ) + ) , & (
10 |    | file ! (  ) , line ! (  ) , __rust_unstable_column ! (  ) ) ) } ) ;
   |    |___________________________________________________________________- in this expansion of `panic!` (#2)
  --> <assert_eq macros>:7:1
   |
1  |   /  ( $ left : expr , $ right : expr ) => (
2  |   |  {
3  |   |  match ( & $ left , & $ right ) {
4  |   |  ( left_val , right_val ) => {
5  |   |  if ! ( * left_val == * right_val ) {
6  |  /|  panic ! (
7  |  ||  r#"assertion failed: `(left == right)`
   |  ||__^
8  | |||    left: `{:?}`,
9  | |||   right: `{:?}`"# ,
   | |||_________________^
10 |  ||  left_val , right_val ) } } } } ) ; ( $ left : expr , $ right : expr , ) => (
   |  ||_______________________- in this macro invocation (#2)
...    |
20 |   |   right: `{:?}`: {}"# ,
21 |   |  left_val , right_val , format_args ! ( $ ( $ arg ) + ) ) } } } } ) ;
   |   |_____________________________________________________________________- in this expansion of `assert_eq!` (#1)

thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:499:9
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at libstd/sys_common/backtrace.rs:59
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: rustc::util::common::panic_hook
             at librustc/util/common.rs:54
   5: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:467
   6: std::panicking::begin_panic
             at /home/vegard/rust/src/libstd/panicking.rs:397
   7: rustc_errors::Handler::span_bug
             at /home/vegard/rust/src/<panic macros>:3
   8: rustc::session::opt_span_bug_fmt::{{closure}}
             at /home/vegard/rust/src/librustc/session/mod.rs:1279
   9: rustc::ty::context::tls::with_opt::{{closure}}
             at /home/vegard/rust/src/librustc/ty/context.rs:1943
  10: rustc::ty::context::tls::with_context_opt
             at /home/vegard/rust/src/librustc/ty/context.rs:1880
  11: rustc::ty::context::tls::with_opt
             at /home/vegard/rust/src/librustc/ty/context.rs:1943
  12: rustc::session::opt_span_bug_fmt
             at /home/vegard/rust/src/librustc/session/mod.rs:1276
  13: rustc::session::span_bug_fmt
             at /home/vegard/rust/src/librustc/session/mod.rs:1267
  14: rustc_mir::hair::pattern::PatternContext::lower_pattern
             at librustc_mir/hair/pattern/mod.rs:465
             at librustc_mir/hair/pattern/mod.rs:344
  15: rustc_mir::hair::pattern::check_match::MatchVisitor::check_match::{{closure}}
             at librustc_mir/hair/pattern/check_match.rs:202
             at /home/vegard/rust/src/libcore/ops/function.rs:271
             at /home/vegard/rust/src/libcore/option.rs:404
             at /home/vegard/rust/src/libcore/iter/mod.rs:1347
             at /home/vegard/rust/src/liballoc/vec.rs:1883
             at /home/vegard/rust/src/liballoc/vec.rs:1866
             at /home/vegard/rust/src/liballoc/vec.rs:1752
             at /home/vegard/rust/src/libcore/iter/iterator.rs:1375
             at librustc_mir/hair/pattern/check_match.rs:198
             at /home/vegard/rust/src/libcore/ops/function.rs:271
             at /home/vegard/rust/src/libcore/option.rs:404
             at /home/vegard/rust/src/libcore/iter/mod.rs:1347
             at /home/vegard/rust/src/liballoc/vec.rs:1883
             at /home/vegard/rust/src/liballoc/vec.rs:1866
             at /home/vegard/rust/src/liballoc/vec.rs:1752
             at /home/vegard/rust/src/libcore/iter/iterator.rs:1375
             at librustc_mir/hair/pattern/check_match.rs:197
  16: <rustc_mir::hair::pattern::check_match::MatchVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr
             at librustc_mir/hair/pattern/_match.rs:166
             at librustc_mir/hair/pattern/check_match.rs:194
             at librustc_mir/hair/pattern/check_match.rs:102
  17: <rustc_mir::hair::pattern::check_match::MatchVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr
             at /home/vegard/rust/src/libsyntax/ptr.rs:0
  18: <rustc_mir::hair::pattern::check_match::MatchVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr
             at /home/vegard/rust/src/<walk_list macros>:2
             at librustc_mir/hair/pattern/check_match.rs:98
  19: <rustc_mir::hair::pattern::check_match::MatchVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr
             at /home/vegard/rust/src/libsyntax/ptr.rs:0
  20: <rustc_mir::hair::pattern::check_match::MatchVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr
             at /home/vegard/rust/src/<walk_list macros>:2
             at librustc_mir/hair/pattern/check_match.rs:98
  21: <rustc_mir::hair::pattern::check_match::MatchVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr
             at /home/vegard/rust/src/<walk_list macros>:2
             at /home/vegard/rust/src/librustc/hir/intravisit.rs:261
             at /home/vegard/rust/src/librustc/hir/intravisit.rs:1018
             at librustc_mir/hair/pattern/check_match.rs:98
  22: <rustc_mir::hair::pattern::check_match::MatchVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr
             at /home/vegard/rust/src/<walk_list macros>:2
             at /home/vegard/rust/src/librustc/hir/intravisit.rs:261
             at /home/vegard/rust/src/librustc/hir/intravisit.rs:1018
             at librustc_mir/hair/pattern/check_match.rs:98
  23: <rustc_mir::hair::pattern::check_match::MatchVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr
             at /home/vegard/rust/src/librustc/hir/intravisit.rs:995
             at librustc_mir/hair/pattern/check_match.rs:98
  24: <rustc_mir::hair::pattern::check_match::MatchVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr
             at /home/vegard/rust/src/<walk_list macros>:2
             at /home/vegard/rust/src/librustc/hir/intravisit.rs:261
             at /home/vegard/rust/src/librustc/hir/intravisit.rs:1018
             at librustc_mir/hair/pattern/check_match.rs:98
  25: <rustc_mir::hair::pattern::check_match::MatchVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr
             at /home/vegard/rust/src/librustc/hir/intravisit.rs:267
             at /home/vegard/rust/src/<walk_list macros>:2
             at librustc_mir/hair/pattern/check_match.rs:98
  26: <rustc_mir::hair::pattern::check_match::MatchVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr
             at /home/vegard/rust/src/<walk_list macros>:2
             at /home/vegard/rust/src/librustc/hir/intravisit.rs:261
             at /home/vegard/rust/src/librustc/hir/intravisit.rs:1018
             at librustc_mir/hair/pattern/check_match.rs:98
  27: <rustc_mir::hair::pattern::check_match::MatchVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_body
             at /home/vegard/rust/src/librustc/hir/intravisit.rs:400
             at librustc_mir/hair/pattern/check_match.rs:121
  28: rustc_mir::hair::pattern::check_match::check_match
             at librustc_mir/hair/pattern/check_match.rs:70
             at /home/vegard/rust/src/librustc/session/mod.rs:318
             at librustc_mir/hair/pattern/check_match.rs:69
  29: rustc::dep_graph::graph::DepGraph::with_task_impl
             at librustc/ty/maps/plumbing.rs:723
             at librustc/dep_graph/graph.rs:343
  30: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
             at librustc/dep_graph/graph.rs:209
             at librustc/ty/maps/plumbing.rs:530
             at librustc/ty/maps/plumbing.rs:200
             at librustc/ty/context.rs:1844
             at librustc/ty/context.rs:1787
             at librustc/ty/context.rs:1843
             at librustc/ty/maps/plumbing.rs:199
             at librustc/ty/context.rs:1905
             at librustc/ty/context.rs:1889
             at librustc/ty/context.rs:1880
             at librustc/ty/context.rs:1889
             at librustc/ty/context.rs:1900
             at librustc/ty/maps/plumbing.rs:189
             at librustc/ty/maps/plumbing.rs:523
  31: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
             at librustc/ty/maps/plumbing.rs:372
             at librustc/ty/maps/plumbing.rs:599
             at librustc/ty/maps/plumbing.rs:606
  32: rustc_mir::interpret::const_eval::const_eval_provider
             at librustc_mir/interpret/const_eval.rs:451
  33: rustc::dep_graph::graph::DepGraph::with_task_impl
             at librustc/ty/maps/plumbing.rs:723
             at librustc/dep_graph/graph.rs:343
  34: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
             at librustc/dep_graph/graph.rs:209
             at librustc/ty/maps/plumbing.rs:530
             at librustc/ty/maps/plumbing.rs:200
             at librustc/ty/context.rs:1844
             at librustc/ty/context.rs:1787
             at librustc/ty/context.rs:1843
             at librustc/ty/maps/plumbing.rs:199
             at librustc/ty/context.rs:1905
             at librustc/ty/context.rs:1889
             at librustc/ty/context.rs:1880
             at librustc/ty/context.rs:1889
             at librustc/ty/context.rs:1900
             at librustc/ty/maps/plumbing.rs:189
             at librustc/ty/maps/plumbing.rs:523
  35: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_get_query
             at librustc/ty/maps/plumbing.rs:372
             at librustc/ty/maps/plumbing.rs:599
  36: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::const_eval
             at librustc/ty/maps/plumbing.rs:606
             at librustc/ty/maps/plumbing.rs:776
             at librustc/ty/maps/plumbing.rs:769
  37: rustc::ty::AdtDef::eval_explicit_discr
             at /home/vegard/rust/src/librustc/ty/mod.rs:1935
  38: <rustc_typeck::collect::CollectItemTypesVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
             at librustc_typeck/collect.rs:486
             at librustc_typeck/collect.rs:388
             at librustc_typeck/collect.rs:111
  39: rustc_typeck::check_crate::{{closure}}::{{closure}}
             at /home/vegard/rust/src/librustc/hir/itemlikevisit.rs:80
             at /home/vegard/rust/src/librustc/hir/mod.rs:711
             at librustc_typeck/collect.rs:61
             at librustc_typeck/lib.rs:316
  40: rustc_typeck::check_crate
             at /home/vegard/rust/src/librustc/util/common.rs:166
             at /home/vegard/rust/src/librustc/util/common.rs:160
             at librustc_typeck/lib.rs:315
             at /home/vegard/rust/src/librustc/session/mod.rs:318
             at librustc_typeck/lib.rs:314
  41: rustc::ty::context::TyCtxt::create_and_enter
             at librustc_driver/driver.rs:1121
             at /home/vegard/rust/src/librustc/ty/context.rs:1867
             at /home/vegard/rust/src/librustc/ty/context.rs:1844
             at /home/vegard/rust/src/librustc/ty/context.rs:1787
             at /home/vegard/rust/src/librustc/ty/context.rs:1843
             at /home/vegard/rust/src/librustc/ty/context.rs:1866
             at /home/vegard/rust/src/librustc/ty/context.rs:1833
             at /home/vegard/rust/src/libstd/thread/local.rs:294
             at /home/vegard/rust/src/libstd/thread/local.rs:248
             at /home/vegard/rust/src/librustc/ty/context.rs:1825
             at /home/vegard/rust/src/libstd/thread/local.rs:294
             at /home/vegard/rust/src/libstd/thread/local.rs:248
             at /home/vegard/rust/src/librustc/ty/context.rs:1817
             at /home/vegard/rust/src/librustc/ty/context.rs:1855
             at /home/vegard/rust/src/librustc/ty/context.rs:1299
  42: rustc_driver::driver::compile_input
             at librustc_driver/driver.rs:1095
             at librustc_driver/driver.rs:231
  43: rustc_driver::run_compiler
             at librustc_driver/lib.rs:540
             at librustc_driver/lib.rs:457
             at /home/vegard/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.1/src/lib.rs:155
             at /home/vegard/rust/src/libsyntax/lib.rs:97
             at /home/vegard/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.1/src/lib.rs:155
             at /home/vegard/rust/src/libsyntax/lib.rs:96
             at librustc_driver/lib.rs:456
  44: rustc_driver::monitor::{{closure}}
             at librustc_driver/lib.rs:1684
             at librustc_driver/lib.rs:174
             at librustc_driver/lib.rs:1598
  45: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:105
  46: rustc_driver::run
             at /home/vegard/rust/src/libstd/panicking.rs:289
             at /home/vegard/rust/src/libstd/panic.rs:374
             at librustc_driver/lib.rs:1530
             at librustc_driver/lib.rs:1597
             at librustc_driver/lib.rs:173
  47: rustc_driver::main
             at librustc_driver/lib.rs:1677
  48: std::rt::lang_start::{{closure}}
             at /home/vegard/rust/src/libstd/rt.rs:74
  49: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  50: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:105
  51: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:374
             at libstd/rt.rs:58
  52: main
  53: __libc_start_main
  54: _start
query stack during panic:
#0 [check_match] processing `main::Foo::Drop::{{initializer}}`
#1 [const_eval] const-evaluating `main::Foo::Drop::{{initializer}}`
end of query stack
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0317`.

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: rustc 1.27.0-dev running on x86_64-unknown-linux-gnu

note: compiler flags: -Z external-macro-backtrace

Running on commit c166b03.

@pietroalbini pietroalbini added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 9, 2018
@estebank estebank self-assigned this Jun 25, 2018
pietroalbini added a commit to pietroalbini/rust that referenced this issue Jun 26, 2018
Don't ICE when performing `lower_pattern_unadjusted` on a `TyError`

Fix rust-lang#50577. CC rust-lang#51696.

r? @oli-obk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ 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

3 participants