Skip to content

Commit 185d1fe

Browse files
committed
Remove <'tcx> bound from ty::GenericParamDefKind and parents
1 parent bfdc677 commit 185d1fe

File tree

30 files changed

+88
-93
lines changed

30 files changed

+88
-93
lines changed

src/librustc/ich/impls_ty.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ impl_stable_hash_for!(enum ty::adjustment::CustomCoerceUnsized {
703703
Struct(index)
704704
});
705705

706-
impl_stable_hash_for!(struct ty::Generics<'tcx> {
706+
impl_stable_hash_for!(struct ty::Generics {
707707
parent,
708708
parent_count,
709709
params,
@@ -713,15 +713,15 @@ impl_stable_hash_for!(struct ty::Generics<'tcx> {
713713
has_late_bound_regions,
714714
});
715715

716-
impl_stable_hash_for!(struct ty::GenericParamDef<'tcx> {
716+
impl_stable_hash_for!(struct ty::GenericParamDef {
717717
name,
718718
def_id,
719719
index,
720720
pure_wrt_drop,
721721
kind
722722
});
723723

724-
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ty::GenericParamDefKind<'tcx> {
724+
impl<'a> HashStable<StableHashingContext<'a>> for ty::GenericParamDefKind {
725725
fn hash_stable<W: StableHasherResult>(&self,
726726
hcx: &mut StableHashingContext<'a>,
727727
hasher: &mut StableHasher<W>) {
@@ -737,9 +737,7 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ty::GenericParamDefKind<
737737
object_lifetime_default.hash_stable(hcx, hasher);
738738
synthetic.hash_stable(hcx, hasher);
739739
}
740-
ty::GenericParamDefKind::Const { ref ty } => {
741-
ty.hash_stable(hcx, hasher);
742-
}
740+
ty::GenericParamDefKind::Const => {}
743741
}
744742
}
745743
}

src/librustc/infer/error_reporting/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
673673
let mut type_params = generics.params.iter().rev().filter_map(|param| match param.kind {
674674
ty::GenericParamDefKind::Lifetime => None,
675675
ty::GenericParamDefKind::Type { has_default, .. } => Some((param.def_id, has_default)),
676-
ty::GenericParamDefKind::Const { .. } => None, // FIXME(const_generics): defaults
676+
ty::GenericParamDefKind::Const => None, // FIXME(const_generics): defaults
677677
}).peekable();
678678
let has_default = {
679679
let has_default = type_params.peek().map(|(_, has_default)| has_default);

src/librustc/infer/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
956956

957957
pub fn var_for_def(&self,
958958
span: Span,
959-
param: &ty::GenericParamDef<'tcx>)
959+
param: &ty::GenericParamDef)
960960
-> Kind<'tcx> {
961961
match param.kind {
962962
GenericParamDefKind::Lifetime => {
@@ -982,12 +982,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
982982

983983
self.tcx.mk_ty_var(ty_var_id).into()
984984
}
985-
GenericParamDefKind::Const { ty } => {
985+
GenericParamDefKind::Const => {
986986
let const_var_id =
987987
self.const_unification_table
988988
.borrow_mut()
989989
.new_key(None);
990-
self.tcx.mk_const_var(const_var_id, ty).into()
990+
self.tcx.mk_const_var(const_var_id, self.tcx.type_of(param.def_id)).into()
991991
}
992992
}
993993
}

src/librustc/middle/resolve_lifetime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1800,7 +1800,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
18001800
GenericParamDefKind::Type { object_lifetime_default, .. } => {
18011801
Some(object_lifetime_default)
18021802
}
1803-
GenericParamDefKind::Const { .. } |
1803+
GenericParamDefKind::Const |
18041804
GenericParamDefKind::Lifetime => None,
18051805
}
18061806
}).collect()

src/librustc/traits/error_reporting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
382382

