Skip to content

Commit f358ca4

Browse files
committed
auto merge of #19342 : alexcrichton/rust/rollup, r=alexcrichton
2 parents fac5a07 + 5816d7f commit f358ca4

File tree

239 files changed

+9720
-10560
lines changed

Some content is hidden

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

239 files changed

+9720
-10560
lines changed

configure

-1
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,6 @@ probe CFG_LD ld
624624
probe CFG_VALGRIND valgrind
625625
probe CFG_PERF perf
626626
probe CFG_ISCC iscc
627-
probe CFG_LLNEXTGEN LLnextgen
628627
probe CFG_JAVAC javac
629628
probe CFG_ANTLR4 antlr4
630629
probe CFG_GRUN grun

mk/docs.mk

+2-21
Original file line numberDiff line numberDiff line change
@@ -246,26 +246,6 @@ endef
246246
$(foreach lang,$(L10N_LANGS),$(eval $(call DEF_L10N_DOC,$(lang),guide)))
247247

248248

249-
######################################################################
250-
# LLnextgen (grammar analysis from refman)
251-
######################################################################
252-
253-
ifeq ($(CFG_LLNEXTGEN),)
254-
$(info cfg: no llnextgen found, omitting grammar-verification)
255-
else
256-
.PHONY: verify-grammar
257-
258-
doc/rust.g: $(D)/rust.md $(S)src/etc/extract_grammar.py
259-
@$(call E, extract_grammar: $@)
260-
$(Q)$(CFG_PYTHON) $(S)src/etc/extract_grammar.py $< >$@
261-
262-
verify-grammar: doc/rust.g
263-
@$(call E, LLnextgen: $<)
264-
$(Q)$(CFG_LLNEXTGEN) --generate-lexer-wrapper=no $< >$@
265-
$(Q)rm -f doc/rust.c doc/rust.h
266-
endif
267-
268-
269249
######################################################################
270250
# Rustdoc (libstd/extra)
271251
######################################################################
@@ -299,7 +279,8 @@ $(2) += doc/$(1)/index.html
299279
doc/$(1)/index.html: CFG_COMPILER_HOST_TRIPLE = $(CFG_TARGET)
300280
doc/$(1)/index.html: $$(LIB_DOC_DEP_$(1)) doc/$(1)/
301281
@$$(call E, rustdoc: $$@)
302-
$$(Q)$$(RUSTDOC) --cfg dox --cfg stage2 $$<
282+
$$(Q)CFG_LLVM_LINKAGE_FILE=$$(LLVM_LINKAGE_PATH_$(CFG_BUILD)) \
283+
$$(RUSTDOC) --cfg dox --cfg stage2 $$<
303284
endef
304285

305286
$(foreach crate,$(DOC_CRATES),$(eval $(call DEF_LIB_DOC,$(crate),DOC_TARGETS)))

mk/llvm.mk

+17-7
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ else
4949
LLVM_STDCPP_LOCATION_$(1) =
5050
endif
5151

52+
53+
# LLVM linkage:
54+
LLVM_LINKAGE_PATH_$(1):=$$(abspath $$(RT_OUTPUT_DIR_$(1))/llvmdeps.rs)
55+
$$(LLVM_LINKAGE_PATH_$(1)): $(S)src/etc/mklldeps.py $$(LLVM_CONFIG_$(1))
56+
$(Q)$(CFG_PYTHON) "$$<" "$$@" "$$(LLVM_COMPONENTS)" "$$(CFG_ENABLE_LLVM_STATIC_STDCPP)" \
57+
$$(LLVM_CONFIG_$(1))
5258
endef
5359

