Skip to content

Commit ed9a678

Browse files
committed
---
yaml --- r: 106295 b: refs/heads/auto c: 82c8cb2 h: refs/heads/master i: 106293: bb43e1a 106291: 21bc21b 106287: df8dbb7 v: v3
1 parent 657029b commit ed9a678

Some content is hidden

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

65 files changed

+369
-456
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 5fddb4280e950c28916ac21838f7433cd199aaed
16+
refs/heads/auto: 82c8cb2abf46e95eeb2fcb3155f10c4d2bc4611f
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/mk/install.mk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# The stage we install from
1616
ISTAGE = $(PREPARE_STAGE)
1717

18+
$(eval $(call DEF_PREPARE,mkfile-install))
19+
1820
install: PREPARE_HOST=$(CFG_BUILD)
1921
install: PREPARE_TARGETS=$(CFG_TARGET)
2022
install: PREPARE_DIR_CMD=$(DEFAULT_PREPARE_DIR_CMD)
@@ -28,7 +30,7 @@ install: PREPARE_SOURCE_MAN_DIR=$(S)/man
2830
install: PREPARE_DEST_BIN_DIR=$(DESTDIR)$(CFG_PREFIX)/bin
2931
install: PREPARE_DEST_LIB_DIR=$(DESTDIR)$(CFG_LIBDIR)
3032
install: PREPARE_DEST_MAN_DIR=$(DESTDIR)$(CFG_MANDIR)/man1
31-
install: prepare-everything
33+
install: prepare-everything-mkfile-install
3234

3335

3436
# Uninstall code

branches/auto/mk/prepare.mk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ prepare-base-$(1): PREPARE_SOURCE_MAN_DIR=$$(S)/man
156156
prepare-base-$(1): PREPARE_DEST_BIN_DIR=$$(PREPARE_DEST_DIR)/bin
157157
prepare-base-$(1): PREPARE_DEST_LIB_DIR=$$(PREPARE_DEST_DIR)/$$(CFG_LIBDIR_RELATIVE)
158158
prepare-base-$(1): PREPARE_DEST_MAN_DIR=$$(PREPARE_DEST_DIR)/share/man/man1
159-
prepare-base-$(1): prepare-host-$(1) prepare-targets-$(1)
159+
prepare-base-$(1): prepare-everything-$(1)
160+
161+
prepare-everything-$(1): prepare-host-$(1) prepare-targets-$(1)
160162

161163
prepare-host-$(1): prepare-host-tools-$(1)
162164

branches/auto/src/compiletest/compiletest.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ pub mod common;
4343
pub mod errors;
4444

4545
#[start]
46-
fn start(argc: int, argv: **u8) -> int { green::start(argc, argv, main) }
46+
fn start(argc: int, argv: **u8) -> int {
47+
green::start(argc, argv, rustuv::event_loop, main)
48+
}
4749

4850
pub fn main() {
4951
let args = os::args();

branches/auto/src/doc/guide-lifetimes.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,9 +559,14 @@ points at a static constant).
559559

560560
# Named lifetimes
561561

562-
Let's look at named lifetimes in more detail. Named lifetimes allow
563-
for grouping of parameters by lifetime. For example, consider this
564-
function:
562+
Lifetimes can be named and referenced. For example, the special lifetime
563+
`'static`, which does not go out of scope, can be used to create global
564+
variables and communicate between tasks (see the manual for usecases).
565+
566+
## Parameter Lifetimes
567+
568+
Named lifetimes allow for grouping of parameters by lifetime.
569+
For example, consider this function:
565570

566571
~~~
567572
# struct Point {x: f64, y: f64}; // as before
@@ -655,6 +660,25 @@ fn select<'r, T>(shape: &Shape, threshold: f64,
655660

656661
This is equivalent to the previous definition.
657662

663+
## Labeled Control Structures
664+
665+
Named lifetime notation can also be used to control the flow of execution:
666+
667+
~~~
668+
'h: for i in range(0,10) {
669+
'g: loop {
670+
if i % 2 == 0 { continue 'h; }
671+
if i == 9 { break 'h; }
672+
break 'g;
673+
}
674+
}
675+
~~~
676+
677+
> ***Note:*** Labelled breaks are not currently supported within `while` loops.
678+
679+
Named labels are hygienic and can be used safely within macros.
680+
See the macros guide section on hygiene for more details.
681+
658682
# Conclusion
659683

660684
So there you have it: a (relatively) brief tour of the lifetime

branches/auto/src/doc/guide-macros.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,38 @@ position (in particular, not as an argument to yet another macro invocation),
398398
the expander will then proceed to evaluate `m2!()` (along with any other macro
399399
invocations `m1!(m2!())` produced).
400400

