fn compute_object_lifetime_bound(&self,
        span: Span,
        explicit_region_bounds: &[&hir::Lifetime],
        existential_predicates: ty::Binder<&'tcx ty::Slice<ty::ExistentialPredicate<'tcx>>>)
        -> Option<&'tcx ty::Region> // if None, use the default
    {
        let tcx = self.tcx();

        debug!("compute_opt_region_bound(explicit_region_bounds={:?}, \
               existential_predicates={:?})",
               explicit_region_bounds,
               existential_predicates);

        if explicit_region_bounds.len() > 1 {
            span_err!(tcx.sess, explicit_region_bounds[1].span, E0226,
                "only a single explicit lifetime bound is permitted");
        }

        if let Some(&r) = explicit_region_bounds.get(0) {
            // Explicitly specified region bound. Use that.
            return Some(ast_region_to_region(tcx, r));
        }

        if let Some(principal) = existential_predicates.principal() {
            if let Err(ErrorReported) = self.ensure_super_predicates(span, principal.def_id()) {
                return Some(tcx.mk_region(ty::ReStatic));
            }
        }

        // No explicit region bound specified. Therefore, examine trait
        // bounds and see if we can derive region bounds from those.
        let derived_region_bounds =
            object_region_bounds(tcx, existential_predicates);

        // If there are no derived region bounds, then report back that we
        // can find no region bound. The caller will use the default.
        if derived_region_bounds.is_empty() {
            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(tcx.mk_region(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[1..].iter().any(|r1| r != *r1) {
            span_err!(tcx.sess, span, E0227,
                      "ambiguous lifetime bound, explicit lifetime bound required");
        }
        return Some(r);
    }
/// Given the bounds on an object, 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 an object, 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 an object 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 ` .
fn compute_object_lifetime_bound(&self,
        span: Span,
        explicit_region_bounds: &[&hir::Lifetime],
        existential_predicates: ty::Binder<&'tcx ty::Slice<ty::ExistentialPredicate<'tcx>>>)
        -> Option<&'tcx ty::Region> // if None, use the default
    {
        let tcx = self.tcx();
        debug!("compute_opt_region_bound(explicit_region_bounds={:?}, \
               existential_predicates={:?})",
               explicit_region_bounds,
               existential_predicates);
        if explicit_region_bounds.len() > 1 {
            span_err!(tcx.sess, explicit_region_bounds[1].span, E0226,
                "only a single explicit lifetime bound is permitted");
        }
        if let Some(&r) = explicit_region_bounds.get(0) {
            // Explicitly specified region bound. Use that.
            return Some(ast_region_to_region(tcx, r));
        }
        if let Some(principal) = existential_predicates.principal() {
            if let Err(ErrorReported) = self.ensure_super_predicates(span, principal.def_id()) {
                return Some(tcx.mk_region(ty::ReStatic));
            }
        }
        // No explicit region bound specified. Therefore, examine trait
        // bounds and see if we can derive region bounds from those.
        let derived_region_bounds =
            object_region_bounds(tcx, existential_predicates);
        // If there are no derived region bounds, then report back that we
        // can find no region bound. The caller will use the default.
        if derived_region_bounds.is_empty() {
            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(tcx.mk_region(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[1..].iter().any(|r1| r != *r1) {
            span_err!(tcx.sess, span, E0227,
                      "ambiguous lifetime bound, explicit lifetime bound required");
        }
        return Some(r);
    }
fn compute_object_lifetime_bound ( & self , span : Span , explicit_region_bounds : & [ & hir :: Lifetime ] , existential_predicates : ty :: Binder < & ' tcx ty :: Slice < ty :: ExistentialPredicate < ' tcx > > > ) -> Option < & ' tcx ty :: Region > // if None, use the default { let tcx = self . tcx ( ) ; debug ! ( " \
 " explicit_region_bounds existential_predicates ) ; if explicit_region_bounds . len ( ) > 1 { span_err ! ( tcx sess explicit_region_bounds [ 1 ] span E0226 " " ) ; } if let Some ( & r ) = explicit_region_bounds . get ( 0 ) { // Explicitly specified region bound. Use that. return Some ( ast_region_to_region ( tcx , r ) ) ; } if let Some ( principal ) = existential_predicates . principal ( ) { if let Err ( ErrorReported ) = self . ensure_super_predicates ( span , principal . def_id ( ) ) { return Some ( tcx . mk_region ( ty :: ReStatic ) ) ; } } // No explicit region bound specified. Therefore, examine trait // bounds and see if we can derive region bounds from those. let derived_region_bounds = object_region_bounds ( tcx , existential_predicates ) ; // If there are no derived region bounds, then report back that we // can find no region bound. The caller will use the default. if derived_region_bounds . is_empty ( ) { 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 ( tcx . mk_region ( 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 [ 1 .. ] . iter ( ) . any ( | r1 | r != * r1 ) { span_err ! ( tcx sess span E0227 " " ) ; } return Some ( r ) ; }
Given the bounds on an object, determines what single region bound (if any) we can
use to summarize this type.
Given the bounds on an object determines what single region bound ( if any ) we can use to summarize this type .
&self
span
Span
explicit_region_bounds
&[&hir::Lifetime]
existential_predicates
ty::Binder<&'tcx ty::Slice<ty::ExistentialPredicate<'tcx>>>