Skip to content

Commit

Permalink
chore(harness): fix clippy error #15701
Browse files Browse the repository at this point in the history
error[E0658]: attributes on expressions are experimental
  --> harness/macro/src/lib.rs:64:5
   |
64 |     #[cfg(feature = "sp1")]
   |     ^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #15701 <rust-lang/rust#15701> for more information
   = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable
   = note: this compiler was built on 2024-04-17; consider upgrading it if it is out of date
  • Loading branch information
keroro520 committed Nov 25, 2024
1 parent bcf888b commit 55379b4
Showing 1 changed file with 32 additions and 30 deletions.
62 changes: 32 additions & 30 deletions harness/macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,45 +59,47 @@ pub fn entrypoint(input: TokenStream) -> TokenStream {
};
}

#[cfg(feature = "sp1")]
let output = quote! {
// Set up a global allocator
use sp1_zkvm::heap::SimpleAlloc;
#[global_allocator]
static HEAP: SimpleAlloc = SimpleAlloc;
let output = if cfg!(feature = "sp1") {
quote! {
// Set up a global allocator
use sp1_zkvm::heap::SimpleAlloc;
#[global_allocator]
static HEAP: SimpleAlloc = SimpleAlloc;

#[cfg(test)]
#tests_entry
#[cfg(test)]
#tests_entry

#[cfg(not(test))]
const ZKVM_ENTRY: fn() = #main_entry;
#[cfg(test)]
const ZKVM_ENTRY: fn() = run_tests;
#[cfg(not(test))]
const ZKVM_ENTRY: fn() = #main_entry;
#[cfg(test)]
const ZKVM_ENTRY: fn() = run_tests;

mod zkvm_generated_main {
#[no_mangle]
fn main() {
super::ZKVM_ENTRY()
mod zkvm_generated_main {
#[no_mangle]
fn main() {
super::ZKVM_ENTRY()
}
}
}
};

#[cfg(feature = "risc0")]
let output = quote! {
#[cfg(test)]
#tests_entry
} else if cfg!(feature = "risc0") {
quote! {
#[cfg(test)]
#tests_entry

#[cfg(not(test))]
const ZKVM_ENTRY: fn() = #main_entry;
#[cfg(test)]
const ZKVM_ENTRY: fn() = run_tests;
#[cfg(not(test))]
const ZKVM_ENTRY: fn() = #main_entry;
#[cfg(test)]
const ZKVM_ENTRY: fn() = run_tests;

mod zkvm_generated_main {
#[no_mangle]
fn main() {
super::ZKVM_ENTRY()
mod zkvm_generated_main {
#[no_mangle]
fn main() {
super::ZKVM_ENTRY()
}
}
}
} else {
quote! {}
};

output.into()
Expand Down

0 comments on commit 55379b4

Please sign in to comment.