Skip to content

Commit 8653529

Browse files
committed
---
yaml --- r: 276087 b: refs/heads/master c: 815987b h: refs/heads/master i: 276085: 38eac94 276083: 4f9393d 276079: a371121
1 parent 285b52f commit 8653529

Some content is hidden

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

57 files changed

+430
-824
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 3a0efffc9dd2df5b55ee0e111875a018aaa4ecf9
2+
refs/heads/master: 815987b4ce9c1649133263b388903322dd77ea6c
33
refs/heads/snap-stage3: 235d77457d80b549dad3ac36d94f235208a1eafb
44
refs/heads/try: 49312a405e14a449b98fe0056b12a40ac128be4a
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

trunk/mk/cfg/i586-pc-windows-msvc.mk

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# i586-pc-windows-msvc configuration
2-
CC_i586-pc-windows-msvc=$(CFG_MSVC_CL_i386)
3-
LINK_i586-pc-windows-msvc=$(CFG_MSVC_LINK_i386)
4-
CXX_i586-pc-windows-msvc=$(CFG_MSVC_CL_i386)
5-
CPP_i586-pc-windows-msvc=$(CFG_MSVC_CL_i386)
6-
AR_i586-pc-windows-msvc=$(CFG_MSVC_LIB_i386)
2+
CC_i586-pc-windows-msvc="$(CFG_MSVC_CL_i386)" -nologo
3+
LINK_i586-pc-windows-msvc="$(CFG_MSVC_LINK_i386)" -nologo
4+
CXX_i586-pc-windows-msvc="$(CFG_MSVC_CL_i386)" -nologo
5+
CPP_i586-pc-windows-msvc="$(CFG_MSVC_CL_i386)" -nologo
6+
AR_i586-pc-windows-msvc="$(CFG_MSVC_LIB_i386)" -nologo
77
CFG_LIB_NAME_i586-pc-windows-msvc=$(1).dll
88
CFG_STATIC_LIB_NAME_i586-pc-windows-msvc=$(1).lib
99
CFG_LIB_GLOB_i586-pc-windows-msvc=$(1)-*.{dll,lib}
1010
CFG_LIB_DSYM_GLOB_i586-pc-windows-msvc=$(1)-*.dylib.dSYM
1111
CFG_JEMALLOC_CFLAGS_i586-pc-windows-msvc :=
12-
CFG_GCCISH_CFLAGS_i586-pc-windows-msvc := -MD -arch:IA32 -nologo
13-
CFG_GCCISH_CXXFLAGS_i586-pc-windows-msvc := -MD -arch:IA32 -nologo
12+
CFG_GCCISH_CFLAGS_i586-pc-windows-msvc := -MD -arch:IA32
13+
CFG_GCCISH_CXXFLAGS_i586-pc-windows-msvc := -MD -arch:IA32
1414
CFG_GCCISH_LINK_FLAGS_i586-pc-windows-msvc :=
1515
CFG_GCCISH_DEF_FLAG_i586-pc-windows-msvc :=
1616
CFG_LLC_FLAGS_i586-pc-windows-msvc :=

trunk/mk/cfg/i686-pc-windows-msvc.mk

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# i686-pc-windows-msvc configuration
2-
CC_i686-pc-windows-msvc=$(CFG_MSVC_CL_i386)
3-
LINK_i686-pc-windows-msvc=$(CFG_MSVC_LINK_i386)
4-
CXX_i686-pc-windows-msvc=$(CFG_MSVC_CL_i386)
5-
CPP_i686-pc-windows-msvc=$(CFG_MSVC_CL_i386)
6-
AR_i686-pc-windows-msvc=$(CFG_MSVC_LIB_i386)
2+
CC_i686-pc-windows-msvc="$(CFG_MSVC_CL_i386)" -nologo
3+
LINK_i686-pc-windows-msvc="$(CFG_MSVC_LINK_i386)" -nologo
4+
CXX_i686-pc-windows-msvc="$(CFG_MSVC_CL_i386)" -nologo
5+
CPP_i686-pc-windows-msvc="$(CFG_MSVC_CL_i386)" -nologo
6+
AR_i686-pc-windows-msvc="$(CFG_MSVC_LIB_i386)" -nologo
77
CFG_LIB_NAME_i686-pc-windows-msvc=$(1).dll
88
CFG_STATIC_LIB_NAME_i686-pc-windows-msvc=$(1).lib
99
CFG_LIB_GLOB_i686-pc-windows-msvc=$(1)-*.{dll,lib}
1010
CFG_LIB_DSYM_GLOB_i686-pc-windows-msvc=$(1)-*.dylib.dSYM
1111
CFG_JEMALLOC_CFLAGS_i686-pc-windows-msvc :=
12-
CFG_GCCISH_CFLAGS_i686-pc-windows-msvc := -MD -nologo
13-
CFG_GCCISH_CXXFLAGS_i686-pc-windows-msvc := -MD -nologo
12+
CFG_GCCISH_CFLAGS_i686-pc-windows-msvc := -MD
13+
CFG_GCCISH_CXXFLAGS_i686-pc-windows-msvc := -MD
1414
CFG_GCCISH_LINK_FLAGS_i686-pc-windows-msvc :=
1515
CFG_GCCISH_DEF_FLAG_i686-pc-windows-msvc :=
1616
CFG_LLC_FLAGS_i686-pc-windows-msvc :=

