Struct rustc::middle::mem_categorization::MemCategorizationContext[src]

pub struct MemCategorizationContext<'t, TYPER> {
    // some fields omitted
}

Methods

impl<'t, TYPER: Typer> MemCategorizationContext<'t, TYPER>

fn new(typer: &'t TYPER) -> MemCategorizationContext<'t, TYPER>

fn cat_expr(&self, expr: &Expr) -> McResult<cmt>

fn cat_expr_autoderefd(&self, expr: &Expr, autoderefs: uint) -> McResult<cmt>

fn cat_expr_unadjusted(&self, expr: &Expr) -> McResult<cmt>

fn cat_def(&self, id: NodeId, span: Span, expr_ty: t, def: Def) -> McResult<cmt>

fn cat_rvalue_node(&self, id: NodeId, span: Span, expr_ty: t) -> cmt

fn cat_rvalue(&self, cmt_id: NodeId, span: Span, temp_scope: Region, expr_ty: t) -> cmt

fn cat_field<N: ast_node>(&self, node: &N, base_cmt: cmt, f_name: Ident, f_ty: t) -> cmt

fn cat_deref_obj<N: ast_node>(&self, node: &N, base_cmt: cmt) -> cmt

fn cat_index<N: ast_node>(&self, elt: &N, base_cmt: cmt, derefs: uint) -> cmt

Creates a cmt for an indexing operation ([]); this indexing operation may occurs as part of an AutoBorrowVec, which when converting a ~[] to an &[] effectively takes the address of the 0th element.

One subtle aspect of indexing that may not be immediately obvious: for anything other than a fixed-length vector, an operation like x[y] actually consists of two disjoint (from the point of view of borrowck) operations. The first is a deref of x to create a pointer p that points at the first element in the array. The second operation is an index which adds y*sizeof(T) to p to obtain the pointer to x[y]. cat_index will produce a resulting cmt containing both this deref and the indexing, presuming that base_cmt is not of fixed-length type.

In the event that a deref is needed, the "deref count" is taken from the parameter derefs. See the comment on the def'n of root_map_key in borrowck/mod.rs for more details about deref counts; the summary is that derefs should be 0 for an explicit indexing operation and N+1 for an indexing that is part of an auto-adjustment, where N is the number of autoderefs in that adjustment.

Parameters

  • elt: the AST node being indexed
  • base_cmt: the cmt of elt
  • derefs: the deref number to be used for the implicit index deref, if any (see above)

fn cat_slice_pattern(&self, vec_cmt: cmt, slice_pat: &Pat) -> McResult<(cmt, Mutability, Region)>

Given a pattern P like: [_, ..Q, _], where vec_cmt is the cmt for P, slice_pat is the pattern Q, returns: - a cmt for Q - the mutability and region of the slice Q

These last two bits of info happen to be things that borrowck needs.

fn cat_imm_interior<N: ast_node>(&self, node: &N, base_cmt: cmt, interior_ty: t, interior: InteriorKind) -> cmt

fn cat_downcast<N: ast_node>(&self, node: &N, base_cmt: cmt, downcast_ty: t) -> cmt

fn cat_pattern(&self, cmt: cmt, pat: &Pat, op: |&MemCategorizationContext<TYPER>, cmt, &Pat|) -> McResult<()>

fn cmt_to_str(&self, cmt: &cmt_) -> String