Skip to content

Commit 5f7b330

Browse files
committed
Auto merge of #42203 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
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:
2 parents 5b13bff + 3e2989b commit 5f7b330

File tree

282 files changed

+795
-732
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

282 files changed

+795
-732
lines changed

src/Cargo.lock

-29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bootstrap/bootstrap.py

+21-18
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,13 @@ def unpack(tarball, dst, verbose=False, match=None):
127127
shutil.move(tp, fp)
128128
shutil.rmtree(os.path.join(dst, fname))
129129

130-
def run(args, verbose=False, exception=False, cwd=None):
130+
def run(args, verbose=False, exception=False, cwd=None, env=None):
131131
if verbose:
132132
print("running: " + ' '.join(args))
133133
sys.stdout.flush()
134134
# Use Popen here instead of call() as it apparently allows powershell on
135135
# Windows to not lock up waiting for input presumably.
136-
ret = subprocess.Popen(args, cwd=cwd)
136+
ret = subprocess.Popen(args, cwd=cwd, env=env)
137137
code = ret.wait()
138138
if code != 0:
139139
err = "failed to run: " + ' '.join(args)
@@ -385,17 +385,15 @@ def build_bootstrap(self):
385385
raise Exception("no cargo executable found at `%s`" % self.cargo())
386386
args = [self.cargo(), "build", "--manifest-path",
387387
os.path.join(self.rust_root, "src/bootstrap/Cargo.toml")]
388+
if self.verbose:
389+
args.append("--verbose")
390+
if self.verbose > 1:
391+
args.append("--verbose")
388392
if self.use_locked_deps:
389393
args.append("--locked")
390394
if self.use_vendored_sources:
391395
args.append("--frozen")
392-
self.run(args, env)
393-
394-
def run(self, args, env=None, cwd=None):
395-
proc = subprocess.Popen(args, env=env, cwd=cwd)
396-
ret = proc.wait()
397-
if ret != 0:
398-
sys.exit(ret)
396+
run(args, env=env, verbose=self.verbose)
399397

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

570-
self.run(["git", "submodule", "sync"], cwd=self.rust_root)
568+
run(["git", "submodule", "sync"], cwd=self.rust_root)
571569

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

582580
if status == ' ':
583-
self.run(["git", "reset", "--hard"], cwd=submod_path)
584-
self.run(["git", "clean", "-fdx"], cwd=submod_path)
581+
run(["git", "reset", "--hard"], cwd=submod_path)
582+
run(["git", "clean", "-fdx"], cwd=submod_path)
585583
elif status == '+':
586-
self.run(["git", "submodule", "update", path], cwd=self.rust_root)
587-
self.run(["git", "reset", "--hard"], cwd=submod_path)
588-
self.run(["git", "clean", "-fdx"], cwd=submod_path)
584+
run(["git", "submodule", "update", path], cwd=self.rust_root)
585+
run(["git", "reset", "--hard"], cwd=submod_path)
586+
run(["git", "clean", "-fdx"], cwd=submod_path)
589587
elif status == '-':
590-
self.run(["git", "submodule", "init", path], cwd=self.rust_root)
591-
self.run(["git", "submodule", "update", path], cwd=self.rust_root)
588+
run(["git", "submodule", "init", path], cwd=self.rust_root)
589+
run(["git", "submodule", "update", path], cwd=self.rust_root)
592590
else:
593591
raise ValueError('unknown submodule status: ' + status)
594592

@@ -620,6 +618,11 @@ def bootstrap():
620618
except:
621619
pass
622620

621+
if '\nverbose = 2' in rb.config_toml:
622+
rb.verbose = 2
623+
elif '\nverbose = 1' in rb.config_toml:
624+
rb.verbose = 1
625+
623626
rb.use_vendored_sources = '\nvendor = true' in rb.config_toml or \
624627
'CFG_ENABLE_VENDOR' in rb.config_mk
625628

