pub fn is_suitable_anonymous_region(&self,
                                        region: Region<'tcx>)
                                        -> Option<(DefId, ty::BoundRegion)> {
        if let ty::ReFree(ref free_region) = *region {
            if let ty::BrAnon(..) = free_region.bound_region{
                    let anonymous_region_binding_scope = free_region.scope;
                    let node_id = self.tcx
                        .hir
                        .as_local_node_id(anonymous_region_binding_scope)
                        .unwrap();
                    match self.tcx.hir.find(node_id) {
                        Some(hir_map::NodeItem(..)) |
                        Some(hir_map::NodeTraitItem(..)) => {
                            // Success -- proceed to return Some below
                        }
                        Some(hir_map::NodeImplItem(..)) => {
                            let container_id = self.tcx
                                .associated_item(anonymous_region_binding_scope)
                                .container
                                .id();
                            if self.tcx.impl_trait_ref(container_id).is_some() {
                                // For now, we do not try to target impls of traits. This is
                                // because this message is going to suggest that the user
                                // change the fn signature, but they may not be free to do so,
                                // since the signature must match the trait.
                                //
                                // FIXME(#42706) -- in some cases, we could do better here.
                                return None;
                            }
                        }
                        _ => return None, // inapplicable
                        // we target only top-level functions
                    }
                    return Some((anonymous_region_binding_scope, free_region.bound_region));
                }
            }
            None
        }
// This method returns whether the given Region is Anonymous
// and returns the DefId and the BoundRegion corresponding to the given region.
This method returns whether the given Region is Anonymous
and returns the DefId and the BoundRegion corresponding to the given region.
This method returns whether the given Region is Anonymous and returns the DefId and the BoundRegion corresponding to the given region .
pub fn is_suitable_anonymous_region(&self,
                                        region: Region<'tcx>)
                                        -> Option<(DefId, ty::BoundRegion)> {
        if let ty::ReFree(ref free_region) = *region {
            if let ty::BrAnon(..) = free_region.bound_region{
                    let anonymous_region_binding_scope = free_region.scope;
                    let node_id = self.tcx
                        .hir
                        .as_local_node_id(anonymous_region_binding_scope)
                        .unwrap();
                    match self.tcx.hir.find(node_id) {
                        Some(hir_map::NodeItem(..)) |
                        Some(hir_map::NodeTraitItem(..)) => {
                            // Success -- proceed to return Some below
                        }
                        Some(hir_map::NodeImplItem(..)) => {
                            let container_id = self.tcx
                                .associated_item(anonymous_region_binding_scope)
                                .container
                                .id();
                            if self.tcx.impl_trait_ref(container_id).is_some() {
                                // For now, we do not try to target impls of traits. This is
                                // because this message is going to suggest that the user
                                // change the fn signature, but they may not be free to do so,
                                // since the signature must match the trait.
                                //
                                // FIXME(#42706) -- in some cases, we could do better here.
                                return None;
                            }
                        }
                        _ => return None, // inapplicable
                        // we target only top-level functions
                    }
                    return Some((anonymous_region_binding_scope, free_region.bound_region));
                }
            }
            None
        }
pub fn is_suitable_anonymous_region ( & self , region : Region < ' tcx > ) -> Option < ( DefId , ty :: BoundRegion ) > { if let ty :: ReFree ( ref free_region ) = * region { if let ty :: BrAnon ( .. ) = free_region . bound_region { let anonymous_region_binding_scope = free_region . scope ; let node_id = self . tcx . hir . as_local_node_id ( anonymous_region_binding_scope ) . unwrap ( ) ; match self . tcx . hir . find ( node_id ) { Some ( hir_map :: NodeItem ( .. ) ) | Some ( hir_map :: NodeTraitItem ( .. ) ) => { // Success -- proceed to return Some below } Some ( hir_map :: NodeImplItem ( .. ) ) => { let container_id = self . tcx . associated_item ( anonymous_region_binding_scope ) . container . id ( ) ; if self . tcx . impl_trait_ref ( container_id ) . is_some ( ) { // For now, we do not try to target impls of traits. This is // because this message is going to suggest that the user // change the fn signature, but they may not be free to do so, // since the signature must match the trait. // // FIXME(#42706) -- in some cases, we could do better here. return None ; } } _ => return None , // inapplicable // we target only top-level functions } return Some ( ( anonymous_region_binding_scope , free_region . bound_region ) ) ; } } None }
This method returns whether the given Region is Anonymous
and returns the DefId and the BoundRegion corresponding to the given region.
This method returns whether the given Region is Anonymous and returns the DefId and the BoundRegion corresponding to the given region .
&self
region
Region<'tcx>
&self
region
Region<'tcx>