fn def_id_represents_local_inlined_item(&self, def_id: DefId) -> bool {
        let node_id = match self.tcx.hir.as_local_node_id(def_id) {
            Some(node_id) => node_id,
            None => { return false; }
        };

        match self.tcx.hir.find(node_id) {
            Some(hir_map::NodeItem(item)) => {
                match item.node {
                    hir::ItemKind::Fn(..) =>
                        item_might_be_inlined(self.tcx, &item, self.tcx.codegen_fn_attrs(def_id)),
                    _ => false,
                }
            }
            Some(hir_map::NodeTraitItem(trait_method)) => {
                match trait_method.node {
                    hir::TraitItemKind::Const(_, ref default) => default.is_some(),
                    hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => true,
                    hir::TraitItemKind::Method(_, hir::TraitMethod::Required(_)) |
                    hir::TraitItemKind::Type(..) => false,
                }
            }
            Some(hir_map::NodeImplItem(impl_item)) => {
                match impl_item.node {
                    hir::ImplItemKind::Const(..) => true,
                    hir::ImplItemKind::Method(..) => {
                        let attrs = self.tcx.codegen_fn_attrs(def_id);
                        let generics = self.tcx.generics_of(def_id);
                        if generics_require_inlining(&generics) ||
                                attrs.requests_inline() {
                            true
                        } else {
                            let impl_did = self.tcx
                                               .hir
                                               .get_parent_did(node_id);
                            // Check the impl. If the generics on the self
                            // type of the impl require inlining, this method
                            // does too.
                            let impl_node_id = self.tcx.hir.as_local_node_id(impl_did).unwrap();
                            match self.tcx.hir.expect_item(impl_node_id).node {
                                hir::ItemKind::Impl(..) => {
                                    let generics = self.tcx.generics_of(impl_did);
                                    generics_require_inlining(&generics)
                                }
                                _ => false
                            }
                        }
                    }
                    hir::ImplItemKind::Existential(..) |
                    hir::ImplItemKind::Type(_) => false,
                }
            }
            Some(_) => false,
            None => false   // This will happen for default methods.
        }
    }
// Returns true if the given def ID represents a local item that is
// eligible for inlining and false otherwise.
Returns true if the given def ID represents a local item that is
eligible for inlining and false otherwise.
Returns true if the given def ID represents a local item that is eligible for inlining and false otherwise .
fn def_id_represents_local_inlined_item(&self, def_id: DefId) -> bool {
        let node_id = match self.tcx.hir.as_local_node_id(def_id) {
            Some(node_id) => node_id,
            None => { return false; }
        };
        match self.tcx.hir.find(node_id) {
            Some(hir_map::NodeItem(item)) => {
                match item.node {
                    hir::ItemKind::Fn(..) =>
                        item_might_be_inlined(self.tcx, &item, self.tcx.codegen_fn_attrs(def_id)),
                    _ => false,
                }
            }
            Some(hir_map::NodeTraitItem(trait_method)) => {
                match trait_method.node {
                    hir::TraitItemKind::Const(_, ref default) => default.is_some(),
                    hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => true,
                    hir::TraitItemKind::Method(_, hir::TraitMethod::Required(_)) |
                    hir::TraitItemKind::Type(..) => false,
                }
            }
            Some(hir_map::NodeImplItem(impl_item)) => {
                match impl_item.node {
                    hir::ImplItemKind::Const(..) => true,
                    hir::ImplItemKind::Method(..) => {
                        let attrs = self.tcx.codegen_fn_attrs(def_id);
                        let generics = self.tcx.generics_of(def_id);
                        if generics_require_inlining(&generics) ||
                                attrs.requests_inline() {
                            true
                        } else {
                            let impl_did = self.tcx
                                               .hir
                                               .get_parent_did(node_id);
                            // Check the impl. If the generics on the self
                            // type of the impl require inlining, this method
                            // does too.
                            let impl_node_id = self.tcx.hir.as_local_node_id(impl_did).unwrap();
                            match self.tcx.hir.expect_item(impl_node_id).node {
                                hir::ItemKind::Impl(..) => {
                                    let generics = self.tcx.generics_of(impl_did);
                                    generics_require_inlining(&generics)
                                }
                                _ => false
                            }
                        }
                    }
                    hir::ImplItemKind::Existential(..) |
                    hir::ImplItemKind::Type(_) => false,
                }
            }
            Some(_) => false,
            None => false   // This will happen for default methods.
        }
    }
fn def_id_represents_local_inlined_item ( & self , def_id : DefId ) -> bool { let node_id = match self . tcx . hir . as_local_node_id ( def_id ) { Some ( node_id ) => node_id , None => { return false ; } } ; match self . tcx . hir . find ( node_id ) { Some ( hir_map :: NodeItem ( item ) ) => { match item . node { hir :: ItemKind :: Fn ( .. ) => item_might_be_inlined ( self . tcx , & item , self . tcx . codegen_fn_attrs ( def_id ) ) , _ => false , } } Some ( hir_map :: NodeTraitItem ( trait_method ) ) => { match trait_method . node { hir :: TraitItemKind :: Const ( _ , ref default ) => default . is_some ( ) , hir :: TraitItemKind :: Method ( _ , hir :: TraitMethod :: Provided ( _ ) ) => true , hir :: TraitItemKind :: Method ( _ , hir :: TraitMethod :: Required ( _ ) ) | hir :: TraitItemKind :: Type ( .. ) => false , } } Some ( hir_map :: NodeImplItem ( impl_item ) ) => { match impl_item . node { hir :: ImplItemKind :: Const ( .. ) => true , hir :: ImplItemKind :: Method ( .. ) => { let attrs = self . tcx . codegen_fn_attrs ( def_id ) ; let generics = self . tcx . generics_of ( def_id ) ; if generics_require_inlining ( & generics ) || attrs . requests_inline ( ) { true } else { let impl_did = self . tcx . hir . get_parent_did ( node_id ) ; // Check the impl. If the generics on the self // type of the impl require inlining, this method // does too. let impl_node_id = self . tcx . hir . as_local_node_id ( impl_did ) . unwrap ( ) ; match self . tcx . hir . expect_item ( impl_node_id ) . node { hir :: ItemKind :: Impl ( .. ) => { let generics = self . tcx . generics_of ( impl_did ) ; generics_require_inlining ( & generics ) } _ => false } } } hir :: ImplItemKind :: Existential ( .. ) | hir :: ImplItemKind :: Type ( _ ) => false , } } Some ( _ ) => false , None => false // This will happen for default methods. } }
Returns true if the given def ID represents a local item that is
eligible for inlining and false otherwise.
Returns true if the given def ID represents a local item that is eligible for inlining and false otherwise .
&self
def_id
DefId