-1

While trying to use cargobenchmark feature, it throws error:

error: use of unstable library feature 'test': `bench` is a part of custom test frameworks which are unstable

    |
    |     #[bench]
    |       ^^^^^
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
    = note: for more information, see issue #64266 <https://github.com/rust-lang/rust/issues/64266>
    = note: `#[deny(soft_unstable)]` on by default

Sandip
  • 156
  • 1
  • 11

1 Answers1

2

Steps to fix this issue:

  1. compile using nightly version or set nightly to default:

To compile using nightly version:

cargo +nightly bench ...

To set nightly as default:

rustup default nightly
  1. add test feature

To do this, add 2 lines to the top of your root file. (Even above imports)

#![feature(test)]
extern crate test;

use...

This will allow you to use the #[bench] feature.

Sandip
  • 156
  • 1
  • 11