Skip to content

Commit 9ff3b23

Browse files
committed
---
yaml --- r: 159520 b: refs/heads/master c: e09d986 h: refs/heads/master v: v3
1 parent 3480d80 commit 9ff3b23

File tree

235 files changed

+5002
-2887
lines changed

Some content is hidden

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

235 files changed

+5002
-2887
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 2293a04b4936a11fc3e09f3df8a8ab591e034f29
2+
refs/heads/master: e09d98603e608c9e47d4c89f7b4dca87a4b56da3
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 9c96a79a74f10bed18b031ce0ac4126c56d6cfb3
55
refs/heads/try: f58aad6dce273570fb130b4df008ef9acd5a5be2

trunk/mk/crates.mk

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ TARGET_CRATES := libc std green native flate arena term \
5353
serialize sync getopts collections test time rand \
5454
log regex graphviz core rbml alloc rustrt \
5555
unicode
56-
HOST_CRATES := syntax rustc rustdoc regex_macros fmt_macros \
56+
HOST_CRATES := syntax rustc rustc_trans rustdoc regex_macros fmt_macros \
5757
rustc_llvm rustc_back
5858
CRATES := $(TARGET_CRATES) $(HOST_CRATES)
5959
TOOLS := compiletest rustdoc rustc
@@ -69,11 +69,12 @@ DEPS_graphviz := std
6969
DEPS_green := std native:context_switch
7070
DEPS_native := std
7171
DEPS_syntax := std term serialize log fmt_macros arena libc
72+
DEPS_rustc_trans := rustc rustc_back rustc_llvm libc
7273
DEPS_rustc := syntax flate arena serialize getopts rbml \
7374
time log graphviz rustc_llvm rustc_back
7475
DEPS_rustc_llvm := native:rustllvm libc std
7576
DEPS_rustc_back := std syntax rustc_llvm flate log libc
76-
DEPS_rustdoc := rustc native:hoedown serialize getopts \
77+
DEPS_rustdoc := rustc rustc_trans native:hoedown serialize getopts \
7778
test time
7879
DEPS_flate := std native:miniz
7980
DEPS_arena := std
@@ -96,7 +97,7 @@ DEPS_fmt_macros = std
9697

9798
TOOL_DEPS_compiletest := test getopts native
9899
TOOL_DEPS_rustdoc := rustdoc native
99-
TOOL_DEPS_rustc := rustc native
100+
TOOL_DEPS_rustc := rustc_trans native
100101
TOOL_SOURCE_compiletest := $(S)src/compiletest/compiletest.rs
101102
TOOL_SOURCE_rustdoc := $(S)src/driver/driver.rs
102103
TOOL_SOURCE_rustc := $(S)src/driver/driver.rs
@@ -112,8 +113,8 @@ ONLY_RLIB_unicode := 1
112113
# You should not need to edit below this line
113114
################################################################################
114115

115-
DOC_CRATES := $(filter-out rustc, $(filter-out syntax, $(CRATES)))
116-
COMPILER_DOC_CRATES := rustc syntax
116+
DOC_CRATES := $(filter-out rustc, $(filter-out rustc_trans, $(filter-out syntax, $(CRATES))))
117+
COMPILER_DOC_CRATES := rustc rustc_trans syntax
117118

118119
# This macro creates some simple definitions for each crate being built, just
119120
# some munging of all of the parameters above.

trunk/src/doc/reference.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2513,11 +2513,6 @@ The currently implemented features of the reference compiler are:
25132513
closure as `once` is unlikely to be supported going forward. So
25142514
they are hidden behind this feature until they are to be removed.
25152515

2516-
* `overloaded_calls` - Allow implementing the `Fn*` family of traits on user
2517-
types, allowing overloading the call operator (`()`).
2518-
This feature may still undergo changes before being
2519-
stabilized.
2520-
25212516
* `phase` - Usage of the `#[phase]` attribute allows loading compiler plugins
25222517
for custom lints or syntax extensions. The implementation is
25232518
considered unwholesome and in need of overhaul, and it is not clear
@@ -2560,11 +2555,8 @@ The currently implemented features of the reference compiler are:
25602555
* `trace_macros` - Allows use of the `trace_macros` macro, which is a nasty
25612556
hack that will certainly be removed.
25622557

2563-
* `unboxed_closure_sugar` - Allows using `|Foo| -> Bar` as a trait bound
2564-
meaning one of the `Fn` traits. Still
2565-
experimental.
2566-
2567-
* `unboxed_closures` - A work in progress feature with many known bugs.
2558+
* `unboxed_closures` - Rust's new closure design, which is currently a work in
2559+
progress feature with many known bugs.
25682560

25692561
* `unsafe_destructor` - Allows use of the `#[unsafe_destructor]` attribute,
25702562
which is considered wildly unsafe and will be

trunk/src/driver/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
extern crate "rustdoc" as this;
1313

1414
#[cfg(rustc)]
15-
extern crate "rustc" as this;
15+
extern crate "rustc_trans" as this;
1616

1717
fn main() { this::main() }

trunk/src/libcore/iter.rs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ use cmp;
6565
use cmp::Ord;
6666
use mem;
6767
use num::{ToPrimitive, Int};
68-
use ops::Add;
68+
use ops::{Add, Deref};
6969
use option::{Option, Some, None};
7070
use uint;
71+
7172
#[deprecated = "renamed to Extend"] pub use self::Extend as Extendable;
7273

7374
/// Conversion from an `Iterator`
@@ -1021,6 +1022,44 @@ impl<T: Clone> MinMaxResult<T> {
10211022
}
10221023
}
10231024

1025+
/// A trait for iterators that contain cloneable elements
1026+
pub trait CloneIteratorExt<A> {
1027+
/// Creates an iterator that clones the elements it yields. Useful for converting an
1028+
/// Iterator<&T> to an Iterator<T>.
1029+
fn cloned(self) -> Cloned<Self>;
1030+
}
1031+
1032+
1033+
impl<A: Clone, D: Deref<A>, I: Iterator<D>> CloneIteratorExt<A> for I {
1034+
fn cloned(self) -> Cloned<I> {
1035+
Cloned { it: self }
1036+
}
1037+
}
1038+
1039+
/// An iterator that clones the elements of an underlying iterator
1040+
pub struct Cloned<I> {
1041+
it: I,
1042+
}
1043+
1044+
impl<A: Clone, D: Deref<A>, I: Iterator<D>> Iterator<A> for Cloned<I> {
1045+
fn next(&mut self) -> Option<A> {
1046+
self.it.next().cloned()
1047+
}
1048+
1049+
fn size_hint(&self) -> (uint, Option<uint>) {
1050+
self.it.size_hint()
1051+
}
1052+
}
1053+
1054+
impl<A: Clone, D: Deref<A>, I: DoubleEndedIterator<D>>
1055+
DoubleEndedIterator<A> for Cloned<I> {
1056+
fn next_back(&mut self) -> Option<A> {
1057+
self.it.next_back().cloned()
1058+
}
1059+
}
1060+
1061+
impl<A: Clone, D: Deref<A>, I: ExactSize<D>> ExactSize<A> for Cloned<I> {}
1062+
10241063
/// A trait for iterators that are cloneable.
10251064
pub trait CloneableIterator {
10261065
/// Repeats an iterator endlessly

trunk/src/libcore/num/mod.rs

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,10 @@ pub fn div_rem<T: Div<T, T> + Rem<T, T>>(x: T, y: T) -> (T, T) {
3939
}
4040

4141
/// Raises a `base` to the power of `exp`, using exponentiation by squaring.
42-
///
43-
/// # Example
44-
///
45-
/// ```rust
46-
/// use std::num;
47-
///
48-
/// assert_eq!(num::pow(2i, 4), 16);
49-
/// ```
5042
#[inline]
51-
pub fn pow<T: Int>(mut base: T, mut exp: uint) -> T {
52-
if exp == 1 { base }
53-
else {
54-
let mut acc: T = Int::one();
55-
while exp > 0 {
56-
if (exp & 1) == 1 {
57-
acc = acc * base;
58-
}
59-
base = base * base;
60-
exp = exp >> 1;
61-
}
62-
acc
63-
}
43+
#[deprecated = "Use Int::pow() instead, as in 2i.pow(4)"]
44+
pub fn pow<T: Int>(base: T, exp: uint) -> T {
45+
base.pow(exp)
6446
}
6547

6648
/// A built-in signed or unsigned integer.
@@ -361,6 +343,29 @@ pub trait Int
361343
None => Int::max_value(),
362344
}
363345
}
346+
347+
/// Raises self to the power of `exp`, using exponentiation by squaring.
348+
///
349+
/// # Example
350+
///
351+
/// ```rust
352+
/// use std::num::Int;
353+
///
354+
/// assert_eq!(2i.pow(4), 16);
355+
/// ```
356+
#[inline]
357+
fn pow(self, mut exp: uint) -> Self {
358+
let mut base = self;
359+
let mut acc: Self = Int::one();
360+
while exp > 0 {
361+
if (exp & 1) == 1 {
362+
acc = acc * base;
363+
}
364+
base = base * base;
365+
exp /= 2;
366+
}
367+
acc
368+
}
364369
}
365370

