Effects cleanup
- removed extra bits from predicates queries that are no longer needed in the new system - removed the need for `non_erasable_generics` to take in tcx and DefId, removed unused arguments in callers
This commit is contained in:
parent
c1db4dc242
commit
f6fea83342
23 changed files with 40 additions and 97 deletions
|
@ -1,7 +1,6 @@
|
|||
//! Bounds are restrictions applied to some types after they've been lowered from the HIR to the
|
||||
//! [`rustc_middle::ty`] form.
|
||||
|
||||
use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_hir::LangItem;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt, Upcast};
|
||||
use rustc_span::Span;
|
||||
|
@ -25,7 +24,6 @@ use rustc_span::Span;
|
|||
#[derive(Default, PartialEq, Eq, Clone, Debug)]
|
||||
pub(crate) struct Bounds<'tcx> {
|
||||
clauses: Vec<(ty::Clause<'tcx>, Span)>,
|
||||
effects_min_tys: FxIndexMap<Ty<'tcx>, Span>,
|
||||
}
|
||||
|
||||
impl<'tcx> Bounds<'tcx> {
|
||||
|
@ -96,15 +94,7 @@ impl<'tcx> Bounds<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn clauses(
|
||||
&self,
|
||||
// FIXME(effects): remove tcx
|
||||
_tcx: TyCtxt<'tcx>,
|
||||
) -> impl Iterator<Item = (ty::Clause<'tcx>, Span)> + '_ {
|
||||
pub(crate) fn clauses(&self) -> impl Iterator<Item = (ty::Clause<'tcx>, Span)> + '_ {
|
||||
self.clauses.iter().cloned()
|
||||
}
|
||||
|
||||
pub(crate) fn effects_min_tys(&self) -> impl Iterator<Item = Ty<'tcx>> + '_ {
|
||||
self.effects_min_tys.keys().copied()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ fn associated_type_bounds<'tcx>(
|
|||
)
|
||||
});
|
||||
|
||||
let all_bounds = tcx.arena.alloc_from_iter(bounds.clauses(tcx).chain(bounds_from_parent));
|
||||
let all_bounds = tcx.arena.alloc_from_iter(bounds.clauses().chain(bounds_from_parent));
|
||||
debug!(
|
||||
"associated_type_bounds({}) = {:?}",
|
||||
tcx.def_path_str(assoc_item_def_id.to_def_id()),
|
||||
|
@ -339,7 +339,7 @@ fn opaque_type_bounds<'tcx>(
|
|||
}
|
||||
debug!(?bounds);
|
||||
|
||||
tcx.arena.alloc_from_iter(bounds.clauses(tcx))
|
||||
tcx.arena.alloc_from_iter(bounds.clauses())
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,6 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
|
|||
return ty::GenericPredicates {
|
||||
parent: Some(tcx.parent(def_id.to_def_id())),
|
||||
predicates: tcx.arena.alloc_from_iter(predicates),
|
||||
effects_min_tys: ty::List::empty(),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -128,7 +127,6 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
|
|||
return ty::GenericPredicates {
|
||||
parent: Some(impl_def_id),
|
||||
predicates: tcx.arena.alloc_from_iter(impl_predicates),
|
||||
effects_min_tys: ty::List::empty(),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -154,7 +152,6 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
|
|||
// We use an `IndexSet` to preserve order of insertion.
|
||||
// Preserving the order of insertion is important here so as not to break UI tests.
|
||||
let mut predicates: FxIndexSet<(ty::Clause<'_>, Span)> = FxIndexSet::default();
|
||||
let mut effects_min_tys = Vec::new();
|
||||
|
||||
let hir_generics = node.generics().unwrap_or(NO_GENERICS);
|
||||
if let Node::Item(item) = node {
|
||||
|
@ -189,8 +186,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
|
|||
ty::List::empty(),
|
||||
PredicateFilter::All,
|
||||
);
|
||||
predicates.extend(bounds.clauses(tcx));
|
||||
effects_min_tys.extend(bounds.effects_min_tys());
|
||||
predicates.extend(bounds.clauses());
|
||||
}
|
||||
|
||||
// In default impls, we can assume that the self type implements
|
||||
|
@ -223,7 +219,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
|
|||
param.span,
|
||||
);
|
||||
trace!(?bounds);
|
||||
predicates.extend(bounds.clauses(tcx));
|
||||
predicates.extend(bounds.clauses());
|
||||
trace!(?predicates);
|
||||
}
|
||||
hir::GenericParamKind::Const { .. } => {
|
||||
|
@ -275,8 +271,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
|
|||
bound_vars,
|
||||
PredicateFilter::All,
|
||||
);
|
||||
predicates.extend(bounds.clauses(tcx));
|
||||
effects_min_tys.extend(bounds.effects_min_tys());
|
||||
predicates.extend(bounds.clauses());
|
||||
}
|
||||
|
||||
hir::WherePredicate::RegionPredicate(region_pred) => {
|
||||
|
@ -348,7 +343,6 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
|
|||
ty::GenericPredicates {
|
||||
parent: generics.parent,
|
||||
predicates: tcx.arena.alloc_from_iter(predicates),
|
||||
effects_min_tys: tcx.mk_type_list(&effects_min_tys),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -499,7 +493,6 @@ pub(super) fn explicit_predicates_of<'tcx>(
|
|||
ty::GenericPredicates {
|
||||
parent: predicates_and_bounds.parent,
|
||||
predicates: tcx.arena.alloc_slice(&predicates),
|
||||
effects_min_tys: predicates_and_bounds.effects_min_tys,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -551,7 +544,6 @@ pub(super) fn explicit_predicates_of<'tcx>(
|
|||
return GenericPredicates {
|
||||
parent: parent_preds.parent,
|
||||
predicates: { tcx.arena.alloc_from_iter(filtered_predicates) },
|
||||
effects_min_tys: parent_preds.effects_min_tys,
|
||||
};
|
||||
}
|
||||
gather_explicit_predicates_of(tcx, def_id)
|
||||
|
@ -630,7 +622,7 @@ pub(super) fn implied_predicates_with_filter<'tcx>(
|
|||
|
||||
// Combine the two lists to form the complete set of superbounds:
|
||||
let implied_bounds =
|
||||
&*tcx.arena.alloc_from_iter(bounds.clauses(tcx).chain(where_bounds_that_match));
|
||||
&*tcx.arena.alloc_from_iter(bounds.clauses().chain(where_bounds_that_match));
|
||||
debug!(?implied_bounds);
|
||||
|
||||
// Now require that immediate supertraits are lowered, which will, in
|
||||
|
@ -874,7 +866,7 @@ impl<'tcx> ItemCtxt<'tcx> {
|
|||
);
|
||||
}
|
||||
|
||||
bounds.clauses(self.tcx).collect()
|
||||
bounds.clauses().collect()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -966,7 +958,7 @@ pub(super) fn const_conditions<'tcx>(
|
|||
|
||||
ty::ConstConditions {
|
||||
parent: has_parent.then(|| tcx.local_parent(def_id).to_def_id()),
|
||||
predicates: tcx.arena.alloc_from_iter(bounds.clauses(tcx).map(|(clause, span)| {
|
||||
predicates: tcx.arena.alloc_from_iter(bounds.clauses().map(|(clause, span)| {
|
||||
(
|
||||
clause.kind().map_bound(|clause| match clause {
|
||||
ty::ClauseKind::HostEffect(ty::HostEffectPredicate {
|
||||
|
|
|
@ -278,8 +278,6 @@ impl<'tcx> PredicatesBuilder<'tcx> {
|
|||
ty::GenericPredicates {
|
||||
parent: self.parent,
|
||||
predicates: self.tcx.arena.alloc_from_iter(preds),
|
||||
// FIXME(fn_delegation): Support effects.
|
||||
effects_min_tys: ty::List::empty(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
|
||||
let mut trait_bounds = vec![];
|
||||
let mut projection_bounds = vec![];
|
||||
for (pred, span) in bounds.clauses(tcx) {
|
||||
for (pred, span) in bounds.clauses() {
|
||||
let bound_pred = pred.kind();
|
||||
match bound_pred.skip_binder() {
|
||||
ty::ClauseKind::Trait(trait_pred) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue