Skip to content

Commit d0aabcf

Browse files
committed
---
yaml --- r: 151514 b: refs/heads/try2 c: e850316 h: refs/heads/master v: v3
1 parent ccc835e commit d0aabcf

File tree

133 files changed

+2066
-1571
lines changed

Some content is hidden

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

133 files changed

+2066
-1571
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 620b4352f28d58801d82d58faa0a71f75ad9087f
8+
refs/heads/try2: e850316408bbe6254305cf4aa7c65381dc475192
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/mk/crates.mk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
TARGET_CRATES := libc std green rustuv native flate arena glob term semver \
5353
uuid serialize sync getopts collections num test time rand \
5454
workcache url log regex graphviz core
55-
HOST_CRATES := syntax rustc rustdoc fourcc hexfloat regex_macros
55+
HOST_CRATES := syntax rustc rustdoc fourcc hexfloat regex_macros fmt_macros
5656
CRATES := $(TARGET_CRATES) $(HOST_CRATES)
5757
TOOLS := compiletest rustdoc rustc
5858

@@ -61,7 +61,7 @@ DEPS_std := core libc native:rustrt native:compiler-rt native:backtrace
6161
DEPS_green := std rand native:context_switch
6262
DEPS_rustuv := std native:uv native:uv_support
6363
DEPS_native := std
64-
DEPS_syntax := std term serialize collections log
64+
DEPS_syntax := std term serialize collections log fmt_macros
6565
DEPS_rustc := syntax native:rustllvm flate arena serialize sync getopts \
6666
collections time log
6767
DEPS_rustdoc := rustc native:hoedown serialize sync getopts collections \
@@ -88,6 +88,7 @@ DEPS_workcache := std serialize collections log
8888
DEPS_log := std sync
8989
DEPS_regex := std collections
9090
DEPS_regex_macros = syntax std regex
91+
DEPS_fmt_macros = std
9192

9293
TOOL_DEPS_compiletest := test green rustuv getopts
9394
TOOL_DEPS_rustdoc := rustdoc native

