Avoid some duplicated typechecking work
There was a FIXME noting that ty::enum_variants and typeck::check:: check_enum_variants both call eval_const_expr. I tried refactoring the code so that check_enum_variants does all the work and enum_variants just looks up cached results, but this turned out not to be easy because several ty functions call enum_variants and it might get invoked on an enum before that enum item has been typechecked. Instead, I just made check_enum_variants update the enum_var_cache so that enum_variants will never call eval_const_expr twice on the same const.
Showing
想要评论请 注册 或 登录