Trait rustc_lint::middle::mem_categorization::TyperUnstable [-] [+] [src]

pub trait Typer<'tcx>: ClosureTyper<'tcx> {
    fn node_ty(&self, id: u32) -> Result<&'tcx TyS<'tcx>, ()>;
    fn expr_ty_adjusted(&self, expr: &Expr) -> Result<&'tcx TyS<'tcx>, ()>;
    fn type_moves_by_default(&self, span: Span, ty: &'tcx TyS<'tcx>) -> bool;
    fn node_method_ty(&self, method_call: MethodCall) -> Option<&'tcx TyS<'tcx>>;
    fn node_method_origin(&self, method_call: MethodCall) -> Option<MethodOrigin<'tcx>>;
    fn adjustments(&'a self) -> &'a RefCell<HashMap<u32, AutoAdjustment<'tcx>, DefaultState<FnvHasher>>>;
    fn is_method_call(&self, id: u32) -> bool;
    fn temporary_scope(&self, rvalue_id: u32) -> Option<CodeExtent>;
    fn upvar_capture(&self, upvar_id: UpvarId) -> Option<UpvarCapture>;
}

The Typer trait provides the interface for the mem-categorization module to the results of the type check. It can be used to query the type assigned to an expression node, to inquire after adjustments, and so on.

This interface is needed because mem-categorization is used from two places: regionck and borrowck. regionck executes before type inference is complete, and hence derives types and so on from intermediate tables. This also implies that type errors can occur, and hence node_ty() and friends return a Result type -- any error will propagate back up through the mem-categorization routines.

In the borrow checker, in contrast, type checking is complete and we know that no errors have occurred, so we simply consult the tcx and we can be sure that only Ok results will occur.

Required Methods

fn node_ty(&self, id: u32) -> Result<&'tcx TyS<'tcx>, ()>

fn expr_ty_adjusted(&self, expr: &Expr) -> Result<&'tcx TyS<'tcx>, ()>

fn type_moves_by_default(&self, span: Span, ty: &'tcx TyS<'tcx>) -> bool

fn node_method_ty(&self, method_call: MethodCall) -> Option<&'tcx TyS<'tcx>>

fn node_method_origin(&self, method_call: MethodCall) -> Option<MethodOrigin<'tcx>>

fn adjustments(&'a self) -> &'a RefCell<HashMap<u32, AutoAdjustment<'tcx>, DefaultState<FnvHasher>>>

fn is_method_call(&self, id: u32) -> bool

fn temporary_scope(&self, rvalue_id: u32) -> Option<CodeExtent>

fn upvar_capture(&self, upvar_id: UpvarId) -> Option<UpvarCapture>

Implementors