]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #58802 - nnethercote:inline-record_layout, r=oli-obk
authorkennytm <kennytm@gmail.com>
Sat, 2 Mar 2019 06:55:15 +0000 (14:55 +0800)
committerkennytm <kennytm@gmail.com>
Sat, 2 Mar 2019 14:58:29 +0000 (22:58 +0800)
Ensure `record_layout_for_printing()` is inlined.

This reduces instruction counts for the `ctfe-stress-2` benchmark by
about 1%.

r? @oli-obk

604 files changed:
Cargo.lock
config.toml.example
src/bootstrap/bin/rustc.rs
src/bootstrap/bootstrap.py
src/bootstrap/config.rs
src/bootstrap/doc.rs
src/bootstrap/native.rs
src/ci/docker/dist-x86_64-netbsd/Dockerfile
src/doc/book
src/doc/edition-guide
src/doc/unstable-book/src/language-features/c-variadic.md [new file with mode: 0644]
src/doc/unstable-book/src/library-features/c-variadic.md [new file with mode: 0644]
src/libcore/benches/iter.rs
src/libcore/iter/adapters/mod.rs
src/libcore/mem.rs
src/libcore/num/mod.rs
src/libcore/num/wrapping.rs
src/libcore/str/mod.rs
src/librustc/Cargo.toml
src/librustc/dep_graph/dep_node.rs
src/librustc/hir/intravisit.rs
src/librustc/hir/lowering.rs
src/librustc/hir/map/collector.rs
src/librustc/hir/map/def_collector.rs
src/librustc/hir/map/mod.rs
src/librustc/hir/mod.rs
src/librustc/hir/print.rs
src/librustc/ich/impls_hir.rs
src/librustc/ich/impls_mir.rs
src/librustc/ich/impls_ty.rs
src/librustc/infer/combine.rs
src/librustc/infer/equate.rs
src/librustc/infer/error_reporting/mod.rs
src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs
src/librustc/infer/mod.rs
src/librustc/infer/opaque_types/mod.rs
src/librustc/infer/outlives/verify.rs
src/librustc/lint/context.rs
src/librustc/lint/mod.rs
src/librustc/middle/dead.rs
src/librustc/middle/exported_symbols.rs
src/librustc/middle/reachable.rs
src/librustc/middle/resolve_lifetime.rs
src/librustc/middle/stability.rs
src/librustc/mir/mod.rs
src/librustc/mir/tcx.rs
src/librustc/mir/visit.rs
src/librustc/session/config.rs
src/librustc/session/mod.rs
src/librustc/traits/auto_trait.rs
src/librustc/traits/codegen/mod.rs
src/librustc/traits/mod.rs
src/librustc/traits/object_safety.rs
src/librustc/traits/project.rs
src/librustc/traits/query/normalize.rs
src/librustc/traits/select.rs
src/librustc/traits/specialize/mod.rs
src/librustc/traits/util.rs
src/librustc/ty/adjustment.rs
src/librustc/ty/codec.rs
src/librustc/ty/context.rs
src/librustc/ty/flags.rs
src/librustc/ty/inhabitedness/mod.rs
src/librustc/ty/instance.rs
src/librustc/ty/mod.rs
src/librustc/ty/query/config.rs
src/librustc/ty/query/job.rs
src/librustc/ty/query/keys.rs
src/librustc/ty/query/mod.rs
src/librustc/ty/query/plumbing.rs
src/librustc/ty/relate.rs
src/librustc/ty/structural_impls.rs
src/librustc/ty/sty.rs
src/librustc/ty/subst.rs
src/librustc/ty/util.rs
src/librustc/ty/walk.rs
src/librustc/ty/wf.rs
src/librustc/util/ppaux.rs
src/librustc_codegen_llvm/abi.rs
src/librustc_codegen_llvm/back/link.rs
src/librustc_codegen_llvm/back/wasm.rs
src/librustc_codegen_llvm/debuginfo/mod.rs
src/librustc_codegen_llvm/debuginfo/type_names.rs
src/librustc_codegen_llvm/intrinsic.rs
src/librustc_codegen_llvm/mono_item.rs
src/librustc_codegen_llvm/va_arg.rs
src/librustc_codegen_ssa/back/symbol_export.rs
src/librustc_codegen_ssa/base.rs
src/librustc_codegen_ssa/callee.rs
src/librustc_codegen_ssa/lib.rs
src/librustc_codegen_ssa/mir/analyze.rs
src/librustc_codegen_ssa/mir/block.rs
src/librustc_codegen_ssa/mir/mod.rs
src/librustc_codegen_ssa/mir/operand.rs
src/librustc_codegen_ssa/mir/place.rs
src/librustc_codegen_ssa/mir/rvalue.rs
src/librustc_codegen_ssa/mir/statement.rs
src/librustc_codegen_ssa/traits/intrinsic.rs
src/librustc_codegen_utils/symbol_names.rs
src/librustc_codegen_utils/symbol_names_test.rs
src/librustc_data_structures/Cargo.toml
src/librustc_data_structures/jobserver.rs [new file with mode: 0644]
src/librustc_data_structures/lib.rs
src/librustc_driver/Cargo.toml
src/librustc_driver/driver.rs
src/librustc_driver/lib.rs
src/librustc_driver/pretty.rs
src/librustc_driver/proc_macro_decls.rs [deleted file]
src/librustc_driver/profile/mod.rs [deleted file]
src/librustc_driver/profile/trace.rs [deleted file]
src/librustc_driver/test.rs
src/librustc_incremental/assert_dep_graph.rs
src/librustc_incremental/persist/dirty_clean.rs
src/librustc_interface/Cargo.toml [new file with mode: 0644]
src/librustc_interface/lib.rs [new file with mode: 0644]
src/librustc_interface/passes.rs [new file with mode: 0644]
src/librustc_interface/proc_macro_decls.rs [new file with mode: 0644]
src/librustc_interface/profile/mod.rs [new file with mode: 0644]
src/librustc_interface/profile/trace.rs [new file with mode: 0644]
src/librustc_interface/util.rs [new file with mode: 0644]
src/librustc_lint/builtin.rs
src/librustc_lint/types.rs
src/librustc_metadata/encoder.rs
src/librustc_mir/borrow_check/borrow_set.rs
src/librustc_mir/borrow_check/error_reporting.rs
src/librustc_mir/borrow_check/mod.rs
src/librustc_mir/borrow_check/move_errors.rs
src/librustc_mir/borrow_check/mutability_errors.rs
src/librustc_mir/borrow_check/nll/constraint_generation.rs
src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs
src/librustc_mir/borrow_check/nll/invalidation.rs
src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs
src/librustc_mir/borrow_check/nll/region_infer/mod.rs
src/librustc_mir/borrow_check/nll/renumber.rs
src/librustc_mir/borrow_check/nll/type_check/mod.rs
src/librustc_mir/borrow_check/nll/universal_regions.rs
src/librustc_mir/borrow_check/path_utils.rs
src/librustc_mir/borrow_check/place_ext.rs
src/librustc_mir/borrow_check/places_conflict.rs
src/librustc_mir/borrow_check/prefixes.rs
src/librustc_mir/borrow_check/used_muts.rs
src/librustc_mir/build/expr/as_operand.rs
src/librustc_mir/build/expr/as_place.rs
src/librustc_mir/build/expr/as_rvalue.rs
src/librustc_mir/build/expr/as_temp.rs
src/librustc_mir/build/expr/into.rs
src/librustc_mir/build/expr/stmt.rs
src/librustc_mir/build/matches/mod.rs
src/librustc_mir/build/misc.rs
src/librustc_mir/build/mod.rs
src/librustc_mir/build/scope.rs
src/librustc_mir/dataflow/drop_flag_effects.rs
src/librustc_mir/dataflow/impls/borrowed_locals.rs
src/librustc_mir/dataflow/impls/borrows.rs
src/librustc_mir/dataflow/impls/mod.rs
src/librustc_mir/dataflow/move_paths/builder.rs
src/librustc_mir/dataflow/move_paths/mod.rs
src/librustc_mir/hair/cx/expr.rs
src/librustc_mir/hair/cx/mod.rs
src/librustc_mir/hair/mod.rs
src/librustc_mir/hair/pattern/_match.rs
src/librustc_mir/hair/pattern/check_match.rs
src/librustc_mir/hair/pattern/mod.rs
src/librustc_mir/interpret/eval_context.rs
src/librustc_mir/interpret/operand.rs
src/librustc_mir/interpret/place.rs
src/librustc_mir/interpret/terminator.rs
src/librustc_mir/lints.rs
src/librustc_mir/monomorphize/collector.rs
src/librustc_mir/monomorphize/item.rs
src/librustc_mir/shim.rs
src/librustc_mir/transform/add_moves_for_packed_drops.rs
src/librustc_mir/transform/add_retag.rs
src/librustc_mir/transform/check_unsafety.rs
src/librustc_mir/transform/const_prop.rs
src/librustc_mir/transform/copy_prop.rs
src/librustc_mir/transform/elaborate_drops.rs
src/librustc_mir/transform/erase_regions.rs
src/librustc_mir/transform/generator.rs
src/librustc_mir/transform/inline.rs
src/librustc_mir/transform/instcombine.rs
src/librustc_mir/transform/lower_128bit.rs
src/librustc_mir/transform/promote_consts.rs
src/librustc_mir/transform/qualify_consts.rs
src/librustc_mir/transform/qualify_min_const_fn.rs
src/librustc_mir/transform/remove_noop_landing_pads.rs
src/librustc_mir/transform/rustc_peek.rs
src/librustc_mir/transform/uniform_array_move_out.rs
src/librustc_mir/util/elaborate_drops.rs
src/librustc_mir/util/graphviz.rs
src/librustc_mir/util/pretty.rs
src/librustc_passes/ast_validation.rs
src/librustc_passes/diagnostics.rs
src/librustc_passes/rvalue_promotion.rs
src/librustc_privacy/lib.rs
src/librustc_resolve/lib.rs
src/librustc_save_analysis/sig.rs
src/librustc_target/abi/call/arm.rs
src/librustc_target/abi/call/mod.rs
src/librustc_target/abi/call/x86.rs
src/librustc_traits/chalk_context/program_clauses.rs
src/librustc_traits/dropck_outlives.rs
src/librustc_traits/generic_types.rs
src/librustc_traits/lowering/mod.rs
src/librustc_typeck/astconv.rs
src/librustc_typeck/check/_match.rs
src/librustc_typeck/check/callee.rs
src/librustc_typeck/check/cast.rs
src/librustc_typeck/check/closure.rs
src/librustc_typeck/check/coercion.rs
src/librustc_typeck/check/compare_method.rs
src/librustc_typeck/check/dropck.rs
src/librustc_typeck/check/intrinsic.rs
src/librustc_typeck/check/method/confirm.rs
src/librustc_typeck/check/method/mod.rs
src/librustc_typeck/check/method/probe.rs
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/regionck.rs
src/librustc_typeck/check/wfcheck.rs
src/librustc_typeck/check/writeback.rs
src/librustc_typeck/check_unused.rs
src/librustc_typeck/coherence/inherent_impls_overlap.rs
src/librustc_typeck/collect.rs
src/librustc_typeck/lib.rs
src/librustc_typeck/variance/constraints.rs
src/librustc_typeck/variance/solve.rs
src/librustc_typeck/variance/terms.rs
src/librustdoc/clean/auto_trait.rs
src/librustdoc/clean/blanket_impl.rs
src/librustdoc/clean/mod.rs
src/librustdoc/config.rs
src/librustdoc/core.rs
src/librustdoc/html/format.rs
src/librustdoc/lib.rs
src/librustdoc/passes/check_code_block_syntax.rs
src/librustdoc/passes/collapse_docs.rs
src/librustdoc/passes/collect_intra_doc_links.rs
src/librustdoc/passes/collect_trait_impls.rs
src/librustdoc/passes/mod.rs
src/librustdoc/passes/private_items_doc_tests.rs
src/librustdoc/passes/propagate_doc_cfg.rs
src/librustdoc/passes/strip_hidden.rs
src/librustdoc/passes/strip_priv_imports.rs
src/librustdoc/passes/strip_private.rs
src/librustdoc/passes/unindent_comments.rs
src/librustdoc/test.rs
src/libstd/Cargo.toml
src/libstd/alloc.rs
src/libstd/build.rs
src/libstd/collections/hash/bench.rs
src/libstd/collections/hash/map.rs
src/libstd/collections/hash/set.rs
src/libstd/collections/hash/table.rs
src/libstd/collections/mod.rs
src/libstd/env.rs
src/libstd/error.rs
src/libstd/f32.rs
src/libstd/f64.rs
src/libstd/ffi/c_str.rs
src/libstd/ffi/os_str.rs
src/libstd/fs.rs
src/libstd/io/buffered.rs
src/libstd/io/cursor.rs
src/libstd/io/error.rs
src/libstd/io/impls.rs
src/libstd/io/lazy.rs
src/libstd/io/mod.rs
src/libstd/io/stdio.rs
src/libstd/io/util.rs
src/libstd/lib.rs
src/libstd/macros.rs
src/libstd/memchr.rs
src/libstd/net/addr.rs
src/libstd/net/ip.rs
src/libstd/net/mod.rs
src/libstd/net/parser.rs
src/libstd/net/tcp.rs
src/libstd/net/test.rs
src/libstd/net/udp.rs
src/libstd/num.rs
src/libstd/os/android/fs.rs
src/libstd/os/android/raw.rs
src/libstd/os/bitrig/fs.rs
src/libstd/os/bitrig/raw.rs
src/libstd/os/dragonfly/fs.rs
src/libstd/os/dragonfly/raw.rs
src/libstd/os/emscripten/fs.rs
src/libstd/os/emscripten/raw.rs
src/libstd/os/fortanix_sgx/mod.rs
src/libstd/os/freebsd/fs.rs
src/libstd/os/freebsd/raw.rs
src/libstd/os/fuchsia/fs.rs
src/libstd/os/fuchsia/raw.rs
src/libstd/os/haiku/fs.rs
src/libstd/os/haiku/raw.rs
src/libstd/os/hermit/fs.rs
src/libstd/os/ios/fs.rs
src/libstd/os/ios/raw.rs
src/libstd/os/linux/fs.rs
src/libstd/os/linux/raw.rs
src/libstd/os/macos/fs.rs
src/libstd/os/macos/raw.rs
src/libstd/os/mod.rs
src/libstd/os/netbsd/fs.rs
src/libstd/os/netbsd/raw.rs
src/libstd/os/openbsd/fs.rs
src/libstd/os/openbsd/raw.rs
src/libstd/os/raw/mod.rs
src/libstd/os/solaris/fs.rs
src/libstd/os/solaris/raw.rs
src/libstd/panic.rs
src/libstd/panicking.rs
src/libstd/path.rs
src/libstd/prelude/v1.rs
src/libstd/process.rs
src/libstd/rt.rs
src/libstd/sync/barrier.rs
src/libstd/sync/condvar.rs
src/libstd/sync/mod.rs
src/libstd/sync/mpsc/blocking.rs
src/libstd/sync/mpsc/cache_aligned.rs
src/libstd/sync/mpsc/mod.rs
src/libstd/sync/mpsc/mpsc_queue.rs
src/libstd/sync/mpsc/oneshot.rs
src/libstd/sync/mpsc/select.rs
src/libstd/sync/mpsc/select_tests.rs
src/libstd/sync/mpsc/shared.rs
src/libstd/sync/mpsc/spsc_queue.rs
src/libstd/sync/mpsc/stream.rs
src/libstd/sync/mpsc/sync.rs
src/libstd/sync/mutex.rs
src/libstd/sync/once.rs
src/libstd/sync/rwlock.rs
src/libstd/sys/cloudabi/abi/bitflags.rs
src/libstd/sys/cloudabi/abi/cloudabi.rs
src/libstd/sys/cloudabi/args.rs
src/libstd/sys/cloudabi/backtrace.rs
src/libstd/sys/cloudabi/condvar.rs
src/libstd/sys/cloudabi/mod.rs
src/libstd/sys/cloudabi/mutex.rs
src/libstd/sys/cloudabi/os.rs
src/libstd/sys/cloudabi/rwlock.rs
src/libstd/sys/cloudabi/shims/args.rs
src/libstd/sys/cloudabi/shims/fs.rs
src/libstd/sys/cloudabi/shims/mod.rs
src/libstd/sys/cloudabi/shims/net.rs
src/libstd/sys/cloudabi/shims/os.rs
src/libstd/sys/cloudabi/shims/pipe.rs
src/libstd/sys/cloudabi/shims/process.rs
src/libstd/sys/cloudabi/stdio.rs
src/libstd/sys/cloudabi/thread.rs
src/libstd/sys/cloudabi/time.rs
src/libstd/sys/mod.rs
src/libstd/sys/redox/args.rs
src/libstd/sys/redox/backtrace/mod.rs
src/libstd/sys/redox/backtrace/printing.rs
src/libstd/sys/redox/backtrace/tracing.rs
src/libstd/sys/redox/condvar.rs
src/libstd/sys/redox/ext/ffi.rs
src/libstd/sys/redox/ext/fs.rs
src/libstd/sys/redox/ext/io.rs
src/libstd/sys/redox/ext/net.rs
src/libstd/sys/redox/ext/process.rs
src/libstd/sys/redox/ext/thread.rs
src/libstd/sys/redox/fast_thread_local.rs
src/libstd/sys/redox/fd.rs
src/libstd/sys/redox/fs.rs
src/libstd/sys/redox/mod.rs
src/libstd/sys/redox/mutex.rs
src/libstd/sys/redox/net/dns/answer.rs
src/libstd/sys/redox/net/dns/mod.rs
src/libstd/sys/redox/net/dns/query.rs
src/libstd/sys/redox/net/mod.rs
src/libstd/sys/redox/net/tcp.rs
src/libstd/sys/redox/net/udp.rs
src/libstd/sys/redox/os.rs
src/libstd/sys/redox/os_str.rs
src/libstd/sys/redox/path.rs
src/libstd/sys/redox/pipe.rs
src/libstd/sys/redox/process.rs
src/libstd/sys/redox/stdio.rs
src/libstd/sys/redox/thread.rs
src/libstd/sys/redox/thread_local.rs
src/libstd/sys/redox/time.rs
src/libstd/sys/sgx/abi/mod.rs
src/libstd/sys/sgx/abi/panic.rs
src/libstd/sys/sgx/abi/reloc.rs
src/libstd/sys/sgx/abi/tls.rs
src/libstd/sys/sgx/abi/usercalls/alloc.rs
src/libstd/sys/sgx/abi/usercalls/mod.rs
src/libstd/sys/sgx/abi/usercalls/raw.rs
src/libstd/sys/sgx/alloc.rs
src/libstd/sys/sgx/args.rs
src/libstd/sys/sgx/backtrace.rs
src/libstd/sys/sgx/condvar.rs
src/libstd/sys/sgx/ext/arch.rs
src/libstd/sys/sgx/ext/ffi.rs
src/libstd/sys/sgx/ext/io.rs
src/libstd/sys/sgx/fd.rs
src/libstd/sys/sgx/fs.rs
src/libstd/sys/sgx/mod.rs
src/libstd/sys/sgx/net.rs
src/libstd/sys/sgx/os.rs
src/libstd/sys/sgx/os_str.rs
src/libstd/sys/sgx/path.rs
src/libstd/sys/sgx/pipe.rs
src/libstd/sys/sgx/process.rs
src/libstd/sys/sgx/rwlock.rs
src/libstd/sys/sgx/stdio.rs
src/libstd/sys/sgx/thread.rs
src/libstd/sys/sgx/time.rs
src/libstd/sys/sgx/waitqueue.rs
src/libstd/sys/unix/alloc.rs
src/libstd/sys/unix/android.rs
src/libstd/sys/unix/args.rs
src/libstd/sys/unix/backtrace/mod.rs
src/libstd/sys/unix/backtrace/printing/dladdr.rs
src/libstd/sys/unix/backtrace/printing/mod.rs
src/libstd/sys/unix/backtrace/tracing/backtrace_fn.rs
src/libstd/sys/unix/backtrace/tracing/gcc_s.rs
src/libstd/sys/unix/condvar.rs
src/libstd/sys/unix/ext/ffi.rs
src/libstd/sys/unix/ext/fs.rs
src/libstd/sys/unix/ext/io.rs
src/libstd/sys/unix/ext/net.rs
src/libstd/sys/unix/ext/process.rs
src/libstd/sys/unix/ext/raw.rs
src/libstd/sys/unix/ext/thread.rs
src/libstd/sys/unix/fast_thread_local.rs
src/libstd/sys/unix/fd.rs
src/libstd/sys/unix/fs.rs
src/libstd/sys/unix/io.rs
src/libstd/sys/unix/l4re.rs
src/libstd/sys/unix/memchr.rs
src/libstd/sys/unix/mod.rs
src/libstd/sys/unix/mutex.rs
src/libstd/sys/unix/net.rs
src/libstd/sys/unix/os.rs
src/libstd/sys/unix/os_str.rs
src/libstd/sys/unix/path.rs
src/libstd/sys/unix/pipe.rs
src/libstd/sys/unix/process/process_common.rs
src/libstd/sys/unix/process/process_fuchsia.rs
src/libstd/sys/unix/process/process_unix.rs
src/libstd/sys/unix/process/zircon.rs
src/libstd/sys/unix/rand.rs
src/libstd/sys/unix/rwlock.rs
src/libstd/sys/unix/stack_overflow.rs
src/libstd/sys/unix/stdio.rs
src/libstd/sys/unix/thread.rs
src/libstd/sys/unix/thread_local.rs
src/libstd/sys/unix/time.rs
src/libstd/sys/unix/weak.rs
src/libstd/sys/wasm/alloc.rs
src/libstd/sys/wasm/args.rs
src/libstd/sys/wasm/backtrace.rs
src/libstd/sys/wasm/condvar.rs
src/libstd/sys/wasm/condvar_atomics.rs
src/libstd/sys/wasm/fs.rs
src/libstd/sys/wasm/mod.rs
src/libstd/sys/wasm/mutex.rs
src/libstd/sys/wasm/mutex_atomics.rs
src/libstd/sys/wasm/net.rs
src/libstd/sys/wasm/os.rs
src/libstd/sys/wasm/os_str.rs
src/libstd/sys/wasm/path.rs
src/libstd/sys/wasm/pipe.rs
src/libstd/sys/wasm/process.rs
src/libstd/sys/wasm/rwlock.rs
src/libstd/sys/wasm/rwlock_atomics.rs
src/libstd/sys/wasm/stdio.rs
src/libstd/sys/wasm/thread.rs
src/libstd/sys/wasm/thread_local.rs
src/libstd/sys/wasm/thread_local_atomics.rs
src/libstd/sys/wasm/time.rs
src/libstd/sys/windows/alloc.rs
src/libstd/sys/windows/args.rs
src/libstd/sys/windows/backtrace/backtrace_gnu.rs
src/libstd/sys/windows/backtrace/mod.rs
src/libstd/sys/windows/backtrace/printing/mod.rs
src/libstd/sys/windows/backtrace/printing/msvc.rs
src/libstd/sys/windows/c.rs
src/libstd/sys/windows/compat.rs
src/libstd/sys/windows/condvar.rs
src/libstd/sys/windows/dynamic_lib.rs
src/libstd/sys/windows/ext/ffi.rs
src/libstd/sys/windows/ext/fs.rs
src/libstd/sys/windows/ext/io.rs
src/libstd/sys/windows/ext/process.rs
src/libstd/sys/windows/ext/raw.rs
src/libstd/sys/windows/ext/thread.rs
src/libstd/sys/windows/fast_thread_local.rs
src/libstd/sys/windows/fs.rs
src/libstd/sys/windows/handle.rs
src/libstd/sys/windows/io.rs
src/libstd/sys/windows/mod.rs
src/libstd/sys/windows/mutex.rs
src/libstd/sys/windows/net.rs
src/libstd/sys/windows/os.rs
src/libstd/sys/windows/os_str.rs
src/libstd/sys/windows/path.rs
src/libstd/sys/windows/pipe.rs
src/libstd/sys/windows/process.rs
src/libstd/sys/windows/rand.rs
src/libstd/sys/windows/rwlock.rs
src/libstd/sys/windows/stack_overflow.rs
src/libstd/sys/windows/stdio.rs
src/libstd/sys/windows/thread.rs
src/libstd/sys/windows/thread_local.rs
src/libstd/sys/windows/time.rs
src/libstd/sys_common/alloc.rs
src/libstd/sys_common/at_exit_imp.rs
src/libstd/sys_common/backtrace.rs
src/libstd/sys_common/bytestring.rs
src/libstd/sys_common/condvar.rs
src/libstd/sys_common/gnu/libbacktrace.rs
src/libstd/sys_common/io.rs
src/libstd/sys_common/mod.rs
src/libstd/sys_common/mutex.rs
src/libstd/sys_common/net.rs
src/libstd/sys_common/poison.rs
src/libstd/sys_common/process.rs
src/libstd/sys_common/remutex.rs
src/libstd/sys_common/rwlock.rs
src/libstd/sys_common/thread.rs
src/libstd/sys_common/thread_info.rs
src/libstd/sys_common/thread_local.rs
src/libstd/sys_common/util.rs
src/libstd/sys_common/wtf8.rs
src/libstd/tests/env.rs
src/libstd/thread/local.rs
src/libstd/thread/mod.rs
src/libstd/time.rs
src/libsyntax/Cargo.toml
src/libsyntax/ast.rs
src/libsyntax/ext/build.rs
src/libsyntax/ext/tt/quoted.rs
src/libsyntax/feature_gate.rs
src/libsyntax/mut_visit.rs
src/libsyntax/parse/parser.rs
src/libsyntax/print/pprust.rs
src/libsyntax/visit.rs
src/libsyntax_ext/test.rs
src/libsyntax_pos/Cargo.toml
src/libtest/lib.rs
src/llvm-project
src/test/codegen/c-variadic.rs [new file with mode: 0644]
src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/checkrust.rs
src/test/run-make-fulldeps/c-link-to-rust-va-list-fn/test.c
src/test/run-make-fulldeps/issue-19371/foo.rs
src/test/run-pass-fulldeps/pprust-expr-roundtrip.rs
src/test/run-pass/issues/issue-58212.rs [new file with mode: 0644]
src/test/rustdoc-ui/failed-doctest-output.stdout
src/test/rustdoc-ui/intra-links-warning.stderr
src/test/rustdoc-ui/issue-58473-2.rs [new file with mode: 0644]
src/test/rustdoc-ui/issue-58473.rs [new file with mode: 0644]
src/test/rustdoc/variadic.rs
src/test/ui-fulldeps/auxiliary/lint_tool_test.rs
src/test/ui/c-variadic/variadic-ffi-1.rs [new file with mode: 0644]
src/test/ui/c-variadic/variadic-ffi-1.stderr [new file with mode: 0644]
src/test/ui/c-variadic/variadic-ffi-2.rs [new file with mode: 0644]
src/test/ui/c-variadic/variadic-ffi-2.stderr [new file with mode: 0644]
src/test/ui/c-variadic/variadic-ffi-3.rs [new file with mode: 0644]
src/test/ui/c-variadic/variadic-ffi-3.stderr [new file with mode: 0644]
src/test/ui/c-variadic/variadic-ffi-4.rs [new file with mode: 0644]
src/test/ui/c-variadic/variadic-ffi-4.stderr [new file with mode: 0644]
src/test/ui/c-variadic/variadic-ffi-5.rs [new file with mode: 0644]
src/test/ui/c-variadic/variadic-ffi-5.stderr [new file with mode: 0644]
src/test/ui/c-variadic/variadic-ffi-6.rs [new file with mode: 0644]
src/test/ui/c-variadic/variadic-ffi-6.stderr [new file with mode: 0644]
src/test/ui/editions/edition-deny-async-fns-2015.rs [new file with mode: 0644]
src/test/ui/editions/edition-deny-async-fns-2015.stderr [new file with mode: 0644]
src/test/ui/error-codes/E0045.stderr
src/test/ui/error-codes/E0617.rs
src/test/ui/error-codes/E0617.stderr
src/test/ui/feature-gate/feature-gate-c_variadic.rs [new file with mode: 0644]
src/test/ui/feature-gate/feature-gate-c_variadic.stderr [new file with mode: 0644]
src/test/ui/feature-gates/feature-gate-async-await-2015-edition.rs
src/test/ui/feature-gates/feature-gate-async-await-2015-edition.stderr
src/test/ui/feature-gates/feature-gate-unwind-attributes.stderr
src/test/ui/hygiene/no_implicit_prelude.rs
src/test/ui/hygiene/no_implicit_prelude.stderr
src/test/ui/impl-trait/recursive-async-impl-trait-type.rs [new file with mode: 0644]
src/test/ui/impl-trait/recursive-async-impl-trait-type.stderr [new file with mode: 0644]
src/test/ui/impl-trait/recursive-impl-trait-type.rs
src/test/ui/impl-trait/recursive-impl-trait-type.stderr
src/test/ui/invalid/invalid-variadic-function.rs
src/test/ui/invalid/invalid-variadic-function.stderr
src/test/ui/issues/issue-23302-3.stderr
src/test/ui/macros/macro-at-most-once-rep-2015-ques-rep.stderr
src/test/ui/parser/recover-enum2.stderr
src/test/ui/parser/variadic-ffi-3.rs
src/test/ui/parser/variadic-ffi-3.stderr
src/test/ui/parser/variadic-ffi-4.rs
src/test/ui/parser/variadic-ffi-4.stderr
src/test/ui/tag-that-dare-not-speak-its-name.rs
src/test/ui/tag-that-dare-not-speak-its-name.stderr
src/test/ui/variadic/variadic-ffi-2.rs [deleted file]
src/test/ui/variadic/variadic-ffi-2.stderr [deleted file]
src/test/ui/variadic/variadic-ffi-3.rs [deleted file]
src/test/ui/variadic/variadic-ffi-3.stderr [deleted file]
src/test/ui/variadic/variadic-ffi.rs [deleted file]
src/test/ui/variadic/variadic-ffi.stderr [deleted file]
src/tools/tidy/src/unstable_book.rs

index 2b17a6acbaa691f7e354fc51ed8e708a9eb59d33..4fe81951170489a36b22273c4f4cbecd33a5dd60 100644 (file)
@@ -744,7 +744,7 @@ dependencies = [
 
 [[package]]
 name = "dlmalloc"
-version = "0.1.2"
+version = "0.1.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "compiler_builtins 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1399,7 +1399,7 @@ dependencies = [
  "serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)",
  "string_cache 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "string_cache_codegen 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "string_cache_codegen 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "tendril 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -1936,14 +1936,6 @@ dependencies = [
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
-[[package]]
-name = "proc-macro2"
-version = "0.3.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
 [[package]]
 name = "proc-macro2"
 version = "0.4.24"
@@ -2015,14 +2007,6 @@ name = "quote"
 version = "0.3.15"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
-[[package]]
-name = "quote"
-version = "0.5.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
 [[package]]
 name = "quote"
 version = "0.6.10"
@@ -2092,7 +2076,7 @@ name = "rand_chacha"
 version = "0.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -2114,7 +2098,7 @@ name = "rand_hc"
 version = "0.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -2139,7 +2123,7 @@ name = "rand_xorshift"
 version = "0.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -2374,14 +2358,14 @@ dependencies = [
  "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "polonius-engine 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-rayon 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-rayon-core 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-rayon 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-rayon-core 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc_apfloat 0.0.0",
  "rustc_data_structures 0.0.0",
  "rustc_errors 0.0.0",
  "rustc_fs_util 0.0.0",
  "rustc_target 0.0.0",
- "scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "serialize 0.0.0",
  "smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
  "syntax 0.0.0",
@@ -2425,8 +2409,8 @@ dependencies = [
  "rustc-ap-rustc_cratesio_shim 373.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-ap-serialize 373.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-rayon 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-rayon-core 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-rayon 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-rayon-core 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
  "stable_deref_trait 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
@@ -2524,23 +2508,23 @@ dependencies = [
 
 [[package]]
 name = "rustc-rayon"
-version = "0.1.1"
+version = "0.1.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
+ "crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-rayon-core 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-rayon-core 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "rustc-rayon-core"
-version = "0.1.1"
+version = "0.1.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
  "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -2688,11 +2672,13 @@ dependencies = [
  "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "ena 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "graphviz 0.0.0",
+ "jobserver 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-rayon 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-rayon-core 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-rayon 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-rayon-core 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc_cratesio_shim 0.0.0",
  "serialize 0.0.0",
  "smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2708,13 +2694,14 @@ dependencies = [
  "graphviz 0.0.0",
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc 0.0.0",
- "rustc-rayon 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-rayon 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc_allocator 0.0.0",
  "rustc_borrowck 0.0.0",
  "rustc_codegen_utils 0.0.0",
  "rustc_data_structures 0.0.0",
  "rustc_errors 0.0.0",
  "rustc_incremental 0.0.0",
+ "rustc_interface 0.0.0",
  "rustc_lint 0.0.0",
  "rustc_metadata 0.0.0",
  "rustc_mir 0.0.0",
@@ -2726,7 +2713,7 @@ dependencies = [
  "rustc_target 0.0.0",
  "rustc_traits 0.0.0",
  "rustc_typeck 0.0.0",
- "scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "serialize 0.0.0",
  "smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
  "syntax 0.0.0",
@@ -2767,6 +2754,36 @@ dependencies = [
  "syntax_pos 0.0.0",
 ]
 
+[[package]]
+name = "rustc_interface"
+version = "0.0.0"
+dependencies = [
+ "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc 0.0.0",
+ "rustc-rayon 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc_allocator 0.0.0",
+ "rustc_borrowck 0.0.0",
+ "rustc_codegen_utils 0.0.0",
+ "rustc_data_structures 0.0.0",
+ "rustc_errors 0.0.0",
+ "rustc_incremental 0.0.0",
+ "rustc_lint 0.0.0",
+ "rustc_metadata 0.0.0",
+ "rustc_mir 0.0.0",
+ "rustc_passes 0.0.0",
+ "rustc_plugin 0.0.0",
+ "rustc_privacy 0.0.0",
+ "rustc_resolve 0.0.0",
+ "rustc_traits 0.0.0",
+ "rustc_typeck 0.0.0",
+ "scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serialize 0.0.0",
+ "smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syntax 0.0.0",
+ "syntax_ext 0.0.0",
+ "syntax_pos 0.0.0",
+]
+
 [[package]]
 name = "rustc_lint"
 version = "0.0.0"
@@ -3090,6 +3107,11 @@ name = "scoped-tls"
 version = "0.1.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
+[[package]]
+name = "scoped-tls"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
 [[package]]
 name = "scoped_threadpool"
 version = "0.1.9"
@@ -3230,7 +3252,7 @@ dependencies = [
  "cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
  "compiler_builtins 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "core 0.0.0",
- "dlmalloc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "dlmalloc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "fortanix-sgx-abi 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.46 (registry+https://github.com/rust-lang/crates.io-index)",
  "panic_abort 0.0.0",
@@ -3255,19 +3277,19 @@ dependencies = [
  "phf_shared 0.7.22 (registry+https://github.com/rust-lang/crates.io-index)",
  "precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)",
- "string_cache_codegen 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "string_cache_codegen 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "string_cache_shared 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "string_cache_codegen"
-version = "0.4.1"
+version = "0.4.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "phf_generator 0.7.22 (registry+https://github.com/rust-lang/crates.io-index)",
  "phf_shared 0.7.22 (registry+https://github.com/rust-lang/crates.io-index)",
- "proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
- "quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)",
+ "quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
  "string_cache_shared 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -3345,7 +3367,7 @@ dependencies = [
  "rustc_data_structures 0.0.0",
  "rustc_errors 0.0.0",
  "rustc_target 0.0.0",
- "scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "serialize 0.0.0",
  "smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
  "syntax_pos 0.0.0",
@@ -3372,7 +3394,7 @@ dependencies = [
  "arena 0.0.0",
  "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "rustc_data_structures 0.0.0",
- "scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "serialize 0.0.0",
  "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
@@ -4000,7 +4022,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum digest 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "03b072242a8cbaf9c145665af9d250c59af3b958f83ed6824e13533cf76d5b90"
 "checksum directories 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "72d337a64190607d4fcca2cb78982c5dd57f4916e19696b48a575fa746b6cb0f"
 "checksum dirs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "88972de891f6118092b643d85a0b28e0678e0f948d7f879aa32f2d5aafe97d2a"
-"checksum dlmalloc 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d56ad71b31043818d0ee10a7fb9664882f8e45849c81647585e6a3124f185517"
+"checksum dlmalloc 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f283302e035e61c23f2b86b3093e8c6273a4c3125742d6087e96ade001ca5e63"
 "checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0"
 "checksum elasticlunr-rs 2.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a99a310cd1f9770e7bf8e48810c7bcbb0e078c8fb23a8c7bcf0da4c2bf61a455"
 "checksum ena 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f56c93cc076508c549d9bb747f79aa9b4eb098be7b8cad8830c3137ef52d1e00"
@@ -4124,7 +4146,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
 "checksum pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a029430f0d744bc3d15dd474d591bed2402b645d024583082b9f63bb936dac6"
 "checksum pretty_env_logger 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df8b3f4e0475def7d9c2e5de8e5a1306949849761e107b360d03e98eafaffd61"
-"checksum proc-macro2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1b06e2f335f48d24442b35a19df506a835fb3547bc3c06ef27340da9acf5cae7"
 "checksum proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)" = "77619697826f31a02ae974457af0b29b723e5619e113e9397b8b82c6bd253f09"
 "checksum proptest 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)" = "926d0604475349f463fe44130aae73f2294b5309ab2ca0310b998bd334ef191f"
 "checksum pulldown-cmark 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d6fdf85cda6cadfae5428a54661d431330b312bc767ddbc57adbedc24da66e32"
@@ -4132,7 +4153,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
 "checksum quine-mc_cluskey 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "07589615d719a60c8dd8a4622e7946465dfef20d1a428f969e3443e7386d5f45"
 "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
-"checksum quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9949cfe66888ffe1d53e6ec9d9f3b70714083854be20fd5e271b232a017401e8"
 "checksum quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "53fa22a1994bd0f9372d7a816207d8a2677ad0325b073f5c5332760f0fb62b5c"
 "checksum racer 2.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "d634483bed41bb116122b84ffe0ef8740345c2ceb2784ce86c33499700eb13a7"
 "checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd"
@@ -4172,8 +4192,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum rustc-ap-syntax_pos 373.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8e4f88a1213562373cee9de5a1d77bbf16dd706030304af041c9733492fcc952"
 "checksum rustc-demangle 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "82ae957aa1b3055d8e086486723c0ccd3d7b8fa190ae8fa2e35543b6171c810e"
 "checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8"
-"checksum rustc-rayon 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c6d5a683c6ba4ed37959097e88d71c9e8e26659a3cb5be8b389078e7ad45306"
-"checksum rustc-rayon-core 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "40f06724db71e18d68b3b946fdf890ca8c921d9edccc1404fdfdb537b0d12649"
+"checksum rustc-rayon 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8d98c51d9cbbe810c8b6693236d3412d8cd60513ff27a3e1b6af483dca0af544"
+"checksum rustc-rayon-core 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "526e7b6d2707a5b9bec3927d424ad70fa3cfc68e0ac1b75e46cdbbc95adc5108"
 "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda"
 "checksum rustc_tools_util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c5a95edfa0c893236ae4778bb7c4752760e4c0d245e19b5eff33c5aa5eb9dc"
 "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
@@ -4183,6 +4203,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267"
 "checksum schannel 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "0e1a231dc10abf6749cfa5d7767f25888d484201accbd919b66ab5413c502d56"
 "checksum scoped-tls 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "332ffa32bf586782a3efaeb58f127980944bbc8c4d6913a86107ac2a5ab24b28"
+"checksum scoped-tls 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
 "checksum scoped_threadpool 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8"
 "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"
 "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
@@ -4201,7 +4222,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 "checksum socket2 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "c4d11a52082057d87cb5caa31ad812f4504b97ab44732cd8359df2e9ff9f48e7"
 "checksum stable_deref_trait 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ffbc596e092fe5f598b12ef46cc03754085ac2f4d8c739ad61c4ae266cc3b3fa"
 "checksum string_cache 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "25d70109977172b127fe834e5449e5ab1740b9ba49fa18a2020f509174f25423"
-"checksum string_cache_codegen 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "35293b05cf1494e8ddd042a7df6756bf18d07f42d234f32e71dce8a7aabb0191"
+"checksum string_cache_codegen 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1eea1eee654ef80933142157fdad9dd8bc43cf7c74e999e369263496f04ff4da"
 "checksum string_cache_shared 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b1884d1bc09741d466d9b14e6d37ac89d6909cbcac41dd9ae982d4d063bbedfc"
 "checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
 "checksum strum 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f6c3a2071519ab6a48f465808c4c1ffdd00dfc8e93111d02b4fc5abab177676e"
index f45db37c33b86103d1e35929600ebc5167c7e009..8f6bf03489f06eb7ee36bee4b2445d3bde04f202 100644 (file)
 # The value specified here will be passed as `-DLLVM_USE_LINKER` to CMake.
 #use-linker = "lld"
 
+# Whether or not to specify `-DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=YES`
+#allow-old-toolchain = false
 
 # =============================================================================
 # General build configuration options
index b6afe317a07b03cf874c84225b7924ba30f92ea4..70e4a69a07d440169b041ce6f4faf93a4f71fc66 100644 (file)
@@ -107,6 +107,8 @@ fn main() {
         // actually downloaded, so we just always pass the `--sysroot` option.
         cmd.arg("--sysroot").arg(&sysroot);
 
+        cmd.arg("-Zexternal-macro-backtrace");
+
         // When we build Rust dylibs they're all intended for intermediate
         // usage, so make sure we pass the -Cprefer-dynamic flag instead of
         // linking all deps statically into the dylib.
index 119b38bcc99dce1b0f8bc9bf505d63e211bdeec7..c98d8b8ecf4370b12412f1ebcd96ab571dad3cae 100644 (file)
@@ -830,7 +830,7 @@ def main():
 
     # x.py help <cmd> ...
     if len(sys.argv) > 1 and sys.argv[1] == 'help':
-        sys.argv = sys.argv[:1] + [sys.argv[2], '-h'] + sys.argv[3:]
+        sys.argv = [sys.argv[0], '-h'] + sys.argv[2:]
 
     help_triggered = (
         '-h' in sys.argv) or ('--help' in sys.argv) or (len(sys.argv) == 1)
index 7d3e584f1a6fa4f649cc6f3b8e506908a44c7838..d20958854ed6a132a14a6daa18ded263d3440afd 100644 (file)
@@ -78,6 +78,7 @@ pub struct Config {
     pub llvm_link_jobs: Option<u32>,
     pub llvm_version_suffix: Option<String>,
     pub llvm_use_linker: Option<String>,
+    pub llvm_allow_old_toolchain: Option<bool>,
 
     pub lld_enabled: bool,
     pub lldb_enabled: bool,
@@ -263,6 +264,7 @@ struct Llvm {
     ldflags: Option<String>,
     use_libcxx: Option<bool>,
     use_linker: Option<String>,
+    allow_old_toolchain: Option<bool>,
 }
 
 #[derive(Deserialize, Default, Clone)]
@@ -530,6 +532,7 @@ pub fn parse(args: &[String]) -> Config {
             config.llvm_ldflags = llvm.ldflags.clone();
             set(&mut config.llvm_use_libcxx, llvm.use_libcxx);
             config.llvm_use_linker = llvm.use_linker.clone();
+            config.llvm_allow_old_toolchain = llvm.allow_old_toolchain.clone();
         }
 
         if let Some(ref rust) = toml.rust {
index 40f0e5ede8bd7ce41a90d8265024d237ae383910..e0ad0422a6ce30acc69cb07828af0c36cb2c285d 100644 (file)
@@ -60,7 +60,7 @@ fn run(self, builder: &Builder<'_>) {
 // NOTE: When adding a book here, make sure to ALSO build the book by
 // adding a build step in `src/bootstrap/builder.rs`!
 book!(
-    EditionGuide, "src/doc/edition-guide", "edition-guide", RustbookVersion::MdBook1;
+    EditionGuide, "src/doc/edition-guide", "edition-guide", RustbookVersion::MdBook2;
     EmbeddedBook, "src/doc/embedded-book", "embedded-book", RustbookVersion::MdBook2;
     Nomicon, "src/doc/nomicon", "nomicon", RustbookVersion::MdBook1;
     Reference, "src/doc/reference", "reference", RustbookVersion::MdBook1;
index 192b1cd1fbb756bd68b726c56132f2363d73d149..d78670cfe515af762c32a009294ca0b04fb461ed 100644 (file)
@@ -238,6 +238,10 @@ fn run(self, builder: &Builder<'_>) -> PathBuf {
             cfg.define("LLVM_USE_LINKER", linker);
         }
 
+        if let Some(true) = builder.config.llvm_allow_old_toolchain {
+            cfg.define("LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN", "YES");
+        }
+
         if let Some(ref python) = builder.config.python {
             cfg.define("PYTHON_EXECUTABLE", python);
         }
index a17a7ebc03dd165f92b588d2bf802d3b5d7ec754..4fe7e2cca2b6009577b7a51179d2ed9e8168e400 100644 (file)
@@ -33,5 +33,6 @@ ENV \
 
 ENV HOSTS=x86_64-unknown-netbsd
 
-ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
+ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs \
+  --set llvm.allow-old-toolchain
 ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS
index 0e9061cbaf95adfb9f3ed36c6cef4c046f282e86..fab9419503f0e34c1a06f9350a6705d0ce741dc6 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 0e9061cbaf95adfb9f3ed36c6cef4c046f282e86
+Subproject commit fab9419503f0e34c1a06f9350a6705d0ce741dc6
index 419edb885ec1a98c0747b3907003d79e3e6b93a9..5f3cc2a5618700efcde3bc00799744f21fa9ad2e 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 419edb885ec1a98c0747b3907003d79e3e6b93a9
+Subproject commit 5f3cc2a5618700efcde3bc00799744f21fa9ad2e
diff --git a/src/doc/unstable-book/src/language-features/c-variadic.md b/src/doc/unstable-book/src/language-features/c-variadic.md
new file mode 100644 (file)
index 0000000..9e7968d
--- /dev/null
@@ -0,0 +1,24 @@
+# `c_variadic`
+
+The tracking issue for this feature is: [#44930]
+
+[#44930]: https://github.com/rust-lang/rust/issues/44930
+
+------------------------
+
+The `c_variadic` language feature enables C-variadic functions to be
+defined in Rust. The may be called both from within Rust and via FFI.
+
+## Examples
+
+```rust
+#![feature(c_variadic)]
+
+pub unsafe extern "C" fn add(n: usize, mut args: ...) -> usize {
+    let mut sum = 0;
+    for _ in 0..n {
+        sum += args.arg::<usize>();
+    }
+    sum
+}
+```
diff --git a/src/doc/unstable-book/src/library-features/c-variadic.md b/src/doc/unstable-book/src/library-features/c-variadic.md
new file mode 100644 (file)
index 0000000..7776211
--- /dev/null
@@ -0,0 +1,26 @@
+# `c_variadic`
+
+The tracking issue for this feature is: [#44930]
+
+[#44930]: https://github.com/rust-lang/rust/issues/44930
+
+------------------------
+
+The `c_variadic` library feature exposes the `VaList` structure,
+Rust's analogue of C's `va_list` type.
+
+## Examples
+
+```rust
+#![feature(c_variadic)]
+
+use std::ffi::VaList;
+
+pub unsafe extern "C" fn vadd(n: usize, mut args: VaList) -> usize {
+    let mut sum = 0;
+    for _ in 0..n {
+        sum += args.arg::<usize>();
+    }
+    sum
+}
+```
index fe852e42b5cd3721b959734652956a4c100b63b1..1dd2bd3ee78aa67a548bb6625d4703109b396f1b 100644 (file)
@@ -185,13 +185,13 @@ fn $bench_ref_sum(b: &mut Bencher) {
 bench_sums! {
     bench_filter_sum,
     bench_filter_ref_sum,
-    (0i64..1000000).filter(|x| x % 2 == 0)
+    (0i64..1000000).filter(|x| x % 3 == 0)
 }
 
 bench_sums! {
     bench_filter_chain_sum,
     bench_filter_chain_ref_sum,
-    (0i64..1000000).chain(0..1000000).filter(|x| x % 2 == 0)
+    (0i64..1000000).chain(0..1000000).filter(|x| x % 3 == 0)
 }
 
 bench_sums! {
@@ -306,3 +306,31 @@ fn bench_skip_then_zip(b: &mut Bencher) {
         assert_eq!(s, 2009900);
     });
 }
+
+#[bench]
+fn bench_filter_count(b: &mut Bencher) {
+    b.iter(|| {
+        (0i64..1000000).map(black_box).filter(|x| x % 3 == 0).count()
+    })
+}
+
+#[bench]
+fn bench_filter_ref_count(b: &mut Bencher) {
+    b.iter(|| {
+        (0i64..1000000).map(black_box).by_ref().filter(|x| x % 3 == 0).count()
+    })
+}
+
+#[bench]
+fn bench_filter_chain_count(b: &mut Bencher) {
+    b.iter(|| {
+        (0i64..1000000).chain(0..1000000).map(black_box).filter(|x| x % 3 == 0).count()
+    })
+}
+
+#[bench]
+fn bench_filter_chain_ref_count(b: &mut Bencher) {
+    b.iter(|| {
+        (0i64..1000000).chain(0..1000000).map(black_box).by_ref().filter(|x| x % 3 == 0).count()
+    })
+}
index bca1b76dbb97514acd74de7a0a130533cbf548c6..d4ad22c16bbfa697458af3c5d2e7882be0588bc8 100644 (file)
@@ -681,12 +681,7 @@ impl<I: Iterator, P> Iterator for Filter<I, P> where P: FnMut(&I::Item) -> bool
 
     #[inline]
     fn next(&mut self) -> Option<I::Item> {
-        for x in &mut self.iter {
-            if (self.predicate)(&x) {
-                return Some(x);
-            }
-        }
-        None
+        self.try_for_each(Err).err()
     }
 
     #[inline]
@@ -707,12 +702,9 @@ fn size_hint(&self) -> (usize, Option<usize>) {
     // Using the branchless version will also simplify the LLVM byte code, thus
     // leaving more budget for LLVM optimizations.
     #[inline]
-    fn count(mut self) -> usize {
-        let mut count = 0;
-        for x in &mut self.iter {
-            count += (self.predicate)(&x) as usize;
-        }
-        count
+    fn count(self) -> usize {
+        let mut predicate = self.predicate;
+        self.iter.map(|x| predicate(&x) as usize).sum()
     }
 
     #[inline]
@@ -746,12 +738,7 @@ impl<I: DoubleEndedIterator, P> DoubleEndedIterator for Filter<I, P>
 {
     #[inline]
     fn next_back(&mut self) -> Option<I::Item> {
-        for x in self.iter.by_ref().rev() {
-            if (self.predicate)(&x) {
-                return Some(x);
-            }
-        }
-        None
+        self.try_rfold((), |_, x| Err(x)).err()
     }
 
     #[inline]
@@ -820,12 +807,7 @@ impl<B, I: Iterator, F> Iterator for FilterMap<I, F>
 
     #[inline]
     fn next(&mut self) -> Option<B> {
-        for x in self.iter.by_ref() {
-            if let Some(y) = (self.f)(x) {
-                return Some(y);
-            }
-        }
-        None
+        self.try_for_each(Err).err()
     }
 
     #[inline]
@@ -863,12 +845,7 @@ impl<B, I: DoubleEndedIterator, F> DoubleEndedIterator for FilterMap<I, F>
 {
     #[inline]
     fn next_back(&mut self) -> Option<B> {
-        for x in self.iter.by_ref().rev() {
-            if let Some(y) = (self.f)(x) {
-                return Some(y);
-            }
-        }
-        None
+        self.try_rfold((), |_, x| Err(x)).err()
     }
 
     #[inline]
index f41d293e80ad3da86b45c6a069734d50eff5a892..94f342e7e8efc6a575184b89027e5a7ce28a2a74 100644 (file)
@@ -900,10 +900,16 @@ pub fn discriminant<T>(v: &T) -> Discriminant<T> {
     }
 }
 
+// FIXME: Reference `MaybeUninit` from these docs, once that is stable.
 /// A wrapper to inhibit compiler from automatically calling `T`’s destructor.
 ///
 /// This wrapper is 0-cost.
 ///
+/// `ManuallyDrop<T>` is subject to the same layout optimizations as `T`.
+/// As a consequence, it has *no effect* on the assumptions that the compiler makes
+/// about all values being initialized at their type.  In particular, initializing
+/// a `ManuallyDrop<&mut T>` with [`mem::zeroed`] is undefined behavior.
+///
 /// # Examples
 ///
 /// This wrapper helps with explicitly documenting the drop order dependencies between fields of
@@ -935,6 +941,8 @@ pub fn discriminant<T>(v: &T) -> Discriminant<T> {
 ///     }
 /// }
 /// ```
+///
+/// [`mem::zeroed`]: fn.zeroed.html
 #[stable(feature = "manually_drop", since = "1.20.0")]
 #[lang = "manually_drop"]
 #[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
index 3ceba83afeef83b309ac04a83ff5ed3d7b49ba88..6708a195f88c53fdeaa508ff63d0607c7ce0de59 100644 (file)
@@ -346,7 +346,7 @@ pub const fn trailing_zeros(self) -> u32 {
             concat!("Shifts the bits to the left by a specified amount, `n`,
 wrapping the truncated bits to the end of the resulting integer.
 
-Please note this isn't the same operation as `<<`!
+Please note this isn't the same operation as the `<<` shifting operator!
 
 # Examples
 
@@ -370,7 +370,7 @@ pub const fn rotate_left(self, n: u32) -> Self {
 wrapping the truncated bits to the beginning of the resulting
 integer.
 
-Please note this isn't the same operation as `>>`!
+Please note this isn't the same operation as the `>>` shifting operator!
 
 # Examples
 
@@ -2300,7 +2300,7 @@ pub const fn trailing_zeros(self) -> u32 {
             concat!("Shifts the bits to the left by a specified amount, `n`,
 wrapping the truncated bits to the end of the resulting integer.
 
-Please note this isn't the same operation as `<<`!
+Please note this isn't the same operation as the `<<` shifting operator!
 
 # Examples
 
@@ -2324,7 +2324,7 @@ pub const fn rotate_left(self, n: u32) -> Self {
 wrapping the truncated bits to the beginning of the resulting
 integer.
 
-Please note this isn't the same operation as `>>`!
+Please note this isn't the same operation as the `>>` shifting operator!
 
 # Examples
 
index 50e189c9e3640502fd70f6255aedf3fe1a98cdf8..9cd5108ade411ebc7f97838a0538bce608a51f07 100644 (file)
@@ -429,7 +429,8 @@ pub const fn trailing_zeros(self) -> u32 {
             /// wrapping the truncated bits to the end of the resulting
             /// integer.
             ///
-            /// Please note this isn't the same operation as `>>`!
+            /// Please note this isn't the same operation as the `>>` shifting
+            /// operator!
             ///
             /// # Examples
             ///
@@ -454,7 +455,8 @@ pub const fn rotate_left(self, n: u32) -> Self {
             /// wrapping the truncated bits to the beginning of the resulting
             /// integer.
             ///
-            /// Please note this isn't the same operation as `<<`!
+            /// Please note this isn't the same operation as the `<<` shifting
+            /// operator!
             ///
             /// # Examples
             ///
index 8b51d8465141afbd0c1b898e1358086217460463..53334adadb856d83a4888393c5fc00a5663a0a0d 100644 (file)
@@ -3965,7 +3965,7 @@ pub fn make_ascii_lowercase(&mut self) {
         me.make_ascii_lowercase()
     }
 
-    /// Return an iterator that escapes each char in `s` with [`char::escape_debug`].
+    /// Return an iterator that escapes each char in `self` with [`char::escape_debug`].
     ///
     /// Note: only extended grapheme codepoints that begin the string will be
     /// escaped.
@@ -4013,7 +4013,7 @@ pub fn escape_debug(&self) -> EscapeDebug {
         }
     }
 
-    /// Return an iterator that escapes each char in `s` with [`char::escape_default`].
+    /// Return an iterator that escapes each char in `self` with [`char::escape_default`].
     ///
     /// [`char::escape_default`]: ../std/primitive.char.html#method.escape_default
     ///
@@ -4051,7 +4051,7 @@ pub fn escape_default(&self) -> EscapeDefault {
         EscapeDefault { inner: self.chars().flat_map(CharEscapeDefault) }
     }
 
-    /// Return an iterator that escapes each char in `s` with [`char::escape_unicode`].
+    /// Return an iterator that escapes each char in `self` with [`char::escape_unicode`].
     ///
     /// [`char::escape_unicode`]: ../std/primitive.char.html#method.escape_unicode
     ///
index e83adad4e2a0e9d9459d3afa99d24b7dd7ba305b..26a27ea88e27a0551e138439a07124cb99482c14 100644 (file)
@@ -17,11 +17,11 @@ graphviz = { path = "../libgraphviz" }
 jobserver = "0.1"
 lazy_static = "1.0.0"
 num_cpus = "1.0"
-scoped-tls = { version = "0.1.1", features = ["nightly"] }
+scoped-tls = "1.0"
 log = { version = "0.4", features = ["release_max_level_info", "std"] }
 polonius-engine = "0.6.2"
-rustc-rayon = "0.1.1"
-rustc-rayon-core = "0.1.1"
+rustc-rayon = "0.1.2"
+rustc-rayon-core = "0.1.2"
 rustc_apfloat = { path = "../librustc_apfloat" }
 rustc_target = { path = "../librustc_target" }
 rustc_data_structures = { path = "../librustc_data_structures" }
index 2f91da4f62e3dc159168fbf87444becadc0cd60e..c607eb5906e605122d54f9aa51523a534930c58e 100644 (file)
@@ -67,7 +67,7 @@
 };
 use crate::ty::{TyCtxt, FnSig, Instance, InstanceDef,
          ParamEnv, ParamEnvAnd, Predicate, PolyFnSig, PolyTraitRef, Ty};
-use crate::ty::subst::Substs;
+use crate::ty::subst::SubstsRef;
 
 // erase!() just makes tokens go away. It's used to specify which macro argument
 // is repeated (i.e., which sub-expression of the macro we are in) but don't need
@@ -456,6 +456,7 @@ pub fn to_dep_node(self, tcx: TyCtxt<'_, '_, '_>, kind: DepKind) -> DepNode {
     [eval_always] CoherenceInherentImplOverlapCheck,
     [] CoherenceCheckTrait(DefId),
     [eval_always] PrivacyAccessLevels(CrateNum),
+    [eval_always] Analysis(CrateNum),
 
     // Represents the MIR for a fn; also used as the task node for
     // things read/modify that MIR.
@@ -661,7 +662,7 @@ pub fn to_dep_node(self, tcx: TyCtxt<'_, '_, '_>, kind: DepKind) -> DepNode {
     [] TypeOpNormalizePolyFnSig(CanonicalTypeOpNormalizeGoal<'tcx, PolyFnSig<'tcx>>),
     [] TypeOpNormalizeFnSig(CanonicalTypeOpNormalizeGoal<'tcx, FnSig<'tcx>>),
 
-    [] SubstituteNormalizeAndTestPredicates { key: (DefId, &'tcx Substs<'tcx>) },
+    [] SubstituteNormalizeAndTestPredicates { key: (DefId, SubstsRef<'tcx>) },
     [] MethodAutoderefSteps(CanonicalTyGoal<'tcx>),
 
     [input] TargetFeaturesWhitelist,
index 0bc40da7e4f2c0c0cf9841624494a9c73a397abe..0aeac8cc440ec95d17c4ed6d9ac46172ca45c7a3 100644 (file)
@@ -617,6 +617,9 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) {
         TyKind::Typeof(ref expression) => {
             visitor.visit_anon_const(expression)
         }
+        TyKind::CVarArgs(ref lt) => {
+            visitor.visit_lifetime(lt)
+        }
         TyKind::Infer | TyKind::Err => {}
     }
 }
@@ -875,7 +878,6 @@ pub fn walk_trait_item_ref<'v, V: Visitor<'v>>(visitor: &mut V, trait_item_ref:
 pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplItem) {
     // N.B., deliberately force a compilation error if/when new fields are added.
     let ImplItem {
-        id: _,
         hir_id: _,
         ident,
         ref vis,
@@ -1103,7 +1105,7 @@ pub fn walk_arm<'v, V: Visitor<'v>>(visitor: &mut V, arm: &'v Arm) {
 }
 
 pub fn walk_vis<'v, V: Visitor<'v>>(visitor: &mut V, vis: &'v Visibility) {
-    if let VisibilityKind::Restricted { ref path, id: _, hir_id } = vis.node {
+    if let VisibilityKind::Restricted { ref path, hir_id } = vis.node {
         visitor.visit_id(hir_id);
         visitor.visit_path(path, hir_id)
     }
index 0211dd7287563d911148e0b2283f788d1fd53d11..a97ea7da7f19cbf3d175a03322039e34ddad38ff 100644 (file)
@@ -74,7 +74,7 @@
 pub struct LoweringContext<'a> {
     crate_root: Option<&'static str>,
 
-    // Used to assign ids to HIR nodes that do not directly correspond to an AST node.
+    /// Used to assign ids to HIR nodes that do not directly correspond to an AST node.
     sess: &'a Session,
 
     cstore: &'a dyn CrateStore,
@@ -107,25 +107,25 @@ pub struct LoweringContext<'a> {
     /// written at all (e.g., `&T` or `std::cell::Ref<T>`).
     anonymous_lifetime_mode: AnonymousLifetimeMode,
 
-    // Used to create lifetime definitions from in-band lifetime usages.
-    // e.g., `fn foo(x: &'x u8) -> &'x u8` to `fn foo<'x>(x: &'x u8) -> &'x u8`
-    // When a named lifetime is encountered in a function or impl header and
-    // has not been defined
-    // (i.e., it doesn't appear in the in_scope_lifetimes list), it is added
-    // to this list. The results of this list are then added to the list of
-    // lifetime definitions in the corresponding impl or function generics.
+    /// Used to create lifetime definitions from in-band lifetime usages.
+    /// e.g., `fn foo(x: &'x u8) -> &'x u8` to `fn foo<'x>(x: &'x u8) -> &'x u8`
+    /// When a named lifetime is encountered in a function or impl header and
+    /// has not been defined
+    /// (i.e., it doesn't appear in the in_scope_lifetimes list), it is added
+    /// to this list. The results of this list are then added to the list of
+    /// lifetime definitions in the corresponding impl or function generics.
     lifetimes_to_define: Vec<(Span, ParamName)>,
 
-    // Whether or not in-band lifetimes are being collected. This is used to
-    // indicate whether or not we're in a place where new lifetimes will result
-    // in in-band lifetime definitions, such a function or an impl header,
-    // including implicit lifetimes from `impl_header_lifetime_elision`.
+    /// Whether or not in-band lifetimes are being collected. This is used to
+    /// indicate whether or not we're in a place where new lifetimes will result
+    /// in in-band lifetime definitions, such a function or an impl header,
+    /// including implicit lifetimes from `impl_header_lifetime_elision`.
     is_collecting_in_band_lifetimes: bool,
 
-    // Currently in-scope lifetimes defined in impl headers, fn headers, or HRTB.
-    // When `is_collectin_in_band_lifetimes` is true, each lifetime is checked
-    // against this list to see if it is already in-scope, or if a definition
-    // needs to be created for it.
+    /// Currently in-scope lifetimes defined in impl headers, fn headers, or HRTB.
+    /// When `is_collectin_in_band_lifetimes` is true, each lifetime is checked
+    /// against this list to see if it is already in-scope, or if a definition
+    /// needs to be created for it.
     in_scope_lifetimes: Vec<Ident>,
 
     current_module: NodeId,
@@ -954,7 +954,7 @@ fn make_async_expr(
         let decl = FnDecl {
             inputs: vec![],
             output,
-            variadic: false
+            c_variadic: false
         };
         let body_id = self.record_body(body_expr, Some(&decl));
         self.is_generator = prev_is_generator;
@@ -1151,10 +1151,9 @@ fn lower_arm(&mut self, arm: &Arm) -> hir::Arm {
 
     fn lower_ty_binding(&mut self, b: &TypeBinding,
                         itctx: ImplTraitContext<'_>) -> hir::TypeBinding {
-        let LoweredNodeId { node_id, hir_id } = self.lower_node_id(b.id);
+        let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(b.id);
 
         hir::TypeBinding {
-            id: node_id,
             hir_id,
             ident: b.ident,
             ty: self.lower_ty(&b.ty, itctx),
@@ -1345,6 +1344,12 @@ fn lower_ty_direct(&mut self, t: &Ty, mut itctx: ImplTraitContext<'_>) -> hir::T
                 }
             }
             TyKind::Mac(_) => panic!("TyMac should have been expanded by now."),
+            TyKind::CVarArgs => {
+                // Create the implicit lifetime of the "spoofed" `VaList`.
+                let span = self.sess.source_map().next_point(t.span.shrink_to_lo());
+                let lt = self.new_implicit_lifetime(span);
+                hir::TyKind::CVarArgs(lt)
+            },
         };
 
         let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(t.id);
@@ -1976,14 +1981,13 @@ fn lower_parenthesized_parameter_data(
                     let LoweredNodeId { node_id: _, hir_id } = this.next_id();
                     hir::Ty { node: hir::TyKind::Tup(tys), hir_id, span }
                 };
-                let LoweredNodeId { node_id, hir_id } = this.next_id();
+                let LoweredNodeId { node_id: _, hir_id } = this.next_id();
 
                 (
                     hir::GenericArgs {
                         args: hir_vec![GenericArg::Type(mk_tup(this, inputs, span))],
                         bindings: hir_vec![
                             hir::TypeBinding {
-                                id: node_id,
                                 hir_id,
                                 ident: Ident::from_str(FN_OUTPUT_NAME),
                                 ty: output
@@ -2002,7 +2006,7 @@ fn lower_parenthesized_parameter_data(
     }
 
     fn lower_local(&mut self, l: &Local) -> (hir::Local, SmallVec<[hir::ItemId; 1]>) {
-        let LoweredNodeId { node_id, hir_id } = self.lower_node_id(l.id);
+        let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(l.id);
         let mut ids = SmallVec::<[hir::ItemId; 1]>::new();
         if self.sess.features_untracked().impl_trait_in_bindings {
             if let Some(ref ty) = l.ty {
@@ -2012,7 +2016,6 @@ fn lower_parenthesized_parameter_data(
         }
         let parent_def_id = DefId::local(self.current_hir_id_owner.last().unwrap().0);
         (hir::Local {
-            id: node_id,
             hir_id,
             ty: l.ty
                 .as_ref()
@@ -2039,9 +2042,8 @@ fn lower_mutability(&mut self, m: Mutability) -> hir::Mutability {
     }
 
     fn lower_arg(&mut self, arg: &Arg) -> hir::Arg {
-        let LoweredNodeId { node_id, hir_id } = self.lower_node_id(arg.id);
+        let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(arg.id);
         hir::Arg {
-            id: node_id,
             hir_id,
             pat: self.lower_pat(&arg.pat),
         }
@@ -2112,7 +2114,7 @@ fn lower_fn_decl(
         P(hir::FnDecl {
             inputs,
             output,
-            variadic: decl.variadic,
+            c_variadic: decl.c_variadic,
             implicit_self: decl.inputs.get(0).map_or(
                 hir::ImplicitSelfKind::None,
                 |arg| {
@@ -2321,13 +2323,12 @@ fn visit_lifetime(&mut self, lifetime: &'v hir::Lifetime) {
             };
 
             // "<Output = T>"
-            let LoweredNodeId { node_id, hir_id } = this.next_id();
+            let LoweredNodeId { node_id: _, hir_id } = this.next_id();
             let future_params = P(hir::GenericArgs {
                 args: hir_vec![],
                 bindings: hir_vec![hir::TypeBinding {
                     ident: Ident::from_str(FN_OUTPUT_NAME),
                     ty: output_ty,
-                    id: node_id,
                     hir_id,
                     span,
                 }],
@@ -2337,13 +2338,12 @@ fn visit_lifetime(&mut self, lifetime: &'v hir::Lifetime) {
             let future_path =
                 this.std_path(span, &["future", "Future"], Some(future_params), false);
 
-            let LoweredNodeId { node_id, hir_id } = this.next_id();
+            let LoweredNodeId { node_id: _, hir_id } = this.next_id();
             let mut bounds = vec![
                 hir::GenericBound::Trait(
                     hir::PolyTraitRef {
                         trait_ref: hir::TraitRef {
                             path: future_path,
-                            ref_id: node_id,
                             hir_ref_id: hir_id,
                         },
                         bound_generic_params: hir_vec![],
@@ -2713,10 +2713,9 @@ fn lower_trait_ref(&mut self, p: &TraitRef, itctx: ImplTraitContext<'_>) -> hir:
             hir::QPath::Resolved(None, path) => path.and_then(|path| path),
             qpath => bug!("lower_trait_ref: unexpected QPath `{:?}`", qpath),
         };
-        let LoweredNodeId { node_id, hir_id } = self.lower_node_id(p.ref_id);
+        let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(p.ref_id);
         hir::TraitRef {
             path,
-            ref_id: node_id,
             hir_ref_id: hir_id,
         }
     }
@@ -2762,10 +2761,9 @@ fn lower_struct_field(&mut self, (index, f): (usize, &StructField)) -> hir::Stru
     }
 
     fn lower_field(&mut self, f: &Field) -> hir::Field {
-        let LoweredNodeId { node_id, hir_id } = self.next_id();
+        let LoweredNodeId { node_id: _, hir_id } = self.next_id();
 
         hir::Field {
-            id: node_id,
             hir_id,
             ident: f.ident,
             expr: P(self.lower_expr(&f.expr)),
@@ -2892,7 +2890,7 @@ fn lower_item_kind(
                     // `impl Future<Output = T>` here because lower_body
                     // only cares about the input argument patterns in the function
                     // declaration (decl), not the return types.
-                    let body_id = this.lower_async_body(decl, header.asyncness, body);
+                    let body_id = this.lower_async_body(decl, header.asyncness.node, body);
 
                     let (generics, fn_decl) = this.add_in_band_defs(
                         generics,
@@ -2902,7 +2900,7 @@ fn lower_item_kind(
                             decl,
                             Some((fn_def_id, idty)),
                             true,
-                            header.asyncness.opt_return_id()
+                            header.asyncness.node.opt_return_id()
                         ),
                     );
 
@@ -3117,12 +3115,11 @@ fn lower_use_tree(
                             hir::VisibilityKind::Public => hir::VisibilityKind::Public,
                             hir::VisibilityKind::Crate(sugar) => hir::VisibilityKind::Crate(sugar),
                             hir::VisibilityKind::Inherited => hir::VisibilityKind::Inherited,
-                            hir::VisibilityKind::Restricted { ref path, id: _, hir_id: _ } => {
+                            hir::VisibilityKind::Restricted { ref path, hir_id: _ } => {
                                 let id = this.next_id();
                                 let path = this.renumber_segment_ids(path);
                                 hir::VisibilityKind::Restricted {
                                     path,
-                                    id: id.node_id,
                                     hir_id: id.hir_id,
                                 }
                             }
@@ -3224,12 +3221,11 @@ fn lower_use_tree(
                             hir::VisibilityKind::Public => hir::VisibilityKind::Public,
                             hir::VisibilityKind::Crate(sugar) => hir::VisibilityKind::Crate(sugar),
                             hir::VisibilityKind::Inherited => hir::VisibilityKind::Inherited,
-                            hir::VisibilityKind::Restricted { ref path, id: _, hir_id: _ } => {
+                            hir::VisibilityKind::Restricted { ref path, hir_id: _ } => {
                                 let id = this.next_id();
                                 let path = this.renumber_segment_ids(path);
                                 hir::VisibilityKind::Restricted {
                                     path: path,
-                                    id: id.node_id,
                                     hir_id: id.hir_id,
                                 }
                             }
@@ -3347,7 +3343,6 @@ fn lower_trait_item(&mut self, i: &TraitItem) -> hir::TraitItem {
         };
 
         hir::TraitItem {
-            id: node_id,
             hir_id,
             ident: i.ident,
             attrs: self.lower_attrs(&i.attrs),
@@ -3398,14 +3393,14 @@ fn lower_impl_item(&mut self, i: &ImplItem) -> hir::ImplItem {
                 )
             }
             ImplItemKind::Method(ref sig, ref body) => {
-                let body_id = self.lower_async_body(&sig.decl, sig.header.asyncness, body);
+                let body_id = self.lower_async_body(&sig.decl, sig.header.asyncness.node, body);
                 let impl_trait_return_allow = !self.is_in_trait_impl;
                 let (generics, sig) = self.lower_method_sig(
                     &i.generics,
                     sig,
                     impl_item_def_id,
                     impl_trait_return_allow,
-                    sig.header.asyncness.opt_return_id(),
+                    sig.header.asyncness.node.opt_return_id(),
                 );
                 (generics, hir::ImplItemKind::Method(sig, body_id))
             }
@@ -3423,7 +3418,6 @@ fn lower_impl_item(&mut self, i: &ImplItem) -> hir::ImplItem {
         };
 
         hir::ImplItem {
-            id: node_id,
             hir_id,
             ident: i.ident,
             attrs: self.lower_attrs(&i.attrs),
@@ -3624,7 +3618,7 @@ fn lower_is_auto(&mut self, a: IsAuto) -> hir::IsAuto {
     fn lower_fn_header(&mut self, h: FnHeader) -> hir::FnHeader {
         hir::FnHeader {
             unsafety: self.lower_unsafety(h.unsafety),
-            asyncness: self.lower_asyncness(h.asyncness),
+            asyncness: self.lower_asyncness(h.asyncness.node),
             constness: self.lower_constness(h.constness),
             abi: h.abi,
         }
@@ -3807,9 +3801,8 @@ fn lower_range_end(&mut self, e: &RangeEnd) -> hir::RangeEnd {
 
     fn lower_anon_const(&mut self, c: &AnonConst) -> hir::AnonConst {
         self.with_new_scopes(|this| {
-            let LoweredNodeId { node_id, hir_id } = this.lower_node_id(c.id);
+            let LoweredNodeId { node_id: _, hir_id } = this.lower_node_id(c.id);
             hir::AnonConst {
-                id: node_id,
                 hir_id,
                 body: this.lower_body(None, |this| this.lower_expr(&c.value)),
             }
@@ -3967,7 +3960,7 @@ fn lower_expr(&mut self, e: &Expr) -> hir::Expr {
                     let outer_decl = FnDecl {
                         inputs: decl.inputs.clone(),
                         output: FunctionRetTy::Default(fn_decl_span),
-                        variadic: false,
+                        c_variadic: false,
                     };
                     // We need to lower the declaration outside the new scope, because we
                     // have to conserve the state of being inside a loop condition for the
@@ -4421,9 +4414,8 @@ fn lower_expr(&mut self, e: &Expr) -> hir::Expr {
                         ThinVec::new(),
                     ))
                 };
-                let LoweredNodeId { node_id, hir_id } = self.next_id();
+                let LoweredNodeId { node_id: _, hir_id } = self.next_id();
                 let match_stmt = hir::Stmt {
-                    id: node_id,
                     hir_id,
                     node: hir::StmtKind::Expr(match_expr),
                     span: head_sp,
@@ -4450,9 +4442,8 @@ fn lower_expr(&mut self, e: &Expr) -> hir::Expr {
 
                 let body_block = self.with_loop_scope(e.id, |this| this.lower_block(body, false));
                 let body_expr = P(self.expr_block(body_block, ThinVec::new()));
-                let LoweredNodeId { node_id, hir_id } = self.next_id();
+                let LoweredNodeId { node_id: _, hir_id } = self.next_id();
                 let body_stmt = hir::Stmt {
-                    id: node_id,
                     hir_id,
                     node: hir::StmtKind::Expr(body_expr),
                     span: body.span,
@@ -4633,10 +4624,9 @@ fn lower_expr(&mut self, e: &Expr) -> hir::Expr {
                 let mut ids: SmallVec<[hir::Stmt; 1]> = item_ids
                     .into_iter()
                     .map(|item_id| {
-                        let LoweredNodeId { node_id, hir_id } = self.next_id();
+                        let LoweredNodeId { node_id: _, hir_id } = self.next_id();
 
                         hir::Stmt {
-                            id: node_id,
                             hir_id,
                             node: hir::StmtKind::Item(item_id),
                             span: s.span,
@@ -4644,10 +4634,9 @@ fn lower_expr(&mut self, e: &Expr) -> hir::Expr {
                     })
                     .collect();
                 ids.push({
-                    let LoweredNodeId { node_id, hir_id } = self.lower_node_id(s.id);
+                    let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(s.id);
 
                     hir::Stmt {
-                        id: node_id,
                         hir_id,
                         node: hir::StmtKind::Local(P(l)),
                         span: s.span,
@@ -4661,12 +4650,11 @@ fn lower_expr(&mut self, e: &Expr) -> hir::Expr {
                 return self.lower_item_id(it)
                     .into_iter()
                     .map(|item_id| {
-                        let LoweredNodeId { node_id, hir_id } = id.take()
+                        let LoweredNodeId { node_id: _, hir_id } = id.take()
                           .map(|id| self.lower_node_id(id))
                           .unwrap_or_else(|| self.next_id());
 
                         hir::Stmt {
-                            id: node_id,
                             hir_id,
                             node: hir::StmtKind::Item(item_id),
                             span: s.span,
@@ -4675,20 +4663,18 @@ fn lower_expr(&mut self, e: &Expr) -> hir::Expr {
                     .collect();
             }
             StmtKind::Expr(ref e) => {
-                let LoweredNodeId { node_id, hir_id } = self.lower_node_id(s.id);
+                let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(s.id);
 
                 hir::Stmt {
-                    id: node_id,
                     hir_id,
                     node: hir::StmtKind::Expr(P(self.lower_expr(e))),
                     span: s.span,
                 }
             },
             StmtKind::Semi(ref e) => {
-                let LoweredNodeId { node_id, hir_id } = self.lower_node_id(s.id);
+                let LoweredNodeId { node_id: _, hir_id } = self.lower_node_id(s.id);
 
                 hir::Stmt {
-                    id: node_id,
                     hir_id,
                     node: hir::StmtKind::Semi(P(self.lower_expr(e))),
                     span: s.span,
@@ -4733,7 +4719,6 @@ fn lower_visibility(
                         ParamMode::Explicit,
                         explicit_owner,
                     )),
-                    id: lowered_id.node_id,
                     hir_id: lowered_id.hir_id,
                 }
             },
@@ -4803,10 +4788,9 @@ fn arm(&mut self, pats: hir::HirVec<P<hir::Pat>>, expr: P<hir::Expr>) -> hir::Ar
     }
 
     fn field(&mut self, ident: Ident, expr: P<hir::Expr>, span: Span) -> hir::Field {
-        let LoweredNodeId { node_id, hir_id } = self.next_id();
+        let LoweredNodeId { node_id: _, hir_id } = self.next_id();
 
         hir::Field {
-            id: node_id,
             hir_id,
             ident,
             span,
@@ -4906,22 +4890,20 @@ fn stmt_let_pat(
         pat: P<hir::Pat>,
         source: hir::LocalSource,
     ) -> hir::Stmt {
-        let LoweredNodeId { node_id, hir_id } = self.next_id();
+        let LoweredNodeId { node_id: _, hir_id } = self.next_id();
 
         let local = hir::Local {
             pat,
             ty: None,
             init: ex,
-            id: node_id,
             hir_id,
             span: sp,
             attrs: ThinVec::new(),
             source,
         };
 
-        let LoweredNodeId { node_id, hir_id } = self.next_id();
+        let LoweredNodeId { node_id: _, hir_id } = self.next_id();
         hir::Stmt {
-            id: node_id,
             hir_id,
             node: hir::StmtKind::Local(P(local)),
             span: sp
@@ -5069,7 +5051,6 @@ fn ty_path(&mut self, id: LoweredNodeId, span: Span, qpath: hir::QPath) -> hir::
                             bound_generic_params: hir::HirVec::new(),
                             trait_ref: hir::TraitRef {
                                 path: path.and_then(|path| path),
-                                ref_id: id.node_id,
                                 hir_ref_id: id.hir_id,
                             },
                             span,
index 588b986aad29d6a3f1d5b31efbc97b2462e72e26..0425d5a5023849e6eff623bb1a2a9c805f118825 100644 (file)
@@ -386,7 +386,7 @@ fn visit_generic_param(&mut self, param: &'hir GenericParam) {
 
     fn visit_trait_item(&mut self, ti: &'hir TraitItem) {
         debug_assert_eq!(ti.hir_id.owner,
-                         self.definitions.opt_def_index(ti.id).unwrap());
+                         self.definitions.opt_def_index(self.hir_to_node_id[&ti.hir_id]).unwrap());
         self.with_dep_node_owner(ti.hir_id.owner, ti, |this| {
             this.insert(ti.span, ti.hir_id, Node::TraitItem(ti));
 
@@ -398,7 +398,7 @@ fn visit_trait_item(&mut self, ti: &'hir TraitItem) {
 
     fn visit_impl_item(&mut self, ii: &'hir ImplItem) {
         debug_assert_eq!(ii.hir_id.owner,
-                         self.definitions.opt_def_index(ii.id).unwrap());
+                         self.definitions.opt_def_index(self.hir_to_node_id[&ii.hir_id]).unwrap());
         self.with_dep_node_owner(ii.hir_id.owner, ii, |this| {
             this.insert(ii.span, ii.hir_id, Node::ImplItem(ii));
 
index 72aa9570cc2ffa04f8025ec16e992677a65c5955..12760f8b9828b2372c40c6335d1a422bfa64775f 100644 (file)
@@ -73,7 +73,7 @@ fn visit_async_fn(
         decl: &'a FnDecl,
         body: &'a Block,
     ) {
-        let (closure_id, return_impl_trait_id) = match header.asyncness {
+        let (closure_id, return_impl_trait_id) = match header.asyncness.node {
             IsAsync::Async {
                 closure_id,
                 return_impl_trait_id,
@@ -129,10 +129,10 @@ fn visit_item(&mut self, i: &'a Item) {
             }
             ItemKind::Fn(
                 ref decl,
-                ref header @ FnHeader { asyncness: IsAsync::Async { .. }, .. },
+                ref header,
                 ref generics,
                 ref body,
-            ) => {
+            ) if header.asyncness.node.is_async() => {
                 return self.visit_async_fn(
                     i.id,
                     i.ident.name,
@@ -242,9 +242,9 @@ fn visit_trait_item(&mut self, ti: &'a TraitItem) {
     fn visit_impl_item(&mut self, ii: &'a ImplItem) {
         let def_data = match ii.node {
             ImplItemKind::Method(MethodSig {
-                header: ref header @ FnHeader { asyncness: IsAsync::Async { .. }, .. },
+                ref header,
                 ref decl,
-            }, ref body) => {
+            }, ref body) if header.asyncness.node.is_async() => {
                 return self.visit_async_fn(
                     ii.id,
                     ii.ident.name,
index 41e48e46ea5b6116d76cc4f62d397099e6cb6663..66e814f06609cf636ee94bd4623360528da63c92 100644 (file)
@@ -349,7 +349,7 @@ pub fn describe_def(&self, node_id: NodeId) -> Option<Def> {
                 }
             }
             Node::TraitItem(item) => {
-                let def_id = self.local_def_id(item.id);
+                let def_id = self.local_def_id_from_hir_id(item.hir_id);
                 match item.node {
                     TraitItemKind::Const(..) => Some(Def::AssociatedConst(def_id)),
                     TraitItemKind::Method(..) => Some(Def::Method(def_id)),
@@ -357,7 +357,7 @@ pub fn describe_def(&self, node_id: NodeId) -> Option<Def> {
                 }
             }
             Node::ImplItem(item) => {
-                let def_id = self.local_def_id(item.id);
+                let def_id = self.local_def_id_from_hir_id(item.hir_id);
                 match item.node {
                     ImplItemKind::Const(..) => Some(Def::AssociatedConst(def_id)),
                     ImplItemKind::Method(..) => Some(Def::Method(def_id)),
@@ -387,7 +387,7 @@ pub fn describe_def(&self, node_id: NodeId) -> Option<Def> {
             Node::Block(_) |
             Node::Crate => None,
             Node::Local(local) => {
-                Some(Def::Local(local.id))
+                Some(Def::Local(self.hir_to_node_id(local.hir_id)))
             }
             Node::MacroDef(macro_def) => {
                 Some(Def::Macro(self.local_def_id_from_hir_id(macro_def.hir_id),
index 38e6e61592b1a4fc321220eb9393f21a1012c7a2..3ba4efba9186cad8425e8fa587162966995b53bc 100644 (file)
@@ -1162,7 +1162,6 @@ pub fn is_by_value(self) -> bool {
 /// A statement.
 #[derive(Clone, RustcEncodable, RustcDecodable)]
 pub struct Stmt {
-    pub id: NodeId,
     pub hir_id: HirId,
     pub node: StmtKind,
     pub span: Span,
@@ -1170,7 +1169,7 @@ pub struct Stmt {
 
 impl fmt::Debug for Stmt {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        write!(f, "stmt({}: {})", self.id,
+        write!(f, "stmt({}: {})", self.hir_id,
                print::to_string(print::NO_ANN, |s| s.print_stmt(self)))
     }
 }
@@ -1208,7 +1207,6 @@ pub struct Local {
     pub ty: Option<P<Ty>>,
     /// Initializer expression to set the value, if any.
     pub init: Option<P<Expr>>,
-    pub id: NodeId,
     pub hir_id: HirId,
     pub span: Span,
     pub attrs: ThinVec<Attribute>,
@@ -1231,7 +1229,6 @@ pub enum Guard {
 
 #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
 pub struct Field {
-    pub id: NodeId,
     pub hir_id: HirId,
     pub ident: Ident,
     pub expr: P<Expr>,
@@ -1325,7 +1322,6 @@ pub fn is_fn_or_closure(self) -> bool {
 /// explicit discriminant values for enum variants.
 #[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Debug)]
 pub struct AnonConst {
-    pub id: NodeId,
     pub hir_id: HirId,
     pub body: BodyId,
 }
@@ -1672,7 +1668,6 @@ pub struct TraitItemId {
 /// signature) or provided (meaning it has a default implementation).
 #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
 pub struct TraitItem {
-    pub id: NodeId,
     pub ident: Ident,
     pub hir_id: HirId,
     pub attrs: HirVec<Attribute>,
@@ -1715,7 +1710,6 @@ pub struct ImplItemId {
 /// Represents anything within an `impl` block
 #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
 pub struct ImplItem {
-    pub id: NodeId,
     pub ident: Ident,
     pub hir_id: HirId,
     pub vis: Visibility,
@@ -1743,7 +1737,6 @@ pub enum ImplItemKind {
 // Bind a type to an associated type: `A=Foo`.
 #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
 pub struct TypeBinding {
-    pub id: NodeId,
     pub hir_id: HirId,
     pub ident: Ident,
     pub ty: P<Ty>,
@@ -1829,6 +1822,9 @@ pub enum TyKind {
     Infer,
     /// Placeholder for a type that has failed to be defined.
     Err,
+    /// Placeholder for C-variadic arguments. We "spoof" the `VaList` created
+    /// from the variadic arguments. This type is only valid up to typeck.
+    CVarArgs(Lifetime),
 }
 
 #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
@@ -1856,7 +1852,6 @@ pub struct InlineAsm {
 #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
 pub struct Arg {
     pub pat: P<Pat>,
-    pub id: NodeId,
     pub hir_id: HirId,
 }
 
@@ -1865,7 +1860,7 @@ pub struct Arg {
 pub struct FnDecl {
     pub inputs: HirVec<Ty>,
     pub output: FunctionRetTy,
-    pub variadic: bool,
+    pub c_variadic: bool,
     /// Does the function have an implicit self?
     pub implicit_self: ImplicitSelfKind,
 }
@@ -2067,7 +2062,6 @@ pub enum UseKind {
 #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
 pub struct TraitRef {
     pub path: Path,
-    pub ref_id: NodeId,
     pub hir_ref_id: HirId,
 }
 
@@ -2102,7 +2096,7 @@ pub struct PolyTraitRef {
 pub enum VisibilityKind {
     Public,
     Crate(CrateSugar),
-    Restricted { path: P<Path>, id: NodeId, hir_id: HirId },
+    Restricted { path: P<Path>, hir_id: HirId },
     Inherited,
 }
 
index 17d374884134a86f429dba2f548f10d2dbce9732..28e9403e9dba2313a1606da3bf40a903ed84b82f 100644 (file)
@@ -25,7 +25,7 @@ pub enum AnnNode<'a> {
     Name(&'a ast::Name),
     Block(&'a hir::Block),
     Item(&'a hir::Item),
-    SubItem(ast::NodeId),
+    SubItem(hir::HirId),
     Expr(&'a hir::Expr),
     Pat(&'a hir::Pat),
 }
@@ -434,6 +434,9 @@ pub fn print_type(&mut self, ty: &hir::Ty) -> io::Result<()> {
                 self.s.word("/*ERROR*/")?;
                 self.pclose()?;
             }
+            hir::TyKind::CVarArgs(_) => {
+                self.s.word("...")?;
+            }
         }
         self.end()
     }
@@ -924,7 +927,7 @@ pub fn print_method_sig(&mut self,
     }
 
     pub fn print_trait_item(&mut self, ti: &hir::TraitItem) -> io::Result<()> {
-        self.ann.pre(self, AnnNode::SubItem(ti.id))?;
+        self.ann.pre(self, AnnNode::SubItem(ti.hir_id))?;
         self.hardbreak_if_not_bol()?;
         self.maybe_print_comment(ti.span.lo())?;
         self.print_outer_attributes(&ti.attrs)?;
@@ -956,11 +959,11 @@ pub fn print_trait_item(&mut self, ti: &hir::TraitItem) -> io::Result<()> {
                                            default.as_ref().map(|ty| &**ty))?;
             }
         }
-        self.ann.post(self, AnnNode::SubItem(ti.id))
+        self.ann.post(self, AnnNode::SubItem(ti.hir_id))
     }
 
     pub fn print_impl_item(&mut self, ii: &hir::ImplItem) -> io::Result<()> {
-        self.ann.pre(self, AnnNode::SubItem(ii.id))?;
+        self.ann.pre(self, AnnNode::SubItem(ii.hir_id))?;
         self.hardbreak_if_not_bol()?;
         self.maybe_print_comment(ii.span.lo())?;
         self.print_outer_attributes(&ii.attrs)?;
@@ -986,7 +989,7 @@ pub fn print_impl_item(&mut self, ii: &hir::ImplItem) -> io::Result<()> {
                 self.print_associated_type(ii.ident, Some(bounds), None)?;
             }
         }
-        self.ann.post(self, AnnNode::SubItem(ii.id))
+        self.ann.post(self, AnnNode::SubItem(ii.hir_id))
     }
 
     pub fn print_stmt(&mut self, st: &hir::Stmt) -> io::Result<()> {
@@ -2004,7 +2007,7 @@ pub fn print_fn(&mut self,
             s.print_type(ty)?;
             s.end()
         })?;
-        if decl.variadic {
+        if decl.c_variadic {
             self.s.word(", ...")?;
         }
         self.pclose()?;
index d1161dda1e2ff592c04f5a7469634e0cc38620a0..af1cce5e354545eba6188386568c892de07771b0 100644 (file)
@@ -294,7 +294,6 @@ fn hash_stable<W: StableHasherResult>(&self,
 });
 
 impl_stable_hash_for!(struct hir::TypeBinding {
-    id,
     hir_id,
     ident -> (ident.name),
     ty,
@@ -361,13 +360,14 @@ fn hash_stable<W: StableHasherResult>(&self,
     TraitObject(trait_refs, lifetime),
     Typeof(body_id),
     Err,
-    Infer
+    Infer,
+    CVarArgs(lt),
 });
 
 impl_stable_hash_for!(struct hir::FnDecl {
     inputs,
     output,
-    variadic,
+    c_variadic,
     implicit_self
 });
 
@@ -385,8 +385,7 @@ fn hash_stable<W: StableHasherResult>(&self,
 });
 
 impl_stable_hash_for!(struct hir::TraitRef {
-    // Don't hash the ref_id. It is tracked via the thing it is used to access
-    ref_id -> _,
+    // Don't hash the hir_ref_id. It is tracked via the thing it is used to access
     hir_ref_id -> _,
     path,
 });
@@ -494,7 +493,6 @@ fn hash_stable<W: StableHasherResult>(&self,
 });
 
 impl_stable_hash_for!(struct hir::Stmt {
-    id,
     hir_id,
     node,
     span,
@@ -505,7 +503,6 @@ fn hash_stable<W: StableHasherResult>(&self,
     pat,
     ty,
     init,
-    id,
     hir_id,
     span,
     attrs,
@@ -524,7 +521,6 @@ fn hash_stable<W: StableHasherResult>(&self,
 });
 
 impl_stable_hash_for!(struct hir::Field {
-    id -> _,
     hir_id -> _,
     ident,
     expr,
@@ -548,7 +544,6 @@ fn hash_stable<W: StableHasherResult>(&self,
 });
 
 impl_stable_hash_for!(struct hir::AnonConst {
-    id,
     hir_id,
     body
 });
@@ -672,7 +667,6 @@ fn hash_stable<W: StableHasherResult>(&self,
                                           hcx: &mut StableHashingContext<'a>,
                                           hasher: &mut StableHasher<W>) {
         let hir::TraitItem {
-            id: _,
             hir_id: _,
             ident,
             ref attrs,
@@ -707,7 +701,6 @@ fn hash_stable<W: StableHasherResult>(&self,
                                           hcx: &mut StableHashingContext<'a>,
                                           hasher: &mut StableHasher<W>) {
         let hir::ImplItem {
-            id: _,
             hir_id: _,
             ident,
             ref vis,
@@ -755,9 +748,8 @@ fn hash_stable<W: StableHasherResult>(&self,
             hir::VisibilityKind::Crate(sugar) => {
                 sugar.hash_stable(hcx, hasher);
             }
-            hir::VisibilityKind::Restricted { ref path, id, hir_id } => {
+            hir::VisibilityKind::Restricted { ref path, hir_id } => {
                 hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| {
-                    id.hash_stable(hcx, hasher);
                     hir_id.hash_stable(hcx, hasher);
                 });
                 path.hash_stable(hcx, hasher);
@@ -961,7 +953,6 @@ fn hash_stable<W: StableHasherResult>(&self,
 
 impl_stable_hash_for!(struct hir::Arg {
     pat,
-    id,
     hir_id
 });
 
index ddc091b7187063eb714aecee9d1724c5f329a9ee..41b78ee50965506a071430575a5024d79f5bac8c 100644 (file)
@@ -209,13 +209,13 @@ fn hash_stable<W: StableHasherResult>(&self,
                                           hasher: &mut StableHasher<W>) {
         mem::discriminant(self).hash_stable(hcx, hasher);
         match *self {
-            mir::Place::Local(ref local) => {
+            mir::Place::Base(mir::PlaceBase::Local(ref local)) => {
                 local.hash_stable(hcx, hasher);
             }
-            mir::Place::Static(ref statik) => {
+            mir::Place::Base(mir::PlaceBase::Static(ref statik)) => {
                 statik.hash_stable(hcx, hasher);
             }
-            mir::Place::Promoted(ref promoted) => {
+            mir::Place::Base(mir::PlaceBase::Promoted(ref promoted)) => {
                 promoted.hash_stable(hcx, hasher);
             }
             mir::Place::Projection(ref place_projection) => {
index cce1273b7f025d0743b29c355061f141e7752960..f77a88128f252ef36deb2a9665d78a087547da56 100644 (file)
@@ -232,7 +232,7 @@ fn hash_stable<W: StableHasherResult>(&self,
 
 impl_stable_hash_for!(struct ty::FnSig<'tcx> {
     inputs_and_output,
-    variadic,
+    c_variadic,
     unsafety,
     abi
 });
index 9cd5a844f15900a178ce8b9755783d8b0d34059d..6ef902a47dc8d768c931156e9a8b2bf485979acf 100644 (file)
@@ -34,7 +34,7 @@
 use crate::ty::{self, Ty, TyCtxt};
 use crate::ty::error::TypeError;
 use crate::ty::relate::{self, Relate, RelateResult, TypeRelation};
-use crate::ty::subst::Substs;
+use crate::ty::subst::SubstsRef;
 use crate::traits::{Obligation, PredicateObligations};
 
 use syntax::ast;
@@ -373,9 +373,9 @@ fn binders<T>(&mut self, a: &ty::Binder<T>, b: &ty::Binder<T>)
 
     fn relate_item_substs(&mut self,
                           item_def_id: DefId,
-                          a_subst: &'tcx Substs<'tcx>,
-                          b_subst: &'tcx Substs<'tcx>)
-                          -> RelateResult<'tcx, &'tcx Substs<'tcx>>
+                          a_subst: SubstsRef<'tcx>,
+                          b_subst: SubstsRef<'tcx>)
+                          -> RelateResult<'tcx, SubstsRef<'tcx>>
     {
         if self.ambient_variance == ty::Variance::Invariant {
             // Avoid fetching the variance if we are in an invariant
index a4b62307a60b861a39b455a43935fe433d137c17..31b01eecf5cb6e88231f428b7f908c0a93f41178 100644 (file)
@@ -5,7 +5,7 @@
 
 use crate::ty::{self, Ty, TyCtxt};
 use crate::ty::TyVar;
-use crate::ty::subst::Substs;
+use crate::ty::subst::SubstsRef;
 use crate::ty::relate::{self, Relate, RelateResult, TypeRelation};
 
 /// Ensures `a` is made equal to `b`. Returns `a` on success.
@@ -33,9 +33,9 @@ fn a_is_expected(&self) -> bool { self.a_is_expected }
 
     fn relate_item_substs(&mut self,
                           _item_def_id: DefId,
-                          a_subst: &'tcx Substs<'tcx>,
-                          b_subst: &'tcx Substs<'tcx>)
-                          -> RelateResult<'tcx, &'tcx Substs<'tcx>>
+                          a_subst: SubstsRef<'tcx>,
+                          b_subst: SubstsRef<'tcx>)
+                          -> RelateResult<'tcx, SubstsRef<'tcx>>
     {
         // N.B., once we are equating types, we don't care about
         // variance, so don't try to lookup the variance here. This
index 705d9c4cf93ea94acc0388fcaae8ffe867476452..3dace2f2e89b0ba7655c8643e492831264695dd5 100644 (file)
@@ -56,7 +56,7 @@
 use crate::middle::region;
 use crate::traits::{ObligationCause, ObligationCauseCode};
 use crate::ty::error::TypeError;
-use crate::ty::{self, subst::Subst, Region, Ty, TyCtxt, TyKind, TypeFoldable};
+use crate::ty::{self, subst::{Subst, SubstsRef}, Region, Ty, TyCtxt, TyKind, TypeFoldable};
 use errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString};
 use std::{cmp, fmt};
 use syntax_pos::{Pos, Span};
@@ -570,7 +570,7 @@ fn highlight_outer(
         value: &mut DiagnosticStyledString,
         other_value: &mut DiagnosticStyledString,
         name: String,
-        sub: &ty::subst::Substs<'tcx>,
+        sub: ty::subst::SubstsRef<'tcx>,
         pos: usize,
         other_ty: &Ty<'tcx>,
     ) {
@@ -648,7 +648,7 @@ fn cmp_type_arg(
         mut t1_out: &mut DiagnosticStyledString,
         mut t2_out: &mut DiagnosticStyledString,
         path: String,
-        sub: &ty::subst::Substs<'tcx>,
+        sub: ty::subst::SubstsRef<'tcx>,
         other_path: String,
         other_ty: &Ty<'tcx>,
     ) -> Option<()> {
@@ -687,8 +687,8 @@ fn push_comma(
     fn strip_generic_default_params(
         &self,
         def_id: DefId,
-        substs: &ty::subst::Substs<'tcx>,
-    ) -> &'tcx ty::subst::Substs<'tcx> {
+        substs: ty::subst::SubstsRef<'tcx>,
+    ) -> SubstsRef<'tcx> {
         let generics = self.tcx.generics_of(def_id);
         let mut num_supplied_defaults = 0;
         let mut type_params = generics
index 3b2fb7d41008e55ca2d3077876ffa6f87d13e5a6..506388c268bb107e01ecade10240980af9297ab7 100644 (file)
@@ -7,7 +7,7 @@
 use crate::traits::{ObligationCause, ObligationCauseCode};
 use crate::ty;
 use crate::ty::error::ExpectedFound;
-use crate::ty::subst::Substs;
+use crate::ty::subst::SubstsRef;
 use crate::util::ppaux::RegionHighlightMode;
 
 impl NiceRegionError<'me, 'gcx, 'tcx> {
@@ -175,8 +175,8 @@ fn try_report_placeholders_trait(
         sub_placeholder: Option<ty::Region<'tcx>>,
         sup_placeholder: Option<ty::Region<'tcx>>,
         trait_def_id: DefId,
-        expected_substs: &'tcx Substs<'tcx>,
-        actual_substs: &'tcx Substs<'tcx>,
+        expected_substs: SubstsRef<'tcx>,
+        actual_substs: SubstsRef<'tcx>,
     ) -> DiagnosticBuilder<'me> {
         debug!(
             "try_report_placeholders_trait(\
index ac2ebece442c8f94e1b61377096e7bac0ac83782..84ad742d3c9722e4f252e90df12d3e225eaa23ff 100644 (file)
@@ -18,7 +18,7 @@
 use crate::ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric};
 use crate::ty::fold::TypeFoldable;
 use crate::ty::relate::RelateResult;
-use crate::ty::subst::{Kind, Substs};
+use crate::ty::subst::{Kind, InternalSubsts, SubstsRef};
 use crate::ty::{self, GenericParamDefKind, Ty, TyCtxt, CtxtInterners};
 use crate::ty::{FloatVid, IntVid, TyVid};
 use crate::util::nodemap::FxHashMap;
@@ -1088,8 +1088,8 @@ pub fn var_for_def(&self, span: Span, param: &ty::GenericParamDef) -> Kind<'tcx>
 
     /// Given a set of generics defined on a type or impl, returns a substitution mapping each
     /// type/region parameter to a fresh inference variable.
-    pub fn fresh_substs_for_item(&self, span: Span, def_id: DefId) -> &'tcx Substs<'tcx> {
-        Substs::for_item(self.tcx, def_id, |param, _| self.var_for_def(span, param))
+    pub fn fresh_substs_for_item(&self, span: Span, def_id: DefId) -> SubstsRef<'tcx> {
+        InternalSubsts::for_item(self.tcx, def_id, |param, _| self.var_for_def(span, param))
     }
 
     /// Returns `true` if errors have been reported since this infcx was
index e75446b01c11e5c90155800caa6583fad01de07b..159bc1ceae26c2329ca0f152d10f2cd9002b4dbd 100644 (file)
@@ -9,7 +9,7 @@
 use crate::ty::{self, Ty, TyCtxt, GenericParamDefKind};
 use crate::ty::fold::{BottomUpFolder, TypeFoldable, TypeFolder};
 use crate::ty::outlives::Component;
-use crate::ty::subst::{Kind, Substs, UnpackedKind};
+use crate::ty::subst::{Kind, InternalSubsts, SubstsRef, UnpackedKind};
 use crate::util::nodemap::DefIdMap;
 
 pub type OpaqueTypeMap<'tcx> = DefIdMap<OpaqueTypeDecl<'tcx>>;
@@ -30,7 +30,7 @@ pub struct OpaqueTypeDecl<'tcx> {
     ///     fn foo<'a, 'b, T>() -> Foo<'a, T>
     ///
     /// then `substs` would be `['a, T]`.
-    pub substs: &'tcx Substs<'tcx>,
+    pub substs: SubstsRef<'tcx>,
 
     /// The type variable that represents the value of the abstract type
     /// that we require. In other words, after we compile this function,
@@ -437,7 +437,7 @@ pub fn infer_opaque_definition_from_instantiation(
         // lifetimes with 'static and remapping only those used in the
         // `impl Trait` return type, resulting in the parameters
         // shifting.
-        let id_substs = Substs::identity_for_item(gcx, def_id);
+        let id_substs = InternalSubsts::identity_for_item(gcx, def_id);
         let map: FxHashMap<Kind<'tcx>, Kind<'gcx>> = opaque_defn
             .substs
             .iter()
@@ -740,7 +740,7 @@ fn fold_opaque_ty(
         &mut self,
         ty: Ty<'tcx>,
         def_id: DefId,
-        substs: &'tcx Substs<'tcx>,
+        substs: SubstsRef<'tcx>,
     ) -> Ty<'tcx> {
         let infcx = self.infcx;
         let tcx = infcx.tcx;
index 494f708c6a7b79b4a0c27c8b455b7cd8ee438ed8..e1ad5aeea19fcb189ec636562a1eef7d1c3a3019 100644 (file)
@@ -2,7 +2,7 @@
 use crate::infer::outlives::env::RegionBoundPairs;
 use crate::infer::{GenericKind, VerifyBound};
 use crate::traits;
-use crate::ty::subst::{Subst, Substs};
+use crate::ty::subst::{Subst, InternalSubsts};
 use crate::ty::{self, Ty, TyCtxt};
 use crate::util::captures::Captures;
 
@@ -292,7 +292,7 @@ fn region_bounds_declared_on_associated_item(
             .iter()
             .map(|(p, _)| *p)
             .collect();
-        let identity_substs = Substs::identity_for_item(tcx, assoc_item_def_id);
+        let identity_substs = InternalSubsts::identity_for_item(tcx, assoc_item_def_id);
         let identity_proj = tcx.mk_projection(assoc_item_def_id, identity_substs);
         self.collect_outlives_from_predicate_list(
             move |ty| ty == identity_proj,
index dda314429fc8579d1d796000f63f7477b7e11f87..9761ee313533fe446b3b2410996e798f676e4e88 100644 (file)
@@ -729,8 +729,7 @@ fn lookup<S: Into<MultiSpan>>(&self,
         match span {
             Some(s) => self.tcx.struct_span_lint_hir(lint, hir_id, s, msg),
             None => {
-                let node_id = self.tcx.hir().hir_to_node_id(hir_id); // FIXME(@ljedrz): remove later
-                self.tcx.struct_lint_node(lint, node_id, msg)
+                self.tcx.struct_lint_node(lint, hir_id, msg)
             },
         }
     }
@@ -793,11 +792,11 @@ fn exit_attrs(&mut self, attrs: &'tcx [ast::Attribute]) {
         run_lints!(self, exit_lint_attrs, attrs);
     }
 
-    fn with_param_env<F>(&mut self, id: ast::NodeId, f: F)
+    fn with_param_env<F>(&mut self, id: hir::HirId, f: F)
         where F: FnOnce(&mut Self),
     {
         let old_param_env = self.param_env;
-        self.param_env = self.tcx.param_env(self.tcx.hir().local_def_id(id));
+        self.param_env = self.tcx.param_env(self.tcx.hir().local_def_id_from_hir_id(id));
         f(self);
         self.param_env = old_param_env;
     }
@@ -841,7 +840,7 @@ fn visit_item(&mut self, it: &'tcx hir::Item) {
         let generics = self.generics.take();
         self.generics = it.node.generics();
         self.with_lint_attrs(it.hir_id, &it.attrs, |cx| {
-            cx.with_param_env(it.id, |cx| {
+            cx.with_param_env(it.hir_id, |cx| {
                 run_lints!(cx, check_item, it);
                 hir_visit::walk_item(cx, it);
                 run_lints!(cx, check_item_post, it);
@@ -852,7 +851,7 @@ fn visit_item(&mut self, it: &'tcx hir::Item) {
 
     fn visit_foreign_item(&mut self, it: &'tcx hir::ForeignItem) {
         self.with_lint_attrs(it.hir_id, &it.attrs, |cx| {
-            cx.with_param_env(it.id, |cx| {
+            cx.with_param_env(it.hir_id, |cx| {
                 run_lints!(cx, check_foreign_item, it);
                 hir_visit::walk_foreign_item(cx, it);
                 run_lints!(cx, check_foreign_item_post, it);
@@ -983,7 +982,7 @@ fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
         let generics = self.generics.take();
         self.generics = Some(&trait_item.generics);
         self.with_lint_attrs(trait_item.hir_id, &trait_item.attrs, |cx| {
-            cx.with_param_env(trait_item.id, |cx| {
+            cx.with_param_env(trait_item.hir_id, |cx| {
                 run_lints!(cx, check_trait_item, trait_item);
                 hir_visit::walk_trait_item(cx, trait_item);
                 run_lints!(cx, check_trait_item_post, trait_item);
@@ -996,7 +995,7 @@ fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
         let generics = self.generics.take();
         self.generics = Some(&impl_item.generics);
         self.with_lint_attrs(impl_item.hir_id, &impl_item.attrs, |cx| {
-            cx.with_param_env(impl_item.id, |cx| {
+            cx.with_param_env(impl_item.hir_id, |cx| {
                 run_lints!(cx, check_impl_item, impl_item);
                 hir_visit::walk_impl_item(cx, impl_item);
                 run_lints!(cx, check_impl_item_post, impl_item);
index dd003e44bea09d8bba7acb41ca40af89e46ac595..496ff568b31b4d5a775a0f1f1382dfa477a9fff6 100644 (file)
@@ -132,14 +132,22 @@ macro_rules! declare_lint {
 
 #[macro_export]
 macro_rules! declare_tool_lint {
-    ($vis: vis $tool: ident ::$NAME: ident, $Level: ident, $desc: expr) => (
-        declare_tool_lint!{$vis $tool::$NAME, $Level, $desc, false}
+    (
+        $(#[$attr:meta])* $vis:vis $tool:ident ::$NAME:ident, $Level: ident, $desc: expr
+    ) => (
+        declare_tool_lint!{$(#[$attr])* $vis $tool::$NAME, $Level, $desc, false}
     );
-    ($vis: vis $tool: ident ::$NAME: ident, $Level: ident, $desc: expr,
-     report_in_external_macro: $rep: expr) => (
-         declare_tool_lint!{$vis $tool::$NAME, $Level, $desc, $rep}
+    (
+        $(#[$attr:meta])* $vis:vis $tool:ident ::$NAME:ident, $Level:ident, $desc:expr,
+        report_in_external_macro: $rep:expr
+    ) => (
+         declare_tool_lint!{$(#[$attr])* $vis $tool::$NAME, $Level, $desc, $rep}
     );
-    ($vis: vis $tool: ident ::$NAME: ident, $Level: ident, $desc: expr, $external: expr) => (
+    (
+        $(#[$attr:meta])* $vis:vis $tool:ident ::$NAME:ident, $Level:ident, $desc:expr,
+        $external:expr
+    ) => (
+        $(#[$attr])*
         $vis static $NAME: &$crate::lint::Lint = &$crate::lint::Lint {
             name: &concat!(stringify!($tool), "::", stringify!($NAME)),
             default_level: $crate::lint::$Level,
index 201a779ee1827adef9f99b6939f81db110bc0d6d..3b607127d8628a1afedba18529ed986edb1cd59a 100644 (file)
@@ -26,8 +26,8 @@
 // function, then we should explore its block to check for codes that
 // may need to be marked as live.
 fn should_explore<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
-                            node_id: ast::NodeId) -> bool {
-    match tcx.hir().find(node_id) {
+                            hir_id: hir::HirId) -> bool {
+    match tcx.hir().find_by_hir_id(hir_id) {
         Some(Node::Item(..)) |
         Some(Node::ImplItem(..)) |
         Some(Node::ForeignItem(..)) |
@@ -39,33 +39,33 @@ fn should_explore<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 }
 
 struct MarkSymbolVisitor<'a, 'tcx: 'a> {
-    worklist: Vec<ast::NodeId>,
+    worklist: Vec<hir::HirId>,
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
     tables: &'a ty::TypeckTables<'tcx>,
-    live_symbols: FxHashSet<ast::NodeId>,
+    live_symbols: FxHashSet<hir::HirId>,
     repr_has_repr_c: bool,
     in_pat: bool,
     inherited_pub_visibility: bool,
     ignore_variant_stack: Vec<DefId>,
     // maps from tuple struct constructors to tuple struct items
-    struct_constructors: FxHashMap<ast::NodeId, ast::NodeId>,
+    struct_constructors: FxHashMap<hir::HirId, hir::HirId>,
 }
 
 impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
     fn check_def_id(&mut self, def_id: DefId) {
-        if let Some(node_id) = self.tcx.hir().as_local_node_id(def_id) {
-            if should_explore(self.tcx, node_id) ||
-               self.struct_constructors.contains_key(&node_id) {
-                self.worklist.push(node_id);
+        if let Some(hir_id) = self.tcx.hir().as_local_hir_id(def_id) {
+            if should_explore(self.tcx, hir_id) ||
+               self.struct_constructors.contains_key(&hir_id) {
+                self.worklist.push(hir_id);
             }
-            self.live_symbols.insert(node_id);
+            self.live_symbols.insert(hir_id);
         }
     }
 
     fn insert_def_id(&mut self, def_id: DefId) {
-        if let Some(node_id) = self.tcx.hir().as_local_node_id(def_id) {
-            debug_assert!(!should_explore(self.tcx, node_id));
-            self.live_symbols.insert(node_id);
+        if let Some(hir_id) = self.tcx.hir().as_local_hir_id(def_id) {
+            debug_assert!(!should_explore(self.tcx, hir_id));
+            self.live_symbols.insert(hir_id);
         }
     }
 
@@ -136,7 +136,7 @@ fn mark_live_symbols(&mut self) {
             // tuple struct constructor function
             let id = self.struct_constructors.get(&id).cloned().unwrap_or(id);
 
-            if let Some(node) = self.tcx.hir().find(id) {
+            if let Some(node) = self.tcx.hir().find_by_hir_id(id) {
                 self.live_symbols.insert(id);
                 self.visit_node(node);
             }
@@ -217,7 +217,7 @@ fn visit_variant_data(&mut self, def: &'tcx hir::VariantData, _: ast::Name,
         let live_fields = def.fields().iter().filter(|f| {
             has_repr_c || inherited_pub_visibility || f.vis.node.is_pub()
         });
-        self.live_symbols.extend(live_fields.map(|f| f.id));
+        self.live_symbols.extend(live_fields.map(|f| f.hir_id));
 
         intravisit::walk_struct_def(self, def);
     }
@@ -285,7 +285,7 @@ fn visit_path(&mut self, path: &'tcx hir::Path, _: hir::HirId) {
 }
 
 fn has_allow_dead_code_or_lang_attr(tcx: TyCtxt<'_, '_, '_>,
-                                    id: ast::NodeId,
+                                    id: hir::HirId,
                                     attrs: &[ast::Attribute]) -> bool {
     if attr::contains_name(attrs, "lang") {
         return true;
@@ -306,7 +306,7 @@ fn has_allow_dead_code_or_lang_attr(tcx: TyCtxt<'_, '_, '_>,
         return true;
     }
 
-    let def_id = tcx.hir().local_def_id(id);
+    let def_id = tcx.hir().local_def_id_from_hir_id(id);
     let cg_attrs = tcx.codegen_fn_attrs(def_id);
 
     // #[used], #[no_mangle], #[export_name], etc also keeps the item alive
@@ -333,25 +333,25 @@ fn has_allow_dead_code_or_lang_attr(tcx: TyCtxt<'_, '_, '_>,
 //   2) We are not sure to be live or not
 //     * Implementation of a trait method
 struct LifeSeeder<'k, 'tcx: 'k> {
-    worklist: Vec<ast::NodeId>,
+    worklist: Vec<hir::HirId>,
     krate: &'k hir::Crate,
     tcx: TyCtxt<'k, 'tcx, 'tcx>,
     // see `MarkSymbolVisitor::struct_constructors`
-    struct_constructors: FxHashMap<ast::NodeId, ast::NodeId>,
+    struct_constructors: FxHashMap<hir::HirId, hir::HirId>,
 }
 
 impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> {
     fn visit_item(&mut self, item: &hir::Item) {
         let allow_dead_code = has_allow_dead_code_or_lang_attr(self.tcx,
-                                                               item.id,
+                                                               item.hir_id,
                                                                &item.attrs);
         if allow_dead_code {
-            self.worklist.push(item.id);
+            self.worklist.push(item.hir_id);
         }
         match item.node {
             hir::ItemKind::Enum(ref enum_def, _) if allow_dead_code => {
                 self.worklist.extend(enum_def.variants.iter()
-                                                      .map(|variant| variant.node.data.id()));
+                                                      .map(|variant| variant.node.data.hir_id()));
             }
             hir::ItemKind::Trait(.., ref trait_item_refs) => {
                 for trait_item_ref in trait_item_refs {
@@ -360,9 +360,9 @@ fn visit_item(&mut self, item: &hir::Item) {
                         hir::TraitItemKind::Const(_, Some(_)) |
                         hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(_)) => {
                             if has_allow_dead_code_or_lang_attr(self.tcx,
-                                                                trait_item.id,
+                                                                trait_item.hir_id,
                                                                 &trait_item.attrs) {
-                                self.worklist.push(trait_item.id);
+                                self.worklist.push(trait_item.hir_id);
                             }
                         }
                         _ => {}
@@ -374,14 +374,14 @@ fn visit_item(&mut self, item: &hir::Item) {
                     let impl_item = self.krate.impl_item(impl_item_ref.id);
                     if opt_trait.is_some() ||
                             has_allow_dead_code_or_lang_attr(self.tcx,
-                                                             impl_item.id,
+                                                             impl_item.hir_id,
                                                              &impl_item.attrs) {
-                        self.worklist.push(impl_item_ref.id.node_id);
+                        self.worklist.push(self.tcx.hir().node_to_hir_id(impl_item_ref.id.node_id));
                     }
                 }
             }
             hir::ItemKind::Struct(ref variant_data, _) => {
-                self.struct_constructors.insert(variant_data.id(), item.id);
+                self.struct_constructors.insert(variant_data.hir_id(), item.hir_id);
             }
             _ => ()
         }
@@ -400,16 +400,16 @@ fn create_and_seed_worklist<'a, 'tcx>(
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
     access_levels: &privacy::AccessLevels,
     krate: &hir::Crate,
-) -> (Vec<ast::NodeId>, FxHashMap<ast::NodeId, ast::NodeId>) {
+) -> (Vec<hir::HirId>, FxHashMap<hir::HirId, hir::HirId>) {
     let worklist = access_levels.map.iter().filter_map(|(&id, level)| {
         if level >= &privacy::AccessLevel::Reachable {
-            Some(id)
+            Some(tcx.hir().node_to_hir_id(id))
         } else {
             None
         }
     }).chain(
         // Seed entry point
-        tcx.entry_fn(LOCAL_CRATE).map(|(def_id, _)| tcx.hir().as_local_node_id(def_id).unwrap())
+        tcx.entry_fn(LOCAL_CRATE).map(|(def_id, _)| tcx.hir().as_local_hir_id(def_id).unwrap())
     ).collect::<Vec<_>>();
 
     // Seed implemented trait items
@@ -427,7 +427,7 @@ fn create_and_seed_worklist<'a, 'tcx>(
 fn find_live<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                        access_levels: &privacy::AccessLevels,
                        krate: &hir::Crate)
-                       -> FxHashSet<ast::NodeId> {
+                       -> FxHashSet<hir::HirId> {
     let (worklist, struct_constructors) = create_and_seed_worklist(tcx, access_levels, krate);
     let mut symbol_visitor = MarkSymbolVisitor {
         worklist,
@@ -446,7 +446,7 @@ fn find_live<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 
 struct DeadVisitor<'a, 'tcx: 'a> {
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
-    live_symbols: FxHashSet<ast::NodeId>,
+    live_symbols: FxHashSet<hir::HirId>,
 }
 
 impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
@@ -461,33 +461,33 @@ fn should_warn_about_item(&mut self, item: &hir::Item) -> bool {
             | hir::ItemKind::Union(..) => true,
             _ => false
         };
-        should_warn && !self.symbol_is_live(item.id)
+        should_warn && !self.symbol_is_live(item.hir_id)
     }
 
     fn should_warn_about_field(&mut self, field: &hir::StructField) -> bool {
         let field_type = self.tcx.type_of(self.tcx.hir().local_def_id(field.id));
         !field.is_positional()
-            && !self.symbol_is_live(field.id)
+            && !self.symbol_is_live(field.hir_id)
             && !field_type.is_phantom_data()
-            && !has_allow_dead_code_or_lang_attr(self.tcx, field.id, &field.attrs)
+            && !has_allow_dead_code_or_lang_attr(self.tcx, field.hir_id, &field.attrs)
     }
 
     fn should_warn_about_variant(&mut self, variant: &hir::VariantKind) -> bool {
-        !self.symbol_is_live(variant.data.id())
+        !self.symbol_is_live(variant.data.hir_id())
             && !has_allow_dead_code_or_lang_attr(self.tcx,
-                                                 variant.data.id(),
+                                                 variant.data.hir_id(),
                                                  &variant.attrs)
     }
 
     fn should_warn_about_foreign_item(&mut self, fi: &hir::ForeignItem) -> bool {
-        !self.symbol_is_live(fi.id)
-            && !has_allow_dead_code_or_lang_attr(self.tcx, fi.id, &fi.attrs)
+        !self.symbol_is_live(fi.hir_id)
+            && !has_allow_dead_code_or_lang_attr(self.tcx, fi.hir_id, &fi.attrs)
     }
 
-    // id := node id of an item's definition.
+    // id := HIR id of an item's definition.
     fn symbol_is_live(
         &mut self,
-        id: ast::NodeId,
+        id: hir::HirId,
     ) -> bool {
         if self.live_symbols.contains(&id) {
             return true;
@@ -496,12 +496,12 @@ fn symbol_is_live(
         // This is done to handle the case where, for example, the static
         // method of a private type is used, but the type itself is never
         // called directly.
-        let def_id = self.tcx.hir().local_def_id(id);
+        let def_id = self.tcx.hir().local_def_id_from_hir_id(id);
         let inherent_impls = self.tcx.inherent_impls(def_id);
         for &impl_did in inherent_impls.iter() {
             for &item_did in &self.tcx.associated_item_def_ids(impl_did)[..] {
-                if let Some(item_node_id) = self.tcx.hir().as_local_node_id(item_did) {
-                    if self.live_symbols.contains(&item_node_id) {
+                if let Some(item_hir_id) = self.tcx.hir().as_local_hir_id(item_did) {
+                    if self.live_symbols.contains(&item_hir_id) {
                         return true;
                     }
                 }
@@ -511,18 +511,18 @@ fn symbol_is_live(
     }
 
     fn warn_dead_code(&mut self,
-                      id: ast::NodeId,
+                      id: hir::HirId,
                       span: syntax_pos::Span,
                       name: ast::Name,
                       node_type: &str,
                       participle: &str) {
         if !name.as_str().starts_with("_") {
             self.tcx
-                .lint_node(lint::builtin::DEAD_CODE,
-                           id,
-                           span,
-                           &format!("{} is never {}: `{}`",
-                                    node_type, participle, name));
+                .lint_hir(lint::builtin::DEAD_CODE,
+                          id,
+                          span,
+                          &format!("{} is never {}: `{}`",
+                                   node_type, participle, name));
         }
     }
 }
@@ -555,7 +555,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
                 _ => "used"
             };
             self.warn_dead_code(
-                item.id,
+                item.hir_id,
                 span,
                 item.ident.name,
                 item.node.descriptive_variant(),
@@ -572,7 +572,7 @@ fn visit_variant(&mut self,
                      g: &'tcx hir::Generics,
                      id: hir::HirId) {
         if self.should_warn_about_variant(&variant.node) {
-            self.warn_dead_code(variant.node.data.id(), variant.span, variant.node.ident.name,
+            self.warn_dead_code(variant.node.data.hir_id(), variant.span, variant.node.ident.name,
                                 "variant", "constructed");
         } else {
             intravisit::walk_variant(self, variant, g, id);
@@ -581,7 +581,7 @@ fn visit_variant(&mut self,
 
     fn visit_foreign_item(&mut self, fi: &'tcx hir::ForeignItem) {
         if self.should_warn_about_foreign_item(fi) {
-            self.warn_dead_code(fi.id, fi.span, fi.ident.name,
+            self.warn_dead_code(fi.hir_id, fi.span, fi.ident.name,
                                 fi.node.descriptive_variant(), "used");
         }
         intravisit::walk_foreign_item(self, fi);
@@ -589,7 +589,7 @@ fn visit_foreign_item(&mut self, fi: &'tcx hir::ForeignItem) {
 
     fn visit_struct_field(&mut self, field: &'tcx hir::StructField) {
         if self.should_warn_about_field(&field) {
-            self.warn_dead_code(field.id, field.span, field.ident.name, "field", "used");
+            self.warn_dead_code(field.hir_id, field.span, field.ident.name, "field", "used");
         }
         intravisit::walk_struct_field(self, field);
     }
@@ -597,8 +597,8 @@ fn visit_struct_field(&mut self, field: &'tcx hir::StructField) {
     fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
         match impl_item.node {
             hir::ImplItemKind::Const(_, body_id) => {
-                if !self.symbol_is_live(impl_item.id) {
-                    self.warn_dead_code(impl_item.id,
+                if !self.symbol_is_live(impl_item.hir_id) {
+                    self.warn_dead_code(impl_item.hir_id,
                                         impl_item.span,
                                         impl_item.ident.name,
                                         "associated const",
@@ -607,9 +607,10 @@ fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
                 self.visit_nested_body(body_id)
             }
             hir::ImplItemKind::Method(_, body_id) => {
-                if !self.symbol_is_live(impl_item.id) {
+                if !self.symbol_is_live(impl_item.hir_id) {
                     let span = self.tcx.sess.source_map().def_span(impl_item.span);
-                    self.warn_dead_code(impl_item.id, span, impl_item.ident.name, "method", "used");
+                    self.warn_dead_code(impl_item.hir_id, span, impl_item.ident.name, "method",
+                        "used");
                 }
                 self.visit_nested_body(body_id)
             }
index 6c43068a227728428957817b188e2900b9c6f02c..32c7216765533cf65fc925b962b74d1096752dca 100644 (file)
@@ -5,7 +5,7 @@
 use std::cmp;
 use std::mem;
 use crate::ty;
-use crate::ty::subst::Substs;
+use crate::ty::subst::SubstsRef;
 
 /// The SymbolExportLevel of a symbols specifies from which kinds of crates
 /// the symbol will be exported. `C` symbols will be exported from any
@@ -33,7 +33,7 @@ pub fn is_below_threshold(self, threshold: SymbolExportLevel) -> bool {
 #[derive(Eq, PartialEq, Debug, Copy, Clone, RustcEncodable, RustcDecodable)]
 pub enum ExportedSymbol<'tcx> {
     NonGeneric(DefId),
-    Generic(DefId, &'tcx Substs<'tcx>),
+    Generic(DefId, SubstsRef<'tcx>),
     NoDefId(ty::SymbolName),
 }
 
index 0562fddb2b5233926bed78a1950cc5d766bcdf5a..cffbc2eaa40ce7a2168b90e35d817d9daf14bb87 100644 (file)
@@ -48,7 +48,7 @@ fn method_might_be_inlined<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                                      impl_item: &hir::ImplItem,
                                      impl_src: DefId) -> bool {
     let codegen_fn_attrs = tcx.codegen_fn_attrs(impl_item.hir_id.owner_def_id());
-    let generics = tcx.generics_of(tcx.hir().local_def_id(impl_item.id));
+    let generics = tcx.generics_of(tcx.hir().local_def_id_from_hir_id(impl_item.hir_id));
     if codegen_fn_attrs.requests_inline() || generics.requires_monomorphization(tcx) {
         return true
     }
index 31e9eb9b7463ca861c25b2aa0f2ae77ed57798c1..dd44e19bc7df9c371b84f3065ed2dac6986ca117 100644 (file)
@@ -764,6 +764,13 @@ fn visit_ty(&mut self, ty: &'tcx hir::Ty) {
                     });
                 }
             }
+            hir::TyKind::CVarArgs(ref lt) => {
+                // Resolve the generated lifetime for the C-variadic arguments.
+                // The lifetime is generated in AST -> HIR lowering.
+                if lt.name.is_elided() {
+                    self.resolve_elided_lifetimes(vec![lt])
+                }
+            }
             _ => intravisit::walk_ty(self, ty),
         }
     }
@@ -774,7 +781,7 @@ fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
             Method(ref sig, _) => {
                 let tcx = self.tcx;
                 self.visit_early_late(
-                    Some(tcx.hir().get_parent(trait_item.id)),
+                    Some(tcx.hir().get_parent_item(trait_item.hir_id)),
                     &sig.decl,
                     &trait_item.generics,
                     |this| intravisit::walk_trait_item(this, trait_item),
@@ -826,7 +833,7 @@ fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
             Method(ref sig, _) => {
                 let tcx = self.tcx;
                 self.visit_early_late(
-                    Some(tcx.hir().get_parent(impl_item.id)),
+                    Some(tcx.hir().get_parent_item(impl_item.hir_id)),
                     &sig.decl,
                     &impl_item.generics,
                     |this| intravisit::walk_impl_item(this, impl_item),
@@ -1678,7 +1685,7 @@ fn check_uses_for_lifetimes_defined_by_scope(&mut self) {
     /// ordering is not important there.
     fn visit_early_late<F>(
         &mut self,
-        parent_id: Option<ast::NodeId>,
+        parent_id: Option<hir::HirId>,
         decl: &'tcx hir::FnDecl,
         generics: &'tcx hir::Generics,
         walk: F,
@@ -1690,7 +1697,7 @@ fn visit_early_late<F>(
         // Find the start of nested early scopes, e.g., in methods.
         let mut index = 0;
         if let Some(parent_id) = parent_id {
-            let parent = self.tcx.hir().expect_item(parent_id);
+            let parent = self.tcx.hir().expect_item_by_hir_id(parent_id);
             if sub_items_have_self_param(&parent.node) {
                 index += 1; // Self comes before lifetimes
             }
@@ -2225,18 +2232,22 @@ fn visit_ty(&mut self, ty: &hir::Ty) {
                 if let hir::TyKind::BareFn(_) = ty.node {
                     self.outer_index.shift_in(1);
                 }
-                if let hir::TyKind::TraitObject(ref bounds, ref lifetime) = ty.node {
-                    for bound in bounds {
-                        self.visit_poly_trait_ref(bound, hir::TraitBoundModifier::None);
-                    }
+                match ty.node {
+                    hir::TyKind::TraitObject(ref bounds, ref lifetime) => {
+                        for bound in bounds {
+                            self.visit_poly_trait_ref(bound, hir::TraitBoundModifier::None);
+                        }
 
-                    // Stay on the safe side and don't include the object
-                    // lifetime default (which may not end up being used).
-                    if !lifetime.is_elided() {
-                        self.visit_lifetime(lifetime);
+                        // Stay on the safe side and don't include the object
+                        // lifetime default (which may not end up being used).
+                        if !lifetime.is_elided() {
+                            self.visit_lifetime(lifetime);
+                        }
+                    }
+                    hir::TyKind::CVarArgs(_) => {}
+                    _ => {
+                        intravisit::walk_ty(self, ty);
                     }
-                } else {
-                    intravisit::walk_ty(self, ty);
                 }
                 if let hir::TyKind::BareFn(_) = ty.node {
                     self.outer_index.shift_out(1);
index 55572c637f80ad729d6b243314415c57e12745b9..3c1b49e2dde6c29740d9a16210b718b71201315e 100644 (file)
@@ -13,7 +13,6 @@
 use crate::session::{DiagnosticMessageId, Session};
 use syntax::symbol::Symbol;
 use syntax_pos::{Span, MultiSpan};
-use syntax::ast;
 use syntax::ast::Attribute;
 use syntax::errors::Applicability;
 use syntax::feature_gate::{GateIssue, emit_feature_err};
@@ -356,7 +355,8 @@ fn visit_trait_item(&mut self, ti: &'tcx hir::TraitItem) {
     }
 
     fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem) {
-        let impl_def_id = self.tcx.hir().local_def_id(self.tcx.hir().get_parent(ii.id));
+        let impl_def_id = self.tcx.hir().local_def_id_from_hir_id(
+            self.tcx.hir().get_parent_item(ii.hir_id));
         if self.tcx.impl_trait_ref(impl_def_id).is_none() {
             self.check_missing_stability(ii.hir_id, ii.span, "item");
         }
@@ -397,10 +397,14 @@ pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Index<'tcx> {
             active_features: Default::default(),
         };
 
-        let ref active_lib_features = tcx.features().declared_lib_features;
+        let active_lib_features = &tcx.features().declared_lib_features;
+        let active_lang_features = &tcx.features().declared_lang_features;
 
-        // Put the active features into a map for quick lookup
-        index.active_features = active_lib_features.iter().map(|&(ref s, _)| s.clone()).collect();
+        // Put the active features into a map for quick lookup.
+        index.active_features =
+            active_lib_features.iter().map(|&(ref s, ..)| s.clone())
+            .chain(active_lang_features.iter().map(|&(ref s, ..)| s.clone()))
+            .collect();
 
         {
             let krate = tcx.hir().krate();
@@ -918,8 +922,8 @@ fn unnecessary_stable_feature_lint<'a, 'tcx>(
     feature: Symbol,
     since: Symbol
 ) {
-    tcx.lint_node(lint::builtin::STABLE_FEATURES,
-        ast::CRATE_NODE_ID,
+    tcx.lint_hir(lint::builtin::STABLE_FEATURES,
+        hir::CRATE_HIR_ID,
         span,
         &format!("the feature `{}` has been stable since {} and no longer requires \
                   an attribute to enable", feature, since));
index 001a347c3313aaef36ce613282bb93ec416eeac5..b6f5ff25c8fb87b41536a4d48fb78f1ee8112320 100644 (file)
@@ -27,7 +27,7 @@
 use syntax::symbol::InternedString;
 use syntax_pos::{Span, DUMMY_SP};
 use crate::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
-use crate::ty::subst::{Subst, Substs};
+use crate::ty::subst::{Subst, SubstsRef};
 use crate::ty::layout::VariantIdx;
 use crate::ty::{
     self, AdtDef, CanonicalUserTypeAnnotations, ClosureSubsts, GeneratorSubsts, Region, Ty, TyCtxt,
@@ -1896,6 +1896,14 @@ fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
 /// changing or disturbing program state.
 #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
 pub enum Place<'tcx> {
+    Base(PlaceBase<'tcx>),
+
+    /// projection out of a place (access a field, deref a pointer, etc)
+    Projection(Box<PlaceProjection<'tcx>>),
+}
+
+#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
+pub enum PlaceBase<'tcx> {
     /// local variable
     Local(Local),
 
@@ -1904,9 +1912,6 @@ pub enum Place<'tcx> {
 
     /// Constant code promoted to an injected static
     Promoted(Box<(Promoted, Ty<'tcx>)>),
-
-    /// projection out of a place (access a field, deref a pointer, etc)
-    Projection(Box<PlaceProjection<'tcx>>),
 }
 
 /// The `DefId` of a static, along with its normalized type (which is
@@ -1994,6 +1999,8 @@ pub struct Field {
 }
 
 impl<'tcx> Place<'tcx> {
+    pub const RETURN_PLACE: Place<'tcx> = Place::Base(PlaceBase::Local(RETURN_PLACE));
+
     pub fn field(self, f: Field, ty: Ty<'tcx>) -> Place<'tcx> {
         self.elem(ProjectionElem::Field(f, ty))
     }
@@ -2020,9 +2027,9 @@ pub fn elem(self, elem: PlaceElem<'tcx>) -> Place<'tcx> {
     // FIXME: can we safely swap the semantics of `fn base_local` below in here instead?
     pub fn local(&self) -> Option<Local> {
         match self {
-            Place::Local(local) |
+            Place::Base(PlaceBase::Local(local)) |
             Place::Projection(box Projection {
-                base: Place::Local(local),
+                base: Place::Base(PlaceBase::Local(local)),
                 elem: ProjectionElem::Deref,
             }) => Some(*local),
             _ => None,
@@ -2032,9 +2039,9 @@ pub fn local(&self) -> Option<Local> {
     /// Finds the innermost `Local` from this `Place`.
     pub fn base_local(&self) -> Option<Local> {
         match self {
-            Place::Local(local) => Some(*local),
+            Place::Base(PlaceBase::Local(local)) => Some(*local),
             Place::Projection(box Projection { base, elem: _ }) => base.base_local(),
-            Place::Promoted(..) | Place::Static(..) => None,
+            Place::Base(PlaceBase::Promoted(..)) | Place::Base(PlaceBase::Static(..)) => None,
         }
     }
 }
@@ -2044,14 +2051,19 @@ fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
         use self::Place::*;
 
         match *self {
-            Local(id) => write!(fmt, "{:?}", id),
-            Static(box self::Static { def_id, ty }) => write!(
+            Base(PlaceBase::Local(id)) => write!(fmt, "{:?}", id),
+            Base(PlaceBase::Static(box self::Static { def_id, ty })) => write!(
                 fmt,
                 "({}: {:?})",
                 ty::tls::with(|tcx| tcx.item_path_str(def_id)),
                 ty
             ),
-            Promoted(ref promoted) => write!(fmt, "({:?}: {:?})", promoted.0, promoted.1),
+            Base(PlaceBase::Promoted(ref promoted)) => write!(
+                fmt,
+                "({:?}: {:?})",
+                promoted.0,
+                promoted.1
+            ),
             Projection(ref data) => match data.elem {
                 ProjectionElem::Downcast(ref adt_def, index) => {
                     write!(fmt, "({:?} as {})", data.base, adt_def.variants[index].ident)
@@ -2151,7 +2163,7 @@ impl<'tcx> Operand<'tcx> {
     pub fn function_handle<'a>(
         tcx: TyCtxt<'a, 'tcx, 'tcx>,
         def_id: DefId,
-        substs: &'tcx Substs<'tcx>,
+        substs: SubstsRef<'tcx>,
         span: Span,
     ) -> Self {
         let ty = tcx.type_of(def_id).subst(tcx, substs);
@@ -2247,7 +2259,7 @@ pub enum AggregateKind<'tcx> {
     Adt(
         &'tcx AdtDef,
         VariantIdx,
-        &'tcx Substs<'tcx>,
+        SubstsRef<'tcx>,
         Option<UserTypeAnnotationIndex>,
         Option<usize>,
     ),
index bf4ac7496d2e76e25c929afcb45d9a857a8d646e..a6f153eaf6461e5c0772c8f18b7188f2bbfb82e8 100644 (file)
@@ -4,7 +4,7 @@
  */
 
 use crate::mir::*;
-use crate::ty::subst::{Subst, Substs};
+use crate::ty::subst::{Subst, SubstsRef};
 use crate::ty::{self, AdtDef, Ty, TyCtxt};
 use crate::ty::layout::VariantIdx;
 use crate::hir;
@@ -17,7 +17,7 @@ pub enum PlaceTy<'tcx> {
 
     /// Downcast to a particular variant of an enum.
     Downcast { adt_def: &'tcx AdtDef,
-               substs: &'tcx Substs<'tcx>,
+               substs: SubstsRef<'tcx>,
                variant_index: VariantIdx },
 }
 
@@ -158,10 +158,10 @@ pub fn ty<'a, 'gcx, D>(&self, local_decls: &D, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> P
         where D: HasLocalDecls<'tcx>
     {
         match *self {
-            Place::Local(index) =>
+            Place::Base(PlaceBase::Local(index)) =>
                 PlaceTy::Ty { ty: local_decls.local_decls()[index].ty },
-            Place::Promoted(ref data) => PlaceTy::Ty { ty: data.1 },
-            Place::Static(ref data) =>
+            Place::Base(PlaceBase::Promoted(ref data)) => PlaceTy::Ty { ty: data.1 },
+            Place::Base(PlaceBase::Static(ref data)) =>
                 PlaceTy::Ty { ty: data.ty },
             Place::Projection(ref proj) =>
                 proj.base.ty(local_decls, tcx).projection_ty(tcx, &proj.elem),
index e5828039ac29cb33fb1510aa05359a75a9a7a7d4..28e816f134365518cb7950834b7b9ef4c9083c2f 100644 (file)
@@ -1,5 +1,5 @@
 use crate::hir::def_id::DefId;
-use crate::ty::subst::Substs;
+use crate::ty::subst::SubstsRef;
 use crate::ty::{CanonicalUserTypeAnnotation, ClosureSubsts, GeneratorSubsts, Region, Ty};
 use crate::mir::*;
 use syntax_pos::Span;
@@ -238,7 +238,7 @@ fn visit_const(&mut self,
             }
 
             fn visit_substs(&mut self,
-                            substs: & $($mutability)? &'tcx Substs<'tcx>,
+                            substs: & $($mutability)? SubstsRef<'tcx>,
                             _: Location) {
                 self.super_substs(substs);
             }
@@ -733,13 +733,13 @@ fn super_place(&mut self,
                             context: PlaceContext<'tcx>,
                             location: Location) {
                 match place {
-                    Place::Local(local) => {
+                    Place::Base(PlaceBase::Local(local)) => {
                         self.visit_local(local, context, location);
                     }
-                    Place::Static(static_) => {
+                    Place::Base(PlaceBase::Static(static_)) => {
                         self.visit_static(static_, context, location);
                     }
-                    Place::Promoted(promoted) => {
+                    Place::Base(PlaceBase::Promoted(promoted)) => {
                         self.visit_ty(& $($mutability)? promoted.1, TyContext::Location(location));
                     },
                     Place::Projection(proj) => {
@@ -889,7 +889,7 @@ fn super_region(&mut self, _region: & $($mutability)? ty::Region<'tcx>) {
             fn super_const(&mut self, _const: & $($mutability)? &'tcx ty::LazyConst<'tcx>) {
             }
 
-            fn super_substs(&mut self, _substs: & $($mutability)? &'tcx Substs<'tcx>) {
+            fn super_substs(&mut self, _substs: & $($mutability)? SubstsRef<'tcx>) {
             }
 
             fn super_generator_substs(&mut self,
index 65da458efbfff3ee3249caa9f735c129dfe4e758..99eee4b559a5cc93af4543c0b17a71bb229b72b5 100644 (file)
@@ -499,6 +499,13 @@ pub fn get_input(&mut self) -> Option<&mut String> {
             Input::Str { ref mut input, .. } => Some(input),
         }
     }
+
+    pub fn source_name(&self) -> FileName {
+        match *self {
+            Input::File(ref ifile) => ifile.clone().into(),
+            Input::Str { ref name, .. } => name.clone(),
+        }
+    }
 }
 
 #[derive(Clone, Hash)]
index 833785f04076cb8c142ef4eedc28bbef7d32531a..3cff5ec230959d8eb46a1369d2070c9fe36fe830 100644 (file)
@@ -34,7 +34,8 @@
 
 use rustc_target::spec::{PanicStrategy, RelroLevel, Target, TargetTriple};
 use rustc_data_structures::flock;
-use jobserver::Client;
+use rustc_data_structures::jobserver;
+use ::jobserver::Client;
 
 use std;
 use std::cell::{self, Cell, RefCell};
@@ -899,14 +900,14 @@ pub fn consider_optimizing<T: Fn() -> String>(&self, crate_name: &str, msg: T) -
 
     /// Returns the number of query threads that should be used for this
     /// compilation
-    pub fn threads_from_opts(opts: &config::Options) -> usize {
-        opts.debugging_opts.threads.unwrap_or(::num_cpus::get())
+    pub fn threads_from_count(query_threads: Option<usize>) -> usize {
+        query_threads.unwrap_or(::num_cpus::get())
     }
 
     /// Returns the number of query threads that should be used for this
     /// compilation
     pub fn threads(&self) -> usize {
-        Self::threads_from_opts(&self.opts)
+        Self::threads_from_count(self.opts.debugging_opts.threads)
     }
 
     /// Returns the number of codegen units that should be used for this
@@ -1023,16 +1024,67 @@ pub fn build_session(
         local_crate_source_file,
         registry,
         Lrc::new(source_map::SourceMap::new(file_path_mapping)),
-        None,
+        DiagnosticOutput::Default,
+        Default::default(),
     )
 }
 
+fn default_emitter(
+    sopts: &config::Options,
+    registry: errors::registry::Registry,
+    source_map: &Lrc<source_map::SourceMap>,
+    emitter_dest: Option<Box<dyn Write + Send>>,
+) -> Box<dyn Emitter + sync::Send> {
+    match (sopts.error_format, emitter_dest) {
+        (config::ErrorOutputType::HumanReadable(color_config), None) => Box::new(
+            EmitterWriter::stderr(
+                color_config,
+                Some(source_map.clone()),
+                false,
+                sopts.debugging_opts.teach,
+            ).ui_testing(sopts.debugging_opts.ui_testing),
+        ),
+        (config::ErrorOutputType::HumanReadable(_), Some(dst)) => Box::new(
+            EmitterWriter::new(dst, Some(source_map.clone()), false, false)
+                .ui_testing(sopts.debugging_opts.ui_testing),
+        ),
+        (config::ErrorOutputType::Json(pretty), None) => Box::new(
+            JsonEmitter::stderr(
+                Some(registry),
+                source_map.clone(),
+                pretty,
+            ).ui_testing(sopts.debugging_opts.ui_testing),
+        ),
+        (config::ErrorOutputType::Json(pretty), Some(dst)) => Box::new(
+            JsonEmitter::new(
+                dst,
+                Some(registry),
+                source_map.clone(),
+                pretty,
+            ).ui_testing(sopts.debugging_opts.ui_testing),
+        ),
+        (config::ErrorOutputType::Short(color_config), None) => Box::new(
+            EmitterWriter::stderr(color_config, Some(source_map.clone()), true, false),
+        ),
+        (config::ErrorOutputType::Short(_), Some(dst)) => {
+            Box::new(EmitterWriter::new(dst, Some(source_map.clone()), true, false))
+        }
+    }
+}
+
+pub enum DiagnosticOutput {
+    Default,
+    Raw(Box<dyn Write + Send>),
+    Emitter(Box<dyn Emitter + Send + sync::Send>)
+}
+
 pub fn build_session_with_source_map(
     sopts: config::Options,
     local_crate_source_file: Option<PathBuf>,
     registry: errors::registry::Registry,
     source_map: Lrc<source_map::SourceMap>,
-    emitter_dest: Option<Box<dyn Write + Send>>,
+    diagnostics_output: DiagnosticOutput,
+    lint_caps: FxHashMap<lint::LintId, lint::Level>,
 ) -> Session {
     // FIXME: This is not general enough to make the warning lint completely override
     // normal diagnostic warnings, since the warning lint can also be denied and changed
@@ -1054,42 +1106,13 @@ pub fn build_session_with_source_map(
 
     let external_macro_backtrace = sopts.debugging_opts.external_macro_backtrace;
 
-    let emitter: Box<dyn Emitter + sync::Send> =
-        match (sopts.error_format, emitter_dest) {
-            (config::ErrorOutputType::HumanReadable(color_config), None) => Box::new(
-                EmitterWriter::stderr(
-                    color_config,
-                    Some(source_map.clone()),
-                    false,
-                    sopts.debugging_opts.teach,
-                ).ui_testing(sopts.debugging_opts.ui_testing),
-            ),
-            (config::ErrorOutputType::HumanReadable(_), Some(dst)) => Box::new(
-                EmitterWriter::new(dst, Some(source_map.clone()), false, false)
-                    .ui_testing(sopts.debugging_opts.ui_testing),
-            ),
-            (config::ErrorOutputType::Json(pretty), None) => Box::new(
-                JsonEmitter::stderr(
-                    Some(registry),
-                    source_map.clone(),
-                    pretty,
-                ).ui_testing(sopts.debugging_opts.ui_testing),
-            ),
-            (config::ErrorOutputType::Json(pretty), Some(dst)) => Box::new(
-                JsonEmitter::new(
-                    dst,
-                    Some(registry),
-                    source_map.clone(),
-                    pretty,
-                ).ui_testing(sopts.debugging_opts.ui_testing),
-            ),
-            (config::ErrorOutputType::Short(color_config), None) => Box::new(
-                EmitterWriter::stderr(color_config, Some(source_map.clone()), true, false),
-            ),
-            (config::ErrorOutputType::Short(_), Some(dst)) => {
-                Box::new(EmitterWriter::new(dst, Some(source_map.clone()), true, false))
-            }
-        };
+    let emitter = match diagnostics_output {
+        DiagnosticOutput::Default => default_emitter(&sopts, registry, &source_map, None),
+        DiagnosticOutput::Raw(write) => {
+            default_emitter(&sopts, registry, &source_map, Some(write))
+        }
+        DiagnosticOutput::Emitter(emitter) => emitter,
+    };
 
     let diagnostic_handler = errors::Handler::with_emitter_and_flags(
         emitter,
@@ -1103,7 +1126,7 @@ pub fn build_session_with_source_map(
         },
     );
 
-    build_session_(sopts, local_crate_source_file, diagnostic_handler, source_map)
+    build_session_(sopts, local_crate_source_file, diagnostic_handler, source_map, lint_caps)
 }
 
 pub fn build_session_(
@@ -1111,6 +1134,7 @@ pub fn build_session_(
     local_crate_source_file: Option<PathBuf>,
     span_diagnostic: errors::Handler,
     source_map: Lrc<source_map::SourceMap>,
+    driver_lint_caps: FxHashMap<lint::LintId, lint::Level>,
 ) -> Session {
     let host_triple = TargetTriple::from_triple(config::host_triple());
     let host = Target::search(&host_triple).unwrap_or_else(|e|
@@ -1207,35 +1231,10 @@ pub fn build_session_(
         optimization_fuel,
         print_fuel_crate,
         print_fuel,
-        // Note that this is unsafe because it may misinterpret file descriptors
-        // on Unix as jobserver file descriptors. We hopefully execute this near
-        // the beginning of the process though to ensure we don't get false
-        // positives, or in other words we try to execute this before we open
-        // any file descriptors ourselves.
-        //
-        // Pick a "reasonable maximum" if we don't otherwise have
-        // a jobserver in our environment, capping out at 32 so we
-        // don't take everything down by hogging the process run queue.
-        // The fixed number is used to have deterministic compilation
-        // across machines.
-        //
-        // Also note that we stick this in a global because there could be
-        // multiple `Session` instances in this process, and the jobserver is
-        // per-process.
-        jobserver: unsafe {
-            static mut GLOBAL_JOBSERVER: *mut Client = 0 as *mut _;
-            static INIT: std::sync::Once = std::sync::ONCE_INIT;
-            INIT.call_once(|| {
-                let client = Client::from_env().unwrap_or_else(|| {
-                    Client::new(32).expect("failed to create jobserver")
-                });
-                GLOBAL_JOBSERVER = Box::into_raw(Box::new(client));
-            });
-            (*GLOBAL_JOBSERVER).clone()
-        },
+        jobserver: jobserver::client(),
         has_global_allocator: Once::new(),
         has_panic_handler: Once::new(),
-        driver_lint_caps: Default::default(),
+        driver_lint_caps,
     };
 
     validate_commandline_args_with_session_available(&sess);
index 60a3777abf844257fc9eab1ae27fc36de885af16..e93351197fe4702c269de8bb3b21fdac02554dc7 100644 (file)
@@ -631,7 +631,7 @@ pub fn map_vid_to_region<'cx>(
         finished_map
     }
 
-    fn is_param_no_infer(&self, substs: &Substs<'_>) -> bool {
+    fn is_param_no_infer(&self, substs: SubstsRef<'_>) -> bool {
         return self.is_of_param(substs.type_at(0)) &&
             !substs.types().any(|t| t.has_infer_types());
     }
index d6b7b3b99cacd8c18bcaf974a6c39bed6b136767..9b0a3820c859ce2fe7d13d928a91b4e0cae7af41 100644 (file)
@@ -11,7 +11,7 @@
 use crate::traits::{FulfillmentContext, Obligation, ObligationCause, SelectionContext,
              TraitEngine, Vtable};
 use crate::ty::{self, Ty, TyCtxt};
-use crate::ty::subst::{Subst, Substs};
+use crate::ty::subst::{Subst, SubstsRef};
 use crate::ty::fold::TypeFoldable;
 
 /// Attempts to resolve an obligation to a vtable. The result is
@@ -82,7 +82,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
     /// types.
     pub fn subst_and_normalize_erasing_regions<T>(
         self,
-        param_substs: &Substs<'tcx>,
+        param_substs: SubstsRef<'tcx>,
         param_env: ty::ParamEnv<'tcx>,
         value: &T
     ) -> T
index be6a95948edb9d5201e8cfac86225b0f3c947f01..ee7893a27de7dd6caad1226c9feff3498437fac1 100644 (file)
@@ -29,7 +29,7 @@
 use rustc_data_structures::sync::Lrc;
 use syntax::ast;
 use syntax_pos::{Span, DUMMY_SP};
-use crate::ty::subst::Substs;
+use crate::ty::subst::{InternalSubsts, SubstsRef};
 use crate::ty::{self, AdtKind, List, Ty, TyCtxt, GenericParamDefKind, ToPredicate};
 use crate::ty::error::{ExpectedFound, TypeError};
 use crate::ty::fold::{TypeFolder, TypeFoldable, TypeVisitor};
@@ -565,7 +565,7 @@ pub enum Vtable<'tcx, N> {
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable)]
 pub struct VtableImplData<'tcx, N> {
     pub impl_def_id: DefId,
-    pub substs: &'tcx Substs<'tcx>,
+    pub substs: SubstsRef<'tcx>,
     pub nested: Vec<N>
 }
 
@@ -622,7 +622,7 @@ pub struct VtableFnPointerData<'tcx, N> {
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable)]
 pub struct VtableTraitAliasData<'tcx, N> {
     pub alias_def_id: DefId,
-    pub substs: &'tcx Substs<'tcx>,
+    pub substs: SubstsRef<'tcx>,
     pub nested: Vec<N>,
 }
 
@@ -963,7 +963,7 @@ fn normalize_and_test_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 }
 
 fn substitute_normalize_and_test_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
-                                                      key: (DefId, &'tcx Substs<'tcx>))
+                                                      key: (DefId, SubstsRef<'tcx>))
                                                       -> bool
 {
     debug!("substitute_normalize_and_test_predicates(key={:?})",
@@ -983,7 +983,7 @@ fn substitute_normalize_and_test_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx
 fn vtable_methods<'a, 'tcx>(
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
     trait_ref: ty::PolyTraitRef<'tcx>)
-    -> Lrc<Vec<Option<(DefId, &'tcx Substs<'tcx>)>>>
+    -> Lrc<Vec<Option<(DefId, SubstsRef<'tcx>)>>>
 {
     debug!("vtable_methods({:?})", trait_ref);
 
@@ -992,7 +992,7 @@ fn vtable_methods<'a, 'tcx>(
             let trait_methods = tcx.associated_items(trait_ref.def_id())
                 .filter(|item| item.kind == ty::AssociatedKind::Method);
 
-            // Now list each method's DefId and Substs (for within its trait).
+            // Now list each method's DefId and InternalSubsts (for within its trait).
             // If the method can never be called from this object, produce None.
             trait_methods.map(move |trait_method| {
                 debug!("vtable_methods: trait_method={:?}", trait_method);
@@ -1007,7 +1007,7 @@ fn vtable_methods<'a, 'tcx>(
                 // the method may have some early-bound lifetimes, add
                 // regions for those
                 let substs = trait_ref.map_bound(|trait_ref|
-                    Substs::for_item(tcx, def_id, |param, _|
+                    InternalSubsts::for_item(tcx, def_id, |param, _|
                         match param.kind {
                             GenericParamDefKind::Lifetime => tcx.types.re_erased.into(),
                             GenericParamDefKind::Type {..} => {
index 5c24b0ebfe05e7c20e7cc64f65972cbe074ed919..b2079c2516935c5e1c11b125b29608d72de7e310 100644 (file)
@@ -15,7 +15,7 @@
 use crate::lint;
 use crate::traits::{self, Obligation, ObligationCause};
 use crate::ty::{self, Ty, TyCtxt, TypeFoldable, Predicate, ToPredicate};
-use crate::ty::subst::{Subst, Substs};
+use crate::ty::subst::{Subst, InternalSubsts};
 use std::borrow::Cow;
 use std::iter::{self};
 use syntax::ast::{self, Name};
@@ -406,7 +406,7 @@ fn receiver_for_self_ty(
         self, receiver_ty: Ty<'tcx>, self_ty: Ty<'tcx>, method_def_id: DefId
     ) -> Ty<'tcx> {
         debug!("receiver_for_self_ty({:?}, {:?}, {:?})", receiver_ty, self_ty, method_def_id);
-        let substs = Substs::for_item(self, method_def_id, |param, _| {
+        let substs = InternalSubsts::for_item(self, method_def_id, |param, _| {
             if param.index == 0 {
                 self_ty.into()
             } else {
@@ -559,13 +559,17 @@ fn receiver_is_dispatchable(
 
             // U: Trait<Arg1, ..., ArgN>
             let trait_predicate = {
-                let substs = Substs::for_item(self, method.container.assert_trait(), |param, _| {
-                    if param.index == 0 {
-                        unsized_self_ty.into()
-                    } else {
-                        self.mk_param_from_def(param)
-                    }
-                });
+                let substs = InternalSubsts::for_item(
+                    self,
+                    method.container.assert_trait(),
+                    |param, _| {
+                        if param.index == 0 {
+                            unsized_self_ty.into()
+                        } else {
+                            self.mk_param_from_def(param)
+                        }
+                    },
+                );
 
                 ty::TraitRef {
                     def_id: unsize_did,
index 05141c9daf1d4b23277e175497e270cc8dc42296..72df12bc535a66e304d38449951af9f9568395b8 100644 (file)
@@ -18,7 +18,7 @@
 use crate::mir::interpret::{GlobalId};
 use rustc_data_structures::snapshot_map::{Snapshot, SnapshotMap};
 use syntax::ast::Ident;
-use crate::ty::subst::{Subst, Substs};
+use crate::ty::subst::{Subst, InternalSubsts};
 use crate::ty::{self, ToPredicate, ToPolyTraitRef, Ty, TyCtxt};
 use crate::ty::fold::{TypeFoldable, TypeFolder};
 use crate::util::common::FN_OUTPUT_NAME;
@@ -401,7 +401,7 @@ fn fold_const(&mut self, constant: &'tcx ty::LazyConst<'tcx>) -> &'tcx ty::LazyC
             let tcx = self.selcx.tcx().global_tcx();
             if let Some(param_env) = self.tcx().lift_to_global(&self.param_env) {
                 if substs.needs_infer() || substs.has_placeholders() {
-                    let identity_substs = Substs::identity_for_item(tcx, def_id);
+                    let identity_substs = InternalSubsts::identity_for_item(tcx, def_id);
                     let instance = ty::Instance::resolve(tcx, param_env, def_id, identity_substs);
                     if let Some(instance) = instance {
                         let cid = GlobalId {
@@ -1490,7 +1490,7 @@ fn confirm_impl_candidate<'cx, 'gcx, 'tcx>(
     }
     let substs = translate_substs(selcx.infcx(), param_env, impl_def_id, substs, assoc_ty.node);
     let ty = if let ty::AssociatedKind::Existential = assoc_ty.item.kind {
-        let item_substs = Substs::identity_for_item(tcx, assoc_ty.item.def_id);
+        let item_substs = InternalSubsts::identity_for_item(tcx, assoc_ty.item.def_id);
         tcx.mk_opaque(assoc_ty.item.def_id, item_substs)
     } else {
         tcx.type_of(assoc_ty.item.def_id)
index 224076ce17e72c29c114233c3083d3c9b7923276..8a30c18d6e5f7fc565b638e93973acdc4ae829c2 100644 (file)
@@ -9,7 +9,7 @@
 use crate::traits::project::Normalized;
 use crate::traits::{Obligation, ObligationCause, PredicateObligation, Reveal};
 use crate::ty::fold::{TypeFoldable, TypeFolder};
-use crate::ty::subst::{Subst, Substs};
+use crate::ty::subst::{Subst, InternalSubsts};
 use crate::ty::{self, Ty, TyCtxt};
 
 use super::NoSolution;
@@ -193,7 +193,7 @@ fn fold_const(&mut self, constant: &'tcx ty::LazyConst<'tcx>) -> &'tcx ty::LazyC
             let tcx = self.infcx.tcx.global_tcx();
             if let Some(param_env) = self.tcx().lift_to_global(&self.param_env) {
                 if substs.needs_infer() || substs.has_placeholders() {
-                    let identity_substs = Substs::identity_for_item(tcx, def_id);
+                    let identity_substs = InternalSubsts::identity_for_item(tcx, def_id);
                     let instance = ty::Instance::resolve(tcx, param_env, def_id, identity_substs);
                     if let Some(instance) = instance {
                         let cid = GlobalId {
index 05fb40ac10a075147dd6927596103df34214d14b..e7cc9618080c2689f0196b84364dfcc4126612ec 100644 (file)
@@ -34,7 +34,7 @@
 use crate::mir::interpret::GlobalId;
 use crate::ty::fast_reject;
 use crate::ty::relate::TypeRelation;
-use crate::ty::subst::{Subst, Substs};
+use crate::ty::subst::{Subst, SubstsRef};
 use crate::ty::{self, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, TypeFoldable};
 
 use crate::hir;
@@ -1944,7 +1944,7 @@ fn assemble_fn_pointer_candidates(
                 if let ty::FnSig {
                     unsafety: hir::Unsafety::Normal,
                     abi: Abi::Rust,
-                    variadic: false,
+                    c_variadic: false,
                     ..
                 } = self_ty.fn_sig(self.tcx()).skip_binder()
                 {
@@ -2944,7 +2944,7 @@ fn confirm_impl_candidate(
     fn vtable_impl(
         &mut self,
         impl_def_id: DefId,
-        mut substs: Normalized<'tcx, &'tcx Substs<'tcx>>,
+        mut substs: Normalized<'tcx, SubstsRef<'tcx>>,
         cause: ObligationCause<'tcx>,
         recursion_depth: usize,
         param_env: ty::ParamEnv<'tcx>,
@@ -3538,7 +3538,7 @@ fn rematch_impl(
         impl_def_id: DefId,
         obligation: &TraitObligation<'tcx>,
         snapshot: &CombinedSnapshot<'_, 'tcx>,
-    ) -> Normalized<'tcx, &'tcx Substs<'tcx>> {
+    ) -> Normalized<'tcx, SubstsRef<'tcx>> {
         match self.match_impl(impl_def_id, obligation, snapshot) {
             Ok(substs) => substs,
             Err(()) => {
@@ -3556,7 +3556,7 @@ fn match_impl(
         impl_def_id: DefId,
         obligation: &TraitObligation<'tcx>,
         snapshot: &CombinedSnapshot<'_, 'tcx>,
-    ) -> Result<Normalized<'tcx, &'tcx Substs<'tcx>>, ()> {
+    ) -> Result<Normalized<'tcx, SubstsRef<'tcx>>, ()> {
         let impl_trait_ref = self.tcx().impl_trait_ref(impl_def_id).unwrap();
 
         // Before we create the substitutions and everything, first
@@ -3761,7 +3761,7 @@ fn impl_or_trait_obligations(
         recursion_depth: usize,
         param_env: ty::ParamEnv<'tcx>,
         def_id: DefId,         // of impl or trait
-        substs: &Substs<'tcx>, // for impl or trait
+        substs: SubstsRef<'tcx>,  // for impl or trait
     ) -> Vec<PredicateObligation<'tcx>> {
         debug!("impl_or_trait_obligations(def_id={:?})", def_id);
         let tcx = self.tcx();
index 804f1b9d820a2c983b95d361abb5d1af8dcf56c9..a2924cb993fbf6f2039b5eeeb1e07663c3ea5a8b 100644 (file)
@@ -20,7 +20,7 @@
 use syntax_pos::DUMMY_SP;
 use crate::traits::select::IntercrateAmbiguityCause;
 use crate::ty::{self, TyCtxt, TypeFoldable};
-use crate::ty::subst::{Subst, Substs};
+use crate::ty::subst::{Subst, InternalSubsts, SubstsRef};
 
 use super::{SelectionContext, FulfillmentContext};
 use super::util::impl_trait_ref_and_oblig;
@@ -73,9 +73,9 @@ pub struct OverlapError {
 pub fn translate_substs<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
                                         param_env: ty::ParamEnv<'tcx>,
                                         source_impl: DefId,
-                                        source_substs: &'tcx Substs<'tcx>,
+                                        source_substs: SubstsRef<'tcx>,
                                         target_node: specialization_graph::Node)
-                                        -> &'tcx Substs<'tcx> {
+                                        -> SubstsRef<'tcx> {
     debug!("translate_substs({:?}, {:?}, {:?}, {:?})",
            param_env, source_impl, source_substs, target_node);
     let source_trait_ref = infcx.tcx
@@ -114,9 +114,9 @@ pub fn find_associated_item<'a, 'tcx>(
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
     param_env: ty::ParamEnv<'tcx>,
     item: &ty::AssociatedItem,
-    substs: &'tcx Substs<'tcx>,
+    substs: SubstsRef<'tcx>,
     impl_data: &super::VtableImplData<'tcx, ()>,
-) -> (DefId, &'tcx Substs<'tcx>) {
+) -> (DefId, SubstsRef<'tcx>) {
     debug!("find_associated_item({:?}, {:?}, {:?}, {:?})",
            param_env, item, substs, impl_data);
     assert!(!substs.needs_infer());
@@ -214,7 +214,7 @@ fn fulfill_implication<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
                                        param_env: ty::ParamEnv<'tcx>,
                                        source_trait_ref: ty::TraitRef<'tcx>,
                                        target_impl: DefId)
-                                       -> Result<&'tcx Substs<'tcx>, ()> {
+                                       -> Result<SubstsRef<'tcx>, ()> {
     debug!("fulfill_implication({:?}, trait_ref={:?} |- {:?} applies)",
            param_env, source_trait_ref, target_impl);
 
@@ -334,9 +334,9 @@ pub(super) fn specialization_graph_provider<'a, 'tcx>(
                         FutureCompatOverlapErrorKind::Issue33140 =>
                             lint::builtin::ORDER_DEPENDENT_TRAIT_OBJECTS,
                     };
-                    tcx.struct_span_lint_node(
+                    tcx.struct_span_lint_hir(
                         lint,
-                        tcx.hir().as_local_node_id(impl_def_id).unwrap(),
+                        tcx.hir().as_local_hir_id(impl_def_id).unwrap(),
                         impl_span,
                         &msg)
                 } else {
@@ -399,7 +399,7 @@ fn to_pretty_impl_header(tcx: TyCtxt<'_, '_, '_>, impl_def_id: DefId) -> Option<
 
     let mut w = "impl".to_owned();
 
-    let substs = Substs::identity_for_item(tcx, impl_def_id);
+    let substs = InternalSubsts::identity_for_item(tcx, impl_def_id);
 
     // FIXME: Currently only handles ?Sized.
     //        Needs to support ?Move and ?DynSized when they are implemented.
index 754cc94073b1067afdb3ae39ab20607e2948fe15..c3223f0cd6331d9c8c1088b9b51d58384294a033 100644 (file)
@@ -3,7 +3,7 @@
 use crate::traits::specialize::specialization_graph::NodeItem;
 use crate::ty::{self, Ty, TyCtxt, ToPredicate, ToPolyTraitRef};
 use crate::ty::outlives::Component;
-use crate::ty::subst::{Kind, Subst, Substs};
+use crate::ty::subst::{Kind, Subst, SubstsRef};
 use crate::util::nodemap::FxHashSet;
 
 use super::{Obligation, ObligationCause, PredicateObligation, SelectionContext, Normalized};
@@ -358,7 +358,7 @@ fn size_hint(&self) -> (usize, Option<usize>) {
 pub fn impl_trait_ref_and_oblig<'a, 'gcx, 'tcx>(selcx: &mut SelectionContext<'a, 'gcx, 'tcx>,
                                                 param_env: ty::ParamEnv<'tcx>,
                                                 impl_def_id: DefId,
-                                                impl_substs: &Substs<'tcx>)
+                                                impl_substs: SubstsRef<'tcx>,)
                                                 -> (ty::TraitRef<'tcx>,
                                                     Vec<PredicateObligation<'tcx>>)
 {
index ff4fc87542dc35862bad1656c12f8b55d292ed5f..8d449f5c44cf4b246d56d5700a9db6c8c6af8104 100644 (file)
@@ -1,7 +1,7 @@
 use crate::hir;
 use crate::hir::def_id::DefId;
 use crate::ty::{self, Ty, TyCtxt};
-use crate::ty::subst::Substs;
+use crate::ty::subst::SubstsRef;
 
 
 /// Represents coercing a value to a different type of value.
@@ -98,7 +98,7 @@ pub struct OverloadedDeref<'tcx> {
 
 impl<'a, 'gcx, 'tcx> OverloadedDeref<'tcx> {
     pub fn method_call(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, source: Ty<'tcx>)
-                       -> (DefId, &'tcx Substs<'tcx>) {
+                       -> (DefId, SubstsRef<'tcx>) {
         let trait_def_id = match self.mutbl {
             hir::MutImmutable => tcx.lang_items().deref_trait(),
             hir::MutMutable => tcx.lang_items().deref_mut_trait()
index e93de32f7257b06168107c3f765d2c68d1b940af..3ab744ebaeb17d0541961cb90bf347054428f2d0 100644 (file)
@@ -13,7 +13,7 @@
 use std::hash::Hash;
 use std::intrinsics;
 use crate::ty::{self, Ty, TyCtxt};
-use crate::ty::subst::Substs;
+use crate::ty::subst::SubstsRef;
 use crate::mir::interpret::Allocation;
 
 /// The shorthand encoding uses an enum's variant index `usize`
@@ -185,7 +185,7 @@ pub fn decode_predicates<'a, 'tcx, D>(decoder: &mut D)
 }
 
 #[inline]
-pub fn decode_substs<'a, 'tcx, D>(decoder: &mut D) -> Result<&'tcx Substs<'tcx>, D::Error>
+pub fn decode_substs<'a, 'tcx, D>(decoder: &mut D) -> Result<SubstsRef<'tcx>, D::Error>
     where D: TyDecoder<'a, 'tcx>,
           'tcx: 'a,
 {
@@ -281,7 +281,7 @@ mod __ty_decoder_impl {
             use $crate::infer::canonical::CanonicalVarInfos;
             use $crate::ty;
             use $crate::ty::codec::*;
-            use $crate::ty::subst::Substs;
+            use $crate::ty::subst::SubstsRef;
             use $crate::hir::def_id::{CrateNum};
             use crate::rustc_serialize::{Decoder, SpecializedDecoder};
             use std::borrow::Cow;
@@ -344,9 +344,9 @@ fn specialized_decode(&mut self)
                 }
             }
 
-            impl<$($typaram),*> SpecializedDecoder<&'tcx Substs<'tcx>>
+            impl<$($typaram),*> SpecializedDecoder<SubstsRef<'tcx>>
             for $DecoderName<$($typaram),*> {
-                fn specialized_decode(&mut self) -> Result<&'tcx Substs<'tcx>, Self::Error> {
+                fn specialized_decode(&mut self) -> Result<SubstsRef<'tcx>, Self::Error> {
                     decode_substs(self)
                 }
             }
index a71c0d4ab963dd6ec830f6f1f032cd43c0e0e594..1983dfbd4b7d16f06ae37b07deb8741d5b073e75 100644 (file)
@@ -22,7 +22,7 @@
 use crate::middle::stability;
 use crate::mir::{self, Mir, interpret, ProjectionKind};
 use crate::mir::interpret::Allocation;
-use crate::ty::subst::{Kind, Substs, Subst};
+use crate::ty::subst::{Kind, InternalSubsts, Subst, SubstsRef};
 use crate::ty::ReprOptions;
 use crate::traits;
 use crate::traits::{Clause, Clauses, GoalKind, Goal, Goals};
@@ -50,7 +50,7 @@
                                            StableVec};
 use arena::{TypedArena, SyncDroplessArena};
 use rustc_data_structures::indexed_vec::{Idx, IndexVec};
-use rustc_data_structures::sync::{self, Lrc, Lock, WorkerLocal};
+use rustc_data_structures::sync::{Lrc, Lock, WorkerLocal};
 use std::any::Any;
 use std::borrow::Borrow;
 use std::cmp::Ordering;
@@ -65,7 +65,7 @@
 use std::sync::Arc;
 use std::marker::PhantomData;
 use rustc_target::spec::abi;
-use syntax::ast::{self, NodeId};
+use syntax::ast;
 use syntax::attr;
 use syntax::source_map::MultiSpan;
 use syntax::edition::Edition;
@@ -118,7 +118,7 @@ pub struct CtxtInterners<'tcx> {
     /// they're accessed quite often.
     type_: InternedSet<'tcx, TyS<'tcx>>,
     type_list: InternedSet<'tcx, List<Ty<'tcx>>>,
-    substs: InternedSet<'tcx, Substs<'tcx>>,
+    substs: InternedSet<'tcx, InternalSubsts<'tcx>>,
     canonical_var_infos: InternedSet<'tcx, List<CanonicalVarInfo>>,
     region: InternedSet<'tcx, RegionKind>,
     existential_predicates: InternedSet<'tcx, List<ExistentialPredicate<'tcx>>>,
@@ -325,7 +325,7 @@ pub struct ResolvedOpaqueTy<'tcx> {
     /// Generic parameters on the opaque type as passed by this function.
     /// For `existential type Foo<A, B>; fn foo<T, U>() -> Foo<T, U> { .. }` this is `[T, U]`, not
     /// `[A, B]`
-    pub substs: &'tcx Substs<'tcx>,
+    pub substs: SubstsRef<'tcx>,
 }
 
 #[derive(RustcEncodable, RustcDecodable, Debug)]
@@ -352,7 +352,7 @@ pub struct TypeckTables<'tcx> {
     /// of this node. This only applies to nodes that refer to entities
     /// parameterized by type parameters, such as generic fns, types, or
     /// other items.
-    node_substs: ItemLocalMap<&'tcx Substs<'tcx>>,
+    node_substs: ItemLocalMap<SubstsRef<'tcx>>,
 
     /// This will either store the canonicalized types provided by the user
     /// or the substitutions that the user explicitly gave (if any) attached
@@ -548,19 +548,19 @@ pub fn node_type_opt(&self, id: hir::HirId) -> Option<Ty<'tcx>> {
         self.node_types.get(&id.local_id).cloned()
     }
 
-    pub fn node_substs_mut(&mut self) -> LocalTableInContextMut<'_, &'tcx Substs<'tcx>> {
+    pub fn node_substs_mut(&mut self) -> LocalTableInContextMut<'_, SubstsRef<'tcx>> {
         LocalTableInContextMut {
             local_id_root: self.local_id_root,
             data: &mut self.node_substs
         }
     }
 
-    pub fn node_substs(&self, id: hir::HirId) -> &'tcx Substs<'tcx> {
+    pub fn node_substs(&self, id: hir::HirId) -> SubstsRef<'tcx> {
         validate_hir_id_for_typeck_tables(self.local_id_root, id, false);
-        self.node_substs.get(&id.local_id).cloned().unwrap_or_else(|| Substs::empty())
+        self.node_substs.get(&id.local_id).cloned().unwrap_or_else(|| InternalSubsts::empty())
     }
 
-    pub fn node_substs_opt(&self, id: hir::HirId) -> Option<&'tcx Substs<'tcx>> {
+    pub fn node_substs_opt(&self, id: hir::HirId) -> Option<SubstsRef<'tcx>> {
         validate_hir_id_for_typeck_tables(self.local_id_root, id, false);
         self.node_substs.get(&id.local_id).cloned()
     }
@@ -1285,8 +1285,6 @@ pub fn create_and_enter<F, R>(s: &'tcx Session,
 
         let gcx = arenas.global_ctxt.as_ref().unwrap();
 
-        sync::assert_send_val(&gcx);
-
         let r = tls::enter_global(gcx, f);
 
         gcx.queries.record_computed_queries(s);
@@ -1733,7 +1731,7 @@ pub fn enter_local<'tcx, F, R>(
 /// A trait implemented for all X<'a> types which can be safely and
 /// efficiently converted to X<'tcx> as long as they are part of the
 /// provided TyCtxt<'tcx>.
-/// This can be done, for example, for Ty<'tcx> or &'tcx Substs<'tcx>
+/// This can be done, for example, for Ty<'tcx> or SubstsRef<'tcx>
 /// by looking them up in their respective interners.
 ///
 /// However, this is still not the best implementation as it does
@@ -1807,7 +1805,7 @@ fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lif
 nop_list_lift!{CanonicalVarInfo => CanonicalVarInfo}
 nop_list_lift!{ProjectionKind<'a> => ProjectionKind<'tcx>}
 
-// this is the impl for `&'a Substs<'a>`
+// this is the impl for `&'a InternalSubsts<'a>`
 nop_list_lift!{Kind<'a> => Kind<'tcx>}
 
 impl<'a, 'tcx> Lift<'tcx> for &'a mir::interpret::Allocation {
@@ -2183,7 +2181,7 @@ pub fn print_debug_stats(self) {
             Generator, GeneratorWitness, Dynamic, Closure, Tuple, Bound,
             Param, Infer, UnnormalizedProjection, Projection, Opaque, Foreign);
 
-        println!("Substs interner: #{}", self.interners.substs.borrow().len());
+        println!("InternalSubsts interner: #{}", self.interners.substs.borrow().len());
         println!("Region interner: #{}", self.interners.region.borrow().len());
         println!("Stability interner: #{}", self.stability_interner.borrow().len());
         println!("Allocation interner: #{}", self.allocation_interner.borrow().len());
@@ -2250,7 +2248,7 @@ fn borrow<'a>(&'a self) -> &'a [CanonicalVarInfo] {
     }
 }
 
-impl<'tcx: 'lcx, 'lcx> Borrow<[Kind<'lcx>]> for Interned<'tcx, Substs<'tcx>> {
+impl<'tcx: 'lcx, 'lcx> Borrow<[Kind<'lcx>]> for Interned<'tcx, InternalSubsts<'tcx>> {
     fn borrow<'a>(&'a self) -> &'a [Kind<'lcx>] {
         &self.0[..]
     }
@@ -2453,7 +2451,7 @@ pub fn coerce_closure_fn_ty(self, sig: PolyFnSig<'tcx>) -> Ty<'tcx> {
             self.mk_fn_sig(
                 params_iter,
                 s.output(),
-                s.variadic,
+                s.c_variadic,
                 hir::Unsafety::Normal,
                 abi::Abi::Rust,
             )
@@ -2507,7 +2505,7 @@ pub fn mk_static_str(self) -> Ty<'tcx> {
     }
 
     #[inline]
-    pub fn mk_adt(self, def: &'tcx AdtDef, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> {
+    pub fn mk_adt(self, def: &'tcx AdtDef, substs: SubstsRef<'tcx>) -> Ty<'tcx> {
         // take a copy of substs so that we own the vectors inside
         self.mk_ty(Adt(def, substs))
     }
@@ -2520,7 +2518,7 @@ pub fn mk_foreign(self, def_id: DefId) -> Ty<'tcx> {
     pub fn mk_box(self, ty: Ty<'tcx>) -> Ty<'tcx> {
         let def_id = self.require_lang_item(lang_items::OwnedBoxLangItem);
         let adt_def = self.adt_def(def_id);
-        let substs = Substs::for_item(self, def_id, |param, substs| {
+        let substs = InternalSubsts::for_item(self, def_id, |param, substs| {
             match param.kind {
                 GenericParamDefKind::Lifetime => bug!(),
                 GenericParamDefKind::Type { has_default, .. } => {
@@ -2613,7 +2611,7 @@ pub fn mk_bool(self) -> Ty<'tcx> {
 
     #[inline]
     pub fn mk_fn_def(self, def_id: DefId,
-                     substs: &'tcx Substs<'tcx>) -> Ty<'tcx> {
+                     substs: SubstsRef<'tcx>) -> Ty<'tcx> {
         self.mk_ty(FnDef(def_id, substs))
     }
 
@@ -2634,7 +2632,7 @@ pub fn mk_dynamic(
     #[inline]
     pub fn mk_projection(self,
                          item_def_id: DefId,
-                         substs: &'tcx Substs<'tcx>)
+                         substs: SubstsRef<'tcx>)
         -> Ty<'tcx> {
             self.mk_ty(Projection(ProjectionTy {
                 item_def_id,
@@ -2704,7 +2702,7 @@ pub fn mk_param_from_def(self, param: &ty::GenericParamDef) -> Kind<'tcx> {
     }
 
     #[inline]
-    pub fn mk_opaque(self, def_id: DefId, substs: &'tcx Substs<'tcx>) -> Ty<'tcx> {
+    pub fn mk_opaque(self, def_id: DefId, substs: SubstsRef<'tcx>) -> Ty<'tcx> {
         self.mk_ty(Opaque(def_id, substs))
     }
 
@@ -2779,7 +2777,7 @@ pub fn intern_goals(self, ts: &[Goal<'tcx>]) -> Goals<'tcx> {
     pub fn mk_fn_sig<I>(self,
                         inputs: I,
                         output: I::Item,
-                        variadic: bool,
+                        c_variadic: bool,
                         unsafety: hir::Unsafety,
                         abi: abi::Abi)
         -> <I::Item as InternIteratorElement<Ty<'tcx>, ty::FnSig<'tcx>>>::Output
@@ -2788,7 +2786,7 @@ pub fn mk_fn_sig<I>(self,
     {
         inputs.chain(iter::once(output)).intern_with(|xs| ty::FnSig {
             inputs_and_output: self.intern_type_list(xs),
-            variadic, unsafety, abi
+            c_variadic, unsafety, abi
         })
     }
 
@@ -2817,7 +2815,7 @@ pub fn mk_substs<I: InternAs<[Kind<'tcx>],
     pub fn mk_substs_trait(self,
                      self_ty: Ty<'tcx>,
                      rest: &[Kind<'tcx>])
-                    -> &'tcx Substs<'tcx>
+                    -> SubstsRef<'tcx>
     {
         self.mk_substs(iter::once(self_ty.into()).chain(rest.iter().cloned()))
     }
@@ -2838,14 +2836,6 @@ pub fn lint_hir<S: Into<MultiSpan>>(self,
         self.struct_span_lint_hir(lint, hir_id, span.into(), msg).emit()
     }
 
-    pub fn lint_node<S: Into<MultiSpan>>(self,
-                                         lint: &'static Lint,
-                                         id: NodeId,
-                                         span: S,
-                                         msg: &str) {
-        self.struct_span_lint_node(lint, id, span.into(), msg).emit()
-    }
-
     pub fn lint_hir_note<S: Into<MultiSpan>>(self,
                                              lint: &'static Lint,
                                              hir_id: HirId,
@@ -2868,7 +2858,7 @@ pub fn lint_node_note<S: Into<MultiSpan>>(self,
         err.emit()
     }
 
-    pub fn lint_level_at_node(self, lint: &'static Lint, mut id: NodeId)
+    pub fn lint_level_at_node(self, lint: &'static Lint, mut id: hir::HirId)
         -> (lint::Level, lint::LintSource)
     {
         // Right now we insert a `with_ignore` node in the dep graph here to
@@ -2882,11 +2872,10 @@ pub fn lint_level_at_node(self, lint: &'static Lint, mut id: NodeId)
         self.dep_graph.with_ignore(|| {
             let sets = self.lint_levels(LOCAL_CRATE);
             loop {
-                let hir_id = self.hir().definitions().node_to_hir_id(id);
-                if let Some(pair) = sets.level_and_source(lint, hir_id, self.sess) {
+                if let Some(pair) = sets.level_and_source(lint, id, self.sess) {
                     return pair
                 }
-                let next = self.hir().get_parent_node(id);
+                let next = self.hir().get_parent_node_by_hir_id(id);
                 if next == id {
                     bug!("lint traversal reached the root of the crate");
                 }
@@ -2902,23 +2891,11 @@ pub fn struct_span_lint_hir<S: Into<MultiSpan>>(self,
                                                     msg: &str)
         -> DiagnosticBuilder<'tcx>
     {
-        let node_id = self.hir().hir_to_node_id(hir_id);
-        let (level, src) = self.lint_level_at_node(lint, node_id);
-        lint::struct_lint_level(self.sess, lint, level, src, Some(span.into()), msg)
-    }
-
-    pub fn struct_span_lint_node<S: Into<MultiSpan>>(self,
-                                                     lint: &'static Lint,
-                                                     id: NodeId,
-                                                     span: S,
-                                                     msg: &str)
-        -> DiagnosticBuilder<'tcx>
-    {
-        let (level, src) = self.lint_level_at_node(lint, id);
+        let (level, src) = self.lint_level_at_node(lint, hir_id);
         lint::struct_lint_level(self.sess, lint, level, src, Some(span.into()), msg)
     }
 
-    pub fn struct_lint_node(self, lint: &'static Lint, id: NodeId, msg: &str)
+    pub fn struct_lint_node(self, lint: &'static Lint, id: HirId, msg: &str)
         -> DiagnosticBuilder<'tcx>
     {
         let (level, src) = self.lint_level_at_node(lint, id);
index 25ec3e49cdf67361f2ccf2f56166f36a17632992..2b12dcca93ad7c7a1022c66d3030aaf90b9b5336 100644 (file)
@@ -1,4 +1,4 @@
-use crate::ty::subst::Substs;
+use crate::ty::subst::SubstsRef;
 use crate::ty::{self, Ty, TypeFlags, TypeFoldable};
 
 #[derive(Debug)]
@@ -241,7 +241,7 @@ fn add_projection_ty(&mut self, projection_ty: &ty::ProjectionTy<'_>) {
         self.add_substs(projection_ty.substs);
     }
 
-    fn add_substs(&mut self, substs: &Substs<'_>) {
+    fn add_substs(&mut self, substs: SubstsRef<'_>) {
         for ty in substs.types() {
             self.add_ty(ty);
         }
index 601ffe70eec18ce07a711c7bdac02e560a3f623b..33ec9c874f9ef1e5e4f3ecd4907bb8ff7c87a22d 100644 (file)
@@ -1,6 +1,6 @@
 use crate::ty::context::TyCtxt;
 use crate::ty::{AdtDef, VariantDef, FieldDef, Ty, TyS};
-use crate::ty::{self, DefId, Substs};
+use crate::ty::{self, DefId, SubstsRef};
 use crate::ty::{AdtKind, Visibility};
 use crate::ty::TyKind::*;
 
@@ -108,7 +108,7 @@ fn ty_inhabitedness_forest(self, ty: Ty<'tcx>) -> DefIdForest {
     pub fn is_enum_variant_uninhabited_from(self,
                                             module: DefId,
                                             variant: &'tcx VariantDef,
-                                            substs: &'tcx Substs<'tcx>)
+                                            substs: SubstsRef<'tcx>)
                                             -> bool
     {
         self.variant_inhabitedness_forest(variant, substs).contains(self, module)
@@ -116,13 +116,13 @@ pub fn is_enum_variant_uninhabited_from(self,
 
     pub fn is_variant_uninhabited_from_all_modules(self,
                                                    variant: &'tcx VariantDef,
-                                                   substs: &'tcx Substs<'tcx>)
+                                                   substs: SubstsRef<'tcx>)
                                                    -> bool
     {
         !self.variant_inhabitedness_forest(variant, substs).is_empty()
     }
 
-    fn variant_inhabitedness_forest(self, variant: &'tcx VariantDef, substs: &'tcx Substs<'tcx>)
+    fn variant_inhabitedness_forest(self, variant: &'tcx VariantDef, substs: SubstsRef<'tcx>)
                                     -> DefIdForest {
         // Determine the ADT kind:
         let adt_def_id = self.adt_def_id_of_variant(variant);
@@ -138,7 +138,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
     fn uninhabited_from(
         &self,
         tcx: TyCtxt<'a, 'gcx, 'tcx>,
-        substs: &'tcx Substs<'tcx>) -> DefIdForest
+        substs: SubstsRef<'tcx>) -> DefIdForest
     {
         DefIdForest::intersection(tcx, self.variants.iter().map(|v| {
             v.uninhabited_from(tcx, substs, self.adt_kind())
@@ -151,7 +151,7 @@ impl<'a, 'gcx, 'tcx> VariantDef {
     fn uninhabited_from(
         &self,
         tcx: TyCtxt<'a, 'gcx, 'tcx>,
-        substs: &'tcx Substs<'tcx>,
+        substs: SubstsRef<'tcx>,
         adt_kind: AdtKind) -> DefIdForest
     {
         let is_enum = match adt_kind {
@@ -172,7 +172,7 @@ impl<'a, 'gcx, 'tcx> FieldDef {
     fn uninhabited_from(
         &self,
         tcx: TyCtxt<'a, 'gcx, 'tcx>,
-        substs: &'tcx Substs<'tcx>,
+        substs: SubstsRef<'tcx>,
         is_enum: bool,
     ) -> DefIdForest {
         let data_uninhabitedness = move || {
index 5fc22e3c02b60cf5502d82529e6ed784c17e2c9c..49ebd202813f636b7518493d91a746b15eae453c 100644 (file)
@@ -1,6 +1,6 @@
 use crate::hir::Unsafety;
 use crate::hir::def_id::DefId;
-use crate::ty::{self, Ty, PolyFnSig, TypeFoldable, Substs, TyCtxt};
+use crate::ty::{self, Ty, PolyFnSig, TypeFoldable, SubstsRef, TyCtxt};
 use crate::traits;
 use rustc_target::spec::abi::Abi;
 use crate::util::ppaux;
@@ -11,7 +11,7 @@
 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)]
 pub struct Instance<'tcx> {
     pub def: InstanceDef<'tcx>,
-    pub substs: &'tcx Substs<'tcx>,
+    pub substs: SubstsRef<'tcx>,
 }
 
 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, RustcEncodable, RustcDecodable)]
@@ -65,7 +65,7 @@ fn fn_sig_noadjust(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> PolyFnSig<'tcx> {
                 sig.map_bound(|sig| tcx.mk_fn_sig(
                     iter::once(*env_ty.skip_binder()).chain(sig.inputs().iter().cloned()),
                     sig.output(),
-                    sig.variadic,
+                    sig.c_variadic,
                     sig.unsafety,
                     sig.abi
                 ))
@@ -203,7 +203,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 }
 
 impl<'a, 'b, 'tcx> Instance<'tcx> {
-    pub fn new(def_id: DefId, substs: &'tcx Substs<'tcx>)
+    pub fn new(def_id: DefId, substs: SubstsRef<'tcx>)
                -> Instance<'tcx> {
         assert!(!substs.has_escaping_bound_vars(),
                 "substs of instance {:?} not normalized for codegen: {:?}",
@@ -241,7 +241,7 @@ pub fn def_id(&self) -> DefId {
     pub fn resolve(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                    param_env: ty::ParamEnv<'tcx>,
                    def_id: DefId,
-                   substs: &'tcx Substs<'tcx>) -> Option<Instance<'tcx>> {
+                   substs: SubstsRef<'tcx>) -> Option<Instance<'tcx>> {
         debug!("resolve(def_id={:?}, substs={:?})", def_id, substs);
         let result = if let Some(trait_def_id) = tcx.trait_of_item(def_id) {
             debug!(" => associated item, attempting to find impl in param_env {:#?}", param_env);
@@ -293,7 +293,7 @@ pub fn resolve(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     pub fn resolve_for_vtable(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                               param_env: ty::ParamEnv<'tcx>,
                               def_id: DefId,
-                              substs: &'tcx Substs<'tcx>) -> Option<Instance<'tcx>> {
+                              substs: SubstsRef<'tcx>) -> Option<Instance<'tcx>> {
         debug!("resolve(def_id={:?}, substs={:?})", def_id, substs);
         let fn_sig = tcx.fn_sig(def_id);
         let is_vtable_shim =
@@ -338,7 +338,7 @@ fn resolve_associated_item<'a, 'tcx>(
     trait_item: &ty::AssociatedItem,
     param_env: ty::ParamEnv<'tcx>,
     trait_id: DefId,
-    rcvr_substs: &'tcx Substs<'tcx>,
+    rcvr_substs: SubstsRef<'tcx>,
 ) -> Option<Instance<'tcx>> {
     let def_id = trait_item.def_id;
     debug!("resolve_associated_item(trait_item={:?}, \
index a3cf7bf488ee71ad0398cc66095f8b5f7428179e..5243c4dbfd209ea6787857c5697a5adc2d762203 100644 (file)
@@ -22,7 +22,7 @@
 use crate::traits::{self, Reveal};
 use crate::ty;
 use crate::ty::layout::VariantIdx;
-use crate::ty::subst::{Subst, Substs};
+use crate::ty::subst::{Subst, InternalSubsts, SubstsRef};
 use crate::ty::util::{IntTypeExt, Discr};
 use crate::ty::walk::TypeWalker;
 use crate::util::captures::Captures;
@@ -982,14 +982,14 @@ impl<'tcx> serialize::UseSpecializedEncodable for GenericPredicates<'tcx> {}
 impl<'tcx> serialize::UseSpecializedDecodable for GenericPredicates<'tcx> {}
 
 impl<'a, 'gcx, 'tcx> GenericPredicates<'tcx> {
-    pub fn instantiate(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, substs: &Substs<'tcx>)
+    pub fn instantiate(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, substs: SubstsRef<'tcx>)
                        -> InstantiatedPredicates<'tcx> {
         let mut instantiated = InstantiatedPredicates::empty();
         self.instantiate_into(tcx, &mut instantiated, substs);
         instantiated
     }
 
-    pub fn instantiate_own(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, substs: &Substs<'tcx>)
+    pub fn instantiate_own(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, substs: SubstsRef<'tcx>)
                            -> InstantiatedPredicates<'tcx> {
         InstantiatedPredicates {
             predicates: self.predicates.iter().map(|(p, _)| p.subst(tcx, substs)).collect(),
@@ -998,7 +998,7 @@ pub fn instantiate_own(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, substs: &Substs<'tcx>
 
     fn instantiate_into(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>,
                         instantiated: &mut InstantiatedPredicates<'tcx>,
-                        substs: &Substs<'tcx>) {
+                        substs: SubstsRef<'tcx>) {
         if let Some(def_id) = self.parent {
             tcx.predicates_of(def_id).instantiate_into(tcx, instantiated, substs);
         }
@@ -1067,7 +1067,7 @@ pub enum Predicate<'tcx> {
     Subtype(PolySubtypePredicate<'tcx>),
 
     /// Constant initializer must evaluate successfully.
-    ConstEvaluatable(DefId, &'tcx Substs<'tcx>),
+    ConstEvaluatable(DefId, SubstsRef<'tcx>),
 }
 
 /// The crate outlives map is computed during typeck and contains the
@@ -2261,7 +2261,7 @@ pub fn eval_explicit_discr(
     ) -> Option<Discr<'tcx>> {
         let param_env = ParamEnv::empty();
         let repr_type = self.repr.discr_type();
-        let substs = Substs::identity_for_item(tcx.global_tcx(), expr_did);
+        let substs = InternalSubsts::identity_for_item(tcx.global_tcx(), expr_did);
         let instance = ty::Instance::new(expr_did, substs);
         let cid = GlobalId {
             instance,
@@ -2463,7 +2463,7 @@ fn sized_constraint_for_ty(&self,
 }
 
 impl<'a, 'gcx, 'tcx> FieldDef {
-    pub fn ty(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, subst: &Substs<'tcx>) -> Ty<'tcx> {
+    pub fn ty(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, subst: SubstsRef<'tcx>) -> Ty<'tcx> {
         tcx.type_of(self.did).subst(tcx, subst)
     }
 }
index 1870812893c14a4abdb6ea27c0c7e328cfd83a56..feca0f7170ef3d11b5d7dd3444dcd01001cce48c 100644 (file)
@@ -9,7 +9,7 @@
     CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpSubtypeGoal,
 };
 use crate::ty::{self, ParamEnvAnd, Ty, TyCtxt};
-use crate::ty::subst::Substs;
+use crate::ty::subst::SubstsRef;
 use crate::ty::query::queries;
 use crate::ty::query::Query;
 use crate::ty::query::QueryCache;
@@ -611,6 +611,12 @@ fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> {
     }
 }
 
+impl<'tcx> QueryDescription<'tcx> for queries::analysis<'tcx> {
+    fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> {
+        "running analysis passes on this crate".into()
+    }
+}
+
 impl<'tcx> QueryDescription<'tcx> for queries::lint_levels<'tcx> {
     fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> {
         "computing the lint levels for items in this crate".into()
@@ -914,7 +920,7 @@ fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 }
 
 impl<'tcx> QueryDescription<'tcx> for queries::substitute_normalize_and_test_predicates<'tcx> {
-    fn describe(tcx: TyCtxt<'_, '_, '_>, key: (DefId, &'tcx Substs<'tcx>)) -> Cow<'static, str> {
+    fn describe(tcx: TyCtxt<'_, '_, '_>, key: (DefId, SubstsRef<'tcx>)) -> Cow<'static, str> {
         format!("testing substituted normalized predicates:`{}`", tcx.item_path_str(key.0)).into()
     }
 }
index 22211468412c1f1551d65b1df4457273de942327..8e68c9fa30431c13789630c95e6a37aa838f0f64 100644 (file)
@@ -7,6 +7,7 @@
 use rustc_data_structures::fx::FxHashSet;
 use rustc_data_structures::sync::{Lock, LockGuard, Lrc, Weak};
 use rustc_data_structures::OnDrop;
+use rustc_data_structures::jobserver;
 use syntax_pos::Span;
 
 use crate::ty::tls;
@@ -198,7 +199,11 @@ fn r#await(&self, waiter: &Lrc<QueryWaiter<'tcx>>) {
             // we have to be in the `wait` call. This is ensured by the deadlock handler
             // getting the self.info lock.
             rayon_core::mark_blocked();
+            jobserver::release_thread();
             waiter.condvar.wait(&mut info);
+            // Release the lock before we potentially block in `acquire_thread`
+            mem::drop(info);
+            jobserver::acquire_thread();
         }
     }
 
index f5eb7374cc19b445739a3b7f5d23bba044eeb49e..d353da801778d5999f6426caa0665af8da36bb6b 100644 (file)
@@ -4,7 +4,7 @@
 use crate::hir::def_id::{CrateNum, DefId, LOCAL_CRATE, DefIndex};
 use crate::traits;
 use crate::ty::{self, Ty, TyCtxt};
-use crate::ty::subst::Substs;
+use crate::ty::subst::SubstsRef;
 use crate::ty::fast_reject::SimplifiedType;
 use crate::mir;
 
@@ -109,7 +109,7 @@ fn default_span(&self, tcx: TyCtxt<'_, '_, '_>) -> Span {
     }
 }
 
-impl<'tcx> Key for (DefId, &'tcx Substs<'tcx>) {
+impl<'tcx> Key for (DefId, SubstsRef<'tcx>) {
     fn query_crate(&self) -> CrateNum {
         self.0.krate
     }
index 740875109d02923b5ce508f5cf20b9c042b69af8..197b9a71b0ac0f31b83b34a7de9a683fcfd959af 100644 (file)
@@ -19,7 +19,7 @@
 use crate::mir::mono::CodegenUnit;
 use crate::mir;
 use crate::mir::interpret::GlobalId;
-use crate::session::{CompileResult, CrateDisambiguator};
+use crate::session::CrateDisambiguator;
 use crate::session::config::{EntryFnType, OutputFilenames, OptLevel};
 use crate::traits::{self, Vtable};
 use crate::traits::query::{
@@ -36,8 +36,8 @@
 use crate::traits::Clauses;
 use crate::ty::{self, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt, AdtSizedConstraint};
 use crate::ty::steal::Steal;
-use crate::ty::subst::Substs;
 use crate::ty::util::NeedsDrop;
+use crate::ty::subst::SubstsRef;
 use crate::util::nodemap::{DefIdSet, DefIdMap, ItemLocalSet};
 use crate::util::common::{ErrorReported};
 use crate::util::profiling::ProfileCategory::*;
@@ -99,6 +99,9 @@
 // as they will raise an fatal error on query cycles instead.
 define_queries! { <'tcx>
     Other {
+        /// Run analysis passes on the crate
+        [] fn analysis: Analysis(CrateNum) -> Result<(), ErrorReported>,
+
         /// Records the type of every item.
         [] fn type_of: TypeOfItem(DefId) -> Ty<'tcx>,
 
     },
 
     TypeChecking {
-        [] fn typeck_item_bodies: typeck_item_bodies_dep_node(CrateNum) -> CompileResult,
+        [] fn typeck_item_bodies:
+                typeck_item_bodies_dep_node(CrateNum) -> Result<(), ErrorReported>,
 
         [] fn typeck_tables_of: TypeckTables(DefId) -> &'tcx ty::TypeckTables<'tcx>,
     },
 
     Other {
         [] fn vtable_methods: vtable_methods_node(ty::PolyTraitRef<'tcx>)
-                            -> Lrc<Vec<Option<(DefId, &'tcx Substs<'tcx>)>>>,
+                            -> Lrc<Vec<Option<(DefId, SubstsRef<'tcx>)>>>,
     },
 
     Codegen {
 
     Codegen {
         [] fn upstream_monomorphizations: UpstreamMonomorphizations(CrateNum)
-            -> Lrc<DefIdMap<Lrc<FxHashMap<&'tcx Substs<'tcx>, CrateNum>>>>,
+            -> Lrc<DefIdMap<Lrc<FxHashMap<SubstsRef<'tcx>, CrateNum>>>>,
         [] fn upstream_monomorphizations_for: UpstreamMonomorphizationsFor(DefId)
-            -> Option<Lrc<FxHashMap<&'tcx Substs<'tcx>, CrateNum>>>,
+            -> Option<Lrc<FxHashMap<SubstsRef<'tcx>, CrateNum>>>,
     },
 
     Other {
         >,
 
         [] fn substitute_normalize_and_test_predicates:
-            substitute_normalize_and_test_predicates_node((DefId, &'tcx Substs<'tcx>)) -> bool,
+            substitute_normalize_and_test_predicates_node((DefId, SubstsRef<'tcx>)) -> bool,
 
         [] fn method_autoderef_steps: MethodAutoderefSteps(
             CanonicalTyGoal<'tcx>
@@ -906,7 +910,7 @@ fn vtable_methods_node<'tcx>(trait_ref: ty::PolyTraitRef<'tcx>) -> DepConstructo
     DepConstructor::VtableMethods{ trait_ref }
 }
 
-fn substitute_normalize_and_test_predicates_node<'tcx>(key: (DefId, &'tcx Substs<'tcx>))
+fn substitute_normalize_and_test_predicates_node<'tcx>(key: (DefId, SubstsRef<'tcx>))
                                             -> DepConstructor<'tcx> {
     DepConstructor::SubstituteNormalizeAndTestPredicates { key }
 }
index 37cb6753ed5b211e2e52197aed00ebc3aeeaee7b..ebaa31d703f8e0195fa969b8cb1364fd0b83665d 100644 (file)
@@ -1357,6 +1357,7 @@ macro_rules! force {
         DepKind::CrateHash => { force!(crate_hash, krate!()); }
         DepKind::OriginalCrateName => { force!(original_crate_name, krate!()); }
         DepKind::ExtraFileName => { force!(extra_filename, krate!()); }
+        DepKind::Analysis => { force!(analysis, krate!()); }
 
         DepKind::AllTraitImplementations => {
             force!(all_trait_implementations, krate!());
index db248072d9b5009f7c7c426b14d00591b4173f5b..2940757fa905be45e68db9baa12418123ca595c8 100644 (file)
@@ -5,7 +5,7 @@
 //! subtyping, type equality, etc.
 
 use crate::hir::def_id::DefId;
-use crate::ty::subst::{Kind, UnpackedKind, Substs};
+use crate::ty::subst::{Kind, UnpackedKind, SubstsRef};
 use crate::ty::{self, Ty, TyCtxt, TypeFoldable};
 use crate::ty::error::{ExpectedFound, TypeError};
 use crate::mir::interpret::GlobalId;
@@ -50,9 +50,9 @@ fn relate<T: Relate<'tcx>>(&mut self, a: &T, b: &T) -> RelateResult<'tcx, T> {
     /// accordingly.
     fn relate_item_substs(&mut self,
                           item_def_id: DefId,
-                          a_subst: &'tcx Substs<'tcx>,
-                          b_subst: &'tcx Substs<'tcx>)
-                          -> RelateResult<'tcx, &'tcx Substs<'tcx>>
+                          a_subst: SubstsRef<'tcx>,
+                          b_subst: SubstsRef<'tcx>)
+                          -> RelateResult<'tcx, SubstsRef<'tcx>>
     {
         debug!("relate_item_substs(item_def_id={:?}, a_subst={:?}, b_subst={:?})",
                item_def_id,
@@ -123,9 +123,9 @@ fn relate<'a, 'gcx, R>(relation: &mut R,
 
 pub fn relate_substs<'a, 'gcx, 'tcx, R>(relation: &mut R,
                                         variances: Option<&Vec<ty::Variance>>,
-                                        a_subst: &'tcx Substs<'tcx>,
-                                        b_subst: &'tcx Substs<'tcx>)
-                                        -> RelateResult<'tcx, &'tcx Substs<'tcx>>
+                                        a_subst: SubstsRef<'tcx>,
+                                        b_subst: SubstsRef<'tcx>)
+                                        -> RelateResult<'tcx, SubstsRef<'tcx>>
     where R: TypeRelation<'a, 'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
 {
     let tcx = relation.tcx();
@@ -147,9 +147,9 @@ fn relate<'a, 'gcx, R>(relation: &mut R,
     {
         let tcx = relation.tcx();
 
-        if a.variadic != b.variadic {
+        if a.c_variadic != b.c_variadic {
             return Err(TypeError::VariadicMismatch(
-                expected_found(relation, &a.variadic, &b.variadic)));
+                expected_found(relation, &a.c_variadic, &b.c_variadic)));
         }
         let unsafety = relation.relate(&a.unsafety, &b.unsafety)?;
         let abi = relation.relate(&a.abi, &b.abi)?;
@@ -171,7 +171,7 @@ fn relate<'a, 'gcx, R>(relation: &mut R,
             });
         Ok(ty::FnSig {
             inputs_and_output: tcx.mk_type_list(inputs_and_output)?,
-            variadic: a.variadic,
+            c_variadic: a.c_variadic,
             unsafety,
             abi,
         })
@@ -624,11 +624,11 @@ fn relate<'a, 'gcx, R>(relation: &mut R,
     }
 }
 
-impl<'tcx> Relate<'tcx> for &'tcx Substs<'tcx> {
+impl<'tcx> Relate<'tcx> for SubstsRef<'tcx> {
     fn relate<'a, 'gcx, R>(relation: &mut R,
-                           a: &&'tcx Substs<'tcx>,
-                           b: &&'tcx Substs<'tcx>)
-                           -> RelateResult<'tcx, &'tcx Substs<'tcx>>
+                           a: &SubstsRef<'tcx>,
+                           b: &SubstsRef<'tcx>)
+                           -> RelateResult<'tcx, SubstsRef<'tcx>>
         where R: TypeRelation<'a, 'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
     {
         relate_substs(relation, None, a, b)
index a81d5c9d86edd1ae17bbe81fcdf52a26a1dfc25e..f1a465e1f1724b384b1c7df0dbe0671a73965f9b 100644 (file)
@@ -396,7 +396,7 @@ fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option<Self::Lif
         tcx.lift(&self.inputs_and_output).map(|x| {
             ty::FnSig {
                 inputs_and_output: x,
-                variadic: self.variadic,
+                c_variadic: self.c_variadic,
                 unsafety: self.unsafety,
                 abi: self.abi,
             }
@@ -832,7 +832,7 @@ impl<'tcx> TypeFoldable<'tcx> for ty::GenSig<'tcx> {
 
 BraceStructTypeFoldableImpl! {
     impl<'tcx> TypeFoldable<'tcx> for ty::FnSig<'tcx> {
-        inputs_and_output, variadic, unsafety, abi
+        inputs_and_output, c_variadic, unsafety, abi
     }
 }
 
index dd382ec006bd7437fa7b4d45d58ed584e6391a94..3fd2e38a3d3e51cd10baca00a68b8bd20bbf766c 100644 (file)
@@ -7,7 +7,7 @@
 use crate::middle::region;
 use polonius_engine::Atom;
 use rustc_data_structures::indexed_vec::Idx;
-use crate::ty::subst::{Substs, Subst, Kind, UnpackedKind};
+use crate::ty::subst::{InternalSubsts, Subst, SubstsRef, Kind, UnpackedKind};
 use crate::ty::{self, AdtDef, TypeFlags, Ty, TyCtxt, TypeFoldable};
 use crate::ty::{List, TyS, ParamEnvAnd, ParamEnv};
 use crate::util::captures::Captures;
@@ -101,11 +101,11 @@ pub enum TyKind<'tcx> {
 
     /// Structures, enumerations and unions.
     ///
-    /// Substs here, possibly against intuition, *may* contain `Param`s.
+    /// InternalSubsts here, possibly against intuition, *may* contain `Param`s.
     /// That is, even after substitution it is possible that there are type
     /// variables. This happens when the `Adt` corresponds to an ADT
     /// definition and not a concrete use of it.
-    Adt(&'tcx AdtDef, &'tcx Substs<'tcx>),
+    Adt(&'tcx AdtDef, SubstsRef<'tcx>),
 
     /// An unsized FFI type that is opaque to Rust. Written as `extern type T`.
     Foreign(DefId),
@@ -136,7 +136,7 @@ pub enum TyKind<'tcx> {
     /// fn foo() -> i32 { 1 }
     /// let bar = foo; // bar: fn() -> i32 {foo}
     /// ```
-    FnDef(DefId, &'tcx Substs<'tcx>),
+    FnDef(DefId, SubstsRef<'tcx>),
 
     /// A pointer to a function. Written as `fn() -> i32`.
     ///
@@ -184,7 +184,7 @@ pub enum TyKind<'tcx> {
     /// * or the `existential type` declaration
     /// The substitutions are for the generics of the function in question.
     /// After typeck, the concrete type can be found in the `types` map.
-    Opaque(DefId, &'tcx Substs<'tcx>),
+    Opaque(DefId, SubstsRef<'tcx>),
 
     /// A type parameter; for example, `T` in `fn f<T>(x: T) {}
     Param(ParamTy),
@@ -309,7 +309,7 @@ pub struct ClosureSubsts<'tcx> {
     ///
     /// These are separated out because codegen wants to pass them around
     /// when monomorphizing.
-    pub substs: &'tcx Substs<'tcx>,
+    pub substs: SubstsRef<'tcx>,
 }
 
 /// Struct returned by `split()`. Note that these are subslices of the
@@ -387,7 +387,7 @@ pub fn closure_sig(self, def_id: DefId, tcx: TyCtxt<'_, 'tcx, 'tcx>) -> ty::Poly
 
 #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, RustcEncodable, RustcDecodable)]
 pub struct GeneratorSubsts<'tcx> {
-    pub substs: &'tcx Substs<'tcx>,
+    pub substs: SubstsRef<'tcx>,
 }
 
 struct SplitGeneratorSubsts<'tcx> {
@@ -672,11 +672,11 @@ pub fn iter<'a>(&'a self)
 #[derive(Copy, Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
 pub struct TraitRef<'tcx> {
     pub def_id: DefId,
-    pub substs: &'tcx Substs<'tcx>,
+    pub substs: SubstsRef<'tcx>,
 }
 
 impl<'tcx> TraitRef<'tcx> {
-    pub fn new(def_id: DefId, substs: &'tcx Substs<'tcx>) -> TraitRef<'tcx> {
+    pub fn new(def_id: DefId, substs: SubstsRef<'tcx>) -> TraitRef<'tcx> {
         TraitRef { def_id: def_id, substs: substs }
     }
 
@@ -685,7 +685,7 @@ pub fn new(def_id: DefId, substs: &'tcx Substs<'tcx>) -> TraitRef<'tcx> {
     pub fn identity<'a, 'gcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>, def_id: DefId) -> TraitRef<'tcx> {
         TraitRef {
             def_id,
-            substs: Substs::identity_for_item(tcx, def_id),
+            substs: InternalSubsts::identity_for_item(tcx, def_id),
         }
     }
 
@@ -704,7 +704,7 @@ pub fn input_types<'a>(&'a self) -> impl DoubleEndedIterator<Item = Ty<'tcx>> +
 
     pub fn from_method(tcx: TyCtxt<'_, '_, 'tcx>,
                        trait_id: DefId,
-                       substs: &Substs<'tcx>)
+                       substs: SubstsRef<'tcx>)
                        -> ty::TraitRef<'tcx> {
         let defs = tcx.generics_of(trait_id);
 
@@ -742,7 +742,7 @@ pub fn to_poly_trait_predicate(&self) -> ty::PolyTraitPredicate<'tcx> {
 #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
 pub struct ExistentialTraitRef<'tcx> {
     pub def_id: DefId,
-    pub substs: &'tcx Substs<'tcx>,
+    pub substs: SubstsRef<'tcx>,
 }
 
 impl<'a, 'gcx, 'tcx> ExistentialTraitRef<'tcx> {
@@ -915,7 +915,7 @@ pub fn split<U,V,F>(self, f: F) -> (Binder<U>, Binder<V>)
 #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, RustcEncodable, RustcDecodable)]
 pub struct ProjectionTy<'tcx> {
     /// The parameters of the associated item.
-    pub substs: &'tcx Substs<'tcx>,
+    pub substs: SubstsRef<'tcx>,
 
     /// The `DefId` of the `TraitItem` for the associated type `N`.
     ///
@@ -977,13 +977,13 @@ pub fn return_ty(&self) -> ty::Binder<Ty<'tcx>> {
 /// Signature of a function type, which I have arbitrarily
 /// decided to use to refer to the input/output types.
 ///
-/// - `inputs` is the list of arguments and their modes.
-/// - `output` is the return type.
-/// - `variadic` indicates whether this is a variadic function. (only true for foreign fns)
+/// - `inputs`: is the list of arguments and their modes.
+/// - `output`: is the return type.
+/// - `c_variadic`: indicates whether this is a C-variadic function.
 #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable)]
 pub struct FnSig<'tcx> {
     pub inputs_and_output: &'tcx List<Ty<'tcx>>,
-    pub variadic: bool,
+    pub c_variadic: bool,
     pub unsafety: hir::Unsafety,
     pub abi: abi::Abi,
 }
@@ -1016,8 +1016,8 @@ pub fn inputs_and_output(&self) -> ty::Binder<&'tcx List<Ty<'tcx>>> {
     pub fn output(&self) -> ty::Binder<Ty<'tcx>> {
         self.map_bound_ref(|fn_sig| fn_sig.output())
     }
-    pub fn variadic(&self) -> bool {
-        self.skip_binder().variadic
+    pub fn c_variadic(&self) -> bool {
+        self.skip_binder().c_variadic
     }
     pub fn unsafety(&self) -> hir::Unsafety {
         self.skip_binder().unsafety
@@ -1120,7 +1120,7 @@ pub struct DebruijnIndex {
 /// These are regions that are stored behind a binder and must be substituted
 /// with some concrete region before being used. There are two kind of
 /// bound regions: early-bound, which are bound in an item's `Generics`,
-/// and are substituted by a `Substs`, and late-bound, which are part of
+/// and are substituted by a `InternalSubsts`, and late-bound, which are part of
 /// higher-ranked types (e.g., `for<'a> fn(&'a ())`), and are substituted by
 /// the likes of `liberate_late_bound_regions`. The distinction exists
 /// because higher-ranked lifetimes aren't supported in all places. See [1][2].
@@ -1297,7 +1297,7 @@ fn from(var: BoundVar) -> Self {
 #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, RustcEncodable, RustcDecodable)]
 pub struct ExistentialProjection<'tcx> {
     pub item_def_id: DefId,
-    pub substs: &'tcx Substs<'tcx>,
+    pub substs: SubstsRef<'tcx>,
     pub ty: Ty<'tcx>,
 }
 
@@ -2060,7 +2060,7 @@ pub fn is_trivially_sized(&self, tcx: TyCtxt<'_, '_, 'tcx>) -> bool {
 /// Used in the HIR by using `Unevaluated` everywhere and later normalizing to `Evaluated` if the
 /// code is monomorphic enough for that.
 pub enum LazyConst<'tcx> {
-    Unevaluated(DefId, &'tcx Substs<'tcx>),
+    Unevaluated(DefId, SubstsRef<'tcx>),
     Evaluated(Const<'tcx>),
 }
 
index 7559ea90b1782059186053d3b8cd5c76e5716c1a..450fab81661fc72336319c4298ca548ff3b220bf 100644 (file)
@@ -157,26 +157,28 @@ fn decode<D: Decoder>(d: &mut D) -> Result<Kind<'tcx>, D::Error> {
 }
 
 /// A substitution mapping generic parameters to new values.
-pub type Substs<'tcx> = List<Kind<'tcx>>;
+pub type InternalSubsts<'tcx> = List<Kind<'tcx>>;
 
-impl<'a, 'gcx, 'tcx> Substs<'tcx> {
-    /// Creates a `Substs` that maps each generic parameter to itself.
+pub type SubstsRef<'tcx> = &'tcx InternalSubsts<'tcx>;
+
+impl<'a, 'gcx, 'tcx> InternalSubsts<'tcx> {
+    /// Creates a `InternalSubsts` that maps each generic parameter to itself.
     pub fn identity_for_item(tcx: TyCtxt<'a, 'gcx, 'tcx>, def_id: DefId)
-                             -> &'tcx Substs<'tcx> {
-        Substs::for_item(tcx, def_id, |param, _| {
+                             -> SubstsRef<'tcx> {
+        Self::for_item(tcx, def_id, |param, _| {
             tcx.mk_param_from_def(param)
         })
     }
 
-    /// Creates a `Substs` that maps each generic parameter to a higher-ranked
+    /// Creates a `InternalSubsts` that maps each generic parameter to a higher-ranked
     /// var bound at index `0`. For types, we use a `BoundVar` index equal to
     /// the type parameter index. For regions, we use the `BoundRegion::BrNamed`
     /// variant (which has a `DefId`).
     pub fn bound_vars_for_item(
         tcx: TyCtxt<'a, 'gcx, 'tcx>,
         def_id: DefId
-    ) -> &'tcx Substs<'tcx> {
-        Substs::for_item(tcx, def_id, |param, _| {
+    ) -> SubstsRef<'tcx> {
+        Self::for_item(tcx, def_id, |param, _| {
             match param.kind {
                 ty::GenericParamDefKind::Type { .. } => {
                     tcx.mk_ty(
@@ -197,21 +199,21 @@ pub fn bound_vars_for_item(
         })
     }
 
-    /// Creates a `Substs` for generic parameter definitions,
+    /// Creates a `InternalSubsts` for generic parameter definitions,
     /// by calling closures to obtain each kind.
-    /// The closures get to observe the `Substs` as they're
+    /// The closures get to observe the `InternalSubsts` as they're
     /// being built, which can be used to correctly
     /// substitute defaults of generic parameters.
     pub fn for_item<F>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
                        def_id: DefId,
                        mut mk_kind: F)
-                       -> &'tcx Substs<'tcx>
+                       -> SubstsRef<'tcx>
     where F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx>
     {
         let defs = tcx.generics_of(def_id);
         let count = defs.count();
         let mut substs = SmallVec::with_capacity(count);
-        Substs::fill_item(&mut substs, tcx, defs, &mut mk_kind);
+        Self::fill_item(&mut substs, tcx, defs, &mut mk_kind);
         tcx.intern_substs(&substs)
     }
 
@@ -219,10 +221,10 @@ pub fn extend_to<F>(&self,
                         tcx: TyCtxt<'a, 'gcx, 'tcx>,
                         def_id: DefId,
                         mut mk_kind: F)
-                        -> &'tcx Substs<'tcx>
+                        -> SubstsRef<'tcx>
     where F: FnMut(&ty::GenericParamDef, &[Kind<'tcx>]) -> Kind<'tcx>
     {
-        Substs::for_item(tcx, def_id, |param, substs| {
+        Self::for_item(tcx, def_id, |param, substs| {
             self.get(param.index as usize)
                 .cloned()
                 .unwrap_or_else(|| mk_kind(param, substs))
@@ -237,9 +239,9 @@ pub fn extend_to<F>(&self,
     {
         if let Some(def_id) = defs.parent {
             let parent_defs = tcx.generics_of(def_id);
-            Substs::fill_item(substs, tcx, parent_defs, mk_kind);
+            Self::fill_item(substs, tcx, parent_defs, mk_kind);
         }
-        Substs::fill_single(substs, defs, mk_kind)
+        Self::fill_single(substs, defs, mk_kind)
     }
 
     fn fill_single<F>(substs: &mut SmallVec<[Kind<'tcx>; 8]>,
@@ -311,19 +313,19 @@ pub fn type_for_def(&self, def: &ty::GenericParamDef) -> Kind<'tcx> {
     /// parameters (e.g., method parameters) on top of that base.
     pub fn rebase_onto(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>,
                        source_ancestor: DefId,
-                       target_substs: &Substs<'tcx>)
-                       -> &'tcx Substs<'tcx> {
+                       target_substs: SubstsRef<'tcx>)
+                       -> SubstsRef<'tcx> {
         let defs = tcx.generics_of(source_ancestor);
         tcx.mk_substs(target_substs.iter().chain(&self[defs.params.len()..]).cloned())
     }
 
     pub fn truncate_to(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, generics: &ty::Generics)
-                       -> &'tcx Substs<'tcx> {
+                       -> SubstsRef<'tcx> {
         tcx.mk_substs(self.iter().take(generics.count()).cloned())
     }
 }
 
-impl<'tcx> TypeFoldable<'tcx> for &'tcx Substs<'tcx> {
+impl<'tcx> TypeFoldable<'tcx> for SubstsRef<'tcx> {
     fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
         let params: SmallVec<[_; 8]> = self.iter().map(|k| k.fold_with(folder)).collect();
 
@@ -341,7 +343,7 @@ fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
     }
 }
 
-impl<'tcx> serialize::UseSpecializedDecodable for &'tcx Substs<'tcx> {}
+impl<'tcx> serialize::UseSpecializedDecodable for SubstsRef<'tcx> {}
 
 ///////////////////////////////////////////////////////////////////////////
 // Public trait `Subst`
@@ -563,7 +565,7 @@ fn shift_region_through_binders(&self, region: ty::Region<'tcx>) -> ty::Region<'
 #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
 pub struct UserSubsts<'tcx> {
     /// The substitutions for the item as given by the user.
-    pub substs: &'tcx Substs<'tcx>,
+    pub substs: SubstsRef<'tcx>,
 
     /// The self type, in the case of a `<T>::Item` path (when applied
     /// to an inherent impl). See `UserSelfTy` below.
index 1ba7c3bba797ce29568e4dd0ae4a418ff8057ac5..4ad3ffaa93da4f41685391e2cd138b519e2a9549 100644 (file)
@@ -4,10 +4,11 @@
 use crate::hir::def_id::DefId;
 use crate::hir::map::DefPathData;
 use crate::hir::{self, Node};
+use crate::mir::interpret::{sign_extend, truncate};
 use crate::ich::NodeIdHashingMode;
 use crate::traits::{self, ObligationCause};
 use crate::ty::{self, Ty, TyCtxt, GenericParamDefKind, TypeFoldable};
-use crate::ty::subst::{Subst, Substs, UnpackedKind};
+use crate::ty::subst::{Subst, InternalSubsts, SubstsRef, UnpackedKind};
 use crate::ty::query::TyCtxtAt;
 use crate::ty::TyKind::*;
 use crate::ty::layout::{Integer, IntegerExt};
@@ -32,12 +33,12 @@ impl<'tcx> fmt::Display for Discr<'tcx> {
     fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
         match self.ty.sty {
             ty::Int(ity) => {
-                let bits = ty::tls::with(|tcx| {
-                    Integer::from_attr(&tcx, SignedInt(ity)).size().bits()
+                let size = ty::tls::with(|tcx| {
+                    Integer::from_attr(&tcx, SignedInt(ity)).size()
                 });
-                let x = self.val as i128;
+                let x = self.val;
                 // sign extend the raw representation to be an i128
-                let x = (x << (128 - bits)) >> (128 - bits);
+                let x = sign_extend(x, size) as i128;
                 write!(fmt, "{}", x)
             },
             _ => write!(fmt, "{}", self.val),
@@ -57,12 +58,12 @@ pub fn checked_add<'a, 'gcx>(self, tcx: TyCtxt<'a, 'gcx, 'tcx>, n: u128) -> (Sel
             _ => bug!("non integer discriminant"),
         };
 
+        let size = int.size();
         let bit_size = int.size().bits();
         let shift = 128 - bit_size;
         if signed {
             let sext = |u| {
-                let i = u as i128;
-                (i << shift) >> shift
+                sign_extend(u, size) as i128
             };
             let min = sext(1_u128 << (bit_size - 1));
             let max = i128::max_value() >> shift;
@@ -77,7 +78,7 @@ pub fn checked_add<'a, 'gcx>(self, tcx: TyCtxt<'a, 'gcx, 'tcx>, n: u128) -> (Sel
             };
             // zero the upper bits
             let val = val as u128;
-            let val = (val << shift) >> shift;
+            let val = truncate(val, size);
             (Self {
                 val: val as u128,
                 ty: self.ty,
@@ -588,8 +589,8 @@ pub fn closure_env_ty(self,
 
     /// Given the `DefId` of some item that has no type parameters, make
     /// a suitable "empty substs" for it.
-    pub fn empty_substs_for_def_id(self, item_def_id: DefId) -> &'tcx Substs<'tcx> {
-        Substs::for_item(self, item_def_id, |param, _| {
+    pub fn empty_substs_for_def_id(self, item_def_id: DefId) -> SubstsRef<'tcx> {
+        InternalSubsts::for_item(self, item_def_id, |param, _| {
             match param.kind {
                 GenericParamDefKind::Lifetime => self.types.re_erased.into(),
                 GenericParamDefKind::Type {..} => {
@@ -633,7 +634,7 @@ pub fn is_static(&self, def_id: DefId) -> Option<hir::Mutability> {
     pub fn try_expand_impl_trait_type(
         self,
         def_id: DefId,
-        substs: &'tcx Substs<'tcx>,
+        substs: SubstsRef<'tcx>,
     ) -> Result<Ty<'tcx>, Ty<'tcx>> {
         use crate::ty::fold::TypeFolder;
 
@@ -652,7 +653,7 @@ impl<'a, 'gcx, 'tcx> OpaqueTypeExpander<'a, 'gcx, 'tcx> {
             fn expand_opaque_ty(
                 &mut self,
                 def_id: DefId,
-                substs: &'tcx Substs<'tcx>,
+                substs: SubstsRef<'tcx>,
             ) -> Option<Ty<'tcx>> {
                 if self.found_recursion {
                     None
index 126f5290af51389f55921de490e7c458051b869c..d9f309ae58e0357b3c03f1bb99921963b9287c1c 100644 (file)
@@ -99,7 +99,7 @@ fn push_subtypes<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent_ty: Ty<'tcx>) {
                         (p.substs, Some(p.ty)),
                     ty::ExistentialPredicate::AutoTrait(_) =>
                         // Empty iterator
-                        (ty::Substs::empty(), None),
+                        (ty::InternalSubsts::empty(), None),
                 };
 
                 substs.types().rev().chain(opt_ty)
index 282bf1219fa5c174deca13a16c972947c71129e5..599d38bc4ab6ee56c76fee7d674729b5e3ac0784 100644 (file)
@@ -1,7 +1,7 @@
 use crate::hir;
 use crate::hir::def_id::DefId;
 use crate::infer::InferCtxt;
-use crate::ty::subst::Substs;
+use crate::ty::subst::SubstsRef;
 use crate::traits;
 use crate::ty::{self, ToPredicate, Ty, TyCtxt, TypeFoldable};
 use std::iter::once;
@@ -432,7 +432,7 @@ fn compute(&mut self, ty0: Ty<'tcx>) -> bool {
 
     fn nominal_obligations(&mut self,
                            def_id: DefId,
-                           substs: &Substs<'tcx>)
+                           substs: SubstsRef<'tcx>)
                            -> Vec<traits::PredicateObligation<'tcx>>
     {
         let predicates =
index 768fd02e8238a013b560c4371ee6d37b546d7035..aecef3c5ec71e4d5439efd1718065508b0e1c1d2 100644 (file)
@@ -1,7 +1,7 @@
 use crate::hir::def_id::DefId;
 use crate::hir::map::definitions::DefPathData;
 use crate::middle::region;
-use crate::ty::subst::{self, Subst};
+use crate::ty::subst::{self, Subst, SubstsRef};
 use crate::ty::{BrAnon, BrEnv, BrFresh, BrNamed};
 use crate::ty::{Bool, Char, Adt};
 use crate::ty::{Error, Str, Array, Slice, Float, FnDef, FnPtr};
@@ -360,7 +360,7 @@ impl PrintContext {
     fn fn_sig<F: fmt::Write>(&mut self,
                              f: &mut F,
                              inputs: &[Ty<'_>],
-                             variadic: bool,
+                             c_variadic: bool,
                              output: Ty<'_>)
                              -> fmt::Result {
         write!(f, "(")?;
@@ -370,7 +370,7 @@ fn fn_sig<F: fmt::Write>(&mut self,
             for &ty in inputs {
                 print!(f, self, write(", "), print_display(ty))?;
             }
-            if variadic {
+            if c_variadic {
                 write!(f, ", ...")?;
             }
         }
@@ -384,7 +384,7 @@ fn fn_sig<F: fmt::Write>(&mut self,
 
     fn parameterized<F: fmt::Write>(&mut self,
                                     f: &mut F,
-                                    substs: &subst::Substs<'_>,
+                                    substs: SubstsRef<'_>,
                                     did: DefId,
                                     projections: &[ty::ProjectionPredicate<'_>])
                                     -> fmt::Result {
@@ -692,7 +692,7 @@ pub fn identify_regions() -> bool {
 }
 
 pub fn parameterized<F: fmt::Write>(f: &mut F,
-                                    substs: &subst::Substs<'_>,
+                                    substs: SubstsRef<'_>,
                                     did: DefId,
                                     projections: &[ty::ProjectionPredicate<'_>])
                                     -> fmt::Result {
@@ -1074,10 +1074,10 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
             }
 
             write!(f, "fn")?;
-            cx.fn_sig(f, self.inputs(), self.variadic, self.output())
+            cx.fn_sig(f, self.inputs(), self.c_variadic, self.output())
         }
         debug {
-            write!(f, "({:?}; variadic: {})->{:?}", self.inputs(), self.variadic, self.output())
+            write!(f, "({:?}; c_variadic: {})->{:?}", self.inputs(), self.c_variadic, self.output())
         }
     }
 }
@@ -1290,7 +1290,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
                         Ok(())
                     }
                 }
-                Foreign(def_id) => parameterized(f, subst::Substs::empty(), def_id, &[]),
+                Foreign(def_id) => parameterized(f, subst::InternalSubsts::empty(), def_id, &[]),
                 Projection(ref data) => data.print(f, cx),
                 UnnormalizedProjection(ref data) => {
                     write!(f, "Unnormalized(")?;
index 992149f7a47b50e8abc1048d71225dd4c71d9b31..49c9555a2c682d74f642016699c9e4116940b953 100644 (file)
@@ -258,7 +258,7 @@ fn store_fn_arg(
             val
         };
         match self.mode {
-            PassMode::Ignore => {},
+            PassMode::Ignore(_) => {}
             PassMode::Pair(..) => {
                 OperandValue::Pair(next(), next()).store(bx, dst);
             }
@@ -422,7 +422,7 @@ fn new_internal(
 
         let mut inputs = sig.inputs();
         let extra_args = if sig.abi == RustCall {
-            assert!(!sig.variadic && extra_args.is_empty());
+            assert!(!sig.c_variadic && extra_args.is_empty());
 
             match sig.inputs().last().unwrap().sty {
                 ty::Tuple(ref tupled_arguments) => {
@@ -435,7 +435,7 @@ fn new_internal(
                 }
             }
         } else {
-            assert!(sig.variadic || extra_args.is_empty());
+            assert!(sig.c_variadic || extra_args.is_empty());
             extra_args
         };
 
@@ -507,6 +507,14 @@ fn new_internal(
             }
         };
 
+        // Store the index of the last argument. This is useful for working with
+        // C-compatible variadic arguments.
+        let last_arg_idx = if sig.inputs().is_empty() {
+            None
+        } else {
+            Some(sig.inputs().len() - 1)
+        };
+
         let arg_of = |ty: Ty<'tcx>, arg_idx: Option<usize>| {
             let is_return = arg_idx.is_none();
             let mut arg = mk_arg_type(ty, arg_idx);
@@ -516,7 +524,30 @@ fn new_internal(
                 // The same is true for s390x-unknown-linux-gnu
                 // and sparc64-unknown-linux-gnu.
                 if is_return || rust_abi || (!win_x64_gnu && !linux_s390x && !linux_sparc64) {
-                    arg.mode = PassMode::Ignore;
+                    arg.mode = PassMode::Ignore(IgnoreMode::Zst);
+                }
+            }
+
+            // If this is a C-variadic function, this is not the return value,
+            // and there is one or more fixed arguments; ensure that the `VaList`
+            // is ignored as an argument.
+            if sig.c_variadic {
+                match (last_arg_idx, arg_idx) {
+                    (Some(last_idx), Some(cur_idx)) if last_idx == cur_idx => {
+                        let va_list_did = match cx.tcx.lang_items().va_list() {
+                            Some(did) => did,
+                            None => bug!("`va_list` lang item required for C-variadic functions"),
+                        };
+                        match ty.sty {
+                            ty::Adt(def, _) if def.did == va_list_did => {
+                                // This is the "spoofed" `VaList`. Set the arguments mode
+                                // so that it will be ignored.
+                                arg.mode = PassMode::Ignore(IgnoreMode::CVarArgs);
+                            },
+                            _ => (),
+                        }
+                    }
+                    _ => {}
                 }
             }
 
@@ -558,7 +589,7 @@ fn new_internal(
             args: inputs.iter().chain(extra_args).enumerate().map(|(i, ty)| {
                 arg_of(ty, Some(i))
             }).collect(),
-            variadic: sig.variadic,
+            c_variadic: sig.c_variadic,
             conv,
         };
         fn_ty.adjust_for_abi(cx, sig.abi);
@@ -646,7 +677,9 @@ fn llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type {
         );
 
         let llreturn_ty = match self.ret.mode {
-            PassMode::Ignore => cx.type_void(),
+            PassMode::Ignore(IgnoreMode::Zst) => cx.type_void(),
+            PassMode::Ignore(IgnoreMode::CVarArgs) =>
+                bug!("`va_list` should never be a return type"),
             PassMode::Direct(_) | PassMode::Pair(..) => {
                 self.ret.layout.immediate_llvm_type(cx)
             }
@@ -664,7 +697,7 @@ fn llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type {
             }
 
             let llarg_ty = match arg.mode {
-                PassMode::Ignore => continue,
+                PassMode::Ignore(_) => continue,
                 PassMode::Direct(_) => arg.layout.immediate_llvm_type(cx),
                 PassMode::Pair(..) => {
                     llargument_tys.push(arg.layout.scalar_pair_element_llvm_type(cx, 0, true));
@@ -684,7 +717,7 @@ fn llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type {
             llargument_tys.push(llarg_ty);
         }
 
-        if self.variadic {
+        if self.c_variadic {
             cx.type_variadic_func(&llargument_tys, llreturn_ty)
         } else {
             cx.type_func(&llargument_tys, llreturn_ty)
@@ -733,7 +766,7 @@ fn apply_attrs_llfn(&self, llfn: &'ll Value) {
                 apply(&ArgAttributes::new());
             }
             match arg.mode {
-                PassMode::Ignore => {}
+                PassMode::Ignore(_) => {}
                 PassMode::Direct(ref attrs) |
                 PassMode::Indirect(ref attrs, None) => apply(attrs),
                 PassMode::Indirect(ref attrs, Some(ref extra_attrs)) => {
@@ -780,7 +813,7 @@ fn apply_attrs_callsite(&self, bx: &mut Builder<'a, 'll, 'tcx>, callsite: &'ll V
                 apply(&ArgAttributes::new());
             }
             match arg.mode {
-                PassMode::Ignore => {}
+                PassMode::Ignore(_) => {}
                 PassMode::Direct(ref attrs) |
                 PassMode::Indirect(ref attrs, None) => apply(attrs),
                 PassMode::Indirect(ref attrs, Some(ref extra_attrs)) => {
index 819f7f9410257cd483afca9138a9c5485a5f8a46..6c175ff4247cadf6e90aa97aa9532dbb45f04f51 100644 (file)
@@ -698,7 +698,6 @@ fn escape_string(s: &[u8]) -> String {
     }
 
     if sess.opts.target_triple.triple() == "wasm32-unknown-unknown" {
-        wasm::rewrite_imports(&out_filename, &codegen_results.crate_info.wasm_imports);
         wasm::add_producer_section(
             &out_filename,
             &sess.edition().to_string(),
index e1d3351d3deca7476946d7f76bd28e8a98f70935..f90bb89fbe87d66c6f8516af5a32508b3b5ba43b 100644 (file)
 use std::path::Path;
 use std::str;
 
-use rustc_data_structures::fx::FxHashMap;
 use serialize::leb128;
 
 // https://webassembly.github.io/spec/core/binary/modules.html#binary-importsec
-const WASM_IMPORT_SECTION_ID: u8 = 2;
 const WASM_CUSTOM_SECTION_ID: u8 = 0;
 
-const WASM_EXTERNAL_KIND_FUNCTION: u8 = 0;
-const WASM_EXTERNAL_KIND_TABLE: u8 = 1;
-const WASM_EXTERNAL_KIND_MEMORY: u8 = 2;
-const WASM_EXTERNAL_KIND_GLOBAL: u8 = 3;
-
-/// Rewrite the module imports are listed from in a wasm module given the field
-/// name to module name mapping in `import_map`.
-///
-/// LLVM 6 which we're using right now doesn't have the ability to configure the
-/// module a wasm symbol is import from. Rather all imported symbols come from
-/// the bland `"env"` module unconditionally. Furthermore we'd *also* need
-/// support in LLD for preserving these import modules, which it unfortunately
-/// currently does not.
-///
-/// This function is intended as a hack for now where we manually rewrite the
-/// wasm output by LLVM to have the correct import modules listed. The
-/// `#[link(wasm_import_module = "...")]` attribute in Rust translates to the
-/// module that each symbol is imported from, so here we manually go through the
-/// wasm file, decode it, rewrite imports, and then rewrite the wasm module.
-///
-/// Support for this was added to LLVM in
-/// https://github.com/llvm-mirror/llvm/commit/0f32e1365, although support still
-/// needs to be added, tracked at https://bugs.llvm.org/show_bug.cgi?id=37168
-pub fn rewrite_imports(path: &Path, import_map: &FxHashMap<String, String>) {
-    if import_map.is_empty() {
-        return
-    }
-
-    let wasm = fs::read(path).expect("failed to read wasm output");
-    let mut ret = WasmEncoder::new();
-    ret.data.extend(&wasm[..8]);
-
-    // skip the 8 byte wasm/version header
-    for (id, raw) in WasmSections(WasmDecoder::new(&wasm[8..])) {
-        ret.byte(id);
-        if id == WASM_IMPORT_SECTION_ID {
-            info!("rewriting import section");
-            let data = rewrite_import_section(
-                &mut WasmDecoder::new(raw),
-                import_map,
-            );
-            ret.bytes(&data);
-        } else {
-            info!("carry forward section {}, {} bytes long", id, raw.len());
-            ret.bytes(raw);
-        }
-    }
-
-    fs::write(path, &ret.data).expect("failed to write wasm output");
-
-    fn rewrite_import_section(
-        wasm: &mut WasmDecoder<'_>,
-        import_map: &FxHashMap<String, String>,
-    )
-        -> Vec<u8>
-    {
-        let mut dst = WasmEncoder::new();
-        let n = wasm.u32();
-        dst.u32(n);
-        info!("rewriting {} imports", n);
-        for _ in 0..n {
-            rewrite_import_entry(wasm, &mut dst, import_map);
-        }
-        return dst.data
-    }
-
-    fn rewrite_import_entry(wasm: &mut WasmDecoder<'_>,
-                            dst: &mut WasmEncoder,
-                            import_map: &FxHashMap<String, String>) {
-        // More info about the binary format here is available at:
-        // https://webassembly.github.io/spec/core/binary/modules.html#import-section
-        //
-        // Note that you can also find the whole point of existence of this
-        // function here, where we map the `module` name to a different one if
-        // we've got one listed.
-        let module = wasm.str();
-        let field = wasm.str();
-        let new_module = if module == "env" {
-            import_map.get(field).map(|s| &**s).unwrap_or(module)
-        } else {
-            module
-        };
-        info!("import rewrite ({} => {}) / {}", module, new_module, field);
-        dst.str(new_module);
-        dst.str(field);
-        let kind = wasm.byte();
-        dst.byte(kind);
-        match kind {
-            WASM_EXTERNAL_KIND_FUNCTION => dst.u32(wasm.u32()),
-            WASM_EXTERNAL_KIND_TABLE => {
-                dst.byte(wasm.byte()); // element_type
-                dst.limits(wasm.limits());
-            }
-            WASM_EXTERNAL_KIND_MEMORY => dst.limits(wasm.limits()),
-            WASM_EXTERNAL_KIND_GLOBAL => {
-                dst.byte(wasm.byte()); // content_type
-                dst.bool(wasm.bool()); // mutable
-            }
-            b => panic!("unknown kind: {}", b),
-        }
-    }
-}
-
 /// Adds or augment the existing `producers` section to encode information about
 /// the Rust compiler used to produce the wasm file.
 pub fn add_producer_section(
@@ -266,15 +161,6 @@ fn str(&mut self) -> &'a str {
         let len = self.u32();
         str::from_utf8(self.skip(len as usize)).unwrap()
     }
-
-    fn bool(&mut self) -> bool {
-        self.byte() == 1
-    }
-
-    fn limits(&mut self) -> (u32, Option<u32>) {
-        let has_max = self.bool();
-        (self.u32(), if has_max { Some(self.u32()) } else { None })
-    }
 }
 
 struct WasmEncoder {
@@ -302,16 +188,4 @@ fn bytes(&mut self, val: &[u8]) {
     fn str(&mut self, val: &str) {
         self.bytes(val.as_bytes())
     }
-
-    fn bool(&mut self, b: bool) {
-        self.byte(b as u8);
-    }
-
-    fn limits(&mut self, limits: (u32, Option<u32>)) {
-        self.bool(limits.1.is_some());
-        self.u32(limits.0);
-        if let Some(c) = limits.1 {
-            self.u32(c);
-        }
-    }
 }
index ae6e16b31e7aa13b6616440e6b475f33fa478e52..c0869bb889afaba430b916ab5278f651bd076079 100644 (file)
@@ -15,7 +15,7 @@
     DISPFlags, DILexicalBlock};
 use rustc::hir::CodegenFnAttrFlags;
 use rustc::hir::def_id::{DefId, CrateNum, LOCAL_CRATE};
-use rustc::ty::subst::{Substs, UnpackedKind};
+use rustc::ty::subst::{SubstsRef, UnpackedKind};
 
 use crate::abi::Abi;
 use crate::common::CodegenCx;
@@ -399,7 +399,7 @@ fn get_function_signature<'ll, 'tcx>(
         fn get_template_parameters<'ll, 'tcx>(
             cx: &CodegenCx<'ll, 'tcx>,
             generics: &ty::Generics,
-            substs: &Substs<'tcx>,
+            substs: SubstsRef<'tcx>,
             file_metadata: &'ll DIFile,
             name_to_append_suffix_to: &mut String,
         ) -> &'ll DIArray {
index 32e930ac44c850a007c6e5711bddd5386f5301be..8b218ab39d99b520d60a3faa078b6d05d736d6ff 100644 (file)
@@ -2,7 +2,7 @@
 
 use crate::common::CodegenCx;
 use rustc::hir::def_id::DefId;
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::SubstsRef;
 use rustc::ty::{self, Ty};
 use rustc_codegen_ssa::traits::*;
 
@@ -143,7 +143,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
                 output.pop();
             }
 
-            if sig.variadic {
+            if sig.c_variadic {
                 if !sig.inputs().is_empty() {
                     output.push_str(", ...");
                 } else {
@@ -193,13 +193,13 @@ fn push_item_name(cx: &CodegenCx<'_, '_>,
         }
     }
 
-    // Pushes the type parameters in the given `Substs` to the output string.
+    // Pushes the type parameters in the given `InternalSubsts` to the output string.
     // This ignores region parameters, since they can't reliably be
     // reconstructed for items from non-local crates. For local crates, this
     // would be possible but with inlining and LTO we have to use the least
     // common denominator - otherwise we would run into conflicts.
     fn push_type_params<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
-                                  substs: &Substs<'tcx>,
+                                  substs: SubstsRef<'tcx>,
                                   output: &mut String) {
         if substs.types().next().is_none() {
             return;
index d1cbe1d4dd6866c44880432ada15a6e69a6c7ea5..3268af396a2f4f475c2353b3ed76ea66083c8ec9 100644 (file)
@@ -136,22 +136,18 @@ fn codegen_intrinsic_call(
                 let tp_ty = substs.type_at(0);
                 self.const_usize(self.size_of(tp_ty).bytes())
             }
-            func @ "va_start" | func @ "va_end" => {
-                let va_list = match (tcx.lang_items().va_list(), &result.layout.ty.sty) {
-                    (Some(did), ty::Adt(def, _)) if def.did == did => args[0].immediate(),
-                    (Some(_), _) => self.load(args[0].immediate(),
-                                              tcx.data_layout.pointer_align.abi),
-                    (None, _) => bug!("va_list language item must be defined")
-                };
-                let intrinsic = self.cx().get_intrinsic(&format!("llvm.{}", func));
-                self.call(intrinsic, &[va_list], None)
+            "va_start" => {
+                self.va_start(args[0].immediate())
+            }
+            "va_end" => {
+                self.va_end(args[0].immediate())
             }
             "va_copy" => {
                 let va_list = match (tcx.lang_items().va_list(), &result.layout.ty.sty) {
                     (Some(did), ty::Adt(def, _)) if def.did == did => args[0].immediate(),
                     (Some(_), _)  => self.load(args[0].immediate(),
                                                tcx.data_layout.pointer_align.abi),
-                    (None, _) => bug!("va_list language item must be defined")
+                    (None, _) => bug!("`va_list` language item must be defined")
                 };
                 let intrinsic = self.cx().get_intrinsic(&("llvm.va_copy"));
                 self.call(intrinsic, &[llresult, va_list], None);
@@ -722,6 +718,41 @@ fn expect(&mut self, cond: Self::Value, expected: bool) -> Self::Value {
         let expect = self.get_intrinsic(&"llvm.expect.i1");
         self.call(expect, &[cond, self.const_bool(expected)], None)
     }
+
+    fn va_start(&mut self, list: &'ll Value) -> &'ll Value {
+        let target = &self.cx.tcx.sess.target.target;
+        let arch = &target.arch;
+        // A pointer to the architecture specific structure is passed to this
+        // function. For pointer variants (i686, RISC-V, Windows, etc), we
+        // should do do nothing, as the address to the pointer is needed. For
+        // architectures with a architecture specific structure (`Aarch64`,
+        // `X86_64`, etc), this function should load the structure from the
+        // address provided.
+        let va_list = match &**arch {
+            _ if target.options.is_like_windows => list,
+            "aarch64" if target.target_os == "ios" => list,
+            "aarch64" | "x86_64" | "powerpc" =>
+                self.load(list, self.tcx().data_layout.pointer_align.abi),
+            _ => list,
+        };
+        let intrinsic = self.cx().get_intrinsic("llvm.va_start");
+        self.call(intrinsic, &[va_list], None)
+    }
+
+    fn va_end(&mut self, list: &'ll Value) -> &'ll Value {
+        let target = &self.cx.tcx.sess.target.target;
+        let arch = &target.arch;
+        // See the comment in `va_start` for the purpose of the following.
+        let va_list = match &**arch {
+            _ if target.options.is_like_windows => list,
+            "aarch64" if target.target_os == "ios" => list,
+            "aarch64" | "x86_64" | "powerpc" =>
+                self.load(list, self.tcx().data_layout.pointer_align.abi),
+            _ => list,
+        };
+        let intrinsic = self.cx().get_intrinsic("llvm.va_end");
+        self.call(intrinsic, &[va_list], None)
+    }
 }
 
 fn copy_intrinsic(
index 4fe6a1f4f4b1ca132e031470fafe00b7d1ecbb7b..7f0cdb9f580088b1b49f0e0ee1d08596f42afcb7 100644 (file)
@@ -36,10 +36,10 @@ fn predefine_static(&self,
     }
 
     fn predefine_fn(&self,
-                              instance: Instance<'tcx>,
-                              linkage: Linkage,
-                              visibility: Visibility,
-                              symbol_name: &str) {
+                    instance: Instance<'tcx>,
+                    linkage: Linkage,
+                    visibility: Visibility,
+                    symbol_name: &str) {
         assert!(!instance.substs.needs_infer() &&
                 !instance.substs.has_param_types());
 
index 8719390b51acaa64dcd724ccafaa01681374f377..7aceaea4510ceb156246f1cea7cafcb110b548fc 100644 (file)
@@ -109,12 +109,12 @@ pub(super) fn emit_va_arg(
                             Align::from_bytes(4).unwrap(), true)
         }
         // Windows Aarch64
-        ("aarch4", true) => {
+        ("aarch64", true) => {
             emit_ptr_va_arg(bx, addr, target_ty, false,
                             Align::from_bytes(8).unwrap(), false)
         }
         // iOS Aarch64
-        ("aarch4", _) if target.target_os == "ios" => {
+        ("aarch64", _) if target.target_os == "ios" => {
             emit_ptr_va_arg(bx, addr, target_ty, false,
                             Align::from_bytes(8).unwrap(), true)
         }
index 16f5880b13f5bd70dc6878469361ef0a00fe3c9a..4b01e264f19eda5b38951da3aae6e105e548e569 100644 (file)
@@ -11,7 +11,7 @@
 use rustc::session::config;
 use rustc::ty::{TyCtxt, SymbolName};
 use rustc::ty::query::Providers;
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::SubstsRef;
 use rustc::util::nodemap::{FxHashMap, DefIdMap};
 use rustc_allocator::ALLOCATOR_METHODS;
 use rustc_data_structures::indexed_vec::IndexVec;
@@ -282,7 +282,7 @@ fn exported_symbols_provider_local<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 fn upstream_monomorphizations_provider<'a, 'tcx>(
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
     cnum: CrateNum)
-    -> Lrc<DefIdMap<Lrc<FxHashMap<&'tcx Substs<'tcx>, CrateNum>>>>
+    -> Lrc<DefIdMap<Lrc<FxHashMap<SubstsRef<'tcx>, CrateNum>>>>
 {
     debug_assert!(cnum == LOCAL_CRATE);
 
@@ -334,7 +334,7 @@ fn upstream_monomorphizations_provider<'a, 'tcx>(
 fn upstream_monomorphizations_for_provider<'a, 'tcx>(
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
     def_id: DefId)
-    -> Option<Lrc<FxHashMap<&'tcx Substs<'tcx>, CrateNum>>>
+    -> Option<Lrc<FxHashMap<SubstsRef<'tcx>, CrateNum>>>
 {
     debug_assert!(!def_id.is_local());
     tcx.upstream_monomorphizations(LOCAL_CRATE)
index fad41a11a82ba126351146f3b678f0bf2abcb9e3..39ce15e4772967b9e4512738022deef64f54ad47 100644 (file)
@@ -16,7 +16,7 @@
 use crate::{ModuleCodegen, ModuleKind, CachedModuleCodegen};
 
 use rustc::dep_graph::cgu_reuse_tracker::CguReuse;
-use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
+use rustc::hir::def_id::{DefId, LOCAL_CRATE};
 use rustc::middle::lang_items::StartFnLangItem;
 use rustc::middle::weak_lang_items;
 use rustc::mir::mono::{Stats, CodegenUnitNameBuilder};
@@ -816,21 +816,11 @@ pub fn new(tcx: TyCtxt<'_, '_, '_>) -> CrateInfo {
             used_crates_dynamic: cstore::used_crates(tcx, LinkagePreference::RequireDynamic),
             used_crates_static: cstore::used_crates(tcx, LinkagePreference::RequireStatic),
             used_crate_source: Default::default(),
-            wasm_imports: Default::default(),
             lang_item_to_crate: Default::default(),
             missing_lang_items: Default::default(),
         };
         let lang_items = tcx.lang_items();
 
-        let load_wasm_items = tcx.sess.crate_types.borrow()
-            .iter()
-            .any(|c| *c != config::CrateType::Rlib) &&
-            tcx.sess.opts.target_triple.triple() == "wasm32-unknown-unknown";
-
-        if load_wasm_items {
-            info.load_wasm_imports(tcx, LOCAL_CRATE);
-        }
-
         let crates = tcx.crates();
 
         let n_crates = crates.len();
@@ -858,9 +848,6 @@ pub fn new(tcx: TyCtxt<'_, '_, '_>) -> CrateInfo {
             if tcx.is_no_builtins(cnum) {
                 info.is_no_builtins.insert(cnum);
             }
-            if load_wasm_items {
-                info.load_wasm_imports(tcx, cnum);
-            }
             let missing = tcx.missing_lang_items(cnum);
             for &item in missing.iter() {
                 if let Ok(id) = lang_items.require(item) {
@@ -879,15 +866,6 @@ pub fn new(tcx: TyCtxt<'_, '_, '_>) -> CrateInfo {
 
         return info
     }
-
-    fn load_wasm_imports(&mut self, tcx: TyCtxt<'_, '_, '_>, cnum: CrateNum) {
-        self.wasm_imports.extend(tcx.wasm_import_module_map(cnum).iter().map(|(&id, module)| {
-            let instance = Instance::mono(tcx, id);
-            let import_name = tcx.symbol_name(instance);
-
-            (import_name.to_string(), module.clone())
-        }));
-    }
 }
 
 fn is_codegened_item(tcx: TyCtxt<'_, '_, '_>, id: DefId) -> bool {
index 3665d45d1e9c7489e3a1b2fb7436778f1ff9d47b..4744dd6302fb3200f1527371a04f35d19eaa598c 100644 (file)
@@ -1,12 +1,12 @@
 use crate::traits::*;
 use rustc::ty;
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::SubstsRef;
 use rustc::hir::def_id::DefId;
 
 pub fn resolve_and_get_fn<'tcx, Cx: CodegenMethods<'tcx>>(
     cx: &Cx,
     def_id: DefId,
-    substs: &'tcx Substs<'tcx>,
+    substs: SubstsRef<'tcx>,
 ) -> Cx::Value {
     cx.get_fn(
         ty::Instance::resolve(
@@ -23,7 +23,7 @@ pub fn resolve_and_get_fn_for_vtable<'tcx,
 >(
     cx: &Cx,
     def_id: DefId,
-    substs: &'tcx Substs<'tcx>,
+    substs: SubstsRef<'tcx>,
 ) -> Cx::Value {
     cx.get_fn(
         ty::Instance::resolve_for_vtable(
index 92fa2766f8727a535d1d6c548fdc4a8a33c830dd..f38b22aa0417129d342e03a1ffae6bafa8fd4fec 100644 (file)
@@ -138,7 +138,6 @@ pub struct CrateInfo {
     pub used_crate_source: FxHashMap<CrateNum, Lrc<CrateSource>>,
     pub used_crates_static: Vec<(CrateNum, LibSource)>,
     pub used_crates_dynamic: Vec<(CrateNum, LibSource)>,
-    pub wasm_imports: FxHashMap<String, String>,
     pub lang_item_to_crate: FxHashMap<LangItem, CrateNum>,
     pub missing_lang_items: FxHashMap<CrateNum, Vec<LangItem>>,
 }
index 9fe2e58bc203cffcd13c6961d08095644bd995f3..facae9a9797065e843d8ee724e7c11ac5cfa0c1e 100644 (file)
@@ -103,7 +103,7 @@ fn visit_assign(&mut self,
                     location: Location) {
         debug!("visit_assign(block={:?}, place={:?}, rvalue={:?})", block, place, rvalue);
 
-        if let mir::Place::Local(index) = *place {
+        if let mir::Place::Base(mir::PlaceBase::Local(index)) = *place {
             self.assign(index, location);
             if !self.fx.rvalue_creates_operand(rvalue) {
                 self.not_ssa(index);
@@ -245,7 +245,8 @@ fn visit_local(&mut self,
             }
 
             PlaceContext::MutatingUse(MutatingUseContext::Drop) => {
-                let ty = mir::Place::Local(local).ty(self.fx.mir, self.fx.cx.tcx());
+                let ty = mir::Place::Base(mir::PlaceBase::Local(local)).ty(self.fx.mir,
+                                                                           self.fx.cx.tcx());
                 let ty = self.fx.monomorphize(&ty.to_ty(self.fx.cx.tcx()));
 
                 // Only need the place if we're actually dropping it.
index caca1789fc98c5989ced9c96018a3f6adfa71572..02086c7730cee15b0c2c2d9ed5d68a7f10bec124 100644 (file)
@@ -3,7 +3,7 @@
 use rustc::ty::layout::{self, LayoutOf, HasTyCtxt};
 use rustc::mir;
 use rustc::mir::interpret::EvalErrorKind;
-use rustc_target::abi::call::{ArgType, FnType, PassMode};
+use rustc_target::abi::call::{ArgType, FnType, PassMode, IgnoreMode};
 use rustc_target::spec::abi::Abi;
 use rustc_mir::monomorphize;
 use crate::base;
 
 use crate::traits::*;
 
+use std::borrow::Cow;
+
 use syntax::symbol::Symbol;
 use syntax_pos::Pos;
 
 use super::{FunctionCx, LocalRef};
 use super::place::PlaceRef;
-use super::operand::OperandRef;
+use super::operand::{OperandValue, OperandRef};
 use super::operand::OperandValue::{Pair, Ref, Immediate};
 
-impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
-    pub fn codegen_block(
-        &mut self,
-        bb: mir::BasicBlock,
-    ) {
-        let mut bx = self.build_block(bb);
-        let data = &self.mir[bb];
+/// Used by `FunctionCx::codegen_terminator` for emitting common patterns
+/// e.g., creating a basic block, calling a function, etc.
+struct TerminatorCodegenHelper<'a, 'tcx> {
+    bb: &'a mir::BasicBlock,
+    terminator: &'a mir::Terminator<'tcx>,
+    funclet_bb: Option<mir::BasicBlock>,
+}
 
-        debug!("codegen_block({:?}={:?})", bb, data);
+impl<'a, 'tcx> TerminatorCodegenHelper<'a, 'tcx> {
+    /// Returns the associated funclet from `FunctionCx::funclets` for the
+    /// `funclet_bb` member if it is not `None`.
+    fn funclet<'c, 'b, Bx: BuilderMethods<'b, 'tcx>>(
+        &self,
+        fx: &'c mut FunctionCx<'b, 'tcx, Bx>,
+    ) -> Option<&'c Bx::Funclet> {
+        match self.funclet_bb {
+            Some(funcl) => fx.funclets[funcl].as_ref(),
+            None => None,
+        }
+    }
 
-        for statement in &data.statements {
-            bx = self.codegen_statement(bx, statement);
+    fn lltarget<'b, 'c, Bx: BuilderMethods<'b, 'tcx>>(
+        &self,
+        fx: &'c mut FunctionCx<'b, 'tcx, Bx>,
+        target: mir::BasicBlock,
+    ) -> (Bx::BasicBlock, bool) {
+        let span = self.terminator.source_info.span;
+        let lltarget = fx.blocks[target];
+        let target_funclet = fx.cleanup_kinds[target].funclet_bb(target);
+        match (self.funclet_bb, target_funclet) {
+            (None, None) => (lltarget, false),
+            (Some(f), Some(t_f)) if f == t_f || !base::wants_msvc_seh(fx.cx.tcx().sess) =>
+                (lltarget, false),
+            // jump *into* cleanup - need a landing pad if GNU
+            (None, Some(_)) => (fx.landing_pad_to(target), false),
+            (Some(_), None) => span_bug!(span, "{:?} - jump out of cleanup?", self.terminator),
+            (Some(_), Some(_)) => (fx.landing_pad_to(target), true),
         }
+    }
 
-        self.codegen_terminator(bx, bb, data.terminator());
+    /// Create a basic block.
+    fn llblock<'c, 'b, Bx: BuilderMethods<'b, 'tcx>>(
+        &self,
+        fx: &'c mut FunctionCx<'b, 'tcx, Bx>,
+        target: mir::BasicBlock,
+    ) -> Bx::BasicBlock {
+        let (lltarget, is_cleanupret) = self.lltarget(fx, target);
+        if is_cleanupret {
+            // MSVC cross-funclet jump - need a trampoline
+
+            debug!("llblock: creating cleanup trampoline for {:?}", target);
+            let name = &format!("{:?}_cleanup_trampoline_{:?}", self.bb, target);
+            let mut trampoline = fx.new_block(name);
+            trampoline.cleanup_ret(self.funclet(fx).unwrap(),
+                                   Some(lltarget));
+            trampoline.llbb()
+        } else {
+            lltarget
+        }
     }
 
-    fn codegen_terminator(
-        &mut self,
-        mut bx: Bx,
-        bb: mir::BasicBlock,
-        terminator: &mir::Terminator<'tcx>
+    fn funclet_br<'c, 'b, Bx: BuilderMethods<'b, 'tcx>>(
+        &self,
+        fx: &'c mut FunctionCx<'b, 'tcx, Bx>,
+        bx: &mut Bx,
+        target: mir::BasicBlock,
     ) {
-        debug!("codegen_terminator: {:?}", terminator);
-
-        // Create the cleanup bundle, if needed.
-        let tcx = self.cx.tcx();
-        let span = terminator.source_info.span;
-        let funclet_bb = self.cleanup_kinds[bb].funclet_bb(bb);
+        let (lltarget, is_cleanupret) = self.lltarget(fx, target);
+        if is_cleanupret {
+            // micro-optimization: generate a `ret` rather than a jump
+            // to a trampoline.
+            bx.cleanup_ret(self.funclet(fx).unwrap(), Some(lltarget));
+        } else {
+            bx.br(lltarget);
+        }
+    }
 
-        // HACK(eddyb) force the right lifetimes, NLL can't figure them out.
-        fn funclet_closure_factory<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
-            funclet_bb: Option<mir::BasicBlock>
-        ) -> impl for<'b> Fn(
-            &'b FunctionCx<'a, 'tcx, Bx>,
-        ) -> Option<&'b Bx::Funclet> {
-            move |this| {
-                match funclet_bb {
-                    Some(funclet_bb) => this.funclets[funclet_bb].as_ref(),
-                    None => None,
-                }
+    /// Call `fn_ptr` of `fn_ty` with the arguments `llargs`, the optional
+    /// return destination `destination` and the cleanup function `cleanup`.
+    fn do_call<'c, 'b, Bx: BuilderMethods<'b, 'tcx>>(
+        &self,
+        fx: &'c mut FunctionCx<'b, 'tcx, Bx>,
+        bx: &mut Bx,
+        fn_ty: FnType<'tcx, Ty<'tcx>>,
+        fn_ptr: Bx::Value,
+        llargs: &[Bx::Value],
+        destination: Option<(ReturnDest<'tcx, Bx::Value>, mir::BasicBlock)>,
+        cleanup: Option<mir::BasicBlock>,
+    ) {
+        if let Some(cleanup) = cleanup {
+            let ret_bx = if let Some((_, target)) = destination {
+                fx.blocks[target]
+            } else {
+                fx.unreachable_block()
+            };
+            let invokeret = bx.invoke(fn_ptr,
+                                      &llargs,
+                                      ret_bx,
+                                      self.llblock(fx, cleanup),
+                                      self.funclet(fx));
+            bx.apply_attrs_callsite(&fn_ty, invokeret);
+
+            if let Some((ret_dest, target)) = destination {
+                let mut ret_bx = fx.build_block(target);
+                fx.set_debug_loc(&mut ret_bx, self.terminator.source_info);
+                fx.store_return(&mut ret_bx, ret_dest, &fn_ty.ret, invokeret);
             }
-        }
-        let funclet = funclet_closure_factory(funclet_bb);
-
-        let lltarget = |this: &mut Self, target: mir::BasicBlock| {
-            let lltarget = this.blocks[target];
-            let target_funclet = this.cleanup_kinds[target].funclet_bb(target);
-            match (funclet_bb, target_funclet) {
-                (None, None) => (lltarget, false),
-                (Some(f), Some(t_f))
-                    if f == t_f || !base::wants_msvc_seh(tcx.sess)
-                    => (lltarget, false),
-                (None, Some(_)) => {
-                    // jump *into* cleanup - need a landing pad if GNU
-                    (this.landing_pad_to(target), false)
-                }
-                (Some(_), None) => span_bug!(span, "{:?} - jump out of cleanup?", terminator),
-                (Some(_), Some(_)) => {
-                    (this.landing_pad_to(target), true)
-                }
+        } else {
+            let llret = bx.call(fn_ptr, &llargs, self.funclet(fx));
+            bx.apply_attrs_callsite(&fn_ty, llret);
+            if fx.mir[*self.bb].is_cleanup {
+                // Cleanup is always the cold path. Don't inline
+                // drop glue. Also, when there is a deeply-nested
+                // struct, there are "symmetry" issues that cause
+                // exponential inlining - see issue #41696.
+                bx.do_not_inline(llret);
             }
-        };
-
-        let llblock = |this: &mut Self, target: mir::BasicBlock| {
-            let (lltarget, is_cleanupret) = lltarget(this, target);
-            if is_cleanupret {
-                // MSVC cross-funclet jump - need a trampoline
 
-                debug!("llblock: creating cleanup trampoline for {:?}", target);
-                let name = &format!("{:?}_cleanup_trampoline_{:?}", bb, target);
-                let mut trampoline = this.new_block(name);
-                trampoline.cleanup_ret(funclet(this).unwrap(), Some(lltarget));
-                trampoline.llbb()
+            if let Some((ret_dest, target)) = destination {
+                fx.store_return(bx, ret_dest, &fn_ty.ret, llret);
+                self.funclet_br(fx, bx, target);
             } else {
-                lltarget
+                bx.unreachable();
             }
-        };
-
-        let funclet_br =
-            |this: &mut Self, bx: &mut Bx, target: mir::BasicBlock| {
-                let (lltarget, is_cleanupret) = lltarget(this, target);
-                if is_cleanupret {
-                    // micro-optimization: generate a `ret` rather than a jump
-                    // to a trampoline.
-                    bx.cleanup_ret(funclet(this).unwrap(), Some(lltarget));
-                } else {
-                    bx.br(lltarget);
-                }
-            };
+        }
+    }
+}
 
-        let do_call = |
-            this: &mut Self,
-            bx: &mut Bx,
-            fn_ty: FnType<'tcx, Ty<'tcx>>,
-            fn_ptr: Bx::Value,
-            llargs: &[Bx::Value],
-            destination: Option<(ReturnDest<'tcx, Bx::Value>, mir::BasicBlock)>,
-            cleanup: Option<mir::BasicBlock>
-        | {
-            if let Some(cleanup) = cleanup {
-                let ret_bx = if let Some((_, target)) = destination {
-                    this.blocks[target]
-                } else {
-                    this.unreachable_block()
-                };
-                let invokeret = bx.invoke(fn_ptr,
-                                          &llargs,
-                                          ret_bx,
-                                          llblock(this, cleanup),
-                                          funclet(this));
-                bx.apply_attrs_callsite(&fn_ty, invokeret);
-
-                if let Some((ret_dest, target)) = destination {
-                    let mut ret_bx = this.build_block(target);
-                    this.set_debug_loc(&mut ret_bx, terminator.source_info);
-                    this.store_return(&mut ret_bx, ret_dest, &fn_ty.ret, invokeret);
-                }
+/// Codegen implementations for some terminator variants.
+impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
+    /// Generates code for a `Resume` terminator.
+    fn codegen_resume_terminator<'b>(
+        &mut self,
+        helper: TerminatorCodegenHelper<'b, 'tcx>,
+        mut bx: Bx,
+    ) {
+        if let Some(funclet) = helper.funclet(self) {
+            bx.cleanup_ret(funclet, None);
+        } else {
+            let slot = self.get_personality_slot(&mut bx);
+            let lp0 = slot.project_field(&mut bx, 0);
+            let lp0 = bx.load_operand(lp0).immediate();
+            let lp1 = slot.project_field(&mut bx, 1);
+            let lp1 = bx.load_operand(lp1).immediate();
+            slot.storage_dead(&mut bx);
+
+            if !bx.sess().target.target.options.custom_unwind_resume {
+                let mut lp = bx.const_undef(self.landing_pad_type());
+                lp = bx.insert_value(lp, lp0, 0);
+                lp = bx.insert_value(lp, lp1, 1);
+                bx.resume(lp);
             } else {
-                let llret = bx.call(fn_ptr, &llargs, funclet(this));
-                bx.apply_attrs_callsite(&fn_ty, llret);
-                if this.mir[bb].is_cleanup {
-                    // Cleanup is always the cold path. Don't inline
-                    // drop glue. Also, when there is a deeply-nested
-                    // struct, there are "symmetry" issues that cause
-                    // exponential inlining - see issue #41696.
-                    bx.do_not_inline(llret);
-                }
-
-                if let Some((ret_dest, target)) = destination {
-                    this.store_return(bx, ret_dest, &fn_ty.ret, llret);
-                    funclet_br(this, bx, target);
-                } else {
-                    bx.unreachable();
-                }
+                bx.call(bx.eh_unwind_resume(), &[lp0],
+                        helper.funclet(self));
+                bx.unreachable();
             }
-        };
+        }
+    }
 
-        self.set_debug_loc(&mut bx, terminator.source_info);
-        match terminator.kind {
-            mir::TerminatorKind::Resume => {
-                if let Some(funclet) = funclet(self) {
-                    bx.cleanup_ret(funclet, None);
+    fn codegen_switchint_terminator<'b>(
+        &mut self,
+        helper: TerminatorCodegenHelper<'b, 'tcx>,
+        mut bx: Bx,
+        discr: &mir::Operand<'tcx>,
+        switch_ty: Ty<'tcx>,
+        values: &Cow<'tcx, [u128]>,
+        targets: &Vec<mir::BasicBlock>,
+    ) {
+        let discr = self.codegen_operand(&mut bx, &discr);
+        if targets.len() == 2 {
+            // If there are two targets, emit br instead of switch
+            let lltrue = helper.llblock(self, targets[0]);
+            let llfalse = helper.llblock(self, targets[1]);
+            if switch_ty == bx.tcx().types.bool {
+                // Don't generate trivial icmps when switching on bool
+                if let [0] = values[..] {
+                    bx.cond_br(discr.immediate(), llfalse, lltrue);
                 } else {
-                    let slot = self.get_personality_slot(&mut bx);
-                    let lp0 = slot.project_field(&mut bx, 0);
-                    let lp0 = bx.load_operand(lp0).immediate();
-                    let lp1 = slot.project_field(&mut bx, 1);
-                    let lp1 = bx.load_operand(lp1).immediate();
-                    slot.storage_dead(&mut bx);
-
-                    if !bx.sess().target.target.options.custom_unwind_resume {
-                        let mut lp = bx.const_undef(self.landing_pad_type());
-                        lp = bx.insert_value(lp, lp0, 0);
-                        lp = bx.insert_value(lp, lp1, 1);
-                        bx.resume(lp);
-                    } else {
-                        bx.call(bx.eh_unwind_resume(), &[lp0], funclet(self));
-                        bx.unreachable();
-                    }
+                    assert_eq!(&values[..], &[1]);
+                    bx.cond_br(discr.immediate(), lltrue, llfalse);
                 }
+            } else {
+                let switch_llty = bx.immediate_backend_type(
+                    bx.layout_of(switch_ty)
+                );
+                let llval = bx.const_uint_big(switch_llty, values[0]);
+                let cmp = bx.icmp(IntPredicate::IntEQ, discr.immediate(), llval);
+                bx.cond_br(cmp, lltrue, llfalse);
+            }
+        } else {
+            let (otherwise, targets) = targets.split_last().unwrap();
+            let switch = bx.switch(discr.immediate(),
+                                   helper.llblock(self, *otherwise),
+                                   values.len());
+            let switch_llty = bx.immediate_backend_type(
+                bx.layout_of(switch_ty)
+            );
+            for (&value, target) in values.iter().zip(targets) {
+                let llval = bx.const_uint_big(switch_llty, value);
+                let llbb = helper.llblock(self, *target);
+                bx.add_case(switch, llval, llbb)
             }
+        }
+    }
 
-            mir::TerminatorKind::Abort => {
-                bx.abort();
-                bx.unreachable();
+    fn codegen_return_terminator<'b>(
+        &mut self,
+        mut bx: Bx,
+    ) {
+        if self.fn_ty.c_variadic {
+            if let Some(va_list) = self.va_list_ref {
+                bx.va_end(va_list.llval);
+            }
+        }
+        let llval = match self.fn_ty.ret.mode {
+            PassMode::Ignore(IgnoreMode::Zst) | PassMode::Indirect(..) => {
+                bx.ret_void();
+                return;
             }
 
-            mir::TerminatorKind::Goto { target } => {
-                funclet_br(self, &mut bx, target);
+            PassMode::Ignore(IgnoreMode::CVarArgs) => {
+                bug!("C-variadic arguments should never be the return type");
             }
 
-            mir::TerminatorKind::SwitchInt { ref discr, switch_ty, ref values, ref targets } => {
-                let discr = self.codegen_operand(&mut bx, discr);
-                if targets.len() == 2 {
-                    // If there are two targets, emit br instead of switch
-                    let lltrue = llblock(self, targets[0]);
-                    let llfalse = llblock(self, targets[1]);
-                    if switch_ty == bx.tcx().types.bool {
-                        // Don't generate trivial icmps when switching on bool
-                        if let [0] = values[..] {
-                            bx.cond_br(discr.immediate(), llfalse, lltrue);
-                        } else {
-                            assert_eq!(&values[..], &[1]);
-                            bx.cond_br(discr.immediate(), lltrue, llfalse);
-                        }
-                    } else {
-                        let switch_llty = bx.immediate_backend_type(
-                            bx.layout_of(switch_ty)
-                        );
-                        let llval = bx.const_uint_big(switch_llty, values[0]);
-                        let cmp = bx.icmp(IntPredicate::IntEQ, discr.immediate(), llval);
-                        bx.cond_br(cmp, lltrue, llfalse);
-                    }
+            PassMode::Direct(_) | PassMode::Pair(..) => {
+                let op =
+                    self.codegen_consume(&mut bx, &mir::Place::RETURN_PLACE);
+                if let Ref(llval, _, align) = op.val {
+                    bx.load(llval, align)
                 } else {
-                    let (otherwise, targets) = targets.split_last().unwrap();
-                    let switch = bx.switch(discr.immediate(),
-                                           llblock(self, *otherwise),
-                                           values.len());
-                    let switch_llty = bx.immediate_backend_type(
-                        bx.layout_of(switch_ty)
-                    );
-                    for (&value, target) in values.iter().zip(targets) {
-                        let llval = bx.const_uint_big(switch_llty, value);
-                        let llbb = llblock(self, *target);
-                        bx.add_case(switch, llval, llbb)
-                    }
+                    op.immediate_or_packed_pair(&mut bx)
                 }
             }
 
-            mir::TerminatorKind::Return => {
-                let llval = match self.fn_ty.ret.mode {
-                    PassMode::Ignore | PassMode::Indirect(..) => {
-                        bx.ret_void();
-                        return;
-                    }
-
-                    PassMode::Direct(_) | PassMode::Pair(..) => {
-                        let op =
-                            self.codegen_consume(&mut bx, &mir::Place::Local(mir::RETURN_PLACE));
-                        if let Ref(llval, _, align) = op.val {
-                            bx.load(llval, align)
-                        } else {
-                            op.immediate_or_packed_pair(&mut bx)
+            PassMode::Cast(cast_ty) => {
+                let op = match self.locals[mir::RETURN_PLACE] {
+                    LocalRef::Operand(Some(op)) => op,
+                    LocalRef::Operand(None) => bug!("use of return before def"),
+                    LocalRef::Place(cg_place) => {
+                        OperandRef {
+                            val: Ref(cg_place.llval, None, cg_place.align),
+                            layout: cg_place.layout
                         }
                     }
-
-                    PassMode::Cast(cast_ty) => {
-                        let op = match self.locals[mir::RETURN_PLACE] {
-                            LocalRef::Operand(Some(op)) => op,
-                            LocalRef::Operand(None) => bug!("use of return before def"),
-                            LocalRef::Place(cg_place) => {
-                                OperandRef {
-                                    val: Ref(cg_place.llval, None, cg_place.align),
-                                    layout: cg_place.layout
-                                }
-                            }
-                            LocalRef::UnsizedPlace(_) => bug!("return type must be sized"),
-                        };
-                        let llslot = match op.val {
-                            Immediate(_) | Pair(..) => {
-                                let scratch =
-                                    PlaceRef::alloca(&mut bx, self.fn_ty.ret.layout, "ret");
-                                op.val.store(&mut bx, scratch);
-                                scratch.llval
-                            }
-                            Ref(llval, _, align) => {
-                                assert_eq!(align, op.layout.align.abi,
-                                           "return place is unaligned!");
-                                llval
-                            }
-                        };
-                        let addr = bx.pointercast(llslot, bx.type_ptr_to(
-                            bx.cast_backend_type(&cast_ty)
-                        ));
-                        bx.load(addr, self.fn_ty.ret.layout.align.abi)
+                    LocalRef::UnsizedPlace(_) => bug!("return type must be sized"),
+                };
+                let llslot = match op.val {
+                    Immediate(_) | Pair(..) => {
+                        let scratch =
+                            PlaceRef::alloca(&mut bx, self.fn_ty.ret.layout, "ret");
+                        op.val.store(&mut bx, scratch);
+                        scratch.llval
+                    }
+                    Ref(llval, _, align) => {
+                        assert_eq!(align, op.layout.align.abi,
+                                   "return place is unaligned!");
+                        llval
                     }
                 };
-                bx.ret(llval);
+                let addr = bx.pointercast(llslot, bx.type_ptr_to(
+                    bx.cast_backend_type(&cast_ty)
+                ));
+                bx.load(addr, self.fn_ty.ret.layout.align.abi)
             }
+        };
+        bx.ret(llval);
+    }
 
-            mir::TerminatorKind::Unreachable => {
-                bx.unreachable();
+
+    fn codegen_drop_terminator<'b>(
+        &mut self,
+        helper: TerminatorCodegenHelper<'b, 'tcx>,
+        mut bx: Bx,
+        location: &mir::Place<'tcx>,
+        target: mir::BasicBlock,
+        unwind: Option<mir::BasicBlock>,
+    ) {
+        let ty = location.ty(self.mir, bx.tcx()).to_ty(bx.tcx());
+        let ty = self.monomorphize(&ty);
+        let drop_fn = monomorphize::resolve_drop_in_place(bx.tcx(), ty);
+
+        if let ty::InstanceDef::DropGlue(_, None) = drop_fn.def {
+            // we don't actually need to drop anything.
+            helper.funclet_br(self, &mut bx, target);
+            return
+        }
+
+        let place = self.codegen_place(&mut bx, location);
+        let (args1, args2);
+        let mut args = if let Some(llextra) = place.llextra {
+            args2 = [place.llval, llextra];
+            &args2[..]
+        } else {
+            args1 = [place.llval];
+            &args1[..]
+        };
+        let (drop_fn, fn_ty) = match ty.sty {
+            ty::Dynamic(..) => {
+                let sig = drop_fn.fn_sig(self.cx.tcx());
+                let sig = self.cx.tcx().normalize_erasing_late_bound_regions(
+                    ty::ParamEnv::reveal_all(),
+                    &sig,
+                );
+                let fn_ty = bx.new_vtable(sig, &[]);
+                let vtable = args[1];
+                args = &args[..1];
+                (meth::DESTRUCTOR.get_fn(&mut bx, vtable, &fn_ty), fn_ty)
+            }
+            _ => {
+                (bx.get_fn(drop_fn),
+                 bx.fn_type_of_instance(&drop_fn))
             }
+        };
+        helper.do_call(self, &mut bx, fn_ty, drop_fn, args,
+                       Some((ReturnDest::Nothing, target)),
+                       unwind);
+    }
 
-            mir::TerminatorKind::Drop { ref location, target, unwind } => {
-                let ty = location.ty(self.mir, bx.tcx()).to_ty(bx.tcx());
-                let ty = self.monomorphize(&ty);
-                let drop_fn = monomorphize::resolve_drop_in_place(bx.tcx(), ty);
-
-                if let ty::InstanceDef::DropGlue(_, None) = drop_fn.def {
-                    // we don't actually need to drop anything.
-                    funclet_br(self, &mut bx, target);
-                    return
-                }
+    fn codegen_assert_terminator<'b>(
+        &mut self,
+        helper: TerminatorCodegenHelper<'b, 'tcx>,
+        mut bx: Bx,
+        terminator: &mir::Terminator<'tcx>,
+        cond: &mir::Operand<'tcx>,
+        expected: bool,
+        msg: &mir::AssertMessage<'tcx>,
+        target: mir::BasicBlock,
+        cleanup: Option<mir::BasicBlock>,
+    ) {
+        let span = terminator.source_info.span;
+        let cond = self.codegen_operand(&mut bx, cond).immediate();
+        let mut const_cond = bx.const_to_opt_u128(cond, false).map(|c| c == 1);
+
+        // This case can currently arise only from functions marked
+        // with #[rustc_inherit_overflow_checks] and inlined from
+        // another crate (mostly core::num generic/#[inline] fns),
+        // while the current crate doesn't use overflow checks.
+        // NOTE: Unlike binops, negation doesn't have its own
+        // checked operation, just a comparison with the minimum
+        // value, so we have to check for the assert message.
+        if !bx.check_overflow() {
+            if let mir::interpret::EvalErrorKind::OverflowNeg = *msg {
+                const_cond = Some(expected);
+            }
+        }
 
-                let place = self.codegen_place(&mut bx, location);
-                let (args1, args2);
-                let mut args = if let Some(llextra) = place.llextra {
-                    args2 = [place.llval, llextra];
-                    &args2[..]
-                } else {
-                    args1 = [place.llval];
-                    &args1[..]
-                };
-                let (drop_fn, fn_ty) = match ty.sty {
-                    ty::Dynamic(..) => {
-                        let sig = drop_fn.fn_sig(tcx);
-                        let sig = tcx.normalize_erasing_late_bound_regions(
-                            ty::ParamEnv::reveal_all(),
-                            &sig,
-                        );
-                        let fn_ty = bx.new_vtable(sig, &[]);
-                        let vtable = args[1];
-                        args = &args[..1];
-                        (meth::DESTRUCTOR.get_fn(&mut bx, vtable, &fn_ty), fn_ty)
-                    }
-                    _ => {
-                        (bx.get_fn(drop_fn),
-                         bx.fn_type_of_instance(&drop_fn))
-                    }
-                };
-                do_call(self, &mut bx, fn_ty, drop_fn, args,
-                        Some((ReturnDest::Nothing, target)),
-                        unwind);
+        // Don't codegen the panic block if success if known.
+        if const_cond == Some(expected) {
+            helper.funclet_br(self, &mut bx, target);
+            return;
+        }
+
+        // Pass the condition through llvm.expect for branch hinting.
+        let cond = bx.expect(cond, expected);
+
+        // Create the failure block and the conditional branch to it.
+        let lltarget = helper.llblock(self, target);
+        let panic_block = self.new_block("panic");
+        if expected {
+            bx.cond_br(cond, lltarget, panic_block.llbb());
+        } else {
+            bx.cond_br(cond, panic_block.llbb(), lltarget);
+        }
+
+        // After this point, bx is the block for the call to panic.
+        bx = panic_block;
+        self.set_debug_loc(&mut bx, terminator.source_info);
+
+        // Get the location information.
+        let loc = bx.sess().source_map().lookup_char_pos(span.lo());
+        let filename = Symbol::intern(&loc.file.name.to_string()).as_str();
+        let filename = bx.const_str_slice(filename);
+        let line = bx.const_u32(loc.line as u32);
+        let col = bx.const_u32(loc.col.to_usize() as u32 + 1);
+        let align = self.cx.tcx().data_layout.aggregate_align.abi
+            .max(self.cx.tcx().data_layout.i32_align.abi)
+            .max(self.cx.tcx().data_layout.pointer_align.abi);
+
+        // Put together the arguments to the panic entry point.
+        let (lang_item, args) = match *msg {
+            EvalErrorKind::BoundsCheck { ref len, ref index } => {
+                let len = self.codegen_operand(&mut bx, len).immediate();
+                let index = self.codegen_operand(&mut bx, index).immediate();
+
+                let file_line_col = bx.const_struct(&[filename, line, col], false);
+                let file_line_col = bx.static_addr_of(
+                    file_line_col,
+                    align,
+                    Some("panic_bounds_check_loc")
+                );
+                (lang_items::PanicBoundsCheckFnLangItem,
+                 vec![file_line_col, index, len])
+            }
+            _ => {
+                let str = msg.description();
+                let msg_str = Symbol::intern(str).as_str();
+                let msg_str = bx.const_str_slice(msg_str);
+                let msg_file_line_col = bx.const_struct(
+                    &[msg_str, filename, line, col],
+                    false
+                );
+                let msg_file_line_col = bx.static_addr_of(
+                    msg_file_line_col,
+                    align,
+                    Some("panic_loc")
+                );
+                (lang_items::PanicFnLangItem,
+                 vec![msg_file_line_col])
             }
+        };
 
-            mir::TerminatorKind::Assert { ref cond, expected, ref msg, target, cleanup } => {
-                let cond = self.codegen_operand(&mut bx, cond).immediate();
-                let mut const_cond = bx.const_to_opt_u128(cond, false).map(|c| c == 1);
-
-                // This case can currently arise only from functions marked
-                // with #[rustc_inherit_overflow_checks] and inlined from
-                // another crate (mostly core::num generic/#[inline] fns),
-                // while the current crate doesn't use overflow checks.
-                // NOTE: Unlike binops, negation doesn't have its own
-                // checked operation, just a comparison with the minimum
-                // value, so we have to check for the assert message.
-                if !bx.check_overflow() {
-                    if let mir::interpret::EvalErrorKind::OverflowNeg = *msg {
-                        const_cond = Some(expected);
-                    }
-                }
+        // Obtain the panic entry point.
+        let def_id = common::langcall(bx.tcx(), Some(span), "", lang_item);
+        let instance = ty::Instance::mono(bx.tcx(), def_id);
+        let fn_ty = bx.fn_type_of_instance(&instance);
+        let llfn = bx.get_fn(instance);
 
-                // Don't codegen the panic block if success if known.
-                if const_cond == Some(expected) {
-                    funclet_br(self, &mut bx, target);
-                    return;
-                }
+        // Codegen the actual panic invoke/call.
+        helper.do_call(self, &mut bx, fn_ty, llfn, &args, None, cleanup);
+    }
 
-                // Pass the condition through llvm.expect for branch hinting.
-                let cond = bx.expect(cond, expected);
+    fn codegen_call_terminator<'b>(
+        &mut self,
+        helper: TerminatorCodegenHelper<'b, 'tcx>,
+        mut bx: Bx,
+        terminator: &mir::Terminator<'tcx>,
+        func: &mir::Operand<'tcx>,
+        args: &Vec<mir::Operand<'tcx>>,
+        destination: &Option<(mir::Place<'tcx>, mir::BasicBlock)>,
+        cleanup: Option<mir::BasicBlock>,
+    ) {
+        let span = terminator.source_info.span;
+        // Create the callee. This is a fn ptr or zero-sized and hence a kind of scalar.
+        let callee = self.codegen_operand(&mut bx, func);
+
+        let (instance, mut llfn) = match callee.layout.ty.sty {
+            ty::FnDef(def_id, substs) => {
+                (Some(ty::Instance::resolve(bx.tcx(),
+                                            ty::ParamEnv::reveal_all(),
+                                            def_id,
+                                            substs).unwrap()),
+                 None)
+            }
+            ty::FnPtr(_) => {
+                (None, Some(callee.immediate()))
+            }
+            _ => bug!("{} is not callable", callee.layout.ty),
+        };
+        let def = instance.map(|i| i.def);
+        let sig = callee.layout.ty.fn_sig(bx.tcx());
+        let sig = bx.tcx().normalize_erasing_late_bound_regions(
+            ty::ParamEnv::reveal_all(),
+            &sig,
+        );
+        let abi = sig.abi;
+
+        // Handle intrinsics old codegen wants Expr's for, ourselves.
+        let intrinsic = match def {
+            Some(ty::InstanceDef::Intrinsic(def_id)) =>
+                Some(bx.tcx().item_name(def_id).as_str()),
+            _ => None
+        };
+        let intrinsic = intrinsic.as_ref().map(|s| &s[..]);
 
-                // Create the failure block and the conditional branch to it.
-                let lltarget = llblock(self, target);
-                let panic_block = self.new_block("panic");
-                if expected {
-                    bx.cond_br(cond, lltarget, panic_block.llbb());
-                } else {
-                    bx.cond_br(cond, panic_block.llbb(), lltarget);
-                }
+        if intrinsic == Some("transmute") {
+            if let Some(destination_ref) = destination.as_ref() {
+                let &(ref dest, target) = destination_ref;
+                self.codegen_transmute(&mut bx, &args[0], dest);
+                helper.funclet_br(self, &mut bx, target);
+            } else {
+                // If we are trying to transmute to an uninhabited type,
+                // it is likely there is no allotted destination. In fact,
+                // transmuting to an uninhabited type is UB, which means
+                // we can do what we like. Here, we declare that transmuting
+                // into an uninhabited type is impossible, so anything following
+                // it must be unreachable.
+                assert_eq!(bx.layout_of(sig.output()).abi, layout::Abi::Uninhabited);
+                bx.unreachable();
+            }
+            return;
+        }
 
-                // After this point, bx is the block for the call to panic.
-                bx = panic_block;
-                self.set_debug_loc(&mut bx, terminator.source_info);
+        // The "spoofed" `VaList` added to a C-variadic functions signature
+        // should not be included in the `extra_args` calculation.
+        let extra_args_start_idx = sig.inputs().len() - if sig.c_variadic { 1 } else { 0 };
+        let extra_args = &args[extra_args_start_idx..];
+        let extra_args = extra_args.iter().map(|op_arg| {
+            let op_ty = op_arg.ty(self.mir, bx.tcx());
+            self.monomorphize(&op_ty)
+        }).collect::<Vec<_>>();
+
+        let fn_ty = match def {
+            Some(ty::InstanceDef::Virtual(..)) => {
+                bx.new_vtable(sig, &extra_args)
+            }
+            Some(ty::InstanceDef::DropGlue(_, None)) => {
+                // Empty drop glue; a no-op.
+                let &(_, target) = destination.as_ref().unwrap();
+                helper.funclet_br(self, &mut bx, target);
+                return;
+            }
+            _ => bx.new_fn_type(sig, &extra_args)
+        };
 
-                // Get the location information.
+        // Emit a panic or a no-op for `panic_if_uninhabited`.
+        if intrinsic == Some("panic_if_uninhabited") {
+            let ty = instance.unwrap().substs.type_at(0);
+            let layout = bx.layout_of(ty);
+            if layout.abi.is_uninhabited() {
                 let loc = bx.sess().source_map().lookup_char_pos(span.lo());
                 let filename = Symbol::intern(&loc.file.name.to_string()).as_str();
                 let filename = bx.const_str_slice(filename);
                 let line = bx.const_u32(loc.line as u32);
                 let col = bx.const_u32(loc.col.to_usize() as u32 + 1);
-                let align = tcx.data_layout.aggregate_align.abi
-                    .max(tcx.data_layout.i32_align.abi)
-                    .max(tcx.data_layout.pointer_align.abi);
-
-                // Put together the arguments to the panic entry point.
-                let (lang_item, args) = match *msg {
-                    EvalErrorKind::BoundsCheck { ref len, ref index } => {
-                        let len = self.codegen_operand(&mut bx, len).immediate();
-                        let index = self.codegen_operand(&mut bx, index).immediate();
-
-                        let file_line_col = bx.const_struct(&[filename, line, col], false);
-                        let file_line_col = bx.static_addr_of(
-                            file_line_col,
-                            align,
-                            Some("panic_bounds_check_loc")
-                        );
-                        (lang_items::PanicBoundsCheckFnLangItem,
-                         vec![file_line_col, index, len])
-                    }
-                    _ => {
-                        let str = msg.description();
-                        let msg_str = Symbol::intern(str).as_str();
-                        let msg_str = bx.const_str_slice(msg_str);
-                        let msg_file_line_col = bx.const_struct(
-                            &[msg_str, filename, line, col],
-                            false
-                        );
-                        let msg_file_line_col = bx.static_addr_of(
-                            msg_file_line_col,
-                            align,
-                            Some("panic_loc")
-                        );
-                        (lang_items::PanicFnLangItem,
-                         vec![msg_file_line_col])
-                    }
-                };
+                let align = self.cx.tcx().data_layout.aggregate_align.abi
+                    .max(self.cx.tcx().data_layout.i32_align.abi)
+                    .max(self.cx.tcx().data_layout.pointer_align.abi);
+
+                let str = format!(
+                    "Attempted to instantiate uninhabited type {}",
+                    ty
+                );
+                let msg_str = Symbol::intern(&str).as_str();
+                let msg_str = bx.const_str_slice(msg_str);
+                let msg_file_line_col = bx.const_struct(
+                    &[msg_str, filename, line, col],
+                    false,
+                );
+                let msg_file_line_col = bx.static_addr_of(
+                    msg_file_line_col,
+                    align,
+                    Some("panic_loc"),
+                );
 
                 // Obtain the panic entry point.
-                let def_id = common::langcall(bx.tcx(), Some(span), "", lang_item);
+                let def_id =
+                    common::langcall(bx.tcx(), Some(span), "", lang_items::PanicFnLangItem);
                 let instance = ty::Instance::mono(bx.tcx(), def_id);
                 let fn_ty = bx.fn_type_of_instance(&instance);
                 let llfn = bx.get_fn(instance);
 
                 // Codegen the actual panic invoke/call.
-                do_call(self, &mut bx, fn_ty, llfn, &args, None, cleanup);
+                helper.do_call(
+                    self,
+                    &mut bx,
+                    fn_ty,
+                    llfn,
+                    &[msg_file_line_col],
+                    destination.as_ref().map(|(_, bb)| (ReturnDest::Nothing, *bb)),
+                    cleanup,
+                );
+            } else {
+                // a NOP
+                helper.funclet_br(self, &mut bx, destination.as_ref().unwrap().1)
             }
+            return;
+        }
 
-            mir::TerminatorKind::DropAndReplace { .. } => {
-                bug!("undesugared DropAndReplace in codegen: {:?}", terminator);
-            }
+        // The arguments we'll be passing. Plus one to account for outptr, if used.
+        let arg_count = fn_ty.args.len() + fn_ty.ret.is_indirect() as usize;
+        let mut llargs = Vec::with_capacity(arg_count);
 
-            mir::TerminatorKind::Call {
-                ref func,
-                ref args,
-                ref destination,
-                cleanup,
-                from_hir_call: _
-            } => {
-                // Create the callee. This is a fn ptr or zero-sized and hence a kind of scalar.
-                let callee = self.codegen_operand(&mut bx, func);
-
-                let (instance, mut llfn) = match callee.layout.ty.sty {
-                    ty::FnDef(def_id, substs) => {
-                        (Some(ty::Instance::resolve(bx.tcx(),
-                                                    ty::ParamEnv::reveal_all(),
-                                                    def_id,
-                                                    substs).unwrap()),
-                         None)
-                    }
-                    ty::FnPtr(_) => {
-                        (None, Some(callee.immediate()))
-                    }
-                    _ => bug!("{} is not callable", callee.layout.ty)
-                };
-                let def = instance.map(|i| i.def);
-                let sig = callee.layout.ty.fn_sig(bx.tcx());
-                let sig = bx.tcx().normalize_erasing_late_bound_regions(
-                    ty::ParamEnv::reveal_all(),
-                    &sig,
-                );
-                let abi = sig.abi;
+        // Prepare the return value destination
+        let ret_dest = if let Some((ref dest, _)) = *destination {
+            let is_intrinsic = intrinsic.is_some();
+            self.make_return_dest(&mut bx, dest, &fn_ty.ret, &mut llargs,
+                                  is_intrinsic)
+        } else {
+            ReturnDest::Nothing
+        };
 
-                // Handle intrinsics old codegen wants Expr's for, ourselves.
-                let intrinsic = match def {
-                    Some(ty::InstanceDef::Intrinsic(def_id))
-                        => Some(bx.tcx().item_name(def_id).as_str()),
-                    _ => None
-                };
-                let intrinsic = intrinsic.as_ref().map(|s| &s[..]);
+        if intrinsic.is_some() && intrinsic != Some("drop_in_place") {
+            let dest = match ret_dest {
+                _ if fn_ty.ret.is_indirect() => llargs[0],
+                ReturnDest::Nothing =>
+                    bx.const_undef(bx.type_ptr_to(bx.memory_ty(&fn_ty.ret))),
+                ReturnDest::IndirectOperand(dst, _) | ReturnDest::Store(dst) =>
+                    dst.llval,
+                ReturnDest::DirectOperand(_) =>
+                    bug!("Cannot use direct operand with an intrinsic call"),
+            };
 
-                if intrinsic == Some("transmute") {
-                    if let Some(destination_ref) = destination.as_ref() {
-                        let &(ref dest, target) = destination_ref;
-                        self.codegen_transmute(&mut bx, &args[0], dest);
-                        funclet_br(self, &mut bx, target);
-                    } else {
-                        // If we are trying to transmute to an uninhabited type,
-                        // it is likely there is no allotted destination. In fact,
-                        // transmuting to an uninhabited type is UB, which means
-                        // we can do what we like. Here, we declare that transmuting
-                        // into an uninhabited type is impossible, so anything following
-                        // it must be unreachable.
-                        assert_eq!(bx.layout_of(sig.output()).abi, layout::Abi::Uninhabited);
-                        bx.unreachable();
+            let args: Vec<_> = args.iter().enumerate().map(|(i, arg)| {
+                // The indices passed to simd_shuffle* in the
+                // third argument must be constant. This is
+                // checked by const-qualification, which also
+                // promotes any complex rvalues to constants.
+                if i == 2 && intrinsic.unwrap().starts_with("simd_shuffle") {
+                    match *arg {
+                        // The shuffle array argument is usually not an explicit constant,
+                        // but specified directly in the code. This means it gets promoted
+                        // and we can then extract the value by evaluating the promoted.
+                        mir::Operand::Copy(
+                            mir::Place::Base(mir::PlaceBase::Promoted(box(index, ty)))
+                        ) |
+                        mir::Operand::Move(
+                            mir::Place::Base(mir::PlaceBase::Promoted(box(index, ty)))
+                        ) => {
+                            let param_env = ty::ParamEnv::reveal_all();
+                            let cid = mir::interpret::GlobalId {
+                                instance: self.instance,
+                                promoted: Some(index),
+                            };
+                            let c = bx.tcx().const_eval(param_env.and(cid));
+                            let (llval, ty) = self.simd_shuffle_indices(
+                                &bx,
+                                terminator.source_info.span,
+                                ty,
+                                c,
+                            );
+                            return OperandRef {
+                                val: Immediate(llval),
+                                layout: bx.layout_of(ty),
+                            };
+
+                        }
+                        mir::Operand::Copy(_) |
+                        mir::Operand::Move(_) => {
+                            span_bug!(span, "shuffle indices must be constant");
+                        }
+                        mir::Operand::Constant(ref constant) => {
+                            let c = self.eval_mir_constant(&bx, constant);
+                            let (llval, ty) = self.simd_shuffle_indices(
+                                &bx,
+                                constant.span,
+                                constant.ty,
+                                c,
+                            );
+                            return OperandRef {
+                                val: Immediate(llval),
+                                layout: bx.layout_of(ty)
+                            };
+                        }
                     }
-                    return;
                 }
 
-                let extra_args = &args[sig.inputs().len()..];
-                let extra_args = extra_args.iter().map(|op_arg| {
-                    let op_ty = op_arg.ty(self.mir, bx.tcx());
-                    self.monomorphize(&op_ty)
-                }).collect::<Vec<_>>();
+                self.codegen_operand(&mut bx, arg)
+            }).collect();
 
-                let fn_ty = match def {
-                    Some(ty::InstanceDef::Virtual(..)) => {
-                        bx.new_vtable(sig, &extra_args)
-                    }
-                    Some(ty::InstanceDef::DropGlue(_, None)) => {
-                        // empty drop glue - a nop.
-                        let &(_, target) = destination.as_ref().unwrap();
-                        funclet_br(self, &mut bx, target);
-                        return;
-                    }
-                    _ => bx.new_fn_type(sig, &extra_args)
+
+            let callee_ty = instance.as_ref().unwrap().ty(bx.tcx());
+            bx.codegen_intrinsic_call(callee_ty, &fn_ty, &args, dest,
+                                      terminator.source_info.span);
+
+            if let ReturnDest::IndirectOperand(dst, _) = ret_dest {
+                self.store_return(&mut bx, ret_dest, &fn_ty.ret, dst.llval);
+            }
+
+            if let Some((_, target)) = *destination {
+                helper.funclet_br(self, &mut bx, target);
+            } else {
+                bx.unreachable();
+            }
+
+            return;
+        }
+
+        // Split the rust-call tupled arguments off.
+        let (first_args, untuple) = if abi == Abi::RustCall && !args.is_empty() {
+            let (tup, args) = args.split_last().unwrap();
+            (args, Some(tup))
+        } else {
+            (&args[..], None)
+        };
+
+        // Useful determining if the current argument is the "spoofed" `VaList`
+        let last_arg_idx = if sig.inputs().is_empty() {
+            None
+        } else {
+            Some(sig.inputs().len() - 1)
+        };
+        'make_args: for (i, arg) in first_args.iter().enumerate() {
+            // If this is a C-variadic function the function signature contains
+            // an "spoofed" `VaList`. This argument is ignored, but we need to
+            // populate it with a dummy operand so that the users real arguments
+            // are not overwritten.
+            let i = if sig.c_variadic && last_arg_idx.map(|x| x == i).unwrap_or(false) {
+                let layout = match self.cx.tcx().lang_items().va_list() {
+                    Some(did) => bx.cx().layout_of(bx.tcx().type_of(did)),
+                    None => bug!("`va_list` language item required for C-variadics"),
                 };
+                let op = OperandRef {
+                    val: OperandValue::Immediate(
+                        bx.cx().const_undef(bx.cx().immediate_backend_type(layout)
+                    )),
+                    layout: layout,
+                };
+                self.codegen_argument(&mut bx, op, &mut llargs, &fn_ty.args[i]);
+                if i + 1 < fn_ty.args.len() {
+                    i + 1
+                } else {
+                    break 'make_args
+                }
+            } else {
+                i
+            };
+            let mut op = self.codegen_operand(&mut bx, arg);
+
+            if let (0, Some(ty::InstanceDef::Virtual(_, idx))) = (i, def) {
+                if let Pair(..) = op.val {
+                    // In the case of Rc<Self>, we need to explicitly pass a
+                    // *mut RcBox<Self> with a Scalar (not ScalarPair) ABI. This is a hack
+                    // that is understood elsewhere in the compiler as a method on
+                    // `dyn Trait`.
+                    // To get a `*mut RcBox<Self>`, we just keep unwrapping newtypes until
+                    // we get a value of a built-in pointer type
+                    'descend_newtypes: while !op.layout.ty.is_unsafe_ptr()
+                                    && !op.layout.ty.is_region_ptr()
+                    {
+                        'iter_fields: for i in 0..op.layout.fields.count() {
+                            let field = op.extract_field(&mut bx, i);
+                            if !field.layout.is_zst() {
+                                // we found the one non-zero-sized field that is allowed
+                                // now find *its* non-zero-sized field, or stop if it's a
+                                // pointer
+                                op = field;
+                                continue 'descend_newtypes
+                            }
+                        }
 
-                // emit a panic or a NOP for `panic_if_uninhabited`
-                if intrinsic == Some("panic_if_uninhabited") {
-                    let ty = instance.unwrap().substs.type_at(0);
-                    let layout = bx.layout_of(ty);
-                    if layout.abi.is_uninhabited() {
-                        let loc = bx.sess().source_map().lookup_char_pos(span.lo());
-                        let filename = Symbol::intern(&loc.file.name.to_string()).as_str();
-                        let filename = bx.const_str_slice(filename);
-                        let line = bx.const_u32(loc.line as u32);
-                        let col = bx.const_u32(loc.col.to_usize() as u32 + 1);
-                        let align = tcx.data_layout.aggregate_align.abi
-                            .max(tcx.data_layout.i32_align.abi)
-                            .max(tcx.data_layout.pointer_align.abi);
-
-                        let str = format!(
-                            "Attempted to instantiate uninhabited type {}",
-                            ty
-                        );
-                        let msg_str = Symbol::intern(&str).as_str();
-                        let msg_str = bx.const_str_slice(msg_str);
-                        let msg_file_line_col = bx.const_struct(
-                            &[msg_str, filename, line, col],
-                            false,
-                        );
-                        let msg_file_line_col = bx.static_addr_of(
-                            msg_file_line_col,
-                            align,
-                            Some("panic_loc"),
-                        );
-
-                        // Obtain the panic entry point.
-                        let def_id =
-                            common::langcall(bx.tcx(), Some(span), "", lang_items::PanicFnLangItem);
-                        let instance = ty::Instance::mono(bx.tcx(), def_id);
-                        let fn_ty = bx.fn_type_of_instance(&instance);
-                        let llfn = bx.get_fn(instance);
-
-                        // Codegen the actual panic invoke/call.
-                        do_call(
-                            self,
-                            &mut bx,
-                            fn_ty,
-                            llfn,
-                            &[msg_file_line_col],
-                            destination.as_ref().map(|(_, bb)| (ReturnDest::Nothing, *bb)),
-                            cleanup,
-                        );
-                    } else {
-                        // a NOP
-                        funclet_br(self, &mut bx, destination.as_ref().unwrap().1);
+                        span_bug!(span, "receiver has no non-zero-sized fields {:?}", op);
                     }
-                    return;
+
+                    // now that we have `*dyn Trait` or `&dyn Trait`, split it up into its
+                    // data pointer and vtable. Look up the method in the vtable, and pass
+                    // the data pointer as the first argument
+                    match op.val {
+                        Pair(data_ptr, meta) => {
+                            llfn = Some(meth::VirtualIndex::from_index(idx)
+                                .get_fn(&mut bx, meta, &fn_ty));
+                            llargs.push(data_ptr);
+                            continue 'make_args
+                        }
+                        other => bug!("expected a Pair, got {:?}", other),
+                    }
+                } else if let Ref(data_ptr, Some(meta), _) = op.val {
+                    // by-value dynamic dispatch
+                    llfn = Some(meth::VirtualIndex::from_index(idx)
+                        .get_fn(&mut bx, meta, &fn_ty));
+                    llargs.push(data_ptr);
+                    continue;
+                } else {
+                    span_bug!(span, "can't codegen a virtual call on {:?}", op);
                 }
+            }
 
-                // The arguments we'll be passing. Plus one to account for outptr, if used.
-                let arg_count = fn_ty.args.len() + fn_ty.ret.is_indirect() as usize;
-                let mut llargs = Vec::with_capacity(arg_count);
+            // The callee needs to own the argument memory if we pass it
+            // by-ref, so make a local copy of non-immediate constants.
+            match (arg, op.val) {
+                (&mir::Operand::Copy(_), Ref(_, None, _)) |
+                (&mir::Operand::Constant(_), Ref(_, None, _)) => {
+                    let tmp = PlaceRef::alloca(&mut bx, op.layout, "const");
+                    op.val.store(&mut bx, tmp);
+                    op.val = Ref(tmp.llval, None, tmp.align);
+                }
+                _ => {}
+            }
 
-                // Prepare the return value destination
-                let ret_dest = if let Some((ref dest, _)) = *destination {
-                    let is_intrinsic = intrinsic.is_some();
-                    self.make_return_dest(&mut bx, dest, &fn_ty.ret, &mut llargs,
-                                          is_intrinsic)
-                } else {
-                    ReturnDest::Nothing
-                };
+            self.codegen_argument(&mut bx, op, &mut llargs, &fn_ty.args[i]);
+        }
+        if let Some(tup) = untuple {
+            self.codegen_arguments_untupled(&mut bx, tup, &mut llargs,
+                &fn_ty.args[first_args.len()..])
+        }
 
-                if intrinsic.is_some() && intrinsic != Some("drop_in_place") {
-                    let dest = match ret_dest {
-                        _ if fn_ty.ret.is_indirect() => llargs[0],
-                        ReturnDest::Nothing => {
-                            bx.const_undef(bx.type_ptr_to(bx.memory_ty(&fn_ty.ret)))
-                        }
-                        ReturnDest::IndirectOperand(dst, _) |
-                        ReturnDest::Store(dst) => dst.llval,
-                        ReturnDest::DirectOperand(_) =>
-                            bug!("Cannot use direct operand with an intrinsic call")
-                    };
+        let fn_ptr = match (llfn, instance) {
+            (Some(llfn), _) => llfn,
+            (None, Some(instance)) => bx.get_fn(instance),
+            _ => span_bug!(span, "no llfn for call"),
+        };
 
-                    let args: Vec<_> = args.iter().enumerate().map(|(i, arg)| {
-                        // The indices passed to simd_shuffle* in the
-                        // third argument must be constant. This is
-                        // checked by const-qualification, which also
-                        // promotes any complex rvalues to constants.
-                        if i == 2 && intrinsic.unwrap().starts_with("simd_shuffle") {
-                            match *arg {
-                                // The shuffle array argument is usually not an explicit constant,
-                                // but specified directly in the code. This means it gets promoted
-                                // and we can then extract the value by evaluating the promoted.
-                                mir::Operand::Copy(mir::Place::Promoted(box(index, ty))) |
-                                mir::Operand::Move(mir::Place::Promoted(box(index, ty))) => {
-                                    let param_env = ty::ParamEnv::reveal_all();
-                                    let cid = mir::interpret::GlobalId {
-                                        instance: self.instance,
-                                        promoted: Some(index),
-                                    };
-                                    let c = bx.tcx().const_eval(param_env.and(cid));
-                                    let (llval, ty) = self.simd_shuffle_indices(
-                                        &bx,
-                                        terminator.source_info.span,
-                                        ty,
-                                        c,
-                                    );
-                                    return OperandRef {
-                                        val: Immediate(llval),
-                                        layout: bx.layout_of(ty),
-                                    };
-
-                                },
-                                mir::Operand::Copy(_) |
-                                mir::Operand::Move(_) => {
-                                    span_bug!(span, "shuffle indices must be constant");
-                                }
-                                mir::Operand::Constant(ref constant) => {
-                                    let c = self.eval_mir_constant(&bx, constant);
-                                    let (llval, ty) = self.simd_shuffle_indices(
-                                        &bx,
-                                        constant.span,
-                                        constant.ty,
-                                        c,
-                                    );
-                                    return OperandRef {
-                                        val: Immediate(llval),
-                                        layout: bx.layout_of(ty)
-                                    };
-                                }
-                            }
-                        }
+        helper.do_call(self, &mut bx, fn_ty, fn_ptr, &llargs,
+                       destination.as_ref().map(|&(_, target)| (ret_dest, target)),
+                       cleanup);
+    }
+}
 
-                        self.codegen_operand(&mut bx, arg)
-                    }).collect();
+impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
+    pub fn codegen_block(
+        &mut self,
+        bb: mir::BasicBlock,
+    ) {
+        let mut bx = self.build_block(bb);
+        let data = &self.mir[bb];
 
+        debug!("codegen_block({:?}={:?})", bb, data);
 
-                    let callee_ty = instance.as_ref().unwrap().ty(bx.tcx());
-                    bx.codegen_intrinsic_call(callee_ty, &fn_ty, &args, dest,
-                                               terminator.source_info.span);
+        for statement in &data.statements {
+            bx = self.codegen_statement(bx, statement);
+        }
 
-                    if let ReturnDest::IndirectOperand(dst, _) = ret_dest {
-                        self.store_return(&mut bx, ret_dest, &fn_ty.ret, dst.llval);
-                    }
+        self.codegen_terminator(bx, bb, data.terminator());
+    }
 
-                    if let Some((_, target)) = *destination {
-                        funclet_br(self, &mut bx, target);
-                    } else {
-                        bx.unreachable();
-                    }
+    fn codegen_terminator(
+        &mut self,
+        mut bx: Bx,
+        bb: mir::BasicBlock,
+        terminator: &mir::Terminator<'tcx>
+    ) {
+        debug!("codegen_terminator: {:?}", terminator);
 
-                    return;
-                }
+        // Create the cleanup bundle, if needed.
+        let funclet_bb = self.cleanup_kinds[bb].funclet_bb(bb);
+        let helper = TerminatorCodegenHelper {
+            bb: &bb, terminator, funclet_bb
+        };
 
-                // Split the rust-call tupled arguments off.
-                let (first_args, untuple) = if abi == Abi::RustCall && !args.is_empty() {
-                    let (tup, args) = args.split_last().unwrap();
-                    (args, Some(tup))
-                } else {
-                    (&args[..], None)
-                };
+        self.set_debug_loc(&mut bx, terminator.source_info);
+        match terminator.kind {
+            mir::TerminatorKind::Resume => {
+                self.codegen_resume_terminator(helper, bx)
+            }
 
-                'make_args: for (i, arg) in first_args.iter().enumerate() {
-                    let mut op = self.codegen_operand(&mut bx, arg);
-
-                    if let (0, Some(ty::InstanceDef::Virtual(_, idx))) = (i, def) {
-                        if let Pair(..) = op.val {
-                            // In the case of Rc<Self>, we need to explicitly pass a
-                            // *mut RcBox<Self> with a Scalar (not ScalarPair) ABI. This is a hack
-                            // that is understood elsewhere in the compiler as a method on
-                            // `dyn Trait`.
-                            // To get a `*mut RcBox<Self>`, we just keep unwrapping newtypes until
-                            // we get a value of a built-in pointer type
-                            'descend_newtypes: while !op.layout.ty.is_unsafe_ptr()
-                                            && !op.layout.ty.is_region_ptr()
-                            {
-                                'iter_fields: for i in 0..op.layout.fields.count() {
-                                    let field = op.extract_field(&mut bx, i);
-                                    if !field.layout.is_zst() {
-                                        // we found the one non-zero-sized field that is allowed
-                                        // now find *its* non-zero-sized field, or stop if it's a
-                                        // pointer
-                                        op = field;
-                                        continue 'descend_newtypes
-                                    }
-                                }
-
-                                span_bug!(span, "receiver has no non-zero-sized fields {:?}", op);
-                            }
+            mir::TerminatorKind::Abort => {
+                bx.abort();
+                bx.unreachable();
+            }
 
-                            // now that we have `*dyn Trait` or `&dyn Trait`, split it up into its
-                            // data pointer and vtable. Look up the method in the vtable, and pass
-                            // the data pointer as the first argument
-                            match op.val {
-                                Pair(data_ptr, meta) => {
-                                    llfn = Some(meth::VirtualIndex::from_index(idx)
-                                        .get_fn(&mut bx, meta, &fn_ty));
-                                    llargs.push(data_ptr);
-                                    continue 'make_args
-                                }
-                                other => bug!("expected a Pair, got {:?}", other)
-                            }
-                        } else if let Ref(data_ptr, Some(meta), _) = op.val {
-                            // by-value dynamic dispatch
-                            llfn = Some(meth::VirtualIndex::from_index(idx)
-                                .get_fn(&mut bx, meta, &fn_ty));
-                            llargs.push(data_ptr);
-                            continue;
-                        } else {
-                            span_bug!(span, "can't codegen a virtual call on {:?}", op);
-                        }
-                    }
+            mir::TerminatorKind::Goto { target } => {
+                helper.funclet_br(self, &mut bx, target);
+            }
 
-                    // The callee needs to own the argument memory if we pass it
-                    // by-ref, so make a local copy of non-immediate constants.
-                    match (arg, op.val) {
-                        (&mir::Operand::Copy(_), Ref(_, None, _)) |
-                        (&mir::Operand::Constant(_), Ref(_, None, _)) => {
-                            let tmp = PlaceRef::alloca(&mut bx, op.layout, "const");
-                            op.val.store(&mut bx, tmp);
-                            op.val = Ref(tmp.llval, None, tmp.align);
-                        }
-                        _ => {}
-                    }
+            mir::TerminatorKind::SwitchInt {
+                ref discr, switch_ty, ref values, ref targets
+            } => {
+                self.codegen_switchint_terminator(helper, bx, discr, switch_ty,
+                                                  values, targets);
+            }
 
-                    self.codegen_argument(&mut bx, op, &mut llargs, &fn_ty.args[i]);
-                }
-                if let Some(tup) = untuple {
-                    self.codegen_arguments_untupled(&mut bx, tup, &mut llargs,
-                        &fn_ty.args[first_args.len()..])
-                }
+            mir::TerminatorKind::Return => {
+                self.codegen_return_terminator(bx);
+            }
 
-                let fn_ptr = match (llfn, instance) {
-                    (Some(llfn), _) => llfn,
-                    (None, Some(instance)) => bx.get_fn(instance),
-                    _ => span_bug!(span, "no llfn for call"),
-                };
+            mir::TerminatorKind::Unreachable => {
+                bx.unreachable();
+            }
 
-                do_call(self, &mut bx, fn_ty, fn_ptr, &llargs,
-                        destination.as_ref().map(|&(_, target)| (ret_dest, target)),
-                        cleanup);
+            mir::TerminatorKind::Drop { ref location, target, unwind } => {
+                self.codegen_drop_terminator(helper, bx, location, target, unwind);
+            }
+
+            mir::TerminatorKind::Assert { ref cond, expected, ref msg, target, cleanup } => {
+                self.codegen_assert_terminator(helper, bx, terminator, cond,
+                                               expected, msg, target, cleanup);
+            }
+
+            mir::TerminatorKind::DropAndReplace { .. } => {
+                bug!("undesugared DropAndReplace in codegen: {:?}", terminator);
+            }
+
+            mir::TerminatorKind::Call {
+                ref func,
+                ref args,
+                ref destination,
+                cleanup,
+                from_hir_call: _
+            } => {
+                self.codegen_call_terminator(helper, bx, terminator, func,
+                                             args, destination, cleanup);
             }
             mir::TerminatorKind::GeneratorDrop |
             mir::TerminatorKind::Yield { .. } => bug!("generator ops in codegen"),
@@ -964,7 +1110,7 @@ fn make_return_dest(
         if fn_ret.is_ignore() {
             return ReturnDest::Nothing;
         }
-        let dest = if let mir::Place::Local(index) = *dest {
+        let dest = if let mir::Place::Base(mir::PlaceBase::Local(index)) = *dest {
             match self.locals[index] {
                 LocalRef::Place(dest) => dest,
                 LocalRef::UnsizedPlace(_) => bug!("return type must be sized"),
@@ -1019,7 +1165,7 @@ fn codegen_transmute(
         src: &mir::Operand<'tcx>,
         dst: &mir::Place<'tcx>
     ) {
-        if let mir::Place::Local(index) = *dst {
+        if let mir::Place::Base(mir::PlaceBase::Local(index)) = *dst {
             match self.locals[index] {
                 LocalRef::Place(place) => self.codegen_transmute_into(bx, src, place),
                 LocalRef::UnsizedPlace(_) => bug!("transmute must not involve unsized locals"),
index 203d84bff5bb3a9afd001908359c60f75d0ef740..dc77d4673cd2a3594b3e9d4865925eb04a3dc7c4 100644 (file)
@@ -2,10 +2,10 @@
 use rustc::ty::{self, Ty, TypeFoldable, UpvarSubsts};
 use rustc::ty::layout::{TyLayout, HasTyCtxt};
 use rustc::mir::{self, Mir};
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::SubstsRef;
 use rustc::session::config::DebugInfo;
 use rustc_mir::monomorphize::Instance;
-use rustc_target::abi::call::{FnType, PassMode};
+use rustc_target::abi::call::{FnType, PassMode, IgnoreMode};
 use crate::base;
 use crate::debuginfo::{self, VariableAccess, VariableKind, FunctionDebugContext};
 use crate::traits::*;
@@ -85,7 +85,11 @@ pub struct FunctionCx<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> {
     scopes: IndexVec<mir::SourceScope, debuginfo::MirDebugScope<Bx::DIScope>>,
 
     /// If this function is being monomorphized, this contains the type substitutions used.
-    param_substs: &'tcx Substs<'tcx>,
+    param_substs: SubstsRef<'tcx>,
+
+    /// If this function is a C-variadic function, this contains the `PlaceRef` of the
+    /// "spoofed" `VaList`.
+    va_list_ref: Option<PlaceRef<'tcx, Bx::Value>>,
 }
 
 impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
@@ -246,13 +250,18 @@ pub fn codegen_mir<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
             assert!(!instance.substs.needs_infer());
             instance.substs
         },
+        va_list_ref: None,
     };
 
     let memory_locals = analyze::non_ssa_locals(&fx);
 
     // Allocate variable and temp allocas
     fx.locals = {
-        let args = arg_local_refs(&mut bx, &fx, &fx.scopes, &memory_locals);
+        // FIXME(dlrobertson): This is ugly. Find a better way of getting the `PlaceRef` or
+        // `LocalRef` from `arg_local_refs`
+        let mut va_list_ref = None;
+        let args = arg_local_refs(&mut bx, &fx, &fx.scopes, &memory_locals, &mut va_list_ref);
+        fx.va_list_ref = va_list_ref;
 
         let mut allocate_local = |local| {
             let decl = &mir.local_decls[local];
@@ -433,6 +442,7 @@ fn arg_local_refs<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
         debuginfo::MirDebugScope<Bx::DIScope>
     >,
     memory_locals: &BitSet<mir::Local>,
+    va_list_ref: &mut Option<PlaceRef<'tcx, Bx::Value>>,
 ) -> Vec<LocalRef<'tcx, Bx::Value>> {
     let mir = fx.mir;
     let tcx = fx.cx.tcx();
@@ -447,6 +457,15 @@ fn arg_local_refs<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
         None
     };
 
+    // Store the index of the last argument. This is used to
+    // call va_start on the va_list instead of attempting
+    // to store_fn_arg.
+    let last_arg_idx = if fx.fn_ty.args.is_empty() {
+        None
+    } else {
+        Some(fx.fn_ty.args.len() - 1)
+    };
+
     mir.args_iter().enumerate().map(|(arg_index, local)| {
         let arg_decl = &mir.local_decls[local];
 
@@ -510,9 +529,16 @@ fn arg_local_refs<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
             // of putting everything in allocas just so we can use llvm.dbg.declare.
             let local = |op| LocalRef::Operand(Some(op));
             match arg.mode {
-                PassMode::Ignore => {
+                PassMode::Ignore(IgnoreMode::Zst) => {
                     return local(OperandRef::new_zst(bx.cx(), arg.layout));
                 }
+                PassMode::Ignore(IgnoreMode::CVarArgs) => {
+                    let backend_type = bx.cx().immediate_backend_type(arg.layout);
+                    return local(OperandRef {
+                        val: OperandValue::Immediate(bx.cx().const_undef(backend_type)),
+                        layout: arg.layout,
+                    });
+                }
                 PassMode::Direct(_) => {
                     let llarg = bx.get_param(bx.llfn(), llarg_idx as c_uint);
                     bx.set_value_name(llarg, &name);
@@ -559,9 +585,35 @@ fn arg_local_refs<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>>(
             indirect_operand.store(bx, tmp);
             tmp
         } else {
-            let tmp = PlaceRef::alloca(bx, arg.layout, &name);
-            bx.store_fn_arg(arg, &mut llarg_idx, tmp);
-            tmp
+            if fx.fn_ty.c_variadic && last_arg_idx.map(|idx| arg_index == idx).unwrap_or(false) {
+                let va_list_impl = match arg_decl.ty.ty_adt_def() {
+                    Some(adt) => adt.non_enum_variant(),
+                    None => bug!("`va_list` language item improperly constructed")
+                };
+                match tcx.type_of(va_list_impl.fields[0].did).sty {
+                    ty::Ref(_, ty, _) => {
+                        // If the underlying structure the `VaList` contains is a structure,
+                        // we need to allocate it (e.g., X86_64 on Linux).
+                        let tmp = PlaceRef::alloca(bx, arg.layout, &name);
+                        if let ty::Adt(..) = ty.sty {
+                            let layout = bx.layout_of(ty);
+                            // Create an unnamed allocation for the backing structure
+                            // and store it in the the spoofed `VaList`.
+                            let backing = PlaceRef::alloca(bx, layout, "");
+                            bx.store(backing.llval, tmp.llval, layout.align.abi);
+                        }
+                        // Call `va_start` on the spoofed `VaList`.
+                        bx.va_start(tmp.llval);
+                        *va_list_ref = Some(tmp);
+                        tmp
+                    }
+                    _ => bug!("improperly constructed `va_list` lang item"),
+                }
+            } else {
+                let tmp = PlaceRef::alloca(bx, arg.layout, &name);
+                bx.store_fn_arg(arg, &mut llarg_idx, tmp);
+                tmp
+            }
         };
         arg_scope.map(|scope| {
             // Is this a regular argument?
index 0e8cdc83b486e24aed97a27d18e12f73bc6d30b0..0a6549851f4462a03f92173cbd0d157f6d84a065 100644 (file)
@@ -378,7 +378,7 @@ fn maybe_codegen_consume_direct(
 
         // watch out for locals that do not have an
         // alloca; they are handled somewhat differently
-        if let mir::Place::Local(index) = *place {
+        if let mir::Place::Base(mir::PlaceBase::Local(index)) = *place {
             match self.locals[index] {
                 LocalRef::Operand(Some(o)) => {
                     return Some(o);
index 1edcbfead2c94424ca509af15fb458825214bd5d..0408ccf039f340093dde20b6a4979e4cdebde86d 100644 (file)
@@ -392,7 +392,7 @@ pub fn codegen_place(
         let cx = self.cx;
         let tcx = self.cx.tcx();
 
-        if let mir::Place::Local(index) = *place {
+        if let mir::Place::Base(mir::PlaceBase::Local(index)) = *place {
             match self.locals[index] {
                 LocalRef::Place(place) => {
                     return place;
@@ -407,8 +407,8 @@ pub fn codegen_place(
         }
 
         let result = match *place {
-            mir::Place::Local(_) => bug!(), // handled above
-            mir::Place::Promoted(box (index, ty)) => {
+            mir::Place::Base(mir::PlaceBase::Local(_)) => bug!(), // handled above
+            mir::Place::Base(mir::PlaceBase::Promoted(box (index, ty))) => {
                 let param_env = ty::ParamEnv::reveal_all();
                 let cid = mir::interpret::GlobalId {
                     instance: self.instance,
@@ -435,7 +435,7 @@ pub fn codegen_place(
                     }
                 }
             }
-            mir::Place::Static(box mir::Static { def_id, ty }) => {
+            mir::Place::Base(mir::PlaceBase::Static(box mir::Static { def_id, ty })) => {
                 // NB: The layout of a static may be unsized as is the case when working
                 // with a static that is an extern_type.
                 let layout = cx.layout_of(self.monomorphize(&ty));
@@ -457,7 +457,9 @@ pub fn codegen_place(
                         cg_base.project_field(bx, field.index())
                     }
                     mir::ProjectionElem::Index(index) => {
-                        let index = &mir::Operand::Copy(mir::Place::Local(index));
+                        let index = &mir::Operand::Copy(
+                            mir::Place::Base(mir::PlaceBase::Local(index))
+                        );
                         let index = self.codegen_operand(bx, index);
                         let llindex = index.immediate();
                         cg_base.project_index(bx, llindex)
index 25a7754d118d739c3f2a4427d1950bbd7111491e..b0c667a965daa3c79e071a107dac6c532daf5bad 100644 (file)
@@ -534,7 +534,7 @@ fn evaluate_array_len(
     ) -> Bx::Value {
         // ZST are passed as operands and require special handling
         // because codegen_place() panics if Local is operand.
-        if let mir::Place::Local(index) = *place {
+        if let mir::Place::Base(mir::PlaceBase::Local(index)) = *place {
             if let LocalRef::Operand(Some(op)) = self.locals[index] {
                 if let ty::Array(_, n) = op.layout.ty.sty {
                     let n = n.unwrap_usize(bx.cx().tcx());
index a1bd919c433541b89a472542100bc605a77fb06e..97729e8aeb35fce44b4e627120dcdcc16be7a1e5 100644 (file)
@@ -17,7 +17,7 @@ pub fn codegen_statement(
         self.set_debug_loc(&mut bx, statement.source_info);
         match statement.kind {
             mir::StatementKind::Assign(ref place, ref rvalue) => {
-                if let mir::Place::Local(index) = *place {
+                if let mir::Place::Base(mir::PlaceBase::Local(index)) = *place {
                     match self.locals[index] {
                         LocalRef::Place(cg_dest) => {
                             self.codegen_rvalue(bx, cg_dest, rvalue)
index 3cd0c39d4139a9c823375307c6f32c1f5c64a0d0..cd5278989778ffac031c05d1b92e47883a5a808f 100644 (file)
@@ -20,4 +20,10 @@ fn codegen_intrinsic_call(
     fn abort(&mut self);
     fn assume(&mut self, val: Self::Value);
     fn expect(&mut self, cond: Self::Value, expected: bool) -> Self::Value;
+    /// Trait method used to inject `va_start` on the "spoofed" `VaList` in
+    /// Rust defined C-variadic functions.
+    fn va_start(&mut self, val: Self::Value) -> Self::Value;
+    /// Trait method used to inject `va_end` on the "spoofed" `VaList` before
+    /// Rust defined C-variadic functions return.
+    fn va_end(&mut self, val: Self::Value) -> Self::Value;
 }
index 8d105853d92f11e12f39da4273894d8738a9fb0c..f529cf30a62ea604ada3e4d05ef21304a820f28f 100644 (file)
@@ -94,7 +94,7 @@
 use rustc::ich::NodeIdHashingMode;
 use rustc::ty::item_path::{self, ItemPathBuffer, RootMode};
 use rustc::ty::query::Providers;
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::SubstsRef;
 use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
 use rustc::util::common::record_time;
 use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
@@ -134,7 +134,7 @@ fn get_symbol_hash<'a, 'tcx>(
 
     // values for generic type parameters,
     // if any.
-    substs: &'tcx Substs<'tcx>,
+    substs: SubstsRef<'tcx>,
 ) -> u64 {
     debug!(
         "get_symbol_hash(def_id={:?}, parameters={:?})",
index a11eb4da66ade917855ae9c69f368677a557455a..c495268154664ee7a4987030b5c5b87cc6f856aa 100644 (file)
@@ -6,7 +6,6 @@
 
 use rustc::hir;
 use rustc::ty::TyCtxt;
-use syntax::ast;
 
 use rustc_mir::monomorphize::Instance;
 
@@ -33,9 +32,9 @@ struct SymbolNamesTest<'a, 'tcx:'a> {
 
 impl<'a, 'tcx> SymbolNamesTest<'a, 'tcx> {
     fn process_attrs(&mut self,
-                     node_id: ast::NodeId) {
+                     hir_id: hir::HirId) {
         let tcx = self.tcx;
-        let def_id = tcx.hir().local_def_id(node_id);
+        let def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
         for attr in tcx.get_attrs(def_id).iter() {
             if attr.check_name(SYMBOL_NAME) {
                 // for now, can only use on monomorphic names
@@ -56,14 +55,14 @@ fn process_attrs(&mut self,
 
 impl<'a, 'tcx> hir::itemlikevisit::ItemLikeVisitor<'tcx> for SymbolNamesTest<'a, 'tcx> {
     fn visit_item(&mut self, item: &'tcx hir::Item) {
-        self.process_attrs(item.id);
+        self.process_attrs(item.hir_id);
     }
 
     fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
-        self.process_attrs(trait_item.id);
+        self.process_attrs(trait_item.hir_id);
     }
 
     fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
-        self.process_attrs(impl_item.id);
+        self.process_attrs(impl_item.hir_id);
     }
 }
index 6aa262715ecf4f9321db656e5a17969ac891ee34..6002bf69b7069871ee9d75e4ab57c0d7edd81b83 100644 (file)
@@ -12,13 +12,15 @@ crate-type = ["dylib"]
 [dependencies]
 ena = "0.11"
 log = "0.4"
+jobserver_crate = { version = "0.1", package = "jobserver" }
+lazy_static = "1"
 rustc_cratesio_shim = { path = "../librustc_cratesio_shim" }
 serialize = { path = "../libserialize" }
 graphviz = { path = "../libgraphviz" }
 cfg-if = "0.1.2"
 stable_deref_trait = "1.0.0"
-rayon = { version = "0.1.1", package = "rustc-rayon" }
-rayon-core = { version = "0.1.1", package = "rustc-rayon-core" }
+rayon = { version = "0.1.2", package = "rustc-rayon" }
+rayon-core = { version = "0.1.2", package = "rustc-rayon-core" }
 rustc-hash = "1.0.1"
 smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
 
diff --git a/src/librustc_data_structures/jobserver.rs b/src/librustc_data_structures/jobserver.rs
new file mode 100644 (file)
index 0000000..48ac812
--- /dev/null
@@ -0,0 +1,156 @@
+use jobserver_crate::{Client, HelperThread, Acquired};
+use lazy_static::lazy_static;
+use std::sync::{Condvar, Arc, Mutex};
+use std::mem;
+
+#[derive(Default)]
+struct LockedProxyData {
+    /// The number of free thread tokens, this may include the implicit token given to the process
+    free: usize,
+
+    /// The number of threads waiting for a token
+    waiters: usize,
+
+    /// The number of tokens we requested from the server
+    requested: usize,
+
+    /// Stored tokens which will be dropped when we no longer need them
+    tokens: Vec<Acquired>,
+}
+
+impl LockedProxyData {
+    fn request_token(&mut self, thread: &Mutex<HelperThread>) {
+        self.requested += 1;
+        thread.lock().unwrap().request_token();
+    }
+
+    fn release_token(&mut self, cond_var: &Condvar) {
+        if self.waiters > 0 {
+            self.free += 1;
+            cond_var.notify_one();
+        } else {
+            if self.tokens.is_empty() {
+                // We are returning the implicit token
+                self.free += 1;
+            } else {
+                // Return a real token to the server
+                self.tokens.pop().unwrap();
+            }
+        }
+    }
+
+    fn take_token(&mut self, thread: &Mutex<HelperThread>) -> bool {
+        if self.free > 0 {
+            self.free -= 1;
+            self.waiters -= 1;
+
+            // We stole some token reqested by someone else
+            // Request another one
+            if self.requested + self.free < self.waiters {
+                self.request_token(thread);
+            }
+
+            true
+        } else {
+            false
+        }
+    }
+
+    fn new_requested_token(&mut self, token: Acquired, cond_var: &Condvar) {
+        self.requested -= 1;
+
+        // Does anything need this token?
+        if self.waiters > 0 {
+            self.free += 1;
+            self.tokens.push(token);
+            cond_var.notify_one();
+        } else {
+            // Otherwise we'll just drop it
+            mem::drop(token);
+        }
+    }
+}
+
+#[derive(Default)]
+struct ProxyData {
+    lock: Mutex<LockedProxyData>,
+    cond_var: Condvar,
+}
+
+/// A helper type which makes managing jobserver tokens easier.
+/// It also allows you to treat the implicit token given to the process
+/// in the same manner as requested tokens.
+struct Proxy {
+    thread: Mutex<HelperThread>,
+    data: Arc<ProxyData>,
+}
+
+lazy_static! {
+    // We can only call `from_env` once per process
+
+    // Note that this is unsafe because it may misinterpret file descriptors
+    // on Unix as jobserver file descriptors. We hopefully execute this near
+    // the beginning of the process though to ensure we don't get false
+    // positives, or in other words we try to execute this before we open
+    // any file descriptors ourselves.
+    //
+    // Pick a "reasonable maximum" if we don't otherwise have
+    // a jobserver in our environment, capping out at 32 so we
+    // don't take everything down by hogging the process run queue.
+    // The fixed number is used to have deterministic compilation
+    // across machines.
+    //
+    // Also note that we stick this in a global because there could be
+    // multiple rustc instances in this process, and the jobserver is
+    // per-process.
+    static ref GLOBAL_CLIENT: Client = unsafe {
+        Client::from_env().unwrap_or_else(|| {
+            Client::new(32).expect("failed to create jobserver")
+        })
+    };
+
+    static ref GLOBAL_PROXY: Proxy = {
+        let data = Arc::new(ProxyData::default());
+
+        Proxy {
+            data: data.clone(),
+            thread: Mutex::new(client().into_helper_thread(move |token| {
+                data.lock.lock().unwrap().new_requested_token(token.unwrap(), &data.cond_var);
+            }).unwrap()),
+        }
+    };
+}
+
+pub fn client() -> Client {
+    GLOBAL_CLIENT.clone()
+}
+
+pub fn acquire_thread() {
+    GLOBAL_PROXY.acquire_token();
+}
+
+pub fn release_thread() {
+    GLOBAL_PROXY.release_token();
+}
+
+impl Proxy {
+    fn release_token(&self) {
+        self.data.lock.lock().unwrap().release_token(&self.data.cond_var);
+    }
+
+    fn acquire_token(&self) {
+        let mut data = self.data.lock.lock().unwrap();
+        data.waiters += 1;
+        if data.take_token(&self.thread) {
+            return;
+        }
+        // Request a token for us
+        data.request_token(&self.thread);
+        loop {
+            data = self.data.cond_var.wait(data).unwrap();
+            if data.take_token(&self.thread) {
+                return;
+            }
+        }
+    }
+}
index 2bfb1b24a81b9629c4a7dbb524f6ae4344ede066..09482340b1a1d725a2a8f3b4068ca8ffd0ad73c8 100644 (file)
@@ -77,6 +77,7 @@ macro_rules! unlikely {
 pub mod graph;
 pub mod indexed_vec;
 pub mod interner;
+pub mod jobserver;
 pub mod obligation_forest;
 pub mod owning_ref;
 pub mod ptr_key;
index 8bcda409e6663f8aa8c6969aaf67d3120a74c84c..a77e497af7b8720f1bcee109eaa9b24cacdfe28f 100644 (file)
@@ -13,8 +13,8 @@ arena = { path = "../libarena" }
 graphviz = { path = "../libgraphviz" }
 log = "0.4"
 env_logger = { version = "0.5", default-features = false }
-rustc-rayon = "0.1.1"
-scoped-tls = { version = "0.1.1", features = ["nightly"] }
+rustc-rayon = "0.1.2"
+scoped-tls = "1.0"
 rustc = { path = "../librustc" }
 rustc_allocator = { path = "../librustc_allocator" }
 rustc_target = { path = "../librustc_target" }
@@ -33,6 +33,7 @@ rustc_save_analysis = { path = "../librustc_save_analysis" }
 rustc_traits = { path = "../librustc_traits" }
 rustc_codegen_utils = { path = "../librustc_codegen_utils" }
 rustc_typeck = { path = "../librustc_typeck" }
+rustc_interface = { path = "../librustc_interface" }
 serialize = { path = "../libserialize" }
 syntax = { path = "../libsyntax" }
 smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
index b998b77a76b9c4c3ba7fdfd744becfa4be588ae6..858a5602e7b7f0abfdd7839bbbc565010265abbc 100644 (file)
@@ -2,42 +2,41 @@
 use rustc::hir;
 use rustc::hir::lowering::lower_crate;
 use rustc::hir::map as hir_map;
+use rustc::hir::def_id::LOCAL_CRATE;
 use rustc::lint;
 use rustc::middle::{self, reachable, resolve_lifetime, stability};
 use rustc::ty::{self, AllArenas, Resolutions, TyCtxt};
 use rustc::traits;
 use rustc::util::common::{install_panic_hook, time, ErrorReported};
 use rustc::util::profiling::ProfileCategory;
-use rustc::session::{CompileResult, CrateDisambiguator, Session};
+use rustc::session::{CompileResult, Session};
 use rustc::session::CompileIncomplete;
 use rustc::session::config::{self, Input, OutputFilenames, OutputType};
 use rustc::session::search_paths::PathKind;
 use rustc_allocator as allocator;
 use rustc_borrowck as borrowck;
 use rustc_codegen_utils::codegen_backend::CodegenBackend;
-use rustc_data_structures::fingerprint::Fingerprint;
-use rustc_data_structures::stable_hasher::StableHasher;
 use rustc_data_structures::sync::{self, Lock};
+#[cfg(parallel_compiler)]
+use rustc_data_structures::jobserver;
 use rustc_incremental;
 use rustc_metadata::creader::CrateLoader;
 use rustc_metadata::cstore::{self, CStore};
 use rustc_mir as mir;
-use rustc_passes::{self, ast_validation, hir_stats, loops, rvalue_promotion, layout_test};
+use rustc_passes::{self, ast_validation, hir_stats};
 use rustc_plugin as plugin;
 use rustc_plugin::registry::Registry;
 use rustc_privacy;
 use rustc_resolve::{Resolver, ResolverArenas};
 use rustc_traits;
 use rustc_typeck as typeck;
-use syntax::{self, ast, attr, diagnostics, visit};
+use syntax::{self, ast, diagnostics, visit};
 use syntax::early_buffered_lints::BufferedEarlyLint;
 use syntax::ext::base::ExtCtxt;
 use syntax::mut_visit::MutVisitor;
 use syntax::parse::{self, PResult};
 use syntax::util::node_count::NodeCounter;
-use syntax::util::lev_distance::find_best_match_for_name;
-use syntax::symbol::Symbol;
-use syntax_pos::{FileName, hygiene};
+use syntax_pos::hygiene;
 use syntax_ext;
 
 use serialize::json;
 use std::env;
 use std::ffi::OsString;
 use std::fs;
-use std::io::{self, Write};
 use std::iter;
 use std::path::{Path, PathBuf};
 use std::sync::mpsc;
 
-use pretty::ReplaceBodyWithLoop;
-use proc_macro_decls;
-use profile;
+use rustc_interface::{util, profile, passes};
 use super::Compilation;
 
 #[cfg(not(parallel_compiler))]
@@ -78,7 +74,9 @@ pub fn spawn_thread_pool<F: FnOnce(config::Options) -> R + sync::Send, R: sync::
     let gcx_ptr = &Lock::new(0);
 
     let config = ThreadPoolBuilder::new()
-        .num_threads(Session::threads_from_opts(&opts))
+        .acquire_thread_handler(jobserver::acquire_thread)
+        .release_thread_handler(jobserver::release_thread)
+        .num_threads(Session::threads_from_count(opts.debugging_opts.threads))
         .deadlock_handler(|| unsafe { ty::query::handle_deadlock() })
         .stack_size(::STACK_SIZE);
 
@@ -160,7 +158,7 @@ macro_rules! controller_entry_point {
             (compile_state.krate.unwrap(), compile_state.registry)
         };
 
-        let outputs = build_output_filenames(input, outdir, output, &krate.attrs, sess);
+        let outputs = util::build_output_filenames(input, outdir, output, &krate.attrs, sess);
         let crate_name =
             ::rustc_codegen_utils::link::find_crate_name(Some(sess), &krate.attrs, input);
         install_panic_hook();
@@ -194,12 +192,17 @@ macro_rules! controller_entry_point {
             )?
         };
 
-        let output_paths = generated_output_paths(sess, &outputs, output.is_some(), &crate_name);
+        let output_paths = passes::generated_output_paths(
+            sess,
+            &outputs,
+            output.is_some(),
+            &crate_name
+        );
 
         // Ensure the source file isn't accidentally overwritten during compilation.
         if let Some(ref input_path) = *input_path {
             if sess.opts.will_create_output_file() {
-                if output_contains_path(&output_paths, input_path) {
+                if passes::output_contains_path(&output_paths, input_path) {
                     sess.err(&format!(
                         "the input file \"{}\" would be overwritten by the generated \
                          executable",
@@ -207,7 +210,7 @@ macro_rules! controller_entry_point {
                     ));
                     return Err(CompileIncomplete::Stopped);
                 }
-                if let Some(dir_path) = output_conflicts_with_dir(&output_paths) {
+                if let Some(dir_path) = passes::output_conflicts_with_dir(&output_paths) {
                     sess.err(&format!(
                         "the generated executable for the input file \"{}\" conflicts with the \
                          existing directory \"{}\"",
@@ -219,7 +222,7 @@ macro_rules! controller_entry_point {
             }
         }
 
-        write_out_deps(sess, &outputs, &output_paths);
+        passes::write_out_deps(sess, &outputs, &output_paths);
         if sess.opts.output_types.contains_key(&OutputType::DepInfo)
             && sess.opts.output_types.len() == 1
         {
@@ -333,7 +336,7 @@ macro_rules! controller_entry_point {
 
                 Ok((outputs.clone(), ongoing_codegen, tcx.dep_graph.clone()))
             },
-        )??
+        )?
     };
 
     if sess.opts.debugging_opts.print_type_sizes {
@@ -364,13 +367,6 @@ macro_rules! controller_entry_point {
     Ok(())
 }
 
-pub fn source_name(input: &Input) -> FileName {
-    match *input {
-        Input::File(ref ifile) => ifile.clone().into(),
-        Input::Str { ref name, .. } => name.clone(),
-    }
-}
-
 /// CompileController is used to customize compilation, it allows compilation to
 /// be stopped and/or to call arbitrary code at various points in compilation.
 /// It also allows for various flags to be set to influence what information gets
@@ -806,10 +802,10 @@ pub fn phase_2_configure_and_expand_inner<'a, F>(
     // these need to be set "early" so that expansion sees `quote` if enabled.
     sess.init_features(features);
 
-    let crate_types = collect_crate_types(sess, &krate.attrs);
+    let crate_types = util::collect_crate_types(sess, &krate.attrs);
     sess.crate_types.set(crate_types);
 
-    let disambiguator = compute_crate_disambiguator(sess);
+    let disambiguator = util::compute_crate_disambiguator(sess);
     sess.crate_disambiguator.set(disambiguator);
     rustc_incremental::prepare_session_directory(sess, &crate_name, disambiguator);
 
@@ -1019,7 +1015,7 @@ pub fn phase_2_configure_and_expand_inner<'a, F>(
     // If we're actually rustdoc then there's no need to actually compile
     // anything, so switch everything to just looping
     if sess.opts.actually_rustdoc {
-        ReplaceBodyWithLoop::new(sess).visit_crate(&mut krate);
+        util::ReplaceBodyWithLoop::new(sess).visit_crate(&mut krate);
     }
 
     let (has_proc_macro_decls, has_global_allocator) = time(sess, "AST validation", || {
@@ -1145,7 +1141,7 @@ pub fn phase_2_configure_and_expand_inner<'a, F>(
 }
 
 pub fn default_provide(providers: &mut ty::query::Providers) {
-    proc_macro_decls::provide(providers);
+    rustc_interface::passes::provide(providers);
     plugin::build::provide(providers);
     hir::provide(providers);
     borrowck::provide(providers);
@@ -1186,7 +1182,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(
     name: &str,
     output_filenames: &OutputFilenames,
     f: F,
-) -> Result<R, CompileIncomplete>
+) -> R
 where
     F: for<'a> FnOnce(
         TyCtxt<'a, 'tcx, 'tcx>,
@@ -1227,114 +1223,9 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(
             // tcx available.
             time(sess, "dep graph tcx init", || rustc_incremental::dep_graph_tcx_init(tcx));
 
-            parallel!({
-                time(sess, "looking for entry point", || {
-                    middle::entry::find_entry_point(tcx)
-                });
-
-                time(sess, "looking for plugin registrar", || {
-                    plugin::build::find_plugin_registrar(tcx)
-                });
-
-                time(sess, "looking for derive registrar", || {
-                    proc_macro_decls::find(tcx)
-                });
-            }, {
-                time(sess, "loop checking", || loops::check_crate(tcx));
-            }, {
-                time(sess, "attribute checking", || {
-                    hir::check_attr::check_crate(tcx)
-                });
-            }, {
-                time(sess, "stability checking", || {
-                    stability::check_unstable_api_usage(tcx)
-                });
-            });
-
-            // passes are timed inside typeck
-            match typeck::check_crate(tcx) {
-                Ok(x) => x,
-                Err(x) => {
-                    f(tcx, rx, Err(x));
-                    return Err(x);
-                }
-            }
-
-            time(sess, "misc checking", || {
-                parallel!({
-                    time(sess, "rvalue promotion", || {
-                        rvalue_promotion::check_crate(tcx)
-                    });
-                }, {
-                    time(sess, "intrinsic checking", || {
-                        middle::intrinsicck::check_crate(tcx)
-                    });
-                }, {
-                    time(sess, "match checking", || mir::matchck_crate(tcx));
-                }, {
-                    // this must run before MIR dump, because
-                    // "not all control paths return a value" is reported here.
-                    //
-                    // maybe move the check to a MIR pass?
-                    time(sess, "liveness checking", || {
-                        middle::liveness::check_crate(tcx)
-                    });
-                });
-            });
-
-            // Abort so we don't try to construct MIR with liveness errors.
-            // We also won't want to continue with errors from rvalue promotion
-            tcx.sess.abort_if_errors();
-
-            time(sess, "borrow checking", || {
-                if tcx.use_ast_borrowck() {
-                    borrowck::check_crate(tcx);
-                }
-            });
-
-            time(sess,
-                 "MIR borrow checking",
-                 || tcx.par_body_owners(|def_id| { tcx.ensure().mir_borrowck(def_id); }));
-
-            time(sess, "dumping chalk-like clauses", || {
-                rustc_traits::lowering::dump_program_clauses(tcx);
-            });
-
-            time(sess, "MIR effect checking", || {
-                for def_id in tcx.body_owners() {
-                    mir::transform::check_unsafety::check_unsafety(tcx, def_id)
-                }
-            });
-
-            time(sess, "layout testing", || layout_test::test_layout(tcx));
-
-            // Avoid overwhelming user with errors if borrow checking failed.
-            // I'm not sure how helpful this is, to be honest, but it avoids
-            // a
-            // lot of annoying errors in the compile-fail tests (basically,
-            // lint warnings and so on -- kindck used to do this abort, but
-            // kindck is gone now). -nmatsakis
-            if sess.err_count() > 0 {
-                return Ok(f(tcx, rx, sess.compile_status()));
-            }
+            tcx.analysis(LOCAL_CRATE).ok();
 
-            time(sess, "misc checking", || {
-                parallel!({
-                    time(sess, "privacy checking", || {
-                        rustc_privacy::check_crate(tcx)
-                    });
-                }, {
-                    time(sess, "death checking", || middle::dead::check_crate(tcx));
-                },  {
-                    time(sess, "unused lib feature checking", || {
-                        stability::check_unused_or_stable_features(tcx)
-                    });
-                }, {
-                    time(sess, "lint checking", || lint::check_crate(tcx));
-                });
-            });
-
-            return Ok(f(tcx, rx, tcx.sess.compile_status()));
+            f(tcx, rx, tcx.sess.compile_status())
         },
     )
 }
@@ -1359,328 +1250,3 @@ pub fn phase_4_codegen<'a, 'tcx>(
 
     codegen
 }
-
-fn escape_dep_filename(filename: &FileName) -> String {
-    // Apparently clang and gcc *only* escape spaces:
-    // http://llvm.org/klaus/clang/commit/9d50634cfc268ecc9a7250226dd5ca0e945240d4
-    filename.to_string().replace(" ", "\\ ")
-}
-
-// Returns all the paths that correspond to generated files.
-fn generated_output_paths(
-    sess: &Session,
-    outputs: &OutputFilenames,
-    exact_name: bool,
-    crate_name: &str,
-) -> Vec<PathBuf> {
-    let mut out_filenames = Vec::new();
-    for output_type in sess.opts.output_types.keys() {
-        let file = outputs.path(*output_type);
-        match *output_type {
-            // If the filename has been overridden using `-o`, it will not be modified
-            // by appending `.rlib`, `.exe`, etc., so we can skip this transformation.
-            OutputType::Exe if !exact_name => for crate_type in sess.crate_types.borrow().iter() {
-                let p = ::rustc_codegen_utils::link::filename_for_input(
-                    sess,
-                    *crate_type,
-                    crate_name,
-                    outputs,
-                );
-                out_filenames.push(p);
-            },
-            OutputType::DepInfo if sess.opts.debugging_opts.dep_info_omit_d_target => {
-                // Don't add the dep-info output when omitting it from dep-info targets
-            }
-            _ => {
-                out_filenames.push(file);
-            }
-        }
-    }
-    out_filenames
-}
-
-// Runs `f` on every output file path and returns the first non-None result, or None if `f`
-// returns None for every file path.
-fn check_output<F, T>(output_paths: &[PathBuf], f: F) -> Option<T>
-where
-    F: Fn(&PathBuf) -> Option<T>,
-{
-    for output_path in output_paths {
-        if let Some(result) = f(output_path) {
-            return Some(result);
-        }
-    }
-    None
-}
-
-pub fn output_contains_path(output_paths: &[PathBuf], input_path: &PathBuf) -> bool {
-    let input_path = input_path.canonicalize().ok();
-    if input_path.is_none() {
-        return false;
-    }
-    let check = |output_path: &PathBuf| {
-        if output_path.canonicalize().ok() == input_path {
-            Some(())
-        } else {
-            None
-        }
-    };
-    check_output(output_paths, check).is_some()
-}
-
-pub fn output_conflicts_with_dir(output_paths: &[PathBuf]) -> Option<PathBuf> {
-    let check = |output_path: &PathBuf| {
-        if output_path.is_dir() {
-            Some(output_path.clone())
-        } else {
-            None
-        }
-    };
-    check_output(output_paths, check)
-}
-
-fn write_out_deps(sess: &Session, outputs: &OutputFilenames, out_filenames: &[PathBuf]) {
-    // Write out dependency rules to the dep-info file if requested
-    if !sess.opts.output_types.contains_key(&OutputType::DepInfo) {
-        return;
-    }
-    let deps_filename = outputs.path(OutputType::DepInfo);
-
-    let result = (|| -> io::Result<()> {
-        // Build a list of files used to compile the output and
-        // write Makefile-compatible dependency rules
-        let files: Vec<String> = sess.source_map()
-            .files()
-            .iter()
-            .filter(|fmap| fmap.is_real_file())
-            .filter(|fmap| !fmap.is_imported())
-            .map(|fmap| escape_dep_filename(&fmap.name))
-            .collect();
-        let mut file = fs::File::create(&deps_filename)?;
-        for path in out_filenames {
-            writeln!(file, "{}: {}\n", path.display(), files.join(" "))?;
-        }
-
-        // Emit a fake target for each input file to the compilation. This
-        // prevents `make` from spitting out an error if a file is later
-        // deleted. For more info see #28735
-        for path in files {
-            writeln!(file, "{}:", path)?;
-        }
-        Ok(())
-    })();
-
-    if let Err(e) = result {
-        sess.fatal(&format!(
-            "error writing dependencies to `{}`: {}",
-            deps_filename.display(),
-            e
-        ));
-    }
-}
-
-pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<config::CrateType> {
-    // Unconditionally collect crate types from attributes to make them used
-    let attr_types: Vec<config::CrateType> = attrs
-        .iter()
-        .filter_map(|a| {
-            if a.check_name("crate_type") {
-                match a.value_str() {
-                    Some(ref n) if *n == "rlib" => Some(config::CrateType::Rlib),
-                    Some(ref n) if *n == "dylib" => Some(config::CrateType::Dylib),
-                    Some(ref n) if *n == "cdylib" => Some(config::CrateType::Cdylib),
-                    Some(ref n) if *n == "lib" => Some(config::default_lib_output()),
-                    Some(ref n) if *n == "staticlib" => Some(config::CrateType::Staticlib),
-                    Some(ref n) if *n == "proc-macro" => Some(config::CrateType::ProcMacro),
-                    Some(ref n) if *n == "bin" => Some(config::CrateType::Executable),
-                    Some(ref n) => {
-                        let crate_types = vec![
-                            Symbol::intern("rlib"),
-                            Symbol::intern("dylib"),
-                            Symbol::intern("cdylib"),
-                            Symbol::intern("lib"),
-                            Symbol::intern("staticlib"),
-                            Symbol::intern("proc-macro"),
-                            Symbol::intern("bin")
-                        ];
-
-                        if let ast::MetaItemKind::NameValue(spanned) = a.meta().unwrap().node {
-                            let span = spanned.span;
-                            let lev_candidate = find_best_match_for_name(
-                                crate_types.iter(),
-                                &n.as_str(),
-                                None
-                            );
-                            if let Some(candidate) = lev_candidate {
-                                session.buffer_lint_with_diagnostic(
-                                    lint::builtin::UNKNOWN_CRATE_TYPES,
-                                    ast::CRATE_NODE_ID,
-                                    span,
-                                    "invalid `crate_type` value",
-                                    lint::builtin::BuiltinLintDiagnostics::
-                                        UnknownCrateTypes(
-                                            span,
-                                            "did you mean".to_string(),
-                                            format!("\"{}\"", candidate)
-                                        )
-                                );
-                            } else {
-                                session.buffer_lint(
-                                    lint::builtin::UNKNOWN_CRATE_TYPES,
-                                    ast::CRATE_NODE_ID,
-                                    span,
-                                    "invalid `crate_type` value"
-                                );
-                            }
-                        }
-                        None
-                    }
-                    None => None
-                }
-            } else {
-                None
-            }
-        })
-        .collect();
-
-    // If we're generating a test executable, then ignore all other output
-    // styles at all other locations
-    if session.opts.test {
-        return vec![config::CrateType::Executable];
-    }
-
-    // Only check command line flags if present. If no types are specified by
-    // command line, then reuse the empty `base` Vec to hold the types that
-    // will be found in crate attributes.
-    let mut base = session.opts.crate_types.clone();
-    if base.is_empty() {
-        base.extend(attr_types);
-        if base.is_empty() {
-            base.push(::rustc_codegen_utils::link::default_output_for_target(
-                session,
-            ));
-        } else {
-            base.sort();
-            base.dedup();
-        }
-    }
-
-    base.retain(|crate_type| {
-        let res = !::rustc_codegen_utils::link::invalid_output_for_target(session, *crate_type);
-
-        if !res {
-            session.warn(&format!(
-                "dropping unsupported crate type `{}` for target `{}`",
-                *crate_type, session.opts.target_triple
-            ));
-        }
-
-        res
-    });
-
-    base
-}
-
-pub fn compute_crate_disambiguator(session: &Session) -> CrateDisambiguator {
-    use std::hash::Hasher;
-
-    // The crate_disambiguator is a 128 bit hash. The disambiguator is fed
-    // into various other hashes quite a bit (symbol hashes, incr. comp. hashes,
-    // debuginfo type IDs, etc), so we don't want it to be too wide. 128 bits
-    // should still be safe enough to avoid collisions in practice.
-    let mut hasher = StableHasher::<Fingerprint>::new();
-
-    let mut metadata = session.opts.cg.metadata.clone();
-    // We don't want the crate_disambiguator to dependent on the order
-    // -C metadata arguments, so sort them:
-    metadata.sort();
-    // Every distinct -C metadata value is only incorporated once:
-    metadata.dedup();
-
-    hasher.write(b"metadata");
-    for s in &metadata {
-        // Also incorporate the length of a metadata string, so that we generate
-        // different values for `-Cmetadata=ab -Cmetadata=c` and
-        // `-Cmetadata=a -Cmetadata=bc`
-        hasher.write_usize(s.len());
-        hasher.write(s.as_bytes());
-    }
-
-    // Also incorporate crate type, so that we don't get symbol conflicts when
-    // linking against a library of the same name, if this is an executable.
-    let is_exe = session
-        .crate_types
-        .borrow()
-        .contains(&config::CrateType::Executable);
-    hasher.write(if is_exe { b"exe" } else { b"lib" });
-
-    CrateDisambiguator::from(hasher.finish())
-}
-
-pub fn build_output_filenames(
-    input: &Input,
-    odir: &Option<PathBuf>,
-    ofile: &Option<PathBuf>,
-    attrs: &[ast::Attribute],
-    sess: &Session,
-) -> OutputFilenames {
-    match *ofile {
-        None => {
-            // "-" as input file will cause the parser to read from stdin so we
-            // have to make up a name
-            // We want to toss everything after the final '.'
-            let dirpath = (*odir).as_ref().cloned().unwrap_or_default();
-
-            // If a crate name is present, we use it as the link name
-            let stem = sess.opts
-                .crate_name
-                .clone()
-                .or_else(|| attr::find_crate_name(attrs).map(|n| n.to_string()))
-                .unwrap_or_else(|| input.filestem().to_owned());
-
-            OutputFilenames {
-                out_directory: dirpath,
-                out_filestem: stem,
-                single_output_file: None,
-                extra: sess.opts.cg.extra_filename.clone(),
-                outputs: sess.opts.output_types.clone(),
-            }
-        }
-
-        Some(ref out_file) => {
-            let unnamed_output_types = sess.opts
-                .output_types
-                .values()
-                .filter(|a| a.is_none())
-                .count();
-            let ofile = if unnamed_output_types > 1 {
-                sess.warn(
-                    "due to multiple output types requested, the explicitly specified \
-                     output file name will be adapted for each output type",
-                );
-                None
-            } else {
-                Some(out_file.clone())
-            };
-            if *odir != None {
-                sess.warn("ignoring --out-dir flag due to -o flag");
-            }
-            if !sess.opts.cg.extra_filename.is_empty() {
-                sess.warn("ignoring -C extra-filename flag due to -o flag");
-            }
-
-            OutputFilenames {
-                out_directory: out_file.parent().unwrap_or_else(|| Path::new("")).to_path_buf(),
-                out_filestem: out_file
-                    .file_stem()
-                    .unwrap_or_default()
-                    .to_str()
-                    .unwrap()
-                    .to_string(),
-                single_output_file: ofile,
-                extra: sess.opts.cg.extra_filename.clone(),
-                outputs: sess.opts.output_types.clone(),
-            }
-        }
-    }
-}
index e022d3a3818a5caae987c3a606bc20c672cfd349..52dbb618d0d11ac5420bafb57e0ca936437869af 100644 (file)
@@ -27,7 +27,6 @@
 extern crate rustc_allocator;
 extern crate rustc_target;
 extern crate rustc_borrowck;
-#[macro_use]
 extern crate rustc_data_structures;
 extern crate rustc_errors as errors;
 extern crate rustc_passes;
@@ -42,6 +41,7 @@
 extern crate rustc_traits;
 extern crate rustc_codegen_utils;
 extern crate rustc_typeck;
+extern crate rustc_interface;
 extern crate scoped_tls;
 extern crate serialize;
 extern crate smallvec;
 use rustc_save_analysis::DumpHandler;
 use rustc_data_structures::sync::{self, Lrc, Ordering::SeqCst};
 use rustc_data_structures::OnDrop;
-use rustc::session::{self, config, Session, build_session, CompileResult};
+use rustc::session::{self, config, Session, build_session, CompileResult, DiagnosticOutput};
 use rustc::session::CompileIncomplete;
 use rustc::session::config::{Input, PrintRequest, ErrorOutputType};
 use rustc::session::config::nightly_options;
-use rustc::session::filesearch;
 use rustc::session::{early_error, early_warn};
 use rustc::lint::Lint;
 use rustc::lint;
 use rustc_metadata::locator;
 use rustc_metadata::cstore::CStore;
-use rustc_metadata::dynamic_lib::DynamicLibrary;
 use rustc::util::common::{time, ErrorReported};
 use rustc_codegen_utils::codegen_backend::CodegenBackend;
+use rustc_interface::util::{self, get_codegen_sysroot};
 
 use serialize::json::ToJson;
 
 use std::borrow::Cow;
 use std::cmp::max;
 use std::default::Default;
-use std::env::consts::{DLL_PREFIX, DLL_SUFFIX};
 use std::env;
 use std::error::Error;
 use std::ffi::OsString;
 use std::fmt::{self, Display};
 use std::io::{self, Read, Write};
-use std::mem;
 use std::panic;
-use std::path::{PathBuf, Path};
+use std::path::PathBuf;
 use std::process::{self, Command, Stdio};
 use std::str;
-use std::sync::atomic::{AtomicBool, Ordering};
-use std::sync::{Once, ONCE_INIT};
 use std::thread;
 
 use syntax::ast;
 #[cfg(test)]
 mod test;
 
-pub mod profile;
 pub mod driver;
 pub mod pretty;
-mod proc_macro_decls;
-
-pub mod target_features {
-    use syntax::ast;
-    use syntax::symbol::Symbol;
-    use rustc::session::Session;
-    use rustc_codegen_utils::codegen_backend::CodegenBackend;
-
-    /// Adds `target_feature = "..."` cfgs for a variety of platform
-    /// specific features (SSE, NEON etc.).
-    ///
-    /// This is performed by checking whether a whitelisted set of
-    /// features is available on the target machine, by querying LLVM.
-    pub fn add_configuration(cfg: &mut ast::CrateConfig,
-                             sess: &Session,
-                             codegen_backend: &dyn CodegenBackend) {
-        let tf = Symbol::intern("target_feature");
-
-        cfg.extend(codegen_backend.target_features(sess).into_iter().map(|feat| (tf, Some(feat))));
-
-        if sess.crt_static_feature() {
-            cfg.insert((tf, Some(Symbol::intern("crt-static"))));
-        }
-    }
-}
 
 /// Exit status code used for successful compilation and help output.
 pub const EXIT_SUCCESS: isize = 0;
@@ -196,235 +165,6 @@ pub fn run<F>(run_compiler: F) -> isize
     }
 }
 
-fn load_backend_from_dylib(path: &Path) -> fn() -> Box<dyn CodegenBackend> {
-    let lib = DynamicLibrary::open(Some(path)).unwrap_or_else(|err| {
-        let err = format!("couldn't load codegen backend {:?}: {:?}", path, err);
-        early_error(ErrorOutputType::default(), &err);
-    });
-    unsafe {
-        match lib.symbol("__rustc_codegen_backend") {
-            Ok(f) => {
-                mem::forget(lib);
-                mem::transmute::<*mut u8, _>(f)
-            }
-            Err(e) => {
-                let err = format!("couldn't load codegen backend as it \
-                                   doesn't export the `__rustc_codegen_backend` \
-                                   symbol: {:?}", e);
-                early_error(ErrorOutputType::default(), &err);
-            }
-        }
-    }
-}
-
-pub fn get_codegen_backend(sess: &Session) -> Box<dyn CodegenBackend> {
-    static INIT: Once = ONCE_INIT;
-
-    #[allow(deprecated)]
-    #[no_debug]
-    static mut LOAD: fn() -> Box<dyn CodegenBackend> = || unreachable!();
-
-    INIT.call_once(|| {
-        let codegen_name = sess.opts.debugging_opts.codegen_backend.as_ref()
-            .unwrap_or(&sess.target.target.options.codegen_backend);
-        let backend = match &codegen_name[..] {
-            "metadata_only" => {
-                rustc_codegen_utils::codegen_backend::MetadataOnlyCodegenBackend::boxed
-            }
-            filename if filename.contains(".") => {
-                load_backend_from_dylib(filename.as_ref())
-            }
-            codegen_name => get_codegen_sysroot(codegen_name),
-        };
-
-        unsafe {
-            LOAD = backend;
-        }
-    });
-    let backend = unsafe { LOAD() };
-    backend.init(sess);
-    backend
-}
-
-fn get_codegen_sysroot(backend_name: &str) -> fn() -> Box<dyn CodegenBackend> {
-    // For now we only allow this function to be called once as it'll dlopen a
-    // few things, which seems to work best if we only do that once. In
-    // general this assertion never trips due to the once guard in `get_codegen_backend`,
-    // but there's a few manual calls to this function in this file we protect
-    // against.
-    static LOADED: AtomicBool = AtomicBool::new(false);
-    assert!(!LOADED.fetch_or(true, Ordering::SeqCst),
-            "cannot load the default codegen backend twice");
-
-    // When we're compiling this library with `--test` it'll run as a binary but
-    // not actually exercise much functionality. As a result most of the logic
-    // here is defunkt (it assumes we're a dynamic library in a sysroot) so
-    // let's just return a dummy creation function which won't be used in
-    // general anyway.
-    if cfg!(test) {
-        return rustc_codegen_utils::codegen_backend::MetadataOnlyCodegenBackend::boxed
-    }
-
-    let target = session::config::host_triple();
-    let mut sysroot_candidates = vec![filesearch::get_or_default_sysroot()];
-    let path = current_dll_path()
-        .and_then(|s| s.canonicalize().ok());
-    if let Some(dll) = path {
-        // use `parent` twice to chop off the file name and then also the
-        // directory containing the dll which should be either `lib` or `bin`.
-        if let Some(path) = dll.parent().and_then(|p| p.parent()) {
-            // The original `path` pointed at the `rustc_driver` crate's dll.
-            // Now that dll should only be in one of two locations. The first is
-            // in the compiler's libdir, for example `$sysroot/lib/*.dll`. The
-            // other is the target's libdir, for example
-            // `$sysroot/lib/rustlib/$target/lib/*.dll`.
-            //
-            // We don't know which, so let's assume that if our `path` above
-            // ends in `$target` we *could* be in the target libdir, and always
-            // assume that we may be in the main libdir.
-            sysroot_candidates.push(path.to_owned());
-
-            if path.ends_with(target) {
-                sysroot_candidates.extend(path.parent() // chop off `$target`
-                    .and_then(|p| p.parent())           // chop off `rustlib`
-                    .and_then(|p| p.parent())           // chop off `lib`
-                    .map(|s| s.to_owned()));
-            }
-        }
-    }
-
-    let sysroot = sysroot_candidates.iter()
-        .map(|sysroot| {
-            let libdir = filesearch::relative_target_lib_path(&sysroot, &target);
-            sysroot.join(libdir).with_file_name(
-                option_env!("CFG_CODEGEN_BACKENDS_DIR").unwrap_or("codegen-backends"))
-        })
-        .filter(|f| {
-            info!("codegen backend candidate: {}", f.display());
-            f.exists()
-        })
-        .next();
-    let sysroot = sysroot.unwrap_or_else(|| {
-        let candidates = sysroot_candidates.iter()
-            .map(|p| p.display().to_string())
-            .collect::<Vec<_>>()
-            .join("\n* ");
-        let err = format!("failed to find a `codegen-backends` folder \
-                           in the sysroot candidates:\n* {}", candidates);
-        early_error(ErrorOutputType::default(), &err);
-    });
-    info!("probing {} for a codegen backend", sysroot.display());
-
-    let d = sysroot.read_dir().unwrap_or_else(|e| {
-        let err = format!("failed to load default codegen backend, couldn't \
-                           read `{}`: {}", sysroot.display(), e);
-        early_error(ErrorOutputType::default(), &err);
-    });
-
-    let mut file: Option<PathBuf> = None;
-
-    let expected_name = format!("rustc_codegen_llvm-{}", backend_name);
-    for entry in d.filter_map(|e| e.ok()) {
-        let path = entry.path();
-        let filename = match path.file_name().and_then(|s| s.to_str()) {
-            Some(s) => s,
-            None => continue,
-        };
-        if !(filename.starts_with(DLL_PREFIX) && filename.ends_with(DLL_SUFFIX)) {
-            continue
-        }
-        let name = &filename[DLL_PREFIX.len() .. filename.len() - DLL_SUFFIX.len()];
-        if name != expected_name {
-            continue
-        }
-        if let Some(ref prev) = file {
-            let err = format!("duplicate codegen backends found\n\
-                               first:  {}\n\
-                               second: {}\n\
-            ", prev.display(), path.display());
-            early_error(ErrorOutputType::default(), &err);
-        }
-        file = Some(path.clone());
-    }
-
-    match file {
-        Some(ref s) => return load_backend_from_dylib(s),
-        None => {
-            let err = format!("failed to load default codegen backend for `{}`, \
-                               no appropriate codegen dylib found in `{}`",
-                              backend_name, sysroot.display());
-            early_error(ErrorOutputType::default(), &err);
-        }
-    }
-
-    #[cfg(unix)]
-    fn current_dll_path() -> Option<PathBuf> {
-        use std::ffi::{OsStr, CStr};
-        use std::os::unix::prelude::*;
-
-        unsafe {
-            let addr = current_dll_path as usize as *mut _;
-            let mut info = mem::zeroed();
-            if libc::dladdr(addr, &mut info) == 0 {
-                info!("dladdr failed");
-                return None
-            }
-            if info.dli_fname.is_null() {
-                info!("dladdr returned null pointer");
-                return None
-            }
-            let bytes = CStr::from_ptr(info.dli_fname).to_bytes();
-            let os = OsStr::from_bytes(bytes);
-            Some(PathBuf::from(os))
-        }
-    }
-
-    #[cfg(windows)]
-    fn current_dll_path() -> Option<PathBuf> {
-        use std::ffi::OsString;
-        use std::os::windows::prelude::*;
-
-        extern "system" {
-            fn GetModuleHandleExW(dwFlags: u32,
-                                  lpModuleName: usize,
-                                  phModule: *mut usize) -> i32;
-            fn GetModuleFileNameW(hModule: usize,
-                                  lpFilename: *mut u16,
-                                  nSize: u32) -> u32;
-        }
-
-        const GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS: u32 = 0x00000004;
-
-        unsafe {
-            let mut module = 0;
-            let r = GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
-                                       current_dll_path as usize,
-                                       &mut module);
-            if r == 0 {
-                info!("GetModuleHandleExW failed: {}", io::Error::last_os_error());
-                return None
-            }
-            let mut space = Vec::with_capacity(1024);
-            let r = GetModuleFileNameW(module,
-                                       space.as_mut_ptr(),
-                                       space.capacity() as u32);
-            if r == 0 {
-                info!("GetModuleFileNameW failed: {}", io::Error::last_os_error());
-                return None
-            }
-            let r = r as usize;
-            if r >= space.capacity() {
-                info!("our buffer was too small? {}",
-                      io::Error::last_os_error());
-                return None
-            }
-            space.set_len(r);
-            let os = OsString::from_wide(&space);
-            Some(PathBuf::from(os))
-        }
-    }
-}
-
 // Parse args and run the compiler. This is the primary entry point for rustc.
 // See comments on CompilerCalls below for details about the callbacks argument.
 // The FileLoader provides a way to load files from sources other than the file system.
@@ -485,7 +225,12 @@ macro_rules! do_or_return {($expr: expr, $sess: expr) => {
     let loader = file_loader.unwrap_or(box RealFileLoader);
     let source_map = Lrc::new(SourceMap::with_file_loader(loader, sopts.file_path_mapping()));
     let mut sess = session::build_session_with_source_map(
-        sopts, input_file_path.clone(), descriptions, source_map, emitter_dest,
+        sopts,
+        input_file_path.clone(),
+        descriptions,
+        source_map,
+        emitter_dest.map(|e| DiagnosticOutput::Raw(e)).unwrap_or(DiagnosticOutput::Default),
+        Default::default(),
     );
 
     if let Some(err) = input_err {
@@ -495,12 +240,12 @@ macro_rules! do_or_return {($expr: expr, $sess: expr) => {
         return (Err(CompileIncomplete::Stopped), Some(sess));
     }
 
-    let codegen_backend = get_codegen_backend(&sess);
+    let codegen_backend = util::get_codegen_backend(&sess);
 
     rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
 
     let mut cfg = config::build_configuration(&sess, cfg);
-    target_features::add_configuration(&mut cfg, &sess, &*codegen_backend);
+    util::add_configuration(&mut cfg, &sess, &*codegen_backend);
     sess.parse_sess.config = cfg;
 
     let result = {
@@ -710,8 +455,8 @@ fn stdout_isatty() -> bool {
 }
 
 fn handle_explain(code: &str,
-                  descriptions: &errors::registry::Registry,
                   output: ErrorOutputType) {
+    let descriptions = rustc_interface::util::diagnostics_registry();
     let normalised = if code.starts_with("E") {
         code.to_string()
     } else {
@@ -788,11 +533,11 @@ fn early_callback(&mut self,
                       matches: &getopts::Matches,
                       _: &config::Options,
                       _: &ast::CrateConfig,
-                      descriptions: &errors::registry::Registry,
+                      _: &errors::registry::Registry,
                       output: ErrorOutputType)
                       -> Compilation {
         if let Some(ref code) = matches.opt_str("explain") {
-            handle_explain(code, descriptions, output);
+            handle_explain(code, output);
             return Compilation::Stop;
         }
 
@@ -820,8 +565,8 @@ fn no_input(&mut self,
                 }
                 rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
                 let mut cfg = config::build_configuration(&sess, cfg.clone());
-                let codegen_backend = get_codegen_backend(&sess);
-                target_features::add_configuration(&mut cfg, &sess, &*codegen_backend);
+                let codegen_backend = util::get_codegen_backend(&sess);
+                util::add_configuration(&mut cfg, &sess, &*codegen_backend);
                 sess.parse_sess.config = cfg;
                 let should_stop = RustcDefaultCalls::print_crate_info(
                     &*codegen_backend,
@@ -1024,13 +769,19 @@ fn print_crate_info(codegen_backend: &dyn CodegenBackend,
                     let input = input.unwrap_or_else(||
                         early_error(ErrorOutputType::default(), "no input file provided"));
                     let attrs = attrs.as_ref().unwrap();
-                    let t_outputs = driver::build_output_filenames(input, odir, ofile, attrs, sess);
+                    let t_outputs = rustc_interface::util::build_output_filenames(
+                        input,
+                        odir,
+                        ofile,
+                        attrs,
+                        sess
+                    );
                     let id = rustc_codegen_utils::link::find_crate_name(Some(sess), attrs, input);
                     if *req == PrintRequest::CrateName {
                         println!("{}", id);
                         continue;
                     }
-                    let crate_types = driver::collect_crate_types(sess, attrs);
+                    let crate_types = rustc_interface::util::collect_crate_types(sess, attrs);
                     for &style in &crate_types {
                         let fname = rustc_codegen_utils::link::filename_for_input(
                             sess,
index 0698c15346ebc4e9792cacf3270a3e048c9e3c19..ac2f6da0c608472f609485473f3817afbc14f21d 100644 (file)
@@ -9,36 +9,33 @@
 use rustc::session::Session;
 use rustc::session::config::{Input, OutputFilenames};
 use rustc::ty::{self, TyCtxt, Resolutions, AllArenas};
+use rustc_interface::util;
 use rustc_borrowck as borrowck;
 use rustc_borrowck::graphviz as borrowck_dot;
-use rustc_data_structures::thin_vec::ThinVec;
 use rustc_metadata::cstore::CStore;
 use rustc_mir::util::{write_mir_pretty, write_mir_graphviz};
 
-use syntax::ast::{self, BlockCheckMode};
-use syntax::mut_visit::{*, MutVisitor, visit_clobber};
+use syntax::ast;
+use syntax::mut_visit::MutVisitor;
 use syntax::print::{pprust};
 use syntax::print::pprust::PrintState;
-use syntax::ptr::P;
-use syntax_pos::{self, FileName};
+use syntax_pos::FileName;
 
 use graphviz as dot;
-use smallvec::SmallVec;
 
 use std::cell::Cell;
 use std::fs::File;
 use std::io::{self, Write};
-use std::ops::DerefMut;
 use std::option;
 use std::path::Path;
 use std::str::FromStr;
-use std::mem;
 
 pub use self::UserIdentifiedItem::*;
 pub use self::PpSourceMode::*;
 pub use self::PpMode::*;
 use self::NodesMatchingUII::*;
-use {abort_on_err, driver};
+use abort_on_err;
+use driver;
 
 #[derive(Copy, Clone, PartialEq, Debug)]
 pub enum PpSourceMode {
@@ -217,18 +214,19 @@ fn call_with_pp_support_hir<'tcx, A, F>(
             }
             PpmTyped => {
                 let control = &driver::CompileController::basic();
-                let codegen_backend = ::get_codegen_backend(sess);
+                let codegen_backend = util::get_codegen_backend(sess);
                 let mut arenas = AllArenas::new();
-                abort_on_err(driver::phase_3_run_analysis_passes(&*codegen_backend,
-                                                                 control,
-                                                                 sess,
-                                                                 cstore,
-                                                                 hir_map.clone(),
-                                                                 resolutions.clone(),
-                                                                 &mut arenas,
-                                                                 id,
-                                                                 output_filenames,
-                                                                 |tcx, _, _| {
+                driver::phase_3_run_analysis_passes(&*codegen_backend,
+                                                    control,
+                                                    sess,
+                                                    cstore,
+                                                    hir_map.clone(),
+                                                    resolutions.clone(),
+                                                    &mut arenas,
+                                                    id,
+                                                    output_filenames,
+                                                    |tcx, _, result| {
+                    abort_on_err(result, tcx.sess);
                     let empty_tables = ty::TypeckTables::empty(None);
                     let annotation = TypedAnnotation {
                         tcx,
@@ -237,8 +235,7 @@ fn call_with_pp_support_hir<'tcx, A, F>(
                     tcx.dep_graph.with_ignore(|| {
                         f(&annotation, hir_map.forest.krate())
                     })
-                }),
-                             sess)
+                })
             }
             _ => panic!("Should use call_with_pp_support"),
         }
@@ -627,204 +624,6 @@ fn to_one_node_id(self, user_option: &str, sess: &Session, map: &hir_map::Map) -
     }
 }
 
-// Note: Also used by librustdoc, see PR #43348. Consider moving this struct elsewhere.
-//
-// FIXME: Currently the `everybody_loops` transformation is not applied to:
-//  * `const fn`, due to issue #43636 that `loop` is not supported for const evaluation. We are
-//    waiting for miri to fix that.
-//  * `impl Trait`, due to issue #43869 that functions returning impl Trait cannot be diverging.
-//    Solving this may require `!` to implement every trait, which relies on the an even more
-//    ambitious form of the closed RFC #1637. See also [#34511].
-//
-// [#34511]: https://github.com/rust-lang/rust/issues/34511#issuecomment-322340401
-pub struct ReplaceBodyWithLoop<'a> {
-    within_static_or_const: bool,
-    nested_blocks: Option<Vec<ast::Block>>,
-    sess: &'a Session,
-}
-
-impl<'a> ReplaceBodyWithLoop<'a> {
-    pub fn new(sess: &'a Session) -> ReplaceBodyWithLoop<'a> {
-        ReplaceBodyWithLoop {
-            within_static_or_const: false,
-            nested_blocks: None,
-            sess
-        }
-    }
-
-    fn run<R, F: FnOnce(&mut Self) -> R>(&mut self, is_const: bool, action: F) -> R {
-        let old_const = mem::replace(&mut self.within_static_or_const, is_const);
-        let old_blocks = self.nested_blocks.take();
-        let ret = action(self);
-        self.within_static_or_const = old_const;
-        self.nested_blocks = old_blocks;
-        ret
-    }
-
-    fn should_ignore_fn(ret_ty: &ast::FnDecl) -> bool {
-        if let ast::FunctionRetTy::Ty(ref ty) = ret_ty.output {
-            fn involves_impl_trait(ty: &ast::Ty) -> bool {
-                match ty.node {
-                    ast::TyKind::ImplTrait(..) => true,
-                    ast::TyKind::Slice(ref subty) |
-                    ast::TyKind::Array(ref subty, _) |
-                    ast::TyKind::Ptr(ast::MutTy { ty: ref subty, .. }) |
-                    ast::TyKind::Rptr(_, ast::MutTy { ty: ref subty, .. }) |
-                    ast::TyKind::Paren(ref subty) => involves_impl_trait(subty),
-                    ast::TyKind::Tup(ref tys) => any_involves_impl_trait(tys.iter()),
-                    ast::TyKind::Path(_, ref path) => path.segments.iter().any(|seg| {
-                        match seg.args.as_ref().map(|generic_arg| &**generic_arg) {
-                            None => false,
-                            Some(&ast::GenericArgs::AngleBracketed(ref data)) => {
-                                let types = data.args.iter().filter_map(|arg| match arg {
-                                    ast::GenericArg::Type(ty) => Some(ty),
-                                    _ => None,
-                                });
-                                any_involves_impl_trait(types.into_iter()) ||
-                                any_involves_impl_trait(data.bindings.iter().map(|b| &b.ty))
-                            },
-                            Some(&ast::GenericArgs::Parenthesized(ref data)) => {
-                                any_involves_impl_trait(data.inputs.iter()) ||
-                                any_involves_impl_trait(data.output.iter())
-                            }
-                        }
-                    }),
-                    _ => false,
-                }
-            }
-
-            fn any_involves_impl_trait<'a, I: Iterator<Item = &'a P<ast::Ty>>>(mut it: I) -> bool {
-                it.any(|subty| involves_impl_trait(subty))
-            }
-
-            involves_impl_trait(ty)
-        } else {
-            false
-        }
-    }
-}
-
-impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> {
-    fn visit_item_kind(&mut self, i: &mut ast::ItemKind) {
-        let is_const = match i {
-            ast::ItemKind::Static(..) | ast::ItemKind::Const(..) => true,
-            ast::ItemKind::Fn(ref decl, ref header, _, _) =>
-                header.constness.node == ast::Constness::Const || Self::should_ignore_fn(decl),
-            _ => false,
-        };
-        self.run(is_const, |s| noop_visit_item_kind(i, s))
-    }
-
-    fn flat_map_trait_item(&mut self, i: ast::TraitItem) -> SmallVec<[ast::TraitItem; 1]> {
-        let is_const = match i.node {
-            ast::TraitItemKind::Const(..) => true,
-            ast::TraitItemKind::Method(ast::MethodSig { ref decl, ref header, .. }, _) =>
-                header.constness.node == ast::Constness::Const || Self::should_ignore_fn(decl),
-            _ => false,
-        };
-        self.run(is_const, |s| noop_flat_map_trait_item(i, s))
-    }
-
-    fn flat_map_impl_item(&mut self, i: ast::ImplItem) -> SmallVec<[ast::ImplItem; 1]> {
-        let is_const = match i.node {
-            ast::ImplItemKind::Const(..) => true,
-            ast::ImplItemKind::Method(ast::MethodSig { ref decl, ref header, .. }, _) =>
-                header.constness.node == ast::Constness::Const || Self::should_ignore_fn(decl),
-            _ => false,
-        };
-        self.run(is_const, |s| noop_flat_map_impl_item(i, s))
-    }
-
-    fn visit_anon_const(&mut self, c: &mut ast::AnonConst) {
-        self.run(true, |s| noop_visit_anon_const(c, s))
-    }
-
-    fn visit_block(&mut self, b: &mut P<ast::Block>) {
-        fn stmt_to_block(rules: ast::BlockCheckMode,
-                         s: Option<ast::Stmt>,
-                         sess: &Session) -> ast::Block {
-            ast::Block {
-                stmts: s.into_iter().collect(),
-                rules,
-                id: sess.next_node_id(),
-                span: syntax_pos::DUMMY_SP,
-            }
-        }
-
-        fn block_to_stmt(b: ast::Block, sess: &Session) -> ast::Stmt {
-            let expr = P(ast::Expr {
-                id: sess.next_node_id(),
-                node: ast::ExprKind::Block(P(b), None),
-                span: syntax_pos::DUMMY_SP,
-                attrs: ThinVec::new(),
-            });
-
-            ast::Stmt {
-                id: sess.next_node_id(),
-                node: ast::StmtKind::Expr(expr),
-                span: syntax_pos::DUMMY_SP,
-            }
-        }
-
-        let empty_block = stmt_to_block(BlockCheckMode::Default, None, self.sess);
-        let loop_expr = P(ast::Expr {
-            node: ast::ExprKind::Loop(P(empty_block), None),
-            id: self.sess.next_node_id(),
-            span: syntax_pos::DUMMY_SP,
-                attrs: ThinVec::new(),
-        });
-
-        let loop_stmt = ast::Stmt {
-            id: self.sess.next_node_id(),
-            span: syntax_pos::DUMMY_SP,
-            node: ast::StmtKind::Expr(loop_expr),
-        };
-
-        if self.within_static_or_const {
-            noop_visit_block(b, self)
-        } else {
-            visit_clobber(b.deref_mut(), |b| {
-                let mut stmts = vec![];
-                for s in b.stmts {
-                    let old_blocks = self.nested_blocks.replace(vec![]);
-
-                    stmts.extend(self.flat_map_stmt(s).into_iter().filter(|s| s.is_item()));
-
-                    // we put a Some in there earlier with that replace(), so this is valid
-                    let new_blocks = self.nested_blocks.take().unwrap();
-                    self.nested_blocks = old_blocks;
-                    stmts.extend(new_blocks.into_iter().map(|b| block_to_stmt(b, &self.sess)));
-                }
-
-                let mut new_block = ast::Block {
-                    stmts,
-                    ..b
-                };
-
-                if let Some(old_blocks) = self.nested_blocks.as_mut() {
-                    //push our fresh block onto the cache and yield an empty block with `loop {}`
-                    if !new_block.stmts.is_empty() {
-                        old_blocks.push(new_block);
-                    }
-
-                    stmt_to_block(b.rules, Some(loop_stmt), self.sess)
-                } else {
-                    //push `loop {}` onto the end of our fresh block and yield that
-                    new_block.stmts.push(loop_stmt);
-
-                    new_block
-                }
-            })
-        }
-    }
-
-    // in general the pretty printer processes unexpanded code, so
-    // we override the default `visit_mac` method which panics.
-    fn visit_mac(&mut self, mac: &mut ast::Mac) {
-        noop_visit_mac(mac, self)
-    }
-}
-
 fn print_flowgraph<'a, 'tcx, W: Write>(variants: Vec<borrowck_dot::Variant>,
                                        tcx: TyCtxt<'a, 'tcx, 'tcx>,
                                        code: blocks::Code<'tcx>,
@@ -892,12 +691,12 @@ fn expand_err_details(r: io::Result<()>) -> io::Result<()> {
 
 pub fn visit_crate(sess: &Session, krate: &mut ast::Crate, ppm: PpMode) {
     if let PpmSource(PpmEveryBodyLoops) = ppm {
-        ReplaceBodyWithLoop::new(sess).visit_crate(krate);
+        util::ReplaceBodyWithLoop::new(sess).visit_crate(krate);
     }
 }
 
 fn get_source(input: &Input, sess: &Session) -> (Vec<u8>, FileName) {
-    let src_name = driver::source_name(input);
+    let src_name = input.source_name();
     let src = sess.source_map()
         .get_source_file(&src_name)
         .unwrap()
@@ -1117,18 +916,19 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session,
     let mut out = Vec::new();
 
     let control = &driver::CompileController::basic();
-    let codegen_backend = ::get_codegen_backend(sess);
+    let codegen_backend = util::get_codegen_backend(sess);
     let mut arenas = AllArenas::new();
-    abort_on_err(driver::phase_3_run_analysis_passes(&*codegen_backend,
-                                                     control,
-                                                     sess,
-                                                     cstore,
-                                                     hir_map.clone(),
-                                                     resolutions.clone(),
-                                                     &mut arenas,
-                                                     crate_name,
-                                                     output_filenames,
-                                                     |tcx, _, _| {
+    driver::phase_3_run_analysis_passes(&*codegen_backend,
+                                        control,
+                                        sess,
+                                        cstore,
+                                        hir_map.clone(),
+                                        resolutions.clone(),
+                                        &mut arenas,
+                                        crate_name,
+                                        output_filenames,
+                                        |tcx, _, result| {
+        abort_on_err(result, tcx.sess);
         match ppm {
             PpmMir | PpmMirCFG => {
                 if let Some(nodeid) = nodeid {
@@ -1174,9 +974,7 @@ fn print_with_analysis<'tcx, 'a: 'tcx>(sess: &'a Session,
             }
             _ => unreachable!(),
         }
-    }),
-                 sess)
-        .unwrap();
+    }).unwrap();
 
     write_output(out, ofile);
 }
diff --git a/src/librustc_driver/proc_macro_decls.rs b/src/librustc_driver/proc_macro_decls.rs
deleted file mode 100644 (file)
index 093d15b..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-use rustc::hir::itemlikevisit::ItemLikeVisitor;
-use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
-use rustc::hir;
-use rustc::ty::TyCtxt;
-use rustc::ty::query::Providers;
-use syntax::ast;
-use syntax::attr;
-
-pub fn find<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) -> Option<DefId> {
-    tcx.proc_macro_decls_static(LOCAL_CRATE)
-}
-
-fn proc_macro_decls_static<'tcx>(
-    tcx: TyCtxt<'_, 'tcx, 'tcx>,
-    cnum: CrateNum,
-) -> Option<DefId> {
-    assert_eq!(cnum, LOCAL_CRATE);
-
-    let mut finder = Finder { decls: None };
-    tcx.hir().krate().visit_all_item_likes(&mut finder);
-
-    finder.decls.map(|id| tcx.hir().local_def_id(id))
-}
-
-struct Finder {
-    decls: Option<ast::NodeId>,
-}
-
-impl<'v> ItemLikeVisitor<'v> for Finder {
-    fn visit_item(&mut self, item: &hir::Item) {
-        if attr::contains_name(&item.attrs, "rustc_proc_macro_decls") {
-            self.decls = Some(item.id);
-        }
-    }
-
-    fn visit_trait_item(&mut self, _trait_item: &hir::TraitItem) {
-    }
-
-    fn visit_impl_item(&mut self, _impl_item: &hir::ImplItem) {
-    }
-}
-
-pub(crate) fn provide(providers: &mut Providers<'_>) {
-    *providers = Providers {
-        proc_macro_decls_static,
-        ..*providers
-    };
-}
diff --git a/src/librustc_driver/profile/mod.rs b/src/librustc_driver/profile/mod.rs
deleted file mode 100644 (file)
index eb13a56..0000000
+++ /dev/null
@@ -1,297 +0,0 @@
-use rustc::session::Session;
-use rustc::util::common::{ProfQDumpParams, ProfileQueriesMsg, profq_msg, profq_set_chan};
-use std::sync::mpsc::{Receiver};
-use std::io::{Write};
-use rustc::dep_graph::{DepNode};
-use std::time::{Duration, Instant};
-
-pub mod trace;
-
-/// begin a profile thread, if not already running
-pub fn begin(sess: &Session) {
-    use std::thread;
-    use std::sync::mpsc::{channel};
-    let (tx, rx) = channel();
-    if profq_set_chan(sess, tx) {
-        thread::spawn(move || profile_queries_thread(rx));
-    }
-}
-
-/// dump files with profiling information to the given base path, and
-/// wait for this dump to complete.
-///
-/// wraps the RPC (send/recv channel logic) of requesting a dump.
-pub fn dump(sess: &Session, path: String) {
-    use std::sync::mpsc::{channel};
-    let (tx, rx) = channel();
-    let params = ProfQDumpParams {
-        path,
-        ack: tx,
-        // FIXME: Add another compiler flag to toggle whether this log
-        // is written; false for now
-        dump_profq_msg_log: true,
-    };
-    profq_msg(sess, ProfileQueriesMsg::Dump(params));
-    let _ = rx.recv().unwrap();
-}
-
-// State for parsing recursive trace structure in separate thread, via messages
-#[derive(Clone, Eq, PartialEq)]
-enum ParseState {
-    // No (local) parse state; may be parsing a tree, focused on a
-    // sub-tree that could be anything.
-    Clear,
-    // Have Query information from the last message
-    HaveQuery(trace::Query, Instant),
-    // Have "time-begin" information from the last message (doit flag, and message)
-    HaveTimeBegin(String, Instant),
-    // Have "task-begin" information from the last message
-    HaveTaskBegin(DepNode, Instant),
-}
-struct StackFrame {
-    pub parse_st: ParseState,
-    pub traces:   Vec<trace::Rec>,
-}
-
-fn total_duration(traces: &[trace::Rec]) -> Duration {
-    Duration::new(0, 0) + traces.iter().map(|t| t.dur_total).sum()
-}
-
-// profiling thread; retains state (in local variables) and dump traces, upon request.
-fn profile_queries_thread(r: Receiver<ProfileQueriesMsg>) {
-    use self::trace::*;
-    use std::fs::File;
-    use std::time::{Instant};
-
-    let mut profq_msgs: Vec<ProfileQueriesMsg> = vec![];
-    let mut frame: StackFrame = StackFrame { parse_st: ParseState::Clear, traces: vec![] };
-    let mut stack: Vec<StackFrame> = vec![];
-    loop {
-        let msg = r.recv();
-        if let Err(_recv_err) = msg {
-            // FIXME: Perhaps do something smarter than simply quitting?
-            break
-        };
-        let msg = msg.unwrap();
-        debug!("profile_queries_thread: {:?}", msg);
-
-        // Meta-level versus _actual_ queries messages
-        match msg {
-            ProfileQueriesMsg::Halt => return,
-            ProfileQueriesMsg::Dump(params) => {
-                assert!(stack.is_empty());
-                assert!(frame.parse_st == ParseState::Clear);
-
-                // write log of all messages
-                if params.dump_profq_msg_log {
-                    let mut log_file =
-                        File::create(format!("{}.log.txt", params.path)).unwrap();
-                    for m in profq_msgs.iter() {
-                        writeln!(&mut log_file, "{:?}", m).unwrap()
-                    };
-                }
-
-                // write HTML file, and counts file
-                let html_path = format!("{}.html", params.path);
-                let mut html_file = File::create(&html_path).unwrap();
-
-                let counts_path = format!("{}.counts.txt", params.path);
-                let mut counts_file = File::create(&counts_path).unwrap();
-
-                writeln!(html_file,
-                    "<html>\n<head>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"{}\">",
-                    "profile_queries.css").unwrap();
-                writeln!(html_file, "<style>").unwrap();
-                trace::write_style(&mut html_file);
-                writeln!(html_file, "</style>\n</head>\n<body>").unwrap();
-                trace::write_traces(&mut html_file, &mut counts_file, &frame.traces);
-                writeln!(html_file, "</body>\n</html>").unwrap();
-
-                let ack_path = format!("{}.ack", params.path);
-                let ack_file = File::create(&ack_path).unwrap();
-                drop(ack_file);
-
-                // Tell main thread that we are done, e.g., so it can exit
-                params.ack.send(()).unwrap();
-            }
-            // Actual query message:
-            msg => {
-                // Record msg in our log
-                profq_msgs.push(msg.clone());
-                // Respond to the message, knowing that we've already handled Halt and Dump, above.
-                match (frame.parse_st.clone(), msg) {
-                    (_, ProfileQueriesMsg::Halt) | (_, ProfileQueriesMsg::Dump(_)) => {
-                        unreachable!();
-                    },
-                    // Parse State: Clear
-                    (ParseState::Clear,
-                     ProfileQueriesMsg::QueryBegin(span, querymsg)) => {
-                        let start = Instant::now();
-                        frame.parse_st = ParseState::HaveQuery
-                            (Query { span, msg: querymsg }, start)
-                    },
-                    (ParseState::Clear,
-                     ProfileQueriesMsg::CacheHit) => {
-                        panic!("parse error: unexpected CacheHit; expected QueryBegin")
-                    },
-                    (ParseState::Clear,
-                     ProfileQueriesMsg::ProviderBegin) => {
-                        panic!("parse error: expected QueryBegin before beginning a provider")
-                    },
-                    (ParseState::Clear,
-                     ProfileQueriesMsg::ProviderEnd) => {
-                        let provider_extent = frame.traces;
-                        match stack.pop() {
-                            None =>
-                                panic!("parse error: expected a stack frame; found an empty stack"),
-                            Some(old_frame) => {
-                                match old_frame.parse_st {
-                                    ParseState::HaveQuery(q, start) => {
-                                        let duration = start.elapsed();
-                                        frame = StackFrame{
-                                            parse_st: ParseState::Clear,
-                                            traces: old_frame.traces
-                                        };
-                                        let dur_extent = total_duration(&provider_extent);
-                                        let trace = Rec {
-                                            effect: Effect::QueryBegin(q, CacheCase::Miss),
-                                            extent: Box::new(provider_extent),
-                                            start: start,
-                                            dur_self: duration - dur_extent,
-                                            dur_total: duration,
-                                        };
-                                        frame.traces.push( trace );
-                                    },
-                                    _ => panic!("internal parse error: malformed parse stack")
-                                }
-                            }
-                        }
-                    },
-                    (ParseState::Clear,
-                     ProfileQueriesMsg::TimeBegin(msg)) => {
-                        let start = Instant::now();
-                        frame.parse_st = ParseState::HaveTimeBegin(msg, start);
-                        stack.push(frame);
-                        frame = StackFrame{parse_st: ParseState::Clear, traces: vec![]};
-                    },
-                    (_, ProfileQueriesMsg::TimeBegin(_)) => {
-                        panic!("parse error; did not expect time begin here");
-                    },
-                    (ParseState::Clear,
-                     ProfileQueriesMsg::TimeEnd) => {
-                        let provider_extent = frame.traces;
-                        match stack.pop() {
-                            None =>
-                                panic!("parse error: expected a stack frame; found an empty stack"),
-                            Some(old_frame) => {
-                                match old_frame.parse_st {
-                                    ParseState::HaveTimeBegin(msg, start) => {
-                                        let duration = start.elapsed();
-                                        frame = StackFrame{
-                                            parse_st: ParseState::Clear,
-                                            traces: old_frame.traces
-                                        };
-                                        let dur_extent = total_duration(&provider_extent);
-                                        let trace = Rec {
-                                            effect: Effect::TimeBegin(msg),
-                                            extent: Box::new(provider_extent),
-                                            start: start,
-                                            dur_total: duration,
-                                            dur_self: duration - dur_extent,
-                                        };
-                                        frame.traces.push( trace );
-                                    },
-                                    _ => panic!("internal parse error: malformed parse stack")
-                                }
-                            }
-                        }
-                    },
-                    (_, ProfileQueriesMsg::TimeEnd) => {
-                        panic!("parse error")
-                    },
-                    (ParseState::Clear,
-                     ProfileQueriesMsg::TaskBegin(key)) => {
-                        let start = Instant::now();
-                        frame.parse_st = ParseState::HaveTaskBegin(key, start);
-                        stack.push(frame);
-                        frame = StackFrame{ parse_st: ParseState::Clear, traces: vec![] };
-                    },
-                    (_, ProfileQueriesMsg::TaskBegin(_)) => {
-                        panic!("parse error; did not expect time begin here");
-                    },
-                    (ParseState::Clear,
-                     ProfileQueriesMsg::TaskEnd) => {
-                        let provider_extent = frame.traces;
-                        match stack.pop() {
-                            None =>
-                                panic!("parse error: expected a stack frame; found an empty stack"),
-                            Some(old_frame) => {
-                                match old_frame.parse_st {
-                                    ParseState::HaveTaskBegin(key, start) => {
-                                        let duration = start.elapsed();
-                                        frame = StackFrame{
-                                            parse_st: ParseState::Clear,
-                                            traces: old_frame.traces
-                                        };
-                                        let dur_extent = total_duration(&provider_extent);
-                                        let trace = Rec {
-                                            effect: Effect::TaskBegin(key),
-                                            extent: Box::new(provider_extent),
-                                            start: start,
-                                            dur_total: duration,
-                                            dur_self: duration - dur_extent,
-                                        };
-                                        frame.traces.push( trace );
-                                    },
-                                    _ => panic!("internal parse error: malformed parse stack")
-                                }
-                            }
-                        }
-                    },
-                    (_, ProfileQueriesMsg::TaskEnd) => {
-                        panic!("parse error")
-                    },
-                    // Parse State: HaveQuery
-                    (ParseState::HaveQuery(q,start),
-                     ProfileQueriesMsg::CacheHit) => {
-                        let duration = start.elapsed();
-                        let trace : Rec = Rec{
-                            effect: Effect::QueryBegin(q, CacheCase::Hit),
-                            extent: Box::new(vec![]),
-                            start: start,
-                            dur_self: duration,
-                            dur_total: duration,
-                        };
-                        frame.traces.push( trace );
-                        frame.parse_st = ParseState::Clear;
-                    },
-                    (ParseState::HaveQuery(_, _),
-                     ProfileQueriesMsg::ProviderBegin) => {
-                        stack.push(frame);
-                        frame = StackFrame{ parse_st: ParseState::Clear, traces: vec![] };
-                    },
-
-                    // Parse errors:
-
-                    (ParseState::HaveQuery(q, _),
-                     ProfileQueriesMsg::ProviderEnd) => {
-                        panic!("parse error: unexpected ProviderEnd; \
-                                expected something else to follow BeginQuery for {:?}", q)
-                    },
-                    (ParseState::HaveQuery(q1, _),
-                     ProfileQueriesMsg::QueryBegin(span2, querymsg2)) => {
-                        panic!("parse error: unexpected QueryBegin; \
-                                earlier query is unfinished: {:?} and now {:?}",
-                               q1, Query{span:span2, msg: querymsg2})
-                    },
-                    (ParseState::HaveTimeBegin(_, _), _) => {
-                        unreachable!()
-                    },
-                    (ParseState::HaveTaskBegin(_, _), _) => {
-                        unreachable!()
-                    },
-                }
-            }
-        }
-    }
-}
diff --git a/src/librustc_driver/profile/trace.rs b/src/librustc_driver/profile/trace.rs
deleted file mode 100644 (file)
index 95c4ea6..0000000
+++ /dev/null
@@ -1,304 +0,0 @@
-use super::*;
-use syntax_pos::SpanData;
-use rustc_data_structures::fx::FxHashMap;
-use rustc::util::common::QueryMsg;
-use std::fs::File;
-use std::time::{Duration, Instant};
-use rustc::dep_graph::{DepNode};
-
-#[derive(Debug, Clone, Eq, PartialEq)]
-pub struct Query {
-    pub span: SpanData,
-    pub msg: QueryMsg,
-}
-pub enum Effect {
-    QueryBegin(Query, CacheCase),
-    TimeBegin(String),
-    TaskBegin(DepNode),
-}
-pub enum CacheCase {
-    Hit, Miss
-}
-/// Recursive trace structure
-pub struct Rec {
-    pub effect: Effect,
-    pub start: Instant,
-    pub dur_self: Duration,
-    pub dur_total: Duration,
-    pub extent: Box<Vec<Rec>>,
-}
-pub struct QueryMetric {
-    pub count: usize,
-    pub dur_self: Duration,
-    pub dur_total: Duration,
-}
-
-fn cons(s: &str) -> String {
-    let first = s.split(|d| d == '(' || d == '{').next();
-    assert!(first.is_some() && first != Some(""));
-    first.unwrap().to_owned()
-}
-
-pub fn cons_of_query_msg(q: &trace::Query) -> String {
-    cons(&format!("{:?}", q.msg))
-}
-
-pub fn cons_of_key(k: &DepNode) -> String {
-    cons(&format!("{:?}", k))
-}
-
-// First return value is text; second return value is a CSS class
-pub fn html_of_effect(eff: &Effect) -> (String, String) {
-    match *eff {
-        Effect::TimeBegin(ref msg) => {
-            (msg.clone(),
-             "time-begin".to_string())
-        },
-        Effect::TaskBegin(ref key) => {
-            let cons = cons_of_key(key);
-            (cons.clone(), format!("{} task-begin", cons))
-        },
-        Effect::QueryBegin(ref qmsg, ref cc) => {
-            let cons = cons_of_query_msg(qmsg);
-            (cons.clone(),
-             format!("{} {}",
-                     cons,
-                     match *cc {
-                         CacheCase::Hit => "hit",
-                         CacheCase::Miss => "miss",
-                     }))
-        }
-    }
-}
-
-// First return value is text; second return value is a CSS class
-fn html_of_duration(_start: &Instant, dur: &Duration) -> (String, String) {
-    use rustc::util::common::duration_to_secs_str;
-    (duration_to_secs_str(dur.clone()), String::new())
-}
-
-fn html_of_fraction(frac: f64) -> (String, &'static str) {
-    let css = {
-        if       frac > 0.50  { "frac-50" }
-        else if  frac > 0.40  { "frac-40" }
-        else if  frac > 0.30  { "frac-30" }
-        else if  frac > 0.20  { "frac-20" }
-        else if  frac > 0.10  { "frac-10" }
-        else if  frac > 0.05  { "frac-05" }
-        else if  frac > 0.02  { "frac-02" }
-        else if  frac > 0.01  { "frac-01" }
-        else if  frac > 0.001 { "frac-001" }
-        else                  { "frac-0" }
-    };
-    let percent = frac * 100.0;
-
-    if percent > 0.1 {
-        (format!("{:.1}%", percent), css)
-    } else {
-        ("< 0.1%".to_string(), css)
-    }
-}
-
-fn total_duration(traces: &[Rec]) -> Duration {
-    Duration::new(0, 0) + traces.iter().map(|t| t.dur_total).sum()
-}
-
-fn duration_div(nom: Duration, den: Duration) -> f64 {
-    fn to_nanos(d: Duration) -> u64 {
-        d.as_secs() * 1_000_000_000 + d.subsec_nanos() as u64
-    }
-
-    to_nanos(nom) as f64 / to_nanos(den) as f64
-}
-
-fn write_traces_rec(file: &mut File, traces: &[Rec], total: Duration, depth: usize) {
-    for t in traces {
-        let (eff_text, eff_css_classes) = html_of_effect(&t.effect);
-        let (dur_text, dur_css_classes) = html_of_duration(&t.start, &t.dur_total);
-        let fraction = duration_div(t.dur_total, total);
-        let percent = fraction * 100.0;
-        let (frc_text, frc_css_classes) = html_of_fraction(fraction);
-        writeln!(file, "<div class=\"trace depth-{} extent-{}{} {} {} {}\">",
-                 depth,
-                 t.extent.len(),
-                 /* Heuristic for 'important' CSS class: */
-                 if t.extent.len() > 5 || percent >= 1.0 { " important" } else { "" },
-                 eff_css_classes,
-                 dur_css_classes,
-                 frc_css_classes,
-        ).unwrap();
-        writeln!(file, "<div class=\"eff\">{}</div>", eff_text).unwrap();
-        writeln!(file, "<div class=\"dur\">{}</div>", dur_text).unwrap();
-        writeln!(file, "<div class=\"frc\">{}</div>", frc_text).unwrap();
-        write_traces_rec(file, &t.extent, total, depth + 1);
-        writeln!(file, "</div>").unwrap();
-    }
-}
-
-fn compute_counts_rec(counts: &mut FxHashMap<String,QueryMetric>, traces: &[Rec]) {
-    counts.reserve(traces.len());
-    for t in traces.iter() {
-        match t.effect {
-            Effect::TimeBegin(ref msg) => {
-                let qm = match counts.get(msg) {
-                    Some(_qm) => panic!("TimeBegin with non-unique, repeat message"),
-                    None => QueryMetric {
-                        count: 1,
-                        dur_self: t.dur_self,
-                        dur_total: t.dur_total,
-                    }
-                };
-                counts.insert(msg.clone(), qm);
-            },
-            Effect::TaskBegin(ref key) => {
-                let cons = cons_of_key(key);
-                let qm = match counts.get(&cons) {
-                    Some(qm) =>
-                        QueryMetric {
-                            count: qm.count + 1,
-                            dur_self: qm.dur_self + t.dur_self,
-                            dur_total: qm.dur_total + t.dur_total,
-                        },
-                    None => QueryMetric {
-                        count: 1,
-                        dur_self: t.dur_self,
-                        dur_total: t.dur_total,
-                    }
-                };
-                counts.insert(cons, qm);
-            },
-            Effect::QueryBegin(ref qmsg, ref _cc) => {
-                let qcons = cons_of_query_msg(qmsg);
-                let qm = match counts.get(&qcons) {
-                    Some(qm) =>
-                        QueryMetric {
-                            count: qm.count + 1,
-                            dur_total: qm.dur_total + t.dur_total,
-                            dur_self: qm.dur_self + t.dur_self
-                        },
-                    None => QueryMetric {
-                        count: 1,
-                        dur_total: t.dur_total,
-                        dur_self: t.dur_self,
-                    }
-                };
-                counts.insert(qcons, qm);
-            }
-        }
-        compute_counts_rec(counts, &t.extent)
-    }
-}
-
-pub fn write_counts(count_file: &mut File, counts: &mut FxHashMap<String, QueryMetric>) {
-    use rustc::util::common::duration_to_secs_str;
-    use std::cmp::Reverse;
-
-    let mut data = counts.iter().map(|(ref cons, ref qm)|
-        (cons.clone(), qm.count.clone(), qm.dur_total.clone(), qm.dur_self.clone())
-    ).collect::<Vec<_>>();
-
-    data.sort_by_key(|k| Reverse(k.3));
-    for (cons, count, dur_total, dur_self) in data {
-        writeln!(count_file, "{}, {}, {}, {}",
-                 cons, count,
-                 duration_to_secs_str(dur_total),
-                 duration_to_secs_str(dur_self)
-        ).unwrap();
-    }
-}
-
-pub fn write_traces(html_file: &mut File, counts_file: &mut File, traces: &[Rec]) {
-    let capacity = traces.iter().fold(0, |acc, t| acc + 1 + t.extent.len());
-    let mut counts = FxHashMap::with_capacity_and_hasher(capacity, Default::default());
-    compute_counts_rec(&mut counts, traces);
-    write_counts(counts_file, &mut counts);
-
-    let total: Duration = total_duration(traces);
-    write_traces_rec(html_file, traces, total, 0)
-}
-
-pub fn write_style(html_file: &mut File) {
-    write!(html_file, "{}", "
-body {
-    font-family: sans-serif;
-    background: black;
-}
-.trace {
-    color: black;
-    display: inline-block;
-    border-style: solid;
-    border-color: red;
-    border-width: 1px;
-    border-radius: 5px;
-    padding: 0px;
-    margin: 1px;
-    font-size: 0px;
-}
-.task-begin {
-    border-width: 1px;
-    color: white;
-    border-color: #ff8;
-    font-size: 0px;
-}
-.miss {
-    border-color: red;
-    border-width: 1px;
-}
-.extent-0 {
-    padding: 2px;
-}
-.time-begin {
-    border-width: 4px;
-    font-size: 12px;
-    color: white;
-    border-color: #afa;
-}
-.important {
-    border-width: 3px;
-    font-size: 12px;
-    color: white;
-    border-color: #f77;
-}
-.hit {
-    padding: 0px;
-    border-color: blue;
-    border-width: 3px;
-}
-.eff {
-  color: #fff;
-  display: inline-block;
-}
-.frc {
-  color: #7f7;
-  display: inline-block;
-}
-.dur {
-  display: none
-}
-.frac-50 {
-  padding: 10px;
-  border-width: 10px;
-  font-size: 32px;
-}
-.frac-40 {
-  padding: 8px;
-  border-width: 8px;
-  font-size: 24px;
-}
-.frac-30 {
-  padding: 6px;
-  border-width: 6px;
-  font-size: 18px;
-}
-.frac-20 {
-  padding: 4px;
-  border-width: 6px;
-  font-size: 16px;
-}
-.frac-10 {
-  padding: 2px;
-  border-width: 6px;
-  font-size: 14px;
-}
-").unwrap();
-}
index 2ec755bd626919864c5efc671ed5b11f9076727c..309a9f7b5252253d8b974f95f6cb624fcb4118a2 100644 (file)
@@ -16,6 +16,7 @@
 use rustc::ty::subst::Subst;
 use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
 use rustc_data_structures::sync::{self, Lrc};
+use rustc_interface::util;
 use rustc_lint;
 use rustc_metadata::cstore::CStore;
 use rustc_target::spec::abi::Abi;
@@ -91,6 +92,13 @@ fn test_env<F>(source_string: &str, args: (Box<dyn Emitter + sync::Send>, usize)
         options.debugging_opts.verbose = true;
         options.unstable_features = UnstableFeatures::Allow;
 
+        // When we're compiling this library with `--test` it'll run as a binary but
+        // not actually exercise much functionality.
+        // As a result most of the logic loading the codegen backend is defunkt
+        // (it assumes we're a dynamic library in a sysroot)
+        // so let's just use the metadata only backend which doesn't need to load any libraries.
+        options.debugging_opts.codegen_backend = Some("metadata_only".to_owned());
+
         driver::spawn_thread_pool(options, |options| {
             test_env_with_pool(options, source_string, args, body)
         })
@@ -111,8 +119,9 @@ fn test_env_with_pool<F>(
         None,
         diagnostic_handler,
         Lrc::new(SourceMap::new(FilePathMapping::empty())),
+        Default::default(),
     );
-    let cstore = CStore::new(::get_codegen_backend(&sess).metadata_loader());
+    let cstore = CStore::new(util::get_codegen_backend(&sess).metadata_loader());
     rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
     let input = config::Input::Str {
         name: FileName::anon_source_code(&source_string),
index fe44e0cbe614333fab41428cead6d9445f252bb6..1f69d617c83b71949f40dcfc468e24a64d62fb0a 100644 (file)
@@ -69,7 +69,7 @@ pub fn assert_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
             let mut visitor = IfThisChanged { tcx,
                                             if_this_changed: vec![],
                                             then_this_would_need: vec![] };
-            visitor.process_attrs(ast::CRATE_NODE_ID, &tcx.hir().krate().attrs);
+            visitor.process_attrs(hir::CRATE_HIR_ID, &tcx.hir().krate().attrs);
             tcx.hir().krate().visit_all_item_likes(&mut visitor.as_deep_visitor());
             (visitor.if_this_changed, visitor.then_this_would_need)
         };
@@ -87,7 +87,7 @@ pub fn assert_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
 }
 
 type Sources = Vec<(Span, DefId, DepNode)>;
-type Targets = Vec<(Span, ast::Name, ast::NodeId, DepNode)>;
+type Targets = Vec<(Span, ast::Name, hir::HirId, DepNode)>;
 
 struct IfThisChanged<'a, 'tcx:'a> {
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
@@ -110,8 +110,8 @@ fn argument(&self, attr: &ast::Attribute) -> Option<ast::Name> {
         value
     }
 
-    fn process_attrs(&mut self, node_id: ast::NodeId, attrs: &[ast::Attribute]) {
-        let def_id = self.tcx.hir().local_def_id(node_id);
+    fn process_attrs(&mut self, hir_id: hir::HirId, attrs: &[ast::Attribute]) {
+        let def_id = self.tcx.hir().local_def_id_from_hir_id(hir_id);
         let def_path_hash = self.tcx.def_path_hash(def_id);
         for attr in attrs {
             if attr.check_name(ATTR_IF_THIS_CHANGED) {
@@ -151,7 +151,7 @@ fn process_attrs(&mut self, node_id: ast::NodeId, attrs: &[ast::Attribute]) {
                 };
                 self.then_this_would_need.push((attr.span,
                                                 dep_node_interned.unwrap(),
-                                                node_id,
+                                                hir_id,
                                                 dep_node));
             }
         }
@@ -164,22 +164,22 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
     }
 
     fn visit_item(&mut self, item: &'tcx hir::Item) {
-        self.process_attrs(item.id, &item.attrs);
+        self.process_attrs(item.hir_id, &item.attrs);
         intravisit::walk_item(self, item);
     }
 
     fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
-        self.process_attrs(trait_item.id, &trait_item.attrs);
+        self.process_attrs(trait_item.hir_id, &trait_item.attrs);
         intravisit::walk_trait_item(self, trait_item);
     }
 
     fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
-        self.process_attrs(impl_item.id, &impl_item.attrs);
+        self.process_attrs(impl_item.hir_id, &impl_item.attrs);
         intravisit::walk_impl_item(self, impl_item);
     }
 
     fn visit_struct_field(&mut self, s: &'tcx hir::StructField) {
-        self.process_attrs(s.id, &s.attrs);
+        self.process_attrs(s.hir_id, &s.attrs);
         intravisit::walk_struct_field(self, s);
     }
 }
index c13a3533032a8298b531a6e04bacdf337112c735..2794b6c556ff24652aa081903f5f0fdbac9a67c7 100644 (file)
@@ -241,7 +241,7 @@ pub struct DirtyCleanVisitor<'a, 'tcx:'a> {
 impl<'a, 'tcx> DirtyCleanVisitor<'a, 'tcx> {
 
     /// Possibly "deserialize" the attribute into a clean/dirty assertion
-    fn assertion_maybe(&mut self, item_id: ast::NodeId, attr: &Attribute)
+    fn assertion_maybe(&mut self, item_id: hir::HirId, attr: &Attribute)
         -> Option<Assertion>
     {
         let is_clean = if attr.check_name(ATTR_DIRTY) {
@@ -269,7 +269,7 @@ fn assertion_maybe(&mut self, item_id: ast::NodeId, attr: &Attribute)
     }
 
     /// Gets the "auto" assertion on pre-validated attr, along with the `except` labels.
-    fn assertion_auto(&mut self, item_id: ast::NodeId, attr: &Attribute, is_clean: bool)
+    fn assertion_auto(&mut self, item_id: hir::HirId, attr: &Attribute, is_clean: bool)
         -> Assertion
     {
         let (name, mut auto) = self.auto_labels(item_id, attr);
@@ -321,8 +321,8 @@ fn except(&self, attr: &Attribute) -> Labels {
 
     /// Return all DepNode labels that should be asserted for this item.
     /// index=0 is the "name" used for error messages
-    fn auto_labels(&mut self, item_id: ast::NodeId, attr: &Attribute) -> (&'static str, Labels) {
-        let node = self.tcx.hir().get(item_id);
+    fn auto_labels(&mut self, item_id: hir::HirId, attr: &Attribute) -> (&'static str, Labels) {
+        let node = self.tcx.hir().get_by_hir_id(item_id);
         let (name, labels) = match node {
             HirNode::Item(item) => {
                 match item.node {
@@ -499,8 +499,8 @@ fn assert_clean(&self, item_span: Span, dep_node: DepNode) {
         }
     }
 
-    fn check_item(&mut self, item_id: ast::NodeId, item_span: Span) {
-        let def_id = self.tcx.hir().local_def_id(item_id);
+    fn check_item(&mut self, item_id: hir::HirId, item_span: Span) {
+        let def_id = self.tcx.hir().local_def_id_from_hir_id(item_id);
         for attr in self.tcx.get_attrs(def_id).iter() {
             let assertion = match self.assertion_maybe(item_id, attr) {
                 Some(a) => a,
@@ -519,15 +519,15 @@ fn check_item(&mut self, item_id: ast::NodeId, item_span: Span) {
 
 impl<'a, 'tcx> ItemLikeVisitor<'tcx> for DirtyCleanVisitor<'a, 'tcx> {
     fn visit_item(&mut self, item: &'tcx hir::Item) {
-        self.check_item(item.id, item.span);
+        self.check_item(item.hir_id, item.span);
     }
 
     fn visit_trait_item(&mut self, item: &hir::TraitItem) {
-        self.check_item(item.id, item.span);
+        self.check_item(item.hir_id, item.span);
     }
 
     fn visit_impl_item(&mut self, item: &hir::ImplItem) {
-        self.check_item(item.id, item.span);
+        self.check_item(item.hir_id, item.span);
     }
 }
 
diff --git a/src/librustc_interface/Cargo.toml b/src/librustc_interface/Cargo.toml
new file mode 100644 (file)
index 0000000..1acd3df
--- /dev/null
@@ -0,0 +1,35 @@
+[package]
+authors = ["The Rust Project Developers"]
+name = "rustc_interface"
+version = "0.0.0"
+
+[lib]
+name = "rustc_interface"
+path = "lib.rs"
+crate-type = ["dylib"]
+
+[dependencies]
+log = "0.4"
+rustc-rayon = "0.1.1"
+smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
+scoped-tls = { version = "0.1.1", features = ["nightly"] }
+syntax = { path = "../libsyntax" }
+syntax_ext = { path = "../libsyntax_ext" }
+syntax_pos = { path = "../libsyntax_pos" }
+serialize = { path = "../libserialize" }
+rustc = { path = "../librustc" }
+rustc_allocator = { path = "../librustc_allocator" }
+rustc_borrowck = { path = "../librustc_borrowck" }
+rustc_incremental = { path = "../librustc_incremental" }
+rustc_traits = { path = "../librustc_traits" }
+rustc_data_structures = { path = "../librustc_data_structures" }
+rustc_codegen_utils = { path = "../librustc_codegen_utils" }
+rustc_metadata = { path = "../librustc_metadata" }
+rustc_mir = { path = "../librustc_mir" }
+rustc_passes = { path = "../librustc_passes" }
+rustc_typeck = { path = "../librustc_typeck" }
+rustc_lint = { path = "../librustc_lint" }
+rustc_errors = { path = "../librustc_errors" }
+rustc_plugin = { path = "../librustc_plugin" }
+rustc_privacy = { path = "../librustc_privacy" }
+rustc_resolve = { path = "../librustc_resolve" }
diff --git a/src/librustc_interface/lib.rs b/src/librustc_interface/lib.rs
new file mode 100644 (file)
index 0000000..e5c7c35
--- /dev/null
@@ -0,0 +1,43 @@
+#![feature(box_syntax)]
+#![feature(set_stdio)]
+#![feature(nll)]
+#![feature(arbitrary_self_types)]
+#![feature(generator_trait)]
+#![cfg_attr(unix, feature(libc))]
+
+#![allow(unused_imports)]
+
+#![recursion_limit="256"]
+
+#[cfg(unix)]
+extern crate libc;
+#[macro_use]
+extern crate log;
+extern crate rustc;
+extern crate rustc_codegen_utils;
+extern crate rustc_allocator;
+extern crate rustc_borrowck;
+extern crate rustc_incremental;
+extern crate rustc_traits;
+#[macro_use]
+extern crate rustc_data_structures;
+extern crate rustc_errors;
+extern crate rustc_lint;
+extern crate rustc_metadata;
+extern crate rustc_mir;
+extern crate rustc_passes;
+extern crate rustc_plugin;
+extern crate rustc_privacy;
+extern crate rustc_rayon as rayon;
+extern crate rustc_resolve;
+extern crate rustc_typeck;
+extern crate smallvec;
+extern crate serialize;
+extern crate syntax;
+extern crate syntax_pos;
+extern crate syntax_ext;
+
+pub mod passes;
+pub mod profile;
+pub mod util;
+pub mod proc_macro_decls;
diff --git a/src/librustc_interface/passes.rs b/src/librustc_interface/passes.rs
new file mode 100644 (file)
index 0000000..16ced69
--- /dev/null
@@ -0,0 +1,296 @@
+use util;
+use proc_macro_decls;
+
+use rustc::dep_graph::DepGraph;
+use rustc::hir;
+use rustc::hir::lowering::lower_crate;
+use rustc::hir::def_id::{CrateNum, LOCAL_CRATE};
+use rustc::lint;
+use rustc::middle::{self, reachable, resolve_lifetime, stability};
+use rustc::middle::privacy::AccessLevels;
+use rustc::ty::{self, AllArenas, Resolutions, TyCtxt};
+use rustc::ty::steal::Steal;
+use rustc::traits;
+use rustc::util::common::{time, ErrorReported};
+use rustc::util::profiling::ProfileCategory;
+use rustc::session::{CompileResult, CrateDisambiguator, Session};
+use rustc::session::config::{self, Input, OutputFilenames, OutputType};
+use rustc::session::search_paths::PathKind;
+use rustc_allocator as allocator;
+use rustc_borrowck as borrowck;
+use rustc_codegen_utils::codegen_backend::CodegenBackend;
+use rustc_data_structures::fingerprint::Fingerprint;
+use rustc_data_structures::stable_hasher::StableHasher;
+use rustc_data_structures::sync::Lrc;
+use rustc_incremental;
+use rustc_metadata::creader::CrateLoader;
+use rustc_metadata::cstore::{self, CStore};
+use rustc_mir as mir;
+use rustc_passes::{self, ast_validation, hir_stats, loops, rvalue_promotion, layout_test};
+use rustc_plugin as plugin;
+use rustc_plugin::registry::Registry;
+use rustc_privacy;
+use rustc_resolve::{Resolver, ResolverArenas};
+use rustc_traits;
+use rustc_typeck as typeck;
+use syntax::{self, ast, attr, diagnostics, visit};
+use syntax::early_buffered_lints::BufferedEarlyLint;
+use syntax::ext::base::ExtCtxt;
+use syntax::mut_visit::MutVisitor;
+use syntax::parse::{self, PResult};
+use syntax::util::node_count::NodeCounter;
+use syntax::util::lev_distance::find_best_match_for_name;
+use syntax::symbol::Symbol;
+use syntax_pos::{FileName, hygiene};
+use syntax_ext;
+
+use serialize::json;
+
+use std::any::Any;
+use std::env;
+use std::ffi::OsString;
+use std::fs;
+use std::io::{self, Write};
+use std::iter;
+use std::path::{Path, PathBuf};
+use std::sync::mpsc;
+use std::cell::RefCell;
+use std::rc::Rc;
+use std::mem;
+use std::ops::Generator;
+
+/// Returns all the paths that correspond to generated files.
+pub fn generated_output_paths(
+    sess: &Session,
+    outputs: &OutputFilenames,
+    exact_name: bool,
+    crate_name: &str,
+) -> Vec<PathBuf> {
+    let mut out_filenames = Vec::new();
+    for output_type in sess.opts.output_types.keys() {
+        let file = outputs.path(*output_type);
+        match *output_type {
+            // If the filename has been overridden using `-o`, it will not be modified
+            // by appending `.rlib`, `.exe`, etc., so we can skip this transformation.
+            OutputType::Exe if !exact_name => for crate_type in sess.crate_types.borrow().iter() {
+                let p = ::rustc_codegen_utils::link::filename_for_input(
+                    sess,
+                    *crate_type,
+                    crate_name,
+                    outputs,
+                );
+                out_filenames.push(p);
+            },
+            OutputType::DepInfo if sess.opts.debugging_opts.dep_info_omit_d_target => {
+                // Don't add the dep-info output when omitting it from dep-info targets
+            }
+            _ => {
+                out_filenames.push(file);
+            }
+        }
+    }
+    out_filenames
+}
+
+// Runs `f` on every output file path and returns the first non-None result, or None if `f`
+// returns None for every file path.
+fn check_output<F, T>(output_paths: &[PathBuf], f: F) -> Option<T>
+where
+    F: Fn(&PathBuf) -> Option<T>,
+{
+    for output_path in output_paths {
+        if let Some(result) = f(output_path) {
+            return Some(result);
+        }
+    }
+    None
+}
+
+pub fn output_contains_path(output_paths: &[PathBuf], input_path: &PathBuf) -> bool {
+    let input_path = input_path.canonicalize().ok();
+    if input_path.is_none() {
+        return false;
+    }
+    let check = |output_path: &PathBuf| {
+        if output_path.canonicalize().ok() == input_path {
+            Some(())
+        } else {
+            None
+        }
+    };
+    check_output(output_paths, check).is_some()
+}
+
+pub fn output_conflicts_with_dir(output_paths: &[PathBuf]) -> Option<PathBuf> {
+    let check = |output_path: &PathBuf| {
+        if output_path.is_dir() {
+            Some(output_path.clone())
+        } else {
+            None
+        }
+    };
+    check_output(output_paths, check)
+}
+
+fn escape_dep_filename(filename: &FileName) -> String {
+    // Apparently clang and gcc *only* escape spaces:
+    // http://llvm.org/klaus/clang/commit/9d50634cfc268ecc9a7250226dd5ca0e945240d4
+    filename.to_string().replace(" ", "\\ ")
+}
+
+pub fn write_out_deps(sess: &Session, outputs: &OutputFilenames, out_filenames: &[PathBuf]) {
+    // Write out dependency rules to the dep-info file if requested
+    if !sess.opts.output_types.contains_key(&OutputType::DepInfo) {
+        return;
+    }
+    let deps_filename = outputs.path(OutputType::DepInfo);
+
+    let result = (|| -> io::Result<()> {
+        // Build a list of files used to compile the output and
+        // write Makefile-compatible dependency rules
+        let files: Vec<String> = sess.source_map()
+            .files()
+            .iter()
+            .filter(|fmap| fmap.is_real_file())
+            .filter(|fmap| !fmap.is_imported())
+            .map(|fmap| escape_dep_filename(&fmap.name))
+            .collect();
+        let mut file = fs::File::create(&deps_filename)?;
+        for path in out_filenames {
+            writeln!(file, "{}: {}\n", path.display(), files.join(" "))?;
+        }
+
+        // Emit a fake target for each input file to the compilation. This
+        // prevents `make` from spitting out an error if a file is later
+        // deleted. For more info see #28735
+        for path in files {
+            writeln!(file, "{}:", path)?;
+        }
+        Ok(())
+    })();
+
+    if let Err(e) = result {
+        sess.fatal(&format!(
+            "error writing dependencies to `{}`: {}",
+            deps_filename.display(),
+            e
+        ));
+    }
+}
+
+pub fn provide(providers: &mut ty::query::Providers) {
+    providers.analysis = analysis;
+    proc_macro_decls::provide(providers);
+}
+
+fn analysis<'tcx>(
+    tcx: TyCtxt<'_, 'tcx, 'tcx>,
+    cnum: CrateNum,
+) -> Result<(), ErrorReported> {
+    assert_eq!(cnum, LOCAL_CRATE);
+
+    let sess = tcx.sess;
+
+    parallel!({
+        time(sess, "looking for entry point", || {
+            middle::entry::find_entry_point(tcx)
+        });
+
+        time(sess, "looking for plugin registrar", || {
+            plugin::build::find_plugin_registrar(tcx)
+        });
+
+        time(sess, "looking for derive registrar", || {
+            proc_macro_decls::find(tcx)
+        });
+    }, {
+        time(sess, "loop checking", || loops::check_crate(tcx));
+    }, {
+        time(sess, "attribute checking", || {
+            hir::check_attr::check_crate(tcx)
+        });
+    }, {
+        time(sess, "stability checking", || {
+            stability::check_unstable_api_usage(tcx)
+        });
+    });
+
+    // passes are timed inside typeck
+    typeck::check_crate(tcx)?;
+
+    time(sess, "misc checking", || {
+        parallel!({
+            time(sess, "rvalue promotion", || {
+                rvalue_promotion::check_crate(tcx)
+            });
+        }, {
+            time(sess, "intrinsic checking", || {
+                middle::intrinsicck::check_crate(tcx)
+            });
+        }, {
+            time(sess, "match checking", || mir::matchck_crate(tcx));
+        }, {
+            // this must run before MIR dump, because
+            // "not all control paths return a value" is reported here.
+            //
+            // maybe move the check to a MIR pass?
+            time(sess, "liveness checking", || {
+                middle::liveness::check_crate(tcx)
+            });
+        });
+    });
+
+    // Abort so we don't try to construct MIR with liveness errors.
+    // We also won't want to continue with errors from rvalue promotion
+    tcx.sess.abort_if_errors();
+
+    time(sess, "borrow checking", || {
+        if tcx.use_ast_borrowck() {
+            borrowck::check_crate(tcx);
+        }
+    });
+
+    time(sess,
+            "MIR borrow checking",
+            || tcx.par_body_owners(|def_id| { tcx.ensure().mir_borrowck(def_id); }));
+
+    time(sess, "dumping chalk-like clauses", || {
+        rustc_traits::lowering::dump_program_clauses(tcx);
+    });
+
+    time(sess, "MIR effect checking", || {
+        for def_id in tcx.body_owners() {
+            mir::transform::check_unsafety::check_unsafety(tcx, def_id)
+        }
+    });
+
+    time(sess, "layout testing", || layout_test::test_layout(tcx));
+
+    // Avoid overwhelming user with errors if borrow checking failed.
+    // I'm not sure how helpful this is, to be honest, but it avoids
+    // a
+    // lot of annoying errors in the compile-fail tests (basically,
+    // lint warnings and so on -- kindck used to do this abort, but
+    // kindck is gone now). -nmatsakis
+    if sess.err_count() > 0 {
+        return Err(ErrorReported);
+    }
+
+    time(sess, "misc checking", || {
+        parallel!({
+            time(sess, "privacy checking", || {
+                rustc_privacy::check_crate(tcx)
+            });
+        }, {
+            time(sess, "death checking", || middle::dead::check_crate(tcx));
+        },  {
+            time(sess, "unused lib feature checking", || {
+                stability::check_unused_or_stable_features(tcx)
+            });
+        }, {
+            time(sess, "lint checking", || lint::check_crate(tcx));
+        });
+    });
+
+    Ok(())
+}
diff --git a/src/librustc_interface/proc_macro_decls.rs b/src/librustc_interface/proc_macro_decls.rs
new file mode 100644 (file)
index 0000000..093d15b
--- /dev/null
@@ -0,0 +1,48 @@
+use rustc::hir::itemlikevisit::ItemLikeVisitor;
+use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
+use rustc::hir;
+use rustc::ty::TyCtxt;
+use rustc::ty::query::Providers;
+use syntax::ast;
+use syntax::attr;
+
+pub fn find<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) -> Option<DefId> {
+    tcx.proc_macro_decls_static(LOCAL_CRATE)
+}
+
+fn proc_macro_decls_static<'tcx>(
+    tcx: TyCtxt<'_, 'tcx, 'tcx>,
+    cnum: CrateNum,
+) -> Option<DefId> {
+    assert_eq!(cnum, LOCAL_CRATE);
+
+    let mut finder = Finder { decls: None };
+    tcx.hir().krate().visit_all_item_likes(&mut finder);
+
+    finder.decls.map(|id| tcx.hir().local_def_id(id))
+}
+
+struct Finder {
+    decls: Option<ast::NodeId>,
+}
+
+impl<'v> ItemLikeVisitor<'v> for Finder {
+    fn visit_item(&mut self, item: &hir::Item) {
+        if attr::contains_name(&item.attrs, "rustc_proc_macro_decls") {
+            self.decls = Some(item.id);
+        }
+    }
+
+    fn visit_trait_item(&mut self, _trait_item: &hir::TraitItem) {
+    }
+
+    fn visit_impl_item(&mut self, _impl_item: &hir::ImplItem) {
+    }
+}
+
+pub(crate) fn provide(providers: &mut Providers<'_>) {
+    *providers = Providers {
+        proc_macro_decls_static,
+        ..*providers
+    };
+}
diff --git a/src/librustc_interface/profile/mod.rs b/src/librustc_interface/profile/mod.rs
new file mode 100644 (file)
index 0000000..eb13a56
--- /dev/null
@@ -0,0 +1,297 @@
+use rustc::session::Session;
+use rustc::util::common::{ProfQDumpParams, ProfileQueriesMsg, profq_msg, profq_set_chan};
+use std::sync::mpsc::{Receiver};
+use std::io::{Write};
+use rustc::dep_graph::{DepNode};
+use std::time::{Duration, Instant};
+
+pub mod trace;
+
+/// begin a profile thread, if not already running
+pub fn begin(sess: &Session) {
+    use std::thread;
+    use std::sync::mpsc::{channel};
+    let (tx, rx) = channel();
+    if profq_set_chan(sess, tx) {
+        thread::spawn(move || profile_queries_thread(rx));
+    }
+}
+
+/// dump files with profiling information to the given base path, and
+/// wait for this dump to complete.
+///
+/// wraps the RPC (send/recv channel logic) of requesting a dump.
+pub fn dump(sess: &Session, path: String) {
+    use std::sync::mpsc::{channel};
+    let (tx, rx) = channel();
+    let params = ProfQDumpParams {
+        path,
+        ack: tx,
+        // FIXME: Add another compiler flag to toggle whether this log
+        // is written; false for now
+        dump_profq_msg_log: true,
+    };
+    profq_msg(sess, ProfileQueriesMsg::Dump(params));
+    let _ = rx.recv().unwrap();
+}
+
+// State for parsing recursive trace structure in separate thread, via messages
+#[derive(Clone, Eq, PartialEq)]
+enum ParseState {
+    // No (local) parse state; may be parsing a tree, focused on a
+    // sub-tree that could be anything.
+    Clear,
+    // Have Query information from the last message
+    HaveQuery(trace::Query, Instant),
+    // Have "time-begin" information from the last message (doit flag, and message)
+    HaveTimeBegin(String, Instant),
+    // Have "task-begin" information from the last message
+    HaveTaskBegin(DepNode, Instant),
+}
+struct StackFrame {
+    pub parse_st: ParseState,
+    pub traces:   Vec<trace::Rec>,
+}
+
+fn total_duration(traces: &[trace::Rec]) -> Duration {
+    Duration::new(0, 0) + traces.iter().map(|t| t.dur_total).sum()
+}
+
+// profiling thread; retains state (in local variables) and dump traces, upon request.
+fn profile_queries_thread(r: Receiver<ProfileQueriesMsg>) {
+    use self::trace::*;
+    use std::fs::File;
+    use std::time::{Instant};
+
+    let mut profq_msgs: Vec<ProfileQueriesMsg> = vec![];
+    let mut frame: StackFrame = StackFrame { parse_st: ParseState::Clear, traces: vec![] };
+    let mut stack: Vec<StackFrame> = vec![];
+    loop {
+        let msg = r.recv();
+        if let Err(_recv_err) = msg {
+            // FIXME: Perhaps do something smarter than simply quitting?
+            break
+        };
+        let msg = msg.unwrap();
+        debug!("profile_queries_thread: {:?}", msg);
+
+        // Meta-level versus _actual_ queries messages
+        match msg {
+            ProfileQueriesMsg::Halt => return,
+            ProfileQueriesMsg::Dump(params) => {
+                assert!(stack.is_empty());
+                assert!(frame.parse_st == ParseState::Clear);
+
+                // write log of all messages
+                if params.dump_profq_msg_log {
+                    let mut log_file =
+                        File::create(format!("{}.log.txt", params.path)).unwrap();
+                    for m in profq_msgs.iter() {
+                        writeln!(&mut log_file, "{:?}", m).unwrap()
+                    };
+                }
+
+                // write HTML file, and counts file
+                let html_path = format!("{}.html", params.path);
+                let mut html_file = File::create(&html_path).unwrap();
+
+                let counts_path = format!("{}.counts.txt", params.path);
+                let mut counts_file = File::create(&counts_path).unwrap();
+
+                writeln!(html_file,
+                    "<html>\n<head>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"{}\">",
+                    "profile_queries.css").unwrap();
+                writeln!(html_file, "<style>").unwrap();
+                trace::write_style(&mut html_file);
+                writeln!(html_file, "</style>\n</head>\n<body>").unwrap();
+                trace::write_traces(&mut html_file, &mut counts_file, &frame.traces);
+                writeln!(html_file, "</body>\n</html>").unwrap();
+
+                let ack_path = format!("{}.ack", params.path);
+                let ack_file = File::create(&ack_path).unwrap();
+                drop(ack_file);
+
+                // Tell main thread that we are done, e.g., so it can exit
+                params.ack.send(()).unwrap();
+            }
+            // Actual query message:
+            msg => {
+                // Record msg in our log
+                profq_msgs.push(msg.clone());
+                // Respond to the message, knowing that we've already handled Halt and Dump, above.
+                match (frame.parse_st.clone(), msg) {
+                    (_, ProfileQueriesMsg::Halt) | (_, ProfileQueriesMsg::Dump(_)) => {
+                        unreachable!();
+                    },
+                    // Parse State: Clear
+                    (ParseState::Clear,
+                     ProfileQueriesMsg::QueryBegin(span, querymsg)) => {
+                        let start = Instant::now();
+                        frame.parse_st = ParseState::HaveQuery
+                            (Query { span, msg: querymsg }, start)
+                    },
+                    (ParseState::Clear,
+                     ProfileQueriesMsg::CacheHit) => {
+                        panic!("parse error: unexpected CacheHit; expected QueryBegin")
+                    },
+                    (ParseState::Clear,
+                     ProfileQueriesMsg::ProviderBegin) => {
+                        panic!("parse error: expected QueryBegin before beginning a provider")
+                    },
+                    (ParseState::Clear,
+                     ProfileQueriesMsg::ProviderEnd) => {
+                        let provider_extent = frame.traces;
+                        match stack.pop() {
+                            None =>
+                                panic!("parse error: expected a stack frame; found an empty stack"),
+                            Some(old_frame) => {
+                                match old_frame.parse_st {
+                                    ParseState::HaveQuery(q, start) => {
+                                        let duration = start.elapsed();
+                                        frame = StackFrame{
+                                            parse_st: ParseState::Clear,
+                                            traces: old_frame.traces
+                                        };
+                                        let dur_extent = total_duration(&provider_extent);
+                                        let trace = Rec {
+                                            effect: Effect::QueryBegin(q, CacheCase::Miss),
+                                            extent: Box::new(provider_extent),
+                                            start: start,
+                                            dur_self: duration - dur_extent,
+                                            dur_total: duration,
+                                        };
+                                        frame.traces.push( trace );
+                                    },
+                                    _ => panic!("internal parse error: malformed parse stack")
+                                }
+                            }
+                        }
+                    },
+                    (ParseState::Clear,
+                     ProfileQueriesMsg::TimeBegin(msg)) => {
+                        let start = Instant::now();
+                        frame.parse_st = ParseState::HaveTimeBegin(msg, start);
+                        stack.push(frame);
+                        frame = StackFrame{parse_st: ParseState::Clear, traces: vec![]};
+                    },
+                    (_, ProfileQueriesMsg::TimeBegin(_)) => {
+                        panic!("parse error; did not expect time begin here");
+                    },
+                    (ParseState::Clear,
+                     ProfileQueriesMsg::TimeEnd) => {
+                        let provider_extent = frame.traces;
+                        match stack.pop() {
+                            None =>
+                                panic!("parse error: expected a stack frame; found an empty stack"),
+                            Some(old_frame) => {
+                                match old_frame.parse_st {
+                                    ParseState::HaveTimeBegin(msg, start) => {
+                                        let duration = start.elapsed();
+                                        frame = StackFrame{
+                                            parse_st: ParseState::Clear,
+                                            traces: old_frame.traces
+                                        };
+                                        let dur_extent = total_duration(&provider_extent);
+                                        let trace = Rec {
+                                            effect: Effect::TimeBegin(msg),
+                                            extent: Box::new(provider_extent),
+                                            start: start,
+                                            dur_total: duration,
+                                            dur_self: duration - dur_extent,
+                                        };
+                                        frame.traces.push( trace );
+                                    },
+                                    _ => panic!("internal parse error: malformed parse stack")
+                                }
+                            }
+                        }
+                    },
+                    (_, ProfileQueriesMsg::TimeEnd) => {
+                        panic!("parse error")
+                    },
+                    (ParseState::Clear,
+                     ProfileQueriesMsg::TaskBegin(key)) => {
+                        let start = Instant::now();
+                        frame.parse_st = ParseState::HaveTaskBegin(key, start);
+                        stack.push(frame);
+                        frame = StackFrame{ parse_st: ParseState::Clear, traces: vec![] };
+                    },
+                    (_, ProfileQueriesMsg::TaskBegin(_)) => {
+                        panic!("parse error; did not expect time begin here");
+                    },
+                    (ParseState::Clear,
+                     ProfileQueriesMsg::TaskEnd) => {
+                        let provider_extent = frame.traces;
+                        match stack.pop() {
+                            None =>
+                                panic!("parse error: expected a stack frame; found an empty stack"),
+                            Some(old_frame) => {
+                                match old_frame.parse_st {
+                                    ParseState::HaveTaskBegin(key, start) => {
+                                        let duration = start.elapsed();
+                                        frame = StackFrame{
+                                            parse_st: ParseState::Clear,
+                                            traces: old_frame.traces
+                                        };
+                                        let dur_extent = total_duration(&provider_extent);
+                                        let trace = Rec {
+                                            effect: Effect::TaskBegin(key),
+                                            extent: Box::new(provider_extent),
+                                            start: start,
+                                            dur_total: duration,
+                                            dur_self: duration - dur_extent,
+                                        };
+                                        frame.traces.push( trace );
+                                    },
+                                    _ => panic!("internal parse error: malformed parse stack")
+                                }
+                            }
+                        }
+                    },
+                    (_, ProfileQueriesMsg::TaskEnd) => {
+                        panic!("parse error")
+                    },
+                    // Parse State: HaveQuery
+                    (ParseState::HaveQuery(q,start),
+                     ProfileQueriesMsg::CacheHit) => {
+                        let duration = start.elapsed();
+                        let trace : Rec = Rec{
+                            effect: Effect::QueryBegin(q, CacheCase::Hit),
+                            extent: Box::new(vec![]),
+                            start: start,
+                            dur_self: duration,
+                            dur_total: duration,
+                        };
+                        frame.traces.push( trace );
+                        frame.parse_st = ParseState::Clear;
+                    },
+                    (ParseState::HaveQuery(_, _),
+                     ProfileQueriesMsg::ProviderBegin) => {
+                        stack.push(frame);
+                        frame = StackFrame{ parse_st: ParseState::Clear, traces: vec![] };
+                    },
+
+                    // Parse errors:
+
+                    (ParseState::HaveQuery(q, _),
+                     ProfileQueriesMsg::ProviderEnd) => {
+                        panic!("parse error: unexpected ProviderEnd; \
+                                expected something else to follow BeginQuery for {:?}", q)
+                    },
+                    (ParseState::HaveQuery(q1, _),
+                     ProfileQueriesMsg::QueryBegin(span2, querymsg2)) => {
+                        panic!("parse error: unexpected QueryBegin; \
+                                earlier query is unfinished: {:?} and now {:?}",
+                               q1, Query{span:span2, msg: querymsg2})
+                    },
+                    (ParseState::HaveTimeBegin(_, _), _) => {
+                        unreachable!()
+                    },
+                    (ParseState::HaveTaskBegin(_, _), _) => {
+                        unreachable!()
+                    },
+                }
+            }
+        }
+    }
+}
diff --git a/src/librustc_interface/profile/trace.rs b/src/librustc_interface/profile/trace.rs
new file mode 100644 (file)
index 0000000..95c4ea6
--- /dev/null
@@ -0,0 +1,304 @@
+use super::*;
+use syntax_pos::SpanData;
+use rustc_data_structures::fx::FxHashMap;
+use rustc::util::common::QueryMsg;
+use std::fs::File;
+use std::time::{Duration, Instant};
+use rustc::dep_graph::{DepNode};
+
+#[derive(Debug, Clone, Eq, PartialEq)]
+pub struct Query {
+    pub span: SpanData,
+    pub msg: QueryMsg,
+}
+pub enum Effect {
+    QueryBegin(Query, CacheCase),
+    TimeBegin(String),
+    TaskBegin(DepNode),
+}
+pub enum CacheCase {
+    Hit, Miss
+}
+/// Recursive trace structure
+pub struct Rec {
+    pub effect: Effect,
+    pub start: Instant,
+    pub dur_self: Duration,
+    pub dur_total: Duration,
+    pub extent: Box<Vec<Rec>>,
+}
+pub struct QueryMetric {
+    pub count: usize,
+    pub dur_self: Duration,
+    pub dur_total: Duration,
+}
+
+fn cons(s: &str) -> String {
+    let first = s.split(|d| d == '(' || d == '{').next();
+    assert!(first.is_some() && first != Some(""));
+    first.unwrap().to_owned()
+}
+
+pub fn cons_of_query_msg(q: &trace::Query) -> String {
+    cons(&format!("{:?}", q.msg))
+}
+
+pub fn cons_of_key(k: &DepNode) -> String {
+    cons(&format!("{:?}", k))
+}
+
+// First return value is text; second return value is a CSS class
+pub fn html_of_effect(eff: &Effect) -> (String, String) {
+    match *eff {
+        Effect::TimeBegin(ref msg) => {
+            (msg.clone(),
+             "time-begin".to_string())
+        },
+        Effect::TaskBegin(ref key) => {
+            let cons = cons_of_key(key);
+            (cons.clone(), format!("{} task-begin", cons))
+        },
+        Effect::QueryBegin(ref qmsg, ref cc) => {
+            let cons = cons_of_query_msg(qmsg);
+            (cons.clone(),
+             format!("{} {}",
+                     cons,
+                     match *cc {
+                         CacheCase::Hit => "hit",
+                         CacheCase::Miss => "miss",
+                     }))
+        }
+    }
+}
+
+// First return value is text; second return value is a CSS class
+fn html_of_duration(_start: &Instant, dur: &Duration) -> (String, String) {
+    use rustc::util::common::duration_to_secs_str;
+    (duration_to_secs_str(dur.clone()), String::new())
+}
+
+fn html_of_fraction(frac: f64) -> (String, &'static str) {
+    let css = {
+        if       frac > 0.50  { "frac-50" }
+        else if  frac > 0.40  { "frac-40" }
+        else if  frac > 0.30  { "frac-30" }
+        else if  frac > 0.20  { "frac-20" }
+        else if  frac > 0.10  { "frac-10" }
+        else if  frac > 0.05  { "frac-05" }
+        else if  frac > 0.02  { "frac-02" }
+        else if  frac > 0.01  { "frac-01" }
+        else if  frac > 0.001 { "frac-001" }
+        else                  { "frac-0" }
+    };
+    let percent = frac * 100.0;
+
+    if percent > 0.1 {
+        (format!("{:.1}%", percent), css)
+    } else {
+        ("< 0.1%".to_string(), css)
+    }
+}
+
+fn total_duration(traces: &[Rec]) -> Duration {
+    Duration::new(0, 0) + traces.iter().map(|t| t.dur_total).sum()
+}
+
+fn duration_div(nom: Duration, den: Duration) -> f64 {
+    fn to_nanos(d: Duration) -> u64 {
+        d.as_secs() * 1_000_000_000 + d.subsec_nanos() as u64
+    }
+
+    to_nanos(nom) as f64 / to_nanos(den) as f64
+}
+
+fn write_traces_rec(file: &mut File, traces: &[Rec], total: Duration, depth: usize) {
+    for t in traces {
+        let (eff_text, eff_css_classes) = html_of_effect(&t.effect);
+        let (dur_text, dur_css_classes) = html_of_duration(&t.start, &t.dur_total);
+        let fraction = duration_div(t.dur_total, total);
+        let percent = fraction * 100.0;
+        let (frc_text, frc_css_classes) = html_of_fraction(fraction);
+        writeln!(file, "<div class=\"trace depth-{} extent-{}{} {} {} {}\">",
+                 depth,
+                 t.extent.len(),
+                 /* Heuristic for 'important' CSS class: */
+                 if t.extent.len() > 5 || percent >= 1.0 { " important" } else { "" },
+                 eff_css_classes,
+                 dur_css_classes,
+                 frc_css_classes,
+        ).unwrap();
+        writeln!(file, "<div class=\"eff\">{}</div>", eff_text).unwrap();
+        writeln!(file, "<div class=\"dur\">{}</div>", dur_text).unwrap();
+        writeln!(file, "<div class=\"frc\">{}</div>", frc_text).unwrap();
+        write_traces_rec(file, &t.extent, total, depth + 1);
+        writeln!(file, "</div>").unwrap();
+    }
+}
+
+fn compute_counts_rec(counts: &mut FxHashMap<String,QueryMetric>, traces: &[Rec]) {
+    counts.reserve(traces.len());
+    for t in traces.iter() {
+        match t.effect {
+            Effect::TimeBegin(ref msg) => {
+                let qm = match counts.get(msg) {
+                    Some(_qm) => panic!("TimeBegin with non-unique, repeat message"),
+                    None => QueryMetric {
+                        count: 1,
+                        dur_self: t.dur_self,
+                        dur_total: t.dur_total,
+                    }
+                };
+                counts.insert(msg.clone(), qm);
+            },
+            Effect::TaskBegin(ref key) => {
+                let cons = cons_of_key(key);
+                let qm = match counts.get(&cons) {
+                    Some(qm) =>
+                        QueryMetric {
+                            count: qm.count + 1,
+                            dur_self: qm.dur_self + t.dur_self,
+                            dur_total: qm.dur_total + t.dur_total,
+                        },
+                    None => QueryMetric {
+                        count: 1,
+                        dur_self: t.dur_self,
+                        dur_total: t.dur_total,
+                    }
+                };
+                counts.insert(cons, qm);
+            },
+            Effect::QueryBegin(ref qmsg, ref _cc) => {
+                let qcons = cons_of_query_msg(qmsg);
+                let qm = match counts.get(&qcons) {
+                    Some(qm) =>
+                        QueryMetric {
+                            count: qm.count + 1,
+                            dur_total: qm.dur_total + t.dur_total,
+                            dur_self: qm.dur_self + t.dur_self
+                        },
+                    None => QueryMetric {
+                        count: 1,
+                        dur_total: t.dur_total,
+                        dur_self: t.dur_self,
+                    }
+                };
+                counts.insert(qcons, qm);
+            }
+        }
+        compute_counts_rec(counts, &t.extent)
+    }
+}
+
+pub fn write_counts(count_file: &mut File, counts: &mut FxHashMap<String, QueryMetric>) {
+    use rustc::util::common::duration_to_secs_str;
+    use std::cmp::Reverse;
+
+    let mut data = counts.iter().map(|(ref cons, ref qm)|
+        (cons.clone(), qm.count.clone(), qm.dur_total.clone(), qm.dur_self.clone())
+    ).collect::<Vec<_>>();
+
+    data.sort_by_key(|k| Reverse(k.3));
+    for (cons, count, dur_total, dur_self) in data {
+        writeln!(count_file, "{}, {}, {}, {}",
+                 cons, count,
+                 duration_to_secs_str(dur_total),
+                 duration_to_secs_str(dur_self)
+        ).unwrap();
+    }
+}
+
+pub fn write_traces(html_file: &mut File, counts_file: &mut File, traces: &[Rec]) {
+    let capacity = traces.iter().fold(0, |acc, t| acc + 1 + t.extent.len());
+    let mut counts = FxHashMap::with_capacity_and_hasher(capacity, Default::default());
+    compute_counts_rec(&mut counts, traces);
+    write_counts(counts_file, &mut counts);
+
+    let total: Duration = total_duration(traces);
+    write_traces_rec(html_file, traces, total, 0)
+}
+
+pub fn write_style(html_file: &mut File) {
+    write!(html_file, "{}", "
+body {
+    font-family: sans-serif;
+    background: black;
+}
+.trace {
+    color: black;
+    display: inline-block;
+    border-style: solid;
+    border-color: red;
+    border-width: 1px;
+    border-radius: 5px;
+    padding: 0px;
+    margin: 1px;
+    font-size: 0px;
+}
+.task-begin {
+    border-width: 1px;
+    color: white;
+    border-color: #ff8;
+    font-size: 0px;
+}
+.miss {
+    border-color: red;
+    border-width: 1px;
+}
+.extent-0 {
+    padding: 2px;
+}
+.time-begin {
+    border-width: 4px;
+    font-size: 12px;
+    color: white;
+    border-color: #afa;
+}
+.important {
+    border-width: 3px;
+    font-size: 12px;
+    color: white;
+    border-color: #f77;
+}
+.hit {
+    padding: 0px;
+    border-color: blue;
+    border-width: 3px;
+}
+.eff {
+  color: #fff;
+  display: inline-block;
+}
+.frc {
+  color: #7f7;
+  display: inline-block;
+}
+.dur {
+  display: none
+}
+.frac-50 {
+  padding: 10px;
+  border-width: 10px;
+  font-size: 32px;
+}
+.frac-40 {
+  padding: 8px;
+  border-width: 8px;
+  font-size: 24px;
+}
+.frac-30 {
+  padding: 6px;
+  border-width: 6px;
+  font-size: 18px;
+}
+.frac-20 {
+  padding: 4px;
+  border-width: 6px;
+  font-size: 16px;
+}
+.frac-10 {
+  padding: 2px;
+  border-width: 6px;
+  font-size: 14px;
+}
+").unwrap();
+}
diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs
new file mode 100644 (file)
index 0000000..6f92c30
--- /dev/null
@@ -0,0 +1,702 @@
+use rustc::session::config::{Input, OutputFilenames, ErrorOutputType};
+use rustc::session::{self, config, early_error, filesearch, Session, DiagnosticOutput};
+use rustc::session::CrateDisambiguator;
+use rustc::ty;
+use rustc::lint;
+use rustc_codegen_utils::codegen_backend::CodegenBackend;
+use rustc_data_structures::sync::{Lock, Lrc};
+use rustc_data_structures::stable_hasher::StableHasher;
+use rustc_data_structures::fingerprint::Fingerprint;
+use rustc_data_structures::thin_vec::ThinVec;
+use rustc_data_structures::fx::{FxHashSet, FxHashMap};
+use rustc_errors::registry::Registry;
+use rustc_lint;
+use rustc_metadata::dynamic_lib::DynamicLibrary;
+use rustc_mir;
+use rustc_passes;
+use rustc_plugin;
+use rustc_privacy;
+use rustc_resolve;
+use rustc_typeck;
+use std::collections::HashSet;
+use std::env;
+use std::env::consts::{DLL_PREFIX, DLL_SUFFIX};
+use std::io::{self, Write};
+use std::mem;
+use std::path::{Path, PathBuf};
+use std::sync::atomic::{AtomicBool, Ordering};
+use std::sync::{Arc, Mutex, Once};
+use std::ops::DerefMut;
+use smallvec::SmallVec;
+use syntax::ptr::P;
+use syntax::mut_visit::{*, MutVisitor, visit_clobber};
+use syntax::ast::BlockCheckMode;
+use syntax::util::lev_distance::find_best_match_for_name;
+use syntax::source_map::{FileLoader, RealFileLoader, SourceMap};
+use syntax::symbol::Symbol;
+use syntax::{self, ast, attr};
+#[cfg(not(parallel_compiler))]
+use std::{thread, panic};
+
+pub fn diagnostics_registry() -> Registry {
+    let mut all_errors = Vec::new();
+    all_errors.extend_from_slice(&rustc::DIAGNOSTICS);
+    all_errors.extend_from_slice(&rustc_typeck::DIAGNOSTICS);
+    all_errors.extend_from_slice(&rustc_resolve::DIAGNOSTICS);
+    all_errors.extend_from_slice(&rustc_privacy::DIAGNOSTICS);
+    // FIXME: need to figure out a way to get these back in here
+    // all_errors.extend_from_slice(get_codegen_backend(sess).diagnostics());
+    all_errors.extend_from_slice(&rustc_metadata::DIAGNOSTICS);
+    all_errors.extend_from_slice(&rustc_passes::DIAGNOSTICS);
+    all_errors.extend_from_slice(&rustc_plugin::DIAGNOSTICS);
+    all_errors.extend_from_slice(&rustc_mir::DIAGNOSTICS);
+    all_errors.extend_from_slice(&syntax::DIAGNOSTICS);
+
+    Registry::new(&all_errors)
+}
+
+/// Adds `target_feature = "..."` cfgs for a variety of platform
+/// specific features (SSE, NEON etc.).
+///
+/// This is performed by checking whether a whitelisted set of
+/// features is available on the target machine, by querying LLVM.
+pub fn add_configuration(
+    cfg: &mut ast::CrateConfig,
+    sess: &Session,
+    codegen_backend: &dyn CodegenBackend,
+) {
+    let tf = Symbol::intern("target_feature");
+
+    cfg.extend(
+        codegen_backend
+            .target_features(sess)
+            .into_iter()
+            .map(|feat| (tf, Some(feat))),
+    );
+
+    if sess.crt_static_feature() {
+        cfg.insert((tf, Some(Symbol::intern("crt-static"))));
+    }
+}
+
+fn load_backend_from_dylib(path: &Path) -> fn() -> Box<dyn CodegenBackend> {
+    let lib = DynamicLibrary::open(Some(path)).unwrap_or_else(|err| {
+        let err = format!("couldn't load codegen backend {:?}: {:?}", path, err);
+        early_error(ErrorOutputType::default(), &err);
+    });
+    unsafe {
+        match lib.symbol("__rustc_codegen_backend") {
+            Ok(f) => {
+                mem::forget(lib);
+                mem::transmute::<*mut u8, _>(f)
+            }
+            Err(e) => {
+                let err = format!("couldn't load codegen backend as it \
+                                   doesn't export the `__rustc_codegen_backend` \
+                                   symbol: {:?}", e);
+                early_error(ErrorOutputType::default(), &err);
+            }
+        }
+    }
+}
+
+pub fn get_codegen_backend(sess: &Session) -> Box<dyn CodegenBackend> {
+    static INIT: Once = Once::new();
+
+    static mut LOAD: fn() -> Box<dyn CodegenBackend> = || unreachable!();
+
+    INIT.call_once(|| {
+        let codegen_name = sess.opts.debugging_opts.codegen_backend.as_ref()
+            .unwrap_or(&sess.target.target.options.codegen_backend);
+        let backend = match &codegen_name[..] {
+            "metadata_only" => {
+                rustc_codegen_utils::codegen_backend::MetadataOnlyCodegenBackend::boxed
+            }
+            filename if filename.contains(".") => {
+                load_backend_from_dylib(filename.as_ref())
+            }
+            codegen_name => get_codegen_sysroot(codegen_name),
+        };
+
+        unsafe {
+            LOAD = backend;
+        }
+    });
+    let backend = unsafe { LOAD() };
+    backend.init(sess);
+    backend
+}
+
+pub fn get_codegen_sysroot(backend_name: &str) -> fn() -> Box<dyn CodegenBackend> {
+    // For now we only allow this function to be called once as it'll dlopen a
+    // few things, which seems to work best if we only do that once. In
+    // general this assertion never trips due to the once guard in `get_codegen_backend`,
+    // but there's a few manual calls to this function in this file we protect
+    // against.
+    static LOADED: AtomicBool = AtomicBool::new(false);
+    assert!(!LOADED.fetch_or(true, Ordering::SeqCst),
+            "cannot load the default codegen backend twice");
+
+    let target = session::config::host_triple();
+    let mut sysroot_candidates = vec![filesearch::get_or_default_sysroot()];
+    let path = current_dll_path()
+        .and_then(|s| s.canonicalize().ok());
+    if let Some(dll) = path {
+        // use `parent` twice to chop off the file name and then also the
+        // directory containing the dll which should be either `lib` or `bin`.
+        if let Some(path) = dll.parent().and_then(|p| p.parent()) {
+            // The original `path` pointed at the `rustc_driver` crate's dll.
+            // Now that dll should only be in one of two locations. The first is
+            // in the compiler's libdir, for example `$sysroot/lib/*.dll`. The
+            // other is the target's libdir, for example
+            // `$sysroot/lib/rustlib/$target/lib/*.dll`.
+            //
+            // We don't know which, so let's assume that if our `path` above
+            // ends in `$target` we *could* be in the target libdir, and always
+            // assume that we may be in the main libdir.
+            sysroot_candidates.push(path.to_owned());
+
+            if path.ends_with(target) {
+                sysroot_candidates.extend(path.parent() // chop off `$target`
+                    .and_then(|p| p.parent())           // chop off `rustlib`
+                    .and_then(|p| p.parent())           // chop off `lib`
+                    .map(|s| s.to_owned()));
+            }
+        }
+    }
+
+    let sysroot = sysroot_candidates.iter()
+        .map(|sysroot| {
+            let libdir = filesearch::relative_target_lib_path(&sysroot, &target);
+            sysroot.join(libdir).with_file_name(
+                option_env!("CFG_CODEGEN_BACKENDS_DIR").unwrap_or("codegen-backends"))
+        })
+        .filter(|f| {
+            info!("codegen backend candidate: {}", f.display());
+            f.exists()
+        })
+        .next();
+    let sysroot = sysroot.unwrap_or_else(|| {
+        let candidates = sysroot_candidates.iter()
+            .map(|p| p.display().to_string())
+            .collect::<Vec<_>>()
+            .join("\n* ");
+        let err = format!("failed to find a `codegen-backends` folder \
+                           in the sysroot candidates:\n* {}", candidates);
+        early_error(ErrorOutputType::default(), &err);
+    });
+    info!("probing {} for a codegen backend", sysroot.display());
+
+    let d = sysroot.read_dir().unwrap_or_else(|e| {
+        let err = format!("failed to load default codegen backend, couldn't \
+                           read `{}`: {}", sysroot.display(), e);
+        early_error(ErrorOutputType::default(), &err);
+    });
+
+    let mut file: Option<PathBuf> = None;
+
+    let expected_name = format!("rustc_codegen_llvm-{}", backend_name);
+    for entry in d.filter_map(|e| e.ok()) {
+        let path = entry.path();
+        let filename = match path.file_name().and_then(|s| s.to_str()) {
+            Some(s) => s,
+            None => continue,
+        };
+        if !(filename.starts_with(DLL_PREFIX) && filename.ends_with(DLL_SUFFIX)) {
+            continue
+        }
+        let name = &filename[DLL_PREFIX.len() .. filename.len() - DLL_SUFFIX.len()];
+        if name != expected_name {
+            continue
+        }
+        if let Some(ref prev) = file {
+            let err = format!("duplicate codegen backends found\n\
+                               first:  {}\n\
+                               second: {}\n\
+            ", prev.display(), path.display());
+            early_error(ErrorOutputType::default(), &err);
+        }
+        file = Some(path.clone());
+    }
+
+    match file {
+        Some(ref s) => return load_backend_from_dylib(s),
+        None => {
+            let err = format!("failed to load default codegen backend for `{}`, \
+                               no appropriate codegen dylib found in `{}`",
+                              backend_name, sysroot.display());
+            early_error(ErrorOutputType::default(), &err);
+        }
+    }
+
+    #[cfg(unix)]
+    fn current_dll_path() -> Option<PathBuf> {
+        use std::ffi::{OsStr, CStr};
+        use std::os::unix::prelude::*;
+
+        unsafe {
+            let addr = current_dll_path as usize as *mut _;
+            let mut info = mem::zeroed();
+            if libc::dladdr(addr, &mut info) == 0 {
+                info!("dladdr failed");
+                return None
+            }
+            if info.dli_fname.is_null() {
+                info!("dladdr returned null pointer");
+                return None
+            }
+            let bytes = CStr::from_ptr(info.dli_fname).to_bytes();
+            let os = OsStr::from_bytes(bytes);
+            Some(PathBuf::from(os))
+        }
+    }
+
+    #[cfg(windows)]
+    fn current_dll_path() -> Option<PathBuf> {
+        use std::ffi::OsString;
+        use std::os::windows::prelude::*;
+
+        extern "system" {
+            fn GetModuleHandleExW(dwFlags: u32,
+                                  lpModuleName: usize,
+                                  phModule: *mut usize) -> i32;
+            fn GetModuleFileNameW(hModule: usize,
+                                  lpFilename: *mut u16,
+                                  nSize: u32) -> u32;
+        }
+
+        const GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS: u32 = 0x00000004;
+
+        unsafe {
+            let mut module = 0;
+            let r = GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
+                                       current_dll_path as usize,
+                                       &mut module);
+            if r == 0 {
+                info!("GetModuleHandleExW failed: {}", io::Error::last_os_error());
+                return None
+            }
+            let mut space = Vec::with_capacity(1024);
+            let r = GetModuleFileNameW(module,
+                                       space.as_mut_ptr(),
+                                       space.capacity() as u32);
+            if r == 0 {
+                info!("GetModuleFileNameW failed: {}", io::Error::last_os_error());
+                return None
+            }
+            let r = r as usize;
+            if r >= space.capacity() {
+                info!("our buffer was too small? {}",
+                      io::Error::last_os_error());
+                return None
+            }
+            space.set_len(r);
+            let os = OsString::from_wide(&space);
+            Some(PathBuf::from(os))
+        }
+    }
+}
+
+pub fn compute_crate_disambiguator(session: &Session) -> CrateDisambiguator {
+    use std::hash::Hasher;
+
+    // The crate_disambiguator is a 128 bit hash. The disambiguator is fed
+    // into various other hashes quite a bit (symbol hashes, incr. comp. hashes,
+    // debuginfo type IDs, etc), so we don't want it to be too wide. 128 bits
+    // should still be safe enough to avoid collisions in practice.
+    let mut hasher = StableHasher::<Fingerprint>::new();
+
+    let mut metadata = session.opts.cg.metadata.clone();
+    // We don't want the crate_disambiguator to dependent on the order
+    // -C metadata arguments, so sort them:
+    metadata.sort();
+    // Every distinct -C metadata value is only incorporated once:
+    metadata.dedup();
+
+    hasher.write(b"metadata");
+    for s in &metadata {
+        // Also incorporate the length of a metadata string, so that we generate
+        // different values for `-Cmetadata=ab -Cmetadata=c` and
+        // `-Cmetadata=a -Cmetadata=bc`
+        hasher.write_usize(s.len());
+        hasher.write(s.as_bytes());
+    }
+
+    // Also incorporate crate type, so that we don't get symbol conflicts when
+    // linking against a library of the same name, if this is an executable.
+    let is_exe = session
+        .crate_types
+        .borrow()
+        .contains(&config::CrateType::Executable);
+    hasher.write(if is_exe { b"exe" } else { b"lib" });
+
+    CrateDisambiguator::from(hasher.finish())
+}
+
+pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<config::CrateType> {
+    // Unconditionally collect crate types from attributes to make them used
+    let attr_types: Vec<config::CrateType> = attrs
+        .iter()
+        .filter_map(|a| {
+            if a.check_name("crate_type") {
+                match a.value_str() {
+                    Some(ref n) if *n == "rlib" => Some(config::CrateType::Rlib),
+                    Some(ref n) if *n == "dylib" => Some(config::CrateType::Dylib),
+                    Some(ref n) if *n == "cdylib" => Some(config::CrateType::Cdylib),
+                    Some(ref n) if *n == "lib" => Some(config::default_lib_output()),
+                    Some(ref n) if *n == "staticlib" => Some(config::CrateType::Staticlib),
+                    Some(ref n) if *n == "proc-macro" => Some(config::CrateType::ProcMacro),
+                    Some(ref n) if *n == "bin" => Some(config::CrateType::Executable),
+                    Some(ref n) => {
+                        let crate_types = vec![
+                            Symbol::intern("rlib"),
+                            Symbol::intern("dylib"),
+                            Symbol::intern("cdylib"),
+                            Symbol::intern("lib"),
+                            Symbol::intern("staticlib"),
+                            Symbol::intern("proc-macro"),
+                            Symbol::intern("bin")
+                        ];
+
+                        if let ast::MetaItemKind::NameValue(spanned) = a.meta().unwrap().node {
+                            let span = spanned.span;
+                            let lev_candidate = find_best_match_for_name(
+                                crate_types.iter(),
+                                &n.as_str(),
+                                None
+                            );
+                            if let Some(candidate) = lev_candidate {
+                                session.buffer_lint_with_diagnostic(
+                                    lint::builtin::UNKNOWN_CRATE_TYPES,
+                                    ast::CRATE_NODE_ID,
+                                    span,
+                                    "invalid `crate_type` value",
+                                    lint::builtin::BuiltinLintDiagnostics::
+                                        UnknownCrateTypes(
+                                            span,
+                                            "did you mean".to_string(),
+                                            format!("\"{}\"", candidate)
+                                        )
+                                );
+                            } else {
+                                session.buffer_lint(
+                                    lint::builtin::UNKNOWN_CRATE_TYPES,
+                                    ast::CRATE_NODE_ID,
+                                    span,
+                                    "invalid `crate_type` value"
+                                );
+                            }
+                        }
+                        None
+                    }
+                    None => None
+                }
+            } else {
+                None
+            }
+        })
+        .collect();
+
+    // If we're generating a test executable, then ignore all other output
+    // styles at all other locations
+    if session.opts.test {
+        return vec![config::CrateType::Executable];
+    }
+
+    // Only check command line flags if present. If no types are specified by
+    // command line, then reuse the empty `base` Vec to hold the types that
+    // will be found in crate attributes.
+    let mut base = session.opts.crate_types.clone();
+    if base.is_empty() {
+        base.extend(attr_types);
+        if base.is_empty() {
+            base.push(::rustc_codegen_utils::link::default_output_for_target(
+                session,
+            ));
+        } else {
+            base.sort();
+            base.dedup();
+        }
+    }
+
+    base.retain(|crate_type| {
+        let res = !::rustc_codegen_utils::link::invalid_output_for_target(session, *crate_type);
+
+        if !res {
+            session.warn(&format!(
+                "dropping unsupported crate type `{}` for target `{}`",
+                *crate_type, session.opts.target_triple
+            ));
+        }
+
+        res
+    });
+
+    base
+}
+
+pub fn build_output_filenames(
+    input: &Input,
+    odir: &Option<PathBuf>,
+    ofile: &Option<PathBuf>,
+    attrs: &[ast::Attribute],
+    sess: &Session,
+) -> OutputFilenames {
+    match *ofile {
+        None => {
+            // "-" as input file will cause the parser to read from stdin so we
+            // have to make up a name
+            // We want to toss everything after the final '.'
+            let dirpath = (*odir).as_ref().cloned().unwrap_or_default();
+
+            // If a crate name is present, we use it as the link name
+            let stem = sess.opts
+                .crate_name
+                .clone()
+                .or_else(|| attr::find_crate_name(attrs).map(|n| n.to_string()))
+                .unwrap_or_else(|| input.filestem().to_owned());
+
+            OutputFilenames {
+                out_directory: dirpath,
+                out_filestem: stem,
+                single_output_file: None,
+                extra: sess.opts.cg.extra_filename.clone(),
+                outputs: sess.opts.output_types.clone(),
+            }
+        }
+
+        Some(ref out_file) => {
+            let unnamed_output_types = sess.opts
+                .output_types
+                .values()
+                .filter(|a| a.is_none())
+                .count();
+            let ofile = if unnamed_output_types > 1 {
+                sess.warn(
+                    "due to multiple output types requested, the explicitly specified \
+                     output file name will be adapted for each output type",
+                );
+                None
+            } else {
+                Some(out_file.clone())
+            };
+            if *odir != None {
+                sess.warn("ignoring --out-dir flag due to -o flag");
+            }
+            if !sess.opts.cg.extra_filename.is_empty() {
+                sess.warn("ignoring -C extra-filename flag due to -o flag");
+            }
+
+            OutputFilenames {
+                out_directory: out_file.parent().unwrap_or_else(|| Path::new("")).to_path_buf(),
+                out_filestem: out_file
+                    .file_stem()
+                    .unwrap_or_default()
+                    .to_str()
+                    .unwrap()
+                    .to_string(),
+                single_output_file: ofile,
+                extra: sess.opts.cg.extra_filename.clone(),
+                outputs: sess.opts.output_types.clone(),
+            }
+        }
+    }
+}
+
+// Note: Also used by librustdoc, see PR #43348. Consider moving this struct elsewhere.
+//
+// FIXME: Currently the `everybody_loops` transformation is not applied to:
+//  * `const fn`, due to issue #43636 that `loop` is not supported for const evaluation. We are
+//    waiting for miri to fix that.
+//  * `impl Trait`, due to issue #43869 that functions returning impl Trait cannot be diverging.
+//    Solving this may require `!` to implement every trait, which relies on the an even more
+//    ambitious form of the closed RFC #1637. See also [#34511].
+//
+// [#34511]: https://github.com/rust-lang/rust/issues/34511#issuecomment-322340401
+pub struct ReplaceBodyWithLoop<'a> {
+    within_static_or_const: bool,
+    nested_blocks: Option<Vec<ast::Block>>,
+    sess: &'a Session,
+}
+
+impl<'a> ReplaceBodyWithLoop<'a> {
+    pub fn new(sess: &'a Session) -> ReplaceBodyWithLoop<'a> {
+        ReplaceBodyWithLoop {
+            within_static_or_const: false,
+            nested_blocks: None,
+            sess
+        }
+    }
+
+    fn run<R, F: FnOnce(&mut Self) -> R>(&mut self, is_const: bool, action: F) -> R {
+        let old_const = mem::replace(&mut self.within_static_or_const, is_const);
+        let old_blocks = self.nested_blocks.take();
+        let ret = action(self);
+        self.within_static_or_const = old_const;
+        self.nested_blocks = old_blocks;
+        ret
+    }
+
+    fn should_ignore_fn(ret_ty: &ast::FnDecl) -> bool {
+        if let ast::FunctionRetTy::Ty(ref ty) = ret_ty.output {
+            fn involves_impl_trait(ty: &ast::Ty) -> bool {
+                match ty.node {
+                    ast::TyKind::ImplTrait(..) => true,
+                    ast::TyKind::Slice(ref subty) |
+                    ast::TyKind::Array(ref subty, _) |
+                    ast::TyKind::Ptr(ast::MutTy { ty: ref subty, .. }) |
+                    ast::TyKind::Rptr(_, ast::MutTy { ty: ref subty, .. }) |
+                    ast::TyKind::Paren(ref subty) => involves_impl_trait(subty),
+                    ast::TyKind::Tup(ref tys) => any_involves_impl_trait(tys.iter()),
+                    ast::TyKind::Path(_, ref path) => path.segments.iter().any(|seg| {
+                        match seg.args.as_ref().map(|generic_arg| &**generic_arg) {
+                            None => false,
+                            Some(&ast::GenericArgs::AngleBracketed(ref data)) => {
+                                let types = data.args.iter().filter_map(|arg| match arg {
+                                    ast::GenericArg::Type(ty) => Some(ty),
+                                    _ => None,
+                                });
+                                any_involves_impl_trait(types.into_iter()) ||
+                                any_involves_impl_trait(data.bindings.iter().map(|b| &b.ty))
+                            },
+                            Some(&ast::GenericArgs::Parenthesized(ref data)) => {
+                                any_involves_impl_trait(data.inputs.iter()) ||
+                                any_involves_impl_trait(data.output.iter())
+                            }
+                        }
+                    }),
+                    _ => false,
+                }
+            }
+
+            fn any_involves_impl_trait<'a, I: Iterator<Item = &'a P<ast::Ty>>>(mut it: I) -> bool {
+                it.any(|subty| involves_impl_trait(subty))
+            }
+
+            involves_impl_trait(ty)
+        } else {
+            false
+        }
+    }
+}
+
+impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> {
+    fn visit_item_kind(&mut self, i: &mut ast::ItemKind) {
+        let is_const = match i {
+            ast::ItemKind::Static(..) | ast::ItemKind::Const(..) => true,
+            ast::ItemKind::Fn(ref decl, ref header, _, _) =>
+                header.constness.node == ast::Constness::Const || Self::should_ignore_fn(decl),
+            _ => false,
+        };
+        self.run(is_const, |s| noop_visit_item_kind(i, s))
+    }
+
+    fn flat_map_trait_item(&mut self, i: ast::TraitItem) -> SmallVec<[ast::TraitItem; 1]> {
+        let is_const = match i.node {
+            ast::TraitItemKind::Const(..) => true,
+            ast::TraitItemKind::Method(ast::MethodSig { ref decl, ref header, .. }, _) =>
+                header.constness.node == ast::Constness::Const || Self::should_ignore_fn(decl),
+            _ => false,
+        };
+        self.run(is_const, |s| noop_flat_map_trait_item(i, s))
+    }
+
+    fn flat_map_impl_item(&mut self, i: ast::ImplItem) -> SmallVec<[ast::ImplItem; 1]> {
+        let is_const = match i.node {
+            ast::ImplItemKind::Const(..) => true,
+            ast::ImplItemKind::Method(ast::MethodSig { ref decl, ref header, .. }, _) =>
+                header.constness.node == ast::Constness::Const || Self::should_ignore_fn(decl),
+            _ => false,
+        };
+        self.run(is_const, |s| noop_flat_map_impl_item(i, s))
+    }
+
+    fn visit_anon_const(&mut self, c: &mut ast::AnonConst) {
+        self.run(true, |s| noop_visit_anon_const(c, s))
+    }
+
+    fn visit_block(&mut self, b: &mut P<ast::Block>) {
+        fn stmt_to_block(rules: ast::BlockCheckMode,
+                         s: Option<ast::Stmt>,
+                         sess: &Session) -> ast::Block {
+            ast::Block {
+                stmts: s.into_iter().collect(),
+                rules,
+                id: sess.next_node_id(),
+                span: syntax_pos::DUMMY_SP,
+            }
+        }
+
+        fn block_to_stmt(b: ast::Block, sess: &Session) -> ast::Stmt {
+            let expr = P(ast::Expr {
+                id: sess.next_node_id(),
+                node: ast::ExprKind::Block(P(b), None),
+                span: syntax_pos::DUMMY_SP,
+                attrs: ThinVec::new(),
+            });
+
+            ast::Stmt {
+                id: sess.next_node_id(),
+                node: ast::StmtKind::Expr(expr),
+                span: syntax_pos::DUMMY_SP,
+            }
+        }
+
+        let empty_block = stmt_to_block(BlockCheckMode::Default, None, self.sess);
+        let loop_expr = P(ast::Expr {
+            node: ast::ExprKind::Loop(P(empty_block), None),
+            id: self.sess.next_node_id(),
+            span: syntax_pos::DUMMY_SP,
+                attrs: ThinVec::new(),
+        });
+
+        let loop_stmt = ast::Stmt {
+            id: self.sess.next_node_id(),
+            span: syntax_pos::DUMMY_SP,
+            node: ast::StmtKind::Expr(loop_expr),
+        };
+
+        if self.within_static_or_const {
+            noop_visit_block(b, self)
+        } else {
+            visit_clobber(b.deref_mut(), |b| {
+                let mut stmts = vec![];
+                for s in b.stmts {
+                    let old_blocks = self.nested_blocks.replace(vec![]);
+
+                    stmts.extend(self.flat_map_stmt(s).into_iter().filter(|s| s.is_item()));
+
+                    // we put a Some in there earlier with that replace(), so this is valid
+                    let new_blocks = self.nested_blocks.take().unwrap();
+                    self.nested_blocks = old_blocks;
+                    stmts.extend(new_blocks.into_iter().map(|b| block_to_stmt(b, &self.sess)));
+                }
+
+                let mut new_block = ast::Block {
+                    stmts,
+                    ..b
+                };
+
+                if let Some(old_blocks) = self.nested_blocks.as_mut() {
+                    //push our fresh block onto the cache and yield an empty block with `loop {}`
+                    if !new_block.stmts.is_empty() {
+                        old_blocks.push(new_block);
+                    }
+
+                    stmt_to_block(b.rules, Some(loop_stmt), self.sess)
+                } else {
+                    //push `loop {}` onto the end of our fresh block and yield that
+                    new_block.stmts.push(loop_stmt);
+
+                    new_block
+                }
+            })
+        }
+    }
+
+    // in general the pretty printer processes unexpanded code, so
+    // we override the default `visit_mac` method which panics.
+    fn visit_mac(&mut self, mac: &mut ast::Mac) {
+        noop_visit_mac(mac, self)
+    }
+}
index ac10b6403bd132e6a7d30c08350cb3b2fc8cb454..4d484a64f47df3fc9df1e44490f4e800582b700d 100644 (file)
@@ -324,7 +324,7 @@ pub struct MissingDoc {
     doc_hidden_stack: Vec<bool>,
 
     /// Private traits or trait items that leaked through. Don't check their methods.
-    private_traits: FxHashSet<ast::NodeId>,
+    private_traits: FxHashSet<hir::HirId>,
 }
 
 fn has_doc(attr: &ast::Attribute) -> bool {
@@ -361,7 +361,7 @@ fn doc_hidden(&self) -> bool {
 
     fn check_missing_docs_attrs(&self,
                                 cx: &LateContext<'_, '_>,
-                                id: Option<ast::NodeId>,
+                                id: Option<hir::HirId>,
                                 attrs: &[ast::Attribute],
                                 sp: Span,
                                 desc: &'static str) {
@@ -380,7 +380,8 @@ fn check_missing_docs_attrs(&self,
         // It's an option so the crate root can also use this function (it doesn't
         // have a NodeId).
         if let Some(id) = id {
-            if !cx.access_levels.is_exported(id) {
+            let node_id = cx.tcx.hir().hir_to_node_id(id);
+            if !cx.access_levels.is_exported(node_id) {
                 return;
             }
         }
@@ -444,9 +445,10 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
             hir::ItemKind::Trait(.., ref trait_item_refs) => {
                 // Issue #11592, traits are always considered exported, even when private.
                 if let hir::VisibilityKind::Inherited = it.vis.node {
-                    self.private_traits.insert(it.id);
+                    self.private_traits.insert(it.hir_id);
                     for trait_item_ref in trait_item_refs {
-                        self.private_traits.insert(trait_item_ref.id.node_id);
+                        let hir_id = cx.tcx.hir().node_to_hir_id(trait_item_ref.id.node_id);
+                        self.private_traits.insert(hir_id);
                     }
                     return;
                 }
@@ -462,7 +464,9 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
                         Some(Node::Item(item)) => {
                             if let hir::VisibilityKind::Inherited = item.vis.node {
                                 for impl_item_ref in impl_item_refs {
-                                    self.private_traits.insert(impl_item_ref.id.node_id);
+                                    let hir_id = cx.tcx.hir().node_to_hir_id(
+                                        impl_item_ref.id.node_id);
+                                    self.private_traits.insert(hir_id);
                                 }
                             }
                         }
@@ -476,11 +480,11 @@ fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
             _ => return,
         };
 
-        self.check_missing_docs_attrs(cx, Some(it.id), &it.attrs, it.span, desc);
+        self.check_missing_docs_attrs(cx, Some(it.hir_id), &it.attrs, it.span, desc);
     }
 
     fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, trait_item: &hir::TraitItem) {
-        if self.private_traits.contains(&trait_item.id) {
+        if self.private_traits.contains(&trait_item.hir_id) {
             return;
         }
 
@@ -491,7 +495,7 @@ fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, trait_item: &hir::Trait
         };
 
         self.check_missing_docs_attrs(cx,
-                                      Some(trait_item.id),
+                                      Some(trait_item.hir_id),
                                       &trait_item.attrs,
                                       trait_item.span,
                                       desc);
@@ -510,7 +514,7 @@ fn check_impl_item(&mut self, cx: &LateContext<'_, '_>, impl_item: &hir::ImplIte
             hir::ImplItemKind::Existential(_) => "an associated existential type",
         };
         self.check_missing_docs_attrs(cx,
-                                      Some(impl_item.id),
+                                      Some(impl_item.hir_id),
                                       &impl_item.attrs,
                                       impl_item.span,
                                       desc);
@@ -519,7 +523,7 @@ fn check_impl_item(&mut self, cx: &LateContext<'_, '_>, impl_item: &hir::ImplIte
     fn check_struct_field(&mut self, cx: &LateContext<'_, '_>, sf: &hir::StructField) {
         if !sf.is_positional() {
             self.check_missing_docs_attrs(cx,
-                                          Some(sf.id),
+                                          Some(sf.hir_id),
                                           &sf.attrs,
                                           sf.span,
                                           "a struct field")
@@ -528,7 +532,7 @@ fn check_struct_field(&mut self, cx: &LateContext<'_, '_>, sf: &hir::StructField
 
     fn check_variant(&mut self, cx: &LateContext<'_, '_>, v: &hir::Variant, _: &hir::Generics) {
         self.check_missing_docs_attrs(cx,
-                                      Some(v.node.data.id()),
+                                      Some(v.node.data.hir_id()),
                                       &v.node.attrs,
                                       v.span,
                                       "a variant");
@@ -1108,11 +1112,12 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl UnreachablePub {
-    fn perform_lint(&self, cx: &LateContext<'_, '_>, what: &str, id: ast::NodeId,
+    fn perform_lint(&self, cx: &LateContext<'_, '_>, what: &str, id: hir::HirId,
                     vis: &hir::Visibility, span: Span, exportable: bool) {
         let mut applicability = Applicability::MachineApplicable;
+        let node_id = cx.tcx.hir().hir_to_node_id(id);
         match vis.node {
-            hir::VisibilityKind::Public if !cx.access_levels.is_reachable(id) => {
+            hir::VisibilityKind::Public if !cx.access_levels.is_reachable(node_id) => {
                 if span.ctxt().outer().expn_info().is_some() {
                     applicability = Applicability::MaybeIncorrect;
                 }
@@ -1144,20 +1149,20 @@ fn perform_lint(&self, cx: &LateContext<'_, '_>, what: &str, id: ast::NodeId,
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnreachablePub {
     fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) {
-        self.perform_lint(cx, "item", item.id, &item.vis, item.span, true);
+        self.perform_lint(cx, "item", item.hir_id, &item.vis, item.span, true);
     }
 
     fn check_foreign_item(&mut self, cx: &LateContext<'_, '_>, foreign_item: &hir::ForeignItem) {
-        self.perform_lint(cx, "item", foreign_item.id, &foreign_item.vis,
+        self.perform_lint(cx, "item", foreign_item.hir_id, &foreign_item.vis,
                           foreign_item.span, true);
     }
 
     fn check_struct_field(&mut self, cx: &LateContext<'_, '_>, field: &hir::StructField) {
-        self.perform_lint(cx, "field", field.id, &field.vis, field.span, false);
+        self.perform_lint(cx, "field", field.hir_id, &field.vis, field.span, false);
     }
 
     fn check_impl_item(&mut self, cx: &LateContext<'_, '_>, impl_item: &hir::ImplItem) {
-        self.perform_lint(cx, "item", impl_item.id, &impl_item.vis, impl_item.span, false);
+        self.perform_lint(cx, "item", impl_item.hir_id, &impl_item.vis, impl_item.span, false);
     }
 }
 
index b6fd6412349336f15f8ef3d92693219fba100a79..35489ab42e73038c056cea9f25597d1903155bca 100644 (file)
@@ -1,7 +1,7 @@
 #![allow(non_snake_case)]
 
 use rustc::hir::Node;
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::SubstsRef;
 use rustc::ty::{self, AdtKind, ParamEnv, Ty, TyCtxt};
 use rustc::ty::layout::{self, IntegerExt, LayoutOf, VariantIdx};
 use rustc::{lint, util};
@@ -445,7 +445,7 @@ enum FfiResult<'tcx> {
 /// FIXME: This duplicates code in codegen.
 fn is_repr_nullable_ptr<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                                   def: &'tcx ty::AdtDef,
-                                  substs: &Substs<'tcx>)
+                                  substs: SubstsRef<'tcx>)
                                   -> bool {
     if def.variants.len() == 2 {
         let data_idx;
@@ -766,8 +766,15 @@ fn check_foreign_fn(&mut self, id: ast::NodeId, decl: &hir::FnDecl) {
         let def_id = self.cx.tcx.hir().local_def_id(id);
         let sig = self.cx.tcx.fn_sig(def_id);
         let sig = self.cx.tcx.erase_late_bound_regions(&sig);
+        let inputs = if sig.c_variadic {
+            // Don't include the spoofed `VaList` in the functions list
+            // of inputs.
+            &sig.inputs()[..sig.inputs().len() - 1]
+        } else {
+            &sig.inputs()[..]
+        };
 
-        for (input_ty, input_hir) in sig.inputs().iter().zip(&decl.inputs) {
+        for (input_ty, input_hir) in inputs.iter().zip(&decl.inputs) {
             self.check_type_for_ffi_and_report_errors(input_hir.span, input_ty);
         }
 
index 5fdc5899a721ec3862365706ee6639c5fb3d7119..b4a71b887dc37a629fd73d5aa89218d160914c3e 100644 (file)
@@ -1667,7 +1667,7 @@ fn visit_variant(&mut self,
         intravisit::walk_variant(self, v, g, id);
 
         if let Some(ref discr) = v.node.disr_expr {
-            let def_id = self.index.tcx.hir().local_def_id(discr.id);
+            let def_id = self.index.tcx.hir().local_def_id_from_hir_id(discr.hir_id);
             self.index.record(def_id, IsolatedEncoder::encode_info_for_anon_const, def_id);
         }
     }
@@ -1719,7 +1719,7 @@ fn encode_info_for_generics(&mut self, generics: &hir::Generics) {
     fn encode_info_for_ty(&mut self, ty: &hir::Ty) {
         match ty.node {
             hir::TyKind::Array(_, ref length) => {
-                let def_id = self.tcx.hir().local_def_id(length.id);
+                let def_id = self.tcx.hir().local_def_id_from_hir_id(length.hir_id);
                 self.record(def_id, IsolatedEncoder::encode_info_for_anon_const, def_id);
             }
             _ => {}
index 2a3a616317c172a86692d4eb7ab35545f3d44a08..cbef7a7f6c481326bbc90bf6e6b1f27289ca6633 100644 (file)
@@ -333,7 +333,7 @@ fn insert_as_pending_if_two_phase(
         //    TEMP = &foo
         //
         // so extract `temp`.
-        let temp = if let &mir::Place::Local(temp) = assigned_place {
+        let temp = if let &mir::Place::Base(mir::PlaceBase::Local(temp)) = assigned_place {
             temp
         } else {
             span_bug!(
index 67fbe5762e73ab267473b862e27e2e61e31735e3..dc1979b6380b1d92a345557df28e5b6acb72b4f9 100644 (file)
@@ -8,7 +8,7 @@
 use rustc::mir::{
     self, AggregateKind, BindingForm, BorrowKind, ClearCrossCrate, Constant,
     ConstraintCategory, Field, Local, LocalDecl, LocalKind, Location, Operand,
-    Place, PlaceProjection, ProjectionElem, Rvalue, Statement, StatementKind,
+    Place, PlaceBase, PlaceProjection, ProjectionElem, Rvalue, Statement, StatementKind,
     TerminatorKind, VarBindingForm,
 };
 use rustc::ty::{self, DefIdTree};
@@ -220,7 +220,7 @@ pub(super) fn report_use_of_moved_or_uninitialized(
                         );
                     }
                 }
-                if let Place::Local(local) = place {
+                if let Place::Base(PlaceBase::Local(local)) = place {
                     let decl = &self.mir.local_decls[*local];
                     err.span_label(
                         decl.source_info.span,
@@ -679,7 +679,7 @@ pub(super) fn report_borrowed_value_does_not_live_long_enough(
         let borrow_span = borrow_spans.var_or_use();
 
         let proper_span = match *root_place {
-            Place::Local(local) => self.mir.local_decls[local].source_info.span,
+            Place::Base(PlaceBase::Local(local)) => self.mir.local_decls[local].source_info.span,
             _ => drop_span,
         };
 
@@ -1061,7 +1061,7 @@ fn report_cannot_return_reference_to_local(
 
         let (place_desc, note) = if let Some(place_desc) = opt_place_desc {
             let local_kind = match borrow.borrowed_place {
-                Place::Local(local) => {
+                Place::Base(PlaceBase::Local(local)) => {
                     match self.mir.local_kind(local) {
                         LocalKind::ReturnPointer
                         | LocalKind::Temp => bug!("temporary or return pointer with a name"),
@@ -1086,7 +1086,7 @@ fn report_cannot_return_reference_to_local(
             let root_place = self.prefixes(&borrow.borrowed_place, PrefixSet::All)
                 .last()
                 .unwrap();
-            let local = if let Place::Local(local) = *root_place {
+            let local = if let Place::Base(PlaceBase::Local(local)) = *root_place {
                 local
             } else {
                 bug!("report_cannot_return_reference_to_local: not a local")
@@ -1385,7 +1385,7 @@ pub(super) fn report_illegal_reassignment(
         assigned_span: Span,
         err_place: &Place<'tcx>,
     ) {
-        let (from_arg, local_decl) = if let Place::Local(local) = *err_place {
+        let (from_arg, local_decl) = if let Place::Base(PlaceBase::Local(local)) = *err_place {
             if let LocalKind::Arg = self.mir.local_kind(local) {
                 (true, Some(&self.mir.local_decls[local]))
             } else {
@@ -1600,13 +1600,13 @@ fn append_place_to_string(
         including_downcast: &IncludingDowncast,
     ) -> Result<(), ()> {
         match *place {
-            Place::Promoted(_) => {
+            Place::Base(PlaceBase::Promoted(_)) => {
                 buf.push_str("promoted");
             }
-            Place::Local(local) => {
+            Place::Base(PlaceBase::Local(local)) => {
                 self.append_local_to_string(local, buf)?;
             }
-            Place::Static(ref static_) => {
+            Place::Base(PlaceBase::Static(ref static_)) => {
                 buf.push_str(&self.infcx.tcx.item_name(static_.def_id).to_string());
             }
             Place::Projection(ref proj) => {
@@ -1630,7 +1630,7 @@ fn append_place_to_string(
                                     autoderef,
                                     &including_downcast,
                                 )?;
-                            } else if let Place::Local(local) = proj.base {
+                            } else if let Place::Base(PlaceBase::Local(local)) = proj.base {
                                 if let Some(ClearCrossCrate::Set(BindingForm::RefForGuard)) =
                                     self.mir.local_decls[local].is_user_variable
                                 {
@@ -1742,12 +1742,14 @@ fn append_local_to_string(&self, local_index: Local, buf: &mut String) -> Result
     /// End-user visible description of the `field`nth field of `base`
     fn describe_field(&self, base: &Place<'_>, field: Field) -> String {
         match *base {
-            Place::Local(local) => {
+            Place::Base(PlaceBase::Local(local)) => {
                 let local = &self.mir.local_decls[local];
                 self.describe_field_from_ty(&local.ty, field)
             }
-            Place::Promoted(ref prom) => self.describe_field_from_ty(&prom.1, field),
-            Place::Static(ref static_) => self.describe_field_from_ty(&static_.ty, field),
+            Place::Base(PlaceBase::Promoted(ref prom)) =>
+                self.describe_field_from_ty(&prom.1, field),
+            Place::Base(PlaceBase::Static(ref static_)) =>
+                self.describe_field_from_ty(&static_.ty, field),
             Place::Projection(ref proj) => match proj.elem {
                 ProjectionElem::Deref => self.describe_field(&proj.base, field),
                 ProjectionElem::Downcast(def, variant_index) =>
@@ -1809,7 +1811,7 @@ fn describe_field_from_ty(&self, ty: &ty::Ty<'_>, field: Field) -> String {
 
     /// Checks if a place is a thread-local static.
     pub fn is_place_thread_local(&self, place: &Place<'tcx>) -> bool {
-        if let Place::Static(statik) = place {
+        if let Place::Base(PlaceBase::Static(statik)) = place {
             let attrs = self.infcx.tcx.get_attrs(statik.def_id);
             let is_thread_local = attrs.iter().any(|attr| attr.check_name("thread_local"));
 
@@ -1827,7 +1829,9 @@ pub fn is_place_thread_local(&self, place: &Place<'tcx>) -> bool {
     fn classify_drop_access_kind(&self, place: &Place<'tcx>) -> StorageDeadOrDrop<'tcx> {
         let tcx = self.infcx.tcx;
         match place {
-            Place::Local(_) | Place::Static(_) | Place::Promoted(_) => {
+            Place::Base(PlaceBase::Local(_)) |
+            Place::Base(PlaceBase::Static(_)) |
+            Place::Base(PlaceBase::Promoted(_)) => {
                 StorageDeadOrDrop::LocalStorageDead
             }
             Place::Projection(box PlaceProjection { base, elem }) => {
@@ -1912,7 +1916,8 @@ fn annotate_argument_and_return_for_borrow(
             );
             // Check that the initial assignment of the reserve location is into a temporary.
             let mut target = *match reservation {
-                Place::Local(local) if self.mir.local_kind(*local) == LocalKind::Temp => local,
+                Place::Base(PlaceBase::Local(local))
+                    if self.mir.local_kind(*local) == LocalKind::Temp => local,
                 _ => return None,
             };
 
@@ -1924,8 +1929,10 @@ fn annotate_argument_and_return_for_borrow(
                     "annotate_argument_and_return_for_borrow: target={:?} stmt={:?}",
                     target, stmt
                 );
-                if let StatementKind::Assign(Place::Local(assigned_to), box rvalue) = &stmt.kind
-                {
+                if let StatementKind::Assign(
+                    Place::Base(PlaceBase::Local(assigned_to)),
+                    box rvalue
+                ) = &stmt.kind {
                     debug!(
                         "annotate_argument_and_return_for_borrow: assigned_to={:?} \
                          rvalue={:?}",
@@ -2048,7 +2055,7 @@ fn annotate_argument_and_return_for_borrow(
                 target, terminator
             );
             if let TerminatorKind::Call {
-                destination: Some((Place::Local(assigned_to), _)),
+                destination: Some((Place::Base(PlaceBase::Local(assigned_to)), _)),
                 args,
                 ..
             } = &terminator.kind
@@ -2496,7 +2503,7 @@ pub(super) fn borrow_spans(&self, use_span: Span, location: Location) -> UseSpan
             .get(location.statement_index)
         {
             Some(&Statement {
-                kind: StatementKind::Assign(Place::Local(local), _),
+                kind: StatementKind::Assign(Place::Base(PlaceBase::Local(local)), _),
                 ..
             }) => local,
             _ => return OtherUse(use_span),
@@ -2522,7 +2529,7 @@ pub(super) fn borrow_spans(&self, use_span: Span, location: Location) -> UseSpan
                     def_id, is_generator, places
                 );
                 if let Some((args_span, var_span)) = self.closure_span(
-                    *def_id, &Place::Local(target), places
+                    *def_id, &Place::Base(PlaceBase::Local(target)), places
                 ) {
                     return ClosureUse {
                         is_generator,
index 1091646bdd5c672ebb3c9e0517ef79a0578e6d81..715ee856a7a6268975885fbec4a89417d3824ead 100644 (file)
@@ -8,7 +8,7 @@
 use rustc::lint::builtin::UNUSED_MUT;
 use rustc::middle::borrowck::SignalledError;
 use rustc::mir::{AggregateKind, BasicBlock, BorrowCheckResult, BorrowKind};
-use rustc::mir::{ClearCrossCrate, Local, Location, Mir, Mutability, Operand, Place};
+use rustc::mir::{ClearCrossCrate, Local, Location, Mir, Mutability, Operand, Place, PlaceBase};
 use rustc::mir::{Field, Projection, ProjectionElem, Rvalue, Statement, StatementKind};
 use rustc::mir::{Terminator, TerminatorKind};
 use rustc::ty::query::Providers;
@@ -588,7 +588,7 @@ fn visit_statement_entry(
             StatementKind::StorageDead(local) => {
                 self.access_place(
                     ContextKind::StorageDead.new(location),
-                    (&Place::Local(local), span),
+                    (&Place::Base(PlaceBase::Local(local)), span),
                     (Shallow(None), Write(WriteKind::StorageDeadOrDrop)),
                     LocalMutationIsAllowed::Yes,
                     flow_state,
@@ -1104,7 +1104,7 @@ fn mutate_place(
         // Special case: you can assign a immutable local variable
         // (e.g., `x = ...`) so long as it has never been initialized
         // before (at this point in the flow).
-        if let &Place::Local(local) = place_span.0 {
+        if let &Place::Base(PlaceBase::Local(local)) = place_span.0 {
             if let Mutability::Not = self.mir.local_decls[local].mutability {
                 // check for reassignments to immutable local variables
                 self.check_if_reassignment_to_immutable_state(
@@ -1231,8 +1231,8 @@ fn consume_rvalue(
                             // captures of a closure are copied/moved directly
                             // when generating MIR.
                             match operands[field.index()] {
-                                Operand::Move(Place::Local(local))
-                                | Operand::Copy(Place::Local(local)) => {
+                                Operand::Move(Place::Base(PlaceBase::Local(local)))
+                                | Operand::Copy(Place::Base(PlaceBase::Local(local))) => {
                                     self.used_mut.insert(local);
                                 }
                                 Operand::Move(ref place @ Place::Projection(_))
@@ -1242,10 +1242,10 @@ fn consume_rvalue(
                                         self.used_mut_upvars.push(field);
                                     }
                                 }
-                                Operand::Move(Place::Static(..))
-                                | Operand::Copy(Place::Static(..))
-                                | Operand::Move(Place::Promoted(..))
-                                | Operand::Copy(Place::Promoted(..))
+                                Operand::Move(Place::Base(PlaceBase::Static(..)))
+                                | Operand::Copy(Place::Base(PlaceBase::Static(..)))
+                                | Operand::Move(Place::Base(PlaceBase::Promoted(..)))
+                                | Operand::Copy(Place::Base(PlaceBase::Promoted(..)))
                                 | Operand::Constant(..) => {}
                             }
                         }
@@ -1328,14 +1328,14 @@ fn check_for_invalidation_at_exit(
         //
         // FIXME: allow thread-locals to borrow other thread locals?
         let (might_be_alive, will_be_dropped) = match root_place {
-            Place::Promoted(_) => (true, false),
-            Place::Static(_) => {
+            Place::Base(PlaceBase::Promoted(_)) => (true, false),
+            Place::Base(PlaceBase::Static(_)) => {
                 // Thread-locals might be dropped after the function exits, but
                 // "true" statics will never be.
                 let is_thread_local = self.is_place_thread_local(&root_place);
                 (true, is_thread_local)
             }
-            Place::Local(_) => {
+            Place::Base(PlaceBase::Local(_)) => {
                 // Locals are always dropped at function exit, and if they
                 // have a destructor it would've been called already.
                 (false, self.locals_are_invalidated_at_exit)
@@ -1594,10 +1594,10 @@ fn move_path_closest_to<'a>(
             last_prefix = prefix;
         }
         match *last_prefix {
-            Place::Local(_) => panic!("should have move path for every Local"),
+            Place::Base(PlaceBase::Local(_)) => panic!("should have move path for every Local"),
             Place::Projection(_) => panic!("PrefixSet::All meant don't stop for Projection"),
-            Place::Promoted(_) |
-            Place::Static(_) => Err(NoMovePathFound::ReachedStatic),
+            Place::Base(PlaceBase::Promoted(_)) |
+            Place::Base(PlaceBase::Static(_)) => Err(NoMovePathFound::ReachedStatic),
         }
     }
 
@@ -1623,8 +1623,8 @@ fn check_if_assigned_path_is_moved(
         let mut place = place;
         loop {
             match *place {
-                Place::Promoted(_) |
-                Place::Local(_) | Place::Static(_) => {
+                Place::Base(PlaceBase::Promoted(_)) |
+                Place::Base(PlaceBase::Local(_)) | Place::Base(PlaceBase::Static(_)) => {
                     // assigning to `x` does not require `x` be initialized.
                     break;
                 }
@@ -1947,7 +1947,7 @@ fn add_used_mut<'d>(
     ) {
         match root_place {
             RootPlace {
-                place: Place::Local(local),
+                place: Place::Base(PlaceBase::Local(local)),
                 is_local_mutation_allowed,
             } => {
                 // If the local may have been initialized, and it is now currently being
@@ -1972,11 +1972,11 @@ fn add_used_mut<'d>(
                 }
             }
             RootPlace {
-                place: Place::Promoted(..),
+                place: Place::Base(PlaceBase::Promoted(..)),
                 is_local_mutation_allowed: _,
             } => {}
             RootPlace {
-                place: Place::Static(..),
+                place: Place::Base(PlaceBase::Static(..)),
                 is_local_mutation_allowed: _,
             } => {}
         }
@@ -1990,7 +1990,7 @@ fn is_mutable<'d>(
         is_local_mutation_allowed: LocalMutationIsAllowed,
     ) -> Result<RootPlace<'d, 'tcx>, &'d Place<'tcx>> {
         match *place {
-            Place::Local(local) => {
+            Place::Base(PlaceBase::Local(local)) => {
                 let local = &self.mir.local_decls[local];
                 match local.mutability {
                     Mutability::Not => match is_local_mutation_allowed {
@@ -2012,11 +2012,11 @@ fn is_mutable<'d>(
             }
             // The rules for promotion are made by `qualify_consts`, there wouldn't even be a
             // `Place::Promoted` if the promotion weren't 100% legal. So we just forward this
-            Place::Promoted(_) => Ok(RootPlace {
+            Place::Base(PlaceBase::Promoted(_)) => Ok(RootPlace {
                 place,
                 is_local_mutation_allowed,
             }),
-            Place::Static(ref static_) => {
+            Place::Base(PlaceBase::Static(ref static_)) => {
                 if self.infcx.tcx.is_static(static_.def_id) != Some(hir::Mutability::MutMutable) {
                     Err(place)
                 } else {
index 2a5433d4317860e57a243948d7ba41f31806f627..bd4bf67d0b154b3856c71fcae5c4dd8b9fffa462 100644 (file)
@@ -111,7 +111,7 @@ fn append_to_grouped_errors(
                 // If that ever stops being the case, then the ever initialized
                 // flow could be used.
                 if let Some(StatementKind::Assign(
-                    Place::Local(local),
+                    Place::Base(PlaceBase::Local(local)),
                     box Rvalue::Use(Operand::Move(move_from)),
                 )) = self.mir.basic_blocks()[location.block]
                     .statements
index 008c081aeb601f7f26062b85e4a21987edb4caf2..f68ed4422bca08eaaa8be21f5d6579b10e0d0b60 100644 (file)
@@ -1,8 +1,8 @@
 use rustc::hir;
 use rustc::hir::Node;
 use rustc::mir::{self, BindingForm, Constant, ClearCrossCrate, Local, Location, Mir};
-use rustc::mir::{Mutability, Operand, Place, Projection, ProjectionElem, Static, Terminator};
-use rustc::mir::TerminatorKind;
+use rustc::mir::{Mutability, Operand, Place, PlaceBase, Projection, ProjectionElem, Static};
+use rustc::mir::{Terminator, TerminatorKind};
 use rustc::ty::{self, Const, DefIdTree, TyS, TyKind, TyCtxt};
 use rustc_data_structures::indexed_vec::Idx;
 use syntax_pos::Span;
@@ -45,9 +45,9 @@ pub(super) fn report_mutability_error(
         debug!("report_mutability_error: access_place_desc={:?}", access_place_desc);
 
         match the_place_err {
-            Place::Local(local) => {
+            Place::Base(PlaceBase::Local(local)) => {
                 item_msg = format!("`{}`", access_place_desc.unwrap());
-                if let Place::Local(_) = access_place {
+                if let Place::Base(PlaceBase::Local(_)) = access_place {
                     reason = ", as it is not declared as mutable".to_string();
                 } else {
                     let name = self.mir.local_decls[*local]
@@ -78,7 +78,8 @@ pub(super) fn report_mutability_error(
                 base,
                 elem: ProjectionElem::Deref,
             }) => {
-                if *base == Place::Local(Local::new(1)) && !self.mir.upvar_decls.is_empty() {
+                if *base == Place::Base(PlaceBase::Local(Local::new(1))) &&
+                    !self.mir.upvar_decls.is_empty() {
                     item_msg = format!("`{}`", access_place_desc.unwrap());
                     debug_assert!(self.mir.local_decls[Local::new(1)].ty.is_region_ptr());
                     debug_assert!(is_closure_or_generator(
@@ -92,7 +93,7 @@ pub(super) fn report_mutability_error(
                         ", as `Fn` closures cannot mutate their captured variables".to_string()
                     }
                 } else if {
-                    if let Place::Local(local) = *base {
+                    if let Place::Base(PlaceBase::Local(local)) = *base {
                         if let Some(ClearCrossCrate::Set(BindingForm::RefForGuard))
                             = self.mir.local_decls[local].is_user_variable {
                                 true
@@ -128,10 +129,10 @@ pub(super) fn report_mutability_error(
                 }
             }
 
-            Place::Promoted(_) => unreachable!(),
+            Place::Base(PlaceBase::Promoted(_)) => unreachable!(),
 
-            Place::Static(box Static { def_id, ty: _ }) => {
-                if let Place::Static(_) = access_place {
+            Place::Base(PlaceBase::Static(box Static { def_id, ty: _ })) => {
+                if let Place::Base(PlaceBase::Static(_)) = access_place {
                     item_msg = format!("immutable static item `{}`", access_place_desc.unwrap());
                     reason = String::new();
                 } else {
@@ -241,7 +242,7 @@ pub(super) fn report_mutability_error(
             },
 
             // Suggest removing a `&mut` from the use of a mutable reference.
-            Place::Local(local)
+            Place::Base(PlaceBase::Local(local))
                 if {
                     self.mir.local_decls.get(*local).map(|local_decl| {
                         if let ClearCrossCrate::Set(
@@ -276,7 +277,8 @@ pub(super) fn report_mutability_error(
 
             // We want to suggest users use `let mut` for local (user
             // variable) mutations...
-            Place::Local(local) if self.mir.local_decls[*local].can_be_made_mutable() => {
+            Place::Base(PlaceBase::Local(local))
+                if self.mir.local_decls[*local].can_be_made_mutable() => {
                 // ... but it doesn't make sense to suggest it on
                 // variables that are `ref x`, `ref mut x`, `&self`,
                 // or `&mut self` (such variables are simply not
@@ -330,7 +332,7 @@ pub(super) fn report_mutability_error(
             // complete hack to approximate old AST-borrowck
             // diagnostic: if the span starts with a mutable borrow of
             // a local variable, then just suggest the user remove it.
-            Place::Local(_)
+            Place::Base(PlaceBase::Local(_))
                 if {
                     if let Ok(snippet) = self.infcx.tcx.sess.source_map().span_to_snippet(span) {
                         snippet.starts_with("&mut ")
@@ -344,7 +346,7 @@ pub(super) fn report_mutability_error(
             }
 
             Place::Projection(box Projection {
-                base: Place::Local(local),
+                base: Place::Base(PlaceBase::Local(local)),
                 elem: ProjectionElem::Deref,
             }) if {
                 if let Some(ClearCrossCrate::Set(BindingForm::RefForGuard)) =
@@ -368,7 +370,7 @@ pub(super) fn report_mutability_error(
             // FIXME: can this case be generalized to work for an
             // arbitrary base for the projection?
             Place::Projection(box Projection {
-                base: Place::Local(local),
+                base: Place::Base(PlaceBase::Local(local)),
                 elem: ProjectionElem::Deref,
             }) if self.mir.local_decls[*local].is_user_variable.is_some() =>
             {
@@ -447,7 +449,8 @@ pub(super) fn report_mutability_error(
             Place::Projection(box Projection {
                 base,
                 elem: ProjectionElem::Deref,
-            }) if *base == Place::Local(Local::new(1)) && !self.mir.upvar_decls.is_empty() =>
+            }) if *base == Place::Base(PlaceBase::Local(Local::new(1))) &&
+                  !self.mir.upvar_decls.is_empty() =>
             {
                 err.span_label(span, format!("cannot {ACT}", ACT = act));
                 err.span_help(
@@ -457,7 +460,7 @@ pub(super) fn report_mutability_error(
             }
 
             Place::Projection(box Projection {
-                base: Place::Local(local),
+                base: Place::Base(PlaceBase::Local(local)),
                 elem: ProjectionElem::Deref,
             })  if error_access == AccessKind::MutableBorrow => {
                 err.span_label(span, format!("cannot {ACT}", ACT = act));
index c02c2b4934cf492261393cabfea022b48910a9e4..375dd6e97f1a29511f3a418fb587719687cd16cd 100644 (file)
@@ -6,12 +6,12 @@
 use rustc::infer::InferCtxt;
 use rustc::mir::visit::TyContext;
 use rustc::mir::visit::Visitor;
-use rustc::mir::{BasicBlock, BasicBlockData, Location, Mir, Place, Rvalue};
+use rustc::mir::{BasicBlock, BasicBlockData, Location, Mir, Place, PlaceBase, Rvalue};
 use rustc::mir::{SourceInfo, Statement, Terminator};
 use rustc::mir::UserTypeProjection;
 use rustc::ty::fold::TypeFoldable;
-use rustc::ty::subst::Substs;
 use rustc::ty::{self, ClosureSubsts, GeneratorSubsts, RegionVid};
+use rustc::ty::subst::SubstsRef;
 
 pub(super) fn generate_constraints<'cx, 'gcx, 'tcx>(
     infcx: &InferCtxt<'cx, 'gcx, 'tcx>,
@@ -50,7 +50,7 @@ fn visit_basic_block_data(&mut self, bb: BasicBlock, data: &BasicBlockData<'tcx>
 
     /// We sometimes have `substs` within an rvalue, or within a
     /// call. Make them live at the location where they appear.
-    fn visit_substs(&mut self, substs: &&'tcx Substs<'tcx>, location: Location) {
+    fn visit_substs(&mut self, substs: &SubstsRef<'tcx>, location: Location) {
         self.add_regular_live_constraint(*substs, location);
         self.super_substs(substs);
     }
@@ -130,7 +130,7 @@ fn visit_assign(
         // When we see `X = ...`, then kill borrows of
         // `(*X).foo` and so forth.
         if let Some(all_facts) = self.all_facts {
-            if let Place::Local(temp) = place {
+            if let Place::Base(PlaceBase::Local(temp)) = place {
                 if let Some(borrow_indices) = self.borrow_set.local_map.get(temp) {
                     all_facts.killed.reserve(borrow_indices.len());
                     for &borrow_index in borrow_indices {
index 8ea249959dd2c284e1c113770784f74a92a5d497..17f8c23f4fddc0cdf43c686e97f8f3bc0558a725 100644 (file)
@@ -6,8 +6,8 @@
 use crate::borrow_check::nll::ConstraintDescription;
 use crate::borrow_check::{Context, MirBorrowckCtxt, WriteKind};
 use rustc::mir::{
-    CastKind, ConstraintCategory, FakeReadCause, Local, Location, Mir, Operand, Place, Projection,
-    ProjectionElem, Rvalue, Statement, StatementKind, TerminatorKind,
+    CastKind, ConstraintCategory, FakeReadCause, Local, Location, Mir, Operand, Place, PlaceBase,
+    Projection, ProjectionElem, Rvalue, Statement, StatementKind, TerminatorKind,
 };
 use rustc::ty::{self, TyCtxt};
 use rustc_data_structures::fx::FxHashSet;
@@ -245,7 +245,7 @@ pub(in crate::borrow_check) fn explain_why_borrow_contains_point(
             Some(Cause::LiveVar(local, location)) => {
                 let span = mir.source_info(location).span;
                 let spans = self
-                    .move_spans(&Place::Local(local), location)
+                    .move_spans(&Place::Base(PlaceBase::Local(local)), location)
                     .or_else(|| self.borrow_spans(span, location));
 
                 let borrow_location = context.loc;
@@ -265,7 +265,7 @@ pub(in crate::borrow_check) fn explain_why_borrow_contains_point(
                 let mut should_note_order = false;
                 if mir.local_decls[local].name.is_some() {
                     if let Some((WriteKind::StorageDeadOrDrop, place)) = kind_place {
-                        if let Place::Local(borrowed_local) = place {
+                        if let Place::Base(PlaceBase::Local(borrowed_local)) = place {
                             let dropped_local_scope = mir.local_decls[local].visibility_scope;
                             let borrowed_local_scope =
                                 mir.local_decls[*borrowed_local].visibility_scope;
@@ -481,7 +481,8 @@ fn later_use_kind(
                         // Just point to the function, to reduce the chance of overlapping spans.
                         let function_span = match func {
                             Operand::Constant(c) => c.span,
-                            Operand::Copy(Place::Local(l)) | Operand::Move(Place::Local(l)) => {
+                            Operand::Copy(Place::Base(PlaceBase::Local(l))) |
+                            Operand::Move(Place::Base(PlaceBase::Local(l))) => {
                                 let local_decl = &self.mir.local_decls[*l];
                                 if local_decl.name.is_none() {
                                     local_decl.source_info.span
@@ -522,7 +523,7 @@ fn was_captured_by_trait_object(&self, borrow: &BorrowData<'tcx>) -> bool {
         // it which simplifies the termination logic.
         let mut queue = vec![location];
         let mut target = if let Some(&Statement {
-            kind: StatementKind::Assign(Place::Local(local), _),
+            kind: StatementKind::Assign(Place::Base(PlaceBase::Local(local)), _),
             ..
         }) = stmt
         {
@@ -547,9 +548,9 @@ fn was_captured_by_trait_object(&self, borrow: &BorrowData<'tcx>) -> bool {
                 // The only kind of statement that we care about is assignments...
                 if let StatementKind::Assign(place, box rvalue) = &stmt.kind {
                     let into = match place {
-                        Place::Local(into) => into,
+                        Place::Base(PlaceBase::Local(into)) => into,
                         Place::Projection(box Projection {
-                            base: Place::Local(into),
+                            base: Place::Base(PlaceBase::Local(into)),
                             elem: ProjectionElem::Deref,
                         }) => into,
                         _ => {
@@ -563,8 +564,8 @@ fn was_captured_by_trait_object(&self, borrow: &BorrowData<'tcx>) -> bool {
                         // If we see a use, we should check whether it is our data, and if so
                         // update the place that we're looking for to that new place.
                         Rvalue::Use(operand) => match operand {
-                            Operand::Copy(Place::Local(from))
-                            | Operand::Move(Place::Local(from))
+                            Operand::Copy(Place::Base(PlaceBase::Local(from)))
+                            | Operand::Move(Place::Base(PlaceBase::Local(from)))
                                 if *from == target =>
                             {
                                 target = *into;
@@ -574,8 +575,8 @@ fn was_captured_by_trait_object(&self, borrow: &BorrowData<'tcx>) -> bool {
                         // If we see a unsized cast, then if it is our data we should check
                         // whether it is being cast to a trait object.
                         Rvalue::Cast(CastKind::Unsize, operand, ty) => match operand {
-                            Operand::Copy(Place::Local(from))
-                            | Operand::Move(Place::Local(from))
+                            Operand::Copy(Place::Base(PlaceBase::Local(from)))
+                            | Operand::Move(Place::Base(PlaceBase::Local(from)))
                                 if *from == target =>
                             {
                                 debug!("was_captured_by_trait_object: ty={:?}", ty);
@@ -605,7 +606,7 @@ fn was_captured_by_trait_object(&self, borrow: &BorrowData<'tcx>) -> bool {
                 debug!("was_captured_by_trait_object: terminator={:?}", terminator);
 
                 if let TerminatorKind::Call {
-                    destination: Some((Place::Local(dest), block)),
+                    destination: Some((Place::Base(PlaceBase::Local(dest)), block)),
                     args,
                     ..
                 } = &terminator.kind
@@ -616,7 +617,7 @@ fn was_captured_by_trait_object(&self, borrow: &BorrowData<'tcx>) -> bool {
                     );
                     // Check if one of the arguments to this function is the target place.
                     let found_target = args.iter().any(|arg| {
-                        if let Operand::Move(Place::Local(potential)) = arg {
+                        if let Operand::Move(Place::Base(PlaceBase::Local(potential))) = arg {
                             *potential == target
                         } else {
                             false
index 9c067677621081998c9f4af0835d6948366a119b..aafbff35776475a91d47624ba015b9b078e59906 100644 (file)
@@ -12,7 +12,7 @@
 use crate::dataflow::move_paths::indexes::BorrowIndex;
 use rustc::ty::TyCtxt;
 use rustc::mir::visit::Visitor;
-use rustc::mir::{BasicBlock, Location, Mir, Place, Rvalue};
+use rustc::mir::{BasicBlock, Location, Mir, Place, PlaceBase, Rvalue};
 use rustc::mir::{Statement, StatementKind};
 use rustc::mir::{Terminator, TerminatorKind};
 use rustc::mir::{Operand, BorrowKind};
@@ -131,7 +131,7 @@ fn visit_statement(
             StatementKind::StorageDead(local) => {
                 self.access_place(
                     ContextKind::StorageDead.new(location),
-                    &Place::Local(local),
+                    &Place::Base(PlaceBase::Local(local)),
                     (Shallow(None), Write(WriteKind::StorageDeadOrDrop)),
                     LocalMutationIsAllowed::Yes,
                 );
index 089640ab7024b19ab8c866f2f72d4d8c80888f76..cc01f632e075cac4210a3b0b40c7169058a55d66 100644 (file)
@@ -6,7 +6,7 @@
 use rustc::hir::def_id::DefId;
 use rustc::infer::InferCtxt;
 use rustc::mir::Mir;
-use rustc::ty::subst::{Substs, UnpackedKind};
+use rustc::ty::subst::{SubstsRef, UnpackedKind};
 use rustc::ty::{self, RegionKind, RegionVid, Ty, TyCtxt};
 use rustc::util::ppaux::RegionHighlightMode;
 use rustc_errors::DiagnosticBuilder;
@@ -541,7 +541,7 @@ fn give_name_if_we_can_match_hir_ty(
     /// types+hir to search through).
     fn match_adt_and_segment<'hir>(
         &self,
-        substs: &'tcx Substs<'tcx>,
+        substs: SubstsRef<'tcx>,
         needle_fr: RegionVid,
         last_segment: &'hir hir::PathSegment,
         counter: &mut usize,
@@ -587,7 +587,7 @@ fn match_adt_and_segment<'hir>(
     /// `search_stack` the types+hir to search through.
     fn try_match_adt_and_generic_args<'hir>(
         &self,
-        substs: &'tcx Substs<'tcx>,
+        substs: SubstsRef<'tcx>,
         needle_fr: RegionVid,
         args: &'hir hir::GenericArgs,
         search_stack: &mut Vec<(Ty<'tcx>, &'hir hir::Ty)>,
index cbeb5dc206ee68d5754cbbe1f96e62c4f9f85fe9..785f810d9415907fd89da70fae1e9c5fa3c62bdf 100644 (file)
@@ -14,7 +14,7 @@
     ClosureOutlivesRequirement, ClosureOutlivesSubject, ClosureRegionRequirements,
     ConstraintCategory, Local, Location, Mir,
 };
-use rustc::ty::{self, RegionVid, Ty, TyCtxt, TypeFoldable};
+use rustc::ty::{self, subst::SubstsRef, RegionVid, Ty, TyCtxt, TypeFoldable};
 use rustc::util::common::{self, ErrorReported};
 use rustc_data_structures::bit_set::BitSet;
 use rustc_data_structures::fx::{FxHashMap, FxHashSet};
@@ -1359,7 +1359,7 @@ fn apply_requirements(
         tcx: TyCtxt<'_, 'gcx, 'tcx>,
         location: Location,
         closure_def_id: DefId,
-        closure_substs: &'tcx ty::subst::Substs<'tcx>,
+        closure_substs: SubstsRef<'tcx>,
     ) -> Vec<QueryRegionConstraint<'tcx>>;
 
     fn subst_closure_mapping<T>(
@@ -1390,7 +1390,7 @@ fn apply_requirements(
         tcx: TyCtxt<'_, 'gcx, 'tcx>,
         location: Location,
         closure_def_id: DefId,
-        closure_substs: &'tcx ty::subst::Substs<'tcx>,
+        closure_substs: SubstsRef<'tcx>,
     ) -> Vec<QueryRegionConstraint<'tcx>> {
         debug!(
             "apply_requirements(location={:?}, closure_def_id={:?}, closure_substs={:?})",
index e6a974fd8cc94d92407d9eead619066d866305d9..eab9e0ae171ed229c8b14a4bd5f326634dcfaeea 100644 (file)
@@ -1,4 +1,4 @@
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::SubstsRef;
 use rustc::ty::{self, ClosureSubsts, GeneratorSubsts, Ty, TypeFoldable};
 use rustc::mir::{Location, Mir};
 use rustc::mir::visit::{MutVisitor, TyContext};
@@ -55,7 +55,7 @@ fn visit_ty(&mut self, ty: &mut Ty<'tcx>, ty_context: TyContext) {
         debug!("visit_ty: ty={:?}", ty);
     }
 
-    fn visit_substs(&mut self, substs: &mut &'tcx Substs<'tcx>, location: Location) {
+    fn visit_substs(&mut self, substs: &mut SubstsRef<'tcx>, location: Location) {
         debug!("visit_substs(substs={:?}, location={:?})", substs, location);
 
         *substs = self.renumber_regions(&{ *substs });
index 49f90eb90aaf043896d7e07698ac1f7e5e8c45dc..cf054c2d05505d73586b92d33403bed420f46318 100644 (file)
@@ -36,7 +36,7 @@
 use rustc::traits::query::{Fallible, NoSolution};
 use rustc::traits::{ObligationCause, PredicateObligations};
 use rustc::ty::fold::TypeFoldable;
-use rustc::ty::subst::{Subst, Substs, UnpackedKind, UserSubsts};
+use rustc::ty::subst::{Subst, SubstsRef, UnpackedKind, UserSubsts};
 use rustc::ty::{
     self, RegionVid, ToPolyTraitRef, Ty, TyCtxt, TyKind, UserType,
     CanonicalUserTypeAnnotation, UserTypeAnnotationIndex,
@@ -451,10 +451,10 @@ fn sanitize_place(
     ) -> PlaceTy<'tcx> {
         debug!("sanitize_place: {:?}", place);
         let place_ty = match *place {
-            Place::Local(index) => PlaceTy::Ty {
+            Place::Base(PlaceBase::Local(index)) => PlaceTy::Ty {
                 ty: self.mir.local_decls[index].ty,
             },
-            Place::Promoted(box (_index, sty)) => {
+            Place::Base(PlaceBase::Promoted(box (_index, sty))) => {
                 let sty = self.sanitize_type(place, sty);
                 // FIXME -- promoted MIR return types reference
                 // various "free regions" (e.g., scopes and things)
@@ -469,7 +469,7 @@ fn sanitize_place(
                 // promoted_mir.return_ty()
                 PlaceTy::Ty { ty: sty }
             }
-            Place::Static(box Static { def_id, ty: sty }) => {
+            Place::Base(PlaceBase::Static(box Static { def_id, ty: sty })) => {
                 let sty = self.sanitize_type(place, sty);
                 let ty = self.tcx().type_of(def_id);
                 let ty = self.cx.normalize(ty, location);
@@ -553,7 +553,7 @@ fn sanitize_projection(
                 }
             }
             ProjectionElem::Index(i) => {
-                let index_ty = Place::Local(i).ty(self.mir, tcx).to_ty(tcx);
+                let index_ty = Place::Base(PlaceBase::Local(i)).ty(self.mir, tcx).to_ty(tcx);
                 if index_ty != tcx.types.usize {
                     PlaceTy::Ty {
                         ty: span_mirbug_and_err!(self, i, "index by non-usize {:?}", i),
@@ -1234,7 +1234,7 @@ fn check_stmt(&mut self, mir: &Mir<'tcx>, stmt: &Statement<'tcx>, location: Loca
                 // of lowering. Assignments to other sorts of places *are* interesting
                 // though.
                 let category = match *place {
-                    Place::Local(RETURN_PLACE) => if let Some(BorrowCheckContext {
+                    Place::Base(PlaceBase::Local(RETURN_PLACE)) => if let Some(BorrowCheckContext {
                         universal_regions:
                             UniversalRegions {
                                 defining_ty: DefiningTy::Const(def_id, _),
@@ -1251,7 +1251,8 @@ fn check_stmt(&mut self, mir: &Mir<'tcx>, stmt: &Statement<'tcx>, location: Loca
                     } else {
                         ConstraintCategory::Return
                     },
-                    Place::Local(l) if !mir.local_decls[l].is_user_variable.is_some() => {
+                    Place::Base(PlaceBase::Local(l))
+                        if !mir.local_decls[l].is_user_variable.is_some() => {
                         ConstraintCategory::Boring
                     }
                     _ => ConstraintCategory::Assignment,
@@ -1537,7 +1538,7 @@ fn check_call_dest(
             Some((ref dest, _target_block)) => {
                 let dest_ty = dest.ty(mir, tcx).to_ty(tcx);
                 let category = match *dest {
-                    Place::Local(RETURN_PLACE) => {
+                    Place::Base(PlaceBase::Local(RETURN_PLACE)) => {
                         if let Some(BorrowCheckContext {
                             universal_regions:
                                 UniversalRegions {
@@ -1556,7 +1557,8 @@ fn check_call_dest(
                             ConstraintCategory::Return
                         }
                     }
-                    Place::Local(l) if !mir.local_decls[l].is_user_variable.is_some() => {
+                    Place::Base(PlaceBase::Local(l))
+                        if !mir.local_decls[l].is_user_variable.is_some() => {
                         ConstraintCategory::Boring
                     }
                     _ => ConstraintCategory::Assignment,
@@ -1602,10 +1604,17 @@ fn check_call_inputs(
         from_hir_call: bool,
     ) {
         debug!("check_call_inputs({:?}, {:?})", sig, args);
-        if args.len() < sig.inputs().len() || (args.len() > sig.inputs().len() && !sig.variadic) {
+        // Do not count the `VaList` argument as a "true" argument to
+        // a C-variadic function.
+        let inputs = if sig.c_variadic {
+            &sig.inputs()[..sig.inputs().len() - 1]
+        } else {
+            &sig.inputs()[..]
+        };
+        if args.len() < inputs.len() || (args.len() > inputs.len() && !sig.c_variadic) {
             span_mirbug!(self, term, "call to {:?} with wrong # of args", sig);
         }
-        for (n, (fn_arg, op_arg)) in sig.inputs().iter().zip(args).enumerate() {
+        for (n, (fn_arg, op_arg)) in inputs.iter().zip(args).enumerate() {
             let op_arg_ty = op_arg.ty(mir, self.tcx());
             let category = if from_hir_call {
                 ConstraintCategory::CallArgument
@@ -2261,7 +2270,7 @@ fn prove_closure_bounds(
         &mut self,
         tcx: TyCtxt<'a, 'gcx, 'tcx>,
         def_id: DefId,
-        substs: &'tcx Substs<'tcx>,
+        substs: SubstsRef<'tcx>,
         location: Location,
     ) -> ty::InstantiatedPredicates<'tcx> {
         if let Some(closure_region_requirements) = tcx.mir_borrowck(def_id).closure_requirements {
index a5bf158257700bd5883978b8e09135f2d95bfac2..4d9a3775b31230f83d94404ca73ff902d17a5cc7 100644 (file)
@@ -17,7 +17,7 @@
 use rustc::hir::{self, BodyOwnerKind, HirId};
 use rustc::infer::{InferCtxt, NLLRegionVariableOrigin};
 use rustc::ty::fold::TypeFoldable;
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::{InternalSubsts, SubstsRef};
 use rustc::ty::{self, ClosureSubsts, GeneratorSubsts, RegionVid, Ty, TyCtxt};
 use rustc::util::nodemap::FxHashMap;
 use rustc_data_structures::indexed_vec::{Idx, IndexVec};
@@ -94,12 +94,12 @@ pub enum DefiningTy<'tcx> {
 
     /// The MIR is a fn item with the given `DefId` and substs. The signature
     /// of the function can be bound then with the `fn_sig` query.
-    FnDef(DefId, &'tcx Substs<'tcx>),
+    FnDef(DefId, SubstsRef<'tcx>),
 
     /// The MIR represents some form of constant. The signature then
     /// is that it has no inputs and a single return value, which is
     /// the value of the constant.
-    Const(DefId, &'tcx Substs<'tcx>),
+    Const(DefId, SubstsRef<'tcx>),
 }
 
 impl<'tcx> DefiningTy<'tcx> {
@@ -138,7 +138,7 @@ struct UniversalRegionIndices<'tcx> {
     /// used because trait matching and type-checking will feed us
     /// region constraints that reference those regions and we need to
     /// be able to map them our internal `RegionVid`. This is
-    /// basically equivalent to a `Substs`, except that it also
+    /// basically equivalent to a `InternalSubsts`, except that it also
     /// contains an entry for `ReStatic` -- it might be nice to just
     /// use a substs, and then handle `ReStatic` another way.
     indices: FxHashMap<ty::Region<'tcx>, RegionVid>,
@@ -222,7 +222,7 @@ pub fn new(
     /// `V[1]: V[2]`.
     pub fn closure_mapping(
         tcx: TyCtxt<'_, '_, 'tcx>,
-        closure_substs: &'tcx Substs<'tcx>,
+        closure_substs: SubstsRef<'tcx>,
         expected_num_vars: usize,
         closure_base_def_id: DefId,
     ) -> IndexVec<RegionVid, ty::Region<'tcx>> {
@@ -507,7 +507,7 @@ fn defining_ty(&self) -> DefiningTy<'tcx> {
 
             BodyOwnerKind::Const | BodyOwnerKind::Static(..) => {
                 assert_eq!(closure_base_def_id, self.mir_def_id);
-                let identity_substs = Substs::identity_for_item(tcx, closure_base_def_id);
+                let identity_substs = InternalSubsts::identity_for_item(tcx, closure_base_def_id);
                 let substs = self.infcx
                     .replace_free_regions_with_nll_infer_vars(FR, &identity_substs);
                 DefiningTy::Const(self.mir_def_id, substs)
@@ -527,7 +527,7 @@ fn compute_indices(
         let tcx = self.infcx.tcx;
         let gcx = tcx.global_tcx();
         let closure_base_def_id = tcx.closure_base_def_id(self.mir_def_id);
-        let identity_substs = Substs::identity_for_item(gcx, closure_base_def_id);
+        let identity_substs = InternalSubsts::identity_for_item(gcx, closure_base_def_id);
         let fr_substs = match defining_ty {
             DefiningTy::Closure(_, ClosureSubsts { ref substs })
             | DefiningTy::Generator(_, GeneratorSubsts { ref substs }, _) => {
index 9073ae6bed5b2963240cadb4abc4b9bb7a35c935..9e0bb93c33a5d5fd0362875adc49b7e8b8c035c5 100644 (file)
@@ -3,7 +3,7 @@
 use crate::borrow_check::Context;
 use crate::borrow_check::AccessDepth;
 use crate::dataflow::indexes::BorrowIndex;
-use rustc::mir::{BasicBlock, Location, Mir, Place};
+use rustc::mir::{BasicBlock, Location, Mir, Place, PlaceBase};
 use rustc::mir::{ProjectionElem, BorrowKind};
 use rustc::ty::TyCtxt;
 use rustc_data_structures::graph::dominators::Dominators;
@@ -138,9 +138,9 @@ pub(super) fn is_active<'tcx>(
 /// This is called for all Yield statements on movable generators
 pub(super) fn borrow_of_local_data<'tcx>(place: &Place<'tcx>) -> bool {
     match place {
-        Place::Promoted(_) |
-        Place::Static(..) => false,
-        Place::Local(..) => true,
+        Place::Base(PlaceBase::Promoted(_)) |
+        Place::Base(PlaceBase::Static(..)) => false,
+        Place::Base(PlaceBase::Local(..)) => true,
         Place::Projection(box proj) => {
             match proj.elem {
                 // Reborrow of already borrowed data is ignored
index d6d2861b557ab1d2956b1526b0ada6358d786ac3..c05ee3cf65b36447f48fb53fd11322dbfdd9c8f7 100644 (file)
@@ -1,6 +1,6 @@
 use rustc::hir;
 use rustc::mir::ProjectionElem;
-use rustc::mir::{Local, Mir, Place, Mutability};
+use rustc::mir::{Local, Mir, Place, PlaceBase, Mutability};
 use rustc::ty::{self, TyCtxt};
 use crate::borrow_check::borrow_set::LocalsStateAtExit;
 
@@ -30,7 +30,7 @@ fn ignore_borrow(
         locals_state_at_exit: &LocalsStateAtExit,
     ) -> bool {
         match self {
-            Place::Promoted(_) => false,
+            Place::Base(PlaceBase::Promoted(_)) => false,
 
             // If a local variable is immutable, then we only need to track borrows to guard
             // against two kinds of errors:
@@ -40,7 +40,7 @@ fn ignore_borrow(
             //
             // In particular, the variable cannot be mutated -- the "access checks" will fail --
             // so we don't have to worry about mutation while borrowed.
-            Place::Local(index) => {
+            Place::Base(PlaceBase::Local(index)) => {
                 match locals_state_at_exit {
                     LocalsStateAtExit::AllAreInvalidated => false,
                     LocalsStateAtExit::SomeAreInvalidated { has_storage_dead_or_moved } => {
@@ -51,7 +51,7 @@ fn ignore_borrow(
                     }
                 }
             }
-            Place::Static(static_) => {
+            Place::Base(PlaceBase::Static(static_)) => {
                 tcx.is_static(static_.def_id) == Some(hir::Mutability::MutMutable)
             }
             Place::Projection(proj) => match proj.elem {
@@ -88,9 +88,9 @@ fn root_local(&self) -> Option<Local> {
         loop {
             match p {
                 Place::Projection(pi) => p = &pi.base,
-                Place::Promoted(_) |
-                Place::Static(_) => return None,
-                Place::Local(l) => return Some(*l),
+                Place::Base(PlaceBase::Promoted(_)) |
+                Place::Base(PlaceBase::Static(_)) => return None,
+                Place::Base(PlaceBase::Local(l)) => return Some(*l),
             }
         }
     }
index b5175cf41dd5c6293d7ba989d40636ab58646ea9..1d18ada1fb69c97dad8b7ace197d65bf6d729d5b 100644 (file)
@@ -2,8 +2,7 @@
 use crate::borrow_check::Overlap;
 use crate::borrow_check::{Deep, Shallow, AccessDepth};
 use rustc::hir;
-use rustc::mir::{BorrowKind, Mir, Place};
-use rustc::mir::{Projection, ProjectionElem};
+use rustc::mir::{BorrowKind, Mir, Place, PlaceBase, Projection, ProjectionElem};
 use rustc::ty::{self, TyCtxt};
 use std::cmp::max;
 
@@ -60,8 +59,8 @@ pub(super) fn borrow_conflicts_with_place<'gcx, 'tcx>(
 
     // This Local/Local case is handled by the more general code below, but
     // it's so common that it's a speed win to check for it first.
-    if let Place::Local(l1) = borrow_place {
-        if let Place::Local(l2) = access_place {
+    if let Place::Base(PlaceBase::Local(l1)) = borrow_place {
+        if let Place::Base(PlaceBase::Local(l2)) = access_place {
             return l1 == l2;
         }
     }
@@ -339,8 +338,8 @@ fn unroll_place<'tcx, R>(
             op,
         ),
 
-        Place::Promoted(_) |
-        Place::Local(_) | Place::Static(_) => {
+        Place::Base(PlaceBase::Promoted(_)) |
+        Place::Base(PlaceBase::Local(_)) | Place::Base(PlaceBase::Static(_)) => {
             let list = PlaceComponents {
                 component: place,
                 next,
@@ -361,7 +360,7 @@ fn place_element_conflict<'a, 'gcx: 'tcx, 'tcx>(
     bias: PlaceConflictBias,
 ) -> Overlap {
     match (elem1, elem2) {
-        (Place::Local(l1), Place::Local(l2)) => {
+        (Place::Base(PlaceBase::Local(l1)), Place::Base(PlaceBase::Local(l2))) => {
             if l1 == l2 {
                 // the same local - base case, equal
                 debug!("place_element_conflict: DISJOINT-OR-EQ-LOCAL");
@@ -372,7 +371,7 @@ fn place_element_conflict<'a, 'gcx: 'tcx, 'tcx>(
                 Overlap::Disjoint
             }
         }
-        (Place::Static(static1), Place::Static(static2)) => {
+        (Place::Base(PlaceBase::Static(static1)), Place::Base(PlaceBase::Static(static2))) => {
             if static1.def_id != static2.def_id {
                 debug!("place_element_conflict: DISJOINT-STATIC");
                 Overlap::Disjoint
@@ -385,7 +384,7 @@ fn place_element_conflict<'a, 'gcx: 'tcx, 'tcx>(
                 Overlap::EqualOrDisjoint
             }
         }
-        (Place::Promoted(p1), Place::Promoted(p2)) => {
+        (Place::Base(PlaceBase::Promoted(p1)), Place::Base(PlaceBase::Promoted(p2))) => {
             if p1.0 == p2.0 {
                 if let ty::Array(_, size) = p1.1.sty {
                     if size.unwrap_usize(tcx) == 0 {
@@ -403,9 +402,12 @@ fn place_element_conflict<'a, 'gcx: 'tcx, 'tcx>(
                 Overlap::Disjoint
             }
         }
-        (Place::Local(_), Place::Promoted(_)) | (Place::Promoted(_), Place::Local(_)) |
-        (Place::Promoted(_), Place::Static(_)) | (Place::Static(_), Place::Promoted(_)) |
-        (Place::Local(_), Place::Static(_)) | (Place::Static(_), Place::Local(_)) => {
+        (Place::Base(PlaceBase::Local(_)), Place::Base(PlaceBase::Promoted(_))) |
+        (Place::Base(PlaceBase::Promoted(_)), Place::Base(PlaceBase::Local(_))) |
+        (Place::Base(PlaceBase::Promoted(_)), Place::Base(PlaceBase::Static(_))) |
+        (Place::Base(PlaceBase::Static(_)), Place::Base(PlaceBase::Promoted(_))) |
+        (Place::Base(PlaceBase::Local(_)), Place::Base(PlaceBase::Static(_))) |
+        (Place::Base(PlaceBase::Static(_)), Place::Base(PlaceBase::Local(_))) => {
             debug!("place_element_conflict: DISJOINT-STATIC-LOCAL-PROMOTED");
             Overlap::Disjoint
         }
index c3a8381cd5810c0f373e99b23786abb227d1b465..384fd5c9987b8a325103bec4fa2c79fd473c37bd 100644 (file)
@@ -11,7 +11,7 @@
 
 use rustc::hir;
 use rustc::ty::{self, TyCtxt};
-use rustc::mir::{Mir, Place, ProjectionElem};
+use rustc::mir::{Mir, Place, PlaceBase, ProjectionElem};
 
 pub trait IsPrefixOf<'tcx> {
     fn is_prefix_of(&self, other: &Place<'tcx>) -> bool;
@@ -26,8 +26,9 @@ fn is_prefix_of(&self, other: &Place<'tcx>) -> bool {
             }
 
             match *cursor {
-                Place::Promoted(_) |
-                Place::Local(_) | Place::Static(_) => return false,
+                Place::Base(PlaceBase::Promoted(_)) |
+                Place::Base(PlaceBase::Local(_)) |
+                Place::Base(PlaceBase::Static(_)) => return false,
                 Place::Projection(ref proj) => {
                     cursor = &proj.base;
                 }
@@ -86,9 +87,9 @@ fn next(&mut self) -> Option<Self::Item> {
 
         'cursor: loop {
             let proj = match *cursor {
-                Place::Promoted(_) |
-                Place::Local(_) | // search yielded this leaf
-                Place::Static(_) => {
+                Place::Base(PlaceBase::Promoted(_)) |
+                Place::Base(PlaceBase::Local(_)) | // search yielded this leaf
+                Place::Base(PlaceBase::Static(_)) => {
                     self.next = None;
                     return Some(cursor);
                 }
index 8c7359bdee768f0f9f3611430fa561c0f8cfd811..b102bced0e335e18822f3a7d7019d464ae5297e3 100644 (file)
@@ -1,5 +1,7 @@
 use rustc::mir::visit::{PlaceContext, Visitor};
-use rustc::mir::{BasicBlock, Local, Location, Place, Statement, StatementKind, TerminatorKind};
+use rustc::mir::{
+    BasicBlock, Local, Location, Place, PlaceBase, Statement, StatementKind, TerminatorKind
+};
 
 use rustc_data_structures::fx::FxHashSet;
 
@@ -114,7 +116,7 @@ fn visit_local(
                     "assignment of {:?} to {:?}, adding {:?} to used mutable set",
                     path.place, local, path.place
                 );
-                if let Place::Local(user_local) = path.place {
+                if let Place::Base(PlaceBase::Local(user_local)) = path.place {
                     self.mbcx.used_mut.insert(user_local);
                 }
             }
index 38fae8539c8d71bef80656516b0ab1c6860b3cc1..e354a2ee8160b47f1f17c40b8561df9eb14e82e4 100644 (file)
@@ -74,7 +74,7 @@ fn expr_as_operand(
             }
             Category::Place | Category::Rvalue(..) => {
                 let operand = unpack!(block = this.as_temp(block, scope, expr, Mutability::Mut));
-                block.and(Operand::Move(Place::Local(operand)))
+                block.and(Operand::Move(Place::Base(PlaceBase::Local(operand))))
             }
         }
     }
index ed444191226a1ddef18c7fb89a6457498d921d3d..3bea88024b3f93e11f319f40e4dcfa18e543c558 100644 (file)
@@ -98,19 +98,19 @@ fn expr_as_place(
                     &lt,
                     Rvalue::BinaryOp(
                         BinOp::Lt,
-                        Operand::Copy(Place::Local(idx)),
+                        Operand::Copy(Place::Base(PlaceBase::Local(idx))),
                         Operand::Copy(len.clone()),
                     ),
                 );
 
                 let msg = BoundsCheck {
                     len: Operand::Move(len),
-                    index: Operand::Copy(Place::Local(idx)),
+                    index: Operand::Copy(Place::Base(PlaceBase::Local(idx))),
                 };
                 let success = this.assert(block, Operand::Move(lt), true, msg, expr_span);
                 success.and(slice.index(idx))
             }
-            ExprKind::SelfRef => block.and(Place::Local(Local::new(1))),
+            ExprKind::SelfRef => block.and(Place::Base(PlaceBase::Local(Local::new(1)))),
             ExprKind::VarRef { id } => {
                 let place = if this.is_bound_var_in_guard(id) && this
                     .hir
@@ -118,17 +118,17 @@ fn expr_as_place(
                     .all_pat_vars_are_implicit_refs_within_guards()
                 {
                     let index = this.var_local_id(id, RefWithinGuard);
-                    Place::Local(index).deref()
+                    Place::Base(PlaceBase::Local(index)).deref()
                 } else {
                     let index = this.var_local_id(id, OutsideGuard);
-                    Place::Local(index)
+                    Place::Base(PlaceBase::Local(index))
                 };
                 block.and(place)
             }
-            ExprKind::StaticRef { id } => block.and(Place::Static(Box::new(Static {
+            ExprKind::StaticRef { id } => block.and(Place::Base(PlaceBase::Static(Box::new(Static {
                 def_id: id,
                 ty: expr.ty,
-            }))),
+            })))),
 
             ExprKind::PlaceTypeAscription { source, user_ty } => {
                 let place = unpack!(block = this.as_place(block, source));
@@ -172,14 +172,14 @@ fn expr_as_place(
                         Statement {
                             source_info,
                             kind: StatementKind::AscribeUserType(
-                                Place::Local(temp.clone()),
+                                Place::Base(PlaceBase::Local(temp.clone())),
                                 Variance::Invariant,
                                 box UserTypeProjection { base: annotation_index, projs: vec![], },
                             ),
                         },
                     );
                 }
-                block.and(Place::Local(temp))
+                block.and(Place::Base(PlaceBase::Local(temp)))
             }
 
             ExprKind::Array { .. }
@@ -219,7 +219,7 @@ fn expr_as_place(
                 });
                 let temp =
                     unpack!(block = this.as_temp(block, expr.temp_lifetime, expr, mutability));
-                block.and(Place::Local(temp))
+                block.and(Place::Base(PlaceBase::Local(temp)))
             }
         }
     }
index 88dbd93939e547885fa043cc83521d2e975d363d..b00d1c612edf38c0bee77e94c7e79f6ef38a951a 100644 (file)
@@ -127,7 +127,7 @@ fn expr_as_rvalue(
                     this.schedule_drop_storage_and_value(
                         expr_span,
                         scope,
-                        &Place::Local(result),
+                        &Place::Base(PlaceBase::Local(result)),
                         value.ty,
                     );
                 }
@@ -135,11 +135,16 @@ fn expr_as_rvalue(
                 // malloc some memory of suitable type (thus far, uninitialized):
                 let box_ = Rvalue::NullaryOp(NullOp::Box, value.ty);
                 this.cfg
-                    .push_assign(block, source_info, &Place::Local(result), box_);
+                    .push_assign(block, source_info, &Place::Base(PlaceBase::Local(result)), box_);
 
                 // initialize the box contents:
-                unpack!(block = this.into(&Place::Local(result).deref(), block, value));
-                block.and(Rvalue::Use(Operand::Move(Place::Local(result))))
+                unpack!(
+                    block = this.into(
+                        &Place::Base(PlaceBase::Local(result)).deref(),
+                        block, value
+                    )
+                );
+                block.and(Rvalue::Use(Operand::Move(Place::Base(PlaceBase::Local(result)))))
             }
             ExprKind::Cast { source } => {
                 let source = this.hir.mirror(source);
@@ -522,9 +527,9 @@ fn limit_capture_mutability(
         let arg_place = unpack!(block = this.as_place(block, arg));
 
         let mutability = match arg_place {
-            Place::Local(local) => this.local_decls[local].mutability,
+            Place::Base(PlaceBase::Local(local)) => this.local_decls[local].mutability,
             Place::Projection(box Projection {
-                base: Place::Local(local),
+                base: Place::Base(PlaceBase::Local(local)),
                 elem: ProjectionElem::Deref,
             }) => {
                 debug_assert!(
@@ -554,11 +559,11 @@ fn limit_capture_mutability(
                 // Not projected from the implicit `self` in a closure.
                 debug_assert!(
                     match *base {
-                        Place::Local(local) => local == Local::new(1),
+                        Place::Base(PlaceBase::Local(local)) => local == Local::new(1),
                         Place::Projection(box Projection {
                             ref base,
                             elem: ProjectionElem::Deref,
-                        }) => *base == Place::Local(Local::new(1)),
+                        }) => *base == Place::Base(PlaceBase::Local(Local::new(1))),
                         _ => false,
                     },
                     "Unexpected capture place"
@@ -583,7 +588,7 @@ fn limit_capture_mutability(
         this.cfg.push_assign(
             block,
             source_info,
-            &Place::Local(temp),
+            &Place::Base(PlaceBase::Local(temp)),
             Rvalue::Ref(this.hir.tcx().types.re_erased, borrow_kind, arg_place),
         );
 
@@ -594,12 +599,12 @@ fn limit_capture_mutability(
             this.schedule_drop_storage_and_value(
                 upvar_span,
                 temp_lifetime,
-                &Place::Local(temp),
+                &Place::Base(PlaceBase::Local(temp)),
                 upvar_ty,
             );
         }
 
-        block.and(Operand::Move(Place::Local(temp)))
+        block.and(Operand::Move(Place::Base(PlaceBase::Local(temp))))
     }
 
     // Helper to get a `-1` value of the appropriate type
index efa1a4895e0c064dc8128579e06efe93c23ea485..cba771f27065d93cd6649f94ee44bfccfd3a2a43 100644 (file)
@@ -73,7 +73,7 @@ fn expr_as_temp(
             );
         }
 
-        unpack!(block = this.into(&Place::Local(temp), block, expr));
+        unpack!(block = this.into(&Place::Base(PlaceBase::Local(temp)), block, expr));
 
         // In constants, temp_lifetime is None for temporaries that live for the
         // 'static lifetime. Thus we do not drop these temporaries and simply leak them.
@@ -88,7 +88,7 @@ fn expr_as_temp(
             this.schedule_drop_storage_and_value(
                 expr_span,
                 temp_lifetime,
-                &Place::Local(temp),
+                &Place::Base(PlaceBase::Local(temp)),
                 expr_ty,
             );
         }
index 07db67a6ae00ff738e23275ae507ec31ad1cac1d..d9839e0c6ec5a88871f146d3999637869062067c 100644 (file)
@@ -295,7 +295,7 @@ pub fn into_expr(
                         is_user_variable: None,
                         is_block_tail: None,
                     });
-                    let ptr_temp = Place::Local(ptr_temp);
+                    let ptr_temp = Place::Base(PlaceBase::Local(ptr_temp));
                     let block = unpack!(this.into(&ptr_temp, block, ptr));
                     this.into(&ptr_temp.deref(), block, val)
                 } else {
index aadc2368f5aec7adddbc1ef85efcbcd6434d51e8..9527a23279570a060ec8fe07c23998b993f9fb9f 100644 (file)
@@ -139,13 +139,22 @@ pub fn stmt_expr(&mut self,
                     Some(value) => {
                         debug!("stmt_expr Return val block_context.push(SubExpr) : {:?}", expr2);
                         this.block_context.push(BlockFrame::SubExpr);
-                        let result = unpack!(this.into(&Place::Local(RETURN_PLACE), block, value));
+                        let result = unpack!(
+                            this.into(
+                                &Place::RETURN_PLACE,
+                                block,
+                                value
+                            )
+                        );
                         this.block_context.pop();
                         result
                     }
                     None => {
-                        this.cfg
-                            .push_assign_unit(block, source_info, &Place::Local(RETURN_PLACE));
+                        this.cfg.push_assign_unit(
+                            block,
+                            source_info,
+                            &Place::RETURN_PLACE,
+                        );
                         block
                     }
                 };
@@ -226,7 +235,7 @@ pub fn stmt_expr(&mut self,
                         }
                     }
                     let temp = this.local_decls.push(local_decl);
-                    let place = Place::Local(temp);
+                    let place = Place::Base(PlaceBase::Local(temp));
                     debug!("created temp {:?} for expr {:?} in block_context: {:?}",
                            temp, expr, this.block_context);
                     place
index 2c4eb0bc091c3c18b9c49f1954601394a756113d..8f1301b743e9d52c1394f6e1c7916562ae214922 100644 (file)
@@ -543,7 +543,7 @@ pub fn storage_live_binding(
                 kind: StatementKind::StorageLive(local_id),
             },
         );
-        let place = Place::Local(local_id);
+        let place = Place::Base(PlaceBase::Local(local_id));
         let var_ty = self.local_decls[local_id].ty;
         let hir_id = self.hir.tcx().hir().node_to_hir_id(var);
         let region_scope = self.hir.region_scope_tree.var_scope(hir_id.local_id);
@@ -559,7 +559,7 @@ pub fn schedule_drop_for_binding(&mut self, var: NodeId, span: Span, for_guard:
         self.schedule_drop(
             span,
             region_scope,
-            &Place::Local(local_id),
+            &Place::Base(PlaceBase::Local(local_id)),
             var_ty,
             DropKind::Value {
                 cached_block: CachedBlock::default(),
@@ -1452,7 +1452,7 @@ fn bind_and_guard_matched_candidate<'pat>(
                 self.cfg.push_assign(
                     block,
                     scrutinee_source_info,
-                    &Place::Local(temp),
+                    &Place::Base(PlaceBase::Local(temp)),
                     borrow,
                 );
             }
@@ -1478,7 +1478,7 @@ fn bind_and_guard_matched_candidate<'pat>(
                     source_info: guard_end,
                     kind: StatementKind::FakeRead(
                         FakeReadCause::ForMatchGuard,
-                        Place::Local(temp),
+                        Place::Base(PlaceBase::Local(temp)),
                     ),
                 });
             }
@@ -1529,7 +1529,7 @@ fn bind_and_guard_matched_candidate<'pat>(
                 // place they refer to can't be modified by the guard.
                 for binding in by_value_bindings.clone() {
                     let local_id = self.var_local_id(binding.var_id, RefWithinGuard);
-                    let place = Place::Local(local_id);
+                    let place = Place::Base(PlaceBase::Local(local_id));
                     self.cfg.push(
                         block,
                         Statement {
index 900f7f1744a134839e45d91653d56e1576b99112..2692c24806ff7c861371e34b83c0f5691f98eba2 100644 (file)
@@ -16,7 +16,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
     /// call `schedule_drop` once the temporary is initialized.
     pub fn temp(&mut self, ty: Ty<'tcx>, span: Span) -> Place<'tcx> {
         let temp = self.local_decls.push(LocalDecl::new_temp(ty, span));
-        let place = Place::Local(temp);
+        let place = Place::Base(PlaceBase::Local(temp));
         debug!("temp: created temp {:?} with type {:?}",
                place, self.local_decls[temp].ty);
         place
index a9a16024302e9354f2aae658e1ee3f56e6c72711..e4f85887841ebcc4f488ecb7f0860f028c326fb0 100644 (file)
@@ -12,7 +12,7 @@
 use rustc::mir::*;
 use rustc::mir::visit::{MutVisitor, TyContext};
 use rustc::ty::{self, Ty, TyCtxt};
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::SubstsRef;
 use rustc::util::nodemap::NodeMap;
 use rustc_target::spec::PanicStrategy;
 use rustc_data_structures::indexed_vec::{IndexVec, Idx};
@@ -212,7 +212,7 @@ fn visit_const(&mut self, constant: &mut &'tcx ty::LazyConst<'tcx>, _: Location)
         }
     }
 
-    fn visit_substs(&mut self, substs: &mut &'tcx Substs<'tcx>, _: Location) {
+    fn visit_substs(&mut self, substs: &mut SubstsRef<'tcx>, _: Location) {
         if let Some(lifted) = self.tcx.lift(substs) {
             *substs = lifted;
         } else {
@@ -741,7 +741,7 @@ fn construct_const<'a, 'gcx, 'tcx>(
 
     let mut block = START_BLOCK;
     let expr = builder.hir.mirror(ast_expr);
-    unpack!(block = builder.into_expr(&Place::Local(RETURN_PLACE), block, expr));
+    unpack!(block = builder.into_expr(&Place::RETURN_PLACE, block, expr));
 
     let source_info = builder.source_info(span);
     builder.cfg.terminate(block, source_info, TerminatorKind::Return);
@@ -887,7 +887,7 @@ fn args_and_body(&mut self,
         for (index, arg_info) in arguments.iter().enumerate() {
             // Function arguments always get the first Local indices after the return place
             let local = Local::new(index + 1);
-            let place = Place::Local(local);
+            let place = Place::Base(PlaceBase::Local(local));
             let &ArgInfo(ty, opt_ty_info, pattern, ref self_binding) = arg_info;
 
             // Make sure we drop (parts of) the argument even when not matched on.
@@ -936,7 +936,7 @@ fn args_and_body(&mut self,
         }
 
         let body = self.hir.mirror(ast_body);
-        self.into(&Place::Local(RETURN_PLACE), block, body)
+        self.into(&Place::RETURN_PLACE, block, body)
     }
 
     fn get_unit_temp(&mut self) -> Place<'tcx> {
index 71acf747d085606e971d635034f9bf0f7efab2d1..4189e3e7ddbb6f92bca0a4eed7b2a7da65068396 100644 (file)
@@ -662,7 +662,7 @@ pub fn schedule_drop(
             DropKind::Value { .. } => if !needs_drop { return },
             DropKind::Storage => {
                 match *place {
-                    Place::Local(index) => if index.index() <= self.arg_count {
+                    Place::Base(PlaceBase::Local(index)) => if index.index() <= self.arg_count {
                         span_bug!(
                             span, "`schedule_drop` called with index {} and arg_count {}",
                             index.index(),
@@ -936,7 +936,7 @@ fn build_scope_drops<'tcx>(
                 // Drop the storage for both value and storage drops.
                 // Only temps and vars need their storage dead.
                 match drop_data.location {
-                    Place::Local(index) if index.index() > arg_count => {
+                    Place::Base(PlaceBase::Local(index)) if index.index() > arg_count => {
                         cfg.push(block, Statement {
                             source_info,
                             kind: StatementKind::StorageDead(index)
index 151a004dce9426aca4c25cf77ab9f8b0ba17da8d..f78c82a93020ce3bb7bf891864c93e47b079f00c 100644 (file)
@@ -163,7 +163,7 @@ pub(crate) fn drop_flag_effects_for_function_entry<'a, 'gcx, 'tcx, F>(
 {
     let move_data = &ctxt.move_data;
     for arg in mir.args_iter() {
-        let place = mir::Place::Local(arg);
+        let place = mir::Place::Base(mir::PlaceBase::Local(arg));
         let lookup_result = move_data.rev_lookup.find(&place);
         on_lookup_result_bits(tcx, mir, move_data,
                               lookup_result,
index 51d628ce6c5c28b5ee59b92d9b7849e3c15052e4..b9c8879b3c36429c5317bbba2607b3b536acecf1 100644 (file)
@@ -92,9 +92,9 @@ struct BorrowedLocalsVisitor<'b, 'c: 'b> {
 
 fn find_local<'tcx>(place: &Place<'tcx>) -> Option<Local> {
     match *place {
-        Place::Local(l) => Some(l),
-        Place::Promoted(_) |
-        Place::Static(..) => None,
+        Place::Base(PlaceBase::Local(l)) => Some(l),
+        Place::Base(PlaceBase::Promoted(_)) |
+        Place::Base(PlaceBase::Static(..)) => None,
         Place::Projection(ref proj) => {
             match proj.elem {
                 ProjectionElem::Deref => None,
index beb0b3187082b410f1f0b71bbf4dacf19f27b916..b47aff3a4f8557ea19bd6174bcf53ff83193fcf0 100644 (file)
@@ -1,7 +1,7 @@
 use crate::borrow_check::borrow_set::{BorrowSet, BorrowData};
 use crate::borrow_check::place_ext::PlaceExt;
 
-use rustc::mir::{self, Location, Place, Mir};
+use rustc::mir::{self, Location, Place, PlaceBase, Mir};
 use rustc::ty::TyCtxt;
 use rustc::ty::RegionVid;
 
@@ -189,7 +189,7 @@ fn kill_borrows_on_place(
     ) {
         debug!("kill_borrows_on_place: place={:?}", place);
         // Handle the `Place::Local(..)` case first and exit early.
-        if let Place::Local(local) = place {
+        if let Place::Base(PlaceBase::Local(local)) = place {
             if let Some(borrow_indices) = self.borrow_set.local_map.get(&local) {
                 debug!("kill_borrows_on_place: borrow_indices={:?}", borrow_indices);
                 sets.kill_all(borrow_indices);
@@ -285,7 +285,7 @@ fn statement_effect(&self, sets: &mut BlockSets<'_, BorrowIndex>, location: Loca
             mir::StatementKind::StorageDead(local) => {
                 // Make sure there are no remaining borrows for locals that
                 // are gone out of scope.
-                self.kill_borrows_on_place(sets, &Place::Local(local));
+                self.kill_borrows_on_place(sets, &Place::Base(PlaceBase::Local(local)));
             }
 
             mir::StatementKind::InlineAsm { ref outputs, ref asm, .. } => {
index cc92ebfab89b76f84d8c734a50f77a00cf86da4e..4dcfb3f1a7fc32a9d01dda14d6bc64848ab451b3 100644 (file)
@@ -493,7 +493,8 @@ fn statement_effect(&self,
                 // storagedeads after everything ends, so if we don't regard the
                 // storagelive as killing storage, we would have a multiple assignment
                 // to immutable data error.
-                if let LookupResult::Exact(mpi) = rev_lookup.find(&mir::Place::Local(local)) {
+                if let LookupResult::Exact(mpi) =
+                    rev_lookup.find(&mir::Place::Base(mir::PlaceBase::Local(local))) {
                     debug!("stmt {:?} at loc {:?} clears the ever initialized status of {:?}",
                            stmt, location, &init_path_map[mpi]);
                     sets.kill_all(&init_path_map[mpi]);
index 1ae050654b4b00af265227873e37db1a03ae9c58..7a9140bce6288f3faef7fe6f1bcd2b5a3463da1f 100644 (file)
@@ -33,13 +33,13 @@ fn new(mir: &'a Mir<'tcx>, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Self {
                 moves: IndexVec::new(),
                 loc_map: LocationMap::new(mir),
                 rev_lookup: MovePathLookup {
-                    locals: mir.local_decls.indices().map(Place::Local).map(|v| {
+                    locals: mir.local_decls.indices().map(PlaceBase::Local).map(|v| {
                         Self::new_move_path(
                             &mut move_paths,
                             &mut path_map,
                             &mut init_path_map,
                             None,
-                            v,
+                            Place::Base(v),
                         )
                     }).collect(),
                     projections: Default::default(),
@@ -96,9 +96,9 @@ fn move_path_for(&mut self, place: &Place<'tcx>)
     {
         debug!("lookup({:?})", place);
         match *place {
-            Place::Local(local) => Ok(self.builder.data.rev_lookup.locals[local]),
-            Place::Promoted(..) |
-            Place::Static(..) => {
+            Place::Base(PlaceBase::Local(local)) => Ok(self.builder.data.rev_lookup.locals[local]),
+            Place::Base(PlaceBase::Promoted(..)) |
+            Place::Base(PlaceBase::Static(..)) => {
                 Err(MoveError::cannot_move_out_of(self.loc, Static))
             }
             Place::Projection(ref proj) => {
@@ -285,7 +285,7 @@ fn gather_statement(&mut self, stmt: &Statement<'tcx>) {
             }
             StatementKind::StorageLive(_) => {}
             StatementKind::StorageDead(local) => {
-                self.gather_move(&Place::Local(local));
+                self.gather_move(&Place::Base(PlaceBase::Local(local)));
             }
             StatementKind::SetDiscriminant{ .. } => {
                 span_bug!(stmt.source_info.span,
@@ -345,7 +345,7 @@ fn gather_terminator(&mut self, term: &Terminator<'tcx>) {
             TerminatorKind::Unreachable => { }
 
             TerminatorKind::Return => {
-                self.gather_move(&Place::Local(RETURN_PLACE));
+                self.gather_move(&Place::RETURN_PLACE);
             }
 
             TerminatorKind::Assert { ref cond, .. } => {
index efd979a7da4fb469b174c41acce5afd3e0bb4ef7..0c29ea8ab4afac8c53dd1a89ac90bea0ee70e955 100644 (file)
@@ -273,9 +273,9 @@ impl<'tcx> MovePathLookup<'tcx> {
     // parent.
     pub fn find(&self, place: &Place<'tcx>) -> LookupResult {
         match *place {
-            Place::Local(local) => LookupResult::Exact(self.locals[local]),
-            Place::Promoted(_) |
-            Place::Static(..) => LookupResult::Parent(None),
+            Place::Base(PlaceBase::Local(local)) => LookupResult::Exact(self.locals[local]),
+            Place::Base(PlaceBase::Promoted(_)) |
+            Place::Base(PlaceBase::Static(..)) => LookupResult::Parent(None),
             Place::Projection(ref proj) => {
                 match self.find(&proj.base) {
                     LookupResult::Exact(base_path) => {
@@ -347,7 +347,7 @@ pub fn gather_moves(mir: &Mir<'tcx>, tcx: TyCtxt<'a, 'gcx, 'tcx>)
     pub fn base_local(&self, mut mpi: MovePathIndex) -> Option<Local> {
         loop {
             let path = &self.move_paths[mpi];
-            if let Place::Local(l) = path.place { return Some(l); }
+            if let Place::Base(PlaceBase::Local(l)) = path.place { return Some(l); }
             if let Some(parent) = path.parent { mpi = parent; continue } else { return None }
         }
     }
index 699ef7138cd936f2d6a450eec6dbf6d0834a529b..0751af9b12affe41a2868170cbeb9e566bc153a8 100644 (file)
@@ -9,6 +9,7 @@
 use rustc::ty::{self, AdtKind, Ty};
 use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow, AutoBorrowMutability};
 use rustc::ty::cast::CastKind as TyCastKind;
+use rustc::ty::subst::{InternalSubsts, SubstsRef};
 use rustc::hir;
 use rustc::hir::def_id::LocalDefId;
 use rustc::mir::BorrowKind;
@@ -559,8 +560,8 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
 
         // Now comes the rote stuff:
         hir::ExprKind::Repeat(ref v, ref count) => {
-            let def_id = cx.tcx.hir().local_def_id(count.id);
-            let substs = Substs::identity_for_item(cx.tcx.global_tcx(), def_id);
+            let def_id = cx.tcx.hir().local_def_id_from_hir_id(count.hir_id);
+            let substs = InternalSubsts::identity_for_item(cx.tcx.global_tcx(), def_id);
             let instance = ty::Instance::resolve(
                 cx.tcx.global_tcx(),
                 cx.param_env,
@@ -716,7 +717,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
                         Some(did) => {
                             // in case we are offsetting from a computed discriminant
                             // and not the beginning of discriminants (which is always `0`)
-                            let substs = Substs::identity_for_item(cx.tcx(), did);
+                            let substs = InternalSubsts::identity_for_item(cx.tcx(), did);
                             let lhs = mk_const(ty::LazyConst::Unevaluated(did, substs));
                             let bin = ExprKind::Binary {
                                 op: BinOp::Add,
@@ -834,7 +835,7 @@ fn method_callee<'a, 'gcx, 'tcx>(
     cx: &mut Cx<'a, 'gcx, 'tcx>,
     expr: &hir::Expr,
     span: Span,
-    overloaded_callee: Option<(DefId, &'tcx Substs<'tcx>)>,
+    overloaded_callee: Option<(DefId, SubstsRef<'tcx>)>,
 ) -> Expr<'tcx> {
     let temp_lifetime = cx.region_scope_tree.temporary_scope(expr.hir_id.local_id);
     let (def_id, substs, user_ty) = match overloaded_callee {
@@ -1133,7 +1134,7 @@ fn overloaded_place<'a, 'gcx, 'tcx>(
     cx: &mut Cx<'a, 'gcx, 'tcx>,
     expr: &'tcx hir::Expr,
     place_ty: Ty<'tcx>,
-    overloaded_callee: Option<(DefId, &'tcx Substs<'tcx>)>,
+    overloaded_callee: Option<(DefId, SubstsRef<'tcx>)>,
     args: Vec<ExprRef<'tcx>>,
 ) -> ExprKind<'tcx> {
     // For an overloaded *x or x[y] expression of type T, the method
index 9e19badf49db0591040ae5732149c3fb576525dc..70f04fb892866814111092e3af74106b6f4a9323 100644 (file)
@@ -12,7 +12,7 @@
 use rustc::infer::InferCtxt;
 use rustc::ty::subst::Subst;
 use rustc::ty::{self, Ty, TyCtxt};
-use rustc::ty::subst::{Kind, Substs};
+use rustc::ty::subst::{Kind, InternalSubsts};
 use rustc::ty::layout::VariantIdx;
 use syntax::ast;
 use syntax::attr;
@@ -29,8 +29,8 @@ pub struct Cx<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
     pub root_lint_level: hir::HirId,
     pub param_env: ty::ParamEnv<'gcx>,
 
-    /// Identity `Substs` for use with const-evaluation.
-    pub identity_substs: &'gcx Substs<'gcx>,
+    /// Identity `InternalSubsts` for use with const-evaluation.
+    pub identity_substs: &'gcx InternalSubsts<'gcx>,
 
     pub region_scope_tree: Lrc<region::ScopeTree>,
     pub tables: &'a ty::TypeckTables<'gcx>,
@@ -82,7 +82,7 @@ pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
             infcx,
             root_lint_level: lint_level,
             param_env: tcx.param_env(src_def_id),
-            identity_substs: Substs::identity_for_item(tcx.global_tcx(), src_def_id),
+            identity_substs: InternalSubsts::identity_for_item(tcx.global_tcx(), src_def_id),
             region_scope_tree: tcx.region_scope_tree(src_def_id),
             tables: tcx.typeck_tables_of(src_def_id),
             constness,
index fffa2ed3ec5538cc8928066f842f35fa80e7e058..2efdacd7622c91868e2851f4afcc8a712f4864d8 100644 (file)
@@ -8,7 +8,7 @@
 use rustc::hir::def_id::DefId;
 use rustc::infer::canonical::Canonical;
 use rustc::middle::region;
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::SubstsRef;
 use rustc::ty::{AdtDef, UpvarSubsts, Ty, Const, LazyConst, UserType};
 use rustc::ty::layout::VariantIdx;
 use rustc::hir;
@@ -261,7 +261,7 @@ pub enum ExprKind<'tcx> {
     Adt {
         adt_def: &'tcx AdtDef,
         variant_index: VariantIdx,
-        substs: &'tcx Substs<'tcx>,
+        substs: SubstsRef<'tcx>,
 
         /// Optional user-given substs: for something like `let x =
         /// Bar::<T> { ... }`.
index 10bef53e249c4430993e3581013d81d776b1d11a..9e9a5d0f82ada34712aef90aba9b42f339919e01 100644 (file)
 
 use rustc::hir::def_id::DefId;
 use rustc::hir::RangeEnd;
-use rustc::ty::{self, Ty, TyCtxt, TypeFoldable, Const};
+use rustc::ty::{self, subst::SubstsRef, Ty, TyCtxt, TypeFoldable, Const};
 use rustc::ty::layout::{Integer, IntegerExt, VariantIdx, Size};
 
 use rustc::mir::Field;
@@ -402,7 +402,7 @@ fn is_local(&self, ty: Ty<'tcx>) -> bool {
 
     fn is_variant_uninhabited(&self,
                               variant: &'tcx ty::VariantDef,
-                              substs: &'tcx ty::subst::Substs<'tcx>)
+                              substs: SubstsRef<'tcx>)
                               -> bool
     {
         if self.tcx.features().exhaustive_patterns {
index fff810b0e6f2cce312a087baafb2dfd1f5ba5c3a..0f151cd688df9792182c9dc46f222a62420f7444 100644 (file)
@@ -11,7 +11,7 @@
 use rustc::middle::region;
 use rustc::session::Session;
 use rustc::ty::{self, Ty, TyCtxt};
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::{InternalSubsts, SubstsRef};
 use rustc::lint;
 use rustc_errors::{Applicability, DiagnosticBuilder};
 use rustc::util::common::ErrorReported;
@@ -51,7 +51,7 @@ pub(crate) fn check_match<'a, 'tcx>(
             tables: tcx.body_tables(body_id),
             region_scope_tree: &tcx.region_scope_tree(def_id),
             param_env: tcx.param_env(def_id),
-            identity_substs: Substs::identity_for_item(tcx, def_id),
+            identity_substs: InternalSubsts::identity_for_item(tcx, def_id),
         }.visit_body(tcx.hir().body(body_id));
     })
 }
@@ -64,7 +64,7 @@ struct MatchVisitor<'a, 'tcx: 'a> {
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
     tables: &'a ty::TypeckTables<'tcx>,
     param_env: ty::ParamEnv<'tcx>,
-    identity_substs: &'tcx Substs<'tcx>,
+    identity_substs: SubstsRef<'tcx>,
     region_scope_tree: &'a region::ScopeTree,
 }
 
@@ -346,9 +346,9 @@ fn check_arms<'a, 'tcx>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
                 NotUseful => {
                     match source {
                         hir::MatchSource::IfLetDesugar { .. } => {
-                            cx.tcx.lint_node(
+                            cx.tcx.lint_hir(
                                 lint::builtin::IRREFUTABLE_LET_PATTERNS,
-                                hir_pat.id,
+                                hir_pat.hir_id,
                                 pat.span,
                                 "irrefutable if-let pattern",
                             );
@@ -359,16 +359,16 @@ fn check_arms<'a, 'tcx>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
                             match arm_index {
                                 // The arm with the user-specified pattern.
                                 0 => {
-                                    cx.tcx.lint_node(
+                                    cx.tcx.lint_hir(
                                         lint::builtin::UNREACHABLE_PATTERNS,
-                                        hir_pat.id, pat.span,
+                                        hir_pat.hir_id, pat.span,
                                         "unreachable pattern");
                                 },
                                 // The arm with the wildcard pattern.
                                 1 => {
-                                    cx.tcx.lint_node(
+                                    cx.tcx.lint_hir(
                                         lint::builtin::IRREFUTABLE_LET_PATTERNS,
-                                        hir_pat.id,
+                                        hir_pat.hir_id,
                                         pat.span,
                                         "irrefutable while-let pattern",
                                     );
@@ -379,9 +379,9 @@ fn check_arms<'a, 'tcx>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
 
                         hir::MatchSource::ForLoopDesugar |
                         hir::MatchSource::Normal => {
-                            let mut err = cx.tcx.struct_span_lint_node(
+                            let mut err = cx.tcx.struct_span_lint_hir(
                                 lint::builtin::UNREACHABLE_PATTERNS,
-                                hir_pat.id,
+                                hir_pat.hir_id,
                                 pat.span,
                                 "unreachable pattern",
                             );
index 9e5fdaa8afdf75b87d1359c1a500709b70254f62..d5f2e7a7275e8e54a580880fd5c1bdffa1d8381a 100644 (file)
@@ -16,7 +16,7 @@
 use rustc::mir::interpret::{Scalar, GlobalId, ConstValue, sign_extend};
 use rustc::ty::{self, Region, TyCtxt, AdtDef, Ty, Lift, UserType};
 use rustc::ty::{CanonicalUserType, CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations};
-use rustc::ty::subst::{Substs, Kind};
+use rustc::ty::subst::{SubstsRef, Kind};
 use rustc::ty::layout::VariantIdx;
 use rustc::hir::{self, PatKind, RangeEnd};
 use rustc::hir::def::{Def, CtorKind};
@@ -135,7 +135,7 @@ pub enum PatternKind<'tcx> {
     /// multiple variants.
     Variant {
         adt_def: &'tcx AdtDef,
-        substs: &'tcx Substs<'tcx>,
+        substs: SubstsRef<'tcx>,
         variant_index: VariantIdx,
         subpatterns: Vec<FieldPattern<'tcx>>,
     },
@@ -330,13 +330,13 @@ pub struct PatternContext<'a, 'tcx: 'a> {
     pub tcx: TyCtxt<'a, 'tcx, 'tcx>,
     pub param_env: ty::ParamEnv<'tcx>,
     pub tables: &'a ty::TypeckTables<'tcx>,
-    pub substs: &'tcx Substs<'tcx>,
+    pub substs: SubstsRef<'tcx>,
     pub errors: Vec<PatternError>,
 }
 
 impl<'a, 'tcx> Pattern<'tcx> {
     pub fn from_hir(tcx: TyCtxt<'a, 'tcx, 'tcx>,
-                    param_env_and_substs: ty::ParamEnvAnd<'tcx, &'tcx Substs<'tcx>>,
+                    param_env_and_substs: ty::ParamEnvAnd<'tcx, SubstsRef<'tcx>>,
                     tables: &'a ty::TypeckTables<'tcx>,
                     pat: &'tcx hir::Pat) -> Self {
         let mut pcx = PatternContext::new(tcx, param_env_and_substs, tables);
@@ -352,7 +352,7 @@ pub fn from_hir(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 
 impl<'a, 'tcx> PatternContext<'a, 'tcx> {
     pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>,
-               param_env_and_substs: ty::ParamEnvAnd<'tcx, &'tcx Substs<'tcx>>,
+               param_env_and_substs: ty::ParamEnvAnd<'tcx, SubstsRef<'tcx>>,
                tables: &'a ty::TypeckTables<'tcx>) -> Self {
         PatternContext {
             tcx,
@@ -955,8 +955,7 @@ fn const_to_pat(
         debug!("const_to_pat: cv.ty={:?} span={:?}", cv.ty, span);
         let kind = match cv.ty.sty {
             ty::Float(_) => {
-                let id = self.tcx.hir().hir_to_node_id(id);
-                self.tcx.lint_node(
+                self.tcx.lint_hir(
                     ::rustc::lint::builtin::ILLEGAL_FLOATING_POINT_LITERAL_PATTERN,
                     id,
                     span,
@@ -1093,7 +1092,7 @@ fn super_fold_with<F: PatternFolder<$lt_tcx>>(&self, _: &mut F) -> Self {
 CloneImpls!{ <'tcx>
     Span, Field, Mutability, ast::Name, ast::NodeId, usize, ty::Const<'tcx>,
     Region<'tcx>, Ty<'tcx>, BindingMode, &'tcx AdtDef,
-    &'tcx Substs<'tcx>, &'tcx Kind<'tcx>, UserType<'tcx>,
+    SubstsRef<'tcx>, &'tcx Kind<'tcx>, UserType<'tcx>,
     UserTypeProjection<'tcx>, PatternTypeProjection<'tcx>
 }
 
index 0c1b5d65b8b68b56507e715841394692410ccafe..8a32c3b636c71242eea742f4e549e5a196e5d771 100644 (file)
@@ -9,7 +9,7 @@
 use rustc::ty::layout::{
     self, Size, Align, HasDataLayout, LayoutOf, TyLayout
 };
-use rustc::ty::subst::{Subst, Substs};
+use rustc::ty::subst::{Subst, SubstsRef};
 use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
 use rustc::ty::query::TyCtxtAt;
 use rustc_data_structures::indexed_vec::IndexVec;
@@ -244,7 +244,7 @@ pub(super) fn subst_and_normalize_erasing_regions<T: TypeFoldable<'tcx>>(
     pub(super) fn resolve(
         &self,
         def_id: DefId,
-        substs: &'tcx Substs<'tcx>
+        substs: SubstsRef<'tcx>
     ) -> EvalResult<'tcx, ty::Instance<'tcx>> {
         trace!("resolve: {:?}, {:#?}", def_id, substs);
         trace!("param_env: {:#?}", self.param_env);
@@ -306,7 +306,7 @@ pub(super) fn monomorphize<T: TypeFoldable<'tcx> + Subst<'tcx>>(
     fn monomorphize_with_substs<T: TypeFoldable<'tcx> + Subst<'tcx>>(
         &self,
         t: T,
-        substs: &'tcx Substs<'tcx>
+        substs: SubstsRef<'tcx>
     ) -> T {
         // miri doesn't care about lifetimes, and will choke on some crazy ones
         // let's simply get rid of them
index 474df457f61a2826a9c799599b4835ab932b2aff..979595d6c00095b5b40631aad1c199bc02abac18 100644 (file)
@@ -515,9 +515,10 @@ pub(super) fn eval_place_to_op(
         layout: Option<TyLayout<'tcx>>,
     ) -> EvalResult<'tcx, OpTy<'tcx, M::PointerTag>> {
         use rustc::mir::Place::*;
+        use rustc::mir::PlaceBase;
         let op = match *mir_place {
-            Local(mir::RETURN_PLACE) => return err!(ReadFromReturnPointer),
-            Local(local) => self.access_local(self.frame(), local, layout)?,
+            Base(PlaceBase::Local(mir::RETURN_PLACE)) => return err!(ReadFromReturnPointer),
+            Base(PlaceBase::Local(local)) => self.access_local(self.frame(), local, layout)?,
 
             Projection(ref proj) => {
                 let op = self.eval_place_to_op(&proj.base, None)?;
index 7b66d11131c13fdd09ae365fd491f78ca7533ca2..4df274bc9df97409db818583209e3706f7db4953 100644 (file)
@@ -581,8 +581,9 @@ pub(super) fn eval_place_to_mplace(
         mir_place: &mir::Place<'tcx>
     ) -> EvalResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> {
         use rustc::mir::Place::*;
+        use rustc::mir::PlaceBase;
         Ok(match *mir_place {
-            Promoted(ref promoted) => {
+            Base(PlaceBase::Promoted(ref promoted)) => {
                 let instance = self.frame().instance;
                 self.const_eval_raw(GlobalId {
                     instance,
@@ -590,7 +591,7 @@ pub(super) fn eval_place_to_mplace(
                 })?
             }
 
-            Static(ref static_) => {
+            Base(PlaceBase::Static(ref static_)) => {
                 assert!(!static_.ty.needs_subst());
                 let layout = self.layout_of(static_.ty)?;
                 let instance = ty::Instance::mono(*self.tcx, static_.def_id);
@@ -624,8 +625,9 @@ pub fn eval_place(
         mir_place: &mir::Place<'tcx>
     ) -> EvalResult<'tcx, PlaceTy<'tcx, M::PointerTag>> {
         use rustc::mir::Place::*;
+        use rustc::mir::PlaceBase;
         let place = match *mir_place {
-            Local(mir::RETURN_PLACE) => match self.frame().return_place {
+            Base(PlaceBase::Local(mir::RETURN_PLACE)) => match self.frame().return_place {
                 Some(return_place) =>
                     // We use our layout to verify our assumption; caller will validate
                     // their layout on return.
@@ -635,7 +637,7 @@ pub fn eval_place(
                     },
                 None => return err!(InvalidNullPointerUsage),
             },
-            Local(local) => PlaceTy {
+            Base(PlaceBase::Local(local)) => PlaceTy {
                 place: Place::Local {
                     frame: self.cur_frame(),
                     local,
index c2ee3f5715bd370bafa580a2acbb1522affdaeb2..83469d749870fc669c45dd4f5e14ea4333065f3c 100644 (file)
@@ -352,7 +352,9 @@ fn eval_fn_call(
                     // not advance `caller_iter` for ZSTs.
                     let mut locals_iter = mir.args_iter();
                     while let Some(local) = locals_iter.next() {
-                        let dest = self.eval_place(&mir::Place::Local(local))?;
+                        let dest = self.eval_place(
+                            &mir::Place::Base(mir::PlaceBase::Local(local))
+                        )?;
                         if Some(local) == mir.spread_arg {
                             // Must be a tuple
                             for i in 0..dest.layout.fields.count() {
@@ -371,7 +373,9 @@ fn eval_fn_call(
                     }
                     // Don't forget to check the return type!
                     if let Some(caller_ret) = dest {
-                        let callee_ret = self.eval_place(&mir::Place::Local(mir::RETURN_PLACE))?;
+                        let callee_ret = self.eval_place(
+                            &mir::Place::RETURN_PLACE
+                        )?;
                         if !Self::check_argument_compat(
                             rust_abi,
                             caller_ret.layout,
index 6b6e8fcdc82cf57bcdf46a94bad09ff87d03d450..bfc977c28cd3944af30ce32cda1438906cd1990d 100644 (file)
@@ -5,7 +5,7 @@
 use rustc::lint::builtin::UNCONDITIONAL_RECURSION;
 use rustc::mir::{self, Mir, TerminatorKind};
 use rustc::ty::{AssociatedItem, AssociatedItemContainer, Instance, TyCtxt, TyKind};
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::InternalSubsts;
 
 pub fn check(tcx: TyCtxt<'a, 'tcx, 'tcx>,
              mir: &Mir<'tcx>,
@@ -69,7 +69,7 @@ fn check_fn_for_unconditional_recursion(tcx: TyCtxt<'a, 'tcx, 'tcx>,
             }) => tcx.generics_of(trait_def_id).count(),
             _ => 0
         };
-    let caller_substs = &Substs::identity_for_item(tcx, def_id)[..trait_substs_count];
+    let caller_substs = &InternalSubsts::identity_for_item(tcx, def_id)[..trait_substs_count];
 
     while let Some(bb) = reachable_without_self_call_queue.pop() {
         if visited.contains(bb) {
@@ -129,12 +129,12 @@ fn check_fn_for_unconditional_recursion(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     // no break */ }`) shouldn't be linted unless it actually
     // recurs.
     if !reached_exit_without_self_call && !self_call_locations.is_empty() {
-        let node_id = tcx.hir().as_local_node_id(def_id).unwrap();
-        let sp = tcx.sess.source_map().def_span(tcx.hir().span(node_id));
-        let mut db = tcx.struct_span_lint_node(UNCONDITIONAL_RECURSION,
-                                                node_id,
-                                                sp,
-                                                "function cannot return without recursing");
+        let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
+        let sp = tcx.sess.source_map().def_span(tcx.hir().span_by_hir_id(hir_id));
+        let mut db = tcx.struct_span_lint_hir(UNCONDITIONAL_RECURSION,
+                                              hir_id,
+                                              sp,
+                                              "function cannot return without recursing");
         db.span_label(sp, "cannot return without recursing");
         // offer some help to the programmer.
         for location in &self_call_locations {
index dd7158897b889fb037739645410e0cfb645c8626..a58c69f636d41886292ff989d06282289bfad361 100644 (file)
 use rustc::hir::def_id::{DefId, LOCAL_CRATE};
 use rustc::mir::interpret::{AllocId, ConstValue};
 use rustc::middle::lang_items::{ExchangeMallocFnLangItem, StartFnLangItem};
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::{InternalSubsts, SubstsRef};
 use rustc::ty::{self, TypeFoldable, Ty, TyCtxt, GenericParamDefKind};
 use rustc::ty::adjustment::CustomCoerceUnsized;
 use rustc::session::config::EntryFnType;
@@ -500,7 +500,7 @@ struct MirNeighborCollector<'a, 'tcx: 'a> {
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
     mir: &'a mir::Mir<'tcx>,
     output: &'a mut Vec<MonoItem<'tcx>>,
-    param_substs: &'tcx Substs<'tcx>,
+    param_substs: SubstsRef<'tcx>,
 }
 
 impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
@@ -748,7 +748,7 @@ fn should_monomorphize_locally<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance:
 
     fn is_available_upstream_generic<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                                                def_id: DefId,
-                                               substs: &'tcx Substs<'tcx>)
+                                               substs: SubstsRef<'tcx>)
                                                -> bool {
         debug_assert!(!def_id.is_local());
 
@@ -956,7 +956,7 @@ fn visit_item(&mut self, item: &'v hir::Item) {
                         debug!("RootCollector: ADT drop-glue for {}",
                                def_id_to_string(self.tcx, def_id));
 
-                        let ty = Instance::new(def_id, Substs::empty()).ty(self.tcx);
+                        let ty = Instance::new(def_id, InternalSubsts::empty()).ty(self.tcx);
                         visit_drop_use(self.tcx, ty, true, self.output);
                     }
                 }
@@ -1006,7 +1006,7 @@ fn visit_trait_item(&mut self, _: &'v hir::TraitItem) {
     fn visit_impl_item(&mut self, ii: &'v hir::ImplItem) {
         match ii.node {
             hir::ImplItemKind::Method(hir::MethodSig { .. }, _) => {
-                let def_id = self.tcx.hir().local_def_id(ii.id);
+                let def_id = self.tcx.hir().local_def_id_from_hir_id(ii.hir_id);
                 self.push_if_root(def_id);
             }
             _ => { /* Nothing to do here */ }
@@ -1116,7 +1116,7 @@ fn create_mono_items_for_default_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                         continue;
                     }
 
-                    let substs = Substs::for_item(tcx, method.def_id, |param, _| {
+                    let substs = InternalSubsts::for_item(tcx, method.def_id, |param, _| {
                         match param.kind {
                             GenericParamDefKind::Lifetime => tcx.types.re_erased.into(),
                             GenericParamDefKind::Type {..} => {
@@ -1218,7 +1218,7 @@ fn def_id_to_string<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 fn collect_lazy_const<'a, 'tcx>(
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
     constant: &ty::LazyConst<'tcx>,
-    param_substs: &'tcx Substs<'tcx>,
+    param_substs: SubstsRef<'tcx>,
     output: &mut Vec<MonoItem<'tcx>>,
 ) {
     let (def_id, substs) = match *constant {
index 6e639c3a1179a2fc96490ab24d06a6f73e8c2bd8..059af2dbba944710f23d5e815e6c3d451acf35c8 100644 (file)
@@ -3,7 +3,7 @@
 use rustc::hir::def_id::{DefId, LOCAL_CRATE};
 use rustc::session::config::OptLevel;
 use rustc::ty::{self, Ty, TyCtxt, ClosureSubsts, GeneratorSubsts};
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::{SubstsRef, InternalSubsts};
 use syntax::ast;
 use syntax::attr::InlineAttr;
 use std::fmt::{self, Write};
@@ -151,7 +151,7 @@ fn is_instantiable(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> bool {
         debug!("is_instantiable({:?})", self);
         let (def_id, substs) = match *self.as_mono_item() {
             MonoItem::Fn(ref instance) => (instance.def_id(), instance.substs),
-            MonoItem::Static(def_id) => (def_id, Substs::empty()),
+            MonoItem::Static(def_id) => (def_id, InternalSubsts::empty()),
             // global asm never has predicates
             MonoItem::GlobalAsm(..) => return true
         };
@@ -353,7 +353,7 @@ pub fn push_type_name(&self, t: Ty<'tcx>, output: &mut String, debug: bool) {
                     output.pop();
                 }
 
-                if sig.variadic {
+                if sig.c_variadic {
                     if !sig.inputs().is_empty() {
                         output.push_str(", ...");
                     } else {
@@ -422,7 +422,7 @@ pub fn push_def_path(&self,
     }
 
     fn push_type_params<I>(&self,
-                            substs: &Substs<'tcx>,
+                            substs: SubstsRef<'tcx>,
                             projections: I,
                             output: &mut String,
                             debug: bool)
index d4145b8e47ea27af3f1e8c9542d74bbe205ad50d..adc328f1033ecaf0ed68217a56abf21318de0109 100644 (file)
@@ -4,7 +4,7 @@
 use rustc::mir::*;
 use rustc::ty::{self, Ty, TyCtxt, GenericParamDefKind};
 use rustc::ty::layout::VariantIdx;
-use rustc::ty::subst::{Subst, Substs};
+use rustc::ty::subst::{Subst, InternalSubsts};
 use rustc::ty::query::Providers;
 
 use rustc_data_structures::indexed_vec::{IndexVec, Idx};
@@ -183,7 +183,7 @@ fn build_drop_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     let substs = if let Some(ty) = ty {
         tcx.intern_substs(&[ty.into()])
     } else {
-        Substs::identity_for_item(tcx, def_id)
+        InternalSubsts::identity_for_item(tcx, def_id)
     };
     let sig = tcx.fn_sig(def_id).subst(tcx, substs);
     let sig = tcx.erase_late_bound_regions(&sig);
@@ -221,7 +221,7 @@ fn build_drop_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 
     if let Some(..) = ty {
         // The first argument (index 0), but add 1 for the return value.
-        let dropee_ptr = Place::Local(Local::new(1+0));
+        let dropee_ptr = Place::Base(PlaceBase::Local(Local::new(1+0)));
         if tcx.sess.opts.debugging_opts.mir_emit_retag {
             // Function arguments should be retagged, and we make this one raw.
             mir.basic_blocks_mut()[START_BLOCK].statements.insert(0, Statement {
@@ -317,8 +317,8 @@ fn build_clone_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     let mut builder = CloneShimBuilder::new(tcx, def_id, self_ty);
     let is_copy = self_ty.is_copy_modulo_regions(tcx, tcx.param_env(def_id), builder.span);
 
-    let dest = Place::Local(RETURN_PLACE);
-    let src = Place::Local(Local::new(1+0)).deref();
+    let dest = Place::RETURN_PLACE;
+    let src = Place::Base(PlaceBase::Local(Local::new(1+0))).deref();
 
     match self_ty.sty {
         _ if is_copy => builder.copy_shim(),
@@ -424,10 +424,10 @@ fn make_statement(&self, kind: StatementKind<'tcx>) -> Statement<'tcx> {
     }
 
     fn copy_shim(&mut self) {
-        let rcvr = Place::Local(Local::new(1+0)).deref();
+        let rcvr = Place::Base(PlaceBase::Local(Local::new(1+0))).deref();
         let ret_statement = self.make_statement(
             StatementKind::Assign(
-                Place::Local(RETURN_PLACE),
+                Place::RETURN_PLACE,
                 box Rvalue::Use(Operand::Copy(rcvr))
             )
         );
@@ -436,9 +436,9 @@ fn copy_shim(&mut self) {
 
     fn make_place(&mut self, mutability: Mutability, ty: Ty<'tcx>) -> Place<'tcx> {
         let span = self.span;
-        Place::Local(
+        Place::Base(PlaceBase::Local(
             self.local_decls.push(temp_decl(mutability, ty, span))
-        )
+        ))
     }
 
     fn make_clone_call(
@@ -451,7 +451,7 @@ fn make_clone_call(
     ) {
         let tcx = self.tcx;
 
-        let substs = Substs::for_item(tcx, self.def_id, |param, _| {
+        let substs = InternalSubsts::for_item(tcx, self.def_id, |param, _| {
             match param.kind {
                 GenericParamDefKind::Lifetime => tcx.types.re_erased.into(),
                 GenericParamDefKind::Type {..} => ty.into(),
@@ -546,7 +546,7 @@ fn array_shim(&mut self, dest: Place<'tcx>, src: Place<'tcx>, ty: Ty<'tcx>, len:
         let inits = vec![
             self.make_statement(
                 StatementKind::Assign(
-                    Place::Local(beg),
+                    Place::Base(PlaceBase::Local(beg)),
                     box Rvalue::Use(Operand::Constant(self.make_usize(0)))
                 )
             ),
@@ -564,7 +564,11 @@ fn array_shim(&mut self, dest: Place<'tcx>, src: Place<'tcx>, ty: Ty<'tcx>, len:
         //     BB #3;
         // }
         // BB #4;
-        self.loop_header(Place::Local(beg), end, BasicBlock::new(2), BasicBlock::new(4), false);
+        self.loop_header(Place::Base(PlaceBase::Local(beg)),
+                         end,
+                         BasicBlock::new(2),
+                         BasicBlock::new(4),
+                         false);
 
         // BB #2
         // `dest[i] = Clone::clone(src[beg])`;
@@ -580,10 +584,10 @@ fn array_shim(&mut self, dest: Place<'tcx>, src: Place<'tcx>, ty: Ty<'tcx>, len:
         let statements = vec![
             self.make_statement(
                 StatementKind::Assign(
-                    Place::Local(beg),
+                    Place::Base(PlaceBase::Local(beg)),
                     box Rvalue::BinaryOp(
                         BinOp::Add,
-                        Operand::Copy(Place::Local(beg)),
+                        Operand::Copy(Place::Base(PlaceBase::Local(beg))),
                         Operand::Constant(self.make_usize(1))
                     )
                 )
@@ -603,7 +607,7 @@ fn array_shim(&mut self, dest: Place<'tcx>, src: Place<'tcx>, ty: Ty<'tcx>, len:
         let beg = self.local_decls.push(temp_decl(Mutability::Mut, tcx.types.usize, span));
         let init = self.make_statement(
             StatementKind::Assign(
-                Place::Local(beg),
+                Place::Base(PlaceBase::Local(beg)),
                 box Rvalue::Use(Operand::Constant(self.make_usize(0)))
             )
         );
@@ -614,7 +618,7 @@ fn array_shim(&mut self, dest: Place<'tcx>, src: Place<'tcx>, ty: Ty<'tcx>, len:
         //     BB #8;
         // }
         // BB #9;
-        self.loop_header(Place::Local(beg), Place::Local(end),
+        self.loop_header(Place::Base(PlaceBase::Local(beg)), Place::Base(PlaceBase::Local(end)),
                          BasicBlock::new(7), BasicBlock::new(9), true);
 
         // BB #7 (cleanup)
@@ -630,10 +634,10 @@ fn array_shim(&mut self, dest: Place<'tcx>, src: Place<'tcx>, ty: Ty<'tcx>, len:
         // `goto #6;`
         let statement = self.make_statement(
             StatementKind::Assign(
-                Place::Local(beg),
+                Place::Base(PlaceBase::Local(beg)),
                 box Rvalue::BinaryOp(
                     BinOp::Add,
-                    Operand::Copy(Place::Local(beg)),
+                    Operand::Copy(Place::Base(PlaceBase::Local(beg))),
                     Operand::Constant(self.make_usize(1))
                 )
             )
@@ -718,7 +722,7 @@ fn build_call_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     let source_info = SourceInfo { span, scope: OUTERMOST_SOURCE_SCOPE };
 
     let rcvr_arg = Local::new(1+0);
-    let rcvr_l = Place::Local(rcvr_arg);
+    let rcvr_l = Place::Base(PlaceBase::Local(rcvr_arg));
     let mut statements = vec![];
 
     let rcvr = match rcvr_adjustment {
@@ -748,11 +752,11 @@ fn build_call_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
             statements.push(Statement {
                 source_info,
                 kind: StatementKind::Assign(
-                    Place::Local(ref_rcvr),
+                    Place::Base(PlaceBase::Local(ref_rcvr)),
                     box Rvalue::Ref(tcx.types.re_erased, borrow_kind, rcvr_l)
                 )
             });
-            Operand::Move(Place::Local(ref_rcvr))
+            Operand::Move(Place::Base(PlaceBase::Local(ref_rcvr)))
         }
     };
 
@@ -774,12 +778,12 @@ fn build_call_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 
     if let Some(untuple_args) = untuple_args {
         args.extend(untuple_args.iter().enumerate().map(|(i, ity)| {
-            let arg_place = Place::Local(Local::new(1+1));
+            let arg_place = Place::Base(PlaceBase::Local(Local::new(1+1)));
             Operand::Move(arg_place.field(Field::new(i), *ity))
         }));
     } else {
         args.extend((1..sig.inputs().len()).map(|i| {
-            Operand::Move(Place::Local(Local::new(1+i)))
+            Operand::Move(Place::Base(PlaceBase::Local(Local::new(1+i))))
         }));
     }
 
@@ -797,7 +801,7 @@ fn build_call_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     block(&mut blocks, statements, TerminatorKind::Call {
         func: callee,
         args,
-        destination: Some((Place::Local(RETURN_PLACE),
+        destination: Some((Place::RETURN_PLACE,
                            BasicBlock::new(1))),
         cleanup: if let Adjustment::RefMut = rcvr_adjustment {
             Some(BasicBlock::new(3))
@@ -810,7 +814,7 @@ fn build_call_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     if let Adjustment::RefMut = rcvr_adjustment {
         // BB #1 - drop for Self
         block(&mut blocks, vec![], TerminatorKind::Drop {
-            location: Place::Local(rcvr_arg),
+            location: Place::Base(PlaceBase::Local(rcvr_arg)),
             target: BasicBlock::new(2),
             unwind: None
         }, false);
@@ -820,7 +824,7 @@ fn build_call_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     if let Adjustment::RefMut = rcvr_adjustment {
         // BB #3 - drop if closure panics
         block(&mut blocks, vec![], TerminatorKind::Drop {
-            location: Place::Local(rcvr_arg),
+            location: Place::Base(PlaceBase::Local(rcvr_arg)),
             target: BasicBlock::new(4),
             unwind: None
         }, true);
@@ -892,11 +896,11 @@ pub fn build_adt_ctor<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a, 'gcx, 'tcx>,
         statements: vec![Statement {
             source_info,
             kind: StatementKind::Assign(
-                Place::Local(RETURN_PLACE),
+                Place::RETURN_PLACE,
                 box Rvalue::Aggregate(
                     box AggregateKind::Adt(adt_def, variant_no, substs, None, None),
                     (1..sig.inputs().len()+1).map(|i| {
-                        Operand::Move(Place::Local(Local::new(i)))
+                        Operand::Move(Place::Base(PlaceBase::Local(Local::new(i))))
                     }).collect()
                 )
             )
index 4d4c89b8b6a40a38c35655d5a014c7e7a968ff95..e8528eee0bcab28d3d63f0217475a39ba2938bfc 100644 (file)
@@ -121,10 +121,10 @@ fn add_move_for_packed_drop<'a, 'tcx>(
 
     patch.add_statement(
         loc, StatementKind::StorageLive(temp));
-    patch.add_assign(loc, Place::Local(temp),
+    patch.add_assign(loc, Place::Base(PlaceBase::Local(temp)),
                      Rvalue::Use(Operand::Move(location.clone())));
     patch.patch_terminator(loc.block, TerminatorKind::Drop {
-        location: Place::Local(temp),
+        location: Place::Base(PlaceBase::Local(temp)),
         target: storage_dead_block,
         unwind
     });
index e66c11aa36e0e5d1fba1e51cfc7229d3566efbd5..20b75c5586794e94f67afeee8af46f0c247cb252 100644 (file)
@@ -21,9 +21,9 @@ fn is_stable<'tcx>(
 
     match *place {
         // Locals and statics have stable addresses, for sure
-        Local { .. } |
-        Promoted { .. } |
-        Static { .. } =>
+        Base(PlaceBase::Local { .. }) |
+        Base(PlaceBase::Promoted { .. }) |
+        Base(PlaceBase::Static { .. }) =>
             true,
         // Recurse for projections
         Projection(ref proj) => {
@@ -101,7 +101,7 @@ fn run_pass<'a, 'tcx>(&self,
             };
             // Gather all arguments, skip return value.
             let places = local_decls.iter_enumerated().skip(1).take(arg_count)
-                    .map(|(local, _)| Place::Local(local))
+                    .map(|(local, _)| Place::Base(PlaceBase::Local(local)))
                     .filter(needs_retag)
                     .collect::<Vec<_>>();
             // Emit their retags.
index 3ed63d749cd3558deefafc72f45e550b948aa798..a8816720b28bd6f4dfa8b2868ddba4482954513d 100644 (file)
@@ -241,7 +241,7 @@ fn visit_place(&mut self,
                     );
                 }
                 let old_source_info = self.source_info;
-                if let &Place::Local(local) = base {
+                if let &Place::Base(PlaceBase::Local(local)) = base {
                     if self.mir.local_decls[local].internal {
                         // Internal locals are used in the `move_val_init` desugaring.
                         // We want to check unsafety against the source info of the
@@ -297,13 +297,13 @@ fn visit_place(&mut self,
                 }
                 self.source_info = old_source_info;
             }
-            &Place::Local(..) => {
+            &Place::Base(PlaceBase::Local(..)) => {
                 // locals are safe
             }
-            &Place::Promoted(_) => {
+            &Place::Base(PlaceBase::Promoted(_)) => {
                 bug!("unsafety checking should happen before promotion")
             }
-            &Place::Static(box Static { def_id, ty: _ }) => {
+            &Place::Base(PlaceBase::Static(box Static { def_id, ty: _ })) => {
                 if self.tcx.is_static(def_id) == Some(hir::Mutability::MutMutable) {
                     self.require_unsafe("use of mutable static",
                         "mutable statics can be mutated by multiple threads: aliasing violations \
@@ -553,10 +553,8 @@ fn unsafety_check_result<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
 }
 
 fn unsafe_derive_on_repr_packed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {
-    let lint_node_id = match tcx.hir().as_local_node_id(def_id) {
-        Some(node_id) => node_id,
-        None => bug!("checking unsafety for non-local def id {:?}", def_id)
-    };
+    let lint_hir_id = tcx.hir().as_local_hir_id(def_id).unwrap_or_else(||
+        bug!("checking unsafety for non-local def id {:?}", def_id));
 
     // FIXME: when we make this a hard error, this should have its
     // own error code.
@@ -567,10 +565,10 @@ fn unsafe_derive_on_repr_packed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: D
         "#[derive] can't be used on a #[repr(packed)] struct that \
          does not derive Copy (error E0133)".to_string()
     };
-    tcx.lint_node(SAFE_PACKED_BORROWS,
-                  lint_node_id,
-                  tcx.def_span(def_id),
-                  &message);
+    tcx.lint_hir(SAFE_PACKED_BORROWS,
+                 lint_hir_id,
+                 tcx.def_span(def_id),
+                 &message);
 }
 
 /// Returns the `HirId` for an enclosing scope that is also `unsafe`.
index 8b17904c7b5b0ed30d3d419c6b9d8245717694ec..9febe6af5b1fc1814bb087ef0109fbca7d9baf7b 100644 (file)
@@ -3,14 +3,14 @@
 
 
 use rustc::hir::def::Def;
-use rustc::mir::{Constant, Location, Place, Mir, Operand, Rvalue, Local};
+use rustc::mir::{Constant, Location, Place, PlaceBase, Mir, Operand, Rvalue, Local};
 use rustc::mir::{NullOp, UnOp, StatementKind, Statement, BasicBlock, LocalKind};
 use rustc::mir::{TerminatorKind, ClearCrossCrate, SourceInfo, BinOp, ProjectionElem};
 use rustc::mir::visit::{Visitor, PlaceContext, MutatingUseContext, NonMutatingUseContext};
 use rustc::mir::interpret::{EvalErrorKind, Scalar, GlobalId, EvalResult};
 use rustc::ty::{TyCtxt, self, Instance};
 use syntax::source_map::{Span, DUMMY_SP};
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::InternalSubsts;
 use rustc_data_structures::indexed_vec::IndexVec;
 use rustc::ty::ParamEnv;
 use rustc::ty::layout::{
@@ -267,7 +267,7 @@ fn eval_constant(
 
     fn eval_place(&mut self, place: &Place<'tcx>, source_info: SourceInfo) -> Option<Const<'tcx>> {
         match *place {
-            Place::Local(loc) => self.places[loc].clone(),
+            Place::Base(PlaceBase::Local(loc)) => self.places[loc].clone(),
             Place::Projection(ref proj) => match proj.elem {
                 ProjectionElem::Field(field, _) => {
                     trace!("field proj on {:?}", proj.base);
@@ -282,13 +282,13 @@ fn eval_place(&mut self, place: &Place<'tcx>, source_info: SourceInfo) -> Option
                 // an `Index` projection would throw us off-track.
                 _ => None,
             },
-            Place::Promoted(ref promoted) => {
+            Place::Base(PlaceBase::Promoted(ref promoted)) => {
                 let generics = self.tcx.generics_of(self.source.def_id());
                 if generics.requires_monomorphization(self.tcx) {
                     // FIXME: can't handle code with generics
                     return None;
                 }
-                let substs = Substs::identity_for_item(self.tcx, self.source.def_id());
+                let substs = InternalSubsts::identity_for_item(self.tcx, self.source.def_id());
                 let instance = Instance::new(self.source.def_id(), substs);
                 let cid = GlobalId {
                     instance,
@@ -556,7 +556,7 @@ fn visit_statement(
                 .to_ty(self.tcx);
             if let Ok(place_layout) = self.tcx.layout_of(self.param_env.and(place_ty)) {
                 if let Some(value) = self.const_prop(rval, place_layout, statement.source_info) {
-                    if let Place::Local(local) = *place {
+                    if let Place::Base(PlaceBase::Local(local)) = *place {
                         trace!("checking whether {:?} can be stored to {:?}", value, local);
                         if self.can_const_prop[local] {
                             trace!("storing {:?} to {:?}", value, local);
@@ -591,7 +591,7 @@ fn visit_terminator_kind(
                             while let Place::Projection(ref proj) = *place {
                                 place = &proj.base;
                             }
-                            if let Place::Local(local) = *place {
+                            if let Place::Base(PlaceBase::Local(local)) = *place {
                                 self.places[local] = None;
                             }
                         },
@@ -603,10 +603,10 @@ fn visit_terminator_kind(
                         .unwrap()
                         .source_info
                         .span;
-                    let node_id = self
+                    let hir_id = self
                         .tcx
                         .hir()
-                        .as_local_node_id(self.source.def_id())
+                        .as_local_hir_id(self.source.def_id())
                         .expect("some part of a failing const eval must be local");
                     use rustc::mir::interpret::EvalErrorKind::*;
                     let msg = match msg {
@@ -643,9 +643,9 @@ fn visit_terminator_kind(
                         // Need proper const propagator for these
                         _ => return,
                     };
-                    self.tcx.lint_node(
+                    self.tcx.lint_hir(
                         ::rustc::lint::builtin::CONST_ERR,
-                        node_id,
+                        hir_id,
                         span,
                         &msg,
                     );
index 7d907ca3a215e019f67e6ecb907549e0047452d5..817a2f31c07361859eb358db6e87506901b4813e 100644 (file)
@@ -19,7 +19,9 @@
 //! (non-mutating) use of `SRC`. These restrictions are conservative and may be relaxed in the
 //! future.
 
-use rustc::mir::{Constant, Local, LocalKind, Location, Place, Mir, Operand, Rvalue, StatementKind};
+use rustc::mir::{
+    Constant, Local, LocalKind, Location, Place, PlaceBase, Mir, Operand, Rvalue, StatementKind
+};
 use rustc::mir::visit::MutVisitor;
 use rustc::ty::TyCtxt;
 use crate::transform::{MirPass, MirSource};
@@ -94,8 +96,10 @@ fn run_pass<'a, 'tcx>(&self,
 
                     // That use of the source must be an assignment.
                     match statement.kind {
-                        StatementKind::Assign(Place::Local(local), box Rvalue::Use(ref operand)) if
-                                local == dest_local => {
+                        StatementKind::Assign(
+                            Place::Base(PlaceBase::Local(local)),
+                            box Rvalue::Use(ref operand)
+                        ) if local == dest_local => {
                             let maybe_action = match *operand {
                                 Operand::Copy(ref src_place) |
                                 Operand::Move(ref src_place) => {
@@ -144,12 +148,12 @@ fn eliminate_self_assignments<'tcx>(
             if let Some(stmt) = mir[location.block].statements.get(location.statement_index) {
                 match stmt.kind {
                     StatementKind::Assign(
-                        Place::Local(local),
-                        box Rvalue::Use(Operand::Copy(Place::Local(src_local))),
+                        Place::Base(PlaceBase::Local(local)),
+                        box Rvalue::Use(Operand::Copy(Place::Base(PlaceBase::Local(src_local)))),
                     ) |
                     StatementKind::Assign(
-                        Place::Local(local),
-                        box Rvalue::Use(Operand::Move(Place::Local(src_local))),
+                        Place::Base(PlaceBase::Local(local)),
+                        box Rvalue::Use(Operand::Move(Place::Base(PlaceBase::Local(src_local)))),
                     ) if local == dest_local && dest_local == src_local => {}
                     _ => {
                         continue;
@@ -176,7 +180,7 @@ impl<'tcx> Action<'tcx> {
     fn local_copy(mir: &Mir<'tcx>, def_use_analysis: &DefUseAnalysis<'_>, src_place: &Place<'tcx>)
                   -> Option<Action<'tcx>> {
         // The source must be a local.
-        let src_local = if let Place::Local(local) = *src_place {
+        let src_local = if let Place::Base(PlaceBase::Local(local)) = *src_place {
             local
         } else {
             debug!("  Can't copy-propagate local: source is not a local");
@@ -330,8 +334,8 @@ fn visit_operand(&mut self, operand: &mut Operand<'tcx>, location: Location) {
         self.super_operand(operand, location);
 
         match *operand {
-            Operand::Copy(Place::Local(local)) |
-            Operand::Move(Place::Local(local)) if local == self.dest_local => {}
+            Operand::Copy(Place::Base(PlaceBase::Local(local))) |
+            Operand::Move(Place::Base(PlaceBase::Local(local))) if local == self.dest_local => {}
             _ => return,
         }
 
index 0f8db5f7334bd795652f45429c33f03e5a3dfce8..74175d0149ff481bab145930472726873c61d4dd 100644 (file)
@@ -330,7 +330,7 @@ fn create_drop_flag(&mut self, index: MovePathIndex, span: Span) {
     }
 
     fn drop_flag(&mut self, index: MovePathIndex) -> Option<Place<'tcx>> {
-        self.drop_flags.get(&index).map(|t| Place::Local(*t))
+        self.drop_flags.get(&index).map(|t| Place::Base(PlaceBase::Local(*t)))
     }
 
     /// create a patch that elaborates all drops in the input
@@ -543,7 +543,7 @@ fn set_drop_flag(&mut self, loc: Location, path: MovePathIndex, val: DropFlagSta
         if let Some(&flag) = self.drop_flags.get(&path) {
             let span = self.patch.source_info_for_location(self.mir, loc).span;
             let val = self.constant_bool(span, val.value());
-            self.patch.add_assign(loc, Place::Local(flag), val);
+            self.patch.add_assign(loc, Place::Base(PlaceBase::Local(flag)), val);
         }
     }
 
@@ -552,7 +552,7 @@ fn drop_flags_on_init(&mut self) {
         let span = self.patch.source_info_for_location(self.mir, loc).span;
         let false_ = self.constant_bool(span, false);
         for flag in self.drop_flags.values() {
-            self.patch.add_assign(loc, Place::Local(*flag), false_.clone());
+            self.patch.add_assign(loc, Place::Base(PlaceBase::Local(*flag)), false_.clone());
         }
     }
 
index 84f209f8776d9cba5905679108ad2d15e94a885e..9494d4b1f6c392d831a4a8025114118876ebda5d 100644 (file)
@@ -4,7 +4,7 @@
 //! N.B., we do _not_ erase regions of statements that are relevant for
 //! "types-as-contracts"-validation, namely, `AcquireValid` and `ReleaseValid`.
 
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::SubstsRef;
 use rustc::ty::{self, Ty, TyCtxt};
 use rustc::mir::*;
 use rustc::mir::visit::{MutVisitor, TyContext};
@@ -36,7 +36,7 @@ fn visit_const(&mut self, constant: &mut &'tcx ty::LazyConst<'tcx>, _: Location)
         *constant = self.tcx.erase_regions(constant);
     }
 
-    fn visit_substs(&mut self, substs: &mut &'tcx Substs<'tcx>, _: Location) {
+    fn visit_substs(&mut self, substs: &mut SubstsRef<'tcx>, _: Location) {
         *substs = self.tcx.erase_regions(substs);
     }
 
index 0866b87cf17e602ff448af2aaf7633df593c2734..c455d38cebce85fff4b824b8325372e6ddc585d6 100644 (file)
@@ -55,7 +55,7 @@
 use rustc::mir::visit::{PlaceContext, Visitor, MutVisitor};
 use rustc::ty::{self, TyCtxt, AdtDef, Ty};
 use rustc::ty::layout::VariantIdx;
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::SubstsRef;
 use rustc_data_structures::fx::FxHashMap;
 use rustc_data_structures::indexed_vec::Idx;
 use rustc_data_structures::bit_set::BitSet;
@@ -102,7 +102,7 @@ fn visit_place(&mut self,
                     place: &mut Place<'tcx>,
                     context: PlaceContext<'tcx>,
                     location: Location) {
-        if *place == Place::Local(self_arg()) {
+        if *place == Place::Base(PlaceBase::Local(self_arg())) {
             *place = Place::Projection(Box::new(Projection {
                 base: place.clone(),
                 elem: ProjectionElem::Deref,
@@ -129,7 +129,7 @@ fn visit_place(&mut self,
                     place: &mut Place<'tcx>,
                     context: PlaceContext<'tcx>,
                     location: Location) {
-        if *place == Place::Local(self_arg()) {
+        if *place == Place::Base(PlaceBase::Local(self_arg())) {
             *place = Place::Projection(Box::new(Projection {
                 base: place.clone(),
                 elem: ProjectionElem::Field(Field::new(0), self.ref_gen_ty),
@@ -154,7 +154,7 @@ struct SuspensionPoint {
 struct TransformVisitor<'a, 'tcx: 'a> {
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
     state_adt_ref: &'tcx AdtDef,
-    state_substs: &'tcx Substs<'tcx>,
+    state_substs: SubstsRef<'tcx>,
 
     // The index of the generator state in the generator struct
     state_field: usize,
@@ -183,7 +183,7 @@ fn make_state(&self, idx: VariantIdx, val: Operand<'tcx>) -> Rvalue<'tcx> {
 
     // Create a Place referencing a generator struct field
     fn make_field(&self, idx: usize, ty: Ty<'tcx>) -> Place<'tcx> {
-        let base = Place::Local(self_arg());
+        let base = Place::Base(PlaceBase::Local(self_arg()));
         let field = Projection {
             base: base,
             elem: ProjectionElem::Field(Field::new(idx), ty),
@@ -223,7 +223,7 @@ fn visit_place(&mut self,
                     place: &mut Place<'tcx>,
                     context: PlaceContext<'tcx>,
                     location: Location) {
-        if let Place::Local(l) = *place {
+        if let Place::Base(PlaceBase::Local(l)) = *place {
             // Replace an Local in the remap with a generator struct access
             if let Some(&(ty, idx)) = self.remap.get(&l) {
                 *place = self.make_field(idx, ty);
@@ -249,7 +249,7 @@ fn visit_basic_block_data(&mut self,
         let ret_val = match data.terminator().kind {
             TerminatorKind::Return => Some((VariantIdx::new(1),
                 None,
-                Operand::Move(Place::Local(self.new_ret_local)),
+                Operand::Move(Place::Base(PlaceBase::Local(self.new_ret_local))),
                 None)),
             TerminatorKind::Yield { ref value, resume, drop } => Some((VariantIdx::new(0),
                 Some(resume),
@@ -263,7 +263,7 @@ fn visit_basic_block_data(&mut self,
             // We must assign the value first in case it gets declared dead below
             data.statements.push(Statement {
                 source_info,
-                kind: StatementKind::Assign(Place::Local(RETURN_PLACE),
+                kind: StatementKind::Assign(Place::RETURN_PLACE,
                                             box self.make_state(state_idx, v)),
             });
             let state = if let Some(resume) = resume { // Yield
@@ -597,7 +597,7 @@ fn elaborate_generator_drops<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
             &Terminator {
                 source_info,
                 kind: TerminatorKind::Drop {
-                    location: Place::Local(local),
+                    location: Place::Base(PlaceBase::Local(local)),
                     target,
                     unwind
                 }
@@ -619,7 +619,7 @@ fn elaborate_generator_drops<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
             elaborate_drop(
                 &mut elaborator,
                 source_info,
-                &Place::Local(gen),
+                &Place::Base(PlaceBase::Local(gen)),
                 (),
                 target,
                 unwind,
@@ -693,7 +693,7 @@ fn create_generator_drop_shim<'a, 'tcx>(
         // Alias tracking must know we changed the type
         mir.basic_blocks_mut()[START_BLOCK].statements.insert(0, Statement {
             source_info,
-            kind: StatementKind::Retag(RetagKind::Raw, Place::Local(self_arg())),
+            kind: StatementKind::Retag(RetagKind::Raw, Place::Base(PlaceBase::Local(self_arg()))),
         })
     }
 
@@ -809,7 +809,7 @@ fn insert_clean_drop<'a, 'tcx>(mir: &mut Mir<'tcx>) -> BasicBlock {
     // Create a block to destroy an unresumed generators. This can only destroy upvars.
     let drop_clean = BasicBlock::new(mir.basic_blocks().len());
     let term = TerminatorKind::Drop {
-        location: Place::Local(self_arg()),
+        location: Place::Base(PlaceBase::Local(self_arg())),
         target: return_block,
         unwind: None,
     };
index 07ebbf6d0ebe37233d4a841a468d07c8750ebddd..4cdef015b53ff0697aee3e7bd0ca74045e950d02 100644 (file)
@@ -9,7 +9,7 @@
 use rustc::mir::*;
 use rustc::mir::visit::*;
 use rustc::ty::{self, Instance, InstanceDef, ParamEnv, Ty, TyCtxt};
-use rustc::ty::subst::{Subst,Substs};
+use rustc::ty::subst::{Subst, SubstsRef};
 
 use std::collections::VecDeque;
 use std::iter;
@@ -32,7 +32,7 @@
 #[derive(Copy, Clone, Debug)]
 struct CallSite<'tcx> {
     callee: DefId,
-    substs: &'tcx Substs<'tcx>,
+    substs: SubstsRef<'tcx>,
     bb: BasicBlock,
     location: SourceInfo,
 }
@@ -449,7 +449,7 @@ fn dest_needs_borrow(place: &Place<'_>) -> bool {
                         }
                         // Static variables need a borrow because the callee
                         // might modify the same static.
-                        Place::Static(_) => true,
+                        Place::Base(PlaceBase::Static(_)) => true,
                         _ => false
                     }
                 }
@@ -466,7 +466,7 @@ fn dest_needs_borrow(place: &Place<'_>) -> bool {
                     let temp = LocalDecl::new_temp(ty, callsite.location.span);
 
                     let tmp = caller_mir.local_decls.push(temp);
-                    let tmp = Place::Local(tmp);
+                    let tmp = Place::Base(PlaceBase::Local(tmp));
 
                     let stmt = Statement {
                         source_info: callsite.location,
@@ -560,7 +560,7 @@ fn make_call_args(
             let tuple = self.create_temp_if_necessary(args.next().unwrap(), callsite, caller_mir);
             assert!(args.next().is_none());
 
-            let tuple = Place::Local(tuple);
+            let tuple = Place::Base(PlaceBase::Local(tuple));
             let tuple_tys = if let ty::Tuple(s) = tuple.ty(caller_mir, tcx).to_ty(tcx).sty {
                 s
             } else {
@@ -599,7 +599,7 @@ fn create_temp_if_necessary(
         // FIXME: Analysis of the usage of the arguments to avoid
         // unnecessary temporaries.
 
-        if let Operand::Move(Place::Local(local)) = arg {
+        if let Operand::Move(Place::Base(PlaceBase::Local(local))) = arg {
             if caller_mir.local_kind(local) == LocalKind::Temp {
                 // Reuse the operand if it's a temporary already
                 return local;
@@ -617,7 +617,7 @@ fn create_temp_if_necessary(
 
         let stmt = Statement {
             source_info: callsite.location,
-            kind: StatementKind::Assign(Place::Local(arg_tmp), box arg),
+            kind: StatementKind::Assign(Place::Base(PlaceBase::Local(arg_tmp)), box arg),
         };
         caller_mir[callsite.bb].statements.push(stmt);
         arg_tmp
@@ -665,7 +665,7 @@ fn visit_local(&mut self,
                    _location: Location) {
         if *local == RETURN_PLACE {
             match self.destination {
-                Place::Local(l) => {
+                Place::Base(PlaceBase::Local(l)) => {
                     *local = l;
                     return;
                 },
@@ -686,11 +686,11 @@ fn visit_place(&mut self,
                     _location: Location) {
 
         match place {
-            Place::Local(RETURN_PLACE) => {
+            Place::Base(PlaceBase::Local(RETURN_PLACE)) => {
                 // Return pointer; update the place itself
                 *place = self.destination.clone();
             },
-            Place::Promoted(ref mut promoted) => {
+            Place::Base(PlaceBase::Promoted(ref mut promoted)) => {
                 if let Some(p) = self.promoted_map.get(promoted.0).cloned() {
                     promoted.0 = p;
                 }
index 290915763e275671df529077793a6d3231c0d73e..e0e64fd1f9b5422b26201bb44bfbb70b7f541b32 100644 (file)
@@ -1,6 +1,6 @@
 //! Performs various peephole optimizations.
 
-use rustc::mir::{Constant, Location, Place, Mir, Operand, ProjectionElem, Rvalue, Local};
+use rustc::mir::{Constant, Location, Place, PlaceBase, Mir, Operand, ProjectionElem, Rvalue, Local};
 use rustc::mir::visit::{MutVisitor, Visitor};
 use rustc::ty::{TyCtxt, TyKind};
 use rustc::util::nodemap::{FxHashMap, FxHashSet};
@@ -45,7 +45,7 @@ fn visit_rvalue(&mut self, rvalue: &mut Rvalue<'tcx>, location: Location) {
             let new_place = match *rvalue {
                 Rvalue::Ref(_, _, Place::Projection(ref mut projection)) => {
                     // Replace with dummy
-                    mem::replace(&mut projection.base, Place::Local(Local::new(0)))
+                    mem::replace(&mut projection.base, Place::Base(PlaceBase::Local(Local::new(0))))
                 }
                 _ => bug!("Detected `&*` but didn't find `&*`!"),
             };
index 3d1f55e530e62a7c88ea1dc9a210d01e470cac90..ad108587247fb678989cbf983decba1d1d7afbf7 100644 (file)
@@ -86,13 +86,13 @@ fn lower_128bit_ops<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, mir: &mut Mir<
                     block.statements.push(Statement {
                         source_info: source_info,
                         kind: StatementKind::Assign(
-                            Place::Local(local),
+                            Place::Base(PlaceBase::Local(local)),
                             box Rvalue::Cast(
                                 CastKind::Misc,
                                 rhs,
                                 rhs_override_ty.unwrap())),
                     });
-                    rhs = Operand::Move(Place::Local(local));
+                    rhs = Operand::Move(Place::Base(PlaceBase::Local(local)));
                 }
 
                 let call_did = check_lang_item_type(
index a6726718e2d23aab6e7e05455ea8976fdf1f139c..831d8b46a65c3a8ad2681abb9be92fc4cab5cda2 100644 (file)
@@ -178,7 +178,7 @@ fn assign(&mut self, dest: Local, rvalue: Rvalue<'tcx>, span: Span) {
                 span,
                 scope: OUTERMOST_SOURCE_SCOPE
             },
-            kind: StatementKind::Assign(Place::Local(dest), box rvalue)
+            kind: StatementKind::Assign(Place::Base(PlaceBase::Local(dest)), box rvalue)
         });
     }
 
@@ -268,7 +268,9 @@ fn promote_temp(&mut self, temp: Local) -> Local {
                             func,
                             args,
                             cleanup: None,
-                            destination: Some((Place::Local(new_temp), new_target)),
+                            destination: Some(
+                                (Place::Base(PlaceBase::Local(new_temp)), new_target)
+                            ),
                             from_hir_call,
                         },
                         ..terminator
@@ -292,7 +294,7 @@ fn promote_candidate(mut self, candidate: Candidate) {
                 promoted.span = span;
                 promoted.local_decls[RETURN_PLACE] =
                     LocalDecl::new_return_place(ty, span);
-                Place::Promoted(box (promoted_id, ty))
+                Place::Base(PlaceBase::Promoted(box (promoted_id, ty)))
             };
             let (blocks, local_decls) = self.source.basic_blocks_and_local_decls_mut();
             match candidate {
@@ -373,7 +375,7 @@ pub fn promote_candidates<'a, 'tcx>(mir: &mut Mir<'tcx>,
         match candidate {
             Candidate::Ref(Location { block, statement_index }) => {
                 match mir[block].statements[statement_index].kind {
-                    StatementKind::Assign(Place::Local(local), _) => {
+                    StatementKind::Assign(Place::Base(PlaceBase::Local(local)), _) => {
                         if temps[local] == TempState::PromotedOut {
                             // Already promoted.
                             continue;
@@ -420,7 +422,7 @@ pub fn promote_candidates<'a, 'tcx>(mir: &mut Mir<'tcx>,
     for block in mir.basic_blocks_mut() {
         block.statements.retain(|statement| {
             match statement.kind {
-                StatementKind::Assign(Place::Local(index), _) |
+                StatementKind::Assign(Place::Base(PlaceBase::Local(index)), _) |
                 StatementKind::StorageLive(index) |
                 StatementKind::StorageDead(index) => {
                     !promoted(index)
@@ -430,7 +432,7 @@ pub fn promote_candidates<'a, 'tcx>(mir: &mut Mir<'tcx>,
         });
         let terminator = block.terminator_mut();
         match terminator.kind {
-            TerminatorKind::Drop { location: Place::Local(index), target, .. } => {
+            TerminatorKind::Drop { location: Place::Base(PlaceBase::Local(index)), target, .. } => {
                 if promoted(index) {
                     terminator.kind = TerminatorKind::Goto {
                         target,
index 285c674643f2e58cdcd2be4b45b1454a7b77f5bb..d41098e2881a63cf7ce7d967e6ab2ac185a6c9b7 100644 (file)
@@ -186,9 +186,9 @@ fn in_projection(cx: &ConstCx<'_, 'tcx>, proj: &PlaceProjection<'tcx>) -> bool {
 
     fn in_place(cx: &ConstCx<'_, 'tcx>, place: &Place<'tcx>) -> bool {
         match *place {
-            Place::Local(local) => Self::in_local(cx, local),
-            Place::Promoted(_) => bug!("qualifying already promoted MIR"),
-            Place::Static(ref static_) => Self::in_static(cx, static_),
+            Place::Base(PlaceBase::Local(local)) => Self::in_local(cx, local),
+            Place::Base(PlaceBase::Promoted(_)) => bug!("qualifying already promoted MIR"),
+            Place::Base(PlaceBase::Static(ref static_)) => Self::in_static(cx, static_),
             Place::Projection(ref proj) => Self::in_projection(cx, proj),
         }
     }
@@ -730,7 +730,7 @@ fn assign(&mut self, dest: &Place<'tcx>, source: ValueSource<'_, 'tcx>, location
                     place = &proj.base;
                 }
                 debug!("qualify_consts: promotion candidate: place={:?}", place);
-                if let Place::Local(local) = *place {
+                if let Place::Base(PlaceBase::Local(local)) = *place {
                     if self.mir.local_kind(local) == LocalKind::Temp {
                         debug!("qualify_consts: promotion candidate: local={:?}", local);
                         // The borrowed place doesn't have `HasMutInterior`
@@ -754,7 +754,7 @@ fn assign(&mut self, dest: &Place<'tcx>, source: ValueSource<'_, 'tcx>, location
         let index = loop {
             match dest {
                 // We treat all locals equal in constants
-                Place::Local(index) => break *index,
+                Place::Base(PlaceBase::Local(index)) => break *index,
                 // projections are transparent for assignments
                 // we qualify the entire destination at once, even if just a field would have
                 // stricter qualification
@@ -768,8 +768,9 @@ fn assign(&mut self, dest: &Place<'tcx>, source: ValueSource<'_, 'tcx>, location
                     );
                     dest = &proj.base;
                 },
-                Place::Promoted(..) => bug!("promoteds don't exist yet during promotion"),
-                Place::Static(..) => {
+                Place::Base(PlaceBase::Promoted(..)) =>
+                    bug!("promoteds don't exist yet during promotion"),
+                Place::Base(PlaceBase::Static(..)) => {
                     // Catch more errors in the destination. `visit_place` also checks that we
                     // do not try to access statics from constants or try to mutate statics
                     self.visit_place(
@@ -878,7 +879,10 @@ fn check_const(&mut self) -> (u8, Lrc<BitSet<Local>>) {
             match *candidate {
                 Candidate::Ref(Location { block: bb, statement_index: stmt_idx }) => {
                     match self.mir[bb].statements[stmt_idx].kind {
-                        StatementKind::Assign(_, box Rvalue::Ref(_, _, Place::Local(index))) => {
+                        StatementKind::Assign(
+                            _,
+                            box Rvalue::Ref(_, _, Place::Base(PlaceBase::Local(index)))
+                        ) => {
                             promoted_temps.insert(index);
                         }
                         _ => {}
@@ -915,9 +919,9 @@ fn visit_place(&mut self,
         debug!("visit_place: place={:?} context={:?} location={:?}", place, context, location);
         self.super_place(place, context, location);
         match *place {
-            Place::Local(_) |
-            Place::Promoted(_) => {}
-            Place::Static(ref global) => {
+            Place::Base(PlaceBase::Local(_)) |
+            Place::Base(PlaceBase::Promoted(_)) => {}
+            Place::Base(PlaceBase::Static(ref global)) => {
                 if self.tcx
                        .get_attrs(global.def_id)
                        .iter()
@@ -1032,7 +1036,7 @@ fn visit_operand(&mut self, operand: &Operand<'tcx>, location: Location) {
         match *operand {
             Operand::Move(ref place) => {
                 // Mark the consumed locals to indicate later drops are noops.
-                if let Place::Local(local) = *place {
+                if let Place::Base(PlaceBase::Local(local)) = *place {
                     self.cx.per_local[NeedsDrop].remove(local);
                 }
             }
@@ -1335,7 +1339,7 @@ fn visit_terminator_kind(&mut self,
                 unleash_miri!(self);
                 // HACK(eddyb): emulate a bit of dataflow analysis,
                 // conservatively, that drop elaboration will do.
-                let needs_drop = if let Place::Local(local) = *place {
+                let needs_drop = if let Place::Base(PlaceBase::Local(local)) = *place {
                     if NeedsDrop::in_local(self, local) {
                         Some(self.mir.local_decls[local].source_info.span)
                     } else {
@@ -1565,7 +1569,11 @@ fn run_pass<'a, 'tcx>(&self,
                 });
                 let terminator = block.terminator_mut();
                 match terminator.kind {
-                    TerminatorKind::Drop { location: Place::Local(index), target, .. } => {
+                    TerminatorKind::Drop {
+                        location: Place::Base(PlaceBase::Local(index)),
+                        target,
+                        ..
+                    } => {
                         if promoted_temps.contains(index) {
                             terminator.kind = TerminatorKind::Goto {
                                 target,
index 34f850fc4aad2a297e6e9913042e80666f9cd5a3..6c44fac10f59de98e9f4acdd736bd27d55baa4f2 100644 (file)
@@ -252,10 +252,11 @@ fn check_place(
     span: Span,
 ) -> McfResult {
     match place {
-        Place::Local(_) => Ok(()),
+        Place::Base(PlaceBase::Local(_)) => Ok(()),
         // promoteds are always fine, they are essentially constants
-        Place::Promoted(_) => Ok(()),
-        Place::Static(_) => Err((span, "cannot access `static` items in const fn".into())),
+        Place::Base(PlaceBase::Promoted(_)) => Ok(()),
+        Place::Base(PlaceBase::Static(_)) =>
+            Err((span, "cannot access `static` items in const fn".into())),
         Place::Projection(proj) => {
             match proj.elem {
                 | ProjectionElem::ConstantIndex { .. } | ProjectionElem::Subslice { .. }
index 0ad33bff9d6caf411ef16058e7a644a34238b91a..b7493b25d46503826b4ddebfb87aa0015e1d2ffe 100644 (file)
@@ -47,7 +47,7 @@ fn is_nop_landing_pad(
                     // These are all nops in a landing pad
                 }
 
-                StatementKind::Assign(Place::Local(_), box Rvalue::Use(_)) => {
+                StatementKind::Assign(Place::Base(PlaceBase::Local(_)), box Rvalue::Use(_)) => {
                     // Writing to a local (e.g., a drop flag) does not
                     // turn a landing pad to a non-nop
                 }
index 40e02e712c1565bb59065a1a97a6ca0805dc5ed1..a44ec526f9ddc852c832f773b3ef5392998851ab 100644 (file)
@@ -115,8 +115,8 @@ fn each_block<'a, 'tcx, O>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     };
     assert!(args.len() == 1);
     let peek_arg_place = match args[0] {
-        mir::Operand::Copy(ref place @ mir::Place::Local(_)) |
-        mir::Operand::Move(ref place @ mir::Place::Local(_)) => Some(place),
+        mir::Operand::Copy(ref place @ mir::Place::Base(mir::PlaceBase::Local(_))) |
+        mir::Operand::Move(ref place @ mir::Place::Base(mir::PlaceBase::Local(_))) => Some(place),
         _ => None,
     };
 
index fd8d68a482262320658f748fc1294c6d08f0da82..b1d898bb5b0263d672887bb99c46fc20b55ef9c0 100644 (file)
@@ -101,7 +101,7 @@ fn uniform(&mut self,
                     let temp = self.patch.new_temp(item_ty, self.mir.source_info(location).span);
                     self.patch.add_statement(location, StatementKind::StorageLive(temp));
                     self.patch.add_assign(location,
-                                          Place::Local(temp),
+                                          Place::Base(PlaceBase::Local(temp)),
                                           Rvalue::Use(
                                               Operand::Move(
                                                   Place::Projection(box PlaceProjection{
@@ -113,12 +113,16 @@ fn uniform(&mut self,
                                                   }))));
                     temp
                 }).collect();
-                self.patch.add_assign(location,
-                                      dst_place.clone(),
-                                      Rvalue::Aggregate(box AggregateKind::Array(item_ty),
-                                      temps.iter().map(
-                                          |x| Operand::Move(Place::Local(*x))).collect()
-                                      ));
+                self.patch.add_assign(
+                    location,
+                    dst_place.clone(),
+                    Rvalue::Aggregate(
+                        box AggregateKind::Array(item_ty),
+                        temps.iter().map(
+                            |x| Operand::Move(Place::Base(PlaceBase::Local(*x)))
+                        ).collect()
+                    )
+                );
                 for temp in temps {
                     self.patch.add_statement(location, StatementKind::StorageDead(temp));
                 }
@@ -176,7 +180,7 @@ fn run_pass<'a, 'tcx>(&self,
                 if let StatementKind::Assign(ref dst_place, ref rval) = statement.kind {
                     if let Rvalue::Aggregate(box AggregateKind::Array(_), ref items) = **rval {
                         let items : Vec<_> = items.iter().map(|item| {
-                            if let Operand::Move(Place::Local(local)) = item {
+                            if let Operand::Move(Place::Base(PlaceBase::Local(local))) = item {
                                 let local_use = &visitor.locals_use[*local];
                                 let opt_index_and_place = Self::try_get_item_source(local_use, mir);
                                 // each local should be used twice:
@@ -257,7 +261,7 @@ fn try_get_item_source<'a, 'tcx>(local_use: &LocalUse,
             if block.statements.len() > location.statement_index {
                 let statement = &block.statements[location.statement_index];
                 if let StatementKind::Assign(
-                    Place::Local(_),
+                    Place::Base(PlaceBase::Local(_)),
                     box Rvalue::Use(Operand::Move(Place::Projection(box PlaceProjection{
                         ref base, elem: ProjectionElem::ConstantIndex{
                             offset, min_length: _, from_end: false}})))) = statement.kind {
index e86ece138301fce509094698cce6fded42629149..26fa8d6d1f0bf98eee4a282b6deecc5661116f71 100644 (file)
@@ -5,7 +5,7 @@
 use rustc::traits::Reveal;
 use rustc::ty::{self, Ty, TyCtxt};
 use rustc::ty::layout::VariantIdx;
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::SubstsRef;
 use rustc::ty::util::IntTypeExt;
 use rustc_data_structures::indexed_vec::Idx;
 use crate::util::patch::MirPatch;
@@ -189,7 +189,7 @@ fn move_paths_for_fields(&self,
                              base_place: &Place<'tcx>,
                              variant_path: D::Path,
                              variant: &'tcx ty::VariantDef,
-                             substs: &'tcx Substs<'tcx>)
+                             substs: SubstsRef<'tcx>)
                              -> Vec<(Place<'tcx>, Option<D::Path>)>
     {
         variant.fields.iter().enumerate().map(|(i, f)| {
@@ -328,7 +328,7 @@ fn open_drop_for_tuple<'a>(&mut self, tys: &[Ty<'tcx>])
         self.drop_ladder(fields, succ, unwind).0
     }
 
-    fn open_drop_for_box<'a>(&mut self, adt: &'tcx ty::AdtDef, substs: &'tcx Substs<'tcx>)
+    fn open_drop_for_box<'a>(&mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>)
                              -> BasicBlock
     {
         debug!("open_drop_for_box({:?}, {:?}, {:?})", self, adt, substs);
@@ -346,7 +346,7 @@ fn open_drop_for_box<'a>(&mut self, adt: &'tcx ty::AdtDef, substs: &'tcx Substs<
         self.drop_subpath(&interior, interior_path, succ, unwind_succ)
     }
 
-    fn open_drop_for_adt<'a>(&mut self, adt: &'tcx ty::AdtDef, substs: &'tcx Substs<'tcx>)
+    fn open_drop_for_adt<'a>(&mut self, adt: &'tcx ty::AdtDef, substs: SubstsRef<'tcx>)
                              -> BasicBlock {
         debug!("open_drop_for_adt({:?}, {:?}, {:?})", self, adt, substs);
         if adt.variants.len() == 0 {
@@ -376,7 +376,7 @@ fn open_drop_for_adt<'a>(&mut self, adt: &'tcx ty::AdtDef, substs: &'tcx Substs<
     }
 
     fn open_drop_for_adt_contents(&mut self, adt: &'tcx ty::AdtDef,
-                                  substs: &'tcx Substs<'tcx>)
+                                  substs: SubstsRef<'tcx>)
                                   -> (BasicBlock, Unwind) {
         let (succ, unwind) = self.drop_ladder_bottom();
         if !adt.is_enum() {
@@ -393,7 +393,7 @@ fn open_drop_for_adt_contents(&mut self, adt: &'tcx ty::AdtDef,
     }
 
     fn open_drop_for_multivariant(&mut self, adt: &'tcx ty::AdtDef,
-                                  substs: &'tcx Substs<'tcx>,
+                                  substs: SubstsRef<'tcx>,
                                   succ: BasicBlock,
                                   unwind: Unwind)
                                   -> (BasicBlock, Unwind) {
@@ -486,7 +486,7 @@ fn adt_switch_block(&mut self,
         // discriminant after it is free-ed, because that
         // way lies only trouble.
         let discr_ty = adt.repr.discr_type().to_ty(self.tcx());
-        let discr = Place::Local(self.new_temp(discr_ty));
+        let discr = Place::Base(PlaceBase::Local(self.new_temp(discr_ty)));
         let discr_rv = Rvalue::Discriminant(self.place.clone());
         let switch_block = BasicBlockData {
             statements: vec![self.assign(&discr, discr_rv)],
@@ -520,11 +520,11 @@ fn destructor_call_block<'a>(&mut self, (succ, unwind): (BasicBlock, Unwind))
             mutbl: hir::Mutability::MutMutable
         });
         let ref_place = self.new_temp(ref_ty);
-        let unit_temp = Place::Local(self.new_temp(tcx.mk_unit()));
+        let unit_temp = Place::Base(PlaceBase::Local(self.new_temp(tcx.mk_unit())));
 
         let result = BasicBlockData {
             statements: vec![self.assign(
-                &Place::Local(ref_place),
+                &Place::Base(PlaceBase::Local(ref_place)),
                 Rvalue::Ref(tcx.types.re_erased,
                             BorrowKind::Mut { allow_two_phase_borrow: false },
                             self.place.clone())
@@ -533,7 +533,7 @@ fn destructor_call_block<'a>(&mut self, (succ, unwind): (BasicBlock, Unwind))
                 kind: TerminatorKind::Call {
                     func: Operand::function_handle(tcx, drop_fn.def_id, substs,
                                                    self.source_info.span),
-                    args: vec![Operand::Move(Place::Local(ref_place))],
+                    args: vec![Operand::Move(Place::Base(PlaceBase::Local(ref_place)))],
                     destination: Some((unit_temp, succ)),
                     cleanup: unwind.into_option(),
                     from_hir_call: true,
@@ -578,8 +578,8 @@ fn drop_loop(&mut self,
             ty: ety,
             mutbl: hir::Mutability::MutMutable
         });
-        let ptr = &Place::Local(self.new_temp(ref_ty));
-        let can_go = &Place::Local(self.new_temp(tcx.types.bool));
+        let ptr = &Place::Base(PlaceBase::Local(self.new_temp(ref_ty)));
+        let can_go = &Place::Base(PlaceBase::Local(self.new_temp(tcx.types.bool)));
 
         let one = self.constant_usize(1);
         let (ptr_next, cur_next) = if ptr_based {
@@ -587,23 +587,23 @@ fn drop_loop(&mut self,
                 tcx.types.re_erased,
                 BorrowKind::Mut { allow_two_phase_borrow: false },
                 Place::Projection(Box::new(Projection {
-                    base: Place::Local(cur),
+                    base: Place::Base(PlaceBase::Local(cur)),
                     elem: ProjectionElem::Deref,
                 }))
              ),
-             Rvalue::BinaryOp(BinOp::Offset, copy(&Place::Local(cur)), one))
+             Rvalue::BinaryOp(BinOp::Offset, copy(&Place::Base(PlaceBase::Local(cur))), one))
         } else {
             (Rvalue::Ref(
                  tcx.types.re_erased,
                  BorrowKind::Mut { allow_two_phase_borrow: false },
                  self.place.clone().index(cur)),
-             Rvalue::BinaryOp(BinOp::Add, copy(&Place::Local(cur)), one))
+             Rvalue::BinaryOp(BinOp::Add, copy(&Place::Base(PlaceBase::Local(cur))), one))
         };
 
         let drop_block = BasicBlockData {
             statements: vec![
                 self.assign(ptr, ptr_next),
-                self.assign(&Place::Local(cur), cur_next)
+                self.assign(&Place::Base(PlaceBase::Local(cur)), cur_next)
             ],
             is_cleanup: unwind.is_cleanup(),
             terminator: Some(Terminator {
@@ -617,7 +617,7 @@ fn drop_loop(&mut self,
         let loop_block = BasicBlockData {
             statements: vec![
                 self.assign(can_go, Rvalue::BinaryOp(BinOp::Eq,
-                                                     copy(&Place::Local(cur)),
+                                                     copy(&Place::Base(PlaceBase::Local(cur))),
                                                      copy(length_or_end)))
             ],
             is_cleanup: unwind.is_cleanup(),
@@ -667,8 +667,8 @@ fn open_drop_for_array(&mut self, ety: Ty<'tcx>, opt_size: Option<u64>) -> Basic
 
         let move_ = |place: &Place<'tcx>| Operand::Move(place.clone());
         let tcx = self.tcx();
-        let size = &Place::Local(self.new_temp(tcx.types.usize));
-        let size_is_zero = &Place::Local(self.new_temp(tcx.types.bool));
+        let size = &Place::Base(PlaceBase::Local(self.new_temp(tcx.types.usize)));
+        let size_is_zero = &Place::Base(PlaceBase::Local(self.new_temp(tcx.types.bool)));
         let base_block = BasicBlockData {
             statements: vec![
                 self.assign(size, Rvalue::NullaryOp(NullOp::SizeOf, ety)),
@@ -703,9 +703,12 @@ fn drop_loop_pair(&mut self, ety: Ty<'tcx>, ptr_based: bool) -> BasicBlock {
         };
 
         let cur = self.new_temp(iter_ty);
-        let length = Place::Local(self.new_temp(tcx.types.usize));
+        let length = Place::Base(PlaceBase::Local(self.new_temp(tcx.types.usize)));
         let length_or_end = if ptr_based {
-            Place::Local(self.new_temp(iter_ty))
+            // FIXME check if we want to make it return a `Place` directly
+            // if all use sites want a `Place::Base` anyway.
+            let temp = self.new_temp(iter_ty);
+            Place::Base(PlaceBase::Local(temp))
         } else {
             length.clone()
         };
@@ -728,13 +731,13 @@ fn drop_loop_pair(&mut self, ety: Ty<'tcx>, ptr_based: bool) -> BasicBlock {
             unwind,
             ptr_based);
 
-        let cur = Place::Local(cur);
+        let cur = Place::Base(PlaceBase::Local(cur));
         let zero = self.constant_usize(0);
         let mut drop_block_stmts = vec![];
         drop_block_stmts.push(self.assign(&length, Rvalue::Len(self.place.clone())));
         if ptr_based {
             let tmp_ty = tcx.mk_mut_ptr(self.place_ty(self.place));
-            let tmp = Place::Local(self.new_temp(tmp_ty));
+            let tmp = Place::Base(PlaceBase::Local(self.new_temp(tmp_ty)));
             // tmp = &mut P;
             // cur = tmp as *mut T;
             // end = Offset(cur, len);
@@ -867,7 +870,7 @@ fn elaborated_drop_block<'a>(&mut self) -> BasicBlock {
     fn box_free_block<'a>(
         &mut self,
         adt: &'tcx ty::AdtDef,
-        substs: &'tcx Substs<'tcx>,
+        substs: SubstsRef<'tcx>,
         target: BasicBlock,
         unwind: Unwind,
     ) -> BasicBlock {
@@ -878,12 +881,12 @@ fn box_free_block<'a>(
     fn unelaborated_free_block<'a>(
         &mut self,
         adt: &'tcx ty::AdtDef,
-        substs: &'tcx Substs<'tcx>,
+        substs: SubstsRef<'tcx>,
         target: BasicBlock,
         unwind: Unwind
     ) -> BasicBlock {
         let tcx = self.tcx();
-        let unit_temp = Place::Local(self.new_temp(tcx.mk_unit()));
+        let unit_temp = Place::Base(PlaceBase::Local(self.new_temp(tcx.mk_unit())));
         let free_func = tcx.require_lang_item(lang_items::BoxFreeFnLangItem);
         let args = adt.variants[VariantIdx::new(0)].fields.iter().enumerate().map(|(i, f)| {
             let field = Field::new(i);
index e93b96c12161cd86aaba5b3dd5a09b8b77aff9ec..5d495fc04588b21e64156f036570f62fb7a577a5 100644 (file)
@@ -134,7 +134,11 @@ fn write_graph_label<'a, 'gcx, 'tcx, W: Write>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
         if i > 0 {
             write!(w, ", ")?;
         }
-        write!(w, "{:?}: {}", Place::Local(arg), escape(&mir.local_decls[arg].ty))?;
+        write!(w,
+               "{:?}: {}",
+               Place::Base(PlaceBase::Local(arg)),
+               escape(&mir.local_decls[arg].ty)
+        )?;
     }
 
     write!(w, ") -&gt; {}", escape(mir.return_ty()))?;
@@ -150,10 +154,10 @@ fn write_graph_label<'a, 'gcx, 'tcx, W: Write>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
 
         if let Some(name) = decl.name {
             write!(w, r#"{:?}: {}; // {}<br align="left"/>"#,
-                   Place::Local(local), escape(&decl.ty), name)?;
+                   Place::Base(PlaceBase::Local(local)), escape(&decl.ty), name)?;
         } else {
             write!(w, r#"let mut {:?}: {};<br align="left"/>"#,
-                   Place::Local(local), escape(&decl.ty))?;
+                   Place::Base(PlaceBase::Local(local)), escape(&decl.ty))?;
         }
     }
 
index 8177de50776d64758e164dbf622de5d9f85fe882..c3fbee3a2a6e5747e31f804dd053a9a5ceb9f3fa 100644 (file)
@@ -625,7 +625,7 @@ fn write_mir_sig(
             if i != 0 {
                 write!(w, ", ")?;
             }
-            write!(w, "{:?}: {}", Place::Local(arg), mir.local_decls[arg].ty)?;
+            write!(w, "{:?}: {}", Place::Base(PlaceBase::Local(arg)), mir.local_decls[arg].ty)?;
         }
 
         write!(w, ") -> {}", mir.return_ty())?;
index 606ae2741283240a973bfb136ac36fc36b8a3114..f96fc3b897f80bc4e85d40d225f737ae1dd77885 100644 (file)
@@ -463,7 +463,7 @@ fn visit_item(&mut self, item: &'a Item) {
                     self.invalid_visibility(&impl_item.vis, None);
                     if let ImplItemKind::Method(ref sig, _) = impl_item.node {
                         self.check_trait_fn_not_const(sig.header.constness);
-                        self.check_trait_fn_not_async(impl_item.span, sig.header.asyncness);
+                        self.check_trait_fn_not_async(impl_item.span, sig.header.asyncness.node);
                     }
                 }
             }
@@ -482,9 +482,10 @@ fn visit_item(&mut self, item: &'a Item) {
                         .note("only trait implementations may be annotated with default").emit();
                 }
             }
-            ItemKind::Fn(_, header, ref generics, _) => {
+            ItemKind::Fn(_, ref header, ref generics, _) => {
                 // We currently do not permit const generics in `const fn`, as
                 // this is tantamount to allowing compile-time dependent typing.
+                self.visit_fn_header(header);
                 if header.constness.node == Constness::Const {
                     // Look for const generics and error if we find any.
                     for param in &generics.params {
@@ -535,7 +536,7 @@ fn visit_item(&mut self, item: &'a Item) {
                 self.no_questions_in_bounds(bounds, "supertraits", true);
                 for trait_item in trait_items {
                     if let TraitItemKind::Method(ref sig, ref block) = trait_item.node {
-                        self.check_trait_fn_not_async(trait_item.span, sig.header.asyncness);
+                        self.check_trait_fn_not_async(trait_item.span, sig.header.asyncness.node);
                         self.check_trait_fn_not_const(sig.header.constness);
                         if block.is_none() {
                             self.check_decl_no_pat(&sig.decl, |span, mut_ident| {
@@ -702,6 +703,13 @@ fn visit_mac(&mut self, mac: &Spanned<Mac_>) {
             .span_bug(mac.span, "macro invocation missed in expansion; did you forget to override \
                                  the relevant `fold_*()` method in `PlaceholderExpander`?");
     }
+
+    fn visit_fn_header(&mut self, header: &'a FnHeader) {
+        if header.asyncness.node.is_async() && self.session.rust_2015() {
+            struct_span_err!(self.session, header.asyncness.span, E0670,
+                             "`async fn` is not permitted in the 2015 edition").emit();
+        }
+    }
 }
 
 pub fn check_crate(session: &Session, krate: &Crate) -> (bool, bool) {
index 19d4d3aeb0f6530e06a0a724bb89c2cb0e52b4b6..e3c6b16703a4ac1a105fdc91812297d5168dff5d 100644 (file)
@@ -310,6 +310,18 @@ trait Foo {
     break;
 }
 ```
+"##,
+
+E0670: r##"
+Rust 2015 does not permit the use of `async fn`.
+
+Example of erroneous code:
+
+```compile_fail,E0670
+async fn foo() {}
+```
+
+Switch to the Rust 2018 edition to use `async fn`.
 "##
 }
 
index c25884df87ba13e49f8e4d8d13fbe34753bf1e87..6b8e37b3b31330b2ecd5d7ba0e9aad410b73f409 100644 (file)
@@ -22,7 +22,7 @@
 use rustc::middle::mem_categorization::Categorization;
 use rustc::ty::{self, Ty, TyCtxt};
 use rustc::ty::query::Providers;
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::{InternalSubsts, SubstsRef};
 use rustc::util::nodemap::{ItemLocalSet, HirIdSet};
 use rustc::hir;
 use rustc_data_structures::sync::Lrc;
@@ -75,7 +75,7 @@ fn rvalue_promotable_map<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
         in_static: false,
         mut_rvalue_borrows: Default::default(),
         param_env: ty::ParamEnv::empty(),
-        identity_substs: Substs::empty(),
+        identity_substs: InternalSubsts::empty(),
         result: ItemLocalSet::default(),
     };
 
@@ -94,7 +94,7 @@ struct CheckCrateVisitor<'a, 'tcx: 'a> {
     in_static: bool,
     mut_rvalue_borrows: HirIdSet,
     param_env: ty::ParamEnv<'tcx>,
-    identity_substs: &'tcx Substs<'tcx>,
+    identity_substs: SubstsRef<'tcx>,
     tables: &'a ty::TypeckTables<'tcx>,
     result: ItemLocalSet,
 }
@@ -199,7 +199,7 @@ fn check_nested_body(&mut self, body_id: hir::BodyId) -> Promotability {
 
         self.tables = self.tcx.typeck_tables_of(item_def_id);
         self.param_env = self.tcx.param_env(item_def_id);
-        self.identity_substs = Substs::identity_for_item(self.tcx, item_def_id);
+        self.identity_substs = InternalSubsts::identity_for_item(self.tcx, item_def_id);
 
         let body = self.tcx.hir().body(body_id);
 
index 568e622bd34c2e70f494729bc4fccd094ee1e9b0..4a73f86ef6fe9dd25e08afef0215a8cac8962724 100644 (file)
@@ -20,7 +20,7 @@
 use rustc::ty::{self, TyCtxt, Ty, TraitRef, TypeFoldable, GenericParamDefKind};
 use rustc::ty::fold::TypeVisitor;
 use rustc::ty::query::Providers;
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::InternalSubsts;
 use rustc::util::nodemap::HirIdSet;
 use rustc_data_structures::fx::FxHashSet;
 use rustc_data_structures::sync::Lrc;
@@ -127,7 +127,7 @@ impl<'a, 'tcx, V> TypeVisitor<'tcx> for DefIdVisitorSkeleton<'_, 'a, 'tcx, V>
 {
     fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool {
         let tcx = self.def_id_visitor.tcx();
-        // Substs are not visited here because they are visited below in `super_visit_with`.
+        // InternalSubsts are not visited here because they are visited below in `super_visit_with`.
         match ty.sty {
             ty::Adt(&ty::AdtDef { did: def_id, .. }, ..) |
             ty::Foreign(def_id) |
@@ -180,7 +180,7 @@ fn visit_ty(&mut self, ty: Ty<'tcx>) -> bool {
                         ty::ExistentialPredicate::Trait(trait_ref) => trait_ref,
                         ty::ExistentialPredicate::Projection(proj) => proj.trait_ref(tcx),
                         ty::ExistentialPredicate::AutoTrait(def_id) =>
-                            ty::ExistentialTraitRef { def_id, substs: Substs::empty() },
+                            ty::ExistentialTraitRef { def_id, substs: InternalSubsts::empty() },
                     };
                     let ty::ExistentialTraitRef { def_id, substs: _ } = trait_ref;
                     if self.def_id_visitor.visit_def_id(def_id, "trait", &trait_ref) {
@@ -290,10 +290,10 @@ fn def_id_visibility<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId)
 // Set the correct `TypeckTables` for the given `item_id` (or an empty table if
 // there is no `TypeckTables` for the item).
 fn item_tables<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
-                         node_id: ast::NodeId,
+                         hir_id: hir::HirId,
                          empty_tables: &'a ty::TypeckTables<'tcx>)
                          -> &'a ty::TypeckTables<'tcx> {
-    let def_id = tcx.hir().local_def_id(node_id);
+    let def_id = tcx.hir().local_def_id_from_hir_id(hir_id);
     if tcx.has_typeck_tables(def_id) { tcx.typeck_tables_of(def_id) } else { empty_tables }
 }
 
@@ -841,7 +841,7 @@ fn visit_nested_body(&mut self, body: hir::BodyId) {
     fn visit_item(&mut self, item: &'tcx hir::Item) {
         let orig_current_item = mem::replace(&mut self.current_item, item.id);
         let orig_tables =
-            mem::replace(&mut self.tables, item_tables(self.tcx, item.id, self.empty_tables));
+            mem::replace(&mut self.tables, item_tables(self.tcx, item.hir_id, self.empty_tables));
         intravisit::walk_item(self, item);
         self.current_item = orig_current_item;
         self.tables = orig_tables;
@@ -849,14 +849,14 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
 
     fn visit_trait_item(&mut self, ti: &'tcx hir::TraitItem) {
         let orig_tables =
-            mem::replace(&mut self.tables, item_tables(self.tcx, ti.id, self.empty_tables));
+            mem::replace(&mut self.tables, item_tables(self.tcx, ti.hir_id, self.empty_tables));
         intravisit::walk_trait_item(self, ti);
         self.tables = orig_tables;
     }
 
     fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem) {
         let orig_tables =
-            mem::replace(&mut self.tables, item_tables(self.tcx, ii.id, self.empty_tables));
+            mem::replace(&mut self.tables, item_tables(self.tcx, ii.hir_id, self.empty_tables));
         intravisit::walk_impl_item(self, ii);
         self.tables = orig_tables;
     }
@@ -1114,7 +1114,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
             mem::replace(&mut self.current_item, self.tcx.hir().local_def_id(item.id));
         let orig_in_body = mem::replace(&mut self.in_body, false);
         let orig_tables =
-            mem::replace(&mut self.tables, item_tables(self.tcx, item.id, self.empty_tables));
+            mem::replace(&mut self.tables, item_tables(self.tcx, item.hir_id, self.empty_tables));
         intravisit::walk_item(self, item);
         self.tables = orig_tables;
         self.in_body = orig_in_body;
@@ -1123,14 +1123,14 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
 
     fn visit_trait_item(&mut self, ti: &'tcx hir::TraitItem) {
         let orig_tables =
-            mem::replace(&mut self.tables, item_tables(self.tcx, ti.id, self.empty_tables));
+            mem::replace(&mut self.tables, item_tables(self.tcx, ti.hir_id, self.empty_tables));
         intravisit::walk_trait_item(self, ti);
         self.tables = orig_tables;
     }
 
     fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem) {
         let orig_tables =
-            mem::replace(&mut self.tables, item_tables(self.tcx, ii.id, self.empty_tables));
+            mem::replace(&mut self.tables, item_tables(self.tcx, ii.hir_id, self.empty_tables));
         intravisit::walk_impl_item(self, ii);
         self.tables = orig_tables;
     }
@@ -1318,7 +1318,9 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
                                      match impl_item.node {
                                          hir::ImplItemKind::Const(..) |
                                          hir::ImplItemKind::Method(..) => {
-                                             self.access_levels.is_reachable(impl_item.id)
+                                             let node_id = self.tcx.hir().hir_to_node_id(
+                                                impl_item.hir_id);
+                                             self.access_levels.is_reachable(node_id)
                                          }
                                          hir::ImplItemKind::Existential(..) |
                                          hir::ImplItemKind::Type(_) => false,
@@ -1340,10 +1342,11 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
                                 // don't erroneously report errors for private
                                 // types in private items.
                                 let impl_item = self.tcx.hir().impl_item(impl_item_ref.id);
+                                let node_id = self.tcx.hir().hir_to_node_id(impl_item.hir_id);
                                 match impl_item.node {
                                     hir::ImplItemKind::Const(..) |
                                     hir::ImplItemKind::Method(..)
-                                        if self.item_is_public(&impl_item.id, &impl_item.vis) =>
+                                        if self.item_is_public(&node_id, &impl_item.vis) =>
                                     {
                                         intravisit::walk_impl_item(self, impl_item)
                                     }
@@ -1495,7 +1498,7 @@ fn visit_expr(&mut self, _: &'tcx hir::Expr) {}
 
 struct SearchInterfaceForPrivateItemsVisitor<'a, 'tcx: 'a> {
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
-    item_id: ast::NodeId,
+    item_id: hir::HirId,
     item_def_id: DefId,
     span: Span,
     /// The visitor checks that each component type is at least this visible.
@@ -1539,17 +1542,17 @@ fn ty(&mut self) -> &mut Self {
 
     fn check_def_id(&mut self, def_id: DefId, kind: &str, descr: &dyn fmt::Display) -> bool {
         if self.leaks_private_dep(def_id) {
-            self.tcx.lint_node(lint::builtin::EXPORTED_PRIVATE_DEPENDENCIES,
-                               self.item_id,
-                               self.span,
-                               &format!("{} `{}` from private dependency '{}' in public \
-                                         interface", kind, descr,
-                                         self.tcx.crate_name(def_id.krate)));
+            self.tcx.lint_hir(lint::builtin::EXPORTED_PRIVATE_DEPENDENCIES,
+                              self.item_id,
+                              self.span,
+                              &format!("{} `{}` from private dependency '{}' in public \
+                                        interface", kind, descr,
+                                        self.tcx.crate_name(def_id.krate)));
 
         }
 
-        let node_id = match self.tcx.hir().as_local_node_id(def_id) {
-            Some(node_id) => node_id,
+        let hir_id = match self.tcx.hir().as_local_hir_id(def_id) {
+            Some(hir_id) => hir_id,
             None => return false,
         };
 
@@ -1567,8 +1570,8 @@ fn check_def_id(&mut self, def_id: DefId, kind: &str, descr: &dyn fmt::Display)
                 err.emit();
             } else {
                 let err_code = if kind == "trait" { "E0445" } else { "E0446" };
-                self.tcx.lint_node(lint::builtin::PRIVATE_IN_PUBLIC, node_id, self.span,
-                                   &format!("{} (error {})", msg, err_code));
+                self.tcx.lint_hir(lint::builtin::PRIVATE_IN_PUBLIC, hir_id, self.span,
+                                  &format!("{} (error {})", msg, err_code));
             }
 
         }
@@ -1604,20 +1607,20 @@ struct PrivateItemsInPublicInterfacesVisitor<'a, 'tcx: 'a> {
 }
 
 impl<'a, 'tcx> PrivateItemsInPublicInterfacesVisitor<'a, 'tcx> {
-    fn check(&self, item_id: ast::NodeId, required_visibility: ty::Visibility)
+    fn check(&self, item_id: hir::HirId, required_visibility: ty::Visibility)
              -> SearchInterfaceForPrivateItemsVisitor<'a, 'tcx> {
         let mut has_old_errors = false;
 
         // Slow path taken only if there any errors in the crate.
         for &id in self.old_error_set {
             // Walk up the nodes until we find `item_id` (or we hit a root).
-            let mut id = self.tcx.hir().hir_to_node_id(id);
+            let mut id = id;
             loop {
                 if id == item_id {
                     has_old_errors = true;
                     break;
                 }
-                let parent = self.tcx.hir().get_parent_node(id);
+                let parent = self.tcx.hir().get_parent_node_by_hir_id(id);
                 if parent == id {
                     break;
                 }
@@ -1632,8 +1635,8 @@ fn check(&self, item_id: ast::NodeId, required_visibility: ty::Visibility)
         SearchInterfaceForPrivateItemsVisitor {
             tcx: self.tcx,
             item_id,
-            item_def_id: self.tcx.hir().local_def_id(item_id),
-            span: self.tcx.hir().span(item_id),
+            item_def_id: self.tcx.hir().local_def_id_from_hir_id(item_id),
+            span: self.tcx.hir().span_by_hir_id(item_id),
             required_visibility,
             has_pub_restricted: self.has_pub_restricted,
             has_old_errors,
@@ -1642,9 +1645,9 @@ fn check(&self, item_id: ast::NodeId, required_visibility: ty::Visibility)
         }
     }
 
-    fn check_trait_or_impl_item(&self, node_id: ast::NodeId, assoc_item_kind: AssociatedItemKind,
+    fn check_trait_or_impl_item(&self, hir_id: hir::HirId, assoc_item_kind: AssociatedItemKind,
                                 defaultness: hir::Defaultness, vis: ty::Visibility) {
-        let mut check = self.check(node_id, vis);
+        let mut check = self.check(hir_id, vis);
 
         let (check_ty, is_assoc_ty) = match assoc_item_kind {
             AssociatedItemKind::Const | AssociatedItemKind::Method { .. } => (true, false),
@@ -1682,30 +1685,31 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
             // Subitems of these items have inherited publicity.
             hir::ItemKind::Const(..) | hir::ItemKind::Static(..) |
             hir::ItemKind::Fn(..) | hir::ItemKind::Ty(..) => {
-                self.check(item.id, item_visibility).generics().predicates().ty();
+                self.check(item.hir_id, item_visibility).generics().predicates().ty();
             }
             hir::ItemKind::Existential(..) => {
                 // `ty()` for existential types is the underlying type,
                 // it's not a part of interface, so we skip it.
-                self.check(item.id, item_visibility).generics().predicates();
+                self.check(item.hir_id, item_visibility).generics().predicates();
             }
             hir::ItemKind::Trait(.., ref trait_item_refs) => {
-                self.check(item.id, item_visibility).generics().predicates();
+                self.check(item.hir_id, item_visibility).generics().predicates();
 
                 for trait_item_ref in trait_item_refs {
-                    self.check_trait_or_impl_item(trait_item_ref.id.node_id, trait_item_ref.kind,
+                    let hir_id = tcx.hir().node_to_hir_id(trait_item_ref.id.node_id);
+                    self.check_trait_or_impl_item(hir_id, trait_item_ref.kind,
                                                   trait_item_ref.defaultness, item_visibility);
                 }
             }
             hir::ItemKind::TraitAlias(..) => {
-                self.check(item.id, item_visibility).generics().predicates();
+                self.check(item.hir_id, item_visibility).generics().predicates();
             }
             hir::ItemKind::Enum(ref def, _) => {
-                self.check(item.id, item_visibility).generics().predicates();
+                self.check(item.hir_id, item_visibility).generics().predicates();
 
                 for variant in &def.variants {
                     for field in variant.node.data.fields() {
-                        self.check(field.id, item_visibility).ty();
+                        self.check(field.hir_id, item_visibility).ty();
                     }
                 }
             }
@@ -1713,17 +1717,17 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
             hir::ItemKind::ForeignMod(ref foreign_mod) => {
                 for foreign_item in &foreign_mod.items {
                     let vis = ty::Visibility::from_hir(&foreign_item.vis, item.id, tcx);
-                    self.check(foreign_item.id, vis).generics().predicates().ty();
+                    self.check(foreign_item.hir_id, vis).generics().predicates().ty();
                 }
             }
             // Subitems of structs and unions have their own publicity.
             hir::ItemKind::Struct(ref struct_def, _) |
             hir::ItemKind::Union(ref struct_def, _) => {
-                self.check(item.id, item_visibility).generics().predicates();
+                self.check(item.hir_id, item_visibility).generics().predicates();
 
                 for field in struct_def.fields() {
                     let field_visibility = ty::Visibility::from_hir(&field.vis, item.id, tcx);
-                    self.check(field.id, min(item_visibility, field_visibility, tcx)).ty();
+                    self.check(field.hir_id, min(item_visibility, field_visibility, tcx)).ty();
                 }
             }
             // An inherent impl is public when its type is public
@@ -1732,7 +1736,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
             // Subitems of trait impls have inherited publicity.
             hir::ItemKind::Impl(.., ref trait_ref, _, ref impl_item_refs) => {
                 let impl_vis = ty::Visibility::of_impl(item.id, tcx, &Default::default());
-                self.check(item.id, impl_vis).generics().predicates();
+                self.check(item.hir_id, impl_vis).generics().predicates();
                 for impl_item_ref in impl_item_refs {
                     let impl_item = tcx.hir().impl_item(impl_item_ref.id);
                     let impl_item_vis = if trait_ref.is_none() {
@@ -1740,7 +1744,8 @@ fn visit_item(&mut self, item: &'tcx hir::Item) {
                     } else {
                         impl_vis
                     };
-                    self.check_trait_or_impl_item(impl_item_ref.id.node_id, impl_item_ref.kind,
+                    let hir_id = tcx.hir().node_to_hir_id(impl_item_ref.id.node_id);
+                    self.check_trait_or_impl_item(hir_id, impl_item_ref.kind,
                                                   impl_item_ref.defaultness, impl_item_vis);
                 }
             }
index 1a7744786d80eefcd6cccc9462200d2b500ed9b3..e9331fcd8bad12676bf094972b7fe62e345dc50a 100644 (file)
@@ -806,9 +806,9 @@ fn visit_fn(&mut self,
         debug!("(resolving function) entering function");
         let (rib_kind, asyncness) = match function_kind {
             FnKind::ItemFn(_, ref header, ..) =>
-                (ItemRibKind, header.asyncness),
+                (ItemRibKind, header.asyncness.node),
             FnKind::Method(_, ref sig, _, _) =>
-                (TraitOrImplItemRibKind, sig.header.asyncness),
+                (TraitOrImplItemRibKind, sig.header.asyncness.node),
             FnKind::Closure(_) =>
                 // Async closures aren't resolved through `visit_fn`-- they're
                 // processed separately
@@ -863,7 +863,7 @@ fn visit_fn(&mut self,
 
     fn visit_generics(&mut self, generics: &'tcx Generics) {
         // For type parameter defaults, we have to ban access
-        // to following type parameters, as the Substs can only
+        // to following type parameters, as the InternalSubsts can only
         // provide previous type parameters as they're built. We
         // put all the parameters on the ban list and then remove
         // them one by one as they are processed and become available.
index 50a335bf908776cf26eee6351e7f6e61af868e7d..64a2c92d04dbd9289fe7d872843f8c60965599f0 100644 (file)
@@ -190,6 +190,7 @@ fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext<'_,
                 Ok(replace_text(nested, text))
             }
             ast::TyKind::Never => Ok(text_sig("!".to_owned())),
+            ast::TyKind::CVarArgs => Ok(text_sig("...".to_owned())),
             ast::TyKind::Tup(ref ts) => {
                 let mut text = "(".to_owned();
                 let mut defs = vec![];
@@ -378,7 +379,7 @@ fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext<'_,
                 if header.constness.node == ast::Constness::Const {
                     text.push_str("const ");
                 }
-                if header.asyncness.is_async() {
+                if header.asyncness.node.is_async() {
                     text.push_str("async ");
                 }
                 if header.unsafety == ast::Unsafety::Unsafe {
@@ -936,7 +937,7 @@ fn make_method_signature(
     if m.header.constness.node == ast::Constness::Const {
         text.push_str("const ");
     }
-    if m.header.asyncness.is_async() {
+    if m.header.asyncness.node.is_async() {
         text.push_str("async ");
     }
     if m.header.unsafety == ast::Unsafety::Unsafe {
index 52d7f3ac3dcbf5363b2e9c09de79ad2284150dd0..e3fee8e5700c196bb62e68d420a0b481e3fa7fd8 100644 (file)
@@ -99,7 +99,7 @@ pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'a, Ty>)
     // `extern "aapcs"`, then we must use the VFP registers for homogeneous aggregates.
     let vfp = cx.target_spec().llvm_target.ends_with("hf")
         && fty.conv != Conv::ArmAapcs
-        && !fty.variadic;
+        && !fty.c_variadic;
 
     if !fty.ret.is_ignore() {
         classify_ret_ty(cx, &mut fty.ret, vfp);
index 411eb192d902bda8c39009af308833628018e8f4..fbbd120f934be845fc21ac5e5a5c2245699cdc59 100644 (file)
 mod x86_win64;
 mod wasm32;
 
+#[derive(Clone, Copy, PartialEq, Eq, Debug)]
+pub enum IgnoreMode {
+    /// C-variadic arguments.
+    CVarArgs,
+    /// A zero-sized type.
+    Zst,
+}
+
 #[derive(Clone, Copy, PartialEq, Eq, Debug)]
 pub enum PassMode {
-    /// Ignore the argument (useful for empty struct).
-    Ignore,
+    /// Ignore the argument (useful for empty structs and C-variadic args).
+    Ignore(IgnoreMode),
     /// Pass the argument directly.
     Direct(ArgAttributes),
     /// Pass a pair's elements directly in two arguments.
@@ -481,7 +489,10 @@ pub fn is_unsized_indirect(&self) -> bool {
     }
 
     pub fn is_ignore(&self) -> bool {
-        self.mode == PassMode::Ignore
+        match self.mode {
+            PassMode::Ignore(_) => true,
+            _ => false
+        }
     }
 }
 
@@ -520,7 +531,7 @@ pub struct FnType<'a, Ty> {
     /// LLVM return type.
     pub ret: ArgType<'a, Ty>,
 
-    pub variadic: bool,
+    pub c_variadic: bool,
 
     pub conv: Conv,
 }
index 2e809571ab18b60fc87e40dc08961133f9133366..6ca3ce88bd6eb37a9aa9aaadf0d35c23812bccfe 100644 (file)
@@ -88,7 +88,7 @@ pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'a, Ty>, flavor: Fla
 
         for arg in &mut fty.args {
             let attrs = match arg.mode {
-                PassMode::Ignore |
+                PassMode::Ignore(_) |
                 PassMode::Indirect(_, None) => continue,
                 PassMode::Direct(ref mut attrs) => attrs,
                 PassMode::Pair(..) |
index adfd26814db1eb0f5acbb9c44bbfbfa26e030d86..3f88d0e08b46ae29eb286880dcdb5935fbe80df2 100644 (file)
@@ -10,7 +10,7 @@
     Environment,
 };
 use rustc::ty;
-use rustc::ty::subst::{Substs, Subst};
+use rustc::ty::subst::{InternalSubsts, Subst};
 use rustc::hir;
 use rustc::hir::def_id::DefId;
 use rustc_target::spec::abi;
@@ -105,7 +105,7 @@ fn assemble_builtin_sized_impls<'tcx>(
             let fn_ptr = generic_types::fn_ptr(
                 tcx,
                 fn_ptr.inputs_and_output.len(),
-                fn_ptr.variadic,
+                fn_ptr.c_variadic,
                 fn_ptr.unsafety,
                 fn_ptr.abi
             );
@@ -129,7 +129,7 @@ fn assemble_builtin_sized_impls<'tcx>(
 
         // Struct def
         ty::Adt(adt_def, _) => {
-            let substs = Substs::bound_vars_for_item(tcx, adt_def.did);
+            let substs = InternalSubsts::bound_vars_for_item(tcx, adt_def.did);
             let adt = tcx.mk_ty(ty::Adt(adt_def, substs));
             let sized_constraint = adt_def.sized_constraint(tcx)
                 .iter()
@@ -190,11 +190,11 @@ fn wf_clause_for_raw_ptr<'tcx>(
 fn wf_clause_for_fn_ptr<'tcx>(
     tcx: ty::TyCtxt<'_, '_, 'tcx>,
     arity_and_output: usize,
-    variadic: bool,
+    c_variadic: bool,
     unsafety: hir::Unsafety,
     abi: abi::Abi
 ) -> Clauses<'tcx> {
-    let fn_ptr = generic_types::fn_ptr(tcx, arity_and_output, variadic, unsafety, abi);
+    let fn_ptr = generic_types::fn_ptr(tcx, arity_and_output, c_variadic, unsafety, abi);
 
     let wf_clause = ProgramClause {
         goal: DomainGoal::WellFormed(WellFormed::Ty(fn_ptr)),
@@ -503,7 +503,7 @@ pub(super) fn program_clauses_impl(
                         wf_clause_for_fn_ptr(
                             self.infcx.tcx,
                             fn_ptr.inputs_and_output.len(),
-                            fn_ptr.variadic,
+                            fn_ptr.c_variadic,
                             fn_ptr.unsafety,
                             fn_ptr.abi
                         )
index 7185c4ce446406269172cd07591e320ea6f176aa..49fcb7cd8335532546e82a0ce5b97fbb409a30de 100644 (file)
@@ -4,7 +4,7 @@
 use rustc::traits::query::{CanonicalTyGoal, NoSolution};
 use rustc::traits::{TraitEngine, Normalized, ObligationCause, TraitEngineExt};
 use rustc::ty::query::Providers;
-use rustc::ty::subst::{Subst, Substs};
+use rustc::ty::subst::{Subst, InternalSubsts};
 use rustc::ty::{self, ParamEnvAnd, Ty, TyCtxt};
 use rustc::util::nodemap::FxHashSet;
 use rustc_data_structures::sync::Lrc;
@@ -291,7 +291,7 @@ fn dtorck_constraint_for_ty<'a, 'gcx, 'tcx>(
     if def.is_phantom_data() {
         // The first generic parameter here is guaranteed to be a type because it's
         // `PhantomData`.
-        let substs = Substs::identity_for_item(tcx, def_id);
+        let substs = InternalSubsts::identity_for_item(tcx, def_id);
         assert_eq!(substs.len(), 1);
         let result = DtorckConstraint {
             outlives: vec![],
index 03511e1d76d0562cf26fcd1b30046c768a1554d2..f2ce9631f35aba590620b862ac87efc73c397523 100644 (file)
@@ -1,7 +1,7 @@
 //! Utilities for creating generic types with bound vars in place of parameter values.
 
 use rustc::ty::{self, Ty, TyCtxt};
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::InternalSubsts;
 use rustc::hir;
 use rustc::hir::def_id::DefId;
 use rustc_target::spec::abi;
@@ -24,7 +24,7 @@
 crate fn fn_ptr(
     tcx: ty::TyCtxt<'_, '_, 'tcx>,
     arity_and_output: usize,
-    variadic: bool,
+    c_variadic: bool,
     unsafety: hir::Unsafety,
     abi: abi::Abi
 ) -> Ty<'tcx> {
@@ -37,7 +37,7 @@
 
     let fn_sig = ty::Binder::bind(ty::FnSig {
         inputs_and_output,
-        variadic,
+        c_variadic,
         unsafety,
         abi,
     });
 }
 
 crate fn fn_def(tcx: ty::TyCtxt<'_, '_, 'tcx>, def_id: DefId) -> Ty<'tcx> {
-    tcx.mk_ty(ty::FnDef(def_id, Substs::bound_vars_for_item(tcx, def_id)))
+    tcx.mk_ty(ty::FnDef(def_id, InternalSubsts::bound_vars_for_item(tcx, def_id)))
 }
 
 crate fn closure(tcx: ty::TyCtxt<'_, '_, 'tcx>, def_id: DefId) -> Ty<'tcx> {
     tcx.mk_closure(def_id, ty::ClosureSubsts {
-        substs: Substs::bound_vars_for_item(tcx, def_id),
+        substs: InternalSubsts::bound_vars_for_item(tcx, def_id),
     })
 }
 
 crate fn generator(tcx: ty::TyCtxt<'_, '_, 'tcx>, def_id: DefId) -> Ty<'tcx> {
     tcx.mk_generator(def_id, ty::GeneratorSubsts {
-        substs: Substs::bound_vars_for_item(tcx, def_id),
+        substs: InternalSubsts::bound_vars_for_item(tcx, def_id),
     }, hir::GeneratorMovability::Movable)
 }
index 908fdcfe7430fc0102321ea85ea673ab5a2a1910..44883d438a1e52eddbe93a724df59185e8e1d3dd 100644 (file)
@@ -18,7 +18,7 @@
 };
 use rustc::ty::query::Providers;
 use rustc::ty::{self, List, TyCtxt};
-use rustc::ty::subst::{Subst, Substs};
+use rustc::ty::subst::{Subst, InternalSubsts};
 use syntax::ast;
 
 use std::iter;
@@ -182,7 +182,7 @@ fn program_clauses_for_trait<'a, 'tcx>(
     // }
     // ```
 
-    let bound_vars = Substs::bound_vars_for_item(tcx, def_id);
+    let bound_vars = InternalSubsts::bound_vars_for_item(tcx, def_id);
 
     // `Self: Trait<P1..Pn>`
     let trait_pred = ty::TraitPredicate {
@@ -294,7 +294,7 @@ fn program_clauses_for_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId
     // }
     // ```
 
-    let bound_vars = Substs::bound_vars_for_item(tcx, def_id);
+    let bound_vars = InternalSubsts::bound_vars_for_item(tcx, def_id);
 
     let trait_ref = tcx.impl_trait_ref(def_id)
         .expect("not an impl")
@@ -336,7 +336,7 @@ pub fn program_clauses_for_type_def<'a, 'tcx>(
     // }
     // ```
 
-    let bound_vars = Substs::bound_vars_for_item(tcx, def_id);
+    let bound_vars = InternalSubsts::bound_vars_for_item(tcx, def_id);
 
     // `Ty<...>`
     let ty = tcx.type_of(def_id).subst(tcx, bound_vars);
@@ -426,7 +426,7 @@ pub fn program_clauses_for_associated_type_def<'a, 'tcx>(
         _ => bug!("not an trait container"),
     };
 
-    let trait_bound_vars = Substs::bound_vars_for_item(tcx, trait_id);
+    let trait_bound_vars = InternalSubsts::bound_vars_for_item(tcx, trait_id);
     let trait_ref = ty::TraitRef {
         def_id: trait_id,
         substs: trait_bound_vars,
@@ -564,7 +564,7 @@ pub fn program_clauses_for_associated_type_value<'a, 'tcx>(
         _ => bug!("not an impl container"),
     };
 
-    let impl_bound_vars = Substs::bound_vars_for_item(tcx, impl_id);
+    let impl_bound_vars = InternalSubsts::bound_vars_for_item(tcx, impl_id);
 
     // `A0 as Trait<A1..An>`
     let trait_ref = tcx.impl_trait_ref(impl_id)
@@ -612,8 +612,8 @@ struct ClauseDumper<'a, 'tcx: 'a> {
 }
 
 impl<'a, 'tcx> ClauseDumper<'a, 'tcx> {
-    fn process_attrs(&mut self, node_id: ast::NodeId, attrs: &[ast::Attribute]) {
-        let def_id = self.tcx.hir().local_def_id(node_id);
+    fn process_attrs(&mut self, hir_id: hir::HirId, attrs: &[ast::Attribute]) {
+        let def_id = self.tcx.hir().local_def_id_from_hir_id(hir_id);
         for attr in attrs {
             let mut clauses = None;
 
@@ -655,22 +655,22 @@ fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
     }
 
     fn visit_item(&mut self, item: &'tcx hir::Item) {
-        self.process_attrs(item.id, &item.attrs);
+        self.process_attrs(item.hir_id, &item.attrs);
         intravisit::walk_item(self, item);
     }
 
     fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
-        self.process_attrs(trait_item.id, &trait_item.attrs);
+        self.process_attrs(trait_item.hir_id, &trait_item.attrs);
         intravisit::walk_trait_item(self, trait_item);
     }
 
     fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
-        self.process_attrs(impl_item.id, &impl_item.attrs);
+        self.process_attrs(impl_item.hir_id, &impl_item.attrs);
         intravisit::walk_impl_item(self, impl_item);
     }
 
     fn visit_struct_field(&mut self, s: &'tcx hir::StructField) {
-        self.process_attrs(s.id, &s.attrs);
+        self.process_attrs(s.hir_id, &s.attrs);
         intravisit::walk_struct_field(self, s);
     }
 }
index db63f2aafbc24d1cb6bf528fd2dd1a9b58ec09b9..5dbcf908020b0505a6b3c33014bd8220fb946719 100644 (file)
 use rustc::traits;
 use rustc::ty::{self, Ty, TyCtxt, ToPredicate, TypeFoldable};
 use rustc::ty::{GenericParamDef, GenericParamDefKind};
-use rustc::ty::subst::{Kind, Subst, Substs};
+use rustc::ty::subst::{Kind, Subst, InternalSubsts, SubstsRef};
 use rustc::ty::wf::object_region_bounds;
 use rustc_data_structures::sync::Lrc;
 use rustc_target::spec::abi;
-use crate::require_c_abi_if_variadic;
+use crate::require_c_abi_if_c_variadic;
 use smallvec::SmallVec;
 use syntax::ast;
 use syntax::feature_gate::{GateIssue, emit_feature_err};
@@ -177,7 +177,7 @@ pub fn ast_path_substs_for_ty(&self,
         span: Span,
         def_id: DefId,
         item_segment: &hir::PathSegment)
-        -> &'tcx Substs<'tcx>
+        -> SubstsRef<'tcx>
     {
         let (substs, assoc_bindings, _) = item_segment.with_generic_args(|generic_args| {
             self.create_substs_for_ast_path(
@@ -436,7 +436,7 @@ pub fn create_substs_for_generic_args<'a, 'b>(
         args_for_def_id: impl Fn(DefId) -> (Option<&'b GenericArgs>, bool),
         provided_kind: impl Fn(&GenericParamDef, &GenericArg) -> Kind<'tcx>,
         inferred_kind: impl Fn(Option<&[Kind<'tcx>]>, &GenericParamDef, bool) -> Kind<'tcx>,
-    ) -> &'tcx Substs<'tcx> {
+    ) -> SubstsRef<'tcx> {
         // Collect the segments of the path; we need to substitute arguments
         // for parameters throughout the entire path (wherever there are
         // generic parameters).
@@ -548,7 +548,7 @@ fn create_substs_for_ast_path(&self,
         generic_args: &hir::GenericArgs,
         infer_types: bool,
         self_ty: Option<Ty<'tcx>>)
-        -> (&'tcx Substs<'tcx>, Vec<ConvertedBinding<'tcx>>, Option<Vec<Span>>)
+        -> (SubstsRef<'tcx>, Vec<ConvertedBinding<'tcx>>, Option<Vec<Span>>)
     {
         // If the type is parameterized by this region, then replace this
         // region with the current anon region binding (in other words,
@@ -718,7 +718,7 @@ pub(super) fn instantiate_poly_trait_ref_inner(&self,
             // specify type to assert that error was already reported in Err case:
             let predicate: Result<_, ErrorReported> =
                 self.ast_type_binding_to_poly_projection_predicate(
-                    trait_ref.ref_id, poly_trait_ref, binding, speculative, &mut dup_bindings);
+                    trait_ref.hir_ref_id, poly_trait_ref, binding, speculative, &mut dup_bindings);
             // okay to ignore Err because of ErrorReported (see above)
             Some((predicate.ok()?, binding.span))
         }));
@@ -760,7 +760,7 @@ fn create_substs_for_ast_trait_ref(
         trait_def_id: DefId,
         self_ty: Ty<'tcx>,
         trait_segment: &hir::PathSegment,
-    ) -> (&'tcx Substs<'tcx>, Vec<ConvertedBinding<'tcx>>, Option<Vec<Span>>) {
+    ) -> (SubstsRef<'tcx>, Vec<ConvertedBinding<'tcx>>, Option<Vec<Span>>) {
         debug!("create_substs_for_ast_trait_ref(trait_segment={:?})",
                trait_segment);
 
@@ -802,7 +802,7 @@ fn trait_defines_associated_type_named(&self,
 
     fn ast_type_binding_to_poly_projection_predicate(
         &self,
-        ref_id: ast::NodeId,
+        hir_ref_id: hir::HirId,
         trait_ref: ty::PolyTraitRef<'tcx>,
         binding: &ConvertedBinding<'tcx>,
         speculative: bool,
@@ -874,7 +874,6 @@ fn ast_type_binding_to_poly_projection_predicate(
                                           binding.item_name, binding.span)
         }?;
 
-        let hir_ref_id = self.tcx().hir().node_to_hir_id(ref_id);
         let (assoc_ident, def_scope) =
             tcx.adjust_ident(binding.item_name, candidate.def_id(), hir_ref_id);
         let assoc_ty = tcx.associated_items(candidate.def_id()).find(|i| {
@@ -1700,7 +1699,8 @@ pub fn def_to_ty(&self,
                 // `Self` in impl (we know the concrete type).
                 assert_eq!(opt_self_ty, None);
                 self.prohibit_generics(&path.segments);
-                tcx.at(span).type_of(def_id)
+                // Try to evaluate any array length constants
+                self.normalize_ty(span, tcx.at(span).type_of(def_id))
             }
             Def::SelfTy(Some(_), None) => {
                 // `Self` in trait.
@@ -1768,7 +1768,7 @@ pub fn ast_ty_to_ty(&self, ast_ty: &hir::Ty) -> Ty<'tcx> {
                 tcx.mk_tup(fields.iter().map(|t| self.ast_ty_to_ty(&t)))
             }
             hir::TyKind::BareFn(ref bf) => {
-                require_c_abi_if_variadic(tcx, &bf.decl, bf.abi, ast_ty.span);
+                require_c_abi_if_c_variadic(tcx, &bf.decl, bf.abi, ast_ty.span);
                 tcx.mk_fn_ptr(self.ty_of_fn(bf.unsafety, bf.abi, &bf.decl))
             }
             hir::TyKind::TraitObject(ref bounds, ref lifetime) => {
@@ -1797,8 +1797,8 @@ pub fn ast_ty_to_ty(&self, ast_ty: &hir::Ty) -> Ty<'tcx> {
                 self.associated_path_to_ty(ast_ty.hir_id, ast_ty.span, ty, def, segment, false).0
             }
             hir::TyKind::Array(ref ty, ref length) => {
-                let length_def_id = tcx.hir().local_def_id(length.id);
-                let substs = Substs::identity_for_item(tcx, length_def_id);
+                let length_def_id = tcx.hir().local_def_id_from_hir_id(length.hir_id);
+                let substs = InternalSubsts::identity_for_item(tcx, length_def_id);
                 let length = ty::LazyConst::Unevaluated(length_def_id, substs);
                 let length = tcx.mk_lazy_const(length);
                 let array_ty = tcx.mk_ty(ty::Array(self.ast_ty_to_ty(&ty), length));
@@ -1822,6 +1822,15 @@ pub fn ast_ty_to_ty(&self, ast_ty: &hir::Ty) -> Ty<'tcx> {
             hir::TyKind::Err => {
                 tcx.types.err
             }
+            hir::TyKind::CVarArgs(lt) => {
+                let va_list_did = match tcx.lang_items().va_list() {
+                    Some(did) => did,
+                    None => span_bug!(ast_ty.span,
+                                      "`va_list` lang item required for variadics"),
+                };
+                let region = self.ast_region_to_region(&lt, None);
+                tcx.type_of(va_list_did).subst(tcx, &[region.into()])
+            }
         };
 
         self.record_ty(ast_ty.hir_id, result_ty, ast_ty.span);
@@ -1839,7 +1848,7 @@ pub fn impl_trait_ty_to_ty(
         let generics = tcx.generics_of(def_id);
 
         debug!("impl_trait_ty_to_ty: generics={:?}", generics);
-        let substs = Substs::for_item(tcx, def_id, |param, _| {
+        let substs = InternalSubsts::for_item(tcx, def_id, |param, _| {
             if let Some(i) = (param.index as usize).checked_sub(generics.parent_count) {
                 // Our own parameters are the resolved lifetimes.
                 match param.kind {
@@ -1904,7 +1913,7 @@ pub fn ty_of_fn(&self,
         let bare_fn_ty = ty::Binder::bind(tcx.mk_fn_sig(
             input_tys,
             output_ty,
-            decl.variadic,
+            decl.c_variadic,
             unsafety,
             abi
         ));
index 100e55fc36723848dfd71b8f6217aaf9e7b12561..e27672842dbc1d70a20302ecb3b0fd78b21eae85 100644 (file)
@@ -227,7 +227,7 @@ pub fn check_pat_walk(
                 self.demand_eqtype_pat(pat.span, expected, rhs_ty, match_discrim_span);
                 common_type
             }
-            PatKind::Binding(ba, var_id, _, _, ref sub) => {
+            PatKind::Binding(ba, _, var_id, _, ref sub) => {
                 let bm = if ba == hir::BindingAnnotation::Unannotated {
                     def_bm
                 } else {
@@ -239,7 +239,7 @@ pub fn check_pat_walk(
                     .pat_binding_modes_mut()
                     .insert(pat.hir_id, bm);
                 debug!("check_pat_walk: pat.hir_id={:?} bm={:?}", pat.hir_id, bm);
-                let local_ty = self.local_ty(pat.span, pat.id).decl_ty;
+                let local_ty = self.local_ty(pat.span, pat.hir_id).decl_ty;
                 match bm {
                     ty::BindByReference(mutbl) => {
                         // if the binding is like
@@ -265,7 +265,7 @@ pub fn check_pat_walk(
 
                 // if there are multiple arms, make sure they all agree on
                 // what the type of the binding `x` ought to be
-                if var_id != pat.id {
+                if var_id != pat.hir_id {
                     let vt = self.local_ty(pat.span, var_id).decl_ty;
                     self.demand_eqtype_pat(pat.span, vt, local_ty, match_discrim_span);
                 }
index 7bf7d82540655325bca06a4f2feafec6e10b228a..0a4c0eb3aff72c1b25b5a34fb47dee71ec71c67f 100644 (file)
@@ -368,20 +368,30 @@ fn confirm_builtin_call(
             .0;
         let fn_sig = self.normalize_associated_types_in(call_expr.span, &fn_sig);
 
+        let inputs = if fn_sig.c_variadic {
+            if fn_sig.inputs().len() > 1 {
+                &fn_sig.inputs()[..fn_sig.inputs().len() - 1]
+            } else {
+                span_bug!(call_expr.span,
+                          "C-variadic functions are only valid with one or more fixed arguments");
+            }
+        } else {
+            &fn_sig.inputs()[..]
+        };
         // Call the generic checker.
         let expected_arg_tys = self.expected_inputs_for_expected_output(
             call_expr.span,
             expected,
             fn_sig.output(),
-            fn_sig.inputs(),
+            inputs,
         );
         self.check_argument_types(
             call_expr.span,
             call_expr.span,
-            fn_sig.inputs(),
+            inputs,
             &expected_arg_tys[..],
             arg_exprs,
-            fn_sig.variadic,
+            fn_sig.c_variadic,
             TupleArgumentsFlag::DontTupleArguments,
             def_span,
         );
@@ -414,7 +424,7 @@ fn confirm_deferred_closure_call(
             fn_sig.inputs(),
             &expected_arg_tys,
             arg_exprs,
-            fn_sig.variadic,
+            fn_sig.c_variadic,
             TupleArgumentsFlag::TupleArguments,
             None,
         );
index 97ee973938ccbbe1e1d4b2d664ea069bbf55f600..87276b8c66ca4a8102963aa68ebe20577ee60521 100644 (file)
@@ -37,9 +37,9 @@
 use rustc::session::Session;
 use rustc::traits;
 use rustc::ty::{self, Ty, TypeFoldable, TypeAndMut};
+use rustc::ty::subst::SubstsRef;
 use rustc::ty::adjustment::AllowTwoPhase;
 use rustc::ty::cast::{CastKind, CastTy};
-use rustc::ty::subst::Substs;
 use rustc::middle::lang_items;
 use syntax::ast;
 use syntax_pos::Span;
@@ -69,7 +69,7 @@ enum PointerKind<'tcx> {
     /// The unsize info of this projection
     OfProjection(&'tcx ty::ProjectionTy<'tcx>),
     /// The unsize info of this opaque ty
-    OfOpaque(DefId, &'tcx Substs<'tcx>),
+    OfOpaque(DefId, SubstsRef<'tcx>),
     /// The unsize info of this parameter
     OfParam(&'tcx ty::ParamTy),
 }
index 220adc2de7b6137f70b2fcc0cdecb46d7d2573c0..db89b32be7b68d109acbc19f557bdcb747d495de 100644 (file)
@@ -12,7 +12,7 @@
 use rustc::traits::error_reporting::ArgKind;
 use rustc::ty::{self, Ty, GenericParamDefKind};
 use rustc::ty::fold::TypeFoldable;
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::InternalSubsts;
 use std::cmp;
 use std::iter;
 use rustc_target::spec::abi::Abi;
@@ -95,7 +95,7 @@ fn check_closure(
         // types of upvars. These will be unified during the upvar
         // inference phase (`upvar.rs`).
         let base_substs =
-            Substs::identity_for_item(self.tcx, self.tcx.closure_base_def_id(expr_def_id));
+            InternalSubsts::identity_for_item(self.tcx, self.tcx.closure_base_def_id(expr_def_id));
         let substs = base_substs.extend_to(self.tcx,expr_def_id, |param, _| {
             match param.kind {
                 GenericParamDefKind::Lifetime => {
@@ -141,7 +141,7 @@ fn check_closure(
             self.tcx.mk_fn_sig(
                 iter::once(self.tcx.intern_tup(sig.inputs())),
                 sig.output(),
-                sig.variadic,
+                sig.c_variadic,
                 sig.unsafety,
                 sig.abi,
             )
@@ -386,7 +386,7 @@ fn sig_of_closure_with_expectation(
         // Watch out for some surprises and just ignore the
         // expectation if things don't see to match up with what we
         // expect.
-        if expected_sig.sig.variadic != decl.variadic {
+        if expected_sig.sig.c_variadic != decl.c_variadic {
             return self.sig_of_closure_no_expectation(expr_def_id, decl, body);
         } else if expected_sig.sig.inputs_and_output.len() != decl.inputs.len() + 1 {
             return self.sig_of_closure_with_mismatched_number_of_arguments(
@@ -404,7 +404,7 @@ fn sig_of_closure_with_expectation(
         let bound_sig = ty::Binder::bind(self.tcx.mk_fn_sig(
             expected_sig.sig.inputs().iter().cloned(),
             expected_sig.sig.output(),
-            decl.variadic,
+            decl.c_variadic,
             hir::Unsafety::Normal,
             Abi::RustCall,
         ));
@@ -586,7 +586,7 @@ fn supplied_sig_of_closure(
         let result = ty::Binder::bind(self.tcx.mk_fn_sig(
             supplied_arguments,
             supplied_return,
-            decl.variadic,
+            decl.c_variadic,
             hir::Unsafety::Normal,
             Abi::RustCall,
         ));
@@ -621,7 +621,7 @@ fn error_sig_of_closure(&self, decl: &hir::FnDecl) -> ty::PolyFnSig<'tcx> {
         let result = ty::Binder::bind(self.tcx.mk_fn_sig(
             supplied_arguments,
             self.tcx.types.err,
-            decl.variadic,
+            decl.c_variadic,
             hir::Unsafety::Normal,
             Abi::RustCall,
         ));
index ebd7dad58fd038235148168eb55e992ee2919995..64f61d5e5232e988c6e93a4a4c93d0950bea3e4f 100644 (file)
@@ -823,7 +823,7 @@ fn try_find_coercion_lub<E>(&self,
         debug!("coercion::try_find_coercion_lub({:?}, {:?})", prev_ty, new_ty);
 
         // Special-case that coercion alone cannot handle:
-        // Two function item types of differing IDs or Substs.
+        // Two function item types of differing IDs or InternalSubsts.
         if let (&ty::FnDef(..), &ty::FnDef(..)) = (&prev_ty.sty, &new_ty.sty) {
             // Don't reify if the function types have a LUB, i.e., they
             // are the same function and their parameters have a LUB.
index c6b34672e6b4c485102fc60786211633ddc84626..e061a5304eb28dbe9f2ccf1230678bdef6ad452d 100644 (file)
@@ -4,7 +4,7 @@
 use rustc::ty::util::ExplicitSelf;
 use rustc::traits::{self, ObligationCause, ObligationCauseCode, Reveal};
 use rustc::ty::error::{ExpectedFound, TypeError};
-use rustc::ty::subst::{Subst, Substs};
+use rustc::ty::subst::{Subst, InternalSubsts, SubstsRef};
 use rustc::util::common::ErrorReported;
 use errors::Applicability;
 
@@ -160,7 +160,7 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     // a fresh FulfillmentCtxt, and invoke select_all_or_error.
 
     // Create mapping from impl to placeholder.
-    let impl_to_skol_substs = Substs::identity_for_item(tcx, impl_m.def_id);
+    let impl_to_skol_substs = InternalSubsts::identity_for_item(tcx, impl_m.def_id);
 
     // Create mapping from trait to placeholder.
     let trait_to_skol_substs = impl_to_skol_substs.rebase_onto(tcx,
@@ -361,7 +361,7 @@ fn check_region_bounds_on_impl_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                                                 trait_m: &ty::AssociatedItem,
                                                 trait_generics: &ty::Generics,
                                                 impl_generics: &ty::Generics,
-                                                trait_to_skol_substs: &Substs<'tcx>)
+                                                trait_to_skol_substs: SubstsRef<'tcx>)
                                                 -> Result<(), ErrorReported> {
     let trait_params = trait_generics.own_counts().lifetimes;
     let impl_params = impl_generics.own_counts().lifetimes;
index ad74e78fecdcdb1270e7b743975cc57b6be0bd79..12c7484f0f9213c672d99995067c5cbfbf94925f 100644 (file)
@@ -6,7 +6,7 @@
 use rustc::infer::{self, InferOk, SuppressRegionErrors};
 use rustc::middle::region;
 use rustc::traits::{ObligationCause, TraitEngine, TraitEngineExt};
-use rustc::ty::subst::{Subst, Substs, UnpackedKind};
+use rustc::ty::subst::{Subst, SubstsRef, UnpackedKind};
 use rustc::ty::{self, Ty, TyCtxt};
 use crate::util::common::ErrorReported;
 
@@ -145,7 +145,7 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'a, 'tcx>(
     drop_impl_did: DefId,
     dtor_predicates: &ty::GenericPredicates<'tcx>,
     self_type_did: DefId,
-    self_to_impl_substs: &Substs<'tcx>,
+    self_to_impl_substs: SubstsRef<'tcx>,
 ) -> Result<(), ErrorReported> {
     let mut result = Ok(());
 
index 3b174b55f2ba02c0e0934a81b1658897896a05f8..924ced2e2a3c77c1cd76729e63734ebd2384fd82 100644 (file)
@@ -337,7 +337,7 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
             "va_start" | "va_end" => {
                 match mk_va_list_ty() {
                     Some(va_list_ty) => (0, vec![va_list_ty], tcx.mk_unit()),
-                    None => bug!("va_list lang_item must be defined to use va_list intrinsics")
+                    None => bug!("`va_list` language item needed for C-variadic intrinsics")
                 }
             }
 
@@ -364,14 +364,14 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                         };
                         (0, vec![tcx.mk_imm_ref(tcx.mk_region(env_region), va_list_ty)], ret_ty)
                     }
-                    None => bug!("va_list lang_item must be defined to use va_list intrinsics")
+                    None => bug!("`va_list` language item needed for C-variadic intrinsics")
                 }
             }
 
             "va_arg" => {
                 match mk_va_list_ty() {
                     Some(va_list_ty) => (1, vec![va_list_ty], param(0)),
-                    None => bug!("va_list lang_item must be defined to use va_list intrinsics")
+                    None => bug!("`va_list` language item needed for C-variadic intrinsics")
                 }
             }
 
index 1eaa8b17d09f7e64ed48e2db09a90b33a64bce6a..996d6cfd5683069cbce19ebaed5c5995f2baa638 100644 (file)
@@ -4,10 +4,9 @@
 use crate::check::{FnCtxt, PlaceOp, callee, Needs};
 use crate::hir::GenericArg;
 use crate::hir::def_id::DefId;
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::{Subst, SubstsRef};
 use rustc::traits;
 use rustc::ty::{self, Ty, GenericParamDefKind};
-use rustc::ty::subst::Subst;
 use rustc::ty::adjustment::{Adjustment, Adjust, OverloadedDeref};
 use rustc::ty::adjustment::{AllowTwoPhase, AutoBorrow, AutoBorrowMutability};
 use rustc::ty::fold::TypeFoldable;
@@ -209,7 +208,7 @@ fn adjust_self_ty(&mut self,
     fn fresh_receiver_substs(&mut self,
                              self_ty: Ty<'tcx>,
                              pick: &probe::Pick<'tcx>)
-                             -> &'tcx Substs<'tcx> {
+                             -> SubstsRef<'tcx> {
         match pick.kind {
             probe::InherentImplPick => {
                 let impl_def_id = pick.item.container.id();
@@ -300,8 +299,8 @@ fn instantiate_method_substs(
         &mut self,
         pick: &probe::Pick<'tcx>,
         seg: &hir::PathSegment,
-        parent_substs: &Substs<'tcx>,
-    ) -> &'tcx Substs<'tcx> {
+        parent_substs: SubstsRef<'tcx>,
+    ) -> SubstsRef<'tcx> {
         // Determine the values for the generic parameters of the method.
         // If they were not explicitly supplied, just construct fresh
         // variables.
@@ -369,7 +368,7 @@ fn unify_receivers(&mut self, self_ty: Ty<'tcx>, method_self_ty: Ty<'tcx>) {
     // until we unify the `Self` type.
     fn instantiate_method_sig(&mut self,
                               pick: &probe::Pick<'tcx>,
-                              all_substs: &'tcx Substs<'tcx>)
+                              all_substs: SubstsRef<'tcx>)
                               -> (ty::FnSig<'tcx>, ty::InstantiatedPredicates<'tcx>) {
         debug!("instantiate_method_sig(pick={:?}, all_substs={:?})",
                pick,
@@ -404,7 +403,7 @@ fn instantiate_method_sig(&mut self,
 
     fn add_obligations(&mut self,
                        fty: Ty<'tcx>,
-                       all_substs: &Substs<'tcx>,
+                       all_substs: SubstsRef<'tcx>,
                        method_predicates: &ty::InstantiatedPredicates<'tcx>) {
         debug!("add_obligations: fty={:?} all_substs={:?} method_predicates={:?}",
                fty,
index b14c56ddad008fa03c9ed1c0bb347f1490b918f3..d81d24e6d2b0356eeac16de309e01ca7aea47c3c 100644 (file)
@@ -18,7 +18,7 @@
 use rustc::hir::def::Def;
 use rustc::hir::def_id::DefId;
 use rustc::traits;
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::{InternalSubsts, SubstsRef};
 use rustc::ty::{self, Ty, ToPredicate, ToPolyTraitRef, TraitRef, TypeFoldable};
 use rustc::ty::GenericParamDefKind;
 use rustc::ty::subst::Subst;
@@ -38,7 +38,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) {
 pub struct MethodCallee<'tcx> {
     /// Impl method ID, for inherent methods, or trait method ID, otherwise.
     pub def_id: DefId,
-    pub substs: &'tcx Substs<'tcx>,
+    pub substs: SubstsRef<'tcx>,
 
     /// Instantiated method signature, i.e., it has been
     /// substituted, normalized, and has had late-bound
@@ -281,7 +281,7 @@ pub fn lookup_method_in_trait(&self,
                trait_def_id);
 
         // Construct a trait-reference `self_ty : Trait<input_tys>`
-        let substs = Substs::for_item(self.tcx, trait_def_id, |param, _| {
+        let substs = InternalSubsts::for_item(self.tcx, trait_def_id, |param, _| {
             match param.kind {
                 GenericParamDefKind::Lifetime => {}
                 GenericParamDefKind::Type {..} => {
index 312d83cebbab3e631e46bcf1386356d96fbb9e53..a4624eebcba830e11304c9c43a7cd03c9394b042 100644 (file)
@@ -13,7 +13,7 @@
 use rustc::hir;
 use rustc::lint;
 use rustc::session::config::nightly_options;
-use rustc::ty::subst::{Subst, Substs};
+use rustc::ty::subst::{Subst, InternalSubsts, SubstsRef};
 use rustc::traits::{self, ObligationCause};
 use rustc::traits::query::{CanonicalTyGoal};
 use rustc::traits::query::method_autoderef::{CandidateStep, MethodAutoderefStepsResult};
@@ -125,7 +125,7 @@ struct Candidate<'tcx> {
 
 #[derive(Debug)]
 enum CandidateKind<'tcx> {
-    InherentImplCandidate(&'tcx Substs<'tcx>,
+    InherentImplCandidate(SubstsRef<'tcx>,
                           // Normalize obligations
                           Vec<traits::PredicateObligation<'tcx>>),
     ObjectCandidate,
@@ -1480,7 +1480,7 @@ fn record_static_candidate(&mut self, source: CandidateSource) {
     fn xform_self_ty(&self,
                      item: &ty::AssociatedItem,
                      impl_ty: Ty<'tcx>,
-                     substs: &Substs<'tcx>)
+                     substs: SubstsRef<'tcx>)
                      -> (Ty<'tcx>, Option<Ty<'tcx>>) {
         if item.kind == ty::AssociatedKind::Method && self.mode == Mode::MethodCall {
             let sig = self.xform_method_sig(item.def_id, substs);
@@ -1492,7 +1492,7 @@ fn xform_self_ty(&self,
 
     fn xform_method_sig(&self,
                         method: DefId,
-                        substs: &Substs<'tcx>)
+                        substs: SubstsRef<'tcx>)
                         -> ty::FnSig<'tcx>
     {
         let fn_sig = self.tcx.fn_sig(method);
@@ -1517,7 +1517,7 @@ fn xform_method_sig(&self,
         if generics.params.is_empty() {
             xform_fn_sig.subst(self.tcx, substs)
         } else {
-            let substs = Substs::for_item(self.tcx, method, |param, _| {
+            let substs = InternalSubsts::for_item(self.tcx, method, |param, _| {
                 let i = param.index as usize;
                 if i < substs.len() {
                     substs[i]
@@ -1537,12 +1537,12 @@ fn xform_method_sig(&self,
     }
 
     /// Gets the type of an impl and generate substitutions with placeholders.
-    fn impl_ty_and_substs(&self, impl_def_id: DefId) -> (Ty<'tcx>, &'tcx Substs<'tcx>) {
+    fn impl_ty_and_substs(&self, impl_def_id: DefId) -> (Ty<'tcx>, SubstsRef<'tcx>) {
         (self.tcx.type_of(impl_def_id), self.fresh_item_substs(impl_def_id))
     }
 
-    fn fresh_item_substs(&self, def_id: DefId) -> &'tcx Substs<'tcx> {
-        Substs::for_item(self.tcx, def_id, |param, _| {
+    fn fresh_item_substs(&self, def_id: DefId) -> SubstsRef<'tcx> {
+        InternalSubsts::for_item(self.tcx, def_id, |param, _| {
             match param.kind {
                 GenericParamDefKind::Lifetime => self.tcx.types.re_erased.into(),
                 GenericParamDefKind::Type {..} => {
index d77aabcda2d8d6bc70a4216e5badda16ed628928..80ffe441561013c5553f9ac483d9532c0b64046f 100644 (file)
 use rustc::ty::adjustment::{Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability};
 use rustc::ty::fold::TypeFoldable;
 use rustc::ty::query::Providers;
-use rustc::ty::subst::{UnpackedKind, Subst, Substs, UserSelfTy, UserSubsts};
+use rustc::ty::subst::{UnpackedKind, Subst, InternalSubsts, SubstsRef, UserSelfTy, UserSubsts};
 use rustc::ty::util::{Representability, IntTypeExt, Discr};
 use rustc::ty::layout::VariantIdx;
 use syntax_pos::{self, BytePos, Span, MultiSpan};
 use std::ops::{self, Deref};
 use std::slice;
 
-use crate::require_c_abi_if_variadic;
-use crate::session::{CompileIncomplete, Session};
+use crate::require_c_abi_if_c_variadic;
+use crate::session::Session;
 use crate::session::config::EntryFnType;
 use crate::TypeAndSubsts;
 use crate::lint;
 use crate::util::captures::Captures;
 use crate::util::common::{ErrorReported, indenter};
-use crate::util::nodemap::{DefIdMap, DefIdSet, FxHashMap, FxHashSet, HirIdMap, NodeMap};
+use crate::util::nodemap::{DefIdMap, DefIdSet, FxHashMap, FxHashSet, HirIdMap};
 
 pub use self::Expectation::*;
 use self::autoderef::Autoderef;
@@ -194,7 +194,7 @@ pub struct Inherited<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
 
     tables: MaybeInProgressTables<'a, 'tcx>,
 
-    locals: RefCell<NodeMap<LocalTy<'tcx>>>,
+    locals: RefCell<HirIdMap<LocalTy<'tcx>>>,
 
     fulfillment_cx: RefCell<Box<dyn TraitEngine<'tcx>>>,
 
@@ -711,12 +711,12 @@ fn check_mod_item_types<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId)
     tcx.hir().visit_item_likes_in_module(module_def_id, &mut CheckItemTypesVisitor { tcx });
 }
 
-pub fn check_item_bodies<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Result<(), CompileIncomplete> {
+pub fn check_item_bodies<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Result<(), ErrorReported> {
     tcx.typeck_item_bodies(LOCAL_CRATE)
 }
 
 fn typeck_item_bodies<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum)
-                                -> Result<(), CompileIncomplete>
+                                -> Result<(), ErrorReported>
 {
     debug_assert!(crate_num == LOCAL_CRATE);
     Ok(tcx.sess.track_errors(|| {
@@ -943,7 +943,7 @@ struct GatherLocalsVisitor<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
 }
 
 impl<'a, 'gcx, 'tcx> GatherLocalsVisitor<'a, 'gcx, 'tcx> {
-    fn assign(&mut self, span: Span, nid: ast::NodeId, ty_opt: Option<LocalTy<'tcx>>) -> Ty<'tcx> {
+    fn assign(&mut self, span: Span, nid: hir::HirId, ty_opt: Option<LocalTy<'tcx>>) -> Ty<'tcx> {
         match ty_opt {
             None => {
                 // infer the variable's type
@@ -994,19 +994,19 @@ fn visit_local(&mut self, local: &'gcx hir::Local) {
             },
             None => None,
         };
-        self.assign(local.span, local.id, local_ty);
+        self.assign(local.span, local.hir_id, local_ty);
 
         debug!("Local variable {:?} is assigned type {}",
                local.pat,
                self.fcx.ty_to_string(
-                   self.fcx.locals.borrow().get(&local.id).unwrap().clone().decl_ty));
+                   self.fcx.locals.borrow().get(&local.hir_id).unwrap().clone().decl_ty));
         intravisit::walk_local(self, local);
     }
 
     // Add pattern bindings.
     fn visit_pat(&mut self, p: &'gcx hir::Pat) {
         if let PatKind::Binding(_, _, _, ident, _) = p.node {
-            let var_ty = self.assign(p.span, p.id, None);
+            let var_ty = self.assign(p.span, p.hir_id, None);
 
             if !self.fcx.tcx.features().unsized_locals {
                 self.fcx.require_type_is_sized(var_ty, p.span,
@@ -1016,7 +1016,7 @@ fn visit_pat(&mut self, p: &'gcx hir::Pat) {
             debug!("Pattern binding {} is assigned to {} with type {:?}",
                    ident,
                    self.fcx.ty_to_string(
-                       self.fcx.locals.borrow().get(&p.id).unwrap().clone().decl_ty),
+                       self.fcx.locals.borrow().get(&p.hir_id).unwrap().clone().decl_ty),
                    var_ty);
         }
         intravisit::walk_pat(self, p);
@@ -1072,7 +1072,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>,
     fn_sig = fcx.tcx.mk_fn_sig(
         fn_sig.inputs().iter().cloned(),
         revealed_ret_ty,
-        fn_sig.variadic,
+        fn_sig.c_variadic,
         fn_sig.unsafety,
         fn_sig.abi
     );
@@ -1318,7 +1318,7 @@ fn check_union<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 fn check_opaque<'a, 'tcx>(
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
     def_id: DefId,
-    substs: &'tcx Substs<'tcx>,
+    substs: SubstsRef<'tcx>,
     span: Span,
 ) {
     if let Err(partially_expanded_type) = tcx.try_expand_impl_trait_type(def_id, substs) {
@@ -1385,7 +1385,7 @@ pub fn check_item_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Ite
         hir::ItemKind::Existential(..) => {
             let def_id = tcx.hir().local_def_id(it.id);
 
-            let substs = Substs::identity_for_item(tcx, def_id);
+            let substs = InternalSubsts::identity_for_item(tcx, def_id);
             check_opaque(tcx, def_id, substs, it.span);
         }
         hir::ItemKind::Ty(..) => {
@@ -1426,7 +1426,7 @@ pub fn check_item_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, it: &'tcx hir::Ite
                     }
 
                     if let hir::ForeignItemKind::Fn(ref fn_decl, _, _) = item.node {
-                        require_c_abi_if_variadic(tcx, fn_decl, m.abi, item.span);
+                        require_c_abi_if_c_variadic(tcx, fn_decl, m.abi, item.span);
                     }
                 }
             }
@@ -1554,7 +1554,8 @@ fn check_impl_items_against_trait<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     // Check existing impl methods to see if they are both present in trait
     // and compatible with trait signature
     for impl_item in impl_items() {
-        let ty_impl_item = tcx.associated_item(tcx.hir().local_def_id(impl_item.id));
+        let ty_impl_item = tcx.associated_item(
+            tcx.hir().local_def_id_from_hir_id(impl_item.hir_id));
         let ty_trait_item = tcx.associated_items(impl_trait_ref.def_id)
             .find(|ac| Namespace::from(&impl_item.node) == Namespace::from(ac.kind) &&
                        tcx.hygienic_eq(ty_impl_item.ident, ac.ident, impl_trait_ref.def_id))
@@ -1809,7 +1810,7 @@ fn check_transparent<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sp: Span, def_id: De
 
     // For each field, figure out if it's known to be a ZST and align(1)
     let field_infos = adt.non_enum_variant().fields.iter().map(|field| {
-        let ty = field.ty(tcx, Substs::identity_for_item(tcx, field.did));
+        let ty = field.ty(tcx, InternalSubsts::identity_for_item(tcx, field.did));
         let param_env = tcx.param_env(field.did);
         let layout = tcx.layout_of(param_env.and(ty));
         // We are currently checking the type this field came from, so it must be local
@@ -1870,7 +1871,7 @@ pub fn check_enum<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 
     for v in vs {
         if let Some(ref e) = v.node.disr_expr {
-            tcx.typeck_tables_of(tcx.hir().local_def_id(e.id));
+            tcx.typeck_tables_of(tcx.hir().local_def_id_from_hir_id(e.hir_id));
         }
     }
 
@@ -2124,10 +2125,10 @@ pub fn tag(&self) -> String {
         format!("{:?}", self_ptr)
     }
 
-    pub fn local_ty(&self, span: Span, nid: ast::NodeId) -> LocalTy<'tcx> {
+    pub fn local_ty(&self, span: Span, nid: hir::HirId) -> LocalTy<'tcx> {
         self.locals.borrow().get(&nid).cloned().unwrap_or_else(||
             span_bug!(span, "no type for local variable {}",
-                      self.tcx.hir().node_to_string(nid))
+                      self.tcx.hir().hir_to_string(nid))
         )
     }
 
@@ -2177,7 +2178,7 @@ pub fn write_method_call(&self,
             if !method_generics.params.is_empty() {
                 let user_type_annotation = self.infcx.probe(|_| {
                     let user_substs = UserSubsts {
-                        substs: Substs::for_item(self.tcx, method.def_id, |param, _| {
+                        substs: InternalSubsts::for_item(self.tcx, method.def_id, |param, _| {
                             let i = param.index as usize;
                             if i < method_generics.parent_count {
                                 self.infcx.var_for_def(DUMMY_SP, param)
@@ -2200,7 +2201,7 @@ pub fn write_method_call(&self,
         }
     }
 
-    pub fn write_substs(&self, node_id: hir::HirId, substs: &'tcx Substs<'tcx>) {
+    pub fn write_substs(&self, node_id: hir::HirId, substs: SubstsRef<'tcx>) {
         if !substs.is_noop() {
             debug!("write_substs({:?}, {:?}) in fcx {}",
                    node_id,
@@ -2222,7 +2223,7 @@ pub fn write_user_type_annotation_from_substs(
         &self,
         hir_id: hir::HirId,
         def_id: DefId,
-        substs: &'tcx Substs<'tcx>,
+        substs: SubstsRef<'tcx>,
         user_self_ty: Option<UserSelfTy<'tcx>>,
     ) {
         debug!(
@@ -2303,7 +2304,7 @@ pub fn apply_adjustments(&self, expr: &hir::Expr, adj: Vec<Adjustment<'tcx>>) {
     /// types as well. This function combines the two.
     fn instantiate_type_scheme<T>(&self,
                                   span: Span,
-                                  substs: &Substs<'tcx>,
+                                  substs: SubstsRef<'tcx>,
                                   value: &T)
                                   -> T
         where T : TypeFoldable<'tcx>
@@ -2319,7 +2320,7 @@ fn instantiate_type_scheme<T>(&self,
 
     /// As `instantiate_type_scheme`, but for the bounds found in a
     /// generic type scheme.
-    fn instantiate_bounds(&self, span: Span, def_id: DefId, substs: &Substs<'tcx>)
+    fn instantiate_bounds(&self, span: Span, def_id: DefId, substs: SubstsRef<'tcx>)
                           -> ty::InstantiatedPredicates<'tcx> {
         let bounds = self.tcx.predicates_of(def_id);
         let result = bounds.instantiate(self.tcx, substs);
@@ -2477,7 +2478,7 @@ pub fn register_wf_obligation(&self,
     }
 
     /// Registers obligations that all types appearing in `substs` are well-formed.
-    pub fn add_wf_bounds(&self, substs: &Substs<'tcx>, expr: &hir::Expr) {
+    pub fn add_wf_bounds(&self, substs: SubstsRef<'tcx>, expr: &hir::Expr) {
         for ty in substs.types() {
             self.register_wf_obligation(ty, expr.span, traits::MiscObligation);
         }
@@ -2521,7 +2522,7 @@ pub fn add_obligations_for_parameters(&self,
     pub fn field_ty(&self,
                     span: Span,
                     field: &'tcx ty::FieldDef,
-                    substs: &Substs<'tcx>)
+                    substs: SubstsRef<'tcx>)
                     -> Ty<'tcx>
     {
         self.normalize_associated_types_in(span, &field.ty(self.tcx, substs))
@@ -2783,7 +2784,7 @@ fn check_method_argument_types(&self,
             &method.sig.inputs()[1..]
         );
         self.check_argument_types(sp, expr_sp, &method.sig.inputs()[1..], &expected_arg_tys[..],
-                                  args_no_rcvr, method.sig.variadic, tuple_arguments,
+                                  args_no_rcvr, method.sig.c_variadic, tuple_arguments,
                                   self.tcx.hir().span_if_local(method.def_id));
         method.sig.output()
     }
@@ -2862,7 +2863,7 @@ fn check_argument_types(&self,
                             fn_inputs: &[Ty<'tcx>],
                             mut expected_arg_tys: &[Ty<'tcx>],
                             args: &'gcx [hir::Expr],
-                            variadic: bool,
+                            c_variadic: bool,
                             tuple_arguments: TupleArgumentsFlag,
                             def_span: Option<Span>) {
         let tcx = self.tcx;
@@ -2886,11 +2887,11 @@ fn check_argument_types(&self,
         let param_count_error = |expected_count: usize,
                                  arg_count: usize,
                                  error_code: &str,
-                                 variadic: bool,
+                                 c_variadic: bool,
                                  sugg_unit: bool| {
             let mut err = tcx.sess.struct_span_err_with_code(sp,
                 &format!("this function takes {}{} but {} {} supplied",
-                    if variadic {"at least "} else {""},
+                    if c_variadic { "at least " } else { "" },
                     potentially_plural_count(expected_count, "parameter"),
                     potentially_plural_count(arg_count, "parameter"),
                     if arg_count == 1 {"was"} else {"were"}),
@@ -2910,7 +2911,7 @@ fn check_argument_types(&self,
                     Applicability::MachineApplicable);
             } else {
                 err.span_label(sp, format!("expected {}{}",
-                                           if variadic {"at least "} else {""},
+                                           if c_variadic { "at least " } else { "" },
                                            potentially_plural_count(expected_count, "parameter")));
             }
             err.emit();
@@ -2944,7 +2945,7 @@ fn check_argument_types(&self,
             }
         } else if expected_arg_count == supplied_arg_count {
             fn_inputs.to_vec()
-        } else if variadic {
+        } else if c_variadic {
             if supplied_arg_count >= expected_arg_count {
                 fn_inputs.to_vec()
             } else {
@@ -2991,10 +2992,10 @@ fn check_argument_types(&self,
                 self.select_obligations_where_possible(false);
             }
 
-            // For variadic functions, we don't have a declared type for all of
+            // For C-variadic functions, we don't have a declared type for all of
             // the arguments hence we only do our usual type checking with
             // the arguments who's types we do know.
-            let t = if variadic {
+            let t = if c_variadic {
                 expected_arg_count
             } else if tuple_arguments == TupleArguments {
                 args.len()
@@ -3043,7 +3044,7 @@ fn check_argument_types(&self,
 
         // We also need to make sure we at least write the ty of the other
         // arguments which we skipped above.
-        if variadic {
+        if c_variadic {
             fn variadic_error<'tcx>(s: &Session, span: Span, t: Ty<'tcx>, cast_ty: &str) {
                 use crate::structured_errors::{VariadicError, StructuredDiagnostic};
                 VariadicError::new(s, span, t, cast_ty).diagnostic().emit();
@@ -4552,9 +4553,9 @@ fn check_expr_kind(
                 tcx.mk_array(element_ty, args.len() as u64)
             }
             ExprKind::Repeat(ref element, ref count) => {
-                let count_def_id = tcx.hir().local_def_id(count.id);
+                let count_def_id = tcx.hir().local_def_id_from_hir_id(count.hir_id);
                 let param_env = ty::ParamEnv::empty();
-                let substs = Substs::identity_for_item(tcx.global_tcx(), count_def_id);
+                let substs = InternalSubsts::identity_for_item(tcx.global_tcx(), count_def_id);
                 let instance = ty::Instance::resolve(
                     tcx.global_tcx(),
                     param_env,
@@ -4805,7 +4806,7 @@ pub fn check_decl_initializer(&self,
         // See #44848.
         let ref_bindings = local.pat.contains_explicit_ref_binding();
 
-        let local_ty = self.local_ty(init.span, local.id).revealed_ty;
+        let local_ty = self.local_ty(init.span, local.hir_id).revealed_ty;
         if let Some(m) = ref_bindings {
             // Somewhat subtle: if we have a `ref` binding in the pattern,
             // we want to avoid introducing coercions for the RHS. This is
@@ -4824,7 +4825,7 @@ pub fn check_decl_initializer(&self,
     }
 
     pub fn check_decl_local(&self, local: &'gcx hir::Local) {
-        let t = self.local_ty(local.span, local.id).decl_ty;
+        let t = self.local_ty(local.span, local.hir_id).decl_ty;
         self.write_ty(local.hir_id, t);
 
         if let Some(ref init) = local.init {
@@ -5378,7 +5379,8 @@ pub fn instantiate_value_path(&self,
 
         match def {
             Def::Local(nid) | Def::Upvar(nid, ..) => {
-                let ty = self.local_ty(span, nid).decl_ty;
+                let hid = self.tcx.hir().node_to_hir_id(nid);
+                let ty = self.local_ty(span, hid).decl_ty;
                 let ty = self.normalize_associated_types_in(span, &ty);
                 self.write_ty(hir_id, ty);
                 return (ty, def);
index bf4df19556d0277736601ee70b26bf739cb01db7..b549986777c84dcbd7f1da5fefc36db5d1ae48d2 100644 (file)
@@ -81,7 +81,7 @@
 use rustc::infer::outlives::env::OutlivesEnvironment;
 use rustc::infer::{self, RegionObligation, SuppressRegionErrors};
 use rustc::ty::adjustment;
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::SubstsRef;
 use rustc::ty::{self, Ty};
 
 use rustc::hir::intravisit::{self, NestedVisitorMap, Visitor};
@@ -1393,7 +1393,7 @@ fn link_reborrowed_region(
     fn substs_wf_in_scope(
         &mut self,
         origin: infer::ParameterOrigin,
-        substs: &Substs<'tcx>,
+        substs: SubstsRef<'tcx>,
         expr_span: Span,
         expr_region: ty::Region<'tcx>,
     ) {
index 9217484f3a7af84714eb1d8db04f7f0140ba4cb2..b7c862a89a1b4d8cc29f3bb2e3c6370c650294a5 100644 (file)
@@ -4,7 +4,7 @@
 use crate::hir::def_id::DefId;
 use rustc::traits::{self, ObligationCauseCode};
 use rustc::ty::{self, Lift, Ty, TyCtxt, TyKind, GenericParamDefKind, TypeFoldable, ToPredicate};
-use rustc::ty::subst::{Subst, Substs};
+use rustc::ty::subst::{Subst, InternalSubsts};
 use rustc::util::nodemap::{FxHashSet, FxHashMap};
 use rustc::middle::lang_items;
 use rustc::infer::opaque_types::may_define_existential_type;
@@ -108,14 +108,14 @@ pub fn check_item_well_formed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: Def
             check_item_fn(tcx, item);
         }
         hir::ItemKind::Static(ref ty, ..) => {
-            check_item_type(tcx, item.id, ty.span, false);
+            check_item_type(tcx, item.hir_id, ty.span, false);
         }
         hir::ItemKind::Const(ref ty, ..) => {
-            check_item_type(tcx, item.id, ty.span, false);
+            check_item_type(tcx, item.hir_id, ty.span, false);
         }
         hir::ItemKind::ForeignMod(ref module) => for it in module.items.iter() {
             if let hir::ForeignItemKind::Static(ref ty, ..) = it.node {
-                check_item_type(tcx, it.id, ty.span, true);
+                check_item_type(tcx, it.hir_id, ty.span, true);
             }
         },
         hir::ItemKind::Struct(ref struct_def, ref ast_generics) => {
@@ -157,7 +157,7 @@ pub fn check_trait_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {
         hir::TraitItemKind::Method(ref sig, _) => Some(sig),
         _ => None
     };
-    check_associated_item(tcx, trait_item.id, trait_item.span, method_sig);
+    check_associated_item(tcx, trait_item.hir_id, trait_item.span, method_sig);
 }
 
 pub fn check_impl_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {
@@ -168,18 +168,18 @@ pub fn check_impl_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) {
         hir::ImplItemKind::Method(ref sig, _) => Some(sig),
         _ => None
     };
-    check_associated_item(tcx, impl_item.id, impl_item.span, method_sig);
+    check_associated_item(tcx, impl_item.hir_id, impl_item.span, method_sig);
 }
 
 fn check_associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
-                                   item_id: ast::NodeId,
+                                   item_id: hir::HirId,
                                    span: Span,
                                    sig_if_method: Option<&hir::MethodSig>) {
     debug!("check_associated_item: {:?}", item_id);
 
     let code = ObligationCauseCode::MiscObligation;
     for_id(tcx, item_id, span).with_fcx(|fcx, tcx| {
-        let item = fcx.tcx.associated_item(fcx.tcx.hir().local_def_id(item_id));
+        let item = fcx.tcx.associated_item(fcx.tcx.hir().local_def_id_from_hir_id(item_id));
 
         let (mut implied_bounds, self_ty) = match item.container {
             ty::TraitContainer(_) => (vec![], fcx.tcx.mk_self_type()),
@@ -220,16 +220,15 @@ fn check_associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 
 fn for_item<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>, item: &hir::Item)
                             -> CheckWfFcxBuilder<'a, 'gcx, 'tcx> {
-    for_id(tcx, item.id, item.span)
+    for_id(tcx, item.hir_id, item.span)
 }
 
-fn for_id<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>, id: ast::NodeId, span: Span)
+fn for_id<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>, id: hir::HirId, span: Span)
                           -> CheckWfFcxBuilder<'a, 'gcx, 'tcx> {
-    let def_id = tcx.hir().local_def_id(id);
-    let hir_id = tcx.hir().node_to_hir_id(id);
+    let def_id = tcx.hir().local_def_id_from_hir_id(id);
     CheckWfFcxBuilder {
         inherited: Inherited::build(tcx, def_id),
-        id: hir_id,
+        id,
         span,
         param_env: tcx.param_env(def_id),
     }
@@ -339,14 +338,14 @@ fn check_item_fn<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item: &hir::Item) {
 
 fn check_item_type<'a, 'tcx>(
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
-    item_id: ast::NodeId,
+    item_id: hir::HirId,
     ty_span: Span,
     allow_foreign_ty: bool,
 ) {
     debug!("check_item_type: {:?}", item_id);
 
     for_id(tcx, item_id, ty_span).with_fcx(|fcx, gcx| {
-        let ty = gcx.type_of(gcx.hir().local_def_id(item_id));
+        let ty = gcx.type_of(gcx.hir().local_def_id_from_hir_id(item_id));
         let item_ty = fcx.normalize_associated_types_in(ty_span, &ty);
 
         let mut forbid_unsized = true;
@@ -459,7 +458,7 @@ fn check_where_clauses<'a, 'gcx, 'fcx, 'tcx>(
     // For more examples see tests `defaults-well-formedness.rs` and `type-check-defaults.rs`.
     //
     // First we build the defaulted substitution.
-    let substs = Substs::for_item(fcx.tcx, def_id, |param, _| {
+    let substs = InternalSubsts::for_item(fcx.tcx, def_id, |param, _| {
         match param.kind {
             GenericParamDefKind::Lifetime => {
                 // All regions are identity.
@@ -1025,13 +1024,13 @@ fn visit_item(&mut self, i: &'tcx hir::Item) {
 
     fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
         debug!("visit_trait_item: {:?}", trait_item);
-        let def_id = self.tcx.hir().local_def_id(trait_item.id);
+        let def_id = self.tcx.hir().local_def_id_from_hir_id(trait_item.hir_id);
         self.tcx.ensure().check_trait_item_well_formed(def_id);
     }
 
     fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
         debug!("visit_impl_item: {:?}", impl_item);
-        let def_id = self.tcx.hir().local_def_id(impl_item.id);
+        let def_id = self.tcx.hir().local_def_id_from_hir_id(impl_item.hir_id);
         self.tcx.ensure().check_impl_item_well_formed(def_id);
     }
 }
index 7c1283a6d210866dd561e58ac0f2616f383a27a6..5981d9bb66bfca81017017746321923d38667a79 100644 (file)
@@ -287,7 +287,7 @@ fn visit_pat(&mut self, p: &'gcx hir::Pat) {
 
     fn visit_local(&mut self, l: &'gcx hir::Local) {
         intravisit::walk_local(self, l);
-        let var_ty = self.fcx.local_ty(l.span, l.id).decl_ty;
+        let var_ty = self.fcx.local_ty(l.span, l.hir_id).decl_ty;
         let var_ty = self.resolve(&var_ty, &l.span);
         self.write_ty_to_tables(l.hir_id, var_ty);
     }
index 70f7c30f7ecb68a43bf113113ce50008605f77fc..4c6d7710009bf9dd502c5b7931c571f8021c6b44 100644 (file)
@@ -34,7 +34,7 @@ fn visit_item(&mut self, item: &hir::Item) {
             return;
         }
         if let hir::ItemKind::Use(ref path, _) = item.node {
-            self.check_import(item.id, path.span);
+            self.check_import(item.hir_id, path.span);
         }
     }
 
@@ -51,14 +51,13 @@ struct CheckVisitor<'a, 'tcx: 'a> {
 }
 
 impl<'a, 'tcx> CheckVisitor<'a, 'tcx> {
-    fn check_import(&self, id: ast::NodeId, span: Span) {
-        let def_id = self.tcx.hir().local_def_id(id);
+    fn check_import(&self, id: hir::HirId, span: Span) {
+        let def_id = self.tcx.hir().local_def_id_from_hir_id(id);
         if !self.tcx.maybe_unused_trait_import(def_id) {
             return;
         }
 
-        let import_def_id = self.tcx.hir().local_def_id(id);
-        if self.used_trait_imports.contains(&import_def_id) {
+        if self.used_trait_imports.contains(&def_id) {
             return;
         }
 
@@ -67,7 +66,7 @@ fn check_import(&self, id: ast::NodeId, span: Span) {
         } else {
             "unused import".to_owned()
         };
-        self.tcx.lint_node(lint::builtin::UNUSED_IMPORTS, id, span, &msg);
+        self.tcx.lint_hir(lint::builtin::UNUSED_IMPORTS, id, span, &msg);
     }
 }
 
@@ -121,8 +120,8 @@ fn unused_crates_lint<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) {
     });
 
     for extern_crate in &crates_to_lint {
-        let id = tcx.hir().as_local_node_id(extern_crate.def_id).unwrap();
-        let item = tcx.hir().expect_item(id);
+        let id = tcx.hir().as_local_hir_id(extern_crate.def_id).unwrap();
+        let item = tcx.hir().expect_item_by_hir_id(id);
 
         // If the crate is fully unused, we suggest removing it altogether.
         // We do this in any edition.
@@ -135,7 +134,7 @@ fn unused_crates_lint<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) {
                     .map(|attr| attr.span)
                     .fold(span, |acc, attr_span| acc.to(attr_span));
 
-                tcx.struct_span_lint_node(lint, id, span, msg)
+                tcx.struct_span_lint_hir(lint, id, span, msg)
                     .span_suggestion_short(
                         span_with_attrs,
                         "remove it",
@@ -177,7 +176,7 @@ fn unused_crates_lint<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) {
             None => format!("use {};", item.ident.name),
         };
         let replacement = visibility_qualified(&item.vis, base_replacement);
-        tcx.struct_span_lint_node(lint, id, extern_crate.span, msg)
+        tcx.struct_span_lint_hir(lint, id, extern_crate.span, msg)
             .span_suggestion_short(
                 extern_crate.span,
                 &help,
index 282f1bad172dca5ed204d8e02b34e7b4a6fb9036..a51f45a6ff8f3e30785723838b6672e7784e8cb1 100644 (file)
@@ -36,11 +36,11 @@ fn check_for_common_items_in_impls(&self, impl1: DefId, impl2: DefId,
 
             for &item2 in &impl_items2[..] {
                 if (name, namespace) == name_and_namespace(item2) {
-                    let node_id = self.tcx.hir().as_local_node_id(impl1);
-                    let mut err = if used_to_be_allowed && node_id.is_some() {
-                        self.tcx.struct_span_lint_node(
+                    let hir_id = self.tcx.hir().as_local_hir_id(impl1);
+                    let mut err = if used_to_be_allowed && hir_id.is_some() {
+                        self.tcx.struct_span_lint_hir(
                             lint::builtin::INCOHERENT_FUNDAMENTAL_IMPLS,
-                            node_id.unwrap(),
+                            hir_id.unwrap(),
                             self.tcx.span_of_impl(item1).unwrap(),
                             &format!("duplicate definitions with name `{}` (E0592)", name)
                         )
index 2153582819c6f8a369195c247ad6715f90c8318e..16102ad4cde30703d8715138d4bfcc32651fabaf 100644 (file)
@@ -23,7 +23,7 @@
 use crate::middle::weak_lang_items;
 use rustc::mir::mono::Linkage;
 use rustc::ty::query::Providers;
-use rustc::ty::subst::{Subst, Substs};
+use rustc::ty::subst::{Subst, InternalSubsts};
 use rustc::ty::util::Discr;
 use rustc::ty::util::IntTypeExt;
 use rustc::ty::subst::UnpackedKind;
@@ -152,12 +152,12 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
     }
 
     fn visit_trait_item(&mut self, trait_item: &'tcx hir::TraitItem) {
-        convert_trait_item(self.tcx, trait_item.id);
+        convert_trait_item(self.tcx, trait_item.hir_id);
         intravisit::walk_trait_item(self, trait_item);
     }
 
     fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem) {
-        convert_impl_item(self.tcx, impl_item.id);
+        convert_impl_item(self.tcx, impl_item.hir_id);
         intravisit::walk_impl_item(self, impl_item);
     }
 }
@@ -479,9 +479,9 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) {
     }
 }
 
-fn convert_trait_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_item_id: ast::NodeId) {
-    let trait_item = tcx.hir().expect_trait_item(trait_item_id);
-    let def_id = tcx.hir().local_def_id(trait_item.id);
+fn convert_trait_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_item_id: hir::HirId) {
+    let trait_item = tcx.hir().expect_trait_item_by_hir_id(trait_item_id);
+    let def_id = tcx.hir().local_def_id_from_hir_id(trait_item.hir_id);
     tcx.generics_of(def_id);
 
     match trait_item.node {
@@ -500,12 +500,12 @@ fn convert_trait_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, trait_item_id: ast:
     tcx.predicates_of(def_id);
 }
 
-fn convert_impl_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_item_id: ast::NodeId) {
-    let def_id = tcx.hir().local_def_id(impl_item_id);
+fn convert_impl_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, impl_item_id: hir::HirId) {
+    let def_id = tcx.hir().local_def_id_from_hir_id(impl_item_id);
     tcx.generics_of(def_id);
     tcx.type_of(def_id);
     tcx.predicates_of(def_id);
-    if let hir::ImplItemKind::Method(..) = tcx.hir().expect_impl_item(impl_item_id).node {
+    if let hir::ImplItemKind::Method(..) = tcx.hir().expect_impl_item_by_hir_id(impl_item_id).node {
         tcx.fn_sig(def_id);
     }
 }
@@ -532,7 +532,7 @@ fn convert_enum_variant_types<'a, 'tcx>(
         let wrapped_discr = prev_discr.map_or(initial, |d| d.wrap_incr(tcx));
         prev_discr = Some(
             if let Some(ref e) = variant.node.disr_expr {
-                let expr_did = tcx.hir().local_def_id(e.id);
+                let expr_did = tcx.hir().local_def_id_from_hir_id(e.hir_id);
                 def.eval_explicit_discr(tcx, expr_did)
             } else if let Some(discr) = repr_type.disr_incr(tcx, prev_discr) {
                 Some(discr)
@@ -637,7 +637,7 @@ fn adt_def<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx ty::Ad
                         let did = tcx.hir().local_def_id(v.node.data.id());
                         let discr = if let Some(ref e) = v.node.disr_expr {
                             distance_from_explicit = 0;
-                            ty::VariantDiscr::Explicit(tcx.hir().local_def_id(e.id))
+                            ty::VariantDiscr::Explicit(tcx.hir().local_def_id_from_hir_id(e.hir_id))
                         } else {
                             ty::VariantDiscr::Relative(distance_from_explicit)
                         };
@@ -1142,14 +1142,14 @@ fn report_assoc_ty_on_inherent_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, span:
 fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> {
     use rustc::hir::*;
 
-    let node_id = tcx.hir().as_local_node_id(def_id).unwrap();
+    let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
 
     let icx = ItemCtxt::new(tcx, def_id);
 
-    match tcx.hir().get(node_id) {
+    match tcx.hir().get_by_hir_id(hir_id) {
         Node::TraitItem(item) => match item.node {
             TraitItemKind::Method(..) => {
-                let substs = Substs::identity_for_item(tcx, def_id);
+                let substs = InternalSubsts::identity_for_item(tcx, def_id);
                 tcx.mk_fn_def(def_id, substs)
             }
             TraitItemKind::Const(ref ty, _) | TraitItemKind::Type(_, Some(ref ty)) => icx.to_ty(ty),
@@ -1160,13 +1160,13 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> {
 
         Node::ImplItem(item) => match item.node {
             ImplItemKind::Method(..) => {
-                let substs = Substs::identity_for_item(tcx, def_id);
+                let substs = InternalSubsts::identity_for_item(tcx, def_id);
                 tcx.mk_fn_def(def_id, substs)
             }
             ImplItemKind::Const(ref ty, _) => icx.to_ty(ty),
             ImplItemKind::Existential(_) => {
                 if tcx
-                    .impl_trait_ref(tcx.hir().get_parent_did(node_id))
+                    .impl_trait_ref(tcx.hir().get_parent_did_by_hir_id(hir_id))
                     .is_none()
                 {
                     report_assoc_ty_on_inherent_impl(tcx, item.span);
@@ -1176,7 +1176,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> {
             }
             ImplItemKind::Type(ref ty) => {
                 if tcx
-                    .impl_trait_ref(tcx.hir().get_parent_did(node_id))
+                    .impl_trait_ref(tcx.hir().get_parent_did_by_hir_id(hir_id))
                     .is_none()
                 {
                     report_assoc_ty_on_inherent_impl(tcx, item.span);
@@ -1193,12 +1193,12 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> {
                 | ItemKind::Ty(ref t, _)
                 | ItemKind::Impl(.., ref t, _) => icx.to_ty(t),
                 ItemKind::Fn(..) => {
-                    let substs = Substs::identity_for_item(tcx, def_id);
+                    let substs = InternalSubsts::identity_for_item(tcx, def_id);
                     tcx.mk_fn_def(def_id, substs)
                 }
                 ItemKind::Enum(..) | ItemKind::Struct(..) | ItemKind::Union(..) => {
                     let def = tcx.adt_def(def_id);
-                    let substs = Substs::identity_for_item(tcx, def_id);
+                    let substs = InternalSubsts::identity_for_item(tcx, def_id);
                     tcx.mk_adt(def, substs)
                 }
                 ItemKind::Existential(hir::ExistTy {
@@ -1246,7 +1246,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> {
 
         Node::ForeignItem(foreign_item) => match foreign_item.node {
             ForeignItemKind::Fn(..) => {
-                let substs = Substs::identity_for_item(tcx, def_id);
+                let substs = InternalSubsts::identity_for_item(tcx, def_id);
                 tcx.mk_fn_def(def_id, substs)
             }
             ForeignItemKind::Static(ref t, _) => icx.to_ty(t),
@@ -1259,10 +1259,10 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> {
             ..
         }) => match *def {
             VariantData::Unit(..) | VariantData::Struct(..) => {
-                tcx.type_of(tcx.hir().get_parent_did(node_id))
+                tcx.type_of(tcx.hir().get_parent_did_by_hir_id(hir_id))
             }
             VariantData::Tuple(..) => {
-                let substs = Substs::identity_for_item(tcx, def_id);
+                let substs = InternalSubsts::identity_for_item(tcx, def_id);
                 tcx.mk_fn_def(def_id, substs)
             }
         },
@@ -1274,18 +1274,19 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> {
             ..
         }) => {
             if gen.is_some() {
-                let hir_id = tcx.hir().node_to_hir_id(node_id);
                 return tcx.typeck_tables_of(def_id).node_type(hir_id);
             }
 
             let substs = ty::ClosureSubsts {
-                substs: Substs::identity_for_item(tcx, def_id),
+                substs: InternalSubsts::identity_for_item(tcx, def_id),
             };
 
             tcx.mk_closure(def_id, substs)
         }
 
-        Node::AnonConst(_) => match tcx.hir().get(tcx.hir().get_parent_node(node_id)) {
+        Node::AnonConst(_) => match tcx.hir().get_by_hir_id(
+            tcx.hir().get_parent_node_by_hir_id(hir_id))
+        {
             Node::Ty(&hir::Ty {
                 node: hir::TyKind::Array(_, ref constant),
                 ..
@@ -1297,7 +1298,7 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> {
             | Node::Expr(&hir::Expr {
                 node: ExprKind::Repeat(_, ref constant),
                 ..
-            }) if constant.id == node_id =>
+            }) if constant.hir_id == hir_id =>
             {
                 tcx.types.usize
             }
@@ -1309,9 +1310,9 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> {
                         ..
                     },
                 ..
-            }) if e.id == node_id =>
+            }) if e.hir_id == hir_id =>
             {
-                tcx.adt_def(tcx.hir().get_parent_did(node_id))
+                tcx.adt_def(tcx.hir().get_parent_did_by_hir_id(hir_id))
                     .repr
                     .discr_type()
                     .to_ty(tcx)
@@ -1484,7 +1485,7 @@ fn visit_item(&mut self, it: &'tcx Item) {
             }
         }
         fn visit_impl_item(&mut self, it: &'tcx ImplItem) {
-            let def_id = self.tcx.hir().local_def_id(it.id);
+            let def_id = self.tcx.hir().local_def_id_from_hir_id(it.hir_id);
             // the existential type itself or its children are not within its reveal scope
             if def_id != self.def_id {
                 self.check(def_id);
@@ -1492,7 +1493,7 @@ fn visit_impl_item(&mut self, it: &'tcx ImplItem) {
             }
         }
         fn visit_trait_item(&mut self, it: &'tcx TraitItem) {
-            let def_id = self.tcx.hir().local_def_id(it.id);
+            let def_id = self.tcx.hir().local_def_id_from_hir_id(it.hir_id);
             self.check(def_id);
             intravisit::walk_trait_item(self, it);
         }
@@ -1829,7 +1830,7 @@ fn extend<I: IntoIterator<Item = (ty::Predicate<'tcx>, Span)>>(&mut self, iter:
 
         Node::ImplItem(item) => match item.node {
             ImplItemKind::Existential(ref bounds) => {
-                let substs = Substs::identity_for_item(tcx, def_id);
+                let substs = InternalSubsts::identity_for_item(tcx, def_id);
                 let opaque_ty = tcx.mk_opaque(def_id, substs);
 
                 // Collect the bounds, i.e., the `A+B+'c` in `impl A+B+'c`.
@@ -1874,7 +1875,7 @@ fn extend<I: IntoIterator<Item = (ty::Predicate<'tcx>, Span)>>(&mut self, iter:
                     impl_trait_fn,
                     ref generics,
                 }) => {
-                    let substs = Substs::identity_for_item(tcx, def_id);
+                    let substs = InternalSubsts::identity_for_item(tcx, def_id);
                     let opaque_ty = tcx.mk_opaque(def_id, substs);
 
                     // Collect the bounds, i.e., the `A+B+'c` in `impl A+B+'c`.
@@ -2062,7 +2063,8 @@ fn extend<I: IntoIterator<Item = (ty::Predicate<'tcx>, Span)>>(&mut self, iter:
             };
 
             let assoc_ty =
-                tcx.mk_projection(tcx.hir().local_def_id(trait_item.id), self_trait_ref.substs);
+                tcx.mk_projection(tcx.hir().local_def_id_from_hir_id(trait_item.hir_id),
+                    self_trait_ref.substs);
 
             let bounds = compute_bounds(
                 &ItemCtxt::new(tcx, def_id),
index bd9b4fecbecc1acde9d39c8fc7a48f0abc46e394..a918113b1fc0b44ac02c8ab8fe1dbbb85ea8536d 100644 (file)
 use rustc::lint;
 use rustc::middle;
 use rustc::session;
-use rustc::session::CompileIncomplete;
+use rustc::util::common::ErrorReported;
 use rustc::session::config::{EntryFnType, nightly_options};
 use rustc::traits::{ObligationCause, ObligationCauseCode, TraitEngine, TraitEngineExt};
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::SubstsRef;
 use rustc::ty::{self, Ty, TyCtxt};
 use rustc::ty::query::Providers;
 use rustc::util;
 use std::iter;
 
 pub struct TypeAndSubsts<'tcx> {
-    substs: &'tcx Substs<'tcx>,
+    substs: SubstsRef<'tcx>,
     ty: Ty<'tcx>,
 }
 
@@ -136,14 +136,14 @@ fn check_type_alias_enum_variants_enabled<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx,
     }
 }
 
-fn require_c_abi_if_variadic(tcx: TyCtxt<'_, '_, '_>,
-                             decl: &hir::FnDecl,
-                             abi: Abi,
-                             span: Span) {
-    if decl.variadic && !(abi == Abi::C || abi == Abi::Cdecl) {
+fn require_c_abi_if_c_variadic(tcx: TyCtxt<'_, '_, '_>,
+                               decl: &hir::FnDecl,
+                               abi: Abi,
+                               span: Span) {
+    if decl.c_variadic && !(abi == Abi::C || abi == Abi::Cdecl) {
         let mut err = struct_span_err!(tcx.sess, span, E0045,
-            "variadic function must have C or cdecl calling convention");
-        err.span_label(span, "variadics require C or cdecl calling convention").emit();
+            "C-variadic function must have C or cdecl calling convention");
+        err.span_label(span, "C-variadics require C or cdecl calling convention").emit();
     }
 }
 
@@ -315,7 +315,7 @@ pub fn provide(providers: &mut Providers<'_>) {
 }
 
 pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>)
-                             -> Result<(), CompileIncomplete>
+                             -> Result<(), ErrorReported>
 {
     tcx.sess.profiler(|p| p.start_activity(ProfileCategory::TypeChecking));
 
@@ -324,7 +324,6 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>)
     tcx.sess.track_errors(|| {
         time(tcx.sess, "type collecting", ||
              collect::collect_item_types(tcx));
-
     })?;
 
     if tcx.features().rustc_attrs {
@@ -362,7 +361,11 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>)
 
     tcx.sess.profiler(|p| p.end_activity(ProfileCategory::TypeChecking));
 
-    tcx.sess.compile_status()
+    if tcx.sess.err_count() == 0 {
+        Ok(())
+    } else {
+        Err(ErrorReported)
+    }
 }
 
 /// A quasi-deprecated helper used in rustdoc and save-analysis to get
@@ -383,8 +386,8 @@ pub fn hir_trait_to_predicates<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, hir_trait:
     // In case there are any projections etc, find the "environment"
     // def-id that will be used to determine the traits/predicates in
     // scope.  This is derived from the enclosing item-like thing.
-    let env_node_id = tcx.hir().get_parent(hir_trait.ref_id);
-    let env_def_id = tcx.hir().local_def_id(env_node_id);
+    let env_hir_id = tcx.hir().get_parent_item(hir_trait.hir_ref_id);
+    let env_def_id = tcx.hir().local_def_id_from_hir_id(env_hir_id);
     let item_cx = self::collect::ItemCtxt::new(tcx, env_def_id);
     let mut projections = Vec::new();
     let (principal, _) = astconv::AstConv::instantiate_poly_trait_ref_inner(
index 1d407870ee73a10d9bf3d554bbc34813c2ac858a..d8d93b462a900b4328285b0594c0304636a83114 100644 (file)
@@ -4,9 +4,8 @@
 //! We walk the set of items and, for each member, generate new constraints.
 
 use hir::def_id::DefId;
-use rustc::ty::subst::{Substs, UnpackedKind};
+use rustc::ty::subst::{UnpackedKind, SubstsRef};
 use rustc::ty::{self, Ty, TyCtxt};
-use syntax::ast;
 use rustc::hir;
 use rustc::hir::itemlikevisit::ItemLikeVisitor;
 
@@ -72,31 +71,31 @@ fn visit_item(&mut self, item: &hir::Item) {
         match item.node {
             hir::ItemKind::Struct(ref struct_def, _) |
             hir::ItemKind::Union(ref struct_def, _) => {
-                self.visit_node_helper(item.id);
+                self.visit_node_helper(item.hir_id);
 
                 if let hir::VariantData::Tuple(..) = *struct_def {
-                    self.visit_node_helper(struct_def.id());
+                    self.visit_node_helper(struct_def.hir_id());
                 }
             }
 
             hir::ItemKind::Enum(ref enum_def, _) => {
-                self.visit_node_helper(item.id);
+                self.visit_node_helper(item.hir_id);
 
                 for variant in &enum_def.variants {
                     if let hir::VariantData::Tuple(..) = variant.node.data {
-                        self.visit_node_helper(variant.node.data.id());
+                        self.visit_node_helper(variant.node.data.hir_id());
                     }
                 }
             }
 
             hir::ItemKind::Fn(..) => {
-                self.visit_node_helper(item.id);
+                self.visit_node_helper(item.hir_id);
             }
 
             hir::ItemKind::ForeignMod(ref foreign_mod) => {
                 for foreign_item in &foreign_mod.items {
                     if let hir::ForeignItemKind::Fn(..) = foreign_item.node {
-                        self.visit_node_helper(foreign_item.id);
+                        self.visit_node_helper(foreign_item.hir_id);
                     }
                 }
             }
@@ -107,21 +106,21 @@ fn visit_item(&mut self, item: &hir::Item) {
 
     fn visit_trait_item(&mut self, trait_item: &hir::TraitItem) {
         if let hir::TraitItemKind::Method(..) = trait_item.node {
-            self.visit_node_helper(trait_item.id);
+            self.visit_node_helper(trait_item.hir_id);
         }
     }
 
     fn visit_impl_item(&mut self, impl_item: &hir::ImplItem) {
         if let hir::ImplItemKind::Method(..) = impl_item.node {
-            self.visit_node_helper(impl_item.id);
+            self.visit_node_helper(impl_item.hir_id);
         }
     }
 }
 
 impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
-    fn visit_node_helper(&mut self, id: ast::NodeId) {
+    fn visit_node_helper(&mut self, id: hir::HirId) {
         let tcx = self.terms_cx.tcx;
-        let def_id = tcx.hir().local_def_id(id);
+        let def_id = tcx.hir().local_def_id_from_hir_id(id);
         self.build_constraints_for_item(def_id);
     }
 
@@ -138,7 +137,7 @@ fn build_constraints_for_item(&mut self, def_id: DefId) {
             return;
         }
 
-        let id = tcx.hir().as_local_node_id(def_id).unwrap();
+        let id = tcx.hir().as_local_hir_id(def_id).unwrap();
         let inferred_start = self.terms_cx.inferred_starts[&id];
         let current_item = &CurrentItem { inferred_start };
         match tcx.type_of(def_id).sty {
@@ -222,7 +221,7 @@ fn add_constraints_from_trait_ref(&mut self,
 
     fn add_constraints_from_invariant_substs(&mut self,
                                              current: &CurrentItem,
-                                             substs: &Substs<'tcx>,
+                                             substs: SubstsRef<'tcx>,
                                              variance: VarianceTermPtr<'a>) {
         debug!("add_constraints_from_invariant_substs: substs={:?} variance={:?}",
                substs,
@@ -344,7 +343,7 @@ fn add_constraints_from_ty(&mut self,
     fn add_constraints_from_substs(&mut self,
                                    current: &CurrentItem,
                                    def_id: DefId,
-                                   substs: &Substs<'tcx>,
+                                   substs: SubstsRef<'tcx>,
                                    variance: VarianceTermPtr<'a>) {
         debug!("add_constraints_from_substs(def_id={:?}, substs={:?}, variance={:?})",
                def_id,
@@ -356,7 +355,7 @@ fn add_constraints_from_substs(&mut self,
             return;
         }
 
-        let (local, remote) = if let Some(id) = self.tcx().hir().as_local_node_id(def_id) {
+        let (local, remote) = if let Some(id) = self.tcx().hir().as_local_hir_id(def_id) {
             (Some(self.terms_cx.inferred_starts[&id]), None)
         } else {
             (None, Some(self.tcx().variances_of(def_id)))
index f962c1313a923ee60b2d0615d781ab9d53b25481..cec33ba87dea46de47c7e912ac29657f6b274de6 100644 (file)
@@ -83,7 +83,7 @@ fn create_map(&self) -> FxHashMap<DefId, Lrc<Vec<ty::Variance>>> {
 
         let solutions = &self.solutions;
         self.terms_cx.inferred_starts.iter().map(|(&id, &InferredIndex(start))| {
-            let def_id = tcx.hir().local_def_id(id);
+            let def_id = tcx.hir().local_def_id_from_hir_id(id);
             let generics = tcx.generics_of(def_id);
 
             let mut variances = solutions[start..start+generics.count()].to_vec();
index 4e562992e8cf931ee267600ae1fe85d305bb02b5..e564a8658fcaba8a4fde306acfe1a25331b0d326 100644 (file)
 use arena::TypedArena;
 use rustc::ty::{self, TyCtxt};
 use std::fmt;
-use syntax::ast;
 use rustc::hir;
 use rustc::hir::itemlikevisit::ItemLikeVisitor;
-use crate::util::nodemap::NodeMap;
+use crate::util::nodemap::HirIdMap;
 
 use self::VarianceTerm::*;
 
@@ -55,11 +54,11 @@ pub struct TermsContext<'a, 'tcx: 'a> {
     // For marker types, UnsafeCell, and other lang items where
     // variance is hardcoded, records the item-id and the hardcoded
     // variance.
-    pub lang_items: Vec<(ast::NodeId, Vec<ty::Variance>)>,
+    pub lang_items: Vec<(hir::HirId, Vec<ty::Variance>)>,
 
     // Maps from the node id of an item to the first inferred index
     // used for its type & region parameters.
-    pub inferred_starts: NodeMap<InferredIndex>,
+    pub inferred_starts: HirIdMap<InferredIndex>,
 
     // Maps from an InferredIndex to the term for that variable.
     pub inferred_terms: Vec<VarianceTermPtr<'a>>,
@@ -86,7 +85,7 @@ pub fn determine_parameters_to_be_inferred<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>
     terms_cx
 }
 
-fn lang_items(tcx: TyCtxt<'_, '_, '_>) -> Vec<(ast::NodeId, Vec<ty::Variance>)> {
+fn lang_items(tcx: TyCtxt<'_, '_, '_>) -> Vec<(hir::HirId, Vec<ty::Variance>)> {
     let lang_items = tcx.lang_items();
     let all = vec![
         (lang_items.phantom_data(), vec![ty::Covariant]),
@@ -96,14 +95,14 @@ fn lang_items(tcx: TyCtxt<'_, '_, '_>) -> Vec<(ast::NodeId, Vec<ty::Variance>)>
     all.into_iter() // iterating over (Option<DefId>, Variance)
        .filter(|&(ref d,_)| d.is_some())
        .map(|(d, v)| (d.unwrap(), v)) // (DefId, Variance)
-       .filter_map(|(d, v)| tcx.hir().as_local_node_id(d).map(|n| (n, v))) // (NodeId, Variance)
+       .filter_map(|(d, v)| tcx.hir().as_local_hir_id(d).map(|n| (n, v))) // (HirId, Variance)
        .collect()
 }
 
 impl<'a, 'tcx> TermsContext<'a, 'tcx> {
-    fn add_inferreds_for_item(&mut self, id: ast::NodeId) {
+    fn add_inferreds_for_item(&mut self, id: hir::HirId) {
         let tcx = self.tcx;
-        let def_id = tcx.hir().local_def_id(id);
+        let def_id = tcx.hir().local_def_id_from_hir_id(id);
         let count = tcx.generics_of(def_id).count();
 
         if count == 0 {
@@ -134,31 +133,31 @@ fn visit_item(&mut self, item: &hir::Item) {
         match item.node {
             hir::ItemKind::Struct(ref struct_def, _) |
             hir::ItemKind::Union(ref struct_def, _) => {
-                self.add_inferreds_for_item(item.id);
+                self.add_inferreds_for_item(item.hir_id);
 
                 if let hir::VariantData::Tuple(..) = *struct_def {
-                    self.add_inferreds_for_item(struct_def.id());
+                    self.add_inferreds_for_item(struct_def.hir_id());
                 }
             }
 
             hir::ItemKind::Enum(ref enum_def, _) => {
-                self.add_inferreds_for_item(item.id);
+                self.add_inferreds_for_item(item.hir_id);
 
                 for variant in &enum_def.variants {
                     if let hir::VariantData::Tuple(..) = variant.node.data {
-                        self.add_inferreds_for_item(variant.node.data.id());
+                        self.add_inferreds_for_item(variant.node.data.hir_id());
                     }
                 }
             }
 
             hir::ItemKind::Fn(..) => {
-                self.add_inferreds_for_item(item.id);
+                self.add_inferreds_for_item(item.hir_id);
             }
 
             hir::ItemKind::ForeignMod(ref foreign_mod) => {
                 for foreign_item in &foreign_mod.items {
                     if let hir::ForeignItemKind::Fn(..) = foreign_item.node {
-                        self.add_inferreds_for_item(foreign_item.id);
+                        self.add_inferreds_for_item(foreign_item.hir_id);
                     }
                 }
             }
@@ -169,13 +168,13 @@ fn visit_item(&mut self, item: &hir::Item) {
 
     fn visit_trait_item(&mut self, trait_item: &hir::TraitItem) {
         if let hir::TraitItemKind::Method(..) = trait_item.node {
-            self.add_inferreds_for_item(trait_item.id);
+            self.add_inferreds_for_item(trait_item.hir_id);
         }
     }
 
     fn visit_impl_item(&mut self, impl_item: &hir::ImplItem) {
         if let hir::ImplItemKind::Method(..) = impl_item.node {
-            self.add_inferreds_for_item(impl_item.id);
+            self.add_inferreds_for_item(impl_item.hir_id);
         }
     }
 }
index 952541bb85f9bc26057626c36a403e7420dbf0cb..d07a4579ad5c3b20b73402846a7578e084a60133 100644 (file)
@@ -115,7 +115,6 @@ fn get_auto_trait_impl_for<F>(
         if result.is_auto() {
             let trait_ = hir::TraitRef {
                 path: get_path_for_type(self.cx.tcx, trait_def_id, hir::def::Def::Trait),
-                ref_id: ast::DUMMY_NODE_ID,
                 hir_ref_id: hir::DUMMY_HIR_ID,
             };
 
index 55abcb4a93bd3e4b44af89c603c4bc2cc64da999..5a13490eeccf23b8e4a52348d6df065393ee5645 100644 (file)
@@ -123,7 +123,6 @@ pub fn get_blanket_impls<F>(
                             path: get_path_for_type(infcx.tcx,
                                                     trait_def_id,
                                                     hir::def::Def::Trait),
-                            ref_id: ast::DUMMY_NODE_ID,
                             hir_ref_id: hir::DUMMY_HIR_ID,
                         };
                         let provided_trait_methods =
index 2c2959aec9fcf7d97e95833fa51133970e1d7e27..d88d0dab4f0ebb5bfd2950eba7e1621ce1fb9a70 100644 (file)
@@ -20,7 +20,7 @@
 use rustc::hir::{self, GenericArg, HirVec};
 use rustc::hir::def::{self, Def, CtorKind};
 use rustc::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE};
-use rustc::ty::subst::Substs;
+use rustc::ty::subst::{InternalSubsts, SubstsRef};
 use rustc::ty::{self, TyCtxt, Region, RegionVid, Ty, AdtKind};
 use rustc::ty::fold::TypeFolder;
 use rustc::ty::layout::VariantIdx;
@@ -1089,7 +1089,7 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> GenericBound {
 }
 
 fn external_generic_args(cx: &DocContext<'_, '_, '_>, trait_did: Option<DefId>, has_self: bool,
-                        bindings: Vec<TypeBinding>, substs: &Substs<'_>) -> GenericArgs {
+                        bindings: Vec<TypeBinding>, substs: SubstsRef<'_>) -> GenericArgs {
     let lifetimes = substs.regions().filter_map(|v| v.clean(cx)).collect();
     let types = substs.types().skip(has_self as usize).collect::<Vec<_>>();
 
@@ -1131,7 +1131,7 @@ fn external_generic_args(cx: &DocContext<'_, '_, '_>, trait_did: Option<DefId>,
 // trait_did should be set to a trait's DefId if called on a TraitRef, in order to sugar
 // from Fn<(A, B,), C> to Fn(A, B) -> C
 fn external_path(cx: &DocContext<'_, '_, '_>, name: &str, trait_did: Option<DefId>, has_self: bool,
-                 bindings: Vec<TypeBinding>, substs: &Substs<'_>) -> Path {
+                 bindings: Vec<TypeBinding>, substs: SubstsRef<'_>) -> Path {
     Path {
         global: false,
         def: Def::Err,
@@ -1192,7 +1192,7 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> GenericBound {
     }
 }
 
-impl<'tcx> Clean<Option<Vec<GenericBound>>> for Substs<'tcx> {
+impl<'tcx> Clean<Option<Vec<GenericBound>>> for InternalSubsts<'tcx> {
     fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Option<Vec<GenericBound>> {
         let mut v = Vec::new();
         v.extend(self.regions().filter_map(|r| r.clean(cx)).map(GenericBound::Outlives));
@@ -1752,7 +1752,6 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
 pub struct FnDecl {
     pub inputs: Arguments,
     pub output: FunctionRetTy,
-    pub variadic: bool,
     pub attrs: Attributes,
 }
 
@@ -1831,7 +1830,6 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> FnDecl {
         FnDecl {
             inputs: (&self.0.inputs[..], self.1).clean(cx),
             output: self.0.output.clean(cx),
-            variadic: self.0.variadic,
             attrs: Attributes::default()
         }
     }
@@ -1849,7 +1847,6 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> FnDecl {
         FnDecl {
             output: Return(sig.skip_binder().output().clean(cx)),
             attrs: Attributes::default(),
-            variadic: sig.skip_binder().variadic,
             inputs: Arguments {
                 values: sig.skip_binder().inputs().iter().map(|t| {
                     Argument {
@@ -2025,14 +2022,15 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
                 AssociatedTypeItem(bounds.clean(cx), default.clean(cx))
             }
         };
+        let local_did = cx.tcx.hir().local_def_id_from_hir_id(self.hir_id);
         Item {
             name: Some(self.ident.name.clean(cx)),
             attrs: self.attrs.clean(cx),
             source: self.span.clean(cx),
-            def_id: cx.tcx.hir().local_def_id(self.id),
+            def_id: local_did,
             visibility: None,
-            stability: get_stability(cx, cx.tcx.hir().local_def_id(self.id)),
-            deprecation: get_deprecation(cx, cx.tcx.hir().local_def_id(self.id)),
+            stability: get_stability(cx, local_did),
+            deprecation: get_deprecation(cx, local_did),
             inner,
         }
     }
@@ -2057,14 +2055,15 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Item {
                 generics: Generics::default(),
             }, true),
         };
+        let local_did = cx.tcx.hir().local_def_id_from_hir_id(self.hir_id);
         Item {
             name: Some(self.ident.name.clean(cx)),
             source: self.span.clean(cx),
             attrs: self.attrs.clean(cx),
-            def_id: cx.tcx.hir().local_def_id(self.id),
+            def_id: local_did,
             visibility: self.vis.clean(cx),
-            stability: get_stability(cx, cx.tcx.hir().local_def_id(self.id)),
-            deprecation: get_deprecation(cx, cx.tcx.hir().local_def_id(self.id)),
+            stability: get_stability(cx, local_did),
+            deprecation: get_deprecation(cx, local_did),
             inner,
         }
     }
@@ -2252,6 +2251,7 @@ pub enum Type {
     Slice(Box<Type>),
     Array(Box<Type>, String),
     Never,
+    CVarArgs,
     Unique(Box<Type>),
     RawPointer(Mutability, Box<Type>),
     BorrowedRef {
@@ -2290,6 +2290,7 @@ pub enum PrimitiveType {
     Reference,
     Fn,
     Never,
+    CVarArgs,
 }
 
 #[derive(Clone, RustcEncodable, RustcDecodable, Copy, Debug)]
@@ -2469,6 +2470,7 @@ pub fn as_str(&self) -> &'static str {
             Reference => "reference",
             Fn => "fn",
             Never => "never",
+            CVarArgs => "...",
         }
     }
 
@@ -2518,6 +2520,7 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Type {
 
         match self.node {
             TyKind::Never => Never,
+            TyKind::CVarArgs(_) => CVarArgs,
             TyKind::Ptr(ref m) => RawPointer(m.mutbl.clean(cx), box m.ty.clean(cx)),
             TyKind::Rptr(ref l, ref m) => {
                 let lifetime = if l.is_elided() {
@@ -2530,9 +2533,9 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Type {
             }
             TyKind::Slice(ref ty) => Slice(box ty.clean(cx)),
             TyKind::Array(ref ty, ref length) => {
-                let def_id = cx.tcx.hir().local_def_id(length.id);
+                let def_id = cx.tcx.hir().local_def_id_from_hir_id(length.hir_id);
                 let param_env = cx.tcx.param_env(def_id);
-                let substs = Substs::identity_for_item(cx.tcx, def_id);
+                let substs = InternalSubsts::identity_for_item(cx.tcx, def_id);
                 let cid = GlobalId {
                     instance: ty::Instance::new(def_id, substs),
                     promoted: None
@@ -2776,7 +2779,7 @@ fn clean(&self, cx: &DocContext<'_, '_, '_>) -> Type {
             ty::Foreign(did) => {
                 inline::record_extern_fqn(cx, did, TypeKind::Foreign);
                 let path = external_path(cx, &cx.tcx.item_name(did).as_str(),
-                                         None, false, vec![], Substs::empty());
+                                         None, false, vec![], InternalSubsts::empty());
                 ResolvedPath {
                     path: path,
                     typarams: None,
@@ -3654,6 +3657,7 @@ fn build_deref_target_impls(cx: &DocContext<'_, '_, '_>,
             Reference => None,
             Fn => None,
             Never => None,
+            CVarArgs => tcx.lang_items().va_list(),
         };
         if let Some(did) = did {
             if !did.is_local() {
index e5caf7fdfa23591d9ba088ea9892ebfca96ce5e8..b1c53ea92b300b6c1ee7af855b38fde739dd0bad 100644 (file)
@@ -214,7 +214,7 @@ pub fn from_matches(matches: &getopts::Matches) -> Result<Options, isize> {
         if matches.opt_strs("passes") == ["list"] {
             println!("Available passes for running rustdoc:");
             for pass in passes::PASSES {
-                println!("{:>20} - {}", pass.name(), pass.description());
+                println!("{:>20} - {}", pass.name, pass.description);
             }
             println!("\nDefault passes for rustdoc:");
             for &name in passes::DEFAULT_PASSES {
index 226924c41c54137745f594fb9a55bcc114aac167..fdb071638b7993245b7dc66bb6a9097fac1d7a13 100644 (file)
@@ -1,5 +1,5 @@
 use rustc_lint;
-use rustc_driver::{self, driver, target_features, abort_on_err};
+use rustc_driver::{driver, abort_on_err};
 use rustc::session::{self, config};
 use rustc::hir::def_id::{DefId, DefIndex, DefIndexAddressSpace, CrateNum, LOCAL_CRATE};
 use rustc::hir::def::Def;
@@ -11,6 +11,7 @@
 use rustc::lint::{self, LintPass};
 use rustc::session::config::ErrorOutputType;
 use rustc::util::nodemap::{FxHashMap, FxHashSet};
+use rustc_interface::util;
 use rustc_resolve as resolve;
 use rustc_metadata::creader::CrateLoader;
 use rustc_metadata::cstore::CStore;
@@ -402,7 +403,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
                                              debugging_options.ui_testing);
 
         let mut sess = session::build_session_(
-            sessopts, cpath, diagnostic_handler, source_map,
+            sessopts, cpath, diagnostic_handler, source_map, Default::default(),
         );
 
         lint::builtin::HardwiredLints.get_lints()
@@ -422,12 +423,12 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
                                                                       lint::Allow);
                                      });
 
-        let codegen_backend = rustc_driver::get_codegen_backend(&sess);
+        let codegen_backend = util::get_codegen_backend(&sess);
         let cstore = Rc::new(CStore::new(codegen_backend.metadata_loader()));
         rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
 
         let mut cfg = config::build_configuration(&sess, config::parse_cfgspecs(cfgs));
-        target_features::add_configuration(&mut cfg, &sess, &*codegen_backend);
+        util::add_configuration(&mut cfg, &sess, &*codegen_backend);
         sess.parse_sess.config = cfg;
 
         let control = &driver::CompileController::basic();
@@ -481,23 +482,23 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
 
         let mut arenas = AllArenas::new();
         let hir_map = hir_map::map_crate(&sess, &*cstore, &mut hir_forest, &defs);
-        let output_filenames = driver::build_output_filenames(&input,
+        let output_filenames = util::build_output_filenames(&input,
                                                             &None,
                                                             &None,
                                                             &[],
                                                             &sess);
 
         let resolver = RefCell::new(resolver);
-        abort_on_err(driver::phase_3_run_analysis_passes(&*codegen_backend,
-                                                        control,
-                                                        &sess,
-                                                        &*cstore,
-                                                        hir_map,
-                                                        resolutions,
-                                                        &mut arenas,
-                                                        &name,
-                                                        &output_filenames,
-                                                        |tcx, _, result| {
+        driver::phase_3_run_analysis_passes(&*codegen_backend,
+                                            control,
+                                            &sess,
+                                            &*cstore,
+                                            hir_map,
+                                            resolutions,
+                                            &mut arenas,
+                                            &name,
+                                            &output_filenames,
+                                            |tcx, _, result| {
             if result.is_err() {
                 sess.fatal("Compilation failed, aborting rustdoc");
             }
@@ -603,16 +604,18 @@ fn report_deprecated_attr(name: &str, diag: &errors::Handler) {
                 passes::defaults(default_passes).iter().map(|p| p.to_string()).collect();
             passes.extend(manual_passes);
 
+            info!("Executing passes");
+
             for pass in &passes {
-                // the "unknown pass" error will be reported when late passes are run
-                if let Some(pass) = passes::find_pass(pass).and_then(|p| p.early_fn()) {
-                    krate = pass(krate, &ctxt);
+                match passes::find_pass(pass).map(|p| p.pass) {
+                    Some(pass) => krate = pass(krate, &ctxt),
+                    None => error!("unknown pass {}, skipping", *pass),
                 }
             }
 
             ctxt.sess().abort_if_errors();
 
             (krate, ctxt.renderinfo.into_inner(), render_options, passes)
-        }), &sess)
+        })
     })
 }
index 4463dad1c8a1f8de1e264ebad0909b3474e86084..d204a179ca62cb68098cbe9b2dd5ac5b6bf13da7 100644 (file)
@@ -609,6 +609,7 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter<'_>, use_absolute: bool) ->
             primitive_link(f, PrimitiveType::Array, &format!("; {}]", n))
         }
         clean::Never => primitive_link(f, PrimitiveType::Never, "!"),
+        clean::CVarArgs => primitive_link(f, PrimitiveType::CVarArgs, "..."),
         clean::RawPointer(m, ref t) => {
             match **t {
                 clean::Generic(_) | clean::ResolvedPath {is_generic: true, ..} => {
@@ -834,18 +835,10 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
 
 impl fmt::Display for clean::FnDecl {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        if self.variadic {
-            if f.alternate() {
-                write!(f, "({args:#}, ...){arrow:#}", args = self.inputs, arrow = self.output)
-            } else {
-                write!(f, "({args}, ...){arrow}", args = self.inputs, arrow = self.output)
-            }
+        if f.alternate() {
+            write!(f, "({args:#}){arrow:#}", args = self.inputs, arrow = self.output)
         } else {
-            if f.alternate() {
-                write!(f, "({args:#}){arrow:#}", args = self.inputs, arrow = self.output)
-            } else {
-                write!(f, "({args}){arrow}", args = self.inputs, arrow = self.output)
-            }
+            write!(f, "({args}){arrow}", args = self.inputs, arrow = self.output)
         }
     }
 }
@@ -907,12 +900,7 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
             }
         }
 
-        let mut args_plain = format!("({})", args_plain);
-
-        if decl.variadic {
-            args.push_str(",<br> ...");
-            args_plain.push_str(", ...");
-        }
+        let args_plain = format!("({})", args_plain);
 
         let output = if let hir::IsAsync::Async = asyncness {
             Cow::Owned(decl.sugared_async_return_type())
index 5e9f9ee9f80af7e2dd81ffbf1a68fe22b333c7ef..b3807d750b6eae2416cb50ca916d6686c4435ca5 100644 (file)
@@ -30,6 +30,7 @@
 extern crate rustc_metadata;
 extern crate rustc_target;
 extern crate rustc_typeck;
+extern crate rustc_interface;
 extern crate serialize;
 extern crate syntax;
 extern crate syntax_pos;
@@ -441,28 +442,6 @@ fn rust_input<R, F>(options: config::Options, f: F) -> R
 
         krate.version = crate_version;
 
-        info!("Executing passes");
-
-        for pass in &passes {
-            // determine if we know about this pass
-            let pass = match passes::find_pass(pass) {
-                Some(pass) => if let Some(pass) = pass.late_fn() {
-                    pass
-                } else {
-                    // not a late pass, but still valid so don't report the error
-                    continue
-                }
-                None => {
-                    error!("unknown pass {}, skipping", *pass);
-
-                    continue
-                },
-            };
-
-            // run it
-            krate = pass(krate);
-        }
-
         tx.send(f(Output {
             krate: krate,
             renderinfo: renderinfo,
index f960374370e043ef193d7706d4ad102f32d00a7c..88d9c87c5289892df082e82b9789430427eeec11 100644 (file)
 use crate::html::markdown::{self, RustCodeBlock};
 use crate::passes::Pass;
 
-pub const CHECK_CODE_BLOCK_SYNTAX: Pass =
-    Pass::early("check-code-block-syntax", check_code_block_syntax,
-                "validates syntax inside Rust code blocks");
+pub const CHECK_CODE_BLOCK_SYNTAX: Pass = Pass {
+    name: "check-code-block-syntax",
+    pass: check_code_block_syntax,
+    description: "validates syntax inside Rust code blocks",
+};
 
 pub fn check_code_block_syntax(krate: clean::Crate, cx: &DocContext<'_, '_, '_>) -> clean::Crate {
     SyntaxChecker { cx }.fold_crate(krate)
index e5e60cbe717001e1f446673e515a9ca7955aa10b..088a6ea77c73ff53b64c7023ee29513b92cd5cfd 100644 (file)
@@ -1,13 +1,16 @@
 use crate::clean::{self, DocFragment, Item};
+use crate::core::DocContext;
 use crate::fold;
 use crate::fold::{DocFolder};
 use crate::passes::Pass;
 
 use std::mem::replace;
 
-pub const COLLAPSE_DOCS: Pass =
-    Pass::late("collapse-docs", collapse_docs,
-        "concatenates all document attributes into one document attribute");
+pub const COLLAPSE_DOCS: Pass = Pass {
+    name: "collapse-docs",
+    pass: collapse_docs,
+    description: "concatenates all document attributes into one document attribute",
+};
 
 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
 enum DocFragmentKind {
@@ -26,7 +29,7 @@ fn kind(&self) -> DocFragmentKind {
     }
 }
 
-pub fn collapse_docs(krate: clean::Crate) -> clean::Crate {
+pub fn collapse_docs(krate: clean::Crate, _: &DocContext<'_, '_, '_>) -> clean::Crate {
     Collapser.fold_crate(krate)
 }
 
index 42fa3e2006b42320e3fcb19163ba30d7cc36ec09..25c86b24c187b6eba04fd4989a727c694fc1a430 100644 (file)
 
 use super::span_of_attrs;
 
-pub const COLLECT_INTRA_DOC_LINKS: Pass =
-    Pass::early("collect-intra-doc-links", collect_intra_doc_links,
-                "reads a crate's documentation to resolve intra-doc-links");
+pub const COLLECT_INTRA_DOC_LINKS: Pass = Pass {
+    name: "collect-intra-doc-links",
+    pass: collect_intra_doc_links,
+    description: "reads a crate's documentation to resolve intra-doc-links",
+};
 
 pub fn collect_intra_doc_links(krate: Crate, cx: &DocContext<'_, '_, '_>) -> Crate {
     if !UnstableFeatures::from_environment().is_nightly_build() {
@@ -471,9 +473,9 @@ fn resolution_failure(
 ) {
     let sp = span_of_attrs(attrs);
 
-    let mut diag = cx.tcx.struct_span_lint_node(
+    let mut diag = cx.tcx.struct_span_lint_hir(
         lint::builtin::INTRA_DOC_LINK_RESOLUTION_FAILURE,
-        NodeId::from_u32(0),
+        hir::CRATE_HIR_ID,
         sp,
         &format!("`[{}]` cannot be resolved, ignoring it...", path_str),
     );
index 903cce3bc032a3a6e6065a8176efe2e503310033..4c90540871d2eb3dabcbe2aa692ff53b81822def 100644 (file)
@@ -6,9 +6,11 @@
 use rustc::util::nodemap::FxHashSet;
 use rustc::hir::def_id::DefId;
 
-pub const COLLECT_TRAIT_IMPLS: Pass =
-    Pass::early("collect-trait-impls", collect_trait_impls,
-                "retrieves trait impls for items in the crate");
+pub const COLLECT_TRAIT_IMPLS: Pass = Pass {
+    name: "collect-trait-impls",
+    pass: collect_trait_impls,
+    description: "retrieves trait impls for items in the crate",
+};
 
 pub fn collect_trait_impls(krate: Crate, cx: &DocContext<'_, '_, '_>) -> Crate {
     let mut synth = SyntheticImplCollector::new(cx);
index 4d7fef7a76a9fe936dadc75ebb248692ed6af387..d6f3585a04f336728fc8fa29d11492b34efd2e4d 100644 (file)
@@ -1,13 +1,12 @@
 //! Contains information about "passes", used to modify crate information during the documentation
 //! process.
 
+use rustc::hir;
 use rustc::hir::def_id::DefId;
 use rustc::lint as lint;
 use rustc::middle::privacy::AccessLevels;
 use rustc::util::nodemap::DefIdSet;
 use std::mem;
-use std::fmt;
-use syntax::ast::NodeId;
 use syntax_pos::{DUMMY_SP, Span};
 use std::ops::Range;
 
 mod check_code_block_syntax;
 pub use self::check_code_block_syntax::CHECK_CODE_BLOCK_SYNTAX;
 
-/// Represents a single pass.
+/// A single pass over the cleaned documentation.
+///
+/// Runs in the compiler context, so it has access to types and traits and the like.
 #[derive(Copy, Clone)]
-pub enum Pass {
-    /// An "early pass" is run in the compiler context, and can gather information about types and
-    /// traits and the like.
-    EarlyPass {
-        name: &'static str,
-        pass: fn(clean::Crate, &DocContext<'_, '_, '_>) -> clean::Crate,
-        description: &'static str,
-    },
-    /// A "late pass" is run between crate cleaning and page generation.
-    LatePass {
-        name: &'static str,
-        pass: fn(clean::Crate) -> clean::Crate,
-        description: &'static str,
-    },
-}
-
-impl fmt::Debug for Pass {
-    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-        let mut dbg = match *self {
-            Pass::EarlyPass { .. } => f.debug_struct("EarlyPass"),
-            Pass::LatePass { .. } => f.debug_struct("LatePass"),
-        };
-
-        dbg.field("name", &self.name())
-           .field("pass", &"...")
-           .field("description", &self.description())
-           .finish()
-    }
-}
-
-impl Pass {
-    /// Constructs a new early pass.
-    pub const fn early(name: &'static str,
-                       pass: fn(clean::Crate, &DocContext<'_, '_, '_>) -> clean::Crate,
-                       description: &'static str) -> Pass {
-        Pass::EarlyPass { name, pass, description }
-    }
-
-    /// Constructs a new late pass.
-    pub const fn late(name: &'static str,
-                      pass: fn(clean::Crate) -> clean::Crate,
-                      description: &'static str) -> Pass {
-        Pass::LatePass { name, pass, description }
-    }
-
-    /// Returns the name of this pass.
-    pub fn name(self) -> &'static str {
-        match self {
-            Pass::EarlyPass { name, .. } |
-                Pass::LatePass { name, .. } => name,
-        }
-    }
-
-    /// Returns the description of this pass.
-    pub fn description(self) -> &'static str {
-        match self {
-            Pass::EarlyPass { description, .. } |
-                Pass::LatePass { description, .. } => description,
-        }
-    }
-
-    /// If this pass is an early pass, returns the pointer to its function.
-    pub fn early_fn(self) -> Option<fn(clean::Crate, &DocContext<'_, '_, '_>) -> clean::Crate> {
-        match self {
-            Pass::EarlyPass { pass, .. } => Some(pass),
-            _ => None,
-        }
-    }
-
-    /// If this pass is a late pass, returns the pointer to its function.
-    pub fn late_fn(self) -> Option<fn(clean::Crate) -> clean::Crate> {
-        match self {
-            Pass::LatePass { pass, .. } => Some(pass),
-            _ => None,
-        }
-    }
+pub struct Pass {
+    pub name: &'static str,
+    pub pass: fn(clean::Crate, &DocContext<'_, '_, '_>) -> clean::Crate,
+    pub description: &'static str,
 }
 
 /// The full list of passes.
@@ -141,27 +70,27 @@ pub fn late_fn(self) -> Option<fn(clean::Crate) -> clean::Crate> {
 ];
 
 /// The list of passes run by default.
-pub const DEFAULT_PASSES: &'static [&'static str] = &[
+pub const DEFAULT_PASSES: &[&str] = &[
     "collect-trait-impls",
+    "collapse-docs",
+    "unindent-comments",
     "check-private-items-doc-tests",
     "strip-hidden",
     "strip-private",
     "collect-intra-doc-links",
     "check-code-block-syntax",
-    "collapse-docs",
-    "unindent-comments",
     "propagate-doc-cfg",
 ];
 
 /// The list of default passes run with `--document-private-items` is passed to rustdoc.
-pub const DEFAULT_PRIVATE_PASSES: &'static [&'static str] = &[
+pub const DEFAULT_PRIVATE_PASSES: &[&str] = &[
     "collect-trait-impls",
+    "collapse-docs",
+    "unindent-comments",
     "check-private-items-doc-tests",
     "strip-priv-imports",
     "collect-intra-doc-links",
     "check-code-block-syntax",
-    "collapse-docs",
-    "unindent-comments",
     "propagate-doc-cfg",
 ];
 
@@ -184,8 +113,8 @@ pub fn defaults(default_set: DefaultPassOption) -> &'static [&'static str] {
 }
 
 /// If the given name matches a known pass, returns its information.
-pub fn find_pass(pass_name: &str) -> Option<Pass> {
-    PASSES.iter().find(|p| p.name() == pass_name).cloned()
+pub fn find_pass(pass_name: &str) -> Option<&'static Pass> {
+    PASSES.iter().find(|p| p.name == pass_name)
 }
 
 struct Stripper<'a> {
@@ -383,18 +312,18 @@ fn add_test(&mut self, _: String, _: LangString, _: usize) {
 
     if find_testable_code(&dox, &mut tests, ErrorCodes::No).is_ok() {
         if check_missing_code == true && tests.found_tests == 0 {
-            let mut diag = cx.tcx.struct_span_lint_node(
+            let mut diag = cx.tcx.struct_span_lint_hir(
                 lint::builtin::MISSING_DOC_CODE_EXAMPLES,
-                NodeId::from_u32(0),
+                hir::CRATE_HIR_ID,
                 span_of_attrs(&item.attrs),
                 "Missing code example in this documentation");
             diag.emit();
         } else if check_missing_code == false &&
                   tests.found_tests > 0 &&
                   !cx.renderinfo.borrow().access_levels.is_doc_reachable(item.def_id) {
-            let mut diag = cx.tcx.struct_span_lint_node(
+            let mut diag = cx.tcx.struct_span_lint_hir(
                 lint::builtin::PRIVATE_DOC_TESTS,
-                NodeId::from_u32(0),
+                hir::CRATE_HIR_ID,
                 span_of_attrs(&item.attrs),
                 "Documentation test in private item");
             diag.emit();
@@ -438,11 +367,11 @@ fn add_test(&mut self, _: String, _: LangString, _: usize) {
         .span_to_snippet(span_of_attrs(attrs))
         .ok()?;
 
-    let starting_line = markdown[..md_range.start].lines().count() - 1;
-    let ending_line = markdown[..md_range.end].lines().count() - 1;
+    let starting_line = markdown[..md_range.start].matches('\n').count();
+    let ending_line = starting_line + markdown[md_range.start..md_range.end].matches('\n').count();
 
-    // We use `split_terminator('\n')` instead of `lines()` when counting bytes so that we only
-    // we can treat CRLF and LF line endings the same way.
+    // We use `split_terminator('\n')` instead of `lines()` when counting bytes so that we treat
+    // CRLF and LF line endings the same way.
     let mut src_lines = snippet.split_terminator('\n');
     let md_lines = markdown.split_terminator('\n');
 
index 819d15f65e8ef33678d14946e7371ce57270c22b..1c3977c4f85cddd36eabf65220353c2ad4ee198c 100644 (file)
@@ -3,10 +3,11 @@
 use crate::fold::DocFolder;
 use crate::passes::{look_for_tests, Pass};
 
-
-pub const CHECK_PRIVATE_ITEMS_DOC_TESTS: Pass =
-    Pass::early("check-private-items-doc-tests", check_private_items_doc_tests,
-                "check private items doc tests");
+pub const CHECK_PRIVATE_ITEMS_DOC_TESTS: Pass = Pass {
+    name: "check-private-items-doc-tests",
+    pass: check_private_items_doc_tests,
+    description: "check private items doc tests",
+};
 
 struct PrivateItemDocTestLinter<'a, 'tcx: 'a, 'rcx: 'a> {
     cx: &'a DocContext<'a, 'tcx, 'rcx>,
index 9ba0b2272869125acde15fbc77223ccf5067dedd..aed80b5ba86fd7c270a95039d3882164a08666c9 100644 (file)
@@ -2,14 +2,17 @@
 
 use crate::clean::{Crate, Item};
 use crate::clean::cfg::Cfg;
+use crate::core::DocContext;
 use crate::fold::DocFolder;
 use crate::passes::Pass;
 
-pub const PROPAGATE_DOC_CFG: Pass =
-    Pass::late("propagate-doc-cfg", propagate_doc_cfg,
-        "propagates `#[doc(cfg(...))]` to child items");
+pub const PROPAGATE_DOC_CFG: Pass = Pass {
+    name: "propagate-doc-cfg",
+    pass: propagate_doc_cfg,
+    description: "propagates `#[doc(cfg(...))]` to child items",
+};
 
-pub fn propagate_doc_cfg(cr: Crate) -> Crate {
+pub fn propagate_doc_cfg(cr: Crate, _: &DocContext<'_, '_, '_>) -> Crate {
     CfgPropagator { parent_cfg: None }.fold_crate(cr)
 }
 
index b3d50e06816c5cc8d07b4d6fabeaefaed081a3d1..330057e53843b517c2c4a61995746a6cc550934a 100644 (file)
@@ -7,9 +7,11 @@
 use crate::fold::{DocFolder, StripItem};
 use crate::passes::{ImplStripper, Pass};
 
-pub const STRIP_HIDDEN: Pass =
-    Pass::early("strip-hidden", strip_hidden,
-                "strips all doc(hidden) items from the output");
+pub const STRIP_HIDDEN: Pass = Pass {
+    name: "strip-hidden",
+    pass: strip_hidden,
+    description: "strips all doc(hidden) items from the output",
+};
 
 /// Strip items marked `#[doc(hidden)]`
 pub fn strip_hidden(krate: clean::Crate, _: &DocContext<'_, '_, '_>) -> clean::Crate {
index 3af1403e8749cc251248a76091392534d17afefe..479f0877bd7d2c4e80418e6350bde545358c39f7 100644 (file)
@@ -3,8 +3,11 @@
 use crate::core::DocContext;
 use crate::passes::{ImportStripper, Pass};
 
-pub const STRIP_PRIV_IMPORTS: Pass = Pass::early("strip-priv-imports", strip_priv_imports,
-     "strips all private import statements (`use`, `extern crate`) from a crate");
+pub const STRIP_PRIV_IMPORTS: Pass = Pass {
+    name: "strip-priv-imports",
+    pass: strip_priv_imports,
+    description: "strips all private import statements (`use`, `extern crate`) from a crate",
+};
 
 pub fn strip_priv_imports(krate: clean::Crate, _: &DocContext<'_, '_, '_>)  -> clean::Crate {
     ImportStripper.fold_crate(krate)
index e553d792eb697329fe683bff733468cc988368d6..1ac3a90f38d35cb191f37290498a4946ee4eaee3 100644 (file)
@@ -5,10 +5,12 @@
 use crate::core::DocContext;
 use crate::passes::{ImplStripper, ImportStripper, Stripper, Pass};
 
-pub const STRIP_PRIVATE: Pass =
-    Pass::early("strip-private", strip_private,
-        "strips all private items from a crate which cannot be seen externally, \
-         implies strip-priv-imports");
+pub const STRIP_PRIVATE: Pass = Pass {
+    name: "strip-private",
+    pass: strip_private,
+    description: "strips all private items from a crate which cannot be seen externally, \
+        implies strip-priv-imports",
+};
 
 /// Strip private items from the point of view of a crate or externally from a
 /// crate, specified by the `xcrate` flag.
index 269e4cbe65f8bbb98a8307a9fd8cb3d1907e7d15..b77cf68d7c63fab3a8955b3ff5749b1156f06913 100644 (file)
@@ -3,14 +3,17 @@
 use std::usize;
 
 use crate::clean::{self, DocFragment, Item};
+use crate::core::DocContext;
 use crate::fold::{self, DocFolder};
 use crate::passes::Pass;
 
-pub const UNINDENT_COMMENTS: Pass =
-    Pass::late("unindent-comments", unindent_comments,
-        "removes excess indentation on comments in order for markdown to like it");
+pub const UNINDENT_COMMENTS: Pass = Pass {
+    name: "unindent-comments",
+    pass: unindent_comments,
+    description: "removes excess indentation on comments in order for markdown to like it",
+};
 
-pub fn unindent_comments(krate: clean::Crate) -> clean::Crate {
+pub fn unindent_comments(krate: clean::Crate, _: &DocContext<'_, '_, '_>) -> clean::Crate {
     CommentCleaner.fold_crate(krate)
 }
 
index 8dad26f9292cd36b610064f4f05aac0591cc4f4f..c3c0875bc7d248cbcfa5cde7f9f03ecfa3f39029 100644 (file)
@@ -2,9 +2,10 @@
 use errors::emitter::ColorConfig;
 use rustc_data_structures::sync::Lrc;
 use rustc_lint;
-use rustc_driver::{self, driver, target_features, Compilation};
+use rustc_driver::{self, driver, Compilation};
 use rustc_driver::driver::phase_2_configure_and_expand;
 use rustc_metadata::cstore::CStore;
+use rustc_interface::util;
 use rustc::hir;
 use rustc::hir::intravisit;
 use rustc::session::{self, CompileIncomplete, config};
@@ -70,15 +71,15 @@ pub fn run(mut options: Options) -> isize {
                                             Some(source_map.clone()));
 
         let mut sess = session::build_session_(
-            sessopts, Some(options.input), handler, source_map.clone(),
+            sessopts, Some(options.input), handler, source_map.clone(), Default::default(),
         );
-        let codegen_backend = rustc_driver::get_codegen_backend(&sess);
+        let codegen_backend = util::get_codegen_backend(&sess);
         let cstore = CStore::new(codegen_backend.metadata_loader());
         rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
 
         let mut cfg = config::build_configuration(&sess,
                                                   config::parse_cfgspecs(options.cfgs.clone()));
-        target_features::add_configuration(&mut cfg, &sess, &*codegen_backend);
+        util::add_configuration(&mut cfg, &sess, &*codegen_backend);
         sess.parse_sess.config = cfg;
 
         let krate =
@@ -274,9 +275,9 @@ fn path(&self) -> &std::path::Path {
         let diagnostic_handler = errors::Handler::with_emitter(true, false, box emitter);
 
         let mut sess = session::build_session_(
-            sessopts, None, diagnostic_handler, source_map,
+            sessopts, None, diagnostic_handler, source_map, Default::default(),
         );
-        let codegen_backend = rustc_driver::get_codegen_backend(&sess);
+        let codegen_backend = util::get_codegen_backend(&sess);
         let cstore = CStore::new(codegen_backend.metadata_loader());
         rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
 
@@ -305,7 +306,7 @@ fn path(&self) -> &std::path::Path {
         let mut control = driver::CompileController::basic();
 
         let mut cfg = config::build_configuration(&sess, config::parse_cfgspecs(cfgs.clone()));
-        target_features::add_configuration(&mut cfg, &sess, &*codegen_backend);
+        util::add_configuration(&mut cfg, &sess, &*codegen_backend);
         sess.parse_sess.config = cfg;
 
         let out = Some(outdir.lock().unwrap().path().join("rust_out"));
index 7d60a170422b3c3aa252191ba290937835345bf3..1a6b58f35b398c30047935133a59816534760925 100644 (file)
@@ -6,6 +6,7 @@ build = "build.rs"
 license = "MIT/Apache-2.0"
 repository = "https://github.com/rust-lang/rust.git"
 description = "The Rust Standard Library"
+edition = "2018"
 
 [lib]
 name = "std"
index 8b6e5680c2d6c324159678da3e4da9b057243273..a13da2901df94cac80cd831c6c5e7eda856c7828 100644 (file)
@@ -64,7 +64,8 @@
 use core::sync::atomic::{AtomicPtr, Ordering};
 use core::{mem, ptr};
 use core::ptr::NonNull;
-use sys_common::util::dumb_print;
+
+use crate::sys_common::util::dumb_print;
 
 #[stable(feature = "alloc_module", since = "1.28.0")]
 #[doc(inline)]
@@ -208,7 +209,7 @@ pub fn rust_oom(layout: Layout) -> ! {
         unsafe { mem::transmute(hook) }
     };
     hook(layout);
-    unsafe { ::sys::abort_internal(); }
+    unsafe { crate::sys::abort_internal(); }
 }
 
 #[cfg(not(test))]
index 9b4ea0829aa96f361bd1d1d5dfa71db3b034222c..726c27321538d2024dfd7944ce563eb38f771db5 100644 (file)
@@ -1,7 +1,5 @@
 #![deny(warnings)]
 
-extern crate cc;
-
 use std::env;
 
 fn main() {
index 8ca43f8ada211d7c9f1d37c1c876b0bf8be53f86..7f5add0543685f756ff97a7594c04dfbbf510aa3 100644 (file)
@@ -1,8 +1,6 @@
 #![cfg(test)]
 
-extern crate test;
-
-use self::test::Bencher;
+use test::Bencher;
 
 #[bench]
 fn new_drop(b: &mut Bencher) {
index 4fb0235539c484001fd84683c48be4973e26f987..a51847c92b51e2bf964969843501f55c867afd9e 100644 (file)
@@ -1,18 +1,18 @@
 use self::Entry::*;
 use self::VacantEntryState::*;
 
-use intrinsics::unlikely;
-use collections::CollectionAllocErr;
-use cell::Cell;
-use borrow::Borrow;
-use cmp::max;
-use fmt::{self, Debug};
+use crate::intrinsics::unlikely;
+use crate::collections::CollectionAllocErr;
+use crate::cell::Cell;
+use crate::borrow::Borrow;
+use crate::cmp::max;
+use crate::fmt::{self, Debug};
 #[allow(deprecated)]
-use hash::{Hash, Hasher, BuildHasher, SipHasher13};
-use iter::{FromIterator, FusedIterator};
-use mem::{self, replace};
-use ops::{Deref, DerefMut, Index};
-use sys;
+use crate::hash::{Hash, Hasher, BuildHasher, SipHasher13};
+use crate::iter::{FromIterator, FusedIterator};
+use crate::mem::{self, replace};
+use crate::ops::{Deref, DerefMut, Index};
+use crate::sys;
 
 use super::table::{self, Bucket, EmptyBucket, Fallibility, FullBucket, FullBucketMut, RawTable,
                    SafeHash};
@@ -3328,7 +3328,7 @@ mod test_map {
     use super::HashMap;
     use super::Entry::{Occupied, Vacant};
     use super::RandomState;
-    use cell::RefCell;
+    use crate::cell::RefCell;
     use rand::{thread_rng, Rng};
     use realstd::collections::CollectionAllocErr::*;
     use realstd::mem::size_of;
index 46a5f26df635185e5c9e1e1f4eb0c0f4ce95fff6..8a599c11b2095985dd2cda4dd700dd3548361a06 100644 (file)
@@ -1,8 +1,8 @@
-use borrow::Borrow;
-use fmt;
-use hash::{Hash, BuildHasher};
-use iter::{Chain, FromIterator, FusedIterator};
-use ops::{BitOr, BitAnd, BitXor, Sub};
+use crate::borrow::Borrow;
+use crate::fmt;
+use crate::hash::{Hash, BuildHasher};
+use crate::iter::{Chain, FromIterator, FusedIterator};
+use crate::ops::{BitOr, BitAnd, BitXor, Sub};
 
 use super::Recover;
 use super::map::{self, HashMap, Keys, RandomState};
@@ -1751,7 +1751,7 @@ fn test_drain() {
 
     #[test]
     fn test_replace() {
-        use hash;
+        use crate::hash;
 
         #[derive(Debug)]
         struct Foo(&'static str, i32);
index 865431252acf63ad0895c593b8bbc47a3b60e0a6..31e7a6931356cc15b3fcc3a928d7199e7c6770bc 100644 (file)
@@ -1,12 +1,11 @@
-use alloc::{Global, Alloc, Layout, LayoutErr, handle_alloc_error};
-use collections::CollectionAllocErr;
-use hash::{BuildHasher, Hash, Hasher};
-use marker;
-use mem::{size_of, needs_drop};
-use mem;
-use ops::{Deref, DerefMut};
-use ptr::{self, Unique, NonNull};
-use hint;
+use crate::alloc::{Global, Alloc, Layout, LayoutErr, handle_alloc_error};
+use crate::collections::CollectionAllocErr;
+use crate::hash::{BuildHasher, Hash, Hasher};
+use crate::marker;
+use crate::mem::{self, size_of, needs_drop};
+use crate::ops::{Deref, DerefMut};
+use crate::ptr::{self, Unique, NonNull};
+use crate::hint;
 
 use self::BucketState::*;
 
index 9ebeff48426f597d8d8a28ebaa371702a8d2cb7a..286ce2d389b8ca78fb6c9d6b56a8fac044f70b82 100644 (file)
 #[stable(feature = "rust1", since = "1.0.0")]
 #[rustc_deprecated(reason = "moved to `std::ops::Bound`", since = "1.26.0")]
 #[doc(hidden)]
-pub use ops::Bound;
+pub use crate::ops::Bound;
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use alloc_crate::collections::{BinaryHeap, BTreeMap, BTreeSet};
 #[stable(feature = "rust1", since = "1.0.0")]
index 543973ab991dffba8eb5394aff3ee92cd0c41228..97c67f562a7dfac171052b854ec03ce49b91219f 100644 (file)
 
 #![stable(feature = "env", since = "1.0.0")]
 
-use error::Error;
-use ffi::{OsStr, OsString};
-use fmt;
-use io;
-use path::{Path, PathBuf};
-use sys;
-use sys::os as os_imp;
+use crate::error::Error;
+use crate::ffi::{OsStr, OsString};
+use crate::fmt;
+use crate::io;
+use crate::path::{Path, PathBuf};
+use crate::sys;
+use crate::sys::os as os_imp;
 
 /// Returns the current working directory as a [`PathBuf`].
 ///
@@ -800,7 +800,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 /// Constants associated with the current target
 #[stable(feature = "env", since = "1.0.0")]
 pub mod consts {
-    use sys::env::os;
+    use crate::sys::env::os;
 
     /// A string describing the architecture of the CPU that is currently
     /// in use.
@@ -972,7 +972,7 @@ mod arch {
 mod tests {
     use super::*;
 
-    use path::Path;
+    use crate::path::Path;
 
     #[test]
     #[cfg_attr(target_os = "emscripten", ignore)]
@@ -995,7 +995,7 @@ fn test() {
     #[test]
     #[cfg(windows)]
     fn split_paths_windows() {
-        use path::PathBuf;
+        use crate::path::PathBuf;
 
         fn check_parse(unparsed: &str, parsed: &[&str]) -> bool {
             split_paths(unparsed).collect::<Vec<_>>() ==
@@ -1017,7 +1017,7 @@ fn check_parse(unparsed: &str, parsed: &[&str]) -> bool {
     #[test]
     #[cfg(unix)]
     fn split_paths_unix() {
-        use path::PathBuf;
+        use crate::path::PathBuf;
 
         fn check_parse(unparsed: &str, parsed: &[&str]) -> bool {
             split_paths(unparsed).collect::<Vec<_>>() ==
@@ -1034,7 +1034,7 @@ fn check_parse(unparsed: &str, parsed: &[&str]) -> bool {
     #[test]
     #[cfg(unix)]
     fn join_paths_unix() {
-        use ffi::OsStr;
+        use crate::ffi::OsStr;
 
         fn test_eq(input: &[&str], output: &str) -> bool {
             &*join_paths(input.iter().cloned()).unwrap() ==
@@ -1052,7 +1052,7 @@ fn test_eq(input: &[&str], output: &str) -> bool {
     #[test]
     #[cfg(windows)]
     fn join_paths_windows() {
-        use ffi::OsStr;
+        use crate::ffi::OsStr;
 
         fn test_eq(input: &[&str], output: &str) -> bool {
             &*join_paths(input.iter().cloned()).unwrap() ==
index 17e50a649fa5208a3e34d93ab3ec84ae845cf44c..2858308e8f8d59a4303eac8aff88492d4d2f423e 100644 (file)
 // coherence challenge (e.g., specialization, neg impls, etc) we can
 // reconsider what crate these items belong in.
 
-use alloc::{AllocErr, LayoutErr, CannotReallocInPlace};
-use any::TypeId;
-use borrow::Cow;
-use cell;
-use char;
 use core::array;
-use fmt::{self, Debug, Display};
-use mem::transmute;
-use num;
-use str;
-use string;
+
+use crate::alloc::{AllocErr, LayoutErr, CannotReallocInPlace};
+use crate::any::TypeId;
+use crate::borrow::Cow;
+use crate::cell;
+use crate::char;
+use crate::fmt::{self, Debug, Display};
+use crate::mem::transmute;
+use crate::num;
+use crate::str;
+use crate::string;
 
 /// `Error` is a trait representing the basic expectations for error values,
 /// i.e., values of type `E` in [`Result<T, E>`]. Errors must describe
@@ -852,7 +853,7 @@ pub fn downcast<T: Error + 'static>(self: Box<Self>)
 #[cfg(test)]
 mod tests {
     use super::Error;
-    use fmt;
+    use crate::fmt;
 
     #[derive(Debug, PartialEq)]
     struct A;
index cb1f93581775c62fabd145d1a2cd104eeafaabf8..f6cd9e82abd40ca16c0b91286e51d62c3f0004bd 100644 (file)
@@ -9,9 +9,9 @@
 #![allow(missing_docs)]
 
 #[cfg(not(test))]
-use intrinsics;
+use crate::intrinsics;
 #[cfg(not(test))]
-use sys::cmath;
+use crate::sys::cmath;
 
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use core::f32::{RADIX, MANTISSA_DIGITS, DIGITS, EPSILON};
@@ -488,7 +488,7 @@ pub fn log(self, base: f32) -> f32 { self.ln() / base.ln() }
     #[inline]
     pub fn log2(self) -> f32 {
         #[cfg(target_os = "android")]
-        return ::sys::android::log2f32(self);
+        return crate::sys::android::log2f32(self);
         #[cfg(not(target_os = "android"))]
         return unsafe { intrinsics::log2f32(self) };
     }
@@ -932,7 +932,7 @@ pub fn asinh(self) -> f32 {
     #[inline]
     pub fn acosh(self) -> f32 {
         match self {
-            x if x < 1.0 => ::f32::NAN,
+            x if x < 1.0 => crate::f32::NAN,
             x => (x + ((x * x) - 1.0).sqrt()).ln(),
         }
     }
@@ -960,10 +960,10 @@ pub fn atanh(self) -> f32 {
 
 #[cfg(test)]
 mod tests {
-    use f32;
-    use f32::*;
-    use num::*;
-    use num::FpCategory as Fp;
+    use crate::f32;
+    use crate::f32::*;
+    use crate::num::*;
+    use crate::num::FpCategory as Fp;
 
     #[test]
     fn test_num_f32() {
index 7fa7b80751938ec760b8ad16d362b3fff9e5f13a..8ff97ab828a735eab873a98857a5ca841661cb74 100644 (file)
@@ -9,9 +9,9 @@
 #![allow(missing_docs)]
 
 #[cfg(not(test))]
-use intrinsics;
+use crate::intrinsics;
 #[cfg(not(test))]
-use sys::cmath;
+use crate::sys::cmath;
 
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use core::f64::{RADIX, MANTISSA_DIGITS, DIGITS, EPSILON};
@@ -436,7 +436,7 @@ pub fn log(self, base: f64) -> f64 { self.ln() / base.ln() }
     pub fn log2(self) -> f64 {
         self.log_wrapper(|n| {
             #[cfg(target_os = "android")]
-            return ::sys::android::log2f64(n);
+            return crate::sys::android::log2f64(n);
             #[cfg(not(target_os = "android"))]
             return unsafe { intrinsics::log2f64(n) };
         })
@@ -906,10 +906,10 @@ fn log_wrapper<F: Fn(f64) -> f64>(self, log_fn: F) -> f64 {
 
 #[cfg(test)]
 mod tests {
-    use f64;
-    use f64::*;
-    use num::*;
-    use num::FpCategory as Fp;
+    use crate::f64;
+    use crate::f64::*;
+    use crate::num::*;
+    use crate::num::FpCategory as Fp;
 
     #[test]
     fn test_num_f64() {
index 0ef72242827823316e7b11c9f801e5ff6d1fcc77..139680e526fd6b2fc24ad1a94f308f00b71bf9d4 100644 (file)
@@ -1,19 +1,19 @@
-use ascii;
-use borrow::{Cow, Borrow};
-use cmp::Ordering;
-use error::Error;
-use fmt::{self, Write};
-use io;
-use mem;
-use memchr;
-use ops;
-use os::raw::c_char;
-use ptr;
-use rc::Rc;
-use slice;
-use str::{self, Utf8Error};
-use sync::Arc;
-use sys;
+use crate::ascii;
+use crate::borrow::{Cow, Borrow};
+use crate::cmp::Ordering;
+use crate::error::Error;
+use crate::fmt::{self, Write};
+use crate::io;
+use crate::mem;
+use crate::memchr;
+use crate::ops;
+use crate::os::raw::c_char;
+use crate::ptr;
+use crate::rc::Rc;
+use crate::slice;
+use crate::str::{self, Utf8Error};
+use crate::sync::Arc;
+use crate::sys;
 
 /// A type representing an owned, C-compatible, nul-terminated string with no nul bytes in the
 /// middle.
@@ -1303,12 +1303,12 @@ fn as_ref(&self) -> &CStr {
 #[cfg(test)]
 mod tests {
     use super::*;
-    use os::raw::c_char;
-    use borrow::Cow::{Borrowed, Owned};
-    use hash::{Hash, Hasher};
-    use collections::hash_map::DefaultHasher;
-    use rc::Rc;
-    use sync::Arc;
+    use crate::os::raw::c_char;
+    use crate::borrow::Cow::{Borrowed, Owned};
+    use crate::hash::{Hash, Hasher};
+    use crate::collections::hash_map::DefaultHasher;
+    use crate::rc::Rc;
+    use crate::sync::Arc;
 
     #[test]
     fn c_to_rust() {
index 81433832ffc7e4b44a9ffce06fb913b489f15b2b..f68eaeb9c7e1f20d3169abe13e03e478452b9de3 100644 (file)
@@ -1,13 +1,13 @@
-use borrow::{Borrow, Cow};
-use fmt;
-use ops;
-use cmp;
-use hash::{Hash, Hasher};
-use rc::Rc;
-use sync::Arc;
+use crate::borrow::{Borrow, Cow};
+use crate::fmt;
+use crate::ops;
+use crate::cmp;
+use crate::hash::{Hash, Hasher};
+use crate::rc::Rc;
+use crate::sync::Arc;
 
-use sys::os_str::{Buf, Slice};
-use sys_common::{AsInner, IntoInner, FromInner};
+use crate::sys::os_str::{Buf, Slice};
+use crate::sys_common::{AsInner, IntoInner, FromInner};
 
 /// A type that can represent owned, mutable platform-native strings, but is
 /// cheaply inter-convertible with Rust strings.
@@ -968,10 +968,10 @@ fn as_inner(&self) -> &Slice {
 #[cfg(test)]
 mod tests {
     use super::*;
-    use sys_common::{AsInner, IntoInner};
+    use crate::sys_common::{AsInner, IntoInner};
 
-    use rc::Rc;
-    use sync::Arc;
+    use crate::rc::Rc;
+    use crate::sync::Arc;
 
     #[test]
     fn test_os_string_with_capacity() {
index 79b5686faac601a4a55493ec2ae283f1157589b1..25f2dd73504ae87619bf4543230af7b3bcfbb6ee 100644 (file)
@@ -7,13 +7,13 @@
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
-use fmt;
-use ffi::OsString;
-use io::{self, SeekFrom, Seek, Read, Initializer, Write};
-use path::{Path, PathBuf};
-use sys::fs as fs_imp;
-use sys_common::{AsInnerMut, FromInner, AsInner, IntoInner};
-use time::SystemTime;
+use crate::fmt;
+use crate::ffi::OsString;
+use crate::io::{self, SeekFrom, Seek, Read, Initializer, Write};
+use crate::path::{Path, PathBuf};
+use crate::sys::fs as fs_imp;
+use crate::sys_common::{AsInnerMut, FromInner, AsInner, IntoInner};
+use crate::time::SystemTime;
 
 /// A reference to an open file on the filesystem.
 ///
@@ -2096,26 +2096,27 @@ fn as_inner_mut(&mut self) -> &mut fs_imp::DirBuilder {
 
 #[cfg(all(test, not(any(target_os = "cloudabi", target_os = "emscripten"))))]
 mod tests {
-    use io::prelude::*;
+    use crate::io::prelude::*;
+
+    use crate::fs::{self, File, OpenOptions};
+    use crate::io::{ErrorKind, SeekFrom};
+    use crate::path::Path;
+    use crate::str;
+    use crate::sys_common::io::test::{TempDir, tmpdir};
+    use crate::thread;
 
-    use fs::{self, File, OpenOptions};
-    use io::{ErrorKind, SeekFrom};
-    use path::Path;
     use rand::{rngs::StdRng, FromEntropy, RngCore};
-    use str;
-    use sys_common::io::test::{TempDir, tmpdir};
-    use thread;
 
     #[cfg(windows)]
-    use os::windows::fs::{symlink_dir, symlink_file};
+    use crate::os::windows::fs::{symlink_dir, symlink_file};
     #[cfg(windows)]
-    use sys::fs::symlink_junction;
+    use crate::sys::fs::symlink_junction;
     #[cfg(unix)]
-    use os::unix::fs::symlink as symlink_dir;
+    use crate::os::unix::fs::symlink as symlink_dir;
     #[cfg(unix)]
-    use os::unix::fs::symlink as symlink_file;
+    use crate::os::unix::fs::symlink as symlink_file;
     #[cfg(unix)]
-    use os::unix::fs::symlink as symlink_junction;
+    use crate::os::unix::fs::symlink as symlink_junction;
 
     macro_rules! check { ($e:expr) => (
         match $e {
@@ -2334,7 +2335,7 @@ fn file_test_io_eof() {
     #[test]
     #[cfg(unix)]
     fn file_test_io_read_write_at() {
-        use os::unix::fs::FileExt;
+        use crate::os::unix::fs::FileExt;
 
         let tmpdir = tmpdir();
         let filename = tmpdir.join("file_rt_io_file_test_read_write_at.txt");
@@ -2390,7 +2391,7 @@ fn file_test_io_read_write_at() {
     #[test]
     #[cfg(unix)]
     fn set_get_unix_permissions() {
-        use os::unix::fs::PermissionsExt;
+        use crate::os::unix::fs::PermissionsExt;
 
         let tmpdir = tmpdir();
         let filename = &tmpdir.join("set_get_unix_permissions");
@@ -2411,7 +2412,7 @@ fn set_get_unix_permissions() {
     #[test]
     #[cfg(windows)]
     fn file_test_io_seek_read_write() {
-        use os::windows::fs::FileExt;
+        use crate::os::windows::fs::FileExt;
 
         let tmpdir = tmpdir();
         let filename = tmpdir.join("file_rt_io_file_test_seek_read_write.txt");
@@ -3013,7 +3014,7 @@ fn truncate_works() {
 
     #[test]
     fn open_flavors() {
-        use fs::OpenOptions as OO;
+        use crate::fs::OpenOptions as OO;
         fn c<T: Clone>(t: &T) -> T { t.clone() }
 
         let tmpdir = tmpdir();
index 6383a14cf184cdccb8826b0ec6b57e5cba964338..559a54d3c8aca0e2fb732f374b339fc7abe0b19e 100644 (file)
@@ -1,12 +1,12 @@
 //! Buffering wrappers for I/O traits
 
-use io::prelude::*;
+use crate::io::prelude::*;
 
-use cmp;
-use error;
-use fmt;
-use io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom, IoVec, IoVecMut};
-use memchr;
+use crate::cmp;
+use crate::error;
+use crate::fmt;
+use crate::io::{self, Initializer, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom, IoVec, IoVecMut};
+use crate::memchr;
 
 /// The `BufReader` struct adds buffering to any reader.
 ///
@@ -977,11 +977,10 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
 
 #[cfg(test)]
 mod tests {
-    use io::prelude::*;
-    use io::{self, BufReader, BufWriter, LineWriter, SeekFrom};
-    use sync::atomic::{AtomicUsize, Ordering};
-    use thread;
-    use test;
+    use crate::io::prelude::*;
+    use crate::io::{self, BufReader, BufWriter, LineWriter, SeekFrom};
+    use crate::sync::atomic::{AtomicUsize, Ordering};
+    use crate::thread;
 
     /// A dummy reader intended at testing short-reads propagation.
     pub struct ShortReader {
index 577a115025ba7b951a866cdac28accdd5fa67415..873da0898c7fe01c4765c20e42a101bd0dca4e91 100644 (file)
@@ -1,8 +1,9 @@
-use io::prelude::*;
+use crate::io::prelude::*;
+
+use crate::cmp;
+use crate::io::{self, Initializer, SeekFrom, Error, ErrorKind, IoVec, IoVecMut};
 
 use core::convert::TryInto;
-use cmp;
-use io::{self, Initializer, SeekFrom, Error, ErrorKind, IoVec, IoVecMut};
 
 /// A `Cursor` wraps an in-memory buffer and provides it with a
 /// [`Seek`] implementation.
@@ -378,8 +379,8 @@ fn flush(&mut self) -> io::Result<()> { Ok(()) }
 
 #[cfg(test)]
 mod tests {
-    use io::prelude::*;
-    use io::{Cursor, SeekFrom, IoVec, IoVecMut};
+    use crate::io::prelude::*;
+    use crate::io::{Cursor, SeekFrom, IoVec, IoVecMut};
 
     #[test]
     fn test_vec_writer() {
index e9b4f60182c499e3633afe00d139255c921639d3..fdc5625ff1841c1eb82b93b765d730f8984b0e23 100644 (file)
@@ -1,8 +1,8 @@
-use error;
-use fmt;
-use result;
-use sys;
-use convert::From;
+use crate::error;
+use crate::fmt;
+use crate::result;
+use crate::sys;
+use crate::convert::From;
 
 /// A specialized [`Result`](../result/enum.Result.html) type for I/O
 /// operations.
@@ -566,10 +566,10 @@ fn _is_sync_send<T: Sync+Send>() {}
 #[cfg(test)]
 mod test {
     use super::{Error, ErrorKind, Repr, Custom};
-    use error;
-    use fmt;
-    use sys::os::error_string;
-    use sys::decode_error_kind;
+    use crate::error;
+    use crate::fmt;
+    use crate::sys::os::error_string;
+    use crate::sys::decode_error_kind;
 
     #[test]
     fn test_debug_error() {
index aa8db177ffcd10908c8d836fd9ad8d1a2776cbdc..bd3d0a4163869b5266736a2a011754896d766ba0 100644 (file)
@@ -1,8 +1,8 @@
-use cmp;
-use io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind, IoVecMut,
+use crate::cmp;
+use crate::io::{self, SeekFrom, Read, Initializer, Write, Seek, BufRead, Error, ErrorKind, IoVecMut,
          IoVec};
-use fmt;
-use mem;
+use crate::fmt;
+use crate::mem;
 
 // =============================================================================
 // Forwarding implementations
@@ -323,8 +323,7 @@ fn flush(&mut self) -> io::Result<()> { Ok(()) }
 
 #[cfg(test)]
 mod tests {
-    use io::prelude::*;
-    use test;
+    use crate::io::prelude::*;
 
     #[bench]
     fn bench_read_slice(b: &mut test::Bencher) {
index e3ebe82e3daca364cd68108e760501406db36b4e..e864aa2c864bbd69246b18d1a145273d7e310840 100644 (file)
@@ -1,8 +1,8 @@
-use cell::Cell;
-use ptr;
-use sync::Arc;
-use sys_common;
-use sys_common::mutex::Mutex;
+use crate::cell::Cell;
+use crate::ptr;
+use crate::sync::Arc;
+use crate::sys_common;
+use crate::sys_common::mutex::Mutex;
 
 pub struct Lazy<T> {
     // We never call `lock.init()`, so it is UB to attempt to acquire this mutex reentrantly!
index 12b158e4197fc7b8468fad3b9fa26f16f1fbca87..e3e2754a7aa092a62d6e2fdd1803413d16683c54 100644 (file)
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
-use cmp;
-use fmt;
-use slice;
-use str;
-use memchr;
-use ops::{Deref, DerefMut};
-use ptr;
-use sys;
+use crate::cmp;
+use crate::fmt;
+use crate::slice;
+use crate::str;
+use crate::memchr;
+use crate::ops::{Deref, DerefMut};
+use crate::ptr;
+use crate::sys;
 
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use self::buffered::{BufReader, BufWriter, LineWriter};
 mod util;
 mod stdio;
 
-const DEFAULT_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE;
+const DEFAULT_BUF_SIZE: usize = crate::sys_common::io::DEFAULT_BUF_SIZE;
 
 struct Guard<'a> { buf: &'a mut Vec<u8>, len: usize }
 
@@ -1578,7 +1578,7 @@ fn read_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> Result<usize> {
     ///
     /// If successful, this function will return the total number of bytes read.
     ///
-    /// An empty buffer returned indicates that the stream has reached EOF.
+    /// If this function returns `Ok(0)`, the stream has reached EOF.
     ///
     /// # Errors
     ///
@@ -2155,10 +2155,9 @@ fn next(&mut self) -> Option<Result<String>> {
 
 #[cfg(test)]
 mod tests {
-    use io::prelude::*;
-    use io;
+    use crate::io::prelude::*;
+    use crate::io;
     use super::Cursor;
-    use test;
     use super::repeat;
 
     #[test]
index 0324568e6fb5293b7898c9eda4605d027d45b0a3..13bf357e2eb8f45adbab532c95bf7c9110bcee97 100644 (file)
@@ -1,13 +1,13 @@
-use io::prelude::*;
+use crate::io::prelude::*;
 
-use cell::RefCell;
-use fmt;
-use io::lazy::Lazy;
-use io::{self, Initializer, BufReader, LineWriter};
-use sync::{Arc, Mutex, MutexGuard};
-use sys::stdio;
-use sys_common::remutex::{ReentrantMutex, ReentrantMutexGuard};
-use thread::LocalKey;
+use crate::cell::RefCell;
+use crate::fmt;
+use crate::io::lazy::Lazy;
+use crate::io::{self, Initializer, BufReader, LineWriter};
+use crate::sync::{Arc, Mutex, MutexGuard};
+use crate::sys::stdio;
+use crate::sys_common::remutex::{ReentrantMutex, ReentrantMutexGuard};
+use crate::thread::LocalKey;
 
 /// Stdout used by print! and println! macros
 thread_local! {
@@ -668,8 +668,8 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
            issue = "0")]
 #[doc(hidden)]
 pub fn set_panic(sink: Option<Box<dyn Write + Send>>) -> Option<Box<dyn Write + Send>> {
-    use panicking::LOCAL_STDERR;
-    use mem;
+    use crate::panicking::LOCAL_STDERR;
+    use crate::mem;
     LOCAL_STDERR.with(move |slot| {
         mem::replace(&mut *slot.borrow_mut(), sink)
     }).and_then(|mut s| {
@@ -692,7 +692,7 @@ pub fn set_panic(sink: Option<Box<dyn Write + Send>>) -> Option<Box<dyn Write +
            issue = "0")]
 #[doc(hidden)]
 pub fn set_print(sink: Option<Box<dyn Write + Send>>) -> Option<Box<dyn Write + Send>> {
-    use mem;
+    use crate::mem;
     LOCAL_STDOUT.with(move |slot| {
         mem::replace(&mut *slot.borrow_mut(), sink)
     }).and_then(|mut s| {
@@ -749,14 +749,14 @@ pub fn _print(args: fmt::Arguments) {
            issue = "0")]
 #[doc(hidden)]
 pub fn _eprint(args: fmt::Arguments) {
-    use panicking::LOCAL_STDERR;
+    use crate::panicking::LOCAL_STDERR;
     print_to(args, &LOCAL_STDERR, stderr, "stderr");
 }
 
 #[cfg(test)]
 mod tests {
-    use panic::{UnwindSafe, RefUnwindSafe};
-    use thread;
+    use crate::panic::{UnwindSafe, RefUnwindSafe};
+    use crate::thread;
     use super::*;
 
     #[test]
index 5ce955eb1e4af049f84a3a9bda520d2be93530da..6aaf8f1889ac0eaac0746917602980f29c8539df 100644 (file)
@@ -1,8 +1,8 @@
 #![allow(missing_copy_implementations)]
 
-use fmt;
-use io::{self, Read, Initializer, Write, ErrorKind, BufRead, IoVec, IoVecMut};
-use mem;
+use crate::fmt;
+use crate::io::{self, Read, Initializer, Write, ErrorKind, BufRead, IoVec, IoVecMut};
+use crate::mem;
 
 /// Copies the entire contents of a reader into a writer.
 ///
@@ -224,8 +224,8 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 
 #[cfg(test)]
 mod tests {
-    use io::prelude::*;
-    use io::{copy, sink, empty, repeat};
+    use crate::io::prelude::*;
+    use crate::io::{copy, sink, empty, repeat};
 
     #[test]
     fn copy_copies() {
index 877a5a96c10bae7a7b7a6d35d0158e31eab4065f..32a168619dfb3267cdac4f39e3084fe5ddd05a26 100644 (file)
 //! [`sync`]: sync/index.html
 //! [`thread`]: thread/index.html
 //! [`use std::env`]: env/index.html
-//! [`use`]: ../book/ch07-02-modules-and-use-to-control-scope-and-privacy.html#the-use-keyword-to-bring-paths-into-a-scope
+//! [`use`]: ../book/ch07-02-defining-modules-to-control-scope-and-privacy.html
 //! [crates.io]: https://crates.io
 //! [deref-coercions]: ../book/ch15-02-deref.html#implicit-deref-coercions-with-functions-and-methods
 //! [files]: fs/struct.File.html
 #![deny(intra_doc_link_resolution_failure)]
 #![deny(missing_debug_implementations)]
 
+#![deny(rust_2018_idioms)]
+#![allow(explicit_outlives_requirements)]
+#![allow(elided_lifetimes_in_paths)]
+
 // Tell the compiler to link to either panic_abort or panic_unwind
 #![needs_panic_runtime]
 
 
 // Access to Bencher, etc.
 #[cfg(test)] extern crate test;
-#[cfg(test)] extern crate rand;
 
 // Re-export a few macros from core
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use core::{assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne};
 #[stable(feature = "rust1", since = "1.0.0")]
-pub use core::{unreachable, unimplemented, write, writeln, try};
+pub use core::{unreachable, unimplemented, write, writeln, r#try};
 
 #[allow(unused_imports)] // macros from `alloc` are not used on all platforms
 #[macro_use]
 extern crate alloc as alloc_crate;
 #[doc(masked)]
+#[allow(unused_extern_crates)]
 extern crate libc;
-extern crate rustc_demangle;
 
 // We always need an unwinder currently for backtraces
 #[doc(masked)]
 #[allow(unused_extern_crates)]
 extern crate unwind;
 
-#[cfg(feature = "backtrace")]
-extern crate backtrace_sys;
-
 // During testing, this crate is not actually the "real" std library, but rather
 // it links to the real std library, which was compiled from this same source
 // code. So any lang items std defines are conditionally excluded (or else they
 // testing gives test-std access to real-std lang items and globals. See #2912
 #[cfg(test)] extern crate std as realstd;
 
-#[cfg(all(target_vendor = "fortanix", target_env = "sgx"))]
-extern crate fortanix_sgx_abi;
-
 // The standard macros that are not built-in to the compiler.
 #[macro_use]
 mod macros;
index b9204d27f539271e4b2b6973bfec19da4a97aede..281641c3c12321f0b5f3248c17b53d9eeeffe880 100644 (file)
@@ -333,7 +333,7 @@ macro_rules! dbg {
 #[cfg_attr(stage0, allow_internal_unstable)]
 #[cfg_attr(not(stage0), allow_internal_unstable(gen_future, generators))]
 #[allow_internal_unsafe]
-macro_rules! await {
+macro_rules! r#await {
     ($e:expr) => { {
         let mut pinned = $e;
         loop {
index 9f44c67c1cc5cb2256c574222bd76b23f0b55c71..d69294b2d200c81ebca63723f7581e2eb291b888 100644 (file)
@@ -22,7 +22,7 @@
 /// ```
 #[inline]
 pub fn memchr(needle: u8, haystack: &[u8]) -> Option<usize> {
-    ::sys::memchr::memchr(needle, haystack)
+    crate::sys::memchr::memchr(needle, haystack)
 }
 
 /// A safe interface to `memrchr`.
@@ -42,7 +42,7 @@ pub fn memchr(needle: u8, haystack: &[u8]) -> Option<usize> {
 /// ```
 #[inline]
 pub fn memrchr(needle: u8, haystack: &[u8]) -> Option<usize> {
-    ::sys::memchr::memrchr(needle, haystack)
+    crate::sys::memchr::memrchr(needle, haystack)
 }
 
 #[cfg(test)]
index 4b60ee8e6daddc47d04c7fa7296dfdd4a10658d9..f5a87cc3ea67a057759d62e562b8e9b3927fca08 100644 (file)
@@ -1,16 +1,16 @@
-use fmt;
-use hash;
-use io;
-use mem;
-use net::{ntoh, hton, IpAddr, Ipv4Addr, Ipv6Addr};
-use option;
-use sys::net::netc as c;
-use sys_common::{FromInner, AsInner, IntoInner};
-use sys_common::net::LookupHost;
-use vec;
-use iter;
-use slice;
-use convert::TryInto;
+use crate::fmt;
+use crate::hash;
+use crate::io;
+use crate::mem;
+use crate::net::{ntoh, hton, IpAddr, Ipv4Addr, Ipv6Addr};
+use crate::option;
+use crate::sys::net::netc as c;
+use crate::sys_common::{FromInner, AsInner, IntoInner};
+use crate::sys_common::net::LookupHost;
+use crate::vec;
+use crate::iter;
+use crate::slice;
+use crate::convert::TryInto;
 
 /// An internet socket address, either IPv4 or IPv6.
 ///
@@ -921,8 +921,8 @@ fn to_socket_addrs(&self) -> io::Result<vec::IntoIter<SocketAddr>> {
 
 #[cfg(all(test, not(target_os = "emscripten")))]
 mod tests {
-    use net::*;
-    use net::test::{tsa, sa6, sa4};
+    use crate::net::*;
+    use crate::net::test::{tsa, sa6, sa4};
 
     #[test]
     fn to_socket_addr_ipaddr_u16() {
index c856129016814d922541b7b81ea7d7b6799b3922..fa256ce508655b4bd2e6e640bcf5a6dd96f3aa06 100644 (file)
@@ -3,11 +3,11 @@
                                       be to be stable",
             issue = "27709")]
 
-use cmp::Ordering;
-use fmt;
-use hash;
-use sys::net::netc as c;
-use sys_common::{AsInner, FromInner};
+use crate::cmp::Ordering;
+use crate::fmt;
+use crate::hash;
+use crate::sys::net::netc as c;
+use crate::sys_common::{AsInner, FromInner};
 
 /// An IP address, either IPv4 or IPv6.
 ///
@@ -1509,9 +1509,9 @@ fn from(ip: u128) -> Ipv6Addr {
 // Tests for this module
 #[cfg(all(test, not(target_os = "emscripten")))]
 mod tests {
-    use net::*;
-    use net::Ipv6MulticastScope::*;
-    use net::test::{tsa, sa6, sa4};
+    use crate::net::*;
+    use crate::net::Ipv6MulticastScope::*;
+    use crate::net::test::{tsa, sa6, sa4};
 
     #[test]
     fn test_from_str_ipv4() {
index 93e724db3d4d089e16b0b824b2f20c84fafaf7ab..b68146939fdcc2dc2fc99a87110deb5464a46eeb 100644 (file)
@@ -28,7 +28,7 @@
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
-use io::{self, Error, ErrorKind};
+use crate::io::{self, Error, ErrorKind};
 
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use self::ip::{IpAddr, Ipv4Addr, Ipv6Addr, Ipv6MulticastScope};
index 70e0c2ad4b49b85b05fb259ba7952cd885940f94..7951cd6bcf28ca589e92dfb016e204f2dee21a07 100644 (file)
@@ -3,10 +3,10 @@
 //! This module is "publicly exported" through the `FromStr` implementations
 //! below.
 
-use error::Error;
-use fmt;
-use net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
-use str::FromStr;
+use crate::error::Error;
+use crate::fmt;
+use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
+use crate::str::FromStr;
 
 struct Parser<'a> {
     // parsing as ASCII, so can use byte array
index 3aa29f83b2938f31d2604b6c21c5377dfecf0a35..275557da96f67d80b75961ba09c2dac6b122fbd9 100644 (file)
@@ -1,11 +1,11 @@
-use io::prelude::*;
+use crate::io::prelude::*;
 
-use fmt;
-use io::{self, Initializer, IoVec, IoVecMut};
-use net::{ToSocketAddrs, SocketAddr, Shutdown};
-use sys_common::net as net_imp;
-use sys_common::{AsInner, FromInner, IntoInner};
-use time::Duration;
+use crate::fmt;
+use crate::io::{self, Initializer, IoVec, IoVecMut};
+use crate::net::{ToSocketAddrs, SocketAddr, Shutdown};
+use crate::sys_common::net as net_imp;
+use crate::sys_common::{AsInner, FromInner, IntoInner};
+use crate::time::Duration;
 
 /// A TCP stream between a local and a remote socket.
 ///
@@ -929,14 +929,14 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 
 #[cfg(all(test, not(any(target_os = "cloudabi", target_os = "emscripten"))))]
 mod tests {
-    use io::{ErrorKind, IoVec, IoVecMut};
-    use io::prelude::*;
-    use net::*;
-    use net::test::{next_test_ip4, next_test_ip6};
-    use sync::mpsc::channel;
-    use sys_common::AsInner;
-    use time::{Instant, Duration};
-    use thread;
+    use crate::io::{ErrorKind, IoVec, IoVecMut};
+    use crate::io::prelude::*;
+    use crate::net::*;
+    use crate::net::test::{next_test_ip4, next_test_ip6};
+    use crate::sync::mpsc::channel;
+    use crate::sys_common::AsInner;
+    use crate::time::{Instant, Duration};
+    use crate::thread;
 
     fn each_ip(f: &mut dyn FnMut(SocketAddr)) {
         f(next_test_ip4());
index eb5862cbdd945fdfdef42dce8d0a2aec72ea4007..89fefd9d1d5e069f8bd3a58398b6b4782b1cf5f5 100644 (file)
@@ -1,8 +1,8 @@
 #![allow(warnings)] // not used on emscripten
 
-use env;
-use net::{SocketAddr, SocketAddrV4, SocketAddrV6, Ipv4Addr, Ipv6Addr, ToSocketAddrs};
-use sync::atomic::{AtomicUsize, Ordering};
+use crate::env;
+use crate::net::{SocketAddr, SocketAddrV4, SocketAddrV6, Ipv4Addr, Ipv6Addr, ToSocketAddrs};
+use crate::sync::atomic::{AtomicUsize, Ordering};
 
 static PORT: AtomicUsize = AtomicUsize::new(0);
 
index d49871ce7bd86556c3b7690920d4232d33ce8f67..edc9d665444a035ebe396fe1c08bf40f5f6f627f 100644 (file)
@@ -1,9 +1,9 @@
-use fmt;
-use io::{self, Error, ErrorKind};
-use net::{ToSocketAddrs, SocketAddr, Ipv4Addr, Ipv6Addr};
-use sys_common::net as net_imp;
-use sys_common::{AsInner, FromInner, IntoInner};
-use time::Duration;
+use crate::fmt;
+use crate::io::{self, Error, ErrorKind};
+use crate::net::{ToSocketAddrs, SocketAddr, Ipv4Addr, Ipv6Addr};
+use crate::sys_common::net as net_imp;
+use crate::sys_common::{AsInner, FromInner, IntoInner};
+use crate::time::Duration;
 
 /// A UDP socket.
 ///
@@ -808,13 +808,13 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 
 #[cfg(all(test, not(any(target_os = "cloudabi", target_os = "emscripten"))))]
 mod tests {
-    use io::ErrorKind;
-    use net::*;
-    use net::test::{next_test_ip4, next_test_ip6};
-    use sync::mpsc::channel;
-    use sys_common::AsInner;
-    use time::{Instant, Duration};
-    use thread;
+    use crate::io::ErrorKind;
+    use crate::net::*;
+    use crate::net::test::{next_test_ip4, next_test_ip6};
+    use crate::sync::mpsc::channel;
+    use crate::sys_common::AsInner;
+    use crate::time::{Instant, Duration};
+    use crate::thread;
 
     fn each_ip(f: &mut dyn FnMut(SocketAddr, SocketAddr)) {
         f(next_test_ip4(), next_test_ip4());
index c80b9a56704a7840ad23330ebbcdd7c835b1f1ae..828d5720eec1eeff9a2be7bb84aabd01e75418cc 100644 (file)
@@ -14,8 +14,8 @@
 #[stable(feature = "nonzero", since = "1.28.0")]
 pub use core::num::{NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU128, NonZeroUsize};
 
-#[cfg(test)] use fmt;
-#[cfg(test)] use ops::{Add, Sub, Mul, Div, Rem};
+#[cfg(test)] use crate::fmt;
+#[cfg(test)] use crate::ops::{Add, Sub, Mul, Div, Rem};
 
 /// Helper function for testing numeric operations
 #[cfg(test)]
@@ -35,16 +35,16 @@ pub fn test_num<T>(ten: T, two: T) where
 
 #[cfg(test)]
 mod tests {
-    use u8;
-    use u16;
-    use u32;
-    use u64;
-    use usize;
-    use ops::Mul;
+    use crate::u8;
+    use crate::u16;
+    use crate::u32;
+    use crate::u64;
+    use crate::usize;
+    use crate::ops::Mul;
 
     #[test]
     fn test_saturating_add_uint() {
-        use usize::MAX;
+        use crate::usize::MAX;
         assert_eq!(3_usize.saturating_add(5_usize), 8_usize);
         assert_eq!(3_usize.saturating_add(MAX-1), MAX);
         assert_eq!(MAX.saturating_add(MAX), MAX);
@@ -53,7 +53,7 @@ fn test_saturating_add_uint() {
 
     #[test]
     fn test_saturating_sub_uint() {
-        use usize::MAX;
+        use crate::usize::MAX;
         assert_eq!(5_usize.saturating_sub(3_usize), 2_usize);
         assert_eq!(3_usize.saturating_sub(5_usize), 0_usize);
         assert_eq!(0_usize.saturating_sub(1_usize), 0_usize);
@@ -62,7 +62,7 @@ fn test_saturating_sub_uint() {
 
     #[test]
     fn test_saturating_add_int() {
-        use isize::{MIN,MAX};
+        use crate::isize::{MIN,MAX};
         assert_eq!(3i32.saturating_add(5), 8);
         assert_eq!(3isize.saturating_add(MAX-1), MAX);
         assert_eq!(MAX.saturating_add(MAX), MAX);
@@ -74,7 +74,7 @@ fn test_saturating_add_int() {
 
     #[test]
     fn test_saturating_sub_int() {
-        use isize::{MIN,MAX};
+        use crate::isize::{MIN,MAX};
         assert_eq!(3i32.saturating_sub(5), -2);
         assert_eq!(MIN.saturating_sub(1), MIN);
         assert_eq!((-2isize).saturating_sub(MAX), MIN);
@@ -232,8 +232,8 @@ fn test_uint_to_str_overflow() {
         assert_eq!(u64_val.to_string(), "0");
     }
 
-    fn from_str<T: ::str::FromStr>(t: &str) -> Option<T> {
-        ::str::FromStr::from_str(t).ok()
+    fn from_str<T: crate::str::FromStr>(t: &str) -> Option<T> {
+        crate::str::FromStr::from_str(t).ok()
     }
 
     #[test]
@@ -275,8 +275,7 @@ fn test_uint_from_str_overflow() {
 
 #[cfg(test)]
 mod bench {
-    extern crate test;
-    use self::test::Bencher;
+    use test::Bencher;
 
     #[bench]
     fn bench_pow_function(b: &mut Bencher) {
index 7aab6bf27ca883837bcb96cfe50c0e3abc3a2116..9b24f86204bb6d0ca156ba84bc7d64572655a0eb 100644 (file)
@@ -1,12 +1,10 @@
 #![stable(feature = "metadata_ext", since = "1.1.0")]
 
-use libc;
-
-use fs::Metadata;
-use sys_common::AsInner;
+use crate::fs::Metadata;
+use crate::sys_common::AsInner;
 
 #[allow(deprecated)]
-use os::android::raw;
+use crate::os::android::raw;
 
 /// OS-specific extensions to [`fs::Metadata`].
 ///
index e03de8a7cc40b92020e61e9a1f86132f774f7cb3..acf5ca1e4297bc6b23497960fe86d75959f47b06 100644 (file)
@@ -8,7 +8,7 @@
                               definitions")]
 #![allow(deprecated)]
 
-use os::raw::c_long;
+use crate::os::raw::c_long;
 
 #[stable(feature = "pthread_t", since = "1.8.0")]
 pub type pthread_t = c_long;
@@ -19,8 +19,8 @@
 
 #[cfg(any(target_arch = "arm", target_arch = "x86"))]
 mod arch {
-    use os::raw::{c_uint, c_uchar, c_ulonglong, c_longlong, c_ulong};
-    use os::unix::raw::{uid_t, gid_t};
+    use crate::os::raw::{c_uint, c_uchar, c_ulonglong, c_longlong, c_ulong};
+    use crate::os::unix::raw::{uid_t, gid_t};
 
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub type dev_t = u64;
@@ -89,8 +89,8 @@ pub struct stat {
 
 #[cfg(target_arch = "aarch64")]
 mod arch {
-    use os::raw::{c_uchar, c_ulong};
-    use os::unix::raw::{uid_t, gid_t};
+    use crate::os::raw::{c_uchar, c_ulong};
+    use crate::os::unix::raw::{uid_t, gid_t};
 
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub type dev_t = u64;
@@ -157,8 +157,8 @@ pub struct stat {
 
 #[cfg(target_arch = "x86_64")]
 mod arch {
-    use os::raw::{c_uint, c_long, c_ulong};
-    use os::unix::raw::{uid_t, gid_t};
+    use crate::os::raw::{c_uint, c_long, c_ulong};
+    use crate::os::unix::raw::{uid_t, gid_t};
 
     #[stable(feature = "raw_ext", since = "1.1.0")]
     pub type dev_t = u64;
index 8d6da3b7a07308aa837629070b68c607935aea0c..849d4aa67f20411b88e6b0b9276deca3af15ec35 100644 (file)
@@ -1,12 +1,10 @@
 #![stable(feature = "metadata_ext", since = "1.1.0")]
 
-use libc;
-
-use fs::Metadata;
-use sys_common::AsInner;
+use crate::fs::Metadata;
+use crate::sys_common::AsInner;
 
 #[allow(deprecated)]
-use os::bitrig::raw;
+use crate::os::bitrig::raw;
 
 /// OS-specific extensions to [`fs::Metadata`].
 ///
index 034dc986b6917a246cc26fe2a10e60142b3b68df..c966d5a8e5b4938caaa4748407e771b04fd332a2 100644 (file)
@@ -8,8 +8,8 @@
                               definitions")]
 #![allow(deprecated)]
 
-use os::raw::c_long;
-use os::unix::raw::{uid_t, gid_t};
+use crate::os::raw::c_long;
+use crate::os::unix::raw::{uid_t, gid_t};
 
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
index 14f5e8035687fab12676b3ad87d914016042f4e0..ba38660224f24b1321aa7687bc0dfe765536859f 100644 (file)
@@ -1,12 +1,10 @@
 #![stable(feature = "metadata_ext", since = "1.1.0")]
 
-use libc;
-
-use fs::Metadata;
-use sys_common::AsInner;
+use crate::fs::Metadata;
+use crate::sys_common::AsInner;
 
 #[allow(deprecated)]
-use os::dragonfly::raw;
+use crate::os::dragonfly::raw;
 
 /// OS-specific extensions to [`fs::Metadata`].
 ///
index 4f36652ddcf506303532d643da96bae300a79f01..46ef5a1e7cf7bce3b7c5984bb5dd8ccf5b32e35d 100644 (file)
@@ -8,7 +8,7 @@
                               definitions")]
 #![allow(deprecated)]
 
-use os::raw::c_long;
+use crate::os::raw::c_long;
 
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
index 33c41c9223e6943ad7fc8ae070feddbfc81240bc..aa6aa38283def97e7dd6b18e0289338c7cfc11dd 100644 (file)
@@ -1,12 +1,10 @@
 #![stable(feature = "metadata_ext", since = "1.1.0")]
 
-use libc;
-
-use fs::Metadata;
-use sys_common::AsInner;
+use crate::fs::Metadata;
+use crate::sys_common::AsInner;
 
 #[allow(deprecated)]
-use os::emscripten::raw;
+use crate::os::emscripten::raw;
 
 /// OS-specific extensions to [`fs::Metadata`].
 ///
index d59ce482ef788eb0df1fc7c04e3e198c611c5b6e..e55134879794288edfcb28078b2cd0a6649549bb 100644 (file)
@@ -10,7 +10,7 @@
                               definitions")]
 #![allow(deprecated)]
 
-use os::raw::{c_long, c_short, c_uint, c_ulong};
+use crate::os::raw::{c_long, c_short, c_uint, c_ulong};
 
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32;
index bd6f4b4465b24e5dc5343c3f30dfe5db0aefac13..bca22e717d7245cfa496bbdaf6aa5f234e38ff83 100644 (file)
 ///
 /// [ABI documentation]: https://docs.rs/fortanix-sgx-abi/
 pub mod usercalls {
-    pub use sys::abi::usercalls::*;
+    pub use crate::sys::abi::usercalls::*;
 
     /// Primitives for allocating memory in userspace as well as copying data
     /// to and from user memory.
     pub mod alloc {
-        pub use sys::abi::usercalls::alloc::*;
+        pub use crate::sys::abi::usercalls::alloc::*;
     }
 
     /// Lowest-level interfaces to usercalls and usercall ABI type definitions.
     pub mod raw {
-        pub use sys::abi::usercalls::raw::{do_usercall, Usercalls as UsercallNrs};
-        pub use sys::abi::usercalls::raw::{accept_stream, alloc, async_queues, bind_stream, close,
-                                           connect_stream, exit, flush, free, insecure_time,
+        pub use crate::sys::abi::usercalls::raw::{do_usercall, Usercalls as UsercallNrs};
+        pub use crate::sys::abi::usercalls::raw::{accept_stream, alloc, async_queues, bind_stream,
+                                           close, connect_stream, exit, flush, free, insecure_time,
                                            launch_thread, read, read_alloc, send, wait, write};
 
         // fortanix-sgx-abi re-exports
-        pub use sys::abi::usercalls::raw::{ByteBuffer, FifoDescriptor, Return, Usercall};
-        pub use sys::abi::usercalls::raw::Error;
-        pub use sys::abi::usercalls::raw::{EV_RETURNQ_NOT_EMPTY, EV_UNPARK, EV_USERCALLQ_NOT_FULL,
-                                           FD_STDERR, FD_STDIN, FD_STDOUT, RESULT_SUCCESS,
-                                           USERCALL_USER_DEFINED, WAIT_INDEFINITE, WAIT_NO};
-        pub use sys::abi::usercalls::raw::{Fd, Result, Tcs};
+        pub use crate::sys::abi::usercalls::raw::{ByteBuffer, FifoDescriptor, Return, Usercall};
+        pub use crate::sys::abi::usercalls::raw::Error;
+        pub use crate::sys::abi::usercalls::raw::{EV_RETURNQ_NOT_EMPTY, EV_UNPARK,
+                                           EV_USERCALLQ_NOT_FULL, FD_STDERR, FD_STDIN, FD_STDOUT,
+                                           RESULT_SUCCESS, USERCALL_USER_DEFINED, WAIT_INDEFINITE,
+                                           WAIT_NO};
+        pub use crate::sys::abi::usercalls::raw::{Fd, Result, Tcs};
     }
 }
 
 /// Functions for querying mapping information for pointers.
 pub mod mem {
-    pub use sys::abi::mem::*;
+    pub use crate::sys::abi::mem::*;
 }
 
-pub use sys::ext::{io, arch, ffi};
+pub use crate::sys::ext::{io, arch, ffi};
index 1b4a0fcfa7c1ee156e8f64c06ede28ab7ea4d82c..4cc3a4b91fbd8beb3b4b02e5222273bdea8ac74f 100644 (file)
@@ -1,12 +1,10 @@
 #![stable(feature = "metadata_ext", since = "1.1.0")]
 
-use libc;
-
-use fs::Metadata;
-use sys_common::AsInner;
+use crate::fs::Metadata;
+use crate::sys_common::AsInner;
 
 #[allow(deprecated)]
-use os::freebsd::raw;
+use crate::os::freebsd::raw;
 
 /// OS-specific extensions to [`fs::Metadata`].
 ///
index 7d90e583b5b9fe256f0286040ca5524acb72f415..0c58154ae607d578a9cab0ff247d0a100cf5f01c 100644 (file)
@@ -8,7 +8,7 @@
                               definitions")]
 #![allow(deprecated)]
 
-use os::raw::c_long;
+use crate::os::raw::c_long;
 
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
index 8c2d23cb1c2eca10873bce7c1d3421aaf853478e..1544bdfbe0cde19b79917a7a45cfdd0efc92b803 100644 (file)
@@ -1,7 +1,7 @@
 #![stable(feature = "metadata_ext", since = "1.1.0")]
 
-use fs::Metadata;
-use sys_common::AsInner;
+use crate::fs::Metadata;
+use crate::sys_common::AsInner;
 
 /// OS-specific extensions to [`fs::Metadata`].
 ///
index b4a6bd3295c6bd6820906c39b5c0fd58b32e99ea..7e44a79b371ce5ea3ff88186ef81f9537ae9144c 100644 (file)
@@ -8,7 +8,7 @@
                               definitions")]
 #![allow(deprecated)]
 
-use os::raw::c_ulong;
+use crate::os::raw::c_ulong;
 
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32;
@@ -25,7 +25,7 @@
           target_arch = "powerpc",
           target_arch = "arm"))]
 mod arch {
-    use os::raw::{c_long, c_short, c_uint};
+    use crate::os::raw::{c_long, c_short, c_uint};
 
     #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
     #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
@@ -81,7 +81,7 @@ pub struct stat {
 
 #[cfg(target_arch = "mips")]
 mod arch {
-    use os::raw::{c_long, c_ulong};
+    use crate::os::raw::{c_long, c_ulong};
 
     #[cfg(target_env = "musl")]
     #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
@@ -151,7 +151,7 @@ mod arch {
 
 #[cfg(target_arch = "aarch64")]
 mod arch {
-    use os::raw::{c_long, c_int};
+    use crate::os::raw::{c_long, c_int};
 
     #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
     #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
@@ -207,7 +207,7 @@ pub struct stat {
 
 #[cfg(target_arch = "x86_64")]
 mod arch {
-    use os::raw::{c_long, c_int};
+    use crate::os::raw::{c_long, c_int};
 
     #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
     #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
index 2ed1ca975d8b622c45acc71812a5a0ed4ab500ef..4097f8c26a62f26d6ac42f32a863c27349c11384 100644 (file)
@@ -1,12 +1,10 @@
 #![stable(feature = "metadata_ext", since = "1.1.0")]
 
-use libc;
-
-use fs::Metadata;
-use sys_common::AsInner;
+use crate::fs::Metadata;
+use crate::sys_common::AsInner;
 
 #[allow(deprecated)]
-use os::haiku::raw;
+use crate::os::haiku::raw;
 
 /// OS-specific extensions to [`fs::Metadata`].
 ///
index e6af8f29807cf511ede9afcc7ef608ebe6209e3d..d86f4f3ba57cb8dbe8bd23ad85494b771d28e257 100644 (file)
@@ -4,8 +4,8 @@
 
 #![allow(deprecated)]
 
-use os::raw::{c_long};
-use os::unix::raw::{uid_t, gid_t};
+use crate::os::raw::{c_long};
+use crate::os::unix::raw::{uid_t, gid_t};
 
 // Use the direct definition of usize, instead of uintptr_t like in libc
 #[stable(feature = "pthread_t", since = "1.8.0")] pub type pthread_t = usize;
index b94324475e5ad85b937e92cd43f986b8ff252ab5..eb28a839ba86582871bcecba8922aeb7b49f144d 100644 (file)
@@ -1,12 +1,10 @@
 #![stable(feature = "metadata_ext", since = "1.1.0")]
 
-use libc;
-
-use fs::Metadata;
-use sys_common::AsInner;
+use crate::fs::Metadata;
+use crate::sys_common::AsInner;
 
 #[allow(deprecated)]
-use os::hermit::raw;
+use crate::os::hermit::raw;
 
 /// OS-specific extensions to [`fs::Metadata`].
 ///
index 7f0bdb80b20d6eabbc38b8586837487b827ddb42..7b625f5e3fe36fd3584cc5bef7401b2170e3b579 100644 (file)
@@ -1,12 +1,10 @@
 #![stable(feature = "metadata_ext", since = "1.1.0")]
 
-use libc;
-
-use fs::Metadata;
-use sys_common::AsInner;
+use crate::fs::Metadata;
+use crate::sys_common::AsInner;
 
 #[allow(deprecated)]
-use os::ios::raw;
+use crate::os::ios::raw;
 
 /// OS-specific extensions to [`fs::Metadata`].
 ///
index 1b528ce8c91b6364ced804a3c6e8c80955555662..fa38bca09e26a9843981b23030d4e6dcdeb11390 100644 (file)
@@ -8,7 +8,7 @@
                               definitions")]
 #![allow(deprecated)]
 
-use os::raw::c_long;
+use crate::os::raw::c_long;
 
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
index 572d814fc069671922d576e6caea6e80c99fb284..ec5e98370768d81fd2a2074164325a436ac33b8b 100644 (file)
@@ -1,12 +1,10 @@
 #![stable(feature = "metadata_ext", since = "1.1.0")]
 
-use libc;
-
-use fs::Metadata;
-use sys_common::AsInner;
+use crate::fs::Metadata;
+use crate::sys_common::AsInner;
 
 #[allow(deprecated)]
-use os::linux::raw;
+use crate::os::linux::raw;
 
 /// OS-specific extensions to [`fs::Metadata`].
 ///
index e5ab8a839cb7bd54828c53cd3e0de895acd4caaa..77eeacb4b477c4a8c7af9576be4205acec3a34c3 100644 (file)
@@ -9,7 +9,7 @@
 #![allow(deprecated)]
 #![allow(missing_debug_implementations)]
 
-use os::raw::c_ulong;
+use crate::os::raw::c_ulong;
 
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32;
@@ -28,7 +28,7 @@
           target_arch = "asmjs",
           target_arch = "wasm32"))]
 mod arch {
-    use os::raw::{c_long, c_short, c_uint};
+    use crate::os::raw::{c_long, c_short, c_uint};
 
     #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
     #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
@@ -84,7 +84,7 @@ pub struct stat {
 
 #[cfg(target_arch = "mips")]
 mod arch {
-    use os::raw::{c_long, c_ulong};
+    use crate::os::raw::{c_long, c_ulong};
 
     #[cfg(target_env = "musl")]
     #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = i64;
@@ -156,7 +156,7 @@ mod arch {
 
 #[cfg(target_arch = "aarch64")]
 mod arch {
-    use os::raw::{c_long, c_int};
+    use crate::os::raw::{c_long, c_int};
 
     #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
     #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
@@ -212,7 +212,7 @@ pub struct stat {
 
 #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64"))]
 mod arch {
-    use os::raw::{c_long, c_int};
+    use crate::os::raw::{c_long, c_int};
 
     #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
     #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
index 1227fc46fcdc11d2620a0f3df4cd923d0ea0b489..1bd66ad4c764c10316559dc517b2922922ad9c1a 100644 (file)
@@ -1,12 +1,10 @@
 #![stable(feature = "metadata_ext", since = "1.1.0")]
 
-use libc;
-
-use fs::Metadata;
-use sys_common::AsInner;
+use crate::fs::Metadata;
+use crate::sys_common::AsInner;
 
 #[allow(deprecated)]
-use os::macos::raw;
+use crate::os::macos::raw;
 
 /// OS-specific extensions to [`fs::Metadata`].
 ///
index 684cb891e0012c9541b78b7df4d7c194b9202ef6..5685642c07ff8ac7c854ec642b777dab1192deab 100644 (file)
@@ -8,7 +8,7 @@
                               definitions")]
 #![allow(deprecated)]
 
-use os::raw::c_long;
+use crate::os::raw::c_long;
 
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
index 6215ba47e30a83f09566bac58f37c17810332490..5cce3df71d6a926a9df7d09177153378420b41a7 100644 (file)
         // cross-platform way in the documentation
 
         #[stable(feature = "rust1", since = "1.0.0")]
-        pub use sys::unix_ext as unix;
+        pub use crate::sys::unix_ext as unix;
 
         #[stable(feature = "rust1", since = "1.0.0")]
-        pub use sys::windows_ext as windows;
+        pub use crate::sys::windows_ext as windows;
 
         #[doc(cfg(target_os = "linux"))]
         pub mod linux;
 
         #[cfg(any(target_os = "redox", unix))]
         #[stable(feature = "rust1", since = "1.0.0")]
-        pub use sys::ext as unix;
+        pub use crate::sys::ext as unix;
 
         #[cfg(windows)]
         #[stable(feature = "rust1", since = "1.0.0")]
-        pub use sys::ext as windows;
+        pub use crate::sys::ext as windows;
 
         #[cfg(any(target_os = "linux", target_os = "l4re"))]
         pub mod linux;
index 7022013e9dd2969e69e08375d1e82f0b17f5a498..6dffb70b5dc7bdb6c158e4e59b480f164cb1afe9 100644 (file)
@@ -1,12 +1,10 @@
 #![stable(feature = "metadata_ext", since = "1.1.0")]
 
-use libc;
-
-use fs::Metadata;
-use sys_common::AsInner;
+use crate::fs::Metadata;
+use crate::sys_common::AsInner;
 
 #[allow(deprecated)]
-use os::netbsd::raw;
+use crate::os::netbsd::raw;
 
 /// OS-specific extensions to [`fs::Metadata`].
 ///
index f02bae801a24ba1a82bd74841efb6e220563ec93..1d5d5c6891e3fec8ed2bc5e6fca0d64e639d9b7f 100644 (file)
@@ -8,8 +8,8 @@
                               definitions")]
 #![allow(deprecated)]
 
-use os::raw::c_long;
-use os::unix::raw::{uid_t, gid_t};
+use crate::os::raw::c_long;
+use crate::os::unix::raw::{uid_t, gid_t};
 
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
index 4d9749199f94d57d301411abe878a594d28b43aa..73f9757f3b794bb8ca7673ef908c32a7a7e6005e 100644 (file)
@@ -1,12 +1,10 @@
 #![stable(feature = "metadata_ext", since = "1.1.0")]
 
-use libc;
-
-use fs::Metadata;
-use sys_common::AsInner;
+use crate::fs::Metadata;
+use crate::sys_common::AsInner;
 
 #[allow(deprecated)]
-use os::openbsd::raw;
+use crate::os::openbsd::raw;
 
 /// OS-specific extensions to [`fs::Metadata`].
 ///
index 27710ca6ce7b08fe24a3273e8cc1f20e095c7723..094168453d792303c421121a56295285b7387543 100644 (file)
@@ -8,7 +8,7 @@
                               definitions")]
 #![allow(deprecated)]
 
-use os::raw::c_long;
+use crate::os::raw::c_long;
 
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
index 78288a6a1f0ca6143d77cfbef8492c2af741aabc..e9043b4b40d73d0474f265e9505f6ef4ce355a56 100644 (file)
@@ -86,9 +86,8 @@
 #[cfg(test)]
 #[allow(unused_imports)]
 mod tests {
-    use any::TypeId;
-    use libc;
-    use mem;
+    use crate::any::TypeId;
+    use crate::mem;
 
     macro_rules! ok {
         ($($t:ident)*) => {$(
@@ -99,7 +98,7 @@ macro_rules! ok {
 
     #[test]
     fn same() {
-        use os::raw;
+        use crate::os::raw;
         ok!(c_char c_schar c_uchar c_short c_ushort c_int c_uint c_long c_ulong
             c_longlong c_ulonglong c_float c_double);
     }
index f2f89b5dd8bcc2b0b19d5b2691c9514217447fbd..55a8d5d1ef0078fd62614e2ecf7dca504dfb648b 100644 (file)
@@ -1,12 +1,10 @@
 #![stable(feature = "metadata_ext", since = "1.1.0")]
 
-use libc;
-
-use fs::Metadata;
-use sys_common::AsInner;
+use crate::fs::Metadata;
+use crate::sys_common::AsInner;
 
 #[allow(deprecated)]
-use os::solaris::raw;
+use crate::os::solaris::raw;
 
 /// OS-specific extensions to [`fs::Metadata`].
 ///
index 3c2c063ca41eea7d6cfe6ada228b75c5d8306464..93270efea2b68340319d43330c370b824045861b 100644 (file)
@@ -8,8 +8,8 @@
                               definitions")]
 #![allow(deprecated)]
 
-use os::raw::c_long;
-use os::unix::raw::{uid_t, gid_t};
+use crate::os::raw::c_long;
+use crate::os::unix::raw::{uid_t, gid_t};
 
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64;
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64;
index daeac7107a56c6f72463fafc398a7d8ada36112f..6a16414c1417e067501edeae16ade9b181c4c38d 100644 (file)
@@ -2,21 +2,21 @@
 
 #![stable(feature = "std_panic", since = "1.9.0")]
 
-use any::Any;
-use cell::UnsafeCell;
-use fmt;
-use future::Future;
-use pin::Pin;
-use ops::{Deref, DerefMut};
-use panicking;
-use ptr::{Unique, NonNull};
-use rc::Rc;
-use sync::{Arc, Mutex, RwLock, atomic};
-use task::{Waker, Poll};
-use thread::Result;
+use crate::any::Any;
+use crate::cell::UnsafeCell;
+use crate::fmt;
+use crate::future::Future;
+use crate::pin::Pin;
+use crate::ops::{Deref, DerefMut};
+use crate::panicking;
+use crate::ptr::{Unique, NonNull};
+use crate::rc::Rc;
+use crate::sync::{Arc, Mutex, RwLock, atomic};
+use crate::task::{Waker, Poll};
+use crate::thread::Result;
 
 #[stable(feature = "panic_hooks", since = "1.10.0")]
-pub use panicking::{take_hook, set_hook};
+pub use crate::panicking::{take_hook, set_hook};
 
 #[stable(feature = "panic_hooks", since = "1.10.0")]
 pub use core::panic::{PanicInfo, Location};
@@ -385,7 +385,7 @@ fn poll(self: Pin<&mut Self>, waker: &Waker) -> Poll<Self::Output> {
 #[stable(feature = "catch_unwind", since = "1.9.0")]
 pub fn catch_unwind<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> {
     unsafe {
-        panicking::try(f)
+        panicking::r#try(f)
     }
 }
 
index aaffc9bad45472a6861aacfd3477bd3df546b3a4..868b309686cf61e47086d729aa0af97c438ab096 100644 (file)
@@ -8,22 +8,22 @@
 //! * Shims around "try"
 
 use core::panic::BoxMeUp;
-
-use io::prelude::*;
-
-use any::Any;
-use cell::RefCell;
 use core::panic::{PanicInfo, Location};
-use fmt;
-use intrinsics;
-use mem;
-use ptr;
-use raw;
-use sys::stdio::panic_output;
-use sys_common::rwlock::RWLock;
-use sys_common::thread_info;
-use sys_common::util;
-use thread;
+
+use crate::io::prelude::*;
+
+use crate::any::Any;
+use crate::cell::RefCell;
+use crate::fmt;
+use crate::intrinsics;
+use crate::mem;
+use crate::ptr;
+use crate::raw;
+use crate::sys::stdio::panic_output;
+use crate::sys_common::rwlock::RWLock;
+use crate::sys_common::thread_info;
+use crate::sys_common::util;
+use crate::thread;
 
 thread_local! {
     pub static LOCAL_STDERR: RefCell<Option<Box<dyn Write + Send>>> = {
@@ -159,7 +159,7 @@ pub fn take_hook() -> Box<dyn Fn(&PanicInfo) + 'static + Sync + Send> {
 
 fn default_hook(info: &PanicInfo) {
     #[cfg(feature = "backtrace")]
-    use sys_common::backtrace;
+    use crate::sys_common::backtrace;
 
     // If this is a double panic, make sure that we print a backtrace
     // for this panic. Otherwise only print it if logging is enabled.
@@ -186,13 +186,13 @@ fn default_hook(info: &PanicInfo) {
     let thread = thread_info::current_thread();
     let name = thread.as_ref().and_then(|t| t.name()).unwrap_or("<unnamed>");
 
-    let write = |err: &mut dyn (::io::Write)| {
+    let write = |err: &mut dyn crate::io::Write| {
         let _ = writeln!(err, "thread '{}' panicked at '{}', {}",
                          name, msg, location);
 
         #[cfg(feature = "backtrace")]
         {
-            use sync::atomic::{AtomicBool, Ordering};
+            use crate::sync::atomic::{AtomicBool, Ordering};
 
             static FIRST_PANIC: AtomicBool = AtomicBool::new(true);
 
@@ -221,7 +221,7 @@ fn default_hook(info: &PanicInfo) {
 #[doc(hidden)]
 #[unstable(feature = "update_panic_count", issue = "0")]
 pub fn update_panic_count(amt: isize) -> usize {
-    use cell::Cell;
+    use crate::cell::Cell;
     thread_local! { static PANIC_COUNT: Cell<usize> = Cell::new(0) }
 
     PANIC_COUNT.with(|c| {
@@ -235,7 +235,7 @@ pub fn update_panic_count(amt: isize) -> usize {
 pub use realstd::rt::update_panic_count;
 
 /// Invoke a closure, capturing the cause of an unwinding panic if one occurs.
-pub unsafe fn try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>> {
+pub unsafe fn r#try<R, F: FnOnce() -> R>(f: F) -> Result<R, Box<dyn Any + Send>> {
     #[allow(unions_with_drop_fields)]
     union Data<F, R> {
         f: F,
@@ -352,7 +352,7 @@ fn new(inner: &'a fmt::Arguments<'a>) -> PanicPayload<'a> {
         }
 
         fn fill(&mut self) -> &mut String {
-            use fmt::Write;
+            use crate::fmt::Write;
 
             let inner = self.inner;
             self.string.get_or_insert_with(|| {
index 9f91a9f89eb766013174ba2d7ad8e6b0d9693213..858a5778b8161f593a9fbc22d3728daeb41a7e67 100644 (file)
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
-use borrow::{Borrow, Cow};
-use cmp;
-use error::Error;
-use fmt;
-use fs;
-use hash::{Hash, Hasher};
-use io;
-use iter::{self, FusedIterator};
-use ops::{self, Deref};
-use rc::Rc;
-use str::FromStr;
-use sync::Arc;
-
-use ffi::{OsStr, OsString};
-
-use sys::path::{is_sep_byte, is_verbatim_sep, MAIN_SEP_STR, parse_prefix};
+use crate::borrow::{Borrow, Cow};
+use crate::cmp;
+use crate::error::Error;
+use crate::fmt;
+use crate::fs;
+use crate::hash::{Hash, Hasher};
+use crate::io;
+use crate::iter::{self, FusedIterator};
+use crate::ops::{self, Deref};
+use crate::rc::Rc;
+use crate::str::FromStr;
+use crate::sync::Arc;
+
+use crate::ffi::{OsStr, OsString};
+
+use crate::sys::path::{is_sep_byte, is_verbatim_sep, MAIN_SEP_STR, parse_prefix};
 
 ////////////////////////////////////////////////////////////////////////////////
 // GENERAL NOTES
@@ -279,7 +279,7 @@ pub fn is_separator(c: char) -> bool {
 ///
 /// For example, `/` on Unix and `\` on Windows.
 #[stable(feature = "rust1", since = "1.0.0")]
-pub const MAIN_SEPARATOR: char = ::sys::path::MAIN_SEP;
+pub const MAIN_SEPARATOR: char = crate::sys::path::MAIN_SEP;
 
 ////////////////////////////////////////////////////////////////////////////////
 // Misc helpers
@@ -2819,8 +2819,8 @@ fn description(&self) -> &str { "prefix not found" }
 mod tests {
     use super::*;
 
-    use rc::Rc;
-    use sync::Arc;
+    use crate::rc::Rc;
+    use crate::sync::Arc;
 
     macro_rules! t(
         ($path:expr, iter: $iter:expr) => (
@@ -2907,7 +2907,7 @@ macro_rules! t(
 
     #[test]
     fn into() {
-        use borrow::Cow;
+        use crate::borrow::Cow;
 
         let static_path = Path::new("/home/foo");
         let static_cow_path: Cow<'static, Path> = static_path.into();
@@ -4007,7 +4007,7 @@ macro_rules! tfe(
 
     #[test]
     fn test_eq_receivers() {
-        use borrow::Cow;
+        use crate::borrow::Cow;
 
         let borrowed: &Path = Path::new("foo/bar");
         let mut owned: PathBuf = PathBuf::new();
@@ -4032,8 +4032,8 @@ macro_rules! t {
 
     #[test]
     pub fn test_compare() {
-        use hash::{Hash, Hasher};
-        use collections::hash_map::DefaultHasher;
+        use crate::hash::{Hash, Hasher};
+        use crate::collections::hash_map::DefaultHasher;
 
         fn hash<T: Hash>(t: T) -> u64 {
             let mut s = DefaultHasher::new();
index 3001c899f6202ff4b4bb77de950e29ffdaa86331..ce1e8e3319cf8b4884d940151446abccb2251726 100644 (file)
@@ -9,41 +9,41 @@
 // Re-exported core operators
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)]
-pub use marker::{Copy, Send, Sized, Sync, Unpin};
+pub use crate::marker::{Copy, Send, Sized, Sync, Unpin};
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)]
-pub use ops::{Drop, Fn, FnMut, FnOnce};
+pub use crate::ops::{Drop, Fn, FnMut, FnOnce};
 
 // Re-exported functions
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)]
-pub use mem::drop;
+pub use crate::mem::drop;
 
 // Re-exported types and traits
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)]
-pub use clone::Clone;
+pub use crate::clone::Clone;
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)]
-pub use cmp::{PartialEq, PartialOrd, Eq, Ord};
+pub use crate::cmp::{PartialEq, PartialOrd, Eq, Ord};
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)]
-pub use convert::{AsRef, AsMut, Into, From};
+pub use crate::convert::{AsRef, AsMut, Into, From};
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)]
-pub use default::Default;
+pub use crate::default::Default;
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)]
-pub use iter::{Iterator, Extend, IntoIterator};
+pub use crate::iter::{Iterator, Extend, IntoIterator};
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)]
-pub use iter::{DoubleEndedIterator, ExactSizeIterator};
+pub use crate::iter::{DoubleEndedIterator, ExactSizeIterator};
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)]
-pub use option::Option::{self, Some, None};
+pub use crate::option::Option::{self, Some, None};
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)]
-pub use result::Result::{self, Ok, Err};
+pub use crate::result::Result::{self, Ok, Err};
 
 
 // The file so far is equivalent to src/libcore/prelude/v1.rs,
 
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)]
-pub use boxed::Box;
+pub use crate::boxed::Box;
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)]
-pub use borrow::ToOwned;
+pub use crate::borrow::ToOwned;
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)]
-pub use slice::SliceConcatExt;
+pub use crate::slice::SliceConcatExt;
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)]
-pub use string::{String, ToString};
+pub use crate::string::{String, ToString};
 #[stable(feature = "rust1", since = "1.0.0")]
 #[doc(no_inline)]
-pub use vec::Vec;
+pub use crate::vec::Vec;
index a2ef85016d8a28151c08c2234d114ed734746240..568400093440c14fff09248ac6e5c7f034194028 100644 (file)
 
 #![stable(feature = "process", since = "1.0.0")]
 
-use io::prelude::*;
-
-use ffi::OsStr;
-use fmt;
-use fs;
-use io::{self, Initializer};
-use path::Path;
-use str;
-use sys::pipe::{read2, AnonPipe};
-use sys::process as imp;
-use sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
+use crate::io::prelude::*;
+
+use crate::ffi::OsStr;
+use crate::fmt;
+use crate::fs;
+use crate::io::{self, Initializer};
+use crate::path::Path;
+use crate::str;
+use crate::sys::pipe::{read2, AnonPipe};
+use crate::sys::process as imp;
+use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
 
 /// Representation of a running or exited child process.
 ///
@@ -1015,7 +1015,7 @@ impl From<ChildStdin> for Stdio {
     ///
     /// `ChildStdin` will be converted to `Stdio` using `Stdio::from` under the hood.
     ///
-    /// ```rust
+    /// ```rust,no_run
     /// use std::process::{Command, Stdio};
     ///
     /// let reverse = Command::new("rev")
@@ -1044,7 +1044,7 @@ impl From<ChildStdout> for Stdio {
     ///
     /// `ChildStdout` will be converted to `Stdio` using `Stdio::from` under the hood.
     ///
-    /// ```rust
+    /// ```rust,no_run
     /// use std::process::{Command, Stdio};
     ///
     /// let hello = Command::new("echo")
@@ -1481,8 +1481,8 @@ pub fn wait_with_output(mut self) -> io::Result<Output> {
 /// [platform-specific behavior]: #platform-specific-behavior
 #[stable(feature = "rust1", since = "1.0.0")]
 pub fn exit(code: i32) -> ! {
-    ::sys_common::cleanup();
-    ::sys::os::exit(code)
+    crate::sys_common::cleanup();
+    crate::sys::os::exit(code)
 }
 
 /// Terminates the process in an abnormal fashion.
@@ -1543,7 +1543,7 @@ pub fn exit(code: i32) -> ! {
 /// [panic hook]: ../../std/panic/fn.set_hook.html
 #[stable(feature = "process_abort", since = "1.17.0")]
 pub fn abort() -> ! {
-    unsafe { ::sys::abort_internal() };
+    unsafe { crate::sys::abort_internal() };
 }
 
 /// Returns the OS-assigned process identifier associated with this process.
@@ -1561,7 +1561,7 @@ pub fn abort() -> ! {
 ///
 #[stable(feature = "getpid", since = "1.26.0")]
 pub fn id() -> u32 {
-    ::sys::os::getpid()
+    crate::sys::os::getpid()
 }
 
 /// A trait for implementing arbitrary return types in the `main` function.
@@ -1623,10 +1623,10 @@ fn report(self) -> i32 {
 
 #[cfg(all(test, not(any(target_os = "cloudabi", target_os = "emscripten"))))]
 mod tests {
-    use io::prelude::*;
+    use crate::io::prelude::*;
 
-    use io::ErrorKind;
-    use str;
+    use crate::io::ErrorKind;
+    use crate::str;
     use super::{Command, Output, Stdio};
 
     // FIXME(#10380) these tests should not all be ignored on android.
@@ -1671,7 +1671,7 @@ fn exit_reported_right() {
     #[cfg(unix)]
     #[cfg_attr(target_os = "android", ignore)]
     fn signal_reported_right() {
-        use os::unix::process::ExitStatusExt;
+        use crate::os::unix::process::ExitStatusExt;
 
         let mut p = Command::new("/bin/sh")
                             .arg("-c").arg("read a")
@@ -1741,8 +1741,8 @@ fn stdin_works() {
     #[cfg_attr(target_os = "android", ignore)]
     #[cfg(unix)]
     fn uid_works() {
-        use os::unix::prelude::*;
-        use libc;
+        use crate::os::unix::prelude::*;
+
         let mut p = Command::new("/bin/sh")
                             .arg("-c").arg("true")
                             .uid(unsafe { libc::getuid() })
@@ -1755,8 +1755,7 @@ fn uid_works() {
     #[cfg_attr(target_os = "android", ignore)]
     #[cfg(unix)]
     fn uid_to_root_fails() {
-        use os::unix::prelude::*;
-        use libc;
+        use crate::os::unix::prelude::*;
 
         // if we're already root, this isn't a valid test. Most of the bots run
         // as non-root though (android is an exception).
@@ -1881,7 +1880,7 @@ pub fn env_cmd() -> Command {
 
     #[test]
     fn test_override_env() {
-        use env;
+        use crate::env;
 
         // In some build environments (such as chrooted Nix builds), `env` can
         // only be found in the explicitly-provided PATH env variable, not in
@@ -1910,7 +1909,7 @@ fn test_add_to_env() {
 
     #[test]
     fn test_capture_env_at_spawn() {
-        use env;
+        use crate::env;
 
         let mut cmd = env_cmd();
         cmd.env("RUN_TEST_NEW_ENV1", "123");
@@ -1985,8 +1984,8 @@ fn test_interior_nul_in_env_value_is_error() {
     #[test]
     #[cfg(windows)]
     fn test_creation_flags() {
-        use os::windows::process::CommandExt;
-        use sys::c::{BOOL, DWORD, INFINITE};
+        use crate::os::windows::process::CommandExt;
+        use crate::sys::c::{BOOL, DWORD, INFINITE};
         #[repr(C, packed)]
         struct DEBUG_EVENT {
             pub event_code: DWORD,
index 5ddb66b1897ee23013ca15540f864049c6121886..cf45eb0daba3988b5626730c3988ca8a732dcd80 100644 (file)
 
 
 // Re-export some of our utilities which are expected by other crates.
-pub use panicking::{begin_panic, begin_panic_fmt, update_panic_count};
+pub use crate::panicking::{begin_panic, begin_panic_fmt, update_panic_count};
 
 // To reduce the generated code of the new `lang_start`, this function is doing
 // the real work.
 #[cfg(not(test))]
-fn lang_start_internal(main: &(dyn Fn() -> i32 + Sync + ::panic::RefUnwindSafe),
+fn lang_start_internal(main: &(dyn Fn() -> i32 + Sync + crate::panic::RefUnwindSafe),
                        argc: isize, argv: *const *const u8) -> isize {
-    use panic;
-    use sys;
-    use sys_common;
-    use sys_common::thread_info;
-    use thread::Thread;
+    use crate::panic;
+    use crate::sys;
+    use crate::sys_common;
+    use crate::sys_common::thread_info;
+    use crate::thread::Thread;
 
     sys::init();
 
@@ -46,7 +46,7 @@ fn lang_start_internal(main: &(dyn Fn() -> i32 + Sync + ::panic::RefUnwindSafe),
         // Let's run some code!
         #[cfg(feature = "backtrace")]
         let exit_code = panic::catch_unwind(|| {
-            ::sys_common::backtrace::__rust_begin_short_backtrace(move || main())
+            sys_common::backtrace::__rust_begin_short_backtrace(move || main())
         });
         #[cfg(not(feature = "backtrace"))]
         let exit_code = panic::catch_unwind(move || main());
@@ -58,7 +58,7 @@ fn lang_start_internal(main: &(dyn Fn() -> i32 + Sync + ::panic::RefUnwindSafe),
 
 #[cfg(not(test))]
 #[lang = "start"]
-fn lang_start<T: ::process::Termination + 'static>
+fn lang_start<T: crate::process::Termination + 'static>
     (main: fn() -> T, argc: isize, argv: *const *const u8) -> isize
 {
     lang_start_internal(&move || main().report(), argc, argv)
index bc2e14d436a994cc388b536f9d00ebeb459511d3..a4205daba8b6e53f38fbaf99c31fd326aab492d9 100644 (file)
@@ -1,5 +1,5 @@
-use fmt;
-use sync::{Mutex, Condvar};
+use crate::fmt;
+use crate::sync::{Mutex, Condvar};
 
 /// A barrier enables multiple threads to synchronize the beginning
 /// of some computation.
@@ -181,9 +181,9 @@ pub fn is_leader(&self) -> bool { self.0 }
 
 #[cfg(test)]
 mod tests {
-    use sync::{Arc, Barrier};
-    use sync::mpsc::{channel, TryRecvError};
-    use thread;
+    use crate::sync::{Arc, Barrier};
+    use crate::sync::mpsc::{channel, TryRecvError};
+    use crate::thread;
 
     #[test]
     #[cfg_attr(target_os = "emscripten", ignore)]
index 036aff090ead992357d60fd4af7db161ddf7e237..5ebb61754e1ff75fb2b581104d1c3587856430cb 100644 (file)
@@ -1,10 +1,10 @@
-use fmt;
-use sync::atomic::{AtomicUsize, Ordering};
-use sync::{mutex, MutexGuard, PoisonError};
-use sys_common::condvar as sys;
-use sys_common::mutex as sys_mutex;
-use sys_common::poison::{self, LockResult};
-use time::{Duration, Instant};
+use crate::fmt;
+use crate::sync::atomic::{AtomicUsize, Ordering};
+use crate::sync::{mutex, MutexGuard, PoisonError};
+use crate::sys_common::condvar as sys;
+use crate::sys_common::mutex as sys_mutex;
+use crate::sys_common::poison::{self, LockResult};
+use crate::time::{Duration, Instant};
 
 /// A type indicating whether a timed wait on a condition variable returned
 /// due to a time out or not.
@@ -612,12 +612,12 @@ fn drop(&mut self) {
 #[cfg(test)]
 mod tests {
     /// #![feature(wait_until)]
-    use sync::mpsc::channel;
-    use sync::{Condvar, Mutex, Arc};
-    use sync::atomic::{AtomicBool, Ordering};
-    use thread;
-    use time::Duration;
-    use u64;
+    use crate::sync::mpsc::channel;
+    use crate::sync::{Condvar, Mutex, Arc};
+    use crate::sync::atomic::{AtomicBool, Ordering};
+    use crate::thread;
+    use crate::time::Duration;
+    use crate::u64;
 
     #[test]
     fn smoke() {
index 3d11af7dc10e981f00d6b4111b1e31ab9bc09402..809ee8826981b21a65ff5705e35cda0751725862 100644 (file)
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use self::once::{Once, OnceState, ONCE_INIT};
 #[stable(feature = "rust1", since = "1.0.0")]
-pub use sys_common::poison::{PoisonError, TryLockError, TryLockResult, LockResult};
+pub use crate::sys_common::poison::{PoisonError, TryLockError, TryLockResult, LockResult};
 #[stable(feature = "rust1", since = "1.0.0")]
 pub use self::rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard};
 
index eaf09a16756b272348d956a21853ef8192c85ee9..6eacfaec25358fde2b83e6cd5c17175ffac63c17 100644 (file)
@@ -1,10 +1,10 @@
 //! Generic support for building blocking abstractions.
 
-use thread::{self, Thread};
-use sync::atomic::{AtomicBool, Ordering};
-use sync::Arc;
-use mem;
-use time::Instant;
+use crate::thread::{self, Thread};
+use crate::sync::atomic::{AtomicBool, Ordering};
+use crate::sync::Arc;
+use crate::mem;
+use crate::time::Instant;
 
 struct Inner {
     thread: Thread,
index fb1177e03506ce536d69630f34a5c02f82abd238..b14a9e5d61bd93c751c2ed38bec0e01f45feba5e 100644 (file)
@@ -1,4 +1,4 @@
-use ops::{Deref, DerefMut};
+use crate::ops::{Deref, DerefMut};
 
 #[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
 #[repr(align(64))]
index 5273345c6b4fd1a90e091d176cb7781c5485e347..90c5c50c23b9cc3304d78e434be7aba27f9191db 100644 (file)
 // And now that you've seen all the races that I found and attempted to fix,
 // here's the code for you to find some more!
 
-use sync::Arc;
-use error;
-use fmt;
-use mem;
-use cell::UnsafeCell;
-use time::{Duration, Instant};
+use crate::sync::Arc;
+use crate::error;
+use crate::fmt;
+use crate::mem;
+use crate::cell::UnsafeCell;
+use crate::time::{Duration, Instant};
 
 #[unstable(feature = "mpsc_select", issue = "27800")]
 pub use self::select::{Select, Handle};
@@ -1822,10 +1822,10 @@ fn from(err: RecvError) -> RecvTimeoutError {
 
 #[cfg(all(test, not(target_os = "emscripten")))]
 mod tests {
-    use env;
     use super::*;
-    use thread;
-    use time::{Duration, Instant};
+    use crate::env;
+    use crate::thread;
+    use crate::time::{Duration, Instant};
 
     pub fn stress_factor() -> usize {
         match env::var("RUST_TEST_STRESS") {
@@ -2514,10 +2514,10 @@ fn issue_32114() {
 
 #[cfg(all(test, not(target_os = "emscripten")))]
 mod sync_tests {
-    use env;
-    use thread;
     use super::*;
-    use time::Duration;
+    use crate::env;
+    use crate::thread;
+    use crate::time::Duration;
 
     pub fn stress_factor() -> usize {
         match env::var("RUST_TEST_STRESS") {
index 794d11f1eac99cfb65405362a497b8fbce6bc06f..8f5681b97f44d87370e116952d6f1634fc9d5e54 100644 (file)
@@ -15,8 +15,9 @@
 
 use core::ptr;
 use core::cell::UnsafeCell;
-use boxed::Box;
-use sync::atomic::{AtomicPtr, Ordering};
+
+use crate::boxed::Box;
+use crate::sync::atomic::{AtomicPtr, Ordering};
 
 /// A result of the `pop` function.
 pub enum PopResult<T> {
@@ -120,10 +121,10 @@ fn drop(&mut self) {
 
 #[cfg(all(test, not(target_os = "emscripten")))]
 mod tests {
-    use sync::mpsc::channel;
     use super::{Queue, Data, Empty, Inconsistent};
-    use sync::Arc;
-    use thread;
+    use crate::sync::mpsc::channel;
+    use crate::sync::Arc;
+    use crate::thread;
 
     #[test]
     fn test_full() {
index 36928c428e331a2200f064d47da9fd9aacfd994b..5c516d5de0f176ed735d8e2cc7a6de488d5e83c2 100644 (file)
 pub use self::SelectionResult::*;
 use self::MyUpgrade::*;
 
-use sync::mpsc::Receiver;
-use sync::mpsc::blocking::{self, SignalToken};
-use cell::UnsafeCell;
-use ptr;
-use sync::atomic::{AtomicUsize, Ordering};
-use time::Instant;
+use crate::sync::mpsc::Receiver;
+use crate::sync::mpsc::blocking::{self, SignalToken};
+use crate::cell::UnsafeCell;
+use crate::ptr;
+use crate::sync::atomic::{AtomicUsize, Ordering};
+use crate::time::Instant;
 
 // Various states you can find a port in.
 const EMPTY: usize = 0;          // initial state: no data, no blocked receiver
index 8591b55dc58ee9fd909f77e7f9381f0c8bc2d41e..19c949086454548e99997e2347512d08c1288db6 100644 (file)
 #![rustc_deprecated(since = "1.32.0",
                     reason = "channel selection will be removed in a future release")]
 
-
-use fmt;
-
 use core::cell::{Cell, UnsafeCell};
 use core::marker;
 use core::ptr;
 use core::usize;
 
-use sync::mpsc::{Receiver, RecvError};
-use sync::mpsc::blocking::{self, SignalToken};
+use crate::fmt;
+use crate::sync::mpsc::{Receiver, RecvError};
+use crate::sync::mpsc::blocking::{self, SignalToken};
 
 /// The "receiver set" of the select interface. This structure is used to manage
 /// a set of receivers which are being selected over.
index be048511caaec9a6e2773c4fcea3c57aaf8c7cc1..18d93462c78db4b6d789eac898c40d2aea631784 100644 (file)
@@ -2,8 +2,8 @@
 
 /// This file exists to hack around https://github.com/rust-lang/rust/issues/47238
 
-use thread;
-use sync::mpsc::*;
+use crate::thread;
+use crate::sync::mpsc::*;
 
 // Don't use the libstd version so we can pull in the right Select structure
 // (std::comm points at the wrong one)
index 3da73ac0b822ea4c256b2ec1067e729c47cc2f5e..6a5d861f0e9cdf749b7a5369276daf14d530cc9a 100644 (file)
 use core::intrinsics::abort;
 use core::isize;
 
-use cell::UnsafeCell;
-use ptr;
-use sync::atomic::{AtomicUsize, AtomicIsize, AtomicBool, Ordering};
-use sync::mpsc::blocking::{self, SignalToken};
-use sync::mpsc::mpsc_queue as mpsc;
-use sync::mpsc::select::StartResult::*;
-use sync::mpsc::select::StartResult;
-use sync::{Mutex, MutexGuard};
-use thread;
-use time::Instant;
+use crate::cell::UnsafeCell;
+use crate::ptr;
+use crate::sync::atomic::{AtomicUsize, AtomicIsize, AtomicBool, Ordering};
+use crate::sync::mpsc::blocking::{self, SignalToken};
+use crate::sync::mpsc::mpsc_queue as mpsc;
+use crate::sync::mpsc::select::StartResult::*;
+use crate::sync::mpsc::select::StartResult;
+use crate::sync::{Mutex, MutexGuard};
+use crate::thread;
+use crate::time::Instant;
 
 const DISCONNECTED: isize = isize::MIN;
 const FUDGE: isize = 1024;
index b43ccf074a42758dff624dac8ad102e2921ba6a2..0edb1c24e801675adcabb5d86d907a16f1bd94a0 100644 (file)
@@ -6,11 +6,11 @@
 
 // http://www.1024cores.net/home/lock-free-algorithms/queues/unbounded-spsc-queue
 
-use boxed::Box;
 use core::ptr;
 use core::cell::UnsafeCell;
 
-use sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
+use crate::boxed::Box;
+use crate::sync::atomic::{AtomicPtr, AtomicUsize, Ordering};
 
 use super::cache_aligned::CacheAligned;
 
@@ -233,10 +233,10 @@ fn drop(&mut self) {
 
 #[cfg(all(test, not(target_os = "emscripten")))]
 mod tests {
-    use sync::Arc;
     use super::Queue;
-    use thread;
-    use sync::mpsc::channel;
+    use crate::sync::Arc;
+    use crate::thread;
+    use crate::sync::mpsc::channel;
 
     #[test]
     fn smoke() {
index 5c68930bf473028bdfb5bbfe03dd84dba08ce74d..7ae6f68b514595d305bb993f1a73896f622a4f49 100644 (file)
 pub use self::SelectionResult::*;
 use self::Message::*;
 
-use cell::UnsafeCell;
 use core::cmp;
 use core::isize;
-use ptr;
-use thread;
-use time::Instant;
-
-use sync::atomic::{AtomicIsize, AtomicUsize, Ordering, AtomicBool};
-use sync::mpsc::Receiver;
-use sync::mpsc::blocking::{self, SignalToken};
-use sync::mpsc::spsc_queue as spsc;
+
+use crate::cell::UnsafeCell;
+use crate::ptr;
+use crate::thread;
+use crate::time::Instant;
+
+use crate::sync::atomic::{AtomicIsize, AtomicUsize, Ordering, AtomicBool};
+use crate::sync::mpsc::Receiver;
+use crate::sync::mpsc::blocking::{self, SignalToken};
+use crate::sync::mpsc::spsc_queue as spsc;
 
 const DISCONNECTED: isize = isize::MIN;
 #[cfg(test)]
index bce42bc69cda46e205ec8010eb76c5bd8648c5cf..485234a9495f3721d838b54bc7f1503ea3669665 100644 (file)
 use core::mem;
 use core::ptr;
 
-use sync::atomic::{Ordering, AtomicUsize};
-use sync::mpsc::blocking::{self, WaitToken, SignalToken};
-use sync::mpsc::select::StartResult::{self, Installed, Abort};
-use sync::{Mutex, MutexGuard};
-use time::Instant;
+use crate::sync::atomic::{Ordering, AtomicUsize};
+use crate::sync::mpsc::blocking::{self, WaitToken, SignalToken};
+use crate::sync::mpsc::select::StartResult::{self, Installed, Abort};
+use crate::sync::{Mutex, MutexGuard};
+use crate::time::Instant;
 
 const MAX_REFCOUNT: usize = (isize::MAX) as usize;
 
index 954867911a03198c3535a498d7ea7b6b3c0d22b9..6b812e65b7269fc2eeecd980357cc67ee96da289 100644 (file)
@@ -1,10 +1,10 @@
-use cell::UnsafeCell;
-use fmt;
-use mem;
-use ops::{Deref, DerefMut};
-use ptr;
-use sys_common::mutex as sys;
-use sys_common::poison::{self, TryLockError, TryLockResult, LockResult};
+use crate::cell::UnsafeCell;
+use crate::fmt;
+use crate::mem;
+use crate::ops::{Deref, DerefMut};
+use crate::ptr;
+use crate::sys_common::mutex as sys;
+use crate::sys_common::poison::{self, TryLockError, TryLockResult, LockResult};
 
 /// A mutual exclusion primitive useful for protecting shared data
 ///
@@ -471,10 +471,10 @@ pub fn guard_poison<'a, T: ?Sized>(guard: &MutexGuard<'a, T>) -> &'a poison::Fla
 
 #[cfg(all(test, not(target_os = "emscripten")))]
 mod tests {
-    use sync::mpsc::channel;
-    use sync::{Arc, Mutex, Condvar};
-    use sync::atomic::{AtomicUsize, Ordering};
-    use thread;
+    use crate::sync::mpsc::channel;
+    use crate::sync::{Arc, Mutex, Condvar};
+    use crate::sync::atomic::{AtomicUsize, Ordering};
+    use crate::thread;
 
     struct Packet<T>(Arc<(Mutex<T>, Condvar)>);
 
index e207d0170d7b8cf4a6bcb5823a61872b5bd4e952..a036c2666625ca23f561de0c7511b0210a6a34bd 100644 (file)
 // You'll find a few more details in the implementation, but that's the gist of
 // it!
 
-use fmt;
-use marker;
-use ptr;
-use sync::atomic::{AtomicUsize, AtomicBool, Ordering};
-use thread::{self, Thread};
+use crate::fmt;
+use crate::marker;
+use crate::ptr;
+use crate::sync::atomic::{AtomicUsize, AtomicBool, Ordering};
+use crate::thread::{self, Thread};
 
 /// A synchronization primitive which can be used to run a one-time global
 /// initialization. Useful for one-time initialization for FFI or related
@@ -514,9 +514,9 @@ pub fn poisoned(&self) -> bool {
 
 #[cfg(all(test, not(target_os = "emscripten")))]
 mod tests {
-    use panic;
-    use sync::mpsc::channel;
-    use thread;
+    use crate::panic;
+    use crate::sync::mpsc::channel;
+    use crate::thread;
     use super::Once;
 
     #[test]
index 7f3cb4f72c7b5baa274dd999ea19c6e180cb5a14..0be83c76d6259c7ed475dd7436e80faf0e2b5e54 100644 (file)
@@ -1,10 +1,10 @@
-use cell::UnsafeCell;
-use fmt;
-use mem;
-use ops::{Deref, DerefMut};
-use ptr;
-use sys_common::poison::{self, LockResult, TryLockError, TryLockResult};
-use sys_common::rwlock as sys;
+use crate::cell::UnsafeCell;
+use crate::fmt;
+use crate::mem;
+use crate::ops::{Deref, DerefMut};
+use crate::ptr;
+use crate::sys_common::poison::{self, LockResult, TryLockError, TryLockResult};
+use crate::sys_common::rwlock as sys;
 
 /// A reader-writer lock
 ///
@@ -554,10 +554,10 @@ fn drop(&mut self) {
 #[cfg(all(test, not(target_os = "emscripten")))]
 mod tests {
     use rand::{self, Rng};
-    use sync::mpsc::channel;
-    use thread;
-    use sync::{Arc, RwLock, TryLockError};
-    use sync::atomic::{AtomicUsize, Ordering};
+    use crate::sync::mpsc::channel;
+    use crate::thread;
+    use crate::sync::{Arc, RwLock, TryLockError};
+    use crate::sync::atomic::{AtomicUsize, Ordering};
 
     #[derive(Eq, PartialEq, Debug)]
     struct NonCopy(i32);
index f764cc1df5a5c2384dbb2e756ca8603fe9feb79e..306936213ed119cf9c34173946bd07a7cb73da69 100644 (file)
@@ -25,8 +25,7 @@
 // ignore-license
 
 #[cfg(feature = "bitflags")]
-#[macro_use]
-extern crate bitflags;
+use bitflags::bitflags;
 
 // Minimal implementation of bitflags! in case we can't depend on the bitflags
 // crate. Only implements `bits()` and a `from_bits_truncate()` that doesn't
index 83d45b3547bc2e80ef04890f63f8ee6f06f1c0a3..2307e2167c5c11e32c177c7c0996a475273f7f43 100644 (file)
@@ -1090,10 +1090,10 @@ pub union auxv_union {
 #[test]
 #[cfg(target_pointer_width = "32")]
 fn auxv_layout_test_32() {
-  assert_eq!(::core::mem::size_of::<auxv>(), 8);
-  assert_eq!(::core::mem::align_of::<auxv>(), 4);
+  assert_eq!(core::mem::size_of::<auxv>(), 8);
+  assert_eq!(core::mem::align_of::<auxv>(), 4);
   unsafe {
-    let obj: auxv = ::core::mem::uninitialized();
+    let obj: auxv = core::mem::uninitialized();
     let base = &obj as *const _ as usize;
     assert_eq!(&obj.a_type as *const _ as usize - base, 0);
     assert_eq!(&obj.union.a_val as *const _ as usize - base, 4);
@@ -1103,10 +1103,10 @@ fn auxv_layout_test_32() {
 #[test]
 #[cfg(target_pointer_width = "64")]
 fn auxv_layout_test_64() {
-  assert_eq!(::core::mem::size_of::<auxv>(), 16);
-  assert_eq!(::core::mem::align_of::<auxv>(), 8);
+  assert_eq!(core::mem::size_of::<auxv>(), 16);
+  assert_eq!(core::mem::align_of::<auxv>(), 8);
   unsafe {
-    let obj: auxv = ::core::mem::uninitialized();
+    let obj: auxv = core::mem::uninitialized();
     let base = &obj as *const _ as usize;
     assert_eq!(&obj.a_type as *const _ as usize - base, 0);
     assert_eq!(&obj.union.a_val as *const _ as usize - base, 8);
@@ -1124,10 +1124,10 @@ pub struct ciovec {
 #[test]
 #[cfg(target_pointer_width = "32")]
 fn ciovec_layout_test_32() {
-  assert_eq!(::core::mem::size_of::<ciovec>(), 8);
-  assert_eq!(::core::mem::align_of::<ciovec>(), 4);
+  assert_eq!(core::mem::size_of::<ciovec>(), 8);
+  assert_eq!(core::mem::align_of::<ciovec>(), 4);
   unsafe {
-    let obj: ciovec = ::core::mem::uninitialized();
+    let obj: ciovec = core::mem::uninitialized();
     let base = &obj as *const _ as usize;
     assert_eq!(&obj.buf.0 as *const _ as usize - base, 0);
     assert_eq!(&obj.buf.1 as *const _ as usize - base, 4);
@@ -1136,10 +1136,10 @@ fn ciovec_layout_test_32() {
 #[test]
 #[cfg(target_pointer_width = "64")]
 fn ciovec_layout_test_64() {
-  assert_eq!(::core::mem::size_of::<ciovec>(), 16);
-  assert_eq!(::core::mem::align_of::<ciovec>(), 8);
+  assert_eq!(core::mem::size_of::<ciovec>(), 16);
+  assert_eq!(core::mem::align_of::<ciovec>(), 8);
   unsafe {
-    let obj: ciovec = ::core::mem::uninitialized();
+    let obj: ciovec = core::mem::uninitialized();
     let base = &obj as *const _ as usize;
     assert_eq!(&obj.buf.0 as *const _ as usize - base, 0);
     assert_eq!(&obj.buf.1 as *const _ as usize - base, 8);
@@ -1164,10 +1164,10 @@ pub struct dirent {
 }
 #[test]
 fn dirent_layout_test() {
-  assert_eq!(::core::mem::size_of::<dirent>(), 24);
-  assert_eq!(::core::mem::align_of::<dirent>(), 8);
+  assert_eq!(core::mem::size_of::<dirent>(), 24);
+  assert_eq!(core::mem::align_of::<dirent>(), 8);
   unsafe {
-    let obj: dirent = ::core::mem::uninitialized();
+    let obj: dirent = core::mem::uninitialized();
     let base = &obj as *const _ as usize;
     assert_eq!(&obj.d_next as *const _ as usize - base, 0);
     assert_eq!(&obj.d_ino as *const _ as usize - base, 8);
@@ -1228,10 +1228,10 @@ pub struct event_proc_terminate {
 }
 #[test]
 fn event_layout_test() {
-  assert_eq!(::core::mem::size_of::<event>(), 32);
-  assert_eq!(::core::mem::align_of::<event>(), 8);
+  assert_eq!(core::mem::size_of::<event>(), 32);
+  assert_eq!(core::mem::align_of::<event>(), 8);
   unsafe {
-    let obj: event = ::core::mem::uninitialized();
+    let obj: event = core::mem::uninitialized();
     let base = &obj as *const _ as usize;
     assert_eq!(&obj.userdata as *const _ as usize - base, 0);
     assert_eq!(&obj.error as *const _ as usize - base, 8);
@@ -1262,10 +1262,10 @@ pub struct fdstat {
 }
 #[test]
 fn fdstat_layout_test() {
-  assert_eq!(::core::mem::size_of::<fdstat>(), 24);
-  assert_eq!(::core::mem::align_of::<fdstat>(), 8);
+  assert_eq!(core::mem::size_of::<fdstat>(), 24);
+  assert_eq!(core::mem::align_of::<fdstat>(), 8);
   unsafe {
-    let obj: fdstat = ::core::mem::uninitialized();
+    let obj: fdstat = core::mem::uninitialized();
     let base = &obj as *const _ as usize;
     assert_eq!(&obj.fs_filetype as *const _ as usize - base, 0);
     assert_eq!(&obj.fs_flags as *const _ as usize - base, 2);
@@ -1299,10 +1299,10 @@ pub struct filestat {
 }
 #[test]
 fn filestat_layout_test() {
-  assert_eq!(::core::mem::size_of::<filestat>(), 56);
-  assert_eq!(::core::mem::align_of::<filestat>(), 8);
+  assert_eq!(core::mem::size_of::<filestat>(), 56);
+  assert_eq!(core::mem::align_of::<filestat>(), 8);
   unsafe {
-    let obj: filestat = ::core::mem::uninitialized();
+    let obj: filestat = core::mem::uninitialized();
     let base = &obj as *const _ as usize;
     assert_eq!(&obj.st_dev as *const _ as usize - base, 0);
     assert_eq!(&obj.st_ino as *const _ as usize - base, 8);
@@ -1325,10 +1325,10 @@ pub struct iovec {
 #[test]
 #[cfg(target_pointer_width = "32")]
 fn iovec_layout_test_32() {
-  assert_eq!(::core::mem::size_of::<iovec>(), 8);
-  assert_eq!(::core::mem::align_of::<iovec>(), 4);
+  assert_eq!(core::mem::size_of::<iovec>(), 8);
+  assert_eq!(core::mem::align_of::<iovec>(), 4);
   unsafe {
-    let obj: iovec = ::core::mem::uninitialized();
+    let obj: iovec = core::mem::uninitialized();
     let base = &obj as *const _ as usize;
     assert_eq!(&obj.buf.0 as *const _ as usize - base, 0);
     assert_eq!(&obj.buf.1 as *const _ as usize - base, 4);
@@ -1337,10 +1337,10 @@ fn iovec_layout_test_32() {
 #[test]
 #[cfg(target_pointer_width = "64")]
 fn iovec_layout_test_64() {
-  assert_eq!(::core::mem::size_of::<iovec>(), 16);
-  assert_eq!(::core::mem::align_of::<iovec>(), 8);
+  assert_eq!(core::mem::size_of::<iovec>(), 16);
+  assert_eq!(core::mem::align_of::<iovec>(), 8);
   unsafe {
-    let obj: iovec = ::core::mem::uninitialized();
+    let obj: iovec = core::mem::uninitialized();
     let base = &obj as *const _ as usize;
     assert_eq!(&obj.buf.0 as *const _ as usize - base, 0);
     assert_eq!(&obj.buf.1 as *const _ as usize - base, 8);
@@ -1360,10 +1360,10 @@ pub struct lookup {
 }
 #[test]
 fn lookup_layout_test() {
-  assert_eq!(::core::mem::size_of::<lookup>(), 8);
-  assert_eq!(::core::mem::align_of::<lookup>(), 4);
+  assert_eq!(core::mem::size_of::<lookup>(), 8);
+  assert_eq!(core::mem::align_of::<lookup>(), 4);
   unsafe {
-    let obj: lookup = ::core::mem::uninitialized();
+    let obj: lookup = core::mem::uninitialized();
     let base = &obj as *const _ as usize;
     assert_eq!(&obj.fd as *const _ as usize - base, 0);
     assert_eq!(&obj.flags as *const _ as usize - base, 4);
@@ -1394,10 +1394,10 @@ pub struct recv_in {
 #[test]
 #[cfg(target_pointer_width = "32")]
 fn recv_in_layout_test_32() {
-  assert_eq!(::core::mem::size_of::<recv_in>(), 20);
-  assert_eq!(::core::mem::align_of::<recv_in>(), 4);
+  assert_eq!(core::mem::size_of::<recv_in>(), 20);
+  assert_eq!(core::mem::align_of::<recv_in>(), 4);
   unsafe {
-    let obj: recv_in = ::core::mem::uninitialized();
+    let obj: recv_in = core::mem::uninitialized();
     let base = &obj as *const _ as usize;
     assert_eq!(&obj.ri_data.0 as *const _ as usize - base, 0);
     assert_eq!(&obj.ri_data.1 as *const _ as usize - base, 4);
@@ -1409,10 +1409,10 @@ fn recv_in_layout_test_32() {
 #[test]
 #[cfg(target_pointer_width = "64")]
 fn recv_in_layout_test_64() {
-  assert_eq!(::core::mem::size_of::<recv_in>(), 40);
-  assert_eq!(::core::mem::align_of::<recv_in>(), 8);
+  assert_eq!(core::mem::size_of::<recv_in>(), 40);
+  assert_eq!(core::mem::align_of::<recv_in>(), 8);
   unsafe {
-    let obj: recv_in = ::core::mem::uninitialized();
+    let obj: recv_in = core::mem::uninitialized();
     let base = &obj as *const _ as usize;
     assert_eq!(&obj.ri_data.0 as *const _ as usize - base, 0);
     assert_eq!(&obj.ri_data.1 as *const _ as usize - base, 8);
@@ -1438,10 +1438,10 @@ pub struct recv_out {
 #[test]
 #[cfg(target_pointer_width = "32")]
 fn recv_out_layout_test_32() {
-  assert_eq!(::core::mem::size_of::<recv_out>(), 52);
-  assert_eq!(::core::mem::align_of::<recv_out>(), 4);
+  assert_eq!(core::mem::size_of::<recv_out>(), 52);
+  assert_eq!(core::mem::align_of::<recv_out>(), 4);
   unsafe {
-    let obj: recv_out = ::core::mem::uninitialized();
+    let obj: recv_out = core::mem::uninitialized();
     let base = &obj as *const _ as usize;
     assert_eq!(&obj.ro_datalen as *const _ as usize - base, 0);
     assert_eq!(&obj.ro_fdslen as *const _ as usize - base, 4);
@@ -1452,10 +1452,10 @@ fn recv_out_layout_test_32() {
 #[test]
 #[cfg(target_pointer_width = "64")]
 fn recv_out_layout_test_64() {
-  assert_eq!(::core::mem::size_of::<recv_out>(), 64);
-  assert_eq!(::core::mem::align_of::<recv_out>(), 8);
+  assert_eq!(core::mem::size_of::<recv_out>(), 64);
+  assert_eq!(core::mem::align_of::<recv_out>(), 8);
   unsafe {
-    let obj: recv_out = ::core::mem::uninitialized();
+    let obj: recv_out = core::mem::uninitialized();
     let base = &obj as *const _ as usize;
     assert_eq!(&obj.ro_datalen as *const _ as usize - base, 0);
     assert_eq!(&obj.ro_fdslen as *const _ as usize - base, 8);
@@ -1480,10 +1480,10 @@ pub struct send_in {
 #[test]
 #[cfg(target_pointer_width = "32")]
 fn send_in_layout_test_32() {
-  assert_eq!(::core::mem::size_of::<send_in>(), 20);
-  assert_eq!(::core::mem::align_of::<send_in>(), 4);
+  assert_eq!(core::mem::size_of::<send_in>(), 20);
+  assert_eq!(core::mem::align_of::<send_in>(), 4);
   unsafe {
-    let obj: send_in = ::core::mem::uninitialized();
+    let obj: send_in = core::mem::uninitialized();
     let base = &obj as *const _ as usize;
     assert_eq!(&obj.si_data.0 as *const _ as usize - base, 0);
     assert_eq!(&obj.si_data.1 as *const _ as usize - base, 4);
@@ -1495,10 +1495,10 @@ fn send_in_layout_test_32() {
 #[test]
 #[cfg(target_pointer_width = "64")]
 fn send_in_layout_test_64() {
-  assert_eq!(::core::mem::size_of::<send_in>(), 40);
-  assert_eq!(::core::mem::align_of::<send_in>(), 8);
+  assert_eq!(core::mem::size_of::<send_in>(), 40);
+  assert_eq!(core::mem::align_of::<send_in>(), 8);
   unsafe {
-    let obj: send_in = ::core::mem::uninitialized();
+    let obj: send_in = core::mem::uninitialized();
     let base = &obj as *const _ as usize;
     assert_eq!(&obj.si_data.0 as *const _ as usize - base, 0);
     assert_eq!(&obj.si_data.1 as *const _ as usize - base, 8);
@@ -1518,10 +1518,10 @@ pub struct send_out {
 #[test]
 #[cfg(target_pointer_width = "32")]
 fn send_out_layout_test_32() {
-  assert_eq!(::core::mem::size_of::<send_out>(), 4);
-  assert_eq!(::core::mem::align_of::<send_out>(), 4);
+  assert_eq!(core::mem::size_of::<send_out>(), 4);
+  assert_eq!(core::mem::align_of::<send_out>(), 4);
   unsafe {
-    let obj: send_out = ::core::mem::uninitialized();
+    let obj: send_out = core::mem::uninitialized();
     let base = &obj as *const _ as usize;
     assert_eq!(&obj.so_datalen as *const _ as usize - base, 0);
   }
@@ -1529,10 +1529,10 @@ fn send_out_layout_test_32() {
 #[test]
 #[cfg(target_pointer_width = "64")]
 fn send_out_layout_test_64() {
-  assert_eq!(::core::mem::size_of::<send_out>(), 8);
-  assert_eq!(::core::mem::align_of::<send_out>(), 8);
+  assert_eq!(core::mem::size_of::<send_out>(), 8);
+  assert_eq!(core::mem::align_of::<send_out>(), 8);
   unsafe {
-    let obj: send_out = ::core::mem::uninitialized();
+    let obj: send_out = core::mem::uninitialized();
     let base = &obj as *const _ as usize;
     assert_eq!(&obj.so_datalen as *const _ as usize - base, 0);
   }
@@ -1647,10 +1647,10 @@ pub struct subscription_proc_terminate {
 #[test]
 #[cfg(target_pointer_width = "32")]
 fn subscription_layout_test_32() {
-  assert_eq!(::core::mem::size_of::<subscription>(), 56);
-  assert_eq!(::core::mem::align_of::<subscription>(), 8);
+  assert_eq!(core::mem::size_of::<subscription>(), 56);
+  assert_eq!(core::mem::align_of::<subscription>(), 8);
   unsafe {
-    let obj: subscription = ::core::mem::uninitialized();
+    let obj: subscription = core::mem::uninitialized();
     let base = &obj as *const _ as usize;
     assert_eq!(&obj.userdata as *const _ as usize - base, 0);
     assert_eq!(&obj.unused as *const _ as usize - base, 8);
@@ -1674,10 +1674,10 @@ fn subscription_layout_test_32() {
 #[test]
 #[cfg(target_pointer_width = "64")]
 fn subscription_layout_test_64() {
-  assert_eq!(::core::mem::size_of::<subscription>(), 56);
-  assert_eq!(::core::mem::align_of::<subscription>(), 8);
+  assert_eq!(core::mem::size_of::<subscription>(), 56);
+  assert_eq!(core::mem::align_of::<subscription>(), 8);
   unsafe {
-    let obj: subscription = ::core::mem::uninitialized();
+    let obj: subscription = core::mem::uninitialized();
     let base = &obj as *const _ as usize;
     assert_eq!(&obj.userdata as *const _ as usize - base, 0);
     assert_eq!(&obj.unused as *const _ as usize - base, 8);
@@ -1728,10 +1728,10 @@ pub struct tcb {
 #[test]
 #[cfg(target_pointer_width = "32")]
 fn tcb_layout_test_32() {
-  assert_eq!(::core::mem::size_of::<tcb>(), 4);
-  assert_eq!(::core::mem::align_of::<tcb>(), 4);
+  assert_eq!(core::mem::size_of::<tcb>(), 4);
+  assert_eq!(core::mem::align_of::<tcb>(), 4);
   unsafe {
-    let obj: tcb = ::core::mem::uninitialized();
+    let obj: tcb = core::mem::uninitialized();
     let base = &obj as *const _ as usize;
     assert_eq!(&obj.parent as *const _ as usize - base, 0);
   }
@@ -1739,10 +1739,10 @@ fn tcb_layout_test_32() {
 #[test]
 #[cfg(target_pointer_width = "64")]
 fn tcb_layout_test_64() {
-  assert_eq!(::core::mem::size_of::<tcb>(), 8);
-  assert_eq!(::core::mem::align_of::<tcb>(), 8);
+  assert_eq!(core::mem::size_of::<tcb>(), 8);
+  assert_eq!(core::mem::align_of::<tcb>(), 8);
   unsafe {
-    let obj: tcb = ::core::mem::uninitialized();
+    let obj: tcb = core::mem::uninitialized();
     let base = &obj as *const _ as usize;
     assert_eq!(&obj.parent as *const _ as usize - base, 0);
   }
@@ -1773,10 +1773,10 @@ pub struct threadattr {
 #[test]
 #[cfg(target_pointer_width = "32")]
 fn threadattr_layout_test_32() {
-  assert_eq!(::core::mem::size_of::<threadattr>(), 16);
-  assert_eq!(::core::mem::align_of::<threadattr>(), 4);
+  assert_eq!(core::mem::size_of::<threadattr>(), 16);
+  assert_eq!(core::mem::align_of::<threadattr>(), 4);
   unsafe {
-    let obj: threadattr = ::core::mem::uninitialized();
+    let obj: threadattr = core::mem::uninitialized();
     let base = &obj as *const _ as usize;
     assert_eq!(&obj.entry_point as *const _ as usize - base, 0);
     assert_eq!(&obj.stack.0 as *const _ as usize - base, 4);
@@ -1787,10 +1787,10 @@ fn threadattr_layout_test_32() {
 #[test]
 #[cfg(target_pointer_width = "64")]
 fn threadattr_layout_test_64() {
-  assert_eq!(::core::mem::size_of::<threadattr>(), 32);
-  assert_eq!(::core::mem::align_of::<threadattr>(), 8);
+  assert_eq!(core::mem::size_of::<threadattr>(), 32);
+  assert_eq!(core::mem::align_of::<threadattr>(), 8);
   unsafe {
-    let obj: threadattr = ::core::mem::uninitialized();
+    let obj: threadattr = core::mem::uninitialized();
     let base = &obj as *const _ as usize;
     assert_eq!(&obj.entry_point as *const _ as usize - base, 0);
     assert_eq!(&obj.stack.0 as *const _ as usize - base, 8);
index 4147ffff87113bd3e9697eaf7196093ed34e6c51..dea562abad3ffbebf84e0916551dea92bd54d371 100644 (file)
@@ -1,4 +1,4 @@
-pub use sys::cloudabi::shims::args::*;
+pub use crate::sys::cloudabi::shims::args::*;
 
 #[allow(dead_code)]
 pub fn init(_: isize, _: *const *const u8) {}
index 72f28550435a1fa9cc69294026e17fafd5adde17..a15d2238e5563e7152bcc98342b15bafe71e4776 100644 (file)
@@ -1,9 +1,10 @@
-use error::Error;
-use ffi::CStr;
-use intrinsics;
-use io;
-use libc;
-use sys_common::backtrace::Frame;
+use crate::error::Error;
+use crate::ffi::CStr;
+use crate::fmt;
+use crate::intrinsics;
+use crate::io;
+use crate::sys_common::backtrace::Frame;
+
 use unwind as uw;
 
 pub struct BacktraceContext;
@@ -22,8 +23,8 @@ fn description(&self) -> &'static str {
     }
 }
 
-impl ::fmt::Display for UnwindError {
-    fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+impl fmt::Display for UnwindError {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "{}: {:?}", self.description(), self.0)
     }
 }
index 758f29653aeb1973f20191aedad6bf3b16f1e31b..7aa0b0b6f4912e670f731706e8d496fbafd40d5b 100644 (file)
@@ -1,10 +1,10 @@
-use cell::UnsafeCell;
-use mem;
-use sync::atomic::{AtomicU32, Ordering};
-use sys::cloudabi::abi;
-use sys::mutex::{self, Mutex};
-use sys::time::checked_dur2intervals;
-use time::Duration;
+use crate::cell::UnsafeCell;
+use crate::mem;
+use crate::sync::atomic::{AtomicU32, Ordering};
+use crate::sys::cloudabi::abi;
+use crate::sys::mutex::{self, Mutex};
+use crate::sys::time::checked_dur2intervals;
+use crate::time::Duration;
 
 extern "C" {
     #[thread_local]
index d9bc21861c90da0c74391637aa174d81a6053fd6..47c90fddd867f72c071a2e928e092506de14b261 100644 (file)
@@ -1,5 +1,5 @@
-use libc;
-use mem;
+use crate::io::ErrorKind;
+use crate::mem;
 
 #[path = "../unix/alloc.rs"]
 pub mod alloc;
 #[allow(dead_code)]
 pub fn init() {}
 
-pub fn decode_error_kind(errno: i32) -> ::io::ErrorKind {
+pub fn decode_error_kind(errno: i32) -> ErrorKind {
     match errno {
-        x if x == abi::errno::ACCES as i32 => ::io::ErrorKind::PermissionDenied,
-        x if x == abi::errno::ADDRINUSE as i32 => ::io::ErrorKind::AddrInUse,
-        x if x == abi::errno::ADDRNOTAVAIL as i32 => ::io::ErrorKind::AddrNotAvailable,
-        x if x == abi::errno::AGAIN as i32 => ::io::ErrorKind::WouldBlock,
-        x if x == abi::errno::CONNABORTED as i32 => ::io::ErrorKind::ConnectionAborted,
-        x if x == abi::errno::CONNREFUSED as i32 => ::io::ErrorKind::ConnectionRefused,
-        x if x == abi::errno::CONNRESET as i32 => ::io::ErrorKind::ConnectionReset,
-        x if x == abi::errno::EXIST as i32 => ::io::ErrorKind::AlreadyExists,
-        x if x == abi::errno::INTR as i32 => ::io::ErrorKind::Interrupted,
-        x if x == abi::errno::INVAL as i32 => ::io::ErrorKind::InvalidInput,
-        x if x == abi::errno::NOENT as i32 => ::io::ErrorKind::NotFound,
-        x if x == abi::errno::NOTCONN as i32 => ::io::ErrorKind::NotConnected,
-        x if x == abi::errno::PERM as i32 => ::io::ErrorKind::PermissionDenied,
-        x if x == abi::errno::PIPE as i32 => ::io::ErrorKind::BrokenPipe,
-        x if x == abi::errno::TIMEDOUT as i32 => ::io::ErrorKind::TimedOut,
-        _ => ::io::ErrorKind::Other,
+        x if x == abi::errno::ACCES as i32 => ErrorKind::PermissionDenied,
+        x if x == abi::errno::ADDRINUSE as i32 => ErrorKind::AddrInUse,
+        x if x == abi::errno::ADDRNOTAVAIL as i32 => ErrorKind::AddrNotAvailable,
+        x if x == abi::errno::AGAIN as i32 => ErrorKind::WouldBlock,
+        x if x == abi::errno::CONNABORTED as i32 => ErrorKind::ConnectionAborted,
+        x if x == abi::errno::CONNREFUSED as i32 => ErrorKind::ConnectionRefused,
+        x if x == abi::errno::CONNRESET as i32 => ErrorKind::ConnectionReset,
+        x if x == abi::errno::EXIST as i32 => ErrorKind::AlreadyExists,
+        x if x == abi::errno::INTR as i32 => ErrorKind::Interrupted,
+        x if x == abi::errno::INVAL as i32 => ErrorKind::InvalidInput,
+        x if x == abi::errno::NOENT as i32 => ErrorKind::NotFound,
+        x if x == abi::errno::NOTCONN as i32 => ErrorKind::NotConnected,
+        x if x == abi::errno::PERM as i32 => ErrorKind::PermissionDenied,
+        x if x == abi::errno::PIPE as i32 => ErrorKind::BrokenPipe,
+        x if x == abi::errno::TIMEDOUT as i32 => ErrorKind::TimedOut,
+        _ => ErrorKind::Other,
     }
 }
 
 pub unsafe fn abort_internal() -> ! {
-    ::core::intrinsics::abort();
+    core::intrinsics::abort();
 }
 
 pub use libc::strlen;
index ae62d8bfdb0c2d0dfda5f63bf496c52cc03e421d..5e191e31d5fc47c347f3b0c72ddde601ef4e53b7 100644 (file)
@@ -1,8 +1,8 @@
-use cell::UnsafeCell;
-use mem;
-use sync::atomic::{AtomicU32, Ordering};
-use sys::cloudabi::abi;
-use sys::rwlock::{self, RWLock};
+use crate::cell::UnsafeCell;
+use crate::mem;
+use crate::sync::atomic::{AtomicU32, Ordering};
+use crate::sys::cloudabi::abi;
+use crate::sys::rwlock::{self, RWLock};
 
 extern "C" {
     #[thread_local]
index 8a6464125de68fd72398488a3b9d2b3f89b8822d..7db7808a08783a6fb0f8b4e53e853928d277c095 100644 (file)
@@ -1,8 +1,9 @@
-use ffi::CStr;
-use libc::{self, c_int};
-use str;
+use crate::ffi::CStr;
+use crate::str;
 
-pub use sys::cloudabi::shims::os::*;
+use libc::c_int;
+
+pub use crate::sys::cloudabi::shims::os::*;
 
 pub fn errno() -> i32 {
     extern "C" {
index 7f08c2c786919b5223ecf1ded1963ade2942c135..6da3f3841b6c6d79d31553bc40e13d14e6407cc8 100644 (file)
@@ -1,7 +1,7 @@
-use cell::UnsafeCell;
-use mem;
-use sync::atomic::{AtomicU32, Ordering};
-use sys::cloudabi::abi;
+use crate::cell::UnsafeCell;
+use crate::mem;
+use crate::sync::atomic::{AtomicU32, Ordering};
+use crate::sys::cloudabi::abi;
 
 extern "C" {
     #[thread_local]
index f924a434263f47f89cf4dbba3079770754b25607..f5cf71caf6c048f28f98bdc621066b3b32f34f3b 100644 (file)
@@ -1,4 +1,4 @@
-use ffi::OsString;
+use crate::ffi::OsString;
 
 pub struct Args(());
 
index 3af10a74c7d45f1096b238a67db4fd50e8d852c6..56667bef007068ace3e29b56cbaff3b44e9a0dab 100644 (file)
@@ -1,10 +1,10 @@
-use ffi::OsString;
-use fmt;
-use hash::{Hash, Hasher};
-use io::{self, SeekFrom};
-use path::{Path, PathBuf};
-use sys::time::SystemTime;
-use sys::{unsupported, Void};
+use crate::ffi::OsString;
+use crate::fmt;
+use crate::hash::{Hash, Hasher};
+use crate::io::{self, SeekFrom};
+use crate::path::{Path, PathBuf};
+use crate::sys::time::SystemTime;
+use crate::sys::{unsupported, Void};
 
 pub struct File(Void);
 
index 080eac19ceb0bcfc022d8943122df1b86d02a4f9..fbb5ff55f22241e4f06cf0acf12f0e45a15f9180 100644 (file)
@@ -1,4 +1,4 @@
-use io;
+use crate::io;
 
 pub mod args;
 pub mod env;
index 869a0ef87a70e8949bb0c35b600cf79bd03bfb45..50d72dc7b240bdf2c7d4d6adc545fcbe546bcaa8 100644 (file)
@@ -1,10 +1,11 @@
-use fmt;
-use io::{self, IoVec, IoVecMut};
-use net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr};
-use time::Duration;
-use sys::{unsupported, Void};
-use convert::TryFrom;
-
+use crate::fmt;
+use crate::io::{self, IoVec, IoVecMut};
+use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr};
+use crate::time::Duration;
+use crate::sys::{unsupported, Void};
+use crate::convert::TryFrom;
+
+#[allow(unused_extern_crates)]
 pub extern crate libc as netc;
 
 pub struct TcpStream(Void);
index 31cb18ea5268bd658126639d001bdb3b6a0a8f91..0c4690e12b052338be67efa0c914ff92f744b593 100644 (file)
@@ -1,10 +1,10 @@
-use error::Error as StdError;
-use ffi::{OsStr, OsString};
-use fmt;
-use io;
-use iter;
-use path::{self, PathBuf};
-use sys::{unsupported, Void};
+use crate::error::Error as StdError;
+use crate::ffi::{OsStr, OsString};
+use crate::fmt;
+use crate::io;
+use crate::iter;
+use crate::path::{self, PathBuf};
+use crate::sys::{unsupported, Void};
 
 pub fn getcwd() -> io::Result<PathBuf> {
     unsupported()
index 30ef79dd769b41ee3d649fed8c9d1f9531b9a4c9..f3debb9504742c72baad48cb957745d9242625b2 100644 (file)
@@ -1,5 +1,5 @@
-use io;
-use sys::Void;
+use crate::io;
+use crate::sys::Void;
 
 pub struct AnonPipe(Void);
 
index 49b9d5e266ec4f869719f7e1703f0f15987dd978..710c42c1149022a212bbd38d85d9282b6a160de3 100644 (file)
@@ -1,10 +1,10 @@
-use ffi::OsStr;
-use fmt;
-use io;
-use sys::fs::File;
-use sys::pipe::AnonPipe;
-use sys::{unsupported, Void};
-use sys_common::process::{CommandEnv, DefaultEnvKey};
+use crate::ffi::OsStr;
+use crate::fmt;
+use crate::io;
+use crate::sys::fs::File;
+use crate::sys::pipe::AnonPipe;
+use crate::sys::{unsupported, Void};
+use crate::sys_common::process::{CommandEnv, DefaultEnvKey};
 
 ////////////////////////////////////////////////////////////////////////////////
 // Command
index 81d79213f615cd583abf1392541a43158dc0b7cc..601563c5b1fcbdebe7e5dca84bea6f5432a42f61 100644 (file)
@@ -1,5 +1,5 @@
-use io;
-use sys::cloudabi::abi;
+use crate::io;
+use crate::sys::cloudabi::abi;
 
 pub struct Stdin(());
 pub struct Stdout(());
@@ -59,7 +59,7 @@ pub fn is_ebadf(err: &io::Error) -> bool {
     err.raw_os_error() == Some(abi::errno::BADF as i32)
 }
 
-pub const STDIN_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE;
+pub const STDIN_BUF_SIZE: usize = crate::sys_common::io::DEFAULT_BUF_SIZE;
 
 pub fn panic_output() -> Option<impl io::Write> {
     Stderr::new().ok()
index 950420420f09ecc0c5e9d3fd7be9c07ce30e0972..f853346e0e63c156c717b95d4382393b0d2e9568 100644 (file)
@@ -1,14 +1,13 @@
-use boxed::FnBox;
-use cmp;
-use ffi::CStr;
-use io;
-use libc;
-use mem;
-use ptr;
-use sys::cloudabi::abi;
-use sys::time::checked_dur2intervals;
-use sys_common::thread::*;
-use time::Duration;
+use crate::boxed::FnBox;
+use crate::cmp;
+use crate::ffi::CStr;
+use crate::io;
+use crate::mem;
+use crate::ptr;
+use crate::sys::cloudabi::abi;
+use crate::sys::time::checked_dur2intervals;
+use crate::sys_common::thread::*;
+use crate::time::Duration;
 
 pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024;
 
index 545e3c0ce845510a99c2e57ada037f88ba64a7a8..d7502c61eff2c044359123990b4ca321134344b6 100644 (file)
@@ -1,6 +1,6 @@
-use mem;
-use sys::cloudabi::abi;
-use time::Duration;
+use crate::mem;
+use crate::sys::cloudabi::abi;
+use crate::time::Duration;
 
 const NSEC_PER_SEC: abi::timestamp = 1_000_000_000;
 
index 0a56f4fad6d15ee69b5bedb31a46912862c7f28b..5ba9304c09b995b875ea2116ca573a61e96be460 100644 (file)
@@ -67,7 +67,7 @@
         pub mod unix_ext {}
     } else {
         // On other platforms like Windows document the bare bones of unix
-        use os::linux as platform;
+        use crate::os::linux as platform;
         #[path = "unix/ext/mod.rs"]
         pub mod unix_ext;
     }
index 4e51be03f6f027aea83d5913cbde6291449557de..f9e2f5ba311a090da85d043e45aba6ae539b0e3a 100644 (file)
@@ -5,9 +5,9 @@
 
 #![allow(dead_code)] // runtime init functions not used during testing
 
-use ffi::OsString;
-use marker::PhantomData;
-use vec;
+use crate::ffi::OsString;
+use crate::marker::PhantomData;
+use crate::vec;
 
 /// One-time global initialization.
 pub unsafe fn init(argc: isize, argv: *const *const u8) { imp::init(argc, argv) }
@@ -46,14 +46,13 @@ fn next_back(&mut self) -> Option<OsString> { self.iter.next_back() }
 }
 
 mod imp {
-    use os::unix::prelude::*;
-    use mem;
-    use ffi::{CStr, OsString};
-    use marker::PhantomData;
-    use libc;
+    use crate::os::unix::prelude::*;
+    use crate::mem;
+    use crate::ffi::{CStr, OsString};
+    use crate::marker::PhantomData;
     use super::Args;
 
-    use sys_common::mutex::Mutex;
+    use crate::sys_common::mutex::Mutex;
 
     static mut GLOBAL_ARGS_PTR: usize = 0;
     static LOCK: Mutex = Mutex::new();
index 9a007241073c47e41a13f3183d48a69ddf84bda4..8ea2783580a4769358c171a55db26782df707e33 100644 (file)
@@ -9,13 +9,13 @@
 mod printing;
 
 pub mod gnu {
-    use io;
-    use fs;
+    use crate::io;
+    use crate::fs;
+    use crate::vec::Vec;
+    use crate::ffi::OsStr;
+    use crate::os::unix::ffi::OsStrExt;
+    use crate::io::Read;
     use libc::c_char;
-    use vec::Vec;
-    use ffi::OsStr;
-    use os::unix::ffi::OsStrExt;
-    use io::Read;
 
     pub fn get_executable_filename() -> io::Result<(Vec<c_char>, fs::File)> {
         let mut exefile = fs::File::open("sys:exe")?;
index c50c7154f0cd2134550c5c86201121590556015c..489eed4562debf3a1a88bf359456a98baff3b4af 100644 (file)
@@ -1 +1 @@
-pub use sys_common::gnu::libbacktrace::{foreach_symbol_fileline, resolve_symname};
+pub use crate::sys_common::gnu::libbacktrace::{foreach_symbol_fileline, resolve_symname};
index 59a8c5fab3d4472647974544e745e888b85760ba..e7a68eadbde3a18e17fcd86b50ba39725f414550 100644 (file)
@@ -1,8 +1,8 @@
-use error::Error;
-use io;
-use libc;
-use sys::backtrace::BacktraceContext;
-use sys_common::backtrace::Frame;
+use crate::error::Error;
+use crate::fmt;
+use crate::io;
+use crate::sys::backtrace::BacktraceContext;
+use crate::sys_common::backtrace::Frame;
 
 use unwind as uw;
 
@@ -20,8 +20,8 @@ fn description(&self) -> &'static str {
     }
 }
 
-impl ::fmt::Display for UnwindError {
-    fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+impl fmt::Display for UnwindError {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "{}: {:?}", self.description(), self.0)
     }
 }
index 5f9eee588c33e47ca9f58bcf0dcfce2d7684c6a5..a6365cac23ea740f5ef7f74a61b05068f5bdffa4 100644 (file)
@@ -1,10 +1,10 @@
-use cell::UnsafeCell;
-use intrinsics::{atomic_cxchg, atomic_load, atomic_xadd, atomic_xchg};
-use ptr;
-use time::Duration;
+use crate::cell::UnsafeCell;
+use crate::intrinsics::{atomic_cxchg, atomic_load, atomic_xadd, atomic_xchg};
+use crate::ptr;
+use crate::time::Duration;
 
-use sys::mutex::{mutex_unlock, Mutex};
-use sys::syscall::{futex, TimeSpec, FUTEX_WAIT, FUTEX_WAKE, FUTEX_REQUEUE};
+use crate::sys::mutex::{mutex_unlock, Mutex};
+use crate::sys::syscall::{futex, TimeSpec, FUTEX_WAIT, FUTEX_WAKE, FUTEX_REQUEUE};
 
 pub struct Condvar {
     lock: UnsafeCell<*mut i32>,
@@ -48,7 +48,7 @@ pub fn notify_all(&self) {
 
             atomic_xadd(seq, 1);
 
-            let _ = futex(seq, FUTEX_REQUEUE, 1, ::usize::MAX, *lock);
+            let _ = futex(seq, FUTEX_REQUEUE, 1, crate::usize::MAX, *lock);
         }
     }
 
index 848880d26e89e1fcab8f81c58c5a79e6b804e03b..671498bc39037e29fc813eb21637c8a40a7eff3c 100644 (file)
@@ -2,10 +2,10 @@
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
-use ffi::{OsStr, OsString};
-use mem;
-use sys::os_str::Buf;
-use sys_common::{FromInner, IntoInner, AsInner};
+use crate::ffi::{OsStr, OsString};
+use crate::mem;
+use crate::sys::os_str::Buf;
+use crate::sys_common::{FromInner, IntoInner, AsInner};
 
 /// Redox-specific extensions to [`OsString`].
 ///
index 8b81273f201cfe16ab85ac80d6e0723e8305a37e..53b9dd68f734f3053899718e1a5738c4a666e7cd 100644 (file)
@@ -2,11 +2,11 @@
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
-use fs::{self, Permissions, OpenOptions};
-use io;
-use path::Path;
-use sys;
-use sys_common::{FromInner, AsInner, AsInnerMut};
+use crate::fs::{self, Permissions, OpenOptions};
+use crate::io;
+use crate::path::Path;
+use crate::sys;
+use crate::sys_common::{FromInner, AsInner, AsInnerMut};
 
 /// Redox-specific extensions to [`fs::Permissions`].
 ///
index 3ee0c6010a7ad476be1edf30dd1c4143565bf914..f431f96c541f7e7f143caa97f5f1eec54dda624b 100644 (file)
@@ -2,11 +2,11 @@
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
-use fs;
-use net;
-use sys;
-use io;
-use sys_common::{self, AsInner, FromInner, IntoInner};
+use crate::fs;
+use crate::net;
+use crate::sys;
+use crate::io;
+use crate::sys_common::{self, AsInner, FromInner, IntoInner};
 
 /// Raw file descriptors.
 #[stable(feature = "rust1", since = "1.0.0")]
index 7411b8e068f643a9934b00699c44441c55a7ae73..2c121787804d1b6aa91a03787e968137f6418e39 100644 (file)
@@ -2,13 +2,13 @@
 
 //! Unix-specific networking functionality
 
-use fmt;
-use io::{self, Error, ErrorKind, Initializer};
-use net::Shutdown;
-use os::unix::io::{RawFd, AsRawFd, FromRawFd, IntoRawFd};
-use path::Path;
-use time::Duration;
-use sys::{cvt, fd::FileDesc, syscall};
+use crate::fmt;
+use crate::io::{self, Error, ErrorKind, Initializer};
+use crate::net::Shutdown;
+use crate::os::unix::io::{RawFd, AsRawFd, FromRawFd, IntoRawFd};
+use crate::path::Path;
+use crate::time::Duration;
+use crate::sys::{cvt, fd::FileDesc, syscall};
 
 /// An address associated with a Unix socket.
 ///
index 020075531dd0e0420f22f2e4248dae215ed87890..e981cb93d441fd987c09adbbcd838ecb75b2af52 100644 (file)
@@ -2,11 +2,11 @@
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
-use io;
-use os::unix::io::{FromRawFd, RawFd, AsRawFd, IntoRawFd};
-use process;
-use sys;
-use sys_common::{AsInnerMut, AsInner, FromInner, IntoInner};
+use crate::io;
+use crate::os::unix::io::{FromRawFd, RawFd, AsRawFd, IntoRawFd};
+use crate::process;
+use crate::sys;
+use crate::sys_common::{AsInnerMut, AsInner, FromInner, IntoInner};
 
 /// Redox-specific extensions to the [`process::Command`] builder,
 ///
index 21b140ad718ac0e9a4248998243fb1b4d00f16c2..629eaef04ce36fcf0636e533358cc7c6f3319408 100644 (file)
@@ -2,8 +2,8 @@
 
 #![stable(feature = "thread_extensions", since = "1.9.0")]
 
-use sys_common::{AsInner, IntoInner};
-use thread::JoinHandle;
+use crate::sys_common::{AsInner, IntoInner};
+use crate::thread::JoinHandle;
 
 #[stable(feature = "thread_extensions", since = "1.9.0")]
 #[allow(deprecated)]
index 95263e6f5e3125326d6cbcfade3769804f9e712e..1202708a4769a56bc916e6b1a43f819bedff543b 100644 (file)
@@ -1,9 +1,9 @@
 #![cfg(target_thread_local)]
 #![unstable(feature = "thread_local_internals", issue = "0")]
 
-use cell::{Cell, UnsafeCell};
-use mem;
-use ptr;
+use crate::cell::{Cell, UnsafeCell};
+use crate::mem;
+use crate::ptr;
 
 
 pub struct Key<T> {
@@ -15,7 +15,7 @@ pub struct Key<T> {
     dtor_running: Cell<bool>,
 }
 
-unsafe impl<T> ::marker::Sync for Key<T> { }
+unsafe impl<T> Sync for Key<T> { }
 
 impl<T> Key<T> {
     pub const fn new() -> Key<T> {
@@ -57,7 +57,7 @@ pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern fn(*mut u8)) {
     // *should* be the case that this loop always terminates because we
     // provide the guarantee that a TLS key cannot be set after it is
     // flagged for destruction.
-    use sys_common::thread_local as os;
+    use crate::sys_common::thread_local as os;
 
     static DTORS: os::StaticKey = os::StaticKey::new(Some(run_dtors));
     type List = Vec<(*mut u8, unsafe extern fn(*mut u8))>;
index fbf31aae2d0e6aedc703184436f4eb94180d18b1..a42e486db2239b54a39052881e9a7e274af11e91 100644 (file)
@@ -1,9 +1,9 @@
 #![unstable(reason = "not public", issue = "0", feature = "fd")]
 
-use io::{self, Read};
-use mem;
-use sys::{cvt, syscall};
-use sys_common::AsInner;
+use crate::io::{self, Read};
+use crate::mem;
+use crate::sys::{cvt, syscall};
+use crate::sys_common::AsInner;
 
 pub struct FileDesc {
     fd: usize,
index 97e5dcebfeab6959191681c28554e0e80a213636..159ee9911bd3ac0bfd1a3e14006b71e119405090 100644 (file)
@@ -1,14 +1,14 @@
-use os::unix::prelude::*;
-
-use ffi::{OsString, OsStr};
-use fmt;
-use io::{self, Error, ErrorKind, SeekFrom};
-use path::{Path, PathBuf};
-use sync::Arc;
-use sys::fd::FileDesc;
-use sys::time::SystemTime;
-use sys::{cvt, syscall};
-use sys_common::{AsInner, FromInner};
+use crate::os::unix::prelude::*;
+
+use crate::ffi::{OsString, OsStr};
+use crate::fmt;
+use crate::io::{self, Error, ErrorKind, SeekFrom};
+use crate::path::{Path, PathBuf};
+use crate::sync::Arc;
+use crate::sys::fd::FileDesc;
+use crate::sys::time::SystemTime;
+use crate::sys::{cvt, syscall};
+use crate::sys_common::{AsInner, FromInner};
 
 pub struct File(FileDesc);
 
@@ -457,7 +457,7 @@ pub fn canonicalize(p: &Path) -> io::Result<PathBuf> {
 }
 
 pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
-    use fs::{File, set_permissions};
+    use crate::fs::{File, set_permissions};
     if !from.is_file() {
         return Err(Error::new(ErrorKind::InvalidInput,
                               "the source path is not an existing regular file"))
index c3878349bb329c6ab1cc519f87626f8972fe3cbf..7f3ac1f1bb5b3f99fb6e30e80504377d0c5dd233 100644 (file)
@@ -1,6 +1,6 @@
 #![allow(dead_code, missing_docs, nonstandard_style)]
 
-use ::io::{ErrorKind};
+use crate::io::ErrorKind;
 
 pub use libc::strlen;
 pub use self::rand::hashmap_random_keys;
@@ -64,8 +64,8 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind {
     }
 }
 
-pub fn cvt(result: Result<usize, syscall::Error>) -> ::io::Result<usize> {
-    result.map_err(|err| ::io::Error::from_raw_os_error(err.errno))
+pub fn cvt(result: Result<usize, syscall::Error>) -> crate::io::Result<usize> {
+    result.map_err(|err| crate::io::Error::from_raw_os_error(err.errno))
 }
 
 #[doc(hidden)]
@@ -83,9 +83,9 @@ fn is_minus_one(&self) -> bool {
 
 impl_is_minus_one! { i8 i16 i32 i64 isize }
 
-pub fn cvt_libc<T: IsMinusOne>(t: T) -> ::io::Result<T> {
+pub fn cvt_libc<T: IsMinusOne>(t: T) -> crate::io::Result<T> {
     if t.is_minus_one() {
-        Err(::io::Error::last_os_error())
+        Err(crate::io::Error::last_os_error())
     } else {
         Ok(t)
     }
@@ -93,5 +93,5 @@ pub fn cvt_libc<T: IsMinusOne>(t: T) -> ::io::Result<T> {
 
 /// On Redox, use an illegal instruction to abort
 pub unsafe fn abort_internal() -> ! {
-    ::core::intrinsics::abort();
+    core::intrinsics::abort();
 }
index bf39cc485911b720ebd254a2a15b4395aa644e5c..59399df0294c8b0e3b5036bc497d276ed81577ae 100644 (file)
@@ -1,8 +1,8 @@
-use cell::UnsafeCell;
-use intrinsics::{atomic_cxchg, atomic_xchg};
-use ptr;
+use crate::cell::UnsafeCell;
+use crate::intrinsics::{atomic_cxchg, atomic_xchg};
+use crate::ptr;
 
-use sys::syscall::{futex, getpid, FUTEX_WAIT, FUTEX_WAKE};
+use crate::sys::syscall::{futex, getpid, FUTEX_WAIT, FUTEX_WAKE};
 
 pub unsafe fn mutex_try_lock(m: *mut i32) -> bool {
     atomic_cxchg(m, 0, 1).0 == 0
index c0450c11ed6b9885cd7fff9aac1ed0501d084c65..e9b406bc685a1c01f7df1d846f9e37f17984ae39 100644 (file)
@@ -1,5 +1,5 @@
-use string::String;
-use vec::Vec;
+use crate::string::String;
+use crate::vec::Vec;
 
 #[derive(Clone, Debug)]
 pub struct DnsAnswer {
index 8f0a0610af5e3bd1de4becb2355431f14a2aa92f..6533e0d5efb77b90b932b5fe631c70a34e3dfc42 100644 (file)
@@ -1,10 +1,10 @@
 pub use self::answer::DnsAnswer;
 pub use self::query::DnsQuery;
 
-use slice;
-use u16;
-use string::String;
-use vec::Vec;
+use crate::slice;
+use crate::u16;
+use crate::string::String;
+use crate::vec::Vec;
 
 mod answer;
 mod query;
index dcb554d82debbb6421357371d429911ecbb42ef0..65fb241b03737d3f62c2424ffd7c001e844b5fd8 100644 (file)
@@ -1,4 +1,4 @@
-use string::String;
+use crate::string::String;
 
 #[derive(Clone, Debug)]
 pub struct DnsQuery {
index 9e7599aebbbdb3a6a96e95f9fcce2fcdff30896a..a172763f61313b771e06082b9f2f2a2e4a36f3ad 100644 (file)
@@ -1,13 +1,13 @@
-use fs::File;
-use io::{Error, Read, self};
-use iter::Iterator;
-use net::{Ipv4Addr, SocketAddr, SocketAddrV4};
-use str::FromStr;
-use string::{String, ToString};
-use sys::syscall::EINVAL;
-use time::{self, Duration};
-use vec::{IntoIter, Vec};
-use convert::{TryFrom, TryInto};
+use crate::fs::File;
+use crate::io::{Error, Read, self};
+use crate::iter::Iterator;
+use crate::net::{Ipv4Addr, SocketAddr, SocketAddrV4};
+use crate::str::FromStr;
+use crate::string::{String, ToString};
+use crate::sys::syscall::EINVAL;
+use crate::time::{self, Duration};
+use crate::vec::{IntoIter, Vec};
+use crate::convert::{TryFrom, TryInto};
 
 use self::dns::{Dns, DnsQuery};
 
index abb9f72c324b6452ac8fb9c0bd183efbffa690b5..5081c3de73c5a51b05c07fbd3e03dc416bb40fad 100644 (file)
@@ -1,12 +1,12 @@
-use cmp;
-use io::{self, Error, ErrorKind, Result, IoVec, IoVecMut};
-use mem;
-use net::{SocketAddr, Shutdown};
-use path::Path;
-use sys::fs::{File, OpenOptions};
-use sys::syscall::TimeSpec;
-use sys_common::{AsInner, FromInner, IntoInner};
-use time::Duration;
+use crate::cmp;
+use crate::io::{self, Error, ErrorKind, Result, IoVec, IoVecMut};
+use crate::mem;
+use crate::net::{SocketAddr, Shutdown};
+use crate::path::Path;
+use crate::sys::fs::{File, OpenOptions};
+use crate::sys::syscall::TimeSpec;
+use crate::sys_common::{AsInner, FromInner, IntoInner};
+use crate::time::Duration;
 
 use super::{path_to_peer_addr, path_to_local_addr};
 
index 2a59b44f09361aafa19976edb9c0140757532693..b1a60b14570836fb9e3ba4b270f09a3c564914e9 100644 (file)
@@ -1,13 +1,13 @@
-use cell::UnsafeCell;
-use cmp;
-use io::{self, Error, ErrorKind, Result};
-use mem;
-use net::{SocketAddr, Ipv4Addr, Ipv6Addr};
-use path::Path;
-use sys::fs::{File, OpenOptions};
-use sys::syscall::TimeSpec;
-use sys_common::{AsInner, FromInner, IntoInner};
-use time::Duration;
+use crate::cell::UnsafeCell;
+use crate::cmp;
+use crate::io::{self, Error, ErrorKind, Result};
+use crate::mem;
+use crate::net::{SocketAddr, Ipv4Addr, Ipv6Addr};
+use crate::path::Path;
+use crate::sys::fs::{File, OpenOptions};
+use crate::sys::syscall::TimeSpec;
+use crate::sys_common::{AsInner, FromInner, IntoInner};
+use crate::time::Duration;
 
 use super::{path_to_peer_addr, path_to_local_addr};
 
index f7a26c94970253ac2799f9c791412b86df54c5cc..76e43a83b73724eaf0ad955c67d00bf3061c2847 100644 (file)
@@ -2,25 +2,25 @@
 
 #![allow(unused_imports)] // lots of cfg code here
 
-use libc::{self, c_char};
-
-use os::unix::prelude::*;
-
-use error::Error as StdError;
-use ffi::{CStr, CString, OsStr, OsString};
-use fmt;
-use io::{self, Read, Write};
-use iter;
-use marker::PhantomData;
-use mem;
-use memchr;
-use path::{self, PathBuf};
-use ptr;
-use slice;
-use str;
-use sys_common::mutex::Mutex;
-use sys::{cvt, cvt_libc, fd, syscall};
-use vec;
+use libc::c_char;
+
+use crate::os::unix::prelude::*;
+
+use crate::error::Error as StdError;
+use crate::ffi::{CStr, CString, OsStr, OsString};
+use crate::fmt;
+use crate::io::{self, Read, Write};
+use crate::iter;
+use crate::marker::PhantomData;
+use crate::mem;
+use crate::memchr;
+use crate::path::{self, PathBuf};
+use crate::ptr;
+use crate::slice;
+use crate::str;
+use crate::sys_common::mutex::Mutex;
+use crate::sys::{cvt, cvt_libc, fd, syscall};
+use crate::vec;
 
 extern {
     #[link_name = "__errno_location"]
@@ -107,7 +107,7 @@ fn description(&self) -> &str { "failed to join paths" }
 }
 
 pub fn current_exe() -> io::Result<PathBuf> {
-    use fs::File;
+    use crate::fs::File;
 
     let mut file = File::open("sys:exe")?;
 
@@ -218,13 +218,13 @@ pub fn page_size() -> usize {
 }
 
 pub fn temp_dir() -> PathBuf {
-    ::env::var_os("TMPDIR").map(PathBuf::from).unwrap_or_else(|| {
+    crate::env::var_os("TMPDIR").map(PathBuf::from).unwrap_or_else(|| {
         PathBuf::from("/tmp")
     })
 }
 
 pub fn home_dir() -> Option<PathBuf> {
-    return ::env::var_os("HOME").map(PathBuf::from);
+    return crate::env::var_os("HOME").map(PathBuf::from);
 }
 
 pub fn exit(code: i32) -> ! {
index 9d5e084feb2d6bbff22b028b5c9dd8db8e0a5785..79b43458d00f3cad06079838d2c0ab3b3c3ef06a 100644 (file)
@@ -1,14 +1,15 @@
 /// The underlying OsString/OsStr implementation on Unix systems: just
 /// a `Vec<u8>`/`[u8]`.
 
-use borrow::Cow;
-use fmt;
-use str;
-use mem;
-use rc::Rc;
-use sync::Arc;
-use sys_common::{AsInner, IntoInner};
-use sys_common::bytestring::debug_fmt_bytestring;
+use crate::borrow::Cow;
+use crate::fmt;
+use crate::str;
+use crate::mem;
+use crate::rc::Rc;
+use crate::sync::Arc;
+use crate::sys_common::{AsInner, IntoInner};
+use crate::sys_common::bytestring::debug_fmt_bytestring;
+
 use core::str::lossy::Utf8Lossy;
 
 #[derive(Clone, Hash)]
index a7a8b03c8b1f6870ed3a01dfd53c151ce62bbabd..618d61e6fcb45eb6d9226286ab8757b5417ed0a3 100644 (file)
@@ -1,5 +1,5 @@
-use ffi::OsStr;
-use path::Prefix;
+use crate::ffi::OsStr;
+use crate::path::Prefix;
 
 #[inline]
 pub fn is_sep_byte(b: u8) -> bool {
index 9e40eadb2370ea831ec0858572b2a31c099d8f0c..911ba9c3f65244801e3f2bb60f0f1f54bd00b5f0 100644 (file)
@@ -1,6 +1,6 @@
-use io;
-use sys::{cvt, syscall};
-use sys::fd::FileDesc;
+use crate::io;
+use crate::sys::{cvt, syscall};
+use crate::sys::fd::FileDesc;
 
 ////////////////////////////////////////////////////////////////////////////////
 // Anonymous pipes
index 81af8eb553d00c15f9312b6a9e9c28c42018a888..8830cdf333ef8b6e6a2e449c3752ebb310305bbb 100644 (file)
@@ -1,20 +1,21 @@
-use env::{split_paths};
-use ffi::{CStr, OsStr};
-use fmt;
-use fs::File;
-use io::{self, prelude::*, BufReader, Error, ErrorKind, SeekFrom};
+use crate::env::{self, split_paths};
+use crate::ffi::{CStr, OsStr};
+use crate::fmt;
+use crate::fs::File;
+use crate::io::{self, prelude::*, BufReader, Error, ErrorKind, SeekFrom};
+use crate::os::unix::ffi::OsStrExt;
+use crate::path::{Path, PathBuf};
+use crate::ptr;
+use crate::sys::ext::fs::MetadataExt;
+use crate::sys::ext::io::AsRawFd;
+use crate::sys::fd::FileDesc;
+use crate::sys::fs::{File as SysFile, OpenOptions};
+use crate::sys::os::{ENV_LOCK, environ};
+use crate::sys::pipe::{self, AnonPipe};
+use crate::sys::{cvt, syscall};
+use crate::sys_common::process::{CommandEnv, DefaultEnvKey};
+
 use libc::{EXIT_SUCCESS, EXIT_FAILURE};
-use os::unix::ffi::OsStrExt;
-use path::{Path, PathBuf};
-use ptr;
-use sys::ext::fs::MetadataExt;
-use sys::ext::io::AsRawFd;
-use sys::fd::FileDesc;
-use sys::fs::{File as SysFile, OpenOptions};
-use sys::os::{ENV_LOCK, environ};
-use sys::pipe::{self, AnonPipe};
-use sys::{cvt, syscall};
-use sys_common::process::{CommandEnv, DefaultEnvKey};
 
 ////////////////////////////////////////////////////////////////////////////////
 // Command
@@ -297,7 +298,7 @@ macro_rules! t {
 
         let program = if self.program.contains(':') || self.program.contains('/') {
             Some(PathBuf::from(&self.program))
-        } else if let Ok(path_env) = ::env::var("PATH") {
+        } else if let Ok(path_env) = env::var("PATH") {
             let mut program = None;
             for mut path in split_paths(&path_env) {
                 path.push(&self.program);
index 8571b38cefa1c53acb86b2149d283309b1dab59e..33f5bdbb5d358e908d8a01b689d0bb933648850b 100644 (file)
@@ -1,6 +1,6 @@
-use io;
-use sys::{cvt, syscall};
-use sys::fd::FileDesc;
+use crate::io;
+use crate::sys::{cvt, syscall};
+use crate::sys::fd::FileDesc;
 
 pub struct Stdin(());
 pub struct Stdout(());
@@ -54,10 +54,10 @@ fn flush(&mut self) -> io::Result<()> {
 }
 
 pub fn is_ebadf(err: &io::Error) -> bool {
-    err.raw_os_error() == Some(::sys::syscall::EBADF as i32)
+    err.raw_os_error() == Some(crate::sys::syscall::EBADF as i32)
 }
 
-pub const STDIN_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE;
+pub const STDIN_BUF_SIZE: usize = crate::sys_common::io::DEFAULT_BUF_SIZE;
 
 pub fn panic_output() -> Option<impl io::Write> {
     Stderr::new().ok()
index 18679a7871e24158f80590471745252adfdae431..ae0b91b4d6c7da6aa9ca52c17f814da1ebdb4305 100644 (file)
@@ -1,10 +1,10 @@
-use boxed::FnBox;
-use ffi::CStr;
-use io;
-use mem;
-use sys_common::thread::start_thread;
-use sys::{cvt, syscall};
-use time::Duration;
+use crate::boxed::FnBox;
+use crate::ffi::CStr;
+use crate::io;
+use crate::mem;
+use crate::sys_common::thread::start_thread;
+use crate::sys::{cvt, syscall};
+use crate::time::Duration;
 
 pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024;
 
index a1929b941659d9c0d9b005f5f1f8e9f2d4f8af75..4bc8c4d5883da0a8e41340be42e55e9c063166f6 100644 (file)
@@ -1,8 +1,8 @@
 #![allow(dead_code)] // not used on all platforms
 
-use collections::BTreeMap;
-use ptr;
-use sync::atomic::{AtomicUsize, Ordering};
+use crate::collections::BTreeMap;
+use crate::ptr;
+use crate::sync::atomic::{AtomicUsize, Ordering};
 
 pub type Key = usize;
 
index 401b7012aa7e9af932d1926453fcc41eb4bcabf2..9db3e85ca9c8b3505bb779010f2503348e1f6067 100644 (file)
@@ -1,8 +1,9 @@
-use cmp::Ordering;
-use fmt;
-use sys::{cvt, syscall};
-use time::Duration;
-use convert::TryInto;
+use crate::cmp::Ordering;
+use crate::fmt;
+use crate::sys::{cvt, syscall};
+use crate::time::Duration;
+use crate::convert::TryInto;
+
 use core::hash::{Hash, Hasher};
 
 const NSEC_PER_SEC: u64 = 1_000_000_000;
index 509a1990d978b46ba7f533c649f958f268f99049..7426f7be9e9615063e4fc419883c78e046451e5f 100644 (file)
@@ -1,5 +1,5 @@
 use core::sync::atomic::{AtomicUsize, Ordering};
-use io::Write;
+use crate::io::Write;
 
 // runtime features
 mod reloc;
@@ -37,7 +37,7 @@
         },
         // We need to wait until the initialization is done.
         BUSY => while RELOC_STATE.load(Ordering::Acquire) == BUSY  {
-            ::core::arch::x86_64::_mm_pause()
+            core::arch::x86_64::_mm_pause()
         },
         // Initialization is done.
         DONE => {},
index b2afacc70b82e504a5925675d12d1473eff03a57..83411cb5b4c26fd9e58672510b2093c9f7f88be0 100644 (file)
@@ -1,7 +1,7 @@
 use super::usercalls::{alloc::UserRef, self};
-use cmp;
-use io::{self, Write};
-use mem;
+use crate::cmp;
+use crate::io::{self, Write};
+use crate::mem;
 
 extern "C" {
     fn take_debug_panic_buf_ptr() -> *mut u8;
index 4dd41d70bd703fb050b6902a52c31225005f28a6..a39841bc36f537939d85aa7f5a1628388b7e6861 100644 (file)
@@ -1,4 +1,4 @@
-use slice::from_raw_parts;
+use crate::slice::from_raw_parts;
 use super::mem;
 
 const R_X86_64_RELATIVE: u32 = 8;
index e1fc36968452766d4e237d1f49d70c04b4ddd150..b2a812c7231da4159a88462b82e18e63151f532c 100644 (file)
@@ -1,8 +1,8 @@
-use sync::atomic::{AtomicUsize, Ordering};
-use ptr;
-use mem;
-use cell::Cell;
-use num::NonZeroUsize;
+use crate::sync::atomic::{AtomicUsize, Ordering};
+use crate::ptr;
+use crate::mem;
+use crate::cell::Cell;
+use crate::num::NonZeroUsize;
 use self::sync_bitset::*;
 
 #[cfg(target_pointer_width="64")]
@@ -152,9 +152,9 @@ pub fn destroy(key: Key) {
 }
 
 mod sync_bitset {
-    use sync::atomic::{AtomicUsize, Ordering};
-    use iter::{Enumerate, Peekable};
-    use slice::Iter;
+    use crate::sync::atomic::{AtomicUsize, Ordering};
+    use crate::iter::{Enumerate, Peekable};
+    use crate::slice::Iter;
     use super::{TLS_KEYS_BITSET_SIZE, USIZE_BITS};
 
     /// A bitset that can be used synchronously.
index 0ccbbbc65015d0c1fa01e0e12baef64580458bc0..b787bd1a5abac44b088bc00fe8b8dea2d3f006ab 100644 (file)
@@ -1,11 +1,11 @@
 #![allow(unused)]
 
-use ptr::{self, NonNull};
-use mem;
-use cell::UnsafeCell;
-use slice;
-use ops::{Deref, DerefMut, Index, IndexMut, CoerceUnsized};
-use slice::SliceIndex;
+use crate::ptr::{self, NonNull};
+use crate::mem;
+use crate::cell::UnsafeCell;
+use crate::slice;
+use crate::ops::{Deref, DerefMut, Index, IndexMut, CoerceUnsized};
+use crate::slice::SliceIndex;
 
 use fortanix_sgx_abi::*;
 use super::super::mem::is_user_range;
index 511d6e9e9273ab870cfbf9ca839438b49c9830a4..d84b6154cbebf401dc14110d01aeec20e8557ad3 100644 (file)
@@ -1,5 +1,5 @@
-use io::{Error as IoError, Result as IoResult};
-use time::Duration;
+use crate::io::{Error as IoError, Result as IoResult};
+use crate::time::Duration;
 
 pub(crate) mod alloc;
 #[macro_use]
@@ -22,7 +22,7 @@ pub fn read(fd: Fd, buf: &mut [u8]) -> IoResult<usize> {
 #[unstable(feature = "sgx_platform", issue = "56975")]
 pub fn read_alloc(fd: Fd) -> IoResult<Vec<u8>> {
     unsafe {
-        let userbuf = ByteBuffer { data: ::ptr::null_mut(), len: 0 };
+        let userbuf = ByteBuffer { data: crate::ptr::null_mut(), len: 0 };
         let mut userbuf = alloc::User::new_from_enclave(&userbuf);
         raw::read_alloc(fd, userbuf.as_raw_mut_ptr()).from_sgx_result()?;
         Ok(userbuf.copy_user_buffer())
index 447f20584f859ea6bde8abc77ffb9ffca41eb1f9..ad0b6d7b3d8ecb65e5f95476a5042b7bf7ba500a 100644 (file)
@@ -3,8 +3,8 @@
 #[unstable(feature = "sgx_platform", issue = "56975")]
 pub use fortanix_sgx_abi::*;
 
-use ptr::NonNull;
-use num::NonZeroU64;
+use crate::ptr::NonNull;
+use crate::num::NonZeroU64;
 
 #[repr(C)]
 struct UsercallReturn(u64, u64);
@@ -35,7 +35,7 @@ pub unsafe fn do_usercall(nr: NonZeroU64, p1: u64, p2: u64, p3: u64, p4: u64, ab
 type Register = u64;
 
 trait RegisterArgument {
-    fn from_register(Register) -> Self;
+    fn from_register(_: Register) -> Self;
     fn into_register(self) -> Register;
 }
 
index 95284190bddceae982ba7b3455c5d3f67ea3ec5d..94dc8ec25b5872e5f9339c0c6260388740944b02 100644 (file)
@@ -1,6 +1,4 @@
-extern crate dlmalloc;
-
-use alloc::{GlobalAlloc, Layout, System};
+use crate::alloc::{GlobalAlloc, Layout, System};
 
 use super::waitqueue::SpinMutex;
 
index bc138a64019a5a738fb417dd4915cef228517ac3..b73bf9213b7727ec677bebff4af9618db050a990 100644 (file)
@@ -1,9 +1,9 @@
-use ffi::OsString;
 use super::abi::usercalls::{alloc, raw::ByteBuffer};
-use sync::atomic::{AtomicUsize, Ordering};
-use sys::os_str::Buf;
-use sys_common::FromInner;
-use slice;
+use crate::ffi::OsString;
+use crate::sync::atomic::{AtomicUsize, Ordering};
+use crate::sys::os_str::Buf;
+use crate::sys_common::FromInner;
+use crate::slice;
 
 static ARGS: AtomicUsize = AtomicUsize::new(0);
 type ArgsStore = Vec<OsString>;
index 2b8e1da05791dee62231a0c0c1aeeb02ee26cadf..d0361574e39d66811209a0211e244cba965c332b 100644 (file)
@@ -1,9 +1,10 @@
-use io;
-use error::Error;
-use libc;
-use sys_common::backtrace::Frame;
+use crate::io;
+use crate::error::Error;
+use crate::fmt;
+use crate::sys_common::backtrace::Frame;
+use crate::sys::sgx::abi::mem::image_base;
+
 use unwind as uw;
-use sys::sgx::abi::mem::image_base;
 
 pub struct BacktraceContext;
 
@@ -21,8 +22,8 @@ fn description(&self) -> &'static str {
     }
 }
 
-impl ::fmt::Display for UnwindError {
-    fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+impl fmt::Display for UnwindError {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "{}: {:?}", self.description(), self.0)
     }
 }
index b42e5490c72dda7ff77ab5dfca6f30fe66cfedf4..e9a7684f74d00f3b6b26568799bf8695c3ffa3a3 100644 (file)
@@ -1,5 +1,5 @@
-use sys::mutex::Mutex;
-use time::Duration;
+use crate::sys::mutex::Mutex;
+use crate::time::Duration;
 
 use super::waitqueue::{WaitVariable, WaitQueue, SpinMutex};
 
index 97f7d9181a53906c5a023c07c990fb14eda4d8d8..53fb371947a99c9dabc1caea52b282d17bcdffac 100644 (file)
@@ -4,7 +4,7 @@
 //! Software Developer's Manual, Volume 3, Chapter 40.
 #![unstable(feature = "sgx_platform", issue = "56975")]
 
-use mem::MaybeUninit;
+use crate::mem::MaybeUninit;
 
 /// Wrapper struct to force 16-byte alignment.
 #[repr(align(16))]
index 7b0ffea49ae7caaf7c9af35ea0cf203a60c2bf98..ad7ade9b17d81c2ce54cc11b589100d20919eff9 100644 (file)
@@ -2,10 +2,10 @@
 
 #![unstable(feature = "sgx_platform", issue = "56975")]
 
-use ffi::{OsStr, OsString};
-use mem;
-use sys::os_str::Buf;
-use sys_common::{FromInner, IntoInner, AsInner};
+use crate::ffi::{OsStr, OsString};
+use crate::mem;
+use crate::sys::os_str::Buf;
+use crate::sys_common::{FromInner, IntoInner, AsInner};
 
 /// SGX-specific extensions to [`OsString`].
 ///
index 1eb269783c5ab288c90470334832c3fed7c78464..fc88d10d3eddba72eb824abc4218f306123a75fc 100644 (file)
@@ -4,9 +4,9 @@
 //! description of [`TryIntoRawFd`](trait.TryIntoRawFd.html) for more details.
 #![unstable(feature = "sgx_platform", issue = "56975")]
 
-pub use sys::abi::usercalls::raw::Fd as RawFd;
-use net;
-use sys::{self, AsInner, FromInner, IntoInner, TryIntoInner};
+pub use crate::sys::abi::usercalls::raw::Fd as RawFd;
+use crate::net;
+use crate::sys::{self, AsInner, FromInner, IntoInner, TryIntoInner};
 
 /// A trait to extract the raw SGX file descriptor from an underlying
 /// object.
index 69077728b1a9ab08aa554c3ae8214af890ed4643..a9924f55f12b0504bdf65c42017b5af2dd42780d 100644 (file)
@@ -1,8 +1,8 @@
 use fortanix_sgx_abi::Fd;
 
-use io;
-use mem;
-use sys::{AsInner, FromInner, IntoInner};
+use crate::io;
+use crate::mem;
+use crate::sys::{AsInner, FromInner, IntoInner};
 use super::abi::usercalls;
 
 #[derive(Debug)]
index 8b1c4476bc4178dd321d007c62264b7ead806558..485d2c87fbd2d2003f2bf7dea01f192ae4e1243c 100644 (file)
@@ -1,10 +1,10 @@
-use ffi::OsString;
-use fmt;
-use hash::{Hash, Hasher};
-use io::{self, SeekFrom};
-use path::{Path, PathBuf};
-use sys::time::SystemTime;
-use sys::{unsupported, Void};
+use crate::ffi::OsString;
+use crate::fmt;
+use crate::hash::{Hash, Hasher};
+use crate::io::{self, SeekFrom};
+use crate::path::{Path, PathBuf};
+use crate::sys::time::SystemTime;
+use crate::sys::{unsupported, Void};
 
 pub struct File(Void);
 
index 403dd61187fc3146ff308e158a29d6f2f385677f..325df7688f37b21ca39b1ef69a15faa37484403d 100644 (file)
@@ -3,8 +3,9 @@
 //! This module contains the facade (aka platform-specific) implementations of
 //! OS level functionality for Fortanix SGX.
 
-use os::raw::c_char;
-use sync::atomic::{AtomicBool, Ordering};
+use crate::io::ErrorKind;
+use crate::os::raw::c_char;
+use crate::sync::atomic::{AtomicBool, Ordering};
 
 pub mod abi;
 mod waitqueue;
@@ -41,12 +42,12 @@ pub fn init() {
 
 /// This function is used to implement functionality that simply doesn't exist.
 /// Programs relying on this functionality will need to deal with the error.
-pub fn unsupported<T>() -> ::io::Result<T> {
+pub fn unsupported<T>() -> crate::io::Result<T> {
     Err(unsupported_err())
 }
 
-pub fn unsupported_err() -> ::io::Error {
-    ::io::Error::new(::io::ErrorKind::Other,
+pub fn unsupported_err() -> crate::io::Error {
+    crate::io::Error::new(ErrorKind::Other,
                    "operation not supported on SGX yet")
 }
 
@@ -55,58 +56,58 @@ pub fn unsupported_err() -> ::io::Error {
 /// returned, the program might very well be able to function normally. This is
 /// what happens when `SGX_INEFFECTIVE_ERROR` is set to `true`. If it is
 /// `false`, the behavior is the same as `unsupported`.
-pub fn sgx_ineffective<T>(v: T) -> ::io::Result<T> {
+pub fn sgx_ineffective<T>(v: T) -> crate::io::Result<T> {
     static SGX_INEFFECTIVE_ERROR: AtomicBool = AtomicBool::new(false);
     if SGX_INEFFECTIVE_ERROR.load(Ordering::Relaxed) {
-        Err(::io::Error::new(::io::ErrorKind::Other,
+        Err(crate::io::Error::new(ErrorKind::Other,
                        "operation can't be trusted to have any effect on SGX"))
     } else {
         Ok(v)
     }
 }
 
-pub fn decode_error_kind(code: i32) -> ::io::ErrorKind {
+pub fn decode_error_kind(code: i32) -> ErrorKind {
     use fortanix_sgx_abi::Error;
 
     // FIXME: not sure how to make sure all variants of Error are covered
     if code == Error::NotFound as _ {
-        ::io::ErrorKind::NotFound
+        ErrorKind::NotFound
     } else if code == Error::PermissionDenied as _ {
-        ::io::ErrorKind::PermissionDenied
+        ErrorKind::PermissionDenied
     } else if code == Error::ConnectionRefused as _ {
-        ::io::ErrorKind::ConnectionRefused
+        ErrorKind::ConnectionRefused
     } else if code == Error::ConnectionReset as _ {
-        ::io::ErrorKind::ConnectionReset
+        ErrorKind::ConnectionReset
     } else if code == Error::ConnectionAborted as _ {
-        ::io::ErrorKind::ConnectionAborted
+        ErrorKind::ConnectionAborted
     } else if code == Error::NotConnected as _ {
-        ::io::ErrorKind::NotConnected
+        ErrorKind::NotConnected
     } else if code == Error::AddrInUse as _ {
-        ::io::ErrorKind::AddrInUse
+        ErrorKind::AddrInUse
     } else if code == Error::AddrNotAvailable as _ {
-        ::io::ErrorKind::AddrNotAvailable
+        ErrorKind::AddrNotAvailable
     } else if code == Error::BrokenPipe as _ {
-        ::io::ErrorKind::BrokenPipe
+        ErrorKind::BrokenPipe
     } else if code == Error::AlreadyExists as _ {
-        ::io::ErrorKind::AlreadyExists
+        ErrorKind::AlreadyExists
     } else if code == Error::WouldBlock as _ {
-        ::io::ErrorKind::WouldBlock
+        ErrorKind::WouldBlock
     } else if code == Error::InvalidInput as _ {
-        ::io::ErrorKind::InvalidInput
+        ErrorKind::InvalidInput
     } else if code == Error::InvalidData as _ {
-        ::io::ErrorKind::InvalidData
+        ErrorKind::InvalidData
     } else if code == Error::TimedOut as _ {
-        ::io::ErrorKind::TimedOut
+        ErrorKind::TimedOut
     } else if code == Error::WriteZero as _ {
-        ::io::ErrorKind::WriteZero
+        ErrorKind::WriteZero
     } else if code == Error::Interrupted as _ {
-        ::io::ErrorKind::Interrupted
+        ErrorKind::Interrupted
     } else if code == Error::Other as _ {
-        ::io::ErrorKind::Other
+        ErrorKind::Other
     } else if code == Error::UnexpectedEof as _ {
-        ::io::ErrorKind::UnexpectedEof
+        ErrorKind::UnexpectedEof
     } else {
-        ::io::ErrorKind::Other
+        ErrorKind::Other
     }
 }
 
@@ -131,9 +132,9 @@ pub unsafe fn abort_internal() -> ! {
 pub fn hashmap_random_keys() -> (u64, u64) {
     fn rdrand64() -> u64 {
         unsafe {
-            let mut ret: u64 = ::mem::uninitialized();
+            let mut ret: u64 = crate::mem::uninitialized();
             for _ in 0..10 {
-                if ::arch::x86_64::_rdrand64_step(&mut ret) == 1 {
+                if crate::arch::x86_64::_rdrand64_step(&mut ret) == 1 {
                     return ret;
                 }
             }
@@ -143,7 +144,7 @@ fn rdrand64() -> u64 {
     (rdrand64(), rdrand64())
 }
 
-pub use sys_common::{AsInner, FromInner, IntoInner};
+pub use crate::sys_common::{AsInner, FromInner, IntoInner};
 
 pub trait TryIntoInner<Inner>: Sized {
     fn try_into_inner(self) -> Result<Inner, Self>;
index c4c2de43ff7df8b43ff3cb9247454148f3f9693a..ab8b2681393f89a4fea26b6261e4b4f1182cacfc 100644 (file)
@@ -1,12 +1,12 @@
-use fmt;
-use io::{self, IoVec, IoVecMut};
-use net::{SocketAddr, Shutdown, Ipv4Addr, Ipv6Addr, ToSocketAddrs};
-use time::Duration;
-use sys::{unsupported, Void, sgx_ineffective, AsInner, FromInner, IntoInner, TryIntoInner};
-use sys::fd::FileDesc;
-use convert::TryFrom;
-use error;
-use sync::Arc;
+use crate::fmt;
+use crate::io::{self, IoVec, IoVecMut};
+use crate::net::{SocketAddr, Shutdown, Ipv4Addr, Ipv6Addr, ToSocketAddrs};
+use crate::time::Duration;
+use crate::sys::{unsupported, Void, sgx_ineffective, AsInner, FromInner, IntoInner, TryIntoInner};
+use crate::sys::fd::FileDesc;
+use crate::convert::TryFrom;
+use crate::error;
+use crate::sync::Arc;
 
 use super::abi::usercalls;
 
index b1e4d371a677937b62c7d62036d4f76d842bf659..2725e66ce5de4001d43489e1e517b8264e0118fd 100644 (file)
@@ -1,17 +1,17 @@
 use fortanix_sgx_abi::{Error, RESULT_SUCCESS};
 
-use error::Error as StdError;
-use ffi::{OsString, OsStr};
-use fmt;
-use io;
-use path::{self, PathBuf};
-use str;
-use sys::{unsupported, Void, sgx_ineffective, decode_error_kind};
-use collections::HashMap;
-use vec;
-use sync::Mutex;
-use sync::atomic::{AtomicUsize, Ordering};
-use sync::Once;
+use crate::error::Error as StdError;
+use crate::ffi::{OsString, OsStr};
+use crate::fmt;
+use crate::io;
+use crate::path::{self, PathBuf};
+use crate::str;
+use crate::sys::{unsupported, Void, sgx_ineffective, decode_error_kind};
+use crate::collections::HashMap;
+use crate::vec;
+use crate::sync::Mutex;
+use crate::sync::atomic::{AtomicUsize, Ordering};
+use crate::sync::Once;
 
 pub fn errno() -> i32 {
     RESULT_SUCCESS
index 9d5e084feb2d6bbff22b028b5c9dd8db8e0a5785..79b43458d00f3cad06079838d2c0ab3b3c3ef06a 100644 (file)
@@ -1,14 +1,15 @@
 /// The underlying OsString/OsStr implementation on Unix systems: just
 /// a `Vec<u8>`/`[u8]`.
 
-use borrow::Cow;
-use fmt;
-use str;
-use mem;
-use rc::Rc;
-use sync::Arc;
-use sys_common::{AsInner, IntoInner};
-use sys_common::bytestring::debug_fmt_bytestring;
+use crate::borrow::Cow;
+use crate::fmt;
+use crate::str;
+use crate::mem;
+use crate::rc::Rc;
+use crate::sync::Arc;
+use crate::sys_common::{AsInner, IntoInner};
+use crate::sys_common::bytestring::debug_fmt_bytestring;
+
 use core::str::lossy::Utf8Lossy;
 
 #[derive(Clone, Hash)]
index 90b1fa7c97b967713d48e140e612c58e6e96eecb..1115de1fbe5bafa40b043a2d0dfd02d1b79f960d 100644 (file)
@@ -1,5 +1,5 @@
-use path::Prefix;
-use ffi::OsStr;
+use crate::path::Prefix;
+use crate::ffi::OsStr;
 
 #[inline]
 pub fn is_sep_byte(b: u8) -> bool {
index ac48a6dc03323e51940bfd02fbea3b3bf08bbc41..2582b993b608eda93136a5558784899814987cae 100644 (file)
@@ -1,5 +1,5 @@
-use io;
-use sys::Void;
+use crate::io;
+use crate::sys::Void;
 
 pub struct AnonPipe(Void);
 
index 5357d931c73677ff820626a285f985262db28c44..c49daaa16320e2b04385cf5e1212948e6b4f7edd 100644 (file)
@@ -1,10 +1,10 @@
-use ffi::OsStr;
-use fmt;
-use io;
-use sys::fs::File;
-use sys::pipe::AnonPipe;
-use sys::{unsupported, Void};
-use sys_common::process::{CommandEnv, DefaultEnvKey};
+use crate::ffi::OsStr;
+use crate::fmt;
+use crate::io;
+use crate::sys::fs::File;
+use crate::sys::pipe::AnonPipe;
+use crate::sys::{unsupported, Void};
+use crate::sys_common::process::{CommandEnv, DefaultEnvKey};
 
 ////////////////////////////////////////////////////////////////////////////////
 // Command
index 4dfbe86d14f4dedd2dd13f9d40925a127eb959d4..372760bbf26b4221959e1f7a243932d630785c5e 100644 (file)
@@ -1,12 +1,12 @@
-use alloc::{self, Layout};
-use num::NonZeroUsize;
-use slice;
-use str;
+use crate::alloc::{self, Layout};
+use crate::num::NonZeroUsize;
+use crate::slice;
+use crate::str;
 
 use super::waitqueue::{
     try_lock_or_false, NotifiedTcs, SpinMutex, SpinMutexGuard, WaitQueue, WaitVariable,
 };
-use mem;
+use crate::mem;
 
 pub struct RWLock {
     readers: SpinMutex<WaitVariable<Option<NonZeroUsize>>>,
@@ -206,7 +206,7 @@ pub unsafe fn destroy(&self) {}
 #[no_mangle]
 // NB. used by both libunwind and libpanic_abort
 pub unsafe extern "C" fn __rust_abort() {
-    ::sys::abort_internal();
+    crate::sys::abort_internal();
 }
 
 #[no_mangle]
@@ -224,8 +224,8 @@ mod tests {
 
     use super::*;
     use core::array::FixedSizeArray;
-    use mem::MaybeUninit;
-    use {mem, ptr};
+    use crate::mem::MaybeUninit;
+    use crate::{mem, ptr};
 
     // The below test verifies that the bytes of initialized RWLock are the ones
     // we use in libunwind.
index 57d66ed9a853c7dc3690b0e708af347221de4bbe..f2c6892bfb7fde6f773ea8613b0ba927745063cd 100644 (file)
@@ -1,7 +1,7 @@
 use fortanix_sgx_abi as abi;
 
-use io;
-use sys::fd::FileDesc;
+use crate::io;
+use crate::sys::fd::FileDesc;
 
 pub struct Stdin(());
 pub struct Stdout(());
@@ -52,7 +52,7 @@ fn flush(&mut self) -> io::Result<()> {
     }
 }
 
-pub const STDIN_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE;
+pub const STDIN_BUF_SIZE: usize = crate::sys_common::io::DEFAULT_BUF_SIZE;
 
 pub fn is_ebadf(err: &io::Error) -> bool {
     // FIXME: Rust normally maps Unix EBADF to `Other`
index b4bdb03e61af65e0403c1cf159393bea8b030ed3..13569062ac184cfd99675c800c0c0bb9d33de149 100644 (file)
@@ -1,7 +1,7 @@
-use boxed::FnBox;
-use ffi::CStr;
-use io;
-use time::Duration;
+use crate::boxed::FnBox;
+use crate::ffi::CStr;
+use crate::io;
+use crate::time::Duration;
 
 use super::abi::usercalls;
 
@@ -10,9 +10,9 @@
 pub const DEFAULT_MIN_STACK_SIZE: usize = 4096;
 
 mod task_queue {
-    use sync::{Mutex, MutexGuard, Once};
-    use sync::mpsc;
-    use boxed::FnBox;
+    use crate::sync::{Mutex, MutexGuard, Once};
+    use crate::sync::mpsc;
+    use crate::boxed::FnBox;
 
     pub type JoinHandle = mpsc::Receiver<()>;
 
index 407fe72b0e62354b8a9af49c93cbb7a0f51a1024..e4f789c3e36565db4086523f55706df3820db074 100644 (file)
@@ -1,4 +1,4 @@
-use time::Duration;
+use crate::time::Duration;
 use super::abi::usercalls;
 
 #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
index aec643b3175b40f2bfb20de7f9a4a4fde998bcca..1dbf2afbf4987e7b47368d7ecca303b69200922f 100644 (file)
@@ -10,8 +10,8 @@
 /// recorded in the enclave. The wakeup event state is protected by a spinlock.
 /// The queue and associated wait state are stored in a `WaitVariable`.
 
-use ops::{Deref, DerefMut};
-use num::NonZeroUsize;
+use crate::ops::{Deref, DerefMut};
+use crate::num::NonZeroUsize;
 
 use fortanix_sgx_abi::{Tcs, EV_UNPARK, WAIT_INDEFINITE};
 use super::abi::usercalls;
@@ -211,8 +211,8 @@ pub fn notify_all<T>(mut guard: SpinMutexGuard<WaitVariable<T>>)
 /// A doubly-linked list where callers are in charge of memory allocation
 /// of the nodes in the list.
 mod unsafe_list {
-    use ptr::NonNull;
-    use mem;
+    use crate::ptr::NonNull;
+    use crate::mem;
 
     pub struct UnsafeListEntry<T> {
         next: NonNull<UnsafeListEntry<T>>,
@@ -341,7 +341,7 @@ pub unsafe fn pop<'a>(&mut self) -> Option<&'a T> {
     #[cfg(test)]
     mod tests {
         use super::*;
-        use cell::Cell;
+        use crate::cell::Cell;
 
         unsafe fn assert_empty<T>(list: &mut UnsafeList<T>) {
             assert!(list.pop().is_none(), "assertion failed: list is not empty");
@@ -404,9 +404,9 @@ fn cell() {
 /// Trivial spinlock-based implementation of `sync::Mutex`.
 // FIXME: Perhaps use Intel TSX to avoid locking?
 mod spin_mutex {
-    use cell::UnsafeCell;
-    use sync::atomic::{AtomicBool, Ordering, spin_loop_hint};
-    use ops::{Deref, DerefMut};
+    use crate::cell::UnsafeCell;
+    use crate::sync::atomic::{AtomicBool, Ordering, spin_loop_hint};
+    use crate::ops::{Deref, DerefMut};
 
     #[derive(Default)]
     pub struct SpinMutex<T> {
@@ -496,8 +496,8 @@ mod tests {
         #![allow(deprecated)]
 
         use super::*;
-        use sync::Arc;
-        use thread;
+        use crate::sync::Arc;
+        use crate::thread;
 
         #[test]
         fn sleep() {
@@ -519,8 +519,8 @@ fn sleep() {
 #[cfg(test)]
 mod tests {
     use super::*;
-    use sync::Arc;
-    use thread;
+    use crate::sync::Arc;
+    use crate::thread;
 
     #[test]
     fn queue() {
index 93e8e0e669671ab1fb7e68f7017f3f46a2fb654b..8e8f5017da75a1abc8fde700edb510caa45a13d0 100644 (file)
@@ -1,7 +1,6 @@
-use ptr;
-use libc;
-use sys_common::alloc::{MIN_ALIGN, realloc_fallback};
-use alloc::{GlobalAlloc, Layout, System};
+use crate::ptr;
+use crate::sys_common::alloc::{MIN_ALIGN, realloc_fallback};
+use crate::alloc::{GlobalAlloc, Layout, System};
 
 #[stable(feature = "alloc_system_type", since = "1.28.0")]
 unsafe impl GlobalAlloc for System {
index 986fa27ede6667e0325220ca94d058a9652ec0bd..6774160bb2561596117de3b16800bd8e7ff31fcf 100644 (file)
@@ -21,7 +21,7 @@
 use libc::{c_int, c_void, sighandler_t, size_t, ssize_t};
 use libc::{ftruncate, pread, pwrite};
 
-use io;
+use crate::io;
 use super::{cvt, cvt_r};
 
 // The `log2` and `log2f` functions apparently appeared in android-18, or at
 
 #[cfg(not(test))]
 pub fn log2f32(f: f32) -> f32 {
-    f.ln() * ::f32::consts::LOG2_E
+    f.ln() * crate::f32::consts::LOG2_E
 }
 
 #[cfg(not(test))]
 pub fn log2f64(f: f64) -> f64 {
-    f.ln() * ::f64::consts::LOG2_E
+    f.ln() * crate::f64::consts::LOG2_E
 }
 
 // Back in the day [1] the `signal` function was just an inline wrapper
@@ -117,7 +117,7 @@ pub fn ftruncate64(fd: c_int, size: u64) -> io::Result<()> {
 pub unsafe fn cvt_pread64(fd: c_int, buf: *mut c_void, count: size_t, offset: i64)
     -> io::Result<ssize_t>
 {
-    use convert::TryInto;
+    use crate::convert::TryInto;
     weak!(fn pread64(c_int, *mut c_void, size_t, i64) -> ssize_t);
     pread64.get().map(|f| cvt(f(fd, buf, count, offset))).unwrap_or_else(|| {
         if let Ok(o) = offset.try_into() {
@@ -133,7 +133,7 @@ pub unsafe fn cvt_pread64(fd: c_int, buf: *mut c_void, count: size_t, offset: i6
 pub unsafe fn cvt_pwrite64(fd: c_int, buf: *const c_void, count: size_t, offset: i64)
     -> io::Result<ssize_t>
 {
-    use convert::TryInto;
+    use crate::convert::TryInto;
     weak!(fn pwrite64(c_int, *const c_void, size_t, i64) -> ssize_t);
     pwrite64.get().map(|f| cvt(f(fd, buf, count, offset))).unwrap_or_else(|| {
         if let Ok(o) = offset.try_into() {
index db1c5f4fea54c6cf8776d38a822e2dcc47d653dd..18de1096df2a208a3121447a8548c0ff804c7b72 100644 (file)
@@ -5,9 +5,9 @@
 
 #![allow(dead_code)] // runtime init functions not used during testing
 
-use ffi::OsString;
-use marker::PhantomData;
-use vec;
+use crate::ffi::OsString;
+use crate::marker::PhantomData;
+use crate::vec;
 
 /// One-time global initialization.
 pub unsafe fn init(argc: isize, argv: *const *const u8) { imp::init(argc, argv) }
@@ -59,14 +59,13 @@ fn next_back(&mut self) -> Option<OsString> { self.iter.next_back() }
           target_os = "fuchsia",
           target_os = "hermit"))]
 mod imp {
-    use os::unix::prelude::*;
-    use ptr;
-    use ffi::{CStr, OsString};
-    use marker::PhantomData;
-    use libc;
+    use crate::os::unix::prelude::*;
+    use crate::ptr;
+    use crate::ffi::{CStr, OsString};
+    use crate::marker::PhantomData;
     use super::Args;
 
-    use sys_common::mutex::Mutex;
+    use crate::sys_common::mutex::Mutex;
 
     static mut ARGC: isize = 0;
     static mut ARGV: *const *const u8 = ptr::null();
@@ -107,9 +106,8 @@ fn clone() -> Vec<OsString> {
 #[cfg(any(target_os = "macos",
           target_os = "ios"))]
 mod imp {
-    use ffi::CStr;
-    use marker::PhantomData;
-    use libc;
+    use crate::ffi::CStr;
+    use crate::marker::PhantomData;
     use super::Args;
 
     pub unsafe fn init(_argc: isize, _argv: *const *const u8) {
@@ -120,7 +118,7 @@ pub fn cleanup() {
 
     #[cfg(target_os = "macos")]
     pub fn args() -> Args {
-        use os::unix::prelude::*;
+        use crate::os::unix::prelude::*;
         extern {
             // These functions are in crt_externs.h.
             fn _NSGetArgc() -> *mut libc::c_int;
@@ -155,9 +153,9 @@ pub fn args() -> Args {
     // res
     #[cfg(target_os = "ios")]
     pub fn args() -> Args {
-        use ffi::OsString;
-        use mem;
-        use str;
+        use crate::ffi::OsString;
+        use crate::mem;
+        use crate::str;
 
         extern {
             fn sel_registerName(name: *const libc::c_uchar) -> Sel;
index 79c3e39d8f8dd4fa75c6950c98a37529a5db1757..0887e5a4df937ed97486ceb77367defe4ab1f833 100644 (file)
@@ -83,8 +83,9 @@
 
 #[cfg(not(target_os = "emscripten"))]
 pub mod gnu {
-    use io;
-    use fs;
+    use crate::io;
+    use crate::fs;
+
     use libc::c_char;
 
     #[cfg(not(any(target_os = "macos", target_os = "ios")))]
@@ -94,8 +95,8 @@ pub fn get_executable_filename() -> io::Result<(Vec<c_char>, fs::File)> {
 
     #[cfg(any(target_os = "macos", target_os = "ios"))]
     pub fn get_executable_filename() -> io::Result<(Vec<c_char>, fs::File)> {
-        use env;
-        use os::unix::ffi::OsStrExt;
+        use crate::env;
+        use crate::os::unix::ffi::OsStrExt;
 
         let filename = env::current_exe()?;
         let file = fs::File::open(&filename)?;
index 09715db8c1a3490c3769a6cce60b44993ce47f56..cf3bda640e92b52a16bb1680153dc0a6e7d03d39 100644 (file)
@@ -1,9 +1,8 @@
-use io;
-use intrinsics;
-use ffi::CStr;
-use libc;
-use sys::backtrace::BacktraceContext;
-use sys_common::backtrace::Frame;
+use crate::io;
+use crate::intrinsics;
+use crate::ffi::CStr;
+use crate::sys::backtrace::BacktraceContext;
+use crate::sys_common::backtrace::Frame;
 
 pub fn resolve_symname<F>(frame: Frame,
                           callback: F,
index d0303e6995f8bb8c767eab881b120b2aea237525..d090caede437abc25749831a46fe2d99896a7300 100644 (file)
@@ -1,8 +1,8 @@
 mod dladdr;
 
-use sys::backtrace::BacktraceContext;
-use sys_common::backtrace::Frame;
-use io;
+use crate::sys::backtrace::BacktraceContext;
+use crate::sys_common::backtrace::Frame;
+use crate::io;
 
 #[cfg(target_os = "emscripten")]
 pub use self::dladdr::resolve_symname;
@@ -16,14 +16,14 @@ pub fn foreach_symbol_fileline<F>(_: Frame, _: F, _: &BacktraceContext) -> io::R
 }
 
 #[cfg(not(target_os = "emscripten"))]
-pub use sys_common::gnu::libbacktrace::foreach_symbol_fileline;
+pub use crate::sys_common::gnu::libbacktrace::foreach_symbol_fileline;
 
 #[cfg(not(target_os = "emscripten"))]
 pub fn resolve_symname<F>(frame: Frame, callback: F, bc: &BacktraceContext) -> io::Result<()>
 where
     F: FnOnce(Option<&str>) -> io::Result<()>
 {
-    ::sys_common::gnu::libbacktrace::resolve_symname(frame, |symname| {
+    crate::sys_common::gnu::libbacktrace::resolve_symname(frame, |symname| {
         if symname.is_some() {
             callback(symname)
         } else {
index 236762c5eb5df8f753ef9c4a78abf51b54c065d6..a628d107ad6fbd94f523f7c49a951cdea4c941c6 100644 (file)
@@ -8,10 +8,10 @@
 /// simple to use it should be used only on iOS devices as the only viable
 /// option.
 
-use io;
-use libc;
-use sys::backtrace::BacktraceContext;
-use sys_common::backtrace::Frame;
+use crate::io;
+use crate::ptr;
+use crate::sys::backtrace::BacktraceContext;
+use crate::sys_common::backtrace::Frame;
 
 #[inline(never)] // if we know this is a function call, we can skip it when
                  // tracing
@@ -20,7 +20,7 @@ pub fn unwind_backtrace(frames: &mut [Frame])
 {
     const FRAME_LEN: usize = 100;
     assert!(FRAME_LEN >= frames.len());
-    let mut raw_frames = [::ptr::null_mut(); FRAME_LEN];
+    let mut raw_frames = [ptr::null_mut(); FRAME_LEN];
     let nb_frames = unsafe {
         backtrace(raw_frames.as_mut_ptr(), raw_frames.len() as libc::c_int)
     } as usize;
index 72a7968c514ca8063c9c4fac66ff47dbd89638a0..abbeca0fde6e7e26056b6453edec68a69820a8c3 100644 (file)
@@ -1,8 +1,8 @@
-use error::Error;
-use io;
-use libc;
-use sys::backtrace::BacktraceContext;
-use sys_common::backtrace::Frame;
+use crate::error::Error;
+use crate::fmt;
+use crate::io;
+use crate::sys::backtrace::BacktraceContext;
+use crate::sys_common::backtrace::Frame;
 
 use unwind as uw;
 
@@ -20,8 +20,8 @@ fn description(&self) -> &'static str {
     }
 }
 
-impl ::fmt::Display for UnwindError {
-    fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
+impl fmt::Display for UnwindError {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "{}: {:?}", self.description(), self.0)
     }
 }
index 3e048d5c6e4f331ccae362e5c4193db79e145ae7..47fb6792f08ae9966319de6d0cab3a522151955f 100644 (file)
@@ -1,7 +1,6 @@
-use cell::UnsafeCell;
-use libc;
-use sys::mutex::{self, Mutex};
-use time::Duration;
+use crate::cell::UnsafeCell;
+use crate::sys::mutex::{self, Mutex};
+use crate::time::Duration;
 
 pub struct Condvar { inner: UnsafeCell<libc::pthread_cond_t> }
 
@@ -41,7 +40,7 @@ pub unsafe fn init(&mut self) {}
                   target_os = "android",
                   target_os = "hermit")))]
     pub unsafe fn init(&mut self) {
-        use mem;
+        use crate::mem;
         let mut attr: libc::pthread_condattr_t = mem::uninitialized();
         let r = libc::pthread_condattr_init(&mut attr);
         assert_eq!(r, 0);
@@ -80,7 +79,7 @@ pub unsafe fn wait(&self, mutex: &Mutex) {
                   target_os = "android",
                   target_os = "hermit")))]
     pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool {
-        use mem;
+        use crate::mem;
 
         let mut now: libc::timespec = mem::zeroed();
         let r = libc::clock_gettime(libc::CLOCK_MONOTONIC, &mut now);
@@ -110,8 +109,8 @@ pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool {
     // https://github.com/llvm-mirror/libcxx/blob/release_35/include/__mutex_base#L367
     #[cfg(any(target_os = "macos", target_os = "ios", target_os = "android", target_os = "hermit"))]
     pub unsafe fn wait_timeout(&self, mutex: &Mutex, mut dur: Duration) -> bool {
-        use ptr;
-        use time::Instant;
+        use crate::ptr;
+        use crate::time::Instant;
 
         // 1000 years
         let max_dur = Duration::from_secs(1000 * 365 * 86400);
index d1c3cd82ac514b9463da4e59af2a52c3c797d400..0c02323981521cbd3a561e99d2b8bac78043c8b3 100644 (file)
@@ -2,10 +2,10 @@
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
-use ffi::{OsStr, OsString};
-use mem;
-use sys::os_str::Buf;
-use sys_common::{FromInner, IntoInner, AsInner};
+use crate::ffi::{OsStr, OsString};
+use crate::mem;
+use crate::sys::os_str::Buf;
+use crate::sys_common::{FromInner, IntoInner, AsInner};
 
 /// Unix-specific extensions to [`OsString`].
 ///
index abcce3ab829625898bd813abee17f654914062d8..d9baac993c42c9419bef73c3d5d9dd54984cd908 100644 (file)
@@ -2,13 +2,12 @@
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
-use fs::{self, Permissions, OpenOptions};
-use io;
-use libc;
-use path::Path;
-use sys;
-use sys_common::{FromInner, AsInner, AsInnerMut};
-use sys::platform::fs::MetadataExt as UnixMetadataExt;
+use crate::fs::{self, Permissions, OpenOptions};
+use crate::io;
+use crate::path::Path;
+use crate::sys;
+use crate::sys_common::{FromInner, AsInner, AsInnerMut};
+use crate::sys::platform::fs::MetadataExt as UnixMetadataExt;
 
 /// Unix-specific extensions to [`File`].
 ///
index 73f4879e4e434da90a983f4db6f71c4f5798561c..1a0b3b8962bd1f028872d5f89df0133de396818d 100644 (file)
@@ -2,12 +2,11 @@
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
-use fs;
-use os::raw;
-use sys;
-use io;
-use sys_common::{AsInner, FromInner, IntoInner};
-use libc;
+use crate::fs;
+use crate::os::raw;
+use crate::sys;
+use crate::io;
+use crate::sys_common::{AsInner, FromInner, IntoInner};
 
 /// Raw file descriptors.
 #[stable(feature = "rust1", since = "1.0.0")]
index 4b60ea654c1f19d49bbce92cb1dc3ab663d0e44a..4fc79efe7ceb54bf40fe51aad495ac8c786b79dc 100644 (file)
@@ -15,19 +15,19 @@ mod libc {
     pub struct sockaddr_un;
 }
 
-use ascii;
-use ffi::OsStr;
-use fmt;
-use io::{self, Initializer, IoVec, IoVecMut};
-use mem;
-use net::{self, Shutdown};
-use os::unix::ffi::OsStrExt;
-use os::unix::io::{RawFd, AsRawFd, FromRawFd, IntoRawFd};
-use path::Path;
-use time::Duration;
-use sys::{self, cvt};
-use sys::net::Socket;
-use sys_common::{self, AsInner, FromInner, IntoInner};
+use crate::ascii;
+use crate::ffi::OsStr;
+use crate::fmt;
+use crate::io::{self, Initializer, IoVec, IoVecMut};
+use crate::mem;
+use crate::net::{self, Shutdown};
+use crate::os::unix::ffi::OsStrExt;
+use crate::os::unix::io::{RawFd, AsRawFd, FromRawFd, IntoRawFd};
+use crate::path::Path;
+use crate::time::Duration;
+use crate::sys::{self, cvt};
+use crate::sys::net::Socket;
+use crate::sys_common::{self, AsInner, FromInner, IntoInner};
 
 #[cfg(any(target_os = "linux", target_os = "android",
           target_os = "dragonfly", target_os = "freebsd",
@@ -1481,11 +1481,11 @@ fn into_raw_fd(self) -> RawFd {
 
 #[cfg(all(test, not(target_os = "emscripten")))]
 mod test {
-    use thread;
-    use io::{self, ErrorKind};
-    use io::prelude::*;
-    use time::Duration;
-    use sys_common::io::test::tmpdir;
+    use crate::thread;
+    use crate::io::{self, ErrorKind};
+    use crate::io::prelude::*;
+    use crate::time::Duration;
+    use crate::sys_common::io::test::tmpdir;
 
     use super::*;
 
index b487bb889bafa5ca115b2638d0e8a6a2832ee8a0..7ace95edef9fb46e8da2039efef53c87af78e2e9 100644 (file)
@@ -2,11 +2,11 @@
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
-use io;
-use os::unix::io::{FromRawFd, RawFd, AsRawFd, IntoRawFd};
-use process;
-use sys;
-use sys_common::{AsInnerMut, AsInner, FromInner, IntoInner};
+use crate::io;
+use crate::os::unix::io::{FromRawFd, RawFd, AsRawFd, IntoRawFd};
+use crate::process;
+use crate::sys;
+use crate::sys_common::{AsInnerMut, AsInner, FromInner, IntoInner};
 
 /// Unix-specific extensions to the [`process::Command`] builder.
 ///
@@ -209,5 +209,5 @@ fn into_raw_fd(self) -> RawFd {
 /// Returns the OS-assigned process identifier associated with this process's parent.
 #[stable(feature = "unix_ppid", since = "1.27.0")]
 pub fn parent_id() -> u32 {
-    ::sys::os::getppid()
+    crate::sys::os::getppid()
 }
index eabb4b0250308a5a597369b2173ce59415da1bf3..75ae54a919ab3e5c04ffdb6081acdfbedf64c8e3 100644 (file)
 
 #[doc(inline)]
 #[stable(feature = "pthread_t", since = "1.8.0")]
-pub use sys::platform::raw::pthread_t;
+pub use crate::sys::platform::raw::pthread_t;
 #[doc(inline)]
 #[stable(feature = "raw_ext", since = "1.1.0")]
-pub use sys::platform::raw::{dev_t, ino_t, mode_t, nlink_t, off_t, blksize_t};
+pub use crate::sys::platform::raw::{dev_t, ino_t, mode_t, nlink_t, off_t, blksize_t};
 #[doc(inline)]
 #[stable(feature = "raw_ext", since = "1.1.0")]
-pub use sys::platform::raw::{blkcnt_t, time_t};
+pub use crate::sys::platform::raw::{blkcnt_t, time_t};
index 4b3d5e31848f1c71591455c48e2ee255119c4485..759ef6236e80459f272ca07f71aa33fa1ba0527a 100644 (file)
@@ -3,9 +3,9 @@
 #![stable(feature = "thread_extensions", since = "1.9.0")]
 
 #[allow(deprecated)]
-use os::unix::raw::pthread_t;
-use sys_common::{AsInner, IntoInner};
-use thread::JoinHandle;
+use crate::os::unix::raw::pthread_t;
+use crate::sys_common::{AsInner, IntoInner};
+use crate::thread::JoinHandle;
 
 #[stable(feature = "thread_extensions", since = "1.9.0")]
 #[allow(deprecated)]
index 742ffd12b883dc89035c73c81aae9379a2a02bf7..17478dce4fe518a2e4a1d18a922175f773d5ea60 100644 (file)
@@ -12,9 +12,8 @@
 // Due to rust-lang/rust#18804, make sure this is not generic!
 #[cfg(any(target_os = "linux", target_os = "fuchsia", target_os = "hermit"))]
 pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern fn(*mut u8)) {
-    use libc;
-    use mem;
-    use sys_common::thread_local::register_dtor_fallback;
+    use crate::mem;
+    use crate::sys_common::thread_local::register_dtor_fallback;
 
     extern {
         #[linkage = "extern_weak"]
@@ -45,8 +44,8 @@ pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern fn(*mut u8)) {
 // _tlv_atexit.
 #[cfg(target_os = "macos")]
 pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern fn(*mut u8)) {
-    use cell::Cell;
-    use ptr;
+    use crate::cell::Cell;
+    use crate::ptr;
 
     #[thread_local]
     static REGISTERED: Cell<bool> = Cell::new(false);
index 6946b7b5dfa48e9ff4c567670eb2fa3d271e6635..c274ad26cb1fe9d4b827b6d9d8d26ae56dfb25f1 100644 (file)
@@ -1,12 +1,13 @@
 #![unstable(reason = "not public", issue = "0", feature = "fd")]
 
-use cmp;
-use io::{self, Read, Initializer, IoVec, IoVecMut};
-use libc::{self, c_int, c_void, ssize_t};
-use mem;
-use sync::atomic::{AtomicBool, Ordering};
-use sys::cvt;
-use sys_common::AsInner;
+use crate::cmp;
+use crate::io::{self, Read, Initializer, IoVec, IoVecMut};
+use crate::mem;
+use crate::sync::atomic::{AtomicBool, Ordering};
+use crate::sys::cvt;
+use crate::sys_common::AsInner;
+
+use libc::{c_int, c_void, ssize_t};
 
 #[derive(Debug)]
 pub struct FileDesc {
@@ -74,7 +75,7 @@ pub fn read_at(&self, buf: &mut [u8], offset: u64) -> io::Result<usize> {
         unsafe fn cvt_pread64(fd: c_int, buf: *mut c_void, count: usize, offset: i64)
             -> io::Result<isize>
         {
-            use convert::TryInto;
+            use crate::convert::TryInto;
             use libc::pread64;
             // pread64 on emscripten actually takes a 32 bit offset
             if let Ok(o) = offset.try_into() {
@@ -131,7 +132,7 @@ pub fn write_at(&self, buf: &[u8], offset: u64) -> io::Result<usize> {
         unsafe fn cvt_pwrite64(fd: c_int, buf: *const c_void, count: usize, offset: i64)
             -> io::Result<isize>
         {
-            use convert::TryInto;
+            use crate::convert::TryInto;
             use libc::pwrite64;
             // pwrite64 on emscripten actually takes a 32 bit offset
             if let Ok(o) = offset.try_into() {
index 5183d6fadd218a784f9ba7d686845bfcfee43539..3b80b475a93db164a27993d914c7e2da9f4eb8f5 100644 (file)
@@ -1,17 +1,18 @@
-use os::unix::prelude::*;
-
-use ffi::{CString, CStr, OsString, OsStr};
-use fmt;
-use io::{self, Error, ErrorKind, SeekFrom};
-use libc::{self, c_int, mode_t};
-use mem;
-use path::{Path, PathBuf};
-use ptr;
-use sync::Arc;
-use sys::fd::FileDesc;
-use sys::time::SystemTime;
-use sys::{cvt, cvt_r};
-use sys_common::{AsInner, FromInner};
+use crate::os::unix::prelude::*;
+
+use crate::ffi::{CString, CStr, OsString, OsStr};
+use crate::fmt;
+use crate::io::{self, Error, ErrorKind, SeekFrom};
+use crate::mem;
+use crate::path::{Path, PathBuf};
+use crate::ptr;
+use crate::sync::Arc;
+use crate::sys::fd::FileDesc;
+use crate::sys::time::SystemTime;
+use crate::sys::{cvt, cvt_r};
+use crate::sys_common::{AsInner, FromInner};
+
+use libc::{c_int, mode_t};
 
 #[cfg(any(target_os = "linux", target_os = "emscripten", target_os = "l4re"))]
 use libc::{stat64, fstat64, lstat64, off64_t, ftruncate64, lseek64, dirent64, readdir64_r, open64};
@@ -217,6 +218,8 @@ impl Iterator for ReadDir {
 
     #[cfg(any(target_os = "solaris", target_os = "fuchsia"))]
     fn next(&mut self) -> Option<io::Result<DirEntry>> {
+        use crate::slice;
+
         unsafe {
             loop {
                 // Although readdir_r(3) would be a correct function to use here because
@@ -239,8 +242,8 @@ fn next(&mut self) -> Option<io::Result<DirEntry>> {
 
                 let ret = DirEntry {
                     entry: *entry_ptr,
-                    name: ::slice::from_raw_parts(name as *const u8,
-                                                  namelen as usize).to_owned().into_boxed_slice(),
+                    name: slice::from_raw_parts(name as *const u8,
+                                                namelen as usize).to_owned().into_boxed_slice(),
                     dir: self.clone()
                 };
                 if ret.name_bytes() != b"." && ret.name_bytes() != b".." {
@@ -365,9 +368,10 @@ pub fn ino(&self) -> u64 {
               target_os = "dragonfly",
               target_os = "bitrig"))]
     fn name_bytes(&self) -> &[u8] {
+        use crate::slice;
         unsafe {
-            ::slice::from_raw_parts(self.entry.d_name.as_ptr() as *const u8,
-                                    self.entry.d_namlen as usize)
+            slice::from_raw_parts(self.entry.d_name.as_ptr() as *const u8,
+                                  self.entry.d_namlen as usize)
         }
     }
     #[cfg(any(target_os = "android",
@@ -475,7 +479,7 @@ pub fn open_c(path: &CStr, opts: &OpenOptions) -> io::Result<File> {
         // that we support, so we only do this on Linux currently.
         #[cfg(target_os = "linux")]
         fn ensure_cloexec(fd: &FileDesc) -> io::Result<()> {
-            use sync::atomic::{AtomicUsize, Ordering};
+            use crate::sync::atomic::{AtomicUsize, Ordering};
 
             const OPEN_CLOEXEC_UNKNOWN: usize = 0;
             const OPEN_CLOEXEC_SUPPORTED: usize = 1;
@@ -542,7 +546,7 @@ unsafe fn os_datasync(fd: c_int) -> c_int { libc::fsync(fd) }
 
     pub fn truncate(&self, size: u64) -> io::Result<()> {
         #[cfg(target_os = "android")]
-        return ::sys::android::ftruncate64(self.0.raw(), size);
+        return crate::sys::android::ftruncate64(self.0.raw(), size);
 
         #[cfg(not(target_os = "android"))]
         return cvt_r(|| unsafe {
@@ -825,7 +829,7 @@ pub fn canonicalize(p: &Path) -> io::Result<PathBuf> {
 
 #[cfg(not(any(target_os = "linux", target_os = "android")))]
 pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
-    use fs::File;
+    use crate::fs::File;
     if !from.is_file() {
         return Err(Error::new(ErrorKind::InvalidInput,
                               "the source path is not an existing regular file"))
@@ -842,9 +846,9 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
 
 #[cfg(any(target_os = "linux", target_os = "android"))]
 pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
-    use cmp;
-    use fs::File;
-    use sync::atomic::{AtomicBool, Ordering};
+    use crate::cmp;
+    use crate::fs::File;
+    use crate::sync::atomic::{AtomicBool, Ordering};
 
     // Kernel prior to 4.5 don't have copy_file_range
     // We store the availability in a global to avoid unnecessary syscalls
index 65e4c6e0577509027d6a3c49b6efa27d3a661fb5..eb3fa470a65252567bf3b4e052a6ed1d4660d32e 100644 (file)
@@ -1,6 +1,7 @@
-use marker::PhantomData;
+use crate::marker::PhantomData;
+use crate::slice;
+
 use libc::{iovec, c_void};
-use slice;
 
 #[repr(transparent)]
 pub struct IoVec<'a> {
index 4775e29fb570919c817818b6d64b34677808de52..b6e8cc738946b9a1a4429471598b46ca8eb2ef82 100644 (file)
@@ -4,15 +4,15 @@ macro_rules! unimpl {
 
 pub mod net {
     #![allow(warnings)]
-    use fmt;
-    use io::{self, IoVec, IoVecMut};
-    use libc;
-    use net::{SocketAddr, Shutdown, Ipv4Addr, Ipv6Addr};
-    use sys_common::{AsInner, FromInner, IntoInner};
-    use sys::fd::FileDesc;
-    use time::Duration;
-    use convert::TryFrom;
-
+    use crate::fmt;
+    use crate::io::{self, IoVec, IoVecMut};
+    use crate::net::{SocketAddr, Shutdown, Ipv4Addr, Ipv6Addr};
+    use crate::sys_common::{AsInner, FromInner, IntoInner};
+    use crate::sys::fd::FileDesc;
+    use crate::time::Duration;
+    use crate::convert::TryFrom;
+
+    #[allow(unused_extern_crates)]
     pub extern crate libc as netc;
 
     pub struct Socket(FileDesc);
index ec04a22a0d2e841e69e9c54a117396891f4b7f57..1984678bdde4e5d27c14db1db6a7bfd05a9e582b 100644 (file)
@@ -2,8 +2,6 @@
 // Copyright 2015 Andrew Gallant, bluss and Nicolas Koch
 
 pub fn memchr(needle: u8, haystack: &[u8]) -> Option<usize> {
-    use libc;
-
     let p = unsafe {
         libc::memchr(
             haystack.as_ptr() as *const libc::c_void,
@@ -21,8 +19,6 @@ pub fn memrchr(needle: u8, haystack: &[u8]) -> Option<usize> {
 
     #[cfg(target_os = "linux")]
     fn memrchr_specific(needle: u8, haystack: &[u8]) -> Option<usize> {
-        use libc;
-
         // GNU's memrchr() will - unlike memchr() - error if haystack is empty.
         if haystack.is_empty() {return None}
         let p = unsafe {
@@ -40,7 +36,7 @@ fn memrchr_specific(needle: u8, haystack: &[u8]) -> Option<usize> {
 
     #[cfg(not(target_os = "linux"))]
     fn memrchr_specific(needle: u8, haystack: &[u8]) -> Option<usize> {
-        ::core::slice::memchr::memrchr(needle, haystack)
+        core::slice::memchr::memrchr(needle, haystack)
     }
 
     memrchr_specific(needle, haystack)
index 0de1a223fbd12a478a6ea4fe3459c5fa1b94dcd7..fbe3444311e5fff704c97be43b7c04a013eda68e 100644 (file)
@@ -1,24 +1,23 @@
 #![allow(missing_docs, nonstandard_style)]
 
-use io::ErrorKind;
-use libc;
-
-#[cfg(any(rustdoc, target_os = "linux"))] pub use os::linux as platform;
-
-#[cfg(all(not(rustdoc), target_os = "android"))]   pub use os::android as platform;
-#[cfg(all(not(rustdoc), target_os = "bitrig"))]    pub use os::bitrig as platform;
-#[cfg(all(not(rustdoc), target_os = "dragonfly"))] pub use os::dragonfly as platform;
-#[cfg(all(not(rustdoc), target_os = "freebsd"))]   pub use os::freebsd as platform;
-#[cfg(all(not(rustdoc), target_os = "haiku"))]     pub use os::haiku as platform;
-#[cfg(all(not(rustdoc), target_os = "ios"))]       pub use os::ios as platform;
-#[cfg(all(not(rustdoc), target_os = "macos"))]     pub use os::macos as platform;
-#[cfg(all(not(rustdoc), target_os = "netbsd"))]    pub use os::netbsd as platform;
-#[cfg(all(not(rustdoc), target_os = "openbsd"))]   pub use os::openbsd as platform;
-#[cfg(all(not(rustdoc), target_os = "solaris"))]   pub use os::solaris as platform;
-#[cfg(all(not(rustdoc), target_os = "emscripten"))] pub use os::emscripten as platform;
-#[cfg(all(not(rustdoc), target_os = "fuchsia"))]   pub use os::fuchsia as platform;
-#[cfg(all(not(rustdoc), target_os = "l4re"))]      pub use os::linux as platform;
-#[cfg(all(not(rustdoc), target_os = "hermit"))]    pub use os::hermit as platform;
+use crate::io::ErrorKind;
+
+#[cfg(any(rustdoc, target_os = "linux"))] pub use crate::os::linux as platform;
+
+#[cfg(all(not(rustdoc), target_os = "android"))]   pub use crate::os::android as platform;
+#[cfg(all(not(rustdoc), target_os = "bitrig"))]    pub use crate::os::bitrig as platform;
+#[cfg(all(not(rustdoc), target_os = "dragonfly"))] pub use crate::os::dragonfly as platform;
+#[cfg(all(not(rustdoc), target_os = "freebsd"))]   pub use crate::os::freebsd as platform;
+#[cfg(all(not(rustdoc), target_os = "haiku"))]     pub use crate::os::haiku as platform;
+#[cfg(all(not(rustdoc), target_os = "ios"))]       pub use crate::os::ios as platform;
+#[cfg(all(not(rustdoc), target_os = "macos"))]     pub use crate::os::macos as platform;
+#[cfg(all(not(rustdoc), target_os = "netbsd"))]    pub use crate::os::netbsd as platform;
+#[cfg(all(not(rustdoc), target_os = "openbsd"))]   pub use crate::os::openbsd as platform;
+#[cfg(all(not(rustdoc), target_os = "solaris"))]   pub use crate::os::solaris as platform;
+#[cfg(all(not(rustdoc), target_os = "emscripten"))] pub use crate::os::emscripten as platform;
+#[cfg(all(not(rustdoc), target_os = "fuchsia"))]   pub use crate::os::fuchsia as platform;
+#[cfg(all(not(rustdoc), target_os = "l4re"))]      pub use crate::os::linux as platform;
+#[cfg(all(not(rustdoc), target_os = "hermit"))]    pub use crate::os::hermit as platform;
 
 pub use self::rand::hashmap_random_keys;
 pub use libc::strlen;
@@ -82,7 +81,7 @@ unsafe fn reset_sigpipe() {}
 }
 
 #[cfg(target_os = "android")]
-pub use sys::android::signal;
+pub use crate::sys::android::signal;
 #[cfg(not(target_os = "android"))]
 pub use libc::signal;
 
@@ -127,15 +126,15 @@ fn is_minus_one(&self) -> bool {
 
 impl_is_minus_one! { i8 i16 i32 i64 isize }
 
-pub fn cvt<T: IsMinusOne>(t: T) -> ::io::Result<T> {
+pub fn cvt<T: IsMinusOne>(t: T) -> crate::io::Result<T> {
     if t.is_minus_one() {
-        Err(::io::Error::last_os_error())
+        Err(crate::io::Error::last_os_error())
     } else {
         Ok(t)
     }
 }
 
-pub fn cvt_r<T, F>(mut f: F) -> ::io::Result<T>
+pub fn cvt_r<T, F>(mut f: F) -> crate::io::Result<T>
     where T: IsMinusOne,
           F: FnMut() -> T
 {
@@ -155,5 +154,5 @@ pub fn cvt_r<T, F>(mut f: F) -> ::io::Result<T>
 // instruction" that intrinsics::abort would cause, as intrinsics::abort is
 // implemented as an illegal instruction.
 pub unsafe fn abort_internal() -> ! {
-    ::libc::abort()
+    libc::abort()
 }
index 54429dc84b6b3fa03a35a8971aa88a4154e0ae2d..b6a22e1962ab83237af605c93055f744f8df7694 100644 (file)
@@ -1,6 +1,5 @@
-use cell::UnsafeCell;
-use libc;
-use mem;
+use crate::cell::UnsafeCell;
+use crate::mem;
 
 pub struct Mutex { inner: UnsafeCell<libc::pthread_mutex_t> }
 
@@ -74,7 +73,6 @@ pub unsafe fn destroy(&self) {
     #[inline]
     #[cfg(target_os = "dragonfly")]
     pub unsafe fn destroy(&self) {
-        use libc;
         let r = libc::pthread_mutex_destroy(self.inner.get());
         // On DragonFly pthread_mutex_destroy() returns EINVAL if called on a
         // mutex that was just initialized with libc::PTHREAD_MUTEX_INITIALIZER.
index 521d9b425179b438b426e03b89a3e2e4d4b5f90d..7712a41ded46f8245cb5381db233e4082f7b794e 100644 (file)
@@ -1,16 +1,19 @@
-use ffi::CStr;
-use io::{self, IoVec, IoVecMut};
-use libc::{self, c_int, c_void, size_t, sockaddr, socklen_t, EAI_SYSTEM, MSG_PEEK};
-use mem;
-use net::{SocketAddr, Shutdown};
-use str;
-use sys::fd::FileDesc;
-use sys_common::{AsInner, FromInner, IntoInner};
-use sys_common::net::{getsockopt, setsockopt, sockaddr_to_addr};
-use time::{Duration, Instant};
-use cmp;
-
-pub use sys::{cvt, cvt_r};
+use crate::ffi::CStr;
+use crate::io::{self, IoVec, IoVecMut};
+use crate::mem;
+use crate::net::{SocketAddr, Shutdown};
+use crate::str;
+use crate::sys::fd::FileDesc;
+use crate::sys_common::{AsInner, FromInner, IntoInner};
+use crate::sys_common::net::{getsockopt, setsockopt, sockaddr_to_addr};
+use crate::time::{Duration, Instant};
+use crate::cmp;
+
+use libc::{c_int, c_void, size_t, sockaddr, socklen_t, EAI_SYSTEM, MSG_PEEK};
+
+pub use crate::sys::{cvt, cvt_r};
+
+#[allow(unused_extern_crates)]
 pub extern crate libc as netc;
 
 pub type wrlen_t = size_t;
@@ -384,7 +387,7 @@ fn into_inner(self) -> c_int { self.0.into_raw() }
 // believe it's thread-safe).
 #[cfg(target_env = "gnu")]
 fn on_resolver_failure() {
-    use sys;
+    use crate::sys;
 
     // If the version fails to parse, we treat it the same as "not glibc".
     if let Some(version) = sys::os::glibc_version() {
index 58ea190fcc004b940c141cc1194c5179fa24a4a9..e16d50d437b220a73fe56f090148b950c58ef21e 100644 (file)
@@ -2,25 +2,26 @@
 
 #![allow(unused_imports)] // lots of cfg code here
 
-use os::unix::prelude::*;
-
-use error::Error as StdError;
-use ffi::{CString, CStr, OsString, OsStr};
-use fmt;
-use io;
-use iter;
-use libc::{self, c_int, c_char, c_void};
-use marker::PhantomData;
-use mem;
-use memchr;
-use path::{self, PathBuf};
-use ptr;
-use slice;
-use str;
-use sys_common::mutex::{Mutex, MutexGuard};
-use sys::cvt;
-use sys::fd;
-use vec;
+use crate::os::unix::prelude::*;
+
+use crate::error::Error as StdError;
+use crate::ffi::{CString, CStr, OsString, OsStr};
+use crate::fmt;
+use crate::io;
+use crate::iter;
+use crate::marker::PhantomData;
+use crate::mem;
+use crate::memchr;
+use crate::path::{self, PathBuf};
+use crate::ptr;
+use crate::slice;
+use crate::str;
+use crate::sys_common::mutex::{Mutex, MutexGuard};
+use crate::sys::cvt;
+use crate::sys::fd;
+use crate::vec;
+
+use libc::{c_int, c_char, c_void};
 
 const TMPBUF_SZ: usize = 128;
 
@@ -207,13 +208,13 @@ pub fn current_exe() -> io::Result<PathBuf> {
                        libc::KERN_PROC_PATHNAME as c_int,
                        -1 as c_int];
         let mut sz = 0;
-        cvt(libc::sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint,
+        cvt(libc::sysctl(mib.as_mut_ptr(), mib.len() as libc::c_uint,
                          ptr::null_mut(), &mut sz, ptr::null_mut(), 0))?;
         if sz == 0 {
             return Err(io::Error::last_os_error())
         }
         let mut v: Vec<u8> = Vec::with_capacity(sz);
-        cvt(libc::sysctl(mib.as_mut_ptr(), mib.len() as ::libc::c_uint,
+        cvt(libc::sysctl(mib.as_mut_ptr(), mib.len() as libc::c_uint,
                          v.as_mut_ptr() as *mut libc::c_void, &mut sz,
                          ptr::null_mut(), 0))?;
         if sz == 0 {
@@ -230,7 +231,7 @@ fn sysctl() -> io::Result<PathBuf> {
         unsafe {
             let mib = [libc::CTL_KERN, libc::KERN_PROC_ARGS, -1, libc::KERN_PROC_PATHNAME];
             let mut path_len: usize = 0;
-            cvt(libc::sysctl(mib.as_ptr(), mib.len() as ::libc::c_uint,
+            cvt(libc::sysctl(mib.as_ptr(), mib.len() as libc::c_uint,
                              ptr::null_mut(), &mut path_len,
                              ptr::null(), 0))?;
             if path_len <= 1 {
@@ -238,7 +239,7 @@ fn sysctl() -> io::Result<PathBuf> {
                            "KERN_PROC_PATHNAME sysctl returned zero-length string"))
             }
             let mut path: Vec<u8> = Vec::with_capacity(path_len);
-            cvt(libc::sysctl(mib.as_ptr(), mib.len() as ::libc::c_uint,
+            cvt(libc::sysctl(mib.as_ptr(), mib.len() as libc::c_uint,
                              path.as_ptr() as *mut libc::c_void, &mut path_len,
                              ptr::null(), 0))?;
             path.set_len(path_len - 1); // chop off NUL
@@ -248,7 +249,7 @@ fn sysctl() -> io::Result<PathBuf> {
     fn procfs() -> io::Result<PathBuf> {
         let curproc_exe = path::Path::new("/proc/curproc/exe");
         if curproc_exe.is_file() {
-            return ::fs::read_link(curproc_exe);
+            return crate::fs::read_link(curproc_exe);
         }
         Err(io::Error::new(io::ErrorKind::Other,
                            "/proc/curproc/exe doesn't point to regular file."))
@@ -277,7 +278,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
         }
         let argv0 = CStr::from_ptr(argv[0]).to_bytes();
         if argv0[0] == b'.' || argv0.iter().any(|b| *b == b'/') {
-            ::fs::canonicalize(OsStr::from_bytes(argv0))
+            crate::fs::canonicalize(OsStr::from_bytes(argv0))
         } else {
             Ok(PathBuf::from(OsStr::from_bytes(argv0)))
         }
@@ -286,7 +287,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
 
 #[cfg(any(target_os = "linux", target_os = "android", target_os = "emscripten"))]
 pub fn current_exe() -> io::Result<PathBuf> {
-    match ::fs::read_link("/proc/self/exe") {
+    match crate::fs::read_link("/proc/self/exe") {
         Err(ref e) if e.kind() == io::ErrorKind::NotFound => {
             Err(io::Error::new(
                 io::ErrorKind::Other,
@@ -373,7 +374,7 @@ fn _get_next_image_info(team_id: i32, cookie: *mut i32,
         let result = _get_next_image_info(0, &mut cookie, &mut info,
             mem::size_of::<image_info>() as i32);
         if result != 0 {
-            use io::ErrorKind;
+            use crate::io::ErrorKind;
             Err(io::Error::new(ErrorKind::Other, "Error getting executable path"))
         } else {
             let name = CStr::from_ptr(info.name.as_ptr()).to_bytes();
@@ -384,7 +385,7 @@ fn _get_next_image_info(team_id: i32, cookie: *mut i32,
 
 #[cfg(any(target_os = "fuchsia", target_os = "l4re", target_os = "hermit"))]
 pub fn current_exe() -> io::Result<PathBuf> {
-    use io::ErrorKind;
+    use crate::io::ErrorKind;
     Err(io::Error::new(ErrorKind::Other, "Not yet implemented!"))
 }
 
@@ -495,7 +496,7 @@ pub fn page_size() -> usize {
 }
 
 pub fn temp_dir() -> PathBuf {
-    ::env::var_os("TMPDIR").map(PathBuf::from).unwrap_or_else(|| {
+    crate::env::var_os("TMPDIR").map(PathBuf::from).unwrap_or_else(|| {
         if cfg!(target_os = "android") {
             PathBuf::from("/data/local/tmp")
         } else {
@@ -505,7 +506,7 @@ pub fn temp_dir() -> PathBuf {
 }
 
 pub fn home_dir() -> Option<PathBuf> {
-    return ::env::var_os("HOME").or_else(|| unsafe {
+    return crate::env::var_os("HOME").or_else(|| unsafe {
         fallback()
     }).map(PathBuf::from);
 
index 9d5e084feb2d6bbff22b028b5c9dd8db8e0a5785..79b43458d00f3cad06079838d2c0ab3b3c3ef06a 100644 (file)
@@ -1,14 +1,15 @@
 /// The underlying OsString/OsStr implementation on Unix systems: just
 /// a `Vec<u8>`/`[u8]`.
 
-use borrow::Cow;
-use fmt;
-use str;
-use mem;
-use rc::Rc;
-use sync::Arc;
-use sys_common::{AsInner, IntoInner};
-use sys_common::bytestring::debug_fmt_bytestring;
+use crate::borrow::Cow;
+use crate::fmt;
+use crate::str;
+use crate::mem;
+use crate::rc::Rc;
+use crate::sync::Arc;
+use crate::sys_common::{AsInner, IntoInner};
+use crate::sys_common::bytestring::debug_fmt_bytestring;
+
 use core::str::lossy::Utf8Lossy;
 
 #[derive(Clone, Hash)]
index 2ef78fb2f86dcd7874323c235d9eba06a1f952c9..5c062e7c97cd3d5072843a62b02c5b1fbe25eb25 100644 (file)
@@ -1,5 +1,5 @@
-use path::Prefix;
-use ffi::OsStr;
+use crate::path::Prefix;
+use crate::ffi::OsStr;
 
 #[inline]
 pub fn is_sep_byte(b: u8) -> bool {
index a746d982c6ca9d4db144d9ab20de5c0ba2cb083a..bc3c026adab8f453b951d897da0b50fc1d5ab899 100644 (file)
@@ -1,9 +1,10 @@
-use io;
-use libc::{self, c_int};
-use mem;
-use sync::atomic::{AtomicBool, Ordering};
-use sys::fd::FileDesc;
-use sys::{cvt, cvt_r};
+use crate::io;
+use crate::mem;
+use crate::sync::atomic::{AtomicBool, Ordering};
+use crate::sys::fd::FileDesc;
+use crate::sys::{cvt, cvt_r};
+
+use libc::c_int;
 
 ////////////////////////////////////////////////////////////////////////////////
 // Anonymous pipes
index 7fa256e59b2db294c5f1dc513ed4348716274893..856d202be03f3388b32c3f99b4341b5428a05910 100644 (file)
@@ -1,15 +1,16 @@
-use os::unix::prelude::*;
-
-use ffi::{OsString, OsStr, CString, CStr};
-use fmt;
-use io;
-use libc::{self, c_int, gid_t, uid_t, c_char, EXIT_SUCCESS, EXIT_FAILURE};
-use ptr;
-use sys::fd::FileDesc;
-use sys::fs::{File, OpenOptions};
-use sys::pipe::{self, AnonPipe};
-use sys_common::process::{CommandEnv, DefaultEnvKey};
-use collections::BTreeMap;
+use crate::os::unix::prelude::*;
+
+use crate::ffi::{OsString, OsStr, CString, CStr};
+use crate::fmt;
+use crate::io;
+use crate::ptr;
+use crate::sys::fd::FileDesc;
+use crate::sys::fs::{File, OpenOptions};
+use crate::sys::pipe::{self, AnonPipe};
+use crate::sys_common::process::{CommandEnv, DefaultEnvKey};
+use crate::collections::BTreeMap;
+
+use libc::{c_int, gid_t, uid_t, c_char, EXIT_SUCCESS, EXIT_FAILURE};
 
 ////////////////////////////////////////////////////////////////////////////////
 // Command
@@ -406,11 +407,10 @@ pub fn as_i32(&self) -> i32 {
 mod tests {
     use super::*;
 
-    use ffi::OsStr;
-    use mem;
-    use ptr;
-    use libc;
-    use sys::cvt;
+    use crate::ffi::OsStr;
+    use crate::mem;
+    use crate::ptr;
+    use crate::sys::cvt;
 
     macro_rules! t {
         ($e:expr) => {
@@ -443,7 +443,7 @@ unsafe fn sigemptyset(set: *mut libc::sigset_t) -> libc::c_int {
 
     #[cfg(target_os = "android")]
     unsafe fn sigaddset(set: *mut libc::sigset_t, signum: libc::c_int) -> libc::c_int {
-        use slice;
+        use crate::slice;
 
         let raw = slice::from_raw_parts_mut(set as *mut u8, mem::size_of::<libc::sigset_t>());
         let bit = (signum - 1) as usize;
index 5582310adbf74ffbdabd30a1f5151d5c35499129..7c6be9b0a6047f4a513d38e8bb2b35c14a9c7d4c 100644 (file)
@@ -1,10 +1,11 @@
-use io;
-use libc::{self, size_t};
-use mem;
-use ptr;
+use crate::io;
+use crate::mem;
+use crate::ptr;
 
-use sys::process::zircon::{Handle, zx_handle_t};
-use sys::process::process_common::*;
+use crate::sys::process::zircon::{Handle, zx_handle_t};
+use crate::sys::process::process_common::*;
+
+use libc::size_t;
 
 ////////////////////////////////////////////////////////////////////////////////
 // Command
@@ -44,7 +45,7 @@ pub fn exec(&mut self, default: Stdio) -> io::Error {
 
     unsafe fn do_exec(&mut self, stdio: ChildPipes, maybe_envp: Option<&CStringArray>)
                       -> io::Result<zx_handle_t> {
-        use sys::process::zircon::*;
+        use crate::sys::process::zircon::*;
 
         let envp = match maybe_envp {
             Some(envp) => envp.as_ptr(),
@@ -109,7 +110,7 @@ pub fn id(&self) -> u32 {
     }
 
     pub fn kill(&mut self) -> io::Result<()> {
-        use sys::process::zircon::*;
+        use crate::sys::process::zircon::*;
 
         unsafe { zx_cvt(zx_task_kill(self.handle.raw()))?; }
 
@@ -117,8 +118,8 @@ pub fn kill(&mut self) -> io::Result<()> {
     }
 
     pub fn wait(&mut self) -> io::Result<ExitStatus> {
-        use default::Default;
-        use sys::process::zircon::*;
+        use crate::default::Default;
+        use crate::sys::process::zircon::*;
 
         let mut proc_info: zx_info_process_t = Default::default();
         let mut actual: size_t = 0;
@@ -140,8 +141,8 @@ pub fn wait(&mut self) -> io::Result<ExitStatus> {
     }
 
     pub fn try_wait(&mut self) -> io::Result<Option<ExitStatus>> {
-        use default::Default;
-        use sys::process::zircon::*;
+        use crate::default::Default;
+        use crate::sys::process::zircon::*;
 
         let mut proc_info: zx_info_process_t = Default::default();
         let mut actual: size_t = 0;
index 6fbbbb349b171a9a86e30ca8118abc18bc425391..220b1fd453131e1ffd2cfb75c3867bd97b956266 100644 (file)
@@ -1,9 +1,10 @@
-use io::{self, Error, ErrorKind};
-use libc::{self, c_int, gid_t, pid_t, uid_t};
-use ptr;
-use sys::cvt;
-use sys::process::process_common::*;
-use sys;
+use crate::io::{self, Error, ErrorKind};
+use crate::ptr;
+use crate::sys::cvt;
+use crate::sys::process::process_common::*;
+use crate::sys;
+
+use libc::{c_int, gid_t, pid_t, uid_t};
 
 ////////////////////////////////////////////////////////////////////////////////
 // Command
@@ -164,7 +165,7 @@ unsafe fn do_exec(
         stdio: ChildPipes,
         maybe_envp: Option<&CStringArray>
     ) -> io::Error {
-        use sys::{self, cvt_r};
+        use crate::sys::{self, cvt_r};
 
         macro_rules! t {
             ($e:expr) => (match $e {
@@ -207,7 +208,7 @@ macro_rules! t {
         // emscripten has no signal support.
         #[cfg(not(any(target_os = "emscripten")))]
         {
-            use mem;
+            use crate::mem;
             // Reset signal handling so the child process starts in a
             // standardized state. libstd ignores SIGPIPE, and signal-handling
             // libraries often set a mask. Child processes inherit ignored
@@ -278,8 +279,8 @@ fn posix_spawn(&mut self, _: &ChildPipes, _: Option<&CStringArray>)
     fn posix_spawn(&mut self, stdio: &ChildPipes, envp: Option<&CStringArray>)
         -> io::Result<Option<Process>>
     {
-        use mem;
-        use sys;
+        use crate::mem;
+        use crate::sys;
 
         if self.get_gid().is_some() ||
             self.get_uid().is_some() ||
@@ -427,7 +428,7 @@ pub fn kill(&mut self) -> io::Result<()> {
     }
 
     pub fn wait(&mut self) -> io::Result<ExitStatus> {
-        use sys::cvt_r;
+        use crate::sys::cvt_r;
         if let Some(status) = self.status {
             return Ok(status)
         }
index 690c745218b640c227ee8346a573cdb4a0daf6e9..ec715d5490f6f967adfc0eead6bc0198d32a7230 100644 (file)
@@ -1,9 +1,9 @@
 #![allow(non_camel_case_types, unused)]
 
-use convert::TryInto;
-use io;
-use os::raw::c_char;
-use u64;
+use crate::convert::TryInto;
+use crate::io;
+use crate::os::raw::c_char;
+use crate::u64;
 
 use libc::{c_int, c_void, size_t};
 
index f2e17c36738fc37ebcf73c1f67c6158dcfc0e475..122f22b37a26b4794e5e2c8d9f294491ce177dc4 100644 (file)
@@ -1,5 +1,5 @@
-use mem;
-use slice;
+use crate::mem;
+use crate::slice;
 
 pub fn hashmap_random_keys() -> (u64, u64) {
     let mut v = (0, 0);
@@ -17,10 +17,8 @@ pub fn hashmap_random_keys() -> (u64, u64) {
           not(target_os = "freebsd"),
           not(target_os = "fuchsia")))]
 mod imp {
-    use fs::File;
-    use io::Read;
-    #[cfg(any(target_os = "linux", target_os = "android"))]
-    use libc;
+    use crate::fs::File;
+    use crate::io::Read;
 
     #[cfg(any(target_os = "linux", target_os = "android"))]
     fn getrandom(buf: &mut [u8]) -> libc::c_long {
@@ -34,8 +32,8 @@ fn getrandom_fill_bytes(_buf: &mut [u8]) -> bool { false }
 
     #[cfg(any(target_os = "linux", target_os = "android"))]
     fn getrandom_fill_bytes(v: &mut [u8]) -> bool {
-        use sync::atomic::{AtomicBool, Ordering};
-        use sys::os::errno;
+        use crate::sync::atomic::{AtomicBool, Ordering};
+        use crate::sys::os::errno;
 
         static GETRANDOM_UNAVAILABLE: AtomicBool = AtomicBool::new(false);
         if GETRANDOM_UNAVAILABLE.load(Ordering::Relaxed) {
@@ -86,8 +84,7 @@ pub fn fill_bytes(v: &mut [u8]) {
 
 #[cfg(target_os = "openbsd")]
 mod imp {
-    use libc;
-    use sys::os::errno;
+    use crate::sys::os::errno;
 
     pub fn fill_bytes(v: &mut [u8]) {
         // getentropy(2) permits a maximum buffer size of 256 bytes
@@ -104,9 +101,9 @@ pub fn fill_bytes(v: &mut [u8]) {
 
 #[cfg(target_os = "ios")]
 mod imp {
-    use io;
+    use crate::io;
+    use crate::ptr;
     use libc::{c_int, size_t};
-    use ptr;
 
     enum SecRandom {}
 
@@ -134,8 +131,7 @@ pub fn fill_bytes(v: &mut [u8]) {
 
 #[cfg(target_os = "freebsd")]
 mod imp {
-    use libc;
-    use ptr;
+    use crate::ptr;
 
     pub fn fill_bytes(v: &mut [u8]) {
         let mib = [libc::CTL_KERN, libc::KERN_ARND];
index a068a11993e36e63aeb8db8ac601c870088adcff..e48bfdae6104756bfc9b03232af5e3bb2aca020f 100644 (file)
@@ -1,6 +1,5 @@
-use libc;
-use cell::UnsafeCell;
-use sync::atomic::{AtomicUsize, Ordering};
+use crate::cell::UnsafeCell;
+use crate::sync::atomic::{AtomicUsize, Ordering};
 
 pub struct RWLock {
     inner: UnsafeCell<libc::pthread_rwlock_t>,
index d6a219a6d575952b34e5c729f3730c49eddc7d94..8c60bddc23839c9b5b84e61cbc269a981f6acec2 100644 (file)
@@ -1,6 +1,5 @@
 #![cfg_attr(test, allow(dead_code))]
 
-use libc;
 use self::imp::{make_handler, drop_handler};
 
 pub use self::imp::cleanup;
@@ -34,17 +33,17 @@ fn drop(&mut self) {
           target_os = "openbsd"))]
 mod imp {
     use super::Handler;
-    use mem;
-    use ptr;
+    use crate::mem;
+    use crate::ptr;
+
     use libc::{sigaltstack, SIGSTKSZ, SS_DISABLE};
     use libc::{sigaction, SIGBUS, SIG_DFL,
                SA_SIGINFO, SA_ONSTACK, sighandler_t};
-    use libc;
     use libc::{mmap, munmap};
     use libc::{SIGSEGV, PROT_READ, PROT_WRITE, MAP_PRIVATE, MAP_ANON};
     use libc::MAP_FAILED;
 
-    use sys_common::thread_info;
+    use crate::sys_common::thread_info;
 
 
     #[cfg(any(target_os = "linux", target_os = "android"))]
@@ -87,7 +86,7 @@ unsafe fn siginfo_si_addr(info: *mut libc::siginfo_t) -> usize {
     unsafe extern fn signal_handler(signum: libc::c_int,
                                     info: *mut libc::siginfo_t,
                                     _data: *mut libc::c_void) {
-        use sys_common::util::report_overflow;
+        use crate::sys_common::util::report_overflow;
 
         let guard = thread_info::stack_guard().unwrap_or(0..0);
         let addr = siginfo_si_addr(info);
@@ -193,7 +192,7 @@ pub unsafe fn drop_handler(handler: &mut Handler) {
               all(target_os = "netbsd", not(target_vendor = "rumprun")),
               target_os = "openbsd")))]
 mod imp {
-    use ptr;
+    use crate::ptr;
 
     pub unsafe fn init() {
     }
index 56b75bf9f7931954cd1c9d0e0c52f0485a7a3f30..35f163bbdb10fd7db3c2ebbd2b80450743e1256e 100644 (file)
@@ -1,6 +1,5 @@
-use io;
-use libc;
-use sys::fd::FileDesc;
+use crate::io;
+use crate::sys::fd::FileDesc;
 
 pub struct Stdin(());
 pub struct Stdout(());
@@ -57,7 +56,7 @@ pub fn is_ebadf(err: &io::Error) -> bool {
     err.raw_os_error() == Some(libc::EBADF as i32)
 }
 
-pub const STDIN_BUF_SIZE: usize = ::sys_common::io::DEFAULT_BUF_SIZE;
+pub const STDIN_BUF_SIZE: usize = crate::sys_common::io::DEFAULT_BUF_SIZE;
 
 pub fn panic_output() -> Option<impl io::Write> {
     Stderr::new().ok()
index e29557f1ba29b1a54170d6d1dd011aba97780ecb..feb15e8f585abb99042b0dee4da166413b8b51c7 100644 (file)
@@ -1,14 +1,13 @@
-use boxed::FnBox;
-use cmp;
-use ffi::CStr;
-use io;
-use libc;
-use mem;
-use ptr;
-use sys::os;
-use time::Duration;
-
-use sys_common::thread::*;
+use crate::boxed::FnBox;
+use crate::cmp;
+use crate::ffi::CStr;
+use crate::io;
+use crate::mem;
+use crate::ptr;
+use crate::sys::os;
+use crate::time::Duration;
+
+use crate::sys_common::thread::*;
 
 #[cfg(not(target_os = "l4re"))]
 pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024;
@@ -118,7 +117,7 @@ pub fn set_name(name: &CStr) {
 
     #[cfg(target_os = "netbsd")]
     pub fn set_name(name: &CStr) {
-        use ffi::CString;
+        use crate::ffi::CString;
         let cname = CString::new(&b"%s"[..]).unwrap();
         unsafe {
             libc::pthread_setname_np(libc::pthread_self(), cname.as_ptr(),
@@ -197,7 +196,7 @@ fn drop(&mut self) {
           not(target_os = "solaris")))]
 #[cfg_attr(test, allow(dead_code))]
 pub mod guard {
-    use ops::Range;
+    use crate::ops::Range;
     pub type Guard = Range<usize>;
     pub unsafe fn current() -> Option<Guard> { None }
     pub unsafe fn init() -> Option<Guard> { None }
@@ -213,11 +212,11 @@ pub unsafe fn init() -> Option<Guard> { None }
           target_os = "solaris"))]
 #[cfg_attr(test, allow(dead_code))]
 pub mod guard {
-    use libc;
     use libc::{mmap, mprotect};
     use libc::{PROT_NONE, PROT_READ, PROT_WRITE, MAP_PRIVATE, MAP_ANON, MAP_FAILED, MAP_FIXED};
-    use ops::Range;
-    use sys::os;
+
+    use crate::ops::Range;
+    use crate::sys::os;
 
     // This is initialized in init() and only read from after
     static mut PAGE_SIZE: usize = 0;
@@ -226,7 +225,7 @@ pub mod guard {
 
     #[cfg(target_os = "solaris")]
     unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
-        let mut current_stack: libc::stack_t = ::mem::zeroed();
+        let mut current_stack: libc::stack_t = crate::mem::zeroed();
         assert_eq!(libc::stack_getbounds(&mut current_stack), 0);
         Some(current_stack.ss_sp)
     }
@@ -240,7 +239,7 @@ unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
 
     #[cfg(any(target_os = "openbsd", target_os = "bitrig"))]
     unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
-        let mut current_stack: libc::stack_t = ::mem::zeroed();
+        let mut current_stack: libc::stack_t = crate::mem::zeroed();
         assert_eq!(libc::pthread_stackseg_np(libc::pthread_self(),
                                              &mut current_stack), 0);
 
@@ -259,14 +258,14 @@ unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
               target_os = "linux", target_os = "netbsd", target_os = "l4re"))]
     unsafe fn get_stack_start() -> Option<*mut libc::c_void> {
         let mut ret = None;
-        let mut attr: libc::pthread_attr_t = ::mem::zeroed();
+        let mut attr: libc::pthread_attr_t = crate::mem::zeroed();
         assert_eq!(libc::pthread_attr_init(&mut attr), 0);
         #[cfg(target_os = "freebsd")]
             let e = libc::pthread_attr_get_np(libc::pthread_self(), &mut attr);
         #[cfg(not(target_os = "freebsd"))]
             let e = libc::pthread_getattr_np(libc::pthread_self(), &mut attr);
         if e == 0 {
-            let mut stackaddr = ::ptr::null_mut();
+            let mut stackaddr = crate::ptr::null_mut();
             let mut stacksize = 0;
             assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr,
                                                    &mut stacksize), 0);
@@ -357,7 +356,7 @@ pub unsafe fn current() -> Option<Guard> {
               target_os = "linux", target_os = "netbsd", target_os = "l4re"))]
     pub unsafe fn current() -> Option<Guard> {
         let mut ret = None;
-        let mut attr: libc::pthread_attr_t = ::mem::zeroed();
+        let mut attr: libc::pthread_attr_t = crate::mem::zeroed();
         assert_eq!(libc::pthread_attr_init(&mut attr), 0);
         #[cfg(target_os = "freebsd")]
             let e = libc::pthread_attr_get_np(libc::pthread_self(), &mut attr);
@@ -369,7 +368,7 @@ pub unsafe fn current() -> Option<Guard> {
             if guardsize == 0 {
                 panic!("there is no guard page");
             }
-            let mut stackaddr = ::ptr::null_mut();
+            let mut stackaddr = crate::ptr::null_mut();
             let mut size = 0;
             assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr,
                                                    &mut size), 0);
index c171fbce237ff19cdadf2ee434aa6a2c03357481..ac615b76b36245650492eb3d883557f5b9ed2ae3 100644 (file)
@@ -1,7 +1,6 @@
 #![allow(dead_code)] // not used on all platforms
 
-use mem;
-use libc;
+use crate::mem;
 
 pub type Key = libc::pthread_key_t;
 
index 4a655714f991cba30c12b9b6a18705c89d2f74b9..cbb0615911adf8298f58760cde61bdecdb45a4a6 100644 (file)
@@ -1,10 +1,10 @@
-use cmp::Ordering;
-use libc;
-use time::Duration;
+use crate::cmp::Ordering;
+use crate::time::Duration;
+
 use core::hash::{Hash, Hasher};
 
 pub use self::inner::{Instant, SystemTime, UNIX_EPOCH};
-use convert::TryInto;
+use crate::convert::TryInto;
 
 const NSEC_PER_SEC: u64 = 1_000_000_000;
 
@@ -113,12 +113,11 @@ fn hash<H : Hasher>(&self, state: &mut H) {
 
 #[cfg(any(target_os = "macos", target_os = "ios"))]
 mod inner {
-    use fmt;
-    use libc;
-    use sync::Once;
-    use sys::cvt;
-    use sys_common::mul_div_u64;
-    use time::Duration;
+    use crate::fmt;
+    use crate::sync::Once;
+    use crate::sys::cvt;
+    use crate::sys_common::mul_div_u64;
+    use crate::time::Duration;
 
     use super::NSEC_PER_SEC;
     use super::Timespec;
@@ -173,7 +172,7 @@ pub fn checked_sub_duration(&self, other: &Duration) -> Option<Instant> {
 
     impl SystemTime {
         pub fn now() -> SystemTime {
-            use ptr;
+            use crate::ptr;
 
             let mut s = libc::timeval {
                 tv_sec: 0,
@@ -249,10 +248,9 @@ fn info() -> &'static libc::mach_timebase_info {
 
 #[cfg(not(any(target_os = "macos", target_os = "ios")))]
 mod inner {
-    use fmt;
-    use libc;
-    use sys::cvt;
-    use time::Duration;
+    use crate::fmt;
+    use crate::sys::cvt;
+    use crate::time::Duration;
 
     use super::Timespec;
 
index b60e241f10ceee698ddfcf65acbad46ae76b967f..9a7691e54bc1aa98f671be9200f8afc7c28f222d 100644 (file)
 //! symbol, but that caused Debian to detect an unnecessarily strict versioned
 //! dependency on libc6 (#23628).
 
-use libc;
-
-use ffi::CStr;
-use marker;
-use mem;
-use sync::atomic::{AtomicUsize, Ordering};
+use crate::ffi::CStr;
+use crate::marker;
+use crate::mem;
+use crate::sync::atomic::{AtomicUsize, Ordering};
 
 macro_rules! weak {
     (fn $name:ident($($t:ty),*) -> $ret:ty) => (
-        static $name: ::sys::weak::Weak<unsafe extern fn($($t),*) -> $ret> =
-            ::sys::weak::Weak::new(concat!(stringify!($name), '\0'));
+        static $name: crate::sys::weak::Weak<unsafe extern fn($($t),*) -> $ret> =
+            crate::sys::weak::Weak::new(concat!(stringify!($name), '\0'));
     )
 }
 
@@ -71,7 +69,6 @@ unsafe fn fetch(name: &str) -> usize {
 macro_rules! syscall {
     (fn $name:ident($($arg_name:ident: $t:ty),*) -> $ret:ty) => (
         unsafe fn $name($($arg_name: $t),*) -> $ret {
-            use libc;
             use super::os;
 
             weak! { fn $name($($t),*) -> $ret }
index f082887ce205a4a02c0127eb2151deae6d423dad..b9098548b9c1e08481ba8ab2630630eaab6d9a5e 100644 (file)
@@ -16,9 +16,7 @@
 //! The crate itself provides a global allocator which on wasm has no
 //! synchronization as there are no threads!
 
-extern crate dlmalloc;
-
-use alloc::{GlobalAlloc, Layout, System};
+use crate::alloc::{GlobalAlloc, Layout, System};
 
 static mut DLMALLOC: dlmalloc::Dlmalloc = dlmalloc::DLMALLOC_INIT;
 
@@ -51,8 +49,8 @@ unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut
 
 #[cfg(target_feature = "atomics")]
 mod lock {
-    use arch::wasm32;
-    use sync::atomic::{AtomicI32, Ordering::SeqCst};
+    use crate::arch::wasm32;
+    use crate::sync::atomic::{AtomicI32, Ordering::SeqCst};
 
     static LOCKED: AtomicI32 = AtomicI32::new(0);
 
index cea56091adcba6ab2630cc5128995fee89426e16..b3c77b869956364326312711471bff4e66fa2556 100644 (file)
@@ -1,7 +1,7 @@
-use ffi::OsString;
-use marker::PhantomData;
-use vec;
-use sys::ArgsSysCall;
+use crate::ffi::OsString;
+use crate::marker::PhantomData;
+use crate::vec;
+use crate::sys::ArgsSysCall;
 
 pub unsafe fn init(_argc: isize, _argv: *const *const u8) {
     // On wasm these should always be null, so there's nothing for us to do here
index 52d4a63bb6384aa428d93564b7b7895c05386119..7d56b298997aa33631d953f2dbd2a24849d8f9bb 100644 (file)
@@ -1,6 +1,6 @@
-use io;
-use sys::unsupported;
-use sys_common::backtrace::Frame;
+use crate::io;
+use crate::sys::unsupported;
+use crate::sys_common::backtrace::Frame;
 
 pub struct BacktraceContext;
 
index 22df0f60db5a18e08614f1c21a31f5139e955b9f..9c7cc3c63b15f06db3ffdff14e8ed9405546640b 100644 (file)
@@ -1,5 +1,5 @@
-use sys::mutex::Mutex;
-use time::Duration;
+use crate::sys::mutex::Mutex;
+use crate::time::Duration;
 
 pub struct Condvar { }
 
index 099404c75d42d6bebe2926a81a48973f7b7dd481..580d21218445f34bbec26c09cbada498992b4b5f 100644 (file)
@@ -1,9 +1,9 @@
-use arch::wasm32;
-use cmp;
-use mem;
-use sync::atomic::{AtomicUsize, Ordering::SeqCst};
-use sys::mutex::Mutex;
-use time::Duration;
+use crate::arch::wasm32;
+use crate::cmp;
+use crate::mem;
+use crate::sync::atomic::{AtomicUsize, Ordering::SeqCst};
+use crate::sys::mutex::Mutex;
+use crate::time::Duration;
 
 pub struct Condvar {
     cnt: AtomicUsize,
index 8b1c4476bc4178dd321d007c62264b7ead806558..485d2c87fbd2d2003f2bf7dea01f192ae4e1243c 100644 (file)
@@ -1,10 +1,10 @@
-use ffi::OsString;
-use fmt;
-use hash::{Hash, Hasher};
-use io::{self, SeekFrom};
-use path::{Path, PathBuf};
-use sys::time::SystemTime;
-use sys::{unsupported, Void};
+use crate::ffi::OsString;
+use crate::fmt;
+use crate::hash::{Hash, Hasher};
+use crate::io::{self, SeekFrom};
+use crate::path::{Path, PathBuf};
+use crate::sys::time::SystemTime;
+use crate::sys::{unsupported, Void};
 
 pub struct File(Void);
 
index e71c6bcd7fe76dc447a5813d09f88f7aa36349f3..1828cce4e520e2bd81f03d5d8e16a5f4cce97078 100644 (file)
 //! compiling for wasm. That way it's a compile time error for something that's
 //! guaranteed to be a runtime error!
 
-use os::raw::c_char;
-use ptr;
-use sys::os_str::Buf;
-use sys_common::{AsInner, FromInner};
-use ffi::{OsString, OsStr};
-use time::Duration;
+use crate::os::raw::c_char;
+use crate::ptr;
+use crate::sys::os_str::Buf;
+use crate::sys_common::{AsInner, FromInner};
+use crate::ffi::{OsString, OsStr};
+use crate::time::Duration;
 
 pub mod alloc;
 pub mod args;
 pub fn init() {
 }
 
-pub fn unsupported<T>() -> ::io::Result<T> {
+pub fn unsupported<T>() -> crate::io::Result<T> {
     Err(unsupported_err())
 }
 
-pub fn unsupported_err() -> ::io::Error {
-    ::io::Error::new(::io::ErrorKind::Other,
+pub fn unsupported_err() -> crate::io::Error {
+    crate::io::Error::new(crate::io::ErrorKind::Other,
                    "operation not supported on wasm yet")
 }
 
-pub fn decode_error_kind(_code: i32) -> ::io::ErrorKind {
-    ::io::ErrorKind::Other
+pub fn decode_error_kind(_code: i32) -> crate::io::ErrorKind {
+    crate::io::ErrorKind::Other
 }
 
 // This enum is used as the storage for a bunch of types which can't actually
@@ -168,7 +168,7 @@ pub fn perform(code: usize) -> ! {
         };
         unsafe {
             syscall(SysCallIndex::Exit, &mut call_record);
-            ::intrinsics::abort();
+            crate::intrinsics::abort();
         }
     }
 }
index cf0a0a8638b13725cd2392ac897f7d148036763a..9d713e9b439038c19dd8c197060cda611f354076 100644 (file)
@@ -1,4 +1,4 @@
-use cell::UnsafeCell;
+use crate::cell::UnsafeCell;
 
 pub struct Mutex {
     locked: UnsafeCell<bool>,
index da03e8fa23f18ba6bb27e42b8ead228da241cab4..0e4f3d80aa93870341d82f32466e3cf0a3db8cd0 100644 (file)
@@ -1,8 +1,8 @@
-use arch::wasm32;
-use cell::UnsafeCell;
-use mem;
-use sync::atomic::{AtomicUsize, AtomicU32, Ordering::SeqCst};
-use sys::thread;
+use crate::arch::wasm32;
+use crate::cell::UnsafeCell;
+use crate::mem;
+use crate::sync::atomic::{AtomicUsize, AtomicU32, Ordering::SeqCst};
+use crate::sys::thread;
 
 pub struct Mutex {
     locked: AtomicUsize,
index d9f5d538432055d59c086479e6e555469e7a8edd..1249832fb09d2db0b232df85e58a775a562b23da 100644 (file)
@@ -1,9 +1,9 @@
-use fmt;
-use io::{self, IoVec, IoVecMut};
-use net::{SocketAddr, Shutdown, Ipv4Addr, Ipv6Addr};
-use time::Duration;
-use sys::{unsupported, Void};
-use convert::TryFrom;
+use crate::fmt;
+use crate::io::{self, IoVec, IoVecMut};
+use crate::net::{SocketAddr, Shutdown, Ipv4Addr, Ipv6Addr};
+use crate::time::Duration;
+use crate::sys::{unsupported, Void};
+use crate::convert::TryFrom;
 
 pub struct TcpStream(Void);
 
index 9b278dfb9f8b2c70f355fa78209219ba0a909426..145f9ccd73a8fe49343327aa5151b6521afcb185 100644 (file)
@@ -1,10 +1,10 @@
-use error::Error as StdError;
-use ffi::{OsString, OsStr};
-use fmt;
-use io;
-use path::{self, PathBuf};
-use str;
-use sys::{unsupported, Void, ExitSysCall, GetEnvSysCall, SetEnvSysCall};
+use crate::error::Error as StdError;
+use crate::ffi::{OsString, OsStr};
+use crate::fmt;
+use crate::io;
+use crate::path::{self, PathBuf};
+use crate::str;
+use crate::sys::{unsupported, Void, ExitSysCall, GetEnvSysCall, SetEnvSysCall};
 
 pub fn errno() -> i32 {
     0
index 9d5e084feb2d6bbff22b028b5c9dd8db8e0a5785..79b43458d00f3cad06079838d2c0ab3b3c3ef06a 100644 (file)
@@ -1,14 +1,15 @@
 /// The underlying OsString/OsStr implementation on Unix systems: just
 /// a `Vec<u8>`/`[u8]`.
 
-use borrow::Cow;
-use fmt;
-use str;
-use mem;
-use rc::Rc;
-use sync::Arc;
-use sys_common::{AsInner, IntoInner};
-use sys_common::bytestring::debug_fmt_bytestring;
+use crate::borrow::Cow;
+use crate::fmt;
+use crate::str;
+use crate::mem;
+use crate::rc::Rc;
+use crate::sync::Arc;
+use crate::sys_common::{AsInner, IntoInner};
+use crate::sys_common::bytestring::debug_fmt_bytestring;
+
 use core::str::lossy::Utf8Lossy;
 
 #[derive(Clone, Hash)]
index 2ef78fb2f86dcd7874323c235d9eba06a1f952c9..5c062e7c97cd3d5072843a62b02c5b1fbe25eb25 100644 (file)
@@ -1,5 +1,5 @@
-use path::Prefix;
-use ffi::OsStr;
+use crate::path::Prefix;
+use crate::ffi::OsStr;
 
 #[inline]
 pub fn is_sep_byte(b: u8) -> bool {
index ac48a6dc03323e51940bfd02fbea3b3bf08bbc41..2582b993b608eda93136a5558784899814987cae 100644 (file)
@@ -1,5 +1,5 @@
-use io;
-use sys::Void;
+use crate::io;
+use crate::sys::Void;
 
 pub struct AnonPipe(Void);
 
index 5357d931c73677ff820626a285f985262db28c44..c49daaa16320e2b04385cf5e1212948e6b4f7edd 100644 (file)
@@ -1,10 +1,10 @@
-use ffi::OsStr;
-use fmt;
-use io;
-use sys::fs::File;
-use sys::pipe::AnonPipe;
-use sys::{unsupported, Void};
-use sys_common::process::{CommandEnv, DefaultEnvKey};
+use crate::ffi::OsStr;
+use crate::fmt;
+use crate::io;
+use crate::sys::fs::File;
+use crate::sys::pipe::AnonPipe;
+use crate::sys::{unsupported, Void};
+use crate::sys_common::process::{CommandEnv, DefaultEnvKey};
 
 ////////////////////////////////////////////////////////////////////////////////
 // Command
index 9f172859b7e65d960feba380e08597653c3248c9..a2b07c7fa1fc02db7dda41d3adcd510096e56678 100644 (file)
@@ -1,4 +1,4 @@
-use cell::UnsafeCell;
+use crate::cell::UnsafeCell;
 
 pub struct RWLock {
     mode: UnsafeCell<isize>,
index 404b33bca41b43faf3497985475c9e3c25a12d23..c705568cec992a0923ce82b194c5d5ae6bb4d4dc 100644 (file)
@@ -1,6 +1,6 @@
-use cell::UnsafeCell;
-use sys::mutex::Mutex;
-use sys::condvar::Condvar;
+use crate::cell::UnsafeCell;
+use crate::sys::mutex::Mutex;
+use crate::sys::condvar::Condvar;
 
 pub struct RWLock {
     lock: Mutex,
index d7540fd815c98b01b3bd1590e02d0ee3ea27ce62..b8899a9c847465e13d944ee57cd7a6319cedd43e 100644 (file)
@@ -1,5 +1,5 @@
-use io;
-use sys::{ReadSysCall, WriteSysCall};
+use crate::io;
+use crate::sys::{ReadSysCall, WriteSysCall};
 
 pub struct Stdin;
 pub struct Stdout;
index c2322088e8e5af36b25e674139023db7c17bcd88..a65c413119f8c7d13a0c975f7f836cedb4fbf170 100644 (file)
@@ -1,8 +1,8 @@
-use boxed::FnBox;
-use ffi::CStr;
-use io;
-use sys::{unsupported, Void};
-use time::Duration;
+use crate::boxed::FnBox;
+use crate::ffi::CStr;
+use crate::io;
+use crate::sys::{unsupported, Void};
+use crate::time::Duration;
 
 pub struct Thread(Void);
 
@@ -31,8 +31,8 @@ pub fn sleep(_dur: Duration) {
 
     #[cfg(target_feature = "atomics")]
     pub fn sleep(dur: Duration) {
-        use arch::wasm32;
-        use cmp;
+        use crate::arch::wasm32;
+        use crate::cmp;
 
         // Use an atomic wait to block the current thread artificially with a
         // timeout listed. Note that we should never be notified (return value
@@ -76,7 +76,7 @@ pub fn my_id() -> u32 {
         // you'd like to use them be sure to update that and make sure everyone
         // agrees what's what.
         pub fn tcb_get() -> *mut u8 {
-            use mem;
+            use crate::mem;
             assert_eq!(mem::size_of::<*mut u8>(), mem::size_of::<u32>());
             unsafe { __wbindgen_tcb_get() as *mut u8 }
         }
index c7c385da8c3763ac2de61920ae472041037cf4df..29e9854bcfccb1f984981a39bcb55ff3efd6a35e 100644 (file)
@@ -1,5 +1,5 @@
-use boxed::Box;
-use ptr;
+use crate::boxed::Box;
+use crate::ptr;
 
 pub type Key = usize;
 
index d1d0af252c8c071845d5cb99cdd029cc55466d91..b408ad0d5c1f82ca3e6e5b04baff907765530b58 100644 (file)
@@ -1,5 +1,5 @@
-use sys::thread;
-use sync::atomic::{AtomicUsize, Ordering::SeqCst};
+use crate::sys::thread;
+use crate::sync::atomic::{AtomicUsize, Ordering::SeqCst};
 
 const MAX_KEYS: usize = 128;
 static NEXT_KEY: AtomicUsize = AtomicUsize::new(0);
index 31798466fed2ae493f1346fd5ecc789e5f35d9ef..c1228a1b75e39e35741e271eee31891b5b2cf401 100644 (file)
@@ -1,5 +1,5 @@
-use time::Duration;
-use sys::{TimeSysCall, TimeClock};
+use crate::time::Duration;
+use crate::sys::{TimeSysCall, TimeClock};
 
 #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
 pub struct Instant(Duration);
index 0d7f803c7eef6d1bf2e6fc9e48dd806aa7c36078..a33c4019a2e6b51d7d6dca46c6a8708d9240cd2a 100644 (file)
@@ -1,6 +1,6 @@
-use alloc::{GlobalAlloc, Layout, System};
-use sys::c;
-use sys_common::alloc::{MIN_ALIGN, realloc_fallback};
+use crate::alloc::{GlobalAlloc, Layout, System};
+use crate::sys::c;
+use crate::sys_common::alloc::{MIN_ALIGN, realloc_fallback};
 
 #[repr(C)]
 struct Header(*mut u8);
index f67280691097ce0e2afce060ac86c9472e5bfef3..3f10e6e5983eb6b433e9110973dadd56cf48a5c5 100644 (file)
@@ -1,14 +1,15 @@
 #![allow(dead_code)] // runtime init functions not used during testing
 
-use os::windows::prelude::*;
-use sys::windows::os::current_exe;
-use sys::c;
-use ffi::OsString;
-use fmt;
-use vec;
+use crate::os::windows::prelude::*;
+use crate::sys::windows::os::current_exe;
+use crate::sys::c;
+use crate::ffi::OsString;
+use crate::fmt;
+use crate::vec;
+use crate::slice;
+use crate::path::PathBuf;
+
 use core::iter;
-use slice;
-use path::PathBuf;
 
 pub unsafe fn init(_argc: isize, _argv: *const *const u8) { }
 
@@ -80,7 +81,7 @@ unsafe fn parse_lp_cmd_line<F: Fn() -> OsString>(lp_cmd_line: *const u16, exe_na
         // "However, if lpCmdLine starts with any amount of whitespace, CommandLineToArgvW
         // will consider the first argument to be an empty string. Excess whitespace at the
         // end of lpCmdLine is ignored."
-        0...SPACE => {
+        0..=SPACE => {
             ret_val.push(OsString::new());
             &cmd_line[1..]
         },
@@ -192,8 +193,8 @@ fn len(&self) -> usize { self.parsed_args_list.len() }
 
 #[cfg(test)]
 mod tests {
-    use sys::windows::args::*;
-    use ffi::OsString;
+    use crate::sys::windows::args::*;
+    use crate::ffi::OsString;
 
     fn chk(string: &str, parts: &[&str]) {
         let mut wide: Vec<u16> = OsString::from(string).encode_wide().collect();
index e8aa939974232d44f1071e6d729096954c5eae53..7ac1f8122f781ce5e2a5a5bf04cbb12caa219851 100644 (file)
@@ -1,10 +1,11 @@
-use io;
-use sys::c;
+use crate::io;
+use crate::sys::c;
+use crate::path::PathBuf;
+use crate::fs::{OpenOptions, File};
+use crate::sys::ext::fs::OpenOptionsExt;
+use crate::sys::handle::Handle;
+
 use libc::c_char;
-use path::PathBuf;
-use fs::{OpenOptions, File};
-use sys::ext::fs::OpenOptionsExt;
-use sys::handle::Handle;
 use super::super::{fill_utf16_buf, os2path, to_u16s, wide_char_to_multi_byte};
 
 fn query_full_process_image_name() -> io::Result<PathBuf> {
index 4bda8ac91da62d8b073e1e178c72b8799afd0e62..c5b0cc8721087d1e0ffcbbf86bfb12c8233179e4 100644 (file)
 
 #![allow(deprecated)] // dynamic_lib
 
-use io;
+use crate::io;
+use crate::mem;
+use crate::ptr;
+use crate::sys::c;
+use crate::sys::dynamic_lib::DynamicLibrary;
+use crate::sys_common::backtrace::Frame;
+
 use libc::c_void;
-use mem;
-use ptr;
-use sys::c;
-use sys::dynamic_lib::DynamicLibrary;
-use sys_common::backtrace::Frame;
 
 macro_rules! sym {
     ($lib:expr, $e:expr, $t:ident) => (
index d44df7e5f248cee3d7fba1ba0f125ee881fd23a8..9497d51ac1799b0f361f14fd6b762b505781f9a2 100644 (file)
@@ -4,11 +4,11 @@
 
 #[cfg(target_env = "gnu")]
 mod printing {
-    pub use sys_common::gnu::libbacktrace::{foreach_symbol_fileline, resolve_symname};
+    pub use crate::sys_common::gnu::libbacktrace::{foreach_symbol_fileline, resolve_symname};
 
     // dummy functions to mirror those present in msvc version.
-    use sys::dynamic_lib::DynamicLibrary;
-    use io;
+    use crate::sys::dynamic_lib::DynamicLibrary;
+    use crate::io;
     pub struct PrintingFnsEx {}
     pub struct PrintingFns64 {}
     pub fn load_printing_fns_ex(_: &DynamicLibrary) -> io::Result<PrintingFnsEx> {
index b186bb423345cb4aa32da60c194d00bbc2fa2f50..13a1512d0eb39e421a9dc4195bd43b46a6859776 100644 (file)
@@ -1,12 +1,13 @@
-use ffi::CStr;
-use io;
+use crate::ffi::CStr;
+use crate::io;
+use crate::mem;
+use crate::sys::backtrace::BacktraceContext;
+use crate::sys::backtrace::StackWalkVariant;
+use crate::sys::c;
+use crate::sys::dynamic_lib::DynamicLibrary;
+use crate::sys_common::backtrace::Frame;
+
 use libc::{c_char, c_ulong};
-use mem;
-use sys::backtrace::BacktraceContext;
-use sys::backtrace::StackWalkVariant;
-use sys::c;
-use sys::dynamic_lib::DynamicLibrary;
-use sys_common::backtrace::Frame;
 
 // Structs holding printing functions and loaders for them
 // Two versions depending on whether dbghelp.dll has StackWalkEx or not
@@ -190,7 +191,7 @@ fn foreach_symbol_fileline_iternal<F, G>(
 {
     unsafe {
         let mut line: c::IMAGEHLP_LINE64 = mem::zeroed();
-        line.SizeOfStruct = ::mem::size_of::<c::IMAGEHLP_LINE64>() as u32;
+        line.SizeOfStruct = mem::size_of::<c::IMAGEHLP_LINE64>() as u32;
 
         let ret = line_getter(
             context.handle,
index a78b599204b200ddeddecd41c52c9af0ca6065d8..518eccf754cffa008ad1cefce354a02b8a7cc62f 100644 (file)
@@ -4,11 +4,12 @@
 #![cfg_attr(test, allow(dead_code))]
 #![unstable(issue = "0", feature = "windows_c")]
 
-use os::raw::{c_int, c_uint, c_ulong, c_long, c_longlong, c_ushort, c_char};
+use crate::os::raw::{c_int, c_uint, c_ulong, c_long, c_longlong, c_ushort, c_char};
 #[cfg(target_arch = "x86_64")]
-use os::raw::c_ulonglong;
+use crate::os::raw::c_ulonglong;
+use crate::ptr;
+
 use libc::{wchar_t, size_t, c_void};
-use ptr;
 
 pub use self::FILE_INFO_BY_HANDLE_CLASS::*;
 pub use self::EXCEPTION_DISPOSITION::*;
@@ -65,7 +66,7 @@
 pub type PLARGE_INTEGER = *mut c_longlong;
 pub type PSRWLOCK = *mut SRWLOCK;
 
-pub type SOCKET = ::os::windows::raw::SOCKET;
+pub type SOCKET = crate::os::windows::raw::SOCKET;
 pub type socklen_t = c_int;
 pub type ADDRESS_FAMILY = USHORT;
 
@@ -450,7 +451,7 @@ pub struct MOUNT_POINT_REPARSE_BUFFER {
     pub PathBuffer: WCHAR,
 }
 
-pub type LPPROGRESS_ROUTINE = ::option::Option<unsafe extern "system" fn(
+pub type LPPROGRESS_ROUTINE = crate::option::Option<unsafe extern "system" fn(
     TotalFileSize: LARGE_INTEGER,
     TotalBytesTransferred: LARGE_INTEGER,
     StreamSize: LARGE_INTEGER,
index b6c55344c6267ddf7840d9623de275e30efecdcd..748c1616d1d32304a42e74e20489ffff1f8c657f 100644 (file)
@@ -11,9 +11,9 @@
 //! manner we pay a semi-large one-time cost up front for detecting whether a
 //! function is available but afterwards it's just a load and a jump.
 
-use ffi::CString;
-use sync::atomic::{AtomicUsize, Ordering};
-use sys::c;
+use crate::ffi::CString;
+use crate::sync::atomic::{AtomicUsize, Ordering};
+use crate::sys::c;
 
 pub fn lookup(module: &str, symbol: &str) -> Option<usize> {
     let mut module: Vec<u16> = module.encode_utf16().collect();
@@ -44,14 +44,14 @@ pub fn $symbol:ident($($argname:ident: $argtype:ty),*)
     )*) => ($(
         #[allow(unused_variables)]
         pub unsafe fn $symbol($($argname: $argtype),*) -> $rettype {
-            use sync::atomic::{AtomicUsize, Ordering};
-            use mem;
+            use crate::sync::atomic::{AtomicUsize, Ordering};
+            use crate::mem;
             type F = unsafe extern "system" fn($($argtype),*) -> $rettype;
 
             static PTR: AtomicUsize = AtomicUsize::new(0);
 
             fn load() -> usize {
-                ::sys::compat::store_func(&PTR,
+                crate::sys::compat::store_func(&PTR,
                                           stringify!($module),
                                           stringify!($symbol),
                                           fallback as usize)
index 48d8af7391308de2d9da2801fc6809e12a7e5878..62835ea7c94f3acbcb5272c77f776f9e5ea88f82 100644 (file)
@@ -1,8 +1,8 @@
-use cell::UnsafeCell;
-use sys::c;
-use sys::mutex::{self, Mutex};
-use sys::os;
-use time::Duration;
+use crate::cell::UnsafeCell;
+use crate::sys::c;
+use crate::sys::mutex::{self, Mutex};
+use crate::sys::os;
+use crate::time::Duration;
 
 pub struct Condvar { inner: UnsafeCell<c::CONDITION_VARIABLE> }
 
index fa3c5ecb977613666599c6142fd00f1539bddf41..b9d5105cb73070e484055b050165eb3d42bfffe7 100644 (file)
@@ -1,8 +1,8 @@
-use os::windows::prelude::*;
+use crate::os::windows::prelude::*;
 
-use ffi::{CString, OsStr};
-use io;
-use sys::c;
+use crate::ffi::{CString, OsStr};
+use crate::io;
+use crate::sys::c;
 
 pub struct DynamicLibrary {
     handle: c::HMODULE,
index 6508c0cf447d19a61e300639827f80607c6b46b2..547b1ef796b4a10d046736ce5da8c0842f9c4e3e 100644 (file)
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
-use ffi::{OsString, OsStr};
-use sys::os_str::Buf;
-use sys_common::wtf8::Wtf8Buf;
-use sys_common::{FromInner, AsInner};
+use crate::ffi::{OsString, OsStr};
+use crate::sys::os_str::Buf;
+use crate::sys_common::wtf8::Wtf8Buf;
+use crate::sys_common::{FromInner, AsInner};
 
 #[stable(feature = "rust1", since = "1.0.0")]
-pub use sys_common::wtf8::EncodeWide;
+pub use crate::sys_common::wtf8::EncodeWide;
 
 /// Windows-specific extensions to [`OsString`].
 ///
index 89038da6295f2e5371be2801de1e3c5889b76fe1..b6da59502806b7f016cc63d18171fd745dd23fe5 100644 (file)
@@ -2,11 +2,11 @@
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
-use fs::{self, OpenOptions, Metadata};
-use io;
-use path::Path;
-use sys;
-use sys_common::{AsInnerMut, AsInner};
+use crate::fs::{self, OpenOptions, Metadata};
+use crate::io;
+use crate::path::Path;
+use crate::sys;
+use crate::sys_common::{AsInnerMut, AsInner};
 
 /// Windows-specific extensions to [`File`].
 ///
index fbe0426ce5a8cb33bff80d400a7c68e24c645ee7..1a7d734b89e4ba8bacb0dacf35e3ade81f8757ad 100644 (file)
@@ -1,12 +1,12 @@
 #![stable(feature = "rust1", since = "1.0.0")]
 
-use fs;
-use os::windows::raw;
-use net;
-use sys_common::{self, AsInner, FromInner, IntoInner};
-use sys;
-use io;
-use sys::c;
+use crate::fs;
+use crate::os::windows::raw;
+use crate::net;
+use crate::sys_common::{self, AsInner, FromInner, IntoInner};
+use crate::sys;
+use crate::sys::c;
+use crate::io;
 
 /// Raw HANDLEs.
 #[stable(feature = "rust1", since = "1.0.0")]
index 15f0fd4e11f43ceb31893a4d8511abb4db167602..b2e6cdead4f3b2a19b5fd84c0e2c3d41f12d02ef 100644 (file)
@@ -2,10 +2,10 @@
 
 #![stable(feature = "process_extensions", since = "1.2.0")]
 
-use os::windows::io::{FromRawHandle, RawHandle, AsRawHandle, IntoRawHandle};
-use process;
-use sys;
-use sys_common::{AsInnerMut, AsInner, FromInner, IntoInner};
+use crate::os::windows::io::{FromRawHandle, RawHandle, AsRawHandle, IntoRawHandle};
+use crate::process;
+use crate::sys;
+use crate::sys_common::{AsInnerMut, AsInner, FromInner, IntoInner};
 
 #[stable(feature = "process_extensions", since = "1.2.0")]
 impl FromRawHandle for process::Stdio {
index 77428d9e7747efd5bc0ddf7512a2117a012ead24..d2bab2720369fbe13c050a0962347642730947c0 100644 (file)
@@ -2,7 +2,7 @@
 
 #![stable(feature = "raw_ext", since = "1.1.0")]
 
-use os::raw::c_void;
+use crate::os::raw::c_void;
 
 #[stable(feature = "raw_ext", since = "1.1.0")] pub type HANDLE = *mut c_void;
 #[cfg(target_pointer_width = "32")]
index 29d612fedc0f0346cafa9d55d02f0af224ebe78b..fdc7e7fa32f0e6248df4ec9e9da25795ffa0c19e 100644 (file)
@@ -2,9 +2,9 @@
 
 #![stable(feature = "thread_extensions", since = "1.9.0")]
 
-use os::windows::io::{RawHandle, AsRawHandle, IntoRawHandle};
-use thread;
-use sys_common::{AsInner, IntoInner};
+use crate::os::windows::io::{RawHandle, AsRawHandle, IntoRawHandle};
+use crate::thread;
+use crate::sys_common::{AsInner, IntoInner};
 
 #[stable(feature = "thread_extensions", since = "1.9.0")]
 impl<T> AsRawHandle for thread::JoinHandle<T> {
index f8b936b48103822d5b503fb607831cafcc430f06..0ccc67e3fd54ebb1fc0ace58dfd366e7b976fe5f 100644 (file)
@@ -1,7 +1,7 @@
 #![unstable(feature = "thread_local_internals", issue = "0")]
 #![cfg(target_thread_local)]
 
-pub use sys_common::thread_local::register_dtor_fallback as register_dtor;
+pub use crate::sys_common::thread_local::register_dtor_fallback as register_dtor;
 
 pub fn requires_move_before_drop() -> bool {
     false
index 533b8ae9ba2c043644affba3d7232667ab64258b..f19c111f09aa2ed4da8bb319bc37d62c1a0ef098 100644 (file)
@@ -1,17 +1,17 @@
-use os::windows::prelude::*;
-
-use ffi::OsString;
-use fmt;
-use io::{self, Error, SeekFrom};
-use mem;
-use path::{Path, PathBuf};
-use ptr;
-use slice;
-use sync::Arc;
-use sys::handle::Handle;
-use sys::time::SystemTime;
-use sys::{c, cvt};
-use sys_common::FromInner;
+use crate::os::windows::prelude::*;
+
+use crate::ffi::OsString;
+use crate::fmt;
+use crate::io::{self, Error, SeekFrom};
+use crate::mem;
+use crate::path::{Path, PathBuf};
+use crate::ptr;
+use crate::slice;
+use crate::sync::Arc;
+use crate::sys::handle::Handle;
+use crate::sys::time::SystemTime;
+use crate::sys::{c, cvt};
+use crate::sys_common::FromInner;
 
 use super::to_u16s;
 
index 855efbd3eb5d6261b62e5ee269770ad8dd697f8f..02549088c8704f158329fc8d610bafd970ad934e 100644 (file)
@@ -1,13 +1,12 @@
 #![unstable(issue = "0", feature = "windows_handle")]
 
-use cmp;
-use io::{ErrorKind, Read};
-use io;
-use mem;
-use ops::Deref;
-use ptr;
-use sys::c;
-use sys::cvt;
+use crate::cmp;
+use crate::io::{self, ErrorKind, Read};
+use crate::mem;
+use crate::ops::Deref;
+use crate::ptr;
+use crate::sys::c;
+use crate::sys::cvt;
 
 /// An owned container for `HANDLE` object, closing them on Drop.
 ///
index 662e304792386e303a4633d2164c02736faf7f3f..54dd271c9d666bb028b2e007bb086269eeaffcee 100644 (file)
@@ -1,6 +1,6 @@
-use marker::PhantomData;
-use slice;
-use sys::c;
+use crate::marker::PhantomData;
+use crate::slice;
+use crate::sys::c;
 
 #[repr(transparent)]
 pub struct IoVec<'a> {
index 56c76a169feb8959519308d5d0111489a5174aa7..1425254a2e12605911778573a6e3225352d64ca9 100644 (file)
@@ -1,11 +1,11 @@
 #![allow(missing_docs, nonstandard_style)]
 
-use ptr;
-use ffi::{OsStr, OsString};
-use io::ErrorKind;
-use os::windows::ffi::{OsStrExt, OsStringExt};
-use path::PathBuf;
-use time::Duration;
+use crate::ptr;
+use crate::ffi::{OsStr, OsString};
+use crate::io::ErrorKind;
+use crate::os::windows::ffi::{OsStrExt, OsStringExt};
+use crate::path::PathBuf;
+use crate::time::Duration;
 
 pub use libc::strlen;
 pub use self::rand::hashmap_random_keys;
@@ -76,11 +76,11 @@ pub fn decode_error_kind(errno: i32) -> ErrorKind {
     }
 }
 
-pub fn to_u16s<S: AsRef<OsStr>>(s: S) -> ::io::Result<Vec<u16>> {
-    fn inner(s: &OsStr) -> ::io::Result<Vec<u16>> {
+pub fn to_u16s<S: AsRef<OsStr>>(s: S) -> crate::io::Result<Vec<u16>> {
+    fn inner(s: &OsStr) -> crate::io::Result<Vec<u16>> {
         let mut maybe_result: Vec<u16> = s.encode_wide().collect();
         if maybe_result.iter().any(|&u| u == 0) {
-            return Err(::io::Error::new(::io::ErrorKind::InvalidInput,
+            return Err(crate::io::Error::new(ErrorKind::InvalidInput,
                                         "strings passed to WinAPI cannot contain NULs"));
         }
         maybe_result.push(0);
@@ -103,7 +103,7 @@ fn inner(s: &OsStr) -> ::io::Result<Vec<u16>> {
 // Once the syscall has completed (errors bail out early) the second closure is
 // yielded the data which has been read from the syscall. The return value
 // from this closure is then the return value of the function.
-fn fill_utf16_buf<F1, F2, T>(mut f1: F1, f2: F2) -> ::io::Result<T>
+fn fill_utf16_buf<F1, F2, T>(mut f1: F1, f2: F2) -> crate::io::Result<T>
     where F1: FnMut(*mut u16, c::DWORD) -> c::DWORD,
           F2: FnOnce(&[u16]) -> T
 {
@@ -135,7 +135,7 @@ fn fill_utf16_buf<F1, F2, T>(mut f1: F1, f2: F2) -> ::io::Result<T>
             c::SetLastError(0);
             let k = match f1(buf.as_mut_ptr(), n as c::DWORD) {
                 0 if c::GetLastError() == 0 => 0,
-                0 => return Err(::io::Error::last_os_error()),
+                0 => return Err(crate::io::Error::last_os_error()),
                 n => n,
             } as usize;
             if k == n && c::GetLastError() == c::ERROR_INSUFFICIENT_BUFFER {
@@ -158,7 +158,7 @@ fn wide_char_to_multi_byte(code_page: u32,
                            flags: u32,
                            s: &[u16],
                            no_default_char: bool)
-                           -> ::io::Result<Vec<i8>> {
+                           -> crate::io::Result<Vec<i8>> {
     unsafe {
         let mut size = c::WideCharToMultiByte(code_page,
                                               flags,
@@ -169,7 +169,7 @@ fn wide_char_to_multi_byte(code_page: u32,
                                               ptr::null(),
                                               ptr::null_mut());
         if size == 0 {
-            return Err(::io::Error::last_os_error());
+            return Err(crate::io::Error::last_os_error());
         }
 
         let mut buf = Vec::with_capacity(size as usize);
@@ -186,10 +186,10 @@ fn wide_char_to_multi_byte(code_page: u32,
                                       if no_default_char { &mut used_default_char }
                                       else { ptr::null_mut() });
         if size == 0 {
-            return Err(::io::Error::last_os_error());
+            return Err(crate::io::Error::last_os_error());
         }
         if no_default_char && used_default_char == c::TRUE {
-            return Err(::io::Error::new(::io::ErrorKind::InvalidData,
+            return Err(crate::io::Error::new(crate::io::ErrorKind::InvalidData,
                                       "string cannot be converted to requested code page"));
         }
 
@@ -221,9 +221,9 @@ fn is_zero(&self) -> bool {
 
 impl_is_zero! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize }
 
-pub fn cvt<I: IsZero>(i: I) -> ::io::Result<I> {
+pub fn cvt<I: IsZero>(i: I) -> crate::io::Result<I> {
     if i.is_zero() {
-        Err(::io::Error::last_os_error())
+        Err(crate::io::Error::last_os_error())
     } else {
         Ok(i)
     }
@@ -263,7 +263,7 @@ pub unsafe fn abort_internal() -> ! {
     #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
     {
         asm!("int $$0x29" :: "{ecx}"(7) ::: volatile); // 7 is FAST_FAIL_FATAL_APP_EXIT
-        ::intrinsics::unreachable();
+        crate::intrinsics::unreachable();
     }
-    ::intrinsics::abort();
+    crate::intrinsics::abort();
 }
index f690580ae38bc3fc75f31ec4c043148c6bcb8878..1aa910f05c9c325d093d77e9308aafd63b4c1ff2 100644 (file)
 //! CriticalSection is used and we keep track of who's holding the mutex to
 //! detect recursive locks.
 
-use cell::UnsafeCell;
-use mem::{self, MaybeUninit};
-use sync::atomic::{AtomicUsize, Ordering};
-use sys::c;
-use sys::compat;
+use crate::cell::UnsafeCell;
+use crate::mem::{self, MaybeUninit};
+use crate::sync::atomic::{AtomicUsize, Ordering};
+use crate::sys::c;
+use crate::sys::compat;
 
 pub struct Mutex {
     lock: AtomicUsize,
index 76be26a9d1a578a01ae0b8dc69974809ccf76b6e..1231fd55e252e127d63a8a678089010f8afb3c16 100644 (file)
@@ -1,26 +1,27 @@
 #![unstable(issue = "0", feature = "windows_net")]
 
-use cmp;
-use io::{self, Read, IoVec, IoVecMut};
+use crate::cmp;
+use crate::io::{self, Read, IoVec, IoVecMut};
+use crate::mem;
+use crate::net::{SocketAddr, Shutdown};
+use crate::ptr;
+use crate::sync::Once;
+use crate::sys::c;
+use crate::sys;
+use crate::sys_common::{self, AsInner, FromInner, IntoInner};
+use crate::sys_common::net;
+use crate::time::Duration;
+
 use libc::{c_int, c_void, c_ulong, c_long};
-use mem;
-use net::{SocketAddr, Shutdown};
-use ptr;
-use sync::Once;
-use sys::c;
-use sys;
-use sys_common::{self, AsInner, FromInner, IntoInner};
-use sys_common::net;
-use time::Duration;
 
 pub type wrlen_t = i32;
 
 pub mod netc {
-    pub use sys::c::*;
-    pub use sys::c::SOCKADDR as sockaddr;
-    pub use sys::c::SOCKADDR_STORAGE_LH as sockaddr_storage;
-    pub use sys::c::ADDRINFOA as addrinfo;
-    pub use sys::c::ADDRESS_FAMILY as sa_family_t;
+    pub use crate::sys::c::*;
+    pub use crate::sys::c::SOCKADDR as sockaddr;
+    pub use crate::sys::c::SOCKADDR_STORAGE_LH as sockaddr_storage;
+    pub use crate::sys::c::ADDRINFOA as addrinfo;
+    pub use crate::sys::c::ADDRESS_FAMILY as sa_family_t;
 }
 
 pub struct Socket(c::SOCKET);
index 7399dd41a41cf3c552573188a7bca40d9b54f331..5b433ddfb4a384955470f8ac6168a90821883ecf 100644 (file)
@@ -2,18 +2,18 @@
 
 #![allow(nonstandard_style)]
 
-use os::windows::prelude::*;
-
-use error::Error as StdError;
-use ffi::{OsString, OsStr};
-use fmt;
-use io;
-use os::windows::ffi::EncodeWide;
-use path::{self, PathBuf};
-use ptr;
-use slice;
-use sys::{c, cvt};
-use sys::handle::Handle;
+use crate::os::windows::prelude::*;
+
+use crate::error::Error as StdError;
+use crate::ffi::{OsString, OsStr};
+use crate::fmt;
+use crate::io;
+use crate::os::windows::ffi::EncodeWide;
+use crate::path::{self, PathBuf};
+use crate::ptr;
+use crate::slice;
+use crate::sys::{c, cvt};
+use crate::sys::handle::Handle;
 
 use super::to_u16s;
 
@@ -285,8 +285,8 @@ pub fn temp_dir() -> PathBuf {
 }
 
 pub fn home_dir() -> Option<PathBuf> {
-    ::env::var_os("HOME").or_else(|| {
-        ::env::var_os("USERPROFILE")
+    crate::env::var_os("HOME").or_else(|| {
+        crate::env::var_os("USERPROFILE")
     }).map(PathBuf::from).or_else(|| unsafe {
         let me = c::GetCurrentProcess();
         let mut token = ptr::null_mut();
@@ -314,8 +314,8 @@ pub fn getpid() -> u32 {
 
 #[cfg(test)]
 mod tests {
-    use io::Error;
-    use sys::c;
+    use crate::io::Error;
+    use crate::sys::c;
 
     // tests `error_string` above
     #[test]
index 7e4bcd990b1e745f2cbba99d5f8de9f20eec4020..8befa66ecdc9cda69dc5b85557131f0fe077b4b3 100644 (file)
@@ -1,13 +1,13 @@
 /// The underlying OsString/OsStr implementation on Windows is a
 /// wrapper around the "WTF-8" encoding; see the `wtf8` module for more.
 
-use borrow::Cow;
-use fmt;
-use sys_common::wtf8::{Wtf8, Wtf8Buf};
-use mem;
-use rc::Rc;
-use sync::Arc;
-use sys_common::{AsInner, IntoInner, FromInner};
+use crate::borrow::Cow;
+use crate::fmt;
+use crate::sys_common::wtf8::{Wtf8, Wtf8Buf};
+use crate::mem;
+use crate::rc::Rc;
+use crate::sync::Arc;
+use crate::sys_common::{AsInner, IntoInner, FromInner};
 
 #[derive(Clone, Hash)]
 pub struct Buf {
index ad1759e84c328c6587df8827c5fa1527516bb9a0..b8532ca9b0d4ebbae4a5b408bc35e2a4cc9b30d3 100644 (file)
@@ -1,6 +1,6 @@
-use path::Prefix;
-use ffi::OsStr;
-use mem;
+use crate::path::Prefix;
+use crate::ffi::OsStr;
+use crate::mem;
 
 fn os_str_as_u8_slice(s: &OsStr) -> &[u8] {
     unsafe { mem::transmute(s) }
@@ -20,7 +20,7 @@ pub fn is_verbatim_sep(b: u8) -> bool {
 }
 
 pub fn parse_prefix<'a>(path: &'a OsStr) -> Option<Prefix> {
-    use path::Prefix::*;
+    use crate::path::Prefix::*;
     unsafe {
         // The unsafety here stems from converting between &OsStr and &[u8]
         // and back. This is safe to do because (1) we only look at ASCII
index d3b102268f6320fc05e413b092bcfb3d05bb303d..07f4f5f0e58c40281479084e86d3c3d7c4aaeb25 100644 (file)
@@ -1,17 +1,17 @@
-use os::windows::prelude::*;
+use crate::os::windows::prelude::*;
 
-use ffi::OsStr;
-use io;
-use mem;
-use path::Path;
-use ptr;
-use slice;
-use sync::atomic::Ordering::SeqCst;
-use sync::atomic::AtomicUsize;
-use sys::c;
-use sys::fs::{File, OpenOptions};
-use sys::handle::Handle;
-use sys::hashmap_random_keys;
+use crate::ffi::OsStr;
+use crate::io;
+use crate::mem;
+use crate::path::Path;
+use crate::ptr;
+use crate::slice;
+use crate::sync::atomic::Ordering::SeqCst;
+use crate::sync::atomic::AtomicUsize;
+use crate::sys::c;
+use crate::sys::fs::{File, OpenOptions};
+use crate::sys::handle::Handle;
+use crate::sys::hashmap_random_keys;
 
 ////////////////////////////////////////////////////////////////////////////////
 // Anonymous pipes
index 2527168a968c47a5be151a453ad7e69042eed8f4..95f061d22bd43f6ecc7664d2009f8f27a92cd835 100644 (file)
@@ -1,27 +1,28 @@
 #![unstable(feature = "process_internals", issue = "0")]
 
-use collections::BTreeMap;
-use env::split_paths;
-use env;
-use ffi::{OsString, OsStr};
-use fmt;
-use fs;
-use io::{self, Error, ErrorKind};
+use crate::collections::BTreeMap;
+use crate::env::split_paths;
+use crate::env;
+use crate::ffi::{OsString, OsStr};
+use crate::fmt;
+use crate::fs;
+use crate::io::{self, Error, ErrorKind};
+use crate::mem;
+use crate::os::windows::ffi::OsStrExt;
+use crate::path::Path;
+use crate::ptr;
+use crate::sys::mutex::Mutex;
+use crate::sys::c;
+use crate::sys::fs::{OpenOptions, File};
+use crate::sys::handle::Handle;
+use crate::sys::pipe::{self, AnonPipe};
+use crate::sys::stdio;
+use crate::sys::cvt;
+use crate::sys_common::{AsInner, FromInner, IntoInner};
+use crate::sys_common::process::{CommandEnv, EnvKey};
+use crate::borrow::Borrow;
+
 use libc::{c_void, EXIT_SUCCESS, EXIT_FAILURE};
-use mem;
-use os::windows::ffi::OsStrExt;
-use path::Path;
-use ptr;
-use sys::mutex::Mutex;
-use sys::c;
-use sys::fs::{OpenOptions, File};
-use sys::handle::Handle;
-use sys::pipe::{self, AnonPipe};
-use sys::stdio;
-use sys::cvt;
-use sys_common::{AsInner, FromInner, IntoInner};
-use sys_common::process::{CommandEnv, EnvKey};
-use borrow::Borrow;
 
 ////////////////////////////////////////////////////////////////////////////////
 // Command
@@ -537,7 +538,7 @@ fn make_dirp(d: Option<&OsString>) -> io::Result<(*const u16, Vec<u16>)> {
 
 #[cfg(test)]
 mod tests {
-    use ffi::{OsStr, OsString};
+    use crate::ffi::{OsStr, OsString};
     use super::make_command_line;
 
     #[test]
index 4f000dceb2f18ea4e265bec42b50e1ee4fca967c..0193f4defa1fff6f8d52968ed3e95748d1b33a39 100644 (file)
@@ -1,6 +1,6 @@
-use io;
-use mem;
-use sys::c;
+use crate::io;
+use crate::mem;
+use crate::sys::c;
 
 pub fn hashmap_random_keys() -> (u64, u64) {
     let mut v = (0, 0);
index 3cd19470101aa5108d8fa71ba2da6a4accb0dbe9..ef57562fc3a0b1157b232c7e38602a170304f3b4 100644 (file)
@@ -1,5 +1,5 @@
-use cell::UnsafeCell;
-use sys::c;
+use crate::cell::UnsafeCell;
+use crate::sys::c;
 
 pub struct RWLock { inner: UnsafeCell<c::SRWLOCK> }
 
index 0c7de0bc9e8f3beb581edd124c4ad58fcfb27ad6..d5b7765f9ff5fcce2b6bd1b8512857fe02512e0c 100644 (file)
@@ -1,7 +1,7 @@
 #![cfg_attr(test, allow(dead_code))]
 
-use sys_common::util::report_overflow;
-use sys::c;
+use crate::sys_common::util::report_overflow;
+use crate::sys::c;
 
 pub struct Handler;
 
index 99445f4e0d45de75f363258927b791b5d316b0d6..b1e76b3b755dafee2ab107e43a35ce130252a083 100644 (file)
@@ -1,13 +1,13 @@
 #![unstable(issue = "0", feature = "windows_stdio")]
 
-use char::decode_utf16;
-use cmp;
-use io;
-use ptr;
-use str;
-use sys::c;
-use sys::cvt;
-use sys::handle::Handle;
+use crate::char::decode_utf16;
+use crate::cmp;
+use crate::io;
+use crate::ptr;
+use crate::str;
+use crate::sys::c;
+use crate::sys::cvt;
+use crate::sys::handle::Handle;
 
 // Don't cache handles but get them fresh for every read/write. This allows us to track changes to
 // the value over time (such as if a process calls `SetStdHandle` while it's running). See #40490.
@@ -201,7 +201,7 @@ fn read_u16s(handle: c::HANDLE, buf: &mut [u16]) -> io::Result<usize> {
     const CTRL_Z: u16 = 0x1A;
     const CTRL_Z_MASK: c::ULONG = 1 << CTRL_Z;
     let mut input_control = c::CONSOLE_READCONSOLE_CONTROL {
-        nLength: ::mem::size_of::<c::CONSOLE_READCONSOLE_CONTROL>() as c::ULONG,
+        nLength: crate::mem::size_of::<c::CONSOLE_READCONSOLE_CONTROL>() as c::ULONG,
         nInitialChars: 0,
         dwCtrlWakeupMask: CTRL_Z_MASK,
         dwControlKeyState: 0,
index bd7cb673a0dbe48fe51246145f03a635729c3873..1b0a811f13b72f5652e66b52c846c3f0fda6241a 100644 (file)
@@ -1,13 +1,14 @@
-use boxed::FnBox;
-use io;
-use ffi::CStr;
-use mem;
+use crate::boxed::FnBox;
+use crate::io;
+use crate::ffi::CStr;
+use crate::mem;
+use crate::ptr;
+use crate::sys::c;
+use crate::sys::handle::Handle;
+use crate::sys_common::thread::*;
+use crate::time::Duration;
+
 use libc::c_void;
-use ptr;
-use sys::c;
-use sys::handle::Handle;
-use sys_common::thread::*;
-use time::Duration;
 
 use super::to_u16s;
 
index 50bbd5476b366b78aeef39c6760793cad3bca180..4c9734fa0aa61843736d056b71d55ac12b674519 100644 (file)
@@ -1,8 +1,8 @@
-use mem;
-use ptr;
-use sync::atomic::AtomicPtr;
-use sync::atomic::Ordering::SeqCst;
-use sys::c;
+use crate::mem;
+use crate::ptr;
+use crate::sync::atomic::AtomicPtr;
+use crate::sync::atomic::Ordering::SeqCst;
+use crate::sys::c;
 
 pub type Key = c::DWORD;
 pub type Dtor = unsafe extern fn(*mut u8);
@@ -211,7 +211,7 @@ unsafe fn register_dtor(key: Key, dtor: Dtor) {
     #[cfg(target_env = "msvc")]
     unsafe fn reference_tls_used() {
         extern { static _tls_used: u8; }
-        ::intrinsics::volatile_load(&_tls_used);
+        crate::intrinsics::volatile_load(&_tls_used);
     }
     #[cfg(not(target_env = "msvc"))]
     unsafe fn reference_tls_used() {}
index 8a8159af2f1a6ee2b5c4e8eecb8995296dc65726..2c99bca70095cb5fb26427592ef2b7b24eca42b1 100644 (file)
@@ -1,9 +1,10 @@
-use cmp::Ordering;
-use fmt;
-use mem;
-use sys::c;
-use time::Duration;
-use convert::TryInto;
+use crate::cmp::Ordering;
+use crate::fmt;
+use crate::mem;
+use crate::sys::c;
+use crate::time::Duration;
+use crate::convert::TryInto;
+
 use core::hash::{Hash, Hasher};
 
 const NANOS_PER_SEC: u64 = 1_000_000_000;
@@ -172,11 +173,11 @@ fn intervals2dur(intervals: u64) -> Duration {
 
 mod perf_counter {
     use super::{NANOS_PER_SEC};
-    use sync::Once;
-    use sys_common::mul_div_u64;
-    use sys::c;
-    use sys::cvt;
-    use time::Duration;
+    use crate::sync::Once;
+    use crate::sys_common::mul_div_u64;
+    use crate::sys::c;
+    use crate::sys::cvt;
+    use crate::time::Duration;
 
     pub struct PerformanceCounterInstant {
         ts: c::LARGE_INTEGER
index eac6bb454c0cd6fff6286eb03b34c01ac5f9bf01..978a70bee09835c65f0b4bdae0377cadd652f344 100644 (file)
@@ -1,8 +1,8 @@
 #![allow(dead_code)]
 
-use alloc::{GlobalAlloc, Layout, System};
-use cmp;
-use ptr;
+use crate::alloc::{GlobalAlloc, Layout, System};
+use crate::cmp;
+use crate::ptr;
 
 // The minimum alignment guaranteed by the architecture. This value is used to
 // add fast paths for low alignment values.
index cd2d176c2a5c5d439bffeba559fe75a1faf612c2..1181b86161199e3d8401d5e1044e5e96be92f612 100644 (file)
@@ -2,10 +2,10 @@
 //!
 //! Documentation can be found on the `rt::at_exit` function.
 
-use boxed::FnBox;
-use ptr;
-use mem;
-use sys_common::mutex::Mutex;
+use crate::boxed::FnBox;
+use crate::ptr;
+use crate::mem;
+use crate::sys_common::mutex::Mutex;
 
 type Queue = Vec<Box<dyn FnBox()>>;
 
index 347244b0e0d440309732c5b3b6137bbc11e1e6ee..1a80908779e1ac81eabbf027f00e842a7e2aa2e5 100644 (file)
@@ -1,17 +1,18 @@
 /// Common code for printing the backtrace in the same way across the different
 /// supported platforms.
 
-use env;
-use io::prelude::*;
-use io;
-use path::{self, Path};
-use ptr;
+use crate::env;
+use crate::io::prelude::*;
+use crate::io;
+use crate::path::{self, Path};
+use crate::ptr;
+use crate::str;
+use crate::sync::atomic::{self, Ordering};
+use crate::sys::mutex::Mutex;
+
 use rustc_demangle::demangle;
-use str;
-use sync::atomic::{self, Ordering};
-use sys::mutex::Mutex;
 
-pub use sys::backtrace::{
+pub use crate::sys::backtrace::{
     unwind_backtrace,
     resolve_symname,
     foreach_symbol_fileline,
index 915c17374ca02004c639370d32614e4ccbb12a65..273d586a5a0b2d189898b3c383ce0a89bb1bb65b 100644 (file)
@@ -1,6 +1,6 @@
 #![allow(dead_code)]
 
-use fmt::{Formatter, Result, Write};
+use crate::fmt::{Formatter, Result, Write};
 use core::str::lossy::{Utf8Lossy, Utf8LossyChunk};
 
 pub fn debug_fmt_bytestring(slice: &[u8], f: &mut Formatter) -> Result {
@@ -25,7 +25,7 @@ fn write_str_escaped(f: &mut Formatter, s: &str) -> Result {
 #[cfg(test)]
 mod tests {
     use super::*;
-    use fmt::{Formatter, Result, Debug};
+    use crate::fmt::{Formatter, Result, Debug};
 
     #[test]
     fn smoke() {
index ad95879f073556fb0a160776cab848f363be7174..fc59c8356f46a1ebd871d4386953a6395868fd6a 100644 (file)
@@ -1,6 +1,6 @@
-use time::Duration;
-use sys_common::mutex::{self, Mutex};
-use sys::condvar as imp;
+use crate::time::Duration;
+use crate::sys_common::mutex::{self, Mutex};
+use crate::sys::condvar as imp;
 
 /// An OS-based condition variable.
 ///
index 188eb4e4b86b169b645d01447bbbc3e2c25903a8..6cd050242dd950e6090f725a969dc157193418a0 100644 (file)
@@ -1,12 +1,11 @@
-use libc;
-use backtrace_sys::{self, backtrace_state};
+use backtrace_sys::backtrace_state;
 
-use ffi::CStr;
-use io;
-use mem;
-use ptr;
-use sys::backtrace::BacktraceContext;
-use sys_common::backtrace::Frame;
+use crate::ffi::CStr;
+use crate::io;
+use crate::mem;
+use crate::ptr;
+use crate::sys::backtrace::BacktraceContext;
+use crate::sys_common::backtrace::Frame;
 
 pub fn foreach_symbol_fileline<F>(frame: Frame,
                                   mut f: F,
@@ -153,7 +152,7 @@ unsafe fn init_state() -> *mut backtrace_state {
     static mut STATE: *mut backtrace_state = ptr::null_mut();
     if !STATE.is_null() { return STATE  }
 
-    let filename = match ::sys::backtrace::gnu::get_executable_filename() {
+    let filename = match crate::sys::backtrace::gnu::get_executable_filename() {
         Ok((filename, file)) => {
             // filename is purposely leaked here since libbacktrace requires
             // it to stay allocated permanently, file is also leaked so that
index b9071c69b7cec0c585fa46c343ab5a760d905038..44b0963302ddfe5491d5c020dd5edcc7f487b7a5 100644 (file)
@@ -3,10 +3,10 @@
 #[cfg(test)]
 #[allow(dead_code)] // not used on emscripten
 pub mod test {
-    use path::{Path, PathBuf};
-    use env;
-    use rand::{self, RngCore};
-    use fs;
+    use crate::path::{Path, PathBuf};
+    use crate::env;
+    use crate::fs;
+    use rand::RngCore;
 
     pub struct TempDir(PathBuf);
 
index c18b603a6356cb71f3c623fc9b07fdc84ac934f9..1fc32365408b86659a2ae3583c41625e30b3a4a9 100644 (file)
 #![allow(missing_docs)]
 #![allow(missing_debug_implementations)]
 
-use sync::Once;
-use sys;
+use crate::sync::Once;
+use crate::sys;
 
 macro_rules! rtabort {
-    ($($t:tt)*) => (::sys_common::util::abort(format_args!($($t)*)))
+    ($($t:tt)*) => (crate::sys_common::util::abort(format_args!($($t)*)))
 }
 
 macro_rules! rtassert {
@@ -52,7 +52,7 @@ macro_rules! rtassert {
                  target_os = "redox",
                  all(target_arch = "wasm32", not(target_os = "emscripten")),
                  all(target_vendor = "fortanix", target_env = "sgx")))] {
-        pub use sys::net;
+        pub use crate::sys::net;
     } else {
         pub mod net;
     }
index b47d8698c605b5d70d4f947ac6914895dc601e7f..4b58cac7941b9bcc19dfd7c7e08963f74e052e56 100644 (file)
@@ -1,4 +1,4 @@
-use sys::mutex as imp;
+use crate::sys::mutex as imp;
 
 /// An OS-based mutual exclusion lock.
 ///
index 0d60593ce1f2ff3939517e782eff75e85a14525d..36721171b17334e111346faebd5254f9ff7e253d 100644 (file)
@@ -1,37 +1,38 @@
-use cmp;
-use ffi::CString;
-use fmt;
-use io::{self, Error, ErrorKind, IoVec, IoVecMut};
+use crate::cmp;
+use crate::ffi::CString;
+use crate::fmt;
+use crate::io::{self, Error, ErrorKind, IoVec, IoVecMut};
+use crate::mem;
+use crate::net::{SocketAddr, Shutdown, Ipv4Addr, Ipv6Addr};
+use crate::ptr;
+use crate::sys::net::{cvt, cvt_r, cvt_gai, Socket, init, wrlen_t};
+use crate::sys::net::netc as c;
+use crate::sys_common::{AsInner, FromInner, IntoInner};
+use crate::time::Duration;
+use crate::convert::{TryFrom, TryInto};
+
 use libc::{c_int, c_void};
-use mem;
-use net::{SocketAddr, Shutdown, Ipv4Addr, Ipv6Addr};
-use ptr;
-use sys::net::{cvt, cvt_r, cvt_gai, Socket, init, wrlen_t};
-use sys::net::netc as c;
-use sys_common::{AsInner, FromInner, IntoInner};
-use time::Duration;
-use convert::{TryFrom, TryInto};
 
 #[cfg(any(target_os = "dragonfly", target_os = "freebsd",
           target_os = "ios", target_os = "macos",
           target_os = "openbsd", target_os = "netbsd",
           target_os = "solaris", target_os = "haiku", target_os = "l4re"))]
-use sys::net::netc::IPV6_JOIN_GROUP as IPV6_ADD_MEMBERSHIP;
+use crate::sys::net::netc::IPV6_JOIN_GROUP as IPV6_ADD_MEMBERSHIP;
 #[cfg(not(any(target_os = "dragonfly", target_os = "freebsd",
               target_os = "ios", target_os = "macos",
               target_os = "openbsd", target_os = "netbsd",
               target_os = "solaris", target_os = "haiku", target_os = "l4re")))]
-use sys::net::netc::IPV6_ADD_MEMBERSHIP;
+use crate::sys::net::netc::IPV6_ADD_MEMBERSHIP;
 #[cfg(any(target_os = "dragonfly", target_os = "freebsd",
           target_os = "ios", target_os = "macos",
           target_os = "openbsd", target_os = "netbsd",
           target_os = "solaris", target_os = "haiku", target_os = "l4re"))]
-use sys::net::netc::IPV6_LEAVE_GROUP as IPV6_DROP_MEMBERSHIP;
+use crate::sys::net::netc::IPV6_LEAVE_GROUP as IPV6_DROP_MEMBERSHIP;
 #[cfg(not(any(target_os = "dragonfly", target_os = "freebsd",
               target_os = "ios", target_os = "macos",
               target_os = "openbsd", target_os = "netbsd",
               target_os = "solaris", target_os = "haiku", target_os = "l4re")))]
-use sys::net::netc::IPV6_DROP_MEMBERSHIP;
+use crate::sys::net::netc::IPV6_DROP_MEMBERSHIP;
 
 #[cfg(any(target_os = "linux", target_os = "android",
           target_os = "dragonfly", target_os = "freebsd",
@@ -109,8 +110,8 @@ fn to_ipv6mr_interface(value: u32) -> c_int {
 }
 
 #[cfg(not(target_os = "android"))]
-fn to_ipv6mr_interface(value: u32) -> ::libc::c_uint {
-    value as ::libc::c_uint
+fn to_ipv6mr_interface(value: u32) -> libc::c_uint {
+    value as libc::c_uint
 }
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -653,7 +654,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 #[cfg(test)]
 mod tests {
     use super::*;
-    use collections::HashMap;
+    use crate::collections::HashMap;
 
     #[test]
     fn no_lookup_host_duplicates() {
index 1358916ef99365096d5cb5b687fca3aef131ddbf..d2294235666493dd40815d57d1f2ede24f3cdc8b 100644 (file)
@@ -1,7 +1,7 @@
-use error::{Error};
-use fmt;
-use sync::atomic::{AtomicBool, Ordering};
-use thread;
+use crate::error::{Error};
+use crate::fmt;
+use crate::sync::atomic::{AtomicBool, Ordering};
+use crate::thread;
 
 pub struct Flag { failed: AtomicBool }
 
index 3384ffeb64e9fcdb466f8d3e352dc438ec7c7275..4d40dec97245a966df377a21751af8803a465195 100644 (file)
@@ -1,10 +1,10 @@
 #![allow(dead_code)]
 #![unstable(feature = "process_internals", issue = "0")]
 
-use ffi::{OsStr, OsString};
-use env;
-use collections::BTreeMap;
-use borrow::Borrow;
+use crate::ffi::{OsStr, OsString};
+use crate::env;
+use crate::collections::BTreeMap;
+use crate::borrow::Borrow;
 
 pub trait EnvKey:
     From<OsString> + Into<OsString> +
index 596e5d534c2933fd1fc24a8257cf57d1767f8174..2aec361d7a4936ece8b4e412efa5e6f025fc729c 100644 (file)
@@ -1,9 +1,9 @@
-use fmt;
-use marker;
-use ops::Deref;
-use sys_common::poison::{self, TryLockError, TryLockResult, LockResult};
-use sys::mutex as sys;
-use panic::{UnwindSafe, RefUnwindSafe};
+use crate::fmt;
+use crate::marker;
+use crate::ops::Deref;
+use crate::sys_common::poison::{self, TryLockError, TryLockResult, LockResult};
+use crate::sys::mutex as sys;
+use crate::panic::{UnwindSafe, RefUnwindSafe};
 
 /// A re-entrant mutual exclusion
 ///
@@ -159,10 +159,10 @@ fn drop(&mut self) {
 
 #[cfg(all(test, not(target_os = "emscripten")))]
 mod tests {
-    use sys_common::remutex::{ReentrantMutex, ReentrantMutexGuard};
-    use cell::RefCell;
-    use sync::Arc;
-    use thread;
+    use crate::sys_common::remutex::{ReentrantMutex, ReentrantMutexGuard};
+    use crate::cell::RefCell;
+    use crate::sync::Arc;
+    use crate::thread;
 
     #[test]
     fn smoke() {
index 0aa0284539a8f152fcfbad326af046285d9e49ed..0b1a092de5422d69589dafb35c6b9865cd32df8d 100644 (file)
@@ -1,4 +1,4 @@
-use sys::rwlock as imp;
+use crate::sys::rwlock as imp;
 
 /// An OS-based reader-writer lock.
 ///
index fe9ad7623b7d5d31b73dc9a12512aa62b4f8aba3..b2142e753085a4caaef57b5da70f825a29f43305 100644 (file)
@@ -1,8 +1,8 @@
-use boxed::FnBox;
-use env;
-use sync::atomic::{self, Ordering};
-use sys::stack_overflow;
-use sys::thread as imp;
+use crate::boxed::FnBox;
+use crate::env;
+use crate::sync::atomic::{self, Ordering};
+use crate::sys::stack_overflow;
+use crate::sys::thread as imp;
 
 #[allow(dead_code)]
 pub unsafe fn start_thread(main: *mut u8) {
index b4bca72b09d1b9b6f9dd67d3b59989371ce54b0b..b3c21ec508a9eda1cb79ce8d53b9daedd33ca8c9 100644 (file)
@@ -1,8 +1,8 @@
 #![allow(dead_code)] // stack_guard isn't used right now on all platforms
 
-use cell::RefCell;
-use sys::thread::guard::Guard;
-use thread::Thread;
+use crate::cell::RefCell;
+use crate::sys::thread::guard::Guard;
+use crate::thread::Thread;
 
 struct ThreadInfo {
     stack_guard: Option<Guard>,
index 874e58dcfeee01c034783ae833a1a9afc8ac5449..bdf79002e906dcc477d6395a75402a37a6b04582 100644 (file)
 #![unstable(feature = "thread_local_internals", issue = "0")]
 #![allow(dead_code)] // sys isn't exported yet
 
-use ptr;
-use sync::atomic::{self, AtomicUsize, Ordering};
-use sys::thread_local as imp;
-use sys_common::mutex::Mutex;
+use crate::ptr;
+use crate::sync::atomic::{self, AtomicUsize, Ordering};
+use crate::sys::thread_local as imp;
+use crate::sys_common::mutex::Mutex;
 
 /// A type for TLS keys that are statically allocated.
 ///
index 7dec22be97808a4101977f6ea78048742bccfd6b..206443a6736922a9d5c91ff5c3bc8650e5cbbbbe 100644 (file)
@@ -1,7 +1,7 @@
-use fmt;
-use io::prelude::*;
-use sys::stdio::panic_output;
-use thread;
+use crate::fmt;
+use crate::io::prelude::*;
+use crate::sys::stdio::panic_output;
+use crate::thread;
 
 pub fn dumb_print(args: fmt::Arguments) {
     if let Some(mut out) = panic_output() {
@@ -11,12 +11,12 @@ pub fn dumb_print(args: fmt::Arguments) {
 
 // Other platforms should use the appropriate platform-specific mechanism for
 // aborting the process.  If no platform-specific mechanism is available,
-// ::intrinsics::abort() may be used instead.  The above implementations cover
+// crate::intrinsics::abort() may be used instead.  The above implementations cover
 // all targets currently supported by libstd.
 
 pub fn abort(args: fmt::Arguments) -> ! {
     dumb_print(format_args!("fatal runtime error: {}\n", args));
-    unsafe { ::sys::abort_internal(); }
+    unsafe { crate::sys::abort_internal(); }
 }
 
 #[allow(dead_code)] // stack overflow detection not enabled on all platforms
index 6d4594fe295ca07b1af2c64a83b6640c6b8b6bf8..b15239e8d877e223507cbcf888c871bac6e8d366 100644 (file)
 
 use core::str::next_code_point;
 
-use borrow::Cow;
-use char;
-use fmt;
-use hash::{Hash, Hasher};
-use iter::FromIterator;
-use mem;
-use ops;
-use rc::Rc;
-use slice;
-use str;
-use sync::Arc;
-use sys_common::AsInner;
+use crate::borrow::Cow;
+use crate::char;
+use crate::fmt;
+use crate::hash::{Hash, Hasher};
+use crate::iter::FromIterator;
+use crate::mem;
+use crate::ops;
+use crate::rc::Rc;
+use crate::slice;
+use crate::str;
+use crate::sync::Arc;
+use crate::sys_common::AsInner;
 
 const UTF8_REPLACEMENT_CHARACTER: &str = "\u{FFFD}";
 
@@ -413,7 +413,7 @@ fn as_inner(&self) -> &[u8] { &self.bytes }
 impl fmt::Debug for Wtf8 {
     fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
         fn write_str_escaped(f: &mut fmt::Formatter, s: &str) -> fmt::Result {
-            use fmt::Write;
+            use crate::fmt::Write;
             for c in s.chars().flat_map(|c| c.escape_debug()) {
                 f.write_char(c)?
             }
@@ -871,7 +871,7 @@ pub fn make_ascii_uppercase(&mut self) { self.bytes.make_ascii_uppercase() }
 
 #[cfg(test)]
 mod tests {
-    use borrow::Cow;
+    use crate::borrow::Cow;
     use super::*;
 
     #[test]
index e985c3899af416bdc69e8c0f84dc1efd2e5f69da..06fb5533afdd80c11140979edfcfa46cb655eec5 100644 (file)
@@ -1,5 +1,3 @@
-extern crate rand;
-
 use std::env::*;
 use std::ffi::{OsString, OsStr};
 
index 8207709e1f9f00ca07de1b6ad7bb53a110b6d589..d1f53734d30e31ea63cbcb2942a0b51a66cd006e 100644 (file)
@@ -2,10 +2,10 @@
 
 #![unstable(feature = "thread_local_internals", issue = "0")]
 
-use cell::UnsafeCell;
-use fmt;
-use hint;
-use mem;
+use crate::cell::UnsafeCell;
+use crate::fmt;
+use crate::hint;
+use crate::mem;
 
 /// A thread local storage key which owns its contents.
 ///
@@ -310,14 +310,14 @@ pub fn try_with<F, R>(&'static self, f: F) -> Result<R, AccessError>
 #[doc(hidden)]
 #[cfg(all(target_arch = "wasm32", not(target_feature = "atomics")))]
 pub mod statik {
-    use cell::UnsafeCell;
-    use fmt;
+    use crate::cell::UnsafeCell;
+    use crate::fmt;
 
     pub struct Key<T> {
         inner: UnsafeCell<Option<T>>,
     }
 
-    unsafe impl<T> ::marker::Sync for Key<T> { }
+    unsafe impl<T> Sync for Key<T> { }
 
     impl<T> fmt::Debug for Key<T> {
         fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -341,11 +341,11 @@ pub unsafe fn get(&self) -> Option<&'static UnsafeCell<Option<T>>> {
 #[doc(hidden)]
 #[cfg(target_thread_local)]
 pub mod fast {
-    use cell::{Cell, UnsafeCell};
-    use fmt;
-    use mem;
-    use ptr;
-    use sys::fast_thread_local::{register_dtor, requires_move_before_drop};
+    use crate::cell::{Cell, UnsafeCell};
+    use crate::fmt;
+    use crate::mem;
+    use crate::ptr;
+    use crate::sys::fast_thread_local::{register_dtor, requires_move_before_drop};
 
     pub struct Key<T> {
         inner: UnsafeCell<Option<T>>,
@@ -412,11 +412,11 @@ unsafe fn register_dtor(&self) {
 
 #[doc(hidden)]
 pub mod os {
-    use cell::{Cell, UnsafeCell};
-    use fmt;
-    use marker;
-    use ptr;
-    use sys_common::thread_local::StaticKey as OsStaticKey;
+    use crate::cell::{Cell, UnsafeCell};
+    use crate::fmt;
+    use crate::marker;
+    use crate::ptr;
+    use crate::sys_common::thread_local::StaticKey as OsStaticKey;
 
     pub struct Key<T> {
         // OS-TLS key that we'll use to key off.
@@ -430,7 +430,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         }
     }
 
-    unsafe impl<T> ::marker::Sync for Key<T> { }
+    unsafe impl<T> Sync for Key<T> { }
 
     struct Value<T: 'static> {
         key: &'static Key<T>,
@@ -484,9 +484,9 @@ pub unsafe fn get(&'static self) -> Option<&'static UnsafeCell<Option<T>>> {
 
 #[cfg(all(test, not(target_os = "emscripten")))]
 mod tests {
-    use sync::mpsc::{channel, Sender};
-    use cell::{Cell, UnsafeCell};
-    use thread;
+    use crate::sync::mpsc::{channel, Sender};
+    use crate::cell::{Cell, UnsafeCell};
+    use crate::thread;
 
     struct Foo(Sender<()>);
 
@@ -632,8 +632,8 @@ fn drop(&mut self) {
 
 #[cfg(test)]
 mod dynamic_tests {
-    use cell::RefCell;
-    use collections::HashMap;
+    use crate::cell::RefCell;
+    use crate::collections::HashMap;
 
     #[test]
     fn smoke() {
index 438ea3aa3f6a396f84aefc2872c1aafc7b8b4dc7..08f0aa2f0d2065d403bc27bee0df2ca8fd0eeaa8 100644 (file)
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
-use any::Any;
-use boxed::FnBox;
-use cell::UnsafeCell;
-use ffi::{CStr, CString};
-use fmt;
-use io;
-use mem;
-use panic;
-use panicking;
-use str;
-use sync::{Mutex, Condvar, Arc};
-use sync::atomic::AtomicUsize;
-use sync::atomic::Ordering::SeqCst;
-use sys::thread as imp;
-use sys_common::mutex;
-use sys_common::thread_info;
-use sys_common::thread;
-use sys_common::{AsInner, IntoInner};
-use time::Duration;
+use crate::any::Any;
+use crate::boxed::FnBox;
+use crate::cell::UnsafeCell;
+use crate::ffi::{CStr, CString};
+use crate::fmt;
+use crate::io;
+use crate::mem;
+use crate::panic;
+use crate::panicking;
+use crate::str;
+use crate::sync::{Mutex, Condvar, Arc};
+use crate::sync::atomic::AtomicUsize;
+use crate::sync::atomic::Ordering::SeqCst;
+use crate::sys::thread as imp;
+use crate::sys_common::mutex;
+use crate::sys_common::thread_info;
+use crate::sys_common::thread;
+use crate::sys_common::{AsInner, IntoInner};
+use crate::time::Duration;
 
 ////////////////////////////////////////////////////////////////////////////////
 // Thread-local storage
@@ -466,7 +466,7 @@ pub unsafe fn spawn_unchecked<'a, F, T>(self, f: F) -> io::Result<JoinHandle<T>>
             thread_info::set(imp::guard::current(), their_thread);
             #[cfg(feature = "backtrace")]
             let try_result = panic::catch_unwind(panic::AssertUnwindSafe(|| {
-                ::sys_common::backtrace::__rust_begin_short_backtrace(f)
+                crate::sys_common::backtrace::__rust_begin_short_backtrace(f)
             }));
             #[cfg(not(feature = "backtrace"))]
             let try_result = panic::catch_unwind(panic::AssertUnwindSafe(f));
@@ -1051,7 +1051,7 @@ fn new() -> ThreadId {
 
             // If we somehow use up all our bits, panic so that we're not
             // covering up subtle bugs of IDs being reused.
-            if COUNTER == ::u64::MAX {
+            if COUNTER == crate::u64::MAX {
                 panic!("failed to generate unique thread ID: bitspace exhausted");
             }
 
@@ -1290,7 +1290,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 ///
 /// [`Result`]: ../../std/result/enum.Result.html
 #[stable(feature = "rust1", since = "1.0.0")]
-pub type Result<T> = ::result::Result<T, Box<dyn Any + Send + 'static>>;
+pub type Result<T> = crate::result::Result<T, Box<dyn Any + Send + 'static>>;
 
 // This packet is used to communicate the return value between the child thread
 // and the parent thread. Memory is shared through the `Arc` within and there's
@@ -1482,13 +1482,13 @@ fn _assert_both<T: Send + Sync>() {}
 
 #[cfg(all(test, not(target_os = "emscripten")))]
 mod tests {
-    use any::Any;
-    use sync::mpsc::{channel, Sender};
-    use result;
-    use super::{Builder};
-    use thread;
-    use time::Duration;
-    use u32;
+    use super::Builder;
+    use crate::any::Any;
+    use crate::sync::mpsc::{channel, Sender};
+    use crate::result;
+    use crate::thread;
+    use crate::time::Duration;
+    use crate::u32;
 
     // !!! These tests are dangerous. If something is buggy, they will hang, !!!
     // !!! instead of exiting cleanly. This might wedge the buildbots.       !!!
index e1f5e1fcb938dde5e46349af963edfdc149cc9eb..6d7093ac33ea7b3556955c8b840e5b3d19b05dd0 100644 (file)
 
 #![stable(feature = "time", since = "1.3.0")]
 
-use cmp;
-use error::Error;
-use fmt;
-use ops::{Add, Sub, AddAssign, SubAssign};
-use sys::time;
-use sys_common::FromInner;
-use sys_common::mutex::Mutex;
+use crate::cmp;
+use crate::error::Error;
+use crate::fmt;
+use crate::ops::{Add, Sub, AddAssign, SubAssign};
+use crate::sys::time;
+use crate::sys_common::FromInner;
+use crate::sys_common::mutex::Mutex;
 
 #[stable(feature = "time", since = "1.3.0")]
 pub use core::time::Duration;
@@ -713,7 +713,7 @@ fn system_time_math() {
         assert_almost_eq!(a.checked_sub(second).unwrap().checked_add(second).unwrap(), a);
 
         // A difference of 80 and 800 years cannot fit inside a 32-bit time_t
-        if !(cfg!(unix) && ::mem::size_of::<::libc::time_t>() <= 4) {
+        if !(cfg!(unix) && crate::mem::size_of::<libc::time_t>() <= 4) {
             let eighty_years = second * 60 * 60 * 24 * 365 * 80;
             assert_almost_eq!(a - eighty_years + eighty_years, a);
             assert_almost_eq!(a - (eighty_years * 10) + (eighty_years * 10), a);
index 4a0bb0302ffbc250907e3075641fa5d9beae5af6..71c2ab82f65c397bcab98650b3c595db92f4600e 100644 (file)
@@ -13,7 +13,7 @@ crate-type = ["dylib"]
 bitflags = "1.0"
 serialize = { path = "../libserialize" }
 log = "0.4"
-scoped-tls = "0.1"
+scoped-tls = "1.0"
 syntax_pos = { path = "../libsyntax_pos" }
 errors = { path = "../librustc_errors", package = "rustc_errors" }
 rustc_data_structures = { path = "../librustc_data_structures" }
index 9c4945d74dbfef9e82e07bffd3d04441f413d151..a01a5bb0a36383da7785012885af8b86b9c93bcb 100644 (file)
@@ -1643,6 +1643,8 @@ pub enum TyKind {
     Mac(Mac),
     /// Placeholder for a kind that has failed to be defined.
     Err,
+    /// Placeholder for a `va_list`.
+    CVarArgs,
 }
 
 impl TyKind {
@@ -1802,7 +1804,7 @@ pub fn from_self(eself: ExplicitSelf, eself_ident: Ident) -> Arg {
 pub struct FnDecl {
     pub inputs: Vec<Arg>,
     pub output: FunctionRetTy,
-    pub variadic: bool,
+    pub c_variadic: bool,
 }
 
 impl FnDecl {
@@ -2216,7 +2218,7 @@ pub fn span_with_attributes(&self) -> Span {
 #[derive(Clone, Copy, RustcEncodable, RustcDecodable, Debug)]
 pub struct FnHeader {
     pub unsafety: Unsafety,
-    pub asyncness: IsAsync,
+    pub asyncness: Spanned<IsAsync>,
     pub constness: Spanned<Constness>,
     pub abi: Abi,
 }
@@ -2225,7 +2227,7 @@ impl Default for FnHeader {
     fn default() -> FnHeader {
         FnHeader {
             unsafety: Unsafety::Normal,
-            asyncness: IsAsync::NotAsync,
+            asyncness: dummy_spanned(IsAsync::NotAsync),
             constness: dummy_spanned(Constness::NotConst),
             abi: Abi::Rust,
         }
index 27b0cfb163077e8d2ba28731a415d9690169f20d..e95f05894491b670f6c5e8d9df58bd22951226f1 100644 (file)
@@ -985,7 +985,7 @@ fn fn_decl(&self, inputs: Vec<ast::Arg>, output: ast::FunctionRetTy) -> P<ast::F
         P(ast::FnDecl {
             inputs,
             output,
-            variadic: false
+            c_variadic: false
         })
     }
 
@@ -1017,7 +1017,7 @@ fn item_fn_poly(&self,
                   ast::ItemKind::Fn(self.fn_decl(inputs, ast::FunctionRetTy::Ty(output)),
                               ast::FnHeader {
                                   unsafety: ast::Unsafety::Normal,
-                                  asyncness: ast::IsAsync::NotAsync,
+                                  asyncness: dummy_spanned(ast::IsAsync::NotAsync),
                                   constness: dummy_spanned(ast::Constness::NotConst),
                                   abi: Abi::Rust,
                               },
index 255795f28c7a34d2926326be5804d8fc2a8213b2..b24edb57e527e4b09892ebc62d3a5d889ade6eb1 100644 (file)
@@ -475,11 +475,13 @@ fn parse_sep_and_kleene_op_2015<I>(
                 // #1 is a separator and #2 should be a KleepeOp.
                 // (N.B. We need to advance the input iterator.)
                 match parse_kleene_op(input, span) {
-                    // #2 is `?`, which is not allowed as a Kleene op in 2015 edition.
+                    // #2 is `?`, which is not allowed as a Kleene op in 2015 edition,
+                    // but is allowed in the 2018 edition.
                     Ok(Ok((op, op2_span))) if op == KleeneOp::ZeroOrOne => {
                         sess.span_diagnostic
                             .struct_span_err(op2_span, "expected `*` or `+`")
-                            .note("`?` is not a macro repetition operator")
+                            .note("`?` is not a macro repetition operator in the 2015 edition, \
+                                 but is accepted in the 2018 edition")
                             .emit();
 
                         // Return a dummy
@@ -507,10 +509,12 @@ fn parse_sep_and_kleene_op_2015<I>(
                     Err(_) => op1_span,
                 }
             } else {
-                // `?` is not allowed as a Kleene op in 2015
+                // `?` is not allowed as a Kleene op in 2015,
+                // but is allowed in the 2018 edition
                 sess.span_diagnostic
                     .struct_span_err(op1_span, "expected `*` or `+`")
-                    .note("`?` is not a macro repetition operator")
+                    .note("`?` is not a macro repetition operator in the 2015 edition, \
+                         but is accepted in the 2018 edition")
                     .emit();
 
                 // Return a dummy
@@ -520,11 +524,13 @@ fn parse_sep_and_kleene_op_2015<I>(
 
         // #1 is a separator followed by #2, a KleeneOp
         Ok(Err((tok, span))) => match parse_kleene_op(input, span) {
-            // #2 is a `?`, which is not allowed as a Kleene op in 2015 edition.
+            // #2 is a `?`, which is not allowed as a Kleene op in 2015 edition,
+            // but is allowed in the 2018 edition
             Ok(Ok((op, op2_span))) if op == KleeneOp::ZeroOrOne => {
                 sess.span_diagnostic
                     .struct_span_err(op2_span, "expected `*` or `+`")
-                    .note("`?` is not a macro repetition operator")
+                    .note("`?` is not a macro repetition operator in the 2015 edition, \
+                        but is accepted in the 2018 edition")
                     .emit();
 
                 // Return a dummy
index cc1953e69d4ca107fc833f3a6acb1e73e9527a6e..1c0b931b289c23d8826d02030b67fb07e3b5bd10 100644 (file)
@@ -233,8 +233,8 @@ pub fn walk_feature_fields<F>(&self, mut f: F)
 
     // Allows `#[unwind(..)]`.
     //
-    // rustc internal for rust runtime
-    (active, unwind_attributes, "1.4.0", None, None),
+    // Permits specifying whether a function should permit unwinding or abort on unwind.
+    (active, unwind_attributes, "1.4.0", Some(58760), None),
 
     // Allows the use of `#[naked]` on functions.
     (active, naked_functions, "1.9.0", Some(32408), None),
@@ -471,6 +471,9 @@ pub fn walk_feature_fields<F>(&self, mut f: F)
 
     // #[repr(align(X))] on enums
     (active, repr_align_enum, "1.34.0", Some(57996), None),
+
+    // Allows the use of C-variadics
+    (active, c_variadic, "1.34.0", Some(44930), None),
 );
 
 declare_features! (
@@ -1898,9 +1901,14 @@ fn visit_fn(&mut self,
         match fn_kind {
             FnKind::ItemFn(_, header, _, _) => {
                 // Check for const fn and async fn declarations.
-                if header.asyncness.is_async() {
+                if header.asyncness.node.is_async() {
                     gate_feature_post!(&self, async_await, span, "async fn is unstable");
                 }
+
+                if fn_decl.c_variadic {
+                    gate_feature_post!(&self, c_variadic, span,
+                                       "C-varaidic functions are unstable");
+                }
                 // Stability of const fn methods are covered in
                 // `visit_trait_item` and `visit_impl_item` below; this is
                 // because default methods don't pass through this point.
@@ -1929,6 +1937,10 @@ fn visit_trait_item(&mut self, ti: &'a ast::TraitItem) {
                 if block.is_none() {
                     self.check_abi(sig.header.abi, ti.span);
                 }
+                if sig.decl.c_variadic {
+                    gate_feature_post!(&self, c_variadic, ti.span,
+                                       "C-varaidic functions are unstable");
+                }
                 if sig.header.constness.node == ast::Constness::Const {
                     gate_feature_post!(&self, const_fn, ti.span, "const fn is unstable");
                 }
index 86849f580d081eda2fe59f9ce53c8769bf92070d..802b78086959721be2aed40543a8712feb949a07 100644 (file)
@@ -21,6 +21,7 @@
 
 use rustc_data_structures::sync::Lrc;
 use std::ops::DerefMut;
+use std::{panic, process, ptr};
 
 pub trait ExpectOne<A: Array> {
     fn expect_one(self, err: &'static str) -> A::Item;
@@ -305,11 +306,18 @@ fn visit_span(&mut self, _sp: &mut Span) {
 
 /// Use a map-style function (`FnOnce(T) -> T`) to overwrite a `&mut T`. Useful
 /// when using a `flat_map_*` or `filter_map_*` method within a `visit_`
-/// method.
+/// method. Abort the program if the closure panics.
 //
 // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
 pub fn visit_clobber<T, F>(t: &mut T, f: F) where F: FnOnce(T) -> T {
-    unsafe { std::ptr::write(t, f(std::ptr::read(t))); }
+    unsafe {
+        // Safe because `t` is used in a read-only fashion by `read()` before
+        // being overwritten by `write()`.
+        let old_t = ptr::read(t);
+        let new_t = panic::catch_unwind(panic::AssertUnwindSafe(|| f(old_t)))
+            .unwrap_or_else(|_| process::abort());
+        ptr::write(t, new_t);
+    }
 }
 
 // No `noop_` prefix because there isn't a corresponding method in `MutVisitor`.
@@ -401,7 +409,8 @@ pub fn noop_visit_ty<T: MutVisitor>(ty: &mut P<Ty>, vis: &mut T) {
     let Ty { id, node, span } = ty.deref_mut();
     vis.visit_id(id);
     match node {
-        TyKind::Infer | TyKind::ImplicitSelf | TyKind::Err | TyKind::Never => {}
+        TyKind::Infer | TyKind::ImplicitSelf | TyKind::Err |
+            TyKind::Never | TyKind::CVarArgs => {}
         TyKind::Slice(ty) => vis.visit_ty(ty),
         TyKind::Ptr(mt) => vis.visit_mt(mt),
         TyKind::Rptr(lt, mt) => {
@@ -672,7 +681,7 @@ pub fn noop_visit_asyncness<T: MutVisitor>(asyncness: &mut IsAsync, vis: &mut T)
 }
 
 pub fn noop_visit_fn_decl<T: MutVisitor>(decl: &mut P<FnDecl>, vis: &mut T) {
-    let FnDecl { inputs, output, variadic: _ } = decl.deref_mut();
+    let FnDecl { inputs, output, c_variadic: _ } = decl.deref_mut();
     visit_vec(inputs, |input| vis.visit_arg(input));
     match output {
         FunctionRetTy::Default(span) => vis.visit_span(span),
@@ -926,7 +935,7 @@ pub fn noop_flat_map_impl_item<T: MutVisitor>(mut item: ImplItem, visitor: &mut
 
 pub fn noop_visit_fn_header<T: MutVisitor>(header: &mut FnHeader, vis: &mut T) {
     let FnHeader { unsafety: _, asyncness, constness: _, abi: _ } = header;
-    vis.visit_asyncness(asyncness);
+    vis.visit_asyncness(&mut asyncness.node);
 }
 
 pub fn noop_visit_mod<T: MutVisitor>(Mod { inner, items, inline: _ }: &mut Mod, vis: &mut T) {
index 7e900dfeb1eeb1040eae25390c66c3c4fc3155da..fd5038a8614f25823cf6c0aee5bd3664701d119d 100644 (file)
@@ -1457,12 +1457,12 @@ fn parse_ty_bare_fn(&mut self, generic_params: Vec<GenericParam>) -> PResult<'a,
         };
 
         self.expect_keyword(keywords::Fn)?;
-        let (inputs, variadic) = self.parse_fn_args(false, true)?;
+        let (inputs, c_variadic) = self.parse_fn_args(false, true)?;
         let ret_ty = self.parse_ret_ty(false)?;
         let decl = P(FnDecl {
             inputs,
             output: ret_ty,
-            variadic,
+            c_variadic,
         });
         Ok(TyKind::BareFn(P(BareFnTy {
             abi,
@@ -1543,7 +1543,7 @@ fn parse_trait_item_(&mut self,
                 // definition...
 
                 // We don't allow argument names to be left off in edition 2018.
-                p.parse_arg_general(p.span.rust_2018(), true)
+                p.parse_arg_general(p.span.rust_2018(), true, false)
             })?;
             generics.where_clause = self.parse_where_clause()?;
 
@@ -1613,7 +1613,7 @@ fn parse_trait_item_(&mut self,
     /// Parses an optional return type `[ -> TY ]` in a function declaration.
     fn parse_ret_ty(&mut self, allow_plus: bool) -> PResult<'a, FunctionRetTy> {
         if self.eat(&token::RArrow) {
-            Ok(FunctionRetTy::Ty(self.parse_ty_common(allow_plus, true)?))
+            Ok(FunctionRetTy::Ty(self.parse_ty_common(allow_plus, true, false)?))
         } else {
             Ok(FunctionRetTy::Default(self.span.shrink_to_lo()))
         }
@@ -1621,7 +1621,7 @@ fn parse_ret_ty(&mut self, allow_plus: bool) -> PResult<'a, FunctionRetTy> {
 
     /// Parses a type.
     pub fn parse_ty(&mut self) -> PResult<'a, P<Ty>> {
-        self.parse_ty_common(true, true)
+        self.parse_ty_common(true, true, false)
     }
 
     /// Parses a type in restricted contexts where `+` is not permitted.
@@ -1631,11 +1631,11 @@ pub fn parse_ty(&mut self) -> PResult<'a, P<Ty>> {
     /// Example 2: `value1 as TYPE + value2`
     ///     `+` is prohibited to avoid interactions with expression grammar.
     fn parse_ty_no_plus(&mut self) -> PResult<'a, P<Ty>> {
-        self.parse_ty_common(false, true)
+        self.parse_ty_common(false, true, false)
     }
 
-    fn parse_ty_common(&mut self, allow_plus: bool, allow_qpath_recovery: bool)
-                       -> PResult<'a, P<Ty>> {
+    fn parse_ty_common(&mut self, allow_plus: bool, allow_qpath_recovery: bool,
+                       allow_c_variadic: bool) -> PResult<'a, P<Ty>> {
         maybe_whole!(self, NtTy, |x| x);
 
         let lo = self.span;
@@ -1772,6 +1772,15 @@ fn parse_ty_common(&mut self, allow_plus: bool, allow_qpath_recovery: bool)
                     TyKind::Path(None, path)
                 }
             }
+        } else if self.check(&token::DotDotDot) {
+            if allow_c_variadic {
+                self.eat(&token::DotDotDot);
+                TyKind::CVarArgs
+            } else {
+                return Err(self.fatal(
+                    "only foreign functions are allowed to be C-variadic"
+                ));
+            }
         } else {
             let msg = format!("expected type, found {}", self.this_token_descr());
             return Err(self.fatal(&msg));
@@ -1959,7 +1968,8 @@ fn eat_incorrect_doc_comment(&mut self, applied_to: &str) {
     }
 
     /// This version of parse arg doesn't necessarily require identifier names.
-    fn parse_arg_general(&mut self, require_name: bool, is_trait_item: bool) -> PResult<'a, Arg> {
+    fn parse_arg_general(&mut self, require_name: bool, is_trait_item: bool,
+                         allow_c_variadic: bool) -> PResult<'a, Arg> {
         maybe_whole!(self, NtArg, |x| x);
 
         if let Ok(Some(_)) = self.parse_self_arg() {
@@ -2008,12 +2018,12 @@ fn parse_arg_general(&mut self, require_name: bool, is_trait_item: bool) -> PRes
             }
 
             self.eat_incorrect_doc_comment("a method argument's type");
-            (pat, self.parse_ty()?)
+            (pat, self.parse_ty_common(true, true, allow_c_variadic)?)
         } else {
             debug!("parse_arg_general ident_to_pat");
             let parser_snapshot_before_ty = self.clone();
             self.eat_incorrect_doc_comment("a method argument's type");
-            let mut ty = self.parse_ty();
+            let mut ty = self.parse_ty_common(true, true, allow_c_variadic);
             if ty.is_ok() && self.token != token::Comma &&
                self.token != token::CloseDelim(token::Paren) {
                 // This wasn't actually a type, but a pattern looking like a type,
@@ -2032,6 +2042,11 @@ fn parse_arg_general(&mut self, require_name: bool, is_trait_item: bool) -> PRes
                     (pat, ty)
                 }
                 Err(mut err) => {
+                    // If this is a C-variadic argument and we hit an error, return the
+                    // error.
+                    if self.token == token::DotDotDot {
+                        return Err(err);
+                    }
                     // Recover from attempting to parse the argument as a type without pattern.
                     err.cancel();
                     mem::replace(self, parser_snapshot_before_ty);
@@ -2068,7 +2083,7 @@ fn parse_arg_general(&mut self, require_name: bool, is_trait_item: bool) -> PRes
 
     /// Parses a single function argument.
     crate fn parse_arg(&mut self) -> PResult<'a, Arg> {
-        self.parse_arg_general(true, false)
+        self.parse_arg_general(true, false, false)
     }
 
     /// Parses an argument in a lambda header (e.g., `|arg, arg|`).
@@ -2406,7 +2421,7 @@ fn parse_path_segment(&mut self, style: PathStyle, enable_warning: bool)
                 }
                 let span = lo.to(self.prev_span);
                 let output = if self.eat(&token::RArrow) {
-                    Some(self.parse_ty_common(false, false)?)
+                    Some(self.parse_ty_common(false, false, false)?)
                 } else {
                     None
                 };
@@ -5001,6 +5016,11 @@ fn is_async_block(&mut self) -> bool {
         )
     }
 
+    fn is_async_fn(&mut self) -> bool {
+        self.token.is_keyword(keywords::Async) &&
+            self.look_ahead(1, |t| t.is_keyword(keywords::Fn))
+    }
+
     fn is_do_catch_block(&mut self) -> bool {
         self.token.is_keyword(keywords::Do) &&
         self.look_ahead(1, |t| t.is_keyword(keywords::Catch)) &&
@@ -5133,7 +5153,8 @@ fn parse_stmt_without_recovery(&mut self,
                   !self.is_union_item() &&
                   !self.is_crate_vis() &&
                   !self.is_existential_type_decl() &&
-                  !self.is_auto_trait_item() {
+                  !self.is_auto_trait_item() &&
+                  !self.is_async_fn() {
             let pth = self.parse_path(PathStyle::Expr)?;
 
             if !self.eat(&token::Not) {
@@ -6107,55 +6128,49 @@ fn parse_where_clause(&mut self) -> PResult<'a, WhereClause> {
         Ok(where_clause)
     }
 
-    fn parse_fn_args(&mut self, named_args: bool, allow_variadic: bool)
+    fn parse_fn_args(&mut self, named_args: bool, allow_c_variadic: bool)
                      -> PResult<'a, (Vec<Arg> , bool)> {
         self.expect(&token::OpenDelim(token::Paren))?;
 
         let sp = self.span;
-        let mut variadic = false;
+        let mut c_variadic = false;
         let (args, recovered): (Vec<Option<Arg>>, bool) =
             self.parse_seq_to_before_end(
                 &token::CloseDelim(token::Paren),
                 SeqSep::trailing_allowed(token::Comma),
                 |p| {
-                    if p.token == token::DotDotDot {
-                        p.bump();
-                        variadic = true;
-                        if allow_variadic {
-                            if p.token != token::CloseDelim(token::Paren) {
-                                let span = p.span;
-                                p.span_err(span,
-                                    "`...` must be last in argument list for variadic function");
-                            }
-                            Ok(None)
-                        } else {
-                            let span = p.prev_span;
-                            if p.token == token::CloseDelim(token::Paren) {
-                                // continue parsing to present any further errors
-                                p.struct_span_err(
-                                    span,
-                                    "only foreign functions are allowed to be variadic"
-                                ).emit();
-                                Ok(Some(dummy_arg(span)))
-                           } else {
-                               // this function definition looks beyond recovery, stop parsing
-                                p.span_err(span,
-                                           "only foreign functions are allowed to be variadic");
-                                Ok(None)
-                            }
-                        }
+                    // If the argument is a C-variadic argument we should not
+                    // enforce named arguments.
+                    let enforce_named_args = if p.token == token::DotDotDot {
+                        false
                     } else {
-                        match p.parse_arg_general(named_args, false) {
-                            Ok(arg) => Ok(Some(arg)),
-                            Err(mut e) => {
-                                e.emit();
-                                let lo = p.prev_span;
-                                // Skip every token until next possible arg or end.
-                                p.eat_to_tokens(&[&token::Comma, &token::CloseDelim(token::Paren)]);
-                                // Create a placeholder argument for proper arg count (#34264).
-                                let span = lo.to(p.prev_span);
-                                Ok(Some(dummy_arg(span)))
+                        named_args
+                    };
+                    match p.parse_arg_general(enforce_named_args, false,
+                                              allow_c_variadic) {
+                        Ok(arg) => {
+                            if let TyKind::CVarArgs = arg.ty.node {
+                                c_variadic = true;
+                                if p.token != token::CloseDelim(token::Paren) {
+                                    let span = p.span;
+                                    p.span_err(span,
+                                        "`...` must be the last argument of a C-variadic function");
+                                    Ok(None)
+                                } else {
+                                    Ok(Some(arg))
+                                }
+                            } else {
+                                Ok(Some(arg))
                             }
+                        },
+                        Err(mut e) => {
+                            e.emit();
+                            let lo = p.prev_span;
+                            // Skip every token until next possible arg or end.
+                            p.eat_to_tokens(&[&token::Comma, &token::CloseDelim(token::Paren)]);
+                            // Create a placeholder argument for proper arg count (issue #34264).
+                            let span = lo.to(p.prev_span);
+                            Ok(Some(dummy_arg(span)))
                         }
                     }
                 }
@@ -6167,24 +6182,24 @@ fn parse_fn_args(&mut self, named_args: bool, allow_variadic: bool)
 
         let args: Vec<_> = args.into_iter().filter_map(|x| x).collect();
 
-        if variadic && args.is_empty() {
+        if c_variadic && args.is_empty() {
             self.span_err(sp,
-                          "variadic function must be declared with at least one named argument");
+                          "C-variadic function must be declared with at least one named argument");
         }
 
-        Ok((args, variadic))
+        Ok((args, c_variadic))
     }
 
     /// Parses the argument list and result type of a function declaration.
-    fn parse_fn_decl(&mut self, allow_variadic: bool) -> PResult<'a, P<FnDecl>> {
+    fn parse_fn_decl(&mut self, allow_c_variadic: bool) -> PResult<'a, P<FnDecl>> {
 
-        let (args, variadic) = self.parse_fn_args(true, allow_variadic)?;
+        let (args, c_variadic) = self.parse_fn_args(true, allow_c_variadic)?;
         let ret_ty = self.parse_ret_ty(true)?;
 
         Ok(P(FnDecl {
             inputs: args,
             output: ret_ty,
-            variadic,
+            c_variadic,
         }))
     }
 
@@ -6331,7 +6346,7 @@ fn parse_fn_decl_with_self<F>(&mut self, parse_arg_fn: F) -> PResult<'a, P<FnDec
         Ok(P(FnDecl {
             inputs: fn_inputs,
             output: self.parse_ret_ty(true)?,
-            variadic: false
+            c_variadic: false
         }))
     }
 
@@ -6357,7 +6372,7 @@ fn parse_fn_block_decl(&mut self) -> PResult<'a, P<FnDecl>> {
         Ok(P(FnDecl {
             inputs: inputs_captures,
             output,
-            variadic: false
+            c_variadic: false
         }))
     }
 
@@ -6384,12 +6399,13 @@ fn mk_item(&mut self, span: Span, ident: Ident, node: ItemKind, vis: Visibility,
     /// Parses an item-position function declaration.
     fn parse_item_fn(&mut self,
                      unsafety: Unsafety,
-                     asyncness: IsAsync,
+                     asyncness: Spanned<IsAsync>,
                      constness: Spanned<Constness>,
                      abi: Abi)
                      -> PResult<'a, ItemInfo> {
         let (ident, mut generics) = self.parse_fn_header()?;
-        let decl = self.parse_fn_decl(false)?;
+        let allow_c_variadic = abi == Abi::C && unsafety == Unsafety::Unsafe;
+        let decl = self.parse_fn_decl(allow_c_variadic)?;
         generics.where_clause = self.parse_where_clause()?;
         let (inner_attrs, body) = self.parse_inner_attrs_and_block()?;
         let header = FnHeader { unsafety, asyncness, constness, abi };
@@ -6416,7 +6432,7 @@ fn parse_fn_front_matter(&mut self)
         -> PResult<'a, (
             Spanned<Constness>,
             Unsafety,
-            IsAsync,
+            Spanned<IsAsync>,
             Abi
         )>
     {
@@ -6424,6 +6440,7 @@ fn parse_fn_front_matter(&mut self)
         let const_span = self.prev_span;
         let unsafety = self.parse_unsafety();
         let asyncness = self.parse_asyncness();
+        let asyncness = respan(self.prev_span, asyncness);
         let (constness, unsafety, abi) = if is_const_fn {
             (respan(const_span, Constness::Const), unsafety, Abi::Rust)
         } else {
@@ -7834,7 +7851,7 @@ fn parse_item_implementation(
                 let abi = opt_abi.unwrap_or(Abi::C);
                 let (ident, item_, extra_attrs) =
                     self.parse_item_fn(Unsafety::Normal,
-                                       IsAsync::NotAsync,
+                                       respan(fn_span, IsAsync::NotAsync),
                                        respan(fn_span, Constness::NotConst),
                                        abi)?;
                 let prev_span = self.prev_span;
@@ -7878,7 +7895,7 @@ fn parse_item_implementation(
                 self.bump();
                 let (ident, item_, extra_attrs) =
                     self.parse_item_fn(unsafety,
-                                       IsAsync::NotAsync,
+                                       respan(const_span, IsAsync::NotAsync),
                                        respan(const_span, Constness::Const),
                                        Abi::Rust)?;
                 let prev_span = self.prev_span;
@@ -7926,14 +7943,15 @@ fn parse_item_implementation(
             // ASYNC FUNCTION ITEM
             let unsafety = self.parse_unsafety();
             self.expect_keyword(keywords::Async)?;
+            let async_span = self.prev_span;
             self.expect_keyword(keywords::Fn)?;
             let fn_span = self.prev_span;
             let (ident, item_, extra_attrs) =
                 self.parse_item_fn(unsafety,
-                                   IsAsync::Async {
+                                   respan(async_span, IsAsync::Async {
                                        closure_id: ast::DUMMY_NODE_ID,
                                        return_impl_trait_id: ast::DUMMY_NODE_ID,
-                                   },
+                                   }),
                                    respan(fn_span, Constness::NotConst),
                                    Abi::Rust)?;
             let prev_span = self.prev_span;
@@ -7942,6 +7960,13 @@ fn parse_item_implementation(
                                     item_,
                                     visibility,
                                     maybe_append(attrs, extra_attrs));
+            if self.span.rust_2015() {
+                self.diagnostic().struct_span_err_with_code(
+                    async_span,
+                    "`async fn` is not permitted in the 2015 edition",
+                    DiagnosticId::Error("E0670".into())
+                ).emit();
+            }
             return Ok(Some(item));
         }
         if self.check_keyword(keywords::Unsafe) &&
@@ -7989,7 +8014,7 @@ fn parse_item_implementation(
             let fn_span = self.prev_span;
             let (ident, item_, extra_attrs) =
                 self.parse_item_fn(Unsafety::Normal,
-                                   IsAsync::NotAsync,
+                                   respan(fn_span, IsAsync::NotAsync),
                                    respan(fn_span, Constness::NotConst),
                                    Abi::Rust)?;
             let prev_span = self.prev_span;
@@ -8015,7 +8040,7 @@ fn parse_item_implementation(
             let fn_span = self.prev_span;
             let (ident, item_, extra_attrs) =
                 self.parse_item_fn(Unsafety::Unsafe,
-                                   IsAsync::NotAsync,
+                                   respan(fn_span, IsAsync::NotAsync),
                                    respan(fn_span, Constness::NotConst),
                                    abi)?;
             let prev_span = self.prev_span;
@@ -8282,7 +8307,8 @@ fn parse_macro_use_or_failure(
         lo: Span,
         visibility: Visibility
     ) -> PResult<'a, Option<P<Item>>> {
-        if macros_allowed && self.token.is_path_start() {
+        if macros_allowed && self.token.is_path_start() &&
+                !(self.is_async_fn() && self.span.rust_2015()) {
             // MACRO INVOCATION ITEM
 
             let prev_span = self.prev_span;
@@ -8337,7 +8363,8 @@ fn parse_macro_use_or_failure(
     fn parse_assoc_macro_invoc(&mut self, item_kind: &str, vis: Option<&Visibility>,
                                at_end: &mut bool) -> PResult<'a, Option<Mac>>
     {
-        if self.token.is_path_start() {
+        if self.token.is_path_start() &&
+                !(self.is_async_fn() && self.span.rust_2015()) {
             let prev_span = self.prev_span;
             let lo = self.span;
             let pth = self.parse_path(PathStyle::Mod)?;
index dcf9815f6d1ba47a4df2facd444514455fb87293..942bd96939173bf20f4e100f6cb6833617d75b20 100644 (file)
@@ -1118,6 +1118,9 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> io::Result<()> {
             ast::TyKind::Mac(ref m) => {
                 self.print_mac(m)?;
             }
+            ast::TyKind::CVarArgs => {
+                self.s.word("...")?;
+            }
         }
         self.end()
     }
@@ -2811,7 +2814,7 @@ pub fn print_fn_args_and_ret(&mut self, decl: &ast::FnDecl)
         -> io::Result<()> {
         self.popen()?;
         self.commasep(Inconsistent, &decl.inputs, |s, arg| s.print_arg(arg, false))?;
-        if decl.variadic {
+        if decl.c_variadic {
             self.s.word(", ...")?;
         }
         self.pclose()?;
@@ -3195,7 +3198,7 @@ pub fn print_fn_header_info(&mut self,
             ast::Constness::Const => self.word_nbsp("const")?
         }
 
-        self.print_asyncness(header.asyncness)?;
+        self.print_asyncness(header.asyncness.node)?;
         self.print_unsafety(header.unsafety)?;
 
         if header.abi != Abi::Rust {
@@ -3238,7 +3241,7 @@ fn test_fun_to_string() {
             let decl = ast::FnDecl {
                 inputs: Vec::new(),
                 output: ast::FunctionRetTy::Default(syntax_pos::DUMMY_SP),
-                variadic: false
+                c_variadic: false
             };
             let generics = ast::Generics::default();
             assert_eq!(
@@ -3247,7 +3250,7 @@ fn test_fun_to_string() {
                     ast::FnHeader {
                         unsafety: ast::Unsafety::Normal,
                         constness: source_map::dummy_spanned(ast::Constness::NotConst),
-                        asyncness: ast::IsAsync::NotAsync,
+                        asyncness: source_map::dummy_spanned(ast::IsAsync::NotAsync),
                         abi: Abi::Rust,
                     },
                     abba_ident,
index a002394c710fe064611c6ccc6ac9f4165377c971..6b3a30ccb54b76738354be8bc8b4ddda3fe3ae55 100644 (file)
@@ -22,7 +22,7 @@
 #[derive(Copy, Clone)]
 pub enum FnKind<'a> {
     /// fn foo() or extern "Abi" fn foo()
-    ItemFn(Ident, FnHeader, &'a Visibility, &'a Block),
+    ItemFn(Ident, &'a FnHeader, &'a Visibility, &'a Block),
 
     /// fn foo(&self)
     Method(Ident, &'a MethodSig, Option<&'a Visibility>, &'a Block),
@@ -149,6 +149,9 @@ fn visit_vis(&mut self, vis: &'ast Visibility) {
     fn visit_fn_ret_ty(&mut self, ret_ty: &'ast FunctionRetTy) {
         walk_fn_ret_ty(self, ret_ty)
     }
+    fn visit_fn_header(&mut self, _header: &'ast FnHeader) {
+        // Nothing to do
+    }
 }
 
 #[macro_export]
@@ -225,8 +228,9 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) {
             visitor.visit_ty(typ);
             visitor.visit_expr(expr);
         }
-        ItemKind::Fn(ref declaration, header, ref generics, ref body) => {
+        ItemKind::Fn(ref declaration, ref header, ref generics, ref body) => {
             visitor.visit_generics(generics);
+            visitor.visit_fn_header(header);
             visitor.visit_fn(FnKind::ItemFn(item.ident, header,
                                             &item.vis, body),
                              declaration,
@@ -315,7 +319,7 @@ pub fn walk_ty<'a, V: Visitor<'a>>(visitor: &mut V, typ: &'a Ty) {
             walk_list!(visitor, visit_lifetime, opt_lifetime);
             visitor.visit_ty(&mutable_type.ty)
         }
-        TyKind::Never => {},
+        TyKind::Never | TyKind::CVarArgs => {}
         TyKind::Tup(ref tuple_element_types) => {
             walk_list!(visitor, visit_ty, tuple_element_types);
         }
@@ -539,11 +543,13 @@ pub fn walk_fn<'a, V>(visitor: &mut V, kind: FnKind<'a>, declaration: &'a FnDecl
     where V: Visitor<'a>,
 {
     match kind {
-        FnKind::ItemFn(_, _, _, body) => {
+        FnKind::ItemFn(_, header, _, body) => {
+            visitor.visit_fn_header(header);
             walk_fn_decl(visitor, declaration);
             visitor.visit_block(body);
         }
-        FnKind::Method(_, _, _, body) => {
+        FnKind::Method(_, sig, _, body) => {
+            visitor.visit_fn_header(&sig.header);
             walk_fn_decl(visitor, declaration);
             visitor.visit_block(body);
         }
@@ -564,6 +570,7 @@ pub fn walk_trait_item<'a, V: Visitor<'a>>(visitor: &mut V, trait_item: &'a Trai
             walk_list!(visitor, visit_expr, default);
         }
         TraitItemKind::Method(ref sig, None) => {
+            visitor.visit_fn_header(&sig.header);
             walk_fn_decl(visitor, &sig.decl);
         }
         TraitItemKind::Method(ref sig, Some(ref body)) => {
index 371862465487b3f2cb5d7e13c53fe06f122d1341..f4b625f8ea2c862c69bec862608d001c7f377fe8 100644 (file)
@@ -257,7 +257,7 @@ fn has_test_signature(cx: &ExtCtxt<'_>, i: &ast::Item) -> bool {
             );
             return false
         }
-        if header.asyncness.is_async() {
+        if header.asyncness.node.is_async() {
             sd.span_err(
                 i.span,
                 "async functions cannot be used for tests"
index 5658451c54f719466e4e9aed4c15560e7d0f9205..691abffbbc1aff54778359097244e1e012ddeb02 100644 (file)
@@ -13,6 +13,6 @@ crate-type = ["dylib"]
 serialize = { path = "../libserialize" }
 rustc_data_structures = { path = "../librustc_data_structures" }
 arena = { path = "../libarena" }
-scoped-tls = { version = "0.1.1", features = ["nightly"] }
+scoped-tls = "1.0"
 unicode-width = "0.1.4"
 cfg-if = "0.1.2"
index 5c7fb1b80446187007749a6e3ce55976def98eae..ea821a1d9392c9211d9cd569ca8ceb9e1a716412 100644 (file)
@@ -366,6 +366,7 @@ pub struct TestOpts {
     pub list: bool,
     pub filter: Option<String>,
     pub filter_exact: bool,
+    pub exclude_should_panic: bool,
     pub run_ignored: RunIgnored,
     pub run_tests: bool,
     pub bench_benchmarks: bool,
@@ -385,6 +386,7 @@ fn new() -> TestOpts {
             list: false,
             filter: None,
             filter_exact: false,
+            exclude_should_panic: false,
             run_ignored: RunIgnored::No,
             run_tests: false,
             bench_benchmarks: false,
@@ -406,6 +408,7 @@ fn optgroups() -> getopts::Options {
     let mut opts = getopts::Options::new();
     opts.optflag("", "include-ignored", "Run ignored and not ignored tests")
         .optflag("", "ignored", "Run only ignored tests")
+        .optflag("", "exclude-should-panic", "Excludes tests marked as should_panic")
         .optflag("", "test", "Run tests and not benchmarks")
         .optflag("", "bench", "Run benchmarks instead of tests")
         .optflag("", "list", "List all tests and benchmarks")
@@ -558,6 +561,13 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
         None
     };
 
+    let exclude_should_panic = matches.opt_present("exclude-should-panic");
+    if !allow_unstable && exclude_should_panic {
+        return Some(Err(
+            "The \"exclude-should-panic\" flag is only accepted on the nightly compiler".into(),
+        ));
+    }
+
     let include_ignored = matches.opt_present("include-ignored");
     if !allow_unstable && include_ignored {
         return Some(Err(
@@ -648,6 +658,7 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
         list,
         filter,
         filter_exact: exact,
+        exclude_should_panic,
         run_ignored,
         run_tests,
         bench_benchmarks,
@@ -1365,6 +1376,11 @@ pub fn filter_tests(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> Vec<TestDescA
     // Skip tests that match any of the skip filters
     filtered.retain(|test| !opts.skip.iter().any(|sf| matches_filter(test, sf)));
 
+    // Excludes #[should_panic] tests
+    if opts.exclude_should_panic {
+        filtered.retain(|test| test.desc.should_panic == ShouldPanic::No);
+    }
+
     // maybe unignore tests
     match opts.run_ignored {
         RunIgnored::Yes => {
@@ -1983,6 +1999,29 @@ pub fn run_include_ignored_option() {
         assert!(!filtered[1].desc.ignore);
     }
 
+    #[test]
+    pub fn exclude_should_panic_option() {
+        let mut opts = TestOpts::new();
+        opts.run_tests = true;
+        opts.exclude_should_panic = true;
+
+        let mut tests = one_ignored_one_unignored_test();
+        tests.push(TestDescAndFn {
+            desc: TestDesc {
+                name: StaticTestName("3"),
+                ignore: false,
+                should_panic: ShouldPanic::Yes,
+                allow_fail: false,
+            },
+            testfn: DynTestFn(Box::new(move || {})),
+        });
+
+        let filtered = filter_tests(&opts, tests);
+
+        assert_eq!(filtered.len(), 2);
+        assert!(filtered.iter().all(|test| test.desc.should_panic == ShouldPanic::No));
+    }
+
     #[test]
     pub fn exact_filter_match() {
         fn tests() -> Vec<TestDescAndFn> {
index 73a75d35b9776d56160fa3200aca4a970ae49b60..38ad31bde8ff681d862dc0f96930a5dd9b7a472e 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 73a75d35b9776d56160fa3200aca4a970ae49b60
+Subproject commit 38ad31bde8ff681d862dc0f96930a5dd9b7a472e
diff --git a/src/test/codegen/c-variadic.rs b/src/test/codegen/c-variadic.rs
new file mode 100644 (file)
index 0000000..09c18ed
--- /dev/null
@@ -0,0 +1,69 @@
+// compile-flags: -C no-prepopulate-passes
+
+#![crate_type = "lib"]
+#![feature(c_variadic)]
+#![no_std]
+use core::ffi::VaList;
+
+extern "C" {
+    fn foreign_c_variadic_0(_: i32, ...);
+    fn foreign_c_variadic_1(_: VaList, ...);
+}
+
+pub unsafe extern "C" fn use_foreign_c_variadic_0() {
+    // Ensure that we correctly call foreign C-variadic functions.
+    // CHECK: invoke void (i32, ...) @foreign_c_variadic_0(i32 0)
+    foreign_c_variadic_0(0);
+    // CHECK: invoke void (i32, ...) @foreign_c_variadic_0(i32 0, i32 42)
+    foreign_c_variadic_0(0, 42i32);
+    // CHECK: invoke void (i32, ...) @foreign_c_variadic_0(i32 0, i32 42, i32 1024)
+    foreign_c_variadic_0(0, 42i32, 1024i32);
+    // CHECK: invoke void (i32, ...) @foreign_c_variadic_0(i32 0, i32 42, i32 1024, i32 0)
+    foreign_c_variadic_0(0, 42i32, 1024i32, 0i32);
+}
+
+// Ensure that we do not remove the `va_list` passed to the foreign function when
+// removing the "spoofed" `VaList` that is used by Rust defined C-variadics.
+pub unsafe extern "C" fn use_foreign_c_variadic_1_0(ap: VaList) {
+    // CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_1({{.*}} %ap)
+    foreign_c_variadic_1(ap);
+}
+
+pub unsafe extern "C" fn use_foreign_c_variadic_1_1(ap: VaList) {
+    // CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_1({{.*}} %ap, i32 42)
+    foreign_c_variadic_1(ap, 42i32);
+}
+pub unsafe extern "C" fn use_foreign_c_variadic_1_2(ap: VaList) {
+    // CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_1({{.*}} %ap, i32 2, i32 42)
+    foreign_c_variadic_1(ap, 2i32, 42i32);
+}
+
+pub unsafe extern "C" fn use_foreign_c_variadic_1_3(ap: VaList) {
+    // CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_1({{.*}} %ap, i32 2, i32 42, i32 0)
+    foreign_c_variadic_1(ap, 2i32, 42i32, 0i32);
+}
+
+// Ensure that `va_start` and `va_end` are properly injected.
+#[no_mangle]
+pub unsafe extern "C" fn c_variadic(n: i32, mut ap: ...) -> i32 {
+    // CHECK: call void @llvm.va_start
+    let mut sum = 0;
+    for _ in 0..n {
+        sum += ap.arg::<i32>();
+    }
+    sum
+    // CHECK: call void @llvm.va_end
+}
+
+// Ensure that we generate the correct `call` signature when calling a Rust
+// defined C-variadic.
+pub unsafe fn test_c_variadic_call() {
+    // CHECK: call i32 (i32, ...) @c_variadic(i32 0)
+    c_variadic(0);
+    // CHECK: call i32 (i32, ...) @c_variadic(i32 0, i32 42)
+    c_variadic(0, 42i32);
+    // CHECK: call i32 (i32, ...) @c_variadic(i32 0, i32 42, i32 1024)
+    c_variadic(0, 42i32, 1024i32);
+    // CHECK: call i32 (i32, ...) @c_variadic(i32 0, i32 42, i32 1024, i32 0)
+    c_variadic(0, 42i32, 1024i32, 0i32);
+}
index d55aac1e40f4f6b320344290f03fbb33402ee315..96a238afaec05039a5c515bd7b79cfa3317f0523 100644 (file)
@@ -18,8 +18,10 @@ macro_rules! continue_if {
 
 unsafe fn compare_c_str(ptr: *const c_char, val: &str) -> bool {
     let cstr0 = CStr::from_ptr(ptr);
-    let cstr1 = CString::new(val).unwrap();
-    &*cstr1 == cstr0
+    match CString::new(val) {
+        Ok(cstr1) => &*cstr1 == cstr0,
+        Err(_) => false,
+    }
 }
 
 #[no_mangle]
@@ -68,3 +70,24 @@ unsafe fn compare_c_str(ptr: *const c_char, val: &str) -> bool {
         }
     })
 }
+
+#[no_mangle]
+pub unsafe extern "C" fn check_varargs_0(_: c_int, mut ap: ...) -> usize {
+    continue_if!(ap.arg::<c_int>() == 42);
+    continue_if!(compare_c_str(ap.arg::<*const c_char>(), "Hello, World!"));
+    0
+}
+
+#[no_mangle]
+pub unsafe extern "C" fn check_varargs_1(_: c_int, mut ap: ...) -> usize {
+    continue_if!(ap.arg::<c_double>().floor() == 3.14f64.floor());
+    continue_if!(ap.arg::<c_long>() == 12);
+    continue_if!(ap.arg::<c_char>() == 'A' as c_char);
+    continue_if!(ap.arg::<c_longlong>() == 1);
+    0
+}
+
+#[no_mangle]
+pub unsafe extern "C" fn check_varargs_2(_: c_int, mut ap: ...) -> usize {
+    0
+}
index 95cf0ef46ca1e443a8a9e412ac647ac5574d0cb3..91b060dce26f436f6f9f5d21b7d038784dba115d 100644 (file)
@@ -8,6 +8,9 @@ extern size_t check_list_0(va_list ap);
 extern size_t check_list_1(va_list ap);
 extern size_t check_list_2(va_list ap);
 extern size_t check_list_copy_0(va_list ap);
+extern size_t check_varargs_0(int fixed, ...);
+extern size_t check_varargs_1(int fixed, ...);
+extern size_t check_varargs_2(int fixed, ...);
 
 int test_rust(size_t (*fn)(va_list), ...) {
     size_t ret = 0;
@@ -26,5 +29,12 @@ int main(int argc, char* argv[]) {
     assert(test_rust(check_list_2, 3.14, 12l, 'a', 6.28, "Hello", 42, "World") == 0);
 
     assert(test_rust(check_list_copy_0, 6.28, 16, 'A', "Skip Me!", "Correct") == 0);
+
+    assert(check_varargs_0(0, 42, "Hello, World!") == 0);
+
+    assert(check_varargs_1(0, 3.14, 12l, 'A', 0x1LL) == 0);
+
+    assert(check_varargs_2(0, "All", "of", "these", "are", "ignored", ".") == 0);
+
     return 0;
 }
index b8461c568c86d244334230529d00890330d38c4d..e9d825df2a46ec9834971dc6b44c7e953261140a 100644 (file)
@@ -6,6 +6,7 @@
 extern crate rustc_metadata;
 extern crate rustc_errors;
 extern crate rustc_codegen_utils;
+extern crate rustc_interface;
 extern crate syntax;
 
 use rustc::session::{build_session, Session};
@@ -14,6 +15,7 @@
 use rustc_driver::driver::{self, compile_input, CompileController};
 use rustc_metadata::cstore::CStore;
 use rustc_errors::registry::Registry;
+use rustc_interface::util;
 use syntax::source_map::FileName;
 use rustc_codegen_utils::codegen_backend::CodegenBackend;
 
@@ -45,7 +47,7 @@ fn main() {}
 fn basic_sess(opts: Options) -> (Session, Rc<CStore>, Box<CodegenBackend>) {
     let descriptions = Registry::new(&rustc::DIAGNOSTICS);
     let sess = build_session(opts, None, descriptions);
-    let codegen_backend = rustc_driver::get_codegen_backend(&sess);
+    let codegen_backend = util::get_codegen_backend(&sess);
     let cstore = Rc::new(CStore::new(codegen_backend.metadata_loader()));
     rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess));
     (sess, cstore, codegen_backend)
index 956bc5ad862caf9f8cfcbbecd5efa21863a99700..80e0b0102af75f8ff8fd4af4eae9132ff3f75dcb 100644 (file)
@@ -112,7 +112,7 @@ fn iter_exprs(depth: usize, f: &mut FnMut(P<Expr>)) {
                 let decl = P(FnDecl {
                     inputs: vec![],
                     output: FunctionRetTy::Default(DUMMY_SP),
-                    variadic: false,
+                    c_variadic: false,
                 });
                 iter_exprs(depth - 1, &mut |e| g(
                         ExprKind::Closure(CaptureBy::Value,
diff --git a/src/test/run-pass/issues/issue-58212.rs b/src/test/run-pass/issues/issue-58212.rs
new file mode 100644 (file)
index 0000000..7643763
--- /dev/null
@@ -0,0 +1,13 @@
+trait FromUnchecked {
+    unsafe fn from_unchecked();
+}
+
+impl FromUnchecked for [u8; 1] {
+    unsafe fn from_unchecked() {
+        let mut array: Self = std::mem::uninitialized();
+        let _ptr = &mut array as *mut [u8] as *mut u8;
+    }
+}
+
+fn main() {
+}
index b7617ec556d2083651f881f0bb8f0adb0165c88d..895c40e4cab2621741cf32f225230fb8b430820a 100644 (file)
@@ -12,7 +12,7 @@ error[E0425]: cannot find value `no` in this scope
 3 | no
   | ^^ not found in this scope
 
-thread '$DIR/failed-doctest-output.rs - OtherStruct (line 17)' panicked at 'couldn't compile the test', src/librustdoc/test.rs:351:13
+thread '$DIR/failed-doctest-output.rs - OtherStruct (line 17)' panicked at 'couldn't compile the test', src/librustdoc/test.rs:352:13
 note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
 
 ---- $DIR/failed-doctest-output.rs - SomeStruct (line 11) stdout ----
@@ -21,7 +21,7 @@ thread '$DIR/failed-doctest-output.rs - SomeStruct (line 11)' panicked at 'test
 thread 'main' panicked at 'oh no', $DIR/failed-doctest-output.rs:3:1
 note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
 
-', src/librustdoc/test.rs:372:17
+', src/librustdoc/test.rs:373:17
 
 
 failures:
index e5409c042056cdf3c92dae7780d2296e2aaa5839..60fc131dbda175029f36eb46e5f501cf6238ccef 100644 (file)
@@ -105,8 +105,8 @@ LL | | /// [error]
    |
    = note: the link appears in this line:
            
-            [error]
-             ^^^^^
+           [error]
+            ^^^^^
    = help: to escape `[` and `]` characters, just add '/' before them like `/[` or `/]`
 
 warning: `[error1]` cannot be resolved, ignoring it...
diff --git a/src/test/rustdoc-ui/issue-58473-2.rs b/src/test/rustdoc-ui/issue-58473-2.rs
new file mode 100644 (file)
index 0000000..5e5ddeb
--- /dev/null
@@ -0,0 +1,12 @@
+// compile-pass
+
+#![deny(private_doc_tests)]
+
+mod foo {
+    /**
+    Does nothing, returns `()`
+
+    yadda-yadda-yadda
+    */
+    fn foo() {}
+}
diff --git a/src/test/rustdoc-ui/issue-58473.rs b/src/test/rustdoc-ui/issue-58473.rs
new file mode 100644 (file)
index 0000000..0e5be32
--- /dev/null
@@ -0,0 +1,10 @@
+// compile-pass
+
+pub trait Foo {
+    /**
+    Does nothing, returns `()`
+
+    yadda-yadda-yadda
+    */
+    fn foo() {}
+}
index bd8f1775b3d048dcb8ee387f44f2be317c4781d6..5af2aea21fcacd94040f88f726176fedf46a66b4 100644 (file)
@@ -1,4 +1,4 @@
 extern "C" {
-    // @has variadic/fn.foo.html //pre 'pub unsafe extern "C" fn foo(x: i32, ...)'
+    // @has variadic/fn.foo.html //pre 'pub unsafe extern "C" fn foo(x: i32, _: ...)'
     pub fn foo(x: i32, ...);
 }
index 1a9bd9e66dbacdc68665c15c28683996c889486c..d25a5ea374627dbf5ec62eff4467088c2eb42ecb 100644 (file)
 use rustc_plugin::Registry;
 use syntax::ast;
 declare_tool_lint!(pub clippy::TEST_LINT, Warn, "Warn about stuff");
-declare_tool_lint!(pub clippy::TEST_GROUP, Warn, "Warn about other stuff");
+declare_tool_lint!(
+    /// Some docs
+    pub clippy::TEST_GROUP,
+    Warn, "Warn about other stuff"
+);
 
 struct Pass;
 
diff --git a/src/test/ui/c-variadic/variadic-ffi-1.rs b/src/test/ui/c-variadic/variadic-ffi-1.rs
new file mode 100644 (file)
index 0000000..61b2ad4
--- /dev/null
@@ -0,0 +1,31 @@
+// ignore-arm stdcall isn't supported
+// ignore-aarch64 stdcall isn't supported
+
+extern "stdcall" {
+    fn printf(_: *const u8, ...); //~ ERROR: variadic function must have C or cdecl calling
+}
+
+extern {
+    fn foo(f: isize, x: u8, ...);
+}
+
+extern "C" fn bar(f: isize, x: u8) {}
+
+fn main() {
+    // errors below are no longer checked because error above aborts
+    // compilation; see variadic-ffi-3.rs for corresponding test.
+    unsafe {
+        foo();
+        foo(1);
+
+        let x: unsafe extern "C" fn(f: isize, x: u8) = foo;
+        let y: extern "C" fn(f: isize, x: u8, ...) = bar;
+
+        foo(1, 2, 3f32);
+        foo(1, 2, true);
+        foo(1, 2, 1i8);
+        foo(1, 2, 1u8);
+        foo(1, 2, 1i16);
+        foo(1, 2, 1u16);
+    }
+}
diff --git a/src/test/ui/c-variadic/variadic-ffi-1.stderr b/src/test/ui/c-variadic/variadic-ffi-1.stderr
new file mode 100644 (file)
index 0000000..61d55ce
--- /dev/null
@@ -0,0 +1,9 @@
+error[E0045]: C-variadic function must have C or cdecl calling convention
+  --> $DIR/variadic-ffi-1.rs:5:5
+   |
+LL |     fn printf(_: *const u8, ...); //~ ERROR: variadic function must have C or cdecl calling
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadics require C or cdecl calling convention
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0045`.
diff --git a/src/test/ui/c-variadic/variadic-ffi-2.rs b/src/test/ui/c-variadic/variadic-ffi-2.rs
new file mode 100644 (file)
index 0000000..224ac16
--- /dev/null
@@ -0,0 +1,8 @@
+// ignore-arm stdcall isn't supported
+
+fn baz(f: extern "stdcall" fn(usize, ...)) {
+    //~^ ERROR: variadic function must have C or cdecl calling convention
+    f(22, 44);
+}
+
+fn main() {}
diff --git a/src/test/ui/c-variadic/variadic-ffi-2.stderr b/src/test/ui/c-variadic/variadic-ffi-2.stderr
new file mode 100644 (file)
index 0000000..4c8b8d2
--- /dev/null
@@ -0,0 +1,9 @@
+error[E0045]: C-variadic function must have C or cdecl calling convention
+  --> $DIR/variadic-ffi-2.rs:3:11
+   |
+LL | fn baz(f: extern "stdcall" fn(usize, ...)) {
+   |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadics require C or cdecl calling convention
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0045`.
diff --git a/src/test/ui/c-variadic/variadic-ffi-3.rs b/src/test/ui/c-variadic/variadic-ffi-3.rs
new file mode 100644 (file)
index 0000000..c02d1f5
--- /dev/null
@@ -0,0 +1,29 @@
+extern {
+    fn foo(f: isize, x: u8, ...);
+    //~^ defined here
+    //~| defined here
+}
+
+extern "C" fn bar(f: isize, x: u8) {}
+
+fn main() {
+    unsafe {
+        foo(); //~ ERROR: this function takes at least 2 parameters but 0 parameters were supplied
+        foo(1); //~ ERROR: this function takes at least 2 parameters but 1 parameter was supplied
+
+        let x: unsafe extern "C" fn(f: isize, x: u8) = foo;
+        //~^ ERROR: mismatched types
+        //~| expected type `unsafe extern "C" fn(isize, u8)`
+
+        let y: extern "C" fn(f: isize, x: u8, ...) = bar;
+        //~^ ERROR: mismatched types
+        //~| expected type `for<'r> extern "C" fn(isize, u8, std::ffi::VaList<'r>, ...)`
+
+        foo(1, 2, 3f32); //~ ERROR can't pass `f32` to variadic function
+        foo(1, 2, true); //~ ERROR can't pass `bool` to variadic function
+        foo(1, 2, 1i8); //~ ERROR can't pass `i8` to variadic function
+        foo(1, 2, 1u8); //~ ERROR can't pass `u8` to variadic function
+        foo(1, 2, 1i16); //~ ERROR can't pass `i16` to variadic function
+        foo(1, 2, 1u16); //~ ERROR can't pass `u16` to variadic function
+    }
+}
diff --git a/src/test/ui/c-variadic/variadic-ffi-3.stderr b/src/test/ui/c-variadic/variadic-ffi-3.stderr
new file mode 100644 (file)
index 0000000..82e3c6c
--- /dev/null
@@ -0,0 +1,76 @@
+error[E0060]: this function takes at least 2 parameters but 0 parameters were supplied
+  --> $DIR/variadic-ffi-3.rs:11:9
+   |
+LL |     fn foo(f: isize, x: u8, ...);
+   |     ----------------------------- defined here
+...
+LL |         foo(); //~ ERROR: this function takes at least 2 parameters but 0 parameters were supplied
+   |         ^^^^^ expected at least 2 parameters
+
+error[E0060]: this function takes at least 2 parameters but 1 parameter was supplied
+  --> $DIR/variadic-ffi-3.rs:12:9
+   |
+LL |     fn foo(f: isize, x: u8, ...);
+   |     ----------------------------- defined here
+...
+LL |         foo(1); //~ ERROR: this function takes at least 2 parameters but 1 parameter was supplied
+   |         ^^^^^^ expected at least 2 parameters
+
+error[E0308]: mismatched types
+  --> $DIR/variadic-ffi-3.rs:14:56
+   |
+LL |         let x: unsafe extern "C" fn(f: isize, x: u8) = foo;
+   |                                                        ^^^ expected non-variadic fn, found variadic function
+   |
+   = note: expected type `unsafe extern "C" fn(isize, u8)`
+              found type `for<'r> unsafe extern "C" fn(isize, u8, std::ffi::VaList<'r>, ...) {foo}`
+
+error[E0308]: mismatched types
+  --> $DIR/variadic-ffi-3.rs:18:54
+   |
+LL |         let y: extern "C" fn(f: isize, x: u8, ...) = bar;
+   |                                                      ^^^ expected variadic fn, found non-variadic function
+   |
+   = note: expected type `for<'r> extern "C" fn(isize, u8, std::ffi::VaList<'r>, ...)`
+              found type `extern "C" fn(isize, u8) {bar}`
+
+error[E0617]: can't pass `f32` to variadic function
+  --> $DIR/variadic-ffi-3.rs:22:19
+   |
+LL |         foo(1, 2, 3f32); //~ ERROR can't pass `f32` to variadic function
+   |                   ^^^^ help: cast the value to `c_double`: `3f32 as c_double`
+
+error[E0617]: can't pass `bool` to variadic function
+  --> $DIR/variadic-ffi-3.rs:23:19
+   |
+LL |         foo(1, 2, true); //~ ERROR can't pass `bool` to variadic function
+   |                   ^^^^ help: cast the value to `c_int`: `true as c_int`
+
+error[E0617]: can't pass `i8` to variadic function
+  --> $DIR/variadic-ffi-3.rs:24:19
+   |
+LL |         foo(1, 2, 1i8); //~ ERROR can't pass `i8` to variadic function
+   |                   ^^^ help: cast the value to `c_int`: `1i8 as c_int`
+
+error[E0617]: can't pass `u8` to variadic function
+  --> $DIR/variadic-ffi-3.rs:25:19
+   |
+LL |         foo(1, 2, 1u8); //~ ERROR can't pass `u8` to variadic function
+   |                   ^^^ help: cast the value to `c_uint`: `1u8 as c_uint`
+
+error[E0617]: can't pass `i16` to variadic function
+  --> $DIR/variadic-ffi-3.rs:26:19
+   |
+LL |         foo(1, 2, 1i16); //~ ERROR can't pass `i16` to variadic function
+   |                   ^^^^ help: cast the value to `c_int`: `1i16 as c_int`
+
+error[E0617]: can't pass `u16` to variadic function
+  --> $DIR/variadic-ffi-3.rs:27:19
+   |
+LL |         foo(1, 2, 1u16); //~ ERROR can't pass `u16` to variadic function
+   |                   ^^^^ help: cast the value to `c_uint`: `1u16 as c_uint`
+
+error: aborting due to 10 previous errors
+
+Some errors occurred: E0060, E0308, E0617.
+For more information about an error, try `rustc --explain E0060`.
diff --git a/src/test/ui/c-variadic/variadic-ffi-4.rs b/src/test/ui/c-variadic/variadic-ffi-4.rs
new file mode 100644 (file)
index 0000000..9101be5
--- /dev/null
@@ -0,0 +1,29 @@
+#![crate_type="lib"]
+#![no_std]
+#![feature(c_variadic)]
+
+use core::ffi::VaList;
+
+pub unsafe extern "C" fn no_escape0<'a>(_: usize, ap: ...) -> VaList<'a> {
+    ap //~ ERROR: explicit lifetime required
+}
+
+pub unsafe extern "C" fn no_escape1(_: usize, ap: ...) -> VaList<'static> {
+    ap //~ ERROR: explicit lifetime required
+}
+
+pub unsafe extern "C" fn no_escape2(_: usize, ap: ...) {
+    let _ = ap.copy(|ap| { ap }); //~ ERROR: cannot infer an appropriate lifetime
+}
+
+pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaList, mut ap1: ...) {
+    *ap0 = ap1; //~ ERROR: mismatched types
+}
+
+pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaList, mut ap1: ...) {
+    ap0 = &mut ap1;
+    //~^ ERROR: a value of type `core::ffi::VaList<'_>` is borrowed for too long
+    //~^^ ERROR: mismatched types
+    //~^^^ ERROR: mismatched types
+    //~^^^^ ERROR: cannot infer an appropriate lifetime
+}
diff --git a/src/test/ui/c-variadic/variadic-ffi-4.stderr b/src/test/ui/c-variadic/variadic-ffi-4.stderr
new file mode 100644 (file)
index 0000000..1d752be
--- /dev/null
@@ -0,0 +1,198 @@
+error[E0621]: explicit lifetime required in the type of `ap`
+  --> $DIR/variadic-ffi-4.rs:8:5
+   |
+LL | pub unsafe extern "C" fn no_escape0<'a>(_: usize, ap: ...) -> VaList<'a> {
+   |                                                       --- help: add explicit lifetime `'a` to the type of `ap`: `core::ffi::VaList<'a>`
+LL |     ap //~ ERROR: explicit lifetime required
+   |     ^^ lifetime `'a` required
+
+error[E0621]: explicit lifetime required in the type of `ap`
+  --> $DIR/variadic-ffi-4.rs:12:5
+   |
+LL | pub unsafe extern "C" fn no_escape1(_: usize, ap: ...) -> VaList<'static> {
+   |                                                   --- help: add explicit lifetime `'static` to the type of `ap`: `core::ffi::VaList<'static>`
+LL |     ap //~ ERROR: explicit lifetime required
+   |     ^^ lifetime `'static` required
+
+error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
+  --> $DIR/variadic-ffi-4.rs:16:28
+   |
+LL |     let _ = ap.copy(|ap| { ap }); //~ ERROR: cannot infer an appropriate lifetime
+   |                            ^^
+   |
+note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 16:21...
+  --> $DIR/variadic-ffi-4.rs:16:21
+   |
+LL |     let _ = ap.copy(|ap| { ap }); //~ ERROR: cannot infer an appropriate lifetime
+   |                     ^^^^^^^^^^^
+   = note: ...so that the expression is assignable:
+           expected core::ffi::VaList<'_>
+              found core::ffi::VaList<'_>
+note: but, the lifetime must be valid for the method call at 16:13...
+  --> $DIR/variadic-ffi-4.rs:16:13
+   |
+LL |     let _ = ap.copy(|ap| { ap }); //~ ERROR: cannot infer an appropriate lifetime
+   |             ^^^^^^^^^^^^^^^^^^^^
+note: ...so type `core::ffi::VaList<'_>` of expression is valid during the expression
+  --> $DIR/variadic-ffi-4.rs:16:13
+   |
+LL |     let _ = ap.copy(|ap| { ap }); //~ ERROR: cannot infer an appropriate lifetime
+   |             ^^^^^^^^^^^^^^^^^^^^
+
+error[E0308]: mismatched types
+  --> $DIR/variadic-ffi-4.rs:20:12
+   |
+LL |     *ap0 = ap1; //~ ERROR: mismatched types
+   |            ^^^ lifetime mismatch
+   |
+   = note: expected type `core::ffi::VaList<'_>`
+              found type `core::ffi::VaList<'_>`
+note: the anonymous lifetime #3 defined on the function body at 19:1...
+  --> $DIR/variadic-ffi-4.rs:19:1
+   |
+LL | / pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaList, mut ap1: ...) {
+LL | |     *ap0 = ap1; //~ ERROR: mismatched types
+LL | | }
+   | |_^
+note: ...does not necessarily outlive the anonymous lifetime #2 defined on the function body at 19:1
+  --> $DIR/variadic-ffi-4.rs:19:1
+   |
+LL | / pub unsafe extern "C" fn no_escape3(_: usize, mut ap0: &mut VaList, mut ap1: ...) {
+LL | |     *ap0 = ap1; //~ ERROR: mismatched types
+LL | | }
+   | |_^
+
+error[E0490]: a value of type `core::ffi::VaList<'_>` is borrowed for too long
+  --> $DIR/variadic-ffi-4.rs:24:11
+   |
+LL |     ap0 = &mut ap1;
+   |           ^^^^^^^^
+   |
+note: the type is valid for the anonymous lifetime #1 defined on the function body at 23:1
+  --> $DIR/variadic-ffi-4.rs:23:1
+   |
+LL | / pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaList, mut ap1: ...) {
+LL | |     ap0 = &mut ap1;
+LL | |     //~^ ERROR: a value of type `core::ffi::VaList<'_>` is borrowed for too long
+LL | |     //~^^ ERROR: mismatched types
+LL | |     //~^^^ ERROR: mismatched types
+LL | |     //~^^^^ ERROR: cannot infer an appropriate lifetime
+LL | | }
+   | |_^
+note: but the borrow lasts for the anonymous lifetime #3 defined on the function body at 23:1
+  --> $DIR/variadic-ffi-4.rs:23:1
+   |
+LL | / pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaList, mut ap1: ...) {
+LL | |     ap0 = &mut ap1;
+LL | |     //~^ ERROR: a value of type `core::ffi::VaList<'_>` is borrowed for too long
+LL | |     //~^^ ERROR: mismatched types
+LL | |     //~^^^ ERROR: mismatched types
+LL | |     //~^^^^ ERROR: cannot infer an appropriate lifetime
+LL | | }
+   | |_^
+
+error[E0308]: mismatched types
+  --> $DIR/variadic-ffi-4.rs:24:11
+   |
+LL |     ap0 = &mut ap1;
+   |           ^^^^^^^^ lifetime mismatch
+   |
+   = note: expected type `&mut core::ffi::VaList<'_>`
+              found type `&mut core::ffi::VaList<'_>`
+note: the anonymous lifetime #3 defined on the function body at 23:1...
+  --> $DIR/variadic-ffi-4.rs:23:1
+   |
+LL | / pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaList, mut ap1: ...) {
+LL | |     ap0 = &mut ap1;
+LL | |     //~^ ERROR: a value of type `core::ffi::VaList<'_>` is borrowed for too long
+LL | |     //~^^ ERROR: mismatched types
+LL | |     //~^^^ ERROR: mismatched types
+LL | |     //~^^^^ ERROR: cannot infer an appropriate lifetime
+LL | | }
+   | |_^
+note: ...does not necessarily outlive the anonymous lifetime #2 defined on the function body at 23:1
+  --> $DIR/variadic-ffi-4.rs:23:1
+   |
+LL | / pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaList, mut ap1: ...) {
+LL | |     ap0 = &mut ap1;
+LL | |     //~^ ERROR: a value of type `core::ffi::VaList<'_>` is borrowed for too long
+LL | |     //~^^ ERROR: mismatched types
+LL | |     //~^^^ ERROR: mismatched types
+LL | |     //~^^^^ ERROR: cannot infer an appropriate lifetime
+LL | | }
+   | |_^
+
+error[E0308]: mismatched types
+  --> $DIR/variadic-ffi-4.rs:24:11
+   |
+LL |     ap0 = &mut ap1;
+   |           ^^^^^^^^ lifetime mismatch
+   |
+   = note: expected type `&mut core::ffi::VaList<'_>`
+              found type `&mut core::ffi::VaList<'_>`
+note: the anonymous lifetime #2 defined on the function body at 23:1...
+  --> $DIR/variadic-ffi-4.rs:23:1
+   |
+LL | / pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaList, mut ap1: ...) {
+LL | |     ap0 = &mut ap1;
+LL | |     //~^ ERROR: a value of type `core::ffi::VaList<'_>` is borrowed for too long
+LL | |     //~^^ ERROR: mismatched types
+LL | |     //~^^^ ERROR: mismatched types
+LL | |     //~^^^^ ERROR: cannot infer an appropriate lifetime
+LL | | }
+   | |_^
+note: ...does not necessarily outlive the anonymous lifetime #3 defined on the function body at 23:1
+  --> $DIR/variadic-ffi-4.rs:23:1
+   |
+LL | / pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaList, mut ap1: ...) {
+LL | |     ap0 = &mut ap1;
+LL | |     //~^ ERROR: a value of type `core::ffi::VaList<'_>` is borrowed for too long
+LL | |     //~^^ ERROR: mismatched types
+LL | |     //~^^^ ERROR: mismatched types
+LL | |     //~^^^^ ERROR: cannot infer an appropriate lifetime
+LL | | }
+   | |_^
+
+error[E0495]: cannot infer an appropriate lifetime for borrow expression due to conflicting requirements
+  --> $DIR/variadic-ffi-4.rs:24:11
+   |
+LL |     ap0 = &mut ap1;
+   |           ^^^^^^^^
+   |
+note: first, the lifetime cannot outlive the anonymous lifetime #3 defined on the function body at 23:1...
+  --> $DIR/variadic-ffi-4.rs:23:1
+   |
+LL | / pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaList, mut ap1: ...) {
+LL | |     ap0 = &mut ap1;
+LL | |     //~^ ERROR: a value of type `core::ffi::VaList<'_>` is borrowed for too long
+LL | |     //~^^ ERROR: mismatched types
+LL | |     //~^^^ ERROR: mismatched types
+LL | |     //~^^^^ ERROR: cannot infer an appropriate lifetime
+LL | | }
+   | |_^
+note: ...so that the type `core::ffi::VaList<'_>` is not borrowed for too long
+  --> $DIR/variadic-ffi-4.rs:24:11
+   |
+LL |     ap0 = &mut ap1;
+   |           ^^^^^^^^
+note: but, the lifetime must be valid for the anonymous lifetime #1 defined on the function body at 23:1...
+  --> $DIR/variadic-ffi-4.rs:23:1
+   |
+LL | / pub unsafe extern "C" fn no_escape4(_: usize, ap0: &mut VaList, mut ap1: ...) {
+LL | |     ap0 = &mut ap1;
+LL | |     //~^ ERROR: a value of type `core::ffi::VaList<'_>` is borrowed for too long
+LL | |     //~^^ ERROR: mismatched types
+LL | |     //~^^^ ERROR: mismatched types
+LL | |     //~^^^^ ERROR: cannot infer an appropriate lifetime
+LL | | }
+   | |_^
+note: ...so that reference does not outlive borrowed content
+  --> $DIR/variadic-ffi-4.rs:24:11
+   |
+LL |     ap0 = &mut ap1;
+   |           ^^^^^^^^
+
+error: aborting due to 8 previous errors
+
+Some errors occurred: E0308, E0490, E0495, E0621.
+For more information about an error, try `rustc --explain E0308`.
diff --git a/src/test/ui/c-variadic/variadic-ffi-5.rs b/src/test/ui/c-variadic/variadic-ffi-5.rs
new file mode 100644 (file)
index 0000000..d96482f
--- /dev/null
@@ -0,0 +1,31 @@
+#![crate_type="lib"]
+#![no_std]
+#![feature(c_variadic)]
+// The tests in this file are similar to that of variadic-ffi-4, but this
+// one enables nll.
+#![feature(nll)]
+
+use core::ffi::VaList;
+
+pub unsafe extern "C" fn no_escape0<'a>(_: usize, ap: ...) -> VaList<'a> {
+    ap //~ ERROR: explicit lifetime required
+}
+
+pub unsafe extern "C" fn no_escape1(_: usize, ap: ...) -> VaList<'static> {
+    ap //~ ERROR: explicit lifetime required
+}
+
+pub unsafe extern "C" fn no_escape2(_: usize, ap: ...) {
+    let _ = ap.copy(|ap| { ap }); //~ ERROR: lifetime may not live long enough
+}
+
+pub unsafe extern "C" fn no_escape3(_: usize, ap0: &mut VaList, mut ap1: ...) {
+    *ap0 = ap1; //~ ERROR: lifetime may not live long enough
+}
+
+pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaList, mut ap1: ...) {
+    ap0 = &mut ap1;
+    //~^ ERROR: lifetime may not live long enough
+    //~^^ ERROR: lifetime may not live long enough
+    //~^^^ ERROR: `ap1` does not live long enough
+}
diff --git a/src/test/ui/c-variadic/variadic-ffi-5.stderr b/src/test/ui/c-variadic/variadic-ffi-5.stderr
new file mode 100644 (file)
index 0000000..2d45287
--- /dev/null
@@ -0,0 +1,73 @@
+error[E0621]: explicit lifetime required in the type of `ap`
+  --> $DIR/variadic-ffi-5.rs:11:5
+   |
+LL | pub unsafe extern "C" fn no_escape0<'a>(_: usize, ap: ...) -> VaList<'a> {
+   |                                                       --- help: add explicit lifetime `'a` to the type of `ap`: `core::ffi::VaList<'a>`
+LL |     ap //~ ERROR: explicit lifetime required
+   |     ^^ lifetime `'a` required
+
+error[E0621]: explicit lifetime required in the type of `ap`
+  --> $DIR/variadic-ffi-5.rs:15:5
+   |
+LL | pub unsafe extern "C" fn no_escape1(_: usize, ap: ...) -> VaList<'static> {
+   |                                                   --- help: add explicit lifetime `'static` to the type of `ap`: `core::ffi::VaList<'static>`
+LL |     ap //~ ERROR: explicit lifetime required
+   |     ^^ lifetime `'static` required
+
+error: lifetime may not live long enough
+  --> $DIR/variadic-ffi-5.rs:19:28
+   |
+LL |     let _ = ap.copy(|ap| { ap }); //~ ERROR: lifetime may not live long enough
+   |                      ---   ^^ returning this value requires that `'1` must outlive `'2`
+   |                      | |
+   |                      | return type of closure is core::ffi::VaList<'2>
+   |                      has type `core::ffi::VaList<'1>`
+
+error: lifetime may not live long enough
+  --> $DIR/variadic-ffi-5.rs:23:5
+   |
+LL | pub unsafe extern "C" fn no_escape3(_: usize, ap0: &mut VaList, mut ap1: ...) {
+   |                                               ---               ------- has type `core::ffi::VaList<'1>`
+   |                                               |
+   |                                               has type `&mut core::ffi::VaList<'2>`
+LL |     *ap0 = ap1; //~ ERROR: lifetime may not live long enough
+   |     ^^^^^^^^^^ assignment requires that `'1` must outlive `'2`
+
+error: lifetime may not live long enough
+  --> $DIR/variadic-ffi-5.rs:27:5
+   |
+LL | pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaList, mut ap1: ...) {
+   |                                               -------               ------- has type `core::ffi::VaList<'2>`
+   |                                               |
+   |                                               has type `&mut core::ffi::VaList<'1>`
+LL |     ap0 = &mut ap1;
+   |     ^^^^^^^^^^^^^^ assignment requires that `'1` must outlive `'2`
+
+error: lifetime may not live long enough
+  --> $DIR/variadic-ffi-5.rs:27:5
+   |
+LL | pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaList, mut ap1: ...) {
+   |                                               -------               ------- has type `core::ffi::VaList<'1>`
+   |                                               |
+   |                                               has type `&mut core::ffi::VaList<'2>`
+LL |     ap0 = &mut ap1;
+   |     ^^^^^^^^^^^^^^ assignment requires that `'1` must outlive `'2`
+
+error[E0597]: `ap1` does not live long enough
+  --> $DIR/variadic-ffi-5.rs:27:11
+   |
+LL | pub unsafe extern "C" fn no_escape4(_: usize, mut ap0: &mut VaList, mut ap1: ...) {
+   |                                                        - let's call the lifetime of this reference `'1`
+LL |     ap0 = &mut ap1;
+   |     ------^^^^^^^^
+   |     |     |
+   |     |     borrowed value does not live long enough
+   |     assignment requires that `ap1` is borrowed for `'1`
+...
+LL | }
+   |  - `ap1` dropped here while still borrowed
+
+error: aborting due to 7 previous errors
+
+Some errors occurred: E0597, E0621.
+For more information about an error, try `rustc --explain E0597`.
diff --git a/src/test/ui/c-variadic/variadic-ffi-6.rs b/src/test/ui/c-variadic/variadic-ffi-6.rs
new file mode 100644 (file)
index 0000000..4dd8a2d
--- /dev/null
@@ -0,0 +1,13 @@
+#![crate_type="lib"]
+#![feature(c_variadic)]
+
+pub unsafe extern "C" fn use_vararg_lifetime(
+    x: usize,
+    y: ...
+) -> &usize { //~ ERROR missing lifetime specifier
+    &0
+}
+
+pub unsafe extern "C" fn use_normal_arg_lifetime(x: &usize, y: ...) -> &usize { // OK
+    x
+}
diff --git a/src/test/ui/c-variadic/variadic-ffi-6.stderr b/src/test/ui/c-variadic/variadic-ffi-6.stderr
new file mode 100644 (file)
index 0000000..76bd189
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0106]: missing lifetime specifier
+  --> $DIR/variadic-ffi-6.rs:7:6
+   |
+LL | ) -> &usize { //~ ERROR missing lifetime specifier
+   |      ^ help: consider giving it an explicit bounded or 'static lifetime: `&'static`
+   |
+   = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0106`.
diff --git a/src/test/ui/editions/edition-deny-async-fns-2015.rs b/src/test/ui/editions/edition-deny-async-fns-2015.rs
new file mode 100644 (file)
index 0000000..2105aa5
--- /dev/null
@@ -0,0 +1,34 @@
+// edition:2015
+
+#![feature(futures_api, async_await)]
+
+async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition
+
+fn baz() { async fn foo() {} } //~ ERROR `async fn` is not permitted in the 2015 edition
+
+async fn async_baz() { //~ ERROR `async fn` is not permitted in the 2015 edition
+    async fn bar() {} //~ ERROR `async fn` is not permitted in the 2015 edition
+}
+
+struct Foo {}
+
+impl Foo {
+    async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition
+}
+
+trait Bar {
+    async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition
+                      //~^ ERROR trait fns cannot be declared `async`
+}
+
+fn main() {
+    macro_rules! accept_item { ($x:item) => {} }
+
+    accept_item! {
+        async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition
+    }
+
+    let inside_closure = || {
+        async fn bar() {} //~ ERROR `async fn` is not permitted in the 2015 edition
+    };
+}
diff --git a/src/test/ui/editions/edition-deny-async-fns-2015.stderr b/src/test/ui/editions/edition-deny-async-fns-2015.stderr
new file mode 100644 (file)
index 0000000..1ad907a
--- /dev/null
@@ -0,0 +1,58 @@
+error[E0670]: `async fn` is not permitted in the 2015 edition
+  --> $DIR/edition-deny-async-fns-2015.rs:5:1
+   |
+LL | async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition
+   | ^^^^^
+
+error[E0670]: `async fn` is not permitted in the 2015 edition
+  --> $DIR/edition-deny-async-fns-2015.rs:7:12
+   |
+LL | fn baz() { async fn foo() {} } //~ ERROR `async fn` is not permitted in the 2015 edition
+   |            ^^^^^
+
+error[E0670]: `async fn` is not permitted in the 2015 edition
+  --> $DIR/edition-deny-async-fns-2015.rs:10:5
+   |
+LL |     async fn bar() {} //~ ERROR `async fn` is not permitted in the 2015 edition
+   |     ^^^^^
+
+error[E0670]: `async fn` is not permitted in the 2015 edition
+  --> $DIR/edition-deny-async-fns-2015.rs:9:1
+   |
+LL | async fn async_baz() { //~ ERROR `async fn` is not permitted in the 2015 edition
+   | ^^^^^
+
+error[E0670]: `async fn` is not permitted in the 2015 edition
+  --> $DIR/edition-deny-async-fns-2015.rs:32:9
+   |
+LL |         async fn bar() {} //~ ERROR `async fn` is not permitted in the 2015 edition
+   |         ^^^^^
+
+error[E0670]: `async fn` is not permitted in the 2015 edition
+  --> $DIR/edition-deny-async-fns-2015.rs:28:9
+   |
+LL |         async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition
+   |         ^^^^^
+
+error[E0670]: `async fn` is not permitted in the 2015 edition
+  --> $DIR/edition-deny-async-fns-2015.rs:16:5
+   |
+LL |     async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition
+   |     ^^^^^
+
+error[E0706]: trait fns cannot be declared `async`
+  --> $DIR/edition-deny-async-fns-2015.rs:20:5
+   |
+LL |     async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition
+   |     ^^^^^^^^^^^^^^^^^
+
+error[E0670]: `async fn` is not permitted in the 2015 edition
+  --> $DIR/edition-deny-async-fns-2015.rs:20:5
+   |
+LL |     async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition
+   |     ^^^^^
+
+error: aborting due to 9 previous errors
+
+Some errors occurred: E0670, E0706.
+For more information about an error, try `rustc --explain E0670`.
index b38bbc169bd60e0a33cf7d2e512263927efe7581..0ce91f0a401031b3a1591c7681f06883032cba83 100644 (file)
@@ -1,8 +1,8 @@
-error[E0045]: variadic function must have C or cdecl calling convention
+error[E0045]: C-variadic function must have C or cdecl calling convention
   --> $DIR/E0045.rs:1:17
    |
 LL | extern "Rust" { fn foo(x: u8, ...); }   //~ ERROR E0045
-   |                 ^^^^^^^^^^^^^^^^^^^ variadics require C or cdecl calling convention
+   |                 ^^^^^^^^^^^^^^^^^^^ C-variadics require C or cdecl calling convention
 
 error: aborting due to previous error
 
index 9eed1225ab82de1e47f55d0a1ebc402ec86806a1..51f13c7dbd5404e3670fb65327967bf2679e87e0 100644 (file)
@@ -22,7 +22,7 @@ fn main() {
         //~^ ERROR can't pass `u16` to variadic function
         //~| HELP cast the value to `c_uint`
         printf(::std::ptr::null(), printf);
-        //~^ ERROR can't pass `unsafe extern "C" fn(*const i8, ...) {printf}` to variadic function
-        //~| HELP cast the value to `unsafe extern "C" fn(*const i8, ...)`
+        //~^ ERROR can't pass `for<'r> unsafe extern "C" fn(*const i8, std::ffi::VaList<'r>, ...) {printf}` to variadic function
+        //~| HELP cast the value to `for<'r> unsafe extern "C" fn(*const i8, std::ffi::VaList<'r>, ...)`
     }
 }
index 486ca1fa92f15c670448309b14ffef43d07aa8be..8387d5c7e93a5fb05d2bdb0f16f69c873a972935 100644 (file)
@@ -28,15 +28,15 @@ error[E0617]: can't pass `u16` to variadic function
 LL |         printf(::std::ptr::null(), 0u16);
    |                                    ^^^^ help: cast the value to `c_uint`: `0u16 as c_uint`
 
-error[E0617]: can't pass `unsafe extern "C" fn(*const i8, ...) {printf}` to variadic function
+error[E0617]: can't pass `for<'r> unsafe extern "C" fn(*const i8, std::ffi::VaList<'r>, ...) {printf}` to variadic function
   --> $DIR/E0617.rs:24:36
    |
 LL |         printf(::std::ptr::null(), printf);
    |                                    ^^^^^^
-help: cast the value to `unsafe extern "C" fn(*const i8, ...)`
+help: cast the value to `for<'r> unsafe extern "C" fn(*const i8, std::ffi::VaList<'r>, ...)`
    |
-LL |         printf(::std::ptr::null(), printf as unsafe extern "C" fn(*const i8, ...));
-   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |         printf(::std::ptr::null(), printf as for<'r> unsafe extern "C" fn(*const i8, std::ffi::VaList<'r>, ...));
+   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to 6 previous errors
 
diff --git a/src/test/ui/feature-gate/feature-gate-c_variadic.rs b/src/test/ui/feature-gate/feature-gate-c_variadic.rs
new file mode 100644 (file)
index 0000000..5801a2a
--- /dev/null
@@ -0,0 +1,4 @@
+#![crate_type="lib"]
+
+pub unsafe extern "C" fn test(_: i32, ap: ...) { }
+//~^ C-varaidic functions are unstable
diff --git a/src/test/ui/feature-gate/feature-gate-c_variadic.stderr b/src/test/ui/feature-gate/feature-gate-c_variadic.stderr
new file mode 100644 (file)
index 0000000..a876e16
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0658]: C-varaidic functions are unstable (see issue #44930)
+  --> $DIR/feature-gate-c_variadic.rs:3:1
+   |
+LL | pub unsafe extern "C" fn test(_: i32, ap: ...) { }
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: add #![feature(c_variadic)] to the crate attributes to enable
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0658`.
index 84dd1b9f814c2c60b7333988746e421083161fe9..b6ab8ae0a9bc7c6b4a27f080194d07dc8e674bf6 100644 (file)
@@ -2,7 +2,8 @@
 
 #![feature(futures_api)]
 
-async fn foo() {} //~ ERROR async fn is unstable
+async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition
+                  //~^ ERROR async fn is unstable
 
 fn main() {
     let _ = async {}; //~ ERROR cannot find struct, variant or union type `async`
index 450b2c42f119d9f431fb824836b5a5f69d3e4783..58051153e1f0df72c43f74f9a6f5e4b09a54eb56 100644 (file)
@@ -1,11 +1,17 @@
+error[E0670]: `async fn` is not permitted in the 2015 edition
+  --> $DIR/feature-gate-async-await-2015-edition.rs:5:1
+   |
+LL | async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition
+   | ^^^^^
+
 error[E0422]: cannot find struct, variant or union type `async` in this scope
-  --> $DIR/feature-gate-async-await-2015-edition.rs:8:13
+  --> $DIR/feature-gate-async-await-2015-edition.rs:9:13
    |
 LL |     let _ = async {}; //~ ERROR cannot find struct, variant or union type `async`
    |             ^^^^^ not found in this scope
 
 error[E0425]: cannot find value `async` in this scope
-  --> $DIR/feature-gate-async-await-2015-edition.rs:9:13
+  --> $DIR/feature-gate-async-await-2015-edition.rs:10:13
    |
 LL |     let _ = async || { true }; //~ ERROR cannot find value `async` in this scope
    |             ^^^^^ not found in this scope
@@ -13,12 +19,12 @@ LL |     let _ = async || { true }; //~ ERROR cannot find value `async` in this
 error[E0658]: async fn is unstable (see issue #50547)
   --> $DIR/feature-gate-async-await-2015-edition.rs:5:1
    |
-LL | async fn foo() {} //~ ERROR async fn is unstable
+LL | async fn foo() {} //~ ERROR `async fn` is not permitted in the 2015 edition
    | ^^^^^^^^^^^^^^^^^
    |
    = help: add #![feature(async_await)] to the crate attributes to enable
 
-error: aborting due to 3 previous errors
+error: aborting due to 4 previous errors
 
-Some errors occurred: E0422, E0425, E0658.
+Some errors occurred: E0422, E0425, E0658, E0670.
 For more information about an error, try `rustc --explain E0422`.
index 918d40d681bb4c1838264d042e59f16ebff98b3b..77f2f13c99ee89dcc36fb642a09fe8563c6ba021 100644 (file)
@@ -1,4 +1,4 @@
-error[E0658]: #[unwind] is experimental
+error[E0658]: #[unwind] is experimental (see issue #58760)
   --> $DIR/feature-gate-unwind-attributes.rs:11:5
    |
 LL |     #[unwind(allowed)] //~ ERROR #[unwind] is experimental
index 20da78f08dd26c8f8879e5b5ce83145537445a10..1cd05f4d44c5e426e126de18e56bba3514d95d8e 100644 (file)
@@ -13,7 +13,7 @@ mod bar {
     }
     fn f() {
         ::foo::m!();
-        println!(); // OK on 2015 edition (at least for now)
+        println!(); //~ ERROR cannot find macro `print!` in this scope
     }
 }
 
index 7c9404cee2b8feb291bd65bf046f076618543dc0..b1de7700edb3cb99726c9ce65723ed15a34b5b2c 100644 (file)
@@ -7,6 +7,15 @@ LL |     fn f() { ::bar::m!(); }
 LL |         Vec::new(); //~ ERROR failed to resolve
    |         ^^^ use of undeclared type or module `Vec`
 
+error: cannot find macro `print!` in this scope
+  --> $DIR/no_implicit_prelude.rs:16:9
+   |
+LL |         println!(); //~ ERROR cannot find macro `print!` in this scope
+   |         ^^^^^^^^^^^
+   |
+   = help: have you added the `#[macro_use]` on the module/import?
+   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
+
 error[E0599]: no method named `clone` found for type `()` in the current scope
   --> $DIR/no_implicit_prelude.rs:12:12
    |
@@ -20,7 +29,7 @@ LL |         ().clone() //~ ERROR no method named `clone` found
    = note: the following trait is implemented but not in scope, perhaps add a `use` for it:
            `use std::clone::Clone;`
 
-error: aborting due to 2 previous errors
+error: aborting due to 3 previous errors
 
 Some errors occurred: E0433, E0599.
 For more information about an error, try `rustc --explain E0433`.
diff --git a/src/test/ui/impl-trait/recursive-async-impl-trait-type.rs b/src/test/ui/impl-trait/recursive-async-impl-trait-type.rs
new file mode 100644 (file)
index 0000000..4064252
--- /dev/null
@@ -0,0 +1,11 @@
+// edition:2018
+// Test that impl trait does not allow creating recursive types that are
+// otherwise forbidden when using `async` and `await`.
+
+#![feature(await_macro, async_await, futures_api, generators)]
+
+async fn recursive_async_function() -> () { //~ ERROR
+    await!(recursive_async_function());
+}
+
+fn main() {}
diff --git a/src/test/ui/impl-trait/recursive-async-impl-trait-type.stderr b/src/test/ui/impl-trait/recursive-async-impl-trait-type.stderr
new file mode 100644 (file)
index 0000000..acdeabb
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0720]: opaque type expands to a recursive type
+  --> $DIR/recursive-async-impl-trait-type.rs:7:40
+   |
+LL | async fn recursive_async_function() -> () { //~ ERROR
+   |                                        ^^ expands to self-referential type
+   |
+   = note: expanded type is `std::future::GenFuture<[static generator@$DIR/recursive-async-impl-trait-type.rs:7:43: 9:2 {impl std::future::Future, ()}]>`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0720`.
index facb191a37081f64e33add598c99d11cf0e1029b..869876dc6a88a3e6c7f53a5cb129a3044227125f 100644 (file)
@@ -1,7 +1,7 @@
 // Test that impl trait does not allow creating recursive types that are
 // otherwise forbidden.
 
-#![feature(await_macro, async_await, futures_api, generators)]
+#![feature(futures_api, generators)]
 
 fn option(i: i32) -> impl Sized { //~ ERROR
     if i < 0 {
@@ -62,10 +62,6 @@ fn generator_hold() -> impl Sized { //~ ERROR
     }
 }
 
-async fn recursive_async_function() -> () { //~ ERROR
-    await!(recursive_async_function());
-}
-
 fn use_fn_ptr() -> impl Sized { // OK, error already reported
     fn_ptr()
 }
index 8a8789120577e72a681b3d57d7bf3a0e18b1d858..96494229fd339f6d70e97d85d19ba63146b35e21 100644 (file)
@@ -95,15 +95,7 @@ LL | fn generator_hold() -> impl Sized { //~ ERROR
    = note: expanded type is `[generator@$DIR/recursive-impl-trait-type.rs:58:5: 62:6 {impl Sized, ()}]`
 
 error[E0720]: opaque type expands to a recursive type
-  --> $DIR/recursive-impl-trait-type.rs:65:40
-   |
-LL | async fn recursive_async_function() -> () { //~ ERROR
-   |                                        ^^ expands to self-referential type
-   |
-   = note: expanded type is `std::future::GenFuture<[static generator@$DIR/recursive-impl-trait-type.rs:65:43: 67:2 {impl std::future::Future, ()}]>`
-
-error[E0720]: opaque type expands to a recursive type
-  --> $DIR/recursive-impl-trait-type.rs:73:26
+  --> $DIR/recursive-impl-trait-type.rs:69:26
    |
 LL | fn mutual_recursion() -> impl Sync { //~ ERROR
    |                          ^^^^^^^^^ expands to self-referential type
@@ -111,13 +103,13 @@ LL | fn mutual_recursion() -> impl Sync { //~ ERROR
    = note: type resolves to itself
 
 error[E0720]: opaque type expands to a recursive type
-  --> $DIR/recursive-impl-trait-type.rs:77:28
+  --> $DIR/recursive-impl-trait-type.rs:73:28
    |
 LL | fn mutual_recursion_b() -> impl Sized { //~ ERROR
    |                            ^^^^^^^^^^ expands to self-referential type
    |
    = note: type resolves to itself
 
-error: aborting due to 15 previous errors
+error: aborting due to 14 previous errors
 
 For more information about this error, try `rustc --explain E0720`.
index aea630e7c26a12cca779c75e7e49cad520ccecb5..8d23f0e477077676cb2e2b4773f8d8a98bc5d22a 100644 (file)
@@ -1,3 +1,3 @@
 extern "C" fn foo(x: u8, ...);
-//~^ ERROR only foreign functions are allowed to be variadic
+//~^ ERROR only foreign functions are allowed to be C-variadic
 //~| ERROR expected one of `->`, `where`, or `{`, found `;`
index 7a0b8066fd52a81e67a4edce949f8a68d9aaf170..b2dbf8b9190848ef69c0886ebb9becb71be116b7 100644 (file)
@@ -1,4 +1,4 @@
-error: only foreign functions are allowed to be variadic
+error: only foreign functions are allowed to be C-variadic
   --> $DIR/invalid-variadic-function.rs:1:26
    |
 LL | extern "C" fn foo(x: u8, ...);
index 392769b4c565f37ab5586e3633032b806705b743..b3ca736622a2ad662501bdb87026f6a6297d848f 100644 (file)
@@ -20,6 +20,7 @@ note: ...which requires checking which parts of `B` are promotable to static...
 LL | const B: i32 = A;
    |                ^
    = note: ...which again requires const checking if rvalue is promotable to static `A`, completing the cycle
+   = note: cycle used when running analysis passes on this crate
 
 error: aborting due to previous error
 
index b27b60459d63303f70c331a8653c9cb6086d807c..cb0a9163b74702da761767ebcc60f9dbf6012906 100644 (file)
@@ -4,7 +4,7 @@ error: expected `*` or `+`
 LL |     ($(a)?) => {} //~ERROR expected `*` or `+`
    |          ^
    |
-   = note: `?` is not a macro repetition operator
+   = note: `?` is not a macro repetition operator in the 2015 edition, but is accepted in the 2018 edition
 
 error: expected `*` or `+`
   --> $DIR/macro-at-most-once-rep-2015-ques-rep.rs:10:11
@@ -12,7 +12,7 @@ error: expected `*` or `+`
 LL |     ($(a),?) => {} //~ERROR expected `*` or `+`
    |           ^
    |
-   = note: `?` is not a macro repetition operator
+   = note: `?` is not a macro repetition operator in the 2015 edition, but is accepted in the 2018 edition
 
 error: aborting due to 2 previous errors
 
index 2473420a77930fb88522e9983b9986812be1d39f..b308e644ad9f89dc743cd8a58e5d34f2ce6198b1 100644 (file)
@@ -10,11 +10,11 @@ error: expected one of `!`, `(`, `)`, `+`, `,`, `::`, or `<`, found `{`
 LL |             Nope(i32 {}) //~ ERROR: found `{`
    |                      ^ expected one of 7 possible tokens here
 
-error: expected one of `!`, `&&`, `&`, `(`, `)`, `*`, `+`, `,`, `::`, `<`, `?`, `[`, `_`, `crate`, `dyn`, `extern`, `fn`, `for`, `impl`, `pub`, `unsafe`, `}`, or lifetime, found `{`
+error: expected one of `!`, `&&`, `&`, `(`, `)`, `*`, `+`, `,`, `...`, `::`, `<`, `?`, `[`, `_`, `crate`, `dyn`, `extern`, `fn`, `for`, `impl`, `pub`, `unsafe`, `}`, or lifetime, found `{`
   --> $DIR/recover-enum2.rs:27:22
    |
 LL |             Nope(i32 {}) //~ ERROR: found `{`
-   |                      ^ expected one of 23 possible tokens here
+   |                      ^ expected one of 24 possible tokens here
 
 error: expected expression, found reserved identifier `_`
   --> $DIR/recover-enum2.rs:32:22
index 13bce27bb83440c8210b6acebeda237b815631a1..ce83cc87abe00f937b45e97d4d4c60a6a29a62d3 100644 (file)
@@ -1,5 +1,5 @@
 fn foo(x: isize, ...) {
-    //~^ ERROR: only foreign functions are allowed to be variadic
+    //~^ ERROR: only foreign functions are allowed to be C-variadic
 }
 
 fn main() {}
index 150de9e63d39dde070e37db8a840a4f37e444076..8ea4d194396faa0082cd2598cab38d97d9e46829 100644 (file)
@@ -1,4 +1,4 @@
-error: only foreign functions are allowed to be variadic
+error: only foreign functions are allowed to be C-variadic
   --> $DIR/variadic-ffi-3.rs:1:18
    |
 LL | fn foo(x: isize, ...) {
index 812ed256a5d32955b8e3375b1f95df8b1289c4e0..5f8b3f8f539b8df463f457d8ae7ac8724bdc84ed 100644 (file)
@@ -1,5 +1,5 @@
 extern "C" fn foo(x: isize, ...) {
-    //~^ ERROR: only foreign functions are allowed to be variadic
+    //~^ ERROR: only foreign functions are allowed to be C-variadic
 }
 
 fn main() {}
index 2d036b0cf3792bd78a356a7d3d96763991bd2b52..69fbf84869c13bf7ad809dc6ab54f6c0bc21fae4 100644 (file)
@@ -1,4 +1,4 @@
-error: only foreign functions are allowed to be variadic
+error: only foreign functions are allowed to be C-variadic
   --> $DIR/variadic-ffi-4.rs:1:29
    |
 LL | extern "C" fn foo(x: isize, ...) {
index 0a7f405746c88536ace10387884586a4d5071b20..9f47b2e9b9f4192ec5da126e0f442cdfc35e7e2a 100644 (file)
@@ -1,10 +1,9 @@
 // Issue #876
 
-#![no_implicit_prelude]
 use std::vec::Vec;
 
 fn last<T>(v: Vec<&T> ) -> std::option::Option<T> {
-    panic!();
+    ::std::panic!();
 }
 
 fn main() {
index a0d6b0007d7d989648e969c4b43e1d2b7fbff2b7..23e3d66526215b51ef4fdc361df045bea2b72b17 100644 (file)
@@ -1,5 +1,5 @@
 error[E0308]: mismatched types
-  --> $DIR/tag-that-dare-not-speak-its-name.rs:12:20
+  --> $DIR/tag-that-dare-not-speak-its-name.rs:11:20
    |
 LL |     let x : char = last(y);
    |                    ^^^^^^^ expected char, found enum `std::option::Option`
diff --git a/src/test/ui/variadic/variadic-ffi-2.rs b/src/test/ui/variadic/variadic-ffi-2.rs
deleted file mode 100644 (file)
index 224ac16..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-// ignore-arm stdcall isn't supported
-
-fn baz(f: extern "stdcall" fn(usize, ...)) {
-    //~^ ERROR: variadic function must have C or cdecl calling convention
-    f(22, 44);
-}
-
-fn main() {}
diff --git a/src/test/ui/variadic/variadic-ffi-2.stderr b/src/test/ui/variadic/variadic-ffi-2.stderr
deleted file mode 100644 (file)
index cb2a9f8..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-error[E0045]: variadic function must have C or cdecl calling convention
-  --> $DIR/variadic-ffi-2.rs:3:11
-   |
-LL | fn baz(f: extern "stdcall" fn(usize, ...)) {
-   |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ variadics require C or cdecl calling convention
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0045`.
diff --git a/src/test/ui/variadic/variadic-ffi-3.rs b/src/test/ui/variadic/variadic-ffi-3.rs
deleted file mode 100644 (file)
index 12b3426..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-extern {
-    fn foo(f: isize, x: u8, ...);
-    //~^ defined here
-    //~| defined here
-}
-
-extern "C" fn bar(f: isize, x: u8) {}
-
-fn main() {
-    unsafe {
-        foo(); //~ ERROR: this function takes at least 2 parameters but 0 parameters were supplied
-        foo(1); //~ ERROR: this function takes at least 2 parameters but 1 parameter was supplied
-
-        let x: unsafe extern "C" fn(f: isize, x: u8) = foo;
-        //~^ ERROR: mismatched types
-        //~| expected type `unsafe extern "C" fn(isize, u8)`
-        //~| found type `unsafe extern "C" fn(isize, u8, ...) {foo}`
-
-        let y: extern "C" fn(f: isize, x: u8, ...) = bar;
-        //~^ ERROR: mismatched types
-        //~| expected type `extern "C" fn(isize, u8, ...)`
-        //~| found type `extern "C" fn(isize, u8) {bar}`
-
-        foo(1, 2, 3f32); //~ ERROR can't pass `f32` to variadic function
-        foo(1, 2, true); //~ ERROR can't pass `bool` to variadic function
-        foo(1, 2, 1i8); //~ ERROR can't pass `i8` to variadic function
-        foo(1, 2, 1u8); //~ ERROR can't pass `u8` to variadic function
-        foo(1, 2, 1i16); //~ ERROR can't pass `i16` to variadic function
-        foo(1, 2, 1u16); //~ ERROR can't pass `u16` to variadic function
-    }
-}
diff --git a/src/test/ui/variadic/variadic-ffi-3.stderr b/src/test/ui/variadic/variadic-ffi-3.stderr
deleted file mode 100644 (file)
index 0fecbbf..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-error[E0060]: this function takes at least 2 parameters but 0 parameters were supplied
-  --> $DIR/variadic-ffi-3.rs:11:9
-   |
-LL |     fn foo(f: isize, x: u8, ...);
-   |     ----------------------------- defined here
-...
-LL |         foo(); //~ ERROR: this function takes at least 2 parameters but 0 parameters were supplied
-   |         ^^^^^ expected at least 2 parameters
-
-error[E0060]: this function takes at least 2 parameters but 1 parameter was supplied
-  --> $DIR/variadic-ffi-3.rs:12:9
-   |
-LL |     fn foo(f: isize, x: u8, ...);
-   |     ----------------------------- defined here
-...
-LL |         foo(1); //~ ERROR: this function takes at least 2 parameters but 1 parameter was supplied
-   |         ^^^^^^ expected at least 2 parameters
-
-error[E0308]: mismatched types
-  --> $DIR/variadic-ffi-3.rs:14:56
-   |
-LL |         let x: unsafe extern "C" fn(f: isize, x: u8) = foo;
-   |                                                        ^^^ expected non-variadic fn, found variadic function
-   |
-   = note: expected type `unsafe extern "C" fn(isize, u8)`
-              found type `unsafe extern "C" fn(isize, u8, ...) {foo}`
-
-error[E0308]: mismatched types
-  --> $DIR/variadic-ffi-3.rs:19:54
-   |
-LL |         let y: extern "C" fn(f: isize, x: u8, ...) = bar;
-   |                                                      ^^^ expected variadic fn, found non-variadic function
-   |
-   = note: expected type `extern "C" fn(isize, u8, ...)`
-              found type `extern "C" fn(isize, u8) {bar}`
-
-error[E0617]: can't pass `f32` to variadic function
-  --> $DIR/variadic-ffi-3.rs:24:19
-   |
-LL |         foo(1, 2, 3f32); //~ ERROR can't pass `f32` to variadic function
-   |                   ^^^^ help: cast the value to `c_double`: `3f32 as c_double`
-
-error[E0617]: can't pass `bool` to variadic function
-  --> $DIR/variadic-ffi-3.rs:25:19
-   |
-LL |         foo(1, 2, true); //~ ERROR can't pass `bool` to variadic function
-   |                   ^^^^ help: cast the value to `c_int`: `true as c_int`
-
-error[E0617]: can't pass `i8` to variadic function
-  --> $DIR/variadic-ffi-3.rs:26:19
-   |
-LL |         foo(1, 2, 1i8); //~ ERROR can't pass `i8` to variadic function
-   |                   ^^^ help: cast the value to `c_int`: `1i8 as c_int`
-
-error[E0617]: can't pass `u8` to variadic function
-  --> $DIR/variadic-ffi-3.rs:27:19
-   |
-LL |         foo(1, 2, 1u8); //~ ERROR can't pass `u8` to variadic function
-   |                   ^^^ help: cast the value to `c_uint`: `1u8 as c_uint`
-
-error[E0617]: can't pass `i16` to variadic function
-  --> $DIR/variadic-ffi-3.rs:28:19
-   |
-LL |         foo(1, 2, 1i16); //~ ERROR can't pass `i16` to variadic function
-   |                   ^^^^ help: cast the value to `c_int`: `1i16 as c_int`
-
-error[E0617]: can't pass `u16` to variadic function
-  --> $DIR/variadic-ffi-3.rs:29:19
-   |
-LL |         foo(1, 2, 1u16); //~ ERROR can't pass `u16` to variadic function
-   |                   ^^^^ help: cast the value to `c_uint`: `1u16 as c_uint`
-
-error: aborting due to 10 previous errors
-
-Some errors occurred: E0060, E0308, E0617.
-For more information about an error, try `rustc --explain E0060`.
diff --git a/src/test/ui/variadic/variadic-ffi.rs b/src/test/ui/variadic/variadic-ffi.rs
deleted file mode 100644 (file)
index 61b2ad4..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-// ignore-arm stdcall isn't supported
-// ignore-aarch64 stdcall isn't supported
-
-extern "stdcall" {
-    fn printf(_: *const u8, ...); //~ ERROR: variadic function must have C or cdecl calling
-}
-
-extern {
-    fn foo(f: isize, x: u8, ...);
-}
-
-extern "C" fn bar(f: isize, x: u8) {}
-
-fn main() {
-    // errors below are no longer checked because error above aborts
-    // compilation; see variadic-ffi-3.rs for corresponding test.
-    unsafe {
-        foo();
-        foo(1);
-
-        let x: unsafe extern "C" fn(f: isize, x: u8) = foo;
-        let y: extern "C" fn(f: isize, x: u8, ...) = bar;
-
-        foo(1, 2, 3f32);
-        foo(1, 2, true);
-        foo(1, 2, 1i8);
-        foo(1, 2, 1u8);
-        foo(1, 2, 1i16);
-        foo(1, 2, 1u16);
-    }
-}
diff --git a/src/test/ui/variadic/variadic-ffi.stderr b/src/test/ui/variadic/variadic-ffi.stderr
deleted file mode 100644 (file)
index 617b1f4..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-error[E0045]: variadic function must have C or cdecl calling convention
-  --> $DIR/variadic-ffi.rs:5:5
-   |
-LL |     fn printf(_: *const u8, ...); //~ ERROR: variadic function must have C or cdecl calling
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ variadics require C or cdecl calling convention
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0045`.
index 63196eda7cc5fd1be91e049b907a572db17221b8..cd60f36b1d273a012eb1b2611ec5d7ccd5c74271 100644 (file)
@@ -82,25 +82,27 @@ pub fn check(path: &path::Path, bad: &mut bool) {
         !lang_features.contains_key(name)
     }).collect();
 
+    // Library features
     let unstable_lib_feature_names = collect_unstable_feature_names(&lib_features);
     let unstable_book_lib_features_section_file_names =
         collect_unstable_book_lib_features_section_file_names(path);
 
-    // Check for Unstable Book sections that don't have a corresponding unstable feature
-    for feature_name in &unstable_book_lib_features_section_file_names -
-                        &unstable_lib_feature_names {
-        tidy_error!(bad,
-                    "The Unstable Book has a 'library feature' section '{}' which doesn't \
-                     correspond to an unstable library feature",
-                    feature_name)
-    }
-
     // Language features
-
     let unstable_lang_feature_names = collect_unstable_feature_names(&lang_features);
     let unstable_book_lang_features_section_file_names =
         collect_unstable_book_lang_features_section_file_names(path);
 
+    // Check for Unstable Book sections that don't have a corresponding unstable feature
+    for feature_name in &unstable_book_lib_features_section_file_names -
+                        &unstable_lib_feature_names {
+        if !unstable_lang_feature_names.contains(&feature_name) {
+            tidy_error!(bad,
+                        "The Unstable Book has a 'library feature' section '{}' which doesn't \
+                         correspond to an unstable library feature",
+                        feature_name);
+        }
+    }
+
     // Check for Unstable Book sections that don't have a corresponding unstable feature.
     for feature_name in &unstable_book_lang_features_section_file_names -
                         &unstable_lang_feature_names {