Skip to content

Commit 212d9c9

Browse files
committed
[experiment] turn on effects everywhere
1 parent edcbcc7 commit 212d9c9

File tree

7 files changed

+15
-42
lines changed

7 files changed

+15
-42
lines changed

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
571571
hir::ItemKind::Impl(impl_) => {
572572
self.is_in_trait_impl = impl_.of_trait.is_some();
573573
}
574-
hir::ItemKind::Trait(_, _, generics, _, _) if self.tcx.features().effects => {
574+
hir::ItemKind::Trait(_, _, generics, _, _) => {
575575
self.host_param_id = generics
576576
.params
577577
.iter()
@@ -1391,9 +1391,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
13911391
// Desugar `~const` bound in generics into an additional `const host: bool` param
13921392
// if the effects feature is enabled. This needs to be done before we lower where
13931393
// clauses since where clauses need to bind to the DefId of the host param
1394-
let host_param_parts = if let Const::Yes(span) = constness
1395-
&& self.tcx.features().effects
1396-
{
1394+
let host_param_parts = if let Const::Yes(span) = constness {
13971395
let span = self.lower_span(span);
13981396
let param_node_id = self.next_node_id();
13991397
let hir_id = self.next_id();

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2556,10 +2556,6 @@ struct GenericArgsCtor<'hir> {
25562556

25572557
impl<'hir> GenericArgsCtor<'hir> {
25582558
fn push_constness(&mut self, lcx: &mut LoweringContext<'_, 'hir>, constness: ast::Const) {
2559-
if !lcx.tcx.features().effects {
2560-
return;
2561-
}
2562-
25632559
// if bound is non-const, don't add host effect param
25642560
let ast::Const::Yes(span) = constness else { return };
25652561

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

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -763,33 +763,16 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
763763
// the trait into the concrete method, and uses that for const stability
764764
// checks.
765765
// FIXME(effects) we might consider moving const stability checks to typeck as well.
766-
if tcx.features().effects {
767-
is_trait = true;
766+
is_trait = true;
768767

769-
if let Ok(Some(instance)) =
770-
Instance::resolve(tcx, param_env, callee, fn_args)
771-
&& let InstanceDef::Item(def) = instance.def
772-
{
773-
// Resolve a trait method call to its concrete implementation, which may be in a
774-
// `const` trait impl. This is only used for the const stability check below, since
775-
// we want to look at the concrete impl's stability.
776-
fn_args = instance.args;
777-
callee = def;
778-
}
779-
} else {
780-
self.check_op(ops::FnCallNonConst {
781-
caller,
782-
callee,
783-
args: fn_args,
784-
span: *fn_span,
785-
call_source: *call_source,
786-
feature: Some(if tcx.features().const_trait_impl {
787-
sym::effects
788-
} else {
789-
sym::const_trait_impl
790-
}),
791-
});
792-
return;
768+
if let Ok(Some(instance)) = Instance::resolve(tcx, param_env, callee, fn_args)
769+
&& let InstanceDef::Item(def) = instance.def
770+
{
771+
// Resolve a trait method call to its concrete implementation, which may be in a
772+
// `const` trait impl. This is only used for the const stability check below, since
773+
// we want to look at the concrete impl's stability.
774+
fn_args = instance.args;
775+
callee = def;
793776
}
794777
}
795778

compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,7 @@ impl Qualif for NeedsNonConstDrop {
157157
// FIXME(effects): If `destruct` is not a `const_trait`,
158158
// or effects are disabled in this crate, then give up.
159159
let destruct_def_id = cx.tcx.require_lang_item(LangItem::Destruct, Some(cx.body.span));
160-
if cx.tcx.generics_of(destruct_def_id).host_effect_index.is_none()
161-
|| !cx.tcx.features().effects
162-
{
160+
if cx.tcx.generics_of(destruct_def_id).host_effect_index.is_none() {
163161
return NeedsDrop::in_any_value_of_ty(cx, ty);
164162
}
165163

compiler/rustc_hir_analysis/src/bounds.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ impl<'tcx> Bounds<'tcx> {
4747
self.push_trait_bound_inner(tcx, trait_ref, span, polarity);
4848

4949
// push a non-const (`host = true`) version of the bound if it is `~const`.
50-
if tcx.features().effects
51-
&& let Some(host_effect_idx) = tcx.generics_of(trait_ref.def_id()).host_effect_index
50+
if let Some(host_effect_idx) = tcx.generics_of(trait_ref.def_id()).host_effect_index
5251
&& trait_ref.skip_binder().args.const_at(host_effect_idx) != tcx.consts.true_
5352
{
5453
let generics = tcx.generics_of(trait_ref.def_id());

compiler/rustc_hir_analysis/src/collect/predicates_of.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub(super) fn predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredic
3838
// an obligation and instead be skipped. Otherwise we'd use
3939
// `tcx.def_span(def_id);`
4040
let span = rustc_span::DUMMY_SP;
41-
let non_const_bound = if tcx.features().effects && tcx.has_attr(def_id, sym::const_trait) {
41+
let non_const_bound = if tcx.has_attr(def_id, sym::const_trait) {
4242
// when `Self` is a const trait, also add `Self: Trait<.., true>` as implied bound,
4343
// because only implementing `Self: Trait<.., false>` is currently not possible.
4444
Some((

compiler/rustc_middle/src/ty/util.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,8 +790,7 @@ impl<'tcx> TyCtxt<'tcx> {
790790
// FIXME(effects): This is suspicious and should probably not be done,
791791
// especially now that we enforce host effects and then properly handle
792792
// effect vars during fallback.
793-
let mut host_always_on =
794-
!self.features().effects || self.sess.opts.unstable_opts.unleash_the_miri_inside_of_you;
793+
let mut host_always_on = self.sess.opts.unstable_opts.unleash_the_miri_inside_of_you;
795794

796795
// Compute the constness required by the context.
797796
let const_context = self.hir().body_const_context(def_id);

0 commit comments

Comments
 (0)