Skip to content

Commit 274488f

Browse files
committed
---
yaml --- r: 104179 b: refs/heads/try c: 92c5738 h: refs/heads/master i: 104177: a23cc32 104175: cdea1a9 v: v3
1 parent c4be5dc commit 274488f

File tree

276 files changed

+6083
-5302
lines changed

Some content is hidden

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

276 files changed

+6083
-5302
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 62f1d68439dcfd509eaca29887afa97f22938373
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6e7f170fedd3c526a643c0b2d13863acd982be02
5-
refs/heads/try: 804955f79a372b2f033b479720a7d72b6d77c48f
5+
refs/heads/try: 92c5738aae54a15717005e84499a522d173a4a09
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/Makefile.in

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,7 @@ ifdef TRACE
125125
CFG_RUSTC_FLAGS += -Z trace
126126
endif
127127
ifdef CFG_DISABLE_RPATH
128-
# NOTE: make this CFG_RUSTC_FLAGS after stage0 snapshot
129-
RUSTFLAGS_STAGE1 += -C no-rpath
130-
RUSTFLAGS_STAGE2 += -C no-rpath
131-
RUSTFLAGS_STAGE3 += -C no-rpath
128+
CFG_RUSTC_FLAGS += -C no-rpath
132129
endif
133130

134131
# The executables crated during this compilation process have no need to include
@@ -140,8 +137,7 @@ endif
140137
# snapshot will be generated with a statically linked rustc so we only have to
141138
# worry about the distribution of one file (with its native dynamic
142139
# dependencies)
143-
#
144-
# NOTE: after a snapshot (stage0), put this on stage0 as well
140+
RUSTFLAGS_STAGE0 += -C prefer-dynamic
145141
RUSTFLAGS_STAGE1 += -C prefer-dynamic
146142

147143
# platform-specific auto-configuration

branches/try/mk/crates.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ TOOLS := compiletest rustdoc rustc
5757

5858
DEPS_std := native:rustrt native:compiler-rt
5959
DEPS_extra := std term sync serialize getopts collections
60-
DEPS_green := std
60+
DEPS_green := std native:context_switch
6161
DEPS_rustuv := std native:uv native:uv_support
6262
DEPS_native := std
6363
DEPS_syntax := std extra term serialize collections

branches/try/mk/dist.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ PKG_ICO = $(S)src/etc/pkg/rust-logo.ico
1212
PKG_EXE = $(PKG_DIR)-install.exe
1313
endif
1414

15-
PKG_GITMODULES := $(S)src/libuv $(S)src/llvm $(S)src/gyp
15+
PKG_GITMODULES := $(S)src/libuv $(S)src/llvm $(S)src/gyp $(S)src/compiler-rt
1616

1717
PKG_FILES := \
1818
$(S)COPYRIGHT \

branches/try/mk/platform.mk

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ CFG_PATH_MUNGE_arm-linux-androideabi := true
300300
CFG_LDPATH_arm-linux-androideabi :=
301301
CFG_RUN_arm-linux-androideabi=
302302
CFG_RUN_TARG_arm-linux-androideabi=
303-
RUSTC_FLAGS_arm-linux-androideabi :=-C android-cross-path=$(CFG_ANDROID_CROSS_PATH)
303+
RUSTC_FLAGS_arm-linux-androideabi :=
304304
RUSTC_CROSS_FLAGS_arm-linux-androideabi :=-C android-cross-path=$(CFG_ANDROID_CROSS_PATH)
305305

306306
# arm-unknown-linux-gnueabihf configuration
@@ -331,7 +331,7 @@ CFG_LDPATH_arm-unknown-linux-gnueabihf :=
331331
CFG_RUN_arm-unknown-linux-gnueabihf=$(2)
332332
CFG_RUN_TARG_arm-unknown-linux-gnueabihf=$(call CFG_RUN_arm-unknown-linux-gnueabihf,,$(2))
333333
RUSTC_FLAGS_arm-unknown-linux-gnueabihf :=
334-
RUSTC_CROSS_FLAGS_arm-unknown-linux-gnueabihf := --linker=$(CROSS_PREFIX_arm-unknown-linux-gnueabihf)$(CXX_arm-unknown-linux-gnueabihf)
334+
RUSTC_CROSS_FLAGS_arm-unknown-linux-gnueabihf :=
335335

