Skip to content

Commit 5a3b8a1

Browse files
committed
---
yaml --- r: 210342 b: refs/heads/try c: 29d7fed h: refs/heads/master v: v3
1 parent 1950795 commit 5a3b8a1

File tree

16 files changed

+87
-316
lines changed

16 files changed

+87
-316
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 3e561f05c00cd180ec02db4ccab2840a4aba93d2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ba0e1cd8147d452c356aacb29fb87568ca26f111
5-
refs/heads/try: e6378cbda39521fa3b9a457b5ed36ecefe37f932
5+
refs/heads/try: 29d7fed994bb35c1cf7e686a3fe967ddff734d01
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/mk/crates.mk

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ RUSTC_CRATES := rustc rustc_typeck rustc_borrowck rustc_resolve rustc_driver \
5858
rustc_data_structures
5959
HOST_CRATES := syntax $(RUSTC_CRATES) rustdoc fmt_macros
6060
CRATES := $(TARGET_CRATES) $(HOST_CRATES)
61-
TOOLS := compiletest rustdoc rustc rustbook error-index-generator
61+
TOOLS := compiletest rustdoc rustc rustbook
6262

6363
DEPS_core :=
6464
DEPS_libc := core
@@ -107,12 +107,10 @@ TOOL_DEPS_compiletest := test getopts
107107
TOOL_DEPS_rustdoc := rustdoc
108108
TOOL_DEPS_rustc := rustc_driver
109109
TOOL_DEPS_rustbook := std rustdoc
110-
TOOL_DEPS_error-index-generator := rustdoc syntax serialize
111110
TOOL_SOURCE_compiletest := $(S)src/compiletest/compiletest.rs
112111
TOOL_SOURCE_rustdoc := $(S)src/driver/driver.rs
113112
TOOL_SOURCE_rustc := $(S)src/driver/driver.rs
114113
TOOL_SOURCE_rustbook := $(S)src/rustbook/main.rs
115-
TOOL_SOURCE_error-index-generator := $(S)src/error-index-generator/main.rs
116114

117115
ONLY_RLIB_core := 1
118116
ONLY_RLIB_libc := 1

branches/try/mk/docs.mk

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,9 @@ RUSTBOOK_EXE = $(HBIN2_H_$(CFG_BUILD))/rustbook$(X_$(CFG_BUILD))
7171
# ./configure
7272
RUSTBOOK = $(RPATH_VAR2_T_$(CFG_BUILD)_H_$(CFG_BUILD)) $(RUSTBOOK_EXE)
7373

74-
# The error-index-generator executable...
75-
ERR_IDX_GEN_EXE = $(HBIN2_H_$(CFG_BUILD))/error-index-generator$(X_$(CFG_BUILD))
76-
ERR_IDX_GEN = $(RPATH_VAR2_T_$(CFG_BUILD)_H_$(CFG_BUILD)) $(ERR_IDX_GEN_EXE)
77-
7874
D := $(S)src/doc
7975

80-
DOC_TARGETS := trpl style error-index
76+
DOC_TARGETS := trpl style
8177
COMPILER_DOC_TARGETS :=
8278
DOC_L10N_TARGETS :=
8379

