Skip to content

Commit

Permalink
Allow DefIds in async support
Browse files Browse the repository at this point in the history
  • Loading branch information
JustusAdam committed Sep 5, 2024
1 parent 98ecbb3 commit 0bdc6b9
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions crates/flowistry_pdg_construction/src/async_support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::rc::Rc;
use either::Either;
use itertools::Itertools;
use rustc_abi::{FieldIdx, VariantIdx};
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::def_id::DefId;
use rustc_middle::{
mir::{
AggregateKind, BasicBlock, Body, Location, Operand, Place, Rvalue, Statement,
Expand Down Expand Up @@ -65,7 +65,7 @@ pub fn try_as_async_trait_function<'tcx>(
tcx: TyCtxt,
def_id: DefId,
body: &Body<'tcx>,
) -> Option<(LocalDefId, GenericArgsRef<'tcx>, Location)> {
) -> Option<(DefId, GenericArgsRef<'tcx>, Location)> {
if !has_async_trait_signature(tcx, def_id) {
return None;
}
Expand All @@ -77,7 +77,7 @@ pub fn try_as_async_trait_function<'tcx>(
move |(statement_index, statement)| {
let (def_id, generics) = match_async_trait_assign(statement)?;
Some((
def_id.as_local()?,
def_id,
generics,
Location {
block,
Expand Down Expand Up @@ -149,7 +149,7 @@ fn match_pin_box_dyn_ty(lang_items: &rustc_hir::LanguageItems, t: ty::Ty) -> boo
})
}

fn get_async_generator<'tcx>(body: &Body<'tcx>) -> (LocalDefId, GenericArgsRef<'tcx>, Location) {
fn get_async_generator<'tcx>(body: &Body<'tcx>) -> (DefId, GenericArgsRef<'tcx>, Location) {
let block = BasicBlock::from_usize(0);
let location = Location {
block,
Expand All @@ -165,7 +165,7 @@ fn get_async_generator<'tcx>(body: &Body<'tcx>) -> (LocalDefId, GenericArgsRef<'
else {
panic!("Async fn should assign to a generator")
};
(def_id.expect_local(), generic_args, location)
(*def_id, generic_args, location)
}

/// Try to interpret this function as an async function.
Expand All @@ -187,8 +187,7 @@ pub fn determine_async<'tcx>(
)
};
let param_env = tcx.param_env_reveal_all_normalized(def_id);
let generator_fn =
utils::try_resolve_function(tcx, generator_def_id.to_def_id(), param_env, args)?;
let generator_fn = utils::try_resolve_function(tcx, generator_def_id, param_env, args)?;
Some((generator_fn, loc, asyncness))
}

Expand Down

0 comments on commit 0bdc6b9

Please sign in to comment.