Skip to content

Commit f5bca86

Browse files
committed
Still not ready
1 parent e959fab commit f5bca86

File tree

5 files changed

+425
-149
lines changed

5 files changed

+425
-149
lines changed

src/librustc/middle/ty.rs

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -258,15 +258,6 @@ pub struct field_ty {
258258
pub origin: ast::DefId, // The DefId of the struct in which the field is declared.
259259
}
260260

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-
270261
#[derive(Clone, PartialEq, RustcDecodable, RustcEncodable)]
271262
pub struct ItemVariances {
272263
pub types: VecPerParamSpace<Variance>,
@@ -351,6 +342,30 @@ pub enum AutoAdjustment<'tcx> {
351342
/// }
352343
/// ```
353344
#[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)]
354369
pub struct AutoDerefRef<'tcx> {
355370
/// Step 1. Apply a number of dereferences, producing an lvalue.
356371
pub autoderefs: usize,
@@ -526,6 +541,15 @@ pub enum vtable_origin<'tcx> {
526541
// expr to the associated trait ref.
527542
pub type ObjectCastMap<'tcx> = RefCell<NodeMap<ty::PolyTraitRef<'tcx>>>;
528543

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+
529553
/// A restriction that certain types must be the same size. The use of
530554
/// `transmute` gives rise to these restrictions. These generally
531555
/// cannot be checked until trans; therefore, each call to `transmute`

0 commit comments

Comments
 (0)