Skip to content

Commit 3a501f7

Browse files
committed
---
yaml --- r: 272820 b: refs/heads/beta c: 45f0ce7 h: refs/heads/master
1 parent 2141e73 commit 3a501f7

File tree

19 files changed

+546
-386
lines changed

19 files changed

+546
-386
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: d908ff1759bf27a8a8a99f113a246b8abc61f425
26+
refs/heads/beta: 45f0ce71c19d8da081714dc917f11a8cc02d15be
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/mk/cfg/i686-pc-windows-gnu.mk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,3 @@ CFG_GNU_TRIPLE_i686-pc-windows-gnu := i686-w64-mingw32
2525
CFG_THIRD_PARTY_OBJECTS_i686-pc-windows-gnu := crt2.o dllcrt2.o
2626
CFG_INSTALLED_OBJECTS_i686-pc-windows-gnu := crt2.o dllcrt2.o rsbegin.o rsend.o
2727
CFG_RUSTRT_HAS_STARTUP_OBJS_i686-pc-windows-gnu := 1
28-
# FIXME(#31030) - there's not a great reason to disable jemalloc here
29-
CFG_DISABLE_JEMALLOC_i686-pc-windows-gnu := 1

branches/beta/mk/cfg/x86_64-pc-windows-gnu.mk

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,3 @@ CFG_GNU_TRIPLE_x86_64-pc-windows-gnu := x86_64-w64-mingw32
2525
CFG_THIRD_PARTY_OBJECTS_x86_64-pc-windows-gnu := crt2.o dllcrt2.o
2626
CFG_INSTALLED_OBJECTS_x86_64-pc-windows-gnu := crt2.o dllcrt2.o rsbegin.o rsend.o
2727
CFG_RUSTRT_HAS_STARTUP_OBJS_x86_64-pc-windows-gnu := 1
28-
# FIXME(#31030) - there's not a great reason to disable jemalloc here
29-
CFG_DISABLE_JEMALLOC_x86_64-pc-windows-gnu := 1

branches/beta/src/bootstrap/build/sanity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub fn check(build: &mut Build) {
7979
}
8080

