Skip to content

Commit 67670bb

Browse files
committed
---
yaml --- r: 97551 b: refs/heads/snap-stage3 c: 1812a7b h: refs/heads/master i: 97549: bea1b46 97547: 9d6a138 97543: f5c0eeb 97535: 0b96d76 v: v3
1 parent 0565ebd commit 67670bb

File tree

188 files changed

+1465
-2820
lines changed

Some content is hidden

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

188 files changed

+1465
-2820
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 0da105a8b7b6b1e0568e8ff20f6ff4b13cc7ecc2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: f6963e260a85b2c6993345a64752794aa87eed07
4+
refs/heads/snap-stage3: 1812a7b540e929bb1688880541fb4c8e3b80bf6d
55
refs/heads/try: c274a6888410ce3e357e014568b43310ed787d36
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/COPYRIGHT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ terms.
66

77
Longer version:
88

9-
The Rust Project is copyright 2014, The Rust Project
9+
The Rust Project is copyright 2013, The Rust Project
1010
Developers (given in the file AUTHORS.txt).
1111

1212
Licensed under the Apache License, Version 2.0

branches/snap-stage3/LICENSE-MIT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Copyright (c) 2006-2009 Graydon Hoare
2-
Copyright (c) 2009-2014 Mozilla Foundation
2+
Copyright (c) 2009-2013 Mozilla Foundation
33

44
Permission is hereby granted, free of charge, to any
55
person obtaining a copy of this software and associated

branches/snap-stage3/Makefile.in

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,14 +410,12 @@ export CFG_SRC_DIR
410410
export CFG_BUILD_DIR
411411
export CFG_VERSION
412412
export CFG_VERSION_WIN
413-
export CFG_RELEASE
414413
export CFG_BUILD
415414
export CFG_LLVM_ROOT
416415
export CFG_ENABLE_MINGW_CROSS
417416
export CFG_PREFIX
418417
export CFG_LIBDIR
419418
export CFG_RUSTLIBDIR
420-
export LIBDIR_RELATIVE
421419

422420
######################################################################
423421
# Subprograms
@@ -435,12 +433,12 @@ define SREQ
435433
# Destinations of artifacts for the host compiler
436434
HROOT$(1)_H_$(3) = $(3)/stage$(1)
437435
HBIN$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/bin
438-
HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(LIBDIR_RELATIVE)
436+
HLIB$(1)_H_$(3) = $$(HROOT$(1)_H_$(3))/$$(CFG_LIBDIR)
439437

440438
# Destinations of artifacts for target architectures
441439
TROOT$(1)_T_$(2)_H_$(3) = $$(HLIB$(1)_H_$(3))/$$(CFG_RUSTLIBDIR)/$(2)
442440
TBIN$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/bin
443-
TLIB$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/lib
441+
TLIB$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/$$(CFG_LIBDIR)
444442

445443
# The name of the standard and extra libraries used by rustc
446444
HSTDLIB_DEFAULT$(1)_H_$(3) = \

branches/snap-stage3/configure

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -397,17 +397,7 @@ valopt sysconfdir "/etc" "install system configuration files"
397397
valopt datadir "${CFG_PREFIX}/share" "install data"
398398
valopt infodir "${CFG_PREFIX}/share/info" "install additional info"
399399
valopt mandir "${CFG_PREFIX}/share/man" "install man pages in PATH"
400-
401-
# On windows we just store the libraries in the bin directory because
402-
# there's no rpath
403-
# FIXME: Thise needs to parameterized over target triples. Do it in platform.mk
404-
LIBDIR_RELATIVE=lib
405-
if [ "$CFG_OSTYPE" = "pc-mingw32" ]
406-
then
407-
LIBDIR_RELATIVE=bin
408-
fi
409-
410-
valopt libdir "${CFG_PREFIX}/${LIBDIR_RELATIVE}" "install libraries"
400+
valopt libdir "${CFG_PREFIX}/lib" "install libraries"
411401
valopt rustlibdir "rustlib" "subdirectory name for rustc's libraries"
412402