trunk/mk/cfg/x86_64-pc-windows-msvc.mk

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# x86_64-pc-windows-msvc configuration
2-
CC_x86_64-pc-windows-msvc=$(CFG_MSVC_CL_x86_64)
3-
LINK_x86_64-pc-windows-msvc=$(CFG_MSVC_LINK_x86_64)
4-
CXX_x86_64-pc-windows-msvc=$(CFG_MSVC_CL_x86_64)
5-
CPP_x86_64-pc-windows-msvc=$(CFG_MSVC_CL_x86_64)
6-
AR_x86_64-pc-windows-msvc=$(CFG_MSVC_LIB_x86_64)
2+
CC_x86_64-pc-windows-msvc="$(CFG_MSVC_CL_x86_64)" -nologo
3+
LINK_x86_64-pc-windows-msvc="$(CFG_MSVC_LINK_x86_64)" -nologo
4+
CXX_x86_64-pc-windows-msvc="$(CFG_MSVC_CL_x86_64)" -nologo
5+
CPP_x86_64-pc-windows-msvc="$(CFG_MSVC_CL_x86_64)" -nologo
6+
AR_x86_64-pc-windows-msvc="$(CFG_MSVC_LIB_x86_64)" -nologo
77
CFG_LIB_NAME_x86_64-pc-windows-msvc=$(1).dll
88
CFG_STATIC_LIB_NAME_x86_64-pc-windows-msvc=$(1).lib
99
CFG_LIB_GLOB_x86_64-pc-windows-msvc=$(1)-*.{dll,lib}
1010
CFG_LIB_DSYM_GLOB_x86_64-pc-windows-msvc=$(1)-*.dylib.dSYM
1111
CFG_JEMALLOC_CFLAGS_x86_64-pc-windows-msvc :=
12-
CFG_GCCISH_CFLAGS_x86_64-pc-windows-msvc := -MD -nologo
13-
CFG_GCCISH_CXXFLAGS_x86_64-pc-windows-msvc := -MD -nologo
12+
CFG_GCCISH_CFLAGS_x86_64-pc-windows-msvc := -MD
13+
CFG_GCCISH_CXXFLAGS_x86_64-pc-windows-msvc := -MD
1414
CFG_GCCISH_LINK_FLAGS_x86_64-pc-windows-msvc :=
1515
CFG_GCCISH_DEF_FLAG_x86_64-pc-windows-msvc :=
1616
CFG_LLC_FLAGS_x86_64-pc-windows-msvc :=

trunk/mk/platform.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ define CC_MACROS
148148
CFG_CC_INCLUDE_$(1)=-I $$(1)
149149
ifeq ($$(findstring msvc,$(1)),msvc)
150150
CFG_CC_OUTPUT_$(1)=-Fo:$$(1)
151-
CFG_CREATE_ARCHIVE_$(1)='$$(AR_$(1))' -OUT:$$(1)
151+
CFG_CREATE_ARCHIVE_$(1)=$$(AR_$(1)) -OUT:$$(1)
152152
else
153153
CFG_CC_OUTPUT_$(1)=-o $$(1)
154154
CFG_CREATE_ARCHIVE_$(1)=$$(AR_$(1)) crus $$(1)
@@ -187,7 +187,7 @@ define CFG_MAKE_TOOLCHAIN
187187
endif
188188
endif
189189

