Skip to content

Rollup of 11 pull requests #32200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Mar 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
118b975
Add missing documentation examples for BinaryHeap.
nathankleyn Mar 8, 2016
04436fb
Address review comments to add "basic usage" sections to docs.
nathankleyn Mar 9, 2016
ca129e3
lint: mark associated types as live for the dead_code pass
seanmonstar Mar 9, 2016
e1048b5
Prefer `Option::expect` over explicit unwrapping.
frewsxcv Mar 10, 2016
410333b
Differentiate "line" and "line number" variable names.
frewsxcv Mar 10, 2016
da4fda4
Remove unnecessary mut in docs causing test failures.
nathankleyn Mar 10, 2016
3d16321
Spell fixes for std::ffi doc comments
cmbrandenburg Mar 10, 2016
4d47669
Update getting-started.md
naltun Mar 10, 2016
266c417
removed integer constants in librustc_typeck
srinivasreddy Mar 10, 2016
fe541b1
removed suffixes for librustc_front
srinivasreddy Mar 10, 2016
bfffe6d
Clarify doc for slice slicing (Index impls)
bluss Mar 10, 2016
e1cc628
cleanup int suffixes in libcoretest
srinivasreddy Mar 11, 2016
e2b055c
Add FreeBSD amd64 snapshot
andoriyu Mar 11, 2016
725d6d8
Rollup merge of #32137 - nathankleyn:improve-docs-for-binaryheap, r=s…
Manishearth Mar 11, 2016
25d253e
Rollup merge of #32158 - seanmonstar:dead-associated-type, r=alexcric…
Manishearth Mar 11, 2016
c194cce
Rollup merge of #32171 - frewsxcv:compiletest, r=alexcrichton
Manishearth Mar 11, 2016
baea278
Rollup merge of #32174 - cmbrandenburg:spell_fix, r=steveklabnik
Manishearth Mar 11, 2016
744ffed
Rollup merge of #32178 - naltun:patch-1, r=steveklabnik
Manishearth Mar 11, 2016
7a1df9e
Rollup merge of #32180 - srinivasreddy:type_check_lib, r=steveklabnik
Manishearth Mar 11, 2016
249ca83
Rollup merge of #32181 - srinivasreddy:librustfront, r=steveklabnik
Manishearth Mar 11, 2016
667dceb
Rollup merge of #32183 - bluss:doc-index, r=alexcrichton
Manishearth Mar 11, 2016
c8578c1
Rollup merge of #32186 - srinivasreddy:libcoretest, r=steveklabnik
Manishearth Mar 11, 2016
10e4e9e
Rollup merge of #32197 - andoriyu:patch-1, r=alexcrichton
Manishearth Mar 11, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions src/compiletest/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::io::prelude::*;
use std::path::Path;

