Rollup merge of #83197 - jyn514:cfg-test-dead-code, r=joshtriplett
Move some test-only code to test files Split out from https://github.com/rust-lang/rust/pull/83185.
This commit is contained in:
commit
37b7031078
8 changed files with 85 additions and 78 deletions
|
@ -15,7 +15,7 @@
|
|||
mod tests;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct TinyList<T: PartialEq> {
|
||||
pub struct TinyList<T> {
|
||||
head: Option<Element<T>>,
|
||||
}
|
||||
|
||||
|
@ -56,20 +56,10 @@ impl<T: PartialEq> TinyList<T> {
|
|||
}
|
||||
false
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn len(&self) -> usize {
|
||||
let (mut elem, mut count) = (self.head.as_ref(), 0);
|
||||
while let Some(ref e) = elem {
|
||||
count += 1;
|
||||
elem = e.next.as_deref();
|
||||
}
|
||||
count
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Element<T: PartialEq> {
|
||||
struct Element<T> {
|
||||
data: T,
|
||||
next: Option<Box<Element<T>>>,
|
||||
}
|
||||
|
|
|
@ -3,6 +3,17 @@ use super::*;
|
|||
extern crate test;
|
||||
use test::{black_box, Bencher};
|
||||
|
||||
impl<T> TinyList<T> {
|
||||
fn len(&self) -> usize {
|
||||
let (mut elem, mut count) = (self.head.as_ref(), 0);
|
||||
while let Some(ref e) = elem {
|
||||
count += 1;
|
||||
elem = e.next.as_deref();
|
||||
}
|
||||
count
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_contains_and_insert() {
|
||||
fn do_insert(i: u32) -> bool {
|
||||
|
|
|
@ -9,7 +9,7 @@ use std::mem;
|
|||
mod tests;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct TransitiveRelation<T: Eq + Hash> {
|
||||
pub struct TransitiveRelation<T> {
|
||||
// List of elements. This is used to map from a T to a usize.
|
||||
elements: FxIndexSet<T>,
|
||||
|
||||
|
@ -49,7 +49,7 @@ struct Edge {
|
|||
target: Index,
|
||||
}
|
||||
|
||||
impl<T: Clone + Debug + Eq + Hash> TransitiveRelation<T> {
|
||||
impl<T: Eq + Hash> TransitiveRelation<T> {
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.edges.is_empty()
|
||||
}
|
||||
|
@ -322,12 +322,6 @@ impl<T: Clone + Debug + Eq + Hash> TransitiveRelation<T> {
|
|||
.collect()
|
||||
}
|
||||
|
||||
/// A "best" parent in some sense. See `parents` and
|
||||
/// `postdom_upper_bound` for more details.
|
||||
pub fn postdom_parent(&self, a: &T) -> Option<&T> {
|
||||
self.mutual_immediate_postdominator(self.parents(a))
|
||||
}
|
||||
|
||||
fn with_closure<OP, R>(&self, op: OP) -> R
|
||||
where
|
||||
OP: FnOnce(&BitMatrix<usize, usize>) -> R,
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
use super::*;
|
||||
|
||||
impl<T: Eq + Hash> TransitiveRelation<T> {
|
||||
/// A "best" parent in some sense. See `parents` and
|
||||
/// `postdom_upper_bound` for more details.
|
||||
fn postdom_parent(&self, a: &T) -> Option<&T> {
|
||||
self.mutual_immediate_postdominator(self.parents(a))
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_one_step() {
|
||||
let mut relation = TransitiveRelation::default();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue