pub fn compute_opt_region_bound<'tcx>(tcx: &ty::ctxt<'tcx>,
                                      span: Span,
                                      builtin_bounds: ty::BuiltinBounds,
                                      region_bounds: &[&ast::Lifetime],
                                      trait_bounds: &[Rc<ty::TraitRef<'tcx>>])
                                      -> Option<ty::Region>
{
    if region_bounds.len() > 1 {
        tcx.sess.span_err(
            region_bounds[1].span,
            format!("only a single explicit lifetime bound is permitted").as_slice());
    }

    if region_bounds.len() != 0 {
        // Explicitly specified region bound. Use that.
        let r = region_bounds[0];
        return Some(ast_region_to_region(tcx, r));
    }

    // No explicit region bound specified. Therefore, examine trait
    // bounds and see if we can derive region bounds from those.
    let derived_region_bounds =
        ty::required_region_bounds(
            tcx,
            &[],
            builtin_bounds,
            trait_bounds);

    // If there are no derived region bounds, then report back that we
    // can find no region bound.
    if derived_region_bounds.len() == 0 {
        return None;
    }

    // If any of the derived region bounds are 'static, that is always
    // the best choice.
    if derived_region_bounds.iter().any(|r| ty::ReStatic == *r) {
        return Some(ty::ReStatic);
    }

    // Determine whether there is exactly one unique region in the set
    // of derived region bounds. If so, use that. Otherwise, report an
    // error.
    let r = derived_region_bounds[0];
    if derived_region_bounds.slice_from(1).iter().any(|r1| r != *r1) {
        tcx.sess.span_err(
            span,
            format!("ambiguous lifetime bound, \
                     explicit lifetime bound required").as_slice());
    }
    return Some(r);
}
/// Given the bounds on a type parameter / existential type, determines what single region bound
/// (if any) we can use to summarize this type. The basic idea is that we will use the bound the
/// user provided, if they provided one, and otherwise search the supertypes of trait bounds for
/// region bounds. It may be that we can derive no bound at all, in which case we return `None`.
Given the bounds on a type parameter / existential type, determines what single region bound
(if any) we can use to summarize this type. The basic idea is that we will use the bound the
user provided, if they provided one, and otherwise search the supertypes of trait bounds for
region bounds. It may be that we can derive no bound at all, in which case we return `None`.
Given the bounds on a type parameter / existential type determines what single region bound ( if any ) we can use to summarize this type . The basic idea is that we will use the bound the user provided if they provided one and otherwise search the supertypes of trait bounds for region bounds . It may be that we can derive no bound at all in which case we return ` None ` .
pub fn compute_opt_region_bound<'tcx>(tcx: &ty::ctxt<'tcx>,
                                      span: Span,
                                      builtin_bounds: ty::BuiltinBounds,
                                      region_bounds: &[&ast::Lifetime],
                                      trait_bounds: &[Rc<ty::TraitRef<'tcx>>])
                                      -> Option<ty::Region>
{
    if region_bounds.len() > 1 {
        tcx.sess.span_err(
            region_bounds[1].span,
            format!("only a single explicit lifetime bound is permitted").as_slice());
    }
    if region_bounds.len() != 0 {
        // Explicitly specified region bound. Use that.
        let r = region_bounds[0];
        return Some(ast_region_to_region(tcx, r));
    }
    // No explicit region bound specified. Therefore, examine trait
    // bounds and see if we can derive region bounds from those.
    let derived_region_bounds =
        ty::required_region_bounds(
            tcx,
            &[],
            builtin_bounds,
            trait_bounds);
    // If there are no derived region bounds, then report back that we
    // can find no region bound.
    if derived_region_bounds.len() == 0 {
        return None;
    }
    // If any of the derived region bounds are 'static, that is always
    // the best choice.
    if derived_region_bounds.iter().any(|r| ty::ReStatic == *r) {
        return Some(ty::ReStatic);
    }
    // Determine whether there is exactly one unique region in the set
    // of derived region bounds. If so, use that. Otherwise, report an
    // error.
    let r = derived_region_bounds[0];
    if derived_region_bounds.slice_from(1).iter().any(|r1| r != *r1) {
        tcx.sess.span_err(
            span,
            format!("ambiguous lifetime bound, \
                     explicit lifetime bound required").as_slice());
    }
    return Some(r);
}
pub fn compute_opt_region_bound < ' tcx > ( tcx : & ty :: ctxt < ' tcx > , span : Span , builtin_bounds : ty :: BuiltinBounds , region_bounds : & [ & ast :: Lifetime ] , trait_bounds : & [ Rc < ty :: TraitRef < ' tcx > > ] ) -> Option < ty :: Region > { if region_bounds . len ( ) > 1 { tcx . sess . span_err ( region_bounds [ 1 ] . span , format ! ( " " ) . as_slice ( ) ) ; } if region_bounds . len ( ) != 0 { // Explicitly specified region bound. Use that. let r = region_bounds [ 0 ] ; return Some ( ast_region_to_region ( tcx , r ) ) ; } // No explicit region bound specified. Therefore, examine trait // bounds and see if we can derive region bounds from those. let derived_region_bounds = ty :: required_region_bounds ( tcx , & [ ] , builtin_bounds , trait_bounds ) ; // If there are no derived region bounds, then report back that we // can find no region bound. if derived_region_bounds . len ( ) == 0 { return None ; } // If any of the derived region bounds are 'static, that is always // the best choice. if derived_region_bounds . iter ( ) . any ( | r | ty :: ReStatic == * r ) { return Some ( ty :: ReStatic ) ; } // Determine whether there is exactly one unique region in the set // of derived region bounds. If so, use that. Otherwise, report an // error. let r = derived_region_bounds [ 0 ] ; if derived_region_bounds . slice_from ( 1 ) . iter ( ) . any ( | r1 | r != * r1 ) { tcx . sess . span_err ( span , format ! ( " \
 " ) . as_slice ( ) ) ; } return Some ( r ) ; }
Given the bounds on a type parameter / existential type, determines what single region bound
(if any) we can use to summarize this type.
Given the bounds on a type parameter / existential type determines what single region bound ( if any ) we can use to summarize this type .
tcx
&ty::ctxt<'tcx>
span
Span
builtin_bounds
ty::BuiltinBounds
region_bounds
&[&ast::Lifetime]
trait_bounds
&[Rc<ty::TraitRef<'tcx>>]