401+
# Hygiene
402+
403+
To prevent clashes, rust implements
404+
[hygienic macros](http://en.wikipedia.org/wiki/Hygienic_macro).
405+
406+
As an example, `loop` and `for-loop` labels (discussed in the lifetimes guide)
407+
will not clash. The following code will print "Hello!" only once:
408+
409+
~~~
410+
#[feature(macro_rules)];
411+
412+
macro_rules! loop_x (
413+
($e: expr) => (
414+
// $e will not interact with this 'x
415+
'x: loop {
416+
println!("Hello!");
417+
$e
418+
}
419+
);
420+
)
421+
422+
fn main() {
423+
'x: loop {
424+
loop_x!(break 'x);
425+
println!("I am never printed.");
426+
}
427+
}
428+
~~~
429+
430+
The two `'x` names did not clash, which would have caused the loop
431+
to print "I am never printed" and to run forever.
432+
401433
# A final note
402434

403435
Macros, as currently implemented, are not for the faint of heart. Even

branches/auto/src/doc/guide-runtime.md

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,27 +223,49 @@ Having a default decision made in the compiler is done out of necessity and
223223
convenience. The compiler's decision of runtime to link to is *not* an
224224
endorsement of one over the other. As always, this decision can be overridden.
225225

226-
For example, this program will be linked to "the default runtime"
226+
For example, this program will be linked to "the default runtime". The current
227+
default runtime is to use libnative.
227228

228229
~~~{.rust}
229230
fn main() {}
230231
~~~
231232

232-
Whereas this program explicitly opts into using a particular runtime
233+
### Force booting with libgreen
234+
235+
In this example, the `main` function will be booted with I/O support powered by
236+
libuv. This is done by linking to the `rustuv` crate and specifying the
237+
`rustuv::event_loop` function as the event loop factory.
238+
239+
To create a pool of green tasks which have no I/O support, you may shed the
240+
`rustuv` dependency and use the `green::basic::event_loop` function instead of
241+
`rustuv::event_loop`. All tasks will have no I/O support, but they will still be
242+
able to deschedule/reschedule (use channels, locks, etc).
233243

234244
~~~{.rust}
235245
extern crate green;
246+
extern crate rustuv;
236247
237248
#[start]
238249
fn start(argc: int, argv: **u8) -> int {
239-
green::start(argc, argv, main)
250+
green::start(argc, argv, rustuv::event_loop, main)
240251
}
241252
242253
fn main() {}
243254
~~~
244255

245-
Both libgreen/libnative provide a top-level `start` function which is used to
246-
boot an initial Rust task in that specified runtime.
256+
### Force booting with libnative
257+
258+
This program's `main` function will always be booted with libnative, running
259+
inside of an OS thread.
260+
261+
~~~{.rust}
262+
extern crate native;
263+
264+
#[start]
265+
fn start(argc: int, argv: **u8) -> int { native::start(argc, argv, main) }
266+
267+
fn main() {}
268+
~~~
247269

248270
# Finding the runtime
249271

branches/auto/src/doc/tutorial.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2103,7 +2103,8 @@ a `&T` pointer. `MutexArc` is an example of a *sharable* type with internal muta
21032103
These are types that do not contain any data whose lifetime is bound to
21042104
a particular stack frame. These are types that do not contain any
21052105
references, or types where the only contained references
2106-
have the `'static` lifetime.
2106+
have the `'static` lifetime. (For more on named lifetimes and their uses,
2107+
see the [references and lifetimes guide][lifetimes].)
21072108
21082109
> ***Note:*** These two traits were referred to as 'kinds' in earlier
21092110
> iterations of the language, and often still are.

branches/auto/src/libcollections/dlist.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -582,16 +582,16 @@ impl<A> DoubleEndedIterator<A> for MoveItems<A> {
582582
}
583583

