/// 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<T>(&mut self, span: Span, segments: &[T], namespace: Namespace)
                                      -> Result<&'a NameBinding<'a>,
                                                bool /* true if an error was reported */>
        where T: Named,
    {
        let module_path = segments.split_last().unwrap().1.iter().map(T::name).collect::<Vec<_>>();
        let root_module = self.graph_root;
        let containing_module;
        match self.resolve_module_path_from_root(root_module,
                                                 &module_path,
                                                 0,
                                                 span) {
            Failed(err) => {
                let (span, msg) = match err {
                    Some((span, msg)) => (span, msg),
                    None => {
                        let msg = format!("Use of undeclared module `::{}`",
                                          names_to_string(&module_path));
                        (span, msg)
                    }
                };
                resolve_error(self, span, ResolutionError::FailedToResolve(&msg));
                return Err(true);
            }
            Indeterminate => return Err(false),
            Success(resulting_module) => {
                containing_module = resulting_module;
            }
        }
        let name = segments.last().unwrap().name();
        let result = self.resolve_name_in_module(containing_module, name, namespace, false, true);
        result.success().map(|binding| {
            self.check_privacy(name, binding, span);
            binding
        }).ok_or(false)
    }
fn resolve_crate_relative_path < T > ( & mut self , span : Span , segments : & [ T ] , namespace : Namespace ) -> Result < & ' a NameBinding < ' a > , bool /* true if an error was reported */ > where T : Named , { let module_path = segments . split_last ( ) . unwrap ( ) . 1 . iter ( ) . map ( T :: name ) . collect :: < Vec < _ > > ( ) ; let root_module = self . graph_root ; let containing_module ; match self . resolve_module_path_from_root ( root_module , & module_path , 0 , span ) { Failed ( err ) => { let ( span , msg ) = match err { Some ( ( span , msg ) ) => ( span , msg ) , None => { let msg = format ! ( " " names_to_string ( module_path ) ) ; ( span , msg ) } } ; resolve_error ( self , span , ResolutionError :: FailedToResolve ( & msg ) ) ; return Err ( true ) ; } Indeterminate => return Err ( false ) , Success ( resulting_module ) => { containing_module = resulting_module ; } } let name = segments . last ( ) . unwrap ( ) . name ( ) ; let result = self . resolve_name_in_module ( containing_module , name , namespace , false , true ) ; result . success ( ) . map ( | binding | { self . check_privacy ( name , binding , span ) ; binding } ) . ok_or ( false ) }
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
span
Span
segments
&[T]
namespace
Namespace