Skip to content

Commit

Permalink
Error when selected impl is not const in constck
Browse files Browse the repository at this point in the history
  • Loading branch information
fee1-dead committed Dec 30, 2021
1 parent 7ae5508 commit 7fd6ddf
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
param_env,
Binder::dummy(TraitPredicate {
trait_ref,
constness: ty::BoundConstness::ConstIfConst,
constness: ty::BoundConstness::NotConst,
polarity: ty::ImplPolarity::Positive,
}),
);
Expand All @@ -830,6 +830,10 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
return;
}
Ok(Some(ImplSource::UserDefined(data))) => {
if let hir::Constness::NotConst = tcx.impl_constness(data.impl_def_id) {
self.check_op(ops::FnCallNonConst(None));
return;
}
let callee_name = tcx.item_name(callee);
if let Some(&did) = tcx
.associated_item_def_ids(data.impl_def_id)
Expand Down

0 comments on commit 7fd6ddf

Please # to comment.