Skip to content

Commit 57c75b6

Browse files
committed
permit const-fn in macro expansions
1 parent 710270d commit 57c75b6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/librustc/middle/check_const.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,16 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
205205
ret_ty: Ty<'tcx>)
206206
-> bool {
207207
if let Some(fn_like) = const_eval::lookup_const_fn_by_id(self.tcx, def_id) {
208-
if self.mode != Mode::Var && !self.tcx.sess.features.borrow().const_fn {
208+
if
209+
// we are in a static/const initializer
210+
self.mode != Mode::Var &&
211+
212+
// feature-gate is not enabled
213+
!self.tcx.sess.features.borrow().const_fn &&
214+
215+
// this doesn't come from a macro that has #[allow_internal_unstable]
216+
!self.tcx.sess.codemap().span_allows_unstable(expr.span)
217+
{
209218
self.tcx.sess.span_err(
210219
expr.span,
211220
&format!("const fns are an unstable feature"));

0 commit comments

Comments
 (0)