Skip to content

Commit 92f28bd

Browse files
authored
Rollup merge of #92409 - bjorn3:libtest_cleanups, r=m-ou-se
Couple of libtest cleanups Remove the unnecessary `TDynBenchFn` trait and remove a couple of unused attributes and feature gates.
2 parents 0335b7b + e015b9e commit 92f28bd

File tree

3 files changed

+5
-21
lines changed

3 files changed

+5
-21
lines changed

Diff for: library/test/src/lib.rs

+4-14
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,12 @@
1313
// running tests while providing a base that other test frameworks may
1414
// build off of.
1515

16-
// N.B., this is also specified in this crate's Cargo.toml, but librustc_ast contains logic specific to
17-
// this crate, which relies on this attribute (rather than the value of `--crate-name` passed by
18-
// cargo) to detect this crate.
19-
20-
#![crate_name = "test"]
2116
#![unstable(feature = "test", issue = "50297")]
2217
#![doc(test(attr(deny(warnings))))]
23-
#![feature(libc)]
24-
#![feature(rustc_private)]
2518
#![feature(nll)]
2619
#![feature(available_parallelism)]
2720
#![feature(bench_black_box)]
2821
#![feature(internal_output_capture)]
29-
#![feature(panic_unwind)]
3022
#![feature(staged_api)]
3123
#![feature(termination_trait_lib)]
3224
#![feature(test)]
@@ -444,8 +436,8 @@ pub fn convert_benchmarks_to_tests(tests: Vec<TestDescAndFn>) -> Vec<TestDescAnd
444436
.into_iter()
445437
.map(|x| {
446438
let testfn = match x.testfn {
447-
DynBenchFn(bench) => DynTestFn(Box::new(move || {
448-
bench::run_once(|b| __rust_begin_short_backtrace(|| bench.run(b)))
439+
DynBenchFn(benchfn) => DynTestFn(Box::new(move || {
440+
bench::run_once(|b| __rust_begin_short_backtrace(|| benchfn(b)))
449441
})),
450442
StaticBenchFn(benchfn) => DynTestFn(Box::new(move || {
451443
bench::run_once(|b| __rust_begin_short_backtrace(|| benchfn(b)))
@@ -544,11 +536,9 @@ pub fn run_test(
544536
TestRunOpts { strategy, nocapture: opts.nocapture, concurrency, time: opts.time_options };
545537

546538
match testfn {
547-
DynBenchFn(bencher) => {
539+
DynBenchFn(benchfn) => {
548540
// Benchmarks aren't expected to panic, so we run them all in-process.
549-
crate::bench::benchmark(id, desc, monitor_ch, opts.nocapture, |harness| {
550-
bencher.run(harness)
551-
});
541+
crate::bench::benchmark(id, desc, monitor_ch, opts.nocapture, benchfn);
552542
None
553543
}
554544
StaticBenchFn(benchfn) => {

Diff for: library/test/src/stats.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![allow(missing_docs)]
2-
#![allow(deprecated)] // Float
32

43
use std::mem;
54

Diff for: library/test/src/types.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,6 @@ impl fmt::Display for TestName {
7474
}
7575
}
7676

77-
/// Represents a benchmark function.
78-
pub trait TDynBenchFn: Send {
79-
fn run(&self, harness: &mut Bencher);
80-
}
81-
8277
// A function that runs a test. If the function returns successfully,
8378
// the test succeeds; if the function panics then the test fails. We
8479
// may need to come up with a more clever definition of test in order
@@ -87,7 +82,7 @@ pub enum TestFn {
8782
StaticTestFn(fn()),
8883
StaticBenchFn(fn(&mut Bencher)),
8984
DynTestFn(Box<dyn FnOnce() + Send>),
90-
DynBenchFn(Box<dyn TDynBenchFn + 'static>),
85+
DynBenchFn(Box<dyn Fn(&mut Bencher) + Send>),
9186
}
9287

9388
impl TestFn {

0 commit comments

Comments
 (0)