Skip to content
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

Rollup of 17 pull requests #42199

Closed
wants to merge 44 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
770bd57
Add `'static` and `Send` constraints explanations to `thread::spawn`
May 13, 2017
b384b18
Refactor: Move the mutable parts out of LintStore. Fix #42007.
kennytm May 15, 2017
a256630
Add an option to the parser to avoid parsing out of line modules
nrc May 17, 2017
37b9ee2
Make assignments to `Copy` union fields safe
petrochenkov May 18, 2017
59b65b3
Use parameter environment associated with field use, not field defini…
petrochenkov May 18, 2017
9ad0dba
remove "much" from unicode diagnostic
euclio May 20, 2017
f166bd9
Make RangeInclusive just a two-field struct
scottmcm Apr 24, 2017
7eaca60
Return a correct size_hint for degenerate inclusive ranges
scottmcm May 21, 2017
66237af
Fix building without backtrace feature, which was broken in ca8b754
ids1024 May 21, 2017
f4147e5
Implement requires_synchronized_create() for Redox
ids1024 May 21, 2017
0b85b64
libstd/sync/mpsc: relicense under rust license
dvyukov May 22, 2017
14b767d
Add example of recursive drop to Drop trait.
Havvy May 22, 2017
ca909c8
Add example of variable declaration drop order to Drop trait.
Havvy May 22, 2017
d7927ff
Add description of how values are dropped to Drop trait.
Havvy May 22, 2017
5f4b0ff
Fix trailing whitespace.
Havvy May 22, 2017
b41b294
Suggested changes by birkenfeld
Havvy May 23, 2017
57f260d
Override size_hint and propagate ExactSizeIterator for iter::StepBy
scottmcm May 23, 2017
4be488c
Add iterator_step_by to the unstable book's summary
scottmcm May 21, 2017
fcb3a71
Update description of iter::StepBy
scottmcm May 21, 2017
21dd71f
incr.comp.: Track expanded spans instead of FileMaps.
michaelwoerister May 23, 2017
e860655
Remove some needless // gate-test- comments
est31 May 23, 2017
2aa6700
bootstrap: Actually respect verbosity setting in config.toml
devurandom May 24, 2017
604f716
bootstrap: Make bootstrap verbose if requested
devurandom May 24, 2017
cd86a9b
bootstrap: Use common run() function to call cargo
devurandom May 24, 2017
5558c64
Change error count messages
citizen428 May 22, 2017
f6d935b
fix broken link to nomicon in Unsize docs
SamWhited May 24, 2017
55c3f0b
Add missing urls for OsStr docs
GuillaumeGomez May 24, 2017
2d30dbc
Rollup merge of #41980 - gamazeps:thread-send, r=steveklabnik
Mark-Simulacrum May 24, 2017
72ac47a
Rollup merge of #42052 - kennytm:fix-42007-ice-on-decode-lint-id, r=n…
Mark-Simulacrum May 24, 2017
5dde9e8
Rollup merge of #42071 - nrc:parse-mods, r=nikomatsakis
Mark-Simulacrum May 24, 2017
eaaee46
Rollup merge of #42083 - petrochenkov:safeassign, r=nikomatsakis
Mark-Simulacrum May 24, 2017
dfb7a00
Rollup merge of #42120 - euclio:unicode, r=arielb1
Mark-Simulacrum May 24, 2017
14baa64
Rollup merge of #42134 - scottmcm:rangeinclusive-struct, r=aturon
Mark-Simulacrum May 24, 2017
9fdb2f6
Rollup merge of #42141 - ids1024:nobacktrace, r=aturon
Mark-Simulacrum May 24, 2017
6b9108e
Rollup merge of #42142 - ids1024:redox, r=aturon
Mark-Simulacrum May 24, 2017
7e1cbc7
Rollup merge of #42149 - dvyukov:license, r=brson
Mark-Simulacrum May 24, 2017
af17281
Rollup merge of #42150 - citizen428:feature/error-count-messages, r=M…
Mark-Simulacrum May 24, 2017
54514a8
Rollup merge of #42159 - Havvy:doc-drop, r=steveklabnik
Mark-Simulacrum May 24, 2017
3f08c03
Rollup merge of #42167 - scottmcm:iter-stepby-sizehint, r=alexcrichton
Mark-Simulacrum May 24, 2017
d5403b9
Rollup merge of #42175 - michaelwoerister:filemap-hashing-fix-1, r=ni…
Mark-Simulacrum May 24, 2017
2d42013
Rollup merge of #42177 - est31:master, r=Mark-Simulacrum
Mark-Simulacrum May 24, 2017
4a3b3f3
Rollup merge of #42186 - devurandom:fix/bootstrap-verbose, r=alexcric…
Mark-Simulacrum May 24, 2017
5dc6dfb
Rollup merge of #42195 - SamWhited:fix_broken_link, r=steveklabnik
Mark-Simulacrum May 24, 2017
b6256f4
Rollup merge of #42198 - GuillaumeGomez:os-str-doc, r=QuietMisdreavus
Mark-Simulacrum May 24, 2017
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
39 changes: 21 additions & 18 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ def unpack(tarball, dst, verbose=False, match=None):
shutil.move(tp, fp)
shutil.rmtree(os.path.join(dst, fname))

