fn convert_path(
        &mut self,
        context: &Context,
        storage: &Storage,
        source: &Source,
        path: &ast::Path,
    ) -> Result<Named, CompileError> {
        let id = path.id();

        let qp = id
            .and_then(|id| self.query_paths.get(&id))
            .ok_or_else(|| QueryError::new(path, QueryErrorKind::MissingId { what: "path", id }))?
            .clone();

        let mut in_self_type = false;
        let mut local = None;

        let mut item = match (&path.global, &path.first) {
            (Some(..), ast::PathSegment::Ident(ident)) => {
                let ident = ident.resolve(storage, source)?;
                Item::with_crate(ident.as_ref())
            }
            (Some(global), _) => {
                return Err(CompileError::new(
                    global.span(),
                    CompileErrorKind::UnsupportedGlobal,
                ));
            }
            (None, segment) => match segment {
                ast::PathSegment::Ident(ident) => {
                    let ident = ident.resolve(storage, source)?;

                    if path.rest.is_empty() {
                        local = Some(<Box<str>>::from(ident.as_ref()));
                    }

                    self.lookup_initial(context, &qp.module, &qp.item, &*ident)?
                }
                ast::PathSegment::Super(super_value) => {
                    let mut item = qp.module.item.clone();

                    item.pop()
                        .ok_or_else(CompileError::unsupported_super(super_value))?;

                    item
                }
                ast::PathSegment::SelfType(self_type) => {
                    let impl_item = qp.impl_item.as_deref().ok_or_else(|| {
                        CompileError::new(self_type, CompileErrorKind::UnsupportedSelfType)
                    })?;

                    in_self_type = true;
                    impl_item.clone()
                }
                ast::PathSegment::SelfValue(..) => qp.module.item.clone(),
                ast::PathSegment::Crate(..) => Item::new(),
                ast::PathSegment::Generics(arguments) => {
                    return Err(CompileError::new(
                        arguments,
                        CompileErrorKind::UnsupportedGenerics,
                    ));
                }
            },
        };

        for (_, segment) in &path.rest {
            log::trace!("item = {}", item);

            match segment {
                ast::PathSegment::Ident(ident) => {
                    let ident = ident.resolve(storage, source)?;
                    item.push(ident.as_ref());
                }
                ast::PathSegment::Super(super_token) => {
                    if in_self_type {
                        return Err(CompileError::new(
                            super_token,
                            CompileErrorKind::UnsupportedSuperInSelfType,
                        ));
                    }

                    item.pop()
                        .ok_or_else(CompileError::unsupported_super(super_token))?;
                }
                ast::PathSegment::Generics(arguments) => {
                    return Err(CompileError::new(
                        arguments,
                        CompileErrorKind::UnsupportedGenerics,
                    ));
                }
                other => {
                    return Err(CompileError::new(
                        other,
                        CompileErrorKind::ExpectedLeadingPathSegment,
                    ));
                }
            }
        }

        let span = path.span();

        if let Some(new) = self.import(span, &qp.module, &item, Used::Used)? {
            return Ok(Named { local, item: new });
        }

        Ok(Named { local, item })
    }
/// Perform a path lookup on the current state of the unit.
Perform a path lookup on the current state of the unit.
Perform a path lookup on the current state of the unit .
fn convert_path(
        &mut self,
        context: &Context,
        storage: &Storage,
        source: &Source,
        path: &ast::Path,
    ) -> Result<Named, CompileError> {
        let id = path.id();
        let qp = id
            .and_then(|id| self.query_paths.get(&id))
            .ok_or_else(|| QueryError::new(path, QueryErrorKind::MissingId { what: "path", id }))?
            .clone();
        let mut in_self_type = false;
        let mut local = None;
        let mut item = match (&path.global, &path.first) {
            (Some(..), ast::PathSegment::Ident(ident)) => {
                let ident = ident.resolve(storage, source)?;
                Item::with_crate(ident.as_ref())
            }
            (Some(global), _) => {
                return Err(CompileError::new(
                    global.span(),
                    CompileErrorKind::UnsupportedGlobal,
                ));
            }
            (None, segment) => match segment {
                ast::PathSegment::Ident(ident) => {
                    let ident = ident.resolve(storage, source)?;
                    if path.rest.is_empty() {
                        local = Some(<Box<str>>::from(ident.as_ref()));
                    }
                    self.lookup_initial(context, &qp.module, &qp.item, &*ident)?
                }
                ast::PathSegment::Super(super_value) => {
                    let mut item = qp.module.item.clone();
                    item.pop()
                        .ok_or_else(CompileError::unsupported_super(super_value))?;
                    item
                }
                ast::PathSegment::SelfType(self_type) => {
                    let impl_item = qp.impl_item.as_deref().ok_or_else(|| {
                        CompileError::new(self_type, CompileErrorKind::UnsupportedSelfType)
                    })?;
                    in_self_type = true;
                    impl_item.clone()
                }
                ast::PathSegment::SelfValue(..) => qp.module.item.clone(),
                ast::PathSegment::Crate(..) => Item::new(),
                ast::PathSegment::Generics(arguments) => {
                    return Err(CompileError::new(
                        arguments,
                        CompileErrorKind::UnsupportedGenerics,
                    ));
                }
            },
        };
        for (_, segment) in &path.rest {
            log::trace!("item = {}", item);
            match segment {
                ast::PathSegment::Ident(ident) => {
                    let ident = ident.resolve(storage, source)?;
                    item.push(ident.as_ref());
                }
                ast::PathSegment::Super(super_token) => {
                    if in_self_type {
                        return Err(CompileError::new(
                            super_token,
                            CompileErrorKind::UnsupportedSuperInSelfType,
                        ));
                    }
                    item.pop()
                        .ok_or_else(CompileError::unsupported_super(super_token))?;
                }
                ast::PathSegment::Generics(arguments) => {
                    return Err(CompileError::new(
                        arguments,
                        CompileErrorKind::UnsupportedGenerics,
                    ));
                }
                other => {
                    return Err(CompileError::new(
                        other,
                        CompileErrorKind::ExpectedLeadingPathSegment,
                    ));
                }
            }
        }
        let span = path.span();
        if let Some(new) = self.import(span, &qp.module, &item, Used::Used)? {
            return Ok(Named { local, item: new });
        }
        Ok(Named { local, item })
    }
