From c30ab7b35a139eccf1c05c82b5b62b0decad3ca5 Mon Sep 17 00:00:00 2001
From: Sylvestre Ledru
Date: Fri, 23 Dec 2016 16:36:51 +0100
Subject: [PATCH] New upstream version 1.14.0+dfsg1
---
README.md | 5 +-
RELEASES.md | 263 +---
configure | 63 +-
mk/cfg/aarch64-unknown-fuchsia.mk | 1 +
mk/cfg/wasm32-unknown-emscripten.mk | 24 +
mk/cfg/x86_64-unknown-fuchsia.mk | 1 +
mk/crates.mk | 19 +-
mk/llvm.mk | 32 +-
mk/main.mk | 20 +-
mk/tests.mk | 3 +-
src/bootstrap/Cargo.lock | 180 ---
src/bootstrap/Cargo.toml | 9 +-
src/bootstrap/README.md | 70 +-
src/bootstrap/bin/rustc.rs | 24 +-
src/bootstrap/bin/rustdoc.rs | 10 +-
src/bootstrap/bootstrap.py | 22 +-
src/bootstrap/check.rs | 138 +-
src/bootstrap/clean.rs | 59 +-
src/bootstrap/compile.rs | 50 +-
src/bootstrap/config.rs | 107 +-
src/bootstrap/config.toml.example | 9 +
src/bootstrap/dist.rs | 71 +-
src/bootstrap/doc.rs | 39 +-
src/bootstrap/flags.rs | 239 +++-
src/bootstrap/install.rs | 61 +
src/bootstrap/lib.rs | 316 +----
src/bootstrap/metadata.rs | 95 ++
src/bootstrap/mk/Makefile.in | 35 +-
src/bootstrap/native.rs | 27 +-
src/bootstrap/sanity.rs | 62 +-
src/bootstrap/step.rs | 1180 +++++++++--------
src/bootstrap/util.rs | 21 +-
src/build_helper/lib.rs | 8 +-
src/compiler-rt/lib/builtins/int_lib.h | 2 +-
src/compiler-rt/lib/builtins/powidf2.c | 2 +-
src/compiler-rt/lib/builtins/powisf2.c | 2 +-
src/doc/book/closures.md | 25 +-
src/doc/book/concurrency.md | 6 +-
src/doc/book/const-and-static.md | 2 +-
src/doc/book/deref-coercions.md | 2 +-
src/doc/book/getting-started.md | 77 +-
src/doc/book/guessing-game.md | 12 +-
src/doc/book/lifetimes.md | 92 +-
src/doc/book/references-and-borrowing.md | 4 +-
src/doc/book/syntax-index.md | 7 +-
src/doc/book/testing.md | 80 +-
src/doc/book/type-aliases.md | 2 +-
src/doc/book/variable-bindings.md | 2 +-
src/doc/footer.inc | 1 -
src/doc/grammar.md | 7 +
src/doc/reference.md | 56 +-
src/doc/rust.css | 8 +-
src/etc/local_stage0.sh | 1 +
src/liballoc/arc.rs | 433 ++++--
src/liballoc/boxed.rs | 8 +-
src/liballoc/lib.rs | 1 -
src/liballoc/raw_vec.rs | 15 +-
src/liballoc/rc.rs | 62 +-
src/liballoc_jemalloc/build.rs | 38 +-
src/liballoc_jemalloc/lib.rs | 262 ++--
src/liballoc_system/lib.rs | 14 +-
src/libarena/lib.rs | 52 +-
src/libcollections/binary_heap.rs | 6 +-
src/libcollections/borrow.rs | 83 +-
src/libcollections/btree/map.rs | 35 +
src/libcollections/btree/set.rs | 5 +
src/libcollections/enum_set.rs | 3 -
src/libcollections/fmt.rs | 6 +-
src/libcollections/lib.rs | 2 +-
src/libcollections/linked_list.rs | 1 +
src/libcollections/macros.rs | 4 +-
src/libcollections/slice.rs | 76 +-
src/libcollections/str.rs | 46 +-
src/libcollections/string.rs | 39 +-
src/libcollections/vec.rs | 475 ++++---
src/libcollections/vec_deque.rs | 82 +-
src/libcollectionstest/binary_heap.rs | 4 +-
src/libcollectionstest/btree/map.rs | 4 +-
src/libcollectionstest/btree/mod.rs | 2 +-
src/libcollectionstest/btree/set.rs | 74 +-
src/libcollectionstest/cow_str.rs | 141 ++
src/libcollectionstest/lib.rs | 7 +-
src/libcollectionstest/slice.rs | 78 +-
src/libcollectionstest/str.rs | 15 +-
src/libcollectionstest/string.rs | 6 +
src/libcollectionstest/vec.rs | 81 +-
src/libcollectionstest/vec_deque.rs | 32 +-
src/libcompiler_builtins/build.rs | 6 +
src/libcompiler_builtins/lib.rs | 4 +-
src/libcore/any.rs | 6 +-
src/libcore/array.rs | 2 +
src/libcore/char.rs | 170 +--
src/libcore/clone.rs | 7 -
src/libcore/cmp.rs | 91 +-
src/libcore/convert.rs | 6 +-
src/libcore/fmt/mod.rs | 30 +-
src/libcore/hash/mod.rs | 37 +-
src/libcore/hash/sip.rs | 195 ++-
src/libcore/internal_macros.rs | 62 +
src/libcore/intrinsics.rs | 15 +-
src/libcore/iter/iterator.rs | 8 +-
src/libcore/iter/mod.rs | 135 +-
src/libcore/iter/range.rs | 54 +-
src/libcore/iter/traits.rs | 36 +-
src/libcore/iter_private.rs | 5 +-
src/libcore/lib.rs | 3 +
src/libcore/macros.rs | 198 ++-
src/libcore/marker.rs | 4 +-
src/libcore/mem.rs | 82 ++
src/libcore/num/bignum.rs | 17 +-
src/libcore/num/diy_float.rs | 35 +-
src/libcore/num/f32.rs | 48 +-
src/libcore/num/f64.rs | 48 +-
src/libcore/num/mod.rs | 34 +-
src/libcore/num/wrapping.rs | 22 +-
src/libcore/ops.rs | 189 +--
src/libcore/option.rs | 15 +-
src/libcore/prelude/v1.rs | 42 +-
src/libcore/ptr.rs | 82 +-
src/libcore/result.rs | 58 +-
src/libcore/slice.rs | 8 +
src/libcore/str/mod.rs | 2 +-
src/libcore/sync/atomic.rs | 134 +-
src/libcoretest/char.rs | 21 +-
src/libcoretest/cmp.rs | 26 +
src/libcoretest/hash/sip.rs | 21 +
src/libcoretest/iter.rs | 12 +
src/libcoretest/lib.rs | 2 +
src/libcoretest/num/flt2dec/estimator.rs | 5 +
src/libcoretest/result.rs | 6 +
src/libflate/lib.rs | 35 +-
src/libgetopts/lib.rs | 4 +-
src/libgraphviz/lib.rs | 10 +-
src/liblibc/.travis.yml | 7 +-
src/liblibc/Cargo.lock | 12 +-
src/liblibc/Cargo.toml | 2 +-
.../mips64-unknown-linux-gnuabi64/Dockerfile | 11 +
src/liblibc/ci/run.sh | 4 +
src/liblibc/libc-test/Cargo.toml | 5 +-
.../libc-test/generate-files/Cargo.toml | 2 +-
src/liblibc/src/lib.rs | 3 -
src/liblibc/src/unix/mod.rs | 12 +-
src/liblibc/src/unix/notbsd/linux/mips64.rs | 6 +
src/liblibc/src/unix/notbsd/linux/mod.rs | 3 +
src/liblibc/src/unix/notbsd/linux/musl/mod.rs | 2 +-
.../src/unix/notbsd/linux/other/mod.rs | 1 +
src/liblibc/src/unix/notbsd/mod.rs | 10 +-
src/liblog/directive.rs | 57 +-
src/libpanic_unwind/Cargo.lock | 27 -
src/libpanic_unwind/dwarf/eh.rs | 10 +-
src/libpanic_unwind/emcc.rs | 75 ++
src/libpanic_unwind/gcc.rs | 25 +-
src/libpanic_unwind/lib.rs | 8 +-
src/libpanic_unwind/seh64_gnu.rs | 3 +-
src/libproc_macro/Cargo.toml | 4 -
src/libproc_macro/lib.rs | 248 ++--
src/libproc_macro_plugin/Cargo.toml | 15 +
src/libproc_macro_plugin/lib.rs | 107 ++
.../qquote.rs | 18 +-
.../Cargo.toml | 5 +-
.../build.rs | 0
src/libproc_macro_tokens/lib.rs | 66 +
.../parse.rs | 0
.../prelude.rs | 0
src/librand/chacha.rs | 20 +-
src/librand/distributions/mod.rs | 30 +-
src/librand/isaac.rs | 32 +-
src/librand/rand_impls.rs | 6 +-
src/librand/reseeding.rs | 6 +-
src/librustc/cfg/construct.rs | 18 +-
src/librustc/dep_graph/graph.rs | 19 +-
src/librustc/dep_graph/raii.rs | 28 +-
src/librustc/dep_graph/shadow.rs | 5 +
src/librustc/dep_graph/thread.rs | 19 +-
src/librustc/diagnostics.rs | 17 +
src/librustc/hir/def.rs | 85 +-
src/librustc/hir/intravisit.rs | 8 +-
src/librustc/hir/lowering.rs | 121 +-
src/librustc/hir/map/def_collector.rs | 118 +-
src/librustc/hir/map/definitions.rs | 9 +-
src/librustc/hir/map/mod.rs | 4 +-
src/librustc/hir/mod.rs | 56 +-
src/librustc/hir/pat_util.rs | 11 +-
src/librustc/hir/print.rs | 14 +-
src/librustc/infer/combine.rs | 5 +-
src/librustc/infer/error_reporting.rs | 138 +-
src/librustc/infer/freshen.rs | 5 +-
src/librustc/infer/higher_ranked/mod.rs | 15 +-
src/librustc/infer/mod.rs | 96 +-
src/librustc/infer/type_variable.rs | 5 +-
src/librustc/lib.rs | 15 +-
src/librustc/lint/builtin.rs | 37 +-
src/librustc/lint/context.rs | 135 +-
src/librustc/lint/mod.rs | 3 +-
src/librustc/middle/cstore.rs | 48 +-
src/librustc/middle/dead.rs | 17 +-
src/librustc/middle/dependency_format.rs | 11 +-
src/librustc/middle/effect.rs | 10 +-
src/librustc/middle/expr_use_visitor.rs | 68 +-
src/librustc/middle/intrinsicck.rs | 2 +-
src/librustc/middle/lang_items.rs | 2 +-
src/librustc/middle/liveness.rs | 20 +-
src/librustc/middle/mem_categorization.rs | 52 +-
src/librustc/middle/reachable.rs | 4 +-
src/librustc/middle/region.rs | 41 +-
src/librustc/middle/stability.rs | 25 +-
src/librustc/middle/weak_lang_items.rs | 7 +-
src/librustc/mir/cache.rs | 2 +-
src/librustc/mir/mir_map.rs | 38 -
src/librustc/mir/{repr.rs => mod.rs} | 324 ++---
src/librustc/mir/tcx.rs | 39 +-
src/librustc/mir/transform.rs | 21 +-
src/librustc/mir/traversal.rs | 2 +-
src/librustc/mir/visit.rs | 81 +-
src/librustc/session/config.rs | 70 +-
src/librustc/session/filesearch.rs | 82 +-
src/librustc/session/mod.rs | 96 +-
src/librustc/traits/coherence.rs | 14 +-
src/librustc/traits/error_reporting.rs | 76 +-
src/librustc/traits/fulfill.rs | 6 +-
src/librustc/traits/mod.rs | 11 +-
src/librustc/traits/project.rs | 27 +-
src/librustc/traits/select.rs | 23 +-
src/librustc/traits/specialize/mod.rs | 48 +-
src/librustc/traits/structural_impls.rs | 27 +-
src/librustc/traits/util.rs | 85 +-
src/librustc/ty/adjustment.rs | 289 ++--
src/librustc/ty/context.rs | 263 +++-
src/librustc/ty/error.rs | 27 -
src/librustc/ty/fast_reject.rs | 4 +-
src/librustc/ty/flags.rs | 22 +-
src/librustc/ty/fold.rs | 30 +-
src/librustc/ty/layout.rs | 91 +-
src/librustc/ty/maps.rs | 4 +
src/librustc/ty/mod.rs | 172 +--
src/librustc/ty/outlives.rs | 22 +-
src/librustc/ty/relate.rs | 18 +-
src/librustc/ty/structural_impls.rs | 38 +-
src/librustc/ty/sty.rs | 31 +-
src/librustc/ty/subst.rs | 140 +-
src/librustc/ty/util.rs | 62 +-
src/librustc/ty/walk.rs | 2 +-
src/librustc/ty/wf.rs | 15 +-
src/librustc/util/common.rs | 34 +
src/librustc/util/ppaux.rs | 37 +-
src/librustc_back/lib.rs | 32 +-
src/librustc_back/sha2.rs | 679 ----------
src/librustc_back/target/aarch64_apple_ios.rs | 3 +-
.../target/aarch64_linux_android.rs | 9 +-
.../target/aarch64_unknown_fuchsia.rs | 31 +
.../target/aarch64_unknown_linux_gnu.rs | 13 +-
src/librustc_back/target/arm_base.rs | 16 +
.../target/arm_linux_androideabi.rs | 9 +-
.../target/arm_unknown_linux_gnueabi.rs | 3 +-
.../target/arm_unknown_linux_gnueabihf.rs | 3 +-
.../target/arm_unknown_linux_musleabi.rs | 9 +-
.../target/arm_unknown_linux_musleabihf.rs | 9 +-
src/librustc_back/target/armv7_apple_ios.rs | 3 +-
.../target/armv7_linux_androideabi.rs | 9 +-
.../target/armv7_unknown_linux_gnueabihf.rs | 5 +-
.../target/armv7_unknown_linux_musleabihf.rs | 9 +-
src/librustc_back/target/armv7s_apple_ios.rs | 3 +-
.../target/asmjs_unknown_emscripten.rs | 3 +-
src/librustc_back/target/dragonfly_base.rs | 4 +-
src/librustc_back/target/freebsd_base.rs | 4 +-
src/librustc_back/target/fuchsia_base.rs | 39 +
src/librustc_back/target/i386_apple_ios.rs | 2 +-
src/librustc_back/target/i686_apple_darwin.rs | 2 +-
.../target/i686_linux_android.rs | 2 +-
.../target/i686_pc_windows_gnu.rs | 2 +-
.../target/i686_pc_windows_msvc.rs | 2 +-
.../target/i686_unknown_dragonfly.rs | 2 +-
.../target/i686_unknown_freebsd.rs | 2 +-
.../target/i686_unknown_haiku.rs | 2 +-
.../target/i686_unknown_linux_gnu.rs | 2 +-
.../target/i686_unknown_linux_musl.rs | 2 +-
src/librustc_back/target/le32_unknown_nacl.rs | 8 +-
.../target/mips64_unknown_linux_gnuabi64.rs | 6 +-
.../target/mips64el_unknown_linux_gnuabi64.rs | 6 +-
.../target/mips_unknown_linux_gnu.rs | 6 +-
.../target/mips_unknown_linux_musl.rs | 6 +-
.../target/mips_unknown_linux_uclibc.rs | 6 +-
.../target/mipsel_unknown_linux_gnu.rs | 6 +-
.../target/mipsel_unknown_linux_musl.rs | 6 +-
.../target/mipsel_unknown_linux_uclibc.rs | 6 +-
src/librustc_back/target/mod.rs | 96 +-
src/librustc_back/target/netbsd_base.rs | 4 +-
src/librustc_back/target/openbsd_base.rs | 4 +-
.../target/powerpc64_unknown_linux_gnu.rs | 5 +-
.../target/powerpc64le_unknown_linux_gnu.rs | 5 +-
.../target/powerpc_unknown_linux_gnu.rs | 5 +-
.../target/s390x_unknown_linux_gnu.rs | 2 +-
src/librustc_back/target/thumb_base.rs | 58 +
.../target/thumbv6m_none_eabi.rs | 36 +
.../target/thumbv7em_none_eabi.rs | 40 +
.../target/thumbv7em_none_eabihf.rs | 49 +
.../target/thumbv7m_none_eabi.rs | 31 +
.../target/wasm32_unknown_emscripten.rs | 42 +
src/librustc_back/target/windows_base.rs | 20 +-
.../target/x86_64_apple_darwin.rs | 2 +-
src/librustc_back/target/x86_64_apple_ios.rs | 2 +-
.../target/x86_64_pc_windows_gnu.rs | 2 +-
.../target/x86_64_pc_windows_msvc.rs | 2 +-
.../target/x86_64_rumprun_netbsd.rs | 2 +-
.../target/x86_64_sun_solaris.rs | 2 +-
.../target/x86_64_unknown_bitrig.rs | 2 +-
.../target/x86_64_unknown_dragonfly.rs | 2 +-
.../target/x86_64_unknown_freebsd.rs | 2 +-
.../target/x86_64_unknown_fuchsia.rs | 30 +
.../target/x86_64_unknown_haiku.rs | 2 +-
.../target/x86_64_unknown_linux_gnu.rs | 2 +-
.../target/x86_64_unknown_linux_musl.rs | 2 +-
.../target/x86_64_unknown_netbsd.rs | 2 +-
.../target/x86_64_unknown_openbsd.rs | 2 +-
src/librustc_borrowck/borrowck/check_loans.rs | 112 +-
.../borrowck/gather_loans/gather_moves.rs | 2 +-
.../borrowck/gather_loans/move_error.rs | 2 +-
.../borrowck/mir/abs_domain.rs | 6 +-
.../borrowck/mir/dataflow/graphviz.rs | 6 +-
.../borrowck/mir/dataflow/impls.rs | 59 +-
.../borrowck/mir/dataflow/mod.rs | 57 +-
.../borrowck/mir/dataflow/sanity_check.rs | 44 +-
.../borrowck/mir/elaborate_drops.rs | 18 +-
.../borrowck/mir/gather_moves.rs | 42 +-
src/librustc_borrowck/borrowck/mir/mod.rs | 49 +-
src/librustc_borrowck/borrowck/mir/patch.rs | 24 +-
src/librustc_borrowck/borrowck/mod.rs | 62 +-
src/librustc_borrowck/borrowck/move_data.rs | 2 +-
src/librustc_borrowck/lib.rs | 4 +-
src/librustc_const_eval/Cargo.toml | 2 +
src/librustc_const_eval/_match.rs | 767 +++++++++++
src/librustc_const_eval/check_match.rs | 1145 ++++------------
src/librustc_const_eval/diagnostics.rs | 16 +-
src/librustc_const_eval/eval.rs | 66 +-
src/librustc_const_eval/lib.rs | 6 +-
src/librustc_const_eval/pattern.rs | 614 +++++++++
.../accumulate_vec.rs | 52 +
src/librustc_data_structures/array_vec.rs | 106 ++
.../bitslice.rs | 3 +-
src/librustc_data_structures/blake2b.rs | 338 +++++
.../control_flow_graph/dominators/mod.rs | 28 +-
.../control_flow_graph/dominators/test.rs | 22 +-
.../control_flow_graph/iterate/test.rs | 20 +-
.../control_flow_graph/mod.rs | 6 +-
.../control_flow_graph/reachable/mod.rs | 9 +-
.../control_flow_graph/reachable/test.rs | 22 +-
.../control_flow_graph/reference.rs | 8 +-
.../control_flow_graph/test.rs | 11 +-
.../control_flow_graph/transpose.rs | 11 +-
src/librustc_data_structures/fmt_wrap.rs | 31 +
src/librustc_data_structures/graph/mod.rs | 4 +-
.../indexed_set.rs | 5 +-
src/librustc_data_structures/indexed_vec.rs | 15 +
src/librustc_data_structures/lib.rs | 9 +
.../obligation_forest/mod.rs | 82 +-
.../snapshot_map/mod.rs | 74 +-
src/librustc_data_structures/unify/mod.rs | 14 +-
src/librustc_driver/Cargo.toml | 9 +-
src/librustc_driver/driver.rs | 204 +--
src/librustc_driver/lib.rs | 98 +-
src/librustc_driver/pretty.rs | 319 +++--
src/librustc_driver/target_features.rs | 25 +-
src/librustc_driver/test.rs | 98 +-
src/librustc_errors/Cargo.toml | 2 +-
src/librustc_errors/diagnostic.rs | 202 +++
src/librustc_errors/diagnostic_builder.rs | 196 +++
src/librustc_errors/emitter.rs | 180 ++-
src/librustc_errors/lib.rs | 349 +----
src/librustc_errors/lock.rs | 15 +-
src/librustc_errors/registry.rs | 2 +-
src/librustc_errors/snippet.rs | 6 +-
src/librustc_errors/styled_buffer.rs | 7 +-
.../calculate_svh/hasher.rs | 88 ++
src/librustc_incremental/calculate_svh/mod.rs | 37 +-
.../calculate_svh/svh_visitor.rs | 362 ++++-
src/librustc_incremental/ich/fingerprint.rs | 81 ++
src/librustc_incremental/ich/mod.rs | 13 +
src/librustc_incremental/lib.rs | 3 +-
src/librustc_incremental/persist/data.rs | 5 +-
src/librustc_incremental/persist/directory.rs | 28 +-
.../persist/dirty_clean.rs | 11 +-
src/librustc_incremental/persist/fs.rs | 17 +-
src/librustc_incremental/persist/hash.rs | 20 +-
src/librustc_incremental/persist/load.rs | 5 +-
src/librustc_incremental/persist/preds.rs | 3 +-
src/librustc_incremental/persist/save.rs | 11 +-
src/librustc_lint/bad_style.rs | 167 ++-
src/librustc_lint/builtin.rs | 379 ++++--
src/librustc_lint/lib.rs | 85 +-
src/librustc_lint/types.rs | 486 +++----
src/librustc_lint/unused.rs | 107 +-
src/librustc_llvm/build.rs | 53 +-
src/librustc_llvm/diagnostic.rs | 11 +-
src/librustc_llvm/ffi.rs | 685 ++++------
src/librustc_llvm/lib.rs | 100 +-
src/librustc_macro/lib.rs | 169 ---
src/librustc_metadata/Cargo.toml | 2 +-
src/librustc_metadata/astencode.rs | 35 +-
src/librustc_metadata/creader.rs | 343 +++--
src/librustc_metadata/cstore.rs | 105 +-
.../{csearch.rs => cstore_impl.rs} | 44 +-
src/librustc_metadata/decoder.rs | 556 ++++----
src/librustc_metadata/diagnostics.rs | 179 ---
src/librustc_metadata/encoder.rs | 369 +++---
src/librustc_metadata/index.rs | 16 +-
src/librustc_metadata/index_builder.rs | 10 +-
src/librustc_metadata/lib.rs | 25 +-
.../{loader.rs => locator.rs} | 309 +++--
src/librustc_metadata/macro_import.rs | 219 ---
src/librustc_metadata/schema.rs | 78 +-
src/librustc_mir/build/block.rs | 2 +-
src/librustc_mir/build/cfg.rs | 2 +-
src/librustc_mir/build/expr/as_constant.rs | 2 +-
src/librustc_mir/build/expr/as_lvalue.rs | 6 +-
src/librustc_mir/build/expr/as_operand.rs | 2 +-
src/librustc_mir/build/expr/as_rvalue.rs | 6 +-
src/librustc_mir/build/expr/as_temp.rs | 2 +-
src/librustc_mir/build/expr/into.rs | 2 +-
src/librustc_mir/build/expr/stmt.rs | 10 +-
src/librustc_mir/build/into.rs | 2 +-
src/librustc_mir/build/matches/mod.rs | 20 +-
src/librustc_mir/build/matches/simplify.rs | 2 +-
src/librustc_mir/build/matches/test.rs | 6 +-
src/librustc_mir/build/matches/util.rs | 2 +-
src/librustc_mir/build/misc.rs | 8 +-
src/librustc_mir/build/mod.rs | 127 +-
src/librustc_mir/build/scope.rs | 37 +-
src/librustc_mir/def_use.rs | 62 +-
src/librustc_mir/graphviz.rs | 31 +-
src/librustc_mir/hair/cx/block.rs | 4 +-
src/librustc_mir/hair/cx/expr.rs | 154 +--
src/librustc_mir/hair/cx/mod.rs | 7 +-
src/librustc_mir/hair/cx/pattern.rs | 328 -----
src/librustc_mir/hair/mod.rs | 80 +-
src/librustc_mir/lib.rs | 2 +-
src/librustc_mir/mir_map.rs | 47 +-
src/librustc_mir/pretty.rs | 61 +-
src/librustc_mir/transform/add_call_guards.rs | 2 +-
src/librustc_mir/transform/copy_prop.rs | 69 +-
src/librustc_mir/transform/deaggregator.rs | 8 +-
src/librustc_mir/transform/dump_mir.rs | 2 +-
src/librustc_mir/transform/erase_regions.rs | 2 +-
src/librustc_mir/transform/instcombine.rs | 7 +-
src/librustc_mir/transform/mod.rs | 2 +-
src/librustc_mir/transform/no_landing_pads.rs | 2 +-
src/librustc_mir/transform/promote_consts.rs | 83 +-
src/librustc_mir/transform/qualify_consts.rs | 281 ++--
.../{simplify_cfg.rs => simplify.rs} | 136 +-
.../transform/simplify_branches.rs | 2 +-
src/librustc_mir/transform/type_check.rs | 27 +-
src/librustc_passes/ast_validation.rs | 10 +-
src/librustc_passes/consts.rs | 63 +-
src/librustc_passes/hir_stats.rs | 374 ++++++
src/librustc_passes/lib.rs | 3 +-
src/librustc_passes/static_recursion.rs | 6 +-
src/librustc_plugin/load.rs | 14 +-
src/librustc_plugin/registry.rs | 10 +-
src/librustc_privacy/lib.rs | 52 +-
src/librustc_resolve/build_reduced_graph.rs | 466 +++++--
src/librustc_resolve/check_unused.rs | 10 +-
src/librustc_resolve/diagnostics.rs | 247 +++-
src/librustc_resolve/lib.rs | 293 ++--
src/librustc_resolve/macros.rs | 361 ++---
src/librustc_resolve/resolve_imports.rs | 23 +-
src/librustc_save_analysis/dump_visitor.rs | 79 +-
src/librustc_save_analysis/json_dumper.rs | 8 +-
src/librustc_save_analysis/lib.rs | 22 +-
src/librustc_save_analysis/span_utils.rs | 14 +-
src/librustc_trans/abi.rs | 73 +-
src/librustc_trans/adt.rs | 61 +-
src/librustc_trans/asm.rs | 2 +-
src/librustc_trans/assert_module_sources.rs | 2 +-
src/librustc_trans/back/link.rs | 22 +-
src/librustc_trans/back/linker.rs | 33 +-
src/librustc_trans/back/rpath.rs | 2 +-
src/librustc_trans/back/symbol_names.rs | 30 +-
src/librustc_trans/back/write.rs | 2 +-
src/librustc_trans/base.rs | 263 ++--
src/librustc_trans/cabi_aarch64.rs | 70 +-
src/librustc_trans/cabi_arm.rs | 31 +-
src/librustc_trans/cabi_mips.rs | 68 +-
src/librustc_trans/cabi_mips64.rs | 68 +-
src/librustc_trans/cabi_powerpc.rs | 61 +-
src/librustc_trans/cabi_powerpc64.rs | 63 +-
src/librustc_trans/cabi_s390x.rs | 6 +-
src/librustc_trans/cabi_x86_64.rs | 59 +-
src/librustc_trans/callee.rs | 9 +-
src/librustc_trans/cleanup.rs | 8 +-
src/librustc_trans/collector.rs | 32 +-
src/librustc_trans/common.rs | 28 +-
src/librustc_trans/consts.rs | 6 +-
src/librustc_trans/context.rs | 72 +-
.../debuginfo/create_scope_map.rs | 9 +-
src/librustc_trans/debuginfo/metadata.rs | 262 +---
src/librustc_trans/debuginfo/mod.rs | 4 +-
src/librustc_trans/glue.rs | 17 +-
src/librustc_trans/lib.rs | 4 +-
src/librustc_trans/meth.rs | 5 +-
src/librustc_trans/mir/analyze.rs | 28 +-
src/librustc_trans/mir/block.rs | 22 +-
src/librustc_trans/mir/constant.rs | 31 +-
src/librustc_trans/mir/lvalue.rs | 25 +-
src/librustc_trans/mir/mod.rs | 141 +-
src/librustc_trans/mir/operand.rs | 26 +-
src/librustc_trans/mir/rvalue.rs | 122 +-
src/librustc_trans/mir/statement.rs | 6 +-
src/librustc_trans/trans_item.rs | 27 +-
src/librustc_typeck/astconv.rs | 130 +-
src/librustc_typeck/check/_match.rs | 123 +-
src/librustc_typeck/check/assoc.rs | 6 +-
src/librustc_typeck/check/autoderef.rs | 110 +-
src/librustc_typeck/check/callee.rs | 176 +--
src/librustc_typeck/check/cast.rs | 214 +--
src/librustc_typeck/check/closure.rs | 123 +-
src/librustc_typeck/check/coercion.rs | 289 ++--
src/librustc_typeck/check/compare_method.rs | 877 +++++++-----
src/librustc_typeck/check/dropck.rs | 203 ++-
src/librustc_typeck/check/intrinsic.rs | 122 +-
src/librustc_typeck/check/method/confirm.rs | 358 ++---
src/librustc_typeck/check/method/mod.rs | 138 +-
src/librustc_typeck/check/method/probe.rs | 465 ++++---
src/librustc_typeck/check/method/suggest.rs | 247 ++--
src/librustc_typeck/check/mod.rs | 429 +++---
src/librustc_typeck/check/regionck.rs | 55 +-
src/librustc_typeck/check/wfcheck.rs | 8 +-
src/librustc_typeck/check/writeback.rs | 40 +-
src/librustc_typeck/check_unused.rs | 11 +-
src/librustc_typeck/coherence/mod.rs | 208 +--
src/librustc_typeck/coherence/orphan.rs | 109 +-
src/librustc_typeck/coherence/overlap.rs | 80 +-
src/librustc_typeck/coherence/unsafety.rs | 71 +-
src/librustc_typeck/collect.rs | 46 +-
src/librustc_typeck/diagnostics.rs | 148 ++-
src/librustc_typeck/lib.rs | 43 +-
src/librustc_typeck/variance/README.md | 22 +-
src/librustc_unicode/char.rs | 92 +-
src/librustc_unicode/u_str.rs | 13 +-
src/librustdoc/clean/inline.rs | 59 +-
src/librustdoc/clean/mod.rs | 157 +--
src/librustdoc/clean/simplify.rs | 2 +-
src/librustdoc/core.rs | 15 +-
src/librustdoc/externalfiles.rs | 85 +-
src/librustdoc/fold.rs | 4 +-
src/librustdoc/html/format.rs | 426 ++++--
src/librustdoc/html/highlight.rs | 13 +-
src/librustdoc/html/item_type.rs | 20 +-
src/librustdoc/html/layout.rs | 9 -
src/librustdoc/html/markdown.rs | 45 +-
src/librustdoc/html/render.rs | 124 +-
src/librustdoc/html/static/playpen.js | 43 -
src/librustdoc/html/static/rustdoc.css | 6 +-
src/librustdoc/html/toc.rs | 4 +-
src/librustdoc/lib.rs | 13 +-
src/librustdoc/markdown.rs | 24 +-
src/librustdoc/passes/mod.rs | 2 +-
src/librustdoc/test.rs | 58 +-
src/librustdoc/visit_ast.rs | 2 +-
src/librustdoc/visit_lib.rs | 7 +-
src/libserialize/json.rs | 17 +-
src/libserialize/leb128.rs | 2 +
src/libserialize/opaque.rs | 21 +-
src/libserialize/serialize.rs | 5 +-
src/libstd/build.rs | 4 +-
src/libstd/collections/hash/bench.rs | 6 +-
src/libstd/collections/hash/map.rs | 703 ++++++----
src/libstd/collections/hash/set.rs | 282 ++--
src/libstd/collections/hash/table.rs | 242 ++--
src/libstd/collections/mod.rs | 123 +-
src/libstd/env.rs | 194 +--
src/libstd/error.rs | 22 +-
src/libstd/{num => }/f32.rs | 0
src/libstd/{num => }/f64.rs | 0
src/libstd/ffi/c_str.rs | 4 +-
src/libstd/ffi/os_str.rs | 11 -
src/libstd/fs.rs | 129 +-
src/libstd/io/buffered.rs | 21 +-
src/libstd/io/cursor.rs | 55 +-
src/libstd/io/error.rs | 78 +-
src/libstd/io/impls.rs | 11 +
src/libstd/io/mod.rs | 191 +--
src/libstd/io/stdio.rs | 26 +-
src/libstd/lib.rs | 152 ++-
src/libstd/macros.rs | 28 +-
src/libstd/memchr.rs | 275 +---
src/libstd/net/addr.rs | 37 +-
src/libstd/net/ip.rs | 37 +-
src/libstd/net/mod.rs | 3 +-
src/libstd/net/parser.rs | 2 +-
src/libstd/net/tcp.rs | 2 +-
src/libstd/net/test.rs | 2 +
src/libstd/net/udp.rs | 2 +-
src/libstd/{num/mod.rs => num.rs} | 0
src/libstd/os/fuchsia/fs.rs | 103 ++
src/libstd/os/fuchsia/mod.rs | 16 +
src/libstd/os/fuchsia/raw.rs | 270 ++++
src/libstd/os/linux/raw.rs | 3 +-
src/libstd/os/mod.rs | 1 +
src/libstd/os/raw.rs | 6 +-
src/libstd/panic.rs | 46 +-
src/libstd/path.rs | 153 +--
src/libstd/primitive_docs.rs | 2 +-
src/libstd/process.rs | 22 +-
src/libstd/rand/mod.rs | 3 +-
src/libstd/rt.rs | 2 +-
src/libstd/sync/barrier.rs | 1 +
src/libstd/sync/condvar.rs | 4 +
src/libstd/sync/mpsc/mod.rs | 11 +-
src/libstd/sync/mpsc/mpsc_queue.rs | 2 +-
src/libstd/sync/mpsc/oneshot.rs | 2 +
src/libstd/sync/mpsc/select.rs | 4 +-
src/libstd/sync/mpsc/spsc_queue.rs | 2 +-
src/libstd/sync/mutex.rs | 2 +-
src/libstd/sync/once.rs | 16 +-
src/libstd/sync/rwlock.rs | 10 +-
src/libstd/sys/common/args.rs | 100 --
src/libstd/sys/mod.rs | 41 +
src/libstd/sys/unix/android.rs | 63 +-
src/libstd/sys/unix/args.rs | 212 +++
src/libstd/sys/unix/env.rs | 184 +++
src/libstd/sys/unix/ext/fs.rs | 45 +
src/libstd/sys/unix/ext/mod.rs | 2 +
src/libstd/sys/unix/ext/net.rs | 15 +-
src/libstd/sys/unix/ext/process.rs | 6 +-
src/libstd/sys/unix/fast_thread_local.rs | 167 +++
src/libstd/sys/unix/fd.rs | 54 +-
src/libstd/sys/unix/fs.rs | 24 +-
src/libstd/sys/unix/memchr.rs | 57 +
src/libstd/sys/unix/mod.rs | 23 +-
src/libstd/sys/unix/net.rs | 14 +-
src/libstd/sys/unix/os.rs | 143 +-
src/libstd/sys/unix/path.rs | 29 +
src/libstd/sys/unix/process.rs | 4 +-
src/libstd/sys/unix/rand.rs | 72 +-
src/libstd/sys/unix/stdio.rs | 3 +
src/libstd/sys/unix/thread.rs | 49 +-
src/libstd/sys/windows/args.rs | 76 ++
src/libstd/sys/windows/env.rs | 19 +
src/libstd/sys/windows/ext/fs.rs | 51 +-
src/libstd/sys/windows/ext/mod.rs | 2 +
src/libstd/sys/windows/ext/process.rs | 10 +-
src/libstd/sys/windows/fs.rs | 16 +
src/libstd/sys/windows/handle.rs | 30 +
src/libstd/sys/windows/memchr.rs | 15 +
src/libstd/sys/windows/mod.rs | 24 +-
src/libstd/sys/windows/os.rs | 56 -
src/libstd/sys/windows/path.rs | 108 ++
src/libstd/sys/windows/stdio.rs | 7 +
.../{sys/common => sys_common}/at_exit_imp.rs | 0
.../{sys/common => sys_common}/backtrace.rs | 0
.../{sys/common => sys_common}/condvar.rs | 0
.../common => sys_common}/gnu/libbacktrace.rs | 0
.../{sys/common => sys_common}/gnu/mod.rs | 0
src/libstd/{sys/common => sys_common}/io.rs | 4 +
src/libstd/sys_common/memchr.rs | 230 ++++
src/libstd/{sys/common => sys_common}/mod.rs | 34 +-
.../{sys/common => sys_common}/mutex.rs | 0
src/libstd/{sys/common => sys_common}/net.rs | 19 +-
.../{sys/common => sys_common}/poison.rs | 0
.../{sys/common => sys_common}/remutex.rs | 2 +-
.../{sys/common => sys_common}/rwlock.rs | 0
.../{sys/common => sys_common}/thread.rs | 0
.../{sys/common => sys_common}/thread_info.rs | 0
.../common => sys_common}/thread_local.rs | 0
src/libstd/{sys/common => sys_common}/util.rs | 28 +-
src/libstd/{sys/common => sys_common}/wtf8.rs | 21 +-
src/libstd/thread/local.rs | 153 +--
src/libstd/thread/mod.rs | 74 +-
src/libstd/time/mod.rs | 2 +-
src/libsyntax/abi.rs | 50 +-
src/libsyntax/ast.rs | 26 +-
src/libsyntax/attr.rs | 13 +-
src/libsyntax/codemap.rs | 6 +-
src/libsyntax/config.rs | 24 +-
src/libsyntax/diagnostics/plugin.rs | 2 +-
src/libsyntax/ext/base.rs | 71 +-
src/libsyntax/ext/build.rs | 48 +-
src/libsyntax/ext/expand.rs | 142 +-
src/libsyntax/ext/hygiene.rs | 5 +
src/libsyntax/ext/placeholders.rs | 3 +-
src/libsyntax/ext/quote.rs | 124 +-
src/libsyntax/ext/source_util.rs | 11 +-
src/libsyntax/ext/tt/macro_parser.rs | 92 +-
src/libsyntax/ext/tt/macro_rules.rs | 64 +-
src/libsyntax/ext/tt/transcribe.rs | 94 +-
src/libsyntax/feature_gate.rs | 256 +++-
src/libsyntax/fold.rs | 113 +-
src/libsyntax/json.rs | 16 +-
src/libsyntax/lib.rs | 2 +
src/libsyntax/parse/attr.rs | 17 +-
src/libsyntax/parse/lexer/comments.rs | 84 +-
src/libsyntax/parse/lexer/mod.rs | 415 +++---
src/libsyntax/parse/lexer/unicode_chars.rs | 2 +-
src/libsyntax/parse/mod.rs | 178 +--
src/libsyntax/parse/parser.rs | 955 ++++++-------
src/libsyntax/parse/token.rs | 78 +-
src/libsyntax/print/pp.rs | 69 +-
src/libsyntax/print/pprust.rs | 67 +-
src/libsyntax/std_inject.rs | 22 +-
src/libsyntax/test.rs | 85 +-
src/libsyntax/tokenstream.rs | 22 +-
src/libsyntax/util/interner.rs | 40 +-
src/libsyntax/util/parser_testing.rs | 5 +-
src/libsyntax/util/small_vector.rs | 56 +-
src/libsyntax/visit.rs | 8 +-
src/libsyntax_ext/Cargo.toml | 2 +-
src/libsyntax_ext/asm.rs | 18 +-
src/libsyntax_ext/cfg.rs | 2 +-
src/libsyntax_ext/deriving/cmp/partial_eq.rs | 4 +-
src/libsyntax_ext/deriving/cmp/partial_ord.rs | 4 +-
src/libsyntax_ext/deriving/custom.rs | 2 +-
src/libsyntax_ext/deriving/decodable.rs | 4 +-
src/libsyntax_ext/deriving/encodable.rs | 14 +-
src/libsyntax_ext/deriving/generic/mod.rs | 10 +-
src/libsyntax_ext/deriving/generic/ty.rs | 7 +-
src/libsyntax_ext/deriving/mod.rs | 268 ++--
src/libsyntax_ext/format.rs | 2 +-
src/libsyntax_ext/lib.rs | 32 +-
...o_registrar.rs => proc_macro_registrar.rs} | 73 +-
src/libsyntax_pos/lib.rs | 2 +-
src/libtest/lib.rs | 158 ++-
src/libunwind/build.rs | 2 +
src/libunwind/libunwind.rs | 4 +-
src/rtstartup/rsbegin.rs | 6 +-
src/rustc/Cargo.lock | 413 ------
src/rustc/std_shim/Cargo.lock | 132 --
src/rustc/test_shim/Cargo.lock | 23 -
src/rustllvm/RustWrapper.cpp | 21 +-
src/rustllvm/llvm-auto-clean-trigger | 2 +-
src/stage0.txt | 4 +-
.../item-collection/overloaded-operators.rs | 8 +-
src/test/codegen/abi-sysv64.rs | 3 +
src/test/codegen/consts.rs | 6 +-
src/test/codegen/enum-bounds-check.rs | 24 +
src/test/codegen/issue-32364.rs | 3 +
src/test/codegen/lifetime_start_end.rs | 8 +-
src/test/codegen/zip.rs | 9 +
.../auxiliary/macro_crate_test.rs | 4 +-
.../derive-no-std-not-supported.rs | 1 -
.../dropck_tarena_cycle_checked.rs | 4 +-
.../dropck_tarena_unsound_drop.rs | 5 +-
src/test/compile-fail-fulldeps/issue-18986.rs | 2 +-
.../macro-crate-doesnt-resolve.rs | 3 +-
...nown-crate.rs => no-link-unknown-crate.rs} | 2 +-
.../at-the-root.rs | 12 +-
.../proc-macro/attribute.rs | 46 +
.../auxiliary/derive-a.rs | 12 +-
.../auxiliary/derive-bad.rs | 12 +-
.../auxiliary/derive-panic.rs | 12 +-
.../auxiliary/derive-unstable-2.rs | 12 +-
.../auxiliary/derive-unstable.rs | 12 +-
.../cannot-link.rs | 2 +-
.../{rustc-macro => proc-macro}/define-two.rs | 12 +-
.../{rustc-macro => proc-macro}/derive-bad.rs | 2 +-
.../derive-still-gated.rs | 2 +-
.../expand-to-unstable-2.rs | 2 +-
.../expand-to-unstable.rs | 2 +-
.../export-macro.rs | 6 +-
.../{rustc-macro => proc-macro}/exports.rs | 2 +-
.../feature-gate-1.rs | 4 +-
.../feature-gate-2.rs | 2 +-
.../feature-gate-3.rs | 4 +-
.../feature-gate-4.rs | 0
.../feature-gate-5.rs | 2 +-
.../illegal-proc-macro-derive-use.rs | 27 +
.../{rustc-macro => proc-macro}/import.rs | 2 +-
.../{rustc-macro => proc-macro}/load-panic.rs | 2 +-
.../shadow-builtin.rs | 10 +-
.../{rustc-macro => proc-macro}/shadow.rs | 5 +-
.../{rustc-macro => proc-macro}/signature.rs | 10 +-
.../two-crate-types-1.rs | 4 +-
.../two-crate-types-2.rs | 4 +-
src/test/compile-fail-fulldeps/qquote.rs | 2 +-
.../rustc-macro/attribute.rs | 46 -
.../compile-fail/{E0002.rs => E0004-2.rs} | 2 +-
src/test/compile-fail/E0007.rs | 1 +
src/test/compile-fail/E0025.rs | 5 +-
src/test/compile-fail/E0035.rs | 1 +
src/test/compile-fail/E0036.rs | 1 +
src/test/compile-fail/E0050.rs | 9 +-
src/test/compile-fail/E0071.rs | 9 +-
src/test/compile-fail/E0164.rs | 8 +-
src/test/compile-fail/E0198.rs | 18 +
src/test/compile-fail/E0199.rs | 3 +-
src/test/compile-fail/E0220.rs | 5 +-
src/test/compile-fail/E0221.rs | 18 +-
src/test/compile-fail/E0243.rs | 2 +-
src/test/compile-fail/E0277.rs | 2 +-
src/test/compile-fail/E0297.rs | 2 +-
src/test/compile-fail/E0303.rs | 8 +-
src/test/compile-fail/E0408.rs | 4 +-
.../compile-fail/allocator-dylib-is-system.rs | 2 +
.../allocator-rust-dylib-is-jemalloc.rs | 2 +
src/test/compile-fail/associated-path-shl.rs | 20 +
...pe-projection-from-multiple-supertraits.rs | 14 +-
...ed-types-ICE-when-projecting-out-of-err.rs | 2 +-
.../attempted-access-non-fatal.rs | 4 +-
.../attr-on-generic-formals-are-visited.rs | 75 ++
...attr-on-generic-formals-wo-feature-gate.rs | 76 ++
.../attrs-with-no-formal-in-generics-1.rs | 26 +
.../attrs-with-no-formal-in-generics-2.rs | 26 +
.../attrs-with-no-formal-in-generics-3.rs | 26 +
.../compile-fail/auto-ref-slice-plus-ref.rs | 2 +-
.../compile-fail/auxiliary/define_macro.rs | 16 +
.../auxiliary/import_crate_var.rs | 12 +
.../auxiliary/namespace-mix-new.rs | 78 ++
.../auxiliary/namespace-mix-old.rs | 85 ++
.../compile-fail/blind-item-block-middle.rs | 2 +-
.../borrowck/borrowck-assign-comp-idx.rs | 6 +-
.../borrowck-borrowed-uniq-rvalue-2.rs | 2 +-
.../borrowck/borrowck-loan-vec-content.rs | 4 +-
...rowck-move-out-of-overloaded-auto-deref.rs | 2 +-
.../borrowck/borrowck-move-out-of-vec-tail.rs | 4 +-
.../borrowck/borrowck-mut-slice-of-imm-vec.rs | 2 +-
...borrowck-overloaded-index-move-from-vec.rs | 2 +-
.../borrowck-use-uninitialized-in-cast.rs | 2 -
.../borrowck-vec-pattern-element-loan.rs | 6 +-
.../borrowck-vec-pattern-loan-from-mut.rs | 2 +-
.../borrowck/borrowck-vec-pattern-nesting.rs | 8 +-
.../borrowck-vec-pattern-tail-element-loan.rs | 2 +-
src/test/compile-fail/cast-rfc0401.rs | 6 +-
src/test/compile-fail/coherence-cow.rs | 2 -
.../compile-fail/coherence-vec-local-2.rs | 2 -
src/test/compile-fail/coherence-vec-local.rs | 2 -
.../compile-fail/const-eval-overflow-2.rs | 4 -
.../const-pattern-not-const-evaluable.rs | 4 +-
src/test/compile-fail/const-unsized.rs | 8 +-
src/test/compile-fail/dep-graph-type-alias.rs | 56 +
.../derived-errors/issue-30580.rs | 2 +-
.../deriving-meta-unknown-trait.rs | 4 +-
src/test/compile-fail/discrim-overflow-2.rs | 32 +-
src/test/compile-fail/discrim-overflow.rs | 32 +-
.../drop-with-active-borrows-2.rs | 2 +-
src/test/compile-fail/empty-comment.rs | 6 +-
.../compile-fail/empty-struct-braces-pat-1.rs | 4 +-
.../compile-fail/empty-struct-braces-pat-2.rs | 8 +-
.../compile-fail/empty-struct-braces-pat-3.rs | 12 +-
.../compile-fail/empty-struct-tuple-pat.rs | 10 +-
.../compile-fail/empty-struct-unit-pat-1.rs | 51 -
.../compile-fail/empty-struct-unit-pat-2.rs | 47 -
.../compile-fail/empty-struct-unit-pat.rs | 61 +
src/test/compile-fail/enum-in-scope.rs | 2 +-
.../compile-fail/enums-are-namespaced-xc.rs | 3 +-
.../compile-fail/enums-pats-not-idents.rs | 2 +-
.../compile-fail/extern-crate-visibility.rs | 11 +-
...s => feature-gate-field-init-shorthand.rs} | 17 +-
.../compile-fail/feature-gate-may-dangle.rs | 20 +
.../compile-fail/feature-gate-no-debug-2.rs | 15 +
.../compile-fail/gated-non-ascii-idents.rs | 2 +-
.../generic-type-less-params-with-defaults.rs | 2 +-
.../compile-fail/if-without-else-result.rs | 2 +-
.../impl-trait/auto-trait-leak.rs | 8 +-
src/test/compile-fail/import-crate-var.rs | 21 +
src/test/compile-fail/inherent-overlap.rs | 12 +-
src/test/compile-fail/integral-indexing.rs | 2 +-
src/test/compile-fail/issue-10200.rs | 2 +-
src/test/compile-fail/issue-11004.rs | 4 +-
src/test/compile-fail/issue-11873.rs | 2 +-
src/test/compile-fail/issue-12612.rs | 2 +-
src/test/compile-fail/issue-12863.rs | 2 +-
src/test/compile-fail/issue-13352.rs | 2 -
src/test/compile-fail/issue-13446.rs | 2 +-
src/test/compile-fail/issue-14092.rs | 2 +-
src/test/compile-fail/issue-14721.rs | 3 +-
src/test/compile-fail/issue-14853.rs | 2 +-
src/test/compile-fail/issue-15260.rs | 25 +-
src/test/compile-fail/issue-16058.rs | 2 +-
src/test/compile-fail/issue-1697.rs | 2 +-
src/test/compile-fail/issue-17001.rs | 2 +-
src/test/compile-fail/issue-17025.rs | 2 +
src/test/compile-fail/issue-17405.rs | 2 +-
src/test/compile-fail/issue-17518.rs | 2 +-
src/test/compile-fail/issue-17933.rs | 2 +-
src/test/compile-fail/issue-18937.rs | 53 +
src/test/compile-fail/issue-19086.rs | 2 +-
src/test/compile-fail/issue-19244-2.rs | 2 +-
src/test/compile-fail/issue-19482.rs | 2 -
src/test/compile-fail/issue-21449.rs | 3 +-
src/test/compile-fail/issue-21837.rs | 20 +
src/test/compile-fail/issue-23253.rs | 2 +-
src/test/compile-fail/issue-24363.rs | 2 +-
src/test/compile-fail/issue-24365.rs | 6 +-
src/test/compile-fail/issue-26158.rs | 16 +
src/test/compile-fail/issue-26459.rs | 2 +-
src/test/compile-fail/issue-27033.rs | 2 +-
src/test/compile-fail/issue-27815.rs | 10 +-
src/test/compile-fail/issue-2848.rs | 4 +-
src/test/compile-fail/issue-28992-empty.rs | 5 +-
src/test/compile-fail/issue-3044.rs | 2 +-
src/test/compile-fail/issue-31011.rs | 2 +-
src/test/compile-fail/issue-32004.rs | 4 +-
src/test/compile-fail/issue-32086.rs | 4 +-
src/test/compile-fail/issue-32922.rs | 2 +-
src/test/compile-fail/issue-36116.rs | 23 +
.../compile-fail/{E0422.rs => issue-36881.rs} | 7 +-
src/test/compile-fail/issue-37026.rs | 18 +
src/test/compile-fail/issue-37534.rs | 16 +
src/test/compile-fail/issue-5067.rs | 2 +-
src/test/compile-fail/issue-5883.rs | 2 -
src/test/compile-fail/issue-5927.rs | 2 +-
src/test/compile-fail/issue-6804.rs | 23 +-
src/test/compile-fail/issue-7970a.rs | 6 +-
.../issue-pr29383.rs | 6 +-
.../keyword-self-as-identifier.rs | 4 +-
.../keyword-super-as-identifier.rs | 4 +-
.../keyword-super.rs | 4 +-
src/test/compile-fail/lexical-scopes.rs | 2 +-
src/test/compile-fail/lifetime-underscore.rs | 2 -
src/test/compile-fail/lint-group-style.rs | 2 +-
.../lint-non-uppercase-statics.rs | 5 +-
src/test/compile-fail/lint-qualification.rs | 7 +
.../compile-fail/lint-unused-extern-crate.rs | 2 +
src/test/compile-fail/lint-unused-imports.rs | 16 +-
.../compile-fail/lint-unused-mut-variables.rs | 4 +-
src/test/compile-fail/macro-shadowing.rs | 39 +
src/test/compile-fail/macro-use-scope.rs | 6 +-
.../compile-fail/match-byte-array-patterns.rs | 73 +
.../match-pattern-field-mismatch-2.rs | 2 +-
.../match-pattern-field-mismatch.rs | 2 +-
.../compile-fail/match-vec-unreachable.rs | 2 +-
.../meta-expected-error-correct-rev.rs | 1 -
.../meta-expected-error-wrong-rev.rs | 1 -
.../compile-fail/method-path-in-pattern.rs | 6 +-
.../method-resolvable-path-in-pattern.rs | 2 +-
.../moves-based-on-type-access-to-field.rs | 2 +-
.../compile-fail/moves-based-on-type-exprs.rs | 10 +-
src/test/compile-fail/name-clash-nullary.rs | 2 +-
src/test/compile-fail/namespace-mix-new.rs | 167 +++
src/test/compile-fail/namespace-mix-old.rs | 174 +++
src/test/compile-fail/no-capture-arc.rs | 2 +-
src/test/compile-fail/no-link.rs | 2 +-
.../compile-fail/no-patterns-in-args-2.rs | 23 +
src/test/compile-fail/no-reuse-move-arc.rs | 2 +-
src/test/compile-fail/no-type-for-node-ice.rs | 2 +-
src/test/compile-fail/non-copyable-void.rs | 2 +-
src/test/compile-fail/non-exhaustive-match.rs | 8 +-
...ct-lifetime-default-from-rptr-box-error.rs | 2 -
...lifetime-default-from-rptr-struct-error.rs | 2 -
.../on-unimplemented/multiple-impls.rs | 6 +-
.../compile-fail/on-unimplemented/on-impl.rs | 9 +-
.../compile-fail/on-unimplemented/on-trait.rs | 6 +-
.../on-unimplemented/slice-index.rs | 14 +-
.../out-of-order-shadowing.rs} | 14 +-
.../pat-shadow-in-nested-binding.rs | 2 +-
src/test/compile-fail/pat-tuple-bad-type.rs | 2 -
src/test/compile-fail/pat-tuple-overfield.rs | 6 +-
.../compile-fail/pattern-error-continue.rs | 2 +-
.../compile-fail/qualified-path-params.rs | 2 +-
.../regions-bound-missing-bound-in-impl.rs | 2 +-
.../resolve-inconsistent-names.rs | 6 +-
.../compile-fail/self-vs-path-ambiguity.rs | 23 +
src/test/compile-fail/self_type_keyword-2.rs | 12 +-
src/test/compile-fail/self_type_keyword.rs | 25 +-
.../struct-fields-shorthand-unresolved.rs | 24 +
.../compile-fail/struct-fields-shorthand.rs | 24 +
src/test/compile-fail/struct-fields-typo.rs | 4 +-
.../compile-fail/struct-pat-derived-error.rs | 2 +-
.../compile-fail/struct-path-alias-bounds.rs | 21 +
.../struct-path-associated-type.rs | 50 +
.../struct-path-self-feature-gate.rs | 29 +
.../struct-path-self-type-mismatch.rs | 40 +
src/test/compile-fail/struct-path-self.rs | 49 +
.../trait-as-struct-constructor.rs | 3 +-
.../trait-suggest-where-clause.rs | 14 +-
.../typeck_type_placeholder_lifetime_1.rs | 2 +-
.../typeck_type_placeholder_lifetime_2.rs | 2 +-
.../unboxed-closure-sugar-wrong-trait.rs | 3 +-
.../unboxed-closures-failed-recursive-fn-2.rs | 2 +-
...es-move-upvar-from-non-once-ref-closure.rs | 2 +-
.../compile-fail/union/union-suggest-field.rs | 4 +-
src/test/compile-fail/unresolved-import.rs | 2 +-
src/test/compile-fail/unsafe-fn-autoderef.rs | 2 +-
src/test/compile-fail/unsized-enum.rs | 7 -
src/test/compile-fail/unsized-enum2.rs | 68 +
src/test/compile-fail/unsized3.rs | 17 +-
.../compile-fail/use-super-global-path.rs | 10 +-
src/test/compile-fail/variadic-ffi-2.rs | 2 +-
src/test/compile-fail/variadic-ffi.rs | 2 +-
.../compile-fail/variance-trait-matching.rs | 2 -
.../compile-fail/vec-macro-with-comma-only.rs | 2 +-
src/test/compile-fail/vec-mut-iter-borrow.rs | 2 +-
src/test/compile-fail/vec-res-add.rs | 4 +-
.../compile-fail/windows-subsystem-gated.rs | 14 +
.../compile-fail/windows-subsystem-invalid.rs | 16 +
.../compile-fail/writing-to-immutable-vec.rs | 2 +-
.../compile-fail/xcrate-private-by-default.rs | 2 +-
src/test/debuginfo/associated-types.rs | 6 +-
.../debuginfo/basic-types-globals-metadata.rs | 42 +-
src/test/debuginfo/basic-types-globals.rs | 45 +-
src/test/debuginfo/basic-types-metadata.rs | 31 +-
src/test/debuginfo/basic-types-mut-globals.rs | 90 +-
src/test/debuginfo/basic-types.rs | 3 +-
src/test/debuginfo/borrowed-basic.rs | 9 +-
src/test/debuginfo/borrowed-c-style-enum.rs | 9 +-
src/test/debuginfo/borrowed-enum.rs | 9 +-
src/test/debuginfo/borrowed-struct.rs | 9 +-
src/test/debuginfo/borrowed-tuple.rs | 9 +-
src/test/debuginfo/borrowed-unique-basic.rs | 3 +-
src/test/debuginfo/box.rs | 3 +-
src/test/debuginfo/boxed-struct.rs | 6 +-
.../by-value-non-immediate-argument.rs | 15 +-
.../by-value-self-argument-in-trait-impl.rs | 6 +-
.../debuginfo/c-style-enum-in-composite.rs | 22 +-
src/test/debuginfo/c-style-enum.rs | 74 +-
src/test/debuginfo/cross-crate-spans.rs | 6 +-
.../debuginfo/destructured-fn-argument.rs | 24 +-
.../destructured-for-loop-variable.rs | 6 +-
src/test/debuginfo/destructured-local.rs | 24 +-
src/test/debuginfo/drop-locations.rs | 91 ++
src/test/debuginfo/evec-in-struct.rs | 15 +-
src/test/debuginfo/extern-c-fn.rs | 3 +-
.../debuginfo/function-arg-initialization.rs | 8 +-
...gdb-pretty-struct-and-enums-pre-gdb-7-7.rs | 9 +-
.../generic-enum-with-different-disr-sizes.rs | 31 +-
src/test/debuginfo/generic-function.rs | 14 +-
.../generic-method-on-generic-struct.rs | 15 +-
.../debuginfo/generic-struct-style-enum.rs | 12 +-
src/test/debuginfo/generic-struct.rs | 12 +-
.../debuginfo/generic-tuple-style-enum.rs | 12 +-
src/test/debuginfo/issue14411.rs | 2 +-
.../lexical-scopes-in-block-expression.rs | 27 +-
src/test/debuginfo/method-on-enum.rs | 15 +-
.../debuginfo/method-on-generic-struct.rs | 15 +-
src/test/debuginfo/method-on-struct.rs | 15 +-
src/test/debuginfo/method-on-trait.rs | 15 +-
src/test/debuginfo/method-on-tuple-struct.rs | 15 +-
src/test/debuginfo/nil-enum.rs | 9 +-
src/test/debuginfo/option-like-enum.rs | 24 +-
.../packed-struct-with-destructor.rs | 24 +-
src/test/debuginfo/packed-struct.rs | 12 +-
src/test/debuginfo/pretty-std.rs | 3 +-
src/test/debuginfo/recursive-struct.rs | 43 +-
src/test/debuginfo/self-in-default-method.rs | 15 +-
.../self-in-generic-default-method.rs | 15 +-
src/test/debuginfo/simd.rs | 56 +-
src/test/debuginfo/simple-struct.rs | 115 +-
src/test/debuginfo/simple-tuple.rs | 121 +-
src/test/debuginfo/struct-in-enum.rs | 9 +-
src/test/debuginfo/struct-in-struct.rs | 9 +-
src/test/debuginfo/struct-style-enum.rs | 12 +-
src/test/debuginfo/struct-with-destructor.rs | 14 +-
src/test/debuginfo/tuple-in-struct.rs | 30 +-
src/test/debuginfo/tuple-in-tuple.rs | 21 +-
src/test/debuginfo/tuple-struct.rs | 18 +-
src/test/debuginfo/tuple-style-enum.rs | 12 +-
src/test/debuginfo/type-names.rs | 138 +-
src/test/debuginfo/union-smoke.rs | 6 +-
src/test/debuginfo/unique-enum.rs | 9 +-
.../var-captured-in-nested-closure.rs | 12 +-
.../var-captured-in-sendable-closure.rs | 3 +-
.../var-captured-in-stack-closure.rs | 12 +-
src/test/debuginfo/vec-slices.rs | 45 +-
src/test/debuginfo/vec.rs | 6 +-
.../change_crate_order/auxiliary/a.rs} | 11 +-
.../change_crate_order/auxiliary/b.rs | 14 +
.../incremental/change_crate_order/main.rs | 34 +
.../change_private_fn/struct_point.rs | 111 ++
.../change_private_fn_cc/auxiliary/point.rs | 35 +
.../change_private_fn_cc/struct_point.rs | 86 ++
.../struct_point.rs | 114 ++
.../auxiliary/point.rs | 35 +
.../struct_point.rs | 89 ++
src/test/incremental/hashes/consts.rs | 132 ++
src/test/incremental/hashes/enum_defs.rs | 715 ++++++++++
.../incremental/hashes/function_interfaces.rs | 400 ++++++
src/test/incremental/hashes/panic_exprs.rs | 173 +++
.../hashes/panic_exprs_no_overflow_checks.rs | 251 ++++
src/test/incremental/hashes/statics.rs | 185 +++
src/test/incremental/hashes/struct_defs.rs | 71 +
src/test/incremental/hashes/trait_defs.rs | 1115 ++++++++++++++++
.../incremental/struct_change_field_name.rs | 4 +-
src/test/mir-opt/deaggregator_test.rs | 22 +-
src/test/mir-opt/deaggregator_test_enum.rs | 20 +-
src/test/mir-opt/simplify_if.rs | 6 +-
src/test/mir-opt/storage_ranges.rs | 40 +-
...ciated-types-project-from-hrtb-explicit.rs | 2 +-
.../generic-non-trailing-defaults.rs | 2 +-
src/test/parse-fail/issue-10412.rs | 2 +-
src/test/parse-fail/issue-17904.rs | 2 +-
src/test/parse-fail/issue-37113.rs | 21 +
src/test/parse-fail/lex-bad-octal-literal.rs | 2 +
src/test/parse-fail/lifetime-no-keyword.rs | 2 +-
.../parse-fail/raw-byte-string-literals.rs | 6 +-
src/test/parse-fail/recover-enum.rs | 19 +
src/test/parse-fail/recover-enum2.rs | 43 +
src/test/parse-fail/recover-struct.rs | 19 +
.../parse-fail/removed-syntax-field-let.rs | 2 +-
src/test/parse-fail/removed-syntax-with-2.rs | 2 +-
.../struct-field-numeric-shorthand.rs | 19 +
src/test/parse-fail/syntax-trait-polarity.rs | 2 +-
.../parse-fail/trailing-plus-in-bounds.rs | 2 +-
.../parse-fail/trait-bounds-not-on-impl.rs | 2 +-
.../use-as-where-use-ends-with-mod-sep.rs | 2 +-
.../where-clauses-no-bounds-or-predicates.rs | 2 +-
src/test/pretty/block-disambig.rs | 4 +-
src/test/pretty/for-comment.rs | 1 -
src/test/pretty/issue-4264.pp | 2 +-
src/test/run-fail-fulldeps/qquote.rs | 2 +-
src/test/run-fail/divide-by-zero.rs | 2 -
src/test/run-fail/glob-use-std.rs | 4 -
src/test/run-fail/mod-zero.rs | 2 -
src/test/run-fail/overflowing-add.rs | 3 -
src/test/run-fail/overflowing-lsh-1.rs | 2 -
src/test/run-fail/overflowing-lsh-2.rs | 2 -
src/test/run-fail/overflowing-lsh-3.rs | 2 -
src/test/run-fail/overflowing-lsh-4.rs | 2 -
src/test/run-fail/overflowing-mul.rs | 2 -
src/test/run-fail/overflowing-neg.rs | 2 -
src/test/run-fail/overflowing-rsh-1.rs | 2 -
src/test/run-fail/overflowing-rsh-2.rs | 2 -
src/test/run-fail/overflowing-rsh-3.rs | 2 -
src/test/run-fail/overflowing-rsh-4.rs | 2 -
src/test/run-fail/overflowing-rsh-5.rs | 2 -
src/test/run-fail/overflowing-rsh-6.rs | 2 -
src/test/run-fail/overflowing-sub.rs | 2 -
src/test/run-fail/panic-task-name-none.rs | 1 +
src/test/run-fail/panic-task-name-owned.rs | 1 +
src/test/run-fail/run-unexported-tests.rs | 1 -
src/test/run-fail/task-spawn-barefn.rs | 1 +
src/test/run-fail/test-panic.rs | 2 +-
.../run-fail/test-should-fail-bad-message.rs | 2 +-
src/test/run-fail/test-tasks-invalid-value.rs | 2 +-
src/test/run-make/dep-info-spaces/Makefile | 7 +-
.../run-make/dep-info-spaces/Makefile.foo | 4 +-
src/test/run-make/issue-19371/foo.rs | 10 +-
src/test/run-make/llvm-phase/test.rs | 9 +-
.../run-make/rustc-macro-dep-files/Makefile | 6 +
.../run-make/rustc-macro-dep-files/bar.rs | 21 +
.../run-make/rustc-macro-dep-files/foo.rs | 24 +
src/test/run-make/save-analysis/foo.rs | 1 -
.../run-make/stable-symbol-names/Makefile | 14 +-
.../stable-symbol-names1.rs | 14 +
.../stable-symbol-names2.rs | 6 +
.../run-make/symbols-are-reasonable/Makefile | 8 +-
.../run-make/target-without-atomics/Makefile | 5 +
src/test/run-make/tools.mk | 3 -
src/test/run-make/windows-subsystem/Makefile | 5 +
.../run-make/windows-subsystem/console.rs | 15 +
.../run-make/windows-subsystem/windows.rs | 14 +
.../run-pass-fulldeps/ast_stmt_expr_attr.rs | 5 +-
.../auxiliary/cond_noprelude_plugin.rs | 6 +-
.../auxiliary/cond_plugin.rs | 6 +-
.../auxiliary/cond_prelude_plugin.rs | 6 +-
.../auxiliary/custom_derive_partial_eq.rs | 4 +-
.../auxiliary/custom_derive_plugin_attr.rs | 1 -
.../auxiliary/dummy_mir_pass.rs | 2 +-
.../auxiliary/macro_crate_test.rs | 3 +-
.../auxiliary/proc_macro_def.rs | 4 +-
.../auxiliary/procedural_mbe_matching.rs | 63 +-
src/test/run-pass-fulldeps/compiler-calls.rs | 3 +-
.../custom-derive-partial-eq.rs | 2 -
src/test/run-pass-fulldeps/issue-16992.rs | 1 -
.../issue-18763-quote-token-tree.rs | 2 -
.../run-pass-fulldeps/lint-group-plugin.rs | 2 -
.../lint-plugin-cmdline-load.rs | 1 -
src/test/run-pass-fulldeps/lint-plugin.rs | 2 -
src/test/run-pass-fulldeps/macro-crate.rs | 2 +-
src/test/run-pass-fulldeps/macro-quote-1.rs | 6 +-
.../{rustc-macro => proc-macro}/add-impl.rs | 2 +-
.../proc-macro}/append-impl.rs | 3 +-
.../auxiliary/add-impl.rs | 14 +-
.../proc-macro}/auxiliary/append-impl.rs | 12 +-
.../auxiliary/derive-a.rs | 16 +-
.../auxiliary/derive-atob.rs | 14 +-
.../auxiliary/derive-ctod.rs | 12 +-
.../auxiliary/derive-same-struct.rs | 14 +-
.../auxiliary/expand-with-a-macro.rs | 12 +-
.../derive-same-struct.rs | 2 +-
.../expand-with-a-macro.rs | 2 +-
.../{rustc-macro => proc-macro}/load-two.rs | 3 +-
.../{rustc-macro => proc-macro}/smoke.rs | 2 +-
src/test/run-pass-fulldeps/qquote.rs | 2 +-
src/test/run-pass-fulldeps/quote-tokens.rs | 2 -
.../quote-unused-sp-no-warning.rs | 2 -
.../run-pass-valgrind/cast-enum-with-dtor.rs | 2 -
src/test/run-pass/allocator-override.rs | 1 +
src/test/run-pass/assignability-trait.rs | 2 +-
...ciated-types-doubleendediterator-object.rs | 2 +-
.../associated-types-iterator-binding.rs | 2 +-
src/test/run-pass/attr-on-generic-formals.rs | 60 +
src/test/run-pass/auto-loop.rs | 2 +-
src/test/run-pass/auto-ref-sliceable.rs | 2 +-
src/test/run-pass/autobind.rs | 2 +-
.../check_static_recursion_foreign_helper.rs | 4 +-
.../auxiliary/dropck_eyepatch_extern_crate.rs | 61 +
src/test/run-pass/auxiliary/issue-36954.rs | 18 +
src/test/run-pass/backtrace-debuginfo.rs | 2 +-
src/test/run-pass/backtrace.rs | 1 -
src/test/run-pass/block-arg.rs | 2 +-
.../run-pass/borrow-by-val-method-receiver.rs | 2 +-
.../borrowck/borrowck-binding-mutbl.rs | 2 +-
.../borrowck/borrowck-mut-vec-as-imm-slice.rs | 2 +-
.../run-pass/borrowck/borrowck-pat-enum.rs | 2 +-
src/test/run-pass/break.rs | 2 +-
.../run-pass/by-value-self-in-mut-slot.rs | 2 +-
src/test/run-pass/byte-literals.rs | 2 +-
src/test/run-pass/cci_no_inline_exe.rs | 2 +-
src/test/run-pass/cfg-in-crate-1.rs | 2 -
.../class-poly-methods-cross-crate.rs | 8 +-
src/test/run-pass/class-poly-methods.rs | 8 +-
...nup-rvalue-temp-during-incomplete-alloc.rs | 2 +-
.../run-pass/coerce-reborrow-imm-vec-rcvr.rs | 2 +-
.../run-pass/coerce-reborrow-mut-vec-arg.rs | 2 +-
.../run-pass/coerce-reborrow-mut-vec-rcvr.rs | 2 +-
src/test/run-pass/command-exec.rs | 3 +-
src/test/run-pass/const-err.rs | 4 +
src/test/run-pass/core-run-destroy.rs | 1 -
src/test/run-pass/cstring-drop.rs | 49 -
.../run-pass/deprecated-macro_escape-inner.rs | 2 -
src/test/run-pass/deprecated-macro_escape.rs | 2 -
.../run-pass/deriving-cmp-generic-enum.rs | 3 -
src/test/run-pass/deriving-in-macro.rs | 2 +-
.../deriving-meta-empty-trait-list.rs | 2 -
src/test/run-pass/deriving-show.rs | 3 +
.../run-pass/discriminant_value-wrapper.rs | 28 +
.../run-pass/drop-with-type-ascription-2.rs | 2 +-
.../run-pass/dropck-eyepatch-extern-crate.rs | 48 +
src/test/run-pass/dropck-eyepatch-reorder.rs | 89 ++
src/test/run-pass/dropck-eyepatch.rs | 112 ++
src/test/run-pass/enum-size-variance.rs | 2 -
src/test/run-pass/expr-fn.rs | 2 +-
src/test/run-pass/expr-match-panic.rs | 2 +-
src/test/run-pass/extern-methods.rs | 3 +
src/test/run-pass/extern-pass-empty.rs | 1 +
src/test/run-pass/extern-vectorcall.rs | 3 +
src/test/run-pass/for-destruct.rs | 2 +-
src/test/run-pass/foreach-nested.rs | 2 +-
src/test/run-pass/format-no-std.rs | 2 +
src/test/run-pass/generic-ivec-leak.rs | 2 +-
src/test/run-pass/generic-static-methods.rs | 2 +-
src/test/run-pass/getopts_ref.rs | 2 +-
src/test/run-pass/hashmap-memory.rs | 2 +-
src/test/run-pass/html-literals.rs | 2 +-
src/test/run-pass/hygiene.rs | 14 +-
src/test/run-pass/hygienic-labels-in-let.rs | 2 -
src/test/run-pass/ifmt.rs | 4 +-
src/test/run-pass/import-glob-crate.rs | 12 +-
src/test/run-pass/imports.rs | 2 -
src/test/run-pass/issue-11709.rs | 2 +-
src/test/run-pass/issue-13204.rs | 2 +-
src/test/run-pass/issue-14936.rs | 2 +-
src/test/run-pass/issue-15080.rs | 2 +-
src/test/run-pass/issue-15189.rs | 4 +-
src/test/run-pass/issue-15734.rs | 2 +-
src/test/run-pass/issue-16492.rs | 2 -
src/test/run-pass/issue-16597-empty.rs | 1 -
src/test/run-pass/issue-16597.rs | 1 -
src/test/run-pass/issue-16668.rs | 2 -
src/test/run-pass/issue-18060.rs | 17 +
src/test/run-pass/issue-18088.rs | 17 +
src/test/run-pass/issue-18464.rs | 2 -
src/test/run-pass/issue-18937-1.rs | 30 +
src/test/run-pass/issue-20427.rs | 2 +-
src/test/run-pass/issue-20823.rs | 1 -
src/test/run-pass/issue-22546.rs | 6 +
src/test/run-pass/issue-22992.rs | 2 +-
.../issue-23338-ensure-param-drop-order.rs | 2 +-
src/test/run-pass/issue-2631-b.rs | 2 +-
src/test/run-pass/issue-26873-multifile.rs | 5 +-
src/test/run-pass/issue-2723-b.rs | 2 +-
.../run-pass/issue-27401-dropflag-reinit.rs | 2 +-
src/test/run-pass/issue-27639.rs | 2 -
src/test/run-pass/issue-28839.rs | 2 +-
src/test/run-pass/issue-28936.rs | 2 +-
src/test/run-pass/issue-29740.rs | 2 -
src/test/run-pass/issue-2989.rs | 4 +-
src/test/run-pass/issue-3389.rs | 4 +-
src/test/run-pass/issue-34932.rs | 2 -
src/test/run-pass/issue-36768.rs | 18 +
src/test/run-pass/issue-36786-resolve-call.rs | 17 +
src/test/run-pass/issue-36816.rs | 16 +
src/test/run-pass/issue-36954.rs | 17 +
src/test/run-pass/issue-37175.rs | 14 +
src/test/run-pass/issue-37686.rs | 16 +
src/test/run-pass/issue-38002.rs | 45 +
src/test/run-pass/issue-38033.rs | 88 ++
src/test/run-pass/issue-6153.rs | 2 +-
src/test/run-pass/issue-7911.rs | 2 -
src/test/run-pass/issue-8460.rs | 2 -
src/test/run-pass/issue-9129.rs | 2 +-
src/test/run-pass/iter-step-overflow-debug.rs | 29 +
.../run-pass/iter-step-overflow-ndebug.rs | 21 +
src/test/run-pass/iter-zip.rs | 112 ++
src/test/run-pass/ivec-pass-by-value.rs | 2 +-
src/test/run-pass/ivec-tag.rs | 4 +-
src/test/run-pass/lambda-infer-unresolved.rs | 2 +-
...line-endings-string-literal-doc-comment.rs | 2 +-
src/test/run-pass/linear-for-loop.rs | 4 +-
src/test/run-pass/log-poly.rs | 2 +-
src/test/run-pass/loop-scope.rs | 2 +-
src/test/run-pass/macro-2.rs | 2 -
.../run-pass/macro-attribute-expansion.rs | 2 -
src/test/run-pass/macro-attributes.rs | 2 -
src/test/run-pass/macro-include-items.rs | 2 +-
src/test/run-pass/macro-meta-items.rs | 1 -
src/test/run-pass/macro-multiple-items.rs | 2 -
src/test/run-pass/macro-stmt.rs | 2 -
.../run-pass/match-byte-array-patterns.rs | 54 +
src/test/run-pass/match-vec-rvalue.rs | 2 +-
src/test/run-pass/mir_raw_fat_ptr.rs | 2 -
src/test/run-pass/mod_dir_implicit.rs | 2 +-
src/test/run-pass/mod_dir_path.rs | 13 +-
src/test/run-pass/mod_dir_path2.rs | 2 +-
src/test/run-pass/mod_dir_path3.rs | 2 +-
src/test/run-pass/mod_dir_path_multi.rs | 2 +-
src/test/run-pass/mod_dir_recursive.rs | 2 +-
src/test/run-pass/mod_dir_simple.rs | 2 +-
src/test/run-pass/mod_file.rs | 2 +-
src/test/run-pass/mod_file_with_path_attr.rs | 2 +-
src/test/run-pass/monad.rs | 6 +-
src/test/run-pass/move-arg-2-unique.rs | 4 +-
src/test/run-pass/move-arg-2.rs | 4 +-
src/test/run-pass/newtype-polymorphic.rs | 2 +-
src/test/run-pass/nonzero-enum.rs | 39 +
.../nullable-pointer-iotareduction.rs | 2 +-
.../run-pass/numeric-method-autoexport.rs | 2 -
...owned-object-borrowed-method-headerless.rs | 4 +-
src/test/run-pass/overloaded-deref.rs | 2 +-
src/test/run-pass/packed-struct-layout.rs | 1 +
.../run-pass/packed-tuple-struct-layout.rs | 1 +
.../abort-link-to-unwinding-crates.rs | 1 +
src/test/run-pass/panic-runtime/abort.rs | 1 +
src/test/run-pass/panic-runtime/lto-abort.rs | 1 +
src/test/run-pass/panic-runtime/lto-unwind.rs | 1 +
src/test/run-pass/pat-tuple-1.rs | 2 -
src/test/run-pass/pat-tuple-2.rs | 2 -
src/test/run-pass/pat-tuple-3.rs | 2 -
src/test/run-pass/pat-tuple-4.rs | 2 -
src/test/run-pass/pat-tuple-5.rs | 2 -
src/test/run-pass/pat-tuple-6.rs | 2 -
.../run-pass/process-status-inherits-stdin.rs | 1 +
.../run-pass/project-cache-issue-37154.rs | 28 +
src/test/run-pass/range_inclusive.rs | 2 +-
src/test/run-pass/rcvr-borrowed-to-slice.rs | 6 +-
.../run-pass/reexport-test-harness-main.rs | 1 -
src/test/run-pass/regions-borrow-evec-uniq.rs | 4 +-
.../regions-bound-lists-feature-gate-2.rs | 2 -
.../regions-bound-lists-feature-gate.rs | 2 -
.../run-pass/regions-dependent-addr-of.rs | 2 +-
.../run-pass/regions-dependent-autoslice.rs | 2 +-
.../regions-infer-borrow-scope-view.rs | 2 +-
...ions-on-closures-to-inference-variables.rs | 2 +-
src/test/run-pass/seq-compare.rs | 18 +-
src/test/run-pass/shebang.rs | 3 -
.../run-pass/simd-intrinsic-generic-cast.rs | 1 +
.../simd-intrinsic-generic-elements.rs | 2 -
src/test/run-pass/size-and-align.rs | 2 +-
src/test/run-pass/static-impl.rs | 6 +-
src/test/run-pass/struct-field-shorthand.rs | 37 +
.../struct-path-associated-type.rs} | 32 +-
src/test/run-pass/struct-path-self.rs | 56 +
src/test/run-pass/super-fast-paren-parsing.rs | 2 -
src/test/run-pass/swap-2.rs | 2 +-
.../run-pass/syntax-extension-source-utils.rs | 11 +-
src/test/run-pass/task-comm-16.rs | 2 +-
src/test/run-pass/task-comm-3.rs | 1 -
src/test/run-pass/task-stderr.rs | 2 +-
...e-verification-for-explicit-return-type.rs | 1 -
src/test/run-pass/test-runner-hides-main.rs | 2 -
.../run-pass/test-should-fail-good-message.rs | 2 -
src/test/run-pass/trait-bounds-in-arc.rs | 6 +-
src/test/run-pass/trait-generic.rs | 8 +-
src/test/run-pass/trait-to-str.rs | 6 +-
.../run-pass/traits-elaborate-type-region.rs | 58 +
src/test/run-pass/type-macros-simple.rs | 2 +-
.../run-pass/typeck-fn-to-unsafe-fn-ptr.rs | 21 +
.../unboxed-closures-counter-not-moved.rs | 2 +-
...ures-move-some-upvars-in-by-ref-closure.rs | 4 +-
src/test/run-pass/union/union-backcomp.rs | 6 +
.../union/union-with-drop-fields-lint.rs | 2 -
src/test/run-pass/uniq-self-in-mut-slot.rs | 2 +-
src/test/run-pass/unique-autoderef-index.rs | 2 +-
src/test/run-pass/unique-create.rs | 2 +-
src/test/run-pass/unique-drop-complex.rs | 2 +-
src/test/run-pass/unique-in-vec-copy.rs | 2 +-
src/test/run-pass/unique-in-vec.rs | 2 +-
src/test/run-pass/unsized2.rs | 8 +-
src/test/run-pass/utf8_chars.rs | 2 +-
src/test/run-pass/vec-concat.rs | 4 +-
src/test/run-pass/vec-growth.rs | 2 +-
src/test/run-pass/vec-late-init.rs | 2 +-
.../run-pass/vec-macro-with-trailing-comma.rs | 4 +-
src/test/run-pass/vec-matching.rs | 15 +
src/test/run-pass/vec-push.rs | 2 +-
src/test/run-pass/vec-to_str.rs | 4 +-
src/test/run-pass/vec.rs | 2 +-
src/test/run-pass/while-with-break.rs | 2 +-
src/test/rustdoc/line-breaks.rs | 21 +
src/test/rustdoc/playground-empty.rs | 21 +
src/test/rustdoc/playground-none.rs | 19 +
src/test/rustdoc/playground.rs | 39 +
.../rustc-macro-crate.rs} | 15 +-
src/test/ui/check_match/issue-35609.rs | 53 +
src/test/ui/check_match/issue-35609.stderr | 50 +
.../ui/compare-method/proj-outlives-region.rs | 27 +
.../proj-outlives-region.stderr | 19 +
.../proj-outlives-region.stdout | 0
.../compare-method/region-extra-2.rs} | 2 +-
.../ui/compare-method/region-extra-2.stderr | 11 +
src/test/ui/compare-method/region-extra.rs | 27 +
.../ui/compare-method/region-extra.stderr | 11 +
.../ui/compare-method/region-extra.stdout | 0
.../ui/compare-method/region-unrelated.rs | 28 +
.../ui/compare-method/region-unrelated.stderr | 19 +
.../ui/compare-method/region-unrelated.stdout | 0
.../compare-method/reordered-type-param.rs} | 2 +
.../reordered-type-param.stderr | 14 +
.../trait-bound-on-type-parameter.rs} | 9 +-
.../trait-bound-on-type-parameter.stderr | 11 +
.../compare-method/traits-misc-mismatch-1.rs} | 14 +-
.../traits-misc-mismatch-1.stderr | 65 +
.../compare-method/traits-misc-mismatch-2.rs} | 2 +-
.../traits-misc-mismatch-2.stderr | 11 +
src/test/ui/did_you_mean/issue-36798.rs | 18 +
src/test/ui/did_you_mean/issue-36798.stderr | 8 +
.../did_you_mean/issue-36798_unknown_field.rs | 18 +
.../issue-36798_unknown_field.stderr | 8 +
.../auxiliary/dropck_eyepatch_extern_crate.rs | 48 +
.../ui/dropck/dropck-eyepatch-extern-crate.rs | 55 +
.../dropck-eyepatch-extern-crate.stderr | 46 +
.../dropck-eyepatch-implies-unsafe-impl.rs | 46 +
...dropck-eyepatch-implies-unsafe-impl.stderr | 14 +
src/test/ui/dropck/dropck-eyepatch-reorder.rs | 73 +
.../ui/dropck/dropck-eyepatch-reorder.stderr | 46 +
src/test/ui/dropck/dropck-eyepatch.rs | 96 ++
src/test/ui/dropck/dropck-eyepatch.stderr | 46 +
.../macro-backtrace-invalid-internals.stderr | 12 +-
src/test/ui/span/E0057.rs | 16 +
src/test/ui/span/E0057.stderr | 18 +
.../span}/borrowck-let-suggestion-suffixes.rs | 8 +-
.../borrowck-let-suggestion-suffixes.stderr | 52 +
.../span}/borrowck-ref-into-rvalue.rs | 0
.../ui/span/borrowck-ref-into-rvalue.stderr | 16 +
.../span}/destructor-restrictions.rs | 0
.../ui/span/destructor-restrictions.stderr | 12 +
.../span}/dropck-object-cycle.rs | 6 +-
src/test/ui/span/dropck-object-cycle.stderr | 13 +
.../span}/dropck_arr_cycle_checked.rs | 18 +-
.../ui/span/dropck_arr_cycle_checked.stderr | 67 +
.../span}/dropck_direct_cycle_with_drop.rs | 6 +-
.../span/dropck_direct_cycle_with_drop.stderr | 23 +
.../span}/dropck_misc_variants.rs | 4 +-
src/test/ui/span/dropck_misc_variants.stderr | 23 +
.../span}/dropck_vec_cycle_checked.rs | 18 +-
.../ui/span/dropck_vec_cycle_checked.stderr | 67 +
src/test/ui/span/issue-11925.stderr | 4 +-
...e-23338-locals-die-before-temps-of-body.rs | 3 +-
...338-locals-die-before-temps-of-body.stderr | 22 +
src/test/ui/span/issue-24690.rs | 22 +
src/test/ui/span/issue-24690.stderr | 32 +
...24805-dropck-child-has-items-via-parent.rs | 3 +-
...5-dropck-child-has-items-via-parent.stderr | 13 +
.../issue-24805-dropck-trait-has-items.rs | 9 +-
.../issue-24805-dropck-trait-has-items.stderr | 32 +
.../span}/issue-24895-copy-clone-dropck.rs | 4 +-
.../span/issue-24895-copy-clone-dropck.stderr | 12 +
.../{compile-fail => ui/span}/issue-25199.rs | 6 +-
src/test/ui/span/issue-25199.stderr | 23 +
.../{compile-fail => ui/span}/issue-26656.rs | 2 +-
src/test/ui/span/issue-26656.stderr | 12 +
.../{compile-fail => ui/span}/issue-29106.rs | 8 +-
src/test/ui/span/issue-29106.stderr | 22 +
src/test/ui/span/issue-36537.rs | 18 +
src/test/ui/span/issue-36537.stderr | 12 +
.../span}/issue28498-reject-ex1.rs | 4 +-
src/test/ui/span/issue28498-reject-ex1.stderr | 23 +
.../span}/issue28498-reject-lifetime-param.rs | 4 +-
.../issue28498-reject-lifetime-param.stderr | 24 +
.../span}/issue28498-reject-passed-to-fn.rs | 4 +-
.../issue28498-reject-passed-to-fn.stderr | 24 +
.../span}/issue28498-reject-trait-bound.rs | 4 +-
.../span/issue28498-reject-trait-bound.stderr | 24 +
.../impl-trait => ui/span}/loan-extend.rs | 9 +-
src/test/ui/span/loan-extend.stderr | 13 +
.../span}/mut-ptr-cant-outlive-ref.rs | 0
.../ui/span/mut-ptr-cant-outlive-ref.stderr | 12 +
src/test/{compile-fail => ui/span}/range-2.rs | 0
src/test/ui/span/range-2.stderr | 24 +
.../regionck-unboxed-closure-lifetimes.rs | 0
.../regionck-unboxed-closure-lifetimes.stderr | 13 +
.../regions-close-over-type-parameter-2.rs | 0
...regions-close-over-type-parameter-2.stderr | 13 +
.../span}/regions-escape-loop-via-variable.rs | 0
.../regions-escape-loop-via-variable.stderr | 12 +
.../span}/regions-escape-loop-via-vec.rs | 2 +-
.../span/regions-escape-loop-via-vec.stderr | 41 +
.../regions-infer-borrow-scope-within-loop.rs | 0
...ions-infer-borrow-scope-within-loop.stderr | 14 +
.../send-is-not-static-ensures-scoping.rs | 0
.../send-is-not-static-ensures-scoping.stderr | 28 +
.../span}/send-is-not-static-std-sync-2.rs | 0
.../span/send-is-not-static-std-sync-2.stderr | 36 +
.../span}/send-is-not-static-std-sync.rs | 0
.../span/send-is-not-static-std-sync.stderr | 56 +
src/test/ui/span/type-binding.stderr | 2 +-
.../vec-must-not-hide-type-from-dropck.rs | 6 +-
.../vec-must-not-hide-type-from-dropck.stderr | 23 +
.../span}/vec_refs_data_with_early_death.rs | 6 +-
.../vec_refs_data_with_early_death.stderr | 24 +
.../span}/wf-method-late-bound-regions.rs | 0
.../span/wf-method-late-bound-regions.stderr | 13 +
src/test/ui/update-references.sh | 4 +-
src/tools/cargotest/Cargo.lock | 4 -
src/tools/cargotest/main.rs | 16 +-
src/tools/compiletest/Cargo.lock | 92 --
src/tools/compiletest/Cargo.toml | 4 +-
src/tools/compiletest/src/common.rs | 11 +-
src/tools/compiletest/src/header.rs | 23 +-
src/tools/compiletest/src/main.rs | 195 ++-
src/tools/compiletest/src/runtest.rs | 166 ++-
src/tools/compiletest/src/util.rs | 3 +-
src/tools/error_index_generator/Cargo.lock | 4 -
src/tools/error_index_generator/main.rs | 5 +-
src/tools/linkchecker/Cargo.lock | 50 -
src/tools/rustbook/Cargo.lock | 4 -
src/tools/rustbook/book.rs | 10 +-
src/tools/rustbook/build.rs | 7 +-
src/tools/tidy/Cargo.lock | 4 -
src/tools/tidy/src/bins.rs | 25 +-
src/tools/tidy/src/cargo.rs | 8 +-
src/tools/tidy/src/features.rs | 113 +-
src/tools/tidy/src/main.rs | 2 +
src/tools/tidy/src/pal.rs | 226 ++++
version | 2 +-
1523 files changed, 37407 insertions(+), 22584 deletions(-)
create mode 100644 mk/cfg/aarch64-unknown-fuchsia.mk
create mode 100644 mk/cfg/wasm32-unknown-emscripten.mk
create mode 100644 mk/cfg/x86_64-unknown-fuchsia.mk
delete mode 100644 src/bootstrap/Cargo.lock
create mode 100644 src/bootstrap/install.rs
create mode 100644 src/bootstrap/metadata.rs
create mode 100644 src/libcollectionstest/cow_str.rs
create mode 100644 src/libcore/internal_macros.rs
create mode 100644 src/liblibc/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile
delete mode 100644 src/libpanic_unwind/Cargo.lock
create mode 100644 src/libpanic_unwind/emcc.rs
create mode 100644 src/libproc_macro_plugin/Cargo.toml
create mode 100644 src/libproc_macro_plugin/lib.rs
rename src/{libproc_macro => libproc_macro_plugin}/qquote.rs (98%)
rename src/{librustc_macro => libproc_macro_tokens}/Cargo.toml (62%)
rename src/{libproc_macro => libproc_macro_tokens}/build.rs (100%)
create mode 100644 src/libproc_macro_tokens/lib.rs
rename src/{libproc_macro => libproc_macro_tokens}/parse.rs (100%)
rename src/{libproc_macro => libproc_macro_tokens}/prelude.rs (100%)
delete mode 100644 src/librustc/mir/mir_map.rs
rename src/librustc/mir/{repr.rs => mod.rs} (86%)
delete mode 100644 src/librustc_back/sha2.rs
create mode 100644 src/librustc_back/target/aarch64_unknown_fuchsia.rs
create mode 100644 src/librustc_back/target/arm_base.rs
create mode 100644 src/librustc_back/target/fuchsia_base.rs
create mode 100644 src/librustc_back/target/thumb_base.rs
create mode 100644 src/librustc_back/target/thumbv6m_none_eabi.rs
create mode 100644 src/librustc_back/target/thumbv7em_none_eabi.rs
create mode 100644 src/librustc_back/target/thumbv7em_none_eabihf.rs
create mode 100644 src/librustc_back/target/thumbv7m_none_eabi.rs
create mode 100644 src/librustc_back/target/wasm32_unknown_emscripten.rs
create mode 100644 src/librustc_back/target/x86_64_unknown_fuchsia.rs
create mode 100644 src/librustc_const_eval/_match.rs
create mode 100644 src/librustc_const_eval/pattern.rs
create mode 100644 src/librustc_data_structures/accumulate_vec.rs
create mode 100644 src/librustc_data_structures/array_vec.rs
rename src/{librustc_borrowck => librustc_data_structures}/bitslice.rs (98%)
create mode 100644 src/librustc_data_structures/blake2b.rs
create mode 100644 src/librustc_data_structures/fmt_wrap.rs
rename src/{librustc_borrowck => librustc_data_structures}/indexed_set.rs (98%)
create mode 100644 src/librustc_errors/diagnostic.rs
create mode 100644 src/librustc_errors/diagnostic_builder.rs
create mode 100644 src/librustc_incremental/calculate_svh/hasher.rs
create mode 100644 src/librustc_incremental/ich/fingerprint.rs
create mode 100644 src/librustc_incremental/ich/mod.rs
delete mode 100644 src/librustc_macro/lib.rs
rename src/librustc_metadata/{csearch.rs => cstore_impl.rs} (94%)
rename src/librustc_metadata/{loader.rs => locator.rs} (79%)
delete mode 100644 src/librustc_metadata/macro_import.rs
delete mode 100644 src/librustc_mir/hair/cx/pattern.rs
rename src/librustc_mir/transform/{simplify_cfg.rs => simplify.rs} (62%)
create mode 100644 src/librustc_passes/hir_stats.rs
delete mode 100644 src/librustdoc/html/static/playpen.js
rename src/libstd/{num => }/f32.rs (100%)
rename src/libstd/{num => }/f64.rs (100%)
rename src/libstd/{num/mod.rs => num.rs} (100%)
create mode 100644 src/libstd/os/fuchsia/fs.rs
create mode 100644 src/libstd/os/fuchsia/mod.rs
create mode 100644 src/libstd/os/fuchsia/raw.rs
delete mode 100644 src/libstd/sys/common/args.rs
create mode 100644 src/libstd/sys/mod.rs
create mode 100644 src/libstd/sys/unix/args.rs
create mode 100644 src/libstd/sys/unix/env.rs
create mode 100644 src/libstd/sys/unix/fast_thread_local.rs
create mode 100644 src/libstd/sys/unix/memchr.rs
create mode 100644 src/libstd/sys/unix/path.rs
create mode 100644 src/libstd/sys/windows/args.rs
create mode 100644 src/libstd/sys/windows/env.rs
create mode 100644 src/libstd/sys/windows/memchr.rs
create mode 100644 src/libstd/sys/windows/path.rs
rename src/libstd/{sys/common => sys_common}/at_exit_imp.rs (100%)
rename src/libstd/{sys/common => sys_common}/backtrace.rs (100%)
rename src/libstd/{sys/common => sys_common}/condvar.rs (100%)
rename src/libstd/{sys/common => sys_common}/gnu/libbacktrace.rs (100%)
rename src/libstd/{sys/common => sys_common}/gnu/mod.rs (100%)
rename src/libstd/{sys/common => sys_common}/io.rs (97%)
create mode 100644 src/libstd/sys_common/memchr.rs
rename src/libstd/{sys/common => sys_common}/mod.rs (82%)
rename src/libstd/{sys/common => sys_common}/mutex.rs (100%)
rename src/libstd/{sys/common => sys_common}/net.rs (96%)
rename src/libstd/{sys/common => sys_common}/poison.rs (100%)
rename src/libstd/{sys/common => sys_common}/remutex.rs (99%)
rename src/libstd/{sys/common => sys_common}/rwlock.rs (100%)
rename src/libstd/{sys/common => sys_common}/thread.rs (100%)
rename src/libstd/{sys/common => sys_common}/thread_info.rs (100%)
rename src/libstd/{sys/common => sys_common}/thread_local.rs (100%)
rename src/libstd/{sys/common => sys_common}/util.rs (58%)
rename src/libstd/{sys/common => sys_common}/wtf8.rs (98%)
rename src/libsyntax_ext/{rustc_macro_registrar.rs => proc_macro_registrar.rs} (77%)
delete mode 100644 src/rustc/Cargo.lock
delete mode 100644 src/rustc/std_shim/Cargo.lock
delete mode 100644 src/rustc/test_shim/Cargo.lock
create mode 100644 src/test/codegen/enum-bounds-check.rs
rename src/test/compile-fail-fulldeps/{macro-crate-unknown-crate.rs => no-link-unknown-crate.rs} (95%)
rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/at-the-root.rs (73%)
create mode 100644 src/test/compile-fail-fulldeps/proc-macro/attribute.rs
rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/auxiliary/derive-a.rs (77%)
rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/auxiliary/derive-bad.rs (78%)
rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/auxiliary/derive-panic.rs (77%)
rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/auxiliary/derive-unstable-2.rs (78%)
rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/auxiliary/derive-unstable.rs (78%)
rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/cannot-link.rs (87%)
rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/define-two.rs (74%)
rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/derive-bad.rs (96%)
rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/derive-still-gated.rs (96%)
rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/expand-to-unstable-2.rs (96%)
rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/expand-to-unstable.rs (96%)
rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/export-macro.rs (79%)
rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/exports.rs (95%)
rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/feature-gate-1.rs (83%)
rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/feature-gate-2.rs (87%)
rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/feature-gate-3.rs (83%)
rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/feature-gate-4.rs (100%)
rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/feature-gate-5.rs (87%)
create mode 100644 src/test/compile-fail-fulldeps/proc-macro/illegal-proc-macro-derive-use.rs
rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/import.rs (96%)
rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/load-panic.rs (96%)
rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/shadow-builtin.rs (80%)
rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/shadow.rs (81%)
rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/signature.rs (78%)
rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/two-crate-types-1.rs (83%)
rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/two-crate-types-2.rs (78%)
delete mode 100644 src/test/compile-fail-fulldeps/rustc-macro/attribute.rs
rename src/test/compile-fail/{E0002.rs => E0004-2.rs} (94%)
create mode 100644 src/test/compile-fail/E0198.rs
create mode 100644 src/test/compile-fail/associated-path-shl.rs
create mode 100644 src/test/compile-fail/attr-on-generic-formals-are-visited.rs
create mode 100644 src/test/compile-fail/attr-on-generic-formals-wo-feature-gate.rs
create mode 100644 src/test/compile-fail/attrs-with-no-formal-in-generics-1.rs
create mode 100644 src/test/compile-fail/attrs-with-no-formal-in-generics-2.rs
create mode 100644 src/test/compile-fail/attrs-with-no-formal-in-generics-3.rs
create mode 100644 src/test/compile-fail/auxiliary/define_macro.rs
create mode 100644 src/test/compile-fail/auxiliary/import_crate_var.rs
create mode 100644 src/test/compile-fail/auxiliary/namespace-mix-new.rs
create mode 100644 src/test/compile-fail/auxiliary/namespace-mix-old.rs
create mode 100644 src/test/compile-fail/dep-graph-type-alias.rs
delete mode 100644 src/test/compile-fail/empty-struct-unit-pat-1.rs
delete mode 100644 src/test/compile-fail/empty-struct-unit-pat-2.rs
create mode 100644 src/test/compile-fail/empty-struct-unit-pat.rs
rename src/test/compile-fail/{pat-tuple-feature-gate.rs => feature-gate-field-init-shorthand.rs} (66%)
create mode 100644 src/test/compile-fail/feature-gate-may-dangle.rs
create mode 100644 src/test/compile-fail/feature-gate-no-debug-2.rs
create mode 100644 src/test/compile-fail/import-crate-var.rs
create mode 100644 src/test/compile-fail/issue-18937.rs
create mode 100644 src/test/compile-fail/issue-21837.rs
create mode 100644 src/test/compile-fail/issue-26158.rs
create mode 100644 src/test/compile-fail/issue-36116.rs
rename src/test/compile-fail/{E0422.rs => issue-36881.rs} (83%)
create mode 100644 src/test/compile-fail/issue-37026.rs
create mode 100644 src/test/compile-fail/issue-37534.rs
rename src/test/{run-pass => compile-fail}/issue-pr29383.rs (74%)
rename src/test/{parse-fail => compile-fail}/keyword-self-as-identifier.rs (81%)
rename src/test/{parse-fail => compile-fail}/keyword-super-as-identifier.rs (81%)
rename src/test/{parse-fail => compile-fail}/keyword-super.rs (81%)
create mode 100644 src/test/compile-fail/macro-shadowing.rs
create mode 100644 src/test/compile-fail/match-byte-array-patterns.rs
create mode 100644 src/test/compile-fail/namespace-mix-new.rs
create mode 100644 src/test/compile-fail/namespace-mix-old.rs
create mode 100644 src/test/compile-fail/no-patterns-in-args-2.rs
rename src/test/{compile-fail-fulldeps/rustc-macro/require-rustc-macro-crate-type.rs => compile-fail/out-of-order-shadowing.rs} (68%)
create mode 100644 src/test/compile-fail/self-vs-path-ambiguity.rs
create mode 100644 src/test/compile-fail/struct-fields-shorthand-unresolved.rs
create mode 100644 src/test/compile-fail/struct-fields-shorthand.rs
create mode 100644 src/test/compile-fail/struct-path-alias-bounds.rs
create mode 100644 src/test/compile-fail/struct-path-associated-type.rs
create mode 100644 src/test/compile-fail/struct-path-self-feature-gate.rs
create mode 100644 src/test/compile-fail/struct-path-self-type-mismatch.rs
create mode 100644 src/test/compile-fail/struct-path-self.rs
create mode 100644 src/test/compile-fail/unsized-enum2.rs
create mode 100644 src/test/compile-fail/windows-subsystem-gated.rs
create mode 100644 src/test/compile-fail/windows-subsystem-invalid.rs
create mode 100644 src/test/debuginfo/drop-locations.rs
rename src/test/{run-pass/lint-non-uppercase-statics-lowercase-mut-statics.rs => incremental/change_crate_order/auxiliary/a.rs} (65%)
create mode 100644 src/test/incremental/change_crate_order/auxiliary/b.rs
create mode 100644 src/test/incremental/change_crate_order/main.rs
create mode 100644 src/test/incremental/change_private_fn/struct_point.rs
create mode 100644 src/test/incremental/change_private_fn_cc/auxiliary/point.rs
create mode 100644 src/test/incremental/change_private_fn_cc/struct_point.rs
create mode 100644 src/test/incremental/change_private_impl_method/struct_point.rs
create mode 100644 src/test/incremental/change_private_impl_method_cc/auxiliary/point.rs
create mode 100644 src/test/incremental/change_private_impl_method_cc/struct_point.rs
create mode 100644 src/test/incremental/hashes/consts.rs
create mode 100644 src/test/incremental/hashes/enum_defs.rs
create mode 100644 src/test/incremental/hashes/function_interfaces.rs
create mode 100644 src/test/incremental/hashes/panic_exprs.rs
create mode 100644 src/test/incremental/hashes/panic_exprs_no_overflow_checks.rs
create mode 100644 src/test/incremental/hashes/statics.rs
create mode 100644 src/test/incremental/hashes/trait_defs.rs
create mode 100644 src/test/parse-fail/issue-37113.rs
create mode 100644 src/test/parse-fail/recover-enum.rs
create mode 100644 src/test/parse-fail/recover-enum2.rs
create mode 100644 src/test/parse-fail/recover-struct.rs
create mode 100644 src/test/parse-fail/struct-field-numeric-shorthand.rs
create mode 100644 src/test/run-make/rustc-macro-dep-files/Makefile
create mode 100644 src/test/run-make/rustc-macro-dep-files/bar.rs
create mode 100644 src/test/run-make/rustc-macro-dep-files/foo.rs
create mode 100644 src/test/run-make/target-without-atomics/Makefile
create mode 100644 src/test/run-make/windows-subsystem/Makefile
create mode 100644 src/test/run-make/windows-subsystem/console.rs
create mode 100644 src/test/run-make/windows-subsystem/windows.rs
rename src/test/run-pass-fulldeps/{rustc-macro => proc-macro}/add-impl.rs (96%)
rename src/test/{compile-fail-fulldeps/rustc-macro => run-pass-fulldeps/proc-macro}/append-impl.rs (88%)
rename src/test/run-pass-fulldeps/{rustc-macro => proc-macro}/auxiliary/add-impl.rs (78%)
rename src/test/{compile-fail-fulldeps/rustc-macro => run-pass-fulldeps/proc-macro}/auxiliary/append-impl.rs (80%)
rename src/test/run-pass-fulldeps/{rustc-macro => proc-macro}/auxiliary/derive-a.rs (66%)
rename src/test/run-pass-fulldeps/{rustc-macro => proc-macro}/auxiliary/derive-atob.rs (73%)
rename src/test/run-pass-fulldeps/{rustc-macro => proc-macro}/auxiliary/derive-ctod.rs (79%)
rename src/test/run-pass-fulldeps/{rustc-macro => proc-macro}/auxiliary/derive-same-struct.rs (80%)
rename src/test/run-pass-fulldeps/{rustc-macro => proc-macro}/auxiliary/expand-with-a-macro.rs (82%)
rename src/test/run-pass-fulldeps/{rustc-macro => proc-macro}/derive-same-struct.rs (96%)
rename src/test/run-pass-fulldeps/{rustc-macro => proc-macro}/expand-with-a-macro.rs (96%)
rename src/test/run-pass-fulldeps/{rustc-macro => proc-macro}/load-two.rs (93%)
rename src/test/run-pass-fulldeps/{rustc-macro => proc-macro}/smoke.rs (96%)
create mode 100644 src/test/run-pass/attr-on-generic-formals.rs
create mode 100644 src/test/run-pass/auxiliary/dropck_eyepatch_extern_crate.rs
create mode 100644 src/test/run-pass/auxiliary/issue-36954.rs
delete mode 100644 src/test/run-pass/cstring-drop.rs
create mode 100644 src/test/run-pass/discriminant_value-wrapper.rs
create mode 100644 src/test/run-pass/dropck-eyepatch-extern-crate.rs
create mode 100644 src/test/run-pass/dropck-eyepatch-reorder.rs
create mode 100644 src/test/run-pass/dropck-eyepatch.rs
create mode 100644 src/test/run-pass/issue-18060.rs
create mode 100644 src/test/run-pass/issue-18088.rs
create mode 100644 src/test/run-pass/issue-18937-1.rs
create mode 100644 src/test/run-pass/issue-36768.rs
create mode 100644 src/test/run-pass/issue-36786-resolve-call.rs
create mode 100644 src/test/run-pass/issue-36816.rs
create mode 100644 src/test/run-pass/issue-36954.rs
create mode 100644 src/test/run-pass/issue-37175.rs
create mode 100644 src/test/run-pass/issue-37686.rs
create mode 100644 src/test/run-pass/issue-38002.rs
create mode 100644 src/test/run-pass/issue-38033.rs
create mode 100644 src/test/run-pass/iter-step-overflow-debug.rs
create mode 100644 src/test/run-pass/iter-step-overflow-ndebug.rs
create mode 100644 src/test/run-pass/iter-zip.rs
create mode 100644 src/test/run-pass/match-byte-array-patterns.rs
create mode 100644 src/test/run-pass/nonzero-enum.rs
create mode 100644 src/test/run-pass/project-cache-issue-37154.rs
create mode 100644 src/test/run-pass/struct-field-shorthand.rs
rename src/test/{compile-fail/struct-pat-associated-path.rs => run-pass/struct-path-associated-type.rs} (59%)
create mode 100644 src/test/run-pass/struct-path-self.rs
create mode 100644 src/test/run-pass/traits-elaborate-type-region.rs
create mode 100644 src/test/run-pass/typeck-fn-to-unsafe-fn-ptr.rs
create mode 100644 src/test/rustdoc/line-breaks.rs
create mode 100644 src/test/rustdoc/playground-empty.rs
create mode 100644 src/test/rustdoc/playground-none.rs
create mode 100644 src/test/rustdoc/playground.rs
rename src/test/{compile-fail-fulldeps/rustc-macro/auxiliary/derive-a-2.rs => rustdoc/rustc-macro-crate.rs} (68%)
create mode 100644 src/test/ui/check_match/issue-35609.rs
create mode 100644 src/test/ui/check_match/issue-35609.stderr
create mode 100644 src/test/ui/compare-method/proj-outlives-region.rs
create mode 100644 src/test/ui/compare-method/proj-outlives-region.stderr
create mode 100644 src/test/ui/compare-method/proj-outlives-region.stdout
rename src/test/{compile-fail/region-bound-extra-bound-in-impl.rs => ui/compare-method/region-extra-2.rs} (94%)
create mode 100644 src/test/ui/compare-method/region-extra-2.stderr
create mode 100644 src/test/ui/compare-method/region-extra.rs
create mode 100644 src/test/ui/compare-method/region-extra.stderr
create mode 100644 src/test/ui/compare-method/region-extra.stdout
create mode 100644 src/test/ui/compare-method/region-unrelated.rs
create mode 100644 src/test/ui/compare-method/region-unrelated.stderr
create mode 100644 src/test/ui/compare-method/region-unrelated.stdout
rename src/test/{compile-fail/issue-2611-5.rs => ui/compare-method/reordered-type-param.rs} (98%)
create mode 100644 src/test/ui/compare-method/reordered-type-param.stderr
rename src/test/{compile-fail/issue-2611-4.rs => ui/compare-method/trait-bound-on-type-parameter.rs} (71%)
create mode 100644 src/test/ui/compare-method/trait-bound-on-type-parameter.stderr
rename src/test/{compile-fail/trait-bounds-impl-comparison-1.rs => ui/compare-method/traits-misc-mismatch-1.rs} (82%)
create mode 100644 src/test/ui/compare-method/traits-misc-mismatch-1.stderr
rename src/test/{compile-fail/trait-bounds-impl-comparison-2.rs => ui/compare-method/traits-misc-mismatch-2.rs} (92%)
create mode 100644 src/test/ui/compare-method/traits-misc-mismatch-2.stderr
create mode 100644 src/test/ui/did_you_mean/issue-36798.rs
create mode 100644 src/test/ui/did_you_mean/issue-36798.stderr
create mode 100644 src/test/ui/did_you_mean/issue-36798_unknown_field.rs
create mode 100644 src/test/ui/did_you_mean/issue-36798_unknown_field.stderr
create mode 100644 src/test/ui/dropck/auxiliary/dropck_eyepatch_extern_crate.rs
create mode 100644 src/test/ui/dropck/dropck-eyepatch-extern-crate.rs
create mode 100644 src/test/ui/dropck/dropck-eyepatch-extern-crate.stderr
create mode 100644 src/test/ui/dropck/dropck-eyepatch-implies-unsafe-impl.rs
create mode 100644 src/test/ui/dropck/dropck-eyepatch-implies-unsafe-impl.stderr
create mode 100644 src/test/ui/dropck/dropck-eyepatch-reorder.rs
create mode 100644 src/test/ui/dropck/dropck-eyepatch-reorder.stderr
create mode 100644 src/test/ui/dropck/dropck-eyepatch.rs
create mode 100644 src/test/ui/dropck/dropck-eyepatch.stderr
create mode 100644 src/test/ui/span/E0057.rs
create mode 100644 src/test/ui/span/E0057.stderr
rename src/test/{compile-fail/borrowck => ui/span}/borrowck-let-suggestion-suffixes.rs (89%)
create mode 100644 src/test/ui/span/borrowck-let-suggestion-suffixes.stderr
rename src/test/{compile-fail/borrowck => ui/span}/borrowck-ref-into-rvalue.rs (100%)
create mode 100644 src/test/ui/span/borrowck-ref-into-rvalue.stderr
rename src/test/{compile-fail => ui/span}/destructor-restrictions.rs (100%)
create mode 100644 src/test/ui/span/destructor-restrictions.stderr
rename src/test/{compile-fail => ui/span}/dropck-object-cycle.rs (89%)
create mode 100644 src/test/ui/span/dropck-object-cycle.stderr
rename src/test/{compile-fail => ui/span}/dropck_arr_cycle_checked.rs (84%)
create mode 100644 src/test/ui/span/dropck_arr_cycle_checked.stderr
rename src/test/{compile-fail => ui/span}/dropck_direct_cycle_with_drop.rs (92%)
create mode 100644 src/test/ui/span/dropck_direct_cycle_with_drop.stderr
rename src/test/{compile-fail => ui/span}/dropck_misc_variants.rs (92%)
create mode 100644 src/test/ui/span/dropck_misc_variants.stderr
rename src/test/{compile-fail => ui/span}/dropck_vec_cycle_checked.rs (85%)
create mode 100644 src/test/ui/span/dropck_vec_cycle_checked.stderr
rename src/test/{compile-fail => ui/span}/issue-23338-locals-die-before-temps-of-body.rs (94%)
create mode 100644 src/test/ui/span/issue-23338-locals-die-before-temps-of-body.stderr
create mode 100644 src/test/ui/span/issue-24690.rs
create mode 100644 src/test/ui/span/issue-24690.stderr
rename src/test/{compile-fail => ui/span}/issue-24805-dropck-child-has-items-via-parent.rs (95%)
create mode 100644 src/test/ui/span/issue-24805-dropck-child-has-items-via-parent.stderr
rename src/test/{compile-fail => ui/span}/issue-24805-dropck-trait-has-items.rs (88%)
create mode 100644 src/test/ui/span/issue-24805-dropck-trait-has-items.stderr
rename src/test/{compile-fail => ui/span}/issue-24895-copy-clone-dropck.rs (93%)
create mode 100644 src/test/ui/span/issue-24895-copy-clone-dropck.stderr
rename src/test/{compile-fail => ui/span}/issue-25199.rs (93%)
create mode 100644 src/test/ui/span/issue-25199.stderr
rename src/test/{compile-fail => ui/span}/issue-26656.rs (96%)
create mode 100644 src/test/ui/span/issue-26656.stderr
rename src/test/{compile-fail => ui/span}/issue-29106.rs (83%)
create mode 100644 src/test/ui/span/issue-29106.stderr
create mode 100644 src/test/ui/span/issue-36537.rs
create mode 100644 src/test/ui/span/issue-36537.stderr
rename src/test/{compile-fail => ui/span}/issue28498-reject-ex1.rs (93%)
create mode 100644 src/test/ui/span/issue28498-reject-ex1.stderr
rename src/test/{compile-fail => ui/span}/issue28498-reject-lifetime-param.rs (92%)
create mode 100644 src/test/ui/span/issue28498-reject-lifetime-param.stderr
rename src/test/{compile-fail => ui/span}/issue28498-reject-passed-to-fn.rs (93%)
create mode 100644 src/test/ui/span/issue28498-reject-passed-to-fn.stderr
rename src/test/{compile-fail => ui/span}/issue28498-reject-trait-bound.rs (92%)
create mode 100644 src/test/ui/span/issue28498-reject-trait-bound.stderr
rename src/test/{compile-fail/impl-trait => ui/span}/loan-extend.rs (76%)
create mode 100644 src/test/ui/span/loan-extend.stderr
rename src/test/{compile-fail => ui/span}/mut-ptr-cant-outlive-ref.rs (100%)
create mode 100644 src/test/ui/span/mut-ptr-cant-outlive-ref.stderr
rename src/test/{compile-fail => ui/span}/range-2.rs (100%)
create mode 100644 src/test/ui/span/range-2.stderr
rename src/test/{compile-fail => ui/span}/regionck-unboxed-closure-lifetimes.rs (100%)
create mode 100644 src/test/ui/span/regionck-unboxed-closure-lifetimes.stderr
rename src/test/{compile-fail => ui/span}/regions-close-over-type-parameter-2.rs (100%)
create mode 100644 src/test/ui/span/regions-close-over-type-parameter-2.stderr
rename src/test/{compile-fail => ui/span}/regions-escape-loop-via-variable.rs (100%)
create mode 100644 src/test/ui/span/regions-escape-loop-via-variable.stderr
rename src/test/{compile-fail => ui/span}/regions-escape-loop-via-vec.rs (97%)
create mode 100644 src/test/ui/span/regions-escape-loop-via-vec.stderr
rename src/test/{compile-fail => ui/span}/regions-infer-borrow-scope-within-loop.rs (100%)
create mode 100644 src/test/ui/span/regions-infer-borrow-scope-within-loop.stderr
rename src/test/{compile-fail => ui/span}/send-is-not-static-ensures-scoping.rs (100%)
create mode 100644 src/test/ui/span/send-is-not-static-ensures-scoping.stderr
rename src/test/{compile-fail => ui/span}/send-is-not-static-std-sync-2.rs (100%)
create mode 100644 src/test/ui/span/send-is-not-static-std-sync-2.stderr
rename src/test/{compile-fail => ui/span}/send-is-not-static-std-sync.rs (100%)
create mode 100644 src/test/ui/span/send-is-not-static-std-sync.stderr
rename src/test/{compile-fail => ui/span}/vec-must-not-hide-type-from-dropck.rs (96%)
create mode 100644 src/test/ui/span/vec-must-not-hide-type-from-dropck.stderr
rename src/test/{compile-fail => ui/span}/vec_refs_data_with_early_death.rs (90%)
create mode 100644 src/test/ui/span/vec_refs_data_with_early_death.stderr
rename src/test/{compile-fail => ui/span}/wf-method-late-bound-regions.rs (100%)
create mode 100644 src/test/ui/span/wf-method-late-bound-regions.stderr
delete mode 100644 src/tools/cargotest/Cargo.lock
delete mode 100644 src/tools/compiletest/Cargo.lock
delete mode 100644 src/tools/error_index_generator/Cargo.lock
delete mode 100644 src/tools/linkchecker/Cargo.lock
delete mode 100644 src/tools/rustbook/Cargo.lock
delete mode 100644 src/tools/tidy/Cargo.lock
create mode 100644 src/tools/tidy/src/pal.rs
diff --git a/README.md b/README.md
index f2385f3151..7360651095 100644
--- a/README.md
+++ b/README.md
@@ -89,6 +89,7 @@ build.
$ pacman -S git \
make \
diffutils \
+ tar \
mingw-w64-x86_64-python2 \
mingw-w64-x86_64-cmake \
mingw-w64-x86_64-gcc
@@ -126,7 +127,7 @@ ones from MSYS if you have it installed). You'll also need Visual Studio 2013 or
newer with the C++ tools. Then all you need to do is to kick off rustbuild.
```
-python .\src\bootstrap\bootstrap.py
+python x.py build
```
Currently rustbuild only works with some known versions of Visual Studio. If you
@@ -136,7 +137,7 @@ by manually calling the appropriate vcvars file before running the bootstrap.
```
CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat"
-python .\src\bootstrap\bootstrap.py
+python x.py build
```
## Building Documentation
diff --git a/RELEASES.md b/RELEASES.md
index 4e815b9b8e..222ad3aa11 100644
--- a/RELEASES.md
+++ b/RELEASES.md
@@ -1,260 +1,3 @@
-Version 1.13.0 (2016-11-10)
-===========================
-
-Language
---------
-
-* [Stabilize the `?` operator][36995]. `?` is a simple way to propagate
- errors, like the `try!` macro, described in [RFC 0243].
-* [Stabilize macros in type position][36014]. Described in [RFC 873].
-* [Stabilize attributes on statements][36995]. Described in [RFC 0016].
-* [Fix `#[derive]` for empty tuple structs/variants][35728]
-* [Fix lifetime rules for 'if' conditions][36029]
-* [Avoid loading and parsing unconfigured non-inline modules][36482]
-
-Compiler
---------
-
-* [Add the `-C link-arg` argument][36574]
-* [Remove the old AST-based backend from rustc_trans][35764]
-* [Don't enable NEON by default on armv7 Linux][35814]
-* [Fix debug line number info for macro expansions][35238]
-* [Do not emit "class method" debuginfo for types that are not
- DICompositeType][36008]
-* [Warn about multiple conflicting #[repr] hints][34623]
-* [When sizing DST, don't double-count nested struct prefixes][36351]
-* [Default RUST_MIN_STACK to 16MiB for now][36505]
-* [Improve rlib metadata format][36551]. Reduces rlib size significantly.
-* [Reject macros with empty repetitions to avoid infinite loop][36721]
-* [Expand macros without recursing to avoid stack overflows][36214]
-
-Diagnostics
------------
-
-* [Replace macro backtraces with labeled local uses][35702]
-* [Improve error message for missplaced doc comments][33922]
-* [Buffer unix and lock windows to prevent message interleaving][35975]
-* [Update lifetime errors to specifically note temporaries][36171]
-* [Special case a few colors for Windows][36178]
-* [Suggest `use self` when such an import resolves][36289]
-* [Be more specific when type parameter shadows primitive type][36338]
-* Many minor improvements
-
-Compile-time Optimizations
---------------------------
-
-* [Compute and cache HIR hashes at beginning][35854]
-* [Don't hash types in loan paths][36004]
-* [Cache projections in trans][35761]
-* [Optimize the parser's last token handling][36527]
-* [Only instantiate #[inline] functions in codegen units referencing
- them][36524]. This leads to big improvements in cases where crates export
- define many inline functions without using them directly.
-* [Lazily allocate TypedArena's first chunk][36592]
-* [Don't allocate during default HashSet creation][36734]
-
-Stabilized APIs
----------------
-
-* [`checked_abs`]
-* [`wrapping_abs`]
-* [`overflowing_abs`]
-* [`RefCell::try_borrow`]
-* [`RefCell::try_borrow_mut`]
-
-Libraries
----------
-
-* [Add `assert_ne!` and `debug_assert_ne!`][35074]
-* [Make `vec_deque::Drain`, `hash_map::Drain`, and `hash_set::Drain`
- covariant][35354]
-* [Implement `AsRef<[T]>` for `std::slice::Iter`][35559]
-* [Implement `Debug` for `std::vec::IntoIter`][35707]
-* [`CString`: avoid excessive growth just to 0-terminate][35871]
-* [Implement `CoerceUnsized` for `{Cell, RefCell, UnsafeCell}`][35627]
-* [Use arc4rand on FreeBSD][35884]
-* [memrchr: Correct aligned offset computation][35969]
-* [Improve Demangling of Rust Symbols][36059]
-* [Use monotonic time in condition variables][35048]
-* [Implement `Debug` for `std::path::{Components,Iter}`][36101]
-* [Implement conversion traits for `char`][35755]
-* [Fix illegal instruction caused by overflow in channel cloning][36104]
-* [Zero first byte of CString on drop][36264]
-* [Inherit overflow checks for sum and product][36372]
-* [Add missing Eq implementations][36423]
-* [Implement `Debug` for `DirEntry`][36631]
-* [When `getaddrinfo` returns `EAI_SYSTEM` retrieve actual error from
- `errno`][36754]
-* [`SipHasher`] is deprecated. Use [`DefaultHasher`].
-* [Implement more traits for `std::io::ErrorKind`][35911]
-* [Optimize BinaryHeap bounds checking][36072]
-* [Work around pointer aliasing issue in `Vec::extend_from_slice`,
- `extend_with_element`][36355]
-* [Fix overflow checking in unsigned pow()][34942]
-
-Cargo
------
-
-* This release includes security fixes to both curl and OpenSSL.
-* [Fix transitive doctests when panic=abort][cargo/3021]
-* [Add --all-features flag to cargo][cargo/3038]
-* [Reject path-based dependencies in `cargo package`][cargo/3060]
-* [Don't parse the home directory more than once][cargo/3078]
-* [Don't try to generate Cargo.lock on empty workspaces][cargo/3092]
-* [Update OpenSSL to 1.0.2j][cargo/3121]
-* [Add license and license_file to cargo metadata output][cargo/3110]
-* [Make crates-io registry URL optional in config; ignore all changes to
- source.crates-io][cargo/3089]
-* [Don't download dependencies from other platforms][cargo/3123]
-* [Build transitive dev-dependencies when needed][cargo/3125]
-* [Add support for per-target rustflags in .cargo/config][cargo/3157]
-* [Avoid updating registry when adding existing deps][cargo/3144]
-* [Warn about path overrides that won't work][cargo/3136]
-* [Use workspaces during `cargo install`][cargo/3146]
-* [Leak mspdbsrv.exe processes on Windows][cargo/3162]
-* [Add --message-format flag][cargo/3000]
-* [Pass target environment for rustdoc][cargo/3205]
-* [Use `CommandExt::exec` for `cargo run` on Unix][cargo/2818]
-* [Update curl and curl-sys][cargo/3241]
-* [Call rustdoc test with the correct cfg flags of a package][cargo/3242]
-
-Tooling
--------
-
-* [rustdoc: Add the `--sysroot` argument][36586]
-* [rustdoc: Fix a couple of issues with the search results][35655]
-* [rustdoc: remove the `!` from macro URLs and titles][35234]
-* [gdb: Fix pretty-printing special-cased Rust types][35585]
-* [rustdoc: Filter more incorrect methods inherited through Deref][36266]
-
-Misc
-----
-
-* [Remove unmaintained style guide][35124]
-* [Add s390x support][36369]
-* [Initial work at Haiku OS support][36727]
-* [Add mips-uclibc targets][35734]
-* [Crate-ify compiler-rt into compiler-builtins][35021]
-* [Add rustc version info (git hash + date) to dist tarball][36213]
-* Many documentation improvements
-
-Compatibility Notes
--------------------
-
-* [`SipHasher`] is deprecated. Use [`DefaultHasher`].
-* [Deny (by default) transmuting from fn item types to pointer-sized
- types][34923]. Continuing the long transition to zero-sized fn items,
- per [RFC 401].
-* [Fix `#[derive]` for empty tuple structs/variants][35728].
- Part of [RFC 1506].
-* [Issue deprecation warnings for safe accesses to extern statics][36173]
-* [Fix lifetime rules for 'if' conditions][36029].
-* [Inherit overflow checks for sum and product][36372].
-* [Forbid user-defined macros named "macro_rules"][36730].
-
-[33922]: https://github.com/rust-lang/rust/pull/33922
-[34623]: https://github.com/rust-lang/rust/pull/34623
-[34923]: https://github.com/rust-lang/rust/pull/34923
-[34942]: https://github.com/rust-lang/rust/pull/34942
-[34982]: https://github.com/rust-lang/rust/pull/34982
-[35021]: https://github.com/rust-lang/rust/pull/35021
-[35048]: https://github.com/rust-lang/rust/pull/35048
-[35074]: https://github.com/rust-lang/rust/pull/35074
-[35124]: https://github.com/rust-lang/rust/pull/35124
-[35234]: https://github.com/rust-lang/rust/pull/35234
-[35238]: https://github.com/rust-lang/rust/pull/35238
-[35354]: https://github.com/rust-lang/rust/pull/35354
-[35559]: https://github.com/rust-lang/rust/pull/35559
-[35585]: https://github.com/rust-lang/rust/pull/35585
-[35627]: https://github.com/rust-lang/rust/pull/35627
-[35655]: https://github.com/rust-lang/rust/pull/35655
-[35702]: https://github.com/rust-lang/rust/pull/35702
-[35707]: https://github.com/rust-lang/rust/pull/35707
-[35728]: https://github.com/rust-lang/rust/pull/35728
-[35734]: https://github.com/rust-lang/rust/pull/35734
-[35755]: https://github.com/rust-lang/rust/pull/35755
-[35761]: https://github.com/rust-lang/rust/pull/35761
-[35764]: https://github.com/rust-lang/rust/pull/35764
-[35814]: https://github.com/rust-lang/rust/pull/35814
-[35854]: https://github.com/rust-lang/rust/pull/35854
-[35871]: https://github.com/rust-lang/rust/pull/35871
-[35884]: https://github.com/rust-lang/rust/pull/35884
-[35911]: https://github.com/rust-lang/rust/pull/35911
-[35969]: https://github.com/rust-lang/rust/pull/35969
-[35975]: https://github.com/rust-lang/rust/pull/35975
-[36004]: https://github.com/rust-lang/rust/pull/36004
-[36008]: https://github.com/rust-lang/rust/pull/36008
-[36014]: https://github.com/rust-lang/rust/pull/36014
-[36029]: https://github.com/rust-lang/rust/pull/36029
-[36059]: https://github.com/rust-lang/rust/pull/36059
-[36072]: https://github.com/rust-lang/rust/pull/36072
-[36101]: https://github.com/rust-lang/rust/pull/36101
-[36104]: https://github.com/rust-lang/rust/pull/36104
-[36171]: https://github.com/rust-lang/rust/pull/36171
-[36173]: https://github.com/rust-lang/rust/pull/36173
-[36178]: https://github.com/rust-lang/rust/pull/36178
-[36213]: https://github.com/rust-lang/rust/pull/36213
-[36214]: https://github.com/rust-lang/rust/pull/36214
-[36264]: https://github.com/rust-lang/rust/pull/36264
-[36266]: https://github.com/rust-lang/rust/pull/36266
-[36289]: https://github.com/rust-lang/rust/pull/36289
-[36338]: https://github.com/rust-lang/rust/pull/36338
-[36351]: https://github.com/rust-lang/rust/pull/36351
-[36355]: https://github.com/rust-lang/rust/pull/36355
-[36369]: https://github.com/rust-lang/rust/pull/36369
-[36372]: https://github.com/rust-lang/rust/pull/36372
-[36423]: https://github.com/rust-lang/rust/pull/36423
-[36482]: https://github.com/rust-lang/rust/pull/36482
-[36505]: https://github.com/rust-lang/rust/pull/36505
-[36524]: https://github.com/rust-lang/rust/pull/36524
-[36527]: https://github.com/rust-lang/rust/pull/36527
-[36551]: https://github.com/rust-lang/rust/pull/36551
-[36574]: https://github.com/rust-lang/rust/pull/36574
-[36586]: https://github.com/rust-lang/rust/pull/36586
-[36592]: https://github.com/rust-lang/rust/pull/36592
-[36631]: https://github.com/rust-lang/rust/pull/36631
-[36639]: https://github.com/rust-lang/rust/pull/36639
-[36721]: https://github.com/rust-lang/rust/pull/36721
-[36727]: https://github.com/rust-lang/rust/pull/36727
-[36730]: https://github.com/rust-lang/rust/pull/36730
-[36734]: https://github.com/rust-lang/rust/pull/36734
-[36754]: https://github.com/rust-lang/rust/pull/36754
-[36995]: https://github.com/rust-lang/rust/pull/36995
-[RFC 0016]: https://github.com/rust-lang/rfcs/blob/master/text/0016-more-attributes.md
-[RFC 0243]: https://github.com/rust-lang/rfcs/blob/master/text/0243-trait-based-exception-handling.md
-[RFC 1506]: https://github.com/rust-lang/rfcs/blob/master/text/1506-adt-kinds.md
-[RFC 401]: https://github.com/rust-lang/rfcs/blob/master/text/0401-coercions.md
-[RFC 873]: https://github.com/rust-lang/rfcs/blob/master/text/0873-type-macros.md
-[cargo/2818]: https://github.com/rust-lang/cargo/pull/2818
-[cargo/3000]: https://github.com/rust-lang/cargo/pull/3000
-[cargo/3021]: https://github.com/rust-lang/cargo/pull/3021
-[cargo/3038]: https://github.com/rust-lang/cargo/pull/3038
-[cargo/3060]: https://github.com/rust-lang/cargo/pull/3060
-[cargo/3078]: https://github.com/rust-lang/cargo/pull/3078
-[cargo/3089]: https://github.com/rust-lang/cargo/pull/3089
-[cargo/3092]: https://github.com/rust-lang/cargo/pull/3092
-[cargo/3110]: https://github.com/rust-lang/cargo/pull/3110
-[cargo/3121]: https://github.com/rust-lang/cargo/pull/3121
-[cargo/3123]: https://github.com/rust-lang/cargo/pull/3123
-[cargo/3125]: https://github.com/rust-lang/cargo/pull/3125
-[cargo/3136]: https://github.com/rust-lang/cargo/pull/3136
-[cargo/3144]: https://github.com/rust-lang/cargo/pull/3144
-[cargo/3146]: https://github.com/rust-lang/cargo/pull/3146
-[cargo/3157]: https://github.com/rust-lang/cargo/pull/3157
-[cargo/3162]: https://github.com/rust-lang/cargo/pull/3162
-[cargo/3205]: https://github.com/rust-lang/cargo/pull/3205
-[cargo/3241]: https://github.com/rust-lang/cargo/pull/3241
-[cargo/3242]: https://github.com/rust-lang/cargo/pull/3242
-[rustup]: https://www.rustup.rs
-[`checked_abs`]: https://doc.rust-lang.org/std/primitive.i32.html#method.checked_abs
-[`wrapping_abs`]: https://doc.rust-lang.org/std/primitive.i32.html#method.wrapping_abs
-[`overflowing_abs`]: https://doc.rust-lang.org/std/primitive.i32.html#method.overflowing_abs
-[`RefCell::try_borrow`]: https://doc.rust-lang.org/std/cell/struct.RefCell.html#method.try_borrow
-[`RefCell::try_borrow_mut`]: https://doc.rust-lang.org/std/cell/struct.RefCell.html#method.try_borrow_mut
-[`SipHasher`]: https://doc.rust-lang.org/std/hash/struct.SipHasher.html
-[`DefaultHasher`]: https://doc.rust-lang.org/std/collections/hash_map/struct.DefaultHasher.html
-
-
Version 1.12.1 (2016-10-20)
===========================
@@ -338,7 +81,7 @@ Diagnostics
Most common editors supporting Rust have been updated to work with it. It was
previously described [on the Rust blog]
(https://blog.rust-lang.org/2016/08/10/Shape-of-errors-to-come.html).
-* [In error descriptions, references are now described in plain english,
+* [In error descriptions, references are now described in plain English,
instead of as "&-ptr"]
(https://github.com/rust-lang/rust/pull/35611)
* [In error type descriptions, unknown numeric types are named `{integer}` or
@@ -432,7 +175,7 @@ Libraries
(https://github.com/rust-lang/rust/pull/34946)
* [`hash_map::Entry`, `hash_map::VacantEntry` and `hash_map::OccupiedEntry`
implement `Debug`]
- (https://github.com/rust-lang/rust/pull/34946)
+ (https://github.com/rust-lang/rust/pull/34937)
* [`btree_map::Entry`, `btree_map::VacantEntry` and `btree_map::OccupiedEntry`
implement `Debug`]
(https://github.com/rust-lang/rust/pull/34885)
@@ -1169,7 +912,7 @@ Cargo
Performance
-----------
-* [The time complexity of comparing variables for equivalence during type
+* [The time complexity of comparing variables for equivalence during type
unification is reduced from _O_(_n_!) to _O_(_n_)][1.9tu]. This leads
to major compilation time improvement in some scenarios.
* [`ToString` is specialized for `str`, giving it the same performance
diff --git a/configure b/configure
index fd0397e5f8..85a3dd4b93 100755
--- a/configure
+++ b/configure
@@ -507,11 +507,16 @@ case $CFG_CPUTYPE in
CFG_CPUTYPE=arm
;;
- armv7l)
+ armv6l)
CFG_CPUTYPE=arm
CFG_OSTYPE="${CFG_OSTYPE}eabihf"
;;
+ armv7l)
+ CFG_CPUTYPE=armv7
+ CFG_OSTYPE="${CFG_OSTYPE}eabihf"
+ ;;
+
aarch64)
CFG_CPUTYPE=aarch64
;;
@@ -610,6 +615,7 @@ opt docs 1 "build standard library documentation"
opt compiler-docs 0 "build compiler documentation"
opt optimize-tests 1 "build tests with optimizations"
opt debuginfo-tests 0 "build tests with debugger metadata"
+opt quiet-tests 0 "enable quieter output when running tests"
opt libcpp 1 "build llvm with libc++ instead of libstdc++ when using clang"
opt llvm-assertions 0 "build LLVM with assertions"
opt debug-assertions 0 "build with debugging assertions"
@@ -636,6 +642,7 @@ opt_nosave optimize-llvm 1 "build optimized LLVM"
opt_nosave llvm-assertions 0 "build LLVM with assertions"
opt_nosave debug-assertions 0 "build with debugging assertions"
opt_nosave debuginfo 0 "build with debugger metadata"
+opt_nosave debuginfo-lines 0 "build with line number debugger metadata"
opt_nosave debug-jemalloc 0 "build jemalloc with --enable-debug --enable-fill"
valopt localstatedir "/var/lib" "local state directory"
@@ -645,7 +652,6 @@ valopt datadir "${CFG_PREFIX}/share" "install data"
valopt infodir "${CFG_PREFIX}/share/info" "install additional info"
valopt llvm-root "" "set LLVM root"
valopt python "" "set path to python"
-valopt nodejs "" "set path to nodejs"
valopt jemalloc-root "" "set directory where libjemalloc_pic.a is located"
valopt build "${DEFAULT_BUILD}" "GNUs ./configure syntax LLVM build triple"
valopt android-cross-path "" "Android NDK standalone path (deprecated)"
@@ -654,7 +660,12 @@ valopt arm-linux-androideabi-ndk "" "arm-linux-androideabi NDK standalone path"
valopt armv7-linux-androideabi-ndk "" "armv7-linux-androideabi NDK standalone path"
valopt aarch64-linux-android-ndk "" "aarch64-linux-android NDK standalone path"
valopt nacl-cross-path "" "NaCl SDK path (Pepper Canary is recommended). Must be absolute!"
-valopt musl-root "/usr/local" "MUSL root installation directory"
+valopt musl-root "/usr/local" "MUSL root installation directory (deprecated)"
+valopt musl-root-x86_64 "/usr/local" "x86_64-unknown-linux-musl install directory"
+valopt musl-root-i686 "/usr/local" "i686-unknown-linux-musl install directory"
+valopt musl-root-arm "/usr/local" "arm-unknown-linux-musleabi install directory"
+valopt musl-root-armhf "/usr/local" "arm-unknown-linux-musleabihf install directory"
+valopt musl-root-armv7 "/usr/local" "armv7-unknown-linux-musleabihf install directory"
valopt extra-filename "" "Additional data that is hashed and passed to the -C extra-filename flag"
if [ -e ${CFG_SRC_DIR}.git ]
@@ -717,8 +728,27 @@ case "$CFG_RELEASE_CHANNEL" in
nightly )
msg "overriding settings for $CFG_RELEASE_CHANNEL"
CFG_ENABLE_LLVM_ASSERTIONS=1
+
+ # FIXME(#37364) shouldn't have to disable this on windows-gnu
+ case "$CFG_BUILD" in
+ *-pc-windows-gnu)
+ ;;
+ *)
+ CFG_ENABLE_DEBUGINFO_LINES=1
+ ;;
+ esac
;;
- dev | beta | stable)
+ beta | stable)
+ msg "overriding settings for $CFG_RELEASE_CHANNEL"
+ case "$CFG_BUILD" in
+ *-pc-windows-gnu)
+ ;;
+ *)
+ CFG_ENABLE_DEBUGINFO_LINES=1
+ ;;
+ esac
+ ;;
+ dev)
;;
*)
err "release channel must be 'dev', 'nightly', 'beta' or 'stable'"
@@ -748,6 +778,7 @@ if [ -n "$CFG_DISABLE_OPTIMIZE_LLVM" ]; then putvar CFG_DISABLE_OPTIMIZE_LLVM; f
if [ -n "$CFG_ENABLE_LLVM_ASSERTIONS" ]; then putvar CFG_ENABLE_LLVM_ASSERTIONS; fi
if [ -n "$CFG_ENABLE_DEBUG_ASSERTIONS" ]; then putvar CFG_ENABLE_DEBUG_ASSERTIONS; fi
if [ -n "$CFG_ENABLE_DEBUGINFO" ]; then putvar CFG_ENABLE_DEBUGINFO; fi
+if [ -n "$CFG_ENABLE_DEBUGINFO_LINES" ]; then putvar CFG_ENABLE_DEBUGINFO_LINES; fi
if [ -n "$CFG_ENABLE_DEBUG_JEMALLOC" ]; then putvar CFG_ENABLE_DEBUG_JEMALLOC; fi
step_msg "looking for build programs"
@@ -762,9 +793,6 @@ if [ $(echo $python_version | grep -c '^Python 2\.7') -ne 1 ]; then
err "Found $python_version, but Python 2.7 is required"
fi
-# Checking for node, but not required
-probe CFG_NODEJS nodejs node
-
# If we have no git directory then we are probably a tarball distribution
# and shouldn't attempt to load submodules
if [ ! -e ${CFG_SRC_DIR}.git ]
@@ -840,13 +868,6 @@ then
fi
fi
-if [ -n "$CFG_GDB" ]
-then
- # Store GDB's version
- CFG_GDB_VERSION=$($CFG_GDB --version 2>/dev/null | head -1)
- putvar CFG_GDB_VERSION
-fi
-
if [ -n "$CFG_LLDB" ]
then
# Store LLDB's version
@@ -1216,14 +1237,6 @@ do
fi
;;
-
- x86_64-*-musl | arm-*-musleabi)
- if [ ! -f $CFG_MUSL_ROOT/lib/libc.a ]
- then
- err "musl libc $CFG_MUSL_ROOT/lib/libc.a not found"
- fi
- ;;
-
*-msvc)
# There are three builds of cmake on windows: MSVC, MinGW and Cygwin
# The Cygwin build does not have generators for Visual Studio, so
@@ -1642,8 +1655,8 @@ do
("ccache gcc")
LLVM_CXX_32="ccache"
LLVM_CC_32="ccache"
- LLVM_CXX_32_ARG1="clang++"
- LLVM_CC_32_ARG1="clang"
+ LLVM_CXX_32_ARG1="g++"
+ LLVM_CC_32_ARG1="gcc"
LLVM_CXX_64="ccache"
LLVM_CC_64="ccache"
@@ -1768,7 +1781,7 @@ do
CMAKE_ARGS="$CMAKE_ARGS -DLLVM_ENABLE_ASSERTIONS=ON"
fi
- CMAKE_ARGS="$CMAKE_ARGS -DLLVM_TARGETS_TO_BUILD='X86;ARM;AArch64;Mips;PowerPC;SystemZ'"
+ CMAKE_ARGS="$CMAKE_ARGS -DLLVM_TARGETS_TO_BUILD='X86;ARM;AArch64;Mips;PowerPC;SystemZ;JSBackend'"
CMAKE_ARGS="$CMAKE_ARGS -G '$CFG_CMAKE_GENERATOR'"
CMAKE_ARGS="$CMAKE_ARGS $CFG_LLVM_SRC_DIR"
diff --git a/mk/cfg/aarch64-unknown-fuchsia.mk b/mk/cfg/aarch64-unknown-fuchsia.mk
new file mode 100644
index 0000000000..34aee77ae2
--- /dev/null
+++ b/mk/cfg/aarch64-unknown-fuchsia.mk
@@ -0,0 +1 @@
+# rustbuild-only target
diff --git a/mk/cfg/wasm32-unknown-emscripten.mk b/mk/cfg/wasm32-unknown-emscripten.mk
new file mode 100644
index 0000000000..997bdfbf03
--- /dev/null
+++ b/mk/cfg/wasm32-unknown-emscripten.mk
@@ -0,0 +1,24 @@
+# wasm32-unknown-emscripten configuration
+CC_wasm32-unknown-emscripten=emcc
+CXX_wasm32-unknown-emscripten=em++
+CPP_wasm32-unknown-emscripten=$(CPP)
+AR_wasm32-unknown-emscripten=emar
+CFG_LIB_NAME_wasm32-unknown-emscripten=lib$(1).so
+CFG_STATIC_LIB_NAME_wasm32-unknown-emscripten=lib$(1).a
+CFG_LIB_GLOB_wasm32-unknown-emscripten=lib$(1)-*.so
+CFG_LIB_DSYM_GLOB_wasm32-unknown-emscripten=lib$(1)-*.dylib.dSYM
+CFG_JEMALLOC_CFLAGS_wasm32-unknown-emscripten := -m32 $(CFLAGS)
+CFG_GCCISH_CFLAGS_wasm32-unknown-emscripten := -g -fPIC -m32 -s BINARYEN=1 $(CFLAGS)
+CFG_GCCISH_CXXFLAGS_wasm32-unknown-emscripten := -fno-rtti -s BINARYEN=1 $(CXXFLAGS)
+CFG_GCCISH_LINK_FLAGS_wasm32-unknown-emscripten := -shared -fPIC -ldl -pthread -lrt -g -m32 -s BINARYEN=1
+CFG_GCCISH_DEF_FLAG_wasm32-unknown-emscripten := -Wl,--export-dynamic,--dynamic-list=
+CFG_LLC_FLAGS_wasm32-unknown-emscripten :=
+CFG_INSTALL_NAME_wasm32-unknown-emscripten =
+CFG_EXE_SUFFIX_wasm32-unknown-emscripten =
+CFG_WINDOWSY_wasm32-unknown-emscripten :=
+CFG_UNIXY_wasm32-unknown-emscripten := 1
+CFG_LDPATH_wasm32-unknown-emscripten :=
+CFG_RUN_wasm32-unknown-emscripten=$(2)
+CFG_RUN_TARG_wasm32-unknown-emscripten=$(call CFG_RUN_wasm32-unknown-emscripten,,$(2))
+CFG_GNU_TRIPLE_wasm32-unknown-emscripten := wasm32-unknown-emscripten
+CFG_DISABLE_JEMALLOC_wasm32-unknown-emscripten := 1
diff --git a/mk/cfg/x86_64-unknown-fuchsia.mk b/mk/cfg/x86_64-unknown-fuchsia.mk
new file mode 100644
index 0000000000..34aee77ae2
--- /dev/null
+++ b/mk/cfg/x86_64-unknown-fuchsia.mk
@@ -0,0 +1 @@
+# rustbuild-only target
diff --git a/mk/crates.mk b/mk/crates.mk
index 86bb3a8ca0..25192bfd27 100644
--- a/mk/crates.mk
+++ b/mk/crates.mk
@@ -59,9 +59,9 @@ RUSTC_CRATES := rustc rustc_typeck rustc_mir rustc_borrowck rustc_resolve rustc_
rustc_trans rustc_back rustc_llvm rustc_privacy rustc_lint \
rustc_data_structures rustc_platform_intrinsics rustc_errors \
rustc_plugin rustc_metadata rustc_passes rustc_save_analysis \
- rustc_const_eval rustc_const_math rustc_incremental rustc_macro
-HOST_CRATES := syntax syntax_ext proc_macro syntax_pos $(RUSTC_CRATES) rustdoc fmt_macros \
- flate arena graphviz log serialize
+ rustc_const_eval rustc_const_math rustc_incremental proc_macro
+HOST_CRATES := syntax syntax_ext proc_macro_tokens proc_macro_plugin syntax_pos $(RUSTC_CRATES) \
+ rustdoc fmt_macros flate arena graphviz log serialize
TOOLS := compiletest rustdoc rustc rustbook error_index_generator
DEPS_core :=
@@ -101,9 +101,10 @@ DEPS_term := std
DEPS_test := std getopts term native:rust_test_helpers
DEPS_syntax := std term serialize log arena libc rustc_bitflags rustc_unicode rustc_errors syntax_pos
-DEPS_syntax_ext := syntax syntax_pos rustc_errors fmt_macros rustc_macro
-DEPS_proc_macro := syntax syntax_pos rustc_plugin log
+DEPS_syntax_ext := syntax syntax_pos rustc_errors fmt_macros proc_macro
DEPS_syntax_pos := serialize
+DEPS_proc_macro_tokens := syntax syntax_pos log
+DEPS_proc_macro_plugin := syntax syntax_pos rustc_plugin log proc_macro_tokens
DEPS_rustc_const_math := std syntax log serialize
DEPS_rustc_const_eval := rustc_const_math rustc syntax log serialize \
@@ -118,15 +119,15 @@ DEPS_rustc_data_structures := std log serialize libc
DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back rustc_borrowck \
rustc_typeck rustc_mir rustc_resolve log syntax serialize rustc_llvm \
rustc_trans rustc_privacy rustc_lint rustc_plugin \
- rustc_metadata syntax_ext proc_macro \
+ rustc_metadata syntax_ext proc_macro_plugin \
rustc_passes rustc_save_analysis rustc_const_eval \
- rustc_incremental syntax_pos rustc_errors rustc_macro
+ rustc_incremental syntax_pos rustc_errors proc_macro rustc_data_structures
DEPS_rustc_errors := log libc serialize syntax_pos
DEPS_rustc_lint := rustc log syntax syntax_pos rustc_const_eval
DEPS_rustc_llvm := native:rustllvm libc std rustc_bitflags
-DEPS_rustc_macro := std syntax
+DEPS_proc_macro := std syntax
DEPS_rustc_metadata := rustc syntax syntax_pos rustc_errors rustc_const_math \
- rustc_macro syntax_ext
+ proc_macro syntax_ext
DEPS_rustc_passes := syntax syntax_pos rustc core rustc_const_eval rustc_errors
DEPS_rustc_mir := rustc syntax syntax_pos rustc_const_math rustc_const_eval rustc_bitflags
DEPS_rustc_resolve := arena rustc log syntax syntax_pos rustc_errors
diff --git a/mk/llvm.mk b/mk/llvm.mk
index d6f812049e..5a91f5fcaa 100644
--- a/mk/llvm.mk
+++ b/mk/llvm.mk
@@ -36,22 +36,27 @@ endif
# If CFG_LLVM_ROOT is defined then we don't build LLVM ourselves
ifeq ($(CFG_LLVM_ROOT),)
-LLVM_STAMP_$(1) = $$(CFG_LLVM_BUILD_DIR_$(1))/llvm-auto-clean-stamp
+LLVM_STAMP_$(1) = $(S)src/rustllvm/llvm-auto-clean-trigger
LLVM_DONE_$(1) = $$(CFG_LLVM_BUILD_DIR_$(1))/llvm-finished-building
$$(LLVM_CONFIG_$(1)): $$(LLVM_DONE_$(1))
-$$(LLVM_DONE_$(1)): $$(LLVM_DEPS_TARGET_$(1)) $$(LLVM_STAMP_$(1))
- @$$(call E, cmake: llvm)
ifneq ($$(CFG_NINJA),)
- $$(Q)$$(CFG_NINJA) -C $$(CFG_LLVM_BUILD_DIR_$(1))
+BUILD_LLVM_$(1) := $$(CFG_NINJA) -C $$(CFG_LLVM_BUILD_DIR_$(1))
else ifeq ($$(findstring msvc,$(1)),msvc)
- $$(Q)$$(CFG_CMAKE) --build $$(CFG_LLVM_BUILD_DIR_$(1)) \
- --config $$(LLVM_BUILD_CONFIG_MODE)
+BUILD_LLVM_$(1) := $$(CFG_CMAKE) --build $$(CFG_LLVM_BUILD_DIR_$(1)) \
+ --config $$(LLVM_BUILD_CONFIG_MODE)
else
- $$(Q)$$(MAKE) -C $$(CFG_LLVM_BUILD_DIR_$(1))
+BUILD_LLVM_$(1) := $$(MAKE) -C $$(CFG_LLVM_BUILD_DIR_$(1))
endif
- $$(Q)touch $$@
+
+$$(LLVM_DONE_$(1)): $$(LLVM_DEPS_TARGET_$(1)) $$(LLVM_STAMP_$(1))
+ @$$(call E, cmake: llvm)
+ $$(Q)if ! cmp $$(LLVM_STAMP_$(1)) $$(LLVM_DONE_$(1)); then \
+ $$(MAKE) clean-llvm$(1); \
+ $$(BUILD_LLVM_$(1)); \
+ fi
+ $$(Q)cp $$(LLVM_STAMP_$(1)) $$@
ifneq ($$(CFG_NINJA),)
clean-llvm$(1):
@@ -75,17 +80,6 @@ endif
$$(LLVM_AR_$(1)): $$(LLVM_CONFIG_$(1))
-# This is used to independently force an LLVM clean rebuild
-# when we changed something not otherwise captured by builtin
-# dependencies. In these cases, commit a change that touches
-# the stamp in the source dir.
-$$(LLVM_STAMP_$(1)): $$(S)src/rustllvm/llvm-auto-clean-trigger
- @$$(call E, make: cleaning llvm)
- $$(Q)touch $$@.start_time
- $$(Q)$$(MAKE) clean-llvm$(1)
- @$$(call E, make: done cleaning llvm)
- touch -r $$@.start_time $$@ && rm $$@.start_time
-
ifeq ($$(CFG_ENABLE_LLVM_STATIC_STDCPP),1)
LLVM_STDCPP_RUSTFLAGS_$(1) = -L "$$(dir $$(shell $$(CC_$(1)) $$(CFG_GCCISH_CFLAGS_$(1)) \
-print-file-name=lib$(CFG_STDCPP_NAME).a))"
diff --git a/mk/main.mk b/mk/main.mk
index 45c085c27c..fd0464aab8 100644
--- a/mk/main.mk
+++ b/mk/main.mk
@@ -13,12 +13,12 @@
######################################################################
# The version number
-CFG_RELEASE_NUM=1.13.0
+CFG_RELEASE_NUM=1.14.0
# An optional number to put after the label, e.g. '.2' -> '-beta.2'
# NB Make sure it starts with a dot to conform to semver pre-release
# versions (section 9)
-CFG_PRERELEASE_VERSION=.3
+CFG_PRERELEASE_VERSION=.5
ifeq ($(CFG_RELEASE_CHANNEL),stable)
# This is the normal semver version string, e.g. "0.12.0", "0.12.0-nightly"
@@ -53,11 +53,12 @@ endif
# versions in the same place
CFG_FILENAME_EXTRA=$(shell printf '%s' $(CFG_RELEASE)$(CFG_EXTRA_FILENAME) | $(CFG_HASH_COMMAND))
-# If local-rust is the same as the current version, then force a local-rebuild
+# If local-rust is the same major.minor as the current version, then force a local-rebuild
ifdef CFG_ENABLE_LOCAL_RUST
-ifeq ($(CFG_RELEASE),\
- $(shell $(S)src/etc/local_stage0.sh --print-rustc-release $(CFG_LOCAL_RUST_ROOT)))
- CFG_INFO := $(info cfg: auto-detected local-rebuild $(CFG_RELEASE))
+SEMVER_PREFIX=$(shell echo $(CFG_RELEASE_NUM) | grep -E -o '^[[:digit:]]+\.[[:digit:]]+')
+LOCAL_RELEASE=$(shell $(S)src/etc/local_stage0.sh --print-rustc-release $(CFG_LOCAL_RUST_ROOT))
+ifneq (,$(filter $(SEMVER_PREFIX).%,$(LOCAL_RELEASE)))
+ CFG_INFO := $(info cfg: auto-detected local-rebuild using $(LOCAL_RELEASE))
CFG_ENABLE_LOCAL_REBUILD = 1
endif
endif
@@ -141,6 +142,9 @@ endif
ifdef CFG_ENABLE_DEBUGINFO
$(info cfg: enabling debuginfo (CFG_ENABLE_DEBUGINFO))
CFG_RUSTC_FLAGS += -g
+else ifdef CFG_ENABLE_DEBUGINFO_LINES
+ $(info cfg: enabling line number debuginfo (CFG_ENABLE_DEBUGINFO_LINES))
+ CFG_RUSTC_FLAGS += -Cdebuginfo=1
endif
ifdef SAVE_TEMPS
@@ -281,7 +285,7 @@ endif
# LLVM macros
######################################################################
-LLVM_OPTIONAL_COMPONENTS=x86 arm aarch64 mips powerpc pnacl systemz
+LLVM_OPTIONAL_COMPONENTS=x86 arm aarch64 mips powerpc pnacl systemz jsbackend
LLVM_REQUIRED_COMPONENTS=ipo bitreader bitwriter linker asmparser mcjit \
interpreter instrumentation
@@ -376,7 +380,7 @@ endif
# FIXME: Transitionary measure to bootstrap using the old bootstrap logic.
# Remove this once the bootstrap compiler uses the new login in Issue #36548.
-export RUSTC_BOOTSTRAP_KEY=5c6cf767
+export RUSTC_BOOTSTRAP_KEY=62b3e239
######################################################################
# Per-stage targets and runner
diff --git a/mk/tests.mk b/mk/tests.mk
index fc1f4b5561..f3d8f0387b 100644
--- a/mk/tests.mk
+++ b/mk/tests.mk
@@ -632,6 +632,7 @@ endif
# is a separate choice from whether to pass `-g` when building the
# compiler and standard library themselves.
CTEST_RUSTC_FLAGS := $$(subst -g,,$$(CTEST_RUSTC_FLAGS))
+CTEST_RUSTC_FLAGS := $$(subst -Cdebuginfo=1,,$$(CTEST_RUSTC_FLAGS))
ifdef CFG_ENABLE_DEBUGINFO_TESTS
CTEST_RUSTC_FLAGS += -g
endif
@@ -647,7 +648,7 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) = \
--host $(3) \
--docck-python $$(CFG_PYTHON) \
--lldb-python $$(CFG_LLDB_PYTHON) \
- --gdb-version="$(CFG_GDB_VERSION)" \
+ --gdb="$(CFG_GDB)" \
--lldb-version="$(CFG_LLDB_VERSION)" \
--llvm-version="$$(LLVM_VERSION_$(3))" \
--android-cross-path=$(CFG_ARM_LINUX_ANDROIDEABI_NDK) \
diff --git a/src/bootstrap/Cargo.lock b/src/bootstrap/Cargo.lock
deleted file mode 100644
index 36b94e4ebe..0000000000
--- a/src/bootstrap/Cargo.lock
+++ /dev/null
@@ -1,180 +0,0 @@
-[root]
-name = "bootstrap"
-version = "0.0.0"
-dependencies = [
- "build_helper 0.1.0",
- "cmake 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
- "filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "gcc 0.3.31 (git+https://github.com/alexcrichton/gcc-rs)",
- "getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
- "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "md5 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "num_cpus 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 0.1.73 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
- "toml 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "aho-corasick"
-version = "0.5.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "build_helper"
-version = "0.1.0"
-
-[[package]]
-name = "cmake"
-version = "0.1.17"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "gcc 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "filetime"
-version = "0.1.10"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "gcc"
-version = "0.3.31"
-source = "git+https://github.com/alexcrichton/gcc-rs#b8e2400883f1a2749b323354dad372cdd1c838c7"
-
-[[package]]
-name = "gcc"
-version = "0.3.31"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
-name = "getopts"
-version = "0.2.14"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
-name = "kernel32-sys"
-version = "0.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "libc"
-version = "0.2.10"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
-name = "md5"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
-name = "memchr"
-version = "0.1.11"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "num_cpus"
-version = "0.2.11"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "regex"
-version = "0.1.73"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "aho-corasick 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex-syntax 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "thread_local 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "regex-syntax"
-version = "0.3.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
-name = "rustc-serialize"
-version = "0.3.19"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
-name = "thread-id"
-version = "2.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "thread_local"
-version = "0.2.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "toml"
-version = "0.1.28"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
-name = "utf8-ranges"
-version = "0.1.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
-name = "winapi"
-version = "0.2.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[[package]]
-name = "winapi-build"
-version = "0.1.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[metadata]
-"checksum aho-corasick 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2b3fb52b09c1710b961acb35390d514be82e4ac96a9969a8e38565a29b878dc9"
-"checksum cmake 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "dfcf5bcece56ef953b8ea042509e9dcbdfe97820b7e20d86beb53df30ed94978"
-"checksum filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "5363ab8e4139b8568a6237db5248646e5a8a2f89bd5ccb02092182b11fd3e922"
-"checksum gcc 0.3.31 (git+https://github.com/alexcrichton/gcc-rs)" = ""
-"checksum gcc 0.3.31 (registry+https://github.com/rust-lang/crates.io-index)" = "cfe877476e53690ebb0ce7325d0bf43e198d9500291b54b3c65e518de5039b07"
-"checksum getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9047cfbd08a437050b363d35ef160452c5fe8ea5187ae0a624708c91581d685"
-"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
-"checksum libc 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "55f3730be7e803cf350d32061958171731c2395831fbd67a61083782808183e0"
-"checksum md5 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a5539a8dee9b4ae308c9c406a379838b435a8f2c84cf9fedc6d5a576be9888db"
-"checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20"
-"checksum num_cpus 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "51fedae97a05f7353612fe017ab705a37e6db8f4d67c5c6fe739a9e70d6eed09"
-"checksum regex 0.1.73 (registry+https://github.com/rust-lang/crates.io-index)" = "56b7ee9f764ecf412c6e2fff779bca4b22980517ae335a21aeaf4e32625a5df2"
-"checksum regex-syntax 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "31040aad7470ad9d8c46302dcffba337bb4289ca5da2e3cd6e37b64109a85199"
-"checksum rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "6159e4e6e559c81bd706afe9c8fd68f547d3e851ce12e76b1de7914bab61691b"
-"checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03"
-"checksum thread_local 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "55dd963dbaeadc08aa7266bf7f91c3154a7805e32bb94b820b769d2ef3b4744d"
-"checksum toml 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)" = "fcd27a04ca509aff336ba5eb2abc58d456f52c4ff64d9724d88acb85ead560b6"
-"checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f"
-"checksum winapi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "4dfaaa8fbdaa618fa6914b59b2769d690dd7521920a18d84b42d254678dd5fd4"
-"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
diff --git a/src/bootstrap/Cargo.toml b/src/bootstrap/Cargo.toml
index b19545590b..9d44ca033e 100644
--- a/src/bootstrap/Cargo.toml
+++ b/src/bootstrap/Cargo.toml
@@ -27,9 +27,10 @@ num_cpus = "0.2"
toml = "0.1"
getopts = "0.2"
rustc-serialize = "0.3"
-winapi = "0.2"
-kernel32-sys = "0.2"
-gcc = { git = "https://github.com/alexcrichton/gcc-rs" }
+gcc = "0.3.36"
libc = "0.2"
md5 = "0.1"
-regex = "0.1.73"
+
+[target.'cfg(windows)'.dependencies]
+winapi = "0.2"
+kernel32-sys = "0.2"
diff --git a/src/bootstrap/README.md b/src/bootstrap/README.md
index 57d644d635..f73f41ffae 100644
--- a/src/bootstrap/README.md
+++ b/src/bootstrap/README.md
@@ -10,24 +10,72 @@ system.
## Using rustbuild
-When configuring Rust via `./configure`, pass the following to enable building
-via this build system:
+The rustbuild build system has a primary entry point, a top level `x.py` script:
```
-./configure --enable-rustbuild
-make
+python ./x.py build
```
-Afterwards the `Makefile` which is generated will have a few commands like
-`make check`, `make tidy`, etc. For finer-grained control, the
-`bootstrap.py` entry point can be used:
+Note that if you're on Unix you should be able to execute the script directly:
```
-python src/bootstrap/bootstrap.py
+./x.py build
```
-This accepts a number of options like `--stage` and `--step` which can configure
-what's actually being done.
+The script accepts commands, flags, and filters to determine what to do:
+
+* `build` - a general purpose command for compiling code. Alone `build` will
+ bootstrap the entire compiler, and otherwise arguments passed indicate what to
+ build. For example:
+
+ ```
+ # build the whole compiler
+ ./x.py build
+
+ # build the stage1 compier
+ ./x.py build --stage 1
+
+ # build stage0 libstd
+ ./x.py build --stage 0 src/libstd
+
+ # build a particular crate in stage0
+ ./x.py build --stage 0 src/libtest
+ ```
+
+* `test` - a command for executing unit tests. Like the `build` command this
+ will execute the entire test suite by default, and otherwise it can be used to
+ select which test suite is run:
+
+ ```
+ # run all unit tests
+ ./x.py test
+
+ # execute the run-pass test suite
+ ./x.py test src/test/run-pass
+
+ # execute only some tests in the run-pass test suite
+ ./x.py test src/test/run-pass --filter my-filter
+
+ # execute tests in the standard library in stage0
+ ./x.py test --stage 0 src/libstd
+
+ # execute all doc tests
+ ./x.py test src/doc
+ ```
+
+* `doc` - a command for building documentation. Like above can take arguments
+ for what to document.
+
+If you're more used to `./configure` and `make`, however, then you can also
+configure the build system to use rustbuild instead of the old makefiles:
+
+```
+./configure --enable-rustbuild
+make
+```
+
+Afterwards the `Makefile` which is generated will have a few commands like
+`make check`, `make tidy`, etc.
## Configuring rustbuild
@@ -47,7 +95,7 @@ being invoked manually (via the python script).
The rustbuild build system goes through a few phases to actually build the
compiler. What actually happens when you invoke rustbuild is:
-1. The entry point script, `src/bootstrap/bootstrap.py` is run. This script is
+1. The entry point script, `x.py` is run. This script is
responsible for downloading the stage0 compiler/Cargo binaries, and it then
compiles the build system itself (this folder). Finally, it then invokes the
actual `bootstrap` binary build system.
diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs
index a70a15b383..879eca60cc 100644
--- a/src/bootstrap/bin/rustc.rs
+++ b/src/bootstrap/bin/rustc.rs
@@ -36,8 +36,9 @@ fn main() {
let args = env::args_os().skip(1).collect::>();
// Detect whether or not we're a build script depending on whether --target
// is passed (a bit janky...)
- let target = args.windows(2).find(|w| &*w[0] == "--target")
- .and_then(|w| w[1].to_str());
+ let target = args.windows(2)
+ .find(|w| &*w[0] == "--target")
+ .and_then(|w| w[1].to_str());
let version = args.iter().find(|w| &**w == "-vV");
// Build scripts always use the snapshot compiler which is guaranteed to be
@@ -64,9 +65,10 @@ fn main() {
let mut cmd = Command::new(rustc);
cmd.args(&args)
- .arg("--cfg").arg(format!("stage{}", stage))
- .env(bootstrap::util::dylib_path_var(),
- env::join_paths(&dylib_path).unwrap());
+ .arg("--cfg")
+ .arg(format!("stage{}", stage))
+ .env(bootstrap::util::dylib_path_var(),
+ env::join_paths(&dylib_path).unwrap());
if let Some(target) = target {
// The stage0 compiler has a special sysroot distinct from what we
@@ -101,11 +103,9 @@ fn main() {
// This... is a bit of a hack how we detect this. Ideally this
// information should be encoded in the crate I guess? Would likely
// require an RFC amendment to RFC 1513, however.
- let is_panic_abort = args.windows(2).any(|a| {
- &*a[0] == "--crate-name" && &*a[1] == "panic_abort"
- });
- // FIXME(stage0): remove this `stage != "0"` condition
- if is_panic_abort && stage != "0" {
+ let is_panic_abort = args.windows(2)
+ .any(|a| &*a[0] == "--crate-name" && &*a[1] == "panic_abort");
+ if is_panic_abort {
cmd.arg("-C").arg("panic=abort");
}
@@ -113,9 +113,11 @@ fn main() {
// code.
if env::var("RUSTC_DEBUGINFO") == Ok("true".to_string()) {
cmd.arg("-g");
+ } else if env::var("RUSTC_DEBUGINFO_LINES") == Ok("true".to_string()) {
+ cmd.arg("-Cdebuginfo=1");
}
let debug_assertions = match env::var("RUSTC_DEBUG_ASSERTIONS") {
- Ok(s) => if s == "true" {"y"} else {"n"},
+ Ok(s) => if s == "true" { "y" } else { "n" },
Err(..) => "n",
};
cmd.arg("-C").arg(format!("debug-assertions={}", debug_assertions));
diff --git a/src/bootstrap/bin/rustdoc.rs b/src/bootstrap/bin/rustdoc.rs
index 658ff358d6..67358e540d 100644
--- a/src/bootstrap/bin/rustdoc.rs
+++ b/src/bootstrap/bin/rustdoc.rs
@@ -29,10 +29,12 @@ fn main() {
let mut cmd = Command::new(rustdoc);
cmd.args(&args)
- .arg("--cfg").arg(format!("stage{}", stage))
- .arg("--cfg").arg("dox")
- .env(bootstrap::util::dylib_path_var(),
- env::join_paths(&dylib_path).unwrap());
+ .arg("--cfg")
+ .arg(format!("stage{}", stage))
+ .arg("--cfg")
+ .arg("dox")
+ .env(bootstrap::util::dylib_path_var(),
+ env::join_paths(&dylib_path).unwrap());
std::process::exit(match cmd.status() {
Ok(s) => s.code().unwrap_or(1),
Err(e) => panic!("\n\nfailed to run {:?}: {}\n\n", cmd, e),
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py
index 2c2260a8e6..63feea1057 100644
--- a/src/bootstrap/bootstrap.py
+++ b/src/bootstrap/bootstrap.py
@@ -344,6 +344,22 @@ class RustBuild(object):
ostype += 'eabihf'
elif cputype == 'aarch64':
cputype = 'aarch64'
+ elif cputype == 'mips':
+ if sys.byteorder == 'big':
+ cputype = 'mips'
+ elif sys.byteorder == 'little':
+ cputype = 'mipsel'
+ else:
+ raise ValueError('unknown byteorder: ' + sys.byteorder)
+ elif cputype == 'mips64':
+ if sys.byteorder == 'big':
+ cputype = 'mips64'
+ elif sys.byteorder == 'little':
+ cputype = 'mips64el'
+ else:
+ raise ValueError('unknown byteorder: ' + sys.byteorder)
+ # only the n64 ABI is supported, indicate it
+ ostype += 'abi64'
elif cputype in {'powerpc', 'ppc', 'ppc64'}:
cputype = 'powerpc'
elif cputype in {'amd64', 'x86_64', 'x86-64', 'x64'}:
@@ -399,12 +415,10 @@ def main():
# Run the bootstrap
args = [os.path.join(rb.build_dir, "bootstrap/debug/bootstrap")]
- args.append('--src')
- args.append(rb.rust_root)
- args.append('--build')
- args.append(rb.build)
args.extend(sys.argv[1:])
env = os.environ.copy()
+ env["BUILD"] = rb.build
+ env["SRC"] = rb.rust_root
env["BOOTSTRAP_PARENT_ID"] = str(os.getpid())
rb.run(args, env)
diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs
index 603a5ce752..611630c573 100644
--- a/src/bootstrap/check.rs
+++ b/src/bootstrap/check.rs
@@ -13,9 +13,9 @@
//! This file implements the various regression test suites that we execute on
//! our CI.
+use std::collections::HashSet;
use std::env;
-use std::fs::{self, File};
-use std::io::prelude::*;
+use std::fs;
use std::path::{PathBuf, Path};
use std::process::Command;
@@ -108,6 +108,10 @@ pub fn compiletest(build: &Build,
cmd.arg("--host").arg(compiler.host);
cmd.arg("--llvm-filecheck").arg(build.llvm_filecheck(&build.config.build));
+ if let Some(nodejs) = build.config.nodejs.as_ref() {
+ cmd.arg("--nodejs").arg(nodejs);
+ }
+
let mut flags = vec!["-Crpath".to_string()];
if build.config.rust_optimize_tests {
flags.push("-O".to_string());
@@ -139,8 +143,8 @@ pub fn compiletest(build: &Build,
cmd.arg("--lldb-python").arg(python_default);
}
- if let Some(ref vers) = build.gdb_version {
- cmd.arg("--gdb-version").arg(vers);
+ if let Some(ref gdb) = build.config.gdb {
+ cmd.arg("--gdb").arg(gdb);
}
if let Some(ref vers) = build.lldb_version {
cmd.arg("--lldb-version").arg(vers);
@@ -152,12 +156,16 @@ pub fn compiletest(build: &Build,
let llvm_version = output(Command::new(&llvm_config).arg("--version"));
cmd.arg("--llvm-version").arg(llvm_version);
- cmd.args(&build.flags.args);
+ cmd.args(&build.flags.cmd.test_args());
if build.config.verbose || build.flags.verbose {
cmd.arg("--verbose");
}
+ if build.config.quiet_tests {
+ cmd.arg("--quiet");
+ }
+
// Only pass correct values for these flags for the `run-make` suite as it
// requires that a C++ compiler was configured which isn't always the case.
if suite == "run-make" {
@@ -248,7 +256,13 @@ fn markdown_test(build: &Build, compiler: &Compiler, markdown: &Path) {
build.add_rustc_lib_path(compiler, &mut cmd);
cmd.arg("--test");
cmd.arg(markdown);
- cmd.arg("--test-args").arg(build.flags.args.join(" "));
+
+ let mut test_args = build.flags.cmd.test_args().join(" ");
+ if build.config.quiet_tests {
+ test_args.push_str(" --quiet");
+ }
+ cmd.arg("--test-args").arg(test_args);
+
build.run(&mut cmd);
}
@@ -259,56 +273,58 @@ fn markdown_test(build: &Build, compiler: &Compiler, markdown: &Path) {
/// It essentially is the driver for running `cargo test`.
///
/// Currently this runs all tests for a DAG by passing a bunch of `-p foo`
-/// arguments, and those arguments are discovered from `Cargo.lock`.
+/// arguments, and those arguments are discovered from `cargo metadata`.
pub fn krate(build: &Build,
compiler: &Compiler,
target: &str,
- mode: Mode) {
- let (name, path, features) = match mode {
- Mode::Libstd => ("libstd", "src/rustc/std_shim", build.std_features()),
- Mode::Libtest => ("libtest", "src/rustc/test_shim", String::new()),
- Mode::Librustc => ("librustc", "src/rustc", build.rustc_features()),
+ mode: Mode,
+ krate: Option<&str>) {
+ let (name, path, features, root) = match mode {
+ Mode::Libstd => {
+ ("libstd", "src/rustc/std_shim", build.std_features(), "std_shim")
+ }
+ Mode::Libtest => {
+ ("libtest", "src/rustc/test_shim", String::new(), "test_shim")
+ }
+ Mode::Librustc => {
+ ("librustc", "src/rustc", build.rustc_features(), "rustc-main")
+ }
_ => panic!("can only test libraries"),
};
println!("Testing {} stage{} ({} -> {})", name, compiler.stage,
compiler.host, target);
// Build up the base `cargo test` command.
+ //
+ // Pass in some standard flags then iterate over the graph we've discovered
+ // in `cargo metadata` with the maps above and figure out what `-p`
+ // arguments need to get passed.
let mut cargo = build.cargo(compiler, mode, target, "test");
cargo.arg("--manifest-path")
.arg(build.src.join(path).join("Cargo.toml"))
.arg("--features").arg(features);
- // Generate a list of `-p` arguments to pass to the `cargo test` invocation
- // by crawling the corresponding Cargo.lock file.
- let lockfile = build.src.join(path).join("Cargo.lock");
- let mut contents = String::new();
- t!(t!(File::open(&lockfile)).read_to_string(&mut contents));
- let mut lines = contents.lines();
- while let Some(line) = lines.next() {
- let prefix = "name = \"";
- if !line.starts_with(prefix) {
- continue
+ match krate {
+ Some(krate) => {
+ cargo.arg("-p").arg(krate);
}
- lines.next(); // skip `version = ...`
-
- // skip crates.io or otherwise non-path crates
- if let Some(line) = lines.next() {
- if line.starts_with("source") {
- continue
+ None => {
+ let mut visited = HashSet::new();
+ let mut next = vec![root];
+ while let Some(name) = next.pop() {
+ // Right now jemalloc is our only target-specific crate in the sense
+ // that it's not present on all platforms. Custom skip it here for now,
+ // but if we add more this probably wants to get more generalized.
+ if !name.contains("jemalloc") {
+ cargo.arg("-p").arg(name);
+ }
+ for dep in build.crates[name].deps.iter() {
+ if visited.insert(dep) {
+ next.push(dep);
+ }
+ }
}
}
-
- let crate_name = &line[prefix.len()..line.len() - 1];
-
- // Right now jemalloc is our only target-specific crate in the sense
- // that it's not present on all platforms. Custom skip it here for now,
- // but if we add more this probably wants to get more generalized.
- if crate_name.contains("jemalloc") {
- continue
- }
-
- cargo.arg("-p").arg(crate_name);
}
// The tests are going to run with the *target* libraries, so we need to
@@ -320,11 +336,19 @@ pub fn krate(build: &Build,
dylib_path.insert(0, build.sysroot_libdir(compiler, target));
cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
+ if build.config.quiet_tests {
+ cargo.arg("--");
+ cargo.arg("--quiet");
+ }
+
if target.contains("android") {
build.run(cargo.arg("--no-run"));
krate_android(build, compiler, target, mode);
+ } else if target.contains("emscripten") {
+ build.run(cargo.arg("--no-run"));
+ krate_emscripten(build, compiler, target, mode);
} else {
- cargo.args(&build.flags.args);
+ cargo.args(&build.flags.cmd.test_args());
build.run(&mut cargo);
}
}
@@ -356,7 +380,7 @@ fn krate_android(build: &Build,
target = target,
test = test_file_name,
log = log,
- args = build.flags.args.join(" "));
+ args = build.flags.cmd.test_args().join(" "));
let output = output(Command::new("adb").arg("shell").arg(&program));
println!("{}", output);
@@ -371,6 +395,35 @@ fn krate_android(build: &Build,
}
}
+fn krate_emscripten(build: &Build,
+ compiler: &Compiler,
+ target: &str,
+ mode: Mode) {
+ let mut tests = Vec::new();
+ let out_dir = build.cargo_out(compiler, mode, target);
+ find_tests(&out_dir, target, &mut tests);
+ find_tests(&out_dir.join("deps"), target, &mut tests);
+
+ for test in tests {
+ let test_file_name = test.to_string_lossy().into_owned();
+ println!("running {}", test_file_name);
+ let nodejs = build.config.nodejs.as_ref().expect("nodejs not configured");
+ let status = Command::new(nodejs)
+ .arg(&test_file_name)
+ .stderr(::std::process::Stdio::inherit())
+ .status();
+ match status {
+ Ok(status) => {
+ if !status.success() {
+ panic!("some tests failed");
+ }
+ }
+ Err(e) => panic!(format!("failed to execute command: {}", e)),
+ };
+ }
+ }
+
+
fn find_tests(dir: &Path,
target: &str,
dst: &mut Vec) {
@@ -381,7 +434,8 @@ fn find_tests(dir: &Path,
}
let filename = e.file_name().into_string().unwrap();
if (target.contains("windows") && filename.ends_with(".exe")) ||
- (!target.contains("windows") && !filename.contains(".")) {
+ (!target.contains("windows") && !filename.contains(".")) ||
+ (target.contains("emscripten") && filename.contains(".js")){
dst.push(e.path());
}
}
diff --git a/src/bootstrap/clean.rs b/src/bootstrap/clean.rs
index a1e286e162..75bcbfee6e 100644
--- a/src/bootstrap/clean.rs
+++ b/src/bootstrap/clean.rs
@@ -16,6 +16,7 @@
//! directory as we want that cached between builds.
use std::fs;
+use std::io::{self, ErrorKind};
use std::path::Path;
use Build;
@@ -25,24 +26,58 @@ pub fn clean(build: &Build) {
rm_rf(build, &build.out.join("tmp"));
for host in build.config.host.iter() {
+ let entries = match build.out.join(host).read_dir() {
+ Ok(iter) => iter,
+ Err(_) => continue,
+ };
- let out = build.out.join(host);
+ for entry in entries {
+ let entry = t!(entry);
+ if entry.file_name().to_str() == Some("llvm") {
+ continue
+ }
+ let path = t!(entry.path().canonicalize());
+ rm_rf(build, &path);
+ }
+ }
+}
- rm_rf(build, &out.join("doc"));
+fn rm_rf(build: &Build, path: &Path) {
+ if !path.exists() {
+ return
+ }
- for stage in 0..4 {
- rm_rf(build, &out.join(format!("stage{}", stage)));
- rm_rf(build, &out.join(format!("stage{}-std", stage)));
- rm_rf(build, &out.join(format!("stage{}-rustc", stage)));
- rm_rf(build, &out.join(format!("stage{}-tools", stage)));
- rm_rf(build, &out.join(format!("stage{}-test", stage)));
+ for file in t!(fs::read_dir(path)) {
+ let file = t!(file).path();
+
+ if file.is_dir() {
+ rm_rf(build, &file);
+ } else {
+ // On windows we can't remove a readonly file, and git will
+ // often clone files as readonly. As a result, we have some
+ // special logic to remove readonly files on windows.
+ do_op(&file, "remove file", |p| fs::remove_file(p));
}
}
+ do_op(path, "remove dir", |p| fs::remove_dir(p));
}
-fn rm_rf(build: &Build, path: &Path) {
- if path.exists() {
- build.verbose(&format!("removing `{}`", path.display()));
- t!(fs::remove_dir_all(path));
+fn do_op(path: &Path, desc: &str, mut f: F)
+ where F: FnMut(&Path) -> io::Result<()>
+{
+ match f(path) {
+ Ok(()) => {}
+ Err(ref e) if cfg!(windows) &&
+ e.kind() == ErrorKind::PermissionDenied => {
+ let mut p = t!(path.metadata()).permissions();
+ p.set_readonly(false);
+ t!(fs::set_permissions(path, p));
+ f(path).unwrap_or_else(|e| {
+ panic!("failed to {} {}: {}", desc, path.display(), e);
+ })
+ }
+ Err(e) => {
+ panic!("failed to {} {}: {}", desc, path.display(), e);
+ }
}
}
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
index 239db55ff5..5fc4f00672 100644
--- a/src/bootstrap/compile.rs
+++ b/src/bootstrap/compile.rs
@@ -25,7 +25,7 @@ use std::process::Command;
use build_helper::output;
use filetime::FileTime;
-use util::{exe, staticlib, libdir, mtime, is_dylib, copy};
+use util::{exe, libdir, mtime, is_dylib, copy};
use {Build, Compiler, Mode};
/// Build the standard library.
@@ -40,20 +40,6 @@ pub fn std<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
let libdir = build.sysroot_libdir(compiler, target);
let _ = fs::remove_dir_all(&libdir);
t!(fs::create_dir_all(&libdir));
- // FIXME(stage0) remove this `if` after the next snapshot
- // The stage0 compiler still passes the `-lcompiler-rt` flag to the linker but now `bootstrap`
- // never builds a `libcopmiler-rt.a`! We'll fill the hole by simply copying stage0's
- // `libcompiler-rt.a` to where the stage1's one is expected (though we could as well just use
- // an empty `.a` archive). Note that the symbols of that stage0 `libcompiler-rt.a` won't make
- // it to the final binary because now `libcore.rlib` also contains the symbols that
- // `libcompiler-rt.a` provides. Since that rlib appears first in the linker arguments, its
- // symbols are used instead of `libcompiler-rt.a`'s.
- if compiler.stage == 0 {
- let rtlib = &staticlib("compiler-rt", target);
- let src = build.rustc.parent().unwrap().parent().unwrap().join("lib").join("rustlib")
- .join(target).join("lib").join(rtlib);
- copy(&src, &libdir.join(rtlib));
- }
// Some platforms have startup objects that may be required to produce the
// libstd dynamic library, for example.
@@ -78,8 +64,8 @@ pub fn std<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
}
build.run(&mut cargo);
- update_mtime(&libstd_stamp(build, compiler, target));
- std_link(build, target, compiler, compiler.host);
+ update_mtime(&libstd_stamp(build, &compiler, target));
+ std_link(build, target, compiler.stage, compiler.host);
}
/// Link all libstd rlibs/dylibs into the sysroot location.
@@ -88,11 +74,12 @@ pub fn std<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
/// by `compiler` into `host`'s sysroot.
pub fn std_link(build: &Build,
target: &str,
- compiler: &Compiler,
+ stage: u32,
host: &str) {
+ let compiler = Compiler::new(stage, &build.config.build);
let target_compiler = Compiler::new(compiler.stage, host);
let libdir = build.sysroot_libdir(&target_compiler, target);
- let out_dir = build.cargo_out(compiler, Mode::Libstd, target);
+ let out_dir = build.cargo_out(&compiler, Mode::Libstd, target);
// If we're linking one compiler host's output into another, then we weren't
// called from the `std` method above. In that case we clean out what's
@@ -104,16 +91,16 @@ pub fn std_link(build: &Build,
add_to_sysroot(&out_dir, &libdir);
if target.contains("musl") && !target.contains("mips") {
- copy_musl_third_party_objects(build, &libdir);
+ copy_musl_third_party_objects(build, target, &libdir);
}
}
/// Copies the crt(1,i,n).o startup objects
///
/// Only required for musl targets that statically link to libc
-fn copy_musl_third_party_objects(build: &Build, into: &Path) {
+fn copy_musl_third_party_objects(build: &Build, target: &str, into: &Path) {
for &obj in &["crt1.o", "crti.o", "crtn.o"] {
- copy(&build.config.musl_root.as_ref().unwrap().join("lib").join(obj), &into.join(obj));
+ copy(&build.musl_root(target).unwrap().join("lib").join(obj), &into.join(obj));
}
}
@@ -160,7 +147,7 @@ pub fn test<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
.arg(build.src.join("src/rustc/test_shim/Cargo.toml"));
build.run(&mut cargo);
update_mtime(&libtest_stamp(build, compiler, target));
- test_link(build, target, compiler, compiler.host);
+ test_link(build, target, compiler.stage, compiler.host);
}
/// Link all libtest rlibs/dylibs into the sysroot location.
@@ -169,11 +156,12 @@ pub fn test<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
/// by `compiler` into `host`'s sysroot.
pub fn test_link(build: &Build,
target: &str,
- compiler: &Compiler,
+ stage: u32,
host: &str) {
+ let compiler = Compiler::new(stage, &build.config.build);
let target_compiler = Compiler::new(compiler.stage, host);
let libdir = build.sysroot_libdir(&target_compiler, target);
- let out_dir = build.cargo_out(compiler, Mode::Libtest, target);
+ let out_dir = build.cargo_out(&compiler, Mode::Libtest, target);
add_to_sysroot(&out_dir, &libdir);
}
@@ -232,7 +220,7 @@ pub fn rustc<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
}
build.run(&mut cargo);
- rustc_link(build, target, compiler, compiler.host);
+ rustc_link(build, target, compiler.stage, compiler.host);
}
/// Link all librustc rlibs/dylibs into the sysroot location.
@@ -241,11 +229,12 @@ pub fn rustc<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
/// by `compiler` into `host`'s sysroot.
pub fn rustc_link(build: &Build,
target: &str,
- compiler: &Compiler,
+ stage: u32,
host: &str) {
+ let compiler = Compiler::new(stage, &build.config.build);
let target_compiler = Compiler::new(compiler.stage, host);
let libdir = build.sysroot_libdir(&target_compiler, target);
- let out_dir = build.cargo_out(compiler, Mode::Librustc, target);
+ let out_dir = build.cargo_out(&compiler, Mode::Librustc, target);
add_to_sysroot(&out_dir, &libdir);
}
@@ -273,7 +262,10 @@ fn compiler_file(compiler: &Path, file: &str) -> PathBuf {
/// must have been previously produced by the `stage - 1` build.config.build
/// compiler.
pub fn assemble_rustc(build: &Build, stage: u32, host: &str) {
- assert!(stage > 0, "the stage0 compiler isn't assembled, it's downloaded");
+ // nothing to do in stage0
+ if stage == 0 {
+ return
+ }
// The compiler that we're assembling
let target_compiler = Compiler::new(stage, host);
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
index 0f69bcfbb6..bb05b75a3f 100644
--- a/src/bootstrap/config.rs
+++ b/src/bootstrap/config.rs
@@ -23,6 +23,7 @@ use std::process;
use num_cpus;
use rustc_serialize::Decodable;
use toml::{Parser, Decoder, Value};
+use util::push_exe_path;
/// Global configuration for the entire build and/or bootstrap.
///
@@ -56,6 +57,7 @@ pub struct Config {
pub rust_codegen_units: u32,
pub rust_debug_assertions: bool,
pub rust_debuginfo: bool,
+ pub rust_debuginfo_lines: bool,
pub rust_rpath: bool,
pub rustc_default_linker: Option,
pub rustc_default_ar: Option,
@@ -76,11 +78,16 @@ pub struct Config {
// misc
pub channel: String,
+ pub quiet_tests: bool,
// Fallback musl-root for all targets
pub musl_root: Option,
pub prefix: Option,
+ pub docdir: Option,
+ pub libdir: Option,
+ pub mandir: Option,
pub codegen_tests: bool,
pub nodejs: Option,
+ pub gdb: Option,
}
/// Per-target configuration stored in the global configuration structure.
@@ -117,6 +124,8 @@ struct Build {
rustc: Option,
compiler_docs: Option,
docs: Option,
+ submodules: Option,
+ gdb: Option,
}
/// TOML representation of how the LLVM build is configured.
@@ -137,6 +146,7 @@ struct Rust {
codegen_units: Option,
debug_assertions: Option,
debuginfo: Option,
+ debuginfo_lines: Option,
debug_jemalloc: Option,
use_jemalloc: Option,
backtrace: Option,
@@ -158,6 +168,7 @@ struct TomlTarget {
cc: Option,
cxx: Option,
android_ndk: Option,
+ musl_root: Option,
}
impl Config {
@@ -219,8 +230,10 @@ impl Config {
}
config.rustc = build.rustc.map(PathBuf::from);
config.cargo = build.cargo.map(PathBuf::from);
+ config.gdb = build.gdb.map(PathBuf::from);
set(&mut config.compiler_docs, build.compiler_docs);
set(&mut config.docs, build.docs);
+ set(&mut config.submodules, build.submodules);
if let Some(ref llvm) = toml.llvm {
set(&mut config.ccache, llvm.ccache);
@@ -233,6 +246,7 @@ impl Config {
if let Some(ref rust) = toml.rust {
set(&mut config.rust_debug_assertions, rust.debug_assertions);
set(&mut config.rust_debuginfo, rust.debuginfo);
+ set(&mut config.rust_debuginfo_lines, rust.debuginfo_lines);
set(&mut config.rust_optimize, rust.optimize);
set(&mut config.rust_optimize_tests, rust.optimize_tests);
set(&mut config.rust_debuginfo_tests, rust.debuginfo_tests);
@@ -268,6 +282,7 @@ impl Config {
}
target.cxx = cfg.cxx.clone().map(PathBuf::from);
target.cc = cfg.cc.clone().map(PathBuf::from);
+ target.musl_root = cfg.musl_root.clone().map(PathBuf::from);
config.target_config.insert(triple.clone(), target);
}
@@ -322,11 +337,13 @@ impl Config {
("OPTIMIZE", self.rust_optimize),
("DEBUG_ASSERTIONS", self.rust_debug_assertions),
("DEBUGINFO", self.rust_debuginfo),
+ ("DEBUGINFO_LINES", self.rust_debuginfo_lines),
("JEMALLOC", self.use_jemalloc),
("DEBUG_JEMALLOC", self.debug_jemalloc),
("RPATH", self.rust_rpath),
("OPTIMIZE_TESTS", self.rust_optimize_tests),
("DEBUGINFO_TESTS", self.rust_debuginfo_tests),
+ ("QUIET_TESTS", self.quiet_tests),
("LOCAL_REBUILD", self.local_rebuild),
("NINJA", self.ninja),
("CODEGEN_TESTS", self.codegen_tests),
@@ -343,7 +360,37 @@ impl Config {
.collect();
}
"CFG_MUSL_ROOT" if value.len() > 0 => {
- self.musl_root = Some(PathBuf::from(value));
+ self.musl_root = Some(parse_configure_path(value));
+ }
+ "CFG_MUSL_ROOT_X86_64" if value.len() > 0 => {
+ let target = "x86_64-unknown-linux-musl".to_string();
+ let target = self.target_config.entry(target)
+ .or_insert(Target::default());
+ target.musl_root = Some(parse_configure_path(value));
+ }
+ "CFG_MUSL_ROOT_I686" if value.len() > 0 => {
+ let target = "i686-unknown-linux-musl".to_string();
+ let target = self.target_config.entry(target)
+ .or_insert(Target::default());
+ target.musl_root = Some(parse_configure_path(value));
+ }
+ "CFG_MUSL_ROOT_ARM" if value.len() > 0 => {
+ let target = "arm-unknown-linux-musleabi".to_string();
+ let target = self.target_config.entry(target)
+ .or_insert(Target::default());
+ target.musl_root = Some(parse_configure_path(value));
+ }
+ "CFG_MUSL_ROOT_ARMHF" if value.len() > 0 => {
+ let target = "arm-unknown-linux-musleabihf".to_string();
+ let target = self.target_config.entry(target)
+ .or_insert(Target::default());
+ target.musl_root = Some(parse_configure_path(value));
+ }
+ "CFG_MUSL_ROOT_ARMV7" if value.len() > 0 => {
+ let target = "armv7-unknown-linux-musleabihf".to_string();
+ let target = self.target_config.entry(target)
+ .or_insert(Target::default());
+ target.musl_root = Some(parse_configure_path(value));
}
"CFG_DEFAULT_AR" if value.len() > 0 => {
self.rustc_default_ar = Some(value.to_string());
@@ -351,53 +398,63 @@ impl Config {
"CFG_DEFAULT_LINKER" if value.len() > 0 => {
self.rustc_default_linker = Some(value.to_string());
}
+ "CFG_GDB" if value.len() > 0 => {
+ self.gdb = Some(parse_configure_path(value));
+ }
"CFG_RELEASE_CHANNEL" => {
self.channel = value.to_string();
}
"CFG_PREFIX" => {
self.prefix = Some(value.to_string());
}
+ "CFG_DOCDIR" => {
+ self.docdir = Some(value.to_string());
+ }
+ "CFG_LIBDIR" => {
+ self.libdir = Some(value.to_string());
+ }
+ "CFG_MANDIR" => {
+ self.mandir = Some(value.to_string());
+ }
"CFG_LLVM_ROOT" if value.len() > 0 => {
let target = self.target_config.entry(self.build.clone())
.or_insert(Target::default());
- let root = PathBuf::from(value);
- target.llvm_config = Some(root.join("bin/llvm-config"));
+ let root = parse_configure_path(value);
+ target.llvm_config = Some(push_exe_path(root, &["bin", "llvm-config"]));
}
"CFG_JEMALLOC_ROOT" if value.len() > 0 => {
let target = self.target_config.entry(self.build.clone())
.or_insert(Target::default());
- target.jemalloc = Some(PathBuf::from(value));
+ target.jemalloc = Some(parse_configure_path(value));
}
"CFG_ARM_LINUX_ANDROIDEABI_NDK" if value.len() > 0 => {
let target = "arm-linux-androideabi".to_string();
let target = self.target_config.entry(target)
.or_insert(Target::default());
- target.ndk = Some(PathBuf::from(value));
+ target.ndk = Some(parse_configure_path(value));
}
"CFG_ARMV7_LINUX_ANDROIDEABI_NDK" if value.len() > 0 => {
let target = "armv7-linux-androideabi".to_string();
let target = self.target_config.entry(target)
.or_insert(Target::default());
- target.ndk = Some(PathBuf::from(value));
+ target.ndk = Some(parse_configure_path(value));
}
"CFG_I686_LINUX_ANDROID_NDK" if value.len() > 0 => {
let target = "i686-linux-android".to_string();
let target = self.target_config.entry(target)
.or_insert(Target::default());
- target.ndk = Some(PathBuf::from(value));
+ target.ndk = Some(parse_configure_path(value));
}
"CFG_AARCH64_LINUX_ANDROID_NDK" if value.len() > 0 => {
let target = "aarch64-linux-android".to_string();
let target = self.target_config.entry(target)
.or_insert(Target::default());
- target.ndk = Some(PathBuf::from(value));
+ target.ndk = Some(parse_configure_path(value));
}
"CFG_LOCAL_RUST_ROOT" if value.len() > 0 => {
- self.rustc = Some(PathBuf::from(value).join("bin/rustc"));
- self.cargo = Some(PathBuf::from(value).join("bin/cargo"));
- }
- "CFG_NODEJS" if value.len() > 0 => {
- self.nodejs = Some(PathBuf::from(value));
+ let path = parse_configure_path(value);
+ self.rustc = Some(push_exe_path(path.clone(), &["bin", "rustc"]));
+ self.cargo = Some(push_exe_path(path, &["bin", "cargo"]));
}
_ => {}
}
@@ -405,6 +462,30 @@ impl Config {
}
}
+#[cfg(not(windows))]
+fn parse_configure_path(path: &str) -> PathBuf {
+ path.into()
+}
+
+#[cfg(windows)]
+fn parse_configure_path(path: &str) -> PathBuf {
+ // on windows, configure produces unix style paths e.g. /c/some/path but we
+ // only want real windows paths
+
+ use std::process::Command;
+ use build_helper;
+
+ // '/' is invalid in windows paths, so we can detect unix paths by the presence of it
+ if !path.contains('/') {
+ return path.into();
+ }
+
+ let win_path = build_helper::output(Command::new("cygpath").arg("-w").arg(path));
+ let win_path = win_path.trim();
+
+ win_path.into()
+}
+
fn set(field: &mut T, val: Option) {
if let Some(v) = val {
*field = v;
diff --git a/src/bootstrap/config.toml.example b/src/bootstrap/config.toml.example
index f054b29d0b..1289cdba59 100644
--- a/src/bootstrap/config.toml.example
+++ b/src/bootstrap/config.toml.example
@@ -76,6 +76,12 @@
# library and facade crates.
#compiler-docs = false
+# Indicate whether submodules are managed and updated automatically.
+#submodules = true
+
+# The path to (or name of) the GDB executable to use
+#gdb = "gdb"
+
# =============================================================================
# Options for compiling Rust code itself
# =============================================================================
@@ -96,6 +102,9 @@
# Whether or not debuginfo is emitted
#debuginfo = false
+# Whether or not line number debug information is emitted
+#debuginfo-lines = false
+
# Whether or not jemalloc is built and enabled
#use-jemalloc = true
diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
index 31b7db168b..8676f5cc4a 100644
--- a/src/bootstrap/dist.rs
+++ b/src/bootstrap/dist.rs
@@ -25,9 +25,8 @@ use std::process::Command;
use {Build, Compiler};
use util::{cp_r, libdir, is_dylib, cp_filtered, copy};
-use regex::{RegexSet, quote};
-fn package_vers(build: &Build) -> &str {
+pub fn package_vers(build: &Build) -> &str {
match &build.config.channel[..] {
"stable" => &build.release,
"beta" => "beta",
@@ -40,7 +39,7 @@ fn distdir(build: &Build) -> PathBuf {
build.out.join("dist")
}
-fn tmpdir(build: &Build) -> PathBuf {
+pub fn tmpdir(build: &Build) -> PathBuf {
build.out.join("tmp/dist")
}
@@ -315,49 +314,31 @@ pub fn rust_src(build: &Build) {
"mk"
];
- // Exclude paths matching these wildcard expressions
- let excludes = [
- // exclude-vcs
- "CVS", "RCS", "SCCS", ".git", ".gitignore", ".gitmodules", ".gitattributes", ".cvsignore",
- ".svn", ".arch-ids", "{arch}", "=RELEASE-ID", "=meta-update", "=update", ".bzr",
- ".bzrignore", ".bzrtags", ".hg", ".hgignore", ".hgrags", "_darcs",
- // extensions
- "*~", "*.pyc",
- // misc
- "llvm/test/*/*.ll",
- "llvm/test/*/*.td",
- "llvm/test/*/*.s",
- "llvm/test/*/*/*.ll",
- "llvm/test/*/*/*.td",
- "llvm/test/*/*/*.s"
- ];
-
- // Construct a set of regexes for efficiently testing whether paths match one of the above
- // expressions.
- let regex_set = t!(RegexSet::new(
- // This converts a wildcard expression to a regex
- excludes.iter().map(|&s| {
- // Prefix ensures that matching starts on a path separator boundary
- r"^(.*[\\/])?".to_owned() + (
- // Escape the expression to produce a regex matching exactly that string
- "e(s)
- // Replace slashes with a pattern matching either forward or backslash
- .replace(r"/", r"[\\/]")
- // Replace wildcards with a pattern matching a single path segment, ie. containing
- // no slashes.
- .replace(r"\*", r"[^\\/]*")
- // Suffix anchors to the end of the path
- ) + "$"
- })
- ));
-
- // Create a filter which skips files which match the regex set or contain invalid unicode
let filter_fn = move |path: &Path| {
- if let Some(path) = path.to_str() {
- !regex_set.is_match(path)
- } else {
- false
+ let spath = match path.to_str() {
+ Some(path) => path,
+ None => return false,
+ };
+ if spath.ends_with("~") || spath.ends_with(".pyc") {
+ return false
}
+ if spath.contains("llvm/test") || spath.contains("llvm\\test") {
+ if spath.ends_with(".ll") ||
+ spath.ends_with(".td") ||
+ spath.ends_with(".s") {
+ return false
+ }
+ }
+
+ let excludes = [
+ "CVS", "RCS", "SCCS", ".git", ".gitignore", ".gitmodules",
+ ".gitattributes", ".cvsignore", ".svn", ".arch-ids", "{arch}",
+ "=RELEASE-ID", "=meta-update", "=update", ".bzr", ".bzrignore",
+ ".bzrtags", ".hg", ".hgignore", ".hgrags", "_darcs",
+ ];
+ !path.iter()
+ .map(|s| s.to_str().unwrap())
+ .any(|s| excludes.contains(&s))
};
// Copy the directories using our filter
@@ -418,7 +399,7 @@ fn chmod(_path: &Path, _perms: u32) {}
// We have to run a few shell scripts, which choke quite a bit on both `\`
// characters and on `C:\` paths, so normalize both of them away.
-fn sanitize_sh(path: &Path) -> String {
+pub fn sanitize_sh(path: &Path) -> String {
let path = path.to_str().unwrap().replace("\\", "/");
return change_drive(&path).unwrap_or(path);
diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs
index c2636384db..30c7fefad8 100644
--- a/src/bootstrap/doc.rs
+++ b/src/bootstrap/doc.rs
@@ -19,7 +19,6 @@
use std::fs::{self, File};
use std::io::prelude::*;
-use std::path::Path;
use std::process::Command;
use {Build, Compiler, Mode};
@@ -30,8 +29,9 @@ use util::{up_to_date, cp_r};
///
/// This will not actually generate any documentation if the documentation has
/// already been generated.
-pub fn rustbook(build: &Build, stage: u32, target: &str, name: &str, out: &Path) {
- t!(fs::create_dir_all(out));
+pub fn rustbook(build: &Build, stage: u32, target: &str, name: &str) {
+ let out = build.doc_out(target);
+ t!(fs::create_dir_all(&out));
let out = out.join(name);
let compiler = Compiler::new(stage, &build.config.build);
@@ -57,9 +57,10 @@ pub fn rustbook(build: &Build, stage: u32, target: &str, name: &str, out: &Path)
/// `STAMP` alongw ith providing the various header/footer HTML we've cutomized.
///
/// In the end, this is just a glorified wrapper around rustdoc!
-pub fn standalone(build: &Build, stage: u32, target: &str, out: &Path) {
+pub fn standalone(build: &Build, stage: u32, target: &str) {
println!("Documenting stage{} standalone ({})", stage, target);
- t!(fs::create_dir_all(out));
+ let out = build.doc_out(target);
+ t!(fs::create_dir_all(&out));
let compiler = Compiler::new(stage, &build.config.build);
@@ -109,7 +110,7 @@ pub fn standalone(build: &Build, stage: u32, target: &str, out: &Path) {
.arg("--html-in-header").arg(&favicon)
.arg("--markdown-playground-url")
.arg("https://play.rust-lang.org/")
- .arg("-o").arg(out)
+ .arg("-o").arg(&out)
.arg(&path);
if filename == "reference.md" {
@@ -131,9 +132,10 @@ pub fn standalone(build: &Build, stage: u32, target: &str, out: &Path) {
///
/// This will generate all documentation for the standard library and its
/// dependencies. This is largely just a wrapper around `cargo doc`.
-pub fn std(build: &Build, stage: u32, target: &str, out: &Path) {
+pub fn std(build: &Build, stage: u32, target: &str) {
println!("Documenting stage{} std ({})", stage, target);
- t!(fs::create_dir_all(out));
+ let out = build.doc_out(target);
+ t!(fs::create_dir_all(&out));
let compiler = Compiler::new(stage, &build.config.build);
let out_dir = build.stage_out(&compiler, Mode::Libstd)
.join(target).join("doc");
@@ -146,16 +148,17 @@ pub fn std(build: &Build, stage: u32, target: &str, out: &Path) {
.arg(build.src.join("src/rustc/std_shim/Cargo.toml"))
.arg("--features").arg(build.std_features());
build.run(&mut cargo);
- cp_r(&out_dir, out)
+ cp_r(&out_dir, &out)
}
/// Compile all libtest documentation.
///
/// This will generate all documentation for libtest and its dependencies. This
/// is largely just a wrapper around `cargo doc`.
-pub fn test(build: &Build, stage: u32, target: &str, out: &Path) {
+pub fn test(build: &Build, stage: u32, target: &str) {
println!("Documenting stage{} test ({})", stage, target);
- t!(fs::create_dir_all(out));
+ let out = build.doc_out(target);
+ t!(fs::create_dir_all(&out));
let compiler = Compiler::new(stage, &build.config.build);
let out_dir = build.stage_out(&compiler, Mode::Libtest)
.join(target).join("doc");
@@ -167,16 +170,17 @@ pub fn test(build: &Build, stage: u32, target: &str, out: &Path) {
cargo.arg("--manifest-path")
.arg(build.src.join("src/rustc/test_shim/Cargo.toml"));
build.run(&mut cargo);
- cp_r(&out_dir, out)
+ cp_r(&out_dir, &out)
}
/// Generate all compiler documentation.
///
/// This will generate all documentation for the compiler libraries and their
/// dependencies. This is largely just a wrapper around `cargo doc`.
-pub fn rustc(build: &Build, stage: u32, target: &str, out: &Path) {
+pub fn rustc(build: &Build, stage: u32, target: &str) {
println!("Documenting stage{} compiler ({})", stage, target);
- t!(fs::create_dir_all(out));
+ let out = build.doc_out(target);
+ t!(fs::create_dir_all(&out));
let compiler = Compiler::new(stage, &build.config.build);
let out_dir = build.stage_out(&compiler, Mode::Librustc)
.join(target).join("doc");
@@ -189,14 +193,15 @@ pub fn rustc(build: &Build, stage: u32, target: &str, out: &Path) {
.arg(build.src.join("src/rustc/Cargo.toml"))
.arg("--features").arg(build.rustc_features());
build.run(&mut cargo);
- cp_r(&out_dir, out)
+ cp_r(&out_dir, &out)
}
/// Generates the HTML rendered error-index by running the
/// `error_index_generator` tool.
-pub fn error_index(build: &Build, stage: u32, target: &str, out: &Path) {
+pub fn error_index(build: &Build, stage: u32, target: &str) {
println!("Documenting stage{} error index ({})", stage, target);
- t!(fs::create_dir_all(out));
+ let out = build.doc_out(target);
+ t!(fs::create_dir_all(&out));
let compiler = Compiler::new(stage, &build.config.build);
let mut index = build.tool_cmd(&compiler, "error_index_generator");
index.arg("html");
diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs
index d925997f36..d7516954f1 100644
--- a/src/bootstrap/flags.rs
+++ b/src/bootstrap/flags.rs
@@ -13,30 +13,46 @@
//! This module implements the command-line parsing of the build system which
//! has various flags to configure how it's run.
+use std::env;
use std::fs;
use std::path::PathBuf;
use std::process;
-use std::slice;
-use getopts::Options;
+use getopts::{Matches, Options};
+
+use Build;
+use config::Config;
+use metadata;
+use step;
/// Deserialized version of all flags for this compile.
pub struct Flags {
pub verbose: bool,
pub stage: Option,
pub build: String,
- pub host: Filter,
- pub target: Filter,
- pub step: Vec,
+ pub host: Vec,
+ pub target: Vec,
pub config: Option,
pub src: Option,
pub jobs: Option,
- pub args: Vec,
- pub clean: bool,
+ pub cmd: Subcommand,
}
-pub struct Filter {
- values: Vec,
+pub enum Subcommand {
+ Build {
+ paths: Vec,
+ },
+ Doc {
+ paths: Vec,
+ },
+ Test {
+ paths: Vec,
+ test_args: Vec,
+ },
+ Clean,
+ Dist {
+ install: bool,
+ },
}
impl Flags {
@@ -44,29 +60,177 @@ impl Flags {
let mut opts = Options::new();
opts.optflag("v", "verbose", "use verbose output");
opts.optopt("", "config", "TOML configuration file for build", "FILE");
+ opts.optopt("", "build", "build target of the stage0 compiler", "BUILD");
opts.optmulti("", "host", "host targets to build", "HOST");
- opts.reqopt("", "build", "build target of the stage0 compiler", "BUILD");
- opts.optmulti("", "target", "targets to build", "TARGET");
- opts.optmulti("s", "step", "build step to execute", "STEP");
+ opts.optmulti("", "target", "target targets to build", "TARGET");
opts.optopt("", "stage", "stage to build", "N");
- opts.optopt("", "src", "path to repo root", "DIR");
+ opts.optopt("", "src", "path to the root of the rust checkout", "DIR");
opts.optopt("j", "jobs", "number of jobs to run in parallel", "JOBS");
- opts.optflag("", "clean", "clean output directory");
opts.optflag("h", "help", "print this help message");
- let usage = |n| -> ! {
- let brief = format!("Usage: rust.py [options]");
- print!("{}", opts.usage(&brief));
+ let usage = |n, opts: &Options| -> ! {
+ let command = args.get(0).map(|s| &**s);
+ let brief = format!("Usage: x.py {} [options] [...]",
+ command.unwrap_or(""));
+
+ println!("{}", opts.usage(&brief));
+ match command {
+ Some("build") => {
+ println!("\
+Arguments:
+ This subcommand accepts a number of positional arguments of directories to
+ the crates and/or artifacts to compile. For example:
+
+ ./x.py build src/libcore
+ ./x.py build src/libproc_macro
+ ./x.py build src/libstd --stage 1
+
+ If no arguments are passed then the complete artifacts for that stage are
+ also compiled.
+
+ ./x.py build
+ ./x.py build --stage 1
+
+ For a quick build with a usable compile, you can pass:
+
+ ./x.py build --stage 1 src/libtest
+");
+ }
+
+ Some("test") => {
+ println!("\
+Arguments:
+ This subcommand accepts a number of positional arguments of directories to
+ tests that should be compiled and run. For example:
+
+ ./x.py test src/test/run-pass
+ ./x.py test src/test/run-pass/assert-*
+ ./x.py test src/libstd --test-args hash_map
+ ./x.py test src/libstd --stage 0
+
+ If no arguments are passed then the complete artifacts for that stage are
+ compiled and tested.
+
+ ./x.py test
+ ./x.py test --stage 1
+");
+ }
+
+ Some("doc") => {
+ println!("\
+Arguments:
+ This subcommand accepts a number of positional arguments of directories of
+ documentation to build. For example:
+
+ ./x.py doc src/doc/book
+ ./x.py doc src/doc/nomicon
+ ./x.py doc src/libstd
+
+ If no arguments are passed then everything is documented:
+
+ ./x.py doc
+ ./x.py doc --stage 1
+");
+ }
+
+ _ => {}
+ }
+
+ if let Some(command) = command {
+ if command == "build" ||
+ command == "dist" ||
+ command == "doc" ||
+ command == "test" ||
+ command == "clean" {
+ println!("Available invocations:");
+ if args.iter().any(|a| a == "-v") {
+ let flags = Flags::parse(&["build".to_string()]);
+ let mut config = Config::default();
+ config.build = flags.build.clone();
+ let mut build = Build::new(flags, config);
+ metadata::build(&mut build);
+ step::build_rules(&build).print_help(command);
+ } else {
+ println!(" ... elided, run `./x.py {} -h -v` to see",
+ command);
+ }
+
+ println!("");
+ }
+ }
+
+println!("\
+Subcommands:
+ build Compile either the compiler or libraries
+ test Build and run some test suites
+ doc Build documentation
+ clean Clean out build directories
+ dist Build and/or install distribution artifacts
+
+To learn more about a subcommand, run `./x.py -h`
+");
+
process::exit(n);
};
-
- let m = opts.parse(args).unwrap_or_else(|e| {
- println!("failed to parse options: {}", e);
- usage(1);
- });
- if m.opt_present("h") {
- usage(0);
+ if args.len() == 0 {
+ println!("a command must be passed");
+ usage(1, &opts);
}
+ let parse = |opts: &Options| {
+ let m = opts.parse(&args[1..]).unwrap_or_else(|e| {
+ println!("failed to parse options: {}", e);
+ usage(1, opts);
+ });
+ if m.opt_present("h") {
+ usage(0, opts);
+ }
+ return m
+ };
+
+ let cwd = t!(env::current_dir());
+ let remaining_as_path = |m: &Matches| {
+ m.free.iter().map(|p| cwd.join(p)).collect::>()
+ };
+
+ let m: Matches;
+ let cmd = match &args[0][..] {
+ "build" => {
+ m = parse(&opts);
+ Subcommand::Build { paths: remaining_as_path(&m) }
+ }
+ "doc" => {
+ m = parse(&opts);
+ Subcommand::Doc { paths: remaining_as_path(&m) }
+ }
+ "test" => {
+ opts.optmulti("", "test-args", "extra arguments", "ARGS");
+ m = parse(&opts);
+ Subcommand::Test {
+ paths: remaining_as_path(&m),
+ test_args: m.opt_strs("test-args"),
+ }
+ }
+ "clean" => {
+ m = parse(&opts);
+ if m.free.len() > 0 {
+ println!("clean takes no arguments");
+ usage(1, &opts);
+ }
+ Subcommand::Clean
+ }
+ "dist" => {
+ opts.optflag("", "install", "run installer as well");
+ m = parse(&opts);
+ Subcommand::Dist {
+ install: m.opt_present("install"),
+ }
+ }
+ cmd => {
+ println!("unknown command: {}", cmd);
+ usage(1, &opts);
+ }
+ };
+
let cfg_file = m.opt_str("config").map(PathBuf::from).or_else(|| {
if fs::metadata("config.toml").is_ok() {
@@ -78,26 +242,27 @@ impl Flags {
Flags {
verbose: m.opt_present("v"),
- clean: m.opt_present("clean"),
stage: m.opt_str("stage").map(|j| j.parse().unwrap()),
- build: m.opt_str("build").unwrap(),
- host: Filter { values: m.opt_strs("host") },
- target: Filter { values: m.opt_strs("target") },
- step: m.opt_strs("step"),
+ build: m.opt_str("build").unwrap_or_else(|| {
+ env::var("BUILD").unwrap()
+ }),
+ host: m.opt_strs("host"),
+ target: m.opt_strs("target"),
config: cfg_file,
src: m.opt_str("src").map(PathBuf::from),
jobs: m.opt_str("jobs").map(|j| j.parse().unwrap()),
- args: m.free.clone(),
+ cmd: cmd,
}
}
}
-impl Filter {
- pub fn contains(&self, name: &str) -> bool {
- self.values.len() == 0 || self.values.iter().any(|s| s == name)
- }
-
- pub fn iter(&self) -> slice::Iter {
- self.values.iter()
+impl Subcommand {
+ pub fn test_args(&self) -> Vec<&str> {
+ match *self {
+ Subcommand::Test { ref test_args, .. } => {
+ test_args.iter().flat_map(|s| s.split_whitespace()).collect()
+ }
+ _ => Vec::new(),
+ }
}
}
diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs
new file mode 100644
index 0000000000..9bc5a7c00a
--- /dev/null
+++ b/src/bootstrap/install.rs
@@ -0,0 +1,61 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 or the MIT license
+// , at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! Implementation of the install aspects of the compiler.
+//!
+//! This module is responsible for installing the standard library,
+//! compiler, and documentation.
+
+use std::fs;
+use std::borrow::Cow;
+use std::path::Path;
+use std::process::Command;
+
+use Build;
+use dist::{package_vers, sanitize_sh, tmpdir};
+
+/// Installs everything.
+pub fn install(build: &Build, stage: u32, host: &str) {
+ let prefix = build.config.prefix.as_ref().clone().map(|x| Path::new(x))
+ .unwrap_or(Path::new("/usr/local"));
+ let docdir = build.config.docdir.as_ref().clone().map(|x| Cow::Borrowed(Path::new(x)))
+ .unwrap_or(Cow::Owned(prefix.join("share/doc/rust")));
+ let libdir = build.config.libdir.as_ref().clone().map(|x| Cow::Borrowed(Path::new(x)))
+ .unwrap_or(Cow::Owned(prefix.join("lib")));
+ let mandir = build.config.mandir.as_ref().clone().map(|x| Cow::Borrowed(Path::new(x)))
+ .unwrap_or(Cow::Owned(prefix.join("share/man")));
+ let empty_dir = build.out.join("tmp/empty_dir");
+ t!(fs::create_dir_all(&empty_dir));
+ if build.config.docs {
+ install_sh(&build, "docs", "rust-docs", stage, host, prefix,
+ &docdir, &libdir, &mandir, &empty_dir);
+ }
+ install_sh(&build, "std", "rust-std", stage, host, prefix,
+ &docdir, &libdir, &mandir, &empty_dir);
+ install_sh(&build, "rustc", "rustc", stage, host, prefix,
+ &docdir, &libdir, &mandir, &empty_dir);
+ t!(fs::remove_dir_all(&empty_dir));
+}
+
+fn install_sh(build: &Build, package: &str, name: &str, stage: u32, host: &str,
+ prefix: &Path, docdir: &Path, libdir: &Path, mandir: &Path, empty_dir: &Path) {
+ println!("Install {} stage{} ({})", package, stage, host);
+ let package_name = format!("{}-{}-{}", name, package_vers(build), host);
+
+ let mut cmd = Command::new("sh");
+ cmd.current_dir(empty_dir)
+ .arg(sanitize_sh(&tmpdir(build).join(&package_name).join("install.sh")))
+ .arg(format!("--prefix={}", sanitize_sh(prefix)))
+ .arg(format!("--docdir={}", sanitize_sh(docdir)))
+ .arg(format!("--libdir={}", sanitize_sh(libdir)))
+ .arg(format!("--mandir={}", sanitize_sh(mandir)))
+ .arg("--disable-ldconfig");
+ build.run(&mut cmd);
+}
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
index 32232cbee9..3f8e3fe531 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -26,7 +26,6 @@ extern crate md5;
extern crate num_cpus;
extern crate rustc_serialize;
extern crate toml;
-extern crate regex;
use std::collections::HashMap;
use std::env;
@@ -58,10 +57,12 @@ mod channel;
mod check;
mod clean;
mod compile;
+mod metadata;
mod config;
mod dist;
mod doc;
mod flags;
+mod install;
mod native;
mod sanity;
mod step;
@@ -76,7 +77,7 @@ mod job {
}
pub use config::Config;
-pub use flags::Flags;
+pub use flags::{Flags, Subcommand};
/// A structure representing a Rust compiler.
///
@@ -123,13 +124,23 @@ pub struct Build {
bootstrap_key_stage0: String,
// Probed tools at runtime
- gdb_version: Option,
lldb_version: Option,
lldb_python_dir: Option,
// Runtime state filled in later on
cc: HashMap)>,
cxx: HashMap,
+ crates: HashMap,
+}
+
+#[derive(Debug)]
+struct Crate {
+ name: String,
+ deps: Vec,
+ path: PathBuf,
+ doc_step: String,
+ build_step: String,
+ test_step: String,
}
/// The various "modes" of invoking Cargo.
@@ -162,7 +173,9 @@ impl Build {
/// By default all build output will be placed in the current directory.
pub fn new(flags: Flags, config: Config) -> Build {
let cwd = t!(env::current_dir());
- let src = flags.src.clone().unwrap_or(cwd.clone());
+ let src = flags.src.clone().or_else(|| {
+ env::var_os("SRC").map(|x| x.into())
+ }).unwrap_or(cwd.clone());
let out = cwd.join("build");
let stage0_root = out.join(&config.build).join("stage0/bin");
@@ -196,7 +209,7 @@ impl Build {
package_vers: String::new(),
cc: HashMap::new(),
cxx: HashMap::new(),
- gdb_version: None,
+ crates: HashMap::new(),
lldb_version: None,
lldb_python_dir: None,
}
@@ -204,13 +217,11 @@ impl Build {
/// Executes the entire build, as configured by the flags and configuration.
pub fn build(&mut self) {
- use step::Source::*;
-
unsafe {
job::setup();
}
- if self.flags.clean {
+ if let Subcommand::Clean = self.flags.cmd {
return clean::clean(self);
}
@@ -220,257 +231,22 @@ impl Build {
sanity::check(self);
self.verbose("collecting channel variables");
channel::collect(self);
- // If local-rust is the same as the current version, then force a local-rebuild
+ // If local-rust is the same major.minor as the current version, then force a local-rebuild
let local_version_verbose = output(
Command::new(&self.rustc).arg("--version").arg("--verbose"));
let local_release = local_version_verbose
.lines().filter(|x| x.starts_with("release:"))
.next().unwrap().trim_left_matches("release:").trim();
- if local_release == self.release {
- self.verbose(&format!("auto-detected local-rebuild {}", self.release));
+ if local_release.split('.').take(2).eq(self.release.split('.').take(2)) {
+ self.verbose(&format!("auto-detected local-rebuild {}", local_release));
self.local_rebuild = true;
}
self.verbose("updating submodules");
self.update_submodules();
+ self.verbose("learning about cargo");
+ metadata::build(self);
- // The main loop of the build system.
- //
- // The `step::all` function returns a topographically sorted list of all
- // steps that need to be executed as part of this build. Each step has a
- // corresponding entry in `step.rs` and indicates some unit of work that
- // needs to be done as part of the build.
- //
- // Almost all of these are simple one-liners that shell out to the
- // corresponding functionality in the extra modules, where more
- // documentation can be found.
- let steps = step::all(self);
-
- self.verbose("bootstrap build plan:");
- for step in &steps {
- self.verbose(&format!("{:?}", step));
- }
-
- for target in steps {
- let doc_out = self.out.join(&target.target).join("doc");
- match target.src {
- Llvm { _dummy } => {
- native::llvm(self, target.target);
- }
- TestHelpers { _dummy } => {
- native::test_helpers(self, target.target);
- }
- Libstd { compiler } => {
- compile::std(self, target.target, &compiler);
- }
- Libtest { compiler } => {
- compile::test(self, target.target, &compiler);
- }
- Librustc { compiler } => {
- compile::rustc(self, target.target, &compiler);
- }
- LibstdLink { compiler, host } => {
- compile::std_link(self, target.target, &compiler, host);
- }
- LibtestLink { compiler, host } => {
- compile::test_link(self, target.target, &compiler, host);
- }
- LibrustcLink { compiler, host } => {
- compile::rustc_link(self, target.target, &compiler, host);
- }
- Rustc { stage: 0 } => {
- // nothing to do...
- }
- Rustc { stage } => {
- compile::assemble_rustc(self, stage, target.target);
- }
- ToolLinkchecker { stage } => {
- compile::tool(self, stage, target.target, "linkchecker");
- }
- ToolRustbook { stage } => {
- compile::tool(self, stage, target.target, "rustbook");
- }
- ToolErrorIndex { stage } => {
- compile::tool(self, stage, target.target,
- "error_index_generator");
- }
- ToolCargoTest { stage } => {
- compile::tool(self, stage, target.target, "cargotest");
- }
- ToolTidy { stage } => {
- compile::tool(self, stage, target.target, "tidy");
- }
- ToolCompiletest { stage } => {
- compile::tool(self, stage, target.target, "compiletest");
- }
- DocBook { stage } => {
- doc::rustbook(self, stage, target.target, "book", &doc_out);
- }
- DocNomicon { stage } => {
- doc::rustbook(self, stage, target.target, "nomicon",
- &doc_out);
- }
- DocStandalone { stage } => {
- doc::standalone(self, stage, target.target, &doc_out);
- }
- DocStd { stage } => {
- doc::std(self, stage, target.target, &doc_out);
- }
- DocTest { stage } => {
- doc::test(self, stage, target.target, &doc_out);
- }
- DocRustc { stage } => {
- doc::rustc(self, stage, target.target, &doc_out);
- }
- DocErrorIndex { stage } => {
- doc::error_index(self, stage, target.target, &doc_out);
- }
-
- CheckLinkcheck { stage } => {
- check::linkcheck(self, stage, target.target);
- }
- CheckCargoTest { stage } => {
- check::cargotest(self, stage, target.target);
- }
- CheckTidy { stage } => {
- check::tidy(self, stage, target.target);
- }
- CheckRPass { compiler } => {
- check::compiletest(self, &compiler, target.target,
- "run-pass", "run-pass");
- }
- CheckRPassFull { compiler } => {
- check::compiletest(self, &compiler, target.target,
- "run-pass", "run-pass-fulldeps");
- }
- CheckCFail { compiler } => {
- check::compiletest(self, &compiler, target.target,
- "compile-fail", "compile-fail");
- }
- CheckCFailFull { compiler } => {
- check::compiletest(self, &compiler, target.target,
- "compile-fail", "compile-fail-fulldeps")
- }
- CheckPFail { compiler } => {
- check::compiletest(self, &compiler, target.target,
- "parse-fail", "parse-fail");
- }
- CheckRFail { compiler } => {
- check::compiletest(self, &compiler, target.target,
- "run-fail", "run-fail");
- }
- CheckRFailFull { compiler } => {
- check::compiletest(self, &compiler, target.target,
- "run-fail", "run-fail-fulldeps");
- }
- CheckPretty { compiler } => {
- check::compiletest(self, &compiler, target.target,
- "pretty", "pretty");
- }
- CheckPrettyRPass { compiler } => {
- check::compiletest(self, &compiler, target.target,
- "pretty", "run-pass");
- }
- CheckPrettyRPassFull { compiler } => {
- check::compiletest(self, &compiler, target.target,
- "pretty", "run-pass-fulldeps");
- }
- CheckPrettyRFail { compiler } => {
- check::compiletest(self, &compiler, target.target,
- "pretty", "run-fail");
- }
- CheckPrettyRFailFull { compiler } => {
- check::compiletest(self, &compiler, target.target,
- "pretty", "run-fail-fulldeps");
- }
- CheckPrettyRPassValgrind { compiler } => {
- check::compiletest(self, &compiler, target.target,
- "pretty", "run-pass-valgrind");
- }
- CheckMirOpt { compiler } => {
- check::compiletest(self, &compiler, target.target,
- "mir-opt", "mir-opt");
- }
- CheckCodegen { compiler } => {
- if self.config.codegen_tests {
- check::compiletest(self, &compiler, target.target,
- "codegen", "codegen");
- }
- }
- CheckCodegenUnits { compiler } => {
- check::compiletest(self, &compiler, target.target,
- "codegen-units", "codegen-units");
- }
- CheckIncremental { compiler } => {
- check::compiletest(self, &compiler, target.target,
- "incremental", "incremental");
- }
- CheckUi { compiler } => {
- check::compiletest(self, &compiler, target.target,
- "ui", "ui");
- }
- CheckDebuginfo { compiler } => {
- if target.target.contains("msvc") {
- // nothing to do
- } else if target.target.contains("apple") {
- check::compiletest(self, &compiler, target.target,
- "debuginfo-lldb", "debuginfo");
- } else {
- check::compiletest(self, &compiler, target.target,
- "debuginfo-gdb", "debuginfo");
- }
- }
- CheckRustdoc { compiler } => {
- check::compiletest(self, &compiler, target.target,
- "rustdoc", "rustdoc");
- }
- CheckRPassValgrind { compiler } => {
- check::compiletest(self, &compiler, target.target,
- "run-pass-valgrind", "run-pass-valgrind");
- }
- CheckDocs { compiler } => {
- check::docs(self, &compiler);
- }
- CheckErrorIndex { compiler } => {
- check::error_index(self, &compiler);
- }
- CheckRMake { compiler } => {
- check::compiletest(self, &compiler, target.target,
- "run-make", "run-make")
- }
- CheckCrateStd { compiler } => {
- check::krate(self, &compiler, target.target, Mode::Libstd)
- }
- CheckCrateTest { compiler } => {
- check::krate(self, &compiler, target.target, Mode::Libtest)
- }
- CheckCrateRustc { compiler } => {
- check::krate(self, &compiler, target.target, Mode::Librustc)
- }
-
- DistDocs { stage } => dist::docs(self, stage, target.target),
- DistMingw { _dummy } => dist::mingw(self, target.target),
- DistRustc { stage } => dist::rustc(self, stage, target.target),
- DistStd { compiler } => dist::std(self, &compiler, target.target),
- DistSrc { _dummy } => dist::rust_src(self),
-
- DebuggerScripts { stage } => {
- let compiler = Compiler::new(stage, target.target);
- dist::debugger_scripts(self,
- &self.sysroot(&compiler),
- target.target);
- }
-
- AndroidCopyLibs { compiler } => {
- check::android_copy_libs(self, &compiler, target.target);
- }
-
- // pseudo-steps
- Dist { .. } |
- Doc { .. } |
- CheckTarget { .. } |
- Check { .. } => {}
- }
- }
+ step::run(self);
}
/// Updates all git submodules that we have.
@@ -557,12 +333,23 @@ impl Build {
continue
}
+ // `submodule.path` is the relative path to a submodule (from the repository root)
+ // `submodule_path` is the path to a submodule from the cwd
+
+ // use `submodule.path` when e.g. executing a submodule specific command from the
+ // repository root
+ // use `submodule_path` when e.g. executing a normal git command for the submodule
+ // (set via `current_dir`)
+ let submodule_path = self.src.join(submodule.path);
+
match submodule.state {
State::MaybeDirty => {
// drop staged changes
- self.run(git().arg("-C").arg(submodule.path).args(&["reset", "--hard"]));
+ self.run(git().current_dir(&submodule_path)
+ .args(&["reset", "--hard"]));
// drops unstaged changes
- self.run(git().arg("-C").arg(submodule.path).args(&["clean", "-fdx"]));
+ self.run(git().current_dir(&submodule_path)
+ .args(&["clean", "-fdx"]));
},
State::NotInitialized => {
self.run(git_submodule().arg("init").arg(submodule.path));
@@ -571,8 +358,10 @@ impl Build {
State::OutOfSync => {
// drops submodule commits that weren't reported to the (outer) git repository
self.run(git_submodule().arg("update").arg(submodule.path));
- self.run(git().arg("-C").arg(submodule.path).args(&["reset", "--hard"]));
- self.run(git().arg("-C").arg(submodule.path).args(&["clean", "-fdx"]));
+ self.run(git().current_dir(&submodule_path)
+ .args(&["reset", "--hard"]));
+ self.run(git().current_dir(&submodule_path)
+ .args(&["clean", "-fdx"]));
},
}
}
@@ -634,6 +423,7 @@ impl Build {
.env("RUSTC_REAL", self.compiler_path(compiler))
.env("RUSTC_STAGE", stage.to_string())
.env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string())
+ .env("RUSTC_DEBUGINFO_LINES", self.config.rust_debuginfo_lines.to_string())
.env("RUSTC_CODEGEN_UNITS",
self.config.rust_codegen_units.to_string())
.env("RUSTC_DEBUG_ASSERTIONS",
@@ -659,12 +449,6 @@ impl Build {
.env(format!("CFLAGS_{}", target), self.cflags(target).join(" "));
}
- // If we're building for OSX, inform the compiler and the linker that
- // we want to build a compiler runnable on 10.7
- if target.contains("apple-darwin") {
- cargo.env("MACOSX_DEPLOYMENT_TARGET", "10.7");
- }
-
// Environment variables *required* needed throughout the build
//
// FIXME: should update code to not require this env var
@@ -802,6 +586,11 @@ impl Build {
self.out.join(target).join("llvm")
}
+ /// Output directory for all documentation for a target
+ fn doc_out(&self, target: &str) -> PathBuf {
+ self.out.join(target).join("doc")
+ }
+
/// Returns true if no custom `llvm-config` is set for the specified target.
///
/// If no custom `llvm-config` was specified then Rust's llvm will be used.
@@ -866,7 +655,7 @@ impl Build {
cmd.env("RUSTC_BOOTSTRAP", "1");
// FIXME: Transitionary measure to bootstrap using the old bootstrap logic.
// Remove this once the bootstrap compiler uses the new login in Issue #36548.
- cmd.env("RUSTC_BOOTSTRAP_KEY", "5c6cf767");
+ cmd.env("RUSTC_BOOTSTRAP_KEY", "62b3e239");
}
/// Returns the compiler's libdir where it stores the dynamic libraries that
@@ -928,7 +717,6 @@ impl Build {
// LLVM/jemalloc/etc are all properly compiled.
if target.contains("apple-darwin") {
base.push("-stdlib=libc++".into());
- base.push("-mmacosx-version-min=10.7".into());
}
// This is a hack, because newer binutils broke things on some vms/distros
// (i.e., linking against unknown relocs disabled by the following flag)
@@ -969,7 +757,8 @@ impl Build {
// than an entry here.
let mut base = Vec::new();
- if target != self.config.build && !target.contains("msvc") {
+ if target != self.config.build && !target.contains("msvc") &&
+ !target.contains("emscripten") {
base.push(format!("-Clinker={}", self.cc(target).display()));
}
return base
@@ -977,7 +766,8 @@ impl Build {
/// Returns the "musl root" for this `target`, if defined
fn musl_root(&self, target: &str) -> Option<&Path> {
- self.config.target_config[target].musl_root.as_ref()
+ self.config.target_config.get(target)
+ .and_then(|t| t.musl_root.as_ref())
.or(self.config.musl_root.as_ref())
.map(|p| &**p)
}
diff --git a/src/bootstrap/metadata.rs b/src/bootstrap/metadata.rs
new file mode 100644
index 0000000000..bf5cc6a4ad
--- /dev/null
+++ b/src/bootstrap/metadata.rs
@@ -0,0 +1,95 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 or the MIT license
+// , at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::collections::HashMap;
+use std::process::Command;
+use std::path::PathBuf;
+
+use build_helper::output;
+use rustc_serialize::json;
+
+use {Build, Crate};
+
+#[derive(RustcDecodable)]
+struct Output {
+ packages: Vec,
+ resolve: Resolve,
+}
+
+#[derive(RustcDecodable)]
+struct Package {
+ id: String,
+ name: String,
+ source: Option,
+ manifest_path: String,
+}
+
+#[derive(RustcDecodable)]
+struct Resolve {
+ nodes: Vec,
+}
+
+#[derive(RustcDecodable)]
+struct ResolveNode {
+ id: String,
+ dependencies: Vec,
+}
+
+pub fn build(build: &mut Build) {
+ build_krate(build, "src/rustc/std_shim");
+ build_krate(build, "src/rustc/test_shim");
+ build_krate(build, "src/rustc");
+}
+
+fn build_krate(build: &mut Build, krate: &str) {
+ // Run `cargo metadata` to figure out what crates we're testing.
+ //
+ // Down below we're going to call `cargo test`, but to test the right set
+ // of packages we're going to have to know what `-p` arguments to pass it
+ // to know what crates to test. Here we run `cargo metadata` to learn about
+ // the dependency graph and what `-p` arguments there are.
+ let mut cargo = Command::new(&build.cargo);
+ cargo.arg("metadata")
+ .arg("--manifest-path").arg(build.src.join(krate).join("Cargo.toml"));
+ let output = output(&mut cargo);
+ let output: Output = json::decode(&output).unwrap();
+ let mut id2name = HashMap::new();
+ for package in output.packages {
+ if package.source.is_none() {
+ id2name.insert(package.id, package.name.clone());
+ let mut path = PathBuf::from(package.manifest_path);
+ path.pop();
+ build.crates.insert(package.name.clone(), Crate {
+ build_step: format!("build-crate-{}", package.name),
+ doc_step: format!("doc-crate-{}", package.name),
+ test_step: format!("test-crate-{}", package.name),
+ name: package.name,
+ deps: Vec::new(),
+ path: path,
+ });
+ }
+ }
+
+ for node in output.resolve.nodes {
+ let name = match id2name.get(&node.id) {
+ Some(name) => name,
+ None => continue,
+ };
+
+ let krate = build.crates.get_mut(name).unwrap();
+ for dep in node.dependencies.iter() {
+ let dep = match id2name.get(dep) {
+ Some(dep) => dep,
+ None => continue,
+ };
+ krate.deps.push(dep.clone());
+ }
+ }
+}
diff --git a/src/bootstrap/mk/Makefile.in b/src/bootstrap/mk/Makefile.in
index cc44d45c2c..d403107763 100644
--- a/src/bootstrap/mk/Makefile.in
+++ b/src/bootstrap/mk/Makefile.in
@@ -17,41 +17,46 @@ else
BOOTSTRAP_ARGS :=
endif
-BOOTSTRAP := $(CFG_PYTHON) $(CFG_SRC_DIR)src/bootstrap/bootstrap.py $(BOOTSTRAP_ARGS)
+BOOTSTRAP := $(CFG_PYTHON) $(CFG_SRC_DIR)src/bootstrap/bootstrap.py
all:
- $(Q)$(BOOTSTRAP)
+ $(Q)$(BOOTSTRAP) build $(BOOTSTRAP_ARGS)
+ $(Q)$(BOOTSTRAP) doc $(BOOTSTRAP_ARGS)
# Donât use $(Q) here, always show how to invoke the bootstrap script directly
help:
$(BOOTSTRAP) --help
clean:
- $(Q)$(BOOTSTRAP) --clean
+ $(Q)$(BOOTSTRAP) clean $(BOOTSTRAP_ARGS)
rustc-stage1:
- $(Q)$(BOOTSTRAP) --step libtest --stage 1
+ $(Q)$(BOOTSTRAP) build --stage 1 src/libtest $(BOOTSTRAP_ARGS)
rustc-stage2:
- $(Q)$(BOOTSTRAP) --step libtest --stage 2
+ $(Q)$(BOOTSTRAP) build --stage 2 src/libtest $(BOOTSTRAP_ARGS)
docs: doc
doc:
- $(Q)$(BOOTSTRAP) --step doc
-style:
- $(Q)$(BOOTSTRAP) --step doc-style
+ $(Q)$(BOOTSTRAP) doc $(BOOTSTRAP_ARGS)
nomicon:
- $(Q)$(BOOTSTRAP) --step doc-nomicon
+ $(Q)$(BOOTSTRAP) doc src/doc/nomicon $(BOOTSTRAP_ARGS)
book:
- $(Q)$(BOOTSTRAP) --step doc-book
+ $(Q)$(BOOTSTRAP) doc src/doc/book $(BOOTSTRAP_ARGS)
standalone-docs:
- $(Q)$(BOOTSTRAP) --step doc-standalone
+ $(Q)$(BOOTSTRAP) doc src/doc $(BOOTSTRAP_ARGS)
check:
- $(Q)$(BOOTSTRAP) --step check
+ $(Q)$(BOOTSTRAP) test $(BOOTSTRAP_ARGS)
check-cargotest:
- $(Q)$(BOOTSTRAP) --step check-cargotest
+ $(Q)$(BOOTSTRAP) test src/tools/cargotest $(BOOTSTRAP_ARGS)
dist:
- $(Q)$(BOOTSTRAP) --step dist
+ $(Q)$(BOOTSTRAP) dist $(BOOTSTRAP_ARGS)
+install:
+ifeq (root user, $(USER) $(patsubst %,user,$(SUDO_USER)))
+ $(Q)echo "'sudo make install' is not supported currently."
+else
+ $(Q)$(BOOTSTRAP) dist --install $(BOOTSTRAP_ARGS)
+endif
tidy:
- $(Q)$(BOOTSTRAP) --step check-tidy --stage 0
+ $(Q)$(BOOTSTRAP) test src/tools/tidy $(BOOTSTRAP_ARGS)
.PHONY: dist
diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs
index df6408e5fe..1b4e86fb30 100644
--- a/src/bootstrap/native.rs
+++ b/src/bootstrap/native.rs
@@ -18,9 +18,10 @@
//! LLVM and compiler-rt are essentially just wired up to everything else to
//! ensure that they're always in place if needed.
+use std::fs::{self, File};
+use std::io::{Read, Write};
use std::path::Path;
use std::process::Command;
-use std::fs::{self, File};
use build_helper::output;
use cmake;
@@ -43,11 +44,17 @@ pub fn llvm(build: &Build, target: &str) {
// artifacts are missing) then we keep going, otherwise we bail out.
let dst = build.llvm_out(target);
let stamp = build.src.join("src/rustllvm/llvm-auto-clean-trigger");
+ let mut stamp_contents = String::new();
+ t!(t!(File::open(&stamp)).read_to_string(&mut stamp_contents));
let done_stamp = dst.join("llvm-finished-building");
- build.clear_if_dirty(&dst, &stamp);
- if fs::metadata(&done_stamp).is_ok() {
- return
+ if done_stamp.exists() {
+ let mut done_contents = String::new();
+ t!(t!(File::open(&done_stamp)).read_to_string(&mut done_contents));
+ if done_contents == stamp_contents {
+ return
+ }
}
+ drop(fs::remove_dir_all(&dst));
println!("Building LLVM for {}", target);
@@ -65,7 +72,7 @@ pub fn llvm(build: &Build, target: &str) {
.out_dir(&dst)
.profile(if build.config.llvm_optimize {"Release"} else {"Debug"})
.define("LLVM_ENABLE_ASSERTIONS", assertions)
- .define("LLVM_TARGETS_TO_BUILD", "X86;ARM;AArch64;Mips;PowerPC;SystemZ")
+ .define("LLVM_TARGETS_TO_BUILD", "X86;ARM;AArch64;Mips;PowerPC;SystemZ;JSBackend")
.define("LLVM_INCLUDE_EXAMPLES", "OFF")
.define("LLVM_INCLUDE_TESTS", "OFF")
.define("LLVM_INCLUDE_DOCS", "OFF")
@@ -73,7 +80,9 @@ pub fn llvm(build: &Build, target: &str) {
.define("WITH_POLLY", "OFF")
.define("LLVM_ENABLE_TERMINFO", "OFF")
.define("LLVM_ENABLE_LIBEDIT", "OFF")
- .define("LLVM_PARALLEL_COMPILE_JOBS", build.jobs().to_string());
+ .define("LLVM_PARALLEL_COMPILE_JOBS", build.jobs().to_string())
+ .define("LLVM_TARGET_ARCH", target.split('-').next().unwrap())
+ .define("LLVM_DEFAULT_TARGET_TRIPLE", target);
if target.starts_with("i686") {
cfg.define("LLVM_BUILD_32_BITS", "ON");
@@ -86,9 +95,7 @@ pub fn llvm(build: &Build, target: &str) {
// actually exists most of the time in normal installs of LLVM.
let host = build.llvm_out(&build.config.build).join("bin/llvm-tblgen");
cfg.define("CMAKE_CROSSCOMPILING", "True")
- .define("LLVM_TARGET_ARCH", target.split('-').next().unwrap())
- .define("LLVM_TABLEGEN", &host)
- .define("LLVM_DEFAULT_TARGET_TRIPLE", target);
+ .define("LLVM_TABLEGEN", &host);
}
// MSVC handles compiler business itself
@@ -114,7 +121,7 @@ pub fn llvm(build: &Build, target: &str) {
// tools and libs on all platforms.
cfg.build();
- t!(File::create(&done_stamp));
+ t!(t!(File::create(&done_stamp)).write_all(stamp_contents.as_bytes()));
}
fn check_llvm_version(build: &Build, llvm_config: &Path) {
diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs
index 05c35543e3..cc1b7136d4 100644
--- a/src/bootstrap/sanity.rs
+++ b/src/bootstrap/sanity.rs
@@ -40,17 +40,23 @@ pub fn check(build: &mut Build) {
panic!("PATH contains invalid character '\"'");
}
}
- let mut need_cmd = |cmd: &OsStr| {
- if !checked.insert(cmd.to_owned()) {
- return
- }
+ let have_cmd = |cmd: &OsStr| {
for path in env::split_paths(&path).map(|p| p.join(cmd)) {
if fs::metadata(&path).is_ok() ||
fs::metadata(path.with_extension("exe")).is_ok() {
- return
+ return Some(path);
}
}
- panic!("\n\ncouldn't find required command: {:?}\n\n", cmd);
+ return None;
+ };
+
+ let mut need_cmd = |cmd: &OsStr| {
+ if !checked.insert(cmd.to_owned()) {
+ return
+ }
+ if have_cmd(cmd).is_none() {
+ panic!("\n\ncouldn't find required command: {:?}\n\n", cmd);
+ }
};
// If we've got a git directory we're gona need git to update
@@ -75,15 +81,33 @@ pub fn check(build: &mut Build) {
need_cmd("python".as_ref());
- // If a manual nodejs was added to the config,
- // of if a nodejs install is detected through config, use it.
+ // Look for the nodejs command, needed for emscripten testing
+ if let Some(node) = have_cmd("node".as_ref()) {
+ build.config.nodejs = Some(node);
+ } else if let Some(node) = have_cmd("nodejs".as_ref()) {
+ build.config.nodejs = Some(node);
+ }
+
if let Some(ref s) = build.config.nodejs {
need_cmd(s.as_ref());
}
+ if let Some(ref gdb) = build.config.gdb {
+ need_cmd(gdb.as_ref());
+ } else {
+ build.config.gdb = have_cmd("gdb".as_ref());
+ }
+
// We're gonna build some custom C code here and there, host triples
// also build some C++ shims for LLVM so we need a C++ compiler.
for target in build.config.target.iter() {
+ // On emscripten we don't actually need the C compiler to just
+ // build the target artifacts, only for testing. For the sake
+ // of easier bot configuration, just skip detection.
+ if target.contains("emscripten") {
+ continue;
+ }
+
need_cmd(build.cc(target).as_ref());
if let Some(ar) = build.ar(target) {
need_cmd(ar.as_ref());
@@ -93,6 +117,14 @@ pub fn check(build: &mut Build) {
need_cmd(build.cxx(host).as_ref());
}
+ // The msvc hosts don't use jemalloc, turn it off globally to
+ // avoid packaging the dummy liballoc_jemalloc on that platform.
+ for host in build.config.host.iter() {
+ if host.contains("msvc") {
+ build.config.use_jemalloc = false;
+ }
+ }
+
// Externally configured LLVM requires FileCheck to exist
let filecheck = build.llvm_filecheck(&build.config.build);
if !filecheck.starts_with(&build.out) && !filecheck.exists() && build.config.codegen_tests {
@@ -100,15 +132,6 @@ pub fn check(build: &mut Build) {
}
for target in build.config.target.iter() {
- // Either can't build or don't want to run jemalloc on these targets
- if target.contains("rumprun") ||
- target.contains("bitrig") ||
- target.contains("openbsd") ||
- target.contains("msvc") ||
- target.contains("emscripten") {
- build.config.use_jemalloc = false;
- }
-
// Can't compile for iOS unless we're on OSX
if target.contains("apple-ios") &&
!build.config.build.contains("apple-darwin") {
@@ -129,8 +152,8 @@ pub fn check(build: &mut Build) {
}
}
None => {
- panic!("when targeting MUSL either the build.musl-root \
- option or the target.$TARGET.musl-root one must \
+ panic!("when targeting MUSL either the rust.musl-root \
+ option or the target.$TARGET.musl-root option must \
be specified in config.toml")
}
}
@@ -181,7 +204,6 @@ $ pacman -R cmake && pacman -S mingw-w64-x86_64-cmake
.to_string()
})
};
- build.gdb_version = run(Command::new("gdb").arg("--version")).ok();
build.lldb_version = run(Command::new("lldb").arg("--version")).ok();
if build.lldb_version.is_some() {
build.lldb_python_dir = run(Command::new("lldb").arg("-P")).ok();
diff --git a/src/bootstrap/step.rs b/src/bootstrap/step.rs
index 4b5a26d205..56be2ccb23 100644
--- a/src/bootstrap/step.rs
+++ b/src/bootstrap/step.rs
@@ -8,592 +8,694 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-//! Major workhorse of rustbuild, definition and dependencies between stages of
-//! the copmile.
-//!
-//! The primary purpose of this module is to define the various `Step`s of
-//! execution of the build. Each `Step` has a corresponding `Source` indicating
-//! what it's actually doing along with a number of dependencies which must be
-//! executed first.
-//!
-//! This module will take the CLI as input and calculate the steps required for
-//! the build requested, ensuring that all intermediate pieces are in place.
-//! Essentially this module is a `make`-replacement, but not as good.
-
-use std::collections::HashSet;
-
-use {Build, Compiler};
-
-#[derive(Hash, Eq, PartialEq, Clone, Debug)]
-pub struct Step<'a> {
- pub src: Source<'a>,
- pub target: &'a str,
+use std::collections::{HashMap, HashSet};
+use std::mem;
+
+use check;
+use compile;
+use dist;
+use doc;
+use flags::Subcommand;
+use install;
+use native;
+use {Compiler, Build, Mode};
+
+#[derive(PartialEq, Eq, Hash, Clone, Debug)]
+struct Step<'a> {
+ name: &'a str,
+ stage: u32,
+ host: &'a str,
+ target: &'a str,
}
-/// Macro used to iterate over all targets that are recognized by the build
-/// system.
-///
-/// Whenever a new step is added it will involve adding an entry here, updating
-/// the dependencies section below, and then adding an implementation of the
-/// step in `build/mod.rs`.
-///
-/// This macro takes another macro as an argument and then calls that macro with
-/// all steps that the build system knows about.
-macro_rules! targets {
- ($m:ident) => {
- $m! {
- // Step representing building the stageN compiler. This is just the
- // compiler executable itself, not any of the support libraries
- (rustc, Rustc { stage: u32 }),
-
- // Steps for the two main cargo builds. These are parameterized over
- // the compiler which is producing the artifact.
- (libstd, Libstd { compiler: Compiler<'a> }),
- (libtest, Libtest { compiler: Compiler<'a> }),
- (librustc, Librustc { compiler: Compiler<'a> }),
-
- // Links the target produced by the compiler provided into the
- // host's directory also provided.
- (libstd_link, LibstdLink {
- compiler: Compiler<'a>,
- host: &'a str
- }),
- (libtest_link, LibtestLink {
- compiler: Compiler<'a>,
- host: &'a str
- }),
- (librustc_link, LibrustcLink {
- compiler: Compiler<'a>,
- host: &'a str
- }),
-
- // Various tools that we can build as part of the build.
- (tool_linkchecker, ToolLinkchecker { stage: u32 }),
- (tool_rustbook, ToolRustbook { stage: u32 }),
- (tool_error_index, ToolErrorIndex { stage: u32 }),
- (tool_cargotest, ToolCargoTest { stage: u32 }),
- (tool_tidy, ToolTidy { stage: u32 }),
- (tool_compiletest, ToolCompiletest { stage: u32 }),
-
- // Steps for long-running native builds. Ideally these wouldn't
- // actually exist and would be part of build scripts, but for now
- // these are here.
- //
- // There aren't really any parameters to this, but empty structs
- // with braces are unstable so we just pick something that works.
- (llvm, Llvm { _dummy: () }),
- (test_helpers, TestHelpers { _dummy: () }),
- (debugger_scripts, DebuggerScripts { stage: u32 }),
-
- // Steps for various pieces of documentation that we can generate,
- // the 'doc' step is just a pseudo target to depend on a bunch of
- // others.
- (doc, Doc { stage: u32 }),
- (doc_book, DocBook { stage: u32 }),
- (doc_nomicon, DocNomicon { stage: u32 }),
- (doc_standalone, DocStandalone { stage: u32 }),
- (doc_std, DocStd { stage: u32 }),
- (doc_test, DocTest { stage: u32 }),
- (doc_rustc, DocRustc { stage: u32 }),
- (doc_error_index, DocErrorIndex { stage: u32 }),
-
- // Steps for running tests. The 'check' target is just a pseudo
- // target to depend on a bunch of others.
- (check, Check { stage: u32, compiler: Compiler<'a> }),
- (check_target, CheckTarget { stage: u32, compiler: Compiler<'a> }),
- (check_linkcheck, CheckLinkcheck { stage: u32 }),
- (check_cargotest, CheckCargoTest { stage: u32 }),
- (check_tidy, CheckTidy { stage: u32 }),
- (check_rpass, CheckRPass { compiler: Compiler<'a> }),
- (check_rpass_full, CheckRPassFull { compiler: Compiler<'a> }),
- (check_rpass_valgrind, CheckRPassValgrind { compiler: Compiler<'a> }),
- (check_rfail, CheckRFail { compiler: Compiler<'a> }),
- (check_rfail_full, CheckRFailFull { compiler: Compiler<'a> }),
- (check_cfail, CheckCFail { compiler: Compiler<'a> }),
- (check_cfail_full, CheckCFailFull { compiler: Compiler<'a> }),
- (check_pfail, CheckPFail { compiler: Compiler<'a> }),
- (check_pretty, CheckPretty { compiler: Compiler<'a> }),
- (check_pretty_rpass, CheckPrettyRPass { compiler: Compiler<'a> }),
- (check_pretty_rpass_full, CheckPrettyRPassFull { compiler: Compiler<'a> }),
- (check_pretty_rfail, CheckPrettyRFail { compiler: Compiler<'a> }),
- (check_pretty_rfail_full, CheckPrettyRFailFull { compiler: Compiler<'a> }),
- (check_pretty_rpass_valgrind, CheckPrettyRPassValgrind { compiler: Compiler<'a> }),
- (check_codegen, CheckCodegen { compiler: Compiler<'a> }),
- (check_codegen_units, CheckCodegenUnits { compiler: Compiler<'a> }),
- (check_incremental, CheckIncremental { compiler: Compiler<'a> }),
- (check_ui, CheckUi { compiler: Compiler<'a> }),
- (check_mir_opt, CheckMirOpt { compiler: Compiler<'a> }),
- (check_debuginfo, CheckDebuginfo { compiler: Compiler<'a> }),
- (check_rustdoc, CheckRustdoc { compiler: Compiler<'a> }),
- (check_docs, CheckDocs { compiler: Compiler<'a> }),
- (check_error_index, CheckErrorIndex { compiler: Compiler<'a> }),
- (check_rmake, CheckRMake { compiler: Compiler<'a> }),
- (check_crate_std, CheckCrateStd { compiler: Compiler<'a> }),
- (check_crate_test, CheckCrateTest { compiler: Compiler<'a> }),
- (check_crate_rustc, CheckCrateRustc { compiler: Compiler<'a> }),
-
- // Distribution targets, creating tarballs
- (dist, Dist { stage: u32 }),
- (dist_docs, DistDocs { stage: u32 }),
- (dist_mingw, DistMingw { _dummy: () }),
- (dist_rustc, DistRustc { stage: u32 }),
- (dist_std, DistStd { compiler: Compiler<'a> }),
- (dist_src, DistSrc { _dummy: () }),
-
- // Misc targets
- (android_copy_libs, AndroidCopyLibs { compiler: Compiler<'a> }),
- }
+impl<'a> Step<'a> {
+ fn name(&self, name: &'a str) -> Step<'a> {
+ Step { name: name, ..*self }
}
-}
-// Define the `Source` enum by iterating over all the steps and peeling out just
-// the types that we want to define.
+ fn stage(&self, stage: u32) -> Step<'a> {
+ Step { stage: stage, ..*self }
+ }
-macro_rules! item { ($a:item) => ($a) }
+ fn host(&self, host: &'a str) -> Step<'a> {
+ Step { host: host, ..*self }
+ }
-macro_rules! define_source {
- ($(($short:ident, $name:ident { $($args:tt)* }),)*) => {
- item! {
- #[derive(Hash, Eq, PartialEq, Clone, Debug)]
- pub enum Source<'a> {
- $($name { $($args)* }),*
- }
- }
+ fn target(&self, target: &'a str) -> Step<'a> {
+ Step { target: target, ..*self }
}
-}
-targets!(define_source);
-
-/// Calculate a list of all steps described by `build`.
-///
-/// This will inspect the flags passed in on the command line and use that to
-/// build up a list of steps to execute. These steps will then be transformed
-/// into a topologically sorted list which when executed left-to-right will
-/// correctly sequence the entire build.
-pub fn all(build: &Build) -> Vec {
- build.verbose("inferred build steps:");
-
- let mut ret = Vec::new();
- let mut all = HashSet::new();
- for target in top_level(build) {
- fill(build, &target, &mut ret, &mut all);
- }
- return ret;
-
- fn fill<'a>(build: &'a Build,
- target: &Step<'a>,
- ret: &mut Vec>,
- set: &mut HashSet>) {
- if set.insert(target.clone()) {
- for dep in target.deps(build) {
- build.verbose(&format!("{:?}\n -> {:?}", target, dep));
- fill(build, &dep, ret, set);
- }
- ret.push(target.clone());
- }
+ fn compiler(&self) -> Compiler<'a> {
+ Compiler::new(self.stage, self.host)
}
}
-/// Determines what top-level targets are requested as part of this build,
-/// returning them as a list.
-fn top_level(build: &Build) -> Vec {
- let mut targets = Vec::new();
- let stage = build.flags.stage.unwrap_or(2);
+pub fn run(build: &Build) {
+ let rules = build_rules(build);
+ let steps = rules.plan();
+ rules.run(&steps);
+}
- let host = Step {
- src: Source::Llvm { _dummy: () },
- target: build.flags.host.iter().next()
- .unwrap_or(&build.config.build),
- };
- let target = Step {
- src: Source::Llvm { _dummy: () },
- target: build.flags.target.iter().next().map(|x| &x[..])
- .unwrap_or(host.target)
+pub fn build_rules(build: &Build) -> Rules {
+ let mut rules: Rules = Rules::new(build);
+ // dummy rule to do nothing, useful when a dep maps to no deps
+ rules.build("dummy", "path/to/nowhere");
+ fn dummy<'a>(s: &Step<'a>, build: &'a Build) -> Step<'a> {
+ s.name("dummy").stage(0)
+ .target(&build.config.build)
+ .host(&build.config.build)
+ }
+
+ // Helper for loading an entire DAG of crates, rooted at `name`
+ let krates = |name: &str| {
+ let mut ret = Vec::new();
+ let mut list = vec![name];
+ let mut visited = HashSet::new();
+ while let Some(krate) = list.pop() {
+ let default = krate == name;
+ let krate = &build.crates[krate];
+ let path = krate.path.strip_prefix(&build.src).unwrap();
+ ret.push((krate, path.to_str().unwrap(), default));
+ for dep in krate.deps.iter() {
+ if visited.insert(dep) && dep != "build_helper" {
+ list.push(dep);
+ }
+ }
+ }
+ return ret
};
- // First, try to find steps on the command line.
- add_steps(build, stage, &host, &target, &mut targets);
+ rules.build("rustc", "path/to/nowhere")
+ .dep(move |s| {
+ if s.stage == 0 {
+ dummy(s, build)
+ } else {
+ s.name("librustc")
+ .host(&build.config.build)
+ .stage(s.stage - 1)
+ }
+ })
+ .run(move |s| compile::assemble_rustc(build, s.stage, s.target));
+ rules.build("llvm", "src/llvm")
+ .host(true)
+ .run(move |s| native::llvm(build, s.target));
+
+ // ========================================================================
+ // Crate compilations
+ //
+ // Tools used during the build system but not shipped
+ rules.build("libstd", "src/libstd")
+ .dep(|s| s.name("build-crate-std_shim"));
+ rules.build("libtest", "src/libtest")
+ .dep(|s| s.name("build-crate-test_shim"));
+ rules.build("librustc", "src/librustc")
+ .dep(|s| s.name("build-crate-rustc-main"));
+ for (krate, path, _default) in krates("std_shim") {
+ rules.build(&krate.build_step, path)
+ .dep(move |s| s.name("rustc").host(&build.config.build).target(s.host))
+ .dep(move |s| {
+ if s.host == build.config.build {
+ dummy(s, build)
+ } else {
+ s.host(&build.config.build)
+ }
+ })
+ .run(move |s| {
+ if s.host == build.config.build {
+ compile::std(build, s.target, &s.compiler())
+ } else {
+ compile::std_link(build, s.target, s.stage, s.host)
+ }
+ });
+ }
+ for (krate, path, default) in krates("test_shim") {
+ rules.build(&krate.build_step, path)
+ .dep(|s| s.name("libstd"))
+ .dep(move |s| {
+ if s.host == build.config.build {
+ dummy(s, build)
+ } else {
+ s.host(&build.config.build)
+ }
+ })
+ .default(default)
+ .run(move |s| {
+ if s.host == build.config.build {
+ compile::test(build, s.target, &s.compiler())
+ } else {
+ compile::test_link(build, s.target, s.stage, s.host)
+ }
+ });
+ }
+ for (krate, path, default) in krates("rustc-main") {
+ rules.build(&krate.build_step, path)
+ .dep(|s| s.name("libtest"))
+ .dep(move |s| s.name("llvm").host(&build.config.build).stage(0))
+ .dep(move |s| {
+ if s.host == build.config.build {
+ dummy(s, build)
+ } else {
+ s.host(&build.config.build)
+ }
+ })
+ .host(true)
+ .default(default)
+ .run(move |s| {
+ if s.host == build.config.build {
+ compile::rustc(build, s.target, &s.compiler())
+ } else {
+ compile::rustc_link(build, s.target, s.stage, s.host)
+ }
+ });
+ }
- // If none are specified, then build everything.
- if targets.len() == 0 {
- let t = Step {
- src: Source::Llvm { _dummy: () },
- target: &build.config.build,
+ // ========================================================================
+ // Test targets
+ //
+ // Various unit tests and tests suites we can run
+ {
+ let mut suite = |name, path, dir, mode| {
+ rules.test(name, path)
+ .dep(|s| s.name("libtest"))
+ .dep(|s| s.name("tool-compiletest").target(s.host))
+ .dep(|s| s.name("test-helpers"))
+ .dep(move |s| {
+ if s.target.contains("android") {
+ s.name("android-copy-libs")
+ } else {
+ dummy(s, build)
+ }
+ })
+ .default(true)
+ .run(move |s| {
+ check::compiletest(build, &s.compiler(), s.target, dir, mode)
+ });
};
- if build.config.docs {
- targets.push(t.doc(stage));
- }
- for host in build.config.host.iter() {
- if !build.flags.host.contains(host) {
- continue
- }
- let host = t.target(host);
- if host.target == build.config.build {
- targets.push(host.librustc(host.compiler(stage)));
- } else {
- targets.push(host.librustc_link(t.compiler(stage), host.target));
- }
- for target in build.config.target.iter() {
- if !build.flags.target.contains(target) {
- continue
- }
- if host.target == build.config.build {
- targets.push(host.target(target)
- .libtest(host.compiler(stage)));
- } else {
- targets.push(host.target(target)
- .libtest_link(t.compiler(stage), host.target));
- }
- }
+ suite("check-rpass", "src/test/run-pass", "run-pass", "run-pass");
+ suite("check-cfail", "src/test/compile-fail", "compile-fail", "compile-fail");
+ suite("check-pfail", "src/test/parse-fail", "parse-fail", "parse-fail");
+ suite("check-rfail", "src/test/run-fail", "run-fail", "run-fail");
+ suite("check-rpass-valgrind", "src/test/run-pass-valgrind",
+ "run-pass-valgrind", "run-pass-valgrind");
+ suite("check-mir-opt", "src/test/mir-opt", "mir-opt", "mir-opt");
+ if build.config.codegen_tests {
+ suite("check-codegen", "src/test/codegen", "codegen", "codegen");
}
+ suite("check-codegen-units", "src/test/codegen-units", "codegen-units",
+ "codegen-units");
+ suite("check-incremental", "src/test/incremental", "incremental",
+ "incremental");
+ suite("check-ui", "src/test/ui", "ui", "ui");
+ suite("check-pretty", "src/test/pretty", "pretty", "pretty");
+ suite("check-pretty-rpass", "src/test/run-pass/pretty", "pretty",
+ "run-pass");
+ suite("check-pretty-rfail", "src/test/run-pass/pretty", "pretty",
+ "run-fail");
+ suite("check-pretty-valgrind", "src/test/run-pass-valgrind", "pretty",
+ "run-pass-valgrind");
+ }
+
+ if build.config.build.contains("msvc") {
+ // nothing to do for debuginfo tests
+ } else if build.config.build.contains("apple") {
+ rules.test("check-debuginfo", "src/test/debuginfo")
+ .dep(|s| s.name("libtest"))
+ .dep(|s| s.name("tool-compiletest").host(s.host))
+ .dep(|s| s.name("test-helpers"))
+ .dep(|s| s.name("debugger-scripts"))
+ .run(move |s| check::compiletest(build, &s.compiler(), s.target,
+ "debuginfo-lldb", "debuginfo"));
+ } else {
+ rules.test("check-debuginfo", "src/test/debuginfo")
+ .dep(|s| s.name("libtest"))
+ .dep(|s| s.name("tool-compiletest").host(s.host))
+ .dep(|s| s.name("test-helpers"))
+ .dep(|s| s.name("debugger-scripts"))
+ .run(move |s| check::compiletest(build, &s.compiler(), s.target,
+ "debuginfo-gdb", "debuginfo"));
}
- return targets
+ rules.test("debugger-scripts", "src/etc/lldb_batchmode.py")
+ .run(move |s| dist::debugger_scripts(build, &build.sysroot(&s.compiler()),
+ s.target));
+
+ {
+ let mut suite = |name, path, dir, mode| {
+ rules.test(name, path)
+ .dep(|s| s.name("librustc"))
+ .dep(|s| s.name("tool-compiletest").target(s.host))
+ .default(true)
+ .host(true)
+ .run(move |s| {
+ check::compiletest(build, &s.compiler(), s.target, dir, mode)
+ });
+ };
+
+ suite("check-rpass-full", "src/test/run-pass-fulldeps",
+ "run-pass", "run-pass-fulldeps");
+ suite("check-cfail-full", "src/test/compile-fail-fulldeps",
+ "compile-fail", "compile-fail-fulldeps");
+ suite("check-rmake", "src/test/run-make", "run-make", "run-make");
+ suite("check-rustdoc", "src/test/rustdoc", "rustdoc", "rustdoc");
+ suite("check-pretty-rpass-full", "src/test/run-pass-fulldeps",
+ "pretty", "run-pass-fulldeps");
+ suite("check-pretty-rfail-full", "src/test/run-fail-fulldeps",
+ "pretty", "run-fail-fulldeps");
+ }
+ for (krate, path, _default) in krates("std_shim") {
+ rules.test(&krate.test_step, path)
+ .dep(|s| s.name("libtest"))
+ .run(move |s| check::krate(build, &s.compiler(), s.target,
+ Mode::Libstd, Some(&krate.name)));
+ }
+ rules.test("check-std-all", "path/to/nowhere")
+ .dep(|s| s.name("libtest"))
+ .default(true)
+ .run(move |s| check::krate(build, &s.compiler(), s.target, Mode::Libstd,
+ None));
+ for (krate, path, _default) in krates("test_shim") {
+ rules.test(&krate.test_step, path)
+ .dep(|s| s.name("libtest"))
+ .run(move |s| check::krate(build, &s.compiler(), s.target,
+ Mode::Libtest, Some(&krate.name)));
+ }
+ rules.test("check-test-all", "path/to/nowhere")
+ .dep(|s| s.name("libtest"))
+ .default(true)
+ .run(move |s| check::krate(build, &s.compiler(), s.target, Mode::Libtest,
+ None));
+ for (krate, path, _default) in krates("rustc-main") {
+ rules.test(&krate.test_step, path)
+ .dep(|s| s.name("librustc"))
+ .host(true)
+ .run(move |s| check::krate(build, &s.compiler(), s.target,
+ Mode::Librustc, Some(&krate.name)));
+ }
+ rules.test("check-rustc-all", "path/to/nowhere")
+ .dep(|s| s.name("librustc"))
+ .default(true)
+ .host(true)
+ .run(move |s| check::krate(build, &s.compiler(), s.target, Mode::Librustc,
+ None));
+
+ rules.test("check-linkchecker", "src/tools/linkchecker")
+ .dep(|s| s.name("tool-linkchecker"))
+ .dep(|s| s.name("default:doc"))
+ .default(true)
+ .host(true)
+ .run(move |s| check::linkcheck(build, s.stage, s.target));
+ rules.test("check-cargotest", "src/tools/cargotest")
+ .dep(|s| s.name("tool-cargotest"))
+ .dep(|s| s.name("librustc"))
+ .host(true)
+ .run(move |s| check::cargotest(build, s.stage, s.target));
+ rules.test("check-tidy", "src/tools/tidy")
+ .dep(|s| s.name("tool-tidy"))
+ .default(true)
+ .host(true)
+ .run(move |s| check::tidy(build, s.stage, s.target));
+ rules.test("check-error-index", "src/tools/error_index_generator")
+ .dep(|s| s.name("libstd"))
+ .dep(|s| s.name("tool-error-index").host(s.host))
+ .default(true)
+ .host(true)
+ .run(move |s| check::error_index(build, &s.compiler()));
+ rules.test("check-docs", "src/doc")
+ .dep(|s| s.name("libtest"))
+ .default(true)
+ .host(true)
+ .run(move |s| check::docs(build, &s.compiler()));
+
+ rules.build("test-helpers", "src/rt/rust_test_helpers.c")
+ .run(move |s| native::test_helpers(build, s.target));
+ rules.test("android-copy-libs", "path/to/nowhere")
+ .dep(|s| s.name("libtest"))
+ .run(move |s| check::android_copy_libs(build, &s.compiler(), s.target));
+
+ // ========================================================================
+ // Build tools
+ //
+ // Tools used during the build system but not shipped
+ rules.build("tool-rustbook", "src/tools/rustbook")
+ .dep(|s| s.name("librustc"))
+ .run(move |s| compile::tool(build, s.stage, s.target, "rustbook"));
+ rules.build("tool-error-index", "src/tools/error_index_generator")
+ .dep(|s| s.name("librustc"))
+ .run(move |s| compile::tool(build, s.stage, s.target, "error_index_generator"));
+ rules.build("tool-tidy", "src/tools/tidy")
+ .dep(|s| s.name("libstd"))
+ .run(move |s| compile::tool(build, s.stage, s.target, "tidy"));
+ rules.build("tool-linkchecker", "src/tools/linkchecker")
+ .dep(|s| s.name("libstd"))
+ .run(move |s| compile::tool(build, s.stage, s.target, "linkchecker"));
+ rules.build("tool-cargotest", "src/tools/cargotest")
+ .dep(|s| s.name("libstd"))
+ .run(move |s| compile::tool(build, s.stage, s.target, "cargotest"));
+ rules.build("tool-compiletest", "src/tools/compiletest")
+ .dep(|s| s.name("libtest"))
+ .run(move |s| compile::tool(build, s.stage, s.target, "compiletest"));
+
+ // ========================================================================
+ // Documentation targets
+ rules.doc("doc-book", "src/doc/book")
+ .dep(move |s| s.name("tool-rustbook").target(&build.config.build))
+ .default(build.config.docs)
+ .run(move |s| doc::rustbook(build, s.stage, s.target, "book"));
+ rules.doc("doc-nomicon", "src/doc/nomicon")
+ .dep(move |s| s.name("tool-rustbook").target(&build.config.build))
+ .default(build.config.docs)
+ .run(move |s| doc::rustbook(build, s.stage, s.target, "nomicon"));
+ rules.doc("doc-standalone", "src/doc")
+ .dep(move |s| s.name("rustc").host(&build.config.build).target(&build.config.build))
+ .default(build.config.docs)
+ .run(move |s| doc::standalone(build, s.stage, s.target));
+ rules.doc("doc-error-index", "src/tools/error_index_generator")
+ .dep(move |s| s.name("tool-error-index").target(&build.config.build))
+ .dep(move |s| s.name("librustc"))
+ .default(build.config.docs)
+ .host(true)
+ .run(move |s| doc::error_index(build, s.stage, s.target));
+ for (krate, path, default) in krates("std_shim") {
+ rules.doc(&krate.doc_step, path)
+ .dep(|s| s.name("libstd"))
+ .default(default && build.config.docs)
+ .run(move |s| doc::std(build, s.stage, s.target));
+ }
+ for (krate, path, default) in krates("test_shim") {
+ rules.doc(&krate.doc_step, path)
+ .dep(|s| s.name("libtest"))
+ .default(default && build.config.docs)
+ .run(move |s| doc::test(build, s.stage, s.target));
+ }
+ for (krate, path, default) in krates("rustc-main") {
+ rules.doc(&krate.doc_step, path)
+ .dep(|s| s.name("librustc"))
+ .host(true)
+ .default(default && build.config.compiler_docs)
+ .run(move |s| doc::rustc(build, s.stage, s.target));
+ }
+
+ // ========================================================================
+ // Distribution targets
+ rules.dist("dist-rustc", "src/librustc")
+ .dep(move |s| s.name("rustc").host(&build.config.build))
+ .host(true)
+ .default(true)
+ .run(move |s| dist::rustc(build, s.stage, s.target));
+ rules.dist("dist-std", "src/libstd")
+ .dep(move |s| {
+ // We want to package up as many target libraries as possible
+ // for the `rust-std` package, so if this is a host target we
+ // depend on librustc and otherwise we just depend on libtest.
+ if build.config.host.iter().any(|t| t == s.target) {
+ s.name("librustc")
+ } else {
+ s.name("libtest")
+ }
+ })
+ .default(true)
+ .run(move |s| dist::std(build, &s.compiler(), s.target));
+ rules.dist("dist-mingw", "path/to/nowhere")
+ .run(move |s| dist::mingw(build, s.target));
+ rules.dist("dist-src", "src")
+ .default(true)
+ .host(true)
+ .run(move |_| dist::rust_src(build));
+ rules.dist("dist-docs", "src/doc")
+ .default(true)
+ .dep(|s| s.name("default:doc"))
+ .run(move |s| dist::docs(build, s.stage, s.target));
+ rules.dist("install", "src")
+ .dep(|s| s.name("default:dist"))
+ .run(move |s| install::install(build, s.stage, s.target));
+
+ rules.verify();
+ return rules
}
-fn add_steps<'a>(build: &'a Build,
- stage: u32,
- host: &Step<'a>,
- target: &Step<'a>,
- targets: &mut Vec>) {
- struct Context<'a> {
- stage: u32,
- compiler: Compiler<'a>,
- _dummy: (),
- host: &'a str,
- }
- for step in build.flags.step.iter() {
-
- // The macro below insists on hygienic access to all local variables, so
- // we shove them all in a struct and subvert hygiene by accessing struct
- // fields instead,
- let cx = Context {
- stage: stage,
- compiler: host.target(&build.config.build).compiler(stage),
- _dummy: (),
- host: host.target,
- };
- macro_rules! add_step {
- ($(($short:ident, $name:ident { $($arg:ident: $t:ty),* }),)*) => ({$(
- let name = stringify!($short).replace("_", "-");
- if &step[..] == &name[..] {
- targets.push(target.$short($(cx.$arg),*));
- continue
- }
- drop(name);
- )*})
+struct Rule<'a> {
+ name: &'a str,
+ path: &'a str,
+ kind: Kind,
+ deps: Vec) -> Step<'a> + 'a>>,
+ run: Box) + 'a>,
+ default: bool,
+ host: bool,
+}
+
+#[derive(PartialEq)]
+enum Kind {
+ Build,
+ Test,
+ Dist,
+ Doc,
+}
+
+impl<'a> Rule<'a> {
+ fn new(name: &'a str, path: &'a str, kind: Kind) -> Rule<'a> {
+ Rule {
+ name: name,
+ deps: Vec::new(),
+ run: Box::new(|_| ()),
+ path: path,
+ kind: kind,
+ default: false,
+ host: false,
}
+ }
+}
+
+struct RuleBuilder<'a: 'b, 'b> {
+ rules: &'b mut Rules<'a>,
+ rule: Rule<'a>,
+}
- targets!(add_step);
+impl<'a, 'b> RuleBuilder<'a, 'b> {
+ fn dep(&mut self, f: F) -> &mut Self
+ where F: Fn(&Step<'a>) -> Step<'a> + 'a,
+ {
+ self.rule.deps.push(Box::new(f));
+ self
+ }
- panic!("unknown step: {}", step);
+ fn run(&mut self, f: F) -> &mut Self
+ where F: Fn(&Step<'a>) + 'a,
+ {
+ self.rule.run = Box::new(f);
+ self
+ }
+
+ fn default(&mut self, default: bool) -> &mut Self {
+ self.rule.default = default;
+ self
+ }
+
+ fn host(&mut self, host: bool) -> &mut Self {
+ self.rule.host = host;
+ self
}
}
-macro_rules! constructors {
- ($(($short:ident, $name:ident { $($arg:ident: $t:ty),* }),)*) => {$(
- fn $short(&self, $($arg: $t),*) -> Step<'a> {
- Step {
- src: Source::$name { $($arg: $arg),* },
- target: self.target,
- }
+impl<'a, 'b> Drop for RuleBuilder<'a, 'b> {
+ fn drop(&mut self) {
+ let rule = mem::replace(&mut self.rule, Rule::new("", "", Kind::Build));
+ let prev = self.rules.rules.insert(rule.name, rule);
+ if let Some(prev) = prev {
+ panic!("duplicate rule named: {}", prev.name);
}
- )*}
+ }
}
-impl<'a> Step<'a> {
- fn compiler(&self, stage: u32) -> Compiler<'a> {
- Compiler::new(stage, self.target)
+pub struct Rules<'a> {
+ build: &'a Build,
+ sbuild: Step<'a>,
+ rules: HashMap<&'a str, Rule<'a>>,
+}
+
+impl<'a> Rules<'a> {
+ fn new(build: &'a Build) -> Rules<'a> {
+ Rules {
+ build: build,
+ sbuild: Step {
+ stage: build.flags.stage.unwrap_or(2),
+ target: &build.config.build,
+ host: &build.config.build,
+ name: "",
+ },
+ rules: HashMap::new(),
+ }
}
- fn target(&self, target: &'a str) -> Step<'a> {
- Step { target: target, src: self.src.clone() }
+ fn build<'b>(&'b mut self, name: &'a str, path: &'a str)
+ -> RuleBuilder<'a, 'b> {
+ self.rule(name, path, Kind::Build)
}
- // Define ergonomic constructors for each step defined above so they can be
- // easily constructed.
- targets!(constructors);
+ fn test<'b>(&'b mut self, name: &'a str, path: &'a str)
+ -> RuleBuilder<'a, 'b> {
+ self.rule(name, path, Kind::Test)
+ }
- /// Mapping of all dependencies for rustbuild.
- ///
- /// This function receives a step, the build that we're building for, and
- /// then returns a list of all the dependencies of that step.
- pub fn deps(&self, build: &'a Build) -> Vec> {
- match self.src {
- Source::Rustc { stage: 0 } => {
- Vec::new()
- }
- Source::Rustc { stage } => {
- let compiler = Compiler::new(stage - 1, &build.config.build);
- vec![self.librustc(compiler)]
- }
- Source::Librustc { compiler } => {
- vec![self.libtest(compiler), self.llvm(())]
- }
- Source::Libtest { compiler } => {
- vec![self.libstd(compiler)]
- }
- Source::Libstd { compiler } => {
- vec![self.rustc(compiler.stage).target(compiler.host)]
- }
- Source::LibrustcLink { compiler, host } => {
- vec![self.librustc(compiler),
- self.libtest_link(compiler, host)]
- }
- Source::LibtestLink { compiler, host } => {
- vec![self.libtest(compiler), self.libstd_link(compiler, host)]
- }
- Source::LibstdLink { compiler, host } => {
- vec![self.libstd(compiler),
- self.target(host).rustc(compiler.stage)]
- }
- Source::Llvm { _dummy } => Vec::new(),
- Source::TestHelpers { _dummy } => Vec::new(),
- Source::DebuggerScripts { stage: _ } => Vec::new(),
-
- // Note that all doc targets depend on artifacts from the build
- // architecture, not the target (which is where we're generating
- // docs into).
- Source::DocStd { stage } => {
- let compiler = self.target(&build.config.build).compiler(stage);
- vec![self.libstd(compiler)]
- }
- Source::DocTest { stage } => {
- let compiler = self.target(&build.config.build).compiler(stage);
- vec![self.libtest(compiler)]
- }
- Source::DocBook { stage } |
- Source::DocNomicon { stage } => {
- vec![self.target(&build.config.build).tool_rustbook(stage)]
- }
- Source::DocErrorIndex { stage } => {
- vec![self.target(&build.config.build).tool_error_index(stage)]
- }
- Source::DocStandalone { stage } => {
- vec![self.target(&build.config.build).rustc(stage)]
- }
- Source::DocRustc { stage } => {
- vec![self.doc_test(stage)]
- }
- Source::Doc { stage } => {
- let mut deps = vec![
- self.doc_book(stage), self.doc_nomicon(stage),
- self.doc_standalone(stage), self.doc_std(stage),
- self.doc_error_index(stage),
- ];
-
- if build.config.compiler_docs {
- deps.push(self.doc_rustc(stage));
- }
+ fn doc<'b>(&'b mut self, name: &'a str, path: &'a str)
+ -> RuleBuilder<'a, 'b> {
+ self.rule(name, path, Kind::Doc)
+ }
- deps
- }
- Source::Check { stage, compiler } => {
- // Check is just a pseudo step which means check all targets,
- // so just depend on checking all targets.
- build.config.target.iter().map(|t| {
- self.target(t).check_target(stage, compiler)
- }).collect()
- }
- Source::CheckTarget { stage, compiler } => {
- // CheckTarget here means run all possible test suites for this
- // target. Most of the time, however, we can't actually run
- // anything if we're not the build triple as we could be cross
- // compiling.
- //
- // As a result, the base set of targets here is quite stripped
- // down from the standard set of targets. These suites have
- // their own internal logic to run in cross-compiled situations
- // if they'll run at all. For example compiletest knows that
- // when testing Android targets we ship artifacts to the
- // emulator.
- //
- // When in doubt the rule of thumb for adding to this list is
- // "should this test suite run on the android bot?"
- let mut base = vec![
- self.check_rpass(compiler),
- self.check_rfail(compiler),
- self.check_crate_std(compiler),
- self.check_crate_test(compiler),
- self.check_debuginfo(compiler),
- self.dist(stage),
- ];
-
- // If we're testing the build triple, then we know we can
- // actually run binaries and such, so we run all possible tests
- // that we know about.
- if self.target == build.config.build {
- base.extend(vec![
- // docs-related
- self.check_docs(compiler),
- self.check_error_index(compiler),
- self.check_rustdoc(compiler),
-
- // UI-related
- self.check_cfail(compiler),
- self.check_pfail(compiler),
- self.check_ui(compiler),
-
- // codegen-related
- self.check_incremental(compiler),
- self.check_codegen(compiler),
- self.check_codegen_units(compiler),
-
- // misc compiletest-test suites
- self.check_rpass_full(compiler),
- self.check_rfail_full(compiler),
- self.check_cfail_full(compiler),
- self.check_pretty_rpass_full(compiler),
- self.check_pretty_rfail_full(compiler),
- self.check_rpass_valgrind(compiler),
- self.check_rmake(compiler),
- self.check_mir_opt(compiler),
-
- // crates
- self.check_crate_rustc(compiler),
-
- // pretty
- self.check_pretty(compiler),
- self.check_pretty_rpass(compiler),
- self.check_pretty_rfail(compiler),
- self.check_pretty_rpass_valgrind(compiler),
-
- // misc
- self.check_linkcheck(stage),
- self.check_tidy(stage),
- ]);
- }
- return base
- }
- Source::CheckLinkcheck { stage } => {
- vec![self.tool_linkchecker(stage), self.doc(stage)]
- }
- Source::CheckCargoTest { stage } => {
- vec![self.tool_cargotest(stage),
- self.librustc(self.compiler(stage))]
- }
- Source::CheckTidy { stage } => {
- vec![self.tool_tidy(stage)]
- }
- Source::CheckMirOpt { compiler} |
- Source::CheckPrettyRPass { compiler } |
- Source::CheckPrettyRFail { compiler } |
- Source::CheckRFail { compiler } |
- Source::CheckPFail { compiler } |
- Source::CheckCodegen { compiler } |
- Source::CheckCodegenUnits { compiler } |
- Source::CheckIncremental { compiler } |
- Source::CheckUi { compiler } |
- Source::CheckRustdoc { compiler } |
- Source::CheckPretty { compiler } |
- Source::CheckCFail { compiler } |
- Source::CheckRPassValgrind { compiler } |
- Source::CheckRPass { compiler } => {
- let mut base = vec![
- self.libtest(compiler),
- self.target(compiler.host).tool_compiletest(compiler.stage),
- self.test_helpers(()),
- ];
- if self.target.contains("android") {
- base.push(self.android_copy_libs(compiler));
+ fn dist<'b>(&'b mut self, name: &'a str, path: &'a str)
+ -> RuleBuilder<'a, 'b> {
+ self.rule(name, path, Kind::Dist)
+ }
+
+ fn rule<'b>(&'b mut self,
+ name: &'a str,
+ path: &'a str,
+ kind: Kind) -> RuleBuilder<'a, 'b> {
+ RuleBuilder {
+ rules: self,
+ rule: Rule::new(name, path, kind),
+ }
+ }
+
+ /// Verify the dependency graph defined by all our rules are correct, e.g.
+ /// everything points to a valid something else.
+ fn verify(&self) {
+ for rule in self.rules.values() {
+ for dep in rule.deps.iter() {
+ let dep = dep(&self.sbuild.name(rule.name));
+ if self.rules.contains_key(&dep.name) || dep.name.starts_with("default:") {
+ continue
}
- base
- }
- Source::CheckDebuginfo { compiler } => {
- vec![
- self.libtest(compiler),
- self.target(compiler.host).tool_compiletest(compiler.stage),
- self.test_helpers(()),
- self.debugger_scripts(compiler.stage),
- ]
- }
- Source::CheckRPassFull { compiler } |
- Source::CheckRFailFull { compiler } |
- Source::CheckCFailFull { compiler } |
- Source::CheckPrettyRPassFull { compiler } |
- Source::CheckPrettyRFailFull { compiler } |
- Source::CheckPrettyRPassValgrind { compiler } |
- Source::CheckRMake { compiler } => {
- vec![self.librustc(compiler),
- self.target(compiler.host).tool_compiletest(compiler.stage)]
- }
- Source::CheckDocs { compiler } => {
- vec![self.libstd(compiler)]
- }
- Source::CheckErrorIndex { compiler } => {
- vec![self.libstd(compiler),
- self.target(compiler.host).tool_error_index(compiler.stage)]
- }
- Source::CheckCrateStd { compiler } => {
- vec![self.libtest(compiler)]
- }
- Source::CheckCrateTest { compiler } => {
- vec![self.libtest(compiler)]
- }
- Source::CheckCrateRustc { compiler } => {
- vec![self.libtest(compiler)]
- }
+ panic!("\
- Source::ToolLinkchecker { stage } |
- Source::ToolTidy { stage } => {
- vec![self.libstd(self.compiler(stage))]
- }
- Source::ToolErrorIndex { stage } |
- Source::ToolRustbook { stage } => {
- vec![self.librustc(self.compiler(stage))]
- }
- Source::ToolCargoTest { stage } => {
- vec![self.libstd(self.compiler(stage))]
- }
- Source::ToolCompiletest { stage } => {
- vec![self.libtest(self.compiler(stage))]
- }
+invalid rule dependency graph detected, was a rule added and maybe typo'd?
+
+ `{}` depends on `{}` which does not exist
- Source::DistDocs { stage } => vec![self.doc(stage)],
- Source::DistMingw { _dummy: _ } => Vec::new(),
- Source::DistRustc { stage } => {
- vec![self.rustc(stage)]
+", rule.name, dep.name);
}
- Source::DistStd { compiler } => {
- // We want to package up as many target libraries as possible
- // for the `rust-std` package, so if this is a host target we
- // depend on librustc and otherwise we just depend on libtest.
- if build.config.host.iter().any(|t| t == self.target) {
- vec![self.librustc(compiler)]
+ }
+ }
+
+ pub fn print_help(&self, command: &str) {
+ let kind = match command {
+ "build" => Kind::Build,
+ "doc" => Kind::Doc,
+ "test" => Kind::Test,
+ "dist" => Kind::Dist,
+ _ => return,
+ };
+ let rules = self.rules.values().filter(|r| r.kind == kind);
+ let rules = rules.filter(|r| !r.path.contains("nowhere"));
+ let mut rules = rules.collect::>();
+ rules.sort_by_key(|r| r.path);
+
+ println!("Available paths:\n");
+ for rule in rules {
+ print!(" ./x.py {} {}", command, rule.path);
+
+ println!("");
+ }
+ }
+
+ /// Construct the top-level build steps that we're going to be executing,
+ /// given the subcommand that our build is performing.
+ fn plan(&self) -> Vec> {
+ let (kind, paths) = match self.build.flags.cmd {
+ Subcommand::Build { ref paths } => (Kind::Build, &paths[..]),
+ Subcommand::Doc { ref paths } => (Kind::Doc, &paths[..]),
+ Subcommand::Test { ref paths, test_args: _ } => (Kind::Test, &paths[..]),
+ Subcommand::Dist { install } => {
+ if install {
+ return vec![self.sbuild.name("install")]
} else {
- vec![self.libtest(compiler)]
- }
- }
- Source::DistSrc { _dummy: _ } => Vec::new(),
-
- Source::Dist { stage } => {
- let mut base = Vec::new();
-
- for host in build.config.host.iter() {
- let host = self.target(host);
- base.push(host.dist_src(()));
- base.push(host.dist_rustc(stage));
- if host.target.contains("windows-gnu") {
- base.push(host.dist_mingw(()));
- }
-
- let compiler = self.compiler(stage);
- for target in build.config.target.iter() {
- let target = self.target(target);
- if build.config.docs {
- base.push(target.dist_docs(stage));
- }
- base.push(target.dist_std(compiler));
- }
+ (Kind::Dist, &[][..])
}
- return base
}
+ Subcommand::Clean => panic!(),
+ };
- Source::AndroidCopyLibs { compiler } => {
- vec![self.libtest(compiler)]
+ self.rules.values().filter(|rule| rule.kind == kind).filter(|rule| {
+ (paths.len() == 0 && rule.default) || paths.iter().any(|path| {
+ path.ends_with(rule.path)
+ })
+ }).flat_map(|rule| {
+ let hosts = if self.build.flags.host.len() > 0 {
+ &self.build.flags.host
+ } else {
+ &self.build.config.host
+ };
+ let targets = if self.build.flags.target.len() > 0 {
+ &self.build.flags.target
+ } else {
+ &self.build.config.target
+ };
+ let arr = if rule.host {hosts} else {targets};
+
+ hosts.iter().flat_map(move |host| {
+ arr.iter().map(move |target| {
+ self.sbuild.name(rule.name).target(target).host(host)
+ })
+ })
+ }).collect()
+ }
+
+ /// Execute all top-level targets indicated by `steps`.
+ ///
+ /// This will take the list returned by `plan` and then execute each step
+ /// along with all required dependencies as it goes up the chain.
+ fn run(&self, steps: &[Step<'a>]) {
+ self.build.verbose("bootstrap top targets:");
+ for step in steps.iter() {
+ self.build.verbose(&format!("\t{:?}", step));
+ }
+
+ // Using `steps` as the top-level targets, make a topological ordering
+ // of what we need to do.
+ let mut order = Vec::new();
+ let mut added = HashSet::new();
+ for step in steps.iter().cloned() {
+ self.fill(step, &mut order, &mut added);
+ }
+
+ // Print out what we're doing for debugging
+ self.build.verbose("bootstrap build plan:");
+ for step in order.iter() {
+ self.build.verbose(&format!("\t{:?}", step));
+ }
+
+ // And finally, iterate over everything and execute it.
+ for step in order.iter() {
+ self.build.verbose(&format!("executing step {:?}", step));
+ (self.rules[step.name].run)(step);
+ }
+ }
+
+ fn fill(&self,
+ step: Step<'a>,
+ order: &mut Vec>,
+ added: &mut HashSet>) {
+ if !added.insert(step.clone()) {
+ return
+ }
+ for dep in self.rules[step.name].deps.iter() {
+ let dep = dep(&step);
+ if dep.name.starts_with("default:") {
+ let kind = match &dep.name[8..] {
+ "doc" => Kind::Doc,
+ "dist" => Kind::Dist,
+ kind => panic!("unknown kind: `{}`", kind),
+ };
+ let host = self.build.config.host.iter().any(|h| h == dep.target);
+ let rules = self.rules.values().filter(|r| r.default);
+ for rule in rules.filter(|r| r.kind == kind && (!r.host || host)) {
+ self.fill(dep.name(rule.name), order, added);
+ }
+ } else {
+ self.fill(dep, order, added);
}
}
+ order.push(step);
}
}
diff --git a/src/bootstrap/util.rs b/src/bootstrap/util.rs
index 6c0a32a54d..e028c52236 100644
--- a/src/bootstrap/util.rs
+++ b/src/bootstrap/util.rs
@@ -57,8 +57,7 @@ pub fn cp_r(src: &Path, dst: &Path) {
let name = path.file_name().unwrap();
let dst = dst.join(name);
if t!(f.file_type()).is_dir() {
- let _ = fs::remove_dir_all(&dst);
- t!(fs::create_dir(&dst));
+ t!(fs::create_dir_all(&dst));
cp_r(&path, &dst);
} else {
let _ = fs::remove_file(&dst);
@@ -172,3 +171,21 @@ pub fn dylib_path() -> Vec {
env::split_paths(&env::var_os(dylib_path_var()).unwrap_or(OsString::new()))
.collect()
}
+
+/// `push` all components to `buf`. On windows, append `.exe` to the last component.
+pub fn push_exe_path(mut buf: PathBuf, components: &[&str]) -> PathBuf {
+ let (&file, components) = components.split_last().expect("at least one component required");
+ let mut file = file.to_owned();
+
+ if cfg!(windows) {
+ file.push_str(".exe");
+ }
+
+ for c in components {
+ buf.push(c);
+ }
+
+ buf.push(file);
+
+ buf
+}
diff --git a/src/build_helper/lib.rs b/src/build_helper/lib.rs
index 838cc4f07a..38844fb6c9 100644
--- a/src/build_helper/lib.rs
+++ b/src/build_helper/lib.rs
@@ -25,7 +25,9 @@ pub fn run_silent(cmd: &mut Command) {
};
if !status.success() {
fail(&format!("command did not execute successfully: {:?}\n\
- expected success, got: {}", cmd, status));
+ expected success, got: {}",
+ cmd,
+ status));
}
}
@@ -65,7 +67,9 @@ pub fn output(cmd: &mut Command) -> String {
};
if !output.status.success() {
panic!("command did not execute successfully: {:?}\n\
- expected success, got: {}", cmd, output.status);
+ expected success, got: {}",
+ cmd,
+ output.status);
}
String::from_utf8(output.stdout).unwrap()
}
diff --git a/src/compiler-rt/lib/builtins/int_lib.h b/src/compiler-rt/lib/builtins/int_lib.h
index 6cf17497d3..8dfe5672d1 100644
--- a/src/compiler-rt/lib/builtins/int_lib.h
+++ b/src/compiler-rt/lib/builtins/int_lib.h
@@ -32,7 +32,7 @@
#if __ARM_EABI__
# define ARM_EABI_FNALIAS(aeabi_name, name) \
void __aeabi_##aeabi_name() __attribute__((alias("__" #name)));
-# define COMPILER_RT_ABI
+# define COMPILER_RT_ABI __attribute__((pcs("aapcs")))
#else
# define ARM_EABI_FNALIAS(aeabi_name, name)
# define COMPILER_RT_ABI
diff --git a/src/compiler-rt/lib/builtins/powidf2.c b/src/compiler-rt/lib/builtins/powidf2.c
index ac13b172b0..0200e1eab0 100644
--- a/src/compiler-rt/lib/builtins/powidf2.c
+++ b/src/compiler-rt/lib/builtins/powidf2.c
@@ -16,7 +16,7 @@
/* Returns: a ^ b */
-COMPILER_RT_ABI double
+double
__powidf2(double a, si_int b)
{
const int recip = b < 0;
diff --git a/src/compiler-rt/lib/builtins/powisf2.c b/src/compiler-rt/lib/builtins/powisf2.c
index 0c400ec6dd..c834b96969 100644
--- a/src/compiler-rt/lib/builtins/powisf2.c
+++ b/src/compiler-rt/lib/builtins/powisf2.c
@@ -16,7 +16,7 @@
/* Returns: a ^ b */
-COMPILER_RT_ABI float
+float
__powisf2(float a, si_int b)
{
const int recip = b < 0;
diff --git a/src/doc/book/closures.md b/src/doc/book/closures.md
index 3ed85c1a90..fa9f66d43b 100644
--- a/src/doc/book/closures.md
+++ b/src/doc/book/closures.md
@@ -327,7 +327,7 @@ that takes a reference like so:
fn call_with_ref(some_closure:F) -> i32
where F: Fn(&i32) -> i32 {
- let mut value = 0;
+ let value = 0;
some_closure(&value)
}
```
@@ -340,14 +340,15 @@ fn call_with_ref<'a, F>(some_closure:F) -> i32
where F: Fn(&'a i32) -> i32 {
```
-However this presents a problem in our case. When you specify the explicit
-lifetime on a function it binds that lifetime to the *entire* scope of the function
-instead of just the invocation scope of our closure. This means that the borrow checker
-will see a mutable reference in the same lifetime as our immutable reference and fail
-to compile.
+However, this presents a problem in our case. When a function has an explicit
+lifetime parameter, that lifetime must be at least as long as the *entire*
+call to that function. The borrow checker will complain that `value` doesn't
+live long enough, because it is only in scope after its declaration inside the
+function body.
-In order to say that we only need the lifetime to be valid for the invocation scope
-of the closure we can use Higher-Ranked Trait Bounds with the `for<...>` syntax:
+What we need is a closure that can borrow its argument only for its own
+invocation scope, not for the outer function's scope. In order to say that,
+we can use Higher-Ranked Trait Bounds with the `for<...>` syntax:
```ignore
fn call_with_ref(some_closure:F) -> i32
@@ -362,7 +363,7 @@ expect.
fn call_with_ref(some_closure:F) -> i32
where F: for<'a> Fn(&'a i32) -> i32 {
- let mut value = 0;
+ let value = 0;
some_closure(&value)
}
```
@@ -510,12 +511,11 @@ fn factory() -> Box i32> {
Box::new(|x| x + num)
}
-# fn main() {
+
let f = factory();
let answer = f(1);
assert_eq!(6, answer);
-# }
```
Thereâs just one last problem:
@@ -540,12 +540,11 @@ fn factory() -> Box i32> {
Box::new(move |x| x + num)
}
-fn main() {
+
let f = factory();
let answer = f(1);
assert_eq!(6, answer);
-}
```
By making the inner closure a `move Fn`, we create a new stack frame for our
diff --git a/src/doc/book/concurrency.md b/src/doc/book/concurrency.md
index a783650f8e..41d8345b72 100644
--- a/src/doc/book/concurrency.md
+++ b/src/doc/book/concurrency.md
@@ -4,7 +4,7 @@ Concurrency and parallelism are incredibly important topics in computer
science, and are also a hot topic in industry today. Computers are gaining more
and more cores, yet many programmers aren't prepared to fully utilize them.
-Rust's memory safety features also apply to its concurrency story too. Even
+Rust's memory safety features also apply to its concurrency story. Even
concurrent Rust programs must be memory safe, having no data races. Rust's type
system is up to the task, and gives you powerful ways to reason about
concurrent code at compile time.
@@ -281,8 +281,8 @@ And... still gives us an error.
```
`Arc` by default has immutable contents. It allows the _sharing_ of data
-between threads, but shared mutable data is unsafe and when threads are
-involved can cause data races!
+between threads, but shared mutable data is unsafeâand when threads are
+involvedâcan cause data races!
Usually when we wish to make something in an immutable position mutable, we use
diff --git a/src/doc/book/const-and-static.md b/src/doc/book/const-and-static.md
index 11aa25ac81..e8f17a41cb 100644
--- a/src/doc/book/const-and-static.md
+++ b/src/doc/book/const-and-static.md
@@ -1,4 +1,4 @@
-% `const` and `static`
+% const and static
Rust has a way of defining constants with the `const` keyword:
diff --git a/src/doc/book/deref-coercions.md b/src/doc/book/deref-coercions.md
index beb65c4ce3..cabe66f5b2 100644
--- a/src/doc/book/deref-coercions.md
+++ b/src/doc/book/deref-coercions.md
@@ -69,7 +69,7 @@ foo(&counted);
All weâve done is wrap our `String` in an `Rc`. But we can now pass the
`Rc` around anywhere weâd have a `String`. The signature of `foo`
didnât change, but works just as well with either type. This example has two
-conversions: `Rc` to `String` and then `String` to `&str`. Rust will do
+conversions: `&Rc` to `&String` and then `&String` to `&str`. Rust will do
this as many times as possible until the types match.
Another very common implementation provided by the standard library is:
diff --git a/src/doc/book/getting-started.md b/src/doc/book/getting-started.md
index bff448aadd..203dbf16ca 100644
--- a/src/doc/book/getting-started.md
+++ b/src/doc/book/getting-started.md
@@ -111,41 +111,40 @@ unofficial locations.
Note that this table can be expanded over time, this isn't the exhaustive set of
tier 3 platforms that will ever be!
-## Installing on Linux or Mac
+## Installing Rust
-If we're on Linux or a Mac, all we need to do is open a terminal and type this:
+All you need to do on Unix systems like Linux and macOS is open a
+terminal and type this:
```bash
-$ curl -sSf https://static.rust-lang.org/rustup.sh | sh
+$ curl https://sh.rustup.rs -sSf | sh
```
-This will download a script, and start the installation. If it all goes well,
-youâll see this appear:
+It will download a script, and start the installation. If everything
+goes well, youâll see this appear:
```text
-Rust is ready to roll.
+Rust is installed now. Great!
```
-From here, press `y` for âyesâ, and then follow the rest of the prompts.
+Installing on Windows is nearly as easy: download and run
+[rustup-init.exe]. It will start the installation in a console and
+present the above message on success.
-## Installing on Windows
+For other installation options and information, visit the [install]
+page of the Rust website.
-If you're on Windows, please download the appropriate [installer][install-page].
-
-[install-page]: https://www.rust-lang.org/install.html
+[rustup-init.exe]: https://win.rustup.rs
+[install]: https://www.rust-lang.org/install.html
## Uninstalling
-Uninstalling Rust is as easy as installing it. On Linux or Mac, run
-the uninstall script:
+Uninstalling Rust is as easy as installing it:
```bash
-$ sudo /usr/local/lib/rustlib/uninstall.sh
+$ rustup self uninstall
```
-If we used the Windows installer, we can re-run the `.msi` and it will give us
-an uninstall option.
-
## Troubleshooting
If we've got Rust installed, we can open up a shell, and type this:
@@ -158,20 +157,33 @@ You should see the version number, commit hash, and commit date.
If you do, Rust has been installed successfully! Congrats!
-If you don't and you're on Windows, check that Rust is in your %PATH% system
-variable: `$ echo %PATH%`. If it isn't, run the installer again, select "Change"
-on the "Change, repair, or remove installation" page and ensure "Add to PATH" is
-installed on the local hard drive. If you need to configure your path manually,
-you can find the Rust executables in a directory like
-`"C:\Program Files\Rust stable GNU 1.x\bin"`.
+If you don't, that probably means that the `PATH` environment variable
+doesn't include Cargo's binary directory, `~/.cargo/bin` on Unix, or
+`%USERPROFILE%\.cargo\bin` on Windows. This is the directory where
+Rust development tools live, and most Rust developers keep it in their
+`PATH` environment variable, which makes it possible to run `rustc` on
+the command line. Due to differences in operating systems, command
+shells, and bugs in installation, you may need to restart your shell,
+log out of the system, or configure `PATH` manually as appropriate for
+your operating environment.
Rust does not do its own linking, and so youâll need to have a linker
-installed. Doing so will depend on your specific system, consult its
-documentation for more details.
-
-If not, there are a number of places where we can get help. The easiest is
-[the #rust-beginners IRC channel on irc.mozilla.org][irc-beginners] and for
-general discussion [the #rust IRC channel on irc.mozilla.org][irc], which we
+installed. Doing so will depend on your specific system. For
+Linux-based systems, Rust will attempt to call `cc` for linking. On
+`windows-msvc` (Rust built on Windows with Microsoft Visual Studio),
+this depends on having [Microsoft Visual C++ Build Tools][msvbt]
+installed. These do not need to be in `%PATH%` as `rustc` will find
+them automatically. In general, if you have your linker in a
+non-traditional location you can call `rustc
+linker=/path/to/cc`, where `/path/to/cc` should point to your linker path.
+
+[msvbt]: http://landinghub.visualstudio.com/visual-cpp-build-tools
+
+If you are still stuck, there are a number of places where we can get
+help. The easiest is
+[the #rust-beginners IRC channel on irc.mozilla.org][irc-beginners]
+and for general discussion
+[the #rust IRC channel on irc.mozilla.org][irc], which we
can access through [Mibbit][mibbit]. Then we'll be chatting with other
Rustaceans (a silly nickname we call ourselves) who can help us out. Other great
resources include [the userâs forum][users] and [Stack Overflow][stackoverflow].
@@ -183,9 +195,7 @@ resources include [the userâs forum][users] and [Stack Overflow][stackoverflow
[stackoverflow]: http://stackoverflow.com/questions/tagged/rust
This installer also installs a copy of the documentation locally, so we can
-read it offline. On UNIX systems, `/usr/local/share/doc/rust` is the location.
-On Windows, it's in a `share/doc` directory, inside the directory to which Rust
-was installed.
+read it offline. It's only a `rustup doc` away!
# Hello, world!
@@ -495,6 +505,9 @@ $ cargo run
Hello, world!
```
+The `run` command comes in handy when you need to rapidly iterate on a
+project.
+
Notice that this example didnât re-build the project. Cargo figured out that
the file hasnât changed, and so it just ran the binary. If you'd modified your
source code, Cargo would have rebuilt the project before running it, and you
diff --git a/src/doc/book/guessing-game.md b/src/doc/book/guessing-game.md
index 22cf6068e4..a3ab4803bc 100644
--- a/src/doc/book/guessing-game.md
+++ b/src/doc/book/guessing-game.md
@@ -56,9 +56,7 @@ $ cargo build
Excellent! Open up your `src/main.rs` again. Weâll be writing all of
our code in this file.
-Before we move on, let me show you one more Cargo command: `run`. `cargo run`
-is kind of like `cargo build`, but it also then runs the produced executable.
-Try it out:
+Remember the `run` command from last chapter? Try it out again here:
```bash
$ cargo run
@@ -67,9 +65,8 @@ $ cargo run
Hello, world!
```
-Great! The `run` command comes in handy when you need to rapidly iterate on a
-project. Our game is such a project, we need to quickly test each
-iteration before moving on to the next one.
+Great! Our game is just the kind of project `run` is good for: we need
+to quickly test each iteration before moving on to the next one.
# Processing a Guess
@@ -279,7 +276,7 @@ displaying the message.
[expect]: ../std/result/enum.Result.html#method.expect
[panic]: error-handling.html
-If we leave off calling this method, our program will compile, but
+If we do not call `expect()`, our program will compile, but
weâll get a warning:
```bash
@@ -365,7 +362,6 @@ numbers. A bare number like above is actually shorthand for `^0.3.0`,
meaning "anything compatible with 0.3.0".
If we wanted to use only `0.3.0` exactly, we could say `rand="=0.3.0"`
(note the two equal signs).
-And if we wanted to use the latest version we could use `rand="*"`.
We could also use a range of versions.
[Cargoâs documentation][cargodoc] contains more details.
diff --git a/src/doc/book/lifetimes.md b/src/doc/book/lifetimes.md
index f7d9c94bc4..df1ee5a293 100644
--- a/src/doc/book/lifetimes.md
+++ b/src/doc/book/lifetimes.md
@@ -50,29 +50,94 @@ complicated. For example, imagine this set of operations:
4. You decide to use the resource.
Uh oh! Your reference is pointing to an invalid resource. This is called a
-dangling pointer or âuse after freeâ, when the resource is memory.
+dangling pointer or âuse after freeâ, when the resource is memory. A small
+example of such a situation would be:
+
+```rust,compile_fail
+let r; // Introduce reference: r
+{
+ let i = 1; // Introduce scoped value: i
+ r = &i; // Store reference of i in r
+} // i goes out of scope and is dropped.
+
+println!("{}", r); // r still refers to i
+```
To fix this, we have to make sure that step four never happens after step
-three. The ownership system in Rust does this through a concept called
-lifetimes, which describe the scope that a reference is valid for.
+three. In the small example above the Rust compiler is able to report the issue
+as it can see the lifetimes of the various values in the function.
-When we have a function that takes an argument by reference, we can be
-implicit or explicit about the lifetime of the reference:
+When we have a function that takes arguments by reference the situation becomes
+more complex. Consider the following example:
-```rust
-// implicit
-fn foo(x: &i32) {
+```rust,compile_fail,E0106
+fn skip_prefix(line: &str, prefix: &str) -> &str {
+ // ...
+# line
}
-// explicit
-fn bar<'a>(x: &'a i32) {
+let line = "lang:en=Hello World!";
+let lang = "en";
+
+let v;
+{
+ let p = format!("lang:{}=", lang); // -+ p goes into scope
+ v = skip_prefix(line, p.as_str()); // |
+} // -+ p goes out of scope
+println!("{}", v);
+```
+
+Here we have a function `skip_prefix` which takes two `&str` references
+as parameters and returns a single `&str` reference. We call it
+by passing in references to `line` and `p`: Two variables with different
+lifetimes. Now the safety of the `println!`-line depends on whether the
+reference returned by `skip_prefix` function references the still living
+`line` or the already dropped `p` string.
+
+Because of the above ambiguity, Rust will refuse to compile the example
+code. To get it to compile we need to tell the compiler more about the
+lifetimes of the references. This can be done by making the lifetimes
+explicit in the function declaration:
+
+```rust
+fn skip_prefix<'a, 'b>(line: &'a str, prefix: &'b str) -> &'a str {
+ // ...
+# line
}
```
+Let's examine the changes without going too deep into the syntax for now -
+we'll get to that later. The first change was adding the `<'a, 'b>` after the
+method name. This introduces two lifetime parameters: `'a` and `'b`. Next each
+reference in the function signature was associated with one of the lifetime
+parameters by adding the lifetime name after the `&`. This tells the compiler
+how the lifetimes between different references are related.
+
+As a result the compiler is now able to deduce that the return value of
+`skip_prefix` has the same lifetime as the `line` parameter, which makes the `v`
+reference safe to use even after the `p` goes out of scope in the original
+example.
+
+In addition to the compiler being able to validate the usage of `skip_prefix`
+return value, it can also ensure that the implementation follows the contract
+established by the function declaration. This is useful especially when you are
+implementing traits that are introduced [later in the book][traits].
+
+**Note** It's important to understand that lifetime annotations are
+_descriptive_, not _prescriptive_. This means that how long a reference is valid
+is determined by the code, not by the annotations. The annotations, however,
+give information about lifetimes to the compiler that uses them to check the
+validity of references. The compiler can do so without annotations in simple
+cases, but needs the programmers support in complex scenarios.
+
+[traits]: traits.html
+
+# Syntax
+
The `'a` reads âthe lifetime aâ. Technically, every reference has some lifetime
associated with it, but the compiler lets you elide (i.e. omit, see
-["Lifetime Elision"][lifetime-elision] below) them in common cases.
-Before we get to that, though, letâs break the explicit example down:
+["Lifetime Elision"][lifetime-elision] below) them in common cases. Before we
+get to that, though, letâs look at a short example with explicit lifetimes:
[lifetime-elision]: #lifetime-elision
@@ -90,7 +155,8 @@ focus on the lifetimes aspect.
[generics]: generics.html
We use `<>` to declare our lifetimes. This says that `bar` has one lifetime,
-`'a`. If we had two reference parameters, it would look like this:
+`'a`. If we had two reference parameters with different lifetimes, it would
+look like this:
```rust,ignore
diff --git a/src/doc/book/references-and-borrowing.md b/src/doc/book/references-and-borrowing.md
index 2ec3a00c0d..1e2f061b06 100644
--- a/src/doc/book/references-and-borrowing.md
+++ b/src/doc/book/references-and-borrowing.md
@@ -86,7 +86,7 @@ fn main() {
return v.iter().fold(0, |a, &b| a + b);
}
// Borrow two vectors and sum them.
- // This kind of borrowing does not allow mutation to the borrowed.
+ // This kind of borrowing does not allow mutation through the borrowed reference.
fn foo(v1: &Vec, v2: &Vec) -> i32 {
// do stuff with v1 and v2
let s1 = sum_vec(v1);
@@ -240,7 +240,7 @@ fn main() {
In other words, the mutable borrow is held through the rest of our example. What
we want is for the mutable borrow by `y` to end so that the resource can be
-returned to the owner, `x`. `x` can then provide a immutable borrow to `println!`.
+returned to the owner, `x`. `x` can then provide an immutable borrow to `println!`.
In Rust, borrowing is tied to the scope that the borrow is valid for. And our
scopes look like this:
diff --git a/src/doc/book/syntax-index.md b/src/doc/book/syntax-index.md
index 0259db221b..28403711cd 100644
--- a/src/doc/book/syntax-index.md
+++ b/src/doc/book/syntax-index.md
@@ -61,7 +61,6 @@
* `-` (`- expr`): arithmetic negation. Overloadable (`Neg`).
* `-=` (`var -= expr`): arithmetic subtraction & assignment. Overloadable (`SubAssign`).
* `->` (`fn(â¦) -> type`, `|â¦| -> type`): function and closure return type. See [Functions], [Closures].
-* `-> !` (`fn(â¦) -> !`, `|â¦| -> !`): diverging function or closure. See [Diverging Functions].
* `.` (`expr.ident`): member access. See [Structs], [Method Syntax].
* `..` (`..`, `expr..`, `..expr`, `expr..expr`): right-exclusive range literal.
* `..` (`..expr`): struct literal update syntax. See [Structs (Update syntax)].
@@ -95,6 +94,7 @@
* `|=` (`var |= expr`): bitwise or & assignment. Overloadable (`BitOrAssign`).
* `||` (`expr || expr`): logical or.
* `_`: "ignored" pattern binding (see [Patterns (Ignoring bindings)]). Also used to make integer-literals readable (see [Reference (Integer literals)]).
+* `?` (`expr?`): Error propagation. Returns early when `Err(_)` is encountered, unwraps otherwise. Similar to the [`try!` macro].
## Other Syntax
@@ -159,6 +159,10 @@
* `/*!â¦*/`: inner block doc comment. See [Comments].
* `/**â¦*/`: outer block doc comment. See [Comments].
+
+
+* `!`: always empty Never type. See [Diverging Functions].
+
* `()`: empty tuple (*a.k.a.* unit), both literal and type.
@@ -207,6 +211,7 @@
[Functions]: functions.html
[Generics]: generics.html
[Iterators]: iterators.html
+[`try!` macro]: error-handling.html#the-try-macro
[Lifetimes]: lifetimes.html
[Loops (`for`)]: loops.html#for
[Loops (`loop`)]: loops.html#loop
diff --git a/src/doc/book/testing.md b/src/doc/book/testing.md
index 86729147ed..0e6cdb8f09 100644
--- a/src/doc/book/testing.md
+++ b/src/doc/book/testing.md
@@ -24,9 +24,11 @@ Cargo will automatically generate a simple test when you make a new project.
Here's the contents of `src/lib.rs`:
```rust
-# fn main() {}
-#[test]
-fn it_works() {
+#[cfg(test)]
+mod tests {
+ #[test]
+ fn it_works() {
+ }
}
```
@@ -36,11 +38,11 @@ currently has no body. That's good enough to pass! We can run the tests with
```bash
$ cargo test
- Compiling adder v0.0.1 (file:///home/you/projects/adder)
- Running target/adder-91b3e234d4ed382a
+ Compiling adder v0.1.0 (file:///home/you/projects/adder)
+ Running target/debug/deps/adder-91b3e234d4ed382a
running 1 test
-test it_works ... ok
+test tests::it_works ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
@@ -56,7 +58,7 @@ for the test we wrote, and another for documentation tests. We'll talk about
those later. For now, see this line:
```text
-test it_works ... ok
+test tests::it_works ... ok
```
Note the `it_works`. This comes from the name of our function:
@@ -89,31 +91,30 @@ run our tests again:
```bash
$ cargo test
- Compiling adder v0.0.1 (file:///home/you/projects/adder)
- Running target/adder-91b3e234d4ed382a
+ Compiling adder v0.1.0 (file:///home/you/projects/adder)
+ Running target/debug/deps/adder-91b3e234d4ed382a
running 1 test
-test it_works ... FAILED
+test tests::it_works ... FAILED
failures:
----- it_works stdout ----
- thread 'it_works' panicked at 'assertion failed: false', /home/steve/tmp/adder/src/lib.rs:3
-
+---- test::it_works stdout ----
+ thread 'tests::it_works' panicked at 'assertion failed: false', src/lib.rs:5
failures:
- it_works
+ tests::it_works
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured
-thread 'main' panicked at 'Some tests failed', /home/steve/src/rust/src/libtest/lib.rs:247
+error: test failed
```
Rust indicates that our test failed:
```text
-test it_works ... FAILED
+test tests::it_works ... FAILED
```
And that's reflected in the summary line:
@@ -159,11 +160,11 @@ This test will now succeed if we `panic!` and fail if we complete. Let's try it:
```bash
$ cargo test
- Compiling adder v0.0.1 (file:///home/you/projects/adder)
- Running target/adder-91b3e234d4ed382a
+ Compiling adder v0.1.0 (file:///home/you/projects/adder)
+ Running target/debug/deps/adder-91b3e234d4ed382a
running 1 test
-test it_works ... ok
+test tests::it_works ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
@@ -191,11 +192,11 @@ passes:
```bash
$ cargo test
- Compiling adder v0.0.1 (file:///home/you/projects/adder)
- Running target/adder-91b3e234d4ed382a
+ Compiling adder v0.1.0 (file:///home/you/projects/adder)
+ Running target/debug/deps/adder-91b3e234d4ed382a
running 1 test
-test it_works ... ok
+test tests::it_works ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
@@ -262,8 +263,8 @@ not:
```bash
$ cargo test
- Compiling adder v0.0.1 (file:///home/you/projects/adder)
- Running target/adder-91b3e234d4ed382a
+ Compiling adder v0.1.0 (file:///home/you/projects/adder)
+ Running target/debug/deps/adder-91b3e234d4ed382a
running 2 tests
test expensive_test ... ignored
@@ -282,7 +283,7 @@ The expensive tests can be run explicitly using `cargo test -- --ignored`:
```bash
$ cargo test -- --ignored
- Running target/adder-91b3e234d4ed382a
+ Running target/debug/deps/adder-91b3e234d4ed382a
running 1 test
test expensive_test ... ok
@@ -302,8 +303,11 @@ which is why the command is `cargo test -- --ignored`.
# The `tests` module
There is one way in which our existing example is not idiomatic: it's
-missing the `tests` module. The idiomatic way of writing our example
-looks like this:
+missing the `tests` module. You might have noticed this test module was
+present in the code that was initially generated with `cargo new` but
+was missing from our last example. Let's explain what this does.
+
+The idiomatic way of writing our example looks like this:
```rust,ignore
# fn main() {}
@@ -356,8 +360,8 @@ Note the different `use` line. Now we run our tests:
```bash
$ cargo test
Updating registry `https://github.com/rust-lang/crates.io-index`
- Compiling adder v0.0.1 (file:///home/you/projects/adder)
- Running target/adder-91b3e234d4ed382a
+ Compiling adder v0.1.0 (file:///home/you/projects/adder)
+ Running target/debug/deps/adder-91b3e234d4ed382a
running 1 test
test tests::it_works ... ok
@@ -380,9 +384,9 @@ the `tests` directory.
# The `tests` directory
-Each file in `tests/*.rs` directory is treated as individual crate.
-So, to write an integration test, let's make a `tests` directory, and
-put a `tests/integration_test.rs` file inside, with this as its contents:
+Each file in `tests/*.rs` directory is treated as an individual crate.
+To write an integration test, let's make a `tests` directory and
+put a `tests/integration_test.rs` file inside with this as its contents:
```rust,ignore
extern crate adder;
@@ -404,15 +408,15 @@ Let's run them:
```bash
$ cargo test
- Compiling adder v0.0.1 (file:///home/you/projects/adder)
- Running target/adder-91b3e234d4ed382a
+ Compiling adder v0.1.0 (file:///home/you/projects/adder)
+ Running target/debug/deps/adder-91b3e234d4ed382a
running 1 test
test tests::it_works ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
- Running target/lib-c18e7d3494509e74
+ Running target/debug/integration_test-68064b69521c828a
running 1 test
test it_works ... ok
@@ -490,15 +494,15 @@ Let's run the tests again:
```bash
$ cargo test
- Compiling adder v0.0.1 (file:///home/steve/tmp/adder)
- Running target/adder-91b3e234d4ed382a
+ Compiling adder v0.1.0. (file:///home/you/projects/adder)
+ Running target/debug/deps/adder-91b3e234d4ed382a
running 1 test
test tests::it_works ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
- Running target/lib-c18e7d3494509e74
+ Running target/debug/integration_test-68064b69521c828a
running 1 test
test it_works ... ok
diff --git a/src/doc/book/type-aliases.md b/src/doc/book/type-aliases.md
index def2e31f35..3798336f0a 100644
--- a/src/doc/book/type-aliases.md
+++ b/src/doc/book/type-aliases.md
@@ -1,4 +1,4 @@
-% `type` Aliases
+% Type Aliases
The `type` keyword lets you declare an alias of another type:
diff --git a/src/doc/book/variable-bindings.md b/src/doc/book/variable-bindings.md
index 30e922d7f4..03f17371de 100644
--- a/src/doc/book/variable-bindings.md
+++ b/src/doc/book/variable-bindings.md
@@ -161,7 +161,7 @@ Could not compile `hello_world`.
Rust will not let us use a value that has not been initialized.
-Let take a minute to talk about this stuff we've added to `println!`.
+Let us take a minute to talk about this stuff we've added to `println!`.
If you include two curly braces (`{}`, some call them moustaches...) in your
string to print, Rust will interpret this as a request to interpolate some sort
diff --git a/src/doc/footer.inc b/src/doc/footer.inc
index 7513e524e7..77e151235e 100644
--- a/src/doc/footer.inc
+++ b/src/doc/footer.inc
@@ -5,4 +5,3 @@ or the MIT license, at your op
This file may not be copied, modified, or distributed except according to those terms.
-
diff --git a/src/doc/grammar.md b/src/doc/grammar.md
index be64379b51..690d44cc2c 100644
--- a/src/doc/grammar.md
+++ b/src/doc/grammar.md
@@ -764,6 +764,13 @@ bound-list := bound | bound '+' bound-list
bound := path | lifetime
```
+### Never type
+An empty type
+
+```antlr
+never_type : "!" ;
+```
+
### Object types
**FIXME:** grammar?
diff --git a/src/doc/reference.md b/src/doc/reference.md
index 9f4830cd19..711a13d21f 100644
--- a/src/doc/reference.md
+++ b/src/doc/reference.md
@@ -2479,8 +2479,6 @@ The currently implemented features of the reference compiler are:
* - `abi_vectorcall` - Allows the usage of the vectorcall calling convention
(e.g. `extern "vectorcall" func fn_();`)
-* - `dotdot_in_tuple_patterns` - Allows `..` in tuple (struct) patterns.
-
* - `abi_sysv64` - Allows the usage of the system V AMD64 calling convention
(e.g. `extern "sysv64" func fn_();`)
@@ -2860,8 +2858,8 @@ assert_eq!(x, y);
### Unary operator expressions
-Rust defines the following unary operators. They are all written as prefix operators,
-before the expression they apply to.
+Rust defines the following unary operators. With the exception of `?`, they are
+all written as prefix operators, before the expression they apply to.
* `-`
: Negation. Signed integer types and floating-point types support negation. It
@@ -2890,6 +2888,10 @@ before the expression they apply to.
If the `&` or `&mut` operators are applied to an rvalue, a
temporary value is created; the lifetime of this temporary value
is defined by [syntactic rules](#temporary-lifetimes).
+* `?`
+ : Propagating errors if applied to `Err(_)` and unwrapping if
+ applied to `Ok(_)`. Only works on the `Result` type,
+ and written in postfix notation.
### Binary operator expressions
@@ -3109,10 +3111,12 @@ the lambda expression captures its environment by reference, effectively
borrowing pointers to all outer variables mentioned inside the function.
Alternately, the compiler may infer that a lambda expression should copy or
move values (depending on their type) from the environment into the lambda
-expression's captured environment.
+expression's captured environment. A lambda can be forced to capture its
+environment by moving values by prefixing it with the `move` keyword.
In this example, we define a function `ten_times` that takes a higher-order
-function argument, and we then call it with a lambda expression as an argument:
+function argument, and we then call it with a lambda expression as an argument,
+followed by a lambda expression that moves values from its environment.
```
fn ten_times(f: F) where F: Fn(i32) {
@@ -3122,6 +3126,9 @@ fn ten_times(f: F) where F: Fn(i32) {
}
ten_times(|j| println!("hello, {}", j));
+
+let word = "konnichiwa".to_owned();
+ten_times(move |j| println!("{}, {}", word, j));
```
### Infinite loops
@@ -3750,6 +3757,21 @@ The special type `Self` has a meaning within traits and impls. In a trait defini
to an implicit type parameter representing the "implementing" type. In an impl,
it is an alias for the implementing type. For example, in:
+```
+pub trait From {
+ fn from(T) -> Self;
+}
+
+impl From for String {
+ fn from(x: i32) -> Self {
+ x.to_string()
+ }
+}
+```
+
+The notation `Self` in the impl refers to the implementing type: `String`. In another
+example:
+
```
trait Printable {
fn make_string(&self) -> String;
@@ -3958,6 +3980,16 @@ the top-level type for the implementation of the called method. If no such metho
found, `.deref()` is called and the compiler continues to search for the method
implementation in the returned type `U`.
+## The `Send` trait
+
+The `Send` trait indicates that a value of this type is safe to send from one
+thread to another.
+
+## The `Sync` trait
+
+The `Sync` trait indicates that a value of this type is safe to share between
+multiple threads.
+
# Memory model
A Rust program's memory consists of a static set of *items* and a *heap*.
@@ -4008,9 +4040,9 @@ Methods that take either `self` or `Box` can optionally place them in a
mutable variable by prefixing them with `mut` (similar to regular arguments):
```
-trait Changer {
- fn change(mut self) -> Self;
- fn modify(mut self: Box) -> Box;
+trait Changer: Sized {
+ fn change(mut self) {}
+ fn modify(mut self: Box) {}
}
```
@@ -4063,6 +4095,12 @@ be ignored in favor of only building the artifacts specified by command line.
Rust code into an existing non-Rust application because it will not have
dynamic dependencies on other Rust code.
+* `--crate-type=cdylib`, `#[crate_type = "cdylib"]` - A dynamic system
+ library will be produced. This is used when compiling Rust code as
+ a dynamic library to be loaded from another language. This output type will
+ create `*.so` files on Linux, `*.dylib` files on OSX, and `*.dll` files on
+ Windows.
+
* `--crate-type=rlib`, `#[crate_type = "rlib"]` - A "Rust library" file will be
produced. This is used as an intermediate artifact and can be thought of as a
"static Rust library". These `rlib` files, unlike `staticlib` files, are
diff --git a/src/doc/rust.css b/src/doc/rust.css
index 262db5673e..932594b991 100644
--- a/src/doc/rust.css
+++ b/src/doc/rust.css
@@ -336,13 +336,11 @@ table th {
/* Code snippets */
-.rusttest { display: none; }
pre.rust { position: relative; }
a.test-arrow {
+ background-color: rgba(78, 139, 202, 0.2);
display: inline-block;
position: absolute;
-
- background-color: #4e8bca;
color: #f5f5f5;
padding: 5px 10px 5px 10px;
border-radius: 5px;
@@ -350,6 +348,10 @@ a.test-arrow {
top: 5px;
right: 5px;
}
+a.test-arrow:hover{
+ background-color: #4e8bca;
+ text-decoration: none;
+}
.unstable-feature {
border: 2px solid red;
diff --git a/src/etc/local_stage0.sh b/src/etc/local_stage0.sh
index 645a80ab8b..ee77206640 100755
--- a/src/etc/local_stage0.sh
+++ b/src/etc/local_stage0.sh
@@ -71,6 +71,7 @@ cp ${PREFIX}/${LIB_DIR}/${LIB_PREFIX}log*${LIB_SUF} ${TARG_DIR}/stage0/${LIB_DIR
cp ${PREFIX}/${LIB_DIR}/${LIB_PREFIX}rbml*${LIB_SUF} ${TARG_DIR}/stage0/${LIB_DIR}/
cp ${PREFIX}/${LIB_DIR}/${LIB_PREFIX}serialize*${LIB_SUF} ${TARG_DIR}/stage0/${LIB_DIR}/
cp ${PREFIX}/${LIB_DIR}/${LIB_PREFIX}term*${LIB_SUF} ${TARG_DIR}/stage0/${LIB_DIR}/
+cp ${PREFIX}/${LIB_DIR}/${LIB_PREFIX}proc_macro*${LIB_SUF} ${TARG_DIR}/stage0/${LIB_DIR}/
# do not fail if one of the above fails, as all we need is a working rustc!
exit 0
diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs
index 5f9ccd1820..d6096d5894 100644
--- a/src/liballoc/arc.rs
+++ b/src/liballoc/arc.rs
@@ -10,35 +10,11 @@
#![stable(feature = "rust1", since = "1.0.0")]
-//! Threadsafe reference-counted boxes (the `Arc` type).
+//! Thread-safe reference-counting pointers.
//!
-//! The `Arc` type provides shared ownership of an immutable value through
-//! atomic reference counting.
+//! See the [`Arc`][arc] documentation for more details.
//!
-//! `Weak` is a weak reference to the `Arc` box, and it is created by
-//! the `downgrade` method.
-//! # Examples
-//!
-//! Sharing some immutable data between threads:
-//!
-// Note that we **do not** run these tests here. The windows builders get super
-// unhappy of a thread outlives the main thread and then exits at the same time
-// (something deadlocks) so we just avoid this entirely by not running these
-// tests.
-//! ```no_run
-//! use std::sync::Arc;
-//! use std::thread;
-//!
-//! let five = Arc::new(5);
-//!
-//! for _ in 0..10 {
-//! let five = five.clone();
-//!
-//! thread::spawn(move || {
-//! println!("{:?}", five);
-//! });
-//! }
-//! ```
+//! [arc]: struct.Arc.html
use boxed::Box;
@@ -60,74 +36,120 @@ use core::{isize, usize};
use core::convert::From;
use heap::deallocate;
+/// A soft limit on the amount of references that may be made to an `Arc`.
+///
+/// Going above this limit will abort your program (although not
+/// necessarily) at _exactly_ `MAX_REFCOUNT + 1` references.
const MAX_REFCOUNT: usize = (isize::MAX) as usize;
-/// An atomically reference counted wrapper for shared state.
-/// Destruction is deterministic, and will occur as soon as the last owner is
-/// gone. It is marked as `Send` because it uses atomic reference counting.
+/// A thread-safe reference-counting pointer.
///
-/// If you do not need thread-safety, and just need shared ownership, consider
-/// the [`Rc` type](../rc/struct.Rc.html). It is the same as `Arc`, but
-/// does not use atomics, making it both thread-unsafe as well as significantly
-/// faster when updating the reference count.
+/// The type `Arc` provides shared ownership of a value of type `T`,
+/// allocated in the heap. Invoking [`clone`][clone] on `Arc` produces
+/// a new pointer to the same value in the heap. When the last `Arc`
+/// pointer to a given value is destroyed, the pointed-to value is
+/// also destroyed.
///
-/// Note: the inherent methods defined on `Arc` are all associated functions,
-/// which means that you have to call them as e.g. `Arc::get_mut(&value)`
-/// instead of `value.get_mut()`. This is so that there are no conflicts with
-/// methods on the inner type `T`, which are what you want to call in the
-/// majority of cases.
+/// Shared references in Rust disallow mutation by default, and `Arc` is no
+/// exception. If you need to mutate through an `Arc`, use [`Mutex`][mutex],
+/// [`RwLock`][rwlock], or one of the [`Atomic`][atomic] types.
///
-/// # Examples
+/// `Arc` uses atomic operations for reference counting, so `Arc`s can be
+/// sent between threads. In other words, `Arc` implements [`Send`][send]
+/// as long as `T` implements `Send` and [`Sync`][sync]. The disadvantage is
+/// that atomic operations are more expensive than ordinary memory accesses.
+/// If you are not sharing reference-counted values between threads, consider
+/// using [`rc::Rc`][rc] for lower overhead. `Rc` is a safe default, because
+/// the compiler will catch any attempt to send an `Rc` between threads.
+/// However, a library might choose `Arc` in order to give library consumers
+/// more flexibility.
///
-/// In this example, a large vector of data will be shared by several threads. First we
-/// wrap it with a `Arc::new` and then clone the `Arc` reference for every thread (which will
-/// increase the reference count atomically).
+/// The [`downgrade`][downgrade] method can be used to create a non-owning
+/// [`Weak`][weak] pointer. A `Weak` pointer can be [`upgrade`][upgrade]d
+/// to an `Arc`, but this will return [`None`][option] if the value has
+/// already been dropped.
+///
+/// A cycle between `Arc` pointers will never be deallocated. For this reason,
+/// `Weak` is used to break cycles. For example, a tree could have strong
+/// `Arc` pointers from parent nodes to children, and `Weak` pointers from
+/// children back to their parents.
+///
+/// `Arc` automatically dereferences to `T` (via the [`Deref`][deref] trait),
+/// so you can call `T`'s methods on a value of type `Arc`. To avoid name
+/// clashes with `T`'s methods, the methods of `Arc` itself are [associated
+/// functions][assoc], called using function-like syntax:
///
/// ```
/// use std::sync::Arc;
-/// use std::thread;
+/// let my_arc = Arc::new(());
///
-/// fn main() {
-/// let numbers: Vec<_> = (0..100).collect();
-/// let shared_numbers = Arc::new(numbers);
+/// Arc::downgrade(&my_arc);
+/// ```
///
-/// for _ in 0..10 {
-/// // prepare a copy of reference here and it will be moved to the thread
-/// let child_numbers = shared_numbers.clone();
+/// `Weak` does not auto-dereference to `T`, because the value may have
+/// already been destroyed.
///
-/// thread::spawn(move || {
-/// let local_numbers = &child_numbers[..];
+/// [arc]: struct.Arc.html
+/// [weak]: struct.Weak.html
+/// [rc]: ../../std/rc/struct.Rc.html
+/// [clone]: ../../std/clone/trait.Clone.html#tymethod.clone
+/// [mutex]: ../../std/sync/struct.Mutex.html
+/// [rwlock]: ../../std/sync/struct.RwLock.html
+/// [atomic]: ../../std/sync/atomic/index.html
+/// [send]: ../../std/marker/trait.Send.html
+/// [sync]: ../../std/marker/trait.Sync.html
+/// [deref]: ../../std/ops/trait.Deref.html
+/// [downgrade]: struct.Arc.html#method.downgrade
+/// [upgrade]: struct.Weak.html#method.upgrade
+/// [option]: ../../std/option/enum.Option.html
+/// [assoc]: ../../book/method-syntax.html#associated-functions
///
-/// // Work with the local numbers
-/// });
-/// }
-/// }
-/// ```
-/// You can also share mutable data between threads safely
-/// by putting it inside `Mutex` and then share `Mutex` immutably
-/// with `Arc` as shown below.
+/// # Examples
///
-// See comment at the top of this file for why the test is no_run
+/// Sharing some immutable data between threads:
+///
+// Note that we **do not** run these tests here. The windows builders get super
+// unhappy if a thread outlives the main thread and then exits at the same time
+// (something deadlocks) so we just avoid this entirely by not running these
+// tests.
/// ```no_run
-/// use std::sync::{Arc, Mutex};
+/// use std::sync::Arc;
/// use std::thread;
///
-/// let five = Arc::new(Mutex::new(5));
+/// let five = Arc::new(5);
///
/// for _ in 0..10 {
/// let five = five.clone();
///
/// thread::spawn(move || {
-/// let mut number = five.lock().unwrap();
+/// println!("{:?}", five);
+/// });
+/// }
+/// ```
///
-/// *number += 1;
+/// Sharing a mutable `AtomicUsize`:
///
-/// println!("{}", *number); // prints 6
+/// ```no_run
+/// use std::sync::Arc;
+/// use std::sync::atomic::{AtomicUsize, Ordering};
+/// use std::thread;
+///
+/// let val = Arc::new(AtomicUsize::new(5));
+///
+/// for _ in 0..10 {
+/// let val = val.clone();
+///
+/// thread::spawn(move || {
+/// let v = val.fetch_add(1, Ordering::SeqCst);
+/// println!("{:?}", v);
/// });
/// }
/// ```
-
-#[cfg_attr(stage0, unsafe_no_drop_flag)]
+///
+/// See the [`rc` documentation][rc_examples] for more examples of reference
+/// counting in general.
+///
+/// [rc_examples]: ../../std/rc/index.html#examples
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Arc {
ptr: Shared>,
@@ -141,19 +163,18 @@ unsafe impl Sync for Arc {}
#[unstable(feature = "coerce_unsized", issue = "27732")]
impl, U: ?Sized> CoerceUnsized> for Arc {}
-/// A weak pointer to an `Arc`.
+/// A weak version of [`Arc`][arc].
///
-/// Weak pointers will not keep the data inside of the `Arc` alive, and can be
-/// used to break cycles between `Arc` pointers.
+/// `Weak` pointers do not count towards determining if the inner value
+/// should be dropped.
///
-/// A `Weak` pointer can be upgraded to an `Arc` pointer, but
-/// will return `None` if the value has already been dropped.
+/// The typical way to obtain a `Weak` pointer is to call
+/// [`Arc::downgrade`][downgrade].
///
-/// For example, a tree with parent pointers can be represented by putting the
-/// nodes behind strong `Arc` pointers, and then storing the parent pointers
-/// as `Weak` pointers.
-
-#[cfg_attr(stage0, unsafe_no_drop_flag)]
+/// See the [`Arc`][arc] documentation for more details.
+///
+/// [arc]: struct.Arc.html
+/// [downgrade]: struct.Arc.html#method.downgrade
#[stable(feature = "arc_weak", since = "1.4.0")]
pub struct Weak {
ptr: Shared>,
@@ -211,12 +232,15 @@ impl Arc {
Arc { ptr: unsafe { Shared::new(Box::into_raw(x)) } }
}
- /// Unwraps the contained value if the `Arc` has exactly one strong reference.
+ /// Returns the contained value, if the `Arc` has exactly one strong reference.
///
- /// Otherwise, an `Err` is returned with the same `Arc`.
+ /// Otherwise, an [`Err`][result] is returned with the same `Arc` that was
+ /// passed in.
///
/// This will succeed even if there are outstanding weak references.
///
+ /// [result]: ../../std/result/enum.Result.html
+ ///
/// # Examples
///
/// ```
@@ -227,7 +251,7 @@ impl Arc {
///
/// let x = Arc::new(4);
/// let _y = x.clone();
- /// assert_eq!(Arc::try_unwrap(x), Err(Arc::new(4)));
+ /// assert_eq!(*Arc::try_unwrap(x).unwrap_err(), 4);
/// ```
#[inline]
#[stable(feature = "arc_unique", since = "1.4.0")]
@@ -253,7 +277,9 @@ impl Arc {
}
impl Arc {
- /// Downgrades the `Arc` to a `Weak` reference.
+ /// Creates a new [`Weak`][weak] pointer to this value.
+ ///
+ /// [weak]: struct.Weak.html
///
/// # Examples
///
@@ -291,7 +317,27 @@ impl Arc {
}
}
- /// Get the number of weak references to this value.
+ /// Gets the number of [`Weak`][weak] pointers to this value.
+ ///
+ /// Be careful how you use this information, because another thread
+ /// may change the weak count at any time.
+ ///
+ /// [weak]: struct.Weak.html
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// #![feature(arc_counts)]
+ ///
+ /// use std::sync::Arc;
+ ///
+ /// let five = Arc::new(5);
+ /// let _weak_five = Arc::downgrade(&five);
+ ///
+ /// // This assertion is deterministic because we haven't shared
+ /// // the `Arc` or `Weak` between threads.
+ /// assert_eq!(1, Arc::weak_count(&five));
+ /// ```
#[inline]
#[unstable(feature = "arc_counts", reason = "not clearly useful, and racy",
issue = "28356")]
@@ -299,7 +345,25 @@ impl Arc {
this.inner().weak.load(SeqCst) - 1
}
- /// Get the number of strong references to this value.
+ /// Gets the number of strong (`Arc`) pointers to this value.
+ ///
+ /// Be careful how you use this information, because another thread
+ /// may change the strong count at any time.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// #![feature(arc_counts)]
+ ///
+ /// use std::sync::Arc;
+ ///
+ /// let five = Arc::new(5);
+ /// let _also_five = five.clone();
+ ///
+ /// // This assertion is deterministic because we haven't shared
+ /// // the `Arc` between threads.
+ /// assert_eq!(2, Arc::strong_count(&five));
+ /// ```
#[inline]
#[unstable(feature = "arc_counts", reason = "not clearly useful, and racy",
issue = "28356")]
@@ -336,8 +400,8 @@ impl Arc {
#[unstable(feature = "ptr_eq",
reason = "newly added",
issue = "36497")]
- /// Return whether two `Arc` references point to the same value
- /// (not just values that compare equal).
+ /// Returns true if the two `Arc`s point to the same value (not
+ /// just values that compare as equal).
///
/// # Examples
///
@@ -362,9 +426,10 @@ impl Arc {
#[stable(feature = "rust1", since = "1.0.0")]
impl Clone for Arc {
- /// Makes a clone of the `Arc`.
+ /// Makes a clone of the `Arc` pointer.
///
- /// This increases the strong reference count.
+ /// This creates another pointer to the same inner value, increasing the
+ /// strong reference count.
///
/// # Examples
///
@@ -420,11 +485,17 @@ impl Deref for Arc {
}
impl Arc {
- /// Make a mutable reference into the given `Arc`.
- /// If the `Arc` has more than one strong reference, or any weak
- /// references, the inner data is cloned.
+ /// Makes a mutable reference into the given `Arc`.
+ ///
+ /// If there are other `Arc` or [`Weak`][weak] pointers to the same value,
+ /// then `make_mut` will invoke [`clone`][clone] on the inner value to
+ /// ensure unique ownership. This is also referred to as clone-on-write.
///
- /// This is also referred to as a copy-on-write.
+ /// See also [`get_mut`][get_mut], which will fail rather than cloning.
+ ///
+ /// [weak]: struct.Weak.html
+ /// [clone]: ../../std/clone/trait.Clone.html#tymethod.clone
+ /// [get_mut]: struct.Arc.html#method.get_mut
///
/// # Examples
///
@@ -439,10 +510,9 @@ impl Arc {
/// *Arc::make_mut(&mut data) += 1; // Won't clone anything
/// *Arc::make_mut(&mut other_data) *= 2; // Won't clone anything
///
- /// // Note: data and other_data now point to different numbers
+ /// // Now `data` and `other_data` point to different values.
/// assert_eq!(*data, 8);
/// assert_eq!(*other_data, 12);
- ///
/// ```
#[inline]
#[stable(feature = "arc_unique", since = "1.4.0")]
@@ -501,8 +571,19 @@ impl Arc {
}
impl Arc {
- /// Returns a mutable reference to the contained value if the `Arc` has
- /// one strong reference and no weak references.
+ /// Returns a mutable reference to the inner value, if there are
+ /// no other `Arc` or [`Weak`][weak] pointers to the same value.
+ ///
+ /// Returns [`None`][option] otherwise, because it is not safe to
+ /// mutate a shared value.
+ ///
+ /// See also [`make_mut`][make_mut], which will [`clone`][clone]
+ /// the inner value when it's shared.
+ ///
+ /// [weak]: struct.Weak.html
+ /// [option]: ../../std/option/enum.Option.html
+ /// [make_mut]: struct.Arc.html#method.make_mut
+ /// [clone]: ../../std/clone/trait.Clone.html#tymethod.clone
///
/// # Examples
///
@@ -564,30 +645,32 @@ impl Arc {
#[stable(feature = "rust1", since = "1.0.0")]
impl Drop for Arc {
- /// Drops the `Arc`.
+ /// Drops the `Arc`.
///
/// This will decrement the strong reference count. If the strong reference
- /// count becomes zero and the only other references are `Weak` ones,
- /// `drop`s the inner value.
+ /// count reaches zero then the only other references (if any) are
+ /// [`Weak`][weak], so we `drop` the inner value.
+ ///
+ /// [weak]: struct.Weak.html
///
/// # Examples
///
/// ```
/// use std::sync::Arc;
///
- /// {
- /// let five = Arc::new(5);
- ///
- /// // stuff
+ /// struct Foo;
///
- /// drop(five); // explicit drop
+ /// impl Drop for Foo {
+ /// fn drop(&mut self) {
+ /// println!("dropped!");
+ /// }
/// }
- /// {
- /// let five = Arc::new(5);
///
- /// // stuff
+ /// let foo = Arc::new(Foo);
+ /// let foo2 = foo.clone();
///
- /// } // implicit drop
+ /// drop(foo); // Doesn't print anything
+ /// drop(foo2); // Prints "dropped!"
/// ```
#[unsafe_destructor_blind_to_params]
#[inline]
@@ -625,10 +708,14 @@ impl Drop for Arc {
}
impl Weak {
- /// Constructs a new `Weak` without an accompanying instance of T.
+ /// Constructs a new `Weak`, without an accompanying instance of `T`.
///
- /// This allocates memory for T, but does not initialize it. Calling
- /// Weak::upgrade() on the return value always gives None.
+ /// This allocates memory for `T`, but does not initialize it. Calling
+ /// [`upgrade`][upgrade] on the return value always gives
+ /// [`None`][option].
+ ///
+ /// [upgrade]: struct.Weak.html#method.upgrade
+ /// [option]: ../../std/option/enum.Option.html
///
/// # Examples
///
@@ -636,6 +723,7 @@ impl Weak {
/// use std::sync::Weak;
///
/// let empty: Weak = Weak::new();
+ /// assert!(empty.upgrade().is_none());
/// ```
#[stable(feature = "downgraded_weak", since = "1.10.0")]
pub fn new() -> Weak {
@@ -652,12 +740,13 @@ impl Weak {
}
impl Weak {
- /// Upgrades a weak reference to a strong reference.
+ /// Upgrades the `Weak` pointer to an [`Arc`][arc], if possible.
///
- /// Upgrades the `Weak` reference to an `Arc`, if possible.
+ /// Returns [`None`][option] if the strong count has reached zero and the
+ /// inner value was destroyed.
///
- /// Returns `None` if there were no strong references and the data was
- /// destroyed.
+ /// [arc]: struct.Arc.html
+ /// [option]: ../../std/option/enum.Option.html
///
/// # Examples
///
@@ -669,6 +758,13 @@ impl Weak {
/// let weak_five = Arc::downgrade(&five);
///
/// let strong_five: Option> = weak_five.upgrade();
+ /// assert!(strong_five.is_some());
+ ///
+ /// // Destroy all strong pointers.
+ /// drop(strong_five);
+ /// drop(five);
+ ///
+ /// assert!(weak_five.upgrade().is_none());
/// ```
#[stable(feature = "arc_weak", since = "1.4.0")]
pub fn upgrade(&self) -> Option> {
@@ -711,9 +807,10 @@ impl Weak {
#[stable(feature = "arc_weak", since = "1.4.0")]
impl Clone for Weak {
- /// Makes a clone of the `Weak`.
+ /// Makes a clone of the `Weak` pointer.
///
- /// This increases the weak reference count.
+ /// This creates another pointer to the same inner value, increasing the
+ /// weak reference count.
///
/// # Examples
///
@@ -745,7 +842,23 @@ impl Clone for Weak {
#[stable(feature = "downgraded_weak", since = "1.10.0")]
impl Default for Weak {
- /// Constructs a new `Weak` without an accompanying instance of T.
+ /// Constructs a new `Weak`, without an accompanying instance of `T`.
+ ///
+ /// This allocates memory for `T`, but does not initialize it. Calling
+ /// [`upgrade`][upgrade] on the return value always gives
+ /// [`None`][option].
+ ///
+ /// [upgrade]: struct.Weak.html#method.upgrade
+ /// [option]: ../../std/option/enum.Option.html
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use std::sync::Weak;
+ ///
+ /// let empty: Weak = Default::default();
+ /// assert!(empty.upgrade().is_none());
+ /// ```
fn default() -> Weak {
Weak::new()
}
@@ -753,7 +866,7 @@ impl Default for Weak {
#[stable(feature = "arc_weak", since = "1.4.0")]
impl Drop for Weak {
- /// Drops the `Weak`.
+ /// Drops the `Weak` pointer.
///
/// This will decrement the weak reference count.
///
@@ -762,21 +875,22 @@ impl Drop for Weak {
/// ```
/// use std::sync::Arc;
///
- /// {
- /// let five = Arc::new(5);
- /// let weak_five = Arc::downgrade(&five);
- ///
- /// // stuff
+ /// struct Foo;
///
- /// drop(weak_five); // explicit drop
+ /// impl Drop for Foo {
+ /// fn drop(&mut self) {
+ /// println!("dropped!");
+ /// }
/// }
- /// {
- /// let five = Arc::new(5);
- /// let weak_five = Arc::downgrade(&five);
///
- /// // stuff
+ /// let foo = Arc::new(Foo);
+ /// let weak_foo = Arc::downgrade(&foo);
+ /// let other_weak_foo = weak_foo.clone();
///
- /// } // implicit drop
+ /// drop(weak_foo); // Doesn't print anything
+ /// drop(foo); // Prints "dropped!"
+ ///
+ /// assert!(other_weak_foo.upgrade().is_none());
/// ```
fn drop(&mut self) {
let ptr = *self.ptr;
@@ -798,9 +912,9 @@ impl Drop for Weak {
#[stable(feature = "rust1", since = "1.0.0")]
impl PartialEq for Arc {
- /// Equality for two `Arc`s.
+ /// Equality for two `Arc`s.
///
- /// Two `Arc`s are equal if their inner value are equal.
+ /// Two `Arc`s are equal if their inner values are equal.
///
/// # Examples
///
@@ -809,15 +923,15 @@ impl PartialEq for Arc {
///
/// let five = Arc::new(5);
///
- /// five == Arc::new(5);
+ /// assert!(five == Arc::new(5));
/// ```
fn eq(&self, other: &Arc) -> bool {
*(*self) == *(*other)
}
- /// Inequality for two `Arc`s.
+ /// Inequality for two `Arc`s.
///
- /// Two `Arc`s are unequal if their inner value are unequal.
+ /// Two `Arc`s are unequal if their inner values are unequal.
///
/// # Examples
///
@@ -826,7 +940,7 @@ impl PartialEq for Arc {
///
/// let five = Arc::new(5);
///
- /// five != Arc::new(5);
+ /// assert!(five != Arc::new(6));
/// ```
fn ne(&self, other: &Arc) -> bool {
*(*self) != *(*other)
@@ -834,7 +948,7 @@ impl PartialEq for Arc {
}
#[stable(feature = "rust1", since = "1.0.0")]
impl PartialOrd for Arc {
- /// Partial comparison for two `Arc`s.
+ /// Partial comparison for two `Arc`s.
///
/// The two are compared by calling `partial_cmp()` on their inner values.
///
@@ -842,16 +956,17 @@ impl PartialOrd for Arc {
///
/// ```
/// use std::sync::Arc;
+ /// use std::cmp::Ordering;
///
/// let five = Arc::new(5);
///
- /// five.partial_cmp(&Arc::new(5));
+ /// assert_eq!(Some(Ordering::Less), five.partial_cmp(&Arc::new(6)));
/// ```
fn partial_cmp(&self, other: &Arc) -> Option {
(**self).partial_cmp(&**other)
}
- /// Less-than comparison for two `Arc`s.
+ /// Less-than comparison for two `Arc`s.
///
/// The two are compared by calling `<` on their inner values.
///
@@ -862,13 +977,13 @@ impl PartialOrd for Arc {
///
/// let five = Arc::new(5);
///
- /// five < Arc::new(5);
+ /// assert!(five < Arc::new(6));
/// ```
fn lt(&self, other: &Arc) -> bool {
*(*self) < *(*other)
}
- /// 'Less-than or equal to' comparison for two `Arc`s.
+ /// 'Less than or equal to' comparison for two `Arc`s.
///
/// The two are compared by calling `<=` on their inner values.
///
@@ -879,13 +994,13 @@ impl PartialOrd for Arc {
///
/// let five = Arc::new(5);
///
- /// five <= Arc::new(5);
+ /// assert!(five <= Arc::new(5));
/// ```
fn le(&self, other: &Arc) -> bool {
*(*self) <= *(*other)
}
- /// Greater-than comparison for two `Arc`s.
+ /// Greater-than comparison for two `Arc`s.
///
/// The two are compared by calling `>` on their inner values.
///
@@ -896,13 +1011,13 @@ impl PartialOrd for Arc {
///
/// let five = Arc::new(5);
///
- /// five > Arc::new(5);
+ /// assert!(five > Arc::new(4));
/// ```
fn gt(&self, other: &Arc) -> bool {
*(*self) > *(*other)
}
- /// 'Greater-than or equal to' comparison for two `Arc`s.
+ /// 'Greater than or equal to' comparison for two `Arc`s.
///
/// The two are compared by calling `>=` on their inner values.
///
@@ -913,7 +1028,7 @@ impl PartialOrd for Arc {
///
/// let five = Arc::new(5);
///
- /// five >= Arc::new(5);
+ /// assert!(five >= Arc::new(5));
/// ```
fn ge(&self, other: &Arc) -> bool {
*(*self) >= *(*other)
@@ -921,6 +1036,20 @@ impl PartialOrd for Arc {
}
#[stable(feature = "rust1", since = "1.0.0")]
impl Ord for Arc {
+ /// Comparison for two `Arc`s.
+ ///
+ /// The two are compared by calling `cmp()` on their inner values.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use std::sync::Arc;
+ /// use std::cmp::Ordering;
+ ///
+ /// let five = Arc::new(5);
+ ///
+ /// assert_eq!(Ordering::Less, five.cmp(&Arc::new(6)));
+ /// ```
fn cmp(&self, other: &Arc) -> Ordering {
(**self).cmp(&**other)
}
@@ -951,7 +1080,16 @@ impl fmt::Pointer for Arc {
#[stable(feature = "rust1", since = "1.0.0")]
impl Default for Arc {
- /// Creates a new `Arc`, with the `Default` value for T.
+ /// Creates a new `Arc`, with the `Default` value for `T`.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// use std::sync::Arc;
+ ///
+ /// let x: Arc = Default::default();
+ /// assert_eq!(*x, 0);
+ /// ```
fn default() -> Arc {
Arc::new(Default::default())
}
@@ -1002,6 +1140,7 @@ mod tests {
}
#[test]
+ #[cfg_attr(target_os = "emscripten", ignore)]
fn manually_share_arc() {
let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let arc_v = Arc::new(v);
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs
index bc9b6e805e..28f4dda140 100644
--- a/src/liballoc/boxed.rs
+++ b/src/liballoc/boxed.rs
@@ -244,12 +244,14 @@ impl Box {
/// the destructor of `T` and free the allocated memory. Since the
/// way `Box` allocates and releases memory is unspecified, the
/// only valid pointer to pass to this function is the one taken
- /// from another `Box` via the `Box::into_raw` function.
+ /// from another `Box` via the [`Box::into_raw`] function.
///
/// This function is unsafe because improper use may lead to
/// memory problems. For example, a double-free may occur if the
/// function is called twice on the same raw pointer.
///
+ /// [`Box::into_raw`]: struct.Box.html#method.into_raw
+ ///
/// # Examples
///
/// ```
@@ -269,12 +271,14 @@ impl Box {
/// memory previously managed by the `Box`. In particular, the
/// caller should properly destroy `T` and release the memory. The
/// proper way to do so is to convert the raw pointer back into a
- /// `Box` with the `Box::from_raw` function.
+ /// `Box` with the [`Box::from_raw`] function.
///
/// Note: this is an associated function, which means that you have
/// to call it as `Box::into_raw(b)` instead of `b.into_raw()`. This
/// is so that there is no conflict with a method on the inner type.
///
+ /// [`Box::from_raw`]: struct.Box.html#method.from_raw
+ ///
/// # Examples
///
/// ```
diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs
index c6453da3f4..31491106d9 100644
--- a/src/liballoc/lib.rs
+++ b/src/liballoc/lib.rs
@@ -88,7 +88,6 @@
#![feature(staged_api)]
#![feature(unboxed_closures)]
#![feature(unique)]
-#![cfg_attr(stage0, feature(unsafe_no_drop_flag))]
#![feature(unsize)]
#![cfg_attr(not(test), feature(fused, fn_traits, placement_new_protocol))]
diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs
index 23542215fa..f23ea0ea8b 100644
--- a/src/liballoc/raw_vec.rs
+++ b/src/liballoc/raw_vec.rs
@@ -44,7 +44,6 @@ use core::cmp;
/// `shrink_to_fit`, and `from_box` will actually set RawVec's private capacity
/// field. This allows zero-sized types to not be special-cased by consumers of
/// this type.
-#[cfg_attr(stage0, unsafe_no_drop_flag)]
pub struct RawVec {
ptr: Unique,
cap: usize,
@@ -58,11 +57,7 @@ impl RawVec {
pub fn new() -> Self {
unsafe {
// !0 is usize::MAX. This branch should be stripped at compile time.
- let cap = if mem::size_of::() == 0 {
- !0
- } else {
- 0
- };
+ let cap = if mem::size_of::() == 0 { !0 } else { 0 };
// heap::EMPTY doubles as "unallocated" and "zero-sized allocation"
RawVec {
@@ -210,11 +205,7 @@ impl RawVec {
let (new_cap, ptr) = if self.cap == 0 {
// skip to 4 because tiny Vec's are dumb; but not if that would cause overflow
- let new_cap = if elem_size > (!0) / 8 {
- 1
- } else {
- 4
- };
+ let new_cap = if elem_size > (!0) / 8 { 1 } else { 4 };
let ptr = heap::allocate(new_cap * elem_size, align);
(new_cap, ptr)
} else {
@@ -348,7 +339,7 @@ impl RawVec {
let elem_size = mem::size_of::();
// Nothing we can really do about these checks :(
let required_cap = used_cap.checked_add(needed_extra_cap)
- .expect("capacity overflow");
+ .expect("capacity overflow");
// Cannot overflow, because `cap <= isize::MAX`, and type of `cap` is `usize`.
let double_cap = self.cap * 2;
// `double_cap` guarantees exponential growth.
diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs
index e0f635f195..740d13c476 100644
--- a/src/liballoc/rc.rs
+++ b/src/liballoc/rc.rs
@@ -12,12 +12,12 @@
//! Single-threaded reference-counting pointers.
//!
-//! The type [`Rc`][rc] provides shared ownership of a value, allocated
-//! in the heap. Invoking [`clone`][clone] on `Rc` produces a new pointer
-//! to the same value in the heap. When the last `Rc` pointer to a given
-//! value is destroyed, the pointed-to value is also destroyed.
+//! The type [`Rc`][rc] provides shared ownership of a value of type `T`,
+//! allocated in the heap. Invoking [`clone`][clone] on `Rc` produces a new
+//! pointer to the same value in the heap. When the last `Rc` pointer to a
+//! given value is destroyed, the pointed-to value is also destroyed.
//!
-//! Shared pointers in Rust disallow mutation by default, and `Rc` is no
+//! Shared references in Rust disallow mutation by default, and `Rc` is no
//! exception. If you need to mutate through an `Rc`, use [`Cell`][cell] or
//! [`RefCell`][refcell].
//!
@@ -44,8 +44,9 @@
//! functions][assoc], called using function-like syntax:
//!
//! ```
-//! # use std::rc::Rc;
-//! # let my_rc = Rc::new(());
+//! use std::rc::Rc;
+//! let my_rc = Rc::new(());
+//!
//! Rc::downgrade(&my_rc);
//! ```
//!
@@ -229,13 +230,14 @@ use core::hash::{Hash, Hasher};
use core::intrinsics::{abort, assume};
use core::marker;
use core::marker::Unsize;
-use core::mem::{self, align_of_val, forget, size_of_val, uninitialized};
+use core::mem::{self, align_of_val, forget, size_of, size_of_val, uninitialized};
use core::ops::Deref;
use core::ops::CoerceUnsized;
use core::ptr::{self, Shared};
use core::convert::From;
use heap::deallocate;
+use raw_vec::RawVec;
struct RcBox {
strong: Cell,
@@ -252,7 +254,6 @@ struct RcBox {
/// that you have to call them as e.g. `Rc::get_mut(&value)` instead of
/// `value.get_mut()`. This avoids conflicts with methods of the inner
/// type `T`.
-#[cfg_attr(stage0, unsafe_no_drop_flag)]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Rc {
ptr: Shared>,
@@ -295,10 +296,13 @@ impl Rc {
/// Returns the contained value, if the `Rc` has exactly one strong reference.
///
- /// Otherwise, an `Err` is returned with the same `Rc` that was passed in.
+ /// Otherwise, an [`Err`][result] is returned with the same `Rc` that was
+ /// passed in.
///
/// This will succeed even if there are outstanding weak references.
///
+ /// [result]: ../../std/result/enum.Result.html
+ ///
/// # Examples
///
/// ```
@@ -332,7 +336,11 @@ impl Rc {
}
}
- /// Checks whether `Rc::try_unwrap` would return `Ok`.
+ /// Checks whether [`Rc::try_unwrap`][try_unwrap] would return
+ /// [`Ok`][result].
+ ///
+ /// [try_unwrap]: struct.Rc.html#method.try_unwrap
+ /// [result]: ../../std/result/enum.Result.html
///
/// # Examples
///
@@ -358,6 +366,31 @@ impl Rc {
}
}
+impl Rc {
+ /// Constructs a new `Rc` from a string slice.
+ #[doc(hidden)]
+ #[unstable(feature = "rustc_private",
+ reason = "for internal use in rustc",
+ issue = "0")]
+ pub fn __from_str(value: &str) -> Rc {
+ unsafe {
+ // Allocate enough space for `RcBox`.
+ let aligned_len = 2 + (value.len() + size_of::() - 1) / size_of::();
+ let vec = RawVec::::with_capacity(aligned_len);
+ let ptr = vec.ptr();
+ forget(vec);
+ // Initialize fields of `RcBox`.
+ *ptr.offset(0) = 1; // strong: Cell::new(1)
+ *ptr.offset(1) = 1; // weak: Cell::new(1)
+ ptr::copy_nonoverlapping(value.as_ptr(), ptr.offset(2) as *mut u8, value.len());
+ // Combine the allocation address and the string length into a fat pointer to `RcBox`.
+ let rcbox_ptr: *mut RcBox = mem::transmute([ptr as usize, value.len()]);
+ assert!(aligned_len * size_of::() == size_of_val(&*rcbox_ptr));
+ Rc { ptr: Shared::new(rcbox_ptr) }
+ }
+ }
+}
+
impl Rc {
/// Creates a new [`Weak`][weak] pointer to this value.
///
@@ -583,8 +616,10 @@ impl Drop for Rc {
/// Drops the `Rc`.
///
/// This will decrement the strong reference count. If the strong reference
- /// count reaches zero then the only other references (if any) are `Weak`,
- /// so we `drop` the inner value.
+ /// count reaches zero then the only other references (if any) are
+ /// [`Weak`][weak], so we `drop` the inner value.
+ ///
+ /// [weak]: struct.Weak.html
///
/// # Examples
///
@@ -873,7 +908,6 @@ impl From for Rc {
///
/// [rc]: struct.Rc.html
/// [downgrade]: struct.Rc.html#method.downgrade
-#[cfg_attr(stage0, unsafe_no_drop_flag)]
#[stable(feature = "rc_weak", since = "1.4.0")]
pub struct Weak {
ptr: Shared>,
diff --git a/src/liballoc_jemalloc/build.rs b/src/liballoc_jemalloc/build.rs
index 8b31c5a557..08a1f8ae8c 100644
--- a/src/liballoc_jemalloc/build.rs
+++ b/src/liballoc_jemalloc/build.rs
@@ -27,6 +27,20 @@ fn main() {
let build_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
let src_dir = env::current_dir().unwrap();
+ // FIXME: This is a hack to support building targets that don't
+ // support jemalloc alongside hosts that do. The jemalloc build is
+ // controlled by a feature of the std crate, and if that feature
+ // changes between targets, it invalidates the fingerprint of
+ // std's build script (this is a cargo bug); so we must ensure
+ // that the feature set used by std is the same across all
+ // targets, which means we have to build the alloc_jemalloc crate
+ // for targets like emscripten, even if we don't use it.
+ if target.contains("rumprun") || target.contains("bitrig") || target.contains("openbsd") ||
+ target.contains("msvc") || target.contains("emscripten") || target.contains("fuchsia") {
+ println!("cargo:rustc-cfg=dummy_jemalloc");
+ return;
+ }
+
if let Some(jemalloc) = env::var_os("JEMALLOC_OVERRIDE") {
let jemalloc = PathBuf::from(jemalloc);
println!("cargo:rustc-link-search=native={}",
@@ -46,16 +60,16 @@ fn main() {
// only msvc returns None for ar so unwrap is okay
let ar = build_helper::cc2ar(compiler.path(), &target).unwrap();
let cflags = compiler.args()
- .iter()
- .map(|s| s.to_str().unwrap())
- .collect::>()
- .join(" ");
+ .iter()
+ .map(|s| s.to_str().unwrap())
+ .collect::>()
+ .join(" ");
let mut stack = src_dir.join("../jemalloc")
- .read_dir()
- .unwrap()
- .map(|e| e.unwrap())
- .collect::>();
+ .read_dir()
+ .unwrap()
+ .map(|e| e.unwrap())
+ .collect::>();
while let Some(entry) = stack.pop() {
let path = entry.path();
if entry.file_type().unwrap().is_dir() {
@@ -137,10 +151,10 @@ fn main() {
run(&mut cmd);
run(Command::new("make")
- .current_dir(&build_dir)
- .arg("build_lib_static")
- .arg("-j")
- .arg(env::var("NUM_JOBS").expect("NUM_JOBS was not set")));
+ .current_dir(&build_dir)
+ .arg("build_lib_static")
+ .arg("-j")
+ .arg(env::var("NUM_JOBS").expect("NUM_JOBS was not set")));
if target.contains("windows") {
println!("cargo:rustc-link-lib=static=jemalloc");
diff --git a/src/liballoc_jemalloc/lib.rs b/src/liballoc_jemalloc/lib.rs
index 5bbf1c35e0..21e45f9c4b 100644
--- a/src/liballoc_jemalloc/lib.rs
+++ b/src/liballoc_jemalloc/lib.rs
@@ -23,124 +23,170 @@
extern crate libc;
-use libc::{c_int, c_void, size_t};
+pub use imp::*;
-// Linkage directives to pull in jemalloc and its dependencies.
-//
-// On some platforms we need to be sure to link in `pthread` which jemalloc
-// depends on, and specifically on android we need to also link to libgcc.
-// Currently jemalloc is compiled with gcc which will generate calls to
-// intrinsics that are libgcc specific (e.g. those intrinsics aren't present in
-// libcompiler-rt), so link that in to get that support.
-#[link(name = "jemalloc", kind = "static")]
-#[cfg_attr(target_os = "android", link(name = "gcc"))]
-#[cfg_attr(all(not(windows),
- not(target_os = "android"),
- not(target_env = "musl")),
- link(name = "pthread"))]
-#[cfg(not(cargobuild))]
-extern "C" {}
-
-// Note that the symbols here are prefixed by default on OSX and Windows (we
-// don't explicitly request it), and on Android and DragonFly we explicitly
-// request it as unprefixing cause segfaults (mismatches in allocators).
-extern "C" {
- #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios",
- target_os = "dragonfly", target_os = "windows"),
- link_name = "je_mallocx")]
- fn mallocx(size: size_t, flags: c_int) -> *mut c_void;
- #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios",
- target_os = "dragonfly", target_os = "windows"),
- link_name = "je_rallocx")]
- fn rallocx(ptr: *mut c_void, size: size_t, flags: c_int) -> *mut c_void;
- #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios",
- target_os = "dragonfly", target_os = "windows"),
- link_name = "je_xallocx")]
- fn xallocx(ptr: *mut c_void, size: size_t, extra: size_t, flags: c_int) -> size_t;
- #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios",
- target_os = "dragonfly", target_os = "windows"),
- link_name = "je_sdallocx")]
- fn sdallocx(ptr: *mut c_void, size: size_t, flags: c_int);
- #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios",
- target_os = "dragonfly", target_os = "windows"),
- link_name = "je_nallocx")]
- fn nallocx(size: size_t, flags: c_int) -> size_t;
-}
+// See comments in build.rs for why we sometimes build a crate that does nothing
+#[cfg(not(dummy_jemalloc))]
+mod imp {
+ use libc::{c_int, c_void, size_t};
-// The minimum alignment guaranteed by the architecture. This value is used to
-// add fast paths for low alignment values. In practice, the alignment is a
-// constant at the call site and the branch will be optimized out.
-#[cfg(all(any(target_arch = "arm",
- target_arch = "mips",
- target_arch = "powerpc")))]
-const MIN_ALIGN: usize = 8;
-#[cfg(all(any(target_arch = "x86",
- target_arch = "x86_64",
- target_arch = "aarch64",
- target_arch = "powerpc64",
- target_arch = "mips64",
- target_arch = "s390x")))]
-const MIN_ALIGN: usize = 16;
-
-// MALLOCX_ALIGN(a) macro
-fn mallocx_align(a: usize) -> c_int {
- a.trailing_zeros() as c_int
-}
+ // Linkage directives to pull in jemalloc and its dependencies.
+ //
+ // On some platforms we need to be sure to link in `pthread` which jemalloc
+ // depends on, and specifically on android we need to also link to libgcc.
+ // Currently jemalloc is compiled with gcc which will generate calls to
+ // intrinsics that are libgcc specific (e.g. those intrinsics aren't present in
+ // libcompiler-rt), so link that in to get that support.
+ #[link(name = "jemalloc", kind = "static")]
+ #[cfg_attr(target_os = "android", link(name = "gcc"))]
+ #[cfg_attr(all(not(windows),
+ not(target_os = "android"),
+ not(target_env = "musl")),
+ link(name = "pthread"))]
+ #[cfg(not(cargobuild))]
+ extern "C" {}
+
+ // Note that the symbols here are prefixed by default on OSX and Windows (we
+ // don't explicitly request it), and on Android and DragonFly we explicitly
+ // request it as unprefixing cause segfaults (mismatches in allocators).
+ extern "C" {
+ #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios",
+ target_os = "dragonfly", target_os = "windows"),
+ link_name = "je_mallocx")]
+ fn mallocx(size: size_t, flags: c_int) -> *mut c_void;
+ #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios",
+ target_os = "dragonfly", target_os = "windows"),
+ link_name = "je_rallocx")]
+ fn rallocx(ptr: *mut c_void, size: size_t, flags: c_int) -> *mut c_void;
+ #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios",
+ target_os = "dragonfly", target_os = "windows"),
+ link_name = "je_xallocx")]
+ fn xallocx(ptr: *mut c_void, size: size_t, extra: size_t, flags: c_int) -> size_t;
+ #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios",
+ target_os = "dragonfly", target_os = "windows"),
+ link_name = "je_sdallocx")]
+ fn sdallocx(ptr: *mut c_void, size: size_t, flags: c_int);
+ #[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios",
+ target_os = "dragonfly", target_os = "windows"),
+ link_name = "je_nallocx")]
+ fn nallocx(size: size_t, flags: c_int) -> size_t;
+ }
+
+ // The minimum alignment guaranteed by the architecture. This value is used to
+ // add fast paths for low alignment values. In practice, the alignment is a
+ // constant at the call site and the branch will be optimized out.
+ #[cfg(all(any(target_arch = "arm",
+ target_arch = "mips",
+ target_arch = "powerpc")))]
+ const MIN_ALIGN: usize = 8;
+ #[cfg(all(any(target_arch = "x86",
+ target_arch = "x86_64",
+ target_arch = "aarch64",
+ target_arch = "powerpc64",
+ target_arch = "mips64",
+ target_arch = "s390x")))]
+ const MIN_ALIGN: usize = 16;
+
+ // MALLOCX_ALIGN(a) macro
+ fn mallocx_align(a: usize) -> c_int {
+ a.trailing_zeros() as c_int
+ }
+
+ fn align_to_flags(align: usize) -> c_int {
+ if align <= MIN_ALIGN {
+ 0
+ } else {
+ mallocx_align(align)
+ }
+ }
+
+ #[no_mangle]
+ pub extern "C" fn __rust_allocate(size: usize, align: usize) -> *mut u8 {
+ let flags = align_to_flags(align);
+ unsafe { mallocx(size as size_t, flags) as *mut u8 }
+ }
+
+ #[no_mangle]
+ pub extern "C" fn __rust_reallocate(ptr: *mut u8,
+ _old_size: usize,
+ size: usize,
+ align: usize)
+ -> *mut u8 {
+ let flags = align_to_flags(align);
+ unsafe { rallocx(ptr as *mut c_void, size as size_t, flags) as *mut u8 }
+ }
+
+ #[no_mangle]
+ pub extern "C" fn __rust_reallocate_inplace(ptr: *mut u8,
+ _old_size: usize,
+ size: usize,
+ align: usize)
+ -> usize {
+ let flags = align_to_flags(align);
+ unsafe { xallocx(ptr as *mut c_void, size as size_t, 0, flags) as usize }
+ }
-fn align_to_flags(align: usize) -> c_int {
- if align <= MIN_ALIGN {
+ #[no_mangle]
+ pub extern "C" fn __rust_deallocate(ptr: *mut u8, old_size: usize, align: usize) {
+ let flags = align_to_flags(align);
+ unsafe { sdallocx(ptr as *mut c_void, old_size as size_t, flags) }
+ }
+
+ #[no_mangle]
+ pub extern "C" fn __rust_usable_size(size: usize, align: usize) -> usize {
+ let flags = align_to_flags(align);
+ unsafe { nallocx(size as size_t, flags) as usize }
+ }
+
+ // These symbols are used by jemalloc on android but the really old android
+ // we're building on doesn't have them defined, so just make sure the symbols
+ // are available.
+ #[no_mangle]
+ #[cfg(target_os = "android")]
+ pub extern "C" fn pthread_atfork(_prefork: *mut u8,
+ _postfork_parent: *mut u8,
+ _postfork_child: *mut u8)
+ -> i32 {
0
- } else {
- mallocx_align(align)
}
}
-#[no_mangle]
-pub extern "C" fn __rust_allocate(size: usize, align: usize) -> *mut u8 {
- let flags = align_to_flags(align);
- unsafe { mallocx(size as size_t, flags) as *mut u8 }
-}
+#[cfg(dummy_jemalloc)]
+mod imp {
+ fn bogus() -> ! {
+ panic!("jemalloc is not implemented for this platform");
+ }
-#[no_mangle]
-pub extern "C" fn __rust_reallocate(ptr: *mut u8,
- _old_size: usize,
- size: usize,
- align: usize)
- -> *mut u8 {
- let flags = align_to_flags(align);
- unsafe { rallocx(ptr as *mut c_void, size as size_t, flags) as *mut u8 }
-}
+ #[no_mangle]
+ pub extern "C" fn __rust_allocate(_size: usize, _align: usize) -> *mut u8 {
+ bogus()
+ }
-#[no_mangle]
-pub extern "C" fn __rust_reallocate_inplace(ptr: *mut u8,
- _old_size: usize,
- size: usize,
- align: usize)
- -> usize {
- let flags = align_to_flags(align);
- unsafe { xallocx(ptr as *mut c_void, size as size_t, 0, flags) as usize }
-}
+ #[no_mangle]
+ pub extern "C" fn __rust_reallocate(_ptr: *mut u8,
+ _old_size: usize,
+ _size: usize,
+ _align: usize)
+ -> *mut u8 {
+ bogus()
+ }
-#[no_mangle]
-pub extern "C" fn __rust_deallocate(ptr: *mut u8, old_size: usize, align: usize) {
- let flags = align_to_flags(align);
- unsafe { sdallocx(ptr as *mut c_void, old_size as size_t, flags) }
-}
+ #[no_mangle]
+ pub extern "C" fn __rust_reallocate_inplace(_ptr: *mut u8,
+ _old_size: usize,
+ _size: usize,
+ _align: usize)
+ -> usize {
+ bogus()
+ }
-#[no_mangle]
-pub extern "C" fn __rust_usable_size(size: usize, align: usize) -> usize {
- let flags = align_to_flags(align);
- unsafe { nallocx(size as size_t, flags) as usize }
-}
+ #[no_mangle]
+ pub extern "C" fn __rust_deallocate(_ptr: *mut u8, _old_size: usize, _align: usize) {
+ bogus()
+ }
-// These symbols are used by jemalloc on android but the really old android
-// we're building on doesn't have them defined, so just make sure the symbols
-// are available.
-#[no_mangle]
-#[cfg(target_os = "android")]
-pub extern "C" fn pthread_atfork(_prefork: *mut u8,
- _postfork_parent: *mut u8,
- _postfork_child: *mut u8)
- -> i32 {
- 0
+ #[no_mangle]
+ pub extern "C" fn __rust_usable_size(_size: usize, _align: usize) -> usize {
+ bogus()
+ }
}
diff --git a/src/liballoc_system/lib.rs b/src/liballoc_system/lib.rs
index 01407d1acd..a4fabb5a2c 100644
--- a/src/liballoc_system/lib.rs
+++ b/src/liballoc_system/lib.rs
@@ -29,7 +29,8 @@
target_arch = "mips",
target_arch = "powerpc",
target_arch = "powerpc64",
- target_arch = "asmjs")))]
+ target_arch = "asmjs",
+ target_arch = "wasm32")))]
const MIN_ALIGN: usize = 8;
#[cfg(all(any(target_arch = "x86_64",
target_arch = "aarch64",
@@ -165,6 +166,7 @@ mod imp {
fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) -> LPVOID;
fn HeapReAlloc(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID, dwBytes: SIZE_T) -> LPVOID;
fn HeapFree(hHeap: HANDLE, dwFlags: DWORD, lpMem: LPVOID) -> BOOL;
+ fn GetLastError() -> DWORD;
}
#[repr(C)]
@@ -220,11 +222,7 @@ mod imp {
HEAP_REALLOC_IN_PLACE_ONLY,
ptr as LPVOID,
size as SIZE_T) as *mut u8;
- if new.is_null() {
- old_size
- } else {
- size
- }
+ if new.is_null() { old_size } else { size }
} else {
old_size
}
@@ -233,11 +231,11 @@ mod imp {
pub unsafe fn deallocate(ptr: *mut u8, _old_size: usize, align: usize) {
if align <= MIN_ALIGN {
let err = HeapFree(GetProcessHeap(), 0, ptr as LPVOID);
- debug_assert!(err != 0);
+ debug_assert!(err != 0, "Failed to free heap memory: {}", GetLastError());
} else {
let header = get_header(ptr);
let err = HeapFree(GetProcessHeap(), 0, header.0 as LPVOID);
- debug_assert!(err != 0);
+ debug_assert!(err != 0, "Failed to free heap memory: {}", GetLastError());
}
}
diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs
index 4986c9850d..6044bec2c5 100644
--- a/src/libarena/lib.rs
+++ b/src/libarena/lib.rs
@@ -46,6 +46,7 @@ use std::intrinsics;
use std::marker::{PhantomData, Send};
use std::mem;
use std::ptr;
+use std::slice;
use alloc::heap;
use alloc::raw_vec::RawVec;
@@ -133,7 +134,7 @@ impl TypedArena {
#[inline]
pub fn alloc(&self, object: T) -> &mut T {
if self.ptr == self.end {
- self.grow()
+ self.grow(1)
}
unsafe {
@@ -154,24 +155,58 @@ impl TypedArena {
}
}
+ /// Allocates a slice of objects that are copy into the `TypedArena`, returning a mutable
+ /// reference to it. Will panic if passed a zero-sized types.
+ ///
+ /// Panics:
+ /// - Zero-sized types
+ /// - Zero-length slices
+ #[inline]
+ pub fn alloc_slice(&self, slice: &[T]) -> &mut [T]
+ where T: Copy {
+ assert!(mem::size_of::() != 0);
+ assert!(slice.len() != 0);
+
+ let available_capacity_bytes = self.end.get() as usize - self.ptr.get() as usize;
+ let at_least_bytes = slice.len() * mem::size_of::();
+ if available_capacity_bytes < at_least_bytes {
+ self.grow(slice.len());
+ }
+
+ unsafe {
+ let start_ptr = self.ptr.get();
+ let arena_slice = slice::from_raw_parts_mut(start_ptr, slice.len());
+ self.ptr.set(start_ptr.offset(arena_slice.len() as isize));
+ arena_slice.copy_from_slice(slice);
+ arena_slice
+ }
+ }
+
/// Grows the arena.
#[inline(never)]
#[cold]
- fn grow(&self) {
+ fn grow(&self, n: usize) {
unsafe {
let mut chunks = self.chunks.borrow_mut();
- let (chunk, new_capacity);
+ let (chunk, mut new_capacity);
if let Some(last_chunk) = chunks.last_mut() {
- if last_chunk.storage.double_in_place() {
+ let used_bytes = self.ptr.get() as usize - last_chunk.start() as usize;
+ let currently_used_cap = used_bytes / mem::size_of::();
+ if last_chunk.storage.reserve_in_place(currently_used_cap, n) {
self.end.set(last_chunk.end());
return;
} else {
let prev_capacity = last_chunk.storage.cap();
- new_capacity = prev_capacity.checked_mul(2).unwrap();
+ loop {
+ new_capacity = prev_capacity.checked_mul(2).unwrap();
+ if new_capacity >= currently_used_cap + n {
+ break;
+ }
+ }
}
} else {
let elem_size = cmp::max(1, mem::size_of::());
- new_capacity = cmp::max(1, PAGE / elem_size);
+ new_capacity = cmp::max(n, PAGE / elem_size);
}
chunk = TypedArenaChunk::::new(new_capacity);
self.ptr.set(chunk.start());
@@ -302,9 +337,8 @@ mod tests {
let arena = Wrap(TypedArena::new());
- let result = arena.alloc_outer(|| {
- Outer { inner: arena.alloc_inner(|| Inner { value: 10 }) }
- });
+ let result =
+ arena.alloc_outer(|| Outer { inner: arena.alloc_inner(|| Inner { value: 10 }) });
assert_eq!(result.inner.value, 10);
}
diff --git a/src/libcollections/binary_heap.rs b/src/libcollections/binary_heap.rs
index 5f2401b236..b4be8a4321 100644
--- a/src/libcollections/binary_heap.rs
+++ b/src/libcollections/binary_heap.rs
@@ -1033,7 +1033,7 @@ pub struct Drain<'a, T: 'a> {
iter: vec::Drain<'a, T>,
}
-#[stable(feature = "rust1", since = "1.0.0")]
+#[stable(feature = "drain", since = "1.6.0")]
impl<'a, T: 'a> Iterator for Drain<'a, T> {
type Item = T;
@@ -1048,7 +1048,7 @@ impl<'a, T: 'a> Iterator for Drain<'a, T> {
}
}
-#[stable(feature = "rust1", since = "1.0.0")]
+#[stable(feature = "drain", since = "1.6.0")]
impl<'a, T: 'a> DoubleEndedIterator for Drain<'a, T> {
#[inline]
fn next_back(&mut self) -> Option {
@@ -1056,7 +1056,7 @@ impl<'a, T: 'a> DoubleEndedIterator for Drain<'a, T> {
}
}
-#[stable(feature = "rust1", since = "1.0.0")]
+#[stable(feature = "drain", since = "1.6.0")]
impl<'a, T: 'a> ExactSizeIterator for Drain<'a, T> {}
#[unstable(feature = "fused", issue = "35602")]
diff --git a/src/libcollections/borrow.rs b/src/libcollections/borrow.rs
index 700f88dc0f..37618b7600 100644
--- a/src/libcollections/borrow.rs
+++ b/src/libcollections/borrow.rs
@@ -14,9 +14,10 @@
use core::cmp::Ordering;
use core::hash::{Hash, Hasher};
-use core::ops::Deref;
+use core::ops::{Add, AddAssign, Deref};
use fmt;
+use string::String;
use self::Cow::*;
@@ -86,16 +87,29 @@ impl ToOwned for T where T: Clone {
/// ```
/// use std::borrow::Cow;
///
-/// # #[allow(dead_code)]
/// fn abs_all(input: &mut Cow<[i32]>) {
/// for i in 0..input.len() {
/// let v = input[i];
/// if v < 0 {
-/// // clones into a vector the first time (if not already owned)
+/// // Clones into a vector if not already owned.
/// input.to_mut()[i] = -v;
/// }
/// }
/// }
+///
+/// // No clone occurs because `input` doesn't need to be mutated.
+/// let slice = [0, 1, 2];
+/// let mut input = Cow::from(&slice[..]);
+/// abs_all(&mut input);
+///
+/// // Clone occurs because `input` needs to be mutated.
+/// let slice = [-1, 0, 1];
+/// let mut input = Cow::from(&slice[..]);
+/// abs_all(&mut input);
+///
+/// // No clone occurs because `input` is already owned.
+/// let mut input = Cow::from(vec![-1, 0, 1]);
+/// abs_all(&mut input);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub enum Cow<'a, B: ?Sized + 'a>
@@ -146,7 +160,10 @@ impl<'a, B: ?Sized> Cow<'a, B> where B: ToOwned {
match *self {
Borrowed(borrowed) => {
*self = Owned(borrowed.to_owned());
- self.to_mut()
+ match *self {
+ Borrowed(..) => unreachable!(),
+ Owned(ref mut owned) => owned,
+ }
}
Owned(ref mut owned) => owned,
}
@@ -270,3 +287,61 @@ impl<'a, T: ?Sized + ToOwned> AsRef for Cow<'a, T> {
self
}
}
+
+#[stable(feature = "cow_add", since = "1.14.0")]
+impl<'a> Add<&'a str> for Cow<'a, str> {
+ type Output = Cow<'a, str>;
+
+ #[inline]
+ fn add(mut self, rhs: &'a str) -> Self::Output {
+ self += rhs;
+ self
+ }
+}
+
+#[stable(feature = "cow_add", since = "1.14.0")]
+impl<'a> Add> for Cow<'a, str> {
+ type Output = Cow<'a, str>;
+
+ #[inline]
+ fn add(mut self, rhs: Cow<'a, str>) -> Self::Output {
+ self += rhs;
+ self
+ }
+}
+
+#[stable(feature = "cow_add", since = "1.14.0")]
+impl<'a> AddAssign<&'a str> for Cow<'a, str> {
+ fn add_assign(&mut self, rhs: &'a str) {
+ if self.is_empty() {
+ *self = Cow::Borrowed(rhs)
+ } else if rhs.is_empty() {
+ return;
+ } else {
+ if let Cow::Borrowed(lhs) = *self {
+ let mut s = String::with_capacity(lhs.len() + rhs.len());
+ s.push_str(lhs);
+ *self = Cow::Owned(s);
+ }
+ self.to_mut().push_str(rhs);
+ }
+ }
+}
+
+#[stable(feature = "cow_add", since = "1.14.0")]
+impl<'a> AddAssign> for Cow<'a, str> {
+ fn add_assign(&mut self, rhs: Cow<'a, str>) {
+ if self.is_empty() {
+ *self = rhs
+ } else if rhs.is_empty() {
+ return;
+ } else {
+ if let Cow::Borrowed(lhs) = *self {
+ let mut s = String::with_capacity(lhs.len() + rhs.len());
+ s.push_str(lhs);
+ *self = Cow::Owned(s);
+ }
+ self.to_mut().push_str(&rhs);
+ }
+ }
+}
diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs
index 36cb5a1fd9..788236c24d 100644
--- a/src/libcollections/btree/map.rs
+++ b/src/libcollections/btree/map.rs
@@ -136,6 +136,7 @@ pub struct BTreeMap {
length: usize,
}
+#[stable(feature = "btree_drop", since = "1.7.0")]
impl Drop for BTreeMap {
#[unsafe_destructor_blind_to_params]
fn drop(&mut self) {
@@ -146,6 +147,7 @@ impl Drop for BTreeMap {
}
}
+#[stable(feature = "rust1", since = "1.0.0")]
impl Clone for BTreeMap {
fn clone(&self) -> BTreeMap {
fn clone_subtree(node: node::NodeRef BTreeMap {
}
}
+#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K: 'a, V: 'a> IntoIterator for &'a BTreeMap {
type Item = (&'a K, &'a V);
type IntoIter = Iter<'a, K, V>;
@@ -1134,6 +1137,7 @@ impl<'a, K: 'a, V: 'a> IntoIterator for &'a BTreeMap {
}
}
+#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K: 'a, V: 'a> Iterator for Iter<'a, K, V> {
type Item = (&'a K, &'a V);
@@ -1154,6 +1158,7 @@ impl<'a, K: 'a, V: 'a> Iterator for Iter<'a, K, V> {
#[unstable(feature = "fused", issue = "35602")]
impl<'a, K, V> FusedIterator for Iter<'a, K, V> {}
+#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K: 'a, V: 'a> DoubleEndedIterator for Iter<'a, K, V> {
fn next_back(&mut self) -> Option<(&'a K, &'a V)> {
if self.length == 0 {
@@ -1165,12 +1170,14 @@ impl<'a, K: 'a, V: 'a> DoubleEndedIterator for Iter<'a, K, V> {
}
}
+#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K: 'a, V: 'a> ExactSizeIterator for Iter<'a, K, V> {
fn len(&self) -> usize {
self.length
}
}
+#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K, V> Clone for Iter<'a, K, V> {
fn clone(&self) -> Iter<'a, K, V> {
Iter {
@@ -1180,6 +1187,7 @@ impl<'a, K, V> Clone for Iter<'a, K, V> {
}
}
+#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K: 'a, V: 'a> IntoIterator for &'a mut BTreeMap {
type Item = (&'a K, &'a mut V);
type IntoIter = IterMut<'a, K, V>;
@@ -1189,6 +1197,7 @@ impl<'a, K: 'a, V: 'a> IntoIterator for &'a mut BTreeMap {
}
}
+#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K: 'a, V: 'a> Iterator for IterMut<'a, K, V> {
type Item = (&'a K, &'a mut V);
@@ -1206,6 +1215,7 @@ impl<'a, K: 'a, V: 'a> Iterator for IterMut<'a, K, V> {
}
}
+#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K: 'a, V: 'a> DoubleEndedIterator for IterMut<'a, K, V> {
fn next_back(&mut self) -> Option<(&'a K, &'a mut V)> {
if self.length == 0 {
@@ -1217,6 +1227,7 @@ impl<'a, K: 'a, V: 'a> DoubleEndedIterator for IterMut<'a, K, V> {
}
}
+#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, K: 'a, V: 'a> ExactSizeIterator for IterMut<'a, K, V> {
fn len(&self) -> usize {
self.length
@@ -1226,6 +1237,7 @@ impl<'a, K: 'a, V: 'a> ExactSizeIterator for IterMut<'a, K, V> {
#[unstable(feature = "fused", issue = "35602")]
impl<'a, K, V> FusedIterator for IterMut<'a, K, V> {}
+#[stable(feature = "rust1", since = "1.0.0")]
impl