8181
// Make sure musl-root is valid if specified
82-
if target.contains("musl") {
82+
if target.contains("musl") && target.contains("x86_64") {
8383
match build.config.musl_root {
8484
Some(ref root) => {
8585
if fs::metadata(root.join("lib/libc.a")).is_err() {

branches/beta/src/doc/book/vectors.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,36 @@ for i in v {
115115
}
116116
```
117117

118+
Note: You cannot use the vector again once you have iterated by taking ownership of the vector.
119+
You can iterate the vector multiple times by taking a reference to the vector whilst iterating.
120+
For example, the following code does not compile.
121+
122+
```rust,ignore
123+
let mut v = vec![1, 2, 3, 4, 5];
124+
125+
for i in v {
126+
println!("Take ownership of the vector and its element {}", i);
127+
}
128+
129+
for i in v {
130+
println!("Take ownership of the vector and its element {}", i);
131+
}
132+
```
133+
134+
Whereas the following works perfectly,
135+
136+
```rust
137+
let mut v = vec![1, 2, 3, 4, 5];
138+
139+
for i in &v {
140+
println!("This is a reference to {}", i);
141+
}
142+
143+
for i in &v {
144+
println!("This is a reference to {}", i);
145+
}
146+
```
147+
118148
Vectors have many more useful methods, which you can read about in [their
119149
API documentation][vec].
120150

branches/beta/src/jemalloc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit e24a1a025a1f214e40eedafe3b9c7b1d69937922
1+
Subproject commit aab1c0a0e0b39825b16673128729ef46310a5da8

branches/beta/src/libcore/iter.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1532,7 +1532,7 @@ pub trait Iterator {
15321532
/// An iterator adaptor that applies a function, producing a single, final value.
15331533
///
15341534
/// `fold()` takes two arguments: an initial value, and a closure with two
1535-
/// arguments: an 'accumulator', and an element. It returns the value that
1535+
/// arguments: an 'accumulator', and an element. The closure returns the value that
15361536
/// the accumulator should have for the next iteration.
15371537
///
15381538
/// The initial value is the value the accumulator will have on the first
@@ -3851,6 +3851,17 @@ impl<I> Iterator for Skip<I> where I: Iterator {
38513851
#[stable(feature = "rust1", since = "1.0.0")]
38523852
impl<I> ExactSizeIterator for Skip<I> where I: ExactSizeIterator {}
38533853

3854+
#[stable(feature = "double_ended_skip_iterator", since = "1.8.0")]
3855+
impl<I> DoubleEndedIterator for Skip<I> where I: DoubleEndedIterator + ExactSizeIterator {
3856+
fn next_back(&mut self) -> Option<Self::Item> {
3857+
if self.len() > 0 {
3858+
self.iter.next_back()
3859+
} else {
3860+
None
3861+
}
3862+
}
3863+
}
3864+
38543865
/// An iterator that only iterates over the first `n` iterations of `iter`.
38553866
///
38563867
/// This `struct` is created by the [`take()`] method on [`Iterator`]. See its

branches/beta/src/libcore/str/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,8 +1095,6 @@ fn eq_slice(a: &str, b: &str) -> bool {
10951095
/// faster than comparing each byte in a loop.
10961096
#[inline]
10971097
unsafe fn cmp_slice(a: &str, b: &str, len: usize) -> i32 {
1098-
// NOTE: In theory n should be libc::size_t and not usize, but libc is not available here
1099-
#[allow(improper_ctypes)]
11001098
extern { fn memcmp(s1: *const i8, s2: *const i8, n: usize) -> i32; }
11011099
memcmp(a.as_ptr() as *const i8, b.as_ptr() as *const i8, len)
11021100
}

branches/beta/src/libcoretest/iter.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,44 @@ fn test_iterator_skip() {
303303
assert_eq!(it.len(), 0);
304304
}
305305

306+
#[test]
307+
fn test_iterator_skip_doubleended() {
308+
let xs = [0, 1, 2, 3, 5, 13, 15, 16, 17, 19, 20, 30];
309+
let mut it = xs.iter().rev().skip(5);
310+
assert_eq!(it.next(), Some(&15));
311+
assert_eq!(it.by_ref().rev().next(), Some(&0));
312+
assert_eq!(it.next(), Some(&13));
313+
assert_eq!(it.by_ref().rev().next(), Some(&1));
314+
assert_eq!(it.next(), Some(&5));
315+
assert_eq!(it.by_ref().rev().next(), Some(&2));
316+
assert_eq!(it.next(), Some(&3));
317+
assert_eq!(it.next(), None);
318+
let mut it = xs.iter().rev().skip(5).rev();
319+
assert_eq!(it.next(), Some(&0));
320+
assert_eq!(it.rev().next(), Some(&15));
321+
let mut it_base = xs.iter();
322+
{
323+
let mut it = it_base.by_ref().skip(5).rev();
324+
assert_eq!(it.next(), Some(&30));
325+
assert_eq!(it.next(), Some(&20));
326+
assert_eq!(it.next(), Some(&19));
327+
assert_eq!(it.next(), Some(&17));
328+
assert_eq!(it.next(), Some(&16));
329+
assert_eq!(it.next(), Some(&15));
330+
assert_eq!(it.next(), Some(&13));
331+
assert_eq!(it.next(), None);
332+
}
333+
// make sure the skipped parts have not been consumed
334+
assert_eq!(it_base.next(), Some(&0));
335+
assert_eq!(it_base.next(), Some(&1));
336+
assert_eq!(it_base.next(), Some(&2));
337+
assert_eq!(it_base.next(), Some(&3));
338+
assert_eq!(it_base.next(), Some(&5));
339+
assert_eq!(it_base.next(), None);
340+
let it = xs.iter().skip(5).rev();
341+
assert_eq!(it.last(), Some(&13));
342+
}
343+
306344
#[test]
307345
fn test_iterator_skip_nth() {
308346
let xs = [0, 1, 2, 3, 5, 13, 15, 16, 17, 19, 20, 30];

branches/beta/src/librustc_resolve/build_reduced_graph.rs

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
9898
fn try_define<T>(&self, parent: Module<'b>, name: Name, ns: Namespace, def: T)
9999
where T: ToNameBinding<'b>
100100
{
101-
let _ = parent.try_define_child(name, ns, self.new_name_binding(def.to_name_binding()));
101+
let _ = parent.try_define_child(name, ns, def.to_name_binding());
102102
}
103103

104104
/// Defines `name` in namespace `ns` of module `parent` to be `def` if it is not yet defined;
105105
/// otherwise, reports an error.
106106
fn define<T: ToNameBinding<'b>>(&self, parent: Module<'b>, name: Name, ns: Namespace, def: T) {
107-
let binding = self.new_name_binding(def.to_name_binding());
108-
let old_binding = match parent.try_define_child(name, ns, binding) {
107+
let binding = def.to_name_binding();
108+
let old_binding = match parent.try_define_child(name, ns, binding.clone()) {
109109
Ok(()) => return,
110110
Err(old_binding) => old_binding,
111111
};
@@ -207,7 +207,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
207207
ResolutionError::SelfImportsOnlyAllowedWithin);
208208
}
209209

210-
let subclass = SingleImport(binding, source_name);
210+
let subclass = ImportDirectiveSubclass::single(binding, source_name);
211211
self.build_import_directive(parent,
212212
module_path,
213213
subclass,
@@ -258,9 +258,10 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
258258
(module_path.to_vec(), name, rename)
259259
}
260260
};
261+
let subclass = ImportDirectiveSubclass::single(rename, name);
261262
self.build_import_directive(parent,
262263
module_path,
263-
SingleImport(rename, name),
264+
subclass,
264265
source_item.span,
265266
source_item.node.id(),
266267
is_public,
@@ -294,14 +295,6 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
294295
let module = self.new_extern_crate_module(parent_link, def, is_public, item.id);
295296
self.define(parent, name, TypeNS, (module, sp));
296297

297-
if is_public {
298-
let export = Export { name: name, def_id: def_id };
299-
if let Some(def_id) = parent.def_id() {
300-
let node_id = self.resolver.ast_map.as_local_node_id(def_id).unwrap();
301-
self.export_map.entry(node_id).or_insert(Vec::new()).push(export);
302-
}
303-
}
304-
305298
self.build_reduced_graph_for_external_crate(module);
306299
}
307300
parent
@@ -683,33 +676,25 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
683676
id: NodeId,
684677
is_public: bool,
685678
shadowable: Shadowable) {
686-
module_.unresolved_imports
687-
.borrow_mut()
688-
.push(ImportDirective::new(module_path, subclass, span, id, is_public, shadowable));
689-
self.unresolved_imports += 1;
690-
691-
if is_public {
692-
module_.inc_pub_count();
693-
}
694-
695679
// Bump the reference count on the name. Or, if this is a glob, set
696680
// the appropriate flag.
697681

698682
match subclass {
699-
SingleImport(target, _) => {
683+
SingleImport { target, .. } => {
700684
module_.increment_outstanding_references_for(target, ValueNS);
701685
module_.increment_outstanding_references_for(target, TypeNS);
702686
}
703687
GlobImport => {
704688
// Set the glob flag. This tells us that we don't know the
705689
// module's exports ahead of time.
706-
707-
module_.inc_glob_count();
708-
if is_public {
709-
module_.inc_pub_glob_count();
710-
}
690+
module_.inc_glob_count(is_public)
711691
}
712692
}
693+
694+
let directive =
695+
ImportDirective::new(module_path, subclass, span, id, is_public, shadowable);
696+
module_.add_import_directive(directive);
697+
self.unresolved_imports += 1;
713698
}
714699
}
715700

0 commit comments

Comments
 (0)