fn convert_path ( & mut self , context : & Context , storage : & Storage , source : & Source , path : & ast :: Path , ) -> Result < Named , CompileError > { let id = path . id ( ) ; let qp = id . and_then ( | id | self . query_paths . get ( & id ) ) . ok_or_else ( | | QueryError :: new ( path , QueryErrorKind :: MissingId { what : " " , id } ) ) ? . clone ( ) ; let mut in_self_type = false ; let mut local = None ; let mut item = match ( & path . global , & path . first ) { ( Some ( .. ) , ast :: PathSegment :: Ident ( ident ) ) => { let ident = ident . resolve ( storage , source ) ? ; Item :: with_crate ( ident . as_ref ( ) ) } ( Some ( global ) , _ ) => { return Err ( CompileError :: new ( global . span ( ) , CompileErrorKind :: UnsupportedGlobal , ) ) ; } ( None , segment ) => match segment { ast :: PathSegment :: Ident ( ident ) => { let ident = ident . resolve ( storage , source ) ? ; if path . rest . is_empty ( ) { local = Some ( < Box < str > > :: from ( ident . as_ref ( ) ) ) ; } self . lookup_initial ( context , & qp . module , & qp . item , & * ident ) ? } ast :: PathSegment :: Super ( super_value ) => { let mut item = qp . module . item . clone ( ) ; item . pop ( ) . ok_or_else ( CompileError :: unsupported_super ( super_value ) ) ? ; item } ast :: PathSegment :: SelfType ( self_type ) => { let impl_item = qp . impl_item . as_deref ( ) . ok_or_else ( | | { CompileError :: new ( self_type , CompileErrorKind :: UnsupportedSelfType ) } ) ? ; in_self_type = true ; impl_item . clone ( ) } ast :: PathSegment :: SelfValue ( .. ) => qp . module . item . clone ( ) , ast :: PathSegment :: Crate ( .. ) => Item :: new ( ) , ast :: PathSegment :: Generics ( arguments ) => { return Err ( CompileError :: new ( arguments , CompileErrorKind :: UnsupportedGenerics , ) ) ; } } , } ; for ( _ , segment ) in & path . rest { log :: trace ! ( " " item ) ; match segment { ast :: PathSegment :: Ident ( ident ) => { let ident = ident . resolve ( storage , source ) ? ; item . push ( ident . as_ref ( ) ) ; } ast :: PathSegment :: Super ( super_token ) => { if in_self_type { return Err ( CompileError :: new ( super_token , CompileErrorKind :: UnsupportedSuperInSelfType , ) ) ; } item . pop ( ) . ok_or_else ( CompileError :: unsupported_super ( super_token ) ) ? ; } ast :: PathSegment :: Generics ( arguments ) => { return Err ( CompileError :: new ( arguments , CompileErrorKind :: UnsupportedGenerics , ) ) ; } other => { return Err ( CompileError :: new ( other , CompileErrorKind :: ExpectedLeadingPathSegment , ) ) ; } } } let span = path . span ( ) ; if let Some ( new ) = self . import ( span , & qp . module , & item , Used :: Used ) ? { return Ok ( Named { local , item : new } ) ; } Ok ( Named { local , item } ) }
Perform a path lookup on the current state of the unit.
Perform a path lookup on the current state of the unit .
&mut self
context
&Context
storage
&Storage
source
&Source
path
&ast::Path
&mut self
context
&Context
storage
&Storage
source
&Source
path
&ast::Path