Skip to content

Commit

Permalink
Auto merge of #42203 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
Rollup of 16 pull requests

- Successful merges: #41700, #41980, #42052, #42071, #42120, #42134, #42141, #42142, #42149, #42150, #42159, #42177, #42186, #42191, #42195, #42198
- Failed merges:
  • Loading branch information
bors committed May 24, 2017
2 parents 5b13bff + 3e2989b commit 5f7b330
Show file tree
Hide file tree
Showing 282 changed files with 795 additions and 732 deletions.
29 changes: 0 additions & 29 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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
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
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
Loading

0 comments on commit 5f7b330

Please sign in to comment.