Update function pointer call error message
It now uses the type of context. (issue 97082)
This commit is contained in:
parent
c1cfdd1fb2
commit
56649bb844
2 changed files with 5 additions and 2 deletions
|
@ -89,7 +89,10 @@ impl<'tcx> NonConstOp<'tcx> for FnCallIndirect {
|
||||||
ccx: &ConstCx<'_, 'tcx>,
|
ccx: &ConstCx<'_, 'tcx>,
|
||||||
span: Span,
|
span: Span,
|
||||||
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
) -> DiagnosticBuilder<'tcx, ErrorGuaranteed> {
|
||||||
ccx.tcx.sess.struct_span_err(span, "function pointers are not allowed in const fn")
|
ccx.tcx.sess.struct_span_err(
|
||||||
|
span,
|
||||||
|
&format!("function pointer calls are not allowed in {}s", ccx.const_kind()),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ LL | const fn foo() { (||{})() }
|
||||||
= note: closures need an RFC before allowed to be called in constant functions
|
= note: closures need an RFC before allowed to be called in constant functions
|
||||||
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
|
||||||
|
|
||||||
error: function pointers are not allowed in const fn
|
error: function pointer calls are not allowed in constant functions
|
||||||
--> $DIR/issue-56164.rs:7:5
|
--> $DIR/issue-56164.rs:7:5
|
||||||
|
|
|
|
||||||
LL | input()
|
LL | input()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue