pub struct MemoPdgConstructor<'tcx> {
pub(crate) tcx: TyCtxt<'tcx>,
pub(crate) call_change_callback: Option<Rc<dyn CallChangeCallback<'tcx> + 'tcx>>,
pub(crate) dump_mir: bool,
pub(crate) async_info: Rc<AsyncInfo>,
pub pdg_cache: Rc<Cache<Instance<'tcx>, PartialGraph<'tcx>>>,
pub(crate) body_cache: Rc<BodyCache<'tcx>>,
}
Expand description
A memoizing constructor of PDGs.
Each (LocalDefId, GenericArgs)
pair is guaranteed to be constructed only
once.
Fields§
§tcx: TyCtxt<'tcx>
§call_change_callback: Option<Rc<dyn CallChangeCallback<'tcx> + 'tcx>>
§dump_mir: bool
§async_info: Rc<AsyncInfo>
§pdg_cache: Rc<Cache<Instance<'tcx>, PartialGraph<'tcx>>>
§body_cache: Rc<BodyCache<'tcx>>
Implementations§
Source§impl<'tcx> MemoPdgConstructor<'tcx>
impl<'tcx> MemoPdgConstructor<'tcx>
Sourcepub fn new_with_cache(
tcx: TyCtxt<'tcx>,
body_cache: Rc<BodyCache<'tcx>>,
) -> Self
pub fn new_with_cache( tcx: TyCtxt<'tcx>, body_cache: Rc<BodyCache<'tcx>>, ) -> Self
Initialize the constructor.
Sourcepub fn with_dump_mir(&mut self, dump_mir: bool) -> &mut Self
pub fn with_dump_mir(&mut self, dump_mir: bool) -> &mut Self
Dump the MIR of any function that is visited.
Sourcepub fn with_call_change_callback(
&mut self,
callback: impl CallChangeCallback<'tcx> + 'tcx,
) -> &mut Self
pub fn with_call_change_callback( &mut self, callback: impl CallChangeCallback<'tcx> + 'tcx, ) -> &mut Self
Register a callback to determine how to deal with function calls seen. Overwrites any previously registered callback with no warning.
Sourcepub fn construct_root<'a>(
&'a self,
function: LocalDefId,
) -> &'a PartialGraph<'tcx>
pub fn construct_root<'a>( &'a self, function: LocalDefId, ) -> &'a PartialGraph<'tcx>
Construct the intermediate PDG for this function. Instantiates any
generic arguments as dyn <constraints>
.
Sourcepub(crate) fn construct_for<'a>(
&'a self,
resolution: Instance<'tcx>,
) -> Option<&'a PartialGraph<'tcx>>
pub(crate) fn construct_for<'a>( &'a self, resolution: Instance<'tcx>, ) -> Option<&'a PartialGraph<'tcx>>
Construct a graph for this instance of return it from the cache.
Returns None
if this is a recursive call trying to construct the graph again.
Sourcepub fn is_in_cache(&self, resolution: Instance<'tcx>) -> bool
pub fn is_in_cache(&self, resolution: Instance<'tcx>) -> bool
Has a PDG been constructed for this instance before?
Sourcepub fn construct_graph(&self, function: LocalDefId) -> DepGraph<'tcx>
pub fn construct_graph(&self, function: LocalDefId) -> DepGraph<'tcx>
Construct a final PDG for this function. Same as
Self::construct_root
this instantiates all generics as dyn
.
Additionally if this is an async fn
or #[async_trait]
it will inline
the closure as though the function were called with poll
.
Sourcepub fn body_for_def_id(&self, key: DefId) -> &'tcx CachedBody<'tcx>
pub fn body_for_def_id(&self, key: DefId) -> &'tcx CachedBody<'tcx>
Try to retrieve or load a body for this id.
Returns None
if the loading policy forbids loading from this crate.
Sourcepub fn body_cache(&self) -> &Rc<BodyCache<'tcx>>
pub fn body_cache(&self) -> &Rc<BodyCache<'tcx>>
Access to the underlying body cache.
Sourcepub fn take_call_changes_policy(
&mut self,
) -> Option<Rc<dyn CallChangeCallback<'tcx> + 'tcx>>
pub fn take_call_changes_policy( &mut self, ) -> Option<Rc<dyn CallChangeCallback<'tcx> + 'tcx>>
Used for testing.
Auto Trait Implementations§
impl<'tcx> Freeze for MemoPdgConstructor<'tcx>
impl<'tcx> !RefUnwindSafe for MemoPdgConstructor<'tcx>
impl<'tcx> !Send for MemoPdgConstructor<'tcx>
impl<'tcx> !Sync for MemoPdgConstructor<'tcx>
impl<'tcx> Unpin for MemoPdgConstructor<'tcx>
impl<'tcx> !UnwindSafe for MemoPdgConstructor<'tcx>
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 more