Skip to content

Commit

Permalink
ty: use delay_span_bug in ty::AdtDef::eval_explicit_discr.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed May 2, 2020
1 parent 7184d13 commit 50c63e4
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions src/librustc_middle/ty/mod.rs
Expand Up @@ -2388,21 +2388,14 @@ impl<'tcx> AdtDef {
None
}
}
Err(ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted) => {
if !expr_did.is_local() {
span_bug!(
tcx.def_span(expr_did),
"variant discriminant evaluation succeeded \
in its crate but failed locally"
);
}
None
}
Err(ErrorHandled::TooGeneric) => {
tcx.sess.delay_span_bug(
tcx.def_span(expr_did),
"enum discriminant depends on generic arguments",
);
Err(err) => {
let msg = match err {
ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted => {
"enum discriminant evaluation failed"
}
ErrorHandled::TooGeneric => "enum discriminant depends on generics",
};
tcx.sess.delay_span_bug(tcx.def_span(expr_did), msg);
None
}
}
Expand Down

0 comments on commit 50c63e4

Please sign in to comment.