From be92200af7ac732063500a96890ed0354dcc490b Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Fri, 14 Feb 2020 21:49:57 +0900 Subject: [PATCH] Check `has_typeck_tables` before calling `typeck_tables_of` --- src/librustc_mir/const_eval/eval_queries.rs | 5 ++++- src/test/ui/consts/issue-68684.rs | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/consts/issue-68684.rs diff --git a/src/librustc_mir/const_eval/eval_queries.rs b/src/librustc_mir/const_eval/eval_queries.rs index 2e8e4dac237..4fdabed54b8 100644 --- a/src/librustc_mir/const_eval/eval_queries.rs +++ b/src/librustc_mir/const_eval/eval_queries.rs @@ -288,7 +288,10 @@ pub fn const_eval_raw_provider<'tcx>( let cid = key.value; let def_id = cid.instance.def.def_id(); - if def_id.is_local() && tcx.typeck_tables_of(def_id).tainted_by_errors { + if def_id.is_local() + && tcx.has_typeck_tables(def_id) + && tcx.typeck_tables_of(def_id).tainted_by_errors + { return Err(ErrorHandled::Reported); } diff --git a/src/test/ui/consts/issue-68684.rs b/src/test/ui/consts/issue-68684.rs new file mode 100644 index 00000000000..c98f199b60e --- /dev/null +++ b/src/test/ui/consts/issue-68684.rs @@ -0,0 +1,15 @@ +// check-pass + +enum _Enum { + A(), +} + +type _E = _Enum; + +const fn _a() -> _Enum { + _E::A() +} + +const _A: _Enum = _a(); + +fn main() {}