Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions compiler/rustc_builtin_macros/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,30 +207,30 @@ pub(crate) fn expand_test_or_bench(
};

let test_fn = if is_bench {
// A simple ident for a lambda
let b = Ident::from_str_and_span("b", attr_sp);

// avoid name collisions by using the function name within the identifier, see bug #148275
let bencher_param =
Ident::from_str_and_span(&format!("__bench_{}", fn_.ident.name), attr_sp);
cx.expr_call(
sp,
cx.expr_path(test_path("StaticBenchFn")),
thin_vec![
// #[coverage(off)]
// |b| self::test::assert_test_result(
// |__bench_fn_name| self::test::assert_test_result(
coverage_off(cx.lambda1(
sp,
cx.expr_call(
sp,
cx.expr_path(test_path("assert_test_result")),
thin_vec![
// super::$test_fn(b)
// super::$test_fn(__bench_fn_name)
cx.expr_call(
ret_ty_sp,
cx.expr_path(cx.path(sp, vec![fn_.ident])),
thin_vec![cx.expr_ident(sp, b)],
thin_vec![cx.expr_ident(sp, bencher_param)],
),
],
),
b,
bencher_param,
)), // )
],
)
Expand Down
Loading