5460
$(foreach host,$(CFG_HOST), \
@@ -57,10 +63,14 @@ $(foreach host,$(CFG_HOST), \
5763
$(foreach host,$(CFG_HOST), \
5864
$(eval LLVM_CONFIGS := $(LLVM_CONFIGS) $(LLVM_CONFIG_$(host))))
5965

60-
$(S)src/librustc_llvm/llvmdeps.rs: \
61-
$(LLVM_CONFIGS) \
62-
$(S)src/etc/mklldeps.py \
63-
$(MKFILE_DEPS)
64-
$(Q)$(CFG_PYTHON) $(S)src/etc/mklldeps.py \
65-
"$@" "$(LLVM_COMPONENTS)" "$(CFG_ENABLE_LLVM_STATIC_STDCPP)" \
66-
$(LLVM_CONFIGS)
66+
# This can't be done in target.mk because it's included before this file.
67+
define LLVM_LINKAGE_DEPS
68+
$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.rustc_llvm: $$(LLVM_LINKAGE_PATH_$(3))
69+
endef
70+
71+
$(foreach source,$(CFG_HOST), \
72+
$(foreach target,$(CFG_TARGET), \
73+
$(eval $(call LLVM_LINKAGE_DEPS,0,$(target),$(source))) \
74+
$(eval $(call LLVM_LINKAGE_DEPS,1,$(target),$(source))) \
75+
$(eval $(call LLVM_LINKAGE_DEPS,2,$(target),$(source))) \
76+
$(eval $(call LLVM_LINKAGE_DEPS,3,$(target),$(source)))))

mk/target.mk

+2-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): \
7979
$$(dir $$@)$$(call CFG_LIB_GLOB_$(2),$(4)))
8080
$$(call REMOVE_ALL_OLD_GLOB_MATCHES, \
8181
$$(dir $$@)$$(call CFG_RLIB_GLOB,$(4)))
82-
$$(STAGE$(1)_T_$(2)_H_$(3)) \
82+
$(Q)CFG_LLVM_LINKAGE_FILE=$$(LLVM_LINKAGE_PATH_$(2)) \
83+
$$(subst @,,$$(STAGE$(1)_T_$(2)_H_$(3))) \
8384
$$(RUST_LIB_FLAGS_ST$(1)) \
8485
-L "$$(RT_OUTPUT_DIR_$(2))" \
8586
-L "$$(LLVM_LIBDIR_$(2))" \
@@ -134,8 +135,6 @@ SNAPSHOT_RUSTC_POST_CLEANUP=$(HBIN0_H_$(CFG_BUILD))/rustc$(X_$(CFG_BUILD))
134135

135136
define TARGET_HOST_RULES
136137

137-
$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.rustc_llvm: $(S)src/librustc_llvm/llvmdeps.rs
138-
139138
$$(TBIN$(1)_T_$(2)_H_$(3))/:
140139
mkdir -p $$@
141140

mk/tests.mk

+4-2
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,8 @@ $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2)): \
412412
$$(CRATEFILE_$(4)) \
413413
$$(TESTDEP_$(1)_$(2)_$(3)_$(4))
414414
@$$(call E, rustc: $$@)
415-
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test \
415+
$(Q)CFG_LLVM_LINKAGE_FILE=$$(LLVM_LINKAGE_PATH_$(2)) \
416+
$$(subst @,,$$(STAGE$(1)_T_$(2)_H_$(3))) -o $$@ $$< --test \
416417
-L "$$(RT_OUTPUT_DIR_$(2))" \
417418
-L "$$(LLVM_LIBDIR_$(2))" \
418419
$$(RUSTFLAGS_$(4))
@@ -890,7 +891,8 @@ endif
890891
ifeq ($(2),$$(CFG_BUILD))
891892
$$(call TEST_OK_FILE,$(1),$(2),$(3),doc-crate-$(4)): $$(CRATEDOCTESTDEP_$(1)_$(2)_$(3)_$(4))
892893
@$$(call E, run doc-crate-$(4) [$(2)])
893-
$$(Q)$$(RUSTDOC_$(1)_T_$(2)_H_$(3)) --test --cfg dox \
894+
$$(Q)CFG_LLVM_LINKAGE_FILE=$$(LLVM_LINKAGE_PATH_$(2)) \
895+
$$(RUSTDOC_$(1)_T_$(2)_H_$(3)) --test --cfg dox \
894896
$$(CRATEFILE_$(4)) --test-args "$$(TESTARGS)" && touch $$@
895897
else
896898
$$(call TEST_OK_FILE,$(1),$(2),$(3),doc-crate-$(4)):

src/doc/complement-bugreport.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# I think I found a bug in the compiler!
44

