@@ -709,20 +709,26 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
709
709
if !is_const {
710
710
v. add_qualif ( ConstQualif :: NOT_CONST ) ;
711
711
if v. mode != Mode :: Var {
712
+ fn span_limited_call_error ( tcx : & ty:: ctxt , span : Span , s : & str ) {
713
+ span_err ! ( tcx. sess, span, E0015 , "{}" , s) ;
714
+ }
715
+
712
716
// FIXME(#24111) Remove this check when const fn stabilizes
713
717
if let UnstableFeatures :: Disallow = v. tcx . sess . opts . unstable_features {
714
- span_err ! ( v. tcx. sess, e. span, E0015 ,
715
- "function calls in {}s are limited to \
716
- struct and enum constructors", v. msg( ) ) ;
718
+ span_limited_call_error ( & v. tcx , e. span ,
719
+ & format ! ( "function calls in {}s are limited to \
720
+ struct and enum constructors",
721
+ v. msg( ) ) ) ;
717
722
v. tcx . sess . span_note ( e. span ,
718
723
"a limited form of compile-time function \
719
724
evaluation is available on a nightly \
720
725
compiler via `const fn`") ;
721
726
} else {
722
- span_err ! ( v. tcx. sess, e. span, E0015 ,
723
- "function calls in {}s are limited to \
724
- constant functions, \
725
- struct and enum constructors", v. msg( ) ) ;
727
+ span_limited_call_error ( & v. tcx , e. span ,
728
+ & format ! ( "function calls in {}s are limited \
729
+ to constant functions, \
730
+ struct and enum constructors",
731
+ v. msg( ) ) ) ;
726
732
}
727
733
}
728
734
}
0 commit comments