Skip to content

Commit 5cb7c88

Browse files
committed
Allow open_inv attribute on functions
1 parent a9b3713 commit 5cb7c88

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

creusot/src/ctx.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ impl<'tcx, 'sess> TranslationCtx<'tcx> {
209209
def_id: DefId,
210210
ty: Ty<'tcx>,
211211
) -> Option<(DefId, SubstsRef<'tcx>)> {
212+
if util::is_open_ty_inv(self.tcx, def_id) {
213+
return None;
214+
}
215+
212216
debug!("resolving type invariant of {ty:?} in {def_id:?}");
213217
let param_env = self.param_env(def_id);
214218
let trait_did = self.get_diagnostic_item(Symbol::intern("creusot_invariant_method"))?;

creusot/src/util.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ pub(crate) fn is_extern_spec(tcx: TyCtxt, def_id: DefId) -> bool {
9393
get_attr(tcx.get_attrs_unchecked(def_id), &["creusot", "extern_spec"]).is_some()
9494
}
9595

96+
pub(crate) fn is_open_ty_inv(tcx: TyCtxt, def_id: DefId) -> bool {
97+
get_attr(tcx.get_attrs_unchecked(def_id), &["creusot", "open_inv"]).is_some()
98+
}
99+
96100
pub(crate) fn is_type_invariant(tcx: TyCtxt, def_id: DefId) -> bool {
97101
let Some(assoc_item) = tcx.opt_associated_item(def_id) else { return false };
98102
let Some(trait_item_did) = (match assoc_item.container {

0 commit comments

Comments
 (0)