5-
If you see this message: `error: internal compiler error: unexpected failure`,
5+
If you see this message: `error: internal compiler error: unexpected panic`,
66
then you have definitely found a bug in the compiler. It's also possible that
77
your code is not well-typed, but if you saw this message, it's still a bug in
88
error reporting.

src/doc/guide-pointers.md

+26-5
Original file line numberDiff line numberDiff line change
@@ -445,11 +445,32 @@ fn succ(x: &int) -> int { *x + 1 }
445445
to
446446

447447
```{rust}
448+
use std::rc::Rc;
449+
448450
fn box_succ(x: Box<int>) -> int { *x + 1 }
449451
450-
fn rc_succ(x: std::rc::Rc<int>) -> int { *x + 1 }
452+
fn rc_succ(x: Rc<int>) -> int { *x + 1 }
453+
```
454+
455+
Note that the caller of your function will have to modify their calls slightly:
456+
457+
```{rust}
458+
use std::rc::Rc;
459+
460+
fn succ(x: &int) -> int { *x + 1 }
461+
462+
let ref_x = &5i;
463+
let box_x = box 5i;
464+
let rc_x = Rc::new(5i);
465+
466+
succ(ref_x);
467+
succ(&*box_x);
468+
succ(&*rc_x);
451469
```
452470

471+
The initial `*` dereferences the pointer, and then `&` takes a reference to
472+
those contents.
473+
453474
# Boxes
454475

