Skip to content

Commit 5bc2d03

Browse files
committed
auto merge of #14783 : alexcrichton/rust/rollup, r=alexcrichton
Closes #14611 (std: Remove the as_utf16_p functions) Closes #14694 (Num cleanup) Closes #14760 (Add --color to test binary options) Closes #14763 (std: Move dynamic_lib from std::unstable to std) Closes #14766 (Add test for issue #13446) Closes #14769 (collections: Add missing Default impls) Closes #14773 (General nits) Closes #14776 (rustdoc: Correctly classify enums/typedefs)
2 parents 5bf5cc6 + 5ede96c commit 5bc2d03

32 files changed

+309
-210
lines changed

src/compiletest/compiletest.rs

+1
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
292292
save_metrics: config.save_metrics.clone(),
293293
test_shard: config.test_shard.clone(),
294294
nocapture: false,
295+
color: test::AutoColor,
295296
}
296297
}
297298

src/compiletest/procsrv.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use std::os;
1212
use std::str;
1313
use std::io::process::{ProcessExit, Command, Process, ProcessOutput};
14-
use std::unstable::dynamic_lib::DynamicLibrary;
14+
use std::dynamic_lib::DynamicLibrary;
1515

1616
fn target_env(lib_path: &str, prog: &str) -> Vec<(String, String)> {
1717
let prog = if cfg!(windows) {prog.slice_to(prog.len() - 4)} else {prog};

src/libcollections/bitv.rs

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use core::prelude::*;
1414

1515
use core::cmp;
16+
use core::default::Default;
1617
use core::fmt;
1718
use core::iter::{Enumerate, Repeat, Map, Zip};
1819
use core::ops;
@@ -698,6 +699,11 @@ pub struct BitvSet {
698699
bitv: BigBitv
699700
}
700701

702+
impl Default for BitvSet {
703+
#[inline]
704+
fn default() -> BitvSet { BitvSet::new() }
705+
}
706+
701707
impl BitvSet {
702708
/// Creates a new bit vector set with initially no contents
703709
pub fn new() -> BitvSet {

src/libcollections/dlist.rs

+6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use core::prelude::*;
2525

2626
use alloc::owned::Box;
27+
use core::default::Default;
2728
use core::fmt;
2829
use core::iter;
2930
use core::mem;
@@ -262,6 +263,11 @@ impl<T> Deque<T> for DList<T> {
262263
}
263264
}
264265

266+
impl<T> Default for DList<T> {
267+
#[inline]
268+
fn default() -> DList<T> { DList::new() }
269+
}
270+
265271
impl<T> DList<T> {
266272
/// Create an empty DList
267273
#[inline]

src/libcollections/priority_queue.rs

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
use core::prelude::*;
1616

17+
use core::default::Default;
1718
use core::mem::{zeroed, replace, swap};
1819
use core::ptr;
1920

@@ -37,6 +38,11 @@ impl<T: Ord> Mutable for PriorityQueue<T> {
3738
fn clear(&mut self) { self.data.truncate(0) }
3839
}
3940

41+
impl<T: Ord> Default for PriorityQueue<T> {
42+
#[inline]
43+
fn default() -> PriorityQueue<T> { PriorityQueue::new() }
44+
}
45+
4046
impl<T: Ord> PriorityQueue<T> {
4147
/// An iterator visiting all values in underlying vector, in
4248
/// arbitrary order.

src/libcollections/ringbuf.rs

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use core::prelude::*;
1717

1818
use core::cmp;
19+
use core::default::Default;
1920
use core::fmt;
2021
use core::iter::RandomAccessIterator;
2122

@@ -112,6 +113,11 @@ impl<T> Deque<T> for RingBuf<T> {
112113
}
113114
}
114115

116+
impl<T> Default for RingBuf<T> {
117+
#[inline]
118+
fn default() -> RingBuf<T> { RingBuf::new() }
119+
}
120+
115121
impl<T> RingBuf<T> {
116122
/// Create an empty RingBuf
117123
pub fn new() -> RingBuf<T> {

src/libcollections/smallintmap.rs

+6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
use core::prelude::*;
1919

20+
use core::default::Default;
2021
use core::fmt;
2122
use core::iter::{Enumerate, FilterMap};
2223
use core::mem::replace;
@@ -114,6 +115,11 @@ impl<V> MutableMap<uint, V> for SmallIntMap<V> {
114115
}
115116
}
116117

118+
impl<V> Default for SmallIntMap<V> {
119+
#[inline]
120+
fn default() -> SmallIntMap<V> { SmallIntMap::new() }
121+
}
122+
117123
impl<V> SmallIntMap<V> {
118124
/// Create an empty SmallIntMap
119125
pub fn new() -> SmallIntMap<V> { SmallIntMap{v: vec!()} }

src/libcollections/treemap.rs

+11
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use core::prelude::*;
1616

1717
use alloc::owned::Box;
18+
use core::default::Default;
1819
use core::fmt;
1920
use core::fmt::Show;
2021
use core::iter::Peekable;
@@ -135,6 +136,11 @@ impl<K: Ord, V> MutableMap<K, V> for TreeMap<K, V> {
135136
}
136137
}
137138

139+
impl<K: Ord, V> Default for TreeMap<K,V> {
140+
#[inline]
141+
fn default() -> TreeMap<K, V> { TreeMap::new() }
142+
}
143+
138144
impl<K: Ord, V> TreeMap<K, V> {
139145
/// Create an empty TreeMap
140146
pub fn new() -> TreeMap<K, V> { TreeMap{root: None, length: 0} }
@@ -633,6 +639,11 @@ impl<T: Ord> MutableSet<T> for TreeSet<T> {
633639
fn remove(&mut self, value: &T) -> bool { self.map.remove(value) }
634640
}
635641

642+
impl<T: Ord> Default for TreeSet<T> {
643+
#[inline]
644+
fn default() -> TreeSet<T> { TreeSet::new() }
645+
}
646+
636647
impl<T: Ord> TreeSet<T> {
637648
/// Create an empty TreeSet
638649
#[inline]

src/libcollections/trie.rs

+11
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use core::prelude::*;
1414

1515
use alloc::owned::Box;
16+
use core::default::Default;
1617
use core::mem::zeroed;
1718
use core::mem;
1819
use core::uint;
@@ -105,6 +106,11 @@ impl<T> MutableMap<uint, T> for TrieMap<T> {
105106
}
106107
}
107108

109+
impl<T> Default for TrieMap<T> {
110+
#[inline]
111+
fn default() -> TrieMap<T> { TrieMap::new() }
112+
}
113+
108114
impl<T> TrieMap<T> {
109115
/// Create an empty TrieMap
110116
#[inline]
@@ -332,6 +338,11 @@ impl MutableSet<uint> for TrieSet {
332338
}
333339
}
334340

341+
impl Default for TrieSet {
342+
#[inline]
343+
fn default() -> TrieSet { TrieSet::new() }
344+
}
345+
335346
impl TrieSet {
336347
/// Create an empty TrieSet
337348
#[inline]

src/libnative/io/c_win32.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ extern "system" {
6969
pub mod compat {
7070
use std::intrinsics::{atomic_store_relaxed, transmute};
7171
use libc::types::os::arch::extra::{LPCWSTR, HMODULE, LPCSTR, LPVOID};
72-
use std::os::win32::as_utf16_p;
7372

7473
extern "system" {
7574
fn GetModuleHandleW(lpModuleName: LPCWSTR) -> HMODULE;
@@ -80,12 +79,11 @@ pub mod compat {
8079
// This way, calling a function in this compatibility layer (after it's loaded) shouldn't
8180
// be any slower than a regular DLL call.
8281
unsafe fn store_func<T: Copy>(ptr: *mut T, module: &str, symbol: &str, fallback: T) {
83-
as_utf16_p(module, |module| {
84-
symbol.with_c_str(|symbol| {
85-
let handle = GetModuleHandleW(module);
86-
let func: Option<T> = transmute(GetProcAddress(handle, symbol));
87-
atomic_store_relaxed(ptr, func.unwrap_or(fallback))
88-
})
82+
let module = module.to_utf16().append_one(0);
83+
symbol.with_c_str(|symbol| {
84+
let handle = GetModuleHandleW(module.as_ptr());
85+
let func: Option<T> = transmute(GetProcAddress(handle, symbol));
86+
atomic_store_relaxed(ptr, func.unwrap_or(fallback))
8987
})
9088
}
9189

0 commit comments

Comments
 (0)