diff --git a/mk/tests.mk b/mk/tests.mk index 052d0c18ed4e26e4545bdc1a5d2f22c3c9d06bd8..73aec5de8da321983812a1662fbfa2e0a0bccaa9 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -25,7 +25,8 @@ $(eval $(call RUST_CRATE,collectionstest)) TEST_TARGET_CRATES = $(filter-out core rustc_unicode alloc_system libc \ alloc_jemalloc,$(TARGET_CRATES)) \ collectionstest coretest -TEST_DOC_CRATES = $(DOC_CRATES) +TEST_DOC_CRATES = $(DOC_CRATES) arena flate fmt_macros getopts graphviz \ + log rand rbml serialize syntax term test TEST_HOST_CRATES = $(filter-out rustc_typeck rustc_borrowck rustc_resolve \ rustc_trans rustc_lint,\ $(HOST_CRATES)) diff --git a/src/doc/trpl/documentation.md b/src/doc/trpl/documentation.md index dc91c90b0fd62263494906e61a40866d936ed260..80aed0d1ca7da63aa3924dba3ee1c9cc4c6c4494 100644 --- a/src/doc/trpl/documentation.md +++ b/src/doc/trpl/documentation.md @@ -620,6 +620,18 @@ You can control a few aspects of the HTML that `rustdoc` generates through the This sets a few different options, with a logo, favicon, and a root URL. +### Configuring documentation tests + +You can also configure the way that `rustdoc` tests your documentation examples +through the `#![doc(test(..))]` attribute. + +```rust +#![doc(test(attr(allow(unused_variables), deny(warnings))))] +``` + +This allows unused variables within the examples, but will fail the test for any +other lint warning thrown. + ## Generation options `rustdoc` also contains a few other options on the command line, for further customization: diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 899e7de4ed59f9ac769e75bb69e7550a02e30f93..4113f67e617d17bc4dc1f76c3d6ab292a9e84234 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -70,7 +70,7 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/", 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))))] #![no_std] #![cfg_attr(not(stage0), needs_allocator)] diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index 5bc1c44e1b1fb11281cb64f1ec38a710e57da10c..2234d3608f3f38b4c722dc02f565c87fc0879d38 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -28,7 +28,8 @@ #![crate_type = "dylib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] + html_root_url = "https://doc.rust-lang.org/nightly/", + test(no_crate_inject, attr(deny(warnings))))] #![feature(alloc)] #![feature(box_syntax)] diff --git a/src/libcollections/binary_heap.rs b/src/libcollections/binary_heap.rs index 30fc22e400a81a65273278b7d8e41e875739eda3..72547a9a5d2ee7703bd13839d63966971a292e05 100644 --- a/src/libcollections/binary_heap.rs +++ b/src/libcollections/binary_heap.rs @@ -233,6 +233,7 @@ pub fn with_capacity(capacity: usize) -> 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 bd1864b28cdd3e24e22621733a2a5d3a2e909d0d..9b8f8c8f5bb8466a8b4bc4c999fb2384ff8d62ee 100644 --- a/src/libcollections/borrow.rs +++ b/src/libcollections/borrow.rs @@ -72,6 +72,7 @@ fn to_owned(&self) -> T { self.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 121668fbb9d9d8026853f495c66cd13360b75956..0c70a1544ef92f21ea1558519a48b46db5a5bbea 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 a31ad6c1093628c1b42b21d13a8cdfdce57bbc81..990575ebbb3361c15ce45f8c1d312f8957e804ba 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 670c32776df7b8679693129dc90cc7735bb8ffed..54b98c6e17992f8490d49fc04a6505b44335332c 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 e6391f5c988a4bc9649ceceae9fe84e9e902b53b..85aefbfffb1ad04dfd9c60d6539ce9b12a4e6337 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 104fbe699e09e94599428df367e7513ed994b265..a5013f4e75b18d8f3b14fb71d7d60c2fab46191e 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -298,7 +298,7 @@ pub unsafe fn slice_mut_unchecked(&mut self, begin: usize, end: usize) -> &mut s /// done by `.chars()` or `.char_indices()`. /// /// ``` - /// #![feature(str_char, core)] + /// #![feature(str_char)] /// /// use std::str::CharRange; /// @@ -358,7 +358,7 @@ pub fn char_range_at(&self, start: usize) -> CharRange { /// done by `.chars().rev()` or `.char_indices()`. /// /// ``` - /// #![feature(str_char, core)] + /// #![feature(str_char)] /// /// use std::str::CharRange; /// @@ -634,6 +634,7 @@ pub fn lines(&self) -> Lines { /// # 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 @@ pub fn lines(&self) -> Lines { /// 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 @@ pub fn rmatches<'a, P: Pattern<'a>>(&'a self, pat: P) -> RMatches<'a, P> /// # 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 @@ pub fn match_indices<'a, P: Pattern<'a>>(&'a self, pat: P) -> MatchIndices<'a, P /// # 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 4255665681c8a1491823af3ebc69ff8550a1db7c..804e798c600a5808b742d341bcce9f49c5696412 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 @@ pub fn new() -> 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 c4e4059429f38b0885c1786662c2d274ce9dd2cf..9153d624268ed6d36d2c48f4701d779538a271ec 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] diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 9fcc2b3412aad444823f39d30f0459d2d2f7930e..59b05c21d80050b6902f7cb2d768241683cc8122 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -76,6 +76,7 @@ //! a trait method that was originally defined to take `&self`. //! //! ``` +//! # #![allow(dead_code)] //! use std::cell::RefCell; //! //! struct Graph { @@ -125,6 +126,7 @@ //! } //! //! struct RcBox { +//! # #[allow(dead_code)] //! value: T, //! refcount: Cell //! } @@ -776,6 +778,7 @@ fn deref_mut(&mut self) -> &mut T { /// use std::cell::UnsafeCell; /// use std::marker::Sync; /// +/// # #[allow(dead_code)] /// struct NotThreadSafe { /// value: UnsafeCell, /// } diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 302c9d0c3697440ac17bd863244df27dd477972e..5458a7b9c38b01b24ba479a71c29f617e965c924 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -140,8 +140,6 @@ unsafe fn from_i8_unchecked(v: i8) -> Ordering { /// This method can be used to reverse a comparison: /// /// ``` - /// use std::cmp::Ordering; - /// /// let mut data: &mut [_] = &mut [2, 10, 5, 8]; /// /// // sort the array from largest to smallest. @@ -263,8 +261,6 @@ pub trait PartialOrd: PartialEq { /// # Examples /// /// ``` - /// use std::cmp::Ordering; - /// /// let result = 1.0 < 2.0; /// assert_eq!(result, true); /// diff --git a/src/libcore/default.rs b/src/libcore/default.rs index cbad72eae3d7d378ff1bd32bd6efdab209d28098..12c4a5ca200ad3b1c7271cc6baff8878764800b0 100644 --- a/src/libcore/default.rs +++ b/src/libcore/default.rs @@ -15,6 +15,7 @@ //! that define a set of options: //! //! ``` +//! # #[allow(dead_code)] //! struct SomeOptions { //! foo: i32, //! bar: f32, @@ -24,6 +25,7 @@ //! How can we define some default values? You can use `Default`: //! //! ``` +//! # #[allow(dead_code)] //! #[derive(Default)] //! struct SomeOptions { //! foo: i32, @@ -40,6 +42,7 @@ //! If you have your own type, you need to implement `Default` yourself: //! //! ``` +//! # #![allow(dead_code)] //! enum Kind { //! A, //! B, @@ -66,6 +69,7 @@ //! If you want to override a particular option, but still retain the other defaults: //! //! ``` +//! # #[allow(dead_code)] //! # #[derive(Default)] //! # struct SomeOptions { //! # foo: i32, @@ -88,6 +92,7 @@ /// # Examples /// /// ``` +/// # #[allow(dead_code)] /// #[derive(Default)] /// struct SomeOptions { /// foo: i32, @@ -114,6 +119,7 @@ pub trait Default: Sized { /// Making your own: /// /// ``` + /// # #[allow(dead_code)] /// enum Kind { /// A, /// B, diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs index 4e038f455e1bea1bc5b17d851fbfea1f7bfdaaa1..0899dc28848195b844aab0e736f7442bbd84324a 100644 --- a/src/libcore/hash/mod.rs +++ b/src/libcore/hash/mod.rs @@ -45,6 +45,7 @@ //! //! struct Person { //! id: u32, +//! # #[allow(dead_code)] //! name: String, //! phone: u64, //! } diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index ea4792bb495f6564d67db74fa8d5638730f7d94b..a094bcd0192d24664ae01e7b40e7fef6afcc045d 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -334,6 +334,7 @@ /// use std::mem; /// use std::ptr; /// + /// # #[allow(dead_code)] /// fn swap(x: &mut T, y: &mut T) { /// unsafe { /// // Give ourselves some scratch space to work with @@ -372,6 +373,7 @@ /// ``` /// use std::ptr; /// + /// # #[allow(dead_code)] /// unsafe fn from_buf_raw(ptr: *const T, elts: usize) -> Vec { /// let mut dst = Vec::with_capacity(elts); /// dst.set_len(elts); diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index f8c6e3cfdd7dd73ae024ce2f0e64ee6740454ff8..8558927e4acae35e9eb2108f3a67eda51f21ce02 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -241,6 +241,7 @@ //! method calls a closure on each element it iterates over: //! //! ``` +//! # #![allow(unused_must_use)] //! let v = vec![1, 2, 3, 4, 5]; //! v.iter().map(|x| println!("{}", x)); //! ``` @@ -419,7 +420,7 @@ pub trait Iterator { /// /// ``` /// // an infinite iterator has no upper bound - /// let iter = (0..); + /// let iter = 0..; /// /// assert_eq!((0, None), iter.size_hint()); /// ``` @@ -709,6 +710,7 @@ fn zip(self, other: U) -> Zip where /// If you're doing some sort of side effect, prefer [`for`] to `map()`: /// /// ``` + /// # #![allow(unused_must_use)] /// // don't do this: /// (0..5).map(|x| println!("{}", x)); /// @@ -2695,7 +2697,7 @@ fn next_back(&mut self) -> Option { (**self).next_back() } /// /// ``` /// // a finite range knows exactly how many times it will iterate -/// let five = (0..5); +/// let five = 0..5; /// /// assert_eq!(5, five.len()); /// ``` @@ -2761,7 +2763,7 @@ pub trait ExactSizeIterator: Iterator { /// /// ``` /// // a finite range knows exactly how many times it will iterate - /// let five = (0..5); + /// let five = 0..5; /// /// assert_eq!(5, five.len()); /// ``` diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 94408072932ea5d6a5ad1690602d1331b8eaaba9..df7b7c437c3cc44ca3e8fd56c008aa43bed5b94b 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -60,7 +60,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/")] -#![doc(test(no_crate_inject))] +#![doc(test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))] #![no_core] #![allow(raw_pointer_derive)] diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index a4a2552025bf760f5da11875c9328bcc4ab29b0f..bc8656b32b8e4e336b29bc4b2d022689cebec347 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -247,6 +247,7 @@ /// Match arms: /// /// ``` +/// # #[allow(dead_code)] /// fn foo(x: Option) { /// match x { /// Some(n) if n >= 0 => println!("Some(Non-negative)"), @@ -260,6 +261,7 @@ /// Iterators: /// /// ``` +/// # #[allow(dead_code)] /// fn divide_by_three(x: u32) -> u32 { // one of the poorest implementations of x/3 /// for i in 0.. { /// if 3*i < i { panic!("u32 overflow"); } diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index 2f2dcc41a1c5e97f4cff1931748033efd782a42a..6e6ae6185278711079a75a1d4b0a87e81cc3e933 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -42,6 +42,7 @@ impl !Send for *mut T { } /// `?Sized` can be used to remove this bound if it is not appropriate. /// /// ``` +/// # #![allow(dead_code)] /// struct Foo(T); /// struct Bar(T); /// @@ -106,6 +107,7 @@ pub trait Unsize { /// `struct` can be `Copy`: /// /// ``` +/// # #[allow(dead_code)] /// struct Point { /// x: i32, /// y: i32, @@ -115,6 +117,7 @@ pub trait Unsize { /// A `struct` can be `Copy`, and `i32` is `Copy`, so therefore, `Point` is eligible to be `Copy`. /// /// ``` +/// # #![allow(dead_code)] /// # struct Point; /// struct PointList { /// points: Vec, @@ -303,6 +306,7 @@ fn default() -> $t { /// ``` /// use std::marker::PhantomData; /// +/// # #[allow(dead_code)] /// struct Slice<'a, T:'a> { /// start: *const T, /// end: *const T, @@ -323,6 +327,7 @@ fn default() -> $t { /// mismatches by enforcing types in the method implementations: /// /// ``` +/// # #![allow(dead_code)] /// # trait ResType { fn foo(&self); } /// # struct ParamType; /// # mod foreign_lib { @@ -393,6 +398,8 @@ unsafe impl<'a, T: Send + ?Sized> Send for &'a mut T {} /// #![feature(reflect_marker)] /// use std::marker::Reflect; /// use std::any::Any; +/// +/// # #[allow(dead_code)] /// fn foo(x: &T) { /// let any: &Any = x; /// if any.is::() { println!("u32"); } diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index a87d135e42592551f518118a93969ca1ad6e436a..2f01ea383400a1d83ff6b4beabf4cfaa34dad754 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -92,6 +92,7 @@ /// use std::mem; /// use std::ptr; /// +/// # #[allow(dead_code)] /// fn swap(x: &mut T, y: &mut T) { /// unsafe { /// // Give ourselves some scratch space to work with @@ -151,6 +152,7 @@ pub fn size_of_val(val: &T) -> usize { /// # Examples /// /// ``` +/// # #![allow(deprecated)] /// use std::mem; /// /// assert_eq!(4, mem::min_align_of::()); @@ -167,6 +169,7 @@ pub fn min_align_of() -> usize { /// # Examples /// /// ``` +/// # #![allow(deprecated)] /// use std::mem; /// /// assert_eq!(4, mem::min_align_of_val(&5i32)); @@ -414,6 +417,7 @@ pub fn swap(x: &mut T, y: &mut T) { /// `self`, allowing it to be returned: /// /// ``` +/// # #![allow(dead_code)] /// use std::mem; /// # struct Buffer { buf: Vec } /// impl Buffer { diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index 1bfdafa7133927211b6016f455d6a3d7d8896e34..7ad49eef8f711aa09ec78545863556c6f974dcf9 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -947,6 +947,7 @@ fn shr(self, other: $f) -> $t { /// } /// } /// +/// # #[allow(unused_assignments)] /// fn main() { /// let mut foo = Foo; /// foo += Foo; @@ -996,6 +997,7 @@ fn add_assign(&mut self, other: $t) { *self += other } /// } /// } /// +/// # #[allow(unused_assignments)] /// fn main() { /// let mut foo = Foo; /// foo -= Foo; @@ -1045,6 +1047,7 @@ fn sub_assign(&mut self, other: $t) { *self -= other } /// } /// } /// +/// # #[allow(unused_assignments)] /// fn main() { /// let mut foo = Foo; /// foo *= Foo; @@ -1094,6 +1097,7 @@ fn mul_assign(&mut self, other: $t) { *self *= other } /// } /// } /// +/// # #[allow(unused_assignments)] /// fn main() { /// let mut foo = Foo; /// foo /= Foo; @@ -1143,6 +1147,7 @@ fn div_assign(&mut self, other: $t) { *self /= other } /// } /// } /// +/// # #[allow(unused_assignments)] /// fn main() { /// let mut foo = Foo; /// foo %= Foo; @@ -1192,6 +1197,7 @@ fn rem_assign(&mut self, other: $t) { *self %= other } /// } /// } /// +/// # #[allow(unused_assignments)] /// fn main() { /// let mut foo = Foo; /// foo &= Foo; @@ -1241,6 +1247,7 @@ fn bitand_assign(&mut self, other: $t) { *self &= other } /// } /// } /// +/// # #[allow(unused_assignments)] /// fn main() { /// let mut foo = Foo; /// foo |= Foo; @@ -1290,6 +1297,7 @@ fn bitor_assign(&mut self, other: $t) { *self |= other } /// } /// } /// +/// # #[allow(unused_assignments)] /// fn main() { /// let mut foo = Foo; /// foo ^= Foo; @@ -1339,6 +1347,7 @@ fn bitxor_assign(&mut self, other: $t) { *self ^= other } /// } /// } /// +/// # #[allow(unused_assignments)] /// fn main() { /// let mut foo = Foo; /// foo <<= Foo; @@ -1407,6 +1416,7 @@ fn shl_assign(&mut self, other: $f) { /// } /// } /// +/// # #[allow(unused_assignments)] /// fn main() { /// let mut foo = Foo; /// foo >>= Foo; diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 26e00867d84d54b430277bb808abacb5b09b6edb..7a3b83f68d0d881535784fc02f5734b208ed441a 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -275,6 +275,7 @@ pub fn as_mut(&mut self) -> Option<&mut T> { /// /// ``` /// #![feature(as_slice)] + /// # #![allow(deprecated)] /// /// let mut x = Some("Diamonds"); /// { diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 71219155cc39fffb14b24bdc3864b8bbeffb993e..6e1f120a1db4826affa0dabbf9ac023c1d2afe5f 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -16,6 +16,7 @@ //! and containing an error value. //! //! ``` +//! # #[allow(dead_code)] //! enum Result { //! Ok(T), //! Err(E) @@ -104,6 +105,7 @@ //! something like this: //! //! ```no_run +//! # #![allow(unused_must_use)] // \o/ //! use std::fs::File; //! use std::io::prelude::*; //! @@ -143,6 +145,7 @@ //! # use std::fs::File; //! # use std::io::prelude::*; //! # use std::io; +//! # #[allow(dead_code)] //! fn write_message() -> io::Result<()> { //! let mut file = try!(File::create("valuable_data.txt")); //! try!(file.write_all(b"important message")); @@ -160,6 +163,7 @@ //! It replaces this: //! //! ``` +//! # #![allow(dead_code)] //! use std::fs::File; //! use std::io::prelude::*; //! use std::io; @@ -189,6 +193,7 @@ //! With this: //! //! ``` +//! # #![allow(dead_code)] //! use std::fs::File; //! use std::io::prelude::*; //! use std::io; @@ -422,6 +427,7 @@ pub fn as_slice(&self) -> &[T] { /// /// ``` /// #![feature(as_slice)] + /// # #![allow(deprecated)] /// /// let mut x: Result<&str, u32> = Ok("Gold"); /// { diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 18334ba91c61d2bdb028bce15895526ab94c14a4..7954bc3a0bf53e50046a4ad63f68eee94a757585 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -142,8 +142,6 @@ impl Utf8Error { /// Basic usage: /// /// ``` - /// #![feature(utf8_error)] - /// /// use std::str; /// /// // some invalid bytes, in a vector diff --git a/src/libflate/lib.rs b/src/libflate/lib.rs index 51f387523294f43832cd263e485e6ae017d26ec3..513379b6558441003ae778625bb9c126f7246ea3 100644 --- a/src/libflate/lib.rs +++ b/src/libflate/lib.rs @@ -23,7 +23,8 @@ #![crate_type = "dylib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] + html_root_url = "https://doc.rust-lang.org/nightly/", + test(attr(deny(warnings))))] #![feature(libc)] #![feature(staged_api)] diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index ed767ab1e5cf97e3116deb0d01ad71b37cc04682..dc69f38e4e7d0870f1259e1bb943ab189343ec41 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -24,7 +24,8 @@ #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/", - html_playground_url = "https://play.rust-lang.org/")] + html_playground_url = "https://play.rust-lang.org/", + test(attr(deny(warnings))))] #![feature(staged_api)] #![feature(unicode)] diff --git a/src/libgetopts/lib.rs b/src/libgetopts/lib.rs index ab34f2e48ca4abcd813fe5826399d9bf06890e56..f49451f827d62306b1e95a163ddbafef9d1745fa 100644 --- a/src/libgetopts/lib.rs +++ b/src/libgetopts/lib.rs @@ -30,9 +30,11 @@ //! file name following `-o`, and accepts both `-h` and `--help` as optional flags. //! //! ```{.rust} +//! #![feature(rustc_private)] +//! //! extern crate getopts; //! use getopts::{optopt,optflag,getopts,OptGroup,usage}; -//! use std::os; +//! use std::env; //! //! fn do_work(inp: &str, out: Option) { //! println!("{}", inp); @@ -44,11 +46,11 @@ //! //! fn print_usage(program: &str, opts: &[OptGroup]) { //! let brief = format!("Usage: {} [options]", program); -//! print!("{}", usage(brief, opts)); +//! print!("{}", usage(&brief, opts)); //! } //! //! fn main() { -//! let args: Vec = os::args(); +//! let args: Vec = env::args().collect(); //! //! let program = args[0].clone(); //! @@ -56,22 +58,22 @@ //! optopt("o", "", "set output file name", "NAME"), //! optflag("h", "help", "print this help menu") //! ]; -//! let matches = match getopts(args[1..], opts) { +//! let matches = match getopts(&args[1..], opts) { //! Ok(m) => { m } //! Err(f) => { panic!(f.to_string()) } //! }; //! if matches.opt_present("h") { -//! print_usage(program, opts); +//! print_usage(&program, opts); //! return; //! } //! let output = matches.opt_str("o"); //! let input = if !matches.free.is_empty() { //! matches.free[0].clone() //! } else { -//! print_usage(program, opts); +//! print_usage(&program, opts); //! return; //! }; -//! do_work(input, output); +//! do_work(&input, output); //! } //! ``` @@ -88,7 +90,8 @@ #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/", - html_playground_url = "https://play.rust-lang.org/")] + html_playground_url = "https://play.rust-lang.org/", + test(attr(deny(warnings))))] #![deny(missing_docs)] #![feature(staged_api)] diff --git a/src/libgraphviz/lib.rs b/src/libgraphviz/lib.rs index b82b7d122b3ce8205c760602202243faed391eeb..1fb54ed9071ab6b6939d79381b93889945d5cd58 100644 --- a/src/libgraphviz/lib.rs +++ b/src/libgraphviz/lib.rs @@ -47,7 +47,7 @@ //! which is cyclic. //! //! ```rust -//! #![feature(rustc_private, core, into_cow)] +//! #![feature(rustc_private, into_cow)] //! //! use std::borrow::IntoCow; //! use std::io::Write; @@ -150,9 +150,8 @@ //! entity `&sube`). //! //! ```rust -//! #![feature(rustc_private, core, into_cow)] +//! #![feature(rustc_private)] //! -//! use std::borrow::IntoCow; //! use std::io::Write; //! use graphviz as dot; //! @@ -174,10 +173,10 @@ //! dot::Id::new(format!("N{}", n)).unwrap() //! } //! fn node_label<'b>(&'b self, n: &Nd) -> dot::LabelText<'b> { -//! dot::LabelText::LabelStr(self.nodes[*n].as_slice().into_cow()) +//! dot::LabelText::LabelStr(self.nodes[*n].into()) //! } //! fn edge_label<'b>(&'b self, _: &Ed) -> dot::LabelText<'b> { -//! dot::LabelText::LabelStr("⊆".into_cow()) +//! dot::LabelText::LabelStr("⊆".into()) //! } //! } //! @@ -209,9 +208,8 @@ //! Hasse-diagram for the subsets of the set `{x, y}`. //! //! ```rust -//! #![feature(rustc_private, core, into_cow)] +//! #![feature(rustc_private)] //! -//! use std::borrow::IntoCow; //! use std::io::Write; //! use graphviz as dot; //! @@ -234,10 +232,10 @@ //! } //! fn node_label<'b>(&'b self, n: &Nd<'b>) -> dot::LabelText<'b> { //! let &(i, _) = n; -//! dot::LabelText::LabelStr(self.nodes[i].into_cow()) +//! dot::LabelText::LabelStr(self.nodes[i].into()) //! } //! fn edge_label<'b>(&'b self, _: &Ed<'b>) -> dot::LabelText<'b> { -//! dot::LabelText::LabelStr("⊆".into_cow()) +//! dot::LabelText::LabelStr("⊆".into()) //! } //! } //! @@ -283,7 +281,8 @@ #![crate_type = "dylib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] + html_root_url = "https://doc.rust-lang.org/nightly/", + test(attr(allow(unused_variables), deny(warnings))))] #![feature(into_cow)] #![feature(str_escape)] diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index 9cb835bd8525d583c99eab127bd178f5048ad2cb..1de7ebfffdea28af1ed89028823eadc9d2170a5b 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -13,6 +13,7 @@ //! # Examples //! //! ``` +//! # #![feature(rustc_private)] //! #[macro_use] extern crate log; //! //! fn main() { @@ -167,7 +168,8 @@ #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/", - html_playground_url = "https://play.rust-lang.org/")] + html_playground_url = "https://play.rust-lang.org/", + test(attr(deny(warnings))))] #![deny(missing_docs)] #![feature(box_syntax)] diff --git a/src/liblog/macros.rs b/src/liblog/macros.rs index 46b51f50c85831d2136363ef28e2279252809b7c..803a2df9ccc8baff67d46d6a3b15db71c8d49602 100644 --- a/src/liblog/macros.rs +++ b/src/liblog/macros.rs @@ -19,6 +19,7 @@ /// # Examples /// /// ``` +/// # #![feature(rustc_private)] /// #[macro_use] extern crate log; /// /// fn main() { @@ -67,6 +68,7 @@ /// # Examples /// /// ``` +/// # #![feature(rustc_private)] /// #[macro_use] extern crate log; /// /// fn main() { @@ -92,6 +94,7 @@ /// # Examples /// /// ``` +/// # #![feature(rustc_private)] /// #[macro_use] extern crate log; /// /// fn main() { @@ -116,6 +119,7 @@ /// # Examples /// /// ``` +/// # #![feature(rustc_private)] /// #[macro_use] extern crate log; /// /// fn main() { @@ -142,6 +146,7 @@ /// # Examples /// /// ``` +/// # #![feature(rustc_private)] /// #[macro_use] extern crate log; /// /// fn main() { @@ -165,9 +170,10 @@ /// # Examples /// /// ``` +/// # #![feature(rustc_private)] /// #[macro_use] extern crate log; /// -/// struct Point { x: int, y: int } +/// struct Point { x: i32, y: i32 } /// fn some_expensive_computation() -> Point { Point { x: 1, y: 2 } } /// /// fn main() { diff --git a/src/librand/lib.rs b/src/librand/lib.rs index b5a1eb9520cec6eb1983925f9ac4c40b6b3674cb..cf2118b45a471220df369249b1d7b4299cecee27 100644 --- a/src/librand/lib.rs +++ b/src/librand/lib.rs @@ -23,7 +23,8 @@ #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/", - html_playground_url = "https://play.rust-lang.org/")] + html_playground_url = "https://play.rust-lang.org/", + test(attr(deny(warnings))))] #![no_std] #![staged_api] #![unstable(feature = "rand", diff --git a/src/librbml/lib.rs b/src/librbml/lib.rs index 1c6cb06d54ae4218530c3b3e22df155c442c83a6..a1b15cd9e6f11ebd28cbb9b43c4d1c9d8a9db439 100644 --- a/src/librbml/lib.rs +++ b/src/librbml/lib.rs @@ -121,7 +121,8 @@ #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/", - html_playground_url = "https://play.rust-lang.org/")] + html_playground_url = "https://play.rust-lang.org/", + test(attr(deny(warnings))))] #![feature(rustc_private)] #![feature(staged_api)] diff --git a/src/librustc_unicode/lib.rs b/src/librustc_unicode/lib.rs index 467c974690062e70ab934a4efd771a916f8f7653..79ce8aacae815a6515e98617fe3959ee5f8bc96c 100644 --- a/src/librustc_unicode/lib.rs +++ b/src/librustc_unicode/lib.rs @@ -31,7 +31,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))))] #![no_std] #![feature(core_char_ext)] diff --git a/src/librustc_unicode/u_str.rs b/src/librustc_unicode/u_str.rs index 2347cdebf2292e60ed550ccc33614c5dced79fb8..57d96bf43719e7fe442e0a94ea6c0c30254e2ecb 100644 --- a/src/librustc_unicode/u_str.rs +++ b/src/librustc_unicode/u_str.rs @@ -190,6 +190,7 @@ fn size_hint(&self) -> (usize, Option) { /// /// ``` /// #![feature(unicode, decode_utf16)] +/// # #![allow(deprecated)] /// /// extern crate rustc_unicode; /// diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index 452feed3cdb4effa751e10616edabbd5867e9e98..9e1e3c6a558055436dc2fa38cc25b8bc3c8cf84c 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -77,8 +77,9 @@ //! serialization API, using the derived serialization code. //! //! ```rust -//! extern crate serialize; -//! use serialize::json; +//! # #![feature(rustc_private)] +//! extern crate serialize as rustc_serialize; // for the deriving below +//! use rustc_serialize::json; //! //! // Automatically generate `Decodable` and `Encodable` trait implementations //! #[derive(RustcDecodable, RustcEncodable)] @@ -111,6 +112,7 @@ //! ### Simple example of `ToJson` usage //! //! ```rust +//! # #![feature(rustc_private)] //! extern crate serialize; //! use serialize::json::{self, ToJson, Json}; //! @@ -150,6 +152,7 @@ //! ### Verbose example of `ToJson` usage //! //! ```rust +//! # #![feature(rustc_private)] //! extern crate serialize; //! use std::collections::BTreeMap; //! use serialize::json::{self, Json, ToJson}; @@ -185,7 +188,7 @@ //! let json_str: String = json_obj.to_string(); //! //! // Deserialize like before -//! let decoded: TestStruct = json::decode(json_str)).unwrap(); +//! let decoded: TestStruct = json::decode(&json_str).unwrap(); //! } //! ``` diff --git a/src/libserialize/lib.rs b/src/libserialize/lib.rs index 5b7bec41723cde69df2dc823c2030899dae9ee8a..4a766f14531374865b8aa505f9b772ace3bebcec 100644 --- a/src/libserialize/lib.rs +++ b/src/libserialize/lib.rs @@ -26,7 +26,8 @@ #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/", - html_playground_url = "https://play.rust-lang.org/")] + html_playground_url = "https://play.rust-lang.org/", + test(attr(allow(unused_variables), deny(warnings))))] #![feature(box_syntax)] #![feature(collections)] diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 8c9c883508703089eb2bf3c96beba6dc9113c15f..1f34af617d588e409501a8b85cb7012c00f82c4a 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -908,13 +908,15 @@ pub enum Expr_ { /// separately. `position` represents the index of the associated /// item qualified with this Self type. /// -/// as a::b::Trait>::AssociatedItem -/// ^~~~~ ~~~~~~~~~~~~~~^ -/// ty position = 3 +/// ```ignore +/// as a::b::Trait>::AssociatedItem +/// ^~~~~ ~~~~~~~~~~~~~~^ +/// ty position = 3 /// -/// >::AssociatedItem -/// ^~~~~ ^ -/// ty position = 0 +/// >::AssociatedItem +/// ^~~~~ ^ +/// ty position = 0 +/// ``` #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct QSelf { pub ty: P, diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs index 5c6e2fce8adcea845f8ddb607608648c9b622476..5a0fc4fda0ccac065a80812dc6b820125e4abb3d 100644 --- a/src/libsyntax/ext/deriving/generic/mod.rs +++ b/src/libsyntax/ext/deriving/generic/mod.rs @@ -54,6 +54,7 @@ //! following snippet //! //! ```rust +//! # #![allow(dead_code)] //! struct A { x : i32 } //! //! struct B(i32); @@ -88,7 +89,7 @@ //! //! ```rust //! trait PartialEq { -//! fn eq(&self, other: &Self); +//! fn eq(&self, other: &Self) -> bool; //! } //! impl PartialEq for i32 { //! fn eq(&self, other: &i32) -> bool { @@ -905,7 +906,7 @@ fn create_method(&self, }) } - /// ``` + /// ```ignore /// #[derive(PartialEq)] /// struct A { x: i32, y: i32 } /// @@ -1010,7 +1011,7 @@ fn expand_static_struct_method_body(&self, &StaticStruct(struct_def, summary)) } - /// ``` + /// ```ignore /// #[derive(PartialEq)] /// enum A { /// A1, @@ -1596,7 +1597,7 @@ pub fn cs_fold(use_foldl: bool, /// Call the method that is being derived on all the fields, and then /// process the collected results. i.e. /// -/// ``` +/// ```ignore /// f(cx, span, vec![self_1.method(__arg_1_1, __arg_2_1), /// self_2.method(__arg_1_2, __arg_2_2)]) /// ``` diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index c56342371c84ed9a72dc305763626be38e3baea1..af0e7ce5c8d368a2030de2ac301d52ed1ccb2064 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -77,9 +77,10 @@ struct Context<'a, 'b:'a> { /// expressions. /// /// If parsing succeeds, the return value is: -/// -/// Some((fmtstr, unnamed arguments, ordering of named arguments, -/// named arguments)) +/// ```ignore +/// Some((fmtstr, unnamed arguments, ordering of named arguments, +/// named arguments)) +/// ``` fn parse_args(ecx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> Option<(P, Vec>, Vec, HashMap>)> { diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 524ac655d884467ea775d4178ac182a4968397f6..0cd27d1b0ccc38f037cb956450484fee7101e6bc 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -23,7 +23,8 @@ #![crate_type = "rlib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] + html_root_url = "https://doc.rust-lang.org/nightly/", + test(attr(deny(warnings))))] #![feature(associated_consts)] #![feature(drain)] diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index fde1058a785c0466147941e0a91eaba39729a675..1e38eebec5d635f86e7cd3d35dae16f2765e2129 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3965,7 +3965,7 @@ fn forbid_lifetime(&mut self) -> PResult<()> { /// Parses an optional `where` clause and places it in `generics`. /// - /// ``` + /// ```ignore /// where T : Trait + 'b, 'a : 'b /// ``` pub fn parse_where_clause(&mut self) -> PResult { diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index 7c5a46465f513163e2954a2d75b6059835a61a14..cbbd5289a5a2d5415a846ebfa050725f96aeac85 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -11,8 +11,10 @@ //! This pretty-printer is a direct reimplementation of Philip Karlton's //! Mesa pretty-printer, as described in appendix A of //! -//! STAN-CS-79-770: "Pretty Printing", by Derek C. Oppen. -//! Stanford Department of Computer Science, 1979. +//! ````ignore +//! STAN-CS-79-770: "Pretty Printing", by Derek C. Oppen. +//! Stanford Department of Computer Science, 1979. +//! ```` //! //! The algorithm's aim is to break a stream into as few lines as possible //! while respecting the indentation-consistency requirements of the enclosing diff --git a/src/libterm/lib.rs b/src/libterm/lib.rs index ced3a7d47d7b674a84d38babf317d6ed74e09edd..99bbd951766c68183712ad0570bf4203096df441 100644 --- a/src/libterm/lib.rs +++ b/src/libterm/lib.rs @@ -53,7 +53,8 @@ #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/", - html_playground_url = "https://play.rust-lang.org/")] + html_playground_url = "https://play.rust-lang.org/", + test(attr(deny(warnings))))] #![deny(missing_docs)] #![feature(box_syntax)] diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 69b1d37bfc4ee9613b0da3a49f4a0c878b2ad6f0..89442fe1096fe6228e974a2655fb997a20d58383 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -32,7 +32,8 @@ #![crate_type = "dylib"] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] + html_root_url = "https://doc.rust-lang.org/nightly/", + test(attr(deny(warnings))))] #![feature(asm)] #![feature(box_syntax)]