about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-12-03 04:39:48 +0000
committerbors <bors@rust-lang.org>2024-12-03 04:39:48 +0000
commitefdd9e802053caeb52103945df858e87f837e59a (patch)
treeba16a8a78b5db2b43298849d14d711b20cc444b9 /compiler/rustc_const_eval/src
parent41cbe3e4d1ef8de310fbbd77043082960def9446 (diff)
parent01ff36a6b9e9134421c4e353ccbc904fdfe53be6 (diff)
downloadrust-efdd9e802053caeb52103945df858e87f837e59a.tar.gz
rust-efdd9e802053caeb52103945df858e87f837e59a.zip
Auto merge of #133321 - compiler-errors:const-checker, r=wesleywiser
Get rid of HIR const checker

As far as I can tell, the HIR const checker was implemented in https://github.com/rust-lang/rust/pull/66170 because we were not able to issue useful const error messages in the MIR const checker.

This seems to have changed in the last 5 years, probably due to work like #90532. I've tweaked the diagnostics slightly and think the error messages have gotten *better* in fact.

Thus I think the HIR const checker has reached the end of its usefulness, and we can retire it.

cc `@RalfJung`
Diffstat (limited to 'compiler/rustc_const_eval/src')
-rw-r--r--compiler/rustc_const_eval/src/check_consts/ops.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/compiler/rustc_const_eval/src/check_consts/ops.rs b/compiler/rustc_const_eval/src/check_consts/ops.rs
index ab81e60a33f..489bb54a6f9 100644
--- a/compiler/rustc_const_eval/src/check_consts/ops.rs
+++ b/compiler/rustc_const_eval/src/check_consts/ops.rs
@@ -180,8 +180,10 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
                     };
                 }
 
-                let mut err = match kind {
-                    CallDesugaringKind::ForLoopIntoIter => {
+                // Don't point at the trait if this is a desugaring...
+                // FIXME(const_trait_impl): we could perhaps do this for `Iterator`.
+                match kind {
+                    CallDesugaringKind::ForLoopIntoIter | CallDesugaringKind::ForLoopNext => {
                         error!(NonConstForLoopIntoIter)
                     }
                     CallDesugaringKind::QuestionBranch => {
@@ -196,10 +198,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
                     CallDesugaringKind::Await => {
                         error!(NonConstAwait)
                     }
-                };
-
-                diag_trait(&mut err, self_ty, kind.trait_def_id(tcx));
-                err
+                }
             }
             CallKind::FnCall { fn_trait_id, self_ty } => {
                 let note = match self_ty.kind() {