Skip to content

Commit 10e7e4a

Browse files
committed
---
yaml --- r: 163493 b: refs/heads/snap-stage3 c: 974e17b h: refs/heads/master i: 163491: 5f72a88 v: v3
1 parent 906ef93 commit 10e7e4a

File tree

112 files changed

+2282
-1901
lines changed

Some content is hidden

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

112 files changed

+2282
-1901
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: 341cf405e5be56b9b1c8f3be6d0fe9a014eeff26
4+
refs/heads/snap-stage3: 974e17b9ea63b38b4a512742fc877a7e4ee94e03
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/doc/guide.md

Lines changed: 46 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,19 @@ let x: int = 5;
418418
If I asked you to read this out loud to the rest of the class, you'd say "`x`
419419
is a binding with the type `int` and the value `five`."
420420

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+
421434
By default, bindings are **immutable**. This code will not compile:
422435

423436
```{ignore}
@@ -436,7 +449,7 @@ error: re-assignment of immutable variable `x`
436449
If you want a binding to be mutable, you can use `mut`:
437450

438451
```{rust}
439-
let mut x = 5i;
452+
let mut x = 5i; // mut x: int
440453
x = 10i;
441454
```
442455

@@ -584,15 +597,15 @@ let y = if x == 5i {
584597
10i
585598
} else {
586599
15i
587-
};
600+
}; // y: int
588601
```
589602

590603
Which we can (and probably should) write like this:
591604

592605
```{rust}
593606
let x = 5i;
594607
595-
let y = if x == 5i { 10i } else { 15i };
608+
let y = if x == 5i { 10i } else { 15i }; // y: int
596609
```
597610

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

930943
```rust
931-
let mut x = (1i, 2i);
932-
let y = (2i, 3i);
944+
let mut x = (1i, 2i); // x: (int, int)
945+
let y = (2i, 3i); // y: (int, int)
933946

934947
x = y;
935948
```
@@ -981,7 +994,7 @@ struct Point {
981994
}
982995

983996
fn main() {
984-
let origin = Point { x: 0i, y: 0i };
997+
let origin = Point { x: 0i, y: 0i }; // origin: Point
985998

986999
println!("The origin is at ({}, {})", origin.x, origin.y);
9871000
}
@@ -1101,7 +1114,7 @@ fn main() {
11011114
let x = 5i;
11021115
let y = 10i;
11031116
1104-
let ordering = cmp(x, y);
1117+
let ordering = cmp(x, y); // ordering: Ordering
11051118
11061119
if ordering == Less {
11071120
println!("less");
@@ -1388,7 +1401,7 @@ Instead, it looks like this:
13881401

13891402
```{rust}
13901403
for x in range(0i, 10i) {
1391-
println!("{}", x);
1404+
println!("{}", x); // x: int
13921405
}
13931406
```
13941407

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

14251438
```{rust}
1426-
let mut x = 5u;
1427-
let mut done = false;
1439+
let mut x = 5u; // mut x: uint
1440+
let mut done = false; // mut done: bool
14281441
14291442
while !done {
14301443
x += x - 3;
@@ -1520,7 +1533,7 @@ The first kind is a `&str`. This is pronounced a 'string slice.' String literals
15201533
are of the type `&str`:
15211534

15221535
```{rust}
1523-
let string = "Hello there.";
1536+
let string = "Hello there."; // string: &str
15241537
```
15251538

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

15341547
```{rust}
1535-
let mut s = "Hello".to_string();
1548+
let mut s = "Hello".to_string(); // mut s: String
15361549
println!("{}", s);
15371550
15381551
s.push_str(", world.");
@@ -1588,16 +1601,19 @@ things. The most basic is the **array**, a fixed-size list of elements of the
15881601
same type. By default, arrays are immutable.
15891602

15901603
```{rust}
1591-
let a = [1i, 2i, 3i];
1592-
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]
15931606
```
15941607

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

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+
15991615
```{rust}
1600-
let a = [0i, ..20]; // Shorthand for array of 20 elements all initialized to 0
1616+
let a = [0i, ..20]; // a: [int, ..20]
16011617
```
16021618

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

16101626
```{rust}
1611-
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
16121628
16131629
println!("a has {} elements", a.len());
16141630
for e in a.iter() {
@@ -1619,7 +1635,7 @@ for e in a.iter() {
16191635
You can access a particular element of an array with **subscript notation**:
16201636

16211637
```{rust}
1622-
let names = ["Graydon", "Brian", "Niko"];
1638+
let names = ["Graydon", "Brian", "Niko"]; // names: [&str, 3]
16231639
16241640
println!("The second name is: {}", names[1]);
16251641
```
@@ -1637,7 +1653,7 @@ later). Vectors are to arrays what `String` is to `&str`. You can create them
16371653
with the `vec!` macro:
16381654

16391655
```{rust}
1640-
let v = vec![1i, 2, 3];
1656+
let v = vec![1i, 2, 3]; // v: Vec<int>
16411657
```
16421658

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

16501666
```{rust}
1651-
let mut nums = vec![1i, 2, 3];
1667+
let mut nums = vec![1i, 2, 3]; // mut nums: Vec<int>
1668+
16521669
nums.push(4);
1670+
16531671
println!("The length of nums is now {}", nums.len()); // Prints 4
16541672
```
16551673

@@ -1823,10 +1841,12 @@ use std::io;
18231841
fn main() {
18241842
println!("Type something!");
18251843
1826-
let input = io::stdin()
1827-
.read_line()
1828-
.ok()
1829-
.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
18301850
18311851
println!("{}", input);
18321852
}
@@ -1969,7 +1989,7 @@ use std::rand;
19691989
fn main() {
19701990
println!("Guess the number!");
19711991
1972-
let secret_number = (rand::random() % 100i) + 1i;
1992+
let secret_number = (rand::random() % 100i) + 1i; // secret_number: int
19731993
19741994
println!("The secret number is: {}", secret_number);
19751995
@@ -2262,8 +2282,8 @@ In this case, we say `x` is a `uint` explicitly, so Rust is able to properly
22622282
tell `random()` what to generate. In a similar fashion, both of these work:
22632283
22642284
```{rust,ignore}
2265-
let input_num = from_str::<uint>("5");
2266-
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>
22672287
```
22682288
22692289
Anyway, with us now converting our input to a number, our code looks like this:

0 commit comments

Comments
 (0)