#![feature(test)]
extern crate test;
#[bench]
fn b(_: &mut test::bench::Bencher) {}
I should be able to run this as a benchmark, but I got the following error:
error[E0308]: mismatched types
--> src/lib.rs:6:1
|
5 | #[bench]
| -------- in this attribute macro expansion
6 | fn b(_: &mut test::bench::Bencher) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| expected `&mut Bencher`, found `TestDescAndFn`
| expected due to this
| constant defined here
| `b` is interpreted as a constant, not a new binding
| help: introduce a new binding instead: `other_b`
error[E0308]: mismatched types
--> src/lib.rs:6:1
|
5 | #[bench]
| -------- in this attribute macro expansion
6 | fn b(_: &mut test::bench::Bencher) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| expected `&mut Bencher`, found `TestDescAndFn`
| arguments to this function are incorrect
|
note: function defined here
--> src/lib.rs:6:4
|
6 | fn b(_: &mut test::bench::Bencher) {}
| ^ ----------------------------
For more information about this error, try `rustc --explain E0308`.
It seems that the macro expansion of #[bench] has a name collision with a variable named b.
|
// A simple ident for a lambda |
|
let b = Ident::from_str_and_span("b", attr_sp); |
|
|
|
cx.expr_call( |
|
sp, |
|
cx.expr_path(test_path("StaticBenchFn")), |
|
thin_vec![ |
|
// #[coverage(off)] |
|
// |b| self::test::assert_test_result( |
Meta
Reproducible on the playground with version 1.93.0-nightly (2025-10-28 278a90913daf77077910) (click on the three dots on top left -> "test")
I should be able to run this as a benchmark, but I got the following error:
It seems that the macro expansion of
#[bench]has a name collision with a variable namedb.rust/compiler/rustc_builtin_macros/src/test.rs
Lines 210 to 218 in 292be5c
Meta
Reproducible on the playground with version
1.93.0-nightly (2025-10-28 278a90913daf77077910)(click on the three dots on top left -> "test")