## MaybeQPath

# Trait MaybeQPath

Source

    pub trait MaybeQPath<'a>: Copy {
        // Required method
        fn opt_qpath(self) -> Option<(&'a QPath<'a>, HirId)>;

        // Provided methods
        fn res<'tcx>(self, typeck: &impl MaybeTypeckRes<'tcx>) -> Res { ... }
        fn res_if_named<'tcx>(
            self,
            typeck: &impl MaybeTypeckRes<'tcx>,
            name: Symbol,
        ) -> Res { ... }
        fn res_with_seg<'tcx>(
            self,
            typeck: &impl MaybeTypeckRes<'tcx>,
        ) -> (Res, Option<&'a PathSegment<'a>>) { ... }
        fn typeless_res<'tcx>(self, typeck: &impl MaybeTypeckRes<'tcx>) -> Res { ... }
        fn typeless_res_if_named<'tcx>(
            self,
            typeck: &impl MaybeTypeckRes<'tcx>,
            name: Symbol,
        ) -> Res { ... }
        fn ty_rel_def<'tcx>(
            self,
            typeck: &impl MaybeTypeckRes<'tcx>,
        ) -> Option<(DefKind, DefId)> { ... }
        fn ty_rel_def_if_named<'tcx>(
            self,
            typeck: &impl MaybeTypeckRes<'tcx>,
            name: Symbol,
        ) -> Option<(DefKind, DefId)> { ... }
        fn ty_rel_def_with_seg<'tcx>(
            self,
            typeck: &impl MaybeTypeckRes<'tcx>,
        ) -> Option<((DefKind, DefId), &'a PathSegment<'a>)> { ... }
    }

Expand description

A HIR node which might be a `QPath`.

## Required Methods§

Source

#### fn opt_qpath(self) -> Option<(&'a QPath<'a>, HirId)>

If this node is a path gets both the contained path and the `HirId` to use for type dependant lookup.

## Provided Methods§

Source

#### fn res<'tcx>(self, typeck: &impl MaybeTypeckRes<'tcx>) -> Res

If this is a path gets its resolution. Returns `Res::Err` otherwise.

Source

#### fn res_if_named<'tcx>( self, typeck: &impl MaybeTypeckRes<'tcx>, name: Symbol, ) -> Res

If this is a path with the specified name as its final segment gets its resolution. Returns `Res::Err` otherwise.

Source

#### fn res_with_seg<'tcx>( self, typeck: &impl MaybeTypeckRes<'tcx>, ) -> (Res, Option<&'a PathSegment<'a>>)

If this is a path gets both its resolution and final segment.

Source

#### fn typeless_res<'tcx>(self, typeck: &impl MaybeTypeckRes<'tcx>) -> Res

If this is a path without an explicit `Self` type gets its resolution. Returns `Res::Err` otherwise.

Only paths to trait items can optionally contain a `Self` type.

Source

#### fn typeless_res_if_named<'tcx>( self, typeck: &impl MaybeTypeckRes<'tcx>, name: Symbol, ) -> Res

If this is a path without an explicit `Self` type to an item with the specified name gets its resolution. Returns `Res::Err` otherwise.

Only paths to trait items can optionally contain a `Self` type.

Source

#### fn ty_rel_def<'tcx>( self, typeck: &impl MaybeTypeckRes<'tcx>, ) -> Option<(DefKind, DefId)>

If this is a type-relative path gets the definition it resolves to.

Only inherent associated items require a type-relative path.

Source

#### fn ty_rel_def_if_named<'tcx>( self, typeck: &impl MaybeTypeckRes<'tcx>, name: Symbol, ) -> Option<(DefKind, DefId)>

If this is a type-relative path to an item with the specified name gets the definition it resolves to.

Only inherent associated items require a type-relative path.

Source

#### fn ty_rel_def_with_seg<'tcx>( self, typeck: &impl MaybeTypeckRes<'tcx>, ) -> Option<((DefKind, DefId), &'a PathSegment<'a>)>

If this is a type-relative path gets the definition it resolves to and its final segment.

Only inherent associated items require a type-relative path.

## Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

## Implementations on Foreign Types§

Source§

### impl<'tcx> MaybeQPath<'tcx> for &'tcx Expr<'_>

Source§

#### fn opt_qpath(self) -> Option<(&'tcx QPath<'tcx>, HirId)>

Source§

### impl<'tcx> MaybeQPath<'tcx> for &'tcx PatExpr<'_>

Source§

#### fn opt_qpath(self) -> Option<(&'tcx QPath<'tcx>, HirId)>

Source§

### impl<'tcx> MaybeQPath<'tcx> for &Pat<'tcx>

Source§

#### fn opt_qpath(self) -> Option<(&'tcx QPath<'tcx>, HirId)>

Source§

### impl<'tcx> MaybeQPath<'tcx> for (&'tcx QPath<'tcx>, HirId)

Source§

#### fn opt_qpath(self) -> Option<(&'tcx QPath<'tcx>, HirId)>

Source§

### impl<'tcx, AmbigArg> MaybeQPath<'tcx> for &'tcx Ty<'_, AmbigArg>

Source§

#### fn opt_qpath(self) -> Option<(&'tcx QPath<'tcx>, HirId)>

Source§

### impl<'tcx, T: Copy + MaybeQPath<'tcx>> MaybeQPath<'tcx> for &Option<T>

Source§

#### fn opt_qpath(self) -> Option<(&'tcx QPath<'tcx>, HirId)>

Source§

### impl<'tcx, T: MaybeQPath<'tcx>> MaybeQPath<'tcx> for Option<T>

Source§

#### fn opt_qpath(self) -> Option<(&'tcx QPath<'tcx>, HirId)>

## Implementors§