Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
154 commits
Select commit Hold shift + click to select a range
4eae892
add: ForallSort
coeff-aij May 23, 2026
2e330a3
change: translate param type using ForallSortIdx
coeff-aij May 24, 2026
f95cfde
change: translate Type::Param into chc::Sort::Forall
coeff-aij Jun 8, 2026
debaa61
change: use forall sort instead of deferred type
coeff-aij Jun 8, 2026
03d7932
add: output (define-forall-sort)
coeff-aij May 24, 2026
0d47cc8
fix: duplication of ForallSortIdx for the same parameter
coeff-aij May 24, 2026
4e35b61
add test cases using unknown type parameters with trait bounds
coeff-aij May 24, 2026
2ef31cb
change: use DeferredType for generic functions without requires/ensures
coeff-aij May 25, 2026
f42debf
change: prevent overwriting concrete types with deferred types
coeff-aij May 25, 2026
0a2cc17
change: disable DeferredType completely
coeff-aij May 25, 2026
dc9b0e9
remove all extern_spec in std.rs temporarily
coeff-aij Jun 8, 2026
6d82bfb
add: imcomplete support for alias types
coeff-aij Jun 8, 2026
a0df8dc
change: use Type::Param and chc::Sort::Forall for type prameters
coeff-aij May 27, 2026
85d9e01
add: ForallPred represents unresolved user-defined predicates
coeff-aij May 27, 2026
4d381fc
change: replace unresolved user-defined predicates with ForallPred
coeff-aij May 27, 2026
14170e7
fix: distinguish different type parameters in subtyping
coeff-aij May 27, 2026
6ee71de
change: store the def_id of the corresponding function in TypeBuilder
coeff-aij May 27, 2026
6c8add1
fix: identify type parameters using the DefId of the owner(e.g. `fn f…
coeff-aij May 28, 2026
af226a4
fix: wrong conditionals to insert forall predicates
coeff-aij May 28, 2026
3888011
fix: normalize thrust::Model::Ty
coeff-aij May 28, 2026
968a4a7
fix: propagate the DefId for the owner function of formula_fn and
coeff-aij Jun 8, 2026
87969f2
fix: use both TypeParamIdx and ForallSortIdx for type parameters
coeff-aij May 29, 2026
2855cc5
add: insert declarations of universally quantified predicate variables
coeff-aij May 30, 2026
8127496
add: analyze and output dependencies between predicates
coeff-aij May 30, 2026
23187ce
add: translate alias type into forall sort
coeff-aij Jun 3, 2026
01f9f6c
add: tests for unknown type parameters
coeff-aij Jun 3, 2026
743bcda
fix: propagate owner_fn_id of type parameters
coeff-aij Jun 8, 2026
d5cdefb
add: debug print for AliasTy
coeff-aij Jun 3, 2026
0dc245d
fix: propagate owner_fn_id of type parameters
coeff-aij Jun 8, 2026
5d50264
add: translate <ParamTy as Model>::Ty into ParamTy
coeff-aij Jun 4, 2026
516cbd5
add: register_generic_def() for substitution of generic args from call
coeff-aij Jun 8, 2026
6de74be
fix: instantiate generic type parameters contained in args of predicate
coeff-aij Jun 7, 2026
b921e2c
add: distinguish calls of forall-predicates with different type
coeff-aij Jun 8, 2026
59f401c
fix: skip expected_ty() for trait methods without MIR body
coeff-aij Jun 7, 2026
e4ed770
change: try to bypass the instantiation of unknown generic args on
coeff-aij Jun 9, 2026
6867936
add: register FunctionType for type parameters with Fn/FnMut/FnOnce
coeff-aij Jun 11, 2026
1c53d16
fix: wrong annotations in a test
coeff-aij Jun 11, 2026
1eb229b
add: more tests for traits
coeff-aij Jun 11, 2026
52ad0ae
add: test for &mut T (not supported for now)
coeff-aij Jun 11, 2026
eaddc78
fix: error on mutable references with unknown type parameters `&mut T`
coeff-aij Jun 11, 2026
3fb0452
fix: wrong DefId and argument types for type parameter with fn trait
coeff-aij Jun 12, 2026
11b2ffd
add: resolve type parameter with fn trait as FunctionType
coeff-aij Jun 12, 2026
d40d441
fix: double instantiation of argument types in
coeff-aij Jun 13, 2026
55d02ca
change: distinguish ForallPred with type parameters instead of argument
coeff-aij Jun 13, 2026
482b186
add: introduce ForallPreds corresponding to pre-/post-condition of
coeff-aij Jun 13, 2026
acb0579
change: use forall sort instead of i32 type to represent unknown type
coeff-aij Jun 13, 2026
8121a82
revert: comment out for some extern_spec in std.rs
coeff-aij Jun 13, 2026
f55687e
add: distinguish args of projection(e.g. <T as Iterator>::Item and <U as
coeff-aij Jun 13, 2026
c4cb3bc
add: opaque type handling for Box and Vec
coeff-aij Jun 13, 2026
b6db754
fix: use try_normalize_erasing_regions to avoid panic
coeff-aij Jun 13, 2026
b1ad064
fix: relax &mut restriction to allow any element type
coeff-aij Jun 13, 2026
2077ab7
revert: commenting out most of extern_spec in std.rs
coeff-aij Jun 14, 2026
92764b7
add: annotations for fold() (WIP)
coeff-aij Jun 14, 2026
7fc03cd
Merge branch 'main' into forall-sort
coeff-aij Jun 14, 2026
312f362
fix annotations on fold() (WIP)
coeff-aij Jun 14, 2026
848f511
add test codes for reproducing/avoiding annotation errors
coeff-aij Jun 14, 2026
555106e
fix: annotations on fold()
coeff-aij Jun 15, 2026
9d1db19
fix: incorrect signature and duplication of ForallPred
coeff-aij Jun 17, 2026
7675b06
Merge branch 'main' into forall-sort
coeff-aij Jun 17, 2026
20349c1
Merge branch 'main' into forall-sort
coeff-aij Jun 20, 2026
77a562e
fix: propagete owner_fn_id to AnnotFnTranslator
coeff-aij Jun 20, 2026
9027871
fix: runtime error with borrowing RefCell
coeff-aij Jun 20, 2026
164e771
add: translate AliasTy with TemplateTypeBuilder
coeff-aij Jun 20, 2026
3bafc78
change: use deferred type for generic functions whose annotations and
coeff-aij Jun 20, 2026
481829f
fix: wrong abi for closure
coeff-aij Jun 20, 2026
675b0e7
fix: annotations on fold()
coeff-aij Jun 21, 2026
a0ce8fb
add: expand projection <T as thrust_models::Model> into T during loop
coeff-aij Jun 21, 2026
5dcba45
change: expand <AliasTy as thrst_models::Model>::Ty into AliasTy
coeff-aij Jun 21, 2026
9d65be6
fix: treat ParamTy(__ThrustSelf) as ParamTy(Self) (ad-hoc)
coeff-aij Jun 21, 2026
5aa82f4
revert: comment out of extern spec for Option::unwrap_or_else()
coeff-aij Jun 21, 2026
45d0bc4
fix: insert ForallPred for the last argument of closure
coeff-aij Jun 24, 2026
9eac0a5
add: positive test cases for traits
coeff-aij Jun 24, 2026
8f6e2fb
Merge branch 'main' into forall-sort
coeff-aij Jun 24, 2026
6e78502
fix: instantiate generic args during construction of argment types for
coeff-aij Jun 25, 2026
60ce95a
fix: bypass instantiation when generic args are unknown
coeff-aij Jun 25, 2026
06a003a
refine: lift closure_trait_args / closure_trait_ret to TypeBuilder
coeff-aij Jun 25, 2026
b9c1413
refine: add TypeBuilder::build_closure_type_for_param
coeff-aij Jun 25, 2026
dd10f29
analyze/annot_fn: drop closure_trait helpers, switch to TypeBuilder e…
coeff-aij Jun 25, 2026
0657632
refine: restrict register_closure_type_param visibility to pub(crate)
coeff-aij Jun 25, 2026
9f537ab
analyze/local_def: eagerly precompute closure contracts for type params
coeff-aij Jun 25, 2026
7595088
fix: try to normalize alias projections and allocate the same
coeff-aij Jun 26, 2026
e27f7ad
fix: use impl block's DefId for recognition of type parameters in imp…
coeff-aij Jun 26, 2026
2b696ce
change: use GenericDefTy for unannotated generic functions
coeff-aij Jun 26, 2026
083f312
remove: instantiation which breaks alias types which are already
coeff-aij Jun 26, 2026
d4252d9
add: gather closure param type from parent impl block
coeff-aij Jun 26, 2026
018444c
fix: unboxing ForallPred
coeff-aij Jun 26, 2026
2458b2e
fix: replace commas and whitespaces contained in `Map<I, F>` as
coeff-aij Jun 26, 2026
9c89768
fix(annot_fn): wrap closure receiver in Mut/Box for FnMut/Fn
coeff-aij Jun 27, 2026
6f870e0
fix(annot_fn): use owner fn's typing env for predicate resolution
coeff-aij Jun 27, 2026
7947594
refactor(analyze): use struct fields and local_idx for TypeParam::Gen…
coeff-aij Jun 27, 2026
d06c115
feat(chc): substitute ForallSort in ADT monomorphization via resolver…
coeff-aij Jun 27, 2026
bff22f1
feat(analyze): populate type_params_reverse before solve
coeff-aij Jun 27, 2026
57d9d4c
feat(chc): add dependencies field to UserDefinedPredDef
coeff-aij Jun 27, 2026
0a5b233
feat(chc): scan forall pred refs from user predicate bodies
coeff-aij Jun 27, 2026
c41997b
feat(chc): integrate user-defined pred deps into dep analysis
coeff-aij Jun 27, 2026
aa22e2c
fix(annot_fn): avoid double-wrapping already-Mut closure receivers
coeff-aij Jun 27, 2026
69debcc
Merge branch 'main' into forall-sort
coeff-aij Jun 28, 2026
57dbc0d
Merge branch 'main' into forall-sort
coeff-aij Jul 5, 2026
3db3950
Merge branch 'main' into forall-sort
coeff-aij Aug 16, 2026
e2a2d43
tests: configure extended CoAR solver
coeff-aij Aug 16, 2026
5b2d3bf
fix: include caller in generic type cache keys
coeff-aij Aug 16, 2026
e18fba1
improve forall sort type formatting
coeff-aij Aug 16, 2026
7993e4b
test: cover forall sort type formatting
coeff-aij Aug 16, 2026
ceb4d03
fix: handle singleton refinement values
coeff-aij Aug 16, 2026
5eef717
fix: add forall sort default values
coeff-aij Aug 16, 2026
015bda2
fix: handle unresolved trait method calls
coeff-aij Aug 16, 2026
6457860
test: specify trait update invariant
coeff-aij Aug 16, 2026
1d814ff
tests: configure solver for remaining polymorphic cases
coeff-aij Aug 16, 2026
267233d
Merge branch 'main' into forall-sort
coeff-aij Aug 25, 2026
9e49de6
Merge branch 'main' into forall-sort
coeff-aij Aug 30, 2026
cf01d7b
Rename ResolvedCallable::Closure to Concrete
coeff-aij Aug 30, 2026
bb83b7b
test: add solver configuration environmental variables
coeff-aij Aug 30, 2026
b4834bf
Reject non-Fn predicates before building closure trait args
coeff-aij Aug 31, 2026
ca53188
Use the method as caller_def_id for trait item types
coeff-aij Aug 31, 2026
6e3bf1b
Carry enum type args in FlowBinding and drop type-param unification
coeff-aij Aug 31, 2026
454173c
Enable extended solver for trait_generic_method tests
coeff-aij Aug 31, 2026
fe1c294
test: add pass/fail regression tests for enum type args in FlowBinding
coeff-aij Aug 31, 2026
5ce937e
add: debug info for (declare-forall-sort) in .smt2 file
coeff-aij Sep 1, 2026
cdda444
fix: place (declare-forall-fun) after (declare-datatypes) in .smt2 file
coeff-aij Sep 1, 2026
a560cd9
fix: emit declare-const for forall sort default only when used
coeff-aij Sep 1, 2026
8816d94
test: fix expected debug info format in emits_forall_sort_debug_info
coeff-aij Sep 1, 2026
66e2346
add: verification examples for bank account operations
coeff-aij Sep 1, 2026
5094a69
add: test for impl and generic function using trait
coeff-aij Sep 2, 2026
ce6bcae
Merge branch 'main' into forall-sort
coeff-aij Sep 4, 2026
50f63ef
Replace invariant_context with context in annot_simple_loop_self.rs
coeff-aij Sep 5, 2026
fb6dff0
Add fail counterparts for the pass/traits tests
coeff-aij Sep 5, 2026
ebfa167
Add probe tests for the language features used by iterator adapters
coeff-aij Sep 5, 2026
cbf05cf
Mark the match-&mut probes as passing with the rebuilt PCSat
coeff-aij Sep 6, 2026
1b59fcf
Find closure bounds declared on the enclosing impl or trait
coeff-aij Sep 6, 2026
8bb1439
Declare the sorts used only in forall and user-defined predicate sign…
coeff-aij Sep 6, 2026
4b4f0ac
Resolve trait predicate calls on concrete types in non-generic functions
coeff-aij Sep 6, 2026
1707162
Fix the simple_loop_call_multi.rs example and add its fail twin
coeff-aij Sep 6, 2026
8bfbcfc
Merge branch 'fix/concrete-trait-pred-in-nongeneric-fn' into forall-sort
coeff-aij Sep 6, 2026
622b67e
Fix simple_loop_self_mut.rs and add the simple_loop_self fail twins
coeff-aij Sep 6, 2026
323a3b8
Drop the probe_ prefix from the adapter feature tests
coeff-aij Sep 8, 2026
d7ddf81
Pin impl predicate resolution on a generic ADT from a generic owner
coeff-aij Sep 8, 2026
7828fb1
Regenerate the predicate hashes broken by dropping the probe_ prefix
coeff-aij Sep 8, 2026
cfcb2c5
Trim the comments of the adapter feature tests
coeff-aij Sep 8, 2026
b748267
Merge branch 'main' into forall-sort
coeff-aij Sep 8, 2026
af978e4
Drop the annotation-error probe tests
coeff-aij Sep 8, 2026
e4acd6a
Add the fold_noloop, id, and take adapter test pairs
coeff-aij Sep 8, 2026
56219a2
Lower `Ghost<T>` through its content instead of trait normalization
coeff-aij Sep 8, 2026
1e4deb1
Add the annotated variants of the two-loop trait tests
coeff-aij Sep 8, 2026
26bf976
Add the annotated variants of the fixed-filter tests
coeff-aij Sep 8, 2026
d4ddb53
fix: track generic fn call results by re-analyzing bodies at concrete…
coeff-aij Aug 31, 2026
5b9d65e
Note what ties a generic body's re-analysis to its caller
coeff-aij Sep 8, 2026
8acdcdc
Pin how a generic function's contract reaches a generic caller
coeff-aij Sep 8, 2026
9301494
Declare the forall default an empty array references
coeff-aij Sep 9, 2026
c0cfee5
Keep a `Self::Assoc` projection resolvable when lifted out of a trait…
coeff-aij Sep 9, 2026
79c5315
Resolve an impl's closure type parameter at the caller's arguments
coeff-aij Sep 9, 2026
09d408e
Let an `FnMut` precondition name the closure's current upvars
coeff-aij Sep 9, 2026
1ae7725
Adopt the ghost-history test pairs from iterator-adapters
coeff-aij Sep 9, 2026
c702e41
Break the item_ok propagation in ghost_produced's fail twin
coeff-aij Sep 9, 2026
1128385
Check a trait postcondition at the impl, not in the default body
coeff-aij Sep 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
296 changes: 234 additions & 62 deletions src/analyze.rs

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions src/analyze/annot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ pub fn closure_model_path() -> [Symbol; 3] {
]
}

pub fn ghost_model_path() -> [Symbol; 3] {
[
Symbol::intern("thrust"),
Symbol::intern("def"),
Symbol::intern("ghost_model"),
]
}

pub fn mut_model_new_path() -> [Symbol; 3] {
[
Symbol::intern("thrust"),
Expand Down
163 changes: 131 additions & 32 deletions src/analyze/annot_fn.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
use std::collections::HashMap;

use pretty::{termcolor, Pretty};
use rustc_hir::{def_id::LocalDefId, HirId};
use rustc_hir::{
def_id::{DefId, LocalDefId},
HirId,
};
use rustc_index::IndexVec;
use rustc_middle::ty::{self as mir_ty, TyCtxt};
use rustc_middle::ty::{self as mir_ty, TyCtxt, TypeFoldable};

use crate::analyze::{self, did_cache::DefIdCache};
use crate::chc;
use crate::chc::{self};
use crate::refine::{self, TypeBuilder};
use crate::rty;

Expand Down Expand Up @@ -204,12 +207,20 @@ impl<'a, 'tcx> AnnotFnTranslator<'a, 'tcx> {
analyzer: &'a analyze::Analyzer<'tcx>,
local_def_id: LocalDefId,
generic_args: mir_ty::GenericArgsRef<'tcx>,
owner_fn_id: DefId,
) -> Self {
let tcx = analyzer.tcx();
let body = tcx.hir_body_owned_by(local_def_id);
let typeck = tcx.typeck(local_def_id);
let def_ids = analyzer.def_ids();
let type_builder = TypeBuilder::new(tcx, def_ids.clone(), local_def_id.to_def_id());
let type_builder = TypeBuilder::new(
tcx,
def_ids.clone(),
owner_fn_id,
analyzer.type_params.clone(),
analyzer.closure_type_params.clone(),
analyzer.system.clone(),
);
let mut translator = Self {
tcx,
local_def_id,
Expand All @@ -227,11 +238,6 @@ impl<'a, 'tcx> AnnotFnTranslator<'a, 'tcx> {

pub fn with_def_id_cache(mut self, def_ids: DefIdCache<'tcx>) -> Self {
self.def_ids = def_ids;
self.type_builder = TypeBuilder::new(
self.tcx,
self.def_ids.clone(),
self.local_def_id.to_def_id(),
);
self
}

Expand Down Expand Up @@ -386,29 +392,52 @@ impl<'a, 'tcx> AnnotFnTranslator<'a, 'tcx> {
}
}

fn instantiate_generics<T>(
&self,
ty: T,
generic_args: mir_ty::GenericArgsRef<'tcx>,
) -> Option<T>
where
T: TypeFoldable<TyCtxt<'tcx>>,
{
if !self.generic_args.is_empty() {
Some(mir_ty::EarlyBinder::bind(ty).instantiate(self.tcx, generic_args))
} else {
None
}
}

fn expr_ty(&self, expr: &'tcx rustc_hir::Expr<'tcx>) -> mir_ty::Ty<'tcx> {
let ty = self.typeck.expr_ty(expr);
let instantiated = mir_ty::EarlyBinder::bind(ty).instantiate(self.tcx, self.generic_args);
let instantiated = self
.instantiate_generics(ty, self.generic_args)
.unwrap_or(ty);
let typing_env = mir_ty::TypingEnv::fully_monomorphized();
self.tcx.normalize_erasing_regions(typing_env, instantiated)
self.tcx
.try_normalize_erasing_regions(typing_env, instantiated)
.unwrap_or(instantiated)
}

fn pat_ty(&self, pat: &'tcx rustc_hir::Pat<'tcx>) -> mir_ty::Ty<'tcx> {
let ty = self.typeck.pat_ty(pat);
let instantiated = mir_ty::EarlyBinder::bind(ty).instantiate(self.tcx, self.generic_args);
let instantiated = self
.instantiate_generics(ty, self.generic_args)
.unwrap_or(ty);
let typing_env = mir_ty::TypingEnv::fully_monomorphized();
self.tcx.normalize_erasing_regions(typing_env, instantiated)
self.tcx
.try_normalize_erasing_regions(typing_env, instantiated)
.unwrap_or(instantiated)
}

pub fn to_formula_fn(&self) -> FormulaFn<'tcx> {
let formula = self.to_formula(self.body.value);
let params = self
.tcx
.fn_sig(self.local_def_id.to_def_id())
.instantiate(self.tcx, self.generic_args)
.skip_binder()
.inputs()
.to_vec();
let fn_sig = self.tcx.fn_sig(self.local_def_id.to_def_id());
let binder = if self.generic_args.is_empty() {
fn_sig.skip_binder()
} else {
fn_sig.instantiate(self.tcx, self.generic_args)
};
let params = binder.skip_binder().inputs().to_vec();
let param_idents = self
.tcx
.fn_arg_idents(self.local_def_id.to_def_id())
Expand Down Expand Up @@ -492,10 +521,41 @@ impl<'a, 'tcx> AnnotFnTranslator<'a, 'tcx> {
fn receiver_closure_fn_type(&self, receiver_ty: mir_ty::Ty<'tcx>) -> Option<rty::FunctionType> {
let closure_ty = self.receiver_closure_ty(receiver_ty)?;
let mir_ty::TyKind::Closure(def_id, args) = closure_ty.kind() else {
if let mir_ty::TyKind::Param(ty) = closure_ty.kind() {
tracing::debug!("ParamTy is found: {ty:?}");
let closure_fun_ty = self.type_builder.build_closure_type_for_param(
*ty,
self.local_def_id,
self.generic_args,
);
tracing::debug!(
"the obtained FunctionType for the closure {ty:?}: {closure_fun_ty:#?}"
);
if let Some(closure_fun_ty) = closure_fun_ty.clone() {
self.type_builder.register_closure_type_param(
analyze::TypeParam::GenericType {
param_def_id: self.type_builder.param_def_id(ty),
local_idx: self.type_builder.param_local_idx(ty),
},
closure_fun_ty,
);
};
return closure_fun_ty;
}
return None;
};
self.analyzer.known_function_ty_with_args(
*def_id,
self.tcx.mk_args(args.as_closure().parent_args()),
self.type_builder.owner_fn_id(),
)
}

fn register_forall_pred(&self, forall_pred: chc::ForallPred) {
self.analyzer
.known_function_ty_with_args(*def_id, self.tcx.mk_args(args.as_closure().parent_args()))
.system
.borrow_mut()
.register_forall_pred(forall_pred.clone());
}

/// Extracts the logical argument terms passed to `closure_precondition`/
Expand Down Expand Up @@ -574,9 +634,11 @@ impl<'a, 'tcx> AnnotFnTranslator<'a, 'tcx> {
}

fn node_arg_type_at(&self, hir_id: HirId, idx: usize) -> rty::Type<rty::Closed> {
let generic_args = self.typeck.node_args(hir_id);
let generic_args =
mir_ty::EarlyBinder::bind(generic_args).instantiate(self.tcx, self.generic_args);
let mut generic_args = self.typeck.node_args(hir_id);
if !self.generic_args.is_empty() {
generic_args =
mir_ty::EarlyBinder::bind(generic_args).instantiate(self.tcx, self.generic_args);
}
let elem_ty = generic_args.type_at(idx);
self.type_builder.build(elem_ty)
}
Expand Down Expand Up @@ -978,7 +1040,10 @@ impl<'a, 'tcx> AnnotFnTranslator<'a, 'tcx> {
.next()
.is_some()
{
let typing_env = mir_ty::TypingEnv::fully_monomorphized();
let typing_env = mir_ty::TypingEnv::post_analysis(
self.tcx,
self.type_builder.owner_fn_id(),
);
let generic_args = self.typeck.node_args(func_expr.hir_id);
tracing::debug!(
lhs = ?def_id,
Expand All @@ -987,23 +1052,57 @@ impl<'a, 'tcx> AnnotFnTranslator<'a, 'tcx> {
outer_generic_args = ?self.generic_args,
"resolving predicate call in formula"
);
let generic_args = mir_ty::EarlyBinder::bind(generic_args)
.instantiate(self.tcx, self.generic_args);
// `self.generic_args` is empty only when the owner has no generics,
// so the predicate's own args are already concrete and there is
// nothing to instantiate. In both cases `Instance::try_resolve`
// decides the routing: it resolves a call on a concrete type to the
// impl's predicate, and returns `None` for a call that still
// depends on the owner's type parameters (an `ImplSource::Param`),
// which is the only case that needs the forall predicate.
let generic_args = self
.instantiate_generics(generic_args, self.generic_args)
.unwrap_or(generic_args);

let instance = mir_ty::Instance::try_resolve(
self.tcx,
typing_env,
def_id,
generic_args,
)
.unwrap();
let pred_def_id = if let Some(instance) = instance {
instance.def_id()
let (is_unresolved_args, pred_def_id) = match instance {
Some(instance) => (false, instance.def_id()),
None => (true, def_id),
};

let pred = if is_unresolved_args {
tracing::debug!(?self.local_def_id, ?generic_args, "owner_fn_id={:?}", self.type_builder.owner_fn_id());
let type_params = generic_args
.types()
.map(|ty| self.type_builder.build(ty).to_sort())
.collect();

let params = args
.iter()
.map(|expr| {
self.type_builder.build(self.expr_ty(expr)).to_sort()
})
.collect();

let pred = refine::trait_forall_pred(
self.tcx,
pred_def_id,
type_params,
params,
);
self.register_forall_pred(pred.clone());
pred.into()
} else {
def_id
refine::user_defined_pred(self.tcx, pred_def_id).into()
};
let pred = refine::user_defined_pred(self.tcx, pred_def_id);
tracing::debug!("resolved predicate call in formula: {:?}", pred);
let arg_terms = args.iter().map(|e| self.to_term(e)).collect();
let atom = chc::Atom::new(pred.into(), arg_terms);
let atom = chc::Atom::new(pred, arg_terms);
return FormulaOrTerm::Formula(chc::Formula::Atom(atom));
}
}
Expand Down
Loading