@@ -24,7 +24,7 @@ use std::ops::Deref;
2424use super :: ops:: { self , NonConstOp , Status } ;
2525use super :: qualifs:: { self , CustomEq , HasMutInterior , NeedsDrop , NeedsNonConstDrop } ;
2626use super :: resolver:: FlowSensitiveAnalysis ;
27- use super :: { is_lang_panic_fn , is_lang_special_const_fn , ConstCx , Qualif } ;
27+ use super :: { ConstCx , Qualif } ;
2828use crate :: const_eval:: is_unstable_const_fn;
2929
3030// 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> {
918918 }
919919
920920 // 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- }
933921
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 ) ,
941931 }
932+ }
942933
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 ) ,
946942 }
947943 }
948944
0 commit comments