/// Attempts to resolve the module part of an import directive or path
/// rooted at the given module.
Attempts to resolve the module part of an import directive or path
rooted at the given module.
Attempts to resolve the module part of an import directive or path rooted at the given module .
fn resolve_module_path(&mut self,
                           module_path: &[Name],
                           use_lexical_scope: UseLexicalScopeFlag,
                           span: Span)
                           -> ResolveResult<Module<'a>> {
        if module_path.len() == 0 {
            return Success(self.graph_root) // Use the crate root
        }
        debug!("(resolving module path for import) processing `{}` rooted at `{}`",
               names_to_string(module_path),
               module_to_string(self.current_module));
        // Resolve the module prefix, if any.
        let module_prefix_result = self.resolve_module_prefix(module_path, span);
        let search_module;
        let start_index;
        match module_prefix_result {
            Failed(err) => return Failed(err),
            Indeterminate => {
                debug!("(resolving module path for import) indeterminate; bailing");
                return Indeterminate;
            }
            Success(NoPrefixFound) => {
                // There was no prefix, so we're considering the first element
                // of the path. How we handle this depends on whether we were
                // instructed to use lexical scope or not.
                match use_lexical_scope {
                    DontUseLexicalScope => {
                        // This is a crate-relative path. We will start the
                        // resolution process at index zero.
                        search_module = self.graph_root;
                        start_index = 0;
                    }
                    UseLexicalScope => {
                        // This is not a crate-relative path. We resolve the
                        // first component of the path in the current lexical
                        // scope and then proceed to resolve below that.
                        let ident = ast::Ident::with_empty_ctxt(module_path[0]);
                        match self.resolve_ident_in_lexical_scope(ident, TypeNS, true)
                                  .and_then(LexicalScopeBinding::module) {
                            None => return Failed(None),
                            Some(containing_module) => {
                                search_module = containing_module;
                                start_index = 1;
                            }
                        }
                    }
                }
            }
            Success(PrefixFound(ref containing_module, index)) => {
                search_module = containing_module;
                start_index = index;
            }
        }
        self.resolve_module_path_from_root(search_module,
                                           module_path,
                                           start_index,
                                           span)
    }
fn resolve_module_path ( & mut self , module_path : & [ Name ] , use_lexical_scope : UseLexicalScopeFlag , span : Span ) -> ResolveResult < Module < ' a > > { if module_path . len ( ) == 0 { return Success ( self . graph_root ) // Use the crate root } debug ! ( " " names_to_string ( module_path ) module_to_string ( self current_module ) ) ; // Resolve the module prefix, if any. let module_prefix_result = self . resolve_module_prefix ( module_path , span ) ; let search_module ; let start_index ; match module_prefix_result { Failed ( err ) => return Failed ( err ) , Indeterminate => { debug ! ( " " ) ; return Indeterminate ; } Success ( NoPrefixFound ) => { // There was no prefix, so we're considering the first element // of the path. How we handle this depends on whether we were // instructed to use lexical scope or not. match use_lexical_scope { DontUseLexicalScope => { // This is a crate-relative path. We will start the // resolution process at index zero. search_module = self . graph_root ; start_index = 0 ; } UseLexicalScope => { // This is not a crate-relative path. We resolve the // first component of the path in the current lexical // scope and then proceed to resolve below that. let ident = ast :: Ident :: with_empty_ctxt ( module_path [ 0 ] ) ; match self . resolve_ident_in_lexical_scope ( ident , TypeNS , true ) . and_then ( LexicalScopeBinding :: module ) { None => return Failed ( None ) , Some ( containing_module ) => { search_module = containing_module ; start_index = 1 ; } } } } } Success ( PrefixFound ( ref containing_module , index ) ) => { search_module = containing_module ; start_index = index ; } } self . resolve_module_path_from_root ( search_module , module_path , start_index , span ) }
Attempts to resolve the module part of an import directive or path
rooted at the given module.
Attempts to resolve the module part of an import directive or path rooted at the given module .
&mut self
module_path
&[Name]
use_lexical_scope
UseLexicalScopeFlag
span
Span