336336
# arm-unknown-linux-gnueabi configuration
337337
CROSS_PREFIX_arm-unknown-linux-gnueabi=arm-linux-gnueabi-
@@ -343,7 +343,7 @@ CFG_LIB_NAME_arm-unknown-linux-gnueabi=lib$(1).so
343343
CFG_STATIC_LIB_NAME_arm-unknown-linux-gnueabi=lib$(1).a
344344
CFG_LIB_GLOB_arm-unknown-linux-gnueabi=lib$(1)-*.so
345345
CFG_LIB_DSYM_GLOB_arm-unknown-linux-gnueabi=lib$(1)-*.dylib.dSYM
346-
CFG_GCCISH_CFLAGS_arm-unknown-linux-gnueabi := -Wall -g -fPIC -D__arm__
346+
CFG_GCCISH_CFLAGS_arm-unknown-linux-gnueabi := -Wall -g -fPIC -D__arm__ -mfpu=vfp
347347
CFG_GCCISH_CXXFLAGS_arm-unknown-linux-gnueabi := -fno-rtti
348348
CFG_GCCISH_LINK_FLAGS_arm-unknown-linux-gnueabi := -shared -fPIC -g
349349
CFG_GCCISH_DEF_FLAG_arm-unknown-linux-gnueabi := -Wl,--export-dynamic,--dynamic-list=
@@ -361,7 +361,7 @@ CFG_LDPATH_arm-unknown-linux-gnueabi :=
361361
CFG_RUN_arm-unknown-linux-gnueabi=$(2)
362362
CFG_RUN_TARG_arm-unknown-linux-gnueabi=$(call CFG_RUN_arm-unknown-linux-gnueabi,,$(2))
363363
RUSTC_FLAGS_arm-unknown-linux-gnueabi :=
364-
RUSTC_CROSS_FLAGS_arm-unknown-linux-gnueabi := --linker=$(CROSS_PREFIX_arm-unknown-linux-gnueabi)$(CXX_arm-unknown-linux-gnueabi)
364+
RUSTC_CROSS_FLAGS_arm-unknown-linux-gnueabi :=
365365

366366
# mips-unknown-linux-gnu configuration
367367
CC_mips-unknown-linux-gnu=mips-linux-gnu-gcc
@@ -389,7 +389,7 @@ CFG_PATH_MUNGE_mips-unknown-linux-gnu := true
389389
CFG_LDPATH_mips-unknown-linux-gnu :=
390390
CFG_RUN_mips-unknown-linux-gnu=
391391
CFG_RUN_TARG_mips-unknown-linux-gnu=
392-
RUSTC_FLAGS_mips-unknown-linux-gnu := --linker=$(CXX_mips-unknown-linux-gnu) --target-cpu mips32r2 --target-feature +mips32r2,+o32 -Z soft-float
392+
RUSTC_FLAGS_mips-unknown-linux-gnu := -C target-cpu=mips32r2 -C target-feature="+mips32r2,+o32" -C soft-float
393393

394394
# i686-pc-mingw32 configuration
395395
CC_i686-pc-mingw32=$(CC)
@@ -475,7 +475,7 @@ CFG_PATH_MUNGE_i686-w64-mingw32 :=
475475
CFG_LDPATH_i686-w64-mingw32 :=$(CFG_LDPATH_i686-w64-mingw32):$(PATH)
476476
CFG_RUN_i686-w64-mingw32=PATH="$(CFG_LDPATH_i686-w64-mingw32):$(1)" $(2)
477477
CFG_RUN_TARG_i686-w64-mingw32=$(call CFG_RUN_i686-w64-mingw32,$(HLIB$(1)_H_$(CFG_BUILD)),$(2))
478-
RUSTC_CROSS_FLAGS_i686-w64-mingw32 := --linker=$(CROSS_PREFIX_i686-w64-mingw32)$(CXX_i686-w64-mingw32)
478+
RUSTC_CROSS_FLAGS_i686-w64-mingw32 :=
479479

