@@ -53,7 +53,7 @@ pub use subst::*;
53
53
pub use vtable:: * ;
54
54
55
55
use std:: fmt:: Debug ;
56
- use std:: hash:: { Hash , Hasher } ;
56
+ use std:: hash:: Hash ;
57
57
use std:: { fmt, str} ;
58
58
59
59
pub use crate :: ty:: diagnostics:: * ;
@@ -142,6 +142,7 @@ mod typeck_results;
142
142
143
143
mod alias_relation_direction;
144
144
mod bound_constness;
145
+ mod field_def;
145
146
mod impl_polarity;
146
147
mod opaque_hidden_type;
147
148
mod param_env;
@@ -153,6 +154,7 @@ mod visibility;
153
154
154
155
pub use alias_relation_direction:: AliasRelationDirection ;
155
156
pub use bound_constness:: BoundConstness ;
157
+ pub use field_def:: FieldDef ;
156
158
pub use impl_polarity:: ImplPolarity ;
157
159
pub use opaque_hidden_type:: OpaqueHiddenType ;
158
160
pub use param_env:: { ParamEnv , ParamEnvAnd } ;
@@ -490,62 +492,6 @@ pub enum VariantDiscr {
490
492
Relative ( u32 ) ,
491
493
}
492
494
493
- #[ derive( Debug , HashStable , TyEncodable , TyDecodable ) ]
494
- pub struct FieldDef {
495
- pub did : DefId ,
496
- pub name : Symbol ,
497
- pub vis : Visibility < DefId > ,
498
- }
499
-
500
- impl PartialEq for FieldDef {
501
- #[ inline]
502
- fn eq ( & self , other : & Self ) -> bool {
503
- // There should be only one `FieldDef` for each `did`, therefore it is
504
- // fine to implement `PartialEq` only based on `did`.
505
- //
506
- // Below, we exhaustively destructure `self` so that if the definition
507
- // of `FieldDef` changes, a compile-error will be produced, reminding
508
- // us to revisit this assumption.
509
-
510
- let Self { did : lhs_did, name : _, vis : _ } = & self ;
511
-
512
- let Self { did : rhs_did, name : _, vis : _ } = other;
513
-
514
- lhs_did == rhs_did
515
- }
516
- }
517
-
518
- impl Eq for FieldDef { }
519
-
520
- impl Hash for FieldDef {
521
- #[ inline]
522
- fn hash < H : Hasher > ( & self , s : & mut H ) {
523
- // There should be only one `FieldDef` for each `did`, therefore it is
524
- // fine to implement `Hash` only based on `did`.
525
- //
526
- // Below, we exhaustively destructure `self` so that if the definition
527
- // of `FieldDef` changes, a compile-error will be produced, reminding
528
- // us to revisit this assumption.
529
-
530
- let Self { did, name : _, vis : _ } = & self ;
531
-
532
- did. hash ( s)
533
- }
534
- }
535
-
536
- impl < ' tcx > FieldDef {
537
- /// Returns the type of this field. The resulting type is not normalized. The `subst` is
538
- /// typically obtained via the second field of [`TyKind::Adt`].
539
- pub fn ty ( & self , tcx : TyCtxt < ' tcx > , subst : SubstsRef < ' tcx > ) -> Ty < ' tcx > {
540
- tcx. type_of ( self . did ) . subst ( tcx, subst)
541
- }
542
-
543
- /// Computes the `Ident` of this variant by looking up the `Span`
544
- pub fn ident ( & self , tcx : TyCtxt < ' _ > ) -> Ident {
545
- Ident :: new ( self . name , tcx. def_ident_span ( self . did ) . unwrap ( ) )
546
- }
547
- }
548
-
549
495
#[ derive( Debug , PartialEq , Eq ) ]
550
496
pub enum ImplOverlapKind {
551
497
/// These impls are always allowed to overlap.
0 commit comments