17
17
// this crate, which relies on this attribute (rather than the value of `--crate-name` passed by
18
18
// cargo) to detect this crate.
19
19
20
+ #![ deny( rust_2018_idioms) ]
20
21
#![ crate_name = "test" ]
21
22
#![ unstable( feature = "test" , issue = "27812" ) ]
22
23
#![ doc( html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png" ,
32
33
#![ feature( termination_trait_lib) ]
33
34
#![ feature( test) ]
34
35
35
- extern crate getopts;
36
+ use getopts;
36
37
#[ cfg( any( unix, target_os = "cloudabi" ) ) ]
37
38
extern crate libc;
38
- extern crate term;
39
+ use term;
39
40
40
41
// FIXME(#54291): rustc and/or LLVM don't yet support building with panic-unwind
41
42
// on aarch64-pc-windows-msvc, so we don't link libtest against
@@ -78,7 +79,7 @@ const QUIET_MODE_MAX_COLUMN: usize = 100; // insert a '\n' after 100 tests in qu
78
79
79
80
// to be used by rustc to compile tests in libtest
80
81
pub mod test {
81
- pub use { assert_test_result, filter_tests, parse_opts, run_test, test_main, test_main_static,
82
+ pub use crate :: { assert_test_result, filter_tests, parse_opts, run_test, test_main, test_main_static,
82
83
Bencher , DynTestFn , DynTestName , Metric , MetricMap , Options , RunIgnored , ShouldPanic ,
83
84
StaticBenchFn , StaticTestFn , StaticTestName , TestDesc , TestDescAndFn , TestName ,
84
85
TestOpts , TestResult , TrFailed , TrFailedMsg , TrIgnored , TrOk } ;
@@ -87,7 +88,7 @@ pub mod test {
87
88
pub mod stats;
88
89
mod formatters;
89
90
90
- use formatters:: { JsonFormatter , OutputFormatter , PrettyFormatter , TerseFormatter } ;
91
+ use crate :: formatters:: { JsonFormatter , OutputFormatter , PrettyFormatter , TerseFormatter } ;
91
92
92
93
/// Whether to execute tests concurrently or not
93
94
#[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
@@ -131,7 +132,7 @@ impl TestName {
131
132
}
132
133
}
133
134
impl fmt:: Display for TestName {
134
- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
135
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
135
136
fmt:: Display :: fmt ( self . as_slice ( ) , f)
136
137
}
137
138
}
@@ -185,7 +186,7 @@ impl TestFn {
185
186
}
186
187
187
188
impl fmt:: Debug for TestFn {
188
- fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
189
+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
189
190
f. write_str ( match * self {
190
191
StaticTestFn ( ..) => "StaticTestFn(..)" ,
191
192
StaticBenchFn ( ..) => "StaticBenchFn(..)" ,
@@ -823,7 +824,7 @@ pub fn list_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> io::Res
823
824
let mut nbench = 0 ;
824
825
825
826
for test in filter_tests ( & opts, tests) {
826
- use TestFn :: * ;
827
+ use crate :: TestFn :: * ;
827
828
828
829
let TestDescAndFn {
829
830
desc : TestDesc { name, .. } ,
@@ -1454,12 +1455,12 @@ pub fn run_test(
1454
1455
1455
1456
match testfn {
1456
1457
DynBenchFn ( bencher) => {
1457
- :: bench:: benchmark ( desc, monitor_ch, opts. nocapture , |harness| {
1458
+ crate :: bench:: benchmark ( desc, monitor_ch, opts. nocapture , |harness| {
1458
1459
bencher. run ( harness)
1459
1460
} ) ;
1460
1461
}
1461
1462
StaticBenchFn ( benchfn) => {
1462
- :: bench:: benchmark ( desc, monitor_ch, opts. nocapture , |harness| {
1463
+ crate :: bench:: benchmark ( desc, monitor_ch, opts. nocapture , |harness| {
1463
1464
( benchfn. clone ( ) ) ( harness)
1464
1465
} ) ;
1465
1466
}
@@ -1673,7 +1674,7 @@ pub mod bench {
1673
1674
use std:: cmp;
1674
1675
use std:: io;
1675
1676
use std:: sync:: { Arc , Mutex } ;
1676
- use stats;
1677
+ use crate :: stats;
1677
1678
use super :: { BenchMode , BenchSamples , Bencher , MonitorMsg , Sender , Sink , TestDesc , TestResult } ;
1678
1679
1679
1680
pub fn benchmark < F > ( desc : TestDesc , monitor_ch : Sender < MonitorMsg > , nocapture : bool , f : F )
@@ -1749,13 +1750,13 @@ pub mod bench {
1749
1750
1750
1751
#[ cfg( test) ]
1751
1752
mod tests {
1752
- use test:: { filter_tests, parse_opts, run_test, DynTestFn , DynTestName , MetricMap , RunIgnored ,
1753
+ use crate :: test:: { filter_tests, parse_opts, run_test, DynTestFn , DynTestName , MetricMap , RunIgnored ,
1753
1754
ShouldPanic , StaticTestName , TestDesc , TestDescAndFn , TestOpts , TrFailed ,
1754
1755
TrFailedMsg , TrIgnored , TrOk } ;
1755
1756
use std:: sync:: mpsc:: channel;
1756
- use bench;
1757
- use Bencher ;
1758
- use Concurrent ;
1757
+ use crate :: bench;
1758
+ use crate :: Bencher ;
1759
+ use crate :: Concurrent ;
1759
1760
1760
1761
1761
1762
fn one_ignored_one_unignored_test ( ) -> Vec < TestDescAndFn > {
@@ -2156,7 +2157,7 @@ mod tests {
2156
2157
allow_fail : false ,
2157
2158
} ;
2158
2159
2159
- :: bench:: benchmark ( desc, tx, true , f) ;
2160
+ crate :: bench:: benchmark ( desc, tx, true , f) ;
2160
2161
rx. recv ( ) . unwrap ( ) ;
2161
2162
}
2162
2163
@@ -2175,7 +2176,7 @@ mod tests {
2175
2176
allow_fail : false ,
2176
2177
} ;
2177
2178
2178
- :: bench:: benchmark ( desc, tx, true , f) ;
2179
+ crate :: bench:: benchmark ( desc, tx, true , f) ;
2179
2180
rx. recv ( ) . unwrap ( ) ;
2180
2181
}
2181
2182
}
0 commit comments