Skip to content

Commit 3dd6ae6

Browse files
committed
---
yaml --- r: 227167 b: refs/heads/auto c: e40516b h: refs/heads/master i: 227165: 7bcf420 227163: b131dd0 227159: 0fbdc8f 227151: 51dfa8e 227135: 56621e8 v: v3
1 parent 31773b8 commit 3dd6ae6

File tree

258 files changed

+4107
-4722
lines changed

Some content is hidden

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

258 files changed

+4107
-4722
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: 8c4dc18d2a51321070abccd34182381bdc66054d
11+
refs/heads/auto: e40516bcb4e3538aca55e1276a9fe20cf2d63280
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/mk/clean.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ define CLEAN_TARGET_STAGE_N
101101
clean$(1)_T_$(2)_H_$(3): \
102102
$$(foreach crate,$$(CRATES),clean$(1)_T_$(2)_H_$(3)-lib-$$(crate)) \
103103
$$(foreach tool,$$(TOOLS) $$(DEBUGGER_BIN_SCRIPTS_ALL),clean$(1)_T_$(2)_H_$(3)-tool-$$(tool))
104-
$$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a
105104
$$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/libcompiler-rt.a
106105
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/librun_pass_stage* # For unix
107106
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/run_pass_stage* # For windows

branches/auto/mk/crates.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ DEPS_libc := core
6565
DEPS_rustc_unicode := core
6666
DEPS_alloc := core libc native:jemalloc
6767
DEPS_std := core libc rand alloc collections rustc_unicode \
68-
native:rust_builtin native:backtrace native:rustrt_native \
68+
native:rust_builtin native:backtrace \
6969
rustc_bitflags
7070
DEPS_graphviz := std
7171
DEPS_syntax := std term serialize log fmt_macros arena libc

branches/auto/mk/main.mk

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ endif
163163
# that the snapshot will be generated with a statically linked rustc so we only
164164
# have to worry about the distribution of one file (with its native dynamic
165165
# dependencies)
166-
RUSTFLAGS_STAGE0 += -C prefer-dynamic
166+
RUSTFLAGS_STAGE0 += -C prefer-dynamic -C no-stack-check
167167
RUSTFLAGS_STAGE1 += -C prefer-dynamic
168168
RUST_LIB_FLAGS_ST2 += -C prefer-dynamic
169169
RUST_LIB_FLAGS_ST3 += -C prefer-dynamic
@@ -400,6 +400,11 @@ TSREQ$(1)_T_$(2)_H_$(3) = \
400400
$$(foreach obj,$$(INSTALLED_OBJECTS_$(2)),\
401401
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(obj))
402402

403+
ifeq ($(1),0)
404+
TSREQ$(1)_T_$(2)_H_$(3) += \
405+
$$(TLIB$(1)_T_$(2)_H_$(3))/$$(call CFG_STATIC_LIB_NAME_$(2),morestack)
406+
endif
407+
403408
# Prerequisites for a working stageN compiler and libraries, for a specific
404409
# target
405410
SREQ$(1)_T_$(2)_H_$(3) = \

