File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed
compiler/rustc_mir/src/transform/check_consts Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -897,16 +897,19 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
897897 permitted = true ;
898898 }
899899 }
900- let mut const_impls = true ;
901- tcx. for_each_relevant_impl ( trait_id, substs. type_at ( 0 ) , |imp| {
902- if const_impls {
903- if let hir:: Constness :: NotConst = tcx. impl_constness ( imp) {
904- const_impls = false ;
900+ if !permitted {
901+ // if trait's impls are all const, permit the call.
902+ let mut const_impls = true ;
903+ tcx. for_each_relevant_impl ( trait_id, substs. type_at ( 0 ) , |imp| {
904+ if const_impls {
905+ if let hir:: Constness :: NotConst = tcx. impl_constness ( imp) {
906+ const_impls = false ;
907+ }
905908 }
909+ } ) ;
910+ if const_impls {
911+ permitted = true ;
906912 }
907- } ) ;
908- if const_impls {
909- permitted = true ;
910913 }
911914 }
912915
You can’t perform that action at this time.
0 commit comments