pub fn partition_bounds<'a>(tcx: &ty::ctxt,
                            _span: Span,
                            ast_bounds: &'a [ast::TyParamBound])
                            -> PartitionedBounds<'a>
{
    let mut builtin_bounds = ty::empty_builtin_bounds();
    let mut region_bounds = Vec::new();
    let mut trait_bounds = Vec::new();
    let mut trait_def_ids = DefIdMap();
    for ast_bound in ast_bounds.iter() {
        match *ast_bound {
            ast::TraitTyParamBound(ref b, ast::TraitBoundModifier::None) => {
                match ::lookup_def_tcx(tcx, b.trait_ref.path.span, b.trait_ref.ref_id) {
                    def::DefTrait(trait_did) => {
                        match trait_def_ids.get(&trait_did) {
                            // Already seen this trait. We forbid
                            // duplicates in the list (for some
                            // reason).
                            Some(span) => {
                                span_err!(
                                    tcx.sess, b.trait_ref.path.span, E0127,
                                    "trait `{}` already appears in the \
                                     list of bounds",
                                    b.trait_ref.path.user_string(tcx));
                                tcx.sess.span_note(
                                    *span,
                                    "previous appearance is here");

                                continue;
                            }

                            None => { }
                        }

                        trait_def_ids.insert(trait_did, b.trait_ref.path.span);

                        if ty::try_add_builtin_trait(tcx,
                                                     trait_did,
                                                     &mut builtin_bounds) {
                            // FIXME(#20302) -- we should check for things like Copy<T>
                            continue; // success
                        }
                    }
                    _ => {
                        // Not a trait? that's an error, but it'll get
                        // reported later.
                    }
                }
                trait_bounds.push(b);
            }
            ast::TraitTyParamBound(_, ast::TraitBoundModifier::Maybe) => {}
            ast::RegionTyParamBound(ref l) => {
                region_bounds.push(l);
            }
        }
    }

    PartitionedBounds {
        builtin_bounds: builtin_bounds,
        trait_bounds: trait_bounds,
        region_bounds: region_bounds,
    }
}
/// Divides a list of bounds from the AST into three groups: builtin bounds (Copy, Sized etc),
/// general trait bounds, and region bounds.
Divides a list of bounds from the AST into three groups: builtin bounds (Copy, Sized etc),
general trait bounds, and region bounds.
Divides a list of bounds from the AST into three groups : builtin bounds ( Copy Sized etc ) general trait bounds and region bounds .
pub fn partition_bounds<'a>(tcx: &ty::ctxt,
                            _span: Span,
                            ast_bounds: &'a [ast::TyParamBound])
                            -> PartitionedBounds<'a>
{
    let mut builtin_bounds = ty::empty_builtin_bounds();
    let mut region_bounds = Vec::new();
    let mut trait_bounds = Vec::new();
    let mut trait_def_ids = DefIdMap();
    for ast_bound in ast_bounds.iter() {
        match *ast_bound {
            ast::TraitTyParamBound(ref b, ast::TraitBoundModifier::None) => {
                match ::lookup_def_tcx(tcx, b.trait_ref.path.span, b.trait_ref.ref_id) {
                    def::DefTrait(trait_did) => {
                        match trait_def_ids.get(&trait_did) {
                            // Already seen this trait. We forbid
                            // duplicates in the list (for some
                            // reason).
                            Some(span) => {
                                span_err!(
                                    tcx.sess, b.trait_ref.path.span, E0127,
                                    "trait `{}` already appears in the \
                                     list of bounds",
                                    b.trait_ref.path.user_string(tcx));
                                tcx.sess.span_note(
                                    *span,
                                    "previous appearance is here");
                                continue;
                            }
                            None => { }
                        }
                        trait_def_ids.insert(trait_did, b.trait_ref.path.span);
                        if ty::try_add_builtin_trait(tcx,
                                                     trait_did,
                                                     &mut builtin_bounds) {
                            // FIXME(#20302) -- we should check for things like Copy<T>
                            continue; // success
                        }
                    }
                    _ => {
                        // Not a trait? that's an error, but it'll get
                        // reported later.
                    }
                }
                trait_bounds.push(b);
            }
            ast::TraitTyParamBound(_, ast::TraitBoundModifier::Maybe) => {}
            ast::RegionTyParamBound(ref l) => {
                region_bounds.push(l);
            }
        }
    }
    PartitionedBounds {
        builtin_bounds: builtin_bounds,
        trait_bounds: trait_bounds,
        region_bounds: region_bounds,
    }
}
pub fn partition_bounds < ' a > ( tcx : & ty :: ctxt , _span : Span , ast_bounds : & ' a [ ast :: TyParamBound ] ) -> PartitionedBounds < ' a > { let mut builtin_bounds = ty :: empty_builtin_bounds ( ) ; let mut region_bounds = Vec :: new ( ) ; let mut trait_bounds = Vec :: new ( ) ; let mut trait_def_ids = DefIdMap ( ) ; for ast_bound in ast_bounds . iter ( ) { match * ast_bound { ast :: TraitTyParamBound ( ref b , ast :: TraitBoundModifier :: None ) => { match :: lookup_def_tcx ( tcx , b . trait_ref . path . span , b . trait_ref . ref_id ) { def :: DefTrait ( trait_did ) => { match trait_def_ids . get ( & trait_did ) { // Already seen this trait. We forbid // duplicates in the list (for some // reason). Some ( span ) => { span_err ! ( tcx sess b trait_ref path span E0127 " \
 " b trait_ref path user_string ( tcx ) ) ; tcx . sess . span_note ( * span , " " ) ; continue ; } None => { } } trait_def_ids . insert ( trait_did , b . trait_ref . path . span ) ; if ty :: try_add_builtin_trait ( tcx , trait_did , & mut builtin_bounds ) { // FIXME(#20302) -- we should check for things like Copy<T> continue ; // success } } _ => { // Not a trait? that's an error, but it'll get // reported later. } } trait_bounds . push ( b ) ; } ast :: TraitTyParamBound ( _ , ast :: TraitBoundModifier :: Maybe ) => { } ast :: RegionTyParamBound ( ref l ) => { region_bounds . push ( l ) ; } } } PartitionedBounds { builtin_bounds : builtin_bounds , trait_bounds : trait_bounds , region_bounds : region_bounds , } }
Divides a list of bounds from the AST into three groups: builtin bounds (Copy, Sized etc),
general trait bounds, and region bounds.
Divides a list of bounds from the AST into three groups : builtin bounds ( Copy Sized etc ) general trait bounds and region bounds .
tcx
&ty::ctxt
_span
Span
ast_bounds
&'a [ast::TyParamBound]
tcx
&ty::ctxt
_span
Span
ast_bounds
&'a [ast::TyParamBound]