Skip to content

error: internal compiler error: librustc_typeck/check/mod.rs:851: can't type-check body of DefId(0/0:3 ~ rust_out[317d]::Foo[0]) #50600

Closed
@vegard

Description

@vegard

Input:

struct Foo (
        fn([u8; |x: u8| { }])
);

Output:

$ rustc -
error[E0601]: `main` function not found in crate `rust_out`

error: internal compiler error: librustc_typeck/check/mod.rs:851: can't type-check body of DefId(0/0:3 ~ rust_out[317d]::Foo[0])
 --> <anon>:1:1
  |
1 | / struct Foo (
2 | |     fn([u8; |x: u8| { }])
3 | | );
  | |__^

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_typeck::check::typeck_tables_of::{{closure}}
             at librustc_typeck/check/mod.rs:851
  15: rustc_typeck::check::typeck_tables_of
             at /home/vegard/rust/src/libcore/option.rs:376
             at librustc_typeck/check/mod.rs:850
  16: rustc::dep_graph::graph::DepGraph::with_task_impl
             at librustc/ty/maps/plumbing.rs:723
             at librustc/dep_graph/graph.rs:343
  17: 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
  18: 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
  19: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_tables_of
             at librustc/ty/maps/plumbing.rs:776
             at librustc/ty/maps/plumbing.rs:769
  20: rustc_typeck::check::typeck_tables_of
             at librustc_typeck/check/mod.rs:843
  21: rustc::dep_graph::graph::DepGraph::with_task_impl
             at librustc/ty/maps/plumbing.rs:723
             at librustc/dep_graph/graph.rs:343
  22: 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
  23: 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
  24: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_tables_of
             at librustc/ty/maps/plumbing.rs:776
             at librustc/ty/maps/plumbing.rs:769
  25: rustc_mir::interpret::const_eval::const_eval_provider
             at librustc_mir/interpret/const_eval.rs:447
  26: rustc::dep_graph::graph::DepGraph::with_task_impl
             at librustc/ty/maps/plumbing.rs:723
             at librustc/dep_graph/graph.rs:343
  27: 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
  28: 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
  29: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_const
             at librustc/ty/maps/plumbing.rs:606
             at librustc/ty/maps/plumbing.rs:776
             at librustc/ty/maps/plumbing.rs:769
             at librustc/traits/project.rs:436
  30: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
             at librustc/ty/structural_impls.rs:1176
             at librustc/ty/structural_impls.rs:857
             at librustc/traits/project.rs:346
  31: rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable<'tcx> for &'tcx rustc::ty::Slice<&'tcx rustc::ty::TyS<'tcx>>>::super_fold_with
             at librustc/ty/structural_impls.rs:890
             at librustc/ty/structural_impls.rs:776
             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/librustc_data_structures/array_vec.rs:197
             at /home/vegard/rust/src/librustc_data_structures/accumulate_vec.rs:113
             at /home/vegard/rust/src/libcore/iter/iterator.rs:1375
             at librustc/ty/structural_impls.rs:776
  32: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
             at librustc/ty/fold.rs:58
             at librustc/macros.rs:287
             at librustc/ty/fold.rs:58
             at librustc/ty/structural_impls.rs:735
             at librustc/ty/sty.rs:691
             at librustc/ty/sty.rs:685
             at librustc/ty/structural_impls.rs:735
             at librustc/ty/fold.rs:137
             at librustc/ty/structural_impls.rs:739
             at librustc/ty/structural_impls.rs:866
             at librustc/traits/project.rs:346
  33: rustc_typeck::check::Inherited::normalize_associated_types_in
             at /home/vegard/rust/src/librustc/ty/structural_impls.rs:890
             at /home/vegard/rust/src/librustc/traits/project.rs:324
             at /home/vegard/rust/src/librustc/traits/project.rs:283
             at /home/vegard/rust/src/librustc/traits/project.rs:267
             at /home/vegard/rust/src/librustc/infer/mod.rs:1358
             at librustc_typeck/check/mod.rs:677
  34: rustc_typeck::check::wfcheck::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::non_enum_variant
             at librustc_typeck/check/mod.rs:2075
             at librustc_typeck/check/wfcheck.rs:721
             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_typeck/check/wfcheck.rs:718
  35: rustc_typeck::check::wfcheck::check_item_well_formed
             at librustc_typeck/check/wfcheck.rs:121
             at librustc_typeck/check/wfcheck.rs:233
             at librustc_typeck/check/wfcheck.rs:49
             at librustc_typeck/check/mod.rs:617
             at /home/vegard/rust/src/librustc/infer/mod.rs:453
             at /home/vegard/rust/src/librustc/ty/context.rs:1578
             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:1577
             at /home/vegard/rust/src/librustc/ty/context.rs:1905
             at /home/vegard/rust/src/librustc/ty/context.rs:1889
             at /home/vegard/rust/src/librustc/ty/context.rs:1880
             at /home/vegard/rust/src/librustc/ty/context.rs:1889
             at /home/vegard/rust/src/librustc/ty/context.rs:1900
             at /home/vegard/rust/src/librustc/ty/context.rs:1570
             at /home/vegard/rust/src/librustc/infer/mod.rs:453
             at librustc_typeck/check/mod.rs:617
             at librustc_typeck/check/wfcheck.rs:47
             at librustc_typeck/check/wfcheck.rs:232
             at librustc_typeck/check/wfcheck.rs:120
  36: rustc::dep_graph::graph::DepGraph::with_task_impl
             at librustc/dep_graph/graph.rs:343
  37: 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
  38: 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
  39: rustc::ty::maps::<impl rustc::ty::maps::queries::check_item_well_formed<'tcx>>::ensure
             at librustc/ty/maps/plumbing.rs:574
             at librustc/ty/maps/plumbing.rs:740
  40: <rustc_typeck::check::wfcheck::CheckTypeWellFormedVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'v>>::visit_item
             at librustc_typeck/check/wfcheck.rs:684
  41: rustc_typeck::check_crate::{{closure}}
             at /home/vegard/rust/src/librustc/hir/itemlikevisit.rs:80
             at /home/vegard/rust/src/librustc/hir/mod.rs:711
             at librustc_typeck/check/mod.rs:695
             at /home/vegard/rust/src/librustc/session/mod.rs:318
             at librustc_typeck/check/mod.rs:693
             at librustc_typeck/lib.rs:340
  42: 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:340
  43: 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
  44: rustc_driver::driver::compile_input
             at librustc_driver/driver.rs:1095
             at librustc_driver/driver.rs:231
  45: 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
  46: rustc_driver::monitor::{{closure}}
             at librustc_driver/lib.rs:1684
             at librustc_driver/lib.rs:174
             at librustc_driver/lib.rs:1598
  47: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:105
  48: 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
  49: rustc_driver::main
             at librustc_driver/lib.rs:1677
  50: std::rt::lang_start::{{closure}}
             at /home/vegard/rust/src/libstd/rt.rs:74
  51: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:310
  52: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:105
  53: std::rt::lang_start_internal
             at libstd/panicking.rs:289
             at libstd/panic.rs:374
             at libstd/rt.rs:58
  54: main
  55: __libc_start_main
  56: _start
query stack during panic:
#0 [typeck_tables_of] processing `Foo`
#1 [typeck_tables_of] processing `Foo::{{closure}}`
#2 [const_eval] const-evaluating `Foo::{{closure}}`
#3 [check_item_well_formed] processing `Foo`
end of query stack
error: aborting due to 2 previous errors

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

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

Running on commit c166b03.

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions