fn with_optional_trait_ref<T>(
        &mut self,
        opt_trait_ref: Option<&TraitRef>,
        f: impl FnOnce(&mut Self, Option<DefId>) -> T,
    ) -> T {
        let mut new_val = None;
        let mut new_id = None;
        if let Some(trait_ref) = opt_trait_ref {
            let path: Vec<_> = Segment::from_path(&trait_ref.path);
            let res = self.smart_resolve_path_fragment(
                trait_ref.ref_id,
                None,
                &path,
                trait_ref.path.span,
                PathSource::Trait(AliasPossibility::No),
                CrateLint::SimplePath(trait_ref.ref_id),
            );
            let res = res.base_res();
            if res != Res::Err {
                new_id = Some(res.def_id());
                let span = trait_ref.path.span;
                if let PathResult::Module(ModuleOrUniformRoot::Module(module)) = self.resolve_path(
                    &path,
                    Some(TypeNS),
                    false,
                    span,
                    CrateLint::SimplePath(trait_ref.ref_id),
                ) {
                    new_val = Some((module, trait_ref.clone()));
                }
            }
        }
        let original_trait_ref = replace(&mut self.current_trait_ref, new_val);
        let result = f(self, new_id);
        self.current_trait_ref = original_trait_ref;
        result
    }
/// This is called to resolve a trait reference from an `impl` (i.e., `impl Trait for Foo`).
This is called to resolve a trait reference from an `impl` .
This is called to resolve a trait reference from an ` impl ` .
fn with_optional_trait_ref<T>(
        &mut self,
        opt_trait_ref: Option<&TraitRef>,
        f: impl FnOnce(&mut Self, Option<DefId>) -> T,
    ) -> T {
        let mut new_val = None;
        let mut new_id = None;
        if let Some(trait_ref) = opt_trait_ref {
            let path: Vec<_> = Segment::from_path(&trait_ref.path);
            let res = self.smart_resolve_path_fragment(
                trait_ref.ref_id,
                None,
                &path,
                trait_ref.path.span,
                PathSource::Trait(AliasPossibility::No),
                CrateLint::SimplePath(trait_ref.ref_id),
            );
            let res = res.base_res();
            if res != Res::Err {
                new_id = Some(res.def_id());
                let span = trait_ref.path.span;
                if let PathResult::Module(ModuleOrUniformRoot::Module(module)) = self.resolve_path(
                    &path,
                    Some(TypeNS),
                    false,
                    span,
                    CrateLint::SimplePath(trait_ref.ref_id),
                ) {
                    new_val = Some((module, trait_ref.clone()));
                }
            }
        }
        let original_trait_ref = replace(&mut self.current_trait_ref, new_val);
        let result = f(self, new_id);
        self.current_trait_ref = original_trait_ref;
        result
    }
fn with_optional_trait_ref < T > ( & mut self , opt_trait_ref : Option < & TraitRef > , f : impl FnOnce ( & mut Self , Option < DefId > ) -> T , ) -> T { let mut new_val = None ; let mut new_id = None ; if let Some ( trait_ref ) = opt_trait_ref { let path : Vec < _ > = Segment :: from_path ( & trait_ref . path ) ; let res = self . smart_resolve_path_fragment ( trait_ref . ref_id , None , & path , trait_ref . path . span , PathSource :: Trait ( AliasPossibility :: No ) , CrateLint :: SimplePath ( trait_ref . ref_id ) , ) ; let res = res . base_res ( ) ; if res != Res :: Err { new_id = Some ( res . def_id ( ) ) ; let span = trait_ref . path . span ; if let PathResult :: Module ( ModuleOrUniformRoot :: Module ( module ) ) = self . resolve_path ( & path , Some ( TypeNS ) , false , span , CrateLint :: SimplePath ( trait_ref . ref_id ) , ) { new_val = Some ( ( module , trait_ref . clone ( ) ) ) ; } } } let original_trait_ref = replace ( & mut self . current_trait_ref , new_val ) ; let result = f ( self , new_id ) ; self . current_trait_ref = original_trait_ref ; result }
This is called to resolve a trait reference from an `impl` (i.e., `impl Trait for Foo`).
This is called to resolve a trait reference from an ` impl ` ( i . e . ` impl Trait for Foo ` ) .
&mut self
opt_trait_ref
Option<&TraitRef>
f
impl FnOnce(&mut Self, Option<DefId>) -> T
&mut self
opt_trait_ref
Option<&TraitRef>
f
impl FnOnce(&mut Self, Option<DefId>) -> T