Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f1d6f12

Browse files
committedMar 12, 2016
Auto merge of #32200 - Manishearth:rollup, r=Manishearth
Rollup of 11 pull requests - Successful merges: #32137, #32158, #32171, #32174, #32178, #32179, #32180, #32181, #32183, #32186, #32197 - Failed merges:
2 parents 0d68aad + 10e4e9e commit f1d6f12

File tree

16 files changed

+279
-69
lines changed

16 files changed

+279
-69
lines changed
 

‎src/compiletest/errors.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::io::prelude::*;
1515
use std::path::Path;
1616

1717
pub struct ExpectedError {
18-
pub line: usize,
18+
pub line_num: usize,
1919
pub kind: String,
2020
pub msg: String,
2121
}
@@ -53,15 +53,15 @@ pub fn load_errors(testfile: &Path, cfg: Option<&str>) -> Vec<ExpectedError> {
5353

5454
rdr.lines()
5555
.enumerate()
56-
.filter_map(|(line_no, ln)| {
56+
.filter_map(|(line_num, line)| {
5757
parse_expected(last_nonfollow_error,
58-
line_no + 1,
59-
&ln.unwrap(),
58+
line_num + 1,
59+
&line.unwrap(),
6060
&tag)
6161
.map(|(which, error)| {
6262
match which {
6363
FollowPrevious(_) => {}
64-
_ => last_nonfollow_error = Some(error.line),
64+
_ => last_nonfollow_error = Some(error.line_num),
6565
}
6666
error
6767
})
@@ -91,23 +91,21 @@ fn parse_expected(last_nonfollow_error: Option<usize>,
9191
.skip_while(|c| !c.is_whitespace())
9292
.collect::<String>().trim().to_owned();
9393

94-
let (which, line) = if follow {
94+
let (which, line_num) = if follow {
9595
assert!(adjusts == 0, "use either //~| or //~^, not both.");
96-
let line = last_nonfollow_error.unwrap_or_else(|| {
97-
panic!("encountered //~| without preceding //~^ line.")
98-
});
99-
(FollowPrevious(line), line)
96+
let line_num = last_nonfollow_error.expect("encountered //~| without \
97+
preceding //~^ line.");
98+
(FollowPrevious(line_num), line_num)
10099
} else {
101100
let which =
102101
if adjusts > 0 { AdjustBackward(adjusts) } else { ThisLine };
103-
let line = line_num - adjusts;
104-
(which, line)
102+
let line_num = line_num - adjusts;
103+
(which, line_num)
105104
};
106105

107106
debug!("line={} tag={:?} which={:?} kind={:?} msg={:?}",
108107
line_num, tag, which, kind, msg);
109-
110-
Some((which, ExpectedError { line: line,
108+
Some((which, ExpectedError { line_num: line_num,
111109
kind: kind,
112110
msg: msg, }))
113111
}

‎src/compiletest/runtest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ fn check_expected_errors(revision: Option<&str>,
10041004
}
10051005

10061006
let prefixes = expected_errors.iter().map(|ee| {
1007-
let expected = format!("{}:{}:", testpaths.file.display(), ee.line);
1007+
let expected = format!("{}:{}:", testpaths.file.display(), ee.line_num);
10081008
// On windows just translate all '\' path separators to '/'
10091009
expected.replace(r"\", "/")
10101010
}).collect::<Vec<String>>();
@@ -1076,7 +1076,7 @@ fn check_expected_errors(revision: Option<&str>,
10761076
if !flag {
10771077
let ee = &expected_errors[i];
10781078
error(revision, &format!("expected {} on line {} not found: {}",
1079-
ee.kind, ee.line, ee.msg));
1079+
ee.kind, ee.line_num, ee.msg));
10801080
not_found += 1;
10811081
}
10821082
}

‎src/doc/book/getting-started.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -119,19 +119,7 @@ This will download a script, and start the installation. If it all goes well,
119119
you’ll see this appear:
120120

121121
```text
122-
Welcome to Rust.
123-
124-
This script will download the Rust compiler and its package manager, Cargo, and
125-
install them to /usr/local. You may install elsewhere by running this script
126-
with the --prefix=<path> option.
127-
128-
The installer will run under ‘sudo’ and may ask you for your password. If you do
129-
not want the script to run ‘sudo’ then pass it the --disable-sudo flag.
130-
131-
You may uninstall later by running /usr/local/lib/rustlib/uninstall.sh,
132-
or by running this script again with the --uninstall flag.
133-
134-
Continue? (y/N)
122+
Rust is ready to roll.
135123
```
136124

137125
From here, press `y` for ‘yes’, and then follow the rest of the prompts.

‎src/libcollections/binary_heap.rs

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,49 @@ use vec::{self, Vec};
167167
/// item's ordering relative to any other item, as determined by the `Ord`
168168
/// trait, changes while it is in the heap. This is normally only possible
169169
/// through `Cell`, `RefCell`, global state, I/O, or unsafe code.
170+
///
171+
/// # Examples
172+
///
173+
/// ```
174+
/// use std::collections::BinaryHeap;
175+
///
176+
/// // type inference lets us omit an explicit type signature (which
177+
/// // would be `BinaryHeap<i32>` in this example).
178+
/// let mut heap = BinaryHeap::new();
179+
///
180+
/// // We can use peek to look at the next item in the heap. In this case,
181+
/// // there's no items in there yet so we get None.
182+
/// assert_eq!(heap.peek(), None);
183+
///
184+
/// // Let's add some scores...
185+
/// heap.push(1);
186+
/// heap.push(5);
187+
/// heap.push(2);
188+
///
189+
/// // Now peek shows the most important item in the heap.
190+
/// assert_eq!(heap.peek(), Some(&5));
191+
///
192+
/// // We can check the length of a heap.
193+
/// assert_eq!(heap.len(), 3);
194+
///
195+
/// // We can iterate over the items in the heap, although they are returned in
196+
/// // a random order.
197+
/// for x in heap.iter() {
198+
/// println!("{}", x);
199+
/// }
200+
///
201+
/// // If we instead pop these scores, they should come back in order.
202+
/// assert_eq!(heap.pop(), Some(5));
203+
/// assert_eq!(heap.pop(), Some(2));
204+
/// assert_eq!(heap.pop(), Some(1));
205+
/// assert_eq!(heap.pop(), None);
206+
///
207+
/// // We can clear the heap of any remaining items.
208+
/// heap.clear();
209+
///
210+
/// // The heap should now be empty.
211+
/// assert!(heap.is_empty())
212+
/// ```
170213
#[stable(feature = "rust1", since = "1.0.0")]
171214
pub struct BinaryHeap<T> {
172215
data: Vec<T>,
@@ -203,6 +246,8 @@ impl<T: Ord> BinaryHeap<T> {
203246
///
204247
/// # Examples
205248
///
249+
/// Basic usage:
250+
///
206251
/// ```
207252
/// use std::collections::BinaryHeap;
208253
/// let mut heap = BinaryHeap::new();
@@ -220,6 +265,8 @@ impl<T: Ord> BinaryHeap<T> {
220265
///
221266
/// # Examples
222267
///
268+
/// Basic usage:
269+
///
223270
/// ```
224271
/// use std::collections::BinaryHeap;
225272
/// let mut heap = BinaryHeap::with_capacity(10);
@@ -235,6 +282,8 @@ impl<T: Ord> BinaryHeap<T> {
235282
///
236283
/// # Examples
237284
///
285+
/// Basic usage:
286+
///
238287
/// ```
239288
/// use std::collections::BinaryHeap;
240289
/// let heap = BinaryHeap::from(vec![1, 2, 3, 4]);
@@ -253,6 +302,8 @@ impl<T: Ord> BinaryHeap<T> {
253302
///
254303
/// # Examples
255304
///
305+
/// Basic usage:
306+
///
256307
/// ```
257308
/// use std::collections::BinaryHeap;
258309
/// let mut heap = BinaryHeap::new();
@@ -273,6 +324,8 @@ impl<T: Ord> BinaryHeap<T> {
273324
///
274325
/// # Examples
275326
///
327+
/// Basic usage:
328+
///
276329
/// ```
277330
/// use std::collections::BinaryHeap;
278331
/// let mut heap = BinaryHeap::with_capacity(100);
@@ -297,6 +350,8 @@ impl<T: Ord> BinaryHeap<T> {
297350
///
298351
/// # Examples
299352
///
353+
/// Basic usage:
354+
///
300355
/// ```
301356
/// use std::collections::BinaryHeap;
302357
/// let mut heap = BinaryHeap::new();
@@ -318,6 +373,8 @@ impl<T: Ord> BinaryHeap<T> {
318373
///
319374
/// # Examples
320375
///
376+
/// Basic usage:
377+
///
321378
/// ```
322379
/// use std::collections::BinaryHeap;
323380
/// let mut heap = BinaryHeap::new();
@@ -331,6 +388,19 @@ impl<T: Ord> BinaryHeap<T> {
331388
}
332389

333390
/// Discards as much additional capacity as possible.
391+
///
392+
/// # Examples
393+
///
394+
/// Basic usage:
395+
///
396+
/// ```
397+
/// use std::collections::BinaryHeap;
398+
/// let mut heap: BinaryHeap<i32> = BinaryHeap::with_capacity(100);
399+
///
400+
/// assert!(heap.capacity() >= 100);
401+
/// heap.shrink_to_fit();
402+
/// assert!(heap.capacity() == 0);
403+
/// ```
334404
#[stable(feature = "rust1", since = "1.0.0")]
335405
pub fn shrink_to_fit(&mut self) {
336406
self.data.shrink_to_fit();
@@ -341,6 +411,8 @@ impl<T: Ord> BinaryHeap<T> {
341411
///
342412
/// # Examples
343413
///
414+
/// Basic usage:
415+
///
344416
/// ```
345417
/// use std::collections::BinaryHeap;
346418
/// let mut heap = BinaryHeap::from(vec![1, 3]);
@@ -364,6 +436,8 @@ impl<T: Ord> BinaryHeap<T> {
364436
///
365437
/// # Examples
366438
///
439+
/// Basic usage:
440+
///
367441
/// ```
368442
/// use std::collections::BinaryHeap;
369443
/// let mut heap = BinaryHeap::new();
@@ -386,6 +460,8 @@ impl<T: Ord> BinaryHeap<T> {
386460
///
387461
/// # Examples
388462
///
463+
/// Basic usage:
464+
///
389465
/// ```
390466
/// #![feature(binary_heap_extras)]
391467
///
@@ -424,6 +500,8 @@ impl<T: Ord> BinaryHeap<T> {
424500
///
425501
/// # Examples
426502
///
503+
/// Basic usage:
504+
///
427505
/// ```
428506
/// #![feature(binary_heap_extras)]
429507
///
@@ -454,6 +532,8 @@ impl<T: Ord> BinaryHeap<T> {
454532
///
455533
/// # Examples
456534
///
535+
/// Basic usage:
536+
///
457537
/// ```
458538
/// use std::collections::BinaryHeap;
459539
/// let heap = BinaryHeap::from(vec![1, 2, 3, 4, 5, 6, 7]);
@@ -474,6 +554,8 @@ impl<T: Ord> BinaryHeap<T> {
474554
///
475555
/// # Examples
476556
///
557+
/// Basic usage:
558+
///
477559
/// ```
478560
/// use std::collections::BinaryHeap;
479561
///
@@ -571,12 +653,40 @@ impl<T: Ord> BinaryHeap<T> {
571653
}
572654

573655
/// Returns the length of the binary heap.
656+
///
657+
/// # Examples
658+
///
659+
/// Basic usage:
660+
///
661+
/// ```
662+
/// use std::collections::BinaryHeap;
663+
/// let heap = BinaryHeap::from(vec![1, 3]);
664+
///
665+
/// assert_eq!(heap.len(), 2);
666+
/// ```
574667
#[stable(feature = "rust1", since = "1.0.0")]
575668
pub fn len(&self) -> usize {
576669
self.data.len()
577670
}
578671

579672
/// Checks if the binary heap is empty.
673+
///
674+
/// # Examples
675+
///
676+
/// Basic usage:
677+
///
678+
/// ```
679+
/// use std::collections::BinaryHeap;
680+
/// let mut heap = BinaryHeap::new();
681+
///
682+
/// assert!(heap.is_empty());
683+
///
684+
/// heap.push(3);
685+
/// heap.push(5);
686+
/// heap.push(1);
687+
///
688+
/// assert!(!heap.is_empty());
689+
/// ```
580690
#[stable(feature = "rust1", since = "1.0.0")]
581691
pub fn is_empty(&self) -> bool {
582692
self.len() == 0
@@ -585,13 +695,45 @@ impl<T: Ord> BinaryHeap<T> {
585695
/// Clears the binary heap, returning an iterator over the removed elements.
586696
///
587697
/// The elements are removed in arbitrary order.
698+
///
699+
/// # Examples
700+
///
701+
/// Basic usage:
702+
///
703+
/// ```
704+
/// use std::collections::BinaryHeap;
705+
/// let mut heap = BinaryHeap::from(vec![1, 3]);
706+
///
707+
/// assert!(!heap.is_empty());
708+
///
709+
/// for x in heap.drain() {
710+
/// println!("{}", x);
711+
/// }
712+
///
713+
/// assert!(heap.is_empty());
714+
/// ```
588715
#[inline]
589716
#[stable(feature = "drain", since = "1.6.0")]
590717
pub fn drain(&mut self) -> Drain<T> {
591718
Drain { iter: self.data.drain(..) }
592719
}
593720

594721
/// Drops all items from the binary heap.
722+
///
723+
/// # Examples
724+
///
725+
/// Basic usage:
726+
///
727+
/// ```
728+
/// use std::collections::BinaryHeap;
729+
/// let mut heap = BinaryHeap::from(vec![1, 3]);
730+
///
731+
/// assert!(!heap.is_empty());
732+
///
733+
/// heap.clear();
734+
///
735+
/// assert!(heap.is_empty());
736+
/// ```
595737
#[stable(feature = "rust1", since = "1.0.0")]
596738
pub fn clear(&mut self) {
597739
self.drain();
@@ -809,6 +951,8 @@ impl<T: Ord> IntoIterator for BinaryHeap<T> {
809951
///
810952
/// # Examples
811953
///
954+
/// Basic usage:
955+
///
812956
/// ```
813957
/// use std::collections::BinaryHeap;
814958
/// let heap = BinaryHeap::from(vec![1, 2, 3, 4]);

‎src/libcore/slice.rs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,16 @@ fn slice_index_order_fail(index: usize, end: usize) -> ! {
535535

536536
// FIXME implement indexing with inclusive ranges
537537

538+
/// Implements slicing with syntax `&self[begin .. end]`.
539+
///
540+
/// Returns a slice of self for the index range [`begin`..`end`).
541+
///
542+
/// This operation is `O(1)`.
543+
///
544+
/// # Panics
545+
///
546+
/// Requires that `begin <= end` and `end <= self.len()`,
547+
/// otherwise slicing will panic.
538548
#[stable(feature = "rust1", since = "1.0.0")]
539549
impl<T> ops::Index<ops::Range<usize>> for [T] {
540550
type Output = [T];
@@ -554,6 +564,13 @@ impl<T> ops::Index<ops::Range<usize>> for [T] {
554564
}
555565
}
556566
}
567+
568+
/// Implements slicing with syntax `&self[.. end]`.
569+
///
570+
/// Returns a slice of self from the beginning until but not including
571+
/// the index `end`.
572+
///
573+
/// Equivalent to `&self[0 .. end]`
557574
#[stable(feature = "rust1", since = "1.0.0")]
558575
impl<T> ops::Index<ops::RangeTo<usize>> for [T] {
559576
type Output = [T];
@@ -563,6 +580,12 @@ impl<T> ops::Index<ops::RangeTo<usize>> for [T] {
563580
self.index(0 .. index.end)
564581
}
565582
}
583+
584+
/// Implements slicing with syntax `&self[begin ..]`.
585+
///
586+
/// Returns a slice of self from and including the index `begin` until the end.
587+
///
588+
/// Equivalent to `&self[begin .. self.len()]`
566589
#[stable(feature = "rust1", since = "1.0.0")]
567590
impl<T> ops::Index<ops::RangeFrom<usize>> for [T] {
568591
type Output = [T];
@@ -572,6 +595,12 @@ impl<T> ops::Index<ops::RangeFrom<usize>> for [T] {
572595
self.index(index.start .. self.len())
573596
}
574597
}
598+
599+
/// Implements slicing with syntax `&self[..]`.
600+
///
601+
/// Returns a slice of the whole slice. This operation can not panic.
602+
///
603+
/// Equivalent to `&self[0 .. self.len()]`
575604
#[stable(feature = "rust1", since = "1.0.0")]
576605
impl<T> ops::Index<RangeFull> for [T] {
577606
type Output = [T];
@@ -608,6 +637,16 @@ impl<T> ops::Index<ops::RangeToInclusive<usize>> for [T] {
608637
}
609638
}
610639

640+
/// Implements mutable slicing with syntax `&mut self[begin .. end]`.
641+
///
642+
/// Returns a slice of self for the index range [`begin`..`end`).
643+
///
644+
/// This operation is `O(1)`.
645+
///
646+
/// # Panics
647+
///
648+
/// Requires that `begin <= end` and `end <= self.len()`,
649+
/// otherwise slicing will panic.
611650
#[stable(feature = "rust1", since = "1.0.0")]
612651
impl<T> ops::IndexMut<ops::Range<usize>> for [T] {
613652
#[inline]
@@ -625,13 +664,26 @@ impl<T> ops::IndexMut<ops::Range<usize>> for [T] {
625664
}
626665
}
627666
}
667+
668+
/// Implements mutable slicing with syntax `&mut self[.. end]`.
669+
///
670+
/// Returns a slice of self from the beginning until but not including
671+
/// the index `end`.
672+
///
673+
/// Equivalent to `&mut self[0 .. end]`
628674
#[stable(feature = "rust1", since = "1.0.0")]
629675
impl<T> ops::IndexMut<ops::RangeTo<usize>> for [T] {
630676
#[inline]
631677
fn index_mut(&mut self, index: ops::RangeTo<usize>) -> &mut [T] {
632678
self.index_mut(0 .. index.end)
633679
}
634680
}
681+
682+
/// Implements mutable slicing with syntax `&mut self[begin ..]`.
683+
///
684+
/// Returns a slice of self from and including the index `begin` until the end.
685+
///
686+
/// Equivalent to `&mut self[begin .. self.len()]`
635687
#[stable(feature = "rust1", since = "1.0.0")]
636688
impl<T> ops::IndexMut<ops::RangeFrom<usize>> for [T] {
637689
#[inline]
@@ -640,6 +692,12 @@ impl<T> ops::IndexMut<ops::RangeFrom<usize>> for [T] {
640692
self.index_mut(index.start .. len)
641693
}
642694
}
695+
696+
/// Implements mutable slicing with syntax `&mut self[..]`.
697+
///
698+
/// Returns a slice of the whole slice. This operation can not panic.
699+
///
700+
/// Equivalent to `&mut self[0 .. self.len()]`
643701
#[stable(feature = "rust1", since = "1.0.0")]
644702
impl<T> ops::IndexMut<RangeFull> for [T] {
645703
#[inline]

‎src/libcoretest/fmt/builders.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ mod debug_struct {
5353
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
5454
fmt.debug_struct("Foo")
5555
.field("bar", &true)
56-
.field("baz", &format_args!("{}/{}", 10i32, 20i32))
56+
.field("baz", &format_args!("{}/{}", 10, 20))
5757
.finish()
5858
}
5959
}
@@ -75,7 +75,7 @@ mod debug_struct {
7575
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
7676
fmt.debug_struct("Foo")
7777
.field("bar", &true)
78-
.field("baz", &format_args!("{}/{}", 10i32, 20i32))
78+
.field("baz", &format_args!("{}/{}", 10, 20))
7979
.finish()
8080
}
8181
}
@@ -150,7 +150,7 @@ mod debug_tuple {
150150
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
151151
fmt.debug_tuple("Foo")
152152
.field(&true)
153-
.field(&format_args!("{}/{}", 10i32, 20i32))
153+
.field(&format_args!("{}/{}", 10, 20))
154154
.finish()
155155
}
156156
}
@@ -172,7 +172,7 @@ mod debug_tuple {
172172
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
173173
fmt.debug_tuple("Foo")
174174
.field(&true)
175-
.field(&format_args!("{}/{}", 10i32, 20i32))
175+
.field(&format_args!("{}/{}", 10, 20))
176176
.finish()
177177
}
178178
}
@@ -247,7 +247,7 @@ mod debug_map {
247247
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
248248
fmt.debug_map()
249249
.entry(&"bar", &true)
250-
.entry(&10i32, &format_args!("{}/{}", 10i32, 20i32))
250+
.entry(&10, &format_args!("{}/{}", 10, 20))
251251
.finish()
252252
}
253253
}
@@ -269,7 +269,7 @@ mod debug_map {
269269
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
270270
fmt.debug_map()
271271
.entry(&"bar", &true)
272-
.entry(&10i32, &format_args!("{}/{}", 10i32, 20i32))
272+
.entry(&10, &format_args!("{}/{}", 10, 20))
273273
.finish()
274274
}
275275
}
@@ -348,7 +348,7 @@ mod debug_set {
348348
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
349349
fmt.debug_set()
350350
.entry(&true)
351-
.entry(&format_args!("{}/{}", 10i32, 20i32))
351+
.entry(&format_args!("{}/{}", 10, 20))
352352
.finish()
353353
}
354354
}
@@ -370,7 +370,7 @@ mod debug_set {
370370
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
371371
fmt.debug_set()
372372
.entry(&true)
373-
.entry(&format_args!("{}/{}", 10i32, 20i32))
373+
.entry(&format_args!("{}/{}", 10, 20))
374374
.finish()
375375
}
376376
}
@@ -445,7 +445,7 @@ mod debug_list {
445445
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
446446
fmt.debug_list()
447447
.entry(&true)
448-
.entry(&format_args!("{}/{}", 10i32, 20i32))
448+
.entry(&format_args!("{}/{}", 10, 20))
449449
.finish()
450450
}
451451
}
@@ -467,7 +467,7 @@ mod debug_list {
467467
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
468468
fmt.debug_list()
469469
.entry(&true)
470-
.entry(&format_args!("{}/{}", 10i32, 20i32))
470+
.entry(&format_args!("{}/{}", 10, 20))
471471
.finish()
472472
}
473473
}

‎src/libcoretest/iter.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ fn test_rev() {
677677

678678
#[test]
679679
fn test_cloned() {
680-
let xs = [2u8, 4, 6, 8];
680+
let xs = [2, 4, 6, 8];
681681

682682
let mut it = xs.iter().cloned();
683683
assert_eq!(it.len(), 4);
@@ -861,8 +861,8 @@ fn test_range() {
861861
assert_eq!((-10..-1).size_hint(), (9, Some(9)));
862862
assert_eq!((-1..-10).size_hint(), (0, Some(0)));
863863

864-
assert_eq!((-70..58i8).size_hint(), (128, Some(128)));
865-
assert_eq!((-128..127i8).size_hint(), (255, Some(255)));
864+
assert_eq!((-70..58).size_hint(), (128, Some(128)));
865+
assert_eq!((-128..127).size_hint(), (255, Some(255)));
866866
assert_eq!((-2..isize::MAX).size_hint(),
867867
(isize::MAX as usize + 2, Some(isize::MAX as usize + 2)));
868868
}
@@ -1013,7 +1013,7 @@ fn bench_max_by_key2(b: &mut Bencher) {
10131013
array.iter().enumerate().max_by_key(|&(_, item)| item).unwrap().0
10141014
}
10151015

1016-
let mut data = vec![0i32; 1638];
1016+
let mut data = vec![0; 1638];
10171017
data[514] = 9999;
10181018

10191019
b.iter(|| max_index_iter(&data));

‎src/libcoretest/num/int_macros.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,11 @@ mod tests {
208208
fn test_pow() {
209209
let mut r = 2 as $T;
210210

211-
assert_eq!(r.pow(2u32), 4 as $T);
212-
assert_eq!(r.pow(0u32), 1 as $T);
211+
assert_eq!(r.pow(2), 4 as $T);
212+
assert_eq!(r.pow(0), 1 as $T);
213213
r = -2 as $T;
214-
assert_eq!(r.pow(2u32), 4 as $T);
215-
assert_eq!(r.pow(3u32), -8 as $T);
214+
assert_eq!(r.pow(2), 4 as $T);
215+
assert_eq!(r.pow(3), -8 as $T);
216216
}
217217
}
218218

‎src/libcoretest/num/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ mod tests {
9999

100100
#[test]
101101
fn test_leading_plus() {
102-
assert_eq!("+127".parse::<u8>().ok(), Some(127u8));
103-
assert_eq!("+9223372036854775807".parse::<i64>().ok(), Some(9223372036854775807i64));
102+
assert_eq!("+127".parse::<u8>().ok(), Some(127));
103+
assert_eq!("+9223372036854775807".parse::<i64>().ok(), Some(9223372036854775807));
104104
}
105105

106106
#[test]

‎src/libcoretest/option.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ fn test_collect() {
251251

252252
#[test]
253253
fn test_cloned() {
254-
let val = 1u32;
254+
let val = 1;
255255
let val_ref = &val;
256256
let opt_none: Option<&'static u32> = None;
257257
let opt_ref = Some(&val);
@@ -263,10 +263,10 @@ fn test_cloned() {
263263

264264
// Immutable ref works
265265
assert_eq!(opt_ref.clone(), Some(&val));
266-
assert_eq!(opt_ref.cloned(), Some(1u32));
266+
assert_eq!(opt_ref.cloned(), Some(1));
267267

268268
// Double Immutable ref works
269269
assert_eq!(opt_ref_ref.clone(), Some(&val_ref));
270270
assert_eq!(opt_ref_ref.clone().cloned(), Some(&val));
271-
assert_eq!(opt_ref_ref.cloned().cloned(), Some(1u32));
271+
assert_eq!(opt_ref_ref.cloned().cloned(), Some(1));
272272
}

‎src/librustc/middle/dead.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -351,15 +351,9 @@ impl<'v> Visitor<'v> for LifeSeeder {
351351
}
352352
hir::ItemImpl(_, _, _, ref opt_trait, _, ref impl_items) => {
353353
for impl_item in impl_items {
354-
match impl_item.node {
355-
hir::ImplItemKind::Const(..) |
356-
hir::ImplItemKind::Method(..) => {
357-
if opt_trait.is_some() ||
358-
has_allow_dead_code_or_lang_attr(&impl_item.attrs) {
359-
self.worklist.push(impl_item.id);
360-
}
361-
}
362-
hir::ImplItemKind::Type(_) => {}
354+
if opt_trait.is_some() ||
355+
has_allow_dead_code_or_lang_attr(&impl_item.attrs) {
356+
self.worklist.push(impl_item.id);
363357
}
364358
}
365359
}

‎src/librustc_front/hir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ pub enum Expr_ {
737737
ExprBinary(BinOp, P<Expr>, P<Expr>),
738738
/// A unary operation (For example: `!x`, `*x`)
739739
ExprUnary(UnOp, P<Expr>),
740-
/// A literal (For example: `1u8`, `"foo"`)
740+
/// A literal (For example: `1`, `"foo"`)
741741
ExprLit(P<Lit>),
742742
/// A cast (`foo as f64`)
743743
ExprCast(P<Expr>, P<Ty>),
@@ -804,7 +804,7 @@ pub enum Expr_ {
804804

805805
/// A vector literal constructed from one repeated element.
806806
///
807-
/// For example, `[1u8; 5]`. The first expression is the element
807+
/// For example, `[1; 5]`. The first expression is the element
808808
/// to be repeated; the second is the number of times to repeat it.
809809
ExprRepeat(P<Expr>, P<Expr>),
810810
}

‎src/librustc_typeck/diagnostics.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ impl Test {
379379
380380
fn main() {
381381
let x = Test;
382-
let v = &[0i32];
382+
let v = &[0];
383383
384384
x.method::<i32, i32>(v); // error: only one type parameter is expected!
385385
}
@@ -398,7 +398,7 @@ impl Test {
398398
399399
fn main() {
400400
let x = Test;
401-
let v = &[0i32];
401+
let v = &[0];
402402
403403
x.method::<i32>(v); // OK, we're good!
404404
}
@@ -901,7 +901,7 @@ Example of erroneous code:
901901
```compile_fail
902902
enum Foo { FirstValue(i32) };
903903
904-
let u = Foo::FirstValue { value: 0i32 }; // error: Foo::FirstValue
904+
let u = Foo::FirstValue { value: 0 }; // error: Foo::FirstValue
905905
// isn't a structure!
906906
// or even simpler, if the name doesn't refer to a structure at all.
907907
let t = u32 { value: 4 }; // error: `u32` does not name a structure.

‎src/libstd/ffi/os_str.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use sys::os_str::{Buf, Slice};
2222
use sys_common::{AsInner, IntoInner, FromInner};
2323

2424
/// A type that can represent owned, mutable platform-native strings, but is
25-
/// cheaply interconvertable with Rust strings.
25+
/// cheaply inter-convertible with Rust strings.
2626
///
2727
/// The need for this type arises from the fact that:
2828
///
@@ -272,7 +272,7 @@ impl OsStr {
272272
unsafe { mem::transmute(inner) }
273273
}
274274

275-
/// Yields a `&str` slice if the `OsStr` is valid unicode.
275+
/// Yields a `&str` slice if the `OsStr` is valid Unicode.
276276
///
277277
/// This conversion may entail doing a check for UTF-8 validity.
278278
#[stable(feature = "rust1", since = "1.0.0")]
@@ -301,7 +301,7 @@ impl OsStr {
301301
/// On Unix systems, this is a no-op.
302302
///
303303
/// On Windows systems, this returns `None` unless the `OsStr` is
304-
/// valid unicode, in which case it produces UTF-8-encoded
304+
/// valid Unicode, in which case it produces UTF-8-encoded
305305
/// data. This may entail checking validity.
306306
#[unstable(feature = "convert", reason = "recently added", issue = "27704")]
307307
#[rustc_deprecated(reason = "RFC was closed, hides subtle Windows semantics",

‎src/snapshots.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ S 2016-02-17 4d3eebf
66
winnt-i386 0c336d794a65f8e285c121866c7d59aa2dd0d1e1
77
winnt-x86_64 27e75b1bf99770b3564bcebd7f3230be01135a92
88
openbsd-x86_64 ac957c6b84de2bd67f01df085d9ea515f96e22f3
9+
freebsd-x86_64 395adf223f3f25514c9dffecb524f493c42a0e5d
910

1011
S 2015-12-18 3391630
1112
bitrig-x86_64 6476e1562df02389b55553b4c88b1f4fd121cd40
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![deny(dead_code)]
12+
13+
trait Foo {
14+
type Bar;
15+
}
16+
17+
struct Used;
18+
19+
struct Ex;
20+
21+
impl Foo for Ex {
22+
type Bar = Used;
23+
}
24+
25+
pub fn main() {
26+
let _x = Ex;
27+
}

0 commit comments

Comments
 (0)
Please sign in to comment.