Skip to content

Commit 872c20d

Browse files
committed
Fix ExternEntry test
1 parent 724f6a1 commit 872c20d

File tree

1 file changed

+11
-25
lines changed

1 file changed

+11
-25
lines changed

src/librustc/session/config.rs

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2686,9 +2686,11 @@ mod tests {
26862686
use super::Options;
26872687

26882688
impl ExternEntry {
2689-
fn new_public(location: Option<String>) -> ExternEntry {
2690-
let mut locations = BTreeSet::new();
2691-
locations.insert(location);
2689+
fn new_public<S: Into<String>,
2690+
I: IntoIterator<Item = Option<S>>>(locations: I) -> ExternEntry {
2691+
let locations: BTreeSet<_> = locations.into_iter().map(|o| o.map(|s| s.into()))
2692+
.collect();
2693+
26922694
ExternEntry {
26932695
locations,
26942696
is_private_dep: false
@@ -2708,10 +2710,6 @@ mod tests {
27082710
BTreeMap::from_iter(entries.into_iter())
27092711
}
27102712

2711-
fn mk_set<V: Ord>(entries: Vec<V>) -> BTreeSet<V> {
2712-
BTreeSet::from_iter(entries.into_iter())
2713-
}
2714-
27152713
// When the user supplies --test we should implicitly supply --cfg test
27162714
#[test]
27172715
fn test_switch_implies_cfg_test() {
@@ -2829,45 +2827,33 @@ mod tests {
28292827
v1.externs = Externs::new(mk_map(vec![
28302828
(
28312829
String::from("a"),
2832-
mk_set(vec![ExternEntry::new_public(Some(String::from("b"))),
2833-
ExternEntry::new_public(Some(String::from("c")))
2834-
]),
2830+
ExternEntry::new_public(vec![Some("b"), Some("c")])
28352831
),
28362832
(
28372833
String::from("d"),
2838-
mk_set(vec![ExternEntry::new_public(Some(String::from("e"))),
2839-
ExternEntry::new_public(Some(String::from("f")))
2840-
]),
2834+
ExternEntry::new_public(vec![Some("e"), Some("f")])
28412835
),
28422836
]));
28432837

28442838
v2.externs = Externs::new(mk_map(vec![
28452839
(
28462840
String::from("d"),
2847-
mk_set(vec![ExternEntry::new_public(Some(String::from("e"))),
2848-
ExternEntry::new_public(Some(String::from("f")))
2849-
]),
2841+
ExternEntry::new_public(vec![Some("e"), Some("f")])
28502842
),
28512843
(
28522844
String::from("a"),
2853-
mk_set(vec![ExternEntry::new_public(Some(String::from("b"))),
2854-
ExternEntry::new_public(Some(String::from("c")))
2855-
]),
2845+
ExternEntry::new_public(vec![Some("b"), Some("c")])
28562846
),
28572847
]));
28582848

28592849
v3.externs = Externs::new(mk_map(vec![
28602850
(
28612851
String::from("a"),
2862-
mk_set(vec![ExternEntry::new_public(Some(String::from("b"))),
2863-
ExternEntry::new_public(Some(String::from("c")))
2864-
]),
2852+
ExternEntry::new_public(vec![Some("b"), Some("c")])
28652853
),
28662854
(
28672855
String::from("d"),
2868-
mk_set(vec![ExternEntry::new_public(Some(String::from("f"))),
2869-
ExternEntry::new_public(Some(String::from("e")))
2870-
]),
2856+
ExternEntry::new_public(vec![Some("f"), Some("e")])
28712857
),
28722858
]));
28732859

0 commit comments

Comments
 (0)