File tree 1 file changed +11
-8
lines changed
compiler/rustc_mir/src/transform/check_consts
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> {
897
897
permitted = true ;
898
898
}
899
899
}
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
+ }
905
908
}
909
+ } ) ;
910
+ if const_impls {
911
+ permitted = true ;
906
912
}
907
- } ) ;
908
- if const_impls {
909
- permitted = true ;
910
913
}
911
914
}
912
915
You can’t perform that action at this time.
0 commit comments