Skip to content

Commit 7fd6ddf

Browse files
committed
Error when selected impl is not const in constck
1 parent 7ae5508 commit 7fd6ddf

File tree

1 file changed

+5
-1
lines changed
  • compiler/rustc_const_eval/src/transform/check_consts

1 file changed

+5
-1
lines changed

compiler/rustc_const_eval/src/transform/check_consts/check.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
811811
param_env,
812812
Binder::dummy(TraitPredicate {
813813
trait_ref,
814-
constness: ty::BoundConstness::ConstIfConst,
814+
constness: ty::BoundConstness::NotConst,
815815
polarity: ty::ImplPolarity::Positive,
816816
}),
817817
);
@@ -830,6 +830,10 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
830830
return;
831831
}
832832
Ok(Some(ImplSource::UserDefined(data))) => {
833+
if let hir::Constness::NotConst = tcx.impl_constness(data.impl_def_id) {
834+
self.check_op(ops::FnCallNonConst(None));
835+
return;
836+
}
833837
let callee_name = tcx.item_name(callee);
834838
if let Some(&did) = tcx
835839
.associated_item_def_ids(data.impl_def_id)

0 commit comments

Comments
 (0)