Closed
Description
Compiler say it's a bug :note: the compiler unexpectedly panicked. this is a bug.
I tried this code:
fn main() {
let x:i32 = 0;
let square = Functions::Square;
println!("x square is {}", square(x));
}
enum Functions{
Square = |x:i32|{x*x},
}
Meta
Compiling advanced_function v0.1.0 (file:///C:/Users/tt/IdeaProjects/advanced_function)
error: internal compiler error: src\librustc_typeck\check\mod.rs:820: can't type-check body of DefId(0/0:4 ~ advanced_function[1c36]::Functions[0])
--> src\main.rs:13:1
|
13 | / enum Functions{
14 | | Square = |x:i32|{x*x},
15 | | }
| |_^
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.24.1 (d3ae9a9e0 2018-02-27) running on x86_64-pc-windows-msvc
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', src\librustc_errors\lib.rs:451:9
stack backtrace:
0: <std::sync::condvar::WaitTimeoutResult as core::fmt::Debug>::fmt
1: <std::time::SystemTimeError as core::fmt::Display>::fmt
2: std::panicking::Location::column
3: std::panicking::Location::column
4: std::panicking::rust_panic_with_hook
5: <rustc_typeck::check::method::probe::ProbeScope as core::fmt::Debug>::fmt
6: <rustc_typeck::constrained_type_params::Parameter as core::fmt::Debug>::fmt
7: <rustc::hir::Arm as rustc_typeck::check::coercion::AsCoercionSite>::as_coercion_site
8: <rustc_typeck::check::upvar::InferBorrowKindVisitor<'a, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::nested_visit_map
9: <rustc_typeck::check::op::Op as core::fmt::Debug>::fmt
10: <rustc_typeck::check::CheckItemTypesVisitor<'a, 'tcx> as rustc::hir::itemlikevisit::ItemLikeVisitor<'tcx>>::visit_item
11: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::ensure
12: rustc::dep_graph::graph::DepGraph::in_ignore
13: rustc::util::ppaux::<impl core::fmt::Debug for rustc::ty::Predicate<'tcx>>::fmt
14: <rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx> as rustc::ty::layout::HasTyCtxt<'gcx>>::tcx
15: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::ensure
16: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::try_get
17: rustc::ty::maps::TyCtxtAt::typeck_tables_of
18: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_tables_of
19: <rustc_typeck::check::CheckItemTypesVisitor<'a, 'tcx> as rustc::hir::itemlikevisit::ItemLikeVisitor<'tcx>>::visit_item
20: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::ensure
21: rustc::dep_graph::graph::DepGraph::in_ignore
22: rustc::util::ppaux::<impl core::fmt::Debug for rustc::ty::Predicate<'tcx>>::fmt
23: <rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx> as rustc::ty::layout::HasTyCtxt<'gcx>>::tcx
24: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::ensure
25: rustc::ty::maps::<impl rustc::ty::maps::queries::typeck_tables_of<'tcx>>::try_get
26: rustc::ty::maps::TyCtxtAt::typeck_tables_of
27: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::typeck_tables_of
28: rustc_mir::interpret::const_eval::const_eval_provider
29: rustc::ty::maps::<impl rustc::ty::maps::queries::const_eval<'tcx>>::ensure
30: rustc::dep_graph::graph::DepGraph::in_ignore
31: rustc::util::ppaux::<impl core::fmt::Debug for rustc::ty::Predicate<'tcx>>::fmt
32: <rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx> as rustc::ty::layout::HasTyCtxt<'gcx>>::tcx
33: rustc::ty::maps::<impl rustc::ty::maps::queries::const_eval<'tcx>>::ensure
34: rustc::ty::maps::<impl rustc::ty::maps::queries::const_eval<'tcx>>::try_get
35: rustc::ty::maps::TyCtxtAt::const_eval
36: <rustc_typeck::collect::CollectItemTypesVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
37: <unknown>
38: rustc_typeck::check_crate
39: rustc_driver::profile::dump
40: rustc_driver::profile::dump
41: <rustc_driver::Compilation as core::fmt::Debug>::fmt
42: rustc_driver::driver::compile_input
43: rustc_driver::run_compiler
44: rustc_driver::profile::dump
45: _rust_maybe_catch_panic
46: <rustc_driver::pretty::UserIdentifiedItem as core::fmt::Debug>::fmt
47: <std::sync::condvar::Condvar as core::fmt::Debug>::fmt
48: std::sys::windows::thread::Thread::new
49: BaseThreadInitThunk
error: Could not compile `advanced_function`.
To learn more, run the command again with --verbose.
Process finished with exit code 101