@@ -39,6 +39,7 @@ use util::nodemap::NodeMap;
39
39
use rustc_front:: hir;
40
40
use syntax:: ast;
41
41
use syntax:: codemap:: Span ;
42
+ use syntax:: feature_gate:: UnstableFeatures ;
42
43
use rustc_front:: visit:: { self , FnKind , Visitor } ;
43
44
44
45
use std:: collections:: hash_map:: Entry ;
@@ -709,10 +710,21 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
709
710
if !is_const {
710
711
v. add_qualif ( ConstQualif :: NOT_CONST ) ;
711
712
if v. mode != Mode :: Var {
712
- span_err ! ( v. tcx. sess, e. span, E0015 ,
713
- "function calls in {}s are limited to \
714
- constant functions, \
715
- struct and enum constructors", v. msg( ) ) ;
713
+ // FIXME(#24111) Remove this check when const fn stabilizes
714
+ if let UnstableFeatures :: Disallow = v. tcx . sess . opts . unstable_features {
715
+ span_err ! ( v. tcx. sess, e. span, E0015 ,
716
+ "function calls in {}s are limited to \
717
+ struct and enum constructors", v. msg( ) ) ;
718
+ v. tcx . sess . span_note ( e. span ,
719
+ "a limited form of compile-time function \
720
+ evaluation is available on a nightly \
721
+ compiler via `const fn`") ;
722
+ } else {
723
+ span_err ! ( v. tcx. sess, e. span, E0015 ,
724
+ "function calls in {}s are limited to \
725
+ constant functions, \
726
+ struct and enum constructors", v. msg( ) ) ;
727
+ }
716
728
}
717
729
}
718
730
}
0 commit comments