pub struct PathLookup {
ns: PathNS,
path: &'static [Symbol],
once: OnceLock<Vec<DefId>>,
}Expand description
Lazily resolves a path into a list of [DefId]s using lookup_path.
Typically it will contain one [DefId] or none, but in some situations there can be multiple:
Fields§
§ns: PathNS§path: &'static [Symbol]§once: OnceLock<Vec<DefId>>Implementations§
Source§impl PathLookup
impl PathLookup
Sourcepub fn get<'tcx>(&self, tcx: &impl HasTyCtxt<'tcx>) -> &[DefId]
pub fn get<'tcx>(&self, tcx: &impl HasTyCtxt<'tcx>) -> &[DefId]
Returns the list of [DefId]s that the path resolves to
Sourcepub fn only(&self, cx: &LateContext<'_>) -> Option<DefId>
pub fn only(&self, cx: &LateContext<'_>) -> Option<DefId>
Returns the single [DefId] that the path resolves to, this can only be used for paths into
stdlib crates to avoid the issue of multiple [DefId]s being returned
May return None in no_std/no_core environments
Sourcepub fn matches<'tcx>(&self, tcx: &impl HasTyCtxt<'tcx>, def_id: DefId) -> bool
pub fn matches<'tcx>(&self, tcx: &impl HasTyCtxt<'tcx>, def_id: DefId) -> bool
Checks if the path resolves to the given def_id
Sourcepub fn matches_path<'tcx>(
&self,
cx: &LateContext<'_>,
maybe_path: impl MaybeQPath<'tcx>,
) -> bool
pub fn matches_path<'tcx>( &self, cx: &LateContext<'_>, maybe_path: impl MaybeQPath<'tcx>, ) -> bool
Resolves maybe_path to a [DefId] and checks if the PathLookup matches it
Sourcepub fn matches_ty<'tcx>(&self, tcx: &impl HasTyCtxt<'tcx>, ty: Ty<'_>) -> bool
pub fn matches_ty<'tcx>(&self, tcx: &impl HasTyCtxt<'tcx>, ty: Ty<'_>) -> bool
Checks if the path resolves to ty’s definition, must be an Adt
Auto Trait Implementations§
impl !Freeze for PathLookup
impl DynSend for PathLookup
impl DynSync for PathLookup
impl RefUnwindSafe for PathLookup
impl Send for PathLookup
impl Sync for PathLookup
impl Unpin for PathLookup
impl UnsafeUnpin for PathLookup
impl UnwindSafe for PathLookup
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreLayout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 56 bytes