Skip to content

Commit

Permalink
[experiment] turn on effects everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
fee1-dead committed Dec 18, 2023
1 parent 8681e07 commit 25306f1
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 17 deletions.
6 changes: 2 additions & 4 deletions compiler/rustc_ast_lowering/src/item.rs
Expand Up @@ -571,7 +571,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
hir::ItemKind::Impl(impl_) => {
self.is_in_trait_impl = impl_.of_trait.is_some();
}
hir::ItemKind::Trait(_, _, generics, _, _) if self.tcx.features().effects => {
hir::ItemKind::Trait(_, _, generics, _, _) => {
self.host_param_id = generics
.params
.iter()
Expand Down Expand Up @@ -1384,9 +1384,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
// Desugar `~const` bound in generics into an additional `const host: bool` param
// if the effects feature is enabled. This needs to be done before we lower where
// clauses since where clauses need to bind to the DefId of the host param
let host_param_parts = if let Const::Yes(span) = constness
&& self.tcx.features().effects
{
let host_param_parts = if let Const::Yes(span) = constness {
let span = self.lower_span(span);
let param_node_id = self.next_node_id();
let hir_id = self.next_id();
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_ast_lowering/src/lib.rs
Expand Up @@ -2557,10 +2557,6 @@ struct GenericArgsCtor<'hir> {

impl<'hir> GenericArgsCtor<'hir> {
fn push_constness(&mut self, lcx: &mut LoweringContext<'_, 'hir>, constness: ast::Const) {
if !lcx.tcx.features().effects {
return;
}

// if bound is non-const, don't add host effect param
let ast::Const::Yes(span) = constness else { return };

Expand Down
Expand Up @@ -779,7 +779,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
};

match implsrc {
Ok(Some(ImplSource::Param(_))) if tcx.features().effects => {
Ok(Some(ImplSource::Param(_))) => {
debug!(
"const_trait_impl: provided {:?} via where-clause in {:?}",
trait_ref, param_env
Expand Down
Expand Up @@ -157,9 +157,7 @@ impl Qualif for NeedsNonConstDrop {
// FIXME(effects): If `destruct` is not a `const_trait`,
// or effects are disabled in this crate, then give up.
let destruct_def_id = cx.tcx.require_lang_item(LangItem::Destruct, Some(cx.body.span));
if cx.tcx.generics_of(destruct_def_id).host_effect_index.is_none()
|| !cx.tcx.features().effects
{
if cx.tcx.generics_of(destruct_def_id).host_effect_index.is_none() {
return NeedsDrop::in_any_value_of_ty(cx, ty);
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_hir_analysis/src/bounds.rs
Expand Up @@ -47,8 +47,7 @@ impl<'tcx> Bounds<'tcx> {
self.push_trait_bound_inner(tcx, trait_ref, span, polarity);

// push a non-const (`host = true`) version of the bound if it is `~const`.
if tcx.features().effects
&& let Some(host_effect_idx) = tcx.generics_of(trait_ref.def_id()).host_effect_index
if let Some(host_effect_idx) = tcx.generics_of(trait_ref.def_id()).host_effect_index
&& trait_ref.skip_binder().args.const_at(host_effect_idx) != tcx.consts.true_
{
let generics = tcx.generics_of(trait_ref.def_id());
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/src/collect/predicates_of.rs
Expand Up @@ -38,7 +38,7 @@ pub(super) fn predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericPredic
// an obligation and instead be skipped. Otherwise we'd use
// `tcx.def_span(def_id);`
let span = rustc_span::DUMMY_SP;
let non_const_bound = if tcx.features().effects && tcx.has_attr(def_id, sym::const_trait) {
let non_const_bound = if tcx.has_attr(def_id, sym::const_trait) {
// when `Self` is a const trait, also add `Self: Trait<.., true>` as implied bound,
// because only implementing `Self: Trait<.., false>` is currently not possible.
Some((
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_middle/src/ty/util.rs
Expand Up @@ -784,8 +784,7 @@ impl<'tcx> TyCtxt<'tcx> {
// FIXME(effects): This is suspicious and should probably not be done,
// especially now that we enforce host effects and then properly handle
// effect vars during fallback.
let mut host_always_on =
!self.features().effects || self.sess.opts.unstable_opts.unleash_the_miri_inside_of_you;
let mut host_always_on = self.sess.opts.unstable_opts.unleash_the_miri_inside_of_you;

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

0 comments on commit 25306f1

Please sign in to comment.