Skip to content

Commit 6bcc055

Browse files
committed
---
yaml --- r: 145262 b: refs/heads/try2 c: da29a8e h: refs/heads/master v: v3
1 parent 923ce72 commit 6bcc055

Some content is hidden

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

91 files changed

+2911
-3106
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 040f1c06bc7c1c5fa37477513227114d343b3ec3
8+
refs/heads/try2: da29a8e6be0af399ef8b350fa4b6d124d2610bf7
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/rust.md

Lines changed: 64 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ string_body : non_double_quote
248248
| '\x5c' [ '\x22' | common_escape ] ;
249249
250250
common_escape : '\x5c'
251-
| 'n' | 'r' | 't'
251+
| 'n' | 'r' | 't' | '0'
252252
| 'x' hex_digit 2
253253
| 'u' hex_digit 4
254254
| 'U' hex_digit 8 ;
@@ -962,24 +962,76 @@ parameters to allow methods with that trait to be called on values
962962
of that type.
963963

964964

965-
#### Unsafe functions
966-
967-
Unsafe functions are those containing unsafe operations that are not contained in an [`unsafe` block](#unsafe-blocks).
968-
Such a function must be prefixed with the keyword `unsafe`.
965+
#### Unsafety
969966

970967
Unsafe operations are those that potentially violate the memory-safety guarantees of Rust's static semantics.
971-
Specifically, the following operations are considered unsafe:
968+
969+
The following language level features cannot be used in the safe subset of Rust:
972970

973971
- Dereferencing a [raw pointer](#pointer-types).
974-
- Casting a [raw pointer](#pointer-types) to a safe pointer type.
975-
- Calling an unsafe function.
972+
- Calling an unsafe function (including an intrinsic or foreign function).
976973

977-
##### Unsafe blocks
974+
##### Unsafe functions
978975

979-
A block of code can also be prefixed with the `unsafe` keyword, to permit a sequence of unsafe operations in an otherwise-safe function.
980-
This facility exists because the static semantics of Rust are a necessary approximation of the dynamic semantics.
981-
When a programmer has sufficient conviction that a sequence of unsafe operations is actually safe, they can encapsulate that sequence (taken as a whole) within an `unsafe` block. The compiler will consider uses of such code "safe", to the surrounding context.
976+
Unsafe functions are functions that are not safe in all contexts and/or for all possible inputs.
977+
Such a function must be prefixed with the keyword `unsafe`.
978+
979+
##### Unsafe blocks
982980

981+
A block of code can also be prefixed with the `unsafe` keyword, to permit calling `unsafe` functions
982+
or dereferencing raw pointers within a safe function.
983+
984+
When a programmer has sufficient conviction that a sequence of potentially unsafe operations is
985+
actually safe, they can encapsulate that sequence (taken as a whole) within an `unsafe` block. The
986+
compiler will consider uses of such code safe, in the surrounding context.
987+
988+
Unsafe blocks are used to wrap foreign libraries, make direct use of hardware or implement features
989+
not directly present in the language. For example, Rust provides the language features necessary to
990+
implement memory-safe concurrency in the language but the implementation of tasks and message
991+
passing is in the standard library.
992+
993+
Rust's type system is a conservative approximation of the dynamic safety requirements, so in some
994+
cases there is a performance cost to using safe code. For example, a doubly-linked list is not a
995+
tree structure and can only be represented with managed or reference-counted pointers in safe code.
996+
By using `unsafe` blocks to represent the reverse links as raw pointers, it can be implemented with
997+
only owned pointers.
998+
999+
##### Behavior considered unsafe
1000+
1001+
This is a list of behavior which is forbidden in all Rust code. Type checking provides the guarantee
1002+
that these issues are never caused by safe code. An `unsafe` block or function is responsible for
1003+
never invoking this behaviour or exposing an API making it possible for it to occur in safe code.
1004+
1005+
* Data races
1006+
* Dereferencing a null/dangling raw pointer
1007+
* Mutating an immutable value/reference, if it is not marked as non-`Freeze`
1008+
* Reads of [undef](http://llvm.org/docs/LangRef.html#undefined-values) (uninitialized) memory
1009+
* Breaking the [pointer aliasing rules](http://llvm.org/docs/LangRef.html#pointer-aliasing-rules)
1010+
with raw pointers (a subset of the rules used by C)
1011+
* Invoking undefined behavior via compiler intrinsics:
1012+
* Indexing outside of the bounds of an object with `std::ptr::offset` (`offset` intrinsic), with
1013+
the exception of one byte past the end which is permitted.
1014+
* Using `std::ptr::copy_nonoverlapping_memory` (`memcpy32`/`memcpy64` instrinsics) on
1015+
overlapping buffers
1016+
* Invalid values in primitive types, even in private fields/locals:
1017+
* Dangling/null pointers in non-raw pointers, or slices
1018+
* A value other than `false` (0) or `true` (1) in a `bool`
1019+
* A discriminant in an `enum` not included in the type definition
1020+
* A value in a `char` which is a surrogate or above `char::MAX`
1021+
* non-UTF-8 byte sequences in a `str`
1022+
1023+
##### Behaviour not considered unsafe
1024+
1025+
This is a list of behaviour not considered *unsafe* in Rust terms, but that may be undesired.
1026+
1027+
* Deadlocks
1028+
* Reading data from private fields (`std::repr`, `format!("{:?}", x)`)
1029+
* Leaks due to reference count cycles, even in the global heap
1030+
* Exiting without calling destructors
1031+
* Sending signals
1032+
* Accessing/modifying the file system
1033+
* Unsigned integer overflow (well-defined as wrapping)
1034+
* Signed integer overflow (well-defined as two's complement representation wrapping)
9831035

9841036
#### Diverging functions
9851037

branches/try2/mk/llvm.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ LLVM_STAMP_$(1) = $$(CFG_LLVM_BUILD_DIR_$(1))/llvm-auto-clean-stamp
2828

2929
$$(LLVM_CONFIG_$(1)): $$(LLVM_DEPS) $$(LLVM_STAMP_$(1))
3030
@$$(call E, make: llvm)
31-
$$(Q)$$(MAKE) -C $$(CFG_LLVM_BUILD_DIR_$(1)) $$(CFG_LLVM_BUILD_ENV)
31+
$$(Q)$$(MAKE) -C $$(CFG_LLVM_BUILD_DIR_$(1)) $$(CFG_LLVM_BUILD_ENV_$(1))
3232
$$(Q)touch $$(LLVM_CONFIG_$(1))
3333
endif
3434

branches/try2/mk/platform.mk

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ CFG_PATH_MUNGE_mips-unknown-linux-gnu := true
343343
CFG_LDPATH_mips-unknown-linux-gnu :=
344344
CFG_RUN_mips-unknown-linux-gnu=
345345
CFG_RUN_TARG_mips-unknown-linux-gnu=
346+
RUSTC_FLAGS_mips-unknown-linux-gnu := --linker=$(CXX_mips-unknown-linux-gnu) --target-cpu mips32r2 --target-feature +mips32r2,+o32
346347

347348
# i686-pc-mingw32 configuration
348349
CC_i686-pc-mingw32=$(CC)
@@ -352,7 +353,7 @@ AR_i686-pc-mingw32=$(AR)
352353
CFG_LIB_NAME_i686-pc-mingw32=$(1).dll
353354
CFG_LIB_GLOB_i686-pc-mingw32=$(1)-*.dll
354355
CFG_LIB_DSYM_GLOB_i686-pc-mingw32=$(1)-*.dylib.dSYM
355-
CFG_GCCISH_CFLAGS_i686-pc-mingw32 := -Wall -Werror -g -m32 -march=i686 -D_WIN32_WINNT=0x0600
356+
CFG_GCCISH_CFLAGS_i686-pc-mingw32 := -Wall -Werror -g -m32 -march=i686 -D_WIN32_WINNT=0x0600 -I$(CFG_SRC_DIR)src/etc/mingw-fix-include
356357
CFG_GCCISH_CXXFLAGS_i686-pc-mingw32 := -fno-rtti
357358
CFG_GCCISH_LINK_FLAGS_i686-pc-mingw32 := -shared -fPIC -g -m32
358359
CFG_GCCISH_DEF_FLAG_i686-pc-mingw32 :=
@@ -361,6 +362,7 @@ CFG_GCCISH_POST_LIB_FLAGS_i686-pc-mingw32 :=
361362
CFG_DEF_SUFFIX_i686-pc-mingw32 := .mingw32.def
362363
CFG_INSTALL_NAME_i686-pc-mingw32 =
363364
CFG_LIBUV_LINK_FLAGS_i686-pc-mingw32 := -lWs2_32 -lpsapi -liphlpapi
365+
CFG_LLVM_BUILD_ENV_i686-pc-mingw32 := CPATH=$(CFG_SRC_DIR)src/etc/mingw-fix-include
364366
CFG_EXE_SUFFIX_i686-pc-mingw32 := .exe
365367
CFG_WINDOWSY_i686-pc-mingw32 := 1
366368
CFG_UNIXY_i686-pc-mingw32 :=
@@ -479,7 +481,7 @@ define CFG_MAKE_TOOLCHAIN
479481
$$(CFG_GCCISH_DEF_FLAG_$(1))$$(3) $$(2) \
480482
$$(call CFG_INSTALL_NAME_$(1),$$(4))
481483

482-
ifneq ($(HOST_$(1)),arm)
484+
ifeq ($$(findstring $(HOST_$(1)),arm mips),)
483485

484486
# We're using llvm-mc as our assembler because it supports
485487
# .cfi pseudo-ops on mac
@@ -491,7 +493,7 @@ define CFG_MAKE_TOOLCHAIN
491493
-o=$$(1)
492494
else
493495

494-
# For the ARM crosses, use the toolchain assembler
496+
# For the ARM and MIPS crosses, use the toolchain assembler
495497
# XXX: We should be able to use the LLVM assembler
496498
CFG_ASSEMBLE_$(1)=$$(CC_$(1)) $$(CFG_DEPEND_FLAGS) $$(2) -c -o $$(1)
497499

branches/try2/mk/rt.mk

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
# working under these assumptions).
2525

2626
# Hack for passing flags into LIBUV, see below.
27-
LIBUV_FLAGS_i386 = -m32 -fPIC
27+
LIBUV_FLAGS_i386 = -m32 -fPIC -I$(S)src/etc/mingw-fix-include
2828
LIBUV_FLAGS_x86_64 = -m64 -fPIC
2929
ifeq ($(OSTYPE_$(1)), linux-androideabi)
3030
LIBUV_FLAGS_arm = -fPIC -DANDROID -std=gnu99
@@ -71,7 +71,6 @@ RUNTIME_CXXS_$(1)_$(2) := \
7171
rt/sync/lock_and_signal.cpp \
7272
rt/sync/rust_thread.cpp \
7373
rt/rust_builtin.cpp \
74-
rt/rust_run_program.cpp \
7574
rt/rust_rng.cpp \
7675
rt/rust_upcall.cpp \
7776
rt/rust_uv.cpp \

branches/try2/src/compiletest/compiletest.rs

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ extern mod extra;
1717

1818
use std::os;
1919
use std::rt;
20-
use std::f64;
2120

2221
use extra::getopts;
2322
use extra::getopts::groups::{optopt, optflag, reqopt};
@@ -92,64 +91,62 @@ pub fn parse_config(args: ~[~str]) -> config {
9291
let matches =
9392
&match getopts::groups::getopts(args_, groups) {
9493
Ok(m) => m,
95-
Err(f) => fail!(getopts::fail_str(f))
94+
Err(f) => fail!(f.to_err_msg())
9695
};
9796

98-
if getopts::opt_present(matches, "h") || getopts::opt_present(matches, "help") {
97+
if matches.opt_present("h") || matches.opt_present("help") {
9998
let message = fmt!("Usage: %s [OPTIONS] [TESTNAME...]", argv0);
10099
println(getopts::groups::usage(message, groups));
101100
println("");
102101
fail!()
103102
}
104103

105104
fn opt_path(m: &getopts::Matches, nm: &str) -> Path {
106-
Path(getopts::opt_str(m, nm))
105+
Path(m.opt_str(nm).unwrap())
107106
}
108107

109108
config {
110-
compile_lib_path: getopts::opt_str(matches, "compile-lib-path"),
111-
run_lib_path: getopts::opt_str(matches, "run-lib-path"),
109+
compile_lib_path: matches.opt_str("compile-lib-path").unwrap(),
110+
run_lib_path: matches.opt_str("run-lib-path").unwrap(),
112111
rustc_path: opt_path(matches, "rustc-path"),
113-
clang_path: getopts::opt_maybe_str(matches, "clang-path").map_move(|s| Path(s)),
114-
llvm_bin_path: getopts::opt_maybe_str(matches, "llvm-bin-path").map_move(|s| Path(s)),
112+
clang_path: matches.opt_str("clang-path").map_move(|s| Path(s)),
113+
llvm_bin_path: matches.opt_str("llvm-bin-path").map_move(|s| Path(s)),
115114
src_base: opt_path(matches, "src-base"),
116115
build_base: opt_path(matches, "build-base"),
117116
aux_base: opt_path(matches, "aux-base"),
118-
stage_id: getopts::opt_str(matches, "stage-id"),
119-
mode: str_mode(getopts::opt_str(matches, "mode")),
120-
run_ignored: getopts::opt_present(matches, "ignored"),
117+
stage_id: matches.opt_str("stage-id").unwrap(),
118+
mode: str_mode(matches.opt_str("mode").unwrap()),
119+
run_ignored: matches.opt_present("ignored"),
121120
filter:
122121
if !matches.free.is_empty() {
123122
Some(matches.free[0].clone())
124123
} else {
125124
None
126125
},
127-
logfile: getopts::opt_maybe_str(matches, "logfile").map_move(|s| Path(s)),
128-
save_metrics: getopts::opt_maybe_str(matches, "save-metrics").map_move(|s| Path(s)),
126+
logfile: matches.opt_str("logfile").map_move(|s| Path(s)),
127+
save_metrics: matches.opt_str("save-metrics").map_move(|s| Path(s)),
129128
ratchet_metrics:
130-
getopts::opt_maybe_str(matches, "ratchet-metrics").map_move(|s| Path(s)),
129+
matches.opt_str("ratchet-metrics").map_move(|s| Path(s)),
131130
ratchet_noise_percent:
132-
getopts::opt_maybe_str(matches,
133-
"ratchet-noise-percent").map_move(|s|
134-
f64::from_str(s).unwrap()),
135-
runtool: getopts::opt_maybe_str(matches, "runtool"),
136-
rustcflags: getopts::opt_maybe_str(matches, "rustcflags"),
137-
jit: getopts::opt_present(matches, "jit"),
138-
target: opt_str2(getopts::opt_maybe_str(matches, "target")).to_str(),
139-
adb_path: opt_str2(getopts::opt_maybe_str(matches, "adb-path")).to_str(),
131+
matches.opt_str("ratchet-noise-percent").and_then(|s| from_str::<f64>(s)),
132+
runtool: matches.opt_str("runtool"),
133+
rustcflags: matches.opt_str("rustcflags"),
134+
jit: matches.opt_present("jit"),
135+
target: opt_str2(matches.opt_str("target")).to_str(),
136+
adb_path: opt_str2(matches.opt_str("adb-path")).to_str(),
140137
adb_test_dir:
141-
opt_str2(getopts::opt_maybe_str(matches, "adb-test-dir")).to_str(),
138+
opt_str2(matches.opt_str("adb-test-dir")).to_str(),
142139
adb_device_status:
143-
if (opt_str2(getopts::opt_maybe_str(matches, "target")) ==
140+
if (opt_str2(matches.opt_str("target")) ==
144141
~"arm-linux-androideabi") {
145-
if (opt_str2(getopts::opt_maybe_str(matches, "adb-test-dir")) !=
142+
if (opt_str2(matches.opt_str("adb-test-dir")) !=
146143
~"(none)" &&
147-
opt_str2(getopts::opt_maybe_str(matches, "adb-test-dir")) !=
144+
opt_str2(matches.opt_str("adb-test-dir")) !=
148145
~"") { true }
149146
else { false }
150147
} else { false },
151-
test_shard: test::opt_shard(getopts::opt_maybe_str(matches, "test-shard")),
152-
verbose: getopts::opt_present(matches, "verbose")
148+
test_shard: test::opt_shard(matches.opt_str("test-shard")),
149+
verbose: matches.opt_present("verbose")
153150
}
154151
}
155152

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
The purpose of these headers is to fix issues with mingw v4.0, as described in #9246.
2+
3+
This works by adding this directory to GCC include search path before mingw system headers directories,
4+
so we can intercept their inclusions and add missing definitions without having to modify files in mingw/include.
5+
6+
Once mingw fixes all 3 issues mentioned in #9246, this directory and all references to it from rust/mk/* may be removed.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef _FIX_CXXCONFIG_H
2+
#define _FIX_CXXCONFIG_H 1
3+
4+
#define _GLIBCXX_HAVE_FENV_H 1
5+
6+
#include_next <bits/c++config.h>
7+
8+
#endif
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef _FIX_WINBASE_H
2+
#define _FIX_WINBASE_H 1
3+
4+
#define NTDDK_VERSION NTDDI_VERSION
5+
6+
#include_next <winbase.h>
7+
8+
#endif
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef _FIX_WINSOCK2_H
2+
#define _FIX_WINSOCK2_H 1
3+
4+
#include_next <winsock2.h>
5+
6+
typedef struct pollfd {
7+
SOCKET fd;
8+
short events;
9+
short revents;
10+
} WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD;
11+
12+
#endif

0 commit comments

Comments
 (0)