@@ -711,8 +711,6 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
711
711
}
712
712
} ;
713
713
714
- let mut nonconst_call_permission = false ;
715
-
716
714
// Attempting to call a trait method?
717
715
if let Some ( trait_id) = tcx. trait_of_item ( callee) {
718
716
trace ! ( "attempting to call a trait method" ) ;
@@ -776,6 +774,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
776
774
_ if !tcx. is_const_fn_raw ( callee) => {
777
775
// At this point, it is only legal when the caller is in a trait
778
776
// marked with #[const_trait], and the callee is in the same trait.
777
+ let mut nonconst_call_permission = false ;
779
778
if let Some ( callee_trait) = tcx. trait_of_item ( callee)
780
779
&& tcx. has_attr ( callee_trait, sym:: const_trait)
781
780
&& Some ( callee_trait) == tcx. trait_of_item ( caller)
@@ -872,14 +871,10 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
872
871
let is_intrinsic = tcx. is_intrinsic ( callee) ;
873
872
874
873
if !tcx. is_const_fn_raw ( callee) {
875
- if tcx. is_const_default_method ( callee) {
874
+ if ! tcx. is_const_default_method ( callee) {
876
875
// To get to here we must have already found a const impl for the
877
876
// trait, but for it to still be non-const can be that the impl is
878
877
// using default method bodies.
879
- nonconst_call_permission = true ;
880
- }
881
-
882
- if !nonconst_call_permission {
883
878
self . check_op ( ops:: FnCallNonConst {
884
879
caller,
885
880
callee,
0 commit comments