455476
`Box<T>` is Rust's 'boxed pointer' type. Boxes provide the simplest form of
@@ -572,7 +593,7 @@ fn add_one(x: &mut int) -> int {
572593
fn main() {
573594
let x = box 5i;
574595
575-
println!("{}", add_one(&*x)); // error: cannot borrow immutable dereference
596+
println!("{}", add_one(&*x)); // error: cannot borrow immutable dereference
576597
// of `&`-pointer as mutable
577598
}
578599
```
@@ -700,9 +721,9 @@ This gives you flexibility without sacrificing performance.
700721

701722
You may think that this gives us terrible performance: return a value and then
702723
immediately box it up ?! Isn't that the worst of both worlds? Rust is smarter
703-
than that. There is no copy in this code. main allocates enough room for the
704-
`box , passes a pointer to that memory into foo as x, and then foo writes the
705-
value straight into that pointer. This writes the return value directly into
724+
than that. There is no copy in this code. `main` allocates enough room for the
725+
`box`, passes a pointer to that memory into `foo` as `x`, and then `foo` writes
726+
the value straight into that pointer. This writes the return value directly into
706727
the allocated box.
707728

708729
This is important enough that it bears repeating: pointers are not for

src/doc/guide.md

+46-11
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ the easiest way to keep people updated while Rust is in its alpha state.
6262

6363
Oh, we should also mention the officially supported platforms:
6464

65-
* Windows (7, 8, Server 2008 R2), x86 only
65+
* Windows (7, 8, Server 2008 R2)
6666
* Linux (2.6.18 or later, various distributions), x86 and x86-64
6767
* OSX 10.7 (Lion) or greater, x86 and x86-64
6868

@@ -378,9 +378,15 @@ of your time with Rust.
378378
The first thing we'll learn about are 'variable bindings.' They look like this:
379379

380380
```{rust}
381-
let x = 5i;
381+
fn main() {
382+
let x = 5i;
383+
}
382384
```
383385

386+
Putting `fn main() {` in each example is a bit tedious, so we'll leave that out
387+
in the future. If you're following along, make sure to edit your `main()`
388+
function, rather than leaving it off. Otherwise, you'll get an error.
389+
384390
In many languages, this is called a 'variable.' But Rust's variable bindings
385391
have a few tricks up their sleeves. Rust has a very powerful feature called
386392
'pattern matching' that we'll get into detail with later, but the left
@@ -683,7 +689,7 @@ fn main() {
683689
```
684690

685691
This is the simplest possible function declaration. As we mentioned before,
686-
`fn` says 'this is a function,' followed by the name, some parenthesis because
692+
`fn` says 'this is a function,' followed by the name, some parentheses because
687693
this function takes no arguments, and then some curly braces to indicate the
688694
body. Here's a function named `foo`:
689695

@@ -884,7 +890,7 @@ Tuples are an ordered list of a fixed size. Like this:
884890
let x = (1i, "hello");
885891
```
886892

887-
The parenthesis and commas form this two-length tuple. Here's the same code, but
893+
The parentheses and commas form this two-length tuple. Here's the same code, but
888894
with the type annotated:
889895

890896
```rust
@@ -908,9 +914,9 @@ let (x, y, z) = (1i, 2i, 3i);
908914
println!("x is {}", x);
909915
```
910916

911-
Remember before when I said the left hand side of a `let` statement was more
917+
Remember before when I said the left-hand side of a `let` statement was more
912918
powerful than just assigning a binding? Here we are. We can put a pattern on
913-
the left hand side of the `let`, and if it matches up to the right hand side,
919+
the left-hand side of the `let`, and if it matches up to the right-hand side,
914920
we can assign multiple bindings at once. In this case, `let` 'destructures,'
915921
or 'breaks up,' the tuple, and assigns the bits to three bindings.
916922

@@ -1453,9 +1459,9 @@ focus. Any time you have a data structure of variable size, things can get
14531459
tricky, and strings are a re-sizable data structure. That said, Rust's strings
14541460
also work differently than in some other systems languages, such as C.
14551461

1456-
Let's dig into the details. A **string** is a sequence of unicode scalar values
1462+
Let's dig into the details. A **string** is a sequence of Unicode scalar values
14571463
encoded as a stream of UTF-8 bytes. All strings are guaranteed to be
1458-
validly-encoded UTF-8 sequences. Additionally, strings are not null-terminated
1464+
validly encoded UTF-8 sequences. Additionally, strings are not null-terminated
14591465
and can contain null bytes.
14601466

14611467
Rust has two main types of strings: `&str` and `String`.
@@ -3933,7 +3939,7 @@ match x {
39333939
}
39343940
```
39353941

3936-
Here, the `val` inside the `match` has type `int`. In other words, the left hand
3942+
Here, the `val` inside the `match` has type `int`. In other words, the left-hand
39373943
side of the pattern destructures the value. If we have `&5i`, then in `&val`, `val`
39383944
would be `5i`.
39393945

@@ -3991,6 +3997,35 @@ match origin {
39913997
}
39923998
```
39933999

4000+
You can do this kind of match on any member, not just the first:
4001+
4002+
```{rust}
4003+
# #![allow(non_shorthand_field_patterns)]
4004+
struct Point {
4005+
x: int,
4006+
y: int,
4007+
}
4008+
4009+
let origin = Point { x: 0i, y: 0i };
4010+
4011+
match origin {
4012+
Point { y: y, .. } => println!("y is {}", y),
4013+
}
4014+
```
4015+
4016+
If you want to match against a slice or array, you can use `[]`:
4017+
4018+
```{rust}
4019+
fn main() {
4020+
let v = vec!["match_this", "1"];
4021+
4022+
match v.as_slice() {
4023+
["match_this", second] => println!("The second element is {}", second),
4024+
_ => {},
4025+
}
4026+
}
4027+
```
4028+
39944029
Whew! That's a lot of different ways to match things, and they can all be
39954030
mixed and matched, depending on what you're doing:
39964031

@@ -4681,7 +4716,7 @@ let x: Option<int> = Some(5i);
46814716

46824717
In the type declaration, we say `Option<int>`. Note how similar this looks to
46834718
`Option<T>`. So, in this particular `Option`, `T` has the value of `int`. On
4684-
the right hand side of the binding, we do make a `Some(T)`, where `T` is `5i`.
4719+
the right-hand side of the binding, we do make a `Some(T)`, where `T` is `5i`.
46854720
Since that's an `int`, the two sides match, and Rust is happy. If they didn't
46864721
match, we'd get an error:
46874722

@@ -5249,7 +5284,7 @@ immediately.
52495284

52505285
## Success and failure
52515286

5252-
Tasks don't always succeed, they can also panic. A task that wishes to panic
5287+
Tasks don't always succeed, they can also panic. A task that wishes to panic
52535288
can call the `panic!` macro, passing a message:
52545289

52555290
```{rust}

0 commit comments

Comments
 (0)