branches/try2/src/compiletest/runtest.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ fn make_lib_name(config: &config, auxfile: &Path, testfile: &Path) -> Path {
997997
fn make_exe_name(config: &config, testfile: &Path) -> Path {
998998
let mut f = output_base_name(config, testfile);
999999
if !os::consts::EXE_SUFFIX.is_empty() {
1000-
match f.filename().map(|s| s + os::consts::EXE_SUFFIX.as_bytes()) {
1000+
match f.filename().map(|s| Vec::from_slice(s).append(os::consts::EXE_SUFFIX.as_bytes())) {
10011001
Some(v) => f.set_filename(v),
10021002
None => ()
10031003
}
@@ -1091,7 +1091,7 @@ fn make_out_name(config: &config, testfile: &Path, extension: &str) -> Path {
10911091

10921092
fn aux_output_dir_name(config: &config, testfile: &Path) -> Path {
10931093
let mut f = output_base_name(config, testfile);
1094-
match f.filename().map(|s| s + bytes!(".libaux")) {
1094+
match f.filename().map(|s| Vec::from_slice(s).append(bytes!(".libaux"))) {
10951095
Some(v) => f.set_filename(v),
10961096
None => ()
10971097
}
@@ -1273,7 +1273,7 @@ fn append_suffix_to_stem(p: &Path, suffix: &str) -> Path {
12731273
(*p).clone()
12741274
} else {
12751275
let stem = p.filestem().unwrap();
1276-
p.with_filename(stem + bytes!("-") + suffix.as_bytes())
1276+
p.with_filename(Vec::from_slice(stem).append(bytes!("-")).append(suffix.as_bytes()))
12771277
}
12781278
}
12791279

branches/try2/src/doc/guide-container.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,8 @@ Iterators offer generic conversion to containers with the `collect` adaptor:
266266

267267
~~~
268268
let xs = [0, 1, 1, 2, 3, 5, 8];
269-
let ys = xs.iter().rev().skip(1).map(|&x| x * 2).collect::<~[int]>();
270-
assert_eq!(ys, ~[10, 6, 4, 2, 2, 0]);
269+
let ys = xs.iter().rev().skip(1).map(|&x| x * 2).collect::<Vec<int>>();
270+
assert_eq!(ys, vec![10, 6, 4, 2, 2, 0]);
271271
~~~
272272

273273
The method requires a type hint for the container type, if the surrounding code
@@ -278,14 +278,14 @@ implementing the `FromIterator` trait. For example, the implementation for
278278
vectors is as follows:
279279

280280
~~~ {.ignore}
281-
impl<A> FromIterator<A> for ~[A] {
282-
pub fn from_iter<T: Iterator<A>>(iterator: &mut T) -> ~[A] {
281+
impl<T> FromIterator<T> for Vec<T> {
282+
fn from_iter<I:Iterator<A>>(mut iterator: I) -> Vec<T> {
283283
let (lower, _) = iterator.size_hint();
284-
let mut xs = with_capacity(lower);
285-
for x in iterator {
286-
xs.push(x);
284+
let mut vector = Vec::with_capacity(lower);
285+
for element in iterator {
286+
vector.push(element);
287287
}
288-
xs
288+
vector
289289
}
290290
}
291291
~~~

branches/try2/src/doc/rust.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,10 +1740,10 @@ import public items from their destination, not private items.
17401740
## Attributes
17411741

17421742
~~~~ {.notrust .ebnf .gram}
1743-
attribute : '#' '!' ? '[' attr_list ']' ;
1744-
attr_list : attr [ ',' attr_list ]* ;
1745-
attr : ident [ '=' literal
1746-
| '(' attr_list ')' ] ? ;
1743+
attribute : '#' '!' ? '[' meta_item ']' ;
1744+
meta_item : ident [ '=' literal
1745+
| '(' meta_seq ')' ] ? ;
1746+
meta_seq : meta_item [ ',' meta_seq ]* ;
17471747
~~~~
17481748

17491749
Static entities in Rust &mdash; crates, modules and items &mdash; may have _attributes_
@@ -3597,18 +3597,18 @@ and the cast expression in `main`.
35973597
Within the body of an item that has type parameter declarations, the names of its type parameters are types:
35983598

35993599
~~~~
3600-
fn map<A: Clone, B: Clone>(f: |A| -> B, xs: &[A]) -> ~[B] {
3600+
fn map<A: Clone, B: Clone>(f: |A| -> B, xs: &[A]) -> Vec<B> {
36013601
if xs.len() == 0 {
3602-
return ~[];
3602+
return vec![];
36033603
}
36043604
let first: B = f(xs[0].clone());
3605-
let rest: ~[B] = map(f, xs.slice(1, xs.len()));
3606-
return ~[first] + rest;
3605+
let rest: Vec<B> = map(f, xs.slice(1, xs.len()));
3606+
return vec![first].append(rest.as_slice());
36073607
}
36083608
~~~~
36093609

36103610
Here, `first` has type `B`, referring to `map`'s `B` type parameter;
3611-
and `rest` has type `~[B]`, a vector type with element type `B`.
3611+
and `rest` has type `Vec<B>`, a vector type with element type `B`.
36123612

36133613
### Self types
36143614

branches/try2/src/doc/tutorial.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,8 +1588,8 @@ let mut numbers = vec![1, 2, 3];
15881588
numbers.push(4);
15891589
numbers.push(5);
15901590
1591-
// The type of a unique vector is written as `~[int]`
1592-
let more_numbers: ~[int] = numbers.move_iter().collect();
1591+
// The type of a unique vector is written as `Vec<int>`
1592+
let more_numbers: Vec<int> = numbers.move_iter().map(|i| i+1).collect();
15931593
15941594
// The original `numbers` value can no longer be used, due to move semantics.
15951595
@@ -1633,7 +1633,7 @@ view[0] = 5;
16331633
let ys: &mut [int] = &mut [1, 2, 3];
16341634
~~~
16351635

1636-
Square brackets denote indexing into a vector:
1636+
Square brackets denote indexing into a slice or fixed-size vector:
16371637

16381638
~~~~
16391639
# enum Crayon { Almond, AntiqueBrass, Apricot,
@@ -1647,7 +1647,7 @@ match crayons[0] {
16471647
}
16481648
~~~~
16491649

1650-
A vector can be destructured using pattern matching:
1650+
A slice or fixed-size vector can be destructured using pattern matching:
16511651

16521652
~~~~
16531653
let numbers: &[int] = &[1, 2, 3];
@@ -1660,9 +1660,10 @@ let score = match numbers {
16601660
~~~~
16611661

16621662
Both vectors and strings support a number of useful [methods](#methods),
1663-
defined in [`std::vec`] and [`std::str`].
1663+
defined in [`std::vec`], [`std::slice`], and [`std::str`].
16641664

16651665
[`std::vec`]: std/vec/index.html
1666+
[`std::slice`]: std/slice/index.html
16661667
[`std::str`]: std/str/index.html
16671668

16681669
# Ownership escape hatches

branches/try2/src/etc/vim/indent/rust.vim

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ setlocal cindent
1313
setlocal cinoptions=L0,(0,Ws,JN,j1
1414
setlocal cinkeys=0{,0},!^F,o,O,0[,0]
1515
" Don't think cinwords will actually do anything at all... never mind
16-
setlocal cinwords=do,for,if,else,while,loop,impl,mod,unsafe,trait,struct,enum,fn,extern
16+
setlocal cinwords=for,if,else,while,loop,impl,mod,unsafe,trait,struct,enum,fn,extern
1717

1818
" Some preliminary settings
1919
setlocal nolisp " Make sure lisp indenting doesn't supersede us
@@ -40,12 +40,12 @@ function! s:get_line_trimmed(lnum)
4040
" If the last character in the line is a comment, do a binary search for
4141
" the start of the comment. synID() is slow, a linear search would take
4242
" too long on a long line.
43-
if synIDattr(synID(a:lnum, line_len, 1), "name") =~ "Comment\|Todo"
43+
if synIDattr(synID(a:lnum, line_len, 1), "name") =~ 'Comment\|Todo'
4444
let min = 1
4545
let max = line_len
4646
while min < max
4747
let col = (min + max) / 2
48-
if synIDattr(synID(a:lnum, col, 1), "name") =~ "Comment\|Todo"
48+
if synIDattr(synID(a:lnum, col, 1), "name") =~ 'Comment\|Todo'
4949
let max = col
5050
else
5151
let min = col + 1
@@ -87,10 +87,10 @@ function GetRustIndent(lnum)
8787
if synname == "rustString"
8888
" If the start of the line is in a string, don't change the indent
8989
return -1
90-
elseif synname =~ "\\(Comment\\|Todo\\)"
91-
\ && line !~ "^\\s*/\\*" " not /* opening line
90+
elseif synname =~ '\(Comment\|Todo\)'
91+
\ && line !~ '^\s*/\*' " not /* opening line
9292
if synname =~ "CommentML" " multi-line
93-
if line !~ "^\\s*\\*" && getline(a:lnum - 1) =~ "^\\s*/\\*"
93+
if line !~ '^\s*\*' && getline(a:lnum - 1) =~ '^\s*/\*'
9494
" This is (hopefully) the line after a /*, and it has no
9595
" leader, so the correct indentation is that of the
9696
" previous line.
@@ -115,11 +115,16 @@ function GetRustIndent(lnum)
115115
" };
116116

117117
" Search backwards for the previous non-empty line.
118-
let prevline = s:get_line_trimmed(prevnonblank(a:lnum - 1))
118+
let prevlinenum = prevnonblank(a:lnum - 1)
119+
let prevline = s:get_line_trimmed(prevlinenum)
120+
while prevlinenum > 1 && prevline !~ '[^[:blank:]]'
121+
let prevlinenum = prevnonblank(prevlinenum - 1)
122+
let prevline = s:get_line_trimmed(prevlinenum)
123+
endwhile
119124
if prevline[len(prevline) - 1] == ","
120-
\ && s:get_line_trimmed(a:lnum) !~ "^\\s*[\\[\\]{}]"
121-
\ && prevline !~ "^\\s*fn\\s"
122-
\ && prevline !~ "([^()]\\+,$"
125+
\ && s:get_line_trimmed(a:lnum) !~ '^\s*[\[\]{}]'
126+
\ && prevline !~ '^\s*fn\s'
127+
\ && prevline !~ '([^()]\+,$'
123128
" Oh ho! The previous line ended in a comma! I bet cindent will try to
124129
" take this too far... For now, let's normally use the previous line's
125130
" indent.
@@ -166,7 +171,7 @@ function GetRustIndent(lnum)
166171
" column zero)
167172

168173
call cursor(a:lnum, 1)
169-
if searchpair('{\|(', '', '}\|)', 'nbW'
174+
if searchpair('{\|(', '', '}\|)', 'nbW',
170175
\ 's:is_string_comment(line("."), col("."))') == 0
171176
if searchpair('\[', '', '\]', 'nbW',
172177
\ 's:is_string_comment(line("."), col("."))') == 0

branches/try2/src/libcore/cast.rs

Lines changed: 21 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,6 @@ use mem;
1414
use intrinsics;
1515
use ptr::copy_nonoverlapping_memory;
1616

17-
/// Casts the value at `src` to U. The two types must have the same length.
18-
#[inline]
19-
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
20-
let mut dest: U = mem::uninit();
21-
let dest_ptr: *mut u8 = transmute(&mut dest);
22-
let src_ptr: *u8 = transmute(src);
23-
copy_nonoverlapping_memory(dest_ptr, src_ptr, mem::size_of::<U>());
24-
dest
25-
}
26-
27-
/**
28-
* Move a thing into the void
29-
*
30-
* The forget function will take ownership of the provided value but neglect
31-
* to run any required cleanup or memory-management operations on it.
32-
*/
33-
#[inline]
34-
pub unsafe fn forget<T>(thing: T) { intrinsics::forget(thing); }
35-
36-
/**
37-
* Force-increment the reference count on a shared box. If used
38-
* carelessly, this can leak the box.
39-
*/
40-
#[inline]
41-
pub unsafe fn bump_box_refcount<T>(t: @T) { forget(t); }
42-
4317
/**
4418
* Transform a value of one type into a value of another type.
4519
* Both types must have the same size and alignment.
@@ -54,10 +28,29 @@ pub unsafe fn bump_box_refcount<T>(t: @T) { forget(t); }
5428
* ```
5529
*/
5630
#[inline]
57-
pub unsafe fn transmute<L, G>(thing: L) -> G {
31+
pub unsafe fn transmute<T, U>(thing: T) -> U {
5832
intrinsics::transmute(thing)
5933
}
6034

35+
/**
36+
* Move a thing into the void
37+
*
38+
* The forget function will take ownership of the provided value but neglect
39+
* to run any required cleanup or memory-management operations on it.
40+
*/
41+
#[inline]
42+
pub unsafe fn forget<T>(thing: T) { intrinsics::forget(thing); }
43+
44+
/// Casts the value at `src` to U. The two types must have the same length.
45+
#[inline]
46+
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
47+
let mut dest: U = mem::uninit();
48+
let dest_ptr: *mut u8 = transmute(&mut dest);
49+
let src_ptr: *u8 = transmute(src);
50+
copy_nonoverlapping_memory(dest_ptr, src_ptr, mem::size_of::<U>());
51+
dest
52+
}
53+
6154
/// Coerce an immutable reference to be mutable.
6255
#[inline]
6356
#[deprecated="casting &T to &mut T is undefined behaviour: use Cell<T>, RefCell<T> or Unsafe<T>"]
@@ -106,7 +99,7 @@ pub unsafe fn copy_lifetime_vec<'a,S,T>(_ptr: &'a [S], ptr: &T) -> &'a T {
10699

107100
#[cfg(test)]
108101
mod tests {
109-
use cast::{bump_box_refcount, transmute};
102+
use cast::transmute;
110103
use raw;
111104
use realstd::str::StrAllocating;
112105

@@ -115,21 +108,6 @@ mod tests {
115108
assert_eq!(1u, unsafe { ::cast::transmute_copy(&1) });
116109
}
117110

118-
#[test]
119-
fn test_bump_managed_refcount() {
120-
unsafe {
121-
let managed = @"box box box".to_owned(); // refcount 1
122-
bump_box_refcount(managed); // refcount 2
123-
let ptr: *int = transmute(managed); // refcount 2
124-
let _box1: @~str = ::cast::transmute_copy(&ptr);
125-
let _box2: @~str = ::cast::transmute_copy(&ptr);
126-
assert!(*_box1 == "box box box".to_owned());
127-
assert!(*_box2 == "box box box".to_owned());
128-
// Will destroy _box1 and _box2. Without the bump, this would
129-
// use-after-free. With too many bumps, it would leak.
130-
}
131-
}
132-
133111
#[test]
134112
fn test_transmute() {
135113
unsafe {

branches/try2/src/libcore/cell.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! Types dealing with dynamic mutability
11+
//! Types that provide interior mutability.
1212
1313
use clone::Clone;
1414
use cmp::Eq;

0 commit comments

Comments
 (0)