]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #57770 - Zoxc:no-hash-query, r=michaelwoerister
authorbors <bors@rust-lang.org>
Sun, 10 Feb 2019 01:33:17 +0000 (01:33 +0000)
committerbors <bors@rust-lang.org>
Sun, 10 Feb 2019 01:33:17 +0000 (01:33 +0000)
Add a query type which is always marked as red if it runs

This is useful for queries which produce results which are very likely to change if their inputs do.

I also expect this to be useful for end to end queries because 1) we don't need `HashStable` impls and 2) we avoid the overhead of hashing the result of large results like the AST or the HIR map.

r? @michaelwoerister

556 files changed:
src/bootstrap/builder.rs
src/bootstrap/test.rs
src/build_helper/Cargo.toml
src/build_helper/lib.rs
src/liballoc/tests/arc.rs
src/liballoc/tests/binary_heap.rs
src/liballoc/tests/btree/mod.rs
src/liballoc/tests/heap.rs
src/liballoc/tests/rc.rs
src/liballoc/tests/slice.rs
src/liballoc/tests/str.rs
src/liballoc/tests/string.rs
src/liballoc/tests/vec.rs
src/liballoc/tests/vec_deque.rs
src/libcore/tests/cell.rs
src/libcore/tests/fmt/mod.rs
src/libcore/tests/hash/mod.rs
src/libcore/tests/iter.rs
src/libcore/tests/num/mod.rs
src/libcore/tests/option.rs
src/libcore/tests/ptr.rs
src/libcore/tests/result.rs
src/libcore/tests/slice.rs
src/libcore/tests/time.rs
src/librustc/hir/def.rs
src/librustc/hir/lowering.rs
src/librustc/hir/map/def_collector.rs
src/librustc/hir/map/definitions.rs
src/librustc/ich/impls_hir.rs
src/librustc/lint/builtin.rs
src/librustc/lint/mod.rs
src/librustc/mir/mod.rs
src/librustc/traits/project.rs
src/librustc/traits/query/normalize.rs
src/librustc/ty/codec.rs
src/librustc/ty/context.rs
src/librustc/ty/item_path.rs
src/librustc/ty/structural_impls.rs
src/librustc/util/ppaux.rs
src/librustc_allocator/Cargo.toml
src/librustc_allocator/expand.rs
src/librustc_allocator/lib.rs
src/librustc_borrowck/Cargo.toml
src/librustc_borrowck/borrowck/check_loans.rs
src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs
src/librustc_borrowck/borrowck/gather_loans/lifetime.rs
src/librustc_borrowck/borrowck/gather_loans/mod.rs
src/librustc_borrowck/borrowck/gather_loans/move_error.rs
src/librustc_borrowck/borrowck/gather_loans/restrictions.rs
src/librustc_borrowck/borrowck/mod.rs
src/librustc_borrowck/borrowck/move_data.rs
src/librustc_borrowck/borrowck/unused.rs
src/librustc_borrowck/dataflow.rs
src/librustc_borrowck/graphviz.rs
src/librustc_borrowck/lib.rs
src/librustc_codegen_utils/Cargo.toml
src/librustc_codegen_utils/codegen_backend.rs
src/librustc_codegen_utils/lib.rs
src/librustc_codegen_utils/link.rs
src/librustc_codegen_utils/symbol_names.rs
src/librustc_cratesio_shim/Cargo.toml
src/librustc_cratesio_shim/src/lib.rs
src/librustc_data_structures/Cargo.toml
src/librustc_data_structures/bit_set.rs
src/librustc_data_structures/fingerprint.rs
src/librustc_data_structures/flock.rs
src/librustc_data_structures/graph/dominators/mod.rs
src/librustc_data_structures/graph/implementation/mod.rs
src/librustc_data_structures/graph/implementation/tests.rs
src/librustc_data_structures/graph/scc/mod.rs
src/librustc_data_structures/graph/scc/test.rs
src/librustc_data_structures/graph/test.rs
src/librustc_data_structures/indexed_vec.rs
src/librustc_data_structures/lib.rs
src/librustc_data_structures/obligation_forest/graphviz.rs
src/librustc_data_structures/obligation_forest/mod.rs
src/librustc_data_structures/owning_ref/mod.rs
src/librustc_data_structures/ptr_key.rs
src/librustc_data_structures/snapshot_map/mod.rs
src/librustc_data_structures/sorted_map.rs
src/librustc_data_structures/stable_hasher.rs
src/librustc_data_structures/svh.rs
src/librustc_data_structures/sync.rs
src/librustc_data_structures/tiny_list.rs
src/librustc_data_structures/transitive_relation.rs
src/librustc_data_structures/vec_linked_list.rs
src/librustc_data_structures/work_queue.rs
src/librustc_errors/emitter.rs
src/librustc_incremental/Cargo.toml
src/librustc_incremental/assert_dep_graph.rs
src/librustc_incremental/lib.rs
src/librustc_incremental/persist/dirty_clean.rs
src/librustc_incremental/persist/load.rs
src/librustc_incremental/persist/mod.rs
src/librustc_incremental/persist/save.rs
src/librustc_incremental/persist/work_product.rs
src/librustc_lint/Cargo.toml
src/librustc_lint/builtin.rs
src/librustc_lint/diagnostics.rs
src/librustc_lint/lib.rs
src/librustc_lint/nonstandard_style.rs
src/librustc_lint/types.rs
src/librustc_lint/unused.rs
src/librustc_metadata/Cargo.toml
src/librustc_metadata/creader.rs
src/librustc_metadata/cstore.rs
src/librustc_metadata/cstore_impl.rs
src/librustc_metadata/decoder.rs
src/librustc_metadata/diagnostics.rs
src/librustc_metadata/dynamic_lib.rs
src/librustc_metadata/encoder.rs
src/librustc_metadata/index.rs
src/librustc_metadata/index_builder.rs
src/librustc_metadata/isolated_encoder.rs
src/librustc_metadata/lib.rs
src/librustc_metadata/locator.rs
src/librustc_metadata/native_libs.rs
src/librustc_metadata/schema.rs
src/librustc_mir/Cargo.toml
src/librustc_mir/borrow_check/borrow_set.rs
src/librustc_mir/borrow_check/error_reporting.rs
src/librustc_mir/borrow_check/flows.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/constraints/graph.rs
src/librustc_mir/borrow_check/nll/constraints/mod.rs
src/librustc_mir/borrow_check/nll/explain_borrow/find_use.rs
src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs
src/librustc_mir/borrow_check/nll/facts.rs
src/librustc_mir/borrow_check/nll/invalidation.rs
src/librustc_mir/borrow_check/nll/mod.rs
src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs
src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs
src/librustc_mir/borrow_check/nll/region_infer/error_reporting/var_name.rs
src/librustc_mir/borrow_check/nll/region_infer/graphviz.rs
src/librustc_mir/borrow_check/nll/region_infer/mod.rs
src/librustc_mir/borrow_check/nll/type_check/constraint_conversion.rs
src/librustc_mir/borrow_check/nll/type_check/free_region_relations.rs
src/librustc_mir/borrow_check/nll/type_check/input_output.rs
src/librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs
src/librustc_mir/borrow_check/nll/type_check/liveness/local_use_map.rs
src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs
src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs
src/librustc_mir/borrow_check/nll/type_check/mod.rs
src/librustc_mir/borrow_check/nll/type_check/relate_tys.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/used_muts.rs
src/librustc_mir/build/block.rs
src/librustc_mir/build/cfg.rs
src/librustc_mir/build/expr/as_constant.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/category.rs
src/librustc_mir/build/expr/into.rs
src/librustc_mir/build/expr/stmt.rs
src/librustc_mir/build/into.rs
src/librustc_mir/build/matches/mod.rs
src/librustc_mir/build/matches/simplify.rs
src/librustc_mir/build/matches/test.rs
src/librustc_mir/build/matches/util.rs
src/librustc_mir/build/misc.rs
src/librustc_mir/build/mod.rs
src/librustc_mir/build/scope.rs
src/librustc_mir/const_eval.rs
src/librustc_mir/dataflow/at_location.rs
src/librustc_mir/dataflow/drop_flag_effects.rs
src/librustc_mir/dataflow/graphviz.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/impls/storage_liveness.rs
src/librustc_mir/dataflow/mod.rs
src/librustc_mir/dataflow/move_paths/mod.rs
src/librustc_mir/hair/cx/block.rs
src/librustc_mir/hair/cx/expr.rs
src/librustc_mir/hair/cx/mod.rs
src/librustc_mir/hair/cx/to_ref.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/snapshot.rs
src/librustc_mir/interpret/terminator.rs
src/librustc_mir/interpret/traits.rs
src/librustc_mir/interpret/visitor.rs
src/librustc_mir/lib.rs
src/librustc_mir/lints.rs
src/librustc_mir/monomorphize/collector.rs
src/librustc_mir/monomorphize/item.rs
src/librustc_mir/monomorphize/partitioning.rs
src/librustc_mir/shim.rs
src/librustc_mir/transform/add_call_guards.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/cleanup_post_borrowck.rs
src/librustc_mir/transform/const_prop.rs
src/librustc_mir/transform/copy_prop.rs
src/librustc_mir/transform/deaggregator.rs
src/librustc_mir/transform/dump_mir.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/mod.rs
src/librustc_mir/transform/no_landing_pads.rs
src/librustc_mir/transform/promote_consts.rs
src/librustc_mir/transform/qualify_consts.rs
src/librustc_mir/transform/remove_noop_landing_pads.rs
src/librustc_mir/transform/rustc_peek.rs
src/librustc_mir/transform/simplify.rs
src/librustc_mir/transform/simplify_branches.rs
src/librustc_mir/transform/uniform_array_move_out.rs
src/librustc_mir/util/borrowck_errors.rs
src/librustc_mir/util/def_use.rs
src/librustc_mir/util/elaborate_drops.rs
src/librustc_mir/util/graphviz.rs
src/librustc_mir/util/liveness.rs
src/librustc_mir/util/patch.rs
src/librustc_mir/util/pretty.rs
src/librustc_passes/Cargo.toml
src/librustc_passes/ast_validation.rs
src/librustc_passes/diagnostics.rs
src/librustc_passes/hir_stats.rs
src/librustc_passes/lib.rs
src/librustc_passes/loops.rs
src/librustc_passes/rvalue_promotion.rs
src/librustc_resolve/diagnostics.rs
src/librustc_resolve/error_reporting.rs
src/librustc_resolve/lib.rs
src/librustc_save_analysis/Cargo.toml
src/librustc_save_analysis/dump_visitor.rs
src/librustc_save_analysis/json_dumper.rs
src/librustc_save_analysis/lib.rs
src/librustc_save_analysis/sig.rs
src/librustc_save_analysis/span_utils.rs
src/librustc_target/Cargo.toml
src/librustc_target/abi/call/aarch64.rs
src/librustc_target/abi/call/amdgpu.rs
src/librustc_target/abi/call/arm.rs
src/librustc_target/abi/call/asmjs.rs
src/librustc_target/abi/call/hexagon.rs
src/librustc_target/abi/call/mips.rs
src/librustc_target/abi/call/mips64.rs
src/librustc_target/abi/call/mod.rs
src/librustc_target/abi/call/msp430.rs
src/librustc_target/abi/call/nvptx.rs
src/librustc_target/abi/call/nvptx64.rs
src/librustc_target/abi/call/powerpc.rs
src/librustc_target/abi/call/powerpc64.rs
src/librustc_target/abi/call/riscv.rs
src/librustc_target/abi/call/s390x.rs
src/librustc_target/abi/call/sparc.rs
src/librustc_target/abi/call/sparc64.rs
src/librustc_target/abi/call/wasm32.rs
src/librustc_target/abi/call/x86.rs
src/librustc_target/abi/call/x86_64.rs
src/librustc_target/abi/call/x86_win64.rs
src/librustc_target/abi/mod.rs
src/librustc_target/lib.rs
src/librustc_target/spec/aarch64_apple_ios.rs
src/librustc_target/spec/aarch64_fuchsia.rs
src/librustc_target/spec/aarch64_linux_android.rs
src/librustc_target/spec/aarch64_pc_windows_msvc.rs
src/librustc_target/spec/aarch64_unknown_cloudabi.rs
src/librustc_target/spec/aarch64_unknown_freebsd.rs
src/librustc_target/spec/aarch64_unknown_hermit.rs
src/librustc_target/spec/aarch64_unknown_linux_gnu.rs
src/librustc_target/spec/aarch64_unknown_linux_musl.rs
src/librustc_target/spec/aarch64_unknown_netbsd.rs
src/librustc_target/spec/aarch64_unknown_openbsd.rs
src/librustc_target/spec/abi.rs
src/librustc_target/spec/android_base.rs
src/librustc_target/spec/apple_base.rs
src/librustc_target/spec/apple_ios_base.rs
src/librustc_target/spec/arm_base.rs
src/librustc_target/spec/arm_linux_androideabi.rs
src/librustc_target/spec/arm_unknown_linux_gnueabi.rs
src/librustc_target/spec/arm_unknown_linux_gnueabihf.rs
src/librustc_target/spec/arm_unknown_linux_musleabi.rs
src/librustc_target/spec/arm_unknown_linux_musleabihf.rs
src/librustc_target/spec/armebv7r_none_eabi.rs
src/librustc_target/spec/armebv7r_none_eabihf.rs
src/librustc_target/spec/armv4t_unknown_linux_gnueabi.rs
src/librustc_target/spec/armv5te_unknown_linux_gnueabi.rs
src/librustc_target/spec/armv5te_unknown_linux_musleabi.rs
src/librustc_target/spec/armv6_unknown_netbsd_eabihf.rs
src/librustc_target/spec/armv7_apple_ios.rs
src/librustc_target/spec/armv7_linux_androideabi.rs
src/librustc_target/spec/armv7_unknown_cloudabi_eabihf.rs
src/librustc_target/spec/armv7_unknown_linux_gnueabihf.rs
src/librustc_target/spec/armv7_unknown_linux_musleabihf.rs
src/librustc_target/spec/armv7_unknown_netbsd_eabihf.rs
src/librustc_target/spec/armv7r_none_eabi.rs
src/librustc_target/spec/armv7r_none_eabihf.rs
src/librustc_target/spec/armv7s_apple_ios.rs
src/librustc_target/spec/bitrig_base.rs
src/librustc_target/spec/cloudabi_base.rs
src/librustc_target/spec/dragonfly_base.rs
src/librustc_target/spec/freebsd_base.rs
src/librustc_target/spec/fuchsia_base.rs
src/librustc_target/spec/haiku_base.rs
src/librustc_target/spec/hermit_base.rs
src/librustc_target/spec/i386_apple_ios.rs
src/librustc_target/spec/i586_pc_windows_msvc.rs
src/librustc_target/spec/i586_unknown_linux_gnu.rs
src/librustc_target/spec/i586_unknown_linux_musl.rs
src/librustc_target/spec/i686_apple_darwin.rs
src/librustc_target/spec/i686_linux_android.rs
src/librustc_target/spec/i686_pc_windows_gnu.rs
src/librustc_target/spec/i686_pc_windows_msvc.rs
src/librustc_target/spec/i686_unknown_cloudabi.rs
src/librustc_target/spec/i686_unknown_dragonfly.rs
src/librustc_target/spec/i686_unknown_freebsd.rs
src/librustc_target/spec/i686_unknown_haiku.rs
src/librustc_target/spec/i686_unknown_linux_gnu.rs
src/librustc_target/spec/i686_unknown_linux_musl.rs
src/librustc_target/spec/i686_unknown_netbsd.rs
src/librustc_target/spec/i686_unknown_openbsd.rs
src/librustc_target/spec/l4re_base.rs
src/librustc_target/spec/linux_base.rs
src/librustc_target/spec/linux_musl_base.rs
src/librustc_target/spec/mips64_unknown_linux_gnuabi64.rs
src/librustc_target/spec/mips64el_unknown_linux_gnuabi64.rs
src/librustc_target/spec/mips_unknown_linux_gnu.rs
src/librustc_target/spec/mips_unknown_linux_musl.rs
src/librustc_target/spec/mips_unknown_linux_uclibc.rs
src/librustc_target/spec/mipsel_unknown_linux_gnu.rs
src/librustc_target/spec/mipsel_unknown_linux_musl.rs
src/librustc_target/spec/mipsel_unknown_linux_uclibc.rs
src/librustc_target/spec/mod.rs
src/librustc_target/spec/msp430_none_elf.rs
src/librustc_target/spec/netbsd_base.rs
src/librustc_target/spec/nvptx64_nvidia_cuda.rs
src/librustc_target/spec/openbsd_base.rs
src/librustc_target/spec/powerpc64_unknown_freebsd.rs
src/librustc_target/spec/powerpc64_unknown_linux_gnu.rs
src/librustc_target/spec/powerpc64_unknown_linux_musl.rs
src/librustc_target/spec/powerpc64le_unknown_linux_gnu.rs
src/librustc_target/spec/powerpc64le_unknown_linux_musl.rs
src/librustc_target/spec/powerpc_unknown_linux_gnu.rs
src/librustc_target/spec/powerpc_unknown_linux_gnuspe.rs
src/librustc_target/spec/powerpc_unknown_linux_musl.rs
src/librustc_target/spec/powerpc_unknown_netbsd.rs
src/librustc_target/spec/redox_base.rs
src/librustc_target/spec/riscv32imac_unknown_none_elf.rs
src/librustc_target/spec/riscv32imc_unknown_none_elf.rs
src/librustc_target/spec/riscv_base.rs
src/librustc_target/spec/s390x_unknown_linux_gnu.rs
src/librustc_target/spec/solaris_base.rs
src/librustc_target/spec/sparc64_unknown_linux_gnu.rs
src/librustc_target/spec/sparc64_unknown_netbsd.rs
src/librustc_target/spec/sparc_unknown_linux_gnu.rs
src/librustc_target/spec/sparcv9_sun_solaris.rs
src/librustc_target/spec/thumb_base.rs
src/librustc_target/spec/thumbv6m_none_eabi.rs
src/librustc_target/spec/thumbv7a_pc_windows_msvc.rs
src/librustc_target/spec/thumbv7em_none_eabi.rs
src/librustc_target/spec/thumbv7em_none_eabihf.rs
src/librustc_target/spec/thumbv7m_none_eabi.rs
src/librustc_target/spec/thumbv7neon_linux_androideabi.rs
src/librustc_target/spec/thumbv7neon_unknown_linux_gnueabihf.rs
src/librustc_target/spec/thumbv8m_base_none_eabi.rs
src/librustc_target/spec/thumbv8m_main_none_eabi.rs
src/librustc_target/spec/thumbv8m_main_none_eabihf.rs
src/librustc_target/spec/uefi_base.rs
src/librustc_target/spec/windows_base.rs
src/librustc_target/spec/windows_msvc_base.rs
src/librustc_target/spec/x86_64_apple_darwin.rs
src/librustc_target/spec/x86_64_apple_ios.rs
src/librustc_target/spec/x86_64_fuchsia.rs
src/librustc_target/spec/x86_64_linux_android.rs
src/librustc_target/spec/x86_64_pc_windows_gnu.rs
src/librustc_target/spec/x86_64_pc_windows_msvc.rs
src/librustc_target/spec/x86_64_rumprun_netbsd.rs
src/librustc_target/spec/x86_64_sun_solaris.rs
src/librustc_target/spec/x86_64_unknown_bitrig.rs
src/librustc_target/spec/x86_64_unknown_cloudabi.rs
src/librustc_target/spec/x86_64_unknown_dragonfly.rs
src/librustc_target/spec/x86_64_unknown_freebsd.rs
src/librustc_target/spec/x86_64_unknown_haiku.rs
src/librustc_target/spec/x86_64_unknown_hermit.rs
src/librustc_target/spec/x86_64_unknown_l4re_uclibc.rs
src/librustc_target/spec/x86_64_unknown_linux_gnu.rs
src/librustc_target/spec/x86_64_unknown_linux_gnux32.rs
src/librustc_target/spec/x86_64_unknown_linux_musl.rs
src/librustc_target/spec/x86_64_unknown_netbsd.rs
src/librustc_target/spec/x86_64_unknown_openbsd.rs
src/librustc_target/spec/x86_64_unknown_redox.rs
src/librustc_target/spec/x86_64_unknown_uefi.rs
src/librustc_traits/Cargo.toml
src/librustc_traits/chalk_context/mod.rs
src/librustc_traits/chalk_context/program_clauses.rs
src/librustc_traits/dropck_outlives.rs
src/librustc_traits/evaluate_obligation.rs
src/librustc_traits/implied_outlives_bounds.rs
src/librustc_traits/lib.rs
src/librustc_traits/lowering/mod.rs
src/librustc_traits/normalize_erasing_regions.rs
src/librustc_traits/normalize_projection_ty.rs
src/librustc_traits/type_op.rs
src/librustc_typeck/astconv.rs
src/librustc_typeck/check/method/probe.rs
src/librustc_typeck/check/mod.rs
src/librustc_typeck/diagnostics.rs
src/librustdoc/html/static/main.js
src/libsyntax/ast.rs
src/libsyntax/early_buffered_lints.rs
src/libsyntax/ext/build.rs
src/libsyntax/ext/tt/macro_rules.rs
src/libsyntax/feature_gate.rs
src/libsyntax/mut_visit.rs
src/libsyntax/parse/lexer/mod.rs
src/libsyntax/parse/lexer/tokentrees.rs
src/libsyntax/parse/mod.rs
src/libsyntax/parse/parser.rs
src/libsyntax/parse/token.rs
src/libsyntax/print/pprust.rs
src/libsyntax/util/parser_testing.rs
src/libsyntax/visit.rs
src/libsyntax_ext/deriving/generic/mod.rs
src/libsyntax_ext/deriving/generic/ty.rs
src/libsyntax_ext/proc_macro_server.rs
src/test/run-pass/macros/macro-follow.rs
src/test/run-pass/methods/method-probe-no-guessing-dyn-trait.rs [new file with mode: 0644]
src/test/ui/attribute-with-no-generics-in-parameter-list.rs [new file with mode: 0644]
src/test/ui/attribute-with-no-generics-in-parameter-list.stderr [new file with mode: 0644]
src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-1.rs
src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-1.stderr
src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-2.rs
src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-2.stderr
src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-3.rs
src/test/ui/attrs-with-no-formal-in-generics/attrs-with-no-formal-in-generics-3.stderr
src/test/ui/augmented-assignments.nll.stderr
src/test/ui/bad/bad-type-env-capture.rs
src/test/ui/bad/bad-type-env-capture.stderr
src/test/ui/const-generics/const-expression-parameter.rs [new file with mode: 0644]
src/test/ui/const-generics/const-expression-parameter.stderr [new file with mode: 0644]
src/test/ui/const-generics/const-fn-with-const-param.rs [new file with mode: 0644]
src/test/ui/const-generics/const-fn-with-const-param.stderr [new file with mode: 0644]
src/test/ui/const-generics/const-param-before-other-params.rs [new file with mode: 0644]
src/test/ui/const-generics/const-param-before-other-params.stderr [new file with mode: 0644]
src/test/ui/const-generics/const-param-from-outer-fn.rs [new file with mode: 0644]
src/test/ui/const-generics/const-param-from-outer-fn.stderr [new file with mode: 0644]
src/test/ui/duplicate/duplicate-type-parameter.stderr
src/test/ui/error-codes/E0401.stderr
src/test/ui/error-codes/E0403.stderr
src/test/ui/feature-gates/feature-gate-const_generics.rs [new file with mode: 0644]
src/test/ui/feature-gates/feature-gate-const_generics.stderr [new file with mode: 0644]
src/test/ui/impl-trait/bindings.rs
src/test/ui/impl-trait/bindings.stderr
src/test/ui/inner-static-type-parameter.rs
src/test/ui/inner-static-type-parameter.stderr
src/test/ui/issues/issue-12796.rs
src/test/ui/issues/issue-12796.stderr
src/test/ui/issues/issue-20616-3.rs
src/test/ui/issues/issue-20616-3.stderr
src/test/ui/issues/issue-20616-4.rs
src/test/ui/issues/issue-20616-4.stderr
src/test/ui/issues/issue-20616-5.rs
src/test/ui/issues/issue-20616-5.stderr
src/test/ui/issues/issue-20616-6.rs
src/test/ui/issues/issue-20616-6.stderr
src/test/ui/issues/issue-20616-7.rs
src/test/ui/issues/issue-20616-7.stderr
src/test/ui/issues/issue-20616-8.rs
src/test/ui/issues/issue-20616-8.stderr
src/test/ui/issues/issue-20616-9.rs
src/test/ui/issues/issue-20616-9.stderr
src/test/ui/issues/issue-27433.rs
src/test/ui/issues/issue-27433.stderr
src/test/ui/issues/issue-3021-c.rs
src/test/ui/issues/issue-3021-c.stderr
src/test/ui/issues/issue-3214.rs
src/test/ui/issues/issue-3214.stderr
src/test/ui/issues/issue-3521-2.rs
src/test/ui/issues/issue-3521-2.stderr
src/test/ui/issues/issue-3668-2.rs
src/test/ui/issues/issue-3668-2.stderr
src/test/ui/issues/issue-3668.rs
src/test/ui/issues/issue-3668.stderr
src/test/ui/issues/issue-52891.stderr
src/test/ui/issues/issue-5997-enum.rs
src/test/ui/issues/issue-5997-enum.stderr
src/test/ui/issues/issue-5997-struct.rs
src/test/ui/issues/issue-5997-struct.stderr
src/test/ui/lifetime-before-type-params.stderr
src/test/ui/macros/macro-follow.rs
src/test/ui/macros/macro-follow.stderr
src/test/ui/macros/macro-multiple-matcher-bindings.rs [new file with mode: 0644]
src/test/ui/macros/macro-multiple-matcher-bindings.stderr [new file with mode: 0644]
src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.rs [new file with mode: 0644]
src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr [new file with mode: 0644]
src/test/ui/methods/method-trait-object-with-hrtb.rs [new file with mode: 0644]
src/test/ui/nested-ty-params.rs
src/test/ui/nested-ty-params.stderr
src/test/ui/nll/issue-57960.rs [new file with mode: 0644]
src/test/ui/parser-recovery-2.stderr
src/test/ui/parser/bounds-lifetime.rs
src/test/ui/parser/bounds-lifetime.stderr
src/test/ui/parser/issue-10636-2.rs
src/test/ui/parser/issue-10636-2.stderr
src/test/ui/parser/issue-14303-enum.stderr
src/test/ui/parser/issue-14303-fn-def.stderr
src/test/ui/parser/issue-14303-fncall.rs
src/test/ui/parser/issue-14303-fncall.stderr
src/test/ui/parser/issue-14303-impl.stderr
src/test/ui/parser/issue-14303-path.rs
src/test/ui/parser/issue-14303-path.stderr
src/test/ui/parser/issue-14303-struct.stderr
src/test/ui/parser/issue-14303-trait.stderr
src/test/ui/parser/issue-32214.rs
src/test/ui/parser/issue-32214.stderr
src/test/ui/parser/macro-mismatched-delim-paren-brace.stderr
src/test/ui/parser/removed-syntax-uniq-mut-ty.rs
src/test/ui/parser/removed-syntax-uniq-mut-ty.stderr
src/test/ui/resolve/resolve-type-param-in-item-in-trait.rs
src/test/ui/resolve/resolve-type-param-in-item-in-trait.stderr
src/test/ui/resolve/token-error-correct-3.rs
src/test/ui/resolve/token-error-correct-3.stderr
src/test/ui/resolve/token-error-correct.rs
src/test/ui/resolve/token-error-correct.stderr
src/test/ui/rfc1598-generic-associated-types/empty_generics.rs
src/test/ui/rfc1598-generic-associated-types/empty_generics.stderr
src/test/ui/suggestions/suggest-move-lifetimes.stderr
src/test/ui/suggestions/suggest-move-types.rs
src/test/ui/suggestions/suggest-move-types.stderr
src/test/ui/traits/trait-object-vs-lifetime.rs
src/test/ui/traits/trait-object-vs-lifetime.stderr
src/test/ui/type/type-arg-out-of-scope.rs
src/test/ui/type/type-arg-out-of-scope.stderr
src/test/ui/type/type-dependent-def-issue-49241.rs
src/test/ui/type/type-dependent-def-issue-49241.stderr
src/test/ui/use-self-in-inner-fn.rs
src/test/ui/use-self-in-inner-fn.stderr
src/tools/compiletest/Cargo.toml
src/tools/compiletest/src/common.rs
src/tools/compiletest/src/errors.rs
src/tools/compiletest/src/header.rs
src/tools/compiletest/src/json.rs
src/tools/compiletest/src/main.rs
src/tools/compiletest/src/read2.rs
src/tools/compiletest/src/runtest.rs
src/tools/compiletest/src/util.rs
src/tools/error_index_generator/Cargo.toml
src/tools/error_index_generator/main.rs
src/tools/rustdoc/Cargo.toml
src/tools/rustdoc/main.rs

index b0d15e6a5df5fc36d898d6392b4989b08557c95f..8540d92f749179bcd976bd6d2496d9ac92d003ac 100644 (file)
@@ -1018,8 +1018,7 @@ pub fn cargo(
 
         cargo.env("RUSTC_VERBOSE", self.verbosity.to_string());
 
-        // in std, we want to avoid denying warnings for stage 0 as that makes cfg's painful.
-        if self.config.deny_warnings && !(mode == Mode::Std && stage == 0) {
+        if self.config.deny_warnings {
             cargo.env("RUSTC_DENY_WARNINGS", "1");
         }
 
index 1a46ebfcabb959211faf0136df056af0df38c14b..bb00f6f6251302c41c62283cec9da4141d4b0d70 100644 (file)
@@ -1383,6 +1383,7 @@ fn run(self, builder: &Builder) {
     RustdocBook, "src/doc/rustdoc", "rustdoc", default=true;
     RustcBook, "src/doc/rustc", "rustc", default=true;
     RustByExample, "src/doc/rust-by-example", "rust-by-example", default=false;
+    EmbeddedBook, "src/doc/embedded-book", "embedded-book", default=false;
     TheBook, "src/doc/book", "book", default=false;
     UnstableBook, "src/doc/unstable-book", "unstable-book", default=true;
 );
index 01d704f816bbc8fc00813d2636f3fe44a847db35..04c7820b45665feb9fe465f3936d086dc5b907f7 100644 (file)
@@ -2,6 +2,7 @@
 name = "build_helper"
 version = "0.1.0"
 authors = ["The Rust Project Developers"]
+edition = "2018"
 
 [lib]
 name = "build_helper"
index c66c5c9249087ba6134efaca46c03ee0a81b13bc..93aa91768121c1f6935d4bb46f40e1073cfd6ead 100644 (file)
@@ -1,3 +1,5 @@
+#![deny(rust_2018_idioms)]
+
 use std::fs::File;
 use std::path::{Path, PathBuf};
 use std::process::{Command, Stdio};
index 2759b1b1cac2769696f43075f2ab6e756318cab1..7c5a8926126e36dd3f63904aa6f9fabdc06a6170 100644 (file)
@@ -1,3 +1,5 @@
+#![cfg(not(miri))]
+
 use std::any::Any;
 use std::sync::{Arc, Weak};
 use std::cell::RefCell;
index 94ae43237d19c3309d732cecfc756f747888e6ea..c1a1c5d88781ffaa0ba7702c4307d66ab97be574 100644 (file)
@@ -282,6 +282,7 @@ fn drain<'new>(d: Drain<'static, &'static str>) -> Drain<'new, &'new str> {
 //
 // Destructors must be called exactly once per element.
 #[test]
+#[cfg(not(miri))]
 fn panic_safe() {
     static DROP_COUNTER: AtomicUsize = AtomicUsize::new(0);
 
index 4c704d0f8c28fa7106bc3364133e9c44c57471b5..653b3f5bcb49d7b62d7b57135f9c346a6da80aa6 100644 (file)
@@ -1,3 +1,5 @@
+#![cfg(not(miri))]
+
 mod map;
 mod set;
 
index 24eea1d2949657f7467f0f479b3ed011354ae6ae..809d2bc094aee7637581454f00cd79f9c35fa6c2 100644 (file)
@@ -1,3 +1,5 @@
+#![cfg(not(miri))]
+
 use std::alloc::{Global, Alloc, Layout, System};
 
 /// https://github.com/rust-lang/rust/issues/45955
index 18f82e804100823bec0e4e9c92dc55e7e444efd4..1be01d1a7ce1a1bbd279007e260df0651f85b7bf 100644 (file)
@@ -1,3 +1,5 @@
+#![cfg(not(miri))]
+
 use std::any::Any;
 use std::rc::{Rc, Weak};
 use std::cell::RefCell;
index 334466dfb25f5017ac52ce427a3510afffd3304e..2a9fdfa9324d5218f70bdb59102dcd17db627b49 100644 (file)
@@ -1,3 +1,5 @@
+#![cfg(not(miri))]
+
 use std::cell::Cell;
 use std::cmp::Ordering::{self, Equal, Greater, Less};
 use std::mem;
index 1bc1bd8d78c57eaf5ead7f6c6879d38572fb30d4..f4e6bc9ea31d5da69d44e8a46861a54d764cc889 100644 (file)
@@ -31,6 +31,7 @@ fn test_rfind() {
 }
 
 #[test]
+#[cfg(not(miri))]
 fn test_collect() {
     let empty = "";
     let s: String = empty.chars().collect();
@@ -118,6 +119,7 @@ fn test_concat_for_different_types() {
 #[test]
 fn test_concat_for_different_lengths() {
     let empty: &[&str] = &[];
+    #[cfg(not(miri))]
     test_concat!("", empty);
     test_concat!("a", ["a"]);
     test_concat!("ab", ["a", "b"]);
@@ -146,6 +148,7 @@ fn test_join_for_different_types() {
 #[test]
 fn test_join_for_different_lengths() {
     let empty: &[&str] = &[];
+    #[cfg(not(miri))]
     test_join!("", empty, "-");
     test_join!("a", ["a"], "-");
     test_join!("a-b", ["a", "b"], "-");
@@ -159,6 +162,7 @@ fn test_join_for_different_lengths_with_long_separator() {
     assert_eq!("~~~~~".len(), 15);
 
     let empty: &[&str] = &[];
+    #[cfg(not(miri))]
     test_join!("", empty, "~~~~~");
     test_join!("a", ["a"], "~~~~~");
     test_join!("a~~~~~b", ["a", "b"], "~~~~~");
@@ -166,6 +170,7 @@ fn test_join_for_different_lengths_with_long_separator() {
 }
 
 #[test]
+#[cfg(not(miri))]
 fn test_unsafe_slice() {
     assert_eq!("ab", unsafe {"abc".get_unchecked(0..2)});
     assert_eq!("bc", unsafe {"abc".get_unchecked(1..3)});
@@ -238,6 +243,7 @@ fn test_replacen() {
 #[test]
 fn test_replace() {
     let a = "a";
+    #[cfg(not(miri))]
     assert_eq!("".replace(a, "b"), "");
     assert_eq!("a".replace(a, "b"), "b");
     assert_eq!("ab".replace(a, "b"), "bb");
@@ -297,6 +303,7 @@ fn test_replace_pattern() {
 // The current implementation of SliceIndex fails to handle methods
 // orthogonally from range types; therefore, it is worth testing
 // all of the indexing operations on each input.
+#[cfg(not(miri))]
 mod slice_index {
     // Test a slicing operation **that should succeed,**
     // testing it on all of the indexing methods.
@@ -679,6 +686,7 @@ fn test_str_slice_rangetoinclusive_ok() {
 
 #[test]
 #[should_panic]
+#[cfg(not(miri))]
 fn test_str_slice_rangetoinclusive_notok() {
     let s = "abcαβγ";
     &s[..=3];
@@ -694,6 +702,7 @@ fn test_str_slicemut_rangetoinclusive_ok() {
 
 #[test]
 #[should_panic]
+#[cfg(not(miri))]
 fn test_str_slicemut_rangetoinclusive_notok() {
     let mut s = "abcαβγ".to_owned();
     let s: &mut str = &mut s;
@@ -883,6 +892,7 @@ fn test_as_bytes() {
 
 #[test]
 #[should_panic]
+#[cfg(not(miri))]
 fn test_as_bytes_fail() {
     // Don't double free. (I'm not sure if this exercises the
     // original problem code path anymore.)
@@ -972,6 +982,7 @@ fn test_split_at_mut() {
 
 #[test]
 #[should_panic]
+#[cfg(not(miri))]
 fn test_split_at_boundscheck() {
     let s = "ศไทย中华Việt Nam";
     s.split_at(1);
@@ -1066,6 +1077,7 @@ fn test_rev_iterator() {
 }
 
 #[test]
+#[cfg(not(miri))]
 fn test_chars_decoding() {
     let mut bytes = [0; 4];
     for c in (0..0x110000).filter_map(std::char::from_u32) {
@@ -1077,6 +1089,7 @@ fn test_chars_decoding() {
 }
 
 #[test]
+#[cfg(not(miri))]
 fn test_chars_rev_decoding() {
     let mut bytes = [0; 4];
     for c in (0..0x110000).filter_map(std::char::from_u32) {
@@ -1306,6 +1319,7 @@ fn t(s: &str, sep: &str, u: &[&str]) {
 }
 
 #[test]
+#[cfg(not(miri))]
 fn test_str_default() {
     use std::default::Default;
 
@@ -1365,6 +1379,7 @@ fn test_bool_from_str() {
     assert_eq!("not even a boolean".parse::<bool>().ok(), None);
 }
 
+#[cfg(not(miri))]
 fn check_contains_all_substrings(s: &str) {
     assert!(s.contains(""));
     for i in 0..s.len() {
@@ -1375,6 +1390,7 @@ fn check_contains_all_substrings(s: &str) {
 }
 
 #[test]
+#[cfg(not(miri))]
 fn strslice_issue_16589() {
     assert!("bananas".contains("nana"));
 
@@ -1384,6 +1400,7 @@ fn strslice_issue_16589() {
 }
 
 #[test]
+#[cfg(not(miri))]
 fn strslice_issue_16878() {
     assert!(!"1234567ah012345678901ah".contains("hah"));
     assert!(!"00abc01234567890123456789abc".contains("bcabc"));
@@ -1391,6 +1408,7 @@ fn strslice_issue_16878() {
 
 
 #[test]
+#[cfg(not(miri))]
 fn test_strslice_contains() {
     let x = "There are moments, Jeeves, when one asks oneself, 'Do trousers matter?'";
     check_contains_all_substrings(x);
@@ -1528,6 +1546,7 @@ fn trim_ws() {
 
 #[test]
 fn to_lowercase() {
+    #[cfg(not(miri))]
     assert_eq!("".to_lowercase(), "");
     assert_eq!("AÉDžaé ".to_lowercase(), "aédžaé ");
 
@@ -1561,6 +1580,7 @@ fn to_lowercase() {
 
 #[test]
 fn to_uppercase() {
+    #[cfg(not(miri))]
     assert_eq!("".to_uppercase(), "");
     assert_eq!("aéDžßfiᾀ".to_uppercase(), "AÉDŽSSFIἈΙ");
 }
@@ -1592,6 +1612,7 @@ fn test_cow_from() {
 }
 
 #[test]
+#[cfg(not(miri))]
 fn test_repeat() {
     assert_eq!("".repeat(3), "");
     assert_eq!("abc".repeat(0), "");
index e5ce51a36ee2286bc33aa1da49ca8fa05d981127..e6ca54c4088653b9420fe7e055f2c0c05d4003b2 100644 (file)
@@ -1,3 +1,5 @@
+#![cfg(not(miri))]
+
 use std::borrow::Cow;
 use std::collections::CollectionAllocErr::*;
 use std::mem::size_of;
index 89f2e0a046d91ae0a05e294784162b6c49384a53..545332bcd6a2f3985c5243bcb08b7f3417e7ce7f 100644 (file)
@@ -1,3 +1,5 @@
+#![cfg(not(miri))]
+
 use std::borrow::Cow;
 use std::mem::size_of;
 use std::{usize, isize};
index aa49bdb009086e9e7738dbfa977aec5e271ce21d..b47e7c867e675441de41e2bccb9a567e8be8b149 100644 (file)
@@ -108,6 +108,7 @@ fn test_index() {
 
 #[test]
 #[should_panic]
+#[cfg(not(miri))]
 fn test_index_out_of_bounds() {
     let mut deq = VecDeque::new();
     for i in 1..4 {
@@ -906,20 +907,24 @@ fn test_append() {
     // normal append
     a.append(&mut b);
     assert_eq!(a.iter().cloned().collect::<Vec<_>>(), [1, 2, 3, 4, 5, 6]);
+    #[cfg(not(miri))]
     assert_eq!(b.iter().cloned().collect::<Vec<_>>(), []);
 
     // append nothing to something
     a.append(&mut b);
     assert_eq!(a.iter().cloned().collect::<Vec<_>>(), [1, 2, 3, 4, 5, 6]);
+    #[cfg(not(miri))]
     assert_eq!(b.iter().cloned().collect::<Vec<_>>(), []);
 
     // append something to nothing
     b.append(&mut a);
     assert_eq!(b.iter().cloned().collect::<Vec<_>>(), [1, 2, 3, 4, 5, 6]);
+    #[cfg(not(miri))]
     assert_eq!(a.iter().cloned().collect::<Vec<_>>(), []);
 }
 
 #[test]
+#[cfg(not(miri))]
 fn test_append_permutations() {
     fn construct_vec_deque(
         push_back: usize,
@@ -1120,6 +1125,7 @@ fn test_reserve_exact_2() {
 }
 
 #[test]
+#[cfg(not(miri))]
 fn test_try_reserve() {
 
     // These are the interesting cases:
@@ -1221,6 +1227,7 @@ fn test_try_reserve() {
 }
 
 #[test]
+#[cfg(not(miri))]
 fn test_try_reserve_exact() {
 
     // This is exactly the same as test_try_reserve with the method changed.
index 56f295dff8e430c1818aeb7a16f3cd2213decf50..73bdaab5861e6bb3f62a7309f0f9360c0bf696b8 100644 (file)
@@ -1,3 +1,5 @@
+#![cfg(not(miri))]
+
 use core::cell::*;
 use core::default::Default;
 use std::mem::drop;
index d86e21cf40b6e7e36da4238066adf742cd887d58..b10b63fc484cb820985485f35cb9201c64503d0b 100644 (file)
@@ -1,3 +1,5 @@
+#![cfg(not(miri))]
+
 mod builders;
 mod float;
 mod num;
index 135f4dfcac7d55563a4579dfdcec0ad6aa7c22a7..bf3039a7e51e8c33c9c503ae48ebfc495fd3d2a0 100644 (file)
@@ -1,3 +1,5 @@
+#![cfg(not(miri))]
+
 mod sip;
 
 use std::hash::{Hash, Hasher};
index 0fa99745d9065ab75c860690203f22c00165378c..9b4c78f8d3b024c5c2d78fff3e7e818e909f029a 100644 (file)
@@ -190,6 +190,7 @@ fn test_iterator_step_by() {
 }
 
 #[test]
+#[cfg(not(miri))]
 fn test_iterator_step_by_nth() {
     let mut it = (0..16).step_by(5);
     assert_eq!(it.nth(0), Some(0));
@@ -208,6 +209,7 @@ fn test_iterator_step_by_nth() {
 }
 
 #[test]
+#[cfg(not(miri))]
 fn test_iterator_step_by_nth_overflow() {
     #[cfg(target_pointer_width = "8")]
     type Bigger = u16;
@@ -253,12 +255,14 @@ fn nth(&mut self, n: usize) -> Option<Self::Item> {
 
 #[test]
 #[should_panic]
+#[cfg(not(miri))]
 fn test_iterator_step_by_zero() {
     let mut it = (0..).step_by(0);
     it.next();
 }
 
 #[test]
+#[cfg(not(miri))]
 fn test_iterator_step_by_size_hint() {
     struct StubSizeHint(usize, Option<usize>);
     impl Iterator for StubSizeHint {
@@ -1413,6 +1417,7 @@ fn test_rposition() {
 
 #[test]
 #[should_panic]
+#[cfg(not(miri))]
 fn test_rposition_panic() {
     let v: [(Box<_>, Box<_>); 4] =
         [(box 0, box 0), (box 0, box 0),
@@ -1652,6 +1657,7 @@ fn test_range_inclusive_nth() {
 }
 
 #[test]
+#[cfg(not(miri))]
 fn test_range_step() {
     #![allow(deprecated)]
 
@@ -1675,6 +1681,7 @@ fn test_range_step() {
 }
 
 #[test]
+#[cfg(not(miri))]
 fn test_step_by_skip() {
     assert_eq!((0..640).step_by(128).skip(1).collect::<Vec<_>>(), [128, 256, 384, 512]);
     assert_eq!((0..=50).step_by(10).nth(3), Some(30));
@@ -1682,6 +1689,7 @@ fn test_step_by_skip() {
 }
 
 #[test]
+#[cfg(not(miri))]
 fn test_range_inclusive_step() {
     assert_eq!((0..=50).step_by(10).collect::<Vec<_>>(), [0, 10, 20, 30, 40, 50]);
     assert_eq!((0..=5).step_by(1).collect::<Vec<_>>(), [0, 1, 2, 3, 4, 5]);
index a17c094679ea854623356691df94479bdb17670e..ab638e06cc10dbcfc31d65d5c3ed9b4426234763 100644 (file)
@@ -1,3 +1,5 @@
+#![cfg(not(miri))]
+
 use core::convert::{TryFrom, TryInto};
 use core::cmp::PartialEq;
 use core::fmt::Debug;
index b059b134868d999fae75fe4e75eba3c2ea03a3a7..1ba886ce037ee0eaf426c42e6b2b2241abade460 100644 (file)
@@ -69,6 +69,7 @@ fn test_option_dance() {
 }
 
 #[test] #[should_panic]
+#[cfg(not(miri))]
 fn test_option_too_much_dance() {
     struct A;
     let mut y = Some(A);
@@ -129,6 +130,7 @@ fn test_unwrap() {
 
 #[test]
 #[should_panic]
+#[cfg(not(miri))]
 fn test_unwrap_panic1() {
     let x: Option<isize> = None;
     x.unwrap();
@@ -136,6 +138,7 @@ fn test_unwrap_panic1() {
 
 #[test]
 #[should_panic]
+#[cfg(not(miri))]
 fn test_unwrap_panic2() {
     let x: Option<String> = None;
     x.unwrap();
index 65c1a3e0254d243e896e2da51667f5b10785a548..5784559082266336e030a0050ac452cd0881ffe0 100644 (file)
@@ -1,3 +1,5 @@
+#![cfg(not(miri))]
+
 use core::ptr::*;
 use core::cell::RefCell;
 
index 1fab07526a07f7f3954a1faa84b802cb4751e795..7bfd396f68d1700212979c8f6d2c9a217527d99b 100644 (file)
@@ -117,6 +117,7 @@ fn handler(msg: &'static str) -> isize {
 
 #[test]
 #[should_panic]
+#[cfg(not(miri))]
 pub fn test_unwrap_or_else_panic() {
     fn handler(msg: &'static str) -> isize {
         if msg == "I got this." {
@@ -138,6 +139,7 @@ pub fn test_expect_ok() {
 }
 #[test]
 #[should_panic(expected="Got expected error: \"All good\"")]
+#[cfg(not(miri))]
 pub fn test_expect_err() {
     let err: Result<isize, &'static str> = Err("All good");
     err.expect("Got expected error");
@@ -151,6 +153,7 @@ pub fn test_expect_err_err() {
 }
 #[test]
 #[should_panic(expected="Got expected ok: \"All good\"")]
+#[cfg(not(miri))]
 pub fn test_expect_err_ok() {
     let err: Result<&'static str, isize> = Ok("All good");
     err.expect_err("Got expected ok");
index e210e83122c47537e6a09e9459bc14526e1ebbed..04d646ea01d038842c2709ce328d633a17fd1f9f 100644 (file)
@@ -782,6 +782,7 @@ macro_rules! assert_range_eq {
     //  to be used in `should_panic`)
     #[test]
     #[should_panic(expected = "out of range")]
+    #[cfg(not(miri))]
     fn assert_range_eq_can_fail_by_panic() {
         assert_range_eq!([0, 1, 2], 0..5, [0, 1, 2]);
     }
@@ -791,6 +792,7 @@ fn assert_range_eq_can_fail_by_panic() {
     //  to be used in `should_panic`)
     #[test]
     #[should_panic(expected = "==")]
+    #[cfg(not(miri))]
     fn assert_range_eq_can_fail_by_inequality() {
         assert_range_eq!([0, 1, 2], 0..2, [0, 1, 2]);
     }
@@ -840,6 +842,7 @@ fn pass() {
 
                 #[test]
                 #[should_panic(expected = $expect_msg)]
+                #[cfg(not(miri))]
                 fn index_fail() {
                     let v = $data;
                     let v: &[_] = &v;
@@ -848,6 +851,7 @@ fn index_fail() {
 
                 #[test]
                 #[should_panic(expected = $expect_msg)]
+                #[cfg(not(miri))]
                 fn index_mut_fail() {
                     let mut v = $data;
                     let v: &mut [_] = &mut v;
@@ -1011,6 +1015,7 @@ fn test_rotate_right() {
 
 #[test]
 #[cfg(not(target_arch = "wasm32"))]
+#[cfg(not(miri))]
 fn sort_unstable() {
     use core::cmp::Ordering::{Equal, Greater, Less};
     use core::slice::heapsort;
@@ -1166,6 +1171,7 @@ fn each_alignment_reversed() {
 }
 
 #[test]
+#[cfg(not(miri))]
 fn test_align_to_simple() {
     let bytes = [1u8, 2, 3, 4, 5, 6, 7];
     let (prefix, aligned, suffix) = unsafe { bytes.align_to::<u16>() };
@@ -1181,6 +1187,7 @@ fn test_align_to_simple() {
 }
 
 #[test]
+#[cfg(not(miri))]
 fn test_align_to_zst() {
     let bytes = [1, 2, 3, 4, 5, 6, 7];
     let (prefix, aligned, suffix) = unsafe { bytes.align_to::<()>() };
@@ -1189,6 +1196,7 @@ fn test_align_to_zst() {
 }
 
 #[test]
+#[cfg(not(miri))]
 fn test_align_to_non_trivial() {
     #[repr(align(8))] struct U64(u64, u64);
     #[repr(align(8))] struct U64U64U32(u64, u64, u32);
@@ -1200,6 +1208,7 @@ fn test_align_to_non_trivial() {
 }
 
 #[test]
+#[cfg(not(miri))]
 fn test_align_to_empty_mid() {
     use core::mem;
 
@@ -1297,6 +1306,7 @@ fn test_copy_within() {
 
 #[test]
 #[should_panic(expected = "src is out of bounds")]
+#[cfg(not(miri))]
 fn test_copy_within_panics_src_too_long() {
     let mut bytes = *b"Hello, World!";
     // The length is only 13, so 14 is out of bounds.
@@ -1305,6 +1315,7 @@ fn test_copy_within_panics_src_too_long() {
 
 #[test]
 #[should_panic(expected = "dest is out of bounds")]
+#[cfg(not(miri))]
 fn test_copy_within_panics_dest_too_long() {
     let mut bytes = *b"Hello, World!";
     // The length is only 13, so a slice of length 4 starting at index 10 is out of bounds.
@@ -1312,6 +1323,7 @@ fn test_copy_within_panics_dest_too_long() {
 }
 #[test]
 #[should_panic(expected = "src end is before src start")]
+#[cfg(not(miri))]
 fn test_copy_within_panics_src_inverted() {
     let mut bytes = *b"Hello, World!";
     // 2 is greater than 1, so this range is invalid.
index 6efd22572dc185d57fe9b06062cfccd93754e48a..d39bd06930a36a83eb715a47733384ee5a993d82 100644 (file)
@@ -1,3 +1,5 @@
+#![cfg(not(miri))]
+
 use core::time::Duration;
 
 #[test]
index 6566c6041b6e5ebd964c752ab4fe4b35e7413262..15efa7650293c52b2f09cd94b56c93fdc42a261e 100644 (file)
@@ -52,6 +52,7 @@ pub enum Def {
     AssociatedExistential(DefId),
     PrimTy(hir::PrimTy),
     TyParam(DefId),
+    ConstParam(DefId),
     SelfTy(Option<DefId> /* trait */, Option<DefId> /* impl */),
     ToolMod, // e.g., `rustfmt` in `#[rustfmt::skip]`
 
@@ -265,7 +266,8 @@ pub fn opt_def_id(&self) -> Option<DefId> {
             Def::Fn(id) | Def::Mod(id) | Def::Static(id, _) |
             Def::Variant(id) | Def::VariantCtor(id, ..) | Def::Enum(id) |
             Def::TyAlias(id) | Def::TraitAlias(id) |
-            Def::AssociatedTy(id) | Def::TyParam(id) | Def::Struct(id) | Def::StructCtor(id, ..) |
+            Def::AssociatedTy(id) | Def::TyParam(id) | Def::ConstParam(id) | Def::Struct(id) |
+            Def::StructCtor(id, ..) |
             Def::Union(id) | Def::Trait(id) | Def::Method(id) | Def::Const(id) |
             Def::AssociatedConst(id) | Def::Macro(id, ..) |
             Def::Existential(id) | Def::AssociatedExistential(id) | Def::ForeignTy(id) => {
@@ -322,6 +324,7 @@ pub fn kind_name(&self) -> &'static str {
             Def::Const(..) => "constant",
             Def::AssociatedConst(..) => "associated constant",
             Def::TyParam(..) => "type parameter",
+            Def::ConstParam(..) => "const parameter",
             Def::PrimTy(..) => "builtin type",
             Def::Local(..) => "local variable",
             Def::Upvar(..) => "closure capture",
index d0fd5bd6844b02b9ab5f02c4fcafc1dce589992d..3de41b1665d6dd08299725a2e04f51498cbefddf 100644 (file)
@@ -1157,6 +1157,15 @@ fn lower_generic_arg(&mut self,
         match arg {
             ast::GenericArg::Lifetime(lt) => GenericArg::Lifetime(self.lower_lifetime(&lt)),
             ast::GenericArg::Type(ty) => GenericArg::Type(self.lower_ty_direct(&ty, itctx)),
+            ast::GenericArg::Const(ct) => {
+                // FIXME(const_generics): const generics are not yet defined in the HIR.
+                self.sess.struct_span_err(
+                    ct.value.span,
+                    "const generics in any position are currently unsupported",
+                ).emit();
+                self.sess.abort_if_errors();
+                bug!();
+            }
         }
     }
 
@@ -2441,7 +2450,7 @@ fn lower_generic_param(&mut self,
             |this| this.lower_param_bounds(&param.bounds, itctx.reborrow()),
         );
 
-        match param.kind {
+        let (name, kind) = match param.kind {
             GenericParamKind::Lifetime => {
                 let was_collecting_in_band = self.is_collecting_in_band_lifetimes;
                 self.is_collecting_in_band_lifetimes = false;
@@ -2457,22 +2466,14 @@ fn lower_generic_param(&mut self,
                         | hir::LifetimeName::Static => hir::ParamName::Plain(lt.name.ident()),
                     hir::LifetimeName::Error => ParamName::Error,
                 };
-                let param = hir::GenericParam {
-                    id: lt.id,
-                    hir_id: lt.hir_id,
-                    name: param_name,
-                    span: lt.span,
-                    pure_wrt_drop: attr::contains_name(&param.attrs, "may_dangle"),
-                    attrs: self.lower_attrs(&param.attrs),
-                    bounds,
-                    kind: hir::GenericParamKind::Lifetime {
-                        kind: hir::LifetimeParamKind::Explicit,
-                    }
+
+                let kind = hir::GenericParamKind::Lifetime {
+                    kind: hir::LifetimeParamKind::Explicit
                 };
 
                 self.is_collecting_in_band_lifetimes = was_collecting_in_band;
 
-                param
+                (param_name, kind)
             }
             GenericParamKind::Type { ref default, .. } => {
                 // Don't expose `Self` (recovered "keyword used as ident" parse error).
@@ -2491,27 +2492,41 @@ fn lower_generic_param(&mut self,
                                    .chain(params)
                                    .collect();
                 }
-                let LoweredNodeId { node_id, hir_id } = self.lower_node_id(param.id);
 
-                hir::GenericParam {
-                    id: node_id,
-                    hir_id,
-                    name: hir::ParamName::Plain(ident),
-                    pure_wrt_drop: attr::contains_name(&param.attrs, "may_dangle"),
-                    attrs: self.lower_attrs(&param.attrs),
-                    bounds,
-                    span: ident.span,
-                    kind: hir::GenericParamKind::Type {
-                        default: default.as_ref().map(|x| {
-                            self.lower_ty(x, ImplTraitContext::disallowed())
-                        }),
-                        synthetic: param.attrs.iter()
-                                              .filter(|attr| attr.check_name("rustc_synthetic"))
-                                              .map(|_| hir::SyntheticTyParamKind::ImplTrait)
-                                              .next(),
-                    }
-                }
+                let kind = hir::GenericParamKind::Type {
+                    default: default.as_ref().map(|x| {
+                        self.lower_ty(x, ImplTraitContext::disallowed())
+                    }),
+                    synthetic: param.attrs.iter()
+                                          .filter(|attr| attr.check_name("rustc_synthetic"))
+                                          .map(|_| hir::SyntheticTyParamKind::ImplTrait)
+                                          .next(),
+                };
+
+                (hir::ParamName::Plain(ident), kind)
             }
+            GenericParamKind::Const { .. } => {
+                // FIXME(const_generics): const generics are not yet defined in the HIR.
+                self.sess.struct_span_err(
+                    param.ident.span,
+                    "const generics in any position are currently unsupported",
+                ).emit();
+                self.sess.abort_if_errors();
+                bug!();
+            }
+        };
+
+        let LoweredNodeId { node_id, hir_id } = self.lower_node_id(param.id);
+
+        hir::GenericParam {
+            id: node_id,
+            hir_id,
+            name,
+            span: param.ident.span,
+            pure_wrt_drop: attr::contains_name(&param.attrs, "may_dangle"),
+            attrs: self.lower_attrs(&param.attrs),
+            bounds,
+            kind,
         }
     }
 
index 710170674f7611fdac5ada1d962f53c209d7783c..02fb503e752b582ab3ef6d4f6c8df24b46999bec 100644 (file)
@@ -218,6 +218,7 @@ fn visit_generic_param(&mut self, param: &'a GenericParam) {
         let def_path_data = match param.kind {
             GenericParamKind::Lifetime { .. } => DefPathData::LifetimeParam(name),
             GenericParamKind::Type { .. } => DefPathData::TypeParam(name),
+            GenericParamKind::Const { .. } => DefPathData::ConstParam(name),
         };
         self.create_def(param.id, def_path_data, REGULAR_SPACE, param.ident.span);
 
index a8193e1d34837ec08ba29435a9800908c82e8da2..84e9cde6df16012a3867cc9bb1f7bc3dd14d1d1d 100644 (file)
@@ -356,10 +356,12 @@ pub enum DefPathData {
     /// A closure expression
     ClosureExpr,
     // Subportions of items
-    /// A type parameter (generic parameter)
+    /// A type (generic) parameter
     TypeParam(InternedString),
-    /// A lifetime definition
+    /// A lifetime (generic) parameter
     LifetimeParam(InternedString),
+    /// A const (generic) parameter
+    ConstParam(InternedString),
     /// A variant of a enum
     EnumVariant(InternedString),
     /// A struct field
@@ -641,6 +643,7 @@ pub fn get_opt_name(&self) -> Option<InternedString> {
             MacroDef(name) |
             TypeParam(name) |
             LifetimeParam(name) |
+            ConstParam(name) |
             EnumVariant(name) |
             Field(name) |
             GlobalMetaData(name) => Some(name),
@@ -669,6 +672,7 @@ pub fn as_interned_str(&self) -> InternedString {
             MacroDef(name) |
             TypeParam(name) |
             LifetimeParam(name) |
+            ConstParam(name) |
             EnumVariant(name) |
             Field(name) |
             GlobalMetaData(name) => {
index 2b359428b1fa169df978d561481e86a7a52732aa..712fd360fbb6fffd31e423b2ad96f18387a6de9a 100644 (file)
@@ -1046,6 +1046,7 @@ fn to_stable_hash_key(&self,
     AssociatedExistential(def_id),
     PrimTy(prim_ty),
     TyParam(def_id),
+    ConstParam(def_id),
     SelfTy(trait_def_id, impl_def_id),
     ForeignTy(def_id),
     Fn(def_id),
index 6ae7448645a20d5d0f42006f79d3f22229674369..3ff76e98d7b89266e3d6780d76312517d9cc6cfe 100644 (file)
     "outlives requirements can be inferred"
 }
 
+declare_lint! {
+    pub DUPLICATE_MATCHER_BINDING_NAME,
+    Warn,
+    "duplicate macro matcher binding name"
+}
+
 /// Some lints that are buffered from `libsyntax`. See `syntax::early_buffered_lints`.
 pub mod parser {
     declare_lint! {
index 4e6bf753b01aa4af75889d07746be18842f2ab74..8952ae98e597e7a7d000c0c45e85a4e86110be6f 100644 (file)
@@ -27,7 +27,7 @@
 use crate::hir::def_id::{CrateNum, LOCAL_CRATE};
 use crate::hir::intravisit;
 use crate::hir;
-use crate::lint::builtin::BuiltinLintDiagnostics;
+use crate::lint::builtin::{BuiltinLintDiagnostics, DUPLICATE_MATCHER_BINDING_NAME};
 use crate::lint::builtin::parser::{QUESTION_MARK_MACRO_SEP, ILL_FORMED_ATTRIBUTE_INPUT};
 use crate::session::{Session, DiagnosticMessageId};
 use std::{hash, ptr};
@@ -82,6 +82,7 @@ pub fn from_parser_lint_id(lint_id: BufferedEarlyLintId) -> &'static Self {
         match lint_id {
             BufferedEarlyLintId::QuestionMarkMacroSep => QUESTION_MARK_MACRO_SEP,
             BufferedEarlyLintId::IllFormedAttributeInput => ILL_FORMED_ATTRIBUTE_INPUT,
+            BufferedEarlyLintId::DuplicateMacroMatcherBindingName => DUPLICATE_MATCHER_BINDING_NAME,
         }
     }
 
index 009997bfcf2c48d038518fe8e99144a26e765aa4..a0f16ae27156c58ef7567824d0db748511b21dc4 100644 (file)
@@ -2154,7 +2154,7 @@ pub fn function_handle<'a>(
             span,
             ty,
             user_ty: None,
-            literal: tcx.intern_lazy_const(
+            literal: tcx.mk_lazy_const(
                 ty::LazyConst::Evaluated(ty::Const::zero_sized(ty)),
             ),
         })
index 99107a1a6d4e1e3944421d568cdd8ede788bbafd..562a29f53f8cc96c0e594e2fe55f25ffbb392de2 100644 (file)
@@ -408,7 +408,7 @@ fn fold_const(&mut self, constant: &'tcx ty::LazyConst<'tcx>) -> &'tcx ty::LazyC
                         if let Ok(evaluated) = tcx.const_eval(param_env.and(cid)) {
                             let substs = tcx.lift_to_global(&substs).unwrap();
                             let evaluated = evaluated.subst(tcx, substs);
-                            return tcx.intern_lazy_const(ty::LazyConst::Evaluated(evaluated));
+                            return tcx.mk_lazy_const(ty::LazyConst::Evaluated(evaluated));
                         }
                     }
                 } else {
@@ -420,7 +420,7 @@ fn fold_const(&mut self, constant: &'tcx ty::LazyConst<'tcx>) -> &'tcx ty::LazyC
                                 promoted: None
                             };
                             if let Ok(evaluated) = tcx.const_eval(param_env.and(cid)) {
-                                return tcx.intern_lazy_const(ty::LazyConst::Evaluated(evaluated));
+                                return tcx.mk_lazy_const(ty::LazyConst::Evaluated(evaluated));
                             }
                         }
                     }
index f477f161bbb323f760edf08e3c1d63da023bb1f8..bcd11194b5730fb4a5423d1bb0cae694b25d9a5d 100644 (file)
@@ -203,7 +203,7 @@ fn fold_const(&mut self, constant: &'tcx ty::LazyConst<'tcx>) -> &'tcx ty::LazyC
                         if let Ok(evaluated) = tcx.const_eval(param_env.and(cid)) {
                             let substs = tcx.lift_to_global(&substs).unwrap();
                             let evaluated = evaluated.subst(tcx, substs);
-                            return tcx.intern_lazy_const(ty::LazyConst::Evaluated(evaluated));
+                            return tcx.mk_lazy_const(ty::LazyConst::Evaluated(evaluated));
                         }
                     }
                 } else {
@@ -215,7 +215,7 @@ fn fold_const(&mut self, constant: &'tcx ty::LazyConst<'tcx>) -> &'tcx ty::LazyC
                                 promoted: None,
                             };
                             if let Ok(evaluated) = tcx.const_eval(param_env.and(cid)) {
-                                return tcx.intern_lazy_const(ty::LazyConst::Evaluated(evaluated));
+                                return tcx.mk_lazy_const(ty::LazyConst::Evaluated(evaluated));
                             }
                         }
                     }
index c9775b102931538b1d56d7ab1749b08c008efee6..e93de32f7257b06168107c3f765d2c68d1b940af 100644 (file)
@@ -252,7 +252,7 @@ pub fn decode_lazy_const<'a, 'tcx, D>(decoder: &mut D)
     where D: TyDecoder<'a, 'tcx>,
           'tcx: 'a,
 {
-    Ok(decoder.tcx().intern_lazy_const(Decodable::decode(decoder)?))
+    Ok(decoder.tcx().mk_lazy_const(Decodable::decode(decoder)?))
 }
 
 #[inline]
index 795853a37c7583d1d44b2f6a6f4bab2b8752816e..11211c91c547928cf372a1c0389f3435b5347642 100644 (file)
@@ -127,6 +127,7 @@ pub struct CtxtInterners<'tcx> {
     goal: InternedSet<'tcx, GoalKind<'tcx>>,
     goal_list: InternedSet<'tcx, List<Goal<'tcx>>>,
     projs: InternedSet<'tcx, List<ProjectionKind<'tcx>>>,
+    lazy_const: InternedSet<'tcx, LazyConst<'tcx>>,
 }
 
 impl<'gcx: 'tcx, 'tcx> CtxtInterners<'tcx> {
@@ -144,6 +145,7 @@ fn new(arena: &'tcx SyncDroplessArena) -> CtxtInterners<'tcx> {
             goal: Default::default(),
             goal_list: Default::default(),
             projs: Default::default(),
+            lazy_const: Default::default(),
         }
     }
 
@@ -1096,10 +1098,7 @@ pub fn alloc_adt_def(self,
         self.global_arenas.adt_def.alloc(def)
     }
 
-    pub fn intern_const_alloc(
-        self,
-        alloc: Allocation,
-    ) -> &'gcx Allocation {
+    pub fn intern_const_alloc(self, alloc: Allocation) -> &'gcx Allocation {
         self.allocation_interner.borrow_mut().intern(alloc, |alloc| {
             self.global_arenas.const_allocs.alloc(alloc)
         })
@@ -1119,10 +1118,6 @@ pub fn intern_stability(self, stab: attr::Stability) -> &'gcx attr::Stability {
         })
     }
 
-    pub fn intern_lazy_const(self, c: ty::LazyConst<'tcx>) -> &'tcx ty::LazyConst<'tcx> {
-        self.global_interners.arena.alloc(c)
-    }
-
     pub fn intern_layout(self, layout: LayoutDetails) -> &'gcx LayoutDetails {
         self.layout_interner.borrow_mut().intern(layout, |layout| {
             self.global_arenas.layout.alloc(layout)
@@ -2272,6 +2267,12 @@ fn borrow<'a>(&'a self) -> &'a GoalKind<'lcx> {
     }
 }
 
+impl<'tcx: 'lcx, 'lcx> Borrow<LazyConst<'lcx>> for Interned<'tcx, LazyConst<'tcx>> {
+    fn borrow<'a>(&'a self) -> &'a LazyConst<'lcx> {
+        &self.0
+    }
+}
+
 impl<'tcx: 'lcx, 'lcx> Borrow<[ExistentialPredicate<'lcx>]>
     for Interned<'tcx, List<ExistentialPredicate<'tcx>>> {
     fn borrow<'a>(&'a self) -> &'a [ExistentialPredicate<'lcx>] {
@@ -2378,7 +2379,8 @@ pub fn keep_local<'tcx, T: ty::TypeFoldable<'tcx>>(x: &T) -> bool {
 
 direct_interners!('tcx,
     region: mk_region(|r: &RegionKind| r.keep_in_local_tcx()) -> RegionKind,
-    goal: mk_goal(|c: &GoalKind<'_>| keep_local(c)) -> GoalKind<'tcx>
+    goal: mk_goal(|c: &GoalKind<'_>| keep_local(c)) -> GoalKind<'tcx>,
+    lazy_const: mk_lazy_const(|c: &LazyConst<'_>| keep_local(&c)) -> LazyConst<'tcx>
 );
 
 macro_rules! slice_interners {
@@ -2563,7 +2565,7 @@ pub fn mk_nil_ptr(self) -> Ty<'tcx> {
 
     #[inline]
     pub fn mk_array(self, ty: Ty<'tcx>, n: u64) -> Ty<'tcx> {
-        self.mk_ty(Array(ty, self.intern_lazy_const(
+        self.mk_ty(Array(ty, self.mk_lazy_const(
             ty::LazyConst::Evaluated(ty::Const::from_usize(self.global_tcx(), n))
         )))
     }
index f89e50d696945bda60e8c7c2cae0d7350de2ccb8..8214c8bacc70408aae36a6df6023fcd7321d1658 100644 (file)
@@ -325,6 +325,7 @@ pub fn push_item_path<T>(self, buffer: &mut T, def_id: DefId, pushed_prelude_cra
             data @ DefPathData::Module(..) |
             data @ DefPathData::TypeParam(..) |
             data @ DefPathData::LifetimeParam(..) |
+            data @ DefPathData::ConstParam(..) |
             data @ DefPathData::EnumVariant(..) |
             data @ DefPathData::Field(..) |
             data @ DefPathData::AnonConst |
index 62a49238ebf3d71f0b2504a7a3e6ce1aeff2fa89..d09cfa84a1690cd9d40d9f1e771c862f85e53430 100644 (file)
@@ -1042,7 +1042,7 @@ fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F)
                 ty::LazyConst::Unevaluated(*def_id, substs.fold_with(folder))
             }
         };
-        folder.tcx().intern_lazy_const(new)
+        folder.tcx().mk_lazy_const(new)
     }
 
     fn fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self {
index 2cd82d44af3aa863ac7793277e8516a88f07af66..a12ec3471a91c7b84f48e1bcf515d39dfc535bc5 100644 (file)
@@ -426,6 +426,7 @@ fn parameterized<F: fmt::Write>(&mut self,
                     DefPathData::ClosureExpr |
                     DefPathData::TypeParam(_) |
                     DefPathData::LifetimeParam(_) |
+                    DefPathData::ConstParam(_) |
                     DefPathData::Field(_) |
                     DefPathData::StructCtor |
                     DefPathData::AnonConst |
index 03d33f413c807e92aee7eb7aeea69d4f0dd1f1c5..cf6c598bfb17b756b89f1119cfffe8a818e68a7f 100644 (file)
@@ -2,6 +2,7 @@
 authors = ["The Rust Project Developers"]
 name = "rustc_allocator"
 version = "0.0.0"
+edition = "2018"
 
 [lib]
 path = "lib.rs"
index 1fb1794d5147d5a49ca119ceac6416823b2b1506..d302e7646d16852ca354d3a62781387ba56681a6 100644 (file)
@@ -1,6 +1,6 @@
+use log::debug;
 use rustc::middle::allocator::AllocatorKind;
-use rustc_errors;
-use smallvec::SmallVec;
+use smallvec::{smallvec, SmallVec};
 use syntax::{
     ast::{
         self, Arg, Attribute, Crate, Expr, FnHeader, Generics, Ident, Item, ItemKind,
@@ -23,7 +23,7 @@
 };
 use syntax_pos::Span;
 
-use {AllocatorMethod, AllocatorTy, ALLOCATOR_METHODS};
+use crate::{AllocatorMethod, AllocatorTy, ALLOCATOR_METHODS};
 
 pub fn modify(
     sess: &ParseSess,
@@ -54,7 +54,7 @@ struct ExpandAllocatorDirectives<'a> {
     in_submod: isize,
 }
 
-impl<'a> MutVisitor for ExpandAllocatorDirectives<'a> {
+impl MutVisitor for ExpandAllocatorDirectives<'_> {
     fn flat_map_item(&mut self, item: P<Item>) -> SmallVec<[P<Item>; 1]> {
         debug!("in submodule {}", self.in_submod);
 
@@ -168,7 +168,7 @@ struct AllocFnFactory<'a> {
     cx: ExtCtxt<'a>,
 }
 
-impl<'a> AllocFnFactory<'a> {
+impl AllocFnFactory<'_> {
     fn allocator_fn(&self, method: &AllocatorMethod) -> P<Item> {
         let mut abi_args = Vec::new();
         let mut i = 0;
index 41c0be615956e83c6114b02eb18c8235160d5d8f..16b9ccfda80107aa09af0258c86dcfdb73ca47a7 100644 (file)
@@ -1,15 +1,6 @@
-#![feature(nll)]
 #![feature(rustc_private)]
 
-#[macro_use] extern crate log;
-extern crate rustc;
-extern crate rustc_data_structures;
-extern crate rustc_errors;
-extern crate rustc_target;
-extern crate syntax;
-extern crate syntax_pos;
-#[macro_use]
-extern crate smallvec;
+#![deny(rust_2018_idioms)]
 
 pub mod expand;
 
index 3368bbf3855a5546c27bcfb9360051239f18fa1f..f293739dec727970f98cce2e10aede9345f4e356 100644 (file)
@@ -2,6 +2,7 @@
 authors = ["The Rust Project Developers"]
 name = "rustc_borrowck"
 version = "0.0.0"
+edition = "2018"
 
 [lib]
 name = "rustc_borrowck"
@@ -13,8 +14,10 @@ test = false
 log = "0.4"
 syntax = { path = "../libsyntax" }
 syntax_pos = { path = "../libsyntax_pos" }
-graphviz = { path = "../libgraphviz" }
+# for "clarity", rename the graphviz crate to dot; graphviz within `borrowck`
+# refers to the borrowck-specific graphviz adapter traits.
+dot = { path = "../libgraphviz", package = "graphviz" }
 rustc = { path = "../librustc" }
 rustc_mir = { path = "../librustc_mir" }
-rustc_errors = { path = "../librustc_errors" }
-rustc_data_structures = { path = "../librustc_data_structures" }
\ No newline at end of file
+errors = { path = "../librustc_errors", package = "rustc_errors" }
+rustc_data_structures = { path = "../librustc_data_structures" }
index cafb29ed99a416b886d7289db2f70200b3c636cc..f675c8d38a6768d89d312a8d0c3eb56945067625 100644 (file)
@@ -7,10 +7,10 @@
 // 3. assignments do not affect things loaned out as immutable
 // 4. moves do not affect things loaned out in any way
 
-use self::UseError::*;
+use UseError::*;
 
-use borrowck::*;
-use borrowck::InteriorKind::{InteriorElement, InteriorField};
+use crate::borrowck::*;
+use crate::borrowck::InteriorKind::{InteriorElement, InteriorField};
 use rustc::middle::expr_use_visitor as euv;
 use rustc::middle::expr_use_visitor::MutateMode;
 use rustc::middle::mem_categorization as mc;
@@ -22,6 +22,7 @@
 use rustc::hir;
 use rustc::hir::Node;
 use rustc_mir::util::borrowck_errors::{BorrowckErrors, Origin};
+use log::debug;
 
 use std::rc::Rc;
 
@@ -101,7 +102,7 @@ fn consume(&mut self,
 
     fn matched_pat(&mut self,
                    _matched_pat: &hir::Pat,
-                   _cmt: &mc::cmt_,
+                   _cmt: &mc::cmt_<'_>,
                    _mode: euv::MatchMode) { }
 
     fn consume_pat(&mut self,
@@ -910,7 +911,7 @@ fn check_assignment(&self,
     pub fn report_illegal_mutation(&self,
                                    span: Span,
                                    loan_path: &LoanPath<'tcx>,
-                                   loan: &Loan) {
+                                   loan: &Loan<'_>) {
         self.bccx.cannot_assign_to_borrowed(
             span, loan.span, &self.bccx.loan_path_to_string(loan_path), Origin::Ast)
             .emit();
index f5e27a953c27de2e4a602c2acda09baa758ce1f7..6b050fd9ba2303236c566c9e21f6bff5ab376ea0 100644 (file)
@@ -1,9 +1,9 @@
 //! Computes moves.
 
-use borrowck::*;
-use borrowck::gather_loans::move_error::MovePlace;
-use borrowck::gather_loans::move_error::{MoveError, MoveErrorCollector};
-use borrowck::move_data::*;
+use crate::borrowck::*;
+use crate::borrowck::gather_loans::move_error::MovePlace;
+use crate::borrowck::gather_loans::move_error::{MoveError, MoveErrorCollector};
+use crate::borrowck::move_data::*;
 use rustc::middle::expr_use_visitor as euv;
 use rustc::middle::mem_categorization as mc;
 use rustc::middle::mem_categorization::Categorization;
@@ -15,6 +15,7 @@
 use syntax_pos::Span;
 use rustc::hir::*;
 use rustc::hir::Node;
+use log::debug;
 
 struct GatherMoveInfo<'c, 'tcx: 'c> {
     id: hir::ItemLocalId,
index 8fc0a3d63384a59e7d1b9af12e9e5b333db17cea..11597455bca8faf1c79908d4bef3fb7f59840e53 100644 (file)
@@ -1,7 +1,7 @@
 //! This module implements the check that the lifetime of a borrow
 //! does not exceed the lifetime of the value being borrowed.
 
-use borrowck::*;
+use crate::borrowck::*;
 use rustc::middle::expr_use_visitor as euv;
 use rustc::middle::mem_categorization as mc;
 use rustc::middle::mem_categorization::Categorization;
@@ -10,6 +10,7 @@
 
 use syntax::ast;
 use syntax_pos::Span;
+use log::debug;
 
 type R = Result<(),()>;
 
index d681c771d2fa92faeb29e7e802d06c87d9b411e2..c21a43bc68333637fe6368b75ace205aa2455a11 100644 (file)
@@ -6,8 +6,8 @@
 // their associated scopes.  In phase two, checking loans, we will then make
 // sure that all of these loans are honored.
 
-use borrowck::*;
-use borrowck::move_data::MoveData;
+use crate::borrowck::*;
+use crate::borrowck::move_data::MoveData;
 use rustc::middle::expr_use_visitor as euv;
 use rustc::middle::mem_categorization as mc;
 use rustc::middle::mem_categorization::Categorization;
@@ -17,8 +17,9 @@
 use syntax::ast;
 use syntax_pos::Span;
 use rustc::hir;
+use log::debug;
 
-use self::restrictions::RestrictionResult;
+use restrictions::RestrictionResult;
 
 mod lifetime;
 mod restrictions;
@@ -427,7 +428,7 @@ fn guarantee_valid(&mut self,
         // }
     }
 
-    pub fn mark_loan_path_as_mutated(&self, loan_path: &LoanPath) {
+    pub fn mark_loan_path_as_mutated(&self, loan_path: &LoanPath<'_>) {
         //! For mutable loans of content whose mutability derives
         //! from a local variable, mark the mutability decl as necessary.
 
index 00cbc250bd686cf19fe2235cd9fd321f68f5c455..622dd8e891ac71b8cb6e77ea5f9ad607fbc9a11b 100644 (file)
@@ -1,4 +1,4 @@
-use borrowck::BorrowckCtxt;
+use crate::borrowck::BorrowckCtxt;
 use rustc::middle::mem_categorization as mc;
 use rustc::middle::mem_categorization::Categorization;
 use rustc::middle::mem_categorization::NoteClosureEnv;
@@ -8,7 +8,8 @@
 use syntax::ast;
 use syntax_pos;
 use errors::{DiagnosticBuilder, Applicability};
-use borrowck::gather_loans::gather_moves::PatternSource;
+use crate::borrowck::gather_loans::gather_moves::PatternSource;
+use log::debug;
 
 pub struct MoveErrorCollector<'tcx> {
     errors: Vec<MoveError<'tcx>>
@@ -167,10 +168,10 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &'a BorrowckCtxt<'a, 'tcx>,
     }
 }
 
-fn note_move_destination(mut err: DiagnosticBuilder,
+fn note_move_destination(mut err: DiagnosticBuilder<'_>,
                          move_to_span: syntax_pos::Span,
                          pat_name: ast::Name,
-                         is_first_note: bool) -> DiagnosticBuilder {
+                         is_first_note: bool) -> DiagnosticBuilder<'_> {
     if is_first_note {
         err.span_label(
             move_to_span,
index a43a7f1e09ae1d7f4408d89814ba1e69804e371a..9f4c05a6b255f2a5c474d556b788943ac55e6751 100644 (file)
@@ -1,13 +1,14 @@
 //! Computes the restrictions that result from a borrow.
 
-use borrowck::*;
+use crate::borrowck::*;
 use rustc::middle::expr_use_visitor as euv;
 use rustc::middle::mem_categorization as mc;
 use rustc::middle::mem_categorization::Categorization;
 use rustc::ty;
 use syntax_pos::Span;
+use log::debug;
 
-use borrowck::ToInteriorKind;
+use crate::borrowck::ToInteriorKind;
 
 use std::rc::Rc;
 
index e40c2b450892244c993bc3242a34d13e04cd7f1b..4ced72cd279b249a8279c33ddea51944038c4c27 100644 (file)
@@ -2,13 +2,13 @@
 
 #![allow(non_camel_case_types)]
 
-pub use self::LoanPathKind::*;
-pub use self::LoanPathElem::*;
-pub use self::bckerr_code::*;
-pub use self::AliasableViolationKind::*;
-pub use self::MovedValueUseKind::*;
+pub use LoanPathKind::*;
+pub use LoanPathElem::*;
+pub use bckerr_code::*;
+pub use AliasableViolationKind::*;
+pub use MovedValueUseKind::*;
 
-use self::InteriorKind::*;
+use InteriorKind::*;
 
 use rustc::hir::HirId;
 use rustc::hir::Node;
 use syntax::ast;
 use syntax_pos::{MultiSpan, Span};
 use errors::{Applicability, DiagnosticBuilder, DiagnosticId};
+use log::debug;
 
 use rustc::hir;
 
-use dataflow::{DataFlowContext, BitwiseOperator, DataFlowOperator, KillFrom};
+use crate::dataflow::{DataFlowContext, BitwiseOperator, DataFlowOperator, KillFrom};
 
 pub mod check_loans;
 
@@ -61,7 +62,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
     });
 }
 
-pub fn provide(providers: &mut Providers) {
+pub fn provide(providers: &mut Providers<'_>) {
     *providers = Providers {
         borrowck,
         ..*providers
@@ -398,7 +399,7 @@ pub enum LoanPathElem<'tcx> {
 }
 
 fn closure_to_block(closure_id: LocalDefId,
-                    tcx: TyCtxt) -> ast::NodeId {
+                    tcx: TyCtxt<'_, '_, '_>) -> ast::NodeId {
     let closure_id = tcx.hir().local_def_id_to_node_id(closure_id);
     match tcx.hir().get(closure_id) {
         Node::Expr(expr) => match expr.node {
@@ -1214,8 +1215,8 @@ fn local_ty(&self, node_id: ast::NodeId) -> (Option<&hir::Ty>, bool) {
     }
 
     fn note_immutability_blame(&self,
-                               db: &mut DiagnosticBuilder,
-                               blame: Option<ImmutabilityBlame>,
+                               db: &mut DiagnosticBuilder<'_>,
+                               blame: Option<ImmutabilityBlame<'_>>,
                                error_node_id: ast::NodeId) {
         match blame {
             None => {}
@@ -1271,7 +1272,7 @@ fn note_immutability_blame(&self,
      // binding: either to make the binding mutable (if its type is
      // not a mutable reference) or to avoid borrowing altogether
     fn note_immutable_local(&self,
-                            db: &mut DiagnosticBuilder,
+                            db: &mut DiagnosticBuilder<'_>,
                             borrowed_node_id: ast::NodeId,
                             binding_node_id: ast::NodeId) {
         let let_span = self.tcx.hir().span(binding_node_id);
@@ -1349,7 +1350,7 @@ fn region_end_span(&self, region: ty::Region<'tcx>) -> Option<Span> {
         }
     }
 
-    fn note_and_explain_mutbl_error(&self, db: &mut DiagnosticBuilder, err: &BckError<'a, 'tcx>,
+    fn note_and_explain_mutbl_error(&self, db: &mut DiagnosticBuilder<'_>, err: &BckError<'a, 'tcx>,
                                     error_span: &Span) {
         match err.cmt.note {
             mc::NoteClosureEnv(upvar_id) | mc::NoteUpvarRef(upvar_id) => {
@@ -1487,7 +1488,7 @@ fn initial_value(&self) -> bool {
 }
 
 impl<'tcx> fmt::Debug for InteriorKind {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         match *self {
             InteriorField(mc::FieldIndex(_, info)) => write!(f, "{}", info),
             InteriorElement => write!(f, "[]"),
@@ -1496,7 +1497,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 }
 
 impl<'tcx> fmt::Debug for Loan<'tcx> {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(f, "Loan_{}({:?}, {:?}, {:?}-{:?}, {:?})",
                self.index,
                self.loan_path,
@@ -1508,7 +1509,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 }
 
 impl<'tcx> fmt::Debug for LoanPath<'tcx> {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         match self.kind {
             LpVar(id) => {
                 write!(f, "$({})", ty::tls::with(|tcx| tcx.hir().node_to_string(id)))
@@ -1543,7 +1544,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 }
 
 impl<'tcx> fmt::Display for LoanPath<'tcx> {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         match self.kind {
             LpVar(id) => {
                 write!(f, "$({})", ty::tls::with(|tcx| tcx.hir().node_to_user_string(id)))
index 56c9f928eb03a30885a1521b8f5fdf0cabdc1de6..a206c37e97b091687420410ee26c24514ae1105a 100644 (file)
@@ -1,11 +1,11 @@
 //! Data structures used for tracking moves. Please see the extensive
 //! comments in the section "Moves and initialization" in `README.md`.
 
-pub use self::MoveKind::*;
+pub use MoveKind::*;
 
-use dataflow::{DataFlowContext, BitwiseOperator, DataFlowOperator, KillFrom};
+use crate::dataflow::{DataFlowContext, BitwiseOperator, DataFlowOperator, KillFrom};
 
-use borrowck::*;
+use crate::borrowck::*;
 use rustc::cfg;
 use rustc::ty::{self, TyCtxt};
 use rustc::util::nodemap::FxHashMap;
@@ -15,6 +15,7 @@
 use std::usize;
 use syntax_pos::Span;
 use rustc::hir;
+use log::debug;
 
 #[derive(Default)]
 pub struct MoveData<'tcx> {
@@ -145,7 +146,7 @@ pub struct Assignment {
 
 pub type AssignDataFlow<'a, 'tcx> = DataFlowContext<'a, 'tcx, AssignDataFlowOperator>;
 
-fn loan_path_is_precise(loan_path: &LoanPath) -> bool {
+fn loan_path_is_precise(loan_path: &LoanPath<'_>) -> bool {
     match loan_path.kind {
         LpVar(_) | LpUpvar(_) => {
             true
@@ -428,8 +429,8 @@ fn add_assignment_helper(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>,
     /// killed by scoping. See `README.md` for more details.
     fn add_gen_kills(&self,
                      bccx: &BorrowckCtxt<'a, 'tcx>,
-                     dfcx_moves: &mut MoveDataFlow,
-                     dfcx_assign: &mut AssignDataFlow) {
+                     dfcx_moves: &mut MoveDataFlow<'_, '_>,
+                     dfcx_assign: &mut AssignDataFlow<'_, '_>) {
         for (i, the_move) in self.moves.borrow().iter().enumerate() {
             dfcx_moves.add_gen(the_move.id, i);
         }
@@ -537,7 +538,7 @@ fn kill_moves(&self,
                   path: MovePathIndex,
                   kill_id: hir::ItemLocalId,
                   kill_kind: KillFrom,
-                  dfcx_moves: &mut MoveDataFlow) {
+                  dfcx_moves: &mut MoveDataFlow<'_, '_>) {
         // We can only perform kills for paths that refer to a unique location,
         // since otherwise we may kill a move from one location with an
         // assignment referring to another location.
index 5db98f0e223e484eba3a9198f7ac93cc9f28dd54..60a9c18e95ee9bac025839de33c8a1a3e6e50618 100644 (file)
@@ -7,7 +7,7 @@
 use std::slice;
 use syntax::ptr::P;
 
-use borrowck::BorrowckCtxt;
+use crate::borrowck::BorrowckCtxt;
 
 pub fn check<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, body: &'tcx hir::Body) {
     let mut used_mut = bccx.used_mut_nodes.borrow().clone();
index 8cf620567405c374b203eb5a9be56dd9a1c49e39..90f33ede62c21714c20b28fd74e8546fe3b9abae 100644 (file)
@@ -10,6 +10,7 @@
 use std::mem;
 use std::usize;
 use syntax::print::pprust::PrintState;
+use log::debug;
 
 use rustc_data_structures::graph::implementation::OUTGOING;
 
@@ -80,7 +81,7 @@ pub trait DataFlowOperator : BitwiseOperator {
     fn initial_value(&self) -> bool;
 }
 
-struct PropagationContext<'a, 'b: 'a, 'tcx: 'b, O: 'a> {
+struct PropagationContext<'a, 'b: 'a, 'tcx: 'b, O> {
     dfcx: &'a mut DataFlowContext<'b, 'tcx, O>,
     changed: bool
 }
@@ -99,12 +100,12 @@ fn has_bitset_for_local_id(&self, n: hir::ItemLocalId) -> bool {
 }
 
 impl<'a, 'tcx, O:DataFlowOperator> pprust::PpAnn for DataFlowContext<'a, 'tcx, O> {
-    fn nested(&self, state: &mut pprust::State, nested: pprust::Nested) -> io::Result<()> {
+    fn nested(&self, state: &mut pprust::State<'_>, nested: pprust::Nested) -> io::Result<()> {
         pprust::PpAnn::nested(self.tcx.hir(), state, nested)
     }
     fn pre(&self,
-           ps: &mut pprust::State,
-           node: pprust::AnnNode) -> io::Result<()> {
+           ps: &mut pprust::State<'_>,
+           node: pprust::AnnNode<'_>) -> io::Result<()> {
         let id = match node {
             pprust::AnnNode::Name(_) => return Ok(()),
             pprust::AnnNode::Expr(expr) => expr.hir_id.local_id,
index adad8c55f2159acc2a9ce1e3a16506d135bae071..77056d4d3eb1516df86cf751ff23b998618f5ec9 100644 (file)
@@ -2,16 +2,15 @@
 //! libgraphviz traits, specialized to attaching borrowck analysis
 //! data to rendered labels.
 
-pub use self::Variant::*;
+pub use Variant::*;
 
 pub use rustc::cfg::graphviz::{Node, Edge};
 use rustc::cfg::graphviz as cfg_dot;
 
-use borrowck;
-use borrowck::{BorrowckCtxt, LoanPath};
-use dot;
+use crate::borrowck::{self, BorrowckCtxt, LoanPath};
+use crate::dataflow::{DataFlowOperator, DataFlowContext, EntryOrExit};
+use log::debug;
 use rustc::cfg::CFGIndex;
-use dataflow::{DataFlowOperator, DataFlowContext, EntryOrExit};
 use std::rc::Rc;
 
 #[derive(Debug, Copy, Clone)]
@@ -53,7 +52,7 @@ fn dataflow_for(&self, e: EntryOrExit, n: &Node<'a>) -> String {
         sets
     }
 
-    fn dataflow_for_variant(&self, e: EntryOrExit, n: &Node, v: Variant) -> String {
+    fn dataflow_for_variant(&self, e: EntryOrExit, n: &Node<'_>, v: Variant) -> String {
         let cfgidx = n.0;
         match v {
             Loans   => self.dataflow_loans_for(e, cfgidx),
@@ -89,7 +88,7 @@ fn dataflow_loans_for(&self, e: EntryOrExit, cfgidx: CFGIndex) -> String {
         let dfcx = &self.analysis_data.loans;
         let loan_index_to_path = |loan_index| {
             let all_loans = &self.analysis_data.all_loans;
-            let l: &borrowck::Loan = &all_loans[loan_index];
+            let l: &borrowck::Loan<'_> = &all_loans[loan_index];
             l.loan_path()
         };
         self.build_set(e, cfgidx, dfcx, loan_index_to_path)
index 49890330a4e429c9101cedbf228a358b31238529..cf4669db87e5e9e4450793494a02ad5ef8c7bd5e 100644 (file)
@@ -1,23 +1,14 @@
 #![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
 
 #![allow(non_camel_case_types)]
+#![deny(rust_2018_idioms)]
 
 #![feature(nll)]
 
 #![recursion_limit="256"]
 
-#[macro_use] extern crate log;
-extern crate syntax;
-extern crate syntax_pos;
-extern crate rustc_errors as errors;
-extern crate rustc_data_structures;
-
-// for "clarity", rename the graphviz crate to dot; graphviz within `borrowck`
-// refers to the borrowck-specific graphviz adapter traits.
-extern crate graphviz as dot;
 #[macro_use]
 extern crate rustc;
-extern crate rustc_mir;
 
 pub use borrowck::check_crate;
 pub use borrowck::build_borrowck_dataflow_data_for_fn;
index 34a09f30b641162e1ed5541673832dd686935634..5f241eb20fb55a9373554b4bd6e3c12b6ac50fd7 100644 (file)
@@ -2,6 +2,7 @@
 authors = ["The Rust Project Developers"]
 name = "rustc_codegen_utils"
 version = "0.0.0"
+edition = "2018"
 
 [lib]
 name = "rustc_codegen_utils"
index a87b02d33de8f2c4fce4957ded5400734639282f..28d7d184228415d7186107417ecc37f68fb92a61 100644 (file)
@@ -29,7 +29,7 @@
 use rustc::middle::cstore::MetadataLoader;
 use rustc::dep_graph::DepGraph;
 use rustc_target::spec::Target;
-use link::out_filename;
+use crate::link::out_filename;
 
 pub use rustc_data_structures::sync::MetadataRef;
 
@@ -42,8 +42,8 @@ fn print_version(&self) {}
     fn diagnostics(&self) -> &[(&'static str, &'static str)] { &[] }
 
     fn metadata_loader(&self) -> Box<dyn MetadataLoader + Sync>;
-    fn provide(&self, _providers: &mut Providers);
-    fn provide_extern(&self, _providers: &mut Providers);
+    fn provide(&self, _providers: &mut Providers<'_>);
+    fn provide_extern(&self, _providers: &mut Providers<'_>);
     fn codegen_crate<'a, 'tcx>(
         &self,
         tcx: TyCtxt<'a, 'tcx, 'tcx>,
@@ -109,8 +109,8 @@ fn metadata_loader(&self) -> Box<dyn MetadataLoader + Sync> {
         box NoLlvmMetadataLoader
     }
 
-    fn provide(&self, providers: &mut Providers) {
-        ::symbol_names::provide(providers);
+    fn provide(&self, providers: &mut Providers<'_>) {
+        crate::symbol_names::provide(providers);
 
         providers.target_features_whitelist = |_tcx, _cnum| {
             Default::default() // Just a dummy
@@ -118,7 +118,7 @@ fn provide(&self, providers: &mut Providers) {
         providers.is_reachable_non_generic = |_tcx, _defid| true;
         providers.exported_symbols = |_tcx, _crate| Arc::new(Vec::new());
     }
-    fn provide_extern(&self, providers: &mut Providers) {
+    fn provide_extern(&self, providers: &mut Providers<'_>) {
         providers.is_reachable_non_generic = |_tcx, _defid| true;
     }
 
@@ -129,12 +129,12 @@ fn codegen_crate<'a, 'tcx>(
     ) -> Box<dyn Any> {
         use rustc_mir::monomorphize::item::MonoItem;
 
-        ::check_for_rustc_errors_attr(tcx);
-        ::symbol_names_test::report_symbol_names(tcx);
-        ::rustc_incremental::assert_dep_graph(tcx);
-        ::rustc_incremental::assert_module_sources::assert_module_sources(tcx);
+        crate::check_for_rustc_errors_attr(tcx);
+        crate::symbol_names_test::report_symbol_names(tcx);
+        rustc_incremental::assert_dep_graph(tcx);
+        rustc_incremental::assert_module_sources::assert_module_sources(tcx);
         // FIXME: Fix this
-        // ::rustc::middle::dependency_format::calculate(tcx);
+        // rustc::middle::dependency_format::calculate(tcx);
         let _ = tcx.link_args(LOCAL_CRATE);
         let _ = tcx.native_libraries(LOCAL_CRATE);
         let (_, cgus) = tcx.collect_and_partition_mono_items(LOCAL_CRATE);
index d6ef555144d201cfdfde13a8504b8288e974dbba..2b70141894be98fabd4f743f0cb649f813ec44af 100644 (file)
 
 #![recursion_limit="256"]
 
-extern crate flate2;
-#[macro_use]
-extern crate log;
+#![deny(rust_2018_idioms)]
 
 #[macro_use]
 extern crate rustc;
-extern crate rustc_target;
-extern crate rustc_metadata;
-extern crate rustc_mir;
-extern crate rustc_incremental;
-extern crate syntax;
-extern crate syntax_pos;
 #[macro_use] extern crate rustc_data_structures;
 
 use rustc::ty::TyCtxt;
@@ -40,7 +32,7 @@
 /// error in codegen. This is used to write compile-fail tests
 /// that actually test that compilation succeeds without
 /// reporting an error.
-pub fn check_for_rustc_errors_attr(tcx: TyCtxt) {
+pub fn check_for_rustc_errors_attr(tcx: TyCtxt<'_, '_, '_>) {
     if let Some((def_id, _)) = tcx.entry_fn(LOCAL_CRATE) {
         if tcx.has_attr(def_id, "rustc_error") {
             tcx.sess.span_fatal(tcx.def_span(def_id), "compilation successful");
index 09e22bd2c91a94c390b61af9e24907258674776f..f3a1b219f8a84d1929119f01019d0d253b4f46be 100644 (file)
@@ -41,7 +41,7 @@ pub fn find_crate_name(sess: Option<&Session>,
                        attrs: &[ast::Attribute],
                        input: &Input) -> String {
     let validate = |s: String, span: Option<Span>| {
-        ::rustc_metadata::validate_crate_name(sess, &s, span);
+        rustc_metadata::validate_crate_name(sess, &s, span);
         s
     };
 
index 3238a0b10bfd6d40fcb939f83b989db7e451466e..8d105853d92f11e12f39da4273894d8738a9fb0c 100644 (file)
 
 use syntax_pos::symbol::Symbol;
 
+use log::debug;
+
 use std::fmt::Write;
 use std::mem::discriminant;
 
-pub fn provide(providers: &mut Providers) {
+pub fn provide(providers: &mut Providers<'_>) {
     *providers = Providers {
         def_symbol_name,
         symbol_name,
index b8e494e4040ec829e52baa89347883c04a287e7a..6bdfbe09354b40530cb730696380e65cfc7fb664 100644 (file)
@@ -15,6 +15,7 @@
 authors = ["The Rust Project Developers"]
 name = "rustc_cratesio_shim"
 version = "0.0.0"
+edition = "2018"
 
 [lib]
 crate-type = ["dylib"]
index 4024087f4d3effa3a90cecbe904dc033eeb75ac4..4c170f4f5f6f98bec42cd3d87e0d55905e4ad2a2 100644 (file)
@@ -1,3 +1,5 @@
+#![deny(rust_2018_idioms)]
+
 // See Cargo.toml for a comment explaining this crate.
 #![allow(unused_extern_crates)]
 
index 1754376a5d7f9e7202daa43007574d722a3fd311..f781952d4172cc874ac2320663921f8295b1109b 100644 (file)
@@ -2,6 +2,7 @@
 authors = ["The Rust Project Developers"]
 name = "rustc_data_structures"
 version = "0.0.0"
+edition = "2018"
 
 [lib]
 name = "rustc_data_structures"
@@ -16,8 +17,8 @@ serialize = { path = "../libserialize" }
 graphviz = { path = "../libgraphviz" }
 cfg-if = "0.1.2"
 stable_deref_trait = "1.0.0"
-rustc-rayon = "0.1.1"
-rustc-rayon-core = "0.1.1"
+rayon = { version = "0.1.1", package = "rustc-rayon" }
+rayon-core = { version = "0.1.1", package = "rustc-rayon-core" }
 rustc-hash = "1.0.1"
 smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
 
index 8adfe3749af8e2ced88529180da1a3750a4d9197..05d2185ae69b406d2a25b2573ace6e44ce9f9660 100644 (file)
@@ -1,4 +1,4 @@
-use indexed_vec::{Idx, IndexVec};
+use crate::indexed_vec::{Idx, IndexVec};
 use smallvec::SmallVec;
 use std::fmt;
 use std::iter;
@@ -208,7 +208,7 @@ fn subtract_from(&self, other: &mut BitSet<T>) -> bool {
 }
 
 impl<T: Idx> fmt::Debug for BitSet<T> {
-    fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, w: &mut fmt::Formatter<'_>) -> fmt::Result {
         w.debug_list()
          .entries(self.iter())
          .finish()
@@ -366,7 +366,7 @@ fn to_dense(&self) -> BitSet<T> {
         dense
     }
 
-    fn iter(&self) -> slice::Iter<T> {
+    fn iter(&self) -> slice::Iter<'_, T> {
         self.elems.iter()
     }
 }
@@ -536,7 +536,7 @@ pub fn to_dense(self) -> BitSet<T> {
         }
     }
 
-    pub fn iter(&self) -> HybridIter<T> {
+    pub fn iter(&self) -> HybridIter<'_, T> {
         match self {
             HybridBitSet::Sparse(sparse) => HybridIter::Sparse(sparse.iter()),
             HybridBitSet::Dense(dense) => HybridIter::Dense(dense.iter()),
index 2e596ca3e44f1f55ca891a34cd6583dd6fb6acae..c4c0db58012092783c4df0f477847814c9562656 100644 (file)
@@ -1,5 +1,5 @@
+use crate::stable_hasher;
 use std::mem;
-use stable_hasher;
 use serialize;
 use serialize::opaque::{EncodeResult, Encoder, Decoder};
 
@@ -70,7 +70,7 @@ pub fn decode_opaque<'a>(decoder: &mut Decoder<'a>) -> Result<Fingerprint, Strin
 }
 
 impl ::std::fmt::Display for Fingerprint {
-    fn fmt(&self, formatter: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+    fn fmt(&self, formatter: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
         write!(formatter, "{:x}-{:x}", self.0, self.1)
     }
 }
index 2dea249f1c07c25773f4858225aaba14d56d076d..255c5fd7fe7ec8938e266e60c9c51b503d587c51 100644 (file)
     if #[cfg(unix)] {
         use std::ffi::{CString, OsStr};
         use std::os::unix::prelude::*;
-        use libc;
 
         #[cfg(any(target_os = "linux", target_os = "android"))]
         mod os {
-            use libc;
-
             #[repr(C)]
             pub struct flock {
                 pub l_type: libc::c_short,
@@ -35,8 +32,6 @@ pub struct flock {
 
         #[cfg(target_os = "freebsd")]
         mod os {
-            use libc;
-
             #[repr(C)]
             pub struct flock {
                 pub l_start: libc::off_t,
@@ -53,8 +48,6 @@ pub struct flock {
                   target_os = "netbsd",
                   target_os = "openbsd"))]
         mod os {
-            use libc;
-
             #[repr(C)]
             pub struct flock {
                 pub l_start: libc::off_t,
@@ -70,8 +63,6 @@ pub struct flock {
 
         #[cfg(target_os = "haiku")]
         mod os {
-            use libc;
-
             #[repr(C)]
             pub struct flock {
                 pub l_type: libc::c_short,
@@ -87,8 +78,6 @@ pub struct flock {
 
         #[cfg(any(target_os = "macos", target_os = "ios"))]
         mod os {
-            use libc;
-
             #[repr(C)]
             pub struct flock {
                 pub l_start: libc::off_t,
@@ -104,8 +93,6 @@ pub struct flock {
 
         #[cfg(target_os = "solaris")]
         mod os {
-            use libc;
-
             #[repr(C)]
             pub struct flock {
                 pub l_type: libc::c_short,
index 536efffbb22f49c064d41534cf877ff03362615d..aaed41d9fa3620e15fb2ebe14ee1462cdbb188e6 100644 (file)
@@ -117,7 +117,7 @@ pub fn immediate_dominator(&self, node: Node) -> Node {
         self.immediate_dominators[node].unwrap()
     }
 
-    pub fn dominators(&self, node: Node) -> Iter<Node> {
+    pub fn dominators(&self, node: Node) -> Iter<'_, Node> {
         assert!(self.is_reachable(node), "node {:?} is not reachable", node);
         Iter {
             dominators: self,
@@ -136,7 +136,7 @@ fn all_immediate_dominators(&self) -> &IndexVec<Node, Option<Node>> {
     }
 }
 
-pub struct Iter<'dom, Node: Idx + 'dom> {
+pub struct Iter<'dom, Node: Idx> {
     dominators: &'dom Dominators<Node>,
     node: Option<Node>,
 }
@@ -171,7 +171,7 @@ pub fn children(&self, node: Node) -> &[Node] {
 }
 
 impl<Node: Idx> fmt::Debug for DominatorTree<Node> {
-    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
         fmt::Debug::fmt(
             &DominatorTreeNode {
                 tree: self,
@@ -188,7 +188,7 @@ struct DominatorTreeNode<'tree, Node: Idx> {
 }
 
 impl<'tree, Node: Idx> fmt::Debug for DominatorTreeNode<'tree, Node> {
-    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
         let subtrees: Vec<_> = self.tree
             .children(self.node)
             .iter()
index 0768873f8362688e824031e1cf2a9f0253dda79a..a8b734094064aa28218985bcdae770194a8a2b15 100644 (file)
 //! the field `next_edge`). Each of those fields is an array that should
 //! be indexed by the direction (see the type `Direction`).
 
-use bit_set::BitSet;
+use crate::bit_set::BitSet;
+use crate::snapshot_vec::{SnapshotVec, SnapshotVecDelegate};
 use std::fmt::Debug;
 use std::usize;
-use snapshot_vec::{SnapshotVec, SnapshotVecDelegate};
 
 #[cfg(test)]
 mod tests;
@@ -212,15 +212,19 @@ pub fn each_edge<'a>(&'a self, mut f: impl FnMut(EdgeIndex, &'a Edge<E>) -> bool
             .all(|(edge_idx, edge)| f(edge_idx, edge))
     }
 
-    pub fn outgoing_edges(&self, source: NodeIndex) -> AdjacentEdges<N, E> {
+    pub fn outgoing_edges(&self, source: NodeIndex) -> AdjacentEdges<'_, N, E> {
         self.adjacent_edges(source, OUTGOING)
     }
 
-    pub fn incoming_edges(&self, source: NodeIndex) -> AdjacentEdges<N, E> {
+    pub fn incoming_edges(&self, source: NodeIndex) -> AdjacentEdges<'_, N, E> {
         self.adjacent_edges(source, INCOMING)
     }
 
-    pub fn adjacent_edges(&self, source: NodeIndex, direction: Direction) -> AdjacentEdges<N, E> {
+    pub fn adjacent_edges(
+        &self,
+        source: NodeIndex,
+        direction: Direction
+    ) -> AdjacentEdges<'_, N, E> {
         let first_edge = self.node(source).first_edge[direction.repr];
         AdjacentEdges {
             graph: self,
@@ -291,11 +295,7 @@ pub fn nodes_in_postorder(
 
 // # Iterators
 
-pub struct AdjacentEdges<'g, N, E>
-where
-    N: 'g,
-    E: 'g,
-{
+pub struct AdjacentEdges<'g, N, E> {
     graph: &'g Graph<N, E>,
     direction: Direction,
     next: EdgeIndex,
@@ -331,11 +331,7 @@ fn size_hint(&self) -> (usize, Option<usize>) {
     }
 }
 
-pub struct DepthFirstTraversal<'g, N, E>
-where
-    N: 'g,
-    E: 'g,
-{
+pub struct DepthFirstTraversal<'g, N, E> {
     graph: &'g Graph<N, E>,
     stack: Vec<NodeIndex>,
     visited: BitSet<usize>,
index a7a25042396101bbabf2d8bb3faa0bfebfb898e1..82c6da3f42711e368232a6ec367422c93a57db6d 100644 (file)
@@ -1,4 +1,4 @@
-use graph::implementation::*;
+use crate::graph::implementation::*;
 use std::fmt::Debug;
 
 type TestGraph = Graph<&'static str, &'static str>;
index baab377ef12760e15cf76e7f30231924f3d8b6c0..e3264fda2629c5695ecb0402d10d419978dcf10f 100644 (file)
@@ -3,9 +3,9 @@
 //! node in the graph. This uses Tarjan's algorithm that completes in
 //! O(n) time.
 
-use fx::FxHashSet;
-use graph::{DirectedGraph, WithNumNodes, WithSuccessors};
-use indexed_vec::{Idx, IndexVec};
+use crate::fx::FxHashSet;
+use crate::graph::{DirectedGraph, WithNumNodes, WithSuccessors};
+use crate::indexed_vec::{Idx, IndexVec};
 use std::ops::Range;
 
 mod test;
@@ -93,7 +93,7 @@ fn create_scc(&mut self, successors: impl IntoIterator<Item = S>) -> S {
     }
 }
 
-struct SccsConstruction<'c, G: DirectedGraph + WithNumNodes + WithSuccessors + 'c, S: Idx> {
+struct SccsConstruction<'c, G: DirectedGraph + WithNumNodes + WithSuccessors, S: Idx> {
     graph: &'c G,
 
     /// The state of each node; used during walk to record the stack
index e23cb1348b0153933fb8ca00ea2ecf38ae656dac..da3a1ceefe94bc6fbb144253ad7e29f750007f2c 100644 (file)
@@ -1,6 +1,6 @@
 #![cfg(test)]
 
-use graph::test::TestGraph;
+use crate::graph::test::TestGraph;
 use super::*;
 
 #[test]
index 3d482e448bdb792af1141327f59116985d84e77b..b390c4195729429b5903c8e933ef0056e77b5703 100644 (file)
@@ -1,4 +1,4 @@
-use fx::FxHashMap;
+use crate::fx::FxHashMap;
 use std::cmp::max;
 use std::slice;
 use std::iter;
index 8d8fbe588a021dc9ce21dc9719b7818eaab0fb21..516ea7fb7d946d405eaf6a519db1a94c8d4b730a 100644 (file)
@@ -257,7 +257,7 @@ fn from(value: u32) -> Self {
      @type         [$type:ident]
      @debug_format [$debug_format:tt]) => (
         impl ::std::fmt::Debug for $type {
-            fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+            fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                 write!(fmt, $debug_format, self.as_u32())
             }
         }
@@ -495,7 +495,7 @@ fn decode<D: serialize::Decoder>(d: &mut D) -> Result<Self, D::Error> {
 }
 
 impl<I: Idx, T: fmt::Debug> fmt::Debug for IndexVec<I, T> {
-    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
         fmt::Debug::fmt(&self.raw, fmt)
     }
 }
@@ -573,7 +573,7 @@ pub fn into_iter_enumerated(self) -> Enumerated<I, vec::IntoIter<T>>
     }
 
     #[inline]
-    pub fn iter(&self) -> slice::Iter<T> {
+    pub fn iter(&self) -> slice::Iter<'_, T> {
         self.raw.iter()
     }
 
@@ -589,7 +589,7 @@ pub fn indices(&self) -> iter::Map<Range<usize>, IntoIdx<I>> {
     }
 
     #[inline]
-    pub fn iter_mut(&mut self) -> slice::IterMut<T> {
+    pub fn iter_mut(&mut self) -> slice::IterMut<'_, T> {
         self.raw.iter_mut()
     }
 
index a46f8aed324997e09bec0e70bf3fe7d6442879c0..08b453cf493f835dd847412d57450c78ee41d380 100644 (file)
 #![cfg_attr(unix, feature(libc))]
 #![cfg_attr(test, feature(test))]
 
-extern crate core;
-extern crate ena;
+#![deny(rust_2018_idioms)]
+
 #[macro_use]
 extern crate log;
+#[allow(unused_extern_crates)]
 extern crate serialize as rustc_serialize; // used by deriving
 #[cfg(unix)]
 extern crate libc;
-extern crate parking_lot;
 #[macro_use]
 extern crate cfg_if;
-extern crate stable_deref_trait;
-extern crate rustc_rayon as rayon;
-extern crate rustc_rayon_core as rayon_core;
-extern crate rustc_hash;
-extern crate serialize;
-extern crate graphviz;
-extern crate smallvec;
 
 // See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
 #[allow(unused_extern_crates)]
index c2e3938b305d2777d6d6429e7abaa7c3855450cf..72551b42324d087dcf7e333904fe12fb6a9e36b0 100644 (file)
@@ -1,5 +1,5 @@
+use crate::obligation_forest::{ForestObligation, ObligationForest};
 use graphviz as dot;
-use obligation_forest::{ForestObligation, ObligationForest};
 use std::env::var_os;
 use std::fs::File;
 use std::path::Path;
@@ -41,22 +41,22 @@ impl<'a, O: ForestObligation + 'a> dot::Labeller<'a> for &'a ObligationForest<O>
     type Node = usize;
     type Edge = (usize, usize);
 
-    fn graph_id(&self) -> dot::Id {
+    fn graph_id(&self) -> dot::Id<'_> {
         dot::Id::new("trait_obligation_forest").unwrap()
     }
 
-    fn node_id(&self, index: &Self::Node) -> dot::Id {
+    fn node_id(&self, index: &Self::Node) -> dot::Id<'_> {
         dot::Id::new(format!("obligation_{}", index)).unwrap()
     }
 
-    fn node_label(&self, index: &Self::Node) -> dot::LabelText {
+    fn node_label(&self, index: &Self::Node) -> dot::LabelText<'_> {
         let node = &self.nodes[*index];
         let label = format!("{:?} ({:?})", node.obligation.as_predicate(), node.state.get());
 
         dot::LabelText::LabelStr(label.into())
     }
 
-    fn edge_label(&self, (_index_source, _index_target): &Self::Edge) -> dot::LabelText {
+    fn edge_label(&self, (_index_source, _index_target): &Self::Edge) -> dot::LabelText<'_> {
         dot::LabelText::LabelStr("".into())
     }
 }
@@ -65,11 +65,11 @@ impl<'a, O: ForestObligation + 'a> dot::GraphWalk<'a> for &'a ObligationForest<O
     type Node = usize;
     type Edge = (usize, usize);
 
-    fn nodes(&self) -> dot::Nodes<Self::Node> {
+    fn nodes(&self) -> dot::Nodes<'_, Self::Node> {
         (0..self.nodes.len()).collect()
     }
 
-    fn edges(&self) -> dot::Edges<Self::Edge> {
+    fn edges(&self) -> dot::Edges<'_, Self::Edge> {
         (0..self.nodes.len())
             .flat_map(|i| {
                 let node = &self.nodes[i];
index 9dd7d204f0373d5ccea71f87c629a3d33b5f6176..546bb64168e1481f3e1bfa67e98277e259871368 100644 (file)
@@ -80,7 +80,7 @@
 //! processing step, we compress the vector to remove completed and error
 //! nodes, which aren't needed anymore.
 
-use fx::{FxHashMap, FxHashSet};
+use crate::fx::{FxHashMap, FxHashSet};
 
 use std::cell::Cell;
 use std::collections::hash_map::Entry;
@@ -733,7 +733,7 @@ fn new(
 
 // I need a Clone closure
 #[derive(Clone)]
-struct GetObligation<'a, O: 'a>(&'a [Node<O>]);
+struct GetObligation<'a, O>(&'a [Node<O>]);
 
 impl<'a, 'b, O> FnOnce<(&'b usize,)> for GetObligation<'a, O> {
     type Output = &'a O;
index 0b126e5c572ed8453431e9f47875e5aff556c8c9..30e510cc5b055909d8f7ee019fc6aaa59efdad77 100644 (file)
@@ -1002,7 +1002,7 @@ impl<O, T: ?Sized> Debug for OwningRef<O, T>
     where O: Debug,
           T: Debug,
 {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(f,
                "OwningRef {{ owner: {:?}, reference: {:?} }}",
                self.owner(),
@@ -1014,7 +1014,7 @@ impl<O, T: ?Sized> Debug for OwningRefMut<O, T>
     where O: Debug,
           T: Debug,
 {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(f,
                "OwningRefMut {{ owner: {:?}, reference: {:?} }}",
                self.owner(),
@@ -1047,7 +1047,7 @@ unsafe impl<O, T: ?Sized> Sync for OwningRefMut<O, T>
     where O: Sync, for<'a> (&'a mut T): Sync {}
 
 impl Debug for dyn Erased {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(f, "<Erased>",)
     }
 }
index 322dcbe8f08fbbc7a8fb41cb4fb792cf3ac5a496..bf3ae2d7af58f77fae0d27e4ad8789856e727429 100644 (file)
@@ -4,7 +4,7 @@
 /// A wrapper around reference that compares and hashes like a pointer.
 /// Can be used as a key in sets/maps indexed by pointers to avoid `unsafe`.
 #[derive(Debug)]
-pub struct PtrKey<'a, T: 'a>(pub &'a T);
+pub struct PtrKey<'a, T>(pub &'a T);
 
 impl<'a, T> Clone for PtrKey<'a, T> {
     fn clone(&self) -> Self { *self }
index d408727aea5049ecbb4e1ccab48c5b55c9a1456d..91d6e29237002c28154673ad5e5c79324529c562 100644 (file)
@@ -1,4 +1,4 @@
-use fx::FxHashMap;
+use crate::fx::FxHashMap;
 use std::hash::Hash;
 use std::ops;
 use std::mem;
index 64bbb8d7c08d12b838b5f19e8bc97278848d07c9..1f674c1c664e4cba7927acaf2561e5990f36bf41 100644 (file)
@@ -111,7 +111,7 @@ pub fn clear(&mut self) {
 
     /// Iterate over elements, sorted by key
     #[inline]
-    pub fn iter(&self) -> ::std::slice::Iter<(K, V)> {
+    pub fn iter(&self) -> ::std::slice::Iter<'_, (K, V)> {
         self.data.iter()
     }
 
index 4583f12ec8cbc42b66ef36a8c8f36c63950ae8c3..19343a9250df3737530124d4f9c4ba6cc90aebf6 100644 (file)
@@ -1,7 +1,9 @@
 use std::hash::{Hash, Hasher, BuildHasher};
 use std::marker::PhantomData;
 use std::mem;
-use sip128::SipHasher128;
+use crate::sip128::SipHasher128;
+use crate::indexed_vec;
+use crate::bit_set;
 
 /// When hashing something that ends up affecting properties like symbol names,
 /// we want these symbol names to be calculated independently of other factors
@@ -17,7 +19,7 @@ pub struct StableHasher<W> {
 }
 
 impl<W: StableHasherResult> ::std::fmt::Debug for StableHasher<W> {
-    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
+    fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
         write!(f, "{:?}", self.state)
     }
 }
@@ -433,7 +435,7 @@ fn hash_stable<W: StableHasherResult>(&self,
     }
 }
 
-impl<I: ::indexed_vec::Idx, T, CTX> HashStable<CTX> for ::indexed_vec::IndexVec<I, T>
+impl<I: indexed_vec::Idx, T, CTX> HashStable<CTX> for indexed_vec::IndexVec<I, T>
     where T: HashStable<CTX>,
 {
     fn hash_stable<W: StableHasherResult>(&self,
@@ -447,7 +449,7 @@ fn hash_stable<W: StableHasherResult>(&self,
 }
 
 
-impl<I: ::indexed_vec::Idx, CTX> HashStable<CTX> for ::bit_set::BitSet<I>
+impl<I: indexed_vec::Idx, CTX> HashStable<CTX> for bit_set::BitSet<I>
 {
     fn hash_stable<W: StableHasherResult>(&self,
                                           ctx: &mut CTX,
index 749479534979c8beb7f4379f90b15b78938d537f..3757f921098f2d5ea13bff1d4968436b7add7ec1 100644 (file)
@@ -9,7 +9,7 @@
 use std::hash::{Hash, Hasher};
 use serialize::{Encodable, Decodable, Encoder, Decoder};
 
-use stable_hasher;
+use crate::stable_hasher;
 
 #[derive(Copy, Clone, PartialEq, Eq, Debug)]
 pub struct Svh {
@@ -40,7 +40,7 @@ fn hash<H>(&self, state: &mut H) where H: Hasher {
 }
 
 impl fmt::Display for Svh {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         f.pad(&self.to_string())
     }
 }
index 7fef1f374d6fdfb1f651791db687805c7a3e6eea..ba1f6eb56fe886eec434fcc1c251c0f577f55a3d 100644 (file)
@@ -21,7 +21,7 @@
 use std::hash::{Hash, BuildHasher};
 use std::marker::PhantomData;
 use std::ops::{Deref, DerefMut};
-use owning_ref::{Erased, OwningRef};
+use crate::owning_ref::{Erased, OwningRef};
 
 pub fn serial_join<A, B, RA, RB>(oper_a: A, oper_b: B) -> (RA, RB)
     where A: FnOnce() -> RA,
@@ -261,12 +261,12 @@ pub fn get_mut(&mut self) -> &mut T {
             }
 
             #[inline(always)]
-            pub fn lock(&self) -> LockGuard<T> {
+            pub fn lock(&self) -> LockGuard<'_, T> {
                 self.0.lock()
             }
 
             #[inline(always)]
-            pub fn lock_mut(&self) -> LockGuard<T> {
+            pub fn lock_mut(&self) -> LockGuard<'_, T> {
                 self.lock()
             }
         }
@@ -490,19 +490,19 @@ pub fn get_mut(&mut self) -> &mut T {
 
     #[cfg(parallel_compiler)]
     #[inline(always)]
-    pub fn try_lock(&self) -> Option<LockGuard<T>> {
+    pub fn try_lock(&self) -> Option<LockGuard<'_, T>> {
         self.0.try_lock()
     }
 
     #[cfg(not(parallel_compiler))]
     #[inline(always)]
-    pub fn try_lock(&self) -> Option<LockGuard<T>> {
+    pub fn try_lock(&self) -> Option<LockGuard<'_, T>> {
         self.0.try_borrow_mut().ok()
     }
 
     #[cfg(parallel_compiler)]
     #[inline(always)]
-    pub fn lock(&self) -> LockGuard<T> {
+    pub fn lock(&self) -> LockGuard<'_, T> {
         if ERROR_CHECKING {
             self.0.try_lock().expect("lock was already held")
         } else {
@@ -512,7 +512,7 @@ pub fn lock(&self) -> LockGuard<T> {
 
     #[cfg(not(parallel_compiler))]
     #[inline(always)]
-    pub fn lock(&self) -> LockGuard<T> {
+    pub fn lock(&self) -> LockGuard<'_, T> {
         self.0.borrow_mut()
     }
 
@@ -522,12 +522,12 @@ pub fn with_lock<F: FnOnce(&mut T) -> R, R>(&self, f: F) -> R {
     }
 
     #[inline(always)]
-    pub fn borrow(&self) -> LockGuard<T> {
+    pub fn borrow(&self) -> LockGuard<'_, T> {
         self.lock()
     }
 
     #[inline(always)]
-    pub fn borrow_mut(&self) -> LockGuard<T> {
+    pub fn borrow_mut(&self) -> LockGuard<'_, T> {
         self.lock()
     }
 }
@@ -568,13 +568,13 @@ pub fn get_mut(&mut self) -> &mut T {
 
     #[cfg(not(parallel_compiler))]
     #[inline(always)]
-    pub fn read(&self) -> ReadGuard<T> {
+    pub fn read(&self) -> ReadGuard<'_, T> {
         self.0.borrow()
     }
 
     #[cfg(parallel_compiler)]
     #[inline(always)]
-    pub fn read(&self) -> ReadGuard<T> {
+    pub fn read(&self) -> ReadGuard<'_, T> {
         if ERROR_CHECKING {
             self.0.try_read().expect("lock was already held")
         } else {
@@ -589,25 +589,25 @@ pub fn with_read_lock<F: FnOnce(&T) -> R, R>(&self, f: F) -> R {
 
     #[cfg(not(parallel_compiler))]
     #[inline(always)]
-    pub fn try_write(&self) -> Result<WriteGuard<T>, ()> {
+    pub fn try_write(&self) -> Result<WriteGuard<'_, T>, ()> {
         self.0.try_borrow_mut().map_err(|_| ())
     }
 
     #[cfg(parallel_compiler)]
     #[inline(always)]
-    pub fn try_write(&self) -> Result<WriteGuard<T>, ()> {
+    pub fn try_write(&self) -> Result<WriteGuard<'_, T>, ()> {
         self.0.try_write().ok_or(())
     }
 
     #[cfg(not(parallel_compiler))]
     #[inline(always)]
-    pub fn write(&self) -> WriteGuard<T> {
+    pub fn write(&self) -> WriteGuard<'_, T> {
         self.0.borrow_mut()
     }
 
     #[cfg(parallel_compiler)]
     #[inline(always)]
-    pub fn write(&self) -> WriteGuard<T> {
+    pub fn write(&self) -> WriteGuard<'_, T> {
         if ERROR_CHECKING {
             self.0.try_write().expect("lock was already held")
         } else {
@@ -621,12 +621,12 @@ pub fn with_write_lock<F: FnOnce(&mut T) -> R, R>(&self, f: F) -> R {
     }
 
     #[inline(always)]
-    pub fn borrow(&self) -> ReadGuard<T> {
+    pub fn borrow(&self) -> ReadGuard<'_, T> {
         self.read()
     }
 
     #[inline(always)]
-    pub fn borrow_mut(&self) -> WriteGuard<T> {
+    pub fn borrow_mut(&self) -> WriteGuard<'_, T> {
         self.write()
     }
 }
index d660486d58446d9c1873ef72a84eb1a6389df1a4..3d74516d9c326292af58172ff3748d4791d37018 100644 (file)
@@ -123,7 +123,7 @@ fn contains(&self, data: &T) -> bool {
 mod test {
     use super::*;
     extern crate test;
-    use self::test::Bencher;
+    use test::Bencher;
 
     #[test]
     fn test_contains_and_insert() {
index 9d675ed3096e03968e9da981c83dd3f555625e4c..39aed9833607fc6b02a71a6a38af4e3add506e74 100644 (file)
@@ -1,8 +1,8 @@
-use bit_set::BitMatrix;
-use fx::FxHashMap;
-use sync::Lock;
+use crate::bit_set::BitMatrix;
+use crate::fx::FxHashMap;
+use crate::stable_hasher::{HashStable, StableHasher, StableHasherResult};
+use crate::sync::Lock;
 use rustc_serialize::{Encodable, Encoder, Decodable, Decoder};
-use stable_hasher::{HashStable, StableHasher, StableHasherResult};
 use std::fmt::Debug;
 use std::hash::Hash;
 use std::mem;
index 3b6984dd07599a562d23a82c036d41c5a1d4e71f..c00c707a435427b985b878f6dc53dae387667c51 100644 (file)
@@ -1,4 +1,4 @@
-use indexed_vec::{Idx, IndexVec};
+use crate::indexed_vec::{Idx, IndexVec};
 
 pub fn iter<Ls>(
     first: Option<Ls::LinkIndex>,
index 0a928de7961b5bed5f824e58ffeb6f8ea1dacc0d..06418b1051ac3ded53ac0c0016a5a4cced31c566 100644 (file)
@@ -1,5 +1,5 @@
-use bit_set::BitSet;
-use indexed_vec::Idx;
+use crate::bit_set::BitSet;
+use crate::indexed_vec::Idx;
 use std::collections::VecDeque;
 
 /// A work queue is a handy data structure for tracking work left to
index 061d23697fa3a26bd6be5b3212dfd06cd318d02f..2821201173ea095b22afe104ac65c0162c1912bd 100644 (file)
@@ -672,8 +672,8 @@ fn render_source_line(&self,
         //   | |  something about `foo`
         //   | something about `fn foo()`
         annotations_position.sort_by(|a, b| {
-            // Decreasing order
-            a.1.len().cmp(&b.1.len()).reverse()
+            // Decreasing order. When `a` and `b` are the same length, prefer `Primary`.
+            (a.1.len(), !a.1.is_primary).cmp(&(b.1.len(), !b.1.is_primary)).reverse()
         });
 
         // Write the underlines.
index b8519ee1ab1a5bff1c839d55e4bb8d2db46abd6e..10b448b7fec3f90f752ee8f26c76d7b158aa1977 100644 (file)
@@ -2,6 +2,7 @@
 authors = ["The Rust Project Developers"]
 name = "rustc_incremental"
 version = "0.0.0"
+edition = "2018"
 
 [lib]
 name = "rustc_incremental"
index 57ab48493fa93599607034136dc4c83fb69b9d9b..b715a32cb0573144b7c88affad90427cf951cf22 100644 (file)
@@ -217,7 +217,7 @@ fn check_paths<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     }
 }
 
-fn dump_graph(tcx: TyCtxt) {
+fn dump_graph(tcx: TyCtxt<'_, '_, '_>) {
     let path: String = env::var("RUST_DEP_GRAPH").unwrap_or_else(|_| "dep_graph".to_string());
     let query = tcx.dep_graph.query();
 
@@ -261,11 +261,11 @@ pub struct GraphvizDepGraph<'q>(FxHashSet<&'q DepNode>,
 impl<'a, 'tcx, 'q> dot::GraphWalk<'a> for GraphvizDepGraph<'q> {
     type Node = &'q DepNode;
     type Edge = (&'q DepNode, &'q DepNode);
-    fn nodes(&self) -> dot::Nodes<&'q DepNode> {
+    fn nodes(&self) -> dot::Nodes<'_, &'q DepNode> {
         let nodes: Vec<_> = self.0.iter().cloned().collect();
         nodes.into()
     }
-    fn edges(&self) -> dot::Edges<(&'q DepNode, &'q DepNode)> {
+    fn edges(&self) -> dot::Edges<'_, (&'q DepNode, &'q DepNode)> {
         self.1[..].into()
     }
     fn source(&self, edge: &(&'q DepNode, &'q DepNode)) -> &'q DepNode {
@@ -279,10 +279,10 @@ fn target(&self, edge: &(&'q DepNode, &'q DepNode)) -> &'q DepNode {
 impl<'a, 'tcx, 'q> dot::Labeller<'a> for GraphvizDepGraph<'q> {
     type Node = &'q DepNode;
     type Edge = (&'q DepNode, &'q DepNode);
-    fn graph_id(&self) -> dot::Id {
+    fn graph_id(&self) -> dot::Id<'_> {
         dot::Id::new("DependencyGraph").unwrap()
     }
-    fn node_id(&self, n: &&'q DepNode) -> dot::Id {
+    fn node_id(&self, n: &&'q DepNode) -> dot::Id<'_> {
         let s: String =
             format!("{:?}", n).chars()
                               .map(|c| if c == '_' || c.is_alphanumeric() { c } else { '_' })
@@ -290,7 +290,7 @@ fn node_id(&self, n: &&'q DepNode) -> dot::Id {
         debug!("n={:?} s={:?}", n, s);
         dot::Id::new(s).unwrap()
     }
-    fn node_label(&self, n: &&'q DepNode) -> dot::LabelText {
+    fn node_label(&self, n: &&'q DepNode) -> dot::LabelText<'_> {
         dot::LabelText::label(format!("{:?}", n))
     }
 }
index f69a1cfa3a92b64003dfdb61b5326d8a0350c376..346ddaa485804c9914f8cc6fe5c930bf76a36d42 100644 (file)
@@ -7,16 +7,13 @@
 
 #![recursion_limit="256"]
 
-extern crate graphviz;
+#![deny(rust_2018_idioms)]
+
 #[macro_use] extern crate rustc;
-extern crate rustc_data_structures;
-extern crate serialize as rustc_serialize;
-extern crate rand;
-extern crate rustc_fs_util;
+#[allow(unused_extern_crates)]
+extern crate serialize as rustc_serialize; // used by deriving
 
 #[macro_use] extern crate log;
-extern crate syntax;
-extern crate syntax_pos;
 
 mod assert_dep_graph;
 pub mod assert_module_sources;
index 105623e5e4e3c236e7e45703ccc9e584feca4bd8..51f3bcdf7a51cdb3be9a2492f1152112509aa671 100644 (file)
@@ -538,7 +538,7 @@ fn visit_impl_item(&mut self, item: &hir::ImplItem) {
 ///
 /// Also make sure that the `label` and `except` fields do not
 /// both exist.
-fn check_config(tcx: TyCtxt, attr: &Attribute) -> bool {
+fn check_config(tcx: TyCtxt<'_, '_, '_>, attr: &Attribute) -> bool {
     debug!("check_config(attr={:?})", attr);
     let config = &tcx.sess.parse_sess.config;
     debug!("check_config: config={:?}", config);
@@ -573,7 +573,7 @@ fn check_config(tcx: TyCtxt, attr: &Attribute) -> bool {
     }
 }
 
-fn expect_associated_value(tcx: TyCtxt, item: &NestedMetaItem) -> ast::Name {
+fn expect_associated_value(tcx: TyCtxt<'_, '_, '_>, item: &NestedMetaItem) -> ast::Name {
     if let Some(value) = item.value_str() {
         value
     } else {
index f330de71918651b25e830c5bcfc330d7dadf931a..ecf8bc4a88084680ef977697605c7eab0b0196cf 100644 (file)
@@ -9,7 +9,6 @@
 use rustc_serialize::Decodable as RustcDecodable;
 use rustc_serialize::opaque::Decoder;
 use std::path::Path;
-use std;
 
 use super::data::*;
 use super::fs::*;
index bd59f24d04e79857e27d7c8b708747372c1cde97..3aad4f5abb884330459bda4644db04e0642b7865 100644 (file)
 mod work_product;
 mod file_format;
 
-pub use self::fs::finalize_session_directory;
-pub use self::fs::garbage_collect_session_directories;
-pub use self::fs::in_incr_comp_dir;
-pub use self::fs::in_incr_comp_dir_sess;
-pub use self::fs::prepare_session_directory;
-pub use self::load::dep_graph_tcx_init;
-pub use self::load::load_dep_graph;
-pub use self::load::load_query_result_cache;
-pub use self::load::LoadResult;
-pub use self::save::save_dep_graph;
-pub use self::save::save_work_product_index;
-pub use self::work_product::copy_cgu_workproducts_to_incr_comp_cache_dir;
-pub use self::work_product::delete_workproduct_files;
+pub use fs::finalize_session_directory;
+pub use fs::garbage_collect_session_directories;
+pub use fs::in_incr_comp_dir;
+pub use fs::in_incr_comp_dir_sess;
+pub use fs::prepare_session_directory;
+pub use load::dep_graph_tcx_init;
+pub use load::load_dep_graph;
+pub use load::load_query_result_cache;
+pub use load::LoadResult;
+pub use save::save_dep_graph;
+pub use save::save_work_product_index;
+pub use work_product::copy_cgu_workproducts_to_incr_comp_cache_dir;
+pub use work_product::delete_workproduct_files;
index 6a7553b3882975e28d68b589254ae54ea6534bca..34fe2f1c25d0445399e81ac60a6e65990c2c854e 100644 (file)
@@ -129,7 +129,7 @@ fn save_in<F>(sess: &Session, path_buf: PathBuf, encode: F)
     }
 }
 
-fn encode_dep_graph(tcx: TyCtxt,
+fn encode_dep_graph(tcx: TyCtxt<'_, '_, '_>,
                     encoder: &mut Encoder) {
     // First encode the commandline arguments hash
     tcx.sess.opts.dep_tracking_hash().encode(encoder).unwrap();
@@ -234,7 +234,7 @@ fn encode_work_product_index(work_products: &FxHashMap<WorkProductId, WorkProduc
     serialized_products.encode(encoder).unwrap();
 }
 
-fn encode_query_cache(tcx: TyCtxt,
+fn encode_query_cache(tcx: TyCtxt<'_, '_, '_>,
                       encoder: &mut Encoder) {
     time(tcx.sess, "serialize query result cache", || {
         tcx.serialize_query_result_cache(encoder).unwrap();
index 535f6930aa39a1da136d045048527ca409ffb91e..3495b27c5ebca6df5fa02c84c8fb660ad523d1de 100644 (file)
@@ -1,6 +1,6 @@
 //! This module contains files for saving intermediate work-products.
 
-use persist::fs::*;
+use crate::persist::fs::*;
 use rustc::dep_graph::{WorkProduct, WorkProductId, WorkProductFileKind};
 use rustc::session::Session;
 use rustc_fs_util::link_or_copy;
index 7fb7a06ea1ad5fc1d1eee29090469a15c8c90fce..82f7118df2d0b8369252d3778e133a864b498cba 100644 (file)
@@ -2,6 +2,7 @@
 authors = ["The Rust Project Developers"]
 name = "rustc_lint"
 version = "0.0.0"
+edition = "2018"
 
 [lib]
 name = "rustc_lint"
index 7c25d8d8b793f7ccc04e2311fc6a9980006511f5..cbcc7f3574d03e31ce85de59a60d4617aa3d42ee 100644 (file)
@@ -21,6 +21,7 @@
 use rustc::hir::def::Def;
 use rustc::hir::def_id::{DefId, LOCAL_CRATE};
 use rustc::ty::{self, Ty};
+use rustc::{lint, util};
 use hir::Node;
 use util::nodemap::NodeSet;
 use lint::{LateContext, LintContext, LintArray};
 use syntax::errors::{Applicability, DiagnosticBuilder};
 use syntax::print::pprust::expr_to_string;
 use syntax::visit::FnKind;
+use syntax::struct_span_err;
 
 use rustc::hir::{self, GenericParamKind, PatKind};
 
-use nonstandard_style::{MethodLateContext, method_context};
+use crate::nonstandard_style::{MethodLateContext, method_context};
+
+use log::debug;
 
 // hardwired lints from librustc
 pub use lint::builtin::*;
@@ -70,7 +74,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for WhileTrue {
-    fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) {
+    fn check_expr(&mut self, cx: &LateContext<'_, '_>, e: &hir::Expr) {
         if let hir::ExprKind::While(ref cond, ..) = e.node {
             if let hir::ExprKind::Lit(ref lit) = cond.node {
                 if let ast::LitKind::Bool(true) = lit.node {
@@ -102,7 +106,7 @@ fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) {
 pub struct BoxPointers;
 
 impl BoxPointers {
-    fn check_heap_type<'a, 'tcx>(&self, cx: &LateContext, span: Span, ty: Ty) {
+    fn check_heap_type<'a, 'tcx>(&self, cx: &LateContext<'_, '_>, span: Span, ty: Ty<'_>) {
         for leaf_ty in ty.walk() {
             if leaf_ty.is_box() {
                 let m = format!("type uses owned (Box type) pointers: {}", ty);
@@ -123,7 +127,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxPointers {
-    fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
+    fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
         match it.node {
             hir::ItemKind::Fn(..) |
             hir::ItemKind::Ty(..) |
@@ -150,7 +154,7 @@ fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
         }
     }
 
-    fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) {
+    fn check_expr(&mut self, cx: &LateContext<'_, '_>, e: &hir::Expr) {
         let ty = cx.tables.node_id_to_type(e.hir_id);
         self.check_heap_type(cx, e.span, ty);
     }
@@ -176,7 +180,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonShorthandFieldPatterns {
-    fn check_pat(&mut self, cx: &LateContext, pat: &hir::Pat) {
+    fn check_pat(&mut self, cx: &LateContext<'_, '_>, pat: &hir::Pat) {
         if let PatKind::Struct(ref qpath, ref field_pats, _) = pat.node {
             let variant = cx.tables.pat_ty(pat).ty_adt_def()
                                    .expect("struct pattern type is not an ADT")
@@ -233,7 +237,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl UnsafeCode {
-    fn report_unsafe(&self, cx: &EarlyContext, span: Span, desc: &'static str) {
+    fn report_unsafe(&self, cx: &EarlyContext<'_>, span: Span, desc: &'static str) {
         // This comes from a macro that has #[allow_internal_unsafe].
         if span.allows_unsafe() {
             return;
@@ -244,7 +248,7 @@ fn report_unsafe(&self, cx: &EarlyContext, span: Span, desc: &'static str) {
 }
 
 impl EarlyLintPass for UnsafeCode {
-    fn check_attribute(&mut self, cx: &EarlyContext, attr: &ast::Attribute) {
+    fn check_attribute(&mut self, cx: &EarlyContext<'_>, attr: &ast::Attribute) {
         if attr.check_name("allow_internal_unsafe") {
             self.report_unsafe(cx, attr.span, "`allow_internal_unsafe` allows defining \
                                                macros using unsafe without triggering \
@@ -252,7 +256,7 @@ fn check_attribute(&mut self, cx: &EarlyContext, attr: &ast::Attribute) {
         }
     }
 
-    fn check_expr(&mut self, cx: &EarlyContext, e: &ast::Expr) {
+    fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) {
         if let ast::ExprKind::Block(ref blk, _) = e.node {
             // Don't warn about generated blocks, that'll just pollute the output.
             if blk.rules == ast::BlockCheckMode::Unsafe(ast::UserProvided) {
@@ -261,7 +265,7 @@ fn check_expr(&mut self, cx: &EarlyContext, e: &ast::Expr) {
         }
     }
 
-    fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
+    fn check_item(&mut self, cx: &EarlyContext<'_>, it: &ast::Item) {
         match it.node {
             ast::ItemKind::Trait(_, ast::Unsafety::Unsafe, ..) => {
                 self.report_unsafe(cx, it.span, "declaration of an `unsafe` trait")
@@ -276,8 +280,8 @@ fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
     }
 
     fn check_fn(&mut self,
-                cx: &EarlyContext,
-                fk: FnKind,
+                cx: &EarlyContext<'_>,
+                fk: FnKind<'_>,
                 _: &ast::FnDecl,
                 span: Span,
                 _: ast::NodeId) {
@@ -296,7 +300,7 @@ fn check_fn(&mut self,
         }
     }
 
-    fn check_trait_item(&mut self, cx: &EarlyContext, item: &ast::TraitItem) {
+    fn check_trait_item(&mut self, cx: &EarlyContext<'_>, item: &ast::TraitItem) {
         if let ast::TraitItemKind::Method(ref sig, None) = item.node {
             if sig.header.unsafety == ast::Unsafety::Unsafe {
                 self.report_unsafe(cx, item.span, "declaration of an `unsafe` method")
@@ -354,7 +358,7 @@ fn doc_hidden(&self) -> bool {
     }
 
     fn check_missing_docs_attrs(&self,
-                                cx: &LateContext,
+                                cx: &LateContext<'_, '_>,
                                 id: Option<ast::NodeId>,
                                 attrs: &[ast::Attribute],
                                 sp: Span,
@@ -399,7 +403,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
-    fn enter_lint_attrs(&mut self, _: &LateContext, attrs: &[ast::Attribute]) {
+    fn enter_lint_attrs(&mut self, _: &LateContext<'_, '_>, attrs: &[ast::Attribute]) {
         let doc_hidden = self.doc_hidden() ||
                          attrs.iter().any(|attr| {
             attr.check_name("doc") &&
@@ -411,11 +415,11 @@ fn enter_lint_attrs(&mut self, _: &LateContext, attrs: &[ast::Attribute]) {
         self.doc_hidden_stack.push(doc_hidden);
     }
 
-    fn exit_lint_attrs(&mut self, _: &LateContext, _attrs: &[ast::Attribute]) {
+    fn exit_lint_attrs(&mut self, _: &LateContext<'_, '_>, _attrs: &[ast::Attribute]) {
         self.doc_hidden_stack.pop().expect("empty doc_hidden_stack");
     }
 
-    fn check_crate(&mut self, cx: &LateContext, krate: &hir::Crate) {
+    fn check_crate(&mut self, cx: &LateContext<'_, '_>, krate: &hir::Crate) {
         self.check_missing_docs_attrs(cx, None, &krate.attrs, krate.span, "crate");
 
         for macro_def in &krate.exported_macros {
@@ -428,7 +432,7 @@ fn check_crate(&mut self, cx: &LateContext, krate: &hir::Crate) {
         }
     }
 
-    fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
+    fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
         let desc = match it.node {
             hir::ItemKind::Fn(..) => "a function",
             hir::ItemKind::Mod(..) => "a module",
@@ -473,7 +477,7 @@ fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
         self.check_missing_docs_attrs(cx, Some(it.id), &it.attrs, it.span, desc);
     }
 
-    fn check_trait_item(&mut self, cx: &LateContext, trait_item: &hir::TraitItem) {
+    fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, trait_item: &hir::TraitItem) {
         if self.private_traits.contains(&trait_item.id) {
             return;
         }
@@ -491,7 +495,7 @@ fn check_trait_item(&mut self, cx: &LateContext, trait_item: &hir::TraitItem) {
                                       desc);
     }
 
-    fn check_impl_item(&mut self, cx: &LateContext, impl_item: &hir::ImplItem) {
+    fn check_impl_item(&mut self, cx: &LateContext<'_, '_>, impl_item: &hir::ImplItem) {
         // If the method is an impl for a trait, don't doc.
         if method_context(cx, impl_item.id) == MethodLateContext::TraitImpl {
             return;
@@ -510,7 +514,7 @@ fn check_impl_item(&mut self, cx: &LateContext, impl_item: &hir::ImplItem) {
                                       desc);
     }
 
-    fn check_struct_field(&mut self, cx: &LateContext, sf: &hir::StructField) {
+    fn check_struct_field(&mut self, cx: &LateContext<'_, '_>, sf: &hir::StructField) {
         if !sf.is_positional() {
             self.check_missing_docs_attrs(cx,
                                           Some(sf.id),
@@ -520,7 +524,7 @@ fn check_struct_field(&mut self, cx: &LateContext, sf: &hir::StructField) {
         }
     }
 
-    fn check_variant(&mut self, cx: &LateContext, v: &hir::Variant, _: &hir::Generics) {
+    fn check_variant(&mut self, cx: &LateContext<'_, '_>, v: &hir::Variant, _: &hir::Generics) {
         self.check_missing_docs_attrs(cx,
                                       Some(v.node.data.id()),
                                       &v.node.attrs,
@@ -549,7 +553,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingCopyImplementations {
-    fn check_item(&mut self, cx: &LateContext, item: &hir::Item) {
+    fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) {
         if !cx.access_levels.is_reachable(item.id) {
             return;
         }
@@ -620,7 +624,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDebugImplementations {
-    fn check_item(&mut self, cx: &LateContext, item: &hir::Item) {
+    fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) {
         if !cx.access_levels.is_reachable(item.id) {
             return;
         }
@@ -681,7 +685,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl EarlyLintPass for AnonymousParameters {
-    fn check_trait_item(&mut self, cx: &EarlyContext, it: &ast::TraitItem) {
+    fn check_trait_item(&mut self, cx: &EarlyContext<'_>, it: &ast::TraitItem) {
         match it.node {
             ast::TraitItemKind::Method(ref sig, _) => {
                 for arg in sig.decl.inputs.iter() {
@@ -749,7 +753,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl EarlyLintPass for DeprecatedAttr {
-    fn check_attribute(&mut self, cx: &EarlyContext, attr: &ast::Attribute) {
+    fn check_attribute(&mut self, cx: &EarlyContext<'_>, attr: &ast::Attribute) {
         for &&(n, _, _, ref g) in &self.depr_attrs {
             if attr.name() == n {
                 if let &AttributeGate::Gated(Stability::Deprecated(link, suggestion),
@@ -804,15 +808,15 @@ fn warn_if_doc<'a, 'tcx,
 }
 
 impl EarlyLintPass for UnusedDocComment {
-    fn check_local(&mut self, cx: &EarlyContext, decl: &ast::Local) {
+    fn check_local(&mut self, cx: &EarlyContext<'_>, decl: &ast::Local) {
         self.warn_if_doc(decl.attrs.iter(), cx);
     }
 
-    fn check_arm(&mut self, cx: &EarlyContext, arm: &ast::Arm) {
+    fn check_arm(&mut self, cx: &EarlyContext<'_>, arm: &ast::Arm) {
         self.warn_if_doc(arm.attrs.iter(), cx);
     }
 
-    fn check_expr(&mut self, cx: &EarlyContext, expr: &ast::Expr) {
+    fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &ast::Expr) {
         self.warn_if_doc(expr.attrs.iter(), cx);
     }
 }
@@ -837,7 +841,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PluginAsLibrary {
-    fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
+    fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
         if cx.tcx.plugin_registrar_fn(LOCAL_CRATE).is_some() {
             // We're compiling a plugin; it's fine to link other plugins.
             return;
@@ -894,7 +898,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidNoMangleItems {
-    fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
+    fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
         match it.node {
             hir::ItemKind::Fn(.., ref generics, _) => {
                 if let Some(no_mangle_attr) = attr::find_by_name(&it.attrs, "no_mangle") {
@@ -968,7 +972,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableTransmutes {
-    fn check_expr(&mut self, cx: &LateContext, expr: &hir::Expr) {
+    fn check_expr(&mut self, cx: &LateContext<'_, '_>, expr: &hir::Expr) {
         use rustc_target::spec::abi::Abi::RustIntrinsic;
 
         let msg = "mutating transmuted &mut T from &T may cause undefined behavior, \
@@ -1004,7 +1008,7 @@ fn get_transmute_from_to<'a, 'tcx>
             None
         }
 
-        fn def_id_is_transmute(cx: &LateContext, def_id: DefId) -> bool {
+        fn def_id_is_transmute(cx: &LateContext<'_, '_>, def_id: DefId) -> bool {
             cx.tcx.fn_sig(def_id).abi() == RustIntrinsic &&
             cx.tcx.item_name(def_id) == "transmute"
         }
@@ -1032,7 +1036,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnstableFeatures {
-    fn check_attribute(&mut self, ctx: &LateContext, attr: &ast::Attribute) {
+    fn check_attribute(&mut self, ctx: &LateContext<'_, '_>, attr: &ast::Attribute) {
         if attr.check_name("feature") {
             if let Some(items) = attr.meta_item_list() {
                 for item in items {
@@ -1063,7 +1067,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnionsWithDropFields {
-    fn check_item(&mut self, ctx: &LateContext, item: &hir::Item) {
+    fn check_item(&mut self, ctx: &LateContext<'_, '_>, item: &hir::Item) {
         if let hir::ItemKind::Union(ref vdata, _) = item.node {
             for field in vdata.fields() {
                 let field_ty = ctx.tcx.type_of(ctx.tcx.hir().local_def_id(field.id));
@@ -1099,7 +1103,7 @@ 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: ast::NodeId,
                     vis: &hir::Visibility, span: Span, exportable: bool) {
         let mut applicability = Applicability::MachineApplicable;
         match vis.node {
@@ -1134,20 +1138,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) {
+    fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) {
         self.perform_lint(cx, "item", item.id, &item.vis, item.span, true);
     }
 
-    fn check_foreign_item(&mut self, cx: &LateContext, foreign_item: &hir::ForeignItem) {
+    fn check_foreign_item(&mut self, cx: &LateContext<'_, '_>, foreign_item: &hir::ForeignItem) {
         self.perform_lint(cx, "item", foreign_item.id, &foreign_item.vis,
                           foreign_item.span, true);
     }
 
-    fn check_struct_field(&mut self, cx: &LateContext, field: &hir::StructField) {
+    fn check_struct_field(&mut self, cx: &LateContext<'_, '_>, field: &hir::StructField) {
         self.perform_lint(cx, "field", field.id, &field.vis, field.span, false);
     }
 
-    fn check_impl_item(&mut self, cx: &LateContext, impl_item: &hir::ImplItem) {
+    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);
     }
 }
@@ -1193,7 +1197,7 @@ fn is_type_variable_assoc(qpath: &hir::QPath) -> bool {
         }
     }
 
-    fn suggest_changing_assoc_types(ty: &hir::Ty, err: &mut DiagnosticBuilder) {
+    fn suggest_changing_assoc_types(ty: &hir::Ty, err: &mut DiagnosticBuilder<'_>) {
         // Access to associates types should use `<T as Bound>::Assoc`, which does not need a
         // bound.  Let's see if this type does that.
 
@@ -1225,7 +1229,7 @@ fn visit_qpath(&mut self, qpath: &'v hir::QPath, id: hir::HirId, span: Span) {
 }
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeAliasBounds {
-    fn check_item(&mut self, cx: &LateContext, item: &hir::Item) {
+    fn check_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::Item) {
         let (ty, type_alias_generics) = match item.node {
             hir::ItemKind::Ty(ref ty, ref generics) => (&*ty, generics),
             _ => return,
@@ -1281,7 +1285,7 @@ fn get_lints(&self) -> LintArray {
         lint_array!()
     }
 }
-fn check_const(cx: &LateContext, body_id: hir::BodyId) {
+fn check_const(cx: &LateContext<'_, '_>, body_id: hir::BodyId) {
     let def_id = cx.tcx.hir().body_owner_def_id(body_id);
     let is_static = cx.tcx.is_static(def_id).is_some();
     let param_env = if is_static {
@@ -1299,7 +1303,7 @@ fn check_const(cx: &LateContext, body_id: hir::BodyId) {
 }
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedBrokenConst {
-    fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
+    fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
         match it.node {
             hir::ItemKind::Const(_, body_id) => {
                 check_const(cx, body_id);
@@ -1429,7 +1433,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl EarlyLintPass for EllipsisInclusiveRangePatterns {
-    fn check_pat(&mut self, cx: &EarlyContext, pat: &ast::Pat, visit_subpats: &mut bool) {
+    fn check_pat(&mut self, cx: &EarlyContext<'_>, pat: &ast::Pat, visit_subpats: &mut bool) {
         use self::ast::{PatKind, RangeEnd, RangeSyntax::DotDotDot};
 
         /// If `pat` is a `...` pattern, return the start and end of the range, as well as the span
@@ -1507,7 +1511,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnameableTestItems {
-    fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
+    fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
         if self.items_nameable {
             if let hir::ItemKind::Mod(..) = it.node {}
             else {
@@ -1526,7 +1530,7 @@ fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
         }
     }
 
-    fn check_item_post(&mut self, _cx: &LateContext, it: &hir::Item) {
+    fn check_item_post(&mut self, _cx: &LateContext<'_, '_>, it: &hir::Item) {
         if !self.items_nameable && self.boundary == it.id {
             self.items_nameable = true;
         }
@@ -1554,7 +1558,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl KeywordIdents {
-    fn check_tokens(&mut self, cx: &EarlyContext, tokens: TokenStream) {
+    fn check_tokens(&mut self, cx: &EarlyContext<'_>, tokens: TokenStream) {
         for tt in tokens.into_trees() {
             match tt {
                 TokenTree::Token(span, tok) => match tok.ident() {
@@ -1576,13 +1580,13 @@ fn check_tokens(&mut self, cx: &EarlyContext, tokens: TokenStream) {
 }
 
 impl EarlyLintPass for KeywordIdents {
-    fn check_mac_def(&mut self, cx: &EarlyContext, mac_def: &ast::MacroDef, _id: ast::NodeId) {
+    fn check_mac_def(&mut self, cx: &EarlyContext<'_>, mac_def: &ast::MacroDef, _id: ast::NodeId) {
         self.check_tokens(cx, mac_def.stream());
     }
-    fn check_mac(&mut self, cx: &EarlyContext, mac: &ast::Mac) {
+    fn check_mac(&mut self, cx: &EarlyContext<'_>, mac: &ast::Mac) {
         self.check_tokens(cx, mac.node.tts.clone().into());
     }
-    fn check_ident(&mut self, cx: &EarlyContext, ident: ast::Ident) {
+    fn check_ident(&mut self, cx: &EarlyContext<'_>, ident: ast::Ident) {
         let ident_str = &ident.as_str()[..];
         let cur_edition = cx.sess.edition();
         let is_raw_ident = |ident: ast::Ident| {
@@ -1665,7 +1669,7 @@ fn get_lints(&self) -> LintArray {
 impl ExplicitOutlivesRequirements {
     fn collect_outlives_bound_spans(
         &self,
-        cx: &LateContext,
+        cx: &LateContext<'_, '_>,
         item_def_id: DefId,
         param_name: &str,
         bounds: &hir::GenericBounds,
index 9a608e4fef08b8e13540b2f61a30710a4b2574ba..3165673111cca008363c69ef5425f4ffeec33c60 100644 (file)
@@ -1,3 +1,5 @@
+use syntax::{register_diagnostic, register_diagnostics};
+
 register_diagnostics! {
     E0721, // `await` keyword
 }
index fd5e68d5ae60a5fb5367b82428242a1cd6bb9677..5c243e13890731a8185141f35247b28b4626790b 100644 (file)
 
 #![recursion_limit="256"]
 
-#[macro_use]
-extern crate syntax;
+#![deny(rust_2018_idioms)]
+
 #[macro_use]
 extern crate rustc;
-#[macro_use]
-extern crate log;
-extern crate rustc_target;
-extern crate syntax_pos;
-extern crate rustc_data_structures;
 
 mod diagnostics;
 mod nonstandard_style;
@@ -49,7 +44,6 @@
     parser::ILL_FORMED_ATTRIBUTE_INPUT,
 };
 use rustc::session;
-use rustc::util;
 use rustc::hir;
 
 use syntax::ast;
@@ -354,6 +348,11 @@ macro_rules! register_passes {
             reference: "issue #57644 <https://github.com/rust-lang/rust/issues/57644>",
             edition: None,
         },
+        FutureIncompatibleInfo {
+            id: LintId::of(DUPLICATE_MATCHER_BINDING_NAME),
+            reference: "issue #57593 <https://github.com/rust-lang/rust/issues/57593>",
+            edition: None,
+        },
         ]);
 
     // Register renamed and removed lints.
index ae2ed28104e5b4a5aab9b91b1118eb0cc9f7605c..2dbafc7ede2a22a33688729aad6d5cbe462abb36 100644 (file)
@@ -1,6 +1,7 @@
 use rustc::hir::{self, GenericParamKind, PatKind};
 use rustc::hir::def::Def;
 use rustc::hir::intravisit::FnKind;
+use rustc::lint;
 use rustc::ty;
 use rustc_target::spec::abi::Abi;
 use lint::{EarlyContext, LateContext, LintContext, LintArray};
@@ -17,7 +18,7 @@ pub enum MethodLateContext {
     PlainImpl,
 }
 
-pub fn method_context(cx: &LateContext, id: ast::NodeId) -> MethodLateContext {
+pub fn method_context(cx: &LateContext<'_, '_>, id: ast::NodeId) -> MethodLateContext {
     let def_id = cx.tcx.hir().local_def_id(id);
     let item = cx.tcx.associated_item(def_id);
     match item.container {
@@ -41,7 +42,7 @@ pub fn method_context(cx: &LateContext, id: ast::NodeId) -> MethodLateContext {
 pub struct NonCamelCaseTypes;
 
 impl NonCamelCaseTypes {
-    fn check_case(&self, cx: &EarlyContext, sort: &str, ident: &Ident) {
+    fn check_case(&self, cx: &EarlyContext<'_>, sort: &str, ident: &Ident) {
         fn char_has_case(c: char) -> bool {
             c.is_lowercase() || c.is_uppercase()
         }
@@ -115,7 +116,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl EarlyLintPass for NonCamelCaseTypes {
-    fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
+    fn check_item(&mut self, cx: &EarlyContext<'_>, it: &ast::Item) {
         let has_repr_c = it.attrs
             .iter()
             .any(|attr| {
@@ -138,11 +139,11 @@ fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
         }
     }
 
-    fn check_variant(&mut self, cx: &EarlyContext, v: &ast::Variant, _: &ast::Generics) {
+    fn check_variant(&mut self, cx: &EarlyContext<'_>, v: &ast::Variant, _: &ast::Generics) {
         self.check_case(cx, "variant", &v.node.ident);
     }
 
-    fn check_generic_param(&mut self, cx: &EarlyContext, param: &ast::GenericParam) {
+    fn check_generic_param(&mut self, cx: &EarlyContext<'_>, param: &ast::GenericParam) {
         if let ast::GenericParamKind::Type { .. } = param.kind {
             self.check_case(cx, "type parameter", &param.ident);
         }
@@ -190,7 +191,7 @@ fn to_snake_case(mut str: &str) -> String {
     }
 
     /// Checks if a given identifier is snake case, and reports a diagnostic if not.
-    fn check_snake_case(&self, cx: &LateContext, sort: &str, ident: &Ident) {
+    fn check_snake_case(&self, cx: &LateContext<'_, '_>, sort: &str, ident: &Ident) {
         fn is_snake_case(ident: &str) -> bool {
             if ident.is_empty() {
                 return true;
@@ -249,7 +250,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase {
-    fn check_crate(&mut self, cx: &LateContext, cr: &hir::Crate) {
+    fn check_crate(&mut self, cx: &LateContext<'_, '_>, cr: &hir::Crate) {
         let crate_ident = if let Some(name) = &cx.tcx.sess.opts.crate_name {
             Some(Ident::from_str(name))
         } else {
@@ -286,7 +287,7 @@ fn check_crate(&mut self, cx: &LateContext, cr: &hir::Crate) {
         }
     }
 
-    fn check_generic_param(&mut self, cx: &LateContext, param: &hir::GenericParam) {
+    fn check_generic_param(&mut self, cx: &LateContext<'_, '_>, param: &hir::GenericParam) {
         if let GenericParamKind::Lifetime { .. } = param.kind {
             self.check_snake_case(cx, "lifetime", &param.name.ident());
         }
@@ -294,8 +295,8 @@ fn check_generic_param(&mut self, cx: &LateContext, param: &hir::GenericParam) {
 
     fn check_fn(
         &mut self,
-        cx: &LateContext,
-        fk: FnKind,
+        cx: &LateContext<'_, '_>,
+        fk: FnKind<'_>,
         _: &hir::FnDecl,
         _: &hir::Body,
         _: Span,
@@ -324,13 +325,13 @@ fn check_fn(
         }
     }
 
-    fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
+    fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
         if let hir::ItemKind::Mod(_) = it.node {
             self.check_snake_case(cx, "module", &it.ident);
         }
     }
 
-    fn check_trait_item(&mut self, cx: &LateContext, item: &hir::TraitItem) {
+    fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, item: &hir::TraitItem) {
         if let hir::TraitItemKind::Method(_, hir::TraitMethod::Required(pnames)) = &item.node {
             self.check_snake_case(cx, "trait method", &item.ident);
             for param_name in pnames {
@@ -339,7 +340,7 @@ fn check_trait_item(&mut self, cx: &LateContext, item: &hir::TraitItem) {
         }
     }
 
-    fn check_pat(&mut self, cx: &LateContext, p: &hir::Pat) {
+    fn check_pat(&mut self, cx: &LateContext<'_, '_>, p: &hir::Pat) {
         if let &PatKind::Binding(_, _, _, ident, _) = &p.node {
             self.check_snake_case(cx, "variable", &ident);
         }
@@ -347,7 +348,7 @@ fn check_pat(&mut self, cx: &LateContext, p: &hir::Pat) {
 
     fn check_struct_def(
         &mut self,
-        cx: &LateContext,
+        cx: &LateContext<'_, '_>,
         s: &hir::VariantData,
         _: ast::Name,
         _: &hir::Generics,
@@ -369,7 +370,7 @@ fn check_struct_def(
 pub struct NonUpperCaseGlobals;
 
 impl NonUpperCaseGlobals {
-    fn check_upper_case(cx: &LateContext, sort: &str, ident: &Ident) {
+    fn check_upper_case(cx: &LateContext<'_, '_>, sort: &str, ident: &Ident) {
         let name = &ident.name.as_str();
 
         if name.chars().any(|c| c.is_lowercase()) {
@@ -399,7 +400,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonUpperCaseGlobals {
-    fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
+    fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
         match it.node {
             hir::ItemKind::Static(..) if !attr::contains_name(&it.attrs, "no_mangle") => {
                 NonUpperCaseGlobals::check_upper_case(cx, "static variable", &it.ident);
@@ -411,19 +412,19 @@ fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
         }
     }
 
-    fn check_trait_item(&mut self, cx: &LateContext, ti: &hir::TraitItem) {
+    fn check_trait_item(&mut self, cx: &LateContext<'_, '_>, ti: &hir::TraitItem) {
         if let hir::TraitItemKind::Const(..) = ti.node {
             NonUpperCaseGlobals::check_upper_case(cx, "associated constant", &ti.ident);
         }
     }
 
-    fn check_impl_item(&mut self, cx: &LateContext, ii: &hir::ImplItem) {
+    fn check_impl_item(&mut self, cx: &LateContext<'_, '_>, ii: &hir::ImplItem) {
         if let hir::ImplItemKind::Const(..) = ii.node {
             NonUpperCaseGlobals::check_upper_case(cx, "associated constant", &ii.ident);
         }
     }
 
-    fn check_pat(&mut self, cx: &LateContext, p: &hir::Pat) {
+    fn check_pat(&mut self, cx: &LateContext<'_, '_>, p: &hir::Pat) {
         // Lint for constants that look like binding identifiers (#7526)
         if let PatKind::Path(hir::QPath::Resolved(None, ref path)) = p.node {
             if let Def::Const(..) = path.def {
index 4abd55b7e31f7d3cda737e4f41e935f08cd7e373..f6b7ccfe2ecd8de9d0cc23e7bfcb9f1fae2eda4b 100644 (file)
@@ -4,6 +4,7 @@
 use rustc::ty::subst::Substs;
 use rustc::ty::{self, AdtKind, ParamEnv, Ty, TyCtxt};
 use rustc::ty::layout::{self, IntegerExt, LayoutOf, VariantIdx};
+use rustc::{lint, util};
 use rustc_data_structures::indexed_vec::Idx;
 use util::nodemap::FxHashSet;
 use lint::{LateContext, LintContext, LintArray};
@@ -23,6 +24,8 @@
 
 use rustc::mir::interpret::{sign_extend, truncate};
 
+use log::debug;
+
 declare_lint! {
     UNUSED_COMPARISONS,
     Warn,
@@ -241,7 +244,7 @@ fn uint_ty_range(uint_ty: ast::UintTy) -> (u128, u128) {
             }
         }
 
-        fn check_limits(cx: &LateContext,
+        fn check_limits(cx: &LateContext<'_, '_>,
                         binop: hir::BinOp,
                         l: &hir::Expr,
                         r: &hir::Expr)
@@ -298,7 +301,7 @@ fn is_comparison(binop: hir::BinOp) -> bool {
             }
         }
 
-        fn get_bin_hex_repr(cx: &LateContext, lit: &ast::Lit) -> Option<String> {
+        fn get_bin_hex_repr(cx: &LateContext<'_, '_>, lit: &ast::Lit) -> Option<String> {
             let src = cx.sess().source_map().span_to_snippet(lit.span).ok()?;
             let firstch = src.chars().next()?;
 
@@ -320,7 +323,7 @@ fn get_bin_hex_repr(cx: &LateContext, lit: &ast::Lit) -> Option<String> {
         //
         // No suggestion for: `isize`, `usize`.
         fn get_type_suggestion<'a>(
-            t: &ty::TyKind,
+            t: &ty::TyKind<'_>,
             val: u128,
             negative: bool,
         ) -> Option<String> {
@@ -364,9 +367,9 @@ macro_rules! find_fit {
         }
 
         fn report_bin_hex_error(
-            cx: &LateContext,
+            cx: &LateContext<'_, '_>,
             expr: &hir::Expr,
-            ty: ty::TyKind,
+            ty: ty::TyKind<'_>,
             repr_str: String,
             val: u128,
             negative: bool,
@@ -481,7 +484,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
     fn check_type_for_ffi(&self,
                           cache: &mut FxHashSet<Ty<'tcx>>,
                           ty: Ty<'tcx>) -> FfiResult<'tcx> {
-        use self::FfiResult::*;
+        use FfiResult::*;
 
         let cx = self.cx.tcx;
 
@@ -799,7 +802,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ImproperCTypes {
-    fn check_foreign_item(&mut self, cx: &LateContext, it: &hir::ForeignItem) {
+    fn check_foreign_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::ForeignItem) {
         let mut vis = ImproperCTypesVisitor { cx };
         let abi = cx.tcx.hir().get_foreign_abi(it.id);
         if abi != Abi::RustIntrinsic && abi != Abi::PlatformIntrinsic {
@@ -829,7 +832,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for VariantSizeDifferences {
-    fn check_item(&mut self, cx: &LateContext, it: &hir::Item) {
+    fn check_item(&mut self, cx: &LateContext<'_, '_>, it: &hir::Item) {
         if let hir::ItemKind::Enum(ref enum_definition, _) = it.node {
             let item_def_id = cx.tcx.hir().local_def_id(it.id);
             let t = cx.tcx.type_of(item_def_id);
index acf5da1e1886aa8820e241b78e0a1e7d86718808..407e6842935151b355441a8dc335da4a467c7d54 100644 (file)
@@ -1,5 +1,6 @@
 use rustc::hir::def::Def;
 use rustc::hir::def_id::DefId;
+use rustc::lint;
 use rustc::ty;
 use rustc::ty::adjustment;
 use lint::{LateContext, EarlyContext, LintContext, LintArray};
@@ -16,6 +17,8 @@
 
 use rustc::hir;
 
+use log::debug;
+
 declare_lint! {
     pub UNUSED_MUST_USE,
     Warn,
@@ -43,7 +46,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
-    fn check_stmt(&mut self, cx: &LateContext, s: &hir::Stmt) {
+    fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt) {
         let expr = match s.node {
             hir::StmtKind::Semi(ref expr) => &**expr,
             _ => return,
@@ -168,7 +171,7 @@ fn check_stmt(&mut self, cx: &LateContext, s: &hir::Stmt) {
         }
 
         fn check_must_use(
-            cx: &LateContext,
+            cx: &LateContext<'_, '_>,
             def_id: DefId,
             sp: Span,
             descr_pre_path: &str,
@@ -212,7 +215,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for PathStatements {
-    fn check_stmt(&mut self, cx: &LateContext, s: &hir::Stmt) {
+    fn check_stmt(&mut self, cx: &LateContext<'_, '_>, s: &hir::Stmt) {
         if let hir::StmtKind::Semi(ref expr) = s.node {
             if let hir::ExprKind::Path(_) = expr.node {
                 cx.span_lint(PATH_STATEMENTS, s.span, "path statement with no effect");
@@ -241,7 +244,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAttributes {
-    fn check_attribute(&mut self, cx: &LateContext, attr: &ast::Attribute) {
+    fn check_attribute(&mut self, cx: &LateContext<'_, '_>, attr: &ast::Attribute) {
         debug!("checking attribute: {:?}", attr);
         // Note that check_name() marks the attribute as used if it matches.
         for &(name, ty, ..) in BUILTIN_ATTRIBUTES {
@@ -303,7 +306,7 @@ fn check_attribute(&mut self, cx: &LateContext, attr: &ast::Attribute) {
 
 impl UnusedParens {
     fn check_unused_parens_expr(&self,
-                                cx: &EarlyContext,
+                                cx: &EarlyContext<'_>,
                                 value: &ast::Expr,
                                 msg: &str,
                                 followed_by_block: bool) {
@@ -325,7 +328,7 @@ fn check_unused_parens_expr(&self,
     }
 
     fn check_unused_parens_pat(&self,
-                                cx: &EarlyContext,
+                                cx: &EarlyContext<'_>,
                                 value: &ast::Pat,
                                 msg: &str) {
         if let ast::PatKind::Paren(_) = value.node {
@@ -339,7 +342,7 @@ fn check_unused_parens_pat(&self,
         }
     }
 
-    fn remove_outer_parens(cx: &EarlyContext, span: Span, pattern: &str, msg: &str) {
+    fn remove_outer_parens(cx: &EarlyContext<'_>, span: Span, pattern: &str, msg: &str) {
         let span_msg = format!("unnecessary parentheses around {}", msg);
         let mut err = cx.struct_span_lint(UNUSED_PARENS, span, &span_msg);
         let mut ate_left_paren = false;
@@ -387,7 +390,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl EarlyLintPass for UnusedParens {
-    fn check_expr(&mut self, cx: &EarlyContext, e: &ast::Expr) {
+    fn check_expr(&mut self, cx: &EarlyContext<'_>, e: &ast::Expr) {
         use syntax::ast::ExprKind::*;
         let (value, msg, followed_by_block) = match e.node {
             If(ref cond, ..) => (cond, "`if` condition", true),
@@ -429,7 +432,7 @@ fn check_expr(&mut self, cx: &EarlyContext, e: &ast::Expr) {
         self.check_unused_parens_expr(cx, &value, msg, followed_by_block);
     }
 
-    fn check_pat(&mut self, cx: &EarlyContext, p: &ast::Pat, _: &mut bool) {
+    fn check_pat(&mut self, cx: &EarlyContext<'_>, p: &ast::Pat, _: &mut bool) {
         use ast::PatKind::{Paren, Range};
         // The lint visitor will visit each subpattern of `p`. We do not want to lint any range
         // pattern no matter where it occurs in the pattern. For something like `&(a..=b)`, there
@@ -443,7 +446,7 @@ fn check_pat(&mut self, cx: &EarlyContext, p: &ast::Pat, _: &mut bool) {
         }
     }
 
-    fn check_stmt(&mut self, cx: &EarlyContext, s: &ast::Stmt) {
+    fn check_stmt(&mut self, cx: &EarlyContext<'_>, s: &ast::Stmt) {
         if let ast::StmtKind::Local(ref local) = s.node {
             if let Some(ref value) = local.init {
                 self.check_unused_parens_expr(cx, &value, "assigned value", false);
@@ -462,7 +465,7 @@ fn check_stmt(&mut self, cx: &EarlyContext, s: &ast::Stmt) {
 pub struct UnusedImportBraces;
 
 impl UnusedImportBraces {
-    fn check_use_tree(&self, cx: &EarlyContext, use_tree: &ast::UseTree, item: &ast::Item) {
+    fn check_use_tree(&self, cx: &EarlyContext<'_>, use_tree: &ast::UseTree, item: &ast::Item) {
         if let ast::UseTreeKind::Nested(ref items) = use_tree.kind {
             // Recursively check nested UseTrees
             for &(ref tree, _) in items {
@@ -509,7 +512,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl EarlyLintPass for UnusedImportBraces {
-    fn check_item(&mut self, cx: &EarlyContext, item: &ast::Item) {
+    fn check_item(&mut self, cx: &EarlyContext<'_>, item: &ast::Item) {
         if let ast::ItemKind::Use(ref use_tree) = item.node {
             self.check_use_tree(cx, use_tree, item);
         }
@@ -536,7 +539,7 @@ fn get_lints(&self) -> LintArray {
 }
 
 impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAllocation {
-    fn check_expr(&mut self, cx: &LateContext, e: &hir::Expr) {
+    fn check_expr(&mut self, cx: &LateContext<'_, '_>, e: &hir::Expr) {
         match e.node {
             hir::ExprKind::Box(_) => {}
             _ => return,
index 337c87c24ba2b2ae0483d58576e722079fe86cbd..e234f4f88070382f99d9c9a85dcb9d8f2018f8bd 100644 (file)
@@ -2,6 +2,7 @@
 authors = ["The Rust Project Developers"]
 name = "rustc_metadata"
 version = "0.0.0"
+edition = "2018"
 
 [lib]
 name = "rustc_metadata"
@@ -14,7 +15,7 @@ log = "0.4"
 memmap = "0.6"
 rustc = { path = "../librustc" }
 rustc_data_structures = { path = "../librustc_data_structures" }
-rustc_errors = { path = "../librustc_errors" }
+errors = { path = "../librustc_errors", package = "rustc_errors" }
 rustc_target = { path = "../librustc_target" }
 serialize = { path = "../libserialize" }
 stable_deref_trait = "1.0.0"
index e9785e7c88d0d845b9fdb0dbea4a4a3d154edb7e..0b4c8a5367c15b7fe8bc4c4273ccbda231ae7d66 100644 (file)
@@ -1,9 +1,9 @@
 //! Validates all used crates and extern libraries and loads their metadata
 
-use cstore::{self, CStore, CrateSource, MetadataBlob};
-use locator::{self, CratePaths};
-use decoder::proc_macro_def_path_table;
-use schema::CrateRoot;
+use crate::cstore::{self, CStore, CrateSource, MetadataBlob};
+use crate::locator::{self, CratePaths};
+use crate::decoder::proc_macro_def_path_table;
+use crate::schema::CrateRoot;
 use rustc_data_structures::sync::{Lrc, RwLock, Lock};
 
 use rustc::hir::def_id::CrateNum;
@@ -29,8 +29,9 @@
 use syntax::ext::base::SyntaxExtension;
 use syntax::symbol::Symbol;
 use syntax::visit;
+use syntax::{span_err, span_fatal};
 use syntax_pos::{Span, DUMMY_SP};
-use log;
+use log::{debug, info, log_enabled};
 
 pub struct Library {
     pub dylib: Option<(PathBuf, PathKind)>,
@@ -342,7 +343,7 @@ fn resolve_crate<'b>(
         }
     }
 
-    fn load(&mut self, locate_ctxt: &mut locator::Context) -> Option<LoadResult> {
+    fn load(&mut self, locate_ctxt: &mut locator::Context<'_>) -> Option<LoadResult> {
         let library = locate_ctxt.maybe_load_library_crate()?;
 
         // In the case that we're loading a crate, but not matching
@@ -427,7 +428,7 @@ fn resolve_crate_deps(&mut self,
         // The map from crate numbers in the crate we're resolving to local crate numbers.
         // We map 0 and all other holes in the map to our parent crate. The "additional"
         // self-dependencies should be harmless.
-        ::std::iter::once(krate).chain(crate_root.crate_deps
+        std::iter::once(krate).chain(crate_root.crate_deps
                                                  .decode(metadata)
                                                  .map(|dep| {
             info!("resolving dep crate {} hash: `{}` extra filename: `{}`", dep.name, dep.hash,
@@ -522,7 +523,7 @@ fn read_extension_crate(&mut self, span: Span, orig_name: Symbol, rename: Symbol
     fn load_derive_macros(&mut self, root: &CrateRoot, dylib: Option<PathBuf>, span: Span)
                           -> Vec<(ast::Name, Lrc<SyntaxExtension>)> {
         use std::{env, mem};
-        use dynamic_lib::DynamicLibrary;
+        use crate::dynamic_lib::DynamicLibrary;
         use proc_macro::bridge::client::ProcMacro;
         use syntax_ext::deriving::custom::ProcMacroDerive;
         use syntax_ext::proc_macro_impl::{AttrProcMacro, BangProcMacro};
@@ -996,7 +997,7 @@ pub fn process_extern_crate(
                        item.ident, orig_name);
                 let orig_name = match orig_name {
                     Some(orig_name) => {
-                        ::validate_crate_name(Some(self.sess), &orig_name.as_str(),
+                        crate::validate_crate_name(Some(self.sess), &orig_name.as_str(),
                                             Some(item.span));
                         orig_name
                     }
index 543fb5d5df5be57bb1907a2a6fc675f1d8291b92..a2f69bc45634dfe56689a0af428cd5413f2a02a1 100644 (file)
@@ -1,7 +1,7 @@
 // The crate store - a central repo for information collected about external
 // crates and libraries
 
-use schema;
+use crate::schema;
 use rustc::hir::def_id::{CrateNum, DefIndex};
 use rustc::hir::map::definitions::DefPathTable;
 use rustc::middle::cstore::{DepKind, ExternCrate, MetadataLoader};
@@ -19,7 +19,7 @@
 pub use rustc::middle::cstore::NativeLibraryKind::*;
 pub use rustc::middle::cstore::{CrateSource, LibSource, ForeignModule};
 
-pub use cstore_impl::{provide, provide_extern};
+pub use crate::cstore_impl::{provide, provide_extern};
 
 // A map from external crate numbers (as decoded from some crate file) to
 // local crate numbers (as generated during this session). Each external
index e61229db86ddb250438f02908de67f950a72c536..b248c6bf6565a29d09d89e59a571efbbb20c03db 100644 (file)
@@ -1,9 +1,9 @@
-use cstore::{self, LoadedMacro};
-use encoder;
-use link_args;
-use native_libs;
-use foreign_modules;
-use schema;
+use crate::cstore::{self, LoadedMacro};
+use crate::encoder;
+use crate::link_args;
+use crate::native_libs;
+use crate::foreign_modules;
+use crate::schema;
 
 use rustc::ty::query::QueryConfig;
 use rustc::middle::cstore::{CrateStore, DepKind,
@@ -29,6 +29,7 @@
 use syntax::source_map;
 use syntax::edition::Edition;
 use syntax::parse::source_file_to_stream;
+use syntax::parse::parser::emit_unclosed_delims;
 use syntax::symbol::Symbol;
 use syntax_pos::{Span, NO_EXPANSION, FileName};
 use rustc_data_structures::bit_set::BitSet;
@@ -51,7 +52,7 @@ pub fn provide_extern<$lt>(providers: &mut Providers<$lt>) {
                     index: CRATE_DEF_INDEX
                 });
                 let dep_node = def_path_hash
-                    .to_dep_node(::rustc::dep_graph::DepKind::CrateMetadata);
+                    .to_dep_node(rustc::dep_graph::DepKind::CrateMetadata);
                 // The DepNodeIndex of the DepNode::CrateMetadata should be
                 // cached somewhere, so that we can use read_index().
                 $tcx.dep_graph.read(dep_node);
@@ -421,7 +422,7 @@ pub fn load_macro_untracked(&self, id: DefId, sess: &Session) -> LoadedMacro {
             use syntax::ext::base::SyntaxExtension;
             use syntax_ext::proc_macro_impl::BangProcMacro;
 
-            let client = ::proc_macro::bridge::client::Client::expand1(::proc_macro::quote);
+            let client = proc_macro::bridge::client::Client::expand1(proc_macro::quote);
             let ext = SyntaxExtension::ProcMacro {
                 expander: Box::new(BangProcMacro { client }),
                 allow_internal_unstable: true,
@@ -436,7 +437,8 @@ pub fn load_macro_untracked(&self, id: DefId, sess: &Session) -> LoadedMacro {
 
         let source_file = sess.parse_sess.source_map().new_source_file(source_name, def.body);
         let local_span = Span::new(source_file.start_pos, source_file.end_pos, NO_EXPANSION);
-        let body = source_file_to_stream(&sess.parse_sess, source_file, None);
+        let (body, errors) = source_file_to_stream(&sess.parse_sess, source_file, None);
+        emit_unclosed_delims(&errors, &sess.diagnostic());
 
         // Mark the attrs as used
         let attrs = data.get_item_attrs(id.index, sess);
index ad6296e1a3bd863d96b097e8e1c23f3f93e382f5..6d7907b096ac67dceafcf2c3e9a1f0ba4337afd4 100644 (file)
@@ -1,7 +1,7 @@
 // Decoding metadata from a single crate's metadata
 
-use cstore::{self, CrateMetadata, MetadataBlob, NativeLibrary, ForeignModule};
-use schema::*;
+use crate::cstore::{self, CrateMetadata, MetadataBlob, NativeLibrary, ForeignModule};
+use crate::schema::*;
 
 use rustc_data_structures::sync::{Lrc, ReadGuard};
 use rustc::hir::map::{DefKey, DefPath, DefPathData, DefPathHash, Definitions};
@@ -34,6 +34,7 @@
 use syntax::ext::base::{MacroKind, SyntaxExtension};
 use syntax::ext::hygiene::Mark;
 use syntax_pos::{self, Span, BytePos, Pos, DUMMY_SP, NO_EXPANSION};
+use log::debug;
 
 pub struct DecodeContext<'a, 'tcx: 'a> {
     opaque: opaque::Decoder<'a>,
@@ -545,7 +546,7 @@ pub fn get_trait_def(&self, item_id: DefIndex, sess: &Session) -> ty::TraitDef {
 
     fn get_variant(&self,
                    tcx: TyCtxt<'a, 'tcx, 'tcx>,
-                   item: &Entry,
+                   item: &Entry<'_>,
                    index: DefIndex,
                    adt_kind: ty::AdtKind)
                    -> ty::VariantDef
index 1b1852434740cb6878b602122d9f23768c66b881..c27d13be4935839357e58ec2020ad8e0049ea9c3 100644 (file)
@@ -1,5 +1,7 @@
 #![allow(non_snake_case)]
 
+use syntax::{register_diagnostic, register_diagnostics, register_long_diagnostics};
+
 register_long_diagnostics! {
 E0454: r##"
 A link name was given with an empty name. Erroneous code example:
index 7d1c3c09d33e9a9e371844a408f29d96fe02cc6b..b9dc4195cb228dbbba9a28bc4dc952405ae16b98 100644 (file)
@@ -76,7 +76,6 @@ pub unsafe fn symbol<T>(&self, symbol: &str) -> Result<*mut T, String> {
 #[cfg(test)]
 mod tests {
     use super::*;
-    use libc;
     use std::mem;
 
     #[test]
@@ -127,7 +126,6 @@ fn test_errors_do_not_crash() {
 
 #[cfg(unix)]
 mod dl {
-    use libc;
     use std::ffi::{CStr, OsStr, CString};
     use std::os::unix::prelude::*;
     use std::ptr;
index 3b212f3b7472de2b8cee894a0f4adfe70dce5809..d68ab9750b9701c207c481f07b8f97d1b5799c87 100644 (file)
@@ -1,7 +1,7 @@
-use index::Index;
-use index_builder::{FromId, IndexBuilder, Untracked};
-use isolated_encoder::IsolatedEncoder;
-use schema::*;
+use crate::index::Index;
+use crate::index_builder::{FromId, IndexBuilder, Untracked};
+use crate::isolated_encoder::IsolatedEncoder;
+use crate::schema::*;
 
 use rustc::middle::cstore::{LinkagePreference, NativeLibrary,
                             EncodedMetadata, ForeignModule};
@@ -34,6 +34,7 @@
 use syntax::source_map::Spanned;
 use syntax::symbol::keywords;
 use syntax_pos::{self, hygiene, FileName, SourceFile, Span};
+use log::{debug, trace};
 
 use rustc::hir::{self, PatKind};
 use rustc::hir::itemlikevisit::ItemLikeVisitor;
@@ -1521,7 +1522,7 @@ fn encode_impls(&mut self, _: ()) -> LazySeq<TraitImpls> {
     // symbol associated with them (they weren't translated) or if they're an FFI
     // definition (as that's not defined in this crate).
     fn encode_exported_symbols(&mut self,
-                               exported_symbols: &[(ExportedSymbol, SymbolExportLevel)])
+                               exported_symbols: &[(ExportedSymbol<'_>, SymbolExportLevel)])
                                -> EncodedExportedSymbols {
         // The metadata symbol name is special. It should not show up in
         // downstream crates.
index ccf398241b191ec27cd3084823bb02b03a769fc3..18f30383090cd7d11ac64525a59cda720ff1e1ed 100644 (file)
@@ -1,9 +1,10 @@
-use schema::*;
+use crate::schema::*;
 
 use rustc::hir::def_id::{DefId, DefIndex, DefIndexAddressSpace};
 use rustc_serialize::opaque::Encoder;
 use std::slice;
 use std::u32;
+use log::debug;
 
 /// While we are generating the metadata, we also track the position
 /// of each DefIndex. It is not required that all definitions appear
@@ -24,12 +25,12 @@ pub fn new((max_index_lo, max_index_hi): (usize, usize)) -> Index {
         }
     }
 
-    pub fn record(&mut self, def_id: DefId, entry: Lazy<Entry>) {
+    pub fn record(&mut self, def_id: DefId, entry: Lazy<Entry<'_>>) {
         assert!(def_id.is_local());
         self.record_index(def_id.index, entry);
     }
 
-    pub fn record_index(&mut self, item: DefIndex, entry: Lazy<Entry>) {
+    pub fn record_index(&mut self, item: DefIndex, entry: Lazy<Entry<'_>>) {
         assert!(entry.position < (u32::MAX as usize));
         let position = entry.position as u32;
         let space_index = item.address_space().index();
index 3608b12aea934636f65b3593944bb2057566b1a2..4175f7acd06889a8694d853166b4d463a4a9b2c5 100644 (file)
 //! give a callback fn, rather than taking a closure: it allows us to
 //! easily control precisely what data is given to that fn.
 
-use encoder::EncodeContext;
-use index::Index;
-use schema::*;
-use isolated_encoder::IsolatedEncoder;
+use crate::encoder::EncodeContext;
+use crate::index::Index;
+use crate::schema::*;
+use crate::isolated_encoder::IsolatedEncoder;
 
 use rustc::hir;
 use rustc::hir::def_id::DefId;
@@ -133,21 +133,21 @@ pub fn into_items(self) -> Index {
 /// `DefId` index, or implement the `read` method so that it can add
 /// a read of whatever dep-graph nodes are appropriate.
 pub trait DepGraphRead {
-    fn read(&self, tcx: TyCtxt);
+    fn read(&self, tcx: TyCtxt<'_, '_, '_>);
 }
 
 impl DepGraphRead for DefId {
-    fn read(&self, _tcx: TyCtxt) {}
+    fn read(&self, _tcx: TyCtxt<'_, '_, '_>) {}
 }
 
 impl DepGraphRead for ast::NodeId {
-    fn read(&self, _tcx: TyCtxt) {}
+    fn read(&self, _tcx: TyCtxt<'_, '_, '_>) {}
 }
 
 impl<T> DepGraphRead for Option<T>
     where T: DepGraphRead
 {
-    fn read(&self, tcx: TyCtxt) {
+    fn read(&self, tcx: TyCtxt<'_, '_, '_>) {
         match *self {
             Some(ref v) => v.read(tcx),
             None => (),
@@ -158,7 +158,7 @@ fn read(&self, tcx: TyCtxt) {
 impl<T> DepGraphRead for [T]
     where T: DepGraphRead
 {
-    fn read(&self, tcx: TyCtxt) {
+    fn read(&self, tcx: TyCtxt<'_, '_, '_>) {
         for i in self {
             i.read(tcx);
         }
@@ -171,7 +171,7 @@ impl<$($name),*> DepGraphRead for ($($name),*)
             where $($name: DepGraphRead),*
         {
             #[allow(non_snake_case)]
-            fn read(&self, tcx: TyCtxt) {
+            fn read(&self, tcx: TyCtxt<'_, '_, '_>) {
                 let &($(ref $name),*) = self;
                 $($name.read(tcx);)*
             }
@@ -184,7 +184,7 @@ fn read(&self, tcx: TyCtxt) {
 macro_rules! read_hir {
     ($t:ty) => {
         impl<'tcx> DepGraphRead for &'tcx $t {
-            fn read(&self, tcx: TyCtxt) {
+            fn read(&self, tcx: TyCtxt<'_, '_, '_>) {
                 tcx.hir().read(self.id);
             }
         }
@@ -208,7 +208,7 @@ fn read(&self, tcx: TyCtxt) {
 pub struct Untracked<T>(pub T);
 
 impl<T> DepGraphRead for Untracked<T> {
-    fn read(&self, _tcx: TyCtxt) {}
+    fn read(&self, _tcx: TyCtxt<'_, '_, '_>) {}
 }
 
 /// Newtype that can be used to package up misc data extracted from a
@@ -218,7 +218,7 @@ fn read(&self, _tcx: TyCtxt) {}
 pub struct FromId<T>(pub ast::NodeId, pub T);
 
 impl<T> DepGraphRead for FromId<T> {
-    fn read(&self, tcx: TyCtxt) {
+    fn read(&self, tcx: TyCtxt<'_, '_, '_>) {
         tcx.hir().read(self.0);
     }
 }
index c09d35d150a12a19bfa6fe53a725ff80cdfa7528..e879a73e650bb026b0e9c902a703c4185a6f9544 100644 (file)
@@ -1,5 +1,5 @@
-use encoder::EncodeContext;
-use schema::{Lazy, LazySeq};
+use crate::encoder::EncodeContext;
+use crate::schema::{Lazy, LazySeq};
 use rustc::ty::TyCtxt;
 use rustc_serialize::Encodable;
 
index 5dc736bfbd313f5af26af8bad0f1714e4aed9b79..a3490b7fea5b592b84219065158aac07c86959eb 100644 (file)
 
 #![recursion_limit="256"]
 
+#![deny(rust_2018_idioms)]
+
 extern crate libc;
-#[macro_use]
-extern crate log;
-extern crate memmap;
-extern crate stable_deref_trait;
-#[macro_use]
-extern crate syntax;
-extern crate syntax_pos;
-extern crate flate2;
+#[allow(unused_extern_crates)]
 extern crate serialize as rustc_serialize; // used by deriving
-extern crate rustc_errors as errors;
-extern crate syntax_ext;
 extern crate proc_macro;
 
 #[macro_use]
 extern crate rustc;
-extern crate rustc_target;
 #[macro_use]
 extern crate rustc_data_structures;
 
index 6b49d6b9e52cbdd2baddd3d4822943c8ffebcb55..f120072b37c05cd1e0462a73fec98898b4bf6e2a 100644 (file)
 //! no means all of the necessary details. Take a look at the rest of
 //! metadata::locator or metadata::creader for all the juicy details!
 
-use cstore::{MetadataRef, MetadataBlob};
-use creader::Library;
-use schema::{METADATA_HEADER, rustc_version};
+use crate::cstore::{MetadataRef, MetadataBlob};
+use crate::creader::Library;
+use crate::schema::{METADATA_HEADER, rustc_version};
 
 use rustc_data_structures::fx::FxHashSet;
 use rustc_data_structures::svh::Svh;
 
 use errors::DiagnosticBuilder;
 use syntax::symbol::Symbol;
+use syntax::struct_span_err;
 use syntax_pos::Span;
 use rustc_target::spec::{Target, TargetTriple};
 
 
 use rustc_data_structures::owning_ref::OwningRef;
 
+use log::{debug, info, warn};
+
 pub struct CrateMismatch {
     path: PathBuf,
     got: String,
@@ -283,7 +286,7 @@ enum CrateFlavor {
 }
 
 impl fmt::Display for CrateFlavor {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         f.write_str(match *self {
             CrateFlavor::Rlib => "rlib",
             CrateFlavor::Rmeta => "rmeta",
@@ -600,7 +603,7 @@ fn extract_one(&mut self,
             }
         }
 
-        let mut err: Option<DiagnosticBuilder> = None;
+        let mut err: Option<DiagnosticBuilder<'_>> = None;
         for (lib, kind) in m {
             info!("{} reading metadata from: {}", flavor, lib.display());
             let (hash, metadata) =
index 1f00086e32fe127d3e5759bddc83f579ebe61497..118fb203c69a1ad3f6e50ce35503a5fdfc580a36 100644 (file)
@@ -9,6 +9,7 @@
 use syntax::source_map::Span;
 use syntax::feature_gate::{self, GateIssue};
 use syntax::symbol::Symbol;
+use syntax::{span_err, struct_span_err};
 
 pub fn collect<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Vec<NativeLibrary> {
     let mut collector = Collector {
index f3ff9747625f5b68724701049c5f6a660f347869..af79ea37dff55eb9010ce826109923ab024685b4 100644 (file)
@@ -1,4 +1,4 @@
-use index;
+use crate::index;
 
 use rustc::hir;
 use rustc::hir::def::{self, CtorKind};
@@ -518,7 +518,7 @@ pub enum AssociatedContainer {
     ImplFinal,
 }
 
-impl_stable_hash_for!(enum ::schema::AssociatedContainer {
+impl_stable_hash_for!(enum crate::schema::AssociatedContainer {
     TraitRequired,
     TraitWithDefault,
     ImplDefault,
index f0234c48c3eca97e0b9644a8b925e27b67fcf154..44a6b41cdfe45233e26c6df4d2b1a71fdfd2b444 100644 (file)
@@ -2,6 +2,7 @@
 authors = ["The Rust Project Developers"]
 name = "rustc_mir"
 version = "0.0.0"
+edition = "2018"
 
 [lib]
 name = "rustc_mir"
@@ -12,7 +13,7 @@ crate-type = ["dylib"]
 arena = { path = "../libarena" }
 bitflags = "1.0"
 either = "1.5.0"
-graphviz = { path = "../libgraphviz" }
+dot = { path = "../libgraphviz", package = "graphviz" }
 log = "0.4"
 log_settings = "0.1.1"
 polonius-engine = "0.6.2"
index ecbc6118bc37c6125882b9f88246b177f7b4e6be..2788f5d4325a962e6af1560703c9fa9cb2123c8f 100644 (file)
@@ -1,7 +1,7 @@
-use borrow_check::place_ext::PlaceExt;
-use borrow_check::nll::ToRegionVid;
-use dataflow::indexes::BorrowIndex;
-use dataflow::move_paths::MoveData;
+use crate::borrow_check::place_ext::PlaceExt;
+use crate::borrow_check::nll::ToRegionVid;
+use crate::dataflow::indexes::BorrowIndex;
+use crate::dataflow::move_paths::MoveData;
 use rustc::mir::traversal;
 use rustc::mir::visit::{
     PlaceContext, Visitor, NonUseContext, MutatingUseContext, NonMutatingUseContext
@@ -72,7 +72,7 @@ fn index(&self, index: BorrowIndex) -> &BorrowData<'tcx> {
 }
 
 impl<'tcx> fmt::Display for BorrowData<'tcx> {
-    fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, w: &mut fmt::Formatter<'_>) -> fmt::Result {
         let kind = match self.kind {
             mir::BorrowKind::Shared => "",
             mir::BorrowKind::Shallow => "shallow ",
index b070031756798b228a9e42198035cab53c4238bf..afb26963217ff949da84e62237a432cbce6e38f9 100644 (file)
@@ -1,7 +1,7 @@
-use borrow_check::nll::explain_borrow::BorrowExplanation;
-use borrow_check::nll::region_infer::{RegionName, RegionNameSource};
-use borrow_check::prefixes::IsPrefixOf;
-use borrow_check::WriteKind;
+use crate::borrow_check::nll::explain_borrow::BorrowExplanation;
+use crate::borrow_check::nll::region_infer::{RegionName, RegionNameSource};
+use crate::borrow_check::prefixes::IsPrefixOf;
+use crate::borrow_check::WriteKind;
 use rustc::hir;
 use rustc::hir::def_id::DefId;
 use rustc::middle::region::ScopeTree;
 use super::borrow_set::BorrowData;
 use super::{Context, MirBorrowckCtxt};
 use super::{InitializationRequiringAction, PrefixSet};
-use dataflow::drop_flag_effects;
-use dataflow::move_paths::indexes::MoveOutIndex;
-use dataflow::move_paths::MovePathIndex;
-use util::borrowck_errors::{BorrowckErrors, Origin};
+use crate::dataflow::drop_flag_effects;
+use crate::dataflow::move_paths::indexes::MoveOutIndex;
+use crate::dataflow::move_paths::MovePathIndex;
+use crate::util::borrowck_errors::{BorrowckErrors, Origin};
 
 #[derive(Debug)]
 struct MoveSite {
@@ -1726,7 +1726,7 @@ 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 {
+    fn describe_field(&self, base: &Place<'_>, field: Field) -> String {
         match *base {
             Place::Local(local) => {
                 let local = &self.mir.local_decls[local];
@@ -1751,7 +1751,7 @@ fn describe_field(&self, base: &Place, field: Field) -> String {
     }
 
     /// End-user visible description of the `field_index`nth field of `ty`
-    fn describe_field_from_ty(&self, ty: &ty::Ty, field: Field) -> String {
+    fn describe_field_from_ty(&self, ty: &ty::Ty<'_>, field: Field) -> String {
         if ty.is_box() {
             // If the type is a box, the field is described from the boxed type
             self.describe_field_from_ty(&ty.boxed_ty(), field)
@@ -1860,7 +1860,7 @@ fn classify_drop_access_kind(&self, place: &Place<'tcx>) -> StorageDeadOrDrop<'t
     fn annotate_argument_and_return_for_borrow(
         &self,
         borrow: &BorrowData<'tcx>,
-    ) -> Option<AnnotatedBorrowFnSignature> {
+    ) -> Option<AnnotatedBorrowFnSignature<'_>> {
         // Define a fallback for when we can't match a closure.
         let fallback = || {
             let is_closure = self.infcx.tcx.is_closure(self.mir_def_id);
@@ -2081,7 +2081,7 @@ fn annotate_fn_sig(
         &self,
         did: DefId,
         sig: ty::PolyFnSig<'tcx>,
-    ) -> Option<AnnotatedBorrowFnSignature> {
+    ) -> Option<AnnotatedBorrowFnSignature<'_>> {
         debug!("annotate_fn_sig: did={:?} sig={:?}", did, sig);
         let is_closure = self.infcx.tcx.is_closure(did);
         let fn_node_id = self.infcx.tcx.hir().as_local_node_id(did)?;
@@ -2368,14 +2368,22 @@ pub(super) fn var_or_use(self) -> Span {
     }
 
     // Add a span label to the arguments of the closure, if it exists.
-    pub(super) fn args_span_label(self, err: &mut DiagnosticBuilder, message: impl Into<String>) {
+    pub(super) fn args_span_label(
+        self,
+        err: &mut DiagnosticBuilder<'_>,
+        message: impl Into<String>,
+    ) {
         if let UseSpans::ClosureUse { args_span, .. } = self {
             err.span_label(args_span, message);
         }
     }
 
     // Add a span label to the use of the captured variable, if it exists.
-    pub(super) fn var_span_label(self, err: &mut DiagnosticBuilder, message: impl Into<String>) {
+    pub(super) fn var_span_label(
+        self,
+        err: &mut DiagnosticBuilder<'_>,
+        message: impl Into<String>,
+    ) {
         if let UseSpans::ClosureUse { var_span, .. } = self {
             err.span_label(var_span, message);
         }
@@ -2563,7 +2571,7 @@ fn closure_span(
 
     /// Helper to retrieve span(s) of given borrow from the current MIR
     /// representation
-    pub(super) fn retrieve_borrow_spans(&self, borrow: &BorrowData) -> UseSpans {
+    pub(super) fn retrieve_borrow_spans(&self, borrow: &BorrowData<'_>) -> UseSpans {
         let span = self.mir.source_info(borrow.reserve_location).span;
         self.borrow_spans(span, borrow.reserve_location)
     }
index 4eeb19c4e7a671e41edef45106839171693bdf55..8de39f0efc1a5309a39eca22b3242f239c58d341 100644 (file)
@@ -7,16 +7,16 @@
 use rustc::ty::RegionVid;
 use rustc_data_structures::bit_set::BitIter;
 
-use borrow_check::location::LocationIndex;
+use crate::borrow_check::location::LocationIndex;
 
 use polonius_engine::Output;
 
-use dataflow::move_paths::indexes::BorrowIndex;
-use dataflow::move_paths::HasMoveData;
-use dataflow::Borrows;
-use dataflow::EverInitializedPlaces;
-use dataflow::{FlowAtLocation, FlowsAtLocation};
-use dataflow::MaybeUninitializedPlaces;
+use crate::dataflow::move_paths::indexes::BorrowIndex;
+use crate::dataflow::move_paths::HasMoveData;
+use crate::dataflow::Borrows;
+use crate::dataflow::EverInitializedPlaces;
+use crate::dataflow::{FlowAtLocation, FlowsAtLocation};
+use crate::dataflow::MaybeUninitializedPlaces;
 use either::Either;
 use std::fmt;
 use std::rc::Rc;
@@ -57,7 +57,7 @@ impl<'b, 'gcx, 'tcx> Flows<'b, 'gcx, 'tcx> {
         }
     }
 
-    crate fn with_outgoing_borrows(&self, op: impl FnOnce(BitIter<BorrowIndex>)) {
+    crate fn with_outgoing_borrows(&self, op: impl FnOnce(BitIter<'_, BorrowIndex>)) {
         self.borrows.with_iter_outgoing(op)
     }
 }
@@ -93,7 +93,7 @@ fn apply_local_effect(&mut self, location: Location) {
 }
 
 impl<'b, 'gcx, 'tcx> fmt::Display for Flows<'b, 'gcx, 'tcx> {
-    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
         let mut s = String::new();
 
         s.push_str("borrows in effect: [");
index 5597e4a6c597e587531e28f82c2843e5b96bb57c..45a8c9e8e6909483c2bc8876fffbee6047565714 100644 (file)
@@ -1,6 +1,6 @@
 //! This query borrow-checks the MIR to (further) ensure it is not broken.
 
-use borrow_check::nll::region_infer::RegionInferenceContext;
+use crate::borrow_check::nll::region_infer::RegionInferenceContext;
 use rustc::hir;
 use rustc::hir::Node;
 use rustc::hir::def_id::DefId;
 
 use syntax_pos::Span;
 
-use dataflow::indexes::{BorrowIndex, InitIndex, MoveOutIndex, MovePathIndex};
-use dataflow::move_paths::{HasMoveData, LookupResult, MoveData, MoveError};
-use dataflow::Borrows;
-use dataflow::DataflowResultsConsumer;
-use dataflow::FlowAtLocation;
-use dataflow::MoveDataParamEnv;
-use dataflow::{do_dataflow, DebugFormatted};
-use dataflow::EverInitializedPlaces;
-use dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces};
-use util::borrowck_errors::{BorrowckErrors, Origin};
+use crate::dataflow::indexes::{BorrowIndex, InitIndex, MoveOutIndex, MovePathIndex};
+use crate::dataflow::move_paths::{HasMoveData, LookupResult, MoveData, MoveError};
+use crate::dataflow::Borrows;
+use crate::dataflow::DataflowResultsConsumer;
+use crate::dataflow::FlowAtLocation;
+use crate::dataflow::MoveDataParamEnv;
+use crate::dataflow::{do_dataflow, DebugFormatted};
+use crate::dataflow::EverInitializedPlaces;
+use crate::dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces};
+use crate::util::borrowck_errors::{BorrowckErrors, Origin};
 
 use self::borrow_set::{BorrowData, BorrowSet};
 use self::flows::Flows;
@@ -59,7 +59,7 @@
 
 pub(crate) mod nll;
 
-pub fn provide(providers: &mut Providers) {
+pub fn provide(providers: &mut Providers<'_>) {
     *providers = Providers {
         mir_borrowck,
         ..*providers
@@ -108,7 +108,7 @@ fn mir_borrowck<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> BorrowC
     }
 
     let opt_closure_req = tcx.infer_ctxt().enter(|infcx| {
-        let input_mir: &Mir = &input_mir.borrow();
+        let input_mir: &Mir<'_> = &input_mir.borrow();
         do_mir_borrowck(&infcx, input_mir, def_id)
     });
     debug!("mir_borrowck done");
index 8539b5c26cee88e5f8a8f4b3b3de187e430eb94a..f7d46925e17dfe14992b83c8559bfd4dcbb5188d 100644 (file)
@@ -6,13 +6,13 @@
 use rustc_errors::{DiagnosticBuilder,Applicability};
 use syntax_pos::Span;
 
-use borrow_check::MirBorrowckCtxt;
-use borrow_check::prefixes::PrefixSet;
-use dataflow::move_paths::{
+use crate::borrow_check::MirBorrowckCtxt;
+use crate::borrow_check::prefixes::PrefixSet;
+use crate::dataflow::move_paths::{
     IllegalMoveOrigin, IllegalMoveOriginKind, InitLocation,
     LookupResult, MoveError, MovePathIndex,
 };
-use util::borrowck_errors::{BorrowckErrors, Origin};
+use crate::util::borrowck_errors::{BorrowckErrors, Origin};
 
 // Often when desugaring a pattern match we may have many individual moves in
 // MIR that are all part of one operation from the user's point-of-view. For
@@ -63,7 +63,7 @@ enum BorrowedContentSource {
 }
 
 impl Display for BorrowedContentSource {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         match *self {
             BorrowedContentSource::Arc => write!(f, "an `Arc`"),
             BorrowedContentSource::Rc => write!(f, "an `Rc`"),
@@ -240,7 +240,7 @@ fn append_binding_error(
 
     fn report(&mut self, error: GroupedMoveError<'tcx>) {
         let (mut err, err_span) = {
-            let (span, original_path, kind): (Span, &Place<'tcx>, &IllegalMoveOriginKind) =
+            let (span, original_path, kind): (Span, &Place<'tcx>, &IllegalMoveOriginKind<'_>) =
                 match error {
                     GroupedMoveError::MovesFromPlace {
                         span,
index 9d3ce7693ea86b22c2aaeeb86ac419beeb2d12a7..dad8d903cf9feec11960f74869d1c100b86da616 100644 (file)
@@ -8,11 +8,11 @@
 use syntax_pos::Span;
 use syntax_pos::symbol::keywords;
 
-use dataflow::move_paths::InitLocation;
-use borrow_check::MirBorrowckCtxt;
-use util::borrowck_errors::{BorrowckErrors, Origin};
-use util::collect_writes::FindAssignments;
-use util::suggest_ref_mut;
+use crate::dataflow::move_paths::InitLocation;
+use crate::borrow_check::MirBorrowckCtxt;
+use crate::util::borrowck_errors::{BorrowckErrors, Origin};
+use crate::util::collect_writes::FindAssignments;
+use crate::util::suggest_ref_mut;
 use rustc_errors::Applicability;
 
 #[derive(Copy, Clone, Debug, Eq, PartialEq)]
@@ -611,7 +611,7 @@ fn suggest_ampmut<'cx, 'gcx, 'tcx>(
      })
 }
 
-fn is_closure_or_generator(ty: ty::Ty) -> bool {
+fn is_closure_or_generator(ty: ty::Ty<'_>) -> bool {
     ty.is_closure() || ty.is_generator()
 }
 
index 588f46cb77fe26f845e342178d8567d63911843b..c02c2b4934cf492261393cabfea022b48910a9e4 100644 (file)
@@ -1,8 +1,8 @@
-use borrow_check::borrow_set::BorrowSet;
-use borrow_check::location::LocationTable;
-use borrow_check::nll::ToRegionVid;
-use borrow_check::nll::facts::AllFacts;
-use borrow_check::nll::region_infer::values::LivenessValues;
+use crate::borrow_check::borrow_set::BorrowSet;
+use crate::borrow_check::location::LocationTable;
+use crate::borrow_check::nll::ToRegionVid;
+use crate::borrow_check::nll::facts::AllFacts;
+use crate::borrow_check::nll::region_infer::values::LivenessValues;
 use rustc::infer::InferCtxt;
 use rustc::mir::visit::TyContext;
 use rustc::mir::visit::Visitor;
index fe9ccb489e425e8a560b67ec424901e0e317d0f8..2479dfd1c709318c7627a625c4634eed9ce10ac3 100644 (file)
@@ -1,6 +1,6 @@
-use borrow_check::nll::type_check::Locations;
-use borrow_check::nll::constraints::ConstraintIndex;
-use borrow_check::nll::constraints::{ConstraintSet, OutlivesConstraint};
+use crate::borrow_check::nll::type_check::Locations;
+use crate::borrow_check::nll::constraints::ConstraintIndex;
+use crate::borrow_check::nll::constraints::{ConstraintSet, OutlivesConstraint};
 use rustc::mir::ConstraintCategory;
 use rustc::ty::RegionVid;
 use rustc_data_structures::graph;
index 146bd65dd11434c1959755093082152a7e448637..d3f9743dfed7720453ac38719cfe60054f82deed 100644 (file)
@@ -2,7 +2,7 @@
 use rustc::ty::RegionVid;
 use rustc_data_structures::graph::scc::Sccs;
 use rustc_data_structures::indexed_vec::{Idx, IndexVec};
-use borrow_check::nll::type_check::Locations;
+use crate::borrow_check::nll::type_check::Locations;
 
 use std::fmt;
 use std::ops::Deref;
@@ -84,7 +84,7 @@ pub struct OutlivesConstraint {
 }
 
 impl fmt::Debug for OutlivesConstraint {
-    fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(
             formatter,
             "({:?}: {:?}) due to {:?}",
index 53035dae4f35c7bd56064ece39876a66aaaf564e..c5aaf5b811ed7e6c956b0c6d56998544dfd32903 100644 (file)
@@ -1,13 +1,13 @@
 use std::collections::VecDeque;
 use std::rc::Rc;
 
-use borrow_check::nll::region_infer::{Cause, RegionInferenceContext};
-use borrow_check::nll::ToRegionVid;
+use crate::borrow_check::nll::region_infer::{Cause, RegionInferenceContext};
+use crate::borrow_check::nll::ToRegionVid;
+use crate::util::liveness::{self, DefUse};
 use rustc::mir::visit::{MirVisitable, PlaceContext, Visitor};
 use rustc::mir::{Local, Location, Mir};
 use rustc::ty::{RegionVid, TyCtxt};
 use rustc_data_structures::fx::FxHashSet;
-use util::liveness::{self, DefUse};
 
 crate fn find<'tcx>(
     mir: &Mir<'tcx>,
index 968c0f53a485205b9a6f866984db60983f3e5a8d..8e57d107aa61effea1334593db3f9ff44023d45d 100644 (file)
@@ -1,8 +1,8 @@
-use borrow_check::borrow_set::BorrowData;
-use borrow_check::error_reporting::UseSpans;
-use borrow_check::nll::ConstraintDescription;
-use borrow_check::nll::region_infer::{Cause, RegionName};
-use borrow_check::{Context, MirBorrowckCtxt, WriteKind};
+use crate::borrow_check::borrow_set::BorrowData;
+use crate::borrow_check::error_reporting::UseSpans;
+use crate::borrow_check::nll::ConstraintDescription;
+use crate::borrow_check::nll::region_infer::{Cause, RegionName};
+use crate::borrow_check::{Context, MirBorrowckCtxt, WriteKind};
 use rustc::ty::{self, TyCtxt};
 use rustc::mir::{
     CastKind, ConstraintCategory, FakeReadCause, Local, Location, Mir, Operand,
@@ -14,7 +14,7 @@
 
 mod find_use;
 
-pub(in borrow_check) enum BorrowExplanation {
+pub(in crate::borrow_check) enum BorrowExplanation {
     UsedLater(LaterUseKind, Span),
     UsedLaterInLoop(LaterUseKind, Span),
     UsedLaterWhenDropped {
@@ -33,7 +33,7 @@ pub(in borrow_check) enum BorrowExplanation {
 }
 
 #[derive(Clone, Copy)]
-pub(in borrow_check) enum LaterUseKind {
+pub(in crate::borrow_check) enum LaterUseKind {
     TraitCapture,
     ClosureCapture,
     Call,
@@ -42,13 +42,13 @@ pub(in borrow_check) enum LaterUseKind {
 }
 
 impl BorrowExplanation {
-    pub(in borrow_check) fn is_explained(&self) -> bool {
+    pub(in crate::borrow_check) fn is_explained(&self) -> bool {
         match self {
             BorrowExplanation::Unexplained => false,
             _ => true,
         }
     }
-    pub(in borrow_check) fn add_explanation_to_diagnostic<'cx, 'gcx, 'tcx>(
+    pub(in crate::borrow_check) fn add_explanation_to_diagnostic<'cx, 'gcx, 'tcx>(
         &self,
         tcx: TyCtxt<'cx, 'gcx, 'tcx>,
         mir: &Mir<'tcx>,
@@ -187,7 +187,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
     ///   - second half is the place being accessed
     ///
     /// [d]: https://rust-lang.github.io/rfcs/2094-nll.html#leveraging-intuition-framing-errors-in-terms-of-points
-    pub(in borrow_check) fn explain_why_borrow_contains_point(
+    pub(in crate::borrow_check) fn explain_why_borrow_contains_point(
         &self,
         context: Context,
         borrow: &BorrowData<'tcx>,
index bc33a1c9c65aac2a387da219d6f4cc44b3e623ec..9672d3e78cd50a76c62ebca1c3ffaab41bb85e71 100644 (file)
@@ -1,5 +1,5 @@
-use borrow_check::location::{LocationIndex, LocationTable};
-use dataflow::indexes::BorrowIndex;
+use crate::borrow_check::location::{LocationIndex, LocationTable};
+use crate::dataflow::indexes::BorrowIndex;
 use polonius_engine::AllFacts as PoloniusAllFacts;
 use polonius_engine::Atom;
 use rustc::ty::{RegionVid, TyCtxt};
index 112b39952559b124770c456be2db7e84d9c1653d..3df6b797a44fb2b4f9b0b449248a5fe66a3b6112 100644 (file)
@@ -1,15 +1,15 @@
-use borrow_check::borrow_set::BorrowSet;
-use borrow_check::location::LocationTable;
-use borrow_check::{JustWrite, WriteAndRead};
-use borrow_check::{AccessDepth, Deep, Shallow};
-use borrow_check::{ReadOrWrite, Activation, Read, Reservation, Write};
-use borrow_check::{Context, ContextKind};
-use borrow_check::{LocalMutationIsAllowed, MutateMode};
-use borrow_check::ArtificialField;
-use borrow_check::{ReadKind, WriteKind};
-use borrow_check::nll::facts::AllFacts;
-use borrow_check::path_utils::*;
-use dataflow::move_paths::indexes::BorrowIndex;
+use crate::borrow_check::borrow_set::BorrowSet;
+use crate::borrow_check::location::LocationTable;
+use crate::borrow_check::{JustWrite, WriteAndRead};
+use crate::borrow_check::{AccessDepth, Deep, Shallow};
+use crate::borrow_check::{ReadOrWrite, Activation, Read, Reservation, Write};
+use crate::borrow_check::{Context, ContextKind};
+use crate::borrow_check::{LocalMutationIsAllowed, MutateMode};
+use crate::borrow_check::ArtificialField;
+use crate::borrow_check::{ReadKind, WriteKind};
+use crate::borrow_check::nll::facts::AllFacts;
+use crate::borrow_check::path_utils::*;
+use crate::dataflow::move_paths::indexes::BorrowIndex;
 use rustc::ty::TyCtxt;
 use rustc::mir::visit::Visitor;
 use rustc::mir::{BasicBlock, Location, Mir, Place, Rvalue};
index a092c3b8ecde2c5671874d7ad4f67835a50f8eed..1fca104cd3825b4f6301708348968e103da3f1c0 100644 (file)
@@ -1,13 +1,14 @@
-use borrow_check::borrow_set::BorrowSet;
-use borrow_check::location::{LocationIndex, LocationTable};
-use borrow_check::nll::facts::AllFactsExt;
-use borrow_check::nll::type_check::{MirTypeckResults, MirTypeckRegionConstraints};
-use borrow_check::nll::type_check::liveness::liveness_map::NllLivenessMap;
-use borrow_check::nll::region_infer::values::RegionValueElements;
-use dataflow::indexes::BorrowIndex;
-use dataflow::move_paths::MoveData;
-use dataflow::FlowAtLocation;
-use dataflow::MaybeInitializedPlaces;
+use crate::borrow_check::borrow_set::BorrowSet;
+use crate::borrow_check::location::{LocationIndex, LocationTable};
+use crate::borrow_check::nll::facts::AllFactsExt;
+use crate::borrow_check::nll::type_check::{MirTypeckResults, MirTypeckRegionConstraints};
+use crate::borrow_check::nll::type_check::liveness::liveness_map::NllLivenessMap;
+use crate::borrow_check::nll::region_infer::values::RegionValueElements;
+use crate::dataflow::indexes::BorrowIndex;
+use crate::dataflow::move_paths::MoveData;
+use crate::dataflow::FlowAtLocation;
+use crate::dataflow::MaybeInitializedPlaces;
+use crate::transform::MirSource;
 use rustc::hir::def_id::DefId;
 use rustc::infer::InferCtxt;
 use rustc::mir::{ClosureOutlivesSubject, ClosureRegionRequirements, Mir};
 use std::path::PathBuf;
 use std::rc::Rc;
 use std::str::FromStr;
-use transform::MirSource;
 
 use self::mir_util::PassWhere;
 use polonius_engine::{Algorithm, Output};
-use util as mir_util;
-use util::pretty;
+use crate::util as mir_util;
+use crate::util::pretty;
 
 mod constraint_generation;
 pub mod explain_borrow;
@@ -45,7 +45,7 @@
 /// scraping out the set of universal regions (e.g., region parameters)
 /// declared on the function. That set will need to be given to
 /// `compute_regions`.
-pub(in borrow_check) fn replace_regions_in_mir<'cx, 'gcx, 'tcx>(
+pub(in crate::borrow_check) fn replace_regions_in_mir<'cx, 'gcx, 'tcx>(
     infcx: &InferCtxt<'cx, 'gcx, 'tcx>,
     def_id: DefId,
     param_env: ty::ParamEnv<'tcx>,
@@ -68,7 +68,7 @@ pub(in borrow_check) fn replace_regions_in_mir<'cx, 'gcx, 'tcx>(
 /// Computes the (non-lexical) regions from the input MIR.
 ///
 /// This may result in errors being reported.
-pub(in borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
+pub(in crate::borrow_check) fn compute_regions<'cx, 'gcx, 'tcx>(
     infcx: &InferCtxt<'cx, 'gcx, 'tcx>,
     def_id: DefId,
     universal_regions: UniversalRegions<'tcx>,
@@ -211,8 +211,8 @@ fn dump_mir_results<'a, 'gcx, 'tcx>(
     infcx: &InferCtxt<'a, 'gcx, 'tcx>,
     source: MirSource,
     mir: &Mir<'tcx>,
-    regioncx: &RegionInferenceContext,
-    closure_region_requirements: &Option<ClosureRegionRequirements>,
+    regioncx: &RegionInferenceContext<'_>,
+    closure_region_requirements: &Option<ClosureRegionRequirements<'_>>,
 ) {
     if !mir_util::dump_enabled(infcx.tcx, "nll", source) {
         return;
@@ -254,14 +254,14 @@ fn dump_mir_results<'a, 'gcx, 'tcx>(
     );
 
     // Also dump the inference graph constraints as a graphviz file.
-    let _: io::Result<()> = try_block! {
+    let _: io::Result<()> = try {
         let mut file =
             pretty::create_dump_file(infcx.tcx, "regioncx.all.dot", None, "nll", &0, source)?;
         regioncx.dump_graphviz_raw_constraints(&mut file)?;
     };
 
     // Also dump the inference graph constraints as a graphviz file.
-    let _: io::Result<()> = try_block! {
+    let _: io::Result<()> = try {
         let mut file =
             pretty::create_dump_file(infcx.tcx, "regioncx.scc.dot", None, "nll", &0, source)?;
         regioncx.dump_graphviz_scc_constraints(&mut file)?;
@@ -273,7 +273,7 @@ fn dump_annotation<'a, 'gcx, 'tcx>(
     mir: &Mir<'tcx>,
     mir_def_id: DefId,
     regioncx: &RegionInferenceContext<'tcx>,
-    closure_region_requirements: &Option<ClosureRegionRequirements>,
+    closure_region_requirements: &Option<ClosureRegionRequirements<'_>>,
     errors_buffer: &mut Vec<Diagnostic>,
 ) {
     let tcx = infcx.tcx;
@@ -322,7 +322,7 @@ fn dump_annotation<'a, 'gcx, 'tcx>(
 }
 
 fn for_each_region_constraint(
-    closure_region_requirements: &ClosureRegionRequirements,
+    closure_region_requirements: &ClosureRegionRequirements<'_>,
     with_msg: &mut dyn FnMut(&str) -> io::Result<()>,
 ) -> io::Result<()> {
     for req in &closure_region_requirements.outlives_requirements {
index 550668a7ceecebd6150d657510462ab3a60bb770..3498e3437676c628061f65d67b26614528120cc1 100644 (file)
@@ -1,8 +1,9 @@
-use borrow_check::nll::constraints::OutlivesConstraint;
-use borrow_check::nll::region_infer::RegionInferenceContext;
-use borrow_check::nll::type_check::Locations;
-use borrow_check::nll::universal_regions::DefiningTy;
-use borrow_check::nll::ConstraintDescription;
+use crate::borrow_check::nll::constraints::OutlivesConstraint;
+use crate::borrow_check::nll::region_infer::RegionInferenceContext;
+use crate::borrow_check::nll::type_check::Locations;
+use crate::borrow_check::nll::universal_regions::DefiningTy;
+use crate::borrow_check::nll::ConstraintDescription;
+use crate::util::borrowck_errors::{BorrowckErrors, Origin};
 use rustc::hir::def_id::DefId;
 use rustc::infer::error_reporting::nice_region_error::NiceRegionError;
 use rustc::infer::InferCtxt;
@@ -15,7 +16,6 @@
 use syntax::errors::Applicability;
 use syntax::symbol::keywords;
 use syntax_pos::Span;
-use util::borrowck_errors::{BorrowckErrors, Origin};
 
 mod region_name;
 mod var_name;
index bff8015511242e1338f17a386eb623d39eba6053..2c4f359f65fa5cbb7395e567120bc92452a8c324 100644 (file)
@@ -1,7 +1,7 @@
 use std::fmt::{self, Display};
-use borrow_check::nll::region_infer::RegionInferenceContext;
-use borrow_check::nll::universal_regions::DefiningTy;
-use borrow_check::nll::ToRegionVid;
+use crate::borrow_check::nll::region_infer::RegionInferenceContext;
+use crate::borrow_check::nll::universal_regions::DefiningTy;
+use crate::borrow_check::nll::ToRegionVid;
 use rustc::hir;
 use rustc::hir::def_id::DefId;
 use rustc::infer::InferCtxt;
@@ -109,7 +109,7 @@ impl RegionName {
 }
 
 impl Display for RegionName {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(f, "{}", self.name)
     }
 }
index c2f2e99c0a55ba838b15a1631839022de16b421e..bd7b8829c7b4fc4f2636d196e5fe344065012c9d 100644 (file)
@@ -1,5 +1,5 @@
-use borrow_check::nll::region_infer::RegionInferenceContext;
-use borrow_check::nll::ToRegionVid;
+use crate::borrow_check::nll::region_infer::RegionInferenceContext;
+use crate::borrow_check::nll::ToRegionVid;
 use rustc::mir::{Local, Mir};
 use rustc::ty::{RegionVid, TyCtxt};
 use rustc_data_structures::indexed_vec::Idx;
index 2da158be432be4123ad884fe64fe66c15a17979c..cffc66ac7ddfd5bee81b828270a209755fdac771 100644 (file)
@@ -3,8 +3,7 @@
 //! data to rendered labels.
 
 use super::*;
-use borrow_check::nll::constraints::OutlivesConstraint;
-use dot;
+use crate::borrow_check::nll::constraints::OutlivesConstraint;
 use std::borrow::Cow;
 use std::io::{self, Write};
 
index fee5dc86465873e23cf834a898503e0e522a7c84..7fe657702d756375d89bb2583eaefbad7e5c3e5c 100644 (file)
@@ -1,9 +1,11 @@
 use super::universal_regions::UniversalRegions;
-use borrow_check::nll::constraints::graph::NormalConstraintGraph;
-use borrow_check::nll::constraints::{ConstraintSccIndex, ConstraintSet, OutlivesConstraint};
-use borrow_check::nll::region_infer::values::{PlaceholderIndices, RegionElement, ToElementIndex};
-use borrow_check::nll::type_check::free_region_relations::UniversalRegionRelations;
-use borrow_check::nll::type_check::Locations;
+use crate::borrow_check::nll::constraints::graph::NormalConstraintGraph;
+use crate::borrow_check::nll::constraints::{ConstraintSccIndex, ConstraintSet, OutlivesConstraint};
+use crate::borrow_check::nll::region_infer::values::{
+    PlaceholderIndices, RegionElement, ToElementIndex
+};
+use crate::borrow_check::nll::type_check::free_region_relations::UniversalRegionRelations;
+use crate::borrow_check::nll::type_check::Locations;
 use rustc::hir::def_id::DefId;
 use rustc::infer::canonical::QueryRegionConstraint;
 use rustc::infer::region_constraints::{GenericKind, VarInfos, VerifyBound};
index b7555e57a62bb60a40b319990c836f8d999563d0..1a72205ad7ae1ba0e3e4c7a7fb3e767b9a2c7d12 100644 (file)
@@ -1,8 +1,8 @@
-use borrow_check::nll::constraints::OutlivesConstraint;
-use borrow_check::nll::region_infer::TypeTest;
-use borrow_check::nll::type_check::{Locations, MirTypeckRegionConstraints};
-use borrow_check::nll::universal_regions::UniversalRegions;
-use borrow_check::nll::ToRegionVid;
+use crate::borrow_check::nll::constraints::OutlivesConstraint;
+use crate::borrow_check::nll::region_infer::TypeTest;
+use crate::borrow_check::nll::type_check::{Locations, MirTypeckRegionConstraints};
+use crate::borrow_check::nll::universal_regions::UniversalRegions;
+use crate::borrow_check::nll::ToRegionVid;
 use rustc::infer::canonical::QueryRegionConstraint;
 use rustc::infer::outlives::env::RegionBoundPairs;
 use rustc::infer::outlives::obligations::{TypeOutlives, TypeOutlivesDelegate};
index b19dc9091cb86a1d911220f70a0a9c185a8d4748..f549aea81f69f0742372de6a7d9507914aefc755 100644 (file)
@@ -1,7 +1,7 @@
-use borrow_check::nll::type_check::constraint_conversion;
-use borrow_check::nll::type_check::{Locations, MirTypeckRegionConstraints};
-use borrow_check::nll::universal_regions::UniversalRegions;
-use borrow_check::nll::ToRegionVid;
+use crate::borrow_check::nll::type_check::constraint_conversion;
+use crate::borrow_check::nll::type_check::{Locations, MirTypeckRegionConstraints};
+use crate::borrow_check::nll::universal_regions::UniversalRegions;
+use crate::borrow_check::nll::ToRegionVid;
 use rustc::infer::canonical::QueryRegionConstraint;
 use rustc::infer::outlives::free_region_map::FreeRegionRelations;
 use rustc::infer::region_constraints::GenericKind;
index ef0f7e1b217a9287a0f072bde1480423cd8d5e6c..50828c294fa1b8d83f9d2bb00caa38ed0fd919ac 100644 (file)
@@ -7,7 +7,7 @@
 //! `RETURN_PLACE` the MIR arguments) are always fully normalized (and
 //! contain revealed `impl Trait` values).
 
-use borrow_check::nll::universal_regions::UniversalRegions;
+use crate::borrow_check::nll::universal_regions::UniversalRegions;
 use rustc::infer::LateBoundRegionConversionTime;
 use rustc::mir::*;
 use rustc::ty::Ty;
index dda74e6a6a688b0d3bc1dfb0905b8477ddd8615f..5e2e4407cbecddaf706b46ac23f97bb15654d27b 100644 (file)
@@ -6,13 +6,13 @@
 //! liveness code so that it only operates over variables with regions in their
 //! types, instead of all variables.
 
-use borrow_check::nll::ToRegionVid;
-use borrow_check::nll::facts::{AllFacts, AllFactsExt};
+use crate::borrow_check::nll::ToRegionVid;
+use crate::borrow_check::nll::facts::{AllFacts, AllFactsExt};
+use crate::util::liveness::LiveVariableMap;
 use rustc::mir::{Local, Mir};
 use rustc::ty::{RegionVid, TyCtxt};
 use rustc_data_structures::fx::FxHashSet;
 use rustc_data_structures::indexed_vec::{Idx, IndexVec};
-use util::liveness::LiveVariableMap;
 
 /// Map between Local and LiveVar indices: the purpose of this
 /// map is to define the subset of local variables for which we need
index 3f13cc8b647784adb7df671b4515924f05bad3bc..e9765d2798cd73aa0ac3a5f8dae93f9519b0d963 100644 (file)
@@ -1,10 +1,10 @@
-use borrow_check::nll::region_infer::values::{PointIndex, RegionValueElements};
-use borrow_check::nll::type_check::liveness::liveness_map::{LiveVar, NllLivenessMap};
+use crate::borrow_check::nll::region_infer::values::{PointIndex, RegionValueElements};
+use crate::borrow_check::nll::type_check::liveness::liveness_map::{LiveVar, NllLivenessMap};
+use crate::util::liveness::{categorize, DefUse, LiveVariableMap};
 use rustc::mir::visit::{PlaceContext, Visitor};
 use rustc::mir::{Local, Location, Mir};
 use rustc_data_structures::indexed_vec::{Idx, IndexVec};
 use rustc_data_structures::vec_linked_list as vll;
-use util::liveness::{categorize, DefUse, LiveVariableMap};
 
 /// A map that cross references each local with the locations where it
 /// is defined (assigned), used, or dropped. Used during liveness
index 633695a9b9ce5510b19097288c71ed44c0a8d060..a5510ba6936cc31f724c3f282139414dfe97c4a3 100644 (file)
@@ -1,11 +1,11 @@
-use borrow_check::location::LocationTable;
-use borrow_check::nll::region_infer::values::RegionValueElements;
-use borrow_check::nll::constraints::ConstraintSet;
-use borrow_check::nll::NllLivenessMap;
-use borrow_check::nll::universal_regions::UniversalRegions;
-use dataflow::move_paths::MoveData;
-use dataflow::MaybeInitializedPlaces;
-use dataflow::FlowAtLocation;
+use crate::borrow_check::location::LocationTable;
+use crate::borrow_check::nll::region_infer::values::RegionValueElements;
+use crate::borrow_check::nll::constraints::ConstraintSet;
+use crate::borrow_check::nll::NllLivenessMap;
+use crate::borrow_check::nll::universal_regions::UniversalRegions;
+use crate::dataflow::move_paths::MoveData;
+use crate::dataflow::MaybeInitializedPlaces;
+use crate::dataflow::FlowAtLocation;
 use rustc::mir::Mir;
 use rustc::ty::RegionVid;
 use rustc_data_structures::fx::FxHashSet;
index 77e8dd9d130e37cdf04b77d847ff0096bb140947..d058be03f55e66d9820823c074d51eb646d4f848 100644 (file)
@@ -1,12 +1,13 @@
-use borrow_check::location::LocationTable;
-use borrow_check::nll::region_infer::values::{self, PointIndex, RegionValueElements};
-use borrow_check::nll::type_check::liveness::liveness_map::{LiveVar, NllLivenessMap};
-use borrow_check::nll::type_check::liveness::local_use_map::LocalUseMap;
-use borrow_check::nll::type_check::NormalizeLocation;
-use borrow_check::nll::type_check::TypeChecker;
-use dataflow::move_paths::indexes::MovePathIndex;
-use dataflow::move_paths::MoveData;
-use dataflow::{FlowAtLocation, FlowsAtLocation, MaybeInitializedPlaces};
+use crate::borrow_check::location::LocationTable;
+use crate::borrow_check::nll::region_infer::values::{self, PointIndex, RegionValueElements};
+use crate::borrow_check::nll::type_check::liveness::liveness_map::{LiveVar, NllLivenessMap};
+use crate::borrow_check::nll::type_check::liveness::local_use_map::LocalUseMap;
+use crate::borrow_check::nll::type_check::NormalizeLocation;
+use crate::borrow_check::nll::type_check::TypeChecker;
+use crate::dataflow::move_paths::indexes::MovePathIndex;
+use crate::dataflow::move_paths::MoveData;
+use crate::dataflow::{FlowAtLocation, FlowsAtLocation, MaybeInitializedPlaces};
+use crate::util::liveness::LiveVariableMap;
 use rustc::infer::canonical::QueryRegionConstraint;
 use rustc::mir::{BasicBlock, ConstraintCategory, Local, Location, Mir};
 use rustc::traits::query::dropck_outlives::DropckOutlivesResult;
@@ -16,7 +17,6 @@
 use rustc_data_structures::bit_set::HybridBitSet;
 use rustc_data_structures::fx::FxHashMap;
 use std::rc::Rc;
-use util::liveness::LiveVariableMap;
 
 /// This is the heart of the liveness computation. For each variable X
 /// that requires a liveness computation, it walks over all the uses
index 3e6aa358ee0d15d1d7491cd34f9bf2b1ff85225e..19ff47f9c390d73d1c16b838989080f297a124dd 100644 (file)
@@ -2,24 +2,25 @@
 
 #![allow(unreachable_code)]
 
-use borrow_check::borrow_set::BorrowSet;
-use borrow_check::location::LocationTable;
-use borrow_check::nll::constraints::{ConstraintSet, OutlivesConstraint};
-use borrow_check::nll::facts::AllFacts;
-use borrow_check::nll::region_infer::values::LivenessValues;
-use borrow_check::nll::region_infer::values::PlaceholderIndex;
-use borrow_check::nll::region_infer::values::PlaceholderIndices;
-use borrow_check::nll::region_infer::values::RegionValueElements;
-use borrow_check::nll::region_infer::{ClosureRegionRequirementsExt, TypeTest};
-use borrow_check::nll::renumber;
-use borrow_check::nll::type_check::free_region_relations::{
+use crate::borrow_check::borrow_set::BorrowSet;
+use crate::borrow_check::location::LocationTable;
+use crate::borrow_check::nll::constraints::{ConstraintSet, OutlivesConstraint};
+use crate::borrow_check::nll::facts::AllFacts;
+use crate::borrow_check::nll::region_infer::values::LivenessValues;
+use crate::borrow_check::nll::region_infer::values::PlaceholderIndex;
+use crate::borrow_check::nll::region_infer::values::PlaceholderIndices;
+use crate::borrow_check::nll::region_infer::values::RegionValueElements;
+use crate::borrow_check::nll::region_infer::{ClosureRegionRequirementsExt, TypeTest};
+use crate::borrow_check::nll::renumber;
+use crate::borrow_check::nll::type_check::free_region_relations::{
     CreateResult, UniversalRegionRelations,
 };
-use borrow_check::nll::universal_regions::{DefiningTy, UniversalRegions};
-use borrow_check::nll::ToRegionVid;
-use dataflow::move_paths::MoveData;
-use dataflow::FlowAtLocation;
-use dataflow::MaybeInitializedPlaces;
+use crate::borrow_check::nll::universal_regions::{DefiningTy, UniversalRegions};
+use crate::borrow_check::nll::ToRegionVid;
+use crate::dataflow::move_paths::MoveData;
+use crate::dataflow::FlowAtLocation;
+use crate::dataflow::MaybeInitializedPlaces;
+use crate::transform::{MirPass, MirSource};
 use either::Either;
 use rustc::hir;
 use rustc::hir::def_id::DefId;
@@ -46,7 +47,6 @@
 use std::rc::Rc;
 use std::{fmt, iter};
 use syntax_pos::{Span, DUMMY_SP};
-use transform::{MirPass, MirSource};
 
 macro_rules! span_mirbug {
     ($context:expr, $elem:expr, $($message:tt)*) => ({
@@ -210,7 +210,7 @@ fn type_check_internal<'a, 'gcx, 'tcx, R>(
     extra(&mut checker)
 }
 
-fn translate_outlives_facts(cx: &mut BorrowCheckContext) {
+fn translate_outlives_facts(cx: &mut BorrowCheckContext<'_, '_>) {
     if let Some(facts) = cx.all_facts {
         let location_table = cx.location_table;
         facts
@@ -235,7 +235,7 @@ fn translate_outlives_facts(cx: &mut BorrowCheckContext) {
     }
 }
 
-fn mirbug(tcx: TyCtxt, span: Span, msg: &str) {
+fn mirbug(tcx: TyCtxt<'_, '_, '_>, span: Span, msg: &str) {
     // We sometimes see MIR failures (notably predicate failures) due to
     // the fact that we check rvalue sized predicates here. So use `delay_span_bug`
     // to avoid reporting bugs in those cases.
@@ -266,7 +266,7 @@ fn visit_span(&mut self, span: &Span) {
         }
     }
 
-    fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext, location: Location) {
+    fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext<'_>, location: Location) {
         self.sanitize_place(place, location, context);
     }
 
@@ -447,7 +447,7 @@ fn sanitize_place(
         &mut self,
         place: &Place<'tcx>,
         location: Location,
-        context: PlaceContext,
+        context: PlaceContext<'_>,
     ) -> PlaceTy<'tcx> {
         debug!("sanitize_place: {:?}", place);
         let place_ty = match *place {
index 74ad7d988cc1afb498d13ed6e5e5885e26784d45..1748e3008902128960fa9b72acde767ec86d916b 100644 (file)
@@ -1,5 +1,5 @@
-use borrow_check::nll::constraints::OutlivesConstraint;
-use borrow_check::nll::type_check::{BorrowCheckContext, Locations};
+use crate::borrow_check::nll::constraints::OutlivesConstraint;
+use crate::borrow_check::nll::type_check::{BorrowCheckContext, Locations};
 use rustc::infer::nll_relate::{TypeRelating, TypeRelatingDelegate, NormalizationStrategy};
 use rustc::infer::{InferCtxt, NLLRegionVariableOrigin};
 use rustc::mir::ConstraintCategory;
index 6875aced8d231944a8be446f425b6781c0e3ec9d..1cea9f662d3517118e5f85b82055670f3b46f9af 100644 (file)
@@ -1,8 +1,8 @@
-use borrow_check::borrow_set::{BorrowSet, BorrowData, TwoPhaseActivation};
-use borrow_check::places_conflict;
-use borrow_check::Context;
-use borrow_check::AccessDepth;
-use dataflow::indexes::BorrowIndex;
+use crate::borrow_check::borrow_set::{BorrowSet, BorrowData, TwoPhaseActivation};
+use crate::borrow_check::places_conflict;
+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::{ProjectionElem, BorrowKind};
 use rustc::ty::TyCtxt;
index 4d0b25b1024a3b78efa8145b1c625fb45197ae7a..bad236a6f5256ace28e16cbad9e4aa1c874ffb10 100644 (file)
@@ -2,7 +2,7 @@
 use rustc::mir::ProjectionElem;
 use rustc::mir::{Local, Mir, Place, Mutability};
 use rustc::ty::{self, TyCtxt};
-use borrow_check::borrow_set::LocalsStateAtExit;
+use crate::borrow_check::borrow_set::LocalsStateAtExit;
 
 /// Extension methods for the `Place` type.
 crate trait PlaceExt<'tcx> {
index ac7182abb36daa58e617e421436fe3cb4064beb8..cd33f22bf3cb7d73e15130383c255885e6ca156a 100644 (file)
@@ -1,6 +1,6 @@
-use borrow_check::ArtificialField;
-use borrow_check::Overlap;
-use borrow_check::{Deep, Shallow, AccessDepth};
+use crate::borrow_check::ArtificialField;
+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};
index 0ff7ff4de10de2cc488838fa0e265a5b40222fd9..8c7359bdee768f0f9f3611430fa561c0f8cfd811 100644 (file)
@@ -3,7 +3,7 @@
 
 use rustc_data_structures::fx::FxHashSet;
 
-use borrow_check::MirBorrowckCtxt;
+use crate::borrow_check::MirBorrowckCtxt;
 
 impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
     /// Walks the MIR adding to the set of `used_mut` locals that will be ignored for the purposes
index f3d89a7a02515b3f17f00a95a44a71a67b3ba6d2..7d93e131a6ca9678cc9794fee7043d76f996c300 100644 (file)
@@ -1,7 +1,7 @@
-use build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
-use build::ForGuard::OutsideGuard;
-use build::matches::ArmHasGuard;
-use hair::*;
+use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
+use crate::build::ForGuard::OutsideGuard;
+use crate::build::matches::ArmHasGuard;
+use crate::hair::*;
 use rustc::mir::*;
 use rustc::hir;
 use syntax_pos::Span;
index a9e468db1d1b79241da2651fefc5f52d561c1a79..778d1e71cedfc3d8bd2414270ec06ec29bc63866 100644 (file)
@@ -1,6 +1,6 @@
 //! Routines for manipulating the control-flow graph.
 
-use build::CFG;
+use crate::build::CFG;
 use rustc::mir::*;
 
 impl<'tcx> CFG<'tcx> {
index 31e0c0daa3fa66ad0dc6f9a8a9413c41b0254314..614668170d5be73c2b8648b6478b7e4a0b160932 100644 (file)
@@ -1,7 +1,7 @@
 //! See docs in build/expr/mod.rs
 
-use build::Builder;
-use hair::*;
+use crate::build::Builder;
+use crate::hair::*;
 use rustc::mir::*;
 use rustc::ty::CanonicalUserTypeAnnotation;
 
index 1f653575a7fbff9a06ba044bfd9e313405110507..38fae8539c8d71bef80656516b0ab1c6860b3cc1 100644 (file)
@@ -1,8 +1,8 @@
 //! See docs in build/expr/mod.rs
 
-use build::expr::category::Category;
-use build::{BlockAnd, BlockAndExtension, Builder};
-use hair::*;
+use crate::build::expr::category::Category;
+use crate::build::{BlockAnd, BlockAndExtension, Builder};
+use crate::hair::*;
 use rustc::middle::region;
 use rustc::mir::*;
 
index 6bd61ab53fd2182df6c75dfb0ebd0721a9b4d58b..ed444191226a1ddef18c7fb89a6457498d921d3d 100644 (file)
@@ -1,9 +1,9 @@
 //! See docs in build/expr/mod.rs
 
-use build::expr::category::Category;
-use build::ForGuard::{OutsideGuard, RefWithinGuard};
-use build::{BlockAnd, BlockAndExtension, Builder};
-use hair::*;
+use crate::build::expr::category::Category;
+use crate::build::ForGuard::{OutsideGuard, RefWithinGuard};
+use crate::build::{BlockAnd, BlockAndExtension, Builder};
+use crate::hair::*;
 use rustc::mir::interpret::EvalErrorKind::BoundsCheck;
 use rustc::mir::*;
 use rustc::ty::{CanonicalUserTypeAnnotation, Variance};
index 3de2f4757865044f9e020817130dd97493a4209b..88dbd93939e547885fa043cc83521d2e975d363d 100644 (file)
@@ -3,9 +3,9 @@
 use rustc_data_structures::fx::FxHashMap;
 use rustc_data_structures::indexed_vec::Idx;
 
-use build::expr::category::{Category, RvalueFunc};
-use build::{BlockAnd, BlockAndExtension, Builder};
-use hair::*;
+use crate::build::expr::category::{Category, RvalueFunc};
+use crate::build::{BlockAnd, BlockAndExtension, Builder};
+use crate::hair::*;
 use rustc::middle::region;
 use rustc::mir::interpret::EvalErrorKind;
 use rustc::mir::*;
@@ -268,7 +268,7 @@ fn expr_as_rvalue(
                             span: expr_span,
                             ty: this.hir.tcx().types.u32,
                             user_ty: None,
-                            literal: this.hir.tcx().intern_lazy_const(ty::LazyConst::Evaluated(
+                            literal: this.hir.tcx().mk_lazy_const(ty::LazyConst::Evaluated(
                                 ty::Const::from_bits(
                                     this.hir.tcx(),
                                     0,
index df271ff6e4016a2497637502f8316e1d355011c2..efa1a4895e0c064dc8128579e06efe93c23ea485 100644 (file)
@@ -1,7 +1,7 @@
 //! See docs in build/expr/mod.rs
 
-use build::{BlockAnd, BlockAndExtension, Builder};
-use hair::*;
+use crate::build::{BlockAnd, BlockAndExtension, Builder};
+use crate::hair::*;
 use rustc::middle::region;
 use rustc::mir::*;
 
index 53f84a495696cb53be51e7d028b3b744ed0d3473..ca7d435e62229aeb2b785d2692953558da8e6015 100644 (file)
@@ -1,4 +1,4 @@
-use hair::*;
+use crate::hair::*;
 
 #[derive(Debug, PartialEq)]
 pub enum Category {
index 2ffff68137dd284c4889d853e2374596f3a2e448..05231bc7b3f16003d6046578666a3e7f281dc2fe 100644 (file)
@@ -1,8 +1,8 @@
 //! See docs in build/expr/mod.rs
 
-use build::expr::category::{Category, RvalueFunc};
-use build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
-use hair::*;
+use crate::build::expr::category::{Category, RvalueFunc};
+use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
+use crate::hair::*;
 use rustc::mir::*;
 use rustc::ty;
 
index 1cbc60586c3567dbd7ac8a79ee9952b61f6b7541..aadc2368f5aec7adddbc1ef85efcbcd6434d51e8 100644 (file)
@@ -1,6 +1,6 @@
-use build::scope::BreakableScope;
-use build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
-use hair::*;
+use crate::build::scope::BreakableScope;
+use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder};
+use crate::hair::*;
 use rustc::mir::*;
 
 impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
index 1b29126082067ab6d5431664cf56189ff3eed2b5..67b6540febea84ded5651362590feb7c17ce77cc 100644 (file)
@@ -4,11 +4,11 @@
 //! wrapped up as expressions (e.g., blocks). To make this ergonomic, we use this
 //! latter `EvalInto` trait.
 
-use build::{BlockAnd, Builder};
-use hair::*;
+use crate::build::{BlockAnd, Builder};
+use crate::hair::*;
 use rustc::mir::*;
 
-pub(in build) trait EvalInto<'tcx> {
+pub(in crate::build) trait EvalInto<'tcx> {
     fn eval_into<'a, 'gcx>(self,
                            builder: &mut Builder<'a, 'gcx, 'tcx>,
                            destination: &Place<'tcx>,
index 2f1e8c03f2f7eefddb32199b0b551ac764eaa165..cf051ba2e0fa6ab9dafb12578348293b64f10673 100644 (file)
@@ -3,11 +3,11 @@
 //! includes the high-level algorithm, the submodules contain the
 //! details.
 
-use build::scope::{CachedBlock, DropKind};
-use build::ForGuard::{self, OutsideGuard, RefWithinGuard, ValWithinGuard};
-use build::{BlockAnd, BlockAndExtension, Builder};
-use build::{GuardFrame, GuardFrameLocal, LocalsForNode};
-use hair::*;
+use crate::build::scope::{CachedBlock, DropKind};
+use crate::build::ForGuard::{self, OutsideGuard, RefWithinGuard, ValWithinGuard};
+use crate::build::{BlockAnd, BlockAndExtension, Builder};
+use crate::build::{GuardFrame, GuardFrameLocal, LocalsForNode};
+use crate::hair::*;
 use rustc::mir::*;
 use rustc::ty::{self, CanonicalUserTypeAnnotation, Ty};
 use rustc::ty::layout::VariantIdx;
index c219fd2218223a0cbbc28b87404409cde7850067..6be9ccb27036e28b7176fcdc48ca4718f05cd29c 100644 (file)
@@ -12,9 +12,9 @@
 //! sort of test: for example, testing which variant an enum is, or
 //! testing a value against a constant.
 
-use build::Builder;
-use build::matches::{Ascription, Binding, MatchPair, Candidate};
-use hair::*;
+use crate::build::Builder;
+use crate::build::matches::{Ascription, Binding, MatchPair, Candidate};
+use crate::hair::*;
 use rustc::ty;
 use rustc::ty::layout::{Integer, IntegerExt, Size};
 use syntax::attr::{SignedInt, UnsignedInt};
index 696c173b048ad282227269634a70847bd5a5ac19..efac4457b8ebdbc370bc27714c0e683132d010ca 100644 (file)
@@ -5,10 +5,10 @@
 // identify what tests are needed, perform the tests, and then filter
 // the candidates based on the result.
 
-use build::Builder;
-use build::matches::{Candidate, MatchPair, Test, TestKind};
-use hair::*;
-use hair::pattern::compare_const_vals;
+use crate::build::Builder;
+use crate::build::matches::{Candidate, MatchPair, Test, TestKind};
+use crate::hair::*;
+use crate::hair::pattern::compare_const_vals;
 use rustc_data_structures::bit_set::BitSet;
 use rustc_data_structures::fx::FxHashMap;
 use rustc::ty::{self, Ty};
@@ -302,7 +302,7 @@ pub fn perform_test(&mut self,
                     }
                     let eq_def_id = self.hir.tcx().lang_items().eq_trait().unwrap();
                     let (mty, method) = self.hir.trait_method(eq_def_id, "eq", ty, &[ty.into()]);
-                    let method = self.hir.tcx().intern_lazy_const(ty::LazyConst::Evaluated(method));
+                    let method = self.hir.tcx().mk_lazy_const(ty::LazyConst::Evaluated(method));
 
                     let re_erased = self.hir.tcx().types.re_erased;
                     // take the argument by reference
index b5a1a388e9cbce75af59d967116f21e71095c091..ed12c1b3bc9c1de1461b3c657a97eef8eebfc24d 100644 (file)
@@ -1,6 +1,6 @@
-use build::Builder;
-use build::matches::MatchPair;
-use hair::*;
+use crate::build::Builder;
+use crate::build::matches::MatchPair;
+use crate::hair::*;
 use rustc::mir::*;
 use std::u32;
 use std::convert::TryInto;
index c849c022428407be55903d1ee267f53f8a0f4305..096020b0f7305b0ee990a2c6f80b573b7200835b 100644 (file)
@@ -1,7 +1,7 @@
 //! Miscellaneous builder routines that are not specific to building any particular
 //! kind of thing.
 
-use build::Builder;
+use crate::build::Builder;
 
 use rustc::ty::{self, Ty};
 
@@ -33,7 +33,7 @@ pub fn literal_operand(&mut self,
             span,
             ty,
             user_ty: None,
-            literal: self.hir.tcx().intern_lazy_const(ty::LazyConst::Evaluated(literal)),
+            literal: self.hir.tcx().mk_lazy_const(ty::LazyConst::Evaluated(literal)),
         };
         Operand::Constant(constant)
     }
index f38648fda0e36355d3a4c1ba92f782b0f884140d..a52b032aeb508c5e8a825cd8208f6029da94bfeb 100644 (file)
@@ -1,7 +1,10 @@
-use build;
-use build::scope::{CachedBlock, DropKind};
-use hair::cx::Cx;
-use hair::{LintLevel, BindingMode, PatternKind};
+use crate::build;
+use crate::build::scope::{CachedBlock, DropKind};
+use crate::hair::cx::Cx;
+use crate::hair::{LintLevel, BindingMode, PatternKind};
+use crate::shim;
+use crate::transform::MirSource;
+use crate::util as mir_util;
 use rustc::hir;
 use rustc::hir::Node;
 use rustc::hir::def_id::DefId;
@@ -13,7 +16,6 @@
 use rustc::util::nodemap::NodeMap;
 use rustc_target::spec::PanicStrategy;
 use rustc_data_structures::indexed_vec::{IndexVec, Idx};
-use shim;
 use std::mem;
 use std::u32;
 use rustc_target::spec::abi::Abi;
@@ -21,8 +23,6 @@
 use syntax::attr::{self, UnwindAttr};
 use syntax::symbol::keywords;
 use syntax_pos::Span;
-use transform::MirSource;
-use util as mir_util;
 
 use super::lints;
 
@@ -161,7 +161,7 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t
         };
         globalizer.visit_mir(&mut mir);
         let mir = unsafe {
-            mem::transmute::<Mir, Mir<'tcx>>(mir)
+            mem::transmute::<Mir<'_>, Mir<'tcx>>(mir)
         };
 
         mir_util::dump_mir(tcx, None, "mir_map", &0,
@@ -241,7 +241,7 @@ fn create_constructor_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
             };
             globalizer.visit_mir(&mut mir);
             let mir = unsafe {
-                mem::transmute::<Mir, Mir<'tcx>>(mir)
+                mem::transmute::<Mir<'_>, Mir<'tcx>>(mir)
             };
 
             mir_util::dump_mir(tcx, None, "mir_map", &0,
index 78abba5f885b2e94882cd8f3f2785d0a7781e445..3872f5db26278d79b53c0d8421692927e583fc70 100644 (file)
@@ -77,8 +77,8 @@
 
 */
 
-use build::{BlockAnd, BlockAndExtension, Builder, CFG};
-use hair::LintLevel;
+use crate::build::{BlockAnd, BlockAndExtension, Builder, CFG};
+use crate::hair::LintLevel;
 use rustc::middle::region;
 use rustc::ty::Ty;
 use rustc::hir;
index f83a930353b7386ea610ab5791932af921d1b764..d1b4486dd9345d76d7e4d533685a9cd17e2ed7c4 100644 (file)
@@ -190,7 +190,7 @@ enum ConstEvalError {
 }
 
 impl fmt::Display for ConstEvalError {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         use self::ConstEvalError::*;
         match *self {
             NeedsRfc(ref msg) => {
index 375bc4fead4433fc6101baccc1b2c6aa0e3136f9..d0b9fbc99f03f754d24776721cc4533dabccf57e 100644 (file)
@@ -4,8 +4,8 @@
 use rustc::mir::{BasicBlock, Location};
 use rustc_data_structures::bit_set::{BitIter, BitSet, HybridBitSet};
 
-use dataflow::{BitDenotation, BlockSets, DataflowResults};
-use dataflow::move_paths::{HasMoveData, MovePathIndex};
+use crate::dataflow::{BitDenotation, BlockSets, DataflowResults};
+use crate::dataflow::move_paths::{HasMoveData, MovePathIndex};
 
 use std::iter;
 
@@ -115,7 +115,7 @@ pub fn contains(&self, x: BD::Idx) -> bool {
     }
 
     /// Returns an iterator over the elements present in the current state.
-    pub fn iter_incoming(&self) -> iter::Peekable<BitIter<BD::Idx>> {
+    pub fn iter_incoming(&self) -> iter::Peekable<BitIter<'_, BD::Idx>> {
         self.curr_state.iter().peekable()
     }
 
@@ -124,7 +124,7 @@ pub fn iter_incoming(&self) -> iter::Peekable<BitIter<BD::Idx>> {
     /// Invokes `f` with an iterator over the resulting state.
     pub fn with_iter_outgoing<F>(&self, f: F)
     where
-        F: FnOnce(BitIter<BD::Idx>),
+        F: FnOnce(BitIter<'_, BD::Idx>),
     {
         let mut curr_state = self.curr_state.clone();
         curr_state.union(&self.stmt_gen);
index 22fb7a3bc470e298489a41d8a2908f43eedf8695..49499cf928d743a96b7bdd2e71b1d78b1c0675ca 100644 (file)
@@ -1,6 +1,6 @@
 use rustc::mir::{self, Mir, Location};
 use rustc::ty::{self, TyCtxt};
-use util::elaborate_drops::DropFlagState;
+use crate::util::elaborate_drops::DropFlagState;
 
 use super::{MoveDataParamEnv};
 use super::indexes::MovePathIndex;
index 34752baa020e224444d73e8c934a87f318313151..9d9f18d4b0dcf926ae47784872f4d1fdf25d0603 100644 (file)
@@ -3,8 +3,6 @@
 use syntax::ast::NodeId;
 use rustc::mir::{BasicBlock, Mir};
 
-use dot;
-
 use std::fs;
 use std::io;
 use std::marker::PhantomData;
@@ -59,7 +57,7 @@ pub(crate) fn print_borrowck_graph_to<'a, 'tcx, BD, P>(
 #[derive(Copy, Clone, PartialEq, Eq, Debug)]
 pub struct Edge { source: BasicBlock, index: usize }
 
-fn outgoing(mir: &Mir, bb: BasicBlock) -> Vec<Edge> {
+fn outgoing(mir: &Mir<'_>, bb: BasicBlock) -> Vec<Edge> {
     (0..mir[bb].terminator().successors().count())
         .map(|index| Edge { source: bb, index: index}).collect()
 }
@@ -70,18 +68,18 @@ impl<'a, 'tcx, MWF, P> dot::Labeller<'a> for Graph<'a, 'tcx, MWF, P>
 {
     type Node = Node;
     type Edge = Edge;
-    fn graph_id(&self) -> dot::Id {
+    fn graph_id(&self) -> dot::Id<'_> {
         dot::Id::new(format!("graph_for_node_{}",
                              self.mbcx.node_id()))
             .unwrap()
     }
 
-    fn node_id(&self, n: &Node) -> dot::Id {
+    fn node_id(&self, n: &Node) -> dot::Id<'_> {
         dot::Id::new(format!("bb_{}", n.index()))
             .unwrap()
     }
 
-    fn node_label(&self, n: &Node) -> dot::LabelText {
+    fn node_label(&self, n: &Node) -> dot::LabelText<'_> {
         // Node label is something like this:
         // +---------+----------------------------------+------------------+------------------+
         // | ENTRY   | MIR                              | GEN              | KILL             |
@@ -105,7 +103,7 @@ fn node_label(&self, n: &Node) -> dot::LabelText {
     }
 
 
-    fn node_shape(&self, _n: &Node) -> Option<dot::LabelText> {
+    fn node_shape(&self, _n: &Node) -> Option<dot::LabelText<'_>> {
         Some(dot::LabelText::label("none"))
     }
 
@@ -125,7 +123,7 @@ fn node_label_internal<W: io::Write>(&self,
                                          n: &Node,
                                          w: &mut W,
                                          block: BasicBlock,
-                                         mir: &Mir) -> io::Result<()> {
+                                         mir: &Mir<'_>) -> io::Result<()> {
         // Header rows
         const HDRS: [&str; 4] = ["ENTRY", "MIR", "BLOCK GENS", "BLOCK KILLS"];
         const HDR_FMT: &str = "bgcolor=\"grey\"";
@@ -150,7 +148,7 @@ fn node_label_verbose_row<W: io::Write>(&self,
                                             n: &Node,
                                             w: &mut W,
                                             block: BasicBlock,
-                                            mir: &Mir)
+                                            mir: &Mir<'_>)
                                             -> io::Result<()> {
         let i = n.index();
 
@@ -200,7 +198,7 @@ fn node_label_final_row<W: io::Write>(&self,
                                           n: &Node,
                                           w: &mut W,
                                           block: BasicBlock,
-                                          mir: &Mir)
+                                          mir: &Mir<'_>)
                                           -> io::Result<()> {
         let i = n.index();
 
@@ -241,7 +239,7 @@ impl<'a, 'tcx, MWF, P> dot::GraphWalk<'a> for Graph<'a, 'tcx, MWF, P>
 {
     type Node = Node;
     type Edge = Edge;
-    fn nodes(&self) -> dot::Nodes<Node> {
+    fn nodes(&self) -> dot::Nodes<'_, Node> {
         self.mbcx.mir()
             .basic_blocks()
             .indices()
@@ -249,7 +247,7 @@ fn nodes(&self) -> dot::Nodes<Node> {
             .into()
     }
 
-    fn edges(&self) -> dot::Edges<Edge> {
+    fn edges(&self) -> dot::Edges<'_, Edge> {
         let mir = self.mbcx.mir();
 
         mir.basic_blocks()
index 9d03e35a35069166d20ad95fa39bb5cb18bbad68..51d628ce6c5c28b5ee59b92d9b7849e3c15052e4 100644 (file)
@@ -2,7 +2,7 @@
 
 use rustc::mir::*;
 use rustc::mir::visit::Visitor;
-use dataflow::BitDenotation;
+use crate::dataflow::BitDenotation;
 
 /// This calculates if any part of a MIR local could have previously been borrowed.
 /// This means that once a local has been borrowed, its bit will be set
@@ -38,7 +38,7 @@ fn start_block_effect(&self, _sets: &mut BitSet<Local>) {
     }
 
     fn statement_effect(&self,
-                        sets: &mut BlockSets<Local>,
+                        sets: &mut BlockSets<'_, Local>,
                         loc: Location) {
         let stmt = &self.mir[loc.block].statements[loc.statement_index];
 
@@ -54,7 +54,7 @@ fn statement_effect(&self,
     }
 
     fn terminator_effect(&self,
-                         sets: &mut BlockSets<Local>,
+                         sets: &mut BlockSets<'_, Local>,
                          loc: Location) {
         BorrowedLocalsVisitor {
             sets,
index 72218e29cfd20f6b5eb8069e337005bd7a4a71cb..beb0b3187082b410f1f0b71bbf4dacf19f27b916 100644 (file)
@@ -1,5 +1,5 @@
-use borrow_check::borrow_set::{BorrowSet, BorrowData};
-use borrow_check::place_ext::PlaceExt;
+use crate::borrow_check::borrow_set::{BorrowSet, BorrowData};
+use crate::borrow_check::place_ext::PlaceExt;
 
 use rustc::mir::{self, Location, Place, Mir};
 use rustc::ty::TyCtxt;
@@ -9,11 +9,11 @@
 use rustc_data_structures::fx::FxHashMap;
 use rustc_data_structures::indexed_vec::{Idx, IndexVec};
 
-use dataflow::{BitDenotation, BlockSets, InitialFlow};
-pub use dataflow::indexes::BorrowIndex;
-use borrow_check::nll::region_infer::RegionInferenceContext;
-use borrow_check::nll::ToRegionVid;
-use borrow_check::places_conflict;
+use crate::dataflow::{BitDenotation, BlockSets, InitialFlow};
+pub use crate::dataflow::indexes::BorrowIndex;
+use crate::borrow_check::nll::region_infer::RegionInferenceContext;
+use crate::borrow_check::nll::ToRegionVid;
+use crate::borrow_check::places_conflict;
 
 use std::rc::Rc;
 
@@ -163,7 +163,7 @@ pub fn location(&self, idx: BorrowIndex) -> &Location {
     /// Add all borrows to the kill set, if those borrows are out of scope at `location`.
     /// That means they went out of a nonlexical scope
     fn kill_loans_out_of_scope_at_location(&self,
-                                           sets: &mut BlockSets<BorrowIndex>,
+                                           sets: &mut BlockSets<'_, BorrowIndex>,
                                            location: Location) {
         // NOTE: The state associated with a given `location`
         // reflects the dataflow on entry to the statement.
@@ -184,7 +184,7 @@ fn kill_loans_out_of_scope_at_location(&self,
     /// Kill any borrows that conflict with `place`.
     fn kill_borrows_on_place(
         &self,
-        sets: &mut BlockSets<BorrowIndex>,
+        sets: &mut BlockSets<'_, BorrowIndex>,
         place: &Place<'tcx>
     ) {
         debug!("kill_borrows_on_place: place={:?}", place);
@@ -243,13 +243,13 @@ fn start_block_effect(&self, _entry_set: &mut BitSet<BorrowIndex>) {
     }
 
     fn before_statement_effect(&self,
-                               sets: &mut BlockSets<BorrowIndex>,
+                               sets: &mut BlockSets<'_, BorrowIndex>,
                                location: Location) {
         debug!("Borrows::before_statement_effect sets: {:?} location: {:?}", sets, location);
         self.kill_loans_out_of_scope_at_location(sets, location);
     }
 
-    fn statement_effect(&self, sets: &mut BlockSets<BorrowIndex>, location: Location) {
+    fn statement_effect(&self, sets: &mut BlockSets<'_, BorrowIndex>, location: Location) {
         debug!("Borrows::statement_effect: sets={:?} location={:?}", sets, location);
 
         let block = &self.mir.basic_blocks().get(location.block).unwrap_or_else(|| {
@@ -307,13 +307,13 @@ fn statement_effect(&self, sets: &mut BlockSets<BorrowIndex>, location: Location
     }
 
     fn before_terminator_effect(&self,
-                                sets: &mut BlockSets<BorrowIndex>,
+                                sets: &mut BlockSets<'_, BorrowIndex>,
                                 location: Location) {
         debug!("Borrows::before_terminator_effect sets: {:?} location: {:?}", sets, location);
         self.kill_loans_out_of_scope_at_location(sets, location);
     }
 
-    fn terminator_effect(&self, _: &mut BlockSets<BorrowIndex>, _: Location) {}
+    fn terminator_effect(&self, _: &mut BlockSets<'_, BorrowIndex>, _: Location) {}
 
     fn propagate_call_return(
         &self,
index 1ccda3a12e433a8d3ca2d283e90b1c2989f747e2..c8965b9f7f4c79d94fad08b09b1b581a74713530 100644 (file)
@@ -9,7 +9,7 @@
 
 use super::MoveDataParamEnv;
 
-use util::elaborate_drops::DropFlagState;
+use crate::util::elaborate_drops::DropFlagState;
 
 use super::move_paths::{HasMoveData, MoveData, MovePathIndex, InitIndex};
 use super::move_paths::{LookupResult, InitKind};
@@ -251,7 +251,7 @@ fn move_data(&self) -> &MoveData<'tcx> { &self.mdpe.move_data }
 
 
 impl<'a, 'gcx, 'tcx> MaybeInitializedPlaces<'a, 'gcx, 'tcx> {
-    fn update_bits(sets: &mut BlockSets<MovePathIndex>, path: MovePathIndex,
+    fn update_bits(sets: &mut BlockSets<'_, MovePathIndex>, path: MovePathIndex,
                    state: DropFlagState)
     {
         match state {
@@ -262,7 +262,7 @@ fn update_bits(sets: &mut BlockSets<MovePathIndex>, path: MovePathIndex,
 }
 
 impl<'a, 'gcx, 'tcx> MaybeUninitializedPlaces<'a, 'gcx, 'tcx> {
-    fn update_bits(sets: &mut BlockSets<MovePathIndex>, path: MovePathIndex,
+    fn update_bits(sets: &mut BlockSets<'_, MovePathIndex>, path: MovePathIndex,
                    state: DropFlagState)
     {
         match state {
@@ -273,7 +273,7 @@ fn update_bits(sets: &mut BlockSets<MovePathIndex>, path: MovePathIndex,
 }
 
 impl<'a, 'gcx, 'tcx> DefinitelyInitializedPlaces<'a, 'gcx, 'tcx> {
-    fn update_bits(sets: &mut BlockSets<MovePathIndex>, path: MovePathIndex,
+    fn update_bits(sets: &mut BlockSets<'_, MovePathIndex>, path: MovePathIndex,
                    state: DropFlagState)
     {
         match state {
@@ -300,7 +300,7 @@ fn start_block_effect(&self, entry_set: &mut BitSet<MovePathIndex>) {
     }
 
     fn statement_effect(&self,
-                        sets: &mut BlockSets<MovePathIndex>,
+                        sets: &mut BlockSets<'_, MovePathIndex>,
                         location: Location)
     {
         drop_flag_effects_for_location(
@@ -311,7 +311,7 @@ fn statement_effect(&self,
     }
 
     fn terminator_effect(&self,
-                         sets: &mut BlockSets<MovePathIndex>,
+                         sets: &mut BlockSets<'_, MovePathIndex>,
                          location: Location)
     {
         drop_flag_effects_for_location(
@@ -358,7 +358,7 @@ fn start_block_effect(&self, entry_set: &mut BitSet<MovePathIndex>) {
     }
 
     fn statement_effect(&self,
-                        sets: &mut BlockSets<MovePathIndex>,
+                        sets: &mut BlockSets<'_, MovePathIndex>,
                         location: Location)
     {
         drop_flag_effects_for_location(
@@ -369,7 +369,7 @@ fn statement_effect(&self,
     }
 
     fn terminator_effect(&self,
-                         sets: &mut BlockSets<MovePathIndex>,
+                         sets: &mut BlockSets<'_, MovePathIndex>,
                          location: Location)
     {
         drop_flag_effects_for_location(
@@ -414,7 +414,7 @@ fn start_block_effect(&self, entry_set: &mut BitSet<MovePathIndex>) {
     }
 
     fn statement_effect(&self,
-                        sets: &mut BlockSets<MovePathIndex>,
+                        sets: &mut BlockSets<'_, MovePathIndex>,
                         location: Location)
     {
         drop_flag_effects_for_location(
@@ -425,7 +425,7 @@ fn statement_effect(&self,
     }
 
     fn terminator_effect(&self,
-                         sets: &mut BlockSets<MovePathIndex>,
+                         sets: &mut BlockSets<'_, MovePathIndex>,
                          location: Location)
     {
         drop_flag_effects_for_location(
@@ -464,7 +464,7 @@ fn start_block_effect(&self, entry_set: &mut BitSet<InitIndex>) {
     }
 
     fn statement_effect(&self,
-                        sets: &mut BlockSets<InitIndex>,
+                        sets: &mut BlockSets<'_, InitIndex>,
                         location: Location) {
         let (_, mir, move_data) = (self.tcx, self.mir, self.move_data());
         let stmt = &mir[location.block].statements[location.statement_index];
@@ -511,7 +511,7 @@ fn statement_effect(&self,
     }
 
     fn terminator_effect(&self,
-                         sets: &mut BlockSets<InitIndex>,
+                         sets: &mut BlockSets<'_, InitIndex>,
                          location: Location)
     {
         let (mir, move_data) = (self.mir, self.move_data());
index 9c17076e6fde0c8278df4a65a2631f772fe7020f..6b8eb6f17f6c13aa03fbcd28a000ceb38e4f91b1 100644 (file)
@@ -1,7 +1,7 @@
 pub use super::*;
 
 use rustc::mir::*;
-use dataflow::BitDenotation;
+use crate::dataflow::BitDenotation;
 
 #[derive(Copy, Clone)]
 pub struct MaybeStorageLive<'a, 'tcx: 'a> {
@@ -31,7 +31,7 @@ fn start_block_effect(&self, _sets: &mut BitSet<Local>) {
     }
 
     fn statement_effect(&self,
-                        sets: &mut BlockSets<Local>,
+                        sets: &mut BlockSets<'_, Local>,
                         loc: Location) {
         let stmt = &self.mir[loc.block].statements[loc.statement_index];
 
@@ -43,7 +43,7 @@ fn statement_effect(&self,
     }
 
     fn terminator_effect(&self,
-                         _sets: &mut BlockSets<Local>,
+                         _sets: &mut BlockSets<'_, Local>,
                          _loc: Location) {
         // Terminators have no effect
     }
index f09db970b73538d5eeb1ad75e25d7bf0f555b812..1853b60efd7e693f4dc8b03fe6bd070b7ad2a4f7 100644 (file)
@@ -58,7 +58,7 @@ pub fn new(input: &dyn fmt::Debug) -> DebugFormatted {
 }
 
 impl fmt::Debug for DebugFormatted {
-    fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, w: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(w, "{}", self.0)
     }
 }
@@ -525,7 +525,7 @@ fn apply_local_effect(&mut self) {
 
 impl<E:Idx> AllSets<E> {
     pub fn bits_per_block(&self) -> usize { self.bits_per_block }
-    pub fn for_block(&mut self, block_idx: usize) -> BlockSets<E> {
+    pub fn for_block(&mut self, block_idx: usize) -> BlockSets<'_, E> {
         BlockSets {
             on_entry: &mut self.on_entry_sets[block_idx],
             gen_set: &mut self.gen_sets[block_idx],
@@ -616,7 +616,7 @@ fn accumulates_intrablock_state() -> bool { false }
     /// applied, in that order, before moving for the next
     /// statement.
     fn before_statement_effect(&self,
-                               _sets: &mut BlockSets<Self::Idx>,
+                               _sets: &mut BlockSets<'_, Self::Idx>,
                                _location: Location) {}
 
     /// Mutates the block-sets (the flow sets for the given
@@ -630,7 +630,7 @@ fn before_statement_effect(&self,
     /// `bb_data` is the sequence of statements identified by `bb` in
     /// the MIR.
     fn statement_effect(&self,
-                        sets: &mut BlockSets<Self::Idx>,
+                        sets: &mut BlockSets<'_, Self::Idx>,
                         location: Location);
 
     /// Similar to `terminator_effect`, except it applies
@@ -645,7 +645,7 @@ fn statement_effect(&self,
     /// applied, in that order, before moving for the next
     /// terminator.
     fn before_terminator_effect(&self,
-                                _sets: &mut BlockSets<Self::Idx>,
+                                _sets: &mut BlockSets<'_, Self::Idx>,
                                 _location: Location) {}
 
     /// Mutates the block-sets (the flow sets for the given
@@ -659,7 +659,7 @@ fn before_terminator_effect(&self,
     /// The effects applied here cannot depend on which branch the
     /// terminator took.
     fn terminator_effect(&self,
-                         sets: &mut BlockSets<Self::Idx>,
+                         sets: &mut BlockSets<'_, Self::Idx>,
                          location: Location);
 
     /// Mutates the block-sets according to the (flow-dependent)
index d77216220ac2b57b60c0e8932b05096b6035d677..efd979a7da4fb469b174c41acce5afd3e0bb4ef7 100644 (file)
@@ -37,7 +37,7 @@ fn index(self) -> usize {
             }
 
             impl fmt::Debug for $Index {
-                fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+                fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
                     write!(fmt, "{}{}", $debug_name, self.index())
                 }
             }
@@ -62,7 +62,7 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
 pub use self::indexes::InitIndex;
 
 impl MoveOutIndex {
-    pub fn move_path_index(&self, move_data: &MoveData) -> MovePathIndex {
+    pub fn move_path_index(&self, move_data: &MoveData<'_>) -> MovePathIndex {
         move_data.moves[*self].path
     }
 }
@@ -88,7 +88,10 @@ pub struct MovePath<'tcx> {
 }
 
 impl<'tcx> MovePath<'tcx> {
-    pub fn parents(&self, move_paths: &IndexVec<MovePathIndex, MovePath>) -> Vec<MovePathIndex> {
+    pub fn parents(
+        &self,
+        move_paths: &IndexVec<MovePathIndex, MovePath<'_>>,
+    ) -> Vec<MovePathIndex> {
         let mut parents = Vec::new();
 
         let mut curr_parent = self.parent;
@@ -102,7 +105,7 @@ pub fn parents(&self, move_paths: &IndexVec<MovePathIndex, MovePath>) -> Vec<Mov
 }
 
 impl<'tcx> fmt::Debug for MovePath<'tcx> {
-    fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, w: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(w, "MovePath {{")?;
         if let Some(parent) = self.parent {
             write!(w, " parent: {:?},", parent)?;
@@ -118,7 +121,7 @@ fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result {
 }
 
 impl<'tcx> fmt::Display for MovePath<'tcx> {
-    fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, w: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(w, "{:?}", self.place)
     }
 }
@@ -166,7 +169,7 @@ fn index_mut(&mut self, index: Location) -> &mut Self::Output {
 }
 
 impl<T> LocationMap<T> where T: Default + Clone {
-    fn new(mir: &Mir) -> Self {
+    fn new(mir: &Mir<'_>) -> Self {
         LocationMap {
             map: mir.basic_blocks().iter().map(|block| {
                 vec![T::default(); block.statements.len()+1]
@@ -190,7 +193,7 @@ pub struct MoveOut {
 }
 
 impl fmt::Debug for MoveOut {
-    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(fmt, "{:?}@{:?}", self.path, self.source)
     }
 }
@@ -227,7 +230,7 @@ pub enum InitKind {
 }
 
 impl fmt::Debug for Init {
-    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(fmt, "{:?}@{:?} ({:?})", self.path, self.location, self.kind)
     }
 }
index 518ae978ae17adcbf2422c364bedd4ccc6e576da..c24cf956504daec0e2d139c2aeebbd1238d49dfb 100644 (file)
@@ -1,6 +1,6 @@
-use hair::*;
-use hair::cx::Cx;
-use hair::cx::to_ref::ToRef;
+use crate::hair::*;
+use crate::hair::cx::Cx;
+use crate::hair::cx::to_ref::ToRef;
 use rustc::middle::region;
 use rustc::hir;
 use rustc::ty;
index 8d64c9e9ada89daa8ea5e71d444527f63d20d979..7e1365f5dc12d7d9ae1886c62b6d45b74fde545e 100644 (file)
@@ -1,9 +1,9 @@
-use hair::*;
+use crate::hair::*;
+use crate::hair::cx::Cx;
+use crate::hair::cx::block;
+use crate::hair::cx::to_ref::ToRef;
+use crate::hair::util::UserAnnotatedTyHelpers;
 use rustc_data_structures::indexed_vec::Idx;
-use hair::cx::Cx;
-use hair::cx::block;
-use hair::cx::to_ref::ToRef;
-use hair::util::UserAnnotatedTyHelpers;
 use rustc::hir::def::{Def, CtorKind};
 use rustc::mir::interpret::{GlobalId, ErrorHandled};
 use rustc::ty::{self, AdtKind, Ty};
@@ -342,7 +342,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
         }
 
         hir::ExprKind::Lit(ref lit) => ExprKind::Literal {
-            literal: cx.tcx.intern_lazy_const(ty::LazyConst::Evaluated(
+            literal: cx.tcx.mk_lazy_const(ty::LazyConst::Evaluated(
                 cx.const_eval_literal(&lit.node, expr_ty, lit.span, false)
             )),
             user_ty: None,
@@ -442,7 +442,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
             } else {
                 if let hir::ExprKind::Lit(ref lit) = arg.node {
                     ExprKind::Literal {
-                        literal: cx.tcx.intern_lazy_const(ty::LazyConst::Evaluated(
+                        literal: cx.tcx.mk_lazy_const(ty::LazyConst::Evaluated(
                             cx.const_eval_literal(&lit.node, expr_ty, lit.span, true)
                         )),
                         user_ty: None,
@@ -702,7 +702,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
                         ty: var_ty,
                         span: expr.span,
                         kind: ExprKind::Literal {
-                            literal: cx.tcx.intern_lazy_const(literal),
+                            literal: cx.tcx.mk_lazy_const(literal),
                             user_ty: None
                         },
                     }.to_ref();
@@ -856,7 +856,7 @@ fn method_callee<'a, 'gcx, 'tcx>(
         ty,
         span,
         kind: ExprKind::Literal {
-            literal: cx.tcx().intern_lazy_const(ty::LazyConst::Evaluated(
+            literal: cx.tcx().mk_lazy_const(ty::LazyConst::Evaluated(
                 ty::Const::zero_sized(ty)
             )),
             user_ty,
@@ -918,7 +918,7 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
             let user_ty = user_substs_applied_to_def(cx, expr.hir_id, &def);
             debug!("convert_path_expr: user_ty={:?}", user_ty);
             ExprKind::Literal {
-                literal: cx.tcx.intern_lazy_const(ty::LazyConst::Evaluated(ty::Const::zero_sized(
+                literal: cx.tcx.mk_lazy_const(ty::LazyConst::Evaluated(ty::Const::zero_sized(
                     cx.tables().node_id_to_type(expr.hir_id),
                 ))),
                 user_ty,
@@ -930,7 +930,7 @@ fn convert_path_expr<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>,
             let user_ty = user_substs_applied_to_def(cx, expr.hir_id, &def);
             debug!("convert_path_expr: (const) user_ty={:?}", user_ty);
             ExprKind::Literal {
-                literal: cx.tcx.intern_lazy_const(ty::LazyConst::Unevaluated(def_id, substs)),
+                literal: cx.tcx.mk_lazy_const(ty::LazyConst::Unevaluated(def_id, substs)),
                 user_ty,
             }
         },
index f514cac6326be317b2a2de11cede84ea73091003..47be8223e8a70b1e6a4cc6e58ce1117e28828405 100644 (file)
@@ -4,8 +4,8 @@
 //! work.
 //!
 
-use hair::*;
-use hair::util::UserAnnotatedTyHelpers;
+use crate::hair::*;
+use crate::hair::util::UserAnnotatedTyHelpers;
 
 use rustc_data_structures::indexed_vec::Idx;
 use rustc::hir::def_id::{DefId, LOCAL_CRATE};
@@ -21,7 +21,7 @@
 use syntax::symbol::Symbol;
 use rustc::hir;
 use rustc_data_structures::sync::Lrc;
-use hair::constant::{lit_to_const, LitToConstError};
+use crate::hair::constant::{lit_to_const, LitToConstError};
 
 #[derive(Clone)]
 pub struct Cx<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> {
@@ -110,7 +110,7 @@ pub fn usize_ty(&mut self) -> Ty<'tcx> {
     }
 
     pub fn usize_literal(&mut self, value: u64) -> &'tcx ty::LazyConst<'tcx> {
-        self.tcx.intern_lazy_const(ty::LazyConst::Evaluated(ty::Const::from_usize(self.tcx, value)))
+        self.tcx.mk_lazy_const(ty::LazyConst::Evaluated(ty::Const::from_usize(self.tcx, value)))
     }
 
     pub fn bool_ty(&mut self) -> Ty<'tcx> {
@@ -122,11 +122,11 @@ pub fn unit_ty(&mut self) -> Ty<'tcx> {
     }
 
     pub fn true_literal(&mut self) -> &'tcx ty::LazyConst<'tcx> {
-        self.tcx.intern_lazy_const(ty::LazyConst::Evaluated(ty::Const::from_bool(self.tcx, true)))
+        self.tcx.mk_lazy_const(ty::LazyConst::Evaluated(ty::Const::from_bool(self.tcx, true)))
     }
 
     pub fn false_literal(&mut self) -> &'tcx ty::LazyConst<'tcx> {
-        self.tcx.intern_lazy_const(ty::LazyConst::Evaluated(ty::Const::from_bool(self.tcx, false)))
+        self.tcx.mk_lazy_const(ty::LazyConst::Evaluated(ty::Const::from_bool(self.tcx, false)))
     }
 
     pub fn const_eval_literal(
@@ -239,7 +239,7 @@ fn tables(&self) -> &ty::TypeckTables<'tcx> {
     }
 }
 
-fn lint_level_for_hir_id(tcx: TyCtxt, mut id: ast::NodeId) -> ast::NodeId {
+fn lint_level_for_hir_id(tcx: TyCtxt<'_, '_, '_>, mut id: ast::NodeId) -> ast::NodeId {
     // Right now we insert a `with_ignore` node in the dep graph here to
     // ignore the fact that `lint_levels` below depends on the entire crate.
     // For now this'll prevent false positives of recompiling too much when
index 1b87e4450c56e23d0923b59e0140ae29adc9e037..a462c61c2acba1184bf8aa3c7270adf2e6b0c5a1 100644 (file)
@@ -1,4 +1,4 @@
-use hair::*;
+use crate::hair::*;
 
 use rustc::hir;
 use syntax::ptr::P;
index 7f5b1a761d2618e070ae4cc4d2ef9e9a49bd9483..5779a032acc4d2d3308c87ff4c3f5ce9eec03eb5 100644 (file)
@@ -307,7 +307,7 @@ pub fn empty() -> Self {
 /// + _     + [_, _, ..tail] +
 /// ++++++++++++++++++++++++++
 impl<'p, 'tcx> fmt::Debug for Matrix<'p, 'tcx> {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(f, "\n")?;
 
         let &Matrix(ref m) = self;
@@ -442,7 +442,7 @@ fn variant_index_for_adt<'a>(
                 VariantIdx::new(0)
             }
             &ConstantValue(c) => {
-                ::const_eval::const_variant_index(
+                crate::const_eval::const_variant_index(
                     cx.tcx,
                     cx.param_env,
                     c,
@@ -1115,7 +1115,7 @@ pub fn is_useful<'p, 'a: 'p, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
     } else {
         debug!("is_useful - expanding wildcard");
 
-        let used_ctors: Vec<Constructor> = rows.iter().flat_map(|row| {
+        let used_ctors: Vec<Constructor<'_>> = rows.iter().flat_map(|row| {
             pat_constructors(cx, row[0], pcx).unwrap_or(vec![])
         }).collect();
         debug!("used_ctors = {:#?}", used_ctors);
@@ -1302,7 +1302,7 @@ fn is_useful_specialized<'p, 'a: 'p, 'tcx: 'a>(
 /// Returns None in case of a catch-all, which can't be specialized.
 fn pat_constructors<'tcx>(cx: &mut MatchCheckCtxt<'_, 'tcx>,
                           pat: &Pattern<'tcx>,
-                          pcx: PatternContext)
+                          pcx: PatternContext<'_>)
                           -> Option<Vec<Constructor<'tcx>>>
 {
     match *pat.kind {
index a47d64319bdc5a63336dcb98bfd28c667b6a3574..978051aab591b9cc0cf2e6d74cf264a4efce71f0 100644 (file)
@@ -229,7 +229,7 @@ fn check_match(
                 return;
             }
 
-            let matrix: Matrix = inlined_arms
+            let matrix: Matrix<'_, '_> = inlined_arms
                 .iter()
                 .filter(|&&(_, guard)| guard.is_none())
                 .flat_map(|arm| &arm.0)
@@ -248,7 +248,7 @@ fn check_irrefutable(&self, pat: &'tcx Pat, origin: &str) {
                                                 self.tables);
             let pattern = patcx.lower_pattern(pat);
             let pattern_ty = pattern.ty;
-            let pats: Matrix = vec![smallvec![
+            let pats: Matrix<'_, '_> = vec![smallvec![
                 expand_pattern(cx, pattern)
             ]].into_iter().collect();
 
@@ -283,7 +283,7 @@ fn check_irrefutable(&self, pat: &'tcx Pat, origin: &str) {
     }
 }
 
-fn check_for_bindings_named_same_as_variants(cx: &MatchVisitor, pat: &Pat) {
+fn check_for_bindings_named_same_as_variants(cx: &MatchVisitor<'_, '_>, pat: &Pat) {
     pat.walk(|p| {
         if let PatKind::Binding(_, _, _, ident, None) = p.node {
             if let Some(&bm) = cx.tables.pat_binding_modes().get(p.hir_id) {
@@ -462,7 +462,7 @@ fn check_exhaustive<'p, 'a: 'p, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
 }
 
 // Legality of move bindings checking
-fn check_legality_of_move_bindings(cx: &MatchVisitor,
+fn check_legality_of_move_bindings(cx: &MatchVisitor<'_, '_>,
                                    has_guard: bool,
                                    pats: &[P<Pat>]) {
     let mut by_ref_span = None;
@@ -541,7 +541,7 @@ fn check_legality_of_move_bindings(cx: &MatchVisitor,
 /// assign.
 ///
 /// FIXME: this should be done by borrowck.
-fn check_for_mutation_in_guard(cx: &MatchVisitor, guard: &hir::Guard) {
+fn check_for_mutation_in_guard(cx: &MatchVisitor<'_, '_>, guard: &hir::Guard) {
     let mut checker = MutationChecker {
         cx,
     };
@@ -561,13 +561,13 @@ struct MutationChecker<'a, 'tcx: 'a> {
 }
 
 impl<'a, 'tcx> Delegate<'tcx> for MutationChecker<'a, 'tcx> {
-    fn matched_pat(&mut self, _: &Pat, _: &cmt_, _: euv::MatchMode) {}
-    fn consume(&mut self, _: ast::NodeId, _: Span, _: &cmt_, _: ConsumeMode) {}
-    fn consume_pat(&mut self, _: &Pat, _: &cmt_, _: ConsumeMode) {}
+    fn matched_pat(&mut self, _: &Pat, _: &cmt_<'_>, _: euv::MatchMode) {}
+    fn consume(&mut self, _: ast::NodeId, _: Span, _: &cmt_<'_>, _: ConsumeMode) {}
+    fn consume_pat(&mut self, _: &Pat, _: &cmt_<'_>, _: ConsumeMode) {}
     fn borrow(&mut self,
               _: ast::NodeId,
               span: Span,
-              _: &cmt_,
+              _: &cmt_<'_>,
               _: ty::Region<'tcx>,
               kind:ty:: BorrowKind,
               _: LoanCause) {
@@ -588,7 +588,7 @@ fn borrow(&mut self,
         }
     }
     fn decl_without_init(&mut self, _: ast::NodeId, _: Span) {}
-    fn mutate(&mut self, _: ast::NodeId, span: Span, _: &cmt_, mode: MutateMode) {
+    fn mutate(&mut self, _: ast::NodeId, span: Span, _: &cmt_<'_>, mode: MutateMode) {
         match mode {
             MutateMode::JustWrite | MutateMode::WriteAndRead => {
                 struct_span_err!(self.cx.tcx.sess, span, E0302, "cannot assign in a pattern guard")
@@ -603,7 +603,7 @@ fn mutate(&mut self, _: ast::NodeId, span: Span, _: &cmt_, mode: MutateMode) {
 /// Forbids bindings in `@` patterns. This is necessary for memory safety,
 /// because of the way rvalues are handled in the borrow check. (See issue
 /// #14587.)
-fn check_legality_of_bindings_in_at_patterns(cx: &MatchVisitor, pat: &Pat) {
+fn check_legality_of_bindings_in_at_patterns(cx: &MatchVisitor<'_, '_>, pat: &Pat) {
     AtBindingPatternVisitor { cx: cx, bindings_allowed: true }.visit_pat(pat);
 }
 
index 6b7e14161186d0f2599830851030b6e94df0ca93..84d8f32954c81ba080454273adbb846ee47a7d23 100644 (file)
@@ -6,10 +6,10 @@
 pub use self::check_match::check_crate;
 pub(crate) use self::check_match::check_match;
 
-use const_eval::{const_field, const_variant_index};
+use crate::const_eval::{const_field, const_variant_index};
 
-use hair::util::UserAnnotatedTyHelpers;
-use hair::constant::*;
+use crate::hair::util::UserAnnotatedTyHelpers;
+use crate::hair::constant::*;
 
 use rustc::mir::{fmt_const_val, Field, BorrowKind, Mutability};
 use rustc::mir::{UserTypeProjection};
@@ -167,6 +167,17 @@ pub enum PatternKind<'tcx> {
     },
 }
 
+impl<'tcx> PatternKind<'tcx> {
+    /// If this is a `PatternKind::AscribeUserType` then return the subpattern kind, otherwise
+    /// return this pattern kind.
+    fn with_user_type_ascription_subpattern(self) -> Self {
+        match self {
+            PatternKind::AscribeUserType { subpattern: Pattern { box kind, ..  }, ..  } => kind,
+            kind => kind,
+        }
+    }
+}
+
 #[derive(Clone, Copy, Debug, PartialEq)]
 pub struct PatternRange<'tcx> {
     pub lo: ty::Const<'tcx>,
@@ -176,7 +187,7 @@ pub struct PatternRange<'tcx> {
 }
 
 impl<'tcx> fmt::Display for Pattern<'tcx> {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         match *self.kind {
             PatternKind::Wild => write!(f, "_"),
             PatternKind::AscribeUserType { ref subpattern, .. } =>
@@ -403,9 +414,15 @@ fn lower_pattern_unadjusted(&mut self, pat: &'tcx hir::Pat) -> Pattern<'tcx> {
             PatKind::Lit(ref value) => self.lower_lit(value),
 
             PatKind::Range(ref lo_expr, ref hi_expr, end) => {
-                match (self.lower_lit(lo_expr), self.lower_lit(hi_expr)) {
-                    (PatternKind::Constant { value: lo },
-                     PatternKind::Constant { value: hi }) => {
+                match (
+                    // Look for `PatternKind::Constant` patterns inside of any
+                    // `PatternKind::AscribeUserType` patterns. Type ascriptions can be safely
+                    // ignored for the purposes of lowering a range correctly - these are checked
+                    // elsewhere for well-formedness.
+                    self.lower_lit(lo_expr).with_user_type_ascription_subpattern(),
+                    self.lower_lit(hi_expr).with_user_type_ascription_subpattern(),
+                ) {
+                    (PatternKind::Constant { value: lo }, PatternKind::Constant { value: hi }) => {
                         use std::cmp::Ordering;
                         let cmp = compare_const_vals(
                             self.tcx,
@@ -454,7 +471,15 @@ fn lower_pattern_unadjusted(&mut self, pat: &'tcx hir::Pat) -> Pattern<'tcx> {
                             }
                         }
                     }
-                    _ => PatternKind::Wild
+                    ref pats => {
+                        self.tcx.sess.delay_span_bug(
+                            pat.span,
+                            &format!("found bad range pattern `{:?}` outside of error recovery",
+                                     pats),
+                        );
+
+                        PatternKind::Wild
+                    }
                 }
             }
 
index 1b976d822ebff1a6d19a2a36afed9b7cc59471ce..c87338fb0ce947262b7638c88a1275b2fca746ad 100644 (file)
@@ -322,7 +322,7 @@ pub fn layout_of_local(
     ) -> EvalResult<'tcx, TyLayout<'tcx>> {
         match frame.locals[local].layout.get() {
             None => {
-                let layout = ::interpret::operand::from_known_layout(layout, || {
+                let layout = crate::interpret::operand::from_known_layout(layout, || {
                     let local_ty = frame.mir.local_decls[local].ty;
                     let local_ty = self.monomorphize_with_substs(local_ty, frame.instance.substs);
                     self.layout_of(local_ty)
index 5fae461bdc2033e42821b67944eb2e0e3b2104f2..ee295116ba9625f3169e92b9cca8c2d7e8953029 100644 (file)
@@ -25,7 +25,7 @@
 
 use super::eval_context::{LocalState, StackPopCleanup};
 use super::{Frame, Memory, Operand, MemPlace, Place, Immediate, ScalarMaybeUndef, LocalValue};
-use const_eval::CompileTimeInterpreter;
+use crate::const_eval::CompileTimeInterpreter;
 
 #[derive(Default)]
 pub(crate) struct InfiniteLoopDetector<'a, 'mir, 'tcx: 'a + 'mir> {
@@ -200,7 +200,7 @@ fn snapshot(&self, ctx: &'a Ctx) -> Self::Item {
     Undef,
 });
 
-impl_stable_hash_for!(struct ::interpret::MemPlace {
+impl_stable_hash_for!(struct crate::interpret::MemPlace {
     ptr,
     align,
     meta,
@@ -211,7 +211,7 @@ fn snapshot(&self, ctx: &'a Ctx) -> Self::Item {
     align -> *align, // just copy alignment verbatim
 });
 
-impl_stable_hash_for!(enum ::interpret::Place {
+impl_stable_hash_for!(enum crate::interpret::Place {
     Ptr(mem_place),
     Local { frame, local },
 });
@@ -232,7 +232,7 @@ fn snapshot(&self, ctx: &'a Ctx) -> Self::Item {
     }
 }
 
-impl_stable_hash_for!(enum ::interpret::Immediate {
+impl_stable_hash_for!(enum crate::interpret::Immediate {
     Scalar(x),
     ScalarPair(x, y),
 });
@@ -241,7 +241,7 @@ fn snapshot(&self, ctx: &'a Ctx) -> Self::Item {
     ScalarPair(s, t),
 });
 
-impl_stable_hash_for!(enum ::interpret::Operand {
+impl_stable_hash_for!(enum crate::interpret::Operand {
     Immediate(x),
     Indirect(x),
 });
@@ -250,7 +250,7 @@ fn snapshot(&self, ctx: &'a Ctx) -> Self::Item {
     Indirect(m),
 });
 
-impl_stable_hash_for!(enum ::interpret::LocalValue {
+impl_stable_hash_for!(enum crate::interpret::LocalValue {
     Dead,
     Live(x),
 });
@@ -298,7 +298,7 @@ fn snapshot(&self, ctx: &'a Ctx) -> Self::Item {
     }
 }
 
-impl_stable_hash_for!(enum ::interpret::eval_context::StackPopCleanup {
+impl_stable_hash_for!(enum crate::interpret::eval_context::StackPopCleanup {
     Goto(block),
     None { cleanup },
 });
index 7e823524c180c81de4c638401347fe3502b7fdc5..be50daa17092f1698eb180cb5814a98334878b1c 100644 (file)
@@ -112,7 +112,7 @@ pub(super) fn eval_terminator(
                 let ty = place.layout.ty;
                 trace!("TerminatorKind::drop: {:?}, type {}", location, ty);
 
-                let instance = ::monomorphize::resolve_drop_in_place(*self.tcx, ty);
+                let instance = crate::monomorphize::resolve_drop_in_place(*self.tcx, ty);
                 self.drop_in_place(
                     place,
                     instance,
@@ -326,7 +326,7 @@ fn eval_fn_call(
                     // last incoming argument.  These two iterators do not have the same type,
                     // so to keep the code paths uniform we accept an allocation
                     // (for RustCall ABI only).
-                    let caller_args : Cow<[OpTy<'tcx, M::PointerTag>]> =
+                    let caller_args : Cow<'_, [OpTy<'tcx, M::PointerTag>]> =
                         if caller_abi == Abi::RustCall && !args.is_empty() {
                             // Untuple
                             let (&untuple_arg, args) = args.split_last().unwrap();
@@ -335,7 +335,7 @@ fn eval_fn_call(
                                 .chain((0..untuple_arg.layout.fields.count()).into_iter()
                                     .map(|i| self.operand_field(untuple_arg, i as u64))
                                 )
-                                .collect::<EvalResult<Vec<OpTy<'tcx, M::PointerTag>>>>()?)
+                                .collect::<EvalResult<'_, Vec<OpTy<'tcx, M::PointerTag>>>>()?)
                         } else {
                             // Plain arg passing
                             Cow::from(args)
index 642bbc114f5620c6a79165e4df3c5d25c04027e4..63253bae9078bdfd758c99c86b87c56939e11324 100644 (file)
@@ -52,7 +52,7 @@ pub fn get_vtable(
         ).with_default_tag();
         let tcx = &*self.tcx;
 
-        let drop = ::monomorphize::resolve_drop_in_place(*tcx, ty);
+        let drop = crate::monomorphize::resolve_drop_in_place(*tcx, ty);
         let drop = self.memory.create_fn_alloc(drop).with_default_tag();
         // no need to do any alignment checks on the memory accesses below, because we know the
         // allocation is correctly aligned as we created it above. Also we're only offsetting by
index 4773f5627d716db0238f6b3d9ac616b20d8eb140..930bcb44374aa21fc5b52c97e179cd5568aaa3de 100644 (file)
@@ -26,7 +26,7 @@ fn to_op(
     ) -> EvalResult<'tcx, OpTy<'tcx, M::PointerTag>>;
 
     /// Create this from an `MPlaceTy`.
-    fn from_mem_place(MPlaceTy<'tcx, M::PointerTag>) -> Self;
+    fn from_mem_place(mplace: MPlaceTy<'tcx, M::PointerTag>) -> Self;
 
     /// Project to the given enum variant.
     fn project_downcast(
index ccfc15bac042ce26bd66c6a2b592964ca947a1a0..909f96956695dabd9c73d22cd09115d203c64b2d 100644 (file)
 #![feature(slice_concat_ext)]
 #![feature(try_from)]
 #![feature(reverse_bits)]
+#![feature(try_blocks)]
 
 #![recursion_limit="256"]
 
-extern crate arena;
+#![deny(rust_2018_idioms)]
+#![allow(explicit_outlives_requirements)]
 
-#[macro_use]
-extern crate bitflags;
 #[macro_use] extern crate log;
-extern crate either;
-extern crate graphviz as dot;
-extern crate polonius_engine;
 #[macro_use]
 extern crate rustc;
 #[macro_use] extern crate rustc_data_structures;
-extern crate serialize as rustc_serialize;
-extern crate rustc_errors;
+#[allow(unused_extern_crates)]
+extern crate serialize as rustc_serialize; // used by deriving
 #[macro_use]
 extern crate syntax;
-extern crate syntax_pos;
-extern crate rustc_target;
-extern crate log_settings;
-extern crate rustc_apfloat;
-extern crate byteorder;
-extern crate core;
-extern crate smallvec;
-
-// Once we can use edition 2018 in the compiler,
-// replace this with real try blocks.
-macro_rules! try_block {
-    ($($inside:tt)*) => (
-        (||{ ::std::ops::Try::from_ok({ $($inside)* }) })()
-    )
-}
 
 mod diagnostics;
 
@@ -77,7 +59,7 @@ macro_rules! try_block {
 pub use hair::pattern::check_crate as matchck_crate;
 use rustc::ty::query::Providers;
 
-pub fn provide(providers: &mut Providers) {
+pub fn provide(providers: &mut Providers<'_>) {
     borrow_check::provide(providers);
     shim::provide(providers);
     transform::provide(providers);
index 8ded31d89daead20a43c0635c01d25eed7f8612d..6b6e8fcdc82cf57bcdf46a94bad09ff87d03d450 100644 (file)
@@ -18,7 +18,7 @@ pub fn check(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 }
 
 fn check_fn_for_unconditional_recursion(tcx: TyCtxt<'a, 'tcx, 'tcx>,
-                                        fn_kind: FnKind,
+                                        fn_kind: FnKind<'_>,
                                         mir: &Mir<'tcx>,
                                         def_id: DefId) {
     if let FnKind::Closure(_) = fn_kind {
index e713ab17c3af5ca40da4ed8c18e0a3753fddab98..7f3c24daf606d4203e2e456bada43639b8090a3c 100644 (file)
 use rustc::mir::mono::MonoItem;
 use rustc::mir::interpret::{Scalar, GlobalId, AllocKind, ErrorHandled};
 
-use monomorphize::{self, Instance};
+use crate::monomorphize::{self, Instance};
 use rustc::util::nodemap::{FxHashSet, FxHashMap, DefIdMap};
 use rustc::util::common::time;
 
-use monomorphize::item::{MonoItemExt, DefPathBasedNames, InstantiationMode};
+use crate::monomorphize::item::{MonoItemExt, DefPathBasedNames, InstantiationMode};
 
 use rustc_data_structures::bit_set::GrowableBitSet;
 use rustc_data_structures::sync::{MTRef, MTLock, ParallelIterator, par_iter};
index 431cc0d52b4c8b4d6aa629ae761c5ba1cce4c26b..d3381f463f49ed1aa06278dbb34c87af3dc06b0f 100644 (file)
@@ -1,4 +1,4 @@
-use monomorphize::Instance;
+use crate::monomorphize::Instance;
 use rustc::hir;
 use rustc::hir::def_id::{DefId, LOCAL_CRATE};
 use rustc::session::config::OptLevel;
index 569e4c828f6014ef845b3a4fd1a3910a07805b0a..d4c7ebefe1753027ce6078fc7a9cebe26a738813 100644 (file)
 use rustc::util::nodemap::{DefIdSet, FxHashMap, FxHashSet};
 use rustc::mir::mono::MonoItem;
 
-use monomorphize::collector::InliningMap;
-use monomorphize::collector::{self, MonoItemCollectionMode};
-use monomorphize::item::{MonoItemExt, InstantiationMode};
+use crate::monomorphize::collector::InliningMap;
+use crate::monomorphize::collector::{self, MonoItemCollectionMode};
+use crate::monomorphize::item::{MonoItemExt, InstantiationMode};
 
 pub use rustc::mir::mono::CodegenUnit;
 
@@ -146,7 +146,7 @@ fn work_product_id(&self) -> WorkProductId {
         WorkProductId::from_cgu_name(&self.name().as_str())
     }
 
-    fn work_product(&self, tcx: TyCtxt) -> WorkProduct {
+    fn work_product(&self, tcx: TyCtxt<'_, '_, '_>) -> WorkProduct {
         let work_product_id = self.work_product_id();
         tcx.dep_graph
            .previous_work_product(&work_product_id)
@@ -213,7 +213,7 @@ fn as_codegen_unit(&self) -> &CodegenUnit<'tcx> {
 }
 
 // Anything we can't find a proper codegen unit for goes into this.
-fn fallback_cgu_name(name_builder: &mut CodegenUnitNameBuilder) -> InternedString {
+fn fallback_cgu_name(name_builder: &mut CodegenUnitNameBuilder<'_, '_, '_>) -> InternedString {
     name_builder.build_cgu_name(LOCAL_CRATE, &["fallback"], Some("cgu"))
 }
 
@@ -536,7 +536,7 @@ fn mono_item_visibility(
     }
 }
 
-fn default_visibility(tcx: TyCtxt, id: DefId, is_generic: bool) -> Visibility {
+fn default_visibility(tcx: TyCtxt<'_, '_, '_>, id: DefId, is_generic: bool) -> Visibility {
     if !tcx.sess.target.target.options.default_hidden_visibility {
         return Visibility::Default
     }
@@ -795,8 +795,8 @@ fn characteristic_def_id_of_mono_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 
 type CguNameCache = FxHashMap<(DefId, bool), InternedString>;
 
-fn compute_codegen_unit_name(tcx: TyCtxt,
-                             name_builder: &mut CodegenUnitNameBuilder,
+fn compute_codegen_unit_name(tcx: TyCtxt<'_, '_, '_>,
+                             name_builder: &mut CodegenUnitNameBuilder<'_, '_, '_>,
                              def_id: DefId,
                              volatile: bool,
                              cache: &mut CguNameCache)
@@ -855,7 +855,7 @@ fn compute_codegen_unit_name(tcx: TyCtxt,
     }).clone()
 }
 
-fn numbered_codegen_unit_name(name_builder: &mut CodegenUnitNameBuilder,
+fn numbered_codegen_unit_name(name_builder: &mut CodegenUnitNameBuilder<'_, '_, '_>,
                               index: usize)
                               -> InternedString {
     name_builder.build_cgu_name_no_mangle(LOCAL_CRATE, &["cgu"], Some(index))
@@ -929,7 +929,7 @@ fn collect_and_partition_mono_items<'a, 'tcx>(
 
     tcx.sess.abort_if_errors();
 
-    ::monomorphize::assert_symbols_are_distinct(tcx, items.iter());
+    crate::monomorphize::assert_symbols_are_distinct(tcx, items.iter());
 
     let strategy = if tcx.sess.opts.incremental.is_some() {
         PartitioningStrategy::PerModule
@@ -1013,7 +1013,7 @@ fn collect_and_partition_mono_items<'a, 'tcx>(
     (Arc::new(mono_items), Arc::new(codegen_units))
 }
 
-pub fn provide(providers: &mut Providers) {
+pub fn provide(providers: &mut Providers<'_>) {
     providers.collect_and_partition_mono_items =
         collect_and_partition_mono_items;
 
index 751815eab287bf03b3554218c6126cf410a4e1e2..f4c3049548d8ef40911edfe9d35ac5fcbcd13815 100644 (file)
 use std::fmt;
 use std::iter;
 
-use transform::{add_moves_for_packed_drops, add_call_guards};
-use transform::{remove_noop_landing_pads, no_landing_pads, simplify};
-use util::elaborate_drops::{self, DropElaborator, DropStyle, DropFlagMode};
-use util::patch::MirPatch;
+use crate::transform::{add_moves_for_packed_drops, add_call_guards};
+use crate::transform::{remove_noop_landing_pads, no_landing_pads, simplify};
+use crate::util::elaborate_drops::{self, DropElaborator, DropStyle, DropFlagMode};
+use crate::util::patch::MirPatch;
 
-pub fn provide(providers: &mut Providers) {
+pub fn provide(providers: &mut Providers<'_>) {
     providers.mir_shims = make_shim;
 }
 
@@ -138,7 +138,7 @@ enum CallKind {
     Direct(DefId),
 }
 
-fn temp_decl(mutability: Mutability, ty: Ty, span: Span) -> LocalDecl {
+fn temp_decl(mutability: Mutability, ty: Ty<'_>, span: Span) -> LocalDecl<'_> {
     let source_info = SourceInfo { scope: OUTERMOST_SOURCE_SCOPE, span };
     LocalDecl {
         mutability,
@@ -259,7 +259,7 @@ pub struct DropShimElaborator<'a, 'tcx: 'a> {
 }
 
 impl<'a, 'tcx> fmt::Debug for DropShimElaborator<'a, 'tcx> {
-    fn fmt(&self, _f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
+    fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
         Ok(())
     }
 }
@@ -459,7 +459,7 @@ fn make_clone_call(
             span: self.span,
             ty: func_ty,
             user_ty: None,
-            literal: tcx.intern_lazy_const(ty::LazyConst::Evaluated(
+            literal: tcx.mk_lazy_const(ty::LazyConst::Evaluated(
                 ty::Const::zero_sized(func_ty),
             )),
         });
@@ -521,7 +521,7 @@ fn make_usize(&self, value: u64) -> Box<Constant<'tcx>> {
             span: self.span,
             ty: self.tcx.types.usize,
             user_ty: None,
-            literal: self.tcx.intern_lazy_const(ty::LazyConst::Evaluated(
+            literal: self.tcx.mk_lazy_const(ty::LazyConst::Evaluated(
                 ty::Const::from_usize(self.tcx, value),
             )),
         }
@@ -759,7 +759,7 @@ fn build_call_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                 span,
                 ty,
                 user_ty: None,
-                literal: tcx.intern_lazy_const(ty::LazyConst::Evaluated(
+                literal: tcx.mk_lazy_const(ty::LazyConst::Evaluated(
                     ty::Const::zero_sized(ty)
                 )),
              }),
index 3ea1c8e82ff2b4b5722357cd9c1e39d2c02ce7f4..dab96faaa2a5ecfe6e1039bbd2b0945b93319397 100644 (file)
@@ -1,7 +1,7 @@
 use rustc::ty::TyCtxt;
 use rustc::mir::*;
 use rustc_data_structures::indexed_vec::{Idx, IndexVec};
-use transform::{MirPass, MirSource};
+use crate::transform::{MirPass, MirSource};
 
 #[derive(PartialEq)]
 pub enum AddCallGuards {
@@ -40,7 +40,7 @@ fn run_pass<'a, 'tcx>(&self,
 }
 
 impl AddCallGuards {
-    pub fn add_call_guards(&self, mir: &mut Mir) {
+    pub fn add_call_guards(&self, mir: &mut Mir<'_>) {
         let pred_count: IndexVec<_, _> =
             mir.predecessors().iter().map(|ps| ps.len()).collect();
 
index 8ec6902cf15fd6e343faa506de2d70a5662389d1..1492f0c50a31a67703d7cdc65f6dc4d2832fda3a 100644 (file)
@@ -2,9 +2,9 @@
 use rustc::mir::*;
 use rustc::ty::TyCtxt;
 
-use transform::{MirPass, MirSource};
-use util::patch::MirPatch;
-use util;
+use crate::transform::{MirPass, MirSource};
+use crate::util::patch::MirPatch;
+use crate::util;
 
 // This pass moves values being dropped that are within a packed
 // struct to a separate local before dropping them, to ensure that
index 3d5897bca9f5234e7726c2b02a24da5737666944..7bfcd318afe2d8adb94ebd1ab21f2a2532c76621 100644 (file)
@@ -6,7 +6,7 @@
 
 use rustc::ty::{self, Ty, TyCtxt};
 use rustc::mir::*;
-use transform::{MirPass, MirSource};
+use crate::transform::{MirPass, MirSource};
 
 pub struct AddRetag;
 
index ab8da2f352c1c1c8ae3b6628d2ba977f3f9e12dd..b2e1afc519ec596b56d07e4921fcc48c4209688e 100644 (file)
@@ -17,7 +17,7 @@
 
 use std::ops::Bound;
 
-use util;
+use crate::util;
 
 pub struct UnsafetyChecker<'a, 'tcx: 'a> {
     mir: &'a Mir<'tcx>,
@@ -458,7 +458,7 @@ fn check_mut_borrowing_layout_constrained_field(
     }
 }
 
-pub(crate) fn provide(providers: &mut Providers) {
+pub(crate) fn provide(providers: &mut Providers<'_>) {
     *providers = Providers {
         unsafety_check_result,
         unsafe_derive_on_repr_packed,
@@ -575,7 +575,7 @@ fn unsafe_derive_on_repr_packed<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: D
 }
 
 /// Return the NodeId for an enclosing scope that is also `unsafe`
-fn is_enclosed(tcx: TyCtxt,
+fn is_enclosed(tcx: TyCtxt<'_, '_, '_>,
                used_unsafe: &FxHashSet<ast::NodeId>,
                id: ast::NodeId) -> Option<(String, ast::NodeId)> {
     let parent_id = tcx.hir().get_parent_node(id);
@@ -598,7 +598,9 @@ fn is_enclosed(tcx: TyCtxt,
     }
 }
 
-fn report_unused_unsafe(tcx: TyCtxt, used_unsafe: &FxHashSet<ast::NodeId>, id: ast::NodeId) {
+fn report_unused_unsafe(tcx: TyCtxt<'_, '_, '_>,
+                        used_unsafe: &FxHashSet<ast::NodeId>,
+                        id: ast::NodeId) {
     let span = tcx.sess.source_map().def_span(tcx.hir().span(id));
     let msg = "unnecessary `unsafe` block";
     let mut db = tcx.struct_span_lint_node(UNUSED_UNSAFE, id, span, msg);
index e6df6b7fd2724f318ce1d1957ffb698138eb2ba6..240ef7c8ba42a8e8d65e64abab3ecd8625a2c543 100644 (file)
@@ -26,7 +26,7 @@
 use rustc::mir::{Statement, StatementKind};
 use rustc::mir::visit::MutVisitor;
 use rustc::ty::TyCtxt;
-use transform::{MirPass, MirSource};
+use crate::transform::{MirPass, MirSource};
 
 pub struct CleanAscribeUserType;
 
index dc556a15cd8550fe0891bba8995997519f50d915..dd1f37a591888351564218e7d112e4166ff45d08 100644 (file)
     HasTyCtxt, TargetDataLayout, HasDataLayout,
 };
 
-use interpret::{self, EvalContext, ScalarMaybeUndef, Immediate, OpTy, MemoryKind};
-use const_eval::{
+use crate::interpret::{self, EvalContext, ScalarMaybeUndef, Immediate, OpTy, MemoryKind};
+use crate::const_eval::{
     CompileTimeInterpreter, error_to_const_error, eval_promoted, mk_eval_cx,
     lazy_const_to_op,
 };
-use transform::{MirPass, MirSource};
+use crate::transform::{MirPass, MirSource};
 
 pub struct ConstProp;
 
@@ -486,7 +486,7 @@ struct CanConstProp {
 
 impl CanConstProp {
     /// returns true if `local` can be propagated
-    fn check(mir: &Mir) -> IndexVec<Local, bool> {
+    fn check(mir: &Mir<'_>) -> IndexVec<Local, bool> {
         let mut cpv = CanConstProp {
             can_const_prop: IndexVec::from_elem(true, &mir.local_decls),
             found_assignment: IndexVec::from_elem(false, &mir.local_decls),
index 55e14077c3ed01f1077e4fbba962dafc72276457..4789c35740eb3ce5df82e9326366042fc44f4f1c 100644 (file)
@@ -22,8 +22,8 @@
 use rustc::mir::{Constant, Local, LocalKind, Location, Place, Mir, Operand, Rvalue, StatementKind};
 use rustc::mir::visit::MutVisitor;
 use rustc::ty::TyCtxt;
-use transform::{MirPass, MirSource};
-use util::def_use::DefUseAnalysis;
+use crate::transform::{MirPass, MirSource};
+use crate::util::def_use::DefUseAnalysis;
 
 pub struct CopyPropagation;
 
@@ -173,7 +173,7 @@ enum Action<'tcx> {
 }
 
 impl<'tcx> Action<'tcx> {
-    fn local_copy(mir: &Mir<'tcx>, def_use_analysis: &DefUseAnalysis, src_place: &Place<'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 {
index a2fe9def8eeba5acd4aa9fe31185f6b52475a89d..669384e31dac354dfbf601e9c61e7ecc2b6152c8 100644 (file)
@@ -1,7 +1,7 @@
 use rustc::ty::TyCtxt;
 use rustc::mir::*;
 use rustc_data_structures::indexed_vec::Idx;
-use transform::{MirPass, MirSource};
+use crate::transform::{MirPass, MirSource};
 
 pub struct Deaggregator;
 
index 8fabb2d11fc4666741c27d89aa38a27fce98a995..d7f697a320049325992ed5bfdc5cadd79cb89f9a 100644 (file)
@@ -8,8 +8,8 @@
 use rustc::mir::Mir;
 use rustc::session::config::{OutputFilenames, OutputType};
 use rustc::ty::TyCtxt;
-use transform::{MirPass, MirSource};
-use util as mir_util;
+use crate::transform::{MirPass, MirSource};
+use crate::util as mir_util;
 
 pub struct Marker(pub &'static str);
 
@@ -31,7 +31,7 @@ pub struct Disambiguator {
 }
 
 impl fmt::Display for Disambiguator {
-    fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
         let title = if self.is_after { "after" } else { "before" };
         write!(formatter, "{}", title)
     }
index 06e16de8b43bcd0130718f1f9cba6442cd1d5c0e..a3750d801bd75f1f294d30b5fdf7321214d1c114 100644 (file)
@@ -1,10 +1,14 @@
-use dataflow::move_paths::{HasMoveData, MoveData, MovePathIndex, LookupResult};
-use dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces};
-use dataflow::{DataflowResults};
-use dataflow::{on_all_children_bits, on_all_drop_children_bits};
-use dataflow::{drop_flag_effects_for_location, on_lookup_result_bits};
-use dataflow::MoveDataParamEnv;
-use dataflow::{self, do_dataflow, DebugFormatted};
+use crate::dataflow::move_paths::{HasMoveData, MoveData, MovePathIndex, LookupResult};
+use crate::dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces};
+use crate::dataflow::{DataflowResults};
+use crate::dataflow::{on_all_children_bits, on_all_drop_children_bits};
+use crate::dataflow::{drop_flag_effects_for_location, on_lookup_result_bits};
+use crate::dataflow::MoveDataParamEnv;
+use crate::dataflow::{self, do_dataflow, DebugFormatted};
+use crate::transform::{MirPass, MirSource};
+use crate::util::patch::MirPatch;
+use crate::util::elaborate_drops::{DropFlagState, Unwind, elaborate_drop};
+use crate::util::elaborate_drops::{DropElaborator, DropStyle, DropFlagMode};
 use rustc::ty::{self, TyCtxt};
 use rustc::ty::layout::VariantIdx;
 use rustc::mir::*;
 use std::fmt;
 use syntax::ast;
 use syntax_pos::Span;
-use transform::{MirPass, MirSource};
-use util::patch::MirPatch;
-use util::elaborate_drops::{DropFlagState, Unwind, elaborate_drop};
-use util::elaborate_drops::{DropElaborator, DropStyle, DropFlagMode};
 
 pub struct ElaborateDrops;
 
@@ -174,7 +174,7 @@ struct Elaborator<'a, 'b: 'a, 'tcx: 'b> {
 }
 
 impl<'a, 'b, 'tcx> fmt::Debug for Elaborator<'a, 'b, 'tcx> {
-    fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
         Ok(())
     }
 }
@@ -533,7 +533,7 @@ fn constant_bool(&self, span: Span, val: bool) -> Rvalue<'tcx> {
             span,
             ty: self.tcx.types.bool,
             user_ty: None,
-            literal: self.tcx.intern_lazy_const(ty::LazyConst::Evaluated(
+            literal: self.tcx.mk_lazy_const(ty::LazyConst::Evaluated(
                 ty::Const::from_bool(self.tcx, val),
             )),
         })))
index b464b7d65e4661b614e9ede69093bf3843eb2a10..b555a2aa83ee3dd87534bb37e74e2641bbac07b2 100644 (file)
@@ -8,7 +8,7 @@
 use rustc::ty::{self, Ty, TyCtxt};
 use rustc::mir::*;
 use rustc::mir::visit::{MutVisitor, TyContext};
-use transform::{MirPass, MirSource};
+use crate::transform::{MirPass, MirSource};
 
 struct EraseRegionsVisitor<'a, 'tcx: 'a> {
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
index f5cc6a43e28b9a299a5052e56e294edf88e3710b..f408bc0d2fbb7cf32e9350e7ec49d21772de7b5d 100644 (file)
 use rustc::ty::{self, TyCtxt, AdtDef, Ty};
 use rustc::ty::layout::VariantIdx;
 use rustc::ty::subst::Substs;
-use util::dump_mir;
-use util::liveness::{self, IdentityMap};
 use rustc_data_structures::fx::FxHashMap;
 use rustc_data_structures::indexed_vec::Idx;
 use rustc_data_structures::bit_set::BitSet;
 use std::borrow::Cow;
 use std::iter::once;
 use std::mem;
-use transform::{MirPass, MirSource};
-use transform::simplify;
-use transform::no_landing_pads::no_landing_pads;
-use dataflow::{do_dataflow, DebugFormatted, state_for_location};
-use dataflow::{MaybeStorageLive, HaveBeenBorrowedLocals};
+use crate::transform::{MirPass, MirSource};
+use crate::transform::simplify;
+use crate::transform::no_landing_pads::no_landing_pads;
+use crate::dataflow::{do_dataflow, DebugFormatted, state_for_location};
+use crate::dataflow::{MaybeStorageLive, HaveBeenBorrowedLocals};
+use crate::util::dump_mir;
+use crate::util::liveness::{self, IdentityMap};
 
 pub struct StateTransform;
 
@@ -198,7 +198,7 @@ fn set_state(&self, state_disc: u32, source_info: SourceInfo) -> Statement<'tcx>
             span: source_info.span,
             ty: self.tcx.types.u32,
             user_ty: None,
-            literal: self.tcx.intern_lazy_const(ty::LazyConst::Evaluated(ty::Const::from_bits(
+            literal: self.tcx.mk_lazy_const(ty::LazyConst::Evaluated(ty::Const::from_bits(
                 self.tcx,
                 state_disc.into(),
                 ty::ParamEnv::empty().and(self.tcx.types.u32)
@@ -581,9 +581,9 @@ fn insert_switch<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 fn elaborate_generator_drops<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
                                        def_id: DefId,
                                        mir: &mut Mir<'tcx>) {
-    use util::elaborate_drops::{elaborate_drop, Unwind};
-    use util::patch::MirPatch;
-    use shim::DropShimElaborator;
+    use crate::util::elaborate_drops::{elaborate_drop, Unwind};
+    use crate::util::patch::MirPatch;
+    use crate::shim::DropShimElaborator;
 
     // Note that `elaborate_drops` only drops the upvars of a generator, and
     // this is ok because `open_drop` can only be reached within that own
@@ -731,7 +731,7 @@ fn insert_panic_block<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
             span: mir.span,
             ty: tcx.types.bool,
             user_ty: None,
-            literal: tcx.intern_lazy_const(ty::LazyConst::Evaluated(
+            literal: tcx.mk_lazy_const(ty::LazyConst::Evaluated(
                 ty::Const::from_bool(tcx, false),
             )),
         }),
index 9f0907adc989279935bf6278746b1e31ae9d49f3..4fddf6f8e09c20ab0feaa135181e74de1e7942a9 100644 (file)
 
 use std::collections::VecDeque;
 use std::iter;
-use transform::{MirPass, MirSource};
+use crate::transform::{MirPass, MirSource};
 use super::simplify::{remove_dead_blocks, CfgSimplifier};
 
-use syntax::{attr};
+use syntax::attr;
 use rustc_target::spec::abi::Abi;
 
 const DEFAULT_THRESHOLD: usize = 50;
@@ -426,7 +426,7 @@ fn inline_call(&self,
                 // Place could result in two different locations if `f`
                 // writes to `i`. To prevent this we need to create a temporary
                 // borrow of the place and pass the destination as `*temp` instead.
-                fn dest_needs_borrow(place: &Place) -> bool {
+                fn dest_needs_borrow(place: &Place<'_>) -> bool {
                     match *place {
                         Place::Projection(ref p) => {
                             match p.elem {
index 2b5e761d1d0558e2b6707a103d9f734689b78c1d..21772e1f1cd5b08e56e4b05607576c831a011876 100644 (file)
@@ -6,7 +6,7 @@
 use rustc::util::nodemap::{FxHashMap, FxHashSet};
 use rustc_data_structures::indexed_vec::Idx;
 use std::mem;
-use transform::{MirPass, MirSource};
+use crate::transform::{MirPass, MirSource};
 
 pub struct InstCombine;
 
index d14e0f078e6c6f83b2f7e70b61da0048e4236912..aa248ba7c53dfd6ca2105f55c038d327a71e0d70 100644 (file)
@@ -5,8 +5,7 @@
 use rustc::mir::*;
 use rustc::ty::{List, Ty, TyCtxt, TyKind};
 use rustc_data_structures::indexed_vec::{Idx};
-use transform::{MirPass, MirSource};
-use syntax;
+use crate::transform::{MirPass, MirSource};
 
 pub struct Lower128Bit;
 
@@ -182,7 +181,7 @@ fn ty<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Option<Ty<'tcx>> {
     }
 }
 
-fn sign_of_128bit(ty: Ty) -> Option<bool> {
+fn sign_of_128bit(ty: Ty<'_>) -> Option<bool> {
     match ty.sty {
         TyKind::Int(syntax::ast::IntTy::I128) => Some(true),
         TyKind::Uint(syntax::ast::UintTy::U128) => Some(false),
index a4f011b2e2ec9354f3d2c3fb95213c4c7d38cbed..cc37a8381f234da9b21ad6117dd44e6a337c5355 100644 (file)
@@ -1,5 +1,5 @@
-use borrow_check::nll::type_check;
-use build;
+use crate::borrow_check::nll::type_check;
+use crate::build;
 use rustc::hir::def_id::{CrateNum, DefId, LOCAL_CRATE};
 use rustc::mir::{Mir, MirPhase, Promoted};
 use rustc::ty::TyCtxt;
@@ -38,7 +38,7 @@
 pub mod lower_128bit;
 pub mod uniform_array_move_out;
 
-pub(crate) fn provide(providers: &mut Providers) {
+pub(crate) fn provide(providers: &mut Providers<'_>) {
     self::qualify_consts::provide(providers);
     self::check_unsafety::provide(providers);
     *providers = Providers {
index 2d13b066270a274e47b8dd47ab3d625808f6d4db..15b59d36d363c75f52f9dad8c5f8858a0d22158f 100644 (file)
@@ -4,7 +4,7 @@
 use rustc::ty::TyCtxt;
 use rustc::mir::*;
 use rustc::mir::visit::MutVisitor;
-use transform::{MirPass, MirSource};
+use crate::transform::{MirPass, MirSource};
 
 pub struct NoLandingPads;
 
index 1602fc35a2c9585a54f44d13d052515a1310e72d..d1dc5cfec994de503a14674f0cb4995d92fbb73e 100644 (file)
@@ -130,7 +130,8 @@ fn visit_source_info(&mut self, source_info: &SourceInfo) {
     }
 }
 
-pub fn collect_temps(mir: &Mir, rpo: &mut ReversePostorder) -> IndexVec<Local, TempState> {
+pub fn collect_temps(mir: &Mir<'_>,
+                     rpo: &mut ReversePostorder<'_, '_>) -> IndexVec<Local, TempState> {
     let mut collector = TempCollector {
         temps: IndexVec::from_elem(TempState::Undefined, &mir.local_decls),
         span: mir.span,
index 7d1943e21b90d71185dea6eb9c5c44221348c80b..ab4e3ad23f69aa3c156e2d08eea6eee5c0ea3d80 100644 (file)
 use std::fmt;
 use std::usize;
 
-use transform::{MirPass, MirSource};
+use crate::transform::{MirPass, MirSource};
 use super::promote_consts::{self, Candidate, TempState};
 
-bitflags! {
+bitflags::bitflags! {
     // Borrows of temporaries can be promoted only if
     // they have none of these qualifications, with
     // the exception of `STATIC_REF` (in statics only).
@@ -84,7 +84,7 @@ enum Mode {
 }
 
 impl fmt::Display for Mode {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         match *self {
             Mode::Const => write!(f, "constant"),
             Mode::Static | Mode::StaticMut => write!(f, "static"),
@@ -1128,7 +1128,7 @@ fn visit_terminator(&mut self,
     }
 }
 
-pub fn provide(providers: &mut Providers) {
+pub fn provide(providers: &mut Providers<'_>) {
     *providers = Providers {
         mir_const_qualif,
         ..*providers
@@ -1317,7 +1317,7 @@ fn run_pass<'a, 'tcx>(&self,
     }
 }
 
-fn args_required_const(tcx: TyCtxt, def_id: DefId) -> Option<FxHashSet<usize>> {
+fn args_required_const(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Option<FxHashSet<usize>> {
     let attrs = tcx.get_attrs(def_id);
     let attr = attrs.iter().find(|a| a.check_name("rustc_args_required_const"))?;
     let mut ret = FxHashSet::default();
index c8ef2decf26066779076966f93d70c9fc43e2183..4fcb4c10f9e6d2604a86cf39a9f5d520c9767211 100644 (file)
@@ -1,8 +1,8 @@
 use rustc::ty::TyCtxt;
 use rustc::mir::*;
 use rustc_data_structures::bit_set::BitSet;
-use transform::{MirPass, MirSource};
-use util::patch::MirPatch;
+use crate::transform::{MirPass, MirSource};
+use crate::util::patch::MirPatch;
 
 /// A pass that removes no-op landing pads and replaces jumps to them with
 /// `None`. This is important because otherwise LLVM generates terrible
@@ -34,7 +34,7 @@ impl RemoveNoopLandingPads {
     fn is_nop_landing_pad(
         &self,
         bb: BasicBlock,
-        mir: &Mir,
+        mir: &Mir<'_>,
         nop_landing_pads: &BitSet<BasicBlock>,
     ) -> bool {
         for stmt in &mir[bb].statements {
@@ -86,7 +86,7 @@ fn is_nop_landing_pad(
         }
     }
 
-    fn remove_nop_landing_pads(&self, mir: &mut Mir) {
+    fn remove_nop_landing_pads(&self, mir: &mut Mir<'_>) {
         // make sure there's a single resume block
         let resume_block = {
             let patch = MirPatch::new(mir);
index 36a6279e503204489ddf06d72cae898b90ee956b..806c1c1cca457daaf7cd9558251d5a0bb27b4d7f 100644 (file)
@@ -5,18 +5,20 @@
 use rustc::ty::{self, TyCtxt};
 use rustc::mir::{self, Mir, Location};
 use rustc_data_structures::bit_set::BitSet;
-use transform::{MirPass, MirSource};
-
-use dataflow::{do_dataflow, DebugFormatted};
-use dataflow::MoveDataParamEnv;
-use dataflow::BitDenotation;
-use dataflow::DataflowResults;
-use dataflow::{DefinitelyInitializedPlaces, MaybeInitializedPlaces, MaybeUninitializedPlaces};
-use dataflow::move_paths::{MovePathIndex, LookupResult};
-use dataflow::move_paths::{HasMoveData, MoveData};
-use dataflow;
-
-use dataflow::has_rustc_mir_with;
+use crate::transform::{MirPass, MirSource};
+
+use crate::dataflow::{do_dataflow, DebugFormatted};
+use crate::dataflow::MoveDataParamEnv;
+use crate::dataflow::BitDenotation;
+use crate::dataflow::DataflowResults;
+use crate::dataflow::{
+    DefinitelyInitializedPlaces, MaybeInitializedPlaces, MaybeUninitializedPlaces
+};
+use crate::dataflow::move_paths::{MovePathIndex, LookupResult};
+use crate::dataflow::move_paths::{HasMoveData, MoveData};
+use crate::dataflow;
+
+use crate::dataflow::has_rustc_mir_with;
 
 pub struct SanityCheck;
 
index ed2da98dd53115c4542aeb58c077c64f6fcbeec6..90486d1566413ca07c8fb744846ccff6f4e8b1e4 100644 (file)
@@ -34,7 +34,7 @@
 use rustc::mir::visit::{MutVisitor, Visitor, PlaceContext};
 use rustc::session::config::DebugInfo;
 use std::borrow::Cow;
-use transform::{MirPass, MirSource};
+use crate::transform::{MirPass, MirSource};
 
 pub struct SimplifyCfg { label: String }
 
@@ -44,7 +44,7 @@ pub fn new(label: &str) -> Self {
     }
 }
 
-pub fn simplify_cfg(mir: &mut Mir) {
+pub fn simplify_cfg(mir: &mut Mir<'_>) {
     CfgSimplifier::new(mir).simplify();
     remove_dead_blocks(mir);
 
@@ -263,7 +263,7 @@ fn strip_nops(&mut self) {
     }
 }
 
-pub fn remove_dead_blocks(mir: &mut Mir) {
+pub fn remove_dead_blocks(mir: &mut Mir<'_>) {
     let mut seen = BitSet::new_empty(mir.basic_blocks().len());
     for (bb, _) in traversal::preorder(mir) {
         seen.insert(bb.index());
index abaea709463838cfdfbeb9a553866acbbeae0eb4..0dc89bfe14709c053b409d2b2466a9eced923281 100644 (file)
@@ -2,7 +2,7 @@
 
 use rustc::ty::{TyCtxt, ParamEnv};
 use rustc::mir::*;
-use transform::{MirPass, MirSource};
+use crate::transform::{MirPass, MirSource};
 
 use std::borrow::Cow;
 
index 5ab9669baaca0d39abb91d7c1e45451fac82221a..09918436817f39ca0594b8a089f4078d8465c436 100644 (file)
@@ -30,9 +30,9 @@
 use rustc::ty::TyCtxt;
 use rustc::mir::*;
 use rustc::mir::visit::{Visitor, PlaceContext, NonUseContext};
-use transform::{MirPass, MirSource};
-use util::patch::MirPatch;
 use rustc_data_structures::indexed_vec::{IndexVec};
+use crate::transform::{MirPass, MirSource};
+use crate::util::patch::MirPatch;
 
 pub struct UniformArrayMoveOut;
 
index 7ad73aaa3f9a958a7ff81a51d86d1d4ca5cf0d01..fd694ddbbd19f994da5ccbe7f895b6cf0c52f5b9 100644 (file)
@@ -12,7 +12,7 @@ pub enum Origin {
 }
 
 impl fmt::Display for Origin {
-    fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, w: &mut fmt::Formatter<'_>) -> fmt::Result {
         // If the user passed `-Z borrowck=compare`, then include
         // origin info as part of the error report,
         // otherwise
@@ -437,7 +437,7 @@ fn cannot_move_out_of(
     fn cannot_move_out_of_interior_noncopy(
         self,
         move_from_span: Span,
-        ty: ty::Ty,
+        ty: ty::Ty<'_>,
         is_index: Option<bool>,
         o: Origin,
     ) -> DiagnosticBuilder<'cx> {
@@ -464,7 +464,7 @@ fn cannot_move_out_of_interior_noncopy(
     fn cannot_move_out_of_interior_of_drop(
         self,
         move_from_span: Span,
-        container_ty: ty::Ty,
+        container_ty: ty::Ty<'_>,
         o: Origin,
     ) -> DiagnosticBuilder<'cx> {
         let mut err = struct_span_err!(
index 057a7c8be88c9fa79133caf393d4ad49cab9e46d..3b9d7c3612a5739f7a7c891932eb290d9146a029 100644 (file)
@@ -107,7 +107,7 @@ pub fn def_count_not_including_drop(&self) -> usize {
 
     pub fn defs_not_including_drop(
         &self,
-    ) -> iter::Filter<slice::Iter<Use<'tcx>>, fn(&&Use<'tcx>) -> bool> {
+    ) -> iter::Filter<slice::Iter<'_, Use<'tcx>>, fn(&&Use<'tcx>) -> bool> {
         self.defs_and_uses.iter().filter(|place_use| {
             place_use.context.is_mutating_use() && !place_use.context.is_drop()
         })
index 8b55a4424ae293f211f2264efeacf4db3b4a143e..1bc956e5ffe1c844004a9c884cf8206a32ca9fbe 100644 (file)
@@ -8,7 +8,7 @@
 use rustc::ty::subst::Substs;
 use rustc::ty::util::IntTypeExt;
 use rustc_data_structures::indexed_vec::Idx;
-use util::patch::MirPatch;
+use crate::util::patch::MirPatch;
 
 use std::u32;
 
@@ -963,7 +963,7 @@ fn constant_usize(&self, val: u16) -> Operand<'tcx> {
             span: self.source_info.span,
             ty: self.tcx().types.usize,
             user_ty: None,
-            literal: self.tcx().intern_lazy_const(ty::LazyConst::Evaluated(
+            literal: self.tcx().mk_lazy_const(ty::LazyConst::Evaluated(
                 ty::Const::from_usize(self.tcx(), val.into())
             )),
         })
index b68898f7130212f2dd2f37b64d796883b74f0ccf..e93b96c12161cd86aaba5b3dd5a09b8b77aff9ec 100644 (file)
@@ -1,4 +1,3 @@
-use dot;
 use rustc::hir::def_id::DefId;
 use rustc::mir::*;
 use rustc::ty::TyCtxt;
@@ -24,7 +23,7 @@ pub fn write_mir_graphviz<'tcx, W>(tcx: TyCtxt<'_, '_, 'tcx>,
 /// Write a graphviz DOT graph of the MIR.
 pub fn write_mir_fn_graphviz<'tcx, W>(tcx: TyCtxt<'_, '_, 'tcx>,
                                       def_id: DefId,
-                                      mir: &Mir,
+                                      mir: &Mir<'_>,
                                       w: &mut W) -> io::Result<()>
     where W: Write
 {
@@ -58,7 +57,7 @@ pub fn write_mir_fn_graphviz<'tcx, W>(tcx: TyCtxt<'_, '_, 'tcx>,
 /// `init` and `fini` are callbacks for emitting additional rows of
 /// data (using HTML enclosed with `<tr>` in the emitted text).
 pub fn write_node_label<W: Write, INIT, FINI>(block: BasicBlock,
-                                              mir: &Mir,
+                                              mir: &Mir<'_>,
                                               w: &mut W,
                                               num_cols: u32,
                                               init: INIT,
@@ -100,7 +99,7 @@ pub fn write_node_label<W: Write, INIT, FINI>(block: BasicBlock,
 }
 
 /// Write a graphviz DOT node for the given basic block.
-fn write_node<W: Write>(block: BasicBlock, mir: &Mir, w: &mut W) -> io::Result<()> {
+fn write_node<W: Write>(block: BasicBlock, mir: &Mir<'_>, w: &mut W) -> io::Result<()> {
     // Start a new node with the label to follow, in one of DOT's pseudo-HTML tables.
     write!(w, r#"    {} [shape="none", label=<"#, node(block))?;
     write_node_label(block, mir, w, 1, |_| Ok(()), |_| Ok(()))?;
@@ -109,7 +108,7 @@ fn write_node<W: Write>(block: BasicBlock, mir: &Mir, w: &mut W) -> io::Result<(
 }
 
 /// Write graphviz DOT edges with labels between the given basic block and all of its successors.
-fn write_edges<W: Write>(source: BasicBlock, mir: &Mir, w: &mut W) -> io::Result<()> {
+fn write_edges<W: Write>(source: BasicBlock, mir: &Mir<'_>, w: &mut W) -> io::Result<()> {
     let terminator = mir[source].terminator();
     let labels = terminator.kind.fmt_successor_labels();
 
@@ -125,7 +124,7 @@ fn write_edges<W: Write>(source: BasicBlock, mir: &Mir, w: &mut W) -> io::Result
 /// all the variables and temporaries.
 fn write_graph_label<'a, 'gcx, 'tcx, W: Write>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
                                                def_id: DefId,
-                                               mir: &Mir,
+                                               mir: &Mir<'_>,
                                                w: &mut W)
                                                -> io::Result<()> {
     write!(w, "    label=<fn {}(", dot::escape_html(&tcx.item_path_str(def_id)))?;
index b68c6f8748fbed5654d480b2080e150cbe5187e3..08ef58a232170f2a794913d7282b72ace8baf248 100644 (file)
@@ -35,8 +35,8 @@
 use std::fs;
 use std::io::{self, Write};
 use std::path::{Path, PathBuf};
-use transform::MirSource;
-use util::pretty::{dump_enabled, write_basic_block, write_mir_intro};
+use crate::transform::MirSource;
+use crate::util::pretty::{dump_enabled, write_basic_block, write_mir_intro};
 
 pub type LiveVarSet<V> = BitSet<V>;
 
index 5a1f94677a1d49df572ad3e3812b87666b20cfe6..366cd71f6d4e9551646247aefd6414f3ee4878c1 100644 (file)
@@ -170,14 +170,14 @@ pub fn apply(self, mir: &mut Mir<'tcx>) {
         }
     }
 
-    pub fn source_info_for_index(data: &BasicBlockData, loc: Location) -> SourceInfo {
+    pub fn source_info_for_index(data: &BasicBlockData<'_>, loc: Location) -> SourceInfo {
         match data.statements.get(loc.statement_index) {
             Some(stmt) => stmt.source_info,
             None => data.terminator().source_info
         }
     }
 
-    pub fn source_info_for_location(&self, mir: &Mir, loc: Location) -> SourceInfo {
+    pub fn source_info_for_location(&self, mir: &Mir<'_>, loc: Location) -> SourceInfo {
         let data = match loc.block.index().checked_sub(mir.basic_blocks().len()) {
             Some(new) => &self.new_blocks[new],
             None => &mir[loc.block]
index 3a15356806a9767b13e6fdb4d1b2b211ffac547d..2e1fc756833b8dceda85a4345e411e015f87f4ed 100644 (file)
@@ -12,7 +12,7 @@
 use std::io::{self, Write};
 use std::path::{Path, PathBuf};
 use super::graphviz::write_mir_fn_graphviz;
-use transform::MirSource;
+use crate::transform::MirSource;
 
 const INDENT: &str = "    ";
 /// Alignment for lining up comments following MIR statements
@@ -131,7 +131,7 @@ fn dump_matched_mir_node<'a, 'gcx, 'tcx, F>(
 ) where
     F: FnMut(PassWhere, &mut dyn Write) -> io::Result<()>,
 {
-    let _: io::Result<()> = try_block! {
+    let _: io::Result<()> = try {
         let mut file = create_dump_file(tcx, "mir", pass_num, pass_name, disambiguator, source)?;
         writeln!(file, "// MIR for `{}`", node_path)?;
         writeln!(file, "// source = {:?}", source)?;
@@ -148,7 +148,7 @@ fn dump_matched_mir_node<'a, 'gcx, 'tcx, F>(
     };
 
     if tcx.sess.opts.debugging_opts.dump_mir_graphviz {
-        let _: io::Result<()> = try_block! {
+        let _: io::Result<()> = try {
             let mut file =
                 create_dump_file(tcx, "dot", pass_num, pass_name, disambiguator, source)?;
             write_mir_fn_graphviz(tcx, source.def_id, mir, &mut file)?;
@@ -446,7 +446,7 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
     }
 }
 
-fn comment(tcx: TyCtxt, SourceInfo { span, scope }: SourceInfo) -> String {
+fn comment(tcx: TyCtxt<'_, '_, '_>, SourceInfo { span, scope }: SourceInfo) -> String {
     format!(
         "scope {} at {}",
         scope.index(),
@@ -458,8 +458,8 @@ fn comment(tcx: TyCtxt, SourceInfo { span, scope }: SourceInfo) -> String {
 ///
 /// Returns the total number of variables printed.
 fn write_scope_tree(
-    tcx: TyCtxt,
-    mir: &Mir,
+    tcx: TyCtxt<'_, '_, '_>,
+    mir: &Mir<'_>,
     scope_tree: &FxHashMap<SourceScope, Vec<SourceScope>>,
     w: &mut dyn Write,
     parent: SourceScope,
@@ -529,7 +529,7 @@ fn write_scope_tree(
 pub fn write_mir_intro<'a, 'gcx, 'tcx>(
     tcx: TyCtxt<'a, 'gcx, 'tcx>,
     src: MirSource,
-    mir: &Mir,
+    mir: &Mir<'_>,
     w: &mut dyn Write,
 ) -> io::Result<()> {
     write_mir_sig(tcx, src, mir, w)?;
@@ -568,7 +568,12 @@ pub fn write_mir_intro<'a, 'gcx, 'tcx>(
     Ok(())
 }
 
-fn write_mir_sig(tcx: TyCtxt, src: MirSource, mir: &Mir, w: &mut dyn Write) -> io::Result<()> {
+fn write_mir_sig(
+    tcx: TyCtxt<'_, '_, '_>,
+    src: MirSource,
+    mir: &Mir<'_>,
+    w: &mut dyn Write,
+) -> io::Result<()> {
     let id = tcx.hir().as_local_node_id(src.def_id).unwrap();
     let body_owner_kind = tcx.hir().body_owner_kind(id);
     match (body_owner_kind, src.promoted) {
@@ -614,7 +619,7 @@ fn write_mir_sig(tcx: TyCtxt, src: MirSource, mir: &Mir, w: &mut dyn Write) -> i
     Ok(())
 }
 
-fn write_temp_decls(mir: &Mir, w: &mut dyn Write) -> io::Result<()> {
+fn write_temp_decls(mir: &Mir<'_>, w: &mut dyn Write) -> io::Result<()> {
     // Compiler-introduced temporary types.
     for temp in mir.temps_iter() {
         writeln!(
@@ -630,7 +635,7 @@ fn write_temp_decls(mir: &Mir, w: &mut dyn Write) -> io::Result<()> {
     Ok(())
 }
 
-fn write_user_type_annotations(mir: &Mir, w: &mut dyn Write) -> io::Result<()> {
+fn write_user_type_annotations(mir: &Mir<'_>, w: &mut dyn Write) -> io::Result<()> {
     if !mir.user_type_annotations.is_empty() {
         writeln!(w, "| User Type Annotations")?;
     }
@@ -643,7 +648,7 @@ fn write_user_type_annotations(mir: &Mir, w: &mut dyn Write) -> io::Result<()> {
     Ok(())
 }
 
-pub fn dump_mir_def_ids(tcx: TyCtxt, single: Option<DefId>) -> Vec<DefId> {
+pub fn dump_mir_def_ids(tcx: TyCtxt<'_, '_, '_>, single: Option<DefId>) -> Vec<DefId> {
     if let Some(i) = single {
         vec![i]
     } else {
index f5154a033af8da9e3f010137883aacb7c02decf6..00bdcdc0cc021151de881115c9b99b3fbd97d551 100644 (file)
@@ -2,6 +2,7 @@
 authors = ["The Rust Project Developers"]
 name = "rustc_passes"
 version = "0.0.0"
+edition = "2018"
 
 [lib]
 name = "rustc_passes"
@@ -16,4 +17,4 @@ rustc_data_structures = { path = "../librustc_data_structures" }
 syntax = { path = "../libsyntax" }
 syntax_ext = { path = "../libsyntax_ext" }
 syntax_pos = { path = "../libsyntax_pos" }
-rustc_errors = { path = "../librustc_errors" }
+errors = { path = "../librustc_errors", package = "rustc_errors" }
index 3deb2ff8d8a0bb60a84defaddb0037a591b69575..a391a316312692393a3a9d351f1844d8f80140fe 100644 (file)
@@ -7,18 +7,21 @@
 // or type checking or some other kind of complex analysis.
 
 use std::mem;
+use syntax::print::pprust;
 use rustc::lint;
 use rustc::session::Session;
+use rustc_data_structures::fx::FxHashMap;
 use syntax::ast::*;
 use syntax::attr;
 use syntax::source_map::Spanned;
 use syntax::symbol::keywords;
 use syntax::ptr::P;
 use syntax::visit::{self, Visitor};
+use syntax::{span_err, struct_span_err, walk_list};
 use syntax_ext::proc_macro_decls::is_proc_macro_attr;
 use syntax_pos::Span;
-use errors;
 use errors::Applicability;
+use log::debug;
 
 struct AstValidator<'a> {
     session: &'a Session,
@@ -271,7 +274,74 @@ fn while_if_let_expr_ambiguity(&self, expr: &P<Expr>) -> Option<(Span, BinOpKind
             _ => None,
         }
     }
+}
 
+enum GenericPosition {
+    Param,
+    Arg,
+}
+
+fn validate_generics_order<'a>(
+    handler: &errors::Handler,
+    generics: impl Iterator<Item = (ParamKindOrd, Span, Option<String>)>,
+    pos: GenericPosition,
+    span: Span,
+) {
+    let mut max_param: Option<ParamKindOrd> = None;
+    let mut out_of_order = FxHashMap::default();
+    let mut param_idents = vec![];
+
+    for (kind, span, ident) in generics {
+        if let Some(ident) = ident {
+            param_idents.push((kind, param_idents.len(), ident));
+        }
+        let max_param = &mut max_param;
+        match max_param {
+            Some(max_param) if *max_param > kind => {
+                let entry = out_of_order.entry(kind).or_insert((*max_param, vec![]));
+                entry.1.push(span);
+            }
+            Some(_) | None => *max_param = Some(kind),
+        };
+    }
+
+    let mut ordered_params = "<".to_string();
+    if !out_of_order.is_empty() {
+        param_idents.sort_by_key(|&(po, i, _)| (po, i));
+        let mut first = true;
+        for (_, _, ident) in param_idents {
+            if !first {
+                ordered_params += ", ";
+            }
+            ordered_params += &ident;
+            first = false;
+        }
+    }
+    ordered_params += ">";
+
+    let pos_str = match pos {
+        GenericPosition::Param => "parameter",
+        GenericPosition::Arg => "argument",
+    };
+
+    for (param_ord, (max_param, spans)) in out_of_order {
+        let mut err = handler.struct_span_err(spans,
+            &format!(
+                "{} {pos}s must be declared prior to {} {pos}s",
+                param_ord,
+                max_param,
+                pos = pos_str,
+            ));
+        if let GenericPosition::Param = pos {
+            err.span_suggestion(
+                span,
+                &format!("reorder the {}s: lifetimes, then types, then consts", pos_str),
+                ordered_params.clone(),
+                Applicability::MachineApplicable,
+            );
+        }
+        err.emit();
+    }
 }
 
 impl<'a> Visitor<'a> for AstValidator<'a> {
@@ -412,6 +482,26 @@ fn visit_item(&mut self, item: &'a Item) {
                         .note("only trait implementations may be annotated with default").emit();
                 }
             }
+            ItemKind::Fn(_, header, ref generics, _) => {
+                // We currently do not permit const generics in `const fn`, as
+                // this is tantamount to allowing compile-time dependent typing.
+                if header.constness.node == Constness::Const {
+                    // Look for const generics and error if we find any.
+                    for param in &generics.params {
+                        match param.kind {
+                            GenericParamKind::Const { .. } => {
+                                self.err_handler()
+                                    .struct_span_err(
+                                        item.span,
+                                        "const parameters are not permitted in `const fn`",
+                                    )
+                                    .emit();
+                            }
+                            _ => {}
+                        }
+                    }
+                }
+            }
             ItemKind::ForeignMod(..) => {
                 self.invalid_visibility(
                     &item.vis,
@@ -508,6 +598,13 @@ fn visit_generic_args(&mut self, _: Span, generic_args: &'a GenericArgs) {
         match *generic_args {
             GenericArgs::AngleBracketed(ref data) => {
                 walk_list!(self, visit_generic_arg, &data.args);
+                validate_generics_order(self.err_handler(), data.args.iter().map(|arg| {
+                    (match arg {
+                        GenericArg::Lifetime(..) => ParamKindOrd::Lifetime,
+                        GenericArg::Type(..) => ParamKindOrd::Type,
+                        GenericArg::Const(..) => ParamKindOrd::Const,
+                    }, arg.span(), None)
+                }), GenericPosition::Arg, generic_args.span());
                 // Type bindings such as `Item=impl Debug` in `Iterator<Item=Debug>`
                 // are allowed to contain nested `impl Trait`.
                 self.with_impl_trait(None, |this| {
@@ -526,27 +623,32 @@ fn visit_generic_args(&mut self, _: Span, generic_args: &'a GenericArgs) {
     }
 
     fn visit_generics(&mut self, generics: &'a Generics) {
-        let mut seen_non_lifetime_param = false;
-        let mut seen_default = None;
+        let mut prev_ty_default = None;
         for param in &generics.params {
-            match (&param.kind, seen_non_lifetime_param) {
-                (GenericParamKind::Lifetime { .. }, true) => {
+            if let GenericParamKind::Type { ref default, .. } = param.kind {
+                if default.is_some() {
+                    prev_ty_default = Some(param.ident.span);
+                } else if let Some(span) = prev_ty_default {
                     self.err_handler()
-                        .span_err(param.ident.span, "lifetime parameters must be leading");
-                },
-                (GenericParamKind::Lifetime { .. }, false) => {}
-                (GenericParamKind::Type { ref default, .. }, _) => {
-                    seen_non_lifetime_param = true;
-                    if default.is_some() {
-                        seen_default = Some(param.ident.span);
-                    } else if let Some(span) = seen_default {
-                        self.err_handler()
-                            .span_err(span, "type parameters with a default must be trailing");
-                        break;
-                    }
+                        .span_err(span, "type parameters with a default must be trailing");
+                    break;
                 }
             }
         }
+
+        validate_generics_order(self.err_handler(), generics.params.iter().map(|param| {
+            let span = param.ident.span;
+            let ident = Some(param.ident.to_string());
+            match &param.kind {
+                GenericParamKind::Lifetime { .. } => (ParamKindOrd::Lifetime, span, ident),
+                GenericParamKind::Type { .. } => (ParamKindOrd::Type, span, ident),
+                GenericParamKind::Const { ref ty } => {
+                    let ty = pprust::ty_to_string(ty);
+                    (ParamKindOrd::Const, span, Some(format!("const {}: {}", param.ident, ty)))
+                }
+            }
+        }), GenericPosition::Param, generics.span);
+
         for predicate in &generics.where_clause.predicates {
             if let WherePredicate::EqPredicate(ref predicate) = *predicate {
                 self.err_handler()
@@ -554,6 +656,7 @@ fn visit_generics(&mut self, generics: &'a Generics) {
                                                supported in where clauses (see #20041)");
             }
         }
+
         visit::walk_generics(self, generics)
     }
 
index 037227aeb715d27cc8952be8a6ede6429ea36cab..19d4d3aeb0f6530e06a0a724bb89c2cb0e52b4b6 100644 (file)
@@ -1,5 +1,7 @@
 #![allow(non_snake_case)]
 
+use syntax::{register_diagnostic, register_diagnostics, register_long_diagnostics};
+
 register_long_diagnostics! {
 /*
 E0014: r##"
index 74d6d75a7f528ad9ef403b8406af5676aa05cebf..2427abad07c958853f3451c0bab378f231755cb1 100644 (file)
@@ -61,7 +61,7 @@ fn record<T>(&mut self, label: &'static str, id: Id, node: &T) {
         });
 
         entry.count += 1;
-        entry.size = ::std::mem::size_of_val(node);
+        entry.size = std::mem::size_of_val(node);
     }
 
     fn print(&self, title: &str) {
index 625f2fcb249d139b7dd8ce92ad9be47617bb42c4..ff2e345d08401a5132059b8c45c5401d7d2d2b6c 100644 (file)
 
 #![recursion_limit="256"]
 
-#[macro_use]
-extern crate rustc;
-extern crate rustc_mir;
-extern crate rustc_data_structures;
+#![deny(rust_2018_idioms)]
 
 #[macro_use]
-extern crate log;
-#[macro_use]
-extern crate syntax;
-extern crate syntax_ext;
-extern crate syntax_pos;
-extern crate rustc_errors as errors;
+extern crate rustc;
 
 use rustc::ty::query::Providers;
 
@@ -36,7 +28,7 @@
 
 __build_diagnostic_array! { librustc_passes, DIAGNOSTICS }
 
-pub fn provide(providers: &mut Providers) {
+pub fn provide(providers: &mut Providers<'_>) {
     rvalue_promotion::provide(providers);
     loops::provide(providers);
 }
index f05a7be7d75137c52a99c4158be99c0c9c6a7608..533e043efa9d223f4f3f1addc239f21a25d58b46 100644 (file)
@@ -1,4 +1,4 @@
-use self::Context::*;
+use Context::*;
 
 use rustc::session::Session;
 
@@ -9,6 +9,7 @@
 use rustc::hir::intravisit::{self, Visitor, NestedVisitorMap};
 use rustc::hir::{self, Node, Destination};
 use syntax::ast;
+use syntax::struct_span_err;
 use syntax_pos::Span;
 use errors::Applicability;
 
@@ -59,7 +60,7 @@ fn check_mod_loops<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>, module_def_id: DefId) {
     }.as_deep_visitor());
 }
 
-pub(crate) fn provide(providers: &mut Providers) {
+pub(crate) fn provide(providers: &mut Providers<'_>) {
     *providers = Providers {
         check_mod_loops,
         ..*providers
index 739c96934e6abebc35312db8db94995f7387a90c..8d33fef5303ed11e3d8fa830ee5f3dc366646352 100644 (file)
 use rustc_data_structures::sync::Lrc;
 use syntax::ast;
 use syntax_pos::{Span, DUMMY_SP};
-use self::Promotability::*;
+use log::debug;
+use Promotability::*;
 use std::ops::{BitAnd, BitAndAssign, BitOr};
 
-pub fn provide(providers: &mut Providers) {
+pub fn provide(providers: &mut Providers<'_>) {
     *providers = Providers {
         rvalue_promotable_map,
         const_is_rvalue_promotable_to_static,
@@ -621,7 +622,7 @@ impl<'a, 'gcx, 'tcx> euv::Delegate<'tcx> for CheckCrateVisitor<'a, 'gcx> {
     fn consume(&mut self,
                _consume_id: ast::NodeId,
                _consume_span: Span,
-               _cmt: &mc::cmt_,
+               _cmt: &mc::cmt_<'_>,
                _mode: euv::ConsumeMode) {}
 
     fn borrow(&mut self,
@@ -680,11 +681,14 @@ fn decl_without_init(&mut self, _id: ast::NodeId, _span: Span) {}
     fn mutate(&mut self,
               _assignment_id: ast::NodeId,
               _assignment_span: Span,
-              _assignee_cmt: &mc::cmt_,
+              _assignee_cmt: &mc::cmt_<'_>,
               _mode: euv::MutateMode) {
     }
 
-    fn matched_pat(&mut self, _: &hir::Pat, _: &mc::cmt_, _: euv::MatchMode) {}
+    fn matched_pat(&mut self, _: &hir::Pat, _: &mc::cmt_<'_>, _: euv::MatchMode) {}
 
-    fn consume_pat(&mut self, _consume_pat: &hir::Pat, _cmt: &mc::cmt_, _mode: euv::ConsumeMode) {}
+    fn consume_pat(&mut self,
+                   _consume_pat: &hir::Pat,
+                   _cmt: &mc::cmt_<'_>,
+                   _mode: euv::ConsumeMode) {}
 }
index 0db8689c0c17c27f855390636c7ba83099d27ad1..5c095994a1bbd422f3a55d4b883b7de11db6ec37 100644 (file)
@@ -414,8 +414,8 @@ fn main() {}
 "##,
 
 E0401: r##"
-Inner items do not inherit type parameters from the functions they are embedded
-in.
+Inner items do not inherit type or const parameters from the functions
+they are embedded in.
 
 Erroneous code example:
 
index b131a6b62f9bf1dd2704c99522ae3c27e02ff01b..8300e691bbea4bce6fb53fb0e0871b67ff5bcc34 100644 (file)
-use crate::{CrateLint, PathResult, Segment};
-use crate::macros::ParentScope;
-use crate::resolve_imports::ImportResolver;
+use std::cmp::Reverse;
 
+use log::debug;
+use rustc::hir::def::*;
+use rustc::hir::def::Namespace::*;
+use rustc::hir::def_id::{CRATE_DEF_INDEX, DefId};
+use rustc::session::config::nightly_options;
+use syntax::ast::{ExprKind};
 use syntax::symbol::keywords;
 use syntax_pos::Span;
 
-use log::debug;
+use crate::errors::{Applicability, DiagnosticBuilder, DiagnosticId};
+use crate::macros::ParentScope;
+use crate::resolve_imports::ImportResolver;
+use crate::{import_candidate_to_enum_paths, is_self_type, is_self_value, path_names_to_string};
+use crate::{AssocSuggestion, CrateLint, ImportSuggestion, ModuleOrUniformRoot, PathResult,
+            PathSource, Resolver, Segment};
 
-use std::cmp::Reverse;
+impl<'a> Resolver<'a> {
+    /// Handles error reporting for `smart_resolve_path_fragment` function.
+    /// Creates base error and amends it with one short label and possibly some longer helps/notes.
+    pub(crate) fn smart_resolve_report_errors(
+        &mut self,
+        path: &[Segment],
+        span: Span,
+        source: PathSource<'_>,
+        def: Option<Def>,
+    ) -> (DiagnosticBuilder<'a>, Vec<ImportSuggestion>) {
+        let ident_span = path.last().map_or(span, |ident| ident.ident.span);
+        let ns = source.namespace();
+        let is_expected = &|def| source.is_expected(def);
+        let is_enum_variant = &|def| if let Def::Variant(..) = def { true } else { false };
+
+        // Make the base error.
+        let expected = source.descr_expected();
+        let path_str = Segment::names_to_string(path);
+        let item_str = path.last().unwrap().ident;
+        let code = source.error_code(def.is_some());
+        let (base_msg, fallback_label, base_span) = if let Some(def) = def {
+            (format!("expected {}, found {} `{}`", expected, def.kind_name(), path_str),
+                format!("not a {}", expected),
+                span)
+        } else {
+            let item_span = path.last().unwrap().ident.span;
+            let (mod_prefix, mod_str) = if path.len() == 1 {
+                (String::new(), "this scope".to_string())
+            } else if path.len() == 2 && path[0].ident.name == keywords::PathRoot.name() {
+                (String::new(), "the crate root".to_string())
+            } else {
+                let mod_path = &path[..path.len() - 1];
+                let mod_prefix = match self.resolve_path_without_parent_scope(
+                    mod_path, Some(TypeNS), false, span, CrateLint::No
+                ) {
+                    PathResult::Module(ModuleOrUniformRoot::Module(module)) =>
+                        module.def(),
+                    _ => None,
+                }.map_or(String::new(), |def| format!("{} ", def.kind_name()));
+                (mod_prefix, format!("`{}`", Segment::names_to_string(mod_path)))
+            };
+            (format!("cannot find {} `{}` in {}{}", expected, item_str, mod_prefix, mod_str),
+                format!("not found in {}", mod_str),
+                item_span)
+        };
+
+        let code = DiagnosticId::Error(code.into());
+        let mut err = self.session.struct_span_err_with_code(base_span, &base_msg, code);
+
+        // Emit help message for fake-self from other languages (e.g., `this` in Javascript).
+        if ["this", "my"].contains(&&*item_str.as_str())
+            && self.self_value_is_available(path[0].ident.span, span) {
+            err.span_suggestion(
+                span,
+                "did you mean",
+                "self".to_string(),
+                Applicability::MaybeIncorrect,
+            );
+        }
+
+        // Emit special messages for unresolved `Self` and `self`.
+        if is_self_type(path, ns) {
+            __diagnostic_used!(E0411);
+            err.code(DiagnosticId::Error("E0411".into()));
+            err.span_label(span, format!("`Self` is only available in impls, traits, \
+                                          and type definitions"));
+            return (err, Vec::new());
+        }
+        if is_self_value(path, ns) {
+            debug!("smart_resolve_path_fragment: E0424, source={:?}", source);
+
+            __diagnostic_used!(E0424);
+            err.code(DiagnosticId::Error("E0424".into()));
+            err.span_label(span, match source {
+                PathSource::Pat => {
+                    format!("`self` value is a keyword \
+                             and may not be bound to \
+                             variables or shadowed")
+                }
+                _ => {
+                    format!("`self` value is a keyword \
+                             only available in methods \
+                             with `self` parameter")
+                }
+            });
+            return (err, Vec::new());
+        }
+
+        // Try to lookup name in more relaxed fashion for better error reporting.
+        let ident = path.last().unwrap().ident;
+        let candidates = self.lookup_import_candidates(ident, ns, is_expected);
+        if candidates.is_empty() && is_expected(Def::Enum(DefId::local(CRATE_DEF_INDEX))) {
+            let enum_candidates =
+                self.lookup_import_candidates(ident, ns, is_enum_variant);
+            let mut enum_candidates = enum_candidates.iter()
+                .map(|suggestion| {
+                    import_candidate_to_enum_paths(&suggestion)
+                }).collect::<Vec<_>>();
+            enum_candidates.sort();
+
+            if !enum_candidates.is_empty() {
+                // Contextualize for E0412 "cannot find type", but don't belabor the point
+                // (that it's a variant) for E0573 "expected type, found variant".
+                let preamble = if def.is_none() {
+                    let others = match enum_candidates.len() {
+                        1 => String::new(),
+                        2 => " and 1 other".to_owned(),
+                        n => format!(" and {} others", n)
+                    };
+                    format!("there is an enum variant `{}`{}; ",
+                            enum_candidates[0].0, others)
+                } else {
+                    String::new()
+                };
+                let msg = format!("{}try using the variant's enum", preamble);
+
+                err.span_suggestions(
+                    span,
+                    &msg,
+                    enum_candidates.into_iter()
+                        .map(|(_variant_path, enum_ty_path)| enum_ty_path)
+                        // Variants re-exported in prelude doesn't mean `prelude::v1` is the
+                        // type name!
+                        // FIXME: is there a more principled way to do this that
+                        // would work for other re-exports?
+                        .filter(|enum_ty_path| enum_ty_path != "std::prelude::v1")
+                        // Also write `Option` rather than `std::prelude::v1::Option`.
+                        .map(|enum_ty_path| {
+                            // FIXME #56861: DRY-er prelude filtering.
+                            enum_ty_path.trim_start_matches("std::prelude::v1::").to_owned()
+                        }),
+                    Applicability::MachineApplicable,
+                );
+            }
+        }
+        if path.len() == 1 && self.self_type_is_available(span) {
+            if let Some(candidate) = self.lookup_assoc_candidate(ident, ns, is_expected) {
+                let self_is_available = self.self_value_is_available(path[0].ident.span, span);
+                match candidate {
+                    AssocSuggestion::Field => {
+                        err.span_suggestion(
+                            span,
+                            "try",
+                            format!("self.{}", path_str),
+                            Applicability::MachineApplicable,
+                        );
+                        if !self_is_available {
+                            err.span_label(span, format!("`self` value is a keyword \
+                                                         only available in \
+                                                         methods with `self` parameter"));
+                        }
+                    }
+                    AssocSuggestion::MethodWithSelf if self_is_available => {
+                        err.span_suggestion(
+                            span,
+                            "try",
+                            format!("self.{}", path_str),
+                            Applicability::MachineApplicable,
+                        );
+                    }
+                    AssocSuggestion::MethodWithSelf | AssocSuggestion::AssocItem => {
+                        err.span_suggestion(
+                            span,
+                            "try",
+                            format!("Self::{}", path_str),
+                            Applicability::MachineApplicable,
+                        );
+                    }
+                }
+                return (err, candidates);
+            }
+        }
+
+        let mut levenshtein_worked = false;
+
+        // Try Levenshtein algorithm.
+        let suggestion = self.lookup_typo_candidate(path, ns, is_expected, span);
+        if let Some(suggestion) = suggestion {
+            let msg = format!(
+                "{} {} with a similar name exists",
+                suggestion.article, suggestion.kind
+            );
+            err.span_suggestion(
+                ident_span,
+                &msg,
+                suggestion.candidate.to_string(),
+                Applicability::MaybeIncorrect,
+            );
+
+            levenshtein_worked = true;
+        }
+
+        // Try context-dependent help if relaxed lookup didn't work.
+        if let Some(def) = def {
+            if self.smart_resolve_context_dependent_help(&mut err,
+                                                         span,
+                                                         source,
+                                                         def,
+                                                         &path_str,
+                                                         &fallback_label) {
+                return (err, candidates);
+            }
+        }
+
+        // Fallback label.
+        if !levenshtein_worked {
+            err.span_label(base_span, fallback_label);
+            self.type_ascription_suggestion(&mut err, base_span);
+        }
+        (err, candidates)
+    }
+
+    /// Provides context-dependent help for errors reported by the `smart_resolve_path_fragment`
+    /// function.
+    /// Returns `true` if able to provide context-dependent help.
+    fn smart_resolve_context_dependent_help(
+        &mut self,
+        err: &mut DiagnosticBuilder<'a>,
+        span: Span,
+        source: PathSource<'_>,
+        def: Def,
+        path_str: &str,
+        fallback_label: &str,
+    ) -> bool {
+        let ns = source.namespace();
+        let is_expected = &|def| source.is_expected(def);
+
+        match (def, source) {
+            (Def::Macro(..), _) => {
+                err.span_suggestion(
+                    span,
+                    "use `!` to invoke the macro",
+                    format!("{}!", path_str),
+                    Applicability::MaybeIncorrect,
+                );
+            }
+            (Def::TyAlias(..), PathSource::Trait(_)) => {
+                err.span_label(span, "type aliases cannot be used as traits");
+                if nightly_options::is_nightly_build() {
+                    err.note("did you mean to use a trait alias?");
+                }
+            }
+            (Def::Mod(..), PathSource::Expr(Some(parent))) => match parent.node {
+                ExprKind::Field(_, ident) => {
+                    err.span_suggestion(
+                        parent.span,
+                        "use the path separator to refer to an item",
+                        format!("{}::{}", path_str, ident),
+                        Applicability::MaybeIncorrect,
+                    );
+                }
+                ExprKind::MethodCall(ref segment, ..) => {
+                    let span = parent.span.with_hi(segment.ident.span.hi());
+                    err.span_suggestion(
+                        span,
+                        "use the path separator to refer to an item",
+                        format!("{}::{}", path_str, segment.ident),
+                        Applicability::MaybeIncorrect,
+                    );
+                }
+                _ => return false,
+            },
+            (Def::Enum(..), PathSource::TupleStruct)
+                | (Def::Enum(..), PathSource::Expr(..))  => {
+                if let Some(variants) = self.collect_enum_variants(def) {
+                    err.note(&format!("did you mean to use one \
+                                       of the following variants?\n{}",
+                        variants.iter()
+                            .map(|suggestion| path_names_to_string(suggestion))
+                            .map(|suggestion| format!("- `{}`", suggestion))
+                            .collect::<Vec<_>>()
+                            .join("\n")));
+                } else {
+                    err.note("did you mean to use one of the enum's variants?");
+                }
+            },
+            (Def::Struct(def_id), _) if ns == ValueNS => {
+                if let Some((ctor_def, ctor_vis))
+                        = self.struct_constructors.get(&def_id).cloned() {
+                    let accessible_ctor = self.is_accessible(ctor_vis);
+                    if is_expected(ctor_def) && !accessible_ctor {
+                        err.span_label(span, format!("constructor is not visible \
+                                                      here due to private fields"));
+                    }
+                } else {
+                    // HACK(estebank): find a better way to figure out that this was a
+                    // parser issue where a struct literal is being used on an expression
+                    // where a brace being opened means a block is being started. Look
+                    // ahead for the next text to see if `span` is followed by a `{`.
+                    let sm = self.session.source_map();
+                    let mut sp = span;
+                    loop {
+                        sp = sm.next_point(sp);
+                        match sm.span_to_snippet(sp) {
+                            Ok(ref snippet) => {
+                                if snippet.chars().any(|c| { !c.is_whitespace() }) {
+                                    break;
+                                }
+                            }
+                            _ => break,
+                        }
+                    }
+                    let followed_by_brace = match sm.span_to_snippet(sp) {
+                        Ok(ref snippet) if snippet == "{" => true,
+                        _ => false,
+                    };
+                    // In case this could be a struct literal that needs to be surrounded
+                    // by parenthesis, find the appropriate span.
+                    let mut i = 0;
+                    let mut closing_brace = None;
+                    loop {
+                        sp = sm.next_point(sp);
+                        match sm.span_to_snippet(sp) {
+                            Ok(ref snippet) => {
+                                if snippet == "}" {
+                                    let sp = span.to(sp);
+                                    if let Ok(snippet) = sm.span_to_snippet(sp) {
+                                        closing_brace = Some((sp, snippet));
+                                    }
+                                    break;
+                                }
+                            }
+                            _ => break,
+                        }
+                        i += 1;
+                        // The bigger the span, the more likely we're incorrect --
+                        // bound it to 100 chars long.
+                        if i > 100 {
+                            break;
+                        }
+                    }
+                    match source {
+                        PathSource::Expr(Some(parent)) => {
+                            match parent.node {
+                                ExprKind::MethodCall(ref path_assignment, _)  => {
+                                    err.span_suggestion(
+                                        sm.start_point(parent.span)
+                                            .to(path_assignment.ident.span),
+                                        "use `::` to access an associated function",
+                                        format!("{}::{}",
+                                                path_str,
+                                                path_assignment.ident),
+                                        Applicability::MaybeIncorrect
+                                    );
+                                },
+                                _ => {
+                                    err.span_label(
+                                        span,
+                                        format!("did you mean `{} {{ /* fields */ }}`?",
+                                                path_str),
+                                    );
+                                },
+                            }
+                        },
+                        PathSource::Expr(None) if followed_by_brace == true => {
+                            if let Some((sp, snippet)) = closing_brace {
+                                err.span_suggestion(
+                                    sp,
+                                    "surround the struct literal with parenthesis",
+                                    format!("({})", snippet),
+                                    Applicability::MaybeIncorrect,
+                                );
+                            } else {
+                                err.span_label(
+                                    span,
+                                    format!("did you mean `({} {{ /* fields */ }})`?",
+                                            path_str),
+                                );
+                            }
+                        },
+                        _ => {
+                            err.span_label(
+                                span,
+                                format!("did you mean `{} {{ /* fields */ }}`?",
+                                        path_str),
+                            );
+                        },
+                    }
+                }
+            }
+            (Def::Union(..), _) |
+            (Def::Variant(..), _) |
+            (Def::VariantCtor(_, CtorKind::Fictive), _) if ns == ValueNS => {
+                err.span_label(span, format!("did you mean `{} {{ /* fields */ }}`?",
+                                             path_str));
+            }
+            (Def::SelfTy(..), _) if ns == ValueNS => {
+                err.span_label(span, fallback_label);
+                err.note("can't use `Self` as a constructor, you must use the \
+                          implemented struct");
+            }
+            (Def::TyAlias(_), _) | (Def::AssociatedTy(..), _) if ns == ValueNS => {
+                err.note("can't use a type alias as a constructor");
+            }
+            _ => return false,
+        }
+        true
+    }
+}
 
 impl<'a, 'b:'a> ImportResolver<'a, 'b> {
-    /// Add suggestions for a path that cannot be resolved.
+    /// Adds suggestions for a path that cannot be resolved.
     pub(crate) fn make_path_suggestion(
         &mut self,
         span: Span,
@@ -24,7 +431,7 @@ pub(crate) fn make_path_suggestion(
             // On 2015 `{{root}}` is usually added implicitly.
             (Some(fst), Some(snd)) if fst.ident.name == keywords::PathRoot.name() &&
                                       !snd.ident.is_path_segment_keyword() => {}
-            // `ident::...` on 2018
+            // `ident::...` on 2018.
             (Some(fst), _) if fst.ident.span.rust_2018() &&
                               !fst.ident.is_path_segment_keyword() => {
                 // Insert a placeholder that's later replaced by `self`/`super`/etc.
@@ -63,7 +470,7 @@ fn make_missing_self_suggestion(
         }
     }
 
-    /// Suggest a missing `crate::` if that resolves to an correct module.
+    /// Suggests a missing `crate::` if that resolves to an correct module.
     ///
     /// ```
     ///    |
@@ -94,7 +501,7 @@ fn make_missing_crate_suggestion(
         }
     }
 
-    /// Suggest a missing `super::` if that resolves to an correct module.
+    /// Suggests a missing `super::` if that resolves to an correct module.
     ///
     /// ```
     ///    |
@@ -118,7 +525,7 @@ fn make_missing_super_suggestion(
         }
     }
 
-    /// Suggest a missing external crate name if that resolves to an correct module.
+    /// Suggests a missing external crate name if that resolves to an correct module.
     ///
     /// ```
     ///    |
@@ -139,7 +546,7 @@ fn make_external_crate_suggestion(
         }
 
         // Sort extern crate names in reverse order to get
-        // 1) some consistent ordering for emitted dignostics and
+        // 1) some consistent ordering for emitted dignostics, and
         // 2) `std` suggestions before `core` suggestions.
         let mut extern_crate_names =
             self.resolver.extern_prelude.iter().map(|(ident, _)| ident.name).collect::<Vec<_>>();
index 270f24241971499d6694d8694558c9ef03b2d161..ecbfcec3c5eb4acc4203254b834922fed61b70b3 100644 (file)
@@ -13,7 +13,7 @@
 
 pub use rustc::hir::def::{Namespace, PerNS};
 
-use TypeParameters::*;
+use GenericParameters::*;
 use RibKind::*;
 
 use rustc::hir::map::{Definitions, DefCollector};
@@ -25,7 +25,6 @@
 use rustc::hir::def::Namespace::*;
 use rustc::hir::def_id::{CRATE_DEF_INDEX, LOCAL_CRATE, DefId};
 use rustc::hir::{Freevar, FreevarMap, TraitCandidate, TraitMap, GlobMap};
-use rustc::session::config::nightly_options;
 use rustc::ty;
 use rustc::util::nodemap::{NodeMap, NodeSet, FxHashMap, FxHashSet, DefIdMap};
 use rustc::{bug, span_bug};
@@ -140,10 +139,11 @@ fn cmp(&self, other: &BindingError) -> cmp::Ordering {
 }
 
 enum ResolutionError<'a> {
-    /// error E0401: can't use type parameters from outer function
-    TypeParametersFromOuterFunction(Def),
-    /// error E0403: the name is already used for a type parameter in this type parameter list
-    NameAlreadyUsedInTypeParameterList(Name, &'a Span),
+    /// error E0401: can't use type or const parameters from outer function
+    GenericParamsFromOuterFunction(Def),
+    /// error E0403: the name is already used for a type/const parameter in this list of
+    /// generic parameters
+    NameAlreadyUsedInParameterList(Name, &'a Span),
     /// error E0407: method is not a member of trait
     MethodNotMemberOfTrait(Name, &'a str),
     /// error E0437: type is not a member of trait
@@ -175,7 +175,7 @@ enum ResolutionError<'a> {
     /// error E0530: X bindings cannot shadow Ys
     BindingShadowsSomethingUnacceptable(&'a str, Name, &'a NameBinding<'a>),
     /// error E0128: type parameters with a default cannot use forward declared identifiers
-    ForwardDeclaredTyParam,
+    ForwardDeclaredTyParam, // FIXME(const_generics:defaults)
 }
 
 /// Combines an error with provided span and emits it
@@ -193,12 +193,13 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver<'_>,
                                    resolution_error: ResolutionError<'a>)
                                    -> DiagnosticBuilder<'sess> {
     match resolution_error {
-        ResolutionError::TypeParametersFromOuterFunction(outer_def) => {
+        ResolutionError::GenericParamsFromOuterFunction(outer_def) => {
             let mut err = struct_span_err!(resolver.session,
-                                           span,
-                                           E0401,
-                                           "can't use type parameters from outer function");
-            err.span_label(span, "use of type variable from outer function");
+                span,
+                E0401,
+                "can't use generic parameters from outer function",
+            );
+            err.span_label(span, format!("use of generic parameter from outer function"));
 
             let cm = resolver.session.source_map();
             match outer_def {
@@ -222,20 +223,25 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver<'_>,
                     }
                     return err;
                 },
-                Def::TyParam(typaram_defid) => {
-                    if let Some(typaram_span) = resolver.definitions.opt_span(typaram_defid) {
-                        err.span_label(typaram_span, "type variable from outer function");
+                Def::TyParam(def_id) => {
+                    if let Some(span) = resolver.definitions.opt_span(def_id) {
+                        err.span_label(span, "type variable from outer function");
                     }
-                },
+                }
+                Def::ConstParam(def_id) => {
+                    if let Some(span) = resolver.definitions.opt_span(def_id) {
+                        err.span_label(span, "const variable from outer function");
+                    }
+                }
                 _ => {
-                    bug!("TypeParametersFromOuterFunction should only be used with Def::SelfTy or \
-                         Def::TyParam")
+                    bug!("GenericParamsFromOuterFunction should only be used with Def::SelfTy, \
+                         Def::TyParam");
                 }
             }
 
             // Try to retrieve the span of the function signature and generate a new message with
-            // a local type parameter
-            let sugg_msg = "try using a local type parameter instead";
+            // a local type or const parameter.
+            let sugg_msg = &format!("try using a local generic parameter instead");
             if let Some((sugg_span, new_snippet)) = cm.generate_local_type_param_snippet(span) {
                 // Suggest the modification to the user
                 err.span_suggestion(
@@ -245,19 +251,20 @@ fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver<'_>,
                     Applicability::MachineApplicable,
                 );
             } else if let Some(sp) = cm.generate_fn_name_span(span) {
-                err.span_label(sp, "try adding a local type parameter in this method instead");
+                err.span_label(sp,
+                    format!("try adding a local generic parameter in this method instead"));
             } else {
-                err.help("try using a local type parameter instead");
+                err.help(&format!("try using a local generic parameter instead"));
             }
 
             err
         }
-        ResolutionError::NameAlreadyUsedInTypeParameterList(name, first_use_span) => {
+        ResolutionError::NameAlreadyUsedInParameterList(name, first_use_span) => {
              let mut err = struct_span_err!(resolver.session,
                                             span,
                                             E0403,
-                                            "the name `{}` is already used for a type parameter \
-                                            in this type parameter list",
+                                            "the name `{}` is already used for a generic \
+                                            parameter in this list of generic parameters",
                                             name);
              err.span_label(span, "already used");
              err.span_label(first_use_span.clone(), format!("first use of `{}`", name));
@@ -544,8 +551,7 @@ fn is_expected(self, def: Def) -> bool {
                 Def::Struct(..) | Def::Union(..) | Def::Enum(..) |
                 Def::Trait(..) | Def::TraitAlias(..) | Def::TyAlias(..) |
                 Def::AssociatedTy(..) | Def::PrimTy(..) | Def::TyParam(..) |
-                Def::SelfTy(..) | Def::Existential(..) |
-                Def::ForeignTy(..) => true,
+                Def::SelfTy(..) | Def::Existential(..) | Def::ForeignTy(..) => true,
                 _ => false,
             },
             PathSource::Trait(AliasPossibility::No) => match def {
@@ -562,7 +568,7 @@ fn is_expected(self, def: Def) -> bool {
                 Def::VariantCtor(_, CtorKind::Const) | Def::VariantCtor(_, CtorKind::Fn) |
                 Def::Const(..) | Def::Static(..) | Def::Local(..) | Def::Upvar(..) |
                 Def::Fn(..) | Def::Method(..) | Def::AssociatedConst(..) |
-                Def::SelfCtor(..) => true,
+                Def::SelfCtor(..) | Def::ConstParam(..) => true,
                 _ => false,
             },
             PathSource::Pat => match def {
@@ -746,6 +752,7 @@ fn visit_block(&mut self, block: &'tcx Block) {
         self.resolve_block(block);
     }
     fn visit_anon_const(&mut self, constant: &'tcx ast::AnonConst) {
+        debug!("visit_anon_const {:?}", constant);
         self.with_constant_rib(|this| {
             visit::walk_anon_const(this, constant);
         });
@@ -779,15 +786,15 @@ fn visit_poly_trait_ref(&mut self,
         visit::walk_poly_trait_ref(self, tref, m);
     }
     fn visit_foreign_item(&mut self, foreign_item: &'tcx ForeignItem) {
-        let type_parameters = match foreign_item.node {
+        let generic_params = match foreign_item.node {
             ForeignItemKind::Fn(_, ref generics) => {
-                HasTypeParameters(generics, ItemRibKind)
+                HasGenericParams(generics, ItemRibKind)
             }
-            ForeignItemKind::Static(..) => NoTypeParameters,
-            ForeignItemKind::Ty => NoTypeParameters,
-            ForeignItemKind::Macro(..) => NoTypeParameters,
+            ForeignItemKind::Static(..) => NoGenericParams,
+            ForeignItemKind::Ty => NoGenericParams,
+            ForeignItemKind::Macro(..) => NoGenericParams,
         };
-        self.with_type_parameter_rib(type_parameters, |this| {
+        self.with_generic_param_rib(generic_params, |this| {
             visit::walk_foreign_item(this, foreign_item);
         });
     }
@@ -797,6 +804,7 @@ fn visit_fn(&mut self,
                 _: Span,
                 node_id: NodeId)
     {
+        debug!("(resolving function) entering function");
         let (rib_kind, asyncness) = match function_kind {
             FnKind::ItemFn(_, ref header, ..) =>
                 (ItemRibKind, header.asyncness),
@@ -853,6 +861,7 @@ fn visit_fn(&mut self,
         self.label_ribs.pop();
         self.ribs[ValueNS].pop();
     }
+
     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
@@ -863,6 +872,7 @@ fn visit_generics(&mut self, generics: &'tcx Generics) {
         let mut found_default = false;
         default_ban_rib.bindings.extend(generics.params.iter()
             .filter_map(|param| match param.kind {
+                GenericParamKind::Const { .. } |
                 GenericParamKind::Lifetime { .. } => None,
                 GenericParamKind::Type { ref default, .. } => {
                     found_default |= default.is_some();
@@ -891,6 +901,13 @@ fn visit_generics(&mut self, generics: &'tcx Generics) {
                     // Allow all following defaults to refer to this type parameter.
                     default_ban_rib.bindings.remove(&Ident::with_empty_ctxt(param.ident.name));
                 }
+                GenericParamKind::Const { ref ty } => {
+                    for bound in &param.bounds {
+                        self.visit_param_bound(bound);
+                    }
+
+                    self.visit_ty(ty);
+                }
             }
         }
         for p in &generics.where_clause.predicates {
@@ -900,9 +917,9 @@ fn visit_generics(&mut self, generics: &'tcx Generics) {
 }
 
 #[derive(Copy, Clone)]
-enum TypeParameters<'a, 'b> {
-    NoTypeParameters,
-    HasTypeParameters(// Type parameters.
+enum GenericParameters<'a, 'b> {
+    NoGenericParams,
+    HasGenericParams(// Type parameters.
                       &'b Generics,
 
                       // The kind of the rib used for type parameters.
@@ -1738,7 +1755,7 @@ pub fn resolve_str_path_error(&mut self, span: Span, path_str: &str, is_value: b
         }
     }
 
-    /// resolve_hir_path, but takes a callback in case there was an error
+    /// Like `resolve_hir_path`, but takes a callback in case there was an error.
     fn resolve_hir_path_cb<F>(
         &mut self,
         path: &ast::Path,
@@ -1751,7 +1768,7 @@ fn resolve_hir_path_cb<F>(
         let span = path.span;
         let segments = &path.segments;
         let path = Segment::from_path(&path);
-        // FIXME (Manishearth): Intra doc links won't get warned of epoch changes
+        // FIXME(Manishearth): intra-doc links won't get warned of epoch changes.
         let def = match self.resolve_path_without_parent_scope(&path, Some(namespace), true,
                                                                span, CrateLint::No) {
             PathResult::Module(ModuleOrUniformRoot::Module(module)) =>
@@ -2038,6 +2055,7 @@ fn resolve_ident_in_lexical_scope(&mut self,
         let record_used = record_used_id.is_some();
         let mut module = self.graph_root;
         for i in (0 .. self.ribs[ns].len()).rev() {
+            debug!("walk rib\n{:?}", self.ribs[ns][i].bindings);
             if let Some(def) = self.ribs[ns][i].bindings.get(&ident).cloned() {
                 // The ident resolves to a type parameter or local variable.
                 return Some(LexicalScopeBinding::Def(
@@ -2359,8 +2377,9 @@ fn search_label<P, R>(&self, mut ident: Ident, pred: P) -> Option<R>
     }
 
     fn resolve_adt(&mut self, item: &Item, generics: &Generics) {
+        debug!("resolve_adt");
         self.with_current_self_item(item, |this| {
-            this.with_type_parameter_rib(HasTypeParameters(generics, ItemRibKind), |this| {
+            this.with_generic_param_rib(HasGenericParams(generics, ItemRibKind), |this| {
                 let item_def_id = this.definitions.local_def_id(item.id);
                 this.with_self_rib(Def::SelfTy(None, Some(item_def_id)), |this| {
                     visit::walk_item(this, item);
@@ -2413,13 +2432,13 @@ fn future_proof_import(&mut self, use_tree: &ast::UseTree) {
 
     fn resolve_item(&mut self, item: &Item) {
         let name = item.ident.name;
-        debug!("(resolving item) resolving {}", name);
+        debug!("(resolving item) resolving {} ({:?})", name, item.node);
 
         match item.node {
             ItemKind::Ty(_, ref generics) |
             ItemKind::Fn(_, _, ref generics, _) |
             ItemKind::Existential(_, ref generics) => {
-                self.with_type_parameter_rib(HasTypeParameters(generics, ItemRibKind),
+                self.with_generic_param_rib(HasGenericParams(generics, ItemRibKind),
                                              |this| visit::walk_item(this, item));
             }
 
@@ -2438,16 +2457,16 @@ fn resolve_item(&mut self, item: &Item) {
 
             ItemKind::Trait(.., ref generics, ref bounds, ref trait_items) => {
                 // Create a new rib for the trait-wide type parameters.
-                self.with_type_parameter_rib(HasTypeParameters(generics, ItemRibKind), |this| {
+                self.with_generic_param_rib(HasGenericParams(generics, ItemRibKind), |this| {
                     let local_def_id = this.definitions.local_def_id(item.id);
                     this.with_self_rib(Def::SelfTy(Some(local_def_id), None), |this| {
                         this.visit_generics(generics);
                         walk_list!(this, visit_param_bound, bounds);
 
                         for trait_item in trait_items {
-                            let type_parameters = HasTypeParameters(&trait_item.generics,
+                            let generic_params = HasGenericParams(&trait_item.generics,
                                                                     TraitOrImplItemRibKind);
-                            this.with_type_parameter_rib(type_parameters, |this| {
+                            this.with_generic_param_rib(generic_params, |this| {
                                 match trait_item.node {
                                     TraitItemKind::Const(ref ty, ref default) => {
                                         this.visit_ty(ty);
@@ -2479,7 +2498,7 @@ fn resolve_item(&mut self, item: &Item) {
 
             ItemKind::TraitAlias(ref generics, ref bounds) => {
                 // Create a new rib for the trait-wide type parameters.
-                self.with_type_parameter_rib(HasTypeParameters(generics, ItemRibKind), |this| {
+                self.with_generic_param_rib(HasGenericParams(generics, ItemRibKind), |this| {
                     let local_def_id = this.definitions.local_def_id(item.id);
                     this.with_self_rib(Def::SelfTy(Some(local_def_id), None), |this| {
                         this.visit_generics(generics);
@@ -2496,6 +2515,7 @@ fn resolve_item(&mut self, item: &Item) {
 
             ItemKind::Static(ref ty, _, ref expr) |
             ItemKind::Const(ref ty, ref expr) => {
+                debug!("resolve_item ItemKind::Const");
                 self.with_item_rib(|this| {
                     this.visit_ty(ty);
                     this.with_constant_rib(|this| {
@@ -2517,23 +2537,25 @@ fn resolve_item(&mut self, item: &Item) {
         }
     }
 
-    fn with_type_parameter_rib<'b, F>(&'b mut self, type_parameters: TypeParameters<'a, 'b>, f: F)
+    fn with_generic_param_rib<'b, F>(&'b mut self, generic_params: GenericParameters<'a, 'b>, f: F)
         where F: FnOnce(&mut Resolver<'_>)
     {
-        match type_parameters {
-            HasTypeParameters(generics, rib_kind) => {
+        debug!("with_generic_param_rib");
+        match generic_params {
+            HasGenericParams(generics, rib_kind) => {
                 let mut function_type_rib = Rib::new(rib_kind);
+                let mut function_value_rib = Rib::new(rib_kind);
                 let mut seen_bindings = FxHashMap::default();
                 for param in &generics.params {
                     match param.kind {
                         GenericParamKind::Lifetime { .. } => {}
                         GenericParamKind::Type { .. } => {
                             let ident = param.ident.modern();
-                            debug!("with_type_parameter_rib: {}", param.id);
+                            debug!("with_generic_param_rib: {}", param.id);
 
                             if seen_bindings.contains_key(&ident) {
                                 let span = seen_bindings.get(&ident).unwrap();
-                                let err = ResolutionError::NameAlreadyUsedInTypeParameterList(
+                                let err = ResolutionError::NameAlreadyUsedInParameterList(
                                     ident.name,
                                     span,
                                 );
@@ -2546,20 +2568,40 @@ fn with_type_parameter_rib<'b, F>(&'b mut self, type_parameters: TypeParameters<
                             function_type_rib.bindings.insert(ident, def);
                             self.record_def(param.id, PathResolution::new(def));
                         }
+                        GenericParamKind::Const { .. } => {
+                            let ident = param.ident.modern();
+                            debug!("with_generic_param_rib: {}", param.id);
+
+                            if seen_bindings.contains_key(&ident) {
+                                let span = seen_bindings.get(&ident).unwrap();
+                                let err = ResolutionError::NameAlreadyUsedInParameterList(
+                                    ident.name,
+                                    span,
+                                );
+                                resolve_error(self, param.ident.span, err);
+                            }
+                            seen_bindings.entry(ident).or_insert(param.ident.span);
+
+                            let def = Def::ConstParam(self.definitions.local_def_id(param.id));
+                            function_value_rib.bindings.insert(ident, def);
+                            self.record_def(param.id, PathResolution::new(def));
+                        }
                     }
                 }
+                self.ribs[ValueNS].push(function_value_rib);
                 self.ribs[TypeNS].push(function_type_rib);
             }
 
-            NoTypeParameters => {
+            NoGenericParams => {
                 // Nothing to do.
             }
         }
 
         f(self);
 
-        if let HasTypeParameters(..) = type_parameters {
+        if let HasGenericParams(..) = generic_params {
             self.ribs[TypeNS].pop();
+            self.ribs[ValueNS].pop();
         }
     }
 
@@ -2584,6 +2626,7 @@ fn with_item_rib<F>(&mut self, f: F)
     fn with_constant_rib<F>(&mut self, f: F)
         where F: FnOnce(&mut Resolver<'_>)
     {
+        debug!("with_constant_rib");
         self.ribs[ValueNS].push(Rib::new(ConstantItemRibKind));
         self.label_ribs.push(Rib::new(ConstantItemRibKind));
         f(self);
@@ -2677,8 +2720,9 @@ fn resolve_implementation(&mut self,
                               self_type: &Ty,
                               item_id: NodeId,
                               impl_items: &[ImplItem]) {
+        debug!("resolve_implementation");
         // If applicable, create a rib for the type parameters.
-        self.with_type_parameter_rib(HasTypeParameters(generics, ItemRibKind), |this| {
+        self.with_generic_param_rib(HasGenericParams(generics, ItemRibKind), |this| {
             // Dummy self type for better errors if `Self` is used in the trait path.
             this.with_self_rib(Def::SelfTy(None, None), |this| {
                 // Resolve the trait reference, if necessary.
@@ -2691,30 +2735,37 @@ fn resolve_implementation(&mut self,
                         }
                         // Resolve the self type.
                         this.visit_ty(self_type);
-                        // Resolve the type parameters.
+                        // Resolve the generic parameters.
                         this.visit_generics(generics);
                         // Resolve the items within the impl.
                         this.with_current_self_type(self_type, |this| {
                             this.with_self_struct_ctor_rib(item_def_id, |this| {
+                                debug!("resolve_implementation with_self_struct_ctor_rib");
                                 for impl_item in impl_items {
                                     this.resolve_visibility(&impl_item.vis);
 
                                     // We also need a new scope for the impl item type parameters.
-                                    let type_parameters = HasTypeParameters(&impl_item.generics,
-                                                                            TraitOrImplItemRibKind);
-                                    this.with_type_parameter_rib(type_parameters, |this| {
+                                    let generic_params = HasGenericParams(&impl_item.generics,
+                                                                          TraitOrImplItemRibKind);
+                                    this.with_generic_param_rib(generic_params, |this| {
                                         use self::ResolutionError::*;
                                         match impl_item.node {
                                             ImplItemKind::Const(..) => {
+                                                debug!(
+                                                    "resolve_implementation ImplItemKind::Const",
+                                                );
                                                 // If this is a trait impl, ensure the const
                                                 // exists in trait
-                                                this.check_trait_item(impl_item.ident,
-                                                                      ValueNS,
-                                                                      impl_item.span,
-                                                    |n, s| ConstNotMemberOfTrait(n, s));
-                                                this.with_constant_rib(|this|
-                                                    visit::walk_impl_item(this, impl_item)
+                                                this.check_trait_item(
+                                                    impl_item.ident,
+                                                    ValueNS,
+                                                    impl_item.span,
+                                                    |n, s| ConstNotMemberOfTrait(n, s),
                                                 );
+
+                                                this.with_constant_rib(|this| {
+                                                    visit::walk_impl_item(this, impl_item)
+                                                });
                                             }
                                             ImplItemKind::Method(..) => {
                                                 // If this is a trait impl, ensure the method
@@ -3132,383 +3183,11 @@ fn smart_resolve_path_fragment(&mut self,
                                    source: PathSource<'_>,
                                    crate_lint: CrateLint)
                                    -> PathResolution {
-        let ident_span = path.last().map_or(span, |ident| ident.ident.span);
         let ns = source.namespace();
         let is_expected = &|def| source.is_expected(def);
-        let is_enum_variant = &|def| if let Def::Variant(..) = def { true } else { false };
 
-        // Base error is amended with one short label and possibly some longer helps/notes.
         let report_errors = |this: &mut Self, def: Option<Def>| {
-            // Make the base error.
-            let expected = source.descr_expected();
-            let path_str = Segment::names_to_string(path);
-            let item_str = path.last().unwrap().ident;
-            let code = source.error_code(def.is_some());
-            let (base_msg, fallback_label, base_span) = if let Some(def) = def {
-                (format!("expected {}, found {} `{}`", expected, def.kind_name(), path_str),
-                 format!("not a {}", expected),
-                 span)
-            } else {
-                let item_span = path.last().unwrap().ident.span;
-                let (mod_prefix, mod_str) = if path.len() == 1 {
-                    (String::new(), "this scope".to_string())
-                } else if path.len() == 2 && path[0].ident.name == keywords::PathRoot.name() {
-                    (String::new(), "the crate root".to_string())
-                } else {
-                    let mod_path = &path[..path.len() - 1];
-                    let mod_prefix = match this.resolve_path_without_parent_scope(
-                        mod_path, Some(TypeNS), false, span, CrateLint::No
-                    ) {
-                        PathResult::Module(ModuleOrUniformRoot::Module(module)) =>
-                            module.def(),
-                        _ => None,
-                    }.map_or(String::new(), |def| format!("{} ", def.kind_name()));
-                    (mod_prefix, format!("`{}`", Segment::names_to_string(mod_path)))
-                };
-                (format!("cannot find {} `{}` in {}{}", expected, item_str, mod_prefix, mod_str),
-                 format!("not found in {}", mod_str),
-                 item_span)
-            };
-
-            let code = DiagnosticId::Error(code.into());
-            let mut err = this.session.struct_span_err_with_code(base_span, &base_msg, code);
-
-            // Emit help message for fake-self from other languages like `this`(javascript)
-            if ["this", "my"].contains(&&*item_str.as_str())
-                && this.self_value_is_available(path[0].ident.span, span) {
-                err.span_suggestion(
-                    span,
-                    "did you mean",
-                    "self".to_string(),
-                    Applicability::MaybeIncorrect,
-                );
-            }
-
-            // Emit special messages for unresolved `Self` and `self`.
-            if is_self_type(path, ns) {
-                __diagnostic_used!(E0411);
-                err.code(DiagnosticId::Error("E0411".into()));
-                err.span_label(span, format!("`Self` is only available in impls, traits, \
-                                              and type definitions"));
-                return (err, Vec::new());
-            }
-            if is_self_value(path, ns) {
-                debug!("smart_resolve_path_fragment E0424 source:{:?}", source);
-
-                __diagnostic_used!(E0424);
-                err.code(DiagnosticId::Error("E0424".into()));
-                err.span_label(span, match source {
-                    PathSource::Pat => {
-                        format!("`self` value is a keyword \
-                                and may not be bound to \
-                                variables or shadowed")
-                    }
-                    _ => {
-                        format!("`self` value is a keyword \
-                                only available in methods \
-                                with `self` parameter")
-                    }
-                });
-                return (err, Vec::new());
-            }
-
-            // Try to lookup the name in more relaxed fashion for better error reporting.
-            let ident = path.last().unwrap().ident;
-            let candidates = this.lookup_import_candidates(ident, ns, is_expected);
-            if candidates.is_empty() && is_expected(Def::Enum(DefId::local(CRATE_DEF_INDEX))) {
-                let enum_candidates =
-                    this.lookup_import_candidates(ident, ns, is_enum_variant);
-                let mut enum_candidates = enum_candidates.iter()
-                    .map(|suggestion| {
-                        import_candidate_to_enum_paths(&suggestion)
-                    }).collect::<Vec<_>>();
-                enum_candidates.sort();
-
-                if !enum_candidates.is_empty() {
-                    // contextualize for E0412 "cannot find type", but don't belabor the point
-                    // (that it's a variant) for E0573 "expected type, found variant"
-                    let preamble = if def.is_none() {
-                        let others = match enum_candidates.len() {
-                            1 => String::new(),
-                            2 => " and 1 other".to_owned(),
-                            n => format!(" and {} others", n)
-                        };
-                        format!("there is an enum variant `{}`{}; ",
-                                enum_candidates[0].0, others)
-                    } else {
-                        String::new()
-                    };
-                    let msg = format!("{}try using the variant's enum", preamble);
-
-                    err.span_suggestions(
-                        span,
-                        &msg,
-                        enum_candidates.into_iter()
-                            .map(|(_variant_path, enum_ty_path)| enum_ty_path)
-                            // variants reëxported in prelude doesn't mean `prelude::v1` is the
-                            // type name! FIXME: is there a more principled way to do this that
-                            // would work for other reëxports?
-                            .filter(|enum_ty_path| enum_ty_path != "std::prelude::v1")
-                            // also say `Option` rather than `std::prelude::v1::Option`
-                            .map(|enum_ty_path| {
-                                // FIXME #56861: DRYer prelude filtering
-                                enum_ty_path.trim_start_matches("std::prelude::v1::").to_owned()
-                            }),
-                        Applicability::MachineApplicable,
-                    );
-                }
-            }
-            if path.len() == 1 && this.self_type_is_available(span) {
-                if let Some(candidate) = this.lookup_assoc_candidate(ident, ns, is_expected) {
-                    let self_is_available = this.self_value_is_available(path[0].ident.span, span);
-                    match candidate {
-                        AssocSuggestion::Field => {
-                            err.span_suggestion(
-                                span,
-                                "try",
-                                format!("self.{}", path_str),
-                                Applicability::MachineApplicable,
-                            );
-                            if !self_is_available {
-                                err.span_label(span, format!("`self` value is a keyword \
-                                                               only available in \
-                                                               methods with `self` parameter"));
-                            }
-                        }
-                        AssocSuggestion::MethodWithSelf if self_is_available => {
-                            err.span_suggestion(
-                                span,
-                                "try",
-                                format!("self.{}", path_str),
-                                Applicability::MachineApplicable,
-                            );
-                        }
-                        AssocSuggestion::MethodWithSelf | AssocSuggestion::AssocItem => {
-                            err.span_suggestion(
-                                span,
-                                "try",
-                                format!("Self::{}", path_str),
-                                Applicability::MachineApplicable,
-                            );
-                        }
-                    }
-                    return (err, candidates);
-                }
-            }
-
-            let mut levenshtein_worked = false;
-
-            // Try Levenshtein algorithm.
-            let suggestion = this.lookup_typo_candidate(path, ns, is_expected, span);
-            if let Some(suggestion) = suggestion {
-                let msg = format!(
-                    "{} {} with a similar name exists",
-                    suggestion.article, suggestion.kind
-                );
-                err.span_suggestion(
-                    ident_span,
-                    &msg,
-                    suggestion.candidate.to_string(),
-                    Applicability::MaybeIncorrect,
-                );
-
-                levenshtein_worked = true;
-            }
-
-            // Try context dependent help if relaxed lookup didn't work.
-            if let Some(def) = def {
-                match (def, source) {
-                    (Def::Macro(..), _) => {
-                        err.span_suggestion(
-                            span,
-                            "use `!` to invoke the macro",
-                            format!("{}!", path_str),
-                            Applicability::MaybeIncorrect,
-                        );
-                        return (err, candidates);
-                    }
-                    (Def::TyAlias(..), PathSource::Trait(_)) => {
-                        err.span_label(span, "type aliases cannot be used as traits");
-                        if nightly_options::is_nightly_build() {
-                            err.note("did you mean to use a trait alias?");
-                        }
-                        return (err, candidates);
-                    }
-                    (Def::Mod(..), PathSource::Expr(Some(parent))) => match parent.node {
-                        ExprKind::Field(_, ident) => {
-                            err.span_suggestion(
-                                parent.span,
-                                "use the path separator to refer to an item",
-                                format!("{}::{}", path_str, ident),
-                                Applicability::MaybeIncorrect,
-                            );
-                            return (err, candidates);
-                        }
-                        ExprKind::MethodCall(ref segment, ..) => {
-                            let span = parent.span.with_hi(segment.ident.span.hi());
-                            err.span_suggestion(
-                                span,
-                                "use the path separator to refer to an item",
-                                format!("{}::{}", path_str, segment.ident),
-                                Applicability::MaybeIncorrect,
-                            );
-                            return (err, candidates);
-                        }
-                        _ => {}
-                    },
-                    (Def::Enum(..), PathSource::TupleStruct)
-                        | (Def::Enum(..), PathSource::Expr(..))  => {
-                        if let Some(variants) = this.collect_enum_variants(def) {
-                            err.note(&format!("did you mean to use one \
-                                               of the following variants?\n{}",
-                                variants.iter()
-                                    .map(|suggestion| path_names_to_string(suggestion))
-                                    .map(|suggestion| format!("- `{}`", suggestion))
-                                    .collect::<Vec<_>>()
-                                    .join("\n")));
-
-                        } else {
-                            err.note("did you mean to use one of the enum's variants?");
-                        }
-                        return (err, candidates);
-                    },
-                    (Def::Struct(def_id), _) if ns == ValueNS => {
-                        if let Some((ctor_def, ctor_vis))
-                                = this.struct_constructors.get(&def_id).cloned() {
-                            let accessible_ctor = this.is_accessible(ctor_vis);
-                            if is_expected(ctor_def) && !accessible_ctor {
-                                err.span_label(span, format!("constructor is not visible \
-                                                              here due to private fields"));
-                            }
-                        } else {
-                            // HACK(estebank): find a better way to figure out that this was a
-                            // parser issue where a struct literal is being used on an expression
-                            // where a brace being opened means a block is being started. Look
-                            // ahead for the next text to see if `span` is followed by a `{`.
-                            let sm = this.session.source_map();
-                            let mut sp = span;
-                            loop {
-                                sp = sm.next_point(sp);
-                                match sm.span_to_snippet(sp) {
-                                    Ok(ref snippet) => {
-                                        if snippet.chars().any(|c| { !c.is_whitespace() }) {
-                                            break;
-                                        }
-                                    }
-                                    _ => break,
-                                }
-                            }
-                            let followed_by_brace = match sm.span_to_snippet(sp) {
-                                Ok(ref snippet) if snippet == "{" => true,
-                                _ => false,
-                            };
-                            // In case this could be a struct literal that needs to be surrounded
-                            // by parenthesis, find the appropriate span.
-                            let mut i = 0;
-                            let mut closing_brace = None;
-                            loop {
-                                sp = sm.next_point(sp);
-                                match sm.span_to_snippet(sp) {
-                                    Ok(ref snippet) => {
-                                        if snippet == "}" {
-                                            let sp = span.to(sp);
-                                            if let Ok(snippet) = sm.span_to_snippet(sp) {
-                                                closing_brace = Some((sp, snippet));
-                                            }
-                                            break;
-                                        }
-                                    }
-                                    _ => break,
-                                }
-                                i += 1;
-                                if i > 100 { // The bigger the span the more likely we're
-                                    break;   // incorrect. Bound it to 100 chars long.
-                                }
-                            }
-                            match source {
-                                PathSource::Expr(Some(parent)) => {
-                                    match parent.node {
-                                        ExprKind::MethodCall(ref path_assignment, _)  => {
-                                            err.span_suggestion(
-                                                sm.start_point(parent.span)
-                                                  .to(path_assignment.ident.span),
-                                                "use `::` to access an associated function",
-                                                format!("{}::{}",
-                                                        path_str,
-                                                        path_assignment.ident),
-                                                Applicability::MaybeIncorrect
-                                            );
-                                            return (err, candidates);
-                                        },
-                                        _ => {
-                                            err.span_label(
-                                                span,
-                                                format!("did you mean `{} {{ /* fields */ }}`?",
-                                                        path_str),
-                                            );
-                                            return (err, candidates);
-                                        },
-                                    }
-                                },
-                                PathSource::Expr(None) if followed_by_brace == true => {
-                                    if let Some((sp, snippet)) = closing_brace {
-                                        err.span_suggestion(
-                                            sp,
-                                            "surround the struct literal with parenthesis",
-                                            format!("({})", snippet),
-                                            Applicability::MaybeIncorrect,
-                                        );
-                                    } else {
-                                        err.span_label(
-                                            span,
-                                            format!("did you mean `({} {{ /* fields */ }})`?",
-                                                    path_str),
-                                        );
-                                    }
-                                    return (err, candidates);
-                                },
-                                _ => {
-                                    err.span_label(
-                                        span,
-                                        format!("did you mean `{} {{ /* fields */ }}`?",
-                                                path_str),
-                                    );
-                                    return (err, candidates);
-                                },
-                            }
-                        }
-                        return (err, candidates);
-                    }
-                    (Def::Union(..), _) |
-                    (Def::Variant(..), _) |
-                    (Def::VariantCtor(_, CtorKind::Fictive), _) if ns == ValueNS => {
-                        err.span_label(span, format!("did you mean `{} {{ /* fields */ }}`?",
-                                                     path_str));
-                        return (err, candidates);
-                    }
-                    (Def::SelfTy(..), _) if ns == ValueNS => {
-                        err.span_label(span, fallback_label);
-                        err.note("can't use `Self` as a constructor, you must use the \
-                                  implemented struct");
-                        return (err, candidates);
-                    }
-                    (Def::TyAlias(_), _) | (Def::AssociatedTy(..), _) if ns == ValueNS => {
-                        err.note("can't use a type alias as a constructor");
-                        return (err, candidates);
-                    }
-                    _ => {}
-                }
-            }
-
-            // Fallback label.
-            if !levenshtein_worked {
-                err.span_label(base_span, fallback_label);
-                this.type_ascription_suggestion(&mut err, base_span);
-            }
-            (err, candidates)
-        };
-        let report_errors = |this: &mut Self, def: Option<Def>| {
-            let (err, candidates) = report_errors(this, def);
+            let (err, candidates) = this.smart_resolve_report_errors(path, span, source, def);
             let def_id = this.current_module.normal_ancestor_id;
             let node_id = this.definitions.as_local_node_id(def_id).unwrap();
             let better = def.is_some();
@@ -3579,7 +3258,8 @@ fn type_ascription_suggestion(&self,
         debug!("self.current_type_ascription {:?}", self.current_type_ascription);
         if let Some(sp) = self.current_type_ascription.last() {
             let mut sp = *sp;
-            loop {  // try to find the `:`, bail on first non-':'/non-whitespace
+            loop {
+                // Try to find the `:`; bail on first non-':' / non-whitespace.
                 sp = cm.next_point(sp);
                 if let Ok(snippet) = cm.span_to_snippet(sp.to(cm.next_point(sp))) {
                     debug!("snippet {:?}", snippet);
@@ -4093,6 +3773,7 @@ fn adjust_local_def(&mut self,
                         mut def: Def,
                         record_used: bool,
                         span: Span) -> Def {
+        debug!("adjust_local_def");
         let ribs = &self.ribs[ns][rib_index + 1..];
 
         // An invalid forward use of a type parameter from a previous default.
@@ -4109,6 +3790,9 @@ fn adjust_local_def(&mut self,
                 span_bug!(span, "unexpected {:?} in bindings", def)
             }
             Def::Local(node_id) => {
+                use ResolutionError::*;
+                let mut res_err = None;
+
                 for rib in ribs {
                     match rib.kind {
                         NormalRibKind | ModuleRibKind(..) | MacroDefinition(..) |
@@ -4144,21 +3828,26 @@ fn adjust_local_def(&mut self,
                             // named function item. This is not allowed, so we
                             // report an error.
                             if record_used {
-                                resolve_error(self, span,
-                                    ResolutionError::CannotCaptureDynamicEnvironmentInFnItem);
+                                // We don't immediately trigger a resolve error, because
+                                // we want certain other resolution errors (namely those
+                                // emitted for `ConstantItemRibKind` below) to take
+                                // precedence.
+                                res_err = Some(CannotCaptureDynamicEnvironmentInFnItem);
                             }
-                            return Def::Err;
                         }
                         ConstantItemRibKind => {
                             // Still doesn't deal with upvars
                             if record_used {
-                                resolve_error(self, span,
-                                    ResolutionError::AttemptToUseNonConstantValueInConstant);
+                                resolve_error(self, span, AttemptToUseNonConstantValueInConstant);
                             }
                             return Def::Err;
                         }
                     }
                 }
+                if let Some(res_err) = res_err {
+                     resolve_error(self, span, res_err);
+                     return Def::Err;
+                }
             }
             Def::TyParam(..) | Def::SelfTy(..) => {
                 for rib in ribs {
@@ -4169,17 +3858,38 @@ fn adjust_local_def(&mut self,
                             // Nothing to do. Continue.
                         }
                         ItemRibKind => {
-                            // This was an attempt to use a type parameter outside
-                            // its scope.
+                            // This was an attempt to use a type parameter outside its scope.
                             if record_used {
-                                resolve_error(self, span,
-                                    ResolutionError::TypeParametersFromOuterFunction(def));
+                                resolve_error(
+                                    self,
+                                    span,
+                                    ResolutionError::GenericParamsFromOuterFunction(def),
+                                );
                             }
                             return Def::Err;
                         }
                     }
                 }
             }
+            Def::ConstParam(..) => {
+                // A const param is always declared in a signature, which is always followed by
+                // some kind of function rib kind (specifically, ItemRibKind in the case of a
+                // normal function), so we can skip the first rib as it will be guaranteed to
+                // (spuriously) conflict with the const param.
+                for rib in &ribs[1..] {
+                    if let ItemRibKind = rib.kind {
+                        // This was an attempt to use a const parameter outside its scope.
+                        if record_used {
+                            resolve_error(
+                                self,
+                                span,
+                                ResolutionError::GenericParamsFromOuterFunction(def),
+                            );
+                        }
+                        return Def::Err;
+                    }
+                }
+            }
             _ => {}
         }
         def
@@ -5438,7 +5148,6 @@ fn import_candidate_to_enum_paths(suggestion: &ImportSuggestion) -> (String, Str
     (variant_path_string, enum_path_string)
 }
 
-
 /// When an entity with a given name is not available in scope, we search for
 /// entities with that name in all crates. This method allows outputting the
 /// results of this search in a programmer-friendly way
index e47f89c64ff075154e85bcf8a9a7c1dc8ac4c620..8bb2e722b57941d6e8cc5a4a28987c2654e58315 100644 (file)
@@ -2,6 +2,7 @@
 authors = ["The Rust Project Developers"]
 name = "rustc_save_analysis"
 version = "0.0.0"
+edition = "2018"
 
 [lib]
 name = "rustc_save_analysis"
index 995df3802aabd043390405125d7cdc0920af80b7..1a49056bc7f2695207d83f96a69caf57824b7b7c 100644 (file)
@@ -16,6 +16,7 @@
 use rustc::hir::def::Def as HirDef;
 use rustc::hir::def_id::DefId;
 use rustc::session::config::Input;
+use rustc::span_bug;
 use rustc::ty::{self, TyCtxt};
 use rustc_data_structures::fx::FxHashSet;
 
 };
 use syntax::ptr::P;
 use syntax::source_map::{Spanned, DUMMY_SP, respan};
+use syntax::walk_list;
 use syntax_pos::*;
 
-use {escape, generated_code, lower_attributes, PathCollector, SaveContext};
-use json_dumper::{Access, DumpOutput, JsonDumper};
-use span_utils::SpanUtils;
-use sig;
+use crate::{escape, generated_code, id_from_def_id, id_from_node_id, lower_attributes,
+            PathCollector, SaveContext};
+use crate::json_dumper::{Access, DumpOutput, JsonDumper};
+use crate::span_utils::SpanUtils;
+use crate::sig;
 
 use rls_data::{CompilationOptions, CratePreludeData, Def, DefKind, GlobalCrateId, Import,
                ImportKind, Ref, RefKind, Relation, RelationKind, SpanData};
 
+use log::{debug, error};
+
 macro_rules! down_cast_data {
     ($id:ident, $kind:ident, $sp:expr) => {
         let $id = if let super::Data::$kind(data) = $id {
@@ -68,7 +73,7 @@ macro_rules! access_from {
     };
 }
 
-pub struct DumpVisitor<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> {
+pub struct DumpVisitor<'l, 'tcx: 'l, 'll, O: DumpOutput> {
     save_ctxt: SaveContext<'l, 'tcx>,
     tcx: TyCtxt<'l, 'tcx, 'tcx>,
     dumper: &'ll mut JsonDumper<O>,
@@ -245,7 +250,7 @@ fn process_formals(&mut self, formals: &'l [ast::Arg], qualname: &str) {
                     None => continue,
                 };
                 if !self.span.filter_generated(ident.span) {
-                    let id = ::id_from_node_id(id, &self.save_ctxt);
+                    let id = id_from_node_id(id, &self.save_ctxt);
                     let span = self.span_from_span(ident.span);
 
                     self.dumper.dump_def(
@@ -286,7 +291,7 @@ fn process_method(
         debug!("process_method: {}:{}", id, ident);
 
         if let Some(mut method_data) = self.save_ctxt.get_method_data(id, ident, span) {
-            let sig_str = ::make_signature(&sig.decl, &generics);
+            let sig_str = crate::make_signature(&sig.decl, &generics);
             if body.is_some() {
                 self.nest_tables(
                     id,
@@ -339,7 +344,7 @@ fn process_generic_params(
                     // Append $id to name to make sure each one is unique.
                     let qualname = format!("{}::{}${}", prefix, name, id);
                     if !self.span.filter_generated(param_ss) {
-                        let id = ::id_from_node_id(param.id, &self.save_ctxt);
+                        let id = id_from_node_id(param.id, &self.save_ctxt);
                         let span = self.span_from_span(param_ss);
 
                         self.dumper.dump_def(
@@ -364,6 +369,7 @@ fn process_generic_params(
                         );
                     }
                 }
+                ast::GenericParamKind::Const { .. } => {}
             }
         }
         self.visit_generics(generics);
@@ -433,12 +439,12 @@ fn process_assoc_const(
                 &access_from!(self.save_ctxt, vis, id),
                 Def {
                     kind: DefKind::Const,
-                    id: ::id_from_node_id(id, &self.save_ctxt),
+                    id: id_from_node_id(id, &self.save_ctxt),
                     span,
                     name: ident.name.to_string(),
                     qualname,
                     value: ty_to_string(&typ),
-                    parent: Some(::id_from_def_id(parent_id)),
+                    parent: Some(id_from_def_id(parent_id)),
                     children: vec![],
                     decl_id: None,
                     docs: self.save_ctxt.docs_for_attrs(attrs),
@@ -495,7 +501,7 @@ fn process_struct(
                     value,
                     fields
                         .iter()
-                        .map(|f| ::id_from_node_id(f.id, &self.save_ctxt))
+                        .map(|f| id_from_node_id(f.id, &self.save_ctxt))
                         .collect(),
                 )
             }
@@ -508,7 +514,7 @@ fn process_struct(
                 &access_from!(self.save_ctxt, item),
                 Def {
                     kind,
-                    id: ::id_from_node_id(item.id, &self.save_ctxt),
+                    id: id_from_node_id(item.id, &self.save_ctxt),
                     span,
                     name,
                     qualname: qualname.clone(),
@@ -564,8 +570,8 @@ fn process_enum(
                     let value = format!("{}::{} {{ {} }}", enum_data.name, name, fields_str);
                     if !self.span.filter_generated(name_span) {
                         let span = self.span_from_span(name_span);
-                        let id = ::id_from_node_id(variant.node.data.id(), &self.save_ctxt);
-                        let parent = Some(::id_from_node_id(item.id, &self.save_ctxt));
+                        let id = id_from_node_id(variant.node.data.id(), &self.save_ctxt);
+                        let parent = Some(id_from_node_id(item.id, &self.save_ctxt));
 
                         self.dumper.dump_def(
                             &access,
@@ -602,8 +608,8 @@ fn process_enum(
                     }
                     if !self.span.filter_generated(name_span) {
                         let span = self.span_from_span(name_span);
-                        let id = ::id_from_node_id(variant.node.data.id(), &self.save_ctxt);
-                        let parent = Some(::id_from_node_id(item.id, &self.save_ctxt));
+                        let id = id_from_node_id(variant.node.data.id(), &self.save_ctxt);
+                        let parent = Some(id_from_node_id(item.id, &self.save_ctxt));
 
                         self.dumper.dump_def(
                             &access,
@@ -686,11 +692,11 @@ fn process_trait(
             val.push_str(&bounds_to_string(trait_refs));
         }
         if !self.span.filter_generated(item.ident.span) {
-            let id = ::id_from_node_id(item.id, &self.save_ctxt);
+            let id = id_from_node_id(item.id, &self.save_ctxt);
             let span = self.span_from_span(item.ident.span);
             let children = methods
                 .iter()
-                .map(|i| ::id_from_node_id(i.id, &self.save_ctxt))
+                .map(|i| id_from_node_id(i.id, &self.save_ctxt))
                 .collect();
             self.dumper.dump_def(
                 &access_from!(self.save_ctxt, item),
@@ -726,14 +732,14 @@ fn process_trait(
                     self.dumper.dump_ref(Ref {
                         kind: RefKind::Type,
                         span: span.clone(),
-                        ref_id: ::id_from_def_id(id),
+                        ref_id: id_from_def_id(id),
                     });
 
                     self.dumper.dump_relation(Relation {
                         kind: RelationKind::SuperTrait,
                         span,
-                        from: ::id_from_def_id(id),
-                        to: ::id_from_node_id(item.id, &self.save_ctxt),
+                        from: id_from_def_id(id),
+                        to: id_from_node_id(item.id, &self.save_ctxt),
                     });
                 }
             }
@@ -873,7 +879,7 @@ fn process_pat(&mut self, p: &'l ast::Pat) {
                             self.dumper.dump_ref(Ref {
                                 kind: RefKind::Variable,
                                 span,
-                                ref_id: ::id_from_def_id(variant.fields[index].did),
+                                ref_id: id_from_def_id(variant.fields[index].did),
                             });
                         }
                     }
@@ -912,7 +918,7 @@ fn process_var_decl_multi(&mut self, pats: &'l [P<ast::Pat>]) {
 
                     if !self.span.filter_generated(ident.span) {
                         let qualname = format!("{}${}", ident.to_string(), id);
-                        let id = ::id_from_node_id(id, &self.save_ctxt);
+                        let id = id_from_node_id(id, &self.save_ctxt);
                         let span = self.span_from_span(ident.span);
 
                         self.dumper.dump_def(
@@ -988,7 +994,7 @@ fn process_var_decl(&mut self, p: &'l ast::Pat, value: String) {
             // Rust uses the id of the pattern for var lookups, so we'll use it too.
             if !self.span.filter_generated(ident.span) {
                 let qualname = format!("{}${}", ident.to_string(), id);
-                let id = ::id_from_node_id(id, &self.save_ctxt);
+                let id = id_from_node_id(id, &self.save_ctxt);
                 let span = self.span_from_span(ident.span);
 
                 self.dumper.dump_def(
@@ -1091,7 +1097,7 @@ fn process_trait_item(&mut self, trait_item: &'l ast::TraitItem, trait_id: DefId
 
                 if !self.span.filter_generated(trait_item.ident.span) {
                     let span = self.span_from_span(trait_item.ident.span);
-                    let id = ::id_from_node_id(trait_item.id, &self.save_ctxt);
+                    let id = id_from_node_id(trait_item.id, &self.save_ctxt);
 
                     self.dumper.dump_def(
                         &Access {
@@ -1105,7 +1111,7 @@ fn process_trait_item(&mut self, trait_item: &'l ast::TraitItem, trait_id: DefId
                             name,
                             qualname,
                             value: self.span.snippet(trait_item.span),
-                            parent: Some(::id_from_def_id(trait_id)),
+                            parent: Some(id_from_def_id(trait_id)),
                             children: vec![],
                             decl_id: None,
                             docs: self.save_ctxt.docs_for_attrs(&trait_item.attrs),
@@ -1196,7 +1202,7 @@ fn process_use_tree(&mut self,
         // The parent def id of a given use tree is always the enclosing item.
         let parent = self.save_ctxt.tcx.hir().opt_local_def_id(id)
             .and_then(|id| self.save_ctxt.tcx.parent_def_id(id))
-            .map(::id_from_def_id);
+            .map(id_from_def_id);
 
         match use_tree.kind {
             ast::UseTreeKind::Simple(alias, ..) => {
@@ -1212,7 +1218,7 @@ fn process_use_tree(&mut self,
 
                 let sub_span = path.segments.last().unwrap().ident.span;
                 if !self.span.filter_generated(sub_span) {
-                    let ref_id = self.lookup_def_id(id).map(|id| ::id_from_def_id(id));
+                    let ref_id = self.lookup_def_id(id).map(|id| id_from_def_id(id));
                     let alias_span = alias.map(|i| self.span_from_span(i.span));
                     let span = self.span_from_span(sub_span);
                     self.dumper.import(&access, Import {
@@ -1298,10 +1304,10 @@ fn visit_mod(&mut self, m: &'l ast::Mod, span: Span, attrs: &[ast::Attribute], i
 
         let cm = self.tcx.sess.source_map();
         let filename = cm.span_to_filename(span);
-        let data_id = ::id_from_node_id(id, &self.save_ctxt);
+        let data_id = id_from_node_id(id, &self.save_ctxt);
         let children = m.items
             .iter()
-            .map(|i| ::id_from_node_id(i.id, &self.save_ctxt))
+            .map(|i| id_from_node_id(i.id, &self.save_ctxt))
             .collect();
         let span = self.span_from_span(span);
 
@@ -1345,7 +1351,7 @@ fn visit_item(&mut self, item: &'l ast::Item) {
                     let span = self.span_from_span(name_span);
                     let parent = self.save_ctxt.tcx.hir().opt_local_def_id(item.id)
                         .and_then(|id| self.save_ctxt.tcx.parent_def_id(id))
-                        .map(::id_from_def_id);
+                        .map(id_from_def_id);
                     self.dumper.import(
                         &Access {
                             public: false,
@@ -1387,7 +1393,7 @@ fn visit_item(&mut self, item: &'l ast::Item) {
                 let value = ty_to_string(&ty);
                 if !self.span.filter_generated(item.ident.span) {
                     let span = self.span_from_span(item.ident.span);
-                    let id = ::id_from_node_id(item.id, &self.save_ctxt);
+                    let id = id_from_node_id(item.id, &self.save_ctxt);
 
                     self.dumper.dump_def(
                         &access_from!(self.save_ctxt, item),
@@ -1417,7 +1423,7 @@ fn visit_item(&mut self, item: &'l ast::Item) {
                 let value = String::new();
                 if !self.span.filter_generated(item.ident.span) {
                     let span = self.span_from_span(item.ident.span);
-                    let id = ::id_from_node_id(item.id, &self.save_ctxt);
+                    let id = id_from_node_id(item.id, &self.save_ctxt);
 
                     self.dumper.dump_def(
                         &access_from!(self.save_ctxt, item),
@@ -1447,9 +1453,16 @@ fn visit_item(&mut self, item: &'l ast::Item) {
 
     fn visit_generics(&mut self, generics: &'l ast::Generics) {
         for param in &generics.params {
-            if let ast::GenericParamKind::Type { ref default, .. } = param.kind {
-                self.process_bounds(&param.bounds);
-                if let Some(ref ty) = default {
+            match param.kind {
+                ast::GenericParamKind::Lifetime { .. } => {}
+                ast::GenericParamKind::Type { ref default, .. } => {
+                    self.process_bounds(&param.bounds);
+                    if let Some(ref ty) = default {
+                        self.visit_ty(&ty);
+                    }
+                }
+                ast::GenericParamKind::Const { ref ty } => {
+                    self.process_bounds(&param.bounds);
                     self.visit_ty(&ty);
                 }
             }
@@ -1476,7 +1489,7 @@ fn visit_ty(&mut self, t: &'l ast::Ty) {
                     self.dumper.dump_ref(Ref {
                         kind: RefKind::Type,
                         span,
-                        ref_id: ::id_from_def_id(id),
+                        ref_id: id_from_def_id(id),
                     });
                 }
 
index 3627c5577a626d3f4afe13fd6e87ef24e1b99200..1840cf652e1d5bbc4060c1eea0e8052b63e5e019 100644 (file)
@@ -7,6 +7,8 @@
                MacroRef, Ref, RefKind, Relation};
 use rls_span::{Column, Row};
 
+use log::error;
+
 #[derive(Debug)]
 pub struct Access {
     pub reachable: bool,
@@ -23,7 +25,7 @@ pub trait DumpOutput {
     fn dump(&mut self, result: &Analysis);
 }
 
-pub struct WriteOutput<'b, W: Write + 'b> {
+pub struct WriteOutput<'b, W: Write> {
     output: &'b mut W,
 }
 
index b9d195d571568bfd3a32fc8d7c14b77407d234f4..c4a2ebeba652952371106595442ecb0ef219869b 100644 (file)
@@ -1,27 +1,10 @@
 #![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
 #![feature(custom_attribute)]
-#![feature(nll)]
+#![deny(rust_2018_idioms)]
 #![allow(unused_attributes)]
 
 #![recursion_limit="256"]
 
-#[macro_use]
-extern crate rustc;
-
-#[macro_use]
-extern crate log;
-extern crate rustc_data_structures;
-extern crate rustc_codegen_utils;
-extern crate rustc_serialize;
-extern crate rustc_target;
-extern crate rustc_typeck;
-#[macro_use]
-extern crate syntax;
-extern crate syntax_pos;
-
-extern crate rls_data;
-extern crate rls_span;
-
 
 mod json_dumper;
 mod dump_visitor;
@@ -37,6 +20,7 @@
 use rustc::middle::cstore::ExternCrate;
 use rustc::session::config::{CrateType, Input, OutputType};
 use rustc::ty::{self, TyCtxt};
+use rustc::{bug, span_bug};
 use rustc_typeck::hir_ty_to_ty;
 use rustc_codegen_utils::link::{filename_for_metadata, out_filename};
 use rustc_data_structures::sync::Lrc;
@@ -64,6 +48,8 @@
                RelationKind, SpanData, Impl, ImplKind};
 use rls_data::config::Config;
 
+use log::{debug, error, info};
+
 
 pub struct SaveContext<'l, 'tcx: 'l> {
     tcx: TyCtxt<'l, 'tcx, 'tcx>,
@@ -170,7 +156,7 @@ pub fn get_extern_item_data(&self, item: &ast::ForeignItem) -> Option<Data> {
             ast::ForeignItemKind::Static(ref ty, _) => {
                 filter!(self.span_utils, item.ident.span);
 
-                let id = ::id_from_node_id(item.id, self);
+                let id = id_from_node_id(item.id, self);
                 let span = self.span_from_span(item.ident.span);
 
                 Some(Data::DefData(Def {
@@ -760,6 +746,13 @@ fn fn_type(seg: &ast::PathSegment) -> bool {
                     ref_id: id_from_def_id(def_id),
                 })
             }
+            HirDef::ConstParam(def_id) => {
+                Some(Ref {
+                    kind: RefKind::Variable,
+                    span,
+                    ref_id: id_from_def_id(def_id),
+                })
+            }
             HirDef::StructCtor(def_id, _) => {
                 // This is a reference to a tuple struct where the def_id points
                 // to an invisible constructor function. That is not a very useful
@@ -1027,7 +1020,7 @@ pub fn new(odir: Option<&'a Path>, cratename: &str) -> DumpHandler<'a> {
         }
     }
 
-    fn output_file(&self, ctx: &SaveContext) -> File {
+    fn output_file(&self, ctx: &SaveContext<'_, '_>) -> File {
         let sess = &ctx.tcx.sess;
         let file_name = match ctx.config.output_file {
             Some(ref s) => PathBuf::from(s),
@@ -1178,7 +1171,7 @@ fn id_from_def_id(id: DefId) -> rls_data::Id {
     }
 }
 
-fn id_from_node_id(id: NodeId, scx: &SaveContext) -> rls_data::Id {
+fn id_from_node_id(id: NodeId, scx: &SaveContext<'_, '_>) -> rls_data::Id {
     let def_id = scx.tcx.hir().opt_local_def_id(id);
     def_id.map(|id| id_from_def_id(id)).unwrap_or_else(|| {
         // Create a *fake* `DefId` out of a `NodeId` by subtracting the `NodeId`
@@ -1198,7 +1191,7 @@ fn null_id() -> rls_data::Id {
     }
 }
 
-fn lower_attributes(attrs: Vec<Attribute>, scx: &SaveContext) -> Vec<rls_data::Attribute> {
+fn lower_attributes(attrs: Vec<Attribute>, scx: &SaveContext<'_, '_>) -> Vec<rls_data::Attribute> {
     attrs.into_iter()
     // Only retain real attributes. Doc comments are lowered separately.
     .filter(|attr| attr.path != "doc")
index 7d4c0d0f9f56f58d461e3dbde648d00f838a3f3f..50a335bf908776cf26eee6351e7f6e61af868e7d 100644 (file)
@@ -25,7 +25,7 @@
 //
 // FIXME where clauses need implementing, defs/refs in generics are mostly missing.
 
-use {id_from_def_id, id_from_node_id, SaveContext};
+use crate::{id_from_def_id, id_from_node_id, SaveContext};
 
 use rls_data::{SigElement, Signature};
 
 use syntax::print::pprust;
 
 
-pub fn item_signature(item: &ast::Item, scx: &SaveContext) -> Option<Signature> {
+pub fn item_signature(item: &ast::Item, scx: &SaveContext<'_, '_>) -> Option<Signature> {
     if !scx.config.signatures {
         return None;
     }
     item.make(0, None, scx).ok()
 }
 
-pub fn foreign_item_signature(item: &ast::ForeignItem, scx: &SaveContext) -> Option<Signature> {
+pub fn foreign_item_signature(
+    item: &ast::ForeignItem,
+    scx: &SaveContext<'_, '_>
+) -> Option<Signature> {
     if !scx.config.signatures {
         return None;
     }
@@ -50,7 +53,7 @@ pub fn foreign_item_signature(item: &ast::ForeignItem, scx: &SaveContext) -> Opt
 
 /// Signature for a struct or tuple field declaration.
 /// Does not include a trailing comma.
-pub fn field_signature(field: &ast::StructField, scx: &SaveContext) -> Option<Signature> {
+pub fn field_signature(field: &ast::StructField, scx: &SaveContext<'_, '_>) -> Option<Signature> {
     if !scx.config.signatures {
         return None;
     }
@@ -58,7 +61,7 @@ pub fn field_signature(field: &ast::StructField, scx: &SaveContext) -> Option<Si
 }
 
 /// Does not include a trailing comma.
-pub fn variant_signature(variant: &ast::Variant, scx: &SaveContext) -> Option<Signature> {
+pub fn variant_signature(variant: &ast::Variant, scx: &SaveContext<'_, '_>) -> Option<Signature> {
     if !scx.config.signatures {
         return None;
     }
@@ -70,7 +73,7 @@ pub fn method_signature(
     ident: ast::Ident,
     generics: &ast::Generics,
     m: &ast::MethodSig,
-    scx: &SaveContext,
+    scx: &SaveContext<'_, '_>,
 ) -> Option<Signature> {
     if !scx.config.signatures {
         return None;
@@ -83,7 +86,7 @@ pub fn assoc_const_signature(
     ident: ast::Name,
     ty: &ast::Ty,
     default: Option<&ast::Expr>,
-    scx: &SaveContext,
+    scx: &SaveContext<'_, '_>,
 ) -> Option<Signature> {
     if !scx.config.signatures {
         return None;
@@ -96,7 +99,7 @@ pub fn assoc_type_signature(
     ident: ast::Ident,
     bounds: Option<&ast::GenericBounds>,
     default: Option<&ast::Ty>,
-    scx: &SaveContext,
+    scx: &SaveContext<'_, '_>,
 ) -> Option<Signature> {
     if !scx.config.signatures {
         return None;
@@ -104,10 +107,10 @@ pub fn assoc_type_signature(
     make_assoc_type_signature(id, ident, bounds, default, scx).ok()
 }
 
-type Result = ::std::result::Result<Signature, &'static str>;
+type Result = std::result::Result<Signature, &'static str>;
 
 trait Sig {
-    fn make(&self, offset: usize, id: Option<NodeId>, scx: &SaveContext) -> Result;
+    fn make(&self, offset: usize, id: Option<NodeId>, scx: &SaveContext<'_, '_>) -> Result;
 }
 
 fn extend_sig(
@@ -155,7 +158,7 @@ fn text_sig(text: String) -> Signature {
 }
 
 impl Sig for ast::Ty {
-    fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext) -> Result {
+    fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext<'_, '_>) -> Result {
         let id = Some(self.id);
         match self.node {
             ast::TyKind::Slice(ref ty) => {
@@ -227,7 +230,7 @@ fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext) ->
                 if f.unsafety == ast::Unsafety::Unsafe {
                     text.push_str("unsafe ");
                 }
-                if f.abi != ::rustc_target::spec::abi::Abi::Rust {
+                if f.abi != rustc_target::spec::abi::Abi::Rust {
                     text.push_str("extern");
                     text.push_str(&f.abi.to_string());
                     text.push(' ');
@@ -317,7 +320,7 @@ fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext) ->
 }
 
 impl Sig for ast::Item {
-    fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext) -> Result {
+    fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext<'_, '_>) -> Result {
         let id = Some(self.id);
 
         match self.node {
@@ -381,7 +384,7 @@ fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext) ->
                 if header.unsafety == ast::Unsafety::Unsafe {
                     text.push_str("unsafe ");
                 }
-                if header.abi != ::rustc_target::spec::abi::Abi::Rust {
+                if header.abi != rustc_target::spec::abi::Abi::Rust {
                     text.push_str("extern");
                     text.push_str(&header.abi.to_string());
                     text.push(' ');
@@ -571,7 +574,7 @@ fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext) ->
 }
 
 impl Sig for ast::Path {
-    fn make(&self, offset: usize, id: Option<NodeId>, scx: &SaveContext) -> Result {
+    fn make(&self, offset: usize, id: Option<NodeId>, scx: &SaveContext<'_, '_>) -> Result {
         let def = scx.get_path_def(id.ok_or("Missing id for Path")?);
 
         let (name, start, end) = match def {
@@ -613,7 +616,7 @@ fn make(&self, offset: usize, id: Option<NodeId>, scx: &SaveContext) -> Result {
 
 // This does not cover the where clause, which must be processed separately.
 impl Sig for ast::Generics {
-    fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext) -> Result {
+    fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext<'_, '_>) -> Result {
         if self.params.is_empty() {
             return Ok(text_sig(String::new()));
         }
@@ -622,12 +625,20 @@ fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext) ->
 
         let mut defs = Vec::with_capacity(self.params.len());
         for param in &self.params {
-            let mut param_text = param.ident.to_string();
+            let mut param_text = String::new();
+            if let ast::GenericParamKind::Const { .. } = param.kind {
+                param_text.push_str("const ");
+            }
+            param_text.push_str(&param.ident.as_str());
             defs.push(SigElement {
                 id: id_from_node_id(param.id, scx),
                 start: offset + text.len(),
-                end: offset + text.len() + param_text.len(),
+                end: offset + text.len() + param_text.as_str().len(),
             });
+            if let ast::GenericParamKind::Const { ref ty } = param.kind {
+                param_text.push_str(": ");
+                param_text.push_str(&pprust::ty_to_string(&ty));
+            }
             if !param.bounds.is_empty() {
                 param_text.push_str(": ");
                 match param.kind {
@@ -646,6 +657,9 @@ fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext) ->
                         param_text.push_str(&pprust::bounds_to_string(&param.bounds));
                         // FIXME descend properly into bounds.
                     }
+                    ast::GenericParamKind::Const { .. } => {
+                        // Const generics cannot contain bounds.
+                    }
                 }
             }
             text.push_str(&param_text);
@@ -662,7 +676,7 @@ fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext) ->
 }
 
 impl Sig for ast::StructField {
-    fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext) -> Result {
+    fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext<'_, '_>) -> Result {
         let mut text = String::new();
         let mut defs = None;
         if let Some(ident) = self.ident {
@@ -685,7 +699,7 @@ fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext) ->
 
 
 impl Sig for ast::Variant_ {
-    fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext) -> Result {
+    fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext<'_, '_>) -> Result {
         let mut text = self.ident.to_string();
         match self.data {
             ast::VariantData::Struct(ref fields, id) => {
@@ -743,7 +757,7 @@ fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext) ->
 }
 
 impl Sig for ast::ForeignItem {
-    fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext) -> Result {
+    fn make(&self, offset: usize, _parent_id: Option<NodeId>, scx: &SaveContext<'_, '_>) -> Result {
         let id = Some(self.id);
         match self.node {
             ast::ForeignItemKind::Fn(ref decl, ref generics) => {
@@ -827,7 +841,7 @@ fn name_and_generics(
     generics: &ast::Generics,
     id: NodeId,
     name: ast::Ident,
-    scx: &SaveContext,
+    scx: &SaveContext<'_, '_>,
 ) -> Result {
     let name = name.to_string();
     let def = SigElement {
@@ -848,7 +862,7 @@ fn make_assoc_type_signature(
     ident: ast::Ident,
     bounds: Option<&ast::GenericBounds>,
     default: Option<&ast::Ty>,
-    scx: &SaveContext,
+    scx: &SaveContext<'_, '_>,
 ) -> Result {
     let mut text = "type ".to_owned();
     let name = ident.to_string();
@@ -882,7 +896,7 @@ fn make_assoc_const_signature(
     ident: ast::Name,
     ty: &ast::Ty,
     default: Option<&ast::Expr>,
-    scx: &SaveContext,
+    scx: &SaveContext<'_, '_>,
 ) -> Result {
     let mut text = "const ".to_owned();
     let name = ident.to_string();
@@ -915,7 +929,7 @@ fn make_method_signature(
     ident: ast::Ident,
     generics: &ast::Generics,
     m: &ast::MethodSig,
-    scx: &SaveContext,
+    scx: &SaveContext<'_, '_>,
 ) -> Result {
     // FIXME code dup with function signature
     let mut text = String::new();
@@ -928,7 +942,7 @@ fn make_method_signature(
     if m.header.unsafety == ast::Unsafety::Unsafe {
         text.push_str("unsafe ");
     }
-    if m.header.abi != ::rustc_target::spec::abi::Abi::Rust {
+    if m.header.abi != rustc_target::spec::abi::Abi::Rust {
         text.push_str("extern");
         text.push_str(&m.header.abi.to_string());
         text.push(' ');
index 88c6012f71f69ea14dc1efc1d7b1e68e3af4d17e..e2c93b6d331586bbd7e5f33daab25af7c46c6b51 100644 (file)
@@ -1,6 +1,6 @@
 use rustc::session::Session;
 
-use generated_code;
+use crate::generated_code;
 
 use std::cell::Cell;
 
index dfdd7f0ae58e5e0b810cdfc90ae1244c893d6b44..ecea15a992250427a3bc6e8d7e161b8153e2e1bf 100644 (file)
@@ -2,6 +2,7 @@
 authors = ["The Rust Project Developers"]
 name = "rustc_target"
 version = "0.0.0"
+edition = "2018"
 
 [lib]
 name = "rustc_target"
index 9f9bba14b963e8428ffc225606fdf2fc40a470eb..f50ec6c2e7e3aa2d270374bcae9e41a01c0bd848 100644 (file)
@@ -1,5 +1,5 @@
-use abi::call::{FnType, ArgType, Reg, RegKind, Uniform};
-use abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
+use crate::abi::call::{FnType, ArgType, Reg, RegKind, Uniform};
+use crate::abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
 
 fn is_homogeneous_aggregate<'a, Ty, C>(cx: &C, arg: &mut ArgType<'a, Ty>)
                                      -> Option<Uniform>
index ea9d4172cbc2329e069897a9ed24c36be0a0bb7b..6bfd1f4387385252428aede04aaf43de8dc6fda5 100644 (file)
@@ -1,5 +1,5 @@
-use abi::call::{ArgType, FnType, };
-use abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
+use crate::abi::call::{ArgType, FnType, };
+use crate::abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
 
 fn classify_ret_ty<'a, Ty, C>(_cx: &C, ret: &mut ArgType<'a, Ty>)
   where Ty: TyLayoutMethods<'a, C> + Copy,
index 228dd36216158976b1926b894f7aca7d1ca95da9..52d7f3ac3dcbf5363b2e9c09de79ad2284150dd0 100644 (file)
@@ -1,6 +1,6 @@
-use abi::call::{Conv, FnType, ArgType, Reg, RegKind, Uniform};
-use abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
-use spec::HasTargetSpec;
+use crate::abi::call::{Conv, FnType, ArgType, Reg, RegKind, Uniform};
+use crate::abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
+use crate::spec::HasTargetSpec;
 
 fn is_homogeneous_aggregate<'a, Ty, C>(cx: &C, arg: &mut ArgType<'a, Ty>)
                                      -> Option<Uniform>
index 85444500c5e11752e13d4653fb0b7ed8fa0d74a7..92c86372a86f331c5b7a0ab137958e1996fe9b1f 100644 (file)
@@ -1,5 +1,5 @@
-use abi::call::{FnType, ArgType, Uniform};
-use abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
+use crate::abi::call::{FnType, ArgType, Uniform};
+use crate::abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
 
 // Data layout: e-p:32:32-i64:64-v128:32:128-n32-S128
 
@@ -26,7 +26,7 @@ fn classify_ret_ty<'a, Ty, C>(cx: &C, ret: &mut ArgType<'a, Ty>)
     }
 }
 
-fn classify_arg_ty<Ty>(arg: &mut ArgType<Ty>) {
+fn classify_arg_ty<Ty>(arg: &mut ArgType<'_, Ty>) {
     if arg.layout.is_aggregate() {
         arg.make_indirect_byval();
     }
index d538a8068ac4a16a392e79e43adaa1011022e6d9..db8c915cdb4bdb4c490b87ed30f0c1884163e611 100644 (file)
@@ -1,8 +1,8 @@
 #![allow(non_upper_case_globals)]
 
-use abi::call::{FnType, ArgType};
+use crate::abi::call::{FnType, ArgType};
 
-fn classify_ret_ty<Ty>(ret: &mut ArgType<Ty>) {
+fn classify_ret_ty<Ty>(ret: &mut ArgType<'_, Ty>) {
     if ret.layout.is_aggregate() && ret.layout.size.bits() > 64 {
         ret.make_indirect();
     } else {
@@ -10,7 +10,7 @@ fn classify_ret_ty<Ty>(ret: &mut ArgType<Ty>) {
     }
 }
 
-fn classify_arg_ty<Ty>(arg: &mut ArgType<Ty>) {
+fn classify_arg_ty<Ty>(arg: &mut ArgType<'_, Ty>) {
     if arg.layout.is_aggregate() && arg.layout.size.bits() > 64 {
         arg.make_indirect();
     } else {
@@ -18,7 +18,7 @@ fn classify_arg_ty<Ty>(arg: &mut ArgType<Ty>) {
     }
 }
 
-pub fn compute_abi_info<Ty>(fty: &mut FnType<Ty>) {
+pub fn compute_abi_info<Ty>(fty: &mut FnType<'_,Ty>) {
     if !fty.ret.is_ignore() {
         classify_ret_ty(&mut fty.ret);
     }
index 2335bfbb5b87bf158f84ac8970998683976f21e0..d496abf8e8b286c1c7d1d278fac38d73bcb7bb73 100644 (file)
@@ -1,7 +1,7 @@
-use abi::call::{ArgType, FnType, Reg, Uniform};
-use abi::{HasDataLayout, LayoutOf, Size, TyLayoutMethods};
+use crate::abi::call::{ArgType, FnType, Reg, Uniform};
+use crate::abi::{HasDataLayout, LayoutOf, Size, TyLayoutMethods};
 
-fn classify_ret_ty<'a, Ty, C>(cx: &C, ret: &mut ArgType<Ty>, offset: &mut Size)
+fn classify_ret_ty<'a, Ty, C>(cx: &C, ret: &mut ArgType<'_, Ty>, offset: &mut Size)
     where Ty: TyLayoutMethods<'a, C>, C: LayoutOf<Ty = Ty> + HasDataLayout
 {
     if !ret.layout.is_aggregate() {
@@ -12,7 +12,7 @@ fn classify_ret_ty<'a, Ty, C>(cx: &C, ret: &mut ArgType<Ty>, offset: &mut Size)
     }
 }
 
-fn classify_arg_ty<'a, Ty, C>(cx: &C, arg: &mut ArgType<Ty>, offset: &mut Size)
+fn classify_arg_ty<'a, Ty, C>(cx: &C, arg: &mut ArgType<'_, Ty>, offset: &mut Size)
     where Ty: TyLayoutMethods<'a, C>, C: LayoutOf<Ty = Ty> + HasDataLayout
 {
     let dl = cx.data_layout();
@@ -34,7 +34,7 @@ fn classify_arg_ty<'a, Ty, C>(cx: &C, arg: &mut ArgType<Ty>, offset: &mut Size)
     *offset = offset.align_to(align) + size.align_to(align);
 }
 
-pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<Ty>)
+pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'_, Ty>)
     where Ty: TyLayoutMethods<'a, C>, C: LayoutOf<Ty = Ty> + HasDataLayout
 {
     let mut offset = Size::ZERO;
index 6f3e6494a4ae8f6cb8753cb328aca5eace174651..5ba05c6bcde377c915f75815dc8a05ef3552f5c2 100644 (file)
@@ -1,7 +1,7 @@
-use abi::call::{ArgAttribute, ArgType, CastTarget, FnType, PassMode, Reg, RegKind, Uniform};
-use abi::{self, HasDataLayout, LayoutOf, Size, TyLayout, TyLayoutMethods};
+use crate::abi::call::{ArgAttribute, ArgType, CastTarget, FnType, PassMode, Reg, RegKind, Uniform};
+use crate::abi::{self, HasDataLayout, LayoutOf, Size, TyLayout, TyLayoutMethods};
 
-fn extend_integer_width_mips<Ty>(arg: &mut ArgType<Ty>, bits: u64) {
+fn extend_integer_width_mips<Ty>(arg: &mut ArgType<'_, Ty>, bits: u64) {
     // Always sign extend u32 values on 64-bit mips
     if let abi::Abi::Scalar(ref scalar) = arg.layout.abi {
         if let abi::Int(i, signed) = scalar.value {
index 0d50439c67ec08495698a6b6b5807c8d7f8c6fa3..839c9a857e64aaa1a8cfce5dd8e130b55fc8bc2c 100644 (file)
@@ -1,6 +1,6 @@
-use abi::{self, Abi, Align, FieldPlacement, Size};
-use abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
-use spec::HasTargetSpec;
+use crate::abi::{self, Abi, Align, FieldPlacement, Size};
+use crate::abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
+use crate::spec::{self, HasTargetSpec};
 
 mod aarch64;
 mod amdgpu;
@@ -42,13 +42,13 @@ pub enum PassMode {
 
 // Hack to disable non_upper_case_globals only for the bitflags! and not for the rest
 // of this module
-pub use self::attr_impl::ArgAttribute;
+pub use attr_impl::ArgAttribute;
 
 #[allow(non_upper_case_globals)]
 #[allow(unused)]
 mod attr_impl {
     // The subset of llvm::Attribute needed for arguments, packed into a bitfield.
-    bitflags! {
+    bitflags::bitflags! {
         #[derive(Default)]
         pub struct ArgAttribute: u16 {
             const ByVal     = 1 << 0;
@@ -526,22 +526,22 @@ pub struct FnType<'a, Ty> {
 }
 
 impl<'a, Ty> FnType<'a, Ty> {
-    pub fn adjust_for_cabi<C>(&mut self, cx: &C, abi: ::spec::abi::Abi) -> Result<(), String>
+    pub fn adjust_for_cabi<C>(&mut self, cx: &C, abi: spec::abi::Abi) -> Result<(), String>
         where Ty: TyLayoutMethods<'a, C> + Copy,
               C: LayoutOf<Ty = Ty, TyLayout = TyLayout<'a, Ty>> + HasDataLayout + HasTargetSpec
     {
         match &cx.target_spec().arch[..] {
             "x86" => {
-                let flavor = if abi == ::spec::abi::Abi::Fastcall {
+                let flavor = if abi == spec::abi::Abi::Fastcall {
                     x86::Flavor::Fastcall
                 } else {
                     x86::Flavor::General
                 };
                 x86::compute_abi_info(cx, self, flavor);
             },
-            "x86_64" => if abi == ::spec::abi::Abi::SysV64 {
+            "x86_64" => if abi == spec::abi::Abi::SysV64 {
                 x86_64::compute_abi_info(cx, self);
-            } else if abi == ::spec::abi::Abi::Win64 || cx.target_spec().options.is_like_windows {
+            } else if abi == spec::abi::Abi::Win64 || cx.target_spec().options.is_like_windows {
                 x86_win64::compute_abi_info(self);
             } else {
                 x86_64::compute_abi_info(cx, self);
index d8ba37db53d4da4b83cd2ba3d1c4b64d52ecceeb..7ae1116cba847fcfb58929bb47cf0b4d2532fa74 100644 (file)
@@ -1,7 +1,7 @@
 // Reference: MSP430 Embedded Application Binary Interface
 // http://www.ti.com/lit/an/slaa534/slaa534.pdf
 
-use abi::call::{ArgType, FnType};
+use crate::abi::call::{ArgType, FnType};
 
 // 3.5 Structures or Unions Passed and Returned by Reference
 //
@@ -9,7 +9,7 @@
 // returned by reference. To pass a structure or union by reference, the caller
 // places its address in the appropriate location: either in a register or on
 // the stack, according to its position in the argument list. (..)"
-fn classify_ret_ty<Ty>(ret: &mut ArgType<Ty>) {
+fn classify_ret_ty<Ty>(ret: &mut ArgType<'_, Ty>) {
     if ret.layout.is_aggregate() && ret.layout.size.bits() > 32 {
         ret.make_indirect();
     } else {
@@ -17,7 +17,7 @@ fn classify_ret_ty<Ty>(ret: &mut ArgType<Ty>) {
     }
 }
 
-fn classify_arg_ty<Ty>(arg: &mut ArgType<Ty>) {
+fn classify_arg_ty<Ty>(arg: &mut ArgType<'_, Ty>) {
     if arg.layout.is_aggregate() && arg.layout.size.bits() > 32 {
         arg.make_indirect();
     } else {
@@ -25,7 +25,7 @@ fn classify_arg_ty<Ty>(arg: &mut ArgType<Ty>) {
     }
 }
 
-pub fn compute_abi_info<Ty>(fty: &mut FnType<Ty>) {
+pub fn compute_abi_info<Ty>(fty: &mut FnType<'_, Ty>) {
     if !fty.ret.is_ignore() {
         classify_ret_ty(&mut fty.ret);
     }
index 4cf0f11eb1e4a032ea496e77d99ab45c09675d5b..4722249f73007148c2b54d262ec33500b0289af5 100644 (file)
@@ -1,9 +1,9 @@
 // Reference: PTX Writer's Guide to Interoperability
 // http://docs.nvidia.com/cuda/ptx-writers-guide-to-interoperability
 
-use abi::call::{ArgType, FnType};
+use crate::abi::call::{ArgType, FnType};
 
-fn classify_ret_ty<Ty>(ret: &mut ArgType<Ty>) {
+fn classify_ret_ty<Ty>(ret: &mut ArgType<'_, Ty>) {
     if ret.layout.is_aggregate() && ret.layout.size.bits() > 32 {
         ret.make_indirect();
     } else {
@@ -11,7 +11,7 @@ fn classify_ret_ty<Ty>(ret: &mut ArgType<Ty>) {
     }
 }
 
-fn classify_arg_ty<Ty>(arg: &mut ArgType<Ty>) {
+fn classify_arg_ty<Ty>(arg: &mut ArgType<'_, Ty>) {
     if arg.layout.is_aggregate() && arg.layout.size.bits() > 32 {
         arg.make_indirect();
     } else {
@@ -19,7 +19,7 @@ fn classify_arg_ty<Ty>(arg: &mut ArgType<Ty>) {
     }
 }
 
-pub fn compute_abi_info<Ty>(fty: &mut FnType<Ty>) {
+pub fn compute_abi_info<Ty>(fty: &mut FnType<'_, Ty>) {
     if !fty.ret.is_ignore() {
         classify_ret_ty(&mut fty.ret);
     }
index 8ccc77598c90a399a8982bb4aa71e4cfa80bfd29..51c00ae007c3c8244d68fa213cc0fcf4a2266177 100644 (file)
@@ -1,9 +1,9 @@
 // Reference: PTX Writer's Guide to Interoperability
 // http://docs.nvidia.com/cuda/ptx-writers-guide-to-interoperability
 
-use abi::call::{ArgType, FnType};
+use crate::abi::call::{ArgType, FnType};
 
-fn classify_ret_ty<Ty>(ret: &mut ArgType<Ty>) {
+fn classify_ret_ty<Ty>(ret: &mut ArgType<'_, Ty>) {
     if ret.layout.is_aggregate() && ret.layout.size.bits() > 64 {
         ret.make_indirect();
     } else {
@@ -11,7 +11,7 @@ fn classify_ret_ty<Ty>(ret: &mut ArgType<Ty>) {
     }
 }
 
-fn classify_arg_ty<Ty>(arg: &mut ArgType<Ty>) {
+fn classify_arg_ty<Ty>(arg: &mut ArgType<'_, Ty>) {
     if arg.layout.is_aggregate() && arg.layout.size.bits() > 64 {
         arg.make_indirect();
     } else {
@@ -19,7 +19,7 @@ fn classify_arg_ty<Ty>(arg: &mut ArgType<Ty>) {
     }
 }
 
-pub fn compute_abi_info<Ty>(fty: &mut FnType<Ty>) {
+pub fn compute_abi_info<Ty>(fty: &mut FnType<'_, Ty>) {
     if !fty.ret.is_ignore() {
         classify_ret_ty(&mut fty.ret);
     }
index 2335bfbb5b87bf158f84ac8970998683976f21e0..d496abf8e8b286c1c7d1d278fac38d73bcb7bb73 100644 (file)
@@ -1,7 +1,7 @@
-use abi::call::{ArgType, FnType, Reg, Uniform};
-use abi::{HasDataLayout, LayoutOf, Size, TyLayoutMethods};
+use crate::abi::call::{ArgType, FnType, Reg, Uniform};
+use crate::abi::{HasDataLayout, LayoutOf, Size, TyLayoutMethods};
 
-fn classify_ret_ty<'a, Ty, C>(cx: &C, ret: &mut ArgType<Ty>, offset: &mut Size)
+fn classify_ret_ty<'a, Ty, C>(cx: &C, ret: &mut ArgType<'_, Ty>, offset: &mut Size)
     where Ty: TyLayoutMethods<'a, C>, C: LayoutOf<Ty = Ty> + HasDataLayout
 {
     if !ret.layout.is_aggregate() {
@@ -12,7 +12,7 @@ fn classify_ret_ty<'a, Ty, C>(cx: &C, ret: &mut ArgType<Ty>, offset: &mut Size)
     }
 }
 
-fn classify_arg_ty<'a, Ty, C>(cx: &C, arg: &mut ArgType<Ty>, offset: &mut Size)
+fn classify_arg_ty<'a, Ty, C>(cx: &C, arg: &mut ArgType<'_, Ty>, offset: &mut Size)
     where Ty: TyLayoutMethods<'a, C>, C: LayoutOf<Ty = Ty> + HasDataLayout
 {
     let dl = cx.data_layout();
@@ -34,7 +34,7 @@ fn classify_arg_ty<'a, Ty, C>(cx: &C, arg: &mut ArgType<Ty>, offset: &mut Size)
     *offset = offset.align_to(align) + size.align_to(align);
 }
 
-pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<Ty>)
+pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'_, Ty>)
     where Ty: TyLayoutMethods<'a, C>, C: LayoutOf<Ty = Ty> + HasDataLayout
 {
     let mut offset = Size::ZERO;
index 305a2d4225056352f776f2df481e76efe8fe8dfc..a9683104d164e5b7e5d410ce7287127fb8db8193 100644 (file)
@@ -2,16 +2,16 @@
 // Alignment of 128 bit types is not currently handled, this will
 // need to be fixed when PowerPC vector support is added.
 
-use abi::call::{FnType, ArgType, Reg, RegKind, Uniform};
-use abi::{Endian, HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
-use spec::HasTargetSpec;
+use crate::abi::call::{FnType, ArgType, Reg, RegKind, Uniform};
+use crate::abi::{Endian, HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
+use crate::spec::HasTargetSpec;
 
 #[derive(Debug, Clone, Copy, PartialEq)]
 enum ABI {
     ELFv1, // original ABI used for powerpc64 (big-endian)
     ELFv2, // newer ABI used for powerpc64le and musl (both endians)
 }
-use self::ABI::*;
+use ABI::*;
 
 fn is_homogeneous_aggregate<'a, Ty, C>(cx: &C, arg: &mut ArgType<'a, Ty>, abi: ABI)
                                        -> Option<Uniform>
index 4950bcd3330aa03b4e4c4a8911d77bb9284d837c..ba82e49ddb03ef75576dc301bd90d39f921de484 100644 (file)
@@ -1,9 +1,9 @@
 // Reference: RISC-V ELF psABI specification
 // https://github.com/riscv/riscv-elf-psabi-doc
 
-use abi::call::{ArgType, FnType};
+use crate::abi::call::{ArgType, FnType};
 
-fn classify_ret_ty<Ty>(arg: &mut ArgType<Ty>, xlen: u64) {
+fn classify_ret_ty<Ty>(arg: &mut ArgType<'_, Ty>, xlen: u64) {
     // "Scalars wider than 2✕XLEN are passed by reference and are replaced in
     // the argument list with the address."
     // "Aggregates larger than 2✕XLEN bits are passed by reference and are
@@ -19,7 +19,7 @@ fn classify_ret_ty<Ty>(arg: &mut ArgType<Ty>, xlen: u64) {
     arg.extend_integer_width_to(xlen); // this method only affects integer scalars
 }
 
-fn classify_arg_ty<Ty>(arg: &mut ArgType<Ty>, xlen: u64) {
+fn classify_arg_ty<Ty>(arg: &mut ArgType<'_, Ty>, xlen: u64) {
     // "Scalars wider than 2✕XLEN are passed by reference and are replaced in
     // the argument list with the address."
     // "Aggregates larger than 2✕XLEN bits are passed by reference and are
@@ -35,7 +35,7 @@ fn classify_arg_ty<Ty>(arg: &mut ArgType<Ty>, xlen: u64) {
     arg.extend_integer_width_to(xlen); // this method only affects integer scalars
 }
 
-pub fn compute_abi_info<Ty>(fty: &mut FnType<Ty>, xlen: u64) {
+pub fn compute_abi_info<Ty>(fty: &mut FnType<'_, Ty>, xlen: u64) {
     if !fty.ret.is_ignore() {
         classify_ret_ty(&mut fty.ret, xlen);
     }
index 954c37fee42ddebe8932a870d2dfa42506e6c129..c2717b1bcb815c91025e2620965d6805b4ad7330 100644 (file)
@@ -1,10 +1,10 @@
 // FIXME: The assumes we're using the non-vector ABI, i.e., compiling
 // for a pre-z13 machine or using -mno-vx.
 
-use abi::call::{FnType, ArgType, Reg};
-use abi::{self, HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
+use crate::abi::call::{FnType, ArgType, Reg};
+use crate::abi::{self, HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
 
-fn classify_ret_ty<'a, Ty, C>(ret: &mut ArgType<Ty>)
+fn classify_ret_ty<'a, Ty, C>(ret: &mut ArgType<'_, Ty>)
     where Ty: TyLayoutMethods<'a, C>, C: LayoutOf<Ty = Ty> + HasDataLayout
 {
     if !ret.layout.is_aggregate() && ret.layout.size.bits() <= 64 {
index 2335bfbb5b87bf158f84ac8970998683976f21e0..d496abf8e8b286c1c7d1d278fac38d73bcb7bb73 100644 (file)
@@ -1,7 +1,7 @@
-use abi::call::{ArgType, FnType, Reg, Uniform};
-use abi::{HasDataLayout, LayoutOf, Size, TyLayoutMethods};
+use crate::abi::call::{ArgType, FnType, Reg, Uniform};
+use crate::abi::{HasDataLayout, LayoutOf, Size, TyLayoutMethods};
 
-fn classify_ret_ty<'a, Ty, C>(cx: &C, ret: &mut ArgType<Ty>, offset: &mut Size)
+fn classify_ret_ty<'a, Ty, C>(cx: &C, ret: &mut ArgType<'_, Ty>, offset: &mut Size)
     where Ty: TyLayoutMethods<'a, C>, C: LayoutOf<Ty = Ty> + HasDataLayout
 {
     if !ret.layout.is_aggregate() {
@@ -12,7 +12,7 @@ fn classify_ret_ty<'a, Ty, C>(cx: &C, ret: &mut ArgType<Ty>, offset: &mut Size)
     }
 }
 
-fn classify_arg_ty<'a, Ty, C>(cx: &C, arg: &mut ArgType<Ty>, offset: &mut Size)
+fn classify_arg_ty<'a, Ty, C>(cx: &C, arg: &mut ArgType<'_, Ty>, offset: &mut Size)
     where Ty: TyLayoutMethods<'a, C>, C: LayoutOf<Ty = Ty> + HasDataLayout
 {
     let dl = cx.data_layout();
@@ -34,7 +34,7 @@ fn classify_arg_ty<'a, Ty, C>(cx: &C, arg: &mut ArgType<Ty>, offset: &mut Size)
     *offset = offset.align_to(align) + size.align_to(align);
 }
 
-pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<Ty>)
+pub fn compute_abi_info<'a, Ty, C>(cx: &C, fty: &mut FnType<'_, Ty>)
     where Ty: TyLayoutMethods<'a, C>, C: LayoutOf<Ty = Ty> + HasDataLayout
 {
     let mut offset = Size::ZERO;
index 150b48a8d02550d06aa0f7ea5377dd9ee8fa4a4d..d8930a875efbce9048e7ed79221f0d46839c20eb 100644 (file)
@@ -1,7 +1,7 @@
 // FIXME: This needs an audit for correctness and completeness.
 
-use abi::call::{FnType, ArgType, Reg, RegKind, Uniform};
-use abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
+use crate::abi::call::{FnType, ArgType, Reg, RegKind, Uniform};
+use crate::abi::{HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
 
 fn is_homogeneous_aggregate<'a, Ty, C>(cx: &C, arg: &mut ArgType<'a, Ty>)
                                      -> Option<Uniform>
index 78f43f8b508b38c2e29e7e97dbec006e9d3e7921..1fdcbb8e39bdff0397f0aaa6a3599d6dcc301f3c 100644 (file)
@@ -1,14 +1,14 @@
-use abi::call::{FnType, ArgType};
+use crate::abi::call::{FnType, ArgType};
 
-fn classify_ret_ty<Ty>(ret: &mut ArgType<Ty>) {
+fn classify_ret_ty<Ty>(ret: &mut ArgType<'_, Ty>) {
     ret.extend_integer_width_to(32);
 }
 
-fn classify_arg_ty<Ty>(arg: &mut ArgType<Ty>) {
+fn classify_arg_ty<Ty>(arg: &mut ArgType<'_, Ty>) {
     arg.extend_integer_width_to(32);
 }
 
-pub fn compute_abi_info<Ty>(fty: &mut FnType<Ty>) {
+pub fn compute_abi_info<Ty>(fty: &mut FnType<'_, Ty>) {
     if !fty.ret.is_ignore() {
         classify_ret_ty(&mut fty.ret);
     }
index 648a4b5bb9d79cb1ceb96000145f9d3ab3363c0d..2e809571ab18b60fc87e40dc08961133f9133366 100644 (file)
@@ -1,6 +1,6 @@
-use abi::call::{ArgAttribute, FnType, PassMode, Reg, RegKind};
-use abi::{self, HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
-use spec::HasTargetSpec;
+use crate::abi::call::{ArgAttribute, FnType, PassMode, Reg, RegKind};
+use crate::abi::{self, HasDataLayout, LayoutOf, TyLayout, TyLayoutMethods};
+use crate::spec::HasTargetSpec;
 
 #[derive(PartialEq)]
 pub enum Flavor {
index 9d8cc19aac524e92d0300cef8e4e49725eeabaa5..680e529b108e0fed1ba62c1ab345692811b22eb1 100644 (file)
@@ -1,8 +1,8 @@
 // The classification code for the x86_64 ABI is taken from the clay language
 // https://github.com/jckarter/clay/blob/master/compiler/src/externals.cpp
 
-use abi::call::{ArgType, CastTarget, FnType, Reg, RegKind};
-use abi::{self, Abi, HasDataLayout, LayoutOf, Size, TyLayout, TyLayoutMethods};
+use crate::abi::call::{ArgType, CastTarget, FnType, Reg, RegKind};
+use crate::abi::{self, Abi, HasDataLayout, LayoutOf, Size, TyLayout, TyLayoutMethods};
 
 /// Classification of "eightbyte" components.
 // N.B., the order of the variants is from general to specific,
index c583f7a0a2a24357bd16824d56e8a1d800cf6003..ebdeb63150a46960c39621211197189958a7eac4 100644 (file)
@@ -1,10 +1,10 @@
-use abi::call::{ArgType, FnType, Reg};
-use abi::Abi;
+use crate::abi::call::{ArgType, FnType, Reg};
+use crate::abi::Abi;
 
 // Win64 ABI: http://msdn.microsoft.com/en-us/library/zthk2dkh.aspx
 
-pub fn compute_abi_info<Ty>(fty: &mut FnType<Ty>) {
-    let fixup = |a: &mut ArgType<Ty>| {
+pub fn compute_abi_info<Ty>(fty: &mut FnType<'_, Ty>) {
+    let fixup = |a: &mut ArgType<'_, Ty>| {
         match a.layout.abi {
             Abi::Uninhabited => {}
             Abi::ScalarPair(..) |
index 3f95e666535be45063fb56468b7a5ec6ee730d70..bb194d5bb1285095de6fb88332daea6aee6f9077 100644 (file)
@@ -1,7 +1,7 @@
-pub use self::Integer::*;
-pub use self::Primitive::*;
+pub use Integer::*;
+pub use Primitive::*;
 
-use spec::Target;
+use crate::spec::Target;
 
 use std::fmt;
 use std::ops::{Add, Deref, Sub, Mul, AddAssign, Range, RangeInclusive};
@@ -533,13 +533,13 @@ pub enum FloatTy {
 }
 
 impl fmt::Debug for FloatTy {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         fmt::Display::fmt(self, f)
     }
 }
 
 impl fmt::Display for FloatTy {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(f, "{}", self.ty_to_string())
     }
 }
index 8e9d0851af162d83de4f668746a38cb081d0f0b0..e831eb41410bbaa114363c9e3335683710b8b4f6 100644 (file)
 #![feature(slice_patterns)]
 #![feature(step_trait)]
 
-#[macro_use]
-extern crate bitflags;
-extern crate serialize;
+#![deny(rust_2018_idioms)]
+
 #[macro_use] extern crate log;
 
+#[allow(unused_extern_crates)]
 extern crate serialize as rustc_serialize; // used by deriving
 
 // See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
index 2210fd1e9e7c947cff4a0dc7b2f8db131f9c4f96..8bdc08c788d01a1e0c04aa8f00b6296e09428a1f 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 use super::apple_ios_base::{opts, Arch};
 
 pub fn target() -> TargetResult {
index e39a1c2e1068c8ad1a4363b81c174ffddeda80f8..308954d56f8bf4b9c67f00b5bd5a74f5511e32ee 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LldFlavor, LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LldFlavor, LinkerFlavor, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::fuchsia_base::opts();
index c05964295d37af0fd59ab4d7d6639245866b7bb9..65160f6231e8c1216a72fa369b05149be4908dac 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 
 // See https://developer.android.com/ndk/guides/abis.html#arm64-v8a
 // for target ABI requirements.
index b33430b59e8f9d5e466228578264d85275ad5731..1aee381d604c3d186792fe536f0bef6360551b32 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult, PanicStrategy};
+use crate::spec::{LinkerFlavor, Target, TargetResult, PanicStrategy};
 
 pub fn target() -> TargetResult {
     let mut base = super::windows_msvc_base::opts();
index ac3345ce3f214bd6405ba21d6da9e37e9a737f84..7141954306769a6fcb6155ccf37241c7d70ac5a7 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::cloudabi_base::opts();
index 1fb0a2bcf7c22618bf720526befdfa19107040e1..36860649c53ad63ff5ea08ea54b409659232a49c 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::freebsd_base::opts();
index 26006d0060d49a6eb54869fa821d14150e302039..7b020605102b1f8d7e55a048e9a38369d769668e 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::hermit_base::opts();
index d30d927b6dd3d4e4b05b90bb5c166cce71874863..e772d8b532cb077229ec5298dc37f5b13374a78e 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::linux_base::opts();
index 258725fed15bec800341987ae9fcdd3809222f63..8123ee82ed524ff133144a77f4b591210fd82cbb 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::linux_musl_base::opts();
index 10aef8f923d4cd001b92721f7b3b28f13430c1a8..47ae08ade9a6be4689b2717708d2adb5ffe79cee 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::netbsd_base::opts();
index 815e11a919c0fb2f20423506fa80a9c8d74fba16..c9cd64c3a84af3a88011f83f413238f2b0e27f33 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::openbsd_base::opts();
index 46606e707d7575028a01defd7caf4d508a761fa4..c9c41f10922401785ac0f1f8f2aac30dc004abba 100644 (file)
@@ -96,7 +96,7 @@ pub fn generic(self) -> bool {
 }
 
 impl fmt::Display for Abi {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(f, "\"{}\"", self.name())
     }
 }
index a8f8ad3185f0dce312949aa1fe69142a422cd29e..684c059b414827f4b75ba7b186c3f0465ba2048a 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, TargetOptions};
+use crate::spec::{LinkerFlavor, TargetOptions};
 
 pub fn opts() -> TargetOptions {
     let mut base = super::linux_base::opts();
index a80d1904a7471d92b0a52abd810fe7cb95cb566f..c21f7f38ca5a3767572b87961a4d8b64b9d2abad 100644 (file)
@@ -1,6 +1,6 @@
 use std::env;
 
-use spec::{LinkArgs, TargetOptions};
+use crate::spec::{LinkArgs, TargetOptions};
 
 pub fn opts() -> TargetOptions {
     // ELF TLS is only available in macOS 10.7+. If you try to compile for 10.6
index 72346ab1f34b6a7ba41d884332490266922d4f49..3068ed8d206cdc236bf01fef36b27d43308f8d70 100644 (file)
@@ -1,8 +1,8 @@
 use std::io;
 use std::process::Command;
-use spec::{LinkArgs, LinkerFlavor, TargetOptions};
+use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions};
 
-use self::Arch::*;
+use Arch::*;
 
 #[allow(non_camel_case_types)]
 #[derive(Copy, Clone)]
index 1d51d60c8f258783890a0ab440c5e3835aac96a1..77e7bfac62d58596fb7046727f8c80e4d7b8828b 100644 (file)
@@ -1,4 +1,4 @@
-use spec::abi::Abi;
+use crate::spec::abi::Abi;
 
 // All the calling conventions trigger an assertion(Unsupported calling convention) in llvm on arm
 pub fn abi_blacklist() -> Vec<Abi> {
index 5e4bebfa1c1a42495ec0044550f1a42e9ce4277e..bb066dc9ad833fb0d1026f9ad267fe67d170e1ce 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::android_base::opts();
index 0f891dacc6dbf157bfd0d648b4ecc9a498629c16..f291818ba80f502fb98e3aa93030df7e8da9b415 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::linux_base::opts();
index 5503bf326cd7b87f6ccef8e381a76fe3158d7174..32b509d9721efa6e503021d01acca0080ed87b60 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::linux_base::opts();
index c2162beba26e842cf498fd83f248494801b3623c..7637577e7e848c1c3dae5478e41db035c76a0db0 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::linux_musl_base::opts();
index b3f00331b3c9efc04b61369007f228a9097483e1..9def151b3ef2910ddf406253fe94be641b0b85c5 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::linux_musl_base::opts();
index cd41ffbab4d9cbd37a4c01ec441736e4d7cc0fec..86c62daa6180a018e97064b6dd058a32de9124ba 100644 (file)
@@ -1,7 +1,7 @@
 // Targets the Big endian Cortex-R4/R5 processor (ARMv7-R)
 
 use std::default::Default;
-use spec::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     Ok(Target {
index 05b12dd28bacd29c629a76f41118a54d6e2599f1..50ee76414ef9a4e122ab28f1b350285ff605fe91 100644 (file)
@@ -1,7 +1,7 @@
 // Targets the Cortex-R4F/R5F processor (ARMv7-R)
 
 use std::default::Default;
-use spec::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     Ok(Target {
index 7fe021e5327b906d92506b61c846ce4f4cbece18..7cd4b14cdebc8b31d309cb764474c18eb7b9ee8d 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     let base = super::linux_base::opts();
index c85a80f6e8a4cc6d10e698552567472128be4a5a..15f614827718b29b4b8375db5334d86180c5e6ea 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     let base = super::linux_base::opts();
index dce767898c06b966dc9459d7cc159665743b1259..74915b942ea4f5e8f0a093f802a5f4ace67f4dfe 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     let base = super::linux_musl_base::opts();
index 95cc41e6c98fb4508d953009c58b9f0e9e8c23af..e460b6c574a26463fed30c436972ae945727a903 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::netbsd_base::opts();
index 98018215c805a52e2f9d05eb18bb57bd9424e7d7..2052d17403dfde9a6104338d8f2bbe142a9be539 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 use super::apple_ios_base::{opts, Arch};
 
 pub fn target() -> TargetResult {
index 65c3c7f7057abe21f8872f3c87373cfe8c0c928f..92f1a55e024d7f57509d0135c1d9eec0b1d30709 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 
 // This target if is for the baseline of the Android v7a ABI
 // in thumb mode. It's named armv7-* instead of thumbv7-*
index fa43879dccab84832867ea8b15a83c7c46659ce8..a6c7fb537c7854b7accb11788b0673a4adfd8fc0 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::cloudabi_base::opts();
index 864c59b81844ee198f7eee3035aea2f91dad4a75..f16215433c766211adfd4bc3f45ca016ceeb4067 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 
 // This target is for glibc Linux on ARMv7 without NEON or
 // thumb-mode. See the thumbv7neon variant for enabling both.
index ae0cb2c08b4309c3c83012e6a5e10a9e5bfd2483..45a26966b716b905161df3d43fb8a4c1d60034ad 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 
 // This target is for musl Linux on ARMv7 without thumb-mode or NEON.
 
index f9e416fd06e92d158e9d86c129e68ba7cf250a69..44e2636e9188ed6aa47e92b64206c7d2c90fc60c 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     let base = super::netbsd_base::opts();
index 38d115bc85e7f2f4df2d476d94020c07cd1fdfb7..19d332467dec50d73f8dad81fc894e087d4d29a5 100644 (file)
@@ -1,7 +1,7 @@
 // Targets the Little-endian Cortex-R4/R5 processor (ARMv7-R)
 
 use std::default::Default;
-use spec::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     Ok(Target {
index cb707f7183a49984b61abf2e18d8a0b105aadada..06ef9f3ec4e37892480acaeb4ad3fd6a5f80ac19 100644 (file)
@@ -1,7 +1,7 @@
 // Targets the Little-endian Cortex-R4F/R5F processor (ARMv7-R)
 
 use std::default::Default;
-use spec::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     Ok(Target {
index 6d9635b308e905767d41ba4f261b25652bb1b853..29e290285e4a9ecc4472fa29b8af466c6b3ae680 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 use super::apple_ios_base::{opts, Arch};
 
 pub fn target() -> TargetResult {
index 3b6985fa4c8260260143c825e987da9e2739daa2..9b34119fc00c9f9484f7aed38989d6b20003d410 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{TargetOptions, RelroLevel};
+use crate::spec::{TargetOptions, RelroLevel};
 use std::default::Default;
 
 pub fn opts() -> TargetOptions {
index 145de0ebe69955dbe2cc4d37f1c11a5be31713a4..a34122d3e0fe29a1811371a608b507c522782749 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkArgs, LinkerFlavor, TargetOptions, RelroLevel};
+use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions, RelroLevel};
 
 pub fn opts() -> TargetOptions {
     let mut args = LinkArgs::new();
index 6ce2912da75cfc1be1ad91553e3868dfbdfe26e3..766030e8015d09942a647467accd358fd92dc0c2 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkArgs, LinkerFlavor, TargetOptions, RelroLevel};
+use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions, RelroLevel};
 use std::default::Default;
 
 pub fn opts() -> TargetOptions {
index 47316f77e634e366b23321b2e59ef87143e286e4..51f030f59084dc8863d308900a58ce02a667df9f 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkArgs, LinkerFlavor, TargetOptions, RelroLevel};
+use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions, RelroLevel};
 use std::default::Default;
 
 pub fn opts() -> TargetOptions {
index 5d94f308410a63fb4a4af31fae437c7178664704..4e4f2fa0cf34c9178c3dc97794f8471b3af19086 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LldFlavor, LinkArgs, LinkerFlavor, TargetOptions};
+use crate::spec::{LldFlavor, LinkArgs, LinkerFlavor, TargetOptions};
 use std::default::Default;
 
 pub fn opts() -> TargetOptions {
index 00c6bd40dc584295d23fdd7a07f00b860a8c681f..d07106270530666271341964fae157fc183aa7a9 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{TargetOptions, RelroLevel};
+use crate::spec::{TargetOptions, RelroLevel};
 use std::default::Default;
 
 pub fn opts() -> TargetOptions {
index d7d8562e055d8c808451f49b83903dbee50a0e46..ee753393ddb3d59bd84287015b2a95b4a9c347f7 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkArgs, LinkerFlavor, PanicStrategy, TargetOptions};
+use crate::spec::{LinkArgs, LinkerFlavor, PanicStrategy, TargetOptions};
 use std::default::Default;
 
 pub fn opts() -> TargetOptions {
index d0e317630013b4aa03c83ba63613db12b618de94..78e9cbb61ef58c10a1368a1270dc5028ccfa3c5f 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 use super::apple_ios_base::{opts, Arch};
 
 pub fn target() -> TargetResult {
index 12a7f98beff957db73ae09ba9a98ca03714d6a94..ba712aced8474b2bd28a9722e6d2b32e79a6fad4 100644 (file)
@@ -1,4 +1,4 @@
-use spec::TargetResult;
+use crate::spec::TargetResult;
 
 pub fn target() -> TargetResult {
     let mut base = super::i686_pc_windows_msvc::target()?;
index 76f6a4eba389f36344f0223993fc62d066ae387f..49f4f2cb6b999c3e595ffc54dc50836d85548cd6 100644 (file)
@@ -1,4 +1,4 @@
-use spec::TargetResult;
+use crate::spec::TargetResult;
 
 pub fn target() -> TargetResult {
     let mut base = super::i686_unknown_linux_gnu::target()?;
index 2b56fd7a7e370365ac8bd45510d3e5b463307bbf..0f2ccebd6dacefe265c8d7ff1dba1dc5ff2253ec 100644 (file)
@@ -1,4 +1,4 @@
-use spec::TargetResult;
+use crate::spec::TargetResult;
 
 pub fn target() -> TargetResult {
     let mut base = super::i686_unknown_linux_musl::target()?;
index 40d9588e463a6862f58faa908e87138187387666..c8a61296d33d2b22857969a4df6eed9f489d9f46 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::apple_base::opts();
index 5b8cb7ac55d589cd6adedc2ff998a6acd99acb8f..3f73d24ee848b90d00505b071eb909fc55816bbd 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 // See https://developer.android.com/ndk/guides/abis.html#x86
 // for target ABI requirements.
index d7bc38ca172d5f4ebc30f9f1f0aebcdbc694f346..12214a7d53119b6108d4c3cde10792c71a6594d3 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::windows_base::opts();
index f0d75ae4e9bddc09088d86190b6de33ce61adafa..1967834819ab251f7522576ee521b3b93fbeb0ed 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::windows_msvc_base::opts();
index 3a9e4246981274c6c844facad69d336c3e7d4be7..f3b40633b40073b31bf31667e319ffc1df19660a 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::cloudabi_base::opts();
index 9d71c5a82336105cbd61bf3c47bb14169bc6cf99..20315e7145c732874e916fda0256780a6721f53b 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::dragonfly_base::opts();
index 627dffa89d247b72dd0afd4aabd5abf056450843..71f05a140f3df13f513f04388b5c536724e92f02 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::freebsd_base::opts();
index 86c64ce684bb8dd75a861f5e4ed0dbe776cbd4f6..b807e4eee39a5756119e8616535d7d7e464de2f7 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::haiku_base::opts();
index ab3883283115766465d5d327e094e0eb4eb916fe..5875cbf78bfe632b011c03e0b12b8a3ef6526511 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::linux_base::opts();
index 81cbf57e577a613d86cffc991dc863b70cfe65e5..732949034e824a429880804ddd08998b85501e26 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::linux_musl_base::opts();
index 1027e240224c9b02ba20aa8c3295570114ad30cb..e8a9f29ea5f4c48f6b71a84663bfb1d4e32a74bc 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::netbsd_base::opts();
index d2bbc6bb2dbafa0d2bd9ffe5440073ab1500c3be..d7c323e0d8a8a46283238952d3705141b97861ba 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::openbsd_base::opts();
index 951005998be07efe410679a7145fffaf6fd02982..9317f053efe7050047e4f5b612099a9ec2981e97 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkArgs, LinkerFlavor, PanicStrategy, TargetOptions};
+use crate::spec::{LinkArgs, LinkerFlavor, PanicStrategy, TargetOptions};
 use std::default::Default;
 //use std::process::Command;
 
index b036bf81a754214bbc2d35e4b520393203e78c2b..195fba3915f94fee1e5b271bfb5da55ef5321393 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkArgs, LinkerFlavor, TargetOptions, RelroLevel};
+use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions, RelroLevel};
 use std::default::Default;
 
 pub fn opts() -> TargetOptions {
index 1bc90d1a73287d982f449077743ab1b5980b652d..e294e63982de45380348b7a16b97ea1214722f9a 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, TargetOptions};
+use crate::spec::{LinkerFlavor, TargetOptions};
 
 pub fn opts() -> TargetOptions {
     let mut base = super::linux_base::opts();
index 650f38702b67b88bc035421268e4db69360a12e5..3b38e64050f3b215bcdcc971de9afb247afd575c 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     Ok(Target {
index cb348d49479b93a4be242fce872ec65a28426778..0f6cd86d616d8b09232eff5a6afb2c159ca741dd 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     Ok(Target {
index 6cc3d30be1fb053acc66c7e467ed79cebaa76d04..b4d29c5fbeaf472c54fb1f34cb87550777b89ca7 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     Ok(Target {
index 152b11b4aeeb5cc5de53f2182fb665aa965ef5c7..c56c6e3822959fa3689bd6365f20c17424fb4db6 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::linux_musl_base::opts();
index 99cd20e9a52e8c44ad0d7d8382b0439dfb8f0281..cb02769c7dfe49edbc4a3b2f6ed72e9ddcb80b85 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     Ok(Target {
index 476cf152706495c3974ac1f904d392c46f37b933..ed49ddd49937f9ac214a7978722b1930211d4d0e 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     Ok(Target {
index 9df131dbe25109be6edf093de5831581c0b0512f..bcc49cf5ffe4f874a221c88c4ecd772a133dc6be 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::linux_musl_base::opts();
index 37c55d11f25c9245379654d60589b4c15d2a6461..205f328a24cec449ebbc4a6c49b2c3a4b41a02f8 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     Ok(Target {
index aeecce49b0c67689c1e07638e288581ebc4d04fa..107583e4fc0a06dbc539bcf54f729affd3c2f345 100644 (file)
@@ -40,7 +40,7 @@
 use std::{fmt, io};
 use std::path::{Path, PathBuf};
 use std::str::FromStr;
-use spec::abi::{Abi, lookup as lookup_abi};
+use crate::spec::abi::{Abi, lookup as lookup_abi};
 
 pub mod abi;
 mod android_base;
@@ -1408,7 +1408,7 @@ pub fn debug_triple(&self) -> String {
 }
 
 impl fmt::Display for TargetTriple {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(f, "{}", self.debug_triple())
     }
 }
index df564bc924baf8bfd87e36f9621c5753d45ddc82..90af5898089b84f751ee4f158c53e28f6cd6a842 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, PanicStrategy, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, PanicStrategy, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     Ok(Target {
index b88d360dd37858385cdfdc61821036ba99c6277d..e9cd98c0e71512afff06e5dc04bb905422118020 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkArgs, LinkerFlavor, TargetOptions, RelroLevel};
+use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions, RelroLevel};
 use std::default::Default;
 
 pub fn opts() -> TargetOptions {
index e8512415e66a3c9c6f969ee7b2339865f4b7e482..db9d6a7409ee540a6c72c62c4711b7d9043dc916 100644 (file)
@@ -1,5 +1,5 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult, PanicStrategy, MergeFunctions};
-use spec::abi::Abi;
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult, PanicStrategy, MergeFunctions};
+use crate::spec::abi::Abi;
 
 pub fn target() -> TargetResult {
     Ok(Target {
index 4bdf73fc922139460eaedf980fe670b7d4163e82..5bcfd62d75bd423b440e9ddd0d84987f21a56ab2 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkArgs, LinkerFlavor, TargetOptions, RelroLevel};
+use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions, RelroLevel};
 use std::default::Default;
 
 pub fn opts() -> TargetOptions {
index cc7b87bfdebc345e29a95c8fe1239bb7363f7996..360876b9ff5573f83e0ae55211e1f1e316e668a9 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::freebsd_base::opts();
index 1f7ae933cedd1e1a1f4238be553c3811a2f6e7eb..c16db7583f32bb14fe4c6dc98e2af6a4b6fdb202 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult, RelroLevel};
+use crate::spec::{LinkerFlavor, Target, TargetResult, RelroLevel};
 
 pub fn target() -> TargetResult {
     let mut base = super::linux_base::opts();
index 6fc8be8a5c4d8f670a502f33bc15ad09ce71c5b8..ac0b7431f91a4210efd32a47f5f4e8a027ad8956 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::linux_musl_base::opts();
index 21791a75d2a29786f1eb0f1795c47a98ede5dd81..038b925a28692d2f2237aa1f760e6e46072a1e09 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::linux_base::opts();
index 38f7fe887f5a9ed7366ac116995770bc1d92fc16..57103345f0a0ced41fa011aed223e0068ca14df4 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::linux_musl_base::opts();
index 286d177c864e409a0fda1029b2ae14719efdb26d..38a801d5ab507fa3cb08646fb73dd414760c7a61 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::linux_base::opts();
index ae144af04723255c0cea43df46362edae664d618..675b2c749d6487ac0b7f8efee1d54da98c9b5925 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::linux_base::opts();
index 3b61889163b4c81bf56661a84bd88f282e62d062..240443aa98db4f4d1725657a150d35ac64683c5c 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::linux_musl_base::opts();
index e8662a785190798134014a39262218a6a64d4f0a..10e7089cf1c4c6fba33c235651ea03cbcd4a0dea 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::netbsd_base::opts();
index dd32f02e340496a4d1b5e7598cd0617b66f200f6..dc51aeb58391ffa6e9905c0e69ccdeb607602609 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkArgs, LinkerFlavor, TargetOptions};
+use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions};
 use std::default::Default;
 
 pub fn opts() -> TargetOptions {
index 8adf562ca7e52b4030ea2db883ac074f8eef46a8..5064393d31135b89800afa9bf499a1c4783ca2a2 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, LldFlavor, PanicStrategy,
+use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy,
            Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
index 5d8157ee59a0accb7e7df6f0fcb4a30718f0c105..31e74c5920cf9207396d06662dd39e587ff6a1ac 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, LldFlavor, PanicStrategy,
+use crate::spec::{LinkerFlavor, LldFlavor, PanicStrategy,
            Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
index ea7fdc39a9a96cc8f23e79c70353492eff427dfb..ec1dc9b4918bde92920ced456544ebfb9201bc30 100644 (file)
@@ -1,4 +1,4 @@
-use spec::abi::Abi;
+use crate::spec::abi::Abi;
 
 // All the calling conventions trigger an assertion(Unsupported calling
 // convention) in llvm on RISCV
index c18c94511f8d71ab0dc6cc80de0f0cc7314215ae..f259787e1d54d507eac0f9bab9a15fb096c9227a 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::linux_base::opts();
index f5f85092105703cf2481618dd107a17c8dd8014b..0dfbb13b7731795f72acaa729e32fce1cd48b352 100644 (file)
@@ -1,4 +1,4 @@
-use spec::TargetOptions;
+use crate::spec::TargetOptions;
 use std::default::Default;
 
 pub fn opts() -> TargetOptions {
index e5e3752be7f82748cf9a33c39815feb32c1e966f..c842b22d4e16e6c8af3f5a734420caf03dfb7bf3 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::linux_base::opts();
index 62efd41dbb8ee64dcb71492fccc8030bce7560e8..78d53e69e8b5237193f3be2deb2ea3a96491e08e 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::netbsd_base::opts();
index b6468993790d8376380f2529445440c1b29c7f45..162cd311a3826b7479f537ffc298701970adf52a 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::linux_base::opts();
index f1c5c5ac44f1ab3245559f573dd6c378d1068267..acc03fd0d79eec7d5411a411339e98bd7bcc8db6 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::solaris_base::opts();
index 06cb6a8d823ef4dca34c214264803f357e5ae56a..ed0dbb766a8357a955179ba32d13eab5924e08a7 100644 (file)
@@ -28,7 +28,7 @@
 // build scripts / gcc flags.
 
 use std::default::Default;
-use spec::{PanicStrategy, TargetOptions};
+use crate::spec::{PanicStrategy, TargetOptions};
 
 pub fn opts() -> TargetOptions {
     // See rust-lang/rfcs#1645 for a discussion about these defaults
index 98c46e9c600a35fb6ccbbb5407af5955d3aad99a..2ab61b57f6bb66504c3d428e6094a58f72e1cbf4 100644 (file)
@@ -1,6 +1,6 @@
 // Targets the Cortex-M0, Cortex-M0+ and Cortex-M1 processors (ARMv6-M architecture)
 
-use spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     Ok(Target {
index eaa08fadbc0f3b4c0a973643c5a07c8c63632aff..310fac31c0c5b44851398f5807c6ed90e345ce66 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult, PanicStrategy};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult, PanicStrategy};
 
 pub fn target() -> TargetResult {
     let mut base = super::windows_msvc_base::opts();
index 8a1fe09cdb07a642ad55cc41092d7c306796b7e4..97114c342cdc7a72c72e28e18cc003363e94ac46 100644 (file)
@@ -9,7 +9,7 @@
 // To opt-in to hardware accelerated floating point operations, you can use, for example,
 // `-C target-feature=+vfp4` or `-C target-cpu=cortex-m4`.
 
-use spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     Ok(Target {
index 0c9aa1c5149ffd656defa97c5db9d94133de8ca3..e4358bdd7991eba3645ab111b7b4d6b076ee1f33 100644 (file)
@@ -8,7 +8,7 @@
 //
 // To opt into double precision hardware support, use the `-C target-feature=-fp-only-sp` flag.
 
-use spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     Ok(Target {
index 9bff3473c58afbcf599286ee3bcb9e2384ecb6ff..daf25b16d58d64a7f9156ccdcca4bbcc0a3810de 100644 (file)
@@ -1,6 +1,6 @@
 // Targets the Cortex-M3 processor (ARMv7-M)
 
-use spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     Ok(Target {
index 2d92e29c09d96aa772225ab42d35e855d83d23c1..e248b930e6e4cb52a32c480a5ce3821303f95a9c 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 
 // This target if is for the Android v7a ABI in thumb mode with
 // NEON unconditionally enabled and, therefore, with 32 FPU registers
index bdf57969154c0ccd32946843e1bdb358d2ea1836..bef62b0a2ebe65e83126979fe319b4e6051d2be0 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 
 // This target is for glibc Linux on ARMv7 with thumb mode enabled
 // (for consistency with Android and Debian-based distributions)
index 0e0e73efd45ccee71a3968d3eebaaf4257bc3641..be8a476db4dbc4b928a20e7fcfefbde57d399613 100644 (file)
@@ -1,6 +1,6 @@
 // Targets the Cortex-M23 processor (Baseline ARMv8-M)
 
-use spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     Ok(Target {
index dc2454d749780d88fe240a5cc5a4548a1819fb31..49ab643d484bc3d53713443397e4a7e33278d44b 100644 (file)
@@ -1,7 +1,7 @@
 // Targets the Cortex-M33 processor (Armv8-M Mainline architecture profile),
 // without the Floating Point extension.
 
-use spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     Ok(Target {
index 5fa1f42288d1a848d0e0294c9c7a0179a50d8756..6a3d8e61d7fe861c9a518105c31ff73f1770dd93 100644 (file)
@@ -1,7 +1,7 @@
 // Targets the Cortex-M33 processor (Armv8-M Mainline architecture profile),
 // with the Floating Point extension.
 
-use spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult};
 
 pub fn target() -> TargetResult {
     Ok(Target {
index 4628089ffe1f4ae3a87c0c60c544fd68fa58d35f..5078d500679d13ed806cca0c1c4be564f0cd1d99 100644 (file)
@@ -9,7 +9,7 @@
 // the timer-interrupt. Device-drivers are required to use polling-based models. Furthermore, all
 // code runs in the same environment, no process separation is supported.
 
-use spec::{LinkArgs, LinkerFlavor, LldFlavor, PanicStrategy, TargetOptions};
+use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, PanicStrategy, TargetOptions};
 use std::default::Default;
 
 pub fn opts() -> TargetOptions {
index 65d618232a249195af29b635d22a57ddfa4d6508..38db9cd356cd86b749db17c2d1d604e0aa3291c6 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkArgs, LinkerFlavor, TargetOptions};
+use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions};
 use std::default::Default;
 
 pub fn opts() -> TargetOptions {
index 89f6b1bcc71c598c1a77d291a77ab04adad07c97..fdd747cdb865a5dcefa3a3db5b2a0d56d9a73c7f 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkArgs, LinkerFlavor, TargetOptions};
+use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions};
 use std::default::Default;
 
 pub fn opts() -> TargetOptions {
index 7de33fe8ac52a91016d73263019cd40ce163bd2d..0911ce06c13d7e19a22f64fef7f6ec1c85c096f0 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::apple_base::opts();
index 286a73d48048cff1b7dc3e085c47d1c2ceeefaaf..1f9594b906282fe584f31fa63470f608aa52d9cc 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
 use super::apple_ios_base::{opts, Arch};
 
 pub fn target() -> TargetResult {
index 00fb7066ca28febb21ffd4f297e0c85de91f68d6..a24d432c591d2ede64cdf4130337c1fac3b86b59 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LldFlavor, LinkerFlavor, Target, TargetResult};
+use crate::spec::{LldFlavor, LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::fuchsia_base::opts();
index 29d5dfa5790a1a6fa5fd27971ada1220adb004d0..c3c6c7bf56fef92808915cc6a6f6ca16be1e2aaf 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::android_base::opts();
index c3c36d22cef5e8c834ab76623e5cf4337573d1f5..35e0d55cd045e183c6edc958c51d8ece5008ad92 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::windows_base::opts();
index 178d67784e6535365ba27ae1047c595c4dc0ac8b..073d49be5a9ab5b93f5bbea484b9235fe3b4791e 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::windows_msvc_base::opts();
index 37c7925c6985e1768138b56d85afdb43501717b6..a2c706c4c723231d05bfdba06511f0b20c149560 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::netbsd_base::opts();
index 3534f9e6436b46fcfce0001b4754315903ece389..3bf3f51ae2512e53a7031da07090a55edc459e37 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::solaris_base::opts();
index fa5392175606a5c597efaff56eade4451fdf5f83..999d93a7e60902d876692819bb78db70fdaa68a9 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::bitrig_base::opts();
index c1253a3b2727bf92fdd1e4211587ae811ac976a7..d48120c5401c28af99dc0354127d7914bd8e2180 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::cloudabi_base::opts();
index 815aa57252561c3c2ade0ce91e61e2e52f2403cd..f55ee6969092b6e3c3c1822a0d26d8131a141a41 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::dragonfly_base::opts();
index 8d43883f33bf3660ce348f514b95ec43f11cc666..1d9c5cce3f729628294edccf407a1dfc50d864d7 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::freebsd_base::opts();
index 608354732d9d11d9cc0ec84ab406ee162889a336..4ab15fa4e90f5dc791ed87f09794d6e8a67f8e3e 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::haiku_base::opts();
index de5992cbf5ef29561d89aa320232759d45d749d3..a696ee16d7c9ef7c2a08763f214449c7c7ba036c 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::hermit_base::opts();
index cf04cc1bdc2f5ab0b6f5f9884b1f528dd0fbdaa4..e5fdb386ef3017aa8b3a7add485bf814b5d0d1b3 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::l4re_base::opts();
index c6ec8de5b7312fef2e7e71e18682d7d449252f66..cb279e86f149886e136120f323ab2f32a2a29716 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::linux_base::opts();
index e4dfb8d05cdfa4605d50a7454e427dd810f4daa5..0b2d7aacc4ddf79160293087a3c40fff1bb6fd9a 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::linux_base::opts();
index 95321fe2f783eba7540138d70c56a880ea9784bc..2e1bc839873c7279da9ad8563fb50980ca1c827c 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::linux_musl_base::opts();
index fbd07ecce1afb2f09ad100d7c5fa2facb189dddc..ffc4f1d5c49b713004f0887220cc5b8c7378b5ba 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::netbsd_base::opts();
index 68496247b1596f5c25451958dadf14ac6e046f7e..f2abd1071227ebfeed10bbcd0f4063b7f2244bc7 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::openbsd_base::opts();
index d04bc5cc6ec21ac907037abe66533c62e821feb7..f0a4519f59548cc633e4daf2d13cbbac725d374c 100644 (file)
@@ -1,4 +1,4 @@
-use spec::{LinkerFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::redox_base::opts();
index 0d7b4fc060bd9af5cb33e818e204e6f56500bd52..9ac17a1693fb5503c5aed3cb86add86a97f0ae03 100644 (file)
@@ -5,7 +5,7 @@
 // The win64 ABI is used. It differs from the sysv64 ABI, so we must use a windows target with
 // LLVM. "x86_64-unknown-windows" is used to get the minimal subset of windows-specific features.
 
-use spec::{LinkerFlavor, LldFlavor, Target, TargetResult};
+use crate::spec::{LinkerFlavor, LldFlavor, Target, TargetResult};
 
 pub fn target() -> TargetResult {
     let mut base = super::uefi_base::opts();
index bf946d39806ecd1991791856a4fc0a91f7387907..da19cc95eb95a0485bc8c5fb4c3d7f503b121eec 100644 (file)
@@ -2,6 +2,7 @@
 authors = ["The Rust Project Developers"]
 name = "rustc_traits"
 version = "0.0.0"
+edition = "2018"
 
 [lib]
 name = "rustc_traits"
index 303920b5842c969636ad962d4da249299f3e3b02..ffa696c90803933fe491caef56639ecf3165172b 100644 (file)
@@ -502,13 +502,13 @@ fn into_ex_clause(
 type ChalkExClause<'tcx> = ExClause<ChalkArenas<'tcx>>;
 
 impl Debug for ChalkContext<'cx, 'gcx> {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(f, "ChalkContext")
     }
 }
 
 impl Debug for ChalkInferenceContext<'cx, 'gcx, 'tcx> {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         write!(f, "ChalkInferenceContext")
     }
 }
@@ -658,7 +658,7 @@ fn upcast(&self) -> Self::Upcasted {
     }
 }
 
-crate fn provide(p: &mut Providers) {
+crate fn provide(p: &mut Providers<'_>) {
     *p = Providers {
         evaluate_goal,
         ..*p
index 71f4945fd648df3f7f51096e3a70883a83e6766d..adfd26814db1eb0f5acbb9c44bbfbfa26e030d86 100644 (file)
@@ -220,7 +220,7 @@ fn wf_clause_for_slice<'tcx>(tcx: ty::TyCtxt<'_, '_, 'tcx>) -> Clauses<'tcx> {
         def_id: sized_trait,
         substs: tcx.mk_substs_trait(ty, ty::List::empty()),
     };
-    let sized_implemented: DomainGoal = ty::TraitPredicate {
+    let sized_implemented: DomainGoal<'_> = ty::TraitPredicate {
         trait_ref: sized_implemented
     }.lower();
 
@@ -252,7 +252,7 @@ fn wf_clause_for_array<'tcx>(
         def_id: sized_trait,
         substs: tcx.mk_substs_trait(ty, ty::List::empty()),
     };
-    let sized_implemented: DomainGoal = ty::TraitPredicate {
+    let sized_implemented: DomainGoal<'_> = ty::TraitPredicate {
         trait_ref: sized_implemented
     }.lower();
 
@@ -326,7 +326,7 @@ fn wf_clause_for_ref<'tcx>(
         mutbl,
     });
 
-    let _outlives: DomainGoal = ty::OutlivesPredicate(ty, region).lower();
+    let _outlives: DomainGoal<'_> = ty::OutlivesPredicate(ty, region).lower();
     let wf_clause = ProgramClause {
         goal: DomainGoal::WellFormed(WellFormed::Ty(ref_ty)),
         hypotheses: ty::List::empty(),
index 7979fe4a750731a3783f42259cbe33d150cda367..45b19e1dc06af843ba5c2af13c372061eccbb68a 100644 (file)
@@ -10,7 +10,7 @@
 use rustc_data_structures::sync::Lrc;
 use syntax::source_map::{Span, DUMMY_SP};
 
-crate fn provide(p: &mut Providers) {
+crate fn provide(p: &mut Providers<'_>) {
     *p = Providers {
         dropck_outlives,
         adt_dtorck_constraint,
@@ -305,7 +305,7 @@ fn dtorck_constraint_for_ty<'a, 'gcx, 'tcx>(
     let mut result = def.all_fields()
         .map(|field| tcx.type_of(field.did))
         .map(|fty| dtorck_constraint_for_ty(tcx, span, fty, 0, fty))
-        .collect::<Result<DtorckConstraint, NoSolution>>()?;
+        .collect::<Result<DtorckConstraint<'_>, NoSolution>>()?;
     result.outlives.extend(tcx.destructor_constraints(def));
     dedup_dtorck_constraint(&mut result);
 
index c5b6de279355231eb3217c23b1f1575f08082ca2..83aebd16e2400889199bec1efd253d0f460806e1 100644 (file)
@@ -6,7 +6,7 @@
 use rustc::ty::{ParamEnvAnd, TyCtxt};
 use syntax::source_map::DUMMY_SP;
 
-crate fn provide(p: &mut Providers) {
+crate fn provide(p: &mut Providers<'_>) {
     *p = Providers {
         evaluate_obligation,
         ..*p
index a3fb96990545e89a80d36b59dde9c0d4501211a7..e4a032aaf7b18a8266b9ae751fa88c26dd8c48de 100644 (file)
@@ -17,7 +17,7 @@
 
 use rustc_data_structures::sync::Lrc;
 
-crate fn provide(p: &mut Providers) {
+crate fn provide(p: &mut Providers<'_>) {
     *p = Providers {
         implied_outlives_bounds,
         ..*p
index a220b9219136948785a9d98a88c270623c3ae678..d52a976981db06037ee2d1be2df6c9ba540c8243 100644 (file)
@@ -1,22 +1,18 @@
 //! New recursive solver modeled on Chalk's recursive solver. Most of
 //! the guts are broken up into modules; see the comments in those modules.
 
+#![deny(rust_2018_idioms)]
+
 #![feature(crate_visibility_modifier)]
 #![feature(in_band_lifetimes)]
 #![feature(nll)]
 
 #![recursion_limit="256"]
 
-extern crate chalk_engine;
 #[macro_use]
 extern crate log;
 #[macro_use]
 extern crate rustc;
-extern crate rustc_data_structures;
-extern crate rustc_target;
-extern crate syntax;
-extern crate syntax_pos;
-extern crate smallvec;
 
 mod chalk_context;
 mod dropck_outlives;
@@ -30,7 +26,7 @@
 
 use rustc::ty::query::Providers;
 
-pub fn provide(p: &mut Providers) {
+pub fn provide(p: &mut Providers<'_>) {
     dropck_outlives::provide(p);
     evaluate_obligation::provide(p);
     implied_outlives_bounds::provide(p);
index 9bdef3051e58934403ec63e0be1712fff71fdda2..908fdcfe7430fc0102321ea85ea673ab5a2a1910 100644 (file)
@@ -23,7 +23,7 @@
 
 use std::iter;
 
-crate fn provide(p: &mut Providers) {
+crate fn provide(p: &mut Providers<'_>) {
     *p = Providers {
         program_clauses_for,
         program_clauses_for_env: environment::program_clauses_for_env,
@@ -193,7 +193,7 @@ fn program_clauses_for_trait<'a, 'tcx>(
     };
 
     // `Implemented(Self: Trait<P1..Pn>)`
-    let impl_trait: DomainGoal = trait_pred.lower();
+    let impl_trait: DomainGoal<'_> = trait_pred.lower();
 
     // `FromEnv(Self: Trait<P1..Pn>)`
     let from_env_goal = tcx.mk_goal(impl_trait.into_from_env_goal().into_goal());
@@ -575,7 +575,7 @@ pub fn program_clauses_for_associated_type_value<'a, 'tcx>(
     let ty = tcx.type_of(item_id);
 
     // `Implemented(A0: Trait<A1..An>)`
-    let trait_implemented: DomainGoal = ty::TraitPredicate { trait_ref }.lower();
+    let trait_implemented: DomainGoal<'_> = ty::TraitPredicate { trait_ref }.lower();
 
     // `<A0 as Trait<A1..An>>::AssocType<Pn+1..Pm>`
     let projection_ty = ty::ProjectionTy::from_ref_and_name(tcx, trait_ref, item.ident);
index c06cdbd0928dacacf1df74fc5204d1158f1508c3..412d2ca6dfcff06384242238a22e0b35af2c38fa 100644 (file)
@@ -4,7 +4,7 @@
 use rustc::ty::{self, ParamEnvAnd, Ty, TyCtxt};
 use std::sync::atomic::Ordering;
 
-crate fn provide(p: &mut Providers) {
+crate fn provide(p: &mut Providers<'_>) {
     *p = Providers {
         normalize_ty_after_erasing_regions,
         ..*p
index b31e9c15d03673c47008f1e43fc2d7af3addede3..6fe9e316cf36ec31e092d68dcfcdfe6a9765e2c9 100644 (file)
@@ -8,7 +8,7 @@
 use syntax::ast::DUMMY_NODE_ID;
 use syntax_pos::DUMMY_SP;
 
-crate fn provide(p: &mut Providers) {
+crate fn provide(p: &mut Providers<'_>) {
     *p = Providers {
         normalize_projection_ty,
         ..*p
index 526637e108d40bb861f1f90f19b3e330172e43eb..3cc2f77187ac75c8bb6e8cb9db674290e60dda7e 100644 (file)
@@ -21,7 +21,7 @@
 use syntax::ast;
 use syntax_pos::DUMMY_SP;
 
-crate fn provide(p: &mut Providers) {
+crate fn provide(p: &mut Providers<'_>) {
     *p = Providers {
         type_op_ascribe_user_type,
         type_op_eq,
index 8da0b6dcbeac3b36ea87c838b44491f817d88929..757385aeb3edc8f0934e4fde066764c6ea539f66 100644 (file)
@@ -1793,7 +1793,7 @@ pub fn ast_ty_to_ty(&self, ast_ty: &hir::Ty) -> Ty<'tcx> {
                 let length_def_id = tcx.hir().local_def_id(length.id);
                 let substs = Substs::identity_for_item(tcx, length_def_id);
                 let length = ty::LazyConst::Unevaluated(length_def_id, substs);
-                let length = tcx.intern_lazy_const(length);
+                let length = tcx.mk_lazy_const(length);
                 let array_ty = tcx.mk_ty(ty::Array(self.ast_ty_to_ty(&ty), length));
                 self.normalize_ty(ast_ty.span, array_ty)
             }
index 623677482db34300c855531b7f53ea88aa69ab7a..ada4a95ed7a34ef49988e4a0f640816466640ee0 100644 (file)
@@ -85,6 +85,37 @@ fn deref(&self) -> &Self::Target {
 
 #[derive(Debug)]
 struct Candidate<'tcx> {
+    // Candidates are (I'm not quite sure, but they are mostly) basically
+    // some metadata on top of a `ty::AssociatedItem` (without substs).
+    //
+    // However, method probing wants to be able to evaluate the predicates
+    // for a function with the substs applied - for example, if a function
+    // has `where Self: Sized`, we don't want to consider it unless `Self`
+    // is actually `Sized`, and similarly, return-type suggestions want
+    // to consider the "actual" return type.
+    //
+    // The way this is handled is through `xform_self_ty`. It contains
+    // the receiver type of this candidate, but `xform_self_ty`,
+    // `xform_ret_ty` and `kind` (which contains the predicates) have the
+    // generic parameters of this candidate substituted with the *same set*
+    // of inference variables, which acts as some weird sort of "query".
+    //
+    // When we check out a candidate, we require `xform_self_ty` to be
+    // a subtype of the passed-in self-type, and this equates the type
+    // variables in the rest of the fields.
+    //
+    // For example, if we have this candidate:
+    // ```
+    //    trait Foo {
+    //        fn foo(&self) where Self: Sized;
+    //    }
+    // ```
+    //
+    // Then `xform_self_ty` will be `&'erased ?X` and `kind` will contain
+    // the predicate `?X: Sized`, so if we are evaluating `Foo` for a
+    // the receiver `&T`, we'll do the subtyping which will make `?X`
+    // get the right value, then when we evaluate the predicate we'll check
+    // if `T: Sized`.
     xform_self_ty: Ty<'tcx>,
     xform_ret_ty: Option<Ty<'tcx>>,
     item: ty::AssociatedItem,
@@ -506,13 +537,28 @@ fn assemble_probe(&mut self, self_ty: &Canonical<'gcx, QueryResponse<'gcx, Ty<'g
         match self_ty.value.value.sty {
             ty::Dynamic(ref data, ..) => {
                 if let Some(p) = data.principal() {
-                    let InferOk { value: instantiated_self_ty, obligations: _ } =
-                        self.fcx.probe_instantiate_query_response(
-                            self.span, &self.orig_steps_var_values, self_ty)
-                        .unwrap_or_else(|_| {
-                            span_bug!(self.span, "{:?} was applicable but now isn't?", self_ty)
-                        });
-                    self.assemble_inherent_candidates_from_object(instantiated_self_ty);
+                    // Subtle: we can't use `instantiate_query_response` here: using it will
+                    // commit to all of the type equalities assumed by inference going through
+                    // autoderef (see the `method-probe-no-guessing` test).
+                    //
+                    // However, in this code, it is OK if we end up with an object type that is
+                    // "more general" than the object type that we are evaluating. For *every*
+                    // object type `MY_OBJECT`, a function call that goes through a trait-ref
+                    // of the form `<MY_OBJECT as SuperTraitOf(MY_OBJECT)>::func` is a valid
+                    // `ObjectCandidate`, and it should be discoverable "exactly" through one
+                    // of the iterations in the autoderef loop, so there is no problem with it
+                    // being discoverable in another one of these iterations.
+                    //
+                    // Using `instantiate_canonical_with_fresh_inference_vars` on our
+                    // `Canonical<QueryResponse<Ty<'tcx>>>` and then *throwing away* the
+                    // `CanonicalVarValues` will exactly give us such a generalization - it
+                    // will still match the original object type, but it won't pollute our
+                    // type variables in any form, so just do that!
+                    let (QueryResponse { value: generalized_self_ty, .. }, _ignored_var_values) =
+                        self.fcx.instantiate_canonical_with_fresh_inference_vars(
+                            self.span, &self_ty);
+
+                    self.assemble_inherent_candidates_from_object(generalized_self_ty);
                     self.assemble_inherent_impl_candidates_for_type(p.def_id());
                 }
             }
index 3e2a9d720f1c178455b6487b99fe308e0d3839b3..fb8f608812197b15b01af61a6b40ea6d508e9599 100644 (file)
@@ -4597,7 +4597,7 @@ fn check_expr_kind(
                 if element_ty.references_error() {
                     tcx.types.err
                 } else if let Ok(count) = count {
-                    tcx.mk_ty(ty::Array(t, tcx.intern_lazy_const(ty::LazyConst::Evaluated(count))))
+                    tcx.mk_ty(ty::Array(t, tcx.mk_lazy_const(ty::LazyConst::Evaluated(count))))
                 } else {
                     tcx.types.err
                 }
index 3ed09dfe99239ccccd0be34f166691eaad2ba395..e6533ac4b75598586fd0bce26524750390fc5136 100644 (file)
@@ -348,13 +348,14 @@ fn main() {
 "##,
 
 E0044: r##"
-You can't use type parameters on foreign items. Example of erroneous code:
+You can't use type or const parameters on foreign items.
+Example of erroneous code:
 
 ```compile_fail,E0044
 extern { fn some_func<T>(x: T); }
 ```
 
-To fix this, replace the type parameter with the specializations that you
+To fix this, replace the generic parameter with the specializations that you
 need:
 
 ```
index d6c05de0df6f2039988acecd7b28a88cd519dd27..877ac9a62bbec67bd62275bd7b9d13709c4a199e 100644 (file)
@@ -2026,7 +2026,7 @@ if (!DOMTokenList.prototype.remove) {
             } else if (action === "hide") {
                 addClass(relatedDoc, "fns-now-collapsed");
                 addClass(docblock, "hidden-by-usual-hider");
-                onEachLazy(toggle.childNodes, adjustToggle(true, dontApplyBlockRule);
+                onEachLazy(toggle.childNodes, adjustToggle(true, dontApplyBlockRule));
                 onEachLazy(relatedDoc.childNodes, implHider(true, dontApplyBlockRule));
             }
         }
index 2cfe2cc896cb1e679f3a2dd71589988169b63f0c..681d8eeaa0d733ff2332da3e873a3cbe8c3667f4 100644 (file)
@@ -167,6 +167,17 @@ pub fn span(&self) -> Span {
 pub enum GenericArg {
     Lifetime(Lifetime),
     Type(P<Ty>),
+    Const(AnonConst),
+}
+
+impl GenericArg {
+    pub fn span(&self) -> Span {
+        match self {
+            GenericArg::Lifetime(lt) => lt.ident.span,
+            GenericArg::Type(ty) => ty.span,
+            GenericArg::Const(ct) => ct.value.span,
+        }
+    }
 }
 
 /// A path like `Foo<'a, T>`
@@ -296,13 +307,32 @@ pub fn span(&self) -> Span {
 
 pub type GenericBounds = Vec<GenericBound>;
 
+/// Specifies the enforced ordering for generic parameters. In the future,
+/// if we wanted to relax this order, we could override `PartialEq` and
+/// `PartialOrd`, to allow the kinds to be unordered.
+#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)]
+pub enum ParamKindOrd {
+    Lifetime,
+    Type,
+    Const,
+}
+
+impl fmt::Display for ParamKindOrd {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        match self {
+            ParamKindOrd::Lifetime => "lifetime".fmt(f),
+            ParamKindOrd::Type => "type".fmt(f),
+            ParamKindOrd::Const => "const".fmt(f),
+        }
+    }
+}
+
 #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
 pub enum GenericParamKind {
     /// A lifetime definition (e.g., `'a: 'b + 'c + 'd`).
     Lifetime,
-    Type {
-        default: Option<P<Ty>>,
-    },
+    Type { default: Option<P<Ty>> },
+    Const { ty: P<Ty> },
 }
 
 #[derive(Clone, RustcEncodable, RustcDecodable, Debug)]
index 977e6d4587709be238c9b86080c42c7ee20e54d2..29cb9cd7f30b5b33d281901282338d7554e9e3df 100644 (file)
@@ -12,6 +12,8 @@ pub enum BufferedEarlyLintId {
     /// Usage of `?` as a macro separator is deprecated.
     QuestionMarkMacroSep,
     IllFormedAttributeInput,
+    /// Usage of a duplicate macro matcher binding name.
+    DuplicateMacroMatcherBindingName,
 }
 
 /// Stores buffered lint info which can later be passed to `librustc`.
index 1e83f6c03ec3097664fbd219001b8b2caf7a32a8..6708e3c12a0057e4b52bd087749a629acac414a7 100644 (file)
@@ -38,12 +38,14 @@ fn qpath_all(&self, self_type: P<ast::Ty>,
                 bindings: Vec<ast::TypeBinding>)
                 -> (ast::QSelf, ast::Path);
 
-    // types
+    // types and consts
     fn ty_mt(&self, ty: P<ast::Ty>, mutbl: ast::Mutability) -> ast::MutTy;
 
     fn ty(&self, span: Span, ty: ast::TyKind) -> P<ast::Ty>;
     fn ty_path(&self, path: ast::Path) -> P<ast::Ty>;
     fn ty_ident(&self, span: Span, idents: ast::Ident) -> P<ast::Ty>;
+    fn anon_const(&self, span: Span, expr: ast::ExprKind) -> ast::AnonConst;
+    fn const_ident(&self, span: Span, idents: ast::Ident) -> ast::AnonConst;
 
     fn ty_rptr(&self, span: Span,
                ty: P<ast::Ty>,
@@ -394,6 +396,22 @@ fn ty_ident(&self, span: Span, ident: ast::Ident)
         self.ty_path(self.path_ident(span, ident))
     }
 
+    fn anon_const(&self, span: Span, expr: ast::ExprKind) -> ast::AnonConst {
+        ast::AnonConst {
+            id: ast::DUMMY_NODE_ID,
+            value: P(ast::Expr {
+                id: ast::DUMMY_NODE_ID,
+                node: expr,
+                span,
+                attrs: ThinVec::new(),
+            })
+        }
+    }
+
+    fn const_ident(&self, span: Span, ident: ast::Ident) -> ast::AnonConst {
+        self.anon_const(span, ast::ExprKind::Path(None, self.path_ident(span, ident)))
+    }
+
     fn ty_rptr(&self,
                span: Span,
                ty: P<ast::Ty>,
index b3ecaeaedbb7ace2fd75875676bf40789df0ed6d..33ea675f9d1bb12e4722a4e809ea919ea3060702 100644 (file)
 use crate::symbol::Symbol;
 use crate::tokenstream::{DelimSpan, TokenStream, TokenTree};
 
-use syntax_pos::{Span, DUMMY_SP};
+use syntax_pos::{Span, DUMMY_SP, symbol::Ident};
 use log::debug;
 
-use rustc_data_structures::fx::FxHashMap;
+use rustc_data_structures::fx::{FxHashMap};
 use std::borrow::Cow;
 use std::collections::hash_map::Entry;
 
@@ -246,8 +246,12 @@ fn generic_extension<'cx>(cx: &'cx mut ExtCtxt<'_>,
 // Holy self-referential!
 
 /// Converts a `macro_rules!` invocation into a syntax extension.
-pub fn compile(sess: &ParseSess, features: &Features, def: &ast::Item, edition: Edition)
-               -> SyntaxExtension {
+pub fn compile(
+    sess: &ParseSess,
+    features: &Features,
+    def: &ast::Item,
+    edition: Edition
+) -> SyntaxExtension {
     let lhs_nm = ast::Ident::with_empty_ctxt(Symbol::gensym("lhs"));
     let rhs_nm = ast::Ident::with_empty_ctxt(Symbol::gensym("rhs"));
 
@@ -355,7 +359,13 @@ pub fn compile(sess: &ParseSess, features: &Features, def: &ast::Item, edition:
 
     // don't abort iteration early, so that errors for multiple lhses can be reported
     for lhs in &lhses {
-        valid &= check_lhs_no_empty_seq(sess, &[lhs.clone()])
+        valid &= check_lhs_no_empty_seq(sess, &[lhs.clone()]);
+        valid &= check_lhs_duplicate_matcher_bindings(
+            sess,
+            &[lhs.clone()],
+            &mut FxHashMap::default(),
+            def.id
+        );
     }
 
     let expander: Box<_> = Box::new(MacroRulesMacroExpander {
@@ -456,6 +466,53 @@ fn check_lhs_no_empty_seq(sess: &ParseSess, tts: &[quoted::TokenTree]) -> bool {
     true
 }
 
+/// Check that the LHS contains no duplicate matcher bindings. e.g. `$a:expr, $a:expr` would be
+/// illegal, since it would be ambiguous which `$a` to use if we ever needed to.
+fn check_lhs_duplicate_matcher_bindings(
+    sess: &ParseSess,
+    tts: &[quoted::TokenTree],
+    metavar_names: &mut FxHashMap<Ident, Span>,
+    node_id: ast::NodeId,
+) -> bool {
+    use self::quoted::TokenTree;
+    use crate::early_buffered_lints::BufferedEarlyLintId;
+    for tt in tts {
+        match *tt {
+            TokenTree::MetaVarDecl(span, name, _kind) => {
+                if let Some(&prev_span) = metavar_names.get(&name) {
+                    // FIXME(mark-i-m): in a few cycles, make this a hard error.
+                    // sess.span_diagnostic
+                    //     .struct_span_err(span, "duplicate matcher binding")
+                    //     .span_note(prev_span, "previous declaration was here")
+                    //     .emit();
+                    sess.buffer_lint(
+                        BufferedEarlyLintId::DuplicateMacroMatcherBindingName,
+                        crate::source_map::MultiSpan::from(vec![prev_span, span]),
+                        node_id,
+                        "duplicate matcher binding"
+                    );
+                    return false;
+                } else {
+                    metavar_names.insert(name, span);
+                }
+            }
+            TokenTree::Delimited(_, ref del) => {
+                if !check_lhs_duplicate_matcher_bindings(sess, &del.tts, metavar_names, node_id) {
+                    return false;
+                }
+            },
+            TokenTree::Sequence(_, ref seq) => {
+                if !check_lhs_duplicate_matcher_bindings(sess, &seq.tts, metavar_names, node_id) {
+                    return false;
+                }
+            }
+            _ => {}
+        }
+    }
+
+    true
+}
+
 fn check_rhs(sess: &ParseSess, rhs: &quoted::TokenTree) -> bool {
     match *rhs {
         quoted::TokenTree::Delimited(..) => return true,
index e7b9a884b5e0caed0b78ab51601e77e694baf904..0853b4399d2c17e8c1b7325fe0fe917198e9c3c8 100644 (file)
@@ -15,7 +15,7 @@
 use AttributeType::*;
 use AttributeGate::*;
 
-use crate::ast::{self, NodeId, PatKind, RangeEnd};
+use crate::ast::{self, NodeId, GenericParam, GenericParamKind, PatKind, RangeEnd};
 use crate::attr;
 use crate::early_buffered_lints::BufferedEarlyLintId;
 use crate::source_map::Spanned;
@@ -462,6 +462,9 @@ pub fn walk_feature_fields<F>(&self, mut f: F)
     // Re-Rebalance coherence
     (active, re_rebalance_coherence, "1.32.0", Some(55437), None),
 
+    // Const generic types.
+    (active, const_generics, "1.34.0", Some(44580), None),
+
     // #[optimize(X)]
     (active, optimize_attribute, "1.34.0", Some(54882), None),
 
@@ -1899,6 +1902,14 @@ fn visit_fn(&mut self,
         visit::walk_fn(self, fn_kind, fn_decl, span);
     }
 
+    fn visit_generic_param(&mut self, param: &'a GenericParam) {
+        if let GenericParamKind::Const { .. } = param.kind {
+            gate_feature_post!(&self, const_generics, param.ident.span,
+                "const generics are unstable");
+        }
+        visit::walk_generic_param(self, param);
+    }
+
     fn visit_trait_item(&mut self, ti: &'a ast::TraitItem) {
         match ti.node {
             ast::TraitItemKind::Method(ref sig, ref block) => {
@@ -1984,7 +1995,7 @@ fn feature_removed(span_handler: &Handler, span: Span, reason: Option<&str>) {
     // Some features are known to be incomplete and using them is likely to have
     // unanticipated results, such as compiler crashes. We warn the user about these
     // to alert them.
-    let incomplete_features = ["generic_associated_types"];
+    let incomplete_features = ["generic_associated_types", "const_generics"];
 
     let mut features = Features::new();
     let mut edition_enabled_features = FxHashMap::default();
index 0fd8bbf100fa25235aabbccadebbb0fd03617412..1e5eb0992bd1bbbe4377faed0b97629a08c3711a 100644 (file)
@@ -480,6 +480,7 @@ pub fn noop_visit_generic_arg<T: MutVisitor>(arg: &mut GenericArg, vis: &mut T)
     match arg {
         GenericArg::Lifetime(lt) => vis.visit_lifetime(lt),
         GenericArg::Type(ty) => vis.visit_ty(ty),
+        GenericArg::Const(ct) => vis.visit_anon_const(ct),
     }
 }
 
@@ -698,6 +699,9 @@ pub fn noop_visit_generic_param<T: MutVisitor>(param: &mut GenericParam, vis: &m
         GenericParamKind::Type { default } => {
             visit_opt(default, |default| vis.visit_ty(default));
         }
+        GenericParamKind::Const { ty } => {
+            vis.visit_ty(ty);
+        }
     }
 }
 
index 2e3233c8ed8fac8a2f9f4f8dda58a5956f8c1830..d3fc1c03634eaad45435bb63692c6bceb825e74a 100644 (file)
@@ -33,6 +33,15 @@ fn default() -> Self {
     }
 }
 
+#[derive(Clone, Debug)]
+pub struct UnmatchedBrace {
+    pub expected_delim: token::DelimToken,
+    pub found_delim: token::DelimToken,
+    pub found_span: Span,
+    pub unclosed_span: Option<Span>,
+    pub candidate_span: Option<Span>,
+}
+
 pub struct StringReader<'a> {
     pub sess: &'a ParseSess,
     /// The absolute offset within the source_map of the next character to read
@@ -58,6 +67,7 @@ pub struct StringReader<'a> {
     span_src_raw: Span,
     /// Stack of open delimiters and their spans. Used for error message.
     open_braces: Vec<(token::DelimToken, Span)>,
+    crate unmatched_braces: Vec<UnmatchedBrace>,
     /// The type and spans for all braces
     ///
     /// Used only for error recovery when arriving to EOF with mismatched braces.
@@ -222,6 +232,7 @@ fn new_raw_internal(sess: &'a ParseSess, source_file: Lrc<syntax_pos::SourceFile
             span: syntax_pos::DUMMY_SP,
             span_src_raw: syntax_pos::DUMMY_SP,
             open_braces: Vec::new(),
+            unmatched_braces: Vec::new(),
             matching_delim_spans: Vec::new(),
             override_span,
             last_unclosed_found_span: None,
index 7699d9eab222543938193a960b359899d84759b9..0db36c84cdfeb532bfe7b3f7d0c033a4300d1c59 100644 (file)
@@ -1,5 +1,5 @@
 use crate::print::pprust::token_to_string;
-use crate::parse::lexer::StringReader;
+use crate::parse::lexer::{StringReader, UnmatchedBrace};
 use crate::parse::{token, PResult};
 use crate::tokenstream::{DelimSpan, IsJoint::*, TokenStream, TokenTree, TreeAndJoint};
 
@@ -101,38 +101,38 @@ fn parse_token_tree(&mut self) -> PResult<'a, TreeAndJoint> {
                     }
                     // Incorrect delimiter.
                     token::CloseDelim(other) => {
-                        let token_str = token_to_string(&self.token);
+                        let mut unclosed_delimiter = None;
+                        let mut candidate = None;
                         if self.last_unclosed_found_span != Some(self.span) {
                             // do not complain about the same unclosed delimiter multiple times
                             self.last_unclosed_found_span = Some(self.span);
-                            let msg = format!("incorrect close delimiter: `{}`", token_str);
-                            let mut err = self.sess.span_diagnostic.struct_span_err(
-                                self.span,
-                                &msg,
-                            );
-                            err.span_label(self.span, "incorrect close delimiter");
                             // This is a conservative error: only report the last unclosed
                             // delimiter. The previous unclosed delimiters could actually be
                             // closed! The parser just hasn't gotten to them yet.
                             if let Some(&(_, sp)) = self.open_braces.last() {
-                                err.span_label(sp, "un-closed delimiter");
+                                unclosed_delimiter = Some(sp);
                             };
                             if let Some(current_padding) = sm.span_to_margin(self.span) {
                                 for (brace, brace_span) in &self.open_braces {
                                     if let Some(padding) = sm.span_to_margin(*brace_span) {
                                         // high likelihood of these two corresponding
                                         if current_padding == padding && brace == &other {
-                                            err.span_label(
-                                                *brace_span,
-                                                "close delimiter possibly meant for this",
-                                            );
+                                            candidate = Some(*brace_span);
                                         }
                                     }
                                 }
                             }
-                            err.emit();
+                            let (tok, _) = self.open_braces.pop().unwrap();
+                            self.unmatched_braces.push(UnmatchedBrace {
+                                expected_delim: tok,
+                                found_delim: other,
+                                found_span: self.span,
+                                unclosed_span: unclosed_delimiter,
+                                candidate_span: candidate,
+                            });
+                        } else {
+                            self.open_braces.pop();
                         }
-                        self.open_braces.pop().unwrap();
 
                         // If the incorrect delimiter matches an earlier opening
                         // delimiter, then don't consume it (it can be used to
index c723d591f2fb2d1b571c92f3efb30fb258db4dca..317d69332078687460da9cae9243bac8eff3a954 100644 (file)
@@ -9,6 +9,7 @@
 use crate::symbol::Symbol;
 use crate::tokenstream::{TokenStream, TokenTree};
 use crate::diagnostics::plugin::ErrorMap;
+use crate::print::pprust::token_to_string;
 
 use rustc_data_structures::sync::{Lrc, Lock};
 use syntax_pos::{Span, SourceFile, FileName, MultiSpan};
@@ -136,15 +137,17 @@ pub fn parse_crate_attrs_from_source_str(name: FileName, source: String, sess: &
     new_parser_from_source_str(sess, name, source).parse_inner_attributes()
 }
 
-pub fn parse_stream_from_source_str(name: FileName, source: String, sess: &ParseSess,
-                                    override_span: Option<Span>)
-                                    -> TokenStream {
+pub fn parse_stream_from_source_str(
+    name: FileName,
+    source: String,
+    sess: &ParseSess,
+    override_span: Option<Span>,
+) -> (TokenStream, Vec<lexer::UnmatchedBrace>) {
     source_file_to_stream(sess, sess.source_map().new_source_file(name, source), override_span)
 }
 
 /// Create a new parser from a source string
-pub fn new_parser_from_source_str(sess: &ParseSess, name: FileName, source: String)
-                                      -> Parser<'_> {
+pub fn new_parser_from_source_str(sess: &ParseSess, name: FileName, source: String) -> Parser<'_> {
     panictry_buffer!(&sess.span_diagnostic, maybe_new_parser_from_source_str(sess, name, source))
 }
 
@@ -195,12 +198,14 @@ fn source_file_to_parser(sess: &ParseSess, source_file: Lrc<SourceFile>) -> Pars
 
 /// Given a source_file and config, return a parser. Returns any buffered errors from lexing the
 /// initial token stream.
-fn maybe_source_file_to_parser(sess: &ParseSess, source_file: Lrc<SourceFile>)
-    -> Result<Parser<'_>, Vec<Diagnostic>>
-{
+fn maybe_source_file_to_parser(
+    sess: &ParseSess,
+    source_file: Lrc<SourceFile>,
+) -> Result<Parser<'_>, Vec<Diagnostic>> {
     let end_pos = source_file.end_pos;
-    let mut parser = stream_to_parser(sess, maybe_file_to_stream(sess, source_file, None)?);
-
+    let (stream, unclosed_delims) = maybe_file_to_stream(sess, source_file, None)?;
+    let mut parser = stream_to_parser(sess, stream);
+    parser.unclosed_delims = unclosed_delims;
     if parser.token == token::Eof && parser.span.is_dummy() {
         parser.span = Span::new(end_pos, end_pos, parser.span.ctxt());
     }
@@ -247,25 +252,44 @@ fn file_to_source_file(sess: &ParseSess, path: &Path, spanopt: Option<Span>)
 }
 
 /// Given a source_file, produce a sequence of token-trees
-pub fn source_file_to_stream(sess: &ParseSess,
-                             source_file: Lrc<SourceFile>,
-                             override_span: Option<Span>) -> TokenStream {
+pub fn source_file_to_stream(
+    sess: &ParseSess,
+    source_file: Lrc<SourceFile>,
+    override_span: Option<Span>,
+) -> (TokenStream, Vec<lexer::UnmatchedBrace>) {
     panictry_buffer!(&sess.span_diagnostic, maybe_file_to_stream(sess, source_file, override_span))
 }
 
 /// Given a source file, produce a sequence of token-trees. Returns any buffered errors from
 /// parsing the token tream.
-pub fn maybe_file_to_stream(sess: &ParseSess,
-                            source_file: Lrc<SourceFile>,
-                            override_span: Option<Span>) -> Result<TokenStream, Vec<Diagnostic>> {
+pub fn maybe_file_to_stream(
+    sess: &ParseSess,
+    source_file: Lrc<SourceFile>,
+    override_span: Option<Span>,
+) -> Result<(TokenStream, Vec<lexer::UnmatchedBrace>), Vec<Diagnostic>> {
     let mut srdr = lexer::StringReader::new_or_buffered_errs(sess, source_file, override_span)?;
     srdr.real_token();
 
     match srdr.parse_all_token_trees() {
-        Ok(stream) => Ok(stream),
+        Ok(stream) => Ok((stream, srdr.unmatched_braces)),
         Err(err) => {
             let mut buffer = Vec::with_capacity(1);
             err.buffer(&mut buffer);
+            // Not using `emit_unclosed_delims` to use `db.buffer`
+            for unmatched in srdr.unmatched_braces {
+                let mut db = sess.span_diagnostic.struct_span_err(unmatched.found_span, &format!(
+                    "incorrect close delimiter: `{}`",
+                    token_to_string(&token::Token::CloseDelim(unmatched.found_delim)),
+                ));
+                db.span_label(unmatched.found_span, "incorrect close delimiter");
+                if let Some(sp) = unmatched.candidate_span {
+                    db.span_label(sp, "close delimiter possibly meant for this");
+                }
+                if let Some(sp) = unmatched.unclosed_span {
+                    db.span_label(sp, "un-closed delimiter");
+                }
+                db.buffer(&mut buffer);
+            }
             Err(buffer)
         }
     }
index cacdab980facde315770f3b5d33a07ded5e3647f..69d6407d506fb0bc17dc89851f731c4d83a613b5 100644 (file)
@@ -35,7 +35,7 @@
 use crate::source_map::{self, SourceMap, Spanned, respan};
 use crate::errors::{self, Applicability, DiagnosticBuilder, DiagnosticId};
 use crate::parse::{self, SeqSep, classify, token};
-use crate::parse::lexer::TokenAndSpan;
+use crate::parse::lexer::{TokenAndSpan, UnmatchedBrace};
 use crate::parse::lexer::comments::{doc_comment_style, strip_doc_comment_decoration};
 use crate::parse::token::DelimToken;
 use crate::parse::{new_sub_parser_from_file, ParseSess, Directory, DirectoryOwnership};
@@ -251,6 +251,11 @@ pub struct Parser<'a> {
     ///
     /// See the comments in the `parse_path_segment` function for more details.
     crate unmatched_angle_bracket_count: u32,
+    crate max_angle_bracket_count: u32,
+    /// List of all unclosed delimiters found by the lexer. If an entry is used for error recovery
+    /// it gets removed from here. Every entry left at the end gets emitted as an independent
+    /// error.
+    crate unclosed_delims: Vec<UnmatchedBrace>,
 }
 
 
@@ -397,6 +402,7 @@ fn next_desugared(&mut self) -> TokenAndSpan {
     Ident,
     Path,
     Type,
+    Const,
 }
 
 impl TokenType {
@@ -409,6 +415,7 @@ fn to_string(&self) -> String {
             TokenType::Ident => "identifier".to_string(),
             TokenType::Path => "path".to_string(),
             TokenType::Type => "type".to_string(),
+            TokenType::Const => "const".to_string(),
         }
     }
 }
@@ -573,6 +580,8 @@ pub fn new(sess: &'a ParseSess,
             desugar_doc_comments,
             cfg_mods: true,
             unmatched_angle_bracket_count: 0,
+            max_angle_bracket_count: 0,
+            unclosed_delims: Vec::new(),
         };
 
         let tok = parser.next_tok();
@@ -642,11 +651,11 @@ fn unexpected_last<T>(&self, t: &token::Token) -> PResult<'a, T> {
 
     /// Expect and consume the token t. Signal an error if
     /// the next token is not t.
-    pub fn expect(&mut self, t: &token::Token) -> PResult<'a,  ()> {
+    pub fn expect(&mut self, t: &token::Token) -> PResult<'a,  bool /* recovered */> {
         if self.expected_tokens.is_empty() {
             if self.token == *t {
                 self.bump();
-                Ok(())
+                Ok(false)
             } else {
                 let token_str = pprust::token_to_string(t);
                 let this_token_str = self.this_token_descr();
@@ -661,6 +670,12 @@ pub fn expect(&mut self, t: &token::Token) -> PResult<'a,  ()> {
                     self.sess.source_map().next_point(self.prev_span)
                 };
                 let label_exp = format!("expected `{}`", token_str);
+                match self.recover_closing_delimiter(&[t.clone()], err) {
+                    Err(e) => err = e,
+                    Ok(recovered) => {
+                        return Ok(recovered);
+                    }
+                }
                 let cm = self.sess.source_map();
                 match (cm.lookup_line(self.span.lo()), cm.lookup_line(sp.lo())) {
                     (Ok(ref a), Ok(ref b)) if a.line == b.line => {
@@ -680,12 +695,64 @@ pub fn expect(&mut self, t: &token::Token) -> PResult<'a,  ()> {
         }
     }
 
+    fn recover_closing_delimiter(
+        &mut self,
+        tokens: &[token::Token],
+        mut err: DiagnosticBuilder<'a>,
+    ) -> PResult<'a, bool> {
+        let mut pos = None;
+        // we want to use the last closing delim that would apply
+        for (i, unmatched) in self.unclosed_delims.iter().enumerate().rev() {
+            if tokens.contains(&token::CloseDelim(unmatched.expected_delim))
+                && Some(self.span) > unmatched.unclosed_span
+            {
+                pos = Some(i);
+            }
+        }
+        match pos {
+            Some(pos) => {
+                // Recover and assume that the detected unclosed delimiter was meant for
+                // this location. Emit the diagnostic and act as if the delimiter was
+                // present for the parser's sake.
+
+                 // Don't attempt to recover from this unclosed delimiter more than once.
+                let unmatched = self.unclosed_delims.remove(pos);
+                let delim = TokenType::Token(token::CloseDelim(unmatched.expected_delim));
+
+                 // We want to suggest the inclusion of the closing delimiter where it makes
+                // the most sense, which is immediately after the last token:
+                //
+                //  {foo(bar {}}
+                //      -      ^
+                //      |      |
+                //      |      help: `)` may belong here (FIXME: #58270)
+                //      |
+                //      unclosed delimiter
+                if let Some(sp) = unmatched.unclosed_span {
+                    err.span_label(sp, "unclosed delimiter");
+                }
+                err.span_suggestion_short(
+                    self.sess.source_map().next_point(self.prev_span),
+                    &format!("{} may belong here", delim.to_string()),
+                    delim.to_string(),
+                    Applicability::MaybeIncorrect,
+                );
+                err.emit();
+                self.expected_tokens.clear();  // reduce errors
+                Ok(true)
+            }
+            _ => Err(err),
+        }
+    }
+
     /// Expect next token to be edible or inedible token.  If edible,
     /// then consume it; if inedible, then return without consuming
     /// anything.  Signal a fatal error if next token is unexpected.
-    pub fn expect_one_of(&mut self,
-                         edible: &[token::Token],
-                         inedible: &[token::Token]) -> PResult<'a,  ()>{
+    pub fn expect_one_of(
+        &mut self,
+        edible: &[token::Token],
+        inedible: &[token::Token],
+    ) -> PResult<'a, bool /* recovered */> {
         fn tokens_to_string(tokens: &[TokenType]) -> String {
             let mut i = tokens.iter();
             // This might be a sign we need a connect method on Iterator.
@@ -705,10 +772,10 @@ fn tokens_to_string(tokens: &[TokenType]) -> String {
         }
         if edible.contains(&self.token) {
             self.bump();
-            Ok(())
+            Ok(false)
         } else if inedible.contains(&self.token) {
             // leave it in the input
-            Ok(())
+            Ok(false)
         } else {
             let mut expected = edible.iter()
                 .map(|x| TokenType::Token(x.clone()))
@@ -759,6 +826,15 @@ fn tokens_to_string(tokens: &[TokenType]) -> String {
             } else {
                 label_sp
             };
+            match self.recover_closing_delimiter(&expected.iter().filter_map(|tt| match tt {
+                TokenType::Token(t) => Some(t.clone()),
+                _ => None,
+            }).collect::<Vec<_>>(), err) {
+                Err(e) => err = e,
+                Ok(recovered) => {
+                    return Ok(recovered);
+                }
+            }
 
             let cm = self.sess.source_map();
             match (cm.lookup_line(self.span.lo()), cm.lookup_line(sp.lo())) {
@@ -946,6 +1022,15 @@ fn check_type(&mut self) -> bool {
         }
     }
 
+    fn check_const_arg(&mut self) -> bool {
+        if self.token.can_begin_const_arg() {
+            true
+        } else {
+            self.expected_tokens.push(TokenType::Const);
+            false
+        }
+    }
+
     /// Expect and consume a `+`. if `+=` is seen, replace it with a `=`
     /// and continue. If a `+` is not seen, return false.
     ///
@@ -1031,7 +1116,8 @@ fn expect_no_suffix(&self, sp: Span, kind: &str, suffix: Option<ast::Name>) {
     }
 
     /// Attempt to consume a `<`. If `<<` is seen, replace it with a single
-    /// `<` and continue. If a `<` is not seen, return false.
+    /// `<` and continue. If `<-` is seen, replace it with a single `<`
+    /// and continue. If a `<` is not seen, return false.
     ///
     /// This is meant to be used when parsing generics on a path to get the
     /// starting token.
@@ -1047,12 +1133,18 @@ fn eat_lt(&mut self) -> bool {
                 self.bump_with(token::Lt, span);
                 true
             }
+            token::LArrow => {
+                let span = self.span.with_lo(self.span.lo() + BytePos(1));
+                self.bump_with(token::BinOp(token::Minus), span);
+                true
+            }
             _ => false,
         };
 
         if ate {
             // See doc comment for `unmatched_angle_bracket_count`.
             self.unmatched_angle_bracket_count += 1;
+            self.max_angle_bracket_count += 1;
             debug!("eat_lt: (increment) count={:?}", self.unmatched_angle_bracket_count);
         }
 
@@ -1093,12 +1185,12 @@ fn expect_gt(&mut self) -> PResult<'a, ()> {
         };
 
         match ate {
-            Some(x) => {
+            Some(_) => {
                 // See doc comment for `unmatched_angle_bracket_count`.
                 self.unmatched_angle_bracket_count -= 1;
                 debug!("expect_gt: (decrement) count={:?}", self.unmatched_angle_bracket_count);
 
-                Ok(x)
+                Ok(())
             },
             None => self.unexpected(),
         }
@@ -1127,19 +1219,22 @@ pub fn parse_seq_to_end<T, F>(&mut self,
                                   -> PResult<'a, Vec<T>> where
         F: FnMut(&mut Parser<'a>) -> PResult<'a,  T>,
     {
-        let val = self.parse_seq_to_before_end(ket, sep, f)?;
-        self.bump();
+        let (val, recovered) = self.parse_seq_to_before_end(ket, sep, f)?;
+        if !recovered {
+            self.bump();
+        }
         Ok(val)
     }
 
     /// Parse a sequence, not including the closing delimiter. The function
     /// f must consume tokens until reaching the next separator or
     /// closing bracket.
-    pub fn parse_seq_to_before_end<T, F>(&mut self,
-                                         ket: &token::Token,
-                                         sep: SeqSep,
-                                         f: F)
-                                         -> PResult<'a, Vec<T>>
+    pub fn parse_seq_to_before_end<T, F>(
+        &mut self,
+        ket: &token::Token,
+        sep: SeqSep,
+        f: F,
+    ) -> PResult<'a, (Vec<T>, bool)>
         where F: FnMut(&mut Parser<'a>) -> PResult<'a, T>
     {
         self.parse_seq_to_before_tokens(&[ket], sep, TokenExpectType::Expect, f)
@@ -1151,10 +1246,11 @@ fn parse_seq_to_before_tokens<T, F>(
         sep: SeqSep,
         expect: TokenExpectType,
         mut f: F,
-    ) -> PResult<'a, Vec<T>>
+    ) -> PResult<'a, (Vec<T>, bool /* recovered */)>
         where F: FnMut(&mut Parser<'a>) -> PResult<'a, T>
     {
-        let mut first: bool = true;
+        let mut first = true;
+        let mut recovered = false;
         let mut v = vec![];
         while !kets.iter().any(|k| {
                 match expect {
@@ -1170,23 +1266,30 @@ fn parse_seq_to_before_tokens<T, F>(
                 if first {
                     first = false;
                 } else {
-                    if let Err(mut e) = self.expect(t) {
-                        // Attempt to keep parsing if it was a similar separator
-                        if let Some(ref tokens) = t.similar_tokens() {
-                            if tokens.contains(&self.token) {
-                                self.bump();
-                            }
+                    match self.expect(t) {
+                        Ok(false) => {}
+                        Ok(true) => {
+                            recovered = true;
+                            break;
                         }
-                        e.emit();
-                        // Attempt to keep parsing if it was an omitted separator
-                        match f(self) {
-                            Ok(t) => {
-                                v.push(t);
-                                continue;
-                            },
-                            Err(mut e) => {
-                                e.cancel();
-                                break;
+                        Err(mut e) => {
+                            // Attempt to keep parsing if it was a similar separator
+                            if let Some(ref tokens) = t.similar_tokens() {
+                                if tokens.contains(&self.token) {
+                                    self.bump();
+                                }
+                            }
+                            e.emit();
+                            // Attempt to keep parsing if it was an omitted separator
+                            match f(self) {
+                                Ok(t) => {
+                                    v.push(t);
+                                    continue;
+                                },
+                                Err(mut e) => {
+                                    e.cancel();
+                                    break;
+                                }
                             }
                         }
                     }
@@ -1205,23 +1308,26 @@ fn parse_seq_to_before_tokens<T, F>(
             v.push(t);
         }
 
-        Ok(v)
+        Ok((v, recovered))
     }
 
     /// Parse a sequence, including the closing delimiter. The function
     /// f must consume tokens until reaching the next separator or
     /// closing bracket.
-    fn parse_unspanned_seq<T, F>(&mut self,
-                                     bra: &token::Token,
-                                     ket: &token::Token,
-                                     sep: SeqSep,
-                                     f: F)
-                                     -> PResult<'a, Vec<T>> where
+    fn parse_unspanned_seq<T, F>(
+        &mut self,
+        bra: &token::Token,
+        ket: &token::Token,
+        sep: SeqSep,
+        f: F,
+    ) -> PResult<'a, Vec<T>> where
         F: FnMut(&mut Parser<'a>) -> PResult<'a, T>,
     {
         self.expect(bra)?;
-        let result = self.parse_seq_to_before_end(ket, sep, f)?;
-        self.eat(ket);
+        let (result, recovered) = self.parse_seq_to_before_end(ket, sep, f)?;
+        if !recovered {
+            self.eat(ket);
+        }
         Ok(result)
     }
 
@@ -2273,7 +2379,10 @@ fn parse_path_segment(&mut self, style: PathStyle, enable_warning: bool)
             // We use `style == PathStyle::Expr` to check if this is in a recursion or not. If
             // it isn't, then we reset the unmatched angle bracket count as we're about to start
             // parsing a new path.
-            if style == PathStyle::Expr { self.unmatched_angle_bracket_count = 0; }
+            if style == PathStyle::Expr {
+                self.unmatched_angle_bracket_count = 0;
+                self.max_angle_bracket_count = 0;
+            }
 
             let args = if self.eat_lt() {
                 // `<'a, T, A = U>`
@@ -2285,12 +2394,14 @@ fn parse_path_segment(&mut self, style: PathStyle, enable_warning: bool)
             } else {
                 // `(T, U) -> R`
                 self.bump(); // `(`
-                let inputs = self.parse_seq_to_before_tokens(
+                let (inputs, recovered) = self.parse_seq_to_before_tokens(
                     &[&token::CloseDelim(token::Paren)],
                     SeqSep::trailing_allowed(token::Comma),
                     TokenExpectType::Expect,
                     |p| p.parse_ty())?;
-                self.bump(); // `)`
+                if !recovered {
+                    self.bump(); // `)`
+                }
                 let span = lo.to(self.prev_span);
                 let output = if self.eat(&token::RArrow) {
                     Some(self.parse_ty_common(false, false)?)
@@ -2496,9 +2607,13 @@ fn parse_bottom_expr(&mut self) -> PResult<'a, P<Expr>> {
                 // (e,) is a tuple with only one field, e
                 let mut es = vec![];
                 let mut trailing_comma = false;
+                let mut recovered = false;
                 while self.token != token::CloseDelim(token::Paren) {
                     es.push(self.parse_expr()?);
-                    self.expect_one_of(&[], &[token::Comma, token::CloseDelim(token::Paren)])?;
+                    recovered = self.expect_one_of(
+                        &[],
+                        &[token::Comma, token::CloseDelim(token::Paren)],
+                    )?;
                     if self.eat(&token::Comma) {
                         trailing_comma = true;
                     } else {
@@ -2506,7 +2621,9 @@ fn parse_bottom_expr(&mut self) -> PResult<'a, P<Expr>> {
                         break;
                     }
                 }
-                self.bump();
+                if !recovered {
+                    self.bump();
+                }
 
                 hi = self.prev_span;
                 ex = if es.len() == 1 && !trailing_comma {
@@ -2703,6 +2820,21 @@ fn parse_bottom_expr(&mut self) -> PResult<'a, P<Expr>> {
                     hi = pth.span;
                     ex = ExprKind::Path(None, pth);
                 } else {
+                    if !self.unclosed_delims.is_empty() && self.check(&token::Semi) {
+                        // Don't complain about bare semicolons after unclosed braces
+                        // recovery in order to keep the error count down. Fixing the
+                        // delimiters will possibly also fix the bare semicolon found in
+                        // expression context. For example, silence the following error:
+                        // ```
+                        // error: expected expression, found `;`
+                        //  --> file.rs:2:13
+                        //   |
+                        // 2 |     foo(bar(;
+                        //   |             ^ expected expression
+                        // ```
+                        self.bump();
+                        return Ok(self.mk_expr(self.span, ExprKind::Err, ThinVec::new()));
+                    }
                     match self.parse_literal_maybe_minus() {
                         Ok(expr) => {
                             hi = expr.span;
@@ -2802,7 +2934,7 @@ fn parse_struct_expr(&mut self, lo: Span, pth: ast::Path, mut attrs: ThinVec<Att
 
             match self.expect_one_of(&[token::Comma],
                                      &[token::CloseDelim(token::Brace)]) {
-                Ok(()) => if let Some(f) = parsed_field.or(recovery_field) {
+                Ok(_) => if let Some(f) = parsed_field.or(recovery_field) {
                     // only include the field if there's no parse error for the field name
                     fields.push(f);
                 }
@@ -5482,15 +5614,27 @@ fn parse_trait_item_assoc_ty(&mut self)
         Ok((ident, TraitItemKind::Type(bounds, default), generics))
     }
 
+    fn parse_const_param(&mut self, preceding_attrs: Vec<Attribute>) -> PResult<'a, GenericParam> {
+        self.expect_keyword(keywords::Const)?;
+        let ident = self.parse_ident()?;
+        self.expect(&token::Colon)?;
+        let ty = self.parse_ty()?;
+
+        Ok(GenericParam {
+            ident,
+            id: ast::DUMMY_NODE_ID,
+            attrs: preceding_attrs.into(),
+            bounds: Vec::new(),
+            kind: GenericParamKind::Const {
+                ty,
+            }
+        })
+    }
+
     /// Parses (possibly empty) list of lifetime and type parameters, possibly including
     /// trailing comma and erroneous trailing attributes.
     crate fn parse_generic_params(&mut self) -> PResult<'a, Vec<ast::GenericParam>> {
-        let mut lifetimes = Vec::new();
         let mut params = Vec::new();
-        let mut seen_ty_param: Option<Span> = None;
-        let mut last_comma_span = None;
-        let mut bad_lifetime_pos = vec![];
-        let mut suggestions = vec![];
         loop {
             let attrs = self.parse_outer_attributes()?;
             if self.check_lifetime() {
@@ -5501,39 +5645,40 @@ fn parse_trait_item_assoc_ty(&mut self)
                 } else {
                     Vec::new()
                 };
-                lifetimes.push(ast::GenericParam {
+                params.push(ast::GenericParam {
                     ident: lifetime.ident,
                     id: lifetime.id,
                     attrs: attrs.into(),
                     bounds,
                     kind: ast::GenericParamKind::Lifetime,
                 });
-                if let Some(sp) = seen_ty_param {
-                    let remove_sp = last_comma_span.unwrap_or(self.prev_span).to(self.prev_span);
-                    bad_lifetime_pos.push(self.prev_span);
-                    if let Ok(snippet) = self.sess.source_map().span_to_snippet(self.prev_span) {
-                        suggestions.push((remove_sp, String::new()));
-                        suggestions.push((
-                            sp.shrink_to_lo(),
-                            format!("{}, ", snippet)));
-                    }
-                }
+            } else if self.check_keyword(keywords::Const) {
+                // Parse const parameter.
+                params.push(self.parse_const_param(attrs)?);
             } else if self.check_ident() {
                 // Parse type parameter.
                 params.push(self.parse_ty_param(attrs)?);
-                if seen_ty_param.is_none() {
-                    seen_ty_param = Some(self.prev_span);
-                }
             } else {
                 // Check for trailing attributes and stop parsing.
                 if !attrs.is_empty() {
-                    let param_kind = if seen_ty_param.is_some() { "type" } else { "lifetime" };
-                    self.struct_span_err(
-                        attrs[0].span,
-                        &format!("trailing attribute after {} parameters", param_kind),
-                    )
-                    .span_label(attrs[0].span, "attributes must go before parameters")
-                    .emit();
+                    if !params.is_empty() {
+                        self.struct_span_err(
+                            attrs[0].span,
+                            &format!("trailing attribute after generic parameter"),
+                        )
+                        .span_label(attrs[0].span, "attributes must go before parameters")
+                        .emit();
+                    } else {
+                        self.struct_span_err(
+                            attrs[0].span,
+                            &format!("attribute without generic parameters"),
+                        )
+                        .span_label(
+                            attrs[0].span,
+                            "attributes are only permitted when preceding parameters",
+                        )
+                        .emit();
+                    }
                 }
                 break
             }
@@ -5541,24 +5686,8 @@ fn parse_trait_item_assoc_ty(&mut self)
             if !self.eat(&token::Comma) {
                 break
             }
-            last_comma_span = Some(self.prev_span);
-        }
-        if !bad_lifetime_pos.is_empty() {
-            let mut err = self.struct_span_err(
-                bad_lifetime_pos,
-                "lifetime parameters must be declared prior to type parameters",
-            );
-            if !suggestions.is_empty() {
-                err.multipart_suggestion(
-                    "move the lifetime parameter prior to the first type parameter",
-                    suggestions,
-                    Applicability::MachineApplicable,
-                );
-            }
-            err.emit();
         }
-        lifetimes.extend(params);  // ensure the correct order of lifetimes and type params
-        Ok(lifetimes)
+        Ok(params)
     }
 
     /// Parse a set of optional generic type parameter declarations. Where
@@ -5740,35 +5869,16 @@ fn parse_generic_args_with_leaning_angle_bracket_recovery(
     fn parse_generic_args(&mut self) -> PResult<'a, (Vec<GenericArg>, Vec<TypeBinding>)> {
         let mut args = Vec::new();
         let mut bindings = Vec::new();
+        let mut misplaced_assoc_ty_bindings: Vec<Span> = Vec::new();
+        let mut assoc_ty_bindings: Vec<Span> = Vec::new();
 
-        let mut seen_type = false;
-        let mut seen_binding = false;
-
-        let mut last_comma_span = None;
-        let mut first_type_or_binding_span: Option<Span> = None;
-        let mut first_binding_span: Option<Span> = None;
-
-        let mut bad_lifetime_pos = vec![];
-        let mut bad_type_pos = vec![];
+        let args_lo = self.span;
 
-        let mut lifetime_suggestions = vec![];
-        let mut type_suggestions = vec![];
         loop {
             if self.check_lifetime() && self.look_ahead(1, |t| !t.is_like_plus()) {
                 // Parse lifetime argument.
                 args.push(GenericArg::Lifetime(self.expect_lifetime()));
-
-                if seen_type || seen_binding {
-                    let remove_sp = last_comma_span.unwrap_or(self.prev_span).to(self.prev_span);
-                    bad_lifetime_pos.push(self.prev_span);
-
-                    if let Ok(snippet) = self.sess.source_map().span_to_snippet(self.prev_span) {
-                        lifetime_suggestions.push((remove_sp, String::new()));
-                        lifetime_suggestions.push((
-                            first_type_or_binding_span.unwrap().shrink_to_lo(),
-                            format!("{}, ", snippet)));
-                    }
-                }
+                misplaced_assoc_ty_bindings.append(&mut assoc_ty_bindings);
             } else if self.check_ident() && self.look_ahead(1, |t| t == &token::Eq) {
                 // Parse associated type binding.
                 let lo = self.span;
@@ -5782,131 +5892,64 @@ fn parse_generic_args(&mut self) -> PResult<'a, (Vec<GenericArg>, Vec<TypeBindin
                     ty,
                     span,
                 });
-
-                seen_binding = true;
-                if first_type_or_binding_span.is_none() {
-                    first_type_or_binding_span = Some(span);
-                }
-                if first_binding_span.is_none() {
-                    first_binding_span = Some(span);
-                }
+                assoc_ty_bindings.push(span);
+            } else if self.check_const_arg() {
+                // FIXME(const_generics): to distinguish between idents for types and consts,
+                // we should introduce a GenericArg::Ident in the AST and distinguish when
+                // lowering to the HIR. For now, idents for const args are not permitted.
+
+                // Parse const argument.
+                let expr = if let token::OpenDelim(token::Brace) = self.token {
+                    self.parse_block_expr(None, self.span, BlockCheckMode::Default, ThinVec::new())?
+                } else if self.token.is_ident() {
+                    // FIXME(const_generics): to distinguish between idents for types and consts,
+                    // we should introduce a GenericArg::Ident in the AST and distinguish when
+                    // lowering to the HIR. For now, idents for const args are not permitted.
+                    return Err(
+                        self.fatal("identifiers may currently not be used for const generics")
+                    );
+                } else {
+                    // FIXME(const_generics): this currently conflicts with emplacement syntax
+                    // with negative integer literals.
+                    self.parse_literal_maybe_minus()?
+                };
+                let value = AnonConst {
+                    id: ast::DUMMY_NODE_ID,
+                    value: expr,
+                };
+                args.push(GenericArg::Const(value));
+                misplaced_assoc_ty_bindings.append(&mut assoc_ty_bindings);
             } else if self.check_type() {
                 // Parse type argument.
-                let ty_param = self.parse_ty()?;
-                if seen_binding {
-                    let remove_sp = last_comma_span.unwrap_or(self.prev_span).to(self.prev_span);
-                    bad_type_pos.push(self.prev_span);
-
-                    if let Ok(snippet) = self.sess.source_map().span_to_snippet(self.prev_span) {
-                        type_suggestions.push((remove_sp, String::new()));
-                        type_suggestions.push((
-                            first_binding_span.unwrap().shrink_to_lo(),
-                            format!("{}, ", snippet)));
-                    }
-                }
-
-                if first_type_or_binding_span.is_none() {
-                    first_type_or_binding_span = Some(ty_param.span);
-                }
-                args.push(GenericArg::Type(ty_param));
-                seen_type = true;
+                args.push(GenericArg::Type(self.parse_ty()?));
+                misplaced_assoc_ty_bindings.append(&mut assoc_ty_bindings);
             } else {
                 break
             }
 
             if !self.eat(&token::Comma) {
                 break
-            } else {
-                last_comma_span = Some(self.prev_span);
-            }
-        }
-
-        self.maybe_report_incorrect_generic_argument_order(
-            bad_lifetime_pos, bad_type_pos, lifetime_suggestions, type_suggestions
-        );
-
-        Ok((args, bindings))
-    }
-
-    /// Maybe report an error about incorrect generic argument order - "lifetime parameters
-    /// must be declared before type parameters", "type parameters must be declared before
-    /// associated type bindings" or both.
-    fn maybe_report_incorrect_generic_argument_order(
-        &self,
-        bad_lifetime_pos: Vec<Span>,
-        bad_type_pos: Vec<Span>,
-        lifetime_suggestions: Vec<(Span, String)>,
-        type_suggestions: Vec<(Span, String)>,
-    ) {
-        let mut err = if !bad_lifetime_pos.is_empty() && !bad_type_pos.is_empty() {
-            let mut positions = bad_lifetime_pos.clone();
-            positions.extend_from_slice(&bad_type_pos);
-
-            self.struct_span_err(
-                positions,
-                "generic arguments must declare lifetimes, types and associated type bindings in \
-                 that order",
-            )
-        } else if !bad_lifetime_pos.is_empty() {
-            self.struct_span_err(
-                bad_lifetime_pos.clone(),
-                "lifetime parameters must be declared prior to type parameters"
-            )
-        } else if !bad_type_pos.is_empty() {
-            self.struct_span_err(
-                bad_type_pos.clone(),
-                "type parameters must be declared prior to associated type bindings"
-            )
-        } else {
-            return;
-        };
-
-        if !bad_lifetime_pos.is_empty() {
-            for sp in &bad_lifetime_pos {
-                err.span_label(*sp, "must be declared prior to type parameters");
             }
         }
 
-        if !bad_type_pos.is_empty() {
-            for sp in &bad_type_pos {
-                err.span_label(*sp, "must be declared prior to associated type bindings");
-            }
-        }
-
-        if !lifetime_suggestions.is_empty() && !type_suggestions.is_empty() {
-            let mut suggestions = lifetime_suggestions;
-            suggestions.extend_from_slice(&type_suggestions);
-
-            let plural = bad_lifetime_pos.len() + bad_type_pos.len() > 1;
-            err.multipart_suggestion(
-                &format!(
-                    "move the parameter{}",
-                    if plural { "s" } else { "" },
-                ),
-                suggestions,
-                Applicability::MachineApplicable,
-            );
-        } else if !lifetime_suggestions.is_empty() {
-            err.multipart_suggestion(
-                &format!(
-                    "move the lifetime parameter{} prior to the first type parameter",
-                    if bad_lifetime_pos.len() > 1 { "s" } else { "" },
-                ),
-                lifetime_suggestions,
-                Applicability::MachineApplicable,
-            );
-        } else if !type_suggestions.is_empty() {
-            err.multipart_suggestion(
-                &format!(
-                    "move the type parameter{} prior to the first associated type binding",
-                    if bad_type_pos.len() > 1 { "s" } else { "" },
-                ),
-                type_suggestions,
-                Applicability::MachineApplicable,
+        // FIXME: we would like to report this in ast_validation instead, but we currently do not
+        // preserve ordering of generic parameters with respect to associated type binding, so we
+        // lose that information after parsing.
+        if misplaced_assoc_ty_bindings.len() > 0 {
+            let mut err = self.struct_span_err(
+                args_lo.to(self.prev_span),
+                "associated type bindings must be declared after generic parameters",
             );
+            for span in misplaced_assoc_ty_bindings {
+                err.span_label(
+                    span,
+                    "this associated type binding should be moved after the generic parameters",
+                );
+            }
+            err.emit();
         }
 
-        err.emit();
+        Ok((args, bindings))
     }
 
     /// Parses an optional `where` clause and places it in `generics`.
@@ -6011,7 +6054,7 @@ fn parse_fn_args(&mut self, named_args: bool, allow_variadic: bool)
 
         let sp = self.span;
         let mut variadic = false;
-        let args: Vec<Option<Arg>> =
+        let (args, recovered): (Vec<Option<Arg>>, bool) =
             self.parse_seq_to_before_end(
                 &token::CloseDelim(token::Paren),
                 SeqSep::trailing_allowed(token::Comma),
@@ -6059,7 +6102,9 @@ fn parse_fn_args(&mut self, named_args: bool, allow_variadic: bool)
                 }
             )?;
 
-        self.eat(&token::CloseDelim(token::Paren));
+        if !recovered {
+            self.eat(&token::CloseDelim(token::Paren));
+        }
 
         let args: Vec<_> = args.into_iter().filter_map(|x| x).collect();
 
@@ -6204,15 +6249,15 @@ fn parse_fn_decl_with_self<F>(&mut self, parse_arg_fn: F) -> PResult<'a, P<FnDec
 
         // Parse the rest of the function parameter list.
         let sep = SeqSep::trailing_allowed(token::Comma);
-        let fn_inputs = if let Some(self_arg) = self_arg {
+        let (fn_inputs, recovered) = if let Some(self_arg) = self_arg {
             if self.check(&token::CloseDelim(token::Paren)) {
-                vec![self_arg]
+                (vec![self_arg], false)
             } else if self.eat(&token::Comma) {
                 let mut fn_inputs = vec![self_arg];
-                fn_inputs.append(&mut self.parse_seq_to_before_end(
-                    &token::CloseDelim(token::Paren), sep, parse_arg_fn)?
-                );
-                fn_inputs
+                let (mut input, recovered) = self.parse_seq_to_before_end(
+                    &token::CloseDelim(token::Paren), sep, parse_arg_fn)?;
+                fn_inputs.append(&mut input);
+                (fn_inputs, recovered)
             } else {
                 return self.unexpected();
             }
@@ -6220,8 +6265,10 @@ fn parse_fn_decl_with_self<F>(&mut self, parse_arg_fn: F) -> PResult<'a, P<FnDec
             self.parse_seq_to_before_end(&token::CloseDelim(token::Paren), sep, parse_arg_fn)?
         };
 
-        // Parse closing paren and return type.
-        self.expect(&token::CloseDelim(token::Paren))?;
+        if !recovered {
+            // Parse closing paren and return type.
+            self.expect(&token::CloseDelim(token::Paren))?;
+        }
         Ok(P(FnDecl {
             inputs: fn_inputs,
             output: self.parse_ret_ty(true)?,
@@ -6241,7 +6288,7 @@ fn parse_fn_block_decl(&mut self) -> PResult<'a, P<FnDecl>> {
                     SeqSep::trailing_allowed(token::Comma),
                     TokenExpectType::NoExpect,
                     |p| p.parse_fn_block_arg()
-                )?;
+                )?.0;
                 self.expect_or()?;
                 args
             }
@@ -6526,6 +6573,7 @@ fn choose_generics_over_qpath(&self) -> bool {
         //     `<` (LIFETIME|IDENT) `,` - first generic parameter in a list
         //     `<` (LIFETIME|IDENT) `:` - generic parameter with bounds
         //     `<` (LIFETIME|IDENT) `=` - generic parameter with a default
+        //     `<` const                - generic const parameter
         // The only truly ambiguous case is
         //     `<` IDENT `>` `::` IDENT ...
         // we disambiguate it in favor of generics (`impl<T> ::absolute::Path<T> { ... }`)
@@ -6535,7 +6583,8 @@ fn choose_generics_over_qpath(&self) -> bool {
             (self.look_ahead(1, |t| t == &token::Pound || t == &token::Gt) ||
              self.look_ahead(1, |t| t.is_lifetime() || t.is_ident()) &&
                 self.look_ahead(2, |t| t == &token::Gt || t == &token::Comma ||
-                                       t == &token::Colon || t == &token::Eq))
+                                       t == &token::Colon || t == &token::Eq) ||
+             self.look_ahead(1, |t| t.is_keyword(keywords::Const)))
     }
 
     fn parse_impl_body(&mut self) -> PResult<'a, (Vec<ImplItem>, Vec<Attribute>)> {
@@ -8238,7 +8287,7 @@ fn parse_assoc_macro_invoc(&mut self, item_kind: &str, vis: Option<&Visibility>,
             // eat a matched-delimiter token tree:
             let (delim, tts) = self.expect_delimited_token_tree()?;
             if delim != MacDelimiter::Brace {
-                self.expect(&token::Semi)?
+                self.expect(&token::Semi)?;
             }
 
             Ok(Some(respan(lo.to(self.prev_span), Mac_ { path: pth, tts, delim })))
@@ -8383,11 +8432,14 @@ fn parse_rename(&mut self) -> PResult<'a, Option<Ident>> {
     /// entry point for the parser.
     pub fn parse_crate_mod(&mut self) -> PResult<'a, Crate> {
         let lo = self.span;
-        Ok(ast::Crate {
+        let krate = Ok(ast::Crate {
             attrs: self.parse_inner_attributes()?,
             module: self.parse_mod_items(&token::Eof, lo)?,
             span: lo.to(self.span),
-        })
+        });
+        emit_unclosed_delims(&self.unclosed_delims, self.diagnostic());
+        self.unclosed_delims.clear();
+        krate
     }
 
     pub fn parse_optional_str(&mut self) -> Option<(Symbol, ast::StrStyle, Option<ast::Name>)> {
@@ -8416,3 +8468,20 @@ pub fn parse_str(&mut self) -> PResult<'a, (Symbol, StrStyle)> {
         }
     }
 }
+
+pub fn emit_unclosed_delims(unclosed_delims: &[UnmatchedBrace], handler: &errors::Handler) {
+    for unmatched in unclosed_delims {
+        let mut err = handler.struct_span_err(unmatched.found_span, &format!(
+            "incorrect close delimiter: `{}`",
+            pprust::token_to_string(&token::Token::CloseDelim(unmatched.found_delim)),
+        ));
+        err.span_label(unmatched.found_span, "incorrect close delimiter");
+        if let Some(sp) = unmatched.candidate_span {
+            err.span_label(sp, "close delimiter possibly meant for this");
+        }
+        if let Some(sp) = unmatched.unclosed_span {
+            err.span_label(sp, "un-closed delimiter");
+        }
+        err.emit();
+    }
+}
index 3b1fa5ea01f541057b7d2084e59eacff29e5ef79..09924e304cfd9c7c5317dd948caefe62b219af6d 100644 (file)
@@ -10,6 +10,7 @@
 use crate::ptr::P;
 use crate::symbol::keywords;
 use crate::syntax::parse::parse_stream_from_source_str;
+use crate::syntax::parse::parser::emit_unclosed_delims;
 use crate::tokenstream::{self, DelimSpan, TokenStream, TokenTree};
 
 use serialize::{Decodable, Decoder, Encodable, Encoder};
@@ -279,6 +280,20 @@ pub fn from_ast_ident(ident: ast::Ident) -> Token {
         }
     }
 
+    /// Returns `true` if the token can appear at the start of a const param.
+    pub fn can_begin_const_arg(&self) -> bool {
+        match self {
+            OpenDelim(Brace) => true,
+            Interpolated(ref nt) => match nt.0 {
+                NtExpr(..) => true,
+                NtBlock(..) => true,
+                NtLiteral(..) => true,
+                _ => false,
+            }
+            _ => self.can_begin_literal_or_bool(),
+        }
+    }
+
     /// Returns `true` if the token can appear at the start of a generic bound.
     crate fn can_begin_bound(&self) -> bool {
         self.is_path_start() || self.is_lifetime() || self.is_keyword(keywords::For) ||
@@ -293,7 +308,7 @@ pub fn from_ast_ident(ident: ast::Ident) -> Token {
         }
     }
 
-    /// Returns `true` if the token is any literal, a minus (which can follow a literal,
+    /// Returns `true` if the token is any literal, a minus (which can prefix a literal,
     /// for example a '-42', or one of the boolean idents).
     crate fn can_begin_literal_or_bool(&self) -> bool {
         match *self {
@@ -487,8 +502,8 @@ pub fn is_reserved_ident(&self) -> bool {
     /// Enables better error recovery when the wrong token is found.
     crate fn similar_tokens(&self) -> Option<Vec<Token>> {
         match *self {
-            Comma => Some(vec![Dot, Lt]),
-            Semi => Some(vec![Colon]),
+            Comma => Some(vec![Dot, Lt, Semi]),
+            Semi => Some(vec![Colon, Comma]),
             _ => None
         }
     }
@@ -545,7 +560,10 @@ pub fn interpolated_to_tokenstream(&self, sess: &ParseSess, span: Span)
             // FIXME(#43081): Avoid this pretty-print + reparse hack
             let source = pprust::token_to_string(self);
             let filename = FileName::macro_expansion_source_code(&source);
-            parse_stream_from_source_str(filename, source, sess, Some(span))
+            let (tokens, errors) = parse_stream_from_source_str(
+                filename, source, sess, Some(span));
+            emit_unclosed_delims(&errors, &sess.span_diagnostic);
+            tokens
         });
 
         // During early phases of the compiler the AST could get modified
@@ -786,12 +804,13 @@ fn prepend_attrs(sess: &ParseSess,
         let source = pprust::attr_to_string(attr);
         let macro_filename = FileName::macro_expansion_source_code(&source);
         if attr.is_sugared_doc {
-            let stream = parse_stream_from_source_str(
+            let (stream, errors) = parse_stream_from_source_str(
                 macro_filename,
                 source,
                 sess,
                 Some(span),
             );
+            emit_unclosed_delims(&errors, &sess.span_diagnostic);
             builder.push(stream);
             continue
         }
@@ -808,12 +827,13 @@ fn prepend_attrs(sess: &ParseSess,
         // ... and for more complicated paths, fall back to a reparse hack that
         // should eventually be removed.
         } else {
-            let stream = parse_stream_from_source_str(
+            let (stream, errors) = parse_stream_from_source_str(
                 macro_filename,
                 source,
                 sess,
                 Some(span),
             );
+            emit_unclosed_delims(&errors, &sess.span_diagnostic);
             brackets.push(stream);
         }
 
index c7c4c4f16205bd74d137bcb0dafefb1bebefd026..c670f47b597da97d098b79ab946d53dbfcb9b128 100644 (file)
@@ -1025,6 +1025,7 @@ pub fn print_generic_arg(&mut self, generic_arg: &GenericArg) -> io::Result<()>
         match generic_arg {
             GenericArg::Lifetime(lt) => self.print_lifetime(*lt),
             GenericArg::Type(ty) => self.print_type(ty),
+            GenericArg::Const(ct) => self.print_expr(&ct.value),
         }
     }
 
@@ -2929,7 +2930,7 @@ pub fn print_generic_params(
                     s.print_outer_attributes_inline(&param.attrs)?;
                     let lt = ast::Lifetime { id: param.id, ident: param.ident };
                     s.print_lifetime_bounds(lt, &param.bounds)
-                },
+                }
                 ast::GenericParamKind::Type { ref default } => {
                     s.print_outer_attributes_inline(&param.attrs)?;
                     s.print_ident(param.ident)?;
@@ -2943,6 +2944,15 @@ pub fn print_generic_params(
                         _ => Ok(())
                     }
                 }
+                ast::GenericParamKind::Const { ref ty } => {
+                    s.print_outer_attributes_inline(&param.attrs)?;
+                    s.word_space("const")?;
+                    s.print_ident(param.ident)?;
+                    s.s.space()?;
+                    s.word_space(":")?;
+                    s.print_type(ty)?;
+                    s.print_type_bounds(":", &param.bounds)
+                }
             }
         })?;
 
index dbe2b8d39f2d06515f68b03a735cd4506c07e2e1..bcf1da66c04b62f5572dc12c4d0e2314f583d686 100644 (file)
 /// Map a string to tts, using a made-up filename:
 pub fn string_to_stream(source_str: String) -> TokenStream {
     let ps = ParseSess::new(FilePathMapping::empty());
-    source_file_to_stream(&ps, ps.source_map()
-                             .new_source_file(PathBuf::from("bogofile").into(), source_str), None)
+    source_file_to_stream(
+        &ps,
+        ps.source_map().new_source_file(PathBuf::from("bogofile").into(),
+        source_str,
+    ), None).0
 }
 
 /// Map string to parser (via tts)
index acbb58a66b6b47f37d44cce571ce890419fbfa80..bb3b0ea7359a8e09f4b7f31310639ffb1270db6b 100644 (file)
@@ -126,6 +126,7 @@ fn visit_generic_arg(&mut self, generic_arg: &'ast GenericArg) {
         match generic_arg {
             GenericArg::Lifetime(lt) => self.visit_lifetime(lt),
             GenericArg::Type(ty) => self.visit_ty(ty),
+            GenericArg::Const(ct) => self.visit_anon_const(ct),
         }
     }
     fn visit_assoc_type_binding(&mut self, type_binding: &'ast TypeBinding) {
@@ -486,6 +487,7 @@ pub fn walk_generic_param<'a, V: Visitor<'a>>(visitor: &mut V, param: &'a Generi
     match param.kind {
         GenericParamKind::Lifetime => {}
         GenericParamKind::Type { ref default } => walk_list!(visitor, visit_ty, default),
+        GenericParamKind::Const { ref ty, .. } => visitor.visit_ty(ty),
     }
 }
 
index e6fe125da9f98eb2e25637d7039cba73bdabf9a5..4678c7520455a10dace790e00f8343e30b04441d 100644 (file)
@@ -560,6 +560,7 @@ fn create_derived_impl(&self,
 
                 cx.typaram(self.span, param.ident, vec![], bounds, None)
             }
+            GenericParamKind::Const { .. } => param.clone(),
         }));
 
         // and similarly for where clauses
@@ -657,6 +658,9 @@ fn create_derived_impl(&self,
             GenericParamKind::Type { .. } => {
                 GenericArg::Type(cx.ty_ident(self.span, param.ident))
             }
+            GenericParamKind::Const { .. } => {
+                GenericArg::Const(cx.const_ident(self.span, param.ident))
+            }
         }).collect();
 
         // Create the type of `self`.
index ea6e07922b2b375396b07753b60d1c10d7c5fd3e..100ec0057ee028ddf62a74110e551ce85b58ec05 100644 (file)
@@ -94,7 +94,7 @@ pub fn to_path(&self,
     }
 }
 
-/// A type. Supports pointers, Self, and literals
+/// A type. Supports pointers, Self, and literals.
 #[derive(Clone)]
 pub enum Ty<'a> {
     Self_,
@@ -107,6 +107,13 @@ pub enum Ty<'a> {
     Tuple(Vec<Ty<'a>>),
 }
 
+/// A const expression. Supports literals and blocks.
+#[derive(Clone, Eq, PartialEq)]
+pub enum Const {
+    Literal,
+    Block,
+}
+
 pub fn borrowed_ptrty<'r>() -> PtrTy<'r> {
     Borrowed(None, ast::Mutability::Immutable)
 }
@@ -180,6 +187,9 @@ pub fn to_path(&self,
                     GenericParamKind::Type { .. } => {
                         GenericArg::Type(cx.ty_ident(span, param.ident))
                     }
+                    GenericParamKind::Const { .. } => {
+                        GenericArg::Const(cx.const_ident(span, param.ident))
+                    }
                 }).collect();
 
                 cx.path_all(span, false, vec![self_ty], params, vec![])
index 730262683c0b7259b2496c68d8d2676f8718ccea..2158cfc089bdd1cbcd9785a7b0b678581b4888a5 100644 (file)
@@ -12,6 +12,7 @@
 use syntax::ext::base::ExtCtxt;
 use syntax::parse::lexer::comments;
 use syntax::parse::{self, token, ParseSess};
+use syntax::parse::parser::emit_unclosed_delims;
 use syntax::tokenstream::{self, DelimSpan, IsJoint::*, TokenStream, TreeAndJoint};
 use syntax_pos::hygiene::{SyntaxContext, Transparency};
 use syntax_pos::symbol::{keywords, Symbol};
@@ -409,12 +410,14 @@ fn is_empty(&mut self, stream: &Self::TokenStream) -> bool {
         stream.is_empty()
     }
     fn from_str(&mut self, src: &str) -> Self::TokenStream {
-        parse::parse_stream_from_source_str(
+        let (tokens, errors) = parse::parse_stream_from_source_str(
             FileName::proc_macro_source_code(src.clone()),
             src.to_string(),
             self.sess,
             Some(self.call_site),
-        )
+        );
+        emit_unclosed_delims(&errors, &self.sess.span_diagnostic);
+        tokens
     }
     fn to_string(&mut self, stream: &Self::TokenStream) -> String {
         stream.to_string()
index f90afce90ee306c3e0b6a3c70c439a59ea52e743..488339b025dcef7b147ef38fe434debd6bb81c7d 100644 (file)
@@ -73,7 +73,7 @@ macro_rules! follow_block {
     ($b:block $t:ty) => {};
     ($b:block $s:stmt) => {};
     ($b:block $p:path) => {};
-    ($b:block $b:block) => {};
+    ($b:block $c:block) => {};
     ($b:block $i:ident) => {};
     ($b:block $t:tt) => {};
     ($b:block $i:item) => {};
@@ -99,9 +99,9 @@ macro_rules! follow_ident {
     ($i:ident $s:stmt) => {};
     ($i:ident $p:path) => {};
     ($i:ident $b:block) => {};
-    ($i:ident $i:ident) => {};
+    ($i:ident $j:ident) => {};
     ($i:ident $t:tt) => {};
-    ($i:ident $i:item) => {};
+    ($i:ident $j:item) => {};
     ($i:ident $m:meta) => {};
 }
 // FOLLOW(tt) = any token
@@ -120,12 +120,12 @@ macro_rules! follow_tt {
     ($t:tt ident) => {};
     ($t:tt $p:pat) => {};
     ($t:tt $e:expr) => {};
-    ($t:tt $t:ty) => {};
+    ($t:tt $v:ty) => {};
     ($t:tt $s:stmt) => {};
     ($t:tt $p:path) => {};
     ($t:tt $b:block) => {};
     ($t:tt $i:ident) => {};
-    ($t:tt $t:tt) => {};
+    ($t:tt $v:tt) => {};
     ($t:tt $i:item) => {};
     ($t:tt $m:meta) => {};
 }
@@ -149,9 +149,9 @@ macro_rules! follow_item {
     ($i:item $s:stmt) => {};
     ($i:item $p:path) => {};
     ($i:item $b:block) => {};
-    ($i:item $i:ident) => {};
+    ($i:item $j:ident) => {};
     ($i:item $t:tt) => {};
-    ($i:item $i:item) => {};
+    ($i:item $j:item) => {};
     ($i:item $m:meta) => {};
 }
 // FOLLOW(meta) = any token
@@ -177,7 +177,7 @@ macro_rules! follow_meta {
     ($m:meta $i:ident) => {};
     ($m:meta $t:tt) => {};
     ($m:meta $i:item) => {};
-    ($m:meta $m:meta) => {};
+    ($m:meta $n:meta) => {};
 }
 
 fn main() {}
diff --git a/src/test/run-pass/methods/method-probe-no-guessing-dyn-trait.rs b/src/test/run-pass/methods/method-probe-no-guessing-dyn-trait.rs
new file mode 100644 (file)
index 0000000..8c8165a
--- /dev/null
@@ -0,0 +1,59 @@
+// Check that method matching does not make "guesses" depending on
+// Deref impls that don't eventually end up being picked.
+
+use std::ops::Deref;
+
+// An impl with less derefs will get called over an impl with more derefs,
+// so `(t: Foo<_>).my_fn()` will use `<Foo<u32> as MyTrait1>::my_fn(t)`,
+// and does *not* force the `_` to equal `()`, because the Deref impl
+// was *not* used.
+
+trait MyTrait1 {
+    fn my_fn(&self) {}
+}
+
+impl MyTrait1 for Foo<u32> {}
+
+struct Foo<T>(T);
+
+impl Deref for Foo<()> {
+    type Target = dyn MyTrait1 + 'static;
+    fn deref(&self) -> &(dyn MyTrait1 + 'static) {
+        panic!()
+    }
+}
+
+// ...but if there is no impl with less derefs, the "guess" will be
+// forced, so `(t: Bar<_>).my_fn2()` is `<dyn MyTrait2 as MyTrait2>::my_fn2(*t)`,
+// and because the deref impl is used, the `_` is forced to equal `u8`.
+
+trait MyTrait2 {
+    fn my_fn2(&self) {}
+}
+
+impl MyTrait2 for u32 {}
+struct Bar<T>(T, u32);
+impl Deref for Bar<u8> {
+    type Target = dyn MyTrait2 + 'static;
+    fn deref(&self) -> &(dyn MyTrait2 + 'static) {
+        &self.1
+    }
+}
+
+// actually invoke things
+
+fn main() {
+    let mut foo: Option<Foo<_>> = None;
+    let mut bar: Option<Bar<_>> = None;
+    let mut first_iter = true;
+    loop {
+        if !first_iter {
+            foo.as_ref().unwrap().my_fn();
+            bar.as_ref().unwrap().my_fn2();
+            break;
+        }
+        foo = Some(Foo(0));
+        bar = Some(Bar(Default::default(), 0));
+        first_iter = false;
+    }
+}
diff --git a/src/test/ui/attribute-with-no-generics-in-parameter-list.rs b/src/test/ui/attribute-with-no-generics-in-parameter-list.rs
new file mode 100644 (file)
index 0000000..c2cc91d
--- /dev/null
@@ -0,0 +1,3 @@
+fn foo<#[attr]>() {} //~ ERROR attribute without generic parameters
+
+fn main() {}
diff --git a/src/test/ui/attribute-with-no-generics-in-parameter-list.stderr b/src/test/ui/attribute-with-no-generics-in-parameter-list.stderr
new file mode 100644 (file)
index 0000000..f08f107
--- /dev/null
@@ -0,0 +1,8 @@
+error: attribute without generic parameters
+  --> $DIR/attribute-with-no-generics-in-parameter-list.rs:1:8
+   |
+LL | fn foo<#[attr]>() {} //~ ERROR attribute without generic parameters
+   |        ^^^^^^^ attributes are only permitted when preceding parameters
+
+error: aborting due to previous error
+
index d7feb03853077b1c098938dec3ec3f1e7d91a52a..ca5fdd9da859bae78bde7f472c409a9b310ec95e 100644 (file)
@@ -7,7 +7,7 @@
 struct RefIntPair<'a, 'b>(&'a u32, &'b u32);
 
 impl<#[rustc_1] 'a, 'b, #[oops]> RefIntPair<'a, 'b> {
-    //~^ ERROR trailing attribute after lifetime parameters
+    //~^ ERROR trailing attribute after generic parameter
 }
 
 fn main() {
index c4c0cee5ccc31fb938a9cb4d3a9b38d289cb0988..55e7a9877846f271a79ac78561a15a13a9823d9c 100644 (file)
@@ -1,4 +1,4 @@
-error: trailing attribute after lifetime parameters
+error: trailing attribute after generic parameter
   --> $DIR/attrs-with-no-formal-in-generics-1.rs:9:25
    |
 LL | impl<#[rustc_1] 'a, 'b, #[oops]> RefIntPair<'a, 'b> {
index f9db6a5f72af9fb303d17dd4a184126424fcdcc6..c795612acf08c13a59b92d967a4d332905182ec9 100644 (file)
@@ -7,6 +7,6 @@
 struct RefAny<'a, T>(&'a T);
 
 impl<#[rustc_1] 'a, #[rustc_2] T, #[oops]> RefAny<'a, T> {}
-//~^ ERROR trailing attribute after type parameters
+//~^ ERROR trailing attribute after generic parameter
 
 fn main() {}
index 9099d74ce1be9e846a9d49b4ad192a8b3cceb970..acd0ae3678a7c275d10f09d059b3cc1b30eeb670 100644 (file)
@@ -1,4 +1,4 @@
-error: trailing attribute after type parameters
+error: trailing attribute after generic parameter
   --> $DIR/attrs-with-no-formal-in-generics-2.rs:9:35
    |
 LL | impl<#[rustc_1] 'a, #[rustc_2] T, #[oops]> RefAny<'a, T> {}
index e9f908d479f649ac7efbbe98d37f306773336732..3cfc70b41850a07ed2836bb10bdfa04b5f51fe6c 100644 (file)
@@ -6,7 +6,7 @@
 
 fn hof_lt<Q>(_: Q)
     where Q: for <#[allow(unused)] 'a, 'b, #[oops]> Fn(RefIntPair<'a,'b>) -> &'b u32
-    //~^ ERROR trailing attribute after lifetime parameters
+    //~^ ERROR trailing attribute after generic parameter
 {}
 
 fn main() {}
index 452f0ea5e1753406aa2ebaa7e6a2561e7039fe01..b9ca00974677b4a835f0654e8e381a639db79c0e 100644 (file)
@@ -1,4 +1,4 @@
-error: trailing attribute after lifetime parameters
+error: trailing attribute after generic parameter
   --> $DIR/attrs-with-no-formal-in-generics-3.rs:8:44
    |
 LL |     where Q: for <#[allow(unused)] 'a, 'b, #[oops]> Fn(RefIntPair<'a,'b>) -> &'b u32
index 840b377263db9147da298f39d154cf16db510cb2..33c94d6e3a59e76c267810b1323992e6c219ea04 100644 (file)
@@ -9,7 +9,7 @@ LL |       x   //~ error: use of moved value: `x`
 LL | |     //~^ value used here after move
 LL | |     +=
 LL | |     x;  //~ value moved here
-   | |     -
+   | |     ^
    | |     |
    | |_____move out of `x` occurs here
    |       borrow later used here
index d2e6dff125273459ba76be9aecf98196b358d870..53dfb13139a54c1093c13be8720f849ce5102314 100644 (file)
@@ -1,4 +1,4 @@
 fn foo<T>() {
-    fn bar(b: T) { } //~ ERROR can't use type parameters from outer
+    fn bar(b: T) { } //~ ERROR can't use generic parameters from outer
 }
 fn main() { }
index 5558a44006180d31ef56bb8cdee9caa88e87c590..ce803e96801f9f5c538203c071c3fd60f9e8023c 100644 (file)
@@ -1,12 +1,12 @@
-error[E0401]: can't use type parameters from outer function
+error[E0401]: can't use generic parameters from outer function
   --> $DIR/bad-type-env-capture.rs:2:15
    |
 LL | fn foo<T>() {
    |        - type variable from outer function
-LL |     fn bar(b: T) { } //~ ERROR can't use type parameters from outer
-   |        ---    ^ use of type variable from outer function
+LL |     fn bar(b: T) { } //~ ERROR can't use generic parameters from outer
+   |        ---    ^ use of generic parameter from outer function
    |        |
-   |        help: try using a local type parameter instead: `bar<T>`
+   |        help: try using a local generic parameter instead: `bar<T>`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/const-generics/const-expression-parameter.rs b/src/test/ui/const-generics/const-expression-parameter.rs
new file mode 100644 (file)
index 0000000..f4e9008
--- /dev/null
@@ -0,0 +1,23 @@
+#![feature(const_generics)]
+//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
+
+fn u32_identity<const X: u32>() -> u32 {
+    //~^ ERROR const generics in any position are currently unsupported
+    5
+}
+
+fn foo_a() {
+    u32_identity::<-1>(); //~ ERROR expected identifier, found `<-`
+}
+
+fn foo_b() {
+    u32_identity::<1 + 2>(); //~ ERROR expected one of `,` or `>`, found `+`
+}
+
+fn foo_c() {
+    u32_identity::< -1 >(); // ok
+}
+
+fn main() {
+    u32_identity::<5>(); // ok
+}
diff --git a/src/test/ui/const-generics/const-expression-parameter.stderr b/src/test/ui/const-generics/const-expression-parameter.stderr
new file mode 100644 (file)
index 0000000..1dd3a96
--- /dev/null
@@ -0,0 +1,26 @@
+error: expected identifier, found `<-`
+  --> $DIR/const-expression-parameter.rs:10:19
+   |
+LL |     u32_identity::<-1>(); //~ ERROR expected identifier, found `<-`
+   |                   ^^ expected identifier
+
+error: expected one of `,` or `>`, found `+`
+  --> $DIR/const-expression-parameter.rs:14:22
+   |
+LL |     u32_identity::<1 + 2>(); //~ ERROR expected one of `,` or `>`, found `+`
+   |                      ^ expected one of `,` or `>` here
+
+warning: the feature `const_generics` is incomplete and may cause the compiler to crash
+  --> $DIR/const-expression-parameter.rs:1:12
+   |
+LL | #![feature(const_generics)]
+   |            ^^^^^^^^^^^^^^
+
+error: const generics in any position are currently unsupported
+  --> $DIR/const-expression-parameter.rs:4:23
+   |
+LL | fn u32_identity<const X: u32>() -> u32 {
+   |                       ^
+
+error: aborting due to 3 previous errors
+
diff --git a/src/test/ui/const-generics/const-fn-with-const-param.rs b/src/test/ui/const-generics/const-fn-with-const-param.rs
new file mode 100644 (file)
index 0000000..052d723
--- /dev/null
@@ -0,0 +1,12 @@
+#![feature(const_generics)]
+//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
+
+const fn const_u32_identity<const X: u32>() -> u32 {
+    //~^ ERROR const parameters are not permitted in `const fn`
+    //~^^ ERROR const generics in any position are currently unsupported
+    X
+}
+
+fn main() {
+    println!("{:?}", const_u32_identity::<18>());
+}
diff --git a/src/test/ui/const-generics/const-fn-with-const-param.stderr b/src/test/ui/const-generics/const-fn-with-const-param.stderr
new file mode 100644 (file)
index 0000000..a08ebfb
--- /dev/null
@@ -0,0 +1,24 @@
+warning: the feature `const_generics` is incomplete and may cause the compiler to crash
+  --> $DIR/const-fn-with-const-param.rs:1:12
+   |
+LL | #![feature(const_generics)]
+   |            ^^^^^^^^^^^^^^
+
+error: const parameters are not permitted in `const fn`
+  --> $DIR/const-fn-with-const-param.rs:4:1
+   |
+LL | / const fn const_u32_identity<const X: u32>() -> u32 {
+LL | |     //~^ ERROR const parameters are not permitted in `const fn`
+LL | |     //~^^ ERROR const generics in any position are currently unsupported
+LL | |     X
+LL | | }
+   | |_^
+
+error: const generics in any position are currently unsupported
+  --> $DIR/const-fn-with-const-param.rs:4:35
+   |
+LL | const fn const_u32_identity<const X: u32>() -> u32 {
+   |                                   ^
+
+error: aborting due to 2 previous errors
+
diff --git a/src/test/ui/const-generics/const-param-before-other-params.rs b/src/test/ui/const-generics/const-param-before-other-params.rs
new file mode 100644 (file)
index 0000000..3f120cb
--- /dev/null
@@ -0,0 +1,13 @@
+#![feature(const_generics)]
+//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
+
+fn foo<const X: (), T>(_: T) {
+    //~^ ERROR type parameters must be declared prior to const parameters
+    //~^^ ERROR const generics in any position are currently unsupported
+}
+
+fn bar<const X: (), 'a>(_: &'a ()) {
+    //~^ ERROR lifetime parameters must be declared prior to const parameters
+}
+
+fn main() {}
diff --git a/src/test/ui/const-generics/const-param-before-other-params.stderr b/src/test/ui/const-generics/const-param-before-other-params.stderr
new file mode 100644 (file)
index 0000000..aedcaf5
--- /dev/null
@@ -0,0 +1,26 @@
+warning: the feature `const_generics` is incomplete and may cause the compiler to crash
+  --> $DIR/const-param-before-other-params.rs:1:12
+   |
+LL | #![feature(const_generics)]
+   |            ^^^^^^^^^^^^^^
+
+error: type parameters must be declared prior to const parameters
+  --> $DIR/const-param-before-other-params.rs:4:21
+   |
+LL | fn foo<const X: (), T>(_: T) {
+   |       --------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, const X: ()>`
+
+error: lifetime parameters must be declared prior to const parameters
+  --> $DIR/const-param-before-other-params.rs:9:21
+   |
+LL | fn bar<const X: (), 'a>(_: &'a ()) {
+   |       --------------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, const X: ()>`
+
+error: const generics in any position are currently unsupported
+  --> $DIR/const-param-before-other-params.rs:4:14
+   |
+LL | fn foo<const X: (), T>(_: T) {
+   |              ^
+
+error: aborting due to 3 previous errors
+
diff --git a/src/test/ui/const-generics/const-param-from-outer-fn.rs b/src/test/ui/const-generics/const-param-from-outer-fn.rs
new file mode 100644 (file)
index 0000000..5a8dd92
--- /dev/null
@@ -0,0 +1,11 @@
+#![feature(const_generics)]
+//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash
+
+fn foo<const X: u32>() {
+    //~^ ERROR const generics in any position are currently unsupported
+    fn bar() -> u32 {
+        X //~ ERROR can't use generic parameters from outer function
+    }
+}
+
+fn main() {}
diff --git a/src/test/ui/const-generics/const-param-from-outer-fn.stderr b/src/test/ui/const-generics/const-param-from-outer-fn.stderr
new file mode 100644 (file)
index 0000000..b238b3a
--- /dev/null
@@ -0,0 +1,26 @@
+warning: the feature `const_generics` is incomplete and may cause the compiler to crash
+  --> $DIR/const-param-from-outer-fn.rs:1:12
+   |
+LL | #![feature(const_generics)]
+   |            ^^^^^^^^^^^^^^
+
+error[E0401]: can't use generic parameters from outer function
+  --> $DIR/const-param-from-outer-fn.rs:7:9
+   |
+LL | fn foo<const X: u32>() {
+   |              - const variable from outer function
+LL |     //~^ ERROR const generics in any position are currently unsupported
+LL |     fn bar() -> u32 {
+   |        --- try adding a local generic parameter in this method instead
+LL |         X //~ ERROR can't use generic parameters from outer function
+   |         ^ use of generic parameter from outer function
+
+error: const generics in any position are currently unsupported
+  --> $DIR/const-param-from-outer-fn.rs:4:14
+   |
+LL | fn foo<const X: u32>() {
+   |              ^
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0401`.
index 41750d4bb36250f81bc6492c0f2aedd1dc11043a..17d48edc35c91bc3feb6f91dad09fc41678cb7aa 100644 (file)
@@ -1,4 +1,4 @@
-error[E0403]: the name `T` is already used for a type parameter in this type parameter list
+error[E0403]: the name `T` is already used for a generic parameter in this list of generic parameters
   --> $DIR/duplicate-type-parameter.rs:1:12
    |
 LL | type Foo<T,T> = Option<T>;
@@ -6,7 +6,7 @@ LL | type Foo<T,T> = Option<T>;
    |          |
    |          first use of `T`
 
-error[E0403]: the name `T` is already used for a type parameter in this type parameter list
+error[E0403]: the name `T` is already used for a generic parameter in this list of generic parameters
   --> $DIR/duplicate-type-parameter.rs:4:14
    |
 LL | struct Bar<T,T>(T);
@@ -14,7 +14,7 @@ LL | struct Bar<T,T>(T);
    |            |
    |            first use of `T`
 
-error[E0403]: the name `T` is already used for a type parameter in this type parameter list
+error[E0403]: the name `T` is already used for a generic parameter in this list of generic parameters
   --> $DIR/duplicate-type-parameter.rs:7:14
    |
 LL | struct Baz<T,T> {
@@ -22,7 +22,7 @@ LL | struct Baz<T,T> {
    |            |
    |            first use of `T`
 
-error[E0403]: the name `T` is already used for a type parameter in this type parameter list
+error[E0403]: the name `T` is already used for a generic parameter in this list of generic parameters
   --> $DIR/duplicate-type-parameter.rs:12:12
    |
 LL | enum Boo<T,T> {
@@ -30,7 +30,7 @@ LL | enum Boo<T,T> {
    |          |
    |          first use of `T`
 
-error[E0403]: the name `T` is already used for a type parameter in this type parameter list
+error[E0403]: the name `T` is already used for a generic parameter in this list of generic parameters
   --> $DIR/duplicate-type-parameter.rs:18:11
    |
 LL | fn quux<T,T>(x: T) {}
@@ -38,7 +38,7 @@ LL | fn quux<T,T>(x: T) {}
    |         |
    |         first use of `T`
 
-error[E0403]: the name `T` is already used for a type parameter in this type parameter list
+error[E0403]: the name `T` is already used for a generic parameter in this list of generic parameters
   --> $DIR/duplicate-type-parameter.rs:21:13
    |
 LL | trait Qux<T,T> {}
@@ -46,7 +46,7 @@ LL | trait Qux<T,T> {}
    |           |
    |           first use of `T`
 
-error[E0403]: the name `T` is already used for a type parameter in this type parameter list
+error[E0403]: the name `T` is already used for a generic parameter in this list of generic parameters
   --> $DIR/duplicate-type-parameter.rs:24:8
    |
 LL | impl<T,T> Qux<T,T> for Option<T> {}
index c94fa497678e0f837dfd2f428d2effa985a8c4fe..27f281ee437867ebbe0fa50b77161bd0bea41a6f 100644 (file)
@@ -1,26 +1,26 @@
-error[E0401]: can't use type parameters from outer function
+error[E0401]: can't use generic parameters from outer function
   --> $DIR/E0401.rs:4:39
    |
 LL | fn foo<T>(x: T) {
    |        - type variable from outer function
 LL |     fn bfnr<U, V: Baz<U>, W: Fn()>(y: T) { //~ ERROR E0401
-   |        ---------------------------    ^ use of type variable from outer function
+   |        ---------------------------    ^ use of generic parameter from outer function
    |        |
-   |        help: try using a local type parameter instead: `bfnr<U, V: Baz<U>, W: Fn(), T>`
+   |        help: try using a local generic parameter instead: `bfnr<U, V: Baz<U>, W: Fn(), T>`
 
-error[E0401]: can't use type parameters from outer function
+error[E0401]: can't use generic parameters from outer function
   --> $DIR/E0401.rs:9:16
    |
 LL | fn foo<T>(x: T) {
    |        - type variable from outer function
 ...
 LL |     fn baz<U,
-   |        --- try adding a local type parameter in this method instead
+   |        --- try adding a local generic parameter in this method instead
 ...
 LL |            (y: T) { //~ ERROR E0401
-   |                ^ use of type variable from outer function
+   |                ^ use of generic parameter from outer function
 
-error[E0401]: can't use type parameters from outer function
+error[E0401]: can't use generic parameters from outer function
   --> $DIR/E0401.rs:22:25
    |
 LL | impl<T> Iterator for A<T> {
@@ -29,7 +29,7 @@ LL | impl<T> Iterator for A<T> {
 LL |         fn helper(sel: &Self) -> u8 { //~ ERROR E0401
    |                         ^^^^
    |                         |
-   |                         use of type variable from outer function
+   |                         use of generic parameter from outer function
    |                         use a type here instead
 
 error: aborting due to 3 previous errors
index 919a82dbe1a72c8c672718bf860a093e350c9990..b924647502965e6ac03a1bd767918640a8e14f4c 100644 (file)
@@ -1,4 +1,4 @@
-error[E0403]: the name `T` is already used for a type parameter in this type parameter list
+error[E0403]: the name `T` is already used for a generic parameter in this list of generic parameters
   --> $DIR/E0403.rs:1:11
    |
 LL | fn foo<T, T>(s: T, u: T) {} //~ ERROR E0403
diff --git a/src/test/ui/feature-gates/feature-gate-const_generics.rs b/src/test/ui/feature-gates/feature-gate-const_generics.rs
new file mode 100644 (file)
index 0000000..a8a4ed5
--- /dev/null
@@ -0,0 +1,6 @@
+fn foo<const X: ()>() {} //~ ERROR const generics are unstable
+//~^ const generics in any position are currently unsupported
+
+struct Foo<const X: usize>([(); X]); //~ ERROR const generics are unstable
+
+fn main() {}
diff --git a/src/test/ui/feature-gates/feature-gate-const_generics.stderr b/src/test/ui/feature-gates/feature-gate-const_generics.stderr
new file mode 100644 (file)
index 0000000..905cc07
--- /dev/null
@@ -0,0 +1,25 @@
+error[E0658]: const generics are unstable (see issue #44580)
+  --> $DIR/feature-gate-const_generics.rs:1:14
+   |
+LL | fn foo<const X: ()>() {} //~ ERROR const generics are unstable
+   |              ^
+   |
+   = help: add #![feature(const_generics)] to the crate attributes to enable
+
+error[E0658]: const generics are unstable (see issue #44580)
+  --> $DIR/feature-gate-const_generics.rs:4:18
+   |
+LL | struct Foo<const X: usize>([(); X]); //~ ERROR const generics are unstable
+   |                  ^
+   |
+   = help: add #![feature(const_generics)] to the crate attributes to enable
+
+error: const generics in any position are currently unsupported
+  --> $DIR/feature-gate-const_generics.rs:1:14
+   |
+LL | fn foo<const X: ()>() {} //~ ERROR const generics are unstable
+   |              ^
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0658`.
index 899303646d671fd44b57dee425a68960ec71b0bf..91d092634a90100ca3b2bf1cead2bab73634e751 100644 (file)
@@ -2,27 +2,27 @@
 
 fn a<T: Clone>(x: T) {
     const foo: impl Clone = x;
-//~^ ERROR can't capture dynamic environment in a fn item
+    //~^ ERROR attempt to use a non-constant value in a constant
 }
 
 fn b<T: Clone>(x: T) {
     let _ = move || {
         const foo: impl Clone = x;
-//~^ ERROR can't capture dynamic environment in a fn item
+        //~^ ERROR attempt to use a non-constant value in a constant
     };
 }
 
 trait Foo<T: Clone> {
     fn a(x: T) {
         const foo: impl Clone = x;
-//~^ ERROR can't capture dynamic environment in a fn item
+        //~^ ERROR attempt to use a non-constant value in a constant
     }
 }
 
 impl<T: Clone> Foo<T> for i32 {
     fn a(x: T) {
         const foo: impl Clone = x;
-//~^ ERROR can't capture dynamic environment in a fn item
+        //~^ ERROR attempt to use a non-constant value in a constant
     }
 }
 
index 2a9be7a270a73d6b1d9ac51dbbf6bd432bd576a3..a5bf583afeaf6a75e09a894cb9d999dc65b6185b 100644 (file)
@@ -1,35 +1,27 @@
-error[E0434]: can't capture dynamic environment in a fn item
+error[E0435]: attempt to use a non-constant value in a constant
   --> $DIR/bindings.rs:4:29
    |
 LL |     const foo: impl Clone = x;
-   |                             ^
-   |
-   = help: use the `|| { ... }` closure form instead
+   |                             ^ non-constant value
 
-error[E0434]: can't capture dynamic environment in a fn item
+error[E0435]: attempt to use a non-constant value in a constant
   --> $DIR/bindings.rs:10:33
    |
 LL |         const foo: impl Clone = x;
-   |                                 ^
-   |
-   = help: use the `|| { ... }` closure form instead
+   |                                 ^ non-constant value
 
-error[E0434]: can't capture dynamic environment in a fn item
+error[E0435]: attempt to use a non-constant value in a constant
   --> $DIR/bindings.rs:17:33
    |
 LL |         const foo: impl Clone = x;
-   |                                 ^
-   |
-   = help: use the `|| { ... }` closure form instead
+   |                                 ^ non-constant value
 
-error[E0434]: can't capture dynamic environment in a fn item
+error[E0435]: attempt to use a non-constant value in a constant
   --> $DIR/bindings.rs:24:33
    |
 LL |         const foo: impl Clone = x;
-   |                                 ^
-   |
-   = help: use the `|| { ... }` closure form instead
+   |                                 ^ non-constant value
 
 error: aborting due to 4 previous errors
 
-For more information about this error, try `rustc --explain E0434`.
+For more information about this error, try `rustc --explain E0435`.
index 60b4c5b8131b35a6ca71bb3aae270fb5a80beca6..c08ccd29d8011bdc8bf08b0e6232732cad439cdf 100644 (file)
@@ -4,7 +4,7 @@ enum Bar<T> { What } //~ ERROR parameter `T` is never used
 
 fn foo<T>() {
     static a: Bar<T> = Bar::What;
-//~^ ERROR can't use type parameters from outer function
+//~^ ERROR can't use generic parameters from outer function
 }
 
 fn main() {
index 2f2856edb0ca9c7bc340717be1d8515ba87a30ce..87fb364954d96b688e004420bebd4e13f929e322 100644 (file)
@@ -1,12 +1,12 @@
-error[E0401]: can't use type parameters from outer function
+error[E0401]: can't use generic parameters from outer function
   --> $DIR/inner-static-type-parameter.rs:6:19
    |
 LL | fn foo<T>() {
    |    --- - type variable from outer function
    |    |
-   |    try adding a local type parameter in this method instead
+   |    try adding a local generic parameter in this method instead
 LL |     static a: Bar<T> = Bar::What;
-   |                   ^ use of type variable from outer function
+   |                   ^ use of generic parameter from outer function
 
 error[E0392]: parameter `T` is never used
   --> $DIR/inner-static-type-parameter.rs:3:10
index acd4584c73700a8e1b72a34064b00800108c9660..942d6b9a5686e6805951d24144bdeb85f102708d 100644 (file)
@@ -1,7 +1,7 @@
 trait Trait {
     fn outer(&self) {
         fn inner(_: &Self) {
-            //~^ ERROR can't use type parameters from outer function
+            //~^ ERROR can't use generic parameters from outer function
         }
     }
 }
index 4bc29fd37dc4a252e348d0df159b74690765c4eb..a01fd2d65420b277d9bc5490710b4a4c0564c643 100644 (file)
@@ -1,10 +1,10 @@
-error[E0401]: can't use type parameters from outer function
+error[E0401]: can't use generic parameters from outer function
   --> $DIR/issue-12796.rs:3:22
    |
 LL |         fn inner(_: &Self) {
    |                      ^^^^
    |                      |
-   |                      use of type variable from outer function
+   |                      use of generic parameter from outer function
    |                      can't use `Self` here
 
 error: aborting due to previous error
index e84506ee249d21d2fae91eaf09a284fe070aaa28..9bfd5bf23130210476c6e46ba4a9f0bdfba67a28 100644 (file)
@@ -1,8 +1,6 @@
 // We need all these 9 issue-20616-N.rs files
 // because we can only catch one parsing error at a time
 
-
-
 type Type_1_<'a, T> = &'a T;
 
 
@@ -12,7 +10,8 @@
 //type Type_2 = Type_1_<'static ()>; // error: expected `,` or `>` after lifetime name, found `(`
 
 
-type Type_3<T> = Box<T,,>; //~ error: expected one of `>`, identifier, lifetime, or type, found `,`
+type Type_3<T> = Box<T,,>;
+//~^ error: expected one of `>`, const, identifier, lifetime, or type, found `,`
 
 
 //type Type_4<T> = Type_1_<'static,, T>; // error: expected type, found `,`
index 5247298b7cc260b851f7ff588dd6342660b73a9a..f51fb949c740cc9de50d960c04029d3668b1dced 100644 (file)
@@ -1,8 +1,8 @@
-error: expected one of `>`, identifier, lifetime, or type, found `,`
-  --> $DIR/issue-20616-3.rs:15:24
+error: expected one of `>`, const, identifier, lifetime, or type, found `,`
+  --> $DIR/issue-20616-3.rs:13:24
    |
-LL | type Type_3<T> = Box<T,,>; //~ error: expected one of `>`, identifier, lifetime, or type, found `,`
-   |                        ^ expected one of `>`, identifier, lifetime, or type here
+LL | type Type_3<T> = Box<T,,>;
+   |                        ^ expected one of `>`, const, identifier, lifetime, or type here
 
 error: aborting due to previous error
 
index 785a6fa7d9a2f2414b5c98e689dbed0589e70044..e9a34a04667b0937a950fba0e37bfbadeb17373b 100644 (file)
@@ -1,8 +1,6 @@
 // We need all these 9 issue-20616-N.rs files
 // because we can only catch one parsing error at a time
 
-
-
 type Type_1_<'a, T> = &'a T;
 
 
@@ -16,7 +14,7 @@
 
 
 type Type_4<T> = Type_1_<'static,, T>;
-//~^ error: expected one of `>`, identifier, lifetime, or type, found `,`
+//~^ error: expected one of `>`, const, identifier, lifetime, or type, found `,`
 
 
 type Type_5_<'a> = Type_1_<'a, ()>;
index 74c38d9e97d60443620ab8574a8e5e5068694bb1..22a655465e83cacfe9c1c7294afdec5056963d9b 100644 (file)
@@ -1,8 +1,8 @@
-error: expected one of `>`, identifier, lifetime, or type, found `,`
-  --> $DIR/issue-20616-4.rs:18:34
+error: expected one of `>`, const, identifier, lifetime, or type, found `,`
+  --> $DIR/issue-20616-4.rs:16:34
    |
 LL | type Type_4<T> = Type_1_<'static,, T>;
-   |                                  ^ expected one of `>`, identifier, lifetime, or type here
+   |                                  ^ expected one of `>`, const, identifier, lifetime, or type here
 
 error: aborting due to previous error
 
index 71dcc1f3a024f9cfe786c3bc00a48a2ca3f49d25..23862516d2cbfb35d97edbbc8bb0c7c14cc13124 100644 (file)
@@ -1,8 +1,6 @@
 // We need all these 9 issue-20616-N.rs files
 // because we can only catch one parsing error at a time
 
-
-
 type Type_1_<'a, T> = &'a T;
 
 
@@ -22,7 +20,7 @@
 
 
 type Type_5<'a> = Type_1_<'a, (),,>;
-//~^ error: expected one of `>`, identifier, lifetime, or type, found `,`
+//~^ error: expected one of `>`, const, identifier, lifetime, or type, found `,`
 
 
 //type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`
index 38457beadc448d4ebad00e6fec93f949bb2fea79..d83fc41f43ec0874979db22b615505cce6e40633 100644 (file)
@@ -1,8 +1,8 @@
-error: expected one of `>`, identifier, lifetime, or type, found `,`
-  --> $DIR/issue-20616-5.rs:24:34
+error: expected one of `>`, const, identifier, lifetime, or type, found `,`
+  --> $DIR/issue-20616-5.rs:22:34
    |
 LL | type Type_5<'a> = Type_1_<'a, (),,>;
-   |                                  ^ expected one of `>`, identifier, lifetime, or type here
+   |                                  ^ expected one of `>`, const, identifier, lifetime, or type here
 
 error: aborting due to previous error
 
index da32da48852429c52432349cfb242388c6715f87..dc327f3f788247631e872e62916b7b4adf79384c 100644 (file)
@@ -1,8 +1,6 @@
 // We need all these 9 issue-20616-N.rs files
 // because we can only catch one parsing error at a time
 
-
-
 type Type_1_<'a, T> = &'a T;
 
 
@@ -25,7 +23,7 @@
 
 
 type Type_6 = Type_5_<'a,,>;
-//~^ error: expected one of `>`, identifier, lifetime, or type, found `,`
+//~^ error: expected one of `>`, const, identifier, lifetime, or type, found `,`
 
 
 //type Type_7 = Box<(),,>; // error: expected type, found `,`
index 55b1d031a3915ae5c2796bddd73cbfa8cd993ef0..0740df595234a013ef4d206a96fc6acccc33a26c 100644 (file)
@@ -1,8 +1,8 @@
-error: expected one of `>`, identifier, lifetime, or type, found `,`
-  --> $DIR/issue-20616-6.rs:27:26
+error: expected one of `>`, const, identifier, lifetime, or type, found `,`
+  --> $DIR/issue-20616-6.rs:25:26
    |
 LL | type Type_6 = Type_5_<'a,,>;
-   |                          ^ expected one of `>`, identifier, lifetime, or type here
+   |                          ^ expected one of `>`, const, identifier, lifetime, or type here
 
 error: aborting due to previous error
 
index feaaff2c8902528c3144f97b6e737d25cb456df1..ffd1620c1d306fca9e86aeeb44f002341ec9555e 100644 (file)
@@ -1,8 +1,6 @@
 // We need all these 9 issue-20616-N.rs files
 // because we can only catch one parsing error at a time
 
-
-
 type Type_1_<'a, T> = &'a T;
 
 
@@ -27,7 +25,8 @@
 //type Type_6 = Type_5_<'a,,>; // error: expected type, found `,`
 
 
-type Type_7 = Box<(),,>; //~ error: expected one of `>`, identifier, lifetime, or type, found `,`
+type Type_7 = Box<(),,>;
+//~^ error: expected one of `>`, const, identifier, lifetime, or type, found `,`
 
 
 //type Type_8<'a,,> = &'a (); // error: expected ident, found `,`
index 8b5f67c703f643f1beca4bf6427a78165a7ee92d..c0e108375be29ddd51e0bab52ced252c5ec42a0a 100644 (file)
@@ -1,8 +1,8 @@
-error: expected one of `>`, identifier, lifetime, or type, found `,`
-  --> $DIR/issue-20616-7.rs:30:22
+error: expected one of `>`, const, identifier, lifetime, or type, found `,`
+  --> $DIR/issue-20616-7.rs:28:22
    |
-LL | type Type_7 = Box<(),,>; //~ error: expected one of `>`, identifier, lifetime, or type, found `,`
-   |                      ^ expected one of `>`, identifier, lifetime, or type here
+LL | type Type_7 = Box<(),,>;
+   |                      ^ expected one of `>`, const, identifier, lifetime, or type here
 
 error: aborting due to previous error
 
index 2fc7243559a312d172fdae09c754b7c991548bce..c9e8b61e50b5280269bd5c23fb9c9cac91ab5b54 100644 (file)
@@ -1,8 +1,6 @@
 // We need all these 9 issue-20616-N.rs files
 // because we can only catch one parsing error at a time
 
-
-
 type Type_1_<'a, T> = &'a T;
 
 
@@ -30,7 +28,8 @@
 //type Type_7 = Box<(),,>; // error: expected type, found `,`
 
 
-type Type_8<'a,,> = &'a (); //~ error: expected one of `>`, identifier, or lifetime, found `,`
+type Type_8<'a,,> = &'a ();
+//~^ error: expected one of `>`, `const`, identifier, or lifetime, found `,`
 
 
 //type Type_9<T,,> = Box<T>; // error: expected identifier, found `,`
index cdeb544f07c4c41497bb193bb659f2f38898b795..0ef9192f1e73a392bbad3df6bcf7559974c047bd 100644 (file)
@@ -1,8 +1,8 @@
-error: expected one of `>`, identifier, or lifetime, found `,`
-  --> $DIR/issue-20616-8.rs:33:16
+error: expected one of `>`, `const`, identifier, or lifetime, found `,`
+  --> $DIR/issue-20616-8.rs:31:16
    |
-LL | type Type_8<'a,,> = &'a (); //~ error: expected one of `>`, identifier, or lifetime, found `,`
-   |                ^ expected one of `>`, identifier, or lifetime here
+LL | type Type_8<'a,,> = &'a ();
+   |                ^ expected one of `>`, `const`, identifier, or lifetime here
 
 error: aborting due to previous error
 
index b14a5b0ff36da376db1fcef550d1867b1c03f2d7..1c509f26fd63aa8c90b1c02b2e996c8c007678ba 100644 (file)
@@ -1,8 +1,6 @@
 // We need all these 9 issue-20616-N.rs files
 // because we can only catch one parsing error at a time
 
-
-
 type Type_1_<'a, T> = &'a T;
 
 
@@ -33,4 +31,5 @@
 //type Type_8<'a,,> = &'a (); // error: expected identifier, found `,`
 
 
-type Type_9<T,,> = Box<T>; //~ error: expected one of `>`, identifier, or lifetime, found `,`
+type Type_9<T,,> = Box<T>;
+//~^ error: expected one of `>`, `const`, identifier, or lifetime, found `,`
index dfe705c6f12edb8b3a1fcf9a3702b82ccee42922..5fd1400a2e8cad777735994c09f2b921c180588a 100644 (file)
@@ -1,8 +1,8 @@
-error: expected one of `>`, identifier, or lifetime, found `,`
-  --> $DIR/issue-20616-9.rs:36:15
+error: expected one of `>`, `const`, identifier, or lifetime, found `,`
+  --> $DIR/issue-20616-9.rs:34:15
    |
-LL | type Type_9<T,,> = Box<T>; //~ error: expected one of `>`, identifier, or lifetime, found `,`
-   |               ^ expected one of `>`, identifier, or lifetime here
+LL | type Type_9<T,,> = Box<T>;
+   |               ^ expected one of `>`, `const`, identifier, or lifetime here
 
 error: aborting due to previous error
 
index 2cc7d05e7c6914d8d71242bd61e25e0e217c9e9d..156ae68efe2c50235036c981b89870ca431a95a4 100644 (file)
@@ -1,5 +1,5 @@
 fn main() {
     let foo = 42u32;
     const FOO : u32 = foo;
-                   //~^ ERROR can't capture dynamic environment
+                   //~^ ERROR attempt to use a non-constant value in a constant
 }
index 78a193dd99a7f3099bb5f4c47927478ebc166135..e232d17e6d7a696b0137367bbdd652db5e532e0a 100644 (file)
@@ -1,11 +1,9 @@
-error[E0434]: can't capture dynamic environment in a fn item
+error[E0435]: attempt to use a non-constant value in a constant
   --> $DIR/issue-27433.rs:3:23
    |
 LL |     const FOO : u32 = foo;
-   |                       ^^^
-   |
-   = help: use the `|| { ... }` closure form instead
+   |                       ^^^ non-constant value
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0434`.
+For more information about this error, try `rustc --explain E0435`.
index 491336206ca9428217157b79aacf500c7ada0cd1..94ed1fdf7819140caa8bbf13210f642390d83838 100644 (file)
@@ -1,8 +1,8 @@
 fn siphash<T>() {
 
     trait U {
-        fn g(&self, x: T) -> T;  //~ ERROR can't use type parameters from outer function
-        //~^ ERROR can't use type parameters from outer function
+        fn g(&self, x: T) -> T;  //~ ERROR can't use generic parameters from outer function
+        //~^ ERROR can't use generic parameters from outer function
     }
 }
 
index 323ce4fa30613e61854f001f3bb1374390a88ede..5eadf7837c7d0533a5773a215117529b3319d131 100644 (file)
@@ -1,24 +1,24 @@
-error[E0401]: can't use type parameters from outer function
+error[E0401]: can't use generic parameters from outer function
   --> $DIR/issue-3021-c.rs:4:24
    |
 LL | fn siphash<T>() {
    |            - type variable from outer function
 ...
-LL |         fn g(&self, x: T) -> T;  //~ ERROR can't use type parameters from outer function
-   |            -           ^ use of type variable from outer function
+LL |         fn g(&self, x: T) -> T;  //~ ERROR can't use generic parameters from outer function
+   |            -           ^ use of generic parameter from outer function
    |            |
-   |            help: try using a local type parameter instead: `g<T>`
+   |            help: try using a local generic parameter instead: `g<T>`
 
-error[E0401]: can't use type parameters from outer function
+error[E0401]: can't use generic parameters from outer function
   --> $DIR/issue-3021-c.rs:4:30
    |
 LL | fn siphash<T>() {
    |            - type variable from outer function
 ...
-LL |         fn g(&self, x: T) -> T;  //~ ERROR can't use type parameters from outer function
-   |            -                 ^ use of type variable from outer function
+LL |         fn g(&self, x: T) -> T;  //~ ERROR can't use generic parameters from outer function
+   |            -                 ^ use of generic parameter from outer function
    |            |
-   |            help: try using a local type parameter instead: `g<T>`
+   |            help: try using a local generic parameter instead: `g<T>`
 
 error: aborting due to 2 previous errors
 
index 85eae2686e6a98611e21d5d5936e617825479368..9a727aa3057977605d7521c8138e09464f65d2f2 100644 (file)
@@ -1,6 +1,6 @@
 fn foo<T>() {
     struct Foo {
-        x: T, //~ ERROR can't use type parameters from outer function
+        x: T, //~ ERROR can't use generic parameters from outer function
     }
 
     impl<T> Drop for Foo<T> {
index 4ecea4f98006e7ed8c528b31920181f6037ab82c..e6526bad3e0d3ac8bb44f3a0d836fa31fefa8e63 100644 (file)
@@ -1,13 +1,13 @@
-error[E0401]: can't use type parameters from outer function
+error[E0401]: can't use generic parameters from outer function
   --> $DIR/issue-3214.rs:3:12
    |
 LL | fn foo<T>() {
    |    --- - type variable from outer function
    |    |
-   |    try adding a local type parameter in this method instead
+   |    try adding a local generic parameter in this method instead
 LL |     struct Foo {
-LL |         x: T, //~ ERROR can't use type parameters from outer function
-   |            ^ use of type variable from outer function
+LL |         x: T, //~ ERROR can't use generic parameters from outer function
+   |            ^ use of generic parameter from outer function
 
 error[E0107]: wrong number of type arguments: expected 0, found 1
   --> $DIR/issue-3214.rs:6:26
index 39f7fcb833756bb68b0bcb5bd0a0fbe95b41de3d..871394f9eaeb96147d2b1144a3cad6988c91d9da 100644 (file)
@@ -2,7 +2,7 @@ fn main() {
     let foo = 100;
 
     static y: isize = foo + 1;
-    //~^ ERROR can't capture dynamic environment
+    //~^ ERROR attempt to use a non-constant value in a constant
 
     println!("{}", y);
 }
index 1464fd74bba692f4a66e89dee6373e9581ad720c..d54bbbcdc3325609a5217c94cd144e1afd53e706 100644 (file)
@@ -1,11 +1,9 @@
-error[E0434]: can't capture dynamic environment in a fn item
+error[E0435]: attempt to use a non-constant value in a constant
   --> $DIR/issue-3521-2.rs:4:23
    |
 LL |     static y: isize = foo + 1;
-   |                       ^^^
-   |
-   = help: use the `|| { ... }` closure form instead
+   |                       ^^^ non-constant value
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0434`.
+For more information about this error, try `rustc --explain E0435`.
index 265a884ded7aa17215ddc6ad78e2341be6991cef..525f6f5684e70f52a31dde057384e7f67d1bb700 100644 (file)
@@ -1,6 +1,6 @@
 fn f(x:isize) {
     static child: isize = x + 1;
-    //~^ ERROR can't capture dynamic environment
+    //~^ ERROR attempt to use a non-constant value in a constant
 }
 
 fn main() {}
index 8dd6f49d8de5a4ca1ac9188824445a590e0291ee..d6a6e8379602d27b90f900f78ff8963118cb99e3 100644 (file)
@@ -1,11 +1,9 @@
-error[E0434]: can't capture dynamic environment in a fn item
+error[E0435]: attempt to use a non-constant value in a constant
   --> $DIR/issue-3668-2.rs:2:27
    |
 LL |     static child: isize = x + 1;
-   |                           ^
-   |
-   = help: use the `|| { ... }` closure form instead
+   |                           ^ non-constant value
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0434`.
+For more information about this error, try `rustc --explain E0435`.
index 3f61b1b02e7796a960b354c2bbb92239c354d9b6..0e1f19a75baeb1d7507f9a4cd349272b98aa666c 100644 (file)
@@ -6,7 +6,7 @@ trait PTrait {
 impl PTrait for P {
    fn getChildOption(&self) -> Option<Box<P>> {
        static childVal: Box<P> = self.child.get();
-       //~^ ERROR can't capture dynamic environment
+       //~^ ERROR attempt to use a non-constant value in a constant
        panic!();
    }
 }
index 7f974de9da8ea1e0571408e371e0b411ffab3de2..98cd3631a5365e2a875cda5e1084593aab715837 100644 (file)
@@ -1,11 +1,9 @@
-error[E0434]: can't capture dynamic environment in a fn item
+error[E0435]: attempt to use a non-constant value in a constant
   --> $DIR/issue-3668.rs:8:34
    |
 LL |        static childVal: Box<P> = self.child.get();
-   |                                  ^^^^
-   |
-   = help: use the `|| { ... }` closure form instead
+   |                                  ^^^^ non-constant value
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0434`.
+For more information about this error, try `rustc --explain E0435`.
index 55d611070d9dcbd5a1fc3af237dee743f1ecaa15..65b2b9460bc9496afea3f12fe01ded404b51d6ef 100644 (file)
@@ -90,7 +90,7 @@ LL |   use issue_52891::a;
 LL |       m,
    |  ______-
 LL | |     a}; //~ ERROR `a` is defined multiple times
-   | |     -
+   | |     ^
    | |     |
    | |_____`a` reimported here
    |       help: remove unnecessary import
index 0987117ecd4023f51d4ee460efc0dba6983e3848..3ff4e036c60bec7d1d8f4d0001ef7e53b422da00 100644 (file)
@@ -1,6 +1,6 @@
 fn f<Z>() -> bool {
     enum E { V(Z) }
-    //~^ ERROR can't use type parameters from outer function
+    //~^ ERROR can't use generic parameters from outer function
     true
 }
 
index 5c26dc92c8584ccddbc3e7bbd20cc4d9614faddf..5c778143e13dd705d32e267c82acead08bdd5470 100644 (file)
@@ -1,12 +1,12 @@
-error[E0401]: can't use type parameters from outer function
+error[E0401]: can't use generic parameters from outer function
   --> $DIR/issue-5997-enum.rs:2:16
    |
 LL | fn f<Z>() -> bool {
    |    - - type variable from outer function
    |    |
-   |    try adding a local type parameter in this method instead
+   |    try adding a local generic parameter in this method instead
 LL |     enum E { V(Z) }
-   |                ^ use of type variable from outer function
+   |                ^ use of generic parameter from outer function
 
 error: aborting due to previous error
 
index 04ac489a55c5087095dc0909d329bd778019e2ab..6cf510b0a9d756641a6a8ee3d47ecb7f89dbc4f7 100644 (file)
@@ -1,5 +1,5 @@
 fn f<T>() -> bool {
-    struct S(T); //~ ERROR can't use type parameters from outer function
+    struct S(T); //~ ERROR can't use generic parameters from outer function
 
     true
 }
index 1d05d13242e8e2dc8aea33ee18bce281c2176c7f..a60987b3f98ba9279ca9175ad417d4a794fee5c0 100644 (file)
@@ -1,12 +1,12 @@
-error[E0401]: can't use type parameters from outer function
+error[E0401]: can't use generic parameters from outer function
   --> $DIR/issue-5997-struct.rs:2:14
    |
 LL | fn f<T>() -> bool {
    |    - - type variable from outer function
    |    |
-   |    try adding a local type parameter in this method instead
-LL |     struct S(T); //~ ERROR can't use type parameters from outer function
-   |              ^ use of type variable from outer function
+   |    try adding a local generic parameter in this method instead
+LL |     struct S(T); //~ ERROR can't use generic parameters from outer function
+   |              ^ use of generic parameter from outer function
 
 error: aborting due to previous error
 
index 7ac8dffdfbe0c2e59cad4ca601ada46e439f44ae..3cef5db66c66fbe6adb7f247bdd9e12c24ded8b3 100644 (file)
@@ -2,41 +2,25 @@ error: lifetime parameters must be declared prior to type parameters
   --> $DIR/lifetime-before-type-params.rs:2:13
    |
 LL | fn first<T, 'a, 'b>() {}
-   |             ^^  ^^
-help: move the lifetime parameter prior to the first type parameter
-   |
-LL | fn first<'a, 'b, T>() {}
-   |          ^^^ ^^^ --
+   |         ----^^--^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>`
 
 error: lifetime parameters must be declared prior to type parameters
   --> $DIR/lifetime-before-type-params.rs:4:18
    |
 LL | fn second<'a, T, 'b>() {}
-   |                  ^^
-help: move the lifetime parameter prior to the first type parameter
-   |
-LL | fn second<'a, 'b, T>() {}
-   |               ^^^ --
+   |          --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>`
 
 error: lifetime parameters must be declared prior to type parameters
   --> $DIR/lifetime-before-type-params.rs:6:16
    |
 LL | fn third<T, U, 'a>() {}
-   |                ^^
-help: move the lifetime parameter prior to the first type parameter
-   |
-LL | fn third<'a, T, U>() {}
-   |          ^^^    --
+   |         -------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, U>`
 
 error: lifetime parameters must be declared prior to type parameters
   --> $DIR/lifetime-before-type-params.rs:8:18
    |
 LL | fn fourth<'a, T, 'b, U, 'c, V>() {}
-   |                  ^^     ^^
-help: move the lifetime parameter prior to the first type parameter
-   |
-LL | fn fourth<'a, 'b, 'c, T, U, V>() {}
-   |               ^^^ ^^^ -- --
+   |          --------^^-----^^---- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, 'c, T, U, V>`
 
 error[E0601]: `main` function not found in crate `lifetime_before_type_params`
    |
index f4a1931da5aecb321f2a3281b2a15e5e9a013986..10b44e0017532498b97b18d159b6f83de5a6f58f 100644 (file)
@@ -12,11 +12,11 @@ macro_rules! follow_pat {
     ($p:pat >) => {};        //~ERROR `$p:pat` is followed by `>`
     ($p:pat +) => {};        //~ERROR `$p:pat` is followed by `+`
     ($p:pat ident) => {};    //~ERROR `$p:pat` is followed by `ident`
-    ($p:pat $p:pat) => {};   //~ERROR `$p:pat` is followed by `$p:pat`
+    ($p:pat $q:pat) => {};   //~ERROR `$p:pat` is followed by `$q:pat`
     ($p:pat $e:expr) => {};  //~ERROR `$p:pat` is followed by `$e:expr`
     ($p:pat $t:ty) => {};    //~ERROR `$p:pat` is followed by `$t:ty`
     ($p:pat $s:stmt) => {};  //~ERROR `$p:pat` is followed by `$s:stmt`
-    ($p:pat $p:path) => {};  //~ERROR `$p:pat` is followed by `$p:path`
+    ($p:pat $q:path) => {};  //~ERROR `$p:pat` is followed by `$q:path`
     ($p:pat $b:block) => {}; //~ERROR `$p:pat` is followed by `$b:block`
     ($p:pat $i:ident) => {}; //~ERROR `$p:pat` is followed by `$i:ident`
     ($p:pat $t:tt) => {};    //~ERROR `$p:pat` is followed by `$t:tt`
@@ -37,7 +37,7 @@ macro_rules! follow_expr {
     ($e:expr if) => {};       //~ERROR `$e:expr` is followed by `if`
     ($e:expr in) => {};       //~ERROR `$e:expr` is followed by `in`
     ($e:expr $p:pat) => {};   //~ERROR `$e:expr` is followed by `$p:pat`
-    ($e:expr $e:expr) => {};  //~ERROR `$e:expr` is followed by `$e:expr`
+    ($e:expr $f:expr) => {};  //~ERROR `$e:expr` is followed by `$f:expr`
     ($e:expr $t:ty) => {};    //~ERROR `$e:expr` is followed by `$t:ty`
     ($e:expr $s:stmt) => {};  //~ERROR `$e:expr` is followed by `$s:stmt`
     ($e:expr $p:path) => {};  //~ERROR `$e:expr` is followed by `$p:path`
@@ -57,12 +57,12 @@ macro_rules! follow_ty {
     ($t:ty if) => {};       //~ERROR `$t:ty` is followed by `if`
     ($t:ty $p:pat) => {};   //~ERROR `$t:ty` is followed by `$p:pat`
     ($t:ty $e:expr) => {};  //~ERROR `$t:ty` is followed by `$e:expr`
-    ($t:ty $t:ty) => {};    //~ERROR `$t:ty` is followed by `$t:ty`
+    ($t:ty $r:ty) => {};    //~ERROR `$t:ty` is followed by `$r:ty`
     ($t:ty $s:stmt) => {};  //~ERROR `$t:ty` is followed by `$s:stmt`
     ($t:ty $p:path) => {};  //~ERROR `$t:ty` is followed by `$p:path`
     ($t:ty $b:block) => {}; // ok (RFC 1494)
     ($t:ty $i:ident) => {}; //~ERROR `$t:ty` is followed by `$i:ident`
-    ($t:ty $t:tt) => {};    //~ERROR `$t:ty` is followed by `$t:tt`
+    ($t:ty $r:tt) => {};    //~ERROR `$t:ty` is followed by `$r:tt`
     ($t:ty $i:item) => {};  //~ERROR `$t:ty` is followed by `$i:item`
     ($t:ty $m:meta) => {};  //~ERROR `$t:ty` is followed by `$m:meta`
 }
@@ -82,7 +82,7 @@ macro_rules! follow_stmt {
     ($s:stmt $p:pat) => {};   //~ERROR `$s:stmt` is followed by `$p:pat`
     ($s:stmt $e:expr) => {};  //~ERROR `$s:stmt` is followed by `$e:expr`
     ($s:stmt $t:ty) => {};    //~ERROR `$s:stmt` is followed by `$t:ty`
-    ($s:stmt $s:stmt) => {};  //~ERROR `$s:stmt` is followed by `$s:stmt`
+    ($s:stmt $t:stmt) => {};  //~ERROR `$s:stmt` is followed by `$t:stmt`
     ($s:stmt $p:path) => {};  //~ERROR `$s:stmt` is followed by `$p:path`
     ($s:stmt $b:block) => {}; //~ERROR `$s:stmt` is followed by `$b:block`
     ($s:stmt $i:ident) => {}; //~ERROR `$s:stmt` is followed by `$i:ident`
@@ -97,11 +97,11 @@ macro_rules! follow_path {
     ($p:path +) => {};        //~ERROR `$p:path` is followed by `+`
     ($p:path ident) => {};    //~ERROR `$p:path` is followed by `ident`
     ($p:path if) => {};       //~ERROR `$p:path` is followed by `if`
-    ($p:path $p:pat) => {};   //~ERROR `$p:path` is followed by `$p:pat`
+    ($p:path $q:pat) => {};   //~ERROR `$p:path` is followed by `$q:pat`
     ($p:path $e:expr) => {};  //~ERROR `$p:path` is followed by `$e:expr`
     ($p:path $t:ty) => {};    //~ERROR `$p:path` is followed by `$t:ty`
     ($p:path $s:stmt) => {};  //~ERROR `$p:path` is followed by `$s:stmt`
-    ($p:path $p:path) => {};  //~ERROR `$p:path` is followed by `$p:path`
+    ($p:path $q:path) => {};  //~ERROR `$p:path` is followed by `$q:path`
     ($p:path $b:block) => {}; // ok (RFC 1494)
     ($p:path $i:ident) => {}; //~ERROR `$p:path` is followed by `$i:ident`
     ($p:path $t:tt) => {};    //~ERROR `$p:path` is followed by `$t:tt`
index 4aea5cc5de6bda86c60f6d60999c783897d2c325..e3302eac4ac086666d7b3dc9d4f3181623067148 100644 (file)
@@ -54,10 +54,10 @@ LL |     ($p:pat ident) => {};    //~ERROR `$p:pat` is followed by `ident`
    |
    = note: allowed there are: `=>`, `,`, `=`, `|`, `if` or `in`
 
-error: `$p:pat` is followed by `$p:pat`, which is not allowed for `pat` fragments
+error: `$p:pat` is followed by `$q:pat`, which is not allowed for `pat` fragments
   --> $DIR/macro-follow.rs:15:13
    |
-LL |     ($p:pat $p:pat) => {};   //~ERROR `$p:pat` is followed by `$p:pat`
+LL |     ($p:pat $q:pat) => {};   //~ERROR `$p:pat` is followed by `$q:pat`
    |             ^^^^^^ not allowed after `pat` fragments
    |
    = note: allowed there are: `=>`, `,`, `=`, `|`, `if` or `in`
@@ -86,10 +86,10 @@ LL |     ($p:pat $s:stmt) => {};  //~ERROR `$p:pat` is followed by `$s:stmt`
    |
    = note: allowed there are: `=>`, `,`, `=`, `|`, `if` or `in`
 
-error: `$p:pat` is followed by `$p:path`, which is not allowed for `pat` fragments
+error: `$p:pat` is followed by `$q:path`, which is not allowed for `pat` fragments
   --> $DIR/macro-follow.rs:19:13
    |
-LL |     ($p:pat $p:path) => {};  //~ERROR `$p:pat` is followed by `$p:path`
+LL |     ($p:pat $q:path) => {};  //~ERROR `$p:pat` is followed by `$q:path`
    |             ^^^^^^^ not allowed after `pat` fragments
    |
    = note: allowed there are: `=>`, `,`, `=`, `|`, `if` or `in`
@@ -230,10 +230,10 @@ LL |     ($e:expr $p:pat) => {};   //~ERROR `$e:expr` is followed by `$p:pat`
    |
    = note: allowed there are: `=>`, `,` or `;`
 
-error: `$e:expr` is followed by `$e:expr`, which is not allowed for `expr` fragments
+error: `$e:expr` is followed by `$f:expr`, which is not allowed for `expr` fragments
   --> $DIR/macro-follow.rs:40:14
    |
-LL |     ($e:expr $e:expr) => {};  //~ERROR `$e:expr` is followed by `$e:expr`
+LL |     ($e:expr $f:expr) => {};  //~ERROR `$e:expr` is followed by `$f:expr`
    |              ^^^^^^^ not allowed after `expr` fragments
    |
    = note: allowed there are: `=>`, `,` or `;`
@@ -350,10 +350,10 @@ LL |     ($t:ty $e:expr) => {};  //~ERROR `$t:ty` is followed by `$e:expr`
    |
    = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where`
 
-error: `$t:ty` is followed by `$t:ty`, which is not allowed for `ty` fragments
+error: `$t:ty` is followed by `$r:ty`, which is not allowed for `ty` fragments
   --> $DIR/macro-follow.rs:60:12
    |
-LL |     ($t:ty $t:ty) => {};    //~ERROR `$t:ty` is followed by `$t:ty`
+LL |     ($t:ty $r:ty) => {};    //~ERROR `$t:ty` is followed by `$r:ty`
    |            ^^^^^ not allowed after `ty` fragments
    |
    = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where`
@@ -382,10 +382,10 @@ LL |     ($t:ty $i:ident) => {}; //~ERROR `$t:ty` is followed by `$i:ident`
    |
    = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where`
 
-error: `$t:ty` is followed by `$t:tt`, which is not allowed for `ty` fragments
+error: `$t:ty` is followed by `$r:tt`, which is not allowed for `ty` fragments
   --> $DIR/macro-follow.rs:65:12
    |
-LL |     ($t:ty $t:tt) => {};    //~ERROR `$t:ty` is followed by `$t:tt`
+LL |     ($t:ty $r:tt) => {};    //~ERROR `$t:ty` is followed by `$r:tt`
    |            ^^^^^ not allowed after `ty` fragments
    |
    = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where`
@@ -518,10 +518,10 @@ LL |     ($s:stmt $t:ty) => {};    //~ERROR `$s:stmt` is followed by `$t:ty`
    |
    = note: allowed there are: `=>`, `,` or `;`
 
-error: `$s:stmt` is followed by `$s:stmt`, which is not allowed for `stmt` fragments
+error: `$s:stmt` is followed by `$t:stmt`, which is not allowed for `stmt` fragments
   --> $DIR/macro-follow.rs:85:14
    |
-LL |     ($s:stmt $s:stmt) => {};  //~ERROR `$s:stmt` is followed by `$s:stmt`
+LL |     ($s:stmt $t:stmt) => {};  //~ERROR `$s:stmt` is followed by `$t:stmt`
    |              ^^^^^^^ not allowed after `stmt` fragments
    |
    = note: allowed there are: `=>`, `,` or `;`
@@ -606,10 +606,10 @@ LL |     ($p:path if) => {};       //~ERROR `$p:path` is followed by `if`
    |
    = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where`
 
-error: `$p:path` is followed by `$p:pat`, which is not allowed for `path` fragments
+error: `$p:path` is followed by `$q:pat`, which is not allowed for `path` fragments
   --> $DIR/macro-follow.rs:100:14
    |
-LL |     ($p:path $p:pat) => {};   //~ERROR `$p:path` is followed by `$p:pat`
+LL |     ($p:path $q:pat) => {};   //~ERROR `$p:path` is followed by `$q:pat`
    |              ^^^^^^ not allowed after `path` fragments
    |
    = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where`
@@ -638,10 +638,10 @@ LL |     ($p:path $s:stmt) => {};  //~ERROR `$p:path` is followed by `$s:stmt`
    |
    = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where`
 
-error: `$p:path` is followed by `$p:path`, which is not allowed for `path` fragments
+error: `$p:path` is followed by `$q:path`, which is not allowed for `path` fragments
   --> $DIR/macro-follow.rs:104:14
    |
-LL |     ($p:path $p:path) => {};  //~ERROR `$p:path` is followed by `$p:path`
+LL |     ($p:path $q:path) => {};  //~ERROR `$p:path` is followed by `$q:path`
    |              ^^^^^^^ not allowed after `path` fragments
    |
    = note: allowed there are: `{`, `[`, `=>`, `,`, `>`, `=`, `:`, `;`, `|`, `as` or `where`
diff --git a/src/test/ui/macros/macro-multiple-matcher-bindings.rs b/src/test/ui/macros/macro-multiple-matcher-bindings.rs
new file mode 100644 (file)
index 0000000..9e0fa38
--- /dev/null
@@ -0,0 +1,25 @@
+// Test that duplicate matcher binding names are caught at declaration time, rather than at macro
+// invocation time.
+//
+// FIXME(mark-i-m): Update this when it becomes a hard error.
+
+// compile-pass
+
+#![allow(unused_macros)]
+
+macro_rules! foo1 {
+    ($a:ident, $a:ident) => {}; //~WARNING duplicate matcher binding
+    ($a:ident, $a:path) => {};  //~WARNING duplicate matcher binding
+}
+
+macro_rules! foo2 {
+    ($a:ident) => {}; // OK
+    ($a:path) => {};  // OK
+}
+
+macro_rules! foo3 {
+    ($a:ident, $($a:ident),*) => {}; //~WARNING duplicate matcher binding
+    ($($a:ident)+ # $($($a:path),+);*) => {}; //~WARNING duplicate matcher binding
+}
+
+fn main() {}
diff --git a/src/test/ui/macros/macro-multiple-matcher-bindings.stderr b/src/test/ui/macros/macro-multiple-matcher-bindings.stderr
new file mode 100644 (file)
index 0000000..bc78b47
--- /dev/null
@@ -0,0 +1,37 @@
+warning: duplicate matcher binding
+  --> $DIR/macro-multiple-matcher-bindings.rs:11:6
+   |
+LL |     ($a:ident, $a:ident) => {}; //~WARNING duplicate matcher binding
+   |      ^^^^^^^^  ^^^^^^^^
+   |
+   = note: #[warn(duplicate_matcher_binding_name)] on by default
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = note: for more information, see issue #57593 <https://github.com/rust-lang/rust/issues/57593>
+
+warning: duplicate matcher binding
+  --> $DIR/macro-multiple-matcher-bindings.rs:12:6
+   |
+LL |     ($a:ident, $a:path) => {};  //~WARNING duplicate matcher binding
+   |      ^^^^^^^^  ^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = note: for more information, see issue #57593 <https://github.com/rust-lang/rust/issues/57593>
+
+warning: duplicate matcher binding
+  --> $DIR/macro-multiple-matcher-bindings.rs:21:6
+   |
+LL |     ($a:ident, $($a:ident),*) => {}; //~WARNING duplicate matcher binding
+   |      ^^^^^^^^    ^^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = note: for more information, see issue #57593 <https://github.com/rust-lang/rust/issues/57593>
+
+warning: duplicate matcher binding
+  --> $DIR/macro-multiple-matcher-bindings.rs:22:8
+   |
+LL |     ($($a:ident)+ # $($($a:path),+);*) => {}; //~WARNING duplicate matcher binding
+   |        ^^^^^^^^         ^^^^^^^
+   |
+   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
+   = note: for more information, see issue #57593 <https://github.com/rust-lang/rust/issues/57593>
+
diff --git a/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.rs b/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.rs
new file mode 100644 (file)
index 0000000..a5dae1c
--- /dev/null
@@ -0,0 +1,177 @@
+#![feature(arbitrary_self_types, coerce_unsized, dispatch_from_dyn, unsize, unsized_locals)]
+
+// This tests a few edge-cases around `arbitrary_self_types`. Most specifically,
+// it checks that the `ObjectCandidate` you get from method matching can't
+// match a trait with the same DefId as a supertrait but a bad type parameter.
+
+use std::marker::PhantomData;
+
+mod internal {
+    use std::ops::{CoerceUnsized, Deref, DispatchFromDyn};
+    use std::marker::{PhantomData, Unsize};
+
+    pub struct Smaht<T: ?Sized, MISC>(pub Box<T>, pub PhantomData<MISC>);
+
+    impl<T: ?Sized, MISC> Deref for Smaht<T, MISC> {
+        type Target = T;
+
+        fn deref(&self) -> &Self::Target {
+            &self.0
+        }
+    }
+    impl<T: ?Sized + Unsize<U>, U: ?Sized, MISC> CoerceUnsized<Smaht<U, MISC>>
+        for Smaht<T, MISC>
+    {}
+    impl<T: ?Sized + Unsize<U>, U: ?Sized, MISC> DispatchFromDyn<Smaht<U, MISC>>
+        for Smaht<T, MISC>
+    {}
+
+    pub trait Foo: X<u32> {}
+    pub trait X<T> {
+        fn foo(self: Smaht<Self, T>) -> T;
+    }
+
+    impl X<u32> for () {
+        fn foo(self: Smaht<Self, u32>) -> u32 {
+            0
+        }
+    }
+
+    pub trait Marker {}
+    impl Marker for dyn Foo {}
+    impl<T: Marker + ?Sized> X<u64> for T {
+        fn foo(self: Smaht<Self, u64>) -> u64 {
+            1
+        }
+    }
+
+    impl Deref for dyn Foo {
+        type Target = ();
+        fn deref(&self) -> &() { &() }
+    }
+
+    impl Foo for () {}
+}
+
+pub trait FinalFoo {
+    fn foo(&self) -> u8;
+}
+
+impl FinalFoo for () {
+    fn foo(&self) -> u8 { 0 }
+}
+
+mod nuisance_foo {
+    pub trait NuisanceFoo {
+        fn foo(self);
+    }
+
+    impl<T: ?Sized> NuisanceFoo for T {
+        fn foo(self) {}
+    }
+}
+
+
+fn objectcandidate_impl() {
+    let x: internal::Smaht<(), u32> = internal::Smaht(Box::new(()), PhantomData);
+    let x: internal::Smaht<dyn internal::Foo, u32> = x;
+
+    // This picks `<dyn internal::Foo as X<u32>>::foo` via `ObjectCandidate`.
+    //
+    // The `TraitCandidate` is not relevant because `X` is not in scope.
+    let z = x.foo();
+
+    // Observe the type of `z` is `u32`
+    let _seetype: () = z; //~ ERROR mismatched types
+    //~| expected (), found u32
+}
+
+fn traitcandidate_impl() {
+    use internal::X;
+
+    let x: internal::Smaht<(), u64> = internal::Smaht(Box::new(()), PhantomData);
+    let x: internal::Smaht<dyn internal::Foo, u64> = x;
+
+    // This picks `<dyn internal::Foo as X<u64>>::foo` via `TraitCandidate`.
+    //
+    // The `ObjectCandidate` does not apply, as it only applies to
+    // `X<u32>` (and not `X<u64>`).
+    let z = x.foo();
+
+    // Observe the type of `z` is `u64`
+    let _seetype: () = z; //~ ERROR mismatched types
+    //~| expected (), found u64
+}
+
+fn traitcandidate_impl_with_nuisance() {
+    use internal::X;
+    use nuisance_foo::NuisanceFoo;
+
+    let x: internal::Smaht<(), u64> = internal::Smaht(Box::new(()), PhantomData);
+    let x: internal::Smaht<dyn internal::Foo, u64> = x;
+
+    // This picks `<dyn internal::Foo as X<u64>>::foo` via `TraitCandidate`.
+    //
+    // The `ObjectCandidate` does not apply, as it only applies to
+    // `X<u32>` (and not `X<u64>`).
+    //
+    // The NuisanceFoo impl has the same priority as the `X` impl,
+    // so we get a conflict.
+    let z = x.foo(); //~ ERROR multiple applicable items in scope
+}
+
+
+fn neither_impl() {
+    let x: internal::Smaht<(), u64> = internal::Smaht(Box::new(()), PhantomData);
+    let x: internal::Smaht<dyn internal::Foo, u64> = x;
+
+    // This can't pick the `TraitCandidate` impl, because `Foo` is not
+    // imported. However, this also can't pick the `ObjectCandidate`
+    // impl, because it only applies to `X<u32>` (and not `X<u64>`).
+    //
+    // Therefore, neither of the candidates is applicable, and we pick
+    // the `FinalFoo` impl after another deref, which will return `u8`.
+    let z = x.foo();
+
+    // Observe the type of `z` is `u8`
+    let _seetype: () = z; //~ ERROR mismatched types
+    //~| expected (), found u8
+}
+
+fn both_impls() {
+    use internal::X;
+
+    let x: internal::Smaht<(), u32> = internal::Smaht(Box::new(()), PhantomData);
+    let x: internal::Smaht<dyn internal::Foo, u32> = x;
+
+    // This can pick both the `TraitCandidate` and the `ObjectCandidate` impl.
+    //
+    // However, the `ObjectCandidate` is considered an "inherent candidate",
+    // and therefore has priority over both the `TraitCandidate` as well as
+    // any other "nuisance" candidate" (if present).
+    let z = x.foo();
+
+    // Observe the type of `z` is `u32`
+    let _seetype: () = z; //~ ERROR mismatched types
+    //~| expected (), found u32
+}
+
+
+fn both_impls_with_nuisance() {
+    // Similar to the `both_impls` example, except with a nuisance impl to
+    // make sure the `ObjectCandidate` indeed has a higher priority.
+
+    use internal::X;
+    use nuisance_foo::NuisanceFoo;
+
+    let x: internal::Smaht<(), u32> = internal::Smaht(Box::new(()), PhantomData);
+    let x: internal::Smaht<dyn internal::Foo, u32> = x;
+    let z = x.foo();
+
+    // Observe the type of `z` is `u32`
+    let _seetype: () = z; //~ ERROR mismatched types
+    //~| expected (), found u32
+}
+
+fn main() {
+}
diff --git a/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr b/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr
new file mode 100644 (file)
index 0000000..2d8449b
--- /dev/null
@@ -0,0 +1,72 @@
+error[E0308]: mismatched types
+  --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:85:24
+   |
+LL |     let _seetype: () = z; //~ ERROR mismatched types
+   |                        ^ expected (), found u32
+   |
+   = note: expected type `()`
+              found type `u32`
+
+error[E0308]: mismatched types
+  --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:102:24
+   |
+LL |     let _seetype: () = z; //~ ERROR mismatched types
+   |                        ^ expected (), found u64
+   |
+   = note: expected type `()`
+              found type `u64`
+
+error[E0034]: multiple applicable items in scope
+  --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:120:15
+   |
+LL |     let z = x.foo(); //~ ERROR multiple applicable items in scope
+   |               ^^^ multiple `foo` found
+   |
+note: candidate #1 is defined in an impl of the trait `internal::X` for the type `_`
+  --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:43:9
+   |
+LL |         fn foo(self: Smaht<Self, u64>) -> u64 {
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+note: candidate #2 is defined in an impl of the trait `nuisance_foo::NuisanceFoo` for the type `_`
+  --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:70:9
+   |
+LL |         fn foo(self) {}
+   |         ^^^^^^^^^^^^
+note: candidate #3 is defined in the trait `FinalFoo`
+  --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:57:5
+   |
+LL |     fn foo(&self) -> u8;
+   |     ^^^^^^^^^^^^^^^^^^^^
+   = help: to disambiguate the method call, write `FinalFoo::foo(x)` instead
+
+error[E0308]: mismatched types
+  --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:137:24
+   |
+LL |     let _seetype: () = z; //~ ERROR mismatched types
+   |                        ^ expected (), found u8
+   |
+   = note: expected type `()`
+              found type `u8`
+
+error[E0308]: mismatched types
+  --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:155:24
+   |
+LL |     let _seetype: () = z; //~ ERROR mismatched types
+   |                        ^ expected (), found u32
+   |
+   = note: expected type `()`
+              found type `u32`
+
+error[E0308]: mismatched types
+  --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:172:24
+   |
+LL |     let _seetype: () = z; //~ ERROR mismatched types
+   |                        ^ expected (), found u32
+   |
+   = note: expected type `()`
+              found type `u32`
+
+error: aborting due to 6 previous errors
+
+Some errors occurred: E0034, E0308.
+For more information about an error, try `rustc --explain E0034`.
diff --git a/src/test/ui/methods/method-trait-object-with-hrtb.rs b/src/test/ui/methods/method-trait-object-with-hrtb.rs
new file mode 100644 (file)
index 0000000..da2f13f
--- /dev/null
@@ -0,0 +1,41 @@
+// compile-pass
+
+// Check that method probing ObjectCandidate works in the presence of
+// auto traits and/or HRTBs.
+
+mod internal {
+    pub trait MyObject<'a> {
+        type Output;
+
+        fn foo(&self) -> Self::Output;
+    }
+
+    impl<'a> MyObject<'a> for () {
+        type Output = &'a u32;
+
+        fn foo(&self) -> Self::Output { &4 }
+    }
+}
+
+fn t1(d: &dyn for<'a> internal::MyObject<'a, Output=&'a u32>) {
+    d.foo();
+}
+
+fn t2(d: &dyn internal::MyObject<'static, Output=&'static u32>) {
+    d.foo();
+}
+
+fn t3(d: &(dyn for<'a> internal::MyObject<'a, Output=&'a u32> + Sync)) {
+    d.foo();
+}
+
+fn t4(d: &(dyn internal::MyObject<'static, Output=&'static u32> + Sync)) {
+    d.foo();
+}
+
+fn main() {
+    t1(&());
+    t2(&());
+    t3(&());
+    t4(&());
+}
index 102f8d02ee416fd1f238521ef27d37c41468f6c5..85413acdb149166ef51ca696fe39332fe54d70ae 100644 (file)
@@ -1,4 +1,4 @@
-// error-pattern:can't use type parameters from outer function
+// error-pattern:can't use generic parameters from outer function
 fn hd<U>(v: Vec<U> ) -> U {
     fn hd1(w: [U]) -> U { return w[0]; }
 
index 617eddf6525df2cfd5a59be511c9812d4ff85e6b..37adeffb9b07afb46b8affa88c8ce97aaf7e7714 100644 (file)
@@ -1,22 +1,22 @@
-error[E0401]: can't use type parameters from outer function
+error[E0401]: can't use generic parameters from outer function
   --> $DIR/nested-ty-params.rs:3:16
    |
 LL | fn hd<U>(v: Vec<U> ) -> U {
    |       - type variable from outer function
 LL |     fn hd1(w: [U]) -> U { return w[0]; }
-   |        ---     ^ use of type variable from outer function
+   |        ---     ^ use of generic parameter from outer function
    |        |
-   |        help: try using a local type parameter instead: `hd1<U>`
+   |        help: try using a local generic parameter instead: `hd1<U>`
 
-error[E0401]: can't use type parameters from outer function
+error[E0401]: can't use generic parameters from outer function
   --> $DIR/nested-ty-params.rs:3:23
    |
 LL | fn hd<U>(v: Vec<U> ) -> U {
    |       - type variable from outer function
 LL |     fn hd1(w: [U]) -> U { return w[0]; }
-   |        ---            ^ use of type variable from outer function
+   |        ---            ^ use of generic parameter from outer function
    |        |
-   |        help: try using a local type parameter instead: `hd1<U>`
+   |        help: try using a local generic parameter instead: `hd1<U>`
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/nll/issue-57960.rs b/src/test/ui/nll/issue-57960.rs
new file mode 100644 (file)
index 0000000..0b52e46
--- /dev/null
@@ -0,0 +1,39 @@
+// run-pass
+
+#![allow(dead_code)]
+
+trait Range {
+    const FIRST: u8;
+    const LAST: u8;
+}
+
+struct OneDigit;
+impl Range for OneDigit {
+    const FIRST: u8 = 0;
+    const LAST: u8 = 9;
+}
+
+struct TwoDigits;
+impl Range for TwoDigits {
+    const FIRST: u8 = 10;
+    const LAST: u8 = 99;
+}
+
+struct ThreeDigits;
+impl Range for ThreeDigits {
+    const FIRST: u8 = 100;
+    const LAST: u8 = 255;
+}
+
+fn digits(x: u8) -> u32 {
+    match x {
+        OneDigit::FIRST...OneDigit::LAST => 1,
+        TwoDigits::FIRST...TwoDigits::LAST => 2,
+        ThreeDigits::FIRST...ThreeDigits::LAST => 3,
+        _ => unreachable!(),
+    }
+}
+
+fn main() {
+    assert_eq!(digits(100), 3);
+}
index 92d8cbc100a039fa79499ff976c0b75724b80ab7..76f7af38e776dcd3b1ca8260669ff958795e297d 100644 (file)
@@ -1,3 +1,9 @@
+error: unexpected token: `;`
+  --> $DIR/parser-recovery-2.rs:12:15
+   |
+LL |     let x = y.;  //~ ERROR unexpected token
+   |               ^
+
 error: incorrect close delimiter: `)`
   --> $DIR/parser-recovery-2.rs:8:5
    |
@@ -7,12 +13,6 @@ LL |         let x = foo(); //~ ERROR cannot find function `foo` in this scope
 LL |     ) //~ ERROR incorrect close delimiter: `)`
    |     ^ incorrect close delimiter
 
-error: unexpected token: `;`
-  --> $DIR/parser-recovery-2.rs:12:15
-   |
-LL |     let x = y.;  //~ ERROR unexpected token
-   |               ^
-
 error[E0425]: cannot find function `foo` in this scope
   --> $DIR/parser-recovery-2.rs:7:17
    |
index 89a969bb2e2a92fd939f6aa17171e743a35ec95f..9225cfce94eb8e832735a63eb6983894b39a4290 100644 (file)
@@ -6,6 +6,6 @@
 type A = for<'a: 'b,> fn(); // OK(rejected later by ast_validation)
 type A = for<'a: 'b +> fn(); // OK (rejected later by ast_validation)
 type A = for<'a, T> fn(); // OK (rejected later by ast_validation)
-type A = for<,> fn(); //~ ERROR expected one of `>`, identifier, or lifetime, found `,`
+type A = for<,> fn(); //~ ERROR expected one of `>`, `const`, identifier, or lifetime, found `,`
 
 fn main() {}
index f39e5beb6ac90d168e64b9db65b64670ef559408..191ea3ebd070acfd0243e104cd61b215b7eda3b2 100644 (file)
@@ -1,8 +1,8 @@
-error: expected one of `>`, identifier, or lifetime, found `,`
+error: expected one of `>`, `const`, identifier, or lifetime, found `,`
   --> $DIR/bounds-lifetime.rs:9:14
    |
-LL | type A = for<,> fn(); //~ ERROR expected one of `>`, identifier, or lifetime, found `,`
-   |              ^ expected one of `>`, identifier, or lifetime here
+LL | type A = for<,> fn(); //~ ERROR expected one of `>`, `const`, identifier, or lifetime, found `,`
+   |              ^ expected one of `>`, `const`, identifier, or lifetime here
 
 error: aborting due to previous error
 
index a02fd41b349c25224502ac66a2466ff9602e0b0e..6fb63639d5f6040a9e6036690f0563f04343c216 100644 (file)
@@ -5,7 +5,7 @@ pub fn trace_option(option: Option<isize>) {
     option.map(|some| 42;
                           //~^ ERROR: expected one of
 
-} //~ ERROR: incorrect close delimiter
+}
 //~^ ERROR: expected expression, found `)`
 
 fn main() {}
index 9b3115cb3f4b7f125855717885277159504b914d..38d57ce57236556b51c54a1b974529ae6d6503c3 100644 (file)
@@ -1,25 +1,17 @@
-error: incorrect close delimiter: `}`
-  --> $DIR/issue-10636-2.rs:8:1
-   |
-LL | pub fn trace_option(option: Option<isize>) {
-   |                                            - close delimiter possibly meant for this
-LL |     option.map(|some| 42;
-   |               - un-closed delimiter
-...
-LL | } //~ ERROR: incorrect close delimiter
-   | ^ incorrect close delimiter
-
 error: expected one of `)`, `,`, `.`, `?`, or an operator, found `;`
   --> $DIR/issue-10636-2.rs:5:25
    |
 LL |     option.map(|some| 42;
-   |                         ^ expected one of `)`, `,`, `.`, `?`, or an operator here
+   |               -         ^
+   |               |         |
+   |               |         help: `)` may belong here
+   |               unclosed delimiter
 
 error: expected expression, found `)`
   --> $DIR/issue-10636-2.rs:8:1
    |
-LL | } //~ ERROR: incorrect close delimiter
+LL | }
    | ^ expected expression
 
-error: aborting due to 3 previous errors
+error: aborting due to 2 previous errors
 
index a31429e7228c513868d6350951e3e7aab5258918..bcecd75b1abbad33e772bf4e1042befd4dfba493 100644 (file)
@@ -2,11 +2,7 @@ error: lifetime parameters must be declared prior to type parameters
   --> $DIR/issue-14303-enum.rs:1:15
    |
 LL | enum X<'a, T, 'b> {
-   |               ^^
-help: move the lifetime parameter prior to the first type parameter
-   |
-LL | enum X<'a, 'b, T> {
-   |            ^^^ --
+   |       --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>`
 
 error: aborting due to previous error
 
index 4582aeef428d37d4e93f554b6399dea75c3b9828..082c37e0be7956e8789126a54c1dcaf7d4452add 100644 (file)
@@ -2,11 +2,7 @@ error: lifetime parameters must be declared prior to type parameters
   --> $DIR/issue-14303-fn-def.rs:1:15
    |
 LL | fn foo<'a, T, 'b>(x: &'a T) {}
-   |               ^^
-help: move the lifetime parameter prior to the first type parameter
-   |
-LL | fn foo<'a, 'b, T>(x: &'a T) {}
-   |            ^^^ --
+   |       --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>`
 
 error: aborting due to previous error
 
index 17b9b766b21816f75d23d2d2c0698e35f1253ea1..39694198cdb4d1807fac4bbb2438c4664dc681f0 100644 (file)
@@ -11,7 +11,7 @@ fn foo<'a, 'b>(start: &'a usize, end: &'a usize) {
     let _x = (*start..*end)
         .map(|x| S { a: start, b: end })
         .collect::<Vec<S<_, 'a>>>();
-        //~^ ERROR lifetime parameters must be declared prior to type parameters
+        //~^ ERROR lifetime arguments must be declared prior to type arguments
 }
 
 fn main() {}
index 2a7364915949efd3dbbeb3569b9f404543b929dd..8ef9f1a1a6c79edcb1533627a2aafb7cbdc08628 100644 (file)
@@ -1,12 +1,8 @@
-error: lifetime parameters must be declared prior to type parameters
+error: lifetime arguments must be declared prior to type arguments
   --> $DIR/issue-14303-fncall.rs:13:29
    |
 LL |         .collect::<Vec<S<_, 'a>>>();
-   |                             ^^ must be declared prior to type parameters
-help: move the lifetime parameter prior to the first type parameter
-   |
-LL |         .collect::<Vec<S<'a, _>>>();
-   |                          ^^^ --
+   |                             ^^
 
 error: aborting due to previous error
 
index a1953396153e0cb6ba2d0eda42ffec7b14781806..3b5615d2a9ecab7e55415c4924b1ce5c9c88ea71 100644 (file)
@@ -2,11 +2,7 @@ error: lifetime parameters must be declared prior to type parameters
   --> $DIR/issue-14303-impl.rs:3:13
    |
 LL | impl<'a, T, 'b> X<T> {}
-   |             ^^
-help: move the lifetime parameter prior to the first type parameter
-   |
-LL | impl<'a, 'b, T> X<T> {}
-   |          ^^^ --
+   |     --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>`
 
 error: aborting due to previous error
 
index a08c89f3437b4be1c97fd7dc65d26077f1fdf808..386d19859e4a83d6a6055ee2e295f4d6023df6cc 100644 (file)
@@ -8,6 +8,6 @@ pub struct X<'a, 'b, 'c, T> {
 }
 
 fn bar<'a, 'b, 'c, T>(x: foo::X<'a, T, 'b, 'c>) {}
-//~^ ERROR lifetime parameters must be declared prior to type parameters
+//~^ ERROR lifetime arguments must be declared prior to type arguments
 
 fn main() {}
index fb4fb32e11e50021d11fdf0841ec59a09d1ac0a1..19f2995ebee536e652d98662d357b6bca4ea263c 100644 (file)
@@ -1,14 +1,8 @@
-error: lifetime parameters must be declared prior to type parameters
+error: lifetime arguments must be declared prior to type arguments
   --> $DIR/issue-14303-path.rs:10:40
    |
 LL | fn bar<'a, 'b, 'c, T>(x: foo::X<'a, T, 'b, 'c>) {}
-   |                                        ^^  ^^ must be declared prior to type parameters
-   |                                        |
-   |                                        must be declared prior to type parameters
-help: move the lifetime parameters prior to the first type parameter
-   |
-LL | fn bar<'a, 'b, 'c, T>(x: foo::X<'a, 'b, 'c, T>) {}
-   |                                     ^^^ ^^^ --
+   |                                        ^^  ^^
 
 error: aborting due to previous error
 
index 668b8d1de6899d36004faca63af96fd0079e2def..dbd0b987dd1901bfaba0b6e650949fc4c9799408 100644 (file)
@@ -2,11 +2,7 @@ error: lifetime parameters must be declared prior to type parameters
   --> $DIR/issue-14303-struct.rs:1:17
    |
 LL | struct X<'a, T, 'b> {
-   |                 ^^
-help: move the lifetime parameter prior to the first type parameter
-   |
-LL | struct X<'a, 'b, T> {
-   |              ^^^ --
+   |         --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>`
 
 error: aborting due to previous error
 
index 11ce0c44351ad1734f110a17d1fec318132a6bf8..7dfa62d823fd8754c7f3873797b2a401b73ac7c3 100644 (file)
@@ -2,11 +2,7 @@ error: lifetime parameters must be declared prior to type parameters
   --> $DIR/issue-14303-trait.rs:1:18
    |
 LL | trait Foo<'a, T, 'b> {}
-   |                  ^^
-help: move the lifetime parameter prior to the first type parameter
-   |
-LL | trait Foo<'a, 'b, T> {}
-   |               ^^^ --
+   |          --------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T>`
 
 error: aborting due to previous error
 
index 7e55bc038e76681d412793a4333ec3ca7e34800c..7191a3234c0837828a3f8b1ab5149c0baa97c6b4 100644 (file)
@@ -3,6 +3,6 @@
 trait Trait<T> { type Item; }
 
 pub fn test<W, I: Trait<Item=(), W> >() {}
-//~^ ERROR type parameters must be declared prior to associated type bindings
+//~^ ERROR associated type bindings must be declared after generic parameters
 
 fn main() { }
index 660e517c85a13d32aaf54fecb7a60b1e768a4764..7022019a22f26c4aed51ba70aa39693ad023da81 100644 (file)
@@ -1,12 +1,10 @@
-error: type parameters must be declared prior to associated type bindings
-  --> $DIR/issue-32214.rs:5:34
+error: associated type bindings must be declared after generic parameters
+  --> $DIR/issue-32214.rs:5:25
    |
 LL | pub fn test<W, I: Trait<Item=(), W> >() {}
-   |                                  ^ must be declared prior to associated type bindings
-help: move the type parameter prior to the first associated type binding
-   |
-LL | pub fn test<W, I: Trait<W, Item=()> >() {}
-   |                         ^^       --
+   |                         -------^^^
+   |                         |
+   |                         this associated type binding should be moved after the generic parameters
 
 error: aborting due to previous error
 
index 805ba8b6baa60ae1ee823c9caf76f7cfe60ed5fd..abb0820979532e92d3c220f4e9c3cfef2ba1749b 100644 (file)
@@ -1,3 +1,9 @@
+error: unexpected close delimiter: `}`
+  --> $DIR/macro-mismatched-delim-paren-brace.rs:5:1
+   |
+LL | } //~ ERROR unexpected close delimiter: `}`
+   | ^ unexpected close delimiter
+
 error: incorrect close delimiter: `}`
   --> $DIR/macro-mismatched-delim-paren-brace.rs:4:5
    |
@@ -7,11 +13,5 @@ LL |         bar, "baz", 1, 2.0
 LL |     } //~ ERROR incorrect close delimiter
    |     ^ incorrect close delimiter
 
-error: unexpected close delimiter: `}`
-  --> $DIR/macro-mismatched-delim-paren-brace.rs:5:1
-   |
-LL | } //~ ERROR unexpected close delimiter: `}`
-   | ^ unexpected close delimiter
-
 error: aborting due to 2 previous errors
 
index 12de76d9d6d9f9aca974c3bf677c4632bdc461ad..79d51f5595d2635283c36d94989c42bb8afc8ce5 100644 (file)
@@ -1 +1 @@
-type mut_box = Box<mut isize>; //~ ERROR expected one of `>`, lifetime, or type, found `mut`
+type mut_box = Box<mut isize>; //~ ERROR expected one of `>`, const, lifetime, or type, found `mut`
index 0177b19d74e7e1530ccf84c29071f2a65e67c865..b2759778d0313a75997fa09d2ce3623d86c55dfe 100644 (file)
@@ -1,8 +1,8 @@
-error: expected one of `>`, lifetime, or type, found `mut`
+error: expected one of `>`, const, lifetime, or type, found `mut`
   --> $DIR/removed-syntax-uniq-mut-ty.rs:1:20
    |
-LL | type mut_box = Box<mut isize>; //~ ERROR expected one of `>`, lifetime, or type, found `mut`
-   |                    ^^^ expected one of `>`, lifetime, or type here
+LL | type mut_box = Box<mut isize>; //~ ERROR expected one of `>`, const, lifetime, or type, found `mut`
+   |                    ^^^ expected one of `>`, const, lifetime, or type here
 
 error: aborting due to previous error
 
index 112427a3fceaeb723b0d1a7653d81f051e3e2388..c77a66524f73f530b9ac3560ee4d7e0d3b86c28a 100644 (file)
@@ -6,7 +6,7 @@ trait TraitA<A> {
     fn outer(&self) {
         enum Foo<B> {
             Variance(A)
-                //~^ ERROR can't use type parameters from outer function
+                //~^ ERROR can't use generic parameters from outer function
         }
     }
 }
@@ -14,21 +14,21 @@ enum Foo<B> {
 trait TraitB<A> {
     fn outer(&self) {
         struct Foo<B>(A);
-                //~^ ERROR can't use type parameters from outer function
+                //~^ ERROR can't use generic parameters from outer function
     }
 }
 
 trait TraitC<A> {
     fn outer(&self) {
         struct Foo<B> { a: A }
-                //~^ ERROR can't use type parameters from outer function
+                //~^ ERROR can't use generic parameters from outer function
     }
 }
 
 trait TraitD<A> {
     fn outer(&self) {
         fn foo<B>(a: A) { }
-                //~^ ERROR can't use type parameters from outer function
+                //~^ ERROR can't use generic parameters from outer function
     }
 }
 
index 8eca720d88e8cb988ea16cfd16d957c5fc6bbdc4..f6b8abf4057e500f2889c1973ee33c8607a07daa 100644 (file)
@@ -1,44 +1,44 @@
-error[E0401]: can't use type parameters from outer function
+error[E0401]: can't use generic parameters from outer function
   --> $DIR/resolve-type-param-in-item-in-trait.rs:8:22
    |
 LL | trait TraitA<A> {
    |              - type variable from outer function
 LL |     fn outer(&self) {
-   |        ----- try adding a local type parameter in this method instead
+   |        ----- try adding a local generic parameter in this method instead
 LL |         enum Foo<B> {
 LL |             Variance(A)
-   |                      ^ use of type variable from outer function
+   |                      ^ use of generic parameter from outer function
 
-error[E0401]: can't use type parameters from outer function
+error[E0401]: can't use generic parameters from outer function
   --> $DIR/resolve-type-param-in-item-in-trait.rs:16:23
    |
 LL | trait TraitB<A> {
    |              - type variable from outer function
 LL |     fn outer(&self) {
-   |        ----- try adding a local type parameter in this method instead
+   |        ----- try adding a local generic parameter in this method instead
 LL |         struct Foo<B>(A);
-   |                       ^ use of type variable from outer function
+   |                       ^ use of generic parameter from outer function
 
-error[E0401]: can't use type parameters from outer function
+error[E0401]: can't use generic parameters from outer function
   --> $DIR/resolve-type-param-in-item-in-trait.rs:23:28
    |
 LL | trait TraitC<A> {
    |              - type variable from outer function
 LL |     fn outer(&self) {
-   |        ----- try adding a local type parameter in this method instead
+   |        ----- try adding a local generic parameter in this method instead
 LL |         struct Foo<B> { a: A }
-   |                            ^ use of type variable from outer function
+   |                            ^ use of generic parameter from outer function
 
-error[E0401]: can't use type parameters from outer function
+error[E0401]: can't use generic parameters from outer function
   --> $DIR/resolve-type-param-in-item-in-trait.rs:30:22
    |
 LL | trait TraitD<A> {
    |              - type variable from outer function
 LL |     fn outer(&self) {
 LL |         fn foo<B>(a: A) { }
-   |            ------    ^ use of type variable from outer function
+   |            ------    ^ use of generic parameter from outer function
    |            |
-   |            help: try using a local type parameter instead: `foo<B, A>`
+   |            help: try using a local generic parameter instead: `foo<B, A>`
 
 error: aborting due to 4 previous errors
 
index 86cf71117a6f8677686139c2a89bb82a962f81d6..b1ca0bbfc57c10b125669ebad3718e8df0f8f0a7 100644 (file)
@@ -17,7 +17,7 @@ pub fn ensure_dir_exists<P: AsRef<Path>, F: FnOnce(&Path)>(path: P,
             //~| expected type `()`
             //~| found type `std::result::Result<bool, std::io::Error>`
             //~| expected one of
-        } else { //~ ERROR: incorrect close delimiter: `}`
+        } else {
             //~^ ERROR: expected one of
             //~| unexpected token
             Ok(false);
index 2164d27a0517480ee1d69282bbd536718bffc3c8..a6bb83c71f3130a594cf54921cfab817856211a2 100644 (file)
@@ -1,19 +1,11 @@
-error: incorrect close delimiter: `}`
-  --> $DIR/token-error-correct-3.rs:20:9
-   |
-LL |         if !is_directory(path.as_ref()) { //~ ERROR: cannot find function `is_directory`
-   |                                         - close delimiter possibly meant for this
-LL |             callback(path.as_ref(); //~ ERROR expected one of
-   |                     - un-closed delimiter
-...
-LL |         } else { //~ ERROR: incorrect close delimiter: `}`
-   |         ^ incorrect close delimiter
-
 error: expected one of `)`, `,`, `.`, `?`, or an operator, found `;`
   --> $DIR/token-error-correct-3.rs:14:35
    |
 LL |             callback(path.as_ref(); //~ ERROR expected one of
-   |                                   ^ expected one of `)`, `,`, `.`, `?`, or an operator here
+   |                     -             ^
+   |                     |             |
+   |                     |             help: `)` may belong here
+   |                     unclosed delimiter
 
 error: expected one of `.`, `;`, `?`, `}`, or an operator, found `)`
   --> $DIR/token-error-correct-3.rs:20:9
@@ -21,7 +13,7 @@ error: expected one of `.`, `;`, `?`, `}`, or an operator, found `)`
 LL |             fs::create_dir_all(path.as_ref()).map(|()| true) //~ ERROR: mismatched types
    |                                                             - expected one of `.`, `;`, `?`, `}`, or an operator here
 ...
-LL |         } else { //~ ERROR: incorrect close delimiter: `}`
+LL |         } else {
    |         ^ unexpected token
 
 error[E0425]: cannot find function `is_directory` in this scope
@@ -41,7 +33,7 @@ LL |             fs::create_dir_all(path.as_ref()).map(|()| true) //~ ERROR: mis
    = note: expected type `()`
               found type `std::result::Result<bool, std::io::Error>`
 
-error: aborting due to 5 previous errors
+error: aborting due to 4 previous errors
 
 Some errors occurred: E0308, E0425.
 For more information about an error, try `rustc --explain E0308`.
index b97e22f7d910b37e762e8114a20a67ff4dada237..d64907780efb512f838d44392b8d3783063c29cc 100644 (file)
@@ -2,6 +2,8 @@
 
 fn main() {
     foo(bar(;
-    //~^ ERROR: expected expression, found `;`
+    //~^ ERROR cannot find function `bar` in this scope
 }
 //~^ ERROR: incorrect close delimiter: `}`
+
+fn foo(_: usize) {}
index 0a4590461b5ab232bfb672cef0e3fee78d74accf..b0827ea7367c2f69910ed463ebc770a088ed13bc 100644 (file)
@@ -5,15 +5,16 @@ LL | fn main() {
    |           - close delimiter possibly meant for this
 LL |     foo(bar(;
    |            - un-closed delimiter
-LL |     //~^ ERROR: expected expression, found `;`
+LL |     //~^ ERROR cannot find function `bar` in this scope
 LL | }
    | ^ incorrect close delimiter
 
-error: expected expression, found `;`
-  --> $DIR/token-error-correct.rs:4:13
+error[E0425]: cannot find function `bar` in this scope
+  --> $DIR/token-error-correct.rs:4:9
    |
 LL |     foo(bar(;
-   |             ^ expected expression
+   |         ^^^ not found in this scope
 
 error: aborting due to 2 previous errors
 
+For more information about this error, try `rustc --explain E0425`.
index 158ebc7d3888aae5c50bbc7633c701899144ce43..afc27701920dceba2981fc863605d72a445b1c71 100644 (file)
@@ -3,7 +3,7 @@
 
 trait Foo {
     type Bar<,>;
-    //~^ ERROR expected one of `>`, identifier, or lifetime, found `,`
+    //~^ ERROR expected one of `>`, `const`, identifier, or lifetime, found `,`
 }
 
 fn main() {}
index 2a01b2a3f0fa58968b14afa0087108bf58a8655f..5b98302924e3ce986bf3fb01412858b00302c834 100644 (file)
@@ -1,8 +1,8 @@
-error: expected one of `>`, identifier, or lifetime, found `,`
+error: expected one of `>`, `const`, identifier, or lifetime, found `,`
   --> $DIR/empty_generics.rs:5:14
    |
 LL |     type Bar<,>;
-   |              ^ expected one of `>`, identifier, or lifetime here
+   |              ^ expected one of `>`, `const`, identifier, or lifetime here
 
 warning: the feature `generic_associated_types` is incomplete and may cause the compiler to crash
   --> $DIR/empty_generics.rs:1:12
index b36e927b5c0c6e46cc1c5018927e5bdaf3c30eba..2d6dee0621662c5839ea606891d28fb2ade84aa4 100644 (file)
@@ -2,41 +2,25 @@ error: lifetime parameters must be declared prior to type parameters
   --> $DIR/suggest-move-lifetimes.rs:1:13
    |
 LL | struct A<T, 'a> { //~ ERROR lifetime parameters must be declared
-   |             ^^
-help: move the lifetime parameter prior to the first type parameter
-   |
-LL | struct A<'a, T> { //~ ERROR lifetime parameters must be declared
-   |          ^^^ --
+   |         ----^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T>`
 
 error: lifetime parameters must be declared prior to type parameters
   --> $DIR/suggest-move-lifetimes.rs:5:13
    |
 LL | struct B<T, 'a, U> { //~ ERROR lifetime parameters must be declared
-   |             ^^
-help: move the lifetime parameter prior to the first type parameter
-   |
-LL | struct B<'a, T, U> { //~ ERROR lifetime parameters must be declared
-   |          ^^^ --
+   |         ----^^---- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, U>`
 
 error: lifetime parameters must be declared prior to type parameters
   --> $DIR/suggest-move-lifetimes.rs:10:16
    |
 LL | struct C<T, U, 'a> { //~ ERROR lifetime parameters must be declared
-   |                ^^
-help: move the lifetime parameter prior to the first type parameter
-   |
-LL | struct C<'a, T, U> { //~ ERROR lifetime parameters must be declared
-   |          ^^^    --
+   |         -------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, T, U>`
 
 error: lifetime parameters must be declared prior to type parameters
   --> $DIR/suggest-move-lifetimes.rs:15:16
    |
 LL | struct D<T, U, 'a, 'b, V, 'c> { //~ ERROR lifetime parameters must be declared
-   |                ^^  ^^     ^^
-help: move the lifetime parameter prior to the first type parameter
-   |
-LL | struct D<'a, 'b, 'c, T, U, V> { //~ ERROR lifetime parameters must be declared
-   |          ^^^ ^^^ ^^^    -- --
+   |         -------^^--^^-----^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, 'c, T, U, V>`
 
 error: aborting due to 4 previous errors
 
index fd10ba4350c4a4bb654c0bb1ef4752313df96b58..890950ea08c5d4a316475b95181f3a28832975ef 100644 (file)
@@ -25,19 +25,20 @@ trait ThreeWithLifetime<'a, 'b, 'c, T, U, V> {
   type C;
 }
 
-struct A<T, M: One<A=(), T>> { //~ ERROR type parameters must be declared
+struct A<T, M: One<A=(), T>> { //~ ERROR associated type bindings must be declared after generic parameters
     m: M,
     t: T,
 }
 
 
 struct Al<'a, T, M: OneWithLifetime<A=(), T, 'a>> {
-//~^ ERROR generic arguments must declare lifetimes, types and associated type bindings in that order
+//~^ ERROR associated type bindings must be declared after generic parameters
+//~^^ ERROR lifetime arguments must be declared prior to type arguments
     m: M,
     t: &'a T,
 }
 
-struct B<T, U, V, M: Three<A=(), B=(), C=(), T, U, V>> { //~ ERROR type parameters must be declared
+struct B<T, U, V, M: Three<A=(), B=(), C=(), T, U, V>> { //~ ERROR associated type bindings must be declared after generic parameters
     m: M,
     t: T,
     u: U,
@@ -45,14 +46,15 @@ struct B<T, U, V, M: Three<A=(), B=(), C=(), T, U, V>> { //~ ERROR type paramete
 }
 
 struct Bl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<A=(), B=(), C=(), T, U, V, 'a, 'b, 'c>> {
-//~^ ERROR generic arguments must declare lifetimes, types and associated type bindings in that order
+//~^ ERROR associated type bindings must be declared after generic parameters
+//~^^ ERROR lifetime arguments must be declared prior to type arguments
     m: M,
     t: &'a T,
     u: &'b U,
     v: &'c V,
 }
 
-struct C<T, U, V, M: Three<T, A=(), B=(), C=(), U, V>> { //~ ERROR type parameters must be declared
+struct C<T, U, V, M: Three<T, A=(), B=(), C=(), U, V>> { //~ ERROR associated type bindings must be declared after generic parameters
     m: M,
     t: T,
     u: U,
@@ -60,14 +62,15 @@ struct C<T, U, V, M: Three<T, A=(), B=(), C=(), U, V>> { //~ ERROR type paramete
 }
 
 struct Cl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<T, 'a, A=(), B=(), C=(), U, 'b, V, 'c>> {
-//~^ ERROR generic arguments must declare lifetimes, types and associated type bindings in that order
+//~^ ERROR associated type bindings must be declared after generic parameters
+//~^^ ERROR lifetime arguments must be declared prior to type arguments
     m: M,
     t: &'a T,
     u: &'b U,
     v: &'c V,
 }
 
-struct D<T, U, V, M: Three<T, A=(), B=(), U, C=(), V>> { //~ ERROR type parameters must be declared
+struct D<T, U, V, M: Three<T, A=(), B=(), U, C=(), V>> { //~ ERROR associated type bindings must be declared after generic parameters
     m: M,
     t: T,
     u: U,
@@ -75,7 +78,8 @@ struct D<T, U, V, M: Three<T, A=(), B=(), U, C=(), V>> { //~ ERROR type paramete
 }
 
 struct Dl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<T, 'a, A=(), B=(), U, 'b, C=(), V, 'c>> {
-//~^ ERROR generic arguments must declare lifetimes, types and associated type bindings in that order
+//~^ ERROR associated type bindings must be declared after generic parameters
+//~^^ ERROR lifetime arguments must be declared prior to type arguments
     m: M,
     t: &'a T,
     u: &'b U,
index 3643d9a912455ea6a4ffeb1e9883fcb41e492839..0901b71911d432023f6579a26bad2cde2e2fa18b 100644 (file)
-error: type parameters must be declared prior to associated type bindings
-  --> $DIR/suggest-move-types.rs:28:26
+error: associated type bindings must be declared after generic parameters
+  --> $DIR/suggest-move-types.rs:28:20
    |
-LL | struct A<T, M: One<A=(), T>> { //~ ERROR type parameters must be declared
-   |                          ^ must be declared prior to associated type bindings
-help: move the type parameter prior to the first associated type binding
-   |
-LL | struct A<T, M: One<T, A=()>> { //~ ERROR type parameters must be declared
-   |                    ^^    --
+LL | struct A<T, M: One<A=(), T>> { //~ ERROR associated type bindings must be declared after generic parameters
+   |                    ----^^^
+   |                    |
+   |                    this associated type binding should be moved after the generic parameters
 
-error: generic arguments must declare lifetimes, types and associated type bindings in that order
-  --> $DIR/suggest-move-types.rs:34:46
+error: associated type bindings must be declared after generic parameters
+  --> $DIR/suggest-move-types.rs:34:37
    |
 LL | struct Al<'a, T, M: OneWithLifetime<A=(), T, 'a>> {
-   |                                           ^  ^^ must be declared prior to type parameters
-   |                                           |
-   |                                           must be declared prior to associated type bindings
-help: move the parameters
-   |
-LL | struct Al<'a, T, M: OneWithLifetime<'a, T, A=()>> {
-   |                                     ^^^ ^^    --
+   |                                     ----^^^^^^^
+   |                                     |
+   |                                     this associated type binding should be moved after the generic parameters
 
-error: type parameters must be declared prior to associated type bindings
-  --> $DIR/suggest-move-types.rs:40:46
-   |
-LL | struct B<T, U, V, M: Three<A=(), B=(), C=(), T, U, V>> { //~ ERROR type parameters must be declared
-   |                                              ^  ^  ^ must be declared prior to associated type bindings
-   |                                              |  |
-   |                                              |  must be declared prior to associated type bindings
-   |                                              must be declared prior to associated type bindings
-help: move the type parameters prior to the first associated type binding
-   |
-LL | struct B<T, U, V, M: Three<T, U, V, A=(), B=(), C=()>> { //~ ERROR type parameters must be declared
-   |                            ^^ ^^ ^^                --
+error: associated type bindings must be declared after generic parameters
+  --> $DIR/suggest-move-types.rs:41:28
+   |
+LL | struct B<T, U, V, M: Three<A=(), B=(), C=(), T, U, V>> { //~ ERROR associated type bindings must be declared after generic parameters
+   |                            ----^^----^^----^^^^^^^^^
+   |                            |     |     |
+   |                            |     |     this associated type binding should be moved after the generic parameters
+   |                            |     this associated type binding should be moved after the generic parameters
+   |                            this associated type binding should be moved after the generic parameters
 
-error: generic arguments must declare lifetimes, types and associated type bindings in that order
-  --> $DIR/suggest-move-types.rs:47:80
+error: associated type bindings must be declared after generic parameters
+  --> $DIR/suggest-move-types.rs:48:53
    |
 LL | struct Bl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<A=(), B=(), C=(), T, U, V, 'a, 'b, 'c>> {
-   |                                                                       ^  ^  ^  ^^  ^^  ^^ must be declared prior to type parameters
-   |                                                                       |  |  |  |   |
-   |                                                                       |  |  |  |   must be declared prior to type parameters
-   |                                                                       |  |  |  must be declared prior to type parameters
-   |                                                                       |  |  must be declared prior to associated type bindings
-   |                                                                       |  must be declared prior to associated type bindings
-   |                                                                       must be declared prior to associated type bindings
-help: move the parameters
-   |
-LL | struct Bl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<'a, 'b, 'c, T, U, V, A=(), B=(), C=()>> {
-   |                                                     ^^^ ^^^ ^^^ ^^ ^^ ^^                --
+   |                                                     ----^^----^^----^^^^^^^^^^^^^^^^^^^^^
+   |                                                     |     |     |
+   |                                                     |     |     this associated type binding should be moved after the generic parameters
+   |                                                     |     this associated type binding should be moved after the generic parameters
+   |                                                     this associated type binding should be moved after the generic parameters
 
-error: type parameters must be declared prior to associated type bindings
-  --> $DIR/suggest-move-types.rs:55:49
-   |
-LL | struct C<T, U, V, M: Three<T, A=(), B=(), C=(), U, V>> { //~ ERROR type parameters must be declared
-   |                                                 ^  ^ must be declared prior to associated type bindings
-   |                                                 |
-   |                                                 must be declared prior to associated type bindings
-help: move the type parameters prior to the first associated type binding
-   |
-LL | struct C<T, U, V, M: Three<T, U, V, A=(), B=(), C=()>> { //~ ERROR type parameters must be declared
-   |                               ^^ ^^                --
+error: associated type bindings must be declared after generic parameters
+  --> $DIR/suggest-move-types.rs:57:28
+   |
+LL | struct C<T, U, V, M: Three<T, A=(), B=(), C=(), U, V>> { //~ ERROR associated type bindings must be declared after generic parameters
+   |                            ^^^----^^----^^----^^^^^^
+   |                               |     |     |
+   |                               |     |     this associated type binding should be moved after the generic parameters
+   |                               |     this associated type binding should be moved after the generic parameters
+   |                               this associated type binding should be moved after the generic parameters
 
-error: generic arguments must declare lifetimes, types and associated type bindings in that order
-  --> $DIR/suggest-move-types.rs:62:56
+error: associated type bindings must be declared after generic parameters
+  --> $DIR/suggest-move-types.rs:64:53
    |
 LL | struct Cl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<T, 'a, A=(), B=(), C=(), U, 'b, V, 'c>> {
-   |                                                        ^^                    ^  ^^  ^  ^^ must be declared prior to type parameters
-   |                                                        |                     |  |   |
-   |                                                        |                     |  |   must be declared prior to associated type bindings
-   |                                                        |                     |  must be declared prior to type parameters
-   |                                                        |                     must be declared prior to associated type bindings
-   |                                                        must be declared prior to type parameters
-help: move the parameters
+   |                                                     ^^^^^^^----^^----^^----^^^^^^^^^^^^^^
+   |                                                            |     |     |
+   |                                                            |     |     this associated type binding should be moved after the generic parameters
+   |                                                            |     this associated type binding should be moved after the generic parameters
+   |                                                            this associated type binding should be moved after the generic parameters
+
+error: associated type bindings must be declared after generic parameters
+  --> $DIR/suggest-move-types.rs:73:28
+   |
+LL | struct D<T, U, V, M: Three<T, A=(), B=(), U, C=(), V>> { //~ ERROR associated type bindings must be declared after generic parameters
+   |                            ^^^----^^----^^^^^----^^^
+   |                               |     |        |
+   |                               |     |        this associated type binding should be moved after the generic parameters
+   |                               |     this associated type binding should be moved after the generic parameters
+   |                               this associated type binding should be moved after the generic parameters
+
+error: associated type bindings must be declared after generic parameters
+  --> $DIR/suggest-move-types.rs:80:53
    |
-LL | struct Cl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<'a, 'b, 'c, T, U, V, A=(), B=(), C=()>> {
-   |                                                     ^^^ ^^^ ^^^ -- ^^ ^^                --
+LL | struct Dl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<T, 'a, A=(), B=(), U, 'b, C=(), V, 'c>> {
+   |                                                     ^^^^^^^----^^----^^^^^^^^^----^^^^^^^
+   |                                                            |     |            |
+   |                                                            |     |            this associated type binding should be moved after the generic parameters
+   |                                                            |     this associated type binding should be moved after the generic parameters
+   |                                                            this associated type binding should be moved after the generic parameters
 
-error: type parameters must be declared prior to associated type bindings
-  --> $DIR/suggest-move-types.rs:70:43
+error: lifetime arguments must be declared prior to type arguments
+  --> $DIR/suggest-move-types.rs:34:46
    |
-LL | struct D<T, U, V, M: Three<T, A=(), B=(), U, C=(), V>> { //~ ERROR type parameters must be declared
-   |                                           ^        ^ must be declared prior to associated type bindings
-   |                                           |
-   |                                           must be declared prior to associated type bindings
-help: move the type parameters prior to the first associated type binding
+LL | struct Al<'a, T, M: OneWithLifetime<A=(), T, 'a>> {
+   |                                              ^^
+
+error: lifetime arguments must be declared prior to type arguments
+  --> $DIR/suggest-move-types.rs:48:80
    |
-LL | struct D<T, U, V, M: Three<T, U, V, A=(), B=(), C=()>> { //~ ERROR type parameters must be declared
-   |                               ^^ ^^          --    --
+LL | struct Bl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<A=(), B=(), C=(), T, U, V, 'a, 'b, 'c>> {
+   |                                                                                ^^  ^^  ^^
 
-error: generic arguments must declare lifetimes, types and associated type bindings in that order
-  --> $DIR/suggest-move-types.rs:77:56
+error: lifetime arguments must be declared prior to type arguments
+  --> $DIR/suggest-move-types.rs:64:56
    |
-LL | struct Dl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<T, 'a, A=(), B=(), U, 'b, C=(), V, 'c>> {
-   |                                                        ^^              ^  ^^        ^  ^^ must be declared prior to type parameters
-   |                                                        |               |  |         |
-   |                                                        |               |  |         must be declared prior to associated type bindings
-   |                                                        |               |  must be declared prior to type parameters
-   |                                                        |               must be declared prior to associated type bindings
-   |                                                        must be declared prior to type parameters
-help: move the parameters
+LL | struct Cl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<T, 'a, A=(), B=(), C=(), U, 'b, V, 'c>> {
+   |                                                        ^^                       ^^     ^^
+
+error: lifetime arguments must be declared prior to type arguments
+  --> $DIR/suggest-move-types.rs:80:56
    |
-LL | struct Dl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<'a, 'b, 'c, T, U, V, A=(), B=(), C=()>> {
-   |                                                     ^^^ ^^^ ^^^ -- ^^ ^^          --    --
+LL | struct Dl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<T, 'a, A=(), B=(), U, 'b, C=(), V, 'c>> {
+   |                                                        ^^                 ^^           ^^
 
-error: aborting due to 8 previous errors
+error: aborting due to 12 previous errors
 
index a12429c868ed028d414575a5d567a27bd5967208..36dec21be0520987d390d1ba59bc0db4982a07a3 100644 (file)
@@ -12,6 +12,6 @@ fn main() {
     //~^ ERROR wrong number of lifetime arguments: expected 1, found 2
     //~| ERROR wrong number of type arguments: expected 1, found 0
     let _: S<'static +, 'static>;
-    //~^ ERROR lifetime parameters must be declared prior to type parameters
+    //~^ ERROR lifetime arguments must be declared prior to type arguments
     //~| ERROR at least one non-builtin trait is required for an object type
 }
index 4cc96bae5cd171b4f0b51dc3f2fb3551e2a591fc..e0c52a72a0931b0941800200b23c8f77befc979c 100644 (file)
@@ -1,12 +1,8 @@
-error: lifetime parameters must be declared prior to type parameters
+error: lifetime arguments must be declared prior to type arguments
   --> $DIR/trait-object-vs-lifetime.rs:14:25
    |
 LL |     let _: S<'static +, 'static>;
-   |                         ^^^^^^^ must be declared prior to type parameters
-help: move the lifetime parameter prior to the first type parameter
-   |
-LL |     let _: S<'static, 'static +>;
-   |              ^^^^^^^^         --
+   |                         ^^^^^^^
 
 error[E0224]: at least one non-builtin trait is required for an object type
   --> $DIR/trait-object-vs-lifetime.rs:9:23
index b96c9bf6a0e41de6d781cf007da3e1d51bfb8c2c..d5b815f6a95e9ab99aef0c315eb654430fb357c9 100644 (file)
@@ -1,4 +1,4 @@
-// error-pattern:can't use type parameters from outer function
+// error-pattern:can't use generic parameters from outer function
 fn foo<T>(x: T) {
     fn bar(f: Box<FnMut(T) -> T>) { }
 }
index 62b6a86662d04b3765260de2de98184261af35ae..645cbb33abec14a5da176c425bf2bbe24b094a5b 100644 (file)
@@ -1,22 +1,22 @@
-error[E0401]: can't use type parameters from outer function
+error[E0401]: can't use generic parameters from outer function
   --> $DIR/type-arg-out-of-scope.rs:3:25
    |
 LL | fn foo<T>(x: T) {
    |        - type variable from outer function
 LL |     fn bar(f: Box<FnMut(T) -> T>) { }
-   |        ---              ^ use of type variable from outer function
+   |        ---              ^ use of generic parameter from outer function
    |        |
-   |        help: try using a local type parameter instead: `bar<T>`
+   |        help: try using a local generic parameter instead: `bar<T>`
 
-error[E0401]: can't use type parameters from outer function
+error[E0401]: can't use generic parameters from outer function
   --> $DIR/type-arg-out-of-scope.rs:3:31
    |
 LL | fn foo<T>(x: T) {
    |        - type variable from outer function
 LL |     fn bar(f: Box<FnMut(T) -> T>) { }
-   |        ---                    ^ use of type variable from outer function
+   |        ---                    ^ use of generic parameter from outer function
    |        |
-   |        help: try using a local type parameter instead: `bar<T>`
+   |        help: try using a local generic parameter instead: `bar<T>`
 
 error: aborting due to 2 previous errors
 
index 4c366a863637c916498f9b3ff521f93ba1c2bc7e..51bd116fbd61c071caed3376d2ffbe5f8aa668fa 100644 (file)
@@ -1,6 +1,6 @@
 fn main() {
     let v = vec![0];
-    const l: usize = v.count(); //~ ERROR can't capture dynamic environment in a fn item
+    const l: usize = v.count(); //~ ERROR attempt to use a non-constant value in a constant
     let s: [u32; l] = v.into_iter().collect();
     //~^ ERROR evaluation of constant value failed
 }
index 8783959f45f5f054b3531245f457d54b0f7d549d..0af777fdcf90721e9a69d601ae067f8397d540e8 100644 (file)
@@ -1,10 +1,8 @@
-error[E0434]: can't capture dynamic environment in a fn item
+error[E0435]: attempt to use a non-constant value in a constant
   --> $DIR/type-dependent-def-issue-49241.rs:3:22
    |
-LL |     const l: usize = v.count(); //~ ERROR can't capture dynamic environment in a fn item
-   |                      ^
-   |
-   = help: use the `|| { ... }` closure form instead
+LL |     const l: usize = v.count(); //~ ERROR attempt to use a non-constant value in a constant
+   |                      ^ non-constant value
 
 error[E0080]: evaluation of constant value failed
   --> $DIR/type-dependent-def-issue-49241.rs:4:18
@@ -14,5 +12,5 @@ LL |     let s: [u32; l] = v.into_iter().collect();
 
 error: aborting due to 2 previous errors
 
-Some errors occurred: E0080, E0434.
+Some errors occurred: E0080, E0435.
 For more information about an error, try `rustc --explain E0080`.
index cde96dc778bbedf00f53ae5edb2997d2d99aa5ab..eccb315feb1e2e126701dc1ef48344a60e6f6fc5 100644 (file)
@@ -4,8 +4,8 @@ impl A {
 //~^ NOTE `Self` type implicitly declared here, by this `impl`
     fn banana(&mut self) {
         fn peach(this: &Self) {
-        //~^ ERROR can't use type parameters from outer function
-        //~| NOTE use of type variable from outer function
+        //~^ ERROR can't use generic parameters from outer function
+        //~| NOTE use of generic parameter from outer function
         //~| NOTE use a type here instead
         }
     }
index a613804b8038bcf94618c4dcb455f12bb11452bd..966093499241dfacbcb0664f2cb695bee48f9942 100644 (file)
@@ -1,4 +1,4 @@
-error[E0401]: can't use type parameters from outer function
+error[E0401]: can't use generic parameters from outer function
   --> $DIR/use-self-in-inner-fn.rs:6:25
    |
 LL | impl A {
@@ -7,7 +7,7 @@ LL | impl A {
 LL |         fn peach(this: &Self) {
    |                         ^^^^
    |                         |
-   |                         use of type variable from outer function
+   |                         use of generic parameter from outer function
    |                         use a type here instead
 
 error: aborting due to previous error
index edf4aeab1c70fb1ba0c4fa1e1186c8ae416d28d7..00e1a53473cdad152d47e9783947c2972ca998fc 100644 (file)
@@ -2,6 +2,7 @@
 authors = ["The Rust Project Developers"]
 name = "compiletest"
 version = "0.0.0"
+edition = "2018"
 
 [dependencies]
 diff = "0.1.10"
index f6f8ef1dff4850cfa12d927b9c15e566617eb737..42afb72c91f39f20ab3044e87b8c1a9d80fdd0d2 100644 (file)
@@ -5,7 +5,7 @@
 use std::str::FromStr;
 
 use test::ColorConfig;
-use util::PathBufExt;
+use crate::util::PathBufExt;
 
 #[derive(Clone, Copy, PartialEq, Debug)]
 pub enum Mode {
@@ -66,7 +66,7 @@ fn from_str(s: &str) -> Result<Mode, ()> {
 }
 
 impl fmt::Display for Mode {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         let s = match *self {
             CompileFail => "compile-fail",
             RunFail => "run-fail",
index fd3f002fb6682a0f30298c59287a90a1baf3a240..0329fb0db1422e61479174abaa09f7d211261155 100644 (file)
@@ -33,7 +33,7 @@ fn from_str(s: &str) -> Result<Self, Self::Err> {
 }
 
 impl fmt::Display for ErrorKind {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         match *self {
             ErrorKind::Help => write!(f, "help message"),
             ErrorKind::Error => write!(f, "error"),
index 591d92f0cfa14ca977702f8335661728098b7980..80a015d7aea56850919b160dad1de84777a06aa2 100644 (file)
@@ -4,10 +4,10 @@
 use std::io::BufReader;
 use std::path::{Path, PathBuf};
 
-use common::{self, CompareMode, Config, Mode};
-use util;
+use crate::common::{self, CompareMode, Config, Mode};
+use crate::util;
 
-use extract_gdb_version;
+use crate::extract_gdb_version;
 
 /// Whether to ignore the test.
 #[derive(Clone, Copy, PartialEq, Debug)]
index 106aa67157a42fc21d048587f408309629416563..12aae303f29aaea24d41acc6aecc21881c7dd2d8 100644 (file)
@@ -1,5 +1,5 @@
-use errors::{Error, ErrorKind};
-use runtest::ProcRes;
+use crate::errors::{Error, ErrorKind};
+use crate::runtest::ProcRes;
 use serde_json;
 use std::path::Path;
 use std::str::FromStr;
index 15d53f1e3755cc3ea7391b626ff3bd2d84442ed6..1f9b4b2ad4363263ed2372d2ff3d1265140bec63 100644 (file)
@@ -1,29 +1,21 @@
 #![crate_name = "compiletest"]
 #![feature(test)]
-#![deny(warnings)]
+#![deny(warnings, rust_2018_idioms)]
 
-extern crate diff;
-extern crate env_logger;
-extern crate filetime;
-extern crate getopts;
 #[cfg(unix)]
 extern crate libc;
 #[macro_use]
 extern crate log;
-extern crate regex;
 #[macro_use]
 extern crate lazy_static;
 #[macro_use]
 extern crate serde_derive;
-extern crate serde_json;
 extern crate test;
-extern crate rustfix;
-extern crate walkdir;
 
-use common::CompareMode;
-use common::{expected_output_path, output_base_dir, output_relative_path, UI_EXTENSIONS};
-use common::{Config, TestPaths};
-use common::{DebugInfoBoth, DebugInfoGdb, DebugInfoLldb, Mode, Pretty};
+use crate::common::CompareMode;
+use crate::common::{expected_output_path, output_base_dir, output_relative_path, UI_EXTENSIONS};
+use crate::common::{Config, TestPaths};
+use crate::common::{DebugInfoBoth, DebugInfoGdb, DebugInfoLldb, Mode, Pretty};
 use filetime::FileTime;
 use getopts::Options;
 use std::env;
 use std::path::{Path, PathBuf};
 use std::process::Command;
 use test::ColorConfig;
-use util::logv;
+use crate::util::logv;
 use walkdir::WalkDir;
+use env_logger;
+use getopts;
 
 use self::header::{EarlyProps, Ignore};
 
index 5a4caddcdd31969927d6a43ab8aaf47021424e5c..6dfd8e97c636d6f28255af4ea19ef6e78150df09 100644 (file)
@@ -100,18 +100,15 @@ pub fn read2(
 
 #[cfg(windows)]
 mod imp {
-    extern crate miow;
-    extern crate winapi;
-
     use std::io;
     use std::os::windows::prelude::*;
     use std::process::{ChildStderr, ChildStdout};
     use std::slice;
 
-    use self::miow::iocp::{CompletionPort, CompletionStatus};
-    use self::miow::pipe::NamedPipe;
-    use self::miow::Overlapped;
-    use self::winapi::shared::winerror::ERROR_BROKEN_PIPE;
+    use miow::iocp::{CompletionPort, CompletionStatus};
+    use miow::pipe::NamedPipe;
+    use miow::Overlapped;
+    use winapi::shared::winerror::ERROR_BROKEN_PIPE;
 
     struct Pipe<'a> {
         dst: &'a mut Vec<u8>,
index ff201b03a0bdc83e7f0642a3cfd7439283cd356a..31529810a04dbc377e6b1e4364836f90e9cd5cd9 100644 (file)
@@ -1,18 +1,18 @@
-use common::CompareMode;
-use common::{expected_output_path, UI_EXTENSIONS, UI_FIXED, UI_STDERR, UI_STDOUT};
-use common::{output_base_dir, output_base_name, output_testname_unique};
-use common::{Codegen, CodegenUnits, DebugInfoBoth, DebugInfoGdb, DebugInfoLldb, Rustdoc};
-use common::{CompileFail, Pretty, RunFail, RunPass, RunPassValgrind};
-use common::{Config, TestPaths};
-use common::{Incremental, MirOpt, RunMake, Ui};
+use crate::common::CompareMode;
+use crate::common::{expected_output_path, UI_EXTENSIONS, UI_FIXED, UI_STDERR, UI_STDOUT};
+use crate::common::{output_base_dir, output_base_name, output_testname_unique};
+use crate::common::{Codegen, CodegenUnits, DebugInfoBoth, DebugInfoGdb, DebugInfoLldb, Rustdoc};
+use crate::common::{CompileFail, Pretty, RunFail, RunPass, RunPassValgrind};
+use crate::common::{Config, TestPaths};
+use crate::common::{Incremental, MirOpt, RunMake, Ui};
 use diff;
-use errors::{self, Error, ErrorKind};
+use crate::errors::{self, Error, ErrorKind};
 use filetime::FileTime;
-use header::TestProps;
-use json;
+use crate::header::TestProps;
+use crate::json;
 use regex::Regex;
 use rustfix::{apply_suggestions, get_suggestions_from_json, Filter};
-use util::{logv, PathBufExt};
+use crate::util::{logv, PathBufExt};
 
 use std::collections::hash_map::DefaultHasher;
 use std::collections::{HashMap, HashSet, VecDeque};
@@ -27,8 +27,8 @@
 use std::process::{Child, Command, ExitStatus, Output, Stdio};
 use std::str;
 
-use extract_gdb_version;
-use is_android_gdb_target;
+use crate::extract_gdb_version;
+use crate::is_android_gdb_target;
 
 #[cfg(windows)]
 fn disable_error_reporting<F: FnOnce() -> R, R>(f: F) -> R {
@@ -1937,7 +1937,7 @@ fn split_maybe_args(&self, argstr: &Option<String>) -> Vec<String> {
     }
 
     fn make_cmdline(&self, command: &Command, libpath: &str) -> String {
-        use util;
+        use crate::util;
 
         // Linux and mac don't require adjusting the library search path
         if cfg!(unix) {
@@ -3255,7 +3255,7 @@ fn prune_duplicate_outputs(&self, modes: &[CompareMode]) {
     }
 
     fn create_stamp(&self) {
-        let stamp = ::stamp(&self.config, self.testpaths, self.revision);
+        let stamp = crate::stamp(&self.config, self.testpaths, self.revision);
         fs::write(&stamp, compute_stamp_hash(&self.config)).unwrap();
     }
 }
@@ -3311,7 +3311,7 @@ impl<T> fmt::Debug for ExpectedLine<T>
 where
     T: AsRef<str> + fmt::Debug,
 {
-    fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
         if let &ExpectedLine::Text(ref t) = self {
             write!(formatter, "{:?}", t)
         } else {
@@ -3334,7 +3334,7 @@ fn nocomment_mir_line(line: &str) -> &str {
 }
 
 fn read2_abbreviated(mut child: Child) -> io::Result<Output> {
-    use read2::read2;
+    use crate::read2::read2;
     use std::mem::replace;
 
     const HEAD_LEN: usize = 160 * 1024;
index 90dfadeee46124215b4cd38a295015fa9a82eb7a..85be2fed07567111e20d1e0ccb0db66a1d0262b5 100644 (file)
@@ -1,7 +1,7 @@
 use std::ffi::OsStr;
 use std::env;
 use std::path::PathBuf;
-use common::Config;
+use crate::common::Config;
 
 /// Conversion table from triple OS name to Rust SYSNAME
 const OS_TABLE: &'static [(&'static str, &'static str)] = &[
index 7f8783c9d89bea3af6ac58f65122d855ed2851b6..116be234f3ceb882d1a02f92626b61bdee58ee51 100644 (file)
@@ -2,6 +2,7 @@
 authors = ["The Rust Project Developers"]
 name = "error_index_generator"
 version = "0.0.0"
+edition = "2018"
 
 [dependencies]
 rustdoc = { path = "../../librustdoc" }
index 72cfd7d5e58e9851f52fbe3699a86ab4ead49fe1..ef045495a08647be8987e8f6d799cdb0f619a201 100644 (file)
@@ -1,8 +1,9 @@
 #![feature(rustc_private)]
 
+#![deny(rust_2018_idioms)]
+
 extern crate env_logger;
 extern crate syntax;
-extern crate rustdoc;
 extern crate serialize as rustc_serialize;
 
 use std::collections::BTreeMap;
index d38815004418cceb7fd62bd824c25981289003f9..36aa5916da733f14bc04d3131aa872c9c2c032d2 100644 (file)
@@ -2,6 +2,7 @@
 name = "rustdoc-tool"
 version = "0.0.0"
 authors = ["The Rust Project Developers"]
+edition = "2018"
 
 # Cargo adds a number of paths to the dylib search path on windows, which results in
 # the wrong rustdoc being executed. To avoid the conflicting rustdocs, we name the "tool"
index df9d2c6ba96db85ea10dab35f9a85ee161057ec6..8bdc365c4ca686cc96f1c739c46c0eebd513985a 100644 (file)
@@ -1,3 +1,5 @@
+#![deny(rust_2018_idioms)]
+
 #![feature(link_args)]
 
 #[allow(unused_attributes)]
@@ -10,6 +12,4 @@
 // See src/rustc/rustc.rs for the corresponding rustc settings.
 extern {}
 
-extern crate rustdoc;
-
 fn main() { rustdoc::main() }