/// This method populates the region map's `free_region_map`. It walks over the transformed
/// argument and return types for each function just before we check the body of that function,
/// looking for types where you have a borrowed pointer to other borrowed data (e.g., `&'a &'b
/// [usize]`.  We do not allow references to outlive the things they point at, so we can assume
/// that `'a <= 'b`. This holds for both the argument and return types, basically because, on
/// the caller side, the caller is responsible for checking that the type of every expression
/// (including the actual values for the arguments, as well as the return type of the fn call)
/// is well-formed.
///
/// Tests: `src/test/compile-fail/regions-free-region-ordering-*.rs`
This method populates the region map's `free_region_map`. It walks over the transformed
argument and return types for each function just before we check the body of that function,
looking for types where you have a borrowed pointer to other borrowed data
is well-formed.


This method populates the region map ' s ` free_region_map ` . It walks over the transformed argument and return types for each function just before we check the body of that function looking for types where you have a borrowed pointer to other borrowed data is well - formed .
fn relate_free_regions(&mut self,
                           fn_sig_tys: &[Ty<'tcx>],
                           body_id: ast::NodeId,
                           span: Span) {
        debug!("relate_free_regions >>");
        for &ty in fn_sig_tys {
            let ty = self.resolve_type(ty);
            debug!("relate_free_regions(t={:?})", ty);
            let implied_bounds = wf::implied_bounds(self.fcx.infcx(), body_id, ty, span);
            // Record any relations between free regions that we observe into the free-region-map.
            self.free_region_map.relate_free_regions_from_implied_bounds(&implied_bounds);
            // But also record other relationships, such as `T:'x`,
            // that don't go into the free-region-map but which we use
            // here.
            for implication in implied_bounds {
                debug!("implication: {:?}", implication);
                match implication {
                    ImpliedBound::RegionSubRegion(ty::ReFree(free_a),
                                                  ty::ReVar(vid_b)) => {
                        self.fcx.inh.infcx.add_given(free_a, vid_b);
                    }
                    ImpliedBound::RegionSubParam(r_a, param_b) => {
                        self.region_bound_pairs.push((r_a, GenericKind::Param(param_b)));
                    }
                    ImpliedBound::RegionSubProjection(r_a, projection_b) => {
                        self.region_bound_pairs.push((r_a, GenericKind::Projection(projection_b)));
                    }
                    ImpliedBound::RegionSubRegion(..) => {
                        // In principle, we could record (and take
                        // advantage of) every relationship here, but
                        // we are also free not to -- it simply means
                        // strictly less that we can successfully type
                        // check. (It may also be that we should
                        // revise our inference system to be more
                        // general and to make use of *every*
                        // relationship that arises here, but
                        // presently we do not.)
                    }
                }
            }
        }
        debug!("<< relate_free_regions");
    }
fn relate_free_regions ( & mut self , fn_sig_tys : & [ Ty < ' tcx > ] , body_id : ast :: NodeId , span : Span ) { debug ! ( " " ) ; for & ty in fn_sig_tys { let ty = self . resolve_type ( ty ) ; debug ! ( " " ty ) ; let implied_bounds = wf :: implied_bounds ( self . fcx . infcx ( ) , body_id , ty , span ) ; // Record any relations between free regions that we observe into the free-region-map. self . free_region_map . relate_free_regions_from_implied_bounds ( & implied_bounds ) ; // But also record other relationships, such as `T:'x`, // that don't go into the free-region-map but which we use // here. for implication in implied_bounds { debug ! ( " " implication ) ; match implication { ImpliedBound :: RegionSubRegion ( ty :: ReFree ( free_a ) , ty :: ReVar ( vid_b ) ) => { self . fcx . inh . infcx . add_given ( free_a , vid_b ) ; } ImpliedBound :: RegionSubParam ( r_a , param_b ) => { self . region_bound_pairs . push ( ( r_a , GenericKind :: Param ( param_b ) ) ) ; } ImpliedBound :: RegionSubProjection ( r_a , projection_b ) => { self . region_bound_pairs . push ( ( r_a , GenericKind :: Projection ( projection_b ) ) ) ; } ImpliedBound :: RegionSubRegion ( .. ) => { // In principle, we could record (and take // advantage of) every relationship here, but // we are also free not to -- it simply means // strictly less that we can successfully type // check. (It may also be that we should // revise our inference system to be more // general and to make use of *every* // relationship that arises here, but // presently we do not.) } } } } debug ! ( " " ) ; }
This method populates the region map's `free_region_map`.
This method populates the region map ' s ` free_region_map ` .
&mut self
fn_sig_tys
&[Ty<'tcx>]
body_id
ast::NodeId
span
Span