async-rs / async-rs/async-attributes
#[bench] attribute dose not work
- Dominant language
- Rust
- Stars
- 49
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Description
The current `#[bench]` attribute is broken because #7 was merged without testing.
code:
```rust
#![feature(test)]
extern crate test;
use async_std::task;
#[async_attributes::bench]
async fn bench(b: &mut test::Bencher) {
b.iter(|| {
println!("hello world");
})
}
```
error:
```text
error: macros that expand to items must be delimited with braces or followed by a semicolon
--> benches/bench.rs:7:16
|
7 | async fn bench(b: &mut test::Bencher) {
| ^^^^^^^^^^^^^^^^^^^^^
help: change the delimiters to curly braces
|
7 | async fn bench( {: &mut test::Benche}) {
| ^ ^
help: add a semicolon
|
7 | async fn bench(b: &mut test::Bencher;) {
| ^
error: macro expansion ignores token `,` and any following
--> benches/bench.rs:7:16
|
6 | #[async_attributes::bench]
| -------------------------- caused by the macro expansion here
7 | async fn bench(b: &mut test::Bencher) {
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: the usage of `async_attributes::bench!` is likely invalid in item context
error: async benchmarks don't take any arguments
--> benches/bench.rs:7:16
|
7 | async fn bench(b: &mut test::Bencher) {
| ^^^^^^^^^^^^^^^^^^^^^
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the reported compiler errors from benches/bench.rs using the shown #[async_attributes::bench] example, then inspect the benchmark attribute implementation and the change from issue #7. Done means the async benchmark example compiles without the reported macro and argument errors and runs as intended.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100