fn check_const_with_type<'a, 'tcx>(ccx: &'a CrateCtxt<'a, 'tcx>,
                                   body: hir::BodyId,
                                   expected_type: Ty<'tcx>,
                                   id: ast::NodeId) {
    let body = ccx.tcx.hir.body(body);
    ccx.inherited(id).enter(|inh| {
        let fcx = FnCtxt::new(&inh, None, body.value.id);
        fcx.require_type_is_sized(expected_type, body.value.span, traits::ConstSized);

        // Gather locals in statics (because of block expressions).
        // This is technically unnecessary because locals in static items are forbidden,
        // but prevents type checking from blowing up before const checking can properly
        // emit an error.
        GatherLocalsVisitor { fcx: &fcx }.visit_body(body);

        fcx.check_expr_coercable_to_type(&body.value, expected_type);

        fcx.select_all_obligations_and_apply_defaults();
        fcx.closure_analyze(body);
        fcx.select_obligations_where_possible();
        fcx.check_casts();
        fcx.select_all_obligations_or_error();

        fcx.regionck_expr(body);
        fcx.resolve_type_vars_in_body(body);
    });
}
/// Checks a constant with a given type.
Checks a constant with a given type.
Checks a constant with a given type .
fn check_const_with_type<'a, 'tcx>(ccx: &'a CrateCtxt<'a, 'tcx>,
                                   body: hir::BodyId,
                                   expected_type: Ty<'tcx>,
                                   id: ast::NodeId) {
    let body = ccx.tcx.hir.body(body);
    ccx.inherited(id).enter(|inh| {
        let fcx = FnCtxt::new(&inh, None, body.value.id);
        fcx.require_type_is_sized(expected_type, body.value.span, traits::ConstSized);
        // Gather locals in statics (because of block expressions).
        // This is technically unnecessary because locals in static items are forbidden,
        // but prevents type checking from blowing up before const checking can properly
        // emit an error.
        GatherLocalsVisitor { fcx: &fcx }.visit_body(body);
        fcx.check_expr_coercable_to_type(&body.value, expected_type);
        fcx.select_all_obligations_and_apply_defaults();
        fcx.closure_analyze(body);
        fcx.select_obligations_where_possible();
        fcx.check_casts();
        fcx.select_all_obligations_or_error();
        fcx.regionck_expr(body);
        fcx.resolve_type_vars_in_body(body);
    });
}
fn check_const_with_type < ' a , ' tcx > ( ccx : & ' a CrateCtxt < ' a , ' tcx > , body : hir :: BodyId , expected_type : Ty < ' tcx > , id : ast :: NodeId ) { let body = ccx . tcx . hir . body ( body ) ; ccx . inherited ( id ) . enter ( | inh | { let fcx = FnCtxt :: new ( & inh , None , body . value . id ) ; fcx . require_type_is_sized ( expected_type , body . value . span , traits :: ConstSized ) ; // Gather locals in statics (because of block expressions). // This is technically unnecessary because locals in static items are forbidden, // but prevents type checking from blowing up before const checking can properly // emit an error. GatherLocalsVisitor { fcx : & fcx } . visit_body ( body ) ; fcx . check_expr_coercable_to_type ( & body . value , expected_type ) ; fcx . select_all_obligations_and_apply_defaults ( ) ; fcx . closure_analyze ( body ) ; fcx . select_obligations_where_possible ( ) ; fcx . check_casts ( ) ; fcx . select_all_obligations_or_error ( ) ; fcx . regionck_expr ( body ) ; fcx . resolve_type_vars_in_body ( body ) ; } ) ; }
Checks a constant with a given type.
Checks a constant with a given type .
ccx
&'a CrateCtxt<'a, 'tcx>
body
hir::BodyId
expected_type
Ty<'tcx>
id
ast::NodeId
ccx
&'a CrateCtxt<'a, 'tcx>
body
hir::BodyId
expected_type
Ty<'tcx>
id
ast::NodeId