413403
# Validate Options
@@ -570,10 +560,10 @@ then
570560
step_msg "on OS X 10.9, forcing use of clang"
571561
CFG_ENABLE_CLANG=1
572562
putvar CFG_ENABLE_CLANG
573-
else
574-
# on OS X, with xcode 5 and newer, certain developers may have
563+
else
564+
# on OS X, with xcode 5 and newer, certain developers may have
575565
# cc, gcc and g++ point to a mixture of clang and gcc
576-
# if so, this will create very strange build errors
566+
# if so, this will create very strange build errors
577567
# this last stanza is to detect some such problems and save the future rust
578568
# contributor some time solving that issue.
579569
# this detection could be generalized to other OSes aside from OS X
@@ -586,8 +576,8 @@ then
586576
# note that for xcode 5, g++ points to clang, not clang++
587577
if !((chk_cc gcc clang && chk_cc g++ clang) ||
588578
(chk_cc gcc gcc &&( chk_cc g++ g++ || chk g++ gcc))) then
589-
err "the gcc and g++ in your path point to different compilers.
590-
Check which versions are in your path with cc --version and g++ --version.
579+
err "the gcc and g++ in your path point to different compilers.
580+
Check which versions are in your path with cc --version and g++ --version.
591581
To resolve this problem, either fix your PATH or run configure with --enable-clang"
592582
fi
593583

@@ -761,6 +751,15 @@ do
761751
done
762752
done
763753

754+
# On windows we just store the libraries in the bin directory because
755+
# there's no rpath
756+
# FIXME: Thise needs to parameterized over target triples. Do it in platform.mk
757+
CFG_LIBDIR=lib
758+
if [ "$CFG_OSTYPE" = "pc-mingw32" ]
759+
then
760+
CFG_LIBDIR=bin
761+
fi
762+
764763
for h in $CFG_HOST
765764
do
766765
for t in $CFG_TARGET
@@ -771,21 +770,21 @@ do
771770
make_dir $h/stage$i/bin
772771

773772
# host lib dir
774-
make_dir $h/stage$i/$LIBDIR_RELATIVE
773+
make_dir $h/stage$i/$CFG_LIBDIR
775774

776775
# host test dir
777776
make_dir $h/stage$i/test
778777

779778
# target bin dir
780-
make_dir $h/stage$i/$LIBDIR_RELATIVE/$CFG_RUSTLIBDIR/$t/bin
779+
make_dir $h/stage$i/$CFG_LIBDIR/$CFG_RUSTLIBDIR/$t/bin
781780

782781
# target lib dir
783-
make_dir $h/stage$i/$LIBDIR_RELATIVE/$CFG_RUSTLIBDIR/$t/lib
782+
make_dir $h/stage$i/$CFG_LIBDIR/$CFG_RUSTLIBDIR/$t/$CFG_LIBDIR
784783
done
785784

786785
# Fix stage0:
787-
make_dir $h/stage0/$LIBDIR_RELATIVE/rustc/$t/bin
788-
make_dir $h/stage0/$LIBDIR_RELATIVE/rustc/$t/$LIBDIR_RELATIVE
786+
make_dir $h/stage0/$CFG_LIBDIR/rustc/$t/bin
787+
make_dir $h/stage0/$CFG_LIBDIR/rustc/$t/$CFG_LIBDIR
789788

790789
done
791790

@@ -801,12 +800,10 @@ do
801800
make_dir $h/test/doc-tutorial
802801
make_dir $h/test/doc-guide-ffi
803802
make_dir $h/test/doc-guide-macros
804-
make_dir $h/test/doc-guide-lifetimes
805-
make_dir $h/test/doc-guide-pointers
803+
make_dir $h/test/doc-guide-borrowed-ptr
806804
make_dir $h/test/doc-guide-container
807805
make_dir $h/test/doc-guide-tasks
808806
make_dir $h/test/doc-guide-conditions
809-
make_dir $h/test/doc-complement-cheatsheet
810807
make_dir $h/test/doc-rust
811808
done
812809

@@ -1041,7 +1038,6 @@ putvar CFG_TARGET
10411038
putvar CFG_C_COMPILER
10421039
putvar CFG_LIBDIR
10431040
putvar CFG_RUSTLIBDIR
1044-
putvar LIBDIR_RELATIVE
10451041
putvar CFG_DISABLE_MANAGE_SUBMODULES
10461042
putvar CFG_ANDROID_CROSS_PATH
10471043
putvar CFG_MINGW32_CROSS_PATH

branches/snap-stage3/doc/complement-cheatsheet.md

Lines changed: 38 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,116 +6,113 @@
66

