about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2015-05-28 15:18:47 -0400
committerNiko Matsakis <niko@alum.mit.edu>2015-05-29 09:42:54 -0400
commit57c75b6b10c329ed1c9c1957e98a990dd04608f2 (patch)
treed1c1fb562ad4d7256a9af22d036f428ea9831b1f
parent710270d9c0b9b9e65e606e1c6109329c93499837 (diff)
downloadrust-57c75b6b10c329ed1c9c1957e98a990dd04608f2.tar.gz
rust-57c75b6b10c329ed1c9c1957e98a990dd04608f2.zip
permit const-fn in macro expansions
-rw-r--r--src/librustc/middle/check_const.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/librustc/middle/check_const.rs b/src/librustc/middle/check_const.rs
index 390b3142e93..ff7c570284f 100644
--- a/src/librustc/middle/check_const.rs
+++ b/src/librustc/middle/check_const.rs
@@ -205,7 +205,16 @@ impl<'a, 'tcx> CheckCrateVisitor<'a, 'tcx> {
                             ret_ty: Ty<'tcx>)
                             -> bool {
         if let Some(fn_like) = const_eval::lookup_const_fn_by_id(self.tcx, def_id) {
-            if self.mode != Mode::Var && !self.tcx.sess.features.borrow().const_fn {
+            if
+                // we are in a static/const initializer
+                self.mode != Mode::Var &&
+
+                // feature-gate is not enabled
+                !self.tcx.sess.features.borrow().const_fn &&
+
+                // this doesn't come from a macro that has #[allow_internal_unstable]
+                !self.tcx.sess.codemap().span_allows_unstable(expr.span)
+            {
                 self.tcx.sess.span_err(
                     expr.span,
                     &format!("const fns are an unstable feature"));