@@ -242,7 +242,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
242242 // impl trait is gone in MIR, so check the return type of a const fn by its signature
243243 // instead of the type of the return place.
244244 self . span = body. local_decls [ RETURN_PLACE ] . source_info . span ;
245- let return_ty = tcx . fn_sig ( def_id ) . output ( ) ;
245+ let return_ty = self . ccx . fn_sig ( ) . output ( ) ;
246246 self . check_local_or_return_ty ( return_ty. skip_binder ( ) , RETURN_PLACE ) ;
247247 }
248248
@@ -730,6 +730,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
730730 substs,
731731 span : * fn_span,
732732 from_hir_call : * from_hir_call,
733+ feature : Some ( sym:: const_trait_impl) ,
733734 } ) ;
734735 return ;
735736 }
@@ -782,6 +783,20 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
782783 ) ;
783784 return ;
784785 }
786+ Ok ( Some ( ImplSource :: Closure ( data) ) ) => {
787+ if !tcx. is_const_fn_raw ( data. closure_def_id ) {
788+ self . check_op ( ops:: FnCallNonConst {
789+ caller,
790+ callee,
791+ substs,
792+ span : * fn_span,
793+ from_hir_call : * from_hir_call,
794+ feature : None ,
795+ } ) ;
796+
797+ return ;
798+ }
799+ }
785800 Ok ( Some ( ImplSource :: UserDefined ( data) ) ) => {
786801 let callee_name = tcx. item_name ( callee) ;
787802 if let Some ( & did) = tcx
@@ -802,6 +817,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
802817 substs,
803818 span : * fn_span,
804819 from_hir_call : * from_hir_call,
820+ feature : None ,
805821 } ) ;
806822 return ;
807823 }
@@ -844,6 +860,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
844860 substs,
845861 span : * fn_span,
846862 from_hir_call : * from_hir_call,
863+ feature : None ,
847864 } ) ;
848865 return ;
849866 }
@@ -903,6 +920,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
903920 substs,
904921 span : * fn_span,
905922 from_hir_call : * from_hir_call,
923+ feature : None ,
906924 } ) ;
907925 return ;
908926 }
0 commit comments