about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src
diff options
context:
space:
mode:
authorDeadbeef <ent3rm4n@gmail.com>2022-01-28 19:59:06 +1100
committerDeadbeef <ent3rm4n@gmail.com>2022-02-12 19:24:43 +1100
commitcccf4b2fc3199f9647f8a4602964e0021d90eeea (patch)
tree9849b75a504c636b6c5d938b0b3788afd01d2543 /compiler/rustc_const_eval/src
parentd3acb9d00e64d68d8c91c9d9925b92cd79b33379 (diff)
downloadrust-cccf4b2fc3199f9647f8a4602964e0021d90eeea.tar.gz
rust-cccf4b2fc3199f9647f8a4602964e0021d90eeea.zip
Adapt new change
Diffstat (limited to 'compiler/rustc_const_eval/src')
-rw-r--r--compiler/rustc_const_eval/src/transform/check_consts/check.rs15
1 files changed, 11 insertions, 4 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 bd16a8853a6..2fd814c129c 100644
--- a/compiler/rustc_const_eval/src/transform/check_consts/check.rs
+++ b/compiler/rustc_const_eval/src/transform/check_consts/check.rs
@@ -832,10 +832,6 @@ 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)
@@ -847,6 +843,17 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
                                 substs = InternalSubsts::identity_for_item(tcx, did);
                                 callee = did;
                             }
+
+                            if let hir::Constness::NotConst = tcx.impl_constness(data.impl_def_id) {
+                                self.check_op(ops::FnCallNonConst {
+                                    caller,
+                                    callee,
+                                    substs,
+                                    span: *fn_span,
+                                    from_hir_call: *from_hir_call,
+                                });
+                                return;
+                            }
                         }
                         _ if !tcx.is_const_fn_raw(callee) => {
                             // At this point, it is only legal when the caller is marked with