def run(args, verbose=False, exception=False, cwd=None):
def run(args, verbose=False, exception=False, cwd=None, env=None):
if verbose:
print("running: " + ' '.join(args))
sys.stdout.flush()
# Use Popen here instead of call() as it apparently allows powershell on
# Windows to not lock up waiting for input presumably.
ret = subprocess.Popen(args, cwd=cwd)
ret = subprocess.Popen(args, cwd=cwd, env=env)
code = ret.wait()
if code != 0:
err = "failed to run: " + ' '.join(args)
Expand Down Expand Up @@ -385,17 +385,15 @@ def build_bootstrap(self):
raise Exception("no cargo executable found at `%s`" % self.cargo())
args = [self.cargo(), "build", "--manifest-path",
os.path.join(self.rust_root, "src/bootstrap/Cargo.toml")]
if self.verbose:
args.append("--verbose")
if self.verbose > 1:
args.append("--verbose")
if self.use_locked_deps:
args.append("--locked")
if self.use_vendored_sources:
args.append("--frozen")
self.run(args, env)

def run(self, args, env=None, cwd=None):
proc = subprocess.Popen(args, env=env, cwd=cwd)
ret = proc.wait()
if ret != 0:
sys.exit(ret)
run(args, env=env, verbose=self.verbose)

def output(self, args, env=None, cwd=None):
default_encoding = sys.getdefaultencoding()
Expand Down Expand Up @@ -567,7 +565,7 @@ def update_submodules(self):
path = line[1:].split(' ')[1]
submodules.append([path, line[0]])

self.run(["git", "submodule", "sync"], cwd=self.rust_root)
run(["git", "submodule", "sync"], cwd=self.rust_root)

for submod in submodules:
path, status = submod
Expand All @@ -580,15 +578,15 @@ def update_submodules(self):
submod_path = os.path.join(self.rust_root, path)

if status == ' ':
self.run(["git", "reset", "--hard"], cwd=submod_path)
self.run(["git", "clean", "-fdx"], cwd=submod_path)
run(["git", "reset", "--hard"], cwd=submod_path)
run(["git", "clean", "-fdx"], cwd=submod_path)
elif status == '+':
self.run(["git", "submodule", "update", path], cwd=self.rust_root)
self.run(["git", "reset", "--hard"], cwd=submod_path)
self.run(["git", "clean", "-fdx"], cwd=submod_path)
run(["git", "submodule", "update", path], cwd=self.rust_root)
run(["git", "reset", "--hard"], cwd=submod_path)
run(["git", "clean", "-fdx"], cwd=submod_path)
elif status == '-':
self.run(["git", "submodule", "init", path], cwd=self.rust_root)
self.run(["git", "submodule", "update", path], cwd=self.rust_root)
run(["git", "submodule", "init", path], cwd=self.rust_root)
run(["git", "submodule", "update", path], cwd=self.rust_root)
else:
raise ValueError('unknown submodule status: ' + status)

Expand Down Expand Up @@ -620,6 +618,11 @@ def bootstrap():
except:
pass

if '\nverbose = 2' in rb.config_toml:
rb.verbose = 2
elif '\nverbose = 1' in rb.config_toml:
rb.verbose = 1

rb.use_vendored_sources = '\nvendor = true' in rb.config_toml or \
'CFG_ENABLE_VENDOR' in rb.config_mk

