pub trait MaybeDef: Copy {
// Required methods
fn opt_def_id(self) -> Option<DefId>;
fn opt_def<'tcx>(
self,
tcx: &impl HasTyCtxt<'tcx>,
) -> Option<(DefKind, DefId)>;
// Provided methods
fn opt_diag_name<'tcx>(self, tcx: &impl HasTyCtxt<'tcx>) -> Option<Symbol> { ... }
fn is_diag_item<'tcx>(
self,
tcx: &impl HasTyCtxt<'tcx>,
name: Symbol,
) -> bool { ... }
fn is_lang_item<'tcx>(
self,
tcx: &impl HasTyCtxt<'tcx>,
item: LangItem,
) -> bool { ... }
fn opt_impl_ty<'tcx>(
self,
tcx: &impl HasTyCtxt<'tcx>,
) -> Option<EarlyBinder<'tcx, Ty<'tcx>>> { ... }
fn opt_parent<'tcx>(self, tcx: &impl HasTyCtxt<'tcx>) -> Option<DefId> { ... }
fn is_impl<'tcx>(self, tcx: &impl HasTyCtxt<'tcx>) -> bool { ... }
fn ctor_parent<'tcx>(self, tcx: &impl HasTyCtxt<'tcx>) -> Option<DefId> { ... }
fn assoc_parent<'tcx>(self, tcx: &impl HasTyCtxt<'tcx>) -> Option<DefId> { ... }
fn assoc_fn_parent<'tcx>(self, tcx: &impl HasTyCtxt<'tcx>) -> Option<DefId> { ... }
}
Expand description
A type which may either contain a DefId
or be referred to by a DefId
.
Required Methods§
fn opt_def_id(self) -> Option<DefId>
Provided Methods§
Sourcefn opt_diag_name<'tcx>(self, tcx: &impl HasTyCtxt<'tcx>) -> Option<Symbol>
fn opt_diag_name<'tcx>(self, tcx: &impl HasTyCtxt<'tcx>) -> Option<Symbol>
Gets the diagnostic name of this definition if it has one.
Sourcefn is_diag_item<'tcx>(self, tcx: &impl HasTyCtxt<'tcx>, name: Symbol) -> bool
fn is_diag_item<'tcx>(self, tcx: &impl HasTyCtxt<'tcx>, name: Symbol) -> bool
Checks if this definition has the specified diagnostic name.
Sourcefn is_lang_item<'tcx>(self, tcx: &impl HasTyCtxt<'tcx>, item: LangItem) -> bool
fn is_lang_item<'tcx>(self, tcx: &impl HasTyCtxt<'tcx>, item: LangItem) -> bool
Checks if this definition is the specified LangItem
.
Sourcefn opt_impl_ty<'tcx>(
self,
tcx: &impl HasTyCtxt<'tcx>,
) -> Option<EarlyBinder<'tcx, Ty<'tcx>>>
fn opt_impl_ty<'tcx>( self, tcx: &impl HasTyCtxt<'tcx>, ) -> Option<EarlyBinder<'tcx, Ty<'tcx>>>
If this definition is an impl block gets its type.
Sourcefn opt_parent<'tcx>(self, tcx: &impl HasTyCtxt<'tcx>) -> Option<DefId>
fn opt_parent<'tcx>(self, tcx: &impl HasTyCtxt<'tcx>) -> Option<DefId>
Gets the parent of this definition if it has one.
Sourcefn is_impl<'tcx>(self, tcx: &impl HasTyCtxt<'tcx>) -> bool
fn is_impl<'tcx>(self, tcx: &impl HasTyCtxt<'tcx>) -> bool
Checks if this definition is an impl block.
Sourcefn ctor_parent<'tcx>(self, tcx: &impl HasTyCtxt<'tcx>) -> Option<DefId>
fn ctor_parent<'tcx>(self, tcx: &impl HasTyCtxt<'tcx>) -> Option<DefId>
If this definition is a constructor gets the DefId
of it’s type or variant.
Sourcefn assoc_parent<'tcx>(self, tcx: &impl HasTyCtxt<'tcx>) -> Option<DefId>
fn assoc_parent<'tcx>(self, tcx: &impl HasTyCtxt<'tcx>) -> Option<DefId>
If this definition is an associated item of an impl or trait gets the
DefId
of its parent.
Sourcefn assoc_fn_parent<'tcx>(self, tcx: &impl HasTyCtxt<'tcx>) -> Option<DefId>
fn assoc_fn_parent<'tcx>(self, tcx: &impl HasTyCtxt<'tcx>) -> Option<DefId>
If this definition is an associated function of an impl or trait gets the
DefId
of its parent.
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.