Skip to content

Commit

Permalink
Iterate through impls only when permitted
Browse files Browse the repository at this point in the history
  • Loading branch information
fee1-dead committed Jul 19, 2021
1 parent 77d1559 commit d05a286
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions compiler/rustc_mir/src/transform/check_consts/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -897,16 +897,19 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
permitted = true;
}
}
let mut const_impls = true;
tcx.for_each_relevant_impl(trait_id, substs.type_at(0), |imp| {
if const_impls {
if let hir::Constness::NotConst = tcx.impl_constness(imp) {
const_impls = false;
if !permitted {
// if trait's impls are all const, permit the call.
let mut const_impls = true;
tcx.for_each_relevant_impl(trait_id, substs.type_at(0), |imp| {
if const_impls {
if let hir::Constness::NotConst = tcx.impl_constness(imp) {
const_impls = false;
}
}
});
if const_impls {
permitted = true;
}
});
if const_impls {
permitted = true;
}
}

Expand Down

0 comments on commit d05a286

Please sign in to comment.