about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src/check_consts/check.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-11-03 19:41:46 +0000
committerbors <bors@rust-lang.org>2024-11-03 19:41:46 +0000
commitb8c8287a229cd79604aa84c25e1235fc78cd5f2e (patch)
treeacfe9ecc81e736fd65eb874b781aa7c365e9c51b /compiler/rustc_const_eval/src/check_consts/check.rs
parente3a918ece026cec748fc64af5b4983095b46097e (diff)
parent6b96103bf3b0746e443f9bb86b532be2c536113a (diff)
downloadrust-b8c8287a229cd79604aa84c25e1235fc78cd5f2e.tar.gz
rust-b8c8287a229cd79604aa84c25e1235fc78cd5f2e.zip
Auto merge of #132479 - compiler-errors:fx-feat-yeet, r=fee1-dead
Yeet the `effects` feature, move it onto `const_trait_impl`

This PR merges the `effects` feature into the `const_trait_impl` feature. There's really no need to have two feature gates for one feature.

After this PR, if `const_trait_impl` **is** enabled:
* Users can use and define const traits
* `HostEffect` const conditions will be enforced on the HIR
* We re-check the predicates in MIR just to make sure that we don't "leak" anything during MIR lowering

And if `const_trait_impl` **is not** enabled:
* Users cannot use nor define const traits
* `HostEffect` const conditions are not enforced on the HIR
* We will raise a const validation error if we call a function that has any const conditions (i.e. const traits and functions with any `~const` in their where clasues)

This should be the last step for us to be able to enable const traits in the standard library. We still need to re-constify `Drop` and `Destruct` and stuff for const traits to be particularly *useful* for some cases, but this is a good step :D

r? fee1-dead
cc `@rust-lang/project-const-traits`
Diffstat (limited to 'compiler/rustc_const_eval/src/check_consts/check.rs')
-rw-r--r--compiler/rustc_const_eval/src/check_consts/check.rs15
1 files changed, 5 insertions, 10 deletions
diff --git a/compiler/rustc_const_eval/src/check_consts/check.rs b/compiler/rustc_const_eval/src/check_consts/check.rs
index 303c490d827..8cb7e02036f 100644
--- a/compiler/rustc_const_eval/src/check_consts/check.rs
+++ b/compiler/rustc_const_eval/src/check_consts/check.rs
@@ -20,7 +20,6 @@ use rustc_mir_dataflow::Analysis;
 use rustc_mir_dataflow::impls::MaybeStorageLive;
 use rustc_mir_dataflow::storage::always_storage_live_locals;
 use rustc_span::{Span, Symbol, sym};
-use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
 use rustc_trait_selection::traits::{
     Obligation, ObligationCause, ObligationCauseCode, ObligationCtxt,
 };
@@ -419,13 +418,8 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
 
         let errors = ocx.select_all_or_error();
         if !errors.is_empty() {
-            // FIXME(effects): Soon this should be unconditionally delaying a bug.
-            if matches!(call_source, CallSource::Normal) && tcx.features().effects() {
-                tcx.dcx()
-                    .span_delayed_bug(call_span, "this should have reported a ~const error in HIR");
-            } else {
-                infcx.err_ctxt().report_fulfillment_errors(errors);
-            }
+            tcx.dcx()
+                .span_delayed_bug(call_span, "this should have reported a ~const error in HIR");
         }
     }
 }
@@ -663,8 +657,9 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
                     // typeck ensures the conditions for calling a const trait method are met,
                     // so we only error if the trait isn't const. We try to resolve the trait
                     // into the concrete method, and uses that for const stability checks.
-                    // FIXME(effects) we might consider moving const stability checks to typeck as well.
-                    if tcx.features().effects() && trait_is_const {
+                    // FIXME(const_trait_impl) we might consider moving const stability checks
+                    // to typeck as well.
+                    if tcx.features().const_trait_impl() && trait_is_const {
                         // This skips the check below that ensures we only call `const fn`.
                         is_trait = true;