@@ -1504,8 +1504,7 @@ pub struct VariantDef {
1504
1504
/// If this variant is a struct variant, then this is `None`.
1505
1505
pub ctor_def_id : Option < DefId > ,
1506
1506
/// Variant or struct name.
1507
- #[ stable_hasher( project( name) ) ]
1508
- pub ident : Ident ,
1507
+ pub name : Symbol ,
1509
1508
/// Discriminant of this variant.
1510
1509
pub discr : VariantDiscr ,
1511
1510
/// Fields of this variant.
@@ -1534,7 +1533,7 @@ impl VariantDef {
1534
1533
/// If someone speeds up attribute loading to not be a performance concern, they can
1535
1534
/// remove this hack and use the constructor `DefId` everywhere.
1536
1535
pub fn new (
1537
- ident : Ident ,
1536
+ name : Symbol ,
1538
1537
variant_did : Option < DefId > ,
1539
1538
ctor_def_id : Option < DefId > ,
1540
1539
discr : VariantDiscr ,
@@ -1546,9 +1545,9 @@ impl VariantDef {
1546
1545
is_field_list_non_exhaustive : bool ,
1547
1546
) -> Self {
1548
1547
debug ! (
1549
- "VariantDef::new(ident = {:?}, variant_did = {:?}, ctor_def_id = {:?}, discr = {:?},
1548
+ "VariantDef::new(name = {:?}, variant_did = {:?}, ctor_def_id = {:?}, discr = {:?},
1550
1549
fields = {:?}, ctor_kind = {:?}, adt_kind = {:?}, parent_did = {:?})" ,
1551
- ident , variant_did, ctor_def_id, discr, fields, ctor_kind, adt_kind, parent_did,
1550
+ name , variant_did, ctor_def_id, discr, fields, ctor_kind, adt_kind, parent_did,
1552
1551
) ;
1553
1552
1554
1553
let mut flags = VariantFlags :: NO_VARIANT_FLAGS ;
@@ -1563,7 +1562,7 @@ impl VariantDef {
1563
1562
VariantDef {
1564
1563
def_id : variant_did. unwrap_or ( parent_did) ,
1565
1564
ctor_def_id,
1566
- ident ,
1565
+ name ,
1567
1566
discr,
1568
1567
fields,
1569
1568
ctor_kind,
@@ -1582,6 +1581,11 @@ impl VariantDef {
1582
1581
pub fn is_recovered ( & self ) -> bool {
1583
1582
self . flags . intersects ( VariantFlags :: IS_RECOVERED )
1584
1583
}
1584
+
1585
+ /// Computes the `Ident` of this variant by looking up the `Span`
1586
+ pub fn ident ( & self , tcx : TyCtxt < ' _ > ) -> Ident {
1587
+ Ident :: new ( self . name , tcx. def_ident_span ( self . def_id ) . unwrap ( ) )
1588
+ }
1585
1589
}
1586
1590
1587
1591
#[ derive( Copy , Clone , Debug , PartialEq , Eq , TyEncodable , TyDecodable , HashStable ) ]
@@ -1600,8 +1604,7 @@ pub enum VariantDiscr {
1600
1604
#[ derive( Debug , HashStable , TyEncodable , TyDecodable ) ]
1601
1605
pub struct FieldDef {
1602
1606
pub did : DefId ,
1603
- #[ stable_hasher( project( name) ) ]
1604
- pub ident : Ident ,
1607
+ pub name : Symbol ,
1605
1608
pub vis : Visibility ,
1606
1609
}
1607
1610
@@ -1776,6 +1779,11 @@ impl<'tcx> FieldDef {
1776
1779
pub fn ty ( & self , tcx : TyCtxt < ' tcx > , subst : SubstsRef < ' tcx > ) -> Ty < ' tcx > {
1777
1780
tcx. type_of ( self . did ) . subst ( tcx, subst)
1778
1781
}
1782
+
1783
+ /// Computes the `Ident` of this variant by looking up the `Span`
1784
+ pub fn ident ( & self , tcx : TyCtxt < ' _ > ) -> Ident {
1785
+ Ident :: new ( self . name , tcx. def_ident_span ( self . did ) . unwrap ( ) )
1786
+ }
1779
1787
}
1780
1788
1781
1789
pub type Attributes < ' tcx > = & ' tcx [ ast:: Attribute ] ;
@@ -1892,7 +1900,10 @@ impl<'tcx> TyCtxt<'tcx> {
1892
1900
}
1893
1901
1894
1902
pub fn find_field_index ( self , ident : Ident , variant : & VariantDef ) -> Option < usize > {
1895
- variant. fields . iter ( ) . position ( |field| self . hygienic_eq ( ident, field. ident , variant. def_id ) )
1903
+ variant
1904
+ . fields
1905
+ . iter ( )
1906
+ . position ( |field| self . hygienic_eq ( ident, field. ident ( self ) , variant. def_id ) )
1896
1907
}
1897
1908
1898
1909
/// Returns `true` if the impls are the same polarity and the trait either
0 commit comments