480480
# x86_64-w64-mingw32 configuration
481481
CROSS_PREFIX_x86_64-w64-mingw32=x86_64-w64-mingw32-
@@ -504,7 +504,7 @@ CFG_PATH_MUNGE_x86_64-w64-mingw32 :=
504504
CFG_LDPATH_x86_64-w64-mingw32 :=$(CFG_LDPATH_x86_64-w64-mingw32):$(PATH)
505505
CFG_RUN_x86_64-w64-mingw32=PATH="$(CFG_LDPATH_x86_64-w64-mingw32):$(1)" $(2)
506506
CFG_RUN_TARG_x86_64-w64-mingw32=$(call CFG_RUN_x86_64-w64-mingw32,$(HLIB$(1)_H_$(CFG_BUILD)),$(2))
507-
RUSTC_CROSS_FLAGS_x86_64-w64-mingw32 := --linker=$(CROSS_PREFIX_x86_64-w64-mingw32)$(CXX_x86_64-w64-mingw32)
507+
RUSTC_CROSS_FLAGS_x86_64-w64-mingw32 :=
508508

509509
# x86_64-unknown-freebsd configuration
510510
CC_x86_64-unknown-freebsd=$(CC)
@@ -549,8 +549,9 @@ define CFG_MAKE_TOOLCHAIN
549549
CXX_$(1)=$(CROSS_PREFIX_$(1))$(CXX_$(1))
550550
CPP_$(1)=$(CROSS_PREFIX_$(1))$(CPP_$(1))
551551
AR_$(1)=$(CROSS_PREFIX_$(1))$(AR_$(1))
552+
RUSTC_CROSS_FLAGS_$(1)=-C linker=$$(CXX_$(1)) -C ar=$$(AR_$(1)) $(RUSTC_CROSS_FLAGS_$(1))
552553

553-
RUSTC_FLAGS_$(1)=$(RUSTC_CROSS_FLAGS_$(1))
554+
RUSTC_FLAGS_$(1)=$$(RUSTC_CROSS_FLAGS_$(1)) $(RUSTC_FLAGS_$(1))
554555
endif
555556

556557
CFG_COMPILE_C_$(1) = $$(CC_$(1)) \

branches/try/mk/rt.mk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
# that's per-target so you're allowed to conditionally add files based on the
3636
# target.
3737
################################################################################
38-
NATIVE_LIBS := rustrt sundown uv_support morestack miniz
38+
NATIVE_LIBS := rustrt sundown uv_support morestack miniz context_switch
3939

4040
# $(1) is the target triple
4141
define NATIVE_LIBRARIES
@@ -54,9 +54,10 @@ NATIVE_DEPS_rustrt_$(1) := rust_builtin.c \
5454
rust_android_dummy.c \
5555
rust_test_helpers.c \
5656
rust_try.ll \
57-
arch/$$(HOST_$(1))/_context.S \
5857
arch/$$(HOST_$(1))/record_sp.S
5958
NATIVE_DEPS_morestack_$(1) := arch/$$(HOST_$(1))/morestack.S
59+
NATIVE_DEPS_context_switch_$(1) := \
60+
arch/$$(HOST_$(1))/_context.S
6061

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

branches/try/mk/tests.mk

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -333,21 +333,22 @@ $(foreach host,$(CFG_HOST), \
333333

334334
define TEST_RUNNER
335335

336-
# If NO_REBUILD is set then break the dependencies on extra so we can
337-
# test crates without rebuilding std and extra first
336+
# If NO_REBUILD is set then break the dependencies on everything but
337+
# the source files so we can test crates without rebuilding any of the
338+
# parent crates.
338339
ifeq ($(NO_REBUILD),)
339-
STDTESTDEP_$(1)_$(2)_$(3)_$(4) = $$(SREQ$(1)_T_$(2)_H_$(3)) \
340+
TESTDEP_$(1)_$(2)_$(3)_$(4) = $$(SREQ$(1)_T_$(2)_H_$(3)) \
340341
$$(foreach crate,$$(TARGET_CRATES),\
341-
$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(crate))
342+
$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(crate)) \
343+
$$(CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4))
342344
else
343-
STDTESTDEP_$(1)_$(2)_$(3)_$(4) =
345+
TESTDEP_$(1)_$(2)_$(3)_$(4) = $$(RSINPUTS_$(4))
344346
endif
345347

