From bbf964afea55f627eee047988d1cc44c386b23ba Mon Sep 17 00:00:00 2001 From: Kevin Butler Date: Tue, 3 Nov 2015 14:49:33 +0000 Subject: [PATCH] libcollections: deny warnings in doctests --- src/libcollections/binary_heap.rs | 1 + src/libcollections/borrow.rs | 1 + src/libcollections/btree/set.rs | 1 + src/libcollections/fmt.rs | 3 ++- src/libcollections/lib.rs | 2 +- src/libcollections/slice.rs | 1 + src/libcollections/str.rs | 10 ++++------ src/libcollections/string.rs | 15 +++++++++++++++ src/libcollections/vec.rs | 1 + 9 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/libcollections/binary_heap.rs b/src/libcollections/binary_heap.rs index 30fc22e400a81..72547a9a5d2ee 100644 --- a/src/libcollections/binary_heap.rs +++ b/src/libcollections/binary_heap.rs @@ -233,6 +233,7 @@ impl BinaryHeap { /// /// ``` /// #![feature(binary_heap_extras)] + /// # #![allow(deprecated)] /// /// use std::collections::BinaryHeap; /// let heap = BinaryHeap::from_vec(vec![9, 1, 2, 7, 3, 2]); diff --git a/src/libcollections/borrow.rs b/src/libcollections/borrow.rs index bd1864b28cdd3..9b8f8c8f5bb84 100644 --- a/src/libcollections/borrow.rs +++ b/src/libcollections/borrow.rs @@ -72,6 +72,7 @@ impl ToOwned for T where T: Clone { /// ``` /// use std::borrow::Cow; /// +/// # #[allow(dead_code)] /// fn abs_all(input: &mut Cow<[i32]>) { /// for i in 0..input.len() { /// let v = input[i]; diff --git a/src/libcollections/btree/set.rs b/src/libcollections/btree/set.rs index 121668fbb9d9d..0c70a1544ef92 100644 --- a/src/libcollections/btree/set.rs +++ b/src/libcollections/btree/set.rs @@ -89,6 +89,7 @@ impl BTreeSet { /// # Examples /// /// ``` + /// # #![allow(unused_mut)] /// use std::collections::BTreeSet; /// /// let mut set: BTreeSet = BTreeSet::new(); diff --git a/src/libcollections/fmt.rs b/src/libcollections/fmt.rs index a31ad6c109362..990575ebbb336 100644 --- a/src/libcollections/fmt.rs +++ b/src/libcollections/fmt.rs @@ -150,6 +150,7 @@ //! implement a method of the signature: //! //! ``` +//! # #![allow(dead_code)] //! # use std::fmt; //! # struct Foo; // our custom type //! # impl fmt::Display for Foo { @@ -174,7 +175,6 @@ //! like: //! //! ``` -//! #![feature(fmt_flags)] //! use std::fmt; //! //! #[derive(Debug)] @@ -288,6 +288,7 @@ //! off, some example usage is: //! //! ``` +//! # #![allow(unused_must_use)] //! use std::fmt; //! use std::io::{self, Write}; //! diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index 670c32776df7b..54b98c6e17992 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -27,7 +27,7 @@ html_root_url = "https://doc.rust-lang.org/nightly/", html_playground_url = "https://play.rust-lang.org/", issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/", - test(no_crate_inject))] + test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))] #![allow(trivial_casts)] #![cfg_attr(test, allow(deprecated))] // rand diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index e6391f5c988a4..85aefbfffb1ad 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -852,6 +852,7 @@ pub trait SliceConcatExt { /// # Examples /// /// ``` + /// # #![allow(deprecated)] /// assert_eq!(["hello", "world"].connect(" "), "hello world"); /// ``` #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 104fbe699e09e..a5013f4e75b18 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -298,7 +298,7 @@ impl str { /// done by `.chars()` or `.char_indices()`. /// /// ``` - /// #![feature(str_char, core)] + /// #![feature(str_char)] /// /// use std::str::CharRange; /// @@ -358,7 +358,7 @@ impl str { /// done by `.chars().rev()` or `.char_indices()`. /// /// ``` - /// #![feature(str_char, core)] + /// #![feature(str_char)] /// /// use std::str::CharRange; /// @@ -634,6 +634,7 @@ impl str { /// # Examples /// /// ``` + /// # #![allow(deprecated)] /// let four_lines = "foo\r\nbar\n\r\nbaz"; /// let v: Vec<&str> = four_lines.lines_any().collect(); /// @@ -643,6 +644,7 @@ impl str { /// Leaving off the trailing character: /// /// ``` + /// # #![allow(deprecated)] /// let four_lines = "foo\r\nbar\n\r\nbaz\n"; /// let v: Vec<&str> = four_lines.lines_any().collect(); /// @@ -1179,8 +1181,6 @@ impl str { /// # Examples /// /// ``` - /// #![feature(str_match_indices)] - /// /// let v: Vec<_> = "abcXXXabcYYYabc".match_indices("abc").collect(); /// assert_eq!(v, [(0, "abc"), (6, "abc"), (12, "abc")]); /// @@ -1216,8 +1216,6 @@ impl str { /// # Examples /// /// ``` - /// #![feature(str_match_indices)] - /// /// let v: Vec<_> = "abcXXXabcYYYabc".rmatch_indices("abc").collect(); /// assert_eq!(v, [(12, "abc"), (6, "abc"), (0, "abc")]); /// diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 4255665681c8a..804e798c600a5 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -55,6 +55,7 @@ impl String { /// # Examples /// /// ``` + /// # #![allow(unused_mut)] /// let mut s = String::new(); /// ``` #[inline] @@ -73,6 +74,20 @@ impl String { /// /// ``` /// let mut s = String::with_capacity(10); + /// + /// // The String contains no chars, even though it has capacity for more + /// assert_eq!(s.len(), 0); + /// + /// // These are all done without reallocating... + /// let cap = s.capacity(); + /// for i in 0..10 { + /// s.push('a'); + /// } + /// + /// assert_eq!(s.capacity(), cap); + /// + /// // ...but this may make the vector reallocate + /// s.push('a'); /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index c4e4059429f38..9153d624268ed 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -242,6 +242,7 @@ impl Vec { /// # Examples /// /// ``` + /// # #![allow(unused_mut)] /// let mut vec: Vec = Vec::new(); /// ``` #[inline]