Skip to content

Commit b8c8287

Browse files
committedNov 3, 2024
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`
·
1.88.01.84.0
2 parents e3a918e + 6b96103 commit b8c8287

File tree

221 files changed

+370
-1025
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

221 files changed

+370
-1025
lines changed
 

‎compiler/rustc_ast_passes/src/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,8 +594,8 @@ pub(crate) struct ConstBoundTraitObject {
594594
pub span: Span,
595595
}
596596

597-
// FIXME(effects): Consider making the note/reason the message of the diagnostic.
598-
// FIXME(effects): Provide structured suggestions (e.g., add `const` / `#[const_trait]` here).
597+
// FIXME(const_trait_impl): Consider making the note/reason the message of the diagnostic.
598+
// FIXME(const_trait_impl): Provide structured suggestions (e.g., add `const` / `#[const_trait]` here).
599599
#[derive(Diagnostic)]
600600
#[diag(ast_passes_tilde_const_disallowed)]
601601
pub(crate) struct TildeConstDisallowed {

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

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use rustc_mir_dataflow::Analysis;
2020
use rustc_mir_dataflow::impls::MaybeStorageLive;
2121
use rustc_mir_dataflow::storage::always_storage_live_locals;
2222
use rustc_span::{Span, Symbol, sym};
23-
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
2423
use rustc_trait_selection::traits::{
2524
Obligation, ObligationCause, ObligationCauseCode, ObligationCtxt,
2625
};
@@ -419,13 +418,8 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
419418

420419
let errors = ocx.select_all_or_error();
421420
if !errors.is_empty() {
422-
// FIXME(effects): Soon this should be unconditionally delaying a bug.
423-
if matches!(call_source, CallSource::Normal) && tcx.features().effects() {
424-
tcx.dcx()
425-
.span_delayed_bug(call_span, "this should have reported a ~const error in HIR");
426-
} else {
427-
infcx.err_ctxt().report_fulfillment_errors(errors);
428-
}
421+
tcx.dcx()
422+
.span_delayed_bug(call_span, "this should have reported a ~const error in HIR");
429423
}
430424
}
431425
}
@@ -663,8 +657,9 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
663657
// typeck ensures the conditions for calling a const trait method are met,
664658
// so we only error if the trait isn't const. We try to resolve the trait
665659
// into the concrete method, and uses that for const stability checks.
666-
// FIXME(effects) we might consider moving const stability checks to typeck as well.
667-
if tcx.features().effects() && trait_is_const {
660+
// FIXME(const_trait_impl) we might consider moving const stability checks
661+
// to typeck as well.
662+
if tcx.features().const_trait_impl() && trait_is_const {
668663
// This skips the check below that ensures we only call `const fn`.
669664
is_trait = true;
670665

0 commit comments

Comments
 (0)
Please sign in to comment.