diff options
| author | Deadbeef <ent3rm4n@gmail.com> | 2021-12-30 19:45:20 +0800 |
|---|---|---|
| committer | Deadbeef <ent3rm4n@gmail.com> | 2021-12-30 20:13:55 +0800 |
| commit | 7fd6ddfba2da259cd5c4232ff32e4c14a54a0e60 (patch) | |
| tree | 53c63854f2fec461a6274f14c9757f80a472524d /compiler/rustc_const_eval/src/transform | |
| parent | 7ae550842635dce84811198446fe87e830de500b (diff) | |
| download | rust-7fd6ddfba2da259cd5c4232ff32e4c14a54a0e60.tar.gz rust-7fd6ddfba2da259cd5c4232ff32e4c14a54a0e60.zip | |
Error when selected impl is not const in constck
Diffstat (limited to 'compiler/rustc_const_eval/src/transform')
| -rw-r--r-- | compiler/rustc_const_eval/src/transform/check_consts/check.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/rustc_const_eval/src/transform/check_consts/check.rs b/compiler/rustc_const_eval/src/transform/check_consts/check.rs index 1d5f4630152..f3e9f4bfc97 100644 --- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs +++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs @@ -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, }), ); @@ -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) |
