Skip to content

Commit 007de2f

Browse files
committed
Lift pure_wrt_drop to GenericParamDef
1 parent 9200bde commit 007de2f

File tree

17 files changed

+40
-60
lines changed

17 files changed

+40
-60
lines changed

src/librustc/ich/impls_ty.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -754,25 +754,21 @@ impl<'a> HashStable<StableHashingContext<'a>> for ty::Generics {
754754
}
755755

756756
impl_stable_hash_for!(enum ty::GenericParamDefKind {
757-
Lifetime(lt),
757+
Lifetime,
758758
Type(ty)
759759
});
760760

761761
impl_stable_hash_for!(struct ty::GenericParamDef {
762762
name,
763763
def_id,
764764
index,
765+
pure_wrt_drop,
765766
kind
766767
});
767768

768-
impl_stable_hash_for!(struct ty::LifetimeParamDef {
769-
pure_wrt_drop
770-
});
771-
772769
impl_stable_hash_for!(struct ty::TypeParamDef {
773770
has_default,
774771
object_lifetime_default,
775-
pure_wrt_drop,
776772
synthetic
777773
});
778774

src/librustc/infer/anon_types/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
315315
let mut least_region = None;
316316
for param in &abstract_type_generics.params {
317317
match param.kind {
318-
GenericParamDefKind::Lifetime(_) => {}
318+
GenericParamDefKind::Lifetime => {}
319319
_ => continue
320320
}
321321
// Get the value supplied for this region from the substs.

src/librustc/middle/resolve_lifetime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1666,7 +1666,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
16661666
GenericParamDefKind::Type(ty) => {
16671667
Some(ty.object_lifetime_default)
16681668
}
1669-
GenericParamDefKind::Lifetime(_) => None,
1669+
GenericParamDefKind::Lifetime => None,
16701670
}
16711671
})
16721672
.collect()

src/librustc/traits/auto_trait.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
226226
.iter()
227227
.filter_map(|param| {
228228
match param.kind {
229-
ty::GenericParamDefKind::Lifetime(_) => Some(param.name.to_string()),
229+
ty::GenericParamDefKind::Lifetime => Some(param.name.to_string()),
230230
_ => None
231231
}
232232
})

src/librustc/traits/error_reporting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
386386
let ty = trait_ref.substs.type_for_def(&param);
387387
ty.to_string()
388388
},
389-
GenericParamDefKind::Lifetime(_) => continue,
389+
GenericParamDefKind::Lifetime => continue,
390390
};
391391
flags.push((name.clone(), Some(value.clone())));
392392
}

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
Some((param.name.to_string(),
294294
trait_ref.substs.type_for_def(&param).to_string()))
295295
},
296-
GenericParamDefKind::Lifetime(_) => None
296+
GenericParamDefKind::Lifetime => None
297297
}
298298
}).collect::<FxHashMap<String, String>>();
299299

src/librustc/ty/mod.rs

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -713,23 +713,9 @@ pub struct FloatVarValue(pub ast::FloatTy);
713713
pub struct TypeParamDef {
714714
pub has_default: bool,
715715
pub object_lifetime_default: ObjectLifetimeDefault,
716-
717-
/// `pure_wrt_drop`, set by the (unsafe) `#[may_dangle]` attribute
718-
/// on generic parameter `T`, asserts data behind the parameter
719-
/// `T` won't be accessed during the parent type's `Drop` impl.
720-
pub pure_wrt_drop: bool,
721-
722716
pub synthetic: Option<hir::SyntheticTyParamKind>,
723717
}
724718