346348
$(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2)): CFG_COMPILER = $(2)
347349
$(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2)): \
348-
$$(CRATEFILE_$(4)) \
349-
$$(CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4)) \
350-
$$(STDTESTDEP_$(1)_$(2)_$(3)_$(4))
350+
$$(CRATEFILE_$(4)) \
351+
$$(TESTDEP_$(1)_$(2)_$(3)_$(4))
351352
@$$(call E, oxidize: $$@)
352353
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test \
353354
-L "$$(RT_OUTPUT_DIR_$(2))" \
@@ -553,7 +554,8 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
553554
--host $(3) \
554555
--adb-path=$(CFG_ADB) \
555556
--adb-test-dir=$(CFG_ADB_TEST_DIR) \
556-
--rustcflags "$(RUSTC_FLAGS_$(2)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(2))" \
557+
--host-rustcflags "$(RUSTC_FLAGS_$(3)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(2))" \
558+
--target-rustcflags "$(RUSTC_FLAGS_$(2)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(2))" \
557559
$$(CTEST_TESTARGS)
558560

559561
CTEST_DEPS_rpass_$(1)-T-$(2)-H-$(3) = $$(RPASS_TESTS)
@@ -684,13 +686,22 @@ $(foreach host,$(CFG_HOST), \
684686

685687
define DEF_CRATE_DOC_TEST
686688

689+
# If NO_REBUILD is set then break the dependencies on everything but
690+
# the source files so we can test crate documentation without
691+
# rebuilding any of the parent crates.
692+
ifeq ($(NO_REBUILD),)
693+
DOCTESTDEP_$(1)_$(2)_$(3)_$(4) = \
694+
$$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
695+
$$(CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4)) \
696+
$$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3))
697+
else
698+
DOCTESTDEP_$(1)_$(2)_$(3)_$(4) = $$(RSINPUTS_$(4))
699+
endif
700+
687701
check-stage$(1)-T-$(2)-H-$(3)-doc-$(4)-exec: $$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4))
688702

689703
ifeq ($(2),$$(CFG_BUILD))
690-
$$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4)): \
691-
$$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
692-
$$(CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4)) \
693-
$$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3))
704+
$$(call TEST_OK_FILE,$(1),$(2),$(3),doc-$(4)): $$(DOCTESTDEP_$(1)_$(2)_$(3)_$(4))
694705
@$$(call E, run doc-$(4) [$(2)])
695706
$$(Q)$$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) --test \
696707
$$(CRATEFILE_$(4)) --test-args "$$(TESTARGS)" && touch $$@