pub struct ExpectedError {
pub line: usize,
pub line_num: usize,
pub kind: String,
pub msg: String,
}
Expand Down Expand Up @@ -53,15 +53,15 @@ pub fn load_errors(testfile: &Path, cfg: Option<&str>) -> Vec<ExpectedError> {

rdr.lines()
.enumerate()
.filter_map(|(line_no, ln)| {
.filter_map(|(line_num, line)| {
parse_expected(last_nonfollow_error,
line_no + 1,
&ln.unwrap(),
line_num + 1,
&line.unwrap(),
&tag)
.map(|(which, error)| {
match which {
FollowPrevious(_) => {}
_ => last_nonfollow_error = Some(error.line),
_ => last_nonfollow_error = Some(error.line_num),
}
error
})
Expand Down Expand Up @@ -91,23 +91,21 @@ fn parse_expected(last_nonfollow_error: Option<usize>,
.skip_while(|c| !c.is_whitespace())
.collect::<String>().trim().to_owned();

let (which, line) = if follow {
let (which, line_num) = if follow {
assert!(adjusts == 0, "use either //~| or //~^, not both.");
let line = last_nonfollow_error.unwrap_or_else(|| {
panic!("encountered //~| without preceding //~^ line.")
});
(FollowPrevious(line), line)
let line_num = last_nonfollow_error.expect("encountered //~| without \
preceding //~^ line.");
(FollowPrevious(line_num), line_num)
} else {
let which =
if adjusts > 0 { AdjustBackward(adjusts) } else { ThisLine };
let line = line_num - adjusts;
(which, line)
let line_num = line_num - adjusts;
(which, line_num)
};

debug!("line={} tag={:?} which={:?} kind={:?} msg={:?}",
line_num, tag, which, kind, msg);

Some((which, ExpectedError { line: line,
Some((which, ExpectedError { line_num: line_num,
kind: kind,
msg: msg, }))
}
4 changes: 2 additions & 2 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ fn check_expected_errors(revision: Option<&str>,
}

let prefixes = expected_errors.iter().map(|ee| {
let expected = format!("{}:{}:", testpaths.file.display(), ee.line);
let expected = format!("{}:{}:", testpaths.file.display(), ee.line_num);
// On windows just translate all '\' path separators to '/'
expected.replace(r"\", "/")
}).collect::<Vec<String>>();
Expand Down Expand Up @@ -1076,7 +1076,7 @@ fn check_expected_errors(revision: Option<&str>,
if !flag {
let ee = &expected_errors[i];
error(revision, &format!("expected {} on line {} not found: {}",
ee.kind, ee.line, ee.msg));
ee.kind, ee.line_num, ee.msg));
not_found += 1;
}
}
Expand Down
14 changes: 1 addition & 13 deletions src/doc/book/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,7 @@ This will download a script, and start the installation. If it all goes well,
you’ll see this appear:

```text
Welcome to Rust.

This script will download the Rust compiler and its package manager, Cargo, and
install them to /usr/local. You may install elsewhere by running this script
with the --prefix=<path> option.

The installer will run under ‘sudo’ and may ask you for your password. If you do
not want the script to run ‘sudo’ then pass it the --disable-sudo flag.

You may uninstall later by running /usr/local/lib/rustlib/uninstall.sh,
or by running this script again with the --uninstall flag.

Continue? (y/N)
Rust is ready to roll.
```

From here, press `y` for ‘yes’, and then follow the rest of the prompts.
Expand Down
144 changes: 144 additions & 0 deletions src/libcollections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,49 @@ use vec::{self, Vec};
/// item's ordering relative to any other item, as determined by the `Ord`
/// trait, changes while it is in the heap. This is normally only possible
/// through `Cell`, `RefCell`, global state, I/O, or unsafe code.
///
/// # Examples
///
/// ```
/// use std::collections::BinaryHeap;
///
/// // type inference lets us omit an explicit type signature (which
/// // would be `BinaryHeap<i32>` in this example).
/// let mut heap = BinaryHeap::new();
///
/// // We can use peek to look at the next item in the heap. In this case,
/// // there's no items in there yet so we get None.
/// assert_eq!(heap.peek(), None);
///
/// // Let's add some scores...
/// heap.push(1);
/// heap.push(5);
/// heap.push(2);
///
/// // Now peek shows the most important item in the heap.
/// assert_eq!(heap.peek(), Some(&5));
///
/// // We can check the length of a heap.
/// assert_eq!(heap.len(), 3);
///
/// // We can iterate over the items in the heap, although they are returned in
/// // a random order.
/// for x in heap.iter() {
/// println!("{}", x);
/// }
///
/// // If we instead pop these scores, they should come back in order.
/// assert_eq!(heap.pop(), Some(5));
/// assert_eq!(heap.pop(), Some(2));
/// assert_eq!(heap.pop(), Some(1));
/// assert_eq!(heap.pop(), None);
///
/// // We can clear the heap of any remaining items.
/// heap.clear();
///
/// // The heap should now be empty.
/// assert!(heap.is_empty())
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub struct BinaryHeap<T> {
data: Vec<T>,
Expand Down Expand Up @@ -203,6 +246,8 @@ impl<T: Ord> BinaryHeap<T> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// use std::collections::BinaryHeap;
/// let mut heap = BinaryHeap::new();
Expand All @@ -220,6 +265,8 @@ impl<T: Ord> BinaryHeap<T> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// use std::collections::BinaryHeap;
/// let mut heap = BinaryHeap::with_capacity(10);
Expand All @@ -235,6 +282,8 @@ impl<T: Ord> BinaryHeap<T> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// use std::collections::BinaryHeap;
/// let heap = BinaryHeap::from(vec![1, 2, 3, 4]);
Expand All @@ -253,6 +302,8 @@ impl<T: Ord> BinaryHeap<T> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// use std::collections::BinaryHeap;
/// let mut heap = BinaryHeap::new();
Expand All @@ -273,6 +324,8 @@ impl<T: Ord> BinaryHeap<T> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// use std::collections::BinaryHeap;
/// let mut heap = BinaryHeap::with_capacity(100);
Expand All @@ -297,6 +350,8 @@ impl<T: Ord> BinaryHeap<T> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// use std::collections::BinaryHeap;
/// let mut heap = BinaryHeap::new();
Expand All @@ -318,6 +373,8 @@ impl<T: Ord> BinaryHeap<T> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// use std::collections::BinaryHeap;
/// let mut heap = BinaryHeap::new();
Expand All @@ -331,6 +388,19 @@ impl<T: Ord> BinaryHeap<T> {
}

/// Discards as much additional capacity as possible.
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// use std::collections::BinaryHeap;
/// let mut heap: BinaryHeap<i32> = BinaryHeap::with_capacity(100);
///
/// assert!(heap.capacity() >= 100);
/// heap.shrink_to_fit();
/// assert!(heap.capacity() == 0);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn shrink_to_fit(&mut self) {
self.data.shrink_to_fit();
Expand All @@ -341,6 +411,8 @@ impl<T: Ord> BinaryHeap<T> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// use std::collections::BinaryHeap;
/// let mut heap = BinaryHeap::from(vec![1, 3]);
Expand All @@ -364,6 +436,8 @@ impl<T: Ord> BinaryHeap<T> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// use std::collections::BinaryHeap;
/// let mut heap = BinaryHeap::new();
Expand All @@ -386,6 +460,8 @@ impl<T: Ord> BinaryHeap<T> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// #![feature(binary_heap_extras)]
///
Expand Down Expand Up @@ -424,6 +500,8 @@ impl<T: Ord> BinaryHeap<T> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// #![feature(binary_heap_extras)]
///
Expand Down Expand Up @@ -454,6 +532,8 @@ impl<T: Ord> BinaryHeap<T> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// use std::collections::BinaryHeap;
/// let heap = BinaryHeap::from(vec![1, 2, 3, 4, 5, 6, 7]);
Expand All @@ -474,6 +554,8 @@ impl<T: Ord> BinaryHeap<T> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// use std::collections::BinaryHeap;
///
Expand Down Expand Up @@ -571,12 +653,40 @@ impl<T: Ord> BinaryHeap<T> {
}

/// Returns the length of the binary heap.
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// use std::collections::BinaryHeap;
/// let heap = BinaryHeap::from(vec![1, 3]);
///
/// assert_eq!(heap.len(), 2);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn len(&self) -> usize {
self.data.len()
}

/// Checks if the binary heap is empty.
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// use std::collections::BinaryHeap;
/// let mut heap = BinaryHeap::new();
///
/// assert!(heap.is_empty());
///
/// heap.push(3);
/// heap.push(5);
/// heap.push(1);
///
/// assert!(!heap.is_empty());
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn is_empty(&self) -> bool {
self.len() == 0
Expand All @@ -585,13 +695,45 @@ impl<T: Ord> BinaryHeap<T> {
/// Clears the binary heap, returning an iterator over the removed elements.
///
/// The elements are removed in arbitrary order.
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// use std::collections::BinaryHeap;
/// let mut heap = BinaryHeap::from(vec![1, 3]);
///
/// assert!(!heap.is_empty());
///
/// for x in heap.drain() {
/// println!("{}", x);
/// }
///
/// assert!(heap.is_empty());
/// ```
#[inline]
#[stable(feature = "drain", since = "1.6.0")]
pub fn drain(&mut self) -> Drain<T> {
Drain { iter: self.data.drain(..) }
}

/// Drops all items from the binary heap.
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// use std::collections::BinaryHeap;
/// let mut heap = BinaryHeap::from(vec![1, 3]);
///
/// assert!(!heap.is_empty());
///
/// heap.clear();
///
/// assert!(heap.is_empty());
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn clear(&mut self) {
self.drain();
Expand Down Expand Up @@ -809,6 +951,8 @@ impl<T: Ord> IntoIterator for BinaryHeap<T> {
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// use std::collections::BinaryHeap;
/// let heap = BinaryHeap::from(vec![1, 2, 3, 4]);
Expand Down
Loading