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

Check has_typeck_tables before calling typeck_tables_of #69166

Merged
merged 1 commit into from
Feb 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/librustc_mir/const_eval/eval_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
15 changes: 15 additions & 0 deletions src/test/ui/consts/issue-68684.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// check-pass

enum _Enum {
A(),
}

type _E = _Enum;

const fn _a() -> _Enum {
_E::A()
}

const _A: _Enum = _a();

fn main() {}