@@ -676,7 +679,7 @@ def bootstrap():
676679
env["BUILD"] = rb.build
677680
env["SRC"] = rb.rust_root
678681
env["BOOTSTRAP_PARENT_ID"] = str(os.getpid())
679-
rb.run(args, env)
682+
run(args, env=env, verbose=rb.verbose)
680683

681684
def main():
682685
start_time = time()

src/libcollections/range.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,10 @@ impl<T> RangeArgument<T> for Range<T> {
106106
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
107107
impl<T> RangeArgument<T> for RangeInclusive<T> {
108108
fn start(&self) -> Bound<&T> {
109-
match *self {
110-
RangeInclusive::Empty{ ref at } => Included(at),
111-
RangeInclusive::NonEmpty { ref start, .. } => Included(start),
112-
}
109+
Included(&self.start)
113110
}
114111
fn end(&self) -> Bound<&T> {
115-
match *self {
116-
RangeInclusive::Empty{ ref at } => Excluded(at),
117-
RangeInclusive::NonEmpty { ref end, .. } => Included(end),
118-
}
112+
Included(&self.end)
119113
}
120114
}
121115

src/libcore/iter/range.rs

+55-119
Original file line numberDiff line numberDiff line change
@@ -403,61 +403,35 @@ impl<A: Step + Clone> Iterator for StepBy<A, ops::RangeInclusive<A>> {
403403

404404
#[inline]
405405
fn next(&mut self) -> Option<A> {
406-
use ops::RangeInclusive::*;
407-
408-
// this function has a sort of odd structure due to borrowck issues
409-
// we may need to replace self.range, so borrows of start and end need to end early
410-
411-
let (finishing, n) = match self.range {
412-
Empty { .. } => return None, // empty iterators yield no values
413-
414-
NonEmpty { ref mut start, ref mut end } => {
415-
let rev = self.step_by.is_negative();
416-
417-
// march start towards (maybe past!) end and yield the old value
418-
if (rev && start >= end) ||
419-
(!rev && start <= end)
420-
{
421-
match start.step(&self.step_by) {
422-
Some(mut n) => {
423-
mem::swap(start, &mut n);
424-
(None, Some(n)) // yield old value, remain non-empty
425-
},
426-
None => {
427-
let mut n = end.clone();
428-
mem::swap(start, &mut n);
429-
(None, Some(n)) // yield old value, remain non-empty
430-
}
431-
}
432-
} else {
433-
// found range in inconsistent state (start at or past end), so become empty
434-
(Some(end.replace_zero()), None)
435-
}
436-
}
437-
};
406+
let rev = self.step_by.is_negative();
438407

439-
// turn into an empty iterator if we've reached the end
440-
if let Some(end) = finishing {
441-
self.range = Empty { at: end };
408+
if (rev && self.range.start >= self.range.end) ||
409+
(!rev && self.range.start <= self.range.end)
410+
{
411+
match self.range.start.step(&self.step_by) {
412+
Some(n) => {
413+
Some(mem::replace(&mut self.range.start, n))
414+
},
415+
None => {
416+
let last = self.range.start.replace_one();
417+
self.range.end.replace_zero();
418+
self.step_by.replace_one();
419+
Some(last)
420+
},
421+
}
422+
}
423+
else {
424+
None
442425
}
443-
444-
n
445426
}
446427

447428
#[inline]
448429
fn size_hint(&self) -> (usize, Option<usize>) {
449-
use ops::RangeInclusive::*;
450-
451-
match self.range {
452-
Empty { .. } => (0, Some(0)),
453-
454-
NonEmpty { ref start, ref end } =>
455-
match Step::steps_between(start,
456-
end,
457-
&self.step_by) {
458-
Some(hint) => (hint.saturating_add(1), hint.checked_add(1)),
459-
None => (0, None)
460-
}
430+
match Step::steps_between(&self.range.start,
431+
&self.range.end,
432+
&self.step_by) {
433+
Some(hint) => (hint.saturating_add(1), hint.checked_add(1)),
434+
None => (0, None)
461435
}
462436
}
463437
}
@@ -583,56 +557,31 @@ impl<A: Step> Iterator for ops::RangeInclusive<A> where
583557

584558
#[inline]
585559
fn next(&mut self) -> Option<A> {
586-
use ops::RangeInclusive::*;
587-
588-
// this function has a sort of odd structure due to borrowck issues
589-
// we may need to replace self, so borrows of self.start and self.end need to end early
590-
591-
let (finishing, n) = match *self {
592-
Empty { .. } => (None, None), // empty iterators yield no values
593-
594-
NonEmpty { ref mut start, ref mut end } => {
595-
if start == end {
596-
(Some(end.replace_one()), Some(start.replace_one()))
597-
} else if start < end {
598-
let mut n = start.add_one();
599-
mem::swap(&mut n, start);
600-
601-
// if the iterator is done iterating, it will change from
602-
// NonEmpty to Empty to avoid unnecessary drops or clones,
603-
// we'll reuse either start or end (they are equal now, so
604-
// it doesn't matter which) to pull out end, we need to swap
605-
// something back in
606-
607-
(if n == *end { Some(end.replace_one()) } else { None },
608-
// ^ are we done yet?
609-
Some(n)) // < the value to output
610-
} else {
611-
(Some(start.replace_one()), None)
612-
}
613-
}
614-
};
615-
616-
// turn into an empty iterator if this is the last value
617-
if let Some(end) = finishing {
618-
*self = Empty { at: end };
560+
use cmp::Ordering::*;
561+
562+
match self.start.partial_cmp(&self.end) {
563+
Some(Less) => {
564+
let n = self.start.add_one();
565+
Some(mem::replace(&mut self.start, n))
566+
},
567+
Some(Equal) => {
568+
let last = self.start.replace_one();
569+
self.end.replace_zero();
570+
Some(last)
571+
},
572+
_ => None,
619573
}
620-
621-
n
622574
}
623575

624576
#[inline]
625577
fn size_hint(&self) -> (usize, Option<usize>) {
626-
use ops::RangeInclusive::*;
627-
628-
match *self {
629-
Empty { .. } => (0, Some(0)),
578+
if !(self.start <= self.end) {
579+
return (0, Some(0));
580+
}
630581

631-
NonEmpty { ref start, ref end } =>
632-
match Step::steps_between_by_one(start, end) {
633-
Some(hint) => (hint.saturating_add(1), hint.checked_add(1)),
634-
None => (0, None),
635-
}
582+
match Step::steps_between_by_one(&self.start, &self.end) {
583+
Some(hint) => (hint.saturating_add(1), hint.checked_add(1)),
584+
None => (0, None),
636585
}
637586
}
638587
}
@@ -644,33 +593,20 @@ impl<A: Step> DoubleEndedIterator for ops::RangeInclusive<A> where
644593
{
645594
#[inline]
646595
fn next_back(&mut self) -> Option<A> {
647-
use ops::RangeInclusive::*;
648-
649-
// see Iterator::next for comments
650-
651-
let (finishing, n) = match *self {
652-
Empty { .. } => return None,
653-
654-
NonEmpty { ref mut start, ref mut end } => {
655-
if start == end {
656-
(Some(start.replace_one()), Some(end.replace_one()))
657-
} else if start < end {
658-
let mut n = end.sub_one();
659-
mem::swap(&mut n, end);
660-
661-
(if n == *start { Some(start.replace_one()) } else { None },
662-
Some(n))
663-
} else {
664-
(Some(end.replace_one()), None)
665-
}
666-
}
667-
};
668-
669-
if let Some(start) = finishing {
670-
*self = Empty { at: start };
596+
use cmp::Ordering::*;
597+
598+
match self.start.partial_cmp(&self.end) {
599+
Some(Less) => {
600+
let n = self.end.sub_one();
601+
Some(mem::replace(&mut self.end, n))
602+
},
603+
Some(Equal) => {
604+
let last = self.end.replace_zero();
605+
self.start.replace_one();
606+
Some(last)
607+
},
608+
_ => None,
671609
}
672-
673-
n
674610
}
675611
}
676612

0 commit comments

Comments
 (0)