190-
CFG_COMPILE_C_$(1) = '$$(CC_$(1))' \
190+
CFG_COMPILE_C_$(1) = $$(CC_$(1)) \
191191
$$(CFLAGS) \
192192
$$(CFG_GCCISH_CFLAGS) \
193193
$$(CFG_GCCISH_CFLAGS_$(1)) \
@@ -198,7 +198,7 @@ define CFG_MAKE_TOOLCHAIN
198198
$$(CFG_GCCISH_LINK_FLAGS_$(1)) \
199199
$$(CFG_GCCISH_DEF_FLAG_$(1))$$(3) $$(2) \
200200
$$(call CFG_INSTALL_NAME_$(1),$$(4))
201-
CFG_COMPILE_CXX_$(1) = '$$(CXX_$(1))' \
201+
CFG_COMPILE_CXX_$(1) = $$(CXX_$(1)) \
202202
$$(CXXFLAGS) \
203203
$$(CFG_GCCISH_CFLAGS) \
204204
$$(CFG_GCCISH_CXXFLAGS) \

trunk/mk/tests.mk

Lines changed: 68 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,6 @@ CODEGEN_RS := $(call rwildcard,$(S)src/test/codegen/,*.rs)
450450
CODEGEN_CC := $(call rwildcard,$(S)src/test/codegen/,*.cc)
451451
CODEGEN_UNITS_RS := $(call rwildcard,$(S)src/test/codegen-units/,*.rs)
452452
INCREMENTAL_RS := $(call rwildcard,$(S)src/test/incremental/,*.rs)
453-
RMAKE_RS := $(wildcard $(S)src/test/run-make/*/Makefile)
454453
RUSTDOCCK_RS := $(call rwildcard,$(S)src/test/rustdoc/,*.rs)
455454

456455
RPASS_TESTS := $(RPASS_RS)
@@ -467,7 +466,6 @@ DEBUGINFO_LLDB_TESTS := $(DEBUGINFO_LLDB_RS)
467466
CODEGEN_TESTS := $(CODEGEN_RS) $(CODEGEN_CC)
468467
CODEGEN_UNITS_TESTS := $(CODEGEN_UNITS_RS)
469468
INCREMENTAL_TESTS := $(INCREMENTAL_RS)
470-
RMAKE_TESTS := $(RMAKE_RS)
471469
RUSTDOCCK_TESTS := $(RUSTDOCCK_RS)
472470

473471
CTEST_SRC_BASE_rpass = run-pass
@@ -535,11 +533,6 @@ CTEST_BUILD_BASE_incremental = incremental
535533
CTEST_MODE_incremental = incremental
536534
CTEST_RUNTOOL_incremental = $(CTEST_RUNTOOL)
537535

538-
CTEST_SRC_BASE_rmake = run-make
539-
CTEST_BUILD_BASE_rmake = run-make
540-
CTEST_MODE_rmake = run-make
541-
CTEST_RUNTOOL_rmake = $(CTEST_RUNTOOL)
542-
543536
CTEST_SRC_BASE_rustdocck = rustdoc
544537
CTEST_BUILD_BASE_rustdocck = rustdoc
545538
CTEST_MODE_rustdocck = rustdoc
@@ -636,11 +629,6 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
636629
--host-rustcflags "$(RUSTC_FLAGS_$(3)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(3))" \
637630
--lldb-python-dir=$(CFG_LLDB_PYTHON_DIR) \
638631
--target-rustcflags "$(RUSTC_FLAGS_$(2)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(2))" \
639-
--cc '$$(CC_$(3))' \
640-
--cxx '$$(CXX_$(3))' \
641-
--cflags "$$(CFG_GCCISH_CFLAGS_$(3))" \
642-
--llvm-components "$$(LLVM_ALL_COMPONENTS_$(3))" \
643-
--llvm-cxxflags "$$(LLVM_CXXFLAGS_$(3))" \
644632
$$(CTEST_TESTARGS)
645633

646634
ifdef CFG_VALGRIND_RPASS
@@ -670,9 +658,6 @@ CTEST_DEPS_debuginfo-lldb_$(1)-T-$(2)-H-$(3) = $$(DEBUGINFO_LLDB_TESTS) \
670658
CTEST_DEPS_codegen_$(1)-T-$(2)-H-$(3) = $$(CODEGEN_TESTS)
671659
CTEST_DEPS_codegen-units_$(1)-T-$(2)-H-$(3) = $$(CODEGEN_UNITS_TESTS)
672660
CTEST_DEPS_incremental_$(1)-T-$(2)-H-$(3) = $$(INCREMENTAL_TESTS)
673-
CTEST_DEPS_rmake_$(1)-T-$(2)-H-$(3) = $$(RMAKE_TESTS) \
674-
$$(CSREQ$(1)_T_$(3)_H_$(3)) $$(SREQ$(1)_T_$(2)_H_$(3))
675-
676661
CTEST_DEPS_rustdocck_$(1)-T-$(2)-H-$(3) = $$(RUSTDOCCK_TESTS) \
677662
$$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
678663
$(S)src/etc/htmldocck.py
@@ -717,10 +702,6 @@ endif
717702
endif
718703

719704
ifeq ($$(CTEST_DONT_RUN_$(1)-T-$(2)-H-$(3)-$(4)),)
720-
$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
721-
export INCLUDE := $$(CFG_MSVC_INCLUDE_PATH_$$(HOST_$(3)))
722-
$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
723-
export LIB := $$(CFG_MSVC_LIB_PATH_$$(HOST_$(3)))
724705
$$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
725706
$$(TEST_SREQ$(1)_T_$(2)_H_$(3)) \
726707
$$(CTEST_DEPS_$(4)_$(1)-T-$(2)-H-$(3))
@@ -743,8 +724,7 @@ endif
743724
endef
744725

745726
CTEST_NAMES = rpass rpass-valgrind rpass-full rfail-full cfail-full rfail cfail pfail \
746-
debuginfo-gdb debuginfo-lldb codegen codegen-units rustdocck incremental \
747-
rmake
727+
debuginfo-gdb debuginfo-lldb codegen codegen-units rustdocck incremental
748728

749729
$(foreach host,$(CFG_HOST), \
750730
$(eval $(foreach target,$(CFG_TARGET), \
@@ -1029,3 +1009,70 @@ endef
10291009

10301010
$(foreach crate,$(TEST_CRATES), \
10311011
$(eval $(call DEF_CHECK_CRATE,$(crate))))
1012+
1013+
######################################################################
1014+
# RMAKE rules
1015+
######################################################################
1016+
1017+
RMAKE_TESTS := $(shell ls -d $(S)src/test/run-make/*/)
1018+
RMAKE_TESTS := $(RMAKE_TESTS:$(S)src/test/run-make/%/=%)
1019+
1020+
define DEF_RMAKE_FOR_T_H
1021+
# $(1) the stage
1022+
# $(2) target triple
1023+
# $(3) host triple
1024+
1025+
1026+
ifeq ($(2)$(3),$$(CFG_BUILD)$$(CFG_BUILD))
1027+
check-stage$(1)-T-$(2)-H-$(3)-rmake-exec: \
1028+
$$(call TEST_OK_FILE,$(1),$(2),$(3),rmake)
1029+
1030+
$$(call TEST_OK_FILE,$(1),$(2),$(3),rmake): \
1031+
$$(RMAKE_TESTS:%=$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok)
1032+
@touch $$@
1033+
1034+
$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
1035+
export INCLUDE := $$(CFG_MSVC_INCLUDE_PATH_$$(HOST_$(3)))
1036+
$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
1037+
export LIB := $$(CFG_MSVC_LIB_PATH_$$(HOST_$(3)))
1038+
$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
1039+
export MSVC_LIB := "$$(CFG_MSVC_LIB_$$(HOST_$(3)))"
1040+
$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
1041+
$(S)src/test/run-make/%/Makefile \
1042+
$$(CSREQ$(1)_T_$(2)_H_$(3))
1043+
@rm -rf $(3)/test/run-make/$$*
1044+
@mkdir -p $(3)/test/run-make/$$*
1045+
$$(Q)touch $$@.start_time
1046+
$$(Q)$$(CFG_PYTHON) $(S)src/etc/maketest.py $$(dir $$<) \
1047+
$$(MAKE) \
1048+
$$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
1049+
$(3)/test/run-make/$$* \
1050+
'$$(CC_$(3))' \
1051+
"$$(CFG_GCCISH_CFLAGS_$(3))" \
1052+
$$(HBIN$(1)_H_$(3))/rustdoc$$(X_$(3)) \
1053+
"$$(TESTNAME)" \
1054+
$$(LD_LIBRARY_PATH_ENV_NAME$(1)_T_$(2)_H_$(3)) \
1055+
"$$(LD_LIBRARY_PATH_ENV_HOSTDIR$(1)_T_$(2)_H_$(3))" \
1056+
"$$(LD_LIBRARY_PATH_ENV_TARGETDIR$(1)_T_$(2)_H_$(3))" \
1057+
$(1) \
1058+
$$(S) \
1059+
$(3) \
1060+
"$$(LLVM_LIBDIR_RUSTFLAGS_$(3))" \
1061+
"$$(LLVM_ALL_COMPONENTS_$(3))" \
1062+
"$$(LLVM_CXXFLAGS_$(3))" \
1063+
'$$(CXX_$(3))'
1064+
@touch -r $$@.start_time $$@ && rm $$@.start_time
1065+
else
1066+
# FIXME #11094 - The above rule doesn't work right for multiple targets
1067+
check-stage$(1)-T-$(2)-H-$(3)-rmake-exec:
1068+
@true
1069+
1070+
endif
1071+
1072+
1073+
endef
1074+
1075+
$(foreach stage,$(STAGES), \
1076+
$(foreach target,$(CFG_TARGET), \
1077+
$(foreach host,$(CFG_HOST), \
1078+
$(eval $(call DEF_RMAKE_FOR_T_H,$(stage),$(target),$(host))))))

