1
Fork 0

Merge SimplifiedTypeGen<D> into SimplifiedType.

`SimplifiedTypeGen<DefId>` is the only instantiation used, so we don't
need the generic parameter.
This commit is contained in:
Nicholas Nethercote 2022-12-15 15:13:19 +11:00
parent 2a5aabdfc2
commit 5258b655a2
5 changed files with 15 additions and 25 deletions

View file

@ -6,28 +6,18 @@ use std::fmt::Debug;
use std::hash::Hash;
use std::iter;
use self::SimplifiedTypeGen::*;
use self::SimplifiedType::*;
pub type SimplifiedType = SimplifiedTypeGen<DefId>;
/// See `simplify_type`
///
/// Note that we keep this type generic over the type of identifier it uses
/// because we sometimes need to use SimplifiedTypeGen values as stable sorting
/// keys (in which case we use a DefPathHash as id-type) but in the general case
/// the non-stable but fast to construct DefId-version is the better choice.
/// See `simplify_type`.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, TyEncodable, TyDecodable, HashStable)]
pub enum SimplifiedTypeGen<D>
where
D: Copy + Debug + Eq,
{
pub enum SimplifiedType {
BoolSimplifiedType,
CharSimplifiedType,
IntSimplifiedType(ty::IntTy),
UintSimplifiedType(ty::UintTy),
FloatSimplifiedType(ty::FloatTy),
AdtSimplifiedType(D),
ForeignSimplifiedType(D),
AdtSimplifiedType(DefId),
ForeignSimplifiedType(DefId),
StrSimplifiedType,
ArraySimplifiedType,
SliceSimplifiedType,
@ -38,9 +28,9 @@ where
/// A trait object, all of whose components are markers
/// (e.g., `dyn Send + Sync`).
MarkerTraitObjectSimplifiedType,
TraitSimplifiedType(D),
ClosureSimplifiedType(D),
GeneratorSimplifiedType(D),
TraitSimplifiedType(DefId),
ClosureSimplifiedType(DefId),
GeneratorSimplifiedType(DefId),
GeneratorWitnessSimplifiedType(usize),
FunctionSimplifiedType(usize),
PlaceholderSimplifiedType,
@ -142,8 +132,8 @@ pub fn simplify_type<'tcx>(
}
}
impl<D: Copy + Debug + Eq> SimplifiedTypeGen<D> {
pub fn def(self) -> Option<D> {
impl SimplifiedType {
pub fn def(self) -> Option<DefId> {
match self {
AdtSimplifiedType(d)
| ForeignSimplifiedType(d)

View file

@ -1,5 +1,5 @@
use rustc_data_structures::fx::FxHashMap;
use rustc_hir::def_id::{DefId, DefIndex};
use rustc_hir::def_id::DefIndex;
use rustc_index::vec::{Idx, IndexVec};
use crate::middle::exported_symbols::ExportedSymbol;
@ -67,7 +67,7 @@ trivially_parameterized_over_tcx! {
ty::TraitDef,
ty::Visibility<DefIndex>,
ty::adjustment::CoerceUnsizedInfo,
ty::fast_reject::SimplifiedTypeGen<DefId>,
ty::fast_reject::SimplifiedType,
rustc_ast::Attribute,
rustc_ast::DelimArgs,
rustc_attr::ConstStability,