Skip to content

Commit bbf964a

Browse files
committed
libcollections: deny warnings in doctests
1 parent 89a8203 commit bbf964a

File tree

9 files changed

+27
-8
lines changed

9 files changed

+27
-8
lines changed

src/libcollections/binary_heap.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ impl<T: Ord> BinaryHeap<T> {
233233
///
234234
/// ```
235235
/// #![feature(binary_heap_extras)]
236+
/// # #![allow(deprecated)]
236237
///
237238
/// use std::collections::BinaryHeap;
238239
/// let heap = BinaryHeap::from_vec(vec![9, 1, 2, 7, 3, 2]);

src/libcollections/borrow.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ impl<T> ToOwned for T where T: Clone {
7272
/// ```
7373
/// use std::borrow::Cow;
7474
///
75+
/// # #[allow(dead_code)]
7576
/// fn abs_all(input: &mut Cow<[i32]>) {
7677
/// for i in 0..input.len() {
7778
/// let v = input[i];

src/libcollections/btree/set.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ impl<T: Ord> BTreeSet<T> {
8989
/// # Examples
9090
///
9191
/// ```
92+
/// # #![allow(unused_mut)]
9293
/// use std::collections::BTreeSet;
9394
///
9495
/// let mut set: BTreeSet<i32> = BTreeSet::new();

src/libcollections/fmt.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@
150150
//! implement a method of the signature:
151151
//!
152152
//! ```
153+
//! # #![allow(dead_code)]
153154
//! # use std::fmt;
154155
//! # struct Foo; // our custom type
155156
//! # impl fmt::Display for Foo {
@@ -174,7 +175,6 @@
174175
//! like:
175176
//!
176177
//! ```
177-
//! #![feature(fmt_flags)]
178178
//! use std::fmt;
179179
//!
180180
//! #[derive(Debug)]
@@ -288,6 +288,7 @@
288288
//! off, some example usage is:
289289
//!
290290
//! ```
291+
//! # #![allow(unused_must_use)]
291292
//! use std::fmt;
292293
//! use std::io::{self, Write};
293294
//!

src/libcollections/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
html_root_url = "https://doc.rust-lang.org/nightly/",
2828
html_playground_url = "https://play.rust-lang.org/",
2929
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
30-
test(no_crate_inject))]
30+
test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))]
3131

3232
#![allow(trivial_casts)]
3333
#![cfg_attr(test, allow(deprecated))] // rand

src/libcollections/slice.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,7 @@ pub trait SliceConcatExt<T: ?Sized> {
852852
/// # Examples
853853
///
854854
/// ```
855+
/// # #![allow(deprecated)]
855856
/// assert_eq!(["hello", "world"].connect(" "), "hello world");
856857
/// ```
857858
#[stable(feature = "rust1", since = "1.0.0")]

src/libcollections/str.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ impl str {
298298
/// done by `.chars()` or `.char_indices()`.
299299
///
300300
/// ```
301-
/// #![feature(str_char, core)]
301+
/// #![feature(str_char)]
302302
///
303303
/// use std::str::CharRange;
304304
///
@@ -358,7 +358,7 @@ impl str {
358358
/// done by `.chars().rev()` or `.char_indices()`.
359359
///
360360
/// ```
361-
/// #![feature(str_char, core)]
361+
/// #![feature(str_char)]
362362
///
363363
/// use std::str::CharRange;
364364
///
@@ -634,6 +634,7 @@ impl str {
634634
/// # Examples
635635
///
636636
/// ```
637+
/// # #![allow(deprecated)]
637638
/// let four_lines = "foo\r\nbar\n\r\nbaz";
638639
/// let v: Vec<&str> = four_lines.lines_any().collect();
639640
///
@@ -643,6 +644,7 @@ impl str {
643644
/// Leaving off the trailing character:
644645
///
645646
/// ```
647+
/// # #![allow(deprecated)]
646648
/// let four_lines = "foo\r\nbar\n\r\nbaz\n";
647649
/// let v: Vec<&str> = four_lines.lines_any().collect();
648650
///
@@ -1179,8 +1181,6 @@ impl str {
11791181
/// # Examples
11801182
///
11811183
/// ```
1182-
/// #![feature(str_match_indices)]
1183-
///
11841184
/// let v: Vec<_> = "abcXXXabcYYYabc".match_indices("abc").collect();
11851185
/// assert_eq!(v, [(0, "abc"), (6, "abc"), (12, "abc")]);
11861186
///
@@ -1216,8 +1216,6 @@ impl str {
12161216
/// # Examples
12171217
///
12181218
/// ```
1219-
/// #![feature(str_match_indices)]
1220-
///
12211219
/// let v: Vec<_> = "abcXXXabcYYYabc".rmatch_indices("abc").collect();
12221220
/// assert_eq!(v, [(12, "abc"), (6, "abc"), (0, "abc")]);
12231221
///

src/libcollections/string.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ impl String {
5555
/// # Examples
5656
///
5757
/// ```
58+
/// # #![allow(unused_mut)]
5859
/// let mut s = String::new();
5960
/// ```
6061
#[inline]
@@ -73,6 +74,20 @@ impl String {
7374
///
7475
/// ```
7576
/// let mut s = String::with_capacity(10);
77+
///
78+
/// // The String contains no chars, even though it has capacity for more
79+
/// assert_eq!(s.len(), 0);
80+
///
81+
/// // These are all done without reallocating...
82+
/// let cap = s.capacity();
83+
/// for i in 0..10 {
84+
/// s.push('a');
85+
/// }
86+
///
87+
/// assert_eq!(s.capacity(), cap);
88+
///
89+
/// // ...but this may make the vector reallocate
90+
/// s.push('a');
7691
/// ```
7792
#[inline]
7893
#[stable(feature = "rust1", since = "1.0.0")]

src/libcollections/vec.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ impl<T> Vec<T> {
242242
/// # Examples
243243
///
244244
/// ```
245+
/// # #![allow(unused_mut)]
245246
/// let mut vec: Vec<i32> = Vec::new();
246247
/// ```
247248
#[inline]

0 commit comments

Comments
 (0)