584584
impl<A> FromIterator<A> for DList<A> {
585-
fn from_iterator<T: Iterator<A>>(iterator: &mut T) -> DList<A> {
585+
fn from_iterator<T: Iterator<A>>(iterator: T) -> DList<A> {
586586
let mut ret = DList::new();
587587
ret.extend(iterator);
588588
ret
589589
}
590590
}
591591

592592
impl<A> Extendable<A> for DList<A> {
593-
fn extend<T: Iterator<A>>(&mut self, iterator: &mut T) {
594-
for elt in *iterator { self.push_back(elt); }
593+
fn extend<T: Iterator<A>>(&mut self, mut iterator: T) {
594+
for elt in iterator { self.push_back(elt); }
595595
}
596596
}
597597

branches/auto/src/libcollections/hashmap.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,7 +1356,7 @@ pub type Values<'a, K, V> =
13561356
iter::Map<'static, (&'a K, &'a V), &'a V, Entries<'a, K, V>>;
13571357

13581358
impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S> + Default> FromIterator<(K, V)> for HashMap<K, V, H> {
1359-
fn from_iterator<T: Iterator<(K, V)>>(iter: &mut T) -> HashMap<K, V, H> {
1359+
fn from_iterator<T: Iterator<(K, V)>>(iter: T) -> HashMap<K, V, H> {
13601360
let (lower, _) = iter.size_hint();
13611361
let mut map = HashMap::with_capacity_and_hasher(lower, Default::default());
13621362
map.extend(iter);
@@ -1365,8 +1365,8 @@ impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S> + Default> FromIterator<(K, V)> fo
13651365
}
13661366

13671367
impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S> + Default> Extendable<(K, V)> for HashMap<K, V, H> {
1368-
fn extend<T: Iterator<(K, V)>>(&mut self, iter: &mut T) {
1369-
for (k, v) in *iter {
1368+
fn extend<T: Iterator<(K, V)>>(&mut self, mut iter: T) {
1369+
for (k, v) in iter {
13701370
self.insert(k, v);
13711371
}
13721372
}
@@ -1540,7 +1540,7 @@ impl<T: TotalEq + Hash<S> + fmt::Show, S, H: Hasher<S>> fmt::Show for HashSet<T,
15401540
}
15411541

15421542
impl<T: TotalEq + Hash<S>, S, H: Hasher<S> + Default> FromIterator<T> for HashSet<T, H> {
1543-
fn from_iterator<I: Iterator<T>>(iter: &mut I) -> HashSet<T, H> {
1543+
fn from_iterator<I: Iterator<T>>(iter: I) -> HashSet<T, H> {
15441544
let (lower, _) = iter.size_hint();
15451545
let mut set = HashSet::with_capacity_and_hasher(lower, Default::default());
15461546
set.extend(iter);
@@ -1549,8 +1549,8 @@ impl<T: TotalEq + Hash<S>, S, H: Hasher<S> + Default> FromIterator<T> for HashSe
15491549
}
15501550

15511551
impl<T: TotalEq + Hash<S>, S, H: Hasher<S> + Default> Extendable<T> for HashSet<T, H> {
1552-
fn extend<I: Iterator<T>>(&mut self, iter: &mut I) {
1553-
for k in *iter {
1552+
fn extend<I: Iterator<T>>(&mut self, mut iter: I) {
1553+
for k in iter {
15541554
self.insert(k);
15551555
}
15561556
}

branches/auto/src/libcollections/priority_queue.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,22 +193,21 @@ impl<'a, T> Iterator<&'a T> for Items<'a, T> {
193193
}
194194

195195
impl<T: Ord> FromIterator<T> for PriorityQueue<T> {
196-
fn from_iterator<Iter: Iterator<T>>(iter: &mut Iter) -> PriorityQueue<T> {
196+
fn from_iterator<Iter: Iterator<T>>(iter: Iter) -> PriorityQueue<T> {
197197
let mut q = PriorityQueue::new();
198198
q.extend(iter);
199-
200199
q
201200
}
202201
}
203202

204203
impl<T: Ord> Extendable<T> for PriorityQueue<T> {
205-
fn extend<Iter: Iterator<T>>(&mut self, iter: &mut Iter) {
204+
fn extend<Iter: Iterator<T>>(&mut self, mut iter: Iter) {
206205
let (lower, _) = iter.size_hint();
207206

208207
let len = self.capacity();
209208
self.reserve(len + lower);
210209

211-
for elem in *iter {
210+
for elem in iter {
212211
self.push(elem);
213212
}
214213
}

branches/auto/src/libcollections/ringbuf.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ impl<A: Eq> Eq for RingBuf<A> {
386386
}
387387

388388
impl<A> FromIterator<A> for RingBuf<A> {
389-
fn from_iterator<T: Iterator<A>>(iterator: &mut T) -> RingBuf<A> {
389+
fn from_iterator<T: Iterator<A>>(iterator: T) -> RingBuf<A> {
390390
let (lower, _) = iterator.size_hint();
391391
let mut deq = RingBuf::with_capacity(lower);
392392
deq.extend(iterator);
@@ -395,8 +395,8 @@ impl<A> FromIterator<A> for RingBuf<A> {
395395
}
396396

397397
impl<A> Extendable<A> for RingBuf<A> {
398-
fn extend<T: Iterator<A>>(&mut self, iterator: &mut T) {
399-
for elt in *iterator {
398+
fn extend<T: Iterator<A>>(&mut self, mut iterator: T) {
399+
for elt in iterator {
400400
self.push_back(elt);
401401
}
402402
}

branches/auto/src/libcollections/treemap.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ fn remove<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>,
971971
}
972972

973973
impl<K: TotalOrd, V> FromIterator<(K, V)> for TreeMap<K, V> {
974-
fn from_iterator<T: Iterator<(K, V)>>(iter: &mut T) -> TreeMap<K, V> {
974+
fn from_iterator<T: Iterator<(K, V)>>(iter: T) -> TreeMap<K, V> {
975975
let mut map = TreeMap::new();
976976
map.extend(iter);
977977
map
@@ -980,15 +980,15 @@ impl<K: TotalOrd, V> FromIterator<(K, V)> for TreeMap<K, V> {
980980

981981
impl<K: TotalOrd, V> Extendable<(K, V)> for TreeMap<K, V> {
982982
#[inline]
983-
fn extend<T: Iterator<(K, V)>>(&mut self, iter: &mut T) {
984-
for (k, v) in *iter {
983+
fn extend<T: Iterator<(K, V)>>(&mut self, mut iter: T) {
984+
for (k, v) in iter {
985985
self.insert(k, v);
986986
}
987987
}
988988
}
989989

990990
impl<T: TotalOrd> FromIterator<T> for TreeSet<T> {
991-
fn from_iterator<Iter: Iterator<T>>(iter: &mut Iter) -> TreeSet<T> {
991+
fn from_iterator<Iter: Iterator<T>>(iter: Iter) -> TreeSet<T> {
992992
let mut set = TreeSet::new();
993993
set.extend(iter);
994994
set
@@ -997,8 +997,8 @@ impl<T: TotalOrd> FromIterator<T> for TreeSet<T> {
997997

998998
impl<T: TotalOrd> Extendable<T> for TreeSet<T> {
999999
#[inline]
1000-
fn extend<Iter: Iterator<T>>(&mut self, iter: &mut Iter) {
1001-
for elem in *iter {
1000+
fn extend<Iter: Iterator<T>>(&mut self, mut iter: Iter) {
1001+
for elem in iter {
10021002
self.insert(elem);
10031003
}
10041004
}

branches/auto/src/libcollections/trie.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,16 +261,16 @@ impl<T> TrieMap<T> {
261261
}
262262

263263
impl<T> FromIterator<(uint, T)> for TrieMap<T> {
264-
fn from_iterator<Iter: Iterator<(uint, T)>>(iter: &mut Iter) -> TrieMap<T> {
264+
fn from_iterator<Iter: Iterator<(uint, T)>>(iter: Iter) -> TrieMap<T> {
265265
let mut map = TrieMap::new();
266266
map.extend(iter);
267267
map
268268
}
269269
}
270270

271271
impl<T> Extendable<(uint, T)> for TrieMap<T> {
272-
fn extend<Iter: Iterator<(uint, T)>>(&mut self, iter: &mut Iter) {
273-
for (k, v) in *iter {
272+
fn extend<Iter: Iterator<(uint, T)>>(&mut self, mut iter: Iter) {
273+
for (k, v) in iter {
274274
self.insert(k, v);
275275
}
276276
}
@@ -346,16 +346,16 @@ impl TrieSet {
346346
}
347347

348348
impl FromIterator<uint> for TrieSet {
349-
fn from_iterator<Iter: Iterator<uint>>(iter: &mut Iter) -> TrieSet {
349+
fn from_iterator<Iter: Iterator<uint>>(iter: Iter) -> TrieSet {
350350
let mut set = TrieSet::new();
351351
set.extend(iter);
352352
set
353353
}
354354
}
355355

356356
impl Extendable<uint> for TrieSet {
357-
fn extend<Iter: Iterator<uint>>(&mut self, iter: &mut Iter) {
358-
for elem in *iter {
357+
fn extend<Iter: Iterator<uint>>(&mut self, mut iter: Iter) {
358+
for elem in iter {
359359
self.insert(elem);
360360
}
361361
}

branches/auto/src/libglob/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl Iterator<Path> for Paths {
153153
// so we don't need to check the children
154154
return Some(path);
155155
} else {
156-
self.todo.extend(&mut list_dir_sorted(&path).move_iter().map(|x|(x,idx+1)));
156+
self.todo.extend(list_dir_sorted(&path).move_iter().map(|x|(x,idx+1)));
157157
}
158158
}
159159
}

0 commit comments

Comments
 (0)