trunk/src/bootstrap/build/check.rs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ use std::fs;
1212
use std::path::{PathBuf, Path};
1313
use std::process::Command;
1414

15-
use build_helper::output;
16-
1715
use build::{Build, Compiler};
1816

1917
pub fn linkcheck(build: &Build, stage: u32, host: &str) {
@@ -114,33 +112,6 @@ pub fn compiletest(build: &Build,
114112
cmd.arg("--verbose");
115113
}
116114

117-
if suite == "run-make" {
118-
let llvm_config = build.llvm_config(target);
119-
let llvm_components = output(Command::new(&llvm_config).arg("--components"));
120-
let llvm_cxxflags = output(Command::new(&llvm_config).arg("--cxxflags"));
121-
cmd.arg("--cc").arg(build.cc(target))
122-
.arg("--cxx").arg(build.cxx(target))
123-
.arg("--cflags").arg(build.cflags(target).join(" "))
124-
.arg("--llvm-components").arg(llvm_components.trim())
125-
.arg("--llvm-cxxflags").arg(llvm_cxxflags.trim());
126-
} else {
127-
cmd.arg("--cc").arg("")
128-
.arg("--cxx").arg("")
129-
.arg("--cflags").arg("")
130-
.arg("--llvm-components").arg("")
131-
.arg("--llvm-cxxflags").arg("");
132-
}
133-
134-
// Running a C compiler on MSVC requires a few env vars to be set, to be
135-
// sure to set them here.
136-
if target.contains("msvc") {
137-
for &(ref k, ref v) in build.cc[target].0.env() {
138-
if k != "PATH" {
139-
cmd.env(k, v);
140-
}
141-
}
142-
}
143-
144115
build.run(&mut cmd);
145116
}
146117