@@ -292,9 +288,3 @@ doc/style/index.html: $(RUSTBOOK_EXE) $(wildcard $(S)/src/doc/style/*.md) | doc/
292288
@$(call E, rustbook: $@)
293289
$(Q)rm -rf doc/style
294290
$(Q)$(RUSTBOOK) build $(S)src/doc/style doc/style
295-
296-
error-index: doc/error-index.html
297-
298-
doc/error-index.html: $(ERR_IDX_GEN_EXE) | doc/
299-
$(Q)$(call E, error-index-generator: $@)
300-
$(Q)$(ERR_IDX_GEN)

branches/try/mk/prepare.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ define PREPARE_MAN
7070
$(Q)$(PREPARE_MAN_CMD) $(PREPARE_SOURCE_MAN_DIR)/$(1) $(PREPARE_DEST_MAN_DIR)/$(1)
7171
endef
7272

73-
PREPARE_TOOLS = $(filter-out compiletest rustbook error-index-generator, $(TOOLS))
73+
PREPARE_TOOLS = $(filter-out compiletest rustbook, $(TOOLS))
7474

7575

7676
# $(1) is tool

branches/try/src/error-index-generator/main.rs

Lines changed: 0 additions & 119 deletions
This file was deleted.

branches/try/src/libcollections/slice.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -996,13 +996,9 @@ impl<T> [T] {
996996
////////////////////////////////////////////////////////////////////////////////
997997
// Extension traits for slices over specific kinds of data
998998
////////////////////////////////////////////////////////////////////////////////
999-
#[unstable(feature = "collections", reason = "recently changed")]
999+
#[unstable(feature = "collections", reason = "U should be an associated type")]
10001000
/// An extension trait for concatenating slices
1001-
pub trait SliceConcatExt<T: ?Sized> {
1002-
#[unstable(feature = "collections", reason = "recently changed")]
1003-
/// The resulting type after concatenation
1004-
type Output;
1005-
1001+
pub trait SliceConcatExt<T: ?Sized, U> {
10061002
/// Flattens a slice of `T` into a single value `U`.
10071003
///
10081004
/// # Examples
@@ -1011,7 +1007,7 @@ pub trait SliceConcatExt<T: ?Sized> {
10111007
/// assert_eq!(["hello", "world"].concat(), "helloworld");
10121008
/// ```
10131009
#[stable(feature = "rust1", since = "1.0.0")]
1014-
fn concat(&self) -> Self::Output;
1010+
fn concat(&self) -> U;
10151011

10161012
/// Flattens a slice of `T` into a single value `U`, placing a given separator between each.
10171013
///
@@ -1021,12 +1017,10 @@ pub trait SliceConcatExt<T: ?Sized> {
10211017
/// assert_eq!(["hello", "world"].connect(" "), "hello world");
10221018
/// ```
10231019
#[stable(feature = "rust1", since = "1.0.0")]
1024-
fn connect(&self, sep: &T) -> Self::Output;
1020+
fn connect(&self, sep: &T) -> U;
10251021
}
10261022

1027-
impl<T: Clone, V: AsRef<[T]>> SliceConcatExt<T> for [V] {
1028-
type Output = Vec<T>;
1029-
1023+
impl<T: Clone, V: AsRef<[T]>> SliceConcatExt<T, Vec<T>> for [V] {
10301024
fn concat(&self) -> Vec<T> {
10311025
let size = self.iter().fold(0, |acc, v| acc + v.as_ref().len());
10321026
let mut result = Vec::with_capacity(size);

branches/try/src/libcollections/str.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,7 @@ pub use core::str::pattern;
8383
Section: Creating a string
8484
*/
8585

86-
impl<S: AsRef<str>> SliceConcatExt<str> for [S] {
87-
type Output = String;
88-
86+
impl<S: AsRef<str>> SliceConcatExt<str, String> for [S] {
8987
fn concat(&self) -> String {
9088
if self.is_empty() {
9189
return String::new();

branches/try/src/libcore/iter.rs

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,18 @@ pub trait Iterator {
106106

107107
/// Counts the number of elements in this iterator.
108108
///
109+
/// # Overflow Behavior
110+
///
111+
/// The method does no guarding against overflows, so counting elements of
112+
/// an iterator with more than `usize::MAX` elements either produces the
113+
/// wrong result or panics. If debug assertions are enabled, a panic is
114+
/// guaranteed.
115+
///
116+
/// # Panics
117+
///
118+
/// This functions might panic if the iterator has more than `usize::MAX`
119+
/// elements.
120+
///
109121
/// # Examples
110122
///
111123
/// ```
@@ -115,7 +127,8 @@ pub trait Iterator {
115127
#[inline]
116128
#[stable(feature = "rust1", since = "1.0.0")]
117129
fn count(self) -> usize where Self: Sized {
118-
self.fold(0, |cnt, _x| cnt + 1)
130+
// Might overflow.
131+
self.fold(0, |cnt, _| cnt + 1)
119132
}
120133

121134
/// Loops through the entire iterator, returning the last element.
@@ -281,6 +294,17 @@ pub trait Iterator {
281294
/// different sized integer, the `zip` function provides similar
282295
/// functionality.
283296
///
297+
/// # Overflow Behavior
298+
///
299+
/// The method does no guarding against overflows, so enumerating more than
300+
/// `usize::MAX` elements either produces the wrong result or panics. If
301+
/// debug assertions are enabled, a panic is guaranteed.
302+
///
303+
/// # Panics
304+
///
305+
/// The returned iterator might panic if the to-be-returned index would
306+
/// overflow a `usize`.
307+
///
284308
/// # Examples
285309
///
286310
/// ```
@@ -293,7 +317,7 @@ pub trait Iterator {
293317
#[inline]
294318
#[stable(feature = "rust1", since = "1.0.0")]
295319
fn enumerate(self) -> Enumerate<Self> where Self: Sized {
296-
Enumerate{iter: self, count: 0}
320+
Enumerate { iter: self, count: 0 }
297321
}
298322

299323
/// Creates an iterator that has a `.peek()` method
@@ -672,6 +696,18 @@ pub trait Iterator {
672696
///
673697
/// Does not consume the iterator past the first found element.
674698
///
699+
/// # Overflow Behavior
700+
///
701+
/// The method does no guarding against overflows, so if there are more
702+
/// than `usize::MAX` non-matching elements, it either produces the wrong
703+
/// result or panics. If debug assertions are enabled, a panic is
704+
/// guaranteed.
705+
///
706+
/// # Panics
707+
///
708+
/// This functions might panic if the iterator has more than `usize::MAX`
709+
/// non-matching elements.
710+
///
675711
/// # Examples
676712
///
677713
/// ```
@@ -685,12 +721,11 @@ pub trait Iterator {
685721
Self: Sized,
686722
P: FnMut(Self::Item) -> bool,
687723
{
688-
let mut i = 0;
689-
for x in self.by_ref() {
724+
// `enumerate` might overflow.
725+
for (i, x) in self.by_ref().enumerate() {
690726
if predicate(x) {
691727
return Some(i);
692728
}
693-
i += 1;
694729
}
695730
None
696731
}
@@ -720,6 +755,8 @@ pub trait Iterator {
720755
if predicate(v) {
721756
return Some(i - 1);
722757
}
758+
// No need for an overflow check here, because `ExactSizeIterator`
759+
// implies that the number of elements fits into a `usize`.
723760
i -= 1;
724761
}
725762
None
@@ -1783,17 +1820,27 @@ impl<B, I: DoubleEndedIterator, F> DoubleEndedIterator for FilterMap<I, F>
17831820
#[stable(feature = "rust1", since = "1.0.0")]
17841821
pub struct Enumerate<I> {
17851822
iter: I,
1786-
count: usize
1823+
count: usize,
17871824
}
17881825

17891826
#[stable(feature = "rust1", since = "1.0.0")]
17901827
impl<I> Iterator for Enumerate<I> where I: Iterator {
17911828
type Item = (usize, <I as Iterator>::Item);
17921829

1830+
/// # Overflow Behavior
1831+
///
1832+
/// The method does no guarding against overflows, so enumerating more than
1833+
/// `usize::MAX` elements either produces the wrong result or panics. If
1834+
/// debug assertions are enabled, a panic is guaranteed.
1835+
///
1836+
/// # Panics
1837+
///
1838+
/// Might panic if the index of the element overflows a `usize`.
17931839
#[inline]
17941840
fn next(&mut self) -> Option<(usize, <I as Iterator>::Item)> {
17951841
self.iter.next().map(|a| {
17961842
let ret = (self.count, a);
1843+
// Possible undefined overflow.
17971844
self.count += 1;
17981845
ret
17991846
})
@@ -1827,6 +1874,8 @@ impl<I> DoubleEndedIterator for Enumerate<I> where
18271874
fn next_back(&mut self) -> Option<(usize, <I as Iterator>::Item)> {
18281875
self.iter.next_back().map(|a| {
18291876
let len = self.iter.len();
1877+
// Can safely add, `ExactSizeIterator` promises that the number of
1878+
// elements fits into a `usize`.
18301879
(self.count + len, a)
18311880
})
18321881
}
@@ -1841,6 +1890,9 @@ impl<I> RandomAccessIterator for Enumerate<I> where I: RandomAccessIterator {
18411890

18421891
#[inline]
18431892
fn idx(&mut self, index: usize) -> Option<(usize, <I as Iterator>::Item)> {
1893+
// Can safely add, `ExactSizeIterator` (ancestor of
1894+
// `RandomAccessIterator`) promises that the number of elements fits
1895+
// into a `usize`.
18441896
self.iter.idx(index).map(|a| (self.count + index, a))
18451897
}
18461898
}

0 commit comments

Comments
 (0)