branches/auto/mk/platform.mk

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,7 @@ CFG_RLIB_GLOB=lib$(1)-*.rlib
113113
include $(wildcard $(CFG_SRC_DIR)mk/cfg/*.mk)
114114

115115
define ADD_INSTALLED_OBJECTS
116-
INSTALLED_OBJECTS_$(1) += $$(call CFG_STATIC_LIB_NAME_$(1),morestack) \
117-
$$(call CFG_STATIC_LIB_NAME_$(1),compiler-rt)
116+
INSTALLED_OBJECTS_$(1) += $$(call CFG_STATIC_LIB_NAME_$(1),compiler-rt)
118117
endef
119118

120119
$(foreach target,$(CFG_TARGET), \
@@ -243,6 +242,9 @@ $(foreach target,$(CFG_TARGET), \
243242
# Windows MSVC in the compiler, but the gist of it is that we use `llvm-ar.exe`
244243
# instead of `lib.exe` for assembling archives, so we need to inject this custom
245244
# dependency here.
245+
#
246+
# FIXME(stage0): remove this and all other relevant support in the makefiles
247+
# after a snapshot is made
246248
define ADD_LLVM_AR_TO_MSVC_DEPS
247249
ifeq ($$(findstring msvc,$(1)),msvc)
248250
NATIVE_TOOL_DEPS_core_T_$(1) += llvm-ar.exe
@@ -278,10 +280,15 @@ $(foreach target,$(CFG_TARGET), \
278280
# Fun times!
279281
#
280282
# [1]: https://msdn.microsoft.com/en-us/library/28d6s79h.aspx
283+
#
284+
# FIXME(stage0): remove this macro and the usage below (and the commments above)
285+
# when a new snapshot is available. Also remove the
286+
# RUSTFLAGS$(1)_.._T_ variable in mk/target.mk along with
287+
# CUSTOM_DEPS (as they were only added for this)
281288
define ADD_RUSTC_LLVM_DEF_TO_MSVC
282289
ifeq ($$(findstring msvc,$(1)),msvc)
283-
RUSTFLAGS_rustc_llvm_T_$(1) += -C link-args="-DEF:$(1)/rt/rustc_llvm.def"
284-
CUSTOM_DEPS_rustc_llvm_T_$(1) += $(1)/rt/rustc_llvm.def
290+
RUSTFLAGS0_rustc_llvm_T_$(1) += -C link-args="-DEF:$(1)/rt/rustc_llvm.def"
291+
CUSTOM_DEPS0_rustc_llvm_T_$(1) += $(1)/rt/rustc_llvm.def
285292

286293
$(1)/rt/rustc_llvm.def: $$(S)src/etc/mklldef.py $$(S)src/librustc_llvm/lib.rs
287294
$$(CFG_PYTHON) $$^ $$@ rustc_llvm-$$(CFG_FILENAME_EXTRA)

branches/auto/mk/rt.mk

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
# that's per-target so you're allowed to conditionally add files based on the
3636
# target.
3737
################################################################################
38-
NATIVE_LIBS := rust_builtin hoedown morestack miniz \
39-
rustrt_native rust_test_helpers
38+
NATIVE_LIBS := rust_builtin hoedown miniz \
39+
rust_test_helpers morestack
4040

4141
# $(1) is the target triple
4242
define NATIVE_LIBRARIES
@@ -53,10 +53,8 @@ NATIVE_DEPS_hoedown_$(1) := hoedown/src/autolink.c \
5353
NATIVE_DEPS_miniz_$(1) = miniz.c
5454
NATIVE_DEPS_rust_builtin_$(1) := rust_builtin.c \
5555
rust_android_dummy.c
56-
NATIVE_DEPS_rustrt_native_$(1) := arch/$$(HOST_$(1))/record_sp.S
5756
NATIVE_DEPS_rust_test_helpers_$(1) := rust_test_helpers.c
58-
NATIVE_DEPS_morestack_$(1) := arch/$$(HOST_$(1))/morestack.S
59-
57+
NATIVE_DEPS_morestack_$(1) := empty.c
6058

6159
################################################################################
6260
# You shouldn't find it that necessary to edit anything below this line.

branches/auto/mk/target.mk

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4) := \
4040
$$(RT_OUTPUT_DIR_$(2))/$$(dep)) \
4141
$$(foreach dep,$$(NATIVE_TOOL_DEPS_$(4)_T_$(2)), \
4242
$$(TBIN$(1)_T_$(3)_H_$(3))/$$(dep)) \
43-
$$(CUSTOM_DEPS_$(4)_T_$(2))
43+
$$(CUSTOM_DEPS$(1)_$(4)_T_$(2))
4444
endef
4545

4646
$(foreach host,$(CFG_HOST), \
@@ -56,8 +56,7 @@ $(foreach host,$(CFG_HOST), \
5656
# 1. The immediate dependencies are the rust source files
5757
# 2. Each rust crate dependency is listed (based on their stamp files),
5858
# as well as all native dependencies (listed in RT_OUTPUT_DIR)
59-
# 3. The stage (n-1) compiler is required through the TSREQ dependency, along
60-
# with the morestack library
59+
# 3. The stage (n-1) compiler is required through the TSREQ dependency
6160
# 4. When actually executing the rule, the first thing we do is to clean out
6261
# old libs and rlibs via the REMOVE_ALL_OLD_GLOB_MATCHES macro
6362
# 5. Finally, we get around to building the actual crate. It's just one
@@ -93,7 +92,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): \
9392
$$(LLVM_LIBDIR_RUSTFLAGS_$(2)) \
9493
$$(LLVM_STDCPP_RUSTFLAGS_$(2)) \
9594
$$(RUSTFLAGS_$(4)) \
96-
$$(RUSTFLAGS_$(4)_T_$(2)) \
95+
$$(RUSTFLAGS$(1)_$(4)_T_$(2)) \
9796
--out-dir $$(@D) \
9897
-C extra-filename=-$$(CFG_FILENAME_EXTRA) \
9998
$$<
@@ -206,6 +205,9 @@ $(foreach host,$(CFG_HOST), \
206205
# $(3) - triple snapshot is built for
207206
# $(4) - crate
208207
# $(5) - tool
208+
#
209+
# FIXME(stage0): remove this and all other relevant support in the makefiles
210+
# after a snapshot is made
209211
define MOVE_TOOLS_TO_SNAPSHOT_HOST_DIR
210212
ifneq (,$(3))
211213
$$(TLIB$(1)_T_$(2)_H_$(2))/stamp.$(4): $$(HLIB$(1)_H_$(2))/rustlib/$(3)/bin/$(5)
@@ -230,6 +232,9 @@ $(foreach target,$(CFG_TARGET), \
230232
# path instead of MinGW's /usr/bin/link.exe (entirely unrelated)
231233
#
232234
# The values for these variables are detected by the configure script.
235+
#
236+
# FIXME(stage0): remove this and all other relevant support in the makefiles
237+
# after a snapshot is made
233238
define SETUP_LIB_MSVC_ENV_VARS
234239
ifeq ($$(findstring msvc,$(2)),msvc)
235240
$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): \

branches/auto/src/compiletest/procsrv.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ fn add_target_env(cmd: &mut Command, lib_path: &str, aux_path: Option<&str>) {
2626
// Add the new dylib search path var
2727
let var = DynamicLibrary::envvar();
2828
let newpath = DynamicLibrary::create_path(&path);
29-
let newpath = newpath.to_str().unwrap().to_string();
30-
cmd.env(var, &newpath);
29+
cmd.env(var, newpath);
3130
}
3231

3332
pub struct Result {pub status: ExitStatus, pub out: String, pub err: String}

branches/auto/src/doc/nomicon/exotic-sizes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ support values.
8585
Safe code need not worry about ZSTs, but *unsafe* code must be careful about the
8686
consequence of types with no size. In particular, pointer offsets are no-ops,
8787
and standard allocators (including jemalloc, the one used by default in Rust)
88-
generally consider passing in `0` for the size of an allocation as Undefined
89-
Behaviour.
88+
may return `nullptr` when a zero-sized allocation is requested, which is
89+
indistinguishable from out of memory.
9090

9191

9292

branches/auto/src/doc/nomicon/lifetimes.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ likely desugar to the following:
5252
}
5353
```
5454

55-
Wow. That's... awful. Let's all take a moment to thank Rust for being a
56-
diabetes-inducing torrent of syrupy-goodness.
55+
Wow. That's... awful. Let's all take a moment to thank Rust for making this easier.
5756

5857
Actually passing references to outer scopes will cause Rust to infer
5958
a larger lifetime:

branches/auto/src/doc/nomicon/repr-rust.md

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ struct A {
3636
}
3737
```
3838

39-
will be 32-bit aligned assuming these primitives are aligned to their size.
40-
It will therefore have a size that is a multiple of 32-bits. It will potentially
41-
*really* become:
39+
will be 32-bit aligned on an architecture that aligns these primitives to their
40+
respective sizes. The whole struct will therefore have a size that is a multiple
41+
of 32-bits. It will potentially become:
4242

4343
```rust
4444
struct A {
@@ -50,10 +50,10 @@ struct A {
5050
}
5151
```
5252

53-
There is *no indirection* for these types; all data is stored contiguously as
54-
you would expect in C. However with the exception of arrays (which are densely
55-
packed and in-order), the layout of data is not by default specified in Rust.
56-
Given the two following struct definitions:
53+
There is *no indirection* for these types; all data is stored within the struct,
54+
as you would expect in C. However with the exception of arrays (which are
55+
densely packed and in-order), the layout of data is not by default specified in
56+
Rust. Given the two following struct definitions:
5757

5858
```rust
5959
struct A {
@@ -62,18 +62,17 @@ struct A {
6262
}
6363

6464
struct B {
65-
x: i32,
65+
a: i32,
6666
b: u64,
6767
}
6868
```
6969

7070
Rust *does* guarantee that two instances of A have their data laid out in
71-
exactly the same way. However Rust *does not* guarantee that an instance of A
72-
has the same field ordering or padding as an instance of B (in practice there's
73-
no particular reason why they wouldn't, other than that its not currently
74-
guaranteed).
71+
exactly the same way. However Rust *does not* currently guarantee that an
72+
instance of A has the same field ordering or padding as an instance of B, though
73+
in practice there's no reason why they wouldn't.
7574

76-
With A and B as written, this is basically nonsensical, but several other
75+
With A and B as written, this point would seem to be pedantic, but several other
7776
features of Rust make it desirable for the language to play with data layout in
7877
complex ways.
7978

@@ -133,18 +132,21 @@ struct FooRepr {
133132
}
134133
```
135134

136-
And indeed this is approximately how it would be laid out in general
137-
(modulo the size and position of `tag`). However there are several cases where
138-
such a representation is inefficient. The classic case of this is Rust's
139-
"null pointer optimization". Given a pointer that is known to not be null
140-
(e.g. `&u32`), an enum can *store* a discriminant bit *inside* the pointer
141-
by using null as a special value. The net result is that
142-
`size_of::<Option<&T>>() == size_of::<&T>()`
135+
And indeed this is approximately how it would be laid out in general (modulo the
136+
size and position of `tag`).
137+
138+
However there are several cases where such a representation is inefficient. The
139+
classic case of this is Rust's "null pointer optimization": an enum consisting
140+
of a single outer unit variant (e.g. `None`) and a (potentially nested) non-
141+
nullable pointer variant (e.g. `&T`) makes the tag unnecessary, because a null
142+
pointer value can safely be interpreted to mean that the unit variant is chosen
143+
instead. The net result is that, for example, `size_of::<Option<&T>>() ==
144+
size_of::<&T>()`.
143145

144-
There are many types in Rust that are, or contain, "not null" pointers such as
146+
There are many types in Rust that are, or contain, non-nullable pointers such as
145147
`Box<T>`, `Vec<T>`, `String`, `&T`, and `&mut T`. Similarly, one can imagine
146148
nested enums pooling their tags into a single discriminant, as they are by
147-
definition known to have a limited range of valid values. In principle enums can
149+
definition known to have a limited range of valid values. In principle enums could
148150
use fairly elaborate algorithms to cache bits throughout nested types with
149151
special constrained representations. As such it is *especially* desirable that
150152
we leave enum layout unspecified today.

branches/auto/src/doc/reference.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,7 +1501,29 @@ have an implementation for `Shape`. Multiple supertraits are separated by `+`,
15011501
`trait Circle : Shape + PartialEq { }`. In an implementation of `Circle` for a
15021502
given type `T`, methods can refer to `Shape` methods, since the typechecker
15031503
checks that any type with an implementation of `Circle` also has an
1504-
implementation of `Shape`.
1504+
implementation of `Shape`:
1505+
1506+
```rust
1507+
struct Foo;
1508+
1509+
trait Shape { fn area(&self) -> f64; }
1510+
trait Circle : Shape { fn radius(&self) -> f64; }
1511+
# impl Shape for Foo {
1512+
# fn area(&self) -> f64 {
1513+
# 0.0
1514+
# }
1515+
# }
1516+
impl Circle for Foo {
1517+
fn radius(&self) -> f64 {
1518+
println!("calling area: {}", self.area());
1519+
1520+
0.0
1521+
}
1522+
}
1523+
1524+
let c = Foo;
1525+
c.radius();
1526+
```
15051527

15061528
In type-parameterized functions, methods of the supertrait may be called on
15071529
values of subtrait-bound type parameters. Referring to the previous example of
@@ -1902,10 +1924,16 @@ On an `extern` block, the following attributes are interpreted:
19021924
name and type. This is feature gated and the exact behavior is
19031925
implementation-defined (due to variety of linker invocation syntax).
19041926
- `link` - indicate that a native library should be linked to for the
1905-
declarations in this block to be linked correctly. `link` supports an optional `kind`
1906-
key with three possible values: `dylib`, `static`, and `framework`. See [external blocks](#external-blocks) for more about external blocks. Two
1927+
declarations in this block to be linked correctly. `link` supports an optional
1928+
`kind` key with three possible values: `dylib`, `static`, and `framework`. See
1929+
[external blocks](#external-blocks) for more about external blocks. Two
19071930
examples: `#[link(name = "readline")]` and
19081931
`#[link(name = "CoreFoundation", kind = "framework")]`.
1932+
- `linked_from` - indicates what native library this block of FFI items is
1933+
coming from. This attribute is of the form `#[linked_from = "foo"]` where
1934+
`foo` is the name of a library in either `#[link]` or a `-l` flag. This
1935+
attribute is currently required to export symbols from a Rust dynamic library
1936+
on Windows, and it is feature gated behind the `linked_from` feature.
19091937

19101938
On declarations inside an `extern` block, the following attributes are
19111939
interpreted:

branches/auto/src/doc/trpl/advanced-linking.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ Static linking refers to the process of creating output that contain all
3838
required libraries and so don't need libraries installed on every system where
3939
you want to use your compiled project. Pure-Rust dependencies are statically
4040
linked by default so you can use created binaries and libraries without
41-
installing the Rust everywhere. By contrast, native libraries
42-
(e.g. `libc` and `libm`) usually dynamically linked, but it is possible to
41+
installing Rust everywhere. By contrast, native libraries
42+
(e.g. `libc` and `libm`) are usually dynamically linked, but it is possible to
4343
change this and statically link them as well.
4444

45-
Linking is a very platform dependent topic — on some platforms, static linking
46-
may not be possible at all! This section assumes some basic familiarity with
45+
Linking is a very platform-dependent topic, and static linking may not even be
46+
possible on some platforms! This section assumes some basic familiarity with
4747
linking on your platform of choice.
4848

4949
## Linux
@@ -71,8 +71,7 @@ Dynamic linking on Linux can be undesirable if you wish to use new library
7171
features on old systems or target systems which do not have the required
7272
dependencies for your program to run.
7373

74-
Static linking is supported via an alternative `libc`, `musl` - this must be
75-
enabled at Rust compile-time with some prerequisites available. You can compile
74+
Static linking is supported via an alternative `libc`, `musl`. You can compile
7675
your own version of Rust with `musl` enabled and install it into a custom
7776
directory with the instructions below:
7877

@@ -123,7 +122,7 @@ $ du -h musldist/bin/rustc
123122
```
124123

125124
You now have a build of a `musl`-enabled Rust! Because we've installed it to a
126-
custom prefix we need to make sure our system can the binaries and appropriate
125+
custom prefix we need to make sure our system can find the binaries and appropriate
127126
libraries when we try and run it:
128127

129128
```text

branches/auto/src/doc/trpl/closures.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,35 @@ assert_eq!(3, answer);
316316
Now we take a trait object, a `&Fn`. And we have to make a reference
317317
to our closure when we pass it to `call_with_one`, so we use `&||`.
318318

319+
# Function pointers and closures
320+
321+
A function pointer is kind of like a closure that has no environment. As such,
322+
you can pass a function pointer to any function expecting a closure argument,
323+
and it will work:
324+
325+
```rust
326+
fn call_with_one(some_closure: &Fn(i32) -> i32) -> i32 {
327+
some_closure(1)
328+
}
329+
330+
fn add_one(i: i32) -> i32 {
331+
i + 1
332+
}
333+
334+
let f = add_one;
335+
336+
let answer = call_with_one(&f);
337+
338+
assert_eq!(2, answer);
339+
```
340+
341+
In this example, we don’t strictly need the intermediate variable `f`,
342+
the name of the function works just fine too:
343+
344+
```ignore
345+
let answer = call_with_one(&add_one);
346+
```
347+
319348
# Returning closures
320349

321350
It’s very common for functional-style code to return closures in various

0 commit comments

Comments
 (0)