trunk/src/bootstrap/build/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,6 @@ impl Build {
314314
CheckErrorIndex { compiler } => {
315315
check::error_index(self, &compiler);
316316
}
317-
CheckRMake { compiler } => {
318-
check::compiletest(self, &compiler, target.target,
319-
"run-make", "run-make")
320-
}
321317

322318
DistDocs { stage } => dist::docs(self, stage, target.target),
323319
DistMingw { _dummy } => dist::mingw(self, target.target),

trunk/src/bootstrap/build/step.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ macro_rules! targets {
9898
(check_cfail_full, CheckCFailFull { compiler: Compiler<'a> }),
9999
(check_docs, CheckDocs { compiler: Compiler<'a> }),
100100
(check_error_index, CheckErrorIndex { compiler: Compiler<'a> }),
101-
(check_rmake, CheckRMake { compiler: Compiler<'a> }),
102101

103102
// Distribution targets, creating tarballs
104103
(dist, Dist { stage: u32 }),
@@ -346,7 +345,6 @@ impl<'a> Step<'a> {
346345
self.check_cfail_full(compiler),
347346
self.check_error_index(compiler),
348347
self.check_docs(compiler),
349-
self.check_rmake(compiler),
350348
self.check_linkcheck(stage),
351349
self.check_tidy(stage),
352350
self.dist(stage),
@@ -386,8 +384,7 @@ impl<'a> Step<'a> {
386384
]
387385
}
388386
Source::CheckRPassFull { compiler } |
389-
Source::CheckCFailFull { compiler } |
390-
Source::CheckRMake { compiler } => {
387+
Source::CheckCFailFull { compiler } => {
391388
vec![self.librustc(compiler),
392389
self.tool_compiletest(compiler.stage)]
393390
}

trunk/src/doc/book/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ enter the following commands:
412412

413413
```bash
414414
$ mkdir src
415-
$ mv main.rs src/main.rs # or 'move main.rs src/main.rs' on Windows
415+
$ mv main.rs src/main.rs
416416
$ rm main # or 'del main.exe' on Windows
417417
```
418418

trunk/src/doc/book/lifetimes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
% Lifetimes
22

3-
This is the last of three sections presenting Rust’s ownership system. This is one of
4-
Rust’s most distinct and compelling features, with which Rust developers should
3+
This guide is three of three presenting Rust’s ownership system. This is one of
4+
Rust’s most unique and compelling features, with which Rust developers should
55
become quite acquainted. Ownership is how Rust achieves its largest goal,
66
memory safety. There are a few distinct concepts, each with its own chapter:
77

trunk/src/doc/book/ownership.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
% Ownership
22

3-
This is the first of three sections presenting Rust’s ownership system. This is one of
4-
Rust’s most distinct and compelling features, with which Rust developers should
3+
This guide is one of three presenting Rust’s ownership system. This is one of
4+
Rust’s most unique and compelling features, with which Rust developers should
55
become quite acquainted. Ownership is how Rust achieves its largest goal,
66
memory safety. There are a few distinct concepts, each with its own
77
chapter:

trunk/src/doc/book/references-and-borrowing.md

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
% References and Borrowing
22

3-
This is the second of three sections presenting Rust’s ownership system. This is one of
4-
Rust’s most distinct and compelling features, with which Rust developers should
3+
This guide is two of three presenting Rust’s ownership system. This is one of
4+
Rust’s most unique and compelling features, with which Rust developers should
55
become quite acquainted. Ownership is how Rust achieves its largest goal,
66
memory safety. There are a few distinct concepts, each with its own
77
chapter:
@@ -77,32 +77,6 @@ let answer = foo(&v1, &v2);
7777
// we can use v1 and v2 here!
7878
```
7979

80-
A more concrete example:
81-
82-
```rust
83-
fn main() {
84-
// Don't worry if you don't understand how `fold` works, the point here is that an immutable reference is borrowed.
85-
fn sum_vec(v: &Vec<i32>) -> i32 {
86-
return v.iter().fold(0, |a, &b| a + b);
87-
}
88-
// Borrow two vectors and and sum them.
89-
// This kind of borrowing does not allow mutation to the borrowed.
90-
fn foo(v1: &Vec<i32>, v2: &Vec<i32>) -> i32 {
91-
// do stuff with v1 and v2
92-
let s1 = sum_vec(v1);
93-
let s2 = sum_vec(v2);
94-
// return the answer
95-
s1 + s2
96-
}
97-
98-
let v1 = vec![1, 2, 3];
99-
let v2 = vec![4, 5, 6];
100-
101-
let answer = foo(&v1, &v2);
102-
println!("{}", answer);
103-
}
104-
```
105-
10680
Instead of taking `Vec<i32>`s as our arguments, we take a reference:
10781
`&Vec<i32>`. And instead of passing `v1` and `v2` directly, we pass `&v1` and
10882
`&v2`. We call the `&T` type a ‘reference’, and rather than owning the resource,

0 commit comments

Comments
 (0)