fn resolve_module_path_from_root(&mut self,
                                     module_: Module<'a>,
                                     module_path: &[Name],
                                     index: usize,
                                     span: Span)
                                     -> ResolveResult<Module<'a>> {
        fn search_parent_externals(needle: Name, module: Module) -> Option<Module> {
            match module.resolve_name(needle, TypeNS, false) {
                Success(binding) if binding.is_extern_crate() => Some(module),
                _ => match module.parent_link {
                    ModuleParentLink(ref parent, _) => {
                        search_parent_externals(needle, parent)
                    }
                    _ => None,
                },
            }
        }

        let mut search_module = module_;
        let mut index = index;
        let module_path_len = module_path.len();

        // Resolve the module part of the path. This does not involve looking
        // upward though scope chains; we simply resolve names directly in
        // modules as we go.
        while index < module_path_len {
            let name = module_path[index];
            match self.resolve_name_in_module(search_module, name, TypeNS, false, true) {
                Failed(None) => {
                    let segment_name = name.as_str();
                    let module_name = module_to_string(search_module);
                    let msg = if "???" == &module_name {
                        match search_parent_externals(name, &self.current_module) {
                            Some(module) => {
                                let path_str = names_to_string(module_path);
                                let target_mod_str = module_to_string(&module);
                                let current_mod_str = module_to_string(&self.current_module);

                                let prefix = if target_mod_str == current_mod_str {
                                    "self::".to_string()
                                } else {
                                    format!("{}::", target_mod_str)
                                };

                                format!("Did you mean `{}{}`?", prefix, path_str)
                            }
                            None => format!("Maybe a missing `extern crate {}`?", segment_name),
                        }
                    } else {
                        format!("Could not find `{}` in `{}`", segment_name, module_name)
                    };

                    return Failed(Some((span, msg)));
                }
                Failed(err) => return Failed(err),
                Indeterminate => {
                    debug!("(resolving module path for import) module resolution is \
                            indeterminate: {}",
                           name);
                    return Indeterminate;
                }
                Success(binding) => {
                    // Check to see whether there are type bindings, and, if
                    // so, whether there is a module within.
                    if let Some(module_def) = binding.module() {
                        self.check_privacy(name, binding, span);
                        search_module = module_def;
                    } else {
                        let msg = format!("Not a module `{}`", name);
                        return Failed(Some((span, msg)));
                    }
                }
            }

            index += 1;
        }

        return Success(search_module);
    }
/// Resolves the given module path from the given root `module_`.
Resolves the given module path from the given root `module_`.
Resolves the given module path from the given root ` module_ ` .
fn resolve_module_path_from_root(&mut self,
                                     module_: Module<'a>,
                                     module_path: &[Name],
                                     index: usize,
                                     span: Span)
                                     -> ResolveResult<Module<'a>> {
        fn search_parent_externals(needle: Name, module: Module) -> Option<Module> {
            match module.resolve_name(needle, TypeNS, false) {
                Success(binding) if binding.is_extern_crate() => Some(module),
                _ => match module.parent_link {
                    ModuleParentLink(ref parent, _) => {
                        search_parent_externals(needle, parent)
                    }
                    _ => None,
                },
            }
        }
        let mut search_module = module_;
        let mut index = index;
        let module_path_len = module_path.len();
        // Resolve the module part of the path. This does not involve looking
        // upward though scope chains; we simply resolve names directly in
        // modules as we go.
        while index < module_path_len {
            let name = module_path[index];
            match self.resolve_name_in_module(search_module, name, TypeNS, false, true) {
                Failed(None) => {
                    let segment_name = name.as_str();
                    let module_name = module_to_string(search_module);
                    let msg = if "???" == &module_name {
                        match search_parent_externals(name, &self.current_module) {
                            Some(module) => {
                                let path_str = names_to_string(module_path);
                                let target_mod_str = module_to_string(&module);
                                let current_mod_str = module_to_string(&self.current_module);
                                let prefix = if target_mod_str == current_mod_str {
                                    "self::".to_string()
                                } else {
                                    format!("{}::", target_mod_str)
                                };
                                format!("Did you mean `{}{}`?", prefix, path_str)
                            }
                            None => format!("Maybe a missing `extern crate {}`?", segment_name),
                        }
                    } else {
                        format!("Could not find `{}` in `{}`", segment_name, module_name)
                    };
                    return Failed(Some((span, msg)));
                }
                Failed(err) => return Failed(err),
                Indeterminate => {
                    debug!("(resolving module path for import) module resolution is \
                            indeterminate: {}",
                           name);
                    return Indeterminate;
                }
                Success(binding) => {
                    // Check to see whether there are type bindings, and, if
                    // so, whether there is a module within.
                    if let Some(module_def) = binding.module() {
                        self.check_privacy(name, binding, span);
                        search_module = module_def;
                    } else {
                        let msg = format!("Not a module `{}`", name);
                        return Failed(Some((span, msg)));
                    }
                }
            }
            index += 1;
        }
        return Success(search_module);
    }
fn resolve_module_path_from_root ( & mut self , module_ : Module < ' a > , module_path : & [ Name ] , index : usize , span : Span ) -> ResolveResult < Module < ' a > > { fn search_parent_externals ( needle : Name , module : Module ) -> Option < Module > { match module . resolve_name ( needle , TypeNS , false ) { Success ( binding ) if binding . is_extern_crate ( ) => Some ( module ) , _ => match module . parent_link { ModuleParentLink ( ref parent , _ ) => { search_parent_externals ( needle , parent ) } _ => None , } , } } let mut search_module = module_ ; let mut index = index ; let module_path_len = module_path . len ( ) ; // Resolve the module part of the path. This does not involve looking // upward though scope chains; we simply resolve names directly in // modules as we go. while index < module_path_len { let name = module_path [ index ] ; match self . resolve_name_in_module ( search_module , name , TypeNS , false , true ) { Failed ( None ) => { let segment_name = name . as_str ( ) ; let module_name = module_to_string ( search_module ) ; let msg = if " " == & module_name { match search_parent_externals ( name , & self . current_module ) { Some ( module ) => { let path_str = names_to_string ( module_path ) ; let target_mod_str = module_to_string ( & module ) ; let current_mod_str = module_to_string ( & self . current_module ) ; let prefix = if target_mod_str == current_mod_str { " " . to_string ( ) } else { format ! ( " " target_mod_str ) } ; format ! ( " " prefix path_str ) } None => format ! ( " " segment_name ) , } } else { format ! ( " " segment_name module_name ) } ; return Failed ( Some ( ( span , msg ) ) ) ; } Failed ( err ) => return Failed ( err ) , Indeterminate => { debug ! ( " \
 " name ) ; return Indeterminate ; } Success ( binding ) => { // Check to see whether there are type bindings, and, if // so, whether there is a module within. if let Some ( module_def ) = binding . module ( ) { self . check_privacy ( name , binding , span ) ; search_module = module_def ; } else { let msg = format ! ( " " name ) ; return Failed ( Some ( ( span , msg ) ) ) ; } } } index += 1 ; } return Success ( search_module ) ; }
Resolves the given module path from the given root `module_`.
Resolves the given module path from the given root ` module_ ` .
&mut self
module_
Module<'a>
module_path
&[Name]
index
usize
span
Span
&mut self
module_
Module<'a>
module_path
&[Name]
index
usize
span
Span