@@ -242,7 +242,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
242
242
// impl trait is gone in MIR, so check the return type of a const fn by its signature
243
243
// instead of the type of the return place.
244
244
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 ( ) ;
246
246
self . check_local_or_return_ty ( return_ty. skip_binder ( ) , RETURN_PLACE ) ;
247
247
}
248
248
@@ -730,6 +730,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
730
730
substs,
731
731
span : * fn_span,
732
732
from_hir_call : * from_hir_call,
733
+ feature : Some ( sym:: const_trait_impl) ,
733
734
} ) ;
734
735
return ;
735
736
}
@@ -782,6 +783,20 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
782
783
) ;
783
784
return ;
784
785
}
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
+ }
785
800
Ok ( Some ( ImplSource :: UserDefined ( data) ) ) => {
786
801
let callee_name = tcx. item_name ( callee) ;
787
802
if let Some ( & did) = tcx
@@ -802,6 +817,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
802
817
substs,
803
818
span : * fn_span,
804
819
from_hir_call : * from_hir_call,
820
+ feature : None ,
805
821
} ) ;
806
822
return ;
807
823
}
@@ -844,6 +860,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
844
860
substs,
845
861
span : * fn_span,
846
862
from_hir_call : * from_hir_call,
863
+ feature : None ,
847
864
} ) ;
848
865
return ;
849
866
}
@@ -903,6 +920,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
903
920
substs,
904
921
span : * fn_span,
905
922
from_hir_call : * from_hir_call,
923
+ feature : None ,
906
924
} ) ;
907
925
return ;
908
926
}
0 commit comments