mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Add diagnostic struct for const eval error in rustc_middle
Co-authored-by: Michael Goulet <michael@errs.io>
This commit is contained in:
parent
f47e9af824
commit
b9c0467e0c
@ -15,3 +15,6 @@ middle_previous_use_here =
|
|||||||
middle_limit_invalid =
|
middle_limit_invalid =
|
||||||
`limit` must be a non-negative integer
|
`limit` must be a non-negative integer
|
||||||
.label = {$error_str}
|
.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 value_span: Span,
|
||||||
pub error_str: &'a str,
|
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 @@ impl<'tcx> AdtDef<'tcx> {
|
|||||||
Some(Discr { val: b, ty })
|
Some(Discr { val: b, ty })
|
||||||
} else {
|
} else {
|
||||||
info!("invalid enum discriminant: {:#?}", val);
|
info!("invalid enum discriminant: {:#?}", val);
|
||||||
crate::mir::interpret::struct_error(
|
tcx.sess.emit_err(crate::error::ConstEvalNonIntError {
|
||||||
tcx.at(tcx.def_span(expr_did)),
|
span: tcx.def_span(expr_did),
|
||||||
"constant evaluation of enum discriminant resulted in non-integer",
|
});
|
||||||
)
|
|
||||||
.emit();
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user