Skip to content

Commit 0f6dcbd

Browse files
committed
---
yaml --- r: 163511 b: refs/heads/snap-stage3 c: dbd68c7 h: refs/heads/master i: 163509: 2e24938 163507: 3f75aa2 163503: 10a6de0 v: v3
1 parent 8926c15 commit 0f6dcbd

File tree

164 files changed

+4317
-2297
lines changed

Some content is hidden

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

164 files changed

+4317
-2297
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: 9146a919b616e39e528e4d7100d16eef52f1f852
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: c3778fae6f57d30381476ea0110cb445e52b407a
4+
refs/heads/snap-stage3: dbd68c70cda23990617a6e255fc0fcce4829cddc
55
refs/heads/try: 20cbbffeefc1f35e2ea63afce7b42fbd79611d42
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@
1111
[submodule "src/jemalloc"]
1212
path = src/jemalloc
1313
url = https://github.com/rust-lang/jemalloc.git
14+
[submodule "src/rust-installer"]
15+
path = src/rust-installer
16+
url = https://github.com/rust-lang/rust-installer

branches/snap-stage3/mk/dist.mk

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ PKG_FILES := \
5858
rt \
5959
rustllvm \
6060
snapshots.txt \
61+
rust-installer \
6162
test) \
6263
$(PKG_GITMODULES) \
6364
$(filter-out config.stamp, \
@@ -209,33 +210,40 @@ distcheck-osx: dist-osx
209210
# Unix binary installer tarballs
210211
######################################################################
211212

213+
NON_INSTALLED_PREFIXES=COPYRIGHT,LICENSE-APACHE,LICENSE-MIT,README.md,doc
214+
212215
define DEF_INSTALLER
213216

214217
$$(eval $$(call DEF_PREPARE,dir-$(1)))
215218

216219
dist-install-dir-$(1): PREPARE_HOST=$(1)
217220
dist-install-dir-$(1): PREPARE_TARGETS=$(2)
218-
dist-install-dir-$(1): PREPARE_DEST_DIR=tmp/dist/$$(PKG_NAME)-$(1)
221+
dist-install-dir-$(1): PREPARE_DEST_DIR=tmp/dist/$$(PKG_NAME)-$(1)-image
219222
dist-install-dir-$(1): PREPARE_DIR_CMD=$(DEFAULT_PREPARE_DIR_CMD)
220223
dist-install-dir-$(1): PREPARE_BIN_CMD=$(DEFAULT_PREPARE_BIN_CMD)
221224
dist-install-dir-$(1): PREPARE_LIB_CMD=$(DEFAULT_PREPARE_LIB_CMD)
222225
dist-install-dir-$(1): PREPARE_MAN_CMD=$(DEFAULT_PREPARE_MAN_CMD)
223226
dist-install-dir-$(1): PREPARE_CLEAN=true
224227
dist-install-dir-$(1): prepare-base-dir-$(1) docs compiler-docs
225-
$$(Q)(cd $$(PREPARE_DEST_DIR)/ && find . -type f | sed 's/^\.\///') \
226-
> tmp/dist/manifest-$(1).in
227-
$$(Q)mv tmp/dist/manifest-$(1).in $$(PREPARE_DEST_DIR)/$$(CFG_LIBDIR_RELATIVE)/rustlib/manifest.in
228-
# Add remaining non-installed files
229228
$$(Q)$$(PREPARE_MAN_CMD) $$(S)COPYRIGHT $$(PREPARE_DEST_DIR)
230229
$$(Q)$$(PREPARE_MAN_CMD) $$(S)LICENSE-APACHE $$(PREPARE_DEST_DIR)
231230
$$(Q)$$(PREPARE_MAN_CMD) $$(S)LICENSE-MIT $$(PREPARE_DEST_DIR)
232231
$$(Q)$$(PREPARE_MAN_CMD) $$(S)README.md $$(PREPARE_DEST_DIR)
233232
$$(Q)cp -r doc $$(PREPARE_DEST_DIR)
234-
$$(Q)$$(PREPARE_BIN_CMD) $$(S)src/etc/install.sh $$(PREPARE_DEST_DIR)
235233

236234
dist/$$(PKG_NAME)-$(1).tar.gz: dist-install-dir-$(1)
237235
@$(call E, build: $$@)
238-
$$(Q)tar -czf dist/$$(PKG_NAME)-$(1).tar.gz -C tmp/dist $$(PKG_NAME)-$(1)
236+
$$(Q)$$(S)src/rust-installer/gen-installer.sh \
237+
--product-name=Rust \
238+
--verify-bin=rustc \
239+
--rel-manifest-dir=rustlib \
240+
--success-message=Rust-is-ready-to-roll. \
241+
--image-dir=tmp/dist/$$(PKG_NAME)-$(1)-image \
242+
--work-dir=tmp/dist \
243+
--output-dir=dist \
244+
--non-installed-prefixes=$$(NON_INSTALLED_PREFIXES) \
245+
--package-name=$$(PKG_NAME)-$(1)
246+
$$(Q)rm -R tmp/dist/$$(PKG_NAME)-$(1)-image
239247

240248
endef
241249

branches/snap-stage3/mk/install.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ endif
2525
# Remove tmp files because it's a decent amount of disk space
2626
$(Q)rm -R tmp/dist
2727

28-
prepare_install: dist-install-dir-$(CFG_BUILD) | tmp/empty_dir
28+
prepare_install: dist/$(PKG_NAME)-$(CFG_BUILD).tar.gz | tmp/empty_dir
2929

3030
uninstall:
3131
ifeq (root user, $(USER) $(patsubst %,user,$(SUDO_USER)))
@@ -38,7 +38,7 @@ endif
3838
# Remove tmp files because it's a decent amount of disk space
3939
$(Q)rm -R tmp/dist
4040

41-
prepare_uninstall: dist-install-dir-$(CFG_BUILD) | tmp/empty_dir
41+
prepare_uninstall: dist/$(PKG_NAME)-$(CFG_BUILD).tar.gz | tmp/empty_dir
4242

4343
.PHONY: install prepare_install uninstall prepare_uninstall
4444

branches/snap-stage3/src/compiletest/compiletest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ fn extract_gdb_version(full_version_line: Option<String>) -> Option<String> {
394394

395395
match re.captures(full_version_line) {
396396
Some(captures) => {
397-
Some(captures.at(2).to_string())
397+
Some(captures.at(2).unwrap_or("").to_string())
398398
}
399399
None => {
400400
println!("Could not extract GDB version from line '{}'",
@@ -428,7 +428,7 @@ fn extract_lldb_version(full_version_line: Option<String>) -> Option<String> {
428428

429429
match re.captures(full_version_line) {
430430
Some(captures) => {
431-
Some(captures.at(1).to_string())
431+
Some(captures.at(1).unwrap_or("").to_string())
432432
}
433433
None => {
434434
println!("Could not extract LLDB version from line '{}'",

branches/snap-stage3/src/compiletest/errors.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ fn parse_expected(last_nonfollow_error: Option<uint>,
6666
line: &str,
6767
re: &Regex) -> Option<(WhichLine, ExpectedError)> {
6868
re.captures(line).and_then(|caps| {
69-
let adjusts = caps.name("adjusts").len();
70-
let kind = caps.name("kind").to_ascii_lower();
71-
let msg = caps.name("msg").trim().to_string();
72-
let follow = caps.name("follow").len() > 0;
69+
let adjusts = caps.name("adjusts").unwrap_or("").len();
70+
let kind = caps.name("kind").unwrap_or("").to_ascii_lower();
71+
let msg = caps.name("msg").unwrap_or("").trim().to_string();
72+
let follow = caps.name("follow").unwrap_or("").len() > 0;
7373

7474
let (which, line) = if follow {
7575
assert!(adjusts == 0, "use either //~| or //~^, not both.");

branches/snap-stage3/src/doc/guide.md

Lines changed: 49 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ $ curl -s https://static.rust-lang.org/rustup.sh | sudo sh
3030
below.)
3131

3232
If you're on Windows, please download either the [32-bit
33-
installer](https://static.rust-lang.org/dist/rust-nightly-i686-w64-mingw32.exe)
33+
installer](https://static.rust-lang.org/dist/rust-nightly-i686-pc-windows-gnu.exe)
34+
3435
or the [64-bit
35-
installer](https://static.rust-lang.org/dist/rust-nightly-x86_64-w64-mingw32.exe)
36+
installer](https://static.rust-lang.org/dist/rust-nightly-x86_64-pc-windows-gnu.exe)
3637
and run it.
3738

3839
If you decide you don't want Rust anymore, we'll be a bit sad, but that's okay.
@@ -417,6 +418,19 @@ let x: int = 5;
417418
If I asked you to read this out loud to the rest of the class, you'd say "`x`
418419
is a binding with the type `int` and the value `five`."
419420

421+
In future examples, we may annotate the type in a comment. The examples will
422+
look like this:
423+
424+
```{rust}
425+
fn main() {
426+
let x = 5i; // x: int
427+
}
428+
```
429+
430+
Note the similarities between this annotation and the syntax you use with `let`.
431+
Including these kinds of comments is not idiomatic Rust, but we'll occasionally
432+
include them to help you understand what the types that Rust infers are.
433+
420434
By default, bindings are **immutable**. This code will not compile:
421435

422436
```{ignore}
@@ -435,7 +449,7 @@ error: re-assignment of immutable variable `x`
435449
If you want a binding to be mutable, you can use `mut`:
436450

437451
```{rust}
438-
let mut x = 5i;
452+
let mut x = 5i; // mut x: int
439453
x = 10i;
440454
```
441455

@@ -583,15 +597,15 @@ let y = if x == 5i {
583597
10i
584598
} else {
585599
15i
586-
};
600+
}; // y: int
587601
```
588602

589603
Which we can (and probably should) write like this:
590604

591605
```{rust}
592606
let x = 5i;
593607
594-
let y = if x == 5i { 10i } else { 15i };
608+
let y = if x == 5i { 10i } else { 15i }; // y: int
595609
```
596610

597611
This reveals two interesting things about Rust: it is an expression-based
@@ -927,8 +941,8 @@ destructuring. You can assign one tuple into another, if they have the same
927941
arity and contained types.
928942

929943
```rust
930-
let mut x = (1i, 2i);
931-
let y = (2i, 3i);
944+
let mut x = (1i, 2i); // x: (int, int)
945+
let y = (2i, 3i); // y: (int, int)
932946

933947
x = y;
934948
```
@@ -980,7 +994,7 @@ struct Point {
980994
}
981995

982996
fn main() {
983-
let origin = Point { x: 0i, y: 0i };
997+
let origin = Point { x: 0i, y: 0i }; // origin: Point
984998

985999
println!("The origin is at ({}, {})", origin.x, origin.y);
9861000
}
@@ -1100,7 +1114,7 @@ fn main() {
11001114
let x = 5i;
11011115
let y = 10i;
11021116
1103-
let ordering = cmp(x, y);
1117+
let ordering = cmp(x, y); // ordering: Ordering
11041118
11051119
if ordering == Less {
11061120
println!("less");
@@ -1387,7 +1401,7 @@ Instead, it looks like this:
13871401

13881402
```{rust}
13891403
for x in range(0i, 10i) {
1390-
println!("{}", x);
1404+
println!("{}", x); // x: int
13911405
}
13921406
```
13931407

@@ -1422,8 +1436,8 @@ The other kind of looping construct in Rust is the `while` loop. It looks like
14221436
this:
14231437

14241438
```{rust}
1425-
let mut x = 5u;
1426-
let mut done = false;
1439+
let mut x = 5u; // mut x: uint
1440+
let mut done = false; // mut done: bool
14271441
14281442
while !done {
14291443
x += x - 3;
@@ -1519,7 +1533,7 @@ The first kind is a `&str`. This is pronounced a 'string slice.' String literals
15191533
are of the type `&str`:
15201534

15211535
```{rust}
1522-
let string = "Hello there.";
1536+
let string = "Hello there."; // string: &str
15231537
```
15241538

15251539
This string is statically allocated, meaning that it's saved inside our
@@ -1531,7 +1545,7 @@ A `String`, on the other hand, is an in-memory string. This string is
15311545
growable, and is also guaranteed to be UTF-8.
15321546

15331547
```{rust}
1534-
let mut s = "Hello".to_string();
1548+
let mut s = "Hello".to_string(); // mut s: String
15351549
println!("{}", s);
15361550
15371551
s.push_str(", world.");
@@ -1587,16 +1601,19 @@ things. The most basic is the **array**, a fixed-size list of elements of the
15871601
same type. By default, arrays are immutable.
15881602

15891603
```{rust}
1590-
let a = [1i, 2i, 3i];
1591-
let mut m = [1i, 2i, 3i];
1604+
let a = [1i, 2i, 3i]; // a: [int, ..3]
1605+
let mut m = [1i, 2i, 3i]; // mut m: [int, ..3]
15921606
```
15931607

15941608
You can create an array with a given number of elements, all initialized to the
15951609
same value, with `[val, ..N]` syntax. The compiler ensures that arrays are
15961610
always initialized.
15971611

1612+
There's a shorthand for initializing each element of an array to the same
1613+
value. In this example, each element of `a` will be initialized to `0i`:
1614+
15981615
```{rust}
1599-
let a = [0i, ..20]; // Shorthand for array of 20 elements all initialized to 0
1616+
let a = [0i, ..20]; // a: [int, ..20]
16001617
```
16011618

16021619
Arrays have type `[T,..N]`. We'll talk about this `T` notation later, when we
@@ -1607,7 +1624,7 @@ You can get the number of elements in an array `a` with `a.len()`, and use
16071624
number in order:
16081625

16091626
```{rust}
1610-
let a = [1i, 2, 3]; // Only the first item needs a type suffix
1627+
let a = [1i, 2, 3]; // Only the first item needs a type suffix
16111628
16121629
println!("a has {} elements", a.len());
16131630
for e in a.iter() {
@@ -1618,7 +1635,7 @@ for e in a.iter() {
16181635
You can access a particular element of an array with **subscript notation**:
16191636

16201637
```{rust}
1621-
let names = ["Graydon", "Brian", "Niko"];
1638+
let names = ["Graydon", "Brian", "Niko"]; // names: [&str, 3]
16221639
16231640
println!("The second name is: {}", names[1]);
16241641
```
@@ -1636,7 +1653,7 @@ later). Vectors are to arrays what `String` is to `&str`. You can create them
16361653
with the `vec!` macro:
16371654

16381655
```{rust}
1639-
let v = vec![1i, 2, 3];
1656+
let v = vec![1i, 2, 3]; // v: Vec<int>
16401657
```
16411658

16421659
(Notice that unlike the `println!` macro we've used in the past, we use square
@@ -1647,8 +1664,10 @@ You can get the length of, iterate over, and subscript vectors just like
16471664
arrays. In addition, (mutable) vectors can grow automatically:
16481665

16491666
```{rust}
1650-
let mut nums = vec![1i, 2, 3];
1667+
let mut nums = vec![1i, 2, 3]; // mut nums: Vec<int>
1668+
16511669
nums.push(4);
1670+
16521671
println!("The length of nums is now {}", nums.len()); // Prints 4
16531672
```
16541673

@@ -1822,10 +1841,12 @@ use std::io;
18221841
fn main() {
18231842
println!("Type something!");
18241843
1825-
let input = io::stdin()
1826-
.read_line()
1827-
.ok()
1828-
.expect("Failed to read line");
1844+
// here, we'll show the types at each step
1845+
1846+
let input = io::stdin() // std::io::stdio::StdinReader
1847+
.read_line() // IoResult<String>
1848+
.ok() // Option<String>
1849+
.expect("Failed to read line"); // String
18291850
18301851
println!("{}", input);
18311852
}
@@ -1968,7 +1989,7 @@ use std::rand;
19681989
fn main() {
19691990
println!("Guess the number!");
19701991
1971-
let secret_number = (rand::random() % 100i) + 1i;
1992+
let secret_number = (rand::random() % 100i) + 1i; // secret_number: int
19721993
19731994
println!("The secret number is: {}", secret_number);
19741995
@@ -2261,8 +2282,8 @@ In this case, we say `x` is a `uint` explicitly, so Rust is able to properly
22612282
tell `random()` what to generate. In a similar fashion, both of these work:
22622283
22632284
```{rust,ignore}
2264-
let input_num = from_str::<uint>("5");
2265-
let input_num: Option<uint> = from_str("5");
2285+
let input_num = from_str::<uint>("5"); // input_num: Option<uint>
2286+
let input_num: Option<uint> = from_str("5"); // input_num: Option<uint>
22662287
```
22672288
22682289
Anyway, with us now converting our input to a number, our code looks like this:

0 commit comments

Comments
 (0)