branches/try/src/compiletest/common.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,11 @@ pub struct config {
7777
// for running under valgrind
7878
runtool: Option<~str>,
7979

80-
// Flags to pass to the compiler
81-
rustcflags: Option<~str>,
80+
// Flags to pass to the compiler when building for the host
81+
host_rustcflags: Option<~str>,
82+
83+
// Flags to pass to the compiler when building for the target
84+
target_rustcflags: Option<~str>,
8285

8386
// Run tests using the JIT
8487
jit: bool,

branches/try/src/compiletest/compiletest.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ pub fn parse_config(args: ~[~str]) -> config {
6464
optflag("", "ignored", "run tests marked as ignored"),
6565
optopt("", "runtool", "supervisor program to run tests under \
6666
(eg. emulator, valgrind)", "PROGRAM"),
67-
optopt("", "rustcflags", "flags to pass to rustc", "FLAGS"),
67+
optopt("", "host-rustcflags", "flags to pass to rustc for host", "FLAGS"),
68+
optopt("", "target-rustcflags", "flags to pass to rustc for target", "FLAGS"),
6869
optflag("", "verbose", "run tests verbosely, showing all output"),
6970
optopt("", "logfile", "file to log test execution to", "FILE"),
7071
optopt("", "save-metrics", "file to save metrics to", "FILE"),
@@ -132,7 +133,8 @@ pub fn parse_config(args: ~[~str]) -> config {
132133
ratchet_noise_percent:
133134
matches.opt_str("ratchet-noise-percent").and_then(|s| from_str::<f64>(s)),
134135
runtool: matches.opt_str("runtool"),
135-
rustcflags: matches.opt_str("rustcflags"),
136+
host_rustcflags: matches.opt_str("host-rustcflags"),
137+
target_rustcflags: matches.opt_str("target-rustcflags"),
136138
jit: matches.opt_present("jit"),
137139
target: opt_str2(matches.opt_str("target")).to_str(),
138140
host: opt_str2(matches.opt_str("host")).to_str(),
@@ -161,7 +163,8 @@ pub fn log_config(config: &config) {
161163
logv(c, format!("run_ignored: {}", config.run_ignored));
162164
logv(c, format!("filter: {}", opt_str(&config.filter)));
163165
logv(c, format!("runtool: {}", opt_str(&config.runtool)));
164-
logv(c, format!("rustcflags: {}", opt_str(&config.rustcflags)));
166+
logv(c, format!("host-rustcflags: {}", opt_str(&config.host_rustcflags)));
167+
logv(c, format!("target-rustcflags: {}", opt_str(&config.target_rustcflags)));
165168
logv(c, format!("jit: {}", config.jit));
166169
logv(c, format!("target: {}", config.target));
167170
logv(c, format!("host: {}", config.host));
@@ -219,12 +222,14 @@ pub fn run_tests(config: &config) {
219222
mode_debug_info => {
220223
println!("arm-linux-androideabi debug-info \
221224
test uses tcp 5039 port. please reserve it");
222-
//arm-linux-androideabi debug-info test uses remote debugger
223-
//so, we test 1 task at once
224-
os::setenv("RUST_TEST_TASKS","1");
225225
}
226226
_ =>{}
227227
}
228+
229+
//arm-linux-androideabi debug-info test uses remote debugger
230+
//so, we test 1 task at once.
231+
// also trying to isolate problems with adb_run_wrapper.sh ilooping
232+
os::setenv("RUST_TEST_TASKS","1");
228233
}
229234

230235
let opts = test_opts(config);

branches/try/src/compiletest/header.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ pub fn is_test_ignored(config: &config, testfile: &Path) -> bool {
108108
else if parse_name_directive(ln, ignore_stage(config)) { false }
109109
else if config.mode == common::mode_pretty &&
110110
parse_name_directive(ln, "ignore-pretty") { false }
111+
else if config.target != config.host &&
112+
parse_name_directive(ln, "ignore-cross-compile") { false }
111113
else { true }
112114
});
113115

branches/try/src/compiletest/runtest.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ actual:\n\
250250
~"-L", config.build_base.as_str().unwrap().to_owned(),
251251
~"-L",
252252
aux_dir.as_str().unwrap().to_owned()];
253-
args.push_all_move(split_maybe_args(&config.rustcflags));
253+
args.push_all_move(split_maybe_args(&config.target_rustcflags));
254254
args.push_all_move(split_maybe_args(&props.compile_flags));
255255
// FIXME (#9639): This needs to handle non-utf8 paths
256256
return ProcArgs {prog: config.rustc_path.as_str().unwrap().to_owned(), args: args};
@@ -260,9 +260,9 @@ actual:\n\
260260
fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
261261

262262
// do not optimize debuginfo tests
263-
let mut config = match config.rustcflags {
263+
let mut config = match config.target_rustcflags {
264264
Some(ref flags) => config {
265-
rustcflags: Some(flags.replace("-O", "")),
265+
target_rustcflags: Some(flags.replace("-O", "")),
266266
.. (*config).clone()
267267
},
268268
None => (*config).clone()
@@ -329,7 +329,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
329329
break;
330330
}
331331

332-
let args = split_maybe_args(&config.rustcflags);
332+
let args = split_maybe_args(&config.target_rustcflags);
333333
let mut tool_path:~str = ~"";
334334
for arg in args.iter() {
335335
if arg.contains("android-cross-path=") {
@@ -770,7 +770,11 @@ fn make_compile_args(config: &config,
770770
ThisDirectory(path) => { args.push(~"--out-dir"); path }
771771
};
772772
args.push(path.as_str().unwrap().to_owned());
773-
args.push_all_move(split_maybe_args(&config.rustcflags));
773+
if props.force_host {
774+
args.push_all_move(split_maybe_args(&config.host_rustcflags));
775+
} else {
776+
args.push_all_move(split_maybe_args(&config.target_rustcflags));
777+
}
774778
args.push_all_move(split_maybe_args(&props.compile_flags));
775779
return ProcArgs {prog: config.rustc_path.as_str().unwrap().to_owned(), args: args};
776780
}

branches/try/src/doc/complement-cheatsheet.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,42 @@ let y: ~str = x.to_str_radix(16);
3636
Use [`FromStrRadix`](http://static.rust-lang.org/doc/master/std/num/trait.FromStrRadix.html), and its helper function, [`from_str_radix`](http://static.rust-lang.org/doc/master/std/num/fn.from_str_radix.html).
3737

3838
~~~
39-
use std::num::from_str_radix;
39+
use std::num;
4040
41-
let x: Option<i64> = from_str_radix("deadbeef", 16);
41+
let x: Option<i64> = num::from_str_radix("deadbeef", 16);
4242
let y: i64 = x.unwrap();
4343
~~~
4444

45+
**Vector of Bytes to String**
46+
47+
To return a Borrowed String Slice (&str) use the str helper function [`from_utf8`](http://static.rust-lang.org/doc/master/std/str/fn.from_utf8.html).
48+
49+
~~~
50+
use std::str;
51+
52+
let bytes = ~[104u8,105u8];
53+
let x: Option<&str> = str::from_utf8(bytes);
54+
let y: &str = x.unwrap();
55+
~~~
56+
57+
To return an Owned String (~str) use the str helper function [`from_utf8_owned`](http://static.rust-lang.org/doc/master/std/str/fn.from_utf8_owned.html).
58+
59+
~~~
60+
use std::str;
61+
62+
let x: Option<~str> = str::from_utf8_owned(~[104u8,105u8]);
63+
let y: ~str = x.unwrap();
64+
~~~~
65+
66+
To return a [`MaybeOwned`](http://static.rust-lang.org/doc/master/std/str/enum.MaybeOwned.html) use the str helper function [`from_utf8_lossy`](http://static.rust-lang.org/doc/master/std/str/fn.from_utf8_owned.html). This function also replaces non-valid utf-8 sequences with U+FFFD replacement character.
67+
68+
~~~
69+
use std::str;
70+
71+
let x = bytes!(72u8,"ello ",0xF0,0x90,0x80,"World!");
72+
let y = str::from_utf8_lossy(x);
73+
~~~~
74+
4575
# File operations
4676
4777
## How do I read from a file?

branches/try/src/doc/guide-ffi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ impl<T: Send> Unique<T> {
195195
pub fn new(value: T) -> Unique<T> {
196196
unsafe {
197197
let ptr = malloc(std::mem::size_of::<T>() as size_t) as *mut T;
198-
assert!(!ptr::is_null(ptr));
198+
assert!(!ptr.is_null());
199199
// `*ptr` is uninitialized, and `*ptr = value` would attempt to destroy it
200200
// move_val_init moves a value into this memory without
201201
// attempting to drop the original value.

branches/try/src/doc/guide-tasks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ Instead we can use a `SharedChan`, a type that allows a single
232232
~~~
233233
# use std::task::spawn;
234234
235-
let (port, chan) = SharedChan::new();
235+
let (port, chan) = Chan::new();
236236
237237
for init_val in range(0u, 3) {
238238
// Create a new channel handle to distribute to the child task

0 commit comments

Comments
 (0)