Rollup merge of #102486 - pierwill:middle-const-eval-err, r=compiler-errors
Add diagnostic struct for const eval error in `rustc_middle` Part of #100717. r? `@ghost`
This commit is contained in:
commit
1b9014f273
@ -15,3 +15,6 @@ middle_previous_use_here =
|
||||
middle_limit_invalid =
|
||||
`limit` must be a non-negative integer
|
||||
.label = {$error_str}
|
||||
|
||||
middle_const_eval_non_int =
|
||||
constant evaluation of enum discriminant resulted in non-integer
|
||||
|
@ -48,3 +48,10 @@ pub struct LimitInvalid<'a> {
|
||||
pub value_span: Span,
|
||||
pub error_str: &'a str,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(middle::const_eval_non_int)]
|
||||
pub struct ConstEvalNonIntError {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
}
|
||||
|
@ -458,11 +458,9 @@ pub fn eval_explicit_discr(self, tcx: TyCtxt<'tcx>, expr_did: DefId) -> Option<D
|
||||
Some(Discr { val: b, ty })
|
||||
} else {
|
||||
info!("invalid enum discriminant: {:#?}", val);
|
||||
crate::mir::interpret::struct_error(
|
||||
tcx.at(tcx.def_span(expr_did)),
|
||||
"constant evaluation of enum discriminant resulted in non-integer",
|
||||
)
|
||||
.emit();
|
||||
tcx.sess.emit_err(crate::error::ConstEvalNonIntError {
|
||||
span: tcx.def_span(expr_did),
|
||||
});
|
||||
None
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user