Skip to content

#[bench] attribute dose not work #9

Open
@taiki-e

Description

@taiki-e

The current #[bench] attribute is broken because #7 was merged without testing.

code:

#![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:

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) {
  |                ^^^^^^^^^^^^^^^^^^^^^

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions