Skip to content

Commit 62ec2cb

Browse files
committed
Remove some more cfg(test)s
1 parent 3d0d6ee commit 62ec2cb

File tree

11 files changed

+45
-60
lines changed

11 files changed

+45
-60
lines changed

src/bootstrap/cache.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,10 @@ impl Cache {
266266
.expect("invalid type mapped");
267267
stepcache.get(step).cloned()
268268
}
269+
}
269270

270-
#[cfg(test)]
271+
#[cfg(test)]
272+
impl Cache {
271273
pub fn all<S: Ord + Copy + Step>(&mut self) -> Vec<(S, S::Output)> {
272274
let cache = self.0.get_mut();
273275
let type_id = TypeId::of::<S>();
@@ -279,7 +281,6 @@ impl Cache {
279281
v
280282
}
281283

282-
#[cfg(test)]
283284
pub fn contains<S: Step>(&self) -> bool {
284285
self.0.borrow().contains_key(&TypeId::of::<S>())
285286
}

src/liballoc/collections/linked_list/tests.rs

-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ fn test_split_off() {
201201
}
202202
}
203203

204-
#[cfg(test)]
205204
fn fuzz_test(sz: i32) {
206205
let mut m: LinkedList<_> = LinkedList::new();
207206
let mut v = vec![];

src/liballoc/tests/linked_list.rs

-2
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,10 @@ fn test_basic() {
4040
assert_eq!(n.pop_front(), Some(1));
4141
}
4242

43-
#[cfg(test)]
4443
fn generate_test() -> LinkedList<i32> {
4544
list_from(&[0, 1, 2, 3, 4, 5, 6])
4645
}
4746

48-
#[cfg(test)]
4947
fn list_from<T: Clone>(v: &[T]) -> LinkedList<T> {
5048
v.iter().cloned().collect()
5149
}

src/liballoc/tests/vec_deque.rs

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ fn test_simple() {
4444
assert_eq!(d[3], 4);
4545
}
4646

47-
#[cfg(test)]
4847
fn test_parameterized<T: Clone + PartialEq + Debug>(a: T, b: T, c: T, d: T) {
4948
let mut deq = VecDeque::new();
5049
assert_eq!(deq.len(), 0);

src/librustc_data_structures/graph/dominators/mod.rs

-5
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,6 @@ impl<Node: Idx> Dominators<Node> {
127127
// FIXME -- could be optimized by using post-order-rank
128128
self.dominators(node).any(|n| n == dom)
129129
}
130-
131-
#[cfg(test)]
132-
fn all_immediate_dominators(&self) -> &IndexVec<Node, Option<Node>> {
133-
&self.immediate_dominators
134-
}
135130
}
136131

137132
pub struct Iter<'dom, Node: Idx> {

src/librustc_data_structures/graph/dominators/tests.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
use super::super::tests::TestGraph;
2-
31
use super::*;
42

3+
use super::super::tests::TestGraph;
4+
55
#[test]
66
fn diamond() {
77
let graph = TestGraph::new(0, &[(0, 1), (0, 2), (1, 3), (2, 3)]);
88

99
let dominators = dominators(&graph);
10-
let immediate_dominators = dominators.all_immediate_dominators();
10+
let immediate_dominators = &dominators.immediate_dominators;
1111
assert_eq!(immediate_dominators[0], Some(0));
1212
assert_eq!(immediate_dominators[1], Some(0));
1313
assert_eq!(immediate_dominators[2], Some(0));
@@ -22,7 +22,7 @@ fn paper() {
2222
(2, 1)]);
2323

2424
let dominators = dominators(&graph);
25-
let immediate_dominators = dominators.all_immediate_dominators();
25+
let immediate_dominators = &dominators.immediate_dominators;
2626
assert_eq!(immediate_dominators[0], None); // <-- note that 0 is not in graph
2727
assert_eq!(immediate_dominators[1], Some(6));
2828
assert_eq!(immediate_dominators[2], Some(6));

src/librustc_data_structures/obligation_forest/tests.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
#![cfg(test)]
2-
3-
use super::{Error, DoCompleted, ObligationForest, ObligationProcessor, Outcome, ProcessResult};
1+
use super::*;
42

53
use std::fmt;
64
use std::marker::PhantomData;

src/libsyntax/print/pprust.rs

-20
Original file line numberDiff line numberDiff line change
@@ -384,21 +384,6 @@ pub fn vis_to_string(v: &ast::Visibility) -> String {
384384
to_string(|s| s.print_visibility(v))
385385
}
386386

387-
#[cfg(test)]
388-
fn fun_to_string(decl: &ast::FnDecl,
389-
header: ast::FnHeader,
390-
name: ast::Ident,
391-
generics: &ast::Generics)
392-
-> String {
393-
to_string(|s| {
394-
s.head("");
395-
s.print_fn(decl, header, Some(name),
396-
generics, &source_map::dummy_spanned(ast::VisibilityKind::Inherited));
397-
s.end(); // Close the head box
398-
s.end(); // Close the outer box
399-
})
400-
}
401-
402387
fn block_to_string(blk: &ast::Block) -> String {
403388
to_string(|s| {
404389
// containing cbox, will be closed by print-block at }
@@ -421,11 +406,6 @@ pub fn attribute_to_string(attr: &ast::Attribute) -> String {
421406
to_string(|s| s.print_attribute(attr))
422407
}
423408

424-
#[cfg(test)]
425-
fn variant_to_string(var: &ast::Variant) -> String {
426-
to_string(|s| s.print_variant(var))
427-
}
428-
429409
pub fn arg_to_string(arg: &ast::Arg) -> String {
430410
to_string(|s| s.print_arg(arg, false))
431411
}

src/libsyntax/print/pprust/tests.rs

+16
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@ use crate::source_map;
55
use crate::with_default_globals;
66
use syntax_pos;
77

8+
fn fun_to_string(
9+
decl: &ast::FnDecl, header: ast::FnHeader, name: ast::Ident, generics: &ast::Generics
10+
) -> String {
11+
to_string(|s| {
12+
s.head("");
13+
s.print_fn(decl, header, Some(name),
14+
generics, &source_map::dummy_spanned(ast::VisibilityKind::Inherited));
15+
s.end(); // Close the head box
16+
s.end(); // Close the outer box
17+
})
18+
}
19+
20+
fn variant_to_string(var: &ast::Variant) -> String {
21+
to_string(|s| s.print_variant(var))
22+
}
23+
824
#[test]
925
fn test_fun_to_string() {
1026
with_default_globals(|| {

src/libtest/lib.rs

-22
Original file line numberDiff line numberDiff line change
@@ -380,28 +380,6 @@ pub struct TestOpts {
380380
pub options: Options,
381381
}
382382

383-
impl TestOpts {
384-
#[cfg(test)]
385-
fn new() -> TestOpts {
386-
TestOpts {
387-
list: false,
388-
filter: None,
389-
filter_exact: false,
390-
exclude_should_panic: false,
391-
run_ignored: RunIgnored::No,
392-
run_tests: false,
393-
bench_benchmarks: false,
394-
logfile: None,
395-
nocapture: false,
396-
color: AutoColor,
397-
format: OutputFormat::Pretty,
398-
test_threads: None,
399-
skip: vec![],
400-
options: Options::new(),
401-
}
402-
}
403-
}
404-
405383
/// Result of parsing the options.
406384
pub type OptRes = Result<TestOpts, String>;
407385

src/libtest/tests.rs

+21
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,27 @@ use crate::test::{
77
};
88
use std::sync::mpsc::channel;
99

10+
impl TestOpts {
11+
fn new() -> TestOpts {
12+
TestOpts {
13+
list: false,
14+
filter: None,
15+
filter_exact: false,
16+
exclude_should_panic: false,
17+
run_ignored: RunIgnored::No,
18+
run_tests: false,
19+
bench_benchmarks: false,
20+
logfile: None,
21+
nocapture: false,
22+
color: AutoColor,
23+
format: OutputFormat::Pretty,
24+
test_threads: None,
25+
skip: vec![],
26+
options: Options::new(),
27+
}
28+
}
29+
}
30+
1031
fn one_ignored_one_unignored_test() -> Vec<TestDescAndFn> {
1132
vec![
1233
TestDescAndFn {

0 commit comments

Comments
 (0)