725-
#[derive(Copy, Clone, Debug, RustcEncodable, RustcDecodable)]
726-
pub struct LifetimeParamDef {
727-
/// `pure_wrt_drop`, set by the (unsafe) `#[may_dangle]` attribute
728-
/// on generic parameter `'a`, asserts data of lifetime `'a`
729-
/// won't be accessed during the parent type's `Drop` impl.
730-
pub pure_wrt_drop: bool,
731-
}
732-
733719
impl ty::EarlyBoundRegion {
734720
pub fn to_bound_region(&self) -> ty::BoundRegion {
735721
ty::BoundRegion::BrNamed(self.def_id, self.name)
@@ -738,7 +724,7 @@ impl ty::EarlyBoundRegion {
738724

739725
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
740726
pub enum GenericParamDefKind {
741-
Lifetime(LifetimeParamDef),
727+
Lifetime,
742728
Type(TypeParamDef),
743729
}
744730

@@ -747,17 +733,16 @@ pub struct GenericParamDef {
747733
pub name: InternedString,
748734
pub def_id: DefId,
749735
pub index: u32,
736+
737+
/// `pure_wrt_drop`, set by the (unsafe) `#[may_dangle]` attribute
738+
/// on generic parameter `'a`/`T`, asserts data behind the parameter
739+
/// `'a`/`T` won't be accessed during the parent type's `Drop` impl.
740+
pub pure_wrt_drop: bool,
741+
750742
pub kind: GenericParamDefKind,
751743
}
752744

753745
impl GenericParamDef {
754-
pub fn to_lifetime(&self) -> LifetimeParamDef {
755-
match self.kind {
756-
GenericParamDefKind::Lifetime(lt) => lt,
757-
_ => bug!("cannot convert a non-lifetime to a lifetime")
758-
}
759-
}
760-
761746
pub fn to_type(&self) -> TypeParamDef {
762747
match self.kind {
763748
GenericParamDefKind::Type(ty) => ty,
@@ -767,7 +752,7 @@ impl GenericParamDef {
767752

768753
pub fn to_early_bound_region_data(&self) -> ty::EarlyBoundRegion {
769754
match self.kind {
770-
GenericParamDefKind::Lifetime(_) => {
755+
GenericParamDefKind::Lifetime => {
771756
ty::EarlyBoundRegion {
772757
def_id: self.def_id,
773758
index: self.index,
@@ -780,7 +765,7 @@ impl GenericParamDef {
780765

781766
pub fn to_bound_region(&self) -> ty::BoundRegion {
782767
match self.kind {
783-
GenericParamDefKind::Lifetime(_) => {
768+
GenericParamDefKind::Lifetime => {
784769
self.to_early_bound_region_data().to_bound_region()
785770
}
786771
_ => bug!("cannot convert a non-lifetime parameter def to an early bound region")
@@ -827,7 +812,7 @@ impl<'a, 'gcx, 'tcx> Generics {
827812

828813
for param in self.params.iter() {
829814
match param.kind {
830-
GenericParamDefKind::Lifetime(_) => param_counts.lifetimes += 1,
815+
GenericParamDefKind::Lifetime => param_counts.lifetimes += 1,
831816
GenericParamDefKind::Type(_) => param_counts.types += 1,
832817
};
833818
}
@@ -839,7 +824,7 @@ impl<'a, 'gcx, 'tcx> Generics {
839824
for param in self.params.iter() {
840825
match param.kind {
841826
GenericParamDefKind::Type(_) => return true,
842-
GenericParamDefKind::Lifetime(_) => {}
827+
GenericParamDefKind::Lifetime => {}
843828
}
844829
}
845830
if let Some(parent_def_id) = self.parent {
@@ -858,7 +843,7 @@ impl<'a, 'gcx, 'tcx> Generics {
858843
if let Some(index) = param.index.checked_sub(self.parent_count as u32) {
859844
let param = &self.params[index as usize];
860845
match param.kind {
861-
ty::GenericParamDefKind::Lifetime(_) => param,
846+
ty::GenericParamDefKind::Lifetime => param,
862847
_ => bug!("expected region parameter, but found another generic parameter")
863848
}
864849
} else {

src/librustc/ty/subst.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> {
243243
FT: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Ty<'tcx> {
244244
for param in &defs.params {
245245
let kind = match param.kind {
246-
ty::GenericParamDefKind::Lifetime(_) => mk_region(param, substs).into(),
246+
ty::GenericParamDefKind::Lifetime => mk_region(param, substs).into(),
247247
ty::GenericParamDefKind::Type(_) => mk_type(param, substs).into(),
248248
};
249249
assert_eq!(param.index as usize, substs.len());

src/librustc/ty/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,12 +505,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
505505
.filter(|&(_, &k)| {
506506
match k.unpack() {
507507
UnpackedKind::Lifetime(&ty::RegionKind::ReEarlyBound(ref ebr)) => {
508-
!impl_generics.region_param(ebr, self).to_lifetime().pure_wrt_drop
508+
!impl_generics.region_param(ebr, self).pure_wrt_drop
509509
}
510510
UnpackedKind::Type(&ty::TyS {
511511
sty: ty::TypeVariants::TyParam(ref pt), ..
512512
}) => {
513-
!impl_generics.type_param(pt, self).to_type().pure_wrt_drop
513+
!impl_generics.type_param(pt, self).pure_wrt_drop
514514
}
515515
UnpackedKind::Lifetime(_) | UnpackedKind::Type(_) => {
516516
// not a type or region param - this should be reported

src/librustc/util/ppaux.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ impl PrintContext {
340340
generics.params.iter().rev().filter_map(|param| {
341341
match param.kind {
342342
GenericParamDefKind::Type(ty) => Some((param.def_id, ty.has_default)),
343-
GenericParamDefKind::Lifetime(_) => None,
343+
GenericParamDefKind::Lifetime => None,
344344
}
345345
});
346346
if let Some(last_ty) = type_params.next() {
@@ -606,7 +606,7 @@ define_print! {
606606
impl fmt::Debug for ty::GenericParamDef {
607607
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
608608
let type_name = match self.kind {
609-
ty::GenericParamDefKind::Lifetime(_) => "Lifetime",
609+
ty::GenericParamDefKind::Lifetime => "Lifetime",
610610
ty::GenericParamDefKind::Type(_) => "Type",
611611
};
612612
write!(f, "{}({}, {:?}, {})",

0 commit comments

Comments
 (0)