pub fn type_known_to_meet_builtin_bound<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
                                                        ty: Ty<'tcx>,
                                                        bound: ty::BuiltinBound,
                                                        span: Span)
                                                        -> bool
{
    debug!("type_known_to_meet_builtin_bound(ty={:?}, bound={:?})",
           ty,
           bound);

    let cause = ObligationCause::misc(span, ast::DUMMY_NODE_ID);
    let obligation =
        infcx.tcx.predicate_for_builtin_bound(cause, bound, 0, ty);
    let obligation = match obligation {
        Ok(o) => o,
        Err(..) => return false
    };
    let result = SelectionContext::new(infcx)
        .evaluate_obligation_conservatively(&obligation);
    debug!("type_known_to_meet_builtin_bound: ty={:?} bound={:?} => {:?}",
           ty, bound, result);

    if result && (ty.has_infer_types() || ty.has_closure_types()) {
        // Because of inference "guessing", selection can sometimes claim
        // to succeed while the success requires a guess. To ensure
        // this function's result remains infallible, we must confirm
        // that guess. While imperfect, I believe this is sound.

        let mut fulfill_cx = FulfillmentContext::new();

        // We can use a dummy node-id here because we won't pay any mind
        // to region obligations that arise (there shouldn't really be any
        // anyhow).
        let cause = ObligationCause::misc(span, ast::DUMMY_NODE_ID);

        fulfill_cx.register_builtin_bound(infcx, ty, bound, cause);

        // Note: we only assume something is `Copy` if we can
        // *definitively* show that it implements `Copy`. Otherwise,
        // assume it is move; linear is always ok.
        match fulfill_cx.select_all_or_error(infcx) {
            Ok(()) => {
                debug!("type_known_to_meet_builtin_bound: ty={:?} bound={:?} success",
                       ty,
                       bound);
                true
            }
            Err(e) => {
                debug!("type_known_to_meet_builtin_bound: ty={:?} bound={:?} errors={:?}",
                       ty,
                       bound,
                       e);
                false
            }
        }
    } else {
        result
    }
}
/// Determines whether the type `ty` is known to meet `bound` and
/// returns true if so. Returns false if `ty` either does not meet
/// `bound` or is not known to meet bound (note that this is
/// conservative towards *no impl*, which is the opposite of the
/// `evaluate` methods).
Determines whether the type `ty` is known to meet `bound` and
returns true if so.
Determines whether the type ` ty ` is known to meet ` bound ` and returns true if so .
pub fn type_known_to_meet_builtin_bound<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
                                                        ty: Ty<'tcx>,
                                                        bound: ty::BuiltinBound,
                                                        span: Span)
                                                        -> bool
{
    debug!("type_known_to_meet_builtin_bound(ty={:?}, bound={:?})",
           ty,
           bound);
    let cause = ObligationCause::misc(span, ast::DUMMY_NODE_ID);
    let obligation =
        infcx.tcx.predicate_for_builtin_bound(cause, bound, 0, ty);
    let obligation = match obligation {
        Ok(o) => o,
        Err(..) => return false
    };
    let result = SelectionContext::new(infcx)
        .evaluate_obligation_conservatively(&obligation);
    debug!("type_known_to_meet_builtin_bound: ty={:?} bound={:?} => {:?}",
           ty, bound, result);
    if result && (ty.has_infer_types() || ty.has_closure_types()) {
        // Because of inference "guessing", selection can sometimes claim
        // to succeed while the success requires a guess. To ensure
        // this function's result remains infallible, we must confirm
        // that guess. While imperfect, I believe this is sound.
        let mut fulfill_cx = FulfillmentContext::new();
        // We can use a dummy node-id here because we won't pay any mind
        // to region obligations that arise (there shouldn't really be any
        // anyhow).
        let cause = ObligationCause::misc(span, ast::DUMMY_NODE_ID);
        fulfill_cx.register_builtin_bound(infcx, ty, bound, cause);
        // Note: we only assume something is `Copy` if we can
        // *definitively* show that it implements `Copy`. Otherwise,
        // assume it is move; linear is always ok.
        match fulfill_cx.select_all_or_error(infcx) {
            Ok(()) => {
                debug!("type_known_to_meet_builtin_bound: ty={:?} bound={:?} success",
                       ty,
                       bound);
                true
            }
            Err(e) => {
                debug!("type_known_to_meet_builtin_bound: ty={:?} bound={:?} errors={:?}",
                       ty,
                       bound,
                       e);
                false
            }
        }
    } else {
        result
    }
}
pub fn type_known_to_meet_builtin_bound < ' a , ' gcx , ' tcx > ( infcx : & InferCtxt < ' a , ' gcx , ' tcx > , ty : Ty < ' tcx > , bound : ty :: BuiltinBound , span : Span ) -> bool { debug ! ( " " ty bound ) ; let cause = ObligationCause :: misc ( span , ast :: DUMMY_NODE_ID ) ; let obligation = infcx . tcx . predicate_for_builtin_bound ( cause , bound , 0 , ty ) ; let obligation = match obligation { Ok ( o ) => o , Err ( .. ) => return false } ; let result = SelectionContext :: new ( infcx ) . evaluate_obligation_conservatively ( & obligation ) ; debug ! ( " " ty bound result ) ; if result && ( ty . has_infer_types ( ) || ty . has_closure_types ( ) ) { // Because of inference "guessing", selection can sometimes claim // to succeed while the success requires a guess. To ensure // this function's result remains infallible, we must confirm // that guess. While imperfect, I believe this is sound. let mut fulfill_cx = FulfillmentContext :: new ( ) ; // We can use a dummy node-id here because we won't pay any mind // to region obligations that arise (there shouldn't really be any // anyhow). let cause = ObligationCause :: misc ( span , ast :: DUMMY_NODE_ID ) ; fulfill_cx . register_builtin_bound ( infcx , ty , bound , cause ) ; // Note: we only assume something is `Copy` if we can // *definitively* show that it implements `Copy`. Otherwise, // assume it is move; linear is always ok. match fulfill_cx . select_all_or_error ( infcx ) { Ok ( ( ) ) => { debug ! ( " " ty bound ) ; true } Err ( e ) => { debug ! ( " " ty bound e ) ; false } } } else { result } }
Determines whether the type `ty` is known to meet `bound` and
returns true if so.
Determines whether the type ` ty ` is known to meet ` bound ` and returns true if so .
infcx
&InferCtxt<'a, 'gcx, 'tcx>
ty
Ty<'tcx>
bound
ty::BuiltinBound
span
Span
infcx
&InferCtxt<'a, 'gcx, 'tcx>
ty
Ty<'tcx>
bound
ty::BuiltinBound
span
Span