Add const_fn_floating_point_arithmetic
This commit is contained in:
parent
5bfeee5fe0
commit
0d2521aaf7
3 changed files with 28 additions and 0 deletions
|
@ -112,6 +112,30 @@ impl NonConstOp for Abort {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct FloatingPointOp;
|
||||
impl NonConstOp for FloatingPointOp {
|
||||
const STOPS_CONST_CHECKING: bool = true;
|
||||
|
||||
fn status_in_item(&self, ccx: &ConstCx<'_, '_>) -> Status {
|
||||
if ccx.const_kind() == hir::ConstContext::ConstFn {
|
||||
Status::Unstable(sym::const_fn_floating_point_arithmetic)
|
||||
} else {
|
||||
Status::Allowed
|
||||
}
|
||||
}
|
||||
|
||||
fn emit_error(&self, ccx: &ConstCx<'_, '_>, span: Span) {
|
||||
feature_err(
|
||||
&ccx.tcx.sess.parse_sess,
|
||||
sym::const_fn_floating_point_arithmetic,
|
||||
span,
|
||||
&format!("floating point arithmetic is not allowed in {}s", ccx.const_kind()),
|
||||
)
|
||||
.emit();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct NonPrimitiveOp;
|
||||
impl NonConstOp for NonPrimitiveOp {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue