Skip to content

Commit

Permalink
rustc: remove unused bounds field from RegionParameterDef.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Jan 28, 2017
1 parent 4eac052 commit 9a0af16
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 38 deletions.
11 changes: 5 additions & 6 deletions src/librustc/ty/mod.rs
Expand Up @@ -606,20 +606,19 @@ pub struct TypeParameterDef<'tcx> {
pub pure_wrt_drop: bool,
}

#[derive(Clone, RustcEncodable, RustcDecodable)]
pub struct RegionParameterDef<'tcx> {
#[derive(Copy, Clone, RustcEncodable, RustcDecodable)]
pub struct RegionParameterDef {
pub name: Name,
pub def_id: DefId,
pub index: u32,
pub bounds: Vec<&'tcx ty::Region>,

/// `pure_wrt_drop`, set by the (unsafe) `#[may_dangle]` attribute
/// on generic parameter `'a`, asserts data of lifetime `'a`
/// won't be accessed during the parent type's `Drop` impl.
pub pure_wrt_drop: bool,
}

impl<'tcx> RegionParameterDef<'tcx> {
impl RegionParameterDef {
pub fn to_early_bound_region_data(&self) -> ty::EarlyBoundRegion {
ty::EarlyBoundRegion {
index: self.index,
Expand All @@ -640,7 +639,7 @@ pub struct Generics<'tcx> {
pub parent: Option<DefId>,
pub parent_regions: u32,
pub parent_types: u32,
pub regions: Vec<RegionParameterDef<'tcx>>,
pub regions: Vec<RegionParameterDef>,
pub types: Vec<TypeParameterDef<'tcx>>,
pub has_self: bool,
}
Expand All @@ -658,7 +657,7 @@ impl<'tcx> Generics<'tcx> {
self.parent_count() + self.own_count()
}

pub fn region_param(&self, param: &EarlyBoundRegion) -> &RegionParameterDef<'tcx> {
pub fn region_param(&self, param: &EarlyBoundRegion) -> &RegionParameterDef {
&self.regions[param.index as usize - self.has_self as usize]
}

Expand Down
18 changes: 1 addition & 17 deletions src/librustc/ty/structural_impls.rs
Expand Up @@ -353,7 +353,7 @@ macro_rules! CopyImpls {
}
}

CopyImpls! { (), hir::Unsafety, abi::Abi }
CopyImpls! { (), hir::Unsafety, abi::Abi, ty::RegionParameterDef }

impl<'tcx, T:TypeFoldable<'tcx>, U:TypeFoldable<'tcx>> TypeFoldable<'tcx> for (T, U) {
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> (T, U) {
Expand Down Expand Up @@ -735,22 +735,6 @@ impl<'tcx> TypeFoldable<'tcx> for ty::TypeParameterDef<'tcx> {
}
}

impl<'tcx> TypeFoldable<'tcx> for ty::RegionParameterDef<'tcx> {
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
ty::RegionParameterDef {
name: self.name,
def_id: self.def_id,
index: self.index,
bounds: self.bounds.fold_with(folder),
pure_wrt_drop: self.pure_wrt_drop,
}
}

fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
self.bounds.visit_with(visitor)
}
}

impl<'tcx> TypeFoldable<'tcx> for ty::Generics<'tcx> {
fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
ty::Generics {
Expand Down
7 changes: 3 additions & 4 deletions src/librustc/util/ppaux.rs
Expand Up @@ -336,13 +336,12 @@ impl<'tcx> fmt::Debug for ty::TypeParameterDef<'tcx> {
}
}

impl<'tcx> fmt::Debug for ty::RegionParameterDef<'tcx> {
impl fmt::Debug for ty::RegionParameterDef {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "RegionParameterDef({}, {:?}, {}, {:?})",
write!(f, "RegionParameterDef({}, {:?}, {})",
self.name,
self.def_id,
self.index,
self.bounds)
self.index)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/schema.rs
Expand Up @@ -256,7 +256,7 @@ pub struct Generics<'tcx> {
pub parent: Option<DefId>,
pub parent_regions: u32,
pub parent_types: u32,
pub regions: LazySeq<ty::RegionParameterDef<'tcx>>,
pub regions: LazySeq<ty::RegionParameterDef>,
pub types: LazySeq<ty::TypeParameterDef<'tcx>>,
pub has_self: bool,
pub object_lifetime_defaults: LazySeq<ObjectLifetimeDefault>,
Expand Down
3 changes: 0 additions & 3 deletions src/librustc_typeck/collect.rs
Expand Up @@ -1446,9 +1446,6 @@ fn generics_of_def_id<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
name: l.lifetime.name,
index: own_start + i as u32,
def_id: tcx.hir.local_def_id(l.lifetime.id),
bounds: l.bounds.iter().map(|l| {
AstConv::ast_region_to_region(&ccx.icx(&()), l, None)
}).collect(),
pure_wrt_drop: l.pure_wrt_drop,
}
}).collect::<Vec<_>>();
Expand Down
9 changes: 2 additions & 7 deletions src/librustdoc/clean/mod.rs
Expand Up @@ -794,7 +794,7 @@ impl Clean<Lifetime> for hir::LifetimeDef {
}
}

impl<'tcx> Clean<Lifetime> for ty::RegionParameterDef<'tcx> {
impl Clean<Lifetime> for ty::RegionParameterDef {
fn clean(&self, _: &DocContext) -> Lifetime {
Lifetime(self.name.to_string())
}
Expand Down Expand Up @@ -970,11 +970,6 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics<'tcx>,
Some(tp.clean(cx))
}
}).collect::<Vec<_>>();
let stripped_lifetimes = gens.regions.iter().map(|rp| {
let mut srp = rp.clone();
srp.bounds = Vec::new();
srp.clean(cx)
}).collect::<Vec<_>>();

let mut where_predicates = preds.predicates.to_vec().clean(cx);

Expand Down Expand Up @@ -1017,7 +1012,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics<'tcx>,

Generics {
type_params: simplify::ty_params(stripped_typarams),
lifetimes: stripped_lifetimes,
lifetimes: gens.regions.clean(cx),
where_predicates: simplify::where_clauses(cx, where_predicates),
}
}
Expand Down

0 comments on commit 9a0af16

Please sign in to comment.