Skip to content

Commit 9eff87f

Browse files
committed
---
yaml --- r: 46868 b: refs/heads/auto c: b69fb75 h: refs/heads/master v: v3
1 parent 5e704f1 commit 9eff87f

File tree

8 files changed

+86
-161
lines changed

8 files changed

+86
-161
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 8453f3110c7b84fe4a29c743b57f846fb5f654d3
17+
refs/heads/auto: b69fb75348b5aeb0988489d748373b1900f2766b

branches/auto/src/etc/emacs/rust-mode.el

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
(require 'cm-mode)
99
(require 'cc-mode)
10-
(eval-when-compile (require 'cl))
1110

1211
(defun rust-electric-brace (arg)
1312
(interactive "*P")

branches/auto/src/libcore/core.rc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,6 @@ pub mod option;
142142
pub mod result;
143143
pub mod either;
144144
pub mod dlist;
145-
#[path="iter-trait.rs"] #[merge = "iter-trait/dlist.rs"]
146-
pub mod dlist_iter;
147145
pub mod hashmap;
148146
pub mod cell;
149147
pub mod trie;

branches/auto/src/libcore/dlist.rs

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Do not use ==, !=, <, etc on doubly-linked lists -- it may not terminate.
1818
1919
*/
2020

21+
use iter;
22+
use iter::BaseIter;
2123
use kinds::Copy;
2224
use managed;
2325
use option::{None, Option, Some};
@@ -489,14 +491,54 @@ pub impl<T:Copy> DList<T> {
489491
let mut v = vec::with_capacity(self.size);
490492
unsafe {
491493
// Take this out of the unchecked when iter's functions are pure
492-
for self.eachi |index,data| {
494+
for iter::eachi(&self) |index,data| {
493495
v[index] = *data;
494496
}
495497
}
496498
v
497499
}
498500
}
499501
502+
impl<T> BaseIter<T> for @mut DList<T> {
503+
/**
504+
* Iterates through the current contents.
505+
*
506+
* Attempts to access this dlist during iteration are allowed (to
507+
* allow for e.g. breadth-first search with in-place enqueues), but
508+
* removing the current node is forbidden.
509+
*/
510+
pure fn each(&self, f: fn(v: &T) -> bool) {
511+
let mut link = self.peek_n();
512+
while option::is_some(&link) {
513+
let nobe = option::get(link);
514+
fail_unless!(nobe.linked);
515+
516+
{
517+
let frozen_nobe = &*nobe;
518+
if !f(&frozen_nobe.data) { break; }
519+
}
520+
521+
// Check (weakly) that the user didn't do a remove.
522+
if self.size == 0 {
523+
fail!(~"The dlist became empty during iteration??")
524+
}
525+
if !nobe.linked ||
526+
(!((nobe.prev.is_some()
527+
|| managed::mut_ptr_eq(self.hd.expect(~"headless dlist?"),
528+
nobe))
529+
&& (nobe.next.is_some()
530+
|| managed::mut_ptr_eq(self.tl.expect(~"tailless dlist?"),
531+
nobe)))) {
532+
fail!(~"Removing a dlist node during iteration is forbidden!")
533+
}
534+
link = nobe.next_link();
535+
}
536+
}
537+
538+
#[inline(always)]
539+
pure fn size_hint(&self) -> Option<uint> { Some(self.len()) }
540+
}
541+
500542
#[cfg(test)]
501543
mod tests {
502544
use dlist::{DList, concat, from_vec, new_dlist_node};

branches/auto/src/libcore/iter-trait.rs

Lines changed: 0 additions & 89 deletions
This file was deleted.

branches/auto/src/libcore/iter-trait/dlist.rs

Lines changed: 0 additions & 59 deletions
This file was deleted.

branches/auto/src/libsyntax/ext/expand.rs

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -409,14 +409,38 @@ pub fn core_macros() -> ~str {
409409
~"pub mod macros {
410410
macro_rules! ignore (($($x:tt)*) => (()))
411411

412-
macro_rules! error ( ($( $arg:expr ),+) => (
413-
log(::core::error, fmt!( $($arg),+ )) ))
414-
macro_rules! warn ( ($( $arg:expr ),+) => (
415-
log(::core::warn, fmt!( $($arg),+ )) ))
416-
macro_rules! info ( ($( $arg:expr ),+) => (
417-
log(::core::info, fmt!( $($arg),+ )) ))
418-
macro_rules! debug ( ($( $arg:expr ),+) => (
419-
log(::core::debug, fmt!( $($arg),+ )) ))
412+
macro_rules! error (
413+
($arg:expr) => (
414+
log(::core::error, fmt!( \"%?\", $arg ))
415+
);
416+
($( $arg:expr ),+) => (
417+
log(::core::error, fmt!( $($arg),+ ))
418+
)
419+
)
420+
macro_rules! warn (
421+
($arg:expr) => (
422+
log(::core::warn, fmt!( \"%?\", $arg ))
423+
);
424+
($( $arg:expr ),+) => (
425+
log(::core::warn, fmt!( $($arg),+ ))
426+
)
427+
)
428+
macro_rules! info (
429+
($arg:expr) => (
430+
log(::core::info, fmt!( \"%?\", $arg ))
431+
);
432+
($( $arg:expr ),+) => (
433+
log(::core::info, fmt!( $($arg),+ ))
434+
)
435+
)
436+
macro_rules! debug (
437+
($arg:expr) => (
438+
log(::core::debug, fmt!( \"%?\", $arg ))
439+
);
440+
($( $arg:expr ),+) => (
441+
log(::core::debug, fmt!( $($arg),+ ))
442+
)
443+
)
420444

421445
macro_rules! fail(
422446
($msg: expr) => (
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
enum Numbers {
2+
Three
3+
}
4+
5+
fn main() {
6+
debug!(1);
7+
info!(2.0);
8+
warn!(Three);
9+
error!(~[4]);
10+
}

0 commit comments

Comments
 (0)