1
Fork 0

Auto merge of #77171 - VFLashM:better_sso_structures, r=oli-obk

Better sso structures

This change greatly expands interface of MiniSet/MiniMap and renames them because they are no longer "Mini".
This commit is contained in:
bors 2020-10-05 17:18:01 +00:00
commit ea7e131435
13 changed files with 902 additions and 127 deletions

View file

@ -4,7 +4,7 @@
use crate::ty::subst::{GenericArg, GenericArgKind};
use crate::ty::{self, Ty, TyCtxt, TypeFoldable};
use rustc_data_structures::mini_set::MiniSet;
use rustc_data_structures::sso::SsoHashSet;
use smallvec::SmallVec;
#[derive(Debug)]
@ -51,7 +51,7 @@ impl<'tcx> TyCtxt<'tcx> {
/// Push onto `out` all the things that must outlive `'a` for the condition
/// `ty0: 'a` to hold. Note that `ty0` must be a **fully resolved type**.
pub fn push_outlives_components(self, ty0: Ty<'tcx>, out: &mut SmallVec<[Component<'tcx>; 4]>) {
let mut visited = MiniSet::new();
let mut visited = SsoHashSet::new();
compute_components(self, ty0, out, &mut visited);
debug!("components({:?}) = {:?}", ty0, out);
}
@ -61,7 +61,7 @@ fn compute_components(
tcx: TyCtxt<'tcx>,
ty: Ty<'tcx>,
out: &mut SmallVec<[Component<'tcx>; 4]>,
visited: &mut MiniSet<GenericArg<'tcx>>,
visited: &mut SsoHashSet<GenericArg<'tcx>>,
) {
// Descend through the types, looking for the various "base"
// components and collecting them into `out`. This is not written
@ -142,7 +142,7 @@ fn compute_components(
// OutlivesProjectionComponents. Continue walking
// through and constrain Pi.
let mut subcomponents = smallvec![];
let mut subvisited = MiniSet::new();
let mut subvisited = SsoHashSet::new();
compute_components_recursive(tcx, ty.into(), &mut subcomponents, &mut subvisited);
out.push(Component::EscapingProjection(subcomponents.into_iter().collect()));
}
@ -194,7 +194,7 @@ fn compute_components_recursive(
tcx: TyCtxt<'tcx>,
parent: GenericArg<'tcx>,
out: &mut SmallVec<[Component<'tcx>; 4]>,
visited: &mut MiniSet<GenericArg<'tcx>>,
visited: &mut SsoHashSet<GenericArg<'tcx>>,
) {
for child in parent.walk_shallow(visited) {
match child.unpack() {

View file

@ -2,7 +2,7 @@ use crate::ty::subst::{GenericArg, Subst};
use crate::ty::{self, DefIdTree, Ty, TyCtxt};
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::mini_set::MiniSet;
use rustc_data_structures::sso::SsoHashSet;
use rustc_hir::def_id::{CrateNum, DefId};
use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
@ -269,7 +269,7 @@ pub trait Printer<'tcx>: Sized {
/// deeply nested tuples that have no DefId.
fn characteristic_def_id_of_type_cached<'a>(
ty: Ty<'a>,
visited: &mut MiniSet<Ty<'a>>,
visited: &mut SsoHashSet<Ty<'a>>,
) -> Option<DefId> {
match *ty.kind() {
ty::Adt(adt_def, _) => Some(adt_def.did),
@ -316,7 +316,7 @@ fn characteristic_def_id_of_type_cached<'a>(
}
}
pub fn characteristic_def_id_of_type(ty: Ty<'_>) -> Option<DefId> {
characteristic_def_id_of_type_cached(ty, &mut MiniSet::new())
characteristic_def_id_of_type_cached(ty, &mut SsoHashSet::new())
}
impl<'tcx, P: Printer<'tcx>> Print<'tcx, P> for ty::RegionKind {

View file

@ -3,7 +3,7 @@
use crate::ty;
use crate::ty::subst::{GenericArg, GenericArgKind};
use rustc_data_structures::mini_set::MiniSet;
use rustc_data_structures::sso::SsoHashSet;
use smallvec::{self, SmallVec};
// The TypeWalker's stack is hot enough that it's worth going to some effort to
@ -13,7 +13,7 @@ type TypeWalkerStack<'tcx> = SmallVec<[GenericArg<'tcx>; 8]>;
pub struct TypeWalker<'tcx> {
stack: TypeWalkerStack<'tcx>,
last_subtree: usize,
visited: MiniSet<GenericArg<'tcx>>,
visited: SsoHashSet<GenericArg<'tcx>>,
}
/// An iterator for walking the type tree.
@ -26,7 +26,7 @@ pub struct TypeWalker<'tcx> {
/// skips any types that are already there.
impl<'tcx> TypeWalker<'tcx> {
pub fn new(root: GenericArg<'tcx>) -> Self {
Self { stack: smallvec![root], last_subtree: 1, visited: MiniSet::new() }
Self { stack: smallvec![root], last_subtree: 1, visited: SsoHashSet::new() }
}
/// Skips the subtree corresponding to the last type
@ -87,7 +87,7 @@ impl GenericArg<'tcx> {
/// and skips any types that are already there.
pub fn walk_shallow(
self,
visited: &mut MiniSet<GenericArg<'tcx>>,
visited: &mut SsoHashSet<GenericArg<'tcx>>,
) -> impl Iterator<Item = GenericArg<'tcx>> {
let mut stack = SmallVec::new();
push_inner(&mut stack, self);