Skip to content

Commit c14ede3

Browse files
committed
clean up
1 parent 190f4ae commit c14ede3

2 files changed

Lines changed: 7 additions & 44 deletions

File tree

crates/anodized-core/src/instrument.rs

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use proc_macro2::TokenStream;
2-
use quote::{ToTokens, quote};
3-
use syn::{Attribute, ItemConst, ItemFn, ItemImpl, ItemTrait, Meta, Result, parse_quote};
2+
use quote::ToTokens;
3+
use syn::{Attribute, ItemConst, ItemFn, ItemImpl, ItemTrait, Result, parse_quote};
44

55
use crate::{DataSpec, Spec};
66

@@ -150,37 +150,3 @@ fn find_spec_attr(attrs: Vec<Attribute>) -> syn::Result<(Option<Attribute>, Vec<
150150

151151
Ok((spec_attr, other_attrs))
152152
}
153-
154-
fn build_assert(
155-
cfg: Option<&Meta>,
156-
expr: &TokenStream,
157-
message: &str,
158-
repr: &TokenStream,
159-
) -> TokenStream {
160-
let repr_str = repr.to_string();
161-
let check = quote! { assert!(#expr, #message, #repr_str); };
162-
guard_check(cfg, check)
163-
}
164-
165-
fn build_eprint(
166-
cfg: Option<&Meta>,
167-
expr: &TokenStream,
168-
message: &str,
169-
repr: &TokenStream,
170-
) -> TokenStream {
171-
let repr_str = repr.to_string();
172-
let check = quote! {
173-
if !(#expr) {
174-
eprintln!(#message, #repr_str);
175-
}
176-
};
177-
guard_check(cfg, check)
178-
}
179-
180-
fn guard_check(cfg: Option<&Meta>, check: TokenStream) -> TokenStream {
181-
if let Some(cfg) = cfg {
182-
quote! { if cfg!(#cfg) { #check } }
183-
} else {
184-
check
185-
}
186-
}

crates/anodized-core/src/instrument/fns.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,16 @@
22
#[path = "fns_tests.rs"]
33
mod fns_tests;
44

5-
use proc_macro2::{Span, TokenStream};
5+
use proc_macro2::Span;
66
use quote::{ToTokens, quote};
77
use syn::{
8-
Attribute, Block, Expr, Ident, LitStr, Meta, Pat, PatIdent, Path, ReturnType, Signature, Stmt,
9-
Type,
8+
Attribute, Block, Expr, Ident, LitStr, Pat, PatIdent, Path, ReturnType, Signature, Stmt, Type,
109
parse::{Parse, Result},
1110
parse_quote,
1211
};
1312

1413
use crate::{
15-
Capture, PostCondition, PreCondition, Spec,
16-
instrument::{Config, build_assert, build_eprint},
17-
qualifiers::FnQualifiers,
14+
Capture, PostCondition, PreCondition, Spec, instrument::Config, qualifiers::FnQualifiers,
1815
};
1916

2017
impl Config {
@@ -180,7 +177,7 @@ impl Config {
180177
subpat: None,
181178
});
182179

183-
// --- Generate Precondition Checks ---
180+
// --- Generate Precondition Clauses ---
184181
let mut precondition_clauses: Vec<Expr> = vec![];
185182
for condition in spec.requires.iter().chain(&spec.maintains) {
186183
let closure = &condition.closure;
@@ -232,7 +229,7 @@ impl Config {
232229
let (#(#aliases),*): (#(#types),*) = (#(#exprs),*);
233230
};
234231

235-
// --- Generate Postcondition Checks ---
232+
// --- Generate Postcondition Clauses ---
236233
let mut postcondition_clauses: Vec<Expr> = vec![];
237234
for condition in &spec.maintains {
238235
let closure = condition.closure.to_token_stream();

0 commit comments

Comments
 (0)