Skip to content

Commit b8c8287

Browse files
committed
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`
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

compiler/rustc_const_eval/src/check_consts/ops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
120120
let implsrc = selcx.select(&obligation);
121121

122122
if let Ok(Some(ImplSource::UserDefined(data))) = implsrc {
123-
// FIXME(effects) revisit this
123+
// FIXME(const_trait_impl) revisit this
124124
if !tcx.is_const_trait_impl(data.impl_def_id) {
125125
let span = tcx.def_span(data.impl_def_id);
126126
err.subdiagnostic(errors::NonConstImplNote { span });

compiler/rustc_const_eval/src/check_consts/qualifs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl Qualif for NeedsNonConstDrop {
192192
return false;
193193
}
194194

195-
// FIXME(effects): Reimplement const drop checking.
195+
// FIXME(const_trait_impl): Reimplement const drop checking.
196196
NeedsDrop::in_any_value_of_ty(cx, ty)
197197
}
198198

compiler/rustc_const_eval/src/const_eval/machine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
431431
// sensitive check here. But we can at least rule out functions that are not const at
432432
// all. That said, we have to allow calling functions inside a trait marked with
433433
// #[const_trait]. These *are* const-checked!
434-
// FIXME(effects): why does `is_const_fn` not classify them as const?
434+
// FIXME(const_trait_impl): why does `is_const_fn` not classify them as const?
435435
if (!ecx.tcx.is_const_fn(def) && !ecx.tcx.is_const_default_method(def))
436436
|| ecx.tcx.has_attr(def, sym::rustc_do_not_const_check)
437437
{

compiler/rustc_feature/src/removed.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ declare_features! (
100100
Some("renamed to `doc_notable_trait`")),
101101
/// Allows using `#[unsafe_destructor_blind_to_params]` (RFC 1238).
102102
(removed, dropck_parametricity, "1.38.0", Some(28498), None),
103+
/// Uses generic effect parameters for ~const bounds
104+
(removed, effects, "CURRENT_RUSTC_VERSION", Some(102090),
105+
Some("removed, redundant with `#![feature(const_trait_impl)]`")),
103106
/// Allows defining `existential type`s.
104107
(removed, existential_type, "1.38.0", Some(63063),
105108
Some("removed in favor of `#![feature(type_alias_impl_trait)]`")),

compiler/rustc_feature/src/unstable.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,6 @@ declare_features! (
462462
(unstable, doc_masked, "1.21.0", Some(44027)),
463463
/// Allows `dyn* Trait` objects.
464464
(incomplete, dyn_star, "1.65.0", Some(102425)),
465-
/// Uses generic effect parameters for ~const bounds
466-
(incomplete, effects, "1.72.0", Some(102090)),
467465
/// Allows exhaustive pattern matching on types that contain uninhabited types.
468466
(unstable, exhaustive_patterns, "1.13.0", Some(51085)),
469467
/// Allows explicit tail calls via `become` expression.

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ fn compare_method_predicate_entailment<'tcx>(
205205
trait_m_predicates.instantiate_own(tcx, trait_to_impl_args).map(|(predicate, _)| predicate),
206206
);
207207

208-
// FIXME(effects): This should be replaced with a more dedicated method.
209208
let is_conditionally_const = tcx.is_conditionally_const(impl_def_id);
210209
if is_conditionally_const {
211210
// Augment the hybrid param-env with the const conditions

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,6 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
563563
if let Err(guar) = ty.error_reported() {
564564
return ty::Const::new_error(tcx, guar).into();
565565
}
566-
// FIXME(effects) see if we should special case effect params here
567566
if !infer_args && has_default {
568567
tcx.const_param_default(param.def_id)
569568
.instantiate(tcx, preceding_args)

compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ fn trait_predicates_eq<'tcx>(
459459
predicate1: ty::Predicate<'tcx>,
460460
predicate2: ty::Predicate<'tcx>,
461461
) -> bool {
462-
// FIXME(effects)
462+
// FIXME(const_trait_impl)
463463
predicate1 == predicate2
464464
}
465465

0 commit comments

Comments
 (0)