pub struct MemoPdgConstructor<'tcx, K> {
pub(crate) tcx: TyCtxt<'tcx>,
pub(crate) call_change_callback: Rc<dyn CallChangeCallback<'tcx, K> + 'tcx>,
pub(crate) dump_mir: bool,
pub(crate) async_info: Rc<AsyncInfo>,
pub pdg_cache: Rc<TwoLevelCache<Instance<'tcx>, K, Option<PartialGraph<'tcx, K>>>>,
pub(crate) body_cache: Rc<BodyCache<'tcx>>,
disable_cache: bool,
relaxed: bool,
}
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: Rc<dyn CallChangeCallback<'tcx, K> + 'tcx>
§dump_mir: bool
§async_info: Rc<AsyncInfo>
§pdg_cache: Rc<TwoLevelCache<Instance<'tcx>, K, Option<PartialGraph<'tcx, K>>>>
§body_cache: Rc<BodyCache<'tcx>>
§disable_cache: bool
§relaxed: bool
Implementations§
Source§impl<'tcx, K: Default> MemoPdgConstructor<'tcx, K>
impl<'tcx, K: Default> MemoPdgConstructor<'tcx, K>
Source§impl<'tcx, K> MemoPdgConstructor<'tcx, K>
impl<'tcx, K> MemoPdgConstructor<'tcx, K>
Sourcepub fn new_with_callbacks(
tcx: TyCtxt<'tcx>,
callback: impl CallChangeCallback<'tcx, K> + 'tcx,
) -> Self
pub fn new_with_callbacks( tcx: TyCtxt<'tcx>, callback: impl CallChangeCallback<'tcx, K> + 'tcx, ) -> Self
Initialize the constructor.
pub fn with_disable_cache(&mut self, disable_cache: bool) -> &mut Self
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.
pub fn with_relaxed(&mut self, relaxed: bool) -> &mut Self
Sourcepub fn with_call_change_callback(
&mut self,
callback: impl CallChangeCallback<'tcx, K> + 'tcx,
) -> &mut Self
pub fn with_call_change_callback( &mut self, callback: impl CallChangeCallback<'tcx, K> + '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 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.
Make sure the body is retrievable or this function will panic.
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,
) -> Rc<dyn CallChangeCallback<'tcx, K> + 'tcx>
pub fn take_call_changes_policy( &mut self, ) -> Rc<dyn CallChangeCallback<'tcx, K> + 'tcx>
Used for testing.
pub(crate) fn maybe_span_err(&self, span: Span, msg: impl Into<DiagMessage>)
Source§impl<'tcx, K: Hash + Eq + Clone> MemoPdgConstructor<'tcx, K>
impl<'tcx, K: Hash + Eq + Clone> MemoPdgConstructor<'tcx, K>
Sourcepub fn construct_root<'a>(
&'a self,
function: LocalDefId,
) -> Cow<'a, PartialGraph<'tcx, K>>
pub fn construct_root<'a>( &'a self, function: LocalDefId, ) -> Cow<'a, PartialGraph<'tcx, K>>
Construct the intermediate PDG for this function. Instantiates any
generic arguments as dyn <constraints>
.
Sourcepub(crate) fn construct_for<'a>(
&'a self,
descriptor: (Instance<'tcx>, K),
) -> ConstructionResult<Cow<'a, PartialGraph<'tcx, K>>>
pub(crate) fn construct_for<'a>( &'a self, descriptor: (Instance<'tcx>, K), ) -> ConstructionResult<Cow<'a, PartialGraph<'tcx, K>>>
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>, K)) -> bool
pub fn is_in_cache(&self, resolution: (Instance<'tcx>, K)) -> bool
Has a PDG been constructed for this instance before?
pub fn is_recursion(&self, instance: Instance<'tcx>) -> bool
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
.
Auto Trait Implementations§
impl<'tcx, K> Freeze for MemoPdgConstructor<'tcx, K>
impl<'tcx, K> !RefUnwindSafe for MemoPdgConstructor<'tcx, K>
impl<'tcx, K> !Send for MemoPdgConstructor<'tcx, K>
impl<'tcx, K> !Sync for MemoPdgConstructor<'tcx, K>
impl<'tcx, K> Unpin for MemoPdgConstructor<'tcx, K>
impl<'tcx, K> !UnwindSafe for MemoPdgConstructor<'tcx, K>
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