diff --git a/configure b/configure index cf349af648835..2c8d78598b2d3 100755 --- a/configure +++ b/configure @@ -1005,11 +1005,9 @@ then (''|*clang) CFG_CLANG_REPORTED_VERSION=$($CFG_CC --version | grep version) - if [[ $CFG_CLANG_REPORTED_VERSION == *"(based on LLVM "* ]] - then + if echo $CFG_CLANG_REPORTED_VERSION | grep -q "(based on LLVM "; then CFG_CLANG_VERSION=$(echo $CFG_CLANG_REPORTED_VERSION | sed 's/.*(based on LLVM \(.*\))/\1/') - elif [[ $CFG_CLANG_REPORTED_VERSION == "Apple LLVM"* ]] - then + elif echo $CFG_CLANG_REPORTED_VERSION | grep -q "Apple LLVM"; then CFG_OSX_CLANG_VERSION=$(echo $CFG_CLANG_REPORTED_VERSION | sed 's/.*version \(.*\) .*/\1/') else CFG_CLANG_VERSION=$(echo $CFG_CLANG_REPORTED_VERSION | sed 's/.*version \(.*\) .*/\1/') diff --git a/src/doc/trpl/choosing-your-guarantees.md b/src/doc/trpl/choosing-your-guarantees.md index 1d3c76ce231b9..a7d9032c3c536 100644 --- a/src/doc/trpl/choosing-your-guarantees.md +++ b/src/doc/trpl/choosing-your-guarantees.md @@ -42,7 +42,7 @@ allowed to share references to this by the regular borrowing rules, checked at c ## `&T` and `&mut T` -These are immutable and mutable references respectively. They follow the &lquo;read-write lock&rquo; +These are immutable and mutable references respectively. They follow the “read-write lock” pattern, such that one may either have only one mutable reference to some data, or any number of immutable ones, but not both. This guarantee is enforced at compile time, and has no visible cost at runtime. In most cases these two pointer types suffice for sharing cheap references between sections @@ -108,7 +108,7 @@ increment the inner reference count and return a copy of the `Rc`. # Cell types -&lquo;Cell&rquo;s provide interior mutability. In other words, they contain data which can be manipulated even +`Cell`s provide interior mutability. In other words, they contain data which can be manipulated even if the type cannot be obtained in a mutable form (for example, when it is behind an `&`-ptr or `Rc`). @@ -127,7 +127,8 @@ If a field is wrapped in `Cell`, it's a nice indicator that the chunk of data is stay the same between the time you first read it and when you intend to use it. ```rust -# use std::cell::Cell; +use std::cell::Cell; + let x = Cell::new(1); let y = &x; let z = &x; @@ -185,7 +186,8 @@ any other borrows active when a mutable borrow is active. If the programmer atte borrow, the thread will panic. ```rust -# use std::cell::RefCell; +use std::cell::RefCell; + let x = RefCell::new(vec![1,2,3,4]); { println!("{:?}", *x.borrow()) diff --git a/src/doc/trpl/crates-and-modules.md b/src/doc/trpl/crates-and-modules.md index 63fdef0760feb..6989099206586 100644 --- a/src/doc/trpl/crates-and-modules.md +++ b/src/doc/trpl/crates-and-modules.md @@ -355,6 +355,10 @@ Hello in English: Hello! Goodbye in English: Goodbye. ``` +`pub` also applies to `struct`s and their member fields. In keeping with Rust’s +tendency toward safety, simply making a `struct` public won't automatically +make its members public: you must mark the fields individually with `pub`. + Now that our functions are public, we can use them. Great! However, typing out `phrases::english::greetings::hello()` is very long and repetitive. Rust has another keyword for importing names into the current scope, so that you can @@ -517,9 +521,6 @@ of `foo` relative to where we are. If that’s prefixed with `::`, as in `::foo::bar()`, it refers to a different `foo`, an absolute path from your crate root. -Also, note that we `pub use`d before we declared our `mod`s. Rust requires that -`use` declarations go first. - This will build and run: ```bash diff --git a/src/doc/trpl/guessing-game.md b/src/doc/trpl/guessing-game.md index 1784c253f7f47..0cd4c60932acf 100644 --- a/src/doc/trpl/guessing-game.md +++ b/src/doc/trpl/guessing-game.md @@ -499,7 +499,7 @@ generator, which is local to the particular [thread][concurrency] of execution we’re in. Because we `use rand::Rng`’d above, it has a `gen_range()` method available. This method takes two arguments, and generates a number between them. It’s inclusive on the lower bound, but exclusive on the upper bound, -so we need `1` and `101` to get a number between one and a hundred. +so we need `1` and `101` to get a number ranging from one to a hundred. [concurrency]: concurrency.html diff --git a/src/doc/trpl/intrinsics.md b/src/doc/trpl/intrinsics.md index e0a8bb59e346a..d1d836fe188ac 100644 --- a/src/doc/trpl/intrinsics.md +++ b/src/doc/trpl/intrinsics.md @@ -11,7 +11,7 @@ perform efficient pointer arithmetic, one would import those functions via a declaration like ```rust -# #![feature(intrinsics)] +#![feature(intrinsics)] # fn main() {} extern "rust-intrinsic" { diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 2a47fd29bd653..05308b3e9d85d 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -200,7 +200,8 @@ impl Arc { /// # Examples /// /// ``` - /// # #![feature(arc_weak)] + /// #![feature(arc_weak)] + /// /// use std::sync::Arc; /// /// let five = Arc::new(5); @@ -337,7 +338,8 @@ impl Arc { /// # Examples /// /// ``` - /// # #![feature(arc_unique)] + /// #![feature(arc_unique)] + /// /// use std::sync::Arc; /// /// let mut five = Arc::new(5); @@ -408,7 +410,8 @@ impl Arc { /// # Examples /// /// ``` - /// # #![feature(arc_unique, alloc)] + /// #![feature(arc_unique, alloc)] + /// /// extern crate alloc; /// # fn main() { /// use alloc::arc::Arc; @@ -555,7 +558,8 @@ impl Weak { /// # Examples /// /// ``` - /// # #![feature(arc_weak)] + /// #![feature(arc_weak)] + /// /// use std::sync::Arc; /// /// let five = Arc::new(5); @@ -599,7 +603,8 @@ impl Clone for Weak { /// # Examples /// /// ``` - /// # #![feature(arc_weak)] + /// #![feature(arc_weak)] + /// /// use std::sync::Arc; /// /// let weak_five = Arc::new(5).downgrade(); @@ -626,7 +631,8 @@ impl Drop for Weak { /// # Examples /// /// ``` - /// # #![feature(arc_weak)] + /// #![feature(arc_weak)] + /// /// use std::sync::Arc; /// /// { diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index db338eaaf00bf..0c2e7eb6bb35c 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -75,7 +75,8 @@ use core::raw::{TraitObject}; /// The following two examples are equivalent: /// /// ``` -/// # #![feature(box_heap)] +/// #![feature(box_heap)] +/// /// #![feature(box_syntax, placement_in_syntax)] /// use std::boxed::HEAP; /// @@ -241,7 +242,8 @@ impl Box { /// /// # Examples /// ``` - /// # #![feature(box_raw)] + /// #![feature(box_raw)] + /// /// let seventeen = Box::new(17u32); /// let raw = Box::into_raw(seventeen); /// let boxed_again = unsafe { Box::from_raw(raw) }; @@ -264,7 +266,8 @@ impl Box { /// /// # Examples /// ``` -/// # #![feature(box_raw)] +/// #![feature(box_raw)] +/// /// use std::boxed; /// /// let seventeen = Box::new(17u32); @@ -307,7 +310,8 @@ impl Clone for Box { /// # Examples /// /// ``` - /// # #![feature(box_raw)] + /// #![feature(box_raw)] + /// /// let x = Box::new(5); /// let mut y = Box::new(10); /// diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index d461eeea0b7eb..b4f993205d16b 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -91,7 +91,8 @@ //! documentation for more details on interior mutability. //! //! ```rust -//! # #![feature(rc_weak)] +//! #![feature(rc_weak)] +//! //! use std::rc::Rc; //! use std::rc::Weak; //! use std::cell::RefCell; @@ -227,7 +228,8 @@ impl Rc { /// # Examples /// /// ``` - /// # #![feature(rc_unique)] + /// #![feature(rc_unique)] + /// /// use std::rc::Rc; /// /// let x = Rc::new(3); @@ -262,7 +264,8 @@ impl Rc { /// # Examples /// /// ``` - /// # #![feature(rc_weak)] + /// #![feature(rc_weak)] + /// /// use std::rc::Rc; /// /// let five = Rc::new(5); @@ -292,7 +295,8 @@ impl Rc { /// # Examples /// /// ``` - /// # #![feature(rc_unique)] + /// #![feature(rc_unique)] + /// /// use std::rc::Rc; /// /// let five = Rc::new(5); @@ -313,7 +317,8 @@ impl Rc { /// # Examples /// /// ``` - /// # #![feature(rc_unique)] + /// #![feature(rc_unique)] + /// /// use std::rc::Rc; /// /// let mut x = Rc::new(3); @@ -353,7 +358,8 @@ pub fn strong_count(this: &Rc) -> usize { Rc::strong_count(this) } /// # Examples /// /// ``` -/// # #![feature(rc_unique)] +/// #![feature(rc_unique)] +/// /// use std::rc; /// use std::rc::Rc; /// @@ -373,7 +379,8 @@ pub fn is_unique(rc: &Rc) -> bool { Rc::is_unique(rc) } /// # Examples /// /// ``` -/// # #![feature(rc_unique)] +/// #![feature(rc_unique)] +/// /// use std::rc::{self, Rc}; /// /// let x = Rc::new(3); @@ -395,7 +402,8 @@ pub fn try_unwrap(rc: Rc) -> Result> { Rc::try_unwrap(rc) } /// # Examples /// /// ``` -/// # #![feature(rc_unique)] +/// #![feature(rc_unique)] +/// /// use std::rc::{self, Rc}; /// /// let mut x = Rc::new(3); @@ -419,7 +427,8 @@ impl Rc { /// # Examples /// /// ``` - /// # #![feature(rc_unique)] + /// #![feature(rc_unique)] + /// /// use std::rc::Rc; /// /// let mut five = Rc::new(5); @@ -750,7 +759,8 @@ impl Weak { /// # Examples /// /// ``` - /// # #![feature(rc_weak)] + /// #![feature(rc_weak)] + /// /// use std::rc::Rc; /// /// let five = Rc::new(5); @@ -778,7 +788,8 @@ impl Drop for Weak { /// # Examples /// /// ``` - /// # #![feature(rc_weak)] + /// #![feature(rc_weak)] + /// /// use std::rc::Rc; /// /// { @@ -825,7 +836,8 @@ impl Clone for Weak { /// # Examples /// /// ``` - /// # #![feature(rc_weak)] + /// #![feature(rc_weak)] + /// /// use std::rc::Rc; /// /// let weak_five = Rc::new(5).downgrade(); diff --git a/src/libcollections/binary_heap.rs b/src/libcollections/binary_heap.rs index f6204173ed7a5..ddf61918947cf 100644 --- a/src/libcollections/binary_heap.rs +++ b/src/libcollections/binary_heap.rs @@ -216,7 +216,8 @@ impl BinaryHeap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// #![feature(collections)] + /// /// use std::collections::BinaryHeap; /// let heap = BinaryHeap::from_vec(vec![9, 1, 2, 7, 3, 2]); /// ``` @@ -236,7 +237,8 @@ impl BinaryHeap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// #![feature(collections)] + /// /// use std::collections::BinaryHeap; /// let heap = BinaryHeap::from_vec(vec![1, 2, 3, 4]); /// @@ -341,7 +343,8 @@ impl BinaryHeap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// #![feature(collections)] + /// /// use std::collections::BinaryHeap; /// let mut heap = BinaryHeap::from_vec(vec![1, 3]); /// @@ -387,7 +390,8 @@ impl BinaryHeap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// #![feature(collections)] + /// /// use std::collections::BinaryHeap; /// let mut heap = BinaryHeap::new(); /// heap.push(1); @@ -419,7 +423,8 @@ impl BinaryHeap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// #![feature(collections)] + /// /// use std::collections::BinaryHeap; /// let mut heap = BinaryHeap::new(); /// @@ -445,7 +450,8 @@ impl BinaryHeap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// #![feature(collections)] + /// /// use std::collections::BinaryHeap; /// let heap = BinaryHeap::from_vec(vec![1, 2, 3, 4, 5, 6, 7]); /// let vec = heap.into_vec(); @@ -463,7 +469,8 @@ impl BinaryHeap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// #![feature(collections)] + /// /// use std::collections::BinaryHeap; /// /// let mut heap = BinaryHeap::from_vec(vec![1, 2, 4, 5, 7]); @@ -724,7 +731,8 @@ impl IntoIterator for BinaryHeap { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// #![feature(collections)] + /// /// use std::collections::BinaryHeap; /// let heap = BinaryHeap::from_vec(vec![1, 2, 3, 4]); /// diff --git a/src/libcollections/bit.rs b/src/libcollections/bit.rs index 3a4cfbba65f4e..30f23e073f691 100644 --- a/src/libcollections/bit.rs +++ b/src/libcollections/bit.rs @@ -43,7 +43,8 @@ //! [sieve]: http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes //! //! ``` -//! # #![feature(bitset, bitvec, range_inclusive, step_by)] +//! #![feature(bitset, bitvec, range_inclusive, step_by)] +//! //! use std::collections::{BitSet, BitVec}; //! use std::iter; //! @@ -139,7 +140,8 @@ const FALSE: &'static bool = &false; /// # Examples /// /// ``` -/// # #![feature(bitvec)] +/// #![feature(bitvec)] +/// /// use std::collections::BitVec; /// /// let mut bv = BitVec::from_elem(10, false); @@ -256,7 +258,8 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(bitvec)] + /// #![feature(bitvec)] + /// /// use std::collections::BitVec; /// let mut bv = BitVec::new(); /// ``` @@ -271,7 +274,8 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(bitvec)] + /// #![feature(bitvec)] + /// /// use std::collections::BitVec; /// /// let bv = BitVec::from_elem(10, false); @@ -312,7 +316,8 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(bitvec)] + /// #![feature(bitvec)] + /// /// use std::collections::BitVec; /// /// let bv = BitVec::from_bytes(&[0b10100000, 0b00010010]); @@ -355,7 +360,8 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(bitvec)] + /// #![feature(bitvec)] + /// /// use std::collections::BitVec; /// /// let bv = BitVec::from_fn(5, |i| { i % 2 == 0 }); @@ -374,7 +380,8 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(bitvec)] + /// #![feature(bitvec)] + /// /// use std::collections::BitVec; /// /// let bv = BitVec::from_bytes(&[0b01100000]); @@ -407,7 +414,8 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(bitvec)] + /// #![feature(bitvec)] + /// /// use std::collections::BitVec; /// /// let mut bv = BitVec::from_elem(5, false); @@ -430,7 +438,8 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(bitvec)] + /// #![feature(bitvec)] + /// /// use std::collections::BitVec; /// /// let before = 0b01100000; @@ -451,7 +460,8 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(bitvec)] + /// #![feature(bitvec)] + /// /// use std::collections::BitVec; /// /// let before = 0b01100000; @@ -480,7 +490,8 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(bitvec)] + /// #![feature(bitvec)] + /// /// use std::collections::BitVec; /// /// let a = 0b01100100; @@ -511,7 +522,8 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(bitvec)] + /// #![feature(bitvec)] + /// /// use std::collections::BitVec; /// /// let a = 0b01100100; @@ -542,7 +554,8 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(bitvec)] + /// #![feature(bitvec)] + /// /// use std::collections::BitVec; /// /// let a = 0b01100100; @@ -572,7 +585,8 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(bitvec)] + /// #![feature(bitvec)] + /// /// use std::collections::BitVec; /// /// let mut bv = BitVec::from_elem(5, true); @@ -597,7 +611,8 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(bitvec)] + /// #![feature(bitvec)] + /// /// use std::collections::BitVec; /// /// let bv = BitVec::from_bytes(&[0b01110100, 0b10010010]); @@ -614,7 +629,8 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(bitvec, append)] + /// #![feature(bitvec, append)] + /// /// use std::collections::BitVec; /// /// let mut a = BitVec::from_bytes(&[0b10000000]); @@ -657,7 +673,8 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(bitvec, split_off)] + /// #![feature(bitvec, split_off)] + /// /// use std::collections::BitVec; /// let mut a = BitVec::new(); /// a.push(true); @@ -718,7 +735,8 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(bitvec)] + /// #![feature(bitvec)] + /// /// use std::collections::BitVec; /// /// let mut bv = BitVec::from_elem(10, false); @@ -736,7 +754,8 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(bitvec)] + /// #![feature(bitvec)] + /// /// use std::collections::BitVec; /// /// let mut bv = BitVec::from_elem(10, false); @@ -758,7 +777,8 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(bitvec)] + /// #![feature(bitvec)] + /// /// use std::collections::BitVec; /// /// let mut bv = BitVec::from_elem(3, true); @@ -806,7 +826,8 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(bitvec)] + /// #![feature(bitvec)] + /// /// use std::collections::BitVec; /// /// let bv = BitVec::from_bytes(&[0b10100000]); @@ -827,7 +848,8 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(bitvec)] + /// #![feature(bitvec)] + /// /// use std::collections::BitVec; /// /// let mut bv = BitVec::from_bytes(&[0b01001011]); @@ -854,7 +876,8 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(bitvec)] + /// #![feature(bitvec)] + /// /// use std::collections::BitVec; /// /// let mut bv = BitVec::from_elem(3, false); @@ -885,7 +908,8 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(bitvec)] + /// #![feature(bitvec)] + /// /// use std::collections::BitVec; /// /// let mut bv = BitVec::from_elem(3, false); @@ -908,7 +932,8 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(bitvec)] + /// #![feature(bitvec)] + /// /// use std::collections::BitVec; /// /// let mut bv = BitVec::new(); @@ -930,7 +955,8 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(bitvec)] + /// #![feature(bitvec)] + /// /// use std::collections::BitVec; /// /// let mut bv = BitVec::from_bytes(&[0b01001011]); @@ -981,7 +1007,8 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(bitvec)] + /// #![feature(bitvec)] + /// /// use std::collections::BitVec; /// /// let mut bv = BitVec::from_bytes(&[0b01001001]); @@ -1012,7 +1039,8 @@ impl BitVec { /// # Examples /// /// ``` - /// # #![feature(bitvec)] + /// #![feature(bitvec)] + /// /// use std::collections::BitVec; /// /// let mut bv = BitVec::new(); @@ -1231,7 +1259,8 @@ impl<'a> IntoIterator for &'a BitVec { /// # Examples /// /// ``` -/// # #![feature(bitvec, bitset)] +/// #![feature(bitvec, bitset)] +/// /// use std::collections::{BitSet, BitVec}; /// /// // It's a regular set @@ -1335,7 +1364,8 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(bitset)] + /// #![feature(bitset)] + /// /// use std::collections::BitSet; /// /// let mut s = BitSet::new(); @@ -1352,7 +1382,8 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(bitset)] + /// #![feature(bitset)] + /// /// use std::collections::BitSet; /// /// let mut s = BitSet::with_capacity(100); @@ -1370,7 +1401,8 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(bitset, bitvec)] + /// #![feature(bitset, bitvec)] + /// /// use std::collections::{BitVec, BitSet}; /// /// let bv = BitVec::from_bytes(&[0b01100000]); @@ -1392,7 +1424,8 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(bitset)] + /// #![feature(bitset)] + /// /// use std::collections::BitSet; /// /// let mut s = BitSet::with_capacity(100); @@ -1414,7 +1447,8 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(bitset)] + /// #![feature(bitset)] + /// /// use std::collections::BitSet; /// /// let mut s = BitSet::new(); @@ -1441,7 +1475,8 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(bitset)] + /// #![feature(bitset)] + /// /// use std::collections::BitSet; /// /// let mut s = BitSet::new(); @@ -1462,7 +1497,8 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(bitset)] + /// #![feature(bitset)] + /// /// use std::collections::BitSet; /// /// let mut s = BitSet::new(); @@ -1483,7 +1519,8 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(bitset)] + /// #![feature(bitset)] + /// /// use std::collections::BitSet; /// /// let mut s = BitSet::new(); @@ -1530,7 +1567,8 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(bitset)] + /// #![feature(bitset)] + /// /// use std::collections::BitSet; /// /// let mut s = BitSet::new(); @@ -1563,7 +1601,8 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(bitset, bitvec)] + /// #![feature(bitset, bitvec)] + /// /// use std::collections::{BitVec, BitSet}; /// /// let s = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01001010])); @@ -1585,7 +1624,8 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(bitset, bitvec)] + /// #![feature(bitset, bitvec)] + /// /// use std::collections::{BitVec, BitSet}; /// /// let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01101000])); @@ -1615,7 +1655,8 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(bitset, bitvec)] + /// #![feature(bitset, bitvec)] + /// /// use std::collections::{BitVec, BitSet}; /// /// let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01101000])); @@ -1646,7 +1687,8 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(bitset, bitvec)] + /// #![feature(bitset, bitvec)] + /// /// use std::collections::{BitSet, BitVec}; /// /// let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01101000])); @@ -1684,7 +1726,8 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(bitset, bitvec)] + /// #![feature(bitset, bitvec)] + /// /// use std::collections::{BitSet, BitVec}; /// /// let a = BitSet::from_bit_vec(BitVec::from_bytes(&[0b01101000])); @@ -1712,7 +1755,8 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(bitset, bitvec)] + /// #![feature(bitset, bitvec)] + /// /// use std::collections::{BitSet, BitVec}; /// /// let a = 0b01101000; @@ -1736,7 +1780,8 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(bitset, bitvec)] + /// #![feature(bitset, bitvec)] + /// /// use std::collections::{BitSet, BitVec}; /// /// let a = 0b01101000; @@ -1761,7 +1806,8 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(bitset, bitvec)] + /// #![feature(bitset, bitvec)] + /// /// use std::collections::{BitSet, BitVec}; /// /// let a = 0b01101000; @@ -1794,7 +1840,8 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(bitset, bitvec)] + /// #![feature(bitset, bitvec)] + /// /// use std::collections::{BitSet, BitVec}; /// /// let a = 0b01101000; @@ -1818,7 +1865,8 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(bitset, bitvec, append)] + /// #![feature(bitset, bitvec, append)] + /// /// use std::collections::{BitVec, BitSet}; /// /// let mut a = BitSet::new(); @@ -1849,7 +1897,8 @@ impl BitSet { /// # Examples /// /// ``` - /// # #![feature(bitset, bitvec, split_off)] + /// #![feature(bitset, bitvec, split_off)] + /// /// use std::collections::{BitSet, BitVec}; /// let mut a = BitSet::new(); /// a.insert(2); diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs index 27b10213ecd7c..a5a0d864572d2 100644 --- a/src/libcollections/btree/map.rs +++ b/src/libcollections/btree/map.rs @@ -1504,7 +1504,8 @@ impl BTreeMap { /// # Examples /// /// ``` - /// # #![feature(btree_range, collections_bound)] + /// #![feature(btree_range, collections_bound)] + /// /// use std::collections::BTreeMap; /// use std::collections::Bound::{Included, Unbounded}; /// @@ -1531,7 +1532,8 @@ impl BTreeMap { /// # Examples /// /// ``` - /// # #![feature(btree_range, collections_bound)] + /// #![feature(btree_range, collections_bound)] + /// /// use std::collections::BTreeMap; /// use std::collections::Bound::{Included, Excluded}; /// diff --git a/src/libcollections/btree/set.rs b/src/libcollections/btree/set.rs index 7c4cda305adf2..596312e509ede 100644 --- a/src/libcollections/btree/set.rs +++ b/src/libcollections/btree/set.rs @@ -141,7 +141,8 @@ impl BTreeSet { /// # Examples /// /// ``` - /// # #![feature(btree_range, collections_bound)] + /// #![feature(btree_range, collections_bound)] + /// /// use std::collections::BTreeSet; /// use std::collections::Bound::{Included, Unbounded}; /// diff --git a/src/libcollections/fmt.rs b/src/libcollections/fmt.rs index 7df259e9b36a8..7e16df6242fcc 100644 --- a/src/libcollections/fmt.rs +++ b/src/libcollections/fmt.rs @@ -172,7 +172,7 @@ //! like: //! //! ``` -//! # #![feature(fmt_flags)] +//! #![feature(fmt_flags)] //! use std::fmt; //! //! #[derive(Debug)] diff --git a/src/libcollections/linked_list.rs b/src/libcollections/linked_list.rs index a02cb44896ad3..32d6b3b95a460 100644 --- a/src/libcollections/linked_list.rs +++ b/src/libcollections/linked_list.rs @@ -784,7 +784,8 @@ impl<'a, A> IterMut<'a, A> { /// # Examples /// /// ``` - /// # #![feature(linked_list_extras)] + /// #![feature(linked_list_extras)] + /// /// use std::collections::LinkedList; /// /// let mut list: LinkedList<_> = vec![1, 3, 4].into_iter().collect(); @@ -812,7 +813,8 @@ impl<'a, A> IterMut<'a, A> { /// # Examples /// /// ``` - /// # #![feature(linked_list_extras)] + /// #![feature(linked_list_extras)] + /// /// use std::collections::LinkedList; /// /// let mut list: LinkedList<_> = vec![1, 2, 3].into_iter().collect(); diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index 00a0432956b8b..5ccf3973c2882 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -887,7 +887,8 @@ impl [T] { /// # Examples /// /// ```rust - /// # #![feature(permutations)] + /// #![feature(permutations)] + /// /// let v = [1, 2, 3]; /// let mut perms = v.permutations(); /// @@ -899,7 +900,8 @@ impl [T] { /// Iterating through permutations one by one. /// /// ```rust - /// # #![feature(permutations)] + /// #![feature(permutations)] + /// /// let v = [1, 2, 3]; /// let mut perms = v.permutations(); /// @@ -924,7 +926,8 @@ impl [T] { /// # Example /// /// ```rust - /// # #![feature(permutations)] + /// #![feature(permutations)] + /// /// let v: &mut [_] = &mut [0, 1, 2]; /// v.next_permutation(); /// let b: &mut [_] = &mut [0, 2, 1]; @@ -949,7 +952,8 @@ impl [T] { /// # Example /// /// ```rust - /// # #![feature(permutations)] + /// #![feature(permutations)] + /// /// let v: &mut [_] = &mut [1, 0, 2]; /// v.prev_permutation(); /// let b: &mut [_] = &mut [0, 2, 1]; @@ -973,7 +977,8 @@ impl [T] { /// # Example /// /// ```rust - /// # #![feature(clone_from_slice)] + /// #![feature(clone_from_slice)] + /// /// let mut dst = [0, 0, 0]; /// let src = [1, 2]; /// @@ -1004,7 +1009,8 @@ impl [T] { /// # Examples /// /// ```rust - /// # #![feature(move_from)] + /// #![feature(move_from)] + /// /// let mut a = [1, 2, 3, 4, 5]; /// let b = vec![6, 7, 8]; /// let num_moved = a.move_from(b, 0, 3); diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 58affdc4729fa..686e46fcbadbc 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -441,7 +441,8 @@ impl str { /// # Examples /// /// ``` - /// # #![feature(str_char)] + /// #![feature(str_char)] + /// /// let s = "Löwe 老虎 Léopard"; /// assert!(s.is_char_boundary(0)); /// // start of `老` @@ -545,7 +546,8 @@ impl str { /// # Examples /// /// ``` - /// # #![feature(slice_chars)] + /// #![feature(slice_chars)] + /// /// let s = "Löwe 老虎 Léopard"; /// /// assert_eq!(s.slice_chars(0, 4), "Löwe"); @@ -576,7 +578,8 @@ impl str { /// done by `.chars()` or `.char_indices()`. /// /// ``` - /// # #![feature(str_char, core)] + /// #![feature(str_char, core)] + /// /// use std::str::CharRange; /// /// let s = "中华Việt Nam"; @@ -633,7 +636,8 @@ impl str { /// done by `.chars().rev()` or `.char_indices()`. /// /// ``` - /// # #![feature(str_char, core)] + /// #![feature(str_char, core)] + /// /// use std::str::CharRange; /// /// let s = "中华Việt Nam"; @@ -679,7 +683,8 @@ impl str { /// # Examples /// /// ``` - /// # #![feature(str_char)] + /// #![feature(str_char)] + /// /// let s = "abπc"; /// assert_eq!(s.char_at(1), 'b'); /// assert_eq!(s.char_at(2), 'π'); @@ -706,7 +711,8 @@ impl str { /// # Examples /// /// ``` - /// # #![feature(str_char)] + /// #![feature(str_char)] + /// /// let s = "abπc"; /// assert_eq!(s.char_at_reverse(1), 'a'); /// assert_eq!(s.char_at_reverse(2), 'b'); @@ -733,7 +739,8 @@ impl str { /// # Examples /// /// ``` - /// # #![feature(str_char)] + /// #![feature(str_char)] + /// /// let s = "Łódź"; // \u{141}o\u{301}dz\u{301} /// let (c, s1) = s.slice_shift_char().unwrap(); /// @@ -767,7 +774,8 @@ impl str { /// /// # Examples /// ``` - /// # #![feature(str_split_at)] + /// #![feature(str_split_at)] + /// /// let s = "Löwe 老虎 Léopard"; /// let first_space = s.find(' ').unwrap_or(s.len()); /// let (a, b) = s.split_at(first_space); @@ -865,8 +873,9 @@ impl str { /// # Examples /// /// ``` - /// # #![feature(str_words)] - /// # #![allow(deprecated)] + /// #![feature(str_words)] + /// #![allow(deprecated)] + /// /// let some_words = " Mary had\ta\u{2009}little \n\t lamb"; /// let v: Vec<&str> = some_words.words().collect(); /// @@ -1021,7 +1030,8 @@ impl str { /// # Examples /// /// ``` - /// # #![feature(unicode, core)] + /// #![feature(unicode, core)] + /// /// let gr1 = "a\u{310}e\u{301}o\u{308}\u{332}".graphemes(true).collect::>(); /// let b: &[_] = &["a\u{310}", "e\u{301}", "o\u{308}\u{332}"]; /// @@ -1047,7 +1057,8 @@ impl str { /// # Examples /// /// ``` - /// # #![feature(unicode, core)] + /// #![feature(unicode, core)] + /// /// let gr_inds = "a̐éö̲\r\n".grapheme_indices(true).collect::>(); /// let b: &[_] = &[(0, "a̐"), (3, "é"), (6, "ö̲"), (11, "\r\n")]; /// @@ -1585,7 +1596,8 @@ impl str { /// # Examples /// /// ``` - /// # #![feature(str_match_indices)] + /// #![feature(str_match_indices)] + /// /// let v: Vec<(usize, usize)> = "abcXXXabcYYYabc".match_indices("abc").collect(); /// assert_eq!(v, [(0, 3), (6, 9), (12, 15)]); /// @@ -1629,7 +1641,8 @@ impl str { /// # Examples /// /// ``` - /// # #![feature(str_match_indices)] + /// #![feature(str_match_indices)] + /// /// let v: Vec<(usize, usize)> = "abcXXXabcYYYabc".rmatch_indices("abc").collect(); /// assert_eq!(v, [(12, 15), (6, 9), (0, 3)]); /// @@ -1659,7 +1672,8 @@ impl str { /// # Examples /// /// ``` - /// # #![feature(subslice_offset)] + /// #![feature(subslice_offset)] + /// /// let string = "a\nb\nc"; /// let lines: Vec<&str> = string.lines().collect(); /// diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index cc58952be600a..0b441b42cdc14 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -89,7 +89,8 @@ impl String { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// #![feature(collections)] + /// /// let s = String::from("hello"); /// assert_eq!(&s[..], "hello"); /// ``` @@ -702,7 +703,7 @@ impl String { /// # Examples /// /// ``` - /// # #![feature(drain)] + /// #![feature(drain)] /// /// let mut s = String::from("α is alpha, β is beta"); /// let beta_offset = s.find('β').unwrap_or(s.len()); diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index e9f3651d63b89..96ad00597f806 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -112,6 +112,13 @@ use super::range::RangeArgument; /// assert_eq!(vec, [1, 2, 3, 4]); /// ``` /// +/// It can also initialize each element of a `Vec` with a given value: +/// +/// ``` +/// let vec = vec![0; 5]; +/// assert_eq!(vec, [0, 0, 0, 0, 0]); +/// ``` +/// /// Use a `Vec` as an efficient stack: /// /// ``` @@ -574,7 +581,7 @@ impl Vec { /// # Examples /// /// ``` - /// let mut vec = vec!(1, 2); + /// let mut vec = vec![1, 2]; /// vec.push(3); /// assert_eq!(vec, [1, 2, 3]); /// ``` @@ -622,7 +629,8 @@ impl Vec { /// # Examples /// /// ``` - /// # #![feature(append)] + /// #![feature(append)] + /// /// let mut vec = vec![1, 2, 3]; /// let mut vec2 = vec![4, 5, 6]; /// vec.append(&mut vec2); @@ -661,7 +669,7 @@ impl Vec { /// # Examples /// /// ``` - /// # #![feature(drain)] + /// #![feature(drain)] /// /// // Draining using `..` clears the whole vector. /// let mut v = vec![1, 2, 3]; @@ -759,7 +767,8 @@ impl Vec { /// # Examples /// /// ``` - /// # #![feature(map_in_place)] + /// #![feature(map_in_place)] + /// /// let v = vec![0, 1, 2]; /// let w = v.map_in_place(|i| i + 3); /// assert_eq!(&w[..], &[3, 4, 5]); @@ -965,7 +974,8 @@ impl Vec { /// # Examples /// /// ``` - /// # #![feature(split_off)] + /// #![feature(split_off)] + /// /// let mut vec = vec![1,2,3]; /// let vec2 = vec.split_off(1); /// assert_eq!(vec, [1]); @@ -1004,7 +1014,8 @@ impl Vec { /// # Examples /// /// ``` - /// # #![feature(vec_resize)] + /// #![feature(vec_resize)] + /// /// let mut vec = vec!["hello"]; /// vec.resize(3, "world"); /// assert_eq!(vec, ["hello", "world", "world"]); @@ -1056,7 +1067,8 @@ impl Vec { /// # Examples /// /// ``` - /// # #![feature(vec_push_all)] + /// #![feature(vec_push_all)] + /// /// let mut vec = vec![1]; /// vec.push_all(&[2, 3, 4]); /// assert_eq!(vec, [1, 2, 3, 4]); diff --git a/src/libcollections/vec_deque.rs b/src/libcollections/vec_deque.rs index 7bdc10cfb64fa..c6d0d946ab024 100644 --- a/src/libcollections/vec_deque.rs +++ b/src/libcollections/vec_deque.rs @@ -231,7 +231,7 @@ impl VecDeque { /// buf.push_back(3); /// buf.push_back(4); /// buf.push_back(5); - /// assert_eq!(buf.get(1).unwrap(), &4); + /// assert_eq!(buf.get(1), Some(&4)); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn get(&self, index: usize) -> Option<&T> { @@ -379,7 +379,8 @@ impl VecDeque { /// # Examples /// /// ``` - /// # #![feature(collections)] + /// #![feature(collections)] + /// /// use std::collections::VecDeque; /// /// let mut buf = VecDeque::with_capacity(15); @@ -455,7 +456,8 @@ impl VecDeque { /// # Examples /// /// ``` - /// # #![feature(deque_extras)] + /// #![feature(deque_extras)] + /// /// use std::collections::VecDeque; /// /// let mut buf = VecDeque::new(); @@ -604,7 +606,8 @@ impl VecDeque { /// # Examples /// /// ``` - /// # #![feature(drain)] + /// #![feature(drain)] + /// /// use std::collections::VecDeque; /// /// let mut v = VecDeque::new(); @@ -847,17 +850,20 @@ impl VecDeque { /// # Examples /// /// ``` - /// # #![feature(deque_extras)] + /// #![feature(deque_extras)] + /// /// use std::collections::VecDeque; /// /// let mut buf = VecDeque::new(); /// assert_eq!(buf.swap_back_remove(0), None); - /// buf.push_back(5); - /// buf.push_back(99); - /// buf.push_back(15); - /// buf.push_back(20); - /// buf.push_back(10); - /// assert_eq!(buf.swap_back_remove(1), Some(99)); + /// buf.push_back(1); + /// buf.push_back(2); + /// buf.push_back(3); + /// + /// assert_eq!(buf.swap_back_remove(0), Some(1)); + /// assert_eq!(buf.len(), 2); + /// assert_eq!(buf[0], 3); + /// assert_eq!(buf[1], 2); /// ``` #[unstable(feature = "deque_extras", reason = "the naming of this function may be altered")] @@ -881,17 +887,20 @@ impl VecDeque { /// # Examples /// /// ``` - /// # #![feature(deque_extras)] + /// #![feature(deque_extras)] + /// /// use std::collections::VecDeque; /// /// let mut buf = VecDeque::new(); /// assert_eq!(buf.swap_front_remove(0), None); - /// buf.push_back(15); - /// buf.push_back(5); - /// buf.push_back(10); - /// buf.push_back(99); - /// buf.push_back(20); - /// assert_eq!(buf.swap_front_remove(3), Some(99)); + /// buf.push_back(1); + /// buf.push_back(2); + /// buf.push_back(3); + /// + /// assert_eq!(buf.swap_front_remove(2), Some(3)); + /// assert_eq!(buf.len(), 2); + /// assert_eq!(buf[0], 2); + /// assert_eq!(buf[1], 1); /// ``` #[unstable(feature = "deque_extras", reason = "the naming of this function may be altered")] @@ -915,7 +924,8 @@ impl VecDeque { /// /// # Examples /// ``` - /// # #![feature(collections)] + /// #![feature(collections)] + /// /// use std::collections::VecDeque; /// /// let mut buf = VecDeque::new(); @@ -1123,12 +1133,12 @@ impl VecDeque { /// use std::collections::VecDeque; /// /// let mut buf = VecDeque::new(); - /// buf.push_back(5); - /// buf.push_back(10); - /// buf.push_back(12); - /// buf.push_back(15); - /// buf.remove(2); - /// assert_eq!(Some(&15), buf.get(2)); + /// buf.push_back(1); + /// buf.push_back(2); + /// buf.push_back(3); + /// + /// assert_eq!(buf.remove(1), Some(2)); + /// assert_eq!(buf.get(1), Some(&3)); /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn remove(&mut self, index: usize) -> Option { @@ -1291,7 +1301,8 @@ impl VecDeque { /// # Examples /// /// ``` - /// # #![feature(split_off)] + /// #![feature(split_off)] + /// /// use std::collections::VecDeque; /// /// let mut buf: VecDeque<_> = vec![1,2,3].into_iter().collect(); @@ -1354,7 +1365,8 @@ impl VecDeque { /// # Examples /// /// ``` - /// # #![feature(append)] + /// #![feature(append)] + /// /// use std::collections::VecDeque; /// /// let mut buf: VecDeque<_> = vec![1, 2, 3].into_iter().collect(); @@ -1380,7 +1392,8 @@ impl VecDeque { /// # Examples /// /// ``` - /// # #![feature(vec_deque_retain)] + /// #![feature(vec_deque_retain)] + /// /// use std::collections::VecDeque; /// /// let mut buf = VecDeque::new(); @@ -1415,7 +1428,8 @@ impl VecDeque { /// # Examples /// /// ``` - /// # #![feature(deque_extras)] + /// #![feature(deque_extras)] + /// /// use std::collections::VecDeque; /// /// let mut buf = VecDeque::new(); diff --git a/src/libcollections/vec_map.rs b/src/libcollections/vec_map.rs index 685bb5dc4b4f3..51fda344c8829 100644 --- a/src/libcollections/vec_map.rs +++ b/src/libcollections/vec_map.rs @@ -35,7 +35,8 @@ use vec::Vec; /// # Examples /// /// ``` -/// # #![feature(vecmap)] +/// #![feature(vecmap)] +/// /// use std::collections::VecMap; /// /// let mut months = VecMap::new(); @@ -135,7 +136,8 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(vecmap)] + /// #![feature(vecmap)] + /// /// use std::collections::VecMap; /// let mut map: VecMap<&str> = VecMap::new(); /// ``` @@ -148,7 +150,8 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(vecmap)] + /// #![feature(vecmap)] + /// /// use std::collections::VecMap; /// let mut map: VecMap<&str> = VecMap::with_capacity(10); /// ``` @@ -163,7 +166,8 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(vecmap)] + /// #![feature(vecmap)] + /// /// use std::collections::VecMap; /// let map: VecMap = VecMap::with_capacity(10); /// assert!(map.capacity() >= 10); @@ -183,7 +187,8 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(vecmap)] + /// #![feature(vecmap)] + /// /// use std::collections::VecMap; /// let mut map: VecMap<&str> = VecMap::new(); /// map.reserve_len(10); @@ -208,7 +213,8 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(vecmap)] + /// #![feature(vecmap)] + /// /// use std::collections::VecMap; /// let mut map: VecMap<&str> = VecMap::new(); /// map.reserve_len_exact(10); @@ -248,7 +254,8 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(vecmap)] + /// #![feature(vecmap)] + /// /// use std::collections::VecMap; /// /// let mut map = VecMap::new(); @@ -277,7 +284,8 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(vecmap)] + /// #![feature(vecmap)] + /// /// use std::collections::VecMap; /// /// let mut map = VecMap::new(); @@ -307,7 +315,8 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(vecmap, append)] + /// #![feature(vecmap, append)] + /// /// use std::collections::VecMap; /// /// let mut a = VecMap::new(); @@ -343,7 +352,8 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(vecmap, split_off)] + /// #![feature(vecmap, split_off)] + /// /// use std::collections::VecMap; /// /// let mut a = VecMap::new(); @@ -400,7 +410,8 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(vecmap, drain)] + /// #![feature(vecmap, drain)] + /// /// use std::collections::VecMap; /// /// let mut map = VecMap::new(); @@ -428,7 +439,8 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(vecmap)] + /// #![feature(vecmap)] + /// /// use std::collections::VecMap; /// /// let mut a = VecMap::new(); @@ -446,7 +458,8 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(vecmap)] + /// #![feature(vecmap)] + /// /// use std::collections::VecMap; /// /// let mut a = VecMap::new(); @@ -464,7 +477,8 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(vecmap)] + /// #![feature(vecmap)] + /// /// use std::collections::VecMap; /// /// let mut a = VecMap::new(); @@ -480,7 +494,8 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(vecmap)] + /// #![feature(vecmap)] + /// /// use std::collections::VecMap; /// /// let mut map = VecMap::new(); @@ -505,7 +520,8 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(vecmap)] + /// #![feature(vecmap)] + /// /// use std::collections::VecMap; /// /// let mut map = VecMap::new(); @@ -524,7 +540,8 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(vecmap)] + /// #![feature(vecmap)] + /// /// use std::collections::VecMap; /// /// let mut map = VecMap::new(); @@ -552,7 +569,8 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(vecmap)] + /// #![feature(vecmap)] + /// /// use std::collections::VecMap; /// /// let mut map = VecMap::new(); @@ -578,7 +596,8 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(vecmap)] + /// #![feature(vecmap)] + /// /// use std::collections::VecMap; /// /// let mut map = VecMap::new(); @@ -600,7 +619,8 @@ impl VecMap { /// # Examples /// /// ``` - /// # #![feature(vecmap, entry)] + /// #![feature(vecmap, entry)] + /// /// use std::collections::VecMap; /// /// let mut count: VecMap = VecMap::new(); @@ -778,7 +798,8 @@ impl IntoIterator for VecMap { /// # Examples /// /// ``` - /// # #![feature(vecmap)] + /// #![feature(vecmap)] + /// /// use std::collections::VecMap; /// /// let mut map = VecMap::new(); diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 2c4ebeafc0bc5..c443270d5f405 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -221,7 +221,8 @@ impl Cell { /// # Examples /// /// ``` - /// # #![feature(as_unsafe_cell)] + /// #![feature(as_unsafe_cell)] + /// /// use std::cell::Cell; /// /// let c = Cell::new(5); @@ -589,7 +590,8 @@ impl<'b, T: ?Sized> Ref<'b, T> { /// # Example /// /// ``` - /// # #![feature(cell_extras)] + /// #![feature(cell_extras)] + /// /// use std::cell::{RefCell, Ref}; /// /// let c = RefCell::new((5, 'b')); diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 93542185eab5b..9d151abea787c 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -383,7 +383,8 @@ pub fn max(v1: T, v2: T) -> T { /// # Examples /// /// ``` -/// # #![feature(cmp_partial)] +/// #![feature(cmp_partial)] +/// /// use std::cmp; /// /// assert_eq!(Some(1), cmp::partial_min(1, 2)); @@ -393,7 +394,8 @@ pub fn max(v1: T, v2: T) -> T { /// When comparison is impossible: /// /// ``` -/// # #![feature(cmp_partial)] +/// #![feature(cmp_partial)] +/// /// use std::cmp; /// /// let result = cmp::partial_min(std::f64::NAN, 1.0); @@ -417,7 +419,8 @@ pub fn partial_min(v1: T, v2: T) -> Option { /// # Examples /// /// ``` -/// # #![feature(cmp_partial)] +/// #![feature(cmp_partial)] +/// /// use std::cmp; /// /// assert_eq!(Some(2), cmp::partial_max(1, 2)); @@ -427,7 +430,8 @@ pub fn partial_min(v1: T, v2: T) -> Option { /// When comparison is impossible: /// /// ``` -/// # #![feature(cmp_partial)] +/// #![feature(cmp_partial)] +/// /// use std::cmp; /// /// let result = cmp::partial_max(std::f64::NAN, 1.0); diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index 8141916dd60fc..7cacc6af575c8 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -167,7 +167,8 @@ pub struct RadixFmt(T, R); /// # Examples /// /// ``` -/// # #![feature(fmt_radix)] +/// #![feature(fmt_radix)] +/// /// use std::fmt::radix; /// assert_eq!(format!("{}", radix(55, 36)), "1j".to_string()); /// ``` diff --git a/src/libcore/hash/mod.rs b/src/libcore/hash/mod.rs index a660cf0cf2d54..75b7208d66bd5 100644 --- a/src/libcore/hash/mod.rs +++ b/src/libcore/hash/mod.rs @@ -16,7 +16,8 @@ //! # Examples //! //! ```rust -//! # #![feature(hash_default)] +//! #![feature(hash_default)] +//! //! use std::hash::{hash, Hash, SipHasher}; //! //! #[derive(Hash)] @@ -36,7 +37,8 @@ //! the trait `Hash`: //! //! ```rust -//! # #![feature(hash_default)] +//! #![feature(hash_default)] +//! //! use std::hash::{hash, Hash, Hasher, SipHasher}; //! //! struct Person { diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 4d8de0c85b6e9..2968d63454457 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -824,7 +824,8 @@ pub trait Iterator { /// # Examples /// /// ``` - /// # #![feature(iter_min_max)] + /// #![feature(iter_min_max)] + /// /// use std::iter::MinMaxResult::{NoElements, OneElement, MinMax}; /// /// let a: [i32; 0] = []; @@ -898,7 +899,8 @@ pub trait Iterator { /// # Examples /// /// ``` - /// # #![feature(iter_cmp)] + /// #![feature(iter_cmp)] + /// /// let a = [-3_i32, 0, 1, 5, -10]; /// assert_eq!(*a.iter().max_by(|x| x.abs()).unwrap(), -10); /// ``` @@ -926,7 +928,8 @@ pub trait Iterator { /// # Examples /// /// ``` - /// # #![feature(iter_cmp)] + /// #![feature(iter_cmp)] + /// /// let a = [-3_i32, 0, 1, 5, -10]; /// assert_eq!(*a.iter().min_by(|x| x.abs()).unwrap(), 0); /// ``` @@ -1065,7 +1068,8 @@ pub trait Iterator { /// # Examples /// /// ``` - /// # #![feature(iter_arith)] + /// #![feature(iter_arith)] + /// /// let a = [1, 2, 3, 4, 5]; /// let it = a.iter(); /// assert_eq!(it.sum::(), 15); @@ -1083,7 +1087,8 @@ pub trait Iterator { /// # Examples /// /// ``` - /// # #![feature(iter_arith)] + /// #![feature(iter_arith)] + /// /// fn factorial(n: u32) -> u32 { /// (1..).take_while(|&i| i <= n).product() /// } @@ -1367,7 +1372,8 @@ impl MinMaxResult { /// # Examples /// /// ``` - /// # #![feature(iter_min_max)] + /// #![feature(iter_min_max)] + /// /// use std::iter::MinMaxResult::{self, NoElements, OneElement, MinMax}; /// /// let r: MinMaxResult = NoElements; @@ -2764,7 +2770,8 @@ impl ops::Range { /// # Examples /// /// ``` - /// # #![feature(step_by)] + /// #![feature(step_by)] + /// /// for i in (0..10).step_by(2) { /// println!("{}", i); /// } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 9ccba7ad78d45..2235dc4af11f5 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -274,7 +274,8 @@ impl Option { /// # Examples /// /// ``` - /// # #![feature(as_slice)] + /// #![feature(as_slice)] + /// /// let mut x = Some("Diamonds"); /// { /// let v = x.as_mut_slice(); diff --git a/src/libcore/raw.rs b/src/libcore/raw.rs index 43535ddd1d5c5..f0bac1bfef3e2 100644 --- a/src/libcore/raw.rs +++ b/src/libcore/raw.rs @@ -49,7 +49,8 @@ use mem; /// # Examples /// /// ``` -/// # #![feature(raw)] +/// #![feature(raw)] +/// /// use std::raw::{self, Repr}; /// /// let slice: &[u16] = &[1, 2, 3, 4]; @@ -98,7 +99,8 @@ impl Clone for Slice { /// # Examples /// /// ``` -/// # #![feature(raw)] +/// #![feature(raw)] +/// /// use std::mem; /// use std::raw; /// diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 2b33b1f83d24c..100cf0779b7e5 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -420,7 +420,8 @@ impl Result { /// Converts from `Result` to `&mut [T]` (without copying) /// /// ``` - /// # #![feature(as_slice)] + /// #![feature(as_slice)] + /// /// let mut x: Result<&str, u32> = Ok("Gold"); /// { /// let v = x.as_mut_slice(); diff --git a/src/libcore/simd.rs b/src/libcore/simd.rs index 7ecd08bea3574..d0205fc9b126e 100644 --- a/src/libcore/simd.rs +++ b/src/libcore/simd.rs @@ -19,7 +19,8 @@ //! provided beyond this module. //! //! ```rust -//! # #![feature(core_simd)] +//! #![feature(core_simd)] +//! //! fn main() { //! use std::simd::f32x4; //! let a = f32x4(40.0, 41.0, 42.0, 43.0); diff --git a/src/libgraphviz/lib.rs b/src/libgraphviz/lib.rs index 4d07573268a68..69120b5818101 100644 --- a/src/libgraphviz/lib.rs +++ b/src/libgraphviz/lib.rs @@ -47,7 +47,8 @@ //! which is cyclic. //! //! ```rust -//! # #![feature(rustc_private, core, into_cow)] +//! #![feature(rustc_private, core, into_cow)] +//! //! use std::borrow::IntoCow; //! use std::io::Write; //! use graphviz as dot; @@ -149,7 +150,8 @@ //! entity `&sube`). //! //! ```rust -//! # #![feature(rustc_private, core, into_cow)] +//! #![feature(rustc_private, core, into_cow)] +//! //! use std::borrow::IntoCow; //! use std::io::Write; //! use graphviz as dot; @@ -207,7 +209,8 @@ //! Hasse-diagram for the subsets of the set `{x, y}`. //! //! ```rust -//! # #![feature(rustc_private, core, into_cow)] +//! #![feature(rustc_private, core, into_cow)] +//! //! use std::borrow::IntoCow; //! use std::io::Write; //! use graphviz as dot; diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 90e24213818a7..95b8161ac3429 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -674,8 +674,7 @@ impl<'a> LifetimeContext<'a> { for lifetime in lifetimes { if special_idents.iter().any(|&i| i.name == lifetime.lifetime.name) { span_err!(self.sess, lifetime.lifetime.span, E0262, - "illegal lifetime parameter name: `{}`", - lifetime.lifetime.name); + "invalid lifetime parameter name: `{}`", lifetime.lifetime.name); } } diff --git a/src/librustc_bitflags/lib.rs b/src/librustc_bitflags/lib.rs index b59c24cf12bdb..c4573bd906063 100644 --- a/src/librustc_bitflags/lib.rs +++ b/src/librustc_bitflags/lib.rs @@ -34,8 +34,8 @@ /// # Examples /// /// ```{.rust} -/// # #![feature(rustc_private)] -/// # #![feature(associated_consts)] +/// #![feature(rustc_private)] +/// #![feature(associated_consts)] /// #[macro_use] extern crate rustc_bitflags; /// /// bitflags! { @@ -62,7 +62,7 @@ /// The generated `struct`s can also be extended with type and trait implementations: /// /// ```{.rust} -/// # #![feature(rustc_private)] +/// #![feature(rustc_private)] /// #[macro_use] extern crate rustc_bitflags; /// /// use std::fmt; diff --git a/src/librustc_trans/trans/expr.rs b/src/librustc_trans/trans/expr.rs index 35e3c96d09c80..2dae1aca8351d 100644 --- a/src/librustc_trans/trans/expr.rs +++ b/src/librustc_trans/trans/expr.rs @@ -2325,7 +2325,7 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, _ => { bcx.tcx().sess.span_bug( expr.span, - &format!("deref invoked on expr of illegal type {:?}", + &format!("deref invoked on expr of invalid type {:?}", datum.ty)); } }; diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs index 37541dee7d9d1..883b972872f50 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -122,20 +122,21 @@ impl<'tcx> CastCheck<'tcx> { CastError::NeedViaInt | CastError::NeedViaUsize => { fcx.type_error_message(self.span, |actual| { - format!("illegal cast; cast through {} first: `{}` as `{}`", - match e { - CastError::NeedViaPtr => "a raw pointer", - CastError::NeedViaInt => "an integer", - CastError::NeedViaUsize => "a usize", - _ => unreachable!() - }, + format!("casting `{}` as `{}` is invalid", actual, fcx.infcx().ty_to_string(self.cast_ty)) - }, self.expr_ty, None) + }, self.expr_ty, None); + fcx.ccx.tcx.sess.fileline_help(self.span, + &format!("cast through {} first", match e { + CastError::NeedViaPtr => "a raw pointer", + CastError::NeedViaInt => "an integer", + CastError::NeedViaUsize => "a usize", + _ => unreachable!() + })); } CastError::CastToBool => { - span_err!(fcx.tcx().sess, self.span, E0054, - "cannot cast as `bool`, compare with zero instead"); + span_err!(fcx.tcx().sess, self.span, E0054, "cannot cast as `bool`"); + fcx.ccx.tcx.sess.fileline_help(self.span, "compare with zero instead"); } CastError::CastToChar => { fcx.type_error_message(self.span, |actual| { @@ -151,17 +152,18 @@ impl<'tcx> CastCheck<'tcx> { } CastError::IllegalCast => { fcx.type_error_message(self.span, |actual| { - format!("illegal cast: `{}` as `{}`", + format!("casting `{}` as `{}` is invalid", actual, fcx.infcx().ty_to_string(self.cast_ty)) }, self.expr_ty, None); } CastError::DifferingKinds => { fcx.type_error_message(self.span, |actual| { - format!("illegal cast: `{}` as `{}`; vtable kinds may not match", + format!("casting `{}` as `{}` is invalid", actual, fcx.infcx().ty_to_string(self.cast_ty)) }, self.expr_ty, None); + fcx.ccx.tcx.sess.fileline_note(self.span, "vtable kinds may not match"); } } } @@ -285,7 +287,7 @@ impl<'tcx> CastCheck<'tcx> { return Ok(CastKind::PtrPtrCast); } - // sized -> unsized? report illegal cast (don't complain about vtable kinds) + // sized -> unsized? report invalid cast (don't complain about vtable kinds) if fcx.type_is_known_to_be_sized(m_expr.ty, self.span) { return Err(CastError::IllegalCast); } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index add46f7efb9ec..819f443729796 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3468,7 +3468,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>, let tcx = fcx.tcx(); if !tcx.expr_is_lval(&**lhs) { span_err!(tcx.sess, expr.span, E0070, - "illegal left-hand side expression"); + "invalid left-hand side expression"); } let lhs_ty = fcx.expr_ty(&**lhs); @@ -4273,10 +4273,8 @@ pub fn check_representable(tcx: &ty::ctxt, // caught by case 1. match rty.is_representable(tcx, sp) { ty::SelfRecursive => { - span_err!(tcx.sess, sp, E0072, - "illegal recursive {} type; \ - wrap the inner value in a box to make it representable", - designation); + span_err!(tcx.sess, sp, E0072, "invalid recursive {} type", designation); + tcx.sess.fileline_help(sp, "wrap the inner value in a box to make it representable"); return false } ty::Representable | ty::ContainsRecursive => (), diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index c419a986f95b1..c6d13d3b0a5ca 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -57,7 +57,7 @@ pub fn check_binop_assign<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, let tcx = fcx.tcx(); if !tcx.expr_is_lval(lhs_expr) { - span_err!(tcx.sess, lhs_expr.span, E0067, "illegal left-hand side expression"); + span_err!(tcx.sess, lhs_expr.span, E0067, "invalid left-hand side expression"); } fcx.require_expr_have_sized_type(lhs_expr, traits::AssignmentLhsSized); diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index bbeb907fd18b3..40ea63e3cf9b4 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -778,7 +778,7 @@ the pointer the size of the type would need to be unbounded. Consider the following erroneous definition of a type for a list of bytes: ``` -// error, illegal recursive struct type +// error, invalid recursive struct type struct ListNode { head: u8, tail: Option, @@ -1264,7 +1264,7 @@ impl From for i32 { // or you use a type from your crate as E0119: r##" There are conflicting trait implementations for the same type. -Erroneous code example: +Example of erroneous code: ``` trait MyTrait { @@ -1285,7 +1285,10 @@ impl MyTrait for Foo { // error: conflicting implementations for trait } ``` -When you write: +When looking for the implementation for the trait, the compiler finds +both the `impl MyTrait for T` where T is all types and the `impl +MyTrait for Foo`. Since a trait cannot be implemented multiple times, +this is an error. So, when you write: ``` impl MyTrait for T { @@ -2362,7 +2365,7 @@ register_diagnostics! { E0241, E0242, // internal error looking up a definition E0245, // not a trait - E0246, // illegal recursive type + E0246, // invalid recursive type E0247, // found module name used as a type E0248, // found value name used as a type E0319, // trait impls for defaulted traits allowed just for structs/enums diff --git a/src/librustc_unicode/char.rs b/src/librustc_unicode/char.rs index 34b0ae18d4fe8..815c1ed4fff99 100644 --- a/src/librustc_unicode/char.rs +++ b/src/librustc_unicode/char.rs @@ -278,7 +278,8 @@ impl char { /// In both of these examples, 'ß' takes two bytes to encode. /// /// ``` - /// # #![feature(unicode)] + /// #![feature(unicode)] + /// /// let mut b = [0; 2]; /// /// let result = 'ß'.encode_utf8(&mut b); @@ -289,7 +290,8 @@ impl char { /// A buffer that's too small: /// /// ``` - /// # #![feature(unicode)] + /// #![feature(unicode)] + /// /// let mut b = [0; 1]; /// /// let result = 'ß'.encode_utf8(&mut b); @@ -315,7 +317,8 @@ impl char { /// In both of these examples, 'ß' takes one `u16` to encode. /// /// ``` - /// # #![feature(unicode)] + /// #![feature(unicode)] + /// /// let mut b = [0; 1]; /// /// let result = 'ß'.encode_utf16(&mut b); @@ -326,7 +329,8 @@ impl char { /// A buffer that's too small: /// /// ``` - /// # #![feature(unicode)] + /// #![feature(unicode)] + /// /// let mut b = [0; 0]; /// /// let result = 'ß'.encode_utf8(&mut b); diff --git a/src/librustc_unicode/u_str.rs b/src/librustc_unicode/u_str.rs index f4c85f18a7e67..e329785d2719b 100644 --- a/src/librustc_unicode/u_str.rs +++ b/src/librustc_unicode/u_str.rs @@ -494,7 +494,8 @@ impl<'a> Iterator for Utf16Items<'a> { /// # Examples /// /// ``` -/// # #![feature(unicode)] +/// #![feature(unicode)] +/// /// extern crate rustc_unicode; /// /// use rustc_unicode::str::Utf16Item::{ScalarValue, LoneSurrogate}; diff --git a/src/libserialize/hex.rs b/src/libserialize/hex.rs index 87f1dca2caed0..609ebe8546164 100644 --- a/src/libserialize/hex.rs +++ b/src/libserialize/hex.rs @@ -30,7 +30,8 @@ impl ToHex for [u8] { /// # Examples /// /// ``` - /// # #![feature(rustc_private)] + /// #![feature(rustc_private)] + /// /// extern crate serialize; /// use serialize::hex::ToHex; /// @@ -100,7 +101,8 @@ impl FromHex for str { /// This converts a string literal to hexadecimal and back. /// /// ``` - /// # #![feature(rustc_private)] + /// #![feature(rustc_private)] + /// /// extern crate serialize; /// use serialize::hex::{FromHex, ToHex}; /// diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index ac98282ebb86b..cd9dadd1be9e6 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -125,7 +125,8 @@ pub trait AsciiExt { /// # Examples /// /// ``` - /// # #![feature(ascii)] + /// #![feature(ascii)] + /// /// use std::ascii::AsciiExt; /// /// let mut ascii = 'a'; @@ -144,7 +145,8 @@ pub trait AsciiExt { /// # Examples /// /// ``` - /// # #![feature(ascii)] + /// #![feature(ascii)] + /// /// use std::ascii::AsciiExt; /// /// let mut ascii = 'A'; diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 06a30670e8b22..66f894fc31fb0 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -543,7 +543,8 @@ impl HashMap /// # Examples /// /// ``` - /// # #![feature(hashmap_hasher)] + /// #![feature(hashmap_hasher)] + /// /// use std::collections::HashMap; /// use std::collections::hash_map::RandomState; /// @@ -572,7 +573,8 @@ impl HashMap /// # Examples /// /// ``` - /// # #![feature(hashmap_hasher)] + /// #![feature(hashmap_hasher)] + /// /// use std::collections::HashMap; /// use std::collections::hash_map::RandomState; /// @@ -979,7 +981,8 @@ impl HashMap /// # Examples /// /// ``` - /// # #![feature(drain)] + /// #![feature(drain)] + /// /// use std::collections::HashMap; /// /// let mut a = HashMap::new(); diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index ba50b156ab230..fb594dadd738b 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -154,7 +154,8 @@ impl HashSet /// # Examples /// /// ``` - /// # #![feature(hashmap_hasher)] + /// #![feature(hashmap_hasher)] + /// /// use std::collections::HashSet; /// use std::collections::hash_map::RandomState; /// @@ -179,7 +180,8 @@ impl HashSet /// # Examples /// /// ``` - /// # #![feature(hashmap_hasher)] + /// #![feature(hashmap_hasher)] + /// /// use std::collections::HashSet; /// use std::collections::hash_map::RandomState; /// diff --git a/src/libstd/io/buffered.rs b/src/libstd/io/buffered.rs index 29d1fe19adf61..eca6ffc8ce39b 100644 --- a/src/libstd/io/buffered.rs +++ b/src/libstd/io/buffered.rs @@ -407,8 +407,6 @@ impl BufWriter { /// Gets a mutable reference to the underlying writer. /// - /// # Warning - /// /// It is inadvisable to directly write to the underlying writer. /// /// # Examples @@ -835,8 +833,6 @@ impl BufStream { /// Gets a mutable reference to the underlying stream. /// - /// # Warning - /// /// It is inadvisable to read directly from or write directly to the /// underlying stream. pub fn get_mut(&mut self) -> &mut S { diff --git a/src/libstd/io/cursor.rs b/src/libstd/io/cursor.rs index 4bb7d2ebd1963..980ec51c92652 100644 --- a/src/libstd/io/cursor.rs +++ b/src/libstd/io/cursor.rs @@ -15,10 +15,8 @@ use cmp; use io::{self, SeekFrom, Error, ErrorKind}; use slice; -/// A `Cursor` wraps another type and provides it with a [`Seek`][seek] -/// implementation. -/// -/// [seek]: trait.Seek.html +/// A `Cursor` wraps another type and provides it with a +/// [`Seek`](trait.Seek.html) implementation. /// /// Cursors are typically used with in-memory buffers to allow them to /// implement `Read` and/or `Write`, allowing these buffers to be used diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index ffdd75b0e6e0f..f811aa1be4ee3 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -707,7 +707,7 @@ pub trait Read { /// /// # fn foo() -> io::Result<()> { /// let mut f = try!(File::open("foo.txt")); - /// let mut buffer = [0; 10]; + /// let mut buffer = [0; 5]; /// /// // read at most five bytes /// let mut handle = f.take(5); diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index dc29811ed5ba1..6e651464c74fc 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -105,7 +105,7 @@ impl BufRead for Empty { /// This struct is generally created by calling [`repeat()`][repeat]. Please /// see the documentation of `repeat()` for more details. /// -/// [empty]: fn.repeat.html +/// [repeat]: fn.repeat.html #[stable(feature = "rust1", since = "1.0.0")] pub struct Repeat { byte: u8 } @@ -131,7 +131,7 @@ impl Read for Repeat { /// This struct is generally created by calling [`sink()`][sink]. Please /// see the documentation of `sink()` for more details. /// -/// [empty]: fn.sink.html +/// [sink]: fn.sink.html #[stable(feature = "rust1", since = "1.0.0")] pub struct Sink { _priv: () } diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 697b934c6760d..eb378bf408028 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -141,7 +141,8 @@ macro_rules! try { /// # Examples /// /// ``` -/// # #![feature(mpsc_select)] +/// #![feature(mpsc_select)] +/// /// use std::thread; /// use std::sync::mpsc; /// diff --git a/src/libstd/net/mod.rs b/src/libstd/net/mod.rs index 1cb8c18703031..c7daf5cdee56a 100644 --- a/src/libstd/net/mod.rs +++ b/src/libstd/net/mod.rs @@ -103,7 +103,8 @@ impl Iterator for LookupHost { /// # Examples /// /// ```no_run -/// # #![feature(lookup_host)] +/// #![feature(lookup_host)] +/// /// use std::net; /// /// # fn foo() -> std::io::Result<()> { diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index 9d0b9c3bbb416..73d6639cf00d7 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -235,7 +235,8 @@ impl f32 { /// The floating point encoding is documented in the [Reference][floating-point]. /// /// ``` - /// # #![feature(float_extras)] + /// #![feature(float_extras)] + /// /// use std::f32; /// /// let num = 2.0f32; @@ -598,7 +599,8 @@ impl f32 { /// Converts radians to degrees. /// /// ``` - /// # #![feature(float_extras)] + /// #![feature(float_extras)] + /// /// use std::f32::{self, consts}; /// /// let angle = consts::PI; @@ -614,7 +616,8 @@ impl f32 { /// Converts degrees to radians. /// /// ``` - /// # #![feature(float_extras)] + /// #![feature(float_extras)] + /// /// use std::f32::{self, consts}; /// /// let angle = 180.0f32; @@ -630,7 +633,8 @@ impl f32 { /// Constructs a floating point number of `x*2^exp`. /// /// ``` - /// # #![feature(float_extras)] + /// #![feature(float_extras)] + /// /// use std::f32; /// // 3*2^2 - 12 == 0 /// let abs_difference = (f32::ldexp(3.0, 2) - 12.0).abs(); @@ -651,7 +655,8 @@ impl f32 { /// * `0.5 <= abs(x) < 1.0` /// /// ``` - /// # #![feature(float_extras)] + /// #![feature(float_extras)] + /// /// use std::f32; /// /// let x = 4.0f32; @@ -679,7 +684,8 @@ impl f32 { /// `other`. /// /// ``` - /// # #![feature(float_extras)] + /// #![feature(float_extras)] + /// /// use std::f32; /// /// let x = 1.0f32; diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index 4f2f59659ac80..3911d276b0f3c 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -191,7 +191,8 @@ impl f64 { /// The floating point encoding is documented in the [Reference][floating-point]. /// /// ``` - /// # #![feature(float_extras)] + /// #![feature(float_extras)] + /// /// let num = 2.0f64; /// /// // (8388608, -22, 1) @@ -568,7 +569,8 @@ impl f64 { /// Constructs a floating point number of `x*2^exp`. /// /// ``` - /// # #![feature(float_extras)] + /// #![feature(float_extras)] + /// /// // 3*2^2 - 12 == 0 /// let abs_difference = (f64::ldexp(3.0, 2) - 12.0).abs(); /// @@ -588,7 +590,8 @@ impl f64 { /// * `0.5 <= abs(x) < 1.0` /// /// ``` - /// # #![feature(float_extras)] + /// #![feature(float_extras)] + /// /// let x = 4.0_f64; /// /// // (1/2)*2^3 -> 1 * 8/2 -> 4.0 @@ -614,7 +617,7 @@ impl f64 { /// `other`. /// /// ``` - /// # #![feature(float_extras)] + /// #![feature(float_extras)] /// /// let x = 1.0f32; /// diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs index 066b2b576da49..7f14ea93c5269 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs @@ -111,7 +111,8 @@ mod prim_unit { } /// the raw pointer. It doesn't destroy `T` or deallocate any memory. /// /// ``` -/// # #![feature(box_raw)] +/// #![feature(box_raw)] +/// /// let my_speed: Box = Box::new(88); /// let my_speed: *mut i32 = Box::into_raw(my_speed); /// diff --git a/src/libstd/sync/condvar.rs b/src/libstd/sync/condvar.rs index f2c389f9426eb..79b3dfa67b1cf 100644 --- a/src/libstd/sync/condvar.rs +++ b/src/libstd/sync/condvar.rs @@ -69,7 +69,8 @@ pub struct Condvar { inner: Box } /// # Examples /// /// ``` -/// # #![feature(static_condvar)] +/// #![feature(static_condvar)] +/// /// use std::sync::{StaticCondvar, CONDVAR_INIT}; /// /// static CVAR: StaticCondvar = CONDVAR_INIT; diff --git a/src/libstd/sync/future.rs b/src/libstd/sync/future.rs index 28dc124f0334f..b87a275682944 100644 --- a/src/libstd/sync/future.rs +++ b/src/libstd/sync/future.rs @@ -14,7 +14,8 @@ //! # Examples //! //! ``` -//! # #![feature(future)] +//! #![feature(future)] +//! //! use std::sync::Future; //! //! // a fake, for now diff --git a/src/libstd/sync/mpsc/select.rs b/src/libstd/sync/mpsc/select.rs index a67138742aeeb..ee1516342ad05 100644 --- a/src/libstd/sync/mpsc/select.rs +++ b/src/libstd/sync/mpsc/select.rs @@ -27,7 +27,8 @@ //! # Examples //! //! ```rust -//! # #![feature(mpsc_select)] +//! #![feature(mpsc_select)] +//! //! use std::sync::mpsc::channel; //! //! let (tx1, rx1) = channel(); @@ -124,7 +125,8 @@ impl Select { /// # Examples /// /// ``` - /// # #![feature(mpsc_select)] + /// #![feature(mpsc_select)] + /// /// use std::sync::mpsc::Select; /// /// let select = Select::new(); diff --git a/src/libstd/sync/mutex.rs b/src/libstd/sync/mutex.rs index 41cd11e4c6900..4b62434d06894 100644 --- a/src/libstd/sync/mutex.rs +++ b/src/libstd/sync/mutex.rs @@ -138,7 +138,8 @@ unsafe impl Sync for Mutex { } /// # Examples /// /// ``` -/// # #![feature(static_mutex)] +/// #![feature(static_mutex)] +/// /// use std::sync::{StaticMutex, MUTEX_INIT}; /// /// static LOCK: StaticMutex = MUTEX_INIT; diff --git a/src/libstd/sync/rwlock.rs b/src/libstd/sync/rwlock.rs index 4ca2e282f707d..40d5af49156dd 100644 --- a/src/libstd/sync/rwlock.rs +++ b/src/libstd/sync/rwlock.rs @@ -81,7 +81,8 @@ unsafe impl Sync for RwLock {} /// # Examples /// /// ``` -/// # #![feature(static_rwlock)] +/// #![feature(static_rwlock)] +/// /// use std::sync::{StaticRwLock, RW_LOCK_INIT}; /// /// static LOCK: StaticRwLock = RW_LOCK_INIT; diff --git a/src/libstd/sync/semaphore.rs b/src/libstd/sync/semaphore.rs index dc9e467a8b135..907df69bfb07a 100644 --- a/src/libstd/sync/semaphore.rs +++ b/src/libstd/sync/semaphore.rs @@ -25,7 +25,8 @@ use sync::{Mutex, Condvar}; /// # Examples /// /// ``` -/// # #![feature(semaphore)] +/// #![feature(semaphore)] +/// /// use std::sync::Semaphore; /// /// // Create a semaphore that represents 5 resources diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index 3388968c56cc1..2683f8e5022bb 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -367,7 +367,8 @@ pub fn spawn(f: F) -> JoinHandle where /// a join before any relevant stack frames are popped: /// /// ```rust -/// # #![feature(scoped)] +/// #![feature(scoped)] +/// /// use std::thread; /// /// let guard = thread::scoped(move || { @@ -447,7 +448,8 @@ pub fn panicking() -> bool { /// # Examples /// /// ``` -/// # #![feature(catch_panic)] +/// #![feature(catch_panic)] +/// /// use std::thread; /// /// let result = thread::catch_panic(|| { diff --git a/src/libstd/thread/scoped_tls.rs b/src/libstd/thread/scoped_tls.rs index c2fad0aa89c93..4fbfdec8e7ec8 100644 --- a/src/libstd/thread/scoped_tls.rs +++ b/src/libstd/thread/scoped_tls.rs @@ -24,7 +24,8 @@ //! # Examples //! //! ``` -//! # #![feature(scoped_tls)] +//! #![feature(scoped_tls)] +//! //! scoped_thread_local!(static FOO: u32); //! //! // Initially each scoped slot is empty. @@ -136,7 +137,8 @@ impl ScopedKey { /// # Examples /// /// ``` - /// # #![feature(scoped_tls)] + /// #![feature(scoped_tls)] + /// /// scoped_thread_local!(static FOO: u32); /// /// FOO.set(&100, || { @@ -189,7 +191,8 @@ impl ScopedKey { /// # Examples /// /// ```no_run - /// # #![feature(scoped_tls)] + /// #![feature(scoped_tls)] + /// /// scoped_thread_local!(static FOO: u32); /// /// FOO.with(|slot| { diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 621335ecd979c..019a8404dfb0d 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -694,7 +694,7 @@ impl<'a> StringReader<'a> { accum_int *= 16; accum_int += c.to_digit(16).unwrap_or_else(|| { self.err_span_char(self.last_pos, self.pos, - "illegal character in numeric character escape", c); + "invalid character in numeric character escape", c); valid = false; 0 @@ -714,7 +714,7 @@ impl<'a> StringReader<'a> { Some(_) => valid, None => { let last_bpos = self.last_pos; - self.err_span_(start_bpos, last_bpos, "illegal numeric character escape"); + self.err_span_(start_bpos, last_bpos, "invalid numeric character escape"); false } } @@ -846,7 +846,7 @@ impl<'a> StringReader<'a> { "unterminated unicode escape (needed a `}`)"); } else { self.err_span_char(self.last_pos, self.pos, - "illegal character in unicode escape", c); + "invalid character in unicode escape", c); } valid = false; 0 @@ -862,7 +862,7 @@ impl<'a> StringReader<'a> { } if valid && (char::from_u32(accum_int).is_none() || count == 0) { - self.err_span_(start_bpos, self.last_pos, "illegal unicode character escape"); + self.err_span_(start_bpos, self.last_pos, "invalid unicode character escape"); valid = false; } @@ -1138,8 +1138,8 @@ impl<'a> StringReader<'a> { let last_bpos = self.last_pos; let curr_char = self.curr.unwrap(); self.fatal_span_char(start_bpos, last_bpos, - "only `#` is allowed in raw string delimitation; \ - found illegal character", + "found invalid character; \ + only `#` is allowed in raw string delimitation", curr_char); } self.bump(); @@ -1323,8 +1323,8 @@ impl<'a> StringReader<'a> { let last_pos = self.last_pos; let ch = self.curr.unwrap(); self.fatal_span_char(start_bpos, last_pos, - "only `#` is allowed in raw string delimitation; \ - found illegal character", + "found invalid character; \ + only `#` is allowed in raw string delimitation", ch); } self.bump(); diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 70da512e89885..c5a73601d895c 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -446,11 +446,11 @@ fn filtered_float_lit(data: token::InternedString, suffix: Option<&str>, Some(suf) => { if suf.len() >= 2 && looks_like_width_suffix(&['f'], suf) { // if it looks like a width, lets try to be helpful. - sd.span_err(sp, &*format!("illegal width `{}` for float literal, \ - valid widths are 32 and 64", &suf[1..])); + sd.span_err(sp, &*format!("invalid width `{}` for float literal", &suf[1..])); + sd.fileline_help(sp, "valid widths are 32 and 64"); } else { - sd.span_err(sp, &*format!("illegal suffix `{}` for float literal, \ - valid suffixes are `f32` and `f64`", suf)); + sd.span_err(sp, &*format!("invalid suffix `{}` for float literal", suf)); + sd.fileline_help(sp, "valid suffixes are `f32` and `f64`"); } ast::LitFloatUnsuffixed(data) @@ -619,11 +619,11 @@ pub fn integer_lit(s: &str, // i and u look like widths, so lets // give an error message along those lines if looks_like_width_suffix(&['i', 'u'], suf) { - sd.span_err(sp, &*format!("illegal width `{}` for integer literal; \ - valid widths are 8, 16, 32 and 64", + sd.span_err(sp, &*format!("invalid width `{}` for integer literal", &suf[1..])); + sd.fileline_help(sp, "valid widths are 8, 16, 32 and 64"); } else { - sd.span_err(sp, &*format!("illegal suffix `{}` for numeric literal", suf)); + sd.span_err(sp, &*format!("invalid suffix `{}` for numeric literal", suf)); sd.fileline_help(sp, "the suffix must be one of the integral types \ (`u32`, `isize`, etc)"); } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 2cae6a4be6520..11611c9adb0bc 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -681,7 +681,7 @@ impl<'a> Parser<'a> { if text.is_empty() { self.span_bug(sp, "found empty literal suffix in Some") } - self.span_err(sp, &*format!("{} with a suffix is illegal", kind)); + self.span_err(sp, &*format!("{} with a suffix is invalid", kind)); } } } @@ -5286,7 +5286,7 @@ impl<'a> Parser<'a> { let last_span = self.last_span; self.span_err( last_span, - &format!("illegal ABI: expected one of [{}], \ + &format!("invalid ABI: expected one of [{}], \ found `{}`", abi::all_names().join(", "), s)); diff --git a/src/test/compile-fail/bad-expr-lhs.rs b/src/test/compile-fail/bad-expr-lhs.rs index 6907bf4b5b813..c7d2f2c472f49 100644 --- a/src/test/compile-fail/bad-expr-lhs.rs +++ b/src/test/compile-fail/bad-expr-lhs.rs @@ -9,12 +9,12 @@ // except according to those terms. fn main() { - 1 = 2; //~ ERROR illegal left-hand side expression - 1 += 2; //~ ERROR illegal left-hand side expression - (1, 2) = (3, 4); //~ ERROR illegal left-hand side expression + 1 = 2; //~ ERROR invalid left-hand side expression + 1 += 2; //~ ERROR invalid left-hand side expression + (1, 2) = (3, 4); //~ ERROR invalid left-hand side expression let (a, b) = (1, 2); - (a, b) = (3, 4); //~ ERROR illegal left-hand side expression + (a, b) = (3, 4); //~ ERROR invalid left-hand side expression - None = Some(3); //~ ERROR illegal left-hand side expression + None = Some(3); //~ ERROR invalid left-hand side expression } diff --git a/src/test/compile-fail/cast-as-bool.rs b/src/test/compile-fail/cast-as-bool.rs index 6d68f56b2b18a..92cbbaa1cb442 100644 --- a/src/test/compile-fail/cast-as-bool.rs +++ b/src/test/compile-fail/cast-as-bool.rs @@ -8,5 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern: cannot cast as `bool`, compare with zero instead -fn main() { let u = (5 as bool); } +fn main() { + let u = (5 as bool); + //~^ ERROR cannot cast as `bool` + //~^^ HELP compare with zero instead +} diff --git a/src/test/compile-fail/cast-rfc0401.rs b/src/test/compile-fail/cast-rfc0401.rs index 29ce8c15143f5..7fca4aece69b8 100644 --- a/src/test/compile-fail/cast-rfc0401.rs +++ b/src/test/compile-fail/cast-rfc0401.rs @@ -10,12 +10,16 @@ fn illegal_cast(u: *const U) -> *const V { - u as *const V //~ ERROR vtable kinds + u as *const V + //~^ ERROR casting + //~^^ NOTE vtable kinds } fn illegal_cast_2(u: *const U) -> *const str { - u as *const str //~ ERROR vtable kinds + u as *const str + //~^ ERROR casting + //~^^ NOTE vtable kinds } trait Foo { fn foo(&self) {} } @@ -41,32 +45,58 @@ fn main() let _ = v as (u32,); //~ ERROR non-scalar let _ = Some(&v) as *const u8; //~ ERROR non-scalar - let _ = v as f32; //~ ERROR through a usize first - let _ = main as f64; //~ ERROR through a usize first - let _ = &v as usize; //~ ERROR through a raw pointer first - let _ = f as *const u8; //~ ERROR through a usize first - let _ = 3 as bool; //~ ERROR compare with zero - let _ = E::A as bool; //~ ERROR compare with zero + let _ = v as f32; + //~^ ERROR casting + //~^^ HELP through a usize first + let _ = main as f64; + //~^ ERROR casting + //~^^ HELP through a usize first + let _ = &v as usize; + //~^ ERROR casting + //~^^ HELP through a raw pointer first + let _ = f as *const u8; + //~^ ERROR casting + //~^^ HELP through a usize first + let _ = 3 as bool; + //~^ ERROR cannot cast as `bool` + //~^^ HELP compare with zero + let _ = E::A as bool; + //~^ ERROR cannot cast as `bool` + //~^^ HELP compare with zero let _ = 0x61u32 as char; //~ ERROR only `u8` can be cast - let _ = false as f32; //~ ERROR through an integer first - let _ = E::A as f32; //~ ERROR through an integer first - let _ = 'a' as f32; //~ ERROR through an integer first + let _ = false as f32; + //~^ ERROR casting + //~^^ HELP through an integer first + let _ = E::A as f32; + //~^ ERROR casting + //~^^ HELP through an integer first + let _ = 'a' as f32; + //~^ ERROR casting + //~^^ HELP through an integer first - let _ = false as *const u8; //~ ERROR through a usize first - let _ = E::A as *const u8; //~ ERROR through a usize first - let _ = 'a' as *const u8; //~ ERROR through a usize first + let _ = false as *const u8; + //~^ ERROR casting + //~^^ HELP through a usize first + let _ = E::A as *const u8; + //~^ ERROR casting + //~^^ HELP through a usize first + let _ = 'a' as *const u8; + //~^ ERROR casting + //~^^ HELP through a usize first - let _ = 42usize as *const [u8]; //~ ERROR illegal cast - let _ = v as *const [u8]; //~ ERROR illegal cast + let _ = 42usize as *const [u8]; //~ ERROR casting + let _ = v as *const [u8]; //~ ERROR casting let _ = fat_v as *const Foo; //~^ ERROR `core::marker::Sized` is not implemented for the type `[u8]` - let _ = foo as *const str; //~ ERROR illegal cast - let _ = foo as *mut str; //~ ERROR illegal cast - let _ = main as *mut str; //~ ERROR illegal cast - let _ = &f as *mut f32; //~ ERROR illegal cast - let _ = &f as *const f64; //~ ERROR illegal cast - let _ = fat_v as usize; //~ ERROR through a raw pointer first + let _ = foo as *const str; //~ ERROR casting + let _ = foo as *mut str; //~ ERROR casting + let _ = main as *mut str; //~ ERROR casting + let _ = &f as *mut f32; //~ ERROR casting + let _ = &f as *const f64; //~ ERROR casting + let _ = fat_v as usize; + //~^ ERROR casting + //~^^ HELP through a raw pointer first let a : *const str = "hello"; let _ = a as *const Foo; @@ -76,6 +106,10 @@ fn main() let _ = main.f as *const u32; //~ ERROR attempted access of field let cf: *const Foo = &0; - let _ = cf as *const [u8]; //~ ERROR vtable kinds - let _ = cf as *const Bar; //~ ERROR vtable kinds + let _ = cf as *const [u8]; + //~^ ERROR casting + //~^^ NOTE vtable kinds + let _ = cf as *const Bar; + //~^ ERROR casting + //~^^ NOTE vtable kinds } diff --git a/src/test/compile-fail/const-cast-different-types.rs b/src/test/compile-fail/const-cast-different-types.rs index e6851f02cb607..397804566b4ae 100644 --- a/src/test/compile-fail/const-cast-different-types.rs +++ b/src/test/compile-fail/const-cast-different-types.rs @@ -9,8 +9,8 @@ // except according to those terms. static a: &'static str = "foo"; -static b: *const u8 = a as *const u8; //~ ERROR illegal cast -static c: *const u8 = &a as *const u8; //~ ERROR illegal cast +static b: *const u8 = a as *const u8; //~ ERROR casting +static c: *const u8 = &a as *const u8; //~ ERROR casting fn main() { } diff --git a/src/test/compile-fail/enum-to-float-cast-2.rs b/src/test/compile-fail/enum-to-float-cast-2.rs index 7ee671317559b..e6f473c8aacbb 100644 --- a/src/test/compile-fail/enum-to-float-cast-2.rs +++ b/src/test/compile-fail/enum-to-float-cast-2.rs @@ -21,8 +21,8 @@ enum F { } pub fn main() { - let a = E::L0 as f32; //~ ERROR illegal cast - let c = F::H1 as f32; //~ ERROR illegal cast + let a = E::L0 as f32; //~ ERROR casting + let c = F::H1 as f32; //~ ERROR casting assert_eq!(a, -1.0f32); assert_eq!(c, -1.0f32); } diff --git a/src/test/compile-fail/enum-to-float-cast.rs b/src/test/compile-fail/enum-to-float-cast.rs index 225b8702302a8..b562ba0e41afd 100644 --- a/src/test/compile-fail/enum-to-float-cast.rs +++ b/src/test/compile-fail/enum-to-float-cast.rs @@ -20,8 +20,8 @@ enum F { H1 = 0xFFFFFFFFFFFFFFFF } -static C0: f32 = E::L0 as f32; //~ ERROR illegal cast -static C1: f32 = F::H1 as f32; //~ ERROR illegal cast +static C0: f32 = E::L0 as f32; //~ ERROR casting +static C1: f32 = F::H1 as f32; //~ ERROR casting pub fn main() { let b = C0; diff --git a/src/test/compile-fail/fat-ptr-cast.rs b/src/test/compile-fail/fat-ptr-cast.rs index 25cab09b7cb49..3746f29ea55d6 100644 --- a/src/test/compile-fail/fat-ptr-cast.rs +++ b/src/test/compile-fail/fat-ptr-cast.rs @@ -17,14 +17,16 @@ fn main() { let p = a as *const [i32]; let q = a.as_ptr(); - a as usize; //~ ERROR illegal cast + a as usize; //~ ERROR casting b as usize; //~ ERROR non-scalar cast - p as usize; //~ ERROR illegal cast; cast through a raw pointer + p as usize; + //~^ ERROR casting + //~^^ HELP cast through a raw pointer // #22955 - q as *const [i32]; //~ ERROR illegal cast + q as *const [i32]; //~ ERROR casting // #21397 - let t: *mut (Trait + 'static) = 0 as *mut _; //~ ERROR illegal cast - let mut fail: *const str = 0 as *const str; //~ ERROR illegal cast + let t: *mut (Trait + 'static) = 0 as *mut _; //~ ERROR casting + let mut fail: *const str = 0 as *const str; //~ ERROR casting } diff --git a/src/test/compile-fail/infinite-tag-type-recursion.rs b/src/test/compile-fail/infinite-tag-type-recursion.rs index a57c015d684b6..7dbf75feda054 100644 --- a/src/test/compile-fail/infinite-tag-type-recursion.rs +++ b/src/test/compile-fail/infinite-tag-type-recursion.rs @@ -9,7 +9,7 @@ // except according to those terms. -// error-pattern: illegal recursive enum type; wrap the inner value in a box +// error-pattern: invalid recursive enum type enum mlist { cons(isize, mlist), nil, } diff --git a/src/test/compile-fail/issue-13407.rs b/src/test/compile-fail/issue-13407.rs index f845eba406041..311280bd49760 100644 --- a/src/test/compile-fail/issue-13407.rs +++ b/src/test/compile-fail/issue-13407.rs @@ -14,6 +14,6 @@ mod A { fn main() { A::C = 1; - //~^ ERROR: illegal left-hand side expression + //~^ ERROR: invalid left-hand side expression //~| ERROR: mismatched types } diff --git a/src/test/compile-fail/issue-14845.rs b/src/test/compile-fail/issue-14845.rs index 219f08ad35a84..74f0833e8d11c 100644 --- a/src/test/compile-fail/issue-14845.rs +++ b/src/test/compile-fail/issue-14845.rs @@ -15,8 +15,8 @@ struct X { fn main() { let x = X { a: [0] }; - let _f = &x.a as *mut u8; //~ ERROR illegal cast + let _f = &x.a as *mut u8; //~ ERROR casting let local: [u8; 1] = [0]; - let _v = &local as *mut u8; //~ ERROR illegal cast + let _v = &local as *mut u8; //~ ERROR casting } diff --git a/src/test/compile-fail/issue-17431-1.rs b/src/test/compile-fail/issue-17431-1.rs index 896a9c06873e9..bd3f283505870 100644 --- a/src/test/compile-fail/issue-17431-1.rs +++ b/src/test/compile-fail/issue-17431-1.rs @@ -9,7 +9,7 @@ // except according to those terms. struct Foo { foo: Option> } -//~^ ERROR illegal recursive struct type; wrap the inner value in a box to make it representable +//~^ ERROR invalid recursive struct type impl Foo { fn bar(&self) {} } diff --git a/src/test/compile-fail/issue-17431-2.rs b/src/test/compile-fail/issue-17431-2.rs index 886fe8d771a8c..4e1c0d6571d16 100644 --- a/src/test/compile-fail/issue-17431-2.rs +++ b/src/test/compile-fail/issue-17431-2.rs @@ -9,10 +9,10 @@ // except according to those terms. struct Baz { q: Option } -//~^ ERROR illegal recursive struct type; wrap the inner value in a box to make it representable +//~^ ERROR invalid recursive struct type struct Foo { q: Option } -//~^ ERROR illegal recursive struct type; wrap the inner value in a box to make it representable +//~^ ERROR invalid recursive struct type impl Foo { fn bar(&self) {} } diff --git a/src/test/compile-fail/issue-17431-3.rs b/src/test/compile-fail/issue-17431-3.rs index c1c450935f6cb..07c5f106456d1 100644 --- a/src/test/compile-fail/issue-17431-3.rs +++ b/src/test/compile-fail/issue-17431-3.rs @@ -11,7 +11,7 @@ use std::sync::Mutex; struct Foo { foo: Mutex> } -//~^ ERROR illegal recursive struct type; wrap the inner value in a box to make it representable +//~^ ERROR invalid recursive struct type impl Foo { fn bar(&self) {} } diff --git a/src/test/compile-fail/issue-17431-4.rs b/src/test/compile-fail/issue-17431-4.rs index 22aaa796ad0f4..74952d9ca2b38 100644 --- a/src/test/compile-fail/issue-17431-4.rs +++ b/src/test/compile-fail/issue-17431-4.rs @@ -11,7 +11,7 @@ use std::marker; struct Foo { foo: Option>>, marker: marker::PhantomData } -//~^ ERROR illegal recursive struct type; wrap the inner value in a box to make it representable +//~^ ERROR invalid recursive struct type impl Foo { fn bar(&self) {} } diff --git a/src/test/compile-fail/issue-17431-5.rs b/src/test/compile-fail/issue-17431-5.rs index cc9cc2e3c035c..157b5ed434e9f 100644 --- a/src/test/compile-fail/issue-17431-5.rs +++ b/src/test/compile-fail/issue-17431-5.rs @@ -12,7 +12,7 @@ use std::marker; struct Foo { foo: Bar } struct Bar { x: Bar , marker: marker::PhantomData } -//~^ ERROR illegal recursive struct type; wrap the inner value in a box to make it representable +//~^ ERROR invalid recursive struct type impl Foo { fn foo(&self) {} } diff --git a/src/test/compile-fail/issue-17431-6.rs b/src/test/compile-fail/issue-17431-6.rs index 8eac295353d27..b2037378d3787 100644 --- a/src/test/compile-fail/issue-17431-6.rs +++ b/src/test/compile-fail/issue-17431-6.rs @@ -11,7 +11,7 @@ use std::sync::Mutex; enum Foo { X(Mutex>) } -//~^ ERROR illegal recursive enum type; wrap the inner value in a box to make it representable +//~^ ERROR invalid recursive enum type impl Foo { fn bar(self) {} } diff --git a/src/test/compile-fail/issue-17431-7.rs b/src/test/compile-fail/issue-17431-7.rs index c64c040aa44cb..9ad81e030aaf0 100644 --- a/src/test/compile-fail/issue-17431-7.rs +++ b/src/test/compile-fail/issue-17431-7.rs @@ -9,7 +9,7 @@ // except according to those terms. enum Foo { Voo(Option>) } -//~^ ERROR illegal recursive enum type; wrap the inner value in a box to make it representable +//~^ ERROR invalid recursive enum type impl Foo { fn bar(&self) {} } diff --git a/src/test/compile-fail/issue-17444.rs b/src/test/compile-fail/issue-17444.rs index a079161d42efa..c1d5827eb90ce 100644 --- a/src/test/compile-fail/issue-17444.rs +++ b/src/test/compile-fail/issue-17444.rs @@ -14,5 +14,6 @@ enum Test { fn main() { let _x = Test::Foo as *const isize; - //~^ ERROR illegal cast; cast through a usize first: `Test` as `*const isize` + //~^ ERROR casting `Test` as `*const isize` is invalid + //~^^ HELP cast through a usize first } diff --git a/src/test/compile-fail/issue-21554.rs b/src/test/compile-fail/issue-21554.rs index 16ce84715b154..741707a47b607 100644 --- a/src/test/compile-fail/issue-21554.rs +++ b/src/test/compile-fail/issue-21554.rs @@ -11,5 +11,7 @@ struct Inches(i32); fn main() { - Inches as f32; //~ ERROR illegal cast; cast through a usize first + Inches as f32; + //~^ ERROR casting + //~^^ cast through a usize first } diff --git a/src/test/compile-fail/issue-2718-a.rs b/src/test/compile-fail/issue-2718-a.rs index 3ba8dd4fefef0..37daf76c0b953 100644 --- a/src/test/compile-fail/issue-2718-a.rs +++ b/src/test/compile-fail/issue-2718-a.rs @@ -16,7 +16,7 @@ mod pingpong { use send_packet; pub type ping = send_packet; pub struct pong(send_packet); - //~^ ERROR illegal recursive struct type; wrap the inner value in a box to make it representable + //~^ ERROR invalid recursive struct type } fn main() {} diff --git a/src/test/compile-fail/issue-3008-1.rs b/src/test/compile-fail/issue-3008-1.rs index d2d7d800470fe..eb68420832635 100644 --- a/src/test/compile-fail/issue-3008-1.rs +++ b/src/test/compile-fail/issue-3008-1.rs @@ -10,7 +10,7 @@ enum foo { foo_(bar) } enum bar { bar_none, bar_some(bar) } -//~^ ERROR illegal recursive enum type; wrap the inner value in a box to make it representable +//~^ ERROR invalid recursive enum type fn main() { } diff --git a/src/test/compile-fail/issue-3008-2.rs b/src/test/compile-fail/issue-3008-2.rs index 2f1fa6780ab0c..f934e0771c2ab 100644 --- a/src/test/compile-fail/issue-3008-2.rs +++ b/src/test/compile-fail/issue-3008-2.rs @@ -12,7 +12,7 @@ enum foo { foo_(bar) } struct bar { x: bar } -//~^ ERROR illegal recursive struct type; wrap the inner value in a box to make it representable +//~^ ERROR invalid recursive struct type fn main() { } diff --git a/src/test/compile-fail/issue-3008-3.rs b/src/test/compile-fail/issue-3008-3.rs index af6cee1f10749..f8756b83f23a6 100644 --- a/src/test/compile-fail/issue-3008-3.rs +++ b/src/test/compile-fail/issue-3008-3.rs @@ -12,7 +12,7 @@ use std::marker; enum E1 { V1(E2), } enum E2 { V2(E2, marker::PhantomData), } -//~^ ERROR illegal recursive enum type; wrap the inner value in a box to make it representable +//~^ ERROR invalid recursive enum type impl E1 { fn foo(&self) {} } diff --git a/src/test/compile-fail/issue-3779.rs b/src/test/compile-fail/issue-3779.rs index 19a7ed05bf442..66d8fb40cd120 100644 --- a/src/test/compile-fail/issue-3779.rs +++ b/src/test/compile-fail/issue-3779.rs @@ -9,7 +9,7 @@ // except according to those terms. struct S { - //~^ ERROR illegal recursive struct type; wrap the inner value in a box to make it representable + //~^ ERROR invalid recursive struct type element: Option } diff --git a/src/test/compile-fail/old-suffixes-are-really-forbidden.rs b/src/test/compile-fail/old-suffixes-are-really-forbidden.rs index b18741d3932f9..9a71dc980149c 100644 --- a/src/test/compile-fail/old-suffixes-are-really-forbidden.rs +++ b/src/test/compile-fail/old-suffixes-are-really-forbidden.rs @@ -9,6 +9,6 @@ // except according to those terms. fn main() { - let a = 1_is; //~ ERROR illegal suffix - let b = 2_us; //~ ERROR illegal suffix + let a = 1_is; //~ ERROR invalid suffix + let b = 2_us; //~ ERROR invalid suffix } diff --git a/src/test/compile-fail/recursive-enum.rs b/src/test/compile-fail/recursive-enum.rs index 119f6dae9e556..33dcbdf74d226 100644 --- a/src/test/compile-fail/recursive-enum.rs +++ b/src/test/compile-fail/recursive-enum.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern: illegal recursive enum type +// error-pattern: invalid recursive enum type enum list { cons(T, list), nil } diff --git a/src/test/compile-fail/regions-name-static.rs b/src/test/compile-fail/regions-name-static.rs index 29896aa486b49..69d63f3820c6c 100644 --- a/src/test/compile-fail/regions-name-static.rs +++ b/src/test/compile-fail/regions-name-static.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct Foo<'static> { //~ ERROR illegal lifetime parameter name: `'static` +struct Foo<'static> { //~ ERROR invalid lifetime parameter name: `'static` x: &'static isize } diff --git a/src/test/compile-fail/type-recursive.rs b/src/test/compile-fail/type-recursive.rs index b972934d0604c..3b08d900733c5 100644 --- a/src/test/compile-fail/type-recursive.rs +++ b/src/test/compile-fail/type-recursive.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:illegal recursive struct type +// error-pattern:invalid recursive struct type struct t1 { foo: isize, foolish: t1 diff --git a/src/test/compile-fail/typeck-cast-pointer-to-float.rs b/src/test/compile-fail/typeck-cast-pointer-to-float.rs index e10a76c65bcf1..2277b1bad776d 100644 --- a/src/test/compile-fail/typeck-cast-pointer-to-float.rs +++ b/src/test/compile-fail/typeck-cast-pointer-to-float.rs @@ -11,5 +11,6 @@ fn main() { let x : i16 = 22; ((&x) as *const i16) as f32; - //~^ ERROR illegal cast; cast through a usize first: `*const i16` as `f32` + //~^ ERROR casting `*const i16` as `f32` is invalid + //~^^ HELP cast through a usize first } diff --git a/src/test/compile-fail/unsupported-cast.rs b/src/test/compile-fail/unsupported-cast.rs index b4246f2ed87f3..8b63dd51729b8 100644 --- a/src/test/compile-fail/unsupported-cast.rs +++ b/src/test/compile-fail/unsupported-cast.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:illegal cast +// error-pattern:casting #![feature(libc)] diff --git a/src/test/compile-fail/vector-cast-weirdness.rs b/src/test/compile-fail/vector-cast-weirdness.rs index 10227f1820d96..26c59c440d47b 100644 --- a/src/test/compile-fail/vector-cast-weirdness.rs +++ b/src/test/compile-fail/vector-cast-weirdness.rs @@ -28,7 +28,7 @@ fn main() { let mut x1 = X { y: [0, 0] }; // This is still an error since we don't allow casts from &mut [T; n] to *mut T. - let p1: *mut u8 = &mut x1.y as *mut _; //~ ERROR illegal cast + let p1: *mut u8 = &mut x1.y as *mut _; //~ ERROR casting let t1: *mut [u8; 2] = &mut x1.y as *mut _; let h1: *mut [u8; 2] = &mut x1.y as *mut [u8; 2]; } diff --git a/src/test/parse-fail/bad-lit-suffixes.rs b/src/test/parse-fail/bad-lit-suffixes.rs index a64ee6a9ce265..a2ee2f6e88ca6 100644 --- a/src/test/parse-fail/bad-lit-suffixes.rs +++ b/src/test/parse-fail/bad-lit-suffixes.rs @@ -12,28 +12,28 @@ extern - "C"suffix //~ ERROR ABI spec with a suffix is illegal + "C"suffix //~ ERROR ABI spec with a suffix is invalid fn foo() {} extern - "C"suffix //~ ERROR ABI spec with a suffix is illegal + "C"suffix //~ ERROR ABI spec with a suffix is invalid {} fn main() { - ""suffix; //~ ERROR str literal with a suffix is illegal - b""suffix; //~ ERROR binary str literal with a suffix is illegal - r#""#suffix; //~ ERROR str literal with a suffix is illegal - br#""#suffix; //~ ERROR binary str literal with a suffix is illegal - 'a'suffix; //~ ERROR char literal with a suffix is illegal - b'a'suffix; //~ ERROR byte literal with a suffix is illegal + ""suffix; //~ ERROR str literal with a suffix is invalid + b""suffix; //~ ERROR binary str literal with a suffix is invalid + r#""#suffix; //~ ERROR str literal with a suffix is invalid + br#""#suffix; //~ ERROR binary str literal with a suffix is invalid + 'a'suffix; //~ ERROR char literal with a suffix is invalid + b'a'suffix; //~ ERROR byte literal with a suffix is invalid - 1234u1024; //~ ERROR illegal width `1024` for integer literal - 1234i1024; //~ ERROR illegal width `1024` for integer literal - 1234f1024; //~ ERROR illegal width `1024` for float literal - 1234.5f1024; //~ ERROR illegal width `1024` for float literal + 1234u1024; //~ ERROR invalid width `1024` for integer literal + 1234i1024; //~ ERROR invalid width `1024` for integer literal + 1234f1024; //~ ERROR invalid width `1024` for float literal + 1234.5f1024; //~ ERROR invalid width `1024` for float literal - 1234suffix; //~ ERROR illegal suffix `suffix` for numeric literal - 0b101suffix; //~ ERROR illegal suffix `suffix` for numeric literal - 1.0suffix; //~ ERROR illegal suffix `suffix` for float literal - 1.0e10suffix; //~ ERROR illegal suffix `suffix` for float literal + 1234suffix; //~ ERROR invalid suffix `suffix` for numeric literal + 0b101suffix; //~ ERROR invalid suffix `suffix` for numeric literal + 1.0suffix; //~ ERROR invalid suffix `suffix` for float literal + 1.0e10suffix; //~ ERROR invalid suffix `suffix` for float literal } diff --git a/src/test/parse-fail/byte-literals.rs b/src/test/parse-fail/byte-literals.rs index 6685a29bb4264..3321f2450c188 100644 --- a/src/test/parse-fail/byte-literals.rs +++ b/src/test/parse-fail/byte-literals.rs @@ -17,7 +17,7 @@ static FOO: u8 = b'\f'; //~ ERROR unknown byte escape pub fn main() { b'\f'; //~ ERROR unknown byte escape - b'\x0Z'; //~ ERROR illegal character in numeric character escape: Z + b'\x0Z'; //~ ERROR invalid character in numeric character escape: Z b' '; //~ ERROR byte constant must be escaped b'''; //~ ERROR byte constant must be escaped b'é'; //~ ERROR byte constant must be ASCII diff --git a/src/test/parse-fail/byte-string-literals.rs b/src/test/parse-fail/byte-string-literals.rs index 7049363c21b77..22f123416f26e 100644 --- a/src/test/parse-fail/byte-string-literals.rs +++ b/src/test/parse-fail/byte-string-literals.rs @@ -17,7 +17,7 @@ static FOO: &'static [u8] = b"\f"; //~ ERROR unknown byte escape pub fn main() { b"\f"; //~ ERROR unknown byte escape - b"\x0Z"; //~ ERROR illegal character in numeric character escape: Z + b"\x0Z"; //~ ERROR invalid character in numeric character escape: Z b"é"; //~ ERROR byte constant must be ASCII b"a //~ ERROR unterminated double quote byte string } diff --git a/src/test/parse-fail/issue-23620-invalid-escapes.rs b/src/test/parse-fail/issue-23620-invalid-escapes.rs index 1790b9164b7ef..d2f78ef897b35 100644 --- a/src/test/parse-fail/issue-23620-invalid-escapes.rs +++ b/src/test/parse-fail/issue-23620-invalid-escapes.rs @@ -23,25 +23,25 @@ fn main() { //~^ ERROR numeric character escape is too short let _ = b'\xxy'; - //~^ ERROR illegal character in numeric character escape: x - //~^^ ERROR illegal character in numeric character escape: y + //~^ ERROR invalid character in numeric character escape: x + //~^^ ERROR invalid character in numeric character escape: y let _ = '\x5'; //~^ ERROR numeric character escape is too short let _ = '\xxy'; - //~^ ERROR illegal character in numeric character escape: x - //~^^ ERROR illegal character in numeric character escape: y + //~^ ERROR invalid character in numeric character escape: x + //~^^ ERROR invalid character in numeric character escape: y let _ = b"\u{a4a4} \xf \u"; //~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string - //~^^ ERROR illegal character in numeric character escape: + //~^^ ERROR invalid character in numeric character escape: //~^^^ ERROR incorrect unicode escape sequence //~^^^^ ERROR unicode escape sequences cannot be used as a byte or in a byte string let _ = "\u{ffffff} \xf \u"; - //~^ ERROR illegal unicode character escape - //~^^ ERROR illegal character in numeric character escape: + //~^ ERROR invalid unicode character escape + //~^^ ERROR invalid character in numeric character escape: //~^^^ ERROR form of character escape may only be used with characters in the range [\x00-\x7f] //~^^^^ ERROR incorrect unicode escape sequence } diff --git a/src/test/parse-fail/issue-8537.rs b/src/test/parse-fail/issue-8537.rs index 5996b744566ce..e152a369290b7 100644 --- a/src/test/parse-fail/issue-8537.rs +++ b/src/test/parse-fail/issue-8537.rs @@ -11,7 +11,7 @@ // compile-flags: -Z parse-only pub extern - "invalid-ab_isize" //~ ERROR illegal ABI + "invalid-ab_isize" //~ ERROR invalid ABI fn foo() {} fn main() {} diff --git a/src/test/parse-fail/new-unicode-escapes-3.rs b/src/test/parse-fail/new-unicode-escapes-3.rs index 5e8bc16ac6e9f..d12bb63111b9e 100644 --- a/src/test/parse-fail/new-unicode-escapes-3.rs +++ b/src/test/parse-fail/new-unicode-escapes-3.rs @@ -11,5 +11,5 @@ // compile-flags: -Z parse-only pub fn main() { - let s = "\u{d805}"; //~ ERROR illegal unicode character escape + let s = "\u{d805}"; //~ ERROR invalid unicode character escape } diff --git a/src/test/parse-fail/new-unicode-escapes-4.rs b/src/test/parse-fail/new-unicode-escapes-4.rs index 896751bd4a727..fe125da1755bd 100644 --- a/src/test/parse-fail/new-unicode-escapes-4.rs +++ b/src/test/parse-fail/new-unicode-escapes-4.rs @@ -12,7 +12,7 @@ pub fn main() { let s = "\u{lol}"; - //~^ ERROR illegal character in unicode escape: l - //~^^ ERROR illegal character in unicode escape: o - //~^^^ ERROR illegal character in unicode escape: l + //~^ ERROR invalid character in unicode escape: l + //~^^ ERROR invalid character in unicode escape: o + //~^^^ ERROR invalid character in unicode escape: l } diff --git a/src/test/parse-fail/raw-str-delim.rs b/src/test/parse-fail/raw-str-delim.rs index c7ef91f14f578..3fc5f8aae1876 100644 --- a/src/test/parse-fail/raw-str-delim.rs +++ b/src/test/parse-fail/raw-str-delim.rs @@ -11,5 +11,5 @@ // compile-flags: -Z parse-only static s: &'static str = - r#x"#"x# //~ ERROR only `#` is allowed in raw string delimitation; found illegal character + r#x"#"x# //~ ERROR found invalid character; only `#` is allowed in raw string delimitation ;