pub enum ItemRef<'ctx> {
Type(&'ctx TypeDecl),
Fun(&'ctx FunDecl),
Global(&'ctx GlobalDecl),
TraitDecl(&'ctx TraitDecl),
TraitImpl(&'ctx TraitImpl),
}Expand description
A reference to a translated item.
Variants§
Type(&'ctx TypeDecl)
Fun(&'ctx FunDecl)
Global(&'ctx GlobalDecl)
TraitDecl(&'ctx TraitDecl)
TraitImpl(&'ctx TraitImpl)
Implementations§
Source§impl<'ctx> ItemRef<'ctx>
impl<'ctx> ItemRef<'ctx>
Sourcepub fn as_type_mut(&mut self) -> Option<&mut &'ctx TypeDecl>
pub fn as_type_mut(&mut self) -> Option<&mut &'ctx TypeDecl>
Optionally returns mutable references to the inner fields if this is a ItemRef::Type, otherwise None
Sourcepub fn as_type(&self) -> Option<&&'ctx TypeDecl>
pub fn as_type(&self) -> Option<&&'ctx TypeDecl>
Optionally returns references to the inner fields if this is a ItemRef::Type, otherwise None
Sourcepub fn into_type(self) -> Result<&'ctx TypeDecl, Self>
pub fn into_type(self) -> Result<&'ctx TypeDecl, Self>
Returns the inner fields if this is a ItemRef::Type, otherwise returns back the enum in the Err case of the result
Sourcepub unsafe fn into_type_unchecked(self) -> &'ctx TypeDecl
pub unsafe fn into_type_unchecked(self) -> &'ctx TypeDecl
Unchecked return of the inner fields of ItemRef::Type.
§Safety
Results in undefined behavior when it is the incorrect variant.
Sourcepub unsafe fn as_type_unchecked(&self) -> &&'ctx TypeDecl
pub unsafe fn as_type_unchecked(&self) -> &&'ctx TypeDecl
Unchecked reference of the inner fields of ItemRef::Type.
§Safety
Results in undefined behavior when it is the incorrect variant.
Sourcepub unsafe fn as_type_mut_unchecked(&mut self) -> &mut &'ctx TypeDecl
pub unsafe fn as_type_mut_unchecked(&mut self) -> &mut &'ctx TypeDecl
Unchecked mutable reference of the inner fields of ItemRef::Type.
§Safety
Results in undefined behavior when it is the incorrect variant.
Sourcepub fn as_fun_mut(&mut self) -> Option<&mut &'ctx FunDecl>
pub fn as_fun_mut(&mut self) -> Option<&mut &'ctx FunDecl>
Optionally returns mutable references to the inner fields if this is a ItemRef::Fun, otherwise None
Sourcepub fn as_fun(&self) -> Option<&&'ctx FunDecl>
pub fn as_fun(&self) -> Option<&&'ctx FunDecl>
Optionally returns references to the inner fields if this is a ItemRef::Fun, otherwise None
Sourcepub fn into_fun(self) -> Result<&'ctx FunDecl, Self>
pub fn into_fun(self) -> Result<&'ctx FunDecl, Self>
Returns the inner fields if this is a ItemRef::Fun, otherwise returns back the enum in the Err case of the result
Sourcepub unsafe fn into_fun_unchecked(self) -> &'ctx FunDecl
pub unsafe fn into_fun_unchecked(self) -> &'ctx FunDecl
Unchecked return of the inner fields of ItemRef::Fun.
§Safety
Results in undefined behavior when it is the incorrect variant.
Sourcepub unsafe fn as_fun_unchecked(&self) -> &&'ctx FunDecl
pub unsafe fn as_fun_unchecked(&self) -> &&'ctx FunDecl
Unchecked reference of the inner fields of ItemRef::Fun.
§Safety
Results in undefined behavior when it is the incorrect variant.
Sourcepub unsafe fn as_fun_mut_unchecked(&mut self) -> &mut &'ctx FunDecl
pub unsafe fn as_fun_mut_unchecked(&mut self) -> &mut &'ctx FunDecl
Unchecked mutable reference of the inner fields of ItemRef::Fun.
§Safety
Results in undefined behavior when it is the incorrect variant.
Sourcepub fn as_global_mut(&mut self) -> Option<&mut &'ctx GlobalDecl>
pub fn as_global_mut(&mut self) -> Option<&mut &'ctx GlobalDecl>
Optionally returns mutable references to the inner fields if this is a ItemRef::Global, otherwise None
Sourcepub fn as_global(&self) -> Option<&&'ctx GlobalDecl>
pub fn as_global(&self) -> Option<&&'ctx GlobalDecl>
Optionally returns references to the inner fields if this is a ItemRef::Global, otherwise None
Sourcepub fn into_global(self) -> Result<&'ctx GlobalDecl, Self>
pub fn into_global(self) -> Result<&'ctx GlobalDecl, Self>
Returns the inner fields if this is a ItemRef::Global, otherwise returns back the enum in the Err case of the result
Sourcepub unsafe fn into_global_unchecked(self) -> &'ctx GlobalDecl
pub unsafe fn into_global_unchecked(self) -> &'ctx GlobalDecl
Unchecked return of the inner fields of ItemRef::Global.
§Safety
Results in undefined behavior when it is the incorrect variant.
Sourcepub unsafe fn as_global_unchecked(&self) -> &&'ctx GlobalDecl
pub unsafe fn as_global_unchecked(&self) -> &&'ctx GlobalDecl
Unchecked reference of the inner fields of ItemRef::Global.
§Safety
Results in undefined behavior when it is the incorrect variant.
Sourcepub unsafe fn as_global_mut_unchecked(&mut self) -> &mut &'ctx GlobalDecl
pub unsafe fn as_global_mut_unchecked(&mut self) -> &mut &'ctx GlobalDecl
Unchecked mutable reference of the inner fields of ItemRef::Global.
§Safety
Results in undefined behavior when it is the incorrect variant.
Sourcepub fn is_trait_decl(&self) -> bool
pub fn is_trait_decl(&self) -> bool
Returns true if this is a ItemRef::TraitDecl, otherwise false
Sourcepub fn as_trait_decl_mut(&mut self) -> Option<&mut &'ctx TraitDecl>
pub fn as_trait_decl_mut(&mut self) -> Option<&mut &'ctx TraitDecl>
Optionally returns mutable references to the inner fields if this is a ItemRef::TraitDecl, otherwise None
Sourcepub fn as_trait_decl(&self) -> Option<&&'ctx TraitDecl>
pub fn as_trait_decl(&self) -> Option<&&'ctx TraitDecl>
Optionally returns references to the inner fields if this is a ItemRef::TraitDecl, otherwise None
Sourcepub fn into_trait_decl(self) -> Result<&'ctx TraitDecl, Self>
pub fn into_trait_decl(self) -> Result<&'ctx TraitDecl, Self>
Returns the inner fields if this is a ItemRef::TraitDecl, otherwise returns back the enum in the Err case of the result
Sourcepub unsafe fn into_trait_decl_unchecked(self) -> &'ctx TraitDecl
pub unsafe fn into_trait_decl_unchecked(self) -> &'ctx TraitDecl
Unchecked return of the inner fields of ItemRef::TraitDecl.
§Safety
Results in undefined behavior when it is the incorrect variant.
Sourcepub unsafe fn as_trait_decl_unchecked(&self) -> &&'ctx TraitDecl
pub unsafe fn as_trait_decl_unchecked(&self) -> &&'ctx TraitDecl
Unchecked reference of the inner fields of ItemRef::TraitDecl.
§Safety
Results in undefined behavior when it is the incorrect variant.
Sourcepub unsafe fn as_trait_decl_mut_unchecked(&mut self) -> &mut &'ctx TraitDecl
pub unsafe fn as_trait_decl_mut_unchecked(&mut self) -> &mut &'ctx TraitDecl
Unchecked mutable reference of the inner fields of ItemRef::TraitDecl.
§Safety
Results in undefined behavior when it is the incorrect variant.
Sourcepub fn is_trait_impl(&self) -> bool
pub fn is_trait_impl(&self) -> bool
Returns true if this is a ItemRef::TraitImpl, otherwise false
Sourcepub fn as_trait_impl_mut(&mut self) -> Option<&mut &'ctx TraitImpl>
pub fn as_trait_impl_mut(&mut self) -> Option<&mut &'ctx TraitImpl>
Optionally returns mutable references to the inner fields if this is a ItemRef::TraitImpl, otherwise None
Sourcepub fn as_trait_impl(&self) -> Option<&&'ctx TraitImpl>
pub fn as_trait_impl(&self) -> Option<&&'ctx TraitImpl>
Optionally returns references to the inner fields if this is a ItemRef::TraitImpl, otherwise None
Sourcepub fn into_trait_impl(self) -> Result<&'ctx TraitImpl, Self>
pub fn into_trait_impl(self) -> Result<&'ctx TraitImpl, Self>
Returns the inner fields if this is a ItemRef::TraitImpl, otherwise returns back the enum in the Err case of the result
Sourcepub unsafe fn into_trait_impl_unchecked(self) -> &'ctx TraitImpl
pub unsafe fn into_trait_impl_unchecked(self) -> &'ctx TraitImpl
Unchecked return of the inner fields of ItemRef::TraitImpl.
§Safety
Results in undefined behavior when it is the incorrect variant.
Sourcepub unsafe fn as_trait_impl_unchecked(&self) -> &&'ctx TraitImpl
pub unsafe fn as_trait_impl_unchecked(&self) -> &&'ctx TraitImpl
Unchecked reference of the inner fields of ItemRef::TraitImpl.
§Safety
Results in undefined behavior when it is the incorrect variant.
Sourcepub unsafe fn as_trait_impl_mut_unchecked(&mut self) -> &mut &'ctx TraitImpl
pub unsafe fn as_trait_impl_mut_unchecked(&mut self) -> &mut &'ctx TraitImpl
Unchecked mutable reference of the inner fields of ItemRef::TraitImpl.
§Safety
Results in undefined behavior when it is the incorrect variant.
Source§impl<'ctx> ItemRef<'ctx>
impl<'ctx> ItemRef<'ctx>
pub fn id(&self) -> ItemId
pub fn to_owned(&self) -> ItemByVal
pub fn item_meta(&self) -> &'ctx ItemMeta
Sourcepub fn generic_params(&self) -> &'ctx GenericParams
pub fn generic_params(&self) -> &'ctx GenericParams
The generic parameters of this item.
Sourcepub fn identity_args(&self) -> GenericArgs
pub fn identity_args(&self) -> GenericArgs
Sourcepub fn drive<V: VisitAst>(&self, visitor: &mut V) -> ControlFlow<V::Break>
pub fn drive<V: VisitAst>(&self, visitor: &mut V) -> ControlFlow<V::Break>
We can’t implement AstVisitable because of the 'static constraint, but it’s ok because
ItemRef isn’t contained in any of our types.
Sourcepub fn drive_two<V: ZipAst>(
&self,
other: &Self,
visitor: &mut V,
) -> ControlFlow<V::Break>
pub fn drive_two<V: ZipAst>( &self, other: &Self, visitor: &mut V, ) -> ControlFlow<V::Break>
Visit two items in lockstep.
Sourcepub fn dyn_visit<T: AstVisitable>(&self, f: impl FnMut(&T))
pub fn dyn_visit<T: AstVisitable>(&self, f: impl FnMut(&T))
Visit all occurrences of that type inside self, in pre-order traversal.
Sourcepub fn is_unsafe_to_declare(&self, krate: &TranslatedCrate) -> bool
pub fn is_unsafe_to_declare(&self, krate: &TranslatedCrate) -> bool
Whether this item is unsafe to declare, i.e. whether whoever declares it discharges a proof
obligation. Note that declaring an unsafe fn or unsafe trait is safe: the obligation is on the
callers/implementors respectively.
Trait Implementations§
impl<'ctx> Copy for ItemRef<'ctx>
Source§impl<'ctx, 's, V> Drive<'s, V> for ItemRef<'ctx>
impl<'ctx, 's, V> Drive<'s, V> for ItemRef<'ctx>
Source§fn drive_inner(&'s self, visitor: &mut V) -> ControlFlow<V::Break>
fn drive_inner(&'s self, visitor: &mut V) -> ControlFlow<V::Break>
v.visit() on the immediate contents of self.Source§impl<'ctx, 's, V> DriveMut<'s, V> for ItemRef<'ctx>
impl<'ctx, 's, V> DriveMut<'s, V> for ItemRef<'ctx>
Source§fn drive_inner_mut(&'s mut self, visitor: &mut V) -> ControlFlow<V::Break>
fn drive_inner_mut(&'s mut self, visitor: &mut V) -> ControlFlow<V::Break>
v.visit() on the immediate contents of self.Source§impl<'ctx, 's, V> DriveTwo<'s, V> for ItemRef<'ctx>
impl<'ctx, 's, V> DriveTwo<'s, V> for ItemRef<'ctx>
Source§fn drive_two_inner(
&'s self,
other: &'s Self,
visitor: &mut V,
) -> ControlFlow<V::Break>
fn drive_two_inner( &'s self, other: &'s Self, visitor: &mut V, ) -> ControlFlow<V::Break>
v.visit() on the immediate contents of self and other, if they correspond. If
the values don’t match up, this returns Break(Default::default()).Source§impl<C: AstFormatter> FmtWithCtx<C> for ItemRef<'_>
impl<C: AstFormatter> FmtWithCtx<C> for ItemRef<'_>
Auto Trait Implementations§
impl<'ctx> Freeze for ItemRef<'ctx>
impl<'ctx> RefUnwindSafe for ItemRef<'ctx>
impl<'ctx> Send for ItemRef<'ctx>
impl<'ctx> Sync for ItemRef<'ctx>
impl<'ctx> Unpin for ItemRef<'ctx>
impl<'ctx> UnsafeUnpin for ItemRef<'ctx>
impl<'ctx> UnwindSafe for ItemRef<'ctx>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
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 more