@@ -709,20 +709,26 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
709709 if !is_const {
710710 v. add_qualif ( ConstQualif :: NOT_CONST ) ;
711711 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+
712716 // FIXME(#24111) Remove this check when const fn stabilizes
713717 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( ) ) ) ;
717722 v. tcx . sess . span_note ( e. span ,
718723 "a limited form of compile-time function \
719724 evaluation is available on a nightly \
720725 compiler via `const fn`") ;
721726 } 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( ) ) ) ;
726732 }
727733 }
728734 }
0 commit comments