Expand Down Expand Up @@ -676,7 +679,7 @@ def bootstrap():
env["BUILD"] = rb.build
env["SRC"] = rb.rust_root
env["BOOTSTRAP_PARENT_ID"] = str(os.getpid())
rb.run(args, env)
run(args, env=env, verbose=rb.verbose)

def main():
start_time = time()
Expand Down
1 change: 1 addition & 0 deletions src/doc/unstable-book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
- [io](library-features/io.md)
- [ip](library-features/ip.md)
- [iter_rfind](library-features/iter-rfind.md)
- [iterator_step_by](library-features/iterator-step-by.md)
- [libstd_io_internals](library-features/libstd-io-internals.md)
- [libstd_sys_internals](library-features/libstd-sys-internals.md)
- [libstd_thread_internals](library-features/libstd-thread-internals.md)
Expand Down
10 changes: 2 additions & 8 deletions src/libcollections/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,10 @@ impl<T> RangeArgument<T> for Range<T> {
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
impl<T> RangeArgument<T> for RangeInclusive<T> {
fn start(&self) -> Bound<&T> {
match *self {
RangeInclusive::Empty{ ref at } => Included(at),
RangeInclusive::NonEmpty { ref start, .. } => Included(start),
}
Included(&self.start)
}
fn end(&self) -> Bound<&T> {
match *self {
RangeInclusive::Empty{ ref at } => Excluded(at),
RangeInclusive::NonEmpty { ref end, .. } => Included(end),
}
Included(&self.end)
}
}

Expand Down
21 changes: 20 additions & 1 deletion src/libcore/iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ impl<I> Iterator for Cycle<I> where I: Clone + Iterator {
#[unstable(feature = "fused", issue = "35602")]
impl<I> FusedIterator for Cycle<I> where I: Clone + Iterator {}

/// An iterator that steps by n elements every iteration.
/// An adapter for stepping iterators by a custom amount.
///
/// This `struct` is created by the [`step_by`] method on [`Iterator`]. See
/// its documentation for more.
Expand Down Expand Up @@ -553,8 +553,27 @@ impl<I> Iterator for StepBy<I> where I: Iterator {
self.iter.nth(self.step)
}
}

#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
let inner_hint = self.iter.size_hint();

if self.first_take {
let f = |n| if n == 0 { 0 } else { 1 + (n-1)/(self.step+1) };
(f(inner_hint.0), inner_hint.1.map(f))
} else {
let f = |n| n / (self.step+1);
(f(inner_hint.0), inner_hint.1.map(f))
}
}
}

// StepBy can only make the iterator shorter, so the len will still fit.
#[unstable(feature = "iterator_step_by",
reason = "unstable replacement of Range::step_by",
issue = "27741")]
impl<I> ExactSizeIterator for StepBy<I> where I: ExactSizeIterator {}