77
Use [`ToStr`](http://static.rust-lang.org/doc/master/std/to_str/trait.ToStr.html).
88

9-
~~~
9+
```rust
1010
let x: int = 42;
1111
let y: ~str = x.to_str();
12-
~~~
12+
```
1313

1414
**String to int**
1515

1616
Use [`FromStr`](http://static.rust-lang.org/doc/master/std/from_str/trait.FromStr.html), and its helper function, [`from_str`](http://static.rust-lang.org/doc/master/std/from_str/fn.from_str.html).
1717

18-
~~~
18+
```rust
1919
let x: Option<int> = from_str("42");
2020
let y: int = x.unwrap();
21-
~~~
21+
```
2222

2323
**Int to string, in non-base-10**
2424

2525
Use [`ToStrRadix`](http://static.rust-lang.org/doc/master/std/num/trait.ToStrRadix.html).
2626

27-
~~~
27+
```rust
2828
use std::num::ToStrRadix;
2929

3030
let x: int = 42;
3131
let y: ~str = x.to_str_radix(16);
32-
~~~
32+
```
3333

3434
**String to int, in non-base-10**
3535

3636
Use [`FromStrRadix`](http://static.rust-lang.org/doc/master/std/num/trait.FromStrRadix.html), and its helper function, [`from_str_radix`](http://static.rust-lang.org/doc/master/std/num/fn.from_str_radix.html).
3737

38-
~~~
38+
```rust
3939
use std::num::from_str_radix;
4040

41-
let x: Option<i64> = from_str_radix("deadbeef", 16);
42-
let y: i64 = x.unwrap();
43-
~~~
41+
let x: Option<int> = from_str_radix("deadbeef", 16);
42+
let y: int = x.unwrap();
43+
```
4444

4545
# File operations
4646

4747
## How do I read from a file?
4848

4949
Use [`File::open`](http://static.rust-lang.org/doc/master/std/io/fs/struct.File.html#method.open) to create a [`File`](http://static.rust-lang.org/doc/master/std/io/fs/struct.File.html) struct, which implements the [`Reader`](http://static.rust-lang.org/doc/master/std/io/trait.Reader.html) trait.
5050

51-
~~~ {.xfail-test}
51+
```rust
5252
use std::path::Path;
5353
use std::io::fs::File;
5454

5555
let path : Path = Path::new("Doc-FAQ-Cheatsheet.md");
5656
let on_error = || fail!("open of {:?} failed", path);
5757
let reader : File = File::open(&path).unwrap_or_else(on_error);
58-
~~~
58+
```
5959

6060
## How do I iterate over the lines in a file?
6161

6262
Use the [`lines`](http://static.rust-lang.org/doc/master/std/io/trait.Buffer.html#method.lines) method on a [`BufferedReader`](http://static.rust-lang.org/doc/master/std/io/buffered/struct.BufferedReader.html).
6363

64-
~~~
64+
```rust
6565
use std::io::buffered::BufferedReader;
66-
# use std::io::mem::MemReader;
67-
68-
# let reader = MemReader::new(~[]);
6966

7067
let mut reader = BufferedReader::new(reader);
7168
for line in reader.lines() {
7269
print!("line: {}", line);
7370
}
74-
~~~
71+
```
7572

7673
# String operations
7774

7875
## How do I search for a substring?
7976

8077
Use the [`find_str`](http://static.rust-lang.org/doc/master/std/str/trait.StrSlice.html#tymethod.find_str) method.
8178

82-
~~~
79+
```rust
8380
let str = "Hello, this is some random string";
8481
let index: Option<uint> = str.find_str("rand");
85-
~~~
82+
```
8683

8784
# Containers
8885

8986
## How do I get the length of a vector?
9087

9188
The [`Container`](http://static.rust-lang.org/doc/master/std/container/trait.Container.html) trait provides the `len` method.
9289

93-
~~~
90+
```rust
9491
let u: ~[u32] = ~[0, 1, 2];
9592
let v: &[u32] = &[0, 1, 2, 3];
9693
let w: [u32, .. 5] = [0, 1, 2, 3, 4];
9794

9895
println!("u: {}, v: {}, w: {}", u.len(), v.len(), w.len()); // 3, 4, 5
99-
~~~
96+
```
10097

10198
## How do I iterate over a vector?
10299

103100
Use the [`iter`](http://static.rust-lang.org/doc/master/std/vec/trait.ImmutableVector.html#tymethod.iter) method.
104101

105-
~~~
102+
```rust
106103
let values: ~[int] = ~[1, 2, 3, 4, 5];
107104
for value in values.iter() { // value: &int
108105
println!("{}", *value);
109106
}
110-
~~~
107+
```
111108

112109
(See also [`mut_iter`](http://static.rust-lang.org/doc/master/std/vec/trait.MutableVector.html#tymethod.mut_iter) which yields `&mut int` and [`move_iter`](http://static.rust-lang.org/doc/master/std/vec/trait.OwnedVector.html#tymethod.move_iter) which yields `int` while consuming the `values` vector.)
113110

114111
# Type system
115112

116113
## How do I store a function in a struct?
117114

118-
~~~
115+
```rust
119116
struct Foo {
120117
myfunc: fn(int, uint) -> i32
121118
}
@@ -134,27 +131,24 @@ fn main() {
134131
println!("{}", (f.myfunc)(1, 2));
135132
println!("{}", (g.myfunc)(3, 4));
136133
}
137-
~~~
134+
```
138135

139136
Note that the parenthesis surrounding `f.myfunc` are necessary: they are how Rust disambiguates field lookup and method call. The `'a` on `FooClosure` is the lifetime of the closure's environment pointer.
140137

141138
## How do I express phantom types?
142139

143140
[Phantom types](http://www.haskell.org/haskellwiki/Phantom_type) are those that cannot be constructed at compile time. To express these in Rust, zero-variant `enum`s can be used:
144141

145-
~~~
142+
```rust
146143
enum Open {}
147144
enum Closed {}
148-
~~~
145+
```
149146

150147
Phantom types are useful for enforcing state at compile time. For example:
151148

152-
~~~
149+
```rust
153150
struct Door<State>(~str);
154151

155-
struct Open;
156-
struct Closed;
157-
158152
fn close(Door(name): Door<Open>) -> Door<Closed> {
159153
Door::<Closed>(name)
160154
}
@@ -163,45 +157,40 @@ fn open(Door(name): Door<Closed>) -> Door<Open> {
163157
Door::<Open>(name)
164158
}
165159

166-
let _ = close(Door::<Open>(~"front"));
167-
~~~
168-
169-
Attempting to close a closed door is prevented statically:
170-
171-
~~~ {.xfail-test}
160+
let _ = close(Door::<Open>(~"front")); // ok
172161
let _ = close(Door::<Closed>(~"front")); // error: mismatched types: expected `main::Door<main::Open>` but found `main::Door<main::Closed>`
173-
~~~
162+
```
174163

175164
# FFI (Foreign Function Interface)
176165

177166
## C function signature conversions
178167

179-
Description C signature Equivalent Rust signature
180-
---------------------- ---------------------------------------------- ------------------------------------------
181-
no parameters `void foo(void);` `fn foo();`
182-
return value `int foo(void);` `fn foo() -> c_int;`
183-
function parameters `void foo(int x, int y);` `fn foo(x: int, y: int);`
184-
in-out pointers `void foo(const int* in_ptr, int* out_ptr);` `fn foo(in_ptr: *c_int, out_ptr: *mut c_int);`
168+
Description | C signature | Equivalent Rust signature
169+
----------------------|----------------------------------------------|------------------------------------------
170+
no parameters | `void foo(void);` | `fn foo();`
171+
return value | `int foo(void);` | `fn foo() -> c_int;`
172+
function parameters | `void foo(int x, int y);` | `fn foo(x: int, y: int);`
173+
in-out pointers | `void foo(const int* in_ptr, int* out_ptr);` | `fn foo(in_ptr: *c_int, out_ptr: *mut c_int);`
185174

186175
Note: The Rust signatures should be wrapped in an `extern "ABI" { ... }` block.
187176

188177
### Representing opaque handles
189178

190179
You might see things like this in C APIs:
191180

192-
~~~ {.notrust}
181+
```c
193182
typedef struct Window Window;
194183
Window* createWindow(int width, int height);
195-
~~~
184+
```
196185
197186
You can use a zero-element `enum` ([phantom type](#how-do-i-express-phantom-types)) to represent the opaque object handle. The FFI would look like this:
198187
199-
~~~ {.xfail-test}
188+
```rust
200189
enum Window {}
201190
extern "C" {
202191
fn createWindow(width: c_int, height: c_int) -> *Window;
203192
}
204-
~~~
193+
```
205194

206195
Using a phantom type ensures that the handles cannot be (safely) constructed in client code.
207196

@@ -211,4 +200,4 @@ For small examples, have full type annotations, as much as is reasonable, to kee
211200

212201
Similar documents for other programming languages:
213202

214-
* [http://pleac.sourceforge.net/](http://pleac.sourceforge.net)
203+
* [http://pleac.sourceforge.net/](http://pleac.sourceforge.net)

0 commit comments

Comments
 (0)