366371
macro_rules! checked_op {

trunk/src/libcore/option.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ use result::{Result, Ok, Err};
153153
use slice;
154154
use slice::AsSlice;
155155
use clone::Clone;
156+
use ops::Deref;
156157

157158
// Note that this is not a lang item per se, but it has a hidden dependency on
158159
// `Iterator`, which is one. The compiler assumes that the `next` method of
@@ -694,11 +695,12 @@ impl<T> Option<T> {
694695
}
695696
}
696697

697-
impl<'a, T: Clone> Option<&'a T> {
698-
/// Maps an Option<&T> to an Option<T> by cloning the contents of the Option<&T>.
698+
impl<'a, T: Clone, D: Deref<T>> Option<D> {
699+
/// Maps an Option<D> to an Option<T> by dereffing and cloning the contents of the Option.
700+
/// Useful for converting an Option<&T> to an Option<T>.
699701
#[unstable = "recently added as part of collections reform"]
700702
pub fn cloned(self) -> Option<T> {
701-
self.map(|t| t.clone())
703+
self.map(|t| t.deref().clone())
702704
}
703705
}
704706

trunk/src/libcoretest/iter.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,23 @@ fn test_rev() {
440440
vec![16, 14, 12, 10, 8, 6]);
441441
}
442442

443+
#[test]
444+
fn test_cloned() {
445+
let xs = [2u8, 4, 6, 8];
446+
447+
let mut it = xs.iter().cloned();
448+
assert_eq!(it.len(), 4);
449+
assert_eq!(it.next(), Some(2));
450+
assert_eq!(it.len(), 3);
451+
assert_eq!(it.next(), Some(4));
452+
assert_eq!(it.len(), 2);
453+
assert_eq!(it.next_back(), Some(8));
454+
assert_eq!(it.len(), 1);
455+
assert_eq!(it.next_back(), Some(6));
456+
assert_eq!(it.len(), 0);
457+
assert_eq!(it.next_back(), None);
458+
}
459+
443460
#[test]
444461
fn test_double_ended_map() {
445462
let xs = [1i, 2, 3, 4, 5, 6];

trunk/src/libcoretest/option.rs

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -241,14 +241,29 @@ fn test_collect() {
241241
assert!(v == None);
242242
}
243243

244+
#[test]
244245
fn test_cloned() {
245-
let s = 1u32;
246-
let n: Option<&'static u32> = None;
247-
let o = Some(&s);
248-
249-
assert_eq!(o.clone(), Some(&s));
250-
assert_eq!(o.cloned(), Some(1u32));
251-
252-
assert_eq!(n.clone(), None);
253-
assert_eq!(n.cloned(), None);
246+
let val1 = 1u32;
247+
let mut val2 = 2u32;
248+
let val1_ref = &val1;
249+
let opt_none: Option<&'static u32> = None;
250+
let opt_ref = Some(&val1);
251+
let opt_ref_ref = Some(&val1_ref);
252+
let opt_mut_ref = Some(&mut val2);
253+
254+
// None works
255+
assert_eq!(opt_none.clone(), None);
256+
assert_eq!(opt_none.cloned(), None);
257+
258+
// Mutable refs work
259+
assert_eq!(opt_mut_ref.cloned(), Some(2u32));
260+
261+
// Immutable ref works
262+
assert_eq!(opt_ref.clone(), Some(&val1));
263+
assert_eq!(opt_ref.cloned(), Some(1u32));
264+
265+
// Double Immutable ref works
266+
assert_eq!(opt_ref_ref.clone(), Some(&val1_ref));
267+
assert_eq!(opt_ref_ref.clone().cloned(), Some(&val1));
268+
assert_eq!(opt_ref_ref.cloned().cloned(), Some(1u32));
254269
}

trunk/src/libgraphviz/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl<'a> dot::GraphWalk<'a, Nd, Ed> for Edges {
9090
fn target(&self, e: &Ed) -> Nd { let &(_,t) = e; t }
9191
}
9292
93-
# pub fn main() { use std::io::MemWriter; render_to(&mut MemWriter::new()) }
93+
# pub fn main() { render_to(&mut Vec::new()) }
9494
```
9595
9696
```no_run
@@ -182,7 +182,7 @@ impl<'a> dot::GraphWalk<'a, Nd, Ed<'a>> for Graph {
182182
fn target(&self, e: &Ed) -> Nd { let & &(_,t) = e; t }
183183
}
184184
185-
# pub fn main() { use std::io::MemWriter; render_to(&mut MemWriter::new()) }
185+
# pub fn main() { render_to(&mut Vec::new()) }
186186
```
187187
188188
```no_run
@@ -246,7 +246,7 @@ impl<'a> dot::GraphWalk<'a, Nd<'a>, Ed<'a>> for Graph {
246246
fn target(&self, e: &Ed<'a>) -> Nd<'a> { let &(_,t) = e; t }
247247
}
248248
249-
# pub fn main() { use std::io::MemWriter; render_to(&mut MemWriter::new()) }
249+
# pub fn main() { render_to(&mut Vec::new()) }
250250
```
251251
252252
```no_run
@@ -274,7 +274,7 @@ pub fn main() {
274274
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
275275
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
276276
html_root_url = "http://doc.rust-lang.org/nightly/")]
277-
#![feature(globs)]
277+
#![feature(globs, slicing_syntax)]
278278

