@@ -24,7 +24,7 @@ use std::ops::Deref;
24
24
use super :: ops:: { self , NonConstOp , Status } ;
25
25
use super :: qualifs:: { self , CustomEq , HasMutInterior , NeedsDrop , NeedsNonConstDrop } ;
26
26
use super :: resolver:: FlowSensitiveAnalysis ;
27
- use super :: { is_lang_panic_fn , is_lang_special_const_fn , ConstCx , Qualif } ;
27
+ use super :: { ConstCx , Qualif } ;
28
28
use crate :: const_eval:: is_unstable_const_fn;
29
29
30
30
// We are using `MaybeMutBorrowedLocals` as a proxy for whether an item may have been mutated
@@ -918,31 +918,27 @@ impl Visitor<'tcx> for Checker<'mir, 'tcx> {
918
918
}
919
919
920
920
// At this point, we are calling a function, `callee`, whose `DefId` is known...
921
- if is_lang_special_const_fn ( tcx, callee) {
922
- // `begin_panic` and `panic_display` are generic functions that accept
923
- // types other than str. Check to enforce that only str can be used in
924
- // const-eval.
925
-
926
- // const-eval of the `begin_panic` fn assumes the argument is `&str`
927
- if Some ( callee) == tcx. lang_items ( ) . begin_panic_fn ( ) {
928
- match args[ 0 ] . ty ( & self . ccx . body . local_decls , tcx) . kind ( ) {
929
- ty:: Ref ( _, ty, _) if ty. is_str ( ) => ( ) ,
930
- _ => self . check_op ( ops:: PanicNonStr ) ,
931
- }
932
- }
933
921
934
- // const-eval of the `panic_display` fn assumes the argument is `&&str`
935
- if Some ( callee) == tcx. lang_items ( ) . panic_display ( ) {
936
- match args[ 0 ] . ty ( & self . ccx . body . local_decls , tcx) . kind ( ) {
937
- ty:: Ref ( _, ty, _) if matches ! ( ty. kind( ) , ty:: Ref ( _, ty, _) if ty. is_str( ) ) =>
938
- { }
939
- _ => self . check_op ( ops:: PanicNonStr ) ,
940
- }
922
+ // `begin_panic` and `panic_display` are generic functions that accept
923
+ // types other than str. Check to enforce that only str can be used in
924
+ // const-eval.
925
+
926
+ // const-eval of the `begin_panic` fn assumes the argument is `&str`
927
+ if Some ( callee) == tcx. lang_items ( ) . begin_panic_fn ( ) {
928
+ match args[ 0 ] . ty ( & self . ccx . body . local_decls , tcx) . kind ( ) {
929
+ ty:: Ref ( _, ty, _) if ty. is_str ( ) => return ,
930
+ _ => self . check_op ( ops:: PanicNonStr ) ,
941
931
}
932
+ }
942
933
943
- if is_lang_panic_fn ( tcx, callee) {
944
- // run stability check on non-panic special const fns.
945
- return ;
934
+ // const-eval of the `panic_display` fn assumes the argument is `&&str`
935
+ if Some ( callee) == tcx. lang_items ( ) . panic_display ( ) {
936
+ match args[ 0 ] . ty ( & self . ccx . body . local_decls , tcx) . kind ( ) {
937
+ ty:: Ref ( _, ty, _) if matches ! ( ty. kind( ) , ty:: Ref ( _, ty, _) if ty. is_str( ) ) =>
938
+ {
939
+ return ;
940
+ }
941
+ _ => self . check_op ( ops:: PanicNonStr ) ,
946
942
}
947
943
}
948
944
0 commit comments