fn resolve_crate_relative_path(&mut self,
                                   path: &Path,
                                   namespace: Namespace)
                                       -> Option<(Def, LastPrivate)> {
        let module_path_idents = path.segments.init().map(|ps| ps.identifier);

        let root_module = self.graph_root.get_module();

        let containing_module;
        let last_private;
        match self.resolve_module_path_from_root(root_module,
                                                 module_path_idents,
                                                 0,
                                                 path.span,
                                                 PathSearch,
                                                 AllPublic) {
            Failed => {
                let msg = format!("use of undeclared module `::{}`",
                                  self.idents_to_str(module_path_idents));
                self.resolve_error(path.span, msg);
                return None;
            }

            Indeterminate => {
                fail!("indeterminate unexpected");
            }

            Success((resulting_module, resulting_last_private)) => {
                containing_module = resulting_module;
                last_private = resulting_last_private;
            }
        }

        let name = path.segments.last().identifier;
        match self.resolve_definition_of_name_in_module(containing_module,
                                                        name,
                                                        namespace) {
            NoNameDefinition => {
                // We failed to resolve the name. Report an error.
                return None;
            }
            ChildNameDefinition(def, lp) | ImportNameDefinition(def, lp) => {
                return Some((def, last_private.or(lp)));
            }
        }
    }
/// Invariant: This must be called only during main resolution, not during
/// import resolution.
This must be called only during main resolution, not during
import resolution.
This must be called only during main resolution not during import resolution .
fn resolve_crate_relative_path(&mut self,
                                   path: &Path,
                                   namespace: Namespace)
                                       -> Option<(Def, LastPrivate)> {
        let module_path_idents = path.segments.init().map(|ps| ps.identifier);
        let root_module = self.graph_root.get_module();
        let containing_module;
        let last_private;
        match self.resolve_module_path_from_root(root_module,
                                                 module_path_idents,
                                                 0,
                                                 path.span,
                                                 PathSearch,
                                                 AllPublic) {
            Failed => {
                let msg = format!("use of undeclared module `::{}`",
                                  self.idents_to_str(module_path_idents));
                self.resolve_error(path.span, msg);
                return None;
            }
            Indeterminate => {
                fail!("indeterminate unexpected");
            }
            Success((resulting_module, resulting_last_private)) => {
                containing_module = resulting_module;
                last_private = resulting_last_private;
            }
        }
        let name = path.segments.last().identifier;
        match self.resolve_definition_of_name_in_module(containing_module,
                                                        name,
                                                        namespace) {
            NoNameDefinition => {
                // We failed to resolve the name. Report an error.
                return None;
            }
            ChildNameDefinition(def, lp) | ImportNameDefinition(def, lp) => {
                return Some((def, last_private.or(lp)));
            }
        }
    }
fn resolve_crate_relative_path ( & mut self , path : & Path , namespace : Namespace ) -> Option < ( Def , LastPrivate ) > { let module_path_idents = path . segments . init ( ) . map ( | ps | ps . identifier ) ; let root_module = self . graph_root . get_module ( ) ; let containing_module ; let last_private ; match self . resolve_module_path_from_root ( root_module , module_path_idents , 0 , path . span , PathSearch , AllPublic ) { Failed => { let msg = format ! ( " " self idents_to_str ( module_path_idents ) ) ; self . resolve_error ( path . span , msg ) ; return None ; } Indeterminate => { fail ! ( " " ) ; } Success ( ( resulting_module , resulting_last_private ) ) => { containing_module = resulting_module ; last_private = resulting_last_private ; } } let name = path . segments . last ( ) . identifier ; match self . resolve_definition_of_name_in_module ( containing_module , name , namespace ) { NoNameDefinition => { // We failed to resolve the name. Report an error. return None ; } ChildNameDefinition ( def , lp ) | ImportNameDefinition ( def , lp ) => { return Some ( ( def , last_private . or ( lp ) ) ) ; } } }
Invariant: This must be called only during main resolution, not during
import resolution.
Invariant : This must be called only during main resolution not during import resolution .
&mut self
path
&Path
namespace
Namespace
&mut self
path
&Path
namespace
Namespace