279279
pub use self::LabelText::*;
280280

@@ -553,7 +553,7 @@ mod tests {
553553
use self::NodeLabels::*;
554554
use super::{Id, LabelText, LabelStr, EscStr, Labeller};
555555
use super::{Nodes, Edges, GraphWalk, render};
556-
use std::io::{MemWriter, BufReader, IoResult};
556+
use std::io::{BufReader, IoResult};
557557
use std::str;
558558

559559
/// each node is an index in a vector in the graph.
@@ -702,9 +702,9 @@ mod tests {
702702
}
703703

704704
fn test_input(g: LabelledGraph) -> IoResult<String> {
705-
let mut writer = MemWriter::new();
705+
let mut writer = Vec::new();
706706
render(&g, &mut writer).unwrap();
707-
let mut r = BufReader::new(writer.get_ref());
707+
let mut r = BufReader::new(writer[]);
708708
r.read_to_string()
709709
}
710710

@@ -809,15 +809,15 @@ r#"digraph hasse_diagram {
809809
"branch2",
810810
"afterward"));
811811

812-
let mut writer = MemWriter::new();
812+
let mut writer = Vec::new();
813813

814814
let g = LabelledGraphWithEscStrs::new(
815815
"syntax_tree", labels,
816816
vec!(edge(0, 1, "then"), edge(0, 2, "else"),
817817
edge(1, 3, ";"), edge(2, 3, ";" )));
818818

819819
render(&g, &mut writer).unwrap();
820-
let mut r = BufReader::new(writer.get_ref());
820+
let mut r = BufReader::new(writer[]);
821821
let r = r.read_to_string();
822822

823823
assert_eq!(r.unwrap().as_slice(),

0 commit comments

Comments
 (0)