/// An iterator that strings two iterators together.
///
/// This `struct` is created by the [`chain`] method on [`Iterator`]. See its
Expand Down
174 changes: 55 additions & 119 deletions src/libcore/iter/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,61 +403,35 @@ impl<A: Step + Clone> Iterator for StepBy<A, ops::RangeInclusive<A>> {

#[inline]
fn next(&mut self) -> Option<A> {
use ops::RangeInclusive::*;

// this function has a sort of odd structure due to borrowck issues
// we may need to replace self.range, so borrows of start and end need to end early

let (finishing, n) = match self.range {
Empty { .. } => return None, // empty iterators yield no values

NonEmpty { ref mut start, ref mut end } => {
let rev = self.step_by.is_negative();

// march start towards (maybe past!) end and yield the old value
if (rev && start >= end) ||
(!rev && start <= end)
{
match start.step(&self.step_by) {
Some(mut n) => {
mem::swap(start, &mut n);
(None, Some(n)) // yield old value, remain non-empty
},
None => {
let mut n = end.clone();
mem::swap(start, &mut n);
(None, Some(n)) // yield old value, remain non-empty
}
}
} else {
// found range in inconsistent state (start at or past end), so become empty
(Some(end.replace_zero()), None)
}
}
};
let rev = self.step_by.is_negative();

// turn into an empty iterator if we've reached the end
if let Some(end) = finishing {
self.range = Empty { at: end };
if (rev && self.range.start >= self.range.end) ||
(!rev && self.range.start <= self.range.end)
{
match self.range.start.step(&self.step_by) {
Some(n) => {
Some(mem::replace(&mut self.range.start, n))
},
None => {
let last = self.range.start.replace_one();
self.range.end.replace_zero();
self.step_by.replace_one();
Some(last)
},
}
}
else {
None
}

n
}

#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
use ops::RangeInclusive::*;

match self.range {
Empty { .. } => (0, Some(0)),

NonEmpty { ref start, ref end } =>
match Step::steps_between(start,
end,
&self.step_by) {
Some(hint) => (hint.saturating_add(1), hint.checked_add(1)),
None => (0, None)
}
match Step::steps_between(&self.range.start,
&self.range.end,
&self.step_by) {
Some(hint) => (hint.saturating_add(1), hint.checked_add(1)),
None => (0, None)
}
}
}
Expand Down Expand Up @@ -583,56 +557,31 @@ impl<A: Step> Iterator for ops::RangeInclusive<A> where

#[inline]
fn next(&mut self) -> Option<A> {
use ops::RangeInclusive::*;

// this function has a sort of odd structure due to borrowck issues
// we may need to replace self, so borrows of self.start and self.end need to end early

let (finishing, n) = match *self {
Empty { .. } => (None, None), // empty iterators yield no values

NonEmpty { ref mut start, ref mut end } => {
if start == end {
(Some(end.replace_one()), Some(start.replace_one()))
} else if start < end {
let mut n = start.add_one();
mem::swap(&mut n, start);

// if the iterator is done iterating, it will change from
// NonEmpty to Empty to avoid unnecessary drops or clones,
// we'll reuse either start or end (they are equal now, so
// it doesn't matter which) to pull out end, we need to swap
// something back in

(if n == *end { Some(end.replace_one()) } else { None },
// ^ are we done yet?
Some(n)) // < the value to output
} else {
(Some(start.replace_one()), None)
}
}
};

// turn into an empty iterator if this is the last value
if let Some(end) = finishing {
*self = Empty { at: end };
use cmp::Ordering::*;

match self.start.partial_cmp(&self.end) {
Some(Less) => {
let n = self.start.add_one();
Some(mem::replace(&mut self.start, n))
},
Some(Equal) => {
let last = self.start.replace_one();
self.end.replace_zero();
Some(last)
},
_ => None,
}

n
}

#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
use ops::RangeInclusive::*;

match *self {
Empty { .. } => (0, Some(0)),
if !(self.start <= self.end) {
return (0, Some(0));
}

NonEmpty { ref start, ref end } =>
match Step::steps_between_by_one(start, end) {
Some(hint) => (hint.saturating_add(1), hint.checked_add(1)),
None => (0, None),
}
match Step::steps_between_by_one(&self.start, &self.end) {
Some(hint) => (hint.saturating_add(1), hint.checked_add(1)),
None => (0, None),
}
}
}
Expand All @@ -644,33 +593,20 @@ impl<A: Step> DoubleEndedIterator for ops::RangeInclusive<A> where
{
#[inline]
fn next_back(&mut self) -> Option<A> {
use ops::RangeInclusive::*;

// see Iterator::next for comments

let (finishing, n) = match *self {
Empty { .. } => return None,

NonEmpty { ref mut start, ref mut end } => {
if start == end {
(Some(start.replace_one()), Some(end.replace_one()))
} else if start < end {
let mut n = end.sub_one();
mem::swap(&mut n, end);

(if n == *start { Some(start.replace_one()) } else { None },
Some(n))
} else {
(Some(end.replace_one()), None)
}
}
};

if let Some(start) = finishing {
*self = Empty { at: start };
use cmp::Ordering::*;

match self.start.partial_cmp(&self.end) {
Some(Less) => {
let n = self.end.sub_one();
Some(mem::replace(&mut self.end, n))
},
Some(Equal) => {
let last = self.end.replace_zero();
self.start.replace_one();
Some(last)
},
_ => None,
}

n
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libcore/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pub trait Sized {
/// [coerceunsized]: ../ops/trait.CoerceUnsized.html
/// [rc]: ../../std/rc/struct.Rc.html
/// [RFC982]: https://github.com/rust-lang/rfcs/blob/master/text/0982-dst-coercion.md

/// [nomicon-coerce]: ../../nomicon/coercions.html
#[unstable(feature = "unsize", issue = "27732")]
#[lang="unsize"]
pub trait Unsize<T: ?Sized> {
Expand Down
Loading