383383
for param in generics.params.iter() {
384384
let value = match param.kind {
385-
GenericParamDefKind::Const { .. } |
385+
GenericParamDefKind::Const |
386386
GenericParamDefKind::Type { .. } => {
387387
trait_ref.substs[param.index as usize].to_string()
388388
},

src/librustc/traits/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ fn vtable_methods<'a, 'tcx>(
855855
Substs::for_item(tcx, def_id, |param, _| {
856856
match param.kind {
857857
GenericParamDefKind::Lifetime => tcx.types.re_erased.into(),
858-
GenericParamDefKind::Const { .. } |
858+
GenericParamDefKind::Const |
859859
GenericParamDefKind::Type { .. } => {
860860
trait_ref.substs[param.index as usize]
861861
}

src/librustc/traits/on_unimplemented.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedFormatString {
293293
let generics = tcx.generics_of(trait_ref.def_id);
294294
let generic_map = generics.params.iter().filter_map(|param| {
295295
let value = match param.kind {
296-
GenericParamDefKind::Const { .. } |
296+
GenericParamDefKind::Const |
297297
GenericParamDefKind::Type { .. } => {
298298
trait_ref.substs[param.index as usize].to_string()
299299
},

src/librustc/ty/context.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ pub struct GlobalArenas<'tcx> {
103103
layout: TypedArena<LayoutDetails>,
104104

105105
// references
106-
generics: TypedArena<ty::Generics<'tcx>>,
106+
generics: TypedArena<ty::Generics>,
107107
trait_def: TypedArena<ty::TraitDef>,
108108
adt_def: TypedArena<ty::AdtDef>,
109109
steal_mir: TypedArena<Steal<Mir<'tcx>>>,
@@ -952,7 +952,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
952952
}
953953
}
954954

955-
pub fn alloc_generics(self, generics: ty::Generics<'tcx>) -> &'gcx ty::Generics<'tcx> {
955+
pub fn alloc_generics(self, generics: ty::Generics) -> &'gcx ty::Generics {
956956
self.global_arenas.generics.alloc(generics)
957957
}
958958

@@ -2402,7 +2402,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
24022402
let adt_def = self.adt_def(def_id);
24032403
let substs = Substs::for_item(self, def_id, |param, substs| {
24042404
match param.kind {
2405-
GenericParamDefKind::Lifetime | GenericParamDefKind::Const { .. } => bug!(),
2405+
GenericParamDefKind::Lifetime | GenericParamDefKind::Const => bug!(),
24062406
GenericParamDefKind::Type { has_default, .. } => {
24072407
if param.index == 0 {
24082408
ty.into()
@@ -2561,13 +2561,15 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
25612561
self.mk_ty_param(0, keywords::SelfType.name().as_interned_str())
25622562
}
25632563

2564-
pub fn mk_param_from_def(self, param: &ty::GenericParamDef<'tcx>) -> Kind<'tcx> {
2564+
pub fn mk_param_from_def(self, param: &ty::GenericParamDef) -> Kind<'tcx> {
25652565
match param.kind {
25662566
GenericParamDefKind::Lifetime => {
25672567
self.mk_region(ty::ReEarlyBound(param.to_early_bound_region_data())).into()
25682568
}
25692569
GenericParamDefKind::Type { .. } => self.mk_ty_param(param.index, param.name).into(),
2570-
GenericParamDefKind::Const { ty } => self.mk_const_param(param.index, param.name, ty).into(),
2570+
GenericParamDefKind::Const => {
2571+
self.mk_const_param(param.index, param.name, self.type_of(param.def_id)).into()
2572+
}
25712573
}
25722574
}
25732575

src/librustc/ty/mod.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -839,21 +839,18 @@ impl ty::EarlyBoundRegion {
839839
}
840840

841841
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
842-
pub enum GenericParamDefKind<'tcx> {
842+
pub enum GenericParamDefKind {
843843
Lifetime,
844844
Type {
845845
has_default: bool,
846846
object_lifetime_default: ObjectLifetimeDefault,
847847
synthetic: Option<hir::SyntheticTyParamKind>,
848848
},
849-
Const {
850-
ty: Ty<'tcx>, // TODO(const_generics): GenericParamDefKind<'tcx> shouldn't be parameterised
851-
// by 'tcx -- we should use tcx.type_of(def_id) instead for ty
852-
}
849+
Const,
853850
}
854851

855852
#[derive(Clone, RustcEncodable, RustcDecodable)]
856-
pub struct GenericParamDef<'tcx> {
853+
pub struct GenericParamDef {
857854
pub name: InternedString,
858855
pub def_id: DefId,
859856
pub index: u32,
@@ -863,10 +860,10 @@ pub struct GenericParamDef<'tcx> {
863860
/// `'a`/`T` won't be accessed during the parent type's `Drop` impl.
864861
pub pure_wrt_drop: bool,
865862

866-
pub kind: GenericParamDefKind<'tcx>,
863+
pub kind: GenericParamDefKind,
867864
}
868865

869-
impl<'tcx> GenericParamDef<'tcx> {
866+
impl GenericParamDef {
870867
pub fn to_early_bound_region_data(&self) -> ty::EarlyBoundRegion {
871868
match self.kind {
872869
GenericParamDefKind::Lifetime => {
@@ -903,10 +900,10 @@ pub struct GenericParamCount {
903900
/// The ordering of parameters is the same as in Subst (excluding child generics):
904901
/// Self (optionally), Lifetime params..., Type params...
905902
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
906-
pub struct Generics<'tcx> {
903+
pub struct Generics {
907904
pub parent: Option<DefId>,
908905
pub parent_count: usize,
909-
pub params: Vec<GenericParamDef<'tcx>>,
906+
pub params: Vec<GenericParamDef>,
910907

911908
/// Reverse map to the `index` field of each `GenericParamDef`
912909
pub param_def_id_to_index: FxHashMap<DefId, u32>,
@@ -915,7 +912,7 @@ pub struct Generics<'tcx> {
915912
pub has_late_bound_regions: Option<Span>,
916913
}
917914

918-
impl<'a, 'gcx, 'tcx> Generics<'tcx> {
915+
impl<'a, 'gcx, 'tcx> Generics {
919916
pub fn count(&self) -> usize {
920917
self.parent_count + self.params.len()
921918
}
@@ -930,7 +927,7 @@ impl<'a, 'gcx, 'tcx> Generics<'tcx> {
930927
match param.kind {
931928
GenericParamDefKind::Lifetime => own_counts.lifetimes += 1,
932929
GenericParamDefKind::Type { .. } => own_counts.types += 1,
933-
GenericParamDefKind::Const { .. } => own_counts.consts += 1,
930+
GenericParamDefKind::Const => own_counts.consts += 1,
934931
};
935932
}
936933

@@ -940,7 +937,7 @@ impl<'a, 'gcx, 'tcx> Generics<'tcx> {
940937
pub fn requires_monomorphization(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> bool {
941938
for param in &self.params {
942939
match param.kind {
943-
GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => return true,
940+
GenericParamDefKind::Type { .. } | GenericParamDefKind::Const => return true,
944941
GenericParamDefKind::Lifetime => {}
945942
}
946943
}
@@ -994,7 +991,7 @@ impl<'a, 'gcx, 'tcx> Generics<'tcx> {
994991
if let Some(index) = param.index.checked_sub(self.parent_count as u32) {
995992
let param = &self.params[index as usize];
996993
match param.kind {
997-
ty::GenericParamDefKind::Const { .. } => param,
994+
ty::GenericParamDefKind::Const => param,
998995
_ => bug!("expected const parameter, but found another generic parameter")
999996
}
1000997
} else {

src/librustc/ty/query/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ define_queries! { <'tcx>
106106

107107
/// Maps from the def-id of an item (trait/struct/enum/fn) to its
108108
/// associated generics.
109-
[] fn generics_of: GenericsOfItem(DefId) -> &'tcx ty::Generics<'tcx>,
109+
[] fn generics_of: GenericsOfItem(DefId) -> &'tcx ty::Generics,
110110

111111
/// Maps from the def-id of an item (trait/struct/enum/fn) to the
112112
/// predicates (where clauses) that must be proven true in order

0 commit comments

Comments
 (0)