@@ -258,15 +258,6 @@ pub struct field_ty {
258
258
pub origin : ast:: DefId , // The DefId of the struct in which the field is declared.
259
259
}
260
260
261
- // Contains information needed to resolve types and (in the future) look up
262
- // the types of AST nodes.
263
- #[ derive( Copy , Clone , PartialEq , Eq , Hash ) ]
264
- pub struct creader_cache_key {
265
- pub cnum : CrateNum ,
266
- pub pos : usize ,
267
- pub len : usize
268
- }
269
-
270
261
#[ derive( Clone , PartialEq , RustcDecodable , RustcEncodable ) ]
271
262
pub struct ItemVariances {
272
263
pub types : VecPerParamSpace < Variance > ,
@@ -351,6 +342,30 @@ pub enum AutoAdjustment<'tcx> {
351
342
/// }
352
343
/// ```
353
344
#[ derive( Copy , Clone , Debug ) ]
345
+
346
+ #[ derive( Copy , PartialEq , Eq ) ]
347
+ pub enum UnsizeKind {
348
+ Vtable ,
349
+ Length
350
+ }
351
+
352
+ /// Returns the kind of unsize information of t, or None
353
+ /// if t is sized or it is unknown.
354
+ pub fn unsize_kind < ' tcx > ( cx : & ctxt < ' tcx > ,
355
+ t : Ty < ' tcx > )
356
+ -> Option < UnsizeKind > {
357
+ match t. sty {
358
+ ty_vec( _, None ) => Some ( Length ) ,
359
+ ty_trait( _) => Some ( Vtable ) ,
360
+ ty_struct( did, substs) => {
361
+ let last_field = struct_fields ( cx, did, substs) . pop ( ) ;
362
+ last_field. map ( |f| unsize_kind ( f. mt . ty ) )
363
+ }
364
+ _ => None
365
+ }
366
+ }
367
+
368
+ #[ derive( Clone , Debug ) ]
354
369
pub struct AutoDerefRef < ' tcx > {
355
370
/// Step 1. Apply a number of dereferences, producing an lvalue.
356
371
pub autoderefs : usize ,
@@ -526,6 +541,15 @@ pub enum vtable_origin<'tcx> {
526
541
// expr to the associated trait ref.
527
542
pub type ObjectCastMap < ' tcx > = RefCell < NodeMap < ty:: PolyTraitRef < ' tcx > > > ;
528
543
544
+ // Contains information needed to resolve types and (in the future) look up
545
+ // the types of AST nodes.
546
+ #[ derive( Copy , Clone , PartialEq , Eq , Hash ) ]
547
+ pub struct creader_cache_key {
548
+ pub cnum : CrateNum ,
549
+ pub pos : usize ,
550
+ pub len : usize
551
+ }
552
+
529
553
/// A restriction that certain types must be the same size. The use of
530
554
/// `transmute` gives rise to these restrictions. These generally
531
555
/// cannot be checked until trans; therefore, each call to `transmute`
0 commit comments