From 46aae255371513a2e9a15813154b984563893656 Mon Sep 17 00:00:00 2001 From: Rust timing bot Date: Tue, 9 Feb 2021 18:17:19 +0100 Subject: [PATCH 1/2] Revert to d60b29d1ae8147538b8d542f7ffcc03b48e2cbda --- .editorconfig | 21 - Cargo.lock | 33 +- compiler/rustc_ast/src/ast.rs | 99 +- compiler/rustc_ast/src/lib.rs | 2 +- compiler/rustc_ast/src/mut_visit.rs | 20 +- compiler/rustc_ast/src/visit.rs | 18 +- compiler/rustc_ast_lowering/src/item.rs | 44 +- compiler/rustc_ast_lowering/src/lib.rs | 48 +- compiler/rustc_ast_lowering/src/path.rs | 7 +- .../rustc_ast_passes/src/ast_validation.rs | 30 +- compiler/rustc_ast_passes/src/feature_gate.rs | 22 +- compiler/rustc_ast_passes/src/lib.rs | 2 - compiler/rustc_ast_passes/src/node_count.rs | 2 +- compiler/rustc_ast_pretty/src/lib.rs | 1 - compiler/rustc_ast_pretty/src/pprust/state.rs | 27 +- compiler/rustc_attr/src/builtin.rs | 2 +- compiler/rustc_builtin_macros/Cargo.toml | 1 - compiler/rustc_builtin_macros/src/assert.rs | 4 +- compiler/rustc_builtin_macros/src/derive.rs | 132 - .../src/deriving/cmp/partial_ord.rs | 197 +- .../src/deriving/debug.rs | 38 +- .../src/deriving/generic/mod.rs | 12 +- .../rustc_builtin_macros/src/deriving/mod.rs | 6 +- .../src/global_allocator.rs | 5 +- compiler/rustc_builtin_macros/src/lib.rs | 4 - compiler/rustc_builtin_macros/src/test.rs | 4 +- .../rustc_builtin_macros/src/test_harness.rs | 3 +- .../rustc_codegen_cranelift/src/abi/mod.rs | 1 - compiler/rustc_codegen_llvm/src/abi.rs | 14 +- compiler/rustc_codegen_llvm/src/consts.rs | 80 +- compiler/rustc_codegen_llvm/src/context.rs | 124 +- compiler/rustc_codegen_llvm/src/declare.rs | 24 +- compiler/rustc_codegen_llvm/src/intrinsic.rs | 143 +- compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 1 - compiler/rustc_codegen_llvm/src/llvm/mod.rs | 4 - compiler/rustc_codegen_llvm/src/va_arg.rs | 12 +- compiler/rustc_codegen_ssa/Cargo.toml | 1 - compiler/rustc_codegen_ssa/src/base.rs | 26 +- compiler/rustc_data_structures/src/lib.rs | 1 - .../rustc_data_structures/src/profiling.rs | 25 +- compiler/rustc_error_codes/src/error_codes.rs | 5 +- .../src/error_codes/E0074.md | 4 +- .../src/error_codes/E0076.md | 4 +- .../src/error_codes/E0077.md | 2 +- .../src/error_codes/E0463.md | 21 - .../src/error_codes/E0521.md | 28 - .../src/error_codes/E0542.md | 47 - .../src/error_codes/E0546.md | 11 +- .../src/error_codes/E0781.md | 12 - compiler/rustc_errors/src/diagnostic.rs | 24 - .../rustc_errors/src/diagnostic_builder.rs | 2 +- compiler/rustc_errors/src/emitter.rs | 2 +- compiler/rustc_errors/src/json.rs | 67 +- compiler/rustc_errors/src/lib.rs | 43 +- compiler/rustc_errors/src/snippet.rs | 15 +- compiler/rustc_errors/src/styled_buffer.rs | 2 +- compiler/rustc_expand/src/base.rs | 47 +- compiler/rustc_expand/src/expand.rs | 343 +- compiler/rustc_expand/src/proc_macro.rs | 94 +- compiler/rustc_feature/src/active.rs | 10 - compiler/rustc_feature/src/builtin_attrs.rs | 1 + compiler/rustc_hir/src/hir.rs | 60 +- compiler/rustc_hir/src/intravisit.rs | 1 - compiler/rustc_hir/src/lib.rs | 1 + compiler/rustc_hir_pretty/src/lib.rs | 1 - compiler/rustc_index/src/bit_set.rs | 12 - compiler/rustc_index/src/bit_set/tests.rs | 34 - compiler/rustc_index/src/lib.rs | 4 - .../src/infer/canonical/canonicalizer.rs | 12 +- .../src/infer/error_reporting/mod.rs | 2 +- .../trait_impl_difference.rs | 7 +- .../infer/lexical_region_resolve/README.md | 1 + compiler/rustc_infer/src/traits/util.rs | 41 +- compiler/rustc_interface/src/lib.rs | 1 - compiler/rustc_interface/src/util.rs | 4 +- compiler/rustc_lint/Cargo.toml | 1 - compiler/rustc_lint/src/builtin.rs | 60 +- compiler/rustc_lint/src/context.rs | 49 +- compiler/rustc_lint/src/early.rs | 16 - compiler/rustc_lint/src/internal.rs | 4 +- compiler/rustc_lint/src/levels.rs | 101 +- compiler/rustc_lint/src/lib.rs | 7 +- compiler/rustc_lint/src/non_fmt_panic.rs | 197 - compiler/rustc_lint/src/panic_fmt.rs | 155 + compiler/rustc_lint_defs/src/builtin.rs | 135 - compiler/rustc_lint_defs/src/lib.rs | 10 - .../rustc_llvm/llvm-wrapper/RustWrapper.cpp | 8 - compiler/rustc_macros/src/query.rs | 129 +- compiler/rustc_metadata/src/creader.rs | 27 +- compiler/rustc_metadata/src/rmeta/encoder.rs | 323 +- compiler/rustc_middle/Cargo.toml | 2 +- compiler/rustc_middle/src/hir/map/mod.rs | 6 +- compiler/rustc_middle/src/lint.rs | 12 +- .../rustc_middle/src/mir/interpret/value.rs | 2 +- compiler/rustc_middle/src/mir/mod.rs | 6 +- compiler/rustc_middle/src/query/mod.rs | 2783 +-- compiler/rustc_middle/src/traits/chalk.rs | 40 +- compiler/rustc_middle/src/ty/context.rs | 38 +- compiler/rustc_middle/src/ty/diagnostics.rs | 18 +- compiler/rustc_middle/src/ty/error.rs | 11 +- compiler/rustc_middle/src/ty/layout.rs | 20 - compiler/rustc_middle/src/ty/print/pretty.rs | 1 - compiler/rustc_middle/src/ty/query/keys.rs | 24 +- compiler/rustc_middle/src/ty/query/mod.rs | 1 + .../rustc_middle/src/ty/query/plumbing.rs | 4 +- compiler/rustc_middle/src/ty/sty.rs | 20 +- compiler/rustc_middle/src/util/bug.rs | 4 +- .../diagnostics/mutability_errors.rs | 4 +- compiler/rustc_mir/src/const_eval/error.rs | 7 - compiler/rustc_mir/src/const_eval/machine.rs | 2 +- compiler/rustc_mir/src/transform/inline.rs | 5 - compiler/rustc_mir_build/src/build/block.rs | 10 +- .../src/build/expr/as_place.rs | 86 +- .../src/build/expr/as_rvalue.rs | 76 +- .../rustc_mir_build/src/build/expr/as_temp.rs | 6 +- .../rustc_mir_build/src/build/expr/into.rs | 110 +- .../rustc_mir_build/src/build/expr/stmt.rs | 2 + compiler/rustc_mir_build/src/build/into.rs | 11 +- .../rustc_mir_build/src/build/matches/mod.rs | 92 +- .../rustc_mir_build/src/build/matches/util.rs | 4 +- compiler/rustc_mir_build/src/build/mod.rs | 27 +- compiler/rustc_mir_build/src/build/scope.rs | 227 +- .../src/thir/pattern/check_match.rs | 14 +- .../src/thir/pattern/deconstruct_pat.rs | 2 + .../src/thir/pattern/usefulness.rs | 573 +- compiler/rustc_parse/src/lexer/mod.rs | 30 +- .../src/lexer/unescape_error_reporting.rs | 186 +- compiler/rustc_parse/src/lib.rs | 2 - compiler/rustc_parse/src/parser/attr.rs | 6 +- .../rustc_parse/src/parser/diagnostics.rs | 4 +- compiler/rustc_parse/src/parser/item.rs | 34 +- .../rustc_parse/src/parser/nonterminal.rs | 17 +- compiler/rustc_parse_format/src/lib.rs | 2 +- compiler/rustc_passes/src/stability.rs | 3 +- compiler/rustc_privacy/src/lib.rs | 2 +- .../rustc_query_system/src/query/config.rs | 3 +- .../rustc_resolve/src/build_reduced_graph.rs | 8 +- compiler/rustc_resolve/src/diagnostics.rs | 11 +- compiler/rustc_resolve/src/late.rs | 38 +- .../rustc_resolve/src/late/diagnostics.rs | 34 +- compiler/rustc_resolve/src/late/lifetimes.rs | 13 +- compiler/rustc_resolve/src/lib.rs | 51 +- compiler/rustc_resolve/src/macros.rs | 186 +- compiler/rustc_serialize/src/lib.rs | 1 - compiler/rustc_serialize/tests/leb128.rs | 1 - compiler/rustc_session/src/config.rs | 116 - compiler/rustc_session/src/filesearch.rs | 52 +- compiler/rustc_session/src/options.rs | 1 - compiler/rustc_span/src/lib.rs | 1 - compiler/rustc_span/src/source_map.rs | 20 +- compiler/rustc_span/src/symbol.rs | 5 - compiler/rustc_target/src/abi/call/aarch64.rs | 24 +- compiler/rustc_target/src/abi/call/arm.rs | 9 +- compiler/rustc_target/src/abi/call/mod.rs | 3 +- .../src/spec/aarch64_be_unknown_linux_gnu.rs | 20 - .../aarch64_be_unknown_linux_gnu_ilp32.rs | 20 - .../spec/aarch64_unknown_linux_gnu_ilp32.rs | 18 - compiler/rustc_target/src/spec/abi.rs | 2 - compiler/rustc_target/src/spec/mod.rs | 4 - .../src/traits/const_evaluatable.rs | 61 +- .../src/traits/error_reporting/mod.rs | 11 +- .../src/traits/error_reporting/suggestions.rs | 8 +- .../rustc_trait_selection/src/traits/mod.rs | 3 +- .../src/traits/object_safety.rs | 8 +- .../src/traits/select/confirmation.rs | 62 +- compiler/rustc_traits/Cargo.toml | 7 +- compiler/rustc_traits/src/chalk/db.rs | 88 +- compiler/rustc_traits/src/chalk/lowering.rs | 8 +- compiler/rustc_traits/src/chalk/mod.rs | 38 +- compiler/rustc_typeck/src/astconv/generics.rs | 15 +- compiler/rustc_typeck/src/astconv/mod.rs | 234 +- compiler/rustc_typeck/src/check/check.rs | 45 +- compiler/rustc_typeck/src/check/expr.rs | 35 +- .../rustc_typeck/src/check/fn_ctxt/_impl.rs | 11 +- .../rustc_typeck/src/check/fn_ctxt/mod.rs | 8 +- compiler/rustc_typeck/src/check/mod.rs | 2 +- compiler/rustc_typeck/src/check/upvar.rs | 242 +- compiler/rustc_typeck/src/check/writeback.rs | 6 +- compiler/rustc_typeck/src/collect.rs | 185 +- .../rustc_typeck/src/collect/item_bounds.rs | 4 +- library/alloc/src/boxed.rs | 14 +- library/alloc/src/collections/btree/map.rs | 145 +- .../alloc/src/collections/btree/map/tests.rs | 43 +- library/alloc/src/collections/btree/mod.rs | 16 + .../alloc/src/collections/btree/navigate.rs | 11 +- library/alloc/src/collections/btree/remove.rs | 5 +- library/alloc/src/collections/btree/set.rs | 99 +- .../alloc/src/collections/btree/set/tests.rs | 21 - library/alloc/src/collections/btree/split.rs | 85 +- library/alloc/src/lib.rs | 3 - library/alloc/src/task.rs | 66 +- library/alloc/src/vec/mod.rs | 113 +- library/alloc/tests/lib.rs | 2 - library/alloc/tests/vec.rs | 70 - library/core/src/alloc/layout.rs | 4 +- library/core/src/alloc/mod.rs | 9 +- library/core/src/cell.rs | 44 +- library/core/src/default.rs | 6 +- library/core/src/intrinsics.rs | 4 +- library/core/src/iter/adapters/fuse.rs | 15 +- library/core/src/iter/adapters/map.rs | 1 - library/core/src/iter/adapters/peekable.rs | 7 +- library/core/src/iter/traits/exact_size.rs | 6 - library/core/src/iter/traits/iterator.rs | 36 +- library/core/src/lib.rs | 3 + library/core/src/macros/mod.rs | 10 +- library/core/src/macros/panic.md | 15 +- library/core/src/mem/maybe_uninit.rs | 39 +- library/core/src/mem/mod.rs | 1 - library/core/src/num/int_macros.rs | 31 +- library/core/src/num/uint_macros.rs | 31 +- library/core/src/ops/control_flow.rs | 86 +- library/core/src/prelude/v1.rs | 5 - library/core/tests/lib.rs | 3 +- library/core/tests/ops.rs | 2 - library/core/tests/ops/control_flow.rs | 18 - library/panic_unwind/src/lib.rs | 1 - library/std/src/backtrace.rs | 21 +- library/std/src/backtrace/tests.rs | 109 +- library/std/src/collections/hash/map.rs | 1 - library/std/src/collections/hash/set.rs | 1 - library/std/src/ffi/os_str.rs | 2 +- library/std/src/fs.rs | 3 - library/std/src/lazy/tests.rs | 5 - library/std/src/lib.rs | 3 +- library/std/src/net/ip.rs | 69 - library/std/src/os/linux/raw.rs | 16 +- library/std/src/prelude/v1.rs | 5 - library/std/src/sync/once.rs | 20 +- library/std/src/sync/once/tests.rs | 4 +- library/std/src/sys/wasi/ext/fs.rs | 8 - library/std/src/sys/wasm/thread.rs | 2 +- library/std/src/sys/windows/mutex.rs | 2 + library/term/src/terminfo/parm/tests.rs | 12 +- library/test/src/cli.rs | 17 +- library/test/src/lib.rs | 4 +- library/test/src/tests.rs | 39 +- library/unwind/src/libunwind.rs | 5 +- rustfmt.toml | 2 +- src/bootstrap/bin/main.rs | 2 +- src/bootstrap/builder/tests.rs | 6 +- src/bootstrap/doc.rs | 11 +- src/bootstrap/test.rs | 71 +- src/bootstrap/tool.rs | 20 +- .../host-x86_64/test-various/Dockerfile | 4 +- src/ci/docker/host-x86_64/wasm32/Dockerfile | 14 +- src/ci/scripts/install-awscli.sh | 2 +- src/ci/scripts/install-msys2.sh | 4 +- src/doc/rustc/src/exploit-mitigations.md | 2 +- src/doc/rustc/src/lints/levels.md | 4 +- src/doc/rustc/src/lints/listing/index.md | 2 +- src/doc/rustc/src/platform-support.md | 3 - src/doc/rustc/src/what-is-rustc.md | 4 +- src/doc/rustdoc/src/advanced-features.md | 5 +- src/doc/rustdoc/src/documentation-tests.md | 20 +- .../rustdoc/src/how-to-write-documentation.md | 54 +- src/doc/rustdoc/src/lints.md | 3 +- src/doc/rustdoc/src/passes.md | 8 +- src/doc/rustdoc/src/references.md | 6 +- src/doc/rustdoc/src/the-doc-attribute.md | 38 +- src/doc/rustdoc/src/what-is-rustdoc.md | 12 +- src/doc/rustdoc/src/what-to-include.md | 24 +- .../src/compiler-flags/codegen-backend.md | 2 +- .../src/compiler-flags/control-flow-guard.md | 4 +- .../src/compiler-flags/extern-location.md | 31 - .../src/compiler-flags/profile.md | 4 +- .../src/compiler-flags/report-time.md | 2 +- .../src/compiler-flags/tls-model.md | 2 +- .../abi-c-cmse-nonsecure-call.md | 88 - .../src/language-features/auto-traits.md | 13 +- .../custom-test-frameworks.md | 1 + .../infer-static-outlives-requirements.md | 1 + .../src/language-features/intrinsics.md | 1 + .../src/language-features/lang-items.md | 12 +- .../src/language-features/non-ascii-idents.md | 8 +- .../src/language-features/or-patterns.md | 2 +- .../src/language-features/plugin.md | 4 +- .../src/language-features/rustc-attrs.md | 2 +- .../src/language-features/unboxed-closures.md | 2 +- .../src/language-features/unsized-locals.md | 4 +- .../unsized-tuple-coercion.md | 2 +- .../unstable-book/src/library-features/asm.md | 2 +- .../src/library-features/concat-idents.md | 2 +- .../src/library-features/global-asm.md | 14 +- .../src/library-features/llvm-asm.md | 2 +- .../src/library-features/test.md | 4 +- .../src/library-features/try-trait.md | 2 +- src/etc/lldb_providers.py | 4 +- src/librustdoc/clean/inline.rs | 3 + src/librustdoc/clean/mod.rs | 31 +- src/librustdoc/clean/types.rs | 43 +- src/librustdoc/clean/utils.rs | 126 +- src/librustdoc/core.rs | 2 +- src/librustdoc/doctest.rs | 7 +- src/librustdoc/formats/cache.rs | 105 +- src/librustdoc/formats/renderer.rs | 1 - src/librustdoc/html/format.rs | 67 +- src/librustdoc/html/markdown.rs | 5 +- src/librustdoc/html/mod.rs | 1 - src/librustdoc/html/render/cache.rs | 163 +- src/librustdoc/html/render/mod.rs | 15 +- src/librustdoc/html/static/main.js | 2 +- src/librustdoc/html/static/rustdoc.css | 9 - src/librustdoc/html/static/themes/dark.css | 1 + src/librustdoc/json/conversions.rs | 30 +- src/librustdoc/json/mod.rs | 2 +- src/librustdoc/lib.rs | 4 +- .../passes/collect_intra_doc_links.rs | 4 +- src/librustdoc/passes/doc_test_lints.rs | 4 +- src/librustdoc/passes/non_autolinks.rs | 2 +- src/librustdoc/passes/strip_hidden.rs | 2 +- src/llvm-project | 2 +- src/rustdoc-json-types/lib.rs | 41 +- src/stage0.txt | 2 +- src/test/codegen/asm-sanitize-llvm.rs | 32 - .../incremental/cyclic-trait-hierarchy.rs | 10 +- ...ignment.main.SimplifyCfg-initial.after.mir | 28 +- .../box_expr.main.ElaborateDrops.before.mir | 28 +- ...h.before-SimplifyBranches-final.after.diff | 2 +- ...ch_68867.try_sum.EarlyOtherwiseBranch.diff | 2 +- ...float_to_exponential_common.ConstProp.diff | 2 +- .../mir-opt/inline/inline-instruction-set.rs | 54 - .../inline/inline_diverging.h.Inline.diff | 11 +- ...inline_instruction_set.default.Inline.diff | 45 - .../inline_instruction_set.t32.Inline.diff | 47 - .../issue_41110.main.ElaborateDrops.after.mir | 27 +- .../issue_41110.test.ElaborateDrops.after.mir | 48 +- .../issue_41888.main.ElaborateDrops.after.mir | 74 +- ...issue_62289.test.ElaborateDrops.before.mir | 40 +- .../issue_73223.main.PreCodegen.32bit.diff | 4 +- .../issue_73223.main.PreCodegen.64bit.diff | 4 +- ..._73223.main.SimplifyArmIdentity.32bit.diff | 4 +- ..._73223.main.SimplifyArmIdentity.64bit.diff | 4 +- ..._after_call.main.ElaborateDrops.before.mir | 10 +- ...ify_arm.id_result.SimplifyArmIdentity.diff | 2 +- ...lify_arm.id_result.SimplifyBranchSame.diff | 2 +- ...mplify_arm.id_try.SimplifyArmIdentity.diff | 6 +- ...implify_arm.id_try.SimplifyBranchSame.diff | 6 +- ...y.try_identity.DestinationPropagation.diff | 6 +- ..._try.try_identity.SimplifyArmIdentity.diff | 6 +- ....try_identity.SimplifyBranchSame.after.mir | 6 +- ..._try.try_identity.SimplifyLocals.after.mir | 6 +- ...ove_out.move_out_by_subslice.mir_map.0.mir | 38 +- ...y_move_out.move_out_from_end.mir_map.0.mir | 38 +- src/test/pretty/macro_rules.rs | 19 - .../coverage-llvmir/Makefile | 6 +- .../coverage-reports/Makefile | 7 +- .../expected_show_coverage.uses_crate.txt | 4 +- .../coverage-spanview/Makefile | 8 +- ...ht_abort.-------.InstrumentCoverage.0.html | 28 +- ...l_assert.-------.InstrumentCoverage.0.html | 6 +- ...osure#0}.-------.InstrumentCoverage.0.html | 6 +- ...osure#1}.-------.InstrumentCoverage.0.html | 6 +- ...osure#2}.-------.InstrumentCoverage.0.html | 6 +- ...block_on.-------.InstrumentCoverage.0.html | 136 +- ...ync.main.-------.InstrumentCoverage.0.html | 108 +- ...osure#0}.-------.InstrumentCoverage.0.html | 4 +- ...sure#10}.-------.InstrumentCoverage.0.html | 4 +- ...sure#11}.-------.InstrumentCoverage.0.html | 4 +- ...osure#1}.-------.InstrumentCoverage.0.html | 4 +- ...osure#2}.-------.InstrumentCoverage.0.html | 12 +- ...osure#3}.-------.InstrumentCoverage.0.html | 4 +- ...osure#5}.-------.InstrumentCoverage.0.html | 12 +- ...osure#6}.-------.InstrumentCoverage.0.html | 4 +- ...osure#7}.-------.InstrumentCoverage.0.html | 12 +- ...osure#8}.-------.InstrumentCoverage.0.html | 4 +- ...osure#9}.-------.InstrumentCoverage.0.html | 4 +- ...ure.main.-------.InstrumentCoverage.0.html | 20224 ++++++++-------- ...ons.main.-------.InstrumentCoverage.0.html | 16 +- ...ode.main.-------.InstrumentCoverage.0.html | 32 +- ...nused_fn.-------.InstrumentCoverage.0.html | 32 +- ..._library.-------.InstrumentCoverage.0.html | 32 +- ...est.main.-------.InstrumentCoverage.0.html | 20 +- ...doctests.-------.InstrumentCoverage.0.html | 40 +- ...ait.main.-------.InstrumentCoverage.0.html | 8 +- ...#0}-drop.-------.InstrumentCoverage.0.html | 24 +- ...ics.main.-------.InstrumentCoverage.0.html | 8 +- ...#1}-drop.-------.InstrumentCoverage.0.html | 24 +- .../if.main.-------.InstrumentCoverage.0.html | 76 +- ...lse.main.-------.InstrumentCoverage.0.html | 36 +- ...ait_func.-------.InstrumentCoverage.0.html | 16 +- ...-in_func.-------.InstrumentCoverage.0.html | 40 +- ...ait_func.-------.InstrumentCoverage.0.html | 8 +- ...ems.main.-------.InstrumentCoverage.0.html | 46 +- ...ean.main.-------.InstrumentCoverage.0.html | 32 +- ...hes.main.-------.InstrumentCoverage.0.html | 32 +- ...l#0}-fmt.-------.InstrumentCoverage.0.html | 10 +- ...ern.main.-------.InstrumentCoverage.0.html | 36 +- ...ops.main.-------.InstrumentCoverage.0.html | 14 +- ...low.main.-------.InstrumentCoverage.0.html | 48 +- ...overflow.-------.InstrumentCoverage.0.html | 84 +- ...ht_panic.-------.InstrumentCoverage.0.html | 28 +- ..._eq.main.-------.InstrumentCoverage.0.html | 96 +- ...osure#0}.-------.InstrumentCoverage.0.html | 82 + ...osure#0}.-------.InstrumentCoverage.0.html | 83 + ...pl#2}-ge.-------.InstrumentCoverage.0.html | 92 + ...osure#0}.-------.InstrumentCoverage.0.html | 82 + ...osure#0}.-------.InstrumentCoverage.0.html | 83 + ...pl#2}-gt.-------.InstrumentCoverage.0.html | 92 + ...osure#0}.-------.InstrumentCoverage.0.html | 82 + ...osure#0}.-------.InstrumentCoverage.0.html | 83 + ...pl#2}-le.-------.InstrumentCoverage.0.html | 92 + ...osure#0}.-------.InstrumentCoverage.0.html | 82 + ...osure#0}.-------.InstrumentCoverage.0.html | 83 + ...pl#2}-lt.-------.InstrumentCoverage.0.html | 92 + ...l#7}-fmt.-------.InstrumentCoverage.0.html | 58 +- ...8}-clone.-------.InstrumentCoverage.0.html | 6 +- ...oop.main.-------.InstrumentCoverage.0.html | 40 +- ...tch.main.-------.InstrumentCoverage.0.html | 34 +- ...ult.main.-------.InstrumentCoverage.0.html | 8 +- ...function.-------.InstrumentCoverage.0.html | 16 +- ...function.-------.InstrumentCoverage.0.html | 24 +- ...function.-------.InstrumentCoverage.0.html | 16 +- ...ib_crate.-------.InstrumentCoverage.0.html | 162 +- ...function.-------.InstrumentCoverage.0.html | 24 +- ...function.-------.InstrumentCoverage.0.html | 12 +- ...function.-------.InstrumentCoverage.0.html | 24 +- ...function.-------.InstrumentCoverage.0.html | 24 +- ...function.-------.InstrumentCoverage.0.html | 24 +- ...ate.main.-------.InstrumentCoverage.0.html | 176 +- ...eld.main.-------.InstrumentCoverage.0.html | 38 +- .../coverage/coverage_tools.mk | 7 + src/test/run-make-fulldeps/simd-ffi/simd.rs | 5 - .../treat-err-as-bug/Makefile | 7 + .../treat-err-as-bug/delay_span_bug.rs | 4 + .../run-make-fulldeps/treat-err-as-bug/err.rs | 3 + src/test/rustdoc-json/method_abi.rs | 25 - src/test/rustdoc-json/traits/has_body.rs | 21 - src/test/rustdoc-json/unions/union.rs | 7 - src/test/rustdoc-ui/issue-81662-shortness.rs | 12 - .../rustdoc-ui/issue-81662-shortness.stdout | 16 - src/test/rustdoc/task-lists.rs | 13 - src/test/rustdoc/trait-self-link.rs | 2 +- src/test/ui-fulldeps/issue-15149.rs | 6 +- src/test/ui/allocator/object-safe.rs | 13 - .../ui/array-slice-vec/array_const_index-0.rs | 1 - .../array_const_index-0.stderr | 2 - .../ui/array-slice-vec/array_const_index-1.rs | 1 - .../array_const_index-1.stderr | 2 - .../defaults-not-assumed-fail.rs | 2 - .../defaults-not-assumed-fail.stderr | 8 +- .../ambiguous-associated-type2.rs | 12 - .../ambiguous-associated-type2.stderr | 16 - .../associated-item-through-where-clause.rs | 21 - ...e-predicates-that-can-define-assoc-type.rs | 10 - .../missing-trait-bound-for-assoc-fails.rs | 10 - ...missing-trait-bound-for-assoc-fails.stderr | 16 - .../super-trait-referencing-self.rs | 12 - .../super-trait-referencing.rs | 19 - .../super-trait-where-referencing-self.rs | 27 - .../traits-assoc-anonymized.rs | 33 - .../traits-assoc-type-macros.rs | 43 - src/test/ui/associated-types/issue-24159.rs | 37 - src/test/ui/associated-types/issue-37808.rs | 19 - src/test/ui/associated-types/issue-37883.rs | 25 - src/test/ui/associated-types/issue-38917.rs | 25 - src/test/ui/associated-types/issue-39532.rs | 14 - src/test/ui/associated-types/issue-40093.rs | 14 - src/test/ui/associated-types/issue-43475.rs | 10 - src/test/ui/associated-types/issue-63591.rs | 24 - ...block-control-flow-static-semantics.stderr | 8 +- src/test/ui/async-await/issue-73137.rs | 1 + .../async-await/issues/issue-62097.nll.stderr | 3 +- .../ui/async-await/issues/issue-67893.stderr | 6 +- src/test/ui/attributes/key-value-non-ascii.rs | 2 +- .../ui/attributes/key-value-non-ascii.stderr | 5 +- src/test/ui/borrowck/issue-45983.stderr | 1 - src/test/ui/borrowck/issue-7573.stderr | 1 - .../borrowck/regions-escape-bound-fn-2.stderr | 1 - .../borrowck/regions-escape-bound-fn.stderr | 1 - .../regions-escape-unboxed-closure.stderr | 1 - src/test/ui/cast/unsupported-cast.rs | 5 - .../migrations/insignificant_drop.rs | 130 - .../migrations/insignificant_drop.stderr | 105 - .../migrations/no_migrations.rs | 84 - .../migrations/significant_drop.rs | 137 - .../migrations/significant_drop.stderr | 103 - .../expect-region-supply-region.stderr | 1 - .../ui/closures/issue-81700-mut-borrow.rs | 5 - .../ui/closures/issue-81700-mut-borrow.stderr | 13 - .../cmse-nonsecure-entry/gate_test.rs | 0 .../cmse-nonsecure-entry/gate_test.stderr | 0 .../params-on-registers.rs | 0 .../cmse-nonsecure-entry/params-on-stack.rs | 0 .../params-on-stack.stderr | 0 .../cmse-nonsecure-entry/trustzone-only.rs | 0 .../trustzone-only.stderr | 0 .../cmse-nonsecure-entry/wrong-abi.rs | 0 .../cmse-nonsecure-entry/wrong-abi.stderr | 0 .../cmse-nonsecure-call/gate_test.rs | 11 - .../cmse-nonsecure-call/gate_test.stderr | 12 - .../params-on-registers.rs | 15 - .../cmse-nonsecure-call/params-on-stack.rs | 17 - .../params-on-stack.stderr | 5 - .../wrong-abi-location-1.rs | 6 - .../wrong-abi-location-1.stderr | 9 - .../wrong-abi-location-2.rs | 8 - .../wrong-abi-location-2.stderr | 11 - src/test/ui/codemap_tests/unicode.stderr | 2 +- ...coercion-missing-tail-expected-type.stderr | 4 +- src/test/ui/command/command-setgroups.rs | 1 - .../cross_crate_predicate.stderr | 8 +- .../different-fn.stderr | 2 +- .../nested_uneval_unification-1.rs | 1 + .../subexprs_are_const_evalutable.rs | 17 - .../ui/const-ptr/out_of_bounds_read.stderr | 8 - src/test/ui/const-ptr/ptr_to_usize_cast.rs | 13 - .../ui/const-ptr/ptr_to_usize_cast.stderr | 14 - .../const_evaluatable/needs_where_clause.rs | 14 - .../needs_where_clause.stderr | 14 - .../ui/const_evaluatable/no_where_clause.rs | 29 - .../const_evaluatable/no_where_clause.stderr | 14 - .../ui/consts/assoc_const_generic_impl.rs | 1 - .../ui/consts/assoc_const_generic_impl.stderr | 4 +- .../ui/consts/assume-type-intrinsics.stderr | 2 - src/test/ui/consts/const-err-early.rs | 5 - src/test/ui/consts/const-err-early.stderr | 22 +- src/test/ui/consts/const-err-multi.rs | 4 - src/test/ui/consts/const-err-multi.stderr | 17 +- src/test/ui/consts/const-err.rs | 1 - src/test/ui/consts/const-err.stderr | 6 +- .../const-eval/conditional_array_execution.rs | 2 - .../conditional_array_execution.stderr | 9 +- .../consts/const-eval/const-eval-overflow2.rs | 8 - .../const-eval/const-eval-overflow2.stderr | 37 +- .../const-eval/const-eval-overflow2b.rs | 8 - .../const-eval/const-eval-overflow2b.stderr | 37 +- .../const-eval/const-eval-overflow2c.rs | 8 - .../const-eval/const-eval-overflow2c.stderr | 37 +- .../const-eval/const-eval-query-stack.rs | 1 - .../const-eval/const-eval-query-stack.stderr | 4 +- .../const-pointer-values-in-various-types.rs | 20 - ...nst-pointer-values-in-various-types.stderr | 113 +- src/test/ui/consts/const-eval/const_panic.rs | 11 - .../ui/consts/const-eval/const_panic.stderr | 60 +- .../const-eval/const_panic_libcore_bin.rs | 3 - .../const-eval/const_panic_libcore_bin.stderr | 14 +- .../consts/const-eval/const_raw_ptr_ops2.rs | 3 - .../const-eval/const_raw_ptr_ops2.stderr | 14 +- src/test/ui/consts/const-eval/dangling.rs | 6 +- src/test/ui/consts/const-eval/dangling.stderr | 3 - .../ui/consts/const-eval/erroneous-const.rs | 1 - .../consts/const-eval/erroneous-const.stderr | 8 +- .../const-eval/heap/alloc_intrinsic_errors.rs | 1 - .../heap/alloc_intrinsic_errors.stderr | 2 - .../index-out-of-bounds-never-type.rs | 1 - .../index-out-of-bounds-never-type.stderr | 4 +- src/test/ui/consts/const-eval/issue-43197.rs | 4 - .../ui/consts/const-eval/issue-43197.stderr | 21 +- src/test/ui/consts/const-eval/issue-49296.rs | 1 - .../ui/consts/const-eval/issue-49296.stderr | 2 - .../ui/consts/const-eval/issue-50814-2.rs | 1 - .../ui/consts/const-eval/issue-50814-2.stderr | 4 +- src/test/ui/consts/const-eval/issue-50814.rs | 1 - .../ui/consts/const-eval/issue-50814.stderr | 4 +- .../const-eval/panic-assoc-never-type.rs | 1 - .../const-eval/panic-assoc-never-type.stderr | 4 +- .../ui/consts/const-eval/panic-never-type.rs | 1 - .../consts/const-eval/panic-never-type.stderr | 4 +- .../const-eval/promoted_errors.noopt.stderr | 13 +- .../const-eval/promoted_errors.opt.stderr | 16 +- ...ted_errors.opt_with_overflow_checks.stderr | 13 +- .../ui/consts/const-eval/promoted_errors.rs | 11 +- .../ui/consts/const-eval/pub_const_err.rs | 1 - .../ui/consts/const-eval/pub_const_err.stderr | 2 - .../ui/consts/const-eval/pub_const_err_bin.rs | 1 - .../const-eval/pub_const_err_bin.stderr | 2 - .../consts/const-eval/simd/insert_extract.rs | 10 +- src/test/ui/consts/const-eval/ub-nonnull.rs | 1 - .../ui/consts/const-eval/ub-nonnull.stderr | 13 +- .../consts/const-eval/unused-broken-const.rs | 1 - .../const-eval/unused-broken-const.stderr | 2 - src/test/ui/consts/const-eval/unwind-abort.rs | 1 - .../ui/consts/const-eval/unwind-abort.stderr | 4 +- .../const-eval/validate_uninhabited_zsts.rs | 1 - .../validate_uninhabited_zsts.stderr | 10 +- .../consts/const-external-macro-const-err.rs | 1 - .../const-external-macro-const-err.stderr | 2 - src/test/ui/consts/const-int-arithmetic.rs | 5 + src/test/ui/consts/const-int-unchecked.rs | 47 - src/test/ui/consts/const-int-unchecked.stderr | 232 +- .../const-len-underflow-separate-spans.rs | 1 - .../const-len-underflow-separate-spans.stderr | 4 +- .../mut_ref_in_final_dynamic_check.rs | 1 - .../mut_ref_in_final_dynamic_check.stderr | 6 +- .../consts/const-prop-read-static-in-const.rs | 1 - .../const-prop-read-static-in-const.stderr | 2 - ...st-size_of_val-align_of_val-extern-type.rs | 2 - ...ize_of_val-align_of_val-extern-type.stderr | 7 +- src/test/ui/consts/const-slice-oob.rs | 1 - src/test/ui/consts/const-slice-oob.stderr | 2 - src/test/ui/consts/const-unwrap.stderr | 2 - .../const_limit/const_eval_limit_reached.rs | 1 - .../const_eval_limit_reached.stderr | 3 - .../ui/consts/const_unsafe_unreachable_ub.rs | 1 - .../consts/const_unsafe_unreachable_ub.stderr | 4 - .../control-flow/assert.const_panic.stderr | 2 - src/test/ui/consts/control-flow/assert.rs | 1 - src/test/ui/consts/issue-51559.rs | 1 - src/test/ui/consts/issue-51559.stderr | 4 +- src/test/ui/consts/issue-52432.stderr | 2 +- src/test/ui/{limits => consts}/issue-55878.rs | 0 .../ui/{limits => consts}/issue-55878.stderr | 2 - src/test/ui/{limits => consts}/issue-56762.rs | 0 .../ui/{limits => consts}/issue-56762.stderr | 0 .../const_refers_to_static_cross_crate.rs | 4 - .../const_refers_to_static_cross_crate.stderr | 37 +- .../ui/consts/miri_unleashed/ptr_arith.rs | 2 +- .../ui/consts/miri_unleashed/ptr_arith.stderr | 2 +- src/test/ui/consts/offset_from_ub.stderr | 14 - src/test/ui/consts/offset_ub.stderr | 32 - src/test/ui/consts/ptr_comparisons.rs | 10 +- src/test/ui/consts/ptr_comparisons.stderr | 19 +- .../transmute-size-mismatch-before-typeck.rs | 1 - ...ansmute-size-mismatch-before-typeck.stderr | 2 - .../consts/uninhabited-const-issue-61744.rs | 1 - .../uninhabited-const-issue-61744.stderr | 132 +- .../cycle-projection-based-on-where-clause.rs | 24 + ...le-projection-based-on-where-clause.stderr | 16 + .../cycle-trait-supertrait-direct.stderr | 11 +- .../cycle-trait-supertrait-indirect.stderr | 18 +- .../derives/derive-Debug-use-ufcs-struct.rs | 40 - .../ui/derives/derive-Debug-use-ufcs-tuple.rs | 32 - src/test/ui/derives/derive-deadlock.rs | 6 - src/test/ui/derives/derive-deadlock.stderr | 10 - .../ui/derives/derive-multiple-with-packed.rs | 10 - src/test/ui/derives/derive-partial-ord.rs | 60 - src/test/ui/derives/derive-renamed.rs | 11 - ...ves-span-PartialOrd-enum-struct-variant.rs | 4 + ...span-PartialOrd-enum-struct-variant.stderr | 42 +- .../derives/derives-span-PartialOrd-enum.rs | 4 + .../derives-span-PartialOrd-enum.stderr | 42 +- .../derives/derives-span-PartialOrd-struct.rs | 4 + .../derives-span-PartialOrd-struct.stderr | 42 +- .../derives-span-PartialOrd-tuple-struct.rs | 4 + ...erives-span-PartialOrd-tuple-struct.stderr | 42 +- .../derives/deriving-meta-empty-trait-list.rs | 4 +- .../deriving-meta-empty-trait-list.stderr | 15 + src/test/ui/derives/issue-36617.rs | 3 +- src/test/ui/derives/issue-36617.stderr | 15 +- src/test/ui/drop/dynamic-drop-async.rs | 167 +- src/test/ui/drop/dynamic-drop.rs | 441 +- src/test/ui/error-codes/E0396-fixed.rs | 1 - src/test/ui/error-codes/E0396-fixed.stderr | 2 - src/test/ui/{cast => }/fat-ptr-cast-rpass.rs | 0 src/test/ui/{cast => }/fat-ptr-cast.rs | 0 src/test/ui/{cast => }/fat-ptr-cast.stderr | 0 .../feature-gate-exhaustive-patterns.stderr | 2 +- .../feature-gate-relaxed_struct_unsize.rs | 10 - .../feature-gate-relaxed_struct_unsize.stderr | 14 - .../issue-43106-gating-of-derive.rs | 1 - .../issue-43106-gating-of-derive.stderr | 22 +- src/test/ui/fmt/format-args-capture.rs | 13 +- .../ref-escapes-but-not-over-yield.stderr | 1 - .../type-mismatch-signature-deduction.stderr | 10 +- .../gat-in-trait-path-undeclared-lifetime.rs | 12 - ...t-in-trait-path-undeclared-lifetime.stderr | 29 - .../gat-in-trait-path.rs | 30 - .../gat-in-trait-path.stderr | 11 - .../gat-trait-path-generic-type-arg.rs | 16 - .../gat-trait-path-generic-type-arg.stderr | 32 - .../gat-trait-path-missing-lifetime.rs | 18 - .../gat-trait-path-missing-lifetime.stderr | 44 - .../gat-trait-path-parenthesised-args.rs | 15 - .../gat-trait-path-parenthesised-args.stderr | 68 - .../issue-67510-pass.rs | 12 - .../issue-67510-pass.stderr | 11 - .../generic-associated-types/issue-67510.rs | 13 - .../issue-67510.stderr | 32 - .../generic-associated-types/issue-68648-1.rs | 26 - .../issue-68648-1.stderr | 11 - .../generic-associated-types/issue-68648-2.rs | 24 - .../issue-68648-2.stderr | 23 - .../issue-68649-pass.rs | 25 - .../issue-68649-pass.stderr | 11 - .../generic-associated-types/issue-74684-1.rs | 26 - .../issue-74684-1.stderr | 27 - .../generic-associated-types/issue-74684-2.rs | 26 - .../issue-74684-2.stderr | 21 - .../generic-associated-types/issue-76535.rs | 41 - .../issue-76535.stderr | 63 - .../generic-associated-types/issue-79422.rs | 47 - .../issue-79422.stderr | 54 - .../issue-80433-reduced.rs | 24 - .../generic-associated-types/issue-80433.rs | 35 - .../issue-80433.stderr | 19 - .../trait-path-type-error-once-implemented.rs | 6 +- ...it-path-type-error-once-implemented.stderr | 51 +- .../parse/trait-path-unimplemented.rs | 17 + .../parse/trait-path-unimplemented.stderr | 14 + src/test/ui/generics/wrong-number-of-args.rs | 2 +- .../ui/generics/wrong-number-of-args.stderr | 2 +- .../ui/{limits => }/huge-array-simple-32.rs | 0 .../{limits => }/huge-array-simple-32.stderr | 0 .../ui/{limits => }/huge-array-simple-64.rs | 0 .../{limits => }/huge-array-simple-64.stderr | 0 src/test/ui/{limits => }/huge-array.rs | 0 src/test/ui/{limits => }/huge-array.stderr | 0 src/test/ui/{limits => }/huge-enum.rs | 0 src/test/ui/{limits => }/huge-enum.stderr | 0 src/test/ui/{limits => }/huge-struct.rs | 0 src/test/ui/{limits => }/huge-struct.stderr | 0 .../dyn-trait.nll.stderr | 1 - src/test/ui/impl-trait/trait_type.stderr | 8 +- .../cannot-infer-closure-circular.stderr | 4 +- .../ui/inference/cannot-infer-closure.stderr | 6 +- .../cannot-infer-partial-try-return.stderr | 6 +- src/test/ui/inference/issue-72616.stderr | 2 +- src/test/ui/issue-74047.stderr | 2 +- src/test/ui/issues/issue-11844.stderr | 4 +- src/test/ui/issues/issue-12511.stderr | 16 +- src/test/ui/issues/issue-12552.stderr | 12 +- src/test/ui/issues/issue-13466.rs | 8 +- src/test/ui/issues/issue-13466.stderr | 8 +- .../ui/{limits => issues}/issue-15919-32.rs | 0 .../{limits => issues}/issue-15919-32.stderr | 0 .../ui/{limits => issues}/issue-15919-64.rs | 0 .../{limits => issues}/issue-15919-64.stderr | 0 src/test/ui/issues/issue-16683.nll.stderr | 1 - src/test/ui/{simd => issues}/issue-17170.rs | 2 +- src/test/ui/{cast => issues}/issue-17444.rs | 0 .../ui/{cast => issues}/issue-17444.stderr | 0 src/test/ui/issues/issue-17758.nll.stderr | 1 - src/test/ui/{limits => issues}/issue-17913.rs | 0 .../ui/{limits => issues}/issue-17913.stderr | 0 src/test/ui/issues/issue-18919.stderr | 2 +- src/test/ui/issues/issue-20772.stderr | 6 +- src/test/ui/issues/issue-20825.stderr | 6 +- src/test/ui/issues/issue-21332.rs | 2 +- src/test/ui/issues/issue-21332.stderr | 4 +- src/test/ui/issues/issue-22673.rs | 5 +- src/test/ui/issues/issue-22673.stderr | 16 + src/test/ui/issues/issue-23281.stderr | 2 +- src/test/ui/issues/issue-29821.rs | 19 - src/test/ui/issues/issue-34229.rs | 4 + src/test/ui/issues/issue-34229.stderr | 42 +- src/test/ui/issues/issue-3680.rs | 4 +- src/test/ui/issues/issue-3680.stderr | 4 +- src/test/ui/{simd => issues}/issue-39720.rs | 3 +- src/test/ui/issues/issue-4736.stderr | 2 +- src/test/ui/issues/issue-49934-errors.rs | 9 +- src/test/ui/issues/issue-49934-errors.stderr | 13 +- src/test/ui/issues/issue-49934.rs | 17 +- src/test/ui/issues/issue-49934.stderr | 31 +- .../result-as_deref.stderr | 2 +- .../result-as_deref_mut.stderr | 4 +- ...1632-try-desugar-incompatible-types.stderr | 4 +- src/test/ui/issues/issue-6458-4.stderr | 4 +- src/test/ui/issues/issue-75307.stderr | 4 +- src/test/ui/issues/issue-80607.stderr | 2 +- ...etime-bound-will-change-warning.nll.stderr | 1 - .../lifetime-elision-return-type-trait.stderr | 4 +- src/test/ui/limits/issue-75158-64.rs | 16 - src/test/ui/limits/issue-75158-64.stderr | 4 - src/test/ui/lint/forbid-group-group-1.rs | 13 - src/test/ui/lint/forbid-group-group-1.stderr | 15 - src/test/ui/lint/forbid-group-group-2.rs | 26 - src/test/ui/lint/forbid-group-group-2.stderr | 115 - src/test/ui/lint/forbid-group-member.rs | 19 - src/test/ui/lint/forbid-group-member.stderr | 51 - src/test/ui/lint/forbid-member-group.rs | 12 - src/test/ui/lint/forbid-member-group.stderr | 30 - .../issue-69485-var-size-diffs-too-large.rs | 0 ...ssue-69485-var-size-diffs-too-large.stderr | 0 ...0819-dont-override-forbid-in-same-scope.rs | 7 +- ...-dont-override-forbid-in-same-scope.stderr | 30 +- src/test/ui/lint/issue-80988.rs | 16 - src/test/ui/lint/issue-80988.stderr | 51 - src/test/ui/lint/issue-81218.rs | 14 - src/test/ui/lint/lint-ctypes-enum.stderr | 2 +- src/test/ui/lint/lint-unsafe-code.rs | 18 +- src/test/ui/lint/lint-unsafe-code.stderr | 115 +- src/test/ui/lint/must_use-tuple.rs | 10 +- src/test/ui/lint/must_use-tuple.stderr | 10 +- src/test/ui/lint/outer-forbid.rs | 5 - src/test/ui/lint/outer-forbid.stderr | 37 +- .../semicolon-in-expressions-from-macros.rs | 11 - ...emicolon-in-expressions-from-macros.stderr | 6 +- src/test/ui/macros/assert-macro-owned.rs | 2 - .../ui/macros/builtin-std-paths-fail.stderr | 44 +- .../ui/macros/macro-comma-behavior-rpass.rs | 2 +- .../ui/macros/must-use-in-macro-55516.stderr | 2 +- .../issue-69341-malformed-derive-inert.rs | 5 +- .../issue-69341-malformed-derive-inert.stderr | 21 +- .../malformed/malformed-derive-entry.stderr | 2 +- .../malformed/malformed-special-attrs.stderr | 4 +- src/test/ui/methods/method-lookup-order.rs | 190 - src/test/ui/mir/issue-80949.rs | 34 - src/test/ui/mir/mir_drop_order.rs | 2 +- src/test/ui/mismatched_types/abridged.stderr | 10 +- src/test/ui/mismatched_types/binops.rs | 2 +- src/test/ui/mismatched_types/binops.stderr | 6 +- .../method-help-unsatisfied-bound.stderr | 4 +- .../escape-upvar-nested.stderr | 8 +- .../escape-upvar-ref.stderr | 4 +- ...er-to-static-comparing-against-free.stderr | 3 +- ...oximated-shorter-to-static-no-bound.stderr | 1 - ...mated-shorter-to-static-wrong-bound.stderr | 1 - src/test/ui/nll/issue-54556-niconii.stderr | 2 +- .../ui/nll/outlives-suggestion-simple.stderr | 1 - .../user-annotations/closure-substs.stderr | 1 - src/test/ui/numeric/numeric-fields.stderr | 2 +- .../object-lifetime-default-mybox.nll.stderr | 1 - .../exhaustiveness-unreachable-pattern.rs | 23 +- .../exhaustiveness-unreachable-pattern.stderr | 56 +- .../ui/or-patterns/inconsistent-modes.stderr | 2 +- .../ui/{non-fmt-panic.rs => panic-brace.rs} | 12 +- ...on-fmt-panic.stderr => panic-brace.stderr} | 116 +- src/test/ui/panics/explicit-panic-msg.rs | 1 - src/test/ui/panics/panic-2021.rs | 9 - src/test/ui/panics/panic-2021.stderr | 42 - src/test/ui/panics/panic-macro-any-wrapped.rs | 2 - src/test/ui/panics/panic-macro-any.rs | 1 - src/test/ui/panics/while-panic.rs | 2 +- .../ui/parser/ascii-only-character-escape.rs | 6 +- .../parser/ascii-only-character-escape.stderr | 12 +- src/test/ui/parser/bad-char-literals.rs | 8 +- src/test/ui/parser/bad-char-literals.stderr | 16 +- src/test/ui/parser/byte-literals.rs | 4 +- src/test/ui/parser/byte-literals.stderr | 25 +- src/test/ui/parser/byte-string-literals.rs | 5 +- .../ui/parser/byte-string-literals.stderr | 27 +- .../ui/parser/issue-23620-invalid-escapes.rs | 14 +- .../parser/issue-23620-invalid-escapes.stderr | 34 +- src/test/ui/parser/issue-43692.stderr | 4 +- src/test/ui/parser/issue-62913.stderr | 2 +- src/test/ui/parser/issue-64732.stderr | 6 +- src/test/ui/parser/issue-81806.rs | 5 - src/test/ui/parser/issue-81806.stderr | 17 - src/test/ui/parser/issue-8537.stderr | 2 +- .../ui/parser/lex-bad-char-literals-1.stderr | 8 +- src/test/ui/parser/lex-bad-char-literals-7.rs | 2 +- .../ui/parser/lex-bad-char-literals-7.stderr | 6 +- .../lex-bare-cr-string-literal-doc-comment.rs | 2 +- ...-bare-cr-string-literal-doc-comment.stderr | 6 +- ...rals-are-validated-before-expansion.stderr | 4 +- src/test/ui/parser/new-unicode-escapes-1.rs | 2 +- .../ui/parser/new-unicode-escapes-1.stderr | 9 +- src/test/ui/parser/new-unicode-escapes-2.rs | 2 +- .../ui/parser/new-unicode-escapes-2.stderr | 4 +- .../ui/parser/new-unicode-escapes-3.stderr | 4 +- src/test/ui/parser/new-unicode-escapes-4.rs | 2 +- .../ui/parser/new-unicode-escapes-4.stderr | 4 +- .../raw/raw-byte-string-literals.stderr | 2 +- .../trailing-carriage-return-in-string.rs | 4 +- .../trailing-carriage-return-in-string.stderr | 2 +- .../parser/unclosed-delimiter-in-dep.stderr | 4 +- .../ui/parser/wrong-escape-of-curly-braces.rs | 8 +- .../wrong-escape-of-curly-braces.stderr | 4 +- .../borrowck-move-and-move.stderr | 4 +- .../borrowck-pat-ref-mut-and-ref.stderr | 4 +- .../or-pattern-macro-pat.rs} | 0 .../pat-struct-field-expr-has-type.stderr | 4 +- .../ui/pattern/pat-type-err-let-stmt.stderr | 12 +- .../issue-80501-or-pat-and-macro.rs | 27 - .../non-exhaustive-match-nested.stderr | 2 +- .../attribute-after-derive-feature-gate.rs | 37 - ...attribute-after-derive-feature-gate.stderr | 30 - .../ui/proc-macro/attribute-after-derive.rs | 30 - .../proc-macro/attribute-after-derive.stdout | 148 - .../proc-macro/attribute-order-restricted.rs | 14 + .../attribute-order-restricted.stderr | 8 + .../proc-macro/derive-helper-legacy-limits.rs | 21 - .../derive-helper-legacy-limits.stderr | 8 - .../ui/proc-macro/derive-helper-shadowing.rs | 2 - .../proc-macro/derive-helper-shadowing.stderr | 27 +- .../ui/proc-macro/derive-helper-vs-legacy.rs | 12 - .../proc-macro/derive-multiple-with-packed.rs | 11 - .../helper-attr-blocked-by-import-ambig.rs | 4 +- ...helper-attr-blocked-by-import-ambig.stderr | 19 +- .../ui/proc-macro/issue-75930-derive-cfg.rs | 3 +- .../proc-macro/issue-75930-derive-cfg.stderr | 15 - .../proc-macro/issue-75930-derive-cfg.stdout | 728 +- .../proc-macro/issue-81543-item-parse-err.rs | 14 - .../issue-81543-item-parse-err.stderr | 8 - src/test/ui/proc-macro/lifetimes.stderr | 7 +- .../ui/proc-macro/proc-macro-attributes.rs | 8 - .../proc-macro/proc-macro-attributes.stderr | 67 +- .../ui/proc-macro/reserved-macro-names.rs | 6 + .../ui/proc-macro/reserved-macro-names.stderr | 8 +- src/test/ui/range/range_traits-1.rs | 24 + src/test/ui/range/range_traits-1.stderr | 262 +- ...recursive-types-are-not-uninhabited.stderr | 2 +- src/test/ui/regions/issue-78262.nll.stderr | 1 - ...nvariant-static-error-reporting.nll.stderr | 1 - ...hod-type-parameters-trait-bound.nll.stderr | 1 - .../ui/regions/regions-nested-fns.nll.stderr | 3 +- .../termination-trait-test-wrong-type.stderr | 4 +- .../ui/rfc-2294-if-let-guard/typeck.stderr | 4 +- .../simd-intrinsic-generic-elements.rs | 19 +- .../simd-intrinsic-generic-elements.stderr | 48 +- .../simd-type-generic-monomorphisation.rs | 0 .../simd-type-generic-monomorphisation.stderr | 0 src/test/ui/simd-type.rs | 20 + src/test/ui/{simd => }/simd-type.stderr | 26 +- src/test/ui/simd/issue-17170.stderr | 11 - src/test/ui/simd/issue-39720.stderr | 15 - .../simd/simd-intrinsic-generic-elements.rs | 24 + src/test/ui/simd/simd-size-align.rs | 103 +- ...imd-type-generic-monomorphisation-empty.rs | 12 - ...type-generic-monomorphisation-empty.stderr | 4 - ...type-generic-monomorphisation-oversized.rs | 12 - ...-generic-monomorphisation-oversized.stderr | 4 - ...e-generic-monomorphisation-power-of-two.rs | 12 - ...neric-monomorphisation-power-of-two.stderr | 4 - src/test/ui/simd/simd-type.rs | 34 +- .../ui/span/impl-wrong-item-for-trait.stderr | 2 +- .../ui/span/issue-43927-non-ADT-derive.rs | 7 +- .../ui/span/issue-43927-non-ADT-derive.stderr | 31 +- src/test/ui/span/macro-ty-params.rs | 2 +- src/test/ui/span/macro-ty-params.stderr | 2 +- .../stability-attribute-sanity.stderr | 2 +- ...adt-param-with-implicit-sized-bound.stderr | 4 +- src/test/ui/suggestions/as-ref.stderr | 12 +- src/test/ui/suggestions/field-access.fixed | 8 +- src/test/ui/suggestions/field-access.rs | 8 +- src/test/ui/suggestions/field-access.stderr | 8 +- ...rait-with-implicit-static-bound.nll.stderr | 1 - .../suggestions/mut-ref-reassignment.stderr | 2 +- ...n-existent-field-present-in-subfield.fixed | 4 +- .../non-existent-field-present-in-subfield.rs | 4 +- .../ui/suggestions/option-content-move.stderr | 2 +- src/test/ui/suggestions/suggest-box.stderr | 2 +- .../ui/test-attrs/test-filter-multiple.rs | 17 - .../test-filter-multiple.run.stdout | 7 - .../self-without-lifetime-constraint.stderr | 8 +- .../ui/treat-err-as-bug/delay_span_bug.rs | 11 - .../ui/treat-err-as-bug/delay_span_bug.stderr | 11 - src/test/ui/treat-err-as-bug/err.rs | 11 - src/test/ui/treat-err-as-bug/err.stderr | 12 - .../ui/try-block/try-block-bad-type.stderr | 4 +- .../ui/typeck/issue-80207-unsized-return.rs | 20 - .../uninhabited-matches-feature-gated.stderr | 6 +- src/test/ui/unsized/unchanged-param.rs | 12 - src/test/ui/unsized/unsized-enum.stderr | 2 +- .../unsized-inherent-impl-self-type.stderr | 2 +- src/test/ui/unsized/unsized-struct.stderr | 2 +- .../unsized-trait-impl-self-type.stderr | 2 +- src/test/ui/unsupported-cast.rs | 7 + .../ui/{cast => }/unsupported-cast.stderr | 4 +- .../extern-loc-bad-loctype.rs | 8 - .../extern-loc-bad-loctype.stderr | 2 - .../unused-crate-deps/extern-loc-defl-json.rs | 10 - .../extern-loc-defl-json.stderr | 17 - .../extern-loc-json-bad-json.rs | 8 - .../extern-loc-json-bad-json.stderr | 2 - .../unused-crate-deps/extern-loc-json-json.rs | 10 - .../extern-loc-json-json.stderr | 17 - .../ui/unused-crate-deps/extern-loc-json.rs | 10 - .../unused-crate-deps/extern-loc-json.stderr | 15 - .../extern-loc-missing-loc.rs | 8 - .../extern-loc-missing-loc.stderr | 2 - .../extern-loc-missing-loctype.rs | 8 - .../extern-loc-missing-loctype.stderr | 2 - .../unused-crate-deps/extern-loc-raw-json.rs | 10 - .../extern-loc-raw-json.stderr | 17 - .../extern-loc-raw-missing-loc.rs | 8 - .../extern-loc-raw-missing-loc.stderr | 2 - .../ui/unused-crate-deps/extern-loc-raw.rs | 10 - .../unused-crate-deps/extern-loc-raw.stderr | 15 - src/test/ui/unused-crate-deps/libfib.stderr | 1 - src/test/ui/unused-crate-deps/test.mk | 7 - .../unused-crate-deps/unused-aliases.stderr | 1 - .../ui/unused-crate-deps/warn-attr.stderr | 1 - .../warn-cmdline-static.stderr | 1 - .../ui/unused-crate-deps/warn-cmdline.stderr | 1 - src/test/ui/wf/wf-fn-where-clause.stderr | 2 +- src/tools/cargo | 2 +- src/tools/clippy/.editorconfig | 2 - src/tools/clippy/CHANGELOG.md | 1 - src/tools/clippy/CONTRIBUTING.md | 9 +- src/tools/clippy/Cargo.toml | 2 +- src/tools/clippy/clippy_dev/src/bless.rs | 3 - src/tools/clippy/clippy_dev/src/fmt.rs | 23 +- src/tools/clippy/clippy_dev/src/lib.rs | 13 - src/tools/clippy/clippy_dev/src/ra_setup.rs | 3 - src/tools/clippy/clippy_dev/src/serve.rs | 3 - src/tools/clippy/clippy_lints/Cargo.toml | 2 +- src/tools/clippy/clippy_lints/src/doc.rs | 131 +- .../clippy_lints/src/excessive_bools.rs | 14 +- .../clippy_lints/src/exhaustive_items.rs | 10 +- src/tools/clippy/clippy_lints/src/lib.rs | 2 - src/tools/clippy/clippy_lints/src/matches.rs | 12 +- .../clippy/clippy_lints/src/methods/mod.rs | 2 +- .../clippy/clippy_lints/src/misc_early.rs | 8 +- .../clippy_lints/src/non_expressive_names.rs | 9 +- .../clippy_lints/src/utils/ast_utils.rs | 52 +- .../clippy_lints/src/utils/constants.rs | 13 + .../clippy_lints/src/utils/diagnostics.rs | 2 +- .../clippy_lints/src/utils/internal_lints.rs | 6 +- .../clippy/clippy_lints/src/utils/mod.rs | 32 +- src/tools/clippy/clippy_lints/src/write.rs | 48 +- src/tools/clippy/doc/adding_lints.md | 10 +- src/tools/clippy/doc/basics.md | 2 +- src/tools/clippy/mini-macro/src/lib.rs | 3 - src/tools/clippy/rust-toolchain | 2 +- src/tools/clippy/tests/missing-test-files.rs | 14 +- .../tests/ui/assertions_on_constants.rs | 2 - .../tests/ui/assertions_on_constants.stderr | 18 +- src/tools/clippy/tests/ui/doc_panics.rs | 95 - src/tools/clippy/tests/ui/doc_panics.stderr | 67 - .../clippy/tests/ui/exhaustive_items.fixed | 23 +- src/tools/clippy/tests/ui/exhaustive_items.rs | 23 +- .../clippy/tests/ui/exhaustive_items.stderr | 4 +- .../clippy/tests/ui/expect_fun_call.fixed | 10 +- .../clippy/tests/ui/expect_fun_call.stderr | 10 +- .../clippy/tests/ui/fallible_impl_from.rs | 2 +- .../clippy/tests/ui/fallible_impl_from.stderr | 4 +- src/tools/clippy/tests/ui/let_and_return.rs | 12 +- .../clippy/tests/ui/let_and_return.stderr | 2 +- .../clippy/tests/ui/match_overlapping_arm.rs | 30 - .../tests/ui/match_overlapping_arm.stderr | 32 +- .../ui/should_impl_trait/corner_cases.rs | 3 +- .../ui/should_impl_trait/method_list_1.rs | 3 +- .../ui/should_impl_trait/method_list_1.stderr | 28 +- .../ui/should_impl_trait/method_list_2.rs | 3 +- .../ui/should_impl_trait/method_list_2.stderr | 30 +- src/tools/compiletest/src/common.rs | 4 +- src/tools/compiletest/src/header.rs | 11 - src/tools/compiletest/src/main.rs | 6 +- src/tools/compiletest/src/runtest.rs | 7 +- src/tools/compiletest/src/util.rs | 6 +- src/tools/miri | 2 +- src/tools/remote-test-server/src/main.rs | 24 +- src/tools/rust-analyzer | 2 +- src/tools/tidy/src/style.rs | 67 +- src/version | 2 +- 1027 files changed, 19997 insertions(+), 25940 deletions(-) delete mode 100644 .editorconfig delete mode 100644 compiler/rustc_builtin_macros/src/derive.rs delete mode 100644 compiler/rustc_error_codes/src/error_codes/E0521.md delete mode 100644 compiler/rustc_error_codes/src/error_codes/E0542.md delete mode 100644 compiler/rustc_error_codes/src/error_codes/E0781.md delete mode 100644 compiler/rustc_lint/src/non_fmt_panic.rs create mode 100644 compiler/rustc_lint/src/panic_fmt.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_be_unknown_linux_gnu.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_be_unknown_linux_gnu_ilp32.rs delete mode 100644 compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu_ilp32.rs delete mode 100644 library/core/tests/ops/control_flow.rs delete mode 100644 src/doc/unstable-book/src/compiler-flags/extern-location.md delete mode 100644 src/doc/unstable-book/src/language-features/abi-c-cmse-nonsecure-call.md delete mode 100644 src/test/codegen/asm-sanitize-llvm.rs delete mode 100644 src/test/mir-opt/inline/inline-instruction-set.rs delete mode 100644 src/test/mir-opt/inline/inline_instruction_set.default.Inline.diff delete mode 100644 src/test/mir-opt/inline/inline_instruction_set.t32.Inline.diff delete mode 100644 src/test/pretty/macro_rules.rs create mode 100644 src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-ge-{closure#0}-{closure#0}.-------.InstrumentCoverage.0.html create mode 100644 src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-ge-{closure#0}.-------.InstrumentCoverage.0.html create mode 100644 src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-ge.-------.InstrumentCoverage.0.html create mode 100644 src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-gt-{closure#0}-{closure#0}.-------.InstrumentCoverage.0.html create mode 100644 src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-gt-{closure#0}.-------.InstrumentCoverage.0.html create mode 100644 src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-gt.-------.InstrumentCoverage.0.html create mode 100644 src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-le-{closure#0}-{closure#0}.-------.InstrumentCoverage.0.html create mode 100644 src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-le-{closure#0}.-------.InstrumentCoverage.0.html create mode 100644 src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-le.-------.InstrumentCoverage.0.html create mode 100644 src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-lt-{closure#0}-{closure#0}.-------.InstrumentCoverage.0.html create mode 100644 src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-lt-{closure#0}.-------.InstrumentCoverage.0.html create mode 100644 src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-lt.-------.InstrumentCoverage.0.html create mode 100644 src/test/run-make-fulldeps/treat-err-as-bug/Makefile create mode 100644 src/test/run-make-fulldeps/treat-err-as-bug/delay_span_bug.rs create mode 100644 src/test/run-make-fulldeps/treat-err-as-bug/err.rs delete mode 100644 src/test/rustdoc-json/method_abi.rs delete mode 100644 src/test/rustdoc-json/traits/has_body.rs delete mode 100644 src/test/rustdoc-json/unions/union.rs delete mode 100644 src/test/rustdoc-ui/issue-81662-shortness.rs delete mode 100644 src/test/rustdoc-ui/issue-81662-shortness.stdout delete mode 100644 src/test/rustdoc/task-lists.rs delete mode 100644 src/test/ui/allocator/object-safe.rs delete mode 100644 src/test/ui/associated-type-bounds/ambiguous-associated-type2.rs delete mode 100644 src/test/ui/associated-type-bounds/ambiguous-associated-type2.stderr delete mode 100644 src/test/ui/associated-type-bounds/associated-item-through-where-clause.rs delete mode 100644 src/test/ui/associated-type-bounds/handle-predicates-that-can-define-assoc-type.rs delete mode 100644 src/test/ui/associated-type-bounds/missing-trait-bound-for-assoc-fails.rs delete mode 100644 src/test/ui/associated-type-bounds/missing-trait-bound-for-assoc-fails.stderr delete mode 100644 src/test/ui/associated-type-bounds/super-trait-referencing-self.rs delete mode 100644 src/test/ui/associated-type-bounds/super-trait-referencing.rs delete mode 100644 src/test/ui/associated-type-bounds/super-trait-where-referencing-self.rs delete mode 100644 src/test/ui/associated-type-bounds/traits-assoc-anonymized.rs delete mode 100644 src/test/ui/associated-type-bounds/traits-assoc-type-macros.rs delete mode 100644 src/test/ui/associated-types/issue-24159.rs delete mode 100644 src/test/ui/associated-types/issue-37808.rs delete mode 100644 src/test/ui/associated-types/issue-37883.rs delete mode 100644 src/test/ui/associated-types/issue-38917.rs delete mode 100644 src/test/ui/associated-types/issue-39532.rs delete mode 100644 src/test/ui/associated-types/issue-40093.rs delete mode 100644 src/test/ui/associated-types/issue-43475.rs delete mode 100644 src/test/ui/associated-types/issue-63591.rs delete mode 100644 src/test/ui/cast/unsupported-cast.rs delete mode 100644 src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.rs delete mode 100644 src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.stderr delete mode 100644 src/test/ui/closures/2229_closure_analysis/migrations/no_migrations.rs delete mode 100644 src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.rs delete mode 100644 src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr delete mode 100644 src/test/ui/closures/issue-81700-mut-borrow.rs delete mode 100644 src/test/ui/closures/issue-81700-mut-borrow.stderr rename src/test/ui/{cmse-nonsecure => }/cmse-nonsecure-entry/gate_test.rs (100%) rename src/test/ui/{cmse-nonsecure => }/cmse-nonsecure-entry/gate_test.stderr (100%) rename src/test/ui/{cmse-nonsecure => }/cmse-nonsecure-entry/params-on-registers.rs (100%) rename src/test/ui/{cmse-nonsecure => }/cmse-nonsecure-entry/params-on-stack.rs (100%) rename src/test/ui/{cmse-nonsecure => }/cmse-nonsecure-entry/params-on-stack.stderr (100%) rename src/test/ui/{cmse-nonsecure => }/cmse-nonsecure-entry/trustzone-only.rs (100%) rename src/test/ui/{cmse-nonsecure => }/cmse-nonsecure-entry/trustzone-only.stderr (100%) rename src/test/ui/{cmse-nonsecure => }/cmse-nonsecure-entry/wrong-abi.rs (100%) rename src/test/ui/{cmse-nonsecure => }/cmse-nonsecure-entry/wrong-abi.stderr (100%) delete mode 100644 src/test/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.rs delete mode 100644 src/test/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.stderr delete mode 100644 src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-registers.rs delete mode 100644 src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.rs delete mode 100644 src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.stderr delete mode 100644 src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.rs delete mode 100644 src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.stderr delete mode 100644 src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.rs delete mode 100644 src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.stderr delete mode 100644 src/test/ui/const-generics/const_evaluatable_checked/subexprs_are_const_evalutable.rs delete mode 100644 src/test/ui/const-ptr/ptr_to_usize_cast.rs delete mode 100644 src/test/ui/const-ptr/ptr_to_usize_cast.stderr delete mode 100644 src/test/ui/const_evaluatable/needs_where_clause.rs delete mode 100644 src/test/ui/const_evaluatable/needs_where_clause.stderr delete mode 100644 src/test/ui/const_evaluatable/no_where_clause.rs delete mode 100644 src/test/ui/const_evaluatable/no_where_clause.stderr rename src/test/ui/{limits => consts}/issue-55878.rs (100%) rename src/test/ui/{limits => consts}/issue-55878.stderr (80%) rename src/test/ui/{limits => consts}/issue-56762.rs (100%) rename src/test/ui/{limits => consts}/issue-56762.stderr (100%) create mode 100644 src/test/ui/cycle-projection-based-on-where-clause.rs create mode 100644 src/test/ui/cycle-projection-based-on-where-clause.stderr delete mode 100644 src/test/ui/derives/derive-Debug-use-ufcs-struct.rs delete mode 100644 src/test/ui/derives/derive-Debug-use-ufcs-tuple.rs delete mode 100644 src/test/ui/derives/derive-deadlock.rs delete mode 100644 src/test/ui/derives/derive-deadlock.stderr delete mode 100644 src/test/ui/derives/derive-multiple-with-packed.rs delete mode 100644 src/test/ui/derives/derive-partial-ord.rs delete mode 100644 src/test/ui/derives/derive-renamed.rs create mode 100644 src/test/ui/derives/deriving-meta-empty-trait-list.stderr rename src/test/ui/{cast => }/fat-ptr-cast-rpass.rs (100%) rename src/test/ui/{cast => }/fat-ptr-cast.rs (100%) rename src/test/ui/{cast => }/fat-ptr-cast.stderr (100%) delete mode 100644 src/test/ui/feature-gates/feature-gate-relaxed_struct_unsize.rs delete mode 100644 src/test/ui/feature-gates/feature-gate-relaxed_struct_unsize.stderr delete mode 100644 src/test/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.rs delete mode 100644 src/test/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.stderr delete mode 100644 src/test/ui/generic-associated-types/gat-in-trait-path.rs delete mode 100644 src/test/ui/generic-associated-types/gat-in-trait-path.stderr delete mode 100644 src/test/ui/generic-associated-types/gat-trait-path-generic-type-arg.rs delete mode 100644 src/test/ui/generic-associated-types/gat-trait-path-generic-type-arg.stderr delete mode 100644 src/test/ui/generic-associated-types/gat-trait-path-missing-lifetime.rs delete mode 100644 src/test/ui/generic-associated-types/gat-trait-path-missing-lifetime.stderr delete mode 100644 src/test/ui/generic-associated-types/gat-trait-path-parenthesised-args.rs delete mode 100644 src/test/ui/generic-associated-types/gat-trait-path-parenthesised-args.stderr delete mode 100644 src/test/ui/generic-associated-types/issue-67510-pass.rs delete mode 100644 src/test/ui/generic-associated-types/issue-67510-pass.stderr delete mode 100644 src/test/ui/generic-associated-types/issue-67510.rs delete mode 100644 src/test/ui/generic-associated-types/issue-67510.stderr delete mode 100644 src/test/ui/generic-associated-types/issue-68648-1.rs delete mode 100644 src/test/ui/generic-associated-types/issue-68648-1.stderr delete mode 100644 src/test/ui/generic-associated-types/issue-68648-2.rs delete mode 100644 src/test/ui/generic-associated-types/issue-68648-2.stderr delete mode 100644 src/test/ui/generic-associated-types/issue-68649-pass.rs delete mode 100644 src/test/ui/generic-associated-types/issue-68649-pass.stderr delete mode 100644 src/test/ui/generic-associated-types/issue-74684-1.rs delete mode 100644 src/test/ui/generic-associated-types/issue-74684-1.stderr delete mode 100644 src/test/ui/generic-associated-types/issue-74684-2.rs delete mode 100644 src/test/ui/generic-associated-types/issue-74684-2.stderr delete mode 100644 src/test/ui/generic-associated-types/issue-76535.rs delete mode 100644 src/test/ui/generic-associated-types/issue-76535.stderr delete mode 100644 src/test/ui/generic-associated-types/issue-79422.rs delete mode 100644 src/test/ui/generic-associated-types/issue-79422.stderr delete mode 100644 src/test/ui/generic-associated-types/issue-80433-reduced.rs delete mode 100644 src/test/ui/generic-associated-types/issue-80433.rs delete mode 100644 src/test/ui/generic-associated-types/issue-80433.stderr create mode 100644 src/test/ui/generic-associated-types/parse/trait-path-unimplemented.rs create mode 100644 src/test/ui/generic-associated-types/parse/trait-path-unimplemented.stderr rename src/test/ui/{limits => }/huge-array-simple-32.rs (100%) rename src/test/ui/{limits => }/huge-array-simple-32.stderr (100%) rename src/test/ui/{limits => }/huge-array-simple-64.rs (100%) rename src/test/ui/{limits => }/huge-array-simple-64.stderr (100%) rename src/test/ui/{limits => }/huge-array.rs (100%) rename src/test/ui/{limits => }/huge-array.stderr (100%) rename src/test/ui/{limits => }/huge-enum.rs (100%) rename src/test/ui/{limits => }/huge-enum.stderr (100%) rename src/test/ui/{limits => }/huge-struct.rs (100%) rename src/test/ui/{limits => }/huge-struct.stderr (100%) rename src/test/ui/{limits => issues}/issue-15919-32.rs (100%) rename src/test/ui/{limits => issues}/issue-15919-32.stderr (100%) rename src/test/ui/{limits => issues}/issue-15919-64.rs (100%) rename src/test/ui/{limits => issues}/issue-15919-64.stderr (100%) rename src/test/ui/{simd => issues}/issue-17170.rs (70%) rename src/test/ui/{cast => issues}/issue-17444.rs (100%) rename src/test/ui/{cast => issues}/issue-17444.stderr (100%) rename src/test/ui/{limits => issues}/issue-17913.rs (100%) rename src/test/ui/{limits => issues}/issue-17913.stderr (100%) create mode 100644 src/test/ui/issues/issue-22673.stderr delete mode 100644 src/test/ui/issues/issue-29821.rs rename src/test/ui/{simd => issues}/issue-39720.rs (80%) delete mode 100644 src/test/ui/limits/issue-75158-64.rs delete mode 100644 src/test/ui/limits/issue-75158-64.stderr delete mode 100644 src/test/ui/lint/forbid-group-group-1.rs delete mode 100644 src/test/ui/lint/forbid-group-group-1.stderr delete mode 100644 src/test/ui/lint/forbid-group-group-2.rs delete mode 100644 src/test/ui/lint/forbid-group-group-2.stderr delete mode 100644 src/test/ui/lint/forbid-group-member.rs delete mode 100644 src/test/ui/lint/forbid-group-member.stderr delete mode 100644 src/test/ui/lint/forbid-member-group.rs delete mode 100644 src/test/ui/lint/forbid-member-group.stderr rename src/test/ui/{limits => lint}/issue-69485-var-size-diffs-too-large.rs (100%) rename src/test/ui/{limits => lint}/issue-69485-var-size-diffs-too-large.stderr (100%) delete mode 100644 src/test/ui/lint/issue-80988.rs delete mode 100644 src/test/ui/lint/issue-80988.stderr delete mode 100644 src/test/ui/lint/issue-81218.rs delete mode 100644 src/test/ui/methods/method-lookup-order.rs delete mode 100644 src/test/ui/mir/issue-80949.rs rename src/test/ui/{non-fmt-panic.rs => panic-brace.rs} (70%) rename src/test/ui/{non-fmt-panic.stderr => panic-brace.stderr} (52%) delete mode 100644 src/test/ui/panics/panic-2021.rs delete mode 100644 src/test/ui/panics/panic-2021.stderr delete mode 100644 src/test/ui/parser/issue-81806.rs delete mode 100644 src/test/ui/parser/issue-81806.stderr rename src/test/ui/{or-patterns/macro-pat.rs => pattern/or-pattern-macro-pat.rs} (100%) delete mode 100644 src/test/ui/pattern/usefulness/issue-80501-or-pat-and-macro.rs delete mode 100644 src/test/ui/proc-macro/attribute-after-derive-feature-gate.rs delete mode 100644 src/test/ui/proc-macro/attribute-after-derive-feature-gate.stderr delete mode 100644 src/test/ui/proc-macro/attribute-after-derive.rs delete mode 100644 src/test/ui/proc-macro/attribute-after-derive.stdout create mode 100644 src/test/ui/proc-macro/attribute-order-restricted.rs create mode 100644 src/test/ui/proc-macro/attribute-order-restricted.stderr delete mode 100644 src/test/ui/proc-macro/derive-helper-legacy-limits.rs delete mode 100644 src/test/ui/proc-macro/derive-helper-legacy-limits.stderr delete mode 100644 src/test/ui/proc-macro/derive-helper-vs-legacy.rs delete mode 100644 src/test/ui/proc-macro/derive-multiple-with-packed.rs delete mode 100644 src/test/ui/proc-macro/issue-75930-derive-cfg.stderr delete mode 100644 src/test/ui/proc-macro/issue-81543-item-parse-err.rs delete mode 100644 src/test/ui/proc-macro/issue-81543-item-parse-err.stderr rename src/test/ui/{simd => }/simd-type-generic-monomorphisation.rs (100%) rename src/test/ui/{simd => }/simd-type-generic-monomorphisation.stderr (100%) create mode 100644 src/test/ui/simd-type.rs rename src/test/ui/{simd => }/simd-type.stderr (57%) delete mode 100644 src/test/ui/simd/issue-17170.stderr delete mode 100644 src/test/ui/simd/issue-39720.stderr delete mode 100644 src/test/ui/simd/simd-type-generic-monomorphisation-empty.rs delete mode 100644 src/test/ui/simd/simd-type-generic-monomorphisation-empty.stderr delete mode 100644 src/test/ui/simd/simd-type-generic-monomorphisation-oversized.rs delete mode 100644 src/test/ui/simd/simd-type-generic-monomorphisation-oversized.stderr delete mode 100644 src/test/ui/simd/simd-type-generic-monomorphisation-power-of-two.rs delete mode 100644 src/test/ui/simd/simd-type-generic-monomorphisation-power-of-two.stderr delete mode 100644 src/test/ui/test-attrs/test-filter-multiple.rs delete mode 100644 src/test/ui/test-attrs/test-filter-multiple.run.stdout delete mode 100644 src/test/ui/treat-err-as-bug/delay_span_bug.rs delete mode 100644 src/test/ui/treat-err-as-bug/delay_span_bug.stderr delete mode 100644 src/test/ui/treat-err-as-bug/err.rs delete mode 100644 src/test/ui/treat-err-as-bug/err.stderr delete mode 100644 src/test/ui/typeck/issue-80207-unsized-return.rs delete mode 100644 src/test/ui/unsized/unchanged-param.rs create mode 100644 src/test/ui/unsupported-cast.rs rename src/test/ui/{cast => }/unsupported-cast.stderr (65%) delete mode 100644 src/test/ui/unused-crate-deps/extern-loc-bad-loctype.rs delete mode 100644 src/test/ui/unused-crate-deps/extern-loc-bad-loctype.stderr delete mode 100644 src/test/ui/unused-crate-deps/extern-loc-defl-json.rs delete mode 100644 src/test/ui/unused-crate-deps/extern-loc-defl-json.stderr delete mode 100644 src/test/ui/unused-crate-deps/extern-loc-json-bad-json.rs delete mode 100644 src/test/ui/unused-crate-deps/extern-loc-json-bad-json.stderr delete mode 100644 src/test/ui/unused-crate-deps/extern-loc-json-json.rs delete mode 100644 src/test/ui/unused-crate-deps/extern-loc-json-json.stderr delete mode 100644 src/test/ui/unused-crate-deps/extern-loc-json.rs delete mode 100644 src/test/ui/unused-crate-deps/extern-loc-json.stderr delete mode 100644 src/test/ui/unused-crate-deps/extern-loc-missing-loc.rs delete mode 100644 src/test/ui/unused-crate-deps/extern-loc-missing-loc.stderr delete mode 100644 src/test/ui/unused-crate-deps/extern-loc-missing-loctype.rs delete mode 100644 src/test/ui/unused-crate-deps/extern-loc-missing-loctype.stderr delete mode 100644 src/test/ui/unused-crate-deps/extern-loc-raw-json.rs delete mode 100644 src/test/ui/unused-crate-deps/extern-loc-raw-json.stderr delete mode 100644 src/test/ui/unused-crate-deps/extern-loc-raw-missing-loc.rs delete mode 100644 src/test/ui/unused-crate-deps/extern-loc-raw-missing-loc.stderr delete mode 100644 src/test/ui/unused-crate-deps/extern-loc-raw.rs delete mode 100644 src/test/ui/unused-crate-deps/extern-loc-raw.stderr delete mode 100644 src/test/ui/unused-crate-deps/test.mk create mode 100644 src/tools/clippy/clippy_lints/src/utils/constants.rs delete mode 100644 src/tools/clippy/tests/ui/doc_panics.rs delete mode 100644 src/tools/clippy/tests/ui/doc_panics.stderr diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index ec6e107d547f0..0000000000000 --- a/.editorconfig +++ /dev/null @@ -1,21 +0,0 @@ -# EditorConfig helps developers define and maintain consistent -# coding styles between different editors and IDEs -# editorconfig.org - -root = true - -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true -indent_style = space -indent_size = 4 - -[*.md] -# double whitespace at end of line -# denotes a line break in Markdown -trim_trailing_whitespace = false - -[*.yml] -indent_size = 2 diff --git a/Cargo.lock b/Cargo.lock index fd23b2764c081..8bfdf23a30bf4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -496,9 +496,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chalk-derive" -version = "0.55.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3983193cacd81f0f924acb666b7fe5e1a0d81db9f113fa69203eda7ea8ce8b6c" +checksum = "9f88ce4deae1dace71e49b7611cfae2d5489de3530d6daba5758043c47ac3a10" dependencies = [ "proc-macro2", "quote", @@ -508,9 +508,9 @@ dependencies = [ [[package]] name = "chalk-engine" -version = "0.55.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05a171ce5abbf0fbd06f221ab80ab182c7ef78603d23b858bc44e7ce8a86a396" +checksum = "0e34c9b1b10616782143d7f49490f91ae94afaf2202de3ab0b2835e78b4f0ccc" dependencies = [ "chalk-derive", "chalk-ir", @@ -521,20 +521,19 @@ dependencies = [ [[package]] name = "chalk-ir" -version = "0.55.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a522f53af971e7678f472d687e053120157b3ae26e2ebd5ecbc0f5ab124f2cb6" +checksum = "63362c629c2014ab639b04029070763fb8224df136d1363d30e9ece4c8877da3" dependencies = [ - "bitflags", "chalk-derive", "lazy_static", ] [[package]] name = "chalk-solve" -version = "0.55.0" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdf79fb77a567e456a170f7ec84ea6584163d4ba3f13660cd182013d34ca667c" +checksum = "cac338a67af52a7f50bb2f8232e730a3518ce432dbe303246acfe525ddd838c7" dependencies = [ "chalk-derive", "chalk-ir", @@ -576,7 +575,7 @@ dependencies = [ [[package]] name = "clippy" -version = "0.1.52" +version = "0.1.51" dependencies = [ "cargo_metadata 0.12.0", "clippy-mini-macro-test", @@ -597,7 +596,7 @@ version = "0.2.0" [[package]] name = "clippy_lints" -version = "0.1.52" +version = "0.1.51" dependencies = [ "cargo_metadata 0.12.0", "if_chain", @@ -726,9 +725,9 @@ dependencies = [ [[package]] name = "const_fn" -version = "0.4.3" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab" +checksum = "ce90df4c658c62f12d78f7508cf92f9173e5184a539c10bfe54a3107b3ffd0f2" [[package]] name = "constant_time_eq" @@ -1784,9 +1783,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.85" +version = "0.2.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ccac4b00700875e6a07c6cde370d44d32fa01c5a65cdd2fca6858c479d28bb3" +checksum = "2448f6066e80e3bfc792e9c98bf705b4b0fc6e8ef5b43e5889aff0eaa9c58743" dependencies = [ "rustc-std-workspace-core", ] @@ -3582,7 +3581,6 @@ dependencies = [ "rustc_errors", "rustc_expand", "rustc_feature", - "rustc_lexer", "rustc_parse", "rustc_parse_format", "rustc_session", @@ -3627,7 +3625,6 @@ version = "0.0.0" dependencies = [ "bitflags", "cc", - "itertools 0.9.0", "jobserver", "libc", "memmap", @@ -3914,7 +3911,6 @@ dependencies = [ "rustc_index", "rustc_middle", "rustc_parse_format", - "rustc_serialize", "rustc_session", "rustc_span", "rustc_target", @@ -4317,7 +4313,6 @@ dependencies = [ "chalk-ir", "chalk-solve", "rustc_ast", - "rustc_attr", "rustc_data_structures", "rustc_hir", "rustc_index", diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index 2ddcb9ef844e9..ff89982a4efd8 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -2655,36 +2655,6 @@ impl Default for FnHeader { } } -#[derive(Clone, Encodable, Decodable, Debug)] -pub struct TraitKind( - pub IsAuto, - pub Unsafe, - pub Generics, - pub GenericBounds, - pub Vec>, -); - -#[derive(Clone, Encodable, Decodable, Debug)] -pub struct TyAliasKind(pub Defaultness, pub Generics, pub GenericBounds, pub Option>); - -#[derive(Clone, Encodable, Decodable, Debug)] -pub struct ImplKind { - pub unsafety: Unsafe, - pub polarity: ImplPolarity, - pub defaultness: Defaultness, - pub constness: Const, - pub generics: Generics, - - /// The trait being implemented, if any. - pub of_trait: Option, - - pub self_ty: P, - pub items: Vec>, -} - -#[derive(Clone, Encodable, Decodable, Debug)] -pub struct FnKind(pub Defaultness, pub FnSig, pub Generics, pub Option>); - #[derive(Clone, Encodable, Decodable, Debug)] pub enum ItemKind { /// An `extern crate` item, with the optional *original* crate name if the crate was renamed. @@ -2706,7 +2676,7 @@ pub enum ItemKind { /// A function declaration (`fn`). /// /// E.g., `fn foo(bar: usize) -> usize { .. }`. - Fn(Box), + Fn(Defaultness, FnSig, Generics, Option>), /// A module declaration (`mod`). /// /// E.g., `mod foo;` or `mod foo { .. }`. @@ -2720,7 +2690,7 @@ pub enum ItemKind { /// A type alias (`type`). /// /// E.g., `type Foo = Bar;`. - TyAlias(Box), + TyAlias(Defaultness, Generics, GenericBounds, Option>), /// An enum definition (`enum`). /// /// E.g., `enum Foo { C, D }`. @@ -2736,7 +2706,7 @@ pub enum ItemKind { /// A trait declaration (`trait`). /// /// E.g., `trait Foo { .. }`, `trait Foo { .. }` or `auto trait Foo {}`. - Trait(Box), + Trait(IsAuto, Unsafe, Generics, GenericBounds, Vec>), /// Trait alias /// /// E.g., `trait Foo = Bar + Quux;`. @@ -2744,7 +2714,19 @@ pub enum ItemKind { /// An implementation. /// /// E.g., `impl Foo { .. }` or `impl Trait for Foo { .. }`. - Impl(Box), + Impl { + unsafety: Unsafe, + polarity: ImplPolarity, + defaultness: Defaultness, + constness: Const, + generics: Generics, + + /// The trait being implemented, if any. + of_trait: Option, + + self_ty: P, + items: Vec>, + }, /// A macro invocation. /// /// E.g., `foo!(..)`. @@ -2754,9 +2736,6 @@ pub enum ItemKind { MacroDef(MacroDef), } -#[cfg(target_arch = "x86_64")] -rustc_data_structures::static_assert_size!(ItemKind, 112); - impl ItemKind { pub fn article(&self) -> &str { use ItemKind::*; @@ -2791,14 +2770,14 @@ impl ItemKind { pub fn generics(&self) -> Option<&Generics> { match self { - Self::Fn(box FnKind(_, _, generics, _)) - | Self::TyAlias(box TyAliasKind(_, generics, ..)) + Self::Fn(_, _, generics, _) + | Self::TyAlias(_, generics, ..) | Self::Enum(_, generics) | Self::Struct(_, generics) | Self::Union(_, generics) - | Self::Trait(box TraitKind(_, _, generics, ..)) + | Self::Trait(_, _, generics, ..) | Self::TraitAlias(generics, _) - | Self::Impl(box ImplKind { generics, .. }) => Some(generics), + | Self::Impl { generics, .. } => Some(generics), _ => None, } } @@ -2821,22 +2800,17 @@ pub enum AssocItemKind { /// If `def` is parsed, then the constant is provided, and otherwise required. Const(Defaultness, P, Option>), /// An associated function. - Fn(Box), + Fn(Defaultness, FnSig, Generics, Option>), /// An associated type. - TyAlias(Box), + TyAlias(Defaultness, Generics, GenericBounds, Option>), /// A macro expanding to associated items. MacCall(MacCall), } -#[cfg(target_arch = "x86_64")] -rustc_data_structures::static_assert_size!(AssocItemKind, 72); - impl AssocItemKind { pub fn defaultness(&self) -> Defaultness { match *self { - Self::Const(def, ..) - | Self::Fn(box FnKind(def, ..)) - | Self::TyAlias(box TyAliasKind(def, ..)) => def, + Self::Const(def, ..) | Self::Fn(def, ..) | Self::TyAlias(def, ..) => def, Self::MacCall(..) => Defaultness::Final, } } @@ -2846,8 +2820,8 @@ impl From for ItemKind { fn from(assoc_item_kind: AssocItemKind) -> ItemKind { match assoc_item_kind { AssocItemKind::Const(a, b, c) => ItemKind::Const(a, b, c), - AssocItemKind::Fn(fn_kind) => ItemKind::Fn(fn_kind), - AssocItemKind::TyAlias(ty_alias_kind) => ItemKind::TyAlias(ty_alias_kind), + AssocItemKind::Fn(a, b, c, d) => ItemKind::Fn(a, b, c, d), + AssocItemKind::TyAlias(a, b, c, d) => ItemKind::TyAlias(a, b, c, d), AssocItemKind::MacCall(a) => ItemKind::MacCall(a), } } @@ -2859,8 +2833,8 @@ impl TryFrom for AssocItemKind { fn try_from(item_kind: ItemKind) -> Result { Ok(match item_kind { ItemKind::Const(a, b, c) => AssocItemKind::Const(a, b, c), - ItemKind::Fn(fn_kind) => AssocItemKind::Fn(fn_kind), - ItemKind::TyAlias(ty_alias_kind) => AssocItemKind::TyAlias(ty_alias_kind), + ItemKind::Fn(a, b, c, d) => AssocItemKind::Fn(a, b, c, d), + ItemKind::TyAlias(a, b, c, d) => AssocItemKind::TyAlias(a, b, c, d), ItemKind::MacCall(a) => AssocItemKind::MacCall(a), _ => return Err(item_kind), }) @@ -2872,23 +2846,20 @@ impl TryFrom for AssocItemKind { pub enum ForeignItemKind { /// A foreign static item (`static FOO: u8`). Static(P, Mutability, Option>), - /// An foreign function. - Fn(Box), - /// An foreign type. - TyAlias(Box), + /// A foreign function. + Fn(Defaultness, FnSig, Generics, Option>), + /// A foreign type. + TyAlias(Defaultness, Generics, GenericBounds, Option>), /// A macro expanding to foreign items. MacCall(MacCall), } -#[cfg(target_arch = "x86_64")] -rustc_data_structures::static_assert_size!(ForeignItemKind, 72); - impl From for ItemKind { fn from(foreign_item_kind: ForeignItemKind) -> ItemKind { match foreign_item_kind { ForeignItemKind::Static(a, b, c) => ItemKind::Static(a, b, c), - ForeignItemKind::Fn(fn_kind) => ItemKind::Fn(fn_kind), - ForeignItemKind::TyAlias(ty_alias_kind) => ItemKind::TyAlias(ty_alias_kind), + ForeignItemKind::Fn(a, b, c, d) => ItemKind::Fn(a, b, c, d), + ForeignItemKind::TyAlias(a, b, c, d) => ItemKind::TyAlias(a, b, c, d), ForeignItemKind::MacCall(a) => ItemKind::MacCall(a), } } @@ -2900,8 +2871,8 @@ impl TryFrom for ForeignItemKind { fn try_from(item_kind: ItemKind) -> Result { Ok(match item_kind { ItemKind::Static(a, b, c) => ForeignItemKind::Static(a, b, c), - ItemKind::Fn(fn_kind) => ForeignItemKind::Fn(fn_kind), - ItemKind::TyAlias(ty_alias_kind) => ForeignItemKind::TyAlias(ty_alias_kind), + ItemKind::Fn(a, b, c, d) => ForeignItemKind::Fn(a, b, c, d), + ItemKind::TyAlias(a, b, c, d) => ForeignItemKind::TyAlias(a, b, c, d), ItemKind::MacCall(a) => ForeignItemKind::MacCall(a), _ => return Err(item_kind), }) diff --git a/compiler/rustc_ast/src/lib.rs b/compiler/rustc_ast/src/lib.rs index ddf52caed088a..08695491de756 100644 --- a/compiler/rustc_ast/src/lib.rs +++ b/compiler/rustc_ast/src/lib.rs @@ -9,11 +9,11 @@ test(attr(deny(warnings))) )] #![feature(box_syntax)] -#![feature(box_patterns)] #![feature(const_fn)] // For the `transmute` in `P::new` #![feature(const_fn_transmute)] #![feature(const_panic)] #![feature(crate_visibility_modifier)] +#![feature(iterator_fold_self)] #![feature(label_break_value)] #![feature(nll)] #![feature(or_patterns)] diff --git a/compiler/rustc_ast/src/mut_visit.rs b/compiler/rustc_ast/src/mut_visit.rs index 024d9687f3119..35de744d274c9 100644 --- a/compiler/rustc_ast/src/mut_visit.rs +++ b/compiler/rustc_ast/src/mut_visit.rs @@ -28,7 +28,7 @@ pub trait ExpectOne { impl ExpectOne for SmallVec { fn expect_one(self, err: &'static str) -> A::Item { - assert!(self.len() == 1, "{}", err); + assert!(self.len() == 1, err); self.into_iter().next().unwrap() } } @@ -912,7 +912,7 @@ pub fn noop_visit_item_kind(kind: &mut ItemKind, vis: &mut T) { vis.visit_ty(ty); visit_opt(expr, |expr| vis.visit_expr(expr)); } - ItemKind::Fn(box FnKind(_, sig, generics, body)) => { + ItemKind::Fn(_, sig, generics, body) => { visit_fn_sig(sig, vis); vis.visit_generics(generics); visit_opt(body, |body| vis.visit_block(body)); @@ -920,7 +920,7 @@ pub fn noop_visit_item_kind(kind: &mut ItemKind, vis: &mut T) { ItemKind::Mod(m) => vis.visit_mod(m), ItemKind::ForeignMod(nm) => vis.visit_foreign_mod(nm), ItemKind::GlobalAsm(_ga) => {} - ItemKind::TyAlias(box TyAliasKind(_, generics, bounds, ty)) => { + ItemKind::TyAlias(_, generics, bounds, ty) => { vis.visit_generics(generics); visit_bounds(bounds, vis); visit_opt(ty, |ty| vis.visit_ty(ty)); @@ -933,7 +933,7 @@ pub fn noop_visit_item_kind(kind: &mut ItemKind, vis: &mut T) { vis.visit_variant_data(variant_data); vis.visit_generics(generics); } - ItemKind::Impl(box ImplKind { + ItemKind::Impl { unsafety: _, polarity: _, defaultness: _, @@ -942,13 +942,13 @@ pub fn noop_visit_item_kind(kind: &mut ItemKind, vis: &mut T) { of_trait, self_ty, items, - }) => { + } => { vis.visit_generics(generics); visit_opt(of_trait, |trait_ref| vis.visit_trait_ref(trait_ref)); vis.visit_ty(self_ty); items.flat_map_in_place(|item| vis.flat_map_impl_item(item)); } - ItemKind::Trait(box TraitKind(.., generics, bounds, items)) => { + ItemKind::Trait(_is_auto, _unsafety, generics, bounds, items) => { vis.visit_generics(generics); visit_bounds(bounds, vis); items.flat_map_in_place(|item| vis.flat_map_trait_item(item)); @@ -976,12 +976,12 @@ pub fn noop_flat_map_assoc_item( visitor.visit_ty(ty); visit_opt(expr, |expr| visitor.visit_expr(expr)); } - AssocItemKind::Fn(box FnKind(_, sig, generics, body)) => { + AssocItemKind::Fn(_, sig, generics, body) => { visitor.visit_generics(generics); visit_fn_sig(sig, visitor); visit_opt(body, |body| visitor.visit_block(body)); } - AssocItemKind::TyAlias(box TyAliasKind(_, generics, bounds, ty)) => { + AssocItemKind::TyAlias(_, generics, bounds, ty) => { visitor.visit_generics(generics); visit_bounds(bounds, visitor); visit_opt(ty, |ty| visitor.visit_ty(ty)); @@ -1066,12 +1066,12 @@ pub fn noop_flat_map_foreign_item( visitor.visit_ty(ty); visit_opt(expr, |expr| visitor.visit_expr(expr)); } - ForeignItemKind::Fn(box FnKind(_, sig, generics, body)) => { + ForeignItemKind::Fn(_, sig, generics, body) => { visitor.visit_generics(generics); visit_fn_sig(sig, visitor); visit_opt(body, |body| visitor.visit_block(body)); } - ForeignItemKind::TyAlias(box TyAliasKind(_, generics, bounds, ty)) => { + ForeignItemKind::TyAlias(_, generics, bounds, ty) => { visitor.visit_generics(generics); visit_bounds(bounds, visitor); visit_opt(ty, |ty| visitor.visit_ty(ty)); diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs index c37d4cd9f7936..2ba1c49edfa44 100644 --- a/compiler/rustc_ast/src/visit.rs +++ b/compiler/rustc_ast/src/visit.rs @@ -292,7 +292,7 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) { visitor.visit_ty(typ); walk_list!(visitor, visit_expr, expr); } - ItemKind::Fn(box FnKind(_, ref sig, ref generics, ref body)) => { + ItemKind::Fn(_, ref sig, ref generics, ref body) => { visitor.visit_generics(generics); let kind = FnKind::Fn(FnCtxt::Free, item.ident, sig, &item.vis, body.as_deref()); visitor.visit_fn(kind, item.span, item.id) @@ -302,7 +302,7 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) { walk_list!(visitor, visit_foreign_item, &foreign_module.items); } ItemKind::GlobalAsm(ref ga) => visitor.visit_global_asm(ga), - ItemKind::TyAlias(box TyAliasKind(_, ref generics, ref bounds, ref ty)) => { + ItemKind::TyAlias(_, ref generics, ref bounds, ref ty) => { visitor.visit_generics(generics); walk_list!(visitor, visit_param_bound, bounds); walk_list!(visitor, visit_ty, ty); @@ -311,7 +311,7 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) { visitor.visit_generics(generics); visitor.visit_enum_def(enum_definition, generics, item.id, item.span) } - ItemKind::Impl(box ImplKind { + ItemKind::Impl { unsafety: _, polarity: _, defaultness: _, @@ -320,7 +320,7 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) { ref of_trait, ref self_ty, ref items, - }) => { + } => { visitor.visit_generics(generics); walk_list!(visitor, visit_trait_ref, of_trait); visitor.visit_ty(self_ty); @@ -331,7 +331,7 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) { visitor.visit_generics(generics); visitor.visit_variant_data(struct_definition); } - ItemKind::Trait(box TraitKind(.., ref generics, ref bounds, ref items)) => { + ItemKind::Trait(.., ref generics, ref bounds, ref items) => { visitor.visit_generics(generics); walk_list!(visitor, visit_param_bound, bounds); walk_list!(visitor, visit_assoc_item, items, AssocCtxt::Trait); @@ -543,12 +543,12 @@ pub fn walk_foreign_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a ForeignI visitor.visit_ty(ty); walk_list!(visitor, visit_expr, expr); } - ForeignItemKind::Fn(box FnKind(_, sig, generics, body)) => { + ForeignItemKind::Fn(_, sig, generics, body) => { visitor.visit_generics(generics); let kind = FnKind::Fn(FnCtxt::Foreign, ident, sig, vis, body.as_deref()); visitor.visit_fn(kind, span, id); } - ForeignItemKind::TyAlias(box TyAliasKind(_, generics, bounds, ty)) => { + ForeignItemKind::TyAlias(_, generics, bounds, ty) => { visitor.visit_generics(generics); walk_list!(visitor, visit_param_bound, bounds); walk_list!(visitor, visit_ty, ty); @@ -653,12 +653,12 @@ pub fn walk_assoc_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a AssocItem, visitor.visit_ty(ty); walk_list!(visitor, visit_expr, expr); } - AssocItemKind::Fn(box FnKind(_, sig, generics, body)) => { + AssocItemKind::Fn(_, sig, generics, body) => { visitor.visit_generics(generics); let kind = FnKind::Fn(FnCtxt::Assoc(ctxt), ident, sig, vis, body.as_deref()); visitor.visit_fn(kind, span, id); } - AssocItemKind::TyAlias(box TyAliasKind(_, generics, bounds, ty)) => { + AssocItemKind::TyAlias(_, generics, bounds, ty) => { visitor.visit_generics(generics); walk_list!(visitor, visit_param_bound, bounds); walk_list!(visitor, visit_ty, ty); diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index 1efe83cacea4a..69257ce1c19e9 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -67,7 +67,7 @@ impl<'a> Visitor<'a> for ItemLowerer<'a, '_, '_> { if let Some(hir_id) = item_hir_id { self.lctx.with_parent_item_lifetime_defs(hir_id, |this| { let this = &mut ItemLowerer { lctx: this }; - if let ItemKind::Impl(box ImplKind { ref of_trait, .. }) = item.kind { + if let ItemKind::Impl { ref of_trait, .. } = item.kind { this.with_trait_impl_ref(of_trait, |this| visit::walk_item(this, item)); } else { visit::walk_item(this, item); @@ -189,9 +189,7 @@ impl<'hir> LoweringContext<'_, 'hir> { vec } ItemKind::MacroDef(..) => SmallVec::new(), - ItemKind::Fn(..) | ItemKind::Impl(box ImplKind { of_trait: None, .. }) => { - smallvec![i.id] - } + ItemKind::Fn(..) | ItemKind::Impl { of_trait: None, .. } => smallvec![i.id], _ => smallvec![i.id], }; @@ -278,12 +276,12 @@ impl<'hir> LoweringContext<'_, 'hir> { let (ty, body_id) = self.lower_const_item(t, span, e.as_deref()); hir::ItemKind::Const(ty, body_id) } - ItemKind::Fn(box FnKind( + ItemKind::Fn( _, FnSig { ref decl, header, span: fn_sig_span }, ref generics, ref body, - )) => { + ) => { let fn_def_id = self.resolver.local_def_id(id); self.with_new_scopes(|this| { this.current_item = Some(ident.span); @@ -331,7 +329,7 @@ impl<'hir> LoweringContext<'_, 'hir> { } } ItemKind::GlobalAsm(ref ga) => hir::ItemKind::GlobalAsm(self.lower_global_asm(ga)), - ItemKind::TyAlias(box TyAliasKind(_, ref gen, _, Some(ref ty))) => { + ItemKind::TyAlias(_, ref gen, _, Some(ref ty)) => { // We lower // // type Foo = impl Trait @@ -350,7 +348,7 @@ impl<'hir> LoweringContext<'_, 'hir> { let generics = self.lower_generics(gen, ImplTraitContext::disallowed()); hir::ItemKind::TyAlias(ty, generics) } - ItemKind::TyAlias(box TyAliasKind(_, ref generics, _, None)) => { + ItemKind::TyAlias(_, ref generics, _, None) => { let ty = self.arena.alloc(self.ty(span, hir::TyKind::Err)); let generics = self.lower_generics(generics, ImplTraitContext::disallowed()); hir::ItemKind::TyAlias(ty, generics) @@ -377,7 +375,7 @@ impl<'hir> LoweringContext<'_, 'hir> { self.lower_generics(generics, ImplTraitContext::disallowed()), ) } - ItemKind::Impl(box ImplKind { + ItemKind::Impl { unsafety, polarity, defaultness, @@ -386,7 +384,7 @@ impl<'hir> LoweringContext<'_, 'hir> { of_trait: ref trait_ref, self_ty: ref ty, items: ref impl_items, - }) => { + } => { let def_id = self.resolver.local_def_id(id); // Lower the "impl header" first. This ordering is important @@ -450,13 +448,7 @@ impl<'hir> LoweringContext<'_, 'hir> { items: new_impl_items, }) } - ItemKind::Trait(box TraitKind( - is_auto, - unsafety, - ref generics, - ref bounds, - ref items, - )) => { + ItemKind::Trait(is_auto, unsafety, ref generics, ref bounds, ref items) => { let bounds = self.lower_param_bounds(bounds, ImplTraitContext::disallowed()); let items = self .arena @@ -706,7 +698,7 @@ impl<'hir> LoweringContext<'_, 'hir> { ident: i.ident, attrs: self.lower_attrs(&i.attrs), kind: match i.kind { - ForeignItemKind::Fn(box FnKind(_, ref sig, ref generics, _)) => { + ForeignItemKind::Fn(_, ref sig, ref generics, _) => { let fdec = &sig.decl; let (generics, (fn_dec, fn_args)) = self.add_in_band_defs( generics, @@ -811,19 +803,19 @@ impl<'hir> LoweringContext<'_, 'hir> { let body = default.as_ref().map(|x| self.lower_const_body(i.span, Some(x))); (hir::Generics::empty(), hir::TraitItemKind::Const(ty, body)) } - AssocItemKind::Fn(box FnKind(_, ref sig, ref generics, None)) => { + AssocItemKind::Fn(_, ref sig, ref generics, None) => { let names = self.lower_fn_params_to_names(&sig.decl); let (generics, sig) = self.lower_method_sig(generics, sig, trait_item_def_id, false, None, i.id); (generics, hir::TraitItemKind::Fn(sig, hir::TraitFn::Required(names))) } - AssocItemKind::Fn(box FnKind(_, ref sig, ref generics, Some(ref body))) => { + AssocItemKind::Fn(_, ref sig, ref generics, Some(ref body)) => { let body_id = self.lower_fn_body_block(i.span, &sig.decl, Some(body)); let (generics, sig) = self.lower_method_sig(generics, sig, trait_item_def_id, false, None, i.id); (generics, hir::TraitItemKind::Fn(sig, hir::TraitFn::Provided(body_id))) } - AssocItemKind::TyAlias(box TyAliasKind(_, ref generics, ref bounds, ref default)) => { + AssocItemKind::TyAlias(_, ref generics, ref bounds, ref default) => { let ty = default.as_ref().map(|x| self.lower_ty(x, ImplTraitContext::disallowed())); let generics = self.lower_generics(generics, ImplTraitContext::disallowed()); let kind = hir::TraitItemKind::Type( @@ -849,10 +841,10 @@ impl<'hir> LoweringContext<'_, 'hir> { fn lower_trait_item_ref(&mut self, i: &AssocItem) -> hir::TraitItemRef { let (kind, has_default) = match &i.kind { AssocItemKind::Const(_, _, default) => (hir::AssocItemKind::Const, default.is_some()), - AssocItemKind::TyAlias(box TyAliasKind(_, _, _, default)) => { + AssocItemKind::TyAlias(_, _, _, default) => { (hir::AssocItemKind::Type, default.is_some()) } - AssocItemKind::Fn(box FnKind(_, sig, _, default)) => { + AssocItemKind::Fn(_, sig, _, default) => { (hir::AssocItemKind::Fn { has_self: sig.decl.has_self() }, default.is_some()) } AssocItemKind::MacCall(..) => unimplemented!(), @@ -878,7 +870,7 @@ impl<'hir> LoweringContext<'_, 'hir> { hir::ImplItemKind::Const(ty, self.lower_const_body(i.span, expr.as_deref())), ) } - AssocItemKind::Fn(box FnKind(_, sig, generics, body)) => { + AssocItemKind::Fn(_, sig, generics, body) => { self.current_item = Some(i.span); let asyncness = sig.header.asyncness; let body_id = @@ -895,7 +887,7 @@ impl<'hir> LoweringContext<'_, 'hir> { (generics, hir::ImplItemKind::Fn(sig, body_id)) } - AssocItemKind::TyAlias(box TyAliasKind(_, generics, _, ty)) => { + AssocItemKind::TyAlias(_, generics, _, ty) => { let generics = self.lower_generics(generics, ImplTraitContext::disallowed()); let kind = match ty { None => { @@ -946,7 +938,7 @@ impl<'hir> LoweringContext<'_, 'hir> { kind: match &i.kind { AssocItemKind::Const(..) => hir::AssocItemKind::Const, AssocItemKind::TyAlias(..) => hir::AssocItemKind::Type, - AssocItemKind::Fn(box FnKind(_, sig, ..)) => { + AssocItemKind::Fn(_, sig, ..) => { hir::AssocItemKind::Fn { has_self: sig.decl.has_self() } } AssocItemKind::MacCall(..) => unimplemented!(), diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index f076dca5cf5f1..8f2e49e299c8b 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -32,7 +32,6 @@ #![feature(crate_visibility_modifier)] #![feature(or_patterns)] -#![feature(box_patterns)] #![recursion_limit = "256"] use rustc_ast::node_id::NodeMap; @@ -501,15 +500,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { ItemKind::Struct(_, ref generics) | ItemKind::Union(_, ref generics) | ItemKind::Enum(_, ref generics) - | ItemKind::TyAlias(box TyAliasKind(_, ref generics, ..)) - | ItemKind::Trait(box TraitKind(_, _, ref generics, ..)) => { + | ItemKind::TyAlias(_, ref generics, ..) + | ItemKind::Trait(_, _, ref generics, ..) => { let def_id = self.lctx.resolver.local_def_id(item.id); let count = generics .params .iter() - .filter(|param| { - matches!(param.kind, ast::GenericParamKind::Lifetime { .. }) - }) + .filter(|param| matches!(param.kind, ast::GenericParamKind::Lifetime { .. })) .count(); self.lctx.type_def_lifetime_params.insert(def_id.to_def_id(), count); } @@ -1076,40 +1073,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { fn lower_assoc_ty_constraint( &mut self, constraint: &AssocTyConstraint, - mut itctx: ImplTraitContext<'_, 'hir>, + itctx: ImplTraitContext<'_, 'hir>, ) -> hir::TypeBinding<'hir> { debug!("lower_assoc_ty_constraint(constraint={:?}, itctx={:?})", constraint, itctx); - // lower generic arguments of identifier in constraint - let gen_args = if let Some(ref gen_args) = constraint.gen_args { - let gen_args_ctor = match gen_args { - GenericArgs::AngleBracketed(ref data) => { - self.lower_angle_bracketed_parameter_data( - data, - ParamMode::Explicit, - itctx.reborrow(), - ) - .0 - } - GenericArgs::Parenthesized(ref data) => { - let mut err = self.sess.struct_span_err( - gen_args.span(), - "parenthesized generic arguments cannot be used in associated type constraints" - ); - // FIXME: try to write a suggestion here - err.emit(); - self.lower_angle_bracketed_parameter_data( - &data.as_angle_bracketed_args(), - ParamMode::Explicit, - itctx.reborrow(), - ) - .0 - } - }; - self.arena.alloc(gen_args_ctor.into_generic_args(&self.arena)) - } else { - self.arena.alloc(hir::GenericArgs::none()) - }; + if let Some(ref gen_args) = constraint.gen_args { + self.sess.span_fatal( + gen_args.span(), + "generic associated types in trait paths are currently not implemented", + ); + } let kind = match constraint.kind { AssocTyConstraintKind::Equality { ref ty } => { @@ -1206,7 +1179,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { hir::TypeBinding { hir_id: self.lower_node_id(constraint.id), ident: constraint.ident, - gen_args, kind, span: constraint.span, } diff --git a/compiler/rustc_ast_lowering/src/path.rs b/compiler/rustc_ast_lowering/src/path.rs index cb4d5ea6ee650..9079e26eb509e 100644 --- a/compiler/rustc_ast_lowering/src/path.rs +++ b/compiler/rustc_ast_lowering/src/path.rs @@ -362,7 +362,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { } } - pub(crate) fn lower_angle_bracketed_parameter_data( + fn lower_angle_bracketed_parameter_data( &mut self, data: &AngleBracketedArgs, param_mode: ParamMode, @@ -426,9 +426,6 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { ) -> hir::TypeBinding<'hir> { let ident = Ident::with_dummy_span(hir::FN_OUTPUT_NAME); let kind = hir::TypeBindingKind::Equality { ty }; - let args = arena_vec![self;]; - let bindings = arena_vec![self;]; - let gen_args = self.arena.alloc(hir::GenericArgs { args, bindings, parenthesized: false }); - hir::TypeBinding { hir_id: self.next_id(), gen_args, span, ident, kind } + hir::TypeBinding { hir_id: self.next_id(), span, ident, kind } } } diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index 8defd91c688d7..baeadb216dc3a 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -920,7 +920,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { } match item.kind { - ItemKind::Impl(box ImplKind { + ItemKind::Impl { unsafety, polarity, defaultness: _, @@ -929,7 +929,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { of_trait: Some(ref t), ref self_ty, items: _, - }) => { + } => { self.with_in_trait_impl(true, |this| { this.invalid_visibility(&item.vis, None); if let TyKind::Err = self_ty.kind { @@ -957,7 +957,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { }); return; // Avoid visiting again. } - ItemKind::Impl(box ImplKind { + ItemKind::Impl { unsafety, polarity, defaultness, @@ -966,7 +966,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { of_trait: None, ref self_ty, items: _, - }) => { + } => { let error = |annotation_span, annotation| { let mut err = self.err_handler().struct_span_err( self_ty.span, @@ -998,7 +998,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { .emit(); } } - ItemKind::Fn(box FnKind(def, _, _, ref body)) => { + ItemKind::Fn(def, _, _, ref body) => { self.check_defaultness(item.span, def); if body.is_none() { @@ -1027,13 +1027,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { } } } - ItemKind::Trait(box TraitKind( - is_auto, - _, - ref generics, - ref bounds, - ref trait_items, - )) => { + ItemKind::Trait(is_auto, _, ref generics, ref bounds, ref trait_items) => { if is_auto == IsAuto::Yes { // Auto traits cannot have generics, super traits nor contain items. self.deny_generic_params(generics, item.ident.span); @@ -1081,7 +1075,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { let msg = "free static item without body"; self.error_item_without_body(item.span, "static", msg, " = ;"); } - ItemKind::TyAlias(box TyAliasKind(def, _, ref bounds, ref body)) => { + ItemKind::TyAlias(def, _, ref bounds, ref body) => { self.check_defaultness(item.span, def); if body.is_none() { let msg = "free type alias without body"; @@ -1097,12 +1091,12 @@ impl<'a> Visitor<'a> for AstValidator<'a> { fn visit_foreign_item(&mut self, fi: &'a ForeignItem) { match &fi.kind { - ForeignItemKind::Fn(box FnKind(def, sig, _, body)) => { + ForeignItemKind::Fn(def, sig, _, body) => { self.check_defaultness(fi.span, *def); self.check_foreign_fn_bodyless(fi.ident, body.as_deref()); self.check_foreign_fn_headerless(fi.ident, fi.span, sig.header); } - ForeignItemKind::TyAlias(box TyAliasKind(def, generics, bounds, body)) => { + ForeignItemKind::TyAlias(def, generics, bounds, body) => { self.check_defaultness(fi.span, *def); self.check_foreign_kind_bodyless(fi.ident, "type", body.as_ref().map(|b| b.span)); self.check_type_no_bounds(bounds, "`extern` blocks"); @@ -1342,10 +1336,10 @@ impl<'a> Visitor<'a> for AstValidator<'a> { AssocItemKind::Const(_, _, body) => { self.check_impl_item_provided(item.span, body, "constant", " = ;"); } - AssocItemKind::Fn(box FnKind(_, _, _, body)) => { + AssocItemKind::Fn(_, _, _, body) => { self.check_impl_item_provided(item.span, body, "function", " { }"); } - AssocItemKind::TyAlias(box TyAliasKind(_, _, bounds, body)) => { + AssocItemKind::TyAlias(_, _, bounds, body) => { self.check_impl_item_provided(item.span, body, "type", " = ;"); self.check_type_no_bounds(bounds, "`impl`s"); } @@ -1355,7 +1349,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> { if ctxt == AssocCtxt::Trait || self.in_trait_impl { self.invalid_visibility(&item.vis, None); - if let AssocItemKind::Fn(box FnKind(_, sig, _, _)) = &item.kind { + if let AssocItemKind::Fn(_, sig, _, _) = &item.kind { self.check_trait_fn_not_const(sig.header.constness); self.check_trait_fn_not_async(item.span, sig.header.asyncness); } diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs index 6514de2b81315..7bd805f91c857 100644 --- a/compiler/rustc_ast_passes/src/feature_gate.rs +++ b/compiler/rustc_ast_passes/src/feature_gate.rs @@ -156,14 +156,6 @@ impl<'a> PostExpansionVisitor<'a> { "efiapi ABI is experimental and subject to change" ); } - "C-cmse-nonsecure-call" => { - gate_feature_post!( - &self, - abi_c_cmse_nonsecure_call, - span, - "C-cmse-nonsecure-call ABI is experimental and subject to change" - ); - } abi => self .sess .parse_sess @@ -373,9 +365,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } } - ast::ItemKind::Impl(box ast::ImplKind { - polarity, defaultness, ref of_trait, .. - }) => { + ast::ItemKind::Impl { polarity, defaultness, ref of_trait, .. } => { if let ast::ImplPolarity::Negative(span) = polarity { gate_feature_post!( &self, @@ -391,7 +381,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } } - ast::ItemKind::Trait(box ast::TraitKind(ast::IsAuto::Yes, ..)) => { + ast::ItemKind::Trait(ast::IsAuto::Yes, ..) => { gate_feature_post!( &self, auto_traits, @@ -409,9 +399,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { gate_feature_post!(&self, decl_macro, i.span, msg); } - ast::ItemKind::TyAlias(box ast::TyAliasKind(_, _, _, Some(ref ty))) => { - self.check_impl_trait(&ty) - } + ast::ItemKind::TyAlias(_, _, _, Some(ref ty)) => self.check_impl_trait(&ty), _ => {} } @@ -567,13 +555,13 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { fn visit_assoc_item(&mut self, i: &'a ast::AssocItem, ctxt: AssocCtxt) { let is_fn = match i.kind { - ast::AssocItemKind::Fn(box ast::FnKind(_, ref sig, _, _)) => { + ast::AssocItemKind::Fn(_, ref sig, _, _) => { if let (ast::Const::Yes(_), AssocCtxt::Trait) = (sig.header.constness, ctxt) { gate_feature_post!(&self, const_fn, i.span, "const fn is unstable"); } true } - ast::AssocItemKind::TyAlias(box ast::TyAliasKind(_, ref generics, _, ref ty)) => { + ast::AssocItemKind::TyAlias(_, ref generics, _, ref ty) => { if let (Some(_), AssocCtxt::Trait) = (ty, ctxt) { gate_feature_post!( &self, diff --git a/compiler/rustc_ast_passes/src/lib.rs b/compiler/rustc_ast_passes/src/lib.rs index c9e2d202da97c..7487421e709a7 100644 --- a/compiler/rustc_ast_passes/src/lib.rs +++ b/compiler/rustc_ast_passes/src/lib.rs @@ -6,8 +6,6 @@ #![feature(bindings_after_at)] #![feature(iter_is_partitioned)] -#![feature(box_syntax)] -#![feature(box_patterns)] #![recursion_limit = "256"] pub mod ast_validation; diff --git a/compiler/rustc_ast_passes/src/node_count.rs b/compiler/rustc_ast_passes/src/node_count.rs index 2971fa435c8dc..6efc78c88427e 100644 --- a/compiler/rustc_ast_passes/src/node_count.rs +++ b/compiler/rustc_ast_passes/src/node_count.rs @@ -68,7 +68,7 @@ impl<'ast> Visitor<'ast> for NodeCounter { self.count += 1; walk_generics(self, g) } - fn visit_fn(&mut self, fk: visit::FnKind<'_>, s: Span, _: NodeId) { + fn visit_fn(&mut self, fk: FnKind<'_>, s: Span, _: NodeId) { self.count += 1; walk_fn(self, fk, s) } diff --git a/compiler/rustc_ast_pretty/src/lib.rs b/compiler/rustc_ast_pretty/src/lib.rs index d869baad012ed..9adc6c604e8ab 100644 --- a/compiler/rustc_ast_pretty/src/lib.rs +++ b/compiler/rustc_ast_pretty/src/lib.rs @@ -1,7 +1,6 @@ #![feature(bool_to_option)] #![feature(crate_visibility_modifier)] #![feature(or_patterns)] -#![feature(box_patterns)] #![recursion_limit = "256"] mod helpers; diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index 01e234c9be972..2c8caf68f00da 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -1022,14 +1022,14 @@ impl<'a> State<'a> { self.maybe_print_comment(span.lo()); self.print_outer_attributes(attrs); match kind { - ast::ForeignItemKind::Fn(box ast::FnKind(def, sig, gen, body)) => { + ast::ForeignItemKind::Fn(def, sig, gen, body) => { self.print_fn_full(sig, ident, gen, vis, *def, body.as_deref(), attrs); } ast::ForeignItemKind::Static(ty, mutbl, body) => { let def = ast::Defaultness::Final; self.print_item_const(ident, Some(*mutbl), ty, body.as_deref(), vis, def); } - ast::ForeignItemKind::TyAlias(box ast::TyAliasKind(def, generics, bounds, ty)) => { + ast::ForeignItemKind::TyAlias(def, generics, bounds, ty) => { self.print_associated_type(ident, generics, bounds, ty.as_deref(), vis, *def); } ast::ForeignItemKind::MacCall(m) => { @@ -1134,7 +1134,7 @@ impl<'a> State<'a> { ast::ItemKind::Const(def, ref ty, ref body) => { self.print_item_const(item.ident, None, ty, body.as_deref(), &item.vis, def); } - ast::ItemKind::Fn(box ast::FnKind(def, ref sig, ref gen, ref body)) => { + ast::ItemKind::Fn(def, ref sig, ref gen, ref body) => { let body = body.as_deref(); self.print_fn_full(sig, item.ident, gen, &item.vis, def, body, &item.attrs); } @@ -1175,7 +1175,7 @@ impl<'a> State<'a> { self.s.word(ga.asm.to_string()); self.end(); } - ast::ItemKind::TyAlias(box ast::TyAliasKind(def, ref generics, ref bounds, ref ty)) => { + ast::ItemKind::TyAlias(def, ref generics, ref bounds, ref ty) => { let ty = ty.as_deref(); self.print_associated_type(item.ident, generics, bounds, ty, &item.vis, def); } @@ -1190,7 +1190,7 @@ impl<'a> State<'a> { self.head(visibility_qualified(&item.vis, "union")); self.print_struct(struct_def, generics, item.ident, item.span, true); } - ast::ItemKind::Impl(box ast::ImplKind { + ast::ItemKind::Impl { unsafety, polarity, defaultness, @@ -1199,7 +1199,7 @@ impl<'a> State<'a> { ref of_trait, ref self_ty, ref items, - }) => { + } => { self.head(""); self.print_visibility(&item.vis); self.print_defaultness(defaultness); @@ -1233,13 +1233,7 @@ impl<'a> State<'a> { } self.bclose(item.span); } - ast::ItemKind::Trait(box ast::TraitKind( - is_auto, - unsafety, - ref generics, - ref bounds, - ref trait_items, - )) => { + ast::ItemKind::Trait(is_auto, unsafety, ref generics, ref bounds, ref trait_items) => { self.head(""); self.print_visibility(&item.vis); self.print_unsafety(unsafety); @@ -1311,9 +1305,6 @@ impl<'a> State<'a> { true, item.span, ); - if macro_def.body.need_semicolon() { - self.word(";"); - } } } self.ann.post(self, AnnNode::Item(item)) @@ -1462,13 +1453,13 @@ impl<'a> State<'a> { self.maybe_print_comment(span.lo()); self.print_outer_attributes(attrs); match kind { - ast::AssocItemKind::Fn(box ast::FnKind(def, sig, gen, body)) => { + ast::AssocItemKind::Fn(def, sig, gen, body) => { self.print_fn_full(sig, ident, gen, vis, *def, body.as_deref(), attrs); } ast::AssocItemKind::Const(def, ty, body) => { self.print_item_const(ident, None, ty, body.as_deref(), vis, *def); } - ast::AssocItemKind::TyAlias(box ast::TyAliasKind(def, generics, bounds, ty)) => { + ast::AssocItemKind::TyAlias(def, generics, bounds, ty) => { self.print_associated_type(ident, generics, bounds, ty.as_deref(), vis, *def); } ast::AssocItemKind::MacCall(m) => { diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs index aca3fbbca1357..696d5fdd6cd45 100644 --- a/compiler/rustc_attr/src/builtin.rs +++ b/compiler/rustc_attr/src/builtin.rs @@ -74,7 +74,7 @@ pub enum InlineAttr { Never, } -#[derive(Clone, Encodable, Decodable, Debug, PartialEq, Eq)] +#[derive(Clone, Encodable, Decodable, Debug)] pub enum InstructionSetAttr { ArmA32, ArmT32, diff --git a/compiler/rustc_builtin_macros/Cargo.toml b/compiler/rustc_builtin_macros/Cargo.toml index eb022b5b2b16e..c397a85412627 100644 --- a/compiler/rustc_builtin_macros/Cargo.toml +++ b/compiler/rustc_builtin_macros/Cargo.toml @@ -15,7 +15,6 @@ rustc_attr = { path = "../rustc_attr" } rustc_data_structures = { path = "../rustc_data_structures" } rustc_errors = { path = "../rustc_errors" } rustc_feature = { path = "../rustc_feature" } -rustc_lexer = { path = "../rustc_lexer" } rustc_parse = { path = "../rustc_parse" } rustc_target = { path = "../rustc_target" } rustc_session = { path = "../rustc_session" } diff --git a/compiler/rustc_builtin_macros/src/assert.rs b/compiler/rustc_builtin_macros/src/assert.rs index 93ba54da3424e..f82269c4eee4f 100644 --- a/compiler/rustc_builtin_macros/src/assert.rs +++ b/compiler/rustc_builtin_macros/src/assert.rs @@ -29,11 +29,11 @@ pub fn expand_assert<'cx>( let panic_call = if let Some(tokens) = custom_message { let path = if span.rust_2021() { - // On edition 2021, we always call `$crate::panic::panic_2021!()`. + // On edition 2021, we always call `$crate::panic!()`. Path { span: sp, segments: cx - .std_path(&[sym::panic, sym::panic_2021]) + .std_path(&[sym::panic]) .into_iter() .map(|ident| PathSegment::from_ident(ident)) .collect(), diff --git a/compiler/rustc_builtin_macros/src/derive.rs b/compiler/rustc_builtin_macros/src/derive.rs deleted file mode 100644 index fad64858ce3ff..0000000000000 --- a/compiler/rustc_builtin_macros/src/derive.rs +++ /dev/null @@ -1,132 +0,0 @@ -use rustc_ast::{self as ast, token, ItemKind, MetaItemKind, NestedMetaItem, StmtKind}; -use rustc_errors::{struct_span_err, Applicability}; -use rustc_expand::base::{Annotatable, ExpandResult, ExtCtxt, Indeterminate, MultiItemModifier}; -use rustc_expand::config::StripUnconfigured; -use rustc_feature::AttributeTemplate; -use rustc_parse::validate_attr; -use rustc_session::Session; -use rustc_span::symbol::sym; -use rustc_span::Span; - -crate struct Expander; - -impl MultiItemModifier for Expander { - fn expand( - &self, - ecx: &mut ExtCtxt<'_>, - span: Span, - meta_item: &ast::MetaItem, - item: Annotatable, - ) -> ExpandResult, Annotatable> { - let sess = ecx.sess; - if report_bad_target(sess, &item, span) { - // We don't want to pass inappropriate targets to derive macros to avoid - // follow up errors, all other errors below are recoverable. - return ExpandResult::Ready(vec![item]); - } - - let template = - AttributeTemplate { list: Some("Trait1, Trait2, ..."), ..Default::default() }; - let attr = ecx.attribute(meta_item.clone()); - validate_attr::check_builtin_attribute(&sess.parse_sess, &attr, sym::derive, template); - - let derives: Vec<_> = attr - .meta_item_list() - .unwrap_or_default() - .into_iter() - .filter_map(|nested_meta| match nested_meta { - NestedMetaItem::MetaItem(meta) => Some(meta), - NestedMetaItem::Literal(lit) => { - // Reject `#[derive("Debug")]`. - report_unexpected_literal(sess, &lit); - None - } - }) - .map(|meta| { - // Reject `#[derive(Debug = "value", Debug(abc))]`, but recover the paths. - report_path_args(sess, &meta); - meta.path - }) - .collect(); - - // FIXME: Try to cache intermediate results to avoid collecting same paths multiple times. - match ecx.resolver.resolve_derives(ecx.current_expansion.id, derives, ecx.force_mode) { - Ok(()) => { - let mut visitor = - StripUnconfigured { sess, features: ecx.ecfg.features, modified: false }; - let mut item = visitor.fully_configure(item); - if visitor.modified { - // Erase the tokens if cfg-stripping modified the item - // This will cause us to synthesize fake tokens - // when `nt_to_tokenstream` is called on this item. - match &mut item { - Annotatable::Item(item) => item, - Annotatable::Stmt(stmt) => match &mut stmt.kind { - StmtKind::Item(item) => item, - _ => unreachable!(), - }, - _ => unreachable!(), - } - .tokens = None; - } - ExpandResult::Ready(vec![item]) - } - Err(Indeterminate) => ExpandResult::Retry(item), - } - } -} - -fn report_bad_target(sess: &Session, item: &Annotatable, span: Span) -> bool { - let item_kind = match item { - Annotatable::Item(item) => Some(&item.kind), - Annotatable::Stmt(stmt) => match &stmt.kind { - StmtKind::Item(item) => Some(&item.kind), - _ => None, - }, - _ => None, - }; - - let bad_target = - !matches!(item_kind, Some(ItemKind::Struct(..) | ItemKind::Enum(..) | ItemKind::Union(..))); - if bad_target { - struct_span_err!( - sess, - span, - E0774, - "`derive` may only be applied to structs, enums and unions", - ) - .emit(); - } - bad_target -} - -fn report_unexpected_literal(sess: &Session, lit: &ast::Lit) { - let help_msg = match lit.token.kind { - token::Str if rustc_lexer::is_ident(&lit.token.symbol.as_str()) => { - format!("try using `#[derive({})]`", lit.token.symbol) - } - _ => "for example, write `#[derive(Debug)]` for `Debug`".to_string(), - }; - struct_span_err!(sess, lit.span, E0777, "expected path to a trait, found literal",) - .help(&help_msg) - .emit(); -} - -fn report_path_args(sess: &Session, meta: &ast::MetaItem) { - let report_error = |title, action| { - let span = meta.span.with_lo(meta.path.span.hi()); - sess.struct_span_err(span, title) - .span_suggestion(span, action, String::new(), Applicability::MachineApplicable) - .emit(); - }; - match meta.kind { - MetaItemKind::Word => {} - MetaItemKind::List(..) => report_error( - "traits in `#[derive(...)]` don't accept arguments", - "remove the arguments", - ), - MetaItemKind::NameValue(..) => { - report_error("traits in `#[derive(...)]` don't accept values", "remove the value") - } - } -} diff --git a/compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs b/compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs index db808bf2ff51e..21174ca4c8bf9 100644 --- a/compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs +++ b/compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs @@ -1,11 +1,13 @@ +pub use OrderingOp::*; + use crate::deriving::generic::ty::*; use crate::deriving::generic::*; -use crate::deriving::{path_std, pathvec_std}; +use crate::deriving::{path_local, path_std, pathvec_std}; use rustc_ast::ptr::P; -use rustc_ast::{Expr, MetaItem}; +use rustc_ast::{self as ast, BinOpKind, Expr, MetaItem}; use rustc_expand::base::{Annotatable, ExtCtxt}; -use rustc_span::symbol::{sym, Ident}; +use rustc_span::symbol::{sym, Ident, Symbol}; use rustc_span::Span; pub fn expand_deriving_partial_ord( @@ -15,6 +17,26 @@ pub fn expand_deriving_partial_ord( item: &Annotatable, push: &mut dyn FnMut(Annotatable), ) { + macro_rules! md { + ($name:expr, $op:expr, $equal:expr) => {{ + let inline = cx.meta_word(span, sym::inline); + let attrs = vec![cx.attribute(inline)]; + MethodDef { + name: $name, + generics: Bounds::empty(), + explicit_self: borrowed_explicit_self(), + args: vec![(borrowed_self(), sym::other)], + ret_ty: Literal(path_local!(bool)), + attributes: attrs, + is_unsafe: false, + unify_fieldless_variants: true, + combine_substructure: combine_substructure(Box::new(|cx, span, substr| { + cs_op($op, $equal, cx, span, substr) + })), + } + }}; + } + let ordering_ty = Literal(path_std!(cmp::Ordering)); let ret_ty = Literal(Path::new_( pathvec_std!(option::Option), @@ -40,6 +62,21 @@ pub fn expand_deriving_partial_ord( })), }; + // avoid defining extra methods if we can + // c-like enums, enums without any fields and structs without fields + // can safely define only `partial_cmp`. + let methods = if is_type_without_fields(item) { + vec![partial_cmp_def] + } else { + vec![ + partial_cmp_def, + md!(sym::lt, true, false), + md!(sym::le, true, true), + md!(sym::gt, false, false), + md!(sym::ge, false, true), + ] + }; + let trait_def = TraitDef { span, attributes: vec![], @@ -48,12 +85,39 @@ pub fn expand_deriving_partial_ord( generics: Bounds::empty(), is_unsafe: false, supports_unions: false, - methods: vec![partial_cmp_def], + methods, associated_types: Vec::new(), }; trait_def.expand(cx, mitem, item, push) } +#[derive(Copy, Clone)] +pub enum OrderingOp { + PartialCmpOp, + LtOp, + LeOp, + GtOp, + GeOp, +} + +pub fn some_ordering_collapsed( + cx: &mut ExtCtxt<'_>, + span: Span, + op: OrderingOp, + self_arg_tags: &[Ident], +) -> P { + let lft = cx.expr_ident(span, self_arg_tags[0]); + let rgt = cx.expr_addr_of(span, cx.expr_ident(span, self_arg_tags[1])); + let op_sym = match op { + PartialCmpOp => sym::partial_cmp, + LtOp => sym::lt, + LeOp => sym::le, + GtOp => sym::gt, + GeOp => sym::ge, + }; + cx.expr_method_call(span, lft, Ident::new(op_sym, span), vec![rgt]) +} + pub fn cs_partial_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> P { let test_id = Ident::new(sym::cmp, span); let ordering = cx.path_global(span, cx.std_path(&[sym::cmp, sym::Ordering, sym::Equal])); @@ -107,9 +171,7 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_ if self_args.len() != 2 { cx.span_bug(span, "not exactly 2 arguments in `derive(PartialOrd)`") } else { - let lft = cx.expr_ident(span, tag_tuple[0]); - let rgt = cx.expr_addr_of(span, cx.expr_ident(span, tag_tuple[1])); - cx.expr_method_call(span, lft, Ident::new(sym::partial_cmp, span), vec![rgt]) + some_ordering_collapsed(cx, span, PartialCmpOp, tag_tuple) } }), cx, @@ -117,3 +179,124 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_ substr, ) } + +/// Strict inequality. +fn cs_op( + less: bool, + inclusive: bool, + cx: &mut ExtCtxt<'_>, + span: Span, + substr: &Substructure<'_>, +) -> P { + let ordering_path = |cx: &mut ExtCtxt<'_>, name: &str| { + cx.expr_path( + cx.path_global(span, cx.std_path(&[sym::cmp, sym::Ordering, Symbol::intern(name)])), + ) + }; + + let par_cmp = |cx: &mut ExtCtxt<'_>, span, self_f: P, other_fs: &[P], default| { + let other_f = match other_fs { + [o_f] => o_f, + _ => cx.span_bug(span, "not exactly 2 arguments in `derive(PartialOrd)`"), + }; + + // `PartialOrd::partial_cmp(self.fi, other.fi)` + let cmp_path = cx.expr_path( + cx.path_global(span, cx.std_path(&[sym::cmp, sym::PartialOrd, sym::partial_cmp])), + ); + let cmp = cx.expr_call( + span, + cmp_path, + vec![cx.expr_addr_of(span, self_f), cx.expr_addr_of(span, other_f.clone())], + ); + + let default = ordering_path(cx, default); + // `Option::unwrap_or(_, Ordering::Equal)` + let unwrap_path = cx.expr_path( + cx.path_global(span, cx.std_path(&[sym::option, sym::Option, sym::unwrap_or])), + ); + cx.expr_call(span, unwrap_path, vec![cmp, default]) + }; + + let fold = cs_fold1( + false, // need foldr + |cx, span, subexpr, self_f, other_fs| { + // build up a series of `partial_cmp`s from the inside + // out (hence foldr) to get lexical ordering, i.e., for op == + // `ast::lt` + // + // ``` + // Ordering::then_with( + // Option::unwrap_or( + // PartialOrd::partial_cmp(self.f1, other.f1), Ordering::Equal) + // ), + // Option::unwrap_or( + // PartialOrd::partial_cmp(self.f2, other.f2), Ordering::Greater) + // ) + // ) + // == Ordering::Less + // ``` + // + // and for op == + // `ast::le` + // + // ``` + // Ordering::then_with( + // Option::unwrap_or( + // PartialOrd::partial_cmp(self.f1, other.f1), Ordering::Equal) + // ), + // Option::unwrap_or( + // PartialOrd::partial_cmp(self.f2, other.f2), Ordering::Greater) + // ) + // ) + // != Ordering::Greater + // ``` + // + // The optimiser should remove the redundancy. We explicitly + // get use the binops to avoid auto-deref dereferencing too many + // layers of pointers, if the type includes pointers. + + // `Option::unwrap_or(PartialOrd::partial_cmp(self.fi, other.fi), Ordering::Equal)` + let par_cmp = par_cmp(cx, span, self_f, other_fs, "Equal"); + + // `Ordering::then_with(Option::unwrap_or(..), ..)` + let then_with_path = cx.expr_path( + cx.path_global(span, cx.std_path(&[sym::cmp, sym::Ordering, sym::then_with])), + ); + cx.expr_call(span, then_with_path, vec![par_cmp, cx.lambda0(span, subexpr)]) + }, + |cx, args| match args { + Some((span, self_f, other_fs)) => { + let opposite = if less { "Greater" } else { "Less" }; + par_cmp(cx, span, self_f, other_fs, opposite) + } + None => cx.expr_bool(span, inclusive), + }, + Box::new(|cx, span, (self_args, tag_tuple), _non_self_args| { + if self_args.len() != 2 { + cx.span_bug(span, "not exactly 2 arguments in `derive(PartialOrd)`") + } else { + let op = match (less, inclusive) { + (false, false) => GtOp, + (false, true) => GeOp, + (true, false) => LtOp, + (true, true) => LeOp, + }; + some_ordering_collapsed(cx, span, op, tag_tuple) + } + }), + cx, + span, + substr, + ); + + match *substr.fields { + EnumMatching(.., ref all_fields) | Struct(.., ref all_fields) if !all_fields.is_empty() => { + let ordering = ordering_path(cx, if less ^ inclusive { "Less" } else { "Greater" }); + let comp_op = if inclusive { BinOpKind::Ne } else { BinOpKind::Eq }; + + cx.expr_binary(span, comp_op, fold, ordering) + } + _ => fold, + } +} diff --git a/compiler/rustc_builtin_macros/src/deriving/debug.rs b/compiler/rustc_builtin_macros/src/deriving/debug.rs index ba43be6ae9a9e..5c21329069bfc 100644 --- a/compiler/rustc_builtin_macros/src/deriving/debug.rs +++ b/compiler/rustc_builtin_macros/src/deriving/debug.rs @@ -8,10 +8,6 @@ use rustc_expand::base::{Annotatable, ExtCtxt}; use rustc_span::symbol::{sym, Ident}; use rustc_span::{Span, DUMMY_SP}; -fn make_mut_borrow(cx: &mut ExtCtxt<'_>, sp: Span, expr: P) -> P { - cx.expr(sp, ast::ExprKind::AddrOf(ast::BorrowKind::Ref, ast::Mutability::Mut, expr)) -} - pub fn expand_deriving_debug( cx: &mut ExtCtxt<'_>, span: Span, @@ -71,12 +67,11 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_> let fmt = substr.nonself_args[0].clone(); let mut stmts = Vec::with_capacity(fields.len() + 2); - let fn_path_finish; match vdata { ast::VariantData::Tuple(..) | ast::VariantData::Unit(..) => { // tuple struct/"normal" variant - let fn_path_debug_tuple = cx.std_path(&[sym::fmt, sym::Formatter, sym::debug_tuple]); - let expr = cx.expr_call_global(span, fn_path_debug_tuple, vec![fmt, name]); + let expr = + cx.expr_method_call(span, fmt, Ident::new(sym::debug_tuple, span), vec![name]); stmts.push(cx.stmt_let(span, true, builder, expr)); for field in fields { @@ -84,21 +79,22 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_> let field = cx.expr_addr_of(field.span, field.self_.clone()); let field = cx.expr_addr_of(field.span, field); - let fn_path_field = cx.std_path(&[sym::fmt, sym::DebugTuple, sym::field]); - let builder_recv = make_mut_borrow(cx, span, builder_expr.clone()); - let expr = cx.expr_call_global(span, fn_path_field, vec![builder_recv, field]); + let expr = cx.expr_method_call( + span, + builder_expr.clone(), + Ident::new(sym::field, span), + vec![field], + ); // Use `let _ = expr;` to avoid triggering the // unused_results lint. stmts.push(stmt_let_underscore(cx, span, expr)); } - - fn_path_finish = cx.std_path(&[sym::fmt, sym::DebugTuple, sym::finish]); } ast::VariantData::Struct(..) => { // normal struct/struct variant - let fn_path_debug_struct = cx.std_path(&[sym::fmt, sym::Formatter, sym::debug_struct]); - let expr = cx.expr_call_global(span, fn_path_debug_struct, vec![fmt, name]); + let expr = + cx.expr_method_call(span, fmt, Ident::new(sym::debug_struct, span), vec![name]); stmts.push(cx.stmt_let(DUMMY_SP, true, builder, expr)); for field in fields { @@ -108,20 +104,20 @@ fn show_substructure(cx: &mut ExtCtxt<'_>, span: Span, substr: &Substructure<'_> ); // Use double indirection to make sure this works for unsized types - let fn_path_field = cx.std_path(&[sym::fmt, sym::DebugStruct, sym::field]); let field = cx.expr_addr_of(field.span, field.self_.clone()); let field = cx.expr_addr_of(field.span, field); - let builder_recv = make_mut_borrow(cx, span, builder_expr.clone()); - let expr = - cx.expr_call_global(span, fn_path_field, vec![builder_recv, name, field]); + let expr = cx.expr_method_call( + span, + builder_expr.clone(), + Ident::new(sym::field, span), + vec![name, field], + ); stmts.push(stmt_let_underscore(cx, span, expr)); } - fn_path_finish = cx.std_path(&[sym::fmt, sym::DebugStruct, sym::finish]); } } - let builder_recv = make_mut_borrow(cx, span, builder_expr); - let expr = cx.expr_call_global(span, fn_path_finish, vec![builder_recv]); + let expr = cx.expr_method_call(span, builder_expr, Ident::new(sym::finish, span), vec![]); stmts.push(cx.stmt_expr(expr)); let block = cx.block(span, stmts); diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs index d498c8e172799..e78d1368b357e 100644 --- a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs +++ b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs @@ -527,12 +527,12 @@ impl<'a> TraitDef<'a> { tokens: None, }, attrs: Vec::new(), - kind: ast::AssocItemKind::TyAlias(box ast::TyAliasKind( + kind: ast::AssocItemKind::TyAlias( ast::Defaultness::Final, Generics::default(), Vec::new(), Some(type_def.to_ty(cx, self.span, type_ident, generics)), - )), + ), tokens: None, }) }); @@ -598,7 +598,7 @@ impl<'a> TraitDef<'a> { let mut ty_params = params .iter() - .filter(|param| matches!(param.kind, ast::GenericParamKind::Type { .. })) + .filter(|param| matches!(param.kind, ast::GenericParamKind::Type{..})) .peekable(); if ty_params.peek().is_some() { @@ -687,7 +687,7 @@ impl<'a> TraitDef<'a> { self.span, Ident::invalid(), a, - ast::ItemKind::Impl(box ast::ImplKind { + ast::ItemKind::Impl { unsafety, polarity: ast::ImplPolarity::Positive, defaultness: ast::Defaultness::Final, @@ -696,7 +696,7 @@ impl<'a> TraitDef<'a> { of_trait: opt_trait_ref, self_ty: self_type, items: methods.into_iter().chain(associated_types).collect(), - }), + }, ) } @@ -929,7 +929,7 @@ impl<'a> MethodDef<'a> { tokens: None, }, ident: method_ident, - kind: ast::AssocItemKind::Fn(box ast::FnKind(def, sig, fn_generics, Some(body_block))), + kind: ast::AssocItemKind::Fn(def, sig, fn_generics, Some(body_block)), tokens: None, }) } diff --git a/compiler/rustc_builtin_macros/src/deriving/mod.rs b/compiler/rustc_builtin_macros/src/deriving/mod.rs index 7dea6099f8f1b..3c8bf12b3d415 100644 --- a/compiler/rustc_builtin_macros/src/deriving/mod.rs +++ b/compiler/rustc_builtin_macros/src/deriving/mod.rs @@ -2,7 +2,7 @@ use rustc_ast as ast; use rustc_ast::ptr::P; -use rustc_ast::{ImplKind, ItemKind, MetaItem}; +use rustc_ast::{ItemKind, MetaItem}; use rustc_expand::base::{Annotatable, ExpandResult, ExtCtxt, MultiItemModifier}; use rustc_span::symbol::{sym, Ident, Symbol}; use rustc_span::Span; @@ -179,7 +179,7 @@ fn inject_impl_of_structural_trait( span, Ident::invalid(), attrs, - ItemKind::Impl(box ImplKind { + ItemKind::Impl { unsafety: ast::Unsafe::No, polarity: ast::ImplPolarity::Positive, defaultness: ast::Defaultness::Final, @@ -188,7 +188,7 @@ fn inject_impl_of_structural_trait( of_trait: Some(trait_ref), self_ty: self_type, items: Vec::new(), - }), + }, ); push(Annotatable::Item(newitem)); diff --git a/compiler/rustc_builtin_macros/src/global_allocator.rs b/compiler/rustc_builtin_macros/src/global_allocator.rs index 9b43c11f0f3d3..e976805d9dd20 100644 --- a/compiler/rustc_builtin_macros/src/global_allocator.rs +++ b/compiler/rustc_builtin_macros/src/global_allocator.rs @@ -5,7 +5,7 @@ use rustc_ast::expand::allocator::{ }; use rustc_ast::ptr::P; use rustc_ast::{self as ast, Attribute, Expr, FnHeader, FnSig, Generics, Param, StmtKind}; -use rustc_ast::{FnKind, ItemKind, Mutability, Stmt, Ty, TyKind, Unsafe}; +use rustc_ast::{ItemKind, Mutability, Stmt, Ty, TyKind, Unsafe}; use rustc_expand::base::{Annotatable, ExtCtxt}; use rustc_span::symbol::{kw, sym, Ident, Symbol}; use rustc_span::Span; @@ -85,8 +85,7 @@ impl AllocFnFactory<'_, '_> { let header = FnHeader { unsafety: Unsafe::Yes(self.span), ..FnHeader::default() }; let sig = FnSig { decl, header, span: self.span }; let block = Some(self.cx.block_expr(output_expr)); - let kind = - ItemKind::Fn(box FnKind(ast::Defaultness::Final, sig, Generics::default(), block)); + let kind = ItemKind::Fn(ast::Defaultness::Final, sig, Generics::default(), block); let item = self.cx.item( self.span, Ident::from_str_and_span(&self.kind.fn_name(method.name), self.span), diff --git a/compiler/rustc_builtin_macros/src/lib.rs b/compiler/rustc_builtin_macros/src/lib.rs index 9a3c914337ca2..bcb3622a95980 100644 --- a/compiler/rustc_builtin_macros/src/lib.rs +++ b/compiler/rustc_builtin_macros/src/lib.rs @@ -2,8 +2,6 @@ //! injecting code into the crate before it is lowered to HIR. #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] -#![feature(box_patterns)] -#![feature(box_syntax)] #![feature(bool_to_option)] #![feature(crate_visibility_modifier)] #![feature(decl_macro)] @@ -27,7 +25,6 @@ mod cfg_accessible; mod compile_error; mod concat; mod concat_idents; -mod derive; mod deriving; mod env; mod format; @@ -89,7 +86,6 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) { register_attr! { bench: test::expand_bench, cfg_accessible: cfg_accessible::Expander, - derive: derive::Expander, global_allocator: global_allocator::expand, test: test::expand_test, test_case: test::expand_test_case, diff --git a/compiler/rustc_builtin_macros/src/test.rs b/compiler/rustc_builtin_macros/src/test.rs index e845f9ec55ad5..25d3f46da6cdc 100644 --- a/compiler/rustc_builtin_macros/src/test.rs +++ b/compiler/rustc_builtin_macros/src/test.rs @@ -425,7 +425,7 @@ fn test_type(cx: &ExtCtxt<'_>) -> TestType { fn has_test_signature(cx: &ExtCtxt<'_>, i: &ast::Item) -> bool { let has_should_panic_attr = cx.sess.contains_name(&i.attrs, sym::should_panic); let sd = &cx.sess.parse_sess.span_diagnostic; - if let ast::ItemKind::Fn(box ast::FnKind(_, ref sig, ref generics, _)) = i.kind { + if let ast::ItemKind::Fn(_, ref sig, ref generics, _) = i.kind { if let ast::Unsafe::Yes(span) = sig.header.unsafety { sd.struct_span_err(i.span, "unsafe functions cannot be used for tests") .span_label(span, "`unsafe` because of this") @@ -474,7 +474,7 @@ fn has_test_signature(cx: &ExtCtxt<'_>, i: &ast::Item) -> bool { } fn has_bench_signature(cx: &ExtCtxt<'_>, i: &ast::Item) -> bool { - let has_sig = if let ast::ItemKind::Fn(box ast::FnKind(_, ref sig, _, _)) = i.kind { + let has_sig = if let ast::ItemKind::Fn(_, ref sig, _, _) = i.kind { // N.B., inadequate check, but we're running // well before resolve, can't get too deep. sig.decl.inputs.len() == 1 diff --git a/compiler/rustc_builtin_macros/src/test_harness.rs b/compiler/rustc_builtin_macros/src/test_harness.rs index 4ac22be3c275d..9976140d6bd8c 100644 --- a/compiler/rustc_builtin_macros/src/test_harness.rs +++ b/compiler/rustc_builtin_macros/src/test_harness.rs @@ -311,8 +311,7 @@ fn mk_main(cx: &mut TestCtxt<'_>) -> P { let decl = ecx.fn_decl(vec![], ast::FnRetTy::Ty(main_ret_ty)); let sig = ast::FnSig { decl, header: ast::FnHeader::default(), span: sp }; let def = ast::Defaultness::Final; - let main = - ast::ItemKind::Fn(box ast::FnKind(def, sig, ast::Generics::default(), Some(main_body))); + let main = ast::ItemKind::Fn(def, sig, ast::Generics::default(), Some(main_body)); // Honor the reexport_test_harness_main attribute let main_id = match cx.reexport_test_harness_main { diff --git a/compiler/rustc_codegen_cranelift/src/abi/mod.rs b/compiler/rustc_codegen_cranelift/src/abi/mod.rs index b2647e6c8d384..6a025f2e88ae3 100644 --- a/compiler/rustc_codegen_cranelift/src/abi/mod.rs +++ b/compiler/rustc_codegen_cranelift/src/abi/mod.rs @@ -28,7 +28,6 @@ fn clif_sig_from_fn_abi<'tcx>( Conv::X86_64SysV => CallConv::SystemV, Conv::X86_64Win64 => CallConv::WindowsFastcall, Conv::ArmAapcs - | Conv::CCmseNonSecureCall | Conv::Msp430Intr | Conv::PtxKernel | Conv::X86Fastcall diff --git a/compiler/rustc_codegen_llvm/src/abi.rs b/compiler/rustc_codegen_llvm/src/abi.rs index a69241e456f16..915dd3d9eda15 100644 --- a/compiler/rustc_codegen_llvm/src/abi.rs +++ b/compiler/rustc_codegen_llvm/src/abi.rs @@ -389,7 +389,7 @@ impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> { fn llvm_cconv(&self) -> llvm::CallConv { match self.conv { - Conv::C | Conv::Rust | Conv::CCmseNonSecureCall => llvm::CCallConv, + Conv::C | Conv::Rust => llvm::CCallConv, Conv::AmdGpuKernel => llvm::AmdGpuKernel, Conv::AvrInterrupt => llvm::AvrInterrupt, Conv::AvrNonBlockingInterrupt => llvm::AvrNonBlockingInterrupt, @@ -546,18 +546,6 @@ impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> { if cconv != llvm::CCallConv { llvm::SetInstructionCallConv(callsite, cconv); } - - if self.conv == Conv::CCmseNonSecureCall { - // This will probably get ignored on all targets but those supporting the TrustZone-M - // extension (thumbv8m targets). - unsafe { - llvm::AddCallSiteAttrString( - callsite, - llvm::AttributePlace::Function, - rustc_data_structures::const_cstr!("cmse_nonsecure_call"), - ); - } - } } } diff --git a/compiler/rustc_codegen_llvm/src/consts.rs b/compiler/rustc_codegen_llvm/src/consts.rs index 16e1a8a1242ae..14dd245625d25 100644 --- a/compiler/rustc_codegen_llvm/src/consts.rs +++ b/compiler/rustc_codegen_llvm/src/consts.rs @@ -8,7 +8,9 @@ use crate::value::Value; use libc::c_uint; use rustc_codegen_ssa::traits::*; use rustc_data_structures::const_cstr; +use rustc_hir as hir; use rustc_hir::def_id::DefId; +use rustc_hir::Node; use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs}; use rustc_middle::mir::interpret::{ read_target_uint, Allocation, ErrorHandled, GlobalAlloc, Pointer, @@ -16,6 +18,7 @@ use rustc_middle::mir::interpret::{ use rustc_middle::mir::mono::MonoItem; use rustc_middle::ty::{self, Instance, Ty}; use rustc_middle::{bug, span_bug}; +use rustc_span::symbol::sym; use rustc_target::abi::{AddressSpace, Align, HasDataLayout, LayoutOf, Primitive, Scalar, Size}; use tracing::debug; @@ -206,42 +209,70 @@ impl CodegenCx<'ll, 'tcx> { let ty = instance.ty(self.tcx, ty::ParamEnv::reveal_all()); let sym = self.tcx.symbol_name(instance).name; - let fn_attrs = self.tcx.codegen_fn_attrs(def_id); - debug!("get_static: sym={} instance={:?} fn_attrs={:?}", sym, instance, fn_attrs); + debug!("get_static: sym={} instance={:?}", sym, instance); - let g = if def_id.is_local() && !self.tcx.is_foreign_item(def_id) { + let g = if let Some(local_def_id) = def_id.as_local() { + let id = self.tcx.hir().local_def_id_to_hir_id(local_def_id); let llty = self.layout_of(ty).llvm_type(self); - if let Some(g) = self.get_declared_value(sym) { - if self.val_ty(g) != self.type_ptr_to(llty) { - span_bug!(self.tcx.def_span(def_id), "Conflicting types for static"); + // FIXME: refactor this to work without accessing the HIR + let (g, attrs) = match self.tcx.hir().get(id) { + Node::Item(&hir::Item { attrs, kind: hir::ItemKind::Static(..), .. }) => { + if let Some(g) = self.get_declared_value(sym) { + if self.val_ty(g) != self.type_ptr_to(llty) { + span_bug!(self.tcx.def_span(def_id), "Conflicting types for static"); + } + } + + let g = self.declare_global(sym, llty); + + if !self.tcx.is_reachable_non_generic(local_def_id) { + unsafe { + llvm::LLVMRustSetVisibility(g, llvm::Visibility::Hidden); + } + } + + (g, attrs) } - } - let g = self.declare_global(sym, llty); + Node::ForeignItem(&hir::ForeignItem { + ref attrs, + kind: hir::ForeignItemKind::Static(..), + .. + }) => { + let fn_attrs = self.tcx.codegen_fn_attrs(local_def_id); + (check_and_apply_linkage(&self, &fn_attrs, ty, sym, def_id), &**attrs) + } + + item => bug!("get_static: expected static, found {:?}", item), + }; + + debug!("get_static: sym={} attrs={:?}", sym, attrs); - if !self.tcx.is_reachable_non_generic(def_id) { - unsafe { - llvm::LLVMRustSetVisibility(g, llvm::Visibility::Hidden); + for attr in attrs { + if self.tcx.sess.check_name(attr, sym::thread_local) { + llvm::set_thread_local_mode(g, self.tls_model); } } g } else { - check_and_apply_linkage(&self, &fn_attrs, ty, sym, def_id) - }; + // FIXME(nagisa): perhaps the map of externs could be offloaded to llvm somehow? + debug!("get_static: sym={} item_attr={:?}", sym, self.tcx.item_attrs(def_id)); - // Thread-local statics in some other crate need to *always* be linked - // against in a thread-local fashion, so we need to be sure to apply the - // thread-local attribute locally if it was present remotely. If we - // don't do this then linker errors can be generated where the linker - // complains that one object files has a thread local version of the - // symbol and another one doesn't. - if fn_attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL) { - llvm::set_thread_local_mode(g, self.tls_model); - } + let attrs = self.tcx.codegen_fn_attrs(def_id); + let g = check_and_apply_linkage(&self, &attrs, ty, sym, def_id); + + // Thread-local statics in some other crate need to *always* be linked + // against in a thread-local fashion, so we need to be sure to apply the + // thread-local attribute locally if it was present remotely. If we + // don't do this then linker errors can be generated where the linker + // complains that one object files has a thread local version of the + // symbol and another one doesn't. + if attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL) { + llvm::set_thread_local_mode(g, self.tls_model); + } - if !def_id.is_local() { let needs_dll_storage_attr = self.use_dll_storage_attrs && !self.tcx.is_foreign_item(def_id) && // ThinLTO can't handle this workaround in all cases, so we don't // emit the attrs. Instead we make them unnecessary by disallowing @@ -273,7 +304,8 @@ impl CodegenCx<'ll, 'tcx> { } } } - } + g + }; if self.use_dll_storage_attrs && self.tcx.is_dllimport_foreign_item(def_id) { // For foreign (native) libs we know the exact storage type to use. diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index ee099f93258b7..6acd26bd415dc 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -380,7 +380,7 @@ impl MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> { "rust_eh_personality" }; let fty = self.type_variadic_func(&[], self.type_i32()); - self.declare_cfn(name, llvm::UnnamedAddr::Global, fty) + self.declare_cfn(name, fty) } }; attributes::apply_target_cpu_attr(self, llfn); @@ -429,7 +429,7 @@ impl MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> { fn declare_c_main(&self, fn_type: Self::Type) -> Option { if self.get_declared_value("main").is_none() { - Some(self.declare_cfn("main", llvm::UnnamedAddr::Global, fn_type)) + Some(self.declare_cfn("main", fn_type)) } else { // If the symbol already exists, it is an error: for example, the user wrote // #[no_mangle] extern "C" fn main(..) {..} @@ -459,7 +459,8 @@ impl CodegenCx<'b, 'tcx> { } else { self.type_variadic_func(&[], ret) }; - let f = self.declare_cfn(name, llvm::UnnamedAddr::No, fn_ty); + let f = self.declare_cfn(name, fn_ty); + llvm::SetUnnamedAddress(f, llvm::UnnamedAddr::No); self.intrinsics.borrow_mut().insert(name, f); f } @@ -497,6 +498,25 @@ impl CodegenCx<'b, 'tcx> { let t_f32 = self.type_f32(); let t_f64 = self.type_f64(); + macro_rules! vector_types { + ($id_out:ident: $elem_ty:ident, $len:expr) => { + let $id_out = self.type_vector($elem_ty, $len); + }; + ($($id_out:ident: $elem_ty:ident, $len:expr;)*) => { + $(vector_types!($id_out: $elem_ty, $len);)* + } + } + vector_types! { + t_v2f32: t_f32, 2; + t_v4f32: t_f32, 4; + t_v8f32: t_f32, 8; + t_v16f32: t_f32, 16; + + t_v2f64: t_f64, 2; + t_v4f64: t_f64, 4; + t_v8f64: t_f64, 8; + } + ifn!("llvm.wasm.trunc.saturate.unsigned.i32.f32", fn(t_f32) -> t_i32); ifn!("llvm.wasm.trunc.saturate.unsigned.i32.f64", fn(t_f64) -> t_i32); ifn!("llvm.wasm.trunc.saturate.unsigned.i64.f32", fn(t_f32) -> t_i64); @@ -520,40 +540,124 @@ impl CodegenCx<'b, 'tcx> { ifn!("llvm.sideeffect", fn() -> void); ifn!("llvm.powi.f32", fn(t_f32, t_i32) -> t_f32); + ifn!("llvm.powi.v2f32", fn(t_v2f32, t_i32) -> t_v2f32); + ifn!("llvm.powi.v4f32", fn(t_v4f32, t_i32) -> t_v4f32); + ifn!("llvm.powi.v8f32", fn(t_v8f32, t_i32) -> t_v8f32); + ifn!("llvm.powi.v16f32", fn(t_v16f32, t_i32) -> t_v16f32); ifn!("llvm.powi.f64", fn(t_f64, t_i32) -> t_f64); + ifn!("llvm.powi.v2f64", fn(t_v2f64, t_i32) -> t_v2f64); + ifn!("llvm.powi.v4f64", fn(t_v4f64, t_i32) -> t_v4f64); + ifn!("llvm.powi.v8f64", fn(t_v8f64, t_i32) -> t_v8f64); ifn!("llvm.pow.f32", fn(t_f32, t_f32) -> t_f32); + ifn!("llvm.pow.v2f32", fn(t_v2f32, t_v2f32) -> t_v2f32); + ifn!("llvm.pow.v4f32", fn(t_v4f32, t_v4f32) -> t_v4f32); + ifn!("llvm.pow.v8f32", fn(t_v8f32, t_v8f32) -> t_v8f32); + ifn!("llvm.pow.v16f32", fn(t_v16f32, t_v16f32) -> t_v16f32); ifn!("llvm.pow.f64", fn(t_f64, t_f64) -> t_f64); + ifn!("llvm.pow.v2f64", fn(t_v2f64, t_v2f64) -> t_v2f64); + ifn!("llvm.pow.v4f64", fn(t_v4f64, t_v4f64) -> t_v4f64); + ifn!("llvm.pow.v8f64", fn(t_v8f64, t_v8f64) -> t_v8f64); ifn!("llvm.sqrt.f32", fn(t_f32) -> t_f32); + ifn!("llvm.sqrt.v2f32", fn(t_v2f32) -> t_v2f32); + ifn!("llvm.sqrt.v4f32", fn(t_v4f32) -> t_v4f32); + ifn!("llvm.sqrt.v8f32", fn(t_v8f32) -> t_v8f32); + ifn!("llvm.sqrt.v16f32", fn(t_v16f32) -> t_v16f32); ifn!("llvm.sqrt.f64", fn(t_f64) -> t_f64); + ifn!("llvm.sqrt.v2f64", fn(t_v2f64) -> t_v2f64); + ifn!("llvm.sqrt.v4f64", fn(t_v4f64) -> t_v4f64); + ifn!("llvm.sqrt.v8f64", fn(t_v8f64) -> t_v8f64); ifn!("llvm.sin.f32", fn(t_f32) -> t_f32); + ifn!("llvm.sin.v2f32", fn(t_v2f32) -> t_v2f32); + ifn!("llvm.sin.v4f32", fn(t_v4f32) -> t_v4f32); + ifn!("llvm.sin.v8f32", fn(t_v8f32) -> t_v8f32); + ifn!("llvm.sin.v16f32", fn(t_v16f32) -> t_v16f32); ifn!("llvm.sin.f64", fn(t_f64) -> t_f64); + ifn!("llvm.sin.v2f64", fn(t_v2f64) -> t_v2f64); + ifn!("llvm.sin.v4f64", fn(t_v4f64) -> t_v4f64); + ifn!("llvm.sin.v8f64", fn(t_v8f64) -> t_v8f64); ifn!("llvm.cos.f32", fn(t_f32) -> t_f32); + ifn!("llvm.cos.v2f32", fn(t_v2f32) -> t_v2f32); + ifn!("llvm.cos.v4f32", fn(t_v4f32) -> t_v4f32); + ifn!("llvm.cos.v8f32", fn(t_v8f32) -> t_v8f32); + ifn!("llvm.cos.v16f32", fn(t_v16f32) -> t_v16f32); ifn!("llvm.cos.f64", fn(t_f64) -> t_f64); + ifn!("llvm.cos.v2f64", fn(t_v2f64) -> t_v2f64); + ifn!("llvm.cos.v4f64", fn(t_v4f64) -> t_v4f64); + ifn!("llvm.cos.v8f64", fn(t_v8f64) -> t_v8f64); ifn!("llvm.exp.f32", fn(t_f32) -> t_f32); + ifn!("llvm.exp.v2f32", fn(t_v2f32) -> t_v2f32); + ifn!("llvm.exp.v4f32", fn(t_v4f32) -> t_v4f32); + ifn!("llvm.exp.v8f32", fn(t_v8f32) -> t_v8f32); + ifn!("llvm.exp.v16f32", fn(t_v16f32) -> t_v16f32); ifn!("llvm.exp.f64", fn(t_f64) -> t_f64); + ifn!("llvm.exp.v2f64", fn(t_v2f64) -> t_v2f64); + ifn!("llvm.exp.v4f64", fn(t_v4f64) -> t_v4f64); + ifn!("llvm.exp.v8f64", fn(t_v8f64) -> t_v8f64); ifn!("llvm.exp2.f32", fn(t_f32) -> t_f32); + ifn!("llvm.exp2.v2f32", fn(t_v2f32) -> t_v2f32); + ifn!("llvm.exp2.v4f32", fn(t_v4f32) -> t_v4f32); + ifn!("llvm.exp2.v8f32", fn(t_v8f32) -> t_v8f32); + ifn!("llvm.exp2.v16f32", fn(t_v16f32) -> t_v16f32); ifn!("llvm.exp2.f64", fn(t_f64) -> t_f64); + ifn!("llvm.exp2.v2f64", fn(t_v2f64) -> t_v2f64); + ifn!("llvm.exp2.v4f64", fn(t_v4f64) -> t_v4f64); + ifn!("llvm.exp2.v8f64", fn(t_v8f64) -> t_v8f64); ifn!("llvm.log.f32", fn(t_f32) -> t_f32); + ifn!("llvm.log.v2f32", fn(t_v2f32) -> t_v2f32); + ifn!("llvm.log.v4f32", fn(t_v4f32) -> t_v4f32); + ifn!("llvm.log.v8f32", fn(t_v8f32) -> t_v8f32); + ifn!("llvm.log.v16f32", fn(t_v16f32) -> t_v16f32); ifn!("llvm.log.f64", fn(t_f64) -> t_f64); + ifn!("llvm.log.v2f64", fn(t_v2f64) -> t_v2f64); + ifn!("llvm.log.v4f64", fn(t_v4f64) -> t_v4f64); + ifn!("llvm.log.v8f64", fn(t_v8f64) -> t_v8f64); ifn!("llvm.log10.f32", fn(t_f32) -> t_f32); + ifn!("llvm.log10.v2f32", fn(t_v2f32) -> t_v2f32); + ifn!("llvm.log10.v4f32", fn(t_v4f32) -> t_v4f32); + ifn!("llvm.log10.v8f32", fn(t_v8f32) -> t_v8f32); + ifn!("llvm.log10.v16f32", fn(t_v16f32) -> t_v16f32); ifn!("llvm.log10.f64", fn(t_f64) -> t_f64); + ifn!("llvm.log10.v2f64", fn(t_v2f64) -> t_v2f64); + ifn!("llvm.log10.v4f64", fn(t_v4f64) -> t_v4f64); + ifn!("llvm.log10.v8f64", fn(t_v8f64) -> t_v8f64); ifn!("llvm.log2.f32", fn(t_f32) -> t_f32); + ifn!("llvm.log2.v2f32", fn(t_v2f32) -> t_v2f32); + ifn!("llvm.log2.v4f32", fn(t_v4f32) -> t_v4f32); + ifn!("llvm.log2.v8f32", fn(t_v8f32) -> t_v8f32); + ifn!("llvm.log2.v16f32", fn(t_v16f32) -> t_v16f32); ifn!("llvm.log2.f64", fn(t_f64) -> t_f64); + ifn!("llvm.log2.v2f64", fn(t_v2f64) -> t_v2f64); + ifn!("llvm.log2.v4f64", fn(t_v4f64) -> t_v4f64); + ifn!("llvm.log2.v8f64", fn(t_v8f64) -> t_v8f64); ifn!("llvm.fma.f32", fn(t_f32, t_f32, t_f32) -> t_f32); + ifn!("llvm.fma.v2f32", fn(t_v2f32, t_v2f32, t_v2f32) -> t_v2f32); + ifn!("llvm.fma.v4f32", fn(t_v4f32, t_v4f32, t_v4f32) -> t_v4f32); + ifn!("llvm.fma.v8f32", fn(t_v8f32, t_v8f32, t_v8f32) -> t_v8f32); + ifn!("llvm.fma.v16f32", fn(t_v16f32, t_v16f32, t_v16f32) -> t_v16f32); ifn!("llvm.fma.f64", fn(t_f64, t_f64, t_f64) -> t_f64); + ifn!("llvm.fma.v2f64", fn(t_v2f64, t_v2f64, t_v2f64) -> t_v2f64); + ifn!("llvm.fma.v4f64", fn(t_v4f64, t_v4f64, t_v4f64) -> t_v4f64); + ifn!("llvm.fma.v8f64", fn(t_v8f64, t_v8f64, t_v8f64) -> t_v8f64); ifn!("llvm.fabs.f32", fn(t_f32) -> t_f32); + ifn!("llvm.fabs.v2f32", fn(t_v2f32) -> t_v2f32); + ifn!("llvm.fabs.v4f32", fn(t_v4f32) -> t_v4f32); + ifn!("llvm.fabs.v8f32", fn(t_v8f32) -> t_v8f32); + ifn!("llvm.fabs.v16f32", fn(t_v16f32) -> t_v16f32); ifn!("llvm.fabs.f64", fn(t_f64) -> t_f64); + ifn!("llvm.fabs.v2f64", fn(t_v2f64) -> t_v2f64); + ifn!("llvm.fabs.v4f64", fn(t_v4f64) -> t_v4f64); + ifn!("llvm.fabs.v8f64", fn(t_v8f64) -> t_v8f64); ifn!("llvm.minnum.f32", fn(t_f32, t_f32) -> t_f32); ifn!("llvm.minnum.f64", fn(t_f64, t_f64) -> t_f64); @@ -561,10 +665,24 @@ impl CodegenCx<'b, 'tcx> { ifn!("llvm.maxnum.f64", fn(t_f64, t_f64) -> t_f64); ifn!("llvm.floor.f32", fn(t_f32) -> t_f32); + ifn!("llvm.floor.v2f32", fn(t_v2f32) -> t_v2f32); + ifn!("llvm.floor.v4f32", fn(t_v4f32) -> t_v4f32); + ifn!("llvm.floor.v8f32", fn(t_v8f32) -> t_v8f32); + ifn!("llvm.floor.v16f32", fn(t_v16f32) -> t_v16f32); ifn!("llvm.floor.f64", fn(t_f64) -> t_f64); + ifn!("llvm.floor.v2f64", fn(t_v2f64) -> t_v2f64); + ifn!("llvm.floor.v4f64", fn(t_v4f64) -> t_v4f64); + ifn!("llvm.floor.v8f64", fn(t_v8f64) -> t_v8f64); ifn!("llvm.ceil.f32", fn(t_f32) -> t_f32); + ifn!("llvm.ceil.v2f32", fn(t_v2f32) -> t_v2f32); + ifn!("llvm.ceil.v4f32", fn(t_v4f32) -> t_v4f32); + ifn!("llvm.ceil.v8f32", fn(t_v8f32) -> t_v8f32); + ifn!("llvm.ceil.v16f32", fn(t_v16f32) -> t_v16f32); ifn!("llvm.ceil.f64", fn(t_f64) -> t_f64); + ifn!("llvm.ceil.v2f64", fn(t_v2f64) -> t_v2f64); + ifn!("llvm.ceil.v4f64", fn(t_v4f64) -> t_v4f64); + ifn!("llvm.ceil.v8f64", fn(t_v8f64) -> t_v8f64); ifn!("llvm.trunc.f32", fn(t_f32) -> t_f32); ifn!("llvm.trunc.f64", fn(t_f64) -> t_f64); diff --git a/compiler/rustc_codegen_llvm/src/declare.rs b/compiler/rustc_codegen_llvm/src/declare.rs index 8977fa085b9bb..0591e0a5c1279 100644 --- a/compiler/rustc_codegen_llvm/src/declare.rs +++ b/compiler/rustc_codegen_llvm/src/declare.rs @@ -30,7 +30,6 @@ fn declare_raw_fn( cx: &CodegenCx<'ll, '_>, name: &str, callconv: llvm::CallConv, - unnamed: llvm::UnnamedAddr, ty: &'ll Type, ) -> &'ll Value { debug!("declare_raw_fn(name={:?}, ty={:?})", name, ty); @@ -39,7 +38,9 @@ fn declare_raw_fn( }; llvm::SetFunctionCallConv(llfn, callconv); - llvm::SetUnnamedAddress(llfn, unnamed); + // Function addresses in Rust are never significant, allowing functions to + // be merged. + llvm::SetUnnamedAddress(llfn, llvm::UnnamedAddr::Global); if cx.tcx.sess.opts.cg.no_redzone.unwrap_or(cx.tcx.sess.target.disable_redzone) { llvm::Attribute::NoRedZone.apply_llfn(Function, llfn); @@ -67,13 +68,8 @@ impl CodegenCx<'ll, 'tcx> { /// /// If there’s a value with the same name already declared, the function will /// update the declaration and return existing Value instead. - pub fn declare_cfn( - &self, - name: &str, - unnamed: llvm::UnnamedAddr, - fn_type: &'ll Type, - ) -> &'ll Value { - declare_raw_fn(self, name, llvm::CCallConv, unnamed, fn_type) + pub fn declare_cfn(&self, name: &str, fn_type: &'ll Type) -> &'ll Value { + declare_raw_fn(self, name, llvm::CCallConv, fn_type) } /// Declare a Rust function. @@ -83,15 +79,7 @@ impl CodegenCx<'ll, 'tcx> { pub fn declare_fn(&self, name: &str, fn_abi: &FnAbi<'tcx, Ty<'tcx>>) -> &'ll Value { debug!("declare_rust_fn(name={:?}, fn_abi={:?})", name, fn_abi); - // Function addresses in Rust are never significant, allowing functions to - // be merged. - let llfn = declare_raw_fn( - self, - name, - fn_abi.llvm_cconv(), - llvm::UnnamedAddr::Global, - fn_abi.llvm_type(self), - ); + let llfn = declare_raw_fn(self, name, fn_abi.llvm_cconv(), fn_abi.llvm_type(self)); fn_abi.apply_attrs_llfn(self, llfn); llfn } diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs index 668daa52ed262..bf0d499e6c491 100644 --- a/compiler/rustc_codegen_llvm/src/intrinsic.rs +++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs @@ -1009,7 +1009,7 @@ fn generic_simd_intrinsic( } fn simd_simple_float_intrinsic( - name: Symbol, + name: &str, in_elem: &::rustc_middle::ty::TyS<'_>, in_ty: &::rustc_middle::ty::TyS<'_>, in_len: u64, @@ -1036,69 +1036,93 @@ fn generic_simd_intrinsic( } } } - - let (elem_ty_str, elem_ty) = if let ty::Float(f) = in_elem.kind() { - let elem_ty = bx.cx.type_float_from_ty(*f); - match f.bit_width() { - 32 => ("f32", elem_ty), - 64 => ("f64", elem_ty), - _ => { + let ety = match in_elem.kind() { + ty::Float(f) if f.bit_width() == 32 => { + if in_len < 2 || in_len > 16 { return_error!( - "unsupported element type `{}` of floating-point vector `{}`", - f.name_str(), - in_ty + "unsupported floating-point vector `{}` with length `{}` \ + out-of-range [2, 16]", + in_ty, + in_len ); } + "f32" + } + ty::Float(f) if f.bit_width() == 64 => { + if in_len < 2 || in_len > 8 { + return_error!( + "unsupported floating-point vector `{}` with length `{}` \ + out-of-range [2, 8]", + in_ty, + in_len + ); + } + "f64" + } + ty::Float(f) => { + return_error!( + "unsupported element type `{}` of floating-point vector `{}`", + f.name_str(), + in_ty + ); + } + _ => { + return_error!("`{}` is not a floating-point type", in_ty); } - } else { - return_error!("`{}` is not a floating-point type", in_ty); - }; - - let vec_ty = bx.type_vector(elem_ty, in_len); - - let (intr_name, fn_ty) = match name { - sym::simd_fsqrt => ("sqrt", bx.type_func(&[vec_ty], vec_ty)), - sym::simd_fsin => ("sin", bx.type_func(&[vec_ty], vec_ty)), - sym::simd_fcos => ("cos", bx.type_func(&[vec_ty], vec_ty)), - sym::simd_fabs => ("fabs", bx.type_func(&[vec_ty], vec_ty)), - sym::simd_floor => ("floor", bx.type_func(&[vec_ty], vec_ty)), - sym::simd_ceil => ("ceil", bx.type_func(&[vec_ty], vec_ty)), - sym::simd_fexp => ("exp", bx.type_func(&[vec_ty], vec_ty)), - sym::simd_fexp2 => ("exp2", bx.type_func(&[vec_ty], vec_ty)), - sym::simd_flog10 => ("log10", bx.type_func(&[vec_ty], vec_ty)), - sym::simd_flog2 => ("log2", bx.type_func(&[vec_ty], vec_ty)), - sym::simd_flog => ("log", bx.type_func(&[vec_ty], vec_ty)), - sym::simd_fpowi => ("powi", bx.type_func(&[vec_ty, bx.type_i32()], vec_ty)), - sym::simd_fpow => ("pow", bx.type_func(&[vec_ty, vec_ty], vec_ty)), - sym::simd_fma => ("fma", bx.type_func(&[vec_ty, vec_ty, vec_ty], vec_ty)), - _ => return_error!("unrecognized intrinsic `{}`", name), }; - let llvm_name = &format!("llvm.{0}.v{1}{2}", intr_name, in_len, elem_ty_str); - let f = bx.declare_cfn(&llvm_name, llvm::UnnamedAddr::No, fn_ty); - let c = bx.call(f, &args.iter().map(|arg| arg.immediate()).collect::>(), None); + let llvm_name = &format!("llvm.{0}.v{1}{2}", name, in_len, ety); + let intrinsic = bx.get_intrinsic(&llvm_name); + let c = + bx.call(intrinsic, &args.iter().map(|arg| arg.immediate()).collect::>(), None); unsafe { llvm::LLVMRustSetHasUnsafeAlgebra(c) }; Ok(c) } - if std::matches!( - name, - sym::simd_fsqrt - | sym::simd_fsin - | sym::simd_fcos - | sym::simd_fabs - | sym::simd_floor - | sym::simd_ceil - | sym::simd_fexp - | sym::simd_fexp2 - | sym::simd_flog10 - | sym::simd_flog2 - | sym::simd_flog - | sym::simd_fpowi - | sym::simd_fpow - | sym::simd_fma - ) { - return simd_simple_float_intrinsic(name, in_elem, in_ty, in_len, bx, span, args); + match name { + sym::simd_fsqrt => { + return simd_simple_float_intrinsic("sqrt", in_elem, in_ty, in_len, bx, span, args); + } + sym::simd_fsin => { + return simd_simple_float_intrinsic("sin", in_elem, in_ty, in_len, bx, span, args); + } + sym::simd_fcos => { + return simd_simple_float_intrinsic("cos", in_elem, in_ty, in_len, bx, span, args); + } + sym::simd_fabs => { + return simd_simple_float_intrinsic("fabs", in_elem, in_ty, in_len, bx, span, args); + } + sym::simd_floor => { + return simd_simple_float_intrinsic("floor", in_elem, in_ty, in_len, bx, span, args); + } + sym::simd_ceil => { + return simd_simple_float_intrinsic("ceil", in_elem, in_ty, in_len, bx, span, args); + } + sym::simd_fexp => { + return simd_simple_float_intrinsic("exp", in_elem, in_ty, in_len, bx, span, args); + } + sym::simd_fexp2 => { + return simd_simple_float_intrinsic("exp2", in_elem, in_ty, in_len, bx, span, args); + } + sym::simd_flog10 => { + return simd_simple_float_intrinsic("log10", in_elem, in_ty, in_len, bx, span, args); + } + sym::simd_flog2 => { + return simd_simple_float_intrinsic("log2", in_elem, in_ty, in_len, bx, span, args); + } + sym::simd_flog => { + return simd_simple_float_intrinsic("log", in_elem, in_ty, in_len, bx, span, args); + } + sym::simd_fpowi => { + return simd_simple_float_intrinsic("powi", in_elem, in_ty, in_len, bx, span, args); + } + sym::simd_fpow => { + return simd_simple_float_intrinsic("pow", in_elem, in_ty, in_len, bx, span, args); + } + sym::simd_fma => { + return simd_simple_float_intrinsic("fma", in_elem, in_ty, in_len, bx, span, args); + } + _ => { /* fallthrough */ } } // FIXME: use: @@ -1254,12 +1278,12 @@ fn generic_simd_intrinsic( format!("llvm.masked.gather.{}.{}", llvm_elem_vec_str, llvm_pointer_vec_str); let f = bx.declare_cfn( &llvm_intrinsic, - llvm::UnnamedAddr::No, bx.type_func( &[llvm_pointer_vec_ty, alignment_ty, mask_ty, llvm_elem_vec_ty], llvm_elem_vec_ty, ), ); + llvm::SetUnnamedAddress(f, llvm::UnnamedAddr::No); let v = bx.call(f, &[args[1].immediate(), alignment, mask, args[0].immediate()], None); return Ok(v); } @@ -1384,9 +1408,9 @@ fn generic_simd_intrinsic( format!("llvm.masked.scatter.{}.{}", llvm_elem_vec_str, llvm_pointer_vec_str); let f = bx.declare_cfn( &llvm_intrinsic, - llvm::UnnamedAddr::No, bx.type_func(&[llvm_elem_vec_ty, llvm_pointer_vec_ty, alignment_ty, mask_ty], ret_t), ); + llvm::SetUnnamedAddress(f, llvm::UnnamedAddr::No); let v = bx.call(f, &[args[0].immediate(), args[1].immediate(), alignment, mask], None); return Ok(v); } @@ -1690,11 +1714,8 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#, ); let vec_ty = bx.cx.type_vector(elem_ty, in_len as u64); - let f = bx.declare_cfn( - &llvm_intrinsic, - llvm::UnnamedAddr::No, - bx.type_func(&[vec_ty, vec_ty], vec_ty), - ); + let f = bx.declare_cfn(&llvm_intrinsic, bx.type_func(&[vec_ty, vec_ty], vec_ty)); + llvm::SetUnnamedAddress(f, llvm::UnnamedAddr::No); let v = bx.call(f, &[lhs, rhs], None); return Ok(v); } diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index e82198f8f0c06..d9f42efebab47 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -1100,7 +1100,6 @@ extern "C" { // Operations on call sites pub fn LLVMSetInstructionCallConv(Instr: &Value, CC: c_uint); pub fn LLVMRustAddCallSiteAttribute(Instr: &Value, index: c_uint, attr: Attribute); - pub fn LLVMRustAddCallSiteAttrString(Instr: &Value, index: c_uint, Name: *const c_char); pub fn LLVMRustAddAlignmentCallSiteAttr(Instr: &Value, index: c_uint, bytes: u32); pub fn LLVMRustAddDereferenceableCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64); pub fn LLVMRustAddDereferenceableOrNullCallSiteAttr(Instr: &Value, index: c_uint, bytes: u64); diff --git a/compiler/rustc_codegen_llvm/src/llvm/mod.rs b/compiler/rustc_codegen_llvm/src/llvm/mod.rs index bb9c6d47373ba..fc40065a9664e 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/mod.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/mod.rs @@ -43,10 +43,6 @@ pub fn AddFunctionAttrString(llfn: &'a Value, idx: AttributePlace, attr: &CStr) } } -pub fn AddCallSiteAttrString(callsite: &Value, idx: AttributePlace, attr: &CStr) { - unsafe { LLVMRustAddCallSiteAttrString(callsite, idx.as_uint(), attr.as_ptr()) } -} - #[derive(Copy, Clone)] pub enum AttributePlace { ReturnValue, diff --git a/compiler/rustc_codegen_llvm/src/va_arg.rs b/compiler/rustc_codegen_llvm/src/va_arg.rs index 39d08fbee3b7f..07fde27b5a314 100644 --- a/compiler/rustc_codegen_llvm/src/va_arg.rs +++ b/compiler/rustc_codegen_llvm/src/va_arg.rs @@ -105,6 +105,7 @@ fn emit_aapcs_va_arg( let mut end = bx.build_sibling_block("va_arg.end"); let zero = bx.const_i32(0); let offset_align = Align::from_bytes(4).unwrap(); + assert_eq!(bx.tcx().sess.target.endian, Endian::Little); let gr_type = target_ty.is_any_ptr() || target_ty.is_integral(); let (reg_off, reg_top_index, slot_size) = if gr_type { @@ -143,14 +144,9 @@ fn emit_aapcs_va_arg( let top = in_reg.load(top, bx.tcx().data_layout.pointer_align.abi); // reg_value = *(@top + reg_off_v); - let mut reg_addr = in_reg.gep(top, &[reg_off_v]); - if bx.tcx().sess.target.endian == Endian::Big && layout.size.bytes() != slot_size { - // On big-endian systems the value is right-aligned in its slot. - let offset = bx.const_i32((slot_size - layout.size.bytes()) as i32); - reg_addr = in_reg.gep(reg_addr, &[offset]); - } - let reg_addr = in_reg.bitcast(reg_addr, bx.cx.type_ptr_to(layout.llvm_type(bx))); - let reg_value = in_reg.load(reg_addr, layout.align.abi); + let top = in_reg.gep(top, &[reg_off_v]); + let top = in_reg.bitcast(top, bx.cx.type_ptr_to(layout.llvm_type(bx))); + let reg_value = in_reg.load(top, layout.align.abi); in_reg.br(&end.llbb()); // On Stack block diff --git a/compiler/rustc_codegen_ssa/Cargo.toml b/compiler/rustc_codegen_ssa/Cargo.toml index 835f906239953..e5df0f60941a8 100644 --- a/compiler/rustc_codegen_ssa/Cargo.toml +++ b/compiler/rustc_codegen_ssa/Cargo.toml @@ -10,7 +10,6 @@ test = false [dependencies] bitflags = "1.2.1" cc = "1.0.1" -itertools = "0.9" num_cpus = "1.0" memmap = "0.7" tracing = "0.1" diff --git a/compiler/rustc_codegen_ssa/src/base.rs b/compiler/rustc_codegen_ssa/src/base.rs index 658ad3c375d29..0fc11c286f899 100644 --- a/compiler/rustc_codegen_ssa/src/base.rs +++ b/compiler/rustc_codegen_ssa/src/base.rs @@ -32,11 +32,10 @@ use rustc_session::config::{self, EntryFnType}; use rustc_session::Session; use rustc_target::abi::{Align, LayoutOf, VariantIdx}; +use std::cmp; use std::ops::{Deref, DerefMut}; use std::time::{Duration, Instant}; -use itertools::Itertools; - pub fn bin_op_to_icmp_predicate(op: hir::BinOpKind, signed: bool) -> IntPredicate { match op { hir::BinOpKind::Eq => IntPredicate::IntEQ, @@ -547,23 +546,12 @@ pub fn codegen_crate( ongoing_codegen.submit_pre_codegened_module_to_llvm(tcx, metadata_module); } - // For better throughput during parallel processing by LLVM, we used to sort - // CGUs largest to smallest. This would lead to better thread utilization - // by, for example, preventing a large CGU from being processed last and - // having only one LLVM thread working while the rest remained idle. - // - // However, this strategy would lead to high memory usage, as it meant the - // LLVM-IR for all of the largest CGUs would be resident in memory at once. - // - // Instead, we can compromise by ordering CGUs such that the largest and - // smallest are first, second largest and smallest are next, etc. If there - // are large size variations, this can reduce memory usage significantly. - let codegen_units: Vec<_> = { - let mut sorted_cgus = codegen_units.iter().collect::>(); - sorted_cgus.sort_by_cached_key(|cgu| cgu.size_estimate()); - - let (first_half, second_half) = sorted_cgus.split_at(sorted_cgus.len() / 2); - second_half.iter().rev().interleave(first_half).copied().collect() + // We sort the codegen units by size. This way we can schedule work for LLVM + // a bit more efficiently. + let codegen_units = { + let mut codegen_units = codegen_units.iter().collect::>(); + codegen_units.sort_by_cached_key(|cgu| cmp::Reverse(cgu.size_estimate())); + codegen_units }; // The non-parallel compiler can only translate codegen units to LLVM IR diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs index 5880bbd3de44e..36d261fb737ce 100644 --- a/compiler/rustc_data_structures/src/lib.rs +++ b/compiler/rustc_data_structures/src/lib.rs @@ -13,7 +13,6 @@ #![feature(unboxed_closures)] #![feature(generator_trait)] #![feature(fn_traits)] -#![feature(int_bits_const)] #![feature(min_specialization)] #![feature(auto_traits)] #![feature(nll)] diff --git a/compiler/rustc_data_structures/src/profiling.rs b/compiler/rustc_data_structures/src/profiling.rs index f0b413c795e9c..9a85b9d02c995 100644 --- a/compiler/rustc_data_structures/src/profiling.rs +++ b/compiler/rustc_data_structures/src/profiling.rs @@ -590,21 +590,24 @@ pub fn print_time_passes_entry( end_rss: Option, ) { let rss_to_mb = |rss| (rss as f64 / 1_000_000.0).round() as usize; - let rss_change_to_mb = |rss| (rss as f64 / 1_000_000.0).round() as i128; let mem_string = match (start_rss, end_rss) { (Some(start_rss), Some(end_rss)) => { - let change_rss = end_rss as i128 - start_rss as i128; - - format!( - "; rss: {:>4}MB -> {:>4}MB ({:>+5}MB)", - rss_to_mb(start_rss), - rss_to_mb(end_rss), - rss_change_to_mb(change_rss), - ) + // It's tempting to add the change in RSS from start to end, but its somewhat confusing + // and misleading when looking at time-passes output. Consider two adjacent entries: + // + // time: 10.000; rss start: 1000MB, end: 1000MB, change: 0MB pass1 + // time: 5.000; rss start: 2000MB, end: 2000MB, change: 0MB pass2 + // + // If you're looking for jumps in RSS based on the change column, you miss the fact + // that a 1GB jump happened between pass1 and pass2 (supposing pass1 and pass2 actually + // occur sequentially and pass1 isn't just nested within pass2). It's easy to imagine + // someone missing this or being confused by the fact that the change is zero. + + format!("; rss: {:>5}MB -> {:>5}MB", rss_to_mb(start_rss), rss_to_mb(end_rss)) } - (Some(start_rss), None) => format!("; rss start: {:>4}MB", rss_to_mb(start_rss)), - (None, Some(end_rss)) => format!("; rss end: {:>4}MB", rss_to_mb(end_rss)), + (Some(start_rss), None) => format!("; rss start: {:>5}MB", rss_to_mb(start_rss)), + (None, Some(end_rss)) => format!("; rss end: {:5>}MB", rss_to_mb(end_rss)), (None, None) => String::new(), }; diff --git a/compiler/rustc_error_codes/src/error_codes.rs b/compiler/rustc_error_codes/src/error_codes.rs index 849ef18fb90cb..c669f7fed272a 100644 --- a/compiler/rustc_error_codes/src/error_codes.rs +++ b/compiler/rustc_error_codes/src/error_codes.rs @@ -267,7 +267,6 @@ E0516: include_str!("./error_codes/E0516.md"), E0517: include_str!("./error_codes/E0517.md"), E0518: include_str!("./error_codes/E0518.md"), E0520: include_str!("./error_codes/E0520.md"), -E0521: include_str!("./error_codes/E0521.md"), E0522: include_str!("./error_codes/E0522.md"), E0524: include_str!("./error_codes/E0524.md"), E0525: include_str!("./error_codes/E0525.md"), @@ -285,7 +284,6 @@ E0537: include_str!("./error_codes/E0537.md"), E0538: include_str!("./error_codes/E0538.md"), E0539: include_str!("./error_codes/E0539.md"), E0541: include_str!("./error_codes/E0541.md"), -E0542: include_str!("./error_codes/E0542.md"), E0546: include_str!("./error_codes/E0546.md"), E0550: include_str!("./error_codes/E0550.md"), E0551: include_str!("./error_codes/E0551.md"), @@ -467,7 +465,6 @@ E0777: include_str!("./error_codes/E0777.md"), E0778: include_str!("./error_codes/E0778.md"), E0779: include_str!("./error_codes/E0779.md"), E0780: include_str!("./error_codes/E0780.md"), -E0781: include_str!("./error_codes/E0781.md"), ; // E0006, // merged with E0005 // E0008, // cannot bind by-move into a pattern guard @@ -600,9 +597,11 @@ E0781: include_str!("./error_codes/E0781.md"), E0514, // metadata version mismatch E0519, // local crate and dependency have same (crate-name, disambiguator) // two dependencies have same (crate-name, disambiguator) but different SVH + E0521, // borrowed data escapes outside of closure E0523, // E0526, // shuffle indices are not constant // E0540, // multiple rustc_deprecated attributes + E0542, // missing 'since' E0543, // missing 'reason' E0544, // multiple stability levels E0545, // incorrect 'issue' diff --git a/compiler/rustc_error_codes/src/error_codes/E0074.md b/compiler/rustc_error_codes/src/error_codes/E0074.md index 785d6de226d3d..e25dec7681be5 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0074.md +++ b/compiler/rustc_error_codes/src/error_codes/E0074.md @@ -11,7 +11,7 @@ This will cause an error: #![feature(repr_simd)] #[repr(simd)] -struct Bad(T, T, T, T); +struct Bad(T, T, T); ``` This will not: @@ -20,5 +20,5 @@ This will not: #![feature(repr_simd)] #[repr(simd)] -struct Good(u32, u32, u32, u32); +struct Good(u32, u32, u32); ``` diff --git a/compiler/rustc_error_codes/src/error_codes/E0076.md b/compiler/rustc_error_codes/src/error_codes/E0076.md index 1da8caa9506d7..f293a2a5772db 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0076.md +++ b/compiler/rustc_error_codes/src/error_codes/E0076.md @@ -7,7 +7,7 @@ Erroneous code example: #![feature(repr_simd)] #[repr(simd)] -struct Bad(u16, u32, u32 u32); // error! +struct Bad(u16, u32, u32); // error! ``` When using the `#[simd]` attribute to automatically use SIMD operations in tuple @@ -20,5 +20,5 @@ Fixed example: #![feature(repr_simd)] #[repr(simd)] -struct Good(u32, u32, u32, u32); // ok! +struct Good(u32, u32, u32); // ok! ``` diff --git a/compiler/rustc_error_codes/src/error_codes/E0077.md b/compiler/rustc_error_codes/src/error_codes/E0077.md index 91aa24d1f52f4..b14513c6ccf1f 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0077.md +++ b/compiler/rustc_error_codes/src/error_codes/E0077.md @@ -19,5 +19,5 @@ Fixed example: #![feature(repr_simd)] #[repr(simd)] -struct Good(u32, u32, u32, u32); // ok! +struct Good(u32, u32, u32); // ok! ``` diff --git a/compiler/rustc_error_codes/src/error_codes/E0463.md b/compiler/rustc_error_codes/src/error_codes/E0463.md index d0cd1b1dcb75b..e46938c607d34 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0463.md +++ b/compiler/rustc_error_codes/src/error_codes/E0463.md @@ -11,24 +11,3 @@ extern crate cake_is_a_lie; // error: can't find crate for `cake_is_a_lie` You need to link your code to the relevant crate in order to be able to use it (through Cargo or the `-L` option of rustc example). Plugins are crates as well, and you link to them the same way. - -## Common causes - -- The crate is not present at all. If using Cargo, add it to `[dependencies]` - in Cargo.toml. -- The crate is present, but under a different name. If using Cargo, look for - `package = ` under `[dependencies]` in Cargo.toml. - -## Common causes for missing `std` or `core` - -- You are cross-compiling for a target which doesn't have `std` prepackaged. - Consider one of the following: - + Adding a pre-compiled version of std with `rustup target add` - + Building std from source with `cargo build -Z build-std` - + Using `#![no_std]` at the crate root, so you won't need `std` in the first - place. -- You are developing the compiler itself and haven't built libstd from source. - You can usually build it with `x.py build library/std`. More information - about x.py is available in the [rustc-dev-guide]. - -[rustc-dev-guide]: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html#building-the-compiler diff --git a/compiler/rustc_error_codes/src/error_codes/E0521.md b/compiler/rustc_error_codes/src/error_codes/E0521.md deleted file mode 100644 index 65dcac983acd5..0000000000000 --- a/compiler/rustc_error_codes/src/error_codes/E0521.md +++ /dev/null @@ -1,28 +0,0 @@ -Borrowed data escapes outside of closure. - -Erroneous code example: - -```compile_fail,E0521 -let mut list: Vec<&str> = Vec::new(); - -let _add = |el: &str| { - list.push(el); // error: `el` escapes the closure body here -}; -``` - -A type anotation of a closure parameter implies a new lifetime declaration. -Consider to drop it, the compiler is reliably able to infer them. - -``` -let mut list: Vec<&str> = Vec::new(); - -let _add = |el| { - list.push(el); -}; -``` - -See the [Closure type inference and annotation][closure-infere-annotation] and -[Lifetime elision][lifetime-elision] sections of the Book for more details. - -[closure-infere-annotation]: https://doc.rust-lang.org/book/ch13-01-closures.html#closure-type-inference-and-annotation -[lifetime-elision]: https://doc.rust-lang.org/reference/lifetime-elision.html diff --git a/compiler/rustc_error_codes/src/error_codes/E0542.md b/compiler/rustc_error_codes/src/error_codes/E0542.md deleted file mode 100644 index dbbc34a71be2c..0000000000000 --- a/compiler/rustc_error_codes/src/error_codes/E0542.md +++ /dev/null @@ -1,47 +0,0 @@ -The `since` value is missing in a stability attribute. - -Erroneous code example: - -```compile_fail,E0542 -#![feature(staged_api)] -#![stable(since = "1.0.0", feature = "test")] - -#[stable(feature = "_stable_fn")] // invalid -fn _stable_fn() {} - -#[rustc_const_stable(feature = "_stable_const_fn")] // invalid -fn _stable_const_fn() {} - -#[stable(feature = "_deprecated_fn", since = "0.1.0")] -#[rustc_deprecated( - reason = "explanation for deprecation" -)] // invalid -fn _deprecated_fn() {} -``` - -To fix the issue you need to provide the `since` field. - -``` -#![feature(staged_api)] -#![stable(since = "1.0.0", feature = "test")] - -#[stable(feature = "_stable_fn", since = "1.0.0")] // ok! -fn _stable_fn() {} - -#[rustc_const_stable(feature = "_stable_const_fn", since = "1.0.0")] // ok! -fn _stable_const_fn() {} - -#[stable(feature = "_deprecated_fn", since = "0.1.0")] -#[rustc_deprecated( - since = "1.0.0", - reason = "explanation for deprecation" -)] // ok! -fn _deprecated_fn() {} -``` - -See the [How Rust is Made and “Nightly Rust”][how-rust-made-nightly] appendix -of the Book and the [Stability attributes][stability-attributes] section of the -Rustc Dev Guide for more details. - -[how-rust-made-nightly]: https://doc.rust-lang.org/book/appendix-07-nightly-rust.html -[stability-attributes]: https://rustc-dev-guide.rust-lang.org/stability.html diff --git a/compiler/rustc_error_codes/src/error_codes/E0546.md b/compiler/rustc_error_codes/src/error_codes/E0546.md index 0073357b5ea84..b2df22c0f8fad 100644 --- a/compiler/rustc_error_codes/src/error_codes/E0546.md +++ b/compiler/rustc_error_codes/src/error_codes/E0546.md @@ -1,4 +1,4 @@ -The `feature` value is missing in a stability attribute. +A feature name is missing. Erroneous code example: @@ -13,7 +13,7 @@ fn unstable_fn() {} fn stable_fn() {} ``` -To fix the issue you need to provide the `feature` field. +To fix the issue you need to provide a feature name. ``` #![feature(staged_api)] @@ -25,10 +25,3 @@ fn unstable_fn() {} #[stable(feature = "stable_fn", since = "1.0.0")] // ok! fn stable_fn() {} ``` - -See the [How Rust is Made and “Nightly Rust”][how-rust-made-nightly] appendix -of the Book and the [Stability attributes][stability-attributes] section of the -Rustc Dev Guide for more details. - -[how-rust-made-nightly]: https://doc.rust-lang.org/book/appendix-07-nightly-rust.html -[stability-attributes]: https://rustc-dev-guide.rust-lang.org/stability.html diff --git a/compiler/rustc_error_codes/src/error_codes/E0781.md b/compiler/rustc_error_codes/src/error_codes/E0781.md deleted file mode 100644 index 7641acfb5249e..0000000000000 --- a/compiler/rustc_error_codes/src/error_codes/E0781.md +++ /dev/null @@ -1,12 +0,0 @@ -The `C-cmse-nonsecure-call` ABI can only be used with function pointers. - -Erroneous code example: - -```compile_fail,E0781 -#![feature(abi_c_cmse_nonsecure_call)] - -pub extern "C-cmse-nonsecure-call" fn test() {} -``` - -The `C-cmse-nonsecure-call` ABI should be used by casting function pointers to -specific addresses. diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index ef4a45cab4135..e61476bf23e1e 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -4,9 +4,7 @@ use crate::Level; use crate::Substitution; use crate::SubstitutionPart; use crate::SuggestionStyle; -use crate::ToolMetadata; use rustc_lint_defs::Applicability; -use rustc_serialize::json::Json; use rustc_span::{MultiSpan, Span, DUMMY_SP}; use std::fmt; @@ -305,7 +303,6 @@ impl Diagnostic { msg: msg.to_owned(), style: SuggestionStyle::ShowCode, applicability, - tool_metadata: Default::default(), }); self } @@ -331,7 +328,6 @@ impl Diagnostic { msg: msg.to_owned(), style: SuggestionStyle::ShowCode, applicability, - tool_metadata: Default::default(), }); self } @@ -358,7 +354,6 @@ impl Diagnostic { msg: msg.to_owned(), style: SuggestionStyle::CompletelyHidden, applicability, - tool_metadata: Default::default(), }); self } @@ -413,7 +408,6 @@ impl Diagnostic { msg: msg.to_owned(), style, applicability, - tool_metadata: Default::default(), }); self } @@ -452,7 +446,6 @@ impl Diagnostic { msg: msg.to_owned(), style: SuggestionStyle::ShowCode, applicability, - tool_metadata: Default::default(), }); self } @@ -522,23 +515,6 @@ impl Diagnostic { self } - /// Adds a suggestion intended only for a tool. The intent is that the metadata encodes - /// the suggestion in a tool-specific way, as it may not even directly involve Rust code. - pub fn tool_only_suggestion_with_metadata( - &mut self, - msg: &str, - applicability: Applicability, - tool_metadata: Json, - ) { - self.suggestions.push(CodeSuggestion { - substitutions: vec![], - msg: msg.to_owned(), - style: SuggestionStyle::CompletelyHidden, - applicability, - tool_metadata: ToolMetadata::new(tool_metadata), - }) - } - pub fn set_span>(&mut self, sp: S) -> &mut Self { self.span = sp.into(); if let Some(span) = self.span.primary_span() { diff --git a/compiler/rustc_errors/src/diagnostic_builder.rs b/compiler/rustc_errors/src/diagnostic_builder.rs index c09cce21bf24c..37902dddff46d 100644 --- a/compiler/rustc_errors/src/diagnostic_builder.rs +++ b/compiler/rustc_errors/src/diagnostic_builder.rs @@ -36,7 +36,7 @@ macro_rules! forward_inner_docs { ($e:expr => $i:item) => { #[doc = $e] $i - }; + } } /// In general, the `DiagnosticBuilder` uses deref to allow access to diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index ea62e21523028..00882bb287a4f 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -645,7 +645,7 @@ impl EmitterWriter { margin: Margin, ) { // Tabs are assumed to have been replaced by spaces in calling code. - debug_assert!(!source_string.contains('\t')); + assert!(!source_string.contains('\t')); let line_len = source_string.len(); // Create the source line we will highlight. let left = margin.left(line_len); diff --git a/compiler/rustc_errors/src/json.rs b/compiler/rustc_errors/src/json.rs index c27b39a9d62ff..d57beb1148a25 100644 --- a/compiler/rustc_errors/src/json.rs +++ b/compiler/rustc_errors/src/json.rs @@ -14,7 +14,6 @@ use rustc_span::source_map::{FilePathMapping, SourceMap}; use crate::emitter::{Emitter, HumanReadableErrorType}; use crate::registry::Registry; use crate::DiagnosticId; -use crate::ToolMetadata; use crate::{CodeSuggestion, SubDiagnostic}; use rustc_lint_defs::{Applicability, FutureBreakage}; @@ -27,7 +26,6 @@ use std::sync::{Arc, Mutex}; use std::vec; use rustc_serialize::json::{as_json, as_pretty_json}; -use rustc_serialize::{Encodable, Encoder}; #[cfg(test)] mod tests; @@ -170,8 +168,7 @@ impl Emitter for JsonEmitter { // The following data types are provided just for serialisation. -// NOTE: this has a manual implementation of Encodable which needs to be updated in -// parallel. +#[derive(Encodable)] struct Diagnostic { /// The primary error message. message: String, @@ -183,65 +180,6 @@ struct Diagnostic { children: Vec, /// The message as rustc would render it. rendered: Option, - /// Extra tool metadata - tool_metadata: ToolMetadata, -} - -macro_rules! encode_fields { - ( - $enc:expr, // encoder - $idx:expr, // starting field index - $struct:expr, // struct we're serializing - $struct_name:ident, // struct name - [ $($name:ident),+$(,)? ], // fields to encode - [ $($ignore:ident),+$(,)? ] // fields we're skipping - ) => { - { - // Pattern match to make sure all fields are accounted for - let $struct_name { $($name,)+ $($ignore: _,)+ } = $struct; - let mut idx = $idx; - $( - $enc.emit_struct_field( - stringify!($name), - idx, - |enc| $name.encode(enc), - )?; - idx += 1; - )+ - idx - } - }; -} - -// Special-case encoder to skip tool_metadata if not set -impl Encodable for Diagnostic { - fn encode(&self, s: &mut E) -> Result<(), E::Error> { - s.emit_struct("diagnostic", 7, |s| { - let mut idx = 0; - - idx = encode_fields!( - s, - idx, - self, - Self, - [message, code, level, spans, children, rendered], - [tool_metadata] - ); - if self.tool_metadata.is_set() { - idx = encode_fields!( - s, - idx, - self, - Self, - [tool_metadata], - [message, code, level, spans, children, rendered] - ); - } - - let _ = idx; - Ok(()) - }) - } } #[derive(Encodable)] @@ -331,7 +269,6 @@ impl Diagnostic { spans: DiagnosticSpan::from_suggestion(sugg, je), children: vec![], rendered: None, - tool_metadata: sugg.tool_metadata.clone(), }); // generate regular command line output and store it in the json @@ -375,7 +312,6 @@ impl Diagnostic { .chain(sugg) .collect(), rendered: Some(output), - tool_metadata: ToolMetadata::default(), } } @@ -391,7 +327,6 @@ impl Diagnostic { .unwrap_or_else(|| DiagnosticSpan::from_multispan(&diag.span, je)), children: vec![], rendered: None, - tool_metadata: ToolMetadata::default(), } } } diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 9800ed9bfa948..e184e929b0745 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -23,13 +23,10 @@ use rustc_data_structures::sync::{self, Lock, Lrc}; use rustc_data_structures::AtomicRef; use rustc_lint_defs::FutureBreakage; pub use rustc_lint_defs::{pluralize, Applicability}; -use rustc_serialize::json::Json; -use rustc_serialize::{Decodable, Decoder, Encodable, Encoder}; use rustc_span::source_map::SourceMap; use rustc_span::{Loc, MultiSpan, Span}; use std::borrow::Cow; -use std::hash::{Hash, Hasher}; use std::panic; use std::path::Path; use std::{error, fmt}; @@ -76,39 +73,6 @@ impl SuggestionStyle { } } -#[derive(Clone, Debug, PartialEq, Default)] -pub struct ToolMetadata(pub Option); - -impl ToolMetadata { - fn new(json: Json) -> Self { - ToolMetadata(Some(json)) - } - - fn is_set(&self) -> bool { - self.0.is_some() - } -} - -impl Hash for ToolMetadata { - fn hash(&self, _state: &mut H) {} -} - -// Doesn't really need to round-trip -impl Decodable for ToolMetadata { - fn decode(_d: &mut D) -> Result { - Ok(ToolMetadata(None)) - } -} - -impl Encodable for ToolMetadata { - fn encode(&self, e: &mut S) -> Result<(), S::Error> { - match &self.0 { - None => e.emit_unit(), - Some(json) => json.encode(e), - } - } -} - #[derive(Clone, Debug, PartialEq, Hash, Encodable, Decodable)] pub struct CodeSuggestion { /// Each substitute can have multiple variants due to multiple @@ -142,8 +106,6 @@ pub struct CodeSuggestion { /// which are useful for users but not useful for /// tools like rustfix pub applicability: Applicability, - /// Tool-specific metadata - pub tool_metadata: ToolMetadata, } #[derive(Clone, Debug, PartialEq, Hash, Encodable, Decodable)] @@ -813,6 +775,7 @@ impl HandlerInner { } let already_emitted = |this: &mut Self| { + use std::hash::Hash; let mut hasher = StableHasher::new(); diagnostic.hash(&mut hasher); let diagnostic_hash = hasher.finish(); @@ -938,7 +901,7 @@ impl HandlerInner { fn span_bug(&mut self, sp: impl Into, msg: &str) -> ! { self.emit_diag_at_span(Diagnostic::new(Bug, msg), sp); - panic::panic_any(ExplicitBug); + panic!(ExplicitBug); } fn emit_diag_at_span(&mut self, mut diag: Diagnostic, sp: impl Into) { @@ -992,7 +955,7 @@ impl HandlerInner { fn bug(&mut self, msg: &str) -> ! { self.emit_diagnostic(&Diagnostic::new(Bug, msg)); - panic::panic_any(ExplicitBug); + panic!(ExplicitBug); } fn delay_as_bug(&mut self, diagnostic: Diagnostic) { diff --git a/compiler/rustc_errors/src/snippet.rs b/compiler/rustc_errors/src/snippet.rs index acb88e57db5ee..dbb2523f28691 100644 --- a/compiler/rustc_errors/src/snippet.rs +++ b/compiler/rustc_errors/src/snippet.rs @@ -122,13 +122,11 @@ impl Annotation { } pub fn is_multiline(&self) -> bool { - matches!( - self.annotation_type, + matches!(self.annotation_type, AnnotationType::Multiline(_) - | AnnotationType::MultilineStart(_) - | AnnotationType::MultilineLine(_) - | AnnotationType::MultilineEnd(_) - ) + | AnnotationType::MultilineStart(_) + | AnnotationType::MultilineLine(_) + | AnnotationType::MultilineEnd(_)) } pub fn len(&self) -> usize { @@ -160,10 +158,7 @@ impl Annotation { pub fn takes_space(&self) -> bool { // Multiline annotations always have to keep vertical space. - matches!( - self.annotation_type, - AnnotationType::MultilineStart(_) | AnnotationType::MultilineEnd(_) - ) + matches!(self.annotation_type, AnnotationType::MultilineStart(_) | AnnotationType::MultilineEnd(_)) } } diff --git a/compiler/rustc_errors/src/styled_buffer.rs b/compiler/rustc_errors/src/styled_buffer.rs index ef71ee36ea36c..a4dd0f391bd3a 100644 --- a/compiler/rustc_errors/src/styled_buffer.rs +++ b/compiler/rustc_errors/src/styled_buffer.rs @@ -15,7 +15,7 @@ impl StyledBuffer { pub fn render(&self) -> Vec> { // Tabs are assumed to have been replaced by spaces in calling code. - debug_assert!(self.text.iter().all(|r| !r.contains(&'\t'))); + assert!(self.text.iter().all(|r| !r.contains(&'\t'))); let mut output: Vec> = vec![]; let mut styled_vec: Vec = vec![]; diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index 196a774355e10..08543d1622a7d 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -141,10 +141,7 @@ impl Annotatable { } crate fn into_tokens(self, sess: &ParseSess) -> TokenStream { - // Tokens of an attribute target may be invalidated by some outer `#[derive]` performing - // "full configuration" (attributes following derives on the same item should be the most - // common case), that's why synthesizing tokens is allowed. - nt_to_tokenstream(&self.into_nonterminal(), sess, CanSynthesizeMissingTokens::Yes) + nt_to_tokenstream(&self.into_nonterminal(), sess, CanSynthesizeMissingTokens::No) } pub fn expect_item(self) -> P { @@ -237,6 +234,25 @@ impl Annotatable { _ => panic!("expected variant"), } } + + pub fn derive_allowed(&self) -> bool { + match *self { + Annotatable::Stmt(ref stmt) => match stmt.kind { + ast::StmtKind::Item(ref item) => matches!( + item.kind, + ast::ItemKind::Struct(..) | ast::ItemKind::Enum(..) | ast::ItemKind::Union(..) + ), + _ => false, + }, + Annotatable::Item(ref item) => match item.kind { + ast::ItemKind::Struct(..) | ast::ItemKind::Enum(..) | ast::ItemKind::Union(..) => { + true + } + _ => false, + }, + _ => false, + } + } } /// Result of an expansion that may need to be retried. @@ -838,6 +854,12 @@ impl SyntaxExtension { } } +/// Result of resolving a macro invocation. +pub enum InvocationRes { + Single(Lrc), + DeriveContainer(Vec>), +} + /// Error type that denotes indeterminacy. pub struct Indeterminate; @@ -863,29 +885,16 @@ pub trait ResolverExpand { invoc: &Invocation, eager_expansion_root: ExpnId, force: bool, - ) -> Result, Indeterminate>; + ) -> Result; fn check_unused_macros(&mut self); /// Some parent node that is close enough to the given macro call. - fn lint_node_id(&self, expn_id: ExpnId) -> NodeId; + fn lint_node_id(&mut self, expn_id: ExpnId) -> NodeId; // Resolver interfaces for specific built-in macros. /// Does `#[derive(...)]` attribute with the given `ExpnId` have built-in `Copy` inside it? fn has_derive_copy(&self, expn_id: ExpnId) -> bool; - /// Resolve paths inside the `#[derive(...)]` attribute with the given `ExpnId`. - fn resolve_derives( - &mut self, - expn_id: ExpnId, - derives: Vec, - force: bool, - ) -> Result<(), Indeterminate>; - /// Take resolutions for paths inside the `#[derive(...)]` attribute with the given `ExpnId` - /// back from resolver. - fn take_derive_resolutions( - &mut self, - expn_id: ExpnId, - ) -> Option, ast::Path)>>; /// Path resolution logic for `#[cfg_accessible(path)]`. fn cfg_accessible(&mut self, expn_id: ExpnId, path: &ast::Path) -> Result; } diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs index 870b5c92d8983..50832d5edbfc5 100644 --- a/compiler/rustc_expand/src/expand.rs +++ b/compiler/rustc_expand/src/expand.rs @@ -1,26 +1,24 @@ use crate::base::*; use crate::config::StripUnconfigured; use crate::configure; -use crate::hygiene::SyntaxContext; +use crate::hygiene::{ExpnData, ExpnKind, SyntaxContext}; use crate::mbe::macro_rules::annotate_err_with_kind; use crate::module::{parse_external_mod, push_directory, Directory, DirectoryOwnership}; use crate::placeholders::{placeholder, PlaceholderExpander}; +use crate::proc_macro::collect_derives; -use rustc_ast as ast; use rustc_ast::mut_visit::*; use rustc_ast::ptr::P; use rustc_ast::token; use rustc_ast::tokenstream::TokenStream; use rustc_ast::visit::{self, AssocCtxt, Visitor}; -use rustc_ast::{AttrItem, AttrStyle, Block, ItemKind, LitKind, MacArgs}; -use rustc_ast::{MacCallStmt, MacStmtStyle, MetaItemKind, NestedMetaItem}; -use rustc_ast::{NodeId, PatKind, Path, StmtKind, Unsafe}; +use rustc_ast::{self as ast, AttrItem, AttrStyle, Block, LitKind, NodeId, PatKind, Path}; +use rustc_ast::{ItemKind, MacArgs, MacCallStmt, MacStmtStyle, StmtKind, Unsafe}; use rustc_ast_pretty::pprust; use rustc_attr::{self as attr, is_builtin_attr, HasAttrs}; use rustc_data_structures::map_in_place::MapInPlace; use rustc_data_structures::stack::ensure_sufficient_stack; -use rustc_data_structures::sync::Lrc; -use rustc_errors::{Applicability, PResult}; +use rustc_errors::{struct_span_err, Applicability, PResult}; use rustc_feature::Features; use rustc_parse::parser::{AttemptLocalParseRecovery, ForceCollect, Parser}; use rustc_parse::validate_attr; @@ -304,11 +302,20 @@ pub enum InvocationKind { item: Annotatable, // Required for resolving derive helper attributes. derives: Vec, + // We temporarily report errors for attribute macros placed after derives + after_derive: bool, }, Derive { path: Path, item: Annotatable, }, + /// "Invocation" that contains all derives from an item, + /// broken into multiple `Derive` invocations when expanded. + /// FIXME: Find a way to remove it. + DeriveContainer { + derives: Vec, + item: Annotatable, + }, } impl InvocationKind { @@ -321,6 +328,7 @@ impl InvocationKind { match self { InvocationKind::Attr { item: Annotatable::StructField(field), .. } | InvocationKind::Derive { item: Annotatable::StructField(field), .. } + | InvocationKind::DeriveContainer { item: Annotatable::StructField(field), .. } if field.ident.is_none() => { Some(field.vis.clone()) @@ -336,6 +344,7 @@ impl Invocation { InvocationKind::Bang { span, .. } => *span, InvocationKind::Attr { attr, .. } => attr.span, InvocationKind::Derive { path, .. } => path.span, + InvocationKind::DeriveContainer { item, .. } => item.span(), } } } @@ -437,7 +446,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { let mut undetermined_invocations = Vec::new(); let (mut progress, mut force) = (false, !self.monotonic); loop { - let (invoc, ext) = if let Some(invoc) = invocations.pop() { + let (invoc, res) = if let Some(invoc) = invocations.pop() { invoc } else { self.resolve_imports(); @@ -455,8 +464,8 @@ impl<'a, 'b> MacroExpander<'a, 'b> { continue; }; - let ext = match ext { - Some(ext) => ext, + let res = match res { + Some(res) => res, None => { let eager_expansion_root = if self.monotonic { invoc.expansion_data.id @@ -468,7 +477,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { eager_expansion_root, force, ) { - Ok(ext) => ext, + Ok(res) => res, Err(Indeterminate) => { // Cannot resolve, will retry this invocation later. undetermined_invocations.push((invoc, None)); @@ -482,78 +491,86 @@ impl<'a, 'b> MacroExpander<'a, 'b> { self.cx.current_expansion = invoc.expansion_data.clone(); self.cx.force_mode = force; + // FIXME(jseyfried): Refactor out the following logic let fragment_kind = invoc.fragment_kind; - let (expanded_fragment, new_invocations) = match self.expand_invoc(invoc, &ext.kind) { - ExpandResult::Ready(fragment) => { - let derive_placeholders = self - .cx - .resolver - .take_derive_resolutions(expn_id) - .map(|derives| { - enum AnnotatableRef<'a> { - Item(&'a P), - Stmt(&'a ast::Stmt), + let (expanded_fragment, new_invocations) = match res { + InvocationRes::Single(ext) => match self.expand_invoc(invoc, &ext.kind) { + ExpandResult::Ready(fragment) => self.collect_invocations(fragment, &[]), + ExpandResult::Retry(invoc) => { + if force { + self.cx.span_bug( + invoc.span(), + "expansion entered force mode but is still stuck", + ); + } else { + // Cannot expand, will retry this invocation later. + undetermined_invocations + .push((invoc, Some(InvocationRes::Single(ext)))); + continue; + } + } + }, + InvocationRes::DeriveContainer(_exts) => { + // FIXME: Consider using the derive resolutions (`_exts`) immediately, + // instead of enqueuing the derives to be resolved again later. + let (derives, mut item) = match invoc.kind { + InvocationKind::DeriveContainer { derives, item } => (derives, item), + _ => unreachable!(), + }; + let (item, derive_placeholders) = if !item.derive_allowed() { + self.error_derive_forbidden_on_non_adt(&derives, &item); + item.visit_attrs(|attrs| attrs.retain(|a| !a.has_name(sym::derive))); + (item, Vec::new()) + } else { + let mut visitor = StripUnconfigured { + sess: self.cx.sess, + features: self.cx.ecfg.features, + modified: false, + }; + let mut item = visitor.fully_configure(item); + item.visit_attrs(|attrs| attrs.retain(|a| !a.has_name(sym::derive))); + if visitor.modified && !derives.is_empty() { + // Erase the tokens if cfg-stripping modified the item + // This will cause us to synthesize fake tokens + // when `nt_to_tokenstream` is called on this item. + match &mut item { + Annotatable::Item(item) => item.tokens = None, + Annotatable::Stmt(stmt) => { + if let StmtKind::Item(item) = &mut stmt.kind { + item.tokens = None + } else { + panic!("Unexpected stmt {:?}", stmt); + } + } + _ => panic!("Unexpected annotatable {:?}", item), } - let item = match &fragment { - AstFragment::Items(items) => match &items[..] { - [item] => AnnotatableRef::Item(item), - _ => unreachable!(), - }, - AstFragment::Stmts(stmts) => match &stmts[..] { - [stmt] => AnnotatableRef::Stmt(stmt), - _ => unreachable!(), - }, - _ => unreachable!(), - }; + } - invocations.reserve(derives.len()); - derives - .into_iter() - .map(|(_exts, path)| { - // FIXME: Consider using the derive resolutions (`_exts`) - // instead of enqueuing the derives to be resolved again later. - let expn_id = ExpnId::fresh(None); - invocations.push(( - Invocation { - kind: InvocationKind::Derive { - path, - item: match item { - AnnotatableRef::Item(item) => { - Annotatable::Item(item.clone()) - } - AnnotatableRef::Stmt(stmt) => { - Annotatable::Stmt(P(stmt.clone())) - } - }, - }, - fragment_kind, - expansion_data: ExpansionData { - id: expn_id, - ..self.cx.current_expansion.clone() - }, + invocations.reserve(derives.len()); + let derive_placeholders = derives + .into_iter() + .map(|path| { + let expn_id = ExpnId::fresh(None); + invocations.push(( + Invocation { + kind: InvocationKind::Derive { path, item: item.clone() }, + fragment_kind, + expansion_data: ExpansionData { + id: expn_id, + ..self.cx.current_expansion.clone() }, - None, - )); - NodeId::placeholder_from_expn_id(expn_id) - }) - .collect::>() - }) - .unwrap_or_default(); + }, + None, + )); + NodeId::placeholder_from_expn_id(expn_id) + }) + .collect::>(); + (item, derive_placeholders) + }; + let fragment = fragment_kind.expect_from_annotatables(::std::iter::once(item)); self.collect_invocations(fragment, &derive_placeholders) } - ExpandResult::Retry(invoc) => { - if force { - self.cx.span_bug( - invoc.span(), - "expansion entered force mode but is still stuck", - ); - } else { - // Cannot expand, will retry this invocation later. - undetermined_invocations.push((invoc, Some(ext))); - continue; - } - } }; progress = true; @@ -579,6 +596,29 @@ impl<'a, 'b> MacroExpander<'a, 'b> { fragment_with_placeholders } + fn error_derive_forbidden_on_non_adt(&self, derives: &[Path], item: &Annotatable) { + let attr = self.cx.sess.find_by_name(item.attrs(), sym::derive); + let span = attr.map_or(item.span(), |attr| attr.span); + let mut err = struct_span_err!( + self.cx.sess, + span, + E0774, + "`derive` may only be applied to structs, enums and unions", + ); + if let Some(ast::Attribute { style: ast::AttrStyle::Inner, .. }) = attr { + let trait_list = derives.iter().map(|t| pprust::path_to_string(t)).collect::>(); + let suggestion = format!("#[derive({})]", trait_list.join(", ")); + err.span_suggestion( + span, + "try an outer attribute", + suggestion, + // We don't 𝑘𝑛𝑜𝑤 that the following item is an ADT + Applicability::MaybeIncorrect, + ); + } + err.emit(); + } + fn resolve_imports(&mut self) { if self.monotonic { self.cx.resolver.resolve_imports(); @@ -593,7 +633,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { &mut self, mut fragment: AstFragment, extra_placeholders: &[NodeId], - ) -> (AstFragment, Vec<(Invocation, Option>)>) { + ) -> (AstFragment, Vec<(Invocation, Option)>) { // Resolve `$crate`s in the fragment for pretty-printing. self.cx.resolver.resolve_dollar_crates(); @@ -693,7 +733,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { } _ => unreachable!(), }, - InvocationKind::Attr { attr, mut item, derives } => match ext { + InvocationKind::Attr { attr, mut item, derives, after_derive } => match ext { SyntaxExtensionKind::Attr(expander) => { self.gate_proc_macro_input(&item); self.gate_proc_macro_attr_item(span, &item); @@ -724,7 +764,12 @@ impl<'a, 'b> MacroExpander<'a, 'b> { ExpandResult::Retry(item) => { // Reassemble the original invocation for retrying. return ExpandResult::Retry(Invocation { - kind: InvocationKind::Attr { attr, item, derives }, + kind: InvocationKind::Attr { + attr, + item, + derives, + after_derive, + }, ..invoc }); } @@ -768,6 +813,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { } _ => unreachable!(), }, + InvocationKind::DeriveContainer { .. } => unreachable!(), }) } @@ -850,9 +896,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> { fragment } Err(mut err) => { - if err.span.is_dummy() { - err.set_span(span); - } + err.set_span(span); annotate_err_with_kind(&mut err, kind, span); err.emit(); self.cx.trace_macros_diag(); @@ -965,13 +1009,29 @@ pub fn ensure_complete_parse<'a>( struct InvocationCollector<'a, 'b> { cx: &'a mut ExtCtxt<'b>, cfg: StripUnconfigured<'a>, - invocations: Vec<(Invocation, Option>)>, + invocations: Vec<(Invocation, Option)>, monotonic: bool, } impl<'a, 'b> InvocationCollector<'a, 'b> { fn collect(&mut self, fragment_kind: AstFragmentKind, kind: InvocationKind) -> AstFragment { - let expn_id = ExpnId::fresh(None); + // Expansion data for all the collected invocations is set upon their resolution, + // with exception of the derive container case which is not resolved and can get + // its expansion data immediately. + let expn_data = match &kind { + InvocationKind::DeriveContainer { item, .. } => { + let mut expn_data = ExpnData::default( + ExpnKind::Macro(MacroKind::Attr, sym::derive), + item.span(), + self.cx.sess.parse_sess.edition, + None, + ); + expn_data.parent = self.cx.current_expansion.id; + Some(expn_data) + } + _ => None, + }; + let expn_id = ExpnId::fresh(expn_data); let vis = kind.placeholder_visibility(); self.invocations.push(( Invocation { @@ -999,44 +1059,64 @@ impl<'a, 'b> InvocationCollector<'a, 'b> { fn collect_attr( &mut self, - (attr, derives): (ast::Attribute, Vec), + (attr, derives, after_derive): (Option, Vec, bool), item: Annotatable, kind: AstFragmentKind, ) -> AstFragment { - self.collect(kind, InvocationKind::Attr { attr, item, derives }) + self.collect( + kind, + match attr { + Some(attr) => InvocationKind::Attr { attr, item, derives, after_derive }, + None => InvocationKind::DeriveContainer { derives, item }, + }, + ) } - /// If `item` is an attribute invocation, remove the attribute and return it together with - /// derives following it. We have to collect the derives in order to resolve legacy derive - /// helpers (helpers written before derives that introduce them). - fn take_first_attr(&mut self, item: &mut impl HasAttrs) -> Option<(ast::Attribute, Vec)> { - let mut attr = None; - - item.visit_attrs(|attrs| { - attr = attrs - .iter() - .position(|a| !self.cx.sess.is_attr_known(a) && !is_builtin_attr(a)) - .map(|attr_pos| { - let attr = attrs.remove(attr_pos); - let following_derives = attrs[attr_pos..] - .iter() - .filter(|a| a.has_name(sym::derive)) - .flat_map(|a| a.meta_item_list().unwrap_or_default()) - .filter_map(|nested_meta| match nested_meta { - NestedMetaItem::MetaItem(ast::MetaItem { - kind: MetaItemKind::Word, - path, - .. - }) => Some(path), - _ => None, - }) - .collect(); - - (attr, following_derives) - }) + fn find_attr_invoc( + &self, + attrs: &mut Vec, + after_derive: &mut bool, + ) -> Option { + attrs + .iter() + .position(|a| { + if a.has_name(sym::derive) { + *after_derive = true; + } + !self.cx.sess.is_attr_known(a) && !is_builtin_attr(a) + }) + .map(|i| attrs.remove(i)) + } + + /// If `item` is an attr invocation, remove and return the macro attribute and derive traits. + fn take_first_attr( + &mut self, + item: &mut impl HasAttrs, + ) -> Option<(Option, Vec, /* after_derive */ bool)> { + let (mut attr, mut traits, mut after_derive) = (None, Vec::new(), false); + + item.visit_attrs(|mut attrs| { + attr = self.find_attr_invoc(&mut attrs, &mut after_derive); + traits = collect_derives(&mut self.cx, &mut attrs); + }); + + if attr.is_some() || !traits.is_empty() { Some((attr, traits, after_derive)) } else { None } + } + + /// Alternative to `take_first_attr()` that ignores `#[derive]` so invocations fallthrough + /// to the unused-attributes lint (making it an error on statements and expressions + /// is a breaking change) + fn take_first_attr_no_derive( + &mut self, + nonitem: &mut impl HasAttrs, + ) -> Option<(Option, Vec, /* after_derive */ bool)> { + let (mut attr, mut after_derive) = (None, false); + + nonitem.visit_attrs(|mut attrs| { + attr = self.find_attr_invoc(&mut attrs, &mut after_derive); }); - attr + attr.map(|attr| (Some(attr), Vec::new(), after_derive)) } fn configure(&mut self, node: T) -> Option { @@ -1050,6 +1130,17 @@ impl<'a, 'b> InvocationCollector<'a, 'b> { for attr in attrs.iter() { rustc_ast_passes::feature_gate::check_attribute(attr, self.cx.sess, features); validate_attr::check_meta(&self.cx.sess.parse_sess, attr); + + // macros are expanded before any lint passes so this warning has to be hardcoded + if attr.has_name(sym::derive) { + self.cx + .parse_sess() + .span_diagnostic + .struct_span_warn(attr.span, "`#[derive]` does nothing on macro invocations") + .note("this may become a hard error in a future release") + .emit(); + } + if attr.doc_str().is_some() { self.cx.sess.parse_sess.buffer_lint_with_diagnostic( &UNUSED_DOC_COMMENTS, @@ -1069,10 +1160,12 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { visit_clobber(expr.deref_mut(), |mut expr| { self.cfg.configure_expr_kind(&mut expr.kind); - if let Some(attr) = self.take_first_attr(&mut expr) { + if let Some(attr) = self.take_first_attr_no_derive(&mut expr) { // Collect the invoc regardless of whether or not attributes are permitted here // expansion will eat the attribute so it won't error later. - self.cfg.maybe_emit_expr_attr_err(&attr.0); + if let Some(attr) = attr.0.as_ref() { + self.cfg.maybe_emit_expr_attr_err(attr) + } // AstFragmentKind::Expr requires the macro to emit an expression. return self @@ -1168,8 +1261,10 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { expr.filter_map(|mut expr| { self.cfg.configure_expr_kind(&mut expr.kind); - if let Some(attr) = self.take_first_attr(&mut expr) { - self.cfg.maybe_emit_expr_attr_err(&attr.0); + if let Some(attr) = self.take_first_attr_no_derive(&mut expr) { + if let Some(attr) = attr.0.as_ref() { + self.cfg.maybe_emit_expr_attr_err(attr) + } return self .collect_attr(attr, Annotatable::Expr(P(expr)), AstFragmentKind::OptExpr) @@ -1211,7 +1306,15 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { // we'll expand attributes on expressions separately if !stmt.is_expr() { - if let Some(attr) = self.take_first_attr(&mut stmt) { + let attr = if stmt.is_item() { + self.take_first_attr(&mut stmt) + } else { + // Ignore derives on non-item statements for backwards compatibility. + // This will result in a unused attribute warning + self.take_first_attr_no_derive(&mut stmt) + }; + + if let Some(attr) = attr { return self .collect_attr(attr, Annotatable::Stmt(P(stmt)), AstFragmentKind::Stmts) .make_stmts(); diff --git a/compiler/rustc_expand/src/proc_macro.rs b/compiler/rustc_expand/src/proc_macro.rs index 8cbaa7c945a81..6779734cfc176 100644 --- a/compiler/rustc_expand/src/proc_macro.rs +++ b/compiler/rustc_expand/src/proc_macro.rs @@ -1,14 +1,16 @@ use crate::base::{self, *}; use crate::proc_macro_server; -use rustc_ast as ast; use rustc_ast::ptr::P; use rustc_ast::token; use rustc_ast::tokenstream::{CanSynthesizeMissingTokens, TokenStream, TokenTree}; +use rustc_ast::{self as ast, *}; use rustc_data_structures::sync::Lrc; -use rustc_errors::ErrorReported; +use rustc_errors::{struct_span_err, Applicability, ErrorReported}; +use rustc_lexer::is_ident; use rustc_parse::nt_to_tokenstream; use rustc_parse::parser::ForceCollect; +use rustc_span::symbol::sym; use rustc_span::{Span, DUMMY_SP}; const EXEC_STRATEGY: pm::bridge::server::SameThread = pm::bridge::server::SameThread; @@ -140,3 +142,91 @@ impl MultiItemModifier for ProcMacroDerive { ExpandResult::Ready(items) } } + +crate fn collect_derives(cx: &mut ExtCtxt<'_>, attrs: &mut Vec) -> Vec { + let mut result = Vec::new(); + attrs.retain(|attr| { + if !attr.has_name(sym::derive) { + return true; + } + + // 1) First let's ensure that it's a meta item. + let nmis = match attr.meta_item_list() { + None => { + cx.struct_span_err(attr.span, "malformed `derive` attribute input") + .span_suggestion( + attr.span, + "missing traits to be derived", + "#[derive(Trait1, Trait2, ...)]".to_owned(), + Applicability::HasPlaceholders, + ) + .emit(); + return false; + } + Some(x) => x, + }; + + let mut error_reported_filter_map = false; + let mut error_reported_map = false; + let traits = nmis + .into_iter() + // 2) Moreover, let's ensure we have a path and not `#[derive("foo")]`. + .filter_map(|nmi| match nmi { + NestedMetaItem::Literal(lit) => { + error_reported_filter_map = true; + let mut err = struct_span_err!( + cx.sess, + lit.span, + E0777, + "expected path to a trait, found literal", + ); + let token = lit.token.to_string(); + if token.starts_with('"') + && token.len() > 2 + && is_ident(&token[1..token.len() - 1]) + { + err.help(&format!("try using `#[derive({})]`", &token[1..token.len() - 1])); + } else { + err.help("for example, write `#[derive(Debug)]` for `Debug`"); + } + err.emit(); + None + } + NestedMetaItem::MetaItem(mi) => Some(mi), + }) + // 3) Finally, we only accept `#[derive($path_0, $path_1, ..)]` + // but not e.g. `#[derive($path_0 = "value", $path_1(abc))]`. + // In this case we can still at least determine that the user + // wanted this trait to be derived, so let's keep it. + .map(|mi| { + let mut traits_dont_accept = |title, action| { + error_reported_map = true; + let sp = mi.span.with_lo(mi.path.span.hi()); + cx.struct_span_err(sp, title) + .span_suggestion( + sp, + action, + String::new(), + Applicability::MachineApplicable, + ) + .emit(); + }; + match &mi.kind { + MetaItemKind::List(..) => traits_dont_accept( + "traits in `#[derive(...)]` don't accept arguments", + "remove the arguments", + ), + MetaItemKind::NameValue(..) => traits_dont_accept( + "traits in `#[derive(...)]` don't accept values", + "remove the value", + ), + MetaItemKind::Word => {} + } + mi.path + }); + + result.extend(traits); + !error_reported_filter_map && !error_reported_map + }); + result +} diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index 2d0009c225c59..e12b533b110d2 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -628,16 +628,6 @@ declare_features! ( /// Allows using `pointer` and `reference` in intra-doc links (active, intra_doc_pointers, "1.51.0", Some(80896), None), - - /// Allows `extern "C-cmse-nonsecure-call" fn()`. - (active, abi_c_cmse_nonsecure_call, "1.51.0", Some(81391), None), - - /// Lessens the requirements for structs to implement `Unsize`. - (active, relaxed_struct_unsize, "1.51.0", Some(1), None), - - /// Allows macro attributes to observe output of `#[derive]`. - (active, macro_attributes_in_derive_output, "1.51.0", Some(81119), None), - // ------------------------------------------------------------------------- // feature-group-end: actual feature gates // ------------------------------------------------------------------------- diff --git a/compiler/rustc_feature/src/builtin_attrs.rs b/compiler/rustc_feature/src/builtin_attrs.rs index ac50703b5444e..3ed5320da73b3 100644 --- a/compiler/rustc_feature/src/builtin_attrs.rs +++ b/compiler/rustc_feature/src/builtin_attrs.rs @@ -188,6 +188,7 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[ ungated!(reexport_test_harness_main, Normal, template!(NameValueStr: "name")), // Macros: + ungated!(derive, Normal, template!(List: "Trait1, Trait2, ...")), ungated!(automatically_derived, Normal, template!(Word)), // FIXME(#14407) ungated!(macro_use, Normal, template!(Word, List: "name1, name2, ...")), diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs index 49d9e3b60b492..35170fa7c1d02 100644 --- a/compiler/rustc_hir/src/hir.rs +++ b/compiler/rustc_hir/src/hir.rs @@ -358,7 +358,7 @@ impl GenericArgs<'_> { .iter() .filter(|arg| !arg.is_synthetic()) .map(|arg| arg.span()) - .reduce(|span1, span2| span1.to(span2)) + .fold_first(|span1, span2| span1.to(span2)) } /// Returns span encompassing arguments and their surrounding `<>` or `()` @@ -1543,10 +1543,10 @@ pub fn is_range_literal(expr: &Expr<'_>) -> bool { **qpath, QPath::LangItem( LangItem::Range - | LangItem::RangeTo - | LangItem::RangeFrom - | LangItem::RangeFull - | LangItem::RangeToInclusive, + | LangItem::RangeTo + | LangItem::RangeFrom + | LangItem::RangeFull + | LangItem::RangeToInclusive, _, ) ), @@ -2015,7 +2015,6 @@ pub struct TypeBinding<'hir> { pub hir_id: HirId, #[stable_hasher(project(name))] pub ident: Ident, - pub gen_args: &'hir GenericArgs<'hir>, pub kind: TypeBindingKind<'hir>, pub span: Span, } @@ -2058,28 +2057,6 @@ pub enum PrimTy { } impl PrimTy { - /// All of the primitive types - pub const ALL: [Self; 17] = [ - // any changes here should also be reflected in `PrimTy::from_name` - Self::Int(IntTy::I8), - Self::Int(IntTy::I16), - Self::Int(IntTy::I32), - Self::Int(IntTy::I64), - Self::Int(IntTy::I128), - Self::Int(IntTy::Isize), - Self::Uint(UintTy::U8), - Self::Uint(UintTy::U16), - Self::Uint(UintTy::U32), - Self::Uint(UintTy::U64), - Self::Uint(UintTy::U128), - Self::Uint(UintTy::Usize), - Self::Float(FloatTy::F32), - Self::Float(FloatTy::F64), - Self::Bool, - Self::Char, - Self::Str, - ]; - pub fn name_str(self) -> &'static str { match self { PrimTy::Int(i) => i.name_str(), @@ -2101,33 +2078,6 @@ impl PrimTy { PrimTy::Char => sym::char, } } - - /// Returns the matching `PrimTy` for a `Symbol` such as "str" or "i32". - /// Returns `None` if no matching type is found. - pub fn from_name(name: Symbol) -> Option { - let ty = match name { - // any changes here should also be reflected in `PrimTy::ALL` - sym::i8 => Self::Int(IntTy::I8), - sym::i16 => Self::Int(IntTy::I16), - sym::i32 => Self::Int(IntTy::I32), - sym::i64 => Self::Int(IntTy::I64), - sym::i128 => Self::Int(IntTy::I128), - sym::isize => Self::Int(IntTy::Isize), - sym::u8 => Self::Uint(UintTy::U8), - sym::u16 => Self::Uint(UintTy::U16), - sym::u32 => Self::Uint(UintTy::U32), - sym::u64 => Self::Uint(UintTy::U64), - sym::u128 => Self::Uint(UintTy::U128), - sym::usize => Self::Uint(UintTy::Usize), - sym::f32 => Self::Float(FloatTy::F32), - sym::f64 => Self::Float(FloatTy::F64), - sym::bool => Self::Bool, - sym::char => Self::Char, - sym::str => Self::Str, - _ => return None, - }; - Some(ty) - } } #[derive(Debug, HashStable_Generic)] diff --git a/compiler/rustc_hir/src/intravisit.rs b/compiler/rustc_hir/src/intravisit.rs index f8b3f0d9b6e23..6c1bee2335a00 100644 --- a/compiler/rustc_hir/src/intravisit.rs +++ b/compiler/rustc_hir/src/intravisit.rs @@ -781,7 +781,6 @@ pub fn walk_assoc_type_binding<'v, V: Visitor<'v>>( ) { visitor.visit_id(type_binding.hir_id); visitor.visit_ident(type_binding.ident); - visitor.visit_generic_args(type_binding.span, type_binding.gen_args); match type_binding.kind { TypeBindingKind::Equality { ref ty } => { visitor.visit_ty(ty); diff --git a/compiler/rustc_hir/src/lib.rs b/compiler/rustc_hir/src/lib.rs index c69a9b063aeca..efc516a662fb7 100644 --- a/compiler/rustc_hir/src/lib.rs +++ b/compiler/rustc_hir/src/lib.rs @@ -6,6 +6,7 @@ #![feature(const_fn)] // For the unsizing cast on `&[]` #![feature(const_panic)] #![feature(in_band_lifetimes)] +#![feature(iterator_fold_self)] #![feature(once_cell)] #![feature(or_patterns)] #![recursion_limit = "256"] diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index 4595855309fda..f1c2a6b7e6e85 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -1840,7 +1840,6 @@ impl<'a> State<'a> { for binding in generic_args.bindings.iter() { start_or_comma(self); self.print_ident(binding.ident); - self.print_generic_args(binding.gen_args, false, false); self.s.space(); match generic_args.bindings[0].kind { hir::TypeBindingKind::Equality { ref ty } => { diff --git a/compiler/rustc_index/src/bit_set.rs b/compiler/rustc_index/src/bit_set.rs index 100824f4b9448..0b501da7cd975 100644 --- a/compiler/rustc_index/src/bit_set.rs +++ b/compiler/rustc_index/src/bit_set.rs @@ -707,18 +707,6 @@ impl GrowableBitSet { self.bit_set.insert(elem) } - /// Returns `true` if the set has changed. - #[inline] - pub fn remove(&mut self, elem: T) -> bool { - self.ensure(elem.index() + 1); - self.bit_set.remove(elem) - } - - #[inline] - pub fn is_empty(&self) -> bool { - self.bit_set.is_empty() - } - #[inline] pub fn contains(&self, elem: T) -> bool { let (word_index, mask) = word_index_and_mask(elem); diff --git a/compiler/rustc_index/src/bit_set/tests.rs b/compiler/rustc_index/src/bit_set/tests.rs index c11b98e77aa58..6cc3e9427d1a7 100644 --- a/compiler/rustc_index/src/bit_set/tests.rs +++ b/compiler/rustc_index/src/bit_set/tests.rs @@ -1,7 +1,6 @@ use super::*; extern crate test; -use std::hint::black_box; use test::Bencher; #[test] @@ -365,36 +364,3 @@ fn union_hybrid_sparse_full_small_domain(b: &mut Bencher) { sparse.union(&dense); }) } - -#[bench] -fn bench_insert(b: &mut Bencher) { - let mut bs = BitSet::new_filled(99999usize); - b.iter(|| { - black_box(bs.insert(black_box(100u32))); - }); -} - -#[bench] -fn bench_remove(b: &mut Bencher) { - let mut bs = BitSet::new_filled(99999usize); - b.iter(|| { - black_box(bs.remove(black_box(100u32))); - }); -} - -#[bench] -fn bench_iter(b: &mut Bencher) { - let bs = BitSet::new_filled(99999usize); - b.iter(|| { - bs.iter().map(|b: usize| black_box(b)).for_each(drop); - }); -} - -#[bench] -fn bench_intersect(b: &mut Bencher) { - let mut ba: BitSet = BitSet::new_filled(99999usize); - let bb = BitSet::new_filled(99999usize); - b.iter(|| { - ba.intersect(black_box(&bb)); - }); -} diff --git a/compiler/rustc_index/src/lib.rs b/compiler/rustc_index/src/lib.rs index 995034e81da28..eaef4c7b54a62 100644 --- a/compiler/rustc_index/src/lib.rs +++ b/compiler/rustc_index/src/lib.rs @@ -8,7 +8,3 @@ pub mod bit_set; pub mod vec; - -// FIXME(#56935): Work around ICEs during cross-compilation. -#[allow(unused)] -extern crate rustc_macros; diff --git a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs index aa4fd055d5ee0..9002d251f1237 100644 --- a/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs +++ b/compiler/rustc_infer/src/infer/canonical/canonicalizer.rs @@ -353,8 +353,10 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> { // `TyVar(vid)` is unresolved, track its universe index in the canonicalized // result. Err(mut ui) => { - // FIXME: perf problem described in #55921. - ui = ty::UniverseIndex::ROOT; + if !self.infcx.unwrap().tcx.sess.opts.debugging_opts.chalk { + // FIXME: perf problem described in #55921. + ui = ty::UniverseIndex::ROOT; + } self.canonicalize_ty_var( CanonicalVarInfo { kind: CanonicalVarKind::Ty(CanonicalTyVarKind::General(ui)), @@ -438,8 +440,10 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> { // `ConstVar(vid)` is unresolved, track its universe index in the // canonicalized result Err(mut ui) => { - // FIXME: perf problem described in #55921. - ui = ty::UniverseIndex::ROOT; + if !self.infcx.unwrap().tcx.sess.opts.debugging_opts.chalk { + // FIXME: perf problem described in #55921. + ui = ty::UniverseIndex::ROOT; + } return self.canonicalize_const_var( CanonicalVarInfo { kind: CanonicalVarKind::Const(ui) }, ct, diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index 84aa19aedebf8..2abb1c725b914 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -1855,7 +1855,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { diag.span_suggestion( span, &format!( - "you might have meant to use field `{}` whose type is `{}`", + "you might have meant to use field `{}` of type `{}`", name, ty ), suggestion, diff --git a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs index 61c8113d05287..0958afa03082a 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs @@ -132,12 +132,7 @@ impl Visitor<'tcx> for TypeParamSpanVisitor<'tcx> { [segment] if segment .res - .map(|res| { - matches!( - res, - Res::SelfTy(_, _) | Res::Def(hir::def::DefKind::TyParam, _) - ) - }) + .map(|res| matches!(res, Res::SelfTy(_, _) | Res::Def(hir::def::DefKind::TyParam, _))) .unwrap_or(false) => { self.types.push(path.span); diff --git a/compiler/rustc_infer/src/infer/lexical_region_resolve/README.md b/compiler/rustc_infer/src/infer/lexical_region_resolve/README.md index 0a7da8c80639c..e0b2c0bffeeb3 100644 --- a/compiler/rustc_infer/src/infer/lexical_region_resolve/README.md +++ b/compiler/rustc_infer/src/infer/lexical_region_resolve/README.md @@ -1,3 +1,4 @@ + Lexical Region Resolution was removed in https://github.com/rust-lang/rust/pull/64790. Rust now uses Non-lexical lifetimes. For more info, please see the [borrowck diff --git a/compiler/rustc_infer/src/traits/util.rs b/compiler/rustc_infer/src/traits/util.rs index 87684c2715f4e..13cf1e1083f7f 100644 --- a/compiler/rustc_infer/src/traits/util.rs +++ b/compiler/rustc_infer/src/traits/util.rs @@ -1,10 +1,9 @@ use smallvec::smallvec; use crate::traits::{Obligation, ObligationCause, PredicateObligation}; -use rustc_data_structures::fx::{FxHashSet, FxIndexSet}; +use rustc_data_structures::fx::FxHashSet; use rustc_middle::ty::outlives::Component; use rustc_middle::ty::{self, ToPredicate, TyCtxt, WithConstness}; -use rustc_span::symbol::Ident; pub fn anonymize_predicate<'tcx>( tcx: TyCtxt<'tcx>, @@ -283,44 +282,6 @@ pub fn transitive_bounds<'tcx>( elaborate_trait_refs(tcx, bounds).filter_to_traits() } -/// A specialized variant of `elaborate_trait_refs` that only elaborates trait references that may -/// define the given associated type `assoc_name`. It uses the -/// `super_predicates_that_define_assoc_type` query to avoid enumerating super-predicates that -/// aren't related to `assoc_item`. This is used when resolving types like `Self::Item` or -/// `T::Item` and helps to avoid cycle errors (see e.g. #35237). -pub fn transitive_bounds_that_define_assoc_type<'tcx>( - tcx: TyCtxt<'tcx>, - bounds: impl Iterator>, - assoc_name: Ident, -) -> impl Iterator> { - let mut stack: Vec<_> = bounds.collect(); - let mut visited = FxIndexSet::default(); - - std::iter::from_fn(move || { - while let Some(trait_ref) = stack.pop() { - let anon_trait_ref = tcx.anonymize_late_bound_regions(trait_ref); - if visited.insert(anon_trait_ref) { - let super_predicates = tcx.super_predicates_that_define_assoc_type(( - trait_ref.def_id(), - Some(assoc_name), - )); - for (super_predicate, _) in super_predicates.predicates { - let bound_predicate = super_predicate.kind(); - let subst_predicate = super_predicate - .subst_supertrait(tcx, &bound_predicate.rebind(trait_ref.skip_binder())); - if let Some(binder) = subst_predicate.to_opt_poly_trait_ref() { - stack.push(binder.value); - } - } - - return Some(trait_ref); - } - } - - return None; - }) -} - /////////////////////////////////////////////////////////////////////////// // Other /////////////////////////////////////////////////////////////////////////// diff --git a/compiler/rustc_interface/src/lib.rs b/compiler/rustc_interface/src/lib.rs index f2b69da3f86b1..0935eb2bd7199 100644 --- a/compiler/rustc_interface/src/lib.rs +++ b/compiler/rustc_interface/src/lib.rs @@ -1,5 +1,4 @@ #![feature(bool_to_option)] -#![feature(box_patterns)] #![feature(box_syntax)] #![feature(internal_output_capture)] #![feature(nll)] diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index b7dc539c6d606..f34990a1a1037 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -759,7 +759,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a, '_> { fn visit_item_kind(&mut self, i: &mut ast::ItemKind) { let is_const = match i { ast::ItemKind::Static(..) | ast::ItemKind::Const(..) => true, - ast::ItemKind::Fn(box ast::FnKind(_, ref sig, _, _)) => Self::is_sig_const(sig), + ast::ItemKind::Fn(_, ref sig, _, _) => Self::is_sig_const(sig), _ => false, }; self.run(is_const, |s| noop_visit_item_kind(i, s)) @@ -768,7 +768,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a, '_> { fn flat_map_trait_item(&mut self, i: P) -> SmallVec<[P; 1]> { let is_const = match i.kind { ast::AssocItemKind::Const(..) => true, - ast::AssocItemKind::Fn(box ast::FnKind(_, ref sig, _, _)) => Self::is_sig_const(sig), + ast::AssocItemKind::Fn(_, ref sig, _, _) => Self::is_sig_const(sig), _ => false, }; self.run(is_const, |s| noop_flat_map_assoc_item(i, s)) diff --git a/compiler/rustc_lint/Cargo.toml b/compiler/rustc_lint/Cargo.toml index 90badd3d573a8..c56eb09b63471 100644 --- a/compiler/rustc_lint/Cargo.toml +++ b/compiler/rustc_lint/Cargo.toml @@ -19,6 +19,5 @@ rustc_data_structures = { path = "../rustc_data_structures" } rustc_feature = { path = "../rustc_feature" } rustc_index = { path = "../rustc_index" } rustc_session = { path = "../rustc_session" } -rustc_serialize = { path = "../rustc_serialize" } rustc_trait_selection = { path = "../rustc_trait_selection" } rustc_parse_format = { path = "../rustc_parse_format" } diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index 20f581625dc31..d0e44550ee6e7 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -328,18 +328,6 @@ impl UnsafeCode { cx.struct_span_lint(UNSAFE_CODE, span, decorate); } - - fn report_overriden_symbol_name(&self, cx: &EarlyContext<'_>, span: Span, msg: &str) { - self.report_unsafe(cx, span, |lint| { - lint.build(msg) - .note( - "the linker's behavior with multiple libraries exporting duplicate symbol \ - names is undefined and Rust cannot provide guarantees when you manually \ - override them", - ) - .emit(); - }) - } } impl EarlyLintPass for UnsafeCode { @@ -369,48 +357,16 @@ impl EarlyLintPass for UnsafeCode { fn check_item(&mut self, cx: &EarlyContext<'_>, it: &ast::Item) { match it.kind { - ast::ItemKind::Trait(box ast::TraitKind(_, ast::Unsafe::Yes(_), ..)) => self - .report_unsafe(cx, it.span, |lint| { + ast::ItemKind::Trait(_, ast::Unsafe::Yes(_), ..) => { + self.report_unsafe(cx, it.span, |lint| { lint.build("declaration of an `unsafe` trait").emit() - }), - - ast::ItemKind::Impl(box ast::ImplKind { unsafety: ast::Unsafe::Yes(_), .. }) => self - .report_unsafe(cx, it.span, |lint| { - lint.build("implementation of an `unsafe` trait").emit() - }), - - ast::ItemKind::Fn(..) => { - if let Some(attr) = cx.sess().find_by_name(&it.attrs, sym::no_mangle) { - self.report_overriden_symbol_name( - cx, - attr.span, - "declaration of a `no_mangle` function", - ); - } - if let Some(attr) = cx.sess().find_by_name(&it.attrs, sym::export_name) { - self.report_overriden_symbol_name( - cx, - attr.span, - "declaration of a function with `export_name`", - ); - } + }) } - ast::ItemKind::Static(..) => { - if let Some(attr) = cx.sess().find_by_name(&it.attrs, sym::no_mangle) { - self.report_overriden_symbol_name( - cx, - attr.span, - "declaration of a `no_mangle` static", - ); - } - if let Some(attr) = cx.sess().find_by_name(&it.attrs, sym::export_name) { - self.report_overriden_symbol_name( - cx, - attr.span, - "declaration of a static with `export_name`", - ); - } + ast::ItemKind::Impl { unsafety: ast::Unsafe::Yes(_), .. } => { + self.report_unsafe(cx, it.span, |lint| { + lint.build("implementation of an `unsafe` trait").emit() + }) } _ => {} @@ -916,7 +872,7 @@ declare_lint_pass!( impl EarlyLintPass for AnonymousParameters { fn check_trait_item(&mut self, cx: &EarlyContext<'_>, it: &ast::AssocItem) { - if let ast::AssocItemKind::Fn(box FnKind(_, ref sig, _, _)) = it.kind { + if let ast::AssocItemKind::Fn(_, ref sig, _, _) = it.kind { for arg in sig.decl.inputs.iter() { if let ast::PatKind::Ident(_, ident, None) = arg.pat.kind { if ident.name == kw::Empty { diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index b8db51f590d84..8bd9dad785c4b 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -21,9 +21,7 @@ use crate::passes::{EarlyLintPassObject, LateLintPassObject}; use rustc_ast as ast; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync; -use rustc_errors::{ - add_elided_lifetime_in_path_suggestion, struct_span_err, Applicability, SuggestionStyle, -}; +use rustc_errors::{add_elided_lifetime_in_path_suggestion, struct_span_err, Applicability}; use rustc_hir as hir; use rustc_hir::def::Res; use rustc_hir::def_id::{CrateNum, DefId}; @@ -34,15 +32,13 @@ use rustc_middle::middle::stability; use rustc_middle::ty::layout::{LayoutError, TyAndLayout}; use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::{self, print::Printer, subst::GenericArg, Ty, TyCtxt}; -use rustc_serialize::json::Json; -use rustc_session::lint::{BuiltinLintDiagnostics, ExternDepSpec}; +use rustc_session::lint::BuiltinLintDiagnostics; use rustc_session::lint::{FutureIncompatibleInfo, Level, Lint, LintBuffer, LintId}; use rustc_session::Session; use rustc_session::SessionLintStore; use rustc_span::lev_distance::find_best_match_for_name; use rustc_span::{symbol::Symbol, MultiSpan, Span, DUMMY_SP}; use rustc_target::abi::LayoutOf; -use tracing::debug; use std::cell::Cell; use std::slice; @@ -340,20 +336,6 @@ impl LintStore { } } - /// True if this symbol represents a lint group name. - pub fn is_lint_group(&self, lint_name: Symbol) -> bool { - debug!( - "is_lint_group(lint_name={:?}, lint_groups={:?})", - lint_name, - self.lint_groups.keys().collect::>() - ); - let lint_name_str = &*lint_name.as_str(); - self.lint_groups.contains_key(&lint_name_str) || { - let warnings_name_str = crate::WARNINGS.name_lower(); - lint_name_str == &*warnings_name_str - } - } - /// Checks the name of a lint for its existence, and whether it was /// renamed or removed. Generates a DiagnosticBuilder containing a /// warning for renamed and removed lints. This is over both lint @@ -639,33 +621,6 @@ pub trait LintContext: Sized { db.span_label(span, "ABI should be specified here"); db.help(&format!("the default ABI is {}", default_abi.name())); } - BuiltinLintDiagnostics::LegacyDeriveHelpers(span) => { - db.span_label(span, "the attribute is introduced here"); - } - BuiltinLintDiagnostics::ExternDepSpec(krate, loc) => { - let json = match loc { - ExternDepSpec::Json(json) => { - db.help(&format!("remove unnecessary dependency `{}`", krate)); - json - } - ExternDepSpec::Raw(raw) => { - db.help(&format!("remove unnecessary dependency `{}` at `{}`", krate, raw)); - db.span_suggestion_with_style( - DUMMY_SP, - "raw extern location", - raw.clone(), - Applicability::Unspecified, - SuggestionStyle::CompletelyHidden, - ); - Json::String(raw) - } - }; - db.tool_only_suggestion_with_metadata( - "json extern location", - Applicability::Unspecified, - json - ); - } } // Rewrap `db`, and pass control to the user. decorate(LintDiagnosticBuilder::new(db)); diff --git a/compiler/rustc_lint/src/early.rs b/compiler/rustc_lint/src/early.rs index 231edf442eb00..e36af2349360f 100644 --- a/compiler/rustc_lint/src/early.rs +++ b/compiler/rustc_lint/src/early.rs @@ -143,14 +143,6 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T> run_early_pass!(self, check_fn, fk, span, id); self.check_id(id); ast_visit::walk_fn(self, fk, span); - - // Explicitly check for lints associated with 'closure_id', since - // it does not have a corresponding AST node - if let ast_visit::FnKind::Fn(_, _, sig, _, _) = fk { - if let ast::Async::Yes { closure_id, .. } = sig.header.asyncness { - self.check_id(closure_id); - } - } run_early_pass!(self, check_fn_post, fk, span, id); } @@ -216,14 +208,6 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T> fn visit_expr_post(&mut self, e: &'a ast::Expr) { run_early_pass!(self, check_expr_post, e); - - // Explicitly check for lints associated with 'closure_id', since - // it does not have a corresponding AST node - match e.kind { - ast::ExprKind::Closure(_, ast::Async::Yes { closure_id, .. }, ..) - | ast::ExprKind::Async(_, closure_id, ..) => self.check_id(closure_id), - _ => {} - } } fn visit_generic_arg(&mut self, arg: &'a ast::GenericArg) { diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index 26e536e8f1ddb..af5972c6c81c7 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -2,7 +2,7 @@ //! Clippy. use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}; -use rustc_ast::{ImplKind, Item, ItemKind}; +use rustc_ast::{Item, ItemKind}; use rustc_data_structures::fx::FxHashMap; use rustc_errors::Applicability; use rustc_hir::def::Res; @@ -243,7 +243,7 @@ declare_lint_pass!(LintPassImpl => [LINT_PASS_IMPL_WITHOUT_MACRO]); impl EarlyLintPass for LintPassImpl { fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) { - if let ItemKind::Impl(box ImplKind { of_trait: Some(lint_pass), .. }) = &item.kind { + if let ItemKind::Impl { of_trait: Some(lint_pass), .. } = &item.kind { if let Some(last) = lint_pass.path.segments.last() { if last.ident.name == sym::LintPass { let expn_data = lint_pass.path.span.ctxt().outer_expn_data(); diff --git a/compiler/rustc_lint/src/levels.rs b/compiler/rustc_lint/src/levels.rs index 1fc2bd0916757..18cd25e5d2aa3 100644 --- a/compiler/rustc_lint/src/levels.rs +++ b/compiler/rustc_lint/src/levels.rs @@ -5,7 +5,7 @@ use rustc_ast::attr; use rustc_ast::unwrap_or; use rustc_ast_pretty::pprust; use rustc_data_structures::fx::FxHashMap; -use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder}; +use rustc_errors::{struct_span_err, Applicability}; use rustc_hir as hir; use rustc_hir::def_id::{CrateNum, LOCAL_CRATE}; use rustc_hir::{intravisit, HirId}; @@ -17,15 +17,11 @@ use rustc_middle::lint::{ }; use rustc_middle::ty::query::Providers; use rustc_middle::ty::TyCtxt; -use rustc_session::lint::{ - builtin::{self, FORBIDDEN_LINT_GROUPS}, - Level, Lint, LintId, -}; +use rustc_session::lint::{builtin, Level, Lint, LintId}; use rustc_session::parse::feature_err; use rustc_session::Session; use rustc_span::symbol::{sym, Symbol}; use rustc_span::{source_map::MultiSpan, Span, DUMMY_SP}; -use tracing::debug; use std::cmp; @@ -55,7 +51,6 @@ pub struct LintLevelsBuilder<'s> { id_to_set: FxHashMap, cur: u32, warn_about_weird_lints: bool, - store: &'s LintStore, } pub struct BuilderPush { @@ -64,14 +59,13 @@ pub struct BuilderPush { } impl<'s> LintLevelsBuilder<'s> { - pub fn new(sess: &'s Session, warn_about_weird_lints: bool, store: &'s LintStore) -> Self { + pub fn new(sess: &'s Session, warn_about_weird_lints: bool, store: &LintStore) -> Self { let mut builder = LintLevelsBuilder { sess, sets: LintLevelSets::new(), cur: 0, id_to_set: Default::default(), warn_about_weird_lints, - store, }; builder.process_command_line(sess, store); assert_eq!(builder.sets.list.len(), 1); @@ -126,75 +120,36 @@ impl<'s> LintLevelsBuilder<'s> { if let (Level::Forbid, old_src) = self.sets.get_lint_level(id.lint, self.cur, Some(&specs), &self.sess) { - // Backwards compatibility check: - // - // We used to not consider `forbid(lint_group)` - // as preventing `allow(lint)` for some lint `lint` in - // `lint_group`. For now, issue a future-compatibility - // warning for this case. - let id_name = id.lint.name_lower(); - let fcw_warning = match old_src { - LintLevelSource::Default => false, - LintLevelSource::Node(symbol, _, _) => self.store.is_lint_group(symbol), - LintLevelSource::CommandLine(symbol, _) => self.store.is_lint_group(symbol), - }; - debug!( - "fcw_warning={:?}, specs.get(&id) = {:?}, old_src={:?}, id_name={:?}", - fcw_warning, specs, old_src, id_name + let mut diag_builder = struct_span_err!( + self.sess, + src.span(), + E0453, + "{}({}) incompatible with previous forbid", + level.as_str(), + src.name(), ); - - let decorate_diag_builder = |mut diag_builder: DiagnosticBuilder<'_>| { - diag_builder.span_label(src.span(), "overruled by previous forbid"); - match old_src { - LintLevelSource::Default => { - diag_builder.note(&format!( - "`forbid` lint level is the default for {}", - id.to_string() - )); - } - LintLevelSource::Node(_, forbid_source_span, reason) => { - diag_builder.span_label(forbid_source_span, "`forbid` level set here"); - if let Some(rationale) = reason { - diag_builder.note(&rationale.as_str()); - } - } - LintLevelSource::CommandLine(_, _) => { - diag_builder.note("`forbid` lint level was set on command line"); + diag_builder.span_label(src.span(), "overruled by previous forbid"); + match old_src { + LintLevelSource::Default => { + diag_builder.note(&format!( + "`forbid` lint level is the default for {}", + id.to_string() + )); + } + LintLevelSource::Node(_, forbid_source_span, reason) => { + diag_builder.span_label(forbid_source_span, "`forbid` level set here"); + if let Some(rationale) = reason { + diag_builder.note(&rationale.as_str()); } } - diag_builder.emit(); - }; - if !fcw_warning { - let diag_builder = struct_span_err!( - self.sess, - src.span(), - E0453, - "{}({}) incompatible with previous forbid", - level.as_str(), - src.name(), - ); - decorate_diag_builder(diag_builder); - } else { - self.struct_lint( - FORBIDDEN_LINT_GROUPS, - Some(src.span().into()), - |diag_builder| { - let diag_builder = diag_builder.build(&format!( - "{}({}) incompatible with previous forbid", - level.as_str(), - src.name(), - )); - decorate_diag_builder(diag_builder); - }, - ); + LintLevelSource::CommandLine(_, _) => { + diag_builder.note("`forbid` lint level was set on command line"); + } } + diag_builder.emit(); - // Retain the forbid lint level, unless we are - // issuing a FCW. In the FCW case, we want to - // respect the new setting. - if !fcw_warning { - return; - } + // Retain the forbid lint level + return; } } specs.insert(id, (level, src)); diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 638b73c27a8d7..2336b52619ab8 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -30,7 +30,6 @@ #![feature(array_windows)] #![feature(bool_to_option)] #![feature(box_syntax)] -#![feature(box_patterns)] #![feature(crate_visibility_modifier)] #![feature(iter_order_by)] #![feature(never_type)] @@ -55,8 +54,8 @@ mod late; mod levels; mod methods; mod non_ascii_idents; -mod non_fmt_panic; mod nonstandard_style; +mod panic_fmt; mod passes; mod redundant_semicolon; mod traits; @@ -81,8 +80,8 @@ use builtin::*; use internal::*; use methods::*; use non_ascii_idents::*; -use non_fmt_panic::NonPanicFmt; use nonstandard_style::*; +use panic_fmt::PanicFmt; use redundant_semicolon::*; use traits::*; use types::*; @@ -169,7 +168,7 @@ macro_rules! late_lint_passes { ClashingExternDeclarations: ClashingExternDeclarations::new(), DropTraitConstraints: DropTraitConstraints, TemporaryCStringAsPtr: TemporaryCStringAsPtr, - NonPanicFmt: NonPanicFmt, + PanicFmt: PanicFmt, ] ); }; diff --git a/compiler/rustc_lint/src/non_fmt_panic.rs b/compiler/rustc_lint/src/non_fmt_panic.rs deleted file mode 100644 index e98297b692c92..0000000000000 --- a/compiler/rustc_lint/src/non_fmt_panic.rs +++ /dev/null @@ -1,197 +0,0 @@ -use crate::{LateContext, LateLintPass, LintContext}; -use rustc_ast as ast; -use rustc_errors::{pluralize, Applicability}; -use rustc_hir as hir; -use rustc_middle::ty; -use rustc_parse_format::{ParseMode, Parser, Piece}; -use rustc_span::{sym, symbol::kw, InnerSpan, Span, Symbol}; - -declare_lint! { - /// The `non_fmt_panic` lint detects `panic!(..)` invocations where the first - /// argument is not a formatting string. - /// - /// ### Example - /// - /// ```rust,no_run - /// panic!("{}"); - /// panic!(123); - /// ``` - /// - /// {{produces}} - /// - /// ### Explanation - /// - /// In Rust 2018 and earlier, `panic!(x)` directly uses `x` as the message. - /// That means that `panic!("{}")` panics with the message `"{}"` instead - /// of using it as a formatting string, and `panic!(123)` will panic with - /// an `i32` as message. - /// - /// Rust 2021 always interprets the first argument as format string. - NON_FMT_PANIC, - Warn, - "detect single-argument panic!() invocations in which the argument is not a format string", - report_in_external_macro -} - -declare_lint_pass!(NonPanicFmt => [NON_FMT_PANIC]); - -impl<'tcx> LateLintPass<'tcx> for NonPanicFmt { - fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) { - if let hir::ExprKind::Call(f, [arg]) = &expr.kind { - if let &ty::FnDef(def_id, _) = cx.typeck_results().expr_ty(f).kind() { - if Some(def_id) == cx.tcx.lang_items().begin_panic_fn() - || Some(def_id) == cx.tcx.lang_items().panic_fn() - || Some(def_id) == cx.tcx.lang_items().panic_str() - { - if let Some(id) = f.span.ctxt().outer_expn_data().macro_def_id { - if cx.tcx.is_diagnostic_item(sym::std_panic_2015_macro, id) - || cx.tcx.is_diagnostic_item(sym::core_panic_2015_macro, id) - { - check_panic(cx, f, arg); - } - } - } - } - } - } -} - -fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tcx hir::Expr<'tcx>) { - if let hir::ExprKind::Lit(lit) = &arg.kind { - if let ast::LitKind::Str(sym, _) = lit.node { - // The argument is a string literal. - check_panic_str(cx, f, arg, &sym.as_str()); - return; - } - } - - // The argument is *not* a string literal. - - let (span, panic) = panic_call(cx, f); - - cx.struct_span_lint(NON_FMT_PANIC, arg.span, |lint| { - let mut l = lint.build("panic message is not a string literal"); - l.note("this is no longer accepted in Rust 2021"); - if span.contains(arg.span) { - l.span_suggestion_verbose( - arg.span.shrink_to_lo(), - "add a \"{}\" format string to Display the message", - "\"{}\", ".into(), - Applicability::MaybeIncorrect, - ); - if panic == sym::std_panic_macro { - l.span_suggestion_verbose( - span.until(arg.span), - "or use std::panic::panic_any instead", - "std::panic::panic_any(".into(), - Applicability::MachineApplicable, - ); - } - } - l.emit(); - }); -} - -fn check_panic_str<'tcx>( - cx: &LateContext<'tcx>, - f: &'tcx hir::Expr<'tcx>, - arg: &'tcx hir::Expr<'tcx>, - fmt: &str, -) { - if !fmt.contains(&['{', '}'][..]) { - // No brace, no problem. - return; - } - - let fmt_span = arg.span.source_callsite(); - - let (snippet, style) = match cx.sess().parse_sess.source_map().span_to_snippet(fmt_span) { - Ok(snippet) => { - // Count the number of `#`s between the `r` and `"`. - let style = snippet.strip_prefix('r').and_then(|s| s.find('"')); - (Some(snippet), style) - } - Err(_) => (None, None), - }; - - let mut fmt_parser = - Parser::new(fmt.as_ref(), style, snippet.clone(), false, ParseMode::Format); - let n_arguments = (&mut fmt_parser).filter(|a| matches!(a, Piece::NextArgument(_))).count(); - - let (span, _) = panic_call(cx, f); - - if n_arguments > 0 && fmt_parser.errors.is_empty() { - let arg_spans: Vec<_> = match &fmt_parser.arg_places[..] { - [] => vec![fmt_span], - v => v.iter().map(|span| fmt_span.from_inner(*span)).collect(), - }; - cx.struct_span_lint(NON_FMT_PANIC, arg_spans, |lint| { - let mut l = lint.build(match n_arguments { - 1 => "panic message contains an unused formatting placeholder", - _ => "panic message contains unused formatting placeholders", - }); - l.note("this message is not used as a format string when given without arguments, but will be in Rust 2021"); - if span.contains(arg.span) { - l.span_suggestion( - arg.span.shrink_to_hi(), - &format!("add the missing argument{}", pluralize!(n_arguments)), - ", ...".into(), - Applicability::HasPlaceholders, - ); - l.span_suggestion( - arg.span.shrink_to_lo(), - "or add a \"{}\" format string to use the message literally", - "\"{}\", ".into(), - Applicability::MachineApplicable, - ); - } - l.emit(); - }); - } else { - let brace_spans: Option> = - snippet.filter(|s| s.starts_with('"') || s.starts_with("r#")).map(|s| { - s.char_indices() - .filter(|&(_, c)| c == '{' || c == '}') - .map(|(i, _)| fmt_span.from_inner(InnerSpan { start: i, end: i + 1 })) - .collect() - }); - let msg = match &brace_spans { - Some(v) if v.len() == 1 => "panic message contains a brace", - _ => "panic message contains braces", - }; - cx.struct_span_lint(NON_FMT_PANIC, brace_spans.unwrap_or(vec![span]), |lint| { - let mut l = lint.build(msg); - l.note("this message is not used as a format string, but will be in Rust 2021"); - if span.contains(arg.span) { - l.span_suggestion( - arg.span.shrink_to_lo(), - "add a \"{}\" format string to use the message literally", - "\"{}\", ".into(), - Applicability::MachineApplicable, - ); - } - l.emit(); - }); - } -} - -fn panic_call<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>) -> (Span, Symbol) { - let mut expn = f.span.ctxt().outer_expn_data(); - - let mut panic_macro = kw::Empty; - - // Unwrap more levels of macro expansion, as panic_2015!() - // was likely expanded from panic!() and possibly from - // [debug_]assert!(). - for &i in - &[sym::std_panic_macro, sym::core_panic_macro, sym::assert_macro, sym::debug_assert_macro] - { - let parent = expn.call_site.ctxt().outer_expn_data(); - if parent.macro_def_id.map_or(false, |id| cx.tcx.is_diagnostic_item(i, id)) { - expn = parent; - panic_macro = i; - } - } - - (expn.call_site, panic_macro) -} diff --git a/compiler/rustc_lint/src/panic_fmt.rs b/compiler/rustc_lint/src/panic_fmt.rs new file mode 100644 index 0000000000000..4a6aca72acbbe --- /dev/null +++ b/compiler/rustc_lint/src/panic_fmt.rs @@ -0,0 +1,155 @@ +use crate::{LateContext, LateLintPass, LintContext}; +use rustc_ast as ast; +use rustc_errors::{pluralize, Applicability}; +use rustc_hir as hir; +use rustc_middle::ty; +use rustc_parse_format::{ParseMode, Parser, Piece}; +use rustc_span::{sym, InnerSpan}; + +declare_lint! { + /// The `panic_fmt` lint detects `panic!("..")` with `{` or `}` in the string literal. + /// + /// ### Example + /// + /// ```rust,no_run + /// panic!("{}"); + /// ``` + /// + /// {{produces}} + /// + /// ### Explanation + /// + /// In Rust 2018 and earlier, `panic!("{}")` panics with the message `"{}"`, + /// as a `panic!()` invocation with a single argument does not use `format_args!()`. + /// Rust 2021 interprets this string as format string, which breaks this. + PANIC_FMT, + Warn, + "detect braces in single-argument panic!() invocations", + report_in_external_macro +} + +declare_lint_pass!(PanicFmt => [PANIC_FMT]); + +impl<'tcx> LateLintPass<'tcx> for PanicFmt { + fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) { + if let hir::ExprKind::Call(f, [arg]) = &expr.kind { + if let &ty::FnDef(def_id, _) = cx.typeck_results().expr_ty(f).kind() { + if Some(def_id) == cx.tcx.lang_items().begin_panic_fn() + || Some(def_id) == cx.tcx.lang_items().panic_fn() + { + check_panic(cx, f, arg); + } + } + } + } +} + +fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tcx hir::Expr<'tcx>) { + if let hir::ExprKind::Lit(lit) = &arg.kind { + if let ast::LitKind::Str(sym, _) = lit.node { + let mut expn = f.span.ctxt().outer_expn_data(); + if let Some(id) = expn.macro_def_id { + if cx.tcx.is_diagnostic_item(sym::std_panic_2015_macro, id) + || cx.tcx.is_diagnostic_item(sym::core_panic_2015_macro, id) + { + let fmt = sym.as_str(); + if !fmt.contains(&['{', '}'][..]) { + return; + } + + let fmt_span = arg.span.source_callsite(); + + let (snippet, style) = + match cx.sess().parse_sess.source_map().span_to_snippet(fmt_span) { + Ok(snippet) => { + // Count the number of `#`s between the `r` and `"`. + let style = snippet.strip_prefix('r').and_then(|s| s.find('"')); + (Some(snippet), style) + } + Err(_) => (None, None), + }; + + let mut fmt_parser = + Parser::new(fmt.as_ref(), style, snippet.clone(), false, ParseMode::Format); + let n_arguments = + (&mut fmt_parser).filter(|a| matches!(a, Piece::NextArgument(_))).count(); + + // Unwrap more levels of macro expansion, as panic_2015!() + // was likely expanded from panic!() and possibly from + // [debug_]assert!(). + for &assert in &[ + sym::std_panic_macro, + sym::core_panic_macro, + sym::assert_macro, + sym::debug_assert_macro, + ] { + let parent = expn.call_site.ctxt().outer_expn_data(); + if parent + .macro_def_id + .map_or(false, |id| cx.tcx.is_diagnostic_item(assert, id)) + { + expn = parent; + } + } + + if n_arguments > 0 && fmt_parser.errors.is_empty() { + let arg_spans: Vec<_> = match &fmt_parser.arg_places[..] { + [] => vec![fmt_span], + v => v.iter().map(|span| fmt_span.from_inner(*span)).collect(), + }; + cx.struct_span_lint(PANIC_FMT, arg_spans, |lint| { + let mut l = lint.build(match n_arguments { + 1 => "panic message contains an unused formatting placeholder", + _ => "panic message contains unused formatting placeholders", + }); + l.note("this message is not used as a format string when given without arguments, but will be in a future Rust edition"); + if expn.call_site.contains(arg.span) { + l.span_suggestion( + arg.span.shrink_to_hi(), + &format!("add the missing argument{}", pluralize!(n_arguments)), + ", ...".into(), + Applicability::HasPlaceholders, + ); + l.span_suggestion( + arg.span.shrink_to_lo(), + "or add a \"{}\" format string to use the message literally", + "\"{}\", ".into(), + Applicability::MachineApplicable, + ); + } + l.emit(); + }); + } else { + let brace_spans: Option> = snippet + .filter(|s| s.starts_with('"') || s.starts_with("r#")) + .map(|s| { + s.char_indices() + .filter(|&(_, c)| c == '{' || c == '}') + .map(|(i, _)| { + fmt_span.from_inner(InnerSpan { start: i, end: i + 1 }) + }) + .collect() + }); + let msg = match &brace_spans { + Some(v) if v.len() == 1 => "panic message contains a brace", + _ => "panic message contains braces", + }; + cx.struct_span_lint(PANIC_FMT, brace_spans.unwrap_or(vec![expn.call_site]), |lint| { + let mut l = lint.build(msg); + l.note("this message is not used as a format string, but will be in a future Rust edition"); + if expn.call_site.contains(arg.span) { + l.span_suggestion( + arg.span.shrink_to_lo(), + "add a \"{}\" format string to use the message literally", + "\"{}\", ".into(), + Applicability::MachineApplicable, + ); + } + l.emit(); + }); + } + } + } + } + } +} diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index f0a5ea150b719..a8bf1ce51bb74 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -1,5 +1,4 @@ // ignore-tidy-filelength - //! Some lints that are built in to the compiler. //! //! These are the built-in lints that are emitted direct in the main @@ -10,42 +9,6 @@ use crate::{declare_lint, declare_lint_pass}; use rustc_span::edition::Edition; use rustc_span::symbol::sym; -declare_lint! { - /// The `forbidden_lint_groups` lint detects violations of - /// `forbid` applied to a lint group. Due to a bug in the compiler, - /// these used to be overlooked entirely. They now generate a warning. - /// - /// ### Example - /// - /// ```rust - /// #![forbid(warnings)] - /// #![deny(bad_style)] - /// - /// fn main() {} - /// ``` - /// - /// {{produces}} - /// - /// ### Recommended fix - /// - /// If your crate is using `#![forbid(warnings)]`, - /// we recommend that you change to `#![deny(warnings)]`. - /// - /// ### Explanation - /// - /// Due to a compiler bug, applying `forbid` to lint groups - /// previously had no effect. The bug is now fixed but instead of - /// enforcing `forbid` we issue this future-compatibility warning - /// to avoid breaking existing crates. - pub FORBIDDEN_LINT_GROUPS, - Warn, - "applying forbid to lint-groups", - @future_incompatible = FutureIncompatibleInfo { - reference: "issue #81670 ", - edition: None, - }; -} - declare_lint! { /// The `ill_formed_attribute_input` lint detects ill-formed attribute /// inputs that were previously accepted and used in practice. @@ -292,10 +255,6 @@ declare_lint! { pub CONST_ERR, Deny, "constant evaluation encountered erroneous expression", - @future_incompatible = FutureIncompatibleInfo { - reference: "issue #71800 ", - edition: None, - }; report_in_external_macro } @@ -2921,57 +2880,10 @@ declare_lint! { }; } -declare_lint! { - /// The `legacy_derive_helpers` lint detects derive helper attributes - /// that are used before they are introduced. - /// - /// ### Example - /// - /// ```rust,ignore (needs extern crate) - /// #[serde(rename_all = "camelCase")] - /// #[derive(Deserialize)] - /// struct S { /* fields */ } - /// ``` - /// - /// produces: - /// - /// ```text - /// warning: derive helper attribute is used before it is introduced - /// --> $DIR/legacy-derive-helpers.rs:1:3 - /// | - /// 1 | #[serde(rename_all = "camelCase")] - /// | ^^^^^ - /// ... - /// 2 | #[derive(Deserialize)] - /// | ----------- the attribute is introduced here - /// ``` - /// - /// ### Explanation - /// - /// Attributes like this work for historical reasons, but attribute expansion works in - /// left-to-right order in general, so, to resolve `#[serde]`, compiler has to try to "look - /// into the future" at not yet expanded part of the item , but such attempts are not always - /// reliable. - /// - /// To fix the warning place the helper attribute after its corresponding derive. - /// ```rust,ignore (needs extern crate) - /// #[derive(Deserialize)] - /// #[serde(rename_all = "camelCase")] - /// struct S { /* fields */ } - /// ``` - pub LEGACY_DERIVE_HELPERS, - Warn, - "detects derive helper attributes that are used before they are introduced", - @future_incompatible = FutureIncompatibleInfo { - reference: "issue #79202 ", - }; -} - declare_lint_pass! { /// Does nothing as a lint pass, but registers some `Lint`s /// that are used by other parts of the compiler. HardwiredLints => [ - FORBIDDEN_LINT_GROUPS, ILLEGAL_FLOATING_POINT_LITERAL_PATTERN, ARITHMETIC_OVERFLOW, UNCONDITIONAL_PANIC, @@ -3056,8 +2968,6 @@ declare_lint_pass! { UNSUPPORTED_NAKED_FUNCTIONS, MISSING_ABI, SEMICOLON_IN_EXPRESSIONS_FROM_MACROS, - DISJOINT_CAPTURE_DROP_REORDER, - LEGACY_DERIVE_HELPERS, ] } @@ -3084,51 +2994,6 @@ declare_lint! { "detects doc comments that aren't used by rustdoc" } -declare_lint! { - /// The `disjoint_capture_drop_reorder` lint detects variables that aren't completely - /// captured when the feature `capture_disjoint_fields` is enabled and it affects the Drop - /// order of at least one path starting at this variable. - /// - /// ### Example - /// - /// ```rust,compile_fail - /// # #![deny(disjoint_capture_drop_reorder)] - /// # #![allow(unused)] - /// struct FancyInteger(i32); - /// - /// impl Drop for FancyInteger { - /// fn drop(&mut self) { - /// println!("Just dropped {}", self.0); - /// } - /// } - /// - /// struct Point { x: FancyInteger, y: FancyInteger } - /// - /// fn main() { - /// let p = Point { x: FancyInteger(10), y: FancyInteger(20) }; - /// - /// let c = || { - /// let x = p.x; - /// }; - /// - /// c(); - /// - /// // ... More code ... - /// } - /// ``` - /// - /// {{produces}} - /// - /// ### Explanation - /// - /// In the above example `p.y` will be dropped at the end of `f` instead of with `c` if - /// the feature `capture_disjoint_fields` is enabled. - pub DISJOINT_CAPTURE_DROP_REORDER, - Allow, - "Drop reorder because of `capture_disjoint_fields`" - -} - declare_lint_pass!(UnusedDocComment => [UNUSED_DOC_COMMENTS]); declare_lint! { diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index 4c7d3f6c8c072..9d60a51a0afb3 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -4,7 +4,6 @@ extern crate rustc_macros; pub use self::Level::*; use rustc_ast::node_id::{NodeId, NodeMap}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey}; -use rustc_serialize::json::Json; use rustc_span::edition::Edition; use rustc_span::{sym, symbol::Ident, MultiSpan, Span, Symbol}; use rustc_target::spec::abi::Abi; @@ -240,13 +239,6 @@ impl ToStableHashKey for LintId { } } -// Duplicated from rustc_session::config::ExternDepSpec to avoid cyclic dependency -#[derive(PartialEq)] -pub enum ExternDepSpec { - Json(Json), - Raw(String), -} - // This could be a closure, but then implementing derive trait // becomes hacky (and it gets allocated). #[derive(PartialEq)] @@ -264,8 +256,6 @@ pub enum BuiltinLintDiagnostics { MissingAbi(Span, Abi), UnusedDocComment(Span), PatternsInFnsWithoutBody(Span, Ident), - LegacyDeriveHelpers(Span), - ExternDepSpec(String, ExternDepSpec), } /// Lints that are buffered up early on in the `Session` before the diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index 4118e93074563..1d89fc8049660 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -216,14 +216,6 @@ extern "C" void LLVMRustAddCallSiteAttribute(LLVMValueRef Instr, unsigned Index, Call->addAttribute(Index, Attr); } -extern "C" void LLVMRustAddCallSiteAttrString(LLVMValueRef Instr, unsigned Index, - const char *Name) { - CallBase *Call = unwrap(Instr); - Attribute Attr = Attribute::get(Call->getContext(), Name); - Call->addAttribute(Index, Attr); -} - - extern "C" void LLVMRustAddAlignmentCallSiteAttr(LLVMValueRef Instr, unsigned Index, uint32_t Bytes) { diff --git a/compiler/rustc_macros/src/query.rs b/compiler/rustc_macros/src/query.rs index bd20c7689ea2e..d264462bf0895 100644 --- a/compiler/rustc_macros/src/query.rs +++ b/compiler/rustc_macros/src/query.rs @@ -189,6 +189,25 @@ impl Parse for List { } } +/// A named group containing queries. +/// +/// For now, the name is not used any more, but the capability remains interesting for future +/// developments of the query system. +struct Group { + #[allow(unused)] + name: Ident, + queries: List, +} + +impl Parse for Group { + fn parse(input: ParseStream<'_>) -> Result { + let name: Ident = input.parse()?; + let content; + braced!(content in input); + Ok(Group { name, queries: content.parse()? }) + } +} + struct QueryModifiers { /// The description of the query. desc: (Option, Punctuated), @@ -417,8 +436,8 @@ fn add_query_description_impl( fn describe( #tcx: TyCtxt<'tcx>, #key: #arg, - ) -> String { - ::rustc_middle::ty::print::with_no_trimmed_paths(|| format!(#desc)) + ) -> Cow<'static, str> { + ::rustc_middle::ty::print::with_no_trimmed_paths(|| format!(#desc).into()) } }; @@ -431,70 +450,72 @@ fn add_query_description_impl( } pub fn rustc_queries(input: TokenStream) -> TokenStream { - let queries = parse_macro_input!(input as List); + let groups = parse_macro_input!(input as List); let mut query_stream = quote! {}; let mut query_description_stream = quote! {}; let mut dep_node_def_stream = quote! {}; let mut cached_queries = quote! {}; - for mut query in queries.0 { - let modifiers = process_modifiers(&mut query); - let name = &query.name; - let arg = &query.arg; - let result_full = &query.result; - let result = match query.result { - ReturnType::Default => quote! { -> () }, - _ => quote! { #result_full }, - }; + for group in groups.0 { + for mut query in group.queries.0 { + let modifiers = process_modifiers(&mut query); + let name = &query.name; + let arg = &query.arg; + let result_full = &query.result; + let result = match query.result { + ReturnType::Default => quote! { -> () }, + _ => quote! { #result_full }, + }; - if modifiers.cache.is_some() { - cached_queries.extend(quote! { - #name, - }); - } + if modifiers.cache.is_some() { + cached_queries.extend(quote! { + #name, + }); + } - let mut attributes = Vec::new(); + let mut attributes = Vec::new(); - // Pass on the fatal_cycle modifier - if modifiers.fatal_cycle { - attributes.push(quote! { fatal_cycle }); - }; - // Pass on the storage modifier - if let Some(ref ty) = modifiers.storage { - attributes.push(quote! { storage(#ty) }); - }; - // Pass on the cycle_delay_bug modifier - if modifiers.cycle_delay_bug { - attributes.push(quote! { cycle_delay_bug }); - }; - // Pass on the no_hash modifier - if modifiers.no_hash { - attributes.push(quote! { no_hash }); - }; - // Pass on the anon modifier - if modifiers.anon { - attributes.push(quote! { anon }); - }; - // Pass on the eval_always modifier - if modifiers.eval_always { - attributes.push(quote! { eval_always }); - }; + // Pass on the fatal_cycle modifier + if modifiers.fatal_cycle { + attributes.push(quote! { fatal_cycle }); + }; + // Pass on the storage modifier + if let Some(ref ty) = modifiers.storage { + attributes.push(quote! { storage(#ty) }); + }; + // Pass on the cycle_delay_bug modifier + if modifiers.cycle_delay_bug { + attributes.push(quote! { cycle_delay_bug }); + }; + // Pass on the no_hash modifier + if modifiers.no_hash { + attributes.push(quote! { no_hash }); + }; + // Pass on the anon modifier + if modifiers.anon { + attributes.push(quote! { anon }); + }; + // Pass on the eval_always modifier + if modifiers.eval_always { + attributes.push(quote! { eval_always }); + }; - let attribute_stream = quote! {#(#attributes),*}; - let doc_comments = query.doc_comments.iter(); - // Add the query to the group - query_stream.extend(quote! { - #(#doc_comments)* - [#attribute_stream] fn #name(#arg) #result, - }); + let attribute_stream = quote! {#(#attributes),*}; + let doc_comments = query.doc_comments.iter(); + // Add the query to the group + query_stream.extend(quote! { + #(#doc_comments)* + [#attribute_stream] fn #name(#arg) #result, + }); - // Create a dep node for the query - dep_node_def_stream.extend(quote! { - [#attribute_stream] #name(#arg), - }); + // Create a dep node for the query + dep_node_def_stream.extend(quote! { + [#attribute_stream] #name(#arg), + }); - add_query_description_impl(&query, modifiers, &mut query_description_stream); + add_query_description_impl(&query, modifiers, &mut query_description_stream); + } } TokenStream::from(quote! { diff --git a/compiler/rustc_metadata/src/creader.rs b/compiler/rustc_metadata/src/creader.rs index 63c6f369eb685..e3fbd1a2b29ea 100644 --- a/compiler/rustc_metadata/src/creader.rs +++ b/compiler/rustc_metadata/src/creader.rs @@ -16,9 +16,8 @@ use rustc_index::vec::IndexVec; use rustc_middle::middle::cstore::{CrateDepKind, CrateSource, ExternCrate}; use rustc_middle::middle::cstore::{ExternCrateSource, MetadataLoaderDyn}; use rustc_middle::ty::TyCtxt; -use rustc_serialize::json::ToJson; use rustc_session::config::{self, CrateType, ExternLocation}; -use rustc_session::lint::{self, BuiltinLintDiagnostics, ExternDepSpec}; +use rustc_session::lint; use rustc_session::output::validate_crate_name; use rustc_session::search_paths::PathKind; use rustc_session::{CrateDisambiguator, Session}; @@ -28,7 +27,6 @@ use rustc_span::{Span, DUMMY_SP}; use rustc_target::spec::{PanicStrategy, TargetTriple}; use proc_macro::bridge::client::ProcMacro; -use std::collections::BTreeMap; use std::path::Path; use std::{cmp, env}; use tracing::{debug, info}; @@ -873,25 +871,8 @@ impl<'a> CrateLoader<'a> { // Don't worry about pathless `--extern foo` sysroot references continue; } - if self.used_extern_options.contains(&Symbol::intern(name)) { - continue; - } - - // Got a real unused --extern - let diag = match self.sess.opts.extern_dep_specs.get(name) { - Some(loc) => BuiltinLintDiagnostics::ExternDepSpec(name.clone(), loc.into()), - None => { - // If we don't have a specific location, provide a json encoding of the `--extern` - // option. - let meta: BTreeMap = - std::iter::once(("name".to_string(), name.to_string())).collect(); - BuiltinLintDiagnostics::ExternDepSpec( - name.clone(), - ExternDepSpec::Json(meta.to_json()), - ) - } - }; - self.sess.parse_sess.buffer_lint_with_diagnostic( + if !self.used_extern_options.contains(&Symbol::intern(name)) { + self.sess.parse_sess.buffer_lint( lint::builtin::UNUSED_CRATE_DEPENDENCIES, span, ast::CRATE_NODE_ID, @@ -900,8 +881,8 @@ impl<'a> CrateLoader<'a> { name, self.local_crate_name, name), - diag, ); + } } } diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 14ca51008bec5..3961adacecae8 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -2,15 +2,15 @@ use crate::rmeta::table::{FixedSizeEncoding, TableBuilder}; use crate::rmeta::*; use rustc_data_structures::fingerprint::{Fingerprint, FingerprintEncoder}; -use rustc_data_structures::fx::{FxHashMap, FxIndexSet}; +use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet}; use rustc_data_structures::stable_hasher::StableHasher; -use rustc_data_structures::sync::{join, par_iter, Lrc, ParallelIterator}; +use rustc_data_structures::sync::{join, Lrc}; use rustc_hir as hir; use rustc_hir::def::{CtorOf, DefKind}; use rustc_hir::def_id::{CrateNum, DefId, DefIndex, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE}; use rustc_hir::definitions::DefPathData; use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; -use rustc_hir::itemlikevisit::ItemLikeVisitor; +use rustc_hir::itemlikevisit::{ItemLikeVisitor, ParItemLikeVisitor}; use rustc_hir::lang_items; use rustc_hir::{AnonConst, GenericParamKind}; use rustc_index::bit_set::GrowableBitSet; @@ -65,6 +65,11 @@ pub(super) struct EncodeContext<'a, 'tcx> { required_source_files: Option>, is_proc_macro: bool, hygiene_ctxt: &'a HygieneEncodeContext, + + // Determines if MIR used for code generation will be included in the crate + // metadata. When emitting only metadata (e.g., cargo check), we can avoid + // generating optimized MIR altogether. + emit_codegen_mir: bool, } /// If the current crate is a proc-macro, returns early with `Lazy:empty()`. @@ -572,11 +577,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { let tcx = self.tcx; - // Encode MIR. - i = self.position(); - self.encode_mir(); - let mir_bytes = self.position() - i; - // Encode the items. i = self.position(); self.encode_def_ids(); @@ -704,7 +704,6 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { println!(" exp. symbols bytes: {}", exported_symbols_bytes); println!(" def-path table bytes: {}", def_path_table_bytes); println!(" proc-macro-data-bytes: {}", proc_macro_data_bytes); - println!(" mir bytes: {}", mir_bytes); println!(" item bytes: {}", item_bytes); println!(" table bytes: {}", tables_bytes); println!(" hygiene bytes: {}", hygiene_bytes); @@ -786,53 +785,6 @@ fn should_encode_stability(def_kind: DefKind) -> bool { } } -/// Whether we should encode MIR. -/// -/// Computing, optimizing and encoding the MIR is a relatively expensive operation. -/// We want to avoid this work when not required. Therefore: -/// - we only compute `mir_for_ctfe` on items with const-eval semantics; -/// - we skip `optimized_mir` for check runs. -/// -/// Return a pair, resp. for CTFE and for LLVM. -fn should_encode_mir(tcx: TyCtxt<'_>, def_id: LocalDefId) -> (bool, bool) { - match tcx.def_kind(def_id) { - // Constructors - DefKind::Ctor(_, _) => { - let mir_opt_base = tcx.sess.opts.output_types.should_codegen() - || tcx.sess.opts.debugging_opts.always_encode_mir; - (true, mir_opt_base) - } - // Constants - DefKind::AnonConst | DefKind::AssocConst | DefKind::Static | DefKind::Const => { - (true, false) - } - // Full-fledged functions - DefKind::AssocFn | DefKind::Fn => { - let generics = tcx.generics_of(def_id); - let needs_inline = (generics.requires_monomorphization(tcx) - || tcx.codegen_fn_attrs(def_id).requests_inline()) - && tcx.sess.opts.output_types.should_codegen(); - // Only check the presence of the `const` modifier. - let is_const_fn = tcx.is_const_fn_raw(def_id.to_def_id()); - let always_encode_mir = tcx.sess.opts.debugging_opts.always_encode_mir; - (is_const_fn, needs_inline || always_encode_mir) - } - // Closures can't be const fn. - DefKind::Closure => { - let generics = tcx.generics_of(def_id); - let needs_inline = (generics.requires_monomorphization(tcx) - || tcx.codegen_fn_attrs(def_id).requests_inline()) - && tcx.sess.opts.output_types.should_codegen(); - let always_encode_mir = tcx.sess.opts.debugging_opts.always_encode_mir; - (false, needs_inline || always_encode_mir) - } - // Generators require optimized MIR to compute layout. - DefKind::Generator => (false, true), - // The others don't have MIR. - _ => (false, false), - } -} - impl EncodeContext<'a, 'tcx> { fn encode_def_ids(&mut self) { if self.is_proc_macro { @@ -930,6 +882,11 @@ impl EncodeContext<'a, 'tcx> { self.encode_generics(def_id); self.encode_explicit_predicates(def_id); self.encode_inferred_outlives(def_id); + let opt_mir = tcx.sess.opts.debugging_opts.always_encode_mir || self.emit_codegen_mir; + if opt_mir { + self.encode_optimized_mir(def_id.expect_local()); + } + self.encode_mir_for_ctfe(def_id.expect_local()); } fn encode_info_for_mod(&mut self, id: hir::HirId, md: &hir::Mod<'_>) { @@ -1015,6 +972,11 @@ impl EncodeContext<'a, 'tcx> { self.encode_generics(def_id); self.encode_explicit_predicates(def_id); self.encode_inferred_outlives(def_id); + let opt_mir = tcx.sess.opts.debugging_opts.always_encode_mir || self.emit_codegen_mir; + if opt_mir { + self.encode_optimized_mir(def_id.expect_local()); + } + self.encode_mir_for_ctfe(def_id.expect_local()); } fn encode_generics(&mut self, def_id: DefId) { @@ -1120,6 +1082,34 @@ impl EncodeContext<'a, 'tcx> { self.encode_generics(def_id); self.encode_explicit_predicates(def_id); self.encode_inferred_outlives(def_id); + + // This should be kept in sync with `PrefetchVisitor.visit_trait_item`. + match trait_item.kind { + ty::AssocKind::Type => {} + ty::AssocKind::Const => { + if self.tcx.mir_keys(LOCAL_CRATE).contains(&def_id.expect_local()) { + self.encode_mir_for_ctfe(def_id.expect_local()); + self.encode_promoted_mir(def_id.expect_local()); + } + } + ty::AssocKind::Fn => { + let opt_mir = + tcx.sess.opts.debugging_opts.always_encode_mir || self.emit_codegen_mir; + if opt_mir { + if self.tcx.mir_keys(LOCAL_CRATE).contains(&def_id.expect_local()) { + self.encode_optimized_mir(def_id.expect_local()); + self.encode_promoted_mir(def_id.expect_local()); + } + } + } + } + } + + fn should_encode_fn_opt_mir(&self, def_id: DefId) -> bool { + self.tcx.sess.opts.debugging_opts.always_encode_mir + || (self.emit_codegen_mir + && (self.tcx.generics_of(def_id).requires_monomorphization(self.tcx) + || self.tcx.codegen_fn_attrs(def_id).requests_inline())) } fn encode_info_for_impl_item(&mut self, def_id: DefId) { @@ -1181,6 +1171,27 @@ impl EncodeContext<'a, 'tcx> { self.encode_generics(def_id); self.encode_explicit_predicates(def_id); self.encode_inferred_outlives(def_id); + + // The following part should be kept in sync with `PrefetchVisitor.visit_impl_item`. + + let (mir, mir_const) = match ast_item.kind { + hir::ImplItemKind::Const(..) => (false, true), + hir::ImplItemKind::Fn(ref sig, _) => { + let opt_mir = self.should_encode_fn_opt_mir(def_id); + let is_const_fn = sig.header.constness == hir::Constness::Const; + (opt_mir, is_const_fn) + } + hir::ImplItemKind::TyAlias(..) => (false, false), + }; + if mir { + self.encode_optimized_mir(def_id.expect_local()); + } + if mir || mir_const { + self.encode_promoted_mir(def_id.expect_local()); + } + if mir_const { + self.encode_mir_for_ctfe(def_id.expect_local()); + } } fn encode_fn_param_names_for_body(&mut self, body_id: hir::BodyId) -> Lazy<[Ident]> { @@ -1191,50 +1202,36 @@ impl EncodeContext<'a, 'tcx> { self.lazy(param_names.iter()) } - fn encode_mir(&mut self) { - if self.is_proc_macro { - return; - } + fn encode_mir_for_ctfe(&mut self, def_id: LocalDefId) { + debug!("EntryBuilder::encode_mir_for_ctfe({:?})", def_id); + record!(self.tables.mir_for_ctfe[def_id.to_def_id()] <- self.tcx.mir_for_ctfe(def_id)); - let mut keys_and_jobs = self - .tcx - .mir_keys(LOCAL_CRATE) - .iter() - .filter_map(|&def_id| { - let (encode_const, encode_opt) = should_encode_mir(self.tcx, def_id); - if encode_const || encode_opt { - Some((def_id, encode_const, encode_opt)) - } else { - None - } - }) - .collect::>(); - // Sort everything to ensure a stable order for diagnotics. - keys_and_jobs.sort_by_key(|&(def_id, _, _)| def_id); - for (def_id, encode_const, encode_opt) in keys_and_jobs.into_iter() { - debug_assert!(encode_const || encode_opt); + let unused = self.tcx.unused_generic_params(def_id); + if !unused.is_empty() { + record!(self.tables.unused_generic_params[def_id.to_def_id()] <- unused); + } - debug!("EntryBuilder::encode_mir({:?})", def_id); - if encode_opt { - record!(self.tables.mir[def_id.to_def_id()] <- self.tcx.optimized_mir(def_id)); - } - if encode_const { - record!(self.tables.mir_for_ctfe[def_id.to_def_id()] <- self.tcx.mir_for_ctfe(def_id)); + let abstract_const = self.tcx.mir_abstract_const(def_id); + if let Ok(Some(abstract_const)) = abstract_const { + record!(self.tables.mir_abstract_consts[def_id.to_def_id()] <- abstract_const); + } + } - let abstract_const = self.tcx.mir_abstract_const(def_id); - if let Ok(Some(abstract_const)) = abstract_const { - record!(self.tables.mir_abstract_consts[def_id.to_def_id()] <- abstract_const); - } - } - record!(self.tables.promoted_mir[def_id.to_def_id()] <- self.tcx.promoted_mir(def_id)); + fn encode_optimized_mir(&mut self, def_id: LocalDefId) { + debug!("EntryBuilder::encode_optimized_mir({:?})", def_id); + record!(self.tables.mir[def_id.to_def_id()] <- self.tcx.optimized_mir(def_id)); - let unused = self.tcx.unused_generic_params(def_id); - if !unused.is_empty() { - record!(self.tables.unused_generic_params[def_id.to_def_id()] <- unused); - } + let unused = self.tcx.unused_generic_params(def_id); + if !unused.is_empty() { + record!(self.tables.unused_generic_params[def_id.to_def_id()] <- unused); } } + fn encode_promoted_mir(&mut self, def_id: LocalDefId) { + debug!("EncodeContext::encode_promoted_mir({:?})", def_id); + record!(self.tables.promoted_mir[def_id.to_def_id()] <- self.tcx.promoted_mir(def_id)); + } + // Encodes the inherent implementations of a structure, enumeration, or trait. fn encode_inherent_implementations(&mut self, def_id: DefId) { debug!("EncodeContext::encode_inherent_implementations({:?})", def_id); @@ -1490,6 +1487,28 @@ impl EncodeContext<'a, 'tcx> { } _ => {} } + + // The following part should be kept in sync with `PrefetchVisitor.visit_item`. + + let (mir, const_mir) = match item.kind { + hir::ItemKind::Static(..) | hir::ItemKind::Const(..) => (false, true), + hir::ItemKind::Fn(ref sig, ..) => { + let opt_mir = self.should_encode_fn_opt_mir(def_id); + let is_const_fn = sig.header.constness == hir::Constness::Const; + // We don't need the optimized MIR for const fns. + (opt_mir, is_const_fn) + } + _ => (false, false), + }; + if mir { + self.encode_optimized_mir(def_id.expect_local()); + } + if mir || const_mir { + self.encode_promoted_mir(def_id.expect_local()); + } + if const_mir { + self.encode_mir_for_ctfe(def_id.expect_local()); + } } /// Serialize the text of exported macros @@ -1531,6 +1550,14 @@ impl EncodeContext<'a, 'tcx> { record!(self.tables.fn_sig[def_id] <- substs.as_closure().sig()); } self.encode_generics(def_id.to_def_id()); + let opt_mir = // FIXME: Optimized MIR is necessary to determine the layout of generators. + matches!(ty.kind(), ty::Generator(..)) + || self.tcx.sess.opts.debugging_opts.always_encode_mir + || self.emit_codegen_mir; + if opt_mir { + self.encode_optimized_mir(def_id); + self.encode_promoted_mir(def_id); + } } fn encode_info_for_anon_const(&mut self, def_id: LocalDefId) { @@ -1545,6 +1572,8 @@ impl EncodeContext<'a, 'tcx> { self.encode_generics(def_id.to_def_id()); self.encode_explicit_predicates(def_id.to_def_id()); self.encode_inferred_outlives(def_id.to_def_id()); + self.encode_mir_for_ctfe(def_id); + self.encode_promoted_mir(def_id); } fn encode_native_libraries(&mut self) -> Lazy<[NativeLib]> { @@ -2009,25 +2038,90 @@ impl<'tcx, 'v> ItemLikeVisitor<'v> for ImplVisitor<'tcx> { /// Used to prefetch queries which will be needed later by metadata encoding. /// Only a subset of the queries are actually prefetched to keep this code smaller. -fn prefetch_mir(tcx: TyCtxt<'_>) { - if !tcx.sess.opts.output_types.should_codegen() { - // We won't emit MIR, so don't prefetch it. - return; - } +struct PrefetchVisitor<'tcx> { + tcx: TyCtxt<'tcx>, + mir_keys: &'tcx FxHashSet, +} - par_iter(tcx.mir_keys(LOCAL_CRATE)).for_each(|&def_id| { - let (encode_const, encode_opt) = should_encode_mir(tcx, def_id); +impl<'tcx> PrefetchVisitor<'tcx> { + fn prefetch_ctfe_mir(&self, def_id: LocalDefId) { + if self.mir_keys.contains(&def_id) { + self.tcx.ensure().mir_for_ctfe(def_id); + self.tcx.ensure().promoted_mir(def_id); + } + } + fn prefetch_mir(&self, def_id: LocalDefId) { + if self.mir_keys.contains(&def_id) { + self.tcx.ensure().optimized_mir(def_id); + self.tcx.ensure().promoted_mir(def_id); + } + } +} - if encode_const { - tcx.ensure().mir_for_ctfe(def_id); +impl<'tcx, 'v> ParItemLikeVisitor<'v> for PrefetchVisitor<'tcx> { + fn visit_item(&self, item: &hir::Item<'_>) { + // This should be kept in sync with `encode_info_for_item`. + let tcx = self.tcx; + match item.kind { + hir::ItemKind::Static(..) | hir::ItemKind::Const(..) => { + self.prefetch_ctfe_mir(tcx.hir().local_def_id(item.hir_id)) + } + hir::ItemKind::Fn(ref sig, ..) => { + let def_id = tcx.hir().local_def_id(item.hir_id); + let opt_mir = tcx.generics_of(def_id.to_def_id()).requires_monomorphization(tcx) + || tcx.codegen_fn_attrs(def_id.to_def_id()).requests_inline(); + if opt_mir { + self.prefetch_mir(def_id) + } + if sig.header.constness == hir::Constness::Const { + self.prefetch_ctfe_mir(def_id); + } + } + _ => (), } - if encode_opt { - tcx.ensure().optimized_mir(def_id); + } + + fn visit_trait_item(&self, trait_item: &'v hir::TraitItem<'v>) { + // This should be kept in sync with `encode_info_for_trait_item`. + let def_id = self.tcx.hir().local_def_id(trait_item.hir_id); + match trait_item.kind { + hir::TraitItemKind::Type(..) => {} + hir::TraitItemKind::Const(..) => { + self.prefetch_ctfe_mir(def_id); + } + hir::TraitItemKind::Fn(..) => { + self.prefetch_mir(def_id); + } } - if encode_opt || encode_const { - tcx.ensure().promoted_mir(def_id); + } + + fn visit_impl_item(&self, impl_item: &'v hir::ImplItem<'v>) { + // This should be kept in sync with `encode_info_for_impl_item`. + let tcx = self.tcx; + match impl_item.kind { + hir::ImplItemKind::Const(..) => { + self.prefetch_ctfe_mir(tcx.hir().local_def_id(impl_item.hir_id)) + } + hir::ImplItemKind::Fn(ref sig, _) => { + let def_id = tcx.hir().local_def_id(impl_item.hir_id); + let opt_mir = tcx.generics_of(def_id.to_def_id()).requires_monomorphization(tcx) + || tcx.codegen_fn_attrs(def_id.to_def_id()).requests_inline(); + let is_const_fn = sig.header.constness == hir::Constness::Const; + if opt_mir { + self.prefetch_mir(def_id) + } + if is_const_fn { + self.prefetch_ctfe_mir(def_id); + } + } + hir::ImplItemKind::TyAlias(..) => (), } - }) + } + + fn visit_foreign_item(&self, _foreign_item: &'v hir::ForeignItem<'v>) { + // This should be kept in sync with `encode_info_for_foreign_item`. + // Foreign items contain no MIR. + } } // NOTE(eddyb) The following comment was preserved for posterity, even @@ -2067,7 +2161,19 @@ pub(super) fn encode_metadata(tcx: TyCtxt<'_>) -> EncodedMetadata { // Prefetch some queries used by metadata encoding. // This is not necessary for correctness, but is only done for performance reasons. // It can be removed if it turns out to cause trouble or be detrimental to performance. - join(|| prefetch_mir(tcx), || tcx.exported_symbols(LOCAL_CRATE)); + join( + || { + if !tcx.sess.opts.output_types.should_codegen() { + // We won't emit MIR, so don't prefetch it. + return; + } + tcx.hir().krate().par_visit_all_item_likes(&PrefetchVisitor { + tcx, + mir_keys: tcx.mir_keys(LOCAL_CRATE), + }); + }, + || tcx.exported_symbols(LOCAL_CRATE), + ); }, ) .0 @@ -2100,6 +2206,7 @@ fn encode_metadata_impl(tcx: TyCtxt<'_>) -> EncodedMetadata { required_source_files, is_proc_macro: tcx.sess.crate_types().contains(&CrateType::ProcMacro), hygiene_ctxt: &hygiene_ctxt, + emit_codegen_mir: tcx.sess.opts.output_types.should_codegen(), }; // Encode the rustc version string in a predictable location. diff --git a/compiler/rustc_middle/Cargo.toml b/compiler/rustc_middle/Cargo.toml index d33aad3b71040..47b7768b410a1 100644 --- a/compiler/rustc_middle/Cargo.toml +++ b/compiler/rustc_middle/Cargo.toml @@ -26,7 +26,7 @@ rustc_index = { path = "../rustc_index" } rustc_serialize = { path = "../rustc_serialize" } rustc_ast = { path = "../rustc_ast" } rustc_span = { path = "../rustc_span" } -chalk-ir = "0.55.0" +chalk-ir = "0.36.0" smallvec = { version = "1.0", features = ["union", "may_dangle"] } measureme = "9.0.0" rustc_session = { path = "../rustc_session" } diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index ee12c0e786d41..412d5b5082be3 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -569,9 +569,9 @@ impl<'hir> Map<'hir> { self.find(self.get_parent_node(id)), Some( Node::Item(_) - | Node::TraitItem(_) - | Node::ImplItem(_) - | Node::Expr(Expr { kind: ExprKind::Closure(..), .. }), + | Node::TraitItem(_) + | Node::ImplItem(_) + | Node::Expr(Expr { kind: ExprKind::Closure(..), .. }), ) ) } diff --git a/compiler/rustc_middle/src/lint.rs b/compiler/rustc_middle/src/lint.rs index ca73481b21699..0bdccf7b5f073 100644 --- a/compiler/rustc_middle/src/lint.rs +++ b/compiler/rustc_middle/src/lint.rs @@ -5,10 +5,7 @@ use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_errors::{DiagnosticBuilder, DiagnosticId}; use rustc_hir::HirId; -use rustc_session::lint::{ - builtin::{self, FORBIDDEN_LINT_GROUPS}, - Level, Lint, LintId, -}; +use rustc_session::lint::{builtin, Level, Lint, LintId}; use rustc_session::{DiagnosticMessageId, Session}; use rustc_span::hygiene::MacroKind; use rustc_span::source_map::{DesugaringKind, ExpnKind, MultiSpan}; @@ -92,12 +89,7 @@ impl LintLevelSets { // If we're about to issue a warning, check at the last minute for any // directives against the warnings "lint". If, for example, there's an // `allow(warnings)` in scope then we want to respect that instead. - // - // We exempt `FORBIDDEN_LINT_GROUPS` from this because it specifically - // triggers in cases (like #80988) where you have `forbid(warnings)`, - // and so if we turned that into an error, it'd defeat the purpose of the - // future compatibility warning. - if level == Level::Warn && LintId::of(lint) != LintId::of(FORBIDDEN_LINT_GROUPS) { + if level == Level::Warn { let (warnings_level, warnings_src) = self.get_lint_id_level(LintId::of(builtin::WARNINGS), idx, aux); if let Some(configured_warning_level) = warnings_level { diff --git a/compiler/rustc_middle/src/mir/interpret/value.rs b/compiler/rustc_middle/src/mir/interpret/value.rs index 4bb39fe4a527e..f288ad8d1d4a3 100644 --- a/compiler/rustc_middle/src/mir/interpret/value.rs +++ b/compiler/rustc_middle/src/mir/interpret/value.rs @@ -96,7 +96,7 @@ impl<'tcx> ConstValue<'tcx> { } /// A `Scalar` represents an immediate, primitive value existing outside of a -/// `memory::Allocation`. It is in many ways like a small chunk of a `Allocation`, up to 16 bytes in +/// `memory::Allocation`. It is in many ways like a small chunk of a `Allocation`, up to 8 bytes in /// size. Like a range of bytes in an `Allocation`, a `Scalar` can either represent the raw bytes /// of a simple value or a pointer into another `Allocation` #[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, TyEncodable, TyDecodable, Hash)] diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 718e81c84eddd..cd2bea86ea1a7 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -962,7 +962,8 @@ impl<'tcx> LocalDecl<'tcx> { opt_ty_info: _, opt_match_place: _, pat_span: _, - }) | BindingForm::ImplicitSelf(ImplicitSelfKind::Imm), + }) + | BindingForm::ImplicitSelf(ImplicitSelfKind::Imm), ))) ) } @@ -979,7 +980,8 @@ impl<'tcx> LocalDecl<'tcx> { opt_ty_info: _, opt_match_place: _, pat_span: _, - }) | BindingForm::ImplicitSelf(_), + }) + | BindingForm::ImplicitSelf(_), ))) ) } diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index f0166ec21672b..d89e3ab4352bb 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -13,6 +13,7 @@ use rustc_hir::def_id::{CrateNum, DefId, LocalDefId}; use rustc_query_system::query::QueryDescription; use rustc_span::symbol::Symbol; +use std::borrow::Cow; fn describe_as_module(def_id: LocalDefId, tcx: TyCtxt<'_>) -> String { if def_id.is_top_level_module() { @@ -34,1602 +35,1684 @@ fn describe_as_module(def_id: LocalDefId, tcx: TyCtxt<'_>) -> String { // Queries marked with `fatal_cycle` do not need the latter implementation, // as they will raise an fatal error on query cycles instead. rustc_queries! { - query trigger_delay_span_bug(key: DefId) -> () { - desc { "trigger a delay span bug" } + Other { + query trigger_delay_span_bug(key: DefId) -> () { + desc { "trigger a delay span bug" } + } } - /// Represents crate as a whole (as distinct from the top-level crate module). - /// If you call `hir_crate` (e.g., indirectly by calling `tcx.hir().krate()`), - /// we will have to assume that any change means that you need to be recompiled. - /// This is because the `hir_crate` query gives you access to all other items. - /// To avoid this fate, do not call `tcx.hir().krate()`; instead, - /// prefer wrappers like `tcx.visit_all_items_in_krate()`. - query hir_crate(key: CrateNum) -> &'tcx Crate<'tcx> { - eval_always - no_hash - desc { "get the crate HIR" } - } + Other { + /// Represents crate as a whole (as distinct from the top-level crate module). + /// If you call `hir_crate` (e.g., indirectly by calling `tcx.hir().krate()`), + /// we will have to assume that any change means that you need to be recompiled. + /// This is because the `hir_crate` query gives you access to all other items. + /// To avoid this fate, do not call `tcx.hir().krate()`; instead, + /// prefer wrappers like `tcx.visit_all_items_in_krate()`. + query hir_crate(key: CrateNum) -> &'tcx Crate<'tcx> { + eval_always + no_hash + desc { "get the crate HIR" } + } - /// The indexed HIR. This can be conveniently accessed by `tcx.hir()`. - /// Avoid calling this query directly. - query index_hir(_: CrateNum) -> &'tcx map::IndexedHir<'tcx> { - eval_always - no_hash - desc { "index HIR" } - } + /// The indexed HIR. This can be conveniently accessed by `tcx.hir()`. + /// Avoid calling this query directly. + query index_hir(_: CrateNum) -> &'tcx map::IndexedHir<'tcx> { + eval_always + no_hash + desc { "index HIR" } + } - /// The items in a module. - /// - /// This can be conveniently accessed by `tcx.hir().visit_item_likes_in_module`. - /// Avoid calling this query directly. - query hir_module_items(key: LocalDefId) -> &'tcx hir::ModuleItems { - eval_always - desc { |tcx| "HIR module items in `{}`", tcx.def_path_str(key.to_def_id()) } - } + /// The items in a module. + /// + /// This can be conveniently accessed by `tcx.hir().visit_item_likes_in_module`. + /// Avoid calling this query directly. + query hir_module_items(key: LocalDefId) -> &'tcx hir::ModuleItems { + eval_always + desc { |tcx| "HIR module items in `{}`", tcx.def_path_str(key.to_def_id()) } + } - /// Gives access to the HIR node for the HIR owner `key`. - /// - /// This can be conveniently accessed by methods on `tcx.hir()`. - /// Avoid calling this query directly. - query hir_owner(key: LocalDefId) -> Option<&'tcx crate::hir::Owner<'tcx>> { - eval_always - desc { |tcx| "HIR owner of `{}`", tcx.def_path_str(key.to_def_id()) } - } + /// Gives access to the HIR node for the HIR owner `key`. + /// + /// This can be conveniently accessed by methods on `tcx.hir()`. + /// Avoid calling this query directly. + query hir_owner(key: LocalDefId) -> Option<&'tcx crate::hir::Owner<'tcx>> { + eval_always + desc { |tcx| "HIR owner of `{}`", tcx.def_path_str(key.to_def_id()) } + } - /// Gives access to the HIR nodes and bodies inside the HIR owner `key`. - /// - /// This can be conveniently accessed by methods on `tcx.hir()`. - /// Avoid calling this query directly. - query hir_owner_nodes(key: LocalDefId) -> Option<&'tcx crate::hir::OwnerNodes<'tcx>> { - eval_always - desc { |tcx| "HIR owner items in `{}`", tcx.def_path_str(key.to_def_id()) } - } + /// Gives access to the HIR nodes and bodies inside the HIR owner `key`. + /// + /// This can be conveniently accessed by methods on `tcx.hir()`. + /// Avoid calling this query directly. + query hir_owner_nodes(key: LocalDefId) -> Option<&'tcx crate::hir::OwnerNodes<'tcx>> { + eval_always + desc { |tcx| "HIR owner items in `{}`", tcx.def_path_str(key.to_def_id()) } + } - /// Computes the `DefId` of the corresponding const parameter in case the `key` is a - /// const argument and returns `None` otherwise. - /// - /// ```ignore (incomplete) - /// let a = foo::<7>(); - /// // ^ Calling `opt_const_param_of` for this argument, - /// - /// fn foo() - /// // ^ returns this `DefId`. - /// - /// fn bar() { - /// // ^ While calling `opt_const_param_of` for other bodies returns `None`. - /// } - /// ``` - // It looks like caching this query on disk actually slightly - // worsened performance in #74376. - // - // Once const generics are more prevalently used, we might want to - // consider only caching calls returning `Some`. - query opt_const_param_of(key: LocalDefId) -> Option { - desc { |tcx| "computing the optional const parameter of `{}`", tcx.def_path_str(key.to_def_id()) } - } + /// Computes the `DefId` of the corresponding const parameter in case the `key` is a + /// const argument and returns `None` otherwise. + /// + /// ```ignore (incomplete) + /// let a = foo::<7>(); + /// // ^ Calling `opt_const_param_of` for this argument, + /// + /// fn foo() + /// // ^ returns this `DefId`. + /// + /// fn bar() { + /// // ^ While calling `opt_const_param_of` for other bodies returns `None`. + /// } + /// ``` + // It looks like caching this query on disk actually slightly + // worsened performance in #74376. + // + // Once const generics are more prevalently used, we might want to + // consider only caching calls returning `Some`. + query opt_const_param_of(key: LocalDefId) -> Option { + desc { |tcx| "computing the optional const parameter of `{}`", tcx.def_path_str(key.to_def_id()) } + } - /// Records the type of every item. - query type_of(key: DefId) -> Ty<'tcx> { - desc { |tcx| "computing type of `{}`", tcx.def_path_str(key) } - cache_on_disk_if { key.is_local() } - } + /// Records the type of every item. + query type_of(key: DefId) -> Ty<'tcx> { + desc { |tcx| "computing type of `{}`", tcx.def_path_str(key) } + cache_on_disk_if { key.is_local() } + } - query analysis(key: CrateNum) -> Result<(), ErrorReported> { - eval_always - desc { "running analysis passes on this crate" } - } + query analysis(key: CrateNum) -> Result<(), ErrorReported> { + eval_always + desc { "running analysis passes on this crate" } + } - /// Maps from the `DefId` of an item (trait/struct/enum/fn) to its - /// associated generics. - query generics_of(key: DefId) -> ty::Generics { - desc { |tcx| "computing generics of `{}`", tcx.def_path_str(key) } - storage(ArenaCacheSelector<'tcx>) - cache_on_disk_if { key.is_local() } - load_cached(tcx, id) { - let generics: Option = tcx.queries.on_disk_cache.as_ref() - .and_then(|c| c.try_load_query_result(tcx, id)); - generics + /// Maps from the `DefId` of an item (trait/struct/enum/fn) to its + /// associated generics. + query generics_of(key: DefId) -> ty::Generics { + desc { |tcx| "computing generics of `{}`", tcx.def_path_str(key) } + storage(ArenaCacheSelector<'tcx>) + cache_on_disk_if { key.is_local() } + load_cached(tcx, id) { + let generics: Option = tcx.queries.on_disk_cache.as_ref() + .and_then(|c| c.try_load_query_result(tcx, id)); + generics + } } - } - /// Maps from the `DefId` of an item (trait/struct/enum/fn) to the - /// predicates (where-clauses) that must be proven true in order - /// to reference it. This is almost always the "predicates query" - /// that you want. - /// - /// `predicates_of` builds on `predicates_defined_on` -- in fact, - /// it is almost always the same as that query, except for the - /// case of traits. For traits, `predicates_of` contains - /// an additional `Self: Trait<...>` predicate that users don't - /// actually write. This reflects the fact that to invoke the - /// trait (e.g., via `Default::default`) you must supply types - /// that actually implement the trait. (However, this extra - /// predicate gets in the way of some checks, which are intended - /// to operate over only the actual where-clauses written by the - /// user.) - query predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> { - desc { |tcx| "computing predicates of `{}`", tcx.def_path_str(key) } - cache_on_disk_if { key.is_local() } - } + /// Maps from the `DefId` of an item (trait/struct/enum/fn) to the + /// predicates (where-clauses) that must be proven true in order + /// to reference it. This is almost always the "predicates query" + /// that you want. + /// + /// `predicates_of` builds on `predicates_defined_on` -- in fact, + /// it is almost always the same as that query, except for the + /// case of traits. For traits, `predicates_of` contains + /// an additional `Self: Trait<...>` predicate that users don't + /// actually write. This reflects the fact that to invoke the + /// trait (e.g., via `Default::default`) you must supply types + /// that actually implement the trait. (However, this extra + /// predicate gets in the way of some checks, which are intended + /// to operate over only the actual where-clauses written by the + /// user.) + query predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> { + desc { |tcx| "computing predicates of `{}`", tcx.def_path_str(key) } + cache_on_disk_if { key.is_local() } + } - /// Returns the list of bounds that can be used for - /// `SelectionCandidate::ProjectionCandidate(_)` and - /// `ProjectionTyCandidate::TraitDef`. - /// Specifically this is the bounds written on the trait's type - /// definition, or those after the `impl` keyword - /// - /// ```ignore (incomplete) - /// type X: Bound + 'lt - /// // ^^^^^^^^^^^ - /// impl Debug + Display - /// // ^^^^^^^^^^^^^^^ - /// ``` - /// - /// `key` is the `DefId` of the associated type or opaque type. - /// - /// Bounds from the parent (e.g. with nested impl trait) are not included. - query explicit_item_bounds(key: DefId) -> &'tcx [(ty::Predicate<'tcx>, Span)] { - desc { |tcx| "finding item bounds for `{}`", tcx.def_path_str(key) } - } + /// Returns the list of bounds that can be used for + /// `SelectionCandidate::ProjectionCandidate(_)` and + /// `ProjectionTyCandidate::TraitDef`. + /// Specifically this is the bounds written on the trait's type + /// definition, or those after the `impl` keyword + /// + /// ```ignore (incomplete) + /// type X: Bound + 'lt + /// // ^^^^^^^^^^^ + /// impl Debug + Display + /// // ^^^^^^^^^^^^^^^ + /// ``` + /// + /// `key` is the `DefId` of the associated type or opaque type. + /// + /// Bounds from the parent (e.g. with nested impl trait) are not included. + query explicit_item_bounds(key: DefId) -> &'tcx [(ty::Predicate<'tcx>, Span)] { + desc { |tcx| "finding item bounds for `{}`", tcx.def_path_str(key) } + } - /// Elaborated version of the predicates from `explicit_item_bounds`. - /// - /// For example: - /// - /// ``` - /// trait MyTrait { - /// type MyAType: Eq + ?Sized; - /// } - /// ``` - /// - /// `explicit_item_bounds` returns `[::MyAType: Eq]`, - /// and `item_bounds` returns - /// ```text - /// [ - /// ::MyAType: Eq, - /// ::MyAType: PartialEq<::MyAType> - /// ] - /// ``` - /// - /// Bounds from the parent (e.g. with nested impl trait) are not included. - query item_bounds(key: DefId) -> &'tcx ty::List> { - desc { |tcx| "elaborating item bounds for `{}`", tcx.def_path_str(key) } - } + /// Elaborated version of the predicates from `explicit_item_bounds`. + /// + /// For example: + /// + /// ``` + /// trait MyTrait { + /// type MyAType: Eq + ?Sized; + /// } + /// ``` + /// + /// `explicit_item_bounds` returns `[::MyAType: Eq]`, + /// and `item_bounds` returns + /// ```text + /// [ + /// ::MyAType: Eq, + /// ::MyAType: PartialEq<::MyAType> + /// ] + /// ``` + /// + /// Bounds from the parent (e.g. with nested impl trait) are not included. + query item_bounds(key: DefId) -> &'tcx ty::List> { + desc { |tcx| "elaborating item bounds for `{}`", tcx.def_path_str(key) } + } - query projection_ty_from_predicates(key: (DefId, DefId)) -> Option> { - desc { |tcx| "finding projection type inside predicates of `{}`", tcx.def_path_str(key.0) } - } + query projection_ty_from_predicates(key: (DefId, DefId)) -> Option> { + desc { |tcx| "finding projection type inside predicates of `{}`", tcx.def_path_str(key.0) } + } - query native_libraries(_: CrateNum) -> Lrc> { - desc { "looking up the native libraries of a linked crate" } - } + query native_libraries(_: CrateNum) -> Lrc> { + desc { "looking up the native libraries of a linked crate" } + } - query lint_levels(_: CrateNum) -> LintLevelMap { - storage(ArenaCacheSelector<'tcx>) - eval_always - desc { "computing the lint levels for items in this crate" } - } + query lint_levels(_: CrateNum) -> LintLevelMap { + storage(ArenaCacheSelector<'tcx>) + eval_always + desc { "computing the lint levels for items in this crate" } + } - query parent_module_from_def_id(key: LocalDefId) -> LocalDefId { - eval_always - desc { |tcx| "parent module of `{}`", tcx.def_path_str(key.to_def_id()) } - } + query parent_module_from_def_id(key: LocalDefId) -> LocalDefId { + eval_always + desc { |tcx| "parent module of `{}`", tcx.def_path_str(key.to_def_id()) } + } - /// Internal helper query. Use `tcx.expansion_that_defined` instead - query expn_that_defined(key: DefId) -> rustc_span::ExpnId { - desc { |tcx| "expansion that defined `{}`", tcx.def_path_str(key) } + /// Internal helper query. Use `tcx.expansion_that_defined` instead + query expn_that_defined(key: DefId) -> rustc_span::ExpnId { + desc { |tcx| "expansion that defined `{}`", tcx.def_path_str(key) } + } } - query is_panic_runtime(_: CrateNum) -> bool { - fatal_cycle - desc { "checking if the crate is_panic_runtime" } + Codegen { + query is_panic_runtime(_: CrateNum) -> bool { + fatal_cycle + desc { "checking if the crate is_panic_runtime" } + } } - /// Set of all the `DefId`s in this crate that have MIR associated with - /// them. This includes all the body owners, but also things like struct - /// constructors. - query mir_keys(_: CrateNum) -> FxHashSet { - storage(ArenaCacheSelector<'tcx>) - desc { "getting a list of all mir_keys" } - } + Codegen { + /// Set of all the `DefId`s in this crate that have MIR associated with + /// them. This includes all the body owners, but also things like struct + /// constructors. + query mir_keys(_: CrateNum) -> FxHashSet { + storage(ArenaCacheSelector<'tcx>) + desc { "getting a list of all mir_keys" } + } - /// Maps DefId's that have an associated `mir::Body` to the result - /// of the MIR const-checking pass. This is the set of qualifs in - /// the final value of a `const`. - query mir_const_qualif(key: DefId) -> mir::ConstQualifs { - desc { |tcx| "const checking `{}`", tcx.def_path_str(key) } - cache_on_disk_if { key.is_local() } - } - query mir_const_qualif_const_arg( - key: (LocalDefId, DefId) - ) -> mir::ConstQualifs { - desc { - |tcx| "const checking the const argument `{}`", - tcx.def_path_str(key.0.to_def_id()) + /// Maps DefId's that have an associated `mir::Body` to the result + /// of the MIR const-checking pass. This is the set of qualifs in + /// the final value of a `const`. + query mir_const_qualif(key: DefId) -> mir::ConstQualifs { + desc { |tcx| "const checking `{}`", tcx.def_path_str(key) } + cache_on_disk_if { key.is_local() } + } + query mir_const_qualif_const_arg( + key: (LocalDefId, DefId) + ) -> mir::ConstQualifs { + desc { + |tcx| "const checking the const argument `{}`", + tcx.def_path_str(key.0.to_def_id()) + } } - } - /// Fetch the MIR for a given `DefId` right after it's built - this includes - /// unreachable code. - query mir_built(key: ty::WithOptConstParam) -> &'tcx Steal> { - desc { |tcx| "building MIR for `{}`", tcx.def_path_str(key.did.to_def_id()) } - } + /// Fetch the MIR for a given `DefId` right after it's built - this includes + /// unreachable code. + query mir_built(key: ty::WithOptConstParam) -> &'tcx Steal> { + desc { |tcx| "building MIR for `{}`", tcx.def_path_str(key.did.to_def_id()) } + } - /// Fetch the MIR for a given `DefId` up till the point where it is - /// ready for const qualification. - /// - /// See the README for the `mir` module for details. - query mir_const(key: ty::WithOptConstParam) -> &'tcx Steal> { - desc { - |tcx| "processing MIR for {}`{}`", - if key.const_param_did.is_some() { "the const argument " } else { "" }, - tcx.def_path_str(key.did.to_def_id()), - } - no_hash - } + /// Fetch the MIR for a given `DefId` up till the point where it is + /// ready for const qualification. + /// + /// See the README for the `mir` module for details. + query mir_const(key: ty::WithOptConstParam) -> &'tcx Steal> { + desc { + |tcx| "processing MIR for {}`{}`", + if key.const_param_did.is_some() { "the const argument " } else { "" }, + tcx.def_path_str(key.did.to_def_id()), + } + no_hash + } - /// Try to build an abstract representation of the given constant. - query mir_abstract_const( - key: DefId - ) -> Result]>, ErrorReported> { - desc { - |tcx| "building an abstract representation for {}", tcx.def_path_str(key), + /// Try to build an abstract representation of the given constant. + query mir_abstract_const( + key: DefId + ) -> Result]>, ErrorReported> { + desc { + |tcx| "building an abstract representation for {}", tcx.def_path_str(key), + } } - } - /// Try to build an abstract representation of the given constant. - query mir_abstract_const_of_const_arg( - key: (LocalDefId, DefId) - ) -> Result]>, ErrorReported> { - desc { - |tcx| - "building an abstract representation for the const argument {}", - tcx.def_path_str(key.0.to_def_id()), + /// Try to build an abstract representation of the given constant. + query mir_abstract_const_of_const_arg( + key: (LocalDefId, DefId) + ) -> Result]>, ErrorReported> { + desc { + |tcx| + "building an abstract representation for the const argument {}", + tcx.def_path_str(key.0.to_def_id()), + } } - } - query try_unify_abstract_consts(key: ( - (ty::WithOptConstParam, SubstsRef<'tcx>), - (ty::WithOptConstParam, SubstsRef<'tcx>) - )) -> bool { - desc { - |tcx| "trying to unify the generic constants {} and {}", - tcx.def_path_str(key.0.0.did), tcx.def_path_str(key.1.0.did) + query try_unify_abstract_consts(key: ( + (ty::WithOptConstParam, SubstsRef<'tcx>), + (ty::WithOptConstParam, SubstsRef<'tcx>) + )) -> bool { + desc { + |tcx| "trying to unify the generic constants {} and {}", + tcx.def_path_str(key.0.0.did), tcx.def_path_str(key.1.0.did) + } } - } - - query mir_drops_elaborated_and_const_checked( - key: ty::WithOptConstParam - ) -> &'tcx Steal> { - no_hash - desc { |tcx| "elaborating drops for `{}`", tcx.def_path_str(key.did.to_def_id()) } - } - - query mir_for_ctfe( - key: DefId - ) -> &'tcx mir::Body<'tcx> { - desc { |tcx| "caching mir of `{}` for CTFE", tcx.def_path_str(key) } - cache_on_disk_if { key.is_local() } - } - query mir_for_ctfe_of_const_arg(key: (LocalDefId, DefId)) -> &'tcx mir::Body<'tcx> { - desc { - |tcx| "MIR for CTFE of the const argument `{}`", - tcx.def_path_str(key.0.to_def_id()) + query mir_drops_elaborated_and_const_checked( + key: ty::WithOptConstParam + ) -> &'tcx Steal> { + no_hash + desc { |tcx| "elaborating drops for `{}`", tcx.def_path_str(key.did.to_def_id()) } } - } - query mir_promoted(key: ty::WithOptConstParam) -> - ( - &'tcx Steal>, - &'tcx Steal>> - ) { - no_hash - desc { - |tcx| "processing {}`{}`", - if key.const_param_did.is_some() { "the const argument " } else { "" }, - tcx.def_path_str(key.did.to_def_id()), + query mir_for_ctfe( + key: DefId + ) -> &'tcx mir::Body<'tcx> { + desc { |tcx| "caching mir of `{}` for CTFE", tcx.def_path_str(key) } + cache_on_disk_if { key.is_local() } } - } - /// MIR after our optimization passes have run. This is MIR that is ready - /// for codegen. This is also the only query that can fetch non-local MIR, at present. - query optimized_mir(key: DefId) -> &'tcx mir::Body<'tcx> { - desc { |tcx| "optimizing MIR for `{}`", tcx.def_path_str(key) } - cache_on_disk_if { key.is_local() } - } + query mir_for_ctfe_of_const_arg(key: (LocalDefId, DefId)) -> &'tcx mir::Body<'tcx> { + desc { + |tcx| "MIR for CTFE of the const argument `{}`", + tcx.def_path_str(key.0.to_def_id()) + } + } - /// Returns coverage summary info for a function, after executing the `InstrumentCoverage` - /// MIR pass (assuming the -Zinstrument-coverage option is enabled). - query coverageinfo(key: DefId) -> mir::CoverageInfo { - desc { |tcx| "retrieving coverage info from MIR for `{}`", tcx.def_path_str(key) } - storage(ArenaCacheSelector<'tcx>) - cache_on_disk_if { key.is_local() } - } + query mir_promoted(key: ty::WithOptConstParam) -> + ( + &'tcx Steal>, + &'tcx Steal>> + ) { + no_hash + desc { + |tcx| "processing {}`{}`", + if key.const_param_did.is_some() { "the const argument " } else { "" }, + tcx.def_path_str(key.did.to_def_id()), + } + } - /// Returns the name of the file that contains the function body, if instrumented for coverage. - query covered_file_name(key: DefId) -> Option { - desc { |tcx| "retrieving the covered file name, if instrumented, for `{}`", tcx.def_path_str(key) } - storage(ArenaCacheSelector<'tcx>) - cache_on_disk_if { key.is_local() } - } + /// MIR after our optimization passes have run. This is MIR that is ready + /// for codegen. This is also the only query that can fetch non-local MIR, at present. + query optimized_mir(key: DefId) -> &'tcx mir::Body<'tcx> { + desc { |tcx| "optimizing MIR for `{}`", tcx.def_path_str(key) } + cache_on_disk_if { key.is_local() } + } - /// Returns the `CodeRegions` for a function that has instrumented coverage, in case the - /// function was optimized out before codegen, and before being added to the Coverage Map. - query covered_code_regions(key: DefId) -> Vec<&'tcx mir::coverage::CodeRegion> { - desc { |tcx| "retrieving the covered `CodeRegion`s, if instrumented, for `{}`", tcx.def_path_str(key) } - storage(ArenaCacheSelector<'tcx>) - cache_on_disk_if { key.is_local() } - } + /// Returns coverage summary info for a function, after executing the `InstrumentCoverage` + /// MIR pass (assuming the -Zinstrument-coverage option is enabled). + query coverageinfo(key: DefId) -> mir::CoverageInfo { + desc { |tcx| "retrieving coverage info from MIR for `{}`", tcx.def_path_str(key) } + storage(ArenaCacheSelector<'tcx>) + cache_on_disk_if { key.is_local() } + } - /// The `DefId` is the `DefId` of the containing MIR body. Promoteds do not have their own - /// `DefId`. This function returns all promoteds in the specified body. The body references - /// promoteds by the `DefId` and the `mir::Promoted` index. This is necessary, because - /// after inlining a body may refer to promoteds from other bodies. In that case you still - /// need to use the `DefId` of the original body. - query promoted_mir(key: DefId) -> &'tcx IndexVec> { - desc { |tcx| "optimizing promoted MIR for `{}`", tcx.def_path_str(key) } - cache_on_disk_if { key.is_local() } - } - query promoted_mir_of_const_arg( - key: (LocalDefId, DefId) - ) -> &'tcx IndexVec> { - desc { - |tcx| "optimizing promoted MIR for the const argument `{}`", - tcx.def_path_str(key.0.to_def_id()), + /// Returns the name of the file that contains the function body, if instrumented for coverage. + query covered_file_name(key: DefId) -> Option { + desc { |tcx| "retrieving the covered file name, if instrumented, for `{}`", tcx.def_path_str(key) } + storage(ArenaCacheSelector<'tcx>) + cache_on_disk_if { key.is_local() } } - } - /// Erases regions from `ty` to yield a new type. - /// Normally you would just use `tcx.erase_regions(value)`, - /// however, which uses this query as a kind of cache. - query erase_regions_ty(ty: Ty<'tcx>) -> Ty<'tcx> { - // This query is not expected to have input -- as a result, it - // is not a good candidates for "replay" because it is essentially a - // pure function of its input (and hence the expectation is that - // no caller would be green **apart** from just these - // queries). Making it anonymous avoids hashing the result, which - // may save a bit of time. - anon - desc { "erasing regions from `{:?}`", ty } - } + /// Returns the `CodeRegions` for a function that has instrumented coverage, in case the + /// function was optimized out before codegen, and before being added to the Coverage Map. + query covered_code_regions(key: DefId) -> Vec<&'tcx mir::coverage::CodeRegion> { + desc { |tcx| "retrieving the covered `CodeRegion`s, if instrumented, for `{}`", tcx.def_path_str(key) } + storage(ArenaCacheSelector<'tcx>) + cache_on_disk_if { key.is_local() } + } - query wasm_import_module_map(_: CrateNum) -> FxHashMap { - storage(ArenaCacheSelector<'tcx>) - desc { "wasm import module map" } + /// The `DefId` is the `DefId` of the containing MIR body. Promoteds do not have their own + /// `DefId`. This function returns all promoteds in the specified body. The body references + /// promoteds by the `DefId` and the `mir::Promoted` index. This is necessary, because + /// after inlining a body may refer to promoteds from other bodies. In that case you still + /// need to use the `DefId` of the original body. + query promoted_mir(key: DefId) -> &'tcx IndexVec> { + desc { |tcx| "optimizing promoted MIR for `{}`", tcx.def_path_str(key) } + cache_on_disk_if { key.is_local() } + } + query promoted_mir_of_const_arg( + key: (LocalDefId, DefId) + ) -> &'tcx IndexVec> { + desc { + |tcx| "optimizing promoted MIR for the const argument `{}`", + tcx.def_path_str(key.0.to_def_id()), + } + } } - /// Maps from the `DefId` of an item (trait/struct/enum/fn) to the - /// predicates (where-clauses) directly defined on it. This is - /// equal to the `explicit_predicates_of` predicates plus the - /// `inferred_outlives_of` predicates. - query predicates_defined_on(key: DefId) -> ty::GenericPredicates<'tcx> { - desc { |tcx| "computing predicates of `{}`", tcx.def_path_str(key) } + TypeChecking { + /// Erases regions from `ty` to yield a new type. + /// Normally you would just use `tcx.erase_regions(value)`, + /// however, which uses this query as a kind of cache. + query erase_regions_ty(ty: Ty<'tcx>) -> Ty<'tcx> { + // This query is not expected to have input -- as a result, it + // is not a good candidates for "replay" because it is essentially a + // pure function of its input (and hence the expectation is that + // no caller would be green **apart** from just these + // queries). Making it anonymous avoids hashing the result, which + // may save a bit of time. + anon + desc { "erasing regions from `{:?}`", ty } + } } - /// Returns everything that looks like a predicate written explicitly - /// by the user on a trait item. - /// - /// Traits are unusual, because predicates on associated types are - /// converted into bounds on that type for backwards compatibility: - /// - /// trait X where Self::U: Copy { type U; } - /// - /// becomes - /// - /// trait X { type U: Copy; } - /// - /// `explicit_predicates_of` and `explicit_item_bounds` will then take - /// the appropriate subsets of the predicates here. - query trait_explicit_predicates_and_bounds(key: LocalDefId) -> ty::GenericPredicates<'tcx> { - desc { |tcx| "computing explicit predicates of trait `{}`", tcx.def_path_str(key.to_def_id()) } + Linking { + query wasm_import_module_map(_: CrateNum) -> FxHashMap { + storage(ArenaCacheSelector<'tcx>) + desc { "wasm import module map" } + } } - /// Returns the predicates written explicitly by the user. - query explicit_predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> { - desc { |tcx| "computing explicit predicates of `{}`", tcx.def_path_str(key) } - } + Other { + /// Maps from the `DefId` of an item (trait/struct/enum/fn) to the + /// predicates (where-clauses) directly defined on it. This is + /// equal to the `explicit_predicates_of` predicates plus the + /// `inferred_outlives_of` predicates. + query predicates_defined_on(key: DefId) -> ty::GenericPredicates<'tcx> { + desc { |tcx| "computing predicates of `{}`", tcx.def_path_str(key) } + } - /// Returns the inferred outlives predicates (e.g., for `struct - /// Foo<'a, T> { x: &'a T }`, this would return `T: 'a`). - query inferred_outlives_of(key: DefId) -> &'tcx [(ty::Predicate<'tcx>, Span)] { - desc { |tcx| "computing inferred outlives predicates of `{}`", tcx.def_path_str(key) } - } + /// Returns everything that looks like a predicate written explicitly + /// by the user on a trait item. + /// + /// Traits are unusual, because predicates on associated types are + /// converted into bounds on that type for backwards compatibility: + /// + /// trait X where Self::U: Copy { type U; } + /// + /// becomes + /// + /// trait X { type U: Copy; } + /// + /// `explicit_predicates_of` and `explicit_item_bounds` will then take + /// the appropriate subsets of the predicates here. + query trait_explicit_predicates_and_bounds(key: LocalDefId) -> ty::GenericPredicates<'tcx> { + desc { |tcx| "computing explicit predicates of trait `{}`", tcx.def_path_str(key.to_def_id()) } + } - /// Maps from the `DefId` of a trait to the list of - /// super-predicates. This is a subset of the full list of - /// predicates. We store these in a separate map because we must - /// evaluate them even during type conversion, often before the - /// full predicates are available (note that supertraits have - /// additional acyclicity requirements). - query super_predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> { - desc { |tcx| "computing the super predicates of `{}`", tcx.def_path_str(key) } - } + /// Returns the predicates written explicitly by the user. + query explicit_predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> { + desc { |tcx| "computing explicit predicates of `{}`", tcx.def_path_str(key) } + } - /// The `Option` is the name of an associated type. If it is `None`, then this query - /// returns the full set of predicates. If `Some`, then the query returns only the - /// subset of super-predicates that reference traits that define the given associated type. - /// This is used to avoid cycles in resolving types like `T::Item`. - query super_predicates_that_define_assoc_type(key: (DefId, Option)) -> ty::GenericPredicates<'tcx> { - desc { |tcx| "computing the super traits of `{}`{}", - tcx.def_path_str(key.0), - if let Some(assoc_name) = key.1 { format!(" with associated type name `{}`", assoc_name) } else { "".to_string() }, + /// Returns the inferred outlives predicates (e.g., for `struct + /// Foo<'a, T> { x: &'a T }`, this would return `T: 'a`). + query inferred_outlives_of(key: DefId) -> &'tcx [(ty::Predicate<'tcx>, Span)] { + desc { |tcx| "computing inferred outlives predicates of `{}`", tcx.def_path_str(key) } } - } - /// To avoid cycles within the predicates of a single item we compute - /// per-type-parameter predicates for resolving `T::AssocTy`. - query type_param_predicates(key: (DefId, LocalDefId, rustc_span::symbol::Ident)) -> ty::GenericPredicates<'tcx> { - desc { |tcx| "computing the bounds for type parameter `{}`", { - let id = tcx.hir().local_def_id_to_hir_id(key.1); - tcx.hir().ty_param_name(id) - }} - } + /// Maps from the `DefId` of a trait to the list of + /// super-predicates. This is a subset of the full list of + /// predicates. We store these in a separate map because we must + /// evaluate them even during type conversion, often before the + /// full predicates are available (note that supertraits have + /// additional acyclicity requirements). + query super_predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> { + desc { |tcx| "computing the supertraits of `{}`", tcx.def_path_str(key) } + } - query trait_def(key: DefId) -> ty::TraitDef { - desc { |tcx| "computing trait definition for `{}`", tcx.def_path_str(key) } - storage(ArenaCacheSelector<'tcx>) - } - query adt_def(key: DefId) -> &'tcx ty::AdtDef { - desc { |tcx| "computing ADT definition for `{}`", tcx.def_path_str(key) } - } - query adt_destructor(key: DefId) -> Option { - desc { |tcx| "computing `Drop` impl for `{}`", tcx.def_path_str(key) } - } + /// To avoid cycles within the predicates of a single item we compute + /// per-type-parameter predicates for resolving `T::AssocTy`. + query type_param_predicates(key: (DefId, LocalDefId)) -> ty::GenericPredicates<'tcx> { + desc { |tcx| "computing the bounds for type parameter `{}`", { + let id = tcx.hir().local_def_id_to_hir_id(key.1); + tcx.hir().ty_param_name(id) + }} + } - // The cycle error here should be reported as an error by `check_representable`. - // We consider the type as Sized in the meanwhile to avoid - // further errors (done in impl Value for AdtSizedConstraint). - // Use `cycle_delay_bug` to delay the cycle error here to be emitted later - // in case we accidentally otherwise don't emit an error. - query adt_sized_constraint( - key: DefId - ) -> AdtSizedConstraint<'tcx> { - desc { |tcx| "computing `Sized` constraints for `{}`", tcx.def_path_str(key) } - cycle_delay_bug - } + query trait_def(key: DefId) -> ty::TraitDef { + desc { |tcx| "computing trait definition for `{}`", tcx.def_path_str(key) } + storage(ArenaCacheSelector<'tcx>) + } + query adt_def(key: DefId) -> &'tcx ty::AdtDef { + desc { |tcx| "computing ADT definition for `{}`", tcx.def_path_str(key) } + } + query adt_destructor(key: DefId) -> Option { + desc { |tcx| "computing `Drop` impl for `{}`", tcx.def_path_str(key) } + } - query adt_dtorck_constraint( - key: DefId - ) -> Result, NoSolution> { - desc { |tcx| "computing drop-check constraints for `{}`", tcx.def_path_str(key) } - } + // The cycle error here should be reported as an error by `check_representable`. + // We consider the type as Sized in the meanwhile to avoid + // further errors (done in impl Value for AdtSizedConstraint). + // Use `cycle_delay_bug` to delay the cycle error here to be emitted later + // in case we accidentally otherwise don't emit an error. + query adt_sized_constraint( + key: DefId + ) -> AdtSizedConstraint<'tcx> { + desc { |tcx| "computing `Sized` constraints for `{}`", tcx.def_path_str(key) } + cycle_delay_bug + } - /// Returns `true` if this is a const fn, use the `is_const_fn` to know whether your crate - /// actually sees it as const fn (e.g., the const-fn-ness might be unstable and you might - /// not have the feature gate active). - /// - /// **Do not call this function manually.** It is only meant to cache the base data for the - /// `is_const_fn` function. - query is_const_fn_raw(key: DefId) -> bool { - desc { |tcx| "checking if item is const fn: `{}`", tcx.def_path_str(key) } - } + query adt_dtorck_constraint( + key: DefId + ) -> Result, NoSolution> { + desc { |tcx| "computing drop-check constraints for `{}`", tcx.def_path_str(key) } + } - /// Returns `true` if this is a const `impl`. **Do not call this function manually.** - /// - /// This query caches the base data for the `is_const_impl` helper function, which also - /// takes into account stability attributes (e.g., `#[rustc_const_unstable]`). - query is_const_impl_raw(key: DefId) -> bool { - desc { |tcx| "checking if item is const impl: `{}`", tcx.def_path_str(key) } - } + /// Returns `true` if this is a const fn, use the `is_const_fn` to know whether your crate + /// actually sees it as const fn (e.g., the const-fn-ness might be unstable and you might + /// not have the feature gate active). + /// + /// **Do not call this function manually.** It is only meant to cache the base data for the + /// `is_const_fn` function. + query is_const_fn_raw(key: DefId) -> bool { + desc { |tcx| "checking if item is const fn: `{}`", tcx.def_path_str(key) } + } - query asyncness(key: DefId) -> hir::IsAsync { - desc { |tcx| "checking if the function is async: `{}`", tcx.def_path_str(key) } - } + /// Returns `true` if this is a const `impl`. **Do not call this function manually.** + /// + /// This query caches the base data for the `is_const_impl` helper function, which also + /// takes into account stability attributes (e.g., `#[rustc_const_unstable]`). + query is_const_impl_raw(key: DefId) -> bool { + desc { |tcx| "checking if item is const impl: `{}`", tcx.def_path_str(key) } + } - /// Returns `true` if calls to the function may be promoted. - /// - /// This is either because the function is e.g., a tuple-struct or tuple-variant - /// constructor, or because it has the `#[rustc_promotable]` attribute. The attribute should - /// be removed in the future in favour of some form of check which figures out whether the - /// function does not inspect the bits of any of its arguments (so is essentially just a - /// constructor function). - query is_promotable_const_fn(key: DefId) -> bool { - desc { |tcx| "checking if item is promotable: `{}`", tcx.def_path_str(key) } - } + query asyncness(key: DefId) -> hir::IsAsync { + desc { |tcx| "checking if the function is async: `{}`", tcx.def_path_str(key) } + } - /// Returns `true` if this is a foreign item (i.e., linked via `extern { ... }`). - query is_foreign_item(key: DefId) -> bool { - desc { |tcx| "checking if `{}` is a foreign item", tcx.def_path_str(key) } - } + /// Returns `true` if calls to the function may be promoted. + /// + /// This is either because the function is e.g., a tuple-struct or tuple-variant + /// constructor, or because it has the `#[rustc_promotable]` attribute. The attribute should + /// be removed in the future in favour of some form of check which figures out whether the + /// function does not inspect the bits of any of its arguments (so is essentially just a + /// constructor function). + query is_promotable_const_fn(key: DefId) -> bool { + desc { |tcx| "checking if item is promotable: `{}`", tcx.def_path_str(key) } + } - /// Returns `Some(mutability)` if the node pointed to by `def_id` is a static item. - query static_mutability(def_id: DefId) -> Option { - desc { |tcx| "looking up static mutability of `{}`", tcx.def_path_str(def_id) } - } + /// Returns `true` if this is a foreign item (i.e., linked via `extern { ... }`). + query is_foreign_item(key: DefId) -> bool { + desc { |tcx| "checking if `{}` is a foreign item", tcx.def_path_str(key) } + } - /// Returns `Some(generator_kind)` if the node pointed to by `def_id` is a generator. - query generator_kind(def_id: DefId) -> Option { - desc { |tcx| "looking up generator kind of `{}`", tcx.def_path_str(def_id) } - } + /// Returns `Some(mutability)` if the node pointed to by `def_id` is a static item. + query static_mutability(def_id: DefId) -> Option { + desc { |tcx| "looking up static mutability of `{}`", tcx.def_path_str(def_id) } + } - /// Gets a map with the variance of every item; use `item_variance` instead. - query crate_variances(_: CrateNum) -> ty::CrateVariancesMap<'tcx> { - storage(ArenaCacheSelector<'tcx>) - desc { "computing the variances for items in this crate" } - } + /// Returns `Some(generator_kind)` if the node pointed to by `def_id` is a generator. + query generator_kind(def_id: DefId) -> Option { + desc { |tcx| "looking up generator kind of `{}`", tcx.def_path_str(def_id) } + } - /// Maps from the `DefId` of a type or region parameter to its (inferred) variance. - query variances_of(def_id: DefId) -> &'tcx [ty::Variance] { - desc { |tcx| "computing the variances of `{}`", tcx.def_path_str(def_id) } - } + /// Gets a map with the variance of every item; use `item_variance` instead. + query crate_variances(_: CrateNum) -> ty::CrateVariancesMap<'tcx> { + storage(ArenaCacheSelector<'tcx>) + desc { "computing the variances for items in this crate" } + } - /// Maps from thee `DefId` of a type to its (inferred) outlives. - query inferred_outlives_crate(_: CrateNum) - -> ty::CratePredicatesMap<'tcx> { - storage(ArenaCacheSelector<'tcx>) - desc { "computing the inferred outlives predicates for items in this crate" } + /// Maps from the `DefId` of a type or region parameter to its (inferred) variance. + query variances_of(def_id: DefId) -> &'tcx [ty::Variance] { + desc { |tcx| "computing the variances of `{}`", tcx.def_path_str(def_id) } + } } - /// Maps from an impl/trait `DefId to a list of the `DefId`s of its items. - query associated_item_def_ids(key: DefId) -> &'tcx [DefId] { - desc { |tcx| "collecting associated items of `{}`", tcx.def_path_str(key) } + TypeChecking { + /// Maps from thee `DefId` of a type to its (inferred) outlives. + query inferred_outlives_crate(_: CrateNum) + -> ty::CratePredicatesMap<'tcx> { + storage(ArenaCacheSelector<'tcx>) + desc { "computing the inferred outlives predicates for items in this crate" } + } } - /// Maps from a trait item to the trait item "descriptor". - query associated_item(key: DefId) -> ty::AssocItem { - desc { |tcx| "computing associated item data for `{}`", tcx.def_path_str(key) } - storage(ArenaCacheSelector<'tcx>) - } + Other { + /// Maps from an impl/trait `DefId to a list of the `DefId`s of its items. + query associated_item_def_ids(key: DefId) -> &'tcx [DefId] { + desc { |tcx| "collecting associated items of `{}`", tcx.def_path_str(key) } + } - /// Collects the associated items defined on a trait or impl. - query associated_items(key: DefId) -> ty::AssociatedItems<'tcx> { - storage(ArenaCacheSelector<'tcx>) - desc { |tcx| "collecting associated items of {}", tcx.def_path_str(key) } - } + /// Maps from a trait item to the trait item "descriptor". + query associated_item(key: DefId) -> ty::AssocItem { + desc { |tcx| "computing associated item data for `{}`", tcx.def_path_str(key) } + storage(ArenaCacheSelector<'tcx>) + } - /// Given an `impl_id`, return the trait it implements. - /// Return `None` if this is an inherent impl. - query impl_trait_ref(impl_id: DefId) -> Option> { - desc { |tcx| "computing trait implemented by `{}`", tcx.def_path_str(impl_id) } - } - query impl_polarity(impl_id: DefId) -> ty::ImplPolarity { - desc { |tcx| "computing implementation polarity of `{}`", tcx.def_path_str(impl_id) } - } + /// Collects the associated items defined on a trait or impl. + query associated_items(key: DefId) -> ty::AssociatedItems<'tcx> { + storage(ArenaCacheSelector<'tcx>) + desc { |tcx| "collecting associated items of {}", tcx.def_path_str(key) } + } - query issue33140_self_ty(key: DefId) -> Option> { - desc { |tcx| "computing Self type wrt issue #33140 `{}`", tcx.def_path_str(key) } - } + /// Given an `impl_id`, return the trait it implements. + /// Return `None` if this is an inherent impl. + query impl_trait_ref(impl_id: DefId) -> Option> { + desc { |tcx| "computing trait implemented by `{}`", tcx.def_path_str(impl_id) } + } + query impl_polarity(impl_id: DefId) -> ty::ImplPolarity { + desc { |tcx| "computing implementation polarity of `{}`", tcx.def_path_str(impl_id) } + } - /// Maps a `DefId` of a type to a list of its inherent impls. - /// Contains implementations of methods that are inherent to a type. - /// Methods in these implementations don't need to be exported. - query inherent_impls(key: DefId) -> &'tcx [DefId] { - desc { |tcx| "collecting inherent impls for `{}`", tcx.def_path_str(key) } - eval_always + query issue33140_self_ty(key: DefId) -> Option> { + desc { |tcx| "computing Self type wrt issue #33140 `{}`", tcx.def_path_str(key) } + } } - /// The result of unsafety-checking this `LocalDefId`. - query unsafety_check_result(key: LocalDefId) -> &'tcx mir::UnsafetyCheckResult { - desc { |tcx| "unsafety-checking `{}`", tcx.def_path_str(key.to_def_id()) } - cache_on_disk_if { true } - } - query unsafety_check_result_for_const_arg(key: (LocalDefId, DefId)) -> &'tcx mir::UnsafetyCheckResult { - desc { - |tcx| "unsafety-checking the const argument `{}`", - tcx.def_path_str(key.0.to_def_id()) + TypeChecking { + /// Maps a `DefId` of a type to a list of its inherent impls. + /// Contains implementations of methods that are inherent to a type. + /// Methods in these implementations don't need to be exported. + query inherent_impls(key: DefId) -> &'tcx [DefId] { + desc { |tcx| "collecting inherent impls for `{}`", tcx.def_path_str(key) } + eval_always } } - /// HACK: when evaluated, this reports a "unsafe derive on repr(packed)" error. - /// - /// Unsafety checking is executed for each method separately, but we only want - /// to emit this error once per derive. As there are some impls with multiple - /// methods, we use a query for deduplication. - query unsafe_derive_on_repr_packed(key: LocalDefId) -> () { - desc { |tcx| "processing `{}`", tcx.def_path_str(key.to_def_id()) } - } + TypeChecking { + /// The result of unsafety-checking this `LocalDefId`. + query unsafety_check_result(key: LocalDefId) -> &'tcx mir::UnsafetyCheckResult { + desc { |tcx| "unsafety-checking `{}`", tcx.def_path_str(key.to_def_id()) } + cache_on_disk_if { true } + } + query unsafety_check_result_for_const_arg(key: (LocalDefId, DefId)) -> &'tcx mir::UnsafetyCheckResult { + desc { + |tcx| "unsafety-checking the const argument `{}`", + tcx.def_path_str(key.0.to_def_id()) + } + } - /// The signature of functions. - query fn_sig(key: DefId) -> ty::PolyFnSig<'tcx> { - desc { |tcx| "computing function signature of `{}`", tcx.def_path_str(key) } - } + /// HACK: when evaluated, this reports a "unsafe derive on repr(packed)" error. + /// + /// Unsafety checking is executed for each method separately, but we only want + /// to emit this error once per derive. As there are some impls with multiple + /// methods, we use a query for deduplication. + query unsafe_derive_on_repr_packed(key: LocalDefId) -> () { + desc { |tcx| "processing `{}`", tcx.def_path_str(key.to_def_id()) } + } - query lint_mod(key: LocalDefId) -> () { - desc { |tcx| "linting {}", describe_as_module(key, tcx) } + /// The signature of functions. + query fn_sig(key: DefId) -> ty::PolyFnSig<'tcx> { + desc { |tcx| "computing function signature of `{}`", tcx.def_path_str(key) } + } } - /// Checks the attributes in the module. - query check_mod_attrs(key: LocalDefId) -> () { - desc { |tcx| "checking attributes in {}", describe_as_module(key, tcx) } - } + Other { + query lint_mod(key: LocalDefId) -> () { + desc { |tcx| "linting {}", describe_as_module(key, tcx) } + } - query check_mod_unstable_api_usage(key: LocalDefId) -> () { - desc { |tcx| "checking for unstable API usage in {}", describe_as_module(key, tcx) } - } + /// Checks the attributes in the module. + query check_mod_attrs(key: LocalDefId) -> () { + desc { |tcx| "checking attributes in {}", describe_as_module(key, tcx) } + } - /// Checks the const bodies in the module for illegal operations (e.g. `if` or `loop`). - query check_mod_const_bodies(key: LocalDefId) -> () { - desc { |tcx| "checking consts in {}", describe_as_module(key, tcx) } - } + query check_mod_unstable_api_usage(key: LocalDefId) -> () { + desc { |tcx| "checking for unstable API usage in {}", describe_as_module(key, tcx) } + } - /// Checks the loops in the module. - query check_mod_loops(key: LocalDefId) -> () { - desc { |tcx| "checking loops in {}", describe_as_module(key, tcx) } - } + /// Checks the const bodies in the module for illegal operations (e.g. `if` or `loop`). + query check_mod_const_bodies(key: LocalDefId) -> () { + desc { |tcx| "checking consts in {}", describe_as_module(key, tcx) } + } - query check_mod_naked_functions(key: LocalDefId) -> () { - desc { |tcx| "checking naked functions in {}", describe_as_module(key, tcx) } - } + /// Checks the loops in the module. + query check_mod_loops(key: LocalDefId) -> () { + desc { |tcx| "checking loops in {}", describe_as_module(key, tcx) } + } - query check_mod_item_types(key: LocalDefId) -> () { - desc { |tcx| "checking item types in {}", describe_as_module(key, tcx) } - } + query check_mod_naked_functions(key: LocalDefId) -> () { + desc { |tcx| "checking naked functions in {}", describe_as_module(key, tcx) } + } - query check_mod_privacy(key: LocalDefId) -> () { - desc { |tcx| "checking privacy in {}", describe_as_module(key, tcx) } - } + query check_mod_item_types(key: LocalDefId) -> () { + desc { |tcx| "checking item types in {}", describe_as_module(key, tcx) } + } - query check_mod_intrinsics(key: LocalDefId) -> () { - desc { |tcx| "checking intrinsics in {}", describe_as_module(key, tcx) } - } + query check_mod_privacy(key: LocalDefId) -> () { + desc { |tcx| "checking privacy in {}", describe_as_module(key, tcx) } + } - query check_mod_liveness(key: LocalDefId) -> () { - desc { |tcx| "checking liveness of variables in {}", describe_as_module(key, tcx) } - } + query check_mod_intrinsics(key: LocalDefId) -> () { + desc { |tcx| "checking intrinsics in {}", describe_as_module(key, tcx) } + } - query check_mod_impl_wf(key: LocalDefId) -> () { - desc { |tcx| "checking that impls are well-formed in {}", describe_as_module(key, tcx) } - } + query check_mod_liveness(key: LocalDefId) -> () { + desc { |tcx| "checking liveness of variables in {}", describe_as_module(key, tcx) } + } - query collect_mod_item_types(key: LocalDefId) -> () { - desc { |tcx| "collecting item types in {}", describe_as_module(key, tcx) } - } + query check_mod_impl_wf(key: LocalDefId) -> () { + desc { |tcx| "checking that impls are well-formed in {}", describe_as_module(key, tcx) } + } - /// Caches `CoerceUnsized` kinds for impls on custom types. - query coerce_unsized_info(key: DefId) - -> ty::adjustment::CoerceUnsizedInfo { - desc { |tcx| "computing CoerceUnsized info for `{}`", tcx.def_path_str(key) } + query collect_mod_item_types(key: LocalDefId) -> () { + desc { |tcx| "collecting item types in {}", describe_as_module(key, tcx) } } - query typeck_item_bodies(_: CrateNum) -> () { - desc { "type-checking all item bodies" } + /// Caches `CoerceUnsized` kinds for impls on custom types. + query coerce_unsized_info(key: DefId) + -> ty::adjustment::CoerceUnsizedInfo { + desc { |tcx| "computing CoerceUnsized info for `{}`", tcx.def_path_str(key) } + } } - query typeck(key: LocalDefId) -> &'tcx ty::TypeckResults<'tcx> { - desc { |tcx| "type-checking `{}`", tcx.def_path_str(key.to_def_id()) } - cache_on_disk_if { true } - } - query typeck_const_arg( - key: (LocalDefId, DefId) - ) -> &'tcx ty::TypeckResults<'tcx> { - desc { - |tcx| "type-checking the const argument `{}`", - tcx.def_path_str(key.0.to_def_id()), + TypeChecking { + query typeck_item_bodies(_: CrateNum) -> () { + desc { "type-checking all item bodies" } } - } - query diagnostic_only_typeck(key: LocalDefId) -> &'tcx ty::TypeckResults<'tcx> { - desc { |tcx| "type-checking `{}`", tcx.def_path_str(key.to_def_id()) } - cache_on_disk_if { true } - load_cached(tcx, id) { - let typeck_results: Option> = tcx - .queries.on_disk_cache.as_ref() - .and_then(|c| c.try_load_query_result(tcx, id)); - typeck_results.map(|x| &*tcx.arena.alloc(x)) + query typeck(key: LocalDefId) -> &'tcx ty::TypeckResults<'tcx> { + desc { |tcx| "type-checking `{}`", tcx.def_path_str(key.to_def_id()) } + cache_on_disk_if { true } + } + query typeck_const_arg( + key: (LocalDefId, DefId) + ) -> &'tcx ty::TypeckResults<'tcx> { + desc { + |tcx| "type-checking the const argument `{}`", + tcx.def_path_str(key.0.to_def_id()), + } + } + query diagnostic_only_typeck(key: LocalDefId) -> &'tcx ty::TypeckResults<'tcx> { + desc { |tcx| "type-checking `{}`", tcx.def_path_str(key.to_def_id()) } + cache_on_disk_if { true } + load_cached(tcx, id) { + let typeck_results: Option> = tcx + .queries.on_disk_cache.as_ref() + .and_then(|c| c.try_load_query_result(tcx, id)); + + typeck_results.map(|x| &*tcx.arena.alloc(x)) + } } } - query used_trait_imports(key: LocalDefId) -> &'tcx FxHashSet { - desc { |tcx| "used_trait_imports `{}`", tcx.def_path_str(key.to_def_id()) } - cache_on_disk_if { true } + Other { + query used_trait_imports(key: LocalDefId) -> &'tcx FxHashSet { + desc { |tcx| "used_trait_imports `{}`", tcx.def_path_str(key.to_def_id()) } + cache_on_disk_if { true } + } } - query has_typeck_results(def_id: DefId) -> bool { - desc { |tcx| "checking whether `{}` has a body", tcx.def_path_str(def_id) } - } + TypeChecking { + query has_typeck_results(def_id: DefId) -> bool { + desc { |tcx| "checking whether `{}` has a body", tcx.def_path_str(def_id) } + } - query coherent_trait(def_id: DefId) -> () { - desc { |tcx| "coherence checking all impls of trait `{}`", tcx.def_path_str(def_id) } + query coherent_trait(def_id: DefId) -> () { + desc { |tcx| "coherence checking all impls of trait `{}`", tcx.def_path_str(def_id) } + } } - /// Borrow-checks the function body. If this is a closure, returns - /// additional requirements that the closure's creator must verify. - query mir_borrowck(key: LocalDefId) -> &'tcx mir::BorrowCheckResult<'tcx> { - desc { |tcx| "borrow-checking `{}`", tcx.def_path_str(key.to_def_id()) } - cache_on_disk_if(tcx, opt_result) { - tcx.is_closure(key.to_def_id()) - || opt_result.map_or(false, |r| !r.concrete_opaque_types.is_empty()) + BorrowChecking { + /// Borrow-checks the function body. If this is a closure, returns + /// additional requirements that the closure's creator must verify. + query mir_borrowck(key: LocalDefId) -> &'tcx mir::BorrowCheckResult<'tcx> { + desc { |tcx| "borrow-checking `{}`", tcx.def_path_str(key.to_def_id()) } + cache_on_disk_if(tcx, opt_result) { + tcx.is_closure(key.to_def_id()) + || opt_result.map_or(false, |r| !r.concrete_opaque_types.is_empty()) + } } - } - query mir_borrowck_const_arg(key: (LocalDefId, DefId)) -> &'tcx mir::BorrowCheckResult<'tcx> { - desc { - |tcx| "borrow-checking the const argument`{}`", - tcx.def_path_str(key.0.to_def_id()) + query mir_borrowck_const_arg(key: (LocalDefId, DefId)) -> &'tcx mir::BorrowCheckResult<'tcx> { + desc { + |tcx| "borrow-checking the const argument`{}`", + tcx.def_path_str(key.0.to_def_id()) + } } } - /// Gets a complete map from all types to their inherent impls. - /// Not meant to be used directly outside of coherence. - /// (Defined only for `LOCAL_CRATE`.) - query crate_inherent_impls(k: CrateNum) - -> CrateInherentImpls { - storage(ArenaCacheSelector<'tcx>) - eval_always - desc { "all inherent impls defined in crate `{:?}`", k } - } - - /// Checks all types in the crate for overlap in their inherent impls. Reports errors. - /// Not meant to be used directly outside of coherence. - /// (Defined only for `LOCAL_CRATE`.) - query crate_inherent_impls_overlap_check(_: CrateNum) - -> () { - eval_always - desc { "check for overlap between inherent impls defined in this crate" } - } + TypeChecking { + /// Gets a complete map from all types to their inherent impls. + /// Not meant to be used directly outside of coherence. + /// (Defined only for `LOCAL_CRATE`.) + query crate_inherent_impls(k: CrateNum) + -> CrateInherentImpls { + storage(ArenaCacheSelector<'tcx>) + eval_always + desc { "all inherent impls defined in crate `{:?}`", k } + } - /// Check whether the function has any recursion that could cause the inliner to trigger - /// a cycle. Returns the call stack causing the cycle. The call stack does not contain the - /// current function, just all intermediate functions. - query mir_callgraph_reachable(key: (ty::Instance<'tcx>, LocalDefId)) -> bool { - fatal_cycle - desc { |tcx| - "computing if `{}` (transitively) calls `{}`", - key.0, - tcx.def_path_str(key.1.to_def_id()), + /// Checks all types in the crate for overlap in their inherent impls. Reports errors. + /// Not meant to be used directly outside of coherence. + /// (Defined only for `LOCAL_CRATE`.) + query crate_inherent_impls_overlap_check(_: CrateNum) + -> () { + eval_always + desc { "check for overlap between inherent impls defined in this crate" } } } - /// Obtain all the calls into other local functions - query mir_inliner_callees(key: ty::InstanceDef<'tcx>) -> &'tcx [(DefId, SubstsRef<'tcx>)] { - fatal_cycle - desc { |tcx| - "computing all local function calls in `{}`", - tcx.def_path_str(key.def_id()), + Other { + /// Check whether the function has any recursion that could cause the inliner to trigger + /// a cycle. Returns the call stack causing the cycle. The call stack does not contain the + /// current function, just all intermediate functions. + query mir_callgraph_reachable(key: (ty::Instance<'tcx>, LocalDefId)) -> bool { + fatal_cycle + desc { |tcx| + "computing if `{}` (transitively) calls `{}`", + key.0, + tcx.def_path_str(key.1.to_def_id()), + } } - } - /// Evaluates a constant and returns the computed allocation. - /// - /// **Do not use this** directly, use the `tcx.eval_static_initializer` wrapper. - query eval_to_allocation_raw(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>) - -> EvalToAllocationRawResult<'tcx> { - desc { |tcx| - "const-evaluating + checking `{}`", - key.value.display(tcx) + /// Obtain all the calls into other local functions + query mir_inliner_callees(key: ty::InstanceDef<'tcx>) -> &'tcx [(DefId, SubstsRef<'tcx>)] { + fatal_cycle + desc { |tcx| + "computing all local function calls in `{}`", + tcx.def_path_str(key.def_id()), + } } - cache_on_disk_if { true } - } - /// Evaluates const items or anonymous constants - /// (such as enum variant explicit discriminants or array lengths) - /// into a representation suitable for the type system and const generics. - /// - /// **Do not use this** directly, use one of the following wrappers: `tcx.const_eval_poly`, - /// `tcx.const_eval_resolve`, `tcx.const_eval_instance`, or `tcx.const_eval_global_id`. - query eval_to_const_value_raw(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>) - -> EvalToConstValueResult<'tcx> { - desc { |tcx| - "simplifying constant for the type system `{}`", - key.value.display(tcx) - } - cache_on_disk_if { true } - } + /// Evaluates a constant and returns the computed allocation. + /// + /// **Do not use this** directly, use the `tcx.eval_static_initializer` wrapper. + query eval_to_allocation_raw(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>) + -> EvalToAllocationRawResult<'tcx> { + desc { |tcx| + "const-evaluating + checking `{}`", + key.value.display(tcx) + } + cache_on_disk_if { true } + } - /// Destructure a constant ADT or array into its variant index and its - /// field values. - query destructure_const( - key: ty::ParamEnvAnd<'tcx, &'tcx ty::Const<'tcx>> - ) -> mir::DestructuredConst<'tcx> { - desc { "destructure constant" } - } + /// Evaluates const items or anonymous constants + /// (such as enum variant explicit discriminants or array lengths) + /// into a representation suitable for the type system and const generics. + /// + /// **Do not use this** directly, use one of the following wrappers: `tcx.const_eval_poly`, + /// `tcx.const_eval_resolve`, `tcx.const_eval_instance`, or `tcx.const_eval_global_id`. + query eval_to_const_value_raw(key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>) + -> EvalToConstValueResult<'tcx> { + desc { |tcx| + "simplifying constant for the type system `{}`", + key.value.display(tcx) + } + cache_on_disk_if { true } + } - /// Dereference a constant reference or raw pointer and turn the result into a constant - /// again. - query deref_const( - key: ty::ParamEnvAnd<'tcx, &'tcx ty::Const<'tcx>> - ) -> &'tcx ty::Const<'tcx> { - desc { "deref constant" } - } + /// Destructure a constant ADT or array into its variant index and its + /// field values. + query destructure_const( + key: ty::ParamEnvAnd<'tcx, &'tcx ty::Const<'tcx>> + ) -> mir::DestructuredConst<'tcx> { + desc { "destructure constant" } + } - query const_caller_location(key: (rustc_span::Symbol, u32, u32)) -> ConstValue<'tcx> { - desc { "get a &core::panic::Location referring to a span" } - } + /// Dereference a constant reference or raw pointer and turn the result into a constant + /// again. + query deref_const( + key: ty::ParamEnvAnd<'tcx, &'tcx ty::Const<'tcx>> + ) -> &'tcx ty::Const<'tcx> { + desc { "deref constant" } + } - query lit_to_const( - key: LitToConstInput<'tcx> - ) -> Result<&'tcx ty::Const<'tcx>, LitToConstError> { - desc { "converting literal to const" } - } + query const_caller_location(key: (rustc_span::Symbol, u32, u32)) -> ConstValue<'tcx> { + desc { "get a &core::panic::Location referring to a span" } + } - query check_match(key: DefId) { - desc { |tcx| "match-checking `{}`", tcx.def_path_str(key) } - cache_on_disk_if { key.is_local() } + query lit_to_const( + key: LitToConstInput<'tcx> + ) -> Result<&'tcx ty::Const<'tcx>, LitToConstError> { + desc { "converting literal to const" } + } } - /// Performs part of the privacy check and computes "access levels". - query privacy_access_levels(_: CrateNum) -> &'tcx AccessLevels { - eval_always - desc { "privacy access levels" } - } - query check_private_in_public(_: CrateNum) -> () { - eval_always - desc { "checking for private elements in public interfaces" } - } + TypeChecking { + query check_match(key: DefId) { + desc { |tcx| "match-checking `{}`", tcx.def_path_str(key) } + cache_on_disk_if { key.is_local() } + } - query reachable_set(_: CrateNum) -> FxHashSet { - storage(ArenaCacheSelector<'tcx>) - desc { "reachability" } + /// Performs part of the privacy check and computes "access levels". + query privacy_access_levels(_: CrateNum) -> &'tcx AccessLevels { + eval_always + desc { "privacy access levels" } + } + query check_private_in_public(_: CrateNum) -> () { + eval_always + desc { "checking for private elements in public interfaces" } + } } - /// Per-body `region::ScopeTree`. The `DefId` should be the owner `DefId` for the body; - /// in the case of closures, this will be redirected to the enclosing function. - query region_scope_tree(def_id: DefId) -> &'tcx region::ScopeTree { - desc { |tcx| "computing drop scopes for `{}`", tcx.def_path_str(def_id) } - } + Other { + query reachable_set(_: CrateNum) -> FxHashSet { + storage(ArenaCacheSelector<'tcx>) + desc { "reachability" } + } - query mir_shims(key: ty::InstanceDef<'tcx>) -> mir::Body<'tcx> { - storage(ArenaCacheSelector<'tcx>) - desc { |tcx| "generating MIR shim for `{}`", tcx.def_path_str(key.def_id()) } - } + /// Per-body `region::ScopeTree`. The `DefId` should be the owner `DefId` for the body; + /// in the case of closures, this will be redirected to the enclosing function. + query region_scope_tree(def_id: DefId) -> &'tcx region::ScopeTree { + desc { |tcx| "computing drop scopes for `{}`", tcx.def_path_str(def_id) } + } - /// The `symbol_name` query provides the symbol name for calling a - /// given instance from the local crate. In particular, it will also - /// look up the correct symbol name of instances from upstream crates. - query symbol_name(key: ty::Instance<'tcx>) -> ty::SymbolName<'tcx> { - desc { "computing the symbol for `{}`", key } - cache_on_disk_if { true } - } + query mir_shims(key: ty::InstanceDef<'tcx>) -> mir::Body<'tcx> { + storage(ArenaCacheSelector<'tcx>) + desc { |tcx| "generating MIR shim for `{}`", tcx.def_path_str(key.def_id()) } + } - query opt_def_kind(def_id: DefId) -> Option { - desc { |tcx| "looking up definition kind of `{}`", tcx.def_path_str(def_id) } - } + /// The `symbol_name` query provides the symbol name for calling a + /// given instance from the local crate. In particular, it will also + /// look up the correct symbol name of instances from upstream crates. + query symbol_name(key: ty::Instance<'tcx>) -> ty::SymbolName<'tcx> { + desc { "computing the symbol for `{}`", key } + cache_on_disk_if { true } + } - query def_span(def_id: DefId) -> Span { - desc { |tcx| "looking up span for `{}`", tcx.def_path_str(def_id) } - // FIXME(mw): DefSpans are not really inputs since they are derived from - // HIR. But at the moment HIR hashing still contains some hacks that allow - // to make type debuginfo to be source location independent. Declaring - // DefSpan an input makes sure that changes to these are always detected - // regardless of HIR hashing. - eval_always - } + query opt_def_kind(def_id: DefId) -> Option { + desc { |tcx| "looking up definition kind of `{}`", tcx.def_path_str(def_id) } + } - query def_ident_span(def_id: DefId) -> Option { - desc { |tcx| "looking up span for `{}`'s identifier", tcx.def_path_str(def_id) } - } + query def_span(def_id: DefId) -> Span { + desc { |tcx| "looking up span for `{}`", tcx.def_path_str(def_id) } + // FIXME(mw): DefSpans are not really inputs since they are derived from + // HIR. But at the moment HIR hashing still contains some hacks that allow + // to make type debuginfo to be source location independent. Declaring + // DefSpan an input makes sure that changes to these are always detected + // regardless of HIR hashing. + eval_always + } - query lookup_stability(def_id: DefId) -> Option<&'tcx attr::Stability> { - desc { |tcx| "looking up stability of `{}`", tcx.def_path_str(def_id) } - } + query def_ident_span(def_id: DefId) -> Option { + desc { |tcx| "looking up span for `{}`'s identifier", tcx.def_path_str(def_id) } + } - query lookup_const_stability(def_id: DefId) -> Option<&'tcx attr::ConstStability> { - desc { |tcx| "looking up const stability of `{}`", tcx.def_path_str(def_id) } - } + query lookup_stability(def_id: DefId) -> Option<&'tcx attr::Stability> { + desc { |tcx| "looking up stability of `{}`", tcx.def_path_str(def_id) } + } - query lookup_deprecation_entry(def_id: DefId) -> Option { - desc { |tcx| "checking whether `{}` is deprecated", tcx.def_path_str(def_id) } - } + query lookup_const_stability(def_id: DefId) -> Option<&'tcx attr::ConstStability> { + desc { |tcx| "looking up const stability of `{}`", tcx.def_path_str(def_id) } + } - query item_attrs(def_id: DefId) -> &'tcx [ast::Attribute] { - desc { |tcx| "collecting attributes of `{}`", tcx.def_path_str(def_id) } - } + query lookup_deprecation_entry(def_id: DefId) -> Option { + desc { |tcx| "checking whether `{}` is deprecated", tcx.def_path_str(def_id) } + } - query codegen_fn_attrs(def_id: DefId) -> CodegenFnAttrs { - desc { |tcx| "computing codegen attributes of `{}`", tcx.def_path_str(def_id) } - storage(ArenaCacheSelector<'tcx>) - cache_on_disk_if { true } + query item_attrs(def_id: DefId) -> &'tcx [ast::Attribute] { + desc { |tcx| "collecting attributes of `{}`", tcx.def_path_str(def_id) } + } } - query fn_arg_names(def_id: DefId) -> &'tcx [rustc_span::symbol::Ident] { - desc { |tcx| "looking up function parameter names for `{}`", tcx.def_path_str(def_id) } - } - /// Gets the rendered value of the specified constant or associated constant. - /// Used by rustdoc. - query rendered_const(def_id: DefId) -> String { - desc { |tcx| "rendering constant intializer of `{}`", tcx.def_path_str(def_id) } - } - query impl_parent(def_id: DefId) -> Option { - desc { |tcx| "computing specialization parent impl of `{}`", tcx.def_path_str(def_id) } + Codegen { + query codegen_fn_attrs(def_id: DefId) -> CodegenFnAttrs { + desc { |tcx| "computing codegen attributes of `{}`", tcx.def_path_str(def_id) } + storage(ArenaCacheSelector<'tcx>) + cache_on_disk_if { true } + } } - /// Given an `associated_item`, find the trait it belongs to. - /// Return `None` if the `DefId` is not an associated item. - query trait_of_item(associated_item: DefId) -> Option { - desc { |tcx| "finding trait defining `{}`", tcx.def_path_str(associated_item) } + Other { + query fn_arg_names(def_id: DefId) -> &'tcx [rustc_span::symbol::Ident] { + desc { |tcx| "looking up function parameter names for `{}`", tcx.def_path_str(def_id) } + } + /// Gets the rendered value of the specified constant or associated constant. + /// Used by rustdoc. + query rendered_const(def_id: DefId) -> String { + desc { |tcx| "rendering constant intializer of `{}`", tcx.def_path_str(def_id) } + } + query impl_parent(def_id: DefId) -> Option { + desc { |tcx| "computing specialization parent impl of `{}`", tcx.def_path_str(def_id) } + } } - query is_ctfe_mir_available(key: DefId) -> bool { - desc { |tcx| "checking if item has ctfe mir available: `{}`", tcx.def_path_str(key) } - } - query is_mir_available(key: DefId) -> bool { - desc { |tcx| "checking if item has mir available: `{}`", tcx.def_path_str(key) } + TypeChecking { + /// Given an `associated_item`, find the trait it belongs to. + /// Return `None` if the `DefId` is not an associated item. + query trait_of_item(associated_item: DefId) -> Option { + desc { |tcx| "finding trait defining `{}`", tcx.def_path_str(associated_item) } + } } - query vtable_methods(key: ty::PolyTraitRef<'tcx>) - -> &'tcx [Option<(DefId, SubstsRef<'tcx>)>] { - desc { |tcx| "finding all methods for trait {}", tcx.def_path_str(key.def_id()) } + Codegen { + query is_ctfe_mir_available(key: DefId) -> bool { + desc { |tcx| "checking if item has ctfe mir available: `{}`", tcx.def_path_str(key) } + } + query is_mir_available(key: DefId) -> bool { + desc { |tcx| "checking if item has mir available: `{}`", tcx.def_path_str(key) } + } } - query codegen_fulfill_obligation( - key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>) - ) -> Result, ErrorReported> { - cache_on_disk_if { true } - desc { |tcx| - "checking if `{}` fulfills its obligations", - tcx.def_path_str(key.1.def_id()) + Other { + query vtable_methods(key: ty::PolyTraitRef<'tcx>) + -> &'tcx [Option<(DefId, SubstsRef<'tcx>)>] { + desc { |tcx| "finding all methods for trait {}", tcx.def_path_str(key.def_id()) } } } - /// Return all `impl` blocks in the current crate. - /// - /// To allow caching this between crates, you must pass in [`LOCAL_CRATE`] as the crate number. - /// Passing in any other crate will cause an ICE. - /// - /// [`LOCAL_CRATE`]: rustc_hir::def_id::LOCAL_CRATE - query all_local_trait_impls(local_crate: CrateNum) -> &'tcx BTreeMap> { - desc { "local trait impls" } + Codegen { + query codegen_fulfill_obligation( + key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>) + ) -> Result, ErrorReported> { + cache_on_disk_if { true } + desc { |tcx| + "checking if `{}` fulfills its obligations", + tcx.def_path_str(key.1.def_id()) + } + } } - /// Given a trait `trait_id`, return all known `impl` blocks. - query trait_impls_of(trait_id: DefId) -> ty::trait_def::TraitImpls { - storage(ArenaCacheSelector<'tcx>) - desc { |tcx| "trait impls of `{}`", tcx.def_path_str(trait_id) } - } + TypeChecking { + /// Return all `impl` blocks in the current crate. + /// + /// To allow caching this between crates, you must pass in [`LOCAL_CRATE`] as the crate number. + /// Passing in any other crate will cause an ICE. + /// + /// [`LOCAL_CRATE`]: rustc_hir::def_id::LOCAL_CRATE + query all_local_trait_impls(local_crate: CrateNum) -> &'tcx BTreeMap> { + desc { "local trait impls" } + } - query specialization_graph_of(trait_id: DefId) -> specialization_graph::Graph { - storage(ArenaCacheSelector<'tcx>) - desc { |tcx| "building specialization graph of trait `{}`", tcx.def_path_str(trait_id) } - cache_on_disk_if { true } - } - query object_safety_violations(trait_id: DefId) -> &'tcx [traits::ObjectSafetyViolation] { - desc { |tcx| "determine object safety of trait `{}`", tcx.def_path_str(trait_id) } - } + /// Given a trait `trait_id`, return all known `impl` blocks. + query trait_impls_of(trait_id: DefId) -> ty::trait_def::TraitImpls { + storage(ArenaCacheSelector<'tcx>) + desc { |tcx| "trait impls of `{}`", tcx.def_path_str(trait_id) } + } - /// Gets the ParameterEnvironment for a given item; this environment - /// will be in "user-facing" mode, meaning that it is suitable for - /// type-checking etc, and it does not normalize specializable - /// associated types. This is almost always what you want, - /// unless you are doing MIR optimizations, in which case you - /// might want to use `reveal_all()` method to change modes. - query param_env(def_id: DefId) -> ty::ParamEnv<'tcx> { - desc { |tcx| "computing normalized predicates of `{}`", tcx.def_path_str(def_id) } - } + query specialization_graph_of(trait_id: DefId) -> specialization_graph::Graph { + storage(ArenaCacheSelector<'tcx>) + desc { |tcx| "building specialization graph of trait `{}`", tcx.def_path_str(trait_id) } + cache_on_disk_if { true } + } + query object_safety_violations(trait_id: DefId) -> &'tcx [traits::ObjectSafetyViolation] { + desc { |tcx| "determine object safety of trait `{}`", tcx.def_path_str(trait_id) } + } - /// Like `param_env`, but returns the `ParamEnv in `Reveal::All` mode. - /// Prefer this over `tcx.param_env(def_id).with_reveal_all_normalized(tcx)`, - /// as this method is more efficient. - query param_env_reveal_all_normalized(def_id: DefId) -> ty::ParamEnv<'tcx> { - desc { |tcx| "computing revealed normalized predicates of `{}`", tcx.def_path_str(def_id) } - } + /// Gets the ParameterEnvironment for a given item; this environment + /// will be in "user-facing" mode, meaning that it is suitable for + /// type-checking etc, and it does not normalize specializable + /// associated types. This is almost always what you want, + /// unless you are doing MIR optimizations, in which case you + /// might want to use `reveal_all()` method to change modes. + query param_env(def_id: DefId) -> ty::ParamEnv<'tcx> { + desc { |tcx| "computing normalized predicates of `{}`", tcx.def_path_str(def_id) } + } - /// Trait selection queries. These are best used by invoking `ty.is_copy_modulo_regions()`, - /// `ty.is_copy()`, etc, since that will prune the environment where possible. - query is_copy_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool { - desc { "computing whether `{}` is `Copy`", env.value } - } - /// Query backing `TyS::is_sized`. - query is_sized_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool { - desc { "computing whether `{}` is `Sized`", env.value } - } - /// Query backing `TyS::is_freeze`. - query is_freeze_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool { - desc { "computing whether `{}` is freeze", env.value } - } - /// Query backing `TyS::needs_drop`. - query needs_drop_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool { - desc { "computing whether `{}` needs drop", env.value } - } + /// Like `param_env`, but returns the `ParamEnv in `Reveal::All` mode. + /// Prefer this over `tcx.param_env(def_id).with_reveal_all_normalized(tcx)`, + /// as this method is more efficient. + query param_env_reveal_all_normalized(def_id: DefId) -> ty::ParamEnv<'tcx> { + desc { |tcx| "computing revealed normalized predicates of `{}`", tcx.def_path_str(def_id) } + } - /// Query backing `TyS::is_structural_eq_shallow`. - /// - /// This is only correct for ADTs. Call `is_structural_eq_shallow` to handle all types - /// correctly. - query has_structural_eq_impls(ty: Ty<'tcx>) -> bool { - desc { - "computing whether `{:?}` implements `PartialStructuralEq` and `StructuralEq`", - ty + /// Trait selection queries. These are best used by invoking `ty.is_copy_modulo_regions()`, + /// `ty.is_copy()`, etc, since that will prune the environment where possible. + query is_copy_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool { + desc { "computing whether `{}` is `Copy`", env.value } + } + /// Query backing `TyS::is_sized`. + query is_sized_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool { + desc { "computing whether `{}` is `Sized`", env.value } + } + /// Query backing `TyS::is_freeze`. + query is_freeze_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool { + desc { "computing whether `{}` is freeze", env.value } + } + /// Query backing `TyS::needs_drop`. + query needs_drop_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool { + desc { "computing whether `{}` needs drop", env.value } } - } - /// A list of types where the ADT requires drop if and only if any of - /// those types require drop. If the ADT is known to always need drop - /// then `Err(AlwaysRequiresDrop)` is returned. - query adt_drop_tys(def_id: DefId) -> Result<&'tcx ty::List>, AlwaysRequiresDrop> { - desc { |tcx| "computing when `{}` needs drop", tcx.def_path_str(def_id) } - cache_on_disk_if { true } - } + /// Query backing `TyS::is_structural_eq_shallow`. + /// + /// This is only correct for ADTs. Call `is_structural_eq_shallow` to handle all types + /// correctly. + query has_structural_eq_impls(ty: Ty<'tcx>) -> bool { + desc { + "computing whether `{:?}` implements `PartialStructuralEq` and `StructuralEq`", + ty + } + } - query layout_raw( - env: ty::ParamEnvAnd<'tcx, Ty<'tcx>> - ) -> Result<&'tcx rustc_target::abi::Layout, ty::layout::LayoutError<'tcx>> { - desc { "computing layout of `{}`", env.value } - } + /// A list of types where the ADT requires drop if and only if any of + /// those types require drop. If the ADT is known to always need drop + /// then `Err(AlwaysRequiresDrop)` is returned. + query adt_drop_tys(def_id: DefId) -> Result<&'tcx ty::List>, AlwaysRequiresDrop> { + desc { |tcx| "computing when `{}` needs drop", tcx.def_path_str(def_id) } + cache_on_disk_if { true } + } - query dylib_dependency_formats(_: CrateNum) - -> &'tcx [(CrateNum, LinkagePreference)] { - desc { "dylib dependency formats of crate" } + query layout_raw( + env: ty::ParamEnvAnd<'tcx, Ty<'tcx>> + ) -> Result<&'tcx rustc_target::abi::Layout, ty::layout::LayoutError<'tcx>> { + desc { "computing layout of `{}`", env.value } + } } - query dependency_formats(_: CrateNum) - -> Lrc - { - desc { "get the linkage format of all dependencies" } - } + Other { + query dylib_dependency_formats(_: CrateNum) + -> &'tcx [(CrateNum, LinkagePreference)] { + desc { "dylib dependency formats of crate" } + } - query is_compiler_builtins(_: CrateNum) -> bool { - fatal_cycle - desc { "checking if the crate is_compiler_builtins" } - } - query has_global_allocator(_: CrateNum) -> bool { - fatal_cycle - desc { "checking if the crate has_global_allocator" } - } - query has_panic_handler(_: CrateNum) -> bool { - fatal_cycle - desc { "checking if the crate has_panic_handler" } - } - query is_profiler_runtime(_: CrateNum) -> bool { - fatal_cycle - desc { "query a crate is `#![profiler_runtime]`" } - } - query panic_strategy(_: CrateNum) -> PanicStrategy { - fatal_cycle - desc { "query a crate's configured panic strategy" } - } - query is_no_builtins(_: CrateNum) -> bool { - fatal_cycle - desc { "test whether a crate has `#![no_builtins]`" } - } - query symbol_mangling_version(_: CrateNum) -> SymbolManglingVersion { - fatal_cycle - desc { "query a crate's symbol mangling version" } + query dependency_formats(_: CrateNum) + -> Lrc + { + desc { "get the linkage format of all dependencies" } + } } - query extern_crate(def_id: DefId) -> Option<&'tcx ExternCrate> { - eval_always - desc { "getting crate's ExternCrateData" } - } + Codegen { + query is_compiler_builtins(_: CrateNum) -> bool { + fatal_cycle + desc { "checking if the crate is_compiler_builtins" } + } + query has_global_allocator(_: CrateNum) -> bool { + fatal_cycle + desc { "checking if the crate has_global_allocator" } + } + query has_panic_handler(_: CrateNum) -> bool { + fatal_cycle + desc { "checking if the crate has_panic_handler" } + } + query is_profiler_runtime(_: CrateNum) -> bool { + fatal_cycle + desc { "query a crate is `#![profiler_runtime]`" } + } + query panic_strategy(_: CrateNum) -> PanicStrategy { + fatal_cycle + desc { "query a crate's configured panic strategy" } + } + query is_no_builtins(_: CrateNum) -> bool { + fatal_cycle + desc { "test whether a crate has `#![no_builtins]`" } + } + query symbol_mangling_version(_: CrateNum) -> SymbolManglingVersion { + fatal_cycle + desc { "query a crate's symbol mangling version" } + } - query specializes(_: (DefId, DefId)) -> bool { - desc { "computing whether impls specialize one another" } - } - query in_scope_traits_map(_: LocalDefId) - -> Option<&'tcx FxHashMap>> { - eval_always - desc { "traits in scope at a block" } + query extern_crate(def_id: DefId) -> Option<&'tcx ExternCrate> { + eval_always + desc { "getting crate's ExternCrateData" } + } } - query module_exports(def_id: LocalDefId) -> Option<&'tcx [Export]> { - desc { |tcx| "looking up items exported by `{}`", tcx.def_path_str(def_id.to_def_id()) } - eval_always + TypeChecking { + query specializes(_: (DefId, DefId)) -> bool { + desc { "computing whether impls specialize one another" } + } + query in_scope_traits_map(_: LocalDefId) + -> Option<&'tcx FxHashMap>> { + eval_always + desc { "traits in scope at a block" } + } } - query impl_defaultness(def_id: DefId) -> hir::Defaultness { - desc { |tcx| "looking up whether `{}` is a default impl", tcx.def_path_str(def_id) } + Other { + query module_exports(def_id: LocalDefId) -> Option<&'tcx [Export]> { + desc { |tcx| "looking up items exported by `{}`", tcx.def_path_str(def_id.to_def_id()) } + eval_always + } } - query check_item_well_formed(key: LocalDefId) -> () { - desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key.to_def_id()) } - } - query check_trait_item_well_formed(key: LocalDefId) -> () { - desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key.to_def_id()) } - } - query check_impl_item_well_formed(key: LocalDefId) -> () { - desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key.to_def_id()) } - } + TypeChecking { + query impl_defaultness(def_id: DefId) -> hir::Defaultness { + desc { |tcx| "looking up whether `{}` is a default impl", tcx.def_path_str(def_id) } + } - // The `DefId`s of all non-generic functions and statics in the given crate - // that can be reached from outside the crate. - // - // We expect this items to be available for being linked to. - // - // This query can also be called for `LOCAL_CRATE`. In this case it will - // compute which items will be reachable to other crates, taking into account - // the kind of crate that is currently compiled. Crates with only a - // C interface have fewer reachable things. - // - // Does not include external symbols that don't have a corresponding DefId, - // like the compiler-generated `main` function and so on. - query reachable_non_generics(_: CrateNum) - -> DefIdMap { - storage(ArenaCacheSelector<'tcx>) - desc { "looking up the exported symbols of a crate" } - } - query is_reachable_non_generic(def_id: DefId) -> bool { - desc { |tcx| "checking whether `{}` is an exported symbol", tcx.def_path_str(def_id) } - } - query is_unreachable_local_definition(def_id: DefId) -> bool { - desc { |tcx| - "checking whether `{}` is reachable from outside the crate", - tcx.def_path_str(def_id), + query check_item_well_formed(key: LocalDefId) -> () { + desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key.to_def_id()) } + } + query check_trait_item_well_formed(key: LocalDefId) -> () { + desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key.to_def_id()) } + } + query check_impl_item_well_formed(key: LocalDefId) -> () { + desc { |tcx| "checking that `{}` is well-formed", tcx.def_path_str(key.to_def_id()) } } } - /// The entire set of monomorphizations the local crate can safely link - /// to because they are exported from upstream crates. Do not depend on - /// this directly, as its value changes anytime a monomorphization gets - /// added or removed in any upstream crate. Instead use the narrower - /// `upstream_monomorphizations_for`, `upstream_drop_glue_for`, or, even - /// better, `Instance::upstream_monomorphization()`. - query upstream_monomorphizations( - k: CrateNum - ) -> DefIdMap, CrateNum>> { - storage(ArenaCacheSelector<'tcx>) - desc { "collecting available upstream monomorphizations `{:?}`", k } - } - /// Returns the set of upstream monomorphizations available for the - /// generic function identified by the given `def_id`. The query makes - /// sure to make a stable selection if the same monomorphization is - /// available in multiple upstream crates. - /// - /// You likely want to call `Instance::upstream_monomorphization()` - /// instead of invoking this query directly. - query upstream_monomorphizations_for(def_id: DefId) - -> Option<&'tcx FxHashMap, CrateNum>> { + Linking { + // The `DefId`s of all non-generic functions and statics in the given crate + // that can be reached from outside the crate. + // + // We expect this items to be available for being linked to. + // + // This query can also be called for `LOCAL_CRATE`. In this case it will + // compute which items will be reachable to other crates, taking into account + // the kind of crate that is currently compiled. Crates with only a + // C interface have fewer reachable things. + // + // Does not include external symbols that don't have a corresponding DefId, + // like the compiler-generated `main` function and so on. + query reachable_non_generics(_: CrateNum) + -> DefIdMap { + storage(ArenaCacheSelector<'tcx>) + desc { "looking up the exported symbols of a crate" } + } + query is_reachable_non_generic(def_id: DefId) -> bool { + desc { |tcx| "checking whether `{}` is an exported symbol", tcx.def_path_str(def_id) } + } + query is_unreachable_local_definition(def_id: DefId) -> bool { desc { |tcx| - "collecting available upstream monomorphizations for `{}`", + "checking whether `{}` is reachable from outside the crate", tcx.def_path_str(def_id), } } - - /// Returns the upstream crate that exports drop-glue for the given - /// type (`substs` is expected to be a single-item list containing the - /// type one wants drop-glue for). - /// - /// This is a subset of `upstream_monomorphizations_for` in order to - /// increase dep-tracking granularity. Otherwise adding or removing any - /// type with drop-glue in any upstream crate would invalidate all - /// functions calling drop-glue of an upstream type. - /// - /// You likely want to call `Instance::upstream_monomorphization()` - /// instead of invoking this query directly. - /// - /// NOTE: This query could easily be extended to also support other - /// common functions that have are large set of monomorphizations - /// (like `Clone::clone` for example). - query upstream_drop_glue_for(substs: SubstsRef<'tcx>) -> Option { - desc { "available upstream drop-glue for `{:?}`", substs } } - query foreign_modules(_: CrateNum) -> Lrc> { - desc { "looking up the foreign modules of a linked crate" } - } + Codegen { + /// The entire set of monomorphizations the local crate can safely link + /// to because they are exported from upstream crates. Do not depend on + /// this directly, as its value changes anytime a monomorphization gets + /// added or removed in any upstream crate. Instead use the narrower + /// `upstream_monomorphizations_for`, `upstream_drop_glue_for`, or, even + /// better, `Instance::upstream_monomorphization()`. + query upstream_monomorphizations( + k: CrateNum + ) -> DefIdMap, CrateNum>> { + storage(ArenaCacheSelector<'tcx>) + desc { "collecting available upstream monomorphizations `{:?}`", k } + } - /// Identifies the entry-point (e.g., the `main` function) for a given - /// crate, returning `None` if there is no entry point (such as for library crates). - query entry_fn(_: CrateNum) -> Option<(LocalDefId, EntryFnType)> { - desc { "looking up the entry function of a crate" } - } - query plugin_registrar_fn(_: CrateNum) -> Option { - desc { "looking up the plugin registrar for a crate" } - } - query proc_macro_decls_static(_: CrateNum) -> Option { - desc { "looking up the derive registrar for a crate" } - } - query crate_disambiguator(_: CrateNum) -> CrateDisambiguator { - eval_always - desc { "looking up the disambiguator a crate" } - } - // The macro which defines `rustc_metadata::provide_extern` depends on this query's name. - // Changing the name should cause a compiler error, but in case that changes, be aware. - query crate_hash(_: CrateNum) -> Svh { - eval_always - desc { "looking up the hash a crate" } - } - query crate_host_hash(_: CrateNum) -> Option { - eval_always - desc { "looking up the hash of a host version of a crate" } - } - query original_crate_name(_: CrateNum) -> Symbol { - eval_always - desc { "looking up the original name a crate" } - } - query extra_filename(_: CrateNum) -> String { - eval_always - desc { "looking up the extra filename for a crate" } - } - query crate_extern_paths(_: CrateNum) -> Vec { - eval_always - desc { "looking up the paths for extern crates" } - } + /// Returns the set of upstream monomorphizations available for the + /// generic function identified by the given `def_id`. The query makes + /// sure to make a stable selection if the same monomorphization is + /// available in multiple upstream crates. + /// + /// You likely want to call `Instance::upstream_monomorphization()` + /// instead of invoking this query directly. + query upstream_monomorphizations_for(def_id: DefId) + -> Option<&'tcx FxHashMap, CrateNum>> { + desc { |tcx| + "collecting available upstream monomorphizations for `{}`", + tcx.def_path_str(def_id), + } + } - /// Given a crate and a trait, look up all impls of that trait in the crate. - /// Return `(impl_id, self_ty)`. - query implementations_of_trait(_: (CrateNum, DefId)) - -> &'tcx [(DefId, Option)] { - desc { "looking up implementations of a trait in a crate" } + /// Returns the upstream crate that exports drop-glue for the given + /// type (`substs` is expected to be a single-item list containing the + /// type one wants drop-glue for). + /// + /// This is a subset of `upstream_monomorphizations_for` in order to + /// increase dep-tracking granularity. Otherwise adding or removing any + /// type with drop-glue in any upstream crate would invalidate all + /// functions calling drop-glue of an upstream type. + /// + /// You likely want to call `Instance::upstream_monomorphization()` + /// instead of invoking this query directly. + /// + /// NOTE: This query could easily be extended to also support other + /// common functions that have are large set of monomorphizations + /// (like `Clone::clone` for example). + query upstream_drop_glue_for(substs: SubstsRef<'tcx>) -> Option { + desc { "available upstream drop-glue for `{:?}`", substs } + } } - /// Given a crate, look up all trait impls in that crate. - /// Return `(impl_id, self_ty)`. - query all_trait_implementations(_: CrateNum) - -> &'tcx [(DefId, Option)] { - desc { "looking up all (?) trait implementations" } - } + Other { + query foreign_modules(_: CrateNum) -> Lrc> { + desc { "looking up the foreign modules of a linked crate" } + } - query is_dllimport_foreign_item(def_id: DefId) -> bool { - desc { |tcx| "is_dllimport_foreign_item({})", tcx.def_path_str(def_id) } - } - query is_statically_included_foreign_item(def_id: DefId) -> bool { - desc { |tcx| "is_statically_included_foreign_item({})", tcx.def_path_str(def_id) } - } - query native_library_kind(def_id: DefId) - -> Option { - desc { |tcx| "native_library_kind({})", tcx.def_path_str(def_id) } + /// Identifies the entry-point (e.g., the `main` function) for a given + /// crate, returning `None` if there is no entry point (such as for library crates). + query entry_fn(_: CrateNum) -> Option<(LocalDefId, EntryFnType)> { + desc { "looking up the entry function of a crate" } + } + query plugin_registrar_fn(_: CrateNum) -> Option { + desc { "looking up the plugin registrar for a crate" } + } + query proc_macro_decls_static(_: CrateNum) -> Option { + desc { "looking up the derive registrar for a crate" } + } + query crate_disambiguator(_: CrateNum) -> CrateDisambiguator { + eval_always + desc { "looking up the disambiguator a crate" } + } + // The macro which defines `rustc_metadata::provide_extern` depends on this query's name. + // Changing the name should cause a compiler error, but in case that changes, be aware. + query crate_hash(_: CrateNum) -> Svh { + eval_always + desc { "looking up the hash a crate" } + } + query crate_host_hash(_: CrateNum) -> Option { + eval_always + desc { "looking up the hash of a host version of a crate" } + } + query original_crate_name(_: CrateNum) -> Symbol { + eval_always + desc { "looking up the original name a crate" } + } + query extra_filename(_: CrateNum) -> String { + eval_always + desc { "looking up the extra filename for a crate" } + } + query crate_extern_paths(_: CrateNum) -> Vec { + eval_always + desc { "looking up the paths for extern crates" } + } } - query link_args(_: CrateNum) -> Lrc> { - eval_always - desc { "looking up link arguments for a crate" } - } + TypeChecking { + /// Given a crate and a trait, look up all impls of that trait in the crate. + /// Return `(impl_id, self_ty)`. + query implementations_of_trait(_: (CrateNum, DefId)) + -> &'tcx [(DefId, Option)] { + desc { "looking up implementations of a trait in a crate" } + } - /// Lifetime resolution. See `middle::resolve_lifetimes`. - query resolve_lifetimes(_: CrateNum) -> ResolveLifetimes { - storage(ArenaCacheSelector<'tcx>) - desc { "resolving lifetimes" } - } - query named_region_map(_: LocalDefId) -> - Option<&'tcx FxHashMap> { - desc { "looking up a named region" } - } - query is_late_bound_map(_: LocalDefId) -> - Option<(LocalDefId, &'tcx FxHashSet)> { - desc { "testing if a region is late bound" } - } - query object_lifetime_defaults_map(_: LocalDefId) - -> Option<&'tcx FxHashMap>> { - desc { "looking up lifetime defaults for a region" } + /// Given a crate, look up all trait impls in that crate. + /// Return `(impl_id, self_ty)`. + query all_trait_implementations(_: CrateNum) + -> &'tcx [(DefId, Option)] { + desc { "looking up all (?) trait implementations" } + } } - query visibility(def_id: DefId) -> ty::Visibility { - eval_always - desc { |tcx| "computing visibility of `{}`", tcx.def_path_str(def_id) } + Other { + query is_dllimport_foreign_item(def_id: DefId) -> bool { + desc { |tcx| "is_dllimport_foreign_item({})", tcx.def_path_str(def_id) } + } + query is_statically_included_foreign_item(def_id: DefId) -> bool { + desc { |tcx| "is_statically_included_foreign_item({})", tcx.def_path_str(def_id) } + } + query native_library_kind(def_id: DefId) + -> Option { + desc { |tcx| "native_library_kind({})", tcx.def_path_str(def_id) } + } } - /// Computes the set of modules from which this type is visibly uninhabited. - /// To check whether a type is uninhabited at all (not just from a given module), you could - /// check whether the forest is empty. - query type_uninhabited_from( - key: ty::ParamEnvAnd<'tcx, Ty<'tcx>> - ) -> ty::inhabitedness::DefIdForest { - desc { "computing the inhabitedness of `{:?}`", key } + Linking { + query link_args(_: CrateNum) -> Lrc> { + eval_always + desc { "looking up link arguments for a crate" } + } } - query dep_kind(_: CrateNum) -> CrateDepKind { - eval_always - desc { "fetching what a dependency looks like" } - } - query crate_name(_: CrateNum) -> Symbol { - eval_always - desc { "fetching what a crate is named" } - } - query item_children(def_id: DefId) -> &'tcx [Export] { - desc { |tcx| "collecting child items of `{}`", tcx.def_path_str(def_id) } - } - query extern_mod_stmt_cnum(def_id: LocalDefId) -> Option { - desc { |tcx| "computing crate imported by `{}`", tcx.def_path_str(def_id.to_def_id()) } + BorrowChecking { + /// Lifetime resolution. See `middle::resolve_lifetimes`. + query resolve_lifetimes(_: CrateNum) -> ResolveLifetimes { + storage(ArenaCacheSelector<'tcx>) + desc { "resolving lifetimes" } + } + query named_region_map(_: LocalDefId) -> + Option<&'tcx FxHashMap> { + desc { "looking up a named region" } + } + query is_late_bound_map(_: LocalDefId) -> + Option<(LocalDefId, &'tcx FxHashSet)> { + desc { "testing if a region is late bound" } + } + query object_lifetime_defaults_map(_: LocalDefId) + -> Option<&'tcx FxHashMap>> { + desc { "looking up lifetime defaults for a region" } + } } - query get_lib_features(_: CrateNum) -> LibFeatures { - storage(ArenaCacheSelector<'tcx>) - eval_always - desc { "calculating the lib features map" } - } - query defined_lib_features(_: CrateNum) - -> &'tcx [(Symbol, Option)] { - desc { "calculating the lib features defined in a crate" } - } - /// Returns the lang items defined in another crate by loading it from metadata. - // FIXME: It is illegal to pass a `CrateNum` other than `LOCAL_CRATE` here, just get rid - // of that argument? - query get_lang_items(_: CrateNum) -> LanguageItems { - storage(ArenaCacheSelector<'tcx>) - eval_always - desc { "calculating the lang items map" } - } + TypeChecking { + query visibility(def_id: DefId) -> ty::Visibility { + eval_always + desc { |tcx| "computing visibility of `{}`", tcx.def_path_str(def_id) } + } - /// Returns all diagnostic items defined in all crates. - query all_diagnostic_items(_: CrateNum) -> FxHashMap { - storage(ArenaCacheSelector<'tcx>) - eval_always - desc { "calculating the diagnostic items map" } + /// Computes the set of modules from which this type is visibly uninhabited. + /// To check whether a type is uninhabited at all (not just from a given module), you could + /// check whether the forest is empty. + query type_uninhabited_from( + key: ty::ParamEnvAnd<'tcx, Ty<'tcx>> + ) -> ty::inhabitedness::DefIdForest { + desc { "computing the inhabitedness of `{:?}`", key } + } } - /// Returns the lang items defined in another crate by loading it from metadata. - query defined_lang_items(_: CrateNum) -> &'tcx [(DefId, usize)] { - desc { "calculating the lang items defined in a crate" } - } + Other { + query dep_kind(_: CrateNum) -> CrateDepKind { + eval_always + desc { "fetching what a dependency looks like" } + } + query crate_name(_: CrateNum) -> Symbol { + eval_always + desc { "fetching what a crate is named" } + } + query item_children(def_id: DefId) -> &'tcx [Export] { + desc { |tcx| "collecting child items of `{}`", tcx.def_path_str(def_id) } + } + query extern_mod_stmt_cnum(def_id: LocalDefId) -> Option { + desc { |tcx| "computing crate imported by `{}`", tcx.def_path_str(def_id.to_def_id()) } + } - /// Returns the diagnostic items defined in a crate. - query diagnostic_items(_: CrateNum) -> FxHashMap { - storage(ArenaCacheSelector<'tcx>) - desc { "calculating the diagnostic items map in a crate" } - } + query get_lib_features(_: CrateNum) -> LibFeatures { + storage(ArenaCacheSelector<'tcx>) + eval_always + desc { "calculating the lib features map" } + } + query defined_lib_features(_: CrateNum) + -> &'tcx [(Symbol, Option)] { + desc { "calculating the lib features defined in a crate" } + } + /// Returns the lang items defined in another crate by loading it from metadata. + // FIXME: It is illegal to pass a `CrateNum` other than `LOCAL_CRATE` here, just get rid + // of that argument? + query get_lang_items(_: CrateNum) -> LanguageItems { + storage(ArenaCacheSelector<'tcx>) + eval_always + desc { "calculating the lang items map" } + } - query missing_lang_items(_: CrateNum) -> &'tcx [LangItem] { - desc { "calculating the missing lang items in a crate" } - } - query visible_parent_map(_: CrateNum) - -> DefIdMap { - storage(ArenaCacheSelector<'tcx>) - desc { "calculating the visible parent map" } - } - query trimmed_def_paths(_: CrateNum) - -> FxHashMap { - storage(ArenaCacheSelector<'tcx>) - desc { "calculating trimmed def paths" } - } - query missing_extern_crate_item(_: CrateNum) -> bool { - eval_always - desc { "seeing if we're missing an `extern crate` item for this crate" } - } - query used_crate_source(_: CrateNum) -> Lrc { - eval_always - desc { "looking at the source for a crate" } - } - query postorder_cnums(_: CrateNum) -> &'tcx [CrateNum] { - eval_always - desc { "generating a postorder list of CrateNums" } - } + /// Returns all diagnostic items defined in all crates. + query all_diagnostic_items(_: CrateNum) -> FxHashMap { + storage(ArenaCacheSelector<'tcx>) + eval_always + desc { "calculating the diagnostic items map" } + } - query upvars_mentioned(def_id: DefId) -> Option<&'tcx FxIndexMap> { - desc { |tcx| "collecting upvars mentioned in `{}`", tcx.def_path_str(def_id) } - eval_always - } - query maybe_unused_trait_import(def_id: LocalDefId) -> bool { - eval_always - desc { |tcx| "maybe_unused_trait_import for `{}`", tcx.def_path_str(def_id.to_def_id()) } - } - query maybe_unused_extern_crates(_: CrateNum) - -> &'tcx [(LocalDefId, Span)] { - eval_always - desc { "looking up all possibly unused extern crates" } - } - query names_imported_by_glob_use(def_id: LocalDefId) - -> &'tcx FxHashSet { - eval_always - desc { |tcx| "names_imported_by_glob_use for `{}`", tcx.def_path_str(def_id.to_def_id()) } - } + /// Returns the lang items defined in another crate by loading it from metadata. + query defined_lang_items(_: CrateNum) -> &'tcx [(DefId, usize)] { + desc { "calculating the lang items defined in a crate" } + } - query stability_index(_: CrateNum) -> stability::Index<'tcx> { - storage(ArenaCacheSelector<'tcx>) - eval_always - desc { "calculating the stability index for the local crate" } - } - query all_crate_nums(_: CrateNum) -> &'tcx [CrateNum] { - eval_always - desc { "fetching all foreign CrateNum instances" } - } + /// Returns the diagnostic items defined in a crate. + query diagnostic_items(_: CrateNum) -> FxHashMap { + storage(ArenaCacheSelector<'tcx>) + desc { "calculating the diagnostic items map in a crate" } + } - /// A vector of every trait accessible in the whole crate - /// (i.e., including those from subcrates). This is used only for - /// error reporting. - query all_traits(_: CrateNum) -> &'tcx [DefId] { - desc { "fetching all foreign and local traits" } - } + query missing_lang_items(_: CrateNum) -> &'tcx [LangItem] { + desc { "calculating the missing lang items in a crate" } + } + query visible_parent_map(_: CrateNum) + -> DefIdMap { + storage(ArenaCacheSelector<'tcx>) + desc { "calculating the visible parent map" } + } + query trimmed_def_paths(_: CrateNum) + -> FxHashMap { + storage(ArenaCacheSelector<'tcx>) + desc { "calculating trimmed def paths" } + } + query missing_extern_crate_item(_: CrateNum) -> bool { + eval_always + desc { "seeing if we're missing an `extern crate` item for this crate" } + } + query used_crate_source(_: CrateNum) -> Lrc { + eval_always + desc { "looking at the source for a crate" } + } + query postorder_cnums(_: CrateNum) -> &'tcx [CrateNum] { + eval_always + desc { "generating a postorder list of CrateNums" } + } - /// The list of symbols exported from the given crate. - /// - /// - All names contained in `exported_symbols(cnum)` are guaranteed to - /// correspond to a publicly visible symbol in `cnum` machine code. - /// - The `exported_symbols` sets of different crates do not intersect. - query exported_symbols(_: CrateNum) - -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportLevel)] { - desc { "exported_symbols" } - } + query upvars_mentioned(def_id: DefId) -> Option<&'tcx FxIndexMap> { + desc { |tcx| "collecting upvars mentioned in `{}`", tcx.def_path_str(def_id) } + eval_always + } + query maybe_unused_trait_import(def_id: LocalDefId) -> bool { + eval_always + desc { |tcx| "maybe_unused_trait_import for `{}`", tcx.def_path_str(def_id.to_def_id()) } + } + query maybe_unused_extern_crates(_: CrateNum) + -> &'tcx [(LocalDefId, Span)] { + eval_always + desc { "looking up all possibly unused extern crates" } + } + query names_imported_by_glob_use(def_id: LocalDefId) + -> &'tcx FxHashSet { + eval_always + desc { |tcx| "names_imported_by_glob_use for `{}`", tcx.def_path_str(def_id.to_def_id()) } + } - query collect_and_partition_mono_items(_: CrateNum) - -> (&'tcx DefIdSet, &'tcx [CodegenUnit<'tcx>]) { - eval_always - desc { "collect_and_partition_mono_items" } - } - query is_codegened_item(def_id: DefId) -> bool { - desc { |tcx| "determining whether `{}` needs codegen", tcx.def_path_str(def_id) } - } - query codegen_unit(_: Symbol) -> &'tcx CodegenUnit<'tcx> { - desc { "codegen_unit" } - } - query unused_generic_params(key: DefId) -> FiniteBitSet { - cache_on_disk_if { key.is_local() } - desc { - |tcx| "determining which generic parameters are unused by `{}`", - tcx.def_path_str(key) + query stability_index(_: CrateNum) -> stability::Index<'tcx> { + storage(ArenaCacheSelector<'tcx>) + eval_always + desc { "calculating the stability index for the local crate" } + } + query all_crate_nums(_: CrateNum) -> &'tcx [CrateNum] { + eval_always + desc { "fetching all foreign CrateNum instances" } } - } - query backend_optimization_level(_: CrateNum) -> OptLevel { - desc { "optimization level used by backend" } - } - query output_filenames(_: CrateNum) -> Arc { - eval_always - desc { "output_filenames" } + /// A vector of every trait accessible in the whole crate + /// (i.e., including those from subcrates). This is used only for + /// error reporting. + query all_traits(_: CrateNum) -> &'tcx [DefId] { + desc { "fetching all foreign and local traits" } + } } - /// Do not call this query directly: invoke `normalize` instead. - query normalize_projection_ty( - goal: CanonicalProjectionGoal<'tcx> - ) -> Result< - &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>, - NoSolution, - > { - desc { "normalizing `{:?}`", goal } + Linking { + /// The list of symbols exported from the given crate. + /// + /// - All names contained in `exported_symbols(cnum)` are guaranteed to + /// correspond to a publicly visible symbol in `cnum` machine code. + /// - The `exported_symbols` sets of different crates do not intersect. + query exported_symbols(_: CrateNum) + -> &'tcx [(ExportedSymbol<'tcx>, SymbolExportLevel)] { + desc { "exported_symbols" } + } } - /// Do not call this query directly: invoke `normalize_erasing_regions` instead. - query normalize_generic_arg_after_erasing_regions( - goal: ParamEnvAnd<'tcx, GenericArg<'tcx>> - ) -> GenericArg<'tcx> { - desc { "normalizing `{}`", goal.value } + Codegen { + query collect_and_partition_mono_items(_: CrateNum) + -> (&'tcx DefIdSet, &'tcx [CodegenUnit<'tcx>]) { + eval_always + desc { "collect_and_partition_mono_items" } + } + query is_codegened_item(def_id: DefId) -> bool { + desc { |tcx| "determining whether `{}` needs codegen", tcx.def_path_str(def_id) } + } + query codegen_unit(_: Symbol) -> &'tcx CodegenUnit<'tcx> { + desc { "codegen_unit" } + } + query unused_generic_params(key: DefId) -> FiniteBitSet { + cache_on_disk_if { key.is_local() } + desc { + |tcx| "determining which generic parameters are unused by `{}`", + tcx.def_path_str(key) + } + } + query backend_optimization_level(_: CrateNum) -> OptLevel { + desc { "optimization level used by backend" } + } } - query implied_outlives_bounds( - goal: CanonicalTyGoal<'tcx> - ) -> Result< - &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Vec>>>, - NoSolution, - > { - desc { "computing implied outlives bounds for `{:?}`", goal } + Other { + query output_filenames(_: CrateNum) -> Arc { + eval_always + desc { "output_filenames" } + } } - /// Do not call this query directly: invoke `infcx.at().dropck_outlives()` instead. - query dropck_outlives( - goal: CanonicalTyGoal<'tcx> - ) -> Result< - &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>, - NoSolution, - > { - desc { "computing dropck types for `{:?}`", goal } - } + TypeChecking { + /// Do not call this query directly: invoke `normalize` instead. + query normalize_projection_ty( + goal: CanonicalProjectionGoal<'tcx> + ) -> Result< + &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, NormalizationResult<'tcx>>>, + NoSolution, + > { + desc { "normalizing `{:?}`", goal } + } - /// Do not call this query directly: invoke `infcx.predicate_may_hold()` or - /// `infcx.predicate_must_hold()` instead. - query evaluate_obligation( - goal: CanonicalPredicateGoal<'tcx> - ) -> Result { - desc { "evaluating trait selection obligation `{}`", goal.value.value } - } + /// Do not call this query directly: invoke `normalize_erasing_regions` instead. + query normalize_generic_arg_after_erasing_regions( + goal: ParamEnvAnd<'tcx, GenericArg<'tcx>> + ) -> GenericArg<'tcx> { + desc { "normalizing `{}`", goal.value } + } - query evaluate_goal( - goal: traits::CanonicalChalkEnvironmentAndGoal<'tcx> - ) -> Result< - &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>, - NoSolution - > { - desc { "evaluating trait selection obligation `{}`", goal.value } - } + query implied_outlives_bounds( + goal: CanonicalTyGoal<'tcx> + ) -> Result< + &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Vec>>>, + NoSolution, + > { + desc { "computing implied outlives bounds for `{:?}`", goal } + } - query type_implements_trait( - key: (DefId, Ty<'tcx>, SubstsRef<'tcx>, ty::ParamEnv<'tcx>, ) - ) -> bool { - desc { "evaluating `type_implements_trait` `{:?}`", key } - } + /// Do not call this query directly: invoke `infcx.at().dropck_outlives()` instead. + query dropck_outlives( + goal: CanonicalTyGoal<'tcx> + ) -> Result< + &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, DropckOutlivesResult<'tcx>>>, + NoSolution, + > { + desc { "computing dropck types for `{:?}`", goal } + } - /// Do not call this query directly: part of the `Eq` type-op - query type_op_ascribe_user_type( - goal: CanonicalTypeOpAscribeUserTypeGoal<'tcx> - ) -> Result< - &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>, - NoSolution, - > { - desc { "evaluating `type_op_ascribe_user_type` `{:?}`", goal } - } + /// Do not call this query directly: invoke `infcx.predicate_may_hold()` or + /// `infcx.predicate_must_hold()` instead. + query evaluate_obligation( + goal: CanonicalPredicateGoal<'tcx> + ) -> Result { + desc { "evaluating trait selection obligation `{}`", goal.value.value } + } - /// Do not call this query directly: part of the `Eq` type-op - query type_op_eq( - goal: CanonicalTypeOpEqGoal<'tcx> - ) -> Result< - &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>, - NoSolution, - > { - desc { "evaluating `type_op_eq` `{:?}`", goal } - } + query evaluate_goal( + goal: traits::CanonicalChalkEnvironmentAndGoal<'tcx> + ) -> Result< + &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>, + NoSolution + > { + desc { "evaluating trait selection obligation `{}`", goal.value } + } - /// Do not call this query directly: part of the `Subtype` type-op - query type_op_subtype( - goal: CanonicalTypeOpSubtypeGoal<'tcx> - ) -> Result< - &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>, - NoSolution, - > { - desc { "evaluating `type_op_subtype` `{:?}`", goal } - } + query type_implements_trait( + key: (DefId, Ty<'tcx>, SubstsRef<'tcx>, ty::ParamEnv<'tcx>, ) + ) -> bool { + desc { "evaluating `type_implements_trait` `{:?}`", key } + } - /// Do not call this query directly: part of the `ProvePredicate` type-op - query type_op_prove_predicate( - goal: CanonicalTypeOpProvePredicateGoal<'tcx> - ) -> Result< - &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>, - NoSolution, - > { - desc { "evaluating `type_op_prove_predicate` `{:?}`", goal } - } + /// Do not call this query directly: part of the `Eq` type-op + query type_op_ascribe_user_type( + goal: CanonicalTypeOpAscribeUserTypeGoal<'tcx> + ) -> Result< + &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>, + NoSolution, + > { + desc { "evaluating `type_op_ascribe_user_type` `{:?}`", goal } + } - /// Do not call this query directly: part of the `Normalize` type-op - query type_op_normalize_ty( - goal: CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>> - ) -> Result< - &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Ty<'tcx>>>, - NoSolution, - > { - desc { "normalizing `{:?}`", goal } - } + /// Do not call this query directly: part of the `Eq` type-op + query type_op_eq( + goal: CanonicalTypeOpEqGoal<'tcx> + ) -> Result< + &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>, + NoSolution, + > { + desc { "evaluating `type_op_eq` `{:?}`", goal } + } - /// Do not call this query directly: part of the `Normalize` type-op - query type_op_normalize_predicate( - goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::Predicate<'tcx>> - ) -> Result< - &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::Predicate<'tcx>>>, - NoSolution, - > { - desc { "normalizing `{:?}`", goal } - } + /// Do not call this query directly: part of the `Subtype` type-op + query type_op_subtype( + goal: CanonicalTypeOpSubtypeGoal<'tcx> + ) -> Result< + &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>, + NoSolution, + > { + desc { "evaluating `type_op_subtype` `{:?}`", goal } + } - /// Do not call this query directly: part of the `Normalize` type-op - query type_op_normalize_poly_fn_sig( - goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::PolyFnSig<'tcx>> - ) -> Result< - &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::PolyFnSig<'tcx>>>, - NoSolution, - > { - desc { "normalizing `{:?}`", goal } - } + /// Do not call this query directly: part of the `ProvePredicate` type-op + query type_op_prove_predicate( + goal: CanonicalTypeOpProvePredicateGoal<'tcx> + ) -> Result< + &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ()>>, + NoSolution, + > { + desc { "evaluating `type_op_prove_predicate` `{:?}`", goal } + } - /// Do not call this query directly: part of the `Normalize` type-op - query type_op_normalize_fn_sig( - goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::FnSig<'tcx>> - ) -> Result< - &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::FnSig<'tcx>>>, - NoSolution, - > { - desc { "normalizing `{:?}`", goal } - } + /// Do not call this query directly: part of the `Normalize` type-op + query type_op_normalize_ty( + goal: CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>> + ) -> Result< + &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, Ty<'tcx>>>, + NoSolution, + > { + desc { "normalizing `{:?}`", goal } + } - query subst_and_check_impossible_predicates(key: (DefId, SubstsRef<'tcx>)) -> bool { - desc { |tcx| - "impossible substituted predicates:`{}`", - tcx.def_path_str(key.0) + /// Do not call this query directly: part of the `Normalize` type-op + query type_op_normalize_predicate( + goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::Predicate<'tcx>> + ) -> Result< + &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::Predicate<'tcx>>>, + NoSolution, + > { + desc { "normalizing `{:?}`", goal } } - } - query method_autoderef_steps( - goal: CanonicalTyGoal<'tcx> - ) -> MethodAutoderefStepsResult<'tcx> { - desc { "computing autoderef types for `{:?}`", goal } - } + /// Do not call this query directly: part of the `Normalize` type-op + query type_op_normalize_poly_fn_sig( + goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::PolyFnSig<'tcx>> + ) -> Result< + &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::PolyFnSig<'tcx>>>, + NoSolution, + > { + desc { "normalizing `{:?}`", goal } + } - query supported_target_features(_: CrateNum) -> FxHashMap> { - storage(ArenaCacheSelector<'tcx>) - eval_always - desc { "looking up supported target features" } - } + /// Do not call this query directly: part of the `Normalize` type-op + query type_op_normalize_fn_sig( + goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::FnSig<'tcx>> + ) -> Result< + &'tcx Canonical<'tcx, canonical::QueryResponse<'tcx, ty::FnSig<'tcx>>>, + NoSolution, + > { + desc { "normalizing `{:?}`", goal } + } - /// Get an estimate of the size of an InstanceDef based on its MIR for CGU partitioning. - query instance_def_size_estimate(def: ty::InstanceDef<'tcx>) - -> usize { - desc { |tcx| "estimating size for `{}`", tcx.def_path_str(def.def_id()) } - } + query subst_and_check_impossible_predicates(key: (DefId, SubstsRef<'tcx>)) -> bool { + desc { |tcx| + "impossible substituted predicates:`{}`", + tcx.def_path_str(key.0) + } + } - query features_query(_: CrateNum) -> &'tcx rustc_feature::Features { - eval_always - desc { "looking up enabled feature gates" } + query method_autoderef_steps( + goal: CanonicalTyGoal<'tcx> + ) -> MethodAutoderefStepsResult<'tcx> { + desc { "computing autoderef types for `{:?}`", goal } + } } - /// Attempt to resolve the given `DefId` to an `Instance`, for the - /// given generics args (`SubstsRef`), returning one of: - /// * `Ok(Some(instance))` on success - /// * `Ok(None)` when the `SubstsRef` are still too generic, - /// and therefore don't allow finding the final `Instance` - /// * `Err(ErrorReported)` when the `Instance` resolution process - /// couldn't complete due to errors elsewhere - this is distinct - /// from `Ok(None)` to avoid misleading diagnostics when an error - /// has already been/will be emitted, for the original cause - query resolve_instance( - key: ty::ParamEnvAnd<'tcx, (DefId, SubstsRef<'tcx>)> - ) -> Result>, ErrorReported> { - desc { "resolving instance `{}`", ty::Instance::new(key.value.0, key.value.1) } - } + Other { + query supported_target_features(_: CrateNum) -> FxHashMap> { + storage(ArenaCacheSelector<'tcx>) + eval_always + desc { "looking up supported target features" } + } - query resolve_instance_of_const_arg( - key: ty::ParamEnvAnd<'tcx, (LocalDefId, DefId, SubstsRef<'tcx>)> - ) -> Result>, ErrorReported> { - desc { - "resolving instance of the const argument `{}`", - ty::Instance::new(key.value.0.to_def_id(), key.value.2), + /// Get an estimate of the size of an InstanceDef based on its MIR for CGU partitioning. + query instance_def_size_estimate(def: ty::InstanceDef<'tcx>) + -> usize { + desc { |tcx| "estimating size for `{}`", tcx.def_path_str(def.def_id()) } + } + + query features_query(_: CrateNum) -> &'tcx rustc_feature::Features { + eval_always + desc { "looking up enabled feature gates" } } - } - query normalize_opaque_types(key: &'tcx ty::List>) -> &'tcx ty::List> { - desc { "normalizing opaque types in {:?}", key } + /// Attempt to resolve the given `DefId` to an `Instance`, for the + /// given generics args (`SubstsRef`), returning one of: + /// * `Ok(Some(instance))` on success + /// * `Ok(None)` when the `SubstsRef` are still too generic, + /// and therefore don't allow finding the final `Instance` + /// * `Err(ErrorReported)` when the `Instance` resolution process + /// couldn't complete due to errors elsewhere - this is distinct + /// from `Ok(None)` to avoid misleading diagnostics when an error + /// has already been/will be emitted, for the original cause + query resolve_instance( + key: ty::ParamEnvAnd<'tcx, (DefId, SubstsRef<'tcx>)> + ) -> Result>, ErrorReported> { + desc { "resolving instance `{}`", ty::Instance::new(key.value.0, key.value.1) } + } + + query resolve_instance_of_const_arg( + key: ty::ParamEnvAnd<'tcx, (LocalDefId, DefId, SubstsRef<'tcx>)> + ) -> Result>, ErrorReported> { + desc { + "resolving instance of the const argument `{}`", + ty::Instance::new(key.value.0.to_def_id(), key.value.2), + } + } + + query normalize_opaque_types(key: &'tcx ty::List>) -> &'tcx ty::List> { + desc { "normalizing opaque types in {:?}", key } + } } } diff --git a/compiler/rustc_middle/src/traits/chalk.rs b/compiler/rustc_middle/src/traits/chalk.rs index 74873778f74ba..f864ad8ebcd8a 100644 --- a/compiler/rustc_middle/src/traits/chalk.rs +++ b/compiler/rustc_middle/src/traits/chalk.rs @@ -72,7 +72,6 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> { type InternedQuantifiedWhereClauses = Vec>; type InternedVariableKinds = Vec>; type InternedCanonicalVarKinds = Vec>; - type InternedVariances = Vec; type InternedConstraints = Vec>>; type DefId = DefId; type InternedAdtId = &'tcx AdtDef; @@ -87,34 +86,17 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> { write!(fmt, "{:?}", pci.consequence)?; let conditions = pci.conditions.interned(); - let constraints = pci.constraints.interned(); let conds = conditions.len(); - let consts = constraints.len(); - if conds == 0 && consts == 0 { + if conds == 0 { return Ok(()); } write!(fmt, " :- ")?; - - if conds != 0 { - for cond in &conditions[..conds - 1] { - write!(fmt, "{:?}, ", cond)?; - } - write!(fmt, "{:?}", conditions[conds - 1])?; - } - - if conds != 0 && consts != 0 { - write!(fmt, " ; ")?; + for cond in &conditions[..conds - 1] { + write!(fmt, "{:?}, ", cond)?; } - - if consts != 0 { - for constraint in &constraints[..consts - 1] { - write!(fmt, "{:?}, ", constraint)?; - } - write!(fmt, "{:?}", constraints[consts - 1])?; - } - + write!(fmt, "{:?}", conditions[conds - 1])?; Ok(()) }; Some(write()) @@ -369,20 +351,6 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> { ) -> &'a [chalk_ir::InEnvironment>] { constraints } - - fn intern_variances( - &self, - data: impl IntoIterator>, - ) -> Result { - data.into_iter().collect::, _>>() - } - - fn variances_data<'a>( - &self, - variances: &'a Self::InternedVariances, - ) -> &'a [chalk_ir::Variance] { - variances - } } impl<'tcx> chalk_ir::interner::HasInterner for RustInterner<'tcx> { diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index f83056ebe2a45..1255302f74384 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -52,7 +52,7 @@ use rustc_session::config::{BorrowckMode, CrateType, OutputFilenames}; use rustc_session::lint::{Level, Lint}; use rustc_session::Session; use rustc_span::source_map::MultiSpan; -use rustc_span::symbol::{kw, sym, Ident, Symbol}; +use rustc_span::symbol::{kw, sym, Symbol}; use rustc_span::{Span, DUMMY_SP}; use rustc_target::abi::{Layout, TargetDataLayout, VariantIdx}; use rustc_target::spec::abi; @@ -2053,42 +2053,6 @@ impl<'tcx> TyCtxt<'tcx> { self.mk_fn_ptr(sig.map_bound(|sig| ty::FnSig { unsafety: hir::Unsafety::Unsafe, ..sig })) } - /// Given the def_id of a Trait `trait_def_id` and the name of an associated item `assoc_name` - /// returns true if the `trait_def_id` defines an associated item of name `assoc_name`. - pub fn trait_may_define_assoc_type(self, trait_def_id: DefId, assoc_name: Ident) -> bool { - self.super_traits_of(trait_def_id).any(|trait_did| { - self.associated_items(trait_did) - .find_by_name_and_kind(self, assoc_name, ty::AssocKind::Type, trait_did) - .is_some() - }) - } - - /// Computes the def-ids of the transitive super-traits of `trait_def_id`. This (intentionally) - /// does not compute the full elaborated super-predicates but just the set of def-ids. It is used - /// to identify which traits may define a given associated type to help avoid cycle errors. - /// Returns a `DefId` iterator. - fn super_traits_of(self, trait_def_id: DefId) -> impl Iterator + 'tcx { - let mut set = FxHashSet::default(); - let mut stack = vec![trait_def_id]; - - set.insert(trait_def_id); - - iter::from_fn(move || -> Option { - let trait_did = stack.pop()?; - let generic_predicates = self.super_predicates_of(trait_did); - - for (predicate, _) in generic_predicates.predicates { - if let ty::PredicateKind::Trait(data, _) = predicate.kind().skip_binder() { - if set.insert(data.def_id()) { - stack.push(data.def_id()); - } - } - } - - Some(trait_did) - }) - } - /// Given a closure signature, returns an equivalent fn signature. Detuples /// and so forth -- so e.g., if we have a sig with `Fn<(u32, i32)>` then /// you would get a `fn(u32, i32)`. diff --git a/compiler/rustc_middle/src/ty/diagnostics.rs b/compiler/rustc_middle/src/ty/diagnostics.rs index 4a131a4ec0581..e386d973ee447 100644 --- a/compiler/rustc_middle/src/ty/diagnostics.rs +++ b/compiler/rustc_middle/src/ty/diagnostics.rs @@ -12,17 +12,13 @@ impl<'tcx> TyS<'tcx> { pub fn is_primitive_ty(&self) -> bool { matches!( self.kind(), - Bool | Char - | Str - | Int(_) - | Uint(_) - | Float(_) - | Infer( - InferTy::IntVar(_) - | InferTy::FloatVar(_) - | InferTy::FreshIntTy(_) - | InferTy::FreshFloatTy(_) - ) + Bool | Char | Str | Int(_) | Uint(_) | Float(_) + | Infer( + InferTy::IntVar(_) + | InferTy::FloatVar(_) + | InferTy::FreshIntTy(_) + | InferTy::FreshFloatTy(_) + ) ) } diff --git a/compiler/rustc_middle/src/ty/error.rs b/compiler/rustc_middle/src/ty/error.rs index 1669c59d7f1b9..c211f07bed8c2 100644 --- a/compiler/rustc_middle/src/ty/error.rs +++ b/compiler/rustc_middle/src/ty/error.rs @@ -646,14 +646,11 @@ impl Trait for X { let current_method_ident = body_owner.and_then(|n| n.ident()).map(|i| i.name); // We don't want to suggest calling an assoc fn in a scope where that isn't feasible. - let callable_scope = matches!( - body_owner, - Some( + let callable_scope = matches!(body_owner, Some( hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(..), .. }) - | hir::Node::TraitItem(hir::TraitItem { kind: hir::TraitItemKind::Fn(..), .. }) - | hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Fn(..), .. }), - ) - ); + | hir::Node::TraitItem(hir::TraitItem { kind: hir::TraitItemKind::Fn(..), .. }) + | hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Fn(..), .. }), + )); let impl_comparison = matches!( cause_code, ObligationCauseCode::CompareImplMethodObligation { .. } diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs index 0b592ca4710b6..adee88ac1c95f 100644 --- a/compiler/rustc_middle/src/ty/layout.rs +++ b/compiler/rustc_middle/src/ty/layout.rs @@ -188,13 +188,6 @@ pub const FAT_PTR_ADDR: usize = 0; /// - For a slice, this is the length. pub const FAT_PTR_EXTRA: usize = 1; -/// The maximum supported number of lanes in a SIMD vector. -/// -/// This value is selected based on backend support: -/// * LLVM does not appear to have a vector width limit. -/// * Cranelift stores the base-2 log of the lane count in a 4 bit integer. -pub const MAX_SIMD_LANES: u64 = 1 << 0xF; - #[derive(Copy, Clone, Debug, TyEncodable, TyDecodable)] pub enum LayoutError<'tcx> { Unknown(Ty<'tcx>), @@ -724,22 +717,10 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { }; // SIMD vectors of zero length are not supported. - // Additionally, lengths are capped at 2^16 as a fixed maximum backends must - // support. // // Can't be caught in typeck if the array length is generic. if e_len == 0 { tcx.sess.fatal(&format!("monomorphising SIMD type `{}` of zero length", ty)); - } else if !e_len.is_power_of_two() { - tcx.sess.fatal(&format!( - "monomorphising SIMD type `{}` of non-power-of-two length", - ty - )); - } else if e_len > MAX_SIMD_LANES { - tcx.sess.fatal(&format!( - "monomorphising SIMD type `{}` of length greater than {}", - ty, MAX_SIMD_LANES, - )); } // Compute the ABI of the element type: @@ -2669,7 +2650,6 @@ where Win64 => Conv::X86_64Win64, SysV64 => Conv::X86_64SysV, Aapcs => Conv::ArmAapcs, - CCmseNonSecureCall => Conv::CCmseNonSecureCall, PtxKernel => Conv::PtxKernel, Msp430Interrupt => Conv::Msp430Intr, X86Interrupt => Conv::X86Intr, diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index a8d9995bd0b2f..4937fdd73144d 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -2143,7 +2143,6 @@ fn for_each_def(tcx: TyCtxt<'_>, mut collect_fn: impl for<'b> FnMut(&'b Ident, N match child.res { def::Res::Def(DefKind::AssocTy, _) => {} - def::Res::Def(DefKind::TyAlias, _) => {} def::Res::Def(defkind, def_id) => { if let Some(ns) = defkind.ns() { collect_fn(&child.ident, ns, def_id); diff --git a/compiler/rustc_middle/src/ty/query/keys.rs b/compiler/rustc_middle/src/ty/query/keys.rs index 6b4714b1bb8c8..bfa1581aaae29 100644 --- a/compiler/rustc_middle/src/ty/query/keys.rs +++ b/compiler/rustc_middle/src/ty/query/keys.rs @@ -7,7 +7,7 @@ use crate::ty::subst::{GenericArg, SubstsRef}; use crate::ty::{self, Ty, TyCtxt}; use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE}; use rustc_query_system::query::DefaultCacheSelector; -use rustc_span::symbol::{Ident, Symbol}; +use rustc_span::symbol::Symbol; use rustc_span::{Span, DUMMY_SP}; /// The `Key` trait controls what types can legally be used as the key @@ -160,28 +160,6 @@ impl Key for (LocalDefId, DefId) { } } -impl Key for (DefId, Option) { - type CacheSelector = DefaultCacheSelector; - - fn query_crate(&self) -> CrateNum { - self.0.krate - } - fn default_span(&self, tcx: TyCtxt<'_>) -> Span { - tcx.def_span(self.0) - } -} - -impl Key for (DefId, LocalDefId, Ident) { - type CacheSelector = DefaultCacheSelector; - - fn query_crate(&self) -> CrateNum { - self.0.krate - } - fn default_span(&self, tcx: TyCtxt<'_>) -> Span { - self.1.default_span(tcx) - } -} - impl Key for (CrateNum, DefId) { type CacheSelector = DefaultCacheSelector; diff --git a/compiler/rustc_middle/src/ty/query/mod.rs b/compiler/rustc_middle/src/ty/query/mod.rs index 804c045a69010..f580cb14dc988 100644 --- a/compiler/rustc_middle/src/ty/query/mod.rs +++ b/compiler/rustc_middle/src/ty/query/mod.rs @@ -53,6 +53,7 @@ use rustc_ast as ast; use rustc_attr as attr; use rustc_span::symbol::Symbol; use rustc_span::{Span, DUMMY_SP}; +use std::borrow::Cow; use std::collections::BTreeMap; use std::ops::Deref; use std::path::PathBuf; diff --git a/compiler/rustc_middle/src/ty/query/plumbing.rs b/compiler/rustc_middle/src/ty/query/plumbing.rs index 46addcdaead43..d0730bd121c98 100644 --- a/compiler/rustc_middle/src/ty/query/plumbing.rs +++ b/compiler/rustc_middle/src/ty/query/plumbing.rs @@ -277,14 +277,14 @@ macro_rules! define_queries { } } - pub fn describe(&self, tcx: TyCtxt<$tcx>) -> String { + pub fn describe(&self, tcx: TyCtxt<$tcx>) -> Cow<'static, str> { let (r, name) = match *self { $(Query::$name(key) => { (queries::$name::describe(tcx, key), stringify!($name)) })* }; if tcx.sess.verbose() { - format!("{} [{}]", r, name) + format!("{} [{}]", r, name).into() } else { r } diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index c1fa84dcb25e0..9cec0eb5be3c5 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -1132,16 +1132,8 @@ impl<'tcx> ProjectionTy<'tcx> { /// For example, if this is a projection of `::Item`, /// then this function would return a `T: Iterator` trait reference. pub fn trait_ref(&self, tcx: TyCtxt<'tcx>) -> ty::TraitRef<'tcx> { - // FIXME: This method probably shouldn't exist at all, since it's not - // clear what this method really intends to do. Be careful when - // using this method since the resulting TraitRef additionally - // contains the substs for the assoc_item, which strictly speaking - // is not correct let def_id = tcx.associated_item(self.item_def_id).container.id(); - // Include substitutions for generic arguments of associated types - let assoc_item = tcx.associated_item(self.item_def_id); - let substs_assoc_item = self.substs.truncate_to(tcx, tcx.generics_of(assoc_item.def_id)); - ty::TraitRef { def_id, substs: substs_assoc_item } + ty::TraitRef { def_id, substs: self.substs.truncate_to(tcx, tcx.generics_of(def_id)) } } pub fn self_ty(&self) -> Ty<'tcx> { @@ -1879,14 +1871,8 @@ impl<'tcx> TyS<'tcx> { pub fn is_scalar(&self) -> bool { matches!( self.kind(), - Bool | Char - | Int(_) - | Float(_) - | Uint(_) - | FnDef(..) - | FnPtr(_) - | RawPtr(_) - | Infer(IntVar(_) | FloatVar(_)) + Bool | Char | Int(_) | Float(_) | Uint(_) | FnDef(..) | FnPtr(_) | RawPtr(_) + | Infer(IntVar(_) | FloatVar(_)) ) } diff --git a/compiler/rustc_middle/src/util/bug.rs b/compiler/rustc_middle/src/util/bug.rs index 791d5060fe5c7..e79adcdb54598 100644 --- a/compiler/rustc_middle/src/util/bug.rs +++ b/compiler/rustc_middle/src/util/bug.rs @@ -3,7 +3,7 @@ use crate::ty::{tls, TyCtxt}; use rustc_span::{MultiSpan, Span}; use std::fmt; -use std::panic::{panic_any, Location}; +use std::panic::Location; #[cold] #[inline(never)] @@ -32,7 +32,7 @@ fn opt_span_bug_fmt>( match (tcx, span) { (Some(tcx), Some(span)) => tcx.sess.diagnostic().span_bug(span, &msg), (Some(tcx), None) => tcx.sess.diagnostic().bug(&msg), - (None, _) => panic_any(msg), + (None, _) => panic!(msg), } }); unreachable!(); diff --git a/compiler/rustc_mir/src/borrow_check/diagnostics/mutability_errors.rs b/compiler/rustc_mir/src/borrow_check/diagnostics/mutability_errors.rs index 333ac0738d45b..74abe2d35ee74 100644 --- a/compiler/rustc_mir/src/borrow_check/diagnostics/mutability_errors.rs +++ b/compiler/rustc_mir/src/borrow_check/diagnostics/mutability_errors.rs @@ -514,7 +514,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { let upvar = ty::place_to_string_for_capture(tcx, place); match tables.upvar_capture(upvar_id) { ty::UpvarCapture::ByRef(ty::UpvarBorrow { - kind: ty::BorrowKind::MutBorrow | ty::BorrowKind::UniqueImmBorrow, + kind: ty::BorrowKind::MutBorrow, .. }) => { format!("mutable borrow of `{}`", upvar) @@ -522,7 +522,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> { ty::UpvarCapture::ByValue(_) => { format!("possible mutation of `{}`", upvar) } - val => bug!("upvar `{}` borrowed, but not mutably: {:?}", upvar, val), + _ => bug!("upvar `{}` borrowed, but not mutably", upvar), } } else { bug!("not an upvar") diff --git a/compiler/rustc_mir/src/const_eval/error.rs b/compiler/rustc_mir/src/const_eval/error.rs index 88af9391cadfe..0e610e3755222 100644 --- a/compiler/rustc_mir/src/const_eval/error.rs +++ b/compiler/rustc_mir/src/const_eval/error.rs @@ -16,7 +16,6 @@ use crate::interpret::{ #[derive(Clone, Debug)] pub enum ConstEvalErrKind { NeedsRfc(String), - PtrToIntCast, ConstAccessesStatic, ModifiedGlobal, AssertFailure(AssertKind), @@ -40,12 +39,6 @@ impl fmt::Display for ConstEvalErrKind { NeedsRfc(ref msg) => { write!(f, "\"{}\" needs an rfc before being allowed inside constants", msg) } - PtrToIntCast => { - write!( - f, - "cannot cast pointer to integer because it was not created by cast from integer" - ) - } ConstAccessesStatic => write!(f, "constant accesses static"), ModifiedGlobal => { write!(f, "modifying a static's initial value from another static's initializer") diff --git a/compiler/rustc_mir/src/const_eval/machine.rs b/compiler/rustc_mir/src/const_eval/machine.rs index f6b950c08c78e..49126cfec6bf8 100644 --- a/compiler/rustc_mir/src/const_eval/machine.rs +++ b/compiler/rustc_mir/src/const_eval/machine.rs @@ -352,7 +352,7 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir, } fn ptr_to_int(_mem: &Memory<'mir, 'tcx, Self>, _ptr: Pointer) -> InterpResult<'tcx, u64> { - Err(ConstEvalErrKind::PtrToIntCast.into()) + Err(ConstEvalErrKind::NeedsRfc("pointer-to-integer cast".to_string()).into()) } fn binary_ptr_op( diff --git a/compiler/rustc_mir/src/transform/inline.rs b/compiler/rustc_mir/src/transform/inline.rs index 1635a95f46ec8..dd9a514466d4c 100644 --- a/compiler/rustc_mir/src/transform/inline.rs +++ b/compiler/rustc_mir/src/transform/inline.rs @@ -281,11 +281,6 @@ impl Inliner<'tcx> { return false; } - if self.codegen_fn_attrs.instruction_set != codegen_fn_attrs.instruction_set { - debug!("`callee has incompatible instruction set - not inlining"); - return false; - } - let hinted = match codegen_fn_attrs.inline { // Just treat inline(always) as a hint for now, // there are cases that prevent inlining that we diff --git a/compiler/rustc_mir_build/src/build/block.rs b/compiler/rustc_mir_build/src/build/block.rs index d5f72e6f22dfa..82f38ac0e7620 100644 --- a/compiler/rustc_mir_build/src/build/block.rs +++ b/compiler/rustc_mir_build/src/build/block.rs @@ -3,6 +3,7 @@ use crate::build::ForGuard::OutsideGuard; use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; use crate::thir::*; use rustc_hir as hir; +use rustc_middle::middle::region; use rustc_middle::mir::*; use rustc_session::lint::builtin::UNSAFE_OP_IN_UNSAFE_FN; use rustc_session::lint::Level; @@ -12,6 +13,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { crate fn ast_block( &mut self, destination: Place<'tcx>, + scope: Option, block: BasicBlock, ast_block: &'tcx hir::Block<'tcx>, source_info: SourceInfo, @@ -28,9 +30,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { self.in_opt_scope(opt_destruction_scope.map(|de| (de, source_info)), move |this| { this.in_scope((region_scope, source_info), LintLevel::Inherited, move |this| { if targeted_by_break { - this.in_breakable_scope(None, destination, span, |this| { + this.in_breakable_scope(None, destination, scope, span, |this| { Some(this.ast_block_stmts( destination, + scope, block, span, stmts, @@ -39,7 +42,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { )) }) } else { - this.ast_block_stmts(destination, block, span, stmts, expr, safety_mode) + this.ast_block_stmts(destination, scope, block, span, stmts, expr, safety_mode) } }) }) @@ -48,6 +51,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { fn ast_block_stmts( &mut self, destination: Place<'tcx>, + scope: Option, mut block: BasicBlock, span: Span, stmts: Vec>, @@ -182,7 +186,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { }; this.block_context.push(BlockFrame::TailExpr { tail_result_is_ignored, span }); - unpack!(block = this.into(destination, block, expr)); + unpack!(block = this.into(destination, scope, block, expr)); let popped = this.block_context.pop(); assert!(popped.map_or(false, |bf| bf.is_tail_expr())); diff --git a/compiler/rustc_mir_build/src/build/expr/as_place.rs b/compiler/rustc_mir_build/src/build/expr/as_place.rs index 3308a243a3afb..2503360b1e4d0 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_place.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_place.rs @@ -6,8 +6,8 @@ use crate::build::{BlockAnd, BlockAndExtension, Builder}; use crate::thir::*; use rustc_hir::def_id::DefId; use rustc_hir::HirId; -use rustc_middle::hir::place::ProjectionKind as HirProjectionKind; use rustc_middle::middle::region; +use rustc_middle::hir::place::ProjectionKind as HirProjectionKind; use rustc_middle::mir::AssertKind::BoundsCheck; use rustc_middle::mir::*; use rustc_middle::ty::{self, CanonicalUserTypeAnnotation, Ty, TyCtxt, Variance}; @@ -57,8 +57,7 @@ crate enum PlaceBase { /// DefId of the closure closure_def_id: DefId, /// The trait closure implements, `Fn`, `FnMut`, `FnOnce` - closure_kind: ty::ClosureKind, - }, + closure_kind: ty::ClosureKind }, } /// `PlaceBuilder` is used to create places during MIR construction. It allows you to "build up" a @@ -82,7 +81,8 @@ crate struct PlaceBuilder<'tcx> { fn convert_to_hir_projections_and_truncate_for_capture<'tcx>( mir_projections: &[PlaceElem<'tcx>], ) -> Vec { - let mut hir_projections = Vec::new(); + + let mut hir_projections = Vec::new(); for mir_projection in mir_projections { let hir_projection = match mir_projection { @@ -91,20 +91,20 @@ fn convert_to_hir_projections_and_truncate_for_capture<'tcx>( // We will never encouter this for multivariant enums, // read the comment for `Downcast`. HirProjectionKind::Field(field.index() as u32, VariantIdx::new(0)) - } + }, ProjectionElem::Downcast(..) => { // This projections exist only for enums that have // multiple variants. Since such enums that are captured // completely, we can stop here. - break; - } + break + }, ProjectionElem::Index(..) | ProjectionElem::ConstantIndex { .. } | ProjectionElem::Subslice { .. } => { // We don't capture array-access projections. // We can stop here as arrays are captured completely. - break; - } + break + }, }; hir_projections.push(hir_projection); @@ -181,9 +181,9 @@ fn find_capture_matching_projections<'a, 'tcx>( // If an ancestor is found, `idx` is the index within the list of captured places // for root variable `var_hir_id` and `capture` is the `ty::CapturedPlace` itself. let (idx, capture) = root_variable_min_captures.iter().enumerate().find(|(_, capture)| { - let possible_ancestor_proj_kinds = - capture.place.projections.iter().map(|proj| proj.kind).collect(); - is_ancestor_or_same_capture(&possible_ancestor_proj_kinds, &hir_projections) + let possible_ancestor_proj_kinds = + capture.place.projections.iter().map(|proj| proj.kind).collect(); + is_ancestor_or_same_capture(&possible_ancestor_proj_kinds, &hir_projections) })?; // Convert index to be from the presepective of the entire closure_min_captures map @@ -213,34 +213,35 @@ fn to_upvars_resolved_place_builder<'a, 'tcx>( ty::ClosureKind::FnOnce => {} } - let (capture_index, capture) = if let Some(capture_details) = - find_capture_matching_projections( + let (capture_index, capture) = + if let Some(capture_details) = find_capture_matching_projections( typeck_results, var_hir_id, closure_def_id, &from_builder.projection, ) { - capture_details - } else { - if !tcx.features().capture_disjoint_fields { - bug!( - "No associated capture found for {:?}[{:#?}] even though \ - capture_disjoint_fields isn't enabled", - var_hir_id, - from_builder.projection - ) + capture_details } else { - // FIXME(project-rfc-2229#24): Handle this case properly - debug!( - "No associated capture found for {:?}[{:#?}]", - var_hir_id, from_builder.projection, - ); - } - return Err(var_hir_id); - }; + if !tcx.features().capture_disjoint_fields { + bug!( + "No associated capture found for {:?}[{:#?}] even though \ + capture_disjoint_fields isn't enabled", + var_hir_id, + from_builder.projection + ) + } else { + // FIXME(project-rfc-2229#24): Handle this case properly + debug!( + "No associated capture found for {:?}[{:#?}]", + var_hir_id, + from_builder.projection, + ); + } + return Err(var_hir_id); + }; - let closure_ty = typeck_results - .node_type(tcx.hir().local_def_id_to_hir_id(closure_def_id.expect_local())); + let closure_ty = + typeck_results.node_type(tcx.hir().local_def_id_to_hir_id(closure_def_id.expect_local())); let substs = match closure_ty.kind() { ty::Closure(_, substs) => ty::UpvarSubsts::Closure(substs), @@ -255,8 +256,7 @@ fn to_upvars_resolved_place_builder<'a, 'tcx>( // we know that the capture exists and is the `capture_index`-th capture. let var_ty = substs.tupled_upvars_ty().tuple_element_ty(capture_index).unwrap(); - upvar_resolved_place_builder = - upvar_resolved_place_builder.field(Field::new(capture_index), var_ty); + upvar_resolved_place_builder = upvar_resolved_place_builder.field(Field::new(capture_index), var_ty); // If the variable is captured via ByRef(Immutable/Mutable) Borrow, // we need to deref it @@ -270,9 +270,8 @@ fn to_upvars_resolved_place_builder<'a, 'tcx>( // We used some of the projections to build the capture itself, // now we apply the remaining to the upvar resolved place. - upvar_resolved_place_builder - .projection - .extend(curr_projections.drain(next_projection..)); + upvar_resolved_place_builder.projection.extend( + curr_projections.drain(next_projection..)); Ok(upvar_resolved_place_builder) } @@ -357,11 +356,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { /// This is used when constructing a compound `Place`, so that we can avoid creating /// intermediate `Place` values until we know the full set of projections. - crate fn as_place_builder( - &mut self, - block: BasicBlock, - expr: M, - ) -> BlockAnd> + crate fn as_place_builder(&mut self, block: BasicBlock, expr: M) -> BlockAnd> where M: Mirror<'tcx, Output = Expr<'tcx>>, { @@ -632,8 +627,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { if is_outermost_index { self.read_fake_borrows(block, fake_borrow_temps, source_info) } else { - base_place = - base_place.expect_upvars_resolved(self.hir.tcx(), self.hir.typeck_results()); + base_place = base_place.expect_upvars_resolved(self.hir.tcx(), self.hir.typeck_results()); self.add_fake_borrows_of_base( &base_place, block, @@ -685,7 +679,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let tcx = self.hir.tcx(); let local = match base_place.base { PlaceBase::Local(local) => local, - PlaceBase::Upvar { .. } => bug!("Expected PlacseBase::Local found Upvar"), + PlaceBase::Upvar { .. } => bug!("Expected PlacseBase::Local found Upvar") }; let place_ty = Place::ty_from(local, &base_place.projection, &self.local_decls, tcx); diff --git a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs index e602f4dd71d25..55bdbcfc5b916 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs @@ -2,9 +2,9 @@ use rustc_index::vec::Idx; -use crate::build::expr::as_place::PlaceBase; use crate::build::expr::category::{Category, RvalueFunc}; use crate::build::{BlockAnd, BlockAndExtension, Builder}; +use crate::build::expr::as_place::PlaceBase; use crate::thir::*; use rustc_middle::middle::region; use rustc_middle::mir::AssertKind; @@ -12,6 +12,8 @@ use rustc_middle::mir::*; use rustc_middle::ty::{self, Ty, UpvarSubsts}; use rustc_span::Span; +use std::slice; + impl<'a, 'tcx> Builder<'a, 'tcx> { /// Returns an rvalue suitable for use until the end of the current /// scope expression. @@ -113,12 +115,19 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let box_ = Rvalue::NullaryOp(NullOp::Box, value.ty); this.cfg.push_assign(block, source_info, Place::from(result), box_); - // initialize the box contents: + // Initialize the box contents. No scope is needed since the + // `Box` is already scheduled to be dropped. unpack!( - block = - this.into(this.hir.tcx().mk_place_deref(Place::from(result)), block, value) + block = this.into( + this.hir.tcx().mk_place_deref(Place::from(result)), + None, + block, + value, + ) ); - block.and(Rvalue::Use(Operand::Move(Place::from(result)))) + let result_operand = Operand::Move(Place::from(result)); + this.record_operands_moved(slice::from_ref(&result_operand)); + block.and(Rvalue::Use(result_operand)) } ExprKind::Cast { source } => { let source = unpack!(block = this.as_operand(block, scope, source)); @@ -162,6 +171,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { .map(|f| unpack!(block = this.as_operand(block, scope, f))) .collect(); + this.record_operands_moved(&fields); block.and(Rvalue::Aggregate(box AggregateKind::Array(el_ty), fields)) } ExprKind::Tuple { fields } => { @@ -172,6 +182,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { .map(|f| unpack!(block = this.as_operand(block, scope, f))) .collect(); + this.record_operands_moved(&fields); block.and(Rvalue::Aggregate(box AggregateKind::Tuple, fields)) } ExprKind::Closure { closure_id, substs, upvars, movability } => { @@ -223,6 +234,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } UpvarSubsts::Closure(substs) => box AggregateKind::Closure(closure_id, substs), }; + this.record_operands_moved(&operands); block.and(Rvalue::Aggregate(result, operands)) } ExprKind::Assign { .. } | ExprKind::AssignOp { .. } => { @@ -262,10 +274,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { | ExprKind::ValueTypeAscription { .. } => { // these do not have corresponding `Rvalue` variants, // so make an operand and then return that - debug_assert!(!matches!( - Category::of(&expr.kind), - Some(Category::Rvalue(RvalueFunc::AsRvalue)) - )); + debug_assert!(!matches!(Category::of(&expr.kind), Some(Category::Rvalue(RvalueFunc::AsRvalue)))); let operand = unpack!(block = this.as_operand(block, scope, expr)); block.and(Rvalue::Use(operand)) } @@ -392,39 +401,34 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // We are capturing a path that starts off a local variable in the parent. // The mutability of the current capture is same as the mutability // of the local declaration in the parent. - PlaceBase::Local(local) => this.local_decls[local].mutability, + PlaceBase::Local(local) => this.local_decls[local].mutability, // Parent is a closure and we are capturing a path that is captured // by the parent itself. The mutability of the current capture // is same as that of the capture in the parent closure. PlaceBase::Upvar { .. } => { - let enclosing_upvars_resolved = - arg_place_builder.clone().into_place(this.hir.tcx(), this.hir.typeck_results()); + let enclosing_upvars_resolved = arg_place_builder.clone().into_place( + this.hir.tcx(), + this.hir.typeck_results()); match enclosing_upvars_resolved.as_ref() { - PlaceRef { - local, - projection: &[ProjectionElem::Field(upvar_index, _), ..], - } + PlaceRef { local, projection: &[ProjectionElem::Field(upvar_index, _), ..] } | PlaceRef { local, - projection: - &[ProjectionElem::Deref, ProjectionElem::Field(upvar_index, _), ..], - } => { - // Not in a closure - debug_assert!( - local == Local::new(1), - "Expected local to be Local(1), found {:?}", - local - ); - // Not in a closure - debug_assert!( - this.upvar_mutbls.len() > upvar_index.index(), - "Unexpected capture place, upvar_mutbls={:#?}, upvar_index={:?}", - this.upvar_mutbls, - upvar_index - ); - this.upvar_mutbls[upvar_index.index()] - } + projection: &[ProjectionElem::Deref, ProjectionElem::Field(upvar_index, _), ..] } => { + // Not in a closure + debug_assert!( + local == Local::new(1), + "Expected local to be Local(1), found {:?}", + local + ); + // Not in a closure + debug_assert!( + this.upvar_mutbls.len() > upvar_index.index(), + "Unexpected capture place, upvar_mutbls={:#?}, upvar_index={:?}", + this.upvar_mutbls, upvar_index + ); + this.upvar_mutbls[upvar_index.index()] + } _ => bug!("Unexpected capture place"), } } @@ -435,7 +439,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { Mutability::Mut => BorrowKind::Mut { allow_two_phase_borrow: false }, }; - let arg_place = arg_place_builder.into_place(this.hir.tcx(), this.hir.typeck_results()); + let arg_place = arg_place_builder.into_place( + this.hir.tcx(), + this.hir.typeck_results()); this.cfg.push_assign( block, diff --git a/compiler/rustc_mir_build/src/build/expr/as_temp.rs b/compiler/rustc_mir_build/src/build/expr/as_temp.rs index 9984b527ffdb4..241330d96e7bd 100644 --- a/compiler/rustc_mir_build/src/build/expr/as_temp.rs +++ b/compiler/rustc_mir_build/src/build/expr/as_temp.rs @@ -114,11 +114,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - unpack!(block = this.into(temp_place, block, expr)); - - if let Some(temp_lifetime) = temp_lifetime { - this.schedule_drop(expr_span, temp_lifetime, temp, DropKind::Value); - } + unpack!(block = this.into(temp_place, temp_lifetime, block, expr)); block.and(temp) } diff --git a/compiler/rustc_mir_build/src/build/expr/into.rs b/compiler/rustc_mir_build/src/build/expr/into.rs index 235fe14cbf9fd..32c01f2c73326 100644 --- a/compiler/rustc_mir_build/src/build/expr/into.rs +++ b/compiler/rustc_mir_build/src/build/expr/into.rs @@ -1,25 +1,35 @@ //! See docs in build/expr/mod.rs use crate::build::expr::category::{Category, RvalueFunc}; +use crate::build::scope::DropKind; use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; use crate::thir::*; use rustc_ast::InlineAsmOptions; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_hir as hir; +use rustc_middle::middle::region; use rustc_middle::mir::*; -use rustc_middle::ty::CanonicalUserTypeAnnotation; +use rustc_middle::ty::{CanonicalUserTypeAnnotation}; + +use std::slice; impl<'a, 'tcx> Builder<'a, 'tcx> { /// Compile `expr`, storing the result into `destination`, which /// is assumed to be uninitialized. + /// If a `drop_scope` is provided, `destination` is scheduled to be dropped + /// in `scope` once it has been initialized. crate fn into_expr( &mut self, destination: Place<'tcx>, + scope: Option, mut block: BasicBlock, expr: Expr<'tcx>, ) -> BlockAnd<()> { - debug!("into_expr(destination={:?}, block={:?}, expr={:?})", destination, block, expr); + debug!( + "into_expr(destination={:?}, scope={:?}, block={:?}, expr={:?})", + destination, scope, block, expr + ); // since we frequently have to reference `self` from within a // closure, where `self` would be shadowed, it's easier to @@ -28,8 +38,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let expr_span = expr.span; let source_info = this.source_info(expr_span); - let expr_is_block_or_scope = - matches!(expr.kind, ExprKind::Block { .. } | ExprKind::Scope { .. }); + let expr_is_block_or_scope = matches!(expr.kind, ExprKind::Block { .. } | ExprKind::Scope { .. }); + + let schedule_drop = move |this: &mut Self| { + if let Some(drop_scope) = scope { + let local = + destination.as_local().expect("cannot schedule drop of non-Local place"); + this.schedule_drop(expr_span, drop_scope, local, DropKind::Value); + } + }; if !expr_is_block_or_scope { this.block_context.push(BlockFrame::SubExpr); @@ -40,20 +57,18 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let region_scope = (region_scope, source_info); ensure_sufficient_stack(|| { this.in_scope(region_scope, lint_level, |this| { - this.into(destination, block, value) + this.into(destination, scope, block, value) }) }) } ExprKind::Block { body: ast_block } => { - this.ast_block(destination, block, ast_block, source_info) + this.ast_block(destination, scope, block, ast_block, source_info) } ExprKind::Match { scrutinee, arms } => { - this.match_expr(destination, expr_span, block, scrutinee, arms) + this.match_expr(destination, scope, expr_span, block, scrutinee, arms) } ExprKind::If { cond, then, else_opt } => { - let place = unpack!( - block = this.as_temp(block, Some(this.local_scope()), cond, Mutability::Mut) - ); + let place = unpack!(block = this.as_temp(block, Some(this.local_scope()), cond, Mutability::Mut)); let operand = Operand::Move(Place::from(place)); let mut then_block = this.cfg.start_new_block(); @@ -61,9 +76,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let term = TerminatorKind::if_(this.hir.tcx(), operand, then_block, else_block); this.cfg.terminate(block, source_info, term); - unpack!(then_block = this.into(destination, then_block, then)); + unpack!(then_block = this.into(destination, scope, then_block, then)); else_block = if let Some(else_opt) = else_opt { - unpack!(this.into(destination, else_block, else_opt)) + unpack!(this.into(destination, None, else_block, else_opt)) } else { // Body of the `if` expression without an `else` clause must return `()`, thus // we implicitly generate a `else {}` if it is not specified. @@ -85,20 +100,18 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { ); join_block.unit() - } + }, ExprKind::NeverToAny { source } => { let source = this.hir.mirror(source); - let is_call = - matches!(source.kind, ExprKind::Call { .. } | ExprKind::InlineAsm { .. }); + let is_call = matches!(source.kind, ExprKind::Call { .. } | ExprKind::InlineAsm { .. }); // (#66975) Source could be a const of type `!`, so has to // exist in the generated MIR. - unpack!( - block = this.as_temp(block, Some(this.local_scope()), source, Mutability::Mut,) - ); + unpack!(block = this.as_temp(block, Some(this.local_scope()), source, Mutability::Mut,)); // This is an optimization. If the expression was a call then we already have an // unreachable block. Don't bother to terminate it and create a new one. + schedule_drop(this); if is_call { block.unit() } else { @@ -174,26 +187,35 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { // Start the loop. this.cfg.goto(block, source_info, loop_block); - this.in_breakable_scope(Some(loop_block), destination, expr_span, move |this| { - // conduct the test, if necessary - let body_block = this.cfg.start_new_block(); - this.cfg.terminate( - loop_block, - source_info, - TerminatorKind::FalseUnwind { real_target: body_block, unwind: None }, - ); - this.diverge_from(loop_block); - - // The “return” value of the loop body must always be an unit. We therefore - // introduce a unit temporary as the destination for the loop body. - let tmp = this.get_unit_temp(); - // Execute the body, branching back to the test. - let body_block_end = unpack!(this.into(tmp, body_block, body)); - this.cfg.goto(body_block_end, source_info, loop_block); - - // Loops are only exited by `break` expressions. - None - }) + this.in_breakable_scope( + Some(loop_block), + destination, + scope, + expr_span, + move |this| { + // conduct the test, if necessary + let body_block = this.cfg.start_new_block(); + this.cfg.terminate( + loop_block, + source_info, + TerminatorKind::FalseUnwind { real_target: body_block, unwind: None }, + ); + this.diverge_from(loop_block); + + // The “return” value of the loop body must always be an unit. We therefore + // introduce a unit temporary as the destination for the loop body. + let tmp = this.get_unit_temp(); + // Execute the body, branching back to the test. + // We don't need to provide a drop scope because `tmp` + // has type `()`. + let body_block_end = unpack!(this.into(tmp, None, body_block, body)); + this.cfg.goto(body_block_end, source_info, loop_block); + schedule_drop(this); + + // Loops are only exited by `break` expressions. + None + }, + ) } ExprKind::Call { ty: _, fun, args, from_hir_call, fn_span } => { let fun = unpack!(block = this.as_local_operand(block, fun)); @@ -228,9 +250,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { }, ); this.diverge_from(block); + schedule_drop(this); success.unit() } - ExprKind::Use { source } => this.into(destination, block, source), + ExprKind::Use { source } => this.into(destination, scope, block, source), ExprKind::Borrow { arg, borrow_kind } => { // We don't do this in `as_rvalue` because we use `as_place` // for borrow expressions, so we cannot create an `RValue` that @@ -290,7 +313,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { .field(n, ty) .into_place(this.hir.tcx(), this.hir.typeck_results()), ) - } + }, }) .collect() } else { @@ -312,12 +335,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { user_ty, active_field_index, ); + this.record_operands_moved(&fields); this.cfg.push_assign( block, source_info, destination, Rvalue::Aggregate(adt, fields), ); + schedule_drop(this); block.unit() } ExprKind::InlineAsm { template, operands, options, line_spans } => { @@ -414,6 +439,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let place = unpack!(block = this.as_place(block, expr)); let rvalue = Rvalue::Use(this.consume_by_copy_or_move(place)); this.cfg.push_assign(block, source_info, destination, rvalue); + schedule_drop(this); block.unit() } ExprKind::Index { .. } | ExprKind::Deref { .. } | ExprKind::Field { .. } => { @@ -431,6 +457,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let place = unpack!(block = this.as_place(block, expr)); let rvalue = Rvalue::Use(this.consume_by_copy_or_move(place)); this.cfg.push_assign(block, source_info, destination, rvalue); + schedule_drop(this); block.unit() } @@ -438,12 +465,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let scope = this.local_scope(); let value = unpack!(block = this.as_operand(block, Some(scope), value)); let resume = this.cfg.start_new_block(); + this.record_operands_moved(slice::from_ref(&value)); this.cfg.terminate( block, source_info, TerminatorKind::Yield { value, resume, resume_arg: destination, drop: None }, ); this.generator_drop_cleanup(block); + schedule_drop(this); resume.unit() } @@ -475,6 +504,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let rvalue = unpack!(block = this.as_local_rvalue(block, expr)); this.cfg.push_assign(block, source_info, destination, rvalue); + schedule_drop(this); block.unit() } }; diff --git a/compiler/rustc_mir_build/src/build/expr/stmt.rs b/compiler/rustc_mir_build/src/build/expr/stmt.rs index f117689d940fd..a974ea0db5f3c 100644 --- a/compiler/rustc_mir_build/src/build/expr/stmt.rs +++ b/compiler/rustc_mir_build/src/build/expr/stmt.rs @@ -3,6 +3,7 @@ use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder}; use crate::thir::*; use rustc_middle::middle::region; use rustc_middle::mir::*; +use std::slice; impl<'a, 'tcx> Builder<'a, 'tcx> { /// Builds a block of MIR statements to evaluate the THIR `expr`. @@ -46,6 +47,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { if this.hir.needs_drop(lhs.ty) { let rhs = unpack!(block = this.as_local_operand(block, rhs)); let lhs = unpack!(block = this.as_place(block, lhs)); + this.record_operands_moved(slice::from_ref(&rhs)); unpack!(block = this.build_drop_and_replace(block, lhs_span, lhs, rhs)); } else { let rhs = unpack!(block = this.as_local_rvalue(block, rhs)); diff --git a/compiler/rustc_mir_build/src/build/into.rs b/compiler/rustc_mir_build/src/build/into.rs index 7264e495b84fd..ee1838ddea66c 100644 --- a/compiler/rustc_mir_build/src/build/into.rs +++ b/compiler/rustc_mir_build/src/build/into.rs @@ -6,6 +6,7 @@ use crate::build::{BlockAnd, Builder}; use crate::thir::*; +use rustc_middle::middle::region; use rustc_middle::mir::*; pub(in crate::build) trait EvalInto<'tcx> { @@ -13,6 +14,7 @@ pub(in crate::build) trait EvalInto<'tcx> { self, builder: &mut Builder<'_, 'tcx>, destination: Place<'tcx>, + scope: Option, block: BasicBlock, ) -> BlockAnd<()>; } @@ -21,13 +23,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { crate fn into( &mut self, destination: Place<'tcx>, + scope: Option, block: BasicBlock, expr: E, ) -> BlockAnd<()> where E: EvalInto<'tcx>, { - expr.eval_into(self, destination, block) + expr.eval_into(self, destination, scope, block) } } @@ -36,10 +39,11 @@ impl<'tcx> EvalInto<'tcx> for ExprRef<'tcx> { self, builder: &mut Builder<'_, 'tcx>, destination: Place<'tcx>, + scope: Option, block: BasicBlock, ) -> BlockAnd<()> { let expr = builder.hir.mirror(self); - builder.into_expr(destination, block, expr) + builder.into_expr(destination, scope, block, expr) } } @@ -48,8 +52,9 @@ impl<'tcx> EvalInto<'tcx> for Expr<'tcx> { self, builder: &mut Builder<'_, 'tcx>, destination: Place<'tcx>, + scope: Option, block: BasicBlock, ) -> BlockAnd<()> { - builder.into_expr(destination, block, self) + builder.into_expr(destination, scope, block, self) } } diff --git a/compiler/rustc_mir_build/src/build/matches/mod.rs b/compiler/rustc_mir_build/src/build/matches/mod.rs index fde007ec011ba..90fcee075b5ac 100644 --- a/compiler/rustc_mir_build/src/build/matches/mod.rs +++ b/compiler/rustc_mir_build/src/build/matches/mod.rs @@ -87,6 +87,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { crate fn match_expr( &mut self, destination: Place<'tcx>, + destination_scope: Option, span: Span, mut block: BasicBlock, scrutinee: ExprRef<'tcx>, @@ -107,6 +108,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { self.lower_match_arms( destination, + destination_scope, scrutinee_place, scrutinee_span, arm_candidates, @@ -213,76 +215,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } } - /// Lower the bindings, guards and arm bodies of a `match` expression. - /// - /// The decision tree should have already been created - /// (by [Builder::lower_match_tree]). - /// - /// `outer_source_info` is the SourceInfo for the whole match. - fn lower_match_arms( - &mut self, - destination: Place<'tcx>, - scrutinee_place: Place<'tcx>, - scrutinee_span: Span, - arm_candidates: Vec<(&'_ Arm<'tcx>, Candidate<'_, 'tcx>)>, - outer_source_info: SourceInfo, - fake_borrow_temps: Vec<(Place<'tcx>, Local)>, - ) -> BlockAnd<()> { - let arm_end_blocks: Vec<_> = arm_candidates - .into_iter() - .map(|(arm, candidate)| { - debug!("lowering arm {:?}\ncandidate = {:?}", arm, candidate); - - let arm_source_info = self.source_info(arm.span); - let arm_scope = (arm.scope, arm_source_info); - self.in_scope(arm_scope, arm.lint_level, |this| { - let body = this.hir.mirror(arm.body.clone()); - let scope = this.declare_bindings( - None, - arm.span, - &arm.pattern, - ArmHasGuard(arm.guard.is_some()), - Some((Some(&scrutinee_place), scrutinee_span)), - ); - - let arm_block = this.bind_pattern( - outer_source_info, - candidate, - arm.guard.as_ref(), - &fake_borrow_temps, - scrutinee_span, - Some(arm.span), - Some(arm.scope), - ); - - if let Some(source_scope) = scope { - this.source_scope = source_scope; - } - - this.into(destination, arm_block, body) - }) - }) - .collect(); - - // all the arm blocks will rejoin here - let end_block = self.cfg.start_new_block(); - - for arm_block in arm_end_blocks { - self.cfg.goto(unpack!(arm_block), outer_source_info, end_block); - } - - self.source_scope = outer_source_info.scope; - - end_block.unit() - } - /// Binds the variables and ascribes types for a given `match` arm or /// `let` binding. /// /// Also check if the guard matches, if it's provided. /// `arm_scope` should be `Some` if and only if this is called for a /// `match` arm. - fn bind_pattern( + crate fn bind_pattern( &mut self, outer_source_info: SourceInfo, candidate: Candidate<'_, 'tcx>, @@ -369,13 +308,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { PatKind::Binding { mode: BindingMode::ByValue, var, subpattern: None, .. } => { let place = self.storage_live_binding(block, var, irrefutable_pat.span, OutsideGuard, true); - unpack!(block = self.into(place, block, initializer)); + let region_scope = self.hir.region_scope_tree.var_scope(var.local_id); + + unpack!(block = self.into(place, Some(region_scope), block, initializer)); // Inject a fake read, see comments on `FakeReadCause::ForLet`. let source_info = self.source_info(irrefutable_pat.span); self.cfg.push_fake_read(block, source_info, FakeReadCause::ForLet, place); - self.schedule_drop_for_binding(var, irrefutable_pat.span, OutsideGuard); block.unit() } @@ -402,9 +342,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { ascription: thir::pattern::Ascription { user_ty: pat_ascription_ty, variance: _, user_ty_span }, } => { + let region_scope = self.hir.region_scope_tree.var_scope(var.local_id); let place = self.storage_live_binding(block, var, irrefutable_pat.span, OutsideGuard, true); - unpack!(block = self.into(place, block, initializer)); + unpack!(block = self.into(place, Some(region_scope), block, initializer)); // Inject a fake read, see comments on `FakeReadCause::ForLet`. let pattern_source_info = self.source_info(irrefutable_pat.span); @@ -442,7 +383,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { }, ); - self.schedule_drop_for_binding(var, irrefutable_pat.span, OutsideGuard); block.unit() } @@ -689,7 +629,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } #[derive(Debug)] -struct Candidate<'pat, 'tcx> { +pub(super) struct Candidate<'pat, 'tcx> { /// [`Span`] of the original pattern that gave rise to this candidate. span: Span, @@ -1752,21 +1692,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let e = self.hir.mirror(e.clone()); let source_info = self.source_info(e.span); (e.span, self.test_bool(block, e, source_info)) - } + }, Guard::IfLet(pat, scrutinee) => { let scrutinee_span = scrutinee.span(); - let scrutinee_place = unpack!( - block = self.lower_scrutinee(block, scrutinee.clone(), scrutinee_span) - ); + let scrutinee_place = unpack!(block = self.lower_scrutinee(block, scrutinee.clone(), scrutinee_span)); let mut guard_candidate = Candidate::new(scrutinee_place, &pat, false); let wildcard = Pat::wildcard_from_ty(pat.ty); let mut otherwise_candidate = Candidate::new(scrutinee_place, &wildcard, false); - let fake_borrow_temps = self.lower_match_tree( - block, - pat.span, - false, - &mut [&mut guard_candidate, &mut otherwise_candidate], - ); + let fake_borrow_temps = + self.lower_match_tree(block, pat.span, false, &mut [&mut guard_candidate, &mut otherwise_candidate]); self.declare_bindings( None, pat.span.to(arm_span.unwrap()), diff --git a/compiler/rustc_mir_build/src/build/matches/util.rs b/compiler/rustc_mir_build/src/build/matches/util.rs index db1f678a5c68d..4ef88c25cadf3 100644 --- a/compiler/rustc_mir_build/src/build/matches/util.rs +++ b/compiler/rustc_mir_build/src/build/matches/util.rs @@ -32,7 +32,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { ) { let tcx = self.hir.tcx(); let (min_length, exact_size) = match place.ty(&self.local_decls, tcx).ty.kind() { - ty::Array(_, length) => (length.eval_usize(tcx, self.hir.param_env), true), + ty::Array(_, length) => { + (length.eval_usize(tcx, self.hir.param_env), true) + } _ => ((prefix.len() + suffix.len()).try_into().unwrap(), false), }; diff --git a/compiler/rustc_mir_build/src/build/mod.rs b/compiler/rustc_mir_build/src/build/mod.rs index 5f6c8d26402ed..e4891eb5a3c0c 100644 --- a/compiler/rustc_mir_build/src/build/mod.rs +++ b/compiler/rustc_mir_build/src/build/mod.rs @@ -618,8 +618,12 @@ where let arg_scope_s = (arg_scope, source_info); // Attribute epilogue to function's closing brace let fn_end = span_with_body.shrink_to_hi(); - let return_block = - unpack!(builder.in_breakable_scope(None, Place::return_place(), fn_end, |builder| { + let return_block = unpack!(builder.in_breakable_scope( + None, + Place::return_place(), + Some(call_site_scope), + fn_end, + |builder| { Some(builder.in_scope(arg_scope_s, LintLevel::Inherited, |builder| { builder.args_and_body( START_BLOCK, @@ -629,11 +633,13 @@ where &body.value, ) })) - })); + }, + )); let source_info = builder.source_info(fn_end); builder.cfg.terminate(return_block, source_info, TerminatorKind::Return); let should_abort = should_abort_on_panic(tcx, fn_def_id, abi); builder.build_drop_trees(should_abort); + builder.unschedule_return_place_drop(); return_block.unit() })); @@ -666,7 +672,9 @@ fn construct_const<'a, 'tcx>( let mut block = START_BLOCK; let ast_expr = &tcx.hir().body(body_id).value; let expr = builder.hir.mirror(ast_expr); - unpack!(block = builder.into_expr(Place::return_place(), block, expr)); + // We don't provide a scope because we can't unwind in constants, so won't + // need to drop the return place. + unpack!(block = builder.into_expr(Place::return_place(), None, block, expr)); let source_info = builder.source_info(span); builder.cfg.terminate(block, source_info, TerminatorKind::Return); @@ -830,8 +838,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { _ => span_bug!(self.fn_span, "upvars with non-closure env ty {:?}", closure_ty), }; let capture_tys = upvar_substs.upvar_tys(); - let captures_with_tys = - hir_typeck_results.closure_min_captures_flattened(fn_def_id).zip(capture_tys); + let captures_with_tys = hir_typeck_results + .closure_min_captures_flattened(fn_def_id) + .zip(capture_tys); self.upvar_mutbls = captures_with_tys .enumerate() @@ -839,7 +848,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let capture = captured_place.info.capture_kind; let var_id = match captured_place.place.base { HirPlaceBase::Upvar(upvar_id) => upvar_id.var_path.hir_id, - _ => bug!("Expected an upvar"), + _ => bug!("Expected an upvar") }; let mutability = captured_place.mutability; @@ -945,7 +954,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { } let body = self.hir.mirror(ast_body); - self.into(Place::return_place(), block, body) + let call_site = + region::Scope { id: ast_body.hir_id.local_id, data: region::ScopeData::CallSite }; + self.into(Place::return_place(), Some(call_site), block, body) } fn set_correct_source_scope_for_arg( diff --git a/compiler/rustc_mir_build/src/build/scope.rs b/compiler/rustc_mir_build/src/build/scope.rs index 5e9d780d17977..62d2212d10962 100644 --- a/compiler/rustc_mir_build/src/build/scope.rs +++ b/compiler/rustc_mir_build/src/build/scope.rs @@ -81,9 +81,10 @@ that contains only loops and breakable blocks. It tracks where a `break`, */ +use crate::build::matches::{ArmHasGuard, Candidate}; use crate::build::{BlockAnd, BlockAndExtension, BlockFrame, Builder, CFG}; -use crate::thir::{Expr, ExprRef, LintLevel}; -use rustc_data_structures::fx::FxHashMap; +use crate::thir::{Arm, Expr, ExprRef, LintLevel}; +use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_index::vec::IndexVec; use rustc_middle::middle::region; use rustc_middle::mir::*; @@ -120,8 +121,6 @@ struct Scope { /// end of the vector (top of the stack) first. drops: Vec, - moved_locals: Vec, - /// The drop index that will drop everything in and below this scope on an /// unwind path. cached_unwind_block: Option, @@ -157,6 +156,8 @@ struct BreakableScope<'tcx> { /// The destination of the loop/block expression itself (i.e., where to put /// the result of a `break` or `return` expression) break_destination: Place<'tcx>, + /// The scope that the destination should have its drop scheduled in. + destination_scope: Option, /// Drops that happen on the `break`/`return` path. break_drops: DropTree, /// Drops that happen on the `continue` path. @@ -405,7 +406,6 @@ impl<'tcx> Scopes<'tcx> { region_scope: region_scope.0, region_scope_span: region_scope.1.span, drops: vec![], - moved_locals: vec![], cached_unwind_block: None, cached_generator_drop_block: None, }); @@ -440,6 +440,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { &mut self, loop_block: Option, break_destination: Place<'tcx>, + destination_scope: Option, span: Span, f: F, ) -> BlockAnd<()> @@ -450,17 +451,19 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let scope = BreakableScope { region_scope, break_destination, + destination_scope, break_drops: DropTree::new(), continue_drops: loop_block.map(|_| DropTree::new()), }; + let continue_block = loop_block.map(|block| (block, self.diverge_cleanup())); self.scopes.breakable_scopes.push(scope); let normal_exit_block = f(self); let breakable_scope = self.scopes.breakable_scopes.pop().unwrap(); assert!(breakable_scope.region_scope == region_scope); - let break_block = self.build_exit_tree(breakable_scope.break_drops, None); if let Some(drops) = breakable_scope.continue_drops { - self.build_exit_tree(drops, loop_block); + self.build_exit_tree(drops, continue_block); } + let break_block = self.build_exit_tree(breakable_scope.break_drops, None); match (normal_exit_block, break_block) { (Some(block), None) | (None, Some(block)) => block, (None, None) => self.cfg.start_new_block().unit(), @@ -589,22 +592,22 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { .rposition(|breakable_scope| breakable_scope.region_scope == scope) .unwrap_or_else(|| span_bug!(span, "no enclosing breakable scope found")) }; - let (break_index, destination) = match target { + let (break_index, destination, dest_scope) = match target { BreakableTarget::Return => { let scope = &self.scopes.breakable_scopes[0]; if scope.break_destination != Place::return_place() { span_bug!(span, "`return` in item with no return scope"); } - (0, Some(scope.break_destination)) + (0, Some(scope.break_destination), scope.destination_scope) } BreakableTarget::Break(scope) => { let break_index = get_scope_index(scope); let scope = &self.scopes.breakable_scopes[break_index]; - (break_index, Some(scope.break_destination)) + (break_index, Some(scope.break_destination), scope.destination_scope) } BreakableTarget::Continue(scope) => { let break_index = get_scope_index(scope); - (break_index, None) + (break_index, None, None) } }; @@ -612,7 +615,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { if let Some(value) = value { debug!("stmt_expr Break val block_context.push(SubExpr)"); self.block_context.push(BlockFrame::SubExpr); - unpack!(block = self.into(destination, block, value)); + unpack!(block = self.into(destination, dest_scope, block, value)); + if let Some(scope) = dest_scope { + self.unschedule_drop(scope, destination.as_local().unwrap()) + }; self.block_context.pop(); } else { self.cfg.push_assign_unit(block, source_info, destination, self.hir.tcx()) @@ -852,14 +858,47 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { span_bug!(span, "region scope {:?} not in scope to drop {:?}", region_scope, local); } - /// Indicates that the "local operand" stored in `local` is + /// Unschedule a drop. Used for `break`, `return` and `match` expressions, + /// where `record_operands_moved` is not powerful enough. + /// + /// The given local is expected to have a value drop scheduled in the given + /// scope and for that drop to be the most recent thing scheduled in that + /// scope. + fn unschedule_drop(&mut self, region_scope: region::Scope, local: Local) { + if !self.hir.needs_drop(self.local_decls[local].ty) { + return; + } + for scope in self.scopes.scopes.iter_mut().rev() { + scope.invalidate_cache(); + + if scope.region_scope == region_scope { + let drop = scope.drops.pop(); + + match drop { + Some(DropData { local: removed_local, kind: DropKind::Value, .. }) + if removed_local == local => + { + return; + } + _ => bug!( + "found wrong drop, expected value drop of {:?}, found {:?}", + local, + drop, + ), + } + } + } + + bug!("region scope {:?} not in scope to unschedule drop of {:?}", region_scope, local); + } + + /// Indicates that the "local operands" stored in `local` is /// *moved* at some point during execution (see `local_scope` for /// more information about what a "local operand" is -- in short, /// it's an intermediate operand created as part of preparing some /// MIR instruction). We use this information to suppress - /// redundant drops on the non-unwind paths. This results in less - /// MIR, but also avoids spurious borrow check errors - /// (c.f. #64391). + /// redundant drops. This results in less MIR, but also avoids spurious + /// borrow check errors (c.f. #64391). /// /// Example: when compiling the call to `foo` here: /// @@ -892,23 +931,25 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let local_scope = self.local_scope(); let scope = self.scopes.scopes.last_mut().unwrap(); - assert_eq!(scope.region_scope, local_scope, "local scope is not the topmost scope!",); + assert_eq!( + scope.region_scope, local_scope, + "local scope is not the topmost scope!", + ); // look for moves of a local variable, like `MOVE(_X)` - let locals_moved = operands.iter().flat_map(|operand| match operand { - Operand::Copy(_) | Operand::Constant(_) => None, - Operand::Move(place) => place.as_local(), - }); + let locals_moved = operands + .iter() + .filter_map(|operand| match operand { + Operand::Copy(_) | Operand::Constant(_) => None, + Operand::Move(place) => place.as_local(), + }) + .collect::>(); - for local in locals_moved { - // check if we have a Drop for this operand and -- if so - // -- add it to the list of moved operands. Note that this - // local might not have been an operand created for this - // call, it could come from other places too. - if scope.drops.iter().any(|drop| drop.local == local && drop.kind == DropKind::Value) { - scope.moved_locals.push(local); - } - } + // Remove the drops for the moved operands. + scope + .drops + .retain(|drop| drop.kind == DropKind::Storage || !locals_moved.contains(&drop.local)); + scope.invalidate_cache(); } // Other @@ -1005,9 +1046,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { matches!( self.cfg.block_data(start).terminator().kind, TerminatorKind::Assert { .. } - | TerminatorKind::Call { .. } - | TerminatorKind::DropAndReplace { .. } - | TerminatorKind::FalseUnwind { .. } + | TerminatorKind::Call {..} + | TerminatorKind::DropAndReplace { .. } + | TerminatorKind::FalseUnwind { .. } ), "diverge_from called on block with terminator that cannot unwind." ); @@ -1095,11 +1136,97 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { success_block } + /// Lower the arms and guards of a match. + /// + /// The decision tree should have already been created (by + /// [Builder::lower_match_tree]). + /// + /// This is this module, and not in `build::matches` because we have to do + /// some careful scope manipulation to have the drop of the destination be + /// scheduled at the end of each arm and then cleared for the next arm. + crate fn lower_match_arms( + &mut self, + destination: Place<'tcx>, + destination_scope: Option, + scrutinee_place: Place<'tcx>, + scrutinee_span: Span, + arm_candidates: Vec<(&'_ Arm<'tcx>, Candidate<'_, 'tcx>)>, + outer_source_info: SourceInfo, + fake_borrow_temps: Vec<(Place<'tcx>, Local)>, + ) -> BlockAnd<()> { + if arm_candidates.is_empty() { + // If there are no arms to schedule drops, then we have to do it + // manually. + if let Some(scope) = destination_scope { + self.schedule_drop( + outer_source_info.span, + scope, + destination.as_local().unwrap(), + DropKind::Value, + ); + } + return self.cfg.start_new_block().unit(); + } + let mut first_arm = true; + let arm_end_blocks: Vec<_> = arm_candidates + .into_iter() + .map(|(arm, candidate)| { + debug!("lowering arm {:?}\ncandidate = {:?}", arm, candidate); + + if first_arm { + first_arm = false; + } else if let Some(scope) = destination_scope { + self.unschedule_drop(scope, destination.as_local().unwrap()); + } + + let arm_source_info = self.source_info(arm.span); + let arm_scope = (arm.scope, arm_source_info); + self.in_scope(arm_scope, arm.lint_level, |this| { + let body = this.hir.mirror(arm.body.clone()); + let scope = this.declare_bindings( + None, + arm.span, + &arm.pattern, + ArmHasGuard(arm.guard.is_some()), + Some((Some(&scrutinee_place), scrutinee_span)), + ); + + let arm_block = this.bind_pattern( + outer_source_info, + candidate, + arm.guard.as_ref(), + &fake_borrow_temps, + scrutinee_span, + Some(arm.span), + Some(arm.scope), + ); + + if let Some(source_scope) = scope { + this.source_scope = source_scope; + } + + this.into(destination, destination_scope, arm_block, body) + }) + }) + .collect(); + + // all the arm blocks will rejoin here + let end_block = self.cfg.start_new_block(); + + for arm_block in arm_end_blocks { + self.cfg.goto(unpack!(arm_block), outer_source_info, end_block); + } + + self.source_scope = outer_source_info.scope; + + end_block.unit() + } + /// Unschedules any drops in the top scope. /// /// This is only needed for `match` arm scopes, because they have one /// entrance per pattern, but only one exit. - crate fn clear_top_scope(&mut self, region_scope: region::Scope) { + pub(super) fn clear_top_scope(&mut self, region_scope: region::Scope) { let top_scope = self.scopes.scopes.last_mut().unwrap(); assert_eq!(top_scope.region_scope, region_scope); @@ -1107,6 +1234,18 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { top_scope.drops.clear(); top_scope.invalidate_cache(); } + + /// Unschedules the drop of the return place. + /// + /// If the return type of a function requires drop, then we schedule it + /// in the outermost scope so that it's dropped if there's a panic while + /// we drop any local variables. But we don't want to drop it if we + /// return normally. + crate fn unschedule_return_place_drop(&mut self) { + assert_eq!(self.scopes.scopes.len(), 1); + assert!(self.scopes.scopes[0].drops.len() <= 1); + self.scopes.scopes[0].drops.clear(); + } } /// Builds drops for `pop_scope` and `leave_top_scope`. @@ -1153,14 +1292,6 @@ fn build_scope_drops<'tcx>( debug_assert_eq!(unwind_drops.drops[unwind_to].0.kind, drop_data.kind); unwind_to = unwind_drops.drops[unwind_to].1; - // If the operand has been moved, and we are not on an unwind - // path, then don't generate the drop. (We only take this into - // account for non-unwind paths so as not to disturb the - // caching mechanism.) - if scope.moved_locals.iter().any(|&o| o == local) { - continue; - } - unwind_drops.add_entry(block, unwind_to); let next = cfg.start_new_block(); @@ -1190,20 +1321,24 @@ impl<'a, 'tcx: 'a> Builder<'a, 'tcx> { /// Build a drop tree for a breakable scope. /// /// If `continue_block` is `Some`, then the tree is for `continue` inside a - /// loop. Otherwise this is for `break` or `return`. + /// loop. Otherwise this is for `break` or `return`. The `DropIdx` is the + /// next drop in the case that the drop tree unwinds. This is needed + /// because the drop of the break destination has already been scheduled + /// but it hasn't been initialized on the `continue` paths. fn build_exit_tree( &mut self, mut drops: DropTree, - continue_block: Option, + continue_block: Option<(BasicBlock, DropIdx)>, ) -> Option> { let mut blocks = IndexVec::from_elem(None, &drops.drops); - blocks[ROOT_NODE] = continue_block; + blocks[ROOT_NODE] = continue_block.map(|(block, _)| block); drops.build_mir::(&mut self.cfg, &mut blocks); // Link the exit drop tree to unwind drop tree. if drops.drops.iter().any(|(drop, _)| drop.kind == DropKind::Value) { - let unwind_target = self.diverge_cleanup(); + let unwind_target = continue_block + .map_or_else(|| self.diverge_cleanup(), |(_, unwind_target)| unwind_target); let mut unwind_indices = IndexVec::from_elem_n(unwind_target, 1); for (drop_idx, drop_data) in drops.drops.iter_enumerated().skip(1) { match drop_data.0.kind { diff --git a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs index 6ec602ff59b9c..397706851cb79 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/check_match.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/check_match.rs @@ -1,6 +1,6 @@ +use super::usefulness::Usefulness::*; use super::usefulness::{ - compute_match_usefulness, expand_pattern, MatchArm, MatchCheckCtxt, Reachability, - UsefulnessReport, + compute_match_usefulness, expand_pattern, MatchArm, MatchCheckCtxt, UsefulnessReport, }; use super::{PatCtxt, PatKind, PatternError}; @@ -398,11 +398,10 @@ fn report_arm_reachability<'p, 'tcx>( report: &UsefulnessReport<'p, 'tcx>, source: hir::MatchSource, ) { - use Reachability::*; let mut catchall = None; for (arm_index, (arm, is_useful)) in report.arm_usefulness.iter().enumerate() { match is_useful { - Unreachable => { + NotUseful => { match source { hir::MatchSource::WhileDesugar => bug!(), @@ -431,16 +430,17 @@ fn report_arm_reachability<'p, 'tcx>( hir::MatchSource::AwaitDesugar | hir::MatchSource::TryDesugar => {} } } - Reachable(unreachables) if unreachables.is_empty() => {} + Useful(unreachables) if unreachables.is_empty() => {} // The arm is reachable, but contains unreachable subpatterns (from or-patterns). - Reachable(unreachables) => { - let mut unreachables = unreachables.clone(); + Useful(unreachables) => { + let mut unreachables: Vec<_> = unreachables.iter().collect(); // Emit lints in the order in which they occur in the file. unreachables.sort_unstable(); for span in unreachables { unreachable_pattern(cx.tcx, span, arm.hir_id, None); } } + UsefulWithWitness(_) => bug!(), } if !arm.has_guard && catchall.is_none() && pat_is_catchall(arm.pat) { catchall = Some(arm.pat.span); diff --git a/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs b/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs index 3a67eeff92c31..e67166c99c8da 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs @@ -723,6 +723,8 @@ impl<'tcx> Constructor<'tcx> { where 'tcx: 'a, { + debug!("Constructor::split({:#?})", self); + match self { Wildcard => { let mut split_wildcard = SplitWildcard::new(pcx); diff --git a/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs b/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs index f3f21b903ea08..d7c08a2d1af6b 100644 --- a/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs +++ b/compiler/rustc_mir_build/src/thir/pattern/usefulness.rs @@ -288,7 +288,6 @@ use super::{Pat, PatKind}; use super::{PatternFoldable, PatternFolder}; use rustc_data_structures::captures::Captures; -use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::OnceCell; use rustc_arena::TypedArena; @@ -345,12 +344,6 @@ pub(super) struct PatCtxt<'a, 'p, 'tcx> { pub(super) is_top_level: bool, } -impl<'a, 'p, 'tcx> fmt::Debug for PatCtxt<'a, 'p, 'tcx> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("PatCtxt").field("ty", &self.ty).finish() - } -} - crate fn expand_pattern<'tcx>(pat: Pat<'tcx>) -> Pat<'tcx> { LiteralExpander.fold_pattern(&pat) } @@ -386,32 +379,11 @@ impl<'tcx> Pat<'tcx> { pub(super) fn is_wildcard(&self) -> bool { matches!(*self.kind, PatKind::Binding { subpattern: None, .. } | PatKind::Wild) } - - fn is_or_pat(&self) -> bool { - matches!(*self.kind, PatKind::Or { .. }) - } - - /// Recursively expand this pattern into its subpatterns. Only useful for or-patterns. - fn expand_or_pat(&self) -> Vec<&Self> { - fn expand<'p, 'tcx>(pat: &'p Pat<'tcx>, vec: &mut Vec<&'p Pat<'tcx>>) { - if let PatKind::Or { pats } = pat.kind.as_ref() { - for pat in pats { - expand(pat, vec); - } - } else { - vec.push(pat) - } - } - - let mut pats = Vec::new(); - expand(self, &mut pats); - pats - } } /// A row of a matrix. Rows of len 1 are very common, which is why `SmallVec[_; 2]` /// works well. -#[derive(Clone)] +#[derive(Debug, Clone)] struct PatStack<'p, 'tcx> { pats: SmallVec<[&'p Pat<'tcx>; 2]>, /// Cache for the constructor of the head @@ -447,14 +419,23 @@ impl<'p, 'tcx> PatStack<'p, 'tcx> { self.pats.iter().copied() } - // Recursively expand the first pattern into its subpatterns. Only useful if the pattern is an - // or-pattern. Panics if `self` is empty. - fn expand_or_pat<'a>(&'a self) -> impl Iterator> + Captures<'a> { - self.head().expand_or_pat().into_iter().map(move |pat| { - let mut new_patstack = PatStack::from_pattern(pat); - new_patstack.pats.extend_from_slice(&self.pats[1..]); - new_patstack - }) + // If the first pattern is an or-pattern, expand this pattern. Otherwise, return `None`. + fn expand_or_pat(&self) -> Option> { + if self.is_empty() { + None + } else if let PatKind::Or { pats } = &*self.head().kind { + Some( + pats.iter() + .map(|pat| { + let mut new_patstack = PatStack::from_pattern(pat); + new_patstack.pats.extend_from_slice(&self.pats[1..]); + new_patstack + }) + .collect(), + ) + } else { + None + } } /// This computes `S(self.head_ctor(), self)`. See top of the file for explanations. @@ -494,17 +475,6 @@ impl<'p, 'tcx> FromIterator<&'p Pat<'tcx>> for PatStack<'p, 'tcx> { } } -/// Pretty-printing for matrix row. -impl<'p, 'tcx> fmt::Debug for PatStack<'p, 'tcx> { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "+")?; - for pat in self.iter() { - write!(f, " {} +", pat)?; - } - Ok(()) - } -} - /// A 2D matrix. #[derive(Clone, PartialEq)] pub(super) struct Matrix<'p, 'tcx> { @@ -521,12 +491,13 @@ impl<'p, 'tcx> Matrix<'p, 'tcx> { self.patterns.get(0).map(|r| r.len()) } - /// Pushes a new row to the matrix. If the row starts with an or-pattern, this recursively - /// expands it. + /// Pushes a new row to the matrix. If the row starts with an or-pattern, this expands it. fn push(&mut self, row: PatStack<'p, 'tcx>) { - if !row.is_empty() && row.head().is_or_pat() { - for row in row.expand_or_pat() { - self.patterns.push(row); + if let Some(rows) = row.expand_or_pat() { + for row in rows { + // We recursively expand the or-patterns of the new rows. + // This is necessary as we might have `0 | (1 | 2)` or e.g., `x @ 0 | x @ (1 | 2)`. + self.push(row) } } else { self.patterns.push(row); @@ -572,11 +543,17 @@ impl<'p, 'tcx> Matrix<'p, 'tcx> { /// Pretty-printer for matrices of patterns, example: /// /// ```text +/// +++++++++++++++++++++++++++++ /// + _ + [] + +/// +++++++++++++++++++++++++++++ /// + true + [First] + +/// +++++++++++++++++++++++++++++ /// + true + [Second(true)] + +/// +++++++++++++++++++++++++++++ /// + false + [_] + +/// +++++++++++++++++++++++++++++ /// + _ + [_, _, tail @ ..] + +/// +++++++++++++++++++++++++++++ /// ``` impl<'p, 'tcx> fmt::Debug for Matrix<'p, 'tcx> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -584,14 +561,17 @@ impl<'p, 'tcx> fmt::Debug for Matrix<'p, 'tcx> { let Matrix { patterns: m, .. } = self; let pretty_printed_matrix: Vec> = - m.iter().map(|row| row.iter().map(|pat| format!("{}", pat)).collect()).collect(); + m.iter().map(|row| row.iter().map(|pat| format!("{:?}", pat)).collect()).collect(); - let column_count = m.iter().map(|row| row.len()).next().unwrap_or(0); + let column_count = m.iter().map(|row| row.len()).max().unwrap_or(0); assert!(m.iter().all(|row| row.len() == column_count)); let column_widths: Vec = (0..column_count) .map(|col| pretty_printed_matrix.iter().map(|row| row[col].len()).max().unwrap_or(0)) .collect(); + let total_width = column_widths.iter().cloned().sum::() + column_count * 3 + 1; + let br = "+".repeat(total_width); + write!(f, "{}\n", br)?; for row in pretty_printed_matrix { write!(f, "+")?; for (column, pat_str) in row.into_iter().enumerate() { @@ -600,6 +580,7 @@ impl<'p, 'tcx> fmt::Debug for Matrix<'p, 'tcx> { write!(f, " +")?; } write!(f, "\n")?; + write!(f, "{}\n", br)?; } Ok(()) } @@ -619,318 +600,183 @@ impl<'p, 'tcx> FromIterator> for Matrix<'p, 'tcx> { } } -/// Given a pattern or a pattern-stack, this struct captures a set of its subpatterns. We use that -/// to track reachable sub-patterns arising from or-patterns. In the absence of or-patterns this -/// will always be either `Empty` (the whole pattern is unreachable) or `Full` (the whole pattern -/// is reachable). When there are or-patterns, some subpatterns may be reachable while others -/// aren't. In this case the whole pattern still counts as reachable, but we will lint the -/// unreachable subpatterns. -/// -/// This supports a limited set of operations, so not all possible sets of subpatterns can be -/// represented. That's ok, we only want the ones that make sense for our usage. -/// -/// What we're doing is illustrated by this: -/// ``` -/// match (true, 0) { -/// (true, 0) => {} -/// (_, 1) => {} -/// (true | false, 0 | 1) => {} -/// } -/// ``` -/// When we try the alternatives of the `true | false` or-pattern, the last `0` is reachable in the -/// `false` alternative but not the `true`. So overall it is reachable. By contrast, the last `1` -/// is not reachable in either alternative, so we want to signal this to the user. -/// Therefore we take the union of sets of reachable patterns coming from different alternatives in -/// order to figure out which subpatterns are overall reachable. -/// -/// Invariant: we try to construct the smallest representation we can. In particular if -/// `self.is_empty()` we ensure that `self` is `Empty`, and same with `Full`. This is not important -/// for correctness currently. -#[derive(Debug, Clone)] -enum SubPatSet<'p, 'tcx> { - /// The empty set. This means the pattern is unreachable. - Empty, - /// The set containing the full pattern. - Full, - /// If the pattern is a pattern with a constructor or a pattern-stack, we store a set for each - /// of its subpatterns. Missing entries in the map are implicitly full, because that's the - /// common case. - Seq { subpats: FxHashMap> }, - /// If the pattern is an or-pattern, we store a set for each of its alternatives. Missing - /// entries in the map are implicitly empty. Note: we always flatten nested or-patterns. - Alt { - subpats: FxHashMap>, - /// Counts the total number of alternatives in the pattern - alt_count: usize, - /// We keep the pattern around to retrieve spans. - pat: &'p Pat<'tcx>, - }, +/// Represents a set of `Span`s closed under the containment relation. That is, if a `Span` is +/// contained in the set then all `Span`s contained in it are also implicitly contained in the set. +/// In particular this means that when intersecting two sets, taking the intersection of some span +/// and one of its subspans returns the subspan, whereas a simple `HashSet` would have returned an +/// empty intersection. +/// It is assumed that two spans don't overlap without one being contained in the other; in other +/// words, that the inclusion structure forms a tree and not a DAG. +/// Intersection is not very efficient. It compares everything pairwise. If needed it could be made +/// faster by sorting the `Span`s and merging cleverly. +#[derive(Debug, Clone, Default)] +pub(crate) struct SpanSet { + /// The minimal set of `Span`s required to represent the whole set. If A and B are `Span`s in + /// the `SpanSet`, and A is a descendant of B, then only B will be in `root_spans`. + /// Invariant: the spans are disjoint. + root_spans: Vec, } -impl<'p, 'tcx> SubPatSet<'p, 'tcx> { - fn full() -> Self { - SubPatSet::Full - } - fn empty() -> Self { - SubPatSet::Empty +impl SpanSet { + /// Creates an empty set. + fn new() -> Self { + Self::default() } - fn is_empty(&self) -> bool { - match self { - SubPatSet::Empty => true, - SubPatSet::Full => false, - // If any subpattern in a sequence is unreachable, the whole pattern is unreachable. - SubPatSet::Seq { subpats } => subpats.values().any(|set| set.is_empty()), - // An or-pattern is reachable if any of its alternatives is. - SubPatSet::Alt { subpats, .. } => subpats.values().all(|set| set.is_empty()), - } + /// Tests whether the set is empty. + pub(crate) fn is_empty(&self) -> bool { + self.root_spans.is_empty() } - fn is_full(&self) -> bool { - match self { - SubPatSet::Empty => false, - SubPatSet::Full => true, - // The whole pattern is reachable only when all its alternatives are. - SubPatSet::Seq { subpats } => subpats.values().all(|sub_set| sub_set.is_full()), - // The whole or-pattern is reachable only when all its alternatives are. - SubPatSet::Alt { subpats, alt_count, .. } => { - subpats.len() == *alt_count && subpats.values().all(|set| set.is_full()) - } - } + /// Iterate over the disjoint list of spans at the roots of this set. + pub(crate) fn iter<'a>(&'a self) -> impl Iterator + Captures<'a> { + self.root_spans.iter().copied() } - /// Union `self` with `other`, mutating `self`. - fn union(&mut self, other: Self) { - use SubPatSet::*; - // Union with full stays full; union with empty changes nothing. - if self.is_full() || other.is_empty() { - return; - } else if self.is_empty() { - *self = other; - return; - } else if other.is_full() { - *self = Full; - return; - } - - match (&mut *self, other) { - (Seq { subpats: s_set }, Seq { subpats: mut o_set }) => { - s_set.retain(|i, s_sub_set| { - // Missing entries count as full. - let o_sub_set = o_set.remove(&i).unwrap_or(Full); - s_sub_set.union(o_sub_set); - // We drop full entries. - !s_sub_set.is_full() - }); - // Everything left in `o_set` is missing from `s_set`, i.e. counts as full. Since - // unioning with full returns full, we can drop those entries. - } - (Alt { subpats: s_set, .. }, Alt { subpats: mut o_set, .. }) => { - s_set.retain(|i, s_sub_set| { - // Missing entries count as empty. - let o_sub_set = o_set.remove(&i).unwrap_or(Empty); - s_sub_set.union(o_sub_set); - // We drop empty entries. - !s_sub_set.is_empty() - }); - // Everything left in `o_set` is missing from `s_set`, i.e. counts as empty. Since - // unioning with empty changes nothing, we can take those entries as is. - s_set.extend(o_set); - } - _ => bug!(), - } - - if self.is_full() { - *self = Full; - } + /// Tests whether the set contains a given Span. + fn contains(&self, span: Span) -> bool { + self.iter().any(|root_span| root_span.contains(span)) } - /// Returns a list of the spans of the unreachable subpatterns. If `self` is empty (i.e. the - /// whole pattern is unreachable) we return `None`. - fn list_unreachable_spans(&self) -> Option> { - /// Panics if `set.is_empty()`. - fn fill_spans(set: &SubPatSet<'_, '_>, spans: &mut Vec) { - match set { - SubPatSet::Empty => bug!(), - SubPatSet::Full => {} - SubPatSet::Seq { subpats } => { - for (_, sub_set) in subpats { - fill_spans(sub_set, spans); - } - } - SubPatSet::Alt { subpats, pat, alt_count, .. } => { - let expanded = pat.expand_or_pat(); - for i in 0..*alt_count { - let sub_set = subpats.get(&i).unwrap_or(&SubPatSet::Empty); - if sub_set.is_empty() { - // Found a unreachable subpattern. - spans.push(expanded[i].span); - } else { - fill_spans(sub_set, spans); - } - } - } - } - } - - if self.is_empty() { - return None; - } - if self.is_full() { - // No subpatterns are unreachable. - return Some(Vec::new()); - } - let mut spans = Vec::new(); - fill_spans(self, &mut spans); - Some(spans) + /// Add a span to the set if we know the span has no intersection in this set. + fn push_nonintersecting(&mut self, new_span: Span) { + self.root_spans.push(new_span); } - /// When `self` refers to a patstack that was obtained from specialization, after running - /// `unspecialize` it will refer to the original patstack before specialization. - fn unspecialize(self, arity: usize) -> Self { - use SubPatSet::*; - match self { - Full => Full, - Empty => Empty, - Seq { subpats } => { - // We gather the first `arity` subpatterns together and shift the remaining ones. - let mut new_subpats = FxHashMap::default(); - let mut new_subpats_first_col = FxHashMap::default(); - for (i, sub_set) in subpats { - if i < arity { - // The first `arity` indices are now part of the pattern in the first - // column. - new_subpats_first_col.insert(i, sub_set); - } else { - // Indices after `arity` are simply shifted - new_subpats.insert(i - arity + 1, sub_set); - } - } - // If `new_subpats_first_col` has no entries it counts as full, so we can omit it. - if !new_subpats_first_col.is_empty() { - new_subpats.insert(0, Seq { subpats: new_subpats_first_col }); - } - Seq { subpats: new_subpats } - } - Alt { .. } => bug!(), // `self` is a patstack + fn intersection_mut(&mut self, other: &Self) { + if self.is_empty() || other.is_empty() { + *self = Self::new(); + return; } - } - - /// When `self` refers to a patstack that was obtained from splitting an or-pattern, after - /// running `unspecialize` it will refer to the original patstack before splitting. - /// - /// For example: - /// ``` - /// match Some(true) { - /// Some(true) => {} - /// None | Some(true | false) => {} - /// } - /// ``` - /// Here `None` would return the full set and `Some(true | false)` would return the set - /// containing `false`. After `unsplit_or_pat`, we want the set to contain `None` and `false`. - /// This is what this function does. - fn unsplit_or_pat(mut self, alt_id: usize, alt_count: usize, pat: &'p Pat<'tcx>) -> Self { - use SubPatSet::*; - if self.is_empty() { - return Empty; + // Those that were in `self` but not contained in `other` + let mut leftover = SpanSet::new(); + // We keep the elements in `self` that are also in `other`. + self.root_spans.retain(|span| { + let retain = other.contains(*span); + if !retain { + leftover.root_spans.push(*span); + } + retain + }); + // We keep the elements in `other` that are also in the original `self`. You might think + // this is not needed because `self` already contains the intersection. But those aren't + // just sets of things. If `self = [a]`, `other = [b]` and `a` contains `b`, then `b` + // belongs in the intersection but we didn't catch it in the filtering above. We look at + // `leftover` instead of the full original `self` to avoid duplicates. + for span in other.iter() { + if leftover.contains(span) { + self.root_spans.push(span); + } } - - // Subpatterns coming from inside the or-pattern alternative itself, e.g. in `None | Some(0 - // | 1)`. - let set_first_col = match &mut self { - Full => Full, - Seq { subpats } => subpats.remove(&0).unwrap_or(Full), - Empty => unreachable!(), - Alt { .. } => bug!(), // `self` is a patstack - }; - let mut subpats_first_col = FxHashMap::default(); - subpats_first_col.insert(alt_id, set_first_col); - let set_first_col = Alt { subpats: subpats_first_col, pat, alt_count }; - - let mut subpats = match self { - Full => FxHashMap::default(), - Seq { subpats } => subpats, - Empty => unreachable!(), - Alt { .. } => bug!(), // `self` is a patstack - }; - subpats.insert(0, set_first_col); - Seq { subpats } } } -/// This carries the results of computing usefulness, as described at the top of the file. When -/// checking usefulness of a match branch, we use the `NoWitnesses` variant, which also keeps track -/// of potential unreachable sub-patterns (in the presence of or-patterns). When checking -/// exhaustiveness of a whole match, we use the `WithWitnesses` variant, which carries a list of -/// witnesses of non-exhaustiveness when there are any. -/// Which variant to use is dictated by `WitnessPreference`. #[derive(Clone, Debug)] -enum Usefulness<'p, 'tcx> { - /// Carries a set of subpatterns that have been found to be reachable. If empty, this indicates - /// the whole pattern is unreachable. If not, this indicates that the pattern is reachable but - /// that some sub-patterns may be unreachable (due to or-patterns). In the absence of - /// or-patterns this will always be either `Empty` (the whole pattern is unreachable) or `Full` - /// (the whole pattern is reachable). - NoWitnesses(SubPatSet<'p, 'tcx>), - /// Carries a list of witnesses of non-exhaustiveness. If empty, indicates that the whole - /// pattern is unreachable. - WithWitnesses(Vec>), +crate enum Usefulness<'tcx> { + /// Pontentially carries a set of sub-branches that have been found to be unreachable. Used + /// only in the presence of or-patterns, otherwise it stays empty. + Useful(SpanSet), + /// Carries a list of witnesses of non-exhaustiveness. + UsefulWithWitness(Vec>), + NotUseful, } -impl<'p, 'tcx> Usefulness<'p, 'tcx> { +impl<'tcx> Usefulness<'tcx> { fn new_useful(preference: WitnessPreference) -> Self { match preference { - ConstructWitness => WithWitnesses(vec![Witness(vec![])]), - LeaveOutWitness => NoWitnesses(SubPatSet::full()), - } - } - fn new_not_useful(preference: WitnessPreference) -> Self { - match preference { - ConstructWitness => WithWitnesses(vec![]), - LeaveOutWitness => NoWitnesses(SubPatSet::empty()), - } - } - - /// Combine usefulnesses from two branches. This is an associative operation. - fn extend(&mut self, other: Self) { - match (&mut *self, other) { - (WithWitnesses(_), WithWitnesses(o)) if o.is_empty() => {} - (WithWitnesses(s), WithWitnesses(o)) if s.is_empty() => *self = WithWitnesses(o), - (WithWitnesses(s), WithWitnesses(o)) => s.extend(o), - (NoWitnesses(s), NoWitnesses(o)) => s.union(o), - _ => unreachable!(), + ConstructWitness => UsefulWithWitness(vec![Witness(vec![])]), + LeaveOutWitness => Useful(Default::default()), } } /// When trying several branches and each returns a `Usefulness`, we need to combine the /// results together. - fn merge(pref: WitnessPreference, usefulnesses: impl Iterator) -> Self { - let mut ret = Self::new_not_useful(pref); + fn merge(usefulnesses: impl Iterator) -> Self { + // If we have detected some unreachable sub-branches, we only want to keep them when they + // were unreachable in _all_ branches. Eg. in the following, the last `true` is unreachable + // in the second branch of the first or-pattern, but not otherwise. Therefore we don't want + // to lint that it is unreachable. + // ``` + // match (true, true) { + // (true, true) => {} + // (false | true, false | true) => {} + // } + // ``` + // Here however we _do_ want to lint that the last `false` is unreachable. So we don't want + // to intersect the spans that come directly from the or-pattern, since each branch of the + // or-pattern brings a new disjoint pattern. + // ``` + // match None { + // Some(false) => {} + // None | Some(true | false) => {} + // } + // ``` + + // Is `None` when no branch was useful. Will often be `Some(Spanset::new())` because the + // sets are only non-empty in the presence of or-patterns. + let mut unreachables: Option = None; + // Witnesses of usefulness, if any. + let mut witnesses = Vec::new(); + for u in usefulnesses { - ret.extend(u); - if let NoWitnesses(subpats) = &ret { - if subpats.is_full() { - // Once we reach the full set, more unions won't change the result. - return ret; + match u { + Useful(spans) if spans.is_empty() => { + // Once we reach the empty set, more intersections won't change the result. + return Useful(SpanSet::new()); + } + Useful(spans) => { + if let Some(unreachables) = &mut unreachables { + if !unreachables.is_empty() { + unreachables.intersection_mut(&spans); + } + if unreachables.is_empty() { + return Useful(SpanSet::new()); + } + } else { + unreachables = Some(spans); + } + } + NotUseful => {} + UsefulWithWitness(wits) => { + witnesses.extend(wits); } } } - ret + + if !witnesses.is_empty() { + UsefulWithWitness(witnesses) + } else if let Some(unreachables) = unreachables { + Useful(unreachables) + } else { + NotUseful + } } /// After calculating the usefulness for a branch of an or-pattern, call this to make this /// usefulness mergeable with those from the other branches. - fn unsplit_or_pat(self, alt_id: usize, alt_count: usize, pat: &'p Pat<'tcx>) -> Self { + fn unsplit_or_pat(self, this_span: Span, or_pat_spans: &[Span]) -> Self { match self { - NoWitnesses(subpats) => NoWitnesses(subpats.unsplit_or_pat(alt_id, alt_count, pat)), - WithWitnesses(_) => bug!(), + Useful(mut spans) => { + // We register the spans of the other branches of this or-pattern as being + // unreachable from this one. This ensures that intersecting together the sets of + // spans returns what we want. + // Until we optimize `SpanSet` however, intersecting this entails a number of + // comparisons quadratic in the number of branches. + for &span in or_pat_spans { + if span != this_span { + spans.push_nonintersecting(span); + } + } + Useful(spans) + } + x => x, } } /// After calculating usefulness after a specialization, call this to recontruct a usefulness /// that makes sense for the matrix pre-specialization. This new usefulness can then be merged /// with the results of specializing with the other constructors. - fn apply_constructor( + fn apply_constructor<'p>( self, pcx: PatCtxt<'_, 'p, 'tcx>, matrix: &Matrix<'p, 'tcx>, // used to compute missing ctors @@ -938,8 +784,7 @@ impl<'p, 'tcx> Usefulness<'p, 'tcx> { ctor_wild_subpatterns: &Fields<'p, 'tcx>, ) -> Self { match self { - WithWitnesses(witnesses) if witnesses.is_empty() => WithWitnesses(witnesses), - WithWitnesses(witnesses) => { + UsefulWithWitness(witnesses) => { let new_witnesses = if matches!(ctor, Constructor::Missing) { let mut split_wildcard = SplitWildcard::new(pcx); split_wildcard.split(pcx, matrix.head_ctors(pcx.cx)); @@ -969,9 +814,9 @@ impl<'p, 'tcx> Usefulness<'p, 'tcx> { .map(|witness| witness.apply_constructor(pcx, &ctor, ctor_wild_subpatterns)) .collect() }; - WithWitnesses(new_witnesses) + UsefulWithWitness(new_witnesses) } - NoWitnesses(subpats) => NoWitnesses(subpats.unspecialize(ctor_wild_subpatterns.len())), + x => x, } } } @@ -1079,7 +924,6 @@ impl<'tcx> Witness<'tcx> { /// `is_under_guard` is used to inform if the pattern has a guard. If it /// has one it must not be inserted into the matrix. This shouldn't be /// relied on for soundness. -#[instrument(skip(cx, matrix, witness_preference, hir_id, is_under_guard, is_top_level))] fn is_useful<'p, 'tcx>( cx: &MatchCheckCtxt<'p, 'tcx>, matrix: &Matrix<'p, 'tcx>, @@ -1088,9 +932,9 @@ fn is_useful<'p, 'tcx>( hir_id: HirId, is_under_guard: bool, is_top_level: bool, -) -> Usefulness<'p, 'tcx> { - debug!("matrix,v={:?}{:?}", matrix, v); +) -> Usefulness<'tcx> { let Matrix { patterns: rows, .. } = matrix; + debug!("is_useful({:#?}, {:#?})", matrix, v); // The base case. We are pattern-matching on () and the return value is // based on whether our matrix has a row or not. @@ -1098,14 +942,12 @@ fn is_useful<'p, 'tcx>( // first and then, if v is non-empty, the return value is based on whether // the type of the tuple we're checking is inhabited or not. if v.is_empty() { - let ret = if rows.is_empty() { + return if rows.is_empty() { Usefulness::new_useful(witness_preference) } else { - Usefulness::new_not_useful(witness_preference) + NotUseful }; - debug!(?ret); - return ret; - } + }; assert!(rows.iter().all(|r| r.len() == v.len())); @@ -1113,15 +955,16 @@ fn is_useful<'p, 'tcx>( let ty = matrix.heads().next().map_or(v.head().ty, |r| r.ty); let pcx = PatCtxt { cx, ty, span: v.head().span, is_top_level }; + debug!("is_useful_expand_first_col: ty={:#?}, expanding {:#?}", pcx.ty, v.head()); + // If the first pattern is an or-pattern, expand it. - let ret = if v.head().is_or_pat() { - debug!("expanding or-pattern"); - let v_head = v.head(); - let vs: Vec<_> = v.expand_or_pat().collect(); - let alt_count = vs.len(); - // We try each or-pattern branch in turn. + let ret = if let Some(vs) = v.expand_or_pat() { + let subspans: Vec<_> = vs.iter().map(|v| v.head().span).collect(); + // We expand the or pattern, trying each of its branches in turn and keeping careful track + // of possible unreachable sub-branches. let mut matrix = matrix.clone(); - let usefulnesses = vs.into_iter().enumerate().map(|(i, v)| { + let usefulnesses = vs.into_iter().map(|v| { + let v_span = v.head().span; let usefulness = is_useful(cx, &matrix, &v, witness_preference, hir_id, is_under_guard, false); // If pattern has a guard don't add it to the matrix. @@ -1130,9 +973,9 @@ fn is_useful<'p, 'tcx>( // branches like `Some(_) | Some(0)`. matrix.push(v); } - usefulness.unsplit_or_pat(i, alt_count, v_head) + usefulness.unsplit_or_pat(v_span, &subspans) }); - Usefulness::merge(witness_preference, usefulnesses) + Usefulness::merge(usefulnesses) } else { let v_ctor = v.head_ctor(cx); if let Constructor::IntRange(ctor_range) = &v_ctor { @@ -1150,7 +993,6 @@ fn is_useful<'p, 'tcx>( // witness the usefulness of `v`. let start_matrix = &matrix; let usefulnesses = split_ctors.into_iter().map(|ctor| { - debug!("specialize({:?})", ctor); // We cache the result of `Fields::wildcards` because it is used a lot. let ctor_wild_subpatterns = Fields::wildcards(pcx, &ctor); let spec_matrix = @@ -1160,9 +1002,9 @@ fn is_useful<'p, 'tcx>( is_useful(cx, &spec_matrix, &v, witness_preference, hir_id, is_under_guard, false); usefulness.apply_constructor(pcx, start_matrix, &ctor, &ctor_wild_subpatterns) }); - Usefulness::merge(witness_preference, usefulnesses) + Usefulness::merge(usefulnesses) }; - debug!(?ret); + debug!("is_useful::returns({:#?}, {:#?}) = {:?}", matrix, v, ret); ret } @@ -1175,21 +1017,10 @@ crate struct MatchArm<'p, 'tcx> { crate has_guard: bool, } -/// Indicates whether or not a given arm is reachable. -#[derive(Clone, Debug)] -crate enum Reachability { - /// The arm is reachable. This additionally carries a set of or-pattern branches that have been - /// found to be unreachable despite the overall arm being reachable. Used only in the presence - /// of or-patterns, otherwise it stays empty. - Reachable(Vec), - /// The arm is unreachable. - Unreachable, -} - /// The output of checking a match for exhaustiveness and arm reachability. crate struct UsefulnessReport<'p, 'tcx> { /// For each arm of the input, whether that arm is reachable after the arms above it. - crate arm_usefulness: Vec<(MatchArm<'p, 'tcx>, Reachability)>, + crate arm_usefulness: Vec<(MatchArm<'p, 'tcx>, Usefulness<'tcx>)>, /// If the match is exhaustive, this is empty. If not, this contains witnesses for the lack of /// exhaustiveness. crate non_exhaustiveness_witnesses: Vec>, @@ -1217,14 +1048,7 @@ crate fn compute_match_usefulness<'p, 'tcx>( if !arm.has_guard { matrix.push(v); } - let reachability = match usefulness { - NoWitnesses(subpats) if subpats.is_empty() => Reachability::Unreachable, - NoWitnesses(subpats) => { - Reachability::Reachable(subpats.list_unreachable_spans().unwrap()) - } - WithWitnesses(..) => bug!(), - }; - (arm, reachability) + (arm, usefulness) }) .collect(); @@ -1232,8 +1056,15 @@ crate fn compute_match_usefulness<'p, 'tcx>( let v = PatStack::from_pattern(wild_pattern); let usefulness = is_useful(cx, &matrix, &v, ConstructWitness, scrut_hir_id, false, true); let non_exhaustiveness_witnesses = match usefulness { - WithWitnesses(pats) => pats.into_iter().map(|w| w.single_pattern()).collect(), - NoWitnesses(_) => bug!(), + NotUseful => vec![], // Wildcard pattern isn't useful, so the match is exhaustive. + UsefulWithWitness(pats) => { + if pats.is_empty() { + bug!("Exhaustiveness check returned no witnesses") + } else { + pats.into_iter().map(|w| w.single_pattern()).collect() + } + } + Useful(_) => bug!(), }; UsefulnessReport { arm_usefulness, non_exhaustiveness_witnesses } } diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index 4a638ec3f8020..b5b34c7338d88 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -14,7 +14,7 @@ mod tokentrees; mod unescape_error_reporting; mod unicode_chars; -use unescape_error_reporting::{emit_unescape_error, escaped_char}; +use unescape_error_reporting::{emit_unescape_error, push_escaped_char}; #[derive(Clone, Debug)] pub struct UnmatchedBrace { @@ -122,9 +122,11 @@ impl<'a> StringReader<'a> { m: &str, c: char, ) -> DiagnosticBuilder<'a> { - self.sess - .span_diagnostic - .struct_span_fatal(self.mk_sp(from_pos, to_pos), &format!("{}: {}", m, escaped_char(c))) + let mut m = m.to_string(); + m.push_str(": "); + push_escaped_char(&mut m, c); + + self.sess.span_diagnostic.struct_span_fatal(self.mk_sp(from_pos, to_pos), &m[..]) } /// Turns simple `rustc_lexer::TokenKind` enum into a rich @@ -419,7 +421,7 @@ impl<'a> StringReader<'a> { let content_start = start + BytePos(prefix_len); let content_end = suffix_start - BytePos(postfix_len); let id = self.symbol_from_to(content_start, content_end); - self.validate_literal_escape(mode, content_start, content_end, prefix_len, postfix_len); + self.validate_literal_escape(mode, content_start, content_end); (lit_kind, id) } @@ -523,29 +525,17 @@ impl<'a> StringReader<'a> { .raise(); } - fn validate_literal_escape( - &self, - mode: Mode, - content_start: BytePos, - content_end: BytePos, - prefix_len: u32, - postfix_len: u32, - ) { + fn validate_literal_escape(&self, mode: Mode, content_start: BytePos, content_end: BytePos) { let lit_content = self.str_from_to(content_start, content_end); unescape::unescape_literal(lit_content, mode, &mut |range, result| { // Here we only check for errors. The actual unescaping is done later. if let Err(err) = result { - let span_with_quotes = self - .mk_sp(content_start - BytePos(prefix_len), content_end + BytePos(postfix_len)); - let (start, end) = (range.start as u32, range.end as u32); - let lo = content_start + BytePos(start); - let hi = lo + BytePos(end - start); - let span = self.mk_sp(lo, hi); + let span_with_quotes = + self.mk_sp(content_start - BytePos(1), content_end + BytePos(1)); emit_unescape_error( &self.sess.span_diagnostic, lit_content, span_with_quotes, - span, mode, range, err, diff --git a/compiler/rustc_parse/src/lexer/unescape_error_reporting.rs b/compiler/rustc_parse/src/lexer/unescape_error_reporting.rs index a580f0c55d0e3..47d317f918865 100644 --- a/compiler/rustc_parse/src/lexer/unescape_error_reporting.rs +++ b/compiler/rustc_parse/src/lexer/unescape_error_reporting.rs @@ -13,8 +13,6 @@ pub(crate) fn emit_unescape_error( lit: &str, // full span of the literal, including quotes span_with_quotes: Span, - // interior span of the literal, without quotes - span: Span, mode: Mode, // range of the error inside `lit` range: Range, @@ -28,6 +26,13 @@ pub(crate) fn emit_unescape_error( range, error ); + let span = { + let Range { start, end } = range; + let (start, end) = (start as u32, end as u32); + let lo = span_with_quotes.lo() + BytePos(start + 1); + let hi = lo + BytePos(end - start); + span_with_quotes.with_lo(lo).with_hi(hi) + }; let last_char = || { let c = lit[range.clone()].chars().rev().next().unwrap(); let span = span.with_lo(span.hi() - BytePos(c.len_utf8() as u32)); @@ -37,22 +42,20 @@ pub(crate) fn emit_unescape_error( EscapeError::LoneSurrogateUnicodeEscape => { handler .struct_span_err(span, "invalid unicode character escape") - .span_label(span, "invalid escape") .help("unicode escape must not be a surrogate") .emit(); } EscapeError::OutOfRangeUnicodeEscape => { handler .struct_span_err(span, "invalid unicode character escape") - .span_label(span, "invalid escape") .help("unicode escape must be at most 10FFFF") .emit(); } EscapeError::MoreThanOneChar => { - let (prefix, msg) = if mode.is_bytes() { - ("b", "if you meant to write a byte string literal, use double quotes") + let msg = if mode.is_bytes() { + "if you meant to write a byte string literal, use double quotes" } else { - ("", "if you meant to write a `str` literal, use double quotes") + "if you meant to write a `str` literal, use double quotes" }; handler @@ -63,44 +66,31 @@ pub(crate) fn emit_unescape_error( .span_suggestion( span_with_quotes, msg, - format!("{}\"{}\"", prefix, lit), + format!("\"{}\"", lit), Applicability::MachineApplicable, ) .emit(); } EscapeError::EscapeOnlyChar => { - let (c, char_span) = last_char(); + let (c, _span) = last_char(); - let msg = if mode.is_bytes() { - "byte constant must be escaped" + let mut msg = if mode.is_bytes() { + "byte constant must be escaped: " } else { - "character constant must be escaped" - }; - handler - .struct_span_err(span, &format!("{}: `{}`", msg, escaped_char(c))) - .span_suggestion( - char_span, - "escape the character", - c.escape_default().to_string(), - Applicability::MachineApplicable, - ) - .emit() + "character constant must be escaped: " + } + .to_string(); + push_escaped_char(&mut msg, c); + + handler.span_err(span, msg.as_str()) } EscapeError::BareCarriageReturn => { let msg = if mode.in_double_quotes() { - "bare CR not allowed in string, use `\\r` instead" + "bare CR not allowed in string, use \\r instead" } else { - "character constant must be escaped: `\\r`" + "character constant must be escaped: \\r" }; - handler - .struct_span_err(span, msg) - .span_suggestion( - span, - "escape the character", - "\\r".to_string(), - Applicability::MachineApplicable, - ) - .emit(); + handler.span_err(span, msg); } EscapeError::BareCarriageReturnInRawString => { assert!(mode.in_double_quotes()); @@ -112,22 +102,21 @@ pub(crate) fn emit_unescape_error( let label = if mode.is_bytes() { "unknown byte escape" } else { "unknown character escape" }; - let ec = escaped_char(c); - let mut diag = handler.struct_span_err(span, &format!("{}: `{}`", label, ec)); + let mut msg = label.to_string(); + msg.push_str(": "); + push_escaped_char(&mut msg, c); + + let mut diag = handler.struct_span_err(span, msg.as_str()); diag.span_label(span, label); if c == '{' || c == '}' && !mode.is_bytes() { diag.help( - "if used in a formatting string, curly braces are escaped with `{{` and `}}`", + "if used in a formatting string, \ + curly braces are escaped with `{{` and `}}`", ); } else if c == '\r' { diag.help( - "this is an isolated carriage return; consider checking your editor and \ - version control settings", - ); - } else { - diag.help( - "for more information, visit \ - ", + "this is an isolated carriage return; \ + consider checking your editor and version control settings", ); } diag.emit(); @@ -138,70 +127,45 @@ pub(crate) fn emit_unescape_error( EscapeError::InvalidCharInHexEscape | EscapeError::InvalidCharInUnicodeEscape => { let (c, span) = last_char(); - let msg = if error == EscapeError::InvalidCharInHexEscape { - "invalid character in numeric character escape" + let mut msg = if error == EscapeError::InvalidCharInHexEscape { + "invalid character in numeric character escape: " } else { - "invalid character in unicode escape" - }; - let c = escaped_char(c); + "invalid character in unicode escape: " + } + .to_string(); + push_escaped_char(&mut msg, c); - handler - .struct_span_err(span, &format!("{}: `{}`", msg, c)) - .span_label(span, msg) - .emit(); + handler.span_err(span, msg.as_str()) } EscapeError::NonAsciiCharInByte => { assert!(mode.is_bytes()); - let (c, span) = last_char(); - handler - .struct_span_err(span, "non-ASCII character in byte constant") - .span_label(span, "byte constant must be ASCII") - .span_suggestion( - span, - "use a \\xHH escape for a non-ASCII byte", - format!("\\x{:X}", c as u32), - Applicability::MachineApplicable, - ) - .emit(); + let (_c, span) = last_char(); + handler.span_err( + span, + "byte constant must be ASCII. \ + Use a \\xHH escape for a non-ASCII byte", + ) } EscapeError::NonAsciiCharInByteString => { assert!(mode.is_bytes()); let (_c, span) = last_char(); - handler - .struct_span_err(span, "raw byte string must be ASCII") - .span_label(span, "must be ASCII") - .emit(); - } - EscapeError::OutOfRangeHexEscape => { - handler - .struct_span_err(span, "out of range hex escape") - .span_label(span, "must be a character in the range [\\x00-\\x7f]") - .emit(); + handler.span_err(span, "raw byte string must be ASCII") } + EscapeError::OutOfRangeHexEscape => handler.span_err( + span, + "this form of character escape may only be used \ + with characters in the range [\\x00-\\x7f]", + ), EscapeError::LeadingUnderscoreUnicodeEscape => { - let (c, span) = last_char(); - let msg = "invalid start of unicode escape"; - handler - .struct_span_err(span, &format!("{}: `{}`", msg, c)) - .span_label(span, msg) - .emit(); + let (_c, span) = last_char(); + handler.span_err(span, "invalid start of unicode escape") } EscapeError::OverlongUnicodeEscape => { - handler - .struct_span_err(span, "overlong unicode escape") - .span_label(span, "must have at most 6 hex digits") - .emit(); + handler.span_err(span, "overlong unicode escape (must have at most 6 hex digits)") + } + EscapeError::UnclosedUnicodeEscape => { + handler.span_err(span, "unterminated unicode escape (needed a `}`)") } - EscapeError::UnclosedUnicodeEscape => handler - .struct_span_err(span, "unterminated unicode escape") - .span_label(span, "missing a closing `}`") - .span_suggestion_verbose( - span.shrink_to_hi(), - "terminate the unicode escape", - "}".to_string(), - Applicability::MaybeIncorrect, - ) - .emit(), EscapeError::NoBraceInUnicodeEscape => { let msg = "incorrect unicode escape sequence"; let mut diag = handler.struct_span_err(span, msg); @@ -231,38 +195,28 @@ pub(crate) fn emit_unescape_error( diag.emit(); } - EscapeError::UnicodeEscapeInByte => { - let msg = "unicode escape in byte string"; - handler - .struct_span_err(span, msg) - .span_label(span, msg) - .help("unicode escape sequences cannot be used as a byte or in a byte string") - .emit(); - } + EscapeError::UnicodeEscapeInByte => handler.span_err( + span, + "unicode escape sequences cannot be used \ + as a byte or in a byte string", + ), EscapeError::EmptyUnicodeEscape => { - handler - .struct_span_err(span, "empty unicode escape") - .span_label(span, "this escape must have at least 1 hex digit") - .emit(); - } - EscapeError::ZeroChars => { - let msg = "empty character literal"; - handler.struct_span_err(span, msg).span_label(span, msg).emit() - } - EscapeError::LoneSlash => { - let msg = "invalid trailing slash in literal"; - handler.struct_span_err(span, msg).span_label(span, msg).emit(); + handler.span_err(span, "empty unicode escape (must have at least 1 hex digit)") } + EscapeError::ZeroChars => handler.span_err(span, "empty character literal"), + EscapeError::LoneSlash => handler.span_err(span, "invalid trailing slash in literal"), } } /// Pushes a character to a message string for error reporting -pub(crate) fn escaped_char(c: char) -> String { +pub(crate) fn push_escaped_char(msg: &mut String, c: char) { match c { '\u{20}'..='\u{7e}' => { // Don't escape \, ' or " for user-facing messages - c.to_string() + msg.push(c); + } + _ => { + msg.extend(c.escape_default()); } - _ => c.escape_default().to_string(), } } diff --git a/compiler/rustc_parse/src/lib.rs b/compiler/rustc_parse/src/lib.rs index f155f3a94e56f..c365acac625a4 100644 --- a/compiler/rustc_parse/src/lib.rs +++ b/compiler/rustc_parse/src/lib.rs @@ -4,8 +4,6 @@ #![feature(bindings_after_at)] #![feature(iter_order_by)] #![feature(or_patterns)] -#![feature(box_syntax)] -#![feature(box_patterns)] use rustc_ast as ast; use rustc_ast::attr::HasAttrs; diff --git a/compiler/rustc_parse/src/parser/attr.rs b/compiler/rustc_parse/src/parser/attr.rs index 523eb9dba35fd..1b26fb3337043 100644 --- a/compiler/rustc_parse/src/parser/attr.rs +++ b/compiler/rustc_parse/src/parser/attr.rs @@ -306,11 +306,13 @@ impl<'a> Parser<'a> { } pub fn maybe_needs_tokens(attrs: &[ast::Attribute]) -> bool { - // One of the attributes may either itself be a macro, + // One of the attributes may either itself be a macro, or apply derive macros (`derive`), // or expand to macro attributes (`cfg_attr`). attrs.iter().any(|attr| { attr.ident().map_or(true, |ident| { - ident.name == sym::cfg_attr || !rustc_feature::is_builtin_attr_name(ident.name) + ident.name == sym::derive + || ident.name == sym::cfg_attr + || !rustc_feature::is_builtin_attr_name(ident.name) }) }) } diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs index 5512e849c451d..f2fcce5c22662 100644 --- a/compiler/rustc_parse/src/parser/diagnostics.rs +++ b/compiler/rustc_parse/src/parser/diagnostics.rs @@ -1104,7 +1104,7 @@ impl<'a> Parser<'a> { let (prev_sp, sp) = match (&self.token.kind, self.subparser_name) { // Point at the end of the macro call when reaching end of macro arguments. (token::Eof, Some(_)) => { - let sp = self.sess.source_map().next_point(self.prev_token.span); + let sp = self.sess.source_map().next_point(self.token.span); (sp, sp) } // We don't want to point at the following span after DUMMY_SP. @@ -1721,7 +1721,7 @@ impl<'a> Parser<'a> { pub(super) fn expected_expression_found(&self) -> DiagnosticBuilder<'a> { let (span, msg) = match (&self.token.kind, self.subparser_name) { (&token::Eof, Some(origin)) => { - let sp = self.sess.source_map().next_point(self.prev_token.span); + let sp = self.sess.source_map().next_point(self.token.span); (sp, format!("expected expression, found end of {}", origin)) } _ => ( diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index ee24286241468..1ed4d39cd0539 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -4,11 +4,11 @@ use super::{FollowedByType, ForceCollect, Parser, PathStyle, TrailingToken}; use crate::{maybe_collect_tokens, maybe_whole}; -use rustc_ast::ast::*; use rustc_ast::ptr::P; use rustc_ast::token::{self, TokenKind}; use rustc_ast::tokenstream::{DelimSpan, TokenStream, TokenTree}; use rustc_ast::{self as ast, AttrVec, Attribute, DUMMY_NODE_ID}; +use rustc_ast::{AssocItem, AssocItemKind, ForeignItemKind, Item, ItemKind, Mod}; use rustc_ast::{Async, Const, Defaultness, IsAuto, Mutability, Unsafe, UseTree, UseTreeKind}; use rustc_ast::{BindingMode, Block, FnDecl, FnSig, Param, SelfKind}; use rustc_ast::{EnumDef, Generics, StructField, TraitRef, Ty, TyKind, Variant, VariantData}; @@ -229,7 +229,7 @@ impl<'a> Parser<'a> { } else if self.check_fn_front_matter() { // FUNCTION ITEM let (ident, sig, generics, body) = self.parse_fn(attrs, req_name, lo)?; - (ident, ItemKind::Fn(box FnKind(def(), sig, generics, body))) + (ident, ItemKind::Fn(def(), sig, generics, body)) } else if self.eat_keyword(kw::Extern) { if self.eat_keyword(kw::Crate) { // EXTERN CRATE @@ -556,7 +556,7 @@ impl<'a> Parser<'a> { }; let trait_ref = TraitRef { path, ref_id: ty_first.id }; - ItemKind::Impl(box ImplKind { + ItemKind::Impl { unsafety, polarity, defaultness, @@ -565,11 +565,11 @@ impl<'a> Parser<'a> { of_trait: Some(trait_ref), self_ty: ty_second, items: impl_items, - }) + } } None => { // impl Type - ItemKind::Impl(box ImplKind { + ItemKind::Impl { unsafety, polarity, defaultness, @@ -578,7 +578,7 @@ impl<'a> Parser<'a> { of_trait: None, self_ty: ty_first, items: impl_items, - }) + } } }; @@ -718,7 +718,7 @@ impl<'a> Parser<'a> { // It's a normal trait. tps.where_clause = self.parse_where_clause()?; let items = self.parse_item_list(attrs, |p| p.parse_trait_item())?; - Ok((ident, ItemKind::Trait(box TraitKind(is_auto, unsafety, tps, bounds, items)))) + Ok((ident, ItemKind::Trait(is_auto, unsafety, tps, bounds, items))) } } @@ -767,7 +767,7 @@ impl<'a> Parser<'a> { let default = if self.eat(&token::Eq) { Some(self.parse_ty()?) } else { None }; self.expect_semi()?; - Ok((ident, ItemKind::TyAlias(box TyAliasKind(def, generics, bounds, default)))) + Ok((ident, ItemKind::TyAlias(def, generics, bounds, default))) } /// Parses a `UseTree`. @@ -1010,21 +1010,10 @@ impl<'a> Parser<'a> { ) -> PResult<'a, ItemInfo> { let impl_span = self.token.span; let mut err = self.expected_ident_found(); - - // Only try to recover if this is implementing a trait for a type - let mut impl_info = match self.parse_item_impl(attrs, defaultness) { - Ok(impl_info) => impl_info, - Err(mut recovery_error) => { - // Recovery failed, raise the "expected identifier" error - recovery_error.cancel(); - return Err(err); - } - }; - + let mut impl_info = self.parse_item_impl(attrs, defaultness)?; match impl_info.1 { - ItemKind::Impl(box ImplKind { - of_trait: Some(ref trai), ref mut constness, .. - }) => { + // only try to recover if this is implementing a trait for a type + ItemKind::Impl { of_trait: Some(ref trai), ref mut constness, .. } => { *constness = Const::Yes(const_span); let before_trait = trai.path.span.shrink_to_lo(); @@ -1039,7 +1028,6 @@ impl<'a> Parser<'a> { ItemKind::Impl { .. } => return Err(err), _ => unreachable!(), } - Ok(impl_info) } diff --git a/compiler/rustc_parse/src/parser/nonterminal.rs b/compiler/rustc_parse/src/parser/nonterminal.rs index 6e25209f0905e..012b76d3d1887 100644 --- a/compiler/rustc_parse/src/parser/nonterminal.rs +++ b/compiler/rustc_parse/src/parser/nonterminal.rs @@ -41,16 +41,13 @@ impl<'a> Parser<'a> { }, NonterminalKind::Block => match token.kind { token::OpenDelim(token::Brace) => true, - token::Interpolated(ref nt) => !matches!( - **nt, - token::NtItem(_) - | token::NtPat(_) - | token::NtTy(_) - | token::NtIdent(..) - | token::NtMeta(_) - | token::NtPath(_) - | token::NtVis(_) - ), + token::Interpolated(ref nt) => !matches!(**nt, token::NtItem(_) + | token::NtPat(_) + | token::NtTy(_) + | token::NtIdent(..) + | token::NtMeta(_) + | token::NtPath(_) + | token::NtVis(_)), _ => false, }, NonterminalKind::Path | NonterminalKind::Meta => match token.kind { diff --git a/compiler/rustc_parse_format/src/lib.rs b/compiler/rustc_parse_format/src/lib.rs index 92d974690b514..f150f7a41ae80 100644 --- a/compiler/rustc_parse_format/src/lib.rs +++ b/compiler/rustc_parse_format/src/lib.rs @@ -730,7 +730,7 @@ fn find_skips_from_snippet( str_style: Option, ) -> (Vec, bool) { let snippet = match snippet { - Some(ref s) if s.starts_with('"') || s.starts_with("r\"") || s.starts_with("r#") => s, + Some(ref s) if s.starts_with('"') || s.starts_with("r#") => s, _ => return (vec![], false), }; diff --git a/compiler/rustc_passes/src/stability.rs b/compiler/rustc_passes/src/stability.rs index e1d03e3504800..b70cec25dfb5a 100644 --- a/compiler/rustc_passes/src/stability.rs +++ b/compiler/rustc_passes/src/stability.rs @@ -553,8 +553,7 @@ impl<'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'tcx> { // optional. They inherit stability from their parents when unannotated. if !matches!( i.kind, - hir::ItemKind::Impl(hir::Impl { of_trait: None, .. }) - | hir::ItemKind::ForeignMod { .. } + hir::ItemKind::Impl(hir::Impl { of_trait: None, .. }) | hir::ItemKind::ForeignMod { .. } ) { self.check_missing_stability(i.hir_id, i.span); } diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index 631dcb60594f1..3fade2c443726 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -132,7 +132,7 @@ where tcx: TyCtxt<'tcx>, ct: AbstractConst<'tcx>, ) -> ControlFlow { - const_evaluatable::walk_abstract_const(tcx, ct, |node| match node.root() { + const_evaluatable::walk_abstract_const(tcx, ct, |node| match node { ACNode::Leaf(leaf) => { let leaf = leaf.subst(tcx, ct.substs); self.visit_const(leaf) diff --git a/compiler/rustc_query_system/src/query/config.rs b/compiler/rustc_query_system/src/query/config.rs index 94e906fc433d5..0f0684b354791 100644 --- a/compiler/rustc_query_system/src/query/config.rs +++ b/compiler/rustc_query_system/src/query/config.rs @@ -7,6 +7,7 @@ use crate::query::plumbing::CycleError; use crate::query::{QueryContext, QueryState}; use rustc_data_structures::fingerprint::Fingerprint; +use std::borrow::Cow; use std::fmt::Debug; use std::hash::Hash; @@ -94,7 +95,7 @@ pub trait QueryAccessors: QueryConfig { } pub trait QueryDescription: QueryAccessors { - fn describe(tcx: CTX, key: Self::Key) -> String; + fn describe(tcx: CTX, key: Self::Key) -> Cow<'static, str>; #[inline] fn cache_on_disk(_: CTX, _: &Self::Key, _: Option<&Self::Value>) -> bool { diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index c4ee4df212863..4ab14c158d337 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -16,8 +16,8 @@ use crate::{ use crate::{Module, ModuleData, ModuleKind, NameBinding, NameBindingKind, Segment, ToNameBinding}; use rustc_ast::visit::{self, AssocCtxt, Visitor}; -use rustc_ast::{self as ast, AssocItem, AssocItemKind, MetaItemKind, StmtKind}; -use rustc_ast::{Block, FnKind, ForeignItem, ForeignItemKind, ImplKind, Item, ItemKind, NodeId}; +use rustc_ast::{self as ast, Block, ForeignItem, ForeignItemKind, Item, ItemKind, NodeId}; +use rustc_ast::{AssocItem, AssocItemKind, MetaItemKind, StmtKind}; use rustc_ast_lowering::ResolverAstLowering; use rustc_attr as attr; use rustc_data_structures::sync::Lrc; @@ -887,7 +887,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { } // These items do not add names to modules. - ItemKind::Impl(box ImplKind { of_trait: Some(..), .. }) => { + ItemKind::Impl { of_trait: Some(..), .. } => { self.r.trait_impl_items.insert(local_def_id); } ItemKind::Impl { .. } | ItemKind::ForeignMod(..) | ItemKind::GlobalAsm(..) => {} @@ -1371,7 +1371,7 @@ impl<'a, 'b> Visitor<'b> for BuildReducedGraphVisitor<'a, 'b> { AssocCtxt::Trait => { let (def_kind, ns) = match item.kind { AssocItemKind::Const(..) => (DefKind::AssocConst, ValueNS), - AssocItemKind::Fn(box FnKind(_, ref sig, _, _)) => { + AssocItemKind::Fn(_, ref sig, _, _) => { if sig.decl.has_self() { self.r.has_self.insert(def_id); } diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 7493fd68505fe..9d55bafd2868e 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -9,7 +9,6 @@ use rustc_feature::BUILTIN_ATTRIBUTES; use rustc_hir::def::Namespace::{self, *}; use rustc_hir::def::{self, CtorKind, CtorOf, DefKind, NonMacroAttrKind}; use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; -use rustc_hir::PrimTy; use rustc_middle::bug; use rustc_middle::ty::{self, DefIdTree}; use rustc_session::Session; @@ -719,9 +718,10 @@ impl<'a> Resolver<'a> { } } Scope::BuiltinTypes => { - suggestions.extend(PrimTy::ALL.iter().filter_map(|prim_ty| { + let primitive_types = &this.primitive_type_table.primitive_types; + suggestions.extend(primitive_types.iter().flat_map(|(name, prim_ty)| { let res = Res::PrimTy(*prim_ty); - filter_fn(res).then_some(TypoSuggestion::from_res(prim_ty.name(), res)) + filter_fn(res).then_some(TypoSuggestion::from_res(*name, res)) })) } } @@ -1111,9 +1111,10 @@ impl<'a> Resolver<'a> { _, ) = binding.kind { - let def_id = self.parent(ctor_def_id).expect("no parent for a constructor"); + let def_id = (&*self).parent(ctor_def_id).expect("no parent for a constructor"); let fields = self.field_names.get(&def_id)?; - return fields.iter().map(|name| name.span).reduce(Span::to); // None for `struct Foo()` + let first_field = fields.first()?; // Handle `struct Foo()` + return Some(fields.iter().fold(first_field.span, |acc, field| acc.to(field.span))); } None } diff --git a/compiler/rustc_resolve/src/late.rs b/compiler/rustc_resolve/src/late.rs index cca40a793dd00..eaeb28388d4f0 100644 --- a/compiler/rustc_resolve/src/late.rs +++ b/compiler/rustc_resolve/src/late.rs @@ -20,7 +20,7 @@ use rustc_errors::DiagnosticId; use rustc_hir::def::Namespace::{self, *}; use rustc_hir::def::{self, CtorKind, DefKind, PartialRes, PerNS}; use rustc_hir::def_id::{DefId, CRATE_DEF_INDEX}; -use rustc_hir::{PrimTy, TraitCandidate}; +use rustc_hir::TraitCandidate; use rustc_middle::{bug, span_bug}; use rustc_session::lint; use rustc_span::symbol::{kw, sym, Ident, Symbol}; @@ -493,8 +493,8 @@ impl<'a: 'ast, 'ast> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast> { } fn visit_foreign_item(&mut self, foreign_item: &'ast ForeignItem) { match foreign_item.kind { - ForeignItemKind::Fn(box FnKind(_, _, ref generics, _)) - | ForeignItemKind::TyAlias(box TyAliasKind(_, ref generics, ..)) => { + ForeignItemKind::Fn(_, _, ref generics, _) + | ForeignItemKind::TyAlias(_, ref generics, ..) => { self.with_generic_param_rib(generics, ItemRibKind(HasGenericParams::Yes), |this| { visit::walk_foreign_item(this, foreign_item); }); @@ -938,8 +938,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { debug!("(resolving item) resolving {} ({:?})", name, item.kind); match item.kind { - ItemKind::TyAlias(box TyAliasKind(_, ref generics, _, _)) - | ItemKind::Fn(box FnKind(_, _, ref generics, _)) => { + ItemKind::TyAlias(_, ref generics, _, _) | ItemKind::Fn(_, _, ref generics, _) => { self.with_generic_param_rib(generics, ItemRibKind(HasGenericParams::Yes), |this| { visit::walk_item(this, item) }); @@ -951,17 +950,17 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { self.resolve_adt(item, generics); } - ItemKind::Impl(box ImplKind { + ItemKind::Impl { ref generics, ref of_trait, ref self_ty, items: ref impl_items, .. - }) => { + } => { self.resolve_implementation(generics, of_trait, &self_ty, item.id, impl_items); } - ItemKind::Trait(box TraitKind(.., ref generics, ref bounds, ref trait_items)) => { + ItemKind::Trait(.., ref generics, ref bounds, ref trait_items) => { // Create a new rib for the trait-wide type parameters. self.with_generic_param_rib(generics, ItemRibKind(HasGenericParams::Yes), |this| { let local_def_id = this.r.local_def_id(item.id).to_def_id(); @@ -996,10 +995,10 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { ); } } - AssocItemKind::Fn(box FnKind(_, _, generics, _)) => { + AssocItemKind::Fn(_, _, generics, _) => { walk_assoc_item(this, generics, item); } - AssocItemKind::TyAlias(box TyAliasKind(_, generics, _, _)) => { + AssocItemKind::TyAlias(_, generics, _, _) => { walk_assoc_item(this, generics, item); } AssocItemKind::MacCall(_) => { @@ -1307,7 +1306,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { }, ); } - AssocItemKind::Fn(box FnKind(.., generics, _)) => { + AssocItemKind::Fn(_, _, generics, _) => { // We also need a new scope for the impl item type parameters. this.with_generic_param_rib( generics, @@ -1330,12 +1329,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { }, ); } - AssocItemKind::TyAlias(box TyAliasKind( - _, - generics, - _, - _, - )) => { + AssocItemKind::TyAlias(_, generics, _, _) => { // We also need a new scope for the impl item type parameters. this.with_generic_param_rib( generics, @@ -1927,7 +1921,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { self.r.trait_map.insert(id, traits); } - if PrimTy::from_name(path[0].ident.name).is_some() { + if self.r.primitive_type_table.primitive_types.contains_key(&path[0].ident.name) { let mut std_path = Vec::with_capacity(1 + path.len()); std_path.push(Segment::from_ident(Ident::with_dummy_span(sym::std))); @@ -2121,9 +2115,13 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> { // The same fallback is used when `a` resolves to nothing. PathResult::Module(ModuleOrUniformRoot::Module(_)) | PathResult::Failed { .. } if (ns == TypeNS || path.len() > 1) - && PrimTy::from_name(path[0].ident.name).is_some() => + && self + .r + .primitive_type_table + .primitive_types + .contains_key(&path[0].ident.name) => { - let prim = PrimTy::from_name(path[0].ident.name).unwrap(); + let prim = self.r.primitive_type_table.primitive_types[&path[0].ident.name]; PartialRes::with_unresolved_segments(Res::PrimTy(prim), path.len() - 1) } PathResult::Module(ModuleOrUniformRoot::Module(module)) => { diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index d2a693a568828..bed7a350ea86d 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -1109,9 +1109,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { if assoc_item.ident == ident { return Some(match &assoc_item.kind { ast::AssocItemKind::Const(..) => AssocSuggestion::AssocConst, - ast::AssocItemKind::Fn(box ast::FnKind(_, sig, ..)) - if sig.decl.has_self() => - { + ast::AssocItemKind::Fn(_, sig, ..) if sig.decl.has_self() => { AssocSuggestion::MethodWithSelf } ast::AssocItemKind::Fn(..) => AssocSuggestion::AssocFn, @@ -1212,8 +1210,8 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { // Add primitive types to the mix if filter_fn(Res::PrimTy(PrimTy::Bool)) { names.extend( - PrimTy::ALL.iter().map(|prim_ty| { - TypoSuggestion::from_res(prim_ty.name(), Res::PrimTy(*prim_ty)) + self.r.primitive_type_table.primitive_types.iter().map(|(name, prim_ty)| { + TypoSuggestion::from_res(*name, Res::PrimTy(*prim_ty)) }), ) } @@ -1661,15 +1659,12 @@ impl<'tcx> LifetimeContext<'_, 'tcx> { match missing { MissingLifetimeSpot::Generics(generics) => { let (span, sugg) = if let Some(param) = generics.params.iter().find(|p| { - !matches!( - p.kind, - hir::GenericParamKind::Type { - synthetic: Some(hir::SyntheticTyParamKind::ImplTrait), - .. - } | hir::GenericParamKind::Lifetime { - kind: hir::LifetimeParamKind::Elided, - } - ) + !matches!(p.kind, hir::GenericParamKind::Type { + synthetic: Some(hir::SyntheticTyParamKind::ImplTrait), + .. + } | hir::GenericParamKind::Lifetime { + kind: hir::LifetimeParamKind::Elided, + }) }) { (param.span.shrink_to_lo(), format!("{}, ", lifetime_ref)) } else { @@ -1849,13 +1844,10 @@ impl<'tcx> LifetimeContext<'_, 'tcx> { msg = "consider introducing a named lifetime parameter".to_string(); should_break = true; if let Some(param) = generics.params.iter().find(|p| { - !matches!( - p.kind, - hir::GenericParamKind::Type { - synthetic: Some(hir::SyntheticTyParamKind::ImplTrait), - .. - } - ) + !matches!(p.kind, hir::GenericParamKind::Type { + synthetic: Some(hir::SyntheticTyParamKind::ImplTrait), + .. + }) }) { (param.span.shrink_to_lo(), "'a, ".to_string()) } else { diff --git a/compiler/rustc_resolve/src/late/lifetimes.rs b/compiler/rustc_resolve/src/late/lifetimes.rs index 0bab33976b29d..95ac2a31dd321 100644 --- a/compiler/rustc_resolve/src/late/lifetimes.rs +++ b/compiler/rustc_resolve/src/late/lifetimes.rs @@ -2083,11 +2083,18 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { output: Option<&'tcx hir::Ty<'tcx>>, ) { debug!("visit_fn_like_elision: enter"); - let arg_scope = Scope::Elision { elide: Elide::FreshLateAnon(Cell::new(0)), s: self.scope }; + let mut arg_elide = Elide::FreshLateAnon(Cell::new(0)); + let arg_scope = Scope::Elision { elide: arg_elide.clone(), s: self.scope }; self.with(arg_scope, |_, this| { for input in inputs { this.visit_ty(input); } + match *this.scope { + Scope::Elision { ref elide, .. } => { + arg_elide = elide.clone(); + } + _ => bug!(), + } }); let output = match output { @@ -2415,7 +2422,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { _ => break, } } - break Some(&e[..]); + break Some(e); } Elide::Forbid => break None, }; @@ -2445,7 +2452,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { lifetime_refs.len(), &lifetime_names, lifetime_spans, - error.unwrap_or(&[]), + error.map(|p| &p[..]).unwrap_or(&[]), ); err.emit(); } diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 819fabdd1f177..2b4a1d9e3fa0a 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -9,7 +9,6 @@ //! Type-relative name resolution (methods, fields, associated items) happens in `librustc_typeck`. #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] -#![feature(box_patterns)] #![feature(bool_to_option)] #![feature(crate_visibility_modifier)] #![feature(format_args_capture)] @@ -25,7 +24,7 @@ use rustc_arena::{DroplessArena, TypedArena}; use rustc_ast::node_id::NodeMap; use rustc_ast::unwrap_or; use rustc_ast::visit::{self, Visitor}; -use rustc_ast::{self as ast, NodeId}; +use rustc_ast::{self as ast, FloatTy, IntTy, NodeId, UintTy}; use rustc_ast::{Crate, CRATE_NODE_ID}; use rustc_ast::{ItemKind, Path}; use rustc_ast_lowering::ResolverAstLowering; @@ -39,7 +38,8 @@ use rustc_hir::def::Namespace::*; use rustc_hir::def::{self, CtorOf, DefKind, NonMacroAttrKind, PartialRes}; use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, CRATE_DEF_INDEX}; use rustc_hir::definitions::{DefKey, DefPathData, Definitions}; -use rustc_hir::{PrimTy, TraitCandidate}; +use rustc_hir::PrimTy::{self, Bool, Char, Float, Int, Str, Uint}; +use rustc_hir::TraitCandidate; use rustc_index::vec::IndexVec; use rustc_metadata::creader::{CStore, CrateLoader}; use rustc_middle::hir::exports::ExportMap; @@ -833,6 +833,39 @@ impl<'a> NameBinding<'a> { } } +/// Interns the names of the primitive types. +/// +/// All other types are defined somewhere and possibly imported, but the primitive ones need +/// special handling, since they have no place of origin. +struct PrimitiveTypeTable { + primitive_types: FxHashMap, +} + +impl PrimitiveTypeTable { + fn new() -> PrimitiveTypeTable { + let mut table = FxHashMap::default(); + + table.insert(sym::bool, Bool); + table.insert(sym::char, Char); + table.insert(sym::f32, Float(FloatTy::F32)); + table.insert(sym::f64, Float(FloatTy::F64)); + table.insert(sym::isize, Int(IntTy::Isize)); + table.insert(sym::i8, Int(IntTy::I8)); + table.insert(sym::i16, Int(IntTy::I16)); + table.insert(sym::i32, Int(IntTy::I32)); + table.insert(sym::i64, Int(IntTy::I64)); + table.insert(sym::i128, Int(IntTy::I128)); + table.insert(sym::str, Str); + table.insert(sym::usize, Uint(UintTy::Usize)); + table.insert(sym::u8, Uint(UintTy::U8)); + table.insert(sym::u16, Uint(UintTy::U16)); + table.insert(sym::u32, Uint(UintTy::U32)); + table.insert(sym::u64, Uint(UintTy::U64)); + table.insert(sym::u128, Uint(UintTy::U128)); + Self { primitive_types: table } + } +} + #[derive(Debug, Default, Clone)] pub struct ExternPreludeEntry<'a> { extern_crate_item: Option<&'a NameBinding<'a>>, @@ -878,6 +911,9 @@ pub struct Resolver<'a> { /// "self-confirming" import resolutions during import validation. unusable_binding: Option<&'a NameBinding<'a>>, + /// The idents for the primitive types. + primitive_type_table: PrimitiveTypeTable, + /// Resolutions for nodes that have a single resolution. partial_res_map: NodeMap, /// Resolutions for import nodes, which have multiple resolutions in different namespaces. @@ -967,8 +1003,6 @@ pub struct Resolver<'a> { output_macro_rules_scopes: FxHashMap>, /// Helper attributes that are in scope for the given expansion. helper_attrs: FxHashMap>, - /// Resolutions for paths inside the `#[derive(...)]` attribute with the given `ExpnId`. - derive_resolutions: FxHashMap, ast::Path)>>, /// Avoid duplicated errors for "name already defined". name_already_seen: FxHashMap, @@ -1249,6 +1283,8 @@ impl<'a> Resolver<'a> { last_import_segment: false, unusable_binding: None, + primitive_type_table: PrimitiveTypeTable::new(), + partial_res_map: Default::default(), import_res_map: Default::default(), label_res_map: Default::default(), @@ -1297,7 +1333,6 @@ impl<'a> Resolver<'a> { invocation_parent_scopes: Default::default(), output_macro_rules_scopes: Default::default(), helper_attrs: Default::default(), - derive_resolutions: Default::default(), local_macro_def_scopes: FxHashMap::default(), name_already_seen: FxHashMap::default(), potentially_unused_imports: Vec::new(), @@ -1958,9 +1993,9 @@ impl<'a> Resolver<'a> { } if ns == TypeNS { - if let Some(prim_ty) = PrimTy::from_name(ident.name) { + if let Some(prim_ty) = self.primitive_type_table.primitive_types.get(&ident.name) { let binding = - (Res::PrimTy(prim_ty), ty::Visibility::Public, DUMMY_SP, ExpnId::root()) + (Res::PrimTy(*prim_ty), ty::Visibility::Public, DUMMY_SP, ExpnId::root()) .to_name_binding(self.arenas); return Some(LexicalScopeBinding::Item(binding)); } diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs index f7010ca94bd2c..d0adee2429d9a 100644 --- a/compiler/rustc_resolve/src/macros.rs +++ b/compiler/rustc_resolve/src/macros.rs @@ -14,17 +14,16 @@ use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::ptr_key::PtrKey; use rustc_data_structures::sync::Lrc; use rustc_errors::struct_span_err; -use rustc_expand::base::{Indeterminate, ResolverExpand, SyntaxExtension, SyntaxExtensionKind}; +use rustc_expand::base::{Indeterminate, InvocationRes, ResolverExpand}; +use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind}; use rustc_expand::compile_declarative_macro; use rustc_expand::expand::{AstFragment, Invocation, InvocationKind}; use rustc_feature::is_builtin_attr_name; use rustc_hir::def::{self, DefKind, NonMacroAttrKind}; use rustc_hir::def_id; -use rustc_hir::PrimTy; use rustc_middle::middle::stability; use rustc_middle::ty; -use rustc_session::lint::builtin::{LEGACY_DERIVE_HELPERS, SOFT_UNSTABLE, UNUSED_MACROS}; -use rustc_session::lint::BuiltinLintDiagnostics; +use rustc_session::lint::builtin::{SOFT_UNSTABLE, UNUSED_MACROS}; use rustc_session::parse::feature_err; use rustc_session::Session; use rustc_span::edition::Edition; @@ -227,7 +226,7 @@ impl<'a> ResolverExpand for Resolver<'a> { invoc: &Invocation, eager_expansion_root: ExpnId, force: bool, - ) -> Result, Indeterminate> { + ) -> Result { let invoc_id = invoc.expansion_data.id; let parent_scope = match self.invocation_parent_scopes.get(&invoc_id) { Some(parent_scope) => *parent_scope, @@ -244,15 +243,65 @@ impl<'a> ResolverExpand for Resolver<'a> { } }; - let (path, kind, inner_attr, derives) = match invoc.kind { - InvocationKind::Attr { ref attr, ref derives, .. } => ( + let (path, kind, inner_attr, derives, after_derive) = match invoc.kind { + InvocationKind::Attr { ref attr, ref derives, after_derive, .. } => ( &attr.get_normal_item().path, MacroKind::Attr, attr.style == ast::AttrStyle::Inner, self.arenas.alloc_ast_paths(derives), + after_derive, ), - InvocationKind::Bang { ref mac, .. } => (&mac.path, MacroKind::Bang, false, &[][..]), - InvocationKind::Derive { ref path, .. } => (path, MacroKind::Derive, false, &[][..]), + InvocationKind::Bang { ref mac, .. } => { + (&mac.path, MacroKind::Bang, false, &[][..], false) + } + InvocationKind::Derive { ref path, .. } => { + (path, MacroKind::Derive, false, &[][..], false) + } + InvocationKind::DeriveContainer { ref derives, .. } => { + // Block expansion of the container until we resolve all derives in it. + // This is required for two reasons: + // - Derive helper attributes are in scope for the item to which the `#[derive]` + // is applied, so they have to be produced by the container's expansion rather + // than by individual derives. + // - Derives in the container need to know whether one of them is a built-in `Copy`. + // FIXME: Try to avoid repeated resolutions for derives here and in expansion. + let mut exts = Vec::new(); + let mut helper_attrs = Vec::new(); + for path in derives { + exts.push( + match self.resolve_macro_path( + path, + Some(MacroKind::Derive), + &parent_scope, + true, + force, + ) { + Ok((Some(ext), _)) => { + let span = path + .segments + .last() + .unwrap() + .ident + .span + .normalize_to_macros_2_0(); + helper_attrs.extend( + ext.helper_attrs.iter().map(|name| Ident::new(*name, span)), + ); + if ext.builtin_name == Some(sym::Copy) { + self.containers_deriving_copy.insert(invoc_id); + } + ext + } + Ok(_) | Err(Determinacy::Determined) => { + self.dummy_ext(MacroKind::Derive) + } + Err(Determinacy::Undetermined) => return Err(Indeterminate), + }, + ) + } + self.helper_attrs.insert(invoc_id, helper_attrs); + return Ok(InvocationRes::DeriveContainer(exts)); + } }; // Derives are not included when `invocations` are collected, so we have to add them here. @@ -278,41 +327,14 @@ impl<'a> ResolverExpand for Resolver<'a> { )); if let Res::Def(_, _) = res { + if after_derive { + self.session.span_err(span, "macro attributes must be placed before `#[derive]`"); + } let normal_module_def_id = self.macro_def_scope(invoc_id).nearest_parent_mod; self.definitions.add_parent_module_of_macro_def(invoc_id, normal_module_def_id); - - // Gate macro attributes in `#[derive]` output. - if !self.session.features_untracked().macro_attributes_in_derive_output - && kind == MacroKind::Attr - && ext.builtin_name != Some(sym::derive) - { - let mut expn_id = parent_scope.expansion; - loop { - // Helper attr table is a quick way to determine whether the attr is `derive`. - if self.helper_attrs.contains_key(&expn_id) { - feature_err( - &self.session.parse_sess, - sym::macro_attributes_in_derive_output, - path.span, - "macro attributes in `#[derive]` output are unstable", - ) - .emit(); - break; - } else { - let expn_data = expn_id.expn_data(); - match expn_data.kind { - ExpnKind::Root - | ExpnKind::Macro(MacroKind::Bang | MacroKind::Derive, _) => { - break; - } - _ => expn_id = expn_data.parent, - } - } - } - } } - Ok(ext) + Ok(InvocationRes::Single(ext)) } fn check_unused_macros(&mut self) { @@ -321,7 +343,7 @@ impl<'a> ResolverExpand for Resolver<'a> { } } - fn lint_node_id(&self, expn_id: ExpnId) -> NodeId { + fn lint_node_id(&mut self, expn_id: ExpnId) -> NodeId { // FIXME - make this more precise. This currently returns the NodeId of the // nearest closing item - we should try to return the closest parent of the ExpnId self.invocation_parents @@ -333,63 +355,6 @@ impl<'a> ResolverExpand for Resolver<'a> { self.containers_deriving_copy.contains(&expn_id) } - fn resolve_derives( - &mut self, - expn_id: ExpnId, - derives: Vec, - force: bool, - ) -> Result<(), Indeterminate> { - // Block expansion of the container until we resolve all derives in it. - // This is required for two reasons: - // - Derive helper attributes are in scope for the item to which the `#[derive]` - // is applied, so they have to be produced by the container's expansion rather - // than by individual derives. - // - Derives in the container need to know whether one of them is a built-in `Copy`. - // FIXME: Try to cache intermediate results to avoid resolving same derives multiple times. - let parent_scope = self.invocation_parent_scopes[&expn_id]; - let mut exts = Vec::new(); - let mut helper_attrs = Vec::new(); - let mut has_derive_copy = false; - for path in derives { - exts.push(( - match self.resolve_macro_path( - &path, - Some(MacroKind::Derive), - &parent_scope, - true, - force, - ) { - Ok((Some(ext), _)) => { - let span = - path.segments.last().unwrap().ident.span.normalize_to_macros_2_0(); - helper_attrs - .extend(ext.helper_attrs.iter().map(|name| Ident::new(*name, span))); - has_derive_copy |= ext.builtin_name == Some(sym::Copy); - ext - } - Ok(_) | Err(Determinacy::Determined) => self.dummy_ext(MacroKind::Derive), - Err(Determinacy::Undetermined) => return Err(Indeterminate), - }, - path, - )) - } - self.derive_resolutions.insert(expn_id, exts); - self.helper_attrs.insert(expn_id, helper_attrs); - // Mark this derive as having `Copy` either if it has `Copy` itself or if its parent derive - // has `Copy`, to support cases like `#[derive(Clone, Copy)] #[derive(Debug)]`. - if has_derive_copy || self.has_derive_copy(parent_scope.expansion) { - self.containers_deriving_copy.insert(expn_id); - } - Ok(()) - } - - fn take_derive_resolutions( - &mut self, - expn_id: ExpnId, - ) -> Option, ast::Path)>> { - self.derive_resolutions.remove(&expn_id) - } - // The function that implements the resolution logic of `#[cfg_accessible(path)]`. // Returns true if the path can certainly be resolved in one of three namespaces, // returns false if the path certainly cannot be resolved in any of the three namespaces. @@ -831,10 +796,12 @@ impl<'a> Resolver<'a> { } result } - Scope::BuiltinTypes => match PrimTy::from_name(ident.name) { - Some(prim_ty) => ok(Res::PrimTy(prim_ty), DUMMY_SP, this.arenas), - None => Err(Determinacy::Determined), - }, + Scope::BuiltinTypes => { + match this.primitive_type_table.primitive_types.get(&ident.name).cloned() { + Some(prim_ty) => ok(Res::PrimTy(prim_ty), DUMMY_SP, this.arenas), + None => Err(Determinacy::Determined), + } + } }; match result { @@ -852,8 +819,6 @@ impl<'a> Resolver<'a> { let is_builtin = |res| { matches!(res, Res::NonMacroAttr(NonMacroAttrKind::Builtin(..))) }; - let derive_helper = - Res::NonMacroAttr(NonMacroAttrKind::DeriveHelper); let derive_helper_compat = Res::NonMacroAttr(NonMacroAttrKind::DeriveHelperCompat); @@ -862,7 +827,7 @@ impl<'a> Resolver<'a> { } else if is_builtin(innermost_res) || is_builtin(res) { Some(AmbiguityKind::BuiltinAttr) } else if innermost_res == derive_helper_compat - || res == derive_helper_compat && innermost_res != derive_helper + || res == derive_helper_compat { Some(AmbiguityKind::DeriveHelper) } else if innermost_flags.contains(Flags::MACRO_RULES) @@ -1028,15 +993,6 @@ impl<'a> Resolver<'a> { let res = binding.res(); let seg = Segment::from_ident(ident); check_consistency(self, &[seg], ident.span, kind, initial_res, res); - if res == Res::NonMacroAttr(NonMacroAttrKind::DeriveHelperCompat) { - self.lint_buffer.buffer_lint_with_diagnostic( - LEGACY_DERIVE_HELPERS, - self.lint_node_id(parent_scope.expansion), - ident.span, - "derive helper attribute is used before it is introduced", - BuiltinLintDiagnostics::LegacyDeriveHelpers(binding.span), - ); - } } Err(..) => { let expected = kind.descr_expected(); @@ -1123,7 +1079,7 @@ impl<'a> Resolver<'a> { crate fn check_reserved_macro_name(&mut self, ident: Ident, res: Res) { // Reserve some names that are not quite covered by the general check // performed on `Resolver::builtin_attrs`. - if ident.name == sym::cfg || ident.name == sym::cfg_attr { + if ident.name == sym::cfg || ident.name == sym::cfg_attr || ident.name == sym::derive { let macro_kind = self.get_macro(res).map(|ext| ext.macro_kind()); if macro_kind.is_some() && sub_namespace_match(macro_kind, Some(MacroKind::Attr)) { self.session.span_err( diff --git a/compiler/rustc_serialize/src/lib.rs b/compiler/rustc_serialize/src/lib.rs index 53c3adcc20c02..ea04e7bb44b3b 100644 --- a/compiler/rustc_serialize/src/lib.rs +++ b/compiler/rustc_serialize/src/lib.rs @@ -17,7 +17,6 @@ Core encoding and decoding interfaces. #![feature(min_specialization)] #![feature(vec_spare_capacity)] #![feature(core_intrinsics)] -#![feature(int_bits_const)] #![feature(maybe_uninit_slice)] #![feature(new_uninit)] #![cfg_attr(test, feature(test))] diff --git a/compiler/rustc_serialize/tests/leb128.rs b/compiler/rustc_serialize/tests/leb128.rs index a2bcf2c251d7a..3e2aab5125ab7 100644 --- a/compiler/rustc_serialize/tests/leb128.rs +++ b/compiler/rustc_serialize/tests/leb128.rs @@ -1,4 +1,3 @@ -#![feature(int_bits_const)] #![feature(maybe_uninit_slice)] #![feature(maybe_uninit_uninit_array)] diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index e9ea0ab6f98f5..9d73c3b4424cb 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -15,8 +15,6 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_target::abi::{Align, TargetDataLayout}; use rustc_target::spec::{SplitDebuginfo, Target, TargetTriple}; -use rustc_serialize::json; - use crate::parse::CrateConfig; use rustc_feature::UnstableFeatures; use rustc_span::edition::{Edition, DEFAULT_EDITION, EDITION_NAME_LIST}; @@ -410,9 +408,6 @@ impl OutputTypes { #[derive(Clone)] pub struct Externs(BTreeMap); -#[derive(Clone)] -pub struct ExternDepSpecs(BTreeMap); - #[derive(Clone, Debug)] pub struct ExternEntry { pub location: ExternLocation, @@ -444,27 +439,6 @@ pub enum ExternLocation { ExactPaths(BTreeSet), } -/// Supplied source location of a dependency - for example in a build specification -/// file like Cargo.toml. We support several syntaxes: if it makes sense to reference -/// a file and line, then the build system can specify that. On the other hand, it may -/// make more sense to have an arbitrary raw string. -#[derive(Clone, PartialEq)] -pub enum ExternDepSpec { - /// Raw string - Raw(String), - /// Raw data in json format - Json(json::Json), -} - -impl<'a> From<&'a ExternDepSpec> for rustc_lint_defs::ExternDepSpec { - fn from(from: &'a ExternDepSpec) -> Self { - match from { - ExternDepSpec::Raw(s) => rustc_lint_defs::ExternDepSpec::Raw(s.clone()), - ExternDepSpec::Json(json) => rustc_lint_defs::ExternDepSpec::Json(json.clone()), - } - } -} - impl Externs { pub fn new(data: BTreeMap) -> Externs { Externs(data) @@ -492,25 +466,6 @@ impl ExternEntry { } } -impl ExternDepSpecs { - pub fn new(data: BTreeMap) -> ExternDepSpecs { - ExternDepSpecs(data) - } - - pub fn get(&self, key: &str) -> Option<&ExternDepSpec> { - self.0.get(key) - } -} - -impl fmt::Display for ExternDepSpec { - fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - ExternDepSpec::Raw(raw) => fmt.write_str(raw), - ExternDepSpec::Json(json) => json::as_json(json).fmt(fmt), - } - } -} - #[derive(Copy, Clone, PartialEq, Eq, Debug)] pub enum PrintRequest { FileNames, @@ -724,7 +679,6 @@ impl Default for Options { cg: basic_codegen_options(), error_format: ErrorOutputType::default(), externs: Externs(BTreeMap::new()), - extern_dep_specs: ExternDepSpecs(BTreeMap::new()), crate_name: None, alt_std_name: None, libs: Vec::new(), @@ -1151,12 +1105,6 @@ pub fn rustc_optgroups() -> Vec { "Specify where an external rust library is located", "NAME[=PATH]", ), - opt::multi_s( - "", - "extern-location", - "Location where an external crate dependency is specified", - "NAME=LOCATION", - ), opt::opt_s("", "sysroot", "Override the system root", "PATH"), opt::multi("Z", "", "Set internal debugging options", "FLAG"), opt::opt_s( @@ -1779,68 +1727,6 @@ pub fn parse_externs( Externs(externs) } -fn parse_extern_dep_specs( - matches: &getopts::Matches, - debugging_opts: &DebuggingOptions, - error_format: ErrorOutputType, -) -> ExternDepSpecs { - let is_unstable_enabled = debugging_opts.unstable_options; - let mut map = BTreeMap::new(); - - for arg in matches.opt_strs("extern-location") { - if !is_unstable_enabled { - early_error( - error_format, - "`--extern-location` option is unstable: set `-Z unstable-options`", - ); - } - - let mut parts = arg.splitn(2, '='); - let name = parts.next().unwrap_or_else(|| { - early_error(error_format, "`--extern-location` value must not be empty") - }); - let loc = parts.next().unwrap_or_else(|| { - early_error( - error_format, - &format!("`--extern-location`: specify location for extern crate `{}`", name), - ) - }); - - let locparts: Vec<_> = loc.split(":").collect(); - let spec = match &locparts[..] { - ["raw", ..] => { - // Don't want `:` split string - let raw = loc.splitn(2, ':').nth(1).unwrap_or_else(|| { - early_error(error_format, "`--extern-location`: missing `raw` location") - }); - ExternDepSpec::Raw(raw.to_string()) - } - ["json", ..] => { - // Don't want `:` split string - let raw = loc.splitn(2, ':').nth(1).unwrap_or_else(|| { - early_error(error_format, "`--extern-location`: missing `json` location") - }); - let json = json::from_str(raw).unwrap_or_else(|_| { - early_error( - error_format, - &format!("`--extern-location`: malformed json location `{}`", raw), - ) - }); - ExternDepSpec::Json(json) - } - [bad, ..] => early_error( - error_format, - &format!("unknown location type `{}`: use `raw` or `json`", bad), - ), - [] => early_error(error_format, "missing location specification"), - }; - - map.insert(name.to_string(), spec); - } - - ExternDepSpecs::new(map) -} - fn parse_remap_path_prefix( matches: &getopts::Matches, error_format: ErrorOutputType, @@ -2002,7 +1888,6 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { } let externs = parse_externs(matches, &debugging_opts, error_format); - let extern_dep_specs = parse_extern_dep_specs(matches, &debugging_opts, error_format); let crate_name = matches.opt_str("crate-name"); @@ -2039,7 +1924,6 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { error_format, externs, unstable_features: UnstableFeatures::from_environment(crate_name.as_deref()), - extern_dep_specs, crate_name, alt_std_name: None, libs, diff --git a/compiler/rustc_session/src/filesearch.rs b/compiler/rustc_session/src/filesearch.rs index 47f14fa6b7a74..3a757e5f0075d 100644 --- a/compiler/rustc_session/src/filesearch.rs +++ b/compiler/rustc_session/src/filesearch.rs @@ -113,8 +113,6 @@ pub fn make_target_lib_path(sysroot: &Path, target_triple: &str) -> PathBuf { sysroot.join(&relative_target_lib_path(sysroot, target_triple)) } -// This function checks if sysroot is found using env::args().next(), and if it -// is not found, uses env::current_exe() to imply sysroot. pub fn get_or_default_sysroot() -> PathBuf { // Follow symlinks. If the resolved path is relative, make it absolute. fn canonicalize(path: PathBuf) -> PathBuf { @@ -125,51 +123,15 @@ pub fn get_or_default_sysroot() -> PathBuf { fix_windows_verbatim_for_gcc(&path) } - // Use env::current_exe() to get the path of the executable following - // symlinks/canonicalizing components. - fn from_current_exe() -> PathBuf { - match env::current_exe() { - Ok(exe) => { - let mut p = canonicalize(exe); - p.pop(); - p.pop(); - p - } - Err(e) => panic!("failed to get current_exe: {}", e), - } - } - - // Use env::args().next() to get the path of the executable without - // following symlinks/canonicalizing any component. This makes the rustc - // binary able to locate Rust libraries in systems using content-addressable - // storage (CAS). - fn from_env_args_next() -> Option { - match env::args_os().next() { - Some(first_arg) => { - let mut p = PathBuf::from(first_arg); - - // Check if sysroot is found using env::args().next() only if the rustc in argv[0] - // is a symlink (see #79253). We might want to change/remove it to conform with - // https://www.gnu.org/prep/standards/standards.html#Finding-Program-Files in the - // future. - if fs::read_link(&p).is_err() { - // Path is not a symbolic link or does not exist. - return None; - } - - p.pop(); - p.pop(); - let mut libdir = PathBuf::from(&p); - libdir.push(find_libdir(&p).as_ref()); - if libdir.exists() { Some(p) } else { None } - } - None => None, + match env::current_exe() { + Ok(exe) => { + let mut p = canonicalize(exe); + p.pop(); + p.pop(); + p } + Err(e) => panic!("failed to get current_exe: {}", e), } - - // Check if sysroot is found using env::args().next(), and if is not found, - // use env::current_exe() to imply sysroot. - from_env_args_next().unwrap_or(from_current_exe()) } // The name of the directory rustc expects libraries to be located. diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index f78df8a7e29fa..779e042163698 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -112,7 +112,6 @@ top_level_options!( borrowck_mode: BorrowckMode [UNTRACKED], cg: CodegenOptions [TRACKED], externs: Externs [UNTRACKED], - extern_dep_specs: ExternDepSpecs [UNTRACKED], crate_name: Option [TRACKED], // An optional name to use as the crate for std during std injection, // written `extern crate name as std`. Defaults to `std`. Used by diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 79c5c7f110c4f..f3d876a5770a8 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -22,7 +22,6 @@ #![feature(nll)] #![feature(min_specialization)] #![feature(option_expect_none)] -#![feature(str_split_once)] #[macro_use] extern crate rustc_macros; diff --git a/compiler/rustc_span/src/source_map.rs b/compiler/rustc_span/src/source_map.rs index 298c995b1660b..4e0ce0d344de4 100644 --- a/compiler/rustc_span/src/source_map.rs +++ b/compiler/rustc_span/src/source_map.rs @@ -539,7 +539,7 @@ impl SourceMap { pub fn is_line_before_span_empty(&self, sp: Span) -> bool { match self.span_to_prev_source(sp) { - Ok(s) => s.rsplit_once('\n').unwrap_or(("", &s)).1.trim_start().is_empty(), + Ok(s) => s.split('\n').last().map_or(false, |l| l.trim_start().is_empty()), Err(_) => false, } } @@ -632,11 +632,10 @@ impl SourceMap { pub fn span_to_margin(&self, sp: Span) -> Option { match self.span_to_prev_source(sp) { Err(_) => None, - Ok(source) => { - let last_line = source.rsplit_once('\n').unwrap_or(("", &source)).1; - - Some(last_line.len() - last_line.trim_start().len()) - } + Ok(source) => source + .split('\n') + .last() + .map(|last_line| last_line.len() - last_line.trim_start().len()), } } @@ -652,7 +651,7 @@ impl SourceMap { pub fn span_extend_to_prev_char(&self, sp: Span, c: char, accept_newlines: bool) -> Span { if let Ok(prev_source) = self.span_to_prev_source(sp) { let prev_source = prev_source.rsplit(c).next().unwrap_or(""); - if !prev_source.is_empty() && (accept_newlines || !prev_source.contains('\n')) { + if !prev_source.is_empty() && (!prev_source.contains('\n') || accept_newlines) { return sp.with_lo(BytePos(sp.lo().0 - prev_source.len() as u32)); } } @@ -674,7 +673,7 @@ impl SourceMap { let prev_source = prev_source.rsplit(&pat).next().unwrap_or("").trim_start(); if prev_source.is_empty() && sp.lo().0 != 0 { return sp.with_lo(BytePos(sp.lo().0 - 1)); - } else if accept_newlines || !prev_source.contains('\n') { + } else if !prev_source.contains('\n') || accept_newlines { return sp.with_lo(BytePos(sp.lo().0 - prev_source.len() as u32)); } } @@ -694,7 +693,7 @@ impl SourceMap { pub fn span_extend_to_next_char(&self, sp: Span, c: char, accept_newlines: bool) -> Span { if let Ok(next_source) = self.span_to_next_source(sp) { let next_source = next_source.split(c).next().unwrap_or(""); - if !next_source.is_empty() && (accept_newlines || !next_source.contains('\n')) { + if !next_source.is_empty() && (!next_source.contains('\n') || accept_newlines) { return sp.with_hi(BytePos(sp.hi().0 + next_source.len() as u32)); } } @@ -800,9 +799,6 @@ impl SourceMap { /// Returns a new span representing the next character after the end-point of this span. pub fn next_point(&self, sp: Span) -> Span { - if sp.is_dummy() { - return sp; - } let start_of_next_point = sp.hi().0; let width = self.find_width_of_character_at_span(sp.shrink_to_hi(), true); diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index 20e4f7262acb9..f2f975c0cf9e5 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -133,8 +133,6 @@ symbols! { Copy, Count, Debug, - DebugStruct, - DebugTuple, Decodable, Decoder, Default, @@ -220,7 +218,6 @@ symbols! { abi, abi_amdgpu_kernel, abi_avr_interrupt, - abi_c_cmse_nonsecure_call, abi_efiapi, abi_msp430_interrupt, abi_ptx, @@ -679,7 +676,6 @@ symbols! { loop_break_value, lt, macro_at_most_once_rep, - macro_attributes_in_derive_output, macro_escape, macro_export, macro_lifetime_matcher, @@ -908,7 +904,6 @@ symbols! { register_attr, register_tool, relaxed_adts, - relaxed_struct_unsize, rem, rem_assign, repr, diff --git a/compiler/rustc_target/src/abi/call/aarch64.rs b/compiler/rustc_target/src/abi/call/aarch64.rs index a5e985d471271..1ab7722edab98 100644 --- a/compiler/rustc_target/src/abi/call/aarch64.rs +++ b/compiler/rustc_target/src/abi/call/aarch64.rs @@ -40,7 +40,17 @@ where let size = ret.layout.size; let bits = size.bits(); if bits <= 128 { - ret.cast_to(Uniform { unit: Reg::i64(), total: size }); + let unit = if bits <= 8 { + Reg::i8() + } else if bits <= 16 { + Reg::i16() + } else if bits <= 32 { + Reg::i32() + } else { + Reg::i64() + }; + + ret.cast_to(Uniform { unit, total: size }); return; } ret.make_indirect(); @@ -62,7 +72,17 @@ where let size = arg.layout.size; let bits = size.bits(); if bits <= 128 { - arg.cast_to(Uniform { unit: Reg::i64(), total: size }); + let unit = if bits <= 8 { + Reg::i8() + } else if bits <= 16 { + Reg::i16() + } else if bits <= 32 { + Reg::i32() + } else { + Reg::i64() + }; + + arg.cast_to(Uniform { unit, total: size }); return; } arg.make_indirect(); diff --git a/compiler/rustc_target/src/abi/call/arm.rs b/compiler/rustc_target/src/abi/call/arm.rs index b560e11fe1c5e..26fed3bae4e48 100644 --- a/compiler/rustc_target/src/abi/call/arm.rs +++ b/compiler/rustc_target/src/abi/call/arm.rs @@ -45,7 +45,14 @@ where let size = ret.layout.size; let bits = size.bits(); if bits <= 32 { - ret.cast_to(Uniform { unit: Reg::i32(), total: size }); + let unit = if bits <= 8 { + Reg::i8() + } else if bits <= 16 { + Reg::i16() + } else { + Reg::i32() + }; + ret.cast_to(Uniform { unit, total: size }); return; } ret.make_indirect(); diff --git a/compiler/rustc_target/src/abi/call/mod.rs b/compiler/rustc_target/src/abi/call/mod.rs index 9c49922c286eb..ce8e56b194980 100644 --- a/compiler/rustc_target/src/abi/call/mod.rs +++ b/compiler/rustc_target/src/abi/call/mod.rs @@ -526,7 +526,7 @@ impl<'a, Ty> ArgAbi<'a, Ty> { } pub fn is_indirect(&self) -> bool { - matches!(self.mode, PassMode::Indirect { .. }) + matches!(self.mode, PassMode::Indirect {..}) } pub fn is_sized_indirect(&self) -> bool { @@ -551,7 +551,6 @@ pub enum Conv { // Target-specific calling conventions. ArmAapcs, - CCmseNonSecureCall, Msp430Intr, diff --git a/compiler/rustc_target/src/spec/aarch64_be_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/aarch64_be_unknown_linux_gnu.rs deleted file mode 100644 index 192c4661c7ce6..0000000000000 --- a/compiler/rustc_target/src/spec/aarch64_be_unknown_linux_gnu.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::linux_gnu_base::opts(); - base.max_atomic_width = Some(128); - - Target { - llvm_target: "aarch64_be-unknown-linux-gnu".to_string(), - pointer_width: 64, - data_layout: "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(), - arch: "aarch64".to_string(), - options: TargetOptions { - unsupported_abis: super::arm_base::unsupported_abis(), - mcount: "\u{1}_mcount".to_string(), - endian: Endian::Big, - ..base - }, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_be_unknown_linux_gnu_ilp32.rs b/compiler/rustc_target/src/spec/aarch64_be_unknown_linux_gnu_ilp32.rs deleted file mode 100644 index 5b9e9c9519c54..0000000000000 --- a/compiler/rustc_target/src/spec/aarch64_be_unknown_linux_gnu_ilp32.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::abi::Endian; -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::linux_gnu_base::opts(); - base.max_atomic_width = Some(128); - - Target { - llvm_target: "aarch64_be-unknown-linux-gnu_ilp32".to_string(), - pointer_width: 32, - data_layout: "E-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(), - arch: "aarch64".to_string(), - options: TargetOptions { - unsupported_abis: super::arm_base::unsupported_abis(), - mcount: "\u{1}_mcount".to_string(), - endian: Endian::Big, - ..base - }, - } -} diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu_ilp32.rs b/compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu_ilp32.rs deleted file mode 100644 index f2d7576280fd9..0000000000000 --- a/compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu_ilp32.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::linux_gnu_base::opts(); - base.max_atomic_width = Some(128); - - Target { - llvm_target: "aarch64-unknown-linux-gnu_ilp32".to_string(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(), - arch: "aarch64".to_string(), - options: TargetOptions { - unsupported_abis: super::arm_base::unsupported_abis(), - mcount: "\u{1}_mcount".to_string(), - ..base - }, - } -} diff --git a/compiler/rustc_target/src/spec/abi.rs b/compiler/rustc_target/src/spec/abi.rs index 65e8a4e8db2ad..1e45739ca22b4 100644 --- a/compiler/rustc_target/src/spec/abi.rs +++ b/compiler/rustc_target/src/spec/abi.rs @@ -36,7 +36,6 @@ pub enum Abi { EfiApi, AvrInterrupt, AvrNonBlockingInterrupt, - CCmseNonSecureCall, // Multiplatform / generic ABIs System, @@ -82,7 +81,6 @@ const AbiDatas: &[AbiData] = &[ name: "avr-non-blocking-interrupt", generic: false, }, - AbiData { abi: Abi::CCmseNonSecureCall, name: "C-cmse-nonsecure-call", generic: false }, // Cross-platform ABIs AbiData { abi: Abi::System, name: "system", generic: true }, AbiData { abi: Abi::RustIntrinsic, name: "rust-intrinsic", generic: true }, diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 7a93bac72ca07..0227febd294a0 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -808,10 +808,6 @@ supported_targets! { ("mipsel-sony-psp", mipsel_sony_psp), ("mipsel-unknown-none", mipsel_unknown_none), ("thumbv4t-none-eabi", thumbv4t_none_eabi), - - ("aarch64_be-unknown-linux-gnu", aarch64_be_unknown_linux_gnu), - ("aarch64-unknown-linux-gnu_ilp32", aarch64_unknown_linux_gnu_ilp32), - ("aarch64_be-unknown-linux-gnu_ilp32", aarch64_be_unknown_linux_gnu_ilp32), } /// Everything `rustc` knows about how to compile for a specific target. diff --git a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs index b1ac02d9fed5a..b587ed6487e3c 100644 --- a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs +++ b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs @@ -16,7 +16,8 @@ use rustc_infer::infer::InferCtxt; use rustc_middle::mir::abstract_const::{Node, NodeId}; use rustc_middle::mir::interpret::ErrorHandled; use rustc_middle::mir::{self, Rvalue, StatementKind, TerminatorKind}; -use rustc_middle::ty::subst::{Subst, SubstsRef}; +use rustc_middle::ty::subst::Subst; +use rustc_middle::ty::subst::SubstsRef; use rustc_middle::ty::{self, TyCtxt, TypeFoldable}; use rustc_session::lint; use rustc_span::def_id::{DefId, LocalDefId}; @@ -42,27 +43,18 @@ pub fn is_const_evaluatable<'cx, 'tcx>( for pred in param_env.caller_bounds() { match pred.kind().skip_binder() { ty::PredicateKind::ConstEvaluatable(b_def, b_substs) => { + debug!( + "is_const_evaluatable: caller_bound={:?}, {:?}", + b_def, b_substs + ); if b_def == def && b_substs == substs { debug!("is_const_evaluatable: caller_bound ~~> ok"); return Ok(()); - } - - if let Some(b_ct) = AbstractConst::new(tcx, b_def, b_substs)? { - // Try to unify with each subtree in the AbstractConst to allow for - // `N + 1` being const evaluatable even if theres only a `ConstEvaluatable` - // predicate for `(N + 1) * 2` - let result = - walk_abstract_const(tcx, b_ct, |b_ct| { - match try_unify(tcx, ct, b_ct) { - true => ControlFlow::BREAK, - false => ControlFlow::CONTINUE, - } - }); - - if let ControlFlow::Break(()) = result { - debug!("is_const_evaluatable: abstract_const ~~> ok"); - return Ok(()); - } + } else if AbstractConst::new(tcx, b_def, b_substs)? + .map_or(false, |b_ct| try_unify(tcx, ct, b_ct)) + { + debug!("is_const_evaluatable: abstract_const ~~> ok"); + return Ok(()); } } _ => {} // don't care @@ -86,7 +78,7 @@ pub fn is_const_evaluatable<'cx, 'tcx>( Concrete, } let mut failure_kind = FailureKind::Concrete; - walk_abstract_const::(tcx, ct, |node| match node.root() { + walk_abstract_const::(tcx, ct, |node| match node { Node::Leaf(leaf) => { let leaf = leaf.subst(tcx, ct.substs); if leaf.has_infer_types_or_consts() { @@ -108,24 +100,15 @@ pub fn is_const_evaluatable<'cx, 'tcx>( } FailureKind::MentionsParam => { // FIXME(const_evaluatable_checked): Better error message. - let mut err = - infcx.tcx.sess.struct_span_err(span, "unconstrained generic constant"); - let const_span = tcx.def_span(def.did); - // FIXME(const_evaluatable_checked): Update this suggestion once - // explicit const evaluatable bounds are implemented. - if let Ok(snippet) = infcx.tcx.sess.source_map().span_to_snippet(const_span) - { - err.span_help( + infcx + .tcx + .sess + .struct_span_err(span, "unconstrained generic constant") + .span_help( tcx.def_span(def.did), - &format!("try adding a `where` bound using this expression: `where [u8; {}]: Sized`", snippet), - ); - } else { - err.span_help( - const_span, "consider adding a `where` bound for this expression", - ); - } - err.emit(); + ) + .emit(); return Err(ErrorHandled::Reported(ErrorReported)); } FailureKind::Concrete => { @@ -597,15 +580,15 @@ pub fn walk_abstract_const<'tcx, R, F>( mut f: F, ) -> ControlFlow where - F: FnMut(AbstractConst<'tcx>) -> ControlFlow, + F: FnMut(Node<'tcx>) -> ControlFlow, { fn recurse<'tcx, R>( tcx: TyCtxt<'tcx>, ct: AbstractConst<'tcx>, - f: &mut dyn FnMut(AbstractConst<'tcx>) -> ControlFlow, + f: &mut dyn FnMut(Node<'tcx>) -> ControlFlow, ) -> ControlFlow { - f(ct)?; let root = ct.root(); + f(root)?; match root { Node::Leaf(_) => ControlFlow::CONTINUE, Node::Binop(_, l, r) => { diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index 756281450d723..a42a05c5f0284 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -1190,12 +1190,9 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> { normalized_ty, data.ty ); - let is_normalized_ty_expected = !matches!( - obligation.cause.code, - ObligationCauseCode::ItemObligation(_) - | ObligationCauseCode::BindingObligation(_, _) - | ObligationCauseCode::ObjectCastObligation(_) - ); + let is_normalized_ty_expected = !matches!(obligation.cause.code, ObligationCauseCode::ItemObligation(_) + | ObligationCauseCode::BindingObligation(_, _) + | ObligationCauseCode::ObjectCastObligation(_)); if let Err(error) = self.at(&obligation.cause, obligation.param_env).eq_exp( is_normalized_ty_expected, @@ -1780,7 +1777,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> { multispan.push_span_label( sp, format!( - "...if indirection were used here: `Box<{}>`", + "...if indirection was used here: `Box<{}>`", param.name.ident(), ), ); diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs index 34bd332951c06..690591930deb9 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/suggestions.rs @@ -290,9 +290,9 @@ fn suggest_restriction( generics .params .iter() - .filter(|p| { - !matches!(p.kind, hir::GenericParamKind::Type { synthetic: Some(_), .. }) - }) + .filter( + |p| !matches!(p.kind, hir::GenericParamKind::Type { synthetic: Some(_), ..}), + ) .next(), super_traits, ) { @@ -1103,7 +1103,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { // This is currently not possible to trigger because E0038 takes precedence, but // leave it in for completeness in case anything changes in an earlier stage. err.note(&format!( - "if trait `{}` were object-safe, you could return a trait object", + "if trait `{}` was object safe, you could return a trait object", trait_obj, )); } diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index 0a81b6e105dff..f7c0bafff05b4 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -65,8 +65,7 @@ pub use self::util::{ get_vtable_index_of_object_method, impl_item_is_final, predicate_for_trait_def, upcast_choices, }; pub use self::util::{ - supertrait_def_ids, supertraits, transitive_bounds, transitive_bounds_that_define_assoc_type, - SupertraitDefIds, Supertraits, + supertrait_def_ids, supertraits, transitive_bounds, SupertraitDefIds, Supertraits, }; pub use self::chalk_fulfill::FulfillmentContext as ChalkFulfillmentContext; diff --git a/compiler/rustc_trait_selection/src/traits/object_safety.rs b/compiler/rustc_trait_selection/src/traits/object_safety.rs index e155f0366e19f..a9723611f8113 100644 --- a/compiler/rustc_trait_selection/src/traits/object_safety.rs +++ b/compiler/rustc_trait_selection/src/traits/object_safety.rs @@ -257,11 +257,13 @@ fn predicates_reference_self( } fn bounds_reference_self(tcx: TyCtxt<'_>, trait_def_id: DefId) -> SmallVec<[Span; 1]> { + let trait_ref = ty::Binder::dummy(ty::TraitRef::identity(tcx, trait_def_id)); tcx.associated_items(trait_def_id) .in_definition_order() .filter(|item| item.kind == ty::AssocKind::Type) .flat_map(|item| tcx.explicit_item_bounds(item.def_id)) - .filter_map(|pred_span| predicate_references_self(tcx, *pred_span)) + .map(|&(predicate, sp)| (predicate.subst_supertrait(tcx, &trait_ref), sp)) + .filter_map(|predicate| predicate_references_self(tcx, predicate)) .collect() } @@ -826,7 +828,7 @@ fn contains_illegal_self_type_reference<'tcx, T: TypeFoldable<'tcx>>( // constants which are not considered const evaluatable. use rustc_middle::mir::abstract_const::Node; if let Ok(Some(ct)) = AbstractConst::from_const(self.tcx, ct) { - const_evaluatable::walk_abstract_const(self.tcx, ct, |node| match node.root() { + const_evaluatable::walk_abstract_const(self.tcx, ct, |node| match node { Node::Leaf(leaf) => { let leaf = leaf.subst(self.tcx, ct.substs); self.visit_const(leaf) @@ -847,7 +849,7 @@ fn contains_illegal_self_type_reference<'tcx, T: TypeFoldable<'tcx>>( // take a `ty::Const` instead. use rustc_middle::mir::abstract_const::Node; if let Ok(Some(ct)) = AbstractConst::new(self.tcx, def, substs) { - const_evaluatable::walk_abstract_const(self.tcx, ct, |node| match node.root() { + const_evaluatable::walk_abstract_const(self.tcx, ct, |node| match node { Node::Leaf(leaf) => { let leaf = leaf.subst(self.tcx, ct.substs); self.visit_const(leaf) diff --git a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs index ed3e117fcfabb..3015188fd447a 100644 --- a/compiler/rustc_trait_selection/src/traits/select/confirmation.rs +++ b/compiler/rustc_trait_selection/src/traits/select/confirmation.rs @@ -823,59 +823,33 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { }, }; - // FIXME(eddyb) cache this (including computing `unsizing_params`) - // by putting it in a query; it would only need the `DefId` as it - // looks at declared field types, not anything substituted. - // The last field of the structure has to exist and contain type/const parameters. let (tail_field, prefix_fields) = def.non_enum_variant().fields.split_last().ok_or(Unimplemented)?; let tail_field_ty = tcx.type_of(tail_field.did); let mut unsizing_params = GrowableBitSet::new_empty(); - if tcx.features().relaxed_struct_unsize { - for arg in tail_field_ty.walk() { - if let Some(i) = maybe_unsizing_param_idx(arg) { - unsizing_params.insert(i); - } - } - - // Ensure none of the other fields mention the parameters used - // in unsizing. - for field in prefix_fields { - for arg in tcx.type_of(field.did).walk() { - if let Some(i) = maybe_unsizing_param_idx(arg) { - unsizing_params.remove(i); - } - } + let mut found = false; + for arg in tail_field_ty.walk() { + if let Some(i) = maybe_unsizing_param_idx(arg) { + unsizing_params.insert(i); + found = true; } + } + if !found { + return Err(Unimplemented); + } - if unsizing_params.is_empty() { - return Err(Unimplemented); - } - } else { - let mut found = false; - for arg in tail_field_ty.walk() { + // Ensure none of the other fields mention the parameters used + // in unsizing. + // FIXME(eddyb) cache this (including computing `unsizing_params`) + // by putting it in a query; it would only need the `DefId` as it + // looks at declared field types, not anything substituted. + for field in prefix_fields { + for arg in tcx.type_of(field.did).walk() { if let Some(i) = maybe_unsizing_param_idx(arg) { - unsizing_params.insert(i); - found = true; - } - } - if !found { - return Err(Unimplemented); - } - - // Ensure none of the other fields mention the parameters used - // in unsizing. - // FIXME(eddyb) cache this (including computing `unsizing_params`) - // by putting it in a query; it would only need the `DefId` as it - // looks at declared field types, not anything substituted. - for field in prefix_fields { - for arg in tcx.type_of(field.did).walk() { - if let Some(i) = maybe_unsizing_param_idx(arg) { - if unsizing_params.contains(i) { - return Err(Unimplemented); - } + if unsizing_params.contains(i) { + return Err(Unimplemented); } } } diff --git a/compiler/rustc_traits/Cargo.toml b/compiler/rustc_traits/Cargo.toml index 8fdbc3b76b459..8bd9e29629dce 100644 --- a/compiler/rustc_traits/Cargo.toml +++ b/compiler/rustc_traits/Cargo.toml @@ -6,16 +6,15 @@ edition = "2018" [dependencies] tracing = "0.1" -rustc_attr = { path = "../rustc_attr" } rustc_middle = { path = "../rustc_middle" } rustc_data_structures = { path = "../rustc_data_structures" } rustc_hir = { path = "../rustc_hir" } rustc_index = { path = "../rustc_index" } rustc_ast = { path = "../rustc_ast" } rustc_span = { path = "../rustc_span" } -chalk-ir = "0.55.0" -chalk-solve = "0.55.0" -chalk-engine = "0.55.0" +chalk-ir = "0.36.0" +chalk-solve = "0.36.0" +chalk-engine = "0.36.0" smallvec = { version = "1.0", features = ["union", "may_dangle"] } rustc_infer = { path = "../rustc_infer" } rustc_trait_selection = { path = "../rustc_trait_selection" } diff --git a/compiler/rustc_traits/src/chalk/db.rs b/compiler/rustc_traits/src/chalk/db.rs index 916186f4204e2..bb48ed936188b 100644 --- a/compiler/rustc_traits/src/chalk/db.rs +++ b/compiler/rustc_traits/src/chalk/db.rs @@ -10,9 +10,6 @@ use rustc_middle::traits::ChalkRustInterner as RustInterner; use rustc_middle::ty::subst::{InternalSubsts, Subst, SubstsRef}; use rustc_middle::ty::{self, AssocItemContainer, AssocKind, TyCtxt, TypeFoldable}; -use rustc_ast::ast; -use rustc_attr as attr; - use rustc_hir::def_id::DefId; use rustc_span::symbol::sym; @@ -21,6 +18,7 @@ use std::fmt; use std::sync::Arc; use crate::chalk::lowering::{self, LowerInto}; +use rustc_ast::ast; pub struct RustIrDatabase<'tcx> { pub(crate) interner: RustInterner<'tcx>, @@ -207,32 +205,12 @@ impl<'tcx> chalk_solve::RustIrDatabase> for RustIrDatabase<'t fn adt_repr( &self, adt_id: chalk_ir::AdtId>, - ) -> Arc>> { + ) -> chalk_solve::rust_ir::AdtRepr { let adt_def = adt_id.0; - let int = |i| chalk_ir::TyKind::Scalar(chalk_ir::Scalar::Int(i)).intern(&self.interner); - let uint = |i| chalk_ir::TyKind::Scalar(chalk_ir::Scalar::Uint(i)).intern(&self.interner); - Arc::new(chalk_solve::rust_ir::AdtRepr { - c: adt_def.repr.c(), - packed: adt_def.repr.packed(), - int: adt_def.repr.int.map(|i| match i { - attr::IntType::SignedInt(ty) => match ty { - ast::IntTy::Isize => int(chalk_ir::IntTy::Isize), - ast::IntTy::I8 => int(chalk_ir::IntTy::I8), - ast::IntTy::I16 => int(chalk_ir::IntTy::I16), - ast::IntTy::I32 => int(chalk_ir::IntTy::I32), - ast::IntTy::I64 => int(chalk_ir::IntTy::I64), - ast::IntTy::I128 => int(chalk_ir::IntTy::I128), - }, - attr::IntType::UnsignedInt(ty) => match ty { - ast::UintTy::Usize => uint(chalk_ir::UintTy::Usize), - ast::UintTy::U8 => uint(chalk_ir::UintTy::U8), - ast::UintTy::U16 => uint(chalk_ir::UintTy::U16), - ast::UintTy::U32 => uint(chalk_ir::UintTy::U32), - ast::UintTy::U64 => uint(chalk_ir::UintTy::U64), - ast::UintTy::U128 => uint(chalk_ir::UintTy::U128), - }, - }), - }) + chalk_solve::rust_ir::AdtRepr { + repr_c: adt_def.repr.c(), + repr_packed: adt_def.repr.packed(), + } } fn fn_def_datum( @@ -338,11 +316,7 @@ impl<'tcx> chalk_solve::RustIrDatabase> for RustIrDatabase<'t let self_ty = self_ty.fold_with(&mut regions_substitutor); let lowered_ty = self_ty.lower_into(&self.interner); - parameters[0].assert_ty_ref(&self.interner).could_match( - &self.interner, - self.unification_database(), - &lowered_ty, - ) + parameters[0].assert_ty_ref(&self.interner).could_match(&self.interner, &lowered_ty) }); let impls = matched_impls.map(chalk_ir::ImplId).collect(); @@ -567,7 +541,6 @@ impl<'tcx> chalk_solve::RustIrDatabase> for RustIrDatabase<'t Unsize => lang_items.unsize_trait(), Unpin => lang_items.unpin_trait(), CoerceUnsized => lang_items.coerce_unsized_trait(), - DiscriminantKind => lang_items.discriminant_kind_trait(), }; def_id.map(chalk_ir::TraitId) } @@ -613,7 +586,7 @@ impl<'tcx> chalk_solve::RustIrDatabase> for RustIrDatabase<'t let sig = &substs.as_slice(&self.interner)[substs.len(&self.interner) - 2]; match sig.assert_ty_ref(&self.interner).kind(&self.interner) { chalk_ir::TyKind::Function(f) => { - let substitution = f.substitution.0.as_slice(&self.interner); + let substitution = f.substitution.as_slice(&self.interner); let return_type = substitution.last().unwrap().assert_ty_ref(&self.interner).clone(); // Closure arguments are tupled @@ -671,51 +644,6 @@ impl<'tcx> chalk_solve::RustIrDatabase> for RustIrDatabase<'t ) -> Arc>> { unimplemented!() } - - fn unification_database(&self) -> &dyn chalk_ir::UnificationDatabase> { - self - } - - fn discriminant_type( - &self, - _: chalk_ir::Ty>, - ) -> chalk_ir::Ty> { - unimplemented!() - } -} - -impl<'tcx> chalk_ir::UnificationDatabase> for RustIrDatabase<'tcx> { - fn fn_def_variance( - &self, - def_id: chalk_ir::FnDefId>, - ) -> chalk_ir::Variances> { - let variances = self.interner.tcx.variances_of(def_id.0); - chalk_ir::Variances::from_iter( - &self.interner, - variances.iter().map(|v| match v { - ty::Variance::Invariant => chalk_ir::Variance::Invariant, - ty::Variance::Covariant => chalk_ir::Variance::Covariant, - ty::Variance::Contravariant => chalk_ir::Variance::Contravariant, - ty::Variance::Bivariant => unimplemented!(), - }), - ) - } - - fn adt_variance( - &self, - def_id: chalk_ir::AdtId>, - ) -> chalk_ir::Variances> { - let variances = self.interner.tcx.variances_of(def_id.0.did); - chalk_ir::Variances::from_iter( - &self.interner, - variances.iter().map(|v| match v { - ty::Variance::Invariant => chalk_ir::Variance::Invariant, - ty::Variance::Covariant => chalk_ir::Variance::Covariant, - ty::Variance::Contravariant => chalk_ir::Variance::Contravariant, - ty::Variance::Bivariant => unimplemented!(), - }), - ) - } } /// Creates a `InternalSubsts` that maps each generic parameter to a higher-ranked diff --git a/compiler/rustc_traits/src/chalk/lowering.rs b/compiler/rustc_traits/src/chalk/lowering.rs index 7d3589c4b6bd8..2a1a3f57e2313 100644 --- a/compiler/rustc_traits/src/chalk/lowering.rs +++ b/compiler/rustc_traits/src/chalk/lowering.rs @@ -287,12 +287,12 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty>> for Ty<'tcx> { chalk_ir::TyKind::Function(chalk_ir::FnPointer { num_binders: binders.len(interner), sig: sig.lower_into(interner), - substitution: chalk_ir::FnSubst(chalk_ir::Substitution::from_iter( + substitution: chalk_ir::Substitution::from_iter( interner, inputs_and_outputs.iter().map(|ty| { chalk_ir::GenericArgData::Ty(ty.lower_into(interner)).intern(interner) }), - )), + ), }) } ty::Dynamic(predicates, region) => chalk_ir::TyKind::Dyn(chalk_ir::DynTy { @@ -478,10 +478,6 @@ impl<'tcx> LowerInto<'tcx, Region<'tcx>> for &chalk_ir::Lifetime ty::RegionKind::ReStatic, chalk_ir::LifetimeData::Phantom(_, _) => unimplemented!(), - chalk_ir::LifetimeData::Empty(ui) => { - ty::RegionKind::ReEmpty(ty::UniverseIndex::from_usize(ui.counter)) - } - chalk_ir::LifetimeData::Erased => ty::RegionKind::ReErased, }; interner.tcx.mk_region(kind) } diff --git a/compiler/rustc_traits/src/chalk/mod.rs b/compiler/rustc_traits/src/chalk/mod.rs index d98f18182c843..bd2f87f70a2f1 100644 --- a/compiler/rustc_traits/src/chalk/mod.rs +++ b/compiler/rustc_traits/src/chalk/mod.rs @@ -105,40 +105,14 @@ crate fn evaluate_goal<'tcx>( // really need this and so it's really minimal. // Right now, we also treat a `Unique` solution the same as // `Ambig(Definite)`. This really isn't right. - let make_solution = |subst: chalk_ir::Substitution<_>, - binders: chalk_ir::CanonicalVarKinds<_>| { - use rustc_middle::infer::canonical::CanonicalVarInfo; - + let make_solution = |subst: chalk_ir::Substitution<_>| { let mut var_values: IndexVec> = IndexVec::new(); subst.as_slice(&interner).iter().for_each(|p| { var_values.push(p.lower_into(&interner)); }); - let variables: Vec<_> = binders - .iter(&interner) - .map(|var| { - let kind = match var.kind { - chalk_ir::VariableKind::Ty(ty_kind) => CanonicalVarKind::Ty(match ty_kind { - chalk_ir::TyVariableKind::General => CanonicalTyVarKind::General( - ty::UniverseIndex::from_usize(var.skip_kind().counter), - ), - chalk_ir::TyVariableKind::Integer => CanonicalTyVarKind::Int, - chalk_ir::TyVariableKind::Float => CanonicalTyVarKind::Float, - }), - chalk_ir::VariableKind::Lifetime => CanonicalVarKind::Region( - ty::UniverseIndex::from_usize(var.skip_kind().counter), - ), - chalk_ir::VariableKind::Const(_) => CanonicalVarKind::Const( - ty::UniverseIndex::from_usize(var.skip_kind().counter), - ), - }; - CanonicalVarInfo { kind } - }) - .collect(); - let max_universe = - binders.iter(&interner).map(|v| v.skip_kind().counter).max().unwrap_or(0); let sol = Canonical { - max_universe: ty::UniverseIndex::from_usize(max_universe), - variables: tcx.intern_canonical_var_infos(&variables), + max_universe: ty::UniverseIndex::from_usize(0), + variables: obligation.variables.clone(), value: QueryResponse { var_values: CanonicalVarValues { var_values }, region_constraints: QueryRegionConstraints::default(), @@ -152,13 +126,11 @@ crate fn evaluate_goal<'tcx>( .map(|s| match s { Solution::Unique(subst) => { // FIXME(chalk): handle constraints - make_solution(subst.value.subst, subst.binders) + make_solution(subst.value.subst) } Solution::Ambig(guidance) => { match guidance { - chalk_solve::Guidance::Definite(subst) => { - make_solution(subst.value, subst.binders) - } + chalk_solve::Guidance::Definite(subst) => make_solution(subst.value), chalk_solve::Guidance::Suggested(_) => unimplemented!(), chalk_solve::Guidance::Unknown => { // chalk_fulfill doesn't use the var_values here, so diff --git a/compiler/rustc_typeck/src/astconv/generics.rs b/compiler/rustc_typeck/src/astconv/generics.rs index 67e37ca8d8e49..0797c95636260 100644 --- a/compiler/rustc_typeck/src/astconv/generics.rs +++ b/compiler/rustc_typeck/src/astconv/generics.rs @@ -496,15 +496,14 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { ) -> bool { let explicit = !seg.infer_args; let impl_trait = generics.params.iter().any(|param| { - matches!( - param.kind, - ty::GenericParamDefKind::Type { - synthetic: Some( - hir::SyntheticTyParamKind::ImplTrait | hir::SyntheticTyParamKind::FromAttr, + matches!(param.kind, ty::GenericParamDefKind::Type { + synthetic: + Some( + hir::SyntheticTyParamKind::ImplTrait + | hir::SyntheticTyParamKind::FromAttr, ), - .. - } - ) + .. + }) }); if explicit && impl_trait { diff --git a/compiler/rustc_typeck/src/astconv/mod.rs b/compiler/rustc_typeck/src/astconv/mod.rs index 244eba8ad5e02..437813ea41bd5 100644 --- a/compiler/rustc_typeck/src/astconv/mod.rs +++ b/compiler/rustc_typeck/src/astconv/mod.rs @@ -49,10 +49,9 @@ pub trait AstConv<'tcx> { fn default_constness_for_trait_bounds(&self) -> Constness; - /// Returns predicates in scope of the form `X: Foo`, where `X` - /// is a type parameter `X` with the given id `def_id` and T - /// matches `assoc_name`. This is a subset of the full set of - /// predicates. + /// Returns predicates in scope of the form `X: Foo`, where `X` is + /// a type parameter `X` with the given id `def_id`. This is a + /// subset of the full set of predicates. /// /// This is used for one specific purpose: resolving "short-hand" /// associated type references like `T::Item`. In principle, we @@ -61,12 +60,7 @@ pub trait AstConv<'tcx> { /// but this can lead to cycle errors. The problem is that we have /// to do this resolution *in order to create the predicates in /// the first place*. Hence, we have this "special pass". - fn get_type_parameter_bounds( - &self, - span: Span, - def_id: DefId, - assoc_name: Ident, - ) -> ty::GenericPredicates<'tcx>; + fn get_type_parameter_bounds(&self, span: Span, def_id: DefId) -> ty::GenericPredicates<'tcx>; /// Returns the lifetime to use when a lifetime is omitted (and not elided). fn re_infer(&self, param: Option<&ty::GenericParamDef>, span: Span) @@ -118,15 +112,12 @@ pub enum SizedByDefault { No, } -#[derive(Debug)] struct ConvertedBinding<'a, 'tcx> { item_name: Ident, kind: ConvertedBindingKind<'a, 'tcx>, - gen_args: &'a GenericArgs<'a>, span: Span, } -#[derive(Debug)] enum ConvertedBindingKind<'a, 'tcx> { Equality(Ty<'tcx>), Constraint(&'a [hir::GenericBound<'a>]), @@ -332,7 +323,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { let tcx = self.tcx(); let generics = tcx.generics_of(def_id); - debug!("generics: {:?}", generics); if generics.has_self { if generics.parent.is_some() { @@ -567,12 +557,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { ConvertedBindingKind::Constraint(bounds) } }; - ConvertedBinding { - item_name: binding.ident, - kind, - gen_args: binding.gen_args, - span: binding.span, - } + ConvertedBinding { item_name: binding.ident, kind, span: binding.span } }) .collect(); @@ -798,7 +783,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { } // Returns `true` if a bounds list includes `?Sized`. - pub fn is_unsized(&self, ast_bounds: &[&hir::GenericBound<'_>], span: Span) -> bool { + pub fn is_unsized(&self, ast_bounds: &[hir::GenericBound<'_>], span: Span) -> bool { let tcx = self.tcx(); // Try to find an unbound in bounds. @@ -856,7 +841,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { fn add_bounds( &self, param_ty: Ty<'tcx>, - ast_bounds: &[&hir::GenericBound<'_>], + ast_bounds: &[hir::GenericBound<'_>], bounds: &mut Bounds<'tcx>, ) { let constness = self.default_constness_for_trait_bounds(); @@ -871,7 +856,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { hir::GenericBound::Trait(_, hir::TraitBoundModifier::Maybe) => {} hir::GenericBound::LangItemTrait(lang_item, span, hir_id, args) => self .instantiate_lang_item_trait_ref( - *lang_item, *span, *hir_id, args, param_ty, bounds, + lang_item, span, hir_id, args, param_ty, bounds, ), hir::GenericBound::Outlives(ref l) => bounds .region_bounds @@ -902,42 +887,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { ast_bounds: &[hir::GenericBound<'_>], sized_by_default: SizedByDefault, span: Span, - ) -> Bounds<'tcx> { - let ast_bounds: Vec<_> = ast_bounds.iter().collect(); - self.compute_bounds_inner(param_ty, &ast_bounds, sized_by_default, span) - } - - /// Convert the bounds in `ast_bounds` that refer to traits which define an associated type - /// named `assoc_name` into ty::Bounds. Ignore the rest. - pub fn compute_bounds_that_match_assoc_type( - &self, - param_ty: Ty<'tcx>, - ast_bounds: &[hir::GenericBound<'_>], - sized_by_default: SizedByDefault, - span: Span, - assoc_name: Ident, - ) -> Bounds<'tcx> { - let mut result = Vec::new(); - - for ast_bound in ast_bounds { - if let Some(trait_ref) = ast_bound.trait_ref() { - if let Some(trait_did) = trait_ref.trait_def_id() { - if self.tcx().trait_may_define_assoc_type(trait_did, assoc_name) { - result.push(ast_bound); - } - } - } - } - - self.compute_bounds_inner(param_ty, &result, sized_by_default, span) - } - - fn compute_bounds_inner( - &self, - param_ty: Ty<'tcx>, - ast_bounds: &[&hir::GenericBound<'_>], - sized_by_default: SizedByDefault, - span: Span, ) -> Bounds<'tcx> { let mut bounds = Bounds::default(); @@ -969,28 +918,61 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { dup_bindings: &mut FxHashMap, path_span: Span, ) -> Result<(), ErrorReported> { - // Given something like `U: SomeTrait`, we want to produce a - // predicate like `::T = X`. This is somewhat - // subtle in the event that `T` is defined in a supertrait of - // `SomeTrait`, because in that case we need to upcast. - // - // That is, consider this case: - // - // ``` - // trait SubTrait: SuperTrait { } - // trait SuperTrait { type T; } - // - // ... B: SubTrait ... - // ``` - // - // We want to produce `>::T == foo`. - - debug!( - "add_predicates_for_ast_type_binding(hir_ref_id {:?}, trait_ref {:?}, binding {:?}, bounds {:?}", - hir_ref_id, trait_ref, binding, bounds - ); let tcx = self.tcx(); + if !speculative { + // Given something like `U: SomeTrait`, we want to produce a + // predicate like `::T = X`. This is somewhat + // subtle in the event that `T` is defined in a supertrait of + // `SomeTrait`, because in that case we need to upcast. + // + // That is, consider this case: + // + // ``` + // trait SubTrait: SuperTrait { } + // trait SuperTrait { type T; } + // + // ... B: SubTrait ... + // ``` + // + // We want to produce `>::T == foo`. + + // Find any late-bound regions declared in `ty` that are not + // declared in the trait-ref. These are not well-formed. + // + // Example: + // + // for<'a> ::Item = &'a str // <-- 'a is bad + // for<'a> >::Output = &'a str // <-- 'a is ok + if let ConvertedBindingKind::Equality(ty) = binding.kind { + let late_bound_in_trait_ref = + tcx.collect_constrained_late_bound_regions(&trait_ref); + let late_bound_in_ty = + tcx.collect_referenced_late_bound_regions(&ty::Binder::bind(ty)); + debug!("late_bound_in_trait_ref = {:?}", late_bound_in_trait_ref); + debug!("late_bound_in_ty = {:?}", late_bound_in_ty); + + // FIXME: point at the type params that don't have appropriate lifetimes: + // struct S1 Fn(&i32, &i32) -> &'a i32>(F); + // ---- ---- ^^^^^^^ + self.validate_late_bound_regions( + late_bound_in_trait_ref, + late_bound_in_ty, + |br_name| { + struct_span_err!( + tcx.sess, + binding.span, + E0582, + "binding for associated type `{}` references {}, \ + which does not appear in the trait input types", + binding.item_name, + br_name + ) + }, + ); + } + } + let candidate = if self.trait_defines_associated_type_named(trait_ref.def_id(), binding.item_name) { // Simple case: X is defined in the current trait. @@ -1048,72 +1030,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { .or_insert(binding.span); } - // Include substitutions for generic parameters of associated types - let projection_ty = candidate.map_bound(|trait_ref| { - let item_segment = hir::PathSegment { - ident: assoc_ty.ident, - hir_id: None, - res: None, - args: Some(binding.gen_args), - infer_args: false, - }; - - let substs_trait_ref_and_assoc_item = self.create_substs_for_associated_item( - tcx, - path_span, - assoc_ty.def_id, - &item_segment, - trait_ref.substs, - ); - - debug!( - "add_predicates_for_ast_type_binding: substs for trait-ref and assoc_item: {:?}", - substs_trait_ref_and_assoc_item - ); - - ty::ProjectionTy { - item_def_id: assoc_ty.def_id, - substs: substs_trait_ref_and_assoc_item, - } - }); - - if !speculative { - // Find any late-bound regions declared in `ty` that are not - // declared in the trait-ref or assoc_ty. These are not well-formed. - // - // Example: - // - // for<'a> ::Item = &'a str // <-- 'a is bad - // for<'a> >::Output = &'a str // <-- 'a is ok - if let ConvertedBindingKind::Equality(ty) = binding.kind { - let late_bound_in_trait_ref = - tcx.collect_constrained_late_bound_regions(&projection_ty); - let late_bound_in_ty = - tcx.collect_referenced_late_bound_regions(&ty::Binder::bind(ty)); - debug!("late_bound_in_trait_ref = {:?}", late_bound_in_trait_ref); - debug!("late_bound_in_ty = {:?}", late_bound_in_ty); - - // FIXME: point at the type params that don't have appropriate lifetimes: - // struct S1 Fn(&i32, &i32) -> &'a i32>(F); - // ---- ---- ^^^^^^^ - self.validate_late_bound_regions( - late_bound_in_trait_ref, - late_bound_in_ty, - |br_name| { - struct_span_err!( - tcx.sess, - binding.span, - E0582, - "binding for associated type `{}` references {}, \ - which does not appear in the trait input types", - binding.item_name, - br_name - ) - }, - ); - } - } - match binding.kind { ConvertedBindingKind::Equality(ref ty) => { // "Desugar" a constraint like `T: Iterator` this to @@ -1121,12 +1037,13 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { // // `::Item = u32` bounds.projection_bounds.push(( - projection_ty.map_bound(|projection_ty| { - debug!( - "add_predicates_for_ast_type_binding: projection_ty {:?}, substs: {:?}", - projection_ty, projection_ty.substs - ); - ty::ProjectionPredicate { projection_ty, ty } + candidate.map_bound(|trait_ref| ty::ProjectionPredicate { + projection_ty: ty::ProjectionTy::from_ref_and_name( + tcx, + trait_ref, + binding.item_name, + ), + ty, }), binding.span, )); @@ -1138,10 +1055,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { // // Calling `skip_binder` is okay, because `add_bounds` expects the `param_ty` // parameter to have a skipped binder. - let param_ty = - tcx.mk_projection(assoc_ty.def_id, projection_ty.skip_binder().substs); - let ast_bounds: Vec<_> = ast_bounds.iter().collect(); - self.add_bounds(param_ty, &ast_bounds, bounds); + let param_ty = tcx.mk_projection(assoc_ty.def_id, candidate.skip_binder().substs); + self.add_bounds(param_ty, ast_bounds, bounds); } } Ok(()) @@ -1456,9 +1371,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { ty_param_def_id, assoc_name, span, ); - let predicates = &self - .get_type_parameter_bounds(span, ty_param_def_id.to_def_id(), assoc_name) - .predicates; + let predicates = + &self.get_type_parameter_bounds(span, ty_param_def_id.to_def_id()).predicates; debug!("find_bound_for_assoc_item: predicates={:#?}", predicates); @@ -1466,14 +1380,12 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { let param_name = tcx.hir().ty_param_name(param_hir_id); self.one_bound_for_assoc_type( || { - traits::transitive_bounds_that_define_assoc_type( + traits::transitive_bounds( tcx, predicates.iter().filter_map(|(p, _)| { p.to_opt_poly_trait_ref().map(|trait_ref| trait_ref.value) }), - assoc_name, ) - .into_iter() }, || param_name.to_string(), assoc_name, diff --git a/compiler/rustc_typeck/src/check/check.rs b/compiler/rustc_typeck/src/check/check.rs index 5f27355f0bab1..47361092a5c50 100644 --- a/compiler/rustc_typeck/src/check/check.rs +++ b/compiler/rustc_typeck/src/check/check.rs @@ -12,7 +12,6 @@ use rustc_hir::{ItemKind, Node}; use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind}; use rustc_infer::infer::{RegionVariableOrigin, TyCtxtInferExt}; use rustc_middle::ty::fold::TypeFoldable; -use rustc_middle::ty::layout::MAX_SIMD_LANES; use rustc_middle::ty::subst::GenericArgKind; use rustc_middle::ty::util::{Discr, IntTypeExt, Representability}; use rustc_middle::ty::{self, ParamEnv, RegionKind, ToPredicate, Ty, TyCtxt}; @@ -43,17 +42,6 @@ pub(super) fn check_abi(tcx: TyCtxt<'_>, span: Span, abi: Abi) { ) .emit() } - - // This ABI is only allowed on function pointers - if abi == Abi::CCmseNonSecureCall { - struct_span_err!( - tcx.sess, - span, - E0781, - "the `\"C-cmse-nonsecure-call\"` ABI is only allowed on function pointers." - ) - .emit() - } } /// Helper used for fns and closures. Does the grungy work of checking a function @@ -204,6 +192,7 @@ pub(super) fn check_fn<'a, 'tcx>( // possible cases. fcx.check_expr(&body.value); fcx.require_type_is_sized(declared_ret_ty, decl.output.span(), traits::SizedReturnType); + tcx.sess.delay_span_bug(decl.output.span(), "`!Sized` return type"); } else { fcx.require_type_is_sized(declared_ret_ty, decl.output.span(), traits::SizedReturnType); fcx.check_return_expr(&body.value); @@ -1135,38 +1124,6 @@ pub fn check_simd(tcx: TyCtxt<'_>, sp: Span, def_id: LocalDefId) { .emit(); return; } - - let len = if let ty::Array(_ty, c) = e.kind() { - c.try_eval_usize(tcx, tcx.param_env(def.did)) - } else { - Some(fields.len() as u64) - }; - if let Some(len) = len { - if len == 0 { - struct_span_err!(tcx.sess, sp, E0075, "SIMD vector cannot be empty").emit(); - return; - } else if !len.is_power_of_two() { - struct_span_err!( - tcx.sess, - sp, - E0075, - "SIMD vector length must be a power of two" - ) - .emit(); - return; - } else if len > MAX_SIMD_LANES { - struct_span_err!( - tcx.sess, - sp, - E0075, - "SIMD vector cannot have more than {} elements", - MAX_SIMD_LANES, - ) - .emit(); - return; - } - } - match e.kind() { ty::Param(_) => { /* struct(T, T, T, T) is ok */ } _ if e.is_machine() => { /* struct(u8, u8, u8, u8) is ok */ } diff --git a/compiler/rustc_typeck/src/check/expr.rs b/compiler/rustc_typeck/src/check/expr.rs index 9692b0524e7ec..04c83a7665caa 100644 --- a/compiler/rustc_typeck/src/check/expr.rs +++ b/compiler/rustc_typeck/src/check/expr.rs @@ -285,9 +285,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { self.check_expr_eq_type(&e, ty); ty } - ExprKind::If(cond, then_expr, opt_else_expr) => { - self.check_then_else(cond, then_expr, opt_else_expr, expr.span, expected) - } + ExprKind::If(ref cond, ref then_expr, ref opt_else_expr) => self.check_then_else( + &cond, + then_expr, + opt_else_expr.as_ref().map(|e| &**e), + expr.span, + expected, + ), ExprKind::DropTemps(ref e) => self.check_expr_with_expectation(e, expected), ExprKind::Array(ref args) => self.check_expr_array(args, expected, expr), ExprKind::ConstBlock(ref anon_const) => self.to_const(anon_const).ty, @@ -1456,33 +1460,28 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ), ); err.span_label(field.ident.span, "field does not exist"); - err.span_suggestion( + err.span_label( ty_span, - &format!( - "`{adt}::{variant}` is a tuple {kind_name}, use the appropriate syntax", - adt = ty, - variant = variant.ident, - ), format!( - "{adt}::{variant}(/* fields */)", + "`{adt}::{variant}` is a tuple {kind_name}, \ + use the appropriate syntax: `{adt}::{variant}(/* fields */)`", adt = ty, variant = variant.ident, + kind_name = kind_name ), - Applicability::HasPlaceholders, ); } _ => { err.span_label(variant.ident.span, format!("`{adt}` defined here", adt = ty)); err.span_label(field.ident.span, "field does not exist"); - err.span_suggestion( + err.span_label( ty_span, - &format!( - "`{adt}` is a tuple {kind_name}, use the appropriate syntax", + format!( + "`{adt}` is a tuple {kind_name}, \ + use the appropriate syntax: `{adt}(/* fields */)`", adt = ty, - kind_name = kind_name, + kind_name = kind_name ), - format!("{adt}(/* fields */)", adt = ty), - Applicability::HasPlaceholders, ); } }, @@ -1975,7 +1974,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { field_path.push(candidate_field.ident.normalize_to_macros_2_0()); let field_ty = candidate_field.ty(self.tcx, subst); - if let Some((nested_fields, subst)) = self.get_field_candidates(span, &field_ty) { + if let Some((nested_fields, _)) = self.get_field_candidates(span, &field_ty) { for field in nested_fields.iter() { let ident = field.ident.normalize_to_macros_2_0(); if ident == target_field { diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs index bc1a07801ae87..ed48a0bc801cf 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs @@ -274,13 +274,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } let autoborrow_mut = adj.iter().any(|adj| { - matches!( - adj, - &Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(_, AutoBorrowMutability::Mut { .. })), - .. - } - ) + matches!(adj, &Adjustment { + kind: Adjust::Borrow(AutoBorrow::Ref(_, AutoBorrowMutability::Mut { .. })), + .. + }) }); match self.typeck_results.borrow_mut().adjustments_mut().entry(expr.hir_id) { diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/mod.rs b/compiler/rustc_typeck/src/check/fn_ctxt/mod.rs index 4da4835f7cfbb..e9223f700dcc7 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/mod.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/mod.rs @@ -20,7 +20,6 @@ use rustc_middle::ty::fold::TypeFoldable; use rustc_middle::ty::subst::GenericArgKind; use rustc_middle::ty::{self, Const, Ty, TyCtxt}; use rustc_session::Session; -use rustc_span::symbol::Ident; use rustc_span::{self, Span}; use rustc_trait_selection::traits::{ObligationCause, ObligationCauseCode}; @@ -184,12 +183,7 @@ impl<'a, 'tcx> AstConv<'tcx> for FnCtxt<'a, 'tcx> { } } - fn get_type_parameter_bounds( - &self, - _: Span, - def_id: DefId, - _: Ident, - ) -> ty::GenericPredicates<'tcx> { + fn get_type_parameter_bounds(&self, _: Span, def_id: DefId) -> ty::GenericPredicates<'tcx> { let tcx = self.tcx; let hir_id = tcx.hir().local_def_id_to_hir_id(def_id.expect_local()); let item_id = tcx.hir().ty_param_owner(hir_id); diff --git a/compiler/rustc_typeck/src/check/mod.rs b/compiler/rustc_typeck/src/check/mod.rs index 229127e95d93c..dc3e3b4e73839 100644 --- a/compiler/rustc_typeck/src/check/mod.rs +++ b/compiler/rustc_typeck/src/check/mod.rs @@ -838,7 +838,7 @@ fn missing_items_err( // Obtain the level of indentation ending in `sugg_sp`. let indentation = tcx.sess.source_map().span_to_margin(sugg_sp).unwrap_or(0); // Make the whitespace that will make the suggestion have the right indentation. - let padding: String = std::iter::repeat(" ").take(indentation).collect(); + let padding: String = (0..indentation).map(|_| " ").collect(); for trait_item in missing_items { let snippet = suggestion_signature(&trait_item, tcx); diff --git a/compiler/rustc_typeck/src/check/upvar.rs b/compiler/rustc_typeck/src/check/upvar.rs index 04a9e65e6647d..f039445bf7780 100644 --- a/compiler/rustc_typeck/src/check/upvar.rs +++ b/compiler/rustc_typeck/src/check/upvar.rs @@ -30,7 +30,6 @@ //! then mean that all later passes would have to check for these figments //! and report an error, and it just seems like more mess in the end.) -use super::writeback::Resolver; use super::FnCtxt; use crate::expr_use_visitor as euv; @@ -41,9 +40,7 @@ use rustc_hir::def_id::LocalDefId; use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_infer::infer::UpvarRegion; use rustc_middle::hir::place::{Place, PlaceBase, PlaceWithHirId, ProjectionKind}; -use rustc_middle::ty::fold::TypeFoldable; -use rustc_middle::ty::{self, Ty, TyCtxt, TypeckResults, UpvarSubsts}; -use rustc_session::lint; +use rustc_middle::ty::{self, Ty, TyCtxt, UpvarSubsts}; use rustc_span::sym; use rustc_span::{MultiSpan, Span, Symbol}; @@ -58,11 +55,6 @@ enum PlaceAncestryRelation { Divergent, } -/// Intermediate format to store a captured `Place` and associated `ty::CaptureInfo` -/// during capture analysis. Information in this map feeds into the minimum capture -/// analysis pass. -type InferredCaptureInformation<'tcx> = FxIndexMap, ty::CaptureInfo<'tcx>>; - impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn closure_analyze(&self, body: &'tcx hir::Body<'tcx>) { InferBorrowKindVisitor { fcx: self }.visit_body(body); @@ -100,7 +92,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &self, closure_hir_id: hir::HirId, span: Span, - body: &'tcx hir::Body<'tcx>, + body: &hir::Body<'_>, capture_clause: hir::CaptureBy, ) { debug!("analyze_closure(id={:?}, body.id={:?})", closure_hir_id, body.id()); @@ -132,6 +124,28 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let local_def_id = closure_def_id.expect_local(); + let mut capture_information: FxIndexMap, ty::CaptureInfo<'tcx>> = + Default::default(); + if !self.tcx.features().capture_disjoint_fields { + if let Some(upvars) = self.tcx.upvars_mentioned(closure_def_id) { + for (&var_hir_id, _) in upvars.iter() { + let place = self.place_for_root_variable(local_def_id, var_hir_id); + + debug!("seed place {:?}", place); + + let upvar_id = ty::UpvarId::new(var_hir_id, local_def_id); + let capture_kind = self.init_capture_kind(capture_clause, upvar_id, span); + let info = ty::CaptureInfo { + capture_kind_expr_id: None, + path_expr_id: None, + capture_kind, + }; + + capture_information.insert(place, info); + } + } + } + let body_owner_def_id = self.tcx.hir().body_owner_def_id(body.id()); assert_eq!(body_owner_def_id.to_def_id(), closure_def_id); let mut delegate = InferBorrowKind { @@ -141,7 +155,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { capture_clause, current_closure_kind: ty::ClosureKind::LATTICE_BOTTOM, current_origin: None, - capture_information: Default::default(), + capture_information, }; euv::ExprUseVisitor::new( &mut delegate, @@ -158,40 +172,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); self.log_capture_analysis_first_pass(closure_def_id, &delegate.capture_information, span); - self.compute_min_captures(closure_def_id, delegate.capture_information); - - let closure_hir_id = self.tcx.hir().local_def_id_to_hir_id(local_def_id); - if should_do_migration_analysis(self.tcx, closure_hir_id) { - self.perform_2229_migration_anaysis(closure_def_id, capture_clause, span, body); - } - - // We now fake capture information for all variables that are mentioned within the closure - // We do this after handling migrations so that min_captures computes before - if !self.tcx.features().capture_disjoint_fields { - let mut capture_information: InferredCaptureInformation<'tcx> = Default::default(); - - if let Some(upvars) = self.tcx.upvars_mentioned(closure_def_id) { - for var_hir_id in upvars.keys() { - let place = self.place_for_root_variable(local_def_id, *var_hir_id); - - debug!("seed place {:?}", place); - - let upvar_id = ty::UpvarId::new(*var_hir_id, local_def_id); - let capture_kind = self.init_capture_kind(capture_clause, upvar_id, span); - let fake_info = ty::CaptureInfo { - capture_kind_expr_id: None, - path_expr_id: None, - capture_kind, - }; - - capture_information.insert(place, fake_info); - } - } - - // This will update the min captures based on this new fake information. - self.compute_min_captures(closure_def_id, capture_information); - } - if let Some(closure_substs) = infer_kind { // Unify the (as yet unbound) type variable in the closure // substs with the kind we inferred. @@ -217,6 +197,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } + self.compute_min_captures(closure_def_id, delegate); self.log_closure_min_capture_info(closure_def_id, span); self.min_captures_to_closure_captures_bridge(closure_def_id); @@ -363,10 +344,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Places (and corresponding capture kind) that we need to keep track of to support all /// the required captured paths. /// - /// - /// Note: If this function is called multiple times for the same closure, it will update - /// the existing min_capture map that is stored in TypeckResults. - /// /// Eg: /// ```rust,no_run /// struct Point { x: i32, y: i32 } @@ -431,18 +408,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn compute_min_captures( &self, closure_def_id: DefId, - capture_information: InferredCaptureInformation<'tcx>, + inferred_info: InferBorrowKind<'_, 'tcx>, ) { - if capture_information.is_empty() { - return; - } - - let mut typeck_results = self.typeck_results.borrow_mut(); + let mut root_var_min_capture_list: ty::RootVariableMinCaptureList<'_> = Default::default(); - let mut root_var_min_capture_list = - typeck_results.closure_min_captures.remove(&closure_def_id).unwrap_or_default(); - - for (place, capture_info) in capture_information.into_iter() { + for (place, capture_info) in inferred_info.capture_information.into_iter() { let var_hir_id = match place.base { PlaceBase::Upvar(upvar_id) => upvar_id.var_path.hir_id, base => bug!("Expected upvar, found={:?}", base), @@ -452,7 +422,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let min_cap_list = match root_var_min_capture_list.get_mut(&var_hir_id) { None => { - let mutability = self.determine_capture_mutability(&typeck_results, &place); + let mutability = self.determine_capture_mutability(&place); let min_cap_list = vec![ty::CapturedPlace { place, info: capture_info, mutability }]; root_var_min_capture_list.insert(var_hir_id, min_cap_list); @@ -517,7 +487,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Only need to insert when we don't have an ancestor in the existing min capture list if !ancestor_found { - let mutability = self.determine_capture_mutability(&typeck_results, &place); + let mutability = self.determine_capture_mutability(&place); let captured_place = ty::CapturedPlace { place, info: updated_capture_info, mutability }; min_cap_list.push(captured_place); @@ -525,121 +495,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } debug!("For closure={:?}, min_captures={:#?}", closure_def_id, root_var_min_capture_list); - typeck_results.closure_min_captures.insert(closure_def_id, root_var_min_capture_list); - } - - /// Perform the migration analysis for RFC 2229, and emit lint - /// `disjoint_capture_drop_reorder` if needed. - fn perform_2229_migration_anaysis( - &self, - closure_def_id: DefId, - capture_clause: hir::CaptureBy, - span: Span, - body: &'tcx hir::Body<'tcx>, - ) { - let need_migrations = self.compute_2229_migrations_first_pass( - closure_def_id, - span, - capture_clause, - body, - self.typeck_results.borrow().closure_min_captures.get(&closure_def_id), - ); - - if !need_migrations.is_empty() { - let need_migrations_hir_id = need_migrations.iter().map(|m| m.0).collect::>(); - - let migrations_text = migration_suggestion_for_2229(self.tcx, &need_migrations_hir_id); - - let local_def_id = closure_def_id.expect_local(); - let closure_hir_id = self.tcx.hir().local_def_id_to_hir_id(local_def_id); - self.tcx.struct_span_lint_hir( - lint::builtin::DISJOINT_CAPTURE_DROP_REORDER, - closure_hir_id, - span, - |lint| { - let mut diagnostics_builder = lint.build( - "drop order affected for closure because of `capture_disjoint_fields`", - ); - diagnostics_builder.note(&migrations_text); - diagnostics_builder.emit(); - }, - ); - } - } - - /// Figures out the list of root variables (and their types) that aren't completely - /// captured by the closure when `capture_disjoint_fields` is enabled and drop order of - /// some path starting at that root variable **might** be affected. - /// - /// The output list would include a root variable if: - /// - It would have been moved into the closure when `capture_disjoint_fields` wasn't - /// enabled, **and** - /// - It wasn't completely captured by the closure, **and** - /// - The type of the root variable needs Drop. - fn compute_2229_migrations_first_pass( - &self, - closure_def_id: DefId, - closure_span: Span, - closure_clause: hir::CaptureBy, - body: &'tcx hir::Body<'tcx>, - min_captures: Option<&ty::RootVariableMinCaptureList<'tcx>>, - ) -> Vec<(hir::HirId, Ty<'tcx>)> { - fn resolve_ty>( - fcx: &FnCtxt<'_, 'tcx>, - span: Span, - body: &'tcx hir::Body<'tcx>, - ty: T, - ) -> T { - let mut resolver = Resolver::new(fcx, &span, body); - ty.fold_with(&mut resolver) - } - - let upvars = if let Some(upvars) = self.tcx.upvars_mentioned(closure_def_id) { - upvars - } else { - return vec![]; - }; - - let mut need_migrations = Vec::new(); - - for (&var_hir_id, _) in upvars.iter() { - let ty = resolve_ty(self, closure_span, body, self.node_ty(var_hir_id)); - - if !ty.needs_drop(self.tcx, self.tcx.param_env(closure_def_id.expect_local())) { - continue; - } - let root_var_min_capture_list = if let Some(root_var_min_capture_list) = - min_captures.and_then(|m| m.get(&var_hir_id)) - { - root_var_min_capture_list - } else { - // The upvar is mentioned within the closure but no path starting from it is - // used. - - match closure_clause { - // Only migrate if closure is a move closure - hir::CaptureBy::Value => need_migrations.push((var_hir_id, ty)), - - hir::CaptureBy::Ref => {} - } - - continue; - }; - - let is_moved = root_var_min_capture_list - .iter() - .any(|capture| matches!(capture.info.capture_kind, ty::UpvarCapture::ByValue(_))); - - let is_not_completely_captured = - root_var_min_capture_list.iter().any(|capture| capture.place.projections.len() > 0); - - if is_moved && is_not_completely_captured { - need_migrations.push((var_hir_id, ty)); - } + if !root_var_min_capture_list.is_empty() { + self.typeck_results + .borrow_mut() + .closure_min_captures + .insert(closure_def_id, root_var_min_capture_list); } - - need_migrations } fn init_capture_kind( @@ -751,17 +613,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// A captured place is mutable if /// 1. Projections don't include a Deref of an immut-borrow, **and** /// 2. PlaceBase is mut or projections include a Deref of a mut-borrow. - fn determine_capture_mutability( - &self, - typeck_results: &'a TypeckResults<'tcx>, - place: &Place<'tcx>, - ) -> hir::Mutability { + fn determine_capture_mutability(&self, place: &Place<'tcx>) -> hir::Mutability { let var_hir_id = match place.base { PlaceBase::Upvar(upvar_id) => upvar_id.var_path.hir_id, _ => unreachable!(), }; - let bm = *typeck_results.pat_binding_modes().get(var_hir_id).expect("missing binding mode"); + let bm = *self + .typeck_results + .borrow() + .pat_binding_modes() + .get(var_hir_id) + .expect("missing binding mode"); let mut is_mutbl = match bm { ty::BindByValue(mutability) => mutability, @@ -835,11 +698,9 @@ struct InferBorrowKind<'a, 'tcx> { /// /// For closure `fix_s`, (at a high level) the map contains /// - /// ``` /// Place { V1, [ProjectionKind::Field(Index=0, Variant=0)] } : CaptureKind { E1, ImmutableBorrow } /// Place { V1, [ProjectionKind::Field(Index=1, Variant=0)] } : CaptureKind { E2, MutableBorrow } - /// ``` - capture_information: InferredCaptureInformation<'tcx>, + capture_information: FxIndexMap, ty::CaptureInfo<'tcx>>, } impl<'a, 'tcx> InferBorrowKind<'a, 'tcx> { @@ -1258,21 +1119,6 @@ fn var_name(tcx: TyCtxt<'_>, var_hir_id: hir::HirId) -> Symbol { tcx.hir().name(var_hir_id) } -fn should_do_migration_analysis(tcx: TyCtxt<'_>, closure_id: hir::HirId) -> bool { - let (level, _) = - tcx.lint_level_at_node(lint::builtin::DISJOINT_CAPTURE_DROP_REORDER, closure_id); - - !matches!(level, lint::Level::Allow) -} - -fn migration_suggestion_for_2229(tcx: TyCtxt<'_>, need_migrations: &Vec) -> String { - let need_migrations_strings = - need_migrations.iter().map(|v| format!("{}", var_name(tcx, *v))).collect::>(); - let migrations_list_concat = need_migrations_strings.join(", "); - - format!("drop(&({}));", migrations_list_concat) -} - /// Helper function to determine if we need to escalate CaptureKind from /// CaptureInfo A to B and returns the escalated CaptureInfo. /// (Note: CaptureInfo contains CaptureKind and an expression that led to capture it in that way) diff --git a/compiler/rustc_typeck/src/check/writeback.rs b/compiler/rustc_typeck/src/check/writeback.rs index 4d18b2cb3fc49..b6d740a4fdb57 100644 --- a/compiler/rustc_typeck/src/check/writeback.rs +++ b/compiler/rustc_typeck/src/check/writeback.rs @@ -650,7 +650,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { } } -crate trait Locatable { +trait Locatable { fn to_span(&self, tcx: TyCtxt<'_>) -> Span; } @@ -668,7 +668,7 @@ impl Locatable for hir::HirId { /// The Resolver. This is the type folding engine that detects /// unresolved types and so forth. -crate struct Resolver<'cx, 'tcx> { +struct Resolver<'cx, 'tcx> { tcx: TyCtxt<'tcx>, infcx: &'cx InferCtxt<'cx, 'tcx>, span: &'cx dyn Locatable, @@ -679,7 +679,7 @@ crate struct Resolver<'cx, 'tcx> { } impl<'cx, 'tcx> Resolver<'cx, 'tcx> { - crate fn new( + fn new( fcx: &'cx FnCtxt<'cx, 'tcx>, span: &'cx dyn Locatable, body: &'tcx hir::Body<'tcx>, diff --git a/compiler/rustc_typeck/src/collect.rs b/compiler/rustc_typeck/src/collect.rs index e5045f906df59..b1d98d75196d5 100644 --- a/compiler/rustc_typeck/src/collect.rs +++ b/compiler/rustc_typeck/src/collect.rs @@ -1,4 +1,3 @@ -// ignore-tidy-filelength //! "Collection" is the process of determining the type and other external //! details of each item in Rust. Collection is specifically concerned //! with *inter-procedural* things -- for example, for a function @@ -78,7 +77,6 @@ pub fn provide(providers: &mut Providers) { projection_ty_from_predicates, explicit_predicates_of, super_predicates_of, - super_predicates_that_define_assoc_type, trait_explicit_predicates_and_bounds, type_param_predicates, trait_def, @@ -310,17 +308,8 @@ impl AstConv<'tcx> for ItemCtxt<'tcx> { } } - fn get_type_parameter_bounds( - &self, - span: Span, - def_id: DefId, - assoc_name: Ident, - ) -> ty::GenericPredicates<'tcx> { - self.tcx.at(span).type_param_predicates(( - self.item_def_id, - def_id.expect_local(), - assoc_name, - )) + fn get_type_parameter_bounds(&self, span: Span, def_id: DefId) -> ty::GenericPredicates<'tcx> { + self.tcx.at(span).type_param_predicates((self.item_def_id, def_id.expect_local())) } fn re_infer(&self, _: Option<&ty::GenericParamDef>, _: Span) -> Option> { @@ -501,7 +490,7 @@ fn get_new_lifetime_name<'tcx>( /// `X: Foo` where `X` is the type parameter `def_id`. fn type_param_predicates( tcx: TyCtxt<'_>, - (item_def_id, def_id, assoc_name): (DefId, LocalDefId, Ident), + (item_def_id, def_id): (DefId, LocalDefId), ) -> ty::GenericPredicates<'_> { use rustc_hir::*; @@ -526,7 +515,7 @@ fn type_param_predicates( let mut result = parent .map(|parent| { let icx = ItemCtxt::new(tcx, parent); - icx.get_type_parameter_bounds(DUMMY_SP, def_id.to_def_id(), assoc_name) + icx.get_type_parameter_bounds(DUMMY_SP, def_id.to_def_id()) }) .unwrap_or_default(); let mut extend = None; @@ -569,18 +558,12 @@ fn type_param_predicates( let icx = ItemCtxt::new(tcx, item_def_id); let extra_predicates = extend.into_iter().chain( - icx.type_parameter_bounds_in_generics( - ast_generics, - param_id, - ty, - OnlySelfBounds(true), - Some(assoc_name), - ) - .into_iter() - .filter(|(predicate, _)| match predicate.kind().skip_binder() { - ty::PredicateKind::Trait(data, _) => data.self_ty().is_param(index), - _ => false, - }), + icx.type_parameter_bounds_in_generics(ast_generics, param_id, ty, OnlySelfBounds(true)) + .into_iter() + .filter(|(predicate, _)| match predicate.kind().skip_binder() { + ty::PredicateKind::Trait(data, _) => data.self_ty().is_param(index), + _ => false, + }), ); result.predicates = tcx.arena.alloc_from_iter(result.predicates.iter().copied().chain(extra_predicates)); @@ -598,7 +581,6 @@ impl ItemCtxt<'tcx> { param_id: hir::HirId, ty: Ty<'tcx>, only_self_bounds: OnlySelfBounds, - assoc_name: Option, ) -> Vec<(ty::Predicate<'tcx>, Span)> { let constness = self.default_constness_for_trait_bounds(); let from_ty_params = ast_generics @@ -609,10 +591,6 @@ impl ItemCtxt<'tcx> { _ => None, }) .flat_map(|bounds| bounds.iter()) - .filter(|b| match assoc_name { - Some(assoc_name) => self.bound_defines_assoc_item(b, assoc_name), - None => true, - }) .flat_map(|b| predicates_from_bound(self, ty, b, constness)); let from_where_clauses = ast_generics @@ -631,34 +609,12 @@ impl ItemCtxt<'tcx> { } else { None }; - bp.bounds - .iter() - .filter(|b| match assoc_name { - Some(assoc_name) => self.bound_defines_assoc_item(b, assoc_name), - None => true, - }) - .filter_map(move |b| bt.map(|bt| (bt, b))) + bp.bounds.iter().filter_map(move |b| bt.map(|bt| (bt, b))) }) .flat_map(|(bt, b)| predicates_from_bound(self, bt, b, constness)); from_ty_params.chain(from_where_clauses).collect() } - - fn bound_defines_assoc_item(&self, b: &hir::GenericBound<'_>, assoc_name: Ident) -> bool { - debug!("bound_defines_assoc_item(b={:?}, assoc_name={:?})", b, assoc_name); - - match b { - hir::GenericBound::Trait(poly_trait_ref, _) => { - let trait_ref = &poly_trait_ref.trait_ref; - if let Some(trait_did) = trait_ref.trait_def_id() { - self.tcx.trait_may_define_assoc_type(trait_did, assoc_name) - } else { - false - } - } - _ => false, - } - } } /// Tests whether this is the AST for a reference to the type @@ -1027,91 +983,54 @@ fn adt_def(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::AdtDef { /// the transitive super-predicates are converted. fn super_predicates_of(tcx: TyCtxt<'_>, trait_def_id: DefId) -> ty::GenericPredicates<'_> { debug!("super_predicates(trait_def_id={:?})", trait_def_id); - tcx.super_predicates_that_define_assoc_type((trait_def_id, None)) -} - -/// Ensures that the super-predicates of the trait with a `DefId` -/// of `trait_def_id` are converted and stored. This also ensures that -/// the transitive super-predicates are converted. -fn super_predicates_that_define_assoc_type( - tcx: TyCtxt<'_>, - (trait_def_id, assoc_name): (DefId, Option), -) -> ty::GenericPredicates<'_> { - debug!( - "super_predicates_that_define_assoc_type(trait_def_id={:?}, assoc_name={:?})", - trait_def_id, assoc_name - ); - if trait_def_id.is_local() { - debug!("super_predicates_that_define_assoc_type: local trait_def_id={:?}", trait_def_id); - let trait_hir_id = tcx.hir().local_def_id_to_hir_id(trait_def_id.expect_local()); + let trait_hir_id = tcx.hir().local_def_id_to_hir_id(trait_def_id.expect_local()); - let item = match tcx.hir().get(trait_hir_id) { - Node::Item(item) => item, - _ => bug!("trait_node_id {} is not an item", trait_hir_id), - }; - - let (generics, bounds) = match item.kind { - hir::ItemKind::Trait(.., ref generics, ref supertraits, _) => (generics, supertraits), - hir::ItemKind::TraitAlias(ref generics, ref supertraits) => (generics, supertraits), - _ => span_bug!(item.span, "super_predicates invoked on non-trait"), - }; - - let icx = ItemCtxt::new(tcx, trait_def_id); + let item = match tcx.hir().get(trait_hir_id) { + Node::Item(item) => item, + _ => bug!("trait_node_id {} is not an item", trait_hir_id), + }; - // Convert the bounds that follow the colon, e.g., `Bar + Zed` in `trait Foo: Bar + Zed`. - let self_param_ty = tcx.types.self_param; - let superbounds1 = if let Some(assoc_name) = assoc_name { - AstConv::compute_bounds_that_match_assoc_type( - &icx, - self_param_ty, - &bounds, - SizedByDefault::No, - item.span, - assoc_name, - ) - } else { - AstConv::compute_bounds(&icx, self_param_ty, &bounds, SizedByDefault::No, item.span) - }; + let (generics, bounds) = match item.kind { + hir::ItemKind::Trait(.., ref generics, ref supertraits, _) => (generics, supertraits), + hir::ItemKind::TraitAlias(ref generics, ref supertraits) => (generics, supertraits), + _ => span_bug!(item.span, "super_predicates invoked on non-trait"), + }; - let superbounds1 = superbounds1.predicates(tcx, self_param_ty); + let icx = ItemCtxt::new(tcx, trait_def_id); + + // Convert the bounds that follow the colon, e.g., `Bar + Zed` in `trait Foo: Bar + Zed`. + let self_param_ty = tcx.types.self_param; + let superbounds1 = + AstConv::compute_bounds(&icx, self_param_ty, bounds, SizedByDefault::No, item.span); + + let superbounds1 = superbounds1.predicates(tcx, self_param_ty); + + // Convert any explicit superbounds in the where-clause, + // e.g., `trait Foo where Self: Bar`. + // In the case of trait aliases, however, we include all bounds in the where-clause, + // so e.g., `trait Foo = where u32: PartialEq` would include `u32: PartialEq` + // as one of its "superpredicates". + let is_trait_alias = tcx.is_trait_alias(trait_def_id); + let superbounds2 = icx.type_parameter_bounds_in_generics( + generics, + item.hir_id, + self_param_ty, + OnlySelfBounds(!is_trait_alias), + ); - // Convert any explicit superbounds in the where-clause, - // e.g., `trait Foo where Self: Bar`. - // In the case of trait aliases, however, we include all bounds in the where-clause, - // so e.g., `trait Foo = where u32: PartialEq` would include `u32: PartialEq` - // as one of its "superpredicates". - let is_trait_alias = tcx.is_trait_alias(trait_def_id); - let superbounds2 = icx.type_parameter_bounds_in_generics( - generics, - item.hir_id, - self_param_ty, - OnlySelfBounds(!is_trait_alias), - assoc_name, - ); + // Combine the two lists to form the complete set of superbounds: + let superbounds = &*tcx.arena.alloc_from_iter(superbounds1.into_iter().chain(superbounds2)); - // Combine the two lists to form the complete set of superbounds: - let superbounds = &*tcx.arena.alloc_from_iter(superbounds1.into_iter().chain(superbounds2)); - - // Now require that immediate supertraits are converted, - // which will, in turn, reach indirect supertraits. - if assoc_name.is_none() { - // Now require that immediate supertraits are converted, - // which will, in turn, reach indirect supertraits. - for &(pred, span) in superbounds { - debug!("superbound: {:?}", pred); - if let ty::PredicateKind::Trait(bound, _) = pred.kind().skip_binder() { - tcx.at(span).super_predicates_of(bound.def_id()); - } - } + // Now require that immediate supertraits are converted, + // which will, in turn, reach indirect supertraits. + for &(pred, span) in superbounds { + debug!("superbound: {:?}", pred); + if let ty::PredicateKind::Trait(bound, _) = pred.kind().skip_binder() { + tcx.at(span).super_predicates_of(bound.def_id()); } - - ty::GenericPredicates { parent: None, predicates: superbounds } - } else { - // if `assoc_name` is None, then the query should've been redirected to an - // external provider - assert!(assoc_name.is_some()); - tcx.super_predicates_of(trait_def_id) } + + ty::GenericPredicates { parent: None, predicates: superbounds } } fn trait_def(tcx: TyCtxt<'_>, def_id: DefId) -> ty::TraitDef { diff --git a/compiler/rustc_typeck/src/collect/item_bounds.rs b/compiler/rustc_typeck/src/collect/item_bounds.rs index fe18dc5ed0c69..537a58328942b 100644 --- a/compiler/rustc_typeck/src/collect/item_bounds.rs +++ b/compiler/rustc_typeck/src/collect/item_bounds.rs @@ -28,7 +28,7 @@ fn associated_type_bounds<'tcx>( let bounds = AstConv::compute_bounds( &ItemCtxt::new(tcx, assoc_item_def_id), item_ty, - &bounds, + bounds, SizedByDefault::Yes, span, ); @@ -69,7 +69,7 @@ fn opaque_type_bounds<'tcx>( let bounds = AstConv::compute_bounds( &ItemCtxt::new(tcx, opaque_def_id), item_ty, - &bounds, + bounds, SizedByDefault::Yes, span, ) diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index e87303749b423..949079e5b699c 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -390,12 +390,7 @@ impl Box { // #[unstable(feature = "new_uninit", issue = "63291")] pub fn new_uninit_in(alloc: A) -> Box, A> { let layout = Layout::new::>(); - // NOTE: Prefer match over unwrap_or_else since closure sometimes not inlineable. - // That would make code size bigger. - match Box::try_new_uninit_in(alloc) { - Ok(m) => m, - Err(_) => handle_alloc_error(layout), - } + Box::try_new_uninit_in(alloc).unwrap_or_else(|_| handle_alloc_error(layout)) } /// Constructs a new box with uninitialized contents in the provided allocator, @@ -452,12 +447,7 @@ impl Box { // #[unstable(feature = "new_uninit", issue = "63291")] pub fn new_zeroed_in(alloc: A) -> Box, A> { let layout = Layout::new::>(); - // NOTE: Prefer match over unwrap_or_else since closure sometimes not inlineable. - // That would make code size bigger. - match Box::try_new_zeroed_in(alloc) { - Ok(m) => m, - Err(_) => handle_alloc_error(layout), - } + Box::try_new_zeroed_in(alloc).unwrap_or_else(|_| handle_alloc_error(layout)) } /// Constructs a new `Box` with uninitialized contents, with the memory diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs index dc1098757268a..79dc694e6be82 100644 --- a/library/alloc/src/collections/btree/map.rs +++ b/library/alloc/src/collections/btree/map.rs @@ -11,6 +11,7 @@ use core::ptr; use super::borrow::DormantMutRef; use super::node::{self, marker, ForceResult::*, Handle, NodeRef, Root}; use super::search::SearchResult::*; +use super::unwrap_unchecked; mod entry; pub use entry::{Entry, OccupiedEntry, VacantEntry}; @@ -20,14 +21,6 @@ use Entry::*; /// We might temporarily have fewer elements during methods. pub(super) const MIN_LEN: usize = node::MIN_LEN_AFTER_SPLIT; -// A tree in a `BTreeMap` is a tree in the `node` module with addtional invariants: -// - Keys must appear in ascending order (according to the key's type). -// - If the root node is internal, it must contain at least 1 element. -// - Every non-root node contains at least MIN_LEN elements. -// -// An empty map may be represented both by the absense of a root node or by a -// root node that is an empty leaf. - /// A map based on a B-Tree. /// /// B-Trees represent a fundamental compromise between cache-efficiency and actually minimizing @@ -467,7 +460,7 @@ impl fmt::Debug for RangeMut<'_, K, V> { } } -impl BTreeMap { +impl BTreeMap { /// Makes a new, empty `BTreeMap`. /// /// Does not allocate anything on its own. @@ -486,10 +479,7 @@ impl BTreeMap { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_btree_new", issue = "71835")] - pub const fn new() -> BTreeMap - where - K: Ord, - { + pub const fn new() -> BTreeMap { BTreeMap { root: None, length: 0 } } @@ -509,7 +499,7 @@ impl BTreeMap { /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn clear(&mut self) { - *self = BTreeMap { root: None, length: 0 }; + *self = BTreeMap::new(); } /// Returns a reference to the value corresponding to the key. @@ -532,7 +522,7 @@ impl BTreeMap { #[stable(feature = "rust1", since = "1.0.0")] pub fn get(&self, key: &Q) -> Option<&V> where - K: Borrow + Ord, + K: Borrow, Q: Ord, { let root_node = self.root.as_ref()?.reborrow(); @@ -560,7 +550,7 @@ impl BTreeMap { #[stable(feature = "map_get_key_value", since = "1.40.0")] pub fn get_key_value(&self, k: &Q) -> Option<(&K, &V)> where - K: Borrow + Ord, + K: Borrow, Q: Ord, { let root_node = self.root.as_ref()?.reborrow(); @@ -588,10 +578,7 @@ impl BTreeMap { /// assert_eq!(map.first_key_value(), Some((&1, &"b"))); /// ``` #[unstable(feature = "map_first_last", issue = "62924")] - pub fn first_key_value(&self) -> Option<(&K, &V)> - where - K: Ord, - { + pub fn first_key_value(&self) -> Option<(&K, &V)> { let root_node = self.root.as_ref()?.reborrow(); root_node.first_leaf_edge().right_kv().ok().map(Handle::into_kv) } @@ -617,10 +604,7 @@ impl BTreeMap { /// assert_eq!(*map.get(&2).unwrap(), "b"); /// ``` #[unstable(feature = "map_first_last", issue = "62924")] - pub fn first_entry(&mut self) -> Option> - where - K: Ord, - { + pub fn first_entry(&mut self) -> Option> { let (map, dormant_map) = DormantMutRef::new(self); let root_node = map.root.as_mut()?.borrow_mut(); let kv = root_node.first_leaf_edge().right_kv().ok()?; @@ -647,10 +631,7 @@ impl BTreeMap { /// assert!(map.is_empty()); /// ``` #[unstable(feature = "map_first_last", issue = "62924")] - pub fn pop_first(&mut self) -> Option<(K, V)> - where - K: Ord, - { + pub fn pop_first(&mut self) -> Option<(K, V)> { self.first_entry().map(|entry| entry.remove_entry()) } @@ -671,10 +652,7 @@ impl BTreeMap { /// assert_eq!(map.last_key_value(), Some((&2, &"a"))); /// ``` #[unstable(feature = "map_first_last", issue = "62924")] - pub fn last_key_value(&self) -> Option<(&K, &V)> - where - K: Ord, - { + pub fn last_key_value(&self) -> Option<(&K, &V)> { let root_node = self.root.as_ref()?.reborrow(); root_node.last_leaf_edge().left_kv().ok().map(Handle::into_kv) } @@ -700,10 +678,7 @@ impl BTreeMap { /// assert_eq!(*map.get(&2).unwrap(), "last"); /// ``` #[unstable(feature = "map_first_last", issue = "62924")] - pub fn last_entry(&mut self) -> Option> - where - K: Ord, - { + pub fn last_entry(&mut self) -> Option> { let (map, dormant_map) = DormantMutRef::new(self); let root_node = map.root.as_mut()?.borrow_mut(); let kv = root_node.last_leaf_edge().left_kv().ok()?; @@ -730,10 +705,7 @@ impl BTreeMap { /// assert!(map.is_empty()); /// ``` #[unstable(feature = "map_first_last", issue = "62924")] - pub fn pop_last(&mut self) -> Option<(K, V)> - where - K: Ord, - { + pub fn pop_last(&mut self) -> Option<(K, V)> { self.last_entry().map(|entry| entry.remove_entry()) } @@ -757,7 +729,7 @@ impl BTreeMap { #[stable(feature = "rust1", since = "1.0.0")] pub fn contains_key(&self, key: &Q) -> bool where - K: Borrow + Ord, + K: Borrow, Q: Ord, { self.get(key).is_some() @@ -786,7 +758,7 @@ impl BTreeMap { #[stable(feature = "rust1", since = "1.0.0")] pub fn get_mut(&mut self, key: &Q) -> Option<&mut V> where - K: Borrow + Ord, + K: Borrow, Q: Ord, { let root_node = self.root.as_mut()?.borrow_mut(); @@ -823,10 +795,7 @@ impl BTreeMap { /// assert_eq!(map[&37], "c"); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn insert(&mut self, key: K, value: V) -> Option - where - K: Ord, - { + pub fn insert(&mut self, key: K, value: V) -> Option { match self.entry(key) { Occupied(mut entry) => Some(entry.insert(value)), Vacant(entry) => { @@ -854,11 +823,10 @@ impl BTreeMap { /// assert_eq!(map.remove(&1), Some("a")); /// assert_eq!(map.remove(&1), None); /// ``` - #[doc(alias = "delete")] #[stable(feature = "rust1", since = "1.0.0")] pub fn remove(&mut self, key: &Q) -> Option where - K: Borrow + Ord, + K: Borrow, Q: Ord, { self.remove_entry(key).map(|(_, v)| v) @@ -885,7 +853,7 @@ impl BTreeMap { #[stable(feature = "btreemap_remove_entry", since = "1.45.0")] pub fn remove_entry(&mut self, key: &Q) -> Option<(K, V)> where - K: Borrow + Ord, + K: Borrow, Q: Ord, { let (map, dormant_map) = DormantMutRef::new(self); @@ -917,7 +885,6 @@ impl BTreeMap { #[unstable(feature = "btree_retain", issue = "79025")] pub fn retain(&mut self, mut f: F) where - K: Ord, F: FnMut(&K, &mut V) -> bool, { self.drain_filter(|k, v| !f(k, v)); @@ -952,10 +919,7 @@ impl BTreeMap { /// assert_eq!(a[&5], "f"); /// ``` #[stable(feature = "btree_append", since = "1.11.0")] - pub fn append(&mut self, other: &mut Self) - where - K: Ord, - { + pub fn append(&mut self, other: &mut Self) { // Do we have to append anything at all? if other.is_empty() { return; @@ -1006,7 +970,7 @@ impl BTreeMap { pub fn range(&self, range: R) -> Range<'_, K, V> where T: Ord, - K: Borrow + Ord, + K: Borrow, R: RangeBounds, { if let Some(root) = &self.root { @@ -1052,7 +1016,7 @@ impl BTreeMap { pub fn range_mut(&mut self, range: R) -> RangeMut<'_, K, V> where T: Ord, - K: Borrow + Ord, + K: Borrow, R: RangeBounds, { if let Some(root) = &mut self.root { @@ -1083,10 +1047,7 @@ impl BTreeMap { /// assert_eq!(count["a"], 3); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn entry(&mut self, key: K) -> Entry<'_, K, V> - where - K: Ord, - { + pub fn entry(&mut self, key: K) -> Entry<'_, K, V> { // FIXME(@porglezomp) Avoid allocating if we don't insert let (map, dormant_map) = DormantMutRef::new(self); let root_node = Self::ensure_is_owned(&mut map.root).borrow_mut(); @@ -1130,7 +1091,7 @@ impl BTreeMap { #[stable(feature = "btree_split_off", since = "1.11.0")] pub fn split_off(&mut self, key: &Q) -> Self where - K: Borrow + Ord, + K: Borrow, { if self.is_empty() { return Self::new(); @@ -1139,31 +1100,37 @@ impl BTreeMap { let total_num = self.len(); let left_root = self.root.as_mut().unwrap(); // unwrap succeeds because not empty - let right_root = left_root.split_off(key); + let mut right = Self::new(); + let right_root = Self::ensure_is_owned(&mut right.root); - let (new_left_len, right_len) = Root::calc_split_length(total_num, &left_root, &right_root); - self.length = new_left_len; + left_root.split_off(right_root, key); - BTreeMap { root: Some(right_root), length: right_len } + if left_root.height() < right_root.height() { + self.length = left_root.reborrow().calc_length(); + right.length = total_num - self.len(); + } else { + right.length = right_root.reborrow().calc_length(); + self.length = total_num - right.len(); + } + + right } - /// Creates an iterator that visits all elements (key-value pairs) in - /// ascending key order and uses a closure to determine if an element should - /// be removed. If the closure returns `true`, the element is removed from - /// the map and yielded. If the closure returns `false`, or panics, the - /// element remains in the map and will not be yielded. + /// Creates an iterator which uses a closure to determine if an element should be removed. + /// + /// If the closure returns true, the element is removed from the map and yielded. + /// If the closure returns false, or panics, the element remains in the map and will not be + /// yielded. /// - /// The iterator also lets you mutate the value of each element in the - /// closure, regardless of whether you choose to keep or remove it. + /// Note that `drain_filter` lets you mutate every value in the filter closure, regardless of + /// whether you choose to keep or remove it. /// - /// If the iterator is only partially consumed or not consumed at all, each - /// of the remaining elements is still subjected to the closure, which may - /// change its value and, by returning `true`, have the element removed and - /// dropped. + /// If the iterator is only partially consumed or not consumed at all, each of the remaining + /// elements will still be subjected to the closure and removed and dropped if it returns true. /// - /// It is unspecified how many more elements will be subjected to the - /// closure if a panic occurs in the closure, or a panic occurs while - /// dropping an element, or if the `DrainFilter` value is leaked. + /// It is unspecified how many more elements will be subjected to the closure + /// if a panic occurs in the closure, or a panic occurs while dropping an element, + /// or if the `DrainFilter` value is leaked. /// /// # Examples /// @@ -1182,16 +1149,12 @@ impl BTreeMap { #[unstable(feature = "btree_drain_filter", issue = "70530")] pub fn drain_filter(&mut self, pred: F) -> DrainFilter<'_, K, V, F> where - K: Ord, F: FnMut(&K, &mut V) -> bool, { DrainFilter { pred, inner: self.drain_filter_inner() } } - pub(super) fn drain_filter_inner(&mut self) -> DrainFilterInner<'_, K, V> - where - K: Ord, - { + pub(super) fn drain_filter_inner(&mut self) -> DrainFilterInner<'_, K, V> { if let Some(root) = self.root.as_mut() { let (root, dormant_root) = DormantMutRef::new(root); let front = root.borrow_mut().first_leaf_edge(); @@ -1423,7 +1386,7 @@ impl Drop for IntoIter { unsafe { let mut node = - ptr::read(&self.0.front).unwrap_unchecked().into_node().forget_type(); + unwrap_unchecked(ptr::read(&self.0.front)).into_node().forget_type(); while let Some(parent) = node.deallocate_and_ascend() { node = parent.into_node().forget_type(); } @@ -1748,7 +1711,7 @@ impl<'a, K, V> Range<'a, K, V> { } unsafe fn next_unchecked(&mut self) -> (&'a K, &'a V) { - unsafe { self.front.as_mut().unwrap_unchecked().next_unchecked() } + unsafe { unwrap_unchecked(self.front.as_mut()).next_unchecked() } } } @@ -1837,7 +1800,7 @@ impl<'a, K, V> DoubleEndedIterator for Range<'a, K, V> { impl<'a, K, V> Range<'a, K, V> { unsafe fn next_back_unchecked(&mut self) -> (&'a K, &'a V) { - unsafe { self.back.as_mut().unwrap_unchecked().next_back_unchecked() } + unsafe { unwrap_unchecked(self.back.as_mut()).next_back_unchecked() } } } @@ -1883,7 +1846,7 @@ impl<'a, K, V> RangeMut<'a, K, V> { } unsafe fn next_unchecked(&mut self) -> (&'a K, &'a mut V) { - unsafe { self.front.as_mut().unwrap_unchecked().next_unchecked() } + unsafe { unwrap_unchecked(self.front.as_mut()).next_unchecked() } } /// Returns an iterator of references over the remaining items. @@ -1913,7 +1876,7 @@ impl FusedIterator for RangeMut<'_, K, V> {} impl<'a, K, V> RangeMut<'a, K, V> { unsafe fn next_back_unchecked(&mut self) -> (&'a K, &'a mut V) { - unsafe { self.back.as_mut().unwrap_unchecked().next_back_unchecked() } + unsafe { unwrap_unchecked(self.back.as_mut()).next_back_unchecked() } } } @@ -2004,9 +1967,9 @@ impl Debug for BTreeMap { } #[stable(feature = "rust1", since = "1.0.0")] -impl Index<&Q> for BTreeMap +impl Index<&Q> for BTreeMap where - K: Borrow + Ord, + K: Borrow, Q: Ord, { type Output = V; diff --git a/library/alloc/src/collections/btree/map/tests.rs b/library/alloc/src/collections/btree/map/tests.rs index 1993c6e047d48..ba5a4442f56e6 100644 --- a/library/alloc/src/collections/btree/map/tests.rs +++ b/library/alloc/src/collections/btree/map/tests.rs @@ -1706,47 +1706,6 @@ fn test_send() { } } -#[allow(dead_code)] -fn test_ord_absence() { - fn map(mut map: BTreeMap) { - map.is_empty(); - map.len(); - map.clear(); - map.iter(); - map.iter_mut(); - map.keys(); - map.values(); - map.values_mut(); - if true { - map.into_values(); - } else if true { - map.into_iter(); - } else { - map.into_keys(); - } - } - - fn map_debug(mut map: BTreeMap) { - format!("{:?}", map); - format!("{:?}", map.iter()); - format!("{:?}", map.iter_mut()); - format!("{:?}", map.keys()); - format!("{:?}", map.values()); - format!("{:?}", map.values_mut()); - if true { - format!("{:?}", map.into_iter()); - } else if true { - format!("{:?}", map.into_keys()); - } else { - format!("{:?}", map.into_values()); - } - } - - fn map_clone(mut map: BTreeMap) { - map.clone_from(&map.clone()); - } -} - #[allow(dead_code)] fn test_const() { const MAP: &'static BTreeMap<(), ()> = &BTreeMap::new(); @@ -1923,7 +1882,7 @@ fn test_append_drop_leak() { catch_unwind(move || left.append(&mut right)).unwrap_err(); - assert_eq!(DROPS.load(SeqCst), 4); // Rust issue #47949 ate one little piggy + assert_eq!(DROPS.load(SeqCst), 5); } #[test] diff --git a/library/alloc/src/collections/btree/mod.rs b/library/alloc/src/collections/btree/mod.rs index cf91c17b511cc..cdb39104047f0 100644 --- a/library/alloc/src/collections/btree/mod.rs +++ b/library/alloc/src/collections/btree/mod.rs @@ -19,6 +19,22 @@ trait Recover { fn replace(&mut self, key: Self::Key) -> Option; } +/// Same purpose as `Option::unwrap` but doesn't always guarantee a panic +/// if the option contains no value. +/// SAFETY: the caller must ensure that the option contains a value. +#[inline(always)] +pub unsafe fn unwrap_unchecked(val: Option) -> T { + val.unwrap_or_else(|| { + if cfg!(debug_assertions) { + panic!("'unchecked' unwrap on None in BTreeMap"); + } else { + unsafe { + core::intrinsics::unreachable(); + } + } + }) +} + #[cfg(test)] /// XorShiftRng struct DeterministicRng { diff --git a/library/alloc/src/collections/btree/navigate.rs b/library/alloc/src/collections/btree/navigate.rs index 1ef2a572ddd91..2773b427fb133 100644 --- a/library/alloc/src/collections/btree/navigate.rs +++ b/library/alloc/src/collections/btree/navigate.rs @@ -6,6 +6,7 @@ use core::ptr; use super::node::{marker, ForceResult::*, Handle, NodeRef}; use super::search::SearchResult; +use super::unwrap_unchecked; /// Finds the leaf edges delimiting a specified range in or underneath a node. /// @@ -309,7 +310,7 @@ macro_rules! def_next_kv_uncheched_dealloc { Err(last_edge) => { unsafe { let parent_edge = last_edge.into_node().deallocate_and_ascend(); - parent_edge.unwrap_unchecked().forget_node_type() + unwrap_unchecked(parent_edge).forget_node_type() } } } @@ -330,7 +331,7 @@ impl<'a, K, V> Handle, K, V, marker::Leaf>, marker::Ed pub unsafe fn next_unchecked(&mut self) -> (&'a K, &'a V) { super::mem::replace(self, |leaf_edge| { let kv = leaf_edge.next_kv(); - let kv = unsafe { kv.ok().unwrap_unchecked() }; + let kv = unsafe { unwrap_unchecked(kv.ok()) }; (kv.next_leaf_edge(), kv.into_kv()) }) } @@ -343,7 +344,7 @@ impl<'a, K, V> Handle, K, V, marker::Leaf>, marker::Ed pub unsafe fn next_back_unchecked(&mut self) -> (&'a K, &'a V) { super::mem::replace(self, |leaf_edge| { let kv = leaf_edge.next_back_kv(); - let kv = unsafe { kv.ok().unwrap_unchecked() }; + let kv = unsafe { unwrap_unchecked(kv.ok()) }; (kv.next_back_leaf_edge(), kv.into_kv()) }) } @@ -358,7 +359,7 @@ impl<'a, K, V> Handle, K, V, marker::Leaf>, marker::E pub unsafe fn next_unchecked(&mut self) -> (&'a K, &'a mut V) { let kv = super::mem::replace(self, |leaf_edge| { let kv = leaf_edge.next_kv(); - let kv = unsafe { kv.ok().unwrap_unchecked() }; + let kv = unsafe { unwrap_unchecked(kv.ok()) }; (unsafe { ptr::read(&kv) }.next_leaf_edge(), kv) }); // Doing this last is faster, according to benchmarks. @@ -373,7 +374,7 @@ impl<'a, K, V> Handle, K, V, marker::Leaf>, marker::E pub unsafe fn next_back_unchecked(&mut self) -> (&'a K, &'a mut V) { let kv = super::mem::replace(self, |leaf_edge| { let kv = leaf_edge.next_back_kv(); - let kv = unsafe { kv.ok().unwrap_unchecked() }; + let kv = unsafe { unwrap_unchecked(kv.ok()) }; (unsafe { ptr::read(&kv) }.next_back_leaf_edge(), kv) }); // Doing this last is faster, according to benchmarks. diff --git a/library/alloc/src/collections/btree/remove.rs b/library/alloc/src/collections/btree/remove.rs index 9cd016fa62f0e..ff842197d1918 100644 --- a/library/alloc/src/collections/btree/remove.rs +++ b/library/alloc/src/collections/btree/remove.rs @@ -1,5 +1,6 @@ use super::map::MIN_LEN; use super::node::{marker, ForceResult::*, Handle, LeftOrRight::*, NodeRef}; +use super::unwrap_unchecked; impl<'a, K: 'a, V: 'a> Handle, K, V, marker::LeafOrInternal>, marker::KV> { /// Removes a key-value pair from the tree, and returns that pair, as well as @@ -76,12 +77,12 @@ impl<'a, K: 'a, V: 'a> Handle, K, V, marker::Internal>, // the element we were asked to remove. Prefer the left adjacent KV, // for the reasons listed in `choose_parent_kv`. let left_leaf_kv = self.left_edge().descend().last_leaf_edge().left_kv(); - let left_leaf_kv = unsafe { left_leaf_kv.ok().unwrap_unchecked() }; + let left_leaf_kv = unsafe { unwrap_unchecked(left_leaf_kv.ok()) }; let (left_kv, left_hole) = left_leaf_kv.remove_leaf_kv(handle_emptied_internal_root); // The internal node may have been stolen from or merged. Go back right // to find where the original KV ended up. - let mut internal = unsafe { left_hole.next_kv().ok().unwrap_unchecked() }; + let mut internal = unsafe { unwrap_unchecked(left_hole.next_kv().ok()) }; let old_kv = internal.replace_kv(left_kv.0, left_kv.1); let pos = internal.next_leaf_edge(); (old_kv, pos) diff --git a/library/alloc/src/collections/btree/set.rs b/library/alloc/src/collections/btree/set.rs index c619b5bf8edd1..c2a96dd8ef471 100644 --- a/library/alloc/src/collections/btree/set.rs +++ b/library/alloc/src/collections/btree/set.rs @@ -222,7 +222,7 @@ impl fmt::Debug for Union<'_, T> { // and it's a power of two to make that division cheap. const ITER_PERFORMANCE_TIPPING_SIZE_DIFF: usize = 16; -impl BTreeSet { +impl BTreeSet { /// Makes a new, empty `BTreeSet`. /// /// Does not allocate anything on its own. @@ -237,10 +237,7 @@ impl BTreeSet { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_const_unstable(feature = "const_btree_new", issue = "71835")] - pub const fn new() -> BTreeSet - where - T: Ord, - { + pub const fn new() -> BTreeSet { BTreeSet { map: BTreeMap::new() } } @@ -270,7 +267,7 @@ impl BTreeSet { pub fn range(&self, range: R) -> Range<'_, T> where K: Ord, - T: Borrow + Ord, + T: Borrow, R: RangeBounds, { Range { iter: self.map.range(range) } @@ -297,10 +294,7 @@ impl BTreeSet { /// assert_eq!(diff, [1]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn difference<'a>(&'a self, other: &'a BTreeSet) -> Difference<'a, T> - where - T: Ord, - { + pub fn difference<'a>(&'a self, other: &'a BTreeSet) -> Difference<'a, T> { let (self_min, self_max) = if let (Some(self_min), Some(self_max)) = (self.first(), self.last()) { (self_min, self_max) @@ -358,10 +352,10 @@ impl BTreeSet { /// assert_eq!(sym_diff, [1, 3]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn symmetric_difference<'a>(&'a self, other: &'a BTreeSet) -> SymmetricDifference<'a, T> - where - T: Ord, - { + pub fn symmetric_difference<'a>( + &'a self, + other: &'a BTreeSet, + ) -> SymmetricDifference<'a, T> { SymmetricDifference(MergeIterInner::new(self.iter(), other.iter())) } @@ -386,10 +380,7 @@ impl BTreeSet { /// assert_eq!(intersection, [2]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn intersection<'a>(&'a self, other: &'a BTreeSet) -> Intersection<'a, T> - where - T: Ord, - { + pub fn intersection<'a>(&'a self, other: &'a BTreeSet) -> Intersection<'a, T> { let (self_min, self_max) = if let (Some(self_min), Some(self_max)) = (self.first(), self.last()) { (self_min, self_max) @@ -437,10 +428,7 @@ impl BTreeSet { /// assert_eq!(union, [1, 2]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn union<'a>(&'a self, other: &'a BTreeSet) -> Union<'a, T> - where - T: Ord, - { + pub fn union<'a>(&'a self, other: &'a BTreeSet) -> Union<'a, T> { Union(MergeIterInner::new(self.iter(), other.iter())) } @@ -479,7 +467,7 @@ impl BTreeSet { #[stable(feature = "rust1", since = "1.0.0")] pub fn contains(&self, value: &Q) -> bool where - T: Borrow + Ord, + T: Borrow, Q: Ord, { self.map.contains_key(value) @@ -503,7 +491,7 @@ impl BTreeSet { #[stable(feature = "set_recovery", since = "1.9.0")] pub fn get(&self, value: &Q) -> Option<&T> where - T: Borrow + Ord, + T: Borrow, Q: Ord, { Recover::get(&self.map, value) @@ -527,10 +515,7 @@ impl BTreeSet { /// assert_eq!(a.is_disjoint(&b), false); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn is_disjoint(&self, other: &BTreeSet) -> bool - where - T: Ord, - { + pub fn is_disjoint(&self, other: &BTreeSet) -> bool { self.intersection(other).next().is_none() } @@ -552,10 +537,7 @@ impl BTreeSet { /// assert_eq!(set.is_subset(&sup), false); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn is_subset(&self, other: &BTreeSet) -> bool - where - T: Ord, - { + pub fn is_subset(&self, other: &BTreeSet) -> bool { // Same result as self.difference(other).next().is_none() // but the code below is faster (hugely in some cases). if self.len() > other.len() { @@ -631,10 +613,7 @@ impl BTreeSet { /// assert_eq!(set.is_superset(&sub), true); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn is_superset(&self, other: &BTreeSet) -> bool - where - T: Ord, - { + pub fn is_superset(&self, other: &BTreeSet) -> bool { other.is_subset(self) } @@ -657,10 +636,7 @@ impl BTreeSet { /// assert_eq!(map.first(), Some(&1)); /// ``` #[unstable(feature = "map_first_last", issue = "62924")] - pub fn first(&self) -> Option<&T> - where - T: Ord, - { + pub fn first(&self) -> Option<&T> { self.map.first_key_value().map(|(k, _)| k) } @@ -676,17 +652,14 @@ impl BTreeSet { /// use std::collections::BTreeSet; /// /// let mut map = BTreeSet::new(); - /// assert_eq!(map.last(), None); + /// assert_eq!(map.first(), None); /// map.insert(1); /// assert_eq!(map.last(), Some(&1)); /// map.insert(2); /// assert_eq!(map.last(), Some(&2)); /// ``` #[unstable(feature = "map_first_last", issue = "62924")] - pub fn last(&self) -> Option<&T> - where - T: Ord, - { + pub fn last(&self) -> Option<&T> { self.map.last_key_value().map(|(k, _)| k) } @@ -708,10 +681,7 @@ impl BTreeSet { /// assert!(set.is_empty()); /// ``` #[unstable(feature = "map_first_last", issue = "62924")] - pub fn pop_first(&mut self) -> Option - where - T: Ord, - { + pub fn pop_first(&mut self) -> Option { self.map.pop_first().map(|kv| kv.0) } @@ -733,10 +703,7 @@ impl BTreeSet { /// assert!(set.is_empty()); /// ``` #[unstable(feature = "map_first_last", issue = "62924")] - pub fn pop_last(&mut self) -> Option - where - T: Ord, - { + pub fn pop_last(&mut self) -> Option { self.map.pop_last().map(|kv| kv.0) } @@ -761,10 +728,7 @@ impl BTreeSet { /// assert_eq!(set.len(), 1); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - pub fn insert(&mut self, value: T) -> bool - where - T: Ord, - { + pub fn insert(&mut self, value: T) -> bool { self.map.insert(value, ()).is_none() } @@ -784,10 +748,7 @@ impl BTreeSet { /// assert_eq!(set.get(&[][..]).unwrap().capacity(), 10); /// ``` #[stable(feature = "set_recovery", since = "1.9.0")] - pub fn replace(&mut self, value: T) -> Option - where - T: Ord, - { + pub fn replace(&mut self, value: T) -> Option { Recover::replace(&mut self.map, value) } @@ -809,11 +770,10 @@ impl BTreeSet { /// assert_eq!(set.remove(&2), true); /// assert_eq!(set.remove(&2), false); /// ``` - #[doc(alias = "delete")] #[stable(feature = "rust1", since = "1.0.0")] pub fn remove(&mut self, value: &Q) -> bool where - T: Borrow + Ord, + T: Borrow, Q: Ord, { self.map.remove(value).is_some() @@ -837,7 +797,7 @@ impl BTreeSet { #[stable(feature = "set_recovery", since = "1.9.0")] pub fn take(&mut self, value: &Q) -> Option where - T: Borrow + Ord, + T: Borrow, Q: Ord, { Recover::take(&mut self.map, value) @@ -862,7 +822,6 @@ impl BTreeSet { #[unstable(feature = "btree_retain", issue = "79025")] pub fn retain(&mut self, mut f: F) where - T: Ord, F: FnMut(&T) -> bool, { self.drain_filter(|v| !f(v)); @@ -897,10 +856,7 @@ impl BTreeSet { /// assert!(a.contains(&5)); /// ``` #[stable(feature = "btree_append", since = "1.11.0")] - pub fn append(&mut self, other: &mut Self) - where - T: Ord, - { + pub fn append(&mut self, other: &mut Self) { self.map.append(&mut other.map); } @@ -936,7 +892,7 @@ impl BTreeSet { #[stable(feature = "btree_split_off", since = "1.11.0")] pub fn split_off(&mut self, key: &Q) -> Self where - T: Borrow + Ord, + T: Borrow, { BTreeSet { map: self.map.split_off(key) } } @@ -971,12 +927,13 @@ impl BTreeSet { #[unstable(feature = "btree_drain_filter", issue = "70530")] pub fn drain_filter<'a, F>(&'a mut self, pred: F) -> DrainFilter<'a, T, F> where - T: Ord, F: 'a + FnMut(&T) -> bool, { DrainFilter { pred, inner: self.map.drain_filter_inner() } } +} +impl BTreeSet { /// Gets an iterator that visits the values in the `BTreeSet` in ascending order. /// /// # Examples diff --git a/library/alloc/src/collections/btree/set/tests.rs b/library/alloc/src/collections/btree/set/tests.rs index 3762af7236af2..fd19c0078a748 100644 --- a/library/alloc/src/collections/btree/set/tests.rs +++ b/library/alloc/src/collections/btree/set/tests.rs @@ -639,27 +639,6 @@ fn test_send() { } } -#[allow(dead_code)] -fn test_ord_absence() { - fn set(mut set: BTreeSet) { - set.is_empty(); - set.len(); - set.clear(); - set.iter(); - set.into_iter(); - } - - fn set_debug(set: BTreeSet) { - format!("{:?}", set); - format!("{:?}", set.iter()); - format!("{:?}", set.into_iter()); - } - - fn set_clone(mut set: BTreeSet) { - set.clone_from(&set.clone()); - } -} - #[test] fn test_append() { let mut a = BTreeSet::new(); diff --git a/library/alloc/src/collections/btree/split.rs b/library/alloc/src/collections/btree/split.rs index 1921982464ae4..62c5e3a46d74d 100644 --- a/library/alloc/src/collections/btree/split.rs +++ b/library/alloc/src/collections/btree/split.rs @@ -4,71 +4,46 @@ use super::search::SearchResult::*; use core::borrow::Borrow; impl Root { - /// Calculates the length of both trees that result from splitting up - /// a given number of distinct key-value pairs. - pub fn calc_split_length( - total_num: usize, - root_a: &Root, - root_b: &Root, - ) -> (usize, usize) { - let (length_a, length_b); - if root_a.height() < root_b.height() { - length_a = root_a.reborrow().calc_length(); - length_b = total_num - length_a; - debug_assert_eq!(length_b, root_b.reborrow().calc_length()); - } else { - length_b = root_b.reborrow().calc_length(); - length_a = total_num - length_b; - debug_assert_eq!(length_a, root_a.reborrow().calc_length()); - } - (length_a, length_b) - } - - /// Split off a tree with key-value pairs at and after the given key. - /// The result is meaningful only if the tree is ordered by key, - /// and if the ordering of `Q` corresponds to that of `K`. - /// If `self` respects all `BTreeMap` tree invariants, then both - /// `self` and the returned tree will respect those invariants. - pub fn split_off(&mut self, key: &Q) -> Self + pub fn split_off(&mut self, right_root: &mut Self, key: &Q) where K: Borrow, { + debug_assert!(right_root.height() == 0); + debug_assert!(right_root.len() == 0); + let left_root = self; - let mut right_root = Root::new_pillar(left_root.height()); - let mut left_node = left_root.borrow_mut(); - let mut right_node = right_root.borrow_mut(); - - loop { - let mut split_edge = match left_node.search_node(key) { - // key is going to the right tree - Found(kv) => kv.left_edge(), - GoDown(edge) => edge, - }; - - split_edge.move_suffix(&mut right_node); - - match (split_edge.force(), right_node.force()) { - (Internal(edge), Internal(node)) => { - left_node = edge.descend(); - right_node = node.first_edge().descend(); + for _ in 0..left_root.height() { + right_root.push_internal_level(); + } + + { + let mut left_node = left_root.borrow_mut(); + let mut right_node = right_root.borrow_mut(); + + loop { + let mut split_edge = match left_node.search_node(key) { + // key is going to the right tree + Found(kv) => kv.left_edge(), + GoDown(edge) => edge, + }; + + split_edge.move_suffix(&mut right_node); + + match (split_edge.force(), right_node.force()) { + (Internal(edge), Internal(node)) => { + left_node = edge.descend(); + right_node = node.first_edge().descend(); + } + (Leaf(_), Leaf(_)) => { + break; + } + _ => unreachable!(), } - (Leaf(_), Leaf(_)) => break, - _ => unreachable!(), } } left_root.fix_right_border(); right_root.fix_left_border(); - right_root - } - - /// Creates a tree consisting of empty nodes. - fn new_pillar(height: usize) -> Self { - let mut root = Root::new(); - for _ in 0..height { - root.push_internal_level(); - } - root } /// Removes empty levels on the top, but keeps an empty leaf if the entire tree is empty. diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs index 99c42a4ba4423..785ce8d606b67 100644 --- a/library/alloc/src/lib.rs +++ b/library/alloc/src/lib.rs @@ -76,7 +76,6 @@ #![cfg_attr(test, feature(test))] #![cfg_attr(test, feature(new_uninit))] #![feature(allocator_api)] -#![feature(vec_extend_from_within)] #![feature(array_chunks)] #![feature(array_methods)] #![feature(array_windows)] @@ -102,7 +101,6 @@ #![feature(fn_traits)] #![feature(fundamental)] #![feature(inplace_iteration)] -#![feature(int_bits_const)] #![feature(lang_items)] #![feature(layout_for_ptr)] #![feature(maybe_uninit_ref)] @@ -111,7 +109,6 @@ #![feature(nll)] #![feature(nonnull_slice_from_raw_parts)] #![feature(auto_traits)] -#![feature(option_result_unwrap_unchecked)] #![feature(or_patterns)] #![feature(pattern)] #![feature(ptr_internals)] diff --git a/library/alloc/src/task.rs b/library/alloc/src/task.rs index ab7611ae071e7..a80550a96531a 100644 --- a/library/alloc/src/task.rs +++ b/library/alloc/src/task.rs @@ -1,4 +1,4 @@ -#![stable(feature = "wake_trait", since = "1.51.0")] +#![unstable(feature = "wake_trait", issue = "69912")] //! Types and Traits for working with asynchronous tasks. use core::mem::ManuallyDrop; use core::task::{RawWaker, RawWakerVTable, Waker}; @@ -16,70 +16,18 @@ use crate::sync::Arc; /// to wake up a task is stored in an [`Arc`]. Some executors (especially /// those for embedded systems) cannot use this API, which is why [`RawWaker`] /// exists as an alternative for those systems. -/// -/// [arc]: ../../std/sync/struct.Arc.html -/// -/// # Examples -/// -/// A basic `block_on` function that takes a future and runs it to completion on -/// the current thread. -/// -/// **Note:** This example trades correctness for simplicity. In order to prevent -/// deadlocks, production-grade implementations will also need to handle -/// intermediate calls to `thread::unpark` as well as nested invocations. -/// -/// ```rust -/// use std::future::Future; -/// use std::sync::Arc; -/// use std::task::{Context, Poll, Wake}; -/// use std::thread::{self, Thread}; -/// -/// /// A waker that wakes up the current thread when called. -/// struct ThreadWaker(Thread); -/// -/// impl Wake for ThreadWaker { -/// fn wake(self: Arc) { -/// self.0.unpark(); -/// } -/// } -/// -/// /// Run a future to completion on the current thread. -/// fn block_on(fut: impl Future) -> T { -/// // Pin the future so it can be polled. -/// let mut fut = Box::pin(fut); -/// -/// // Create a new context to be passed to the future. -/// let t = thread::current(); -/// let waker = Arc::new(ThreadWaker(t)).into(); -/// let mut cx = Context::from_waker(&waker); -/// -/// // Run the future to completion. -/// loop { -/// match fut.as_mut().poll(&mut cx) { -/// Poll::Ready(res) => return res, -/// Poll::Pending => thread::park(), -/// } -/// } -/// } -/// -/// block_on(async { -/// println!("Hi from inside a future!"); -/// }); -/// ``` -#[stable(feature = "wake_trait", since = "1.51.0")] +#[unstable(feature = "wake_trait", issue = "69912")] pub trait Wake { /// Wake this task. - #[stable(feature = "wake_trait", since = "1.51.0")] + #[unstable(feature = "wake_trait", issue = "69912")] fn wake(self: Arc); /// Wake this task without consuming the waker. /// /// If an executor supports a cheaper way to wake without consuming the /// waker, it should override this method. By default, it clones the - /// [`Arc`] and calls [`wake`] on the clone. - /// - /// [`wake`]: Wake::wake - #[stable(feature = "wake_trait", since = "1.51.0")] + /// [`Arc`] and calls `wake` on the clone. + #[unstable(feature = "wake_trait", issue = "69912")] fn wake_by_ref(self: &Arc) { self.clone().wake(); } @@ -87,7 +35,7 @@ pub trait Wake { #[cfg_attr(bootstrap, allow(rustc::ineffective_unstable_trait_impl))] #[cfg_attr(not(bootstrap), allow(ineffective_unstable_trait_impl))] -#[stable(feature = "wake_trait", since = "1.51.0")] +#[unstable(feature = "wake_trait", issue = "69912")] impl From> for Waker { fn from(waker: Arc) -> Waker { // SAFETY: This is safe because raw_waker safely constructs @@ -98,7 +46,7 @@ impl From> for Waker { #[cfg_attr(bootstrap, allow(rustc::ineffective_unstable_trait_impl))] #[cfg_attr(not(bootstrap), allow(ineffective_unstable_trait_impl))] -#[stable(feature = "wake_trait", since = "1.51.0")] +#[unstable(feature = "wake_trait", issue = "69912")] impl From> for RawWaker { fn from(waker: Arc) -> RawWaker { raw_waker(waker) diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index ede1601fa33cc..9aea19f04c644 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -1825,27 +1825,11 @@ impl Vec { #[unstable(feature = "vec_spare_capacity", issue = "75017")] #[inline] pub fn spare_capacity_mut(&mut self) -> &mut [MaybeUninit] { - self.split_at_spare_mut().1 - } - - #[inline] - fn split_at_spare_mut(&mut self) -> (&mut [T], &mut [MaybeUninit]) { - let ptr = self.as_mut_ptr(); - - // Safety: - // - `ptr` is guaranteed to be in bounds for `capacity` elements - // - `len` is guaranteed to less or equal to `capacity` - // - `MaybeUninit` has the same layout as `T` - let spare_ptr = unsafe { ptr.cast::>().add(self.len) }; - - // Safety: - // - `ptr` is guaranteed to be valid for `len` elements - // - `spare_ptr` is offseted from `ptr` by `len`, so it doesn't overlap `initialized` slice unsafe { - let initialized = slice::from_raw_parts_mut(ptr, self.len); - let spare = slice::from_raw_parts_mut(spare_ptr, self.buf.capacity() - self.len); - - (initialized, spare) + slice::from_raw_parts_mut( + self.as_mut_ptr().add(self.len) as *mut MaybeUninit, + self.buf.capacity() - self.len, + ) } } } @@ -1907,39 +1891,6 @@ impl Vec { pub fn extend_from_slice(&mut self, other: &[T]) { self.spec_extend(other.iter()) } - - /// Copies elements from `src` range to the end of the vector. - /// - /// ## Examples - /// - /// ``` - /// #![feature(vec_extend_from_within)] - /// - /// let mut vec = vec![0, 1, 2, 3, 4]; - /// - /// vec.extend_from_within(2..); - /// assert_eq!(vec, [0, 1, 2, 3, 4, 2, 3, 4]); - /// - /// vec.extend_from_within(..2); - /// assert_eq!(vec, [0, 1, 2, 3, 4, 2, 3, 4, 0, 1]); - /// - /// vec.extend_from_within(4..8); - /// assert_eq!(vec, [0, 1, 2, 3, 4, 2, 3, 4, 0, 1, 4, 2, 3, 4]); - /// ``` - #[unstable(feature = "vec_extend_from_within", issue = "81656")] - pub fn extend_from_within(&mut self, src: R) - where - R: RangeBounds, - { - let range = src.assert_len(self.len()); - self.reserve(range.len()); - - // SAFETY: - // - `assert_len` guarantees that the given range is valid for indexing self - unsafe { - self.spec_extend_from_within(range); - } - } } // This code generalizes `extend_with_{element,default}`. @@ -2047,62 +1998,6 @@ pub fn from_elem_in(elem: T, n: usize, alloc: A) -> Vec< ::from_elem(elem, n, alloc) } -trait ExtendFromWithinSpec { - /// Safety: - /// - `src` needs to be valid index - /// - `self.capacity() - self.len()` must be `>= src.len()` - unsafe fn spec_extend_from_within(&mut self, src: Range); -} - -impl ExtendFromWithinSpec for Vec { - default unsafe fn spec_extend_from_within(&mut self, src: Range) { - let initialized = { - let (this, spare) = self.split_at_spare_mut(); - - // Safety: - // - caller guaratees that src is a valid index - let to_clone = unsafe { this.get_unchecked(src) }; - - to_clone.iter().cloned().zip(spare.iter_mut()).map(|(e, s)| s.write(e)).count() - }; - - // Safety: - // - elements were just initialized - unsafe { - let new_len = self.len() + initialized; - self.set_len(new_len); - } - } -} - -impl ExtendFromWithinSpec for Vec { - unsafe fn spec_extend_from_within(&mut self, src: Range) { - let count = src.len(); - { - let (init, spare) = self.split_at_spare_mut(); - - // Safety: - // - caller guaratees that `src` is a valid index - let source = unsafe { init.get_unchecked(src) }; - - // Safety: - // - Both pointers are created from unique slice references (`&mut [_]`) - // so they are valid and do not overlap. - // - Elements are :Copy so it's OK to to copy them, without doing - // anything with the original values - // - `count` is equal to the len of `source`, so source is valid for - // `count` reads - // - `.reserve(count)` guarantees that `spare.len() >= count` so spare - // is valid for `count` writes - unsafe { ptr::copy_nonoverlapping(source.as_ptr(), spare.as_mut_ptr() as _, count) }; - } - - // Safety: - // - The elements were just initialized by `copy_nonoverlapping` - self.len += count; - } -} - //////////////////////////////////////////////////////////////////////////////// // Common trait implementations for Vec //////////////////////////////////////////////////////////////////////////////// diff --git a/library/alloc/tests/lib.rs b/library/alloc/tests/lib.rs index dd98f806451d8..7b00354629875 100644 --- a/library/alloc/tests/lib.rs +++ b/library/alloc/tests/lib.rs @@ -17,10 +17,8 @@ #![feature(binary_heap_retain)] #![feature(inplace_iteration)] #![feature(iter_map_while)] -#![feature(int_bits_const)] #![feature(vecdeque_binary_search)] #![feature(slice_group_by)] -#![feature(vec_extend_from_within)] use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; diff --git a/library/alloc/tests/vec.rs b/library/alloc/tests/vec.rs index 5c7ff67bc621c..e19406d7a0697 100644 --- a/library/alloc/tests/vec.rs +++ b/library/alloc/tests/vec.rs @@ -1954,73 +1954,3 @@ fn test_vec_swap() { assert_eq!(a[0], 42); assert_eq!(n, 0); } - -#[test] -fn test_extend_from_within_spec() { - #[derive(Copy)] - struct CopyOnly; - - impl Clone for CopyOnly { - fn clone(&self) -> Self { - panic!("extend_from_within must use specialization on copy"); - } - } - - vec![CopyOnly, CopyOnly].extend_from_within(..); -} - -#[test] -fn test_extend_from_within_clone() { - let mut v = vec![String::from("sssss"), String::from("12334567890"), String::from("c")]; - v.extend_from_within(1..); - - assert_eq!(v, ["sssss", "12334567890", "c", "12334567890", "c"]); -} - -#[test] -fn test_extend_from_within_complete_rande() { - let mut v = vec![0, 1, 2, 3]; - v.extend_from_within(..); - - assert_eq!(v, [0, 1, 2, 3, 0, 1, 2, 3]); -} - -#[test] -fn test_extend_from_within_empty_rande() { - let mut v = vec![0, 1, 2, 3]; - v.extend_from_within(1..1); - - assert_eq!(v, [0, 1, 2, 3]); -} - -#[test] -#[should_panic] -fn test_extend_from_within_out_of_rande() { - let mut v = vec![0, 1]; - v.extend_from_within(..3); -} - -#[test] -fn test_extend_from_within_zst() { - let mut v = vec![(); 8]; - v.extend_from_within(3..7); - - assert_eq!(v, [(); 12]); -} - -#[test] -fn test_extend_from_within_empty_vec() { - let mut v = Vec::::new(); - v.extend_from_within(..); - - assert_eq!(v, []); -} - -#[test] -fn test_extend_from_within() { - let mut v = vec![String::from("a"), String::from("b"), String::from("c")]; - v.extend_from_within(1..=2); - v.extend_from_within(..=1); - - assert_eq!(v, ["a", "b", "c", "b", "c", "a", "b"]); -} diff --git a/library/core/src/alloc/layout.rs b/library/core/src/alloc/layout.rs index 9dc3f05dae5ac..c572c66ce328b 100644 --- a/library/core/src/alloc/layout.rs +++ b/library/core/src/alloc/layout.rs @@ -400,7 +400,7 @@ impl Layout { #[stable(feature = "alloc_layout", since = "1.28.0")] #[rustc_deprecated( - since = "1.52.0", + since = "1.51.0", reason = "Name does not follow std convention, use LayoutError", suggestion = "LayoutError" )] @@ -409,7 +409,7 @@ pub type LayoutErr = LayoutError; /// The parameters given to `Layout::from_size_align` /// or some other `Layout` constructor /// do not satisfy its documented constraints. -#[stable(feature = "alloc_layout_error", since = "1.50.0")] +#[stable(feature = "alloc_layout_error", since = "1.49.0")] #[derive(Clone, PartialEq, Eq, Debug)] pub struct LayoutError { private: (), diff --git a/library/core/src/alloc/mod.rs b/library/core/src/alloc/mod.rs index 06a761531b676..045eb58d0135a 100644 --- a/library/core/src/alloc/mod.rs +++ b/library/core/src/alloc/mod.rs @@ -11,14 +11,14 @@ pub use self::global::GlobalAlloc; pub use self::layout::Layout; #[stable(feature = "alloc_layout", since = "1.28.0")] #[rustc_deprecated( - since = "1.52.0", + since = "1.51.0", reason = "Name does not follow std convention, use LayoutError", suggestion = "LayoutError" )] #[allow(deprecated, deprecated_in_future)] pub use self::layout::LayoutErr; -#[stable(feature = "alloc_layout_error", since = "1.50.0")] +#[stable(feature = "alloc_layout_error", since = "1.49.0")] pub use self::layout::LayoutError; use crate::fmt; @@ -342,10 +342,7 @@ pub unsafe trait Allocator { /// /// The returned adaptor also implements `Allocator` and will simply borrow this. #[inline(always)] - fn by_ref(&self) -> &Self - where - Self: Sized, - { + fn by_ref(&self) -> &Self { self } } diff --git a/library/core/src/cell.rs b/library/core/src/cell.rs index 885422732e401..fa0fbaa35c95c 100644 --- a/library/core/src/cell.rs +++ b/library/core/src/cell.rs @@ -11,10 +11,12 @@ //! mutate it. //! //! Shareable mutable containers exist to permit mutability in a controlled manner, even in the -//! presence of aliasing. Both [`Cell`] and [`RefCell`] allow doing this in a single-threaded +//! presence of aliasing. Both `Cell` and `RefCell` allow doing this in a single-threaded //! way. However, neither `Cell` nor `RefCell` are thread safe (they do not implement -//! [`Sync`]). If you need to do aliasing and mutation between multiple threads it is possible to -//! use [`Mutex`], [`RwLock`] or [`atomic`] types. +//! `Sync`). If you need to do aliasing and mutation between multiple threads it is possible to +//! use [`Mutex`](../../std/sync/struct.Mutex.html), +//! [`RwLock`](../../std/sync/struct.RwLock.html) or +//! [`atomic`](../../core/sync/atomic/index.html) types. //! //! Values of the `Cell` and `RefCell` types may be mutated through shared references (i.e. //! the common `&T` type), whereas most Rust types can only be mutated through unique (`&mut T`) @@ -26,14 +28,13 @@ //! one must use the `RefCell` type, acquiring a write lock before mutating. `Cell` provides //! methods to retrieve and change the current interior value: //! -//! - For types that implement [`Copy`], the [`get`](Cell::get) method retrieves the current -//! interior value. -//! - For types that implement [`Default`], the [`take`](Cell::take) method replaces the current -//! interior value with [`Default::default()`] and returns the replaced value. -//! - For all types, the [`replace`](Cell::replace) method replaces the current interior value and -//! returns the replaced value and the [`into_inner`](Cell::into_inner) method consumes the -//! `Cell` and returns the interior value. Additionally, the [`set`](Cell::set) method -//! replaces the interior value, dropping the replaced value. +//! - For types that implement `Copy`, the `get` method retrieves the current interior value. +//! - For types that implement `Default`, the `take` method replaces the current interior value +//! with `Default::default()` and returns the replaced value. +//! - For all types, the `replace` method replaces the current interior value and returns the +//! replaced value and the `into_inner` method consumes the `Cell` and returns the interior +//! value. Additionally, the `set` method replaces the interior value, dropping the replaced +//! value. //! //! `RefCell` uses Rust's lifetimes to implement 'dynamic borrowing', a process whereby one can //! claim temporary, exclusive, mutable access to the inner value. Borrows for `RefCell`s are @@ -53,12 +54,12 @@ //! //! * Introducing mutability 'inside' of something immutable //! * Implementation details of logically-immutable methods. -//! * Mutating implementations of [`Clone`]. +//! * Mutating implementations of `Clone`. //! //! ## Introducing mutability 'inside' of something immutable //! -//! Many shared smart pointer types, including [`Rc`] and [`Arc`], provide containers that can -//! be cloned and shared between multiple parties. Because the contained values may be +//! Many shared smart pointer types, including `Rc` and `Arc`, provide containers that can be +//! cloned and shared between multiple parties. Because the contained values may be //! multiply-aliased, they can only be borrowed with `&`, not `&mut`. Without cells it would be //! impossible to mutate data inside of these smart pointers at all. //! @@ -90,7 +91,7 @@ //! ``` //! //! Note that this example uses `Rc` and not `Arc`. `RefCell`s are for single-threaded -//! scenarios. Consider using [`RwLock`] or [`Mutex`] if you need shared mutability in a +//! scenarios. Consider using `RwLock` or `Mutex` if you need shared mutability in a //! multi-threaded situation. //! //! ## Implementation details of logically-immutable methods @@ -126,10 +127,10 @@ //! ## Mutating implementations of `Clone` //! //! This is simply a special - but common - case of the previous: hiding mutability for operations -//! that appear to be immutable. The [`clone`](Clone::clone) method is expected to not change the -//! source value, and is declared to take `&self`, not `&mut self`. Therefore, any mutation that -//! happens in the `clone` method must use cell types. For example, [`Rc`] maintains its -//! reference counts within a `Cell`. +//! that appear to be immutable. The `clone` method is expected to not change the source value, and +//! is declared to take `&self`, not `&mut self`. Therefore, any mutation that happens in the +//! `clone` method must use cell types. For example, `Rc` maintains its reference counts within a +//! `Cell`. //! //! ``` //! use std::cell::Cell; @@ -184,11 +185,6 @@ //! } //! ``` //! -//! [`Arc`]: ../../std/sync/struct.Arc.html -//! [`Rc`]: ../../std/rc/struct.Rc.html -//! [`RwLock`]: ../../std/sync/struct.RwLock.html -//! [`Mutex`]: ../../std/sync/struct.Mutex.html -//! [`atomic`]: ../../core/sync/atomic/index.html #![stable(feature = "rust1", since = "1.0.0")] diff --git a/library/core/src/default.rs b/library/core/src/default.rs index 28ec3279459ab..9a8d65cd4e06b 100644 --- a/library/core/src/default.rs +++ b/library/core/src/default.rs @@ -173,11 +173,9 @@ macro_rules! default_impl { impl Default for $t { #[inline] #[doc = $doc] - fn default() -> $t { - $v - } + fn default() -> $t { $v } } - }; + } } default_impl! { (), (), "Returns the default value of `()`" } diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index 080a0a21188ea..7c1a9b82f99b2 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -1586,7 +1586,7 @@ extern "rust-intrinsic" { /// Safe wrappers for this intrinsic are available on the integer /// primitives via the `checked_div` method. For example, /// [`u32::checked_div`] - #[rustc_const_stable(feature = "const_int_unchecked_arith", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_int_unchecked_arith", issue = "none")] pub fn unchecked_div(x: T, y: T) -> T; /// Returns the remainder of an unchecked division, resulting in /// undefined behavior when `y == 0` or `x == T::MIN && y == -1` @@ -1594,7 +1594,7 @@ extern "rust-intrinsic" { /// Safe wrappers for this intrinsic are available on the integer /// primitives via the `checked_rem` method. For example, /// [`u32::checked_rem`] - #[rustc_const_stable(feature = "const_int_unchecked_arith", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_int_unchecked_arith", issue = "none")] pub fn unchecked_rem(x: T, y: T) -> T; /// Performs an unchecked left shift, resulting in undefined behavior when diff --git a/library/core/src/iter/adapters/fuse.rs b/library/core/src/iter/adapters/fuse.rs index 7a852c2cb9da5..ae07406531593 100644 --- a/library/core/src/iter/adapters/fuse.rs +++ b/library/core/src/iter/adapters/fuse.rs @@ -1,8 +1,6 @@ use crate::intrinsics; use crate::iter::adapters::{zip::try_get_unchecked, InPlaceIterable, SourceIter}; -use crate::iter::{ - DoubleEndedIterator, ExactSizeIterator, FusedIterator, TrustedLen, TrustedRandomAccess, -}; +use crate::iter::{DoubleEndedIterator, ExactSizeIterator, FusedIterator, TrustedRandomAccess}; use crate::ops::Try; /// An iterator that yields `None` forever after the underlying iterator @@ -184,19 +182,8 @@ where } } -#[unstable(feature = "trusted_len", issue = "37572")] -// SAFETY: `TrustedLen` requires that an accurate length is reported via `size_hint()`. As `Fuse` -// is just forwarding this to the wrapped iterator `I` this property is preserved and it is safe to -// implement `TrustedLen` here. -unsafe impl TrustedLen for Fuse where I: TrustedLen {} - #[doc(hidden)] #[unstable(feature = "trusted_random_access", issue = "none")] -// SAFETY: `TrustedRandomAccess` requires that `size_hint()` must be exact and cheap to call, and -// `Iterator::__iterator_get_unchecked()` must be implemented accordingly. -// -// This is safe to implement as `Fuse` is just forwarding these to the wrapped iterator `I`, which -// preserves these properties. unsafe impl TrustedRandomAccess for Fuse where I: TrustedRandomAccess, diff --git a/library/core/src/iter/adapters/map.rs b/library/core/src/iter/adapters/map.rs index f238baf743c55..12673806ec40d 100644 --- a/library/core/src/iter/adapters/map.rs +++ b/library/core/src/iter/adapters/map.rs @@ -60,7 +60,6 @@ pub struct Map { iter: I, f: F, } - impl Map { pub(in crate::iter) fn new(iter: I, f: F) -> Map { Map { iter, f } diff --git a/library/core/src/iter/adapters/peekable.rs b/library/core/src/iter/adapters/peekable.rs index 43301444e3e2c..2f8b9653c59da 100644 --- a/library/core/src/iter/adapters/peekable.rs +++ b/library/core/src/iter/adapters/peekable.rs @@ -265,6 +265,7 @@ impl Peekable { /// # Examples /// Consume a number if it's equal to 0. /// ``` + /// #![feature(peekable_next_if)] /// let mut iter = (0..5).peekable(); /// // The first item of the iterator is 0; consume it. /// assert_eq!(iter.next_if(|&x| x == 0), Some(0)); @@ -276,13 +277,14 @@ impl Peekable { /// /// Consume any number less than 10. /// ``` + /// #![feature(peekable_next_if)] /// let mut iter = (1..20).peekable(); /// // Consume all numbers less than 10 /// while iter.next_if(|&x| x < 10).is_some() {} /// // The next value returned will be 10 /// assert_eq!(iter.next(), Some(10)); /// ``` - #[stable(feature = "peekable_next_if", since = "1.51.0")] + #[unstable(feature = "peekable_next_if", issue = "72480")] pub fn next_if(&mut self, func: impl FnOnce(&I::Item) -> bool) -> Option { match self.next() { Some(matched) if func(&matched) => Some(matched), @@ -300,6 +302,7 @@ impl Peekable { /// # Example /// Consume a number if it's equal to 0. /// ``` + /// #![feature(peekable_next_if)] /// let mut iter = (0..5).peekable(); /// // The first item of the iterator is 0; consume it. /// assert_eq!(iter.next_if_eq(&0), Some(0)); @@ -308,7 +311,7 @@ impl Peekable { /// // `next_if_eq` saves the value of the next item if it was not equal to `expected`. /// assert_eq!(iter.next(), Some(1)); /// ``` - #[stable(feature = "peekable_next_if", since = "1.51.0")] + #[unstable(feature = "peekable_next_if", issue = "72480")] pub fn next_if_eq(&mut self, expected: &T) -> Option where T: ?Sized, diff --git a/library/core/src/iter/traits/exact_size.rs b/library/core/src/iter/traits/exact_size.rs index 167db3359f240..996d62e2b4a42 100644 --- a/library/core/src/iter/traits/exact_size.rs +++ b/library/core/src/iter/traits/exact_size.rs @@ -13,12 +13,6 @@ /// implement it. However, you may be able to provide a more performant /// implementation than the default, so overriding it in this case makes sense. /// -/// Note that this trait is a safe trait and as such does *not* and *cannot* -/// guarantee that the returned length is correct. This means that `unsafe` -/// code **must not** rely on the correctness of [`Iterator::size_hint`]. The -/// unstable and unsafe [`TrustedLen`](super::marker::TrustedLen) trait gives -/// this additional guarantee. -/// /// [`len`]: ExactSizeIterator::len /// /// # Examples diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index 5faa4b825605f..9f7ced829b0ac 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -1213,7 +1213,7 @@ pub trait Iterator { /// the iteration should stop, but wasn't placed back into the iterator. /// /// Note that unlike [`take_while`] this iterator is **not** fused. - /// It is also not specified what this iterator returns after the first [`None`] is returned. + /// It is also not specified what this iterator returns after the first` None` is returned. /// If you need fused iterator, use [`fuse`]. /// /// [`fuse`]: Iterator::fuse @@ -2028,8 +2028,7 @@ pub trait Iterator { self.try_fold((), call(f)) } - /// Folds every element into an accumulator by applying an operation, - /// returning the final result. + /// An iterator method that applies a function, producing a single, final value. /// /// `fold()` takes two arguments: an initial value, and a closure with two /// arguments: an 'accumulator', and an element. The closure returns the value that @@ -2050,9 +2049,6 @@ pub trait Iterator { /// may not terminate for infinite iterators, even on traits for which a /// result is determinable in finite time. /// - /// Note: [`reduce()`] can be used to use the first element as the initial - /// value, if the accumulator type and item type is the same. - /// /// # Note to Implementors /// /// Several of the other (forward) methods have default implementations in @@ -2108,8 +2104,6 @@ pub trait Iterator { /// // they're the same /// assert_eq!(result, result2); /// ``` - /// - /// [`reduce()`]: Iterator::reduce #[doc(alias = "reduce")] #[doc(alias = "inject")] #[inline] @@ -2126,15 +2120,10 @@ pub trait Iterator { accum } - /// Reduces the elements to a single one, by repeatedly applying a reducing - /// operation. - /// - /// If the iterator is empty, returns [`None`]; otherwise, returns the - /// result of the reduction. - /// - /// For iterators with at least one element, this is the same as [`fold()`] - /// with the first element of the iterator as the initial value, folding - /// every subsequent element into it. + /// The same as [`fold()`], but uses the first element in the + /// iterator as the initial value, folding every subsequent element into it. + /// If the iterator is empty, return [`None`]; otherwise, return the result + /// of the fold. /// /// [`fold()`]: Iterator::fold /// @@ -2143,11 +2132,13 @@ pub trait Iterator { /// Find the maximum value: /// /// ``` + /// #![feature(iterator_fold_self)] + /// /// fn find_max(iter: I) -> Option /// where I: Iterator, /// I::Item: Ord, /// { - /// iter.reduce(|a, b| { + /// iter.fold_first(|a, b| { /// if a >= b { a } else { b } /// }) /// } @@ -2158,8 +2149,8 @@ pub trait Iterator { /// assert_eq!(find_max(b.iter()), None); /// ``` #[inline] - #[stable(feature = "iterator_fold_self", since = "1.51.0")] - fn reduce(mut self, f: F) -> Option + #[unstable(feature = "iterator_fold_self", issue = "68125")] + fn fold_first(mut self, f: F) -> Option where Self: Sized, F: FnMut(Self::Item, Self::Item) -> Self::Item, @@ -2205,7 +2196,6 @@ pub trait Iterator { /// // we can still use `iter`, as there are more elements. /// assert_eq!(iter.next(), Some(&3)); /// ``` - #[doc(alias = "every")] #[inline] #[stable(feature = "rust1", since = "1.0.0")] fn all(&mut self, f: F) -> bool @@ -2657,7 +2647,7 @@ pub trait Iterator { move |x, y| cmp::max_by(x, y, &mut compare) } - self.reduce(fold(compare)) + self.fold_first(fold(compare)) } /// Returns the element that gives the minimum value from the @@ -2717,7 +2707,7 @@ pub trait Iterator { move |x, y| cmp::min_by(x, y, &mut compare) } - self.reduce(fold(compare)) + self.fold_first(fold(compare)) } /// Reverses an iterator's direction. diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs index fd4a76c1eb548..a69b840e4bf14 100644 --- a/library/core/src/lib.rs +++ b/library/core/src/lib.rs @@ -73,8 +73,11 @@ #![feature(const_discriminant)] #![feature(const_cell_into_inner)] #![feature(const_intrinsic_copy)] +#![feature(const_checked_int_methods)] +#![feature(const_euclidean_int_methods)] #![feature(const_float_classify)] #![feature(const_float_bits_conv)] +#![feature(const_overflowing_int_methods)] #![feature(const_int_unchecked_arith)] #![feature(const_mut_refs)] #![feature(const_cttz)] diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs index 7aaf5a5fd4614..10d30609aca32 100644 --- a/library/core/src/macros/mod.rs +++ b/library/core/src/macros/mod.rs @@ -1234,7 +1234,7 @@ pub(crate) mod builtin { #[rustc_builtin_macro] #[macro_export] #[rustc_diagnostic_item = "assert_macro"] - #[allow_internal_unstable(core_panic, edition_panic)] + #[allow_internal_unstable(core_panic)] macro_rules! assert { ($cond:expr $(,)?) => {{ /* compiler built-in */ }}; ($cond:expr, $($arg:tt)+) => {{ /* compiler built-in */ }}; @@ -1324,14 +1324,6 @@ pub(crate) mod builtin { (false) => {{ /* compiler built-in */ }}; } - /// Attribute macro used to apply derive macros. - #[cfg(not(bootstrap))] - #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_builtin_macro] - pub macro derive($item:item) { - /* compiler built-in */ - } - /// Attribute macro applied to a function to turn it into a unit test. #[stable(feature = "rust1", since = "1.0.0")] #[allow_internal_unstable(test, rustc_attrs)] diff --git a/library/core/src/macros/panic.md b/library/core/src/macros/panic.md index 6e502426df906..a02e74d5e5a4d 100644 --- a/library/core/src/macros/panic.md +++ b/library/core/src/macros/panic.md @@ -10,23 +10,22 @@ tests. `panic!` is closely tied with the `unwrap` method of both `panic!` when they are set to [`None`] or [`Err`] variants. This macro is used to inject panic into a Rust thread, causing the thread to -panic entirely. This macro panics with a string and uses the [`format!`] syntax -for building the message. - -Each thread's panic can be reaped as the [`Box`]`<`[`Any`]`>` type, -which contains either a `&str` or `String` for regular `panic!()` invocations. -To panic with a value of another other type, [`panic_any`] can be used. +panic entirely. Each thread's panic can be reaped as the [`Box`]`<`[`Any`]`>` type, +and the single-argument form of the `panic!` macro will be the value which +is transmitted. [`Result`] enum is often a better solution for recovering from errors than using the `panic!` macro. This macro should be used to avoid proceeding using incorrect values, such as from external sources. Detailed information about error handling is found in the [book]. +The multi-argument form of this macro panics with a string and has the +[`format!`] syntax for building a string. + See also the macro [`compile_error!`], for raising errors during compilation. [ounwrap]: Option::unwrap [runwrap]: Result::unwrap -[`panic_any`]: ../std/panic/fn.panic_any.html [`Box`]: ../std/boxed/struct.Box.html [`Any`]: crate::any::Any [`format!`]: ../std/macro.format.html @@ -43,6 +42,6 @@ program with code `101`. # #![allow(unreachable_code)] panic!(); panic!("this is a terrible mistake!"); +panic!(4); // panic with the value of 4 to be collected elsewhere panic!("this is a {} {message}", "fancy", message = "message"); -std::panic::panic_any(4); // panic with the value of 4 to be collected elsewhere ``` diff --git a/library/core/src/mem/maybe_uninit.rs b/library/core/src/mem/maybe_uninit.rs index 3760f5c479481..05bcd90d3ca76 100644 --- a/library/core/src/mem/maybe_uninit.rs +++ b/library/core/src/mem/maybe_uninit.rs @@ -172,42 +172,11 @@ use crate::ptr; /// /// ## Initializing a struct field-by-field /// -/// You can use `MaybeUninit`, and the [`std::ptr::addr_of_mut`] macro, to initialize structs field by field: +/// There is currently no supported way to create a raw pointer or reference +/// to a field of a struct inside `MaybeUninit`. That means it is not possible +/// to create a struct by calling `MaybeUninit::uninit::()` and then writing +/// to its fields. /// -/// ```rust -/// use std::mem::MaybeUninit; -/// use std::ptr::addr_of_mut; -/// -/// #[derive(Debug, PartialEq)] -/// pub struct Foo { -/// name: String, -/// list: Vec, -/// } -/// -/// let foo = { -/// let mut uninit: MaybeUninit = MaybeUninit::uninit(); -/// let ptr = uninit.as_mut_ptr(); -/// -/// // Initializing the `name` field -/// unsafe { addr_of_mut!((*ptr).name).write("Bob".to_string()); } -/// -/// // Initializing the `list` field -/// // If there is a panic here, then the `String` in the `name` field leaks. -/// unsafe { addr_of_mut!((*ptr).list).write(vec![0, 1, 2]); } -/// -/// // All the fields are initialized, so we call `assume_init` to get an initialized Foo. -/// unsafe { uninit.assume_init() } -/// }; -/// -/// assert_eq!( -/// foo, -/// Foo { -/// name: "Bob".to_string(), -/// list: vec![0, 1, 2] -/// } -/// ); -/// ``` -/// [`std::ptr::addr_of_mut`]: crate::ptr::addr_of_mut /// [ub]: ../../reference/behavior-considered-undefined.html /// /// # Layout diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs index 778e34e634f64..64cf5286eb14a 100644 --- a/library/core/src/mem/mod.rs +++ b/library/core/src/mem/mod.rs @@ -889,7 +889,6 @@ pub fn replace(dest: &mut T, mut src: T) -> T { /// ``` /// /// [`RefCell`]: crate::cell::RefCell -#[doc(alias = "delete")] #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn drop(_x: T) {} diff --git a/library/core/src/num/int_macros.rs b/library/core/src/num/int_macros.rs index 1a60c3c7b7eab..96affd17cc520 100644 --- a/library/core/src/num/int_macros.rs +++ b/library/core/src/num/int_macros.rs @@ -32,10 +32,9 @@ macro_rules! int_impl { /// # Examples /// /// ``` - /// #![feature(int_bits_const)] #[doc = concat!("assert_eq!(", stringify!($SelfT), "::BITS, ", stringify!($BITS), ");")] /// ``` - #[unstable(feature = "int_bits_const", issue = "76904")] + #[stable(feature = "int_bits_const", since = "1.51.0")] pub const BITS: u32 = $BITS; /// Converts a string slice in a given base to an integer. @@ -513,7 +512,7 @@ macro_rules! int_impl { #[doc = concat!("assert_eq!((1", stringify!($SelfT), ").checked_div(0), None);")] /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_checked_int_methods", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_checked_int_methods", issue = "53718")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -539,7 +538,7 @@ macro_rules! int_impl { #[doc = concat!("assert_eq!((1", stringify!($SelfT), ").checked_div_euclid(0), None);")] /// ``` #[stable(feature = "euclidean_division", since = "1.38.0")] - #[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -565,7 +564,7 @@ macro_rules! int_impl { #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.checked_rem(-1), None);")] /// ``` #[stable(feature = "wrapping", since = "1.7.0")] - #[rustc_const_stable(feature = "const_checked_int_methods", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_checked_int_methods", issue = "53718")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -591,7 +590,7 @@ macro_rules! int_impl { #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.checked_rem_euclid(-1), None);")] /// ``` #[stable(feature = "euclidean_division", since = "1.38.0")] - #[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -949,7 +948,7 @@ macro_rules! int_impl { /// assert_eq!((-128i8).wrapping_div(-1), -128); /// ``` #[stable(feature = "num_wrapping", since = "1.2.0")] - #[rustc_const_stable(feature = "const_wrapping_int_methods", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_wrapping_int_methods", issue = "53718")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -977,7 +976,7 @@ macro_rules! int_impl { /// assert_eq!((-128i8).wrapping_div_euclid(-1), -128); /// ``` #[stable(feature = "euclidean_division", since = "1.38.0")] - #[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -1005,7 +1004,7 @@ macro_rules! int_impl { /// assert_eq!((-128i8).wrapping_rem(-1), 0); /// ``` #[stable(feature = "num_wrapping", since = "1.2.0")] - #[rustc_const_stable(feature = "const_wrapping_int_methods", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_wrapping_int_methods", issue = "53718")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -1032,7 +1031,7 @@ macro_rules! int_impl { /// assert_eq!((-128i8).wrapping_rem_euclid(-1), 0); /// ``` #[stable(feature = "euclidean_division", since = "1.38.0")] - #[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -1299,7 +1298,7 @@ macro_rules! int_impl { /// ``` #[inline] #[stable(feature = "wrapping", since = "1.7.0")] - #[rustc_const_stable(feature = "const_overflowing_int_methods", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_overflowing_int_methods", issue = "53718")] #[must_use = "this returns the result of the operation, \ without modifying the original"] pub const fn overflowing_div(self, rhs: Self) -> (Self, bool) { @@ -1329,7 +1328,7 @@ macro_rules! int_impl { /// ``` #[inline] #[stable(feature = "euclidean_division", since = "1.38.0")] - #[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")] #[must_use = "this returns the result of the operation, \ without modifying the original"] pub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool) { @@ -1360,7 +1359,7 @@ macro_rules! int_impl { /// ``` #[inline] #[stable(feature = "wrapping", since = "1.7.0")] - #[rustc_const_stable(feature = "const_overflowing_int_methods", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_overflowing_int_methods", issue = "53718")] #[must_use = "this returns the result of the operation, \ without modifying the original"] pub const fn overflowing_rem(self, rhs: Self) -> (Self, bool) { @@ -1390,7 +1389,7 @@ macro_rules! int_impl { #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.overflowing_rem_euclid(-1), (0, true));")] /// ``` #[stable(feature = "euclidean_division", since = "1.38.0")] - #[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -1615,7 +1614,7 @@ macro_rules! int_impl { /// assert_eq!((-a).div_euclid(-b), 2); // -7 >= -4 * 2 /// ``` #[stable(feature = "euclidean_division", since = "1.38.0")] - #[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -1653,7 +1652,7 @@ macro_rules! int_impl { /// assert_eq!((-a).rem_euclid(-b), 1); /// ``` #[stable(feature = "euclidean_division", since = "1.38.0")] - #[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] diff --git a/library/core/src/num/uint_macros.rs b/library/core/src/num/uint_macros.rs index ff5f432acd8ac..aee424b9b1392 100644 --- a/library/core/src/num/uint_macros.rs +++ b/library/core/src/num/uint_macros.rs @@ -32,10 +32,9 @@ macro_rules! uint_impl { /// # Examples /// /// ``` - /// #![feature(int_bits_const)] #[doc = concat!("assert_eq!(", stringify!($SelfT), "::BITS, ", stringify!($BITS), ");")] /// ``` - #[unstable(feature = "int_bits_const", issue = "76904")] + #[stable(feature = "int_bits_const", since = "1.51.0")] pub const BITS: u32 = $BITS; /// Converts a string slice in a given base to an integer. @@ -522,7 +521,7 @@ macro_rules! uint_impl { #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".checked_div(0), None);")] /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_checked_int_methods", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_checked_int_methods", issue = "53718")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -548,7 +547,7 @@ macro_rules! uint_impl { #[doc = concat!("assert_eq!(1", stringify!($SelfT), ".checked_div_euclid(0), None);")] /// ``` #[stable(feature = "euclidean_division", since = "1.38.0")] - #[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -573,7 +572,7 @@ macro_rules! uint_impl { #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".checked_rem(0), None);")] /// ``` #[stable(feature = "wrapping", since = "1.7.0")] - #[rustc_const_stable(feature = "const_checked_int_methods", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_checked_int_methods", issue = "53718")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -599,7 +598,7 @@ macro_rules! uint_impl { #[doc = concat!("assert_eq!(5", stringify!($SelfT), ".checked_rem_euclid(0), None);")] /// ``` #[stable(feature = "euclidean_division", since = "1.38.0")] - #[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -876,7 +875,7 @@ macro_rules! uint_impl { #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".wrapping_div(10), 10);")] /// ``` #[stable(feature = "num_wrapping", since = "1.2.0")] - #[rustc_const_stable(feature = "const_wrapping_int_methods", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_wrapping_int_methods", issue = "53718")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -901,7 +900,7 @@ macro_rules! uint_impl { #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".wrapping_div_euclid(10), 10);")] /// ``` #[stable(feature = "euclidean_division", since = "1.38.0")] - #[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -924,7 +923,7 @@ macro_rules! uint_impl { #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".wrapping_rem(10), 0);")] /// ``` #[stable(feature = "num_wrapping", since = "1.2.0")] - #[rustc_const_stable(feature = "const_wrapping_int_methods", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_wrapping_int_methods", issue = "53718")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -950,7 +949,7 @@ macro_rules! uint_impl { #[doc = concat!("assert_eq!(100", stringify!($SelfT), ".wrapping_rem_euclid(10), 0);")] /// ``` #[stable(feature = "euclidean_division", since = "1.38.0")] - #[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -1185,7 +1184,7 @@ macro_rules! uint_impl { /// ``` #[inline] #[stable(feature = "wrapping", since = "1.7.0")] - #[rustc_const_stable(feature = "const_overflowing_int_methods", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_overflowing_int_methods", issue = "53718")] #[must_use = "this returns the result of the operation, \ without modifying the original"] pub const fn overflowing_div(self, rhs: Self) -> (Self, bool) { @@ -1215,7 +1214,7 @@ macro_rules! uint_impl { /// ``` #[inline] #[stable(feature = "euclidean_division", since = "1.38.0")] - #[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")] #[must_use = "this returns the result of the operation, \ without modifying the original"] pub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool) { @@ -1242,7 +1241,7 @@ macro_rules! uint_impl { /// ``` #[inline] #[stable(feature = "wrapping", since = "1.7.0")] - #[rustc_const_stable(feature = "const_overflowing_int_methods", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_overflowing_int_methods", issue = "53718")] #[must_use = "this returns the result of the operation, \ without modifying the original"] pub const fn overflowing_rem(self, rhs: Self) -> (Self, bool) { @@ -1272,7 +1271,7 @@ macro_rules! uint_impl { /// ``` #[inline] #[stable(feature = "euclidean_division", since = "1.38.0")] - #[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")] #[must_use = "this returns the result of the operation, \ without modifying the original"] pub const fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool) { @@ -1456,7 +1455,7 @@ macro_rules! uint_impl { #[doc = concat!("assert_eq!(7", stringify!($SelfT), ".div_euclid(4), 1); // or any other integer type")] /// ``` #[stable(feature = "euclidean_division", since = "1.38.0")] - #[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -1484,7 +1483,7 @@ macro_rules! uint_impl { #[doc = concat!("assert_eq!(7", stringify!($SelfT), ".rem_euclid(4), 3); // or any other integer type")] /// ``` #[stable(feature = "euclidean_division", since = "1.38.0")] - #[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")] + #[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] diff --git a/library/core/src/ops/control_flow.rs b/library/core/src/ops/control_flow.rs index 2f78ba8f28e29..4834ca74b8270 100644 --- a/library/core/src/ops/control_flow.rs +++ b/library/core/src/ops/control_flow.rs @@ -1,63 +1,13 @@ use crate::ops::Try; -/// Used to tell an operation whether it should exit early or go on as usual. -/// -/// This is used when exposing things (like graph traversals or visitors) where -/// you want the user to be able to choose whether to exit early. -/// Having the enum makes it clearer -- no more wondering "wait, what did `false` -/// mean again?" -- and allows including a value. -/// -/// # Examples -/// -/// Early-exiting from [`Iterator::try_for_each`]: -/// ``` -/// #![feature(control_flow_enum)] -/// use std::ops::ControlFlow; -/// -/// let r = (2..100).try_for_each(|x| { -/// if 403 % x == 0 { -/// return ControlFlow::Break(x) -/// } -/// -/// ControlFlow::Continue(()) -/// }); -/// assert_eq!(r, ControlFlow::Break(13)); -/// ``` -/// -/// A basic tree traversal: -/// ```no_run -/// #![feature(control_flow_enum)] -/// use std::ops::ControlFlow; -/// -/// pub struct TreeNode { -/// value: T, -/// left: Option>>, -/// right: Option>>, -/// } -/// -/// impl TreeNode { -/// pub fn traverse_inorder(&self, mut f: impl FnMut(&T) -> ControlFlow) -> ControlFlow { -/// if let Some(left) = &self.left { -/// left.traverse_inorder(&mut f)?; -/// } -/// f(&self.value)?; -/// if let Some(right) = &self.right { -/// right.traverse_inorder(&mut f)?; -/// } -/// ControlFlow::Continue(()) -/// } -/// } -/// ``` +/// Used to make try_fold closures more like normal loops #[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")] #[derive(Debug, Clone, Copy, PartialEq)] pub enum ControlFlow { - /// Move on to the next phase of the operation as normal. + /// Continue in the loop, using the given value for the next iteration Continue(C), - /// Exit the operation without running subsequent phases. + /// Exit the loop, yielding the given value Break(B), - // Yes, the order of the variants doesn't match the type parameters. - // They're in this order so that `ControlFlow` <-> `Result` - // is a no-op conversion in the `Try` implementation. } #[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")] @@ -83,16 +33,6 @@ impl Try for ControlFlow { impl ControlFlow { /// Returns `true` if this is a `Break` variant. - /// - /// # Examples - /// - /// ``` - /// #![feature(control_flow_enum)] - /// use std::ops::ControlFlow; - /// - /// assert!(ControlFlow::::Break(3).is_break()); - /// assert!(!ControlFlow::::Continue(3).is_break()); - /// ``` #[inline] #[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")] pub fn is_break(&self) -> bool { @@ -100,16 +40,6 @@ impl ControlFlow { } /// Returns `true` if this is a `Continue` variant. - /// - /// # Examples - /// - /// ``` - /// #![feature(control_flow_enum)] - /// use std::ops::ControlFlow; - /// - /// assert!(!ControlFlow::::Break(3).is_continue()); - /// assert!(ControlFlow::::Continue(3).is_continue()); - /// ``` #[inline] #[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")] pub fn is_continue(&self) -> bool { @@ -118,16 +48,6 @@ impl ControlFlow { /// Converts the `ControlFlow` into an `Option` which is `Some` if the /// `ControlFlow` was `Break` and `None` otherwise. - /// - /// # Examples - /// - /// ``` - /// #![feature(control_flow_enum)] - /// use std::ops::ControlFlow; - /// - /// assert_eq!(ControlFlow::::Break(3).break_value(), Some(3)); - /// assert_eq!(ControlFlow::::Continue(3).break_value(), None); - /// ``` #[inline] #[unstable(feature = "control_flow_enum", reason = "new API", issue = "75744")] pub fn break_value(self) -> Option { diff --git a/library/core/src/prelude/v1.rs b/library/core/src/prelude/v1.rs index a1fbd8dec7505..b4fff3d67b555 100644 --- a/library/core/src/prelude/v1.rs +++ b/library/core/src/prelude/v1.rs @@ -69,11 +69,6 @@ pub use crate::macros::builtin::{ bench, global_allocator, test, test_case, RustcDecodable, RustcEncodable, }; -#[cfg(not(bootstrap))] -#[stable(feature = "builtin_macro_prelude", since = "1.38.0")] -#[doc(no_inline)] -pub use crate::macros::builtin::derive; - #[unstable( feature = "cfg_accessible", issue = "64797", diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs index 339691b117694..26dbcb8569b43 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -15,7 +15,6 @@ #![feature(const_maybe_uninit_assume_init)] #![feature(const_ptr_read)] #![feature(const_ptr_offset)] -#![feature(control_flow_enum)] #![feature(core_intrinsics)] #![feature(core_private_bignum)] #![feature(core_private_diy_float)] @@ -66,11 +65,11 @@ #![feature(unwrap_infallible)] #![feature(option_result_unwrap_unchecked)] #![feature(option_unwrap_none)] +#![feature(peekable_next_if)] #![feature(peekable_peek_mut)] #![feature(partition_point)] #![feature(once_cell)] #![feature(unsafe_block_in_unsafe_fn)] -#![feature(int_bits_const)] #![feature(nonzero_leading_trailing_zeros)] #![feature(const_option)] #![feature(integer_atomics)] diff --git a/library/core/tests/ops.rs b/library/core/tests/ops.rs index aa79dbac8f39d..53e5539fad91c 100644 --- a/library/core/tests/ops.rs +++ b/library/core/tests/ops.rs @@ -1,5 +1,3 @@ -mod control_flow; - use core::ops::{Bound, Range, RangeFrom, RangeFull, RangeInclusive, RangeTo, RangeToInclusive}; use core::ops::{Deref, DerefMut}; diff --git a/library/core/tests/ops/control_flow.rs b/library/core/tests/ops/control_flow.rs deleted file mode 100644 index eacfd63a6c48f..0000000000000 --- a/library/core/tests/ops/control_flow.rs +++ /dev/null @@ -1,18 +0,0 @@ -use core::intrinsics::discriminant_value; -use core::ops::ControlFlow; - -#[test] -fn control_flow_discriminants_match_result() { - // This isn't stable surface area, but helps keep `?` cheap between them, - // even if LLVM can't always take advantage of it right now. - // (Sadly Result and Option are inconsistent, so ControlFlow can't match both.) - - assert_eq!( - discriminant_value(&ControlFlow::::Break(3)), - discriminant_value(&Result::::Err(3)), - ); - assert_eq!( - discriminant_value(&ControlFlow::::Continue(3)), - discriminant_value(&Result::::Ok(3)), - ); -} diff --git a/library/panic_unwind/src/lib.rs b/library/panic_unwind/src/lib.rs index 9ce9c477ec0f0..99a0c67fc11b9 100644 --- a/library/panic_unwind/src/lib.rs +++ b/library/panic_unwind/src/lib.rs @@ -18,7 +18,6 @@ issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/" )] #![feature(core_intrinsics)] -#![feature(int_bits_const)] #![feature(lang_items)] #![feature(nll)] #![feature(panic_unwind)] diff --git a/library/std/src/backtrace.rs b/library/std/src/backtrace.rs index 0aae4674b2942..95e18ef2a6543 100644 --- a/library/std/src/backtrace.rs +++ b/library/std/src/backtrace.rs @@ -147,14 +147,11 @@ fn _assert_send_sync() { _assert::(); } -/// A single frame of a backtrace. -#[unstable(feature = "backtrace_frames", issue = "79676")] -pub struct BacktraceFrame { +struct BacktraceFrame { frame: RawFrame, symbols: Vec, } -#[derive(Debug)] enum RawFrame { Actual(backtrace_rs::Frame), #[cfg(test)] @@ -199,14 +196,6 @@ impl fmt::Debug for Backtrace { } } -impl fmt::Debug for BacktraceFrame { - fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { - let mut dbg = fmt.debug_list(); - dbg.entries(&self.symbols); - dbg.finish() - } -} - impl fmt::Debug for BacktraceSymbol { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { // FIXME: improve formatting: https://github.com/rust-lang/rust/issues/65280 @@ -364,14 +353,6 @@ impl Backtrace { } } -impl<'a> Backtrace { - /// Returns an iterator over the backtrace frames. - #[unstable(feature = "backtrace_frames", issue = "79676")] - pub fn frames(&'a self) -> &'a [BacktraceFrame] { - if let Inner::Captured(c) = &self.inner { &c.force().frames } else { &[] } - } -} - impl fmt::Display for Backtrace { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { let capture = match &self.inner { diff --git a/library/std/src/backtrace/tests.rs b/library/std/src/backtrace/tests.rs index f5da93f93fd93..31cf0f702185c 100644 --- a/library/std/src/backtrace/tests.rs +++ b/library/std/src/backtrace/tests.rs @@ -1,52 +1,48 @@ use super::*; -fn generate_fake_frames() -> Vec { - vec![ - BacktraceFrame { - frame: RawFrame::Fake, - symbols: vec![BacktraceSymbol { - name: Some(b"std::backtrace::Backtrace::create".to_vec()), - filename: Some(BytesOrWide::Bytes(b"rust/backtrace.rs".to_vec())), - lineno: Some(100), - colno: None, - }], - }, - BacktraceFrame { - frame: RawFrame::Fake, - symbols: vec![BacktraceSymbol { - name: Some(b"__rust_maybe_catch_panic".to_vec()), - filename: None, - lineno: None, - colno: None, - }], - }, - BacktraceFrame { - frame: RawFrame::Fake, - symbols: vec![ - BacktraceSymbol { - name: Some(b"std::rt::lang_start_internal".to_vec()), - filename: Some(BytesOrWide::Bytes(b"rust/rt.rs".to_vec())), - lineno: Some(300), - colno: Some(5), - }, - BacktraceSymbol { - name: Some(b"std::rt::lang_start".to_vec()), - filename: Some(BytesOrWide::Bytes(b"rust/rt.rs".to_vec())), - lineno: Some(400), - colno: None, - }, - ], - }, - ] -} - #[test] fn test_debug() { let backtrace = Backtrace { inner: Inner::Captured(LazilyResolvedCapture::new(Capture { actual_start: 1, resolved: true, - frames: generate_fake_frames(), + frames: vec![ + BacktraceFrame { + frame: RawFrame::Fake, + symbols: vec![BacktraceSymbol { + name: Some(b"std::backtrace::Backtrace::create".to_vec()), + filename: Some(BytesOrWide::Bytes(b"rust/backtrace.rs".to_vec())), + lineno: Some(100), + colno: None, + }], + }, + BacktraceFrame { + frame: RawFrame::Fake, + symbols: vec![BacktraceSymbol { + name: Some(b"__rust_maybe_catch_panic".to_vec()), + filename: None, + lineno: None, + colno: None, + }], + }, + BacktraceFrame { + frame: RawFrame::Fake, + symbols: vec![ + BacktraceSymbol { + name: Some(b"std::rt::lang_start_internal".to_vec()), + filename: Some(BytesOrWide::Bytes(b"rust/rt.rs".to_vec())), + lineno: Some(300), + colno: Some(5), + }, + BacktraceSymbol { + name: Some(b"std::rt::lang_start".to_vec()), + filename: Some(BytesOrWide::Bytes(b"rust/rt.rs".to_vec())), + lineno: Some(400), + colno: None, + }, + ], + }, + ], })), }; @@ -62,34 +58,3 @@ fn test_debug() { // Format the backtrace a second time, just to make sure lazily resolved state is stable assert_eq!(format!("{:#?}", backtrace), expected); } - -#[test] -fn test_frames() { - let backtrace = Backtrace { - inner: Inner::Captured(LazilyResolvedCapture::new(Capture { - actual_start: 1, - resolved: true, - frames: generate_fake_frames(), - })), - }; - - let frames = backtrace.frames(); - - #[rustfmt::skip] - let expected = vec![ - "[ - { fn: \"std::backtrace::Backtrace::create\", file: \"rust/backtrace.rs\", line: 100 }, -]", - "[ - { fn: \"__rust_maybe_catch_panic\" }, -]", - "[ - { fn: \"std::rt::lang_start_internal\", file: \"rust/rt.rs\", line: 300 }, - { fn: \"std::rt::lang_start\", file: \"rust/rt.rs\", line: 400 }, -]" - ]; - - let mut iter = frames.iter().zip(expected.iter()); - - assert!(iter.all(|(f, e)| format!("{:#?}", f) == *e)); -} diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs index 27f7191831d41..28a25572dd83e 100644 --- a/library/std/src/collections/hash/map.rs +++ b/library/std/src/collections/hash/map.rs @@ -859,7 +859,6 @@ where /// assert_eq!(map.remove(&1), Some("a")); /// assert_eq!(map.remove(&1), None); /// ``` - #[doc(alias = "delete")] #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn remove(&mut self, k: &Q) -> Option diff --git a/library/std/src/collections/hash/set.rs b/library/std/src/collections/hash/set.rs index 912e975aa0a4c..b08510d6b01ae 100644 --- a/library/std/src/collections/hash/set.rs +++ b/library/std/src/collections/hash/set.rs @@ -874,7 +874,6 @@ where /// assert_eq!(set.remove(&2), true); /// assert_eq!(set.remove(&2), false); /// ``` - #[doc(alias = "delete")] #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn remove(&mut self, value: &Q) -> bool diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs index c9c8f68cd9cce..21060182d60bc 100644 --- a/library/std/src/ffi/os_str.rs +++ b/library/std/src/ffi/os_str.rs @@ -826,7 +826,7 @@ impl OsStr { /// assert!(!OsString::from("Ferrös").eq_ignore_ascii_case("FERRÖS")); /// ``` #[unstable(feature = "osstring_ascii", issue = "70516")] - pub fn eq_ignore_ascii_case>(&self, other: S) -> bool { + pub fn eq_ignore_ascii_case>(&self, other: &S) -> bool { self.inner.eq_ignore_ascii_case(&other.as_ref().inner) } } diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 43119c36cfec7..e2d4f2e6a56af 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -1524,7 +1524,6 @@ impl AsInner for DirEntry { /// Ok(()) /// } /// ``` -#[doc(alias = "delete")] #[stable(feature = "rust1", since = "1.0.0")] pub fn remove_file>(path: P) -> io::Result<()> { fs_imp::unlink(path.as_ref()) @@ -1959,7 +1958,6 @@ pub fn create_dir_all>(path: P) -> io::Result<()> { /// Ok(()) /// } /// ``` -#[doc(alias = "delete")] #[stable(feature = "rust1", since = "1.0.0")] pub fn remove_dir>(path: P) -> io::Result<()> { fs_imp::rmdir(path.as_ref()) @@ -1997,7 +1995,6 @@ pub fn remove_dir>(path: P) -> io::Result<()> { /// Ok(()) /// } /// ``` -#[doc(alias = "delete")] #[stable(feature = "rust1", since = "1.0.0")] pub fn remove_dir_all>(path: P) -> io::Result<()> { fs_imp::remove_dir_all(path.as_ref()) diff --git a/library/std/src/lazy/tests.rs b/library/std/src/lazy/tests.rs index 83466eb0904fb..a170edbd997dd 100644 --- a/library/std/src/lazy/tests.rs +++ b/library/std/src/lazy/tests.rs @@ -48,7 +48,6 @@ fn spawn_and_wait(f: impl FnOnce() -> R + Send + 'static) -> } #[test] -#[cfg_attr(target_os = "emscripten", ignore)] fn sync_once_cell() { static ONCE_CELL: SyncOnceCell = SyncOnceCell::new(); @@ -82,7 +81,6 @@ fn sync_once_cell_get_unchecked() { } #[test] -#[cfg_attr(target_os = "emscripten", ignore)] fn sync_once_cell_drop() { static DROP_CNT: AtomicUsize = AtomicUsize::new(0); struct Dropper; @@ -160,7 +158,6 @@ fn into_inner() { } #[test] -#[cfg_attr(target_os = "emscripten", ignore)] fn sync_lazy_new() { static CALLED: AtomicUsize = AtomicUsize::new(0); static SYNC_LAZY: SyncLazy = SyncLazy::new(|| { @@ -207,7 +204,6 @@ fn sync_lazy_default() { } #[test] -#[cfg_attr(target_os = "emscripten", ignore)] fn static_sync_lazy() { static XS: SyncLazy> = SyncLazy::new(|| { let mut xs = Vec::new(); @@ -283,7 +279,6 @@ fn eval_once_macro() { } #[test] -#[cfg_attr(target_os = "emscripten", ignore)] fn sync_once_cell_does_not_leak_partially_constructed_boxes() { static ONCE_CELL: SyncOnceCell = SyncOnceCell::new(); diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 961cff661e3ba..b6929f5939576 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -329,6 +329,7 @@ #![feature(unwind_attributes)] #![feature(vec_into_raw_parts)] #![feature(vec_spare_capacity)] +#![feature(wake_trait)] // NB: the above list is sorted to minimize merge conflicts. #![default_lib_allocator] @@ -507,7 +508,7 @@ pub mod task { pub use core::task::*; #[doc(inline)] - #[stable(feature = "wake_trait", since = "1.51.0")] + #[unstable(feature = "wake_trait", issue = "69912")] pub use alloc::task::*; } diff --git a/library/std/src/net/ip.rs b/library/std/src/net/ip.rs index 2aa305d7f831e..a8a4127d40a5e 100644 --- a/library/std/src/net/ip.rs +++ b/library/std/src/net/ip.rs @@ -150,7 +150,6 @@ impl IpAddr { /// ``` #[rustc_const_stable(feature = "const_ip", since = "1.50.0")] #[stable(feature = "ip_shared", since = "1.12.0")] - #[inline] pub const fn is_unspecified(&self) -> bool { match self { IpAddr::V4(ip) => ip.is_unspecified(), @@ -173,7 +172,6 @@ impl IpAddr { /// ``` #[rustc_const_stable(feature = "const_ip", since = "1.50.0")] #[stable(feature = "ip_shared", since = "1.12.0")] - #[inline] pub const fn is_loopback(&self) -> bool { match self { IpAddr::V4(ip) => ip.is_loopback(), @@ -197,7 +195,6 @@ impl IpAddr { /// assert_eq!(IpAddr::V6(Ipv6Addr::new(0, 0, 0x1c9, 0, 0, 0xafc8, 0, 0x1)).is_global(), true); /// ``` #[rustc_const_unstable(feature = "const_ip", issue = "76205")] - #[inline] pub const fn is_global(&self) -> bool { match self { IpAddr::V4(ip) => ip.is_global(), @@ -220,7 +217,6 @@ impl IpAddr { /// ``` #[rustc_const_stable(feature = "const_ip", since = "1.50.0")] #[stable(feature = "ip_shared", since = "1.12.0")] - #[inline] pub const fn is_multicast(&self) -> bool { match self { IpAddr::V4(ip) => ip.is_multicast(), @@ -247,7 +243,6 @@ impl IpAddr { /// ); /// ``` #[rustc_const_unstable(feature = "const_ip", issue = "76205")] - #[inline] pub const fn is_documentation(&self) -> bool { match self { IpAddr::V4(ip) => ip.is_documentation(), @@ -270,7 +265,6 @@ impl IpAddr { /// ``` #[rustc_const_stable(feature = "const_ip", since = "1.50.0")] #[stable(feature = "ipaddr_checker", since = "1.16.0")] - #[inline] pub const fn is_ipv4(&self) -> bool { matches!(self, IpAddr::V4(_)) } @@ -290,7 +284,6 @@ impl IpAddr { /// ``` #[rustc_const_stable(feature = "const_ip", since = "1.50.0")] #[stable(feature = "ipaddr_checker", since = "1.16.0")] - #[inline] pub const fn is_ipv6(&self) -> bool { matches!(self, IpAddr::V6(_)) } @@ -310,7 +303,6 @@ impl Ipv4Addr { /// ``` #[rustc_const_stable(feature = "const_ipv4", since = "1.32.0")] #[stable(feature = "rust1", since = "1.0.0")] - #[inline] pub const fn new(a: u8, b: u8, c: u8, d: u8) -> Ipv4Addr { // `s_addr` is stored as BE on all machine and the array is in BE order. // So the native endian conversion method is used so that it's never swapped. @@ -368,7 +360,6 @@ impl Ipv4Addr { /// ``` #[rustc_const_stable(feature = "const_ipv4", since = "1.50.0")] #[stable(feature = "rust1", since = "1.0.0")] - #[inline] pub const fn octets(&self) -> [u8; 4] { // This returns the order we want because s_addr is stored in big-endian. self.inner.s_addr.to_ne_bytes() @@ -391,7 +382,6 @@ impl Ipv4Addr { /// ``` #[rustc_const_stable(feature = "const_ipv4", since = "1.32.0")] #[stable(feature = "ip_shared", since = "1.12.0")] - #[inline] pub const fn is_unspecified(&self) -> bool { self.inner.s_addr == 0 } @@ -412,7 +402,6 @@ impl Ipv4Addr { /// ``` #[rustc_const_stable(feature = "const_ipv4", since = "1.50.0")] #[stable(since = "1.7.0", feature = "ip_17")] - #[inline] pub const fn is_loopback(&self) -> bool { self.octets()[0] == 127 } @@ -442,7 +431,6 @@ impl Ipv4Addr { /// ``` #[rustc_const_stable(feature = "const_ipv4", since = "1.50.0")] #[stable(since = "1.7.0", feature = "ip_17")] - #[inline] pub const fn is_private(&self) -> bool { match self.octets() { [10, ..] => true, @@ -469,7 +457,6 @@ impl Ipv4Addr { /// ``` #[rustc_const_stable(feature = "const_ipv4", since = "1.50.0")] #[stable(since = "1.7.0", feature = "ip_17")] - #[inline] pub const fn is_link_local(&self) -> bool { matches!(self.octets(), [169, 254, ..]) } @@ -544,7 +531,6 @@ impl Ipv4Addr { /// assert_eq!(Ipv4Addr::new(80, 9, 12, 3).is_global(), true); /// ``` #[rustc_const_unstable(feature = "const_ipv4", issue = "76205")] - #[inline] pub const fn is_global(&self) -> bool { // check if this address is 192.0.0.9 or 192.0.0.10. These addresses are the only two // globally routable addresses in the 192.0.0.0/24 range. @@ -582,7 +568,6 @@ impl Ipv4Addr { /// assert_eq!(Ipv4Addr::new(100, 128, 0, 0).is_shared(), false); /// ``` #[rustc_const_unstable(feature = "const_ipv4", issue = "76205")] - #[inline] pub const fn is_shared(&self) -> bool { self.octets()[0] == 100 && (self.octets()[1] & 0b1100_0000 == 0b0100_0000) } @@ -615,7 +600,6 @@ impl Ipv4Addr { /// assert_eq!(Ipv4Addr::new(191, 255, 255, 255).is_ietf_protocol_assignment(), false); /// ``` #[rustc_const_unstable(feature = "const_ipv4", issue = "76205")] - #[inline] pub const fn is_ietf_protocol_assignment(&self) -> bool { self.octets()[0] == 192 && self.octets()[1] == 0 && self.octets()[2] == 0 } @@ -639,7 +623,6 @@ impl Ipv4Addr { /// assert_eq!(Ipv4Addr::new(198, 20, 0, 0).is_benchmarking(), false); /// ``` #[rustc_const_unstable(feature = "const_ipv4", issue = "76205")] - #[inline] pub const fn is_benchmarking(&self) -> bool { self.octets()[0] == 198 && (self.octets()[1] & 0xfe) == 18 } @@ -672,7 +655,6 @@ impl Ipv4Addr { /// assert_eq!(Ipv4Addr::new(255, 255, 255, 255).is_reserved(), false); /// ``` #[rustc_const_unstable(feature = "const_ipv4", issue = "76205")] - #[inline] pub const fn is_reserved(&self) -> bool { self.octets()[0] & 240 == 240 && !self.is_broadcast() } @@ -695,7 +677,6 @@ impl Ipv4Addr { /// ``` #[rustc_const_stable(feature = "const_ipv4", since = "1.50.0")] #[stable(since = "1.7.0", feature = "ip_17")] - #[inline] pub const fn is_multicast(&self) -> bool { self.octets()[0] >= 224 && self.octets()[0] <= 239 } @@ -716,7 +697,6 @@ impl Ipv4Addr { /// ``` #[rustc_const_stable(feature = "const_ipv4", since = "1.50.0")] #[stable(since = "1.7.0", feature = "ip_17")] - #[inline] pub const fn is_broadcast(&self) -> bool { u32::from_be_bytes(self.octets()) == u32::from_be_bytes(Self::BROADCAST.octets()) } @@ -743,7 +723,6 @@ impl Ipv4Addr { /// ``` #[rustc_const_stable(feature = "const_ipv4", since = "1.50.0")] #[stable(since = "1.7.0", feature = "ip_17")] - #[inline] pub const fn is_documentation(&self) -> bool { match self.octets() { [192, 0, 2, _] => true, @@ -774,7 +753,6 @@ impl Ipv4Addr { /// ``` #[rustc_const_stable(feature = "const_ipv4", since = "1.50.0")] #[stable(feature = "rust1", since = "1.0.0")] - #[inline] pub const fn to_ipv6_compatible(&self) -> Ipv6Addr { let [a, b, c, d] = self.octets(); Ipv6Addr { @@ -798,7 +776,6 @@ impl Ipv4Addr { /// ``` #[rustc_const_stable(feature = "const_ipv4", since = "1.50.0")] #[stable(feature = "rust1", since = "1.0.0")] - #[inline] pub const fn to_ipv6_mapped(&self) -> Ipv6Addr { let [a, b, c, d] = self.octets(); Ipv6Addr { @@ -840,7 +817,6 @@ impl From for IpAddr { /// IpAddr::from(addr) /// ) /// ``` - #[inline] fn from(ipv4: Ipv4Addr) -> IpAddr { IpAddr::V4(ipv4) } @@ -862,7 +838,6 @@ impl From for IpAddr { /// IpAddr::from(addr) /// ); /// ``` - #[inline] fn from(ipv6: Ipv6Addr) -> IpAddr { IpAddr::V6(ipv6) } @@ -900,7 +875,6 @@ impl fmt::Debug for Ipv4Addr { #[stable(feature = "rust1", since = "1.0.0")] impl Clone for Ipv4Addr { - #[inline] fn clone(&self) -> Ipv4Addr { *self } @@ -908,7 +882,6 @@ impl Clone for Ipv4Addr { #[stable(feature = "rust1", since = "1.0.0")] impl PartialEq for Ipv4Addr { - #[inline] fn eq(&self, other: &Ipv4Addr) -> bool { self.inner.s_addr == other.inner.s_addr } @@ -916,7 +889,6 @@ impl PartialEq for Ipv4Addr { #[stable(feature = "ip_cmp", since = "1.16.0")] impl PartialEq for IpAddr { - #[inline] fn eq(&self, other: &Ipv4Addr) -> bool { match self { IpAddr::V4(v4) => v4 == other, @@ -927,7 +899,6 @@ impl PartialEq for IpAddr { #[stable(feature = "ip_cmp", since = "1.16.0")] impl PartialEq for Ipv4Addr { - #[inline] fn eq(&self, other: &IpAddr) -> bool { match other { IpAddr::V4(v4) => self == v4, @@ -941,7 +912,6 @@ impl Eq for Ipv4Addr {} #[stable(feature = "rust1", since = "1.0.0")] impl hash::Hash for Ipv4Addr { - #[inline] fn hash(&self, s: &mut H) { // NOTE: // * hash in big endian order @@ -953,7 +923,6 @@ impl hash::Hash for Ipv4Addr { #[stable(feature = "rust1", since = "1.0.0")] impl PartialOrd for Ipv4Addr { - #[inline] fn partial_cmp(&self, other: &Ipv4Addr) -> Option { Some(self.cmp(other)) } @@ -961,7 +930,6 @@ impl PartialOrd for Ipv4Addr { #[stable(feature = "ip_cmp", since = "1.16.0")] impl PartialOrd for IpAddr { - #[inline] fn partial_cmp(&self, other: &Ipv4Addr) -> Option { match self { IpAddr::V4(v4) => v4.partial_cmp(other), @@ -972,7 +940,6 @@ impl PartialOrd for IpAddr { #[stable(feature = "ip_cmp", since = "1.16.0")] impl PartialOrd for Ipv4Addr { - #[inline] fn partial_cmp(&self, other: &IpAddr) -> Option { match other { IpAddr::V4(v4) => self.partial_cmp(v4), @@ -983,7 +950,6 @@ impl PartialOrd for Ipv4Addr { #[stable(feature = "rust1", since = "1.0.0")] impl Ord for Ipv4Addr { - #[inline] fn cmp(&self, other: &Ipv4Addr) -> Ordering { // Compare as native endian u32::from_be(self.inner.s_addr).cmp(&u32::from_be(other.inner.s_addr)) @@ -1008,7 +974,6 @@ impl From for u32 { /// let addr = Ipv4Addr::new(0xca, 0xfe, 0xba, 0xbe); /// assert_eq!(0xcafebabe, u32::from(addr)); /// ``` - #[inline] fn from(ip: Ipv4Addr) -> u32 { let ip = ip.octets(); u32::from_be_bytes(ip) @@ -1027,7 +992,6 @@ impl From for Ipv4Addr { /// let addr = Ipv4Addr::from(0xcafebabe); /// assert_eq!(Ipv4Addr::new(0xca, 0xfe, 0xba, 0xbe), addr); /// ``` - #[inline] fn from(ip: u32) -> Ipv4Addr { Ipv4Addr::from(ip.to_be_bytes()) } @@ -1045,7 +1009,6 @@ impl From<[u8; 4]> for Ipv4Addr { /// let addr = Ipv4Addr::from([13u8, 12u8, 11u8, 10u8]); /// assert_eq!(Ipv4Addr::new(13, 12, 11, 10), addr); /// ``` - #[inline] fn from(octets: [u8; 4]) -> Ipv4Addr { Ipv4Addr::new(octets[0], octets[1], octets[2], octets[3]) } @@ -1063,7 +1026,6 @@ impl From<[u8; 4]> for IpAddr { /// let addr = IpAddr::from([13u8, 12u8, 11u8, 10u8]); /// assert_eq!(IpAddr::V4(Ipv4Addr::new(13, 12, 11, 10)), addr); /// ``` - #[inline] fn from(octets: [u8; 4]) -> IpAddr { IpAddr::V4(Ipv4Addr::from(octets)) } @@ -1084,7 +1046,6 @@ impl Ipv6Addr { #[rustc_allow_const_fn_unstable(const_fn_transmute)] #[rustc_const_stable(feature = "const_ipv6", since = "1.32.0")] #[stable(feature = "rust1", since = "1.0.0")] - #[inline] pub const fn new(a: u16, b: u16, c: u16, d: u16, e: u16, f: u16, g: u16, h: u16) -> Ipv6Addr { let addr16 = [ a.to_be(), @@ -1146,7 +1107,6 @@ impl Ipv6Addr { #[rustc_allow_const_fn_unstable(const_fn_transmute)] #[rustc_const_stable(feature = "const_ipv6", since = "1.50.0")] #[stable(feature = "rust1", since = "1.0.0")] - #[inline] pub const fn segments(&self) -> [u16; 8] { // All elements in `s6_addr` must be big endian. // SAFETY: `[u8; 16]` is always safe to transmute to `[u16; 8]`. @@ -1182,7 +1142,6 @@ impl Ipv6Addr { /// ``` #[rustc_const_stable(feature = "const_ipv6", since = "1.50.0")] #[stable(since = "1.7.0", feature = "ip_17")] - #[inline] pub const fn is_unspecified(&self) -> bool { u128::from_be_bytes(self.octets()) == u128::from_be_bytes(Ipv6Addr::UNSPECIFIED.octets()) } @@ -1203,7 +1162,6 @@ impl Ipv6Addr { /// ``` #[rustc_const_stable(feature = "const_ipv6", since = "1.50.0")] #[stable(since = "1.7.0", feature = "ip_17")] - #[inline] pub const fn is_loopback(&self) -> bool { u128::from_be_bytes(self.octets()) == u128::from_be_bytes(Ipv6Addr::LOCALHOST.octets()) } @@ -1228,7 +1186,6 @@ impl Ipv6Addr { /// assert_eq!(Ipv6Addr::new(0, 0, 0x1c9, 0, 0, 0xafc8, 0, 0x1).is_global(), true); /// ``` #[rustc_const_unstable(feature = "const_ipv6", issue = "76205")] - #[inline] pub const fn is_global(&self) -> bool { match self.multicast_scope() { Some(Ipv6MulticastScope::Global) => true, @@ -1254,7 +1211,6 @@ impl Ipv6Addr { /// assert_eq!(Ipv6Addr::new(0xfc02, 0, 0, 0, 0, 0, 0, 0).is_unique_local(), true); /// ``` #[rustc_const_unstable(feature = "const_ipv6", issue = "76205")] - #[inline] pub const fn is_unique_local(&self) -> bool { (self.segments()[0] & 0xfe00) == 0xfc00 } @@ -1309,7 +1265,6 @@ impl Ipv6Addr { /// [IETF RFC 4291 section 2.5.6]: https://tools.ietf.org/html/rfc4291#section-2.5.6 /// [RFC 4291 errata 4406]: https://www.rfc-editor.org/errata/eid4406 #[rustc_const_unstable(feature = "const_ipv6", issue = "76205")] - #[inline] pub const fn is_unicast_link_local_strict(&self) -> bool { matches!(self.segments(), [0xfe80, 0, 0, 0, ..]) } @@ -1363,7 +1318,6 @@ impl Ipv6Addr { /// [IETF RFC 4291 section 2.4]: https://tools.ietf.org/html/rfc4291#section-2.4 /// [RFC 4291 errata 4406]: https://www.rfc-editor.org/errata/eid4406 #[rustc_const_unstable(feature = "const_ipv6", issue = "76205")] - #[inline] pub const fn is_unicast_link_local(&self) -> bool { (self.segments()[0] & 0xffc0) == 0xfe80 } @@ -1403,7 +1357,6 @@ impl Ipv6Addr { /// /// [RFC 3879]: https://tools.ietf.org/html/rfc3879 #[rustc_const_unstable(feature = "const_ipv6", issue = "76205")] - #[inline] pub const fn is_unicast_site_local(&self) -> bool { (self.segments()[0] & 0xffc0) == 0xfec0 } @@ -1426,7 +1379,6 @@ impl Ipv6Addr { /// assert_eq!(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0).is_documentation(), true); /// ``` #[rustc_const_unstable(feature = "const_ipv6", issue = "76205")] - #[inline] pub const fn is_documentation(&self) -> bool { (self.segments()[0] == 0x2001) && (self.segments()[1] == 0xdb8) } @@ -1462,7 +1414,6 @@ impl Ipv6Addr { /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).is_unicast_global(), true); /// ``` #[rustc_const_unstable(feature = "const_ipv6", issue = "76205")] - #[inline] pub const fn is_unicast_global(&self) -> bool { !self.is_multicast() && !self.is_loopback() @@ -1488,7 +1439,6 @@ impl Ipv6Addr { /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc00a, 0x2ff).multicast_scope(), None); /// ``` #[rustc_const_unstable(feature = "const_ipv6", issue = "76205")] - #[inline] pub const fn multicast_scope(&self) -> Option { if self.is_multicast() { match self.segments()[0] & 0x000f { @@ -1522,7 +1472,6 @@ impl Ipv6Addr { /// ``` #[rustc_const_stable(feature = "const_ipv6", since = "1.50.0")] #[stable(since = "1.7.0", feature = "ip_17")] - #[inline] pub const fn is_multicast(&self) -> bool { (self.segments()[0] & 0xff00) == 0xff00 } @@ -1549,7 +1498,6 @@ impl Ipv6Addr { /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1).to_ipv4_mapped(), None); /// ``` #[rustc_const_unstable(feature = "const_ipv6", issue = "76205")] - #[inline] pub const fn to_ipv4_mapped(&self) -> Option { match self.octets() { [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, a, b, c, d] => { @@ -1579,7 +1527,6 @@ impl Ipv6Addr { /// ``` #[rustc_const_stable(feature = "const_ipv6", since = "1.50.0")] #[stable(feature = "rust1", since = "1.0.0")] - #[inline] pub const fn to_ipv4(&self) -> Option { if let [0, 0, 0, 0, 0, 0 | 0xffff, ab, cd] = self.segments() { let [a, b] = ab.to_be_bytes(); @@ -1600,7 +1547,6 @@ impl Ipv6Addr { /// ``` #[rustc_const_stable(feature = "const_ipv6", since = "1.32.0")] #[stable(feature = "ipv6_to_octets", since = "1.12.0")] - #[inline] pub const fn octets(&self) -> [u8; 16] { self.inner.s6_addr } @@ -1712,7 +1658,6 @@ impl fmt::Debug for Ipv6Addr { #[stable(feature = "rust1", since = "1.0.0")] impl Clone for Ipv6Addr { - #[inline] fn clone(&self) -> Ipv6Addr { *self } @@ -1720,7 +1665,6 @@ impl Clone for Ipv6Addr { #[stable(feature = "rust1", since = "1.0.0")] impl PartialEq for Ipv6Addr { - #[inline] fn eq(&self, other: &Ipv6Addr) -> bool { self.inner.s6_addr == other.inner.s6_addr } @@ -1728,7 +1672,6 @@ impl PartialEq for Ipv6Addr { #[stable(feature = "ip_cmp", since = "1.16.0")] impl PartialEq for Ipv6Addr { - #[inline] fn eq(&self, other: &IpAddr) -> bool { match other { IpAddr::V4(_) => false, @@ -1739,7 +1682,6 @@ impl PartialEq for Ipv6Addr { #[stable(feature = "ip_cmp", since = "1.16.0")] impl PartialEq for IpAddr { - #[inline] fn eq(&self, other: &Ipv6Addr) -> bool { match self { IpAddr::V4(_) => false, @@ -1753,7 +1695,6 @@ impl Eq for Ipv6Addr {} #[stable(feature = "rust1", since = "1.0.0")] impl hash::Hash for Ipv6Addr { - #[inline] fn hash(&self, s: &mut H) { self.inner.s6_addr.hash(s) } @@ -1761,7 +1702,6 @@ impl hash::Hash for Ipv6Addr { #[stable(feature = "rust1", since = "1.0.0")] impl PartialOrd for Ipv6Addr { - #[inline] fn partial_cmp(&self, other: &Ipv6Addr) -> Option { Some(self.cmp(other)) } @@ -1769,7 +1709,6 @@ impl PartialOrd for Ipv6Addr { #[stable(feature = "ip_cmp", since = "1.16.0")] impl PartialOrd for IpAddr { - #[inline] fn partial_cmp(&self, other: &Ipv6Addr) -> Option { match self { IpAddr::V4(_) => Some(Ordering::Less), @@ -1780,7 +1719,6 @@ impl PartialOrd for IpAddr { #[stable(feature = "ip_cmp", since = "1.16.0")] impl PartialOrd for Ipv6Addr { - #[inline] fn partial_cmp(&self, other: &IpAddr) -> Option { match other { IpAddr::V4(_) => Some(Ordering::Greater), @@ -1791,7 +1729,6 @@ impl PartialOrd for Ipv6Addr { #[stable(feature = "rust1", since = "1.0.0")] impl Ord for Ipv6Addr { - #[inline] fn cmp(&self, other: &Ipv6Addr) -> Ordering { self.segments().cmp(&other.segments()) } @@ -1823,7 +1760,6 @@ impl From for u128 { /// ); /// assert_eq!(0x102030405060708090A0B0C0D0E0F00D_u128, u128::from(addr)); /// ``` - #[inline] fn from(ip: Ipv6Addr) -> u128 { let ip = ip.octets(); u128::from_be_bytes(ip) @@ -1846,7 +1782,6 @@ impl From for Ipv6Addr { /// ), /// addr); /// ``` - #[inline] fn from(ip: u128) -> Ipv6Addr { Ipv6Addr::from(ip.to_be_bytes()) } @@ -1875,7 +1810,6 @@ impl From<[u8; 16]> for Ipv6Addr { /// addr /// ); /// ``` - #[inline] fn from(octets: [u8; 16]) -> Ipv6Addr { let inner = c::in6_addr { s6_addr: octets }; Ipv6Addr::from_inner(inner) @@ -1905,7 +1839,6 @@ impl From<[u16; 8]> for Ipv6Addr { /// addr /// ); /// ``` - #[inline] fn from(segments: [u16; 8]) -> Ipv6Addr { let [a, b, c, d, e, f, g, h] = segments; Ipv6Addr::new(a, b, c, d, e, f, g, h) @@ -1935,7 +1868,6 @@ impl From<[u8; 16]> for IpAddr { /// addr /// ); /// ``` - #[inline] fn from(octets: [u8; 16]) -> IpAddr { IpAddr::V6(Ipv6Addr::from(octets)) } @@ -1964,7 +1896,6 @@ impl From<[u16; 8]> for IpAddr { /// addr /// ); /// ``` - #[inline] fn from(segments: [u16; 8]) -> IpAddr { IpAddr::V6(Ipv6Addr::from(segments)) } diff --git a/library/std/src/os/linux/raw.rs b/library/std/src/os/linux/raw.rs index 525102212c41e..617c4098aa959 100644 --- a/library/std/src/os/linux/raw.rs +++ b/library/std/src/os/linux/raw.rs @@ -247,17 +247,17 @@ mod arch { use crate::os::raw::{c_int, c_long}; #[stable(feature = "raw_ext", since = "1.1.0")] - pub type blkcnt_t = i64; + pub type blkcnt_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] - pub type blksize_t = i32; + pub type blksize_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] - pub type nlink_t = u32; + pub type nlink_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] - pub type off_t = i64; + pub type off_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] - pub type time_t = c_long; + pub type time_t = i64; #[repr(C)] #[derive(Clone)] @@ -288,15 +288,15 @@ mod arch { #[stable(feature = "raw_ext", since = "1.1.0")] pub st_blocks: i64, #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_atime: time_t, + pub st_atime: i64, #[stable(feature = "raw_ext", since = "1.1.0")] pub st_atime_nsec: c_long, #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_mtime: time_t, + pub st_mtime: i64, #[stable(feature = "raw_ext", since = "1.1.0")] pub st_mtime_nsec: c_long, #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_ctime: time_t, + pub st_ctime: i64, #[stable(feature = "raw_ext", since = "1.1.0")] pub st_ctime_nsec: c_long, #[stable(feature = "raw_ext", since = "1.1.0")] diff --git a/library/std/src/prelude/v1.rs b/library/std/src/prelude/v1.rs index ef9aec54a4ca2..26302d0ecf2b1 100644 --- a/library/std/src/prelude/v1.rs +++ b/library/std/src/prelude/v1.rs @@ -54,11 +54,6 @@ pub use core::prelude::v1::{ bench, global_allocator, test, test_case, RustcDecodable, RustcEncodable, }; -#[cfg(not(bootstrap))] -#[stable(feature = "builtin_macro_prelude", since = "1.38.0")] -#[doc(hidden)] -pub use core::prelude::v1::derive; - #[unstable( feature = "cfg_accessible", issue = "64797", diff --git a/library/std/src/sync/once.rs b/library/std/src/sync/once.rs index 2e5f843fc43cb..6a330834489df 100644 --- a/library/std/src/sync/once.rs +++ b/library/std/src/sync/once.rs @@ -125,7 +125,7 @@ unsafe impl Send for Once {} /// State yielded to [`Once::call_once_force()`]’s closure parameter. The state /// can be used to query the poison status of the [`Once`]. -#[stable(feature = "once_poison", since = "1.51.0")] +#[unstable(feature = "once_poison", issue = "33577")] #[derive(Debug)] pub struct OnceState { poisoned: bool, @@ -280,6 +280,8 @@ impl Once { /// # Examples /// /// ``` + /// #![feature(once_poison)] + /// /// use std::sync::Once; /// use std::thread; /// @@ -299,13 +301,13 @@ impl Once { /// /// // call_once_force will still run and reset the poisoned state /// INIT.call_once_force(|state| { - /// assert!(state.is_poisoned()); + /// assert!(state.poisoned()); /// }); /// /// // once any success happens, we stop propagating the poison /// INIT.call_once(|| {}); /// ``` - #[stable(feature = "once_poison", since = "1.51.0")] + #[unstable(feature = "once_poison", issue = "33577")] pub fn call_once_force(&self, f: F) where F: FnOnce(&OnceState), @@ -524,6 +526,8 @@ impl OnceState { /// A poisoned [`Once`]: /// /// ``` + /// #![feature(once_poison)] + /// /// use std::sync::Once; /// use std::thread; /// @@ -536,22 +540,24 @@ impl OnceState { /// assert!(handle.join().is_err()); /// /// INIT.call_once_force(|state| { - /// assert!(state.is_poisoned()); + /// assert!(state.poisoned()); /// }); /// ``` /// /// An unpoisoned [`Once`]: /// /// ``` + /// #![feature(once_poison)] + /// /// use std::sync::Once; /// /// static INIT: Once = Once::new(); /// /// INIT.call_once_force(|state| { - /// assert!(!state.is_poisoned()); + /// assert!(!state.poisoned()); /// }); - #[stable(feature = "once_poison", since = "1.51.0")] - pub fn is_poisoned(&self) -> bool { + #[unstable(feature = "once_poison", issue = "33577")] + pub fn poisoned(&self) -> bool { self.poisoned } diff --git a/library/std/src/sync/once/tests.rs b/library/std/src/sync/once/tests.rs index 0c35597e11c51..fae2752526e58 100644 --- a/library/std/src/sync/once/tests.rs +++ b/library/std/src/sync/once/tests.rs @@ -69,7 +69,7 @@ fn poison_bad() { let mut called = false; O.call_once_force(|p| { called = true; - assert!(p.is_poisoned()) + assert!(p.poisoned()) }); assert!(called); @@ -92,7 +92,7 @@ fn wait_for_force_to_finish() { let (tx2, rx2) = channel(); let t1 = thread::spawn(move || { O.call_once_force(|p| { - assert!(p.is_poisoned()); + assert!(p.poisoned()); tx1.send(()).unwrap(); rx2.recv().unwrap(); }); diff --git a/library/std/src/sys/wasi/ext/fs.rs b/library/std/src/sys/wasi/ext/fs.rs index a8da003d550ac..4f7cf6018d90f 100644 --- a/library/std/src/sys/wasi/ext/fs.rs +++ b/library/std/src/sys/wasi/ext/fs.rs @@ -514,11 +514,3 @@ pub fn symlink, U: AsRef>( .fd() .symlink(osstr2str(old_path.as_ref().as_ref())?, osstr2str(new_path.as_ref().as_ref())?) } - -/// Create a symbolic link. -/// -/// This is a convenience API similar to [`std::os::unix::fs::symlink`] and -/// [`std::os::windows::fs::symlink_file`] and [`symlink_dir`](std::os::windows::fs::symlink_dir). -pub fn symlink_path, U: AsRef>(old_path: P, new_path: U) -> io::Result<()> { - crate::sys::fs::symlink(old_path.as_ref(), new_path.as_ref()) -} diff --git a/library/std/src/sys/wasm/thread.rs b/library/std/src/sys/wasm/thread.rs index 5eafb77da1dcd..95a9230aa7888 100644 --- a/library/std/src/sys/wasm/thread.rs +++ b/library/std/src/sys/wasm/thread.rs @@ -86,7 +86,7 @@ pub fn my_id() -> u32 { if MY_ID == 0 { let mut cur = NEXT_ID.load(SeqCst); MY_ID = loop { - let next = cur.checked_add(1).unwrap_or_else(|| crate::process::abort()); + let next = cur.checked_add(1).unwrap_or_else(|| crate::arch::wasm32::unreachable()); match NEXT_ID.compare_exchange(cur, next, SeqCst, SeqCst) { Ok(_) => break next, Err(i) => cur = i, diff --git a/library/std/src/sys/windows/mutex.rs b/library/std/src/sys/windows/mutex.rs index 12c5ea741f9ef..72a0993d94ddf 100644 --- a/library/std/src/sys/windows/mutex.rs +++ b/library/std/src/sys/windows/mutex.rs @@ -23,6 +23,8 @@ pub struct Mutex { } // Windows SRW Locks are movable (while not borrowed). +// ReentrantMutexes (in Inner) are not, but those are stored indirectly through +// a Box, so do not move when the Mutex it self is moved. pub type MovableMutex = Mutex; unsafe impl Send for Mutex {} diff --git a/library/term/src/terminfo/parm/tests.rs b/library/term/src/terminfo/parm/tests.rs index 1cc0967c8f42e..b975bd2d19882 100644 --- a/library/term/src/terminfo/parm/tests.rs +++ b/library/term/src/terminfo/parm/tests.rs @@ -77,15 +77,15 @@ fn test_comparison_ops() { for &(op, bs) in v.iter() { let s = format!("%{{1}}%{{2}}%{}%d", op); let res = expand(s.as_bytes(), &[], &mut Variables::new()); - assert!(res.is_ok(), "{}", res.unwrap_err()); + assert!(res.is_ok(), res.unwrap_err()); assert_eq!(res.unwrap(), vec![b'0' + bs[0]]); let s = format!("%{{1}}%{{1}}%{}%d", op); let res = expand(s.as_bytes(), &[], &mut Variables::new()); - assert!(res.is_ok(), "{}", res.unwrap_err()); + assert!(res.is_ok(), res.unwrap_err()); assert_eq!(res.unwrap(), vec![b'0' + bs[1]]); let s = format!("%{{2}}%{{1}}%{}%d", op); let res = expand(s.as_bytes(), &[], &mut Variables::new()); - assert!(res.is_ok(), "{}", res.unwrap_err()); + assert!(res.is_ok(), res.unwrap_err()); assert_eq!(res.unwrap(), vec![b'0' + bs[2]]); } } @@ -95,13 +95,13 @@ fn test_conditionals() { let mut vars = Variables::new(); let s = b"\\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m"; let res = expand(s, &[Number(1)], &mut vars); - assert!(res.is_ok(), "{}", res.unwrap_err()); + assert!(res.is_ok(), res.unwrap_err()); assert_eq!(res.unwrap(), "\\E[31m".bytes().collect::>()); let res = expand(s, &[Number(8)], &mut vars); - assert!(res.is_ok(), "{}", res.unwrap_err()); + assert!(res.is_ok(), res.unwrap_err()); assert_eq!(res.unwrap(), "\\E[90m".bytes().collect::>()); let res = expand(s, &[Number(42)], &mut vars); - assert!(res.is_ok(), "{}", res.unwrap_err()); + assert!(res.is_ok(), res.unwrap_err()); assert_eq!(res.unwrap(), "\\E[38;5;42m".bytes().collect::>()); } diff --git a/library/test/src/cli.rs b/library/test/src/cli.rs index c0b5197e997bb..02c529252e029 100644 --- a/library/test/src/cli.rs +++ b/library/test/src/cli.rs @@ -10,7 +10,7 @@ use super::time::TestTimeOptions; #[derive(Debug)] pub struct TestOpts { pub list: bool, - pub filters: Vec, + pub filter: Option, pub filter_exact: bool, pub force_run_in_process: bool, pub exclude_should_panic: bool, @@ -148,13 +148,12 @@ fn optgroups() -> getopts::Options { } fn usage(binary: &str, options: &getopts::Options) { - let message = format!("Usage: {} [OPTIONS] [FILTERS...]", binary); + let message = format!("Usage: {} [OPTIONS] [FILTER]", binary); println!( r#"{usage} The FILTER string is tested against the name of all tests, and only those -tests whose names contain the filter are run. Multiple filter strings may -be passed, which will run all tests matching any of the filters. +tests whose names contain the filter are run. By default, all tests are run in parallel. This can be altered with the --test-threads flag or the RUST_TEST_THREADS environment variable when running @@ -244,7 +243,7 @@ fn parse_opts_impl(matches: getopts::Matches) -> OptRes { let logfile = get_log_file(&matches)?; let run_ignored = get_run_ignored(&matches, include_ignored)?; - let filters = matches.free.clone(); + let filter = get_filter(&matches)?; let nocapture = get_nocapture(&matches)?; let test_threads = get_test_threads(&matches)?; let color = get_color_config(&matches)?; @@ -254,7 +253,7 @@ fn parse_opts_impl(matches: getopts::Matches) -> OptRes { let test_opts = TestOpts { list, - filters, + filter, filter_exact: exact, force_run_in_process, exclude_should_panic, @@ -398,6 +397,12 @@ fn get_run_ignored(matches: &getopts::Matches, include_ignored: bool) -> OptPart Ok(run_ignored) } +fn get_filter(matches: &getopts::Matches) -> OptPartRes> { + let filter = if !matches.free.is_empty() { Some(matches.free[0].clone()) } else { None }; + + Ok(filter) +} + fn get_allow_unstable(matches: &getopts::Matches) -> OptPartRes { let mut allow_unstable = false; diff --git a/library/test/src/lib.rs b/library/test/src/lib.rs index c38a8c965be61..3ff79eaea49ab 100644 --- a/library/test/src/lib.rs +++ b/library/test/src/lib.rs @@ -396,8 +396,8 @@ pub fn filter_tests(opts: &TestOpts, tests: Vec) -> Vec TestOpts { TestOpts { list: false, - filters: vec![], + filter: None, filter_exact: false, force_run_in_process: false, exclude_should_panic: false, @@ -197,9 +198,8 @@ fn test_should_panic_bad_message() { #[cfg(not(target_os = "emscripten"))] fn test_should_panic_non_string_message_type() { use crate::tests::TrFailedMsg; - use std::any::TypeId; fn f() { - std::panic::panic_any(1i32); + panic!(1i32); } let expected = "foobar"; let failed_msg = format!( @@ -473,60 +473,43 @@ pub fn exact_filter_match() { } let substr = - filter_tests(&TestOpts { filters: vec!["base".into()], ..TestOpts::new() }, tests()); + filter_tests(&TestOpts { filter: Some("base".into()), ..TestOpts::new() }, tests()); assert_eq!(substr.len(), 4); - let substr = - filter_tests(&TestOpts { filters: vec!["bas".into()], ..TestOpts::new() }, tests()); + let substr = filter_tests(&TestOpts { filter: Some("bas".into()), ..TestOpts::new() }, tests()); assert_eq!(substr.len(), 4); let substr = - filter_tests(&TestOpts { filters: vec!["::test".into()], ..TestOpts::new() }, tests()); + filter_tests(&TestOpts { filter: Some("::test".into()), ..TestOpts::new() }, tests()); assert_eq!(substr.len(), 3); let substr = - filter_tests(&TestOpts { filters: vec!["base::test".into()], ..TestOpts::new() }, tests()); + filter_tests(&TestOpts { filter: Some("base::test".into()), ..TestOpts::new() }, tests()); assert_eq!(substr.len(), 3); - let substr = filter_tests( - &TestOpts { filters: vec!["test1".into(), "test2".into()], ..TestOpts::new() }, - tests(), - ); - assert_eq!(substr.len(), 2); - let exact = filter_tests( - &TestOpts { filters: vec!["base".into()], filter_exact: true, ..TestOpts::new() }, + &TestOpts { filter: Some("base".into()), filter_exact: true, ..TestOpts::new() }, tests(), ); assert_eq!(exact.len(), 1); let exact = filter_tests( - &TestOpts { filters: vec!["bas".into()], filter_exact: true, ..TestOpts::new() }, + &TestOpts { filter: Some("bas".into()), filter_exact: true, ..TestOpts::new() }, tests(), ); assert_eq!(exact.len(), 0); let exact = filter_tests( - &TestOpts { filters: vec!["::test".into()], filter_exact: true, ..TestOpts::new() }, + &TestOpts { filter: Some("::test".into()), filter_exact: true, ..TestOpts::new() }, tests(), ); assert_eq!(exact.len(), 0); let exact = filter_tests( - &TestOpts { filters: vec!["base::test".into()], filter_exact: true, ..TestOpts::new() }, + &TestOpts { filter: Some("base::test".into()), filter_exact: true, ..TestOpts::new() }, tests(), ); assert_eq!(exact.len(), 1); - - let exact = filter_tests( - &TestOpts { - filters: vec!["base".into(), "base::test".into()], - filter_exact: true, - ..TestOpts::new() - }, - tests(), - ); - assert_eq!(exact.len(), 2); } #[test] diff --git a/library/unwind/src/libunwind.rs b/library/unwind/src/libunwind.rs index faf554d285a9a..ff1d82fc99040 100644 --- a/library/unwind/src/libunwind.rs +++ b/library/unwind/src/libunwind.rs @@ -36,12 +36,9 @@ pub const unwinder_private_data_size: usize = 20; #[cfg(all(target_arch = "arm", target_os = "ios"))] pub const unwinder_private_data_size: usize = 5; -#[cfg(all(target_arch = "aarch64", target_pointer_width = "64"))] +#[cfg(target_arch = "aarch64")] pub const unwinder_private_data_size: usize = 2; -#[cfg(all(target_arch = "aarch64", target_pointer_width = "32"))] -pub const unwinder_private_data_size: usize = 5; - #[cfg(target_arch = "mips")] pub const unwinder_private_data_size: usize = 2; diff --git a/rustfmt.toml b/rustfmt.toml index af807aa6f739e..45cce186c0996 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -6,7 +6,7 @@ merge_derives = false # by default we ignore everything in the repository # tidy only checks files which are not ignored, each entry follows gitignore style ignore = [ - "/build/", + "build", "/vendor/", # tests for now are not formatted, as they are sometimes pretty-printing constrained diff --git a/src/bootstrap/bin/main.rs b/src/bootstrap/bin/main.rs index a32a4a7fe56c2..07e582d4d2941 100644 --- a/src/bootstrap/bin/main.rs +++ b/src/bootstrap/bin/main.rs @@ -15,7 +15,7 @@ fn main() { // check_version warnings are not printed during setup let changelog_suggestion = - if matches!(config.cmd, Subcommand::Setup { .. }) { None } else { check_version(&config) }; + if matches!(config.cmd, Subcommand::Setup {..}) { None } else { check_version(&config) }; // NOTE: Since `./configure` generates a `config.toml`, distro maintainers will see the // changelog warning, not the `x.py setup` message. diff --git a/src/bootstrap/builder/tests.rs b/src/bootstrap/builder/tests.rs index 885fcfff030a2..a367aa5349667 100644 --- a/src/bootstrap/builder/tests.rs +++ b/src/bootstrap/builder/tests.rs @@ -146,7 +146,7 @@ mod defaults { // rustdoc tool. assert_eq!( first(builder.cache.all::()), - &[doc::ErrorIndex { target: a },] + &[doc::ErrorIndex { compiler: Compiler { host: a, stage: 0 }, target: a },] ); assert_eq!( first(builder.cache.all::()), @@ -556,7 +556,7 @@ mod dist { // rustdoc tool. assert_eq!( first(builder.cache.all::()), - &[doc::ErrorIndex { target: a },] + &[doc::ErrorIndex { compiler: Compiler { host: a, stage: 1 }, target: a },] ); assert_eq!( first(builder.cache.all::()), @@ -594,7 +594,7 @@ mod dist { // rustdoc tool. assert_eq!( first(builder.cache.all::()), - &[doc::ErrorIndex { target: a },] + &[doc::ErrorIndex { compiler: Compiler { host: a, stage: 1 }, target: a },] ); assert_eq!( first(builder.cache.all::()), diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 30d690c970507..8c849846676f0 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -626,7 +626,6 @@ impl Step for Rustdoc { // Only include compiler crates, no dependencies of those, such as `libc`. cargo.arg("--no-deps"); cargo.arg("-p").arg("rustdoc"); - cargo.arg("-p").arg("rustdoc-json-types"); cargo.rustdocflag("--document-private-items"); cargo.rustdocflag("--enable-index-page"); @@ -637,6 +636,7 @@ impl Step for Rustdoc { #[derive(Ord, PartialOrd, Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct ErrorIndex { + pub compiler: Compiler, pub target: TargetSelection, } @@ -652,7 +652,12 @@ impl Step for ErrorIndex { fn make_run(run: RunConfig<'_>) { let target = run.target; - run.builder.ensure(ErrorIndex { target }); + // error_index_generator depends on librustdoc. Use the compiler that + // is normally used to build rustdoc for other documentation so that + // it shares the same artifacts. + let compiler = + run.builder.compiler_for(run.builder.top_stage, run.builder.config.build, target); + run.builder.ensure(ErrorIndex { compiler, target }); } /// Generates the HTML rendered error-index by running the @@ -661,7 +666,7 @@ impl Step for ErrorIndex { builder.info(&format!("Documenting error index ({})", self.target)); let out = builder.doc_out(self.target); t!(fs::create_dir_all(&out)); - let mut index = tool::ErrorIndex::command(builder); + let mut index = tool::ErrorIndex::command(builder, self.compiler); index.arg("html"); index.arg(out.join("error-index.html")); index.arg(&builder.version); diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index d9132f20d85b3..335a173100290 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -14,7 +14,7 @@ use std::process::Command; use build_helper::{self, output, t}; use crate::builder::{Builder, Compiler, Kind, RunConfig, ShouldRun, Step}; -use crate::cache::Interned; +use crate::cache::{Interned, INTERNER}; use crate::compile; use crate::config::TargetSelection; use crate::dist; @@ -1482,7 +1482,7 @@ impl Step for ErrorIndex { // error_index_generator depends on librustdoc. Use the compiler that // is normally used to build rustdoc for other tests (like compiletest // tests in src/test/rustdoc) so that it shares the same artifacts. - let compiler = run.builder.compiler(run.builder.top_stage, run.builder.config.build); + let compiler = run.builder.compiler_for(run.builder.top_stage, run.target, run.target); run.builder.ensure(ErrorIndex { compiler }); } @@ -1499,16 +1499,19 @@ impl Step for ErrorIndex { t!(fs::create_dir_all(&dir)); let output = dir.join("error-index.md"); - let mut tool = tool::ErrorIndex::command(builder); + let mut tool = tool::ErrorIndex::command(builder, compiler); tool.arg("markdown").arg(&output); - builder.info(&format!("Testing error-index stage{}", compiler.stage)); + // Use the rustdoc that was built by self.compiler. This copy of + // rustdoc is shared with other tests (like compiletest tests in + // src/test/rustdoc). This helps avoid building rustdoc multiple + // times. + let rustdoc_compiler = builder.compiler(builder.top_stage, builder.config.build); + builder.info(&format!("Testing error-index stage{}", rustdoc_compiler.stage)); let _time = util::timeit(&builder); builder.run_quiet(&mut tool); - // The tests themselves need to link to std, so make sure it is - // available. - builder.ensure(compile::Std { compiler, target: compiler.host }); - markdown_test(builder, compiler, &output); + builder.ensure(compile::Std { compiler: rustdoc_compiler, target: rustdoc_compiler.host }); + markdown_test(builder, rustdoc_compiler, &output); } } @@ -1610,6 +1613,55 @@ impl Step for CrateLibrustc { } } +#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] +pub struct CrateNotDefault { + compiler: Compiler, + target: TargetSelection, + test_kind: TestKind, + krate: &'static str, +} + +impl Step for CrateNotDefault { + type Output = (); + + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + run.path("src/librustc_asan") + .path("src/librustc_lsan") + .path("src/librustc_msan") + .path("src/librustc_tsan") + } + + fn make_run(run: RunConfig<'_>) { + let builder = run.builder; + let compiler = builder.compiler(builder.top_stage, run.build_triple()); + + let test_kind = builder.kind.into(); + + builder.ensure(CrateNotDefault { + compiler, + target: run.target, + test_kind, + krate: match run.path { + _ if run.path.ends_with("src/librustc_asan") => "rustc_asan", + _ if run.path.ends_with("src/librustc_lsan") => "rustc_lsan", + _ if run.path.ends_with("src/librustc_msan") => "rustc_msan", + _ if run.path.ends_with("src/librustc_tsan") => "rustc_tsan", + _ => panic!("unexpected path {:?}", run.path), + }, + }); + } + + fn run(self, builder: &Builder<'_>) { + builder.ensure(Crate { + compiler: self.compiler, + target: self.target, + mode: Mode::Std, + test_kind: self.test_kind, + krate: INTERNER.intern_str(self.krate), + }); + } +} + #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Crate { pub compiler: Compiler, @@ -1880,7 +1932,8 @@ impl Step for RemoteCopyLibs { builder.info(&format!("REMOTE copy libs to emulator ({})", target)); t!(fs::create_dir_all(builder.out.join("tmp"))); - let server = builder.ensure(tool::RemoteTestServer { compiler, target }); + let server = + builder.ensure(tool::RemoteTestServer { compiler: compiler.with_stage(0), target }); // Spawn the emulator and wait for it to come online let tool = builder.tool_exe(Tool::RemoteTestClient); diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index bf6bea539e5c2..835b8beb0e7df 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -376,15 +376,7 @@ pub struct ErrorIndex { } impl ErrorIndex { - pub fn command(builder: &Builder<'_>) -> Command { - // This uses stage-1 to match the behavior of building rustdoc. - // Error-index-generator links with the rustdoc library, so we want to - // use the same librustdoc to avoid building rustdoc twice (and to - // avoid building the compiler an extra time). This uses - // saturating_sub to deal with building with stage 0. (Using stage 0 - // isn't recommended, since it will fail if any new error index tests - // use new syntax, but it should work otherwise.) - let compiler = builder.compiler(builder.top_stage.saturating_sub(1), builder.config.build); + pub fn command(builder: &Builder<'_>, compiler: Compiler) -> Command { let mut cmd = Command::new(builder.ensure(ErrorIndex { compiler })); add_dylib_path( vec![PathBuf::from(&builder.sysroot_libdir(compiler, compiler.host))], @@ -404,14 +396,8 @@ impl Step for ErrorIndex { fn make_run(run: RunConfig<'_>) { // Compile the error-index in the same stage as rustdoc to avoid // recompiling rustdoc twice if we can. - // - // NOTE: This `make_run` isn't used in normal situations, only if you - // manually build the tool with `x.py build - // src/tools/error-index-generator` which almost nobody does. - // Normally, `x.py test` or `x.py doc` will use the - // `ErrorIndex::command` function instead. - let compiler = - run.builder.compiler(run.builder.top_stage.saturating_sub(1), run.builder.config.build); + let host = run.builder.config.build; + let compiler = run.builder.compiler_for(run.builder.top_stage, host, host); run.builder.ensure(ErrorIndex { compiler }); } diff --git a/src/ci/docker/host-x86_64/test-various/Dockerfile b/src/ci/docker/host-x86_64/test-various/Dockerfile index f5fe546cdc6b5..147de5f801588 100644 --- a/src/ci/docker/host-x86_64/test-various/Dockerfile +++ b/src/ci/docker/host-x86_64/test-various/Dockerfile @@ -1,6 +1,6 @@ -FROM ubuntu:20.04 +FROM ubuntu:18.04 -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ +RUN apt-get update && apt-get install -y --no-install-recommends \ g++ \ make \ ninja-build \ diff --git a/src/ci/docker/host-x86_64/wasm32/Dockerfile b/src/ci/docker/host-x86_64/wasm32/Dockerfile index 878c4e341589d..096b66453461e 100644 --- a/src/ci/docker/host-x86_64/wasm32/Dockerfile +++ b/src/ci/docker/host-x86_64/wasm32/Dockerfile @@ -1,6 +1,6 @@ -FROM ubuntu:20.04 +FROM ubuntu:16.04 -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ +RUN apt-get update && apt-get install -y --no-install-recommends \ g++ \ make \ ninja-build \ @@ -51,6 +51,12 @@ ENV EMCC_CFLAGS=-O1 # Emscripten installation is user-specific ENV NO_CHANGE_USER=1 -# Exclude library/alloc due to OOM in benches. +# FIXME: Re-enable these tests once https://github.com/rust-lang/cargo/pull/7476 +# is picked up by CI ENV SCRIPT python3 ../x.py test --stage 2 --host='' --target $TARGETS \ - --exclude library/alloc + --exclude library/core \ + --exclude library/alloc \ + --exclude library/proc_macro \ + --exclude library/std \ + --exclude library/term \ + --exclude library/test diff --git a/src/ci/scripts/install-awscli.sh b/src/ci/scripts/install-awscli.sh index 3d8f0de7a396b..f9b759fe343f0 100755 --- a/src/ci/scripts/install-awscli.sh +++ b/src/ci/scripts/install-awscli.sh @@ -27,7 +27,7 @@ if isLinux; then pip="pip3" pipflags="--user" - sudo apt-get install -y python3-setuptools python3-wheel + sudo apt-get install -y python3-setuptools ciCommandAddPath "${HOME}/.local/bin" fi diff --git a/src/ci/scripts/install-msys2.sh b/src/ci/scripts/install-msys2.sh index 0aa4b42a6a8fb..185d361582505 100755 --- a/src/ci/scripts/install-msys2.sh +++ b/src/ci/scripts/install-msys2.sh @@ -24,9 +24,7 @@ if isWindows; then # baked in which break LLVM's build system one way or another, so let's use the # native version which keeps everything as native as possible. python_home="/c/hostedtoolcache/windows/Python/${native_python_version}/x64" - if ! [[ -f "${python_home}/python3.exe" ]]; then - cp "${python_home}/python.exe" "${python_home}/python3.exe" - fi + cp "${python_home}/python.exe" "${python_home}/python3.exe" ciCommandAddPath "C:\\hostedtoolcache\\windows\\Python\\${native_python_version}\\x64" ciCommandAddPath "C:\\hostedtoolcache\\windows\\Python\\${native_python_version}\\x64\\Scripts" fi diff --git a/src/doc/rustc/src/exploit-mitigations.md b/src/doc/rustc/src/exploit-mitigations.md index 70df5170b21c1..44d5d9564f267 100644 --- a/src/doc/rustc/src/exploit-mitigations.md +++ b/src/doc/rustc/src/exploit-mitigations.md @@ -378,7 +378,7 @@ C library default allocator5 since version 1.32.0 (2019-01-17)[39]. -```rust,no_run +```ignore fn main() { let mut x = Box::new([0; 1024]); diff --git a/src/doc/rustc/src/lints/levels.md b/src/doc/rustc/src/lints/levels.md index 3e616f226ed76..64cbbbb003585 100644 --- a/src/doc/rustc/src/lints/levels.md +++ b/src/doc/rustc/src/lints/levels.md @@ -62,7 +62,7 @@ warning: unused variable: `x` A 'deny' lint produces an error if you violate it. For example, this code runs into the `exceeding_bitshifts` lint. -```rust,no_run +```rust,ignore fn main() { 100u8 << 10; } @@ -232,7 +232,7 @@ pub fn foo() {} This is the maximum level for all lints. So for example, if we take our code sample from the "deny" lint level above: -```rust,no_run +```rust,ignore fn main() { 100u8 << 10; } diff --git a/src/doc/rustc/src/lints/listing/index.md b/src/doc/rustc/src/lints/listing/index.md index 97aa2caf91508..18cd2fe32a3cc 100644 --- a/src/doc/rustc/src/lints/listing/index.md +++ b/src/doc/rustc/src/lints/listing/index.md @@ -2,4 +2,4 @@ This section lists out all of the lints, grouped by their default lint levels. -You can also see this list by running `rustc -W help`. +You can also see this list by running `rustc -W help`. \ No newline at end of file diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index eb74041964701..ce8caae375e98 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -156,14 +156,11 @@ target | std | host | notes `aarch64-apple-tvos` | * | | ARM64 tvOS `aarch64-unknown-freebsd` | ✓ | ✓ | ARM64 FreeBSD `aarch64-unknown-hermit` | ? | | -`aarch64-unknown-linux-gnu_ilp32` | ✓ | ✓ | ARM64 Linux (ILP32 ABI) `aarch64-unknown-netbsd` | ✓ | ✓ | `aarch64-unknown-openbsd` | ✓ | ✓ | ARM64 OpenBSD `aarch64-unknown-redox` | ? | | ARM64 Redox OS `aarch64-uwp-windows-msvc` | ? | | `aarch64-wrs-vxworks` | ? | | -`aarch64_be-unknown-linux-gnu` | ✓ | ✓ | ARM64 Linux (big-endian) -`aarch64_be-unknown-linux-gnu_ilp32` | ✓ | ✓ | ARM64 Linux (big-endian, ILP32 ABI) `armv4t-unknown-linux-gnueabi` | ? | | `armv5te-unknown-linux-uclibceabi` | ? | | ARMv5TE Linux with uClibc `armv6-unknown-freebsd` | ✓ | ✓ | ARMv6 FreeBSD diff --git a/src/doc/rustc/src/what-is-rustc.md b/src/doc/rustc/src/what-is-rustc.md index 39a05cfe20534..9dcc9f7daa9ff 100644 --- a/src/doc/rustc/src/what-is-rustc.md +++ b/src/doc/rustc/src/what-is-rustc.md @@ -39,7 +39,7 @@ $ .\hello.exe # on Windows Note that we only ever pass `rustc` the *crate root*, not every file we wish to compile. For example, if we had a `main.rs` that looked like this: -```rust,ignore (needs-multiple-files) +```rust,ignore mod foo; fn main() { @@ -49,7 +49,7 @@ fn main() { And a `foo.rs` that had this: -```rust,no_run +```rust,ignore pub fn hello() { println!("Hello, world!"); } diff --git a/src/doc/rustdoc/src/advanced-features.md b/src/doc/rustdoc/src/advanced-features.md index abdc2e4025d0e..5128ff13b7a79 100644 --- a/src/doc/rustdoc/src/advanced-features.md +++ b/src/doc/rustdoc/src/advanced-features.md @@ -47,7 +47,8 @@ all type errors and name resolution errors with function bodies. Note that this work for anything outside a function body: since Rustdoc documents your types, it has to know what those types are! For example, this code will work regardless of the platform: -```rust,ignore (platform-specific,rustdoc-specific-behavior) + +```ignore pub fn f() { use std::os::windows::ffi::OsStrExt; } @@ -55,7 +56,7 @@ pub fn f() { but this will not, because the unknown type is part of the function signature: -```rust,ignore (platform-specific,rustdoc-specific-behavior) +```ignore pub fn f() -> std::os::windows::ffi::EncodeWide<'static> { unimplemented!() } diff --git a/src/doc/rustdoc/src/documentation-tests.md b/src/doc/rustdoc/src/documentation-tests.md index 8e3c622818954..387d86189b08f 100644 --- a/src/doc/rustdoc/src/documentation-tests.md +++ b/src/doc/rustdoc/src/documentation-tests.md @@ -5,13 +5,12 @@ that examples within your documentation are up to date and working. The basic idea is this: -```rust,no_run +```ignore /// # Examples /// /// ``` /// let x = 5; /// ``` -# fn f() {} ``` The triple backticks start and end code blocks. If this were in a file named `foo.rs`, @@ -79,13 +78,12 @@ Sometimes, you need some setup code, or other things that would distract from your example, but are important to make the tests work. Consider an example block that looks like this: -```rust,no_run +```ignore /// ``` /// /// Some documentation. /// # fn foo() {} // this function will be hidden /// println!("Hello, World!"); /// ``` -# fn f() {} ``` It will render like this: @@ -198,13 +196,12 @@ When writing an example, it is rarely useful to include a complete error handling, as it would add significant amounts of boilerplate code. Instead, you may want the following: -```rust,no_run +```ignore /// ``` /// use std::io; /// let mut input = String::new(); /// io::stdin().read_line(&mut input)?; /// ``` -# fn f() {} ``` The problem is that `?` returns a `Result` and test functions don't @@ -213,7 +210,7 @@ return anything, so this will give a mismatched types error. You can get around this limitation by manually adding a `main` that returns `Result`, because `Result` implements the `Termination` trait: -```rust,no_run +```ignore /// A doc test using ? /// /// ``` @@ -225,13 +222,12 @@ You can get around this limitation by manually adding a `main` that returns /// Ok(()) /// } /// ``` -# fn f() {} ``` Together with the `# ` from the section above, you arrive at a solution that appears to the reader as the initial idea but works with doc tests: -```rust,no_run +```ignore /// ``` /// use std::io; /// # fn main() -> io::Result<()> { @@ -240,20 +236,18 @@ appears to the reader as the initial idea but works with doc tests: /// # Ok(()) /// # } /// ``` -# fn f() {} ``` As of version 1.34.0, one can also omit the `fn main()`, but you will have to disambiguate the error type: -```rust,no_run +```ignore /// ``` /// use std::io; /// let mut input = String::new(); /// io::stdin().read_line(&mut input)?; /// # Ok::<(), io::Error>(()) /// ``` -# fn f() {} ``` This is an unfortunate consequence of the `?` operator adding an implicit @@ -423,7 +417,7 @@ Another possible use of `#[cfg(doctest)]` is to test doctests that are included without including it in your main documentation. For example, you could write this into your `lib.rs` to test your README as part of your doctests: -```rust,no_run +```rust,ignore #![feature(external_doc)] #[doc(include = "../README.md")] diff --git a/src/doc/rustdoc/src/how-to-write-documentation.md b/src/doc/rustdoc/src/how-to-write-documentation.md index 9938cddc94106..41736e5ee3a7e 100644 --- a/src/doc/rustdoc/src/how-to-write-documentation.md +++ b/src/doc/rustdoc/src/how-to-write-documentation.md @@ -7,7 +7,7 @@ implementation detail, or leaves readers with unanswered questions. There are a few tenets to Rust documentation that can help guide anyone through the process of documenting libraries so that everyone has an ample opportunity -to use the code. +to use the code. This chapter covers not only how to write documentation but specifically how to write **good** documentation. It is important to be as clear @@ -19,31 +19,31 @@ then it should be documented. Documenting a crate should begin with front-page documentation. As an example, the [`hashbrown`] crate level documentation summarizes the role of -the crate, provides links to explain technical details, and explains why you -would want to use the crate. +the crate, provides links to explain technical details, and explains why you +would want to use the crate. -After introducing the crate, it is important that the front-page gives +After introducing the crate, it is important that the front-page gives an example of how to use the crate in a real world setting. Stick to the library's role in the example, but do so without shortcuts to benefit users who -may copy and paste the example to get started. +may copy and paste the example to get started. [`futures`] uses inline comments to explain line by line -the complexities of using a [`Future`], because a person's first exposure to +the complexities of using a [`Future`], because a person's first exposure to rust's [`Future`] may be this example. -The [`backtrace`] documentation walks through the whole process, explaining +The [`backtrace`] documentation walks through the whole process, explaining changes made to the `Cargo.toml` file, passing command line arguments to the -compiler, and shows a quick example of backtrace in the wild. +compiler, and shows a quick example of backtrace in the wild. Finally, the front-page can eventually become a comprehensive reference how to use a crate, like [`regex`]. In this front page, all -requirements are outlined, the edge cases shown, and practical examples +requirements are outlined, the edge cases shown, and practical examples provided. The front page goes on to show how to use regular expressions then concludes with crate features. Don't worry about comparing your crate, which is just beginning, to other more developed crates. To get the documentation to something more polished, start -incrementally and put in an introduction, example, and features. Rome was not +incrementally and put in an introduction, example, and features. Rome was not built in a day! The first lines within the `lib.rs` will compose the front-page, and they @@ -51,7 +51,7 @@ use a different convention than the rest of the rustdocs. Lines should start with `//!` which indicate module-level or crate-level documentation. Here's a quick example of the difference: -```rust,no_run +```rust,ignore //! Fast and easy queue abstraction. //! //! Provides an abstraction over a queue. When the abstraction is used @@ -64,13 +64,13 @@ Here's a quick example of the difference: /// This module makes it easy. pub mod easy { - /// Use the abstraction function to do this specific thing. - pub fn abstraction() {} + /// Use the abstract function to do this specific thing. + pub fn abstract() {} } ``` -Ideally, this first line of documentation is a sentence without highly +Ideally, this first line of documentation is a sentence without highly technical details, but with a good description of where this crate fits within the rust ecosystem. Users should know whether this crate meets their use case after reading this line. @@ -95,7 +95,7 @@ It is recommended that each item's documentation follows this basic structure: This basic structure should be straightforward to follow when writing your documentation; while you might think that a code example is trivial, -the examples are really important because they can help users understand +the examples are really important because they can help users understand what an item is, how it is used, and for what purpose it exists. Let's see an example coming from the [standard library] by taking a look at the @@ -133,7 +133,7 @@ for argument in env::args() { [`args_os`]: ./fn.args_os.html `````` -Everything before the first empty line will be reused to describe the component +Everything before the first empty line will be reused to describe the component in searches and module overviews. For example, the function `std::env::args()` above will be shown on the [`std::env`] module documentation. It is good practice to keep the summary to one line: concise writing is a goal of good @@ -221,30 +221,11 @@ This example will render similarly to this: See the specification for the [GitHub Tables extension][tables] for more details on the exact syntax supported. -### Task lists - -Task lists can be used as a checklist of items that have been completed. -Example: - -```md -- [x] Complete task -- [ ] IncComplete task -``` - -This will render as - -
    -
  • -
  • -
- -See the specification for the [task list extension] for more details. - [`backtrace`]: https://docs.rs/backtrace/0.3.50/backtrace/ [commonmark markdown specification]: https://commonmark.org/ [commonmark quick reference]: https://commonmark.org/help/ [env::args]: https://doc.rust-lang.org/stable/std/env/fn.args.html -[`Future`]: https://doc.rust-lang.org/std/future/trait.Future.html +[`Future`]: https://doc.rust-lang.org/std/future/trait.Future.html [`futures`]: https://docs.rs/futures/0.3.5/futures/ [`hashbrown`]: https://docs.rs/hashbrown/0.8.2/hashbrown/ [`regex`]: https://docs.rs/regex/1.3.9/regex/ @@ -253,4 +234,3 @@ See the specification for the [task list extension] for more details. [`std::env`]: https://doc.rust-lang.org/stable/std/env/index.html#functions [strikethrough]: https://github.github.com/gfm/#strikethrough-extension- [tables]: https://github.github.com/gfm/#tables-extension- -[task list extension]: https://github.github.com/gfm/#task-list-items-extension- diff --git a/src/doc/rustdoc/src/lints.md b/src/doc/rustdoc/src/lints.md index cce3623dc8f49..41292b3d83841 100644 --- a/src/doc/rustdoc/src/lints.md +++ b/src/doc/rustdoc/src/lints.md @@ -3,11 +3,10 @@ `rustdoc` provides lints to help you writing and testing your documentation. You can use them like any other lints by doing this: -```rust +```rust,ignore #![allow(missing_docs)] // allows the lint, no diagnostics will be reported #![warn(missing_docs)] // warn if there are missing docs #![deny(missing_docs)] // error if there are missing docs -# //! Crate docs. ``` Here is the list of the lints provided by `rustdoc`: diff --git a/src/doc/rustdoc/src/passes.md b/src/doc/rustdoc/src/passes.md index 140b832f19a54..081e477de8010 100644 --- a/src/doc/rustdoc/src/passes.md +++ b/src/doc/rustdoc/src/passes.md @@ -32,9 +32,8 @@ Without this pass, these items will remain in the output. When you write a doc comment like this: -```rust,no_run +```rust,ignore /// This is a documentation comment. -# fn f() {} ``` There's a space between the `///` and that `T`. That spacing isn't intended @@ -53,10 +52,9 @@ documentation string. For example: -```rust,no_run +```rust,ignore #[doc = "This is the first line."] #[doc = "This is the second line."] -# fn f() {} ``` Gets collapsed into a single doc string of @@ -70,7 +68,7 @@ This is the second line. This removes documentation for any non-public items, so for example: -```rust,no_run +```rust,ignore /// These are private docs. struct Private; diff --git a/src/doc/rustdoc/src/references.md b/src/doc/rustdoc/src/references.md index b0e2437392c95..1e050e321d2e3 100644 --- a/src/doc/rustdoc/src/references.md +++ b/src/doc/rustdoc/src/references.md @@ -3,7 +3,7 @@ There are many great `rustdoc` references out there. If you know of other great resources, please submit a pull request! -## Official +## Official - [Learn Rust] - [Rust By Example] @@ -11,7 +11,7 @@ If you know of other great resources, please submit a pull request! - [RFC 1574: More API Documentation Conventions] - [RFC 1946: Intra Rustdoc Links] -## Community +## Community - [API Guidelines] - [Github tagged RFCs] - [Github tagged issues] @@ -28,4 +28,4 @@ If you know of other great resources, please submit a pull request! [RFC 1946: Intra Rustdoc Links]: https://rust-lang.github.io/rfcs/1946-intra-rustdoc-links.html [RFC (stalled) front page styleguide]: https://github.com/rust-lang/rfcs/pull/1687 [Rust By Example]: https://doc.rust-lang.org/stable/rust-by-example/meta/doc.html -[Rust Reference]: https://doc.rust-lang.org/stable/reference/comments.html#doc-comments +[Rust Reference]: https://doc.rust-lang.org/stable/reference/comments.html#doc-comments \ No newline at end of file diff --git a/src/doc/rustdoc/src/the-doc-attribute.md b/src/doc/rustdoc/src/the-doc-attribute.md index 52f2a3728fabb..ef143c8727ee9 100644 --- a/src/doc/rustdoc/src/the-doc-attribute.md +++ b/src/doc/rustdoc/src/the-doc-attribute.md @@ -7,10 +7,9 @@ The most basic function of `#[doc]` is to handle the actual documentation text. That is, `///` is syntax sugar for `#[doc]`. This means that these two are the same: -```rust,no_run +```rust,ignore /// This is a doc comment. #[doc = " This is a doc comment."] -# fn f() {} ``` (Note the leading space in the attribute version.) @@ -19,18 +18,16 @@ In most cases, `///` is easier to use than `#[doc]`. One case where the latter i when generating documentation in macros; the `collapse-docs` pass will combine multiple `#[doc]` attributes into a single doc comment, letting you generate code like this: -```rust,no_run +```rust,ignore #[doc = "This is"] #[doc = " a "] #[doc = "doc comment"] -# fn f() {} ``` Which can feel more flexible. Note that this would generate this: -```rust,no_run +```rust,ignore #[doc = "This is\n a \ndoc comment"] -# fn f() {} ``` but given that docs are rendered via Markdown, it will remove these newlines. @@ -48,7 +45,7 @@ These options control how the docs look at a crate level. This form of the `doc` attribute lets you control the favicon of your docs. -```rust,no_run +```rust,ignore #![doc(html_favicon_url = "https://example.com/favicon.ico")] ``` @@ -62,7 +59,7 @@ If you don't use this attribute, there will be no favicon. This form of the `doc` attribute lets you control the logo in the upper left hand side of the docs. -```rust,no_run +```rust,ignore #![doc(html_logo_url = "https://example.com/logo.jpg")] ``` @@ -76,7 +73,7 @@ If you don't use this attribute, there will be no logo. This form of the `doc` attribute lets you control where the "run" buttons on your documentation examples make requests to. -```rust,no_run +```rust,ignore #![doc(html_playground_url = "https://playground.example.com/")] ``` @@ -91,7 +88,7 @@ When a feature is unstable, an issue number for tracking the feature must be given. `rustdoc` uses this number, plus the base URL given here, to link to the tracking issue. -```rust,no_run +```rust,ignore #![doc(issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")] ``` @@ -106,7 +103,7 @@ available. If that is not available, then it will use the `html_root_url` value in the extern crate if it is available. If that is not available, then the extern items will not be linked. -```rust,no_run +```rust,ignore #![doc(html_root_url = "https://docs.rs/serde/1.0")] ``` @@ -115,7 +112,7 @@ the extern items will not be linked. By default, `rustdoc` will include the source code of your program, with links to it in the docs. But if you include this: -```rust,no_run +```rust,ignore #![doc(html_no_source)] ``` @@ -126,7 +123,7 @@ it will not. By default, `rustdoc` will automatically add a line with `extern crate my_crate;` into each doctest. But if you include this: -```rust,no_run +```rust,ignore #![doc(test(no_crate_inject))] ``` @@ -137,7 +134,7 @@ it will not. This form of the `doc` attribute allows you to add arbitrary attributes to all your doctests. For example, if you want your doctests to fail if they produce any warnings, you could add this: -```rust,no_run +```rust,ignore #![doc(test(attr(deny(warnings))))] ``` @@ -151,7 +148,7 @@ they are documented. These attributes are used on `use` statements, and control where the documentation shows up. For example, consider this Rust code: -```rust,no_run +```rust,ignore pub use bar::Bar; /// bar docs @@ -159,7 +156,6 @@ pub mod bar { /// the docs for Bar pub struct Bar; } -# fn main() {} ``` The documentation will generate a "Re-exports" section, and say `pub use bar::Bar;`, where @@ -167,11 +163,9 @@ The documentation will generate a "Re-exports" section, and say `pub use bar::Ba If we change the `use` line like this: -```rust,no_run +```rust,ignore #[doc(inline)] pub use bar::Bar; -# pub mod bar { pub struct Bar; } -# fn main() {} ``` Instead, `Bar` will appear in a `Structs` section, just like `Bar` was defined at the @@ -179,7 +173,7 @@ top level, rather than `pub use`'d. Let's change our original example, by making `bar` private: -```rust,no_run +```rust,ignore pub use bar::Bar; /// bar docs @@ -187,7 +181,6 @@ mod bar { /// the docs for Bar pub struct Bar; } -# fn main() {} ``` Here, because `bar` is not public, `Bar` wouldn't have its own page, so there's nowhere @@ -195,7 +188,7 @@ to link to. `rustdoc` will inline these definitions, and so we end up in the sam as the `#[doc(inline)]` above; `Bar` is in a `Structs` section, as if it were defined at the top level. If we add the `no_inline` form of the attribute: -```rust,no_run +```rust,ignore #[doc(no_inline)] pub use bar::Bar; @@ -204,7 +197,6 @@ mod bar { /// the docs for Bar pub struct Bar; } -# fn main() {} ``` Now we'll have a `Re-exports` line, and `Bar` will not link to anywhere. diff --git a/src/doc/rustdoc/src/what-is-rustdoc.md b/src/doc/rustdoc/src/what-is-rustdoc.md index 7a444d77c09d1..32dc1e02bb3db 100644 --- a/src/doc/rustdoc/src/what-is-rustdoc.md +++ b/src/doc/rustdoc/src/what-is-rustdoc.md @@ -32,7 +32,7 @@ $ rustdoc src/lib.rs This will create a new directory, `doc`, with a website inside! In our case, the main page is located in `doc/lib/index.html`. If you open that up in a web browser, you will see a page with a search bar, and "Crate lib" at the -top, with no contents. +top, with no contents. ## Configuring rustdoc @@ -89,18 +89,18 @@ dependency=/docs/target/debug/deps You can see this with `cargo doc --verbose`. It generates the correct `--crate-name` for us, as well as pointing to -`src/lib.rs`. But what about those other arguments? - - `-o` controls the *o*utput of our docs. Instead of a top-level - `doc` directory, notice that Cargo puts generated documentation under +`src/lib.rs`. But what about those other arguments? + - `-o` controls the *o*utput of our docs. Instead of a top-level + `doc` directory, notice that Cargo puts generated documentation under `target`. That is the idiomatic place for generated files in Cargo projects. - - `-L` flag helps rustdoc find the dependencies your code relies on. + - `-L` flag helps rustdoc find the dependencies your code relies on. If our project used dependencies, we would get documentation for them as well! ## Outer and inner documentation The `///` syntax is used to document the item present after it. That's why it is called an outer documentation. -There is another syntax: `//!`, which is used to document the +There is another syntax: `//!`, which is used to document the item it is present inside. It is called an inner documentation. It is often used when documenting the entire crate, because nothing comes before it: it is the root of the crate. diff --git a/src/doc/rustdoc/src/what-to-include.md b/src/doc/rustdoc/src/what-to-include.md index 9683f519be121..878c75baae727 100644 --- a/src/doc/rustdoc/src/what-to-include.md +++ b/src/doc/rustdoc/src/what-to-include.md @@ -38,10 +38,10 @@ warning: 1 warning emitted As a library author, adding the lint `#![deny(missing_docs)]` is a great way to ensure the project does not drift away from being documented well, and -`#![warn(missing_docs)]` is a good way to move towards comprehensive +`#![warn(missing_docs)]` is a good way to move towards comprehensive documentation. In addition to docs, `#![deny(missing_doc_code_examples)]` ensures each function contains a usage example. In our example above, the -warning is resolved by adding crate level documentation. +warning is resolved by adding crate level documentation. There are more lints in the upcoming chapter [Lints][rustdoc-lints]. @@ -58,7 +58,7 @@ users to figure out how to put the `async` code into their own runtime. It is preferred that `unwrap()` not be used inside an example, and some of the error handling components be hidden if they make the example too difficult to -follow. +follow. ``````text /// Example @@ -66,9 +66,9 @@ follow. /// let fourtytwo = "42".parse::()?; /// println!("{} + 10 = {}", fourtytwo, fourtytwo+10); /// ``` -`````` +`````` -When rustdoc wraps that in a main function, it will fail to compile because the +When rustdoc wraps that in a main function, it will fail to compile because the `ParseIntError` trait is not implemented. In order to help both your audience and your test suite, this example needs some additional code: @@ -81,17 +81,17 @@ and your test suite, this example needs some additional code: /// # Ok(()) /// # } /// ``` -`````` +`````` The example is the same on the doc page, but has that extra information -available to anyone trying to use your crate. More about tests in the -upcoming [Documentation tests] chapter. +available to anyone trying to use your crate. More about tests in the +upcoming [Documentation tests] chapter. ## What to Exclude Certain parts of your public interface may be included by default in the output of rustdoc. The attribute `#[doc(hidden)]` can hide implementation details -to encourage idiomatic use of the crate. +to encourage idiomatic use of the crate. For example, an internal `macro!` that makes the crate easier to implement can become a footgun for users when it appears in the public documentation. An @@ -101,11 +101,11 @@ detailed in the [API Guidelines]. ## Customizing the output It is possible to pass a custom css file to `rustdoc` and style the -documentation. +documentation. ```bash rustdoc --extend-css custom.css src/lib.rs -``` +``` A good example of using this feature to create a dark theme is documented [on this blog]. Just remember, dark theme is already included in the rustdoc output @@ -122,4 +122,4 @@ Here is an example of a new theme, [Ayu]. [API Guidelines]: https://rust-lang.github.io/api-guidelines/documentation.html#rustdoc-does-not-show-unhelpful-implementation-details-c-hidden [Documentation tests]: documentation-tests.md [on this blog]: https://blog.guillaume-gomez.fr/articles/2016-09-16+Generating+doc+with+rustdoc+and+a+custom+theme -[rustdoc-lints]: lints.md +[rustdoc-lints]: lints.md \ No newline at end of file diff --git a/src/doc/unstable-book/src/compiler-flags/codegen-backend.md b/src/doc/unstable-book/src/compiler-flags/codegen-backend.md index 3c0cd32fae172..878c894a6ca70 100644 --- a/src/doc/unstable-book/src/compiler-flags/codegen-backend.md +++ b/src/doc/unstable-book/src/compiler-flags/codegen-backend.md @@ -15,7 +15,7 @@ named `__rustc_codegen_backend` with a signature of `fn() -> Box`, indicating which dependency of - which rule introduced the unused extern crate. - -This primarily intended to be used with tooling - for example a linter which can automatically -remove unused dependencies - rather than being directly presented to users. - -`raw` locations are presented as part of the normal rendered diagnostics and included in -the json form. `json` locations are only included in the json form of diagnostics, -as a `tool_metadata` field. For `raw` locations `tool_metadata` is simply a json string, -whereas `json` allows the rustc invoker to fully control its form and content. diff --git a/src/doc/unstable-book/src/compiler-flags/profile.md b/src/doc/unstable-book/src/compiler-flags/profile.md index 71303bfaff20d..7973b3e4f2f32 100644 --- a/src/doc/unstable-book/src/compiler-flags/profile.md +++ b/src/doc/unstable-book/src/compiler-flags/profile.md @@ -22,6 +22,6 @@ Once you've built and run your program, files with the `gcno` (after build) and You can parse them with [llvm-cov gcov](https://llvm.org/docs/CommandGuide/llvm-cov.html#llvm-cov-gcov) or [grcov](https://github.com/mozilla/grcov). Please note that `RUSTFLAGS` by default applies to everything that cargo builds and runs during a build! -When the `--target` flag is explicitly passed to cargo, the `RUSTFLAGS` no longer apply to build scripts and procedural macros. -For more fine-grained control consider passing a `RUSTC_WRAPPER` program to cargo that only adds the profiling flags to +When the `--target` flag is explicitly passed to cargo, the `RUSTFLAGS` no longer apply to build scripts and procedural macros. +For more fine-grained control consider passing a `RUSTC_WRAPPER` program to cargo that only adds the profiling flags to rustc for the specific crates you want to profile. diff --git a/src/doc/unstable-book/src/compiler-flags/report-time.md b/src/doc/unstable-book/src/compiler-flags/report-time.md index ac0093f77aec2..68265d8a9e810 100644 --- a/src/doc/unstable-book/src/compiler-flags/report-time.md +++ b/src/doc/unstable-book/src/compiler-flags/report-time.md @@ -34,7 +34,7 @@ Available options: Expected format of environment variable is `VARIABLE=WARN_TIME,CRITICAL_TIME`. Not available for --format=terse ---ensure-time +--ensure-time Treat excess of the test execution time limit as error. Threshold values for this option can be configured via diff --git a/src/doc/unstable-book/src/compiler-flags/tls-model.md b/src/doc/unstable-book/src/compiler-flags/tls-model.md index 8b19e785c6a5b..cd625f3fd096c 100644 --- a/src/doc/unstable-book/src/compiler-flags/tls-model.md +++ b/src/doc/unstable-book/src/compiler-flags/tls-model.md @@ -11,7 +11,7 @@ Supported values for this option are: - `global-dynamic` - General Dynamic TLS Model (alternatively called Global Dynamic) is the most general option usable in all circumstances, even if the TLS data is defined in a shared library -loaded at runtime and is accessed from code outside of that library. +loaded at runtime and is accessed from code outside of that library. This is the default for most targets. - `local-dynamic` - model usable if the TLS data is only accessed from the shared library or executable it is defined in. The TLS data may be in a library loaded after startup (via `dlopen`). diff --git a/src/doc/unstable-book/src/language-features/abi-c-cmse-nonsecure-call.md b/src/doc/unstable-book/src/language-features/abi-c-cmse-nonsecure-call.md deleted file mode 100644 index 79a177cb28b15..0000000000000 --- a/src/doc/unstable-book/src/language-features/abi-c-cmse-nonsecure-call.md +++ /dev/null @@ -1,88 +0,0 @@ -# `abi_c_cmse_nonsecure_call` - -The tracking issue for this feature is: [#81391] - -[#81391]: https://github.com/rust-lang/rust/issues/81391 - ------------------------- - -The [TrustZone-M -feature](https://developer.arm.com/documentation/100690/latest/) is available -for targets with the Armv8-M architecture profile (`thumbv8m` in their target -name). -LLVM, the Rust compiler and the linker are providing -[support](https://developer.arm.com/documentation/ecm0359818/latest/) for the -TrustZone-M feature. - -One of the things provided, with this unstable feature, is the -`C-cmse-nonsecure-call` function ABI. This ABI is used on function pointers to -non-secure code to mark a non-secure function call (see [section -5.5](https://developer.arm.com/documentation/ecm0359818/latest/) for details). - -With this ABI, the compiler will do the following to perform the call: -* save registers needed after the call to Secure memory -* clear all registers that might contain confidential information -* clear the Least Significant Bit of the function address -* branches using the BLXNS instruction - -To avoid using the non-secure stack, the compiler will constrain the number and -type of parameters/return value. - -The `extern "C-cmse-nonsecure-call"` ABI is otherwise equivalent to the -`extern "C"` ABI. - - - -``` rust,ignore -#![no_std] -#![feature(abi_c_cmse_nonsecure_call)] - -#[no_mangle] -pub fn call_nonsecure_function(addr: usize) -> u32 { - let non_secure_function = - unsafe { core::mem::transmute:: u32>(addr) }; - non_secure_function() -} -``` - -``` text -$ rustc --emit asm --crate-type lib --target thumbv8m.main-none-eabi function.rs - -call_nonsecure_function: - .fnstart - .save {r7, lr} - push {r7, lr} - .setfp r7, sp - mov r7, sp - .pad #16 - sub sp, #16 - str r0, [sp, #12] - ldr r0, [sp, #12] - str r0, [sp, #8] - b .LBB0_1 -.LBB0_1: - ldr r0, [sp, #8] - push.w {r4, r5, r6, r7, r8, r9, r10, r11} - bic r0, r0, #1 - mov r1, r0 - mov r2, r0 - mov r3, r0 - mov r4, r0 - mov r5, r0 - mov r6, r0 - mov r7, r0 - mov r8, r0 - mov r9, r0 - mov r10, r0 - mov r11, r0 - mov r12, r0 - msr apsr_nzcvq, r0 - blxns r0 - pop.w {r4, r5, r6, r7, r8, r9, r10, r11} - str r0, [sp, #4] - b .LBB0_2 -.LBB0_2: - ldr r0, [sp, #4] - add sp, #16 - pop {r7, pc} -``` diff --git a/src/doc/unstable-book/src/language-features/auto-traits.md b/src/doc/unstable-book/src/language-features/auto-traits.md index f967c11fc4d08..0ca6dd6670bc4 100644 --- a/src/doc/unstable-book/src/language-features/auto-traits.md +++ b/src/doc/unstable-book/src/language-features/auto-traits.md @@ -1,6 +1,6 @@ # `auto_traits` -The tracking issue for this feature is [#13231] +The tracking issue for this feature is [#13231] [#13231]: https://github.com/rust-lang/rust/issues/13231 @@ -9,15 +9,15 @@ The tracking issue for this feature is [#13231] The `auto_traits` feature gate allows you to define auto traits. Auto traits, like [`Send`] or [`Sync`] in the standard library, are marker traits -that are automatically implemented for every type, unless the type, or a type it contains, +that are automatically implemented for every type, unless the type, or a type it contains, has explicitly opted out via a negative impl. (Negative impls are separately controlled by the `negative_impls` feature.) [`Send`]: https://doc.rust-lang.org/std/marker/trait.Send.html [`Sync`]: https://doc.rust-lang.org/std/marker/trait.Sync.html -```rust,ignore (partial-example) -impl !Trait for Type {} +```rust,ignore +impl !Trait for Type ``` Example: @@ -40,7 +40,7 @@ fn must_be_valid(_t: T) { } fn main() { // works must_be_valid( MaybeValid(True) ); - + // compiler error - trait bound not satisfied // must_be_valid( MaybeValid(False) ); } @@ -80,7 +80,7 @@ where Explicit impls may be either positive or negative. They take the form: -```rust,ignore (partial-example) +```rust,ignore impl<...> AutoTrait for StructName<..> { } impl<...> !AutoTrait for StructName<..> { } ``` @@ -104,3 +104,4 @@ Auto traits cannot have any trait items, such as methods or associated types. Th ## Supertraits Auto traits cannot have supertraits. This is for soundness reasons, as the interaction of coinduction with implied bounds is difficult to reconcile. + diff --git a/src/doc/unstable-book/src/language-features/custom-test-frameworks.md b/src/doc/unstable-book/src/language-features/custom-test-frameworks.md index 53ecac9314d79..3990b6ad2f080 100644 --- a/src/doc/unstable-book/src/language-features/custom-test-frameworks.md +++ b/src/doc/unstable-book/src/language-features/custom-test-frameworks.md @@ -30,3 +30,4 @@ const WILL_PASS: i32 = 0; #[test_case] const WILL_FAIL: i32 = 4; ``` + diff --git a/src/doc/unstable-book/src/language-features/infer-static-outlives-requirements.md b/src/doc/unstable-book/src/language-features/infer-static-outlives-requirements.md index 5f3f1b4dd8a31..53e01091f754e 100644 --- a/src/doc/unstable-book/src/language-features/infer-static-outlives-requirements.md +++ b/src/doc/unstable-book/src/language-features/infer-static-outlives-requirements.md @@ -42,3 +42,4 @@ struct Bar { x: T, } ``` + diff --git a/src/doc/unstable-book/src/language-features/intrinsics.md b/src/doc/unstable-book/src/language-features/intrinsics.md index a0fb4e743d3f2..bc35c2a030533 100644 --- a/src/doc/unstable-book/src/language-features/intrinsics.md +++ b/src/doc/unstable-book/src/language-features/intrinsics.md @@ -27,3 +27,4 @@ extern "rust-intrinsic" { ``` As with any other FFI functions, these are always `unsafe` to call. + diff --git a/src/doc/unstable-book/src/language-features/lang-items.md b/src/doc/unstable-book/src/language-features/lang-items.md index d44c841d48c66..20c7d7dcec8d6 100644 --- a/src/doc/unstable-book/src/language-features/lang-items.md +++ b/src/doc/unstable-book/src/language-features/lang-items.md @@ -15,8 +15,8 @@ For example, `Box` pointers require two lang items, one for allocation and one for deallocation. A freestanding program that uses the `Box` sugar for dynamic allocations via `malloc` and `free`: -```rust,ignore (libc-is-finicky) -#![feature(lang_items, box_syntax, start, libc, core_intrinsics, rustc_private)] +```rust,ignore +#![feature(lang_items, box_syntax, start, libc, core_intrinsics)] #![no_std] use core::intrinsics; use core::panic::PanicInfo; @@ -105,8 +105,8 @@ or overriding the default shim for the C `main` function with your own. The function marked `#[start]` is passed the command line parameters in the same format as C: -```rust,ignore (libc-is-finicky) -#![feature(lang_items, core_intrinsics, rustc_private)] +```rust,ignore +#![feature(lang_items, core_intrinsics)] #![feature(start)] #![no_std] use core::intrinsics; @@ -141,8 +141,8 @@ with `#![no_main]` and then create the appropriate symbol with the correct ABI and the correct name, which requires overriding the compiler's name mangling too: -```rust,ignore (libc-is-finicky) -#![feature(lang_items, core_intrinsics, rustc_private)] +```rust,ignore +#![feature(lang_items, core_intrinsics)] #![feature(start)] #![no_std] #![no_main] diff --git a/src/doc/unstable-book/src/language-features/non-ascii-idents.md b/src/doc/unstable-book/src/language-features/non-ascii-idents.md index 847f25ecab132..22dae0c89a6ff 100644 --- a/src/doc/unstable-book/src/language-features/non-ascii-idents.md +++ b/src/doc/unstable-book/src/language-features/non-ascii-idents.md @@ -19,10 +19,10 @@ const Π: f64 = 3.14f64; ## Changes to the language reference -> **Lexer:**\ -> IDENTIFIER :\ ->       XID_start XID_continue\*\ ->    | `_` XID_continue+ +> **Lexer:** +> IDENTIFIER : +>       XID_start XID_continue\* +>    | `_` XID_continue+ An identifier is any nonempty Unicode string of the following form: diff --git a/src/doc/unstable-book/src/language-features/or-patterns.md b/src/doc/unstable-book/src/language-features/or-patterns.md index 55c31add26d77..8ebacb44d37cc 100644 --- a/src/doc/unstable-book/src/language-features/or-patterns.md +++ b/src/doc/unstable-book/src/language-features/or-patterns.md @@ -11,7 +11,7 @@ a pattern, for example, `Some(A(0) | B(1 | 2))` becomes a valid pattern. ## Examples -```rust,no_run +```rust,ignore #![feature(or_patterns)] pub enum Foo { diff --git a/src/doc/unstable-book/src/language-features/plugin.md b/src/doc/unstable-book/src/language-features/plugin.md index 44308bdfba6c3..3835113152762 100644 --- a/src/doc/unstable-book/src/language-features/plugin.md +++ b/src/doc/unstable-book/src/language-features/plugin.md @@ -38,7 +38,7 @@ additional checks for code style, safety, etc. Now let's write a plugin [`lint-plugin-test.rs`](https://github.com/rust-lang/rust/blob/master/src/test/ui-fulldeps/auxiliary/lint-plugin-test.rs) that warns about any item named `lintme`. -```rust,ignore (requires-stage-2) +```rust,ignore #![feature(plugin_registrar)] #![feature(box_syntax, rustc_private)] @@ -77,7 +77,7 @@ pub fn plugin_registrar(reg: &mut Registry) { Then code like -```rust,ignore (requires-plugin) +```rust,ignore #![feature(plugin)] #![plugin(lint_plugin_test)] diff --git a/src/doc/unstable-book/src/language-features/rustc-attrs.md b/src/doc/unstable-book/src/language-features/rustc-attrs.md index c67b806f06af4..1d9409ee9e438 100644 --- a/src/doc/unstable-book/src/language-features/rustc-attrs.md +++ b/src/doc/unstable-book/src/language-features/rustc-attrs.md @@ -18,7 +18,7 @@ Options provided by `#[rustc_layout(...)]` are `debug`, `size`, `align`, ## Examples -```rust,compile_fail +```rust,ignore #![feature(rustc_attrs)] #[rustc_layout(abi, size)] diff --git a/src/doc/unstable-book/src/language-features/unboxed-closures.md b/src/doc/unstable-book/src/language-features/unboxed-closures.md index e4113d72d0914..71003fba00ba2 100644 --- a/src/doc/unstable-book/src/language-features/unboxed-closures.md +++ b/src/doc/unstable-book/src/language-features/unboxed-closures.md @@ -9,7 +9,7 @@ See Also: [`fn_traits`](../library-features/fn-traits.md) ---- The `unboxed_closures` feature allows you to write functions using the `"rust-call"` ABI, -required for implementing the [`Fn*`] family of traits. `"rust-call"` functions must have +required for implementing the [`Fn*`] family of traits. `"rust-call"` functions must have exactly one (non self) argument, a tuple representing the argument list. [`Fn*`]: https://doc.rust-lang.org/std/ops/trait.Fn.html diff --git a/src/doc/unstable-book/src/language-features/unsized-locals.md b/src/doc/unstable-book/src/language-features/unsized-locals.md index d5b01a3d6168e..d716b1d51dcf7 100644 --- a/src/doc/unstable-book/src/language-features/unsized-locals.md +++ b/src/doc/unstable-book/src/language-features/unsized-locals.md @@ -30,7 +30,7 @@ fn foo(_: dyn Any) {} The RFC still forbids the following unsized expressions: -```rust,compile_fail +```rust,ignore #![feature(unsized_locals)] use std::any::Any; @@ -124,7 +124,7 @@ One of the objectives of this feature is to allow `Box`. The RFC also describes an extension to the array literal syntax: `[e; dyn n]`. In the syntax, `n` isn't necessarily a constant expression. The array is dynamically allocated on the stack and has the type of `[T]`, instead of `[T; n]`. -```rust,ignore (not-yet-implemented) +```rust,ignore #![feature(unsized_locals)] fn mergesort(a: &mut [T]) { diff --git a/src/doc/unstable-book/src/language-features/unsized-tuple-coercion.md b/src/doc/unstable-book/src/language-features/unsized-tuple-coercion.md index 310c8d962948a..731d2acbfdd5a 100644 --- a/src/doc/unstable-book/src/language-features/unsized-tuple-coercion.md +++ b/src/doc/unstable-book/src/language-features/unsized-tuple-coercion.md @@ -8,7 +8,7 @@ The tracking issue for this feature is: [#42877] This is a part of [RFC0401]. According to the RFC, there should be an implementation like this: -```rust,ignore (partial-example) +```rust,ignore impl<..., T, U: ?Sized> Unsized<(..., U)> for (..., T) where T: Unsized {} ``` diff --git a/src/doc/unstable-book/src/library-features/asm.md b/src/doc/unstable-book/src/library-features/asm.md index c0e23b834d150..ccdd862869961 100644 --- a/src/doc/unstable-book/src/library-features/asm.md +++ b/src/doc/unstable-book/src/library-features/asm.md @@ -405,7 +405,7 @@ When required, options are specified as the final argument. The following ABNF specifies the general syntax: -```text +```ignore dir_spec := "in" / "out" / "lateout" / "inout" / "inlateout" reg_spec := / "" operand_expr := expr / "_" / expr "=>" expr / expr "=>" "_" diff --git a/src/doc/unstable-book/src/library-features/concat-idents.md b/src/doc/unstable-book/src/library-features/concat-idents.md index 73f6cfa21787e..ecfd34a22e5cc 100644 --- a/src/doc/unstable-book/src/library-features/concat-idents.md +++ b/src/doc/unstable-book/src/library-features/concat-idents.md @@ -19,4 +19,4 @@ fn main() { let f = concat_idents!(foo, bar); assert_eq!(f(), 23); } -``` +``` \ No newline at end of file diff --git a/src/doc/unstable-book/src/library-features/global-asm.md b/src/doc/unstable-book/src/library-features/global-asm.md index ce1155a977cd0..bc55fe80fa64c 100644 --- a/src/doc/unstable-book/src/library-features/global-asm.md +++ b/src/doc/unstable-book/src/library-features/global-asm.md @@ -24,18 +24,17 @@ conventions of the assembler in your toolchain. A simple usage looks like this: -```rust,ignore (requires-external-file) -#![feature(global_asm)] -# // you also need relevant target_arch cfgs +```rust,ignore +# #![feature(global_asm)] +# you also need relevant target_arch cfgs global_asm!(include_str!("something_neato.s")); ``` And a more complicated usage looks like this: -```rust,no_run -#![feature(global_asm)] -# #[cfg(any(target_arch="x86", target_arch="x86_64"))] -# mod x86 { +```rust,ignore +# #![feature(global_asm)] +# #![cfg(any(target_arch = "x86", target_arch = "x86_64"))] pub mod sally { global_asm!(r#" @@ -65,7 +64,6 @@ pub mod harry { #[no_mangle] pub unsafe extern "C" fn quux() {} } -# } ``` You may use `global_asm!` multiple times, anywhere in your crate, in diff --git a/src/doc/unstable-book/src/library-features/llvm-asm.md b/src/doc/unstable-book/src/library-features/llvm-asm.md index 07fc16261d820..a2f029db29165 100644 --- a/src/doc/unstable-book/src/library-features/llvm-asm.md +++ b/src/doc/unstable-book/src/library-features/llvm-asm.md @@ -10,7 +10,7 @@ For extremely low-level manipulations and performance reasons, one might wish to control the CPU directly. Rust supports using inline assembly to do this via the `llvm_asm!` macro. -```rust,ignore (pseudo-code) +```rust,ignore llvm_asm!(assembly template : output operands : input operands diff --git a/src/doc/unstable-book/src/library-features/test.md b/src/doc/unstable-book/src/library-features/test.md index c99584e5fb397..6b4a3a677db61 100644 --- a/src/doc/unstable-book/src/library-features/test.md +++ b/src/doc/unstable-book/src/library-features/test.md @@ -9,7 +9,7 @@ most widely used part of the `test` crate are benchmark tests, which can test the performance of your code. Let's make our `src/lib.rs` look like this (comments elided): -```rust,no_run +```rust,ignore #![feature(test)] extern crate test; @@ -83,7 +83,7 @@ the benchmark is no longer benchmarking what one expects. For example, the compiler might recognize that some calculation has no external effects and remove it entirely. -```rust,no_run +```rust,ignore #![feature(test)] extern crate test; diff --git a/src/doc/unstable-book/src/library-features/try-trait.md b/src/doc/unstable-book/src/library-features/try-trait.md index 022640067bd11..0c07329025bca 100644 --- a/src/doc/unstable-book/src/library-features/try-trait.md +++ b/src/doc/unstable-book/src/library-features/try-trait.md @@ -16,7 +16,7 @@ macro on `Poll`, among other things. Here's an example implementation of the trait: -```rust,ignore (cannot-reimpl-Try) +```rust,ignore /// A distinct type to represent the `None` value of an `Option`. /// /// This enables using the `?` operator on `Option`; it's rarely useful alone. diff --git a/src/etc/lldb_providers.py b/src/etc/lldb_providers.py index ca2685ca31ffd..9c7b07efbaa77 100644 --- a/src/etc/lldb_providers.py +++ b/src/etc/lldb_providers.py @@ -531,9 +531,7 @@ def update(self): ctrl = table.GetChildMemberWithName("ctrl").GetChildAtIndex(0) self.size = table.GetChildMemberWithName("items").GetValueAsUnsigned() - self.pair_type = table.type.template_args[0] - if self.pair_type.IsTypedefType(): - self.pair_type = self.pair_type.GetTypedefedType() + self.pair_type = table.type.template_args[0].GetTypedefedType() self.pair_type_size = self.pair_type.GetByteSize() self.new_layout = not table.GetChildMemberWithName("data").IsValid() diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index cdff37cbd51f4..2588c00f2cffd 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -217,10 +217,13 @@ fn build_external_function(cx: &DocContext<'_>, did: DefId) -> clean::Function { let (generics, decl) = clean::enter_impl_trait(cx, || { ((cx.tcx.generics_of(did), predicates).clean(cx), (did, sig).clean(cx)) }); + let (all_types, ret_types) = clean::get_all_types(&generics, &decl, cx); clean::Function { decl, generics, header: hir::FnHeader { unsafety: sig.unsafety(), abi: sig.abi(), constness, asyncness }, + all_types, + ret_types, } } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 331bb2a73f962..03454bb8b7ff0 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -928,7 +928,8 @@ impl<'a> Clean for (&'a hir::FnSig<'a>, &'a hir::Generics<'a>, hir::Bo fn clean(&self, cx: &DocContext<'_>) -> Function { let (generics, decl) = enter_impl_trait(cx, || (self.1.clean(cx), (&*self.0.decl, self.2).clean(cx))); - Function { decl, generics, header: self.0.header } + let (all_types, ret_types) = get_all_types(&generics, &decl, cx); + Function { decl, generics, header: self.0.header, all_types, ret_types } } } @@ -1042,7 +1043,21 @@ impl Clean for hir::PolyTraitRef<'_> { impl Clean for hir::def::DefKind { fn clean(&self, _: &DocContext<'_>) -> TypeKind { - (*self).into() + match *self { + hir::def::DefKind::Mod => TypeKind::Module, + hir::def::DefKind::Struct => TypeKind::Struct, + hir::def::DefKind::Union => TypeKind::Union, + hir::def::DefKind::Enum => TypeKind::Enum, + hir::def::DefKind::Trait => TypeKind::Trait, + hir::def::DefKind::TyAlias => TypeKind::Typedef, + hir::def::DefKind::ForeignTy => TypeKind::Foreign, + hir::def::DefKind::TraitAlias => TypeKind::TraitAlias, + hir::def::DefKind::Fn => TypeKind::Function, + hir::def::DefKind::Const => TypeKind::Const, + hir::def::DefKind::Static => TypeKind::Static, + hir::def::DefKind::Macro(_) => TypeKind::Macro, + _ => TypeKind::Foreign, + } } } @@ -1067,7 +1082,9 @@ impl Clean for hir::TraitItem<'_> { let (generics, decl) = enter_impl_trait(cx, || { (self.generics.clean(cx), (&*sig.decl, &names[..]).clean(cx)) }); - let mut t = Function { header: sig.header, decl, generics }; + let (all_types, ret_types) = get_all_types(&generics, &decl, cx); + let mut t = + Function { header: sig.header, decl, generics, all_types, ret_types }; if t.header.constness == hir::Constness::Const && is_unstable_const_fn(cx.tcx, local_did).is_some() { @@ -1179,6 +1196,7 @@ impl Clean for ty::AssocItem { ty::ImplContainer(_) => true, ty::TraitContainer(_) => self.defaultness.has_value(), }; + let (all_types, ret_types) = get_all_types(&generics, &decl, cx); if provided { let constness = if is_min_const_fn(cx.tcx, self.def_id) { hir::Constness::Const @@ -1200,6 +1218,8 @@ impl Clean for ty::AssocItem { constness, asyncness, }, + all_types, + ret_types, }, defaultness, ) @@ -1213,6 +1233,8 @@ impl Clean for ty::AssocItem { constness: hir::Constness::NotConst, asyncness: hir::IsAsync::NotAsync, }, + all_types, + ret_types, }) } } @@ -2252,6 +2274,7 @@ impl Clean for (&hir::ForeignItem<'_>, Option) { let (generics, decl) = enter_impl_trait(cx, || { (generics.clean(cx), (&**decl, &names[..]).clean(cx)) }); + let (all_types, ret_types) = get_all_types(&generics, &decl, cx); ForeignFunctionItem(Function { decl, generics, @@ -2261,6 +2284,8 @@ impl Clean for (&hir::ForeignItem<'_>, Option) { constness: hir::Constness::NotConst, asyncness: hir::IsAsync::NotAsync, }, + all_types, + ret_types, }) } hir::ForeignItemKind::Static(ref ty, mutability) => ForeignStaticItem(Static { diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 754f1c2eeeb21..e509ec3f0213f 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -1087,6 +1087,8 @@ crate struct Function { crate decl: FnDecl, crate generics: Generics, crate header: hir::FnHeader, + crate all_types: Vec<(Type, TypeKind)>, + crate ret_types: Vec<(Type, TypeKind)>, } #[derive(Clone, PartialEq, Eq, Debug, Hash)] @@ -1302,43 +1304,6 @@ crate enum TypeKind { Primitive, } -impl From for TypeKind { - fn from(other: hir::def::DefKind) -> Self { - match other { - hir::def::DefKind::Enum => Self::Enum, - hir::def::DefKind::Fn => Self::Function, - hir::def::DefKind::Mod => Self::Module, - hir::def::DefKind::Const => Self::Const, - hir::def::DefKind::Static => Self::Static, - hir::def::DefKind::Struct => Self::Struct, - hir::def::DefKind::Union => Self::Union, - hir::def::DefKind::Trait => Self::Trait, - hir::def::DefKind::TyAlias => Self::Typedef, - hir::def::DefKind::TraitAlias => Self::TraitAlias, - hir::def::DefKind::Macro(_) => Self::Macro, - hir::def::DefKind::ForeignTy - | hir::def::DefKind::Variant - | hir::def::DefKind::AssocTy - | hir::def::DefKind::TyParam - | hir::def::DefKind::ConstParam - | hir::def::DefKind::Ctor(..) - | hir::def::DefKind::AssocFn - | hir::def::DefKind::AssocConst - | hir::def::DefKind::ExternCrate - | hir::def::DefKind::Use - | hir::def::DefKind::ForeignMod - | hir::def::DefKind::AnonConst - | hir::def::DefKind::OpaqueTy - | hir::def::DefKind::Field - | hir::def::DefKind::LifetimeParam - | hir::def::DefKind::GlobalAsm - | hir::def::DefKind::Impl - | hir::def::DefKind::Closure - | hir::def::DefKind::Generator => Self::Foreign, - } - } -} - crate trait GetDefId { /// Use this method to get the [`DefId`] of a [`clean`] AST node. /// This will return [`None`] when called on a primitive [`clean::Type`]. @@ -1402,14 +1367,14 @@ impl Type { } } - crate fn generics(&self) -> Option> { + crate fn generics(&self) -> Option> { match *self { ResolvedPath { ref path, .. } => path.segments.last().and_then(|seg| { if let GenericArgs::AngleBracketed { ref args, .. } = seg.args { Some( args.iter() .filter_map(|arg| match arg { - GenericArg::Type(ty) => Some(ty), + GenericArg::Type(ty) => Some(ty.clone()), _ => None, }) .collect(), diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 2c829c49953ff..e380d4672d055 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -1,9 +1,10 @@ use crate::clean::auto_trait::AutoTraitFinder; use crate::clean::blanket_impl::BlanketImplFinder; use crate::clean::{ - inline, Clean, Crate, ExternalCrate, Generic, GenericArg, GenericArgs, ImportSource, Item, - ItemKind, Lifetime, MacroKind, Path, PathSegment, Primitive, PrimitiveType, ResolvedPath, Type, - TypeBinding, TypeKind, + inline, Clean, Crate, ExternalCrate, FnDecl, FnRetTy, Generic, GenericArg, GenericArgs, + GenericBound, Generics, GetDefId, ImportSource, Item, ItemKind, Lifetime, MacroKind, Path, + PathSegment, Primitive, PrimitiveType, ResolvedPath, Type, TypeBinding, TypeKind, + WherePredicate, }; use crate::core::DocContext; @@ -159,6 +160,125 @@ pub(super) fn external_path( } } +/// The point of this function is to replace bounds with types. +/// +/// i.e. `[T, U]` when you have the following bounds: `T: Display, U: Option` will return +/// `[Display, Option]` (we just returns the list of the types, we don't care about the +/// wrapped types in here). +crate fn get_real_types( + generics: &Generics, + arg: &Type, + cx: &DocContext<'_>, + recurse: i32, +) -> FxHashSet<(Type, TypeKind)> { + fn insert(res: &mut FxHashSet<(Type, TypeKind)>, cx: &DocContext<'_>, ty: Type) { + if let Some(kind) = ty.def_id().map(|did| cx.tcx.def_kind(did).clean(cx)) { + res.insert((ty, kind)); + } else if ty.is_primitive() { + // This is a primitive, let's store it as such. + res.insert((ty, TypeKind::Primitive)); + } + } + let mut res = FxHashSet::default(); + if recurse >= 10 { + // FIXME: remove this whole recurse thing when the recursion bug is fixed + return res; + } + + if arg.is_full_generic() { + let arg_s = Symbol::intern(&arg.print(&cx.cache).to_string()); + if let Some(where_pred) = generics.where_predicates.iter().find(|g| match g { + WherePredicate::BoundPredicate { ty, .. } => ty.def_id() == arg.def_id(), + _ => false, + }) { + let bounds = where_pred.get_bounds().unwrap_or_else(|| &[]); + for bound in bounds.iter() { + if let GenericBound::TraitBound(poly_trait, _) = bound { + for x in poly_trait.generic_params.iter() { + if !x.is_type() { + continue; + } + if let Some(ty) = x.get_type() { + let adds = get_real_types(generics, &ty, cx, recurse + 1); + if !adds.is_empty() { + res.extend(adds); + } else if !ty.is_full_generic() { + insert(&mut res, cx, ty); + } + } + } + } + } + } + if let Some(bound) = generics.params.iter().find(|g| g.is_type() && g.name == arg_s) { + for bound in bound.get_bounds().unwrap_or_else(|| &[]) { + if let Some(ty) = bound.get_trait_type() { + let adds = get_real_types(generics, &ty, cx, recurse + 1); + if !adds.is_empty() { + res.extend(adds); + } else if !ty.is_full_generic() { + insert(&mut res, cx, ty); + } + } + } + } + } else { + insert(&mut res, cx, arg.clone()); + if let Some(gens) = arg.generics() { + for gen in gens.iter() { + if gen.is_full_generic() { + let adds = get_real_types(generics, gen, cx, recurse + 1); + if !adds.is_empty() { + res.extend(adds); + } + } else { + insert(&mut res, cx, gen.clone()); + } + } + } + } + res +} + +/// Return the full list of types when bounds have been resolved. +/// +/// i.e. `fn foo>(x: u32, y: B)` will return +/// `[u32, Display, Option]`. +crate fn get_all_types( + generics: &Generics, + decl: &FnDecl, + cx: &DocContext<'_>, +) -> (Vec<(Type, TypeKind)>, Vec<(Type, TypeKind)>) { + let mut all_types = FxHashSet::default(); + for arg in decl.inputs.values.iter() { + if arg.type_.is_self_type() { + continue; + } + let args = get_real_types(generics, &arg.type_, cx, 0); + if !args.is_empty() { + all_types.extend(args); + } else { + if let Some(kind) = arg.type_.def_id().map(|did| cx.tcx.def_kind(did).clean(cx)) { + all_types.insert((arg.type_.clone(), kind)); + } + } + } + + let ret_types = match decl.output { + FnRetTy::Return(ref return_type) => { + let mut ret = get_real_types(generics, &return_type, cx, 0); + if ret.is_empty() { + if let Some(kind) = return_type.def_id().map(|did| cx.tcx.def_kind(did).clean(cx)) { + ret.insert((return_type.clone(), kind)); + } + } + ret.into_iter().collect() + } + _ => Vec::new(), + }; + (all_types.into_iter().collect(), ret_types) +} + crate fn strip_type(ty: Type) -> Type { match ty { Type::ResolvedPath { path, param_names, did, is_generic } => { diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index a20e9dec33b36..aa18684aea197 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -435,7 +435,7 @@ crate fn create_resolver<'a>( // Before we actually clone it, let's force all the extern'd crates to // actually be loaded, just in case they're only referred to inside - // intra-doc links + // intra-doc-links resolver.borrow_mut().access(|resolver| { sess.time("load_extern_crates", || { for extern_name in &extern_names { diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index eecfd337cdf84..30ff124dac60f 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -296,12 +296,7 @@ fn run_test( } }); if let ErrorOutputType::HumanReadable(kind) = options.error_format { - let (short, color_config) = kind.unzip(); - - if short { - compiler.arg("--error-format").arg("short"); - } - + let (_, color_config) = kind.unzip(); match color_config { ColorConfig::Never => { compiler.arg("--color").arg("never"); diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs index ce1204c7be19c..c506f5a37b15b 100644 --- a/src/librustdoc/formats/cache.rs +++ b/src/librustdoc/formats/cache.rs @@ -5,7 +5,6 @@ use std::path::{Path, PathBuf}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX}; use rustc_middle::middle::privacy::AccessLevels; -use rustc_middle::ty::TyCtxt; use rustc_span::source_map::FileName; use rustc_span::Symbol; @@ -122,21 +121,13 @@ crate struct Cache { crate aliases: BTreeMap>, } -/// This struct is used to wrap the `cache` and `tcx` in order to run `DocFolder`. -struct CacheBuilder<'a, 'tcx> { - cache: &'a mut Cache, - empty_cache: Cache, - tcx: TyCtxt<'tcx>, -} - impl Cache { - crate fn from_krate<'tcx>( + crate fn from_krate( render_info: RenderInfo, document_private: bool, extern_html_root_urls: &BTreeMap, dst: &Path, mut krate: clean::Crate, - tcx: TyCtxt<'tcx>, ) -> (clean::Crate, Cache) { // Crawl the crate to build various caches used for the output let RenderInfo { @@ -203,8 +194,7 @@ impl Cache { cache.stack.push(krate.name.to_string()); - krate = CacheBuilder { tcx, cache: &mut cache, empty_cache: Cache::default() } - .fold_crate(krate); + krate = cache.fold_crate(krate); for (trait_did, dids, impl_) in cache.orphan_trait_impls.drain(..) { if cache.traits.contains_key(&trait_did) { @@ -218,7 +208,7 @@ impl Cache { } } -impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> { +impl DocFolder for Cache { fn fold_item(&mut self, item: clean::Item) -> Option { if item.def_id.is_local() { debug!("folding {} \"{:?}\", id {:?}", item.type_(), item.name, item.def_id); @@ -228,17 +218,17 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> { // we don't want it or its children in the search index. let orig_stripped_mod = match *item.kind { clean::StrippedItem(box clean::ModuleItem(..)) => { - mem::replace(&mut self.cache.stripped_mod, true) + mem::replace(&mut self.stripped_mod, true) } - _ => self.cache.stripped_mod, + _ => self.stripped_mod, }; // If the impl is from a masked crate or references something from a // masked crate then remove it completely. if let clean::ImplItem(ref i) = *item.kind { - if self.cache.masked_crates.contains(&item.def_id.krate) - || i.trait_.def_id().map_or(false, |d| self.cache.masked_crates.contains(&d.krate)) - || i.for_.def_id().map_or(false, |d| self.cache.masked_crates.contains(&d.krate)) + if self.masked_crates.contains(&item.def_id.krate) + || i.trait_.def_id().map_or(false, |d| self.masked_crates.contains(&d.krate)) + || i.for_.def_id().map_or(false, |d| self.masked_crates.contains(&d.krate)) { return None; } @@ -247,15 +237,14 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> { // Propagate a trait method's documentation to all implementors of the // trait. if let clean::TraitItem(ref t) = *item.kind { - self.cache.traits.entry(item.def_id).or_insert_with(|| t.clone()); + self.traits.entry(item.def_id).or_insert_with(|| t.clone()); } // Collect all the implementors of traits. if let clean::ImplItem(ref i) = *item.kind { if let Some(did) = i.trait_.def_id() { if i.blanket_impl.is_none() { - self.cache - .implementors + self.implementors .entry(did) .or_default() .push(Impl { impl_item: item.clone() }); @@ -268,7 +257,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> { let (parent, is_inherent_impl_item) = match *item.kind { clean::StrippedItem(..) => ((None, None), false), clean::AssocConstItem(..) | clean::TypedefItem(_, true) - if self.cache.parent_is_trait_impl => + if self.parent_is_trait_impl => { // skip associated items in trait impls ((None, None), false) @@ -278,18 +267,18 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> { | clean::StructFieldItem(..) | clean::VariantItem(..) => ( ( - Some(*self.cache.parent_stack.last().expect("parent_stack is empty")), - Some(&self.cache.stack[..self.cache.stack.len() - 1]), + Some(*self.parent_stack.last().expect("parent_stack is empty")), + Some(&self.stack[..self.stack.len() - 1]), ), false, ), clean::MethodItem(..) | clean::AssocConstItem(..) => { - if self.cache.parent_stack.is_empty() { + if self.parent_stack.is_empty() { ((None, None), false) } else { - let last = self.cache.parent_stack.last().expect("parent_stack is empty 2"); + let last = self.parent_stack.last().expect("parent_stack is empty 2"); let did = *last; - let path = match self.cache.paths.get(&did) { + let path = match self.paths.get(&did) { // The current stack not necessarily has correlation // for where the type was defined. On the other // hand, `paths` always has the right @@ -301,24 +290,24 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> { | ItemType::Union | ItemType::Enum, )) => Some(&fqp[..fqp.len() - 1]), - Some(..) => Some(&*self.cache.stack), + Some(..) => Some(&*self.stack), None => None, }; ((Some(*last), path), true) } } - _ => ((None, Some(&*self.cache.stack)), false), + _ => ((None, Some(&*self.stack)), false), }; match parent { - (parent, Some(path)) if is_inherent_impl_item || !self.cache.stripped_mod => { + (parent, Some(path)) if is_inherent_impl_item || !self.stripped_mod => { debug_assert!(!item.is_stripped()); // A crate has a module at its root, containing all items, // which should not be indexed. The crate-item itself is // inserted later on when serializing the search-index. if item.def_id.index != CRATE_DEF_INDEX { - self.cache.search_index.push(IndexItem { + self.search_index.push(IndexItem { ty: item.type_(), name: s.to_string(), path: path.join("::"), @@ -327,22 +316,21 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> { .map_or_else(String::new, |x| short_markdown_summary(&x.as_str())), parent, parent_idx: None, - search_type: get_index_search_type(&item, &self.empty_cache, self.tcx), + search_type: get_index_search_type(&item, None), }); for alias in item.attrs.get_doc_aliases() { - self.cache - .aliases + self.aliases .entry(alias.to_lowercase()) .or_insert(Vec::new()) - .push(self.cache.search_index.len() - 1); + .push(self.search_index.len() - 1); } } } (Some(parent), None) if is_inherent_impl_item => { // We have a parent, but we don't know where they're // defined yet. Wait for later to index this item. - self.cache.orphan_impl_items.push((parent, item.clone())); + self.orphan_impl_items.push((parent, item.clone())); } _ => {} } @@ -351,7 +339,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> { // Keep track of the fully qualified path for this item. let pushed = match item.name { Some(n) if !n.is_empty() => { - self.cache.stack.push(n.to_string()); + self.stack.push(n.to_string()); true } _ => false, @@ -373,7 +361,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> { | clean::MacroItem(..) | clean::ProcMacroItem(..) | clean::VariantItem(..) - if !self.cache.stripped_mod => + if !self.stripped_mod => { // Re-exported items mean that the same id can show up twice // in the rustdoc ast that we're looking at. We know, @@ -381,21 +369,21 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> { // `public_items` map, so we can skip inserting into the // paths map if there was already an entry present and we're // not a public item. - if !self.cache.paths.contains_key(&item.def_id) - || self.cache.access_levels.is_public(item.def_id) + if !self.paths.contains_key(&item.def_id) + || self.access_levels.is_public(item.def_id) { - self.cache.paths.insert(item.def_id, (self.cache.stack.clone(), item.type_())); + self.paths.insert(item.def_id, (self.stack.clone(), item.type_())); } } clean::PrimitiveItem(..) => { - self.cache.paths.insert(item.def_id, (self.cache.stack.clone(), item.type_())); + self.paths.insert(item.def_id, (self.stack.clone(), item.type_())); } _ => {} } // Maintain the parent stack - let orig_parent_is_trait_impl = self.cache.parent_is_trait_impl; + let orig_parent_is_trait_impl = self.parent_is_trait_impl; let parent_pushed = match *item.kind { clean::TraitItem(..) | clean::EnumItem(..) @@ -403,24 +391,24 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> { | clean::StructItem(..) | clean::UnionItem(..) | clean::VariantItem(..) => { - self.cache.parent_stack.push(item.def_id); - self.cache.parent_is_trait_impl = false; + self.parent_stack.push(item.def_id); + self.parent_is_trait_impl = false; true } clean::ImplItem(ref i) => { - self.cache.parent_is_trait_impl = i.trait_.is_some(); + self.parent_is_trait_impl = i.trait_.is_some(); match i.for_ { clean::ResolvedPath { did, .. } => { - self.cache.parent_stack.push(did); + self.parent_stack.push(did); true } ref t => { let prim_did = t .primitive_type() - .and_then(|t| self.cache.primitive_locations.get(&t).cloned()); + .and_then(|t| self.primitive_locations.get(&t).cloned()); match prim_did { Some(did) => { - self.cache.parent_stack.push(did); + self.parent_stack.push(did); true } None => false, @@ -445,9 +433,8 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> { dids.insert(did); } ref t => { - let did = t - .primitive_type() - .and_then(|t| self.cache.primitive_locations.get(&t).cloned()); + let did = + t.primitive_type().and_then(|t| self.primitive_locations.get(&t).cloned()); if let Some(did) = did { dids.insert(did); @@ -463,13 +450,13 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> { } } let impl_item = Impl { impl_item: item }; - if impl_item.trait_did().map_or(true, |d| self.cache.traits.contains_key(&d)) { + if impl_item.trait_did().map_or(true, |d| self.traits.contains_key(&d)) { for did in dids { - self.cache.impls.entry(did).or_insert(vec![]).push(impl_item.clone()); + self.impls.entry(did).or_insert(vec![]).push(impl_item.clone()); } } else { let trait_did = impl_item.trait_did().expect("no trait did"); - self.cache.orphan_trait_impls.push((trait_did, dids, impl_item)); + self.orphan_trait_impls.push((trait_did, dids, impl_item)); } None } else { @@ -477,13 +464,13 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> { }; if pushed { - self.cache.stack.pop().expect("stack already empty"); + self.stack.pop().expect("stack already empty"); } if parent_pushed { - self.cache.parent_stack.pop().expect("parent stack already empty"); + self.parent_stack.pop().expect("parent stack already empty"); } - self.cache.stripped_mod = orig_stripped_mod; - self.cache.parent_is_trait_impl = orig_parent_is_trait_impl; + self.stripped_mod = orig_stripped_mod; + self.parent_is_trait_impl = orig_parent_is_trait_impl; ret } } diff --git a/src/librustdoc/formats/renderer.rs b/src/librustdoc/formats/renderer.rs index 6437ba45511a1..6ecc4695dc8fb 100644 --- a/src/librustdoc/formats/renderer.rs +++ b/src/librustdoc/formats/renderer.rs @@ -61,7 +61,6 @@ crate fn run_format<'tcx, T: FormatRenderer<'tcx>>( &options.extern_html_root_urls, &options.output, krate, - tcx, ) }); let prof = &tcx.sess.prof; diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index bea0e75832c33..74b61f1555c6f 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -102,6 +102,14 @@ impl Buffer { self.into_inner() } + crate fn from_display(&mut self, t: T) { + if self.for_html { + write!(self, "{}", t); + } else { + write!(self, "{:#}", t); + } + } + crate fn is_for_html(&self) -> bool { self.for_html } @@ -892,7 +900,16 @@ impl clean::Type { } impl clean::Impl { - crate fn print<'a>(&'a self, cache: &'a Cache, use_absolute: bool) -> impl fmt::Display + 'a { + crate fn print<'a>(&'a self, cache: &'a Cache) -> impl fmt::Display + 'a { + self.print_inner(true, false, cache) + } + + fn print_inner<'a>( + &'a self, + link_trait: bool, + use_absolute: bool, + cache: &'a Cache, + ) -> impl fmt::Display + 'a { display_fn(move |f| { if f.alternate() { write!(f, "impl{:#} ", self.generics.print(cache))?; @@ -904,7 +921,21 @@ impl clean::Impl { if self.negative_polarity { write!(f, "!")?; } - fmt::Display::fmt(&ty.print(cache), f)?; + + if link_trait { + fmt::Display::fmt(&ty.print(cache), f)?; + } else { + match ty { + clean::ResolvedPath { + param_names: None, path, is_generic: false, .. + } => { + let last = path.segments.last().unwrap(); + fmt::Display::fmt(&last.name, f)?; + fmt::Display::fmt(&last.args.print(cache), f)?; + } + _ => unreachable!(), + } + } write!(f, " for ")?; } @@ -921,6 +952,16 @@ impl clean::Impl { } } +// The difference from above is that trait is not hyperlinked. +crate fn fmt_impl_for_trait_page( + i: &clean::Impl, + f: &mut Buffer, + use_absolute: bool, + cache: &Cache, +) { + f.from_display(i.print_inner(false, use_absolute, cache)) +} + impl clean::Arguments { crate fn print<'a>(&'a self, cache: &'a Cache) -> impl fmt::Display + 'a { display_fn(move |f| { @@ -1290,16 +1331,16 @@ impl clean::GenericArg { } crate fn display_fn(f: impl FnOnce(&mut fmt::Formatter<'_>) -> fmt::Result) -> impl fmt::Display { - struct WithFormatter(Cell>); - - impl fmt::Display for WithFormatter - where - F: FnOnce(&mut fmt::Formatter<'_>) -> fmt::Result, - { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - (self.0.take()).unwrap()(f) - } - } - WithFormatter(Cell::new(Some(f))) } + +struct WithFormatter(Cell>); + +impl fmt::Display for WithFormatter +where + F: FnOnce(&mut fmt::Formatter<'_>) -> fmt::Result, +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + (self.0.take()).unwrap()(f) + } +} diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index a81fd55f6f192..bdb92844f07ad 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -48,10 +48,7 @@ mod tests; /// Options for rendering Markdown in the main body of documentation. pub(crate) fn opts() -> Options { - Options::ENABLE_TABLES - | Options::ENABLE_FOOTNOTES - | Options::ENABLE_STRIKETHROUGH - | Options::ENABLE_TASKLISTS + Options::ENABLE_TABLES | Options::ENABLE_FOOTNOTES | Options::ENABLE_STRIKETHROUGH } /// A subset of [`opts()`] used for rendering summaries. diff --git a/src/librustdoc/html/mod.rs b/src/librustdoc/html/mod.rs index 4318be898ceb4..403a9303c3ff0 100644 --- a/src/librustdoc/html/mod.rs +++ b/src/librustdoc/html/mod.rs @@ -2,7 +2,6 @@ crate mod escape; crate mod format; crate mod highlight; crate mod layout; -// used by the error-index generator, so it needs to be public pub mod markdown; crate mod render; crate mod sources; diff --git a/src/librustdoc/html/render/cache.rs b/src/librustdoc/html/render/cache.rs index a21cf5266fe1f..74a770b954853 100644 --- a/src/librustdoc/html/render/cache.rs +++ b/src/librustdoc/html/render/cache.rs @@ -1,14 +1,11 @@ use std::collections::BTreeMap; use std::path::Path; -use rustc_data_structures::fx::{FxHashMap, FxHashSet}; -use rustc_middle::ty::TyCtxt; +use rustc_data_structures::fx::FxHashMap; use rustc_span::symbol::{sym, Symbol}; use serde::Serialize; -use crate::clean::types::{ - FnDecl, FnRetTy, GenericBound, Generics, GetDefId, Type, TypeKind, WherePredicate, -}; +use crate::clean::types::GetDefId; use crate::clean::{self, AttributesExt}; use crate::formats::cache::Cache; use crate::formats::item_type::ItemType; @@ -65,7 +62,7 @@ crate fn extern_location( } /// Builds the search index from the collected metadata -crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt<'tcx>) -> String { +crate fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String { let mut defid_to_pathid = FxHashMap::default(); let mut crate_items = Vec::with_capacity(cache.search_index.len()); let mut crate_paths = vec![]; @@ -81,7 +78,7 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt< desc: item.doc_value().map_or_else(String::new, |s| short_markdown_summary(&s)), parent: Some(did), parent_idx: None, - search_type: get_index_search_type(&item, cache, tcx), + search_type: get_index_search_type(&item, Some(cache)), }); for alias in item.attrs.get_doc_aliases() { cache @@ -167,15 +164,14 @@ crate fn build_index<'tcx>(krate: &clean::Crate, cache: &mut Cache, tcx: TyCtxt< ) } -crate fn get_index_search_type<'tcx>( +crate fn get_index_search_type( item: &clean::Item, - cache: &Cache, - tcx: TyCtxt<'tcx>, + cache: Option<&Cache>, ) -> Option { let (all_types, ret_types) = match *item.kind { - clean::FunctionItem(ref f) => get_all_types(&f.generics, &f.decl, tcx), - clean::MethodItem(ref m, _) => get_all_types(&m.generics, &m.decl, tcx), - clean::TyMethodItem(ref m) => get_all_types(&m.generics, &m.decl, tcx), + clean::FunctionItem(ref f) => (&f.all_types, &f.ret_types), + clean::MethodItem(ref m, _) => (&m.all_types, &m.ret_types), + clean::TyMethodItem(ref m) => (&m.all_types, &m.ret_types), _ => return None, }; @@ -194,9 +190,9 @@ crate fn get_index_search_type<'tcx>( Some(IndexItemFunctionType { inputs, output }) } -fn get_index_type(clean_type: &clean::Type, cache: &Cache) -> RenderType { +fn get_index_type(clean_type: &clean::Type, cache: &Option<&Cache>) -> RenderType { RenderType { - ty: clean_type.def_id_full(cache), + ty: cache.map_or_else(|| clean_type.def_id(), |cache| clean_type.def_id_full(cache)), idx: None, name: get_index_type_name(clean_type, true).map(|s| s.as_str().to_ascii_lowercase()), generics: get_generics(clean_type, cache), @@ -218,27 +214,19 @@ fn get_index_type_name(clean_type: &clean::Type, accept_generic: bool) -> Option clean::Generic(s) if accept_generic => Some(s), clean::Primitive(ref p) => Some(p.as_sym()), clean::BorrowedRef { ref type_, .. } => get_index_type_name(type_, accept_generic), - clean::Generic(_) - | clean::BareFunction(_) - | clean::Tuple(_) - | clean::Slice(_) - | clean::Array(_, _) - | clean::Never - | clean::RawPointer(_, _) - | clean::QPath { .. } - | clean::Infer - | clean::ImplTrait(_) => None, + // FIXME: add all from clean::Type. + _ => None, } } -fn get_generics(clean_type: &clean::Type, cache: &Cache) -> Option> { +fn get_generics(clean_type: &clean::Type, cache: &Option<&Cache>) -> Option> { clean_type.generics().and_then(|types| { let r = types .iter() .filter_map(|t| { get_index_type_name(t, false).map(|name| Generic { name: name.as_str().to_ascii_lowercase(), - defid: t.def_id_full(cache), + defid: cache.map_or_else(|| t.def_id(), |cache| t.def_id_full(cache)), idx: None, }) }) @@ -246,124 +234,3 @@ fn get_generics(clean_type: &clean::Type, cache: &Cache) -> Option> if r.is_empty() { None } else { Some(r) } }) } - -/// The point of this function is to replace bounds with types. -/// -/// i.e. `[T, U]` when you have the following bounds: `T: Display, U: Option` will return -/// `[Display, Option]` (we just returns the list of the types, we don't care about the -/// wrapped types in here). -crate fn get_real_types<'tcx>( - generics: &Generics, - arg: &Type, - tcx: TyCtxt<'tcx>, - recurse: i32, - res: &mut FxHashSet<(Type, TypeKind)>, -) -> usize { - fn insert(res: &mut FxHashSet<(Type, TypeKind)>, tcx: TyCtxt<'_>, ty: Type) -> usize { - if let Some(kind) = ty.def_id().map(|did| tcx.def_kind(did).into()) { - res.insert((ty, kind)); - 1 - } else if ty.is_primitive() { - // This is a primitive, let's store it as such. - res.insert((ty, TypeKind::Primitive)); - 1 - } else { - 0 - } - } - - if recurse >= 10 { - // FIXME: remove this whole recurse thing when the recursion bug is fixed - return 0; - } - let mut nb_added = 0; - - if let &Type::Generic(arg_s) = arg { - if let Some(where_pred) = generics.where_predicates.iter().find(|g| match g { - WherePredicate::BoundPredicate { ty, .. } => ty.def_id() == arg.def_id(), - _ => false, - }) { - let bounds = where_pred.get_bounds().unwrap_or_else(|| &[]); - for bound in bounds.iter() { - if let GenericBound::TraitBound(poly_trait, _) = bound { - for x in poly_trait.generic_params.iter() { - if !x.is_type() { - continue; - } - if let Some(ty) = x.get_type() { - let adds = get_real_types(generics, &ty, tcx, recurse + 1, res); - nb_added += adds; - if adds == 0 && !ty.is_full_generic() { - nb_added += insert(res, tcx, ty); - } - } - } - } - } - } - if let Some(bound) = generics.params.iter().find(|g| g.is_type() && g.name == arg_s) { - for bound in bound.get_bounds().unwrap_or(&[]) { - if let Some(ty) = bound.get_trait_type() { - let adds = get_real_types(generics, &ty, tcx, recurse + 1, res); - nb_added += adds; - if adds == 0 && !ty.is_full_generic() { - nb_added += insert(res, tcx, ty); - } - } - } - } - } else { - nb_added += insert(res, tcx, arg.clone()); - if let Some(gens) = arg.generics() { - for gen in gens.iter() { - if gen.is_full_generic() { - nb_added += get_real_types(generics, gen, tcx, recurse + 1, res); - } else { - nb_added += insert(res, tcx, (*gen).clone()); - } - } - } - } - nb_added -} - -/// Return the full list of types when bounds have been resolved. -/// -/// i.e. `fn foo>(x: u32, y: B)` will return -/// `[u32, Display, Option]`. -crate fn get_all_types<'tcx>( - generics: &Generics, - decl: &FnDecl, - tcx: TyCtxt<'tcx>, -) -> (Vec<(Type, TypeKind)>, Vec<(Type, TypeKind)>) { - let mut all_types = FxHashSet::default(); - for arg in decl.inputs.values.iter() { - if arg.type_.is_self_type() { - continue; - } - let mut args = FxHashSet::default(); - get_real_types(generics, &arg.type_, tcx, 0, &mut args); - if !args.is_empty() { - all_types.extend(args); - } else { - if let Some(kind) = arg.type_.def_id().map(|did| tcx.def_kind(did).into()) { - all_types.insert((arg.type_.clone(), kind)); - } - } - } - - let ret_types = match decl.output { - FnRetTy::Return(ref return_type) => { - let mut ret = FxHashSet::default(); - get_real_types(generics, &return_type, tcx, 0, &mut ret); - if ret.is_empty() { - if let Some(kind) = return_type.def_id().map(|did| tcx.def_kind(did).into()) { - ret.insert((return_type.clone(), kind)); - } - } - ret.into_iter().collect() - } - _ => Vec::new(), - }; - (all_types.into_iter().collect(), ret_types) -} diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 914ad35e7a488..6909ab870db61 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -73,6 +73,7 @@ use crate::formats::cache::Cache; use crate::formats::item_type::ItemType; use crate::formats::{AssocItemRender, FormatRenderer, Impl, RenderMode}; use crate::html::escape::Escape; +use crate::html::format::fmt_impl_for_trait_page; use crate::html::format::Function; use crate::html::format::{href, print_default_space, print_generic_bounds, WhereClause}; use crate::html::format::{print_abi_with_space, Buffer, PrintWithSpace}; @@ -498,7 +499,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> { krate = sources::render(&dst, &mut scx, krate)?; // Build our search index - let index = build_index(&krate, &mut cache, tcx); + let index = build_index(&krate, &mut cache); let mut cx = Context { current: Vec::new(), @@ -1137,7 +1138,7 @@ themePicker.onblur = handleThemeButtonsBlur; None } else { Some(Implementor { - text: imp.inner_impl().print(cx.cache(), false).to_string(), + text: imp.inner_impl().print(cx.cache()).to_string(), synthetic: imp.inner_impl().synthetic, types: collect_paths_for_type(imp.inner_impl().for_.clone(), cx.cache()), }) @@ -2549,8 +2550,8 @@ fn bounds(t_bounds: &[clean::GenericBound], trait_alias: bool, cache: &Cache) -> } fn compare_impl<'a, 'b>(lhs: &'a &&Impl, rhs: &'b &&Impl, cache: &Cache) -> Ordering { - let lhs = format!("{}", lhs.inner_impl().print(cache, false)); - let rhs = format!("{}", rhs.inner_impl().print(cache, false)); + let lhs = format!("{}", lhs.inner_impl().print(cache)); + let rhs = format!("{}", rhs.inner_impl().print(cache)); // lhs and rhs are formatted as HTML, which may be unnecessary compare_names(&lhs, &rhs) @@ -3697,7 +3698,7 @@ fn spotlight_decl(decl: &clean::FnDecl, cache: &Cache) -> String { write!( &mut out, "{}", - impl_.print(cache, false) + impl_.print(cache) ); let t_did = impl_.trait_.def_id_full(cache).unwrap(); for it in &impl_.items { @@ -3770,7 +3771,7 @@ fn render_impl( }; if let Some(use_absolute) = use_absolute { write!(w, "

", id, aliases); - write!(w, "{}", i.inner_impl().print(cx.cache(), use_absolute)); + fmt_impl_for_trait_page(&i.inner_impl(), w, use_absolute, cx.cache()); if show_def_docs { for it in &i.inner_impl().items { if let clean::TypedefItem(ref tydef, _) = *it.kind { @@ -3795,7 +3796,7 @@ fn render_impl( "

{}", id, aliases, - i.inner_impl().print(cx.cache(), false) + i.inner_impl().print(cx.cache()) ); } write!(w, "", id); diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index ec89ae0228c5e..4dbe7a37fcdc8 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -2910,7 +2910,7 @@ function defocusSearchBar() { ["-", "Collapse all sections"], ].map(x => "
" + x[0].split(" ") - .map((y, index) => (index & 1) === 0 ? "" + y + "" : " " + y + " ") + .map((y, index) => (index & 1) === 0 ? "" + y + "" : y) .join("") + "
" + x[1] + "
").join(""); var div_shortcuts = document.createElement("div"); addClass(div_shortcuts, "shortcuts"); diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 56f17b7a616cd..d50fda278bd7c 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -798,7 +798,6 @@ body.blur > :not(#help) { float: left; clear: left; display: block; - margin-right: 0.5rem; } #help > div > span { text-align: center; @@ -1491,14 +1490,6 @@ h4 > .notable-traits { background-color: rgba(0,0,0,0); height: 100%; } - /* - This allows to prevent the version text to overflow the sidebar title on mobile mode when the - sidebar is displayed (after clicking on the "hamburger" button). - */ - .sidebar.mobile > div.version { - overflow: hidden; - max-height: 33px; - } .sidebar { width: calc(100% + 30px); } diff --git a/src/librustdoc/html/static/themes/dark.css b/src/librustdoc/html/static/themes/dark.css index 9eeccd038a2ff..8c7794479a70a 100644 --- a/src/librustdoc/html/static/themes/dark.css +++ b/src/librustdoc/html/static/themes/dark.css @@ -239,6 +239,7 @@ a.test-arrow { #help dt { border-color: #bfbfbf; background: rgba(0,0,0,0); + color: black; } .since { diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index e021faa50412e..b2e5c8834b8ff 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -154,7 +154,7 @@ impl From for ItemEnum { } ImportItem(i) => ItemEnum::ImportItem(i.into()), StructItem(s) => ItemEnum::StructItem(s.into()), - UnionItem(u) => ItemEnum::UnionItem(u.into()), + UnionItem(u) => ItemEnum::StructItem(u.into()), StructFieldItem(f) => ItemEnum::StructFieldItem(f.into()), EnumItem(e) => ItemEnum::EnumItem(e.into()), VariantItem(v) => ItemEnum::VariantItem(v.into()), @@ -162,8 +162,8 @@ impl From for ItemEnum { ForeignFunctionItem(f) => ItemEnum::FunctionItem(f.into()), TraitItem(t) => ItemEnum::TraitItem(t.into()), TraitAliasItem(t) => ItemEnum::TraitAliasItem(t.into()), - MethodItem(m, _) => ItemEnum::MethodItem(from_function_method(m, true)), - TyMethodItem(m) => ItemEnum::MethodItem(from_function_method(m, false)), + MethodItem(m, _) => ItemEnum::MethodItem(m.into()), + TyMethodItem(m) => ItemEnum::MethodItem(m.into()), ImplItem(i) => ItemEnum::ImplItem(i.into()), StaticItem(s) => ItemEnum::StaticItem(s.into()), ForeignStaticItem(s) => ItemEnum::StaticItem(s.into()), @@ -205,10 +205,11 @@ impl From for Struct { } } -impl From for Union { +impl From for Struct { fn from(struct_: clean::Union) -> Self { let clean::Union { generics, fields, fields_stripped } = struct_; - Union { + Struct { + struct_type: StructType::Union, generics: generics.into(), fields_stripped, fields: ids(fields), @@ -238,7 +239,7 @@ fn stringify_header(header: &rustc_hir::FnHeader) -> String { impl From for Function { fn from(function: clean::Function) -> Self { - let clean::Function { decl, generics, header } = function; + let clean::Function { decl, generics, header, all_types: _, ret_types: _ } = function; Function { decl: decl.into(), generics: generics.into(), @@ -434,14 +435,15 @@ impl From for Impl { } } -crate fn from_function_method(function: clean::Function, has_body: bool) -> Method { - let clean::Function { header, decl, generics } = function; - Method { - decl: decl.into(), - generics: generics.into(), - header: stringify_header(&header), - abi: header.abi.to_string(), - has_body, +impl From for Method { + fn from(function: clean::Function) -> Self { + let clean::Function { header, decl, generics, all_types: _, ret_types: _ } = function; + Method { + decl: decl.into(), + generics: generics.into(), + header: stringify_header(&header), + has_body: true, + } } } diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index 876b1b56dee6d..a7c875fb7480b 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -243,7 +243,7 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { ) }) .collect(), - format_version: 3, + format_version: 2, }; let mut p = self.out_path.clone(); p.push(output.index.get(&output.root).unwrap().name.clone().unwrap()); diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 18bc275572ff0..e98cb237635fe 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -9,6 +9,7 @@ #![feature(in_band_lifetimes)] #![feature(nll)] #![feature(or_patterns)] +#![feature(peekable_next_if)] #![feature(test)] #![feature(crate_visibility_modifier)] #![feature(never_type)] @@ -82,8 +83,7 @@ mod doctree; mod error; mod doctest; mod fold; -mod formats; -// used by the error-index generator, so it needs to be public +crate mod formats; pub mod html; mod json; mod markdown; diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 532a0cf932904..002d8938f694d 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -44,7 +44,7 @@ use super::span_of_attrs; crate const COLLECT_INTRA_DOC_LINKS: Pass = Pass { name: "collect-intra-doc-links", run: collect_intra_doc_links, - description: "resolves intra-doc links", + description: "reads a crate's documentation to resolve intra-doc-links", }; crate fn collect_intra_doc_links(krate: Crate, cx: &DocContext<'_>) -> Crate { @@ -981,7 +981,7 @@ impl LinkCollector<'_, '_> { let link_text = disambiguator.map(|d| d.display_for(path_str)).unwrap_or_else(|| path_str.to_owned()); - // In order to correctly resolve intra-doc links we need to + // In order to correctly resolve intra-doc-links we need to // pick a base AST node to work from. If the documentation for // this module came from an inner comment (//!) then we anchor // our name resolution *inside* the module. If, on the other diff --git a/src/librustdoc/passes/doc_test_lints.rs b/src/librustdoc/passes/doc_test_lints.rs index 11f572560d606..a513c2abc8747 100644 --- a/src/librustdoc/passes/doc_test_lints.rs +++ b/src/librustdoc/passes/doc_test_lints.rs @@ -1,7 +1,7 @@ //! This pass is overloaded and runs two different lints. //! -//! - MISSING_DOC_CODE_EXAMPLES: this lint is **UNSTABLE** and looks for public items missing doctests -//! - PRIVATE_DOC_TESTS: this lint is **STABLE** and looks for private items with doctests. +//! - MISSING_DOC_CODE_EXAMPLES: this lint is **UNSTABLE** and looks for public items missing doc-tests +//! - PRIVATE_DOC_TESTS: this lint is **STABLE** and looks for private items with doc-tests. use super::{span_of_attrs, Pass}; use crate::clean; diff --git a/src/librustdoc/passes/non_autolinks.rs b/src/librustdoc/passes/non_autolinks.rs index efb5df08cafdb..1f411b997f802 100644 --- a/src/librustdoc/passes/non_autolinks.rs +++ b/src/librustdoc/passes/non_autolinks.rs @@ -12,7 +12,7 @@ use rustc_session::lint; crate const CHECK_NON_AUTOLINKS: Pass = Pass { name: "check-non-autolinks", run: check_non_autolinks, - description: "detects URLs that could be linkified", + description: "detects URLS that could be written using angle brackets", }; const URL_REGEX: &str = concat!( diff --git a/src/librustdoc/passes/strip_hidden.rs b/src/librustdoc/passes/strip_hidden.rs index 79f8562c4726d..a276b7a63371b 100644 --- a/src/librustdoc/passes/strip_hidden.rs +++ b/src/librustdoc/passes/strip_hidden.rs @@ -11,7 +11,7 @@ use crate::passes::{ImplStripper, Pass}; crate const STRIP_HIDDEN: Pass = Pass { name: "strip-hidden", run: strip_hidden, - description: "strips all `#[doc(hidden)]` items from the output", + description: "strips all doc(hidden) items from the output", }; /// Strip items marked `#[doc(hidden)]` diff --git a/src/llvm-project b/src/llvm-project index 70d09f218d1c8..f9a8d70b6e036 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 70d09f218d1c84fedabdb74881e214dacd5b0c3d +Subproject commit f9a8d70b6e0365ac2172ca6b7f1de0341297458d diff --git a/src/rustdoc-json-types/lib.rs b/src/rustdoc-json-types/lib.rs index 297fc95006b02..3fb2a32d5a0a3 100644 --- a/src/rustdoc-json-types/lib.rs +++ b/src/rustdoc-json-types/lib.rs @@ -96,8 +96,8 @@ pub struct Deprecation { pub note: Option, } -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "snake_case")] +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub enum Visibility { Public, /// For the most part items are private by default. The exceptions are associated items of @@ -112,8 +112,8 @@ pub enum Visibility { }, } -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "snake_case")] +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub enum GenericArgs { /// <'a, 32, B: Copy, C = u32> AngleBracketed { args: Vec, bindings: Vec }, @@ -121,8 +121,8 @@ pub enum GenericArgs { Parenthesized { inputs: Vec, output: Option }, } -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "snake_case")] +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub enum GenericArg { Lifetime(String), Type(Type), @@ -144,8 +144,8 @@ pub struct TypeBinding { pub binding: TypeBindingKind, } -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "snake_case")] +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub enum TypeBindingKind { Equality(Type), Constraint(Vec), @@ -154,8 +154,8 @@ pub enum TypeBindingKind { #[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct Id(pub String); -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "snake_case")] +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub enum ItemKind { Module, ExternCrate, @@ -184,8 +184,8 @@ pub enum ItemKind { Keyword, } -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[serde(untagged)] +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub enum ItemEnum { ModuleItem(Module), ExternCrateItem { @@ -194,7 +194,6 @@ pub enum ItemEnum { }, ImportItem(Import), - UnionItem(Union), StructItem(Struct), StructFieldItem(Type), EnumItem(Enum), @@ -239,14 +238,6 @@ pub struct Module { pub items: Vec, } -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] -pub struct Union { - pub generics: Generics, - pub fields_stripped: bool, - pub fields: Vec, - pub impls: Vec, -} - #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct Struct { pub struct_type: StructType, @@ -264,21 +255,22 @@ pub struct Enum { pub impls: Vec, } -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "snake_case")] #[serde(tag = "variant_kind", content = "variant_inner")] +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub enum Variant { Plain, Tuple(Vec), Struct(Vec), } -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "snake_case")] +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub enum StructType { Plain, Tuple, Unit, + Union, } #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] @@ -294,7 +286,6 @@ pub struct Method { pub decl: FnDecl, pub generics: Generics, pub header: String, - pub abi: String, pub has_body: bool, } @@ -310,24 +301,24 @@ pub struct GenericParamDef { pub kind: GenericParamDefKind, } -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "snake_case")] +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub enum GenericParamDefKind { Lifetime, Type { bounds: Vec, default: Option }, Const(Type), } -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "snake_case")] +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub enum WherePredicate { BoundPredicate { ty: Type, bounds: Vec }, RegionPredicate { lifetime: String, bounds: Vec }, EqPredicate { lhs: Type, rhs: Type }, } -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "snake_case")] +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub enum GenericBound { TraitBound { #[serde(rename = "trait")] @@ -339,17 +330,17 @@ pub enum GenericBound { Outlives(String), } -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "snake_case")] +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub enum TraitBoundModifier { None, Maybe, MaybeConst, } -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "snake_case")] #[serde(tag = "kind", content = "inner")] +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub enum Type { /// Structs, enums, and traits ResolvedPath { @@ -448,8 +439,8 @@ pub struct Impl { pub blanket_impl: Option, } -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "snake_case")] +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct Import { /// The full path being imported. pub span: String, @@ -468,8 +459,8 @@ pub struct ProcMacro { pub helpers: Vec, } -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "snake_case")] +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub enum MacroKind { /// A bang macro `foo!()`. Bang, diff --git a/src/stage0.txt b/src/stage0.txt index d3c76eb282a7e..e853b9b4e4191 100644 --- a/src/stage0.txt +++ b/src/stage0.txt @@ -19,7 +19,7 @@ rustc: beta # bootstrapping issues with use of new syntax in this repo. If you're looking at # the beta/stable branch, this key should be omitted, as we don't want to depend # on rustfmt from nightly there. -rustfmt: nightly-2021-01-28 +rustfmt: nightly-2020-11-19 # When making a stable release the process currently looks like: # diff --git a/src/test/codegen/asm-sanitize-llvm.rs b/src/test/codegen/asm-sanitize-llvm.rs deleted file mode 100644 index fe09caa697309..0000000000000 --- a/src/test/codegen/asm-sanitize-llvm.rs +++ /dev/null @@ -1,32 +0,0 @@ -// FIXME(nagisa): remove the flags here once all targets support `asm!`. -// compile-flags: --target x86_64-unknown-linux-gnu - -// Verify we sanitize the special tokens for the LLVM inline-assembly, ensuring people won't -// inadvertently rely on the LLVM-specific syntax and features. -#![no_core] -#![feature(no_core, lang_items, rustc_attrs)] -#![crate_type = "rlib"] - -#[rustc_builtin_macro] -macro_rules! asm { - () => {}; -} - -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} - -pub unsafe fn we_escape_dollar_signs() { - // CHECK: call void asm sideeffect alignstack inteldialect "banana$$:" - asm!( - r"banana$:", - ) -} - -pub unsafe fn we_escape_escapes_too() { - // CHECK: call void asm sideeffect alignstack inteldialect "banana\{{(\\|5C)}}36:" - asm!( - r"banana\36:", - ) -} diff --git a/src/test/incremental/cyclic-trait-hierarchy.rs b/src/test/incremental/cyclic-trait-hierarchy.rs index b502e7207d561..03bb5eea765cc 100644 --- a/src/test/incremental/cyclic-trait-hierarchy.rs +++ b/src/test/incremental/cyclic-trait-hierarchy.rs @@ -3,11 +3,11 @@ // revisions: rpass1 cfail2 #[cfg(rpass1)] -pub trait T2 {} +pub trait T2 { } #[cfg(cfail2)] -pub trait T2: T1 {} -//[cfail2]~^ ERROR cycle detected when computing the super predicates of `T2` +pub trait T2: T1 { } +//[cfail2]~^ ERROR cycle detected when computing the supertraits of `T2` -pub trait T1: T2 {} +pub trait T1: T2 { } -fn main() {} +fn main() { } diff --git a/src/test/mir-opt/basic_assignment.main.SimplifyCfg-initial.after.mir b/src/test/mir-opt/basic_assignment.main.SimplifyCfg-initial.after.mir index 7e0ca3dea4b71..0c7b64cb97f8f 100644 --- a/src/test/mir-opt/basic_assignment.main.SimplifyCfg-initial.after.mir +++ b/src/test/mir-opt/basic_assignment.main.SimplifyCfg-initial.after.mir @@ -41,44 +41,36 @@ fn main() -> () { StorageLive(_5); // scope 3 at $DIR/basic_assignment.rs:19:9: 19:15 StorageLive(_6); // scope 4 at $DIR/basic_assignment.rs:23:14: 23:20 _6 = move _4; // scope 4 at $DIR/basic_assignment.rs:23:14: 23:20 - replace(_5 <- move _6) -> [return: bb1, unwind: bb5]; // scope 4 at $DIR/basic_assignment.rs:23:5: 23:11 + replace(_5 <- move _6) -> [return: bb1, unwind: bb4]; // scope 4 at $DIR/basic_assignment.rs:23:5: 23:11 } bb1: { - drop(_6) -> [return: bb2, unwind: bb6]; // scope 4 at $DIR/basic_assignment.rs:23:19: 23:20 - } - - bb2: { StorageDead(_6); // scope 4 at $DIR/basic_assignment.rs:23:19: 23:20 _0 = const (); // scope 0 at $DIR/basic_assignment.rs:10:11: 24:2 - drop(_5) -> [return: bb3, unwind: bb7]; // scope 3 at $DIR/basic_assignment.rs:24:1: 24:2 + drop(_5) -> [return: bb2, unwind: bb5]; // scope 3 at $DIR/basic_assignment.rs:24:1: 24:2 } - bb3: { + bb2: { StorageDead(_5); // scope 3 at $DIR/basic_assignment.rs:24:1: 24:2 - drop(_4) -> [return: bb4, unwind: bb8]; // scope 2 at $DIR/basic_assignment.rs:24:1: 24:2 + drop(_4) -> [return: bb3, unwind: bb6]; // scope 2 at $DIR/basic_assignment.rs:24:1: 24:2 } - bb4: { + bb3: { StorageDead(_4); // scope 2 at $DIR/basic_assignment.rs:24:1: 24:2 StorageDead(_2); // scope 1 at $DIR/basic_assignment.rs:24:1: 24:2 StorageDead(_1); // scope 0 at $DIR/basic_assignment.rs:24:1: 24:2 return; // scope 0 at $DIR/basic_assignment.rs:24:2: 24:2 } - bb5 (cleanup): { - drop(_6) -> bb6; // scope 4 at $DIR/basic_assignment.rs:23:19: 23:20 - } - - bb6 (cleanup): { - drop(_5) -> bb7; // scope 3 at $DIR/basic_assignment.rs:24:1: 24:2 + bb4 (cleanup): { + drop(_5) -> bb5; // scope 3 at $DIR/basic_assignment.rs:24:1: 24:2 } - bb7 (cleanup): { - drop(_4) -> bb8; // scope 2 at $DIR/basic_assignment.rs:24:1: 24:2 + bb5 (cleanup): { + drop(_4) -> bb6; // scope 2 at $DIR/basic_assignment.rs:24:1: 24:2 } - bb8 (cleanup): { + bb6 (cleanup): { resume; // scope 0 at $DIR/basic_assignment.rs:10:1: 24:2 } } diff --git a/src/test/mir-opt/box_expr.main.ElaborateDrops.before.mir b/src/test/mir-opt/box_expr.main.ElaborateDrops.before.mir index cfbd3a58637c0..20ea7b026bc6e 100644 --- a/src/test/mir-opt/box_expr.main.ElaborateDrops.before.mir +++ b/src/test/mir-opt/box_expr.main.ElaborateDrops.before.mir @@ -14,7 +14,7 @@ fn main() -> () { StorageLive(_1); // scope 0 at $DIR/box_expr.rs:7:9: 7:10 StorageLive(_2); // scope 0 at $DIR/box_expr.rs:7:13: 7:25 _2 = Box(S); // scope 0 at $DIR/box_expr.rs:7:13: 7:25 - (*_2) = S::new() -> [return: bb1, unwind: bb7]; // scope 0 at $DIR/box_expr.rs:7:17: 7:25 + (*_2) = S::new() -> [return: bb1, unwind: bb5]; // scope 0 at $DIR/box_expr.rs:7:17: 7:25 // mir::Constant // + span: $DIR/box_expr.rs:7:17: 7:23 // + literal: Const { ty: fn() -> S {S::new}, val: Value(Scalar()) } @@ -22,45 +22,37 @@ fn main() -> () { bb1: { _1 = move _2; // scope 0 at $DIR/box_expr.rs:7:13: 7:25 - drop(_2) -> bb2; // scope 0 at $DIR/box_expr.rs:7:24: 7:25 - } - - bb2: { StorageDead(_2); // scope 0 at $DIR/box_expr.rs:7:24: 7:25 StorageLive(_3); // scope 1 at $DIR/box_expr.rs:8:5: 8:12 StorageLive(_4); // scope 1 at $DIR/box_expr.rs:8:10: 8:11 _4 = move _1; // scope 1 at $DIR/box_expr.rs:8:10: 8:11 - _3 = std::mem::drop::>(move _4) -> [return: bb3, unwind: bb5]; // scope 1 at $DIR/box_expr.rs:8:5: 8:12 + _3 = std::mem::drop::>(move _4) -> [return: bb2, unwind: bb4]; // scope 1 at $DIR/box_expr.rs:8:5: 8:12 // mir::Constant // + span: $DIR/box_expr.rs:8:5: 8:9 // + literal: Const { ty: fn(std::boxed::Box) {std::mem::drop::>}, val: Value(Scalar()) } } - bb3: { + bb2: { StorageDead(_4); // scope 1 at $DIR/box_expr.rs:8:11: 8:12 StorageDead(_3); // scope 1 at $DIR/box_expr.rs:8:12: 8:13 _0 = const (); // scope 0 at $DIR/box_expr.rs:6:11: 9:2 - drop(_1) -> bb4; // scope 0 at $DIR/box_expr.rs:9:1: 9:2 + drop(_1) -> bb3; // scope 0 at $DIR/box_expr.rs:9:1: 9:2 } - bb4: { + bb3: { StorageDead(_1); // scope 0 at $DIR/box_expr.rs:9:1: 9:2 return; // scope 0 at $DIR/box_expr.rs:9:2: 9:2 } - bb5 (cleanup): { - drop(_4) -> bb6; // scope 1 at $DIR/box_expr.rs:8:11: 8:12 - } - - bb6 (cleanup): { - drop(_1) -> bb8; // scope 0 at $DIR/box_expr.rs:9:1: 9:2 + bb4 (cleanup): { + drop(_1) -> bb6; // scope 0 at $DIR/box_expr.rs:9:1: 9:2 } - bb7 (cleanup): { - drop(_2) -> bb8; // scope 0 at $DIR/box_expr.rs:7:24: 7:25 + bb5 (cleanup): { + drop(_2) -> bb6; // scope 0 at $DIR/box_expr.rs:7:24: 7:25 } - bb8 (cleanup): { + bb6 (cleanup): { resume; // scope 0 at $DIR/box_expr.rs:6:1: 9:2 } } diff --git a/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.before-SimplifyBranches-final.after.diff b/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.before-SimplifyBranches-final.after.diff index 1b292cdd796e5..f51a08ed73068 100644 --- a/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.before-SimplifyBranches-final.after.diff +++ b/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.before-SimplifyBranches-final.after.diff @@ -1,7 +1,7 @@ - // MIR for `try_sum` before EarlyOtherwiseBranch + // MIR for `try_sum` after SimplifyBranches-final - fn try_sum(_1: &ViewportPercentageLength, _2: &ViewportPercentageLength) -> Result { + fn try_sum(_1: &ViewportPercentageLength, _2: &ViewportPercentageLength) -> std::result::Result { debug x => _1; // in scope 0 at $DIR/early_otherwise_branch_68867.rs:18:5: 18:6 debug other => _2; // in scope 0 at $DIR/early_otherwise_branch_68867.rs:19:5: 19:10 let mut _0: std::result::Result; // return place in scope 0 at $DIR/early_otherwise_branch_68867.rs:20:6: 20:42 diff --git a/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff b/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff index d20ee78459103..05ef6721e6535 100644 --- a/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff +++ b/src/test/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff @@ -1,7 +1,7 @@ - // MIR for `try_sum` before EarlyOtherwiseBranch + // MIR for `try_sum` after EarlyOtherwiseBranch - fn try_sum(_1: &ViewportPercentageLength, _2: &ViewportPercentageLength) -> Result { + fn try_sum(_1: &ViewportPercentageLength, _2: &ViewportPercentageLength) -> std::result::Result { debug x => _1; // in scope 0 at $DIR/early_otherwise_branch_68867.rs:18:5: 18:6 debug other => _2; // in scope 0 at $DIR/early_otherwise_branch_68867.rs:19:5: 19:10 let mut _0: std::result::Result; // return place in scope 0 at $DIR/early_otherwise_branch_68867.rs:20:6: 20:42 diff --git a/src/test/mir-opt/funky_arms.float_to_exponential_common.ConstProp.diff b/src/test/mir-opt/funky_arms.float_to_exponential_common.ConstProp.diff index caa02abf01936..bb79cd80e51b6 100644 --- a/src/test/mir-opt/funky_arms.float_to_exponential_common.ConstProp.diff +++ b/src/test/mir-opt/funky_arms.float_to_exponential_common.ConstProp.diff @@ -1,7 +1,7 @@ - // MIR for `float_to_exponential_common` before ConstProp + // MIR for `float_to_exponential_common` after ConstProp - fn float_to_exponential_common(_1: &mut Formatter, _2: &T, _3: bool) -> Result<(), std::fmt::Error> { + fn float_to_exponential_common(_1: &mut Formatter, _2: &T, _3: bool) -> std::result::Result<(), std::fmt::Error> { debug fmt => _1; // in scope 0 at $DIR/funky_arms.rs:11:35: 11:38 debug num => _2; // in scope 0 at $DIR/funky_arms.rs:11:60: 11:63 debug upper => _3; // in scope 0 at $DIR/funky_arms.rs:11:69: 11:74 diff --git a/src/test/mir-opt/inline/inline-instruction-set.rs b/src/test/mir-opt/inline/inline-instruction-set.rs deleted file mode 100644 index be36ff50c7ef1..0000000000000 --- a/src/test/mir-opt/inline/inline-instruction-set.rs +++ /dev/null @@ -1,54 +0,0 @@ -// Checks that only functions with the compatible instruction_set attributes are inlined. -// -// compile-flags: --target thumbv4t-none-eabi -// needs-llvm-components: arm - -#![crate_type = "lib"] -#![feature(rustc_attrs)] -#![feature(no_core, lang_items)] -#![feature(isa_attribute)] -#![no_core] - -#[rustc_builtin_macro] -#[macro_export] -macro_rules! asm { - ("assembly template", - $(operands,)* - $(options($(option),*))? - ) => { - /* compiler built-in */ - }; -} - -#[lang = "sized"] -trait Sized {} -#[lang = "copy"] -trait Copy {} - -#[instruction_set(arm::a32)] -#[inline] -fn instruction_set_a32() {} - -#[instruction_set(arm::t32)] -#[inline] -fn instruction_set_t32() {} - -#[inline] -fn instruction_set_default() {} - -// EMIT_MIR inline_instruction_set.t32.Inline.diff -#[instruction_set(arm::t32)] -pub fn t32() { - instruction_set_a32(); - instruction_set_t32(); - // The default instruction set is currently - // conservatively assumed to be incompatible. - instruction_set_default(); -} - -// EMIT_MIR inline_instruction_set.default.Inline.diff -pub fn default() { - instruction_set_a32(); - instruction_set_t32(); - instruction_set_default(); -} diff --git a/src/test/mir-opt/inline/inline_diverging.h.Inline.diff b/src/test/mir-opt/inline/inline_diverging.h.Inline.diff index 07994eb3c1661..22737381c71ae 100644 --- a/src/test/mir-opt/inline/inline_diverging.h.Inline.diff +++ b/src/test/mir-opt/inline/inline_diverging.h.Inline.diff @@ -5,18 +5,19 @@ let mut _0: (); // return place in scope 0 at $DIR/inline-diverging.rs:21:12: 21:12 let _1: (!, !); // in scope 0 at $DIR/inline-diverging.rs:22:5: 22:22 + let mut _2: fn() -> ! {sleep}; // in scope 0 at $DIR/inline-diverging.rs:22:5: 22:22 -+ let mut _7: (); // in scope 0 at $DIR/inline-diverging.rs:22:5: 22:22 + let mut _8: (); // in scope 0 at $DIR/inline-diverging.rs:22:5: 22:22 ++ let mut _9: (); // in scope 0 at $DIR/inline-diverging.rs:22:5: 22:22 + scope 1 (inlined call_twice:: ! {sleep}>) { // at $DIR/inline-diverging.rs:22:5: 22:22 + debug f => _2; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + let _3: !; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + let mut _4: &fn() -> ! {sleep}; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + let mut _5: &fn() -> ! {sleep}; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + let mut _6: !; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 ++ let mut _7: !; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + scope 2 { + debug a => _3; // in scope 2 at $DIR/inline-diverging.rs:22:5: 22:22 + scope 3 { -+ debug b => _6; // in scope 3 at $DIR/inline-diverging.rs:22:5: 22:22 ++ debug b => _7; // in scope 3 at $DIR/inline-diverging.rs:22:5: 22:22 + } + scope 6 (inlined ! {sleep} as Fn<()>>::call - shim(fn() -> ! {sleep})) { // at $DIR/inline-diverging.rs:22:5: 22:22 + scope 7 (inlined sleep) { // at $DIR/inline-diverging.rs:22:5: 22:22 @@ -40,12 +41,12 @@ - // mir::Constant // + span: $DIR/inline-diverging.rs:22:16: 22:21 // + literal: Const { ty: fn() -> ! {sleep}, val: Value(Scalar()) } -+ StorageLive(_6); // scope 0 at $DIR/inline-diverging.rs:22:5: 22:22 ++ StorageLive(_7); // scope 0 at $DIR/inline-diverging.rs:22:5: 22:22 + StorageLive(_3); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + StorageLive(_4); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + _4 = &_2; // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 -+ StorageLive(_7); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 -+ _7 = const (); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 ++ StorageLive(_8); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 ++ _8 = const (); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22 + goto -> bb1; // scope 5 at $DIR/inline-diverging.rs:22:5: 22:22 } diff --git a/src/test/mir-opt/inline/inline_instruction_set.default.Inline.diff b/src/test/mir-opt/inline/inline_instruction_set.default.Inline.diff deleted file mode 100644 index 334cf5a08e2c5..0000000000000 --- a/src/test/mir-opt/inline/inline_instruction_set.default.Inline.diff +++ /dev/null @@ -1,45 +0,0 @@ -- // MIR for `default` before Inline -+ // MIR for `default` after Inline - - fn default() -> () { - let mut _0: (); // return place in scope 0 at $DIR/inline-instruction-set.rs:50:18: 50:18 - let _1: (); // in scope 0 at $DIR/inline-instruction-set.rs:51:5: 51:26 - let _2: (); // in scope 0 at $DIR/inline-instruction-set.rs:52:5: 52:26 - let _3: (); // in scope 0 at $DIR/inline-instruction-set.rs:53:5: 53:30 -+ scope 1 (inlined instruction_set_default) { // at $DIR/inline-instruction-set.rs:53:5: 53:30 -+ } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/inline-instruction-set.rs:51:5: 51:26 - _1 = instruction_set_a32() -> bb1; // scope 0 at $DIR/inline-instruction-set.rs:51:5: 51:26 - // mir::Constant - // + span: $DIR/inline-instruction-set.rs:51:5: 51:24 - // + literal: Const { ty: fn() {instruction_set_a32}, val: Value(Scalar()) } - } - - bb1: { - StorageDead(_1); // scope 0 at $DIR/inline-instruction-set.rs:51:26: 51:27 - StorageLive(_2); // scope 0 at $DIR/inline-instruction-set.rs:52:5: 52:26 - _2 = instruction_set_t32() -> bb2; // scope 0 at $DIR/inline-instruction-set.rs:52:5: 52:26 - // mir::Constant - // + span: $DIR/inline-instruction-set.rs:52:5: 52:24 - // + literal: Const { ty: fn() {instruction_set_t32}, val: Value(Scalar()) } - } - - bb2: { - StorageDead(_2); // scope 0 at $DIR/inline-instruction-set.rs:52:26: 52:27 - StorageLive(_3); // scope 0 at $DIR/inline-instruction-set.rs:53:5: 53:30 -- _3 = instruction_set_default() -> bb3; // scope 0 at $DIR/inline-instruction-set.rs:53:5: 53:30 -- // mir::Constant -- // + span: $DIR/inline-instruction-set.rs:53:5: 53:28 -- // + literal: Const { ty: fn() {instruction_set_default}, val: Value(Scalar()) } -- } -- -- bb3: { -+ _3 = const (); // scope 1 at $DIR/inline-instruction-set.rs:53:5: 53:30 - StorageDead(_3); // scope 0 at $DIR/inline-instruction-set.rs:53:30: 53:31 - _0 = const (); // scope 0 at $DIR/inline-instruction-set.rs:50:18: 54:2 - return; // scope 0 at $DIR/inline-instruction-set.rs:54:2: 54:2 - } - } - diff --git a/src/test/mir-opt/inline/inline_instruction_set.t32.Inline.diff b/src/test/mir-opt/inline/inline_instruction_set.t32.Inline.diff deleted file mode 100644 index 920b68c9daa1e..0000000000000 --- a/src/test/mir-opt/inline/inline_instruction_set.t32.Inline.diff +++ /dev/null @@ -1,47 +0,0 @@ -- // MIR for `t32` before Inline -+ // MIR for `t32` after Inline - - fn t32() -> () { - let mut _0: (); // return place in scope 0 at $DIR/inline-instruction-set.rs:41:14: 41:14 - let _1: (); // in scope 0 at $DIR/inline-instruction-set.rs:42:5: 42:26 - let _2: (); // in scope 0 at $DIR/inline-instruction-set.rs:43:5: 43:26 - let _3: (); // in scope 0 at $DIR/inline-instruction-set.rs:46:5: 46:30 -+ scope 1 (inlined instruction_set_t32) { // at $DIR/inline-instruction-set.rs:43:5: 43:26 -+ } - - bb0: { - StorageLive(_1); // scope 0 at $DIR/inline-instruction-set.rs:42:5: 42:26 - _1 = instruction_set_a32() -> bb1; // scope 0 at $DIR/inline-instruction-set.rs:42:5: 42:26 - // mir::Constant - // + span: $DIR/inline-instruction-set.rs:42:5: 42:24 - // + literal: Const { ty: fn() {instruction_set_a32}, val: Value(Scalar()) } - } - - bb1: { - StorageDead(_1); // scope 0 at $DIR/inline-instruction-set.rs:42:26: 42:27 - StorageLive(_2); // scope 0 at $DIR/inline-instruction-set.rs:43:5: 43:26 -- _2 = instruction_set_t32() -> bb2; // scope 0 at $DIR/inline-instruction-set.rs:43:5: 43:26 -- // mir::Constant -- // + span: $DIR/inline-instruction-set.rs:43:5: 43:24 -- // + literal: Const { ty: fn() {instruction_set_t32}, val: Value(Scalar()) } -- } -- -- bb2: { -+ _2 = const (); // scope 1 at $DIR/inline-instruction-set.rs:43:5: 43:26 - StorageDead(_2); // scope 0 at $DIR/inline-instruction-set.rs:43:26: 43:27 - StorageLive(_3); // scope 0 at $DIR/inline-instruction-set.rs:46:5: 46:30 -- _3 = instruction_set_default() -> bb3; // scope 0 at $DIR/inline-instruction-set.rs:46:5: 46:30 -+ _3 = instruction_set_default() -> bb2; // scope 0 at $DIR/inline-instruction-set.rs:46:5: 46:30 - // mir::Constant - // + span: $DIR/inline-instruction-set.rs:46:5: 46:28 - // + literal: Const { ty: fn() {instruction_set_default}, val: Value(Scalar()) } - } - -- bb3: { -+ bb2: { - StorageDead(_3); // scope 0 at $DIR/inline-instruction-set.rs:46:30: 46:31 - _0 = const (); // scope 0 at $DIR/inline-instruction-set.rs:41:14: 47:2 - return; // scope 0 at $DIR/inline-instruction-set.rs:47:2: 47:2 - } - } - diff --git a/src/test/mir-opt/issue_41110.main.ElaborateDrops.after.mir b/src/test/mir-opt/issue_41110.main.ElaborateDrops.after.mir index 7113c42b9c77f..bbbd2bcf128b1 100644 --- a/src/test/mir-opt/issue_41110.main.ElaborateDrops.after.mir +++ b/src/test/mir-opt/issue_41110.main.ElaborateDrops.after.mir @@ -6,21 +6,18 @@ fn main() -> () { let mut _2: S; // in scope 0 at $DIR/issue-41110.rs:8:13: 8:14 let mut _3: S; // in scope 0 at $DIR/issue-41110.rs:8:21: 8:27 let mut _4: S; // in scope 0 at $DIR/issue-41110.rs:8:21: 8:22 - let mut _5: bool; // in scope 0 at $DIR/issue-41110.rs:8:27: 8:28 scope 1 { debug x => _1; // in scope 1 at $DIR/issue-41110.rs:8:9: 8:10 } bb0: { - _5 = const false; // scope 0 at $DIR/issue-41110.rs:8:9: 8:10 StorageLive(_1); // scope 0 at $DIR/issue-41110.rs:8:9: 8:10 StorageLive(_2); // scope 0 at $DIR/issue-41110.rs:8:13: 8:14 - _5 = const true; // scope 0 at $DIR/issue-41110.rs:8:13: 8:14 _2 = S; // scope 0 at $DIR/issue-41110.rs:8:13: 8:14 StorageLive(_3); // scope 0 at $DIR/issue-41110.rs:8:21: 8:27 StorageLive(_4); // scope 0 at $DIR/issue-41110.rs:8:21: 8:22 _4 = S; // scope 0 at $DIR/issue-41110.rs:8:21: 8:22 - _3 = S::id(move _4) -> [return: bb1, unwind: bb4]; // scope 0 at $DIR/issue-41110.rs:8:21: 8:27 + _3 = S::id(move _4) -> [return: bb1, unwind: bb3]; // scope 0 at $DIR/issue-41110.rs:8:21: 8:27 // mir::Constant // + span: $DIR/issue-41110.rs:8:23: 8:25 // + literal: Const { ty: fn(S) -> S {S::id}, val: Value(Scalar()) } @@ -28,8 +25,7 @@ fn main() -> () { bb1: { StorageDead(_4); // scope 0 at $DIR/issue-41110.rs:8:26: 8:27 - _5 = const false; // scope 0 at $DIR/issue-41110.rs:8:13: 8:28 - _1 = S::other(move _2, move _3) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/issue-41110.rs:8:13: 8:28 + _1 = S::other(move _2, move _3) -> bb2; // scope 0 at $DIR/issue-41110.rs:8:13: 8:28 // mir::Constant // + span: $DIR/issue-41110.rs:8:15: 8:20 // + literal: Const { ty: fn(S, S) {S::other}, val: Value(Scalar()) } @@ -37,7 +33,6 @@ fn main() -> () { bb2: { StorageDead(_3); // scope 0 at $DIR/issue-41110.rs:8:27: 8:28 - _5 = const false; // scope 0 at $DIR/issue-41110.rs:8:27: 8:28 StorageDead(_2); // scope 0 at $DIR/issue-41110.rs:8:27: 8:28 _0 = const (); // scope 0 at $DIR/issue-41110.rs:7:11: 9:2 StorageDead(_1); // scope 0 at $DIR/issue-41110.rs:9:1: 9:2 @@ -45,26 +40,10 @@ fn main() -> () { } bb3 (cleanup): { - goto -> bb5; // scope 0 at $DIR/issue-41110.rs:8:27: 8:28 + drop(_2) -> bb4; // scope 0 at $DIR/issue-41110.rs:8:27: 8:28 } bb4 (cleanup): { - goto -> bb5; // scope 0 at $DIR/issue-41110.rs:8:26: 8:27 - } - - bb5 (cleanup): { - goto -> bb8; // scope 0 at $DIR/issue-41110.rs:8:27: 8:28 - } - - bb6 (cleanup): { resume; // scope 0 at $DIR/issue-41110.rs:7:1: 9:2 } - - bb7 (cleanup): { - drop(_2) -> bb6; // scope 0 at $DIR/issue-41110.rs:8:27: 8:28 - } - - bb8 (cleanup): { - switchInt(_5) -> [false: bb6, otherwise: bb7]; // scope 0 at $DIR/issue-41110.rs:8:27: 8:28 - } } diff --git a/src/test/mir-opt/issue_41110.test.ElaborateDrops.after.mir b/src/test/mir-opt/issue_41110.test.ElaborateDrops.after.mir index c4e852ca3212a..b0c7260f0f4dc 100644 --- a/src/test/mir-opt/issue_41110.test.ElaborateDrops.after.mir +++ b/src/test/mir-opt/issue_41110.test.ElaborateDrops.after.mir @@ -25,7 +25,7 @@ fn test() -> () { StorageLive(_3); // scope 2 at $DIR/issue-41110.rs:17:5: 17:12 StorageLive(_4); // scope 2 at $DIR/issue-41110.rs:17:10: 17:11 _4 = move _2; // scope 2 at $DIR/issue-41110.rs:17:10: 17:11 - _3 = std::mem::drop::(move _4) -> [return: bb1, unwind: bb7]; // scope 2 at $DIR/issue-41110.rs:17:5: 17:12 + _3 = std::mem::drop::(move _4) -> [return: bb1, unwind: bb5]; // scope 2 at $DIR/issue-41110.rs:17:5: 17:12 // mir::Constant // + span: $DIR/issue-41110.rs:17:5: 17:9 // + literal: Const { ty: fn(S) {std::mem::drop::}, val: Value(Scalar()) } @@ -37,65 +37,53 @@ fn test() -> () { StorageLive(_5); // scope 2 at $DIR/issue-41110.rs:18:9: 18:10 _6 = const false; // scope 2 at $DIR/issue-41110.rs:18:9: 18:10 _5 = move _1; // scope 2 at $DIR/issue-41110.rs:18:9: 18:10 - goto -> bb12; // scope 2 at $DIR/issue-41110.rs:18:5: 18:6 + goto -> bb9; // scope 2 at $DIR/issue-41110.rs:18:5: 18:6 } bb2: { - goto -> bb3; // scope 2 at $DIR/issue-41110.rs:18:9: 18:10 - } - - bb3: { StorageDead(_5); // scope 2 at $DIR/issue-41110.rs:18:9: 18:10 _0 = const (); // scope 0 at $DIR/issue-41110.rs:14:15: 19:2 - drop(_2) -> [return: bb4, unwind: bb9]; // scope 1 at $DIR/issue-41110.rs:19:1: 19:2 + drop(_2) -> [return: bb3, unwind: bb6]; // scope 1 at $DIR/issue-41110.rs:19:1: 19:2 } - bb4: { + bb3: { StorageDead(_2); // scope 1 at $DIR/issue-41110.rs:19:1: 19:2 - goto -> bb5; // scope 0 at $DIR/issue-41110.rs:19:1: 19:2 + goto -> bb4; // scope 0 at $DIR/issue-41110.rs:19:1: 19:2 } - bb5: { + bb4: { _6 = const false; // scope 0 at $DIR/issue-41110.rs:19:1: 19:2 StorageDead(_1); // scope 0 at $DIR/issue-41110.rs:19:1: 19:2 return; // scope 0 at $DIR/issue-41110.rs:19:2: 19:2 } - bb6 (cleanup): { - goto -> bb8; // scope 2 at $DIR/issue-41110.rs:18:9: 18:10 - } - - bb7 (cleanup): { - goto -> bb8; // scope 2 at $DIR/issue-41110.rs:17:11: 17:12 - } - - bb8 (cleanup): { - goto -> bb9; // scope 1 at $DIR/issue-41110.rs:19:1: 19:2 + bb5 (cleanup): { + goto -> bb6; // scope 1 at $DIR/issue-41110.rs:19:1: 19:2 } - bb9 (cleanup): { - goto -> bb14; // scope 0 at $DIR/issue-41110.rs:19:1: 19:2 + bb6 (cleanup): { + goto -> bb11; // scope 0 at $DIR/issue-41110.rs:19:1: 19:2 } - bb10 (cleanup): { + bb7 (cleanup): { resume; // scope 0 at $DIR/issue-41110.rs:14:1: 19:2 } - bb11 (cleanup): { + bb8 (cleanup): { _2 = move _5; // scope 2 at $DIR/issue-41110.rs:18:5: 18:6 - goto -> bb6; // scope 2 at $DIR/issue-41110.rs:18:5: 18:6 + goto -> bb5; // scope 2 at $DIR/issue-41110.rs:18:5: 18:6 } - bb12: { + bb9: { _2 = move _5; // scope 2 at $DIR/issue-41110.rs:18:5: 18:6 goto -> bb2; // scope 2 at $DIR/issue-41110.rs:18:5: 18:6 } - bb13 (cleanup): { - drop(_1) -> bb10; // scope 0 at $DIR/issue-41110.rs:19:1: 19:2 + bb10 (cleanup): { + drop(_1) -> bb7; // scope 0 at $DIR/issue-41110.rs:19:1: 19:2 } - bb14 (cleanup): { - switchInt(_6) -> [false: bb10, otherwise: bb13]; // scope 0 at $DIR/issue-41110.rs:19:1: 19:2 + bb11 (cleanup): { + switchInt(_6) -> [false: bb7, otherwise: bb10]; // scope 0 at $DIR/issue-41110.rs:19:1: 19:2 } } diff --git a/src/test/mir-opt/issue_41888.main.ElaborateDrops.after.mir b/src/test/mir-opt/issue_41888.main.ElaborateDrops.after.mir index 488fcb5dd70e8..4fc7f9daa22b9 100644 --- a/src/test/mir-opt/issue_41888.main.ElaborateDrops.after.mir +++ b/src/test/mir-opt/issue_41888.main.ElaborateDrops.after.mir @@ -26,7 +26,7 @@ fn main() -> () { _8 = const false; // scope 0 at $DIR/issue-41888.rs:7:9: 7:10 StorageLive(_1); // scope 0 at $DIR/issue-41888.rs:7:9: 7:10 StorageLive(_2); // scope 1 at $DIR/issue-41888.rs:8:8: 8:14 - _2 = cond() -> [return: bb1, unwind: bb11]; // scope 1 at $DIR/issue-41888.rs:8:8: 8:14 + _2 = cond() -> [return: bb1, unwind: bb9]; // scope 1 at $DIR/issue-41888.rs:8:8: 8:14 // mir::Constant // + span: $DIR/issue-41888.rs:8:8: 8:12 // + literal: Const { ty: fn() -> bool {cond}, val: Value(Scalar()) } @@ -42,44 +42,40 @@ fn main() -> () { _4 = K; // scope 1 at $DIR/issue-41888.rs:9:18: 9:19 _3 = E::F(move _4); // scope 1 at $DIR/issue-41888.rs:9:13: 9:20 StorageDead(_4); // scope 1 at $DIR/issue-41888.rs:9:19: 9:20 - goto -> bb14; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10 + goto -> bb12; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10 } bb3: { _0 = const (); // scope 1 at $DIR/issue-41888.rs:14:6: 14:6 - goto -> bb8; // scope 1 at $DIR/issue-41888.rs:8:5: 14:6 + goto -> bb7; // scope 1 at $DIR/issue-41888.rs:8:5: 14:6 } bb4: { - goto -> bb5; // scope 1 at $DIR/issue-41888.rs:9:19: 9:20 - } - - bb5: { StorageDead(_3); // scope 1 at $DIR/issue-41888.rs:9:19: 9:20 _5 = discriminant(_1); // scope 1 at $DIR/issue-41888.rs:10:16: 10:24 - switchInt(move _5) -> [0_isize: bb7, otherwise: bb6]; // scope 1 at $DIR/issue-41888.rs:10:16: 10:24 + switchInt(move _5) -> [0_isize: bb6, otherwise: bb5]; // scope 1 at $DIR/issue-41888.rs:10:16: 10:24 } - bb6: { + bb5: { _0 = const (); // scope 1 at $DIR/issue-41888.rs:13:10: 13:10 - goto -> bb8; // scope 1 at $DIR/issue-41888.rs:10:9: 13:10 + goto -> bb7; // scope 1 at $DIR/issue-41888.rs:10:9: 13:10 } - bb7: { + bb6: { StorageLive(_6); // scope 1 at $DIR/issue-41888.rs:10:21: 10:23 _9 = const false; // scope 1 at $DIR/issue-41888.rs:10:21: 10:23 _6 = move ((_1 as F).0: K); // scope 1 at $DIR/issue-41888.rs:10:21: 10:23 _0 = const (); // scope 2 at $DIR/issue-41888.rs:10:29: 13:10 StorageDead(_6); // scope 1 at $DIR/issue-41888.rs:13:9: 13:10 - goto -> bb8; // scope 1 at $DIR/issue-41888.rs:10:9: 13:10 + goto -> bb7; // scope 1 at $DIR/issue-41888.rs:10:9: 13:10 } - bb8: { + bb7: { StorageDead(_2); // scope 1 at $DIR/issue-41888.rs:14:5: 14:6 - goto -> bb20; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + goto -> bb18; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 } - bb9: { + bb8: { _7 = const false; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 _8 = const false; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 _9 = const false; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 @@ -87,27 +83,23 @@ fn main() -> () { return; // scope 0 at $DIR/issue-41888.rs:15:2: 15:2 } - bb10 (cleanup): { - goto -> bb11; // scope 1 at $DIR/issue-41888.rs:9:19: 9:20 - } - - bb11 (cleanup): { - goto -> bb12; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + bb9 (cleanup): { + goto -> bb10; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 } - bb12 (cleanup): { + bb10 (cleanup): { resume; // scope 0 at $DIR/issue-41888.rs:6:1: 15:2 } - bb13 (cleanup): { + bb11 (cleanup): { _7 = const true; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10 _8 = const true; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10 _9 = const true; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10 _1 = move _3; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10 - goto -> bb10; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10 + goto -> bb9; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10 } - bb14: { + bb12: { _7 = const true; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10 _8 = const true; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10 _9 = const true; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10 @@ -115,38 +107,38 @@ fn main() -> () { goto -> bb4; // scope 1 at $DIR/issue-41888.rs:9:9: 9:10 } - bb15: { + bb13: { _7 = const false; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 - goto -> bb9; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + goto -> bb8; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 } - bb16 (cleanup): { - goto -> bb12; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + bb14 (cleanup): { + goto -> bb10; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 } - bb17: { - drop(_1) -> [return: bb15, unwind: bb12]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + bb15: { + drop(_1) -> [return: bb13, unwind: bb10]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 } - bb18 (cleanup): { - drop(_1) -> bb12; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + bb16 (cleanup): { + drop(_1) -> bb10; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 } - bb19: { + bb17: { _10 = discriminant(_1); // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 - switchInt(move _10) -> [0_isize: bb15, otherwise: bb17]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + switchInt(move _10) -> [0_isize: bb13, otherwise: bb15]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 } - bb20: { - switchInt(_7) -> [false: bb15, otherwise: bb19]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + bb18: { + switchInt(_7) -> [false: bb13, otherwise: bb17]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 } - bb21 (cleanup): { + bb19 (cleanup): { _11 = discriminant(_1); // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 - switchInt(move _11) -> [0_isize: bb16, otherwise: bb18]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + switchInt(move _11) -> [0_isize: bb14, otherwise: bb16]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 } - bb22 (cleanup): { - switchInt(_7) -> [false: bb12, otherwise: bb21]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + bb20 (cleanup): { + switchInt(_7) -> [false: bb10, otherwise: bb19]; // scope 0 at $DIR/issue-41888.rs:15:1: 15:2 } } diff --git a/src/test/mir-opt/issue_62289.test.ElaborateDrops.before.mir b/src/test/mir-opt/issue_62289.test.ElaborateDrops.before.mir index c1421f20a0ba2..f74cdd7191927 100644 --- a/src/test/mir-opt/issue_62289.test.ElaborateDrops.before.mir +++ b/src/test/mir-opt/issue_62289.test.ElaborateDrops.before.mir @@ -30,7 +30,7 @@ fn test() -> Option> { StorageLive(_3); // scope 0 at $DIR/issue-62289.rs:9:15: 9:20 StorageLive(_4); // scope 0 at $DIR/issue-62289.rs:9:15: 9:19 _4 = Option::::None; // scope 0 at $DIR/issue-62289.rs:9:15: 9:19 - _3 = as Try>::into_result(move _4) -> [return: bb1, unwind: bb12]; // scope 0 at $DIR/issue-62289.rs:9:15: 9:20 + _3 = as Try>::into_result(move _4) -> [return: bb1, unwind: bb10]; // scope 0 at $DIR/issue-62289.rs:9:15: 9:20 // mir::Constant // + span: $DIR/issue-62289.rs:9:15: 9:20 // + literal: Const { ty: fn(std::option::Option) -> std::result::Result< as std::ops::Try>::Ok, as std::ops::Try>::Error> { as std::ops::Try>::into_result}, val: Value(Scalar()) } @@ -48,7 +48,11 @@ fn test() -> Option> { (*_2) = _10; // scope 4 at $DIR/issue-62289.rs:9:15: 9:20 StorageDead(_10); // scope 0 at $DIR/issue-62289.rs:9:19: 9:20 _1 = move _2; // scope 0 at $DIR/issue-62289.rs:9:10: 9:21 - drop(_2) -> [return: bb7, unwind: bb11]; // scope 0 at $DIR/issue-62289.rs:9:20: 9:21 + StorageDead(_2); // scope 0 at $DIR/issue-62289.rs:9:20: 9:21 + _0 = Option::>::Some(move _1); // scope 0 at $DIR/issue-62289.rs:9:5: 9:22 + StorageDead(_1); // scope 0 at $DIR/issue-62289.rs:9:21: 9:22 + StorageDead(_3); // scope 0 at $DIR/issue-62289.rs:10:1: 10:2 + goto -> bb8; // scope 0 at $DIR/issue-62289.rs:10:2: 10:2 } bb3: { @@ -61,7 +65,7 @@ fn test() -> Option> { StorageLive(_8); // scope 2 at $DIR/issue-62289.rs:9:19: 9:20 StorageLive(_9); // scope 2 at $DIR/issue-62289.rs:9:19: 9:20 _9 = _6; // scope 2 at $DIR/issue-62289.rs:9:19: 9:20 - _8 = >::from(move _9) -> [return: bb5, unwind: bb12]; // scope 2 at $DIR/issue-62289.rs:9:19: 9:20 + _8 = >::from(move _9) -> [return: bb5, unwind: bb10]; // scope 2 at $DIR/issue-62289.rs:9:19: 9:20 // mir::Constant // + span: $DIR/issue-62289.rs:9:19: 9:20 // + literal: Const { ty: fn(std::option::NoneError) -> std::option::NoneError {>::from}, val: Value(Scalar()) } @@ -69,7 +73,7 @@ fn test() -> Option> { bb5: { StorageDead(_9); // scope 2 at $DIR/issue-62289.rs:9:19: 9:20 - _0 = > as Try>::from_error(move _8) -> [return: bb6, unwind: bb12]; // scope 2 at $DIR/issue-62289.rs:9:15: 9:20 + _0 = > as Try>::from_error(move _8) -> [return: bb6, unwind: bb10]; // scope 2 at $DIR/issue-62289.rs:9:15: 9:20 // mir::Constant // + span: $DIR/issue-62289.rs:9:15: 9:20 // + literal: Const { ty: fn(> as std::ops::Try>::Error) -> std::option::Option> {> as std::ops::Try>::from_error}, val: Value(Scalar()) } @@ -78,41 +82,29 @@ fn test() -> Option> { bb6: { StorageDead(_8); // scope 2 at $DIR/issue-62289.rs:9:19: 9:20 StorageDead(_6); // scope 0 at $DIR/issue-62289.rs:9:19: 9:20 - drop(_2) -> bb9; // scope 0 at $DIR/issue-62289.rs:9:20: 9:21 + drop(_2) -> [return: bb7, unwind: bb9]; // scope 0 at $DIR/issue-62289.rs:9:20: 9:21 } bb7: { - StorageDead(_2); // scope 0 at $DIR/issue-62289.rs:9:20: 9:21 - _0 = Option::>::Some(move _1); // scope 0 at $DIR/issue-62289.rs:9:5: 9:22 - drop(_1) -> bb8; // scope 0 at $DIR/issue-62289.rs:9:21: 9:22 - } - - bb8: { - StorageDead(_1); // scope 0 at $DIR/issue-62289.rs:9:21: 9:22 - StorageDead(_3); // scope 0 at $DIR/issue-62289.rs:10:1: 10:2 - goto -> bb10; // scope 0 at $DIR/issue-62289.rs:10:2: 10:2 - } - - bb9: { StorageDead(_2); // scope 0 at $DIR/issue-62289.rs:9:20: 9:21 StorageDead(_1); // scope 0 at $DIR/issue-62289.rs:9:21: 9:22 StorageDead(_3); // scope 0 at $DIR/issue-62289.rs:10:1: 10:2 - goto -> bb10; // scope 0 at $DIR/issue-62289.rs:10:2: 10:2 + goto -> bb8; // scope 0 at $DIR/issue-62289.rs:10:2: 10:2 } - bb10: { + bb8: { return; // scope 0 at $DIR/issue-62289.rs:10:2: 10:2 } - bb11 (cleanup): { - drop(_1) -> bb13; // scope 0 at $DIR/issue-62289.rs:9:21: 9:22 + bb9 (cleanup): { + drop(_0) -> bb11; // scope 0 at $DIR/issue-62289.rs:10:1: 10:2 } - bb12 (cleanup): { - drop(_2) -> bb13; // scope 0 at $DIR/issue-62289.rs:9:20: 9:21 + bb10 (cleanup): { + drop(_2) -> bb11; // scope 0 at $DIR/issue-62289.rs:9:20: 9:21 } - bb13 (cleanup): { + bb11 (cleanup): { resume; // scope 0 at $DIR/issue-62289.rs:8:1: 10:2 } } diff --git a/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff b/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff index e4916a56bea9b..9139f2cf6092b 100644 --- a/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff +++ b/src/test/mir-opt/issue_73223.main.PreCodegen.32bit.diff @@ -128,7 +128,7 @@ // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } StorageLive(_22); // scope 7 at $SRC_DIR/core/src/panic.rs:LL:COL - _22 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> Result<(), std::fmt::Error>>(move _23) -> bb3; // scope 7 at $SRC_DIR/core/src/panic.rs:LL:COL + _22 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _23) -> bb3; // scope 7 at $SRC_DIR/core/src/panic.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/panic.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } @@ -158,7 +158,7 @@ // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } StorageLive(_25); // scope 9 at $SRC_DIR/core/src/panic.rs:LL:COL - _25 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> Result<(), std::fmt::Error>>(move _26) -> bb5; // scope 9 at $SRC_DIR/core/src/panic.rs:LL:COL + _25 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _26) -> bb5; // scope 9 at $SRC_DIR/core/src/panic.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/panic.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } diff --git a/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff b/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff index e4916a56bea9b..9139f2cf6092b 100644 --- a/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff +++ b/src/test/mir-opt/issue_73223.main.PreCodegen.64bit.diff @@ -128,7 +128,7 @@ // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } StorageLive(_22); // scope 7 at $SRC_DIR/core/src/panic.rs:LL:COL - _22 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> Result<(), std::fmt::Error>>(move _23) -> bb3; // scope 7 at $SRC_DIR/core/src/panic.rs:LL:COL + _22 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _23) -> bb3; // scope 7 at $SRC_DIR/core/src/panic.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/panic.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } @@ -158,7 +158,7 @@ // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL // + literal: Const { ty: for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {<&i32 as std::fmt::Debug>::fmt}, val: Value(Scalar()) } StorageLive(_25); // scope 9 at $SRC_DIR/core/src/panic.rs:LL:COL - _25 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> Result<(), std::fmt::Error>>(move _26) -> bb5; // scope 9 at $SRC_DIR/core/src/panic.rs:LL:COL + _25 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _26) -> bb5; // scope 9 at $SRC_DIR/core/src/panic.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/panic.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } diff --git a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff index b5dd416ddb171..0eea0bf0a0614 100644 --- a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff +++ b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.32bit.diff @@ -203,7 +203,7 @@ StorageLive(_44); // scope 7 at $SRC_DIR/core/src/panic.rs:LL:COL StorageLive(_45); // scope 7 at $SRC_DIR/core/src/panic.rs:LL:COL _45 = _38; // scope 7 at $SRC_DIR/core/src/panic.rs:LL:COL - _44 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> Result<(), std::fmt::Error>>(move _45) -> bb5; // scope 7 at $SRC_DIR/core/src/panic.rs:LL:COL + _44 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _45) -> bb5; // scope 7 at $SRC_DIR/core/src/panic.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/panic.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } @@ -252,7 +252,7 @@ StorageLive(_48); // scope 9 at $SRC_DIR/core/src/panic.rs:LL:COL StorageLive(_49); // scope 9 at $SRC_DIR/core/src/panic.rs:LL:COL _49 = _41; // scope 9 at $SRC_DIR/core/src/panic.rs:LL:COL - _48 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> Result<(), std::fmt::Error>>(move _49) -> bb7; // scope 9 at $SRC_DIR/core/src/panic.rs:LL:COL + _48 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _49) -> bb7; // scope 9 at $SRC_DIR/core/src/panic.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/panic.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } diff --git a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff index b5dd416ddb171..0eea0bf0a0614 100644 --- a/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff +++ b/src/test/mir-opt/issue_73223.main.SimplifyArmIdentity.64bit.diff @@ -203,7 +203,7 @@ StorageLive(_44); // scope 7 at $SRC_DIR/core/src/panic.rs:LL:COL StorageLive(_45); // scope 7 at $SRC_DIR/core/src/panic.rs:LL:COL _45 = _38; // scope 7 at $SRC_DIR/core/src/panic.rs:LL:COL - _44 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> Result<(), std::fmt::Error>>(move _45) -> bb5; // scope 7 at $SRC_DIR/core/src/panic.rs:LL:COL + _44 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _45) -> bb5; // scope 7 at $SRC_DIR/core/src/panic.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/panic.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } @@ -252,7 +252,7 @@ StorageLive(_48); // scope 9 at $SRC_DIR/core/src/panic.rs:LL:COL StorageLive(_49); // scope 9 at $SRC_DIR/core/src/panic.rs:LL:COL _49 = _41; // scope 9 at $SRC_DIR/core/src/panic.rs:LL:COL - _48 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> Result<(), std::fmt::Error>>(move _49) -> bb7; // scope 9 at $SRC_DIR/core/src/panic.rs:LL:COL + _48 = transmute:: fn(&'r &i32, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>(move _49) -> bb7; // scope 9 at $SRC_DIR/core/src/panic.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/panic.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>) -> for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> {std::intrinsics::transmute:: fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>, for<'r, 's, 't0> fn(&'r core::fmt::Opaque, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error>>}, val: Value(Scalar()) } diff --git a/src/test/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.mir b/src/test/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.mir index bbb433dbe25c7..2f95931d2b2a1 100644 --- a/src/test/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.mir +++ b/src/test/mir-opt/no_spurious_drop_after_call.main.ElaborateDrops.before.mir @@ -28,7 +28,7 @@ fn main() -> () { bb1: { StorageDead(_3); // scope 0 at $DIR/no-spurious-drop-after-call.rs:9:33: 9:34 - _1 = std::mem::drop::(move _2) -> [return: bb2, unwind: bb3]; // scope 0 at $DIR/no-spurious-drop-after-call.rs:9:5: 9:35 + _1 = std::mem::drop::(move _2) -> bb2; // scope 0 at $DIR/no-spurious-drop-after-call.rs:9:5: 9:35 // mir::Constant // + span: $DIR/no-spurious-drop-after-call.rs:9:5: 9:19 // + literal: Const { ty: fn(std::string::String) {std::mem::drop::}, val: Value(Scalar()) } @@ -41,12 +41,4 @@ fn main() -> () { _0 = const (); // scope 0 at $DIR/no-spurious-drop-after-call.rs:8:11: 10:2 return; // scope 0 at $DIR/no-spurious-drop-after-call.rs:10:2: 10:2 } - - bb3 (cleanup): { - drop(_2) -> bb4; // scope 0 at $DIR/no-spurious-drop-after-call.rs:9:34: 9:35 - } - - bb4 (cleanup): { - resume; // scope 0 at $DIR/no-spurious-drop-after-call.rs:8:1: 10:2 - } } diff --git a/src/test/mir-opt/simplify_arm.id_result.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify_arm.id_result.SimplifyArmIdentity.diff index 40c18fb7282ec..253e3236ff7d1 100644 --- a/src/test/mir-opt/simplify_arm.id_result.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/simplify_arm.id_result.SimplifyArmIdentity.diff @@ -1,7 +1,7 @@ - // MIR for `id_result` before SimplifyArmIdentity + // MIR for `id_result` after SimplifyArmIdentity - fn id_result(_1: Result) -> Result { + fn id_result(_1: std::result::Result) -> std::result::Result { debug r => _1; // in scope 0 at $DIR/simplify-arm.rs:16:14: 16:15 let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify-arm.rs:16:37: 16:52 let mut _2: isize; // in scope 0 at $DIR/simplify-arm.rs:18:9: 18:14 diff --git a/src/test/mir-opt/simplify_arm.id_result.SimplifyBranchSame.diff b/src/test/mir-opt/simplify_arm.id_result.SimplifyBranchSame.diff index 596dbabead0bf..23cf43c531973 100644 --- a/src/test/mir-opt/simplify_arm.id_result.SimplifyBranchSame.diff +++ b/src/test/mir-opt/simplify_arm.id_result.SimplifyBranchSame.diff @@ -1,7 +1,7 @@ - // MIR for `id_result` before SimplifyBranchSame + // MIR for `id_result` after SimplifyBranchSame - fn id_result(_1: Result) -> Result { + fn id_result(_1: std::result::Result) -> std::result::Result { debug r => _1; // in scope 0 at $DIR/simplify-arm.rs:16:14: 16:15 let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify-arm.rs:16:37: 16:52 let mut _2: isize; // in scope 0 at $DIR/simplify-arm.rs:18:9: 18:14 diff --git a/src/test/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff index ccb3b71817ff6..84d8214122ae1 100644 --- a/src/test/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff @@ -1,7 +1,7 @@ - // MIR for `id_try` before SimplifyArmIdentity + // MIR for `id_try` after SimplifyArmIdentity - fn id_try(_1: Result) -> Result { + fn id_try(_1: std::result::Result) -> std::result::Result { debug r => _1; // in scope 0 at $DIR/simplify-arm.rs:23:11: 23:12 let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify-arm.rs:23:34: 23:49 let _2: u8; // in scope 0 at $DIR/simplify-arm.rs:24:9: 24:10 @@ -26,7 +26,7 @@ - debug t => _9; // in scope 7 at $DIR/simplify-arm.rs:24:14: 24:15 + debug t => ((_0 as Err).0: i32); // in scope 7 at $DIR/simplify-arm.rs:24:14: 24:15 } - scope 8 (inlined as Try>::from_error) { // at $DIR/simplify-arm.rs:24:13: 24:15 + scope 8 (inlined as Try>::from_error) { // at $DIR/simplify-arm.rs:24:13: 24:15 - debug v => _8; // in scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 + debug v => ((_0 as Err).0: i32); // in scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 let mut _12: i32; // in scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 @@ -39,7 +39,7 @@ scope 5 { } } - scope 6 (inlined as Try>::into_result) { // at $DIR/simplify-arm.rs:24:13: 24:15 + scope 6 (inlined as Try>::into_result) { // at $DIR/simplify-arm.rs:24:13: 24:15 debug self => _4; // in scope 6 at $DIR/simplify-arm.rs:24:13: 24:15 } diff --git a/src/test/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff b/src/test/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff index ec8ac30228e59..aa050655cdaa5 100644 --- a/src/test/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff +++ b/src/test/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff @@ -1,7 +1,7 @@ - // MIR for `id_try` before SimplifyBranchSame + // MIR for `id_try` after SimplifyBranchSame - fn id_try(_1: Result) -> Result { + fn id_try(_1: std::result::Result) -> std::result::Result { debug r => _1; // in scope 0 at $DIR/simplify-arm.rs:23:11: 23:12 let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify-arm.rs:23:34: 23:49 let _2: u8; // in scope 0 at $DIR/simplify-arm.rs:24:9: 24:10 @@ -23,7 +23,7 @@ scope 7 (inlined >::from) { // at $DIR/simplify-arm.rs:24:14: 24:15 debug t => ((_0 as Err).0: i32); // in scope 7 at $DIR/simplify-arm.rs:24:14: 24:15 } - scope 8 (inlined as Try>::from_error) { // at $DIR/simplify-arm.rs:24:13: 24:15 + scope 8 (inlined as Try>::from_error) { // at $DIR/simplify-arm.rs:24:13: 24:15 debug v => ((_0 as Err).0: i32); // in scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 let mut _12: i32; // in scope 8 at $DIR/simplify-arm.rs:24:13: 24:15 } @@ -34,7 +34,7 @@ scope 5 { } } - scope 6 (inlined as Try>::into_result) { // at $DIR/simplify-arm.rs:24:13: 24:15 + scope 6 (inlined as Try>::into_result) { // at $DIR/simplify-arm.rs:24:13: 24:15 debug self => _4; // in scope 6 at $DIR/simplify-arm.rs:24:13: 24:15 } diff --git a/src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff b/src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff index b1bae447f9c65..3ba0af991f63b 100644 --- a/src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff +++ b/src/test/mir-opt/simplify_try.try_identity.DestinationPropagation.diff @@ -1,7 +1,7 @@ - // MIR for `try_identity` before DestinationPropagation + // MIR for `try_identity` after DestinationPropagation - fn try_identity(_1: Result) -> Result { + fn try_identity(_1: std::result::Result) -> std::result::Result { debug x => _1; // in scope 0 at $DIR/simplify_try.rs:7:17: 7:18 let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify_try.rs:7:41: 7:57 let _2: u32; // in scope 0 at $DIR/simplify_try.rs:8:9: 8:10 @@ -23,7 +23,7 @@ scope 7 (inlined >::from) { // at $DIR/simplify_try.rs:8:14: 8:15 debug t => ((_0 as Err).0: i32); // in scope 7 at $DIR/simplify_try.rs:8:14: 8:15 } - scope 8 (inlined as Try>::from_error) { // at $DIR/simplify_try.rs:8:13: 8:15 + scope 8 (inlined as Try>::from_error) { // at $DIR/simplify_try.rs:8:13: 8:15 debug v => ((_0 as Err).0: i32); // in scope 8 at $DIR/simplify_try.rs:8:13: 8:15 let mut _12: i32; // in scope 8 at $DIR/simplify_try.rs:8:13: 8:15 } @@ -34,7 +34,7 @@ scope 5 { } } - scope 6 (inlined as Try>::into_result) { // at $DIR/simplify_try.rs:8:13: 8:15 + scope 6 (inlined as Try>::into_result) { // at $DIR/simplify_try.rs:8:13: 8:15 - debug self => _4; // in scope 6 at $DIR/simplify_try.rs:8:13: 8:15 + debug self => _0; // in scope 6 at $DIR/simplify_try.rs:8:13: 8:15 } diff --git a/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff index df274852f6820..9c91762eb4e15 100644 --- a/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff +++ b/src/test/mir-opt/simplify_try.try_identity.SimplifyArmIdentity.diff @@ -1,7 +1,7 @@ - // MIR for `try_identity` before SimplifyArmIdentity + // MIR for `try_identity` after SimplifyArmIdentity - fn try_identity(_1: Result) -> Result { + fn try_identity(_1: std::result::Result) -> std::result::Result { debug x => _1; // in scope 0 at $DIR/simplify_try.rs:7:17: 7:18 let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify_try.rs:7:41: 7:57 let _2: u32; // in scope 0 at $DIR/simplify_try.rs:8:9: 8:10 @@ -26,7 +26,7 @@ - debug t => _9; // in scope 7 at $DIR/simplify_try.rs:8:14: 8:15 + debug t => ((_0 as Err).0: i32); // in scope 7 at $DIR/simplify_try.rs:8:14: 8:15 } - scope 8 (inlined as Try>::from_error) { // at $DIR/simplify_try.rs:8:13: 8:15 + scope 8 (inlined as Try>::from_error) { // at $DIR/simplify_try.rs:8:13: 8:15 - debug v => _8; // in scope 8 at $DIR/simplify_try.rs:8:13: 8:15 + debug v => ((_0 as Err).0: i32); // in scope 8 at $DIR/simplify_try.rs:8:13: 8:15 let mut _12: i32; // in scope 8 at $DIR/simplify_try.rs:8:13: 8:15 @@ -39,7 +39,7 @@ scope 5 { } } - scope 6 (inlined as Try>::into_result) { // at $DIR/simplify_try.rs:8:13: 8:15 + scope 6 (inlined as Try>::into_result) { // at $DIR/simplify_try.rs:8:13: 8:15 debug self => _4; // in scope 6 at $DIR/simplify_try.rs:8:13: 8:15 } diff --git a/src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir b/src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir index 37274691fb476..cd8436a971ee8 100644 --- a/src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir +++ b/src/test/mir-opt/simplify_try.try_identity.SimplifyBranchSame.after.mir @@ -1,6 +1,6 @@ // MIR for `try_identity` after SimplifyBranchSame -fn try_identity(_1: Result) -> Result { +fn try_identity(_1: std::result::Result) -> std::result::Result { debug x => _1; // in scope 0 at $DIR/simplify_try.rs:7:17: 7:18 let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify_try.rs:7:41: 7:57 let _2: u32; // in scope 0 at $DIR/simplify_try.rs:8:9: 8:10 @@ -22,7 +22,7 @@ fn try_identity(_1: Result) -> Result { scope 7 (inlined >::from) { // at $DIR/simplify_try.rs:8:14: 8:15 debug t => ((_0 as Err).0: i32); // in scope 7 at $DIR/simplify_try.rs:8:14: 8:15 } - scope 8 (inlined as Try>::from_error) { // at $DIR/simplify_try.rs:8:13: 8:15 + scope 8 (inlined as Try>::from_error) { // at $DIR/simplify_try.rs:8:13: 8:15 debug v => ((_0 as Err).0: i32); // in scope 8 at $DIR/simplify_try.rs:8:13: 8:15 let mut _12: i32; // in scope 8 at $DIR/simplify_try.rs:8:13: 8:15 } @@ -33,7 +33,7 @@ fn try_identity(_1: Result) -> Result { scope 5 { } } - scope 6 (inlined as Try>::into_result) { // at $DIR/simplify_try.rs:8:13: 8:15 + scope 6 (inlined as Try>::into_result) { // at $DIR/simplify_try.rs:8:13: 8:15 debug self => _4; // in scope 6 at $DIR/simplify_try.rs:8:13: 8:15 } diff --git a/src/test/mir-opt/simplify_try.try_identity.SimplifyLocals.after.mir b/src/test/mir-opt/simplify_try.try_identity.SimplifyLocals.after.mir index f8adcced4b306..73f77f35a2b92 100644 --- a/src/test/mir-opt/simplify_try.try_identity.SimplifyLocals.after.mir +++ b/src/test/mir-opt/simplify_try.try_identity.SimplifyLocals.after.mir @@ -1,6 +1,6 @@ // MIR for `try_identity` after SimplifyLocals -fn try_identity(_1: Result) -> Result { +fn try_identity(_1: std::result::Result) -> std::result::Result { debug x => _1; // in scope 0 at $DIR/simplify_try.rs:7:17: 7:18 let mut _0: std::result::Result; // return place in scope 0 at $DIR/simplify_try.rs:7:41: 7:57 scope 1 { @@ -12,7 +12,7 @@ fn try_identity(_1: Result) -> Result { scope 7 (inlined >::from) { // at $DIR/simplify_try.rs:8:14: 8:15 debug t => ((_0 as Err).0: i32); // in scope 7 at $DIR/simplify_try.rs:8:14: 8:15 } - scope 8 (inlined as Try>::from_error) { // at $DIR/simplify_try.rs:8:13: 8:15 + scope 8 (inlined as Try>::from_error) { // at $DIR/simplify_try.rs:8:13: 8:15 debug v => ((_0 as Err).0: i32); // in scope 8 at $DIR/simplify_try.rs:8:13: 8:15 } } @@ -22,7 +22,7 @@ fn try_identity(_1: Result) -> Result { scope 5 { } } - scope 6 (inlined as Try>::into_result) { // at $DIR/simplify_try.rs:8:13: 8:15 + scope 6 (inlined as Try>::into_result) { // at $DIR/simplify_try.rs:8:13: 8:15 debug self => _0; // in scope 6 at $DIR/simplify_try.rs:8:13: 8:15 } diff --git a/src/test/mir-opt/uniform_array_move_out.move_out_by_subslice.mir_map.0.mir b/src/test/mir-opt/uniform_array_move_out.move_out_by_subslice.mir_map.0.mir index d18f6308ded84..9bca5d24605fb 100644 --- a/src/test/mir-opt/uniform_array_move_out.move_out_by_subslice.mir_map.0.mir +++ b/src/test/mir-opt/uniform_array_move_out.move_out_by_subslice.mir_map.0.mir @@ -22,62 +22,38 @@ fn move_out_by_subslice() -> () { _3 = Box(i32); // scope 0 at $DIR/uniform_array_move_out.rs:11:14: 11:19 (*_3) = const 1_i32; // scope 0 at $DIR/uniform_array_move_out.rs:11:18: 11:19 _2 = move _3; // scope 0 at $DIR/uniform_array_move_out.rs:11:14: 11:19 - drop(_3) -> [return: bb1, unwind: bb9]; // scope 0 at $DIR/uniform_array_move_out.rs:11:18: 11:19 - } - - bb1: { StorageDead(_3); // scope 0 at $DIR/uniform_array_move_out.rs:11:18: 11:19 StorageLive(_4); // scope 0 at $DIR/uniform_array_move_out.rs:11:21: 11:26 StorageLive(_5); // scope 0 at $DIR/uniform_array_move_out.rs:11:21: 11:26 _5 = Box(i32); // scope 0 at $DIR/uniform_array_move_out.rs:11:21: 11:26 (*_5) = const 2_i32; // scope 0 at $DIR/uniform_array_move_out.rs:11:25: 11:26 _4 = move _5; // scope 0 at $DIR/uniform_array_move_out.rs:11:21: 11:26 - drop(_5) -> [return: bb2, unwind: bb8]; // scope 0 at $DIR/uniform_array_move_out.rs:11:25: 11:26 - } - - bb2: { StorageDead(_5); // scope 0 at $DIR/uniform_array_move_out.rs:11:25: 11:26 _1 = [move _2, move _4]; // scope 0 at $DIR/uniform_array_move_out.rs:11:13: 11:27 - drop(_4) -> [return: bb3, unwind: bb9]; // scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27 - } - - bb3: { StorageDead(_4); // scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27 - drop(_2) -> [return: bb4, unwind: bb10]; // scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27 - } - - bb4: { StorageDead(_2); // scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27 FakeRead(ForLet, _1); // scope 0 at $DIR/uniform_array_move_out.rs:11:9: 11:10 StorageLive(_6); // scope 1 at $DIR/uniform_array_move_out.rs:12:10: 12:17 _6 = move _1[0..2]; // scope 1 at $DIR/uniform_array_move_out.rs:12:10: 12:17 _0 = const (); // scope 0 at $DIR/uniform_array_move_out.rs:10:27: 13:2 - drop(_6) -> [return: bb5, unwind: bb7]; // scope 1 at $DIR/uniform_array_move_out.rs:13:1: 13:2 + drop(_6) -> [return: bb1, unwind: bb3]; // scope 1 at $DIR/uniform_array_move_out.rs:13:1: 13:2 } - bb5: { + bb1: { StorageDead(_6); // scope 1 at $DIR/uniform_array_move_out.rs:13:1: 13:2 - drop(_1) -> [return: bb6, unwind: bb10]; // scope 0 at $DIR/uniform_array_move_out.rs:13:1: 13:2 + drop(_1) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/uniform_array_move_out.rs:13:1: 13:2 } - bb6: { + bb2: { StorageDead(_1); // scope 0 at $DIR/uniform_array_move_out.rs:13:1: 13:2 return; // scope 0 at $DIR/uniform_array_move_out.rs:13:2: 13:2 } - bb7 (cleanup): { - drop(_1) -> bb10; // scope 0 at $DIR/uniform_array_move_out.rs:13:1: 13:2 - } - - bb8 (cleanup): { - drop(_4) -> bb9; // scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27 - } - - bb9 (cleanup): { - drop(_2) -> bb10; // scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27 + bb3 (cleanup): { + drop(_1) -> bb4; // scope 0 at $DIR/uniform_array_move_out.rs:13:1: 13:2 } - bb10 (cleanup): { + bb4 (cleanup): { resume; // scope 0 at $DIR/uniform_array_move_out.rs:10:1: 13:2 } } diff --git a/src/test/mir-opt/uniform_array_move_out.move_out_from_end.mir_map.0.mir b/src/test/mir-opt/uniform_array_move_out.move_out_from_end.mir_map.0.mir index eda8e5fd3afe7..c9004416f2ec1 100644 --- a/src/test/mir-opt/uniform_array_move_out.move_out_from_end.mir_map.0.mir +++ b/src/test/mir-opt/uniform_array_move_out.move_out_from_end.mir_map.0.mir @@ -22,62 +22,38 @@ fn move_out_from_end() -> () { _3 = Box(i32); // scope 0 at $DIR/uniform_array_move_out.rs:5:14: 5:19 (*_3) = const 1_i32; // scope 0 at $DIR/uniform_array_move_out.rs:5:18: 5:19 _2 = move _3; // scope 0 at $DIR/uniform_array_move_out.rs:5:14: 5:19 - drop(_3) -> [return: bb1, unwind: bb9]; // scope 0 at $DIR/uniform_array_move_out.rs:5:18: 5:19 - } - - bb1: { StorageDead(_3); // scope 0 at $DIR/uniform_array_move_out.rs:5:18: 5:19 StorageLive(_4); // scope 0 at $DIR/uniform_array_move_out.rs:5:21: 5:26 StorageLive(_5); // scope 0 at $DIR/uniform_array_move_out.rs:5:21: 5:26 _5 = Box(i32); // scope 0 at $DIR/uniform_array_move_out.rs:5:21: 5:26 (*_5) = const 2_i32; // scope 0 at $DIR/uniform_array_move_out.rs:5:25: 5:26 _4 = move _5; // scope 0 at $DIR/uniform_array_move_out.rs:5:21: 5:26 - drop(_5) -> [return: bb2, unwind: bb8]; // scope 0 at $DIR/uniform_array_move_out.rs:5:25: 5:26 - } - - bb2: { StorageDead(_5); // scope 0 at $DIR/uniform_array_move_out.rs:5:25: 5:26 _1 = [move _2, move _4]; // scope 0 at $DIR/uniform_array_move_out.rs:5:13: 5:27 - drop(_4) -> [return: bb3, unwind: bb9]; // scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27 - } - - bb3: { StorageDead(_4); // scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27 - drop(_2) -> [return: bb4, unwind: bb10]; // scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27 - } - - bb4: { StorageDead(_2); // scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27 FakeRead(ForLet, _1); // scope 0 at $DIR/uniform_array_move_out.rs:5:9: 5:10 StorageLive(_6); // scope 1 at $DIR/uniform_array_move_out.rs:6:14: 6:16 _6 = move _1[1 of 2]; // scope 1 at $DIR/uniform_array_move_out.rs:6:14: 6:16 _0 = const (); // scope 0 at $DIR/uniform_array_move_out.rs:4:24: 7:2 - drop(_6) -> [return: bb5, unwind: bb7]; // scope 1 at $DIR/uniform_array_move_out.rs:7:1: 7:2 + drop(_6) -> [return: bb1, unwind: bb3]; // scope 1 at $DIR/uniform_array_move_out.rs:7:1: 7:2 } - bb5: { + bb1: { StorageDead(_6); // scope 1 at $DIR/uniform_array_move_out.rs:7:1: 7:2 - drop(_1) -> [return: bb6, unwind: bb10]; // scope 0 at $DIR/uniform_array_move_out.rs:7:1: 7:2 + drop(_1) -> [return: bb2, unwind: bb4]; // scope 0 at $DIR/uniform_array_move_out.rs:7:1: 7:2 } - bb6: { + bb2: { StorageDead(_1); // scope 0 at $DIR/uniform_array_move_out.rs:7:1: 7:2 return; // scope 0 at $DIR/uniform_array_move_out.rs:7:2: 7:2 } - bb7 (cleanup): { - drop(_1) -> bb10; // scope 0 at $DIR/uniform_array_move_out.rs:7:1: 7:2 - } - - bb8 (cleanup): { - drop(_4) -> bb9; // scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27 - } - - bb9 (cleanup): { - drop(_2) -> bb10; // scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27 + bb3 (cleanup): { + drop(_1) -> bb4; // scope 0 at $DIR/uniform_array_move_out.rs:7:1: 7:2 } - bb10 (cleanup): { + bb4 (cleanup): { resume; // scope 0 at $DIR/uniform_array_move_out.rs:4:1: 7:2 } } diff --git a/src/test/pretty/macro_rules.rs b/src/test/pretty/macro_rules.rs deleted file mode 100644 index da223d164f9b0..0000000000000 --- a/src/test/pretty/macro_rules.rs +++ /dev/null @@ -1,19 +0,0 @@ -// pp-exact - -macro_rules! brace { () => { } ; } - -macro_rules! bracket[() => { } ;]; - -macro_rules! paren(() => { } ;); - -macro_rules! matcher_brackets { - (paren) => { } ; (bracket) => { } ; (brace) => { } ; -} - -macro_rules! all_fragments { - ($ b : block, $ e : expr, $ i : ident, $ it : item, $ l : lifetime, $ lit - : literal, $ m : meta, $ p : pat, $ pth : path, $ s : stmt, $ tt : tt, $ - ty : ty, $ vis : vis) => { } ; -} - -fn main() { } diff --git a/src/test/run-make-fulldeps/coverage-llvmir/Makefile b/src/test/run-make-fulldeps/coverage-llvmir/Makefile index 7d9121ee2f834..54fc3d168645f 100644 --- a/src/test/run-make-fulldeps/coverage-llvmir/Makefile +++ b/src/test/run-make-fulldeps/coverage-llvmir/Makefile @@ -1,5 +1,4 @@ # needs-profiler-support -# min-llvm-version: 11.0 -include ../coverage/coverage_tools.mk @@ -49,7 +48,12 @@ else -DINSTR_PROF_ORDERFILE='$(DATA_SECTION_PREFIX)__llvm_orderfile' endif +ifeq ($(LLVM_VERSION_11_PLUS),true) all: test_llvm_ir +else +$(info Rust option `-Z instrument-coverage` requires LLVM 11 or higher. Test skipped.) +all: +endif test_llvm_ir: # Compile the test program with non-experimental coverage instrumentation, and generate LLVM IR diff --git a/src/test/run-make-fulldeps/coverage-reports/Makefile b/src/test/run-make-fulldeps/coverage-reports/Makefile index a700cf68cd9da..f98245b4a9944 100644 --- a/src/test/run-make-fulldeps/coverage-reports/Makefile +++ b/src/test/run-make-fulldeps/coverage-reports/Makefile @@ -1,7 +1,5 @@ -# ignore-test Broken; accidentally silently ignored on Linux CI; FIXME(#81688) # needs-profiler-support # ignore-windows-gnu -# min-llvm-version: 11.0 # FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works # properly. Since we only have GCC on the CI ignore the test for now. @@ -69,7 +67,12 @@ ifdef RUSTC_BLESS_TEST DEBUG_FLAG=--debug endif +ifeq ($(LLVM_VERSION_11_PLUS),true) all: $(patsubst $(SOURCEDIR)/lib/%.rs,%,$(wildcard $(SOURCEDIR)/lib/*.rs)) $(patsubst $(SOURCEDIR)/%.rs,%,$(wildcard $(SOURCEDIR)/*.rs)) +else +$(info Rust option `-Z instrument-coverage` requires LLVM 11 or higher. Test skipped.) +all: +endif # Ensure there are no `expected` results for tests that may have been removed or renamed .PHONY: clear_expected_if_blessed diff --git a/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.uses_crate.txt b/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.uses_crate.txt index e14e733fff6d4..4c03e950af029 100644 --- a/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.uses_crate.txt +++ b/src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.uses_crate.txt @@ -19,12 +19,12 @@ 18| 2| println!("used_only_from_bin_crate_generic_function with {:?}", arg); 19| 2|} ------------------ - | used_crate::used_only_from_bin_crate_generic_function::<&str>: + | used_crate::used_only_from_bin_crate_generic_function::<&alloc::vec::Vec>: | 17| 1|pub fn used_only_from_bin_crate_generic_function(arg: T) { | 18| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg); | 19| 1|} ------------------ - | used_crate::used_only_from_bin_crate_generic_function::<&alloc::vec::Vec>: + | used_crate::used_only_from_bin_crate_generic_function::<&str>: | 17| 1|pub fn used_only_from_bin_crate_generic_function(arg: T) { | 18| 1| println!("used_only_from_bin_crate_generic_function with {:?}", arg); | 19| 1|} diff --git a/src/test/run-make-fulldeps/coverage-spanview/Makefile b/src/test/run-make-fulldeps/coverage-spanview/Makefile index cd54ac0ed4c75..84b5d0e522f8c 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/Makefile +++ b/src/test/run-make-fulldeps/coverage-spanview/Makefile @@ -1,5 +1,4 @@ # needs-profiler-support -# min-llvm-version: 11.0 -include ../coverage/coverage_tools.mk @@ -21,7 +20,12 @@ For revisions in Pull Requests (PR): endef export SPANVIEW_HEADER +ifeq ($(LLVM_VERSION_11_PLUS),true) all: $(patsubst $(SOURCEDIR)/lib/%.rs,%,$(wildcard $(SOURCEDIR)/lib/*.rs)) $(patsubst $(SOURCEDIR)/%.rs,%,$(wildcard $(SOURCEDIR)/*.rs)) +else +$(info Rust option `-Z instrument-coverage` requires LLVM 11 or higher. Test skipped.) +all: +endif # Ensure there are no `expected` results for tests that may have been removed or renamed .PHONY: clear_expected_if_blessed @@ -42,7 +46,6 @@ endif echo "--edition=2018" \ ) \ --crate-type rlib \ - -Ztrim-diagnostic-paths=no \ -Zinstrument-coverage \ -Zdump-mir=InstrumentCoverage \ -Zdump-mir-spanview \ @@ -74,7 +77,6 @@ endif echo "--edition=2018" \ ) \ -L "$(TMPDIR)" \ - -Ztrim-diagnostic-paths=no \ -Zinstrument-coverage \ -Zdump-mir=InstrumentCoverage \ -Zdump-mir-spanview \ diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.abort/abort.might_abort.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.abort/abort.might_abort.-------.InstrumentCoverage.0.html index a302b974ae1d2..b058dce298342 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.abort/abort.might_abort.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.abort/abort.might_abort.-------.InstrumentCoverage.0.html @@ -81,10 +81,10 @@ 7:9-7:33: @1[18]: _13 = &(*_32) 7:9-7:33: @1[19]: _12 = &(*_13) 7:9-7:33: @1[20]: _11 = move _12 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -7:9-7:33: @1.Call: _6 = std::fmt::Arguments::new_v1(move _7, move _11) -> [return: bb3, unwind: bb7] -7:9-7:33: @3.Call: _5 = std::io::_print(move _6) -> [return: bb4, unwind: bb7] +7:9-7:33: @1.Call: _6 = Arguments::new_v1(move _7, move _11) -> [return: bb3, unwind: bb7] +7:9-7:33: @3.Call: _5 = _print(move _6) -> [return: bb4, unwind: bb7] 7:9-7:33: @4[5]: _4 = const () -8:9-8:37: @4.Call: std::rt::begin_panic::<&str>(const "panics and aborts") -> bb7">@1,3,4⦊println!("aborting..."); +8:9-8:37: @4.Call: begin_panic::<&str>(const "panics and aborts") -> bb7">@1,3,4⦊println!("aborting..."); panic!("panics and aborts");⦉@1,3,4 +8:9-8:37: @4.Call: begin_panic::<&str>(const "panics and aborts") -> bb7"> panic!("panics and aborts");⦉@1,3,4 } else @2,5,6⦊{ @@ -124,8 +124,8 @@ 10:9-10:33: @2[18]: _27 = &(*_30) 10:9-10:33: @2[19]: _26 = &(*_27) 10:9-10:33: @2[20]: _25 = move _26 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -10:9-10:33: @2.Call: _20 = std::fmt::Arguments::new_v1(move _21, move _25) -> [return: bb5, unwind: bb7] -10:9-10:33: @5.Call: _19 = std::io::_print(move _20) -> [return: bb6, unwind: bb7] +10:9-10:33: @2.Call: _20 = Arguments::new_v1(move _21, move _25) -> [return: bb5, unwind: bb7] +10:9-10:33: @5.Call: _19 = _print(move _20) -> [return: bb6, unwind: bb7] 10:9-10:33: @6[5]: _18 = const () 9:12-11:6: @6[7]: _0 = const () 12:2-12:2: @6.Return: return"> println!("Don't Panic"); @@ -139,8 +139,8 @@ 10:9-10:33: @2[18]: _27 = &(*_30) 10:9-10:33: @2[19]: _26 = &(*_27) 10:9-10:33: @2[20]: _25 = move _26 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -10:9-10:33: @2.Call: _20 = std::fmt::Arguments::new_v1(move _21, move _25) -> [return: bb5, unwind: bb7] -10:9-10:33: @5.Call: _19 = std::io::_print(move _20) -> [return: bb6, unwind: bb7] +10:9-10:33: @2.Call: _20 = Arguments::new_v1(move _21, move _25) -> [return: bb5, unwind: bb7] +10:9-10:33: @5.Call: _19 = _print(move _20) -> [return: bb6, unwind: bb7] 10:9-10:33: @6[5]: _18 = const () 9:12-11:6: @6[7]: _0 = const () 12:2-12:2: @6.Return: return"> } @@ -154,8 +154,8 @@ 10:9-10:33: @2[18]: _27 = &(*_30) 10:9-10:33: @2[19]: _26 = &(*_27) 10:9-10:33: @2[20]: _25 = move _26 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -10:9-10:33: @2.Call: _20 = std::fmt::Arguments::new_v1(move _21, move _25) -> [return: bb5, unwind: bb7] -10:9-10:33: @5.Call: _19 = std::io::_print(move _20) -> [return: bb6, unwind: bb7] +10:9-10:33: @2.Call: _20 = Arguments::new_v1(move _21, move _25) -> [return: bb5, unwind: bb7] +10:9-10:33: @5.Call: _19 = _print(move _20) -> [return: bb6, unwind: bb7] 10:9-10:33: @6[5]: _18 = const () 9:12-11:6: @6[7]: _0 = const () 12:2-12:2: @6.Return: return">}⦉@2,5,6 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.assert/assert.might_fail_assert.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.assert/assert.might_fail_assert.-------.InstrumentCoverage.0.html index b7f3cf0819fc5..823bb0cfd8404 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.assert/assert.might_fail_assert.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.assert/assert.might_fail_assert.-------.InstrumentCoverage.0.html @@ -80,13 +80,13 @@ 5:5-5:48: @0[22]: _15 = (_13.0: &u32) 5:5-5:48: @0[25]: _17 = &(*_15) 5:5-5:48: @0[27]: _18 = <u32 as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r u32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -5:5-5:48: @0.Call: _16 = std::fmt::ArgumentV1::new::<u32>(move _17, move _18) -> [return: bb1, unwind: bb12] +5:5-5:48: @0.Call: _16 = ArgumentV1::new::<u32>(move _17, move _18) -> [return: bb1, unwind: bb12] 5:5-5:48: @1[2]: _12 = [move _16] 5:5-5:48: @1[5]: _11 = &_12 5:5-5:48: @1[6]: _10 = &(*_11) 5:5-5:48: @1[7]: _9 = move _10 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -5:5-5:48: @1.Call: _4 = std::fmt::Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb12] -5:5-5:48: @2.Call: _3 = std::io::_print(move _4) -> [return: bb3, unwind: bb12] +5:5-5:48: @1.Call: _4 = Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb12] +5:5-5:48: @2.Call: _3 = _print(move _4) -> [return: bb3, unwind: bb12] 5:5-5:48: @3[6]: _2 = const ()">@0,1,2,3,4⦊println!("does 1 + 1 = {}?", one_plus_one);⦉@0,1,2,3,4 assert_eq!(@0,1,2,3,4⦊1 + 1⦉@0,1,2,3,4, one_plus_one, @0,1,2,3⦊⦉@0,1,2,3$crate::panicking::panic_fmt($crate::format_args!($fmt, $($arg)+)) +24:38-24:74: @2.Call: _4 = Arguments::new_v1(move _5, move _9) -> [return: bb3, unwind: bb4]">@0,1,2,3⦊⦉@0,1,2,3$crate::panicking::panic_fmt($crate::format_args!($fmt, $($arg)+)) diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.executor-block_on-VTABLE-{closure#1}.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.executor-block_on-VTABLE-{closure#1}.-------.InstrumentCoverage.0.html index 1bbcfa5744b6b..828b9cebd6ae6 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.executor-block_on-VTABLE-{closure#1}.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.executor-block_on-VTABLE-{closure#1}.-------.InstrumentCoverage.0.html @@ -73,12 +73,12 @@ 24:38-24:74: @1[5]: FakeRead(ForMatchedPlace, _13) 24:38-24:74: @1[7]: _25 = (_13.0: &std::fmt::Arguments) 24:38-24:74: @1[10]: _27 = &(*_25) -24:38-24:74: @1[12]: _28 = <std::fmt::Arguments as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::fmt::Arguments, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -24:38-24:74: @1.Call: _26 = std::fmt::ArgumentV1::new::<std::fmt::Arguments>(move _27, move _28) -> [return: bb2, unwind: bb4] +24:38-24:74: @1[12]: _28 = <Arguments as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::fmt::Arguments, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +24:38-24:74: @1.Call: _26 = ArgumentV1::new::<Arguments>(move _27, move _28) -> [return: bb2, unwind: bb4] 24:38-24:74: @2[2]: _12 = [move _26] 24:38-24:74: @2[5]: _11 = &_12 24:38-24:74: @2[6]: _10 = &(*_11) 24:38-24:74: @2[7]: _9 = move _10 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -24:38-24:74: @2.Call: _4 = std::fmt::Arguments::new_v1(move _5, move _9) -> [return: bb3, unwind: bb4]">@0,1,2,3⦊⦉@0,1,2,3$crate::panicking::panic_fmt($crate::format_args!($fmt, $($arg)+)) +24:38-24:74: @2.Call: _4 = Arguments::new_v1(move _5, move _9) -> [return: bb3, unwind: bb4]">@0,1,2,3⦊⦉@0,1,2,3$crate::panicking::panic_fmt($crate::format_args!($fmt, $($arg)+)) diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.executor-block_on-VTABLE-{closure#2}.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.executor-block_on-VTABLE-{closure#2}.-------.InstrumentCoverage.0.html index 14cb98d20c988..28b10e59b5a3f 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.executor-block_on-VTABLE-{closure#2}.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.executor-block_on-VTABLE-{closure#2}.-------.InstrumentCoverage.0.html @@ -73,12 +73,12 @@ 24:38-24:74: @1[5]: FakeRead(ForMatchedPlace, _13) 24:38-24:74: @1[7]: _25 = (_13.0: &std::fmt::Arguments) 24:38-24:74: @1[10]: _27 = &(*_25) -24:38-24:74: @1[12]: _28 = <std::fmt::Arguments as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::fmt::Arguments, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -24:38-24:74: @1.Call: _26 = std::fmt::ArgumentV1::new::<std::fmt::Arguments>(move _27, move _28) -> [return: bb2, unwind: bb4] +24:38-24:74: @1[12]: _28 = <Arguments as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::fmt::Arguments, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +24:38-24:74: @1.Call: _26 = ArgumentV1::new::<Arguments>(move _27, move _28) -> [return: bb2, unwind: bb4] 24:38-24:74: @2[2]: _12 = [move _26] 24:38-24:74: @2[5]: _11 = &_12 24:38-24:74: @2[6]: _10 = &(*_11) 24:38-24:74: @2[7]: _9 = move _10 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -24:38-24:74: @2.Call: _4 = std::fmt::Arguments::new_v1(move _5, move _9) -> [return: bb3, unwind: bb4]">@0,1,2,3⦊⦉@0,1,2,3$crate::panicking::panic_fmt($crate::format_args!($fmt, $($arg)+)) +24:38-24:74: @2.Call: _4 = Arguments::new_v1(move _5, move _9) -> [return: bb3, unwind: bb4]">@0,1,2,3⦊⦉@0,1,2,3$crate::panicking::panic_fmt($crate::format_args!($fmt, $($arg)+)) diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.executor-block_on.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.executor-block_on.-------.InstrumentCoverage.0.html index 9a5bd6e42cd37..19707255d07c7 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.executor-block_on.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.executor-block_on.-------.InstrumentCoverage.0.html @@ -70,166 +70,166 @@
@0,1,2,3,4,5⦊pub fn block_on<F: Future>(mut future: F) -> F::Output { let mut future = unsafe { Pin::new_unchecked(&mut future) }; static VTABLE: RawWakerVTable = RawWakerVTable::new( |_| unimplemented!("clone"), |_| unimplemented!("wake"), |_| unimplemented!("wake_by_ref"), |_| (), ); let waker = unsafe { Waker::from_raw(RawWaker::new(core::ptr::null(), &VTABLE)) }; let mut context = Context::from_waker(&waker)⦉@0,1,2,3,4,5; loop { if let Poll::Ready(@10,12,14,15,16,17⦊val⦉@10,12,14,15,16,17) = @6,7,8,9⦊future.as_mut().poll(&mut context)⦉@6,7,8,9 { break @10,12,14,15,16,17⦊val⦉@10,12,14,15,16,17; }@11,13⦊⦉@11,13 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.main.-------.InstrumentCoverage.0.html index b892af0ed37d5..611799161d398 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.async/async.main.-------.InstrumentCoverage.0.html @@ -69,121 +69,121 @@ -
@0,1,2,3,4,5,6,7,8,9,10,11,12,13⦊fn main() { - let _ = g(10); - let _ = h(9); - let mut future = Box::pin(i(8)); - j(7); - l(6); - let _ = m(5); - executor::block_on(future.as_mut()); -}⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13
diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#0}.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#0}.-------.InstrumentCoverage.0.html index 3998295a0525e..b4b171dc955cb 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#0}.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#0}.-------.InstrumentCoverage.0.html @@ -86,11 +86,11 @@ 36:21-38:10: @1[1]: _3 = const ()"> }⦉@1@2⦊⦉@2 @3,4⦊"alt string 2".to_owned() }⦉@3,4
diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#10}.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#10}.-------.InstrumentCoverage.0.html index 3bdfe71b48c27..c1edc3eb929b0 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#10}.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#10}.-------.InstrumentCoverage.0.html @@ -86,11 +86,11 @@ 21:29-23:18: @1[1]: _3 = const ()"> }⦉@1@2⦊⦉@2 @3,4⦊"alt string 1".to_owned() }⦉@3,4 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#11}.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#11}.-------.InstrumentCoverage.0.html index 4b3f04b5a0c7e..24c1cadacac4a 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#11}.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#11}.-------.InstrumentCoverage.0.html @@ -86,11 +86,11 @@ 63:29-65:18: @1[1]: _3 = const ()"> }⦉@1@2⦊⦉@2 @3,4⦊"alt string 3".to_owned() }⦉@3,4 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#1}.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#1}.-------.InstrumentCoverage.0.html index 8ae494178f70b..7a3921c5aec76 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#1}.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#1}.-------.InstrumentCoverage.0.html @@ -86,11 +86,11 @@ 78:21-80:10: @1[1]: _3 = const ()"> }⦉@1@2⦊⦉@2 @3,4⦊"alt string 4".to_owned() }⦉@3,4 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#2}.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#2}.-------.InstrumentCoverage.0.html index ad40ba57d69be..06b817e4318e8 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#2}.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#2}.-------.InstrumentCoverage.0.html @@ -94,13 +94,13 @@ 103:9-103:29: @3[23]: _18 = (_16.0: &&str) 103:9-103:29: @3[26]: _20 = &(*_18) 103:9-103:29: @3[28]: _21 = <&str as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r &str, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -103:9-103:29: @3.Call: _19 = std::fmt::ArgumentV1::new::<&str>(move _20, move _21) -> [return: bb4, unwind: bb8] +103:9-103:29: @3.Call: _19 = ArgumentV1::new::<&str>(move _20, move _21) -> [return: bb4, unwind: bb9] 103:9-103:29: @4[2]: _15 = [move _19] 103:9-103:29: @4[5]: _14 = &_15 103:9-103:29: @4[6]: _13 = &(*_14) 103:9-103:29: @4[7]: _12 = move _13 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -103:9-103:29: @4.Call: _7 = std::fmt::Arguments::new_v1(move _8, move _12) -> [return: bb5, unwind: bb8] -103:9-103:29: @5.Call: _6 = std::fmt::format(move _7) -> [return: bb6, unwind: bb8] +103:9-103:29: @4.Call: _7 = Arguments::new_v1(move _8, move _12) -> [return: bb5, unwind: bb9] +103:9-103:29: @5.Call: _6 = format(move _7) -> [return: bb6, unwind: bb9] 103:9-103:29: @6[1]: FakeRead(ForLet, _6) 103:9-103:29: @6[6]: _0 = move _6 104:6-104:6: @7.Return: return">@3,4,5,6,7⦊format!("'{}'", val) @@ -114,13 +114,13 @@ 103:9-103:29: @3[23]: _18 = (_16.0: &&str) 103:9-103:29: @3[26]: _20 = &(*_18) 103:9-103:29: @3[28]: _21 = <&str as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r &str, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -103:9-103:29: @3.Call: _19 = std::fmt::ArgumentV1::new::<&str>(move _20, move _21) -> [return: bb4, unwind: bb8] +103:9-103:29: @3.Call: _19 = ArgumentV1::new::<&str>(move _20, move _21) -> [return: bb4, unwind: bb9] 103:9-103:29: @4[2]: _15 = [move _19] 103:9-103:29: @4[5]: _14 = &_15 103:9-103:29: @4[6]: _13 = &(*_14) 103:9-103:29: @4[7]: _12 = move _13 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -103:9-103:29: @4.Call: _7 = std::fmt::Arguments::new_v1(move _8, move _12) -> [return: bb5, unwind: bb8] -103:9-103:29: @5.Call: _6 = std::fmt::format(move _7) -> [return: bb6, unwind: bb8] +103:9-103:29: @4.Call: _7 = Arguments::new_v1(move _8, move _12) -> [return: bb5, unwind: bb9] +103:9-103:29: @5.Call: _6 = format(move _7) -> [return: bb6, unwind: bb9] 103:9-103:29: @6[1]: FakeRead(ForLet, _6) 103:9-103:29: @6[6]: _0 = move _6 104:6-104:6: @7.Return: return"> }⦉@3,4,5,6,7 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#3}.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#3}.-------.InstrumentCoverage.0.html index 23101d76a8ef4..0940775840093 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#3}.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#3}.-------.InstrumentCoverage.0.html @@ -81,11 +81,11 @@ 124:21-126:10: @1[1]: _3 = const ()"> }⦉@1@2⦊⦉@2 @3,4⦊"closure should be unused".to_owned() }⦉@3,4 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#5}.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#5}.-------.InstrumentCoverage.0.html index 8ba7a6187fdb4..9ff7a13522af5 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#5}.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#5}.-------.InstrumentCoverage.0.html @@ -79,8 +79,8 @@ 112:28-112:61: @0[17]: _11 = &(*_14) 112:28-112:61: @0[18]: _10 = &(*_11) 112:28-112:61: @0[19]: _9 = move _10 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -112:28-112:61: @0.Call: _4 = std::fmt::Arguments::new_v1(move _5, move _9) -> [return: bb1, unwind: bb3] -112:9-112:62: @1.Call: _3 = std::io::_print(move _4) -> [return: bb2, unwind: bb3] +112:28-112:61: @0.Call: _4 = Arguments::new_v1(move _5, move _9) -> [return: bb1, unwind: bb3] +112:9-112:62: @1.Call: _3 = _print(move _4) -> [return: bb2, unwind: bb3] 111:23-113:6: @2[5]: _0 = const () 111:23-113:6: @2.Return: return">@0,1,2⦊{ $crate::io::_print($crate::format_args_nl!($($arg)*)); }⦉@0,1,2 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#6}.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#6}.-------.InstrumentCoverage.0.html index 74c75c6c46ca2..d479211aa37e5 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#6}.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#6}.-------.InstrumentCoverage.0.html @@ -79,8 +79,8 @@ 141:61-141:83: @0[17]: _11 = &(*_14) 141:61-141:83: @0[18]: _10 = &(*_11) 141:61-141:83: @0[19]: _9 = move _10 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -141:61-141:83: @0.Call: _4 = std::fmt::Arguments::new_v1(move _5, move _9) -> [return: bb1, unwind: bb3] -141:61-141:83: @1.Call: _3 = std::io::_print(move _4) -> [return: bb2, unwind: bb3] +141:61-141:83: @0.Call: _4 = Arguments::new_v1(move _5, move _9) -> [return: bb1, unwind: bb3] +141:61-141:83: @1.Call: _3 = _print(move _4) -> [return: bb2, unwind: bb3] 141:61-141:83: @2[5]: _0 = const () 141:85-141:85: @2.Return: return">@0,1,2⦊{ println!("not called") }⦉@0,1,2 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#7}.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#7}.-------.InstrumentCoverage.0.html index 386fb1b9e6f95..2734c0b24688c 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#7}.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#7}.-------.InstrumentCoverage.0.html @@ -79,8 +79,8 @@ 144:9-144:31: @0[17]: _11 = &(*_14) 144:9-144:31: @0[18]: _10 = &(*_11) 144:9-144:31: @0[19]: _9 = move _10 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -144:9-144:31: @0.Call: _4 = std::fmt::Arguments::new_v1(move _5, move _9) -> [return: bb1, unwind: bb3] -144:9-144:31: @1.Call: _3 = std::io::_print(move _4) -> [return: bb2, unwind: bb3] +144:9-144:31: @0.Call: _4 = Arguments::new_v1(move _5, move _9) -> [return: bb1, unwind: bb3] +144:9-144:31: @1.Call: _3 = _print(move _4) -> [return: bb2, unwind: bb3] 144:9-144:31: @2[5]: _0 = const () 145:6-145:6: @2.Return: return">@0,1,2⦊{ println!("not called") }⦉@0,1,2 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#8}.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#8}.-------.InstrumentCoverage.0.html index f9da6ac9dfc34..a032df54ea21c 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#8}.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#8}.-------.InstrumentCoverage.0.html @@ -81,8 +81,8 @@ 149:9-149:31: @0[17]: _11 = &(*_14) 149:9-149:31: @0[18]: _10 = &(*_11) 149:9-149:31: @0[19]: _9 = move _10 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -149:9-149:31: @0.Call: _4 = std::fmt::Arguments::new_v1(move _5, move _9) -> [return: bb1, unwind: bb3] -149:9-149:31: @1.Call: _3 = std::io::_print(move _4) -> [return: bb2, unwind: bb3] +149:9-149:31: @0.Call: _4 = Arguments::new_v1(move _5, move _9) -> [return: bb1, unwind: bb3] +149:9-149:31: @1.Call: _3 = _print(move _4) -> [return: bb2, unwind: bb3] 149:9-149:31: @2[5]: _0 = const () 149:33-149:33: @2.Return: return">@0,1,2⦊{ println!("not called") }⦉@0,1,2 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#9}.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#9}.-------.InstrumentCoverage.0.html index e259fc9bb67e7..3c174e03ebe35 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#9}.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main-{closure#9}.-------.InstrumentCoverage.0.html @@ -81,8 +81,8 @@ 153:9-153:31: @0[17]: _11 = &(*_14) 153:9-153:31: @0[18]: _10 = &(*_11) 153:9-153:31: @0[19]: _9 = move _10 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -153:9-153:31: @0.Call: _4 = std::fmt::Arguments::new_v1(move _5, move _9) -> [return: bb1, unwind: bb3] -153:9-153:31: @1.Call: _3 = std::io::_print(move _4) -> [return: bb2, unwind: bb3] +153:9-153:31: @0.Call: _4 = Arguments::new_v1(move _5, move _9) -> [return: bb1, unwind: bb3] +153:9-153:31: @1.Call: _3 = _print(move _4) -> [return: bb2, unwind: bb3] 153:9-153:31: @2[5]: _0 = const () 153:33-153:33: @2.Return: return">@0,1,2⦊{ println!("not called") }⦉@0,1,2 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main.-------.InstrumentCoverage.0.html index a7d1728114ec9..3bd446b0e049d 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.closure/closure.main.-------.InstrumentCoverage.0.html @@ -69,7079 +69,7079 @@ -
@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42⦊fn main() { -@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37⦊fn main() { + // Initialize test constants in a way that cannot be determined at compile time, to ensure - // Initialize test constants in a way that cannot be determined at compile time, to ensure + // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from + // dependent conditions. - // dependent conditions. + let is_true = std::env::args().len() == 1; - let is_true = std::env::args().len() == 1; + let is_false = ! is_true; - let is_false = ! is_true; + - + let mut some_string = Some(String::from("the string content")); - let mut some_string = Some(String::from("the string content")); + println!( - println!( + "The string or alt: {}" - "The string or alt: {}" + , - , + some_string - some_string + . - . + unwrap_or_else - unwrap_or_else + ( - ( + ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42|| +10:32-10:66: @3.Call: _8 = <String as From<&str>>::from(const "the string content") -> [return: bb4, unwind: bb45] +10:27-10:67: @4[0]: _7 = Option::<String>::Some(move _8) +10:9-10:24: @4[2]: FakeRead(ForLet, _7) +12:9-12:32: @4[9]: _137 = const main::promoted[4] +12:9-12:32: @4[10]: _14 = &(*_137) +12:9-12:32: @4[11]: _13 = &(*_14) +12:9-12:32: @4[12]: _12 = move _13 as &[&str] (Pointer(Unsize)) +14:9-14:20: @4[22]: _23 = move _7 +14:9-26:10: @4.Call: _22 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:18:13: 25:14]>(move _23, move _24) -> [return: bb5, unwind: bb43] +14:9-26:10: @5[2]: _21 = &_22 +11:5-27:7: @5[3]: _20 = (move _21,) +11:5-27:7: @5[5]: FakeRead(ForMatchedPlace, _20) +11:5-27:7: @5[7]: _26 = (_20.0: &std::string::String) +11:5-27:7: @5[10]: _28 = &(*_26) +11:5-27:7: @5[12]: _29 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +11:5-27:7: @5.Call: _27 = ArgumentV1::new::<String>(move _28, move _29) -> [return: bb6, unwind: bb42] +11:5-27:7: @6[2]: _19 = [move _27] +11:5-27:7: @6[5]: _18 = &_19 +11:5-27:7: @6[6]: _17 = &(*_18) +11:5-27:7: @6[7]: _16 = move _17 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +11:5-27:7: @6.Call: _11 = Arguments::new_v1(move _12, move _16) -> [return: bb7, unwind: bb42] +11:5-27:7: @7.Call: _10 = _print(move _11) -> [return: bb8, unwind: bb42] +11:5-27:7: @9[6]: _9 = const () +3:11-155:2: @36[38]: _0 = const ()"> ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37|| { let mut countdown = 0; if is_false { countdown = 10; } "alt string 1".to_owned() - } }@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42⦊ -@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37⦊ + ) - ) + ); - ); + - + some_string = Some(String::from("the string content")); - some_string = Some(String::from("the string content")); + let - let + a - a + = - = + ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42|| +10:32-10:66: @3.Call: _8 = <String as From<&str>>::from(const "the string content") -> [return: bb4, unwind: bb45] +10:27-10:67: @4[0]: _7 = Option::<String>::Some(move _8) +10:9-10:24: @4[2]: FakeRead(ForLet, _7) +12:9-12:32: @4[9]: _137 = const main::promoted[4] +12:9-12:32: @4[10]: _14 = &(*_137) +12:9-12:32: @4[11]: _13 = &(*_14) +12:9-12:32: @4[12]: _12 = move _13 as &[&str] (Pointer(Unsize)) +14:9-14:20: @4[22]: _23 = move _7 +14:9-26:10: @4.Call: _22 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:18:13: 25:14]>(move _23, move _24) -> [return: bb5, unwind: bb43] +14:9-26:10: @5[2]: _21 = &_22 +11:5-27:7: @5[3]: _20 = (move _21,) +11:5-27:7: @5[5]: FakeRead(ForMatchedPlace, _20) +11:5-27:7: @5[7]: _26 = (_20.0: &std::string::String) +11:5-27:7: @5[10]: _28 = &(*_26) +11:5-27:7: @5[12]: _29 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +11:5-27:7: @5.Call: _27 = ArgumentV1::new::<String>(move _28, move _29) -> [return: bb6, unwind: bb42] +11:5-27:7: @6[2]: _19 = [move _27] +11:5-27:7: @6[5]: _18 = &_19 +11:5-27:7: @6[6]: _17 = &(*_18) +11:5-27:7: @6[7]: _16 = move _17 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +11:5-27:7: @6.Call: _11 = Arguments::new_v1(move _12, move _16) -> [return: bb7, unwind: bb42] +11:5-27:7: @7.Call: _10 = _print(move _11) -> [return: bb8, unwind: bb42] +11:5-27:7: @9[6]: _9 = const () +29:24-29:58: @9.Call: _31 = <String as From<&str>>::from(const "the string content") -> [return: bb10, unwind: bb43] +29:19-29:59: @10[0]: _30 = Option::<String>::Some(move _31) +33:9-40:6: @11[3]: _33 = &_5 +31:9-31:10: @11[6]: FakeRead(ForLet, _32) +3:11-155:2: @36[38]: _0 = const ()"> ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37|| { let mut countdown = 0; if is_false { countdown = 10; } "alt string 2".to_owned() - } }@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42⦊; -@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37⦊; + println!( - println!( + "The string or alt: {}" - "The string or alt: {}" + , - , + some_string - some_string + . - . + unwrap_or_else - unwrap_or_else + ( - ( + a - a + ) - ) + ); - ); + - + some_string = None; - some_string = None; + println!( - println!( + "The string or alt: {}" - "The string or alt: {}" + , - , + some_string - some_string + . - . + unwrap_or_else - unwrap_or_else + ( - ( + ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42|| +10:32-10:66: @3.Call: _8 = <String as From<&str>>::from(const "the string content") -> [return: bb4, unwind: bb45] +10:27-10:67: @4[0]: _7 = Option::<String>::Some(move _8) +10:9-10:24: @4[2]: FakeRead(ForLet, _7) +12:9-12:32: @4[9]: _137 = const main::promoted[4] +12:9-12:32: @4[10]: _14 = &(*_137) +12:9-12:32: @4[11]: _13 = &(*_14) +12:9-12:32: @4[12]: _12 = move _13 as &[&str] (Pointer(Unsize)) +14:9-14:20: @4[22]: _23 = move _7 +14:9-26:10: @4.Call: _22 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:18:13: 25:14]>(move _23, move _24) -> [return: bb5, unwind: bb43] +14:9-26:10: @5[2]: _21 = &_22 +11:5-27:7: @5[3]: _20 = (move _21,) +11:5-27:7: @5[5]: FakeRead(ForMatchedPlace, _20) +11:5-27:7: @5[7]: _26 = (_20.0: &std::string::String) +11:5-27:7: @5[10]: _28 = &(*_26) +11:5-27:7: @5[12]: _29 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +11:5-27:7: @5.Call: _27 = ArgumentV1::new::<String>(move _28, move _29) -> [return: bb6, unwind: bb42] +11:5-27:7: @6[2]: _19 = [move _27] +11:5-27:7: @6[5]: _18 = &_19 +11:5-27:7: @6[6]: _17 = &(*_18) +11:5-27:7: @6[7]: _16 = move _17 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +11:5-27:7: @6.Call: _11 = Arguments::new_v1(move _12, move _16) -> [return: bb7, unwind: bb42] +11:5-27:7: @7.Call: _10 = _print(move _11) -> [return: bb8, unwind: bb42] +11:5-27:7: @9[6]: _9 = const () +29:24-29:58: @9.Call: _31 = <String as From<&str>>::from(const "the string content") -> [return: bb10, unwind: bb43] +29:19-29:59: @10[0]: _30 = Option::<String>::Some(move _31) +33:9-40:6: @11[3]: _33 = &_5 +31:9-31:10: @11[6]: FakeRead(ForLet, _32) +42:9-42:32: @11[13]: _136 = const main::promoted[3] +42:9-42:32: @11[14]: _39 = &(*_136) +42:9-42:32: @11[15]: _38 = &(*_39) +42:9-42:32: @11[16]: _37 = move _38 as &[&str] (Pointer(Unsize)) +44:9-44:20: @11[26]: _48 = move _7 +48:13-48:14: @11[28]: _49 = _32 +44:9-49:10: @11.Call: _47 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:33:9: 40:6]>(move _48, move _49) -> [return: bb12, unwind: bb43] +44:9-49:10: @12[2]: _46 = &_47 +41:5-50:7: @12[3]: _45 = (move _46,) +41:5-50:7: @12[5]: FakeRead(ForMatchedPlace, _45) +41:5-50:7: @12[7]: _50 = (_45.0: &std::string::String) +41:5-50:7: @12[10]: _52 = &(*_50) +41:5-50:7: @12[12]: _53 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +41:5-50:7: @12.Call: _51 = ArgumentV1::new::<String>(move _52, move _53) -> [return: bb13, unwind: bb41] +41:5-50:7: @13[2]: _44 = [move _51] +41:5-50:7: @13[5]: _43 = &_44 +41:5-50:7: @13[6]: _42 = &(*_43) +41:5-50:7: @13[7]: _41 = move _42 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +41:5-50:7: @13.Call: _36 = Arguments::new_v1(move _37, move _41) -> [return: bb14, unwind: bb41] +41:5-50:7: @14.Call: _35 = _print(move _36) -> [return: bb15, unwind: bb41] +41:5-50:7: @16[6]: _34 = const () +52:19-52:23: @16[9]: _54 = Option::<String>::None +54:9-54:32: @17[7]: _135 = const main::promoted[2] +54:9-54:32: @17[8]: _60 = &(*_135) +54:9-54:32: @17[9]: _59 = &(*_60) +54:9-54:32: @17[10]: _58 = move _59 as &[&str] (Pointer(Unsize)) +56:9-56:20: @17[20]: _69 = move _7 +56:9-68:10: @17.Call: _68 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:60:13: 67:14]>(move _69, move _70) -> [return: bb18, unwind: bb43] +56:9-68:10: @18[2]: _67 = &_68 +53:5-69:7: @18[3]: _66 = (move _67,) +53:5-69:7: @18[5]: FakeRead(ForMatchedPlace, _66) +53:5-69:7: @18[7]: _72 = (_66.0: &std::string::String) +53:5-69:7: @18[10]: _74 = &(*_72) +53:5-69:7: @18[12]: _75 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +53:5-69:7: @18.Call: _73 = ArgumentV1::new::<String>(move _74, move _75) -> [return: bb19, unwind: bb40] +53:5-69:7: @19[2]: _65 = [move _73] +53:5-69:7: @19[5]: _64 = &_65 +53:5-69:7: @19[6]: _63 = &(*_64) +53:5-69:7: @19[7]: _62 = move _63 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +53:5-69:7: @19.Call: _57 = Arguments::new_v1(move _58, move _62) -> [return: bb20, unwind: bb40] +53:5-69:7: @20.Call: _56 = _print(move _57) -> [return: bb21, unwind: bb40] +53:5-69:7: @22[6]: _55 = const () +3:11-155:2: @36[38]: _0 = const ()"> ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37|| { let mut countdown = 0; if is_false { countdown = 10; } "alt string 3".to_owned() - } }@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42⦊ -@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37⦊ + ) - ) + ); - ); + - + some_string = None; - some_string = None; + let - let + a - a + = - = + ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42|| +10:32-10:66: @3.Call: _8 = <String as From<&str>>::from(const "the string content") -> [return: bb4, unwind: bb45] +10:27-10:67: @4[0]: _7 = Option::<String>::Some(move _8) +10:9-10:24: @4[2]: FakeRead(ForLet, _7) +12:9-12:32: @4[9]: _137 = const main::promoted[4] +12:9-12:32: @4[10]: _14 = &(*_137) +12:9-12:32: @4[11]: _13 = &(*_14) +12:9-12:32: @4[12]: _12 = move _13 as &[&str] (Pointer(Unsize)) +14:9-14:20: @4[22]: _23 = move _7 +14:9-26:10: @4.Call: _22 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:18:13: 25:14]>(move _23, move _24) -> [return: bb5, unwind: bb43] +14:9-26:10: @5[2]: _21 = &_22 +11:5-27:7: @5[3]: _20 = (move _21,) +11:5-27:7: @5[5]: FakeRead(ForMatchedPlace, _20) +11:5-27:7: @5[7]: _26 = (_20.0: &std::string::String) +11:5-27:7: @5[10]: _28 = &(*_26) +11:5-27:7: @5[12]: _29 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +11:5-27:7: @5.Call: _27 = ArgumentV1::new::<String>(move _28, move _29) -> [return: bb6, unwind: bb42] +11:5-27:7: @6[2]: _19 = [move _27] +11:5-27:7: @6[5]: _18 = &_19 +11:5-27:7: @6[6]: _17 = &(*_18) +11:5-27:7: @6[7]: _16 = move _17 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +11:5-27:7: @6.Call: _11 = Arguments::new_v1(move _12, move _16) -> [return: bb7, unwind: bb42] +11:5-27:7: @7.Call: _10 = _print(move _11) -> [return: bb8, unwind: bb42] +11:5-27:7: @9[6]: _9 = const () +29:24-29:58: @9.Call: _31 = <String as From<&str>>::from(const "the string content") -> [return: bb10, unwind: bb43] +29:19-29:59: @10[0]: _30 = Option::<String>::Some(move _31) +33:9-40:6: @11[3]: _33 = &_5 +31:9-31:10: @11[6]: FakeRead(ForLet, _32) +42:9-42:32: @11[13]: _136 = const main::promoted[3] +42:9-42:32: @11[14]: _39 = &(*_136) +42:9-42:32: @11[15]: _38 = &(*_39) +42:9-42:32: @11[16]: _37 = move _38 as &[&str] (Pointer(Unsize)) +44:9-44:20: @11[26]: _48 = move _7 +48:13-48:14: @11[28]: _49 = _32 +44:9-49:10: @11.Call: _47 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:33:9: 40:6]>(move _48, move _49) -> [return: bb12, unwind: bb43] +44:9-49:10: @12[2]: _46 = &_47 +41:5-50:7: @12[3]: _45 = (move _46,) +41:5-50:7: @12[5]: FakeRead(ForMatchedPlace, _45) +41:5-50:7: @12[7]: _50 = (_45.0: &std::string::String) +41:5-50:7: @12[10]: _52 = &(*_50) +41:5-50:7: @12[12]: _53 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +41:5-50:7: @12.Call: _51 = ArgumentV1::new::<String>(move _52, move _53) -> [return: bb13, unwind: bb41] +41:5-50:7: @13[2]: _44 = [move _51] +41:5-50:7: @13[5]: _43 = &_44 +41:5-50:7: @13[6]: _42 = &(*_43) +41:5-50:7: @13[7]: _41 = move _42 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +41:5-50:7: @13.Call: _36 = Arguments::new_v1(move _37, move _41) -> [return: bb14, unwind: bb41] +41:5-50:7: @14.Call: _35 = _print(move _36) -> [return: bb15, unwind: bb41] +41:5-50:7: @16[6]: _34 = const () +52:19-52:23: @16[9]: _54 = Option::<String>::None +54:9-54:32: @17[7]: _135 = const main::promoted[2] +54:9-54:32: @17[8]: _60 = &(*_135) +54:9-54:32: @17[9]: _59 = &(*_60) +54:9-54:32: @17[10]: _58 = move _59 as &[&str] (Pointer(Unsize)) +56:9-56:20: @17[20]: _69 = move _7 +56:9-68:10: @17.Call: _68 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:60:13: 67:14]>(move _69, move _70) -> [return: bb18, unwind: bb43] +56:9-68:10: @18[2]: _67 = &_68 +53:5-69:7: @18[3]: _66 = (move _67,) +53:5-69:7: @18[5]: FakeRead(ForMatchedPlace, _66) +53:5-69:7: @18[7]: _72 = (_66.0: &std::string::String) +53:5-69:7: @18[10]: _74 = &(*_72) +53:5-69:7: @18[12]: _75 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +53:5-69:7: @18.Call: _73 = ArgumentV1::new::<String>(move _74, move _75) -> [return: bb19, unwind: bb40] +53:5-69:7: @19[2]: _65 = [move _73] +53:5-69:7: @19[5]: _64 = &_65 +53:5-69:7: @19[6]: _63 = &(*_64) +53:5-69:7: @19[7]: _62 = move _63 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +53:5-69:7: @19.Call: _57 = Arguments::new_v1(move _58, move _62) -> [return: bb20, unwind: bb40] +53:5-69:7: @20.Call: _56 = _print(move _57) -> [return: bb21, unwind: bb40] +53:5-69:7: @22[6]: _55 = const () +71:19-71:23: @22[9]: _76 = Option::<String>::None +75:9-82:6: @23[3]: _78 = &_5 +73:9-73:10: @23[6]: FakeRead(ForLet, _77) +3:11-155:2: @36[38]: _0 = const ()"> ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37|| { let mut countdown = 0; if is_false { countdown = 10; } "alt string 4".to_owned() - } }@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42⦊; -@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37⦊; + println!( - println!( + "The string or alt: {}" - "The string or alt: {}" + , - , + some_string - some_string + . - . + unwrap_or_else - unwrap_or_else + ( - ( + a - a + ) - ) + ); - ); + - + let - let + quote_closure - quote_closure + = - = + ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42|val| +10:32-10:66: @3.Call: _8 = <String as From<&str>>::from(const "the string content") -> [return: bb4, unwind: bb45] +10:27-10:67: @4[0]: _7 = Option::<String>::Some(move _8) +10:9-10:24: @4[2]: FakeRead(ForLet, _7) +12:9-12:32: @4[9]: _137 = const main::promoted[4] +12:9-12:32: @4[10]: _14 = &(*_137) +12:9-12:32: @4[11]: _13 = &(*_14) +12:9-12:32: @4[12]: _12 = move _13 as &[&str] (Pointer(Unsize)) +14:9-14:20: @4[22]: _23 = move _7 +14:9-26:10: @4.Call: _22 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:18:13: 25:14]>(move _23, move _24) -> [return: bb5, unwind: bb43] +14:9-26:10: @5[2]: _21 = &_22 +11:5-27:7: @5[3]: _20 = (move _21,) +11:5-27:7: @5[5]: FakeRead(ForMatchedPlace, _20) +11:5-27:7: @5[7]: _26 = (_20.0: &std::string::String) +11:5-27:7: @5[10]: _28 = &(*_26) +11:5-27:7: @5[12]: _29 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +11:5-27:7: @5.Call: _27 = ArgumentV1::new::<String>(move _28, move _29) -> [return: bb6, unwind: bb42] +11:5-27:7: @6[2]: _19 = [move _27] +11:5-27:7: @6[5]: _18 = &_19 +11:5-27:7: @6[6]: _17 = &(*_18) +11:5-27:7: @6[7]: _16 = move _17 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +11:5-27:7: @6.Call: _11 = Arguments::new_v1(move _12, move _16) -> [return: bb7, unwind: bb42] +11:5-27:7: @7.Call: _10 = _print(move _11) -> [return: bb8, unwind: bb42] +11:5-27:7: @9[6]: _9 = const () +29:24-29:58: @9.Call: _31 = <String as From<&str>>::from(const "the string content") -> [return: bb10, unwind: bb43] +29:19-29:59: @10[0]: _30 = Option::<String>::Some(move _31) +33:9-40:6: @11[3]: _33 = &_5 +31:9-31:10: @11[6]: FakeRead(ForLet, _32) +42:9-42:32: @11[13]: _136 = const main::promoted[3] +42:9-42:32: @11[14]: _39 = &(*_136) +42:9-42:32: @11[15]: _38 = &(*_39) +42:9-42:32: @11[16]: _37 = move _38 as &[&str] (Pointer(Unsize)) +44:9-44:20: @11[26]: _48 = move _7 +48:13-48:14: @11[28]: _49 = _32 +44:9-49:10: @11.Call: _47 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:33:9: 40:6]>(move _48, move _49) -> [return: bb12, unwind: bb43] +44:9-49:10: @12[2]: _46 = &_47 +41:5-50:7: @12[3]: _45 = (move _46,) +41:5-50:7: @12[5]: FakeRead(ForMatchedPlace, _45) +41:5-50:7: @12[7]: _50 = (_45.0: &std::string::String) +41:5-50:7: @12[10]: _52 = &(*_50) +41:5-50:7: @12[12]: _53 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +41:5-50:7: @12.Call: _51 = ArgumentV1::new::<String>(move _52, move _53) -> [return: bb13, unwind: bb41] +41:5-50:7: @13[2]: _44 = [move _51] +41:5-50:7: @13[5]: _43 = &_44 +41:5-50:7: @13[6]: _42 = &(*_43) +41:5-50:7: @13[7]: _41 = move _42 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +41:5-50:7: @13.Call: _36 = Arguments::new_v1(move _37, move _41) -> [return: bb14, unwind: bb41] +41:5-50:7: @14.Call: _35 = _print(move _36) -> [return: bb15, unwind: bb41] +41:5-50:7: @16[6]: _34 = const () +52:19-52:23: @16[9]: _54 = Option::<String>::None +54:9-54:32: @17[7]: _135 = const main::promoted[2] +54:9-54:32: @17[8]: _60 = &(*_135) +54:9-54:32: @17[9]: _59 = &(*_60) +54:9-54:32: @17[10]: _58 = move _59 as &[&str] (Pointer(Unsize)) +56:9-56:20: @17[20]: _69 = move _7 +56:9-68:10: @17.Call: _68 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:60:13: 67:14]>(move _69, move _70) -> [return: bb18, unwind: bb43] +56:9-68:10: @18[2]: _67 = &_68 +53:5-69:7: @18[3]: _66 = (move _67,) +53:5-69:7: @18[5]: FakeRead(ForMatchedPlace, _66) +53:5-69:7: @18[7]: _72 = (_66.0: &std::string::String) +53:5-69:7: @18[10]: _74 = &(*_72) +53:5-69:7: @18[12]: _75 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +53:5-69:7: @18.Call: _73 = ArgumentV1::new::<String>(move _74, move _75) -> [return: bb19, unwind: bb40] +53:5-69:7: @19[2]: _65 = [move _73] +53:5-69:7: @19[5]: _64 = &_65 +53:5-69:7: @19[6]: _63 = &(*_64) +53:5-69:7: @19[7]: _62 = move _63 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +53:5-69:7: @19.Call: _57 = Arguments::new_v1(move _58, move _62) -> [return: bb20, unwind: bb40] +53:5-69:7: @20.Call: _56 = _print(move _57) -> [return: bb21, unwind: bb40] +53:5-69:7: @22[6]: _55 = const () +71:19-71:23: @22[9]: _76 = Option::<String>::None +75:9-82:6: @23[3]: _78 = &_5 +73:9-73:10: @23[6]: FakeRead(ForLet, _77) +84:9-84:32: @23[13]: _134 = const main::promoted[1] +84:9-84:32: @23[14]: _84 = &(*_134) +84:9-84:32: @23[15]: _83 = &(*_84) +84:9-84:32: @23[16]: _82 = move _83 as &[&str] (Pointer(Unsize)) +86:9-86:20: @23[26]: _93 = move _7 +90:13-90:14: @23[28]: _94 = _77 +86:9-91:10: @23.Call: _92 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:75:9: 82:6]>(move _93, move _94) -> [return: bb24, unwind: bb43] +86:9-91:10: @24[2]: _91 = &_92 +83:5-92:7: @24[3]: _90 = (move _91,) +83:5-92:7: @24[5]: FakeRead(ForMatchedPlace, _90) +83:5-92:7: @24[7]: _95 = (_90.0: &std::string::String) +83:5-92:7: @24[10]: _97 = &(*_95) +83:5-92:7: @24[12]: _98 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +83:5-92:7: @24.Call: _96 = ArgumentV1::new::<String>(move _97, move _98) -> [return: bb25, unwind: bb39] +83:5-92:7: @25[2]: _89 = [move _96] +83:5-92:7: @25[5]: _88 = &_89 +83:5-92:7: @25[6]: _87 = &(*_88) +83:5-92:7: @25[7]: _86 = move _87 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +83:5-92:7: @25.Call: _81 = Arguments::new_v1(move _82, move _86) -> [return: bb26, unwind: bb39] +83:5-92:7: @26.Call: _80 = _print(move _81) -> [return: bb27, unwind: bb39] +83:5-92:7: @28[6]: _79 = const () +97:9-104:6: @28[10]: _100 = &_5 +95:9-95:22: @28[13]: FakeRead(ForLet, _99) +3:11-155:2: @36[38]: _0 = const ()"> ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37|val| { let mut countdown = 0; if is_false { countdown = 10; } format!("'{}'", val) - } }@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42⦊; -@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37⦊; + println!( - println!( + "Repeated, quoted string: {:?}" - "Repeated, quoted string: {:?}" + , - , + std::iter::repeat("repeat me") - std::iter::repeat("repeat me") + .take(5) - .take(5) + .map - .map + ( - ( + quote_closure - quote_closure + ) - ) + .collect::<Vec<_>>() - .collect::<Vec<_>>() + ); - ); + - + let - let + _unused_closure - _unused_closure + = - = + ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42| +10:32-10:66: @3.Call: _8 = <String as From<&str>>::from(const "the string content") -> [return: bb4, unwind: bb45] +10:27-10:67: @4[0]: _7 = Option::<String>::Some(move _8) +10:9-10:24: @4[2]: FakeRead(ForLet, _7) +12:9-12:32: @4[9]: _137 = const main::promoted[4] +12:9-12:32: @4[10]: _14 = &(*_137) +12:9-12:32: @4[11]: _13 = &(*_14) +12:9-12:32: @4[12]: _12 = move _13 as &[&str] (Pointer(Unsize)) +14:9-14:20: @4[22]: _23 = move _7 +14:9-26:10: @4.Call: _22 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:18:13: 25:14]>(move _23, move _24) -> [return: bb5, unwind: bb43] +14:9-26:10: @5[2]: _21 = &_22 +11:5-27:7: @5[3]: _20 = (move _21,) +11:5-27:7: @5[5]: FakeRead(ForMatchedPlace, _20) +11:5-27:7: @5[7]: _26 = (_20.0: &std::string::String) +11:5-27:7: @5[10]: _28 = &(*_26) +11:5-27:7: @5[12]: _29 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +11:5-27:7: @5.Call: _27 = ArgumentV1::new::<String>(move _28, move _29) -> [return: bb6, unwind: bb42] +11:5-27:7: @6[2]: _19 = [move _27] +11:5-27:7: @6[5]: _18 = &_19 +11:5-27:7: @6[6]: _17 = &(*_18) +11:5-27:7: @6[7]: _16 = move _17 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +11:5-27:7: @6.Call: _11 = Arguments::new_v1(move _12, move _16) -> [return: bb7, unwind: bb42] +11:5-27:7: @7.Call: _10 = _print(move _11) -> [return: bb8, unwind: bb42] +11:5-27:7: @9[6]: _9 = const () +29:24-29:58: @9.Call: _31 = <String as From<&str>>::from(const "the string content") -> [return: bb10, unwind: bb43] +29:19-29:59: @10[0]: _30 = Option::<String>::Some(move _31) +33:9-40:6: @11[3]: _33 = &_5 +31:9-31:10: @11[6]: FakeRead(ForLet, _32) +42:9-42:32: @11[13]: _136 = const main::promoted[3] +42:9-42:32: @11[14]: _39 = &(*_136) +42:9-42:32: @11[15]: _38 = &(*_39) +42:9-42:32: @11[16]: _37 = move _38 as &[&str] (Pointer(Unsize)) +44:9-44:20: @11[26]: _48 = move _7 +48:13-48:14: @11[28]: _49 = _32 +44:9-49:10: @11.Call: _47 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:33:9: 40:6]>(move _48, move _49) -> [return: bb12, unwind: bb43] +44:9-49:10: @12[2]: _46 = &_47 +41:5-50:7: @12[3]: _45 = (move _46,) +41:5-50:7: @12[5]: FakeRead(ForMatchedPlace, _45) +41:5-50:7: @12[7]: _50 = (_45.0: &std::string::String) +41:5-50:7: @12[10]: _52 = &(*_50) +41:5-50:7: @12[12]: _53 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +41:5-50:7: @12.Call: _51 = ArgumentV1::new::<String>(move _52, move _53) -> [return: bb13, unwind: bb41] +41:5-50:7: @13[2]: _44 = [move _51] +41:5-50:7: @13[5]: _43 = &_44 +41:5-50:7: @13[6]: _42 = &(*_43) +41:5-50:7: @13[7]: _41 = move _42 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +41:5-50:7: @13.Call: _36 = Arguments::new_v1(move _37, move _41) -> [return: bb14, unwind: bb41] +41:5-50:7: @14.Call: _35 = _print(move _36) -> [return: bb15, unwind: bb41] +41:5-50:7: @16[6]: _34 = const () +52:19-52:23: @16[9]: _54 = Option::<String>::None +54:9-54:32: @17[7]: _135 = const main::promoted[2] +54:9-54:32: @17[8]: _60 = &(*_135) +54:9-54:32: @17[9]: _59 = &(*_60) +54:9-54:32: @17[10]: _58 = move _59 as &[&str] (Pointer(Unsize)) +56:9-56:20: @17[20]: _69 = move _7 +56:9-68:10: @17.Call: _68 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:60:13: 67:14]>(move _69, move _70) -> [return: bb18, unwind: bb43] +56:9-68:10: @18[2]: _67 = &_68 +53:5-69:7: @18[3]: _66 = (move _67,) +53:5-69:7: @18[5]: FakeRead(ForMatchedPlace, _66) +53:5-69:7: @18[7]: _72 = (_66.0: &std::string::String) +53:5-69:7: @18[10]: _74 = &(*_72) +53:5-69:7: @18[12]: _75 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +53:5-69:7: @18.Call: _73 = ArgumentV1::new::<String>(move _74, move _75) -> [return: bb19, unwind: bb40] +53:5-69:7: @19[2]: _65 = [move _73] +53:5-69:7: @19[5]: _64 = &_65 +53:5-69:7: @19[6]: _63 = &(*_64) +53:5-69:7: @19[7]: _62 = move _63 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +53:5-69:7: @19.Call: _57 = Arguments::new_v1(move _58, move _62) -> [return: bb20, unwind: bb40] +53:5-69:7: @20.Call: _56 = _print(move _57) -> [return: bb21, unwind: bb40] +53:5-69:7: @22[6]: _55 = const () +71:19-71:23: @22[9]: _76 = Option::<String>::None +75:9-82:6: @23[3]: _78 = &_5 +73:9-73:10: @23[6]: FakeRead(ForLet, _77) +84:9-84:32: @23[13]: _134 = const main::promoted[1] +84:9-84:32: @23[14]: _84 = &(*_134) +84:9-84:32: @23[15]: _83 = &(*_84) +84:9-84:32: @23[16]: _82 = move _83 as &[&str] (Pointer(Unsize)) +86:9-86:20: @23[26]: _93 = move _7 +90:13-90:14: @23[28]: _94 = _77 +86:9-91:10: @23.Call: _92 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:75:9: 82:6]>(move _93, move _94) -> [return: bb24, unwind: bb43] +86:9-91:10: @24[2]: _91 = &_92 +83:5-92:7: @24[3]: _90 = (move _91,) +83:5-92:7: @24[5]: FakeRead(ForMatchedPlace, _90) +83:5-92:7: @24[7]: _95 = (_90.0: &std::string::String) +83:5-92:7: @24[10]: _97 = &(*_95) +83:5-92:7: @24[12]: _98 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +83:5-92:7: @24.Call: _96 = ArgumentV1::new::<String>(move _97, move _98) -> [return: bb25, unwind: bb39] +83:5-92:7: @25[2]: _89 = [move _96] +83:5-92:7: @25[5]: _88 = &_89 +83:5-92:7: @25[6]: _87 = &(*_88) +83:5-92:7: @25[7]: _86 = move _87 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +83:5-92:7: @25.Call: _81 = Arguments::new_v1(move _82, move _86) -> [return: bb26, unwind: bb39] +83:5-92:7: @26.Call: _80 = _print(move _81) -> [return: bb27, unwind: bb39] +83:5-92:7: @28[6]: _79 = const () +97:9-104:6: @28[10]: _100 = &_5 +95:9-95:22: @28[13]: FakeRead(ForLet, _99) +106:9-106:40: @28[20]: _133 = const main::promoted[0] +106:9-106:40: @28[21]: _106 = &(*_133) +106:9-106:40: @28[22]: _105 = &(*_106) +106:9-106:40: @28[23]: _104 = move _105 as &[&str] (Pointer(Unsize)) +108:9-108:39: @28.Call: _117 = std::iter::repeat::<&str>(const "repeat me") -> [return: bb29, unwind: bb43] +108:9-109:21: @29.Call: _116 = <std::iter::Repeat<&str> as Iterator>::take(move _117, const 5_usize) -> [return: bb30, unwind: bb43] +112:13-112:26: @30[2]: _118 = _99 +108:9-113:10: @30.Call: _115 = <std::iter::Take<std::iter::Repeat<&str>> as Iterator>::map::<String, [closure@../coverage/closure.rs:97:9: 104:6]>(move _116, move _118) -> [return: bb31, unwind: bb43] +108:9-114:33: @31.Call: _114 = <Map<std::iter::Take<std::iter::Repeat<&str>>, [closure@../coverage/closure.rs:97:9: 104:6]> as Iterator>::collect::<Vec<String>>(move _115) -> [return: bb32, unwind: bb43] +108:9-114:33: @32[1]: _113 = &_114 +105:5-115:7: @32[2]: _112 = (move _113,) +105:5-115:7: @32[4]: FakeRead(ForMatchedPlace, _112) +105:5-115:7: @32[6]: _119 = (_112.0: &std::vec::Vec<std::string::String>) +105:5-115:7: @32[9]: _121 = &(*_119) +105:5-115:7: @32[11]: _122 = <Vec<String> as Debug>::fmt as for<'r, 's, 't0> fn(&'r std::vec::Vec<std::string::String>, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +105:5-115:7: @32.Call: _120 = ArgumentV1::new::<Vec<String>>(move _121, move _122) -> [return: bb33, unwind: bb38] +105:5-115:7: @33[2]: _111 = [move _120] +105:5-115:7: @33[5]: _110 = &_111 +105:5-115:7: @33[6]: _109 = &(*_110) +105:5-115:7: @33[7]: _108 = move _109 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +105:5-115:7: @33.Call: _103 = Arguments::new_v1(move _104, move _108) -> [return: bb34, unwind: bb38] +105:5-115:7: @34.Call: _102 = _print(move _103) -> [return: bb35, unwind: bb38] +105:5-115:7: @36[6]: _101 = const () +118:9-118:24: @36[13]: FakeRead(ForLet, _123) +3:11-155:2: @36[38]: _0 = const ()"> ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37| mut countdown | { @@ -7149,3773 +7149,3773 @@ countdown = 10; } "closure should be unused".to_owned() - } }@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42⦊; -@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37⦊; + - + let mut countdown = 10; - let mut countdown = 10; + let _short_unused_closure = ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42| _unused_arg: u8 | countdown += 1 let _short_unused_closure = ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37| _unused_arg: u8 | countdown += 1@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42⦊; -@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37⦊; + - + // Macros can sometimes confuse the coverage results. Compare this next assignment, with an - // Macros can sometimes confuse the coverage results. Compare this next assignment, with an + // unused closure that invokes the `println!()` macro, with the closure assignment above, that - // unused closure that invokes the `println!()` macro, with the closure assignment above, that + // does not use a macro. The closure above correctly shows `0` executions. - // does not use a macro. The closure above correctly shows `0` executions. + let _short_unused_closure = ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42| _unused_arg: u8 | println!("not called") let _short_unused_closure = ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37| _unused_arg: u8 | println!("not called")@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42⦊; -@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37⦊; + // The closure assignment above is executed, with a line count of `1`, but the `println!()` - // The closure assignment above is executed, with a line count of `1`, but the `println!()` + // could not have been called, and yet, there is no indication that it wasn't... - // could not have been called, and yet, there is no indication that it wasn't... + - + // ...but adding block braces gives the expected result, showing the block was not executed. - // ...but adding block braces gives the expected result, showing the block was not executed. + let _short_unused_closure_block = ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42| _unused_arg: u8 | { println!("not called") } let _short_unused_closure_block = ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37| _unused_arg: u8 | { println!("not called") }@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42⦊; -@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37⦊; + - + let _shortish_unused_closure = ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42| _unused_arg: u8 | { +10:32-10:66: @3.Call: _8 = <String as From<&str>>::from(const "the string content") -> [return: bb4, unwind: bb45] +10:27-10:67: @4[0]: _7 = Option::<String>::Some(move _8) +10:9-10:24: @4[2]: FakeRead(ForLet, _7) +12:9-12:32: @4[9]: _137 = const main::promoted[4] +12:9-12:32: @4[10]: _14 = &(*_137) +12:9-12:32: @4[11]: _13 = &(*_14) +12:9-12:32: @4[12]: _12 = move _13 as &[&str] (Pointer(Unsize)) +14:9-14:20: @4[22]: _23 = move _7 +14:9-26:10: @4.Call: _22 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:18:13: 25:14]>(move _23, move _24) -> [return: bb5, unwind: bb43] +14:9-26:10: @5[2]: _21 = &_22 +11:5-27:7: @5[3]: _20 = (move _21,) +11:5-27:7: @5[5]: FakeRead(ForMatchedPlace, _20) +11:5-27:7: @5[7]: _26 = (_20.0: &std::string::String) +11:5-27:7: @5[10]: _28 = &(*_26) +11:5-27:7: @5[12]: _29 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +11:5-27:7: @5.Call: _27 = ArgumentV1::new::<String>(move _28, move _29) -> [return: bb6, unwind: bb42] +11:5-27:7: @6[2]: _19 = [move _27] +11:5-27:7: @6[5]: _18 = &_19 +11:5-27:7: @6[6]: _17 = &(*_18) +11:5-27:7: @6[7]: _16 = move _17 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +11:5-27:7: @6.Call: _11 = Arguments::new_v1(move _12, move _16) -> [return: bb7, unwind: bb42] +11:5-27:7: @7.Call: _10 = _print(move _11) -> [return: bb8, unwind: bb42] +11:5-27:7: @9[6]: _9 = const () +29:24-29:58: @9.Call: _31 = <String as From<&str>>::from(const "the string content") -> [return: bb10, unwind: bb43] +29:19-29:59: @10[0]: _30 = Option::<String>::Some(move _31) +33:9-40:6: @11[3]: _33 = &_5 +31:9-31:10: @11[6]: FakeRead(ForLet, _32) +42:9-42:32: @11[13]: _136 = const main::promoted[3] +42:9-42:32: @11[14]: _39 = &(*_136) +42:9-42:32: @11[15]: _38 = &(*_39) +42:9-42:32: @11[16]: _37 = move _38 as &[&str] (Pointer(Unsize)) +44:9-44:20: @11[26]: _48 = move _7 +48:13-48:14: @11[28]: _49 = _32 +44:9-49:10: @11.Call: _47 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:33:9: 40:6]>(move _48, move _49) -> [return: bb12, unwind: bb43] +44:9-49:10: @12[2]: _46 = &_47 +41:5-50:7: @12[3]: _45 = (move _46,) +41:5-50:7: @12[5]: FakeRead(ForMatchedPlace, _45) +41:5-50:7: @12[7]: _50 = (_45.0: &std::string::String) +41:5-50:7: @12[10]: _52 = &(*_50) +41:5-50:7: @12[12]: _53 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +41:5-50:7: @12.Call: _51 = ArgumentV1::new::<String>(move _52, move _53) -> [return: bb13, unwind: bb41] +41:5-50:7: @13[2]: _44 = [move _51] +41:5-50:7: @13[5]: _43 = &_44 +41:5-50:7: @13[6]: _42 = &(*_43) +41:5-50:7: @13[7]: _41 = move _42 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +41:5-50:7: @13.Call: _36 = Arguments::new_v1(move _37, move _41) -> [return: bb14, unwind: bb41] +41:5-50:7: @14.Call: _35 = _print(move _36) -> [return: bb15, unwind: bb41] +41:5-50:7: @16[6]: _34 = const () +52:19-52:23: @16[9]: _54 = Option::<String>::None +54:9-54:32: @17[7]: _135 = const main::promoted[2] +54:9-54:32: @17[8]: _60 = &(*_135) +54:9-54:32: @17[9]: _59 = &(*_60) +54:9-54:32: @17[10]: _58 = move _59 as &[&str] (Pointer(Unsize)) +56:9-56:20: @17[20]: _69 = move _7 +56:9-68:10: @17.Call: _68 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:60:13: 67:14]>(move _69, move _70) -> [return: bb18, unwind: bb43] +56:9-68:10: @18[2]: _67 = &_68 +53:5-69:7: @18[3]: _66 = (move _67,) +53:5-69:7: @18[5]: FakeRead(ForMatchedPlace, _66) +53:5-69:7: @18[7]: _72 = (_66.0: &std::string::String) +53:5-69:7: @18[10]: _74 = &(*_72) +53:5-69:7: @18[12]: _75 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +53:5-69:7: @18.Call: _73 = ArgumentV1::new::<String>(move _74, move _75) -> [return: bb19, unwind: bb40] +53:5-69:7: @19[2]: _65 = [move _73] +53:5-69:7: @19[5]: _64 = &_65 +53:5-69:7: @19[6]: _63 = &(*_64) +53:5-69:7: @19[7]: _62 = move _63 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +53:5-69:7: @19.Call: _57 = Arguments::new_v1(move _58, move _62) -> [return: bb20, unwind: bb40] +53:5-69:7: @20.Call: _56 = _print(move _57) -> [return: bb21, unwind: bb40] +53:5-69:7: @22[6]: _55 = const () +71:19-71:23: @22[9]: _76 = Option::<String>::None +75:9-82:6: @23[3]: _78 = &_5 +73:9-73:10: @23[6]: FakeRead(ForLet, _77) +84:9-84:32: @23[13]: _134 = const main::promoted[1] +84:9-84:32: @23[14]: _84 = &(*_134) +84:9-84:32: @23[15]: _83 = &(*_84) +84:9-84:32: @23[16]: _82 = move _83 as &[&str] (Pointer(Unsize)) +86:9-86:20: @23[26]: _93 = move _7 +90:13-90:14: @23[28]: _94 = _77 +86:9-91:10: @23.Call: _92 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:75:9: 82:6]>(move _93, move _94) -> [return: bb24, unwind: bb43] +86:9-91:10: @24[2]: _91 = &_92 +83:5-92:7: @24[3]: _90 = (move _91,) +83:5-92:7: @24[5]: FakeRead(ForMatchedPlace, _90) +83:5-92:7: @24[7]: _95 = (_90.0: &std::string::String) +83:5-92:7: @24[10]: _97 = &(*_95) +83:5-92:7: @24[12]: _98 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +83:5-92:7: @24.Call: _96 = ArgumentV1::new::<String>(move _97, move _98) -> [return: bb25, unwind: bb39] +83:5-92:7: @25[2]: _89 = [move _96] +83:5-92:7: @25[5]: _88 = &_89 +83:5-92:7: @25[6]: _87 = &(*_88) +83:5-92:7: @25[7]: _86 = move _87 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +83:5-92:7: @25.Call: _81 = Arguments::new_v1(move _82, move _86) -> [return: bb26, unwind: bb39] +83:5-92:7: @26.Call: _80 = _print(move _81) -> [return: bb27, unwind: bb39] +83:5-92:7: @28[6]: _79 = const () +97:9-104:6: @28[10]: _100 = &_5 +95:9-95:22: @28[13]: FakeRead(ForLet, _99) +106:9-106:40: @28[20]: _133 = const main::promoted[0] +106:9-106:40: @28[21]: _106 = &(*_133) +106:9-106:40: @28[22]: _105 = &(*_106) +106:9-106:40: @28[23]: _104 = move _105 as &[&str] (Pointer(Unsize)) +108:9-108:39: @28.Call: _117 = std::iter::repeat::<&str>(const "repeat me") -> [return: bb29, unwind: bb43] +108:9-109:21: @29.Call: _116 = <std::iter::Repeat<&str> as Iterator>::take(move _117, const 5_usize) -> [return: bb30, unwind: bb43] +112:13-112:26: @30[2]: _118 = _99 +108:9-113:10: @30.Call: _115 = <std::iter::Take<std::iter::Repeat<&str>> as Iterator>::map::<String, [closure@../coverage/closure.rs:97:9: 104:6]>(move _116, move _118) -> [return: bb31, unwind: bb43] +108:9-114:33: @31.Call: _114 = <Map<std::iter::Take<std::iter::Repeat<&str>>, [closure@../coverage/closure.rs:97:9: 104:6]> as Iterator>::collect::<Vec<String>>(move _115) -> [return: bb32, unwind: bb43] +108:9-114:33: @32[1]: _113 = &_114 +105:5-115:7: @32[2]: _112 = (move _113,) +105:5-115:7: @32[4]: FakeRead(ForMatchedPlace, _112) +105:5-115:7: @32[6]: _119 = (_112.0: &std::vec::Vec<std::string::String>) +105:5-115:7: @32[9]: _121 = &(*_119) +105:5-115:7: @32[11]: _122 = <Vec<String> as Debug>::fmt as for<'r, 's, 't0> fn(&'r std::vec::Vec<std::string::String>, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +105:5-115:7: @32.Call: _120 = ArgumentV1::new::<Vec<String>>(move _121, move _122) -> [return: bb33, unwind: bb38] +105:5-115:7: @33[2]: _111 = [move _120] +105:5-115:7: @33[5]: _110 = &_111 +105:5-115:7: @33[6]: _109 = &(*_110) +105:5-115:7: @33[7]: _108 = move _109 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +105:5-115:7: @33.Call: _103 = Arguments::new_v1(move _104, move _108) -> [return: bb34, unwind: bb38] +105:5-115:7: @34.Call: _102 = _print(move _103) -> [return: bb35, unwind: bb38] +105:5-115:7: @36[6]: _101 = const () +118:9-118:24: @36[13]: FakeRead(ForLet, _123) +130:25-130:27: @36[15]: _125 = const 10_i32 +130:9-130:22: @36[16]: FakeRead(ForLet, _125) +131:33-131:67: @36[19]: _127 = &mut _125 +131:9-131:30: @36[22]: FakeRead(ForLet, _126) +136:9-136:30: @36[25]: FakeRead(ForLet, _128) +141:9-141:36: @36[28]: FakeRead(ForLet, _129) +143:9-143:33: @36[31]: FakeRead(ForLet, _130) +3:11-155:2: @36[38]: _0 = const ()"> let _shortish_unused_closure = ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37| _unused_arg: u8 | { println!("not called") - } }@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42⦊; -@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37⦊; + - + let _as_short_unused_closure = ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42| +10:32-10:66: @3.Call: _8 = <String as From<&str>>::from(const "the string content") -> [return: bb4, unwind: bb45] +10:27-10:67: @4[0]: _7 = Option::<String>::Some(move _8) +10:9-10:24: @4[2]: FakeRead(ForLet, _7) +12:9-12:32: @4[9]: _137 = const main::promoted[4] +12:9-12:32: @4[10]: _14 = &(*_137) +12:9-12:32: @4[11]: _13 = &(*_14) +12:9-12:32: @4[12]: _12 = move _13 as &[&str] (Pointer(Unsize)) +14:9-14:20: @4[22]: _23 = move _7 +14:9-26:10: @4.Call: _22 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:18:13: 25:14]>(move _23, move _24) -> [return: bb5, unwind: bb43] +14:9-26:10: @5[2]: _21 = &_22 +11:5-27:7: @5[3]: _20 = (move _21,) +11:5-27:7: @5[5]: FakeRead(ForMatchedPlace, _20) +11:5-27:7: @5[7]: _26 = (_20.0: &std::string::String) +11:5-27:7: @5[10]: _28 = &(*_26) +11:5-27:7: @5[12]: _29 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +11:5-27:7: @5.Call: _27 = ArgumentV1::new::<String>(move _28, move _29) -> [return: bb6, unwind: bb42] +11:5-27:7: @6[2]: _19 = [move _27] +11:5-27:7: @6[5]: _18 = &_19 +11:5-27:7: @6[6]: _17 = &(*_18) +11:5-27:7: @6[7]: _16 = move _17 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +11:5-27:7: @6.Call: _11 = Arguments::new_v1(move _12, move _16) -> [return: bb7, unwind: bb42] +11:5-27:7: @7.Call: _10 = _print(move _11) -> [return: bb8, unwind: bb42] +11:5-27:7: @9[6]: _9 = const () +29:24-29:58: @9.Call: _31 = <String as From<&str>>::from(const "the string content") -> [return: bb10, unwind: bb43] +29:19-29:59: @10[0]: _30 = Option::<String>::Some(move _31) +33:9-40:6: @11[3]: _33 = &_5 +31:9-31:10: @11[6]: FakeRead(ForLet, _32) +42:9-42:32: @11[13]: _136 = const main::promoted[3] +42:9-42:32: @11[14]: _39 = &(*_136) +42:9-42:32: @11[15]: _38 = &(*_39) +42:9-42:32: @11[16]: _37 = move _38 as &[&str] (Pointer(Unsize)) +44:9-44:20: @11[26]: _48 = move _7 +48:13-48:14: @11[28]: _49 = _32 +44:9-49:10: @11.Call: _47 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:33:9: 40:6]>(move _48, move _49) -> [return: bb12, unwind: bb43] +44:9-49:10: @12[2]: _46 = &_47 +41:5-50:7: @12[3]: _45 = (move _46,) +41:5-50:7: @12[5]: FakeRead(ForMatchedPlace, _45) +41:5-50:7: @12[7]: _50 = (_45.0: &std::string::String) +41:5-50:7: @12[10]: _52 = &(*_50) +41:5-50:7: @12[12]: _53 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +41:5-50:7: @12.Call: _51 = ArgumentV1::new::<String>(move _52, move _53) -> [return: bb13, unwind: bb41] +41:5-50:7: @13[2]: _44 = [move _51] +41:5-50:7: @13[5]: _43 = &_44 +41:5-50:7: @13[6]: _42 = &(*_43) +41:5-50:7: @13[7]: _41 = move _42 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +41:5-50:7: @13.Call: _36 = Arguments::new_v1(move _37, move _41) -> [return: bb14, unwind: bb41] +41:5-50:7: @14.Call: _35 = _print(move _36) -> [return: bb15, unwind: bb41] +41:5-50:7: @16[6]: _34 = const () +52:19-52:23: @16[9]: _54 = Option::<String>::None +54:9-54:32: @17[7]: _135 = const main::promoted[2] +54:9-54:32: @17[8]: _60 = &(*_135) +54:9-54:32: @17[9]: _59 = &(*_60) +54:9-54:32: @17[10]: _58 = move _59 as &[&str] (Pointer(Unsize)) +56:9-56:20: @17[20]: _69 = move _7 +56:9-68:10: @17.Call: _68 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:60:13: 67:14]>(move _69, move _70) -> [return: bb18, unwind: bb43] +56:9-68:10: @18[2]: _67 = &_68 +53:5-69:7: @18[3]: _66 = (move _67,) +53:5-69:7: @18[5]: FakeRead(ForMatchedPlace, _66) +53:5-69:7: @18[7]: _72 = (_66.0: &std::string::String) +53:5-69:7: @18[10]: _74 = &(*_72) +53:5-69:7: @18[12]: _75 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +53:5-69:7: @18.Call: _73 = ArgumentV1::new::<String>(move _74, move _75) -> [return: bb19, unwind: bb40] +53:5-69:7: @19[2]: _65 = [move _73] +53:5-69:7: @19[5]: _64 = &_65 +53:5-69:7: @19[6]: _63 = &(*_64) +53:5-69:7: @19[7]: _62 = move _63 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +53:5-69:7: @19.Call: _57 = Arguments::new_v1(move _58, move _62) -> [return: bb20, unwind: bb40] +53:5-69:7: @20.Call: _56 = _print(move _57) -> [return: bb21, unwind: bb40] +53:5-69:7: @22[6]: _55 = const () +71:19-71:23: @22[9]: _76 = Option::<String>::None +75:9-82:6: @23[3]: _78 = &_5 +73:9-73:10: @23[6]: FakeRead(ForLet, _77) +84:9-84:32: @23[13]: _134 = const main::promoted[1] +84:9-84:32: @23[14]: _84 = &(*_134) +84:9-84:32: @23[15]: _83 = &(*_84) +84:9-84:32: @23[16]: _82 = move _83 as &[&str] (Pointer(Unsize)) +86:9-86:20: @23[26]: _93 = move _7 +90:13-90:14: @23[28]: _94 = _77 +86:9-91:10: @23.Call: _92 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:75:9: 82:6]>(move _93, move _94) -> [return: bb24, unwind: bb43] +86:9-91:10: @24[2]: _91 = &_92 +83:5-92:7: @24[3]: _90 = (move _91,) +83:5-92:7: @24[5]: FakeRead(ForMatchedPlace, _90) +83:5-92:7: @24[7]: _95 = (_90.0: &std::string::String) +83:5-92:7: @24[10]: _97 = &(*_95) +83:5-92:7: @24[12]: _98 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +83:5-92:7: @24.Call: _96 = ArgumentV1::new::<String>(move _97, move _98) -> [return: bb25, unwind: bb39] +83:5-92:7: @25[2]: _89 = [move _96] +83:5-92:7: @25[5]: _88 = &_89 +83:5-92:7: @25[6]: _87 = &(*_88) +83:5-92:7: @25[7]: _86 = move _87 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +83:5-92:7: @25.Call: _81 = Arguments::new_v1(move _82, move _86) -> [return: bb26, unwind: bb39] +83:5-92:7: @26.Call: _80 = _print(move _81) -> [return: bb27, unwind: bb39] +83:5-92:7: @28[6]: _79 = const () +97:9-104:6: @28[10]: _100 = &_5 +95:9-95:22: @28[13]: FakeRead(ForLet, _99) +106:9-106:40: @28[20]: _133 = const main::promoted[0] +106:9-106:40: @28[21]: _106 = &(*_133) +106:9-106:40: @28[22]: _105 = &(*_106) +106:9-106:40: @28[23]: _104 = move _105 as &[&str] (Pointer(Unsize)) +108:9-108:39: @28.Call: _117 = std::iter::repeat::<&str>(const "repeat me") -> [return: bb29, unwind: bb43] +108:9-109:21: @29.Call: _116 = <std::iter::Repeat<&str> as Iterator>::take(move _117, const 5_usize) -> [return: bb30, unwind: bb43] +112:13-112:26: @30[2]: _118 = _99 +108:9-113:10: @30.Call: _115 = <std::iter::Take<std::iter::Repeat<&str>> as Iterator>::map::<String, [closure@../coverage/closure.rs:97:9: 104:6]>(move _116, move _118) -> [return: bb31, unwind: bb43] +108:9-114:33: @31.Call: _114 = <Map<std::iter::Take<std::iter::Repeat<&str>>, [closure@../coverage/closure.rs:97:9: 104:6]> as Iterator>::collect::<Vec<String>>(move _115) -> [return: bb32, unwind: bb43] +108:9-114:33: @32[1]: _113 = &_114 +105:5-115:7: @32[2]: _112 = (move _113,) +105:5-115:7: @32[4]: FakeRead(ForMatchedPlace, _112) +105:5-115:7: @32[6]: _119 = (_112.0: &std::vec::Vec<std::string::String>) +105:5-115:7: @32[9]: _121 = &(*_119) +105:5-115:7: @32[11]: _122 = <Vec<String> as Debug>::fmt as for<'r, 's, 't0> fn(&'r std::vec::Vec<std::string::String>, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +105:5-115:7: @32.Call: _120 = ArgumentV1::new::<Vec<String>>(move _121, move _122) -> [return: bb33, unwind: bb38] +105:5-115:7: @33[2]: _111 = [move _120] +105:5-115:7: @33[5]: _110 = &_111 +105:5-115:7: @33[6]: _109 = &(*_110) +105:5-115:7: @33[7]: _108 = move _109 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +105:5-115:7: @33.Call: _103 = Arguments::new_v1(move _104, move _108) -> [return: bb34, unwind: bb38] +105:5-115:7: @34.Call: _102 = _print(move _103) -> [return: bb35, unwind: bb38] +105:5-115:7: @36[6]: _101 = const () +118:9-118:24: @36[13]: FakeRead(ForLet, _123) +130:25-130:27: @36[15]: _125 = const 10_i32 +130:9-130:22: @36[16]: FakeRead(ForLet, _125) +131:33-131:67: @36[19]: _127 = &mut _125 +131:9-131:30: @36[22]: FakeRead(ForLet, _126) +136:9-136:30: @36[25]: FakeRead(ForLet, _128) +141:9-141:36: @36[28]: FakeRead(ForLet, _129) +143:9-143:33: @36[31]: FakeRead(ForLet, _130) +147:9-147:33: @36[34]: FakeRead(ForLet, _131) +3:11-155:2: @36[38]: _0 = const ()"> let _as_short_unused_closure = ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37| _unused_arg: u8 - | { println!("not called") } | { println!("not called") }@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42⦊; -@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37⦊; + - + let _almost_as_short_unused_closure = ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42| +10:32-10:66: @3.Call: _8 = <String as From<&str>>::from(const "the string content") -> [return: bb4, unwind: bb45] +10:27-10:67: @4[0]: _7 = Option::<String>::Some(move _8) +10:9-10:24: @4[2]: FakeRead(ForLet, _7) +12:9-12:32: @4[9]: _137 = const main::promoted[4] +12:9-12:32: @4[10]: _14 = &(*_137) +12:9-12:32: @4[11]: _13 = &(*_14) +12:9-12:32: @4[12]: _12 = move _13 as &[&str] (Pointer(Unsize)) +14:9-14:20: @4[22]: _23 = move _7 +14:9-26:10: @4.Call: _22 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:18:13: 25:14]>(move _23, move _24) -> [return: bb5, unwind: bb43] +14:9-26:10: @5[2]: _21 = &_22 +11:5-27:7: @5[3]: _20 = (move _21,) +11:5-27:7: @5[5]: FakeRead(ForMatchedPlace, _20) +11:5-27:7: @5[7]: _26 = (_20.0: &std::string::String) +11:5-27:7: @5[10]: _28 = &(*_26) +11:5-27:7: @5[12]: _29 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +11:5-27:7: @5.Call: _27 = ArgumentV1::new::<String>(move _28, move _29) -> [return: bb6, unwind: bb42] +11:5-27:7: @6[2]: _19 = [move _27] +11:5-27:7: @6[5]: _18 = &_19 +11:5-27:7: @6[6]: _17 = &(*_18) +11:5-27:7: @6[7]: _16 = move _17 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +11:5-27:7: @6.Call: _11 = Arguments::new_v1(move _12, move _16) -> [return: bb7, unwind: bb42] +11:5-27:7: @7.Call: _10 = _print(move _11) -> [return: bb8, unwind: bb42] +11:5-27:7: @9[6]: _9 = const () +29:24-29:58: @9.Call: _31 = <String as From<&str>>::from(const "the string content") -> [return: bb10, unwind: bb43] +29:19-29:59: @10[0]: _30 = Option::<String>::Some(move _31) +33:9-40:6: @11[3]: _33 = &_5 +31:9-31:10: @11[6]: FakeRead(ForLet, _32) +42:9-42:32: @11[13]: _136 = const main::promoted[3] +42:9-42:32: @11[14]: _39 = &(*_136) +42:9-42:32: @11[15]: _38 = &(*_39) +42:9-42:32: @11[16]: _37 = move _38 as &[&str] (Pointer(Unsize)) +44:9-44:20: @11[26]: _48 = move _7 +48:13-48:14: @11[28]: _49 = _32 +44:9-49:10: @11.Call: _47 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:33:9: 40:6]>(move _48, move _49) -> [return: bb12, unwind: bb43] +44:9-49:10: @12[2]: _46 = &_47 +41:5-50:7: @12[3]: _45 = (move _46,) +41:5-50:7: @12[5]: FakeRead(ForMatchedPlace, _45) +41:5-50:7: @12[7]: _50 = (_45.0: &std::string::String) +41:5-50:7: @12[10]: _52 = &(*_50) +41:5-50:7: @12[12]: _53 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +41:5-50:7: @12.Call: _51 = ArgumentV1::new::<String>(move _52, move _53) -> [return: bb13, unwind: bb41] +41:5-50:7: @13[2]: _44 = [move _51] +41:5-50:7: @13[5]: _43 = &_44 +41:5-50:7: @13[6]: _42 = &(*_43) +41:5-50:7: @13[7]: _41 = move _42 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +41:5-50:7: @13.Call: _36 = Arguments::new_v1(move _37, move _41) -> [return: bb14, unwind: bb41] +41:5-50:7: @14.Call: _35 = _print(move _36) -> [return: bb15, unwind: bb41] +41:5-50:7: @16[6]: _34 = const () +52:19-52:23: @16[9]: _54 = Option::<String>::None +54:9-54:32: @17[7]: _135 = const main::promoted[2] +54:9-54:32: @17[8]: _60 = &(*_135) +54:9-54:32: @17[9]: _59 = &(*_60) +54:9-54:32: @17[10]: _58 = move _59 as &[&str] (Pointer(Unsize)) +56:9-56:20: @17[20]: _69 = move _7 +56:9-68:10: @17.Call: _68 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:60:13: 67:14]>(move _69, move _70) -> [return: bb18, unwind: bb43] +56:9-68:10: @18[2]: _67 = &_68 +53:5-69:7: @18[3]: _66 = (move _67,) +53:5-69:7: @18[5]: FakeRead(ForMatchedPlace, _66) +53:5-69:7: @18[7]: _72 = (_66.0: &std::string::String) +53:5-69:7: @18[10]: _74 = &(*_72) +53:5-69:7: @18[12]: _75 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +53:5-69:7: @18.Call: _73 = ArgumentV1::new::<String>(move _74, move _75) -> [return: bb19, unwind: bb40] +53:5-69:7: @19[2]: _65 = [move _73] +53:5-69:7: @19[5]: _64 = &_65 +53:5-69:7: @19[6]: _63 = &(*_64) +53:5-69:7: @19[7]: _62 = move _63 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +53:5-69:7: @19.Call: _57 = Arguments::new_v1(move _58, move _62) -> [return: bb20, unwind: bb40] +53:5-69:7: @20.Call: _56 = _print(move _57) -> [return: bb21, unwind: bb40] +53:5-69:7: @22[6]: _55 = const () +71:19-71:23: @22[9]: _76 = Option::<String>::None +75:9-82:6: @23[3]: _78 = &_5 +73:9-73:10: @23[6]: FakeRead(ForLet, _77) +84:9-84:32: @23[13]: _134 = const main::promoted[1] +84:9-84:32: @23[14]: _84 = &(*_134) +84:9-84:32: @23[15]: _83 = &(*_84) +84:9-84:32: @23[16]: _82 = move _83 as &[&str] (Pointer(Unsize)) +86:9-86:20: @23[26]: _93 = move _7 +90:13-90:14: @23[28]: _94 = _77 +86:9-91:10: @23.Call: _92 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:75:9: 82:6]>(move _93, move _94) -> [return: bb24, unwind: bb43] +86:9-91:10: @24[2]: _91 = &_92 +83:5-92:7: @24[3]: _90 = (move _91,) +83:5-92:7: @24[5]: FakeRead(ForMatchedPlace, _90) +83:5-92:7: @24[7]: _95 = (_90.0: &std::string::String) +83:5-92:7: @24[10]: _97 = &(*_95) +83:5-92:7: @24[12]: _98 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +83:5-92:7: @24.Call: _96 = ArgumentV1::new::<String>(move _97, move _98) -> [return: bb25, unwind: bb39] +83:5-92:7: @25[2]: _89 = [move _96] +83:5-92:7: @25[5]: _88 = &_89 +83:5-92:7: @25[6]: _87 = &(*_88) +83:5-92:7: @25[7]: _86 = move _87 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +83:5-92:7: @25.Call: _81 = Arguments::new_v1(move _82, move _86) -> [return: bb26, unwind: bb39] +83:5-92:7: @26.Call: _80 = _print(move _81) -> [return: bb27, unwind: bb39] +83:5-92:7: @28[6]: _79 = const () +97:9-104:6: @28[10]: _100 = &_5 +95:9-95:22: @28[13]: FakeRead(ForLet, _99) +106:9-106:40: @28[20]: _133 = const main::promoted[0] +106:9-106:40: @28[21]: _106 = &(*_133) +106:9-106:40: @28[22]: _105 = &(*_106) +106:9-106:40: @28[23]: _104 = move _105 as &[&str] (Pointer(Unsize)) +108:9-108:39: @28.Call: _117 = std::iter::repeat::<&str>(const "repeat me") -> [return: bb29, unwind: bb43] +108:9-109:21: @29.Call: _116 = <std::iter::Repeat<&str> as Iterator>::take(move _117, const 5_usize) -> [return: bb30, unwind: bb43] +112:13-112:26: @30[2]: _118 = _99 +108:9-113:10: @30.Call: _115 = <std::iter::Take<std::iter::Repeat<&str>> as Iterator>::map::<String, [closure@../coverage/closure.rs:97:9: 104:6]>(move _116, move _118) -> [return: bb31, unwind: bb43] +108:9-114:33: @31.Call: _114 = <Map<std::iter::Take<std::iter::Repeat<&str>>, [closure@../coverage/closure.rs:97:9: 104:6]> as Iterator>::collect::<Vec<String>>(move _115) -> [return: bb32, unwind: bb43] +108:9-114:33: @32[1]: _113 = &_114 +105:5-115:7: @32[2]: _112 = (move _113,) +105:5-115:7: @32[4]: FakeRead(ForMatchedPlace, _112) +105:5-115:7: @32[6]: _119 = (_112.0: &std::vec::Vec<std::string::String>) +105:5-115:7: @32[9]: _121 = &(*_119) +105:5-115:7: @32[11]: _122 = <Vec<String> as Debug>::fmt as for<'r, 's, 't0> fn(&'r std::vec::Vec<std::string::String>, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +105:5-115:7: @32.Call: _120 = ArgumentV1::new::<Vec<String>>(move _121, move _122) -> [return: bb33, unwind: bb38] +105:5-115:7: @33[2]: _111 = [move _120] +105:5-115:7: @33[5]: _110 = &_111 +105:5-115:7: @33[6]: _109 = &(*_110) +105:5-115:7: @33[7]: _108 = move _109 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +105:5-115:7: @33.Call: _103 = Arguments::new_v1(move _104, move _108) -> [return: bb34, unwind: bb38] +105:5-115:7: @34.Call: _102 = _print(move _103) -> [return: bb35, unwind: bb38] +105:5-115:7: @36[6]: _101 = const () +118:9-118:24: @36[13]: FakeRead(ForLet, _123) +130:25-130:27: @36[15]: _125 = const 10_i32 +130:9-130:22: @36[16]: FakeRead(ForLet, _125) +131:33-131:67: @36[19]: _127 = &mut _125 +131:9-131:30: @36[22]: FakeRead(ForLet, _126) +136:9-136:30: @36[25]: FakeRead(ForLet, _128) +141:9-141:36: @36[28]: FakeRead(ForLet, _129) +143:9-143:33: @36[31]: FakeRead(ForLet, _130) +147:9-147:33: @36[34]: FakeRead(ForLet, _131) +151:9-151:40: @36[37]: FakeRead(ForLet, _132) +3:11-155:2: @36[38]: _0 = const ()"> let _almost_as_short_unused_closure = ⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37| _unused_arg: u8 - | { println!("not called") } | { println!("not called") }@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42⦊ -@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37⦊ + ; - ; +}⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42
+10:32-10:66: @3.Call: _8 = <String as From<&str>>::from(const "the string content") -> [return: bb4, unwind: bb45] +10:27-10:67: @4[0]: _7 = Option::<String>::Some(move _8) +10:9-10:24: @4[2]: FakeRead(ForLet, _7) +12:9-12:32: @4[9]: _137 = const main::promoted[4] +12:9-12:32: @4[10]: _14 = &(*_137) +12:9-12:32: @4[11]: _13 = &(*_14) +12:9-12:32: @4[12]: _12 = move _13 as &[&str] (Pointer(Unsize)) +14:9-14:20: @4[22]: _23 = move _7 +14:9-26:10: @4.Call: _22 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:18:13: 25:14]>(move _23, move _24) -> [return: bb5, unwind: bb43] +14:9-26:10: @5[2]: _21 = &_22 +11:5-27:7: @5[3]: _20 = (move _21,) +11:5-27:7: @5[5]: FakeRead(ForMatchedPlace, _20) +11:5-27:7: @5[7]: _26 = (_20.0: &std::string::String) +11:5-27:7: @5[10]: _28 = &(*_26) +11:5-27:7: @5[12]: _29 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +11:5-27:7: @5.Call: _27 = ArgumentV1::new::<String>(move _28, move _29) -> [return: bb6, unwind: bb42] +11:5-27:7: @6[2]: _19 = [move _27] +11:5-27:7: @6[5]: _18 = &_19 +11:5-27:7: @6[6]: _17 = &(*_18) +11:5-27:7: @6[7]: _16 = move _17 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +11:5-27:7: @6.Call: _11 = Arguments::new_v1(move _12, move _16) -> [return: bb7, unwind: bb42] +11:5-27:7: @7.Call: _10 = _print(move _11) -> [return: bb8, unwind: bb42] +11:5-27:7: @9[6]: _9 = const () +29:24-29:58: @9.Call: _31 = <String as From<&str>>::from(const "the string content") -> [return: bb10, unwind: bb43] +29:19-29:59: @10[0]: _30 = Option::<String>::Some(move _31) +33:9-40:6: @11[3]: _33 = &_5 +31:9-31:10: @11[6]: FakeRead(ForLet, _32) +42:9-42:32: @11[13]: _136 = const main::promoted[3] +42:9-42:32: @11[14]: _39 = &(*_136) +42:9-42:32: @11[15]: _38 = &(*_39) +42:9-42:32: @11[16]: _37 = move _38 as &[&str] (Pointer(Unsize)) +44:9-44:20: @11[26]: _48 = move _7 +48:13-48:14: @11[28]: _49 = _32 +44:9-49:10: @11.Call: _47 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:33:9: 40:6]>(move _48, move _49) -> [return: bb12, unwind: bb43] +44:9-49:10: @12[2]: _46 = &_47 +41:5-50:7: @12[3]: _45 = (move _46,) +41:5-50:7: @12[5]: FakeRead(ForMatchedPlace, _45) +41:5-50:7: @12[7]: _50 = (_45.0: &std::string::String) +41:5-50:7: @12[10]: _52 = &(*_50) +41:5-50:7: @12[12]: _53 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +41:5-50:7: @12.Call: _51 = ArgumentV1::new::<String>(move _52, move _53) -> [return: bb13, unwind: bb41] +41:5-50:7: @13[2]: _44 = [move _51] +41:5-50:7: @13[5]: _43 = &_44 +41:5-50:7: @13[6]: _42 = &(*_43) +41:5-50:7: @13[7]: _41 = move _42 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +41:5-50:7: @13.Call: _36 = Arguments::new_v1(move _37, move _41) -> [return: bb14, unwind: bb41] +41:5-50:7: @14.Call: _35 = _print(move _36) -> [return: bb15, unwind: bb41] +41:5-50:7: @16[6]: _34 = const () +52:19-52:23: @16[9]: _54 = Option::<String>::None +54:9-54:32: @17[7]: _135 = const main::promoted[2] +54:9-54:32: @17[8]: _60 = &(*_135) +54:9-54:32: @17[9]: _59 = &(*_60) +54:9-54:32: @17[10]: _58 = move _59 as &[&str] (Pointer(Unsize)) +56:9-56:20: @17[20]: _69 = move _7 +56:9-68:10: @17.Call: _68 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:60:13: 67:14]>(move _69, move _70) -> [return: bb18, unwind: bb43] +56:9-68:10: @18[2]: _67 = &_68 +53:5-69:7: @18[3]: _66 = (move _67,) +53:5-69:7: @18[5]: FakeRead(ForMatchedPlace, _66) +53:5-69:7: @18[7]: _72 = (_66.0: &std::string::String) +53:5-69:7: @18[10]: _74 = &(*_72) +53:5-69:7: @18[12]: _75 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +53:5-69:7: @18.Call: _73 = ArgumentV1::new::<String>(move _74, move _75) -> [return: bb19, unwind: bb40] +53:5-69:7: @19[2]: _65 = [move _73] +53:5-69:7: @19[5]: _64 = &_65 +53:5-69:7: @19[6]: _63 = &(*_64) +53:5-69:7: @19[7]: _62 = move _63 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +53:5-69:7: @19.Call: _57 = Arguments::new_v1(move _58, move _62) -> [return: bb20, unwind: bb40] +53:5-69:7: @20.Call: _56 = _print(move _57) -> [return: bb21, unwind: bb40] +53:5-69:7: @22[6]: _55 = const () +71:19-71:23: @22[9]: _76 = Option::<String>::None +75:9-82:6: @23[3]: _78 = &_5 +73:9-73:10: @23[6]: FakeRead(ForLet, _77) +84:9-84:32: @23[13]: _134 = const main::promoted[1] +84:9-84:32: @23[14]: _84 = &(*_134) +84:9-84:32: @23[15]: _83 = &(*_84) +84:9-84:32: @23[16]: _82 = move _83 as &[&str] (Pointer(Unsize)) +86:9-86:20: @23[26]: _93 = move _7 +90:13-90:14: @23[28]: _94 = _77 +86:9-91:10: @23.Call: _92 = Option::<String>::unwrap_or_else::<[closure@../coverage/closure.rs:75:9: 82:6]>(move _93, move _94) -> [return: bb24, unwind: bb43] +86:9-91:10: @24[2]: _91 = &_92 +83:5-92:7: @24[3]: _90 = (move _91,) +83:5-92:7: @24[5]: FakeRead(ForMatchedPlace, _90) +83:5-92:7: @24[7]: _95 = (_90.0: &std::string::String) +83:5-92:7: @24[10]: _97 = &(*_95) +83:5-92:7: @24[12]: _98 = <String as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r std::string::String, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +83:5-92:7: @24.Call: _96 = ArgumentV1::new::<String>(move _97, move _98) -> [return: bb25, unwind: bb39] +83:5-92:7: @25[2]: _89 = [move _96] +83:5-92:7: @25[5]: _88 = &_89 +83:5-92:7: @25[6]: _87 = &(*_88) +83:5-92:7: @25[7]: _86 = move _87 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +83:5-92:7: @25.Call: _81 = Arguments::new_v1(move _82, move _86) -> [return: bb26, unwind: bb39] +83:5-92:7: @26.Call: _80 = _print(move _81) -> [return: bb27, unwind: bb39] +83:5-92:7: @28[6]: _79 = const () +97:9-104:6: @28[10]: _100 = &_5 +95:9-95:22: @28[13]: FakeRead(ForLet, _99) +106:9-106:40: @28[20]: _133 = const main::promoted[0] +106:9-106:40: @28[21]: _106 = &(*_133) +106:9-106:40: @28[22]: _105 = &(*_106) +106:9-106:40: @28[23]: _104 = move _105 as &[&str] (Pointer(Unsize)) +108:9-108:39: @28.Call: _117 = std::iter::repeat::<&str>(const "repeat me") -> [return: bb29, unwind: bb43] +108:9-109:21: @29.Call: _116 = <std::iter::Repeat<&str> as Iterator>::take(move _117, const 5_usize) -> [return: bb30, unwind: bb43] +112:13-112:26: @30[2]: _118 = _99 +108:9-113:10: @30.Call: _115 = <std::iter::Take<std::iter::Repeat<&str>> as Iterator>::map::<String, [closure@../coverage/closure.rs:97:9: 104:6]>(move _116, move _118) -> [return: bb31, unwind: bb43] +108:9-114:33: @31.Call: _114 = <Map<std::iter::Take<std::iter::Repeat<&str>>, [closure@../coverage/closure.rs:97:9: 104:6]> as Iterator>::collect::<Vec<String>>(move _115) -> [return: bb32, unwind: bb43] +108:9-114:33: @32[1]: _113 = &_114 +105:5-115:7: @32[2]: _112 = (move _113,) +105:5-115:7: @32[4]: FakeRead(ForMatchedPlace, _112) +105:5-115:7: @32[6]: _119 = (_112.0: &std::vec::Vec<std::string::String>) +105:5-115:7: @32[9]: _121 = &(*_119) +105:5-115:7: @32[11]: _122 = <Vec<String> as Debug>::fmt as for<'r, 's, 't0> fn(&'r std::vec::Vec<std::string::String>, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +105:5-115:7: @32.Call: _120 = ArgumentV1::new::<Vec<String>>(move _121, move _122) -> [return: bb33, unwind: bb38] +105:5-115:7: @33[2]: _111 = [move _120] +105:5-115:7: @33[5]: _110 = &_111 +105:5-115:7: @33[6]: _109 = &(*_110) +105:5-115:7: @33[7]: _108 = move _109 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) +105:5-115:7: @33.Call: _103 = Arguments::new_v1(move _104, move _108) -> [return: bb34, unwind: bb38] +105:5-115:7: @34.Call: _102 = _print(move _103) -> [return: bb35, unwind: bb38] +105:5-115:7: @36[6]: _101 = const () +118:9-118:24: @36[13]: FakeRead(ForLet, _123) +130:25-130:27: @36[15]: _125 = const 10_i32 +130:9-130:22: @36[16]: FakeRead(ForLet, _125) +131:33-131:67: @36[19]: _127 = &mut _125 +131:9-131:30: @36[22]: FakeRead(ForLet, _126) +136:9-136:30: @36[25]: FakeRead(ForLet, _128) +141:9-141:36: @36[28]: FakeRead(ForLet, _129) +143:9-143:33: @36[31]: FakeRead(ForLet, _130) +147:9-147:33: @36[34]: FakeRead(ForLet, _131) +151:9-151:40: @36[37]: FakeRead(ForLet, _132) +3:11-155:2: @36[38]: _0 = const () +155:2-155:2: @37.Return: return">}⦉@0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.conditions/conditions.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.conditions/conditions.main.-------.InstrumentCoverage.0.html index 0aa6fe65686cf..184dba6abd17f 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.conditions/conditions.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.conditions/conditions.main.-------.InstrumentCoverage.0.html @@ -87,10 +87,10 @@ 10:16-10:29: @3[6]: _5 = Gt(move _6, const 7_u32)">@3⦊countdown > 7⦉@3 { @4,6⦊countdown -= 4; +12:9-12:10: @6[1]: _4 = const B">@4,6⦊countdown -= 4; B⦉@4,6 +12:9-12:10: @6[1]: _4 = const B"> B⦉@4,6 } else if @5⦊countdown > 2⦉@5 { if @74,87,88⦊should_be_reachable = countdown; println!("reached"); return⦉@74,87,88; }; diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.dead_code/dead_code.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.dead_code/dead_code.main.-------.InstrumentCoverage.0.html index be06ddd126da9..421fe27825c3f 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.dead_code/dead_code.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.dead_code/dead_code.main.-------.InstrumentCoverage.0.html @@ -69,65 +69,65 @@ -
@0,1,2,3⦊fn main() { - // Initialize test constants in a way that cannot be determined at compile time, to ensure - // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - // dependent conditions. - let is_true = std::env::args().len() == 1; - - let mut countdown = 0; -@0,1,2,3⦊fn unused_fn() { - // Initialize test constants in a way that cannot be determined at compile time, to ensure - // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - // dependent conditions. - let is_true = std::env::args().len() == 1; - - let mut countdown = 0; -@0,1,2,3⦊pub fn unused_pub_fn_not_in_library() { - // Initialize test constants in a way that cannot be determined at compile time, to ensure - // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - // dependent conditions. - let is_true = std::env::args().len() == 1; - - let mut countdown = 0; -@3,5,6,7⦊assert_eq!(1, 1);⦉@3,5,6,7⦉@4 } else { @9⦊@8,10,11,12⦊assert_eq!(1, 2);⦉@8,10,11,12⦉@9 } }@13⦊⦉@13
diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.doctest_crate/doctest_crate.fn_run_in_doctests.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.doctest_crate/doctest_crate.fn_run_in_doctests.-------.InstrumentCoverage.0.html index f55bb0f32d9ce..02c25cc904c4a 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.doctest_crate/doctest_crate.fn_run_in_doctests.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.doctest_crate/doctest_crate.fn_run_in_doctests.-------.InstrumentCoverage.0.html @@ -84,16 +84,16 @@ 4:14-4:30: @6[28]: _28 = (_23.0: &&i32) 4:14-4:30: @6[30]: _29 = (_23.1: &&i32) 4:14-4:30: @6[33]: _31 = &(*_28) -4:14-4:30: @6[35]: _32 = <&i32 as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -4:14-4:30: @6.Call: _30 = std::fmt::ArgumentV1::new::<&i32>(move _31, move _32) -> [return: bb8, unwind: bb29] +4:14-4:30: @6[35]: _32 = <&i32 as Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +4:14-4:30: @6.Call: _30 = ArgumentV1::new::<&i32>(move _31, move _32) -> [return: bb8, unwind: bb29] 4:14-4:30: @8[4]: _34 = &(*_29) -4:14-4:30: @8[6]: _35 = <&i32 as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -4:14-4:30: @8.Call: _33 = std::fmt::ArgumentV1::new::<&i32>(move _34, move _35) -> [return: bb9, unwind: bb29] +4:14-4:30: @8[6]: _35 = <&i32 as Debug>::fmt as for<'r, 's, 't0> fn(&'r &i32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +4:14-4:30: @8.Call: _33 = ArgumentV1::new::<&i32>(move _34, move _35) -> [return: bb9, unwind: bb29] 4:14-4:30: @9[2]: _22 = [move _30, move _33] 4:14-4:30: @9[7]: _21 = &_22 4:14-4:30: @9[8]: _20 = &(*_21) 4:14-4:30: @9[9]: _19 = move _20 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -4:14-4:30: @9.Call: _14 = std::fmt::Arguments::new_v1(move _15, move _19) -> [return: bb10, unwind: bb29] +4:14-4:30: @9.Call: _14 = Arguments::new_v1(move _15, move _19) -> [return: bb10, unwind: bb29] 4:14-4:30: @10.Call: core::panicking::panic_fmt(move _14) -> bb29">@6,8,9,10⦊assert_eq!(1, 1)⦉@6,8,9,10⦉@7, // this is run, 2 => @13⦊@12,14,15,16⦊assert_eq!(1, 1)⦉@12,14,15,16⦉@13, // this, 3 => @19⦊@18,20,21,22⦊assert_eq!(1, 1)⦉@18,20,21,22⦉@19, // and this too _ => @24⦊@23,25,26,27⦊assert_eq!(1, 2)⦉@23,25,26,27⦉@24, // however this is not } }@28⦊⦉@28 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.drop_trait/drop_trait.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.drop_trait/drop_trait.main.-------.InstrumentCoverage.0.html index 66a6e776a0622..3b5d1e2cdac28 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.drop_trait/drop_trait.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.drop_trait/drop_trait.main.-------.InstrumentCoverage.0.html @@ -109,8 +109,8 @@ 20:9-20:43: @1[18]: _15 = &(*_20) 20:9-20:43: @1[19]: _14 = &(*_15) 20:9-20:43: @1[20]: _13 = move _14 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -20:9-20:43: @1.Call: _8 = std::fmt::Arguments::new_v1(move _9, move _13) -> [return: bb3, unwind: bb11] -20:9-20:43: @3.Call: _7 = std::io::_print(move _8) -> [return: bb4, unwind: bb11] +20:9-20:43: @1.Call: _8 = Arguments::new_v1(move _9, move _13) -> [return: bb3, unwind: bb11] +20:9-20:43: @3.Call: _7 = _print(move _8) -> [return: bb4, unwind: bb11] 20:9-20:43: @4[5]: _6 = const () 21:16-21:22: @4[7]: _0 = std::result::Result::<(), u8>::Err(const 1_u8)">@1,3,4,8,9⦊println!("Exiting with error..."); return Err(1)⦉@1,3,4,8,9; } @0,1,2,3⦊fn drop(&mut self) { - println!("BOOM times {}!!!", self.strength); - }⦉@0,1,2,3 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.generics/generics.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.generics/generics.main.-------.InstrumentCoverage.0.html index 098c140425160..0373b38e1b11f 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.generics/generics.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.generics/generics.main.-------.InstrumentCoverage.0.html @@ -178,8 +178,8 @@ 31:9-31:43: @4[18]: _21 = &(*_26) 31:9-31:43: @4[19]: _20 = &(*_21) 31:9-31:43: @4[20]: _19 = move _20 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -31:9-31:43: @4.Call: _14 = std::fmt::Arguments::new_v1(move _15, move _19) -> [return: bb6, unwind: bb14] -31:9-31:43: @6.Call: _13 = std::io::_print(move _14) -> [return: bb7, unwind: bb14] +31:9-31:43: @4.Call: _14 = Arguments::new_v1(move _15, move _19) -> [return: bb6, unwind: bb14] +31:9-31:43: @6.Call: _13 = _print(move _14) -> [return: bb7, unwind: bb14] 31:9-31:43: @7[5]: _12 = const () 32:16-32:22: @7[7]: _0 = std::result::Result::<(), u8>::Err(const 1_u8)">@4,6,7,11,12⦊println!("Exiting with error..."); return Err(1)⦉@4,6,7,11,12; } @0,1,2,3⦊fn drop(&mut self) { - println!("BOOM times {}!!!", self.strength); - }⦉@0,1,2,3 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.if/if.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.if/if.main.-------.InstrumentCoverage.0.html index d6eccf57846ef..dd9ba4a190cd8 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.if/if.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.if/if.main.-------.InstrumentCoverage.0.html @@ -69,153 +69,153 @@ -
@0,1,2,3⦊fn main() { - // Initialize test constants in a way that cannot be determined at compile time, to ensure - // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - // dependent conditions. - let - is_true - = - std::env::args().len() - == - 1 - ; - let - mut - countdown - = - 0 - ; - if -@0,1,2,3⦊fn main() { - // Initialize test constants in a way that cannot be determined at compile time, to ensure - // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - // dependent conditions. - let is_true = std::env::args().len() == 1; - - let mut countdown = 0; - if - @0,1,2⦊fn default_trait_func(&mut self) { - in_func(IN_CONST); - self.trait_func(IN_CONST); - }⦉@0,1,2
diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.inner_items/inner_items.main-in_func.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.inner_items/inner_items.main-in_func.-------.InstrumentCoverage.0.html index 82724e5e86517..8b5257b02bbd6 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.inner_items/inner_items.main-in_func.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.inner_items/inner_items.main-in_func.-------.InstrumentCoverage.0.html @@ -76,7 +76,7 @@ 20:17-20:22: @0[8]: _6 = CheckedAdd(_4, _5) 20:17-20:22: @1[0]: _3 = move (_6.0: u32) 20:13-20:14: @1[3]: FakeRead(ForLet, _3) -21:18-21:26: @1[9]: _23 = const main::in_func::promoted[0] +21:18-21:26: @1[9]: _23 = const in_func::promoted[0] 21:18-21:26: @1[10]: _11 = &(*_23) 21:18-21:26: @1[11]: _10 = &(*_11) 21:18-21:26: @1[12]: _9 = move _10 as &[&str] (Pointer(Unsize)) @@ -86,13 +86,13 @@ 21:9-21:30: @1[25]: _19 = (_17.0: &u32) 21:9-21:30: @1[28]: _21 = &(*_19) 21:9-21:30: @1[30]: _22 = <u32 as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r u32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -21:9-21:30: @1.Call: _20 = std::fmt::ArgumentV1::new::<u32>(move _21, move _22) -> [return: bb2, unwind: bb5] +21:9-21:30: @1.Call: _20 = ArgumentV1::new::<u32>(move _21, move _22) -> [return: bb2, unwind: bb5] 21:9-21:30: @2[2]: _16 = [move _20] 21:9-21:30: @2[5]: _15 = &_16 21:9-21:30: @2[6]: _14 = &(*_15) 21:9-21:30: @2[7]: _13 = move _14 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -21:9-21:30: @2.Call: _8 = std::fmt::Arguments::new_v1(move _9, move _13) -> [return: bb3, unwind: bb5] -21:9-21:30: @3.Call: _7 = std::io::_print(move _8) -> [return: bb4, unwind: bb5] +21:9-21:30: @2.Call: _8 = Arguments::new_v1(move _9, move _13) -> [return: bb3, unwind: bb5] +21:9-21:30: @3.Call: _7 = _print(move _8) -> [return: bb4, unwind: bb5] 21:9-21:30: @4[6]: _0 = const () 22:6-22:6: @4.Return: return">@0,1,2,3,4⦊fn in_func(a: u32) {
let b = 1; let c = a + b; println!("c = {}", c) }⦉@0,1,2,3,4
diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.inner_items/inner_items.main-{impl#0}-trait_func.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.inner_items/inner_items.main-{impl#0}-trait_func.-------.InstrumentCoverage.0.html index b00a781a0a74c..ee1e0339049e1 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.inner_items/inner_items.main-{impl#0}-trait_func.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.inner_items/inner_items.main-{impl#0}-trait_func.-------.InstrumentCoverage.0.html @@ -73,28 +73,28 @@ 41:13-41:41: @0[2]: _4 = CheckedAdd(((*_1).0: u32), _3) 41:13-41:41: @1[0]: ((*_1).0: u32) = move (_4.0: u32) 42:21-42:41: @1[4]: _6 = ((*_1).0: u32) -42:13-42:42: @1.Call: _5 = main::in_func(move _6) -> [return: bb2, unwind: bb3] +42:13-42:42: @1.Call: _5 = in_func(move _6) -> [return: bb2, unwind: bb3] 40:45-43:10: @2[2]: _0 = const () 43:10-43:10: @2.Return: return">@0,1,2⦊fn trait_func(&mut self, incr: u32) {
self.in_struct_field += incr; in_func(self.in_struct_field); }⦉@0,1,2
diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.inner_items/inner_items.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.inner_items/inner_items.main.-------.InstrumentCoverage.0.html index 4a1003dfbed32..d21710b7240d3 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.inner_items/inner_items.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.inner_items/inner_items.main.-------.InstrumentCoverage.0.html @@ -73,33 +73,33 @@ // Initialize test constants in a way that cannot be determined at compile time, to ensure // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from // dependent conditions. - let let @0,1,2,3⦊is_true = std::env::args().len() == 1; - - let mut countdown = 0; - type InType = String; if @6⦊is_true⦉@6 @7,9⦊{ in_func(countdown); }⦉@7,9@8⦊⦉@8 - let let @10,11⦊mut val = InStruct { - in_struct_field: 101, - }; - - val.default_trait_func(); -}⦉@10,11 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.lazy_boolean/lazy_boolean.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.lazy_boolean/lazy_boolean.main.-------.InstrumentCoverage.0.html index 358e2e2bbba3c..0cfe2119fbc8a 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.lazy_boolean/lazy_boolean.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.lazy_boolean/lazy_boolean.main.-------.InstrumentCoverage.0.html @@ -69,9 +69,9 @@ -
@0,1,2,3⦊fn main() { - // Initialize test constants in a way that cannot be determined at compile time, to ensure - // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - // dependent conditions. - let is_true = std::env::args().len() == 1; - - let (mut a, mut b, mut c) = (0, 0, 0); -@0,1,2,3⦊fn main() { @@ -102,14 +102,14 @@ 24:5-24:34: @0[23]: FakeRead(ForMatchedPlace, _13) 24:5-24:34: @0[25]: _15 = (_13.0: &DebugTest) 24:5-24:34: @0[28]: _17 = &(*_15) -24:5-24:34: @0[30]: _18 = <DebugTest as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r DebugTest, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -24:5-24:34: @0.Call: _16 = std::fmt::ArgumentV1::new::<DebugTest>(move _17, move _18) -> [return: bb1, unwind: bb4] +24:5-24:34: @0[30]: _18 = <DebugTest as Debug>::fmt as for<'r, 's, 't0> fn(&'r DebugTest, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +24:5-24:34: @0.Call: _16 = ArgumentV1::new::<DebugTest>(move _17, move _18) -> [return: bb1, unwind: bb4] 24:5-24:34: @1[2]: _12 = [move _16] 24:5-24:34: @1[5]: _11 = &_12 24:5-24:34: @1[6]: _10 = &(*_11) 24:5-24:34: @1[7]: _9 = move _10 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -24:5-24:34: @1.Call: _4 = std::fmt::Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb4] -24:5-24:34: @2.Call: _3 = std::io::_print(move _4) -> [return: bb3, unwind: bb4] +24:5-24:34: @1.Call: _4 = Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb4] +24:5-24:34: @2.Call: _3 = _print(move _4) -> [return: bb3, unwind: bb4] 24:5-24:34: @3[6]: _2 = const () 22:11-25:2: @3[8]: _0 = const () 25:2-25:2: @3.Return: return"> let debug_test = DebugTest; @@ -124,14 +124,14 @@ 24:5-24:34: @0[23]: FakeRead(ForMatchedPlace, _13) 24:5-24:34: @0[25]: _15 = (_13.0: &DebugTest) 24:5-24:34: @0[28]: _17 = &(*_15) -24:5-24:34: @0[30]: _18 = <DebugTest as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r DebugTest, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -24:5-24:34: @0.Call: _16 = std::fmt::ArgumentV1::new::<DebugTest>(move _17, move _18) -> [return: bb1, unwind: bb4] +24:5-24:34: @0[30]: _18 = <DebugTest as Debug>::fmt as for<'r, 's, 't0> fn(&'r DebugTest, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +24:5-24:34: @0.Call: _16 = ArgumentV1::new::<DebugTest>(move _17, move _18) -> [return: bb1, unwind: bb4] 24:5-24:34: @1[2]: _12 = [move _16] 24:5-24:34: @1[5]: _11 = &_12 24:5-24:34: @1[6]: _10 = &(*_11) 24:5-24:34: @1[7]: _9 = move _10 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -24:5-24:34: @1.Call: _4 = std::fmt::Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb4] -24:5-24:34: @2.Call: _3 = std::io::_print(move _4) -> [return: bb3, unwind: bb4] +24:5-24:34: @1.Call: _4 = Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb4] +24:5-24:34: @2.Call: _3 = _print(move _4) -> [return: bb3, unwind: bb4] 24:5-24:34: @3[6]: _2 = const () 22:11-25:2: @3[8]: _0 = const () 25:2-25:2: @3.Return: return"> println!("{:?}", debug_test); @@ -146,14 +146,14 @@ 24:5-24:34: @0[23]: FakeRead(ForMatchedPlace, _13) 24:5-24:34: @0[25]: _15 = (_13.0: &DebugTest) 24:5-24:34: @0[28]: _17 = &(*_15) -24:5-24:34: @0[30]: _18 = <DebugTest as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r DebugTest, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -24:5-24:34: @0.Call: _16 = std::fmt::ArgumentV1::new::<DebugTest>(move _17, move _18) -> [return: bb1, unwind: bb4] +24:5-24:34: @0[30]: _18 = <DebugTest as Debug>::fmt as for<'r, 's, 't0> fn(&'r DebugTest, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +24:5-24:34: @0.Call: _16 = ArgumentV1::new::<DebugTest>(move _17, move _18) -> [return: bb1, unwind: bb4] 24:5-24:34: @1[2]: _12 = [move _16] 24:5-24:34: @1[5]: _11 = &_12 24:5-24:34: @1[6]: _10 = &(*_11) 24:5-24:34: @1[7]: _9 = move _10 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -24:5-24:34: @1.Call: _4 = std::fmt::Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb4] -24:5-24:34: @2.Call: _3 = std::io::_print(move _4) -> [return: bb3, unwind: bb4] +24:5-24:34: @1.Call: _4 = Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb4] +24:5-24:34: @2.Call: _3 = _print(move _4) -> [return: bb3, unwind: bb4] 24:5-24:34: @3[6]: _2 = const () 22:11-25:2: @3[8]: _0 = const () 25:2-25:2: @3.Return: return">}⦉@0,1,2,3
diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.loops_branches/loops_branches.{impl#0}-fmt.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.loops_branches/loops_branches.{impl#0}-fmt.-------.InstrumentCoverage.0.html index f6f08b6a7704b..b3f344f7fc0b8 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.loops_branches/loops_branches.{impl#0}-fmt.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.loops_branches/loops_branches.{impl#0}-fmt.-------.InstrumentCoverage.0.html @@ -77,20 +77,20 @@ }⦉@6,8
}@3⦊⦉@3 @9,10,11,12⦊write!(f, "error")⦉@9,10,11,12@9,10,11,12⦊write!(f, "error")⦉@9,10,11,12@14,16,17,18⦊?⦉@14,16,17,18; +15:31-15:32: @16.Call: _27 = <std::fmt::Error as From<std::fmt::Error>>::from(move _28) -> [return: bb17, unwind: bb21]">@14,16,17,18⦊?⦉@14,16,17,18
;
} else @2⦊{ }⦉@2 @0,1,2,3⦊fn main() { - // Initialize test constants in a way that cannot be determined at compile time, to ensure - // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - // dependent conditions. - let is_true = std::env::args().len() == 1; - - let mut a: u8 = 0; - let mut b: u8 = 0; -@0,1,2,3⦊fn main() { - let is_true = std::env::args().len() == 1; -@14,16⦊_⦉@14,16 in @10,11,12⦊0..50⦉@10,11,12 { if @14,16⦊a < 30⦉@14,16 { diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.overflow/overflow.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.overflow/overflow.main.-------.InstrumentCoverage.0.html index 2a9b1b10efcd2..ca3515689d337 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.overflow/overflow.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.overflow/overflow.main.-------.InstrumentCoverage.0.html @@ -89,13 +89,13 @@ 20:13-20:44: @8[23]: _23 = (_21.0: &u32) 20:13-20:44: @8[26]: _25 = &(*_23) 20:13-20:44: @8[28]: _26 = <u32 as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r u32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -20:13-20:44: @8.Call: _24 = std::fmt::ArgumentV1::new::<u32>(move _25, move _26) -> [return: bb9, unwind: bb21] +20:13-20:44: @8.Call: _24 = ArgumentV1::new::<u32>(move _25, move _26) -> [return: bb9, unwind: bb21] 20:13-20:44: @9[2]: _20 = [move _24] 20:13-20:44: @9[5]: _19 = &_20 20:13-20:44: @9[6]: _18 = &(*_19) 20:13-20:44: @9[7]: _17 = move _18 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -20:13-20:44: @9.Call: _12 = std::fmt::Arguments::new_v1(move _13, move _17) -> [return: bb10, unwind: bb21] -20:13-20:44: @10.Call: _11 = std::io::_print(move _12) -> [return: bb11, unwind: bb21] +20:13-20:44: @9.Call: _12 = Arguments::new_v1(move _13, move _17) -> [return: bb10, unwind: bb21] +20:13-20:44: @10.Call: _11 = _print(move _12) -> [return: bb11, unwind: bb21] 20:13-20:44: @11[6]: _10 = const () 18:27-21:10: @11[8]: _6 = const ()">@6,8,9,10,11⦊{ let result = might_overflow(10); println!("Result: {}", result); }⦉@6,8,9,10,11 else if @7⦊countdown < 5⦉@7 @12,14,15,16,17⦊{ let result = might_overflow(1); println!("Result: {}", result); }⦉@12,14,15,16,17@13⦊⦉@13 @1,3,4⦊{ println!("this will probably overflow"); }⦉@1,3,4@2⦊⦉@2 let @5,6,7,8,9,10,11,12,13⦊add_to = u32::MAX - 5; @@ -175,16 +175,16 @@ 9:5-9:56: @6[29]: _34 = (_30.1: &u32) 9:5-9:56: @6[32]: _36 = &(*_33) 9:5-9:56: @6[34]: _37 = <u32 as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r u32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -9:5-9:56: @6.Call: _35 = std::fmt::ArgumentV1::new::<u32>(move _36, move _37) -> [return: bb7, unwind: bb14] +9:5-9:56: @6.Call: _35 = ArgumentV1::new::<u32>(move _36, move _37) -> [return: bb7, unwind: bb14] 9:5-9:56: @7[4]: _39 = &(*_34) 9:5-9:56: @7[6]: _40 = <u32 as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r u32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -9:5-9:56: @7.Call: _38 = std::fmt::ArgumentV1::new::<u32>(move _39, move _40) -> [return: bb8, unwind: bb14] +9:5-9:56: @7.Call: _38 = ArgumentV1::new::<u32>(move _39, move _40) -> [return: bb8, unwind: bb14] 9:5-9:56: @8[2]: _29 = [move _35, move _38] 9:5-9:56: @8[7]: _28 = &_29 9:5-9:56: @8[8]: _27 = &(*_28) 9:5-9:56: @8[9]: _26 = move _27 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -9:5-9:56: @8.Call: _21 = std::fmt::Arguments::new_v1(move _22, move _26) -> [return: bb9, unwind: bb14] -9:5-9:56: @9.Call: _20 = std::io::_print(move _21) -> [return: bb10, unwind: bb14] +9:5-9:56: @8.Call: _21 = Arguments::new_v1(move _22, move _26) -> [return: bb9, unwind: bb14] +9:5-9:56: @9.Call: _20 = _print(move _21) -> [return: bb10, unwind: bb14] 9:5-9:56: @10[6]: _19 = const () 10:18-10:24: @10[10]: _42 = _1 10:27-10:33: @10[12]: _43 = _17 @@ -201,8 +201,8 @@ 11:5-11:49: @11[22]: _54 = &(*_57) 11:5-11:49: @11[23]: _53 = &(*_54) 11:5-11:49: @11[24]: _52 = move _53 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -11:5-11:49: @11.Call: _47 = std::fmt::Arguments::new_v1(move _48, move _52) -> [return: bb12, unwind: bb14] -11:5-11:49: @12.Call: _46 = std::io::_print(move _47) -> [return: bb13, unwind: bb14] +11:5-11:49: @11.Call: _47 = Arguments::new_v1(move _48, move _52) -> [return: bb12, unwind: bb14] +11:5-11:49: @12.Call: _46 = _print(move _47) -> [return: bb13, unwind: bb14] 11:5-11:49: @13[5]: _45 = const () 12:5-12:11: @13[7]: _0 = _41 13:2-13:2: @13.Return: return"> println!("does {} + {} overflow?", add_to, to_add); @@ -221,16 +221,16 @@ 9:5-9:56: @6[29]: _34 = (_30.1: &u32) 9:5-9:56: @6[32]: _36 = &(*_33) 9:5-9:56: @6[34]: _37 = <u32 as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r u32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -9:5-9:56: @6.Call: _35 = std::fmt::ArgumentV1::new::<u32>(move _36, move _37) -> [return: bb7, unwind: bb14] +9:5-9:56: @6.Call: _35 = ArgumentV1::new::<u32>(move _36, move _37) -> [return: bb7, unwind: bb14] 9:5-9:56: @7[4]: _39 = &(*_34) 9:5-9:56: @7[6]: _40 = <u32 as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r u32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -9:5-9:56: @7.Call: _38 = std::fmt::ArgumentV1::new::<u32>(move _39, move _40) -> [return: bb8, unwind: bb14] +9:5-9:56: @7.Call: _38 = ArgumentV1::new::<u32>(move _39, move _40) -> [return: bb8, unwind: bb14] 9:5-9:56: @8[2]: _29 = [move _35, move _38] 9:5-9:56: @8[7]: _28 = &_29 9:5-9:56: @8[8]: _27 = &(*_28) 9:5-9:56: @8[9]: _26 = move _27 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -9:5-9:56: @8.Call: _21 = std::fmt::Arguments::new_v1(move _22, move _26) -> [return: bb9, unwind: bb14] -9:5-9:56: @9.Call: _20 = std::io::_print(move _21) -> [return: bb10, unwind: bb14] +9:5-9:56: @8.Call: _21 = Arguments::new_v1(move _22, move _26) -> [return: bb9, unwind: bb14] +9:5-9:56: @9.Call: _20 = _print(move _21) -> [return: bb10, unwind: bb14] 9:5-9:56: @10[6]: _19 = const () 10:18-10:24: @10[10]: _42 = _1 10:27-10:33: @10[12]: _43 = _17 @@ -247,8 +247,8 @@ 11:5-11:49: @11[22]: _54 = &(*_57) 11:5-11:49: @11[23]: _53 = &(*_54) 11:5-11:49: @11[24]: _52 = move _53 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -11:5-11:49: @11.Call: _47 = std::fmt::Arguments::new_v1(move _48, move _52) -> [return: bb12, unwind: bb14] -11:5-11:49: @12.Call: _46 = std::io::_print(move _47) -> [return: bb13, unwind: bb14] +11:5-11:49: @11.Call: _47 = Arguments::new_v1(move _48, move _52) -> [return: bb12, unwind: bb14] +11:5-11:49: @12.Call: _46 = _print(move _47) -> [return: bb13, unwind: bb14] 11:5-11:49: @13[5]: _45 = const () 12:5-12:11: @13[7]: _0 = _41 13:2-13:2: @13.Return: return"> let result = to_add + add_to; @@ -267,16 +267,16 @@ 9:5-9:56: @6[29]: _34 = (_30.1: &u32) 9:5-9:56: @6[32]: _36 = &(*_33) 9:5-9:56: @6[34]: _37 = <u32 as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r u32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -9:5-9:56: @6.Call: _35 = std::fmt::ArgumentV1::new::<u32>(move _36, move _37) -> [return: bb7, unwind: bb14] +9:5-9:56: @6.Call: _35 = ArgumentV1::new::<u32>(move _36, move _37) -> [return: bb7, unwind: bb14] 9:5-9:56: @7[4]: _39 = &(*_34) 9:5-9:56: @7[6]: _40 = <u32 as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r u32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -9:5-9:56: @7.Call: _38 = std::fmt::ArgumentV1::new::<u32>(move _39, move _40) -> [return: bb8, unwind: bb14] +9:5-9:56: @7.Call: _38 = ArgumentV1::new::<u32>(move _39, move _40) -> [return: bb8, unwind: bb14] 9:5-9:56: @8[2]: _29 = [move _35, move _38] 9:5-9:56: @8[7]: _28 = &_29 9:5-9:56: @8[8]: _27 = &(*_28) 9:5-9:56: @8[9]: _26 = move _27 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -9:5-9:56: @8.Call: _21 = std::fmt::Arguments::new_v1(move _22, move _26) -> [return: bb9, unwind: bb14] -9:5-9:56: @9.Call: _20 = std::io::_print(move _21) -> [return: bb10, unwind: bb14] +9:5-9:56: @8.Call: _21 = Arguments::new_v1(move _22, move _26) -> [return: bb9, unwind: bb14] +9:5-9:56: @9.Call: _20 = _print(move _21) -> [return: bb10, unwind: bb14] 9:5-9:56: @10[6]: _19 = const () 10:18-10:24: @10[10]: _42 = _1 10:27-10:33: @10[12]: _43 = _17 @@ -293,8 +293,8 @@ 11:5-11:49: @11[22]: _54 = &(*_57) 11:5-11:49: @11[23]: _53 = &(*_54) 11:5-11:49: @11[24]: _52 = move _53 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -11:5-11:49: @11.Call: _47 = std::fmt::Arguments::new_v1(move _48, move _52) -> [return: bb12, unwind: bb14] -11:5-11:49: @12.Call: _46 = std::io::_print(move _47) -> [return: bb13, unwind: bb14] +11:5-11:49: @11.Call: _47 = Arguments::new_v1(move _48, move _52) -> [return: bb12, unwind: bb14] +11:5-11:49: @12.Call: _46 = _print(move _47) -> [return: bb13, unwind: bb14] 11:5-11:49: @13[5]: _45 = const () 12:5-12:11: @13[7]: _0 = _41 13:2-13:2: @13.Return: return"> println!("continuing after overflow check"); @@ -313,16 +313,16 @@ 9:5-9:56: @6[29]: _34 = (_30.1: &u32) 9:5-9:56: @6[32]: _36 = &(*_33) 9:5-9:56: @6[34]: _37 = <u32 as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r u32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -9:5-9:56: @6.Call: _35 = std::fmt::ArgumentV1::new::<u32>(move _36, move _37) -> [return: bb7, unwind: bb14] +9:5-9:56: @6.Call: _35 = ArgumentV1::new::<u32>(move _36, move _37) -> [return: bb7, unwind: bb14] 9:5-9:56: @7[4]: _39 = &(*_34) 9:5-9:56: @7[6]: _40 = <u32 as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r u32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -9:5-9:56: @7.Call: _38 = std::fmt::ArgumentV1::new::<u32>(move _39, move _40) -> [return: bb8, unwind: bb14] +9:5-9:56: @7.Call: _38 = ArgumentV1::new::<u32>(move _39, move _40) -> [return: bb8, unwind: bb14] 9:5-9:56: @8[2]: _29 = [move _35, move _38] 9:5-9:56: @8[7]: _28 = &_29 9:5-9:56: @8[8]: _27 = &(*_28) 9:5-9:56: @8[9]: _26 = move _27 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -9:5-9:56: @8.Call: _21 = std::fmt::Arguments::new_v1(move _22, move _26) -> [return: bb9, unwind: bb14] -9:5-9:56: @9.Call: _20 = std::io::_print(move _21) -> [return: bb10, unwind: bb14] +9:5-9:56: @8.Call: _21 = Arguments::new_v1(move _22, move _26) -> [return: bb9, unwind: bb14] +9:5-9:56: @9.Call: _20 = _print(move _21) -> [return: bb10, unwind: bb14] 9:5-9:56: @10[6]: _19 = const () 10:18-10:24: @10[10]: _42 = _1 10:27-10:33: @10[12]: _43 = _17 @@ -339,8 +339,8 @@ 11:5-11:49: @11[22]: _54 = &(*_57) 11:5-11:49: @11[23]: _53 = &(*_54) 11:5-11:49: @11[24]: _52 = move _53 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -11:5-11:49: @11.Call: _47 = std::fmt::Arguments::new_v1(move _48, move _52) -> [return: bb12, unwind: bb14] -11:5-11:49: @12.Call: _46 = std::io::_print(move _47) -> [return: bb13, unwind: bb14] +11:5-11:49: @11.Call: _47 = Arguments::new_v1(move _48, move _52) -> [return: bb12, unwind: bb14] +11:5-11:49: @12.Call: _46 = _print(move _47) -> [return: bb13, unwind: bb14] 11:5-11:49: @13[5]: _45 = const () 12:5-12:11: @13[7]: _0 = _41 13:2-13:2: @13.Return: return"> result @@ -359,16 +359,16 @@ 9:5-9:56: @6[29]: _34 = (_30.1: &u32) 9:5-9:56: @6[32]: _36 = &(*_33) 9:5-9:56: @6[34]: _37 = <u32 as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r u32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -9:5-9:56: @6.Call: _35 = std::fmt::ArgumentV1::new::<u32>(move _36, move _37) -> [return: bb7, unwind: bb14] +9:5-9:56: @6.Call: _35 = ArgumentV1::new::<u32>(move _36, move _37) -> [return: bb7, unwind: bb14] 9:5-9:56: @7[4]: _39 = &(*_34) 9:5-9:56: @7[6]: _40 = <u32 as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r u32, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -9:5-9:56: @7.Call: _38 = std::fmt::ArgumentV1::new::<u32>(move _39, move _40) -> [return: bb8, unwind: bb14] +9:5-9:56: @7.Call: _38 = ArgumentV1::new::<u32>(move _39, move _40) -> [return: bb8, unwind: bb14] 9:5-9:56: @8[2]: _29 = [move _35, move _38] 9:5-9:56: @8[7]: _28 = &_29 9:5-9:56: @8[8]: _27 = &(*_28) 9:5-9:56: @8[9]: _26 = move _27 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -9:5-9:56: @8.Call: _21 = std::fmt::Arguments::new_v1(move _22, move _26) -> [return: bb9, unwind: bb14] -9:5-9:56: @9.Call: _20 = std::io::_print(move _21) -> [return: bb10, unwind: bb14] +9:5-9:56: @8.Call: _21 = Arguments::new_v1(move _22, move _26) -> [return: bb9, unwind: bb14] +9:5-9:56: @9.Call: _20 = _print(move _21) -> [return: bb10, unwind: bb14] 9:5-9:56: @10[6]: _19 = const () 10:18-10:24: @10[10]: _42 = _1 10:27-10:33: @10[12]: _43 = _17 @@ -385,8 +385,8 @@ 11:5-11:49: @11[22]: _54 = &(*_57) 11:5-11:49: @11[23]: _53 = &(*_54) 11:5-11:49: @11[24]: _52 = move _53 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -11:5-11:49: @11.Call: _47 = std::fmt::Arguments::new_v1(move _48, move _52) -> [return: bb12, unwind: bb14] -11:5-11:49: @12.Call: _46 = std::io::_print(move _47) -> [return: bb13, unwind: bb14] +11:5-11:49: @11.Call: _47 = Arguments::new_v1(move _48, move _52) -> [return: bb12, unwind: bb14] +11:5-11:49: @12.Call: _46 = _print(move _47) -> [return: bb13, unwind: bb14] 11:5-11:49: @13[5]: _45 = const () 12:5-12:11: @13[7]: _0 = _41 13:2-13:2: @13.Return: return">}⦉@5,6,7,8,9,10,11,12,13 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.panic_unwind/panic_unwind.might_panic.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.panic_unwind/panic_unwind.might_panic.-------.InstrumentCoverage.0.html index 32988629ba0eb..86d9875b47cb5 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.panic_unwind/panic_unwind.might_panic.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.panic_unwind/panic_unwind.might_panic.-------.InstrumentCoverage.0.html @@ -81,10 +81,10 @@ 6:9-6:34: @1[18]: _13 = &(*_32) 6:9-6:34: @1[19]: _12 = &(*_13) 6:9-6:34: @1[20]: _11 = move _12 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -6:9-6:34: @1.Call: _6 = std::fmt::Arguments::new_v1(move _7, move _11) -> [return: bb3, unwind: bb7] -6:9-6:34: @3.Call: _5 = std::io::_print(move _6) -> [return: bb4, unwind: bb7] +6:9-6:34: @1.Call: _6 = Arguments::new_v1(move _7, move _11) -> [return: bb3, unwind: bb7] +6:9-6:34: @3.Call: _5 = _print(move _6) -> [return: bb4, unwind: bb7] 6:9-6:34: @4[5]: _4 = const () -7:9-7:26: @4.Call: std::rt::begin_panic::<&str>(const "panics") -> bb7">@1,3,4⦊println!("panicking..."); +7:9-7:26: @4.Call: begin_panic::<&str>(const "panics") -> bb7">@1,3,4⦊println!("panicking..."); panic!("panics");⦉@1,3,4 +7:9-7:26: @4.Call: begin_panic::<&str>(const "panics") -> bb7"> panic!("panics");⦉@1,3,4 } else @2,5,6⦊{ @@ -124,8 +124,8 @@ 9:9-9:33: @2[18]: _27 = &(*_30) 9:9-9:33: @2[19]: _26 = &(*_27) 9:9-9:33: @2[20]: _25 = move _26 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -9:9-9:33: @2.Call: _20 = std::fmt::Arguments::new_v1(move _21, move _25) -> [return: bb5, unwind: bb7] -9:9-9:33: @5.Call: _19 = std::io::_print(move _20) -> [return: bb6, unwind: bb7] +9:9-9:33: @2.Call: _20 = Arguments::new_v1(move _21, move _25) -> [return: bb5, unwind: bb7] +9:9-9:33: @5.Call: _19 = _print(move _20) -> [return: bb6, unwind: bb7] 9:9-9:33: @6[5]: _18 = const () 8:12-10:6: @6[7]: _0 = const () 11:2-11:2: @6.Return: return"> println!("Don't Panic"); @@ -139,8 +139,8 @@ 9:9-9:33: @2[18]: _27 = &(*_30) 9:9-9:33: @2[19]: _26 = &(*_27) 9:9-9:33: @2[20]: _25 = move _26 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -9:9-9:33: @2.Call: _20 = std::fmt::Arguments::new_v1(move _21, move _25) -> [return: bb5, unwind: bb7] -9:9-9:33: @5.Call: _19 = std::io::_print(move _20) -> [return: bb6, unwind: bb7] +9:9-9:33: @2.Call: _20 = Arguments::new_v1(move _21, move _25) -> [return: bb5, unwind: bb7] +9:9-9:33: @5.Call: _19 = _print(move _20) -> [return: bb6, unwind: bb7] 9:9-9:33: @6[5]: _18 = const () 8:12-10:6: @6[7]: _0 = const () 11:2-11:2: @6.Return: return"> }
@@ -154,8 +154,8 @@ 9:9-9:33: @2[18]: _27 = &(*_30) 9:9-9:33: @2[19]: _26 = &(*_27) 9:9-9:33: @2[20]: _25 = move _26 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -9:9-9:33: @2.Call: _20 = std::fmt::Arguments::new_v1(move _21, move _25) -> [return: bb5, unwind: bb7] -9:9-9:33: @5.Call: _19 = std::io::_print(move _20) -> [return: bb6, unwind: bb7] +9:9-9:33: @2.Call: _20 = Arguments::new_v1(move _21, move _25) -> [return: bb5, unwind: bb7] +9:9-9:33: @5.Call: _19 = _print(move _20) -> [return: bb6, unwind: bb7] 9:9-9:33: @6[5]: _18 = const () 8:12-10:6: @6[7]: _0 = const () 11:2-11:2: @6.Return: return">}⦉@2,5,6
diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.main.-------.InstrumentCoverage.0.html index 3e307c4f460d5..6d9d63deccf17 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.main.-------.InstrumentCoverage.0.html @@ -81,7 +81,7 @@ 25:49-25:62: @2[20]: _16 = &_2 25:64-25:77: @2[24]: _19 = &_1 25:80-25:93: @2[26]: _20 = &_2 -25:64-25:93: @2.Call: _18 = <Version as std::cmp::PartialOrd>::lt(move _19, move _20) -> [return: bb3, unwind: bb9] +25:64-25:93: @2.Call: _18 = <Version as PartialOrd>::lt(move _19, move _20) -> [return: bb3, unwind: bb9] 25:64-25:93: @3[2]: _17 = &_18 25:5-25:95: @3[3]: _14 = (move _15, move _16, move _17) 25:5-25:95: @3[7]: FakeRead(ForMatchedPlace, _14) @@ -89,20 +89,20 @@ 25:5-25:95: @3[11]: _22 = (_14.1: &Version) 25:5-25:95: @3[13]: _23 = (_14.2: &bool) 25:5-25:95: @3[16]: _25 = &(*_21) -25:5-25:95: @3[18]: _26 = <Version as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r Version, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -25:5-25:95: @3.Call: _24 = std::fmt::ArgumentV1::new::<Version>(move _25, move _26) -> [return: bb4, unwind: bb9] +25:5-25:95: @3[18]: _26 = <Version as Debug>::fmt as for<'r, 's, 't0> fn(&'r Version, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +25:5-25:95: @3.Call: _24 = ArgumentV1::new::<Version>(move _25, move _26) -> [return: bb4, unwind: bb9] 25:5-25:95: @4[4]: _28 = &(*_22) -25:5-25:95: @4[6]: _29 = <Version as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r Version, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -25:5-25:95: @4.Call: _27 = std::fmt::ArgumentV1::new::<Version>(move _28, move _29) -> [return: bb5, unwind: bb9] +25:5-25:95: @4[6]: _29 = <Version as Debug>::fmt as for<'r, 's, 't0> fn(&'r Version, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +25:5-25:95: @4.Call: _27 = ArgumentV1::new::<Version>(move _28, move _29) -> [return: bb5, unwind: bb9] 25:5-25:95: @5[4]: _31 = &(*_23) 25:5-25:95: @5[6]: _32 = <bool as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r bool, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -25:5-25:95: @5.Call: _30 = std::fmt::ArgumentV1::new::<bool>(move _31, move _32) -> [return: bb6, unwind: bb9] +25:5-25:95: @5.Call: _30 = ArgumentV1::new::<bool>(move _31, move _32) -> [return: bb6, unwind: bb9] 25:5-25:95: @6[2]: _13 = [move _24, move _27, move _30] 25:5-25:95: @6[9]: _12 = &_13 25:5-25:95: @6[10]: _11 = &(*_12) 25:5-25:95: @6[11]: _10 = move _11 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -25:5-25:95: @6.Call: _5 = std::fmt::Arguments::new_v1(move _6, move _10) -> [return: bb7, unwind: bb9] -25:5-25:95: @7.Call: _4 = std::io::_print(move _5) -> [return: bb8, unwind: bb9] +25:5-25:95: @6.Call: _5 = Arguments::new_v1(move _6, move _10) -> [return: bb7, unwind: bb9] +25:5-25:95: @7.Call: _4 = _print(move _5) -> [return: bb8, unwind: bb9] 25:5-25:95: @8[7]: _3 = const () 21:11-26:2: @8[9]: _0 = const () 26:2-26:2: @8.Return: return">@0,1,2,3,4,5,6,7,8⦊fn main() {
@@ -118,7 +118,7 @@ 25:49-25:62: @2[20]: _16 = &_2 25:64-25:77: @2[24]: _19 = &_1 25:80-25:93: @2[26]: _20 = &_2 -25:64-25:93: @2.Call: _18 = <Version as std::cmp::PartialOrd>::lt(move _19, move _20) -> [return: bb3, unwind: bb9] +25:64-25:93: @2.Call: _18 = <Version as PartialOrd>::lt(move _19, move _20) -> [return: bb3, unwind: bb9] 25:64-25:93: @3[2]: _17 = &_18 25:5-25:95: @3[3]: _14 = (move _15, move _16, move _17) 25:5-25:95: @3[7]: FakeRead(ForMatchedPlace, _14) @@ -126,20 +126,20 @@ 25:5-25:95: @3[11]: _22 = (_14.1: &Version) 25:5-25:95: @3[13]: _23 = (_14.2: &bool) 25:5-25:95: @3[16]: _25 = &(*_21) -25:5-25:95: @3[18]: _26 = <Version as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r Version, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -25:5-25:95: @3.Call: _24 = std::fmt::ArgumentV1::new::<Version>(move _25, move _26) -> [return: bb4, unwind: bb9] +25:5-25:95: @3[18]: _26 = <Version as Debug>::fmt as for<'r, 's, 't0> fn(&'r Version, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +25:5-25:95: @3.Call: _24 = ArgumentV1::new::<Version>(move _25, move _26) -> [return: bb4, unwind: bb9] 25:5-25:95: @4[4]: _28 = &(*_22) -25:5-25:95: @4[6]: _29 = <Version as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r Version, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -25:5-25:95: @4.Call: _27 = std::fmt::ArgumentV1::new::<Version>(move _28, move _29) -> [return: bb5, unwind: bb9] +25:5-25:95: @4[6]: _29 = <Version as Debug>::fmt as for<'r, 's, 't0> fn(&'r Version, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +25:5-25:95: @4.Call: _27 = ArgumentV1::new::<Version>(move _28, move _29) -> [return: bb5, unwind: bb9] 25:5-25:95: @5[4]: _31 = &(*_23) 25:5-25:95: @5[6]: _32 = <bool as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r bool, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -25:5-25:95: @5.Call: _30 = std::fmt::ArgumentV1::new::<bool>(move _31, move _32) -> [return: bb6, unwind: bb9] +25:5-25:95: @5.Call: _30 = ArgumentV1::new::<bool>(move _31, move _32) -> [return: bb6, unwind: bb9] 25:5-25:95: @6[2]: _13 = [move _24, move _27, move _30] 25:5-25:95: @6[9]: _12 = &_13 25:5-25:95: @6[10]: _11 = &(*_12) 25:5-25:95: @6[11]: _10 = move _11 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -25:5-25:95: @6.Call: _5 = std::fmt::Arguments::new_v1(move _6, move _10) -> [return: bb7, unwind: bb9] -25:5-25:95: @7.Call: _4 = std::io::_print(move _5) -> [return: bb8, unwind: bb9] +25:5-25:95: @6.Call: _5 = Arguments::new_v1(move _6, move _10) -> [return: bb7, unwind: bb9] +25:5-25:95: @7.Call: _4 = _print(move _5) -> [return: bb8, unwind: bb9] 25:5-25:95: @8[7]: _3 = const () 21:11-26:2: @8[9]: _0 = const () 26:2-26:2: @8.Return: return"> let version_3_2_1 = Version::new(3, 2, 1);
@@ -155,7 +155,7 @@ 25:49-25:62: @2[20]: _16 = &_2 25:64-25:77: @2[24]: _19 = &_1 25:80-25:93: @2[26]: _20 = &_2 -25:64-25:93: @2.Call: _18 = <Version as std::cmp::PartialOrd>::lt(move _19, move _20) -> [return: bb3, unwind: bb9] +25:64-25:93: @2.Call: _18 = <Version as PartialOrd>::lt(move _19, move _20) -> [return: bb3, unwind: bb9] 25:64-25:93: @3[2]: _17 = &_18 25:5-25:95: @3[3]: _14 = (move _15, move _16, move _17) 25:5-25:95: @3[7]: FakeRead(ForMatchedPlace, _14) @@ -163,20 +163,20 @@ 25:5-25:95: @3[11]: _22 = (_14.1: &Version) 25:5-25:95: @3[13]: _23 = (_14.2: &bool) 25:5-25:95: @3[16]: _25 = &(*_21) -25:5-25:95: @3[18]: _26 = <Version as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r Version, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -25:5-25:95: @3.Call: _24 = std::fmt::ArgumentV1::new::<Version>(move _25, move _26) -> [return: bb4, unwind: bb9] +25:5-25:95: @3[18]: _26 = <Version as Debug>::fmt as for<'r, 's, 't0> fn(&'r Version, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +25:5-25:95: @3.Call: _24 = ArgumentV1::new::<Version>(move _25, move _26) -> [return: bb4, unwind: bb9] 25:5-25:95: @4[4]: _28 = &(*_22) -25:5-25:95: @4[6]: _29 = <Version as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r Version, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -25:5-25:95: @4.Call: _27 = std::fmt::ArgumentV1::new::<Version>(move _28, move _29) -> [return: bb5, unwind: bb9] +25:5-25:95: @4[6]: _29 = <Version as Debug>::fmt as for<'r, 's, 't0> fn(&'r Version, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +25:5-25:95: @4.Call: _27 = ArgumentV1::new::<Version>(move _28, move _29) -> [return: bb5, unwind: bb9] 25:5-25:95: @5[4]: _31 = &(*_23) 25:5-25:95: @5[6]: _32 = <bool as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r bool, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -25:5-25:95: @5.Call: _30 = std::fmt::ArgumentV1::new::<bool>(move _31, move _32) -> [return: bb6, unwind: bb9] +25:5-25:95: @5.Call: _30 = ArgumentV1::new::<bool>(move _31, move _32) -> [return: bb6, unwind: bb9] 25:5-25:95: @6[2]: _13 = [move _24, move _27, move _30] 25:5-25:95: @6[9]: _12 = &_13 25:5-25:95: @6[10]: _11 = &(*_12) 25:5-25:95: @6[11]: _10 = move _11 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -25:5-25:95: @6.Call: _5 = std::fmt::Arguments::new_v1(move _6, move _10) -> [return: bb7, unwind: bb9] -25:5-25:95: @7.Call: _4 = std::io::_print(move _5) -> [return: bb8, unwind: bb9] +25:5-25:95: @6.Call: _5 = Arguments::new_v1(move _6, move _10) -> [return: bb7, unwind: bb9] +25:5-25:95: @7.Call: _4 = _print(move _5) -> [return: bb8, unwind: bb9] 25:5-25:95: @8[7]: _3 = const () 21:11-26:2: @8[9]: _0 = const () 26:2-26:2: @8.Return: return"> let version_3_3_0 = Version::new(3, 3, 0);
@@ -192,7 +192,7 @@ 25:49-25:62: @2[20]: _16 = &_2 25:64-25:77: @2[24]: _19 = &_1 25:80-25:93: @2[26]: _20 = &_2 -25:64-25:93: @2.Call: _18 = <Version as std::cmp::PartialOrd>::lt(move _19, move _20) -> [return: bb3, unwind: bb9] +25:64-25:93: @2.Call: _18 = <Version as PartialOrd>::lt(move _19, move _20) -> [return: bb3, unwind: bb9] 25:64-25:93: @3[2]: _17 = &_18 25:5-25:95: @3[3]: _14 = (move _15, move _16, move _17) 25:5-25:95: @3[7]: FakeRead(ForMatchedPlace, _14) @@ -200,20 +200,20 @@ 25:5-25:95: @3[11]: _22 = (_14.1: &Version) 25:5-25:95: @3[13]: _23 = (_14.2: &bool) 25:5-25:95: @3[16]: _25 = &(*_21) -25:5-25:95: @3[18]: _26 = <Version as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r Version, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -25:5-25:95: @3.Call: _24 = std::fmt::ArgumentV1::new::<Version>(move _25, move _26) -> [return: bb4, unwind: bb9] +25:5-25:95: @3[18]: _26 = <Version as Debug>::fmt as for<'r, 's, 't0> fn(&'r Version, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +25:5-25:95: @3.Call: _24 = ArgumentV1::new::<Version>(move _25, move _26) -> [return: bb4, unwind: bb9] 25:5-25:95: @4[4]: _28 = &(*_22) -25:5-25:95: @4[6]: _29 = <Version as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r Version, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -25:5-25:95: @4.Call: _27 = std::fmt::ArgumentV1::new::<Version>(move _28, move _29) -> [return: bb5, unwind: bb9] +25:5-25:95: @4[6]: _29 = <Version as Debug>::fmt as for<'r, 's, 't0> fn(&'r Version, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +25:5-25:95: @4.Call: _27 = ArgumentV1::new::<Version>(move _28, move _29) -> [return: bb5, unwind: bb9] 25:5-25:95: @5[4]: _31 = &(*_23) 25:5-25:95: @5[6]: _32 = <bool as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r bool, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -25:5-25:95: @5.Call: _30 = std::fmt::ArgumentV1::new::<bool>(move _31, move _32) -> [return: bb6, unwind: bb9] +25:5-25:95: @5.Call: _30 = ArgumentV1::new::<bool>(move _31, move _32) -> [return: bb6, unwind: bb9] 25:5-25:95: @6[2]: _13 = [move _24, move _27, move _30] 25:5-25:95: @6[9]: _12 = &_13 25:5-25:95: @6[10]: _11 = &(*_12) 25:5-25:95: @6[11]: _10 = move _11 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -25:5-25:95: @6.Call: _5 = std::fmt::Arguments::new_v1(move _6, move _10) -> [return: bb7, unwind: bb9] -25:5-25:95: @7.Call: _4 = std::io::_print(move _5) -> [return: bb8, unwind: bb9] +25:5-25:95: @6.Call: _5 = Arguments::new_v1(move _6, move _10) -> [return: bb7, unwind: bb9] +25:5-25:95: @7.Call: _4 = _print(move _5) -> [return: bb8, unwind: bb9] 25:5-25:95: @8[7]: _3 = const () 21:11-26:2: @8[9]: _0 = const () 26:2-26:2: @8.Return: return">
@@ -229,7 +229,7 @@ 25:49-25:62: @2[20]: _16 = &_2 25:64-25:77: @2[24]: _19 = &_1 25:80-25:93: @2[26]: _20 = &_2 -25:64-25:93: @2.Call: _18 = <Version as std::cmp::PartialOrd>::lt(move _19, move _20) -> [return: bb3, unwind: bb9] +25:64-25:93: @2.Call: _18 = <Version as PartialOrd>::lt(move _19, move _20) -> [return: bb3, unwind: bb9] 25:64-25:93: @3[2]: _17 = &_18 25:5-25:95: @3[3]: _14 = (move _15, move _16, move _17) 25:5-25:95: @3[7]: FakeRead(ForMatchedPlace, _14) @@ -237,20 +237,20 @@ 25:5-25:95: @3[11]: _22 = (_14.1: &Version) 25:5-25:95: @3[13]: _23 = (_14.2: &bool) 25:5-25:95: @3[16]: _25 = &(*_21) -25:5-25:95: @3[18]: _26 = <Version as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r Version, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -25:5-25:95: @3.Call: _24 = std::fmt::ArgumentV1::new::<Version>(move _25, move _26) -> [return: bb4, unwind: bb9] +25:5-25:95: @3[18]: _26 = <Version as Debug>::fmt as for<'r, 's, 't0> fn(&'r Version, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +25:5-25:95: @3.Call: _24 = ArgumentV1::new::<Version>(move _25, move _26) -> [return: bb4, unwind: bb9] 25:5-25:95: @4[4]: _28 = &(*_22) -25:5-25:95: @4[6]: _29 = <Version as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r Version, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -25:5-25:95: @4.Call: _27 = std::fmt::ArgumentV1::new::<Version>(move _28, move _29) -> [return: bb5, unwind: bb9] +25:5-25:95: @4[6]: _29 = <Version as Debug>::fmt as for<'r, 's, 't0> fn(&'r Version, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +25:5-25:95: @4.Call: _27 = ArgumentV1::new::<Version>(move _28, move _29) -> [return: bb5, unwind: bb9] 25:5-25:95: @5[4]: _31 = &(*_23) 25:5-25:95: @5[6]: _32 = <bool as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r bool, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -25:5-25:95: @5.Call: _30 = std::fmt::ArgumentV1::new::<bool>(move _31, move _32) -> [return: bb6, unwind: bb9] +25:5-25:95: @5.Call: _30 = ArgumentV1::new::<bool>(move _31, move _32) -> [return: bb6, unwind: bb9] 25:5-25:95: @6[2]: _13 = [move _24, move _27, move _30] 25:5-25:95: @6[9]: _12 = &_13 25:5-25:95: @6[10]: _11 = &(*_12) 25:5-25:95: @6[11]: _10 = move _11 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -25:5-25:95: @6.Call: _5 = std::fmt::Arguments::new_v1(move _6, move _10) -> [return: bb7, unwind: bb9] -25:5-25:95: @7.Call: _4 = std::io::_print(move _5) -> [return: bb8, unwind: bb9] +25:5-25:95: @6.Call: _5 = Arguments::new_v1(move _6, move _10) -> [return: bb7, unwind: bb9] +25:5-25:95: @7.Call: _4 = _print(move _5) -> [return: bb8, unwind: bb9] 25:5-25:95: @8[7]: _3 = const () 21:11-26:2: @8[9]: _0 = const () 26:2-26:2: @8.Return: return"> println!("{:?} < {:?} = {}", version_3_2_1, version_3_3_0, version_3_2_1 < version_3_3_0);
@@ -266,7 +266,7 @@ 25:49-25:62: @2[20]: _16 = &_2 25:64-25:77: @2[24]: _19 = &_1 25:80-25:93: @2[26]: _20 = &_2 -25:64-25:93: @2.Call: _18 = <Version as std::cmp::PartialOrd>::lt(move _19, move _20) -> [return: bb3, unwind: bb9] +25:64-25:93: @2.Call: _18 = <Version as PartialOrd>::lt(move _19, move _20) -> [return: bb3, unwind: bb9] 25:64-25:93: @3[2]: _17 = &_18 25:5-25:95: @3[3]: _14 = (move _15, move _16, move _17) 25:5-25:95: @3[7]: FakeRead(ForMatchedPlace, _14) @@ -274,20 +274,20 @@ 25:5-25:95: @3[11]: _22 = (_14.1: &Version) 25:5-25:95: @3[13]: _23 = (_14.2: &bool) 25:5-25:95: @3[16]: _25 = &(*_21) -25:5-25:95: @3[18]: _26 = <Version as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r Version, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -25:5-25:95: @3.Call: _24 = std::fmt::ArgumentV1::new::<Version>(move _25, move _26) -> [return: bb4, unwind: bb9] +25:5-25:95: @3[18]: _26 = <Version as Debug>::fmt as for<'r, 's, 't0> fn(&'r Version, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +25:5-25:95: @3.Call: _24 = ArgumentV1::new::<Version>(move _25, move _26) -> [return: bb4, unwind: bb9] 25:5-25:95: @4[4]: _28 = &(*_22) -25:5-25:95: @4[6]: _29 = <Version as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r Version, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -25:5-25:95: @4.Call: _27 = std::fmt::ArgumentV1::new::<Version>(move _28, move _29) -> [return: bb5, unwind: bb9] +25:5-25:95: @4[6]: _29 = <Version as Debug>::fmt as for<'r, 's, 't0> fn(&'r Version, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +25:5-25:95: @4.Call: _27 = ArgumentV1::new::<Version>(move _28, move _29) -> [return: bb5, unwind: bb9] 25:5-25:95: @5[4]: _31 = &(*_23) 25:5-25:95: @5[6]: _32 = <bool as std::fmt::Display>::fmt as for<'r, 's, 't0> fn(&'r bool, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -25:5-25:95: @5.Call: _30 = std::fmt::ArgumentV1::new::<bool>(move _31, move _32) -> [return: bb6, unwind: bb9] +25:5-25:95: @5.Call: _30 = ArgumentV1::new::<bool>(move _31, move _32) -> [return: bb6, unwind: bb9] 25:5-25:95: @6[2]: _13 = [move _24, move _27, move _30] 25:5-25:95: @6[9]: _12 = &_13 25:5-25:95: @6[10]: _11 = &(*_12) 25:5-25:95: @6[11]: _10 = move _11 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -25:5-25:95: @6.Call: _5 = std::fmt::Arguments::new_v1(move _6, move _10) -> [return: bb7, unwind: bb9] -25:5-25:95: @7.Call: _4 = std::io::_print(move _5) -> [return: bb8, unwind: bb9] +25:5-25:95: @6.Call: _5 = Arguments::new_v1(move _6, move _10) -> [return: bb7, unwind: bb9] +25:5-25:95: @7.Call: _4 = _print(move _5) -> [return: bb8, unwind: bb9] 25:5-25:95: @8[7]: _3 = const () 21:11-26:2: @8[9]: _0 = const () 26:2-26:2: @8.Return: return">}⦉@0,1,2,3,4,5,6,7,8
diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-ge-{closure#0}-{closure#0}.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-ge-{closure#0}-{closure#0}.-------.InstrumentCoverage.0.html new file mode 100644 index 0000000000000..47f9ab2bd5e7d --- /dev/null +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-ge-{closure#0}-{closure#0}.-------.InstrumentCoverage.0.html @@ -0,0 +1,82 @@ + + + + +partial_eq.{impl#2}-ge-{closure#0}-{closure#0} - Coverage Spans + + + +
minor: usize, // Count: 1 - `PartialOrd` compared `minor` values in 3.2.1 vs. 3.3.0 + @0,1,2⦊patch: usize⦉@0,1,2
+ + diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-ge-{closure#0}.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-ge-{closure#0}.-------.InstrumentCoverage.0.html new file mode 100644 index 0000000000000..9f0c29c50bf1b --- /dev/null +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-ge-{closure#0}.-------.InstrumentCoverage.0.html @@ -0,0 +1,83 @@ + + + + +partial_eq.{impl#2}-ge-{closure#0} - Coverage Spans + + + +
major: usize, + @0,1,2,3⦊⦉@0,1,2,3minor: usize
+ + diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-ge.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-ge.-------.InstrumentCoverage.0.html new file mode 100644 index 0000000000000..60a832b2e2a8e --- /dev/null +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-ge.-------.InstrumentCoverage.0.html @@ -0,0 +1,92 @@ + + + + +partial_eq.{impl#2}-ge - Coverage Spans + + + +
@0,1,2,3,4⦊⦉@0,1,2,3,4PartialOrd
+ + diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-gt-{closure#0}-{closure#0}.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-gt-{closure#0}-{closure#0}.-------.InstrumentCoverage.0.html new file mode 100644 index 0000000000000..2b9a13fe0603f --- /dev/null +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-gt-{closure#0}-{closure#0}.-------.InstrumentCoverage.0.html @@ -0,0 +1,82 @@ + + + + +partial_eq.{impl#2}-gt-{closure#0}-{closure#0} - Coverage Spans + + + +
minor: usize, // Count: 1 - `PartialOrd` compared `minor` values in 3.2.1 vs. 3.3.0 + @0,1,2⦊patch: usize⦉@0,1,2
+ + diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-gt-{closure#0}.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-gt-{closure#0}.-------.InstrumentCoverage.0.html new file mode 100644 index 0000000000000..ff7e783dd68c1 --- /dev/null +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-gt-{closure#0}.-------.InstrumentCoverage.0.html @@ -0,0 +1,83 @@ + + + + +partial_eq.{impl#2}-gt-{closure#0} - Coverage Spans + + + +
major: usize, + @0,1,2,3⦊⦉@0,1,2,3minor: usize
+ + diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-gt.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-gt.-------.InstrumentCoverage.0.html new file mode 100644 index 0000000000000..f6b9dc9776f99 --- /dev/null +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-gt.-------.InstrumentCoverage.0.html @@ -0,0 +1,92 @@ + + + + +partial_eq.{impl#2}-gt - Coverage Spans + + + +
@0,1,2,3,4⦊⦉@0,1,2,3,4PartialOrd
+ + diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-le-{closure#0}-{closure#0}.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-le-{closure#0}-{closure#0}.-------.InstrumentCoverage.0.html new file mode 100644 index 0000000000000..5c95a635f0710 --- /dev/null +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-le-{closure#0}-{closure#0}.-------.InstrumentCoverage.0.html @@ -0,0 +1,82 @@ + + + + +partial_eq.{impl#2}-le-{closure#0}-{closure#0} - Coverage Spans + + + +
minor: usize, // Count: 1 - `PartialOrd` compared `minor` values in 3.2.1 vs. 3.3.0 + @0,1,2⦊patch: usize⦉@0,1,2
+ + diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-le-{closure#0}.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-le-{closure#0}.-------.InstrumentCoverage.0.html new file mode 100644 index 0000000000000..6eb894a166a01 --- /dev/null +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-le-{closure#0}.-------.InstrumentCoverage.0.html @@ -0,0 +1,83 @@ + + + + +partial_eq.{impl#2}-le-{closure#0} - Coverage Spans + + + +
major: usize, + @0,1,2,3⦊⦉@0,1,2,3minor: usize
+ + diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-le.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-le.-------.InstrumentCoverage.0.html new file mode 100644 index 0000000000000..fb7e520faf1dd --- /dev/null +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-le.-------.InstrumentCoverage.0.html @@ -0,0 +1,92 @@ + + + + +partial_eq.{impl#2}-le - Coverage Spans + + + +
@0,1,2,3,4⦊⦉@0,1,2,3,4PartialOrd
+ + diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-lt-{closure#0}-{closure#0}.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-lt-{closure#0}-{closure#0}.-------.InstrumentCoverage.0.html new file mode 100644 index 0000000000000..b2b3e172d53db --- /dev/null +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-lt-{closure#0}-{closure#0}.-------.InstrumentCoverage.0.html @@ -0,0 +1,82 @@ + + + + +partial_eq.{impl#2}-lt-{closure#0}-{closure#0} - Coverage Spans + + + +
minor: usize, // Count: 1 - `PartialOrd` compared `minor` values in 3.2.1 vs. 3.3.0 + @0,1,2⦊patch: usize⦉@0,1,2
+ + diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-lt-{closure#0}.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-lt-{closure#0}.-------.InstrumentCoverage.0.html new file mode 100644 index 0000000000000..e54849345b7f1 --- /dev/null +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-lt-{closure#0}.-------.InstrumentCoverage.0.html @@ -0,0 +1,83 @@ + + + + +partial_eq.{impl#2}-lt-{closure#0} - Coverage Spans + + + +
major: usize, + @0,1,2,3⦊⦉@0,1,2,3minor: usize
+ + diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-lt.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-lt.-------.InstrumentCoverage.0.html new file mode 100644 index 0000000000000..f111ad0045a11 --- /dev/null +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#2}-lt.-------.InstrumentCoverage.0.html @@ -0,0 +1,92 @@ + + + + +partial_eq.{impl#2}-lt - Coverage Spans + + + +
@0,1,2,3,4⦊⦉@0,1,2,3,4PartialOrd
+ + diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#7}-fmt.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#7}-fmt.-------.InstrumentCoverage.0.html index 5b9e070864b40..195ef4da7b484 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#7}-fmt.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#7}-fmt.-------.InstrumentCoverage.0.html @@ -76,38 +76,34 @@ 4:17-4:22: @0[9]: _7 = &mut (*_2) 4:17-4:22: @0[12]: _9 = const "Version" 4:17-4:22: @0[13]: _8 = &(*_9) -4:17-4:22: @0.Call: _6 = std::fmt::Formatter::debug_struct(move _7, move _8) -> [return: bb1, unwind: bb6] +4:17-4:22: @0.Call: _6 = Formatter::debug_struct(move _7, move _8) -> [return: bb1, unwind: bb6] 4:17-4:22: @1[2]: FakeRead(ForLet, _6) -4:17-4:22: @1[7]: _12 = &mut _6 -4:17-4:22: @1[8]: _11 = &mut (*_12) -4:17-4:22: @1[11]: _14 = const "major" -4:17-4:22: @1[12]: _13 = &(*_14) -4:17-4:22: @1[17]: _18 = &(*_3) -4:17-4:22: @1[18]: _17 = &_18 -4:17-4:22: @1[19]: _16 = &(*_17) -4:17-4:22: @1[20]: _15 = move _16 as &dyn std::fmt::Debug (Pointer(Unsize)) -4:17-4:22: @1.Call: _10 = std::fmt::DebugStruct::field(move _11, move _13, move _15) -> [return: bb2, unwind: bb6] -4:17-4:22: @2[11]: _21 = &mut _6 -4:17-4:22: @2[12]: _20 = &mut (*_21) -4:17-4:22: @2[15]: _23 = const "minor" -4:17-4:22: @2[16]: _22 = &(*_23) -4:17-4:22: @2[21]: _27 = &(*_4) -4:17-4:22: @2[22]: _26 = &_27 -4:17-4:22: @2[23]: _25 = &(*_26) -4:17-4:22: @2[24]: _24 = move _25 as &dyn std::fmt::Debug (Pointer(Unsize)) -4:17-4:22: @2.Call: _19 = std::fmt::DebugStruct::field(move _20, move _22, move _24) -> [return: bb3, unwind: bb6] -4:17-4:22: @3[11]: _30 = &mut _6 -4:17-4:22: @3[12]: _29 = &mut (*_30) -4:17-4:22: @3[15]: _32 = const "patch" -4:17-4:22: @3[16]: _31 = &(*_32) -4:17-4:22: @3[21]: _36 = &(*_5) -4:17-4:22: @3[22]: _35 = &_36 -4:17-4:22: @3[23]: _34 = &(*_35) -4:17-4:22: @3[24]: _33 = move _34 as &dyn std::fmt::Debug (Pointer(Unsize)) -4:17-4:22: @3.Call: _28 = std::fmt::DebugStruct::field(move _29, move _31, move _33) -> [return: bb4, unwind: bb6] -4:17-4:22: @4[10]: _38 = &mut _6 -4:17-4:22: @4[11]: _37 = &mut (*_38) -4:17-4:22: @4.Call: _0 = std::fmt::DebugStruct::finish(move _37) -> [return: bb5, unwind: bb6] +4:17-4:22: @1[6]: _11 = &mut _6 +4:17-4:22: @1[9]: _13 = const "major" +4:17-4:22: @1[10]: _12 = &(*_13) +4:17-4:22: @1[15]: _17 = &(*_3) +4:17-4:22: @1[16]: _16 = &_17 +4:17-4:22: @1[17]: _15 = &(*_16) +4:17-4:22: @1[18]: _14 = move _15 as &dyn std::fmt::Debug (Pointer(Unsize)) +4:17-4:22: @1.Call: _10 = DebugStruct::field(move _11, move _12, move _14) -> [return: bb2, unwind: bb6] +4:17-4:22: @2[9]: _19 = &mut _6 +4:17-4:22: @2[12]: _21 = const "minor" +4:17-4:22: @2[13]: _20 = &(*_21) +4:17-4:22: @2[18]: _25 = &(*_4) +4:17-4:22: @2[19]: _24 = &_25 +4:17-4:22: @2[20]: _23 = &(*_24) +4:17-4:22: @2[21]: _22 = move _23 as &dyn std::fmt::Debug (Pointer(Unsize)) +4:17-4:22: @2.Call: _18 = DebugStruct::field(move _19, move _20, move _22) -> [return: bb3, unwind: bb6] +4:17-4:22: @3[9]: _27 = &mut _6 +4:17-4:22: @3[12]: _29 = const "patch" +4:17-4:22: @3[13]: _28 = &(*_29) +4:17-4:22: @3[18]: _33 = &(*_5) +4:17-4:22: @3[19]: _32 = &_33 +4:17-4:22: @3[20]: _31 = &(*_32) +4:17-4:22: @3[21]: _30 = move _31 as &dyn std::fmt::Debug (Pointer(Unsize)) +4:17-4:22: @3.Call: _26 = DebugStruct::field(move _27, move _28, move _30) -> [return: bb4, unwind: bb6] +4:17-4:22: @4[8]: _34 = &mut _6 +4:17-4:22: @4.Call: _0 = DebugStruct::finish(move _34) -> [return: bb5, unwind: bb6] 4:22-4:22: @5.Return: return">@0,1,2,3,4,5⦊Debug⦉@0,1,2,3,4,5 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#8}-clone.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#8}-clone.-------.InstrumentCoverage.0.html index f1c983933432c..27a2ab71827a0 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#8}-clone.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.partial_eq/partial_eq.{impl#8}-clone.-------.InstrumentCoverage.0.html @@ -75,13 +75,13 @@ 4:10-4:15: @0[6]: _4 = &((*_1).2: usize) 4:10-4:15: @0[10]: _7 = &(*_2) 4:10-4:15: @0[11]: _6 = &(*_7) -4:10-4:15: @0.Call: _5 = <usize as std::clone::Clone>::clone(move _6) -> [return: bb1, unwind: bb4] +4:10-4:15: @0.Call: _5 = <usize as Clone>::clone(move _6) -> [return: bb1, unwind: bb4] 4:10-4:15: @1[4]: _10 = &(*_3) 4:10-4:15: @1[5]: _9 = &(*_10) -4:10-4:15: @1.Call: _8 = <usize as std::clone::Clone>::clone(move _9) -> [return: bb2, unwind: bb4] +4:10-4:15: @1.Call: _8 = <usize as Clone>::clone(move _9) -> [return: bb2, unwind: bb4] 4:10-4:15: @2[4]: _13 = &(*_4) 4:10-4:15: @2[5]: _12 = &(*_13) -4:10-4:15: @2.Call: _11 = <usize as std::clone::Clone>::clone(move _12) -> [return: bb3, unwind: bb4] +4:10-4:15: @2.Call: _11 = <usize as Clone>::clone(move _12) -> [return: bb3, unwind: bb4] 4:10-4:15: @3[1]: _0 = Version { major: move _5, minor: move _8, patch: move _11 } 4:15-4:15: @3.Return: return">@0,1,2,3⦊Clone⦉@0,1,2,3 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.simple_loop/simple_loop.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.simple_loop/simple_loop.main.-------.InstrumentCoverage.0.html index 6b911eea34121..f528b698d440f 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.simple_loop/simple_loop.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.simple_loop/simple_loop.main.-------.InstrumentCoverage.0.html @@ -69,81 +69,81 @@ -
@0,1,2,3⦊fn main() { - // Initialize test constants in a way that cannot be determined at compile time, to ensure - // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - // dependent conditions. - let is_true = std::env::args().len() == 1; - - let mut countdown = 0; - - if -@0,1,2,3⦊fn main() { - // Initialize test constants in a way that cannot be determined at compile time, to ensure - // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from - // dependent conditions. - let is_true = std::env::args().len() == 1; - - let mut countdown = 1; - in @8,9,10⦊0..2⦉@8,9,10 { let z diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.try_error_result/try_error_result.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.try_error_result/try_error_result.main.-------.InstrumentCoverage.0.html index 5b0c5cb072f04..41404759c3da7 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.try_error_result/try_error_result.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.try_error_result/try_error_result.main.-------.InstrumentCoverage.0.html @@ -84,7 +84,7 @@ in @2,3,4⦊0..10⦉@2,3,4 { { @10,12,13⦊call(/*return_error=*/ true)⦉@10,12,13@15,17,18,19⦊?⦉@15,17,18,19; +27:41-27:42: @17.Call: _26 = <() as From<()>>::from(move _27) -> [return: bb18, unwind: bb39]">@15,17,18,19⦊?⦉@15,17,18,19; @14,20,21⦊call(/*return_error=*/ false)⦉@14,20,21@23,25,26,27⦊?⦉@23,25,26,27; +28:42-28:43: @25.Call: _35 = <() as From<()>>::from(move _36) -> [return: bb26, unwind: bb39]">@23,25,26,27⦊?⦉@23,25,26,27; } else { @11,28,29⦊call(/*return_error=*/ false)⦉@11,28,29@31,33,34,35⦊?⦉@31,33,34,35; +32:42-32:43: @33.Call: _44 = <() as From<()>>::from(move _45) -> [return: bb34, unwind: bb39]">@31,33,34,35⦊?⦉@31,33,34,35; } } @0,1,2,3⦊pub fn unused_function() { - let is_true = std::env::args().len() == 1; - let mut countdown = 2; -@0,1,2,3,4⦊pub fn unused_generic_function<T: Debug>(arg: T) { @@ -98,14 +98,14 @@ 34:5-34:56: @0[20]: FakeRead(ForMatchedPlace, _13) 34:5-34:56: @0[22]: _15 = (_13.0: &T) 34:5-34:56: @0[25]: _17 = &(*_15) -34:5-34:56: @0[27]: _18 = <T as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r T, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -34:5-34:56: @0.Call: _16 = std::fmt::ArgumentV1::new::<T>(move _17, move _18) -> [return: bb1, unwind: bb5] +34:5-34:56: @0[27]: _18 = <T as Debug>::fmt as for<'r, 's, 't0> fn(&'r T, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +34:5-34:56: @0.Call: _16 = ArgumentV1::new::<T>(move _17, move _18) -> [return: bb1, unwind: bb5] 34:5-34:56: @1[2]: _12 = [move _16] 34:5-34:56: @1[5]: _11 = &_12 34:5-34:56: @1[6]: _10 = &(*_11) 34:5-34:56: @1[7]: _9 = move _10 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -34:5-34:56: @1.Call: _4 = std::fmt::Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb5] -34:5-34:56: @2.Call: _3 = std::io::_print(move _4) -> [return: bb3, unwind: bb5] +34:5-34:56: @1.Call: _4 = Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb5] +34:5-34:56: @2.Call: _3 = _print(move _4) -> [return: bb3, unwind: bb5] 34:5-34:56: @3[6]: _2 = const () 33:50-35:2: @3[8]: _0 = const () 35:2-35:2: @4.Return: return"> println!("unused_generic_function with {:?}", arg); @@ -118,14 +118,14 @@ 34:5-34:56: @0[20]: FakeRead(ForMatchedPlace, _13) 34:5-34:56: @0[22]: _15 = (_13.0: &T) 34:5-34:56: @0[25]: _17 = &(*_15) -34:5-34:56: @0[27]: _18 = <T as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r T, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -34:5-34:56: @0.Call: _16 = std::fmt::ArgumentV1::new::<T>(move _17, move _18) -> [return: bb1, unwind: bb5] +34:5-34:56: @0[27]: _18 = <T as Debug>::fmt as for<'r, 's, 't0> fn(&'r T, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +34:5-34:56: @0.Call: _16 = ArgumentV1::new::<T>(move _17, move _18) -> [return: bb1, unwind: bb5] 34:5-34:56: @1[2]: _12 = [move _16] 34:5-34:56: @1[5]: _11 = &_12 34:5-34:56: @1[6]: _10 = &(*_11) 34:5-34:56: @1[7]: _9 = move _10 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -34:5-34:56: @1.Call: _4 = std::fmt::Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb5] -34:5-34:56: @2.Call: _3 = std::io::_print(move _4) -> [return: bb3, unwind: bb5] +34:5-34:56: @1.Call: _4 = Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb5] +34:5-34:56: @2.Call: _3 = _print(move _4) -> [return: bb3, unwind: bb5] 34:5-34:56: @3[6]: _2 = const () 33:50-35:2: @3[8]: _0 = const () 35:2-35:2: @4.Return: return">}⦉@0,1,2,3,4
diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.unused_private_function.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.unused_private_function.-------.InstrumentCoverage.0.html index 78228594e3753..6424e03fc7113 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.unused_private_function.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.unused_private_function.-------.InstrumentCoverage.0.html @@ -69,36 +69,36 @@ -
@0,1,2,3⦊fn unused_private_function() { - let is_true = std::env::args().len() == 1; - let mut countdown = 2; -@0,1,2,3,4,5,6,7,8⦊fn use_this_lib_crate() { -@0,1,2,3,4,5,6,7⦊fn use_this_lib_crate() { + used_from_bin_crate_and_lib_crate_generic_function("used from library used_crate.rs"); - used_from_bin_crate_and_lib_crate_generic_function("used from library used_crate.rs"); + used_with_same_type_from_bin_crate_and_lib_crate_generic_function( - used_with_same_type_from_bin_crate_and_lib_crate_generic_function( + "used from library used_crate.rs", - "used from library used_crate.rs", + ); - ); + let some_vec = vec![5, 6, 7, 8]; - let some_vec = vec![5, 6, 7, 8]; + used_only_from_this_lib_crate_generic_function(some_vec); - used_only_from_this_lib_crate_generic_function(some_vec); + used_only_from_this_lib_crate_generic_function("used ONLY from library used_crate.rs"); - used_only_from_this_lib_crate_generic_function("used ONLY from library used_crate.rs"); +}⦉@0,1,2,3,4,5,6,7,8
+58:20-58:36: @3.Call: _3 = slice::<impl [i32]>::into_vec::<std::alloc::Global>(move _4) -> [return: bb4, unwind: bb10] +58:9-58:17: @4[1]: FakeRead(ForLet, _3) +59:52-59:60: @4[4]: _8 = move _3 +59:5-59:61: @4.Call: _7 = used_only_from_this_lib_crate_generic_function::<Vec<i32>>(move _8) -> [return: bb5, unwind: bb8] +60:5-60:91: @5.Call: _9 = used_only_from_this_lib_crate_generic_function::<&str>(const "used ONLY from library used_crate.rs") -> [return: bb6, unwind: bb8] +53:25-61:2: @6[1]: _0 = const () +61:2-61:2: @7.Return: return">}⦉@0,1,2,3,4,5,6,7 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.used_from_bin_crate_and_lib_crate_generic_function.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.used_from_bin_crate_and_lib_crate_generic_function.-------.InstrumentCoverage.0.html index 61a709c4729f2..8b994a6962b83 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.used_from_bin_crate_and_lib_crate_generic_function.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.used_from_bin_crate_and_lib_crate_generic_function.-------.InstrumentCoverage.0.html @@ -78,14 +78,14 @@ 26:5-26:83: @0[20]: FakeRead(ForMatchedPlace, _13) 26:5-26:83: @0[22]: _15 = (_13.0: &T) 26:5-26:83: @0[25]: _17 = &(*_15) -26:5-26:83: @0[27]: _18 = <T as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r T, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -26:5-26:83: @0.Call: _16 = std::fmt::ArgumentV1::new::<T>(move _17, move _18) -> [return: bb1, unwind: bb5] +26:5-26:83: @0[27]: _18 = <T as Debug>::fmt as for<'r, 's, 't0> fn(&'r T, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +26:5-26:83: @0.Call: _16 = ArgumentV1::new::<T>(move _17, move _18) -> [return: bb1, unwind: bb5] 26:5-26:83: @1[2]: _12 = [move _16] 26:5-26:83: @1[5]: _11 = &_12 26:5-26:83: @1[6]: _10 = &(*_11) 26:5-26:83: @1[7]: _9 = move _10 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -26:5-26:83: @1.Call: _4 = std::fmt::Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb5] -26:5-26:83: @2.Call: _3 = std::io::_print(move _4) -> [return: bb3, unwind: bb5] +26:5-26:83: @1.Call: _4 = Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb5] +26:5-26:83: @2.Call: _3 = _print(move _4) -> [return: bb3, unwind: bb5] 26:5-26:83: @3[6]: _2 = const () 25:77-27:2: @3[8]: _0 = const () 27:2-27:2: @4.Return: return">@0,1,2,3,4⦊pub fn used_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) { @@ -98,14 +98,14 @@ 26:5-26:83: @0[20]: FakeRead(ForMatchedPlace, _13) 26:5-26:83: @0[22]: _15 = (_13.0: &T) 26:5-26:83: @0[25]: _17 = &(*_15) -26:5-26:83: @0[27]: _18 = <T as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r T, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -26:5-26:83: @0.Call: _16 = std::fmt::ArgumentV1::new::<T>(move _17, move _18) -> [return: bb1, unwind: bb5] +26:5-26:83: @0[27]: _18 = <T as Debug>::fmt as for<'r, 's, 't0> fn(&'r T, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +26:5-26:83: @0.Call: _16 = ArgumentV1::new::<T>(move _17, move _18) -> [return: bb1, unwind: bb5] 26:5-26:83: @1[2]: _12 = [move _16] 26:5-26:83: @1[5]: _11 = &_12 26:5-26:83: @1[6]: _10 = &(*_11) 26:5-26:83: @1[7]: _9 = move _10 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -26:5-26:83: @1.Call: _4 = std::fmt::Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb5] -26:5-26:83: @2.Call: _3 = std::io::_print(move _4) -> [return: bb3, unwind: bb5] +26:5-26:83: @1.Call: _4 = Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb5] +26:5-26:83: @2.Call: _3 = _print(move _4) -> [return: bb3, unwind: bb5] 26:5-26:83: @3[6]: _2 = const () 25:77-27:2: @3[8]: _0 = const () 27:2-27:2: @4.Return: return"> println!("used_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); @@ -118,14 +118,14 @@ 26:5-26:83: @0[20]: FakeRead(ForMatchedPlace, _13) 26:5-26:83: @0[22]: _15 = (_13.0: &T) 26:5-26:83: @0[25]: _17 = &(*_15) -26:5-26:83: @0[27]: _18 = <T as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r T, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -26:5-26:83: @0.Call: _16 = std::fmt::ArgumentV1::new::<T>(move _17, move _18) -> [return: bb1, unwind: bb5] +26:5-26:83: @0[27]: _18 = <T as Debug>::fmt as for<'r, 's, 't0> fn(&'r T, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +26:5-26:83: @0.Call: _16 = ArgumentV1::new::<T>(move _17, move _18) -> [return: bb1, unwind: bb5] 26:5-26:83: @1[2]: _12 = [move _16] 26:5-26:83: @1[5]: _11 = &_12 26:5-26:83: @1[6]: _10 = &(*_11) 26:5-26:83: @1[7]: _9 = move _10 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -26:5-26:83: @1.Call: _4 = std::fmt::Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb5] -26:5-26:83: @2.Call: _3 = std::io::_print(move _4) -> [return: bb3, unwind: bb5] +26:5-26:83: @1.Call: _4 = Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb5] +26:5-26:83: @2.Call: _3 = _print(move _4) -> [return: bb3, unwind: bb5] 26:5-26:83: @3[6]: _2 = const () 25:77-27:2: @3[8]: _0 = const () 27:2-27:2: @4.Return: return">}⦉@0,1,2,3,4 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.used_function.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.used_function.-------.InstrumentCoverage.0.html index 974a24b2c6d44..d35f191b64e85 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.used_function.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.used_function.-------.InstrumentCoverage.0.html @@ -73,25 +73,25 @@ // Initialize test constants in a way that cannot be determined at compile time, to ensure // rustc and LLVM cannot optimize out statements (or coverage counters) downstream from // dependent conditions. - let let @0,1,2,3⦊is_true = std::env::args().len() == 1; - let mut countdown = 0; -@0,1,2,3,4⦊pub fn used_only_from_bin_crate_generic_function<T: Debug>(arg: T) { @@ -98,14 +98,14 @@ 18:5-18:74: @0[20]: FakeRead(ForMatchedPlace, _13) 18:5-18:74: @0[22]: _15 = (_13.0: &T) 18:5-18:74: @0[25]: _17 = &(*_15) -18:5-18:74: @0[27]: _18 = <T as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r T, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -18:5-18:74: @0.Call: _16 = std::fmt::ArgumentV1::new::<T>(move _17, move _18) -> [return: bb1, unwind: bb5] +18:5-18:74: @0[27]: _18 = <T as Debug>::fmt as for<'r, 's, 't0> fn(&'r T, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +18:5-18:74: @0.Call: _16 = ArgumentV1::new::<T>(move _17, move _18) -> [return: bb1, unwind: bb5] 18:5-18:74: @1[2]: _12 = [move _16] 18:5-18:74: @1[5]: _11 = &_12 18:5-18:74: @1[6]: _10 = &(*_11) 18:5-18:74: @1[7]: _9 = move _10 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -18:5-18:74: @1.Call: _4 = std::fmt::Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb5] -18:5-18:74: @2.Call: _3 = std::io::_print(move _4) -> [return: bb3, unwind: bb5] +18:5-18:74: @1.Call: _4 = Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb5] +18:5-18:74: @2.Call: _3 = _print(move _4) -> [return: bb3, unwind: bb5] 18:5-18:74: @3[6]: _2 = const () 17:68-19:2: @3[8]: _0 = const () 19:2-19:2: @4.Return: return"> println!("used_only_from_bin_crate_generic_function with {:?}", arg); @@ -118,14 +118,14 @@ 18:5-18:74: @0[20]: FakeRead(ForMatchedPlace, _13) 18:5-18:74: @0[22]: _15 = (_13.0: &T) 18:5-18:74: @0[25]: _17 = &(*_15) -18:5-18:74: @0[27]: _18 = <T as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r T, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -18:5-18:74: @0.Call: _16 = std::fmt::ArgumentV1::new::<T>(move _17, move _18) -> [return: bb1, unwind: bb5] +18:5-18:74: @0[27]: _18 = <T as Debug>::fmt as for<'r, 's, 't0> fn(&'r T, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +18:5-18:74: @0.Call: _16 = ArgumentV1::new::<T>(move _17, move _18) -> [return: bb1, unwind: bb5] 18:5-18:74: @1[2]: _12 = [move _16] 18:5-18:74: @1[5]: _11 = &_12 18:5-18:74: @1[6]: _10 = &(*_11) 18:5-18:74: @1[7]: _9 = move _10 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -18:5-18:74: @1.Call: _4 = std::fmt::Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb5] -18:5-18:74: @2.Call: _3 = std::io::_print(move _4) -> [return: bb3, unwind: bb5] +18:5-18:74: @1.Call: _4 = Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb5] +18:5-18:74: @2.Call: _3 = _print(move _4) -> [return: bb3, unwind: bb5] 18:5-18:74: @3[6]: _2 = const () 17:68-19:2: @3[8]: _0 = const () 19:2-19:2: @4.Return: return">}⦉@0,1,2,3,4 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.used_only_from_this_lib_crate_generic_function.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.used_only_from_this_lib_crate_generic_function.-------.InstrumentCoverage.0.html index 63944eb9ab38e..76bc057dd00a9 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.used_only_from_this_lib_crate_generic_function.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.used_only_from_this_lib_crate_generic_function.-------.InstrumentCoverage.0.html @@ -78,14 +78,14 @@ 22:5-22:79: @0[20]: FakeRead(ForMatchedPlace, _13) 22:5-22:79: @0[22]: _15 = (_13.0: &T) 22:5-22:79: @0[25]: _17 = &(*_15) -22:5-22:79: @0[27]: _18 = <T as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r T, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -22:5-22:79: @0.Call: _16 = std::fmt::ArgumentV1::new::<T>(move _17, move _18) -> [return: bb1, unwind: bb5] +22:5-22:79: @0[27]: _18 = <T as Debug>::fmt as for<'r, 's, 't0> fn(&'r T, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +22:5-22:79: @0.Call: _16 = ArgumentV1::new::<T>(move _17, move _18) -> [return: bb1, unwind: bb5] 22:5-22:79: @1[2]: _12 = [move _16] 22:5-22:79: @1[5]: _11 = &_12 22:5-22:79: @1[6]: _10 = &(*_11) 22:5-22:79: @1[7]: _9 = move _10 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -22:5-22:79: @1.Call: _4 = std::fmt::Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb5] -22:5-22:79: @2.Call: _3 = std::io::_print(move _4) -> [return: bb3, unwind: bb5] +22:5-22:79: @1.Call: _4 = Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb5] +22:5-22:79: @2.Call: _3 = _print(move _4) -> [return: bb3, unwind: bb5] 22:5-22:79: @3[6]: _2 = const () 21:73-23:2: @3[8]: _0 = const () 23:2-23:2: @4.Return: return">@0,1,2,3,4⦊pub fn used_only_from_this_lib_crate_generic_function<T: Debug>(arg: T) { @@ -98,14 +98,14 @@ 22:5-22:79: @0[20]: FakeRead(ForMatchedPlace, _13) 22:5-22:79: @0[22]: _15 = (_13.0: &T) 22:5-22:79: @0[25]: _17 = &(*_15) -22:5-22:79: @0[27]: _18 = <T as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r T, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -22:5-22:79: @0.Call: _16 = std::fmt::ArgumentV1::new::<T>(move _17, move _18) -> [return: bb1, unwind: bb5] +22:5-22:79: @0[27]: _18 = <T as Debug>::fmt as for<'r, 's, 't0> fn(&'r T, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +22:5-22:79: @0.Call: _16 = ArgumentV1::new::<T>(move _17, move _18) -> [return: bb1, unwind: bb5] 22:5-22:79: @1[2]: _12 = [move _16] 22:5-22:79: @1[5]: _11 = &_12 22:5-22:79: @1[6]: _10 = &(*_11) 22:5-22:79: @1[7]: _9 = move _10 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -22:5-22:79: @1.Call: _4 = std::fmt::Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb5] -22:5-22:79: @2.Call: _3 = std::io::_print(move _4) -> [return: bb3, unwind: bb5] +22:5-22:79: @1.Call: _4 = Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb5] +22:5-22:79: @2.Call: _3 = _print(move _4) -> [return: bb3, unwind: bb5] 22:5-22:79: @3[6]: _2 = const () 21:73-23:2: @3[8]: _0 = const () 23:2-23:2: @4.Return: return"> println!("used_only_from_this_lib_crate_generic_function with {:?}", arg); @@ -118,14 +118,14 @@ 22:5-22:79: @0[20]: FakeRead(ForMatchedPlace, _13) 22:5-22:79: @0[22]: _15 = (_13.0: &T) 22:5-22:79: @0[25]: _17 = &(*_15) -22:5-22:79: @0[27]: _18 = <T as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r T, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -22:5-22:79: @0.Call: _16 = std::fmt::ArgumentV1::new::<T>(move _17, move _18) -> [return: bb1, unwind: bb5] +22:5-22:79: @0[27]: _18 = <T as Debug>::fmt as for<'r, 's, 't0> fn(&'r T, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +22:5-22:79: @0.Call: _16 = ArgumentV1::new::<T>(move _17, move _18) -> [return: bb1, unwind: bb5] 22:5-22:79: @1[2]: _12 = [move _16] 22:5-22:79: @1[5]: _11 = &_12 22:5-22:79: @1[6]: _10 = &(*_11) 22:5-22:79: @1[7]: _9 = move _10 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -22:5-22:79: @1.Call: _4 = std::fmt::Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb5] -22:5-22:79: @2.Call: _3 = std::io::_print(move _4) -> [return: bb3, unwind: bb5] +22:5-22:79: @1.Call: _4 = Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb5] +22:5-22:79: @2.Call: _3 = _print(move _4) -> [return: bb3, unwind: bb5] 22:5-22:79: @3[6]: _2 = const () 21:73-23:2: @3[8]: _0 = const () 23:2-23:2: @4.Return: return">}⦉@0,1,2,3,4 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.used_with_same_type_from_bin_crate_and_lib_crate_generic_function.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.used_with_same_type_from_bin_crate_and_lib_crate_generic_function.-------.InstrumentCoverage.0.html index b146180fbd155..a2f4b7e19ebdd 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.used_with_same_type_from_bin_crate_and_lib_crate_generic_function.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.used_crate/used_crate.used_with_same_type_from_bin_crate_and_lib_crate_generic_function.-------.InstrumentCoverage.0.html @@ -78,14 +78,14 @@ 30:5-30:98: @0[20]: FakeRead(ForMatchedPlace, _13) 30:5-30:98: @0[22]: _15 = (_13.0: &T) 30:5-30:98: @0[25]: _17 = &(*_15) -30:5-30:98: @0[27]: _18 = <T as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r T, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -30:5-30:98: @0.Call: _16 = std::fmt::ArgumentV1::new::<T>(move _17, move _18) -> [return: bb1, unwind: bb5] +30:5-30:98: @0[27]: _18 = <T as Debug>::fmt as for<'r, 's, 't0> fn(&'r T, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +30:5-30:98: @0.Call: _16 = ArgumentV1::new::<T>(move _17, move _18) -> [return: bb1, unwind: bb5] 30:5-30:98: @1[2]: _12 = [move _16] 30:5-30:98: @1[5]: _11 = &_12 30:5-30:98: @1[6]: _10 = &(*_11) 30:5-30:98: @1[7]: _9 = move _10 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -30:5-30:98: @1.Call: _4 = std::fmt::Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb5] -30:5-30:98: @2.Call: _3 = std::io::_print(move _4) -> [return: bb3, unwind: bb5] +30:5-30:98: @1.Call: _4 = Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb5] +30:5-30:98: @2.Call: _3 = _print(move _4) -> [return: bb3, unwind: bb5] 30:5-30:98: @3[6]: _2 = const () 29:92-31:2: @3[8]: _0 = const () 31:2-31:2: @4.Return: return">@0,1,2,3,4⦊pub fn used_with_same_type_from_bin_crate_and_lib_crate_generic_function<T: Debug>(arg: T) { @@ -98,14 +98,14 @@ 30:5-30:98: @0[20]: FakeRead(ForMatchedPlace, _13) 30:5-30:98: @0[22]: _15 = (_13.0: &T) 30:5-30:98: @0[25]: _17 = &(*_15) -30:5-30:98: @0[27]: _18 = <T as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r T, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -30:5-30:98: @0.Call: _16 = std::fmt::ArgumentV1::new::<T>(move _17, move _18) -> [return: bb1, unwind: bb5] +30:5-30:98: @0[27]: _18 = <T as Debug>::fmt as for<'r, 's, 't0> fn(&'r T, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +30:5-30:98: @0.Call: _16 = ArgumentV1::new::<T>(move _17, move _18) -> [return: bb1, unwind: bb5] 30:5-30:98: @1[2]: _12 = [move _16] 30:5-30:98: @1[5]: _11 = &_12 30:5-30:98: @1[6]: _10 = &(*_11) 30:5-30:98: @1[7]: _9 = move _10 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -30:5-30:98: @1.Call: _4 = std::fmt::Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb5] -30:5-30:98: @2.Call: _3 = std::io::_print(move _4) -> [return: bb3, unwind: bb5] +30:5-30:98: @1.Call: _4 = Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb5] +30:5-30:98: @2.Call: _3 = _print(move _4) -> [return: bb3, unwind: bb5] 30:5-30:98: @3[6]: _2 = const () 29:92-31:2: @3[8]: _0 = const () 31:2-31:2: @4.Return: return"> println!("used_with_same_type_from_bin_crate_and_lib_crate_generic_function with {:?}", arg); @@ -118,14 +118,14 @@ 30:5-30:98: @0[20]: FakeRead(ForMatchedPlace, _13) 30:5-30:98: @0[22]: _15 = (_13.0: &T) 30:5-30:98: @0[25]: _17 = &(*_15) -30:5-30:98: @0[27]: _18 = <T as std::fmt::Debug>::fmt as for<'r, 's, 't0> fn(&'r T, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) -30:5-30:98: @0.Call: _16 = std::fmt::ArgumentV1::new::<T>(move _17, move _18) -> [return: bb1, unwind: bb5] +30:5-30:98: @0[27]: _18 = <T as Debug>::fmt as for<'r, 's, 't0> fn(&'r T, &'s mut std::fmt::Formatter<'t0>) -> std::result::Result<(), std::fmt::Error> (Pointer(ReifyFnPointer)) +30:5-30:98: @0.Call: _16 = ArgumentV1::new::<T>(move _17, move _18) -> [return: bb1, unwind: bb5] 30:5-30:98: @1[2]: _12 = [move _16] 30:5-30:98: @1[5]: _11 = &_12 30:5-30:98: @1[6]: _10 = &(*_11) 30:5-30:98: @1[7]: _9 = move _10 as &[std::fmt::ArgumentV1] (Pointer(Unsize)) -30:5-30:98: @1.Call: _4 = std::fmt::Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb5] -30:5-30:98: @2.Call: _3 = std::io::_print(move _4) -> [return: bb3, unwind: bb5] +30:5-30:98: @1.Call: _4 = Arguments::new_v1(move _5, move _9) -> [return: bb2, unwind: bb5] +30:5-30:98: @2.Call: _3 = _print(move _4) -> [return: bb3, unwind: bb5] 30:5-30:98: @3[6]: _2 = const () 29:92-31:2: @3[8]: _0 = const () 31:2-31:2: @4.Return: return">}⦉@0,1,2,3,4 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.uses_crate/uses_crate.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.uses_crate/uses_crate.main.-------.InstrumentCoverage.0.html index 28cf051ecf873..ba6af60fa5cc9 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.uses_crate/uses_crate.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.uses_crate/uses_crate.main.-------.InstrumentCoverage.0.html @@ -69,125 +69,125 @@ -
@0,1,2,3,4,5,6,7,8,9⦊fn main() { -@0,1,2,3,4,5,6,7,8⦊fn main() { + used_crate::used_function(); - used_crate::used_function(); + let some_vec = vec![1, 2, 3, 4]; - let some_vec = vec![1, 2, 3, 4]; + used_crate::used_only_from_bin_crate_generic_function(&some_vec); - used_crate::used_only_from_bin_crate_generic_function(&some_vec); + used_crate::used_only_from_bin_crate_generic_function("used from bin uses_crate.rs"); - used_crate::used_only_from_bin_crate_generic_function("used from bin uses_crate.rs"); + used_crate::used_from_bin_crate_and_lib_crate_generic_function(some_vec); - used_crate::used_from_bin_crate_and_lib_crate_generic_function(some_vec); + used_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function("interesting?"); - used_crate::used_with_same_type_from_bin_crate_and_lib_crate_generic_function("interesting?"); +}⦉@0,1,2,3,4,5,6,7,8,9
+7:20-7:36: @2.Call: _2 = slice::<impl [i32]>::into_vec::<std::alloc::Global>(move _3) -> [return: bb3, unwind: bb11] +7:9-7:17: @3[1]: FakeRead(ForLet, _2) +8:59-8:68: @3[4]: _7 = &_2 +8:5-8:69: @3.Call: _6 = used_only_from_bin_crate_generic_function::<&Vec<i32>>(move _7) -> [return: bb4, unwind: bb9] +9:5-9:89: @4.Call: _8 = used_only_from_bin_crate_generic_function::<&str>(const "used from bin uses_crate.rs") -> [return: bb5, unwind: bb9] +10:68-10:76: @5[3]: _10 = move _2 +10:5-10:77: @5.Call: _9 = used_from_bin_crate_and_lib_crate_generic_function::<Vec<i32>>(move _10) -> [return: bb6, unwind: bb9] +11:5-11:98: @6.Call: _11 = used_with_same_type_from_bin_crate_and_lib_crate_generic_function::<&str>(const "interesting?") -> [return: bb7, unwind: bb9] +5:11-12:2: @7[1]: _0 = const () +12:2-12:2: @8.Return: return">}⦉@0,1,2,3,4,5,6,7,8 diff --git a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.yield/yield.main.-------.InstrumentCoverage.0.html b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.yield/yield.main.-------.InstrumentCoverage.0.html index 4c0c0d562b840..99e56393ea599 100644 --- a/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.yield/yield.main.-------.InstrumentCoverage.0.html +++ b/src/test/run-make-fulldeps/coverage-spanview/expected_mir_dump.yield/yield.main.-------.InstrumentCoverage.0.html @@ -76,26 +76,26 @@ }; match @0,1,2⦊Pin::new(&mut generator).resume(()) { GeneratorState::Yielded(1)⦉@0,1,2 => @4,6,7,8⦊{}⦉@4,6,7,8 - _ => @5⦊panic!("unexpected value from resume")⦉@5, + _ => @5⦊panic!("unexpected value from resume")⦉@5, } match @4,6,7,8⦊Pin::new(&mut generator).resume(())⦉@4,6,7,8 { - GeneratorState::Complete(@10,11⦊"foo"⦉@10,11) => @12,13,14,15⦊{}⦉@12,13,14,15 - _ => @9⦊panic!("unexpected value from resume")⦉@9, + GeneratorState::Complete(@10,11⦊"foo"⦉@10,11) => @12,13,14,15⦊{}⦉@12,13,14,15 + _ => @9⦊panic!("unexpected value from resume")⦉@9, } let @12,13,14,15⦊mut generator⦉@12,13,14,15 = || { @@ -106,32 +106,32 @@ }; match @12,13,14,15⦊Pin::new(&mut generator).resume(()) { GeneratorState::Yielded(1)⦉@12,13,14,15 => @17,19,20,21⦊{}⦉@17,19,20,21 - _ => @18⦊panic!("unexpected value from resume")⦉@18, + _ => @18⦊panic!("unexpected value from resume")⦉@18, } match @17,19,20,21⦊Pin::new(&mut generator).resume(()) { GeneratorState::Yielded(2)⦉@17,19,20,21 => @23,25⦊{}⦉@23,25 - _ => @24⦊panic!("unexpected value from resume")⦉@24, + _ => @24⦊panic!("unexpected value from resume")⦉@24, } }@23,25⦊⦉@23,25 diff --git a/src/test/run-make-fulldeps/coverage/coverage_tools.mk b/src/test/run-make-fulldeps/coverage/coverage_tools.mk index 11fd824e5272f..4d340d4b1dadd 100644 --- a/src/test/run-make-fulldeps/coverage/coverage_tools.mk +++ b/src/test/run-make-fulldeps/coverage/coverage_tools.mk @@ -14,3 +14,10 @@ # Therefore, `-C link-dead-code` is no longer automatically enabled. UNAME = $(shell uname) + +# Rust option `-Z instrument-coverage` uses LLVM Coverage Mapping Format version 4, +# which requires LLVM 11 or greater. +LLVM_VERSION_11_PLUS := $(shell \ + LLVM_VERSION=$$("$(LLVM_BIN_DIR)"/llvm-config --version) && \ + LLVM_VERSION_MAJOR=$${LLVM_VERSION/.*/} && \ + [ $$LLVM_VERSION_MAJOR -ge 11 ] && echo true || echo false) diff --git a/src/test/run-make-fulldeps/simd-ffi/simd.rs b/src/test/run-make-fulldeps/simd-ffi/simd.rs index d11cfd77c5bf9..717da367feec5 100644 --- a/src/test/run-make-fulldeps/simd-ffi/simd.rs +++ b/src/test/run-make-fulldeps/simd-ffi/simd.rs @@ -75,8 +75,3 @@ auto trait Freeze {} macro_rules! Copy { () => {}; } -#[macro_export] -#[rustc_builtin_macro] -macro_rules! derive { - () => {}; -} diff --git a/src/test/run-make-fulldeps/treat-err-as-bug/Makefile b/src/test/run-make-fulldeps/treat-err-as-bug/Makefile new file mode 100644 index 0000000000000..57cac76aec2a5 --- /dev/null +++ b/src/test/run-make-fulldeps/treat-err-as-bug/Makefile @@ -0,0 +1,7 @@ +-include ../tools.mk + +all: + $(RUSTC) err.rs -Z treat-err-as-bug 2>&1 \ + | $(CGREP) "panicked at 'aborting due to \`-Z treat-err-as-bug=1\`'" + $(RUSTC) delay_span_bug.rs -Z treat-err-as-bug 2>&1 \ + | $(CGREP) "panicked at 'aborting due to \`-Z treat-err-as-bug=1\`'" diff --git a/src/test/run-make-fulldeps/treat-err-as-bug/delay_span_bug.rs b/src/test/run-make-fulldeps/treat-err-as-bug/delay_span_bug.rs new file mode 100644 index 0000000000000..dad33e498b52f --- /dev/null +++ b/src/test/run-make-fulldeps/treat-err-as-bug/delay_span_bug.rs @@ -0,0 +1,4 @@ +#![feature(rustc_attrs)] + +#[rustc_error(delay_span_bug_from_inside_query)] +fn main() {} diff --git a/src/test/run-make-fulldeps/treat-err-as-bug/err.rs b/src/test/run-make-fulldeps/treat-err-as-bug/err.rs new file mode 100644 index 0000000000000..136b2f3070299 --- /dev/null +++ b/src/test/run-make-fulldeps/treat-err-as-bug/err.rs @@ -0,0 +1,3 @@ +#![crate_type="rlib"] + +pub static C: u32 = 0-1; diff --git a/src/test/rustdoc-json/method_abi.rs b/src/test/rustdoc-json/method_abi.rs deleted file mode 100644 index 6fabbc836117b..0000000000000 --- a/src/test/rustdoc-json/method_abi.rs +++ /dev/null @@ -1,25 +0,0 @@ -// @has method_abi.json "$.index[*][?(@.name=='Foo')]" -pub struct Foo; - -impl Foo { - // @has - "$.index[*][?(@.name=='abi_rust')].inner.abi" '"\"Rust\""' - pub fn abi_rust() {} - - // @has - "$.index[*][?(@.name=='abi_c')].inner.abi" '"\"C\""' - pub extern "C" fn abi_c() {} - - // @has - "$.index[*][?(@.name=='abi_system')].inner.abi" '"\"system\""' - pub extern "system" fn abi_system() {} -} - -// @has method_abi.json "$.index[*][?(@.name=='Bar')]" -pub trait Bar { - // @has - "$.index[*][?(@.name=='trait_abi_rust')].inner.abi" '"\"Rust\""' - fn trait_abi_rust(); - - // @has - "$.index[*][?(@.name=='trait_abi_c')].inner.abi" '"\"C\""' - extern "C" fn trait_abi_c(); - - // @has - "$.index[*][?(@.name=='trait_abi_system')].inner.abi" '"\"system\""' - extern "system" fn trait_abi_system(); -} diff --git a/src/test/rustdoc-json/traits/has_body.rs b/src/test/rustdoc-json/traits/has_body.rs deleted file mode 100644 index 44dacb1ee75bf..0000000000000 --- a/src/test/rustdoc-json/traits/has_body.rs +++ /dev/null @@ -1,21 +0,0 @@ -// @has has_body.json "$.index[*][?(@.name=='Foo')]" -pub trait Foo { - // @has - "$.index[*][?(@.name=='no_self')].inner.has_body" false - fn no_self(); - // @has - "$.index[*][?(@.name=='move_self')].inner.has_body" false - fn move_self(self); - // @has - "$.index[*][?(@.name=='ref_self')].inner.has_body" false - fn ref_self(&self); - - // @has - "$.index[*][?(@.name=='no_self_def')].inner.has_body" true - fn no_self_def() {} - // @has - "$.index[*][?(@.name=='move_self_def')].inner.has_body" true - fn move_self_def(self) {} - // @has - "$.index[*][?(@.name=='ref_self_def')].inner.has_body" true - fn ref_self_def(&self) {} -} - -pub trait Bar: Clone { - // @has - "$.index[*][?(@.name=='method')].inner.has_body" false - fn method(&self, param: usize); -} diff --git a/src/test/rustdoc-json/unions/union.rs b/src/test/rustdoc-json/unions/union.rs deleted file mode 100644 index ac2eb797791f3..0000000000000 --- a/src/test/rustdoc-json/unions/union.rs +++ /dev/null @@ -1,7 +0,0 @@ -// @has union.json "$.index[*][?(@.name=='Union')].visibility" \"public\" -// @has - "$.index[*][?(@.name=='Union')].kind" \"union\" -// @!has - "$.index[*][?(@.name=='Union')].inner.struct_type" -pub union Union { - int: i32, - float: f32, -} diff --git a/src/test/rustdoc-ui/issue-81662-shortness.rs b/src/test/rustdoc-ui/issue-81662-shortness.rs deleted file mode 100644 index 27a21a313bc55..0000000000000 --- a/src/test/rustdoc-ui/issue-81662-shortness.rs +++ /dev/null @@ -1,12 +0,0 @@ -// compile-flags:--test --error-format=short -// normalize-stdout-test: "src/test/rustdoc-ui" -> "$$DIR" -// normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" -// failure-status: 101 - -/// ```rust -/// foo(); -/// ``` -//~^^ ERROR cannot find function `foo` in this scope -fn foo() { - println!("Hello, world!"); -} diff --git a/src/test/rustdoc-ui/issue-81662-shortness.stdout b/src/test/rustdoc-ui/issue-81662-shortness.stdout deleted file mode 100644 index 748113be3a26d..0000000000000 --- a/src/test/rustdoc-ui/issue-81662-shortness.stdout +++ /dev/null @@ -1,16 +0,0 @@ - -running 1 test -test $DIR/issue-81662-shortness.rs - foo (line 6) ... FAILED - -failures: - ----- $DIR/issue-81662-shortness.rs - foo (line 6) stdout ---- -$DIR/issue-81662-shortness.rs:7:1: error[E0425]: cannot find function `foo` in this scope -error: aborting due to previous error -Couldn't compile the test. - -failures: - $DIR/issue-81662-shortness.rs - foo (line 6) - -test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME - diff --git a/src/test/rustdoc/task-lists.rs b/src/test/rustdoc/task-lists.rs deleted file mode 100644 index c2e7dd60f225e..0000000000000 --- a/src/test/rustdoc/task-lists.rs +++ /dev/null @@ -1,13 +0,0 @@ -// ignore-tidy-linelength -// FIXME: this doesn't test as much as I'd like; ideally it would have these query too: - // has task_lists/index.html '//li/input[@type="checkbox" and disabled]/following-sibling::text()' 'a' - // has task_lists/index.html '//li/input[@type="checkbox"]/following-sibling::text()' 'b' -// Unfortunately that requires LXML, because the built-in xml module doesn't support all of xpath. - -// @has task_lists/index.html '//ul/li/input[@type="checkbox"]' '' -// @has task_lists/index.html '//ul/li/input[@disabled]' '' -// @has task_lists/index.html '//ul/li' 'a' -// @has task_lists/index.html '//ul/li' 'b' -//! This tests 'task list' support, a common markdown extension. -//! - [ ] a -//! - [x] b diff --git a/src/test/rustdoc/trait-self-link.rs b/src/test/rustdoc/trait-self-link.rs index bac28b44012cc..51e1fe91f9672 100644 --- a/src/test/rustdoc/trait-self-link.rs +++ b/src/test/rustdoc/trait-self-link.rs @@ -1,4 +1,4 @@ -// @has trait_self_link/trait.Foo.html //a/@href ../trait_self_link/trait.Foo.html +// @!has trait_self_link/trait.Foo.html //a/@href ../trait_self_link/trait.Foo.html pub trait Foo {} pub struct Bar; diff --git a/src/test/ui-fulldeps/issue-15149.rs b/src/test/ui-fulldeps/issue-15149.rs index c7ef5ad70a114..c80628aabc83f 100644 --- a/src/test/ui-fulldeps/issue-15149.rs +++ b/src/test/ui-fulldeps/issue-15149.rs @@ -50,7 +50,7 @@ fn test() { .output().unwrap(); assert!(child_output.status.success(), - "child assertion failed\n child stdout:\n {}\n child stderr:\n {}", - str::from_utf8(&child_output.stdout).unwrap(), - str::from_utf8(&child_output.stderr).unwrap()); + format!("child assertion failed\n child stdout:\n {}\n child stderr:\n {}", + str::from_utf8(&child_output.stdout).unwrap(), + str::from_utf8(&child_output.stderr).unwrap())); } diff --git a/src/test/ui/allocator/object-safe.rs b/src/test/ui/allocator/object-safe.rs deleted file mode 100644 index fae7ab7fe3319..0000000000000 --- a/src/test/ui/allocator/object-safe.rs +++ /dev/null @@ -1,13 +0,0 @@ -// run-pass - -// Check that `Allocator` is object safe, this allows for polymorphic allocators - -#![feature(allocator_api)] - -use std::alloc::{Allocator, System}; - -fn ensure_object_safe(_: &dyn Allocator) {} - -fn main() { - ensure_object_safe(&System); -} diff --git a/src/test/ui/array-slice-vec/array_const_index-0.rs b/src/test/ui/array-slice-vec/array_const_index-0.rs index 9ff7e2c569ab9..4021dfcc6eb7d 100644 --- a/src/test/ui/array-slice-vec/array_const_index-0.rs +++ b/src/test/ui/array-slice-vec/array_const_index-0.rs @@ -2,7 +2,6 @@ const A: &'static [i32] = &[]; const B: i32 = (&A)[1]; //~^ index out of bounds: the length is 0 but the index is 1 //~| ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out fn main() { let _ = B; diff --git a/src/test/ui/array-slice-vec/array_const_index-0.stderr b/src/test/ui/array-slice-vec/array_const_index-0.stderr index 641705e1c6875..7ccc3aa087e1e 100644 --- a/src/test/ui/array-slice-vec/array_const_index-0.stderr +++ b/src/test/ui/array-slice-vec/array_const_index-0.stderr @@ -7,8 +7,6 @@ LL | const B: i32 = (&A)[1]; | index out of bounds: the length is 0 but the index is 1 | = note: `#[deny(const_err)]` 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 #71800 error: aborting due to previous error diff --git a/src/test/ui/array-slice-vec/array_const_index-1.rs b/src/test/ui/array-slice-vec/array_const_index-1.rs index f4326189c1917..d0ee1796c0ffc 100644 --- a/src/test/ui/array-slice-vec/array_const_index-1.rs +++ b/src/test/ui/array-slice-vec/array_const_index-1.rs @@ -2,7 +2,6 @@ const A: [i32; 0] = []; const B: i32 = A[1]; //~^ index out of bounds: the length is 0 but the index is 1 //~| ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out fn main() { let _ = B; diff --git a/src/test/ui/array-slice-vec/array_const_index-1.stderr b/src/test/ui/array-slice-vec/array_const_index-1.stderr index 4d52d38af5e17..37de61b9df01b 100644 --- a/src/test/ui/array-slice-vec/array_const_index-1.stderr +++ b/src/test/ui/array-slice-vec/array_const_index-1.stderr @@ -7,8 +7,6 @@ LL | const B: i32 = A[1]; | index out of bounds: the length is 0 but the index is 1 | = note: `#[deny(const_err)]` 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 #71800 error: aborting due to previous error diff --git a/src/test/ui/associated-consts/defaults-not-assumed-fail.rs b/src/test/ui/associated-consts/defaults-not-assumed-fail.rs index 3936e6a3bc722..b0a4c7722e3ce 100644 --- a/src/test/ui/associated-consts/defaults-not-assumed-fail.rs +++ b/src/test/ui/associated-consts/defaults-not-assumed-fail.rs @@ -7,7 +7,6 @@ trait Tr { // `Self::A` must not be assumed to hold inside the trait. const B: u8 = Self::A + 1; //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out } // An impl that doesn't override any constant will NOT cause a const eval error @@ -34,7 +33,6 @@ fn main() { assert_eq!(<() as Tr>::B, 0); // causes the error above //~^ ERROR evaluation of constant value failed //~| ERROR erroneous constant used - //~| WARN this was previously accepted by the compiler but is being phased out assert_eq!(::A, 254); assert_eq!(::B, 255); diff --git a/src/test/ui/associated-consts/defaults-not-assumed-fail.stderr b/src/test/ui/associated-consts/defaults-not-assumed-fail.stderr index d034a50299d50..cbaaed0508b98 100644 --- a/src/test/ui/associated-consts/defaults-not-assumed-fail.stderr +++ b/src/test/ui/associated-consts/defaults-not-assumed-fail.stderr @@ -7,23 +7,19 @@ LL | const B: u8 = Self::A + 1; | attempt to compute `u8::MAX + 1_u8`, which would overflow | = note: `#[deny(const_err)]` 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 #71800 error[E0080]: evaluation of constant value failed - --> $DIR/defaults-not-assumed-fail.rs:34:16 + --> $DIR/defaults-not-assumed-fail.rs:33:16 | LL | assert_eq!(<() as Tr>::B, 0); // causes the error above | ^^^^^^^^^^^^^ referenced constant has errors error: erroneous constant used - --> $DIR/defaults-not-assumed-fail.rs:34:5 + --> $DIR/defaults-not-assumed-fail.rs:33:5 | LL | assert_eq!(<() as Tr>::B, 0); // causes the error above | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors | - = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 3 previous errors diff --git a/src/test/ui/associated-type-bounds/ambiguous-associated-type2.rs b/src/test/ui/associated-type-bounds/ambiguous-associated-type2.rs deleted file mode 100644 index 1b6d6d0ff599f..0000000000000 --- a/src/test/ui/associated-type-bounds/ambiguous-associated-type2.rs +++ /dev/null @@ -1,12 +0,0 @@ -// ignore-tidy-linelength - -trait Foo { - type Item; -} -trait Bar { - type Item; -} -trait Baz: Foo + Bar {} -//~^ ERROR cycle detected when computing the super traits of `Baz` with associated type name `Item` [E0391] - -fn main() {} diff --git a/src/test/ui/associated-type-bounds/ambiguous-associated-type2.stderr b/src/test/ui/associated-type-bounds/ambiguous-associated-type2.stderr deleted file mode 100644 index bda1debeac0d6..0000000000000 --- a/src/test/ui/associated-type-bounds/ambiguous-associated-type2.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0391]: cycle detected when computing the super traits of `Baz` with associated type name `Item` - --> $DIR/ambiguous-associated-type2.rs:9:1 - | -LL | trait Baz: Foo + Bar {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: ...which again requires computing the super traits of `Baz` with associated type name `Item`, completing the cycle -note: cycle used when computing the super traits of `Baz` - --> $DIR/ambiguous-associated-type2.rs:9:1 - | -LL | trait Baz: Foo + Bar {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0391`. diff --git a/src/test/ui/associated-type-bounds/associated-item-through-where-clause.rs b/src/test/ui/associated-type-bounds/associated-item-through-where-clause.rs deleted file mode 100644 index 3eb50ab554735..0000000000000 --- a/src/test/ui/associated-type-bounds/associated-item-through-where-clause.rs +++ /dev/null @@ -1,21 +0,0 @@ -// check-pass - -trait Foo { - type Item; -} - -trait Bar -where - Self: Foo, -{ -} - -#[allow(dead_code)] -fn foo(_m: M) -where - M: Bar, - M::Item: Send, -{ -} - -fn main() {} diff --git a/src/test/ui/associated-type-bounds/handle-predicates-that-can-define-assoc-type.rs b/src/test/ui/associated-type-bounds/handle-predicates-that-can-define-assoc-type.rs deleted file mode 100644 index b1e54ec04493b..0000000000000 --- a/src/test/ui/associated-type-bounds/handle-predicates-that-can-define-assoc-type.rs +++ /dev/null @@ -1,10 +0,0 @@ -// check-pass - -trait Foo {} -trait Bar { - type A; - type B; -} -trait Baz: Bar + Foo {} - -fn main() {} diff --git a/src/test/ui/associated-type-bounds/missing-trait-bound-for-assoc-fails.rs b/src/test/ui/associated-type-bounds/missing-trait-bound-for-assoc-fails.rs deleted file mode 100644 index 07d0f8f8769e5..0000000000000 --- a/src/test/ui/associated-type-bounds/missing-trait-bound-for-assoc-fails.rs +++ /dev/null @@ -1,10 +0,0 @@ -#[allow(dead_code)] -fn foo(_m: M) -where - M::Item: Temp, - //~^ ERROR cannot find trait `Temp` in this scope [E0405] - //~| ERROR associated type `Item` not found for `M` [E0220] -{ -} - -fn main() {} diff --git a/src/test/ui/associated-type-bounds/missing-trait-bound-for-assoc-fails.stderr b/src/test/ui/associated-type-bounds/missing-trait-bound-for-assoc-fails.stderr deleted file mode 100644 index bc2807b03961c..0000000000000 --- a/src/test/ui/associated-type-bounds/missing-trait-bound-for-assoc-fails.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0405]: cannot find trait `Temp` in this scope - --> $DIR/missing-trait-bound-for-assoc-fails.rs:4:14 - | -LL | M::Item: Temp, - | ^^^^ not found in this scope - -error[E0220]: associated type `Item` not found for `M` - --> $DIR/missing-trait-bound-for-assoc-fails.rs:4:8 - | -LL | M::Item: Temp, - | ^^^^ associated type `Item` not found - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0220, E0405. -For more information about an error, try `rustc --explain E0220`. diff --git a/src/test/ui/associated-type-bounds/super-trait-referencing-self.rs b/src/test/ui/associated-type-bounds/super-trait-referencing-self.rs deleted file mode 100644 index c82ec01f4d61d..0000000000000 --- a/src/test/ui/associated-type-bounds/super-trait-referencing-self.rs +++ /dev/null @@ -1,12 +0,0 @@ -// check-pass -trait Foo { - type Bar; -} -trait Qux: Foo + AsRef {} -trait Foo2 {} - -trait Qux2: Foo2 + AsRef { - type Bar; -} - -fn main() {} diff --git a/src/test/ui/associated-type-bounds/super-trait-referencing.rs b/src/test/ui/associated-type-bounds/super-trait-referencing.rs deleted file mode 100644 index 2e97535157fd2..0000000000000 --- a/src/test/ui/associated-type-bounds/super-trait-referencing.rs +++ /dev/null @@ -1,19 +0,0 @@ -// check-pass - -// The goal of this test is to ensure that T: Bar -// in the where clause does not cycle - -trait Foo { - type Item; -} - -trait Bar {} - -fn baz() -where - T: Foo, - T: Bar, -{ -} - -fn main() {} diff --git a/src/test/ui/associated-type-bounds/super-trait-where-referencing-self.rs b/src/test/ui/associated-type-bounds/super-trait-where-referencing-self.rs deleted file mode 100644 index 72a6be9ffc388..0000000000000 --- a/src/test/ui/associated-type-bounds/super-trait-where-referencing-self.rs +++ /dev/null @@ -1,27 +0,0 @@ -// check-pass - -// Test that we do not get a cycle due to -// resolving `Self::Bar` in the where clauses -// on a trait definition (in particular, in -// a where clause that is defining a superpredicate). - -trait Foo { - type Bar; -} -trait Qux -where - Self: Foo, - Self: AsRef, -{ -} -trait Foo2 {} - -trait Qux2 -where - Self: Foo2, - Self: AsRef, -{ - type Bar; -} - -fn main() {} diff --git a/src/test/ui/associated-type-bounds/traits-assoc-anonymized.rs b/src/test/ui/associated-type-bounds/traits-assoc-anonymized.rs deleted file mode 100644 index a9d6eed810a6b..0000000000000 --- a/src/test/ui/associated-type-bounds/traits-assoc-anonymized.rs +++ /dev/null @@ -1,33 +0,0 @@ -// check-pass - -pub struct LookupInternedStorage; - -impl QueryStorageOps for LookupInternedStorage -where - Q: Query, - for<'d> Q: QueryDb<'d>, -{ - fn fmt_index(&self, db: &>::DynDb) { - <>::DynDb as HasQueryGroup>::group_storage(db); - } -} - -pub trait HasQueryGroup { - fn group_storage(&self); -} - -pub trait QueryStorageOps -where - Q: Query, -{ - fn fmt_index(&self, db: &>::DynDb); -} - -pub trait QueryDb<'d> { - type DynDb: HasQueryGroup + 'd; - type Group; -} - -pub trait Query: for<'d> QueryDb<'d> {} - -fn main() {} diff --git a/src/test/ui/associated-type-bounds/traits-assoc-type-macros.rs b/src/test/ui/associated-type-bounds/traits-assoc-type-macros.rs deleted file mode 100644 index ad5c6aed97c2c..0000000000000 --- a/src/test/ui/associated-type-bounds/traits-assoc-type-macros.rs +++ /dev/null @@ -1,43 +0,0 @@ -// check-pass -// compile-flags:-Cincremental=tmp/traits-assoc-type-macros - -// This test case makes sure that we can compile with incremental compilation -// enabled when there are macros, traits, inheritance and associated types involved. - -trait Deserializer { - type Error; -} - -trait Deserialize { - fn deserialize(_: D) -> D::Error - where - D: Deserializer; -} - -macro_rules! impl_deserialize { - ($name:ident) => { - impl Deserialize for $name { - fn deserialize(_: D) -> D::Error - where - D: Deserializer, - { - loop {} - } - } - }; -} - -macro_rules! formats { - { - $($name:ident,)* - } => { - $( - pub struct $name; - - impl_deserialize!($name); - )* - } -} -formats! { Foo, Bar, } - -fn main() {} diff --git a/src/test/ui/associated-types/issue-24159.rs b/src/test/ui/associated-types/issue-24159.rs deleted file mode 100644 index 49753e7bf1660..0000000000000 --- a/src/test/ui/associated-types/issue-24159.rs +++ /dev/null @@ -1,37 +0,0 @@ -// check-pass - -#![allow(unused)] - -trait Bar { - fn dummy(&self); -} - -trait Foo { - type A; - type B: Bar; - - fn get_b(&self) -> &Self::B; -} - -fn test_bar>(_: &B) {} - -fn test>(f: &F) { - test_bar(f.get_b()); -} - -trait Bar1 {} -trait Caz1 { - type A; - type B: Bar1; -} - -fn test1() where T: Caz1, U: Caz1 {} - -trait Bar2 {} -trait Caz2 { - type A; - type B: Bar2; -} -fn test2>() {} - -fn main() {} diff --git a/src/test/ui/associated-types/issue-37808.rs b/src/test/ui/associated-types/issue-37808.rs deleted file mode 100644 index 3701c37d0c86f..0000000000000 --- a/src/test/ui/associated-types/issue-37808.rs +++ /dev/null @@ -1,19 +0,0 @@ -// check-pass - -trait Parent { - type Ty; - type Assoc: Child; -} - -trait Child {} - -struct ChildWrapper(T); -impl Child for ChildWrapper where T: Child {} - -struct ParentWrapper(T); -impl> Parent for ParentWrapper { - type Ty = A; - type Assoc = ChildWrapper; -} - -fn main() {} diff --git a/src/test/ui/associated-types/issue-37883.rs b/src/test/ui/associated-types/issue-37883.rs deleted file mode 100644 index d854f6af3ea94..0000000000000 --- a/src/test/ui/associated-types/issue-37883.rs +++ /dev/null @@ -1,25 +0,0 @@ -// check-pass - -use std::ops::Mul; - -fn main() {} - -trait Ring {} -trait Real: Ring {} - -trait Module: Sized + Mul<::Ring, Output = Self> { - type Ring: Ring; -} - -trait EuclideanSpace { - type Coordinates: Module; - type Real: Real; -} - -trait Translation { - fn to_vector(&self) -> E::Coordinates; - - fn powf(&self, n: ::Ring) -> E::Coordinates { - self.to_vector() * n - } -} diff --git a/src/test/ui/associated-types/issue-38917.rs b/src/test/ui/associated-types/issue-38917.rs deleted file mode 100644 index 7e898851aa83a..0000000000000 --- a/src/test/ui/associated-types/issue-38917.rs +++ /dev/null @@ -1,25 +0,0 @@ -// check-pass - -use std::borrow::Borrow; - -trait TNode: Sized { - type ConcreteElement: TElement; -} - -trait TElement: Sized { - type ConcreteNode: TNode; -} - -trait DomTraversal { - type BorrowElement: Borrow; -} - -#[allow(dead_code)] -fn recalc_style_at() -where - E: TElement, - D: DomTraversal, -{ -} - -fn main() {} diff --git a/src/test/ui/associated-types/issue-39532.rs b/src/test/ui/associated-types/issue-39532.rs deleted file mode 100644 index 52652cedec961..0000000000000 --- a/src/test/ui/associated-types/issue-39532.rs +++ /dev/null @@ -1,14 +0,0 @@ -// check-pass - -#![allow(unused)] - -trait Foo { - type Bar; - type Baz: Bar; -} - -trait Bar {} - -fn x, U>(t: &T) {} - -fn main() {} diff --git a/src/test/ui/associated-types/issue-40093.rs b/src/test/ui/associated-types/issue-40093.rs deleted file mode 100644 index fd325ae100861..0000000000000 --- a/src/test/ui/associated-types/issue-40093.rs +++ /dev/null @@ -1,14 +0,0 @@ -// check-pass - -pub trait Test { - type Item; - type Bundle: From; -} - -fn fails() -where - T: Test, -{ -} - -fn main() {} diff --git a/src/test/ui/associated-types/issue-43475.rs b/src/test/ui/associated-types/issue-43475.rs deleted file mode 100644 index 5f177333c93d5..0000000000000 --- a/src/test/ui/associated-types/issue-43475.rs +++ /dev/null @@ -1,10 +0,0 @@ -// check-pass - -trait Foo { type FooT: Foo; } -impl Foo for () { type FooT = (); } -trait Bar { type BarT: Bar; } -impl Bar<()> for () { type BarT = (); } - -#[allow(dead_code)] -fn test>() { } -fn main() { } diff --git a/src/test/ui/associated-types/issue-63591.rs b/src/test/ui/associated-types/issue-63591.rs deleted file mode 100644 index 4d2e39f4da60c..0000000000000 --- a/src/test/ui/associated-types/issue-63591.rs +++ /dev/null @@ -1,24 +0,0 @@ -// check-pass - -#![feature(associated_type_bounds)] -#![feature(type_alias_impl_trait)] - -fn main() {} - -trait Bar { type Assoc; } - -trait Thing { - type Out; - fn func() -> Self::Out; -} - -struct AssocIsCopy; -impl Bar for AssocIsCopy { type Assoc = u8; } - -impl Thing for AssocIsCopy { - type Out = impl Bar; - - fn func() -> Self::Out { - AssocIsCopy - } -} diff --git a/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr b/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr index 919904ce3b6a2..dbdfb2e71e0cd 100644 --- a/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr +++ b/src/test/ui/async-await/async-block-control-flow-static-semantics.stderr @@ -59,22 +59,22 @@ error[E0308]: mismatched types --> $DIR/async-block-control-flow-static-semantics.rs:47:44 | LL | fn rethrow_targets_async_block_not_fn() -> Result { - | ---------------------------------- ^^^^^^^^^^^^^^^^^ expected enum `Result`, found `()` + | ---------------------------------- ^^^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found `()` | | | implicitly returns `()` as its body has no tail or `return` expression | - = note: expected enum `Result` + = note: expected enum `std::result::Result` found unit type `()` error[E0308]: mismatched types --> $DIR/async-block-control-flow-static-semantics.rs:56:50 | LL | fn rethrow_targets_async_block_not_async_fn() -> Result { - | ---------------------------------------- ^^^^^^^^^^^^^^^^^ expected enum `Result`, found `()` + | ---------------------------------------- ^^^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found `()` | | | implicitly returns `()` as its body has no tail or `return` expression | - = note: expected enum `Result` + = note: expected enum `std::result::Result` found unit type `()` error: aborting due to 8 previous errors diff --git a/src/test/ui/async-await/issue-73137.rs b/src/test/ui/async-await/issue-73137.rs index c43ce2cadba04..18374460df79b 100644 --- a/src/test/ui/async-await/issue-73137.rs +++ b/src/test/ui/async-await/issue-73137.rs @@ -4,6 +4,7 @@ // edition:2018 #![allow(dead_code)] +#![feature(wake_trait)] use std::future::Future; use std::task::{Waker, Wake, Context}; use std::sync::Arc; diff --git a/src/test/ui/async-await/issues/issue-62097.nll.stderr b/src/test/ui/async-await/issues/issue-62097.nll.stderr index ab10e5f1810bd..2a399540e5296 100644 --- a/src/test/ui/async-await/issues/issue-62097.nll.stderr +++ b/src/test/ui/async-await/issues/issue-62097.nll.stderr @@ -26,5 +26,4 @@ LL | foo(|| self.bar()).await; error: aborting due to 2 previous errors -Some errors have detailed explanations: E0373, E0521. -For more information about an error, try `rustc --explain E0373`. +For more information about this error, try `rustc --explain E0373`. diff --git a/src/test/ui/async-await/issues/issue-67893.stderr b/src/test/ui/async-await/issues/issue-67893.stderr index aee2ae0e2e4a8..af09f0a27bf21 100644 --- a/src/test/ui/async-await/issues/issue-67893.stderr +++ b/src/test/ui/async-await/issues/issue-67893.stderr @@ -13,9 +13,9 @@ LL | pub async fn run() { | - within this `impl Future` | = help: within `impl Future`, the trait `Send` is not implemented for `MutexGuard<'_, ()>` - = note: required because it appears within the type `for<'r, 's, 't0, 't1, 't2, 't3> {ResumeTy, Arc>, &'r Mutex<()>, Result, PoisonError>>, &'t1 MutexGuard<'t2, ()>, MutexGuard<'t3, ()>, (), impl Future}` - = note: required because it appears within the type `[static generator@run::{closure#0} for<'r, 's, 't0, 't1, 't2, 't3> {ResumeTy, Arc>, &'r Mutex<()>, Result, PoisonError>>, &'t1 MutexGuard<'t2, ()>, MutexGuard<'t3, ()>, (), impl Future}]` - = note: required because it appears within the type `from_generator::GenFuture<[static generator@run::{closure#0} for<'r, 's, 't0, 't1, 't2, 't3> {ResumeTy, Arc>, &'r Mutex<()>, Result, PoisonError>>, &'t1 MutexGuard<'t2, ()>, MutexGuard<'t3, ()>, (), impl Future}]>` + = note: required because it appears within the type `for<'r, 's, 't0, 't1, 't2, 't3> {ResumeTy, Arc>, &'r Mutex<()>, std::result::Result, PoisonError>>, &'t1 MutexGuard<'t2, ()>, MutexGuard<'t3, ()>, (), impl Future}` + = note: required because it appears within the type `[static generator@run::{closure#0} for<'r, 's, 't0, 't1, 't2, 't3> {ResumeTy, Arc>, &'r Mutex<()>, std::result::Result, PoisonError>>, &'t1 MutexGuard<'t2, ()>, MutexGuard<'t3, ()>, (), impl Future}]` + = note: required because it appears within the type `from_generator::GenFuture<[static generator@run::{closure#0} for<'r, 's, 't0, 't1, 't2, 't3> {ResumeTy, Arc>, &'r Mutex<()>, std::result::Result, PoisonError>>, &'t1 MutexGuard<'t2, ()>, MutexGuard<'t3, ()>, (), impl Future}]>` = note: required because it appears within the type `impl Future` = note: required because it appears within the type `impl Future` diff --git a/src/test/ui/attributes/key-value-non-ascii.rs b/src/test/ui/attributes/key-value-non-ascii.rs index 12942eabdf7b5..91c917e7db56f 100644 --- a/src/test/ui/attributes/key-value-non-ascii.rs +++ b/src/test/ui/attributes/key-value-non-ascii.rs @@ -1,4 +1,4 @@ #![feature(rustc_attrs)] -#[rustc_dummy = b"ffi.rs"] //~ ERROR non-ASCII character in byte constant +#[rustc_dummy = b"ffi.rs"] //~ ERROR byte constant must be ASCII fn main() {} diff --git a/src/test/ui/attributes/key-value-non-ascii.stderr b/src/test/ui/attributes/key-value-non-ascii.stderr index 1d4b0d5b2b130..3e082139f895b 100644 --- a/src/test/ui/attributes/key-value-non-ascii.stderr +++ b/src/test/ui/attributes/key-value-non-ascii.stderr @@ -1,11 +1,8 @@ -error: non-ASCII character in byte constant +error: byte constant must be ASCII. Use a \xHH escape for a non-ASCII byte --> $DIR/key-value-non-ascii.rs:3:19 | LL | #[rustc_dummy = b"ffi.rs"] | ^ - | | - | byte constant must be ASCII - | help: use a \xHH escape for a non-ASCII byte: `\xFB03` error: aborting due to previous error diff --git a/src/test/ui/borrowck/issue-45983.stderr b/src/test/ui/borrowck/issue-45983.stderr index feb098c598588..efd414a2d44ff 100644 --- a/src/test/ui/borrowck/issue-45983.stderr +++ b/src/test/ui/borrowck/issue-45983.stderr @@ -10,4 +10,3 @@ LL | give_any(|y| x = Some(y)); error: aborting due to previous error -For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/borrowck/issue-7573.stderr b/src/test/ui/borrowck/issue-7573.stderr index 9d86286b8676c..815419db833e5 100644 --- a/src/test/ui/borrowck/issue-7573.stderr +++ b/src/test/ui/borrowck/issue-7573.stderr @@ -12,4 +12,3 @@ LL | lines_to_use.push(installed_id); error: aborting due to previous error -For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/borrowck/regions-escape-bound-fn-2.stderr b/src/test/ui/borrowck/regions-escape-bound-fn-2.stderr index 14393bc8eeede..1dc60bb155452 100644 --- a/src/test/ui/borrowck/regions-escape-bound-fn-2.stderr +++ b/src/test/ui/borrowck/regions-escape-bound-fn-2.stderr @@ -10,4 +10,3 @@ LL | with_int(|y| x = Some(y)); error: aborting due to previous error -For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/borrowck/regions-escape-bound-fn.stderr b/src/test/ui/borrowck/regions-escape-bound-fn.stderr index a23fdacdee641..5c548ec2876a3 100644 --- a/src/test/ui/borrowck/regions-escape-bound-fn.stderr +++ b/src/test/ui/borrowck/regions-escape-bound-fn.stderr @@ -10,4 +10,3 @@ LL | with_int(|y| x = Some(y)); error: aborting due to previous error -For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/borrowck/regions-escape-unboxed-closure.stderr b/src/test/ui/borrowck/regions-escape-unboxed-closure.stderr index 153f77c8913ac..f2a49e70d2716 100644 --- a/src/test/ui/borrowck/regions-escape-unboxed-closure.stderr +++ b/src/test/ui/borrowck/regions-escape-unboxed-closure.stderr @@ -10,4 +10,3 @@ LL | with_int(&mut |y| x = Some(y)); error: aborting due to previous error -For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/cast/unsupported-cast.rs b/src/test/ui/cast/unsupported-cast.rs deleted file mode 100644 index 1384ecc6ef251..0000000000000 --- a/src/test/ui/cast/unsupported-cast.rs +++ /dev/null @@ -1,5 +0,0 @@ -struct A; - -fn main() { - println!("{:?}", 1.0 as *const A); //~ERROR casting `f64` as `*const A` is invalid -} diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.rs b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.rs deleted file mode 100644 index 02b373620966e..0000000000000 --- a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.rs +++ /dev/null @@ -1,130 +0,0 @@ -#![deny(disjoint_capture_drop_reorder)] -//~^ NOTE: the lint level is defined here - -// Test cases for types that implement a insignificant drop (stlib defined) - -// `t` needs Drop because one of its elements needs drop, -// therefore precise capture might affect drop ordering -fn test1_all_need_migration() { - let t = (String::new(), String::new()); - let t1 = (String::new(), String::new()); - let t2 = (String::new(), String::new()); - - let c = || { - //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` - //~| NOTE: drop(&(t, t1, t2)); - let _t = t.0; - let _t1 = t1.0; - let _t2 = t2.0; - }; - - c(); -} - -// String implements drop and therefore should be migrated. -// But in this test cases, `t2` is completely captured and when it is dropped won't be affected -fn test2_only_precise_paths_need_migration() { - let t = (String::new(), String::new()); - let t1 = (String::new(), String::new()); - let t2 = (String::new(), String::new()); - - let c = || { - //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` - //~| NOTE: drop(&(t, t1)); - let _t = t.0; - let _t1 = t1.0; - let _t2 = t2; - }; - - c(); -} - -// If a variable would've not been captured by value then it would've not been -// dropped with the closure and therefore doesn't need migration. -fn test3_only_by_value_need_migration() { - let t = (String::new(), String::new()); - let t1 = (String::new(), String::new()); - let c = || { - //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` - //~| NOTE: drop(&(t)); - let _t = t.0; - println!("{}", t1.1); - }; - - c(); -} - -// Copy types get copied into the closure instead of move. Therefore we don't need to -// migrate then as their drop order isn't tied to the closure. -fn test4_only_non_copy_types_need_migration() { - let t = (String::new(), String::new()); - - // `t1` is Copy because all of its elements are Copy - let t1 = (0i32, 0i32); - - let c = || { - //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` - //~| NOTE: drop(&(t)); - let _t = t.0; - let _t1 = t1.0; - }; - - c(); -} - -fn test5_only_drop_types_need_migration() { - struct S(i32, i32); - - let t = (String::new(), String::new()); - - // `s` doesn't implement Drop or any elements within it, and doesn't need migration - let s = S(0i32, 0i32); - - let c = || { - //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` - //~| NOTE: drop(&(t)); - let _t = t.0; - let _s = s.0; - }; - - c(); -} - -// Since we are using a move closure here, both `t` and `t1` get moved -// even though they are being used by ref inside the closure. -fn test6_move_closures_non_copy_types_might_need_migration() { - let t = (String::new(), String::new()); - let t1 = (String::new(), String::new()); - let c = move || { - //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` - //~| NOTE: drop(&(t1, t)); - println!("{} {}", t1.1, t.1); - }; - - c(); -} - -// Test migration analysis in case of Drop + Non Drop aggregates. -// Note we need migration here only because the non-copy (because Drop type) is captured, -// otherwise we won't need to, since we can get away with just by ref capture in that case. -fn test7_drop_non_drop_aggregate_need_migration() { - let t = (String::new(), String::new(), 0i32); - - let c = || { - //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` - //~| NOTE: drop(&(t)); - let _t = t.0; - }; - - c(); -} - -fn main() { - test1_all_need_migration(); - test2_only_precise_paths_need_migration(); - test3_only_by_value_need_migration(); - test4_only_non_copy_types_need_migration(); - test5_only_drop_types_need_migration(); - test6_move_closures_non_copy_types_might_need_migration(); - test7_drop_non_drop_aggregate_need_migration(); -} diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.stderr deleted file mode 100644 index 656c132c12dee..0000000000000 --- a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.stderr +++ /dev/null @@ -1,105 +0,0 @@ -error: drop order affected for closure because of `capture_disjoint_fields` - --> $DIR/insignificant_drop.rs:13:13 - | -LL | let c = || { - | _____________^ -LL | | -LL | | -LL | | let _t = t.0; -LL | | let _t1 = t1.0; -LL | | let _t2 = t2.0; -LL | | }; - | |_____^ - | -note: the lint level is defined here - --> $DIR/insignificant_drop.rs:1:9 - | -LL | #![deny(disjoint_capture_drop_reorder)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: drop(&(t, t1, t2)); - -error: drop order affected for closure because of `capture_disjoint_fields` - --> $DIR/insignificant_drop.rs:31:13 - | -LL | let c = || { - | _____________^ -LL | | -LL | | -LL | | let _t = t.0; -LL | | let _t1 = t1.0; -LL | | let _t2 = t2; -LL | | }; - | |_____^ - | - = note: drop(&(t, t1)); - -error: drop order affected for closure because of `capture_disjoint_fields` - --> $DIR/insignificant_drop.rs:47:13 - | -LL | let c = || { - | _____________^ -LL | | -LL | | -LL | | let _t = t.0; -LL | | println!("{}", t1.1); -LL | | }; - | |_____^ - | - = note: drop(&(t)); - -error: drop order affected for closure because of `capture_disjoint_fields` - --> $DIR/insignificant_drop.rs:65:13 - | -LL | let c = || { - | _____________^ -LL | | -LL | | -LL | | let _t = t.0; -LL | | let _t1 = t1.0; -LL | | }; - | |_____^ - | - = note: drop(&(t)); - -error: drop order affected for closure because of `capture_disjoint_fields` - --> $DIR/insignificant_drop.rs:83:13 - | -LL | let c = || { - | _____________^ -LL | | -LL | | -LL | | let _t = t.0; -LL | | let _s = s.0; -LL | | }; - | |_____^ - | - = note: drop(&(t)); - -error: drop order affected for closure because of `capture_disjoint_fields` - --> $DIR/insignificant_drop.rs:98:13 - | -LL | let c = move || { - | _____________^ -LL | | -LL | | -LL | | println!("{} {}", t1.1, t.1); -LL | | }; - | |_____^ - | - = note: drop(&(t1, t)); - -error: drop order affected for closure because of `capture_disjoint_fields` - --> $DIR/insignificant_drop.rs:113:13 - | -LL | let c = || { - | _____________^ -LL | | -LL | | -LL | | let _t = t.0; -LL | | }; - | |_____^ - | - = note: drop(&(t)); - -error: aborting due to 7 previous errors - diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/no_migrations.rs b/src/test/ui/closures/2229_closure_analysis/migrations/no_migrations.rs deleted file mode 100644 index 73592ce04c28f..0000000000000 --- a/src/test/ui/closures/2229_closure_analysis/migrations/no_migrations.rs +++ /dev/null @@ -1,84 +0,0 @@ -// run-pass - -// Set of test cases that don't need migrations - -#![deny(disjoint_capture_drop_reorder)] - - -// Copy types as copied by the closure instead of being moved into the closure -// Therefore their drop order isn't tied to the closure and won't be requiring any -// migrations. -fn test1_only_copy_types() { - let t = (0i32, 0i32); - - let c = || { - let _t = t.0; - }; - - c(); -} - -// Same as test1 but using a move closure -fn test2_only_copy_types_move_closure() { - let t = (0i32, 0i32); - - let c = move || { - println!("{}", t.0); - }; - - c(); -} - -// Don't need to migrate if captured by ref -fn test3_only_copy_types_move_closure() { - let t = (String::new(), String::new()); - - let c = || { - println!("{}", t.0); - }; - - c(); -} - -// Test migration analysis in case of Insignificant Drop + Non Drop aggregates. -// Note in this test the closure captures a non Drop type and therefore the variable -// is only captured by ref. -fn test4_insignificant_drop_non_drop_aggregate() { - let t = (String::new(), 0i32); - - let c = || { - let _t = t.1; - }; - - c(); -} - - -struct Foo(i32); -impl Drop for Foo { - fn drop(&mut self) { - println!("{:?} dropped", self.0); - } -} - -// Test migration analysis in case of Significant Drop + Non Drop aggregates. -// Note in this test the closure captures a non Drop type and therefore the variable -// is only captured by ref. -fn test5_significant_drop_non_drop_aggregate() { - let t = (Foo(0), 0i32); - - let c = || { - let _t = t.1; - }; - - c(); -} - -fn main() { - test1_only_copy_types(); - test2_only_copy_types_move_closure(); - test3_only_copy_types_move_closure(); - test4_insignificant_drop_non_drop_aggregate(); - test5_significant_drop_non_drop_aggregate(); - -} diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.rs b/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.rs deleted file mode 100644 index ed5e4ea8be011..0000000000000 --- a/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.rs +++ /dev/null @@ -1,137 +0,0 @@ -#![deny(disjoint_capture_drop_reorder)] -//~^ NOTE: the lint level is defined here - -// Test cases for types that implement a significant drop (user defined) - -#[derive(Debug)] -struct Foo(i32); -impl Drop for Foo { - fn drop(&mut self) { - println!("{:?} dropped", self.0); - } -} - -#[derive(Debug)] -struct ConstainsDropField(Foo, Foo); - -// `t` needs Drop because one of its elements needs drop, -// therefore precise capture might affect drop ordering -fn test1_all_need_migration() { - let t = (Foo(0), Foo(0)); - let t1 = (Foo(0), Foo(0)); - let t2 = (Foo(0), Foo(0)); - - let c = || { - //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` - //~| NOTE: drop(&(t, t1, t2)); - let _t = t.0; - let _t1 = t1.0; - let _t2 = t2.0; - }; - - c(); -} - -// String implements drop and therefore should be migrated. -// But in this test cases, `t2` is completely captured and when it is dropped won't be affected -fn test2_only_precise_paths_need_migration() { - let t = (Foo(0), Foo(0)); - let t1 = (Foo(0), Foo(0)); - let t2 = (Foo(0), Foo(0)); - - let c = || { - //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` - //~| NOTE: drop(&(t, t1)); - let _t = t.0; - let _t1 = t1.0; - let _t2 = t2; - }; - - c(); -} - -// If a variable would've not been captured by value then it would've not been -// dropped with the closure and therefore doesn't need migration. -fn test3_only_by_value_need_migration() { - let t = (Foo(0), Foo(0)); - let t1 = (Foo(0), Foo(0)); - let c = || { - //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` - //~| NOTE: drop(&(t)); - let _t = t.0; - println!("{:?}", t1.1); - }; - - c(); -} - -// The root variable might not implement drop themselves but some path starting -// at the root variable might implement Drop. -// -// If this path isn't captured we need to migrate for the root variable. -fn test4_type_contains_drop_need_migration() { - let t = ConstainsDropField(Foo(0), Foo(0)); - - let c = || { - //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` - //~| NOTE: drop(&(t)); - let _t = t.0; - }; - - c(); -} - -// Test migration analysis in case of Drop + Non Drop aggregates. -// Note we need migration here only because the non-copy (because Drop type) is captured, -// otherwise we won't need to, since we can get away with just by ref capture in that case. -fn test5_drop_non_drop_aggregate_need_migration() { - let t = (Foo(0), Foo(0), 0i32); - - let c = || { - //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` - //~| NOTE: drop(&(t)); - let _t = t.0; - }; - - c(); -} - -// Test migration analysis in case of Significant and Insignificant Drop aggregates. -fn test6_significant_insignificant_drop_aggregate_need_migration() { - struct S(i32, i32); - - let t = (Foo(0), String::new()); - - let c = || { - //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` - //~| NOTE: drop(&(t)); - let _t = t.1; - }; - - c(); -} - -// Since we are using a move closure here, both `t` and `t1` get moved -// even though they are being used by ref inside the closure. -fn test7_move_closures_non_copy_types_might_need_migration() { - let t = (Foo(0), Foo(0)); - let t1 = (Foo(0), Foo(0), Foo(0)); - - let c = move || { - //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` - //~| NOTE: drop(&(t1, t)); - println!("{:?} {:?}", t1.1, t.1); - }; - - c(); -} - -fn main() { - test1_all_need_migration(); - test2_only_precise_paths_need_migration(); - test3_only_by_value_need_migration(); - test4_type_contains_drop_need_migration(); - test5_drop_non_drop_aggregate_need_migration(); - test6_significant_insignificant_drop_aggregate_need_migration(); - test7_move_closures_non_copy_types_might_need_migration(); -} diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr deleted file mode 100644 index 6c21b27b493ba..0000000000000 --- a/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr +++ /dev/null @@ -1,103 +0,0 @@ -error: drop order affected for closure because of `capture_disjoint_fields` - --> $DIR/significant_drop.rs:24:13 - | -LL | let c = || { - | _____________^ -LL | | -LL | | -LL | | let _t = t.0; -LL | | let _t1 = t1.0; -LL | | let _t2 = t2.0; -LL | | }; - | |_____^ - | -note: the lint level is defined here - --> $DIR/significant_drop.rs:1:9 - | -LL | #![deny(disjoint_capture_drop_reorder)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: drop(&(t, t1, t2)); - -error: drop order affected for closure because of `capture_disjoint_fields` - --> $DIR/significant_drop.rs:42:13 - | -LL | let c = || { - | _____________^ -LL | | -LL | | -LL | | let _t = t.0; -LL | | let _t1 = t1.0; -LL | | let _t2 = t2; -LL | | }; - | |_____^ - | - = note: drop(&(t, t1)); - -error: drop order affected for closure because of `capture_disjoint_fields` - --> $DIR/significant_drop.rs:58:13 - | -LL | let c = || { - | _____________^ -LL | | -LL | | -LL | | let _t = t.0; -LL | | println!("{:?}", t1.1); -LL | | }; - | |_____^ - | - = note: drop(&(t)); - -error: drop order affected for closure because of `capture_disjoint_fields` - --> $DIR/significant_drop.rs:75:13 - | -LL | let c = || { - | _____________^ -LL | | -LL | | -LL | | let _t = t.0; -LL | | }; - | |_____^ - | - = note: drop(&(t)); - -error: drop order affected for closure because of `capture_disjoint_fields` - --> $DIR/significant_drop.rs:90:13 - | -LL | let c = || { - | _____________^ -LL | | -LL | | -LL | | let _t = t.0; -LL | | }; - | |_____^ - | - = note: drop(&(t)); - -error: drop order affected for closure because of `capture_disjoint_fields` - --> $DIR/significant_drop.rs:105:13 - | -LL | let c = || { - | _____________^ -LL | | -LL | | -LL | | let _t = t.1; -LL | | }; - | |_____^ - | - = note: drop(&(t)); - -error: drop order affected for closure because of `capture_disjoint_fields` - --> $DIR/significant_drop.rs:120:13 - | -LL | let c = move || { - | _____________^ -LL | | -LL | | -LL | | println!("{:?} {:?}", t1.1, t.1); -LL | | }; - | |_____^ - | - = note: drop(&(t1, t)); - -error: aborting due to 7 previous errors - diff --git a/src/test/ui/closures/closure-expected-type/expect-region-supply-region.stderr b/src/test/ui/closures/closure-expected-type/expect-region-supply-region.stderr index 0d97fa7e23014..213071abfffc3 100644 --- a/src/test/ui/closures/closure-expected-type/expect-region-supply-region.stderr +++ b/src/test/ui/closures/closure-expected-type/expect-region-supply-region.stderr @@ -20,4 +20,3 @@ LL | f = Some(x); error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/closures/issue-81700-mut-borrow.rs b/src/test/ui/closures/issue-81700-mut-borrow.rs deleted file mode 100644 index a27a6160142ad..0000000000000 --- a/src/test/ui/closures/issue-81700-mut-borrow.rs +++ /dev/null @@ -1,5 +0,0 @@ -fn foo(x: &mut u32) { - let bar = || { foo(x); }; - bar(); //~ ERROR cannot borrow -} -fn main() {} diff --git a/src/test/ui/closures/issue-81700-mut-borrow.stderr b/src/test/ui/closures/issue-81700-mut-borrow.stderr deleted file mode 100644 index 3f564afff58e2..0000000000000 --- a/src/test/ui/closures/issue-81700-mut-borrow.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0596]: cannot borrow `bar` as mutable, as it is not declared as mutable - --> $DIR/issue-81700-mut-borrow.rs:3:5 - | -LL | let bar = || { foo(x); }; - | --- - calling `bar` requires mutable binding due to mutable borrow of `x` - | | - | help: consider changing this to be mutable: `mut bar` -LL | bar(); - | ^^^ cannot borrow as mutable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0596`. diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/gate_test.rs b/src/test/ui/cmse-nonsecure-entry/gate_test.rs similarity index 100% rename from src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/gate_test.rs rename to src/test/ui/cmse-nonsecure-entry/gate_test.rs diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/gate_test.stderr b/src/test/ui/cmse-nonsecure-entry/gate_test.stderr similarity index 100% rename from src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/gate_test.stderr rename to src/test/ui/cmse-nonsecure-entry/gate_test.stderr diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-registers.rs b/src/test/ui/cmse-nonsecure-entry/params-on-registers.rs similarity index 100% rename from src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-registers.rs rename to src/test/ui/cmse-nonsecure-entry/params-on-registers.rs diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-stack.rs b/src/test/ui/cmse-nonsecure-entry/params-on-stack.rs similarity index 100% rename from src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-stack.rs rename to src/test/ui/cmse-nonsecure-entry/params-on-stack.rs diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-stack.stderr b/src/test/ui/cmse-nonsecure-entry/params-on-stack.stderr similarity index 100% rename from src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-stack.stderr rename to src/test/ui/cmse-nonsecure-entry/params-on-stack.stderr diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.rs b/src/test/ui/cmse-nonsecure-entry/trustzone-only.rs similarity index 100% rename from src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.rs rename to src/test/ui/cmse-nonsecure-entry/trustzone-only.rs diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.stderr b/src/test/ui/cmse-nonsecure-entry/trustzone-only.stderr similarity index 100% rename from src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.stderr rename to src/test/ui/cmse-nonsecure-entry/trustzone-only.stderr diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/wrong-abi.rs b/src/test/ui/cmse-nonsecure-entry/wrong-abi.rs similarity index 100% rename from src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/wrong-abi.rs rename to src/test/ui/cmse-nonsecure-entry/wrong-abi.rs diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/wrong-abi.stderr b/src/test/ui/cmse-nonsecure-entry/wrong-abi.stderr similarity index 100% rename from src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/wrong-abi.stderr rename to src/test/ui/cmse-nonsecure-entry/wrong-abi.stderr diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.rs b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.rs deleted file mode 100644 index e05dbf3bbc4bc..0000000000000 --- a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.rs +++ /dev/null @@ -1,11 +0,0 @@ -// gate-test-abi_c_cmse_nonsecure_call -fn main() { - let non_secure_function = unsafe { - core::mem::transmute:: i32>( - //~^ ERROR [E0658] - 0x10000004, - ) - }; - let mut toto = 5; - toto += non_secure_function(toto, 2, 3, 5); -} diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.stderr b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.stderr deleted file mode 100644 index ed8e16899a161..0000000000000 --- a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: C-cmse-nonsecure-call ABI is experimental and subject to change - --> $DIR/gate_test.rs:4:46 - | -LL | core::mem::transmute:: i32>( - | ^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #81391 for more information - = help: add `#![feature(abi_c_cmse_nonsecure_call)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-registers.rs b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-registers.rs deleted file mode 100644 index b09ea06c8f3d2..0000000000000 --- a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-registers.rs +++ /dev/null @@ -1,15 +0,0 @@ -// build-pass -// compile-flags: --target thumbv8m.main-none-eabi --crate-type lib -// only-thumbv8m.main-none-eabi -#![feature(abi_c_cmse_nonsecure_call)] -#![no_std] - -#[no_mangle] -pub fn test(a: u32, b: u32, c: u32, d: u32) -> u32 { - let non_secure_function = unsafe { - core::mem::transmute:: u32>( - 0x10000004, - ) - }; - non_secure_function(a, b, c, d) -} diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.rs b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.rs deleted file mode 100644 index cfdce4f4e92fa..0000000000000 --- a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.rs +++ /dev/null @@ -1,17 +0,0 @@ -// compile-flags: --target thumbv8m.main-none-eabi --crate-type lib -// only-thumbv8m.main-none-eabi -#![feature(abi_c_cmse_nonsecure_call)] -#![no_std] - -#[no_mangle] -pub fn test(a: u32, b: u32, c: u32, d: u32, e: u32) -> u32 { - let non_secure_function = unsafe { - core::mem::transmute::< - usize, - extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u32, u32) -> u32> - ( - 0x10000004, - ) - }; - non_secure_function(a, b, c, d, e) -} diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.stderr b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.stderr deleted file mode 100644 index c90641840755d..0000000000000 --- a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.stderr +++ /dev/null @@ -1,5 +0,0 @@ -error: :0:0: in function test i32 (i32, i32, i32, i32, i32): call to non-secure function would require passing arguments on stack - - -error: aborting due to previous error - diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.rs b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.rs deleted file mode 100644 index 17117301fefcb..0000000000000 --- a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.rs +++ /dev/null @@ -1,6 +0,0 @@ -// compile-flags: --target thumbv8m.main-none-eabi --crate-type lib -// only-thumbv8m.main-none-eabi -#![feature(abi_c_cmse_nonsecure_call)] -#![no_std] - -pub extern "C-cmse-nonsecure-call" fn test() {} //~ ERROR [E0781] diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.stderr b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.stderr deleted file mode 100644 index 78490bf8f68a2..0000000000000 --- a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0781]: the `"cmse-nonsecure-call"` ABI is only allowed on function pointers. - --> $DIR/wrong-abi-location-1.rs:6:1 - | -LL | pub extern "C-cmse-nonsecure-call" fn test() {} //~ ERROR [E0781] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0781`. diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.rs b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.rs deleted file mode 100644 index 78f553d747c20..0000000000000 --- a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.rs +++ /dev/null @@ -1,8 +0,0 @@ -// compile-flags: --target thumbv8m.main-none-eabi --crate-type lib -// only-thumbv8m.main-none-eabi -#![feature(abi_c_cmse_nonsecure_call)] -#![no_std] - -extern "C-cmse-nonsecure-call" { //~ ERROR [E0781] - fn test(); -} diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.stderr b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.stderr deleted file mode 100644 index 5c148e2cd6fe0..0000000000000 --- a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0781]: the `"C-cmse-nonsecure-call"` ABI is only allowed on function pointers. - --> $DIR/wrong-abi-location-2.rs:6:1 - | -LL | / extern "C-cmse-nonsecure-call" { -LL | | fn test(); //~ ERROR [E0781] -LL | | } - | |_^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0781`. diff --git a/src/test/ui/codemap_tests/unicode.stderr b/src/test/ui/codemap_tests/unicode.stderr index 61c3f4f1c9847..8b85adb58453f 100644 --- a/src/test/ui/codemap_tests/unicode.stderr +++ b/src/test/ui/codemap_tests/unicode.stderr @@ -4,7 +4,7 @@ error[E0703]: invalid ABI: found `路濫狼á́́` LL | extern "路濫狼á́́" fn foo() {} | ^^^^^^^^^ invalid ABI | - = help: valid ABIs: Rust, C, cdecl, stdcall, fastcall, vectorcall, thiscall, aapcs, win64, sysv64, ptx-kernel, msp430-interrupt, x86-interrupt, amdgpu-kernel, efiapi, avr-interrupt, avr-non-blocking-interrupt, C-cmse-nonsecure-call, system, rust-intrinsic, rust-call, platform-intrinsic, unadjusted + = help: valid ABIs: Rust, C, cdecl, stdcall, fastcall, vectorcall, thiscall, aapcs, win64, sysv64, ptx-kernel, msp430-interrupt, x86-interrupt, amdgpu-kernel, efiapi, avr-interrupt, avr-non-blocking-interrupt, system, rust-intrinsic, rust-call, platform-intrinsic, unadjusted error: aborting due to previous error diff --git a/src/test/ui/coercion/coercion-missing-tail-expected-type.stderr b/src/test/ui/coercion/coercion-missing-tail-expected-type.stderr index df1fb58e25a02..da8db4331dffb 100644 --- a/src/test/ui/coercion/coercion-missing-tail-expected-type.stderr +++ b/src/test/ui/coercion/coercion-missing-tail-expected-type.stderr @@ -12,13 +12,13 @@ error[E0308]: mismatched types --> $DIR/coercion-missing-tail-expected-type.rs:8:13 | LL | fn foo() -> Result { - | --- ^^^^^^^^^^^^^^^ expected enum `Result`, found `()` + | --- ^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found `()` | | | implicitly returns `()` as its body has no tail or `return` expression LL | Ok(1); | - help: consider removing this semicolon | - = note: expected enum `Result` + = note: expected enum `std::result::Result` found unit type `()` error: aborting due to 2 previous errors diff --git a/src/test/ui/command/command-setgroups.rs b/src/test/ui/command/command-setgroups.rs index 2067314f740d1..28f2bfdd3a776 100644 --- a/src/test/ui/command/command-setgroups.rs +++ b/src/test/ui/command/command-setgroups.rs @@ -3,7 +3,6 @@ // ignore-cloudabi // ignore-emscripten // ignore-sgx -// ignore-musl - returns dummy result for _SC_NGROUPS_MAX #![feature(rustc_private)] #![feature(setgroups)] diff --git a/src/test/ui/const-generics/const_evaluatable_checked/cross_crate_predicate.stderr b/src/test/ui/const-generics/const_evaluatable_checked/cross_crate_predicate.stderr index 1beb5315d1055..8a298b47fffa7 100644 --- a/src/test/ui/const-generics/const_evaluatable_checked/cross_crate_predicate.stderr +++ b/src/test/ui/const-generics/const_evaluatable_checked/cross_crate_predicate.stderr @@ -4,7 +4,7 @@ error: unconstrained generic constant LL | let _ = const_evaluatable_lib::test1::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -help: try adding a `where` bound using this expression: `where [u8; std::mem::size_of::() - 1]: Sized` +help: consider adding a `where` bound for this expression --> $DIR/auxiliary/const_evaluatable_lib.rs:6:10 | LL | [u8; std::mem::size_of::() - 1]: Sized, @@ -16,7 +16,7 @@ error: unconstrained generic constant LL | let _ = const_evaluatable_lib::test1::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -help: try adding a `where` bound using this expression: `where [u8; std::mem::size_of::() - 1]: Sized` +help: consider adding a `where` bound for this expression --> $DIR/auxiliary/const_evaluatable_lib.rs:4:27 | LL | pub fn test1() -> [u8; std::mem::size_of::() - 1] @@ -28,7 +28,7 @@ error: unconstrained generic constant LL | let _ = const_evaluatable_lib::test1::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -help: try adding a `where` bound using this expression: `where [u8; std::mem::size_of::() - 1]: Sized` +help: consider adding a `where` bound for this expression --> $DIR/auxiliary/const_evaluatable_lib.rs:6:10 | LL | [u8; std::mem::size_of::() - 1]: Sized, @@ -40,7 +40,7 @@ error: unconstrained generic constant LL | let _ = const_evaluatable_lib::test1::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -help: try adding a `where` bound using this expression: `where [u8; std::mem::size_of::() - 1]: Sized` +help: consider adding a `where` bound for this expression --> $DIR/auxiliary/const_evaluatable_lib.rs:4:27 | LL | pub fn test1() -> [u8; std::mem::size_of::() - 1] diff --git a/src/test/ui/const-generics/const_evaluatable_checked/different-fn.stderr b/src/test/ui/const-generics/const_evaluatable_checked/different-fn.stderr index 8cdc9b57750ee..1f6dddb04e56c 100644 --- a/src/test/ui/const-generics/const_evaluatable_checked/different-fn.stderr +++ b/src/test/ui/const-generics/const_evaluatable_checked/different-fn.stderr @@ -4,7 +4,7 @@ error: unconstrained generic constant LL | [0; size_of::>()] | ^^^^^^^^^^^^^^^^^^^ | -help: try adding a `where` bound using this expression: `where [u8; size_of::>()]: Sized` +help: consider adding a `where` bound for this expression --> $DIR/different-fn.rs:10:9 | LL | [0; size_of::>()] diff --git a/src/test/ui/const-generics/const_evaluatable_checked/nested_uneval_unification-1.rs b/src/test/ui/const-generics/const_evaluatable_checked/nested_uneval_unification-1.rs index 4d0b87efc77c3..1428f774b0d70 100644 --- a/src/test/ui/const-generics/const_evaluatable_checked/nested_uneval_unification-1.rs +++ b/src/test/ui/const-generics/const_evaluatable_checked/nested_uneval_unification-1.rs @@ -21,6 +21,7 @@ where fn substs3() -> Substs1<{ (L - 1) * 2 }> where + [(); (L - 1)]: , [(); (L - 1) * 2 + 1]: , { substs2::<{ L - 1 }>() diff --git a/src/test/ui/const-generics/const_evaluatable_checked/subexprs_are_const_evalutable.rs b/src/test/ui/const-generics/const_evaluatable_checked/subexprs_are_const_evalutable.rs deleted file mode 100644 index 11c0760cdfe05..0000000000000 --- a/src/test/ui/const-generics/const_evaluatable_checked/subexprs_are_const_evalutable.rs +++ /dev/null @@ -1,17 +0,0 @@ -// run-pass -#![feature(const_generics, const_evaluatable_checked)] -#![allow(incomplete_features)] - -fn make_array() -> [(); M + 1] { - [(); M + 1] -} - -fn foo() -> [(); (N * 2) + 1] { - make_array::<{ N * 2 }>() -} - -fn main() { - assert_eq!(foo::<10>(), [(); 10 * 2 + 1]) -} - -// Tests that N * 2 is considered const_evalutable by appearing as part of the (N * 2) + 1 const diff --git a/src/test/ui/const-ptr/out_of_bounds_read.stderr b/src/test/ui/const-ptr/out_of_bounds_read.stderr index 87b7c377b0036..ca65a079947e0 100644 --- a/src/test/ui/const-ptr/out_of_bounds_read.stderr +++ b/src/test/ui/const-ptr/out_of_bounds_read.stderr @@ -15,8 +15,6 @@ LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) }; | ------------------------------------------------------ | = note: `#[deny(const_err)]` 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/intrinsics.rs:LL:COL @@ -34,9 +32,6 @@ LL | unsafe { copy_nonoverlapping(src, dst, count) } | LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() }; | -------------------------------------------------------- - | - = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/intrinsics.rs:LL:COL @@ -54,9 +49,6 @@ LL | unsafe { copy_nonoverlapping(src, dst, count) } | LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() }; | -------------------------------------------------------------------- - | - = 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 #71800 error: aborting due to 3 previous errors diff --git a/src/test/ui/const-ptr/ptr_to_usize_cast.rs b/src/test/ui/const-ptr/ptr_to_usize_cast.rs deleted file mode 100644 index bf1e790b5dc29..0000000000000 --- a/src/test/ui/const-ptr/ptr_to_usize_cast.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![feature(const_raw_ptr_to_usize_cast)] - -fn main() { - const OK: usize = unsafe { 0 as *const i32 as usize }; - - const _ERROR: usize = unsafe { &0 as *const i32 as usize }; - //~^ ERROR [const_err] - //~| NOTE cannot cast pointer to integer because it was not created by cast from integer - //~| NOTE - //~| NOTE `#[deny(const_err)]` on by default - //~| WARN this was previously accepted by the compiler but is being phased out - //~| NOTE see issue #71800 -} diff --git a/src/test/ui/const-ptr/ptr_to_usize_cast.stderr b/src/test/ui/const-ptr/ptr_to_usize_cast.stderr deleted file mode 100644 index 48255860bb53f..0000000000000 --- a/src/test/ui/const-ptr/ptr_to_usize_cast.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: any use of this value will cause an error - --> $DIR/ptr_to_usize_cast.rs:6:36 - | -LL | const _ERROR: usize = unsafe { &0 as *const i32 as usize }; - | -------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^--- - | | - | cannot cast pointer to integer because it was not created by cast from integer - | - = note: `#[deny(const_err)]` 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 #71800 - -error: aborting due to previous error - diff --git a/src/test/ui/const_evaluatable/needs_where_clause.rs b/src/test/ui/const_evaluatable/needs_where_clause.rs deleted file mode 100644 index 498a2ae753361..0000000000000 --- a/src/test/ui/const_evaluatable/needs_where_clause.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![crate_type = "lib"] -#![feature(const_generics, const_evaluatable_checked)] -#![allow(incomplete_features)] - -const fn complex_maths(n : usize) -> usize { - 2 * n + 1 -} - -struct Example { - a: [f32; N], - b: [f32; complex_maths::(N)], - //~^ ERROR unconstrained - c: T, -} diff --git a/src/test/ui/const_evaluatable/needs_where_clause.stderr b/src/test/ui/const_evaluatable/needs_where_clause.stderr deleted file mode 100644 index 945105d1a2dc6..0000000000000 --- a/src/test/ui/const_evaluatable/needs_where_clause.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: unconstrained generic constant - --> $DIR/needs_where_clause.rs:11:6 - | -LL | b: [f32; complex_maths::(N)], - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try adding a `where` bound using this expression: `where [u8; complex_maths::(N)]: Sized` - --> $DIR/needs_where_clause.rs:11:12 - | -LL | b: [f32; complex_maths::(N)], - | ^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/const_evaluatable/no_where_clause.rs b/src/test/ui/const_evaluatable/no_where_clause.rs deleted file mode 100644 index 12f4a22038ef7..0000000000000 --- a/src/test/ui/const_evaluatable/no_where_clause.rs +++ /dev/null @@ -1,29 +0,0 @@ -#![feature(const_generics, const_evaluatable_checked)] -#![allow(incomplete_features, unused)] - -const fn complex_maths(n : usize) -> usize { - 2 * n + 1 -} - -pub struct Example { - a: [f32; N], - b: [f32; complex_maths(N)], - //~^ ERROR unconstrained generic -} - -impl Example { - pub fn new() -> Self { - Self { - a: [0.; N], - b: [0.; complex_maths(N)], - } - } -} - -impl Example<2> { - pub fn sum(&self) -> f32 { - self.a.iter().sum::() + self.b.iter().sum::() - } -} - -fn main() {} diff --git a/src/test/ui/const_evaluatable/no_where_clause.stderr b/src/test/ui/const_evaluatable/no_where_clause.stderr deleted file mode 100644 index 84a65f0d1d29b..0000000000000 --- a/src/test/ui/const_evaluatable/no_where_clause.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: unconstrained generic constant - --> $DIR/no_where_clause.rs:10:6 - | -LL | b: [f32; complex_maths(N)], - | ^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try adding a `where` bound using this expression: `where [u8; complex_maths(N)]: Sized` - --> $DIR/no_where_clause.rs:10:12 - | -LL | b: [f32; complex_maths(N)], - | ^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/consts/assoc_const_generic_impl.rs b/src/test/ui/consts/assoc_const_generic_impl.rs index 71d947b0c2c70..83f334dca9e83 100644 --- a/src/test/ui/consts/assoc_const_generic_impl.rs +++ b/src/test/ui/consts/assoc_const_generic_impl.rs @@ -9,7 +9,6 @@ trait ZeroSized: Sized { impl ZeroSized for T { const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::()]; //~ WARN any use of this value - //~| WARN this was previously accepted by the compiler but is being phased out fn requires_zero_size(self) { let () = Self::I_AM_ZERO_SIZED; //~ ERROR erroneous constant encountered println!("requires_zero_size called"); diff --git a/src/test/ui/consts/assoc_const_generic_impl.stderr b/src/test/ui/consts/assoc_const_generic_impl.stderr index 96cb904fa1b19..db64ebe0c4ae0 100644 --- a/src/test/ui/consts/assoc_const_generic_impl.stderr +++ b/src/test/ui/consts/assoc_const_generic_impl.stderr @@ -11,11 +11,9 @@ note: the lint level is defined here | LL | #![warn(const_err)] | ^^^^^^^^^ - = 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 #71800 error: erroneous constant encountered - --> $DIR/assoc_const_generic_impl.rs:14:18 + --> $DIR/assoc_const_generic_impl.rs:13:18 | LL | let () = Self::I_AM_ZERO_SIZED; | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/consts/assume-type-intrinsics.stderr b/src/test/ui/consts/assume-type-intrinsics.stderr index d46ce44b7ba2d..ed09f74e9b1f2 100644 --- a/src/test/ui/consts/assume-type-intrinsics.stderr +++ b/src/test/ui/consts/assume-type-intrinsics.stderr @@ -16,8 +16,6 @@ LL | | }; | |______- | = note: `#[deny(const_err)]` 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 #71800 error: aborting due to previous error diff --git a/src/test/ui/consts/const-err-early.rs b/src/test/ui/consts/const-err-early.rs index d8f7635fe9bbe..13dfe7fac9900 100644 --- a/src/test/ui/consts/const-err-early.rs +++ b/src/test/ui/consts/const-err-early.rs @@ -1,15 +1,10 @@ #![deny(const_err)] pub const A: i8 = -i8::MIN; //~ ERROR const_err -//~| WARN this was previously accepted by the compiler but is being phased out pub const B: u8 = 200u8 + 200u8; //~ ERROR const_err -//~| WARN this was previously accepted by the compiler but is being phased out pub const C: u8 = 200u8 * 4; //~ ERROR const_err -//~| WARN this was previously accepted by the compiler but is being phased out pub const D: u8 = 42u8 - (42u8 + 1); //~ ERROR const_err -//~| WARN this was previously accepted by the compiler but is being phased out pub const E: u8 = [5u8][1]; //~ ERROR const_err -//~| WARN this was previously accepted by the compiler but is being phased out fn main() { let _a = A; diff --git a/src/test/ui/consts/const-err-early.stderr b/src/test/ui/consts/const-err-early.stderr index 2b3d881738762..ec55139f17345 100644 --- a/src/test/ui/consts/const-err-early.stderr +++ b/src/test/ui/consts/const-err-early.stderr @@ -11,52 +11,38 @@ note: the lint level is defined here | LL | #![deny(const_err)] | ^^^^^^^^^ - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-err-early.rs:5:19 + --> $DIR/const-err-early.rs:4:19 | LL | pub const B: u8 = 200u8 + 200u8; | ------------------^^^^^^^^^^^^^- | | | attempt to compute `200_u8 + 200_u8`, which would overflow - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-err-early.rs:7:19 + --> $DIR/const-err-early.rs:5:19 | LL | pub const C: u8 = 200u8 * 4; | ------------------^^^^^^^^^- | | | attempt to compute `200_u8 * 4_u8`, which would overflow - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-err-early.rs:9:19 + --> $DIR/const-err-early.rs:6:19 | LL | pub const D: u8 = 42u8 - (42u8 + 1); | ------------------^^^^^^^^^^^^^^^^^- | | | attempt to compute `42_u8 - 43_u8`, which would overflow - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-err-early.rs:11:19 + --> $DIR/const-err-early.rs:7:19 | LL | pub const E: u8 = [5u8][1]; | ------------------^^^^^^^^- | | | index out of bounds: the length is 1 but the index is 1 - | - = 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 #71800 error: aborting due to 5 previous errors diff --git a/src/test/ui/consts/const-err-multi.rs b/src/test/ui/consts/const-err-multi.rs index 62552e1476ce2..ce74fae98162d 100644 --- a/src/test/ui/consts/const-err-multi.rs +++ b/src/test/ui/consts/const-err-multi.rs @@ -2,16 +2,12 @@ pub const A: i8 = -i8::MIN; //~^ ERROR const_err -//~| WARN this was previously accepted by the compiler but is being phased out pub const B: i8 = A; //~^ ERROR const_err -//~| WARN this was previously accepted by the compiler but is being phased out pub const C: u8 = A as u8; //~^ ERROR const_err -//~| WARN this was previously accepted by the compiler but is being phased out pub const D: i8 = 50 - A; //~^ ERROR const_err -//~| WARN this was previously accepted by the compiler but is being phased out fn main() { let _ = (A, B, C, D); diff --git a/src/test/ui/consts/const-err-multi.stderr b/src/test/ui/consts/const-err-multi.stderr index c8172e83d10e2..b3123b4e35928 100644 --- a/src/test/ui/consts/const-err-multi.stderr +++ b/src/test/ui/consts/const-err-multi.stderr @@ -11,41 +11,30 @@ note: the lint level is defined here | LL | #![deny(const_err)] | ^^^^^^^^^ - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-err-multi.rs:6:19 + --> $DIR/const-err-multi.rs:5:19 | LL | pub const B: i8 = A; | ------------------^- | | | referenced constant has errors - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-err-multi.rs:9:19 + --> $DIR/const-err-multi.rs:7:19 | LL | pub const C: u8 = A as u8; | ------------------^------- | | | referenced constant has errors - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-err-multi.rs:12:24 + --> $DIR/const-err-multi.rs:9:24 | LL | pub const D: i8 = 50 - A; | -----------------------^- | | | referenced constant has errors - | - = 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 #71800 error: aborting due to 4 previous errors diff --git a/src/test/ui/consts/const-err.rs b/src/test/ui/consts/const-err.rs index 031f2121a1ee2..d1c5f4f3f32ee 100644 --- a/src/test/ui/consts/const-err.rs +++ b/src/test/ui/consts/const-err.rs @@ -10,7 +10,6 @@ fn black_box(_: T) { const FOO: u8 = [5u8][1]; //~^ WARN any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out fn main() { black_box((FOO, FOO)); diff --git a/src/test/ui/consts/const-err.stderr b/src/test/ui/consts/const-err.stderr index 0c963874a8496..693b74c2c2f61 100644 --- a/src/test/ui/consts/const-err.stderr +++ b/src/test/ui/consts/const-err.stderr @@ -11,17 +11,15 @@ note: the lint level is defined here | LL | #![warn(const_err)] | ^^^^^^^^^ - = 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 #71800 error[E0080]: erroneous constant used - --> $DIR/const-err.rs:16:16 + --> $DIR/const-err.rs:15:16 | LL | black_box((FOO, FOO)); | ^^^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const-err.rs:16:21 + --> $DIR/const-err.rs:15:21 | LL | black_box((FOO, FOO)); | ^^^ referenced constant has errors diff --git a/src/test/ui/consts/const-eval/conditional_array_execution.rs b/src/test/ui/consts/const-eval/conditional_array_execution.rs index 9b99a685b6370..2058d2e218473 100644 --- a/src/test/ui/consts/const-eval/conditional_array_execution.rs +++ b/src/test/ui/consts/const-eval/conditional_array_execution.rs @@ -6,11 +6,9 @@ const X: u32 = 5; const Y: u32 = 6; const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; //~^ WARN any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out fn main() { println!("{}", FOO); //~^ ERROR //~| WARN erroneous constant used [const_err] - //~| WARN this was previously accepted by the compiler but is being phased out } diff --git a/src/test/ui/consts/const-eval/conditional_array_execution.stderr b/src/test/ui/consts/const-eval/conditional_array_execution.stderr index 356a7f58d8562..c2adff116ef20 100644 --- a/src/test/ui/consts/const-eval/conditional_array_execution.stderr +++ b/src/test/ui/consts/const-eval/conditional_array_execution.stderr @@ -11,23 +11,18 @@ note: the lint level is defined here | LL | #![warn(const_err)] | ^^^^^^^^^ - = 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 #71800 error[E0080]: evaluation of constant value failed - --> $DIR/conditional_array_execution.rs:12:20 + --> $DIR/conditional_array_execution.rs:11:20 | LL | println!("{}", FOO); | ^^^ referenced constant has errors warning: erroneous constant used - --> $DIR/conditional_array_execution.rs:12:20 + --> $DIR/conditional_array_execution.rs:11:20 | LL | println!("{}", FOO); | ^^^ referenced constant has errors - | - = 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 #71800 error: aborting due to previous error; 2 warnings emitted diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2.rs b/src/test/ui/consts/const-eval/const-eval-overflow2.rs index b11f7d6983bfa..57a9dd55c8b55 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow2.rs @@ -14,54 +14,46 @@ const VALS_I8: (i8,) = i8::MIN - 1, ); //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const VALS_I16: (i16,) = ( i16::MIN - 1, ); //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const VALS_I32: (i32,) = ( i32::MIN - 1, ); //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const VALS_I64: (i64,) = ( i64::MIN - 1, ); //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const VALS_U8: (u8,) = ( u8::MIN - 1, ); //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const VALS_U16: (u16,) = ( u16::MIN - 1, ); //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const VALS_U32: (u32,) = ( u32::MIN - 1, ); //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const VALS_U64: (u64,) = ( u64::MIN - 1, ); //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out fn main() { foo(VALS_I8); diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2.stderr b/src/test/ui/consts/const-eval/const-eval-overflow2.stderr index 66e86c352d154..8864bc170f2ee 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow2.stderr @@ -13,11 +13,9 @@ note: the lint level is defined here | LL | #![deny(const_err)] | ^^^^^^^^^ - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:21:6 + --> $DIR/const-eval-overflow2.rs:20:6 | LL | / const VALS_I16: (i16,) = LL | | ( @@ -25,12 +23,9 @@ LL | | i16::MIN - 1, | | ^^^^^^^^^^^^ attempt to compute `i16::MIN - 1_i16`, which would overflow LL | | ); | |_______- - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:28:6 + --> $DIR/const-eval-overflow2.rs:26:6 | LL | / const VALS_I32: (i32,) = LL | | ( @@ -38,12 +33,9 @@ LL | | i32::MIN - 1, | | ^^^^^^^^^^^^ attempt to compute `i32::MIN - 1_i32`, which would overflow LL | | ); | |_______- - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:35:6 + --> $DIR/const-eval-overflow2.rs:32:6 | LL | / const VALS_I64: (i64,) = LL | | ( @@ -51,12 +43,9 @@ LL | | i64::MIN - 1, | | ^^^^^^^^^^^^ attempt to compute `i64::MIN - 1_i64`, which would overflow LL | | ); | |_______- - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:42:6 + --> $DIR/const-eval-overflow2.rs:38:6 | LL | / const VALS_U8: (u8,) = LL | | ( @@ -64,36 +53,27 @@ LL | | u8::MIN - 1, | | ^^^^^^^^^^^ attempt to compute `0_u8 - 1_u8`, which would overflow LL | | ); | |_______- - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:48:6 + --> $DIR/const-eval-overflow2.rs:43:6 | LL | / const VALS_U16: (u16,) = ( LL | | u16::MIN - 1, | | ^^^^^^^^^^^^ attempt to compute `0_u16 - 1_u16`, which would overflow LL | | ); | |_______- - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:54:6 + --> $DIR/const-eval-overflow2.rs:48:6 | LL | / const VALS_U32: (u32,) = ( LL | | u32::MIN - 1, | | ^^^^^^^^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow LL | | ); | |_______- - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:61:6 + --> $DIR/const-eval-overflow2.rs:54:6 | LL | / const VALS_U64: (u64,) = LL | | ( @@ -101,9 +81,6 @@ LL | | u64::MIN - 1, | | ^^^^^^^^^^^^ attempt to compute `0_u64 - 1_u64`, which would overflow LL | | ); | |_______- - | - = 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 #71800 error: aborting due to 8 previous errors diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2b.rs b/src/test/ui/consts/const-eval/const-eval-overflow2b.rs index 9c3ad8ef9b44e..e87952ab0f438 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2b.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow2b.rs @@ -14,54 +14,46 @@ const VALS_I8: (i8,) = i8::MAX + 1, ); //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const VALS_I16: (i16,) = ( i16::MAX + 1, ); //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const VALS_I32: (i32,) = ( i32::MAX + 1, ); //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const VALS_I64: (i64,) = ( i64::MAX + 1, ); //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const VALS_U8: (u8,) = ( u8::MAX + 1, ); //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const VALS_U16: (u16,) = ( u16::MAX + 1, ); //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const VALS_U32: (u32,) = ( u32::MAX + 1, ); //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const VALS_U64: (u64,) = ( u64::MAX + 1, ); //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out fn main() { foo(VALS_I8); diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr b/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr index 3401ba4776500..e66e80c8f1937 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr @@ -13,11 +13,9 @@ note: the lint level is defined here | LL | #![deny(const_err)] | ^^^^^^^^^ - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:21:6 + --> $DIR/const-eval-overflow2b.rs:20:6 | LL | / const VALS_I16: (i16,) = LL | | ( @@ -25,12 +23,9 @@ LL | | i16::MAX + 1, | | ^^^^^^^^^^^^ attempt to compute `i16::MAX + 1_i16`, which would overflow LL | | ); | |_______- - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:28:6 + --> $DIR/const-eval-overflow2b.rs:26:6 | LL | / const VALS_I32: (i32,) = LL | | ( @@ -38,12 +33,9 @@ LL | | i32::MAX + 1, | | ^^^^^^^^^^^^ attempt to compute `i32::MAX + 1_i32`, which would overflow LL | | ); | |_______- - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:35:6 + --> $DIR/const-eval-overflow2b.rs:32:6 | LL | / const VALS_I64: (i64,) = LL | | ( @@ -51,12 +43,9 @@ LL | | i64::MAX + 1, | | ^^^^^^^^^^^^ attempt to compute `i64::MAX + 1_i64`, which would overflow LL | | ); | |_______- - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:42:6 + --> $DIR/const-eval-overflow2b.rs:38:6 | LL | / const VALS_U8: (u8,) = LL | | ( @@ -64,36 +53,27 @@ LL | | u8::MAX + 1, | | ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow LL | | ); | |_______- - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:48:6 + --> $DIR/const-eval-overflow2b.rs:43:6 | LL | / const VALS_U16: (u16,) = ( LL | | u16::MAX + 1, | | ^^^^^^^^^^^^ attempt to compute `u16::MAX + 1_u16`, which would overflow LL | | ); | |_______- - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:54:6 + --> $DIR/const-eval-overflow2b.rs:48:6 | LL | / const VALS_U32: (u32,) = ( LL | | u32::MAX + 1, | | ^^^^^^^^^^^^ attempt to compute `u32::MAX + 1_u32`, which would overflow LL | | ); | |_______- - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:61:6 + --> $DIR/const-eval-overflow2b.rs:54:6 | LL | / const VALS_U64: (u64,) = LL | | ( @@ -101,9 +81,6 @@ LL | | u64::MAX + 1, | | ^^^^^^^^^^^^ attempt to compute `u64::MAX + 1_u64`, which would overflow LL | | ); | |_______- - | - = 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 #71800 error: aborting due to 8 previous errors diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2c.rs b/src/test/ui/consts/const-eval/const-eval-overflow2c.rs index bac4d042e23c9..84d3dd20a924e 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2c.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow2c.rs @@ -14,54 +14,46 @@ const VALS_I8: (i8,) = i8::MIN * 2, ); //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const VALS_I16: (i16,) = ( i16::MIN * 2, ); //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const VALS_I32: (i32,) = ( i32::MIN * 2, ); //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const VALS_I64: (i64,) = ( i64::MIN * 2, ); //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const VALS_U8: (u8,) = ( u8::MAX * 2, ); //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const VALS_U16: (u16,) = ( u16::MAX * 2, ); //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const VALS_U32: (u32,) = ( u32::MAX * 2, ); //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const VALS_U64: (u64,) = ( u64::MAX * 2, ); //~^^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out fn main() { foo(VALS_I8); diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr b/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr index 93c64090f0eeb..10e308938f3a1 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr @@ -13,11 +13,9 @@ note: the lint level is defined here | LL | #![deny(const_err)] | ^^^^^^^^^ - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:21:6 + --> $DIR/const-eval-overflow2c.rs:20:6 | LL | / const VALS_I16: (i16,) = LL | | ( @@ -25,12 +23,9 @@ LL | | i16::MIN * 2, | | ^^^^^^^^^^^^ attempt to compute `i16::MIN * 2_i16`, which would overflow LL | | ); | |_______- - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:28:6 + --> $DIR/const-eval-overflow2c.rs:26:6 | LL | / const VALS_I32: (i32,) = LL | | ( @@ -38,12 +33,9 @@ LL | | i32::MIN * 2, | | ^^^^^^^^^^^^ attempt to compute `i32::MIN * 2_i32`, which would overflow LL | | ); | |_______- - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:35:6 + --> $DIR/const-eval-overflow2c.rs:32:6 | LL | / const VALS_I64: (i64,) = LL | | ( @@ -51,12 +43,9 @@ LL | | i64::MIN * 2, | | ^^^^^^^^^^^^ attempt to compute `i64::MIN * 2_i64`, which would overflow LL | | ); | |_______- - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:42:6 + --> $DIR/const-eval-overflow2c.rs:38:6 | LL | / const VALS_U8: (u8,) = LL | | ( @@ -64,36 +53,27 @@ LL | | u8::MAX * 2, | | ^^^^^^^^^^^ attempt to compute `u8::MAX * 2_u8`, which would overflow LL | | ); | |_______- - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:48:6 + --> $DIR/const-eval-overflow2c.rs:43:6 | LL | / const VALS_U16: (u16,) = ( LL | | u16::MAX * 2, | | ^^^^^^^^^^^^ attempt to compute `u16::MAX * 2_u16`, which would overflow LL | | ); | |_______- - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:54:6 + --> $DIR/const-eval-overflow2c.rs:48:6 | LL | / const VALS_U32: (u32,) = ( LL | | u32::MAX * 2, | | ^^^^^^^^^^^^ attempt to compute `u32::MAX * 2_u32`, which would overflow LL | | ); | |_______- - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:61:6 + --> $DIR/const-eval-overflow2c.rs:54:6 | LL | / const VALS_U64: (u64,) = LL | | ( @@ -101,9 +81,6 @@ LL | | u64::MAX * 2, | | ^^^^^^^^^^^^ attempt to compute `u64::MAX * 2_u64`, which would overflow LL | | ); | |_______- - | - = 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 #71800 error: aborting due to 8 previous errors diff --git a/src/test/ui/consts/const-eval/const-eval-query-stack.rs b/src/test/ui/consts/const-eval/const-eval-query-stack.rs index 8c3959cc11a43..cbfeca2402666 100644 --- a/src/test/ui/consts/const-eval/const-eval-query-stack.rs +++ b/src/test/ui/consts/const-eval/const-eval-query-stack.rs @@ -18,7 +18,6 @@ #[warn(const_err)] const X: i32 = 1 / 0; //~WARN any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out fn main() { let x: &'static i32 = &X; diff --git a/src/test/ui/consts/const-eval/const-eval-query-stack.stderr b/src/test/ui/consts/const-eval/const-eval-query-stack.stderr index 6a205ce9787f9..3e727b84aed10 100644 --- a/src/test/ui/consts/const-eval/const-eval-query-stack.stderr +++ b/src/test/ui/consts/const-eval/const-eval-query-stack.stderr @@ -11,11 +11,9 @@ note: the lint level is defined here | LL | #[warn(const_err)] | ^^^^^^^^^ - = 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 #71800 error[E0080]: evaluation of constant value failed - --> $DIR/const-eval-query-stack.rs:24:28 + --> $DIR/const-eval-query-stack.rs:23:28 | LL | let x: &'static i32 = &X; | ^ referenced constant has errors diff --git a/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.rs b/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.rs index 90bc191020e26..a2196db780ce0 100644 --- a/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.rs +++ b/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.rs @@ -27,15 +27,12 @@ fn main() { const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_8 }; //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 }; //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 }; //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 }; //~^ ERROR it is undefined behavior to use this value @@ -45,15 +42,12 @@ fn main() { const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 }; //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 }; //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 }; //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 }; //~^ ERROR it is undefined behavior to use this value @@ -63,69 +57,55 @@ fn main() { const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 }; //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 }; //~^ ERROR it is undefined behavior to use this value const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey }; //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character }; //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 }; //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 }; //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 }; //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 }; //~^ ERROR it is undefined behavior to use this value const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 }; //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 }; //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 }; //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 }; //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; //~^ ERROR it is undefined behavior to use this value const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 }; //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 }; //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 }; //~^ ERROR it is undefined behavior to use this value const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey }; //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character }; //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out } diff --git a/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr b/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr index ccd13784784e1..fb0ed1bd5aa94 100644 --- a/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr +++ b/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr @@ -15,33 +15,25 @@ LL | const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_ | unable to turn pointer into raw bytes | = note: `#[deny(const_err)]` 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 #71800 error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:32:45 + --> $DIR/const-pointer-values-in-various-types.rs:31:45 | LL | const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 }; | ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:36:45 + --> $DIR/const-pointer-values-in-various-types.rs:34:45 | LL | const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 }; | ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes - | - = 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 #71800 error[E0080]: it is undefined behavior to use this value - --> $DIR/const-pointer-values-in-various-types.rs:40:5 + --> $DIR/const-pointer-values-in-various-types.rs:37:5 | LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc18, but expected initialized plain (non-pointer) bytes @@ -49,7 +41,7 @@ LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uin = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. error[E0080]: it is undefined behavior to use this value - --> $DIR/const-pointer-values-in-various-types.rs:43:5 + --> $DIR/const-pointer-values-in-various-types.rs:40:5 | LL | const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes @@ -57,40 +49,31 @@ LL | const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.u = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:46:43 + --> $DIR/const-pointer-values-in-various-types.rs:43:43 | LL | const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 }; | --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:50:45 + --> $DIR/const-pointer-values-in-various-types.rs:46:45 | LL | const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 }; | ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:54:45 + --> $DIR/const-pointer-values-in-various-types.rs:49:45 | LL | const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 }; | ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes - | - = 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 #71800 error[E0080]: it is undefined behavior to use this value - --> $DIR/const-pointer-values-in-various-types.rs:58:5 + --> $DIR/const-pointer-values-in-various-types.rs:52:5 | LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc38, but expected initialized plain (non-pointer) bytes @@ -98,7 +81,7 @@ LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. error[E0080]: it is undefined behavior to use this value - --> $DIR/const-pointer-values-in-various-types.rs:61:5 + --> $DIR/const-pointer-values-in-various-types.rs:55:5 | LL | const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes @@ -106,18 +89,15 @@ LL | const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.i = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:64:45 + --> $DIR/const-pointer-values-in-various-types.rs:58:45 | LL | const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 }; | ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes - | - = 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 #71800 error[E0080]: it is undefined behavior to use this value - --> $DIR/const-pointer-values-in-various-types.rs:68:5 + --> $DIR/const-pointer-values-in-various-types.rs:61:5 | LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc50, but expected initialized plain (non-pointer) bytes @@ -125,62 +105,47 @@ LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.flo = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:71:47 + --> $DIR/const-pointer-values-in-various-types.rs:64:47 | LL | const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey }; | ------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:75:47 + --> $DIR/const-pointer-values-in-various-types.rs:67:47 | LL | const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character }; | ------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:79:39 + --> $DIR/const-pointer-values-in-various-types.rs:70:39 | LL | const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 }; | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:83:41 + --> $DIR/const-pointer-values-in-various-types.rs:73:41 | LL | const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 }; | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:87:41 + --> $DIR/const-pointer-values-in-various-types.rs:76:41 | LL | const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 }; | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes - | - = 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 #71800 error[E0080]: it is undefined behavior to use this value - --> $DIR/const-pointer-values-in-various-types.rs:91:5 + --> $DIR/const-pointer-values-in-various-types.rs:79:5 | LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc71, but expected initialized plain (non-pointer) bytes @@ -188,51 +153,39 @@ LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 } = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:94:43 + --> $DIR/const-pointer-values-in-various-types.rs:82:43 | LL | const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 }; | --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:98:39 + --> $DIR/const-pointer-values-in-various-types.rs:85:39 | LL | const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 }; | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:102:41 + --> $DIR/const-pointer-values-in-various-types.rs:88:41 | LL | const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 }; | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:106:41 + --> $DIR/const-pointer-values-in-various-types.rs:91:41 | LL | const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 }; | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes - | - = 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 #71800 error[E0080]: it is undefined behavior to use this value - --> $DIR/const-pointer-values-in-various-types.rs:110:5 + --> $DIR/const-pointer-values-in-various-types.rs:94:5 | LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc86, but expected initialized plain (non-pointer) bytes @@ -240,29 +193,23 @@ LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:113:43 + --> $DIR/const-pointer-values-in-various-types.rs:97:43 | LL | const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 }; | --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:117:41 + --> $DIR/const-pointer-values-in-various-types.rs:100:41 | LL | const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 }; | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes - | - = 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 #71800 error[E0080]: it is undefined behavior to use this value - --> $DIR/const-pointer-values-in-various-types.rs:121:5 + --> $DIR/const-pointer-values-in-various-types.rs:103:5 | LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc95, but expected initialized plain (non-pointer) bytes @@ -270,26 +217,20 @@ LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:124:43 + --> $DIR/const-pointer-values-in-various-types.rs:106:43 | LL | const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey }; | --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:128:43 + --> $DIR/const-pointer-values-in-various-types.rs:109:43 | LL | const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character }; | --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes - | - = 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 #71800 error: aborting due to 29 previous errors diff --git a/src/test/ui/consts/const-eval/const_panic.rs b/src/test/ui/consts/const-eval/const_panic.rs index 8ae8376ae4a6f..799c185fb8e4b 100644 --- a/src/test/ui/consts/const-eval/const_panic.rs +++ b/src/test/ui/consts/const-eval/const_panic.rs @@ -1,45 +1,34 @@ #![feature(const_panic)] -#![allow(non_fmt_panic)] #![crate_type = "lib"] const MSG: &str = "hello"; const Z: () = std::panic!("cheese"); //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const Z2: () = std::panic!(); //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const Y: () = std::unreachable!(); //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const X: () = std::unimplemented!(); //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out // const W: () = std::panic!(MSG); //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const Z_CORE: () = core::panic!("cheese"); //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const Z2_CORE: () = core::panic!(); //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const Y_CORE: () = core::unreachable!(); //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const X_CORE: () = core::unimplemented!(); //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const W_CORE: () = core::panic!(MSG); //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out diff --git a/src/test/ui/consts/const-eval/const_panic.stderr b/src/test/ui/consts/const-eval/const_panic.stderr index 74907a0b49518..c2711952d5837 100644 --- a/src/test/ui/consts/const-eval/const_panic.stderr +++ b/src/test/ui/consts/const-eval/const_panic.stderr @@ -1,122 +1,102 @@ error: any use of this value will cause an error - --> $DIR/const_panic.rs:7:15 + --> $DIR/const_panic.rs:6:15 | LL | const Z: () = std::panic!("cheese"); | --------------^^^^^^^^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'cheese', $DIR/const_panic.rs:7:15 + | the evaluated program panicked at 'cheese', $DIR/const_panic.rs:6:15 | = note: `#[deny(const_err)]` 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic.rs:11:16 + --> $DIR/const_panic.rs:9:16 | LL | const Z2: () = std::panic!(); | ---------------^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:11:16 + | the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:9:16 | - = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic.rs:15:15 + --> $DIR/const_panic.rs:12:15 | LL | const Y: () = std::unreachable!(); | --------------^^^^^^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:15:15 + | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:12:15 | - = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic.rs:19:15 + --> $DIR/const_panic.rs:15:15 | LL | const X: () = std::unimplemented!(); | --------------^^^^^^^^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:19:15 + | the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:15:15 | - = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic.rs:23:15 + --> $DIR/const_panic.rs:18:15 | LL | const W: () = std::panic!(MSG); | --------------^^^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'hello', $DIR/const_panic.rs:23:15 + | the evaluated program panicked at 'hello', $DIR/const_panic.rs:18:15 | - = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic.rs:27:20 + --> $DIR/const_panic.rs:21:20 | LL | const Z_CORE: () = core::panic!("cheese"); | -------------------^^^^^^^^^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'cheese', $DIR/const_panic.rs:27:20 + | the evaluated program panicked at 'cheese', $DIR/const_panic.rs:21:20 | - = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic.rs:31:21 + --> $DIR/const_panic.rs:24:21 | LL | const Z2_CORE: () = core::panic!(); | --------------------^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:31:21 + | the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:24:21 | - = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic.rs:35:20 + --> $DIR/const_panic.rs:27:20 | LL | const Y_CORE: () = core::unreachable!(); | -------------------^^^^^^^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:35:20 + | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:27:20 | - = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic.rs:39:20 + --> $DIR/const_panic.rs:30:20 | LL | const X_CORE: () = core::unimplemented!(); | -------------------^^^^^^^^^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:39:20 + | the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:30:20 | - = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic.rs:43:20 + --> $DIR/const_panic.rs:33:20 | LL | const W_CORE: () = core::panic!(MSG); | -------------------^^^^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'hello', $DIR/const_panic.rs:43:20 + | the evaluated program panicked at 'hello', $DIR/const_panic.rs:33:20 | - = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 10 previous errors diff --git a/src/test/ui/consts/const-eval/const_panic_libcore_bin.rs b/src/test/ui/consts/const-eval/const_panic_libcore_bin.rs index 0eb1e3eb94e52..6b03e847def14 100644 --- a/src/test/ui/consts/const-eval/const_panic_libcore_bin.rs +++ b/src/test/ui/consts/const-eval/const_panic_libcore_bin.rs @@ -8,15 +8,12 @@ use core::panic::PanicInfo; const Z: () = panic!("cheese"); //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const Y: () = unreachable!(); //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const X: () = unimplemented!(); //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out #[lang = "eh_personality"] fn eh() {} diff --git a/src/test/ui/consts/const-eval/const_panic_libcore_bin.stderr b/src/test/ui/consts/const-eval/const_panic_libcore_bin.stderr index 7c33610faff0a..9eeddc464f5ad 100644 --- a/src/test/ui/consts/const-eval/const_panic_libcore_bin.stderr +++ b/src/test/ui/consts/const-eval/const_panic_libcore_bin.stderr @@ -7,32 +7,26 @@ LL | const Z: () = panic!("cheese"); | the evaluated program panicked at 'cheese', $DIR/const_panic_libcore_bin.rs:9:15 | = note: `#[deny(const_err)]` 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic_libcore_bin.rs:13:15 + --> $DIR/const_panic_libcore_bin.rs:12:15 | LL | const Y: () = unreachable!(); | --------------^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore_bin.rs:13:15 + | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore_bin.rs:12:15 | - = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic_libcore_bin.rs:17:15 + --> $DIR/const_panic_libcore_bin.rs:15:15 | LL | const X: () = unimplemented!(); | --------------^^^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'not implemented', $DIR/const_panic_libcore_bin.rs:17:15 + | the evaluated program panicked at 'not implemented', $DIR/const_panic_libcore_bin.rs:15:15 | - = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 3 previous errors diff --git a/src/test/ui/consts/const-eval/const_raw_ptr_ops2.rs b/src/test/ui/consts/const-eval/const_raw_ptr_ops2.rs index c6a623b293276..d2a7623837a23 100644 --- a/src/test/ui/consts/const-eval/const_raw_ptr_ops2.rs +++ b/src/test/ui/consts/const-eval/const_raw_ptr_ops2.rs @@ -6,11 +6,8 @@ fn main() {} const Y: usize = unsafe { 42usize as *const i32 as usize + 1 }; // unconst and bad, will thus error in miri const Y2: usize = unsafe { &1 as *const i32 as usize + 1 }; //~ ERROR any use of this -//~| WARN this was previously accepted by the compiler but is being phased out // unconst and fine const Z: i32 = unsafe { *(&1 as *const i32) }; // unconst and bad, will thus error in miri const Z2: i32 = unsafe { *(42 as *const i32) }; //~ ERROR any use of this value will cause -//~| WARN this was previously accepted by the compiler but is being phased out const Z3: i32 = unsafe { *(44 as *const i32) }; //~ ERROR any use of this value will cause -//~| WARN this was previously accepted by the compiler but is being phased out diff --git a/src/test/ui/consts/const-eval/const_raw_ptr_ops2.stderr b/src/test/ui/consts/const-eval/const_raw_ptr_ops2.stderr index df8b33a0898f6..93f2261745d6f 100644 --- a/src/test/ui/consts/const-eval/const_raw_ptr_ops2.stderr +++ b/src/test/ui/consts/const-eval/const_raw_ptr_ops2.stderr @@ -4,33 +4,25 @@ error: any use of this value will cause an error LL | const Y2: usize = unsafe { &1 as *const i32 as usize + 1 }; | ---------------------------^^^^^^^^^^^^^^^^^^^^^^^^^------- | | - | cannot cast pointer to integer because it was not created by cast from integer + | "pointer-to-integer cast" needs an rfc before being allowed inside constants | = note: `#[deny(const_err)]` 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 #71800 error: any use of this value will cause an error - --> $DIR/const_raw_ptr_ops2.rs:13:26 + --> $DIR/const_raw_ptr_ops2.rs:12:26 | LL | const Z2: i32 = unsafe { *(42 as *const i32) }; | -------------------------^^^^^^^^^^^^^^^^^^^--- | | | unable to turn bytes into a pointer - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const_raw_ptr_ops2.rs:15:26 + --> $DIR/const_raw_ptr_ops2.rs:13:26 | LL | const Z3: i32 = unsafe { *(44 as *const i32) }; | -------------------------^^^^^^^^^^^^^^^^^^^--- | | | unable to turn bytes into a pointer - | - = 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 #71800 error: aborting due to 3 previous errors diff --git a/src/test/ui/consts/const-eval/dangling.rs b/src/test/ui/consts/const-eval/dangling.rs index 185d11605fdb5..72e97c03220fc 100644 --- a/src/test/ui/consts/const-eval/dangling.rs +++ b/src/test/ui/consts/const-eval/dangling.rs @@ -6,10 +6,8 @@ use std::mem; const TEST: () = { unsafe { //~ NOTE let slice: *const [u8] = mem::transmute((1usize, usize::MAX)); let _val = &*slice; //~ ERROR: any use of this value will cause an error - //~| NOTE: slice is bigger than largest supported object - //~| on by default - //~| WARN this was previously accepted by the compiler but is being phased out - //~| NOTE + //~^ NOTE: slice is bigger than largest supported object + //~^^ on by default } }; fn main() {} diff --git a/src/test/ui/consts/const-eval/dangling.stderr b/src/test/ui/consts/const-eval/dangling.stderr index a7f7cf13c5b0f..b9ddc93b03b84 100644 --- a/src/test/ui/consts/const-eval/dangling.stderr +++ b/src/test/ui/consts/const-eval/dangling.stderr @@ -6,14 +6,11 @@ LL | | let slice: *const [u8] = mem::transmute((1usize, usize::MAX)); LL | | let _val = &*slice; | | ^^^^^^^ invalid metadata in wide pointer: slice is bigger than largest supported object LL | | -... | LL | | LL | | } }; | |____- | = note: `#[deny(const_err)]` 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 #71800 error: aborting due to previous error diff --git a/src/test/ui/consts/const-eval/erroneous-const.rs b/src/test/ui/consts/const-eval/erroneous-const.rs index b79ce4a523f96..16bf1adf7db3e 100644 --- a/src/test/ui/consts/const-eval/erroneous-const.rs +++ b/src/test/ui/consts/const-eval/erroneous-const.rs @@ -5,7 +5,6 @@ struct PrintName(T); impl PrintName { const VOID: () = [()][2]; //~WARN any use of this value will cause an error //~^ WARN this operation will panic at runtime - //~| WARN this was previously accepted by the compiler but is being phased out } const fn no_codegen() { diff --git a/src/test/ui/consts/const-eval/erroneous-const.stderr b/src/test/ui/consts/const-eval/erroneous-const.stderr index 16ed596628bf5..040cc3fcf798d 100644 --- a/src/test/ui/consts/const-eval/erroneous-const.stderr +++ b/src/test/ui/consts/const-eval/erroneous-const.stderr @@ -23,20 +23,18 @@ note: the lint level is defined here | LL | #![warn(const_err, unconditional_panic)] | ^^^^^^^^^ - = 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 #71800 error[E0080]: could not evaluate static initializer - --> $DIR/erroneous-const.rs:13:17 + --> $DIR/erroneous-const.rs:12:17 | LL | let _ = PrintName::::VOID; | ^^^^^^^^^^^^^^^^^^^^ | | | referenced constant has errors - | inside `no_codegen::` at $DIR/erroneous-const.rs:13:17 + | inside `no_codegen::` at $DIR/erroneous-const.rs:12:17 ... LL | pub static FOO: () = no_codegen::(); - | ------------------- inside `FOO` at $DIR/erroneous-const.rs:17:22 + | ------------------- inside `FOO` at $DIR/erroneous-const.rs:16:22 error: aborting due to previous error; 2 warnings emitted diff --git a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs index 43d79badd7282..0d809ca9a622b 100644 --- a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs +++ b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs @@ -9,7 +9,6 @@ const fn foo() -> i32 { unsafe { let _ = intrinsics::const_allocate(4, 3) as * mut i32; //~^ error: any use of this value will cause an error [const_err] - //~| WARN this was previously accepted by the compiler but is being phased out } 1 diff --git a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr index 3d529ab4ca6e5..41c1b977269a3 100644 --- a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr +++ b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr @@ -12,8 +12,6 @@ LL | let _ = intrinsics::const_allocate(4, 3) as * mut i32; | inside `FOO` at $DIR/alloc_intrinsic_errors.rs:7:18 | = note: `#[deny(const_err)]` 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 #71800 error: aborting due to previous error diff --git a/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs b/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs index 8064cc49359ee..795c5154f8155 100644 --- a/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs +++ b/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs @@ -9,7 +9,6 @@ struct PrintName(T); impl PrintName { const VOID: ! = { let x = 0 * std::mem::size_of::(); [][x] }; //~^ WARN any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out } diff --git a/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.stderr b/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.stderr index 73664fa49d189..8647da90a37d4 100644 --- a/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.stderr +++ b/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.stderr @@ -11,11 +11,9 @@ note: the lint level is defined here | LL | #![warn(const_err, unconditional_panic)] | ^^^^^^^^^ - = 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 #71800 error: erroneous constant encountered - --> $DIR/index-out-of-bounds-never-type.rs:17:13 + --> $DIR/index-out-of-bounds-never-type.rs:16:13 | LL | let _ = PrintName::::VOID; | ^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/consts/const-eval/issue-43197.rs b/src/test/ui/consts/const-eval/issue-43197.rs index e15f8771dd73b..7d1d33288a907 100644 --- a/src/test/ui/consts/const-eval/issue-43197.rs +++ b/src/test/ui/consts/const-eval/issue-43197.rs @@ -9,15 +9,11 @@ const fn foo(x: u32) -> u32 { fn main() { const X: u32 = 0 - 1; //~^ WARN any use of this value will cause - //~| WARN this was previously accepted by the compiler but is being phased out const Y: u32 = foo(0 - 1); //~^ WARN any use of this value will cause - //~| WARN this was previously accepted by the compiler but is being phased out println!("{} {}", X, Y); //~^ ERROR evaluation of constant value failed //~| ERROR evaluation of constant value failed //~| WARN erroneous constant used [const_err] //~| WARN erroneous constant used [const_err] - //~| WARN this was previously accepted by the compiler but is being phased out - //~| WARN this was previously accepted by the compiler but is being phased out } diff --git a/src/test/ui/consts/const-eval/issue-43197.stderr b/src/test/ui/consts/const-eval/issue-43197.stderr index d4d8cbc669a7b..8c72b59141687 100644 --- a/src/test/ui/consts/const-eval/issue-43197.stderr +++ b/src/test/ui/consts/const-eval/issue-43197.stderr @@ -11,49 +11,38 @@ note: the lint level is defined here | LL | #![warn(const_err)] | ^^^^^^^^^ - = 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 #71800 warning: any use of this value will cause an error - --> $DIR/issue-43197.rs:13:24 + --> $DIR/issue-43197.rs:12:24 | LL | const Y: u32 = foo(0 - 1); | -------------------^^^^^-- | | | attempt to compute `0_u32 - 1_u32`, which would overflow - | - = 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 #71800 error[E0080]: evaluation of constant value failed - --> $DIR/issue-43197.rs:16:23 + --> $DIR/issue-43197.rs:14:23 | LL | println!("{} {}", X, Y); | ^ referenced constant has errors warning: erroneous constant used - --> $DIR/issue-43197.rs:16:23 + --> $DIR/issue-43197.rs:14:23 | LL | println!("{} {}", X, Y); | ^ referenced constant has errors - | - = 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 #71800 error[E0080]: evaluation of constant value failed - --> $DIR/issue-43197.rs:16:26 + --> $DIR/issue-43197.rs:14:26 | LL | println!("{} {}", X, Y); | ^ referenced constant has errors warning: erroneous constant used - --> $DIR/issue-43197.rs:16:26 + --> $DIR/issue-43197.rs:14:26 | LL | println!("{} {}", X, Y); | ^ referenced constant has errors - | - = 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 #71800 error: aborting due to 2 previous errors; 4 warnings emitted diff --git a/src/test/ui/consts/const-eval/issue-49296.rs b/src/test/ui/consts/const-eval/issue-49296.rs index 9fd9e8f36472d..c6caeeffd22dd 100644 --- a/src/test/ui/consts/const-eval/issue-49296.rs +++ b/src/test/ui/consts/const-eval/issue-49296.rs @@ -18,7 +18,6 @@ const fn wat(x: u64) -> &'static u64 { } const X: u64 = *wat(42); //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out fn main() { println!("{}", X); diff --git a/src/test/ui/consts/const-eval/issue-49296.stderr b/src/test/ui/consts/const-eval/issue-49296.stderr index 0389471edb57c..9363ffbb996e4 100644 --- a/src/test/ui/consts/const-eval/issue-49296.stderr +++ b/src/test/ui/consts/const-eval/issue-49296.stderr @@ -7,8 +7,6 @@ LL | const X: u64 = *wat(42); | pointer to alloc1 was dereferenced after this allocation got freed | = note: `#[deny(const_err)]` 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 #71800 error: aborting due to previous error diff --git a/src/test/ui/consts/const-eval/issue-50814-2.rs b/src/test/ui/consts/const-eval/issue-50814-2.rs index 15f4de0ae1b67..8f5c8f097a2ca 100644 --- a/src/test/ui/consts/const-eval/issue-50814-2.rs +++ b/src/test/ui/consts/const-eval/issue-50814-2.rs @@ -12,7 +12,6 @@ struct A(T); impl Foo for A { const BAR: usize = [5, 6, 7][T::BOO]; //~ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out } fn foo() -> &'static usize { diff --git a/src/test/ui/consts/const-eval/issue-50814-2.stderr b/src/test/ui/consts/const-eval/issue-50814-2.stderr index 0c52016549676..f929f500cf9fb 100644 --- a/src/test/ui/consts/const-eval/issue-50814-2.stderr +++ b/src/test/ui/consts/const-eval/issue-50814-2.stderr @@ -7,11 +7,9 @@ LL | const BAR: usize = [5, 6, 7][T::BOO]; | index out of bounds: the length is 3 but the index is 42 | = note: `#[deny(const_err)]` 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 #71800 error[E0080]: evaluation of constant value failed - --> $DIR/issue-50814-2.rs:19:6 + --> $DIR/issue-50814-2.rs:18:6 | LL | & as Foo>::BAR | ^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors diff --git a/src/test/ui/consts/const-eval/issue-50814.rs b/src/test/ui/consts/const-eval/issue-50814.rs index 98229f919dd13..5c3635e4650cd 100644 --- a/src/test/ui/consts/const-eval/issue-50814.rs +++ b/src/test/ui/consts/const-eval/issue-50814.rs @@ -14,7 +14,6 @@ struct Sum(A,B); impl Unsigned for Sum { const MAX: u8 = A::MAX + B::MAX; //~^ ERROR any use of this value will cause an error [const_err] - //~| WARN this was previously accepted by the compiler but is being phased out } fn foo(_: T) -> &'static u8 { diff --git a/src/test/ui/consts/const-eval/issue-50814.stderr b/src/test/ui/consts/const-eval/issue-50814.stderr index cf82d1eef3e45..307fb3c8c9de1 100644 --- a/src/test/ui/consts/const-eval/issue-50814.stderr +++ b/src/test/ui/consts/const-eval/issue-50814.stderr @@ -7,11 +7,9 @@ LL | const MAX: u8 = A::MAX + B::MAX; | attempt to compute `u8::MAX + u8::MAX`, which would overflow | = note: `#[deny(const_err)]` 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 #71800 error[E0080]: evaluation of constant value failed - --> $DIR/issue-50814.rs:21:6 + --> $DIR/issue-50814.rs:20:6 | LL | &Sum::::MAX | ^^^^^^^^^^^^^^^^^ referenced constant has errors diff --git a/src/test/ui/consts/const-eval/panic-assoc-never-type.rs b/src/test/ui/consts/const-eval/panic-assoc-never-type.rs index f76440298b3ca..21ee64fa6d937 100644 --- a/src/test/ui/consts/const-eval/panic-assoc-never-type.rs +++ b/src/test/ui/consts/const-eval/panic-assoc-never-type.rs @@ -10,7 +10,6 @@ struct PrintName; impl PrintName { const VOID: ! = panic!(); //~^ WARN any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out } fn main() { diff --git a/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr b/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr index 28a3ebede5038..979f4a5904d1c 100644 --- a/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr +++ b/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr @@ -11,12 +11,10 @@ note: the lint level is defined here | LL | #![warn(const_err)] | ^^^^^^^^^ - = 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 #71800 = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: erroneous constant used - --> $DIR/panic-assoc-never-type.rs:17:13 + --> $DIR/panic-assoc-never-type.rs:16:13 | LL | let _ = PrintName::VOID; | ^^^^^^^^^^^^^^^ referenced constant has errors diff --git a/src/test/ui/consts/const-eval/panic-never-type.rs b/src/test/ui/consts/const-eval/panic-never-type.rs index c5139c575b15f..3b28b2fdd247e 100644 --- a/src/test/ui/consts/const-eval/panic-never-type.rs +++ b/src/test/ui/consts/const-eval/panic-never-type.rs @@ -7,7 +7,6 @@ const VOID: ! = panic!(); //~^ WARN any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out fn main() { let _ = VOID; diff --git a/src/test/ui/consts/const-eval/panic-never-type.stderr b/src/test/ui/consts/const-eval/panic-never-type.stderr index 8f67dd6a8ba42..af68a2ff44211 100644 --- a/src/test/ui/consts/const-eval/panic-never-type.stderr +++ b/src/test/ui/consts/const-eval/panic-never-type.stderr @@ -11,12 +11,10 @@ note: the lint level is defined here | LL | #![warn(const_err)] | ^^^^^^^^^ - = 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 #71800 = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: erroneous constant used - --> $DIR/panic-never-type.rs:13:13 + --> $DIR/panic-never-type.rs:12:13 | LL | let _ = VOID; | ^^^^ referenced constant has errors diff --git a/src/test/ui/consts/const-eval/promoted_errors.noopt.stderr b/src/test/ui/consts/const-eval/promoted_errors.noopt.stderr index 6f266801bdb4a..1cd1be5309b90 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.noopt.stderr +++ b/src/test/ui/consts/const-eval/promoted_errors.noopt.stderr @@ -6,12 +6,12 @@ LL | 0 - 1 | | | attempt to compute `0_u32 - 1_u32`, which would overflow | inside `overflow` at $DIR/promoted_errors.rs:13:5 - | inside `X` at $DIR/promoted_errors.rs:33:29 + | inside `X` at $DIR/promoted_errors.rs:31:29 ... LL | / const X: () = { LL | | let _x: &'static u32 = &overflow(); LL | | -LL | | +LL | | let _x: &'static i32 = &div_by_zero1(); ... | LL | | let _x: &'static i32 = &oob(); LL | | }; @@ -22,24 +22,19 @@ note: the lint level is defined here | LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] | ^^^^^^^^^ - = 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 #71800 warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:33:28 + --> $DIR/promoted_errors.rs:31:28 | LL | / const X: () = { LL | | let _x: &'static u32 = &overflow(); | | ^^^^^^^^^^^ referenced constant has errors LL | | -LL | | +LL | | let _x: &'static i32 = &div_by_zero1(); ... | LL | | let _x: &'static i32 = &oob(); LL | | }; | |__- - | - = 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 #71800 warning: 2 warnings emitted diff --git a/src/test/ui/consts/const-eval/promoted_errors.opt.stderr b/src/test/ui/consts/const-eval/promoted_errors.opt.stderr index 892f57bfdfc1b..ca62e21b61385 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.opt.stderr +++ b/src/test/ui/consts/const-eval/promoted_errors.opt.stderr @@ -1,17 +1,17 @@ warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:18:5 + --> $DIR/promoted_errors.rs:17:5 | LL | 1 / 0 | ^^^^^ | | | attempt to divide `1_i32` by zero - | inside `div_by_zero1` at $DIR/promoted_errors.rs:18:5 - | inside `X` at $DIR/promoted_errors.rs:36:29 + | inside `div_by_zero1` at $DIR/promoted_errors.rs:17:5 + | inside `X` at $DIR/promoted_errors.rs:33:29 ... LL | / const X: () = { LL | | let _x: &'static u32 = &overflow(); LL | | -LL | | +LL | | let _x: &'static i32 = &div_by_zero1(); ... | LL | | let _x: &'static i32 = &oob(); LL | | }; @@ -22,25 +22,19 @@ note: the lint level is defined here | LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] | ^^^^^^^^^ - = 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 #71800 warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:36:28 + --> $DIR/promoted_errors.rs:33:28 | LL | / const X: () = { LL | | let _x: &'static u32 = &overflow(); LL | | -LL | | LL | | let _x: &'static i32 = &div_by_zero1(); | | ^^^^^^^^^^^^^^^ referenced constant has errors ... | LL | | let _x: &'static i32 = &oob(); LL | | }; | |__- - | - = 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 #71800 warning: 2 warnings emitted diff --git a/src/test/ui/consts/const-eval/promoted_errors.opt_with_overflow_checks.stderr b/src/test/ui/consts/const-eval/promoted_errors.opt_with_overflow_checks.stderr index 6f266801bdb4a..1cd1be5309b90 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.opt_with_overflow_checks.stderr +++ b/src/test/ui/consts/const-eval/promoted_errors.opt_with_overflow_checks.stderr @@ -6,12 +6,12 @@ LL | 0 - 1 | | | attempt to compute `0_u32 - 1_u32`, which would overflow | inside `overflow` at $DIR/promoted_errors.rs:13:5 - | inside `X` at $DIR/promoted_errors.rs:33:29 + | inside `X` at $DIR/promoted_errors.rs:31:29 ... LL | / const X: () = { LL | | let _x: &'static u32 = &overflow(); LL | | -LL | | +LL | | let _x: &'static i32 = &div_by_zero1(); ... | LL | | let _x: &'static i32 = &oob(); LL | | }; @@ -22,24 +22,19 @@ note: the lint level is defined here | LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] | ^^^^^^^^^ - = 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 #71800 warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:33:28 + --> $DIR/promoted_errors.rs:31:28 | LL | / const X: () = { LL | | let _x: &'static u32 = &overflow(); | | ^^^^^^^^^^^ referenced constant has errors LL | | -LL | | +LL | | let _x: &'static i32 = &div_by_zero1(); ... | LL | | let _x: &'static i32 = &oob(); LL | | }; | |__- - | - = 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 #71800 warning: 2 warnings emitted diff --git a/src/test/ui/consts/const-eval/promoted_errors.rs b/src/test/ui/consts/const-eval/promoted_errors.rs index 7840f67c216c0..a2136c8d09be4 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.rs +++ b/src/test/ui/consts/const-eval/promoted_errors.rs @@ -12,33 +12,30 @@ const fn overflow() -> u32 { 0 - 1 //[opt_with_overflow_checks,noopt]~^ WARN any use of this value will cause an error - //[opt_with_overflow_checks,noopt]~| WARN this was previously accepted by the compiler } const fn div_by_zero1() -> i32 { 1 / 0 //[opt]~^ WARN any use of this value will cause an error - //[opt]~| WARN this was previously accepted by the compiler but is being phased out } const fn div_by_zero2() -> i32 { - 1 / (1 - 1) + 1 / (1-1) } const fn div_by_zero3() -> i32 { 1 / (false as i32) } const fn oob() -> i32 { - [1, 2, 3][4] + [1,2,3][4] } const X: () = { let _x: &'static u32 = &overflow(); //[opt_with_overflow_checks,noopt]~^ WARN any use of this value will cause an error - //[opt_with_overflow_checks,noopt]~| WARN this was previously accepted by the compiler let _x: &'static i32 = &div_by_zero1(); //[opt]~^ WARN any use of this value will cause an error - //[opt]~| WARN this was previously accepted by the compiler but is being phased out let _x: &'static i32 = &div_by_zero2(); let _x: &'static i32 = &div_by_zero3(); let _x: &'static i32 = &oob(); }; -fn main() {} +fn main() { +} diff --git a/src/test/ui/consts/const-eval/pub_const_err.rs b/src/test/ui/consts/const-eval/pub_const_err.rs index 5faacd556d479..ad165d40a76f2 100644 --- a/src/test/ui/consts/const-eval/pub_const_err.rs +++ b/src/test/ui/consts/const-eval/pub_const_err.rs @@ -5,6 +5,5 @@ pub const Z: u32 = 0 - 1; //~^ WARN any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out pub type Foo = [i32; 0 - 1]; diff --git a/src/test/ui/consts/const-eval/pub_const_err.stderr b/src/test/ui/consts/const-eval/pub_const_err.stderr index dd47dca2b2e40..5be0fd96723dd 100644 --- a/src/test/ui/consts/const-eval/pub_const_err.stderr +++ b/src/test/ui/consts/const-eval/pub_const_err.stderr @@ -11,8 +11,6 @@ note: the lint level is defined here | LL | #![warn(const_err)] | ^^^^^^^^^ - = 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 #71800 warning: 1 warning emitted diff --git a/src/test/ui/consts/const-eval/pub_const_err_bin.rs b/src/test/ui/consts/const-eval/pub_const_err_bin.rs index 82eae25121e41..078e4c896df80 100644 --- a/src/test/ui/consts/const-eval/pub_const_err_bin.rs +++ b/src/test/ui/consts/const-eval/pub_const_err_bin.rs @@ -3,7 +3,6 @@ pub const Z: u32 = 0 - 1; //~^ WARN any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out pub type Foo = [i32; 0 - 1]; diff --git a/src/test/ui/consts/const-eval/pub_const_err_bin.stderr b/src/test/ui/consts/const-eval/pub_const_err_bin.stderr index 9f413fb8fd770..55f8a58ea9470 100644 --- a/src/test/ui/consts/const-eval/pub_const_err_bin.stderr +++ b/src/test/ui/consts/const-eval/pub_const_err_bin.stderr @@ -11,8 +11,6 @@ note: the lint level is defined here | LL | #![warn(const_err)] | ^^^^^^^^^ - = 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 #71800 warning: 1 warning emitted diff --git a/src/test/ui/consts/const-eval/simd/insert_extract.rs b/src/test/ui/consts/const-eval/simd/insert_extract.rs index 9e5cb0d4eb1f8..92231d4ced321 100644 --- a/src/test/ui/consts/const-eval/simd/insert_extract.rs +++ b/src/test/ui/consts/const-eval/simd/insert_extract.rs @@ -8,7 +8,7 @@ #[repr(simd)] struct i8x1(i8); #[repr(simd)] struct u16x2(u16, u16); -#[repr(simd)] struct f32x4(f32, f32, f32, f32); +#[repr(simd)] struct f32x3(f32, f32, f32); extern "platform-intrinsic" { #[rustc_const_stable(feature = "foo", since = "1.3.37")] @@ -39,23 +39,19 @@ fn main() { assert_eq!(Y1, 42); } { - const U: f32x4 = f32x4(13., 14., 15., 16.); - const V: f32x4 = unsafe { simd_insert(U, 1_u32, 42_f32) }; + const U: f32x3 = f32x3(13., 14., 15.); + const V: f32x3 = unsafe { simd_insert(U, 1_u32, 42_f32) }; const X0: f32 = V.0; const X1: f32 = V.1; const X2: f32 = V.2; - const X3: f32 = V.3; const Y0: f32 = unsafe { simd_extract(V, 0) }; const Y1: f32 = unsafe { simd_extract(V, 1) }; const Y2: f32 = unsafe { simd_extract(V, 2) }; - const Y3: f32 = unsafe { simd_extract(V, 3) }; assert_eq!(X0, 13.); assert_eq!(X1, 42.); assert_eq!(X2, 15.); - assert_eq!(X3, 16.); assert_eq!(Y0, 13.); assert_eq!(Y1, 42.); assert_eq!(Y2, 15.); - assert_eq!(Y3, 16.); } } diff --git a/src/test/ui/consts/const-eval/ub-nonnull.rs b/src/test/ui/consts/const-eval/ub-nonnull.rs index e4ced600b4cc4..4b90b892dce9a 100644 --- a/src/test/ui/consts/const-eval/ub-nonnull.rs +++ b/src/test/ui/consts/const-eval/ub-nonnull.rs @@ -16,7 +16,6 @@ const OUT_OF_BOUNDS_PTR: NonNull = { unsafe { let ptr: &[u8; 256] = mem::transmute(&0u8); // &0 gets promoted so it does not dangle // Use address-of-element for pointer arithmetic. This could wrap around to NULL! let out_of_bounds_ptr = &ptr[255]; //~ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out mem::transmute(out_of_bounds_ptr) } }; diff --git a/src/test/ui/consts/const-eval/ub-nonnull.stderr b/src/test/ui/consts/const-eval/ub-nonnull.stderr index 94496b77fe773..39a568d054af4 100644 --- a/src/test/ui/consts/const-eval/ub-nonnull.stderr +++ b/src/test/ui/consts/const-eval/ub-nonnull.stderr @@ -14,7 +14,6 @@ LL | | let ptr: &[u8; 256] = mem::transmute(&0u8); // &0 gets promoted so it LL | | // Use address-of-element for pointer arithmetic. This could wrap around to NULL! LL | | let out_of_bounds_ptr = &ptr[255]; | | ^^^^^^^^ memory access failed: pointer must be in-bounds at offset 256, but is outside bounds of alloc10 which has size 1 -LL | | LL | | mem::transmute(out_of_bounds_ptr) LL | | } }; | |____- @@ -24,11 +23,9 @@ note: the lint level is defined here | LL | #[deny(const_err)] // this triggers a `const_err` so validation does not even happen | ^^^^^^^^^ - = 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 #71800 error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:23:1 + --> $DIR/ub-nonnull.rs:22:1 | LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0, but expected something greater or equal to 1 @@ -36,7 +33,7 @@ LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) }; = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:25:1 + --> $DIR/ub-nonnull.rs:24:1 | LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0, but expected something greater or equal to 1 @@ -44,7 +41,7 @@ LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) }; = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:33:1 + --> $DIR/ub-nonnull.rs:32:1 | LL | const UNINIT: NonZeroU8 = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes at .0, but expected initialized plain (non-pointer) bytes @@ -52,7 +49,7 @@ LL | const UNINIT: NonZeroU8 = unsafe { MaybeUninit { uninit: () }.init }; = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:41:1 + --> $DIR/ub-nonnull.rs:40:1 | LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 42, but expected something in the range 10..=30 @@ -60,7 +57,7 @@ LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:47:1 + --> $DIR/ub-nonnull.rs:46:1 | LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 20, but expected something less or equal to 10, or greater or equal to 30 diff --git a/src/test/ui/consts/const-eval/unused-broken-const.rs b/src/test/ui/consts/const-eval/unused-broken-const.rs index 3b4523681002e..56b16e224e5ad 100644 --- a/src/test/ui/consts/const-eval/unused-broken-const.rs +++ b/src/test/ui/consts/const-eval/unused-broken-const.rs @@ -4,6 +4,5 @@ const FOO: i32 = [][0]; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out fn main() {} diff --git a/src/test/ui/consts/const-eval/unused-broken-const.stderr b/src/test/ui/consts/const-eval/unused-broken-const.stderr index 2ce60ec16a33f..0cb13790f2f53 100644 --- a/src/test/ui/consts/const-eval/unused-broken-const.stderr +++ b/src/test/ui/consts/const-eval/unused-broken-const.stderr @@ -7,8 +7,6 @@ LL | const FOO: i32 = [][0]; | index out of bounds: the length is 0 but the index is 0 | = note: `#[deny(const_err)]` 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 #71800 error: aborting due to previous error diff --git a/src/test/ui/consts/const-eval/unwind-abort.rs b/src/test/ui/consts/const-eval/unwind-abort.rs index 10820986fa7d3..2dc8e14bed545 100644 --- a/src/test/ui/consts/const-eval/unwind-abort.rs +++ b/src/test/ui/consts/const-eval/unwind-abort.rs @@ -3,7 +3,6 @@ #[unwind(aborts)] const fn foo() { panic!() //~ ERROR any use of this value will cause an error [const_err] - //~| WARN this was previously accepted by the compiler but is being phased out } const _: () = foo(); diff --git a/src/test/ui/consts/const-eval/unwind-abort.stderr b/src/test/ui/consts/const-eval/unwind-abort.stderr index f13f2bfe9b110..8a90fdfc5751b 100644 --- a/src/test/ui/consts/const-eval/unwind-abort.stderr +++ b/src/test/ui/consts/const-eval/unwind-abort.stderr @@ -6,14 +6,12 @@ LL | panic!() | | | the evaluated program panicked at 'explicit panic', $DIR/unwind-abort.rs:5:5 | inside `foo` at $SRC_DIR/std/src/panic.rs:LL:COL - | inside `_` at $DIR/unwind-abort.rs:9:15 + | inside `_` at $DIR/unwind-abort.rs:8:15 ... LL | const _: () = foo(); | -------------------- | = note: `#[deny(const_err)]` 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.rs b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.rs index 4e1c71cd60013..48a989bf58863 100644 --- a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.rs +++ b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.rs @@ -5,7 +5,6 @@ const fn foo() -> ! { unsafe { std::mem::transmute(()) } //~^ WARN any use of this value will cause an error [const_err] //~| WARN the type `!` does not permit zero-initialization [invalid_value] - //~| WARN this was previously accepted by the compiler but is being phased out } #[derive(Clone, Copy)] diff --git a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.stderr b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.stderr index 3f22fac11f65d..2adff5fc7d408 100644 --- a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.stderr +++ b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.stderr @@ -6,21 +6,19 @@ LL | unsafe { std::mem::transmute(()) } | | | transmuting to uninhabited type | inside `foo` at $DIR/validate_uninhabited_zsts.rs:5:14 - | inside `FOO` at $DIR/validate_uninhabited_zsts.rs:15:26 + | inside `FOO` at $DIR/validate_uninhabited_zsts.rs:14:26 ... LL | const FOO: [Empty; 3] = [foo(); 3]; | ----------------------------------- | note: the lint level is defined here - --> $DIR/validate_uninhabited_zsts.rs:14:8 + --> $DIR/validate_uninhabited_zsts.rs:13:8 | LL | #[warn(const_err)] | ^^^^^^^^^ - = 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 #71800 error[E0080]: it is undefined behavior to use this value - --> $DIR/validate_uninhabited_zsts.rs:18:1 + --> $DIR/validate_uninhabited_zsts.rs:17:1 | LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of uninhabited type Empty at [0] @@ -40,7 +38,7 @@ LL | unsafe { std::mem::transmute(()) } = note: the `!` type has no valid value warning: the type `Empty` does not permit zero-initialization - --> $DIR/validate_uninhabited_zsts.rs:18:35 + --> $DIR/validate_uninhabited_zsts.rs:17:35 | LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/consts/const-external-macro-const-err.rs b/src/test/ui/consts/const-external-macro-const-err.rs index 440c42e32ef39..616d24f4a7bcf 100644 --- a/src/test/ui/consts/const-external-macro-const-err.rs +++ b/src/test/ui/consts/const-external-macro-const-err.rs @@ -10,5 +10,4 @@ use external_macro::static_assert; fn main() { static_assert!(2 + 2 == 5); //~ ERROR - //~| WARN this was previously accepted by the compiler but is being phased out } diff --git a/src/test/ui/consts/const-external-macro-const-err.stderr b/src/test/ui/consts/const-external-macro-const-err.stderr index 21fdffa115b83..350e4b24de100 100644 --- a/src/test/ui/consts/const-external-macro-const-err.stderr +++ b/src/test/ui/consts/const-external-macro-const-err.stderr @@ -5,8 +5,6 @@ LL | static_assert!(2 + 2 == 5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 1 | = note: `#[deny(const_err)]` 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/consts/const-int-arithmetic.rs b/src/test/ui/consts/const-int-arithmetic.rs index b9096648f9235..e0d722ede94e3 100644 --- a/src/test/ui/consts/const-int-arithmetic.rs +++ b/src/test/ui/consts/const-int-arithmetic.rs @@ -1,5 +1,10 @@ // run-pass +#![feature(const_checked_int_methods)] +#![feature(const_euclidean_int_methods)] +#![feature(const_overflowing_int_methods)] +#![feature(const_wrapping_int_methods)] + macro_rules! suite { ($( $fn:ident -> $ty:ty { $( $label:ident : $expr:expr, $result:expr; )* } diff --git a/src/test/ui/consts/const-int-unchecked.rs b/src/test/ui/consts/const-int-unchecked.rs index 41d8f7a0972bc..1596093b2c14b 100644 --- a/src/test/ui/consts/const-int-unchecked.rs +++ b/src/test/ui/consts/const-int-unchecked.rs @@ -14,74 +14,54 @@ use std::intrinsics; const SHL_U8: u8 = unsafe { intrinsics::unchecked_shl(5_u8, 8) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHL_U16: u16 = unsafe { intrinsics::unchecked_shl(5_u16, 16) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHL_U32: u32 = unsafe { intrinsics::unchecked_shl(5_u32, 32) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHL_U64: u64 = unsafe { intrinsics::unchecked_shl(5_u64, 64) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHL_U128: u128 = unsafe { intrinsics::unchecked_shl(5_u128, 128) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out // signed types: const SHL_I8: i8 = unsafe { intrinsics::unchecked_shl(5_i8, 8) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHL_I16: i16 = unsafe { intrinsics::unchecked_shl(5_16, 16) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHL_I32: i32 = unsafe { intrinsics::unchecked_shl(5_i32, 32) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHL_I64: i64 = unsafe { intrinsics::unchecked_shl(5_i64, 64) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHL_I128: i128 = unsafe { intrinsics::unchecked_shl(5_i128, 128) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out // and make sure we capture y < 0: const SHL_I8_NEG: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -1) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHL_I16_NEG: i16 = unsafe { intrinsics::unchecked_shl(5_16, -1) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHL_I32_NEG: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -1) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHL_I64_NEG: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -1) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHL_I128_NEG: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -1) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out // and that there's no special relation to the value -1 by picking some // negative values at random: const SHL_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -6) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHL_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shl(5_16, -13) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHL_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -25) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHL_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -30) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHL_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -93) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out // Repeat it all over for `unchecked_shr` @@ -89,101 +69,74 @@ const SHL_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -93 const SHR_U8: u8 = unsafe { intrinsics::unchecked_shr(5_u8, 8) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHR_U16: u16 = unsafe { intrinsics::unchecked_shr(5_u16, 16) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHR_U32: u32 = unsafe { intrinsics::unchecked_shr(5_u32, 32) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHR_U64: u64 = unsafe { intrinsics::unchecked_shr(5_u64, 64) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHR_U128: u128 = unsafe { intrinsics::unchecked_shr(5_u128, 128) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out // signed types: const SHR_I8: i8 = unsafe { intrinsics::unchecked_shr(5_i8, 8) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHR_I16: i16 = unsafe { intrinsics::unchecked_shr(5_16, 16) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHR_I32: i32 = unsafe { intrinsics::unchecked_shr(5_i32, 32) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHR_I64: i64 = unsafe { intrinsics::unchecked_shr(5_i64, 64) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHR_I128: i128 = unsafe { intrinsics::unchecked_shr(5_i128, 128) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out // and make sure we capture y < 0: const SHR_I8_NEG: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -1) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHR_I16_NEG: i16 = unsafe { intrinsics::unchecked_shr(5_16, -1) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHR_I32_NEG: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -1) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHR_I64_NEG: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -1) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHR_I128_NEG: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -1) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out // and that there's no special relation to the value -1 by picking some // negative values at random: const SHR_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -6) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHR_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shr(5_16, -13) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHR_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -25) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHR_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -30) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const SHR_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -93) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out // Other arithmetic functions: const _: u16 = unsafe { std::intrinsics::unchecked_add(40000u16, 30000) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const _: u32 = unsafe { std::intrinsics::unchecked_sub(14u32, 22) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const _: u16 = unsafe { std::intrinsics::unchecked_mul(300u16, 250u16) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const _: i32 = unsafe { std::intrinsics::unchecked_div(1, 0) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const _: i32 = unsafe { std::intrinsics::unchecked_div(i32::MIN, -1) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const _: i32 = unsafe { std::intrinsics::unchecked_rem(1, 0) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out const _: i32 = unsafe { std::intrinsics::unchecked_rem(i32::MIN, -1) }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out fn main() {} diff --git a/src/test/ui/consts/const-int-unchecked.stderr b/src/test/ui/consts/const-int-unchecked.stderr index e5ecbbc71a7f6..0287b404e7d46 100644 --- a/src/test/ui/consts/const-int-unchecked.stderr +++ b/src/test/ui/consts/const-int-unchecked.stderr @@ -7,514 +7,374 @@ LL | const SHL_U8: u8 = unsafe { intrinsics::unchecked_shl(5_u8, 8) }; | overflowing shift by 8 in `unchecked_shl` | = note: `#[deny(const_err)]` 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:18:31 + --> $DIR/const-int-unchecked.rs:17:31 | LL | const SHL_U16: u16 = unsafe { intrinsics::unchecked_shl(5_u16, 16) }; | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 16 in `unchecked_shl` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:21:31 + --> $DIR/const-int-unchecked.rs:19:31 | LL | const SHL_U32: u32 = unsafe { intrinsics::unchecked_shl(5_u32, 32) }; | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 32 in `unchecked_shl` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:24:31 + --> $DIR/const-int-unchecked.rs:21:31 | LL | const SHL_U64: u64 = unsafe { intrinsics::unchecked_shl(5_u64, 64) }; | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 64 in `unchecked_shl` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:27:33 + --> $DIR/const-int-unchecked.rs:23:33 | LL | const SHL_U128: u128 = unsafe { intrinsics::unchecked_shl(5_u128, 128) }; | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 128 in `unchecked_shl` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:33:29 + --> $DIR/const-int-unchecked.rs:28:29 | LL | const SHL_I8: i8 = unsafe { intrinsics::unchecked_shl(5_i8, 8) }; | ----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 8 in `unchecked_shl` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:36:31 + --> $DIR/const-int-unchecked.rs:30:31 | LL | const SHL_I16: i16 = unsafe { intrinsics::unchecked_shl(5_16, 16) }; | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 16 in `unchecked_shl` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:39:31 + --> $DIR/const-int-unchecked.rs:32:31 | LL | const SHL_I32: i32 = unsafe { intrinsics::unchecked_shl(5_i32, 32) }; | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 32 in `unchecked_shl` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:42:31 + --> $DIR/const-int-unchecked.rs:34:31 | LL | const SHL_I64: i64 = unsafe { intrinsics::unchecked_shl(5_i64, 64) }; | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 64 in `unchecked_shl` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:45:33 + --> $DIR/const-int-unchecked.rs:36:33 | LL | const SHL_I128: i128 = unsafe { intrinsics::unchecked_shl(5_i128, 128) }; | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 128 in `unchecked_shl` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:51:33 + --> $DIR/const-int-unchecked.rs:41:33 | LL | const SHL_I8_NEG: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -1) }; | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 255 in `unchecked_shl` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:54:35 + --> $DIR/const-int-unchecked.rs:43:35 | LL | const SHL_I16_NEG: i16 = unsafe { intrinsics::unchecked_shl(5_16, -1) }; | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 65535 in `unchecked_shl` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:57:35 + --> $DIR/const-int-unchecked.rs:45:35 | LL | const SHL_I32_NEG: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -1) }; | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 4294967295 in `unchecked_shl` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:60:35 + --> $DIR/const-int-unchecked.rs:47:35 | LL | const SHL_I64_NEG: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -1) }; | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 18446744073709551615 in `unchecked_shl` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:63:37 + --> $DIR/const-int-unchecked.rs:49:37 | LL | const SHL_I128_NEG: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -1) }; | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 340282366920938463463374607431768211455 in `unchecked_shl` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:70:40 + --> $DIR/const-int-unchecked.rs:55:40 | LL | const SHL_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -6) }; | ---------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 250 in `unchecked_shl` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:73:42 + --> $DIR/const-int-unchecked.rs:57:42 | LL | const SHL_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shl(5_16, -13) }; | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 65523 in `unchecked_shl` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:76:42 + --> $DIR/const-int-unchecked.rs:59:42 | LL | const SHL_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -25) }; | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 4294967271 in `unchecked_shl` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:79:42 + --> $DIR/const-int-unchecked.rs:61:42 | LL | const SHL_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -30) }; | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 18446744073709551586 in `unchecked_shl` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:82:44 + --> $DIR/const-int-unchecked.rs:63:44 | LL | const SHL_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -93) }; | -------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 340282366920938463463374607431768211363 in `unchecked_shl` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:90:29 + --> $DIR/const-int-unchecked.rs:70:29 | LL | const SHR_U8: u8 = unsafe { intrinsics::unchecked_shr(5_u8, 8) }; | ----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 8 in `unchecked_shr` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:93:31 + --> $DIR/const-int-unchecked.rs:72:31 | LL | const SHR_U16: u16 = unsafe { intrinsics::unchecked_shr(5_u16, 16) }; | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 16 in `unchecked_shr` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:96:31 + --> $DIR/const-int-unchecked.rs:74:31 | LL | const SHR_U32: u32 = unsafe { intrinsics::unchecked_shr(5_u32, 32) }; | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 32 in `unchecked_shr` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:99:31 + --> $DIR/const-int-unchecked.rs:76:31 | LL | const SHR_U64: u64 = unsafe { intrinsics::unchecked_shr(5_u64, 64) }; | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 64 in `unchecked_shr` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:102:33 + --> $DIR/const-int-unchecked.rs:78:33 | LL | const SHR_U128: u128 = unsafe { intrinsics::unchecked_shr(5_u128, 128) }; | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 128 in `unchecked_shr` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:108:29 + --> $DIR/const-int-unchecked.rs:83:29 | LL | const SHR_I8: i8 = unsafe { intrinsics::unchecked_shr(5_i8, 8) }; | ----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 8 in `unchecked_shr` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:111:31 + --> $DIR/const-int-unchecked.rs:85:31 | LL | const SHR_I16: i16 = unsafe { intrinsics::unchecked_shr(5_16, 16) }; | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 16 in `unchecked_shr` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:114:31 + --> $DIR/const-int-unchecked.rs:87:31 | LL | const SHR_I32: i32 = unsafe { intrinsics::unchecked_shr(5_i32, 32) }; | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 32 in `unchecked_shr` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:117:31 + --> $DIR/const-int-unchecked.rs:89:31 | LL | const SHR_I64: i64 = unsafe { intrinsics::unchecked_shr(5_i64, 64) }; | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 64 in `unchecked_shr` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:120:33 + --> $DIR/const-int-unchecked.rs:91:33 | LL | const SHR_I128: i128 = unsafe { intrinsics::unchecked_shr(5_i128, 128) }; | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 128 in `unchecked_shr` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:126:33 + --> $DIR/const-int-unchecked.rs:96:33 | LL | const SHR_I8_NEG: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -1) }; | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 255 in `unchecked_shr` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:129:35 + --> $DIR/const-int-unchecked.rs:98:35 | LL | const SHR_I16_NEG: i16 = unsafe { intrinsics::unchecked_shr(5_16, -1) }; | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 65535 in `unchecked_shr` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:132:35 + --> $DIR/const-int-unchecked.rs:100:35 | LL | const SHR_I32_NEG: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -1) }; | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 4294967295 in `unchecked_shr` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:135:35 + --> $DIR/const-int-unchecked.rs:102:35 | LL | const SHR_I64_NEG: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -1) }; | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 18446744073709551615 in `unchecked_shr` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:138:37 + --> $DIR/const-int-unchecked.rs:104:37 | LL | const SHR_I128_NEG: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -1) }; | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 340282366920938463463374607431768211455 in `unchecked_shr` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:145:40 + --> $DIR/const-int-unchecked.rs:110:40 | LL | const SHR_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -6) }; | ---------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 250 in `unchecked_shr` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:148:42 + --> $DIR/const-int-unchecked.rs:112:42 | LL | const SHR_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shr(5_16, -13) }; | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 65523 in `unchecked_shr` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:151:42 + --> $DIR/const-int-unchecked.rs:114:42 | LL | const SHR_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -25) }; | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 4294967271 in `unchecked_shr` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:154:42 + --> $DIR/const-int-unchecked.rs:116:42 | LL | const SHR_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -30) }; | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 18446744073709551586 in `unchecked_shr` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:157:44 + --> $DIR/const-int-unchecked.rs:118:44 | LL | const SHR_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -93) }; | -------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 340282366920938463463374607431768211363 in `unchecked_shr` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:163:25 + --> $DIR/const-int-unchecked.rs:123:25 | LL | const _: u16 = unsafe { std::intrinsics::unchecked_add(40000u16, 30000) }; | ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflow executing `unchecked_add` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:167:25 + --> $DIR/const-int-unchecked.rs:126:25 | LL | const _: u32 = unsafe { std::intrinsics::unchecked_sub(14u32, 22) }; | ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflow executing `unchecked_sub` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:171:25 + --> $DIR/const-int-unchecked.rs:129:25 | LL | const _: u16 = unsafe { std::intrinsics::unchecked_mul(300u16, 250u16) }; | ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflow executing `unchecked_mul` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:175:25 + --> $DIR/const-int-unchecked.rs:132:25 | LL | const _: i32 = unsafe { std::intrinsics::unchecked_div(1, 0) }; | ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | dividing by zero - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:178:25 + --> $DIR/const-int-unchecked.rs:134:25 | LL | const _: i32 = unsafe { std::intrinsics::unchecked_div(i32::MIN, -1) }; | ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflow executing `unchecked_div` - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:182:25 + --> $DIR/const-int-unchecked.rs:137:25 | LL | const _: i32 = unsafe { std::intrinsics::unchecked_rem(1, 0) }; | ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | calculating the remainder with a divisor of zero - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:185:25 + --> $DIR/const-int-unchecked.rs:139:25 | LL | const _: i32 = unsafe { std::intrinsics::unchecked_rem(i32::MIN, -1) }; | ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflow executing `unchecked_rem` - | - = 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 #71800 error: aborting due to 47 previous errors diff --git a/src/test/ui/consts/const-len-underflow-separate-spans.rs b/src/test/ui/consts/const-len-underflow-separate-spans.rs index 7c3d1f320f2f6..01d2951b41613 100644 --- a/src/test/ui/consts/const-len-underflow-separate-spans.rs +++ b/src/test/ui/consts/const-len-underflow-separate-spans.rs @@ -6,7 +6,6 @@ const ONE: usize = 1; const TWO: usize = 2; const LEN: usize = ONE - TWO; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out fn main() { let a: [i8; LEN] = unimplemented!(); diff --git a/src/test/ui/consts/const-len-underflow-separate-spans.stderr b/src/test/ui/consts/const-len-underflow-separate-spans.stderr index 70f645a6c40e8..2ab6d0ffdef4c 100644 --- a/src/test/ui/consts/const-len-underflow-separate-spans.stderr +++ b/src/test/ui/consts/const-len-underflow-separate-spans.stderr @@ -7,11 +7,9 @@ LL | const LEN: usize = ONE - TWO; | attempt to compute `1_usize - 2_usize`, which would overflow | = note: `#[deny(const_err)]` 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 #71800 error[E0080]: evaluation of constant value failed - --> $DIR/const-len-underflow-separate-spans.rs:12:17 + --> $DIR/const-len-underflow-separate-spans.rs:11:17 | LL | let a: [i8; LEN] = unimplemented!(); | ^^^ referenced constant has errors diff --git a/src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs b/src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs index 90977efd2b454..1e856ec0a0acc 100644 --- a/src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs +++ b/src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs @@ -13,7 +13,6 @@ const fn helper() -> Option<&'static mut i32> { unsafe { // Undefined behaviour (integer as pointer), who doesn't love tests like this. // This code never gets executed, because the static checks fail before that. Some(&mut *(42 as *mut i32)) //~ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out } } // The error is an evaluation error and not a validation error, so the error is reported // directly at the site where it occurs. diff --git a/src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr b/src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr index 45ae055614b57..0bbf84b71bb68 100644 --- a/src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr +++ b/src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr @@ -6,17 +6,15 @@ LL | Some(&mut *(42 as *mut i32)) | | | unable to turn bytes into a pointer | inside `helper` at $DIR/mut_ref_in_final_dynamic_check.rs:15:10 - | inside `A` at $DIR/mut_ref_in_final_dynamic_check.rs:20:29 + | inside `A` at $DIR/mut_ref_in_final_dynamic_check.rs:19:29 ... LL | const A: Option<&mut i32> = helper(); | ------------------------------------- | = note: `#[deny(const_err)]` 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 #71800 error: encountered dangling pointer in final constant - --> $DIR/mut_ref_in_final_dynamic_check.rs:27:1 + --> $DIR/mut_ref_in_final_dynamic_check.rs:26:1 | LL | const B: Option<&mut i32> = helper2(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/consts/const-prop-read-static-in-const.rs b/src/test/ui/consts/const-prop-read-static-in-const.rs index a65b707f012d0..13b1b2d14125b 100644 --- a/src/test/ui/consts/const-prop-read-static-in-const.rs +++ b/src/test/ui/consts/const-prop-read-static-in-const.rs @@ -3,7 +3,6 @@ #![allow(dead_code)] const TEST: u8 = MY_STATIC; //~ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out static MY_STATIC: u8 = 4; diff --git a/src/test/ui/consts/const-prop-read-static-in-const.stderr b/src/test/ui/consts/const-prop-read-static-in-const.stderr index 94d3f1c614544..7a517d1d7b363 100644 --- a/src/test/ui/consts/const-prop-read-static-in-const.stderr +++ b/src/test/ui/consts/const-prop-read-static-in-const.stderr @@ -7,8 +7,6 @@ LL | const TEST: u8 = MY_STATIC; | constant accesses static | = note: `#[deny(const_err)]` 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 #71800 warning: skipping const checks | diff --git a/src/test/ui/consts/const-size_of_val-align_of_val-extern-type.rs b/src/test/ui/consts/const-size_of_val-align_of_val-extern-type.rs index 6653717778ba5..09c7d5580deca 100644 --- a/src/test/ui/consts/const-size_of_val-align_of_val-extern-type.rs +++ b/src/test/ui/consts/const-size_of_val-align_of_val-extern-type.rs @@ -9,8 +9,6 @@ extern "C" { } const _SIZE: usize = unsafe { size_of_val(&4 as *const i32 as *const Opaque) }; //~ ERROR -//~| WARN this was previously accepted by the compiler but is being phased out const _ALIGN: usize = unsafe { min_align_of_val(&4 as *const i32 as *const Opaque) }; //~ ERROR -//~| WARN this was previously accepted by the compiler but is being phased out fn main() {} diff --git a/src/test/ui/consts/const-size_of_val-align_of_val-extern-type.stderr b/src/test/ui/consts/const-size_of_val-align_of_val-extern-type.stderr index a9211c17a6bc0..d3f1b04d25154 100644 --- a/src/test/ui/consts/const-size_of_val-align_of_val-extern-type.stderr +++ b/src/test/ui/consts/const-size_of_val-align_of_val-extern-type.stderr @@ -7,19 +7,14 @@ LL | const _SIZE: usize = unsafe { size_of_val(&4 as *const i32 as *const Opaque | `extern type` does not have known layout | = note: `#[deny(const_err)]` 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 #71800 error: any use of this value will cause an error - --> $DIR/const-size_of_val-align_of_val-extern-type.rs:13:32 + --> $DIR/const-size_of_val-align_of_val-extern-type.rs:12:32 | LL | const _ALIGN: usize = unsafe { min_align_of_val(&4 as *const i32 as *const Opaque) }; | -------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | `extern type` does not have known layout - | - = 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 #71800 error: aborting due to 2 previous errors diff --git a/src/test/ui/consts/const-slice-oob.rs b/src/test/ui/consts/const-slice-oob.rs index 35e5a4d2233fe..70852f8f56929 100644 --- a/src/test/ui/consts/const-slice-oob.rs +++ b/src/test/ui/consts/const-slice-oob.rs @@ -4,7 +4,6 @@ const FOO: &'static[u32] = &[1, 2, 3]; const BAR: u32 = FOO[5]; //~^ index out of bounds: the length is 3 but the index is 5 //~| ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out fn main() { let _ = BAR; diff --git a/src/test/ui/consts/const-slice-oob.stderr b/src/test/ui/consts/const-slice-oob.stderr index 6d2c79034d391..0077bafe9e628 100644 --- a/src/test/ui/consts/const-slice-oob.stderr +++ b/src/test/ui/consts/const-slice-oob.stderr @@ -7,8 +7,6 @@ LL | const BAR: u32 = FOO[5]; | index out of bounds: the length is 3 but the index is 5 | = note: `#[deny(const_err)]` 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 #71800 error: aborting due to previous error diff --git a/src/test/ui/consts/const-unwrap.stderr b/src/test/ui/consts/const-unwrap.stderr index 86c2f1c4f8e13..b2e037c69cb00 100644 --- a/src/test/ui/consts/const-unwrap.stderr +++ b/src/test/ui/consts/const-unwrap.stderr @@ -14,8 +14,6 @@ LL | const BAR: i32 = Option::::None.unwrap(); | ---------------------------------------------- | = note: `#[deny(const_err)]` 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/consts/const_limit/const_eval_limit_reached.rs b/src/test/ui/consts/const_limit/const_eval_limit_reached.rs index 773640b72e6ea..069dac00c9ace 100644 --- a/src/test/ui/consts/const_limit/const_eval_limit_reached.rs +++ b/src/test/ui/consts/const_limit/const_eval_limit_reached.rs @@ -5,7 +5,6 @@ const X: usize = { let mut x = 0; while x != 1000 { //~^ ERROR any use of this value will cause an error - //~| WARN this was previously accepted by the compiler but is being phased out x += 1; } diff --git a/src/test/ui/consts/const_limit/const_eval_limit_reached.stderr b/src/test/ui/consts/const_limit/const_eval_limit_reached.stderr index 10e54e0348cb7..8785c9e54b9bf 100644 --- a/src/test/ui/consts/const_limit/const_eval_limit_reached.stderr +++ b/src/test/ui/consts/const_limit/const_eval_limit_reached.stderr @@ -6,7 +6,6 @@ LL | | let mut x = 0; LL | | while x != 1000 { | |_____^ LL | || -LL | || LL | || x += 1; LL | || } | ||_____^ exceeded interpreter step limit (see `#[const_eval_limit]`) @@ -16,8 +15,6 @@ LL | | }; | |__- | = note: `#[deny(const_err)]` 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 #71800 error: aborting due to previous error diff --git a/src/test/ui/consts/const_unsafe_unreachable_ub.rs b/src/test/ui/consts/const_unsafe_unreachable_ub.rs index 0bd37876cc3f0..11920d852e02f 100644 --- a/src/test/ui/consts/const_unsafe_unreachable_ub.rs +++ b/src/test/ui/consts/const_unsafe_unreachable_ub.rs @@ -17,5 +17,4 @@ fn main() { assert_eq!(BAR, true); //~^ ERROR E0080 //~| ERROR erroneous constant - //~| WARN this was previously accepted by the compiler but is being phased out } diff --git a/src/test/ui/consts/const_unsafe_unreachable_ub.stderr b/src/test/ui/consts/const_unsafe_unreachable_ub.stderr index 3f122b2a85912..6dddc7ff6e9d2 100644 --- a/src/test/ui/consts/const_unsafe_unreachable_ub.stderr +++ b/src/test/ui/consts/const_unsafe_unreachable_ub.stderr @@ -19,8 +19,6 @@ note: the lint level is defined here | LL | #[warn(const_err)] | ^^^^^^^^^ - = 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 #71800 error[E0080]: evaluation of constant value failed --> $DIR/const_unsafe_unreachable_ub.rs:17:14 @@ -35,8 +33,6 @@ LL | assert_eq!(BAR, true); | ^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors | = note: `#[deny(const_err)]` 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors; 1 warning emitted diff --git a/src/test/ui/consts/control-flow/assert.const_panic.stderr b/src/test/ui/consts/control-flow/assert.const_panic.stderr index 2f28c2e7bb642..03662a3520909 100644 --- a/src/test/ui/consts/control-flow/assert.const_panic.stderr +++ b/src/test/ui/consts/control-flow/assert.const_panic.stderr @@ -7,8 +7,6 @@ LL | const _: () = assert!(false); | the evaluated program panicked at 'assertion failed: false', $DIR/assert.rs:10:15 | = note: `#[deny(const_err)]` 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/consts/control-flow/assert.rs b/src/test/ui/consts/control-flow/assert.rs index a21f28604bdea..90017fee19337 100644 --- a/src/test/ui/consts/control-flow/assert.rs +++ b/src/test/ui/consts/control-flow/assert.rs @@ -10,6 +10,5 @@ const _: () = assert!(true); const _: () = assert!(false); //[stock]~^ ERROR panicking in constants is unstable //[const_panic]~^^ ERROR any use of this value will cause an error -//[const_panic]~| WARN this was previously accepted by the compiler but is being phased out fn main() {} diff --git a/src/test/ui/consts/issue-51559.rs b/src/test/ui/consts/issue-51559.rs index cc644404f7d73..69f0d8df0aa4a 100644 --- a/src/test/ui/consts/issue-51559.rs +++ b/src/test/ui/consts/issue-51559.rs @@ -3,6 +3,5 @@ const BAR: *mut () = ((|| 3) as fn() -> i32) as *mut (); pub const FOO: usize = unsafe { BAR as usize }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out fn main() {} diff --git a/src/test/ui/consts/issue-51559.stderr b/src/test/ui/consts/issue-51559.stderr index d571eb549630f..4d50ec818bce7 100644 --- a/src/test/ui/consts/issue-51559.stderr +++ b/src/test/ui/consts/issue-51559.stderr @@ -4,11 +4,9 @@ error: any use of this value will cause an error LL | pub const FOO: usize = unsafe { BAR as usize }; | --------------------------------^^^^^^^^^^^^--- | | - | cannot cast pointer to integer because it was not created by cast from integer + | "pointer-to-integer cast" needs an rfc before being allowed inside constants | = note: `#[deny(const_err)]` 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 #71800 error: aborting due to previous error diff --git a/src/test/ui/consts/issue-52432.stderr b/src/test/ui/consts/issue-52432.stderr index 29998950552cd..e9539d24118a0 100644 --- a/src/test/ui/consts/issue-52432.stderr +++ b/src/test/ui/consts/issue-52432.stderr @@ -20,7 +20,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/issue-52432.rs:7:10 | LL | [(); &(static || {}) as *const _ as usize]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot cast pointer to integer because it was not created by cast from integer + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "pointer-to-integer cast" needs an rfc before being allowed inside constants error: aborting due to 4 previous errors diff --git a/src/test/ui/limits/issue-55878.rs b/src/test/ui/consts/issue-55878.rs similarity index 100% rename from src/test/ui/limits/issue-55878.rs rename to src/test/ui/consts/issue-55878.rs diff --git a/src/test/ui/limits/issue-55878.stderr b/src/test/ui/consts/issue-55878.stderr similarity index 80% rename from src/test/ui/limits/issue-55878.stderr rename to src/test/ui/consts/issue-55878.stderr index a0e8fc70b6acd..ede5487b65d39 100644 --- a/src/test/ui/limits/issue-55878.stderr +++ b/src/test/ui/consts/issue-55878.stderr @@ -16,8 +16,6 @@ LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors | = note: `#[deny(const_err)]` 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 #71800 error: aborting due to 2 previous errors diff --git a/src/test/ui/limits/issue-56762.rs b/src/test/ui/consts/issue-56762.rs similarity index 100% rename from src/test/ui/limits/issue-56762.rs rename to src/test/ui/consts/issue-56762.rs diff --git a/src/test/ui/limits/issue-56762.stderr b/src/test/ui/consts/issue-56762.stderr similarity index 100% rename from src/test/ui/limits/issue-56762.stderr rename to src/test/ui/consts/issue-56762.stderr diff --git a/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs b/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs index 7bbe9c87705a3..ba3b61a3fa732 100644 --- a/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs +++ b/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs @@ -26,8 +26,6 @@ const U8_MUT2: &u8 = { //~ NOTE unsafe { &(*static_cross_crate::ZERO_REF)[0] } //~^ WARN [const_err] //~| NOTE constant accesses static - //~| WARN this was previously accepted by the compiler but is being phased out - //~| NOTE }; #[warn(const_err)] //~ NOTE const U8_MUT3: &u8 = { //~ NOTE @@ -35,8 +33,6 @@ const U8_MUT3: &u8 = { //~ NOTE //~^ WARN [const_err] //~| NOTE constant accesses static //~| NOTE in this expansion of panic! - //~| WARN this was previously accepted by the compiler but is being phased out - //~| NOTE }; pub fn test(x: &[u8; 1]) -> bool { diff --git a/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr b/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr index a9d6fde6c05be..4484a813a883d 100644 --- a/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr +++ b/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr @@ -11,7 +11,7 @@ LL | | }; = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:44:9 + --> $DIR/const_refers_to_static_cross_crate.rs:40:9 | LL | SLICE_MUT => true, | ^^^^^^^^^ @@ -29,7 +29,7 @@ LL | | }; = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:53:9 + --> $DIR/const_refers_to_static_cross_crate.rs:49:9 | LL | U8_MUT => true, | ^^^^^^ @@ -42,8 +42,6 @@ LL | | unsafe { &(*static_cross_crate::ZERO_REF)[0] } | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static LL | | LL | | -LL | | -LL | | LL | | }; | |__- | @@ -52,62 +50,57 @@ note: the lint level is defined here | LL | #[warn(const_err)] | ^^^^^^^^^ - = 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 #71800 error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:64:9 + --> $DIR/const_refers_to_static_cross_crate.rs:60:9 | LL | U8_MUT2 => true, | ^^^^^^^ warning: any use of this value will cause an error - --> $DIR/const_refers_to_static_cross_crate.rs:34:51 + --> $DIR/const_refers_to_static_cross_crate.rs:32:51 | LL | / const U8_MUT3: &u8 = { LL | | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | | ^^^^^^^^^^^ constant accesses static LL | | LL | | -... | LL | | LL | | }; | |__- | note: the lint level is defined here - --> $DIR/const_refers_to_static_cross_crate.rs:32:8 + --> $DIR/const_refers_to_static_cross_crate.rs:30:8 | LL | #[warn(const_err)] | ^^^^^^^^^ - = 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 #71800 error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:72:9 + --> $DIR/const_refers_to_static_cross_crate.rs:68:9 | LL | U8_MUT3 => true, | ^^^^^^^ error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:44:9 + --> $DIR/const_refers_to_static_cross_crate.rs:40:9 | LL | SLICE_MUT => true, | ^^^^^^^^^ error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:53:9 + --> $DIR/const_refers_to_static_cross_crate.rs:49:9 | LL | U8_MUT => true, | ^^^^^^ error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:64:9 + --> $DIR/const_refers_to_static_cross_crate.rs:60:9 | LL | U8_MUT2 => true, | ^^^^^^^ error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:72:9 + --> $DIR/const_refers_to_static_cross_crate.rs:68:9 | LL | U8_MUT3 => true, | ^^^^^^^ @@ -145,27 +138,27 @@ help: skipping check that does not even have a feature gate LL | unsafe { &(*static_cross_crate::ZERO_REF)[0] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:34:20 + --> $DIR/const_refers_to_static_cross_crate.rs:32:20 | LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:34:20 + --> $DIR/const_refers_to_static_cross_crate.rs:32:20 | LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:34:20 + --> $DIR/const_refers_to_static_cross_crate.rs:32:20 | LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check for `const_panic` feature - --> $DIR/const_refers_to_static_cross_crate.rs:34:77 + --> $DIR/const_refers_to_static_cross_crate.rs:32:77 | LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | ^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:34:20 + --> $DIR/const_refers_to_static_cross_crate.rs:32:20 | LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/consts/miri_unleashed/ptr_arith.rs b/src/test/ui/consts/miri_unleashed/ptr_arith.rs index aae6d837204e3..65fc49c0b27a6 100644 --- a/src/test/ui/consts/miri_unleashed/ptr_arith.rs +++ b/src/test/ui/consts/miri_unleashed/ptr_arith.rs @@ -15,7 +15,7 @@ static INT_PTR_ARITH: () = unsafe { let x: usize = std::mem::transmute(&0); let _v = x + 0; //~^ ERROR could not evaluate static initializer - //~| NOTE cannot cast pointer to integer + //~| NOTE pointer-to-integer cast }; fn main() {} diff --git a/src/test/ui/consts/miri_unleashed/ptr_arith.stderr b/src/test/ui/consts/miri_unleashed/ptr_arith.stderr index 8ac4aa87f642a..d782a3633b243 100644 --- a/src/test/ui/consts/miri_unleashed/ptr_arith.stderr +++ b/src/test/ui/consts/miri_unleashed/ptr_arith.stderr @@ -8,7 +8,7 @@ error[E0080]: could not evaluate static initializer --> $DIR/ptr_arith.rs:16:14 | LL | let _v = x + 0; - | ^^^^^ cannot cast pointer to integer because it was not created by cast from integer + | ^^^^^ "pointer-to-integer cast" needs an rfc before being allowed inside constants warning: skipping const checks | diff --git a/src/test/ui/consts/offset_from_ub.stderr b/src/test/ui/consts/offset_from_ub.stderr index eb726f9cb113f..ebe17e8730413 100644 --- a/src/test/ui/consts/offset_from_ub.stderr +++ b/src/test/ui/consts/offset_from_ub.stderr @@ -20,8 +20,6 @@ LL | | }; | |__- | = note: `#[deny(const_err)]` 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -40,9 +38,6 @@ LL | | LL | | unsafe { (42 as *const u8).offset_from(&5u8) as usize } LL | | }; | |__- - | - = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -64,9 +59,6 @@ LL | | let field_ptr = &data[1] as *const u8 as *const u16; LL | | unsafe { field_ptr.offset_from(base_ptr as *const u16) } LL | | }; | |__- - | - = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -86,9 +78,6 @@ LL | | let ptr = 0 as *const u8; LL | | unsafe { ptr.offset_from(ptr) } LL | | }; | |__- - | - = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -109,9 +98,6 @@ LL | | let ptr2 = 16 as *const u8; LL | | unsafe { ptr2.offset_from(ptr1) } LL | | }; | |__- - | - = 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 #71800 error: aborting due to 5 previous errors diff --git a/src/test/ui/consts/offset_ub.stderr b/src/test/ui/consts/offset_ub.stderr index 5e8b7a8e0b698..e58db1efaf0e0 100644 --- a/src/test/ui/consts/offset_ub.stderr +++ b/src/test/ui/consts/offset_ub.stderr @@ -14,8 +14,6 @@ LL | pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1) | ------------------------------------------------------------------------------ | = note: `#[deny(const_err)]` 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -31,9 +29,6 @@ LL | unsafe { intrinsics::offset(self, count) } | LL | pub const AFTER_END: *const u8 = unsafe { (&0u8 as *const u8).offset(2) }; | -------------------------------------------------------------------------- - | - = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -49,9 +44,6 @@ LL | unsafe { intrinsics::offset(self, count) } | LL | pub const AFTER_ARRAY: *const u8 = unsafe { [0u8; 100].as_ptr().offset(101) }; | ------------------------------------------------------------------------------ - | - = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -67,9 +59,6 @@ LL | unsafe { intrinsics::offset(self, count) } | LL | pub const OVERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MAX) }; | ---------------------------------------------------------------------------------- - | - = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -85,9 +74,6 @@ LL | unsafe { intrinsics::offset(self, count) } | LL | pub const UNDERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MIN) }; | ----------------------------------------------------------------------------------- - | - = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -103,9 +89,6 @@ LL | unsafe { intrinsics::offset(self, count) } | LL | pub const OVERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (usize::MAX as *const u8).offset(2) }; | --------------------------------------------------------------------------------------------- - | - = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -121,9 +104,6 @@ LL | unsafe { intrinsics::offset(self, count) } | LL | pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).offset(-2) }; | -------------------------------------------------------------------------------------- - | - = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -139,9 +119,6 @@ LL | unsafe { intrinsics::offset(self, count) } | LL | pub const ZERO_SIZED_ALLOC: *const u8 = unsafe { [0u8; 0].as_ptr().offset(1) }; | ------------------------------------------------------------------------------- - | - = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL @@ -157,9 +134,6 @@ LL | unsafe { intrinsics::offset(self, count) as *mut T } | LL | pub const DANGLING: *const u8 = unsafe { ptr::NonNull::::dangling().as_ptr().offset(4) }; | --------------------------------------------------------------------------------------------- - | - = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -175,9 +149,6 @@ LL | unsafe { intrinsics::offset(self, count) } | LL | pub const NULL_OFFSET_ZERO: *const u8 = unsafe { ptr::null::().offset(0) }; | ------------------------------------------------------------------------------- - | - = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -193,9 +164,6 @@ LL | unsafe { intrinsics::offset(self, count) } | LL | pub const UNDERFLOW_ABS: *const u8 = unsafe { (usize::MAX as *const u8).offset(isize::MIN) }; | --------------------------------------------------------------------------------------------- - | - = 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 #71800 error: aborting due to 11 previous errors diff --git a/src/test/ui/consts/ptr_comparisons.rs b/src/test/ui/consts/ptr_comparisons.rs index 0fbe55f972ee5..f16f6fd6de4ba 100644 --- a/src/test/ui/consts/ptr_comparisons.rs +++ b/src/test/ui/consts/ptr_comparisons.rs @@ -66,19 +66,13 @@ const _: *const u8 = unsafe { std::ptr::addr_of!((*(FOO as *const usize as *const [u8; 1000]))[999]) }; //~^ ERROR any use of this value will cause an error //~| NOTE -//~| WARN this was previously accepted by the compiler but is being phased out -//~| NOTE const _: usize = unsafe { std::mem::transmute::<*const usize, usize>(FOO) + 4 }; //~^ ERROR any use of this value will cause an error -//~| NOTE cannot cast pointer to integer -//~| NOTE -//~| WARN this was previously accepted by the compiler but is being phased out +//~| NOTE "pointer-to-integer cast" needs an rfc //~| NOTE const _: usize = unsafe { *std::mem::transmute::<&&usize, &usize>(&FOO) + 4 }; //~^ ERROR any use of this value will cause an error -//~| NOTE cannot cast pointer to integer -//~| NOTE -//~| WARN this was previously accepted by the compiler but is being phased out +//~| NOTE "pointer-to-integer cast" needs an rfc //~| NOTE diff --git a/src/test/ui/consts/ptr_comparisons.stderr b/src/test/ui/consts/ptr_comparisons.stderr index 9ec009c55c443..96b63c0acb0a1 100644 --- a/src/test/ui/consts/ptr_comparisons.stderr +++ b/src/test/ui/consts/ptr_comparisons.stderr @@ -14,8 +14,6 @@ LL | const _: *const usize = unsafe { (FOO as *const usize).offset(2) }; | ------------------------------------------------------------------- | = note: `#[deny(const_err)]` 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 #71800 error: any use of this value will cause an error --> $DIR/ptr_comparisons.rs:66:33 @@ -26,31 +24,22 @@ LL | | unsafe { std::ptr::addr_of!((*(FOO as *const usize as *const [u8; 100 | |_________________________________^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^___- | | | memory access failed: pointer must be in-bounds at offset 1000, but is outside bounds of alloc2 which has size $WORD - | - = 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 #71800 error: any use of this value will cause an error - --> $DIR/ptr_comparisons.rs:72:27 + --> $DIR/ptr_comparisons.rs:70:27 | LL | const _: usize = unsafe { std::mem::transmute::<*const usize, usize>(FOO) + 4 }; | --------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | - | cannot cast pointer to integer because it was not created by cast from integer - | - = 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 #71800 + | "pointer-to-integer cast" needs an rfc before being allowed inside constants error: any use of this value will cause an error - --> $DIR/ptr_comparisons.rs:79:27 + --> $DIR/ptr_comparisons.rs:75:27 | LL | const _: usize = unsafe { *std::mem::transmute::<&&usize, &usize>(&FOO) + 4 }; | --------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | - | cannot cast pointer to integer because it was not created by cast from integer - | - = 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 #71800 + | "pointer-to-integer cast" needs an rfc before being allowed inside constants error: aborting due to 4 previous errors diff --git a/src/test/ui/consts/transmute-size-mismatch-before-typeck.rs b/src/test/ui/consts/transmute-size-mismatch-before-typeck.rs index 0f0068ac3bdc1..2817abfcaa8de 100644 --- a/src/test/ui/consts/transmute-size-mismatch-before-typeck.rs +++ b/src/test/ui/consts/transmute-size-mismatch-before-typeck.rs @@ -15,7 +15,6 @@ fn main() { const ZST: &[u8] = unsafe { std::mem::transmute(1usize) }; //~^ ERROR any use of this value will cause an error //~| ERROR cannot transmute between types of different sizes -//~| WARN this was previously accepted by the compiler but is being phased out // Once the `any use of this value will cause an error` disappears in this test, make sure to // remove the `TransmuteSizeDiff` error variant and make its emitter site an assertion again. diff --git a/src/test/ui/consts/transmute-size-mismatch-before-typeck.stderr b/src/test/ui/consts/transmute-size-mismatch-before-typeck.stderr index 6e93aed70b65a..b4970c82adb3e 100644 --- a/src/test/ui/consts/transmute-size-mismatch-before-typeck.stderr +++ b/src/test/ui/consts/transmute-size-mismatch-before-typeck.stderr @@ -7,8 +7,6 @@ LL | const ZST: &[u8] = unsafe { std::mem::transmute(1usize) }; | transmuting `usize` to `&[u8]` is not possible, because these types do not have the same size | = note: `#[deny(const_err)]` 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 #71800 error: could not evaluate constant pattern --> $DIR/transmute-size-mismatch-before-typeck.rs:10:9 diff --git a/src/test/ui/consts/uninhabited-const-issue-61744.rs b/src/test/ui/consts/uninhabited-const-issue-61744.rs index 860628c39c371..2f4b7578d1c32 100644 --- a/src/test/ui/consts/uninhabited-const-issue-61744.rs +++ b/src/test/ui/consts/uninhabited-const-issue-61744.rs @@ -2,7 +2,6 @@ pub const unsafe fn fake_type() -> T { hint_unreachable() //~ ERROR any use of this value will cause an error [const_err] - //~| WARN this was previously accepted by the compiler but is being phased out } pub const unsafe fn hint_unreachable() -> ! { diff --git a/src/test/ui/consts/uninhabited-const-issue-61744.stderr b/src/test/ui/consts/uninhabited-const-issue-61744.stderr index e98eefc11c3c8..1fb5ac11df0f0 100644 --- a/src/test/ui/consts/uninhabited-const-issue-61744.stderr +++ b/src/test/ui/consts/uninhabited-const-issue-61744.stderr @@ -6,143 +6,141 @@ LL | hint_unreachable() | | | reached the configured maximum number of stack frames | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `::CONSTANT` at $DIR/uninhabited-const-issue-61744.rs:13:36 + | inside `::CONSTANT` at $DIR/uninhabited-const-issue-61744.rs:12:36 ... LL | const CONSTANT: i32 = unsafe { fake_type() }; | --------------------------------------------- | = note: `#[deny(const_err)]` 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 #71800 error[E0080]: erroneous constant used - --> $DIR/uninhabited-const-issue-61744.rs:19:10 + --> $DIR/uninhabited-const-issue-61744.rs:18:10 | LL | dbg!(i32::CONSTANT); | ^^^^^^^^^^^^^ referenced constant has errors diff --git a/src/test/ui/cycle-projection-based-on-where-clause.rs b/src/test/ui/cycle-projection-based-on-where-clause.rs new file mode 100644 index 0000000000000..d3609acfdff63 --- /dev/null +++ b/src/test/ui/cycle-projection-based-on-where-clause.rs @@ -0,0 +1,24 @@ +// Example cycle where a bound on `T` uses a shorthand for `T`. This +// creates a cycle because we have to know the bounds on `T` to figure +// out what trait defines `Item`, but we can't know the bounds on `T` +// without knowing how to handle `T::Item`. +// +// Note that in the future cases like this could perhaps become legal, +// if we got more fine-grained about our cycle detection or changed +// how we handle `T::Item` resolution. + +use std::ops::Add; + +// Preamble. +trait Trait { type Item; } + +struct A + where T : Trait, + T : Add + //~^ ERROR cycle detected +{ + data: T +} + +fn main() { +} diff --git a/src/test/ui/cycle-projection-based-on-where-clause.stderr b/src/test/ui/cycle-projection-based-on-where-clause.stderr new file mode 100644 index 0000000000000..2c337cc6bf903 --- /dev/null +++ b/src/test/ui/cycle-projection-based-on-where-clause.stderr @@ -0,0 +1,16 @@ +error[E0391]: cycle detected when computing the bounds for type parameter `T` + --> $DIR/cycle-projection-based-on-where-clause.rs:17:19 + | +LL | T : Add + | ^^^^^^^ + | + = note: ...which again requires computing the bounds for type parameter `T`, completing the cycle +note: cycle used when computing explicit predicates of `A` + --> $DIR/cycle-projection-based-on-where-clause.rs:17:19 + | +LL | T : Add + | ^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/src/test/ui/cycle-trait/cycle-trait-supertrait-direct.stderr b/src/test/ui/cycle-trait/cycle-trait-supertrait-direct.stderr index ee54b2fd151d7..8aa3ac8abf52c 100644 --- a/src/test/ui/cycle-trait/cycle-trait-supertrait-direct.stderr +++ b/src/test/ui/cycle-trait/cycle-trait-supertrait-direct.stderr @@ -1,15 +1,10 @@ -error[E0391]: cycle detected when computing the super predicates of `Chromosome` - --> $DIR/cycle-trait-supertrait-direct.rs:3:1 - | -LL | trait Chromosome: Chromosome { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: ...which requires computing the super traits of `Chromosome`... +error[E0391]: cycle detected when computing the supertraits of `Chromosome` --> $DIR/cycle-trait-supertrait-direct.rs:3:19 | LL | trait Chromosome: Chromosome { | ^^^^^^^^^^ - = note: ...which again requires computing the super predicates of `Chromosome`, completing the cycle + | + = note: ...which again requires computing the supertraits of `Chromosome`, completing the cycle note: cycle used when collecting item types in top-level module --> $DIR/cycle-trait-supertrait-direct.rs:3:1 | diff --git a/src/test/ui/cycle-trait/cycle-trait-supertrait-indirect.stderr b/src/test/ui/cycle-trait/cycle-trait-supertrait-indirect.stderr index 0a2284e0efbca..9740f43a4ba97 100644 --- a/src/test/ui/cycle-trait/cycle-trait-supertrait-indirect.stderr +++ b/src/test/ui/cycle-trait/cycle-trait-supertrait-indirect.stderr @@ -1,26 +1,16 @@ -error[E0391]: cycle detected when computing the super predicates of `B` - --> $DIR/cycle-trait-supertrait-indirect.rs:7:1 - | -LL | trait B: C { - | ^^^^^^^^^^ - | -note: ...which requires computing the super traits of `B`... +error[E0391]: cycle detected when computing the supertraits of `B` --> $DIR/cycle-trait-supertrait-indirect.rs:7:10 | LL | trait B: C { | ^ -note: ...which requires computing the super predicates of `C`... - --> $DIR/cycle-trait-supertrait-indirect.rs:11:1 | -LL | trait C: B { } - | ^^^^^^^^^^ -note: ...which requires computing the super traits of `C`... +note: ...which requires computing the supertraits of `C`... --> $DIR/cycle-trait-supertrait-indirect.rs:11:10 | LL | trait C: B { } | ^ - = note: ...which again requires computing the super predicates of `B`, completing the cycle -note: cycle used when computing the super traits of `A` + = note: ...which again requires computing the supertraits of `B`, completing the cycle +note: cycle used when computing the supertraits of `A` --> $DIR/cycle-trait-supertrait-indirect.rs:4:10 | LL | trait A: B { diff --git a/src/test/ui/derives/derive-Debug-use-ufcs-struct.rs b/src/test/ui/derives/derive-Debug-use-ufcs-struct.rs deleted file mode 100644 index cb9dda8415927..0000000000000 --- a/src/test/ui/derives/derive-Debug-use-ufcs-struct.rs +++ /dev/null @@ -1,40 +0,0 @@ -// run-pass -#![allow(warnings)] - -#[derive(Debug)] -pub struct Bar { pub t: () } - -impl Access for T {} -pub trait Access { - fn field(&self, _: impl Sized, _: impl Sized) { - panic!("got into Access::field"); - } - - fn finish(&self) -> Result<(), std::fmt::Error> { - panic!("got into Access::finish"); - } - - fn debug_struct(&self, _: impl Sized, _: impl Sized) { - panic!("got into Access::debug_struct"); - } -} - -impl MutAccess for T {} -pub trait MutAccess { - fn field(&mut self, _: impl Sized, _: impl Sized) { - panic!("got into MutAccess::field"); - } - - fn finish(&mut self) -> Result<(), std::fmt::Error> { - panic!("got into MutAccess::finish"); - } - - fn debug_struct(&mut self, _: impl Sized, _: impl Sized) { - panic!("got into MutAccess::debug_struct"); - } -} - -fn main() { - let bar = Bar { t: () }; - assert_eq!("Bar { t: () }", format!("{:?}", bar)); -} diff --git a/src/test/ui/derives/derive-Debug-use-ufcs-tuple.rs b/src/test/ui/derives/derive-Debug-use-ufcs-tuple.rs deleted file mode 100644 index 5f786769fe73b..0000000000000 --- a/src/test/ui/derives/derive-Debug-use-ufcs-tuple.rs +++ /dev/null @@ -1,32 +0,0 @@ -// run-pass -#![allow(warnings)] - -#[derive(Debug)] -pub struct Foo(pub T); - -use std::fmt; - -impl Field for T {} -impl Finish for T {} -impl Dt for &mut fmt::Formatter<'_> {} - -pub trait Field { - fn field(&self, _: impl Sized) { - panic!("got into field"); - } -} -pub trait Finish { - fn finish(&self) -> Result<(), std::fmt::Error> { - panic!("got into finish"); - } -} -pub trait Dt { - fn debug_tuple(&self, _: &str) { - panic!("got into debug_tuple"); - } -} - -fn main() { - let foo = Foo(()); - assert_eq!("Foo(())", format!("{:?}", foo)); -} diff --git a/src/test/ui/derives/derive-deadlock.rs b/src/test/ui/derives/derive-deadlock.rs deleted file mode 100644 index 0137b1e5bfbf3..0000000000000 --- a/src/test/ui/derives/derive-deadlock.rs +++ /dev/null @@ -1,6 +0,0 @@ -use std as derive; - -#[derive(Default)] //~ ERROR cannot determine resolution for the attribute macro `derive` -struct S; - -fn main() {} diff --git a/src/test/ui/derives/derive-deadlock.stderr b/src/test/ui/derives/derive-deadlock.stderr deleted file mode 100644 index 8d062491c6a7c..0000000000000 --- a/src/test/ui/derives/derive-deadlock.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: cannot determine resolution for the attribute macro `derive` - --> $DIR/derive-deadlock.rs:3:3 - | -LL | #[derive(Default)] - | ^^^^^^ - | - = note: import resolution is stuck, try simplifying macro imports - -error: aborting due to previous error - diff --git a/src/test/ui/derives/derive-multiple-with-packed.rs b/src/test/ui/derives/derive-multiple-with-packed.rs deleted file mode 100644 index e762ee357caab..0000000000000 --- a/src/test/ui/derives/derive-multiple-with-packed.rs +++ /dev/null @@ -1,10 +0,0 @@ -// check-pass - -#[derive(Clone, Copy)] -#[derive(Debug)] // OK, even if `Copy` is in the different `#[derive]` -#[repr(packed)] -struct CacheRecordHeader { - field: u64, -} - -fn main() {} diff --git a/src/test/ui/derives/derive-partial-ord.rs b/src/test/ui/derives/derive-partial-ord.rs deleted file mode 100644 index 9078a7ffa4fd7..0000000000000 --- a/src/test/ui/derives/derive-partial-ord.rs +++ /dev/null @@ -1,60 +0,0 @@ -// Checks that in a derived implementation of PartialOrd the lt, le, ge, gt methods are consistent -// with partial_cmp. Also verifies that implementation is consistent with that for tuples. -// -// run-pass - -#[derive(PartialEq, PartialOrd)] -struct P(f64, f64); - -fn main() { - let values: &[f64] = &[1.0, 2.0, f64::NAN]; - for a in values { - for b in values { - for c in values { - for d in values { - // Check impl for a tuple. - check(&(*a, *b), &(*c, *d)); - - // Check derived impl. - check(&P(*a, *b), &P(*c, *d)); - - // Check that impls agree with each other. - assert_eq!( - PartialOrd::partial_cmp(&(*a, *b), &(*c, *d)), - PartialOrd::partial_cmp(&P(*a, *b), &P(*c, *d)), - ); - } - } - } - } -} - -fn check(a: &T, b: &T) { - use std::cmp::Ordering::*; - match PartialOrd::partial_cmp(a, b) { - None => { - assert!(!(a < b)); - assert!(!(a <= b)); - assert!(!(a > b)); - assert!(!(a >= b)); - } - Some(Equal) => { - assert!(!(a < b)); - assert!(a <= b); - assert!(!(a > b)); - assert!(a >= b); - } - Some(Less) => { - assert!(a < b); - assert!(a <= b); - assert!(!(a > b)); - assert!(!(a >= b)); - } - Some(Greater) => { - assert!(!(a < b)); - assert!(!(a <= b)); - assert!(a > b); - assert!(a >= b); - } - } -} diff --git a/src/test/ui/derives/derive-renamed.rs b/src/test/ui/derives/derive-renamed.rs deleted file mode 100644 index d310e5806c560..0000000000000 --- a/src/test/ui/derives/derive-renamed.rs +++ /dev/null @@ -1,11 +0,0 @@ -// check-pass -// edition:2018 - -use derive as my_derive; - -#[my_derive(Debug)] -struct S; - -fn main() { - println!("{:?}", S); // OK -} diff --git a/src/test/ui/derives/derives-span-PartialOrd-enum-struct-variant.rs b/src/test/ui/derives/derives-span-PartialOrd-enum-struct-variant.rs index a769c137657cc..4e7a8d71a18f4 100644 --- a/src/test/ui/derives/derives-span-PartialOrd-enum-struct-variant.rs +++ b/src/test/ui/derives/derives-span-PartialOrd-enum-struct-variant.rs @@ -7,6 +7,10 @@ struct Error; enum Enum { A { x: Error //~ ERROR can't compare `Error` with `Error` + //~| ERROR can't compare `Error` with `Error` + //~| ERROR can't compare `Error` with `Error` + //~| ERROR can't compare `Error` with `Error` + //~| ERROR can't compare `Error` with `Error` } } diff --git a/src/test/ui/derives/derives-span-PartialOrd-enum-struct-variant.stderr b/src/test/ui/derives/derives-span-PartialOrd-enum-struct-variant.stderr index 9f2f47add1278..0736e71460b3d 100644 --- a/src/test/ui/derives/derives-span-PartialOrd-enum-struct-variant.stderr +++ b/src/test/ui/derives/derives-span-PartialOrd-enum-struct-variant.stderr @@ -8,6 +8,46 @@ LL | x: Error = note: required by `std::cmp::PartialOrd::partial_cmp` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to previous error +error[E0277]: can't compare `Error` with `Error` + --> $DIR/derives-span-PartialOrd-enum-struct-variant.rs:9:6 + | +LL | x: Error + | ^^^^^^^^ no implementation for `Error < Error` and `Error > Error` + | + = help: the trait `PartialOrd` is not implemented for `Error` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `Error` with `Error` + --> $DIR/derives-span-PartialOrd-enum-struct-variant.rs:9:6 + | +LL | x: Error + | ^^^^^^^^ no implementation for `Error < Error` and `Error > Error` + | + = help: the trait `PartialOrd` is not implemented for `Error` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `Error` with `Error` + --> $DIR/derives-span-PartialOrd-enum-struct-variant.rs:9:6 + | +LL | x: Error + | ^^^^^^^^ no implementation for `Error < Error` and `Error > Error` + | + = help: the trait `PartialOrd` is not implemented for `Error` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `Error` with `Error` + --> $DIR/derives-span-PartialOrd-enum-struct-variant.rs:9:6 + | +LL | x: Error + | ^^^^^^^^ no implementation for `Error < Error` and `Error > Error` + | + = help: the trait `PartialOrd` is not implemented for `Error` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/derives/derives-span-PartialOrd-enum.rs b/src/test/ui/derives/derives-span-PartialOrd-enum.rs index 4f0d794e42d76..d0a6c5ab52ad7 100644 --- a/src/test/ui/derives/derives-span-PartialOrd-enum.rs +++ b/src/test/ui/derives/derives-span-PartialOrd-enum.rs @@ -7,6 +7,10 @@ struct Error; enum Enum { A( Error //~ ERROR can't compare `Error` with `Error` + //~| ERROR can't compare `Error` with `Error` + //~| ERROR can't compare `Error` with `Error` + //~| ERROR can't compare `Error` with `Error` + //~| ERROR can't compare `Error` with `Error` ) } diff --git a/src/test/ui/derives/derives-span-PartialOrd-enum.stderr b/src/test/ui/derives/derives-span-PartialOrd-enum.stderr index 25073c5718c9d..d88321b97973b 100644 --- a/src/test/ui/derives/derives-span-PartialOrd-enum.stderr +++ b/src/test/ui/derives/derives-span-PartialOrd-enum.stderr @@ -8,6 +8,46 @@ LL | Error = note: required by `std::cmp::PartialOrd::partial_cmp` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to previous error +error[E0277]: can't compare `Error` with `Error` + --> $DIR/derives-span-PartialOrd-enum.rs:9:6 + | +LL | Error + | ^^^^^ no implementation for `Error < Error` and `Error > Error` + | + = help: the trait `PartialOrd` is not implemented for `Error` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `Error` with `Error` + --> $DIR/derives-span-PartialOrd-enum.rs:9:6 + | +LL | Error + | ^^^^^ no implementation for `Error < Error` and `Error > Error` + | + = help: the trait `PartialOrd` is not implemented for `Error` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `Error` with `Error` + --> $DIR/derives-span-PartialOrd-enum.rs:9:6 + | +LL | Error + | ^^^^^ no implementation for `Error < Error` and `Error > Error` + | + = help: the trait `PartialOrd` is not implemented for `Error` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `Error` with `Error` + --> $DIR/derives-span-PartialOrd-enum.rs:9:6 + | +LL | Error + | ^^^^^ no implementation for `Error < Error` and `Error > Error` + | + = help: the trait `PartialOrd` is not implemented for `Error` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/derives/derives-span-PartialOrd-struct.rs b/src/test/ui/derives/derives-span-PartialOrd-struct.rs index da857c6743575..a596a2e32959d 100644 --- a/src/test/ui/derives/derives-span-PartialOrd-struct.rs +++ b/src/test/ui/derives/derives-span-PartialOrd-struct.rs @@ -6,6 +6,10 @@ struct Error; #[derive(PartialOrd,PartialEq)] struct Struct { x: Error //~ ERROR can't compare `Error` with `Error` + //~| ERROR can't compare `Error` with `Error` + //~| ERROR can't compare `Error` with `Error` + //~| ERROR can't compare `Error` with `Error` + //~| ERROR can't compare `Error` with `Error` } fn main() {} diff --git a/src/test/ui/derives/derives-span-PartialOrd-struct.stderr b/src/test/ui/derives/derives-span-PartialOrd-struct.stderr index b514dd9993f7f..3023517752844 100644 --- a/src/test/ui/derives/derives-span-PartialOrd-struct.stderr +++ b/src/test/ui/derives/derives-span-PartialOrd-struct.stderr @@ -8,6 +8,46 @@ LL | x: Error = note: required by `std::cmp::PartialOrd::partial_cmp` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to previous error +error[E0277]: can't compare `Error` with `Error` + --> $DIR/derives-span-PartialOrd-struct.rs:8:5 + | +LL | x: Error + | ^^^^^^^^ no implementation for `Error < Error` and `Error > Error` + | + = help: the trait `PartialOrd` is not implemented for `Error` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `Error` with `Error` + --> $DIR/derives-span-PartialOrd-struct.rs:8:5 + | +LL | x: Error + | ^^^^^^^^ no implementation for `Error < Error` and `Error > Error` + | + = help: the trait `PartialOrd` is not implemented for `Error` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `Error` with `Error` + --> $DIR/derives-span-PartialOrd-struct.rs:8:5 + | +LL | x: Error + | ^^^^^^^^ no implementation for `Error < Error` and `Error > Error` + | + = help: the trait `PartialOrd` is not implemented for `Error` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `Error` with `Error` + --> $DIR/derives-span-PartialOrd-struct.rs:8:5 + | +LL | x: Error + | ^^^^^^^^ no implementation for `Error < Error` and `Error > Error` + | + = help: the trait `PartialOrd` is not implemented for `Error` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/derives/derives-span-PartialOrd-tuple-struct.rs b/src/test/ui/derives/derives-span-PartialOrd-tuple-struct.rs index 61d5076708800..6dd1623471045 100644 --- a/src/test/ui/derives/derives-span-PartialOrd-tuple-struct.rs +++ b/src/test/ui/derives/derives-span-PartialOrd-tuple-struct.rs @@ -6,6 +6,10 @@ struct Error; #[derive(PartialOrd,PartialEq)] struct Struct( Error //~ ERROR can't compare `Error` with `Error` + //~| ERROR can't compare `Error` with `Error` + //~| ERROR can't compare `Error` with `Error` + //~| ERROR can't compare `Error` with `Error` + //~| ERROR can't compare `Error` with `Error` ); fn main() {} diff --git a/src/test/ui/derives/derives-span-PartialOrd-tuple-struct.stderr b/src/test/ui/derives/derives-span-PartialOrd-tuple-struct.stderr index c098f6bfb36ac..3abf1ded8df8f 100644 --- a/src/test/ui/derives/derives-span-PartialOrd-tuple-struct.stderr +++ b/src/test/ui/derives/derives-span-PartialOrd-tuple-struct.stderr @@ -8,6 +8,46 @@ LL | Error = note: required by `std::cmp::PartialOrd::partial_cmp` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to previous error +error[E0277]: can't compare `Error` with `Error` + --> $DIR/derives-span-PartialOrd-tuple-struct.rs:8:5 + | +LL | Error + | ^^^^^ no implementation for `Error < Error` and `Error > Error` + | + = help: the trait `PartialOrd` is not implemented for `Error` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `Error` with `Error` + --> $DIR/derives-span-PartialOrd-tuple-struct.rs:8:5 + | +LL | Error + | ^^^^^ no implementation for `Error < Error` and `Error > Error` + | + = help: the trait `PartialOrd` is not implemented for `Error` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `Error` with `Error` + --> $DIR/derives-span-PartialOrd-tuple-struct.rs:8:5 + | +LL | Error + | ^^^^^ no implementation for `Error < Error` and `Error > Error` + | + = help: the trait `PartialOrd` is not implemented for `Error` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `Error` with `Error` + --> $DIR/derives-span-PartialOrd-tuple-struct.rs:8:5 + | +LL | Error + | ^^^^^ no implementation for `Error < Error` and `Error > Error` + | + = help: the trait `PartialOrd` is not implemented for `Error` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/derives/deriving-meta-empty-trait-list.rs b/src/test/ui/derives/deriving-meta-empty-trait-list.rs index 0306ce717d049..4f2e31e8efb15 100644 --- a/src/test/ui/derives/deriving-meta-empty-trait-list.rs +++ b/src/test/ui/derives/deriving-meta-empty-trait-list.rs @@ -1,8 +1,6 @@ -// check-pass - #![deny(unused)] -#[derive()] // OK +#[derive()] //~ ERROR unused attribute struct _Bar; pub fn main() {} diff --git a/src/test/ui/derives/deriving-meta-empty-trait-list.stderr b/src/test/ui/derives/deriving-meta-empty-trait-list.stderr new file mode 100644 index 0000000000000..1fd7d58c86a37 --- /dev/null +++ b/src/test/ui/derives/deriving-meta-empty-trait-list.stderr @@ -0,0 +1,15 @@ +error: unused attribute + --> $DIR/deriving-meta-empty-trait-list.rs:3:1 + | +LL | #[derive()] + | ^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/deriving-meta-empty-trait-list.rs:1:9 + | +LL | #![deny(unused)] + | ^^^^^^ + = note: `#[deny(unused_attributes)]` implied by `#[deny(unused)]` + +error: aborting due to previous error + diff --git a/src/test/ui/derives/issue-36617.rs b/src/test/ui/derives/issue-36617.rs index 08fc82e91f623..1102f3c4640a1 100644 --- a/src/test/ui/derives/issue-36617.rs +++ b/src/test/ui/derives/issue-36617.rs @@ -1,3 +1,4 @@ -#![derive(Copy)] //~ ERROR cannot determine resolution for the attribute macro `derive` +#![derive(Copy)] //~ ERROR `derive` may only be applied to structs, enums and unions + //~| ERROR cannot determine resolution for the derive macro `Copy` fn main() {} diff --git a/src/test/ui/derives/issue-36617.stderr b/src/test/ui/derives/issue-36617.stderr index 0716764b42704..dc6ef16925913 100644 --- a/src/test/ui/derives/issue-36617.stderr +++ b/src/test/ui/derives/issue-36617.stderr @@ -1,10 +1,17 @@ -error: cannot determine resolution for the attribute macro `derive` - --> $DIR/issue-36617.rs:1:4 +error[E0774]: `derive` may only be applied to structs, enums and unions + --> $DIR/issue-36617.rs:1:1 | LL | #![derive(Copy)] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^ help: try an outer attribute: `#[derive(Copy)]` + +error: cannot determine resolution for the derive macro `Copy` + --> $DIR/issue-36617.rs:1:11 + | +LL | #![derive(Copy)] + | ^^^^ | = note: import resolution is stuck, try simplifying macro imports -error: aborting due to previous error +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0774`. diff --git a/src/test/ui/drop/dynamic-drop-async.rs b/src/test/ui/drop/dynamic-drop-async.rs index c0bf0bdf731e6..a952fe8e76e81 100644 --- a/src/test/ui/drop/dynamic-drop-async.rs +++ b/src/test/ui/drop/dynamic-drop-async.rs @@ -43,6 +43,7 @@ impl Future for Defer { /// The `failing_op`-th operation will panic. struct Allocator { data: RefCell>, + name: &'static str, failing_op: usize, cur_ops: Cell, } @@ -54,40 +55,45 @@ impl Drop for Allocator { fn drop(&mut self) { let data = self.data.borrow(); if data.iter().any(|d| *d) { - panic!("missing free: {:?}", data); + panic!("missing free in {:?}: {:?}", self.name, data); } } } impl Allocator { - fn new(failing_op: usize) -> Self { - Allocator { failing_op, cur_ops: Cell::new(0), data: RefCell::new(vec![]) } + fn new(failing_op: usize, name: &'static str) -> Self { + Allocator { + failing_op, + name, + cur_ops: Cell::new(0), + data: RefCell::new(vec![]), + } } - fn alloc(&self) -> impl Future> + '_ { + fn alloc(self: &Rc) -> impl Future + 'static { self.fallible_operation(); let mut data = self.data.borrow_mut(); let addr = data.len(); data.push(true); - Defer { ready: false, value: Some(Ptr(addr, self)) } + Defer { ready: false, value: Some(Ptr(addr, self.clone())) } } fn fallible_operation(&self) { self.cur_ops.set(self.cur_ops.get() + 1); if self.cur_ops.get() == self.failing_op { - panic::panic_any(InjectedFailure); + panic!(InjectedFailure); } } } // Type that tracks whether it was dropped and can panic when it's created or // destroyed. -struct Ptr<'a>(usize, &'a Allocator); -impl<'a> Drop for Ptr<'a> { +struct Ptr(usize, Rc); +impl Drop for Ptr { fn drop(&mut self) { match self.1.data.borrow_mut()[self.0] { - false => panic!("double free at index {:?}", self.0), + false => panic!("double free in {:?} at index {:?}", self.1.name, self.0), ref mut d => *d = false, } @@ -111,7 +117,7 @@ async fn dynamic_drop(a: Rc, c: bool) { }; } -struct TwoPtrs<'a>(Ptr<'a>, Ptr<'a>); +struct TwoPtrs(Ptr, Ptr); async fn struct_dynamic_drop(a: Rc, c0: bool, c1: bool, c: bool) { for i in 0..2 { let x; @@ -232,21 +238,62 @@ async fn move_ref_pattern(a: Rc) { a.alloc().await; } -fn run_test(cx: &mut Context<'_>, ref f: F) +async fn panic_after_return(a: Rc, c: bool) -> (Ptr,) { + a.alloc().await; + let p = a.alloc().await; + if c { + a.alloc().await; + let q = a.alloc().await; + // We use a return type that isn't used anywhere else to make sure that + // the return place doesn't incorrectly end up in the generator state. + return (a.alloc().await,); + } + (a.alloc().await,) +} + + +async fn panic_after_init_by_loop(a: Rc) { + a.alloc().await; + let p = a.alloc().await; + let q = loop { + a.alloc().await; + let r = a.alloc().await; + break a.alloc().await; + }; +} + +async fn panic_after_init_by_match_with_bindings_and_guard(a: Rc, b: bool) { + a.alloc().await; + let p = a.alloc().await; + let q = match a.alloc().await { + ref _x if b => { + a.alloc().await; + let r = a.alloc().await; + a.alloc().await + } + _x => { + a.alloc().await; + let r = a.alloc().await; + a.alloc().await + }, + }; +} + +fn run_test(cx: &mut Context<'_>, ref f: F, name: &'static str) where F: Fn(Rc) -> G, - G: Future, + G: Future, { for polls in 0.. { // Run without any panics to find which operations happen after the // penultimate `poll`. - let first_alloc = Rc::new(Allocator::new(usize::MAX)); + let first_alloc = Rc::new(Allocator::new(usize::MAX, name)); let mut fut = Box::pin(f(first_alloc.clone())); let mut ops_before_last_poll = 0; let mut completed = false; for _ in 0..polls { ops_before_last_poll = first_alloc.cur_ops.get(); - if let Poll::Ready(()) = fut.as_mut().poll(cx) { + if let Poll::Ready(_) = fut.as_mut().poll(cx) { completed = true; } } @@ -255,7 +302,7 @@ where // Start at `ops_before_last_poll` so that we will always be able to // `poll` the expected number of times. for failing_op in ops_before_last_poll..first_alloc.cur_ops.get() { - let alloc = Rc::new(Allocator::new(failing_op + 1)); + let alloc = Rc::new(Allocator::new(failing_op + 1, name)); let f = &f; let cx = &mut *cx; let result = panic::catch_unwind(panic::AssertUnwindSafe(move || { @@ -285,48 +332,58 @@ fn clone_waker(data: *const ()) -> RawWaker { RawWaker::new(data, &RawWakerVTable::new(clone_waker, drop, drop, drop)) } +macro_rules! run_test { + ($ctxt:expr, $e:expr) => { run_test($ctxt, $e, stringify!($e)); }; +} + fn main() { let waker = unsafe { Waker::from_raw(clone_waker(ptr::null())) }; let context = &mut Context::from_waker(&waker); - run_test(context, |a| dynamic_init(a, false)); - run_test(context, |a| dynamic_init(a, true)); - run_test(context, |a| dynamic_drop(a, false)); - run_test(context, |a| dynamic_drop(a, true)); - - run_test(context, |a| assignment(a, false, false)); - run_test(context, |a| assignment(a, false, true)); - run_test(context, |a| assignment(a, true, false)); - run_test(context, |a| assignment(a, true, true)); - - run_test(context, |a| array_simple(a)); - run_test(context, |a| vec_simple(a)); - run_test(context, |a| vec_unreachable(a)); - - run_test(context, |a| struct_dynamic_drop(a, false, false, false)); - run_test(context, |a| struct_dynamic_drop(a, false, false, true)); - run_test(context, |a| struct_dynamic_drop(a, false, true, false)); - run_test(context, |a| struct_dynamic_drop(a, false, true, true)); - run_test(context, |a| struct_dynamic_drop(a, true, false, false)); - run_test(context, |a| struct_dynamic_drop(a, true, false, true)); - run_test(context, |a| struct_dynamic_drop(a, true, true, false)); - run_test(context, |a| struct_dynamic_drop(a, true, true, true)); - - run_test(context, |a| field_assignment(a, false)); - run_test(context, |a| field_assignment(a, true)); - - run_test(context, |a| mixed_drop_and_nondrop(a)); - - run_test(context, |a| slice_pattern_one_of(a, 0)); - run_test(context, |a| slice_pattern_one_of(a, 1)); - run_test(context, |a| slice_pattern_one_of(a, 2)); - run_test(context, |a| slice_pattern_one_of(a, 3)); - - run_test(context, |a| subslice_pattern_from_end_with_drop(a, true, true)); - run_test(context, |a| subslice_pattern_from_end_with_drop(a, true, false)); - run_test(context, |a| subslice_pattern_from_end_with_drop(a, false, true)); - run_test(context, |a| subslice_pattern_from_end_with_drop(a, false, false)); - run_test(context, |a| subslice_pattern_reassign(a)); - - run_test(context, |a| move_ref_pattern(a)); + run_test!(context, |a| dynamic_init(a, false)); + run_test!(context, |a| dynamic_init(a, true)); + run_test!(context, |a| dynamic_drop(a, false)); + run_test!(context, |a| dynamic_drop(a, true)); + + run_test!(context, |a| assignment(a, false, false)); + run_test!(context, |a| assignment(a, false, true)); + run_test!(context, |a| assignment(a, true, false)); + run_test!(context, |a| assignment(a, true, true)); + + run_test!(context, |a| array_simple(a)); + run_test!(context, |a| vec_simple(a)); + run_test!(context, |a| vec_unreachable(a)); + + run_test!(context, |a| struct_dynamic_drop(a, false, false, false)); + run_test!(context, |a| struct_dynamic_drop(a, false, false, true)); + run_test!(context, |a| struct_dynamic_drop(a, false, true, false)); + run_test!(context, |a| struct_dynamic_drop(a, false, true, true)); + run_test!(context, |a| struct_dynamic_drop(a, true, false, false)); + run_test!(context, |a| struct_dynamic_drop(a, true, false, true)); + run_test!(context, |a| struct_dynamic_drop(a, true, true, false)); + run_test!(context, |a| struct_dynamic_drop(a, true, true, true)); + + run_test!(context, |a| field_assignment(a, false)); + run_test!(context, |a| field_assignment(a, true)); + + run_test!(context, |a| mixed_drop_and_nondrop(a)); + + run_test!(context, |a| slice_pattern_one_of(a, 0)); + run_test!(context, |a| slice_pattern_one_of(a, 1)); + run_test!(context, |a| slice_pattern_one_of(a, 2)); + run_test!(context, |a| slice_pattern_one_of(a, 3)); + + run_test!(context, |a| subslice_pattern_from_end_with_drop(a, true, true)); + run_test!(context, |a| subslice_pattern_from_end_with_drop(a, true, false)); + run_test!(context, |a| subslice_pattern_from_end_with_drop(a, false, true)); + run_test!(context, |a| subslice_pattern_from_end_with_drop(a, false, false)); + run_test!(context, |a| subslice_pattern_reassign(a)); + + run_test!(context, |a| move_ref_pattern(a)); + + run_test!(context, |a| panic_after_return(a, false)); + run_test!(context, |a| panic_after_return(a, true)); + run_test!(context, |a| panic_after_init_by_loop(a)); + run_test!(context, |a| panic_after_init_by_match_with_bindings_and_guard(a, false)); + run_test!(context, |a| panic_after_init_by_match_with_bindings_and_guard(a, true)); } diff --git a/src/test/ui/drop/dynamic-drop.rs b/src/test/ui/drop/dynamic-drop.rs index e90ea1c55b0c1..ddccee20e12a6 100644 --- a/src/test/ui/drop/dynamic-drop.rs +++ b/src/test/ui/drop/dynamic-drop.rs @@ -3,7 +3,6 @@ #![feature(generators, generator_trait)] #![feature(bindings_after_at)] - #![allow(unused_assignments)] #![allow(unused_variables)] @@ -17,6 +16,7 @@ struct InjectedFailure; struct Allocator { data: RefCell>, + name: &'static str, failing_op: usize, cur_ops: Cell, } @@ -28,24 +28,25 @@ impl Drop for Allocator { fn drop(&mut self) { let data = self.data.borrow(); if data.iter().any(|d| *d) { - panic!("missing free: {:?}", data); + panic!("missing free in {:?}: {:?}", self.name, data); } } } impl Allocator { - fn new(failing_op: usize) -> Self { + fn new(failing_op: usize, name: &'static str) -> Self { Allocator { failing_op: failing_op, cur_ops: Cell::new(0), - data: RefCell::new(vec![]) + data: RefCell::new(vec![]), + name, } } fn alloc(&self) -> Ptr<'_> { self.cur_ops.set(self.cur_ops.get() + 1); if self.cur_ops.get() == self.failing_op { - panic::panic_any(InjectedFailure); + panic!(InjectedFailure); } let mut data = self.data.borrow_mut(); @@ -53,36 +54,20 @@ impl Allocator { data.push(true); Ptr(addr, self) } - // FIXME(#47949) Any use of this indicates a bug in rustc: we should never - // be leaking values in the cases here. - // - // Creates a `Ptr<'_>` and checks that the allocated value is leaked if the - // `failing_op` is in the list of exception. - fn alloc_leaked(&self, exceptions: Vec) -> Ptr<'_> { - let ptr = self.alloc(); - - if exceptions.iter().any(|operation| *operation == self.failing_op) { - let mut data = self.data.borrow_mut(); - data[ptr.0] = false; - } - ptr - } } struct Ptr<'a>(usize, &'a Allocator); impl<'a> Drop for Ptr<'a> { fn drop(&mut self) { match self.1.data.borrow_mut()[self.0] { - false => { - panic!("double free at index {:?}", self.0) - } - ref mut d => *d = false + false => panic!("double free in {:?} at index {:?}", self.1.name, self.0), + ref mut d => *d = false, } - self.1.cur_ops.set(self.1.cur_ops.get()+1); + self.1.cur_ops.set(self.1.cur_ops.get() + 1); if self.1.cur_ops.get() == self.1.failing_op { - panic::panic_any(InjectedFailure); + panic!(InjectedFailure); } } } @@ -177,11 +162,7 @@ fn generator(a: &Allocator, run_count: usize) { assert!(run_count < 4); let mut gen = || { - (a.alloc(), - yield a.alloc(), - a.alloc(), - yield a.alloc() - ); + (a.alloc(), yield a.alloc(), a.alloc(), yield a.alloc()); }; for _ in 0..run_count { Pin::new(&mut gen).resume(()); @@ -205,28 +186,40 @@ fn vec_unreachable(a: &Allocator) { } fn slice_pattern_first(a: &Allocator) { - let[_x, ..] = [a.alloc(), a.alloc(), a.alloc()]; + let [_x, ..] = [a.alloc(), a.alloc(), a.alloc()]; } fn slice_pattern_middle(a: &Allocator) { - let[_, _x, _] = [a.alloc(), a.alloc(), a.alloc()]; + let [_, _x, _] = [a.alloc(), a.alloc(), a.alloc()]; } fn slice_pattern_two(a: &Allocator) { - let[_x, _, _y, _] = [a.alloc(), a.alloc(), a.alloc(), a.alloc()]; + let [_x, _, _y, _] = [a.alloc(), a.alloc(), a.alloc(), a.alloc()]; } fn slice_pattern_last(a: &Allocator) { - let[.., _y] = [a.alloc(), a.alloc(), a.alloc(), a.alloc()]; + let [.., _y] = [a.alloc(), a.alloc(), a.alloc(), a.alloc()]; } fn slice_pattern_one_of(a: &Allocator, i: usize) { let array = [a.alloc(), a.alloc(), a.alloc(), a.alloc()]; let _x = match i { - 0 => { let [a, ..] = array; a } - 1 => { let [_, a, ..] = array; a } - 2 => { let [_, _, a, _] = array; a } - 3 => { let [_, _, _, a] = array; a } + 0 => { + let [a, ..] = array; + a + } + 1 => { + let [_, a, ..] = array; + a + } + 2 => { + let [_, _, a, _] = array; + a + } + 3 => { + let [_, _, _, a] = array; + a + } _ => panic!("unmatched"), }; } @@ -234,9 +227,9 @@ fn slice_pattern_one_of(a: &Allocator, i: usize) { fn subslice_pattern_from_end(a: &Allocator, arg: bool) { let a = [a.alloc(), a.alloc(), a.alloc()]; if arg { - let[.., _x, _] = a; + let [.., _x, _] = a; } else { - let[_, _y @ ..] = a; + let [_, _y @ ..] = a; } } @@ -248,45 +241,61 @@ fn subslice_pattern_from_end_with_drop(a: &Allocator, arg: bool, arg2: bool) { } if arg { - let[.., _x, _] = a; + let [.., _x, _] = a; } else { - let[_, _y @ ..] = a; + let [_, _y @ ..] = a; } } fn slice_pattern_reassign(a: &Allocator) { let mut ar = [a.alloc(), a.alloc()]; - let[_, _x] = ar; + let [_, _x] = ar; ar = [a.alloc(), a.alloc()]; - let[.., _y] = ar; + let [.., _y] = ar; } fn subslice_pattern_reassign(a: &Allocator) { let mut ar = [a.alloc(), a.alloc(), a.alloc()]; - let[_, _, _x] = ar; + let [_, _, _x] = ar; ar = [a.alloc(), a.alloc(), a.alloc()]; - let[_, _y @ ..] = ar; + let [_, _y @ ..] = ar; } fn index_field_mixed_ends(a: &Allocator) { let ar = [(a.alloc(), a.alloc()), (a.alloc(), a.alloc())]; - let[(_x, _), ..] = ar; - let[(_, _y), _] = ar; - let[_, (_, _w)] = ar; - let[.., (_z, _)] = ar; + let [(_x, _), ..] = ar; + let [(_, _y), _] = ar; + let [_, (_, _w)] = ar; + let [.., (_z, _)] = ar; } fn subslice_mixed_min_lengths(a: &Allocator, c: i32) { let ar = [(a.alloc(), a.alloc()), (a.alloc(), a.alloc())]; match c { - 0 => { let[_x, ..] = ar; } - 1 => { let[_x, _, ..] = ar; } - 2 => { let[_x, _] = ar; } - 3 => { let[(_x, _), _, ..] = ar; } - 4 => { let[.., (_x, _)] = ar; } - 5 => { let[.., (_x, _), _] = ar; } - 6 => { let [_y @ ..] = ar; } - _ => { let [_y @ .., _] = ar; } + 0 => { + let [_x, ..] = ar; + } + 1 => { + let [_x, _, ..] = ar; + } + 2 => { + let [_x, _] = ar; + } + 3 => { + let [(_x, _), _, ..] = ar; + } + 4 => { + let [.., (_x, _)] = ar; + } + 5 => { + let [.., (_x, _), _] = ar; + } + 6 => { + let [_y @ ..] = ar; + } + _ => { + let [_y @ .., _] = ar; + } } } @@ -334,87 +343,160 @@ fn move_ref_pattern(a: &Allocator) { } fn panic_after_return(a: &Allocator) -> Ptr<'_> { - // Panic in the drop of `p` or `q` can leak - let exceptions = vec![8, 9]; a.alloc(); let p = a.alloc(); { a.alloc(); let p = a.alloc(); - // FIXME (#47949) We leak values when we panic in a destructor after - // evaluating an expression with `rustc_mir::build::Builder::into`. - a.alloc_leaked(exceptions) + a.alloc() } } fn panic_after_return_expr(a: &Allocator) -> Ptr<'_> { - // Panic in the drop of `p` or `q` can leak - let exceptions = vec![8, 9]; a.alloc(); let p = a.alloc(); { a.alloc(); let q = a.alloc(); - // FIXME (#47949) - return a.alloc_leaked(exceptions); + return a.alloc(); } } fn panic_after_init(a: &Allocator) { - // Panic in the drop of `r` can leak - let exceptions = vec![8]; a.alloc(); let p = a.alloc(); let q = { a.alloc(); let r = a.alloc(); - // FIXME (#47949) - a.alloc_leaked(exceptions) + a.alloc() }; } fn panic_after_init_temp(a: &Allocator) { - // Panic in the drop of `r` can leak - let exceptions = vec![8]; a.alloc(); let p = a.alloc(); { a.alloc(); let r = a.alloc(); - // FIXME (#47949) - a.alloc_leaked(exceptions) + a.alloc() }; } fn panic_after_init_by_loop(a: &Allocator) { - // Panic in the drop of `r` can leak - let exceptions = vec![8]; a.alloc(); let p = a.alloc(); let q = loop { a.alloc(); let r = a.alloc(); - // FIXME (#47949) - break a.alloc_leaked(exceptions); + break a.alloc(); + }; +} + +fn panic_after_init_by_match(a: &Allocator, b: bool) { + a.alloc(); + let p = a.alloc(); + let _ = loop { + let q = match b { + true => { + a.alloc(); + let r = a.alloc(); + a.alloc() + } + false => { + a.alloc(); + let r = a.alloc(); + break a.alloc(); + } + }; + return; + }; +} + +fn panic_after_init_by_match_with_guard(a: &Allocator, b: bool) { + a.alloc(); + let p = a.alloc(); + let q = match a.alloc() { + _ if b => { + a.alloc(); + let r = a.alloc(); + a.alloc() + } + _ => { + a.alloc(); + let r = a.alloc(); + a.alloc() + } + }; +} + +fn panic_after_init_by_match_with_bindings_and_guard(a: &Allocator, b: bool) { + a.alloc(); + let p = a.alloc(); + let q = match a.alloc() { + _x if b => { + a.alloc(); + let r = a.alloc(); + a.alloc() + } + _x => { + a.alloc(); + let r = a.alloc(); + a.alloc() + } + }; +} + +fn panic_after_init_by_match_with_ref_bindings_and_guard(a: &Allocator, b: bool) { + a.alloc(); + let p = a.alloc(); + let q = match a.alloc() { + ref _x if b => { + a.alloc(); + let r = a.alloc(); + a.alloc() + } + ref _x => { + a.alloc(); + let r = a.alloc(); + a.alloc() + } + }; +} + +fn panic_after_init_by_break_if(a: &Allocator, b: bool) { + a.alloc(); + let p = a.alloc(); + let q = loop { + let r = a.alloc(); + break if b { + let s = a.alloc(); + a.alloc() + } else { + a.alloc() + }; }; } -fn run_test(mut f: F) - where F: FnMut(&Allocator) +fn run_test(mut f: F, name: &'static str) +where + F: FnMut(&Allocator), { - let first_alloc = Allocator::new(usize::MAX); + let first_alloc = Allocator::new(usize::MAX, name); f(&first_alloc); - for failing_op in 1..first_alloc.cur_ops.get()+1 { - let alloc = Allocator::new(failing_op); + for failing_op in 1..first_alloc.cur_ops.get() + 1 { + let alloc = Allocator::new(failing_op, name); let alloc = &alloc; let f = panic::AssertUnwindSafe(&mut f); let result = panic::catch_unwind(move || { f.0(alloc); }); match result { - Ok(..) => panic!("test executed {} ops but now {}", - first_alloc.cur_ops.get(), alloc.cur_ops.get()), + Ok(..) => panic!( + "test executed {} ops but now {}", + first_alloc.cur_ops.get(), + alloc.cur_ops.get() + ), Err(e) => { if e.downcast_ref::().is_none() { panic::resume_unwind(e); @@ -424,98 +506,115 @@ fn run_test(mut f: F) } } -fn run_test_nopanic(mut f: F) - where F: FnMut(&Allocator) +fn run_test_nopanic(mut f: F, name: &'static str) +where + F: FnMut(&Allocator), { - let first_alloc = Allocator::new(usize::MAX); + let first_alloc = Allocator::new(usize::MAX, name); f(&first_alloc); } +macro_rules! run_test { + ($e:expr) => { + run_test($e, stringify!($e)); + }; +} + fn main() { - run_test(|a| dynamic_init(a, false)); - run_test(|a| dynamic_init(a, true)); - run_test(|a| dynamic_drop(a, false)); - run_test(|a| dynamic_drop(a, true)); - - run_test(|a| assignment2(a, false, false)); - run_test(|a| assignment2(a, false, true)); - run_test(|a| assignment2(a, true, false)); - run_test(|a| assignment2(a, true, true)); - - run_test(|a| assignment1(a, false)); - run_test(|a| assignment1(a, true)); - - run_test(|a| array_simple(a)); - run_test(|a| vec_simple(a)); - run_test(|a| vec_unreachable(a)); - - run_test(|a| struct_dynamic_drop(a, false, false, false)); - run_test(|a| struct_dynamic_drop(a, false, false, true)); - run_test(|a| struct_dynamic_drop(a, false, true, false)); - run_test(|a| struct_dynamic_drop(a, false, true, true)); - run_test(|a| struct_dynamic_drop(a, true, false, false)); - run_test(|a| struct_dynamic_drop(a, true, false, true)); - run_test(|a| struct_dynamic_drop(a, true, true, false)); - run_test(|a| struct_dynamic_drop(a, true, true, true)); - - run_test(|a| field_assignment(a, false)); - run_test(|a| field_assignment(a, true)); - - run_test(|a| generator(a, 0)); - run_test(|a| generator(a, 1)); - run_test(|a| generator(a, 2)); - run_test(|a| generator(a, 3)); - - run_test(|a| mixed_drop_and_nondrop(a)); - - run_test(|a| slice_pattern_first(a)); - run_test(|a| slice_pattern_middle(a)); - run_test(|a| slice_pattern_two(a)); - run_test(|a| slice_pattern_last(a)); - run_test(|a| slice_pattern_one_of(a, 0)); - run_test(|a| slice_pattern_one_of(a, 1)); - run_test(|a| slice_pattern_one_of(a, 2)); - run_test(|a| slice_pattern_one_of(a, 3)); - - run_test(|a| subslice_pattern_from_end(a, true)); - run_test(|a| subslice_pattern_from_end(a, false)); - run_test(|a| subslice_pattern_from_end_with_drop(a, true, true)); - run_test(|a| subslice_pattern_from_end_with_drop(a, true, false)); - run_test(|a| subslice_pattern_from_end_with_drop(a, false, true)); - run_test(|a| subslice_pattern_from_end_with_drop(a, false, false)); - run_test(|a| slice_pattern_reassign(a)); - run_test(|a| subslice_pattern_reassign(a)); - - run_test(|a| index_field_mixed_ends(a)); - run_test(|a| subslice_mixed_min_lengths(a, 0)); - run_test(|a| subslice_mixed_min_lengths(a, 1)); - run_test(|a| subslice_mixed_min_lengths(a, 2)); - run_test(|a| subslice_mixed_min_lengths(a, 3)); - run_test(|a| subslice_mixed_min_lengths(a, 4)); - run_test(|a| subslice_mixed_min_lengths(a, 5)); - run_test(|a| subslice_mixed_min_lengths(a, 6)); - run_test(|a| subslice_mixed_min_lengths(a, 7)); - - run_test(|a| move_ref_pattern(a)); - - run_test(|a| { + run_test!(|a| dynamic_init(a, false)); + run_test!(|a| dynamic_init(a, true)); + run_test!(|a| dynamic_drop(a, false)); + run_test!(|a| dynamic_drop(a, true)); + + run_test!(|a| assignment2(a, false, false)); + run_test!(|a| assignment2(a, false, true)); + run_test!(|a| assignment2(a, true, false)); + run_test!(|a| assignment2(a, true, true)); + + run_test!(|a| assignment1(a, false)); + run_test!(|a| assignment1(a, true)); + + run_test!(|a| array_simple(a)); + run_test!(|a| vec_simple(a)); + run_test!(|a| vec_unreachable(a)); + + run_test!(|a| struct_dynamic_drop(a, false, false, false)); + run_test!(|a| struct_dynamic_drop(a, false, false, true)); + run_test!(|a| struct_dynamic_drop(a, false, true, false)); + run_test!(|a| struct_dynamic_drop(a, false, true, true)); + run_test!(|a| struct_dynamic_drop(a, true, false, false)); + run_test!(|a| struct_dynamic_drop(a, true, false, true)); + run_test!(|a| struct_dynamic_drop(a, true, true, false)); + run_test!(|a| struct_dynamic_drop(a, true, true, true)); + + run_test!(|a| field_assignment(a, false)); + run_test!(|a| field_assignment(a, true)); + + run_test!(|a| generator(a, 0)); + run_test!(|a| generator(a, 1)); + run_test!(|a| generator(a, 2)); + run_test!(|a| generator(a, 3)); + + run_test!(|a| mixed_drop_and_nondrop(a)); + + run_test!(|a| slice_pattern_first(a)); + run_test!(|a| slice_pattern_middle(a)); + run_test!(|a| slice_pattern_two(a)); + run_test!(|a| slice_pattern_last(a)); + run_test!(|a| slice_pattern_one_of(a, 0)); + run_test!(|a| slice_pattern_one_of(a, 1)); + run_test!(|a| slice_pattern_one_of(a, 2)); + run_test!(|a| slice_pattern_one_of(a, 3)); + + run_test!(|a| subslice_pattern_from_end(a, true)); + run_test!(|a| subslice_pattern_from_end(a, false)); + run_test!(|a| subslice_pattern_from_end_with_drop(a, true, true)); + run_test!(|a| subslice_pattern_from_end_with_drop(a, true, false)); + run_test!(|a| subslice_pattern_from_end_with_drop(a, false, true)); + run_test!(|a| subslice_pattern_from_end_with_drop(a, false, false)); + run_test!(|a| slice_pattern_reassign(a)); + run_test!(|a| subslice_pattern_reassign(a)); + + run_test!(|a| index_field_mixed_ends(a)); + run_test!(|a| subslice_mixed_min_lengths(a, 0)); + run_test!(|a| subslice_mixed_min_lengths(a, 1)); + run_test!(|a| subslice_mixed_min_lengths(a, 2)); + run_test!(|a| subslice_mixed_min_lengths(a, 3)); + run_test!(|a| subslice_mixed_min_lengths(a, 4)); + run_test!(|a| subslice_mixed_min_lengths(a, 5)); + run_test!(|a| subslice_mixed_min_lengths(a, 6)); + run_test!(|a| subslice_mixed_min_lengths(a, 7)); + + run_test!(|a| move_ref_pattern(a)); + + run_test!(|a| { panic_after_return(a); }); - run_test(|a| { + run_test!(|a| { panic_after_return_expr(a); }); - run_test(|a| panic_after_init(a)); - run_test(|a| panic_after_init_temp(a)); - run_test(|a| panic_after_init_by_loop(a)); - - run_test(|a| bindings_after_at_dynamic_init_move(a, true)); - run_test(|a| bindings_after_at_dynamic_init_move(a, false)); - run_test(|a| bindings_after_at_dynamic_init_ref(a, true)); - run_test(|a| bindings_after_at_dynamic_init_ref(a, false)); - run_test(|a| bindings_after_at_dynamic_drop_move(a, true)); - run_test(|a| bindings_after_at_dynamic_drop_move(a, false)); - run_test(|a| bindings_after_at_dynamic_drop_ref(a, true)); - run_test(|a| bindings_after_at_dynamic_drop_ref(a, false)); - - run_test_nopanic(|a| union1(a)); + run_test!(|a| panic_after_init(a)); + run_test!(|a| panic_after_init_temp(a)); + run_test!(|a| panic_after_init_by_loop(a)); + run_test!(|a| panic_after_init_by_match(a, false)); + run_test!(|a| panic_after_init_by_match(a, true)); + run_test!(|a| panic_after_init_by_match_with_guard(a, false)); + run_test!(|a| panic_after_init_by_match_with_guard(a, true)); + run_test!(|a| panic_after_init_by_match_with_bindings_and_guard(a, false)); + run_test!(|a| panic_after_init_by_match_with_bindings_and_guard(a, true)); + run_test!(|a| panic_after_init_by_match_with_ref_bindings_and_guard(a, false)); + run_test!(|a| panic_after_init_by_match_with_ref_bindings_and_guard(a, true)); + run_test!(|a| panic_after_init_by_break_if(a, false)); + run_test!(|a| panic_after_init_by_break_if(a, true)); + + run_test!(|a| bindings_after_at_dynamic_init_move(a, true)); + run_test!(|a| bindings_after_at_dynamic_init_move(a, false)); + run_test!(|a| bindings_after_at_dynamic_init_ref(a, true)); + run_test!(|a| bindings_after_at_dynamic_init_ref(a, false)); + run_test!(|a| bindings_after_at_dynamic_drop_move(a, true)); + run_test!(|a| bindings_after_at_dynamic_drop_move(a, false)); + run_test!(|a| bindings_after_at_dynamic_drop_ref(a, true)); + run_test!(|a| bindings_after_at_dynamic_drop_ref(a, false)); + + run_test_nopanic(|a| union1(a), "|a| union1(a)"); } diff --git a/src/test/ui/error-codes/E0396-fixed.rs b/src/test/ui/error-codes/E0396-fixed.rs index 76dd857ea5616..1029c75f17d2e 100644 --- a/src/test/ui/error-codes/E0396-fixed.rs +++ b/src/test/ui/error-codes/E0396-fixed.rs @@ -4,7 +4,6 @@ const REG_ADDR: *const u8 = 0x5f3759df as *const u8; const VALUE: u8 = unsafe { *REG_ADDR }; //~^ ERROR any use of this value will cause an error -//~| WARN this was previously accepted by the compiler but is being phased out fn main() { } diff --git a/src/test/ui/error-codes/E0396-fixed.stderr b/src/test/ui/error-codes/E0396-fixed.stderr index 521394bdc8e01..685055525627e 100644 --- a/src/test/ui/error-codes/E0396-fixed.stderr +++ b/src/test/ui/error-codes/E0396-fixed.stderr @@ -7,8 +7,6 @@ LL | const VALUE: u8 = unsafe { *REG_ADDR }; | unable to turn bytes into a pointer | = note: `#[deny(const_err)]` 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 #71800 error: aborting due to previous error diff --git a/src/test/ui/cast/fat-ptr-cast-rpass.rs b/src/test/ui/fat-ptr-cast-rpass.rs similarity index 100% rename from src/test/ui/cast/fat-ptr-cast-rpass.rs rename to src/test/ui/fat-ptr-cast-rpass.rs diff --git a/src/test/ui/cast/fat-ptr-cast.rs b/src/test/ui/fat-ptr-cast.rs similarity index 100% rename from src/test/ui/cast/fat-ptr-cast.rs rename to src/test/ui/fat-ptr-cast.rs diff --git a/src/test/ui/cast/fat-ptr-cast.stderr b/src/test/ui/fat-ptr-cast.stderr similarity index 100% rename from src/test/ui/cast/fat-ptr-cast.stderr rename to src/test/ui/fat-ptr-cast.stderr diff --git a/src/test/ui/feature-gates/feature-gate-exhaustive-patterns.stderr b/src/test/ui/feature-gates/feature-gate-exhaustive-patterns.stderr index e079c2ddcee26..055475952340e 100644 --- a/src/test/ui/feature-gates/feature-gate-exhaustive-patterns.stderr +++ b/src/test/ui/feature-gates/feature-gate-exhaustive-patterns.stderr @@ -11,7 +11,7 @@ LL | Err(#[stable(feature = "rust1", since = "1.0.0")] E), | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html - = note: the matched value is of type `Result` + = note: the matched value is of type `std::result::Result` help: you might want to use `if let` to ignore the variant that isn't matched | LL | if let Ok(_x) = foo() { /* */ } diff --git a/src/test/ui/feature-gates/feature-gate-relaxed_struct_unsize.rs b/src/test/ui/feature-gates/feature-gate-relaxed_struct_unsize.rs deleted file mode 100644 index 0cfd0a0b9784c..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-relaxed_struct_unsize.rs +++ /dev/null @@ -1,10 +0,0 @@ -// Test that we allow unsizing even if there is an unchanged param in the -// field getting unsized. -struct A(T, B); -struct B(T, U); - -fn main() { - let x: A<[u32; 1], [u32; 1]> = A([0; 1], B([0; 1], [0; 1])); - let y: &A<[u32; 1], [u32]> = &x; //~ ERROR mismatched types - assert_eq!(y.1.1.len(), 1); -} diff --git a/src/test/ui/feature-gates/feature-gate-relaxed_struct_unsize.stderr b/src/test/ui/feature-gates/feature-gate-relaxed_struct_unsize.stderr deleted file mode 100644 index f62def47726f9..0000000000000 --- a/src/test/ui/feature-gates/feature-gate-relaxed_struct_unsize.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/feature-gate-relaxed_struct_unsize.rs:8:34 - | -LL | let y: &A<[u32; 1], [u32]> = &x; - | ------------------- ^^ expected slice `[u32]`, found array `[u32; 1]` - | | - | expected due to this - | - = note: expected reference `&A<[u32; 1], [u32]>` - found reference `&A<[u32; 1], [u32; 1]>` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/feature-gates/issue-43106-gating-of-derive.rs b/src/test/ui/feature-gates/issue-43106-gating-of-derive.rs index 5404b8c04bb76..c5d9e0db4d389 100644 --- a/src/test/ui/feature-gates/issue-43106-gating-of-derive.rs +++ b/src/test/ui/feature-gates/issue-43106-gating-of-derive.rs @@ -6,7 +6,6 @@ mod derive { mod inner { #![derive(Debug)] } //~^ ERROR `derive` may only be applied to structs, enums and unions - //~| ERROR inner macro attributes are unstable #[derive(Debug)] //~^ ERROR `derive` may only be applied to structs, enums and unions diff --git a/src/test/ui/feature-gates/issue-43106-gating-of-derive.stderr b/src/test/ui/feature-gates/issue-43106-gating-of-derive.stderr index 9b1f4f46219d2..ffec76f409ef7 100644 --- a/src/test/ui/feature-gates/issue-43106-gating-of-derive.stderr +++ b/src/test/ui/feature-gates/issue-43106-gating-of-derive.stderr @@ -4,40 +4,30 @@ error[E0774]: `derive` may only be applied to structs, enums and unions LL | #[derive(Debug)] | ^^^^^^^^^^^^^^^^ -error[E0658]: inner macro attributes are unstable - --> $DIR/issue-43106-gating-of-derive.rs:7:20 - | -LL | mod inner { #![derive(Debug)] } - | ^^^^^^ - | - = note: see issue #54726 for more information - = help: add `#![feature(custom_inner_attributes)]` to the crate attributes to enable - error[E0774]: `derive` may only be applied to structs, enums and unions --> $DIR/issue-43106-gating-of-derive.rs:7:17 | LL | mod inner { #![derive(Debug)] } - | ^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^ help: try an outer attribute: `#[derive(Debug)]` error[E0774]: `derive` may only be applied to structs, enums and unions - --> $DIR/issue-43106-gating-of-derive.rs:11:5 + --> $DIR/issue-43106-gating-of-derive.rs:10:5 | LL | #[derive(Debug)] | ^^^^^^^^^^^^^^^^ error[E0774]: `derive` may only be applied to structs, enums and unions - --> $DIR/issue-43106-gating-of-derive.rs:24:5 + --> $DIR/issue-43106-gating-of-derive.rs:23:5 | LL | #[derive(Debug)] | ^^^^^^^^^^^^^^^^ error[E0774]: `derive` may only be applied to structs, enums and unions - --> $DIR/issue-43106-gating-of-derive.rs:28:5 + --> $DIR/issue-43106-gating-of-derive.rs:27:5 | LL | #[derive(Debug)] | ^^^^^^^^^^^^^^^^ -error: aborting due to 6 previous errors +error: aborting due to 5 previous errors -Some errors have detailed explanations: E0658, E0774. -For more information about an error, try `rustc --explain E0658`. +For more information about this error, try `rustc --explain E0774`. diff --git a/src/test/ui/fmt/format-args-capture.rs b/src/test/ui/fmt/format-args-capture.rs index 6c97a807b052b..4e3fa9a3c589a 100644 --- a/src/test/ui/fmt/format-args-capture.rs +++ b/src/test/ui/fmt/format-args-capture.rs @@ -5,7 +5,6 @@ fn main() { named_argument_takes_precedence_to_captured(); formatting_parameters_can_be_captured(); - capture_raw_strings_and_idents(); #[cfg(panic = "unwind")] { @@ -26,23 +25,13 @@ fn named_argument_takes_precedence_to_captured() { assert_eq!(&s, "positional-named-captured"); } -fn capture_raw_strings_and_idents() { - let r#type = "apple"; - let s = format!(r#"The fruit is an {type}"#); - assert_eq!(&s, "The fruit is an apple"); - - let r#type = "orange"; - let s = format!(r"The fruit is an {type}"); - assert_eq!(&s, "The fruit is an orange"); -} - #[cfg(panic = "unwind")] fn panic_with_single_argument_does_not_get_formatted() { // panic! with a single argument does not perform string formatting. // RFC #2795 suggests that this may need to change so that captured arguments are formatted. // For stability reasons this will need to part of an edition change. - #[allow(non_fmt_panic)] + #[allow(panic_fmt)] let msg = std::panic::catch_unwind(|| { panic!("{foo}"); }).unwrap_err(); diff --git a/src/test/ui/generator/ref-escapes-but-not-over-yield.stderr b/src/test/ui/generator/ref-escapes-but-not-over-yield.stderr index 5fc8100409822..9986220218e28 100644 --- a/src/test/ui/generator/ref-escapes-but-not-over-yield.stderr +++ b/src/test/ui/generator/ref-escapes-but-not-over-yield.stderr @@ -12,4 +12,3 @@ LL | a = &b; error: aborting due to previous error -For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/generator/type-mismatch-signature-deduction.stderr b/src/test/ui/generator/type-mismatch-signature-deduction.stderr index 30e23ea8f650c..4abc0542c5142 100644 --- a/src/test/ui/generator/type-mismatch-signature-deduction.stderr +++ b/src/test/ui/generator/type-mismatch-signature-deduction.stderr @@ -2,11 +2,11 @@ error[E0308]: mismatched types --> $DIR/type-mismatch-signature-deduction.rs:13:9 | LL | 5 - | ^ expected enum `Result`, found integer + | ^ expected enum `std::result::Result`, found integer | - = note: expected type `Result<{integer}, _>` + = note: expected type `std::result::Result<{integer}, _>` found type `{integer}` -note: return type inferred to be `Result<{integer}, _>` here +note: return type inferred to be `std::result::Result<{integer}, _>` here --> $DIR/type-mismatch-signature-deduction.rs:8:20 | LL | return Ok(6); @@ -16,9 +16,9 @@ error[E0271]: type mismatch resolving `<[generator@$DIR/type-mismatch-signature- --> $DIR/type-mismatch-signature-deduction.rs:5:13 | LL | fn foo() -> impl Generator { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `Result`, found `i32` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found `i32` | - = note: expected enum `Result<{integer}, _>` + = note: expected enum `std::result::Result<{integer}, _>` found type `i32` error: aborting due to 2 previous errors diff --git a/src/test/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.rs b/src/test/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.rs deleted file mode 100644 index 2c543455b6ebd..0000000000000 --- a/src/test/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![feature(generic_associated_types)] - //~^ WARNING: the feature `generic_associated_types` is incomplete - -trait X { - type Y<'x>; -} - -fn main() { - fn _f(arg : Box X = &'a [u32]>>) {} - //~^ ERROR: use of undeclared lifetime name `'x` - //~| ERROR: binding for associated type `Y` references lifetime -} diff --git a/src/test/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.stderr b/src/test/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.stderr deleted file mode 100644 index 1c7c107d78354..0000000000000 --- a/src/test/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.stderr +++ /dev/null @@ -1,29 +0,0 @@ -warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/gat-in-trait-path-undeclared-lifetime.rs:1:12 - | -LL | #![feature(generic_associated_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44265 for more information - -error[E0261]: use of undeclared lifetime name `'x` - --> $DIR/gat-in-trait-path-undeclared-lifetime.rs:9:35 - | -LL | fn _f(arg : Box X = &'a [u32]>>) {} - | - ^^ undeclared lifetime - | | - | help: consider introducing lifetime `'x` here: `<'x>` - | - = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes - -error[E0582]: binding for associated type `Y` references lifetime `'a`, which does not appear in the trait input types - --> $DIR/gat-in-trait-path-undeclared-lifetime.rs:9:33 - | -LL | fn _f(arg : Box X = &'a [u32]>>) {} - | ^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors; 1 warning emitted - -Some errors have detailed explanations: E0261, E0582. -For more information about an error, try `rustc --explain E0261`. diff --git a/src/test/ui/generic-associated-types/gat-in-trait-path.rs b/src/test/ui/generic-associated-types/gat-in-trait-path.rs deleted file mode 100644 index 2dbd1840dec55..0000000000000 --- a/src/test/ui/generic-associated-types/gat-in-trait-path.rs +++ /dev/null @@ -1,30 +0,0 @@ -// check-pass - -#![feature(generic_associated_types)] - //~^ WARNING: the feature `generic_associated_types` is incomplete -#![feature(associated_type_defaults)] - -trait Foo { - type A<'a> where Self: 'a; -} - -struct Fooy; - -impl Foo for Fooy { - type A<'a> = &'a (); -} - -#[derive(Clone)] -struct Fooer(T); - -impl Foo for Fooer { - type A<'x> where T: 'x = &'x (); -} - -fn f(_arg : Box Foo = &'a ()>>) {} - - -fn main() { - let foo = Fooer(5); - f(Box::new(foo)); -} diff --git a/src/test/ui/generic-associated-types/gat-in-trait-path.stderr b/src/test/ui/generic-associated-types/gat-in-trait-path.stderr deleted file mode 100644 index f3769827f04b2..0000000000000 --- a/src/test/ui/generic-associated-types/gat-in-trait-path.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/gat-in-trait-path.rs:3:12 - | -LL | #![feature(generic_associated_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44265 for more information - -warning: 1 warning emitted - diff --git a/src/test/ui/generic-associated-types/gat-trait-path-generic-type-arg.rs b/src/test/ui/generic-associated-types/gat-trait-path-generic-type-arg.rs deleted file mode 100644 index cff5a21052f9b..0000000000000 --- a/src/test/ui/generic-associated-types/gat-trait-path-generic-type-arg.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![feature(generic_associated_types)] - //~^ WARNING: the feature `generic_associated_types` is incomplete - -trait Foo { - type F<'a>; - - fn identity<'a>(t: &'a Self::F<'a>) -> &'a Self::F<'a> { t } -} - -impl Foo for T { - type F = &[u8]; - //~^ ERROR: the name `T1` is already used for - //~| ERROR: missing lifetime specifier -} - -fn main() {} diff --git a/src/test/ui/generic-associated-types/gat-trait-path-generic-type-arg.stderr b/src/test/ui/generic-associated-types/gat-trait-path-generic-type-arg.stderr deleted file mode 100644 index e83af1d0c739d..0000000000000 --- a/src/test/ui/generic-associated-types/gat-trait-path-generic-type-arg.stderr +++ /dev/null @@ -1,32 +0,0 @@ -error[E0403]: the name `T1` is already used for a generic parameter in this item's generic parameters - --> $DIR/gat-trait-path-generic-type-arg.rs:11:12 - | -LL | impl Foo for T { - | -- first use of `T1` -LL | type F = &[u8]; - | ^^ already used - -warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/gat-trait-path-generic-type-arg.rs:1:12 - | -LL | #![feature(generic_associated_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44265 for more information - -error[E0106]: missing lifetime specifier - --> $DIR/gat-trait-path-generic-type-arg.rs:11:18 - | -LL | type F = &[u8]; - | ^ expected named lifetime parameter - | -help: consider introducing a named lifetime parameter - | -LL | type F<'a, T1> = &'a [u8]; - | ^^^ ^^^ - -error: aborting due to 2 previous errors; 1 warning emitted - -Some errors have detailed explanations: E0106, E0403. -For more information about an error, try `rustc --explain E0106`. diff --git a/src/test/ui/generic-associated-types/gat-trait-path-missing-lifetime.rs b/src/test/ui/generic-associated-types/gat-trait-path-missing-lifetime.rs deleted file mode 100644 index e69e355ba48e5..0000000000000 --- a/src/test/ui/generic-associated-types/gat-trait-path-missing-lifetime.rs +++ /dev/null @@ -1,18 +0,0 @@ -#![feature(generic_associated_types)] - //~^ WARNING: the feature `generic_associated_types` is incomplete - -trait X { - type Y<'a>; - //~^ ERROR missing generics for - //~| ERROR missing generics for - - fn foo<'a>(t : Self::Y<'a>) -> Self::Y<'a> { t } -} - -impl X for T { - fn foo<'a, T1: X>(t : T1) -> T1::Y<'a> { - t - } -} - -fn main() {} diff --git a/src/test/ui/generic-associated-types/gat-trait-path-missing-lifetime.stderr b/src/test/ui/generic-associated-types/gat-trait-path-missing-lifetime.stderr deleted file mode 100644 index 9c6e2ce3e17a3..0000000000000 --- a/src/test/ui/generic-associated-types/gat-trait-path-missing-lifetime.stderr +++ /dev/null @@ -1,44 +0,0 @@ -warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/gat-trait-path-missing-lifetime.rs:1:12 - | -LL | #![feature(generic_associated_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44265 for more information - -error[E0107]: missing generics for associated type `X::Y` - --> $DIR/gat-trait-path-missing-lifetime.rs:5:8 - | -LL | type Y<'a>; - | ^ expected 1 lifetime argument - | -note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/gat-trait-path-missing-lifetime.rs:5:8 - | -LL | type Y<'a>; - | ^ -- -help: use angle brackets to add missing lifetime argument - | -LL | type Y<'a><'a>; - | ^^^^ - -error[E0107]: missing generics for associated type `X::Y` - --> $DIR/gat-trait-path-missing-lifetime.rs:5:8 - | -LL | type Y<'a>; - | ^ expected 1 lifetime argument - | -note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/gat-trait-path-missing-lifetime.rs:5:8 - | -LL | type Y<'a>; - | ^ -- -help: use angle brackets to add missing lifetime argument - | -LL | type Y<'a><'a>; - | ^^^^ - -error: aborting due to 2 previous errors; 1 warning emitted - -For more information about this error, try `rustc --explain E0107`. diff --git a/src/test/ui/generic-associated-types/gat-trait-path-parenthesised-args.rs b/src/test/ui/generic-associated-types/gat-trait-path-parenthesised-args.rs deleted file mode 100644 index bb1f27a17ca4c..0000000000000 --- a/src/test/ui/generic-associated-types/gat-trait-path-parenthesised-args.rs +++ /dev/null @@ -1,15 +0,0 @@ -#![feature(generic_associated_types)] - //~^ WARNING: the feature `generic_associated_types` is incomplete - -trait X { - type Y<'a>; - //~^ ERROR this associated type - //~| ERROR this associated type -} - -fn foo<'a>(arg: Box>) {} - //~^ ERROR: lifetime in trait object type must be followed by `+` - //~| ERROR: parenthesized generic arguments cannot be used - //~| WARNING: trait objects without an explicit `dyn` are deprecated - -fn main() {} diff --git a/src/test/ui/generic-associated-types/gat-trait-path-parenthesised-args.stderr b/src/test/ui/generic-associated-types/gat-trait-path-parenthesised-args.stderr deleted file mode 100644 index 20cb6d8828755..0000000000000 --- a/src/test/ui/generic-associated-types/gat-trait-path-parenthesised-args.stderr +++ /dev/null @@ -1,68 +0,0 @@ -error: lifetime in trait object type must be followed by `+` - --> $DIR/gat-trait-path-parenthesised-args.rs:10:29 - | -LL | fn foo<'a>(arg: Box>) {} - | ^^ - -error: parenthesized generic arguments cannot be used in associated type constraints - --> $DIR/gat-trait-path-parenthesised-args.rs:10:27 - | -LL | fn foo<'a>(arg: Box>) {} - | ^^^^^ - -warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/gat-trait-path-parenthesised-args.rs:1:12 - | -LL | #![feature(generic_associated_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44265 for more information - -warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/gat-trait-path-parenthesised-args.rs:10:29 - | -LL | fn foo<'a>(arg: Box>) {} - | ^^ help: use `dyn`: `dyn 'a` - | - = note: `#[warn(bare_trait_objects)]` on by default - -error[E0107]: this associated type takes 1 lifetime argument but 0 lifetime arguments were supplied - --> $DIR/gat-trait-path-parenthesised-args.rs:5:8 - | -LL | type Y<'a>; - | ^ expected 1 lifetime argument - | -note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/gat-trait-path-parenthesised-args.rs:5:8 - | -LL | type Y<'a>; - | ^ -- -help: add missing lifetime argument - | -LL | fn foo<'a>(arg: Box>) {} - | ^^ - -error[E0107]: this associated type takes 0 type arguments but 1 type argument was supplied - --> $DIR/gat-trait-path-parenthesised-args.rs:5:8 - | -LL | type Y<'a>; - | ________^- - | | | - | | expected 0 type arguments -LL | | -LL | | -LL | | } -LL | | -LL | | fn foo<'a>(arg: Box>) {} - | |_________________________________________- help: remove these generics - | -note: associated type defined here, with 0 type parameters - --> $DIR/gat-trait-path-parenthesised-args.rs:5:8 - | -LL | type Y<'a>; - | ^ - -error: aborting due to 4 previous errors; 2 warnings emitted - -For more information about this error, try `rustc --explain E0107`. diff --git a/src/test/ui/generic-associated-types/issue-67510-pass.rs b/src/test/ui/generic-associated-types/issue-67510-pass.rs deleted file mode 100644 index ff38b3e93eb1a..0000000000000 --- a/src/test/ui/generic-associated-types/issue-67510-pass.rs +++ /dev/null @@ -1,12 +0,0 @@ -// check-pass - -#![feature(generic_associated_types)] - //~^ WARNING: the feature `generic_associated_types` is incomplete - -trait X { - type Y<'a>; -} - -fn _func1<'a>(_x: Box=&'a ()>>) {} - -fn main() {} diff --git a/src/test/ui/generic-associated-types/issue-67510-pass.stderr b/src/test/ui/generic-associated-types/issue-67510-pass.stderr deleted file mode 100644 index 0fbf704df76a1..0000000000000 --- a/src/test/ui/generic-associated-types/issue-67510-pass.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-67510-pass.rs:3:12 - | -LL | #![feature(generic_associated_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44265 for more information - -warning: 1 warning emitted - diff --git a/src/test/ui/generic-associated-types/issue-67510.rs b/src/test/ui/generic-associated-types/issue-67510.rs deleted file mode 100644 index 62b22089f917c..0000000000000 --- a/src/test/ui/generic-associated-types/issue-67510.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![feature(generic_associated_types)] - //~^ WARNING: the feature `generic_associated_types` is incomplete - -trait X { - type Y<'a>; -} - -fn f(x: Box=&'a ()>>) {} - //~^ ERROR: use of undeclared lifetime name `'a` - //~| ERROR: use of undeclared lifetime name `'a` - - -fn main() {} diff --git a/src/test/ui/generic-associated-types/issue-67510.stderr b/src/test/ui/generic-associated-types/issue-67510.stderr deleted file mode 100644 index 12755c56974f2..0000000000000 --- a/src/test/ui/generic-associated-types/issue-67510.stderr +++ /dev/null @@ -1,32 +0,0 @@ -warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-67510.rs:1:12 - | -LL | #![feature(generic_associated_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44265 for more information - -error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/issue-67510.rs:8:21 - | -LL | fn f(x: Box=&'a ()>>) {} - | - ^^ undeclared lifetime - | | - | help: consider introducing lifetime `'a` here: `<'a>` - | - = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes - -error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/issue-67510.rs:8:26 - | -LL | fn f(x: Box=&'a ()>>) {} - | - ^^ undeclared lifetime - | | - | help: consider introducing lifetime `'a` here: `<'a>` - | - = help: if you want to experiment with in-band lifetime bindings, add `#![feature(in_band_lifetimes)]` to the crate attributes - -error: aborting due to 2 previous errors; 1 warning emitted - -For more information about this error, try `rustc --explain E0261`. diff --git a/src/test/ui/generic-associated-types/issue-68648-1.rs b/src/test/ui/generic-associated-types/issue-68648-1.rs deleted file mode 100644 index f294b22f73c67..0000000000000 --- a/src/test/ui/generic-associated-types/issue-68648-1.rs +++ /dev/null @@ -1,26 +0,0 @@ -// check-pass - -#![feature(generic_associated_types)] - //~^ WARNING: the feature `generic_associated_types` is incomplete - - -trait Fun { - type F<'a>; - - fn identity<'a>(t: Self::F<'a>) -> Self::F<'a> { t } -} - -impl Fun for T { - type F<'a> = Self; -} - -fn bug<'a, T: for<'b> Fun = T>>(t: T) -> T::F<'a> { - T::identity(t) -} - - -fn main() { - let x = 10; - - bug(x); -} diff --git a/src/test/ui/generic-associated-types/issue-68648-1.stderr b/src/test/ui/generic-associated-types/issue-68648-1.stderr deleted file mode 100644 index 322a8f9e13f81..0000000000000 --- a/src/test/ui/generic-associated-types/issue-68648-1.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-68648-1.rs:3:12 - | -LL | #![feature(generic_associated_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44265 for more information - -warning: 1 warning emitted - diff --git a/src/test/ui/generic-associated-types/issue-68648-2.rs b/src/test/ui/generic-associated-types/issue-68648-2.rs deleted file mode 100644 index e55bfcd4ba295..0000000000000 --- a/src/test/ui/generic-associated-types/issue-68648-2.rs +++ /dev/null @@ -1,24 +0,0 @@ -#![feature(generic_associated_types)] - //~^ WARNING: the feature `generic_associated_types` is incomplete - -trait Fun { - type F<'a>; - - fn identity<'a>(t: Self::F<'a>) -> Self::F<'a> { t } -} - -impl Fun for T { - type F<'a> = Self; -} - -fn bug<'a, T: Fun = T>>(t: T) -> T::F<'a> { - T::identity(()) - //~^ ERROR: mismatched types -} - - -fn main() { - let x = 10; - - bug(x); -} diff --git a/src/test/ui/generic-associated-types/issue-68648-2.stderr b/src/test/ui/generic-associated-types/issue-68648-2.stderr deleted file mode 100644 index b51e0bca9f7a9..0000000000000 --- a/src/test/ui/generic-associated-types/issue-68648-2.stderr +++ /dev/null @@ -1,23 +0,0 @@ -warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-68648-2.rs:1:12 - | -LL | #![feature(generic_associated_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44265 for more information - -error[E0308]: mismatched types - --> $DIR/issue-68648-2.rs:15:17 - | -LL | fn bug<'a, T: Fun = T>>(t: T) -> T::F<'a> { - | - this type parameter -LL | T::identity(()) - | ^^ expected type parameter `T`, found `()` - | - = note: expected type parameter `T` - found unit type `()` - -error: aborting due to previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/generic-associated-types/issue-68649-pass.rs b/src/test/ui/generic-associated-types/issue-68649-pass.rs deleted file mode 100644 index 396315302f74c..0000000000000 --- a/src/test/ui/generic-associated-types/issue-68649-pass.rs +++ /dev/null @@ -1,25 +0,0 @@ -// check-pass - -#![feature(generic_associated_types)] - //~^ WARNING: the feature `generic_associated_types` is incomplete - -trait Fun { - type F<'a>; - - fn identity<'a>(t: Self::F<'a>) -> Self::F<'a> { t } -} - -impl Fun for T { - type F<'a> = Self; -} - -fn bug<'a, T: Fun = T>>(t: T) -> T::F<'a> { - T::identity(t) -} - - -fn main() { - let x = 10; - - bug(x); -} diff --git a/src/test/ui/generic-associated-types/issue-68649-pass.stderr b/src/test/ui/generic-associated-types/issue-68649-pass.stderr deleted file mode 100644 index e4a2f8d2a6401..0000000000000 --- a/src/test/ui/generic-associated-types/issue-68649-pass.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-68649-pass.rs:3:12 - | -LL | #![feature(generic_associated_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44265 for more information - -warning: 1 warning emitted - diff --git a/src/test/ui/generic-associated-types/issue-74684-1.rs b/src/test/ui/generic-associated-types/issue-74684-1.rs deleted file mode 100644 index a483da863ff00..0000000000000 --- a/src/test/ui/generic-associated-types/issue-74684-1.rs +++ /dev/null @@ -1,26 +0,0 @@ -#![feature(generic_associated_types)] - //~^ WARNING: the feature `generic_associated_types` is incomplete - -trait Fun { - type F<'a>: ?Sized; - - fn identity<'a>(t: &'a Self::F<'a>) -> &'a Self::F<'a> { t } -} - -impl Fun for T { - type F<'a> = [u8]; -} - -fn bug<'a, T: ?Sized + Fun = [u8]>>(_ : Box) -> &'static T::F<'a> { - let a = [0; 1]; - let _x = T::identity(&a); - //~^ ERROR: `a` does not live long enough - todo!() -} - - -fn main() { - let x = 10; - - bug(Box::new(x)); -} diff --git a/src/test/ui/generic-associated-types/issue-74684-1.stderr b/src/test/ui/generic-associated-types/issue-74684-1.stderr deleted file mode 100644 index 651da696827c3..0000000000000 --- a/src/test/ui/generic-associated-types/issue-74684-1.stderr +++ /dev/null @@ -1,27 +0,0 @@ -warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-74684-1.rs:1:12 - | -LL | #![feature(generic_associated_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44265 for more information - -error[E0597]: `a` does not live long enough - --> $DIR/issue-74684-1.rs:16:26 - | -LL | fn bug<'a, T: ?Sized + Fun = [u8]>>(_ : Box) -> &'static T::F<'a> { - | -- lifetime `'a` defined here -LL | let a = [0; 1]; -LL | let _x = T::identity(&a); - | ------------^^- - | | | - | | borrowed value does not live long enough - | argument requires that `a` is borrowed for `'a` -... -LL | } - | - `a` dropped here while still borrowed - -error: aborting due to previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/generic-associated-types/issue-74684-2.rs b/src/test/ui/generic-associated-types/issue-74684-2.rs deleted file mode 100644 index 0caf19cb03038..0000000000000 --- a/src/test/ui/generic-associated-types/issue-74684-2.rs +++ /dev/null @@ -1,26 +0,0 @@ -#![feature(generic_associated_types)] - //~^ WARNING: the feature `generic_associated_types` is incomplete - -trait Fun { - type F<'a>: ?Sized; - - fn identity<'a>(t: &'a Self::F<'a>) -> &'a Self::F<'a> { t } -} - -impl Fun for T { - type F<'a> = i32; -} - -fn bug<'a, T: ?Sized + Fun = [u8]>>(t: Box) -> &'static T::F<'a> { - let a = [0; 1]; - let x = T::identity(&a); - todo!() -} - - -fn main() { - let x = 10; - - bug(Box::new(x)); - //~^ ERROR: type mismatch resolving `<{integer} as Fun>::F<'_> == [u8]` -} diff --git a/src/test/ui/generic-associated-types/issue-74684-2.stderr b/src/test/ui/generic-associated-types/issue-74684-2.stderr deleted file mode 100644 index 8c3484f9a7300..0000000000000 --- a/src/test/ui/generic-associated-types/issue-74684-2.stderr +++ /dev/null @@ -1,21 +0,0 @@ -warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-74684-2.rs:1:12 - | -LL | #![feature(generic_associated_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44265 for more information - -error[E0271]: type mismatch resolving `<{integer} as Fun>::F<'_> == [u8]` - --> $DIR/issue-74684-2.rs:24:5 - | -LL | fn bug<'a, T: ?Sized + Fun = [u8]>>(t: Box) -> &'static T::F<'a> { - | ------------ required by this bound in `bug` -... -LL | bug(Box::new(x)); - | ^^^ expected slice `[u8]`, found `i32` - -error: aborting due to previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0271`. diff --git a/src/test/ui/generic-associated-types/issue-76535.rs b/src/test/ui/generic-associated-types/issue-76535.rs deleted file mode 100644 index 2b4757d8d15ed..0000000000000 --- a/src/test/ui/generic-associated-types/issue-76535.rs +++ /dev/null @@ -1,41 +0,0 @@ -#![feature(generic_associated_types)] - //~^ WARNING the feature - -pub trait SubTrait {} - -pub trait SuperTrait { - type SubType<'a>: SubTrait; - //~^ ERROR missing generics for associated - - fn get_sub<'a>(&'a mut self) -> Self::SubType<'a>; -} - -pub struct SubStruct<'a> { - sup: &'a mut SuperStruct, -} - -impl<'a> SubTrait for SubStruct<'a> {} - -pub struct SuperStruct { - value: u8, -} - -impl SuperStruct { - pub fn new(value: u8) -> SuperStruct { - SuperStruct { value } - } -} - -impl SuperTrait for SuperStruct { - type SubType<'a> = SubStruct<'a>; - - fn get_sub<'a>(&'a mut self) -> Self::SubType<'a> { - SubStruct { sup: self } - } -} - -fn main() { - let sub: Box> = Box::new(SuperStruct::new(0)); - //~^ ERROR the trait - //~| ERROR the trait -} diff --git a/src/test/ui/generic-associated-types/issue-76535.stderr b/src/test/ui/generic-associated-types/issue-76535.stderr deleted file mode 100644 index ce4875af9c012..0000000000000 --- a/src/test/ui/generic-associated-types/issue-76535.stderr +++ /dev/null @@ -1,63 +0,0 @@ -warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-76535.rs:1:12 - | -LL | #![feature(generic_associated_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44265 for more information - -error[E0107]: missing generics for associated type `SuperTrait::SubType` - --> $DIR/issue-76535.rs:7:10 - | -LL | type SubType<'a>: SubTrait; - | ^^^^^^^ expected 1 lifetime argument - | -note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-76535.rs:7:10 - | -LL | type SubType<'a>: SubTrait; - | ^^^^^^^ -- -help: use angle brackets to add missing lifetime argument - | -LL | type SubType<'a><'a>: SubTrait; - | ^^^^ - -error[E0038]: the trait `SuperTrait` cannot be made into an object - --> $DIR/issue-76535.rs:38:14 - | -LL | let sub: Box> = Box::new(SuperStruct::new(0)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object - | - = help: consider moving `get_sub` to another trait -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit - --> $DIR/issue-76535.rs:10:37 - | -LL | pub trait SuperTrait { - | ---------- this trait cannot be made into an object... -... -LL | fn get_sub<'a>(&'a mut self) -> Self::SubType<'a>; - | ^^^^^^^^^^^^^^^^^ ...because method `get_sub` references the `Self` type in its return type - -error[E0038]: the trait `SuperTrait` cannot be made into an object - --> $DIR/issue-76535.rs:38:57 - | -LL | let sub: Box> = Box::new(SuperStruct::new(0)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object - | - = help: consider moving `get_sub` to another trait -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit - --> $DIR/issue-76535.rs:10:37 - | -LL | pub trait SuperTrait { - | ---------- this trait cannot be made into an object... -... -LL | fn get_sub<'a>(&'a mut self) -> Self::SubType<'a>; - | ^^^^^^^^^^^^^^^^^ ...because method `get_sub` references the `Self` type in its return type - = note: required because of the requirements on the impl of `CoerceUnsized>>>` for `Box` - = note: required by cast to type `Box>>` - -error: aborting due to 3 previous errors; 1 warning emitted - -Some errors have detailed explanations: E0038, E0107. -For more information about an error, try `rustc --explain E0038`. diff --git a/src/test/ui/generic-associated-types/issue-79422.rs b/src/test/ui/generic-associated-types/issue-79422.rs deleted file mode 100644 index 26b38430dd9a5..0000000000000 --- a/src/test/ui/generic-associated-types/issue-79422.rs +++ /dev/null @@ -1,47 +0,0 @@ -#![allow(incomplete_features)] -#![feature(generic_associated_types)] - -trait RefCont<'a, T> { - fn t(&'a self) -> &'a T; -} - -impl<'a, T> RefCont<'a, T> for &'a T { - fn t(&'a self) -> &'a T { - self - } -} - -impl<'a, T> RefCont<'a, T> for Box { - fn t(&'a self) -> &'a T { - self.as_ref() - } -} - -trait MapLike { - type VRefCont<'a>: RefCont<'a, V>; - //~^ ERROR missing generics - fn get<'a>(&'a self, key: &K) -> Option>; -} - -impl MapLike for std::collections::BTreeMap { - type VRefCont<'a> = &'a V; - fn get<'a>(&'a self, key: &K) -> Option<&'a V> { - std::collections::BTreeMap::get(self, key) - } -} - -struct Source; - -impl MapLike for Source { - type VRefCont<'a> = Box; - fn get<'a>(&self, _: &K) -> Option> { - Some(Box::new(V::default())) - } -} - -fn main() { - let m = Box::new(std::collections::BTreeMap::::new()) - as Box>>; - //~^ ERROR the trait - //~^^^ ERROR the trait -} diff --git a/src/test/ui/generic-associated-types/issue-79422.stderr b/src/test/ui/generic-associated-types/issue-79422.stderr deleted file mode 100644 index d2e12962715f0..0000000000000 --- a/src/test/ui/generic-associated-types/issue-79422.stderr +++ /dev/null @@ -1,54 +0,0 @@ -error[E0107]: missing generics for associated type `MapLike::VRefCont` - --> $DIR/issue-79422.rs:21:10 - | -LL | type VRefCont<'a>: RefCont<'a, V>; - | ^^^^^^^^ expected 1 lifetime argument - | -note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-79422.rs:21:10 - | -LL | type VRefCont<'a>: RefCont<'a, V>; - | ^^^^^^^^ -- -help: use angle brackets to add missing lifetime argument - | -LL | type VRefCont<'a><'a>: RefCont<'a, V>; - | ^^^^ - -error[E0038]: the trait `MapLike` cannot be made into an object - --> $DIR/issue-79422.rs:44:12 - | -LL | as Box>>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` cannot be made into an object - | - = help: consider moving `get` to another trait -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit - --> $DIR/issue-79422.rs:23:38 - | -LL | trait MapLike { - | ------- this trait cannot be made into an object... -... -LL | fn get<'a>(&'a self, key: &K) -> Option>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ...because method `get` references the `Self` type in its return type - -error[E0038]: the trait `MapLike` cannot be made into an object - --> $DIR/issue-79422.rs:43:13 - | -LL | let m = Box::new(std::collections::BTreeMap::::new()) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` cannot be made into an object - | - = help: consider moving `get` to another trait -note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit - --> $DIR/issue-79422.rs:23:38 - | -LL | trait MapLike { - | ------- this trait cannot be made into an object... -... -LL | fn get<'a>(&'a self, key: &K) -> Option>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ...because method `get` references the `Self` type in its return type - = note: required because of the requirements on the impl of `CoerceUnsized + 'static)>>>` for `Box>` - = note: required by cast to type `Box + 'static)>>` - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0038, E0107. -For more information about an error, try `rustc --explain E0038`. diff --git a/src/test/ui/generic-associated-types/issue-80433-reduced.rs b/src/test/ui/generic-associated-types/issue-80433-reduced.rs deleted file mode 100644 index 7c1673edc51a4..0000000000000 --- a/src/test/ui/generic-associated-types/issue-80433-reduced.rs +++ /dev/null @@ -1,24 +0,0 @@ -// check-pass - -#![allow(incomplete_features)] -#![feature(generic_associated_types)] - -struct E {} - -trait TestMut { - type Output<'a>; - fn test_mut(&mut self) -> Self::Output<'static>; -} - -impl TestMut for E { - type Output<'a> = usize; - fn test_mut(&mut self) -> Self::Output<'static> { - todo!() - } -} - -fn test_simpler<'a>(_: impl TestMut = usize>) {} - -fn main() { - test_simpler(E {}); -} diff --git a/src/test/ui/generic-associated-types/issue-80433.rs b/src/test/ui/generic-associated-types/issue-80433.rs deleted file mode 100644 index ea65f05de23d7..0000000000000 --- a/src/test/ui/generic-associated-types/issue-80433.rs +++ /dev/null @@ -1,35 +0,0 @@ -#![feature(generic_associated_types)] -#![allow(incomplete_features)] - -#[derive(Default)] -struct E { - data: T, -} - -trait TestMut { - type Output<'a>; - //~^ ERROR missing generics - fn test_mut<'a>(&'a mut self) -> Self::Output<'a>; -} - -impl TestMut for E -where - T: 'static, -{ - type Output<'a> = &'a mut T; - fn test_mut<'a>(&'a mut self) -> Self::Output<'a> { - &mut self.data - } -} - -fn test_simpler<'a>(dst: &'a mut impl TestMut) -{ - for n in 0i16..100 { - *dst.test_mut() = n.into(); - } -} - -fn main() { - let mut t1: E = Default::default(); - test_simpler(&mut t1); -} diff --git a/src/test/ui/generic-associated-types/issue-80433.stderr b/src/test/ui/generic-associated-types/issue-80433.stderr deleted file mode 100644 index 5398920fafdb0..0000000000000 --- a/src/test/ui/generic-associated-types/issue-80433.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0107]: missing generics for associated type `TestMut::Output` - --> $DIR/issue-80433.rs:10:10 - | -LL | type Output<'a>; - | ^^^^^^ expected 1 lifetime argument - | -note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-80433.rs:10:10 - | -LL | type Output<'a>; - | ^^^^^^ -- -help: use angle brackets to add missing lifetime argument - | -LL | type Output<'a><'a>; - | ^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0107`. diff --git a/src/test/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.rs b/src/test/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.rs index 2d38770bcdff8..e203a5e0d2de6 100644 --- a/src/test/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.rs +++ b/src/test/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.rs @@ -1,14 +1,10 @@ #![feature(generic_associated_types)] - //~^ the feature `generic_associated_types` is incomplete trait X { type Y<'a>; - //~^ ERROR this associated type - //~| ERROR this associated type } const _: () = { fn f2<'a>(arg : Box = &'a ()>>) {} + //~^ ERROR: generic associated types in trait paths are currently not implemented }; - -fn main() {} diff --git a/src/test/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.stderr b/src/test/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.stderr index 60b8fb9bcaa23..e59a72a99eeb9 100644 --- a/src/test/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.stderr +++ b/src/test/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.stderr @@ -1,49 +1,8 @@ -warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/trait-path-type-error-once-implemented.rs:1:12 +error: generic associated types in trait paths are currently not implemented + --> $DIR/trait-path-type-error-once-implemented.rs:8:30 | -LL | #![feature(generic_associated_types)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `#[warn(incomplete_features)]` on by default - = note: see issue #44265 for more information - -error[E0107]: this associated type takes 1 lifetime argument but 0 lifetime arguments were supplied - --> $DIR/trait-path-type-error-once-implemented.rs:5:10 - | -LL | type Y<'a>; - | ^ expected 1 lifetime argument - | -note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/trait-path-type-error-once-implemented.rs:5:10 - | -LL | type Y<'a>; - | ^ -- -help: add missing lifetime argument - | -LL | fn f2<'a>(arg : Box = &'a ()>>) {} - | ^^ - -error[E0107]: this associated type takes 0 const arguments but 1 const argument was supplied - --> $DIR/trait-path-type-error-once-implemented.rs:5:10 - | -LL | type Y<'a>; - | __________^- - | | | - | | expected 0 const arguments -LL | | -LL | | -LL | | } -LL | | -LL | | const _: () = { -LL | | fn f2<'a>(arg : Box = &'a ()>>) {} - | |________________________________- help: remove these generics - | -note: associated type defined here, with 0 const parameters - --> $DIR/trait-path-type-error-once-implemented.rs:5:10 - | -LL | type Y<'a>; - | ^ +LL | fn f2<'a>(arg : Box = &'a ()>>) {} + | ^^^ -error: aborting due to 2 previous errors; 1 warning emitted +error: aborting due to previous error -For more information about this error, try `rustc --explain E0107`. diff --git a/src/test/ui/generic-associated-types/parse/trait-path-unimplemented.rs b/src/test/ui/generic-associated-types/parse/trait-path-unimplemented.rs new file mode 100644 index 0000000000000..02d53d5faeec5 --- /dev/null +++ b/src/test/ui/generic-associated-types/parse/trait-path-unimplemented.rs @@ -0,0 +1,17 @@ +#![feature(generic_associated_types)] + +trait X { + type Y<'a>; +} + +const _: () = { + fn f1<'a>(arg : Box = &'a ()>>) {} + //~^ ERROR: generic associated types in trait paths are currently not implemented +}; + +const _: () = { + fn f1<'a>(arg : Box>) {} + //~^ ERROR: lifetime in trait object type must be followed by `+` +}; + +fn main() {} diff --git a/src/test/ui/generic-associated-types/parse/trait-path-unimplemented.stderr b/src/test/ui/generic-associated-types/parse/trait-path-unimplemented.stderr new file mode 100644 index 0000000000000..1fba9cebd2491 --- /dev/null +++ b/src/test/ui/generic-associated-types/parse/trait-path-unimplemented.stderr @@ -0,0 +1,14 @@ +error: lifetime in trait object type must be followed by `+` + --> $DIR/trait-path-unimplemented.rs:13:31 + | +LL | fn f1<'a>(arg : Box>) {} + | ^^ + +error: generic associated types in trait paths are currently not implemented + --> $DIR/trait-path-unimplemented.rs:8:30 + | +LL | fn f1<'a>(arg : Box = &'a ()>>) {} + | ^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/generics/wrong-number-of-args.rs b/src/test/ui/generics/wrong-number-of-args.rs index 2994ca3c7595c..6b99865202e54 100644 --- a/src/test/ui/generics/wrong-number-of-args.rs +++ b/src/test/ui/generics/wrong-number-of-args.rs @@ -139,7 +139,7 @@ mod stdlib { mod result { type A = Result; - //~^ ERROR missing generics for enum `Result` + //~^ ERROR missing generics for enum `std::result::Result` //~| HELP use angle brackets type B = Result; diff --git a/src/test/ui/generics/wrong-number-of-args.stderr b/src/test/ui/generics/wrong-number-of-args.stderr index 73bd76aa5fad0..2a34fba2c4875 100644 --- a/src/test/ui/generics/wrong-number-of-args.stderr +++ b/src/test/ui/generics/wrong-number-of-args.stderr @@ -365,7 +365,7 @@ note: struct defined here, with at most 3 type parameters: `K`, `V`, `S` LL | pub struct HashMap { | ^^^^^^^ - - - -error[E0107]: missing generics for enum `Result` +error[E0107]: missing generics for enum `std::result::Result` --> $DIR/wrong-number-of-args.rs:141:18 | LL | type A = Result; diff --git a/src/test/ui/limits/huge-array-simple-32.rs b/src/test/ui/huge-array-simple-32.rs similarity index 100% rename from src/test/ui/limits/huge-array-simple-32.rs rename to src/test/ui/huge-array-simple-32.rs diff --git a/src/test/ui/limits/huge-array-simple-32.stderr b/src/test/ui/huge-array-simple-32.stderr similarity index 100% rename from src/test/ui/limits/huge-array-simple-32.stderr rename to src/test/ui/huge-array-simple-32.stderr diff --git a/src/test/ui/limits/huge-array-simple-64.rs b/src/test/ui/huge-array-simple-64.rs similarity index 100% rename from src/test/ui/limits/huge-array-simple-64.rs rename to src/test/ui/huge-array-simple-64.rs diff --git a/src/test/ui/limits/huge-array-simple-64.stderr b/src/test/ui/huge-array-simple-64.stderr similarity index 100% rename from src/test/ui/limits/huge-array-simple-64.stderr rename to src/test/ui/huge-array-simple-64.stderr diff --git a/src/test/ui/limits/huge-array.rs b/src/test/ui/huge-array.rs similarity index 100% rename from src/test/ui/limits/huge-array.rs rename to src/test/ui/huge-array.rs diff --git a/src/test/ui/limits/huge-array.stderr b/src/test/ui/huge-array.stderr similarity index 100% rename from src/test/ui/limits/huge-array.stderr rename to src/test/ui/huge-array.stderr diff --git a/src/test/ui/limits/huge-enum.rs b/src/test/ui/huge-enum.rs similarity index 100% rename from src/test/ui/limits/huge-enum.rs rename to src/test/ui/huge-enum.rs diff --git a/src/test/ui/limits/huge-enum.stderr b/src/test/ui/huge-enum.stderr similarity index 100% rename from src/test/ui/limits/huge-enum.stderr rename to src/test/ui/huge-enum.stderr diff --git a/src/test/ui/limits/huge-struct.rs b/src/test/ui/huge-struct.rs similarity index 100% rename from src/test/ui/limits/huge-struct.rs rename to src/test/ui/huge-struct.rs diff --git a/src/test/ui/limits/huge-struct.stderr b/src/test/ui/huge-struct.stderr similarity index 100% rename from src/test/ui/limits/huge-struct.stderr rename to src/test/ui/huge-struct.stderr diff --git a/src/test/ui/impl-header-lifetime-elision/dyn-trait.nll.stderr b/src/test/ui/impl-header-lifetime-elision/dyn-trait.nll.stderr index d72435bc63111..8e660d6814c43 100644 --- a/src/test/ui/impl-header-lifetime-elision/dyn-trait.nll.stderr +++ b/src/test/ui/impl-header-lifetime-elision/dyn-trait.nll.stderr @@ -10,4 +10,3 @@ LL | static_val(x); error: aborting due to previous error -For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/impl-trait/trait_type.stderr b/src/test/ui/impl-trait/trait_type.stderr index 961bb7351181e..e94f2c702150a 100644 --- a/src/test/ui/impl-trait/trait_type.stderr +++ b/src/test/ui/impl-trait/trait_type.stderr @@ -4,7 +4,7 @@ error[E0053]: method `fmt` has an incompatible type for trait LL | fn fmt(&self, x: &str) -> () { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ in mutability | - = note: expected fn pointer `fn(&MyType, &mut Formatter<'_>) -> Result<(), std::fmt::Error>` + = note: expected fn pointer `fn(&MyType, &mut Formatter<'_>) -> std::result::Result<(), std::fmt::Error>` found fn pointer `fn(&MyType, &str)` error[E0050]: method `fmt` has 1 parameter but the declaration in trait `std::fmt::Display::fmt` has 2 @@ -13,7 +13,7 @@ error[E0050]: method `fmt` has 1 parameter but the declaration in trait `std::fm LL | fn fmt(&self) -> () { } | ^^^^^ expected 2 parameters, found 1 | - = note: `fmt` from trait: `fn(&Self, &mut Formatter<'_>) -> Result<(), std::fmt::Error>` + = note: `fmt` from trait: `fn(&Self, &mut Formatter<'_>) -> std::result::Result<(), std::fmt::Error>` error[E0186]: method `fmt` has a `&self` declaration in the trait, but not in the impl --> $DIR/trait_type.rs:17:4 @@ -21,7 +21,7 @@ error[E0186]: method `fmt` has a `&self` declaration in the trait, but not in th LL | fn fmt() -> () { } | ^^^^^^^^^^^^^^ expected `&self` in impl | - = note: `fmt` from trait: `fn(&Self, &mut Formatter<'_>) -> Result<(), std::fmt::Error>` + = note: `fmt` from trait: `fn(&Self, &mut Formatter<'_>) -> std::result::Result<(), std::fmt::Error>` error[E0046]: not all trait items implemented, missing: `fmt` --> $DIR/trait_type.rs:21:1 @@ -29,7 +29,7 @@ error[E0046]: not all trait items implemented, missing: `fmt` LL | impl std::fmt::Display for MyType4 {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `fmt` in implementation | - = help: implement the missing item: `fn fmt(&self, _: &mut Formatter<'_>) -> Result<(), std::fmt::Error> { todo!() }` + = help: implement the missing item: `fn fmt(&self, _: &mut Formatter<'_>) -> std::result::Result<(), std::fmt::Error> { todo!() }` error: aborting due to 4 previous errors diff --git a/src/test/ui/inference/cannot-infer-closure-circular.stderr b/src/test/ui/inference/cannot-infer-closure-circular.stderr index 211ae13e46df1..5efb400a4c7a5 100644 --- a/src/test/ui/inference/cannot-infer-closure-circular.stderr +++ b/src/test/ui/inference/cannot-infer-closure-circular.stderr @@ -1,8 +1,8 @@ -error[E0282]: type annotations needed for `Result<(), E>` +error[E0282]: type annotations needed for `std::result::Result<(), E>` --> $DIR/cannot-infer-closure-circular.rs:7:14 | LL | let x = |r| { - | ^ consider giving this closure parameter the explicit type `Result<(), E>`, with the type parameters specified + | ^ consider giving this closure parameter the explicit type `std::result::Result<(), E>`, with the type parameters specified error: aborting due to previous error diff --git a/src/test/ui/inference/cannot-infer-closure.stderr b/src/test/ui/inference/cannot-infer-closure.stderr index 0dcce9e990b53..475ed00d10752 100644 --- a/src/test/ui/inference/cannot-infer-closure.stderr +++ b/src/test/ui/inference/cannot-infer-closure.stderr @@ -1,4 +1,4 @@ -error[E0282]: type annotations needed for the closure `fn((), ()) -> Result<(), _>` +error[E0282]: type annotations needed for the closure `fn((), ()) -> std::result::Result<(), _>` --> $DIR/cannot-infer-closure.rs:3:15 | LL | Err(a)?; @@ -7,8 +7,8 @@ LL | Err(a)?; = note: `?` implicitly converts the error value into a type implementing `From<()>` help: give this closure an explicit return type without `_` placeholders | -LL | let x = |a: (), b: ()| -> Result<(), _> { - | ^^^^^^^^^^^^^^^^ +LL | let x = |a: (), b: ()| -> std::result::Result<(), _> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/inference/cannot-infer-partial-try-return.stderr b/src/test/ui/inference/cannot-infer-partial-try-return.stderr index 86e2126e1ae7b..a64503fa667c7 100644 --- a/src/test/ui/inference/cannot-infer-partial-try-return.stderr +++ b/src/test/ui/inference/cannot-infer-partial-try-return.stderr @@ -1,4 +1,4 @@ -error[E0282]: type annotations needed for the closure `fn() -> Result<(), QualifiedError<_>>` +error[E0282]: type annotations needed for the closure `fn() -> std::result::Result<(), QualifiedError<_>>` --> $DIR/cannot-infer-partial-try-return.rs:19:9 | LL | infallible()?; @@ -7,8 +7,8 @@ LL | infallible()?; = note: `?` implicitly converts the error value into `QualifiedError<_>` using its implementation of `From` help: give this closure an explicit return type without `_` placeholders | -LL | let x = || -> Result<(), QualifiedError<_>> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let x = || -> std::result::Result<(), QualifiedError<_>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/inference/issue-72616.stderr b/src/test/ui/inference/issue-72616.stderr index 3c9d864c42639..d811988c9c1d0 100644 --- a/src/test/ui/inference/issue-72616.stderr +++ b/src/test/ui/inference/issue-72616.stderr @@ -2,7 +2,7 @@ error[E0283]: type annotations needed --> $DIR/issue-72616.rs:20:30 | LL | if String::from("a") == "a".try_into().unwrap() {} - | ^^ -------------- this method call resolves to `Result>::Error>` + | ^^ -------------- this method call resolves to `std::result::Result>::Error>` | | | cannot infer type | diff --git a/src/test/ui/issue-74047.stderr b/src/test/ui/issue-74047.stderr index 28174825d8bce..8f7c91a78d8c0 100644 --- a/src/test/ui/issue-74047.stderr +++ b/src/test/ui/issue-74047.stderr @@ -5,7 +5,7 @@ LL | impl TryFrom for MyStream {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Error`, `try_from` in implementation | = help: implement the missing item: `type Error = Type;` - = help: implement the missing item: `fn try_from(_: T) -> Result>::Error> { todo!() }` + = help: implement the missing item: `fn try_from(_: T) -> std::result::Result>::Error> { todo!() }` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-11844.stderr b/src/test/ui/issues/issue-11844.stderr index 9d7470e7af9aa..00eecbc9a98b6 100644 --- a/src/test/ui/issues/issue-11844.stderr +++ b/src/test/ui/issues/issue-11844.stderr @@ -4,10 +4,10 @@ error[E0308]: mismatched types LL | match a { | - this expression has type `Option>` LL | Ok(a) => - | ^^^^^ expected enum `Option`, found enum `Result` + | ^^^^^ expected enum `Option`, found enum `std::result::Result` | = note: expected enum `Option>` - found enum `Result<_, _>` + found enum `std::result::Result<_, _>` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-12511.stderr b/src/test/ui/issues/issue-12511.stderr index 5f2b98c5237db..37e38ff60ae4b 100644 --- a/src/test/ui/issues/issue-12511.stderr +++ b/src/test/ui/issues/issue-12511.stderr @@ -1,25 +1,15 @@ -error[E0391]: cycle detected when computing the super predicates of `T1` - --> $DIR/issue-12511.rs:1:1 - | -LL | trait T1 : T2 { - | ^^^^^^^^^^^^^ - | -note: ...which requires computing the super traits of `T1`... +error[E0391]: cycle detected when computing the supertraits of `T1` --> $DIR/issue-12511.rs:1:12 | LL | trait T1 : T2 { | ^^ -note: ...which requires computing the super predicates of `T2`... - --> $DIR/issue-12511.rs:5:1 | -LL | trait T2 : T1 { - | ^^^^^^^^^^^^^ -note: ...which requires computing the super traits of `T2`... +note: ...which requires computing the supertraits of `T2`... --> $DIR/issue-12511.rs:5:12 | LL | trait T2 : T1 { | ^^ - = note: ...which again requires computing the super predicates of `T1`, completing the cycle + = note: ...which again requires computing the supertraits of `T1`, completing the cycle note: cycle used when collecting item types in top-level module --> $DIR/issue-12511.rs:1:1 | diff --git a/src/test/ui/issues/issue-12552.stderr b/src/test/ui/issues/issue-12552.stderr index 3d8852ca748af..1594c9f503a18 100644 --- a/src/test/ui/issues/issue-12552.stderr +++ b/src/test/ui/issues/issue-12552.stderr @@ -2,23 +2,23 @@ error[E0308]: mismatched types --> $DIR/issue-12552.rs:6:5 | LL | match t { - | - this expression has type `Result<_, {integer}>` + | - this expression has type `std::result::Result<_, {integer}>` LL | Some(k) => match k { - | ^^^^^^^ expected enum `Result`, found enum `Option` + | ^^^^^^^ expected enum `std::result::Result`, found enum `Option` | - = note: expected enum `Result<_, {integer}>` + = note: expected enum `std::result::Result<_, {integer}>` found enum `Option<_>` error[E0308]: mismatched types --> $DIR/issue-12552.rs:9:5 | LL | match t { - | - this expression has type `Result<_, {integer}>` + | - this expression has type `std::result::Result<_, {integer}>` ... LL | None => () - | ^^^^ expected enum `Result`, found enum `Option` + | ^^^^ expected enum `std::result::Result`, found enum `Option` | - = note: expected enum `Result<_, {integer}>` + = note: expected enum `std::result::Result<_, {integer}>` found enum `Option<_>` error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-13466.rs b/src/test/ui/issues/issue-13466.rs index a420c7704af51..8048dae123994 100644 --- a/src/test/ui/issues/issue-13466.rs +++ b/src/test/ui/issues/issue-13466.rs @@ -8,13 +8,13 @@ pub fn main() { Ok(u) => u, //~^ ERROR mismatched types //~| expected enum `Option<{integer}>` - //~| found enum `Result<_, _>` - //~| expected enum `Option`, found enum `Result` + //~| found enum `std::result::Result<_, _>` + //~| expected enum `Option`, found enum `std::result::Result` Err(e) => panic!(e) //~^ ERROR mismatched types //~| expected enum `Option<{integer}>` - //~| found enum `Result<_, _>` - //~| expected enum `Option`, found enum `Result` + //~| found enum `std::result::Result<_, _>` + //~| expected enum `Option`, found enum `std::result::Result` }; } diff --git a/src/test/ui/issues/issue-13466.stderr b/src/test/ui/issues/issue-13466.stderr index c78466f4e8ce1..792cc398bb86b 100644 --- a/src/test/ui/issues/issue-13466.stderr +++ b/src/test/ui/issues/issue-13466.stderr @@ -4,10 +4,10 @@ error[E0308]: mismatched types LL | let _x: usize = match Some(1) { | ------- this expression has type `Option<{integer}>` LL | Ok(u) => u, - | ^^^^^ expected enum `Option`, found enum `Result` + | ^^^^^ expected enum `Option`, found enum `std::result::Result` | = note: expected enum `Option<{integer}>` - found enum `Result<_, _>` + found enum `std::result::Result<_, _>` error[E0308]: mismatched types --> $DIR/issue-13466.rs:14:9 @@ -16,10 +16,10 @@ LL | let _x: usize = match Some(1) { | ------- this expression has type `Option<{integer}>` ... LL | Err(e) => panic!(e) - | ^^^^^^ expected enum `Option`, found enum `Result` + | ^^^^^^ expected enum `Option`, found enum `std::result::Result` | = note: expected enum `Option<{integer}>` - found enum `Result<_, _>` + found enum `std::result::Result<_, _>` error: aborting due to 2 previous errors diff --git a/src/test/ui/limits/issue-15919-32.rs b/src/test/ui/issues/issue-15919-32.rs similarity index 100% rename from src/test/ui/limits/issue-15919-32.rs rename to src/test/ui/issues/issue-15919-32.rs diff --git a/src/test/ui/limits/issue-15919-32.stderr b/src/test/ui/issues/issue-15919-32.stderr similarity index 100% rename from src/test/ui/limits/issue-15919-32.stderr rename to src/test/ui/issues/issue-15919-32.stderr diff --git a/src/test/ui/limits/issue-15919-64.rs b/src/test/ui/issues/issue-15919-64.rs similarity index 100% rename from src/test/ui/limits/issue-15919-64.rs rename to src/test/ui/issues/issue-15919-64.rs diff --git a/src/test/ui/limits/issue-15919-64.stderr b/src/test/ui/issues/issue-15919-64.stderr similarity index 100% rename from src/test/ui/limits/issue-15919-64.stderr rename to src/test/ui/issues/issue-15919-64.stderr diff --git a/src/test/ui/issues/issue-16683.nll.stderr b/src/test/ui/issues/issue-16683.nll.stderr index 51d86eaf9e60c..b82b0b552e2dd 100644 --- a/src/test/ui/issues/issue-16683.nll.stderr +++ b/src/test/ui/issues/issue-16683.nll.stderr @@ -8,4 +8,3 @@ LL | self.a(); error: aborting due to previous error -For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/simd/issue-17170.rs b/src/test/ui/issues/issue-17170.rs similarity index 70% rename from src/test/ui/simd/issue-17170.rs rename to src/test/ui/issues/issue-17170.rs index 49cfbab9a3e6f..8d70dacdc9010 100644 --- a/src/test/ui/simd/issue-17170.rs +++ b/src/test/ui/issues/issue-17170.rs @@ -1,8 +1,8 @@ +// run-pass #![feature(repr_simd)] #[repr(simd)] struct T(f64, f64, f64); -//~^ ERROR SIMD vector length must be a power of two static X: T = T(0.0, 0.0, 0.0); diff --git a/src/test/ui/cast/issue-17444.rs b/src/test/ui/issues/issue-17444.rs similarity index 100% rename from src/test/ui/cast/issue-17444.rs rename to src/test/ui/issues/issue-17444.rs diff --git a/src/test/ui/cast/issue-17444.stderr b/src/test/ui/issues/issue-17444.stderr similarity index 100% rename from src/test/ui/cast/issue-17444.stderr rename to src/test/ui/issues/issue-17444.stderr diff --git a/src/test/ui/issues/issue-17758.nll.stderr b/src/test/ui/issues/issue-17758.nll.stderr index 075c141ed7af6..23557b4d956aa 100644 --- a/src/test/ui/issues/issue-17758.nll.stderr +++ b/src/test/ui/issues/issue-17758.nll.stderr @@ -8,4 +8,3 @@ LL | self.foo(); error: aborting due to previous error -For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/limits/issue-17913.rs b/src/test/ui/issues/issue-17913.rs similarity index 100% rename from src/test/ui/limits/issue-17913.rs rename to src/test/ui/issues/issue-17913.rs diff --git a/src/test/ui/limits/issue-17913.stderr b/src/test/ui/issues/issue-17913.stderr similarity index 100% rename from src/test/ui/limits/issue-17913.stderr rename to src/test/ui/issues/issue-17913.stderr diff --git a/src/test/ui/issues/issue-18919.stderr b/src/test/ui/issues/issue-18919.stderr index d4b93eb074cfe..ece714c949c19 100644 --- a/src/test/ui/issues/issue-18919.stderr +++ b/src/test/ui/issues/issue-18919.stderr @@ -14,7 +14,7 @@ help: you could relax the implicit `Sized` bound on `T` if it were used through LL | enum Option { | ^ this could be changed to `T: ?Sized`... LL | Some(T), - | - ...if indirection were used here: `Box` + | - ...if indirection was used here: `Box` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-20772.stderr b/src/test/ui/issues/issue-20772.stderr index 4aecc7eab4628..d64636310a368 100644 --- a/src/test/ui/issues/issue-20772.stderr +++ b/src/test/ui/issues/issue-20772.stderr @@ -1,4 +1,4 @@ -error[E0391]: cycle detected when computing the super traits of `T` with associated type name `Item` +error[E0391]: cycle detected when computing the supertraits of `T` --> $DIR/issue-20772.rs:1:1 | LL | / trait T : Iterator @@ -6,8 +6,8 @@ LL | | LL | | {} | |__^ | - = note: ...which again requires computing the super traits of `T` with associated type name `Item`, completing the cycle -note: cycle used when computing the super traits of `T` + = note: ...which again requires computing the supertraits of `T`, completing the cycle +note: cycle used when collecting item types in top-level module --> $DIR/issue-20772.rs:1:1 | LL | / trait T : Iterator diff --git a/src/test/ui/issues/issue-20825.stderr b/src/test/ui/issues/issue-20825.stderr index ccbe06d9c0d56..5f9709d1c649b 100644 --- a/src/test/ui/issues/issue-20825.stderr +++ b/src/test/ui/issues/issue-20825.stderr @@ -1,11 +1,11 @@ -error[E0391]: cycle detected when computing the super traits of `Processor` with associated type name `Input` +error[E0391]: cycle detected when computing the supertraits of `Processor` --> $DIR/issue-20825.rs:5:1 | LL | pub trait Processor: Subscriber { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: ...which again requires computing the super traits of `Processor` with associated type name `Input`, completing the cycle -note: cycle used when computing the super traits of `Processor` + = note: ...which again requires computing the supertraits of `Processor`, completing the cycle +note: cycle used when collecting item types in top-level module --> $DIR/issue-20825.rs:5:1 | LL | pub trait Processor: Subscriber { diff --git a/src/test/ui/issues/issue-21332.rs b/src/test/ui/issues/issue-21332.rs index 6547f3a9b19ae..1b13f000b8c8c 100644 --- a/src/test/ui/issues/issue-21332.rs +++ b/src/test/ui/issues/issue-21332.rs @@ -4,7 +4,7 @@ impl Iterator for S { type Item = i32; fn next(&mut self) -> Result { Ok(7) } //~^ ERROR method `next` has an incompatible type for trait - //~| expected enum `Option`, found enum `Result` + //~| expected enum `Option`, found enum `std::result::Result` } fn main() {} diff --git a/src/test/ui/issues/issue-21332.stderr b/src/test/ui/issues/issue-21332.stderr index 35863fbebe315..1d6ddd2660ec2 100644 --- a/src/test/ui/issues/issue-21332.stderr +++ b/src/test/ui/issues/issue-21332.stderr @@ -2,10 +2,10 @@ error[E0053]: method `next` has an incompatible type for trait --> $DIR/issue-21332.rs:5:5 | LL | fn next(&mut self) -> Result { Ok(7) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `Option`, found enum `Result` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected enum `Option`, found enum `std::result::Result` | = note: expected fn pointer `fn(&mut S) -> Option` - found fn pointer `fn(&mut S) -> Result` + found fn pointer `fn(&mut S) -> std::result::Result` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-22673.rs b/src/test/ui/issues/issue-22673.rs index 4b9b4d6b23da4..ba8057b684de8 100644 --- a/src/test/ui/issues/issue-22673.rs +++ b/src/test/ui/issues/issue-22673.rs @@ -1,6 +1,5 @@ -// check-pass - -trait Expr: PartialEq { +trait Expr : PartialEq { + //~^ ERROR: cycle detected type Item; } diff --git a/src/test/ui/issues/issue-22673.stderr b/src/test/ui/issues/issue-22673.stderr new file mode 100644 index 0000000000000..9e7e4b218b1c6 --- /dev/null +++ b/src/test/ui/issues/issue-22673.stderr @@ -0,0 +1,16 @@ +error[E0391]: cycle detected when computing the supertraits of `Expr` + --> $DIR/issue-22673.rs:1:1 + | +LL | trait Expr : PartialEq { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: ...which again requires computing the supertraits of `Expr`, completing the cycle +note: cycle used when collecting item types in top-level module + --> $DIR/issue-22673.rs:1:1 + | +LL | trait Expr : PartialEq { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/src/test/ui/issues/issue-23281.stderr b/src/test/ui/issues/issue-23281.stderr index a3d2583292551..d8046497b9875 100644 --- a/src/test/ui/issues/issue-23281.stderr +++ b/src/test/ui/issues/issue-23281.stderr @@ -14,7 +14,7 @@ help: you could relax the implicit `Sized` bound on `T` if it were used through LL | struct Vec { | ^ this could be changed to `T: ?Sized`... LL | t: T, - | - ...if indirection were used here: `Box` + | - ...if indirection was used here: `Box` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-29821.rs b/src/test/ui/issues/issue-29821.rs deleted file mode 100644 index 54be3afb59d0a..0000000000000 --- a/src/test/ui/issues/issue-29821.rs +++ /dev/null @@ -1,19 +0,0 @@ -// build-pass - -pub trait Foo { - type FooAssoc; -} - -pub struct Bar { - id: F::FooAssoc -} - -pub struct Baz; - -impl Foo for Baz { - type FooAssoc = usize; -} - -static mut MY_FOO: Bar = Bar { id: 0 }; - -fn main() {} diff --git a/src/test/ui/issues/issue-34229.rs b/src/test/ui/issues/issue-34229.rs index 13e627a492f40..625fcb0a6f607 100644 --- a/src/test/ui/issues/issue-34229.rs +++ b/src/test/ui/issues/issue-34229.rs @@ -1,5 +1,9 @@ #[derive(PartialEq)] struct Comparable; #[derive(PartialEq, PartialOrd)] struct Nope(Comparable); //~^ ERROR can't compare `Comparable` +//~| ERROR can't compare `Comparable` +//~| ERROR can't compare `Comparable` +//~| ERROR can't compare `Comparable` +//~| ERROR can't compare `Comparable` fn main() {} diff --git a/src/test/ui/issues/issue-34229.stderr b/src/test/ui/issues/issue-34229.stderr index 7268e94c8d167..d25189e783759 100644 --- a/src/test/ui/issues/issue-34229.stderr +++ b/src/test/ui/issues/issue-34229.stderr @@ -8,6 +8,46 @@ LL | #[derive(PartialEq, PartialOrd)] struct Nope(Comparable); = note: required by `std::cmp::PartialOrd::partial_cmp` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to previous error +error[E0277]: can't compare `Comparable` with `Comparable` + --> $DIR/issue-34229.rs:2:46 + | +LL | #[derive(PartialEq, PartialOrd)] struct Nope(Comparable); + | ^^^^^^^^^^ no implementation for `Comparable < Comparable` and `Comparable > Comparable` + | + = help: the trait `PartialOrd` is not implemented for `Comparable` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `Comparable` with `Comparable` + --> $DIR/issue-34229.rs:2:46 + | +LL | #[derive(PartialEq, PartialOrd)] struct Nope(Comparable); + | ^^^^^^^^^^ no implementation for `Comparable < Comparable` and `Comparable > Comparable` + | + = help: the trait `PartialOrd` is not implemented for `Comparable` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `Comparable` with `Comparable` + --> $DIR/issue-34229.rs:2:46 + | +LL | #[derive(PartialEq, PartialOrd)] struct Nope(Comparable); + | ^^^^^^^^^^ no implementation for `Comparable < Comparable` and `Comparable > Comparable` + | + = help: the trait `PartialOrd` is not implemented for `Comparable` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `Comparable` with `Comparable` + --> $DIR/issue-34229.rs:2:46 + | +LL | #[derive(PartialEq, PartialOrd)] struct Nope(Comparable); + | ^^^^^^^^^^ no implementation for `Comparable < Comparable` and `Comparable > Comparable` + | + = help: the trait `PartialOrd` is not implemented for `Comparable` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/issues/issue-3680.rs b/src/test/ui/issues/issue-3680.rs index 37c9000c043da..8912e7a18ac3b 100644 --- a/src/test/ui/issues/issue-3680.rs +++ b/src/test/ui/issues/issue-3680.rs @@ -3,7 +3,7 @@ fn main() { Err(_) => () //~^ ERROR mismatched types //~| expected enum `Option<_>` - //~| found enum `Result<_, _>` - //~| expected enum `Option`, found enum `Result` + //~| found enum `std::result::Result<_, _>` + //~| expected enum `Option`, found enum `std::result::Result` } } diff --git a/src/test/ui/issues/issue-3680.stderr b/src/test/ui/issues/issue-3680.stderr index e8fafa76b919b..479942b8e2c5f 100644 --- a/src/test/ui/issues/issue-3680.stderr +++ b/src/test/ui/issues/issue-3680.stderr @@ -4,10 +4,10 @@ error[E0308]: mismatched types LL | match None { | ---- this expression has type `Option<_>` LL | Err(_) => () - | ^^^^^^ expected enum `Option`, found enum `Result` + | ^^^^^^ expected enum `Option`, found enum `std::result::Result` | = note: expected enum `Option<_>` - found enum `Result<_, _>` + found enum `std::result::Result<_, _>` error: aborting due to previous error diff --git a/src/test/ui/simd/issue-39720.rs b/src/test/ui/issues/issue-39720.rs similarity index 80% rename from src/test/ui/simd/issue-39720.rs rename to src/test/ui/issues/issue-39720.rs index 7d5969265121c..8cf841f937121 100644 --- a/src/test/ui/simd/issue-39720.rs +++ b/src/test/ui/issues/issue-39720.rs @@ -1,3 +1,4 @@ +// run-pass // ignore-emscripten FIXME(#45351) #![feature(repr_simd, platform_intrinsics)] @@ -5,12 +6,10 @@ #[repr(simd)] #[derive(Copy, Clone, Debug)] pub struct Char3(pub i8, pub i8, pub i8); -//~^ ERROR SIMD vector length must be a power of two #[repr(simd)] #[derive(Copy, Clone, Debug)] pub struct Short3(pub i16, pub i16, pub i16); -//~^ ERROR SIMD vector length must be a power of two extern "platform-intrinsic" { fn simd_cast(x: T) -> U; diff --git a/src/test/ui/issues/issue-4736.stderr b/src/test/ui/issues/issue-4736.stderr index 9be4eb1c7fddb..257ec914a61ca 100644 --- a/src/test/ui/issues/issue-4736.stderr +++ b/src/test/ui/issues/issue-4736.stderr @@ -7,7 +7,7 @@ LL | struct NonCopyable(()); LL | let z = NonCopyable{ p: () }; | ----------- ^ field does not exist | | - | help: `NonCopyable` is a tuple struct, use the appropriate syntax: `NonCopyable(/* fields */)` + | `NonCopyable` is a tuple struct, use the appropriate syntax: `NonCopyable(/* fields */)` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-49934-errors.rs b/src/test/ui/issues/issue-49934-errors.rs index dd14bac5e3a9f..bf95f8fa7e1ec 100644 --- a/src/test/ui/issues/issue-49934-errors.rs +++ b/src/test/ui/issues/issue-49934-errors.rs @@ -1,8 +1,11 @@ -fn foo<#[derive(Debug)] T>() { //~ ERROR expected non-macro attribute, found attribute macro +fn foo<#[derive(Debug)] T>() { +//~^ ERROR `derive` may only be applied to structs, enums and unions match 0 { - #[derive(Debug)] //~ ERROR expected non-macro attribute, found attribute macro + #[derive(Debug)] + //~^ ERROR `derive` may only be applied to structs, enums and unions _ => (), } } -fn main() {} +fn main() { +} diff --git a/src/test/ui/issues/issue-49934-errors.stderr b/src/test/ui/issues/issue-49934-errors.stderr index 8c4c54170a101..71cd2d3034243 100644 --- a/src/test/ui/issues/issue-49934-errors.stderr +++ b/src/test/ui/issues/issue-49934-errors.stderr @@ -1,14 +1,15 @@ -error: expected non-macro attribute, found attribute macro `derive` - --> $DIR/issue-49934-errors.rs:1:10 +error[E0774]: `derive` may only be applied to structs, enums and unions + --> $DIR/issue-49934-errors.rs:1:8 | LL | fn foo<#[derive(Debug)] T>() { - | ^^^^^^ not a non-macro attribute + | ^^^^^^^^^^^^^^^^ -error: expected non-macro attribute, found attribute macro `derive` - --> $DIR/issue-49934-errors.rs:3:11 +error[E0774]: `derive` may only be applied to structs, enums and unions + --> $DIR/issue-49934-errors.rs:4:9 | LL | #[derive(Debug)] - | ^^^^^^ not a non-macro attribute + | ^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0774`. diff --git a/src/test/ui/issues/issue-49934.rs b/src/test/ui/issues/issue-49934.rs index ec73e670634df..5b253750db0b6 100644 --- a/src/test/ui/issues/issue-49934.rs +++ b/src/test/ui/issues/issue-49934.rs @@ -1,4 +1,7 @@ +// check-pass + #![feature(stmt_expr_attributes)] +#![warn(unused_attributes)] //~ NOTE the lint level is defined here fn main() { // fold_stmt (Item) @@ -7,24 +10,26 @@ fn main() { struct Foo; // fold_stmt (Mac) - #[derive(Debug)] //~ ERROR `derive` may only be applied to structs, enums and unions + #[derive(Debug)] + //~^ WARN `#[derive]` does nothing on macro invocations + //~| NOTE this may become a hard error in a future release println!("Hello, world!"); // fold_stmt (Semi) - #[derive(Debug)] //~ ERROR `derive` may only be applied to structs, enums and unions + #[derive(Debug)] //~ WARN unused attribute "Hello, world!"; // fold_stmt (Local) - #[derive(Debug)] //~ ERROR `derive` may only be applied to structs, enums and unions + #[derive(Debug)] //~ WARN unused attribute let _ = "Hello, world!"; // visit_expr let _ = #[derive(Debug)] "Hello, world!"; - //~^ ERROR `derive` may only be applied to structs, enums and unions + //~^ WARN unused attribute let _ = [ // filter_map_expr - #[derive(Debug)] //~ ERROR `derive` may only be applied to structs, enums and unions - "Hello, world!", + #[derive(Debug)] //~ WARN unused attribute + "Hello, world!" ]; } diff --git a/src/test/ui/issues/issue-49934.stderr b/src/test/ui/issues/issue-49934.stderr index 7746ad287ab79..8a5596521ec55 100644 --- a/src/test/ui/issues/issue-49934.stderr +++ b/src/test/ui/issues/issue-49934.stderr @@ -1,33 +1,40 @@ -error[E0774]: `derive` may only be applied to structs, enums and unions - --> $DIR/issue-49934.rs:10:5 +warning: `#[derive]` does nothing on macro invocations + --> $DIR/issue-49934.rs:13:5 | LL | #[derive(Debug)] | ^^^^^^^^^^^^^^^^ + | + = note: this may become a hard error in a future release -error[E0774]: `derive` may only be applied to structs, enums and unions - --> $DIR/issue-49934.rs:14:5 +warning: unused attribute + --> $DIR/issue-49934.rs:19:5 | LL | #[derive(Debug)] | ^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/issue-49934.rs:4:9 + | +LL | #![warn(unused_attributes)] + | ^^^^^^^^^^^^^^^^^ -error[E0774]: `derive` may only be applied to structs, enums and unions - --> $DIR/issue-49934.rs:18:5 +warning: unused attribute + --> $DIR/issue-49934.rs:23:5 | LL | #[derive(Debug)] | ^^^^^^^^^^^^^^^^ -error[E0774]: `derive` may only be applied to structs, enums and unions - --> $DIR/issue-49934.rs:22:13 +warning: unused attribute + --> $DIR/issue-49934.rs:27:13 | LL | let _ = #[derive(Debug)] "Hello, world!"; | ^^^^^^^^^^^^^^^^ -error[E0774]: `derive` may only be applied to structs, enums and unions - --> $DIR/issue-49934.rs:27:9 +warning: unused attribute + --> $DIR/issue-49934.rs:32:9 | LL | #[derive(Debug)] | ^^^^^^^^^^^^^^^^ -error: aborting due to 5 previous errors +warning: 5 warnings emitted -For more information about this error, try `rustc --explain E0774`. diff --git a/src/test/ui/issues/issue-50264-inner-deref-trait/result-as_deref.stderr b/src/test/ui/issues/issue-50264-inner-deref-trait/result-as_deref.stderr index 9711e27d8a8a3..e41c04ee89e0f 100644 --- a/src/test/ui/issues/issue-50264-inner-deref-trait/result-as_deref.stderr +++ b/src/test/ui/issues/issue-50264-inner-deref-trait/result-as_deref.stderr @@ -1,4 +1,4 @@ -error[E0599]: the method `as_deref` exists for enum `Result<{integer}, _>`, but its trait bounds were not satisfied +error[E0599]: the method `as_deref` exists for enum `std::result::Result<{integer}, _>`, but its trait bounds were not satisfied --> $DIR/result-as_deref.rs:2:27 | LL | let _result = &Ok(42).as_deref(); diff --git a/src/test/ui/issues/issue-50264-inner-deref-trait/result-as_deref_mut.stderr b/src/test/ui/issues/issue-50264-inner-deref-trait/result-as_deref_mut.stderr index ee7ea1e6a0229..372d056fc1908 100644 --- a/src/test/ui/issues/issue-50264-inner-deref-trait/result-as_deref_mut.stderr +++ b/src/test/ui/issues/issue-50264-inner-deref-trait/result-as_deref_mut.stderr @@ -1,8 +1,8 @@ -error[E0599]: the method `as_deref_mut` exists for enum `Result<{integer}, _>`, but its trait bounds were not satisfied +error[E0599]: the method `as_deref_mut` exists for enum `std::result::Result<{integer}, _>`, but its trait bounds were not satisfied --> $DIR/result-as_deref_mut.rs:2:31 | LL | let _result = &mut Ok(42).as_deref_mut(); - | ^^^^^^^^^^^^ method cannot be called on `Result<{integer}, _>` due to unsatisfied trait bounds + | ^^^^^^^^^^^^ method cannot be called on `std::result::Result<{integer}, _>` due to unsatisfied trait bounds | = note: the following trait bounds were not satisfied: `{integer}: DerefMut` diff --git a/src/test/ui/issues/issue-51632-try-desugar-incompatible-types.stderr b/src/test/ui/issues/issue-51632-try-desugar-incompatible-types.stderr index 554ac7e7c75fc..9ca983df30af5 100644 --- a/src/test/ui/issues/issue-51632-try-desugar-incompatible-types.stderr +++ b/src/test/ui/issues/issue-51632-try-desugar-incompatible-types.stderr @@ -2,9 +2,9 @@ error[E0308]: try expression alternatives have incompatible types --> $DIR/issue-51632-try-desugar-incompatible-types.rs:8:5 | LL | missing_discourses()? - | ^^^^^^^^^^^^^^^^^^^^^ expected enum `Result`, found `isize` + | ^^^^^^^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found `isize` | - = note: expected enum `Result` + = note: expected enum `std::result::Result` found type `isize` help: try removing this `?` | diff --git a/src/test/ui/issues/issue-6458-4.stderr b/src/test/ui/issues/issue-6458-4.stderr index 0cf82d37d5d0b..00ebff9007ded 100644 --- a/src/test/ui/issues/issue-6458-4.stderr +++ b/src/test/ui/issues/issue-6458-4.stderr @@ -2,13 +2,13 @@ error[E0308]: mismatched types --> $DIR/issue-6458-4.rs:1:20 | LL | fn foo(b: bool) -> Result { - | --- ^^^^^^^^^^^^^^^^^^^ expected enum `Result`, found `()` + | --- ^^^^^^^^^^^^^^^^^^^ expected enum `std::result::Result`, found `()` | | | implicitly returns `()` as its body has no tail or `return` expression LL | Err("bar".to_string()); | - help: consider removing this semicolon | - = note: expected enum `Result` + = note: expected enum `std::result::Result` found unit type `()` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-75307.stderr b/src/test/ui/issues/issue-75307.stderr index 10c952006c208..4a5d997e00d74 100644 --- a/src/test/ui/issues/issue-75307.stderr +++ b/src/test/ui/issues/issue-75307.stderr @@ -1,8 +1,8 @@ error: invalid reference to positional arguments 1 and 2 (there is 1 argument) - --> $DIR/issue-75307.rs:2:17 + --> $DIR/issue-75307.rs:2:13 | LL | format!(r"{}{}{}", named_arg=1); - | ^^^^ + | ^^^^^^^^^ | = note: positional arguments are zero-based diff --git a/src/test/ui/issues/issue-80607.stderr b/src/test/ui/issues/issue-80607.stderr index 22a660b4167d3..5375478942b18 100644 --- a/src/test/ui/issues/issue-80607.stderr +++ b/src/test/ui/issues/issue-80607.stderr @@ -7,7 +7,7 @@ LL | V1(i32), LL | Enum::V1 { x } | -------- ^ field does not exist | | - | help: `Enum::V1` is a tuple variant, use the appropriate syntax: `Enum::V1(/* fields */)` + | `Enum::V1` is a tuple variant, use the appropriate syntax: `Enum::V1(/* fields */)` error: aborting due to previous error diff --git a/src/test/ui/lifetimes/lifetime-bound-will-change-warning.nll.stderr b/src/test/ui/lifetimes/lifetime-bound-will-change-warning.nll.stderr index 57dab46df6b6a..60420973e1ee0 100644 --- a/src/test/ui/lifetimes/lifetime-bound-will-change-warning.nll.stderr +++ b/src/test/ui/lifetimes/lifetime-bound-will-change-warning.nll.stderr @@ -22,4 +22,3 @@ LL | lib::ref_obj(x) error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr b/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr index ef1127c59ac4c..c3d597bec2e40 100644 --- a/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr +++ b/src/test/ui/lifetimes/lifetime-elision-return-type-trait.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `Result<(), _>: Future` is not satisfied +error[E0277]: the trait bound `std::result::Result<(), _>: Future` is not satisfied --> $DIR/lifetime-elision-return-type-trait.rs:8:13 | LL | fn foo() -> impl Future> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Future` is not implemented for `Result<(), _>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Future` is not implemented for `std::result::Result<(), _>` error: aborting due to previous error diff --git a/src/test/ui/limits/issue-75158-64.rs b/src/test/ui/limits/issue-75158-64.rs deleted file mode 100644 index 06c209c078f19..0000000000000 --- a/src/test/ui/limits/issue-75158-64.rs +++ /dev/null @@ -1,16 +0,0 @@ -//~ ERROR - -// build-fail -// ignore-32bit - -struct S { - x: [T; !0], -} - -pub fn f() -> usize { - std::mem::size_of::>() -} - -fn main() { - let x = f(); -} diff --git a/src/test/ui/limits/issue-75158-64.stderr b/src/test/ui/limits/issue-75158-64.stderr deleted file mode 100644 index dc11d05615427..0000000000000 --- a/src/test/ui/limits/issue-75158-64.stderr +++ /dev/null @@ -1,4 +0,0 @@ -error: values of the type `[u8; 18446744073709551615]` are too big for the current architecture - -error: aborting due to previous error - diff --git a/src/test/ui/lint/forbid-group-group-1.rs b/src/test/ui/lint/forbid-group-group-1.rs deleted file mode 100644 index 80f7db4e56036..0000000000000 --- a/src/test/ui/lint/forbid-group-group-1.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Check what happens when we forbid a smaller group but -// then allow a superset of that group. - -#![forbid(nonstandard_style)] - -// FIXME: Arguably this should be an error, but the WARNINGS group is -// treated in a very special (and rather ad-hoc) way and -// it fails to trigger. -#[allow(warnings)] -fn main() { - let A: (); - //~^ ERROR should have a snake case name -} diff --git a/src/test/ui/lint/forbid-group-group-1.stderr b/src/test/ui/lint/forbid-group-group-1.stderr deleted file mode 100644 index fd425e5f74e6f..0000000000000 --- a/src/test/ui/lint/forbid-group-group-1.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: variable `A` should have a snake case name - --> $DIR/forbid-group-group-1.rs:11:9 - | -LL | let A: (); - | ^ help: convert the identifier to snake case: `a` - | -note: the lint level is defined here - --> $DIR/forbid-group-group-1.rs:4:11 - | -LL | #![forbid(nonstandard_style)] - | ^^^^^^^^^^^^^^^^^ - = note: `#[forbid(non_snake_case)]` implied by `#[forbid(nonstandard_style)]` - -error: aborting due to previous error - diff --git a/src/test/ui/lint/forbid-group-group-2.rs b/src/test/ui/lint/forbid-group-group-2.rs deleted file mode 100644 index b12fd72da7494..0000000000000 --- a/src/test/ui/lint/forbid-group-group-2.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Check what happens when we forbid a bigger group but -// then deny a subset of that group. - -#![forbid(warnings)] -#![deny(forbidden_lint_groups)] - -#[allow(nonstandard_style)] -//~^ ERROR incompatible with previous -//~| WARNING previously accepted by the compiler -//~| ERROR incompatible with previous -//~| WARNING previously accepted by the compiler -//~| ERROR incompatible with previous -//~| WARNING previously accepted by the compiler -//~| ERROR incompatible with previous -//~| WARNING previously accepted by the compiler -//~| ERROR incompatible with previous -//~| WARNING previously accepted by the compiler -//~| ERROR incompatible with previous -//~| WARNING previously accepted by the compiler -//~| ERROR incompatible with previous -//~| WARNING previously accepted by the compiler -//~| ERROR incompatible with previous -//~| WARNING previously accepted by the compiler -//~| ERROR incompatible with previous -//~| WARNING previously accepted by the compiler -fn main() {} diff --git a/src/test/ui/lint/forbid-group-group-2.stderr b/src/test/ui/lint/forbid-group-group-2.stderr deleted file mode 100644 index 214e949c11a74..0000000000000 --- a/src/test/ui/lint/forbid-group-group-2.stderr +++ /dev/null @@ -1,115 +0,0 @@ -error: allow(nonstandard_style) incompatible with previous forbid - --> $DIR/forbid-group-group-2.rs:7:9 - | -LL | #![forbid(warnings)] - | -------- `forbid` level set here -... -LL | #[allow(nonstandard_style)] - | ^^^^^^^^^^^^^^^^^ overruled by previous forbid - | -note: the lint level is defined here - --> $DIR/forbid-group-group-2.rs:5:9 - | -LL | #![deny(forbidden_lint_groups)] - | ^^^^^^^^^^^^^^^^^^^^^ - = 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 #81670 - -error: allow(nonstandard_style) incompatible with previous forbid - --> $DIR/forbid-group-group-2.rs:7:9 - | -LL | #![forbid(warnings)] - | -------- `forbid` level set here -... -LL | #[allow(nonstandard_style)] - | ^^^^^^^^^^^^^^^^^ overruled by previous forbid - | - = 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 #81670 - -error: allow(nonstandard_style) incompatible with previous forbid - --> $DIR/forbid-group-group-2.rs:7:9 - | -LL | #![forbid(warnings)] - | -------- `forbid` level set here -... -LL | #[allow(nonstandard_style)] - | ^^^^^^^^^^^^^^^^^ overruled by previous forbid - | - = 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 #81670 - -error: allow(nonstandard_style) incompatible with previous forbid - --> $DIR/forbid-group-group-2.rs:7:9 - | -LL | #![forbid(warnings)] - | -------- `forbid` level set here -... -LL | #[allow(nonstandard_style)] - | ^^^^^^^^^^^^^^^^^ overruled by previous forbid - | - = 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 #81670 - -error: allow(nonstandard_style) incompatible with previous forbid - --> $DIR/forbid-group-group-2.rs:7:9 - | -LL | #![forbid(warnings)] - | -------- `forbid` level set here -... -LL | #[allow(nonstandard_style)] - | ^^^^^^^^^^^^^^^^^ overruled by previous forbid - | - = 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 #81670 - -error: allow(nonstandard_style) incompatible with previous forbid - --> $DIR/forbid-group-group-2.rs:7:9 - | -LL | #![forbid(warnings)] - | -------- `forbid` level set here -... -LL | #[allow(nonstandard_style)] - | ^^^^^^^^^^^^^^^^^ overruled by previous forbid - | - = 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 #81670 - -error: allow(nonstandard_style) incompatible with previous forbid - --> $DIR/forbid-group-group-2.rs:7:9 - | -LL | #![forbid(warnings)] - | -------- `forbid` level set here -... -LL | #[allow(nonstandard_style)] - | ^^^^^^^^^^^^^^^^^ overruled by previous forbid - | - = 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 #81670 - -error: allow(nonstandard_style) incompatible with previous forbid - --> $DIR/forbid-group-group-2.rs:7:9 - | -LL | #![forbid(warnings)] - | -------- `forbid` level set here -... -LL | #[allow(nonstandard_style)] - | ^^^^^^^^^^^^^^^^^ overruled by previous forbid - | - = 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 #81670 - -error: allow(nonstandard_style) incompatible with previous forbid - --> $DIR/forbid-group-group-2.rs:7:9 - | -LL | #![forbid(warnings)] - | -------- `forbid` level set here -... -LL | #[allow(nonstandard_style)] - | ^^^^^^^^^^^^^^^^^ overruled by previous forbid - | - = 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 #81670 - -error: aborting due to 9 previous errors - diff --git a/src/test/ui/lint/forbid-group-member.rs b/src/test/ui/lint/forbid-group-member.rs deleted file mode 100644 index 6f1b2e9f66812..0000000000000 --- a/src/test/ui/lint/forbid-group-member.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Check what happens when we forbid a group but -// then allow a member of that group. -// -// check-pass - -#![forbid(unused)] - -#[allow(unused_variables)] -//~^ WARNING incompatible with previous forbid -//~| WARNING previously accepted -//~| WARNING incompatible with previous forbid -//~| WARNING previously accepted -//~| WARNING incompatible with previous forbid -//~| WARNING previously accepted -//~| WARNING incompatible with previous forbid -//~| WARNING previously accepted -fn main() { - let a: (); -} diff --git a/src/test/ui/lint/forbid-group-member.stderr b/src/test/ui/lint/forbid-group-member.stderr deleted file mode 100644 index c818d7ff60605..0000000000000 --- a/src/test/ui/lint/forbid-group-member.stderr +++ /dev/null @@ -1,51 +0,0 @@ -warning: allow(unused_variables) incompatible with previous forbid - --> $DIR/forbid-group-member.rs:8:9 - | -LL | #![forbid(unused)] - | ------ `forbid` level set here -LL | -LL | #[allow(unused_variables)] - | ^^^^^^^^^^^^^^^^ overruled by previous forbid - | - = note: `#[warn(forbidden_lint_groups)]` 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 #81670 - -warning: allow(unused_variables) incompatible with previous forbid - --> $DIR/forbid-group-member.rs:8:9 - | -LL | #![forbid(unused)] - | ------ `forbid` level set here -LL | -LL | #[allow(unused_variables)] - | ^^^^^^^^^^^^^^^^ overruled by previous forbid - | - = 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 #81670 - -warning: allow(unused_variables) incompatible with previous forbid - --> $DIR/forbid-group-member.rs:8:9 - | -LL | #![forbid(unused)] - | ------ `forbid` level set here -LL | -LL | #[allow(unused_variables)] - | ^^^^^^^^^^^^^^^^ overruled by previous forbid - | - = 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 #81670 - -warning: allow(unused_variables) incompatible with previous forbid - --> $DIR/forbid-group-member.rs:8:9 - | -LL | #![forbid(unused)] - | ------ `forbid` level set here -LL | -LL | #[allow(unused_variables)] - | ^^^^^^^^^^^^^^^^ overruled by previous forbid - | - = 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 #81670 - -warning: 4 warnings emitted - diff --git a/src/test/ui/lint/forbid-member-group.rs b/src/test/ui/lint/forbid-member-group.rs deleted file mode 100644 index 3279029a9cbc3..0000000000000 --- a/src/test/ui/lint/forbid-member-group.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Check what happens when we forbid a member of -// a group but then allow the group. - -#![forbid(unused_variables)] - -#[allow(unused)] -//~^ ERROR incompatible with previous forbid -//~| ERROR incompatible with previous forbid -//~| ERROR incompatible with previous forbid -fn main() { - let a: (); -} diff --git a/src/test/ui/lint/forbid-member-group.stderr b/src/test/ui/lint/forbid-member-group.stderr deleted file mode 100644 index 1d8ab4d5edb0c..0000000000000 --- a/src/test/ui/lint/forbid-member-group.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0453]: allow(unused) incompatible with previous forbid - --> $DIR/forbid-member-group.rs:6:9 - | -LL | #![forbid(unused_variables)] - | ---------------- `forbid` level set here -LL | -LL | #[allow(unused)] - | ^^^^^^ overruled by previous forbid - -error[E0453]: allow(unused) incompatible with previous forbid - --> $DIR/forbid-member-group.rs:6:9 - | -LL | #![forbid(unused_variables)] - | ---------------- `forbid` level set here -LL | -LL | #[allow(unused)] - | ^^^^^^ overruled by previous forbid - -error[E0453]: allow(unused) incompatible with previous forbid - --> $DIR/forbid-member-group.rs:6:9 - | -LL | #![forbid(unused_variables)] - | ---------------- `forbid` level set here -LL | -LL | #[allow(unused)] - | ^^^^^^ overruled by previous forbid - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0453`. diff --git a/src/test/ui/limits/issue-69485-var-size-diffs-too-large.rs b/src/test/ui/lint/issue-69485-var-size-diffs-too-large.rs similarity index 100% rename from src/test/ui/limits/issue-69485-var-size-diffs-too-large.rs rename to src/test/ui/lint/issue-69485-var-size-diffs-too-large.rs diff --git a/src/test/ui/limits/issue-69485-var-size-diffs-too-large.stderr b/src/test/ui/lint/issue-69485-var-size-diffs-too-large.stderr similarity index 100% rename from src/test/ui/limits/issue-69485-var-size-diffs-too-large.stderr rename to src/test/ui/lint/issue-69485-var-size-diffs-too-large.stderr diff --git a/src/test/ui/lint/issue-70819-dont-override-forbid-in-same-scope.rs b/src/test/ui/lint/issue-70819-dont-override-forbid-in-same-scope.rs index 05d7d924c8fab..f725304cf29d4 100644 --- a/src/test/ui/lint/issue-70819-dont-override-forbid-in-same-scope.rs +++ b/src/test/ui/lint/issue-70819-dont-override-forbid-in-same-scope.rs @@ -14,17 +14,14 @@ // compile-flags: -Z deduplicate-diagnostics=yes -#![forbid(forbidden_lint_groups)] - fn forbid_first(num: i32) -> i32 { #![forbid(unused)] #![deny(unused)] //~^ ERROR: deny(unused) incompatible with previous forbid - //~| WARNING being phased out - //~| ERROR: deny(unused) incompatible with previous forbid - //~| WARNING being phased out #![warn(unused)] + //~^ ERROR: warn(unused) incompatible with previous forbid #![allow(unused)] + //~^ ERROR: allow(unused) incompatible with previous forbid num * num } diff --git a/src/test/ui/lint/issue-70819-dont-override-forbid-in-same-scope.stderr b/src/test/ui/lint/issue-70819-dont-override-forbid-in-same-scope.stderr index 475410cecffa3..9f107411c102a 100644 --- a/src/test/ui/lint/issue-70819-dont-override-forbid-in-same-scope.stderr +++ b/src/test/ui/lint/issue-70819-dont-override-forbid-in-same-scope.stderr @@ -1,29 +1,29 @@ -error: deny(unused) incompatible with previous forbid - --> $DIR/issue-70819-dont-override-forbid-in-same-scope.rs:21:13 +error[E0453]: deny(unused) incompatible with previous forbid + --> $DIR/issue-70819-dont-override-forbid-in-same-scope.rs:19:13 | LL | #![forbid(unused)] | ------ `forbid` level set here LL | #![deny(unused)] | ^^^^^^ overruled by previous forbid - | -note: the lint level is defined here - --> $DIR/issue-70819-dont-override-forbid-in-same-scope.rs:17:11 - | -LL | #![forbid(forbidden_lint_groups)] - | ^^^^^^^^^^^^^^^^^^^^^ - = 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 #81670 -error: deny(unused) incompatible with previous forbid +error[E0453]: warn(unused) incompatible with previous forbid --> $DIR/issue-70819-dont-override-forbid-in-same-scope.rs:21:13 | LL | #![forbid(unused)] | ------ `forbid` level set here -LL | #![deny(unused)] +... +LL | #![warn(unused)] | ^^^^^^ overruled by previous forbid + +error[E0453]: allow(unused) incompatible with previous forbid + --> $DIR/issue-70819-dont-override-forbid-in-same-scope.rs:23:14 | - = 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 #81670 +LL | #![forbid(unused)] + | ------ `forbid` level set here +... +LL | #![allow(unused)] + | ^^^^^^ overruled by previous forbid -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0453`. diff --git a/src/test/ui/lint/issue-80988.rs b/src/test/ui/lint/issue-80988.rs deleted file mode 100644 index 16a041928db73..0000000000000 --- a/src/test/ui/lint/issue-80988.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Regression test for #80988 -// -// check-pass - -#![forbid(warnings)] - -#[deny(warnings)] -//~^ WARNING incompatible with previous forbid -//~| WARNING being phased out -//~| WARNING incompatible with previous forbid -//~| WARNING being phased out -//~| WARNING incompatible with previous forbid -//~| WARNING being phased out -//~| WARNING incompatible with previous forbid -//~| WARNING being phased out -fn main() {} diff --git a/src/test/ui/lint/issue-80988.stderr b/src/test/ui/lint/issue-80988.stderr deleted file mode 100644 index 4cae11f97c0fb..0000000000000 --- a/src/test/ui/lint/issue-80988.stderr +++ /dev/null @@ -1,51 +0,0 @@ -warning: deny(warnings) incompatible with previous forbid - --> $DIR/issue-80988.rs:7:8 - | -LL | #![forbid(warnings)] - | -------- `forbid` level set here -LL | -LL | #[deny(warnings)] - | ^^^^^^^^ overruled by previous forbid - | - = note: `#[warn(forbidden_lint_groups)]` 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 #81670 - -warning: deny(warnings) incompatible with previous forbid - --> $DIR/issue-80988.rs:7:8 - | -LL | #![forbid(warnings)] - | -------- `forbid` level set here -LL | -LL | #[deny(warnings)] - | ^^^^^^^^ overruled by previous forbid - | - = 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 #81670 - -warning: deny(warnings) incompatible with previous forbid - --> $DIR/issue-80988.rs:7:8 - | -LL | #![forbid(warnings)] - | -------- `forbid` level set here -LL | -LL | #[deny(warnings)] - | ^^^^^^^^ overruled by previous forbid - | - = 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 #81670 - -warning: deny(warnings) incompatible with previous forbid - --> $DIR/issue-80988.rs:7:8 - | -LL | #![forbid(warnings)] - | -------- `forbid` level set here -LL | -LL | #[deny(warnings)] - | ^^^^^^^^ overruled by previous forbid - | - = 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 #81670 - -warning: 4 warnings emitted - diff --git a/src/test/ui/lint/issue-81218.rs b/src/test/ui/lint/issue-81218.rs deleted file mode 100644 index f02aa9040ebc5..0000000000000 --- a/src/test/ui/lint/issue-81218.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Regression test for #81218 -// -// check-pass - -#![forbid(warnings)] - -#[allow(unused_variables)] -fn main() { - // We want to ensure that you don't get an error - // here. The idea is that a derive might generate - // code that would otherwise trigger the "unused variables" - // lint, but it is meant to be suppressed. - let x: (); -} diff --git a/src/test/ui/lint/lint-ctypes-enum.stderr b/src/test/ui/lint/lint-ctypes-enum.stderr index f3991ab417752..8917d309e6087 100644 --- a/src/test/ui/lint/lint-ctypes-enum.stderr +++ b/src/test/ui/lint/lint-ctypes-enum.stderr @@ -97,7 +97,7 @@ LL | fn repr_rust(x: Option>); = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum = note: enum has no representation hint -error: `extern` block uses type `Result<(), NonZeroI32>`, which is not FFI-safe +error: `extern` block uses type `std::result::Result<(), NonZeroI32>`, which is not FFI-safe --> $DIR/lint-ctypes-enum.rs:90:20 | LL | fn no_result(x: Result<(), num::NonZeroI32>); diff --git a/src/test/ui/lint/lint-unsafe-code.rs b/src/test/ui/lint/lint-unsafe-code.rs index 4ac02b51f62fe..735f33f601f9d 100644 --- a/src/test/ui/lint/lint-unsafe-code.rs +++ b/src/test/ui/lint/lint-unsafe-code.rs @@ -12,28 +12,14 @@ mod allowed_unsafe { unsafe fn also_allowed() {} unsafe trait AllowedUnsafe { } unsafe impl AllowedUnsafe for super::Bar {} - #[no_mangle] fn allowed2() {} - #[export_name = "foo"] fn allowed3() {} } macro_rules! unsafe_in_macro { - () => {{ - #[no_mangle] fn foo() {} //~ ERROR: declaration of a `no_mangle` function - #[no_mangle] static FOO: u32 = 5; //~ ERROR: declaration of a `no_mangle` static - #[export_name = "bar"] fn bar() {} - //~^ ERROR: declaration of a function with `export_name` - #[export_name = "BAR"] static BAR: u32 = 5; - //~^ ERROR: declaration of a static with `export_name` + () => { unsafe {} //~ ERROR: usage of an `unsafe` block - }} + } } -#[no_mangle] fn foo() {} //~ ERROR: declaration of a `no_mangle` function -#[no_mangle] static FOO: u32 = 5; //~ ERROR: declaration of a `no_mangle` static - -#[export_name = "bar"] fn bar() {} //~ ERROR: declaration of a function with `export_name` -#[export_name = "BAR"] static BAR: u32 = 5; //~ ERROR: declaration of a static with `export_name` - unsafe fn baz() {} //~ ERROR: declaration of an `unsafe` function unsafe trait Foo {} //~ ERROR: declaration of an `unsafe` trait unsafe impl Foo for Bar {} //~ ERROR: implementation of an `unsafe` trait diff --git a/src/test/ui/lint/lint-unsafe-code.stderr b/src/test/ui/lint/lint-unsafe-code.stderr index a8ef047e517b4..0b2b9fab3925e 100644 --- a/src/test/ui/lint/lint-unsafe-code.stderr +++ b/src/test/ui/lint/lint-unsafe-code.stderr @@ -1,168 +1,89 @@ -error: declaration of a `no_mangle` function - --> $DIR/lint-unsafe-code.rs:31:1 +error: declaration of an `unsafe` function + --> $DIR/lint-unsafe-code.rs:23:1 | -LL | #[no_mangle] fn foo() {} - | ^^^^^^^^^^^^ +LL | unsafe fn baz() {} + | ^^^^^^^^^^^^^^^^^^ | note: the lint level is defined here --> $DIR/lint-unsafe-code.rs:3:9 | LL | #![deny(unsafe_code)] | ^^^^^^^^^^^ - = note: the linker's behavior with multiple libraries exporting duplicate symbol names is undefined and Rust cannot provide guarantees when you manually override them - -error: declaration of a `no_mangle` static - --> $DIR/lint-unsafe-code.rs:32:1 - | -LL | #[no_mangle] static FOO: u32 = 5; - | ^^^^^^^^^^^^ - | - = note: the linker's behavior with multiple libraries exporting duplicate symbol names is undefined and Rust cannot provide guarantees when you manually override them - -error: declaration of a function with `export_name` - --> $DIR/lint-unsafe-code.rs:34:1 - | -LL | #[export_name = "bar"] fn bar() {} - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the linker's behavior with multiple libraries exporting duplicate symbol names is undefined and Rust cannot provide guarantees when you manually override them - -error: declaration of a static with `export_name` - --> $DIR/lint-unsafe-code.rs:35:1 - | -LL | #[export_name = "BAR"] static BAR: u32 = 5; - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the linker's behavior with multiple libraries exporting duplicate symbol names is undefined and Rust cannot provide guarantees when you manually override them - -error: declaration of an `unsafe` function - --> $DIR/lint-unsafe-code.rs:37:1 - | -LL | unsafe fn baz() {} - | ^^^^^^^^^^^^^^^^^^ error: declaration of an `unsafe` trait - --> $DIR/lint-unsafe-code.rs:38:1 + --> $DIR/lint-unsafe-code.rs:24:1 | LL | unsafe trait Foo {} | ^^^^^^^^^^^^^^^^^^^ error: implementation of an `unsafe` trait - --> $DIR/lint-unsafe-code.rs:39:1 + --> $DIR/lint-unsafe-code.rs:25:1 | LL | unsafe impl Foo for Bar {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: declaration of an `unsafe` method - --> $DIR/lint-unsafe-code.rs:42:5 + --> $DIR/lint-unsafe-code.rs:28:5 | LL | unsafe fn baz(&self); | ^^^^^^^^^^^^^^^^^^^^^ error: implementation of an `unsafe` method - --> $DIR/lint-unsafe-code.rs:43:5 + --> $DIR/lint-unsafe-code.rs:29:5 | LL | unsafe fn provided(&self) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: implementation of an `unsafe` method - --> $DIR/lint-unsafe-code.rs:44:5 + --> $DIR/lint-unsafe-code.rs:30:5 | LL | unsafe fn provided_override(&self) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: implementation of an `unsafe` method - --> $DIR/lint-unsafe-code.rs:48:5 + --> $DIR/lint-unsafe-code.rs:34:5 | LL | unsafe fn baz(&self) {} | ^^^^^^^^^^^^^^^^^^^^^^^ error: implementation of an `unsafe` method - --> $DIR/lint-unsafe-code.rs:49:5 + --> $DIR/lint-unsafe-code.rs:35:5 | LL | unsafe fn provided_override(&self) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: implementation of an `unsafe` method - --> $DIR/lint-unsafe-code.rs:68:5 + --> $DIR/lint-unsafe-code.rs:54:5 | LL | unsafe fn provided_override(&self) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: implementation of an `unsafe` method - --> $DIR/lint-unsafe-code.rs:79:5 + --> $DIR/lint-unsafe-code.rs:65:5 | LL | unsafe fn provided(&self) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: implementation of an `unsafe` method - --> $DIR/lint-unsafe-code.rs:85:5 + --> $DIR/lint-unsafe-code.rs:71:5 | LL | unsafe fn provided(&self) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: implementation of an `unsafe` method - --> $DIR/lint-unsafe-code.rs:89:5 + --> $DIR/lint-unsafe-code.rs:75:5 | LL | unsafe fn baz(&self) {} | ^^^^^^^^^^^^^^^^^^^^^^^ error: usage of an `unsafe` block - --> $DIR/lint-unsafe-code.rs:100:5 + --> $DIR/lint-unsafe-code.rs:86:5 | LL | unsafe {} | ^^^^^^^^^ -error: declaration of a `no_mangle` function - --> $DIR/lint-unsafe-code.rs:21:9 - | -LL | #[no_mangle] fn foo() {} - | ^^^^^^^^^^^^ -... -LL | unsafe_in_macro!() - | ------------------ in this macro invocation - | - = note: the linker's behavior with multiple libraries exporting duplicate symbol names is undefined and Rust cannot provide guarantees when you manually override them - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: declaration of a `no_mangle` static - --> $DIR/lint-unsafe-code.rs:22:9 - | -LL | #[no_mangle] static FOO: u32 = 5; - | ^^^^^^^^^^^^ -... -LL | unsafe_in_macro!() - | ------------------ in this macro invocation - | - = note: the linker's behavior with multiple libraries exporting duplicate symbol names is undefined and Rust cannot provide guarantees when you manually override them - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: declaration of a function with `export_name` - --> $DIR/lint-unsafe-code.rs:23:9 - | -LL | #[export_name = "bar"] fn bar() {} - | ^^^^^^^^^^^^^^^^^^^^^^ -... -LL | unsafe_in_macro!() - | ------------------ in this macro invocation - | - = note: the linker's behavior with multiple libraries exporting duplicate symbol names is undefined and Rust cannot provide guarantees when you manually override them - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: declaration of a static with `export_name` - --> $DIR/lint-unsafe-code.rs:25:9 - | -LL | #[export_name = "BAR"] static BAR: u32 = 5; - | ^^^^^^^^^^^^^^^^^^^^^^ -... -LL | unsafe_in_macro!() - | ------------------ in this macro invocation - | - = note: the linker's behavior with multiple libraries exporting duplicate symbol names is undefined and Rust cannot provide guarantees when you manually override them - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - error: usage of an `unsafe` block - --> $DIR/lint-unsafe-code.rs:27:9 + --> $DIR/lint-unsafe-code.rs:19:9 | LL | unsafe {} | ^^^^^^^^^ @@ -172,5 +93,5 @@ LL | unsafe_in_macro!() | = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 22 previous errors +error: aborting due to 14 previous errors diff --git a/src/test/ui/lint/must_use-tuple.rs b/src/test/ui/lint/must_use-tuple.rs index 0f0aa20253c96..f6b579a7f35cf 100644 --- a/src/test/ui/lint/must_use-tuple.rs +++ b/src/test/ui/lint/must_use-tuple.rs @@ -5,13 +5,13 @@ fn foo() -> (Result<(), ()>, ()) { } fn main() { - (Ok::<(), ()>(()),); //~ ERROR unused `Result` + (Ok::<(), ()>(()),); //~ ERROR unused `std::result::Result` (Ok::<(), ()>(()), 0, Ok::<(), ()>(()), 5); - //~^ ERROR unused `Result` - //~^^ ERROR unused `Result` + //~^ ERROR unused `std::result::Result` + //~^^ ERROR unused `std::result::Result` - foo(); //~ ERROR unused `Result` + foo(); //~ ERROR unused `std::result::Result` - ((Err::<(), ()>(()), ()), ()); //~ ERROR unused `Result` + ((Err::<(), ()>(()), ()), ()); //~ ERROR unused `std::result::Result` } diff --git a/src/test/ui/lint/must_use-tuple.stderr b/src/test/ui/lint/must_use-tuple.stderr index 0532d89e039eb..de3c6f46c6867 100644 --- a/src/test/ui/lint/must_use-tuple.stderr +++ b/src/test/ui/lint/must_use-tuple.stderr @@ -1,4 +1,4 @@ -error: unused `Result` in tuple element 0 that must be used +error: unused `std::result::Result` in tuple element 0 that must be used --> $DIR/must_use-tuple.rs:8:6 | LL | (Ok::<(), ()>(()),); @@ -11,7 +11,7 @@ LL | #![deny(unused_must_use)] | ^^^^^^^^^^^^^^^ = note: this `Result` may be an `Err` variant, which should be handled -error: unused `Result` in tuple element 0 that must be used +error: unused `std::result::Result` in tuple element 0 that must be used --> $DIR/must_use-tuple.rs:10:6 | LL | (Ok::<(), ()>(()), 0, Ok::<(), ()>(()), 5); @@ -19,7 +19,7 @@ LL | (Ok::<(), ()>(()), 0, Ok::<(), ()>(()), 5); | = note: this `Result` may be an `Err` variant, which should be handled -error: unused `Result` in tuple element 2 that must be used +error: unused `std::result::Result` in tuple element 2 that must be used --> $DIR/must_use-tuple.rs:10:27 | LL | (Ok::<(), ()>(()), 0, Ok::<(), ()>(()), 5); @@ -27,7 +27,7 @@ LL | (Ok::<(), ()>(()), 0, Ok::<(), ()>(()), 5); | = note: this `Result` may be an `Err` variant, which should be handled -error: unused `Result` in tuple element 0 that must be used +error: unused `std::result::Result` in tuple element 0 that must be used --> $DIR/must_use-tuple.rs:14:5 | LL | foo(); @@ -35,7 +35,7 @@ LL | foo(); | = note: this `Result` may be an `Err` variant, which should be handled -error: unused `Result` in tuple element 0 that must be used +error: unused `std::result::Result` in tuple element 0 that must be used --> $DIR/must_use-tuple.rs:16:6 | LL | ((Err::<(), ()>(()), ()), ()); diff --git a/src/test/ui/lint/outer-forbid.rs b/src/test/ui/lint/outer-forbid.rs index 486ec3c46804f..d45848bf706f3 100644 --- a/src/test/ui/lint/outer-forbid.rs +++ b/src/test/ui/lint/outer-forbid.rs @@ -15,16 +15,11 @@ // compile-flags: -Z deduplicate-diagnostics=yes #![forbid(unused, non_snake_case)] -#![forbid(forbidden_lint_groups)] #[allow(unused_variables)] //~ ERROR incompatible with previous -//~^ ERROR incompatible with previous -//~| WARNING this was previously accepted by the compiler -//~| WARNING this was previously accepted by the compiler fn foo() {} #[allow(unused)] //~ ERROR incompatible with previous -//~^ WARNING this was previously accepted by the compiler fn bar() {} #[allow(nonstandard_style)] //~ ERROR incompatible with previous diff --git a/src/test/ui/lint/outer-forbid.stderr b/src/test/ui/lint/outer-forbid.stderr index d69157a8bb3ad..c012c20697e16 100644 --- a/src/test/ui/lint/outer-forbid.stderr +++ b/src/test/ui/lint/outer-forbid.stderr @@ -1,34 +1,23 @@ -error: allow(unused_variables) incompatible with previous forbid - --> $DIR/outer-forbid.rs:20:9 +error[E0453]: allow(unused_variables) incompatible with previous forbid + --> $DIR/outer-forbid.rs:19:9 | LL | #![forbid(unused, non_snake_case)] | ------ `forbid` level set here -... +LL | LL | #[allow(unused_variables)] | ^^^^^^^^^^^^^^^^ overruled by previous forbid - | -note: the lint level is defined here - --> $DIR/outer-forbid.rs:18:11 - | -LL | #![forbid(forbidden_lint_groups)] - | ^^^^^^^^^^^^^^^^^^^^^ - = 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 #81670 -error: allow(unused) incompatible with previous forbid - --> $DIR/outer-forbid.rs:26:9 +error[E0453]: allow(unused) incompatible with previous forbid + --> $DIR/outer-forbid.rs:22:9 | LL | #![forbid(unused, non_snake_case)] | ------ `forbid` level set here ... LL | #[allow(unused)] | ^^^^^^ overruled by previous forbid - | - = 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 #81670 error[E0453]: allow(nonstandard_style) incompatible with previous forbid - --> $DIR/outer-forbid.rs:30:9 + --> $DIR/outer-forbid.rs:25:9 | LL | #![forbid(unused, non_snake_case)] | -------------- `forbid` level set here @@ -36,18 +25,6 @@ LL | #![forbid(unused, non_snake_case)] LL | #[allow(nonstandard_style)] | ^^^^^^^^^^^^^^^^^ overruled by previous forbid -error: allow(unused_variables) incompatible with previous forbid - --> $DIR/outer-forbid.rs:20:9 - | -LL | #![forbid(unused, non_snake_case)] - | ------ `forbid` level set here -... -LL | #[allow(unused_variables)] - | ^^^^^^^^^^^^^^^^ overruled by previous forbid - | - = 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 #81670 - -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0453`. diff --git a/src/test/ui/lint/semicolon-in-expressions-from-macros/semicolon-in-expressions-from-macros.rs b/src/test/ui/lint/semicolon-in-expressions-from-macros/semicolon-in-expressions-from-macros.rs index 0bbd7dc6c8a7a..605d5a0309cfc 100644 --- a/src/test/ui/lint/semicolon-in-expressions-from-macros/semicolon-in-expressions-from-macros.rs +++ b/src/test/ui/lint/semicolon-in-expressions-from-macros/semicolon-in-expressions-from-macros.rs @@ -1,5 +1,4 @@ // check-pass -// edition:2018 #![warn(semicolon_in_expressions_from_macros)] #[allow(dead_code)] @@ -12,11 +11,6 @@ macro_rules! foo { } } -#[allow(semicolon_in_expressions_from_macros)] -async fn bar() { - foo!(first); -} - fn main() { // This `allow` doesn't work #[allow(semicolon_in_expressions_from_macros)] @@ -33,9 +27,4 @@ fn main() { fn inner() { let _ = foo!(third); } - - #[allow(semicolon_in_expressions_from_macros)] - async { - let _ = foo!(fourth); - }; } diff --git a/src/test/ui/lint/semicolon-in-expressions-from-macros/semicolon-in-expressions-from-macros.stderr b/src/test/ui/lint/semicolon-in-expressions-from-macros/semicolon-in-expressions-from-macros.stderr index bfdce732e029d..6f9f879661a41 100644 --- a/src/test/ui/lint/semicolon-in-expressions-from-macros/semicolon-in-expressions-from-macros.stderr +++ b/src/test/ui/lint/semicolon-in-expressions-from-macros/semicolon-in-expressions-from-macros.stderr @@ -1,5 +1,5 @@ warning: trailing semicolon in macro used in expression position - --> $DIR/semicolon-in-expressions-from-macros.rs:8:13 + --> $DIR/semicolon-in-expressions-from-macros.rs:7:13 | LL | true; | ^ @@ -8,7 +8,7 @@ LL | foo!(first) | ----------- in this macro invocation | note: the lint level is defined here - --> $DIR/semicolon-in-expressions-from-macros.rs:3:9 + --> $DIR/semicolon-in-expressions-from-macros.rs:2:9 | LL | #![warn(semicolon_in_expressions_from_macros)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | #![warn(semicolon_in_expressions_from_macros)] = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) warning: trailing semicolon in macro used in expression position - --> $DIR/semicolon-in-expressions-from-macros.rs:8:13 + --> $DIR/semicolon-in-expressions-from-macros.rs:7:13 | LL | true; | ^ diff --git a/src/test/ui/macros/assert-macro-owned.rs b/src/test/ui/macros/assert-macro-owned.rs index 2846f2a1f8353..b50fe65c0150f 100644 --- a/src/test/ui/macros/assert-macro-owned.rs +++ b/src/test/ui/macros/assert-macro-owned.rs @@ -2,8 +2,6 @@ // error-pattern:panicked at 'test-assert-owned' // ignore-emscripten no processes -#![allow(non_fmt_panic)] - fn main() { assert!(false, "test-assert-owned".to_string()); } diff --git a/src/test/ui/macros/builtin-std-paths-fail.stderr b/src/test/ui/macros/builtin-std-paths-fail.stderr index 4f1a76b0d6e08..9831e46ec30a1 100644 --- a/src/test/ui/macros/builtin-std-paths-fail.stderr +++ b/src/test/ui/macros/builtin-std-paths-fail.stderr @@ -1,15 +1,3 @@ -error[E0433]: failed to resolve: could not find `RustcDecodable` in `core` - --> $DIR/builtin-std-paths-fail.rs:2:11 - | -LL | core::RustcDecodable, - | ^^^^^^^^^^^^^^ could not find `RustcDecodable` in `core` - -error[E0433]: failed to resolve: could not find `RustcDecodable` in `core` - --> $DIR/builtin-std-paths-fail.rs:4:11 - | -LL | core::RustcDecodable, - | ^^^^^^^^^^^^^^ could not find `RustcDecodable` in `core` - error[E0433]: failed to resolve: could not find `bench` in `core` --> $DIR/builtin-std-paths-fail.rs:7:9 | @@ -35,28 +23,28 @@ LL | #[core::test] | ^^^^ could not find `test` in `core` error[E0433]: failed to resolve: could not find `RustcDecodable` in `core` - --> $DIR/builtin-std-paths-fail.rs:4:11 + --> $DIR/builtin-std-paths-fail.rs:2:11 | LL | core::RustcDecodable, | ^^^^^^^^^^^^^^ could not find `RustcDecodable` in `core` error[E0433]: failed to resolve: could not find `RustcDecodable` in `core` - --> $DIR/builtin-std-paths-fail.rs:2:11 + --> $DIR/builtin-std-paths-fail.rs:4:11 | LL | core::RustcDecodable, | ^^^^^^^^^^^^^^ could not find `RustcDecodable` in `core` -error[E0433]: failed to resolve: could not find `RustcDecodable` in `std` - --> $DIR/builtin-std-paths-fail.rs:14:10 +error[E0433]: failed to resolve: could not find `RustcDecodable` in `core` + --> $DIR/builtin-std-paths-fail.rs:4:11 | -LL | std::RustcDecodable, - | ^^^^^^^^^^^^^^ could not find `RustcDecodable` in `std` +LL | core::RustcDecodable, + | ^^^^^^^^^^^^^^ could not find `RustcDecodable` in `core` -error[E0433]: failed to resolve: could not find `RustcDecodable` in `std` - --> $DIR/builtin-std-paths-fail.rs:16:10 +error[E0433]: failed to resolve: could not find `RustcDecodable` in `core` + --> $DIR/builtin-std-paths-fail.rs:2:11 | -LL | std::RustcDecodable, - | ^^^^^^^^^^^^^^ could not find `RustcDecodable` in `std` +LL | core::RustcDecodable, + | ^^^^^^^^^^^^^^ could not find `RustcDecodable` in `core` error[E0433]: failed to resolve: could not find `bench` in `std` --> $DIR/builtin-std-paths-fail.rs:19:8 @@ -82,6 +70,18 @@ error[E0433]: failed to resolve: could not find `test` in `std` LL | #[std::test] | ^^^^ could not find `test` in `std` +error[E0433]: failed to resolve: could not find `RustcDecodable` in `std` + --> $DIR/builtin-std-paths-fail.rs:14:10 + | +LL | std::RustcDecodable, + | ^^^^^^^^^^^^^^ could not find `RustcDecodable` in `std` + +error[E0433]: failed to resolve: could not find `RustcDecodable` in `std` + --> $DIR/builtin-std-paths-fail.rs:16:10 + | +LL | std::RustcDecodable, + | ^^^^^^^^^^^^^^ could not find `RustcDecodable` in `std` + error[E0433]: failed to resolve: could not find `RustcDecodable` in `std` --> $DIR/builtin-std-paths-fail.rs:16:10 | diff --git a/src/test/ui/macros/macro-comma-behavior-rpass.rs b/src/test/ui/macros/macro-comma-behavior-rpass.rs index fd2c590ae5fd6..c46274d59b658 100644 --- a/src/test/ui/macros/macro-comma-behavior-rpass.rs +++ b/src/test/ui/macros/macro-comma-behavior-rpass.rs @@ -57,7 +57,7 @@ fn writeln_1arg() { // // (Example: Issue #48042) #[test] -#[allow(non_fmt_panic)] +#[allow(panic_fmt)] fn to_format_or_not_to_format() { // ("{}" is the easiest string to test because if this gets // sent to format_args!, it'll simply fail to compile. diff --git a/src/test/ui/macros/must-use-in-macro-55516.stderr b/src/test/ui/macros/must-use-in-macro-55516.stderr index b4072a1ad7e57..a694c887085f0 100644 --- a/src/test/ui/macros/must-use-in-macro-55516.stderr +++ b/src/test/ui/macros/must-use-in-macro-55516.stderr @@ -1,4 +1,4 @@ -warning: unused `Result` that must be used +warning: unused `std::result::Result` that must be used --> $DIR/must-use-in-macro-55516.rs:9:5 | LL | write!(&mut example, "{}", 42); diff --git a/src/test/ui/malformed/issue-69341-malformed-derive-inert.rs b/src/test/ui/malformed/issue-69341-malformed-derive-inert.rs index fc4c3f4e64bf9..1fd7cddc7c937 100644 --- a/src/test/ui/malformed/issue-69341-malformed-derive-inert.rs +++ b/src/test/ui/malformed/issue-69341-malformed-derive-inert.rs @@ -1,6 +1,9 @@ fn main() {} struct CLI { - #[derive(parse())] //~ ERROR expected non-macro attribute, found attribute macro + #[derive(parse())] + //~^ ERROR traits in `#[derive(...)]` don't accept arguments + //~| ERROR cannot find derive macro `parse` in this scope path: (), + //~^ ERROR `derive` may only be applied to structs, enums and unions } diff --git a/src/test/ui/malformed/issue-69341-malformed-derive-inert.stderr b/src/test/ui/malformed/issue-69341-malformed-derive-inert.stderr index 04f7ebe019ea4..db40ce0753045 100644 --- a/src/test/ui/malformed/issue-69341-malformed-derive-inert.stderr +++ b/src/test/ui/malformed/issue-69341-malformed-derive-inert.stderr @@ -1,8 +1,21 @@ -error: expected non-macro attribute, found attribute macro `derive` - --> $DIR/issue-69341-malformed-derive-inert.rs:4:7 +error: traits in `#[derive(...)]` don't accept arguments + --> $DIR/issue-69341-malformed-derive-inert.rs:4:19 | LL | #[derive(parse())] - | ^^^^^^ not a non-macro attribute + | ^^ help: remove the arguments -error: aborting due to previous error +error[E0774]: `derive` may only be applied to structs, enums and unions + --> $DIR/issue-69341-malformed-derive-inert.rs:7:5 + | +LL | path: (), + | ^^^^^^^^ + +error: cannot find derive macro `parse` in this scope + --> $DIR/issue-69341-malformed-derive-inert.rs:4:14 + | +LL | #[derive(parse())] + | ^^^^^ + +error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0774`. diff --git a/src/test/ui/malformed/malformed-derive-entry.stderr b/src/test/ui/malformed/malformed-derive-entry.stderr index 365cc099e9d3e..63be8f9ca14db 100644 --- a/src/test/ui/malformed/malformed-derive-entry.stderr +++ b/src/test/ui/malformed/malformed-derive-entry.stderr @@ -14,7 +14,7 @@ error: malformed `derive` attribute input --> $DIR/malformed-derive-entry.rs:11:1 | LL | #[derive] - | ^^^^^^^^^ help: must be of the form: `#[derive(Trait1, Trait2, ...)]` + | ^^^^^^^^^ help: missing traits to be derived: `#[derive(Trait1, Trait2, ...)]` error[E0277]: the trait bound `Test1: Clone` is not satisfied --> $DIR/malformed-derive-entry.rs:1:10 diff --git a/src/test/ui/malformed/malformed-special-attrs.stderr b/src/test/ui/malformed/malformed-special-attrs.stderr index 1764c3969cfee..6f535e03e6aec 100644 --- a/src/test/ui/malformed/malformed-special-attrs.stderr +++ b/src/test/ui/malformed/malformed-special-attrs.stderr @@ -18,13 +18,13 @@ error: malformed `derive` attribute input --> $DIR/malformed-special-attrs.rs:7:1 | LL | #[derive] - | ^^^^^^^^^ help: must be of the form: `#[derive(Trait1, Trait2, ...)]` + | ^^^^^^^^^ help: missing traits to be derived: `#[derive(Trait1, Trait2, ...)]` error: malformed `derive` attribute input --> $DIR/malformed-special-attrs.rs:10:1 | LL | #[derive = ""] - | ^^^^^^^^^^^^^^ help: must be of the form: `#[derive(Trait1, Trait2, ...)]` + | ^^^^^^^^^^^^^^ help: missing traits to be derived: `#[derive(Trait1, Trait2, ...)]` error: aborting due to 4 previous errors diff --git a/src/test/ui/methods/method-lookup-order.rs b/src/test/ui/methods/method-lookup-order.rs deleted file mode 100644 index 986fe103cdc79..0000000000000 --- a/src/test/ui/methods/method-lookup-order.rs +++ /dev/null @@ -1,190 +0,0 @@ -// ignore-tidy-linelength - -// run-pass - -// There are five cfg's below. I explored the set of all non-empty combinations -// of the below five cfg's, which is 2^5 - 1 = 31 combinations. -// -// Of the 31, 11 resulted in ambiguous method resolutions; while it may be good -// to have a test for all of the eleven variations of that error, I am not sure -// this particular test is the best way to encode it. So they are skipped in -// this revisions list (but not in the expansion mapping the binary encoding to -// the corresponding cfg flags). -// -// Notable, here are the cases that will be incompatible if something does not override them first: -// {bar_for_foo, valbar_for_et_foo}: these are higher precedent than the `&mut self` method on `Foo`, and so no case matching bx1x1x is included. -// {mutbar_for_foo, valbar_for_etmut_foo} (which are lower precedent than the inherent `&mut self` method on `Foo`; e.g. b10101 *is* included. - -// revisions: b00001 b00010 b00011 b00100 b00101 b00110 b00111 b01000 b01001 b01100 b01101 b10000 b10001 b10010 b10011 b10101 b10111 b11000 b11001 b11101 - -//[b00001]compile-flags: --cfg inherent_mut -//[b00010]compile-flags: --cfg bar_for_foo -//[b00011]compile-flags: --cfg inherent_mut --cfg bar_for_foo -//[b00100]compile-flags: --cfg mutbar_for_foo -//[b00101]compile-flags: --cfg inherent_mut --cfg mutbar_for_foo -//[b00110]compile-flags: --cfg bar_for_foo --cfg mutbar_for_foo -//[b00111]compile-flags: --cfg inherent_mut --cfg bar_for_foo --cfg mutbar_for_foo -//[b01000]compile-flags: --cfg valbar_for_et_foo -//[b01001]compile-flags: --cfg inherent_mut --cfg valbar_for_et_foo -//[b01010]compile-flags: --cfg bar_for_foo --cfg valbar_for_et_foo -//[b01011]compile-flags: --cfg inherent_mut --cfg bar_for_foo --cfg valbar_for_et_foo -//[b01100]compile-flags: --cfg mutbar_for_foo --cfg valbar_for_et_foo -//[b01101]compile-flags: --cfg inherent_mut --cfg mutbar_for_foo --cfg valbar_for_et_foo -//[b01110]compile-flags: --cfg bar_for_foo --cfg mutbar_for_foo --cfg valbar_for_et_foo -//[b01111]compile-flags: --cfg inherent_mut --cfg bar_for_foo --cfg mutbar_for_foo --cfg valbar_for_et_foo -//[b10000]compile-flags: --cfg valbar_for_etmut_foo -//[b10001]compile-flags: --cfg inherent_mut --cfg valbar_for_etmut_foo -//[b10010]compile-flags: --cfg bar_for_foo --cfg valbar_for_etmut_foo -//[b10011]compile-flags: --cfg inherent_mut --cfg bar_for_foo --cfg valbar_for_etmut_foo -//[b10100]compile-flags: --cfg mutbar_for_foo --cfg valbar_for_etmut_foo -//[b10101]compile-flags: --cfg inherent_mut --cfg mutbar_for_foo --cfg valbar_for_etmut_foo -//[b10110]compile-flags: --cfg bar_for_foo --cfg mutbar_for_foo --cfg valbar_for_etmut_foo -//[b10111]compile-flags: --cfg inherent_mut --cfg bar_for_foo --cfg mutbar_for_foo --cfg valbar_for_etmut_foo -//[b11000]compile-flags: --cfg valbar_for_et_foo --cfg valbar_for_etmut_foo -//[b11001]compile-flags: --cfg inherent_mut --cfg valbar_for_et_foo --cfg valbar_for_etmut_foo -//[b11010]compile-flags: --cfg bar_for_foo --cfg valbar_for_et_foo --cfg valbar_for_etmut_foo -//[b11011]compile-flags: --cfg inherent_mut --cfg bar_for_foo --cfg valbar_for_et_foo --cfg valbar_for_etmut_foo -//[b11100]compile-flags: --cfg mutbar_for_foo --cfg valbar_for_et_foo --cfg valbar_for_etmut_foo -//[b11101]compile-flags: --cfg inherent_mut --cfg mutbar_for_foo --cfg valbar_for_et_foo --cfg valbar_for_etmut_foo -//[b11110]compile-flags: --cfg bar_for_foo --cfg mutbar_for_foo --cfg valbar_for_et_foo --cfg valbar_for_etmut_foo -//[b11111]compile-flags: --cfg inherent_mut --cfg bar_for_foo --cfg mutbar_for_foo --cfg valbar_for_et_foo --cfg valbar_for_etmut_foo - -struct Foo {} - -type S = &'static str; - -trait Bar { - fn bar(&self, _: &str) -> S; -} - -trait MutBar { - fn bar(&mut self, _: &str) -> S; -} - -trait ValBar { - fn bar(self, _: &str) -> S; -} - -#[cfg(inherent_mut)] -impl Foo { - fn bar(&mut self, _: &str) -> S { - "In struct impl!" - } -} - -#[cfg(bar_for_foo)] -impl Bar for Foo { - fn bar(&self, _: &str) -> S { - "In trait &self impl!" - } -} - -#[cfg(mutbar_for_foo)] -impl MutBar for Foo { - fn bar(&mut self, _: &str) -> S { - "In trait &mut self impl!" - } -} - -#[cfg(valbar_for_et_foo)] -impl ValBar for &Foo { - fn bar(self, _: &str) -> S { - "In trait self impl for &Foo!" - } -} - -#[cfg(valbar_for_etmut_foo)] -impl ValBar for &mut Foo { - fn bar(self, _: &str) -> S { - "In trait self impl for &mut Foo!" - } -} - -fn main() { - #![allow(unused_mut)] // some of the impls above will want it. - - #![allow(unreachable_patterns)] // the cfg-coding pattern below generates unreachable patterns. - - { - macro_rules! all_variants_on_value { - ($e:expr) => { - match $e { - #[cfg(bar_for_foo)] - x => assert_eq!(x, "In trait &self impl!"), - - #[cfg(valbar_for_et_foo)] - x => assert_eq!(x, "In trait self impl for &Foo!"), - - #[cfg(inherent_mut)] - x => assert_eq!(x, "In struct impl!"), - - #[cfg(mutbar_for_foo)] - x => assert_eq!(x, "In trait &mut self impl!"), - - #[cfg(valbar_for_etmut_foo)] - x => assert_eq!(x, "In trait self impl for &mut Foo!"), - } - } - } - - let mut f = Foo {}; - all_variants_on_value!(f.bar("f.bar")); - - let f_mr = &mut Foo {}; - all_variants_on_value!((*f_mr).bar("(*f_mr).bar")); - } - - // This is sort of interesting: `&mut Foo` ends up with a significantly - // different resolution order than what was devised above. Presumably this - // is because we can get to a `&self` method by first a deref of the given - // `&mut Foo` and then an autoref, and that is a longer path than a mere - // auto-ref of a `Foo`. - - { - let f_mr = &mut Foo {}; - - match f_mr.bar("f_mr.bar") { - #[cfg(inherent_mut)] - x => assert_eq!(x, "In struct impl!"), - - #[cfg(valbar_for_etmut_foo)] - x => assert_eq!(x, "In trait self impl for &mut Foo!"), - - #[cfg(mutbar_for_foo)] - x => assert_eq!(x, "In trait &mut self impl!"), - - #[cfg(valbar_for_et_foo)] - x => assert_eq!(x, "In trait self impl for &Foo!"), - - #[cfg(bar_for_foo)] - x => assert_eq!(x, "In trait &self impl!"), - } - } - - - // Note that this isn't actually testing a resolution order; if both of these are - // enabled, it yields an ambiguous method resolution error. The test tries to embed - // that fact by testing *both* orders (and so the only way that can be right is if - // they are not actually compatible). - #[cfg(any(bar_for_foo, valbar_for_et_foo))] - { - let f_r = &Foo {}; - - match f_r.bar("f_r.bar") { - #[cfg(bar_for_foo)] - x => assert_eq!(x, "In trait &self impl!"), - - #[cfg(valbar_for_et_foo)] - x => assert_eq!(x, "In trait self impl for &Foo!"), - } - - match f_r.bar("f_r.bar") { - #[cfg(valbar_for_et_foo)] - x => assert_eq!(x, "In trait self impl for &Foo!"), - - #[cfg(bar_for_foo)] - x => assert_eq!(x, "In trait &self impl!"), - } - } - -} diff --git a/src/test/ui/mir/issue-80949.rs b/src/test/ui/mir/issue-80949.rs deleted file mode 100644 index 7e34a4f5c2737..0000000000000 --- a/src/test/ui/mir/issue-80949.rs +++ /dev/null @@ -1,34 +0,0 @@ -// build-pass - -trait Trait { type Item; } - -impl<'a, X> Trait for &'a Vec { - type Item = &'a X; -} - -impl Trait for Box> { - type Item = X; -} - -fn make_dyn_trait(_: &()) -> Box> { - todo!() -} - -fn diff<'a, M, N, S>(_: N, _: S) -where - M: 'a, - N: Trait, - S: Trait, -{ - todo!() -} - -fn may_panic(_: X) { } - -fn main() { - let dyn_trait = make_dyn_trait(&()); - let storage = vec![()]; - let _x = may_panic(()); - let storage_ref = &storage; - diff(dyn_trait, storage_ref); -} diff --git a/src/test/ui/mir/mir_drop_order.rs b/src/test/ui/mir/mir_drop_order.rs index 22c804abf5cc8..2949437b1e4b6 100644 --- a/src/test/ui/mir/mir_drop_order.rs +++ b/src/test/ui/mir/mir_drop_order.rs @@ -38,7 +38,7 @@ fn main() { assert_eq!(get(), vec![0, 2, 3, 1]); let _ = std::panic::catch_unwind(|| { - (d(4), &d(5), d(6), &d(7), panic::panic_any(InjectedFailure)); + (d(4), &d(5), d(6), &d(7), panic!(InjectedFailure)); }); // here, the temporaries (5/7) live until the end of the diff --git a/src/test/ui/mismatched_types/abridged.stderr b/src/test/ui/mismatched_types/abridged.stderr index 61994e5bfee2e..b7564686cd52e 100644 --- a/src/test/ui/mismatched_types/abridged.stderr +++ b/src/test/ui/mismatched_types/abridged.stderr @@ -15,10 +15,10 @@ error[E0308]: mismatched types LL | fn a2() -> Foo { | --- expected `Foo` because of return type LL | Ok(Foo { bar: 1}) - | ^^^^^^^^^^^^^^^^^ expected struct `Foo`, found enum `Result` + | ^^^^^^^^^^^^^^^^^ expected struct `Foo`, found enum `std::result::Result` | = note: expected struct `Foo` - found enum `Result` + found enum `std::result::Result` error[E0308]: mismatched types --> $DIR/abridged.rs:24:5 @@ -38,14 +38,14 @@ error[E0308]: mismatched types --> $DIR/abridged.rs:28:5 | LL | fn c() -> Result { - | ---------------- expected `Result` because of return type + | ---------------- expected `std::result::Result` because of return type LL | Foo { bar: 1 } | ^^^^^^^^^^^^^^ | | - | expected enum `Result`, found struct `Foo` + | expected enum `std::result::Result`, found struct `Foo` | help: try using a variant of the expected enum: `Ok(Foo { bar: 1 })` | - = note: expected enum `Result` + = note: expected enum `std::result::Result` found struct `Foo` error[E0308]: mismatched types diff --git a/src/test/ui/mismatched_types/binops.rs b/src/test/ui/mismatched_types/binops.rs index f359451dfb8f9..4be7420e33c17 100644 --- a/src/test/ui/mismatched_types/binops.rs +++ b/src/test/ui/mismatched_types/binops.rs @@ -4,5 +4,5 @@ fn main() { 3 * (); //~ ERROR cannot multiply `{integer}` by `()` 4 / ""; //~ ERROR cannot divide `{integer}` by `&str` 5 < String::new(); //~ ERROR can't compare `{integer}` with `String` - 6 == Ok(1); //~ ERROR can't compare `{integer}` with `Result<{integer}, _>` + 6 == Ok(1); //~ ERROR can't compare `{integer}` with `std::result::Result<{integer}, _>` } diff --git a/src/test/ui/mismatched_types/binops.stderr b/src/test/ui/mismatched_types/binops.stderr index 19e921dd04d73..f2bfb12ee9c80 100644 --- a/src/test/ui/mismatched_types/binops.stderr +++ b/src/test/ui/mismatched_types/binops.stderr @@ -38,13 +38,13 @@ LL | 5 < String::new(); | = help: the trait `PartialOrd` is not implemented for `{integer}` -error[E0277]: can't compare `{integer}` with `Result<{integer}, _>` +error[E0277]: can't compare `{integer}` with `std::result::Result<{integer}, _>` --> $DIR/binops.rs:7:7 | LL | 6 == Ok(1); - | ^^ no implementation for `{integer} == Result<{integer}, _>` + | ^^ no implementation for `{integer} == std::result::Result<{integer}, _>` | - = help: the trait `PartialEq>` is not implemented for `{integer}` + = help: the trait `PartialEq>` is not implemented for `{integer}` error: aborting due to 6 previous errors diff --git a/src/test/ui/mismatched_types/method-help-unsatisfied-bound.stderr b/src/test/ui/mismatched_types/method-help-unsatisfied-bound.stderr index 1030061b2d1fe..92a88cbdb34a3 100644 --- a/src/test/ui/mismatched_types/method-help-unsatisfied-bound.stderr +++ b/src/test/ui/mismatched_types/method-help-unsatisfied-bound.stderr @@ -1,11 +1,11 @@ -error[E0599]: the method `unwrap` exists for enum `Result<(), Foo>`, but its trait bounds were not satisfied +error[E0599]: the method `unwrap` exists for enum `std::result::Result<(), Foo>`, but its trait bounds were not satisfied --> $DIR/method-help-unsatisfied-bound.rs:5:7 | LL | struct Foo; | ----------- doesn't satisfy `Foo: Debug` ... LL | a.unwrap(); - | ^^^^^^ method cannot be called on `Result<(), Foo>` due to unsatisfied trait bounds + | ^^^^^^ method cannot be called on `std::result::Result<(), Foo>` due to unsatisfied trait bounds | = note: the following trait bounds were not satisfied: `Foo: Debug` diff --git a/src/test/ui/nll/closure-requirements/escape-upvar-nested.stderr b/src/test/ui/nll/closure-requirements/escape-upvar-nested.stderr index e1b446fc61f61..1a8258376142a 100644 --- a/src/test/ui/nll/closure-requirements/escape-upvar-nested.stderr +++ b/src/test/ui/nll/closure-requirements/escape-upvar-nested.stderr @@ -7,10 +7,10 @@ LL | let mut closure1 = || p = &y; = note: defining type: test::{closure#0}::{closure#0} with closure substs [ i16, extern "rust-call" fn(()), - (&'_#1r mut &'_#2r i32, &'_#3r i32), + (&'_#1r i32, &'_#2r mut &'_#3r i32), ] = note: number of external vids: 4 - = note: where '_#3r: '_#2r + = note: where '_#1r: '_#3r note: external requirements --> $DIR/escape-upvar-nested.rs:20:27 @@ -25,10 +25,10 @@ LL | | }; = note: defining type: test::{closure#0} with closure substs [ i16, extern "rust-call" fn(()), - (&'_#1r mut &'_#2r i32, &'_#3r i32), + (&'_#1r i32, &'_#2r mut &'_#3r i32), ] = note: number of external vids: 4 - = note: where '_#3r: '_#2r + = note: where '_#1r: '_#3r note: no external requirements --> $DIR/escape-upvar-nested.rs:13:1 diff --git a/src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr b/src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr index 0ea1076c32ef4..29fd796882b6a 100644 --- a/src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr +++ b/src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr @@ -7,10 +7,10 @@ LL | let mut closure = || p = &y; = note: defining type: test::{closure#0} with closure substs [ i16, extern "rust-call" fn(()), - (&'_#1r mut &'_#2r i32, &'_#3r i32), + (&'_#1r i32, &'_#2r mut &'_#3r i32), ] = note: number of external vids: 4 - = note: where '_#3r: '_#2r + = note: where '_#1r: '_#3r note: no external requirements --> $DIR/escape-upvar-ref.rs:17:1 diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr index 0932f9415480c..0115f5412f21d 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr @@ -83,5 +83,4 @@ LL | } error: aborting due to 2 previous errors -Some errors have detailed explanations: E0521, E0597. -For more information about an error, try `rustc --explain E0521`. +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr index bf6e2a922ed08..e55d033d2c763 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr @@ -51,4 +51,3 @@ LL | | }); error: aborting due to previous error -For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr index a3d993848cbaa..ac4a4579c9cd2 100644 --- a/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr +++ b/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr @@ -51,4 +51,3 @@ LL | | }); error: aborting due to previous error -For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/nll/issue-54556-niconii.stderr b/src/test/ui/nll/issue-54556-niconii.stderr index 1bfebd755b4fc..b4791fd22b4ad 100644 --- a/src/test/ui/nll/issue-54556-niconii.stderr +++ b/src/test/ui/nll/issue-54556-niconii.stderr @@ -11,7 +11,7 @@ LL | } | - | | | `counter` dropped here while still borrowed - | ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `Result, ()>` + | ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `std::result::Result, ()>` | help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped | diff --git a/src/test/ui/nll/outlives-suggestion-simple.stderr b/src/test/ui/nll/outlives-suggestion-simple.stderr index bfe98a71a99b1..6300ea66511fb 100644 --- a/src/test/ui/nll/outlives-suggestion-simple.stderr +++ b/src/test/ui/nll/outlives-suggestion-simple.stderr @@ -106,4 +106,3 @@ LL | Bar2::new(&self) error: aborting due to 9 previous errors -For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/nll/user-annotations/closure-substs.stderr b/src/test/ui/nll/user-annotations/closure-substs.stderr index 37e751aeb67b7..e3e294106d168 100644 --- a/src/test/ui/nll/user-annotations/closure-substs.stderr +++ b/src/test/ui/nll/user-annotations/closure-substs.stderr @@ -38,4 +38,3 @@ LL | b(x); error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/numeric/numeric-fields.stderr b/src/test/ui/numeric/numeric-fields.stderr index 13b6cfae4ec47..5202393f559c9 100644 --- a/src/test/ui/numeric/numeric-fields.stderr +++ b/src/test/ui/numeric/numeric-fields.stderr @@ -7,7 +7,7 @@ LL | struct S(u8, u16); LL | let s = S{0b1: 10, 0: 11}; | - ^^^ field does not exist | | - | help: `S` is a tuple struct, use the appropriate syntax: `S(/* fields */)` + | `S` is a tuple struct, use the appropriate syntax: `S(/* fields */)` error[E0026]: struct `S` does not have a field named `0x1` --> $DIR/numeric-fields.rs:7:17 diff --git a/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr b/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr index 42dae7e40dbb3..d871eb5327d22 100644 --- a/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr +++ b/src/test/ui/object-lifetime/object-lifetime-default-mybox.nll.stderr @@ -23,4 +23,3 @@ LL | load0(ss) error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs b/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs index bdb7a1ec92b7f..184ffa85c40e2 100644 --- a/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs +++ b/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.rs @@ -48,25 +48,6 @@ fn main() { (1 | 1,) => {} //~ ERROR unreachable _ => {} } - match 0 { - (0 | 1) | 1 => {} //~ ERROR unreachable - _ => {} - } - match 0 { - // We get two errors because recursive or-pattern expansion means we don't notice the two - // errors span a whole pattern. This could be better but doesn't matter much - 0 | (0 | 0) => {} - //~^ ERROR unreachable - //~| ERROR unreachable - _ => {} - } - match None { - // There is only one error that correctly points to the whole subpattern - Some(0) | - Some( //~ ERROR unreachable - 0 | 0) => {} - _ => {} - } match [0; 2] { [0 | 0 //~ ERROR unreachable @@ -103,8 +84,8 @@ fn main() { } macro_rules! t_or_f { () => { - (true //~ ERROR unreachable - | false) + (true // FIXME: should be unreachable + | false) }; } match (true, None) { diff --git a/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr b/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr index 51991fc603967..8b1003b5514a6 100644 --- a/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr +++ b/src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr @@ -77,94 +77,58 @@ LL | (1 | 1,) => {} | ^ error: unreachable pattern - --> $DIR/exhaustiveness-unreachable-pattern.rs:52:19 - | -LL | (0 | 1) | 1 => {} - | ^ - -error: unreachable pattern - --> $DIR/exhaustiveness-unreachable-pattern.rs:58:14 - | -LL | 0 | (0 | 0) => {} - | ^ - -error: unreachable pattern - --> $DIR/exhaustiveness-unreachable-pattern.rs:58:18 - | -LL | 0 | (0 | 0) => {} - | ^ - -error: unreachable pattern - --> $DIR/exhaustiveness-unreachable-pattern.rs:66:13 - | -LL | / Some( -LL | | 0 | 0) => {} - | |______________________^ - -error: unreachable pattern - --> $DIR/exhaustiveness-unreachable-pattern.rs:72:15 + --> $DIR/exhaustiveness-unreachable-pattern.rs:53:15 | LL | | 0 | ^ error: unreachable pattern - --> $DIR/exhaustiveness-unreachable-pattern.rs:74:15 + --> $DIR/exhaustiveness-unreachable-pattern.rs:55:15 | LL | | 0] => {} | ^ error: unreachable pattern - --> $DIR/exhaustiveness-unreachable-pattern.rs:82:10 + --> $DIR/exhaustiveness-unreachable-pattern.rs:63:10 | LL | [1 | ^ error: unreachable pattern - --> $DIR/exhaustiveness-unreachable-pattern.rs:94:10 + --> $DIR/exhaustiveness-unreachable-pattern.rs:75:10 | LL | [true | ^^^^ error: unreachable pattern - --> $DIR/exhaustiveness-unreachable-pattern.rs:101:36 + --> $DIR/exhaustiveness-unreachable-pattern.rs:82:36 | LL | (true | false, None | Some(true | ^^^^ error: unreachable pattern - --> $DIR/exhaustiveness-unreachable-pattern.rs:106:14 - | -LL | (true - | ^^^^ -... -LL | (true | false, None | Some(t_or_f!())) => {} - | --------- in this macro invocation - | - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: unreachable pattern - --> $DIR/exhaustiveness-unreachable-pattern.rs:117:14 + --> $DIR/exhaustiveness-unreachable-pattern.rs:98:14 | LL | Some(0 | ^ error: unreachable pattern - --> $DIR/exhaustiveness-unreachable-pattern.rs:136:19 + --> $DIR/exhaustiveness-unreachable-pattern.rs:117:19 | LL | | false) => {} | ^^^^^ error: unreachable pattern - --> $DIR/exhaustiveness-unreachable-pattern.rs:144:15 + --> $DIR/exhaustiveness-unreachable-pattern.rs:125:15 | LL | | true) => {} | ^^^^ error: unreachable pattern - --> $DIR/exhaustiveness-unreachable-pattern.rs:150:15 + --> $DIR/exhaustiveness-unreachable-pattern.rs:131:15 | LL | | true, | ^^^^ -error: aborting due to 26 previous errors +error: aborting due to 21 previous errors diff --git a/src/test/ui/or-patterns/inconsistent-modes.stderr b/src/test/ui/or-patterns/inconsistent-modes.stderr index 15790771043df..c5dcef36e0580 100644 --- a/src/test/ui/or-patterns/inconsistent-modes.stderr +++ b/src/test/ui/or-patterns/inconsistent-modes.stderr @@ -65,7 +65,7 @@ error[E0308]: mismatched types --> $DIR/inconsistent-modes.rs:14:31 | LL | let Ok((ref a, b)) | Err((ref mut a, ref b)) = Ok((0, &0)); - | ----- ^^^^^^^^^ ----------- this expression has type `Result<({integer}, &{integer}), (_, _)>` + | ----- ^^^^^^^^^ ----------- this expression has type `std::result::Result<({integer}, &{integer}), (_, _)>` | | | | | types differ in mutability | first introduced with type `&{integer}` here diff --git a/src/test/ui/non-fmt-panic.rs b/src/test/ui/panic-brace.rs similarity index 70% rename from src/test/ui/non-fmt-panic.rs rename to src/test/ui/panic-brace.rs index 25c53316e1290..754dcc287d0f9 100644 --- a/src/test/ui/non-fmt-panic.rs +++ b/src/test/ui/panic-brace.rs @@ -13,27 +13,19 @@ fn main() { core::panic!("Hello {}"); //~ WARN panic message contains an unused formatting placeholder assert!(false, "{:03x} {test} bla"); //~^ WARN panic message contains unused formatting placeholders - assert!(false, S); - //~^ WARN panic message is not a string literal debug_assert!(false, "{{}} bla"); //~ WARN panic message contains braces - panic!(C); //~ WARN panic message is not a string literal - panic!(S); //~ WARN panic message is not a string literal - std::panic!(123); //~ WARN panic message is not a string literal - core::panic!(&*"abc"); //~ WARN panic message is not a string literal + panic!(C); // No warning (yet) + panic!(S); // No warning (yet) panic!(concat!("{", "}")); //~ WARN panic message contains an unused formatting placeholder panic!(concat!("{", "{")); //~ WARN panic message contains braces fancy_panic::fancy_panic!("test {} 123"); //~^ WARN panic message contains an unused formatting placeholder - fancy_panic::fancy_panic!(S); - //~^ WARN panic message is not a string literal - // Check that the lint only triggers for std::panic and core::panic, // not any panic macro: macro_rules! panic { ($e:expr) => (); } panic!("{}"); // OK - panic!(S); // OK } diff --git a/src/test/ui/non-fmt-panic.stderr b/src/test/ui/panic-brace.stderr similarity index 52% rename from src/test/ui/non-fmt-panic.stderr rename to src/test/ui/panic-brace.stderr index 45187c518c423..93808891c3c37 100644 --- a/src/test/ui/non-fmt-panic.stderr +++ b/src/test/ui/panic-brace.stderr @@ -1,35 +1,35 @@ warning: panic message contains a brace - --> $DIR/non-fmt-panic.rs:11:29 + --> $DIR/panic-brace.rs:11:29 | LL | panic!("here's a brace: {"); | ^ | - = note: `#[warn(non_fmt_panic)]` on by default - = note: this message is not used as a format string, but will be in Rust 2021 + = note: `#[warn(panic_fmt)]` on by default + = note: this message is not used as a format string, but will be in a future Rust edition help: add a "{}" format string to use the message literally | LL | panic!("{}", "here's a brace: {"); | ^^^^^ warning: panic message contains a brace - --> $DIR/non-fmt-panic.rs:12:31 + --> $DIR/panic-brace.rs:12:31 | LL | std::panic!("another one: }"); | ^ | - = note: this message is not used as a format string, but will be in Rust 2021 + = note: this message is not used as a format string, but will be in a future Rust edition help: add a "{}" format string to use the message literally | LL | std::panic!("{}", "another one: }"); | ^^^^^ warning: panic message contains an unused formatting placeholder - --> $DIR/non-fmt-panic.rs:13:25 + --> $DIR/panic-brace.rs:13:25 | LL | core::panic!("Hello {}"); | ^^ | - = note: this message is not used as a format string when given without arguments, but will be in Rust 2021 + = note: this message is not used as a format string when given without arguments, but will be in a future Rust edition help: add the missing argument | LL | core::panic!("Hello {}", ...); @@ -40,12 +40,12 @@ LL | core::panic!("{}", "Hello {}"); | ^^^^^ warning: panic message contains unused formatting placeholders - --> $DIR/non-fmt-panic.rs:14:21 + --> $DIR/panic-brace.rs:14:21 | LL | assert!(false, "{:03x} {test} bla"); | ^^^^^^ ^^^^^^ | - = note: this message is not used as a format string when given without arguments, but will be in Rust 2021 + = note: this message is not used as a format string when given without arguments, but will be in a future Rust edition help: add the missing arguments | LL | assert!(false, "{:03x} {test} bla", ...); @@ -55,97 +55,25 @@ help: or add a "{}" format string to use the message literally LL | assert!(false, "{}", "{:03x} {test} bla"); | ^^^^^ -warning: panic message is not a string literal - --> $DIR/non-fmt-panic.rs:16:20 - | -LL | assert!(false, S); - | ^ - | - = note: this is no longer accepted in Rust 2021 -help: add a "{}" format string to Display the message - | -LL | assert!(false, "{}", S); - | ^^^^^ - warning: panic message contains braces - --> $DIR/non-fmt-panic.rs:18:27 + --> $DIR/panic-brace.rs:16:27 | LL | debug_assert!(false, "{{}} bla"); | ^^^^ | - = note: this message is not used as a format string, but will be in Rust 2021 + = note: this message is not used as a format string, but will be in a future Rust edition help: add a "{}" format string to use the message literally | LL | debug_assert!(false, "{}", "{{}} bla"); | ^^^^^ -warning: panic message is not a string literal - --> $DIR/non-fmt-panic.rs:19:12 - | -LL | panic!(C); - | ^ - | - = note: this is no longer accepted in Rust 2021 -help: add a "{}" format string to Display the message - | -LL | panic!("{}", C); - | ^^^^^ -help: or use std::panic::panic_any instead - | -LL | std::panic::panic_any(C); - | ^^^^^^^^^^^^^^^^^^^^^^ - -warning: panic message is not a string literal - --> $DIR/non-fmt-panic.rs:20:12 - | -LL | panic!(S); - | ^ - | - = note: this is no longer accepted in Rust 2021 -help: add a "{}" format string to Display the message - | -LL | panic!("{}", S); - | ^^^^^ -help: or use std::panic::panic_any instead - | -LL | std::panic::panic_any(S); - | ^^^^^^^^^^^^^^^^^^^^^^ - -warning: panic message is not a string literal - --> $DIR/non-fmt-panic.rs:21:17 - | -LL | std::panic!(123); - | ^^^ - | - = note: this is no longer accepted in Rust 2021 -help: add a "{}" format string to Display the message - | -LL | std::panic!("{}", 123); - | ^^^^^ -help: or use std::panic::panic_any instead - | -LL | std::panic::panic_any(123); - | ^^^^^^^^^^^^^^^^^^^^^^ - -warning: panic message is not a string literal - --> $DIR/non-fmt-panic.rs:22:18 - | -LL | core::panic!(&*"abc"); - | ^^^^^^^ - | - = note: this is no longer accepted in Rust 2021 -help: add a "{}" format string to Display the message - | -LL | core::panic!("{}", &*"abc"); - | ^^^^^ - warning: panic message contains an unused formatting placeholder - --> $DIR/non-fmt-panic.rs:23:12 + --> $DIR/panic-brace.rs:19:12 | LL | panic!(concat!("{", "}")); | ^^^^^^^^^^^^^^^^^ | - = note: this message is not used as a format string when given without arguments, but will be in Rust 2021 + = note: this message is not used as a format string when given without arguments, but will be in a future Rust edition help: add the missing argument | LL | panic!(concat!("{", "}"), ...); @@ -156,32 +84,24 @@ LL | panic!("{}", concat!("{", "}")); | ^^^^^ warning: panic message contains braces - --> $DIR/non-fmt-panic.rs:24:5 + --> $DIR/panic-brace.rs:20:5 | LL | panic!(concat!("{", "{")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: this message is not used as a format string, but will be in Rust 2021 + = note: this message is not used as a format string, but will be in a future Rust edition help: add a "{}" format string to use the message literally | LL | panic!("{}", concat!("{", "{")); | ^^^^^ warning: panic message contains an unused formatting placeholder - --> $DIR/non-fmt-panic.rs:26:37 + --> $DIR/panic-brace.rs:22:37 | LL | fancy_panic::fancy_panic!("test {} 123"); | ^^ | - = note: this message is not used as a format string when given without arguments, but will be in Rust 2021 - -warning: panic message is not a string literal - --> $DIR/non-fmt-panic.rs:29:31 - | -LL | fancy_panic::fancy_panic!(S); - | ^ - | - = note: this is no longer accepted in Rust 2021 + = note: this message is not used as a format string when given without arguments, but will be in a future Rust edition -warning: 14 warnings emitted +warning: 8 warnings emitted diff --git a/src/test/ui/panics/explicit-panic-msg.rs b/src/test/ui/panics/explicit-panic-msg.rs index bfcc12cd186bd..1789e2e62c8b2 100644 --- a/src/test/ui/panics/explicit-panic-msg.rs +++ b/src/test/ui/panics/explicit-panic-msg.rs @@ -1,6 +1,5 @@ #![allow(unused_assignments)] #![allow(unused_variables)] -#![allow(non_fmt_panic)] // run-fail // error-pattern:wooooo diff --git a/src/test/ui/panics/panic-2021.rs b/src/test/ui/panics/panic-2021.rs deleted file mode 100644 index e606612e10862..0000000000000 --- a/src/test/ui/panics/panic-2021.rs +++ /dev/null @@ -1,9 +0,0 @@ -// edition:2021 - -fn main() { - panic!(123); //~ ERROR: format argument must be a string literal - panic!("{}"); //~ ERROR: 1 positional argument in format string - core::panic!("{}"); //~ ERROR: 1 positional argument in format string - assert!(false, 123); //~ ERROR: format argument must be a string literal - assert!(false, "{}"); //~ ERROR: 1 positional argument in format string -} diff --git a/src/test/ui/panics/panic-2021.stderr b/src/test/ui/panics/panic-2021.stderr deleted file mode 100644 index 59b1e4f7a9858..0000000000000 --- a/src/test/ui/panics/panic-2021.stderr +++ /dev/null @@ -1,42 +0,0 @@ -error: format argument must be a string literal - --> $DIR/panic-2021.rs:4:12 - | -LL | panic!(123); - | ^^^ - | -help: you might be missing a string literal to format with - | -LL | panic!("{}", 123); - | ^^^^^ - -error: 1 positional argument in format string, but no arguments were given - --> $DIR/panic-2021.rs:5:13 - | -LL | panic!("{}"); - | ^^ - -error: 1 positional argument in format string, but no arguments were given - --> $DIR/panic-2021.rs:6:19 - | -LL | core::panic!("{}"); - | ^^ - -error: format argument must be a string literal - --> $DIR/panic-2021.rs:7:20 - | -LL | assert!(false, 123); - | ^^^ - | -help: you might be missing a string literal to format with - | -LL | assert!(false, "{}", 123); - | ^^^^^ - -error: 1 positional argument in format string, but no arguments were given - --> $DIR/panic-2021.rs:8:21 - | -LL | assert!(false, "{}"); - | ^^ - -error: aborting due to 5 previous errors - diff --git a/src/test/ui/panics/panic-macro-any-wrapped.rs b/src/test/ui/panics/panic-macro-any-wrapped.rs index 95ae6ffe8be02..80c87c6f32c4b 100644 --- a/src/test/ui/panics/panic-macro-any-wrapped.rs +++ b/src/test/ui/panics/panic-macro-any-wrapped.rs @@ -2,8 +2,6 @@ // error-pattern:panicked at 'Box' // ignore-emscripten no processes -#![allow(non_fmt_panic)] - fn main() { panic!(Box::new(612_i64)); } diff --git a/src/test/ui/panics/panic-macro-any.rs b/src/test/ui/panics/panic-macro-any.rs index d2a7ba3713a51..ffc7114c1f5f2 100644 --- a/src/test/ui/panics/panic-macro-any.rs +++ b/src/test/ui/panics/panic-macro-any.rs @@ -3,7 +3,6 @@ // ignore-emscripten no processes #![feature(box_syntax)] -#![allow(non_fmt_panic)] fn main() { panic!(box 413 as Box); diff --git a/src/test/ui/panics/while-panic.rs b/src/test/ui/panics/while-panic.rs index 3c6ee8fa3155e..857f65a225228 100644 --- a/src/test/ui/panics/while-panic.rs +++ b/src/test/ui/panics/while-panic.rs @@ -5,7 +5,7 @@ // ignore-emscripten no processes fn main() { - panic!("{}", { + panic!({ while true { panic!("giraffe") } diff --git a/src/test/ui/parser/ascii-only-character-escape.rs b/src/test/ui/parser/ascii-only-character-escape.rs index 725c8ad23515e..20d3edf125175 100644 --- a/src/test/ui/parser/ascii-only-character-escape.rs +++ b/src/test/ui/parser/ascii-only-character-escape.rs @@ -1,6 +1,6 @@ fn main() { - let x = "\x80"; //~ ERROR out of range hex escape - let y = "\xff"; //~ ERROR out of range hex escape - let z = "\xe2"; //~ ERROR out of range hex escape + let x = "\x80"; //~ ERROR may only be used + let y = "\xff"; //~ ERROR may only be used + let z = "\xe2"; //~ ERROR may only be used let a = b"\x00e2"; // ok because byte literal } diff --git a/src/test/ui/parser/ascii-only-character-escape.stderr b/src/test/ui/parser/ascii-only-character-escape.stderr index b599b35f4b324..cf51b00cdc39a 100644 --- a/src/test/ui/parser/ascii-only-character-escape.stderr +++ b/src/test/ui/parser/ascii-only-character-escape.stderr @@ -1,20 +1,20 @@ -error: out of range hex escape +error: this form of character escape may only be used with characters in the range [\x00-\x7f] --> $DIR/ascii-only-character-escape.rs:2:14 | LL | let x = "\x80"; - | ^^^^ must be a character in the range [\x00-\x7f] + | ^^^^ -error: out of range hex escape +error: this form of character escape may only be used with characters in the range [\x00-\x7f] --> $DIR/ascii-only-character-escape.rs:3:14 | LL | let y = "\xff"; - | ^^^^ must be a character in the range [\x00-\x7f] + | ^^^^ -error: out of range hex escape +error: this form of character escape may only be used with characters in the range [\x00-\x7f] --> $DIR/ascii-only-character-escape.rs:4:14 | LL | let z = "\xe2"; - | ^^^^ must be a character in the range [\x00-\x7f] + | ^^^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/parser/bad-char-literals.rs b/src/test/ui/parser/bad-char-literals.rs index 748b4a22253f5..11696b82bc9ac 100644 --- a/src/test/ui/parser/bad-char-literals.rs +++ b/src/test/ui/parser/bad-char-literals.rs @@ -4,17 +4,17 @@ fn main() { // these literals are just silly. '''; - //~^ ERROR: character constant must be escaped: `'` + //~^ ERROR: character constant must be escaped: ' // note that this is a literal "\n" byte ' '; - //~^^ ERROR: character constant must be escaped: `\n` + //~^^ ERROR: character constant must be escaped: \n // note that this is a literal "\r" byte - ' '; //~ ERROR: character constant must be escaped: `\r` + ' '; //~ ERROR: character constant must be escaped: \r // note that this is a literal tab character here ' '; - //~^ ERROR: character constant must be escaped: `\t` + //~^ ERROR: character constant must be escaped: \t } diff --git a/src/test/ui/parser/bad-char-literals.stderr b/src/test/ui/parser/bad-char-literals.stderr index a22ddbac1b931..093978fd84d00 100644 --- a/src/test/ui/parser/bad-char-literals.stderr +++ b/src/test/ui/parser/bad-char-literals.stderr @@ -1,28 +1,28 @@ -error: character constant must be escaped: `'` +error: character constant must be escaped: ' --> $DIR/bad-char-literals.rs:6:6 | LL | '''; - | ^ help: escape the character: `\'` + | ^ -error: character constant must be escaped: `\n` +error: character constant must be escaped: \n --> $DIR/bad-char-literals.rs:10:6 | LL | ' | ______^ LL | | '; - | |_ help: escape the character: `\n` + | |_ -error: character constant must be escaped: `\r` +error: character constant must be escaped: \r --> $DIR/bad-char-literals.rs:15:6 | LL | ' '; - | ^ help: escape the character: `\r` + | ^ -error: character constant must be escaped: `\t` +error: character constant must be escaped: \t --> $DIR/bad-char-literals.rs:18:6 | LL | ' '; - | ^^^^ help: escape the character: `\t` + | ^^^^ error: aborting due to 4 previous errors diff --git a/src/test/ui/parser/byte-literals.rs b/src/test/ui/parser/byte-literals.rs index 05a510b24a7ab..9683a83e72095 100644 --- a/src/test/ui/parser/byte-literals.rs +++ b/src/test/ui/parser/byte-literals.rs @@ -4,9 +4,9 @@ static FOO: u8 = b'\f'; //~ ERROR unknown byte escape pub fn main() { b'\f'; //~ ERROR unknown byte escape - b'\x0Z'; //~ ERROR invalid character in numeric character escape: `Z` + b'\x0Z'; //~ ERROR invalid character in numeric character escape: Z b' '; //~ ERROR byte constant must be escaped b'''; //~ ERROR byte constant must be escaped - b'é'; //~ ERROR non-ASCII character in byte constant + b'é'; //~ ERROR byte constant must be ASCII b'a //~ ERROR unterminated byte constant [E0763] } diff --git a/src/test/ui/parser/byte-literals.stderr b/src/test/ui/parser/byte-literals.stderr index 55be113e16b99..7bbdc07cd835f 100644 --- a/src/test/ui/parser/byte-literals.stderr +++ b/src/test/ui/parser/byte-literals.stderr @@ -1,45 +1,38 @@ -error: unknown byte escape: `f` +error: unknown byte escape: f --> $DIR/byte-literals.rs:3:21 | LL | static FOO: u8 = b'\f'; | ^ unknown byte escape - | - = help: for more information, visit -error: unknown byte escape: `f` +error: unknown byte escape: f --> $DIR/byte-literals.rs:6:8 | LL | b'\f'; | ^ unknown byte escape - | - = help: for more information, visit -error: invalid character in numeric character escape: `Z` +error: invalid character in numeric character escape: Z --> $DIR/byte-literals.rs:7:10 | LL | b'\x0Z'; - | ^ invalid character in numeric character escape + | ^ -error: byte constant must be escaped: `\t` +error: byte constant must be escaped: \t --> $DIR/byte-literals.rs:8:7 | LL | b' '; - | ^^^^ help: escape the character: `\t` + | ^^^^ -error: byte constant must be escaped: `'` +error: byte constant must be escaped: ' --> $DIR/byte-literals.rs:9:7 | LL | b'''; - | ^ help: escape the character: `\'` + | ^ -error: non-ASCII character in byte constant +error: byte constant must be ASCII. Use a \xHH escape for a non-ASCII byte --> $DIR/byte-literals.rs:10:7 | LL | b'é'; | ^ - | | - | byte constant must be ASCII - | help: use a \xHH escape for a non-ASCII byte: `\xE9` error[E0763]: unterminated byte constant --> $DIR/byte-literals.rs:11:6 diff --git a/src/test/ui/parser/byte-string-literals.rs b/src/test/ui/parser/byte-string-literals.rs index b1f11024a7bb6..caffd9efbed37 100644 --- a/src/test/ui/parser/byte-string-literals.rs +++ b/src/test/ui/parser/byte-string-literals.rs @@ -2,8 +2,7 @@ static FOO: &'static [u8] = b"\f"; //~ ERROR unknown byte escape pub fn main() { b"\f"; //~ ERROR unknown byte escape - b"\x0Z"; //~ ERROR invalid character in numeric character escape: `Z` - b"é"; //~ ERROR non-ASCII character in byte constant - br##"é"##; //~ ERROR raw byte string must be ASCII + b"\x0Z"; //~ ERROR invalid character in numeric character escape: Z + b"é"; //~ ERROR byte constant must be ASCII b"a //~ ERROR unterminated double quote byte string } diff --git a/src/test/ui/parser/byte-string-literals.stderr b/src/test/ui/parser/byte-string-literals.stderr index 3a5a8b331d339..9be9064414796 100644 --- a/src/test/ui/parser/byte-string-literals.stderr +++ b/src/test/ui/parser/byte-string-literals.stderr @@ -1,48 +1,35 @@ -error: unknown byte escape: `f` +error: unknown byte escape: f --> $DIR/byte-string-literals.rs:1:32 | LL | static FOO: &'static [u8] = b"\f"; | ^ unknown byte escape - | - = help: for more information, visit -error: unknown byte escape: `f` +error: unknown byte escape: f --> $DIR/byte-string-literals.rs:4:8 | LL | b"\f"; | ^ unknown byte escape - | - = help: for more information, visit -error: invalid character in numeric character escape: `Z` +error: invalid character in numeric character escape: Z --> $DIR/byte-string-literals.rs:5:10 | LL | b"\x0Z"; - | ^ invalid character in numeric character escape + | ^ -error: non-ASCII character in byte constant +error: byte constant must be ASCII. Use a \xHH escape for a non-ASCII byte --> $DIR/byte-string-literals.rs:6:7 | LL | b"é"; | ^ - | | - | byte constant must be ASCII - | help: use a \xHH escape for a non-ASCII byte: `\xE9` - -error: raw byte string must be ASCII - --> $DIR/byte-string-literals.rs:7:10 - | -LL | br##"é"##; - | ^ must be ASCII error[E0766]: unterminated double quote byte string - --> $DIR/byte-string-literals.rs:8:6 + --> $DIR/byte-string-literals.rs:7:6 | LL | b"a | ______^ LL | | } | |__^ -error: aborting due to 6 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0766`. diff --git a/src/test/ui/parser/issue-23620-invalid-escapes.rs b/src/test/ui/parser/issue-23620-invalid-escapes.rs index c1355f0d6fe0c..ab445a9329426 100644 --- a/src/test/ui/parser/issue-23620-invalid-escapes.rs +++ b/src/test/ui/parser/issue-23620-invalid-escapes.rs @@ -1,9 +1,9 @@ fn main() { let _ = b"\u{a66e}"; - //~^ ERROR unicode escape in byte string + //~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string let _ = b'\u{a66e}'; - //~^ ERROR unicode escape in byte string + //~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string let _ = b'\u'; //~^ ERROR incorrect unicode escape sequence @@ -12,21 +12,21 @@ fn main() { //~^ ERROR numeric character escape is too short let _ = b'\xxy'; - //~^ ERROR invalid character in numeric character escape: `x` + //~^ ERROR invalid character in numeric character escape: x let _ = '\x5'; //~^ ERROR numeric character escape is too short let _ = '\xxy'; - //~^ ERROR invalid character in numeric character escape: `x` + //~^ ERROR invalid character in numeric character escape: x let _ = b"\u{a4a4} \xf \u"; - //~^ ERROR unicode escape in byte string - //~^^ ERROR invalid character in numeric character escape: ` ` + //~^ ERROR unicode escape sequences cannot be used as a byte or in a byte string + //~^^ ERROR invalid character in numeric character escape: //~^^^ ERROR incorrect unicode escape sequence let _ = "\xf \u"; - //~^ ERROR invalid character in numeric character escape: ` ` + //~^ ERROR invalid character in numeric character escape: //~^^ ERROR incorrect unicode escape sequence let _ = "\u8f"; diff --git a/src/test/ui/parser/issue-23620-invalid-escapes.stderr b/src/test/ui/parser/issue-23620-invalid-escapes.stderr index 88d97c795fc2a..8c924ad0330e9 100644 --- a/src/test/ui/parser/issue-23620-invalid-escapes.stderr +++ b/src/test/ui/parser/issue-23620-invalid-escapes.stderr @@ -1,18 +1,14 @@ -error: unicode escape in byte string +error: unicode escape sequences cannot be used as a byte or in a byte string --> $DIR/issue-23620-invalid-escapes.rs:2:15 | LL | let _ = b"\u{a66e}"; - | ^^^^^^^^ unicode escape in byte string - | - = help: unicode escape sequences cannot be used as a byte or in a byte string + | ^^^^^^^^ -error: unicode escape in byte string +error: unicode escape sequences cannot be used as a byte or in a byte string --> $DIR/issue-23620-invalid-escapes.rs:5:15 | LL | let _ = b'\u{a66e}'; - | ^^^^^^^^ unicode escape in byte string - | - = help: unicode escape sequences cannot be used as a byte or in a byte string + | ^^^^^^^^ error: incorrect unicode escape sequence --> $DIR/issue-23620-invalid-escapes.rs:8:15 @@ -28,11 +24,11 @@ error: numeric character escape is too short LL | let _ = b'\x5'; | ^^^ -error: invalid character in numeric character escape: `x` +error: invalid character in numeric character escape: x --> $DIR/issue-23620-invalid-escapes.rs:14:17 | LL | let _ = b'\xxy'; - | ^ invalid character in numeric character escape + | ^ error: numeric character escape is too short --> $DIR/issue-23620-invalid-escapes.rs:17:14 @@ -40,25 +36,23 @@ error: numeric character escape is too short LL | let _ = '\x5'; | ^^^ -error: invalid character in numeric character escape: `x` +error: invalid character in numeric character escape: x --> $DIR/issue-23620-invalid-escapes.rs:20:16 | LL | let _ = '\xxy'; - | ^ invalid character in numeric character escape + | ^ -error: unicode escape in byte string +error: unicode escape sequences cannot be used as a byte or in a byte string --> $DIR/issue-23620-invalid-escapes.rs:23:15 | LL | let _ = b"\u{a4a4} \xf \u"; - | ^^^^^^^^ unicode escape in byte string - | - = help: unicode escape sequences cannot be used as a byte or in a byte string + | ^^^^^^^^ -error: invalid character in numeric character escape: ` ` +error: invalid character in numeric character escape: --> $DIR/issue-23620-invalid-escapes.rs:23:27 | LL | let _ = b"\u{a4a4} \xf \u"; - | ^ invalid character in numeric character escape + | ^ error: incorrect unicode escape sequence --> $DIR/issue-23620-invalid-escapes.rs:23:28 @@ -68,11 +62,11 @@ LL | let _ = b"\u{a4a4} \xf \u"; | = help: format of unicode escape sequences is `\u{...}` -error: invalid character in numeric character escape: ` ` +error: invalid character in numeric character escape: --> $DIR/issue-23620-invalid-escapes.rs:28:17 | LL | let _ = "\xf \u"; - | ^ invalid character in numeric character escape + | ^ error: incorrect unicode escape sequence --> $DIR/issue-23620-invalid-escapes.rs:28:18 diff --git a/src/test/ui/parser/issue-43692.stderr b/src/test/ui/parser/issue-43692.stderr index baf998035178b..69a54af3d82ed 100644 --- a/src/test/ui/parser/issue-43692.stderr +++ b/src/test/ui/parser/issue-43692.stderr @@ -1,8 +1,8 @@ -error: invalid start of unicode escape: `_` +error: invalid start of unicode escape --> $DIR/issue-43692.rs:2:9 | LL | '\u{_10FFFF}'; - | ^ invalid start of unicode escape + | ^ error: aborting due to previous error diff --git a/src/test/ui/parser/issue-62913.stderr b/src/test/ui/parser/issue-62913.stderr index 6f385e8dc1777..f72174f8929b8 100644 --- a/src/test/ui/parser/issue-62913.stderr +++ b/src/test/ui/parser/issue-62913.stderr @@ -10,7 +10,7 @@ error: invalid trailing slash in literal --> $DIR/issue-62913.rs:1:5 | LL | "\u\" - | ^ invalid trailing slash in literal + | ^ error: expected item, found `"\u\"` --> $DIR/issue-62913.rs:1:1 diff --git a/src/test/ui/parser/issue-64732.stderr b/src/test/ui/parser/issue-64732.stderr index ac04258096280..3b00ffc8f6c8d 100644 --- a/src/test/ui/parser/issue-64732.stderr +++ b/src/test/ui/parser/issue-64732.stderr @@ -1,13 +1,13 @@ error: character literal may only contain one codepoint - --> $DIR/issue-64732.rs:3:16 + --> $DIR/issue-64732.rs:3:17 | LL | let _foo = b'hello\0'; - | ^^^^^^^^^^ + | ^^^^^^^^^ | help: if you meant to write a byte string literal, use double quotes | LL | let _foo = b"hello\0"; - | ^^^^^^^^^^ + | ^^^^^^^^^ error: character literal may only contain one codepoint --> $DIR/issue-64732.rs:6:16 diff --git a/src/test/ui/parser/issue-81806.rs b/src/test/ui/parser/issue-81806.rs deleted file mode 100644 index ca86788dff79c..0000000000000 --- a/src/test/ui/parser/issue-81806.rs +++ /dev/null @@ -1,5 +0,0 @@ -trait T { const -impl //~ ERROR: expected identifier, found keyword `impl` -} - -fn main() {} diff --git a/src/test/ui/parser/issue-81806.stderr b/src/test/ui/parser/issue-81806.stderr deleted file mode 100644 index b8ada11d922b2..0000000000000 --- a/src/test/ui/parser/issue-81806.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error: expected identifier, found keyword `impl` - --> $DIR/issue-81806.rs:2:1 - | -LL | trait T { const - | - while parsing this item list starting here -LL | impl - | ^^^^ expected identifier, found keyword -LL | } - | - the item list ends here - | -help: you can escape reserved keywords to use them as identifiers - | -LL | r#impl - | ^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/parser/issue-8537.stderr b/src/test/ui/parser/issue-8537.stderr index 3f63c08021098..e33adb239d78d 100644 --- a/src/test/ui/parser/issue-8537.stderr +++ b/src/test/ui/parser/issue-8537.stderr @@ -4,7 +4,7 @@ error[E0703]: invalid ABI: found `invalid-ab_isize` LL | "invalid-ab_isize" | ^^^^^^^^^^^^^^^^^^ invalid ABI | - = help: valid ABIs: Rust, C, cdecl, stdcall, fastcall, vectorcall, thiscall, aapcs, win64, sysv64, ptx-kernel, msp430-interrupt, x86-interrupt, amdgpu-kernel, efiapi, avr-interrupt, avr-non-blocking-interrupt, C-cmse-nonsecure-call, system, rust-intrinsic, rust-call, platform-intrinsic, unadjusted + = help: valid ABIs: Rust, C, cdecl, stdcall, fastcall, vectorcall, thiscall, aapcs, win64, sysv64, ptx-kernel, msp430-interrupt, x86-interrupt, amdgpu-kernel, efiapi, avr-interrupt, avr-non-blocking-interrupt, system, rust-intrinsic, rust-call, platform-intrinsic, unadjusted error: aborting due to previous error diff --git a/src/test/ui/parser/lex-bad-char-literals-1.stderr b/src/test/ui/parser/lex-bad-char-literals-1.stderr index ed129a1d13388..fcf4802f79bba 100644 --- a/src/test/ui/parser/lex-bad-char-literals-1.stderr +++ b/src/test/ui/parser/lex-bad-char-literals-1.stderr @@ -10,21 +10,17 @@ error: numeric character escape is too short LL | "\x1" | ^^^ -error: unknown character escape: `\u{25cf}` +error: unknown character escape: \u{25cf} --> $DIR/lex-bad-char-literals-1.rs:10:7 | LL | '\●' | ^ unknown character escape - | - = help: for more information, visit -error: unknown character escape: `\u{25cf}` +error: unknown character escape: \u{25cf} --> $DIR/lex-bad-char-literals-1.rs:14:7 | LL | "\●" | ^ unknown character escape - | - = help: for more information, visit error: aborting due to 4 previous errors diff --git a/src/test/ui/parser/lex-bad-char-literals-7.rs b/src/test/ui/parser/lex-bad-char-literals-7.rs index c675df2f3ccd0..1580157210e69 100644 --- a/src/test/ui/parser/lex-bad-char-literals-7.rs +++ b/src/test/ui/parser/lex-bad-char-literals-7.rs @@ -2,7 +2,7 @@ fn main() { let _: char = ''; //~^ ERROR: empty character literal let _: char = '\u{}'; - //~^ ERROR: empty unicode escape + //~^ ERROR: empty unicode escape (must have at least 1 hex digit) // Next two are OK, but may befool error recovery let _ = '/'; diff --git a/src/test/ui/parser/lex-bad-char-literals-7.stderr b/src/test/ui/parser/lex-bad-char-literals-7.stderr index 255b9c6899999..70ee8087b5163 100644 --- a/src/test/ui/parser/lex-bad-char-literals-7.stderr +++ b/src/test/ui/parser/lex-bad-char-literals-7.stderr @@ -2,13 +2,13 @@ error: empty character literal --> $DIR/lex-bad-char-literals-7.rs:2:20 | LL | let _: char = ''; - | ^ empty character literal + | ^ -error: empty unicode escape +error: empty unicode escape (must have at least 1 hex digit) --> $DIR/lex-bad-char-literals-7.rs:4:20 | LL | let _: char = '\u{}'; - | ^^^^ this escape must have at least 1 hex digit + | ^^^^ error[E0762]: unterminated character literal --> $DIR/lex-bad-char-literals-7.rs:11:13 diff --git a/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.rs b/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.rs index b7752e1f0c45f..9a9f9c433e1d6 100644 --- a/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.rs +++ b/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.rs @@ -22,5 +22,5 @@ fn main() { let _s = r"bar foo"; //~ ERROR: bare CR not allowed in raw string // the following string literal has a bare CR in it - let _s = "foo\ bar"; //~ ERROR: unknown character escape: `\r` + let _s = "foo\ bar"; //~ ERROR: unknown character escape: \r } diff --git a/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.stderr b/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.stderr index 1a21fed63bdec..598da6b930730 100644 --- a/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.stderr +++ b/src/test/ui/parser/lex-bare-cr-string-literal-doc-comment.stderr @@ -22,11 +22,11 @@ error: bare CR not allowed in block doc-comment LL | /*! block doc comment with bare CR: ' ' */ | ^ -error: bare CR not allowed in string, use `\r` instead +error: bare CR not allowed in string, use \r instead --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:19:18 | LL | let _s = "foo bar"; - | ^ help: escape the character: `\r` + | ^ error: bare CR not allowed in raw string --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:22:19 @@ -34,7 +34,7 @@ error: bare CR not allowed in raw string LL | let _s = r"bar foo"; | ^ -error: unknown character escape: `\r` +error: unknown character escape: \r --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:25:19 | LL | let _s = "foo\ bar"; diff --git a/src/test/ui/parser/macro/literals-are-validated-before-expansion.stderr b/src/test/ui/parser/macro/literals-are-validated-before-expansion.stderr index e874f62497ea8..d20eb0fb30a49 100644 --- a/src/test/ui/parser/macro/literals-are-validated-before-expansion.stderr +++ b/src/test/ui/parser/macro/literals-are-validated-before-expansion.stderr @@ -2,7 +2,7 @@ error: invalid unicode character escape --> $DIR/literals-are-validated-before-expansion.rs:6:20 | LL | black_hole! { '\u{FFFFFF}' } - | ^^^^^^^^^^ invalid escape + | ^^^^^^^^^^ | = help: unicode escape must be at most 10FFFF @@ -10,7 +10,7 @@ error: invalid unicode character escape --> $DIR/literals-are-validated-before-expansion.rs:8:39 | LL | black_hole! { "this is surrogate: \u{DAAA}" } - | ^^^^^^^^ invalid escape + | ^^^^^^^^ | = help: unicode escape must not be a surrogate diff --git a/src/test/ui/parser/new-unicode-escapes-1.rs b/src/test/ui/parser/new-unicode-escapes-1.rs index d6a54660ea6e8..0e1421214d9d8 100644 --- a/src/test/ui/parser/new-unicode-escapes-1.rs +++ b/src/test/ui/parser/new-unicode-escapes-1.rs @@ -1,3 +1,3 @@ pub fn main() { - let s = "\u{2603"; //~ ERROR unterminated unicode escape + let s = "\u{2603"; //~ ERROR unterminated unicode escape (needed a `}`) } diff --git a/src/test/ui/parser/new-unicode-escapes-1.stderr b/src/test/ui/parser/new-unicode-escapes-1.stderr index 1ffdc0401e59c..22d6a0981ffd6 100644 --- a/src/test/ui/parser/new-unicode-escapes-1.stderr +++ b/src/test/ui/parser/new-unicode-escapes-1.stderr @@ -1,13 +1,8 @@ -error: unterminated unicode escape +error: unterminated unicode escape (needed a `}`) --> $DIR/new-unicode-escapes-1.rs:2:14 | LL | let s = "\u{2603"; - | ^^^^^^^ missing a closing `}` - | -help: terminate the unicode escape - | -LL | let s = "\u{2603}"; - | ^ + | ^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/parser/new-unicode-escapes-2.rs b/src/test/ui/parser/new-unicode-escapes-2.rs index cbb614c19c004..b30b3dbf9036a 100644 --- a/src/test/ui/parser/new-unicode-escapes-2.rs +++ b/src/test/ui/parser/new-unicode-escapes-2.rs @@ -1,3 +1,3 @@ pub fn main() { - let s = "\u{260311111111}"; //~ ERROR overlong unicode escape + let s = "\u{260311111111}"; //~ ERROR overlong unicode escape (must have at most 6 hex digits) } diff --git a/src/test/ui/parser/new-unicode-escapes-2.stderr b/src/test/ui/parser/new-unicode-escapes-2.stderr index 2f3f8c0f9dae5..b5148279c7450 100644 --- a/src/test/ui/parser/new-unicode-escapes-2.stderr +++ b/src/test/ui/parser/new-unicode-escapes-2.stderr @@ -1,8 +1,8 @@ -error: overlong unicode escape +error: overlong unicode escape (must have at most 6 hex digits) --> $DIR/new-unicode-escapes-2.rs:2:14 | LL | let s = "\u{260311111111}"; - | ^^^^^^^^^^^^^^^^ must have at most 6 hex digits + | ^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/parser/new-unicode-escapes-3.stderr b/src/test/ui/parser/new-unicode-escapes-3.stderr index f5a0f8fc785c5..361698467f97d 100644 --- a/src/test/ui/parser/new-unicode-escapes-3.stderr +++ b/src/test/ui/parser/new-unicode-escapes-3.stderr @@ -2,7 +2,7 @@ error: invalid unicode character escape --> $DIR/new-unicode-escapes-3.rs:2:15 | LL | let s1 = "\u{d805}"; - | ^^^^^^^^ invalid escape + | ^^^^^^^^ | = help: unicode escape must not be a surrogate @@ -10,7 +10,7 @@ error: invalid unicode character escape --> $DIR/new-unicode-escapes-3.rs:3:15 | LL | let s2 = "\u{ffffff}"; - | ^^^^^^^^^^ invalid escape + | ^^^^^^^^^^ | = help: unicode escape must be at most 10FFFF diff --git a/src/test/ui/parser/new-unicode-escapes-4.rs b/src/test/ui/parser/new-unicode-escapes-4.rs index 79882713e59a2..9ac03cedc3f3e 100644 --- a/src/test/ui/parser/new-unicode-escapes-4.rs +++ b/src/test/ui/parser/new-unicode-escapes-4.rs @@ -1,4 +1,4 @@ pub fn main() { let s = "\u{lol}"; - //~^ ERROR invalid character in unicode escape: `l` + //~^ ERROR invalid character in unicode escape: l } diff --git a/src/test/ui/parser/new-unicode-escapes-4.stderr b/src/test/ui/parser/new-unicode-escapes-4.stderr index 514591af17e6e..a35c5f0f21658 100644 --- a/src/test/ui/parser/new-unicode-escapes-4.stderr +++ b/src/test/ui/parser/new-unicode-escapes-4.stderr @@ -1,8 +1,8 @@ -error: invalid character in unicode escape: `l` +error: invalid character in unicode escape: l --> $DIR/new-unicode-escapes-4.rs:2:17 | LL | let s = "\u{lol}"; - | ^ invalid character in unicode escape + | ^ error: aborting due to previous error diff --git a/src/test/ui/parser/raw/raw-byte-string-literals.stderr b/src/test/ui/parser/raw/raw-byte-string-literals.stderr index cfc877104bd9f..4076fe334e653 100644 --- a/src/test/ui/parser/raw/raw-byte-string-literals.stderr +++ b/src/test/ui/parser/raw/raw-byte-string-literals.stderr @@ -8,7 +8,7 @@ error: raw byte string must be ASCII --> $DIR/raw-byte-string-literals.rs:5:8 | LL | br"é"; - | ^ must be ASCII + | ^ error: found invalid character; only `#` is allowed in raw string delimitation: ~ --> $DIR/raw-byte-string-literals.rs:6:5 diff --git a/src/test/ui/parser/trailing-carriage-return-in-string.rs b/src/test/ui/parser/trailing-carriage-return-in-string.rs index 5d3c31944064a..8abf2624e4f97 100644 --- a/src/test/ui/parser/trailing-carriage-return-in-string.rs +++ b/src/test/ui/parser/trailing-carriage-return-in-string.rs @@ -8,7 +8,7 @@ fn main() { a test"; // \r only let bad = "This is \ a test"; - //~^ ERROR unknown character escape: `\r` - //~| HELP this is an isolated carriage return + //~^ ERROR unknown character escape: \r + //~^^ HELP this is an isolated carriage return } diff --git a/src/test/ui/parser/trailing-carriage-return-in-string.stderr b/src/test/ui/parser/trailing-carriage-return-in-string.stderr index 8a44e02707ce5..3687b9dd282d1 100644 --- a/src/test/ui/parser/trailing-carriage-return-in-string.stderr +++ b/src/test/ui/parser/trailing-carriage-return-in-string.stderr @@ -1,4 +1,4 @@ -error: unknown character escape: `\r` +error: unknown character escape: \r --> $DIR/trailing-carriage-return-in-string.rs:10:25 | LL | let bad = "This is \ a test"; diff --git a/src/test/ui/parser/unclosed-delimiter-in-dep.stderr b/src/test/ui/parser/unclosed-delimiter-in-dep.stderr index 00861a5a3d49a..d63a50034c58d 100644 --- a/src/test/ui/parser/unclosed-delimiter-in-dep.stderr +++ b/src/test/ui/parser/unclosed-delimiter-in-dep.stderr @@ -13,12 +13,12 @@ error[E0308]: mismatched types --> $DIR/unclosed-delimiter-in-dep.rs:4:20 | LL | let _: usize = unclosed_delim_mod::new(); - | ----- ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found enum `Result` + | ----- ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found enum `std::result::Result` | | | expected due to this | = note: expected type `usize` - found enum `Result` + found enum `std::result::Result` error: aborting due to 2 previous errors diff --git a/src/test/ui/parser/wrong-escape-of-curly-braces.rs b/src/test/ui/parser/wrong-escape-of-curly-braces.rs index 8e5258acd49da..7a5c27afca552 100644 --- a/src/test/ui/parser/wrong-escape-of-curly-braces.rs +++ b/src/test/ui/parser/wrong-escape-of-curly-braces.rs @@ -1,8 +1,8 @@ fn main() { let ok = "{{everything fine}}"; let bad = "\{it is wrong\}"; - //~^ ERROR unknown character escape: `{` - //~| HELP if used in a formatting string, curly braces are escaped with `{{` and `}}` - //~| ERROR unknown character escape: `}` - //~| HELP if used in a formatting string, curly braces are escaped with `{{` and `}}` + //~^ ERROR unknown character escape: { + //~^^ HELP if used in a formatting string, curly braces are escaped with `{{` and `}}` + //~^^^ ERROR unknown character escape: } + //~^^^^ HELP if used in a formatting string, curly braces are escaped with `{{` and `}}` } diff --git a/src/test/ui/parser/wrong-escape-of-curly-braces.stderr b/src/test/ui/parser/wrong-escape-of-curly-braces.stderr index ff1a2fb0f3c67..1406b795ba8c3 100644 --- a/src/test/ui/parser/wrong-escape-of-curly-braces.stderr +++ b/src/test/ui/parser/wrong-escape-of-curly-braces.stderr @@ -1,4 +1,4 @@ -error: unknown character escape: `{` +error: unknown character escape: { --> $DIR/wrong-escape-of-curly-braces.rs:3:17 | LL | let bad = "\{it is wrong\}"; @@ -6,7 +6,7 @@ LL | let bad = "\{it is wrong\}"; | = help: if used in a formatting string, curly braces are escaped with `{{` and `}}` -error: unknown character escape: `}` +error: unknown character escape: } --> $DIR/wrong-escape-of-curly-braces.rs:3:30 | LL | let bad = "\{it is wrong\}"; diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr index ff8183e87635f..bfb7b479731a6 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-move-and-move.stderr @@ -33,7 +33,7 @@ error[E0382]: use of moved value --> $DIR/borrowck-move-and-move.rs:20:16 | LL | match Ok(U) { - | ----- move occurs because value has type `Result`, which does not implement the `Copy` trait + | ----- move occurs because value has type `std::result::Result`, which does not implement the `Copy` trait LL | a @ Ok(b) | a @ Err(b) => {} | -------^- | | | @@ -44,7 +44,7 @@ error[E0382]: use of moved value --> $DIR/borrowck-move-and-move.rs:20:29 | LL | match Ok(U) { - | ----- move occurs because value has type `Result`, which does not implement the `Copy` trait + | ----- move occurs because value has type `std::result::Result`, which does not implement the `Copy` trait LL | a @ Ok(b) | a @ Err(b) => {} | --------^- | | | diff --git a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr index 13032c3838a92..00136c2576423 100644 --- a/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr +++ b/src/test/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr @@ -390,7 +390,7 @@ error[E0507]: cannot move out of `a` in pattern guard --> $DIR/borrowck-pat-ref-mut-and-ref.rs:111:66 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {} - | ^ move occurs because `a` has type `&mut Result`, which does not implement the `Copy` trait + | ^ move occurs because `a` has type `&mut std::result::Result`, which does not implement the `Copy` trait | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard @@ -398,7 +398,7 @@ error[E0507]: cannot move out of `a` in pattern guard --> $DIR/borrowck-pat-ref-mut-and-ref.rs:111:66 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {} - | ^ move occurs because `a` has type `&mut Result`, which does not implement the `Copy` trait + | ^ move occurs because `a` has type `&mut std::result::Result`, which does not implement the `Copy` trait | = note: variables bound in patterns cannot be moved from until after the end of the pattern guard diff --git a/src/test/ui/or-patterns/macro-pat.rs b/src/test/ui/pattern/or-pattern-macro-pat.rs similarity index 100% rename from src/test/ui/or-patterns/macro-pat.rs rename to src/test/ui/pattern/or-pattern-macro-pat.rs diff --git a/src/test/ui/pattern/pat-struct-field-expr-has-type.stderr b/src/test/ui/pattern/pat-struct-field-expr-has-type.stderr index 3a61d4293b01d..d57a8a0dbc181 100644 --- a/src/test/ui/pattern/pat-struct-field-expr-has-type.stderr +++ b/src/test/ui/pattern/pat-struct-field-expr-has-type.stderr @@ -4,10 +4,10 @@ error[E0308]: mismatched types LL | match (S { f: 42 }) { | ------------- this expression has type `S` LL | S { f: Ok(_) } => {} - | ^^^^^ expected `u8`, found enum `Result` + | ^^^^^ expected `u8`, found enum `std::result::Result` | = note: expected type `u8` - found enum `Result<_, _>` + found enum `std::result::Result<_, _>` error: aborting due to previous error diff --git a/src/test/ui/pattern/pat-type-err-let-stmt.stderr b/src/test/ui/pattern/pat-type-err-let-stmt.stderr index 4b4fb08928327..42258cfc1aef5 100644 --- a/src/test/ui/pattern/pat-type-err-let-stmt.stderr +++ b/src/test/ui/pattern/pat-type-err-let-stmt.stderr @@ -17,10 +17,10 @@ error[E0308]: mismatched types LL | let Ok(0): Option = 42u8; | ^^^^^ ---------- expected due to this | | - | expected enum `Option`, found enum `Result` + | expected enum `Option`, found enum `std::result::Result` | = note: expected enum `Option` - found enum `Result<_, _>` + found enum `std::result::Result<_, _>` error[E0308]: mismatched types --> $DIR/pat-type-err-let-stmt.rs:11:9 @@ -28,10 +28,10 @@ error[E0308]: mismatched types LL | let Ok(0): Option; | ^^^^^ ---------- expected due to this | | - | expected enum `Option`, found enum `Result` + | expected enum `Option`, found enum `std::result::Result` | = note: expected enum `Option` - found enum `Result<_, _>` + found enum `std::result::Result<_, _>` error[E0308]: mismatched types --> $DIR/pat-type-err-let-stmt.rs:15:9 @@ -39,10 +39,10 @@ error[E0308]: mismatched types LL | let Ok(0) = 42u8; | ^^^^^ ---- this expression has type `u8` | | - | expected `u8`, found enum `Result` + | expected `u8`, found enum `std::result::Result` | = note: expected type `u8` - found enum `Result<_, _>` + found enum `std::result::Result<_, _>` error: aborting due to 4 previous errors diff --git a/src/test/ui/pattern/usefulness/issue-80501-or-pat-and-macro.rs b/src/test/ui/pattern/usefulness/issue-80501-or-pat-and-macro.rs deleted file mode 100644 index aac7d7d5385a4..0000000000000 --- a/src/test/ui/pattern/usefulness/issue-80501-or-pat-and-macro.rs +++ /dev/null @@ -1,27 +0,0 @@ -// check-pass -#![deny(unreachable_patterns)] -pub enum TypeCtor { - Slice, - Array, -} - -pub struct ApplicationTy(TypeCtor); - -macro_rules! ty_app { - ($ctor:pat) => { - ApplicationTy($ctor) - }; -} - -fn _foo(ty: ApplicationTy) { - match ty { - ty_app!(TypeCtor::Array) | ty_app!(TypeCtor::Slice) => {} - } - - // same as above, with the macro expanded - match ty { - ApplicationTy(TypeCtor::Array) | ApplicationTy(TypeCtor::Slice) => {} - } -} - -fn main() {} diff --git a/src/test/ui/pattern/usefulness/non-exhaustive-match-nested.stderr b/src/test/ui/pattern/usefulness/non-exhaustive-match-nested.stderr index 928e9068266cd..d1cab75210296 100644 --- a/src/test/ui/pattern/usefulness/non-exhaustive-match-nested.stderr +++ b/src/test/ui/pattern/usefulness/non-exhaustive-match-nested.stderr @@ -5,7 +5,7 @@ LL | match (l1, l2) { | ^^^^^^^^ pattern `(Some(&[]), Err(_))` not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `(Option<&[T]>, Result<&[T], ()>)` + = note: the matched value is of type `(Option<&[T]>, std::result::Result<&[T], ()>)` error[E0004]: non-exhaustive patterns: `A(C)` not covered --> $DIR/non-exhaustive-match-nested.rs:15:11 diff --git a/src/test/ui/proc-macro/attribute-after-derive-feature-gate.rs b/src/test/ui/proc-macro/attribute-after-derive-feature-gate.rs deleted file mode 100644 index f0fec6782423e..0000000000000 --- a/src/test/ui/proc-macro/attribute-after-derive-feature-gate.rs +++ /dev/null @@ -1,37 +0,0 @@ -// gate-test-macro_attributes_in_derive_output -// aux-build: test-macros.rs - -#![feature(proc_macro_hygiene)] -#![feature(stmt_expr_attributes)] - -#[macro_use] -extern crate test_macros; - -#[derive(Empty)] -#[empty_attr] //~ ERROR macro attributes in `#[derive]` output are unstable -struct S1 { - field: [u8; 10], -} - -#[derive(Empty)] -#[empty_helper] -#[empty_attr] //~ ERROR macro attributes in `#[derive]` output are unstable -struct S2 { - field: [u8; 10], -} - -#[derive(Empty)] -struct S3 { - field: [u8; #[identity_attr] 10], //~ ERROR macro attributes in `#[derive]` output are unstable -} - -#[derive(Empty)] -struct S4 { - field: [u8; { - #[derive(Empty)] // OK, not gated - struct Inner; - 10 - }] -} - -fn main() {} diff --git a/src/test/ui/proc-macro/attribute-after-derive-feature-gate.stderr b/src/test/ui/proc-macro/attribute-after-derive-feature-gate.stderr deleted file mode 100644 index 74cace628b94c..0000000000000 --- a/src/test/ui/proc-macro/attribute-after-derive-feature-gate.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0658]: macro attributes in `#[derive]` output are unstable - --> $DIR/attribute-after-derive-feature-gate.rs:11:3 - | -LL | #[empty_attr] - | ^^^^^^^^^^ - | - = note: see issue #81119 for more information - = help: add `#![feature(macro_attributes_in_derive_output)]` to the crate attributes to enable - -error[E0658]: macro attributes in `#[derive]` output are unstable - --> $DIR/attribute-after-derive-feature-gate.rs:18:3 - | -LL | #[empty_attr] - | ^^^^^^^^^^ - | - = note: see issue #81119 for more information - = help: add `#![feature(macro_attributes_in_derive_output)]` to the crate attributes to enable - -error[E0658]: macro attributes in `#[derive]` output are unstable - --> $DIR/attribute-after-derive-feature-gate.rs:25:19 - | -LL | field: [u8; #[identity_attr] 10], - | ^^^^^^^^^^^^^ - | - = note: see issue #81119 for more information - = help: add `#![feature(macro_attributes_in_derive_output)]` to the crate attributes to enable - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/proc-macro/attribute-after-derive.rs b/src/test/ui/proc-macro/attribute-after-derive.rs deleted file mode 100644 index ac3f28b6ef3ea..0000000000000 --- a/src/test/ui/proc-macro/attribute-after-derive.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Macro attributes are allowed after `#[derive]` and -// `#[derive]` fully configures the item for following attributes. - -// check-pass -// compile-flags: -Z span-debug -// aux-build: test-macros.rs - -#![feature(macro_attributes_in_derive_output)] - -#![no_std] // Don't load unnecessary hygiene information from std -extern crate std; - -#[macro_use] -extern crate test_macros; - -#[print_attr] -#[derive(Print)] -struct AttributeDerive { - #[cfg(FALSE)] - field: u8, -} - -#[derive(Print)] -#[print_attr] -struct DeriveAttribute { - #[cfg(FALSE)] - field: u8, -} - -fn main() {} diff --git a/src/test/ui/proc-macro/attribute-after-derive.stdout b/src/test/ui/proc-macro/attribute-after-derive.stdout deleted file mode 100644 index 11f492353271a..0000000000000 --- a/src/test/ui/proc-macro/attribute-after-derive.stdout +++ /dev/null @@ -1,148 +0,0 @@ -PRINT-ATTR INPUT (DISPLAY): #[derive(Print)] struct AttributeDerive { #[cfg(FALSE)] field : u8, } -PRINT-ATTR INPUT (DEBUG): TokenStream [ - Punct { - ch: '#', - spacing: Alone, - span: $DIR/attribute-after-derive.rs:17:1: 17:2 (#0), - }, - Group { - delimiter: Bracket, - stream: TokenStream [ - Ident { - ident: "derive", - span: $DIR/attribute-after-derive.rs:17:3: 17:9 (#0), - }, - Group { - delimiter: Parenthesis, - stream: TokenStream [ - Ident { - ident: "Print", - span: $DIR/attribute-after-derive.rs:17:10: 17:15 (#0), - }, - ], - span: $DIR/attribute-after-derive.rs:17:9: 17:16 (#0), - }, - ], - span: $DIR/attribute-after-derive.rs:17:2: 17:17 (#0), - }, - Ident { - ident: "struct", - span: $DIR/attribute-after-derive.rs:18:1: 18:7 (#0), - }, - Ident { - ident: "AttributeDerive", - span: $DIR/attribute-after-derive.rs:18:8: 18:23 (#0), - }, - Group { - delimiter: Brace, - stream: TokenStream [ - Punct { - ch: '#', - spacing: Alone, - span: $DIR/attribute-after-derive.rs:19:5: 19:6 (#0), - }, - Group { - delimiter: Bracket, - stream: TokenStream [ - Ident { - ident: "cfg", - span: $DIR/attribute-after-derive.rs:19:7: 19:10 (#0), - }, - Group { - delimiter: Parenthesis, - stream: TokenStream [ - Ident { - ident: "FALSE", - span: $DIR/attribute-after-derive.rs:19:11: 19:16 (#0), - }, - ], - span: $DIR/attribute-after-derive.rs:19:10: 19:17 (#0), - }, - ], - span: $DIR/attribute-after-derive.rs:19:6: 19:18 (#0), - }, - Ident { - ident: "field", - span: $DIR/attribute-after-derive.rs:20:5: 20:10 (#0), - }, - Punct { - ch: ':', - spacing: Alone, - span: $DIR/attribute-after-derive.rs:20:10: 20:11 (#0), - }, - Ident { - ident: "u8", - span: $DIR/attribute-after-derive.rs:20:12: 20:14 (#0), - }, - Punct { - ch: ',', - spacing: Alone, - span: $DIR/attribute-after-derive.rs:20:14: 20:15 (#0), - }, - ], - span: $DIR/attribute-after-derive.rs:18:24: 21:2 (#0), - }, -] -PRINT-DERIVE INPUT (DISPLAY): struct AttributeDerive { } -PRINT-DERIVE INPUT (DEBUG): TokenStream [ - Ident { - ident: "struct", - span: $DIR/attribute-after-derive.rs:18:1: 21:2 (#0), - }, - Ident { - ident: "AttributeDerive", - span: $DIR/attribute-after-derive.rs:18:1: 21:2 (#0), - }, - Group { - delimiter: Brace, - stream: TokenStream [], - span: $DIR/attribute-after-derive.rs:18:1: 21:2 (#0), - }, -] -PRINT-ATTR INPUT (DISPLAY): struct DeriveAttribute { } -PRINT-ATTR INPUT (DEBUG): TokenStream [ - Ident { - ident: "struct", - span: $DIR/attribute-after-derive.rs:25:1: 28:2 (#0), - }, - Ident { - ident: "DeriveAttribute", - span: $DIR/attribute-after-derive.rs:25:1: 28:2 (#0), - }, - Group { - delimiter: Brace, - stream: TokenStream [], - span: $DIR/attribute-after-derive.rs:25:1: 28:2 (#0), - }, -] -PRINT-DERIVE INPUT (DISPLAY): #[print_attr] struct DeriveAttribute { } -PRINT-DERIVE INPUT (DEBUG): TokenStream [ - Punct { - ch: '#', - spacing: Alone, - span: $DIR/attribute-after-derive.rs:25:1: 28:2 (#0), - }, - Group { - delimiter: Bracket, - stream: TokenStream [ - Ident { - ident: "print_attr", - span: $DIR/attribute-after-derive.rs:25:1: 28:2 (#0), - }, - ], - span: $DIR/attribute-after-derive.rs:25:1: 28:2 (#0), - }, - Ident { - ident: "struct", - span: $DIR/attribute-after-derive.rs:25:1: 28:2 (#0), - }, - Ident { - ident: "DeriveAttribute", - span: $DIR/attribute-after-derive.rs:25:1: 28:2 (#0), - }, - Group { - delimiter: Brace, - stream: TokenStream [], - span: $DIR/attribute-after-derive.rs:25:1: 28:2 (#0), - }, -] diff --git a/src/test/ui/proc-macro/attribute-order-restricted.rs b/src/test/ui/proc-macro/attribute-order-restricted.rs new file mode 100644 index 0000000000000..a3d4d23450ca6 --- /dev/null +++ b/src/test/ui/proc-macro/attribute-order-restricted.rs @@ -0,0 +1,14 @@ +// aux-build:test-macros.rs + +#[macro_use] +extern crate test_macros; + +#[identity_attr] // OK +#[derive(Clone)] +struct Before; + +#[derive(Clone)] +#[identity_attr] //~ ERROR macro attributes must be placed before `#[derive]` +struct After; + +fn main() {} diff --git a/src/test/ui/proc-macro/attribute-order-restricted.stderr b/src/test/ui/proc-macro/attribute-order-restricted.stderr new file mode 100644 index 0000000000000..9ca8a443e40fb --- /dev/null +++ b/src/test/ui/proc-macro/attribute-order-restricted.stderr @@ -0,0 +1,8 @@ +error: macro attributes must be placed before `#[derive]` + --> $DIR/attribute-order-restricted.rs:11:1 + | +LL | #[identity_attr] + | ^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/proc-macro/derive-helper-legacy-limits.rs b/src/test/ui/proc-macro/derive-helper-legacy-limits.rs deleted file mode 100644 index ca904900da0bb..0000000000000 --- a/src/test/ui/proc-macro/derive-helper-legacy-limits.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Support for legacy derive helpers is limited and heuristic-based -// (that's exactly the reason why they are deprecated). - -// edition:2018 -// aux-build:test-macros.rs - -#[macro_use] -extern crate test_macros; - -use derive as my_derive; - -#[my_derive(Empty)] -#[empty_helper] // OK -struct S1; - -// Legacy helper detection doesn't see through `derive` renaming. -#[empty_helper] //~ ERROR cannot find attribute `empty_helper` in this scope -#[my_derive(Empty)] -struct S2; - -fn main() {} diff --git a/src/test/ui/proc-macro/derive-helper-legacy-limits.stderr b/src/test/ui/proc-macro/derive-helper-legacy-limits.stderr deleted file mode 100644 index 186f38a00f917..0000000000000 --- a/src/test/ui/proc-macro/derive-helper-legacy-limits.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: cannot find attribute `empty_helper` in this scope - --> $DIR/derive-helper-legacy-limits.rs:17:3 - | -LL | #[empty_helper] - | ^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/proc-macro/derive-helper-shadowing.rs b/src/test/ui/proc-macro/derive-helper-shadowing.rs index 80d982d2504db..6147e96a74bf1 100644 --- a/src/test/ui/proc-macro/derive-helper-shadowing.rs +++ b/src/test/ui/proc-macro/derive-helper-shadowing.rs @@ -17,8 +17,6 @@ macro_rules! gen_helper_use { } #[empty_helper] //~ ERROR `empty_helper` is ambiguous - //~| WARN derive helper attribute is used before it is introduced - //~| WARN this was previously accepted #[derive(Empty)] struct S { #[empty_helper] // OK, no ambiguity, derive helpers have highest priority diff --git a/src/test/ui/proc-macro/derive-helper-shadowing.stderr b/src/test/ui/proc-macro/derive-helper-shadowing.stderr index a49df9f2d4a33..f82f49aa77526 100644 --- a/src/test/ui/proc-macro/derive-helper-shadowing.stderr +++ b/src/test/ui/proc-macro/derive-helper-shadowing.stderr @@ -1,17 +1,17 @@ error: cannot use a derive helper attribute through an import - --> $DIR/derive-helper-shadowing.rs:42:15 + --> $DIR/derive-helper-shadowing.rs:40:15 | LL | #[renamed] | ^^^^^^^ | note: the derive helper attribute imported here - --> $DIR/derive-helper-shadowing.rs:41:17 + --> $DIR/derive-helper-shadowing.rs:39:17 | LL | use empty_helper as renamed; | ^^^^^^^^^^^^^^^^^^^^^^^ error: cannot find attribute `empty_helper` in this scope - --> $DIR/derive-helper-shadowing.rs:38:22 + --> $DIR/derive-helper-shadowing.rs:36:22 | LL | #[derive(GenHelperUse)] | ^^^^^^^^^^^^ @@ -30,13 +30,13 @@ LL | gen_helper_use!(); = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error[E0659]: `empty_helper` is ambiguous (name vs any other name during import resolution) - --> $DIR/derive-helper-shadowing.rs:26:13 + --> $DIR/derive-helper-shadowing.rs:24:13 | LL | use empty_helper; | ^^^^^^^^^^^^ ambiguous name | note: `empty_helper` could refer to the derive helper attribute defined here - --> $DIR/derive-helper-shadowing.rs:22:10 + --> $DIR/derive-helper-shadowing.rs:20:10 | LL | #[derive(Empty)] | ^^^^^ @@ -54,7 +54,7 @@ LL | #[empty_helper] | ^^^^^^^^^^^^ ambiguous name | note: `empty_helper` could refer to the derive helper attribute defined here - --> $DIR/derive-helper-shadowing.rs:22:10 + --> $DIR/derive-helper-shadowing.rs:20:10 | LL | #[derive(Empty)] | ^^^^^ @@ -65,19 +65,6 @@ LL | use test_macros::empty_attr as empty_helper; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use `crate::empty_helper` to refer to this attribute macro unambiguously -warning: derive helper attribute is used before it is introduced - --> $DIR/derive-helper-shadowing.rs:19:3 - | -LL | #[empty_helper] - | ^^^^^^^^^^^^ -... -LL | #[derive(Empty)] - | ----- the attribute is introduced here - | - = note: `#[warn(legacy_derive_helpers)]` 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 #79202 - -error: aborting due to 5 previous errors; 1 warning emitted +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0659`. diff --git a/src/test/ui/proc-macro/derive-helper-vs-legacy.rs b/src/test/ui/proc-macro/derive-helper-vs-legacy.rs deleted file mode 100644 index 98836bcb8937d..0000000000000 --- a/src/test/ui/proc-macro/derive-helper-vs-legacy.rs +++ /dev/null @@ -1,12 +0,0 @@ -// check-pass -// aux-build:test-macros.rs - -#[macro_use] -extern crate test_macros; - -#[derive(Empty)] -#[empty_helper] // OK, this is both derive helper and legacy derive helper -#[derive(Empty)] -struct S; - -fn main() {} diff --git a/src/test/ui/proc-macro/derive-multiple-with-packed.rs b/src/test/ui/proc-macro/derive-multiple-with-packed.rs deleted file mode 100644 index 23578aa0e9fb8..0000000000000 --- a/src/test/ui/proc-macro/derive-multiple-with-packed.rs +++ /dev/null @@ -1,11 +0,0 @@ -// check-pass - -#[derive(Clone, Copy)] -#[derive(Debug)] // OK, even if `Copy` is in the different `#[derive]` -#[derive(PartialEq)] // OK too -#[repr(packed)] -struct CacheRecordHeader { - field: u64, -} - -fn main() {} diff --git a/src/test/ui/proc-macro/helper-attr-blocked-by-import-ambig.rs b/src/test/ui/proc-macro/helper-attr-blocked-by-import-ambig.rs index 40c42d82f68de..3a1c56efce8c2 100644 --- a/src/test/ui/proc-macro/helper-attr-blocked-by-import-ambig.rs +++ b/src/test/ui/proc-macro/helper-attr-blocked-by-import-ambig.rs @@ -4,10 +4,8 @@ extern crate test_macros; use test_macros::empty_attr as empty_helper; -#[empty_helper] //~ ERROR `empty_helper` is ambiguous - //~| WARN derive helper attribute is used before it is introduced - //~| WARN this was previously accepted #[derive(Empty)] +#[empty_helper] //~ ERROR `empty_helper` is ambiguous struct S; fn main() {} diff --git a/src/test/ui/proc-macro/helper-attr-blocked-by-import-ambig.stderr b/src/test/ui/proc-macro/helper-attr-blocked-by-import-ambig.stderr index ceb6d789785cc..012fb105b128d 100644 --- a/src/test/ui/proc-macro/helper-attr-blocked-by-import-ambig.stderr +++ b/src/test/ui/proc-macro/helper-attr-blocked-by-import-ambig.stderr @@ -1,11 +1,11 @@ error[E0659]: `empty_helper` is ambiguous (derive helper attribute vs any other name) - --> $DIR/helper-attr-blocked-by-import-ambig.rs:7:3 + --> $DIR/helper-attr-blocked-by-import-ambig.rs:8:3 | LL | #[empty_helper] | ^^^^^^^^^^^^ ambiguous name | note: `empty_helper` could refer to the derive helper attribute defined here - --> $DIR/helper-attr-blocked-by-import-ambig.rs:10:10 + --> $DIR/helper-attr-blocked-by-import-ambig.rs:7:10 | LL | #[derive(Empty)] | ^^^^^ @@ -16,19 +16,6 @@ LL | use test_macros::empty_attr as empty_helper; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: use `crate::empty_helper` to refer to this attribute macro unambiguously -warning: derive helper attribute is used before it is introduced - --> $DIR/helper-attr-blocked-by-import-ambig.rs:7:3 - | -LL | #[empty_helper] - | ^^^^^^^^^^^^ -... -LL | #[derive(Empty)] - | ----- the attribute is introduced here - | - = note: `#[warn(legacy_derive_helpers)]` 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 #79202 - -error: aborting due to previous error; 1 warning emitted +error: aborting due to previous error For more information about this error, try `rustc --explain E0659`. diff --git a/src/test/ui/proc-macro/issue-75930-derive-cfg.rs b/src/test/ui/proc-macro/issue-75930-derive-cfg.rs index 649e731840337..a051d23bac0ae 100644 --- a/src/test/ui/proc-macro/issue-75930-derive-cfg.rs +++ b/src/test/ui/proc-macro/issue-75930-derive-cfg.rs @@ -13,8 +13,7 @@ #[macro_use] extern crate test_macros; -#[print_helper(a)] //~ WARN derive helper attribute is used before it is introduced - //~| WARN this was previously accepted +#[print_helper(a)] #[cfg_attr(not(FALSE), allow(dead_code))] #[print_attr] #[derive(Print)] diff --git a/src/test/ui/proc-macro/issue-75930-derive-cfg.stderr b/src/test/ui/proc-macro/issue-75930-derive-cfg.stderr deleted file mode 100644 index 5227da7d76677..0000000000000 --- a/src/test/ui/proc-macro/issue-75930-derive-cfg.stderr +++ /dev/null @@ -1,15 +0,0 @@ -warning: derive helper attribute is used before it is introduced - --> $DIR/issue-75930-derive-cfg.rs:16:3 - | -LL | #[print_helper(a)] - | ^^^^^^^^^^^^ -... -LL | #[derive(Print)] - | ----- the attribute is introduced here - | - = note: `#[warn(legacy_derive_helpers)]` 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 #79202 - -warning: 1 warning emitted - diff --git a/src/test/ui/proc-macro/issue-75930-derive-cfg.stdout b/src/test/ui/proc-macro/issue-75930-derive-cfg.stdout index 19aa4dfb60e36..5f513684cfa6f 100644 --- a/src/test/ui/proc-macro/issue-75930-derive-cfg.stdout +++ b/src/test/ui/proc-macro/issue-75930-derive-cfg.stdout @@ -26,77 +26,77 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:18:1: 18:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:17:1: 17:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "allow", - span: $DIR/issue-75930-derive-cfg.rs:18:24: 18:29 (#0), + span: $DIR/issue-75930-derive-cfg.rs:17:24: 17:29 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "dead_code", - span: $DIR/issue-75930-derive-cfg.rs:18:30: 18:39 (#0), + span: $DIR/issue-75930-derive-cfg.rs:17:30: 17:39 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:18:29: 18:40 (#0), + span: $DIR/issue-75930-derive-cfg.rs:17:29: 17:40 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:18:1: 18:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:17:1: 17:2 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:20:1: 20:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:19:1: 19:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "derive", - span: $DIR/issue-75930-derive-cfg.rs:20:3: 20:9 (#0), + span: $DIR/issue-75930-derive-cfg.rs:19:3: 19:9 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "Print", - span: $DIR/issue-75930-derive-cfg.rs:20:10: 20:15 (#0), + span: $DIR/issue-75930-derive-cfg.rs:19:10: 19:15 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:20:9: 20:16 (#0), + span: $DIR/issue-75930-derive-cfg.rs:19:9: 19:16 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:20:2: 20:17 (#0), + span: $DIR/issue-75930-derive-cfg.rs:19:2: 19:17 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:21:1: 21:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:20:1: 20:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "print_helper", - span: $DIR/issue-75930-derive-cfg.rs:21:3: 21:15 (#0), + span: $DIR/issue-75930-derive-cfg.rs:20:3: 20:15 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "b", - span: $DIR/issue-75930-derive-cfg.rs:21:16: 21:17 (#0), + span: $DIR/issue-75930-derive-cfg.rs:20:16: 20:17 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:21:15: 21:18 (#0), + span: $DIR/issue-75930-derive-cfg.rs:20:15: 20:18 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:21:2: 21:19 (#0), + span: $DIR/issue-75930-derive-cfg.rs:20:2: 20:19 (#0), }, Punct { ch: '#', @@ -125,59 +125,59 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ }, Ident { ident: "struct", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 22:7 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 21:7 (#0), }, Ident { ident: "Foo", - span: $DIR/issue-75930-derive-cfg.rs:22:8: 22:11 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:8: 21:11 (#0), }, Punct { ch: '<', spacing: Joint, - span: $DIR/issue-75930-derive-cfg.rs:22:11: 22:12 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:11: 21:12 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:12: 22:13 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:12: 21:13 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:22:14: 22:17 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:14: 21:17 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:22:18: 22:23 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:18: 21:23 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:17: 22:24 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:17: 21:24 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:13: 22:25 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:13: 21:25 (#0), }, Ident { ident: "A", - span: $DIR/issue-75930-derive-cfg.rs:22:26: 22:27 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:26: 21:27 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:27: 22:28 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:27: 21:28 (#0), }, Ident { ident: "B", - span: $DIR/issue-75930-derive-cfg.rs:22:29: 22:30 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:29: 21:30 (#0), }, Punct { ch: '>', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:30: 22:31 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:30: 21:31 (#0), }, Group { delimiter: Brace, @@ -185,128 +185,128 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:23:5: 23:6 (#0), + span: $DIR/issue-75930-derive-cfg.rs:22:5: 22:6 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:23:7: 23:10 (#0), + span: $DIR/issue-75930-derive-cfg.rs:22:7: 22:10 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:23:11: 23:16 (#0), + span: $DIR/issue-75930-derive-cfg.rs:22:11: 22:16 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:23:10: 23:17 (#0), + span: $DIR/issue-75930-derive-cfg.rs:22:10: 22:17 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:23:6: 23:18 (#0), + span: $DIR/issue-75930-derive-cfg.rs:22:6: 22:18 (#0), }, Ident { ident: "first", - span: $DIR/issue-75930-derive-cfg.rs:23:19: 23:24 (#0), + span: $DIR/issue-75930-derive-cfg.rs:22:19: 22:24 (#0), }, Punct { ch: ':', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:23:24: 23:25 (#0), + span: $DIR/issue-75930-derive-cfg.rs:22:24: 22:25 (#0), }, Ident { ident: "String", - span: $DIR/issue-75930-derive-cfg.rs:23:26: 23:32 (#0), + span: $DIR/issue-75930-derive-cfg.rs:22:26: 22:32 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:23:32: 23:33 (#0), + span: $DIR/issue-75930-derive-cfg.rs:22:32: 22:33 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:24:5: 24:6 (#0), + span: $DIR/issue-75930-derive-cfg.rs:23:5: 23:6 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg_attr", - span: $DIR/issue-75930-derive-cfg.rs:24:7: 24:15 (#0), + span: $DIR/issue-75930-derive-cfg.rs:23:7: 23:15 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:24:16: 24:21 (#0), + span: $DIR/issue-75930-derive-cfg.rs:23:16: 23:21 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:24:21: 24:22 (#0), + span: $DIR/issue-75930-derive-cfg.rs:23:21: 23:22 (#0), }, Ident { ident: "deny", - span: $DIR/issue-75930-derive-cfg.rs:24:23: 24:27 (#0), + span: $DIR/issue-75930-derive-cfg.rs:23:23: 23:27 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "warnings", - span: $DIR/issue-75930-derive-cfg.rs:24:28: 24:36 (#0), + span: $DIR/issue-75930-derive-cfg.rs:23:28: 23:36 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:24:27: 24:37 (#0), + span: $DIR/issue-75930-derive-cfg.rs:23:27: 23:37 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:24:15: 24:38 (#0), + span: $DIR/issue-75930-derive-cfg.rs:23:15: 23:38 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:24:6: 24:39 (#0), + span: $DIR/issue-75930-derive-cfg.rs:23:6: 23:39 (#0), }, Ident { ident: "second", - span: $DIR/issue-75930-derive-cfg.rs:24:40: 24:46 (#0), + span: $DIR/issue-75930-derive-cfg.rs:23:40: 23:46 (#0), }, Punct { ch: ':', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:24:46: 24:47 (#0), + span: $DIR/issue-75930-derive-cfg.rs:23:46: 23:47 (#0), }, Ident { ident: "bool", - span: $DIR/issue-75930-derive-cfg.rs:24:48: 24:52 (#0), + span: $DIR/issue-75930-derive-cfg.rs:23:48: 23:52 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:24:52: 24:53 (#0), + span: $DIR/issue-75930-derive-cfg.rs:23:52: 23:53 (#0), }, Ident { ident: "third", - span: $DIR/issue-75930-derive-cfg.rs:25:5: 25:10 (#0), + span: $DIR/issue-75930-derive-cfg.rs:24:5: 24:10 (#0), }, Punct { ch: ':', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:25:10: 25:11 (#0), + span: $DIR/issue-75930-derive-cfg.rs:24:10: 24:11 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "u8", - span: $DIR/issue-75930-derive-cfg.rs:25:13: 25:15 (#0), + span: $DIR/issue-75930-derive-cfg.rs:24:13: 24:15 (#0), }, Punct { ch: ';', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:25:15: 25:16 (#0), + span: $DIR/issue-75930-derive-cfg.rs:24:15: 24:16 (#0), }, Group { delimiter: Brace, @@ -314,145 +314,145 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:26:9: 26:10 (#0), + span: $DIR/issue-75930-derive-cfg.rs:25:9: 25:10 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:26:11: 26:14 (#0), + span: $DIR/issue-75930-derive-cfg.rs:25:11: 25:14 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:26:15: 26:20 (#0), + span: $DIR/issue-75930-derive-cfg.rs:25:15: 25:20 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:26:14: 26:21 (#0), + span: $DIR/issue-75930-derive-cfg.rs:25:14: 25:21 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:26:10: 26:22 (#0), + span: $DIR/issue-75930-derive-cfg.rs:25:10: 25:22 (#0), }, Ident { ident: "struct", - span: $DIR/issue-75930-derive-cfg.rs:26:23: 26:29 (#0), + span: $DIR/issue-75930-derive-cfg.rs:25:23: 25:29 (#0), }, Ident { ident: "Bar", - span: $DIR/issue-75930-derive-cfg.rs:26:30: 26:33 (#0), + span: $DIR/issue-75930-derive-cfg.rs:25:30: 25:33 (#0), }, Punct { ch: ';', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:26:33: 26:34 (#0), + span: $DIR/issue-75930-derive-cfg.rs:25:33: 25:34 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:27:9: 27:10 (#0), + span: $DIR/issue-75930-derive-cfg.rs:26:9: 26:10 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:27:11: 27:14 (#0), + span: $DIR/issue-75930-derive-cfg.rs:26:11: 26:14 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "not", - span: $DIR/issue-75930-derive-cfg.rs:27:15: 27:18 (#0), + span: $DIR/issue-75930-derive-cfg.rs:26:15: 26:18 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:27:19: 27:24 (#0), + span: $DIR/issue-75930-derive-cfg.rs:26:19: 26:24 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:27:18: 27:25 (#0), + span: $DIR/issue-75930-derive-cfg.rs:26:18: 26:25 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:27:14: 27:26 (#0), + span: $DIR/issue-75930-derive-cfg.rs:26:14: 26:26 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:27:10: 27:27 (#0), + span: $DIR/issue-75930-derive-cfg.rs:26:10: 26:27 (#0), }, Ident { ident: "struct", - span: $DIR/issue-75930-derive-cfg.rs:27:28: 27:34 (#0), + span: $DIR/issue-75930-derive-cfg.rs:26:28: 26:34 (#0), }, Ident { ident: "Inner", - span: $DIR/issue-75930-derive-cfg.rs:27:35: 27:40 (#0), + span: $DIR/issue-75930-derive-cfg.rs:26:35: 26:40 (#0), }, Punct { ch: ';', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:27:40: 27:41 (#0), + span: $DIR/issue-75930-derive-cfg.rs:26:40: 26:41 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:28:9: 28:10 (#0), + span: $DIR/issue-75930-derive-cfg.rs:27:9: 27:10 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:28:11: 28:14 (#0), + span: $DIR/issue-75930-derive-cfg.rs:27:11: 27:14 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:28:15: 28:20 (#0), + span: $DIR/issue-75930-derive-cfg.rs:27:15: 27:20 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:28:14: 28:21 (#0), + span: $DIR/issue-75930-derive-cfg.rs:27:14: 27:21 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:28:10: 28:22 (#0), + span: $DIR/issue-75930-derive-cfg.rs:27:10: 27:22 (#0), }, Ident { ident: "let", - span: $DIR/issue-75930-derive-cfg.rs:28:23: 28:26 (#0), + span: $DIR/issue-75930-derive-cfg.rs:27:23: 27:26 (#0), }, Ident { ident: "a", - span: $DIR/issue-75930-derive-cfg.rs:28:27: 28:28 (#0), + span: $DIR/issue-75930-derive-cfg.rs:27:27: 27:28 (#0), }, Punct { ch: '=', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:28:29: 28:30 (#0), + span: $DIR/issue-75930-derive-cfg.rs:27:29: 27:30 (#0), }, Literal { kind: Integer, symbol: "25", suffix: None, - span: $DIR/issue-75930-derive-cfg.rs:28:31: 28:33 (#0), + span: $DIR/issue-75930-derive-cfg.rs:27:31: 27:33 (#0), }, Punct { ch: ';', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:28:33: 28:34 (#0), + span: $DIR/issue-75930-derive-cfg.rs:27:33: 27:34 (#0), }, Ident { ident: "match", - span: $DIR/issue-75930-derive-cfg.rs:29:9: 29:14 (#0), + span: $DIR/issue-75930-derive-cfg.rs:28:9: 28:14 (#0), }, Ident { ident: "true", - span: $DIR/issue-75930-derive-cfg.rs:29:15: 29:19 (#0), + span: $DIR/issue-75930-derive-cfg.rs:28:15: 28:19 (#0), }, Group { delimiter: Brace, @@ -460,194 +460,194 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:30:13: 30:14 (#0), + span: $DIR/issue-75930-derive-cfg.rs:29:13: 29:14 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:30:15: 30:18 (#0), + span: $DIR/issue-75930-derive-cfg.rs:29:15: 29:18 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:30:19: 30:24 (#0), + span: $DIR/issue-75930-derive-cfg.rs:29:19: 29:24 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:30:18: 30:25 (#0), + span: $DIR/issue-75930-derive-cfg.rs:29:18: 29:25 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:30:14: 30:26 (#0), + span: $DIR/issue-75930-derive-cfg.rs:29:14: 29:26 (#0), }, Ident { ident: "true", - span: $DIR/issue-75930-derive-cfg.rs:30:27: 30:31 (#0), + span: $DIR/issue-75930-derive-cfg.rs:29:27: 29:31 (#0), }, Punct { ch: '=', spacing: Joint, - span: $DIR/issue-75930-derive-cfg.rs:30:32: 30:34 (#0), + span: $DIR/issue-75930-derive-cfg.rs:29:32: 29:34 (#0), }, Punct { ch: '>', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:30:32: 30:34 (#0), + span: $DIR/issue-75930-derive-cfg.rs:29:32: 29:34 (#0), }, Group { delimiter: Brace, stream: TokenStream [], - span: $DIR/issue-75930-derive-cfg.rs:30:35: 30:37 (#0), + span: $DIR/issue-75930-derive-cfg.rs:29:35: 29:37 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:30:37: 30:38 (#0), + span: $DIR/issue-75930-derive-cfg.rs:29:37: 29:38 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:31:13: 31:14 (#0), + span: $DIR/issue-75930-derive-cfg.rs:30:13: 30:14 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg_attr", - span: $DIR/issue-75930-derive-cfg.rs:31:15: 31:23 (#0), + span: $DIR/issue-75930-derive-cfg.rs:30:15: 30:23 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "not", - span: $DIR/issue-75930-derive-cfg.rs:31:24: 31:27 (#0), + span: $DIR/issue-75930-derive-cfg.rs:30:24: 30:27 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:31:28: 31:33 (#0), + span: $DIR/issue-75930-derive-cfg.rs:30:28: 30:33 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:31:27: 31:34 (#0), + span: $DIR/issue-75930-derive-cfg.rs:30:27: 30:34 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:31:34: 31:35 (#0), + span: $DIR/issue-75930-derive-cfg.rs:30:34: 30:35 (#0), }, Ident { ident: "allow", - span: $DIR/issue-75930-derive-cfg.rs:31:36: 31:41 (#0), + span: $DIR/issue-75930-derive-cfg.rs:30:36: 30:41 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "warnings", - span: $DIR/issue-75930-derive-cfg.rs:31:42: 31:50 (#0), + span: $DIR/issue-75930-derive-cfg.rs:30:42: 30:50 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:31:41: 31:51 (#0), + span: $DIR/issue-75930-derive-cfg.rs:30:41: 30:51 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:31:23: 31:52 (#0), + span: $DIR/issue-75930-derive-cfg.rs:30:23: 30:52 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:31:14: 31:53 (#0), + span: $DIR/issue-75930-derive-cfg.rs:30:14: 30:53 (#0), }, Ident { ident: "false", - span: $DIR/issue-75930-derive-cfg.rs:31:54: 31:59 (#0), + span: $DIR/issue-75930-derive-cfg.rs:30:54: 30:59 (#0), }, Punct { ch: '=', spacing: Joint, - span: $DIR/issue-75930-derive-cfg.rs:31:60: 31:62 (#0), + span: $DIR/issue-75930-derive-cfg.rs:30:60: 30:62 (#0), }, Punct { ch: '>', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:31:60: 31:62 (#0), + span: $DIR/issue-75930-derive-cfg.rs:30:60: 30:62 (#0), }, Group { delimiter: Brace, stream: TokenStream [], - span: $DIR/issue-75930-derive-cfg.rs:31:63: 31:65 (#0), + span: $DIR/issue-75930-derive-cfg.rs:30:63: 30:65 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:31:65: 31:66 (#0), + span: $DIR/issue-75930-derive-cfg.rs:30:65: 30:66 (#0), }, Ident { ident: "_", - span: $DIR/issue-75930-derive-cfg.rs:32:13: 32:14 (#0), + span: $DIR/issue-75930-derive-cfg.rs:31:13: 31:14 (#0), }, Punct { ch: '=', spacing: Joint, - span: $DIR/issue-75930-derive-cfg.rs:32:15: 32:17 (#0), + span: $DIR/issue-75930-derive-cfg.rs:31:15: 31:17 (#0), }, Punct { ch: '>', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:32:15: 32:17 (#0), + span: $DIR/issue-75930-derive-cfg.rs:31:15: 31:17 (#0), }, Group { delimiter: Brace, stream: TokenStream [], - span: $DIR/issue-75930-derive-cfg.rs:32:18: 32:20 (#0), + span: $DIR/issue-75930-derive-cfg.rs:31:18: 31:20 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:29:20: 33:10 (#0), + span: $DIR/issue-75930-derive-cfg.rs:28:20: 32:10 (#0), }, Punct { ch: ';', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:33:10: 33:11 (#0), + span: $DIR/issue-75930-derive-cfg.rs:32:10: 32:11 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:35:9: 35:10 (#0), + span: $DIR/issue-75930-derive-cfg.rs:34:9: 34:10 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "print_helper", - span: $DIR/issue-75930-derive-cfg.rs:35:11: 35:23 (#0), + span: $DIR/issue-75930-derive-cfg.rs:34:11: 34:23 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "should_be_removed", - span: $DIR/issue-75930-derive-cfg.rs:35:24: 35:41 (#0), + span: $DIR/issue-75930-derive-cfg.rs:34:24: 34:41 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:35:23: 35:42 (#0), + span: $DIR/issue-75930-derive-cfg.rs:34:23: 34:42 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:35:10: 35:43 (#0), + span: $DIR/issue-75930-derive-cfg.rs:34:10: 34:43 (#0), }, Ident { ident: "fn", - span: $DIR/issue-75930-derive-cfg.rs:36:9: 36:11 (#0), + span: $DIR/issue-75930-derive-cfg.rs:35:9: 35:11 (#0), }, Ident { ident: "removed_fn", - span: $DIR/issue-75930-derive-cfg.rs:36:12: 36:22 (#0), + span: $DIR/issue-75930-derive-cfg.rs:35:12: 35:22 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [], - span: $DIR/issue-75930-derive-cfg.rs:36:22: 36:24 (#0), + span: $DIR/issue-75930-derive-cfg.rs:35:22: 35:24 (#0), }, Group { delimiter: Brace, @@ -655,108 +655,108 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Joint, - span: $DIR/issue-75930-derive-cfg.rs:37:13: 37:14 (#0), + span: $DIR/issue-75930-derive-cfg.rs:36:13: 36:14 (#0), }, Punct { ch: '!', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:37:14: 37:15 (#0), + span: $DIR/issue-75930-derive-cfg.rs:36:14: 36:15 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:37:16: 37:19 (#0), + span: $DIR/issue-75930-derive-cfg.rs:36:16: 36:19 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:37:20: 37:25 (#0), + span: $DIR/issue-75930-derive-cfg.rs:36:20: 36:25 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:37:19: 37:26 (#0), + span: $DIR/issue-75930-derive-cfg.rs:36:19: 36:26 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:37:15: 37:27 (#0), + span: $DIR/issue-75930-derive-cfg.rs:36:15: 36:27 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:36:25: 38:10 (#0), + span: $DIR/issue-75930-derive-cfg.rs:35:25: 37:10 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:40:9: 40:10 (#0), + span: $DIR/issue-75930-derive-cfg.rs:39:9: 39:10 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "print_helper", - span: $DIR/issue-75930-derive-cfg.rs:40:11: 40:23 (#0), + span: $DIR/issue-75930-derive-cfg.rs:39:11: 39:23 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "c", - span: $DIR/issue-75930-derive-cfg.rs:40:24: 40:25 (#0), + span: $DIR/issue-75930-derive-cfg.rs:39:24: 39:25 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:40:23: 40:26 (#0), + span: $DIR/issue-75930-derive-cfg.rs:39:23: 39:26 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:40:10: 40:27 (#0), + span: $DIR/issue-75930-derive-cfg.rs:39:10: 39:27 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:40:28: 40:29 (#0), + span: $DIR/issue-75930-derive-cfg.rs:39:28: 39:29 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:40:30: 40:33 (#0), + span: $DIR/issue-75930-derive-cfg.rs:39:30: 39:33 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "not", - span: $DIR/issue-75930-derive-cfg.rs:40:34: 40:37 (#0), + span: $DIR/issue-75930-derive-cfg.rs:39:34: 39:37 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:40:38: 40:43 (#0), + span: $DIR/issue-75930-derive-cfg.rs:39:38: 39:43 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:40:37: 40:44 (#0), + span: $DIR/issue-75930-derive-cfg.rs:39:37: 39:44 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:40:33: 40:45 (#0), + span: $DIR/issue-75930-derive-cfg.rs:39:33: 39:45 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:40:29: 40:46 (#0), + span: $DIR/issue-75930-derive-cfg.rs:39:29: 39:46 (#0), }, Ident { ident: "fn", - span: $DIR/issue-75930-derive-cfg.rs:40:47: 40:49 (#0), + span: $DIR/issue-75930-derive-cfg.rs:39:47: 39:49 (#0), }, Ident { ident: "kept_fn", - span: $DIR/issue-75930-derive-cfg.rs:40:50: 40:57 (#0), + span: $DIR/issue-75930-derive-cfg.rs:39:50: 39:57 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [], - span: $DIR/issue-75930-derive-cfg.rs:40:57: 40:59 (#0), + span: $DIR/issue-75930-derive-cfg.rs:39:57: 39:59 (#0), }, Group { delimiter: Brace, @@ -764,82 +764,82 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Joint, - span: $DIR/issue-75930-derive-cfg.rs:41:13: 41:14 (#0), + span: $DIR/issue-75930-derive-cfg.rs:40:13: 40:14 (#0), }, Punct { ch: '!', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:41:14: 41:15 (#0), + span: $DIR/issue-75930-derive-cfg.rs:40:14: 40:15 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:41:16: 41:19 (#0), + span: $DIR/issue-75930-derive-cfg.rs:40:16: 40:19 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "not", - span: $DIR/issue-75930-derive-cfg.rs:41:20: 41:23 (#0), + span: $DIR/issue-75930-derive-cfg.rs:40:20: 40:23 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:41:24: 41:29 (#0), + span: $DIR/issue-75930-derive-cfg.rs:40:24: 40:29 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:41:23: 41:30 (#0), + span: $DIR/issue-75930-derive-cfg.rs:40:23: 40:30 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:41:19: 41:31 (#0), + span: $DIR/issue-75930-derive-cfg.rs:40:19: 40:31 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:41:15: 41:32 (#0), + span: $DIR/issue-75930-derive-cfg.rs:40:15: 40:32 (#0), }, Ident { ident: "let", - span: $DIR/issue-75930-derive-cfg.rs:42:13: 42:16 (#0), + span: $DIR/issue-75930-derive-cfg.rs:41:13: 41:16 (#0), }, Ident { ident: "my_val", - span: $DIR/issue-75930-derive-cfg.rs:42:17: 42:23 (#0), + span: $DIR/issue-75930-derive-cfg.rs:41:17: 41:23 (#0), }, Punct { ch: '=', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:42:24: 42:25 (#0), + span: $DIR/issue-75930-derive-cfg.rs:41:24: 41:25 (#0), }, Ident { ident: "true", - span: $DIR/issue-75930-derive-cfg.rs:42:26: 42:30 (#0), + span: $DIR/issue-75930-derive-cfg.rs:41:26: 41:30 (#0), }, Punct { ch: ';', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:42:30: 42:31 (#0), + span: $DIR/issue-75930-derive-cfg.rs:41:30: 41:31 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:40:60: 43:10 (#0), + span: $DIR/issue-75930-derive-cfg.rs:39:60: 42:10 (#0), }, Ident { ident: "enum", - span: $DIR/issue-75930-derive-cfg.rs:45:9: 45:13 (#0), + span: $DIR/issue-75930-derive-cfg.rs:44:9: 44:13 (#0), }, Ident { ident: "TupleEnum", - span: $DIR/issue-75930-derive-cfg.rs:45:14: 45:23 (#0), + span: $DIR/issue-75930-derive-cfg.rs:44:14: 44:23 (#0), }, Group { delimiter: Brace, stream: TokenStream [ Ident { ident: "Foo", - span: $DIR/issue-75930-derive-cfg.rs:46:13: 46:16 (#0), + span: $DIR/issue-75930-derive-cfg.rs:45:13: 45:16 (#0), }, Group { delimiter: Parenthesis, @@ -847,166 +847,166 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:47:17: 47:18 (#0), + span: $DIR/issue-75930-derive-cfg.rs:46:17: 46:18 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:47:19: 47:22 (#0), + span: $DIR/issue-75930-derive-cfg.rs:46:19: 46:22 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:47:23: 47:28 (#0), + span: $DIR/issue-75930-derive-cfg.rs:46:23: 46:28 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:47:22: 47:29 (#0), + span: $DIR/issue-75930-derive-cfg.rs:46:22: 46:29 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:47:18: 47:30 (#0), + span: $DIR/issue-75930-derive-cfg.rs:46:18: 46:30 (#0), }, Ident { ident: "u8", - span: $DIR/issue-75930-derive-cfg.rs:47:31: 47:33 (#0), + span: $DIR/issue-75930-derive-cfg.rs:46:31: 46:33 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:47:33: 47:34 (#0), + span: $DIR/issue-75930-derive-cfg.rs:46:33: 46:34 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:48:17: 48:18 (#0), + span: $DIR/issue-75930-derive-cfg.rs:47:17: 47:18 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:48:19: 48:22 (#0), + span: $DIR/issue-75930-derive-cfg.rs:47:19: 47:22 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:48:23: 48:28 (#0), + span: $DIR/issue-75930-derive-cfg.rs:47:23: 47:28 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:48:22: 48:29 (#0), + span: $DIR/issue-75930-derive-cfg.rs:47:22: 47:29 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:48:18: 48:30 (#0), + span: $DIR/issue-75930-derive-cfg.rs:47:18: 47:30 (#0), }, Ident { ident: "bool", - span: $DIR/issue-75930-derive-cfg.rs:48:31: 48:35 (#0), + span: $DIR/issue-75930-derive-cfg.rs:47:31: 47:35 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:48:35: 48:36 (#0), + span: $DIR/issue-75930-derive-cfg.rs:47:35: 47:36 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:49:17: 49:18 (#0), + span: $DIR/issue-75930-derive-cfg.rs:48:17: 48:18 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:49:19: 49:22 (#0), + span: $DIR/issue-75930-derive-cfg.rs:48:19: 48:22 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "not", - span: $DIR/issue-75930-derive-cfg.rs:49:23: 49:26 (#0), + span: $DIR/issue-75930-derive-cfg.rs:48:23: 48:26 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:49:27: 49:32 (#0), + span: $DIR/issue-75930-derive-cfg.rs:48:27: 48:32 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:49:26: 49:33 (#0), + span: $DIR/issue-75930-derive-cfg.rs:48:26: 48:33 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:49:22: 49:34 (#0), + span: $DIR/issue-75930-derive-cfg.rs:48:22: 48:34 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:49:18: 49:35 (#0), + span: $DIR/issue-75930-derive-cfg.rs:48:18: 48:35 (#0), }, Ident { ident: "i32", - span: $DIR/issue-75930-derive-cfg.rs:49:36: 49:39 (#0), + span: $DIR/issue-75930-derive-cfg.rs:48:36: 48:39 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:49:39: 49:40 (#0), + span: $DIR/issue-75930-derive-cfg.rs:48:39: 48:40 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:50:17: 50:18 (#0), + span: $DIR/issue-75930-derive-cfg.rs:49:17: 49:18 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:50:19: 50:22 (#0), + span: $DIR/issue-75930-derive-cfg.rs:49:19: 49:22 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:50:23: 50:28 (#0), + span: $DIR/issue-75930-derive-cfg.rs:49:23: 49:28 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:50:22: 50:29 (#0), + span: $DIR/issue-75930-derive-cfg.rs:49:22: 49:29 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:50:18: 50:30 (#0), + span: $DIR/issue-75930-derive-cfg.rs:49:18: 49:30 (#0), }, Ident { ident: "String", - span: $DIR/issue-75930-derive-cfg.rs:50:31: 50:37 (#0), + span: $DIR/issue-75930-derive-cfg.rs:49:31: 49:37 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:50:37: 50:38 (#0), + span: $DIR/issue-75930-derive-cfg.rs:49:37: 49:38 (#0), }, Ident { ident: "u8", - span: $DIR/issue-75930-derive-cfg.rs:50:39: 50:41 (#0), + span: $DIR/issue-75930-derive-cfg.rs:49:39: 49:41 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:46:16: 51:14 (#0), + span: $DIR/issue-75930-derive-cfg.rs:45:16: 50:14 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:45:24: 52:10 (#0), + span: $DIR/issue-75930-derive-cfg.rs:44:24: 51:10 (#0), }, Ident { ident: "struct", - span: $DIR/issue-75930-derive-cfg.rs:54:9: 54:15 (#0), + span: $DIR/issue-75930-derive-cfg.rs:53:9: 53:15 (#0), }, Ident { ident: "TupleStruct", - span: $DIR/issue-75930-derive-cfg.rs:54:16: 54:27 (#0), + span: $DIR/issue-75930-derive-cfg.rs:53:16: 53:27 (#0), }, Group { delimiter: Parenthesis, @@ -1014,184 +1014,184 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:55:13: 55:14 (#0), + span: $DIR/issue-75930-derive-cfg.rs:54:13: 54:14 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:55:15: 55:18 (#0), + span: $DIR/issue-75930-derive-cfg.rs:54:15: 54:18 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:55:19: 55:24 (#0), + span: $DIR/issue-75930-derive-cfg.rs:54:19: 54:24 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:55:18: 55:25 (#0), + span: $DIR/issue-75930-derive-cfg.rs:54:18: 54:25 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:55:14: 55:26 (#0), + span: $DIR/issue-75930-derive-cfg.rs:54:14: 54:26 (#0), }, Ident { ident: "String", - span: $DIR/issue-75930-derive-cfg.rs:55:27: 55:33 (#0), + span: $DIR/issue-75930-derive-cfg.rs:54:27: 54:33 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:55:33: 55:34 (#0), + span: $DIR/issue-75930-derive-cfg.rs:54:33: 54:34 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:56:13: 56:14 (#0), + span: $DIR/issue-75930-derive-cfg.rs:55:13: 55:14 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:56:15: 56:18 (#0), + span: $DIR/issue-75930-derive-cfg.rs:55:15: 55:18 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "not", - span: $DIR/issue-75930-derive-cfg.rs:56:19: 56:22 (#0), + span: $DIR/issue-75930-derive-cfg.rs:55:19: 55:22 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:56:23: 56:28 (#0), + span: $DIR/issue-75930-derive-cfg.rs:55:23: 55:28 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:56:22: 56:29 (#0), + span: $DIR/issue-75930-derive-cfg.rs:55:22: 55:29 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:56:18: 56:30 (#0), + span: $DIR/issue-75930-derive-cfg.rs:55:18: 55:30 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:56:14: 56:31 (#0), + span: $DIR/issue-75930-derive-cfg.rs:55:14: 55:31 (#0), }, Ident { ident: "i32", - span: $DIR/issue-75930-derive-cfg.rs:56:32: 56:35 (#0), + span: $DIR/issue-75930-derive-cfg.rs:55:32: 55:35 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:56:35: 56:36 (#0), + span: $DIR/issue-75930-derive-cfg.rs:55:35: 55:36 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:57:13: 57:14 (#0), + span: $DIR/issue-75930-derive-cfg.rs:56:13: 56:14 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:57:15: 57:18 (#0), + span: $DIR/issue-75930-derive-cfg.rs:56:15: 56:18 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:57:19: 57:24 (#0), + span: $DIR/issue-75930-derive-cfg.rs:56:19: 56:24 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:57:18: 57:25 (#0), + span: $DIR/issue-75930-derive-cfg.rs:56:18: 56:25 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:57:14: 57:26 (#0), + span: $DIR/issue-75930-derive-cfg.rs:56:14: 56:26 (#0), }, Ident { ident: "bool", - span: $DIR/issue-75930-derive-cfg.rs:57:27: 57:31 (#0), + span: $DIR/issue-75930-derive-cfg.rs:56:27: 56:31 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:57:31: 57:32 (#0), + span: $DIR/issue-75930-derive-cfg.rs:56:31: 56:32 (#0), }, Ident { ident: "u8", - span: $DIR/issue-75930-derive-cfg.rs:58:13: 58:15 (#0), + span: $DIR/issue-75930-derive-cfg.rs:57:13: 57:15 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:54:27: 59:10 (#0), + span: $DIR/issue-75930-derive-cfg.rs:53:27: 58:10 (#0), }, Punct { ch: ';', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:59:10: 59:11 (#0), + span: $DIR/issue-75930-derive-cfg.rs:58:10: 58:11 (#0), }, Literal { kind: Integer, symbol: "0", suffix: None, - span: $DIR/issue-75930-derive-cfg.rs:61:9: 61:10 (#0), + span: $DIR/issue-75930-derive-cfg.rs:60:9: 60:10 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:25:17: 62:6 (#0), + span: $DIR/issue-75930-derive-cfg.rs:24:17: 61:6 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:25:12: 62:7 (#0), + span: $DIR/issue-75930-derive-cfg.rs:24:12: 61:7 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:62:7: 62:8 (#0), + span: $DIR/issue-75930-derive-cfg.rs:61:7: 61:8 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:63:5: 63:6 (#0), + span: $DIR/issue-75930-derive-cfg.rs:62:5: 62:6 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "print_helper", - span: $DIR/issue-75930-derive-cfg.rs:63:7: 63:19 (#0), + span: $DIR/issue-75930-derive-cfg.rs:62:7: 62:19 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "d", - span: $DIR/issue-75930-derive-cfg.rs:63:20: 63:21 (#0), + span: $DIR/issue-75930-derive-cfg.rs:62:20: 62:21 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:63:19: 63:22 (#0), + span: $DIR/issue-75930-derive-cfg.rs:62:19: 62:22 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:63:6: 63:23 (#0), + span: $DIR/issue-75930-derive-cfg.rs:62:6: 62:23 (#0), }, Ident { ident: "fourth", - span: $DIR/issue-75930-derive-cfg.rs:64:5: 64:11 (#0), + span: $DIR/issue-75930-derive-cfg.rs:63:5: 63:11 (#0), }, Punct { ch: ':', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:64:11: 64:12 (#0), + span: $DIR/issue-75930-derive-cfg.rs:63:11: 63:12 (#0), }, Ident { ident: "B", - span: $DIR/issue-75930-derive-cfg.rs:64:13: 64:14 (#0), + span: $DIR/issue-75930-derive-cfg.rs:63:13: 63:14 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:32: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:32: 64:2 (#0), }, ] PRINT-DERIVE INPUT (DISPLAY): #[allow(dead_code)] #[print_helper(b)] #[print_helper(a)] struct Foo < B > @@ -1211,141 +1211,141 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "allow", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "dead_code", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "print_helper", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "b", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "print_helper", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "a", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "struct", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "Foo", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '<', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "B", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '>', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Brace, stream: TokenStream [ Ident { ident: "second", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ':', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "bool", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "third", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ':', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "u8", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ';', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Brace, @@ -1353,58 +1353,58 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "not", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "struct", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "Inner", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ';', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "match", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "true", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Brace, @@ -1412,146 +1412,146 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "allow", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "warnings", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "false", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '=', spacing: Joint, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '>', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Brace, stream: TokenStream [], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "_", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '=', spacing: Joint, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '>', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Brace, stream: TokenStream [], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ';', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "print_helper", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "c", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "not", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "fn", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "kept_fn", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Brace, @@ -1559,82 +1559,82 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Joint, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '!', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "not", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "let", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "my_val", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '=', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "true", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ';', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "enum", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "TupleEnum", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Brace, stream: TokenStream [ Ident { ident: "Foo", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, @@ -1642,69 +1642,69 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "not", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "i32", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "u8", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "struct", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "TupleStruct", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, @@ -1712,120 +1712,120 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "cfg", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "not", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "FALSE", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "i32", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "u8", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ';', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Literal { kind: Integer, symbol: "0", suffix: None, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: '#', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Bracket, stream: TokenStream [ Ident { ident: "print_helper", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Group { delimiter: Parenthesis, stream: TokenStream [ Ident { ident: "d", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "fourth", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ':', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Ident { ident: "B", - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, Punct { ch: ',', spacing: Alone, - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ], - span: $DIR/issue-75930-derive-cfg.rs:22:1: 65:2 (#0), + span: $DIR/issue-75930-derive-cfg.rs:21:1: 64:2 (#0), }, ] diff --git a/src/test/ui/proc-macro/issue-81543-item-parse-err.rs b/src/test/ui/proc-macro/issue-81543-item-parse-err.rs deleted file mode 100644 index 027389556fe24..0000000000000 --- a/src/test/ui/proc-macro/issue-81543-item-parse-err.rs +++ /dev/null @@ -1,14 +0,0 @@ -// aux-build:test-macros.rs - -// Regression test for issue #81543 -// Tests that we emit a properly spanned error -// when the output of a proc-macro cannot be parsed -// as the expected AST node kind - -extern crate test_macros; - -test_macros::identity! { - fn 32() {} //~ ERROR expected identifier -} - -fn main() {} diff --git a/src/test/ui/proc-macro/issue-81543-item-parse-err.stderr b/src/test/ui/proc-macro/issue-81543-item-parse-err.stderr deleted file mode 100644 index ca524176035b8..0000000000000 --- a/src/test/ui/proc-macro/issue-81543-item-parse-err.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: expected identifier, found `32` - --> $DIR/issue-81543-item-parse-err.rs:11:8 - | -LL | fn 32() {} - | ^^ expected identifier - -error: aborting due to previous error - diff --git a/src/test/ui/proc-macro/lifetimes.stderr b/src/test/ui/proc-macro/lifetimes.stderr index 58f6165388ca1..10acd4304aa23 100644 --- a/src/test/ui/proc-macro/lifetimes.stderr +++ b/src/test/ui/proc-macro/lifetimes.stderr @@ -2,12 +2,7 @@ error: expected type, found `'` --> $DIR/lifetimes.rs:7:10 | LL | type A = single_quote_alone!(); - | ^^^^^^^^^^^^^^^^^^^^^ - | | - | expected type - | this macro call doesn't expand to a type - | - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) + | ^^^^^^^^^^^^^^^^^^^^^ this macro call doesn't expand to a type error: aborting due to previous error diff --git a/src/test/ui/proc-macro/proc-macro-attributes.rs b/src/test/ui/proc-macro/proc-macro-attributes.rs index 8d96381b9bdff..6401522bdf89c 100644 --- a/src/test/ui/proc-macro/proc-macro-attributes.rs +++ b/src/test/ui/proc-macro/proc-macro-attributes.rs @@ -4,18 +4,10 @@ extern crate derive_b; #[B] //~ ERROR `B` is ambiguous - //~| WARN derive helper attribute is used before it is introduced - //~| WARN this was previously accepted #[C] //~ ERROR cannot find attribute `C` in this scope #[B(D)] //~ ERROR `B` is ambiguous - //~| WARN derive helper attribute is used before it is introduced - //~| WARN this was previously accepted #[B(E = "foo")] //~ ERROR `B` is ambiguous - //~| WARN derive helper attribute is used before it is introduced - //~| WARN this was previously accepted #[B(arbitrary tokens)] //~ ERROR `B` is ambiguous - //~| WARN derive helper attribute is used before it is introduced - //~| WARN this was previously accepted #[derive(B)] struct B; diff --git a/src/test/ui/proc-macro/proc-macro-attributes.stderr b/src/test/ui/proc-macro/proc-macro-attributes.stderr index 1ba04258df0d5..3ac93a748523a 100644 --- a/src/test/ui/proc-macro/proc-macro-attributes.stderr +++ b/src/test/ui/proc-macro/proc-macro-attributes.stderr @@ -1,5 +1,5 @@ error: cannot find attribute `C` in this scope - --> $DIR/proc-macro-attributes.rs:9:3 + --> $DIR/proc-macro-attributes.rs:7:3 | LL | #[C] | ^ help: a derive helper attribute with a similar name exists: `B` @@ -11,7 +11,7 @@ LL | #[B] | ^ ambiguous name | note: `B` could refer to the derive helper attribute defined here - --> $DIR/proc-macro-attributes.rs:19:10 + --> $DIR/proc-macro-attributes.rs:11:10 | LL | #[derive(B)] | ^ @@ -22,13 +22,13 @@ LL | #[macro_use] | ^^^^^^^^^^^^ error[E0659]: `B` is ambiguous (derive helper attribute vs any other name) - --> $DIR/proc-macro-attributes.rs:10:3 + --> $DIR/proc-macro-attributes.rs:8:3 | LL | #[B(D)] | ^ ambiguous name | note: `B` could refer to the derive helper attribute defined here - --> $DIR/proc-macro-attributes.rs:19:10 + --> $DIR/proc-macro-attributes.rs:11:10 | LL | #[derive(B)] | ^ @@ -39,13 +39,13 @@ LL | #[macro_use] | ^^^^^^^^^^^^ error[E0659]: `B` is ambiguous (derive helper attribute vs any other name) - --> $DIR/proc-macro-attributes.rs:13:3 + --> $DIR/proc-macro-attributes.rs:9:3 | LL | #[B(E = "foo")] | ^ ambiguous name | note: `B` could refer to the derive helper attribute defined here - --> $DIR/proc-macro-attributes.rs:19:10 + --> $DIR/proc-macro-attributes.rs:11:10 | LL | #[derive(B)] | ^ @@ -56,13 +56,13 @@ LL | #[macro_use] | ^^^^^^^^^^^^ error[E0659]: `B` is ambiguous (derive helper attribute vs any other name) - --> $DIR/proc-macro-attributes.rs:16:3 + --> $DIR/proc-macro-attributes.rs:10:3 | LL | #[B(arbitrary tokens)] | ^ ambiguous name | note: `B` could refer to the derive helper attribute defined here - --> $DIR/proc-macro-attributes.rs:19:10 + --> $DIR/proc-macro-attributes.rs:11:10 | LL | #[derive(B)] | ^ @@ -72,55 +72,6 @@ note: `B` could also refer to the derive macro imported here LL | #[macro_use] | ^^^^^^^^^^^^ -warning: derive helper attribute is used before it is introduced - --> $DIR/proc-macro-attributes.rs:6:3 - | -LL | #[B] - | ^ -... -LL | #[derive(B)] - | - the attribute is introduced here - | - = note: `#[warn(legacy_derive_helpers)]` 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 #79202 - -warning: derive helper attribute is used before it is introduced - --> $DIR/proc-macro-attributes.rs:10:3 - | -LL | #[B(D)] - | ^ -... -LL | #[derive(B)] - | - the attribute is introduced here - | - = 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 #79202 - -warning: derive helper attribute is used before it is introduced - --> $DIR/proc-macro-attributes.rs:13:3 - | -LL | #[B(E = "foo")] - | ^ -... -LL | #[derive(B)] - | - the attribute is introduced here - | - = 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 #79202 - -warning: derive helper attribute is used before it is introduced - --> $DIR/proc-macro-attributes.rs:16:3 - | -LL | #[B(arbitrary tokens)] - | ^ -... -LL | #[derive(B)] - | - the attribute is introduced here - | - = 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 #79202 - -error: aborting due to 5 previous errors; 4 warnings emitted +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0659`. diff --git a/src/test/ui/proc-macro/reserved-macro-names.rs b/src/test/ui/proc-macro/reserved-macro-names.rs index c5e71a87dfbe8..9f56eccb7a61c 100644 --- a/src/test/ui/proc-macro/reserved-macro-names.rs +++ b/src/test/ui/proc-macro/reserved-macro-names.rs @@ -17,3 +17,9 @@ pub fn cfg_attr(_: TokenStream, input: TokenStream) -> TokenStream { //~^ ERROR name `cfg_attr` is reserved in attribute namespace input } + +#[proc_macro_attribute] +pub fn derive(_: TokenStream, input: TokenStream) -> TokenStream { + //~^ ERROR name `derive` is reserved in attribute namespace + input +} diff --git a/src/test/ui/proc-macro/reserved-macro-names.stderr b/src/test/ui/proc-macro/reserved-macro-names.stderr index 39bdd03be863a..f871e43ce51df 100644 --- a/src/test/ui/proc-macro/reserved-macro-names.stderr +++ b/src/test/ui/proc-macro/reserved-macro-names.stderr @@ -10,5 +10,11 @@ error: name `cfg_attr` is reserved in attribute namespace LL | pub fn cfg_attr(_: TokenStream, input: TokenStream) -> TokenStream { | ^^^^^^^^ -error: aborting due to 2 previous errors +error: name `derive` is reserved in attribute namespace + --> $DIR/reserved-macro-names.rs:22:8 + | +LL | pub fn derive(_: TokenStream, input: TokenStream) -> TokenStream { + | ^^^^^^ + +error: aborting due to 3 previous errors diff --git a/src/test/ui/range/range_traits-1.rs b/src/test/ui/range/range_traits-1.rs index e28e47435c2c2..4f57c32e913e1 100644 --- a/src/test/ui/range/range_traits-1.rs +++ b/src/test/ui/range/range_traits-1.rs @@ -4,21 +4,45 @@ use std::ops::*; struct AllTheRanges { a: Range, //~^ ERROR can't compare + //~| ERROR can't compare + //~| ERROR can't compare + //~| ERROR can't compare + //~| ERROR can't compare //~| ERROR Ord b: RangeTo, //~^ ERROR can't compare + //~| ERROR can't compare + //~| ERROR can't compare + //~| ERROR can't compare + //~| ERROR can't compare //~| ERROR Ord c: RangeFrom, //~^ ERROR can't compare + //~| ERROR can't compare + //~| ERROR can't compare + //~| ERROR can't compare + //~| ERROR can't compare //~| ERROR Ord d: RangeFull, //~^ ERROR can't compare + //~| ERROR can't compare + //~| ERROR can't compare + //~| ERROR can't compare + //~| ERROR can't compare //~| ERROR Ord e: RangeInclusive, //~^ ERROR can't compare + //~| ERROR can't compare + //~| ERROR can't compare + //~| ERROR can't compare + //~| ERROR can't compare //~| ERROR Ord f: RangeToInclusive, //~^ ERROR can't compare + //~| ERROR can't compare + //~| ERROR can't compare + //~| ERROR can't compare + //~| ERROR can't compare //~| ERROR Ord } diff --git a/src/test/ui/range/range_traits-1.stderr b/src/test/ui/range/range_traits-1.stderr index e2c1eeb292a7b..165fcd415ce7e 100644 --- a/src/test/ui/range/range_traits-1.stderr +++ b/src/test/ui/range/range_traits-1.stderr @@ -9,7 +9,7 @@ LL | a: Range, = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: can't compare `std::ops::RangeTo` with `std::ops::RangeTo` - --> $DIR/range_traits-1.rs:8:5 + --> $DIR/range_traits-1.rs:12:5 | LL | b: RangeTo, | ^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeTo < std::ops::RangeTo` and `std::ops::RangeTo > std::ops::RangeTo` @@ -19,7 +19,7 @@ LL | b: RangeTo, = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: can't compare `std::ops::RangeFrom` with `std::ops::RangeFrom` - --> $DIR/range_traits-1.rs:11:5 + --> $DIR/range_traits-1.rs:19:5 | LL | c: RangeFrom, | ^^^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeFrom < std::ops::RangeFrom` and `std::ops::RangeFrom > std::ops::RangeFrom` @@ -29,7 +29,7 @@ LL | c: RangeFrom, = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: can't compare `std::ops::RangeFull` with `std::ops::RangeFull` - --> $DIR/range_traits-1.rs:14:5 + --> $DIR/range_traits-1.rs:26:5 | LL | d: RangeFull, | ^^^^^^^^^^^^ no implementation for `std::ops::RangeFull < std::ops::RangeFull` and `std::ops::RangeFull > std::ops::RangeFull` @@ -39,7 +39,7 @@ LL | d: RangeFull, = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: can't compare `std::ops::RangeInclusive` with `std::ops::RangeInclusive` - --> $DIR/range_traits-1.rs:17:5 + --> $DIR/range_traits-1.rs:33:5 | LL | e: RangeInclusive, | ^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeInclusive < std::ops::RangeInclusive` and `std::ops::RangeInclusive > std::ops::RangeInclusive` @@ -49,7 +49,247 @@ LL | e: RangeInclusive, = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: can't compare `std::ops::RangeToInclusive` with `std::ops::RangeToInclusive` - --> $DIR/range_traits-1.rs:20:5 + --> $DIR/range_traits-1.rs:40:5 + | +LL | f: RangeToInclusive, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeToInclusive < std::ops::RangeToInclusive` and `std::ops::RangeToInclusive > std::ops::RangeToInclusive` + | + = help: the trait `PartialOrd` is not implemented for `std::ops::RangeToInclusive` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `std::ops::Range` with `std::ops::Range` + --> $DIR/range_traits-1.rs:5:5 + | +LL | a: Range, + | ^^^^^^^^^^^^^^^ no implementation for `std::ops::Range < std::ops::Range` and `std::ops::Range > std::ops::Range` + | + = help: the trait `PartialOrd` is not implemented for `std::ops::Range` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `std::ops::RangeTo` with `std::ops::RangeTo` + --> $DIR/range_traits-1.rs:12:5 + | +LL | b: RangeTo, + | ^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeTo < std::ops::RangeTo` and `std::ops::RangeTo > std::ops::RangeTo` + | + = help: the trait `PartialOrd` is not implemented for `std::ops::RangeTo` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `std::ops::RangeFrom` with `std::ops::RangeFrom` + --> $DIR/range_traits-1.rs:19:5 + | +LL | c: RangeFrom, + | ^^^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeFrom < std::ops::RangeFrom` and `std::ops::RangeFrom > std::ops::RangeFrom` + | + = help: the trait `PartialOrd` is not implemented for `std::ops::RangeFrom` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `std::ops::RangeFull` with `std::ops::RangeFull` + --> $DIR/range_traits-1.rs:26:5 + | +LL | d: RangeFull, + | ^^^^^^^^^^^^ no implementation for `std::ops::RangeFull < std::ops::RangeFull` and `std::ops::RangeFull > std::ops::RangeFull` + | + = help: the trait `PartialOrd` is not implemented for `std::ops::RangeFull` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `std::ops::RangeInclusive` with `std::ops::RangeInclusive` + --> $DIR/range_traits-1.rs:33:5 + | +LL | e: RangeInclusive, + | ^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeInclusive < std::ops::RangeInclusive` and `std::ops::RangeInclusive > std::ops::RangeInclusive` + | + = help: the trait `PartialOrd` is not implemented for `std::ops::RangeInclusive` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `std::ops::RangeToInclusive` with `std::ops::RangeToInclusive` + --> $DIR/range_traits-1.rs:40:5 + | +LL | f: RangeToInclusive, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeToInclusive < std::ops::RangeToInclusive` and `std::ops::RangeToInclusive > std::ops::RangeToInclusive` + | + = help: the trait `PartialOrd` is not implemented for `std::ops::RangeToInclusive` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `std::ops::Range` with `std::ops::Range` + --> $DIR/range_traits-1.rs:5:5 + | +LL | a: Range, + | ^^^^^^^^^^^^^^^ no implementation for `std::ops::Range < std::ops::Range` and `std::ops::Range > std::ops::Range` + | + = help: the trait `PartialOrd` is not implemented for `std::ops::Range` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `std::ops::RangeTo` with `std::ops::RangeTo` + --> $DIR/range_traits-1.rs:12:5 + | +LL | b: RangeTo, + | ^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeTo < std::ops::RangeTo` and `std::ops::RangeTo > std::ops::RangeTo` + | + = help: the trait `PartialOrd` is not implemented for `std::ops::RangeTo` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `std::ops::RangeFrom` with `std::ops::RangeFrom` + --> $DIR/range_traits-1.rs:19:5 + | +LL | c: RangeFrom, + | ^^^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeFrom < std::ops::RangeFrom` and `std::ops::RangeFrom > std::ops::RangeFrom` + | + = help: the trait `PartialOrd` is not implemented for `std::ops::RangeFrom` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `std::ops::RangeFull` with `std::ops::RangeFull` + --> $DIR/range_traits-1.rs:26:5 + | +LL | d: RangeFull, + | ^^^^^^^^^^^^ no implementation for `std::ops::RangeFull < std::ops::RangeFull` and `std::ops::RangeFull > std::ops::RangeFull` + | + = help: the trait `PartialOrd` is not implemented for `std::ops::RangeFull` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `std::ops::RangeInclusive` with `std::ops::RangeInclusive` + --> $DIR/range_traits-1.rs:33:5 + | +LL | e: RangeInclusive, + | ^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeInclusive < std::ops::RangeInclusive` and `std::ops::RangeInclusive > std::ops::RangeInclusive` + | + = help: the trait `PartialOrd` is not implemented for `std::ops::RangeInclusive` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `std::ops::RangeToInclusive` with `std::ops::RangeToInclusive` + --> $DIR/range_traits-1.rs:40:5 + | +LL | f: RangeToInclusive, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeToInclusive < std::ops::RangeToInclusive` and `std::ops::RangeToInclusive > std::ops::RangeToInclusive` + | + = help: the trait `PartialOrd` is not implemented for `std::ops::RangeToInclusive` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `std::ops::Range` with `std::ops::Range` + --> $DIR/range_traits-1.rs:5:5 + | +LL | a: Range, + | ^^^^^^^^^^^^^^^ no implementation for `std::ops::Range < std::ops::Range` and `std::ops::Range > std::ops::Range` + | + = help: the trait `PartialOrd` is not implemented for `std::ops::Range` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `std::ops::RangeTo` with `std::ops::RangeTo` + --> $DIR/range_traits-1.rs:12:5 + | +LL | b: RangeTo, + | ^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeTo < std::ops::RangeTo` and `std::ops::RangeTo > std::ops::RangeTo` + | + = help: the trait `PartialOrd` is not implemented for `std::ops::RangeTo` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `std::ops::RangeFrom` with `std::ops::RangeFrom` + --> $DIR/range_traits-1.rs:19:5 + | +LL | c: RangeFrom, + | ^^^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeFrom < std::ops::RangeFrom` and `std::ops::RangeFrom > std::ops::RangeFrom` + | + = help: the trait `PartialOrd` is not implemented for `std::ops::RangeFrom` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `std::ops::RangeFull` with `std::ops::RangeFull` + --> $DIR/range_traits-1.rs:26:5 + | +LL | d: RangeFull, + | ^^^^^^^^^^^^ no implementation for `std::ops::RangeFull < std::ops::RangeFull` and `std::ops::RangeFull > std::ops::RangeFull` + | + = help: the trait `PartialOrd` is not implemented for `std::ops::RangeFull` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `std::ops::RangeInclusive` with `std::ops::RangeInclusive` + --> $DIR/range_traits-1.rs:33:5 + | +LL | e: RangeInclusive, + | ^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeInclusive < std::ops::RangeInclusive` and `std::ops::RangeInclusive > std::ops::RangeInclusive` + | + = help: the trait `PartialOrd` is not implemented for `std::ops::RangeInclusive` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `std::ops::RangeToInclusive` with `std::ops::RangeToInclusive` + --> $DIR/range_traits-1.rs:40:5 + | +LL | f: RangeToInclusive, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeToInclusive < std::ops::RangeToInclusive` and `std::ops::RangeToInclusive > std::ops::RangeToInclusive` + | + = help: the trait `PartialOrd` is not implemented for `std::ops::RangeToInclusive` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `std::ops::Range` with `std::ops::Range` + --> $DIR/range_traits-1.rs:5:5 + | +LL | a: Range, + | ^^^^^^^^^^^^^^^ no implementation for `std::ops::Range < std::ops::Range` and `std::ops::Range > std::ops::Range` + | + = help: the trait `PartialOrd` is not implemented for `std::ops::Range` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `std::ops::RangeTo` with `std::ops::RangeTo` + --> $DIR/range_traits-1.rs:12:5 + | +LL | b: RangeTo, + | ^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeTo < std::ops::RangeTo` and `std::ops::RangeTo > std::ops::RangeTo` + | + = help: the trait `PartialOrd` is not implemented for `std::ops::RangeTo` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `std::ops::RangeFrom` with `std::ops::RangeFrom` + --> $DIR/range_traits-1.rs:19:5 + | +LL | c: RangeFrom, + | ^^^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeFrom < std::ops::RangeFrom` and `std::ops::RangeFrom > std::ops::RangeFrom` + | + = help: the trait `PartialOrd` is not implemented for `std::ops::RangeFrom` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `std::ops::RangeFull` with `std::ops::RangeFull` + --> $DIR/range_traits-1.rs:26:5 + | +LL | d: RangeFull, + | ^^^^^^^^^^^^ no implementation for `std::ops::RangeFull < std::ops::RangeFull` and `std::ops::RangeFull > std::ops::RangeFull` + | + = help: the trait `PartialOrd` is not implemented for `std::ops::RangeFull` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `std::ops::RangeInclusive` with `std::ops::RangeInclusive` + --> $DIR/range_traits-1.rs:33:5 + | +LL | e: RangeInclusive, + | ^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeInclusive < std::ops::RangeInclusive` and `std::ops::RangeInclusive > std::ops::RangeInclusive` + | + = help: the trait `PartialOrd` is not implemented for `std::ops::RangeInclusive` + = note: required by `std::cmp::PartialOrd::partial_cmp` + = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: can't compare `std::ops::RangeToInclusive` with `std::ops::RangeToInclusive` + --> $DIR/range_traits-1.rs:40:5 | LL | f: RangeToInclusive, | ^^^^^^^^^^^^^^^^^^^^^^^^^^ no implementation for `std::ops::RangeToInclusive < std::ops::RangeToInclusive` and `std::ops::RangeToInclusive > std::ops::RangeToInclusive` @@ -68,7 +308,7 @@ LL | a: Range, = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `std::ops::RangeTo: Ord` is not satisfied - --> $DIR/range_traits-1.rs:8:5 + --> $DIR/range_traits-1.rs:12:5 | LL | b: RangeTo, | ^^^^^^^^^^^^^^^^^ the trait `Ord` is not implemented for `std::ops::RangeTo` @@ -77,7 +317,7 @@ LL | b: RangeTo, = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `std::ops::RangeFrom: Ord` is not satisfied - --> $DIR/range_traits-1.rs:11:5 + --> $DIR/range_traits-1.rs:19:5 | LL | c: RangeFrom, | ^^^^^^^^^^^^^^^^^^^ the trait `Ord` is not implemented for `std::ops::RangeFrom` @@ -86,7 +326,7 @@ LL | c: RangeFrom, = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `std::ops::RangeFull: Ord` is not satisfied - --> $DIR/range_traits-1.rs:14:5 + --> $DIR/range_traits-1.rs:26:5 | LL | d: RangeFull, | ^^^^^^^^^^^^ the trait `Ord` is not implemented for `std::ops::RangeFull` @@ -95,7 +335,7 @@ LL | d: RangeFull, = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `std::ops::RangeInclusive: Ord` is not satisfied - --> $DIR/range_traits-1.rs:17:5 + --> $DIR/range_traits-1.rs:33:5 | LL | e: RangeInclusive, | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Ord` is not implemented for `std::ops::RangeInclusive` @@ -104,7 +344,7 @@ LL | e: RangeInclusive, = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `std::ops::RangeToInclusive: Ord` is not satisfied - --> $DIR/range_traits-1.rs:20:5 + --> $DIR/range_traits-1.rs:40:5 | LL | f: RangeToInclusive, | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Ord` is not implemented for `std::ops::RangeToInclusive` @@ -112,6 +352,6 @@ LL | f: RangeToInclusive, = note: required by `std::cmp::Ord::cmp` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 12 previous errors +error: aborting due to 36 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/recursion/recursive-types-are-not-uninhabited.stderr b/src/test/ui/recursion/recursive-types-are-not-uninhabited.stderr index dfb69a3cc1b42..c6f500ec8cc78 100644 --- a/src/test/ui/recursion/recursive-types-are-not-uninhabited.stderr +++ b/src/test/ui/recursion/recursive-types-are-not-uninhabited.stderr @@ -11,7 +11,7 @@ LL | Err(#[stable(feature = "rust1", since = "1.0.0")] E), | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html - = note: the matched value is of type `Result` + = note: the matched value is of type `std::result::Result` help: you might want to use `if let` to ignore the variant that isn't matched | LL | if let Ok(x) = res { /* */ } diff --git a/src/test/ui/regions/issue-78262.nll.stderr b/src/test/ui/regions/issue-78262.nll.stderr index fafff35e4155f..4607dbad4220b 100644 --- a/src/test/ui/regions/issue-78262.nll.stderr +++ b/src/test/ui/regions/issue-78262.nll.stderr @@ -8,4 +8,3 @@ LL | let f = |x: &dyn TT| x.func(); error: aborting due to previous error -For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/regions/region-invariant-static-error-reporting.nll.stderr b/src/test/ui/regions/region-invariant-static-error-reporting.nll.stderr index 89a22adc8f021..d941030d82474 100644 --- a/src/test/ui/regions/region-invariant-static-error-reporting.nll.stderr +++ b/src/test/ui/regions/region-invariant-static-error-reporting.nll.stderr @@ -11,4 +11,3 @@ LL | x.unwrap() error: aborting due to previous error -For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.nll.stderr b/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.nll.stderr index ed7b17c207c30..92a3942c916b7 100644 --- a/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.nll.stderr +++ b/src/test/ui/regions/regions-bounded-method-type-parameters-trait-bound.nll.stderr @@ -13,4 +13,3 @@ LL | f.method(b); error: aborting due to previous error -For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/regions/regions-nested-fns.nll.stderr b/src/test/ui/regions/regions-nested-fns.nll.stderr index 60754f4c2284c..9d966486f98d1 100644 --- a/src/test/ui/regions/regions-nested-fns.nll.stderr +++ b/src/test/ui/regions/regions-nested-fns.nll.stderr @@ -50,5 +50,4 @@ LL | if false { return x; } error: aborting due to 4 previous errors -Some errors have detailed explanations: E0521, E0597. -For more information about an error, try `rustc --explain E0521`. +For more information about this error, try `rustc --explain E0597`. diff --git a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr index 4580620186197..d015b72c5cffe 100644 --- a/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr +++ b/src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr @@ -1,4 +1,4 @@ -error[E0277]: `main` has invalid return type `Result` +error[E0277]: `main` has invalid return type `std::result::Result` --> $DIR/termination-trait-test-wrong-type.rs:6:1 | LL | / fn can_parse_zero_as_f32() -> Result { @@ -11,7 +11,7 @@ LL | | } LL | pub fn assert_test_result(result: T) { | ----------- required by this bound in `assert_test_result` | - = help: the trait `Termination` is not implemented for `Result` + = help: the trait `Termination` is not implemented for `std::result::Result` = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/rfc-2294-if-let-guard/typeck.stderr b/src/test/ui/rfc-2294-if-let-guard/typeck.stderr index 6407128d8d877..7ce93fe7348fd 100644 --- a/src/test/ui/rfc-2294-if-let-guard/typeck.stderr +++ b/src/test/ui/rfc-2294-if-let-guard/typeck.stderr @@ -2,10 +2,10 @@ error[E0308]: mismatched types --> $DIR/typeck.rs:10:22 | LL | Ok(x) if let Err(_) = x => {}, - | ^^^^^^ expected enum `Option`, found enum `Result` + | ^^^^^^ expected enum `Option`, found enum `std::result::Result` | = note: expected enum `Option` - found enum `Result<_, _>` + found enum `std::result::Result<_, _>` error[E0308]: mismatched types --> $DIR/typeck.rs:12:22 diff --git a/src/test/ui/simd-intrinsic/simd-intrinsic-generic-elements.rs b/src/test/ui/simd-intrinsic/simd-intrinsic-generic-elements.rs index 493cd7a477c7a..5929d05f4de31 100644 --- a/src/test/ui/simd-intrinsic/simd-intrinsic-generic-elements.rs +++ b/src/test/ui/simd-intrinsic/simd-intrinsic-generic-elements.rs @@ -9,6 +9,10 @@ struct i32x2(i32, i32); #[repr(simd)] #[derive(Copy, Clone)] #[allow(non_camel_case_types)] +struct i32x3(i32, i32, i32); +#[repr(simd)] +#[derive(Copy, Clone)] +#[allow(non_camel_case_types)] struct i32x4(i32, i32, i32, i32); #[repr(simd)] #[derive(Copy, Clone)] @@ -23,6 +27,10 @@ struct f32x2(f32, f32); #[repr(simd)] #[derive(Copy, Clone)] #[allow(non_camel_case_types)] +struct f32x3(f32, f32, f32); +#[repr(simd)] +#[derive(Copy, Clone)] +#[allow(non_camel_case_types)] struct f32x4(f32, f32, f32, f32); #[repr(simd)] #[derive(Copy, Clone)] @@ -35,6 +43,7 @@ extern "platform-intrinsic" { fn simd_extract(x: T, idx: u32) -> E; fn simd_shuffle2(x: T, y: T, idx: [u32; 2]) -> U; + fn simd_shuffle3(x: T, y: T, idx: [u32; 3]) -> U; fn simd_shuffle4(x: T, y: T, idx: [u32; 4]) -> U; fn simd_shuffle8(x: T, y: T, idx: [u32; 8]) -> U; } @@ -52,6 +61,8 @@ fn main() { simd_shuffle2::(0, 0, [0; 2]); //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_shuffle3::(0, 0, [0; 3]); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` simd_shuffle4::(0, 0, [0; 4]); //~^ ERROR expected SIMD input type, found non-SIMD `i32` simd_shuffle8::(0, 0, [0; 8]); @@ -59,6 +70,8 @@ fn main() { simd_shuffle2::<_, f32x2>(x, x, [0; 2]); //~^ ERROR element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32` + simd_shuffle3::<_, f32x3>(x, x, [0; 3]); +//~^ ERROR element type `i32` (element of input `i32x4`), found `f32x3` with element type `f32` simd_shuffle4::<_, f32x4>(x, x, [0; 4]); //~^ ERROR element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32` simd_shuffle8::<_, f32x8>(x, x, [0; 8]); @@ -66,8 +79,10 @@ fn main() { simd_shuffle2::<_, i32x8>(x, x, [0; 2]); //~^ ERROR expected return type of length 2, found `i32x8` with length 8 - simd_shuffle4::<_, i32x8>(x, x, [0; 4]); - //~^ ERROR expected return type of length 4, found `i32x8` with length 8 + simd_shuffle3::<_, i32x4>(x, x, [0; 3]); + //~^ ERROR expected return type of length 3, found `i32x4` with length 4 + simd_shuffle4::<_, i32x3>(x, x, [0; 4]); + //~^ ERROR expected return type of length 4, found `i32x3` with length 3 simd_shuffle8::<_, i32x2>(x, x, [0; 8]); //~^ ERROR expected return type of length 8, found `i32x2` with length 2 } diff --git a/src/test/ui/simd-intrinsic/simd-intrinsic-generic-elements.stderr b/src/test/ui/simd-intrinsic/simd-intrinsic-generic-elements.stderr index 703e64d1ddcc8..78022c0c8bd98 100644 --- a/src/test/ui/simd-intrinsic/simd-intrinsic-generic-elements.stderr +++ b/src/test/ui/simd-intrinsic/simd-intrinsic-generic-elements.stderr @@ -1,75 +1,93 @@ error[E0511]: invalid monomorphization of `simd_insert` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/simd-intrinsic-generic-elements.rs:46:9 + --> $DIR/simd-intrinsic-generic-elements.rs:55:9 | LL | simd_insert(0, 0, 0); | ^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_insert` intrinsic: expected inserted type `i32` (element of input `i32x4`), found `f64` - --> $DIR/simd-intrinsic-generic-elements.rs:48:9 + --> $DIR/simd-intrinsic-generic-elements.rs:57:9 | LL | simd_insert(x, 0, 1.0); | ^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_extract` intrinsic: expected return type `i32` (element of input `i32x4`), found `f32` - --> $DIR/simd-intrinsic-generic-elements.rs:50:9 + --> $DIR/simd-intrinsic-generic-elements.rs:59:9 | LL | simd_extract::<_, f32>(x, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle2` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/simd-intrinsic-generic-elements.rs:53:9 + --> $DIR/simd-intrinsic-generic-elements.rs:62:9 | LL | simd_shuffle2::(0, 0, [0; 2]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0511]: invalid monomorphization of `simd_shuffle3` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/simd-intrinsic-generic-elements.rs:64:9 + | +LL | simd_shuffle3::(0, 0, [0; 3]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error[E0511]: invalid monomorphization of `simd_shuffle4` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/simd-intrinsic-generic-elements.rs:55:9 + --> $DIR/simd-intrinsic-generic-elements.rs:66:9 | LL | simd_shuffle4::(0, 0, [0; 4]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle8` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/simd-intrinsic-generic-elements.rs:57:9 + --> $DIR/simd-intrinsic-generic-elements.rs:68:9 | LL | simd_shuffle8::(0, 0, [0; 8]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle2` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32` - --> $DIR/simd-intrinsic-generic-elements.rs:60:9 + --> $DIR/simd-intrinsic-generic-elements.rs:71:9 | LL | simd_shuffle2::<_, f32x2>(x, x, [0; 2]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0511]: invalid monomorphization of `simd_shuffle3` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x3` with element type `f32` + --> $DIR/simd-intrinsic-generic-elements.rs:73:9 + | +LL | simd_shuffle3::<_, f32x3>(x, x, [0; 3]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error[E0511]: invalid monomorphization of `simd_shuffle4` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32` - --> $DIR/simd-intrinsic-generic-elements.rs:62:9 + --> $DIR/simd-intrinsic-generic-elements.rs:75:9 | LL | simd_shuffle4::<_, f32x4>(x, x, [0; 4]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle8` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32` - --> $DIR/simd-intrinsic-generic-elements.rs:64:9 + --> $DIR/simd-intrinsic-generic-elements.rs:77:9 | LL | simd_shuffle8::<_, f32x8>(x, x, [0; 8]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle2` intrinsic: expected return type of length 2, found `i32x8` with length 8 - --> $DIR/simd-intrinsic-generic-elements.rs:67:9 + --> $DIR/simd-intrinsic-generic-elements.rs:80:9 | LL | simd_shuffle2::<_, i32x8>(x, x, [0; 2]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `simd_shuffle4` intrinsic: expected return type of length 4, found `i32x8` with length 8 - --> $DIR/simd-intrinsic-generic-elements.rs:69:9 +error[E0511]: invalid monomorphization of `simd_shuffle3` intrinsic: expected return type of length 3, found `i32x4` with length 4 + --> $DIR/simd-intrinsic-generic-elements.rs:82:9 | -LL | simd_shuffle4::<_, i32x8>(x, x, [0; 4]); +LL | simd_shuffle3::<_, i32x4>(x, x, [0; 3]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle4` intrinsic: expected return type of length 4, found `i32x3` with length 3 + --> $DIR/simd-intrinsic-generic-elements.rs:84:9 + | +LL | simd_shuffle4::<_, i32x3>(x, x, [0; 4]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle8` intrinsic: expected return type of length 8, found `i32x2` with length 2 - --> $DIR/simd-intrinsic-generic-elements.rs:71:9 + --> $DIR/simd-intrinsic-generic-elements.rs:86:9 | LL | simd_shuffle8::<_, i32x2>(x, x, [0; 8]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 12 previous errors +error: aborting due to 15 previous errors For more information about this error, try `rustc --explain E0511`. diff --git a/src/test/ui/simd/simd-type-generic-monomorphisation.rs b/src/test/ui/simd-type-generic-monomorphisation.rs similarity index 100% rename from src/test/ui/simd/simd-type-generic-monomorphisation.rs rename to src/test/ui/simd-type-generic-monomorphisation.rs diff --git a/src/test/ui/simd/simd-type-generic-monomorphisation.stderr b/src/test/ui/simd-type-generic-monomorphisation.stderr similarity index 100% rename from src/test/ui/simd/simd-type-generic-monomorphisation.stderr rename to src/test/ui/simd-type-generic-monomorphisation.stderr diff --git a/src/test/ui/simd-type.rs b/src/test/ui/simd-type.rs new file mode 100644 index 0000000000000..a320df85138e5 --- /dev/null +++ b/src/test/ui/simd-type.rs @@ -0,0 +1,20 @@ +#![feature(repr_simd)] +#![allow(non_camel_case_types)] + +// ignore-tidy-linelength + +#[repr(simd)] +struct empty; //~ ERROR SIMD vector cannot be empty + +#[repr(simd)] +struct i64f64(i64, f64); //~ ERROR SIMD vector should be homogeneous + +struct Foo; + +#[repr(simd)] +struct FooV(Foo, Foo); //~ ERROR SIMD vector element type should be a primitive scalar (integer/float/pointer) type + +#[repr(simd)] +struct FooV2([Foo; 2]); //~ ERROR SIMD vector element type should be a primitive scalar (integer/float/pointer) type + +fn main() {} diff --git a/src/test/ui/simd/simd-type.stderr b/src/test/ui/simd-type.stderr similarity index 57% rename from src/test/ui/simd/simd-type.stderr rename to src/test/ui/simd-type.stderr index 8b15ef05e032b..23004c785918c 100644 --- a/src/test/ui/simd/simd-type.stderr +++ b/src/test/ui/simd-type.stderr @@ -4,43 +4,25 @@ error[E0075]: SIMD vector cannot be empty LL | struct empty; | ^^^^^^^^^^^^^ -error[E0075]: SIMD vector cannot be empty - --> $DIR/simd-type.rs:10:1 - | -LL | struct empty2([f32; 0]); - | ^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0075]: SIMD vector length must be a power of two - --> $DIR/simd-type.rs:13:1 - | -LL | struct pow2([f32; 7]); - | ^^^^^^^^^^^^^^^^^^^^^^ - error[E0076]: SIMD vector should be homogeneous - --> $DIR/simd-type.rs:16:1 + --> $DIR/simd-type.rs:10:1 | LL | struct i64f64(i64, f64); | ^^^^^^^^^^^^^^^^^^^^^^^^ SIMD elements must have the same type error[E0077]: SIMD vector element type should be a primitive scalar (integer/float/pointer) type - --> $DIR/simd-type.rs:21:1 + --> $DIR/simd-type.rs:15:1 | LL | struct FooV(Foo, Foo); | ^^^^^^^^^^^^^^^^^^^^^^ error[E0077]: SIMD vector element type should be a primitive scalar (integer/float/pointer) type - --> $DIR/simd-type.rs:24:1 + --> $DIR/simd-type.rs:18:1 | LL | struct FooV2([Foo; 2]); | ^^^^^^^^^^^^^^^^^^^^^^^ -error[E0075]: SIMD vector cannot have more than 32768 elements - --> $DIR/simd-type.rs:27:1 - | -LL | struct TooBig([f32; 65536]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 7 previous errors +error: aborting due to 4 previous errors Some errors have detailed explanations: E0075, E0076, E0077. For more information about an error, try `rustc --explain E0075`. diff --git a/src/test/ui/simd/issue-17170.stderr b/src/test/ui/simd/issue-17170.stderr deleted file mode 100644 index b35c3c4dc980d..0000000000000 --- a/src/test/ui/simd/issue-17170.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0075]: SIMD vector length must be a power of two - --> $DIR/issue-17170.rs:4:1 - | -LL | struct T(f64, f64, f64); - | ^^^^^^^^^^^^^^^^^^^^^^^^ - -error: monomorphising SIMD type `T` of non-power-of-two length - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0075`. diff --git a/src/test/ui/simd/issue-39720.stderr b/src/test/ui/simd/issue-39720.stderr deleted file mode 100644 index 355ceff00508a..0000000000000 --- a/src/test/ui/simd/issue-39720.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0075]: SIMD vector length must be a power of two - --> $DIR/issue-39720.rs:7:1 - | -LL | pub struct Char3(pub i8, pub i8, pub i8); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0075]: SIMD vector length must be a power of two - --> $DIR/issue-39720.rs:12:1 - | -LL | pub struct Short3(pub i16, pub i16, pub i16); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0075`. diff --git a/src/test/ui/simd/simd-intrinsic-generic-elements.rs b/src/test/ui/simd/simd-intrinsic-generic-elements.rs index a85ec7c58235b..ea3d4b1894416 100644 --- a/src/test/ui/simd/simd-intrinsic-generic-elements.rs +++ b/src/test/ui/simd/simd-intrinsic-generic-elements.rs @@ -10,6 +10,10 @@ struct i32x2(i32, i32); #[repr(simd)] #[derive(Copy, Clone, Debug, PartialEq)] #[allow(non_camel_case_types)] +struct i32x3(i32, i32, i32); +#[repr(simd)] +#[derive(Copy, Clone, Debug, PartialEq)] +#[allow(non_camel_case_types)] struct i32x4(i32, i32, i32, i32); #[repr(simd)] #[derive(Copy, Clone, Debug, PartialEq)] @@ -22,6 +26,7 @@ extern "platform-intrinsic" { fn simd_extract(x: T, idx: u32) -> E; fn simd_shuffle2(x: T, y: T, idx: [u32; 2]) -> U; + fn simd_shuffle3(x: T, y: T, idx: [u32; 3]) -> U; fn simd_shuffle4(x: T, y: T, idx: [u32; 4]) -> U; fn simd_shuffle8(x: T, y: T, idx: [u32; 8]) -> U; } @@ -40,12 +45,17 @@ macro_rules! all_eq { fn main() { let x2 = i32x2(20, 21); + let x3 = i32x3(30, 31, 32); let x4 = i32x4(40, 41, 42, 43); let x8 = i32x8(80, 81, 82, 83, 84, 85, 86, 87); unsafe { all_eq!(simd_insert(x2, 0, 100), i32x2(100, 21)); all_eq!(simd_insert(x2, 1, 100), i32x2(20, 100)); + all_eq!(simd_insert(x3, 0, 100), i32x3(100, 31, 32)); + all_eq!(simd_insert(x3, 1, 100), i32x3(30, 100, 32)); + all_eq!(simd_insert(x3, 2, 100), i32x3(30, 31, 100)); + all_eq!(simd_insert(x4, 0, 100), i32x4(100, 41, 42, 43)); all_eq!(simd_insert(x4, 1, 100), i32x4(40, 100, 42, 43)); all_eq!(simd_insert(x4, 2, 100), i32x4(40, 41, 100, 43)); @@ -63,6 +73,10 @@ fn main() { all_eq!(simd_extract(x2, 0), 20); all_eq!(simd_extract(x2, 1), 21); + all_eq!(simd_extract(x3, 0), 30); + all_eq!(simd_extract(x3, 1), 31); + all_eq!(simd_extract(x3, 2), 32); + all_eq!(simd_extract(x4, 0), 40); all_eq!(simd_extract(x4, 1), 41); all_eq!(simd_extract(x4, 2), 42); @@ -79,20 +93,30 @@ fn main() { } let y2 = i32x2(120, 121); + let y3 = i32x3(130, 131, 132); let y4 = i32x4(140, 141, 142, 143); let y8 = i32x8(180, 181, 182, 183, 184, 185, 186, 187); unsafe { all_eq!(simd_shuffle2(x2, y2, [3, 0]), i32x2(121, 20)); + all_eq!(simd_shuffle3(x2, y2, [3, 0, 1]), i32x3(121, 20, 21)); all_eq!(simd_shuffle4(x2, y2, [3, 0, 1, 2]), i32x4(121, 20, 21, 120)); all_eq!(simd_shuffle8(x2, y2, [3, 0, 1, 2, 1, 2, 3, 0]), i32x8(121, 20, 21, 120, 21, 120, 121, 20)); + all_eq!(simd_shuffle2(x3, y3, [4, 2]), i32x2(131, 32)); + all_eq!(simd_shuffle3(x3, y3, [4, 2, 3]), i32x3(131, 32, 130)); + all_eq!(simd_shuffle4(x3, y3, [4, 2, 3, 0]), i32x4(131, 32, 130, 30)); + all_eq!(simd_shuffle8(x3, y3, [4, 2, 3, 0, 1, 5, 5, 1]), + i32x8(131, 32, 130, 30, 31, 132, 132, 31)); + all_eq!(simd_shuffle2(x4, y4, [7, 2]), i32x2(143, 42)); + all_eq!(simd_shuffle3(x4, y4, [7, 2, 5]), i32x3(143, 42, 141)); all_eq!(simd_shuffle4(x4, y4, [7, 2, 5, 0]), i32x4(143, 42, 141, 40)); all_eq!(simd_shuffle8(x4, y4, [7, 2, 5, 0, 3, 6, 4, 1]), i32x8(143, 42, 141, 40, 43, 142, 140, 41)); all_eq!(simd_shuffle2(x8, y8, [11, 5]), i32x2(183, 85)); + all_eq!(simd_shuffle3(x8, y8, [11, 5, 15]), i32x3(183, 85, 187)); all_eq!(simd_shuffle4(x8, y8, [11, 5, 15, 0]), i32x4(183, 85, 187, 80)); all_eq!(simd_shuffle8(x8, y8, [11, 5, 15, 0, 3, 8, 12, 1]), i32x8(183, 85, 187, 80, 83, 180, 184, 81)); diff --git a/src/test/ui/simd/simd-size-align.rs b/src/test/ui/simd/simd-size-align.rs index 0afa4947225d3..556013788c335 100644 --- a/src/test/ui/simd/simd-size-align.rs +++ b/src/test/ui/simd/simd-size-align.rs @@ -10,44 +10,87 @@ use std::mem; /// `T` should satisfy `size_of T (mod min_align_of T) === 0` to be stored at `Vec` properly /// Please consult the issue #20460 fn check() { - assert_eq!(mem::size_of::() % mem::min_align_of::(), 0); - assert_eq!(mem::size_of::() % mem::min_align_of::(), 0); - assert_eq!(mem::size_of::() % mem::min_align_of::(), 0); + assert_eq!(mem::size_of::() % mem::min_align_of::(), 0) } -#[repr(simd)] -struct U8([u8; N]); +fn main() { + check::(); + check::(); + check::(); + check::(); + check::(); + check::(); + check::(); -#[repr(simd)] -struct I16([i16; N]); + check::(); + check::(); + check::(); + check::(); + check::(); + check::(); + check::(); -#[repr(simd)] -struct F32([f32; N]); + check::(); + check::(); + check::(); + check::(); + check::(); + check::(); + check::(); -#[repr(simd)] -struct Usize([usize; N]); + check::(); + check::(); + check::(); + check::(); + check::(); + check::(); + check::(); -#[repr(simd)] -struct Isize([isize; N]); + check::(); + check::(); + check::(); + check::(); + check::(); + check::(); + check::(); +} -fn main() { - check::>(); - check::>(); - check::>(); +#[repr(simd)] struct u8x2(u8, u8); +#[repr(simd)] struct u8x3(u8, u8, u8); +#[repr(simd)] struct u8x4(u8, u8, u8, u8); +#[repr(simd)] struct u8x5(u8, u8, u8, u8, u8); +#[repr(simd)] struct u8x6(u8, u8, u8, u8, u8, u8); +#[repr(simd)] struct u8x7(u8, u8, u8, u8, u8, u8, u8); +#[repr(simd)] struct u8x8(u8, u8, u8, u8, u8, u8, u8, u8); - check::>(); - check::>(); - check::>(); +#[repr(simd)] struct i16x2(i16, i16); +#[repr(simd)] struct i16x3(i16, i16, i16); +#[repr(simd)] struct i16x4(i16, i16, i16, i16); +#[repr(simd)] struct i16x5(i16, i16, i16, i16, i16); +#[repr(simd)] struct i16x6(i16, i16, i16, i16, i16, i16); +#[repr(simd)] struct i16x7(i16, i16, i16, i16, i16, i16, i16); +#[repr(simd)] struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16); - check::>(); - check::>(); - check::>(); +#[repr(simd)] struct f32x2(f32, f32); +#[repr(simd)] struct f32x3(f32, f32, f32); +#[repr(simd)] struct f32x4(f32, f32, f32, f32); +#[repr(simd)] struct f32x5(f32, f32, f32, f32, f32); +#[repr(simd)] struct f32x6(f32, f32, f32, f32, f32, f32); +#[repr(simd)] struct f32x7(f32, f32, f32, f32, f32, f32, f32); +#[repr(simd)] struct f32x8(f32, f32, f32, f32, f32, f32, f32, f32); - check::>(); - check::>(); - check::>(); +#[repr(simd)] struct usizex2(usize, usize); +#[repr(simd)] struct usizex3(usize, usize, usize); +#[repr(simd)] struct usizex4(usize, usize, usize, usize); +#[repr(simd)] struct usizex5(usize, usize, usize, usize, usize); +#[repr(simd)] struct usizex6(usize, usize, usize, usize, usize, usize); +#[repr(simd)] struct usizex7(usize, usize, usize, usize, usize, usize, usize); +#[repr(simd)] struct usizex8(usize, usize, usize, usize, usize, usize, usize, usize); - check::>(); - check::>(); - check::>(); -} +#[repr(simd)] struct isizex2(isize, isize); +#[repr(simd)] struct isizex3(isize, isize, isize); +#[repr(simd)] struct isizex4(isize, isize, isize, isize); +#[repr(simd)] struct isizex5(isize, isize, isize, isize, isize); +#[repr(simd)] struct isizex6(isize, isize, isize, isize, isize, isize); +#[repr(simd)] struct isizex7(isize, isize, isize, isize, isize, isize, isize); +#[repr(simd)] struct isizex8(isize, isize, isize, isize, isize, isize, isize, isize); diff --git a/src/test/ui/simd/simd-type-generic-monomorphisation-empty.rs b/src/test/ui/simd/simd-type-generic-monomorphisation-empty.rs deleted file mode 100644 index 0121404c74935..0000000000000 --- a/src/test/ui/simd/simd-type-generic-monomorphisation-empty.rs +++ /dev/null @@ -1,12 +0,0 @@ -// build-fail - -#![feature(repr_simd, platform_intrinsics)] - -// error-pattern:monomorphising SIMD type `Simd<0_usize>` of zero length - -#[repr(simd)] -struct Simd([f32; N]); - -fn main() { - let _ = Simd::<0>([]); -} diff --git a/src/test/ui/simd/simd-type-generic-monomorphisation-empty.stderr b/src/test/ui/simd/simd-type-generic-monomorphisation-empty.stderr deleted file mode 100644 index 00fde199b12a2..0000000000000 --- a/src/test/ui/simd/simd-type-generic-monomorphisation-empty.stderr +++ /dev/null @@ -1,4 +0,0 @@ -error: monomorphising SIMD type `Simd<0_usize>` of zero length - -error: aborting due to previous error - diff --git a/src/test/ui/simd/simd-type-generic-monomorphisation-oversized.rs b/src/test/ui/simd/simd-type-generic-monomorphisation-oversized.rs deleted file mode 100644 index bd0d457b35e27..0000000000000 --- a/src/test/ui/simd/simd-type-generic-monomorphisation-oversized.rs +++ /dev/null @@ -1,12 +0,0 @@ -// build-fail - -#![feature(repr_simd, platform_intrinsics)] - -// error-pattern:monomorphising SIMD type `Simd<65536_usize>` of length greater than 32768 - -#[repr(simd)] -struct Simd([f32; N]); - -fn main() { - let _ = Simd::<65536>([0.; 65536]); -} diff --git a/src/test/ui/simd/simd-type-generic-monomorphisation-oversized.stderr b/src/test/ui/simd/simd-type-generic-monomorphisation-oversized.stderr deleted file mode 100644 index f441835011532..0000000000000 --- a/src/test/ui/simd/simd-type-generic-monomorphisation-oversized.stderr +++ /dev/null @@ -1,4 +0,0 @@ -error: monomorphising SIMD type `Simd<65536_usize>` of length greater than 32768 - -error: aborting due to previous error - diff --git a/src/test/ui/simd/simd-type-generic-monomorphisation-power-of-two.rs b/src/test/ui/simd/simd-type-generic-monomorphisation-power-of-two.rs deleted file mode 100644 index 3a0b9e02663d8..0000000000000 --- a/src/test/ui/simd/simd-type-generic-monomorphisation-power-of-two.rs +++ /dev/null @@ -1,12 +0,0 @@ -// build-fail - -#![feature(repr_simd, platform_intrinsics)] - -// error-pattern:monomorphising SIMD type `Simd<3_usize>` of non-power-of-two length - -#[repr(simd)] -struct Simd([f32; N]); - -fn main() { - let _ = Simd::<3>([0.; 3]); -} diff --git a/src/test/ui/simd/simd-type-generic-monomorphisation-power-of-two.stderr b/src/test/ui/simd/simd-type-generic-monomorphisation-power-of-two.stderr deleted file mode 100644 index 82cc0d8714aba..0000000000000 --- a/src/test/ui/simd/simd-type-generic-monomorphisation-power-of-two.stderr +++ /dev/null @@ -1,4 +0,0 @@ -error: monomorphising SIMD type `Simd<3_usize>` of non-power-of-two length - -error: aborting due to previous error - diff --git a/src/test/ui/simd/simd-type.rs b/src/test/ui/simd/simd-type.rs index cc7443d04856c..e7b9bfe32f8df 100644 --- a/src/test/ui/simd/simd-type.rs +++ b/src/test/ui/simd/simd-type.rs @@ -1,33 +1,9 @@ -#![feature(repr_simd)] -#![allow(non_camel_case_types)] - -// ignore-tidy-linelength - -#[repr(simd)] -struct empty; //~ ERROR SIMD vector cannot be empty - -#[repr(simd)] -struct empty2([f32; 0]); //~ ERROR SIMD vector cannot be empty - -#[repr(simd)] -struct pow2([f32; 7]); //~ ERROR SIMD vector length must be a power of two - -#[repr(simd)] -struct i64f64(i64, f64); //~ ERROR SIMD vector should be homogeneous - -struct Foo; +// run-pass +#![allow(dead_code)] -#[repr(simd)] -struct FooV(Foo, Foo); //~ ERROR SIMD vector element type should be a primitive scalar (integer/float/pointer) type - -#[repr(simd)] -struct FooV2([Foo; 2]); //~ ERROR SIMD vector element type should be a primitive scalar (integer/float/pointer) type +// pretty-expanded FIXME #23616 -#[repr(simd)] -struct TooBig([f32; 65536]); //~ ERROR SIMD vector cannot have more than 32768 elements - -#[repr(simd)] -struct JustRight([u128; 32768]); +#![feature(repr_simd)] #[repr(simd)] struct RGBA { @@ -37,4 +13,4 @@ struct RGBA { a: f32 } -fn main() {} +pub fn main() {} diff --git a/src/test/ui/span/impl-wrong-item-for-trait.stderr b/src/test/ui/span/impl-wrong-item-for-trait.stderr index de200ca0721ca..9b0aad28b0a33 100644 --- a/src/test/ui/span/impl-wrong-item-for-trait.stderr +++ b/src/test/ui/span/impl-wrong-item-for-trait.stderr @@ -64,7 +64,7 @@ error[E0046]: not all trait items implemented, missing: `fmt` LL | impl Debug for FooTypeForMethod { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `fmt` in implementation | - = help: implement the missing item: `fn fmt(&self, _: &mut Formatter<'_>) -> Result<(), std::fmt::Error> { todo!() }` + = help: implement the missing item: `fn fmt(&self, _: &mut Formatter<'_>) -> std::result::Result<(), std::fmt::Error> { todo!() }` error: aborting due to 8 previous errors diff --git a/src/test/ui/span/issue-43927-non-ADT-derive.rs b/src/test/ui/span/issue-43927-non-ADT-derive.rs index 840c12e16e1c8..8f1599a5abcb0 100644 --- a/src/test/ui/span/issue-43927-non-ADT-derive.rs +++ b/src/test/ui/span/issue-43927-non-ADT-derive.rs @@ -1,5 +1,10 @@ +#![allow(dead_code)] + #![derive(Debug, PartialEq, Eq)] // should be an outer attribute! -//~^ ERROR cannot determine resolution for the attribute macro `derive` +//~^ ERROR `derive` may only be applied to structs, enums and unions +//~| ERROR cannot determine resolution for the derive macro `Debug` +//~| ERROR cannot determine resolution for the derive macro `PartialEq` +//~| ERROR cannot determine resolution for the derive macro `Eq` struct DerivedOn; fn main() {} diff --git a/src/test/ui/span/issue-43927-non-ADT-derive.stderr b/src/test/ui/span/issue-43927-non-ADT-derive.stderr index 9ef81c5150a45..85beac535c965 100644 --- a/src/test/ui/span/issue-43927-non-ADT-derive.stderr +++ b/src/test/ui/span/issue-43927-non-ADT-derive.stderr @@ -1,10 +1,33 @@ -error: cannot determine resolution for the attribute macro `derive` - --> $DIR/issue-43927-non-ADT-derive.rs:1:4 +error[E0774]: `derive` may only be applied to structs, enums and unions + --> $DIR/issue-43927-non-ADT-derive.rs:3:1 | LL | #![derive(Debug, PartialEq, Eq)] // should be an outer attribute! - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try an outer attribute: `#[derive(Debug, PartialEq, Eq)]` + +error: cannot determine resolution for the derive macro `Debug` + --> $DIR/issue-43927-non-ADT-derive.rs:3:11 + | +LL | #![derive(Debug, PartialEq, Eq)] // should be an outer attribute! + | ^^^^^ + | + = note: import resolution is stuck, try simplifying macro imports + +error: cannot determine resolution for the derive macro `PartialEq` + --> $DIR/issue-43927-non-ADT-derive.rs:3:18 + | +LL | #![derive(Debug, PartialEq, Eq)] // should be an outer attribute! + | ^^^^^^^^^ + | + = note: import resolution is stuck, try simplifying macro imports + +error: cannot determine resolution for the derive macro `Eq` + --> $DIR/issue-43927-non-ADT-derive.rs:3:29 + | +LL | #![derive(Debug, PartialEq, Eq)] // should be an outer attribute! + | ^^ | = note: import resolution is stuck, try simplifying macro imports -error: aborting due to previous error +error: aborting due to 4 previous errors +For more information about this error, try `rustc --explain E0774`. diff --git a/src/test/ui/span/macro-ty-params.rs b/src/test/ui/span/macro-ty-params.rs index 0a93105b66477..713b9eb542cfa 100644 --- a/src/test/ui/span/macro-ty-params.rs +++ b/src/test/ui/span/macro-ty-params.rs @@ -9,5 +9,5 @@ macro_rules! foo { () => () } fn main() { foo::!(); //~ ERROR generic arguments in macro path foo::<>!(); //~ ERROR generic arguments in macro path - m!(Default<>); //~ ERROR unexpected generic arguments in path + m!(Default<>); //~ ERROR generic arguments in macro path } diff --git a/src/test/ui/span/macro-ty-params.stderr b/src/test/ui/span/macro-ty-params.stderr index 138cd2598a1c5..21683b2fb8643 100644 --- a/src/test/ui/span/macro-ty-params.stderr +++ b/src/test/ui/span/macro-ty-params.stderr @@ -10,7 +10,7 @@ error: generic arguments in macro path LL | foo::<>!(); | ^^ -error: unexpected generic arguments in path +error: generic arguments in macro path --> $DIR/macro-ty-params.rs:12:15 | LL | m!(Default<>); diff --git a/src/test/ui/stability-attribute/stability-attribute-sanity.stderr b/src/test/ui/stability-attribute/stability-attribute-sanity.stderr index 151b96b8b5a66..ee9a93359f032 100644 --- a/src/test/ui/stability-attribute/stability-attribute-sanity.stderr +++ b/src/test/ui/stability-attribute/stability-attribute-sanity.stderr @@ -116,5 +116,5 @@ LL | #[rustc_deprecated(since = "a", reason = "text")] error: aborting due to 19 previous errors -Some errors have detailed explanations: E0539, E0541, E0542, E0546, E0550. +Some errors have detailed explanations: E0539, E0541, E0546, E0550. For more information about an error, try `rustc --explain E0539`. diff --git a/src/test/ui/suggestions/adt-param-with-implicit-sized-bound.stderr b/src/test/ui/suggestions/adt-param-with-implicit-sized-bound.stderr index 9437fbe61cc7e..9450612332caa 100644 --- a/src/test/ui/suggestions/adt-param-with-implicit-sized-bound.stderr +++ b/src/test/ui/suggestions/adt-param-with-implicit-sized-bound.stderr @@ -13,7 +13,7 @@ help: you could relax the implicit `Sized` bound on `T` if it were used through --> $DIR/adt-param-with-implicit-sized-bound.rs:18:10 | LL | struct X(T); - | ^ - ...if indirection were used here: `Box` + | ^ - ...if indirection was used here: `Box` | | | this could be changed to `T: ?Sized`... @@ -68,7 +68,7 @@ help: you could relax the implicit `Sized` bound on `T` if it were used through LL | struct Struct3{ | ^ this could be changed to `T: ?Sized`... LL | _t: T, - | - ...if indirection were used here: `Box` + | - ...if indirection was used here: `Box` help: consider further restricting `Self` | LL | fn func3() -> Struct3 where Self: Sized; diff --git a/src/test/ui/suggestions/as-ref.stderr b/src/test/ui/suggestions/as-ref.stderr index 7e4d7fb3933d3..4b5a9be7e5b4d 100644 --- a/src/test/ui/suggestions/as-ref.stderr +++ b/src/test/ui/suggestions/as-ref.stderr @@ -47,12 +47,12 @@ error[E0308]: mismatched types --> $DIR/as-ref.rs:19:35 | LL | let y: Result<&usize, &usize> = x; - | ---------------------- ^ expected enum `Result`, found reference + | ---------------------- ^ expected enum `std::result::Result`, found reference | | | expected due to this | - = note: expected enum `Result<&usize, &usize>` - found reference `&Result` + = note: expected enum `std::result::Result<&usize, &usize>` + found reference `&std::result::Result` help: you can convert from `&Result` to `Result<&T, &E>` using `.as_ref()` | LL | let y: Result<&usize, &usize> = x.as_ref(); @@ -62,12 +62,12 @@ error[E0308]: mismatched types --> $DIR/as-ref.rs:23:34 | LL | let y: Result<&usize, usize> = x; - | --------------------- ^ expected enum `Result`, found reference + | --------------------- ^ expected enum `std::result::Result`, found reference | | | expected due to this | - = note: expected enum `Result<&usize, usize>` - found reference `&Result` + = note: expected enum `std::result::Result<&usize, usize>` + found reference `&std::result::Result` error: aborting due to 7 previous errors diff --git a/src/test/ui/suggestions/field-access.fixed b/src/test/ui/suggestions/field-access.fixed index ed9aef6e37444..05a4a0eb1266d 100644 --- a/src/test/ui/suggestions/field-access.fixed +++ b/src/test/ui/suggestions/field-access.fixed @@ -18,17 +18,17 @@ union Foo { fn main() { let a = A { b: B::Fst }; if let B::Fst = a.b {}; //~ ERROR mismatched types [E0308] - //~^ HELP you might have meant to use field `b` whose type is `B` + //~^ HELP you might have meant to use field `b` of type `B` match a.b { - //~^ HELP you might have meant to use field `b` whose type is `B` - //~| HELP you might have meant to use field `b` whose type is `B` + //~^ HELP you might have meant to use field `b` of type `B` + //~| HELP you might have meant to use field `b` of type `B` B::Fst => (), //~ ERROR mismatched types [E0308] B::Snd => (), //~ ERROR mismatched types [E0308] } let foo = Foo { bar: 42 }; match unsafe { foo.bar } { - //~^ HELP you might have meant to use field `bar` whose type is `u32` + //~^ HELP you might have meant to use field `bar` of type `u32` 1u32 => (), //~ ERROR mismatched types [E0308] _ => (), } diff --git a/src/test/ui/suggestions/field-access.rs b/src/test/ui/suggestions/field-access.rs index d80488e8a45f5..ad23c0ffa2e74 100644 --- a/src/test/ui/suggestions/field-access.rs +++ b/src/test/ui/suggestions/field-access.rs @@ -18,17 +18,17 @@ union Foo { fn main() { let a = A { b: B::Fst }; if let B::Fst = a {}; //~ ERROR mismatched types [E0308] - //~^ HELP you might have meant to use field `b` whose type is `B` + //~^ HELP you might have meant to use field `b` of type `B` match a { - //~^ HELP you might have meant to use field `b` whose type is `B` - //~| HELP you might have meant to use field `b` whose type is `B` + //~^ HELP you might have meant to use field `b` of type `B` + //~| HELP you might have meant to use field `b` of type `B` B::Fst => (), //~ ERROR mismatched types [E0308] B::Snd => (), //~ ERROR mismatched types [E0308] } let foo = Foo { bar: 42 }; match foo { - //~^ HELP you might have meant to use field `bar` whose type is `u32` + //~^ HELP you might have meant to use field `bar` of type `u32` 1u32 => (), //~ ERROR mismatched types [E0308] _ => (), } diff --git a/src/test/ui/suggestions/field-access.stderr b/src/test/ui/suggestions/field-access.stderr index b113b3746d87e..aad9872032a2a 100644 --- a/src/test/ui/suggestions/field-access.stderr +++ b/src/test/ui/suggestions/field-access.stderr @@ -9,7 +9,7 @@ LL | if let B::Fst = a {}; | | | expected struct `A`, found enum `B` | -help: you might have meant to use field `b` whose type is `B` +help: you might have meant to use field `b` of type `B` | LL | if let B::Fst = a.b {}; | ^^^ @@ -26,7 +26,7 @@ LL | match a { LL | B::Fst => (), | ^^^^^^ expected struct `A`, found enum `B` | -help: you might have meant to use field `b` whose type is `B` +help: you might have meant to use field `b` of type `B` | LL | match a.b { | ^^^ @@ -43,7 +43,7 @@ LL | match a { LL | B::Snd => (), | ^^^^^^ expected struct `A`, found enum `B` | -help: you might have meant to use field `b` whose type is `B` +help: you might have meant to use field `b` of type `B` | LL | match a.b { | ^^^ @@ -57,7 +57,7 @@ LL | LL | 1u32 => (), | ^^^^ expected union `Foo`, found `u32` | -help: you might have meant to use field `bar` whose type is `u32` +help: you might have meant to use field `bar` of type `u32` | LL | match unsafe { foo.bar } { | ^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.nll.stderr b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.nll.stderr index 6c235ae8f0277..697467dc3a630 100644 --- a/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.nll.stderr +++ b/src/test/ui/suggestions/impl-on-dyn-trait-with-implicit-static-bound.nll.stderr @@ -40,4 +40,3 @@ LL | MyTrait::use_self(val) error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0521`. diff --git a/src/test/ui/suggestions/mut-ref-reassignment.stderr b/src/test/ui/suggestions/mut-ref-reassignment.stderr index 327bbee1968bf..e31c4dc66c805 100644 --- a/src/test/ui/suggestions/mut-ref-reassignment.stderr +++ b/src/test/ui/suggestions/mut-ref-reassignment.stderr @@ -17,7 +17,7 @@ error[E0308]: mismatched types LL | opt = None | ^^^^ expected mutable reference, found enum `Option` | - = note: expected mutable reference `&mut Result` + = note: expected mutable reference `&mut std::result::Result` found enum `Option<_>` error[E0308]: mismatched types diff --git a/src/test/ui/suggestions/non-existent-field-present-in-subfield.fixed b/src/test/ui/suggestions/non-existent-field-present-in-subfield.fixed index e58b4e6ca4d6f..167548a89defa 100644 --- a/src/test/ui/suggestions/non-existent-field-present-in-subfield.fixed +++ b/src/test/ui/suggestions/non-existent-field-present-in-subfield.fixed @@ -3,7 +3,7 @@ struct Foo { first: Bar, _second: u32, - _third: Vec, + _third: u32, } struct Bar { @@ -32,7 +32,7 @@ fn main() { let d = D { test: e }; let c = C { c: d }; let bar = Bar { bar: c }; - let fooer = Foo { first: bar, _second: 4, _third: Vec::new() }; + let fooer = Foo { first: bar, _second: 4, _third: 5 }; let _test = &fooer.first.bar.c; //~^ ERROR no field diff --git a/src/test/ui/suggestions/non-existent-field-present-in-subfield.rs b/src/test/ui/suggestions/non-existent-field-present-in-subfield.rs index 7e273ac23d8c3..81cc1af4dff52 100644 --- a/src/test/ui/suggestions/non-existent-field-present-in-subfield.rs +++ b/src/test/ui/suggestions/non-existent-field-present-in-subfield.rs @@ -3,7 +3,7 @@ struct Foo { first: Bar, _second: u32, - _third: Vec, + _third: u32, } struct Bar { @@ -32,7 +32,7 @@ fn main() { let d = D { test: e }; let c = C { c: d }; let bar = Bar { bar: c }; - let fooer = Foo { first: bar, _second: 4, _third: Vec::new() }; + let fooer = Foo { first: bar, _second: 4, _third: 5 }; let _test = &fooer.c; //~^ ERROR no field diff --git a/src/test/ui/suggestions/option-content-move.stderr b/src/test/ui/suggestions/option-content-move.stderr index c00a0f1700bb4..0f3dd346e856a 100644 --- a/src/test/ui/suggestions/option-content-move.stderr +++ b/src/test/ui/suggestions/option-content-move.stderr @@ -13,7 +13,7 @@ error[E0507]: cannot move out of `selection.1` which is behind a shared referenc LL | if selection.1.unwrap().contains(selection.0) { | ^^^^^^^^^^^ | | - | move occurs because `selection.1` has type `Result`, which does not implement the `Copy` trait + | move occurs because `selection.1` has type `std::result::Result`, which does not implement the `Copy` trait | help: consider borrowing the `Result`'s content: `selection.1.as_ref()` error: aborting due to 2 previous errors diff --git a/src/test/ui/suggestions/suggest-box.stderr b/src/test/ui/suggestions/suggest-box.stderr index 8107fd862122a..57c83baf4f831 100644 --- a/src/test/ui/suggestions/suggest-box.stderr +++ b/src/test/ui/suggestions/suggest-box.stderr @@ -10,7 +10,7 @@ LL | | Ok(()) LL | | }; | |_____^ expected struct `Box`, found closure | - = note: expected struct `Box Result<(), ()>>` + = note: expected struct `Box std::result::Result<(), ()>>` found closure `[closure@$DIR/suggest-box.rs:4:47: 7:6]` = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html help: store this in the heap by calling `Box::new` diff --git a/src/test/ui/test-attrs/test-filter-multiple.rs b/src/test/ui/test-attrs/test-filter-multiple.rs deleted file mode 100644 index 04dd83b7fd0f7..0000000000000 --- a/src/test/ui/test-attrs/test-filter-multiple.rs +++ /dev/null @@ -1,17 +0,0 @@ -// run-pass -// compile-flags: --test -// run-flags: --test-threads=1 test1 test2 -// check-run-results -// normalize-stdout-test "finished in \d+\.\d+s" -> "finished in $$TIME" -// ignore-emscripten no threads support - -#[test] -fn test1() {} - -#[test] -fn test2() {} - -#[test] -fn test3() { - panic!("this should not run"); -} diff --git a/src/test/ui/test-attrs/test-filter-multiple.run.stdout b/src/test/ui/test-attrs/test-filter-multiple.run.stdout deleted file mode 100644 index 1aa684ed5073a..0000000000000 --- a/src/test/ui/test-attrs/test-filter-multiple.run.stdout +++ /dev/null @@ -1,7 +0,0 @@ - -running 2 tests -test test1 ... ok -test test2 ... ok - -test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 1 filtered out; finished in $TIME - diff --git a/src/test/ui/traits/self-without-lifetime-constraint.stderr b/src/test/ui/traits/self-without-lifetime-constraint.stderr index 73b5aec022c60..6c7abe753e2bf 100644 --- a/src/test/ui/traits/self-without-lifetime-constraint.stderr +++ b/src/test/ui/traits/self-without-lifetime-constraint.stderr @@ -2,13 +2,13 @@ error: `impl` item signature doesn't match `trait` item signature --> $DIR/self-without-lifetime-constraint.rs:45:5 | LL | fn column_result(value: ValueRef<'_>) -> FromSqlResult; - | -------------------------------------------------------------------- expected `fn(ValueRef<'_>) -> Result<(&str, &&str), FromSqlError>` + | -------------------------------------------------------------------- expected `fn(ValueRef<'_>) -> std::result::Result<(&str, &&str), FromSqlError>` ... LL | fn column_result(value: ValueRef<'_>) -> FromSqlResult<&str, &&str> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(ValueRef<'_>) -> Result<(&str, &&str), FromSqlError>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(ValueRef<'_>) -> std::result::Result<(&str, &&str), FromSqlError>` | - = note: expected `fn(ValueRef<'_>) -> Result<(&str, &&str), _>` - found `fn(ValueRef<'_>) -> Result<(&str, &&str), _>` + = note: expected `fn(ValueRef<'_>) -> std::result::Result<(&str, &&str), _>` + found `fn(ValueRef<'_>) -> std::result::Result<(&str, &&str), _>` help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait` --> $DIR/self-without-lifetime-constraint.rs:41:60 | diff --git a/src/test/ui/treat-err-as-bug/delay_span_bug.rs b/src/test/ui/treat-err-as-bug/delay_span_bug.rs deleted file mode 100644 index 67846336acaaf..0000000000000 --- a/src/test/ui/treat-err-as-bug/delay_span_bug.rs +++ /dev/null @@ -1,11 +0,0 @@ -// compile-flags: -Ztreat-err-as-bug -// failure-status: 101 -// error-pattern: aborting due to `-Z treat-err-as-bug=1` -// error-pattern: [trigger_delay_span_bug] trigger a delay span bug -// normalize-stderr-test "note: .*\n\n" -> "" -// normalize-stderr-test "thread 'rustc' panicked.*\n" -> "" - -#![feature(rustc_attrs)] - -#[rustc_error(delay_span_bug_from_inside_query)] -fn main() {} diff --git a/src/test/ui/treat-err-as-bug/delay_span_bug.stderr b/src/test/ui/treat-err-as-bug/delay_span_bug.stderr deleted file mode 100644 index ed65b69ebcab1..0000000000000 --- a/src/test/ui/treat-err-as-bug/delay_span_bug.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: internal compiler error: delayed span bug triggered by #[rustc_error(delay_span_bug_from_inside_query)] - --> $DIR/delay_span_bug.rs:11:1 - | -LL | fn main() {} - | ^^^^^^^^^ - -error: internal compiler error: unexpected panic - -query stack during panic: -#0 [trigger_delay_span_bug] trigger a delay span bug -end of query stack diff --git a/src/test/ui/treat-err-as-bug/err.rs b/src/test/ui/treat-err-as-bug/err.rs deleted file mode 100644 index 5442d8585941b..0000000000000 --- a/src/test/ui/treat-err-as-bug/err.rs +++ /dev/null @@ -1,11 +0,0 @@ -// compile-flags: -Ztreat-err-as-bug -// failure-status: 101 -// error-pattern: aborting due to `-Z treat-err-as-bug=1` -// error-pattern: [eval_to_allocation_raw] const-evaluating + checking `C` -// normalize-stderr-test "note: .*\n\n" -> "" -// normalize-stderr-test "thread 'rustc' panicked.*\n" -> "" - -#![crate_type = "rlib"] - -pub static C: u32 = 0 - 1; -//~^ ERROR could not evaluate static initializer diff --git a/src/test/ui/treat-err-as-bug/err.stderr b/src/test/ui/treat-err-as-bug/err.stderr deleted file mode 100644 index 61eb85c40a112..0000000000000 --- a/src/test/ui/treat-err-as-bug/err.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0080]: could not evaluate static initializer - --> $DIR/err.rs:10:21 - | -LL | pub static C: u32 = 0 - 1; - | ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow - -error: internal compiler error: unexpected panic - -query stack during panic: -#0 [eval_to_allocation_raw] const-evaluating + checking `C` -#1 [eval_to_allocation_raw] const-evaluating + checking `C` -end of query stack diff --git a/src/test/ui/try-block/try-block-bad-type.stderr b/src/test/ui/try-block/try-block-bad-type.stderr index 2d1313d7d0e31..cadf3a841c961 100644 --- a/src/test/ui/try-block/try-block-bad-type.stderr +++ b/src/test/ui/try-block/try-block-bad-type.stderr @@ -13,13 +13,13 @@ LL | Err("")?; and 2 others = note: required by `from` -error[E0271]: type mismatch resolving ` as Try>::Ok == &str` +error[E0271]: type mismatch resolving ` as Try>::Ok == &str` --> $DIR/try-block-bad-type.rs:12:9 | LL | "" | ^^ expected `i32`, found `&str` -error[E0271]: type mismatch resolving ` as Try>::Ok == ()` +error[E0271]: type mismatch resolving ` as Try>::Ok == ()` --> $DIR/try-block-bad-type.rs:15:39 | LL | let res: Result = try { }; diff --git a/src/test/ui/typeck/issue-80207-unsized-return.rs b/src/test/ui/typeck/issue-80207-unsized-return.rs deleted file mode 100644 index 75430da148239..0000000000000 --- a/src/test/ui/typeck/issue-80207-unsized-return.rs +++ /dev/null @@ -1,20 +0,0 @@ -// check-pass - -trait Foo { - fn do_stuff() -> Self; -} - -trait Bar { - type Output; -} - -impl Foo for dyn Bar -where - Self: Sized, -{ - fn do_stuff() -> Self { - todo!() - } -} - -fn main() {} diff --git a/src/test/ui/uninhabited/uninhabited-matches-feature-gated.stderr b/src/test/ui/uninhabited/uninhabited-matches-feature-gated.stderr index 4f2f9e070fe52..7b999f507739b 100644 --- a/src/test/ui/uninhabited/uninhabited-matches-feature-gated.stderr +++ b/src/test/ui/uninhabited/uninhabited-matches-feature-gated.stderr @@ -10,7 +10,7 @@ LL | Err(#[stable(feature = "rust1", since = "1.0.0")] E), | --- not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `Result` + = note: the matched value is of type `std::result::Result` error[E0004]: non-exhaustive patterns: type `&Void` is non-empty --> $DIR/uninhabited-matches-feature-gated.rs:15:19 @@ -64,7 +64,7 @@ LL | Err(#[stable(feature = "rust1", since = "1.0.0")] E), | --- not covered | = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms - = note: the matched value is of type `Result` + = note: the matched value is of type `std::result::Result` error[E0005]: refutable pattern in local binding: `Err(_)` not covered --> $DIR/uninhabited-matches-feature-gated.rs:37:9 @@ -79,7 +79,7 @@ LL | Err(#[stable(feature = "rust1", since = "1.0.0")] E), | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html - = note: the matched value is of type `Result` + = note: the matched value is of type `std::result::Result` help: you might want to use `if let` to ignore the variant that isn't matched | LL | if let Ok(x) = x { /* */ } diff --git a/src/test/ui/unsized/unchanged-param.rs b/src/test/ui/unsized/unchanged-param.rs deleted file mode 100644 index 83199e8112e71..0000000000000 --- a/src/test/ui/unsized/unchanged-param.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![feature(relaxed_struct_unsize)] -// run-pass -// Test that we allow unsizing even if there is an unchanged param in the -// field getting unsized. -struct A(T, B); -struct B(T, U); - -fn main() { - let x: A<[u32; 1], [u32; 1]> = A([0; 1], B([0; 1], [0; 1])); - let y: &A<[u32; 1], [u32]> = &x; - assert_eq!(y.1.1.len(), 1); -} diff --git a/src/test/ui/unsized/unsized-enum.stderr b/src/test/ui/unsized/unsized-enum.stderr index 3057d4789bd81..795c7beab0ac6 100644 --- a/src/test/ui/unsized/unsized-enum.stderr +++ b/src/test/ui/unsized/unsized-enum.stderr @@ -13,7 +13,7 @@ help: you could relax the implicit `Sized` bound on `U` if it were used through --> $DIR/unsized-enum.rs:4:10 | LL | enum Foo { FooSome(U), FooNone } - | ^ - ...if indirection were used here: `Box` + | ^ - ...if indirection was used here: `Box` | | | this could be changed to `U: ?Sized`... diff --git a/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr b/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr index 9d8a1c67734a4..9efebe3aeff70 100644 --- a/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr +++ b/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr @@ -13,7 +13,7 @@ help: you could relax the implicit `Sized` bound on `Y` if it were used through --> $DIR/unsized-inherent-impl-self-type.rs:5:11 | LL | struct S5(Y); - | ^ - ...if indirection were used here: `Box` + | ^ - ...if indirection was used here: `Box` | | | this could be changed to `Y: ?Sized`... diff --git a/src/test/ui/unsized/unsized-struct.stderr b/src/test/ui/unsized/unsized-struct.stderr index 6661cf358b3ab..e013b8fc69ece 100644 --- a/src/test/ui/unsized/unsized-struct.stderr +++ b/src/test/ui/unsized/unsized-struct.stderr @@ -13,7 +13,7 @@ help: you could relax the implicit `Sized` bound on `T` if it were used through --> $DIR/unsized-struct.rs:4:12 | LL | struct Foo { data: T } - | ^ - ...if indirection were used here: `Box` + | ^ - ...if indirection was used here: `Box` | | | this could be changed to `T: ?Sized`... diff --git a/src/test/ui/unsized/unsized-trait-impl-self-type.stderr b/src/test/ui/unsized/unsized-trait-impl-self-type.stderr index d1b590d813307..516c750cb342e 100644 --- a/src/test/ui/unsized/unsized-trait-impl-self-type.stderr +++ b/src/test/ui/unsized/unsized-trait-impl-self-type.stderr @@ -13,7 +13,7 @@ help: you could relax the implicit `Sized` bound on `Y` if it were used through --> $DIR/unsized-trait-impl-self-type.rs:8:11 | LL | struct S5(Y); - | ^ - ...if indirection were used here: `Box` + | ^ - ...if indirection was used here: `Box` | | | this could be changed to `Y: ?Sized`... diff --git a/src/test/ui/unsupported-cast.rs b/src/test/ui/unsupported-cast.rs new file mode 100644 index 0000000000000..cb6a57a4d39d5 --- /dev/null +++ b/src/test/ui/unsupported-cast.rs @@ -0,0 +1,7 @@ +// error-pattern:casting + +struct A; + +fn main() { + println!("{:?}", 1.0 as *const A); // Can't cast float to foreign. +} diff --git a/src/test/ui/cast/unsupported-cast.stderr b/src/test/ui/unsupported-cast.stderr similarity index 65% rename from src/test/ui/cast/unsupported-cast.stderr rename to src/test/ui/unsupported-cast.stderr index 56a375a1d942a..63e7713d2f4e7 100644 --- a/src/test/ui/cast/unsupported-cast.stderr +++ b/src/test/ui/unsupported-cast.stderr @@ -1,7 +1,7 @@ error[E0606]: casting `f64` as `*const A` is invalid - --> $DIR/unsupported-cast.rs:4:20 + --> $DIR/unsupported-cast.rs:6:20 | -LL | println!("{:?}", 1.0 as *const A); +LL | println!("{:?}", 1.0 as *const A); // Can't cast float to foreign. | ^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/unused-crate-deps/extern-loc-bad-loctype.rs b/src/test/ui/unused-crate-deps/extern-loc-bad-loctype.rs deleted file mode 100644 index 3e1527e2c2e71..0000000000000 --- a/src/test/ui/unused-crate-deps/extern-loc-bad-loctype.rs +++ /dev/null @@ -1,8 +0,0 @@ -// --extern-location with bad location type - -// aux-crate:bar=bar.rs -// compile-flags:--extern-location bar=badloc:in-the-test-file - -#![warn(unused_crate_dependencies)] - -fn main() {} diff --git a/src/test/ui/unused-crate-deps/extern-loc-bad-loctype.stderr b/src/test/ui/unused-crate-deps/extern-loc-bad-loctype.stderr deleted file mode 100644 index 12378f12557b7..0000000000000 --- a/src/test/ui/unused-crate-deps/extern-loc-bad-loctype.stderr +++ /dev/null @@ -1,2 +0,0 @@ -error: unknown location type `badloc`: use `raw` or `json` - diff --git a/src/test/ui/unused-crate-deps/extern-loc-defl-json.rs b/src/test/ui/unused-crate-deps/extern-loc-defl-json.rs deleted file mode 100644 index a023f535b8198..0000000000000 --- a/src/test/ui/unused-crate-deps/extern-loc-defl-json.rs +++ /dev/null @@ -1,10 +0,0 @@ -// Default extern location from name and path if one isn't specified - -// check-pass -// aux-crate:bar=bar.rs -// compile-flags:--error-format json - -#![warn(unused_crate_dependencies)] -//~^ WARNING external crate `bar` unused in - -fn main() {} diff --git a/src/test/ui/unused-crate-deps/extern-loc-defl-json.stderr b/src/test/ui/unused-crate-deps/extern-loc-defl-json.stderr deleted file mode 100644 index cee3f6c1495c7..0000000000000 --- a/src/test/ui/unused-crate-deps/extern-loc-defl-json.stderr +++ /dev/null @@ -1,17 +0,0 @@ -{"message":"external crate `bar` unused in `extern_loc_defl_json`: remove the dependency or add `use bar as _;`","code":{"code":"unused_crate_dependencies","explanation":null},"level":"warning","spans":[{"file_name":"$DIR/extern-loc-defl-json.rs","byte_start":146,"byte_end":146,"line_start":7,"line_end":7,"column_start":1,"column_end":1,"is_primary":true,"text":[{"text":"#![warn(unused_crate_dependencies)]","highlight_start":1,"highlight_end":1}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"the lint level is defined here","code":null,"level":"note","spans":[{"file_name":"$DIR/extern-loc-defl-json.rs","byte_start":154,"byte_end":179,"line_start":7,"line_end":7,"column_start":9,"column_end":34,"is_primary":true,"text":[{"text":"#![warn(unused_crate_dependencies)]","highlight_start":9,"highlight_end":34}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"remove unnecessary dependency `bar`","code":null,"level":"help","spans":[],"children":[],"rendered":null},{"message":"json extern location","code":null,"level":"help","spans":[],"children":[],"rendered":null,"tool_metadata":{"name":"bar"}}],"rendered":"warning: external crate `bar` unused in `extern_loc_defl_json`: remove the dependency or add `use bar as _;` - --> $DIR/extern-loc-defl-json.rs:7:1 - | -LL | #![warn(unused_crate_dependencies)] - | ^ - | -note: the lint level is defined here - --> $DIR/extern-loc-defl-json.rs:7:9 - | -LL | #![warn(unused_crate_dependencies)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: remove unnecessary dependency `bar` - -"} -{"message":"1 warning emitted","code":null,"level":"warning","spans":[],"children":[],"rendered":"warning: 1 warning emitted - -"} diff --git a/src/test/ui/unused-crate-deps/extern-loc-json-bad-json.rs b/src/test/ui/unused-crate-deps/extern-loc-json-bad-json.rs deleted file mode 100644 index 6fdf710a1268d..0000000000000 --- a/src/test/ui/unused-crate-deps/extern-loc-json-bad-json.rs +++ /dev/null @@ -1,8 +0,0 @@ -// --extern-location with a raw reference - -// aux-crate:bar=bar.rs -// compile-flags:--extern-location bar=json:[{"malformed - -#![warn(unused_crate_dependencies)] - -fn main() {} diff --git a/src/test/ui/unused-crate-deps/extern-loc-json-bad-json.stderr b/src/test/ui/unused-crate-deps/extern-loc-json-bad-json.stderr deleted file mode 100644 index 20d606372e027..0000000000000 --- a/src/test/ui/unused-crate-deps/extern-loc-json-bad-json.stderr +++ /dev/null @@ -1,2 +0,0 @@ -error: `--extern-location`: malformed json location `[{"malformed` - diff --git a/src/test/ui/unused-crate-deps/extern-loc-json-json.rs b/src/test/ui/unused-crate-deps/extern-loc-json-json.rs deleted file mode 100644 index 02a9869151f32..0000000000000 --- a/src/test/ui/unused-crate-deps/extern-loc-json-json.rs +++ /dev/null @@ -1,10 +0,0 @@ -// --extern-location with a raw reference - -// check-pass -// aux-crate:bar=bar.rs -// compile-flags:--extern-location bar=json:{"key":123,"value":{}} --error-format json - -#![warn(unused_crate_dependencies)] -//~^ WARNING external crate `bar` unused in - -fn main() {} diff --git a/src/test/ui/unused-crate-deps/extern-loc-json-json.stderr b/src/test/ui/unused-crate-deps/extern-loc-json-json.stderr deleted file mode 100644 index 5fc8397e4698c..0000000000000 --- a/src/test/ui/unused-crate-deps/extern-loc-json-json.stderr +++ /dev/null @@ -1,17 +0,0 @@ -{"message":"external crate `bar` unused in `extern_loc_json_json`: remove the dependency or add `use bar as _;`","code":{"code":"unused_crate_dependencies","explanation":null},"level":"warning","spans":[{"file_name":"$DIR/extern-loc-json-json.rs","byte_start":169,"byte_end":169,"line_start":7,"line_end":7,"column_start":1,"column_end":1,"is_primary":true,"text":[{"text":"#![warn(unused_crate_dependencies)]","highlight_start":1,"highlight_end":1}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"the lint level is defined here","code":null,"level":"note","spans":[{"file_name":"$DIR/extern-loc-json-json.rs","byte_start":177,"byte_end":202,"line_start":7,"line_end":7,"column_start":9,"column_end":34,"is_primary":true,"text":[{"text":"#![warn(unused_crate_dependencies)]","highlight_start":9,"highlight_end":34}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"remove unnecessary dependency `bar`","code":null,"level":"help","spans":[],"children":[],"rendered":null},{"message":"json extern location","code":null,"level":"help","spans":[],"children":[],"rendered":null,"tool_metadata":{"key":123,"value":{}}}],"rendered":"warning: external crate `bar` unused in `extern_loc_json_json`: remove the dependency or add `use bar as _;` - --> $DIR/extern-loc-json-json.rs:7:1 - | -LL | #![warn(unused_crate_dependencies)] - | ^ - | -note: the lint level is defined here - --> $DIR/extern-loc-json-json.rs:7:9 - | -LL | #![warn(unused_crate_dependencies)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: remove unnecessary dependency `bar` - -"} -{"message":"1 warning emitted","code":null,"level":"warning","spans":[],"children":[],"rendered":"warning: 1 warning emitted - -"} diff --git a/src/test/ui/unused-crate-deps/extern-loc-json.rs b/src/test/ui/unused-crate-deps/extern-loc-json.rs deleted file mode 100644 index 212610d532e1c..0000000000000 --- a/src/test/ui/unused-crate-deps/extern-loc-json.rs +++ /dev/null @@ -1,10 +0,0 @@ -// --extern-location with a raw reference - -// check-pass -// aux-crate:bar=bar.rs -// compile-flags:--extern-location bar=json:{"key":123,"value":{}} - -#![warn(unused_crate_dependencies)] -//~^ WARNING external crate `bar` unused in - -fn main() {} diff --git a/src/test/ui/unused-crate-deps/extern-loc-json.stderr b/src/test/ui/unused-crate-deps/extern-loc-json.stderr deleted file mode 100644 index a6bbc0da1c6b4..0000000000000 --- a/src/test/ui/unused-crate-deps/extern-loc-json.stderr +++ /dev/null @@ -1,15 +0,0 @@ -warning: external crate `bar` unused in `extern_loc_json`: remove the dependency or add `use bar as _;` - --> $DIR/extern-loc-json.rs:7:1 - | -LL | #![warn(unused_crate_dependencies)] - | ^ - | -note: the lint level is defined here - --> $DIR/extern-loc-json.rs:7:9 - | -LL | #![warn(unused_crate_dependencies)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: remove unnecessary dependency `bar` - -warning: 1 warning emitted - diff --git a/src/test/ui/unused-crate-deps/extern-loc-missing-loc.rs b/src/test/ui/unused-crate-deps/extern-loc-missing-loc.rs deleted file mode 100644 index 9339a004d3b74..0000000000000 --- a/src/test/ui/unused-crate-deps/extern-loc-missing-loc.rs +++ /dev/null @@ -1,8 +0,0 @@ -// --extern-location with a raw reference - -// aux-crate:bar=bar.rs -// compile-flags:--extern-location bar - -#![warn(unused_crate_dependencies)] - -fn main() {} diff --git a/src/test/ui/unused-crate-deps/extern-loc-missing-loc.stderr b/src/test/ui/unused-crate-deps/extern-loc-missing-loc.stderr deleted file mode 100644 index 4584fbfb67ff7..0000000000000 --- a/src/test/ui/unused-crate-deps/extern-loc-missing-loc.stderr +++ /dev/null @@ -1,2 +0,0 @@ -error: `--extern-location`: specify location for extern crate `bar` - diff --git a/src/test/ui/unused-crate-deps/extern-loc-missing-loctype.rs b/src/test/ui/unused-crate-deps/extern-loc-missing-loctype.rs deleted file mode 100644 index 4768365a65325..0000000000000 --- a/src/test/ui/unused-crate-deps/extern-loc-missing-loctype.rs +++ /dev/null @@ -1,8 +0,0 @@ -// --extern-location with no type - -// aux-crate:bar=bar.rs -// compile-flags:--extern-location bar=missing-loc-type - -#![warn(unused_crate_dependencies)] - -fn main() {} diff --git a/src/test/ui/unused-crate-deps/extern-loc-missing-loctype.stderr b/src/test/ui/unused-crate-deps/extern-loc-missing-loctype.stderr deleted file mode 100644 index d0c36ebeb142e..0000000000000 --- a/src/test/ui/unused-crate-deps/extern-loc-missing-loctype.stderr +++ /dev/null @@ -1,2 +0,0 @@ -error: unknown location type `missing-loc-type`: use `raw` or `json` - diff --git a/src/test/ui/unused-crate-deps/extern-loc-raw-json.rs b/src/test/ui/unused-crate-deps/extern-loc-raw-json.rs deleted file mode 100644 index 207615ccc87b6..0000000000000 --- a/src/test/ui/unused-crate-deps/extern-loc-raw-json.rs +++ /dev/null @@ -1,10 +0,0 @@ -// --extern-location with a raw reference - -// check-pass -// aux-crate:bar=bar.rs -// compile-flags:--extern-location bar=raw:in-the-test-file --error-format json - -#![warn(unused_crate_dependencies)] -//~^ WARNING external crate `bar` unused in - -fn main() {} diff --git a/src/test/ui/unused-crate-deps/extern-loc-raw-json.stderr b/src/test/ui/unused-crate-deps/extern-loc-raw-json.stderr deleted file mode 100644 index 25f099927fd0a..0000000000000 --- a/src/test/ui/unused-crate-deps/extern-loc-raw-json.stderr +++ /dev/null @@ -1,17 +0,0 @@ -{"message":"external crate `bar` unused in `extern_loc_raw_json`: remove the dependency or add `use bar as _;`","code":{"code":"unused_crate_dependencies","explanation":null},"level":"warning","spans":[{"file_name":"$DIR/extern-loc-raw-json.rs","byte_start":162,"byte_end":162,"line_start":7,"line_end":7,"column_start":1,"column_end":1,"is_primary":true,"text":[{"text":"#![warn(unused_crate_dependencies)]","highlight_start":1,"highlight_end":1}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"the lint level is defined here","code":null,"level":"note","spans":[{"file_name":"$DIR/extern-loc-raw-json.rs","byte_start":170,"byte_end":195,"line_start":7,"line_end":7,"column_start":9,"column_end":34,"is_primary":true,"text":[{"text":"#![warn(unused_crate_dependencies)]","highlight_start":9,"highlight_end":34}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"remove unnecessary dependency `bar` at `in-the-test-file`","code":null,"level":"help","spans":[],"children":[],"rendered":null},{"message":"raw extern location","code":null,"level":"help","spans":[{"file_name":"$DIR/extern-loc-raw-json.rs","byte_start":0,"byte_end":0,"line_start":1,"line_end":1,"column_start":1,"column_end":1,"is_primary":true,"text":[],"label":null,"suggested_replacement":"in-the-test-file","suggestion_applicability":"Unspecified","expansion":null}],"children":[],"rendered":null},{"message":"json extern location","code":null,"level":"help","spans":[],"children":[],"rendered":null,"tool_metadata":"in-the-test-file"}],"rendered":"warning: external crate `bar` unused in `extern_loc_raw_json`: remove the dependency or add `use bar as _;` - --> $DIR/extern-loc-raw-json.rs:7:1 - | -LL | #![warn(unused_crate_dependencies)] - | ^ - | -note: the lint level is defined here - --> $DIR/extern-loc-raw-json.rs:7:9 - | -LL | #![warn(unused_crate_dependencies)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: remove unnecessary dependency `bar` at `in-the-test-file` - -"} -{"message":"1 warning emitted","code":null,"level":"warning","spans":[],"children":[],"rendered":"warning: 1 warning emitted - -"} diff --git a/src/test/ui/unused-crate-deps/extern-loc-raw-missing-loc.rs b/src/test/ui/unused-crate-deps/extern-loc-raw-missing-loc.rs deleted file mode 100644 index 65b6426839471..0000000000000 --- a/src/test/ui/unused-crate-deps/extern-loc-raw-missing-loc.rs +++ /dev/null @@ -1,8 +0,0 @@ -// --extern-location with a raw reference - -// aux-crate:bar=bar.rs -// compile-flags:--extern-location bar=raw - -#![warn(unused_crate_dependencies)] - -fn main() {} diff --git a/src/test/ui/unused-crate-deps/extern-loc-raw-missing-loc.stderr b/src/test/ui/unused-crate-deps/extern-loc-raw-missing-loc.stderr deleted file mode 100644 index 4b51266e4f6fa..0000000000000 --- a/src/test/ui/unused-crate-deps/extern-loc-raw-missing-loc.stderr +++ /dev/null @@ -1,2 +0,0 @@ -error: `--extern-location`: missing `raw` location - diff --git a/src/test/ui/unused-crate-deps/extern-loc-raw.rs b/src/test/ui/unused-crate-deps/extern-loc-raw.rs deleted file mode 100644 index fc3fed1e10e80..0000000000000 --- a/src/test/ui/unused-crate-deps/extern-loc-raw.rs +++ /dev/null @@ -1,10 +0,0 @@ -// --extern-location with a raw reference - -// check-pass -// aux-crate:bar=bar.rs -// compile-flags:--extern-location bar=raw:in-the-test-file - -#![warn(unused_crate_dependencies)] -//~^ WARNING external crate `bar` unused in - -fn main() {} diff --git a/src/test/ui/unused-crate-deps/extern-loc-raw.stderr b/src/test/ui/unused-crate-deps/extern-loc-raw.stderr deleted file mode 100644 index 2cdd005586673..0000000000000 --- a/src/test/ui/unused-crate-deps/extern-loc-raw.stderr +++ /dev/null @@ -1,15 +0,0 @@ -warning: external crate `bar` unused in `extern_loc_raw`: remove the dependency or add `use bar as _;` - --> $DIR/extern-loc-raw.rs:7:1 - | -LL | #![warn(unused_crate_dependencies)] - | ^ - | -note: the lint level is defined here - --> $DIR/extern-loc-raw.rs:7:9 - | -LL | #![warn(unused_crate_dependencies)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: remove unnecessary dependency `bar` at `in-the-test-file` - -warning: 1 warning emitted - diff --git a/src/test/ui/unused-crate-deps/libfib.stderr b/src/test/ui/unused-crate-deps/libfib.stderr index 479f51bff464d..15833126bd620 100644 --- a/src/test/ui/unused-crate-deps/libfib.stderr +++ b/src/test/ui/unused-crate-deps/libfib.stderr @@ -5,7 +5,6 @@ LL | pub fn fib(n: u32) -> Vec { | ^ | = note: requested on the command line with `-W unused-crate-dependencies` - = help: remove unnecessary dependency `bar` warning: 1 warning emitted diff --git a/src/test/ui/unused-crate-deps/test.mk b/src/test/ui/unused-crate-deps/test.mk deleted file mode 100644 index 0b98b4e44fb2a..0000000000000 --- a/src/test/ui/unused-crate-deps/test.mk +++ /dev/null @@ -1,7 +0,0 @@ -# Everyone uses make for building Rust - -foo: bar.rlib - $(RUSTC) --crate-type bin --extern bar=bar.rlib - -%.rlib: %.rs - $(RUSTC) --crate-type lib $< diff --git a/src/test/ui/unused-crate-deps/unused-aliases.stderr b/src/test/ui/unused-crate-deps/unused-aliases.stderr index 1142d156d0e96..c8c6c4507b0c5 100644 --- a/src/test/ui/unused-crate-deps/unused-aliases.stderr +++ b/src/test/ui/unused-crate-deps/unused-aliases.stderr @@ -9,7 +9,6 @@ note: the lint level is defined here | LL | #![warn(unused_crate_dependencies)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: remove unnecessary dependency `barbar` warning: 1 warning emitted diff --git a/src/test/ui/unused-crate-deps/warn-attr.stderr b/src/test/ui/unused-crate-deps/warn-attr.stderr index 29667d9525cb4..0d38315704b11 100644 --- a/src/test/ui/unused-crate-deps/warn-attr.stderr +++ b/src/test/ui/unused-crate-deps/warn-attr.stderr @@ -9,7 +9,6 @@ note: the lint level is defined here | LL | #![warn(unused_crate_dependencies)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: remove unnecessary dependency `bar` warning: 1 warning emitted diff --git a/src/test/ui/unused-crate-deps/warn-cmdline-static.stderr b/src/test/ui/unused-crate-deps/warn-cmdline-static.stderr index 2c0c921512986..65956461d6439 100644 --- a/src/test/ui/unused-crate-deps/warn-cmdline-static.stderr +++ b/src/test/ui/unused-crate-deps/warn-cmdline-static.stderr @@ -5,7 +5,6 @@ LL | fn main() {} | ^ | = note: requested on the command line with `-W unused-crate-dependencies` - = help: remove unnecessary dependency `bar` warning: 1 warning emitted diff --git a/src/test/ui/unused-crate-deps/warn-cmdline.stderr b/src/test/ui/unused-crate-deps/warn-cmdline.stderr index 2cd49218f5ad8..ea675ba9a1eb1 100644 --- a/src/test/ui/unused-crate-deps/warn-cmdline.stderr +++ b/src/test/ui/unused-crate-deps/warn-cmdline.stderr @@ -5,7 +5,6 @@ LL | fn main() {} | ^ | = note: requested on the command line with `-W unused-crate-dependencies` - = help: remove unnecessary dependency `bar` warning: 1 warning emitted diff --git a/src/test/ui/wf/wf-fn-where-clause.stderr b/src/test/ui/wf/wf-fn-where-clause.stderr index 22598e58bd744..988cb2fa5480c 100644 --- a/src/test/ui/wf/wf-fn-where-clause.stderr +++ b/src/test/ui/wf/wf-fn-where-clause.stderr @@ -28,7 +28,7 @@ help: you could relax the implicit `Sized` bound on `T` if it were used through LL | struct Vec { | ^ this could be changed to `T: ?Sized`... LL | t: T, - | - ...if indirection were used here: `Box` + | - ...if indirection was used here: `Box` error[E0038]: the trait `Copy` cannot be made into an object --> $DIR/wf-fn-where-clause.rs:12:16 diff --git a/src/tools/cargo b/src/tools/cargo index 34170fcd6e094..e099df243bb24 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 34170fcd6e0947808a1ac63ac85ffc0da7dace2f +Subproject commit e099df243bb2495b9b197f79c19f124032b1e778 diff --git a/src/tools/clippy/.editorconfig b/src/tools/clippy/.editorconfig index ec6e107d547f0..a13173544d80a 100644 --- a/src/tools/clippy/.editorconfig +++ b/src/tools/clippy/.editorconfig @@ -13,8 +13,6 @@ indent_style = space indent_size = 4 [*.md] -# double whitespace at end of line -# denotes a line break in Markdown trim_trailing_whitespace = false [*.yml] diff --git a/src/tools/clippy/CHANGELOG.md b/src/tools/clippy/CHANGELOG.md index c1032204a22cb..dadb6832d1fd7 100644 --- a/src/tools/clippy/CHANGELOG.md +++ b/src/tools/clippy/CHANGELOG.md @@ -2079,7 +2079,6 @@ Released 2018-09-13 [`missing_docs_in_private_items`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_docs_in_private_items [`missing_errors_doc`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_errors_doc [`missing_inline_in_public_items`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_inline_in_public_items -[`missing_panics_doc`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc [`missing_safety_doc`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc [`mistyped_literal_suffixes`]: https://rust-lang.github.io/rust-clippy/master/index.html#mistyped_literal_suffixes [`mixed_case_hex_literals`]: https://rust-lang.github.io/rust-clippy/master/index.html#mixed_case_hex_literals diff --git a/src/tools/clippy/CONTRIBUTING.md b/src/tools/clippy/CONTRIBUTING.md index 5954ab25d1942..f2641a23f563b 100644 --- a/src/tools/clippy/CONTRIBUTING.md +++ b/src/tools/clippy/CONTRIBUTING.md @@ -46,12 +46,11 @@ first read the [Basics docs](doc/basics.md).** ### Finding something to fix/improve -All issues on Clippy are mentored, if you want help simply ask @Manishearth, @flip1995, @phansch -or @llogiq directly by mentioning them in the issue or over on [Zulip]. This list may be out of date. -All currently active mentors can be found [here](https://github.com/rust-lang/highfive/blob/master/highfive/configs/rust-lang/rust-clippy.json#L3) +All issues on Clippy are mentored, if you want help with a bug just ask +@Manishearth, @flip1995, @phansch or @yaahc. -Some issues are easier than others. The [`good-first-issue`] label can be used to find the easy -issues. You can use `@rustbot claim` to assign the issue to yourself. +Some issues are easier than others. The [`good-first-issue`] label can be used to find the easy issues. +If you want to work on an issue, please leave a comment so that we can assign it to you! There are also some abandoned PRs, marked with [`S-inactive-closed`]. Pretty often these PRs are nearly completed and just need some extra steps diff --git a/src/tools/clippy/Cargo.toml b/src/tools/clippy/Cargo.toml index e7755c46eb80d..e60aa472846cf 100644 --- a/src/tools/clippy/Cargo.toml +++ b/src/tools/clippy/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clippy" -version = "0.1.52" +version = "0.1.51" authors = [ "Manish Goregaokar ", "Andre Bogus ", diff --git a/src/tools/clippy/clippy_dev/src/bless.rs b/src/tools/clippy/clippy_dev/src/bless.rs index 2a869e9d4491b..b877806946cfe 100644 --- a/src/tools/clippy/clippy_dev/src/bless.rs +++ b/src/tools/clippy/clippy_dev/src/bless.rs @@ -24,9 +24,6 @@ static CLIPPY_BUILD_TIME: SyncLazy> = SyncLazy::ne fs::metadata(path).ok()?.modified().ok() }); -/// # Panics -/// -/// Panics if the path to a test file is broken pub fn bless(ignore_timestamp: bool) { let test_suite_dirs = [ clippy_project_root().join("tests").join("ui"), diff --git a/src/tools/clippy/clippy_dev/src/fmt.rs b/src/tools/clippy/clippy_dev/src/fmt.rs index 4d0fdadbd85d1..6b528d219df27 100644 --- a/src/tools/clippy/clippy_dev/src/fmt.rs +++ b/src/tools/clippy/clippy_dev/src/fmt.rs @@ -8,7 +8,7 @@ use walkdir::WalkDir; #[derive(Debug)] pub enum CliError { - CommandFailed(String, String), + CommandFailed(String), IoError(io::Error), RustfmtNotInstalled, WalkDirError(walkdir::Error), @@ -75,8 +75,8 @@ pub fn run(check: bool, verbose: bool) { fn output_err(err: CliError) { match err { - CliError::CommandFailed(command, stderr) => { - eprintln!("error: A command failed! `{}`\nstderr: {}", command, stderr); + CliError::CommandFailed(command) => { + eprintln!("error: A command failed! `{}`", command); }, CliError::IoError(err) => { eprintln!("error: {}", err); @@ -136,16 +136,12 @@ fn exec( println!("{}", format_command(&program, &dir, args)); } - let child = Command::new(&program).current_dir(&dir).args(args.iter()).spawn()?; - let output = child.wait_with_output()?; - let success = output.status.success(); + let mut child = Command::new(&program).current_dir(&dir).args(args.iter()).spawn()?; + let code = child.wait()?; + let success = code.success(); if !context.check && !success { - let stderr = std::str::from_utf8(&output.stderr).unwrap_or(""); - return Err(CliError::CommandFailed( - format_command(&program, &dir, args), - String::from(stderr), - )); + return Err(CliError::CommandFailed(format_command(&program, &dir, args))); } Ok(success) @@ -181,10 +177,7 @@ fn rustfmt_test(context: &FmtContext) -> Result<(), CliError> { { Err(CliError::RustfmtNotInstalled) } else { - Err(CliError::CommandFailed( - format_command(&program, &dir, args), - std::str::from_utf8(&output.stderr).unwrap_or("").to_string(), - )) + Err(CliError::CommandFailed(format_command(&program, &dir, args))) } } diff --git a/src/tools/clippy/clippy_dev/src/lib.rs b/src/tools/clippy/clippy_dev/src/lib.rs index 01d1fc9211a94..24d70d433f367 100644 --- a/src/tools/clippy/clippy_dev/src/lib.rs +++ b/src/tools/clippy/clippy_dev/src/lib.rs @@ -236,10 +236,6 @@ pub struct FileChange { /// `path` is the relative path to the file on which you want to perform the replacement. /// /// See `replace_region_in_text` for documentation of the other options. -/// -/// # Panics -/// -/// Panics if the path could not read or then written pub fn replace_region_in_file( path: &Path, start: &str, @@ -287,10 +283,6 @@ where /// .new_lines; /// assert_eq!("replace_start\na different\ntext\nreplace_end", result); /// ``` -/// -/// # Panics -/// -/// Panics if start or end is not valid regex pub fn replace_region_in_text(text: &str, start: &str, end: &str, replace_start: bool, replacements: F) -> FileChange where F: FnOnce() -> Vec, @@ -337,11 +329,6 @@ where } /// Returns the path to the Clippy project directory -/// -/// # Panics -/// -/// Panics if the current directory could not be retrieved, there was an error reading any of the -/// Cargo.toml files or ancestor directory is the clippy root directory #[must_use] pub fn clippy_project_root() -> PathBuf { let current_dir = std::env::current_dir().unwrap(); diff --git a/src/tools/clippy/clippy_dev/src/ra_setup.rs b/src/tools/clippy/clippy_dev/src/ra_setup.rs index a3c329b578b20..a8a6a2cb1bd6f 100644 --- a/src/tools/clippy/clippy_dev/src/ra_setup.rs +++ b/src/tools/clippy/clippy_dev/src/ra_setup.rs @@ -8,9 +8,6 @@ use std::path::{Path, PathBuf}; // This allows rust analyzer to analyze rustc internals and show proper information inside clippy // code. See https://github.com/rust-analyzer/rust-analyzer/issues/3517 and https://github.com/rust-lang/rust-clippy/issues/5514 for details -/// # Panics -/// -/// Panics if `rustc_path` does not lead to a rustc repo or the files could not be read pub fn run(rustc_path: Option<&str>) { // we can unwrap here because the arg is required by clap let rustc_path = PathBuf::from(rustc_path.unwrap()); diff --git a/src/tools/clippy/clippy_dev/src/serve.rs b/src/tools/clippy/clippy_dev/src/serve.rs index faa94859601e3..a46c0e4d3f0a1 100644 --- a/src/tools/clippy/clippy_dev/src/serve.rs +++ b/src/tools/clippy/clippy_dev/src/serve.rs @@ -4,9 +4,6 @@ use std::process::Command; use std::thread; use std::time::{Duration, SystemTime}; -/// # Panics -/// -/// Panics if the python commands could not be spawned pub fn run(port: u16, lint: Option<&str>) -> ! { let mut url = Some(match lint { None => format!("http://localhost:{}", port), diff --git a/src/tools/clippy/clippy_lints/Cargo.toml b/src/tools/clippy/clippy_lints/Cargo.toml index 840341fefc6a2..a9516560a6195 100644 --- a/src/tools/clippy/clippy_lints/Cargo.toml +++ b/src/tools/clippy/clippy_lints/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "clippy_lints" # begin automatic update -version = "0.1.52" +version = "0.1.51" # end automatic update authors = [ "Manish Goregaokar ", diff --git a/src/tools/clippy/clippy_lints/src/doc.rs b/src/tools/clippy/clippy_lints/src/doc.rs index 75e71eb1e4ce2..3a754f4991782 100644 --- a/src/tools/clippy/clippy_lints/src/doc.rs +++ b/src/tools/clippy/clippy_lints/src/doc.rs @@ -1,20 +1,14 @@ -use crate::utils::{ - implements_trait, is_entrypoint_fn, is_type_diagnostic_item, match_panic_def_id, method_chain_args, return_ty, - span_lint, span_lint_and_note, -}; +use crate::utils::{implements_trait, is_entrypoint_fn, is_type_diagnostic_item, return_ty, span_lint}; use if_chain::if_chain; use itertools::Itertools; -use rustc_ast::ast::{Async, AttrKind, Attribute, FnKind, FnRetTy, ItemKind}; +use rustc_ast::ast::{Async, AttrKind, Attribute, FnRetTy, ItemKind}; use rustc_ast::token::CommentKind; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::sync::Lrc; use rustc_errors::emitter::EmitterWriter; use rustc_errors::Handler; use rustc_hir as hir; -use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; -use rustc_hir::{Expr, ExprKind, QPath}; use rustc_lint::{LateContext, LateLintPass}; -use rustc_middle::hir::map::Map; use rustc_middle::lint::in_external_macro; use rustc_middle::ty; use rustc_parse::maybe_new_parser_from_source_str; @@ -128,37 +122,6 @@ declare_clippy_lint! { "`pub fn` returns `Result` without `# Errors` in doc comment" } -declare_clippy_lint! { - /// **What it does:** Checks the doc comments of publicly visible functions that - /// may panic and warns if there is no `# Panics` section. - /// - /// **Why is this bad?** Documenting the scenarios in which panicking occurs - /// can help callers who do not want to panic to avoid those situations. - /// - /// **Known problems:** None. - /// - /// **Examples:** - /// - /// Since the following function may panic it has a `# Panics` section in - /// its doc comment: - /// - /// ```rust - /// /// # Panics - /// /// - /// /// Will panic if y is 0 - /// pub fn divide_by(x: i32, y: i32) -> i32 { - /// if y == 0 { - /// panic!("Cannot divide by 0") - /// } else { - /// x / y - /// } - /// } - /// ``` - pub MISSING_PANICS_DOC, - pedantic, - "`pub fn` may panic without `# Panics` in doc comment" -} - declare_clippy_lint! { /// **What it does:** Checks for `fn main() { .. }` in doctests /// @@ -203,9 +166,7 @@ impl DocMarkdown { } } -impl_lint_pass!(DocMarkdown => - [DOC_MARKDOWN, MISSING_SAFETY_DOC, MISSING_ERRORS_DOC, MISSING_PANICS_DOC, NEEDLESS_DOCTEST_MAIN] -); +impl_lint_pass!(DocMarkdown => [DOC_MARKDOWN, MISSING_SAFETY_DOC, MISSING_ERRORS_DOC, NEEDLESS_DOCTEST_MAIN]); impl<'tcx> LateLintPass<'tcx> for DocMarkdown { fn check_crate(&mut self, cx: &LateContext<'tcx>, krate: &'tcx hir::Crate<'_>) { @@ -219,15 +180,7 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown { if !(is_entrypoint_fn(cx, cx.tcx.hir().local_def_id(item.hir_id).to_def_id()) || in_external_macro(cx.tcx.sess, item.span)) { - let body = cx.tcx.hir().body(body_id); - let impl_item_def_id = cx.tcx.hir().local_def_id(item.hir_id); - let mut fpu = FindPanicUnwrap { - cx, - typeck_results: cx.tcx.typeck(impl_item_def_id), - panic_span: None, - }; - fpu.visit_expr(&body.value); - lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, Some(body_id), fpu.panic_span); + lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, Some(body_id)); } }, hir::ItemKind::Impl(ref impl_) => { @@ -247,7 +200,7 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown { let headers = check_attrs(cx, &self.valid_idents, &item.attrs); if let hir::TraitItemKind::Fn(ref sig, ..) = item.kind { if !in_external_macro(cx.tcx.sess, item.span) { - lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, None, None); + lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, None); } } } @@ -258,15 +211,7 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown { return; } if let hir::ImplItemKind::Fn(ref sig, body_id) = item.kind { - let body = cx.tcx.hir().body(body_id); - let impl_item_def_id = cx.tcx.hir().local_def_id(item.hir_id); - let mut fpu = FindPanicUnwrap { - cx, - typeck_results: cx.tcx.typeck(impl_item_def_id), - panic_span: None, - }; - fpu.visit_expr(&body.value); - lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, Some(body_id), fpu.panic_span); + lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, Some(body_id)); } } } @@ -278,7 +223,6 @@ fn lint_for_missing_headers<'tcx>( sig: &hir::FnSig<'_>, headers: DocHeaders, body_id: Option, - panic_span: Option, ) { if !cx.access_levels.is_exported(hir_id) { return; // Private functions do not require doc comments @@ -291,16 +235,6 @@ fn lint_for_missing_headers<'tcx>( "unsafe function's docs miss `# Safety` section", ); } - if !headers.panics && panic_span.is_some() { - span_lint_and_note( - cx, - MISSING_PANICS_DOC, - span, - "docs for function which may panic missing `# Panics` section", - panic_span, - "first possible panic found here", - ); - } if !headers.errors { if is_type_diagnostic_item(cx, return_ty(cx, hir_id), sym::result_type) { span_lint( @@ -387,7 +321,6 @@ pub fn strip_doc_comment_decoration(doc: &str, comment_kind: CommentKind, span: struct DocHeaders { safety: bool, errors: bool, - panics: bool, } fn check_attrs<'a>(cx: &LateContext<'_>, valid_idents: &FxHashSet, attrs: &'a [Attribute]) -> DocHeaders { @@ -405,7 +338,6 @@ fn check_attrs<'a>(cx: &LateContext<'_>, valid_idents: &FxHashSet, attrs return DocHeaders { safety: true, errors: true, - panics: true, }; } } @@ -421,7 +353,6 @@ fn check_attrs<'a>(cx: &LateContext<'_>, valid_idents: &FxHashSet, attrs return DocHeaders { safety: false, errors: false, - panics: false, }; } @@ -463,7 +394,6 @@ fn check_doc<'a, Events: Iterator, Range, Range o, Err(e) => e - 1, @@ -563,9 +492,7 @@ fn check_code(cx: &LateContext<'_>, text: &str, edition: Edition, span: Span) { | ItemKind::ExternCrate(..) | ItemKind::ForeignMod(..) => return false, // We found a main function ... - ItemKind::Fn(box FnKind(_, sig, _, Some(block))) - if item.ident.name == sym::main => - { + ItemKind::Fn(_, sig, _, Some(block)) if item.ident.name == sym::main => { let is_async = matches!(sig.header.asyncness, Async::Yes { .. }); let returns_nothing = match &sig.decl.output { FnRetTy::Default(..) => true, @@ -680,47 +607,3 @@ fn check_word(cx: &LateContext<'_>, word: &str, span: Span) { ); } } - -struct FindPanicUnwrap<'a, 'tcx> { - cx: &'a LateContext<'tcx>, - panic_span: Option, - typeck_results: &'tcx ty::TypeckResults<'tcx>, -} - -impl<'a, 'tcx> Visitor<'tcx> for FindPanicUnwrap<'a, 'tcx> { - type Map = Map<'tcx>; - - fn visit_expr(&mut self, expr: &'tcx Expr<'_>) { - if self.panic_span.is_some() { - return; - } - - // check for `begin_panic` - if_chain! { - if let ExprKind::Call(ref func_expr, _) = expr.kind; - if let ExprKind::Path(QPath::Resolved(_, ref path)) = func_expr.kind; - if let Some(path_def_id) = path.res.opt_def_id(); - if match_panic_def_id(self.cx, path_def_id); - then { - self.panic_span = Some(expr.span); - } - } - - // check for `unwrap` - if let Some(arglists) = method_chain_args(expr, &["unwrap"]) { - let reciever_ty = self.typeck_results.expr_ty(&arglists[0][0]).peel_refs(); - if is_type_diagnostic_item(self.cx, reciever_ty, sym::option_type) - || is_type_diagnostic_item(self.cx, reciever_ty, sym::result_type) - { - self.panic_span = Some(expr.span); - } - } - - // and check sub-expressions - intravisit::walk_expr(self, expr); - } - - fn nested_visit_map(&mut self) -> NestedVisitorMap { - NestedVisitorMap::OnlyBodies(self.cx.tcx.hir()) - } -} diff --git a/src/tools/clippy/clippy_lints/src/excessive_bools.rs b/src/tools/clippy/clippy_lints/src/excessive_bools.rs index 6f22f65deac80..82ca4baacb7a9 100644 --- a/src/tools/clippy/clippy_lints/src/excessive_bools.rs +++ b/src/tools/clippy/clippy_lints/src/excessive_bools.rs @@ -1,7 +1,5 @@ use crate::utils::{attr_by_name, in_macro, match_path_ast, span_lint_and_help}; -use rustc_ast::ast::{ - AssocItemKind, Extern, FnKind, FnSig, ImplKind, Item, ItemKind, TraitKind, Ty, TyKind, -}; +use rustc_ast::ast::{AssocItemKind, Extern, FnSig, Item, ItemKind, Ty, TyKind}; use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::Span; @@ -161,17 +159,17 @@ impl EarlyLintPass for ExcessiveBools { ); } }, - ItemKind::Impl(box ImplKind { + ItemKind::Impl { of_trait: None, items, .. - }) - | ItemKind::Trait(box TraitKind(.., items)) => { + } + | ItemKind::Trait(_, _, _, _, items) => { for item in items { - if let AssocItemKind::Fn(box FnKind(_, fn_sig, _, _)) = &item.kind { + if let AssocItemKind::Fn(_, fn_sig, _, _) = &item.kind { self.check_fn_sig(cx, fn_sig, item.span); } } }, - ItemKind::Fn(box FnKind(_, fn_sig, _, _)) => self.check_fn_sig(cx, fn_sig, item.span), + ItemKind::Fn(_, fn_sig, _, _) => self.check_fn_sig(cx, fn_sig, item.span), _ => (), } } diff --git a/src/tools/clippy/clippy_lints/src/exhaustive_items.rs b/src/tools/clippy/clippy_lints/src/exhaustive_items.rs index e3988d0038c23..32b1299efce91 100644 --- a/src/tools/clippy/clippy_lints/src/exhaustive_items.rs +++ b/src/tools/clippy/clippy_lints/src/exhaustive_items.rs @@ -75,14 +75,10 @@ impl LateLintPass<'_> for ExhaustiveItems { if cx.access_levels.is_exported(item.hir_id); if !item.attrs.iter().any(|a| a.has_name(sym::non_exhaustive)); then { - let (lint, msg) = if let ItemKind::Struct(ref v, ..) = item.kind { - if v.fields().iter().any(|f| !f.vis.node.is_pub()) { - // skip structs with private fields - return; - } - (EXHAUSTIVE_STRUCTS, "exported structs should not be exhaustive") - } else { + let (lint, msg) = if let ItemKind::Enum(..) = item.kind { (EXHAUSTIVE_ENUMS, "exported enums should not be exhaustive") + } else { + (EXHAUSTIVE_STRUCTS, "exported structs should not be exhaustive") }; let suggestion_span = item.span.shrink_to_lo(); let indent = " ".repeat(indent_of(cx, item.span).unwrap_or(0)); diff --git a/src/tools/clippy/clippy_lints/src/lib.rs b/src/tools/clippy/clippy_lints/src/lib.rs index 5a40c00bd673a..54007c29c6c5e 100644 --- a/src/tools/clippy/clippy_lints/src/lib.rs +++ b/src/tools/clippy/clippy_lints/src/lib.rs @@ -592,7 +592,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: &disallowed_method::DISALLOWED_METHOD, &doc::DOC_MARKDOWN, &doc::MISSING_ERRORS_DOC, - &doc::MISSING_PANICS_DOC, &doc::MISSING_SAFETY_DOC, &doc::NEEDLESS_DOCTEST_MAIN, &double_comparison::DOUBLE_COMPARISONS, @@ -1318,7 +1317,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: LintId::of(&derive::UNSAFE_DERIVE_DESERIALIZE), LintId::of(&doc::DOC_MARKDOWN), LintId::of(&doc::MISSING_ERRORS_DOC), - LintId::of(&doc::MISSING_PANICS_DOC), LintId::of(&empty_enum::EMPTY_ENUM), LintId::of(&enum_variants::MODULE_NAME_REPETITIONS), LintId::of(&enum_variants::PUB_ENUM_VARIANT_NAMES), diff --git a/src/tools/clippy/clippy_lints/src/matches.rs b/src/tools/clippy/clippy_lints/src/matches.rs index ba7b9bd04248d..5f62d2d13165c 100644 --- a/src/tools/clippy/clippy_lints/src/matches.rs +++ b/src/tools/clippy/clippy_lints/src/matches.rs @@ -1592,17 +1592,7 @@ where } }, (&Kind::End(a, _), &Kind::Start(b, _)) if a != Bound::Included(b) => (), - _ => { - // skip if the range `a` is completely included into the range `b` - if let Ordering::Equal | Ordering::Less = a.cmp(&b) { - let kind_a = Kind::End(a.range().node.1, a.range()); - let kind_b = Kind::End(b.range().node.1, b.range()); - if let Ordering::Equal | Ordering::Greater = kind_a.cmp(&kind_b) { - return None; - } - } - return Some((a.range(), b.range())); - }, + _ => return Some((a.range(), b.range())), } } diff --git a/src/tools/clippy/clippy_lints/src/methods/mod.rs b/src/tools/clippy/clippy_lints/src/methods/mod.rs index 4ee423b383b0f..a17c5996293e9 100644 --- a/src/tools/clippy/clippy_lints/src/methods/mod.rs +++ b/src/tools/clippy/clippy_lints/src/methods/mod.rs @@ -2183,7 +2183,7 @@ fn lint_expect_fun_call( span_replace_word, &format!("use of `{}` followed by a function call", name), "try this", - format!("unwrap_or_else({} {{ panic!(\"{{}}\", {}) }})", closure_args, arg_root_snippet), + format!("unwrap_or_else({} {{ panic!({}) }})", closure_args, arg_root_snippet), applicability, ); } diff --git a/src/tools/clippy/clippy_lints/src/misc_early.rs b/src/tools/clippy/clippy_lints/src/misc_early.rs index 84a0df92f5b43..5bc45c87874b4 100644 --- a/src/tools/clippy/clippy_lints/src/misc_early.rs +++ b/src/tools/clippy/clippy_lints/src/misc_early.rs @@ -1,4 +1,4 @@ -use crate::utils::{snippet_opt, span_lint, span_lint_and_help, span_lint_and_sugg, span_lint_and_then}; +use crate::utils::{constants, snippet_opt, span_lint, span_lint_and_help, span_lint_and_sugg, span_lint_and_then}; use rustc_ast::ast::{ BindingMode, Expr, ExprKind, GenericParamKind, Generics, Lit, LitFloatType, LitIntType, LitKind, Mutability, NodeId, Pat, PatKind, UnOp, @@ -6,7 +6,6 @@ use rustc_ast::ast::{ use rustc_ast::visit::FnKind; use rustc_data_structures::fx::FxHashMap; use rustc_errors::Applicability; -use rustc_hir::PrimTy; use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_session::{declare_lint_pass, declare_tool_lint}; @@ -265,12 +264,13 @@ impl EarlyLintPass for MiscEarlyLints { fn check_generics(&mut self, cx: &EarlyContext<'_>, gen: &Generics) { for param in &gen.params { if let GenericParamKind::Type { .. } = param.kind { - if let Some(prim_ty) = PrimTy::from_name(param.ident.name) { + let name = param.ident.as_str(); + if constants::BUILTIN_TYPES.contains(&&*name) { span_lint( cx, BUILTIN_TYPE_SHADOW, param.ident.span, - &format!("this generic shadows the built-in type `{}`", prim_ty.name()), + &format!("this generic shadows the built-in type `{}`", name), ); } } diff --git a/src/tools/clippy/clippy_lints/src/non_expressive_names.rs b/src/tools/clippy/clippy_lints/src/non_expressive_names.rs index d5222a030d7af..855529378e650 100644 --- a/src/tools/clippy/clippy_lints/src/non_expressive_names.rs +++ b/src/tools/clippy/clippy_lints/src/non_expressive_names.rs @@ -1,8 +1,5 @@ use crate::utils::{span_lint, span_lint_and_then}; -use rustc_ast::ast::{ - Arm, AssocItem, AssocItemKind, Attribute, Block, FnDecl, FnKind, Item, ItemKind, Local, Pat, - PatKind, -}; +use rustc_ast::ast::{Arm, AssocItem, AssocItemKind, Attribute, Block, FnDecl, Item, ItemKind, Local, Pat, PatKind}; use rustc_ast::visit::{walk_block, walk_expr, walk_pat, Visitor}; use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_middle::lint::in_external_macro; @@ -367,7 +364,7 @@ impl EarlyLintPass for NonExpressiveNames { return; } - if let ItemKind::Fn(box FnKind(_, ref sig, _, Some(ref blk))) = item.kind { + if let ItemKind::Fn(_, ref sig, _, Some(ref blk)) = item.kind { do_check(self, cx, &item.attrs, &sig.decl, blk); } } @@ -377,7 +374,7 @@ impl EarlyLintPass for NonExpressiveNames { return; } - if let AssocItemKind::Fn(box FnKind(_, ref sig, _, Some(ref blk))) = item.kind { + if let AssocItemKind::Fn(_, ref sig, _, Some(ref blk)) = item.kind { do_check(self, cx, &item.attrs, &sig.decl, blk); } } diff --git a/src/tools/clippy/clippy_lints/src/utils/ast_utils.rs b/src/tools/clippy/clippy_lints/src/utils/ast_utils.rs index 642326469725f..eac5d0aa3ee9d 100644 --- a/src/tools/clippy/clippy_lints/src/utils/ast_utils.rs +++ b/src/tools/clippy/clippy_lints/src/utils/ast_utils.rs @@ -229,26 +229,17 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool { match (l, r) { (ExternCrate(l), ExternCrate(r)) => l == r, (Use(l), Use(r)) => eq_use_tree(l, r), - (Static(lt, lm, le), Static(rt, rm, re)) => { - lm == rm && eq_ty(lt, rt) && eq_expr_opt(le, re) - } - (Const(ld, lt, le), Const(rd, rt, re)) => { - eq_defaultness(*ld, *rd) && eq_ty(lt, rt) && eq_expr_opt(le, re) - } - (Fn(box FnKind(ld, lf, lg, lb)), Fn(box FnKind(rd, rf, rg, rb))) => { - eq_defaultness(*ld, *rd) - && eq_fn_sig(lf, rf) - && eq_generics(lg, rg) - && both(lb, rb, |l, r| eq_block(l, r)) - } - (Mod(l), Mod(r)) => { - l.inline == r.inline && over(&l.items, &r.items, |l, r| eq_item(l, r, eq_item_kind)) - } + (Static(lt, lm, le), Static(rt, rm, re)) => lm == rm && eq_ty(lt, rt) && eq_expr_opt(le, re), + (Const(ld, lt, le), Const(rd, rt, re)) => eq_defaultness(*ld, *rd) && eq_ty(lt, rt) && eq_expr_opt(le, re), + (Fn(ld, lf, lg, lb), Fn(rd, rf, rg, rb)) => { + eq_defaultness(*ld, *rd) && eq_fn_sig(lf, rf) && eq_generics(lg, rg) && both(lb, rb, |l, r| eq_block(l, r)) + }, + (Mod(l), Mod(r)) => l.inline == r.inline && over(&l.items, &r.items, |l, r| eq_item(l, r, eq_item_kind)), (ForeignMod(l), ForeignMod(r)) => { both(&l.abi, &r.abi, |l, r| eq_str_lit(l, r)) && over(&l.items, &r.items, |l, r| eq_item(l, r, eq_foreign_item_kind)) }, - (TyAlias(box TyAliasKind(ld, lg, lb, lt)), TyAlias(box TyAliasKind(rd, rg, rb, rt))) => { + (TyAlias(ld, lg, lb, lt), TyAlias(rd, rg, rb, rt)) => { eq_defaultness(*ld, *rd) && eq_generics(lg, rg) && over(lb, rb, |l, r| eq_generic_bound(l, r)) @@ -260,7 +251,7 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool { (Struct(lv, lg), Struct(rv, rg)) | (Union(lv, lg), Union(rv, rg)) => { eq_variant_data(lv, rv) && eq_generics(lg, rg) }, - (Trait(box TraitKind(la, lu, lg, lb, li)), Trait(box TraitKind(ra, ru, rg, rb, ri))) => { + (Trait(la, lu, lg, lb, li), Trait(ra, ru, rg, rb, ri)) => { la == ra && matches!(lu, Unsafe::No) == matches!(ru, Unsafe::No) && eq_generics(lg, rg) @@ -269,7 +260,7 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool { }, (TraitAlias(lg, lb), TraitAlias(rg, rb)) => eq_generics(lg, rg) && over(lb, rb, |l, r| eq_generic_bound(l, r)), ( - Impl(box ImplKind { + Impl { unsafety: lu, polarity: lp, defaultness: ld, @@ -278,8 +269,8 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool { of_trait: lot, self_ty: lst, items: li, - }), - Impl(box ImplKind { + }, + Impl { unsafety: ru, polarity: rp, defaultness: rd, @@ -288,7 +279,7 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool { of_trait: rot, self_ty: rst, items: ri, - }), + }, ) => { matches!(lu, Unsafe::No) == matches!(ru, Unsafe::No) && matches!(lp, ImplPolarity::Positive) == matches!(rp, ImplPolarity::Positive) @@ -308,16 +299,11 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool { pub fn eq_foreign_item_kind(l: &ForeignItemKind, r: &ForeignItemKind) -> bool { use ForeignItemKind::*; match (l, r) { - (Static(lt, lm, le), Static(rt, rm, re)) => { - lm == rm && eq_ty(lt, rt) && eq_expr_opt(le, re) - } - (Fn(box FnKind(ld, lf, lg, lb)), Fn(box FnKind(rd, rf, rg, rb))) => { - eq_defaultness(*ld, *rd) - && eq_fn_sig(lf, rf) - && eq_generics(lg, rg) - && both(lb, rb, |l, r| eq_block(l, r)) - } - (TyAlias(box TyAliasKind(ld, lg, lb, lt)), TyAlias(box TyAliasKind(rd, rg, rb, rt))) => { + (Static(lt, lm, le), Static(rt, rm, re)) => lm == rm && eq_ty(lt, rt) && eq_expr_opt(le, re), + (Fn(ld, lf, lg, lb), Fn(rd, rf, rg, rb)) => { + eq_defaultness(*ld, *rd) && eq_fn_sig(lf, rf) && eq_generics(lg, rg) && both(lb, rb, |l, r| eq_block(l, r)) + }, + (TyAlias(ld, lg, lb, lt), TyAlias(rd, rg, rb, rt)) => { eq_defaultness(*ld, *rd) && eq_generics(lg, rg) && over(lb, rb, |l, r| eq_generic_bound(l, r)) @@ -332,10 +318,10 @@ pub fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool { use AssocItemKind::*; match (l, r) { (Const(ld, lt, le), Const(rd, rt, re)) => eq_defaultness(*ld, *rd) && eq_ty(lt, rt) && eq_expr_opt(le, re), - (Fn(box FnKind(ld, lf, lg, lb)), Fn(box FnKind(rd, rf, rg, rb))) => { + (Fn(ld, lf, lg, lb), Fn(rd, rf, rg, rb)) => { eq_defaultness(*ld, *rd) && eq_fn_sig(lf, rf) && eq_generics(lg, rg) && both(lb, rb, |l, r| eq_block(l, r)) }, - (TyAlias(box TyAliasKind(ld, lg, lb, lt)), TyAlias(box TyAliasKind(rd, rg, rb, rt))) => { + (TyAlias(ld, lg, lb, lt), TyAlias(rd, rg, rb, rt)) => { eq_defaultness(*ld, *rd) && eq_generics(lg, rg) && over(lb, rb, |l, r| eq_generic_bound(l, r)) diff --git a/src/tools/clippy/clippy_lints/src/utils/constants.rs b/src/tools/clippy/clippy_lints/src/utils/constants.rs new file mode 100644 index 0000000000000..522932f054d89 --- /dev/null +++ b/src/tools/clippy/clippy_lints/src/utils/constants.rs @@ -0,0 +1,13 @@ +//! This module contains some useful constants. + +#![deny(clippy::missing_docs_in_private_items)] + +/// List of the built-in types names. +/// +/// See also [the reference][reference-types] for a list of such types. +/// +/// [reference-types]: https://doc.rust-lang.org/reference/types.html +pub const BUILTIN_TYPES: &[&str] = &[ + "i8", "u8", "i16", "u16", "i32", "u32", "i64", "u64", "i128", "u128", "isize", "usize", "f32", "f64", "bool", + "str", "char", +]; diff --git a/src/tools/clippy/clippy_lints/src/utils/diagnostics.rs b/src/tools/clippy/clippy_lints/src/utils/diagnostics.rs index 269be217c2d87..6caa04f651fae 100644 --- a/src/tools/clippy/clippy_lints/src/utils/diagnostics.rs +++ b/src/tools/clippy/clippy_lints/src/utils/diagnostics.rs @@ -110,7 +110,7 @@ pub fn span_lint_and_help<'a, T: LintContext>( pub fn span_lint_and_note<'a, T: LintContext>( cx: &'a T, lint: &'static Lint, - span: impl Into, + span: Span, msg: &str, note_span: Option, note: &str, diff --git a/src/tools/clippy/clippy_lints/src/utils/internal_lints.rs b/src/tools/clippy/clippy_lints/src/utils/internal_lints.rs index cccad243e1b59..822863ca3e279 100644 --- a/src/tools/clippy/clippy_lints/src/utils/internal_lints.rs +++ b/src/tools/clippy/clippy_lints/src/utils/internal_lints.rs @@ -760,7 +760,7 @@ impl<'tcx> LateLintPass<'tcx> for MatchTypeOnDiagItem { // Extract the path to the matched type if let Some(segments) = path_to_matched_type(cx, ty_path); let segments: Vec<&str> = segments.iter().map(|sym| &**sym).collect(); - if let Some(ty_did) = path_to_res(cx, &segments[..]).opt_def_id(); + if let Some(ty_did) = path_to_res(cx, &segments[..]).and_then(|res| res.opt_def_id()); // Check if the matched type is a diagnostic item let diag_items = cx.tcx.diagnostic_items(ty_did.krate); if let Some(item_name) = diag_items.iter().find_map(|(k, v)| if *v == ty_did { Some(k) } else { None }); @@ -833,7 +833,7 @@ fn path_to_matched_type(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> Option, path: &[&str]) -> bool { - if path_to_res(cx, path) != Res::Err { + if path_to_res(cx, path).is_some() { return true; } @@ -906,7 +906,7 @@ impl<'tcx> LateLintPass<'tcx> for InterningDefinedSymbol { } for &module in &[&paths::KW_MODULE, &paths::SYM_MODULE] { - if let Some(def_id) = path_to_res(cx, module).opt_def_id() { + if let Some(Res::Def(_, def_id)) = path_to_res(cx, module) { for item in cx.tcx.item_children(def_id).iter() { if_chain! { if let Res::Def(DefKind::Const, item_def_id) = item.res; diff --git a/src/tools/clippy/clippy_lints/src/utils/mod.rs b/src/tools/clippy/clippy_lints/src/utils/mod.rs index de1538233a8c3..d0db3a67533bc 100644 --- a/src/tools/clippy/clippy_lints/src/utils/mod.rs +++ b/src/tools/clippy/clippy_lints/src/utils/mod.rs @@ -8,6 +8,7 @@ pub mod author; pub mod camel_case; pub mod comparisons; pub mod conf; +pub mod constants; mod diagnostics; pub mod eager_or_lazy; pub mod higher; @@ -308,15 +309,7 @@ pub fn match_path_ast(path: &ast::Path, segments: &[&str]) -> bool { /// Gets the definition associated to a path. #[allow(clippy::shadow_unrelated)] // false positive #6563 -pub fn path_to_res(cx: &LateContext<'_>, path: &[&str]) -> Res { - macro_rules! try_res { - ($e:expr) => { - match $e { - Some(e) => e, - None => return Res::Err, - } - }; - } +pub fn path_to_res(cx: &LateContext<'_>, path: &[&str]) -> Option { fn item_child_by_name<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, name: &str) -> Option<&'tcx Export> { tcx.item_children(def_id) .iter() @@ -325,12 +318,12 @@ pub fn path_to_res(cx: &LateContext<'_>, path: &[&str]) -> Res { let (krate, first, path) = match *path { [krate, first, ref path @ ..] => (krate, first, path), - _ => return Res::Err, + _ => return None, }; let tcx = cx.tcx; let crates = tcx.crates(); - let krate = try_res!(crates.iter().find(|&&num| tcx.crate_name(num).as_str() == krate)); - let first = try_res!(item_child_by_name(tcx, krate.as_def_id(), first)); + let krate = crates.iter().find(|&&num| tcx.crate_name(num).as_str() == krate)?; + let first = item_child_by_name(tcx, krate.as_def_id(), first)?; let last = path .iter() .copied() @@ -350,15 +343,21 @@ pub fn path_to_res(cx: &LateContext<'_>, path: &[&str]) -> Res { } else { None } - }); - try_res!(last).res + })?; + Some(last.res) } /// Convenience function to get the `DefId` of a trait by path. /// It could be a trait or trait alias. pub fn get_trait_def_id(cx: &LateContext<'_>, path: &[&str]) -> Option { - match path_to_res(cx, path) { + let res = match path_to_res(cx, path) { + Some(res) => res, + None => return None, + }; + + match res { Res::Def(DefKind::Trait | DefKind::TraitAlias, trait_id) => Some(trait_id), + Res::Err => unreachable!("this trait resolution is impossible: {:?}", &path), _ => None, } } @@ -1533,11 +1532,10 @@ pub fn fn_def_id(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option { ExprKind::Call( Expr { kind: ExprKind::Path(qpath), - hir_id: path_hir_id, .. }, .., - ) => cx.typeck_results().qpath_res(qpath, *path_hir_id).opt_def_id(), + ) => cx.typeck_results().qpath_res(qpath, expr.hir_id).opt_def_id(), _ => None, } } diff --git a/src/tools/clippy/clippy_lints/src/write.rs b/src/tools/clippy/clippy_lints/src/write.rs index 978a232bcfb3a..6358104eedad1 100644 --- a/src/tools/clippy/clippy_lints/src/write.rs +++ b/src/tools/clippy/clippy_lints/src/write.rs @@ -3,9 +3,7 @@ use std::ops::Range; use crate::utils::{snippet_with_applicability, span_lint, span_lint_and_sugg, span_lint_and_then}; use if_chain::if_chain; -use rustc_ast::ast::{ - Expr, ExprKind, ImplKind, Item, ItemKind, LitKind, MacCall, StrLit, StrStyle, -}; +use rustc_ast::ast::{Expr, ExprKind, Item, ItemKind, LitKind, MacCall, StrLit, StrStyle}; use rustc_ast::token; use rustc_ast::tokenstream::TokenStream; use rustc_errors::Applicability; @@ -233,10 +231,10 @@ impl_lint_pass!(Write => [ impl EarlyLintPass for Write { fn check_item(&mut self, _: &EarlyContext<'_>, item: &Item) { - if let ItemKind::Impl(box ImplKind { + if let ItemKind::Impl { of_trait: Some(trait_ref), .. - }) = &item.kind + } = &item.kind { let trait_name = trait_ref .path @@ -379,15 +377,10 @@ impl Write { /// (Some("string to write: {}"), Some(buf)) /// ``` #[allow(clippy::too_many_lines)] - fn check_tts<'a>( - &self, - cx: &EarlyContext<'a>, - tts: TokenStream, - is_write: bool, - ) -> (Option, Option) { + fn check_tts<'a>(&self, cx: &EarlyContext<'a>, tts: TokenStream, is_write: bool) -> (Option, Option) { use rustc_parse_format::{ - AlignUnknown, ArgumentImplicitlyIs, ArgumentIs, ArgumentNamed, CountImplied, - FormatSpec, ParseMode, Parser, Piece, + AlignUnknown, ArgumentImplicitlyIs, ArgumentIs, ArgumentNamed, CountImplied, FormatSpec, ParseMode, Parser, + Piece, }; let mut parser = parser::Parser::new(&cx.sess.parse_sess, tts, false, None); @@ -417,12 +410,7 @@ impl Write { if let Piece::NextArgument(arg) = piece { if !self.in_debug_impl && arg.format.ty == "?" { // FIXME: modify rustc's fmt string parser to give us the current span - span_lint( - cx, - USE_DEBUG, - parser.prev_token.span, - "use of `Debug`-based formatting", - ); + span_lint(cx, USE_DEBUG, parser.prev_token.span, "use of `Debug`-based formatting"); } args.push(arg); } @@ -450,9 +438,7 @@ impl Write { return (Some(fmtstr), None); }; match &token_expr.kind { - ExprKind::Lit(lit) - if !matches!(lit.kind, LitKind::Int(..) | LitKind::Float(..)) => - { + ExprKind::Lit(lit) if !matches!(lit.kind, LitKind::Int(..) | LitKind::Float(..)) => { let mut all_simple = true; let mut seen = false; for arg in &args { @@ -462,15 +448,15 @@ impl Write { all_simple &= arg.format == SIMPLE; seen = true; } - } - ArgumentNamed(_) => {} + }, + ArgumentNamed(_) => {}, } } if all_simple && seen { span_lint(cx, lint, token_expr.span, "literal with an empty format string"); } idx += 1; - } + }, ExprKind::Assign(lhs, rhs, _) => { if_chain! { if let ExprKind::Lit(ref lit) = rhs.kind; @@ -495,7 +481,7 @@ impl Write { } } } - } + }, _ => idx += 1, } } @@ -527,17 +513,11 @@ impl Write { cx, PRINT_WITH_NEWLINE, mac.span(), - &format!( - "using `{}!()` with a format string that ends in a single newline", - name - ), + &format!("using `{}!()` with a format string that ends in a single newline", name), |err| { err.multipart_suggestion( &format!("use `{}!` instead", suggested), - vec![ - (mac.path.span, suggested), - (newline_span(&fmt_str), String::new()), - ], + vec![(mac.path.span, suggested), (newline_span(&fmt_str), String::new())], Applicability::MachineApplicable, ); }, diff --git a/src/tools/clippy/doc/adding_lints.md b/src/tools/clippy/doc/adding_lints.md index 8fd1dea9aeef9..fd2a7d171d020 100644 --- a/src/tools/clippy/doc/adding_lints.md +++ b/src/tools/clippy/doc/adding_lints.md @@ -581,15 +581,15 @@ in the following steps: 3. Passing the configuration value to the lint impl struct: First find the struct construction in the [clippy_lints lib file](/clippy_lints/src/lib.rs). - The configuration value is now cloned or copied into a local value that is then passed to the - impl struct like this: + Make sure that `clippy dev update_lints` added it beforehand. The configuration value is now + cloned or copied into a local value that is then passed to the impl struct like this: ```rust // Default generated registration: - store.register_*_pass(|| box module::StructName); + store.register_late_pass(|| box module::StructName); // New registration with configuration value let configuration_ident = conf.configuration_ident.clone(); - store.register_*_pass(move || box module::StructName::new(configuration_ident)); + store.register_late_pass(move || box module::StructName::new(configuration_ident)); ``` Congratulations the work is almost done. The configuration value can now be accessed @@ -599,7 +599,7 @@ in the following steps: 1. The default configured value can be tested like any normal lint in [`tests/ui`](/tests/ui). 2. The configuration itself will be tested separately in [`tests/ui-toml`](/tests/ui-toml). Simply add a new subfolder with a fitting name. This folder contains a `clippy.toml` file - with the configuration value and a rust file that should be linted by Clippy. The test can + with the configuration value and a rust file that should be linted by clippy. The test can otherwise be written as usual. ## Cheatsheet diff --git a/src/tools/clippy/doc/basics.md b/src/tools/clippy/doc/basics.md index a9416f3b20b7a..57f83bdf32bc2 100644 --- a/src/tools/clippy/doc/basics.md +++ b/src/tools/clippy/doc/basics.md @@ -109,7 +109,7 @@ See . | HIR | High-Level Intermediate Representation | | TCX | Type context | -This is a concise list of abbreviations that can come up during Clippy development. An extensive +This is a concise list of abbreviations that can come up during clippy development. An extensive general list can be found in the [rustc-dev-guide glossary][glossary]. Always feel free to ask if an abbreviation or meaning is unclear to you. diff --git a/src/tools/clippy/mini-macro/src/lib.rs b/src/tools/clippy/mini-macro/src/lib.rs index 2b793589049ba..ba946563ec595 100644 --- a/src/tools/clippy/mini-macro/src/lib.rs +++ b/src/tools/clippy/mini-macro/src/lib.rs @@ -7,9 +7,6 @@ extern crate proc_macro; use proc_macro::{quote, TokenStream}; #[proc_macro_derive(ClippyMiniMacroTest)] -/// # Panics -/// -/// Panics if the macro derivation fails pub fn mini_macro(_: TokenStream) -> TokenStream { quote!( #[allow(unused)] diff --git a/src/tools/clippy/rust-toolchain b/src/tools/clippy/rust-toolchain index b617203bef6d8..f55d55d706587 100644 --- a/src/tools/clippy/rust-toolchain +++ b/src/tools/clippy/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2021-02-03" +channel = "nightly-2021-01-30" components = ["llvm-tools-preview", "rustc-dev", "rust-src", "rustfmt"] diff --git a/src/tools/clippy/tests/missing-test-files.rs b/src/tools/clippy/tests/missing-test-files.rs index 9cef7438d225c..d87bb4be3c3f9 100644 --- a/src/tools/clippy/tests/missing-test-files.rs +++ b/src/tools/clippy/tests/missing-test-files.rs @@ -9,12 +9,14 @@ fn test_missing_tests() { if !missing_files.is_empty() { assert!( false, - "Didn't see a test file for the following files:\n\n{}\n", - missing_files - .iter() - .map(|s| format!("\t{}", s)) - .collect::>() - .join("\n") + format!( + "Didn't see a test file for the following files:\n\n{}\n", + missing_files + .iter() + .map(|s| format!("\t{}", s)) + .collect::>() + .join("\n") + ) ); } } diff --git a/src/tools/clippy/tests/ui/assertions_on_constants.rs b/src/tools/clippy/tests/ui/assertions_on_constants.rs index e989de6540456..60d721c2f2049 100644 --- a/src/tools/clippy/tests/ui/assertions_on_constants.rs +++ b/src/tools/clippy/tests/ui/assertions_on_constants.rs @@ -1,5 +1,3 @@ -#![allow(non_fmt_panic)] - macro_rules! assert_const { ($len:expr) => { assert!($len > 0); diff --git a/src/tools/clippy/tests/ui/assertions_on_constants.stderr b/src/tools/clippy/tests/ui/assertions_on_constants.stderr index c66fdf093f514..8f09c8ce9d52a 100644 --- a/src/tools/clippy/tests/ui/assertions_on_constants.stderr +++ b/src/tools/clippy/tests/ui/assertions_on_constants.stderr @@ -1,5 +1,5 @@ error: `assert!(true)` will be optimized out by the compiler - --> $DIR/assertions_on_constants.rs:11:5 + --> $DIR/assertions_on_constants.rs:9:5 | LL | assert!(true); | ^^^^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | assert!(true); = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: `assert!(false)` should probably be replaced - --> $DIR/assertions_on_constants.rs:12:5 + --> $DIR/assertions_on_constants.rs:10:5 | LL | assert!(false); | ^^^^^^^^^^^^^^^ @@ -18,7 +18,7 @@ LL | assert!(false); = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: `assert!(true)` will be optimized out by the compiler - --> $DIR/assertions_on_constants.rs:13:5 + --> $DIR/assertions_on_constants.rs:11:5 | LL | assert!(true, "true message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -27,7 +27,7 @@ LL | assert!(true, "true message"); = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: `assert!(false, "false message")` should probably be replaced - --> $DIR/assertions_on_constants.rs:14:5 + --> $DIR/assertions_on_constants.rs:12:5 | LL | assert!(false, "false message"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -36,7 +36,7 @@ LL | assert!(false, "false message"); = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: `assert!(false, msg.to_uppercase())` should probably be replaced - --> $DIR/assertions_on_constants.rs:17:5 + --> $DIR/assertions_on_constants.rs:15:5 | LL | assert!(false, msg.to_uppercase()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -45,7 +45,7 @@ LL | assert!(false, msg.to_uppercase()); = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: `assert!(true)` will be optimized out by the compiler - --> $DIR/assertions_on_constants.rs:20:5 + --> $DIR/assertions_on_constants.rs:18:5 | LL | assert!(B); | ^^^^^^^^^^^ @@ -54,7 +54,7 @@ LL | assert!(B); = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: `assert!(false)` should probably be replaced - --> $DIR/assertions_on_constants.rs:23:5 + --> $DIR/assertions_on_constants.rs:21:5 | LL | assert!(C); | ^^^^^^^^^^^ @@ -63,7 +63,7 @@ LL | assert!(C); = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: `assert!(false, "C message")` should probably be replaced - --> $DIR/assertions_on_constants.rs:24:5 + --> $DIR/assertions_on_constants.rs:22:5 | LL | assert!(C, "C message"); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -72,7 +72,7 @@ LL | assert!(C, "C message"); = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: `debug_assert!(true)` will be optimized out by the compiler - --> $DIR/assertions_on_constants.rs:26:5 + --> $DIR/assertions_on_constants.rs:24:5 | LL | debug_assert!(true); | ^^^^^^^^^^^^^^^^^^^^ diff --git a/src/tools/clippy/tests/ui/doc_panics.rs b/src/tools/clippy/tests/ui/doc_panics.rs deleted file mode 100644 index 7ef932f367b10..0000000000000 --- a/src/tools/clippy/tests/ui/doc_panics.rs +++ /dev/null @@ -1,95 +0,0 @@ -#![warn(clippy::missing_panics_doc)] -#![allow(clippy::option_map_unit_fn)] - -fn main() {} - -/// This needs to be documented -pub fn unwrap() { - let result = Err("Hi"); - result.unwrap() -} - -/// This needs to be documented -pub fn panic() { - panic!("This function panics") -} - -/// This needs to be documented -pub fn todo() { - todo!() -} - -/// This needs to be documented -pub fn inner_body(opt: Option) { - opt.map(|x| { - if x == 10 { - panic!() - } - }); -} - -/// This is documented -/// -/// # Panics -/// -/// Panics if `result` if an error -pub fn unwrap_documented() { - let result = Err("Hi"); - result.unwrap() -} - -/// This is documented -/// -/// # Panics -/// -/// Panics just because -pub fn panic_documented() { - panic!("This function panics") -} - -/// This is documented -/// -/// # Panics -/// -/// Panics if `opt` is Just(10) -pub fn inner_body_documented(opt: Option) { - opt.map(|x| { - if x == 10 { - panic!() - } - }); -} - -/// This is documented -/// -/// # Panics -/// -/// We still need to do this part -pub fn todo_documented() { - todo!() -} - -/// This is okay because it is private -fn unwrap_private() { - let result = Err("Hi"); - result.unwrap() -} - -/// This is okay because it is private -fn panic_private() { - panic!("This function panics") -} - -/// This is okay because it is private -fn todo_private() { - todo!() -} - -/// This is okay because it is private -fn inner_body_private(opt: Option) { - opt.map(|x| { - if x == 10 { - panic!() - } - }); -} diff --git a/src/tools/clippy/tests/ui/doc_panics.stderr b/src/tools/clippy/tests/ui/doc_panics.stderr deleted file mode 100644 index c0c4e9e4fa7ee..0000000000000 --- a/src/tools/clippy/tests/ui/doc_panics.stderr +++ /dev/null @@ -1,67 +0,0 @@ -error: docs for function which may panic missing `# Panics` section - --> $DIR/doc_panics.rs:7:1 - | -LL | / pub fn unwrap() { -LL | | let result = Err("Hi"); -LL | | result.unwrap() -LL | | } - | |_^ - | - = note: `-D clippy::missing-panics-doc` implied by `-D warnings` -note: first possible panic found here - --> $DIR/doc_panics.rs:9:5 - | -LL | result.unwrap() - | ^^^^^^^^^^^^^^^ - -error: docs for function which may panic missing `# Panics` section - --> $DIR/doc_panics.rs:13:1 - | -LL | / pub fn panic() { -LL | | panic!("This function panics") -LL | | } - | |_^ - | -note: first possible panic found here - --> $DIR/doc_panics.rs:14:5 - | -LL | panic!("This function panics") - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: docs for function which may panic missing `# Panics` section - --> $DIR/doc_panics.rs:18:1 - | -LL | / pub fn todo() { -LL | | todo!() -LL | | } - | |_^ - | -note: first possible panic found here - --> $DIR/doc_panics.rs:19:5 - | -LL | todo!() - | ^^^^^^^ - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: docs for function which may panic missing `# Panics` section - --> $DIR/doc_panics.rs:23:1 - | -LL | / pub fn inner_body(opt: Option) { -LL | | opt.map(|x| { -LL | | if x == 10 { -LL | | panic!() -LL | | } -LL | | }); -LL | | } - | |_^ - | -note: first possible panic found here - --> $DIR/doc_panics.rs:26:13 - | -LL | panic!() - | ^^^^^^^^ - = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 4 previous errors - diff --git a/src/tools/clippy/tests/ui/exhaustive_items.fixed b/src/tools/clippy/tests/ui/exhaustive_items.fixed index c209f5b4b7278..8174a0175ab32 100644 --- a/src/tools/clippy/tests/ui/exhaustive_items.fixed +++ b/src/tools/clippy/tests/ui/exhaustive_items.fixed @@ -56,36 +56,27 @@ pub mod enums { pub mod structs { #[non_exhaustive] pub struct Exhaustive { - pub foo: u8, - pub bar: String, + foo: u8, + bar: String, } // no warning, already non_exhaustive #[non_exhaustive] pub struct NonExhaustive { - pub foo: u8, - pub bar: String, - } - - // no warning, private fields - pub struct ExhaustivePrivateFieldTuple(u8); - - // no warning, private fields - pub struct ExhaustivePrivateField { - pub foo: u8, + foo: u8, bar: String, } // no warning, private struct ExhaustivePrivate { - pub foo: u8, - pub bar: String, + foo: u8, + bar: String, } // no warning, private #[non_exhaustive] struct NonExhaustivePrivate { - pub foo: u8, - pub bar: String, + foo: u8, + bar: String, } } diff --git a/src/tools/clippy/tests/ui/exhaustive_items.rs b/src/tools/clippy/tests/ui/exhaustive_items.rs index 6f59dbf2da59b..b476f09f8a087 100644 --- a/src/tools/clippy/tests/ui/exhaustive_items.rs +++ b/src/tools/clippy/tests/ui/exhaustive_items.rs @@ -53,36 +53,27 @@ pub mod enums { pub mod structs { pub struct Exhaustive { - pub foo: u8, - pub bar: String, + foo: u8, + bar: String, } // no warning, already non_exhaustive #[non_exhaustive] pub struct NonExhaustive { - pub foo: u8, - pub bar: String, - } - - // no warning, private fields - pub struct ExhaustivePrivateFieldTuple(u8); - - // no warning, private fields - pub struct ExhaustivePrivateField { - pub foo: u8, + foo: u8, bar: String, } // no warning, private struct ExhaustivePrivate { - pub foo: u8, - pub bar: String, + foo: u8, + bar: String, } // no warning, private #[non_exhaustive] struct NonExhaustivePrivate { - pub foo: u8, - pub bar: String, + foo: u8, + bar: String, } } diff --git a/src/tools/clippy/tests/ui/exhaustive_items.stderr b/src/tools/clippy/tests/ui/exhaustive_items.stderr index 8fbab535a9b25..7369fe75a4f74 100644 --- a/src/tools/clippy/tests/ui/exhaustive_items.stderr +++ b/src/tools/clippy/tests/ui/exhaustive_items.stderr @@ -41,8 +41,8 @@ error: exported structs should not be exhaustive --> $DIR/exhaustive_items.rs:55:5 | LL | / pub struct Exhaustive { -LL | | pub foo: u8, -LL | | pub bar: String, +LL | | foo: u8, +LL | | bar: String, LL | | } | |_____^ | diff --git a/src/tools/clippy/tests/ui/expect_fun_call.fixed b/src/tools/clippy/tests/ui/expect_fun_call.fixed index a756d1cf50659..f3d8a941a92bc 100644 --- a/src/tools/clippy/tests/ui/expect_fun_call.fixed +++ b/src/tools/clippy/tests/ui/expect_fun_call.fixed @@ -74,12 +74,12 @@ fn main() { "foo" } - Some("foo").unwrap_or_else(|| { panic!("{}", get_string()) }); - Some("foo").unwrap_or_else(|| { panic!("{}", get_string()) }); - Some("foo").unwrap_or_else(|| { panic!("{}", get_string()) }); + Some("foo").unwrap_or_else(|| { panic!(get_string()) }); + Some("foo").unwrap_or_else(|| { panic!(get_string()) }); + Some("foo").unwrap_or_else(|| { panic!(get_string()) }); - Some("foo").unwrap_or_else(|| { panic!("{}", get_static_str()) }); - Some("foo").unwrap_or_else(|| { panic!("{}", get_non_static_str(&0).to_string()) }); + Some("foo").unwrap_or_else(|| { panic!(get_static_str()) }); + Some("foo").unwrap_or_else(|| { panic!(get_non_static_str(&0).to_string()) }); } //Issue #3839 diff --git a/src/tools/clippy/tests/ui/expect_fun_call.stderr b/src/tools/clippy/tests/ui/expect_fun_call.stderr index 6dc796f5cee37..a492e2df89d47 100644 --- a/src/tools/clippy/tests/ui/expect_fun_call.stderr +++ b/src/tools/clippy/tests/ui/expect_fun_call.stderr @@ -34,31 +34,31 @@ error: use of `expect` followed by a function call --> $DIR/expect_fun_call.rs:77:21 | LL | Some("foo").expect(&get_string()); - | ^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!("{}", get_string()) })` + | ^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!(get_string()) })` error: use of `expect` followed by a function call --> $DIR/expect_fun_call.rs:78:21 | LL | Some("foo").expect(get_string().as_ref()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!("{}", get_string()) })` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!(get_string()) })` error: use of `expect` followed by a function call --> $DIR/expect_fun_call.rs:79:21 | LL | Some("foo").expect(get_string().as_str()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!("{}", get_string()) })` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!(get_string()) })` error: use of `expect` followed by a function call --> $DIR/expect_fun_call.rs:81:21 | LL | Some("foo").expect(get_static_str()); - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!("{}", get_static_str()) })` + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!(get_static_str()) })` error: use of `expect` followed by a function call --> $DIR/expect_fun_call.rs:82:21 | LL | Some("foo").expect(get_non_static_str(&0)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!("{}", get_non_static_str(&0).to_string()) })` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `unwrap_or_else(|| { panic!(get_non_static_str(&0).to_string()) })` error: use of `expect` followed by a function call --> $DIR/expect_fun_call.rs:86:16 diff --git a/src/tools/clippy/tests/ui/fallible_impl_from.rs b/src/tools/clippy/tests/ui/fallible_impl_from.rs index 5d5af4e463297..679f4a7dc357d 100644 --- a/src/tools/clippy/tests/ui/fallible_impl_from.rs +++ b/src/tools/clippy/tests/ui/fallible_impl_from.rs @@ -36,7 +36,7 @@ impl From> for Invalid { fn from(s: Option) -> Invalid { let s = s.unwrap(); if !s.is_empty() { - panic!("42"); + panic!(42); } else if s.parse::().unwrap() != 42 { panic!("{:?}", s); } diff --git a/src/tools/clippy/tests/ui/fallible_impl_from.stderr b/src/tools/clippy/tests/ui/fallible_impl_from.stderr index f787b30bdabc5..ab976b947b356 100644 --- a/src/tools/clippy/tests/ui/fallible_impl_from.stderr +++ b/src/tools/clippy/tests/ui/fallible_impl_from.stderr @@ -59,8 +59,8 @@ note: potential failure(s) LL | let s = s.unwrap(); | ^^^^^^^^^^ LL | if !s.is_empty() { -LL | panic!("42"); - | ^^^^^^^^^^^^^ +LL | panic!(42); + | ^^^^^^^^^^^ LL | } else if s.parse::().unwrap() != 42 { | ^^^^^^^^^^^^^^^^^^^^^^^^^ LL | panic!("{:?}", s); diff --git a/src/tools/clippy/tests/ui/let_and_return.rs b/src/tools/clippy/tests/ui/let_and_return.rs index e3561863c1e1f..73e550b3df891 100644 --- a/src/tools/clippy/tests/ui/let_and_return.rs +++ b/src/tools/clippy/tests/ui/let_and_return.rs @@ -117,11 +117,7 @@ mod no_lint_if_stmt_borrows { fn drop(&mut self) {} } - impl<'a> Foo<'a> { - fn new(inner: &'a Inner) -> Self { - Self { inner } - } - + impl Foo<'_> { fn value(&self) -> i32 { 42 } @@ -136,12 +132,6 @@ mod no_lint_if_stmt_borrows { let value = some_foo(&x).value(); value } - - fn test2() -> i32 { - let x = Inner {}; - let value = Foo::new(&x).value(); - value - } } } diff --git a/src/tools/clippy/tests/ui/let_and_return.stderr b/src/tools/clippy/tests/ui/let_and_return.stderr index a6941dabeb88d..fe878e5f20601 100644 --- a/src/tools/clippy/tests/ui/let_and_return.stderr +++ b/src/tools/clippy/tests/ui/let_and_return.stderr @@ -28,7 +28,7 @@ LL | 5 | error: returning the result of a `let` binding from a block - --> $DIR/let_and_return.rs:164:13 + --> $DIR/let_and_return.rs:154:13 | LL | let clone = Arc::clone(&self.foo); | ---------------------------------- unnecessary `let` binding diff --git a/src/tools/clippy/tests/ui/match_overlapping_arm.rs b/src/tools/clippy/tests/ui/match_overlapping_arm.rs index 44c51e8112a7d..97789bb766f89 100644 --- a/src/tools/clippy/tests/ui/match_overlapping_arm.rs +++ b/src/tools/clippy/tests/ui/match_overlapping_arm.rs @@ -57,36 +57,6 @@ fn overlapping() { _ => (), } - match 42 { - 5..7 => println!("5 .. 7"), - 0..10 => println!("0 .. 10"), - _ => (), - } - - match 42 { - 5..10 => println!("5 .. 10"), - 0..=10 => println!("0 ... 10"), - _ => (), - } - - match 42 { - 0..14 => println!("0 .. 14"), - 5..10 => println!("5 .. 10"), - _ => (), - } - - match 42 { - 5..14 => println!("5 .. 14"), - 0..=10 => println!("0 ... 10"), - _ => (), - } - - match 42 { - 0..7 => println!("0 .. 7"), - 0..=10 => println!("0 ... 10"), - _ => (), - } - /* // FIXME(JohnTitor): uncomment this once rustfmt knows half-open patterns match 42 { diff --git a/src/tools/clippy/tests/ui/match_overlapping_arm.stderr b/src/tools/clippy/tests/ui/match_overlapping_arm.stderr index f25a66d634e88..eb20d5405a95e 100644 --- a/src/tools/clippy/tests/ui/match_overlapping_arm.stderr +++ b/src/tools/clippy/tests/ui/match_overlapping_arm.stderr @@ -24,39 +24,39 @@ LL | FOO..=11 => println!("0 ... 11"), | ^^^^^^^^ error: some ranges overlap - --> $DIR/match_overlapping_arm.rs:55:9 + --> $DIR/match_overlapping_arm.rs:26:9 | -LL | 0..11 => println!("0 .. 11"), +LL | 0..=5 => println!("0 ... 5"), | ^^^^^ | note: overlaps with this - --> $DIR/match_overlapping_arm.rs:56:9 + --> $DIR/match_overlapping_arm.rs:25:9 | -LL | 0..=11 => println!("0 ... 11"), - | ^^^^^^ +LL | 2 => println!("2"), + | ^ error: some ranges overlap - --> $DIR/match_overlapping_arm.rs:80:9 + --> $DIR/match_overlapping_arm.rs:32:9 | -LL | 0..=10 => println!("0 ... 10"), - | ^^^^^^ +LL | 0..=2 => println!("0 ... 2"), + | ^^^^^ | note: overlaps with this - --> $DIR/match_overlapping_arm.rs:79:9 + --> $DIR/match_overlapping_arm.rs:31:9 | -LL | 5..14 => println!("5 .. 14"), - | ^^^^^ +LL | 2 => println!("2"), + | ^ error: some ranges overlap - --> $DIR/match_overlapping_arm.rs:85:9 + --> $DIR/match_overlapping_arm.rs:55:9 | -LL | 0..7 => println!("0 .. 7"), - | ^^^^ +LL | 0..11 => println!("0 .. 11"), + | ^^^^^ | note: overlaps with this - --> $DIR/match_overlapping_arm.rs:86:9 + --> $DIR/match_overlapping_arm.rs:56:9 | -LL | 0..=10 => println!("0 ... 10"), +LL | 0..=11 => println!("0 ... 11"), | ^^^^^^ error: aborting due to 5 previous errors diff --git a/src/tools/clippy/tests/ui/should_impl_trait/corner_cases.rs b/src/tools/clippy/tests/ui/should_impl_trait/corner_cases.rs index a7f8f54f2be04..6c5ffe6aba8b7 100644 --- a/src/tools/clippy/tests/ui/should_impl_trait/corner_cases.rs +++ b/src/tools/clippy/tests/ui/should_impl_trait/corner_cases.rs @@ -8,8 +8,7 @@ clippy::unused_self, clippy::needless_lifetimes, clippy::missing_safety_doc, - clippy::wrong_self_convention, - clippy::missing_panics_doc + clippy::wrong_self_convention )] use std::ops::Mul; diff --git a/src/tools/clippy/tests/ui/should_impl_trait/method_list_1.rs b/src/tools/clippy/tests/ui/should_impl_trait/method_list_1.rs index 69a3390b03b0b..f8d248fc98d82 100644 --- a/src/tools/clippy/tests/ui/should_impl_trait/method_list_1.rs +++ b/src/tools/clippy/tests/ui/should_impl_trait/method_list_1.rs @@ -8,8 +8,7 @@ clippy::unused_self, clippy::needless_lifetimes, clippy::missing_safety_doc, - clippy::wrong_self_convention, - clippy::missing_panics_doc + clippy::wrong_self_convention )] use std::ops::Mul; diff --git a/src/tools/clippy/tests/ui/should_impl_trait/method_list_1.stderr b/src/tools/clippy/tests/ui/should_impl_trait/method_list_1.stderr index 86c63946516ce..2b7d4628c3fa0 100644 --- a/src/tools/clippy/tests/ui/should_impl_trait/method_list_1.stderr +++ b/src/tools/clippy/tests/ui/should_impl_trait/method_list_1.stderr @@ -1,5 +1,5 @@ error: method `add` can be confused for the standard trait method `std::ops::Add::add` - --> $DIR/method_list_1.rs:26:5 + --> $DIR/method_list_1.rs:25:5 | LL | / pub fn add(self, other: T) -> T { LL | | unimplemented!() @@ -10,7 +10,7 @@ LL | | } = help: consider implementing the trait `std::ops::Add` or choosing a less ambiguous method name error: method `as_mut` can be confused for the standard trait method `std::convert::AsMut::as_mut` - --> $DIR/method_list_1.rs:30:5 + --> $DIR/method_list_1.rs:29:5 | LL | / pub fn as_mut(&mut self) -> &mut T { LL | | unimplemented!() @@ -20,7 +20,7 @@ LL | | } = help: consider implementing the trait `std::convert::AsMut` or choosing a less ambiguous method name error: method `as_ref` can be confused for the standard trait method `std::convert::AsRef::as_ref` - --> $DIR/method_list_1.rs:34:5 + --> $DIR/method_list_1.rs:33:5 | LL | / pub fn as_ref(&self) -> &T { LL | | unimplemented!() @@ -30,7 +30,7 @@ LL | | } = help: consider implementing the trait `std::convert::AsRef` or choosing a less ambiguous method name error: method `bitand` can be confused for the standard trait method `std::ops::BitAnd::bitand` - --> $DIR/method_list_1.rs:38:5 + --> $DIR/method_list_1.rs:37:5 | LL | / pub fn bitand(self, rhs: T) -> T { LL | | unimplemented!() @@ -40,7 +40,7 @@ LL | | } = help: consider implementing the trait `std::ops::BitAnd` or choosing a less ambiguous method name error: method `bitor` can be confused for the standard trait method `std::ops::BitOr::bitor` - --> $DIR/method_list_1.rs:42:5 + --> $DIR/method_list_1.rs:41:5 | LL | / pub fn bitor(self, rhs: Self) -> Self { LL | | unimplemented!() @@ -50,7 +50,7 @@ LL | | } = help: consider implementing the trait `std::ops::BitOr` or choosing a less ambiguous method name error: method `bitxor` can be confused for the standard trait method `std::ops::BitXor::bitxor` - --> $DIR/method_list_1.rs:46:5 + --> $DIR/method_list_1.rs:45:5 | LL | / pub fn bitxor(self, rhs: Self) -> Self { LL | | unimplemented!() @@ -60,7 +60,7 @@ LL | | } = help: consider implementing the trait `std::ops::BitXor` or choosing a less ambiguous method name error: method `borrow` can be confused for the standard trait method `std::borrow::Borrow::borrow` - --> $DIR/method_list_1.rs:50:5 + --> $DIR/method_list_1.rs:49:5 | LL | / pub fn borrow(&self) -> &str { LL | | unimplemented!() @@ -70,7 +70,7 @@ LL | | } = help: consider implementing the trait `std::borrow::Borrow` or choosing a less ambiguous method name error: method `borrow_mut` can be confused for the standard trait method `std::borrow::BorrowMut::borrow_mut` - --> $DIR/method_list_1.rs:54:5 + --> $DIR/method_list_1.rs:53:5 | LL | / pub fn borrow_mut(&mut self) -> &mut str { LL | | unimplemented!() @@ -80,7 +80,7 @@ LL | | } = help: consider implementing the trait `std::borrow::BorrowMut` or choosing a less ambiguous method name error: method `clone` can be confused for the standard trait method `std::clone::Clone::clone` - --> $DIR/method_list_1.rs:58:5 + --> $DIR/method_list_1.rs:57:5 | LL | / pub fn clone(&self) -> Self { LL | | unimplemented!() @@ -90,7 +90,7 @@ LL | | } = help: consider implementing the trait `std::clone::Clone` or choosing a less ambiguous method name error: method `cmp` can be confused for the standard trait method `std::cmp::Ord::cmp` - --> $DIR/method_list_1.rs:62:5 + --> $DIR/method_list_1.rs:61:5 | LL | / pub fn cmp(&self, other: &Self) -> Self { LL | | unimplemented!() @@ -100,7 +100,7 @@ LL | | } = help: consider implementing the trait `std::cmp::Ord` or choosing a less ambiguous method name error: method `deref` can be confused for the standard trait method `std::ops::Deref::deref` - --> $DIR/method_list_1.rs:70:5 + --> $DIR/method_list_1.rs:69:5 | LL | / pub fn deref(&self) -> &Self { LL | | unimplemented!() @@ -110,7 +110,7 @@ LL | | } = help: consider implementing the trait `std::ops::Deref` or choosing a less ambiguous method name error: method `deref_mut` can be confused for the standard trait method `std::ops::DerefMut::deref_mut` - --> $DIR/method_list_1.rs:74:5 + --> $DIR/method_list_1.rs:73:5 | LL | / pub fn deref_mut(&mut self) -> &mut Self { LL | | unimplemented!() @@ -120,7 +120,7 @@ LL | | } = help: consider implementing the trait `std::ops::DerefMut` or choosing a less ambiguous method name error: method `div` can be confused for the standard trait method `std::ops::Div::div` - --> $DIR/method_list_1.rs:78:5 + --> $DIR/method_list_1.rs:77:5 | LL | / pub fn div(self, rhs: Self) -> Self { LL | | unimplemented!() @@ -130,7 +130,7 @@ LL | | } = help: consider implementing the trait `std::ops::Div` or choosing a less ambiguous method name error: method `drop` can be confused for the standard trait method `std::ops::Drop::drop` - --> $DIR/method_list_1.rs:82:5 + --> $DIR/method_list_1.rs:81:5 | LL | / pub fn drop(&mut self) { LL | | unimplemented!() diff --git a/src/tools/clippy/tests/ui/should_impl_trait/method_list_2.rs b/src/tools/clippy/tests/ui/should_impl_trait/method_list_2.rs index 2cdc1a06fe689..ed5e0d384bf50 100644 --- a/src/tools/clippy/tests/ui/should_impl_trait/method_list_2.rs +++ b/src/tools/clippy/tests/ui/should_impl_trait/method_list_2.rs @@ -8,8 +8,7 @@ clippy::unused_self, clippy::needless_lifetimes, clippy::missing_safety_doc, - clippy::wrong_self_convention, - clippy::missing_panics_doc + clippy::wrong_self_convention )] use std::ops::Mul; diff --git a/src/tools/clippy/tests/ui/should_impl_trait/method_list_2.stderr b/src/tools/clippy/tests/ui/should_impl_trait/method_list_2.stderr index 0142e2991081c..b6fd435695698 100644 --- a/src/tools/clippy/tests/ui/should_impl_trait/method_list_2.stderr +++ b/src/tools/clippy/tests/ui/should_impl_trait/method_list_2.stderr @@ -1,5 +1,5 @@ error: method `eq` can be confused for the standard trait method `std::cmp::PartialEq::eq` - --> $DIR/method_list_2.rs:27:5 + --> $DIR/method_list_2.rs:26:5 | LL | / pub fn eq(&self, other: &Self) -> bool { LL | | unimplemented!() @@ -10,7 +10,7 @@ LL | | } = help: consider implementing the trait `std::cmp::PartialEq` or choosing a less ambiguous method name error: method `from_iter` can be confused for the standard trait method `std::iter::FromIterator::from_iter` - --> $DIR/method_list_2.rs:31:5 + --> $DIR/method_list_2.rs:30:5 | LL | / pub fn from_iter(iter: T) -> Self { LL | | unimplemented!() @@ -20,7 +20,7 @@ LL | | } = help: consider implementing the trait `std::iter::FromIterator` or choosing a less ambiguous method name error: method `from_str` can be confused for the standard trait method `std::str::FromStr::from_str` - --> $DIR/method_list_2.rs:35:5 + --> $DIR/method_list_2.rs:34:5 | LL | / pub fn from_str(s: &str) -> Result { LL | | unimplemented!() @@ -30,7 +30,7 @@ LL | | } = help: consider implementing the trait `std::str::FromStr` or choosing a less ambiguous method name error: method `hash` can be confused for the standard trait method `std::hash::Hash::hash` - --> $DIR/method_list_2.rs:39:5 + --> $DIR/method_list_2.rs:38:5 | LL | / pub fn hash(&self, state: &mut T) { LL | | unimplemented!() @@ -40,7 +40,7 @@ LL | | } = help: consider implementing the trait `std::hash::Hash` or choosing a less ambiguous method name error: method `index` can be confused for the standard trait method `std::ops::Index::index` - --> $DIR/method_list_2.rs:43:5 + --> $DIR/method_list_2.rs:42:5 | LL | / pub fn index(&self, index: usize) -> &Self { LL | | unimplemented!() @@ -50,7 +50,7 @@ LL | | } = help: consider implementing the trait `std::ops::Index` or choosing a less ambiguous method name error: method `index_mut` can be confused for the standard trait method `std::ops::IndexMut::index_mut` - --> $DIR/method_list_2.rs:47:5 + --> $DIR/method_list_2.rs:46:5 | LL | / pub fn index_mut(&mut self, index: usize) -> &mut Self { LL | | unimplemented!() @@ -60,7 +60,7 @@ LL | | } = help: consider implementing the trait `std::ops::IndexMut` or choosing a less ambiguous method name error: method `into_iter` can be confused for the standard trait method `std::iter::IntoIterator::into_iter` - --> $DIR/method_list_2.rs:51:5 + --> $DIR/method_list_2.rs:50:5 | LL | / pub fn into_iter(self) -> Self { LL | | unimplemented!() @@ -70,7 +70,7 @@ LL | | } = help: consider implementing the trait `std::iter::IntoIterator` or choosing a less ambiguous method name error: method `mul` can be confused for the standard trait method `std::ops::Mul::mul` - --> $DIR/method_list_2.rs:55:5 + --> $DIR/method_list_2.rs:54:5 | LL | / pub fn mul(self, rhs: Self) -> Self { LL | | unimplemented!() @@ -80,7 +80,7 @@ LL | | } = help: consider implementing the trait `std::ops::Mul` or choosing a less ambiguous method name error: method `neg` can be confused for the standard trait method `std::ops::Neg::neg` - --> $DIR/method_list_2.rs:59:5 + --> $DIR/method_list_2.rs:58:5 | LL | / pub fn neg(self) -> Self { LL | | unimplemented!() @@ -90,7 +90,7 @@ LL | | } = help: consider implementing the trait `std::ops::Neg` or choosing a less ambiguous method name error: method `next` can be confused for the standard trait method `std::iter::Iterator::next` - --> $DIR/method_list_2.rs:63:5 + --> $DIR/method_list_2.rs:62:5 | LL | / pub fn next(&mut self) -> Option { LL | | unimplemented!() @@ -100,7 +100,7 @@ LL | | } = help: consider implementing the trait `std::iter::Iterator` or choosing a less ambiguous method name error: method `not` can be confused for the standard trait method `std::ops::Not::not` - --> $DIR/method_list_2.rs:67:5 + --> $DIR/method_list_2.rs:66:5 | LL | / pub fn not(self) -> Self { LL | | unimplemented!() @@ -110,7 +110,7 @@ LL | | } = help: consider implementing the trait `std::ops::Not` or choosing a less ambiguous method name error: method `rem` can be confused for the standard trait method `std::ops::Rem::rem` - --> $DIR/method_list_2.rs:71:5 + --> $DIR/method_list_2.rs:70:5 | LL | / pub fn rem(self, rhs: Self) -> Self { LL | | unimplemented!() @@ -120,7 +120,7 @@ LL | | } = help: consider implementing the trait `std::ops::Rem` or choosing a less ambiguous method name error: method `shl` can be confused for the standard trait method `std::ops::Shl::shl` - --> $DIR/method_list_2.rs:75:5 + --> $DIR/method_list_2.rs:74:5 | LL | / pub fn shl(self, rhs: Self) -> Self { LL | | unimplemented!() @@ -130,7 +130,7 @@ LL | | } = help: consider implementing the trait `std::ops::Shl` or choosing a less ambiguous method name error: method `shr` can be confused for the standard trait method `std::ops::Shr::shr` - --> $DIR/method_list_2.rs:79:5 + --> $DIR/method_list_2.rs:78:5 | LL | / pub fn shr(self, rhs: Self) -> Self { LL | | unimplemented!() @@ -140,7 +140,7 @@ LL | | } = help: consider implementing the trait `std::ops::Shr` or choosing a less ambiguous method name error: method `sub` can be confused for the standard trait method `std::ops::Sub::sub` - --> $DIR/method_list_2.rs:83:5 + --> $DIR/method_list_2.rs:82:5 | LL | / pub fn sub(self, rhs: Self) -> Self { LL | | unimplemented!() diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index cde4bfe288d2e..c8e767432310a 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -240,8 +240,8 @@ pub struct Config { /// Run ignored tests pub run_ignored: bool, - /// Only run tests that match these filters - pub filters: Vec, + /// Only run tests that match this filter + pub filter: Option, /// Exactly match the filter, rather than a substring pub filter_exact: bool, diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 429a8c98cd57c..2eba91fd1f4cf 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -333,8 +333,6 @@ pub struct TestProps { pub assembly_output: Option, // If true, the test is expected to ICE pub should_ice: bool, - // If true, the stderr is expected to be different across bit-widths. - pub stderr_per_bitwidth: bool, } impl TestProps { @@ -374,7 +372,6 @@ impl TestProps { rustfix_only_machine_applicable: false, assembly_output: None, should_ice: false, - stderr_per_bitwidth: false, } } @@ -541,10 +538,6 @@ impl TestProps { if self.assembly_output.is_none() { self.assembly_output = config.parse_assembly_output(ln); } - - if !self.stderr_per_bitwidth { - self.stderr_per_bitwidth = config.parse_stderr_per_bitwidth(ln); - } }); } @@ -781,10 +774,6 @@ impl Config { self.parse_name_directive(line, "ignore-pass") } - fn parse_stderr_per_bitwidth(&self, line: &str) -> bool { - self.parse_name_directive(line, "stderr-per-bitwidth") - } - fn parse_assembly_output(&self, line: &str) -> Option { self.parse_name_value_directive(line, "assembly-output").map(|r| r.trim().to_string()) } diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index 3fde24e8a7fba..688cf930033ef 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -221,7 +221,7 @@ pub fn parse_config(args: Vec) -> Config { suite: matches.opt_str("suite").unwrap(), debugger: None, run_ignored, - filters: matches.free.clone(), + filter: matches.free.first().cloned(), filter_exact: matches.opt_present("exact"), force_pass_mode: matches.opt_str("pass").map(|mode| { mode.parse::() @@ -280,7 +280,7 @@ pub fn log_config(config: &Config) { logv(c, format!("stage_id: {}", config.stage_id)); logv(c, format!("mode: {}", config.mode)); logv(c, format!("run_ignored: {}", config.run_ignored)); - logv(c, format!("filters: {:?}", config.filters)); + logv(c, format!("filter: {}", opt_str(&config.filter))); logv(c, format!("filter_exact: {}", config.filter_exact)); logv( c, @@ -465,7 +465,7 @@ fn configure_lldb(config: &Config) -> Option { pub fn test_opts(config: &Config) -> test::TestOpts { test::TestOpts { exclude_should_panic: false, - filters: config.filters.clone(), + filter: config.filter.clone(), filter_exact: config.filter_exact, run_ignored: if config.run_ignored { test::RunIgnored::Yes } else { test::RunIgnored::No }, format: if config.quiet { test::OutputFormat::Terse } else { test::OutputFormat::Pretty }, diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 1ec32184d9898..52aed57fc76af 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -3124,12 +3124,7 @@ impl<'test> TestCx<'test> { errors += self.compare_output("stdout", &normalized_stdout, &expected_stdout); } if !self.props.dont_check_compiler_stderr { - let kind = if self.props.stderr_per_bitwidth { - format!("{}bit.stderr", get_pointer_width(&self.config.target)) - } else { - String::from("stderr") - }; - errors += self.compare_output(&kind, &normalized_stderr, &expected_stderr); + errors += self.compare_output("stderr", &normalized_stderr, &expected_stderr); } } TestOutput::Run => { diff --git a/src/tools/compiletest/src/util.rs b/src/tools/compiletest/src/util.rs index 292850bd9e277..1647df8044ccc 100644 --- a/src/tools/compiletest/src/util.rs +++ b/src/tools/compiletest/src/util.rs @@ -38,7 +38,6 @@ const OS_TABLE: &[(&str, &str)] = &[ const ARCH_TABLE: &[(&str, &str)] = &[ ("aarch64", "aarch64"), - ("aarch64_be", "aarch64"), ("amd64", "x86_64"), ("arm", "arm"), ("arm64", "aarch64"), @@ -111,7 +110,6 @@ pub const TSAN_SUPPORTED_TARGETS: &[&str] = &[ ]; const BIG_ENDIAN: &[&str] = &[ - "aarch64_be", "armebv7r", "mips", "mips64", @@ -162,9 +160,7 @@ pub fn matches_env(triple: &str, name: &str) -> bool { } pub fn get_pointer_width(triple: &str) -> &'static str { - if (triple.contains("64") && !triple.ends_with("gnux32") && !triple.ends_with("gnu_ilp32")) - || triple.starts_with("s390x") - { + if (triple.contains("64") && !triple.ends_with("gnux32")) || triple.starts_with("s390x") { "64bit" } else if triple.starts_with("avr") { "16bit" diff --git a/src/tools/miri b/src/tools/miri index e09dce0f43993..8d24b02414073 160000 --- a/src/tools/miri +++ b/src/tools/miri @@ -1 +1 @@ -Subproject commit e09dce0f43993faf03cc46ac365b6a46287f90e7 +Subproject commit 8d24b02414073bd4dafd3810205265c668dbcae1 diff --git a/src/tools/remote-test-server/src/main.rs b/src/tools/remote-test-server/src/main.rs index cd9d530096496..d92758eb7474c 100644 --- a/src/tools/remote-test-server/src/main.rs +++ b/src/tools/remote-test-server/src/main.rs @@ -218,19 +218,25 @@ fn handle_run(socket: TcpStream, work: &Path, tmp: &Path, lock: &Mutex<()>, conf cmd.args(args); cmd.envs(env); - // On windows, libraries are just searched in the executable directory, - // system directories, PWD, and PATH, in that order. PATH is the only one - // we can change for this. - let library_path = if cfg!(windows) { "PATH" } else { "LD_LIBRARY_PATH" }; - // Support libraries were uploaded to `work` earlier, so make sure that's // in `LD_LIBRARY_PATH`. Also include our own current dir which may have // had some libs uploaded. - let mut paths = vec![work.to_owned(), path.clone()]; - if let Some(library_path) = env::var_os(library_path) { - paths.extend(env::split_paths(&library_path)); + if cfg!(windows) { + // On windows, libraries are just searched in the executable directory, + // system directories, PWD, and PATH, in that order. PATH is the only one + // we can change for this. + cmd.env( + "PATH", + env::join_paths( + std::iter::once(work.to_owned()) + .chain(std::iter::once(path.clone())) + .chain(env::split_paths(&env::var_os("PATH").unwrap())), + ) + .unwrap(), + ); + } else { + cmd.env("LD_LIBRARY_PATH", format!("{}:{}", work.display(), path.display())); } - cmd.env(library_path, env::join_paths(paths).unwrap()); // Some tests assume RUST_TEST_TMPDIR exists cmd.env("RUST_TEST_TMPDIR", tmp.to_owned()); diff --git a/src/tools/rust-analyzer b/src/tools/rust-analyzer index 336909b63a14b..1a59f75cdaa73 160000 --- a/src/tools/rust-analyzer +++ b/src/tools/rust-analyzer @@ -1 +1 @@ -Subproject commit 336909b63a14b801520c6627d90d750babcfe280 +Subproject commit 1a59f75cdaa730c16a694a4294eccf6dfe6fe0ad diff --git a/src/tools/tidy/src/style.rs b/src/tools/tidy/src/style.rs index 9f68c55ec975c..6697fbd1be2de 100644 --- a/src/tools/tidy/src/style.rs +++ b/src/tools/tidy/src/style.rs @@ -18,8 +18,6 @@ use std::path::Path; -/// Error code markdown is restricted to 80 columns because they can be -/// displayed on the console with --example. const ERROR_CODE_COLS: usize = 80; const COLS: usize = 100; @@ -57,9 +55,9 @@ enum LIUState { /// Lines of this form are allowed to be overlength, because Markdown /// offers no way to split a line in the middle of a URL, and the lengths /// of URLs to external references are beyond our control. -fn line_is_url(is_error_code: bool, columns: usize, line: &str) -> bool { - // more basic check for markdown, to avoid complexity in implementing two state machines - if is_error_code { +fn line_is_url(columns: usize, line: &str) -> bool { + // more basic check for error_codes.rs, to avoid complexity in implementing two state machines + if columns == ERROR_CODE_COLS { return line.starts_with('[') && line.contains("]:") && line.contains("http"); } @@ -95,13 +93,8 @@ fn line_is_url(is_error_code: bool, columns: usize, line: &str) -> bool { /// Returns `true` if `line` is allowed to be longer than the normal limit. /// Currently there is only one exception, for long URLs, but more /// may be added in the future. -fn long_line_is_ok(extension: &str, is_error_code: bool, max_columns: usize, line: &str) -> bool { - if extension != "md" || is_error_code { - if line_is_url(is_error_code, max_columns, line) { - return true; - } - } else if extension == "md" { - // non-error code markdown is allowed to be any length +fn long_line_is_ok(max_columns: usize, line: &str) -> bool { + if line_is_url(max_columns, line) { return true; } @@ -165,36 +158,8 @@ pub fn is_in(full_path: &Path, parent_folder_to_find: &str, folder_to_find: &str } } -fn skip_markdown_path(path: &Path) -> bool { - // These aren't ready for tidy. - const SKIP_MD: &[&str] = &[ - "src/doc/edition-guide", - "src/doc/embedded-book", - "src/doc/nomicon", - "src/doc/reference", - "src/doc/rust-by-example", - "src/doc/rustc-dev-guide", - ]; - SKIP_MD.iter().any(|p| path.ends_with(p)) -} - -fn is_unexplained_ignore(extension: &str, line: &str) -> bool { - if !line.ends_with("```ignore") && !line.ends_with("```rust,ignore") { - return false; - } - if extension == "md" && line.trim().starts_with("//") { - // Markdown examples may include doc comments with ignore inside a - // code block. - return false; - } - true -} - pub fn check(path: &Path, bad: &mut bool) { - fn skip(path: &Path) -> bool { - super::filter_dirs(path) || skip_markdown_path(path) - } - super::walk(path, &mut skip, &mut |entry, contents| { + super::walk(path, &mut super::filter_dirs, &mut |entry, contents| { let file = entry.path(); let filename = file.file_name().unwrap().to_string_lossy(); let extensions = [".rs", ".py", ".js", ".sh", ".c", ".cpp", ".h", ".md", ".css"]; @@ -211,6 +176,13 @@ pub fn check(path: &Path, bad: &mut bool) { a.ends_with("src/doc/book") }); + if filename.ends_with(".md") + && file.parent().unwrap().file_name().unwrap().to_string_lossy() != "error_codes" + { + // We don't want to check all ".md" files (almost of of them aren't compliant + // currently), just the long error code explanation ones. + return; + } if is_style_file && !is_in(file, "src", "librustdoc") { // We only check CSS files in rustdoc. return; @@ -220,10 +192,11 @@ pub fn check(path: &Path, bad: &mut bool) { tidy_error!(bad, "{}: empty file", file.display()); } - let extension = file.extension().unwrap().to_string_lossy(); - let is_error_code = extension == "md" && is_in(file, "src", "error_codes"); - - let max_columns = if is_error_code { ERROR_CODE_COLS } else { COLS }; + let max_columns = if filename == "error_codes.rs" || filename.ends_with(".md") { + ERROR_CODE_COLS + } else { + COLS + }; let can_contain = contents.contains("// ignore-tidy-") || contents.contains("# ignore-tidy-") @@ -254,7 +227,7 @@ pub fn check(path: &Path, bad: &mut bool) { }; if !under_rustfmt && line.chars().count() > max_columns - && !long_line_is_ok(&extension, is_error_code, max_columns, line) + && !long_line_is_ok(max_columns, line) { suppressible_tidy_err!( err, @@ -307,7 +280,7 @@ pub fn check(path: &Path, bad: &mut bool) { "copyright notices attributed to the Rust Project Developers are deprecated" ); } - if is_unexplained_ignore(&extension, line) { + if line.ends_with("```ignore") || line.ends_with("```rust,ignore") { err(UNEXPLAINED_IGNORE_DOCTEST_INFO); } if filename.ends_with(".cpp") && line.contains("llvm_unreachable") { diff --git a/src/version b/src/version index a63cb35e6f0b4..ba0a719118cee 100644 --- a/src/version +++ b/src/version @@ -1 +1 @@ -1.52.0 +1.51.0 From 851b33aa1ee4114b34d70eb3e7184cbb1e516af4 Mon Sep 17 00:00:00 2001 From: Rust timing bot Date: Tue, 9 Feb 2021 18:17:19 +0100 Subject: [PATCH 2/2] rust-timer simulated merge of a1887912e8a9dc3c190814d27ba00f5f488c6cd3 Original message: Rollup merge of #80629 - sexxi-goose:migrations_1, r=nikomatsakis Add lint for 2229 migrations Implements the first for RFC 2229 where we make the decision to migrate a root variable based on if the type of the variable needs Drop and if the root variable would be moved into the closure when the feature isn't enabled. r? `@nikomatsakis` --- compiler/rustc_lint_defs/src/builtin.rs | 46 ++++ compiler/rustc_typeck/src/check/upvar.rs | 242 ++++++++++++++---- compiler/rustc_typeck/src/check/writeback.rs | 6 +- .../migrations/insignificant_drop.rs | 130 ++++++++++ .../migrations/insignificant_drop.stderr | 105 ++++++++ .../migrations/no_migrations.rs | 84 ++++++ .../migrations/significant_drop.rs | 137 ++++++++++ .../migrations/significant_drop.stderr | 103 ++++++++ .../escape-upvar-nested.stderr | 8 +- .../escape-upvar-ref.stderr | 4 +- 10 files changed, 812 insertions(+), 53 deletions(-) create mode 100644 src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.rs create mode 100644 src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.stderr create mode 100644 src/test/ui/closures/2229_closure_analysis/migrations/no_migrations.rs create mode 100644 src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.rs create mode 100644 src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index a8bf1ce51bb74..199be00990761 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -2968,6 +2968,7 @@ declare_lint_pass! { UNSUPPORTED_NAKED_FUNCTIONS, MISSING_ABI, SEMICOLON_IN_EXPRESSIONS_FROM_MACROS, + DISJOINT_CAPTURE_DROP_REORDER, ] } @@ -2994,6 +2995,51 @@ declare_lint! { "detects doc comments that aren't used by rustdoc" } +declare_lint! { + /// The `disjoint_capture_drop_reorder` lint detects variables that aren't completely + /// captured when the feature `capture_disjoint_fields` is enabled and it affects the Drop + /// order of at least one path starting at this variable. + /// + /// ### Example + /// + /// ```rust,compile_fail + /// # #![deny(disjoint_capture_drop_reorder)] + /// # #![allow(unused)] + /// struct FancyInteger(i32); + /// + /// impl Drop for FancyInteger { + /// fn drop(&mut self) { + /// println!("Just dropped {}", self.0); + /// } + /// } + /// + /// struct Point { x: FancyInteger, y: FancyInteger } + /// + /// fn main() { + /// let p = Point { x: FancyInteger(10), y: FancyInteger(20) }; + /// + /// let c = || { + /// let x = p.x; + /// }; + /// + /// c(); + /// + /// // ... More code ... + /// } + /// ``` + /// + /// {{produces}} + /// + /// ### Explanation + /// + /// In the above example `p.y` will be dropped at the end of `f` instead of with `c` if + /// the feature `capture_disjoint_fields` is enabled. + pub DISJOINT_CAPTURE_DROP_REORDER, + Allow, + "Drop reorder because of `capture_disjoint_fields`" + +} + declare_lint_pass!(UnusedDocComment => [UNUSED_DOC_COMMENTS]); declare_lint! { diff --git a/compiler/rustc_typeck/src/check/upvar.rs b/compiler/rustc_typeck/src/check/upvar.rs index f039445bf7780..04a9e65e6647d 100644 --- a/compiler/rustc_typeck/src/check/upvar.rs +++ b/compiler/rustc_typeck/src/check/upvar.rs @@ -30,6 +30,7 @@ //! then mean that all later passes would have to check for these figments //! and report an error, and it just seems like more mess in the end.) +use super::writeback::Resolver; use super::FnCtxt; use crate::expr_use_visitor as euv; @@ -40,7 +41,9 @@ use rustc_hir::def_id::LocalDefId; use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_infer::infer::UpvarRegion; use rustc_middle::hir::place::{Place, PlaceBase, PlaceWithHirId, ProjectionKind}; -use rustc_middle::ty::{self, Ty, TyCtxt, UpvarSubsts}; +use rustc_middle::ty::fold::TypeFoldable; +use rustc_middle::ty::{self, Ty, TyCtxt, TypeckResults, UpvarSubsts}; +use rustc_session::lint; use rustc_span::sym; use rustc_span::{MultiSpan, Span, Symbol}; @@ -55,6 +58,11 @@ enum PlaceAncestryRelation { Divergent, } +/// Intermediate format to store a captured `Place` and associated `ty::CaptureInfo` +/// during capture analysis. Information in this map feeds into the minimum capture +/// analysis pass. +type InferredCaptureInformation<'tcx> = FxIndexMap, ty::CaptureInfo<'tcx>>; + impl<'a, 'tcx> FnCtxt<'a, 'tcx> { pub fn closure_analyze(&self, body: &'tcx hir::Body<'tcx>) { InferBorrowKindVisitor { fcx: self }.visit_body(body); @@ -92,7 +100,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { &self, closure_hir_id: hir::HirId, span: Span, - body: &hir::Body<'_>, + body: &'tcx hir::Body<'tcx>, capture_clause: hir::CaptureBy, ) { debug!("analyze_closure(id={:?}, body.id={:?})", closure_hir_id, body.id()); @@ -124,28 +132,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let local_def_id = closure_def_id.expect_local(); - let mut capture_information: FxIndexMap, ty::CaptureInfo<'tcx>> = - Default::default(); - if !self.tcx.features().capture_disjoint_fields { - if let Some(upvars) = self.tcx.upvars_mentioned(closure_def_id) { - for (&var_hir_id, _) in upvars.iter() { - let place = self.place_for_root_variable(local_def_id, var_hir_id); - - debug!("seed place {:?}", place); - - let upvar_id = ty::UpvarId::new(var_hir_id, local_def_id); - let capture_kind = self.init_capture_kind(capture_clause, upvar_id, span); - let info = ty::CaptureInfo { - capture_kind_expr_id: None, - path_expr_id: None, - capture_kind, - }; - - capture_information.insert(place, info); - } - } - } - let body_owner_def_id = self.tcx.hir().body_owner_def_id(body.id()); assert_eq!(body_owner_def_id.to_def_id(), closure_def_id); let mut delegate = InferBorrowKind { @@ -155,7 +141,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { capture_clause, current_closure_kind: ty::ClosureKind::LATTICE_BOTTOM, current_origin: None, - capture_information, + capture_information: Default::default(), }; euv::ExprUseVisitor::new( &mut delegate, @@ -172,6 +158,40 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { ); self.log_capture_analysis_first_pass(closure_def_id, &delegate.capture_information, span); + self.compute_min_captures(closure_def_id, delegate.capture_information); + + let closure_hir_id = self.tcx.hir().local_def_id_to_hir_id(local_def_id); + if should_do_migration_analysis(self.tcx, closure_hir_id) { + self.perform_2229_migration_anaysis(closure_def_id, capture_clause, span, body); + } + + // We now fake capture information for all variables that are mentioned within the closure + // We do this after handling migrations so that min_captures computes before + if !self.tcx.features().capture_disjoint_fields { + let mut capture_information: InferredCaptureInformation<'tcx> = Default::default(); + + if let Some(upvars) = self.tcx.upvars_mentioned(closure_def_id) { + for var_hir_id in upvars.keys() { + let place = self.place_for_root_variable(local_def_id, *var_hir_id); + + debug!("seed place {:?}", place); + + let upvar_id = ty::UpvarId::new(*var_hir_id, local_def_id); + let capture_kind = self.init_capture_kind(capture_clause, upvar_id, span); + let fake_info = ty::CaptureInfo { + capture_kind_expr_id: None, + path_expr_id: None, + capture_kind, + }; + + capture_information.insert(place, fake_info); + } + } + + // This will update the min captures based on this new fake information. + self.compute_min_captures(closure_def_id, capture_information); + } + if let Some(closure_substs) = infer_kind { // Unify the (as yet unbound) type variable in the closure // substs with the kind we inferred. @@ -197,7 +217,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } } - self.compute_min_captures(closure_def_id, delegate); self.log_closure_min_capture_info(closure_def_id, span); self.min_captures_to_closure_captures_bridge(closure_def_id); @@ -344,6 +363,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Places (and corresponding capture kind) that we need to keep track of to support all /// the required captured paths. /// + /// + /// Note: If this function is called multiple times for the same closure, it will update + /// the existing min_capture map that is stored in TypeckResults. + /// /// Eg: /// ```rust,no_run /// struct Point { x: i32, y: i32 } @@ -408,11 +431,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { fn compute_min_captures( &self, closure_def_id: DefId, - inferred_info: InferBorrowKind<'_, 'tcx>, + capture_information: InferredCaptureInformation<'tcx>, ) { - let mut root_var_min_capture_list: ty::RootVariableMinCaptureList<'_> = Default::default(); + if capture_information.is_empty() { + return; + } + + let mut typeck_results = self.typeck_results.borrow_mut(); - for (place, capture_info) in inferred_info.capture_information.into_iter() { + let mut root_var_min_capture_list = + typeck_results.closure_min_captures.remove(&closure_def_id).unwrap_or_default(); + + for (place, capture_info) in capture_information.into_iter() { let var_hir_id = match place.base { PlaceBase::Upvar(upvar_id) => upvar_id.var_path.hir_id, base => bug!("Expected upvar, found={:?}", base), @@ -422,7 +452,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let min_cap_list = match root_var_min_capture_list.get_mut(&var_hir_id) { None => { - let mutability = self.determine_capture_mutability(&place); + let mutability = self.determine_capture_mutability(&typeck_results, &place); let min_cap_list = vec![ty::CapturedPlace { place, info: capture_info, mutability }]; root_var_min_capture_list.insert(var_hir_id, min_cap_list); @@ -487,7 +517,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Only need to insert when we don't have an ancestor in the existing min capture list if !ancestor_found { - let mutability = self.determine_capture_mutability(&place); + let mutability = self.determine_capture_mutability(&typeck_results, &place); let captured_place = ty::CapturedPlace { place, info: updated_capture_info, mutability }; min_cap_list.push(captured_place); @@ -495,13 +525,121 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } debug!("For closure={:?}, min_captures={:#?}", closure_def_id, root_var_min_capture_list); + typeck_results.closure_min_captures.insert(closure_def_id, root_var_min_capture_list); + } - if !root_var_min_capture_list.is_empty() { - self.typeck_results - .borrow_mut() - .closure_min_captures - .insert(closure_def_id, root_var_min_capture_list); + /// Perform the migration analysis for RFC 2229, and emit lint + /// `disjoint_capture_drop_reorder` if needed. + fn perform_2229_migration_anaysis( + &self, + closure_def_id: DefId, + capture_clause: hir::CaptureBy, + span: Span, + body: &'tcx hir::Body<'tcx>, + ) { + let need_migrations = self.compute_2229_migrations_first_pass( + closure_def_id, + span, + capture_clause, + body, + self.typeck_results.borrow().closure_min_captures.get(&closure_def_id), + ); + + if !need_migrations.is_empty() { + let need_migrations_hir_id = need_migrations.iter().map(|m| m.0).collect::>(); + + let migrations_text = migration_suggestion_for_2229(self.tcx, &need_migrations_hir_id); + + let local_def_id = closure_def_id.expect_local(); + let closure_hir_id = self.tcx.hir().local_def_id_to_hir_id(local_def_id); + self.tcx.struct_span_lint_hir( + lint::builtin::DISJOINT_CAPTURE_DROP_REORDER, + closure_hir_id, + span, + |lint| { + let mut diagnostics_builder = lint.build( + "drop order affected for closure because of `capture_disjoint_fields`", + ); + diagnostics_builder.note(&migrations_text); + diagnostics_builder.emit(); + }, + ); + } + } + + /// Figures out the list of root variables (and their types) that aren't completely + /// captured by the closure when `capture_disjoint_fields` is enabled and drop order of + /// some path starting at that root variable **might** be affected. + /// + /// The output list would include a root variable if: + /// - It would have been moved into the closure when `capture_disjoint_fields` wasn't + /// enabled, **and** + /// - It wasn't completely captured by the closure, **and** + /// - The type of the root variable needs Drop. + fn compute_2229_migrations_first_pass( + &self, + closure_def_id: DefId, + closure_span: Span, + closure_clause: hir::CaptureBy, + body: &'tcx hir::Body<'tcx>, + min_captures: Option<&ty::RootVariableMinCaptureList<'tcx>>, + ) -> Vec<(hir::HirId, Ty<'tcx>)> { + fn resolve_ty>( + fcx: &FnCtxt<'_, 'tcx>, + span: Span, + body: &'tcx hir::Body<'tcx>, + ty: T, + ) -> T { + let mut resolver = Resolver::new(fcx, &span, body); + ty.fold_with(&mut resolver) + } + + let upvars = if let Some(upvars) = self.tcx.upvars_mentioned(closure_def_id) { + upvars + } else { + return vec![]; + }; + + let mut need_migrations = Vec::new(); + + for (&var_hir_id, _) in upvars.iter() { + let ty = resolve_ty(self, closure_span, body, self.node_ty(var_hir_id)); + + if !ty.needs_drop(self.tcx, self.tcx.param_env(closure_def_id.expect_local())) { + continue; + } + + let root_var_min_capture_list = if let Some(root_var_min_capture_list) = + min_captures.and_then(|m| m.get(&var_hir_id)) + { + root_var_min_capture_list + } else { + // The upvar is mentioned within the closure but no path starting from it is + // used. + + match closure_clause { + // Only migrate if closure is a move closure + hir::CaptureBy::Value => need_migrations.push((var_hir_id, ty)), + + hir::CaptureBy::Ref => {} + } + + continue; + }; + + let is_moved = root_var_min_capture_list + .iter() + .any(|capture| matches!(capture.info.capture_kind, ty::UpvarCapture::ByValue(_))); + + let is_not_completely_captured = + root_var_min_capture_list.iter().any(|capture| capture.place.projections.len() > 0); + + if is_moved && is_not_completely_captured { + need_migrations.push((var_hir_id, ty)); + } } + + need_migrations } fn init_capture_kind( @@ -613,18 +751,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// A captured place is mutable if /// 1. Projections don't include a Deref of an immut-borrow, **and** /// 2. PlaceBase is mut or projections include a Deref of a mut-borrow. - fn determine_capture_mutability(&self, place: &Place<'tcx>) -> hir::Mutability { + fn determine_capture_mutability( + &self, + typeck_results: &'a TypeckResults<'tcx>, + place: &Place<'tcx>, + ) -> hir::Mutability { let var_hir_id = match place.base { PlaceBase::Upvar(upvar_id) => upvar_id.var_path.hir_id, _ => unreachable!(), }; - let bm = *self - .typeck_results - .borrow() - .pat_binding_modes() - .get(var_hir_id) - .expect("missing binding mode"); + let bm = *typeck_results.pat_binding_modes().get(var_hir_id).expect("missing binding mode"); let mut is_mutbl = match bm { ty::BindByValue(mutability) => mutability, @@ -698,9 +835,11 @@ struct InferBorrowKind<'a, 'tcx> { /// /// For closure `fix_s`, (at a high level) the map contains /// + /// ``` /// Place { V1, [ProjectionKind::Field(Index=0, Variant=0)] } : CaptureKind { E1, ImmutableBorrow } /// Place { V1, [ProjectionKind::Field(Index=1, Variant=0)] } : CaptureKind { E2, MutableBorrow } - capture_information: FxIndexMap, ty::CaptureInfo<'tcx>>, + /// ``` + capture_information: InferredCaptureInformation<'tcx>, } impl<'a, 'tcx> InferBorrowKind<'a, 'tcx> { @@ -1119,6 +1258,21 @@ fn var_name(tcx: TyCtxt<'_>, var_hir_id: hir::HirId) -> Symbol { tcx.hir().name(var_hir_id) } +fn should_do_migration_analysis(tcx: TyCtxt<'_>, closure_id: hir::HirId) -> bool { + let (level, _) = + tcx.lint_level_at_node(lint::builtin::DISJOINT_CAPTURE_DROP_REORDER, closure_id); + + !matches!(level, lint::Level::Allow) +} + +fn migration_suggestion_for_2229(tcx: TyCtxt<'_>, need_migrations: &Vec) -> String { + let need_migrations_strings = + need_migrations.iter().map(|v| format!("{}", var_name(tcx, *v))).collect::>(); + let migrations_list_concat = need_migrations_strings.join(", "); + + format!("drop(&({}));", migrations_list_concat) +} + /// Helper function to determine if we need to escalate CaptureKind from /// CaptureInfo A to B and returns the escalated CaptureInfo. /// (Note: CaptureInfo contains CaptureKind and an expression that led to capture it in that way) diff --git a/compiler/rustc_typeck/src/check/writeback.rs b/compiler/rustc_typeck/src/check/writeback.rs index b6d740a4fdb57..4d18b2cb3fc49 100644 --- a/compiler/rustc_typeck/src/check/writeback.rs +++ b/compiler/rustc_typeck/src/check/writeback.rs @@ -650,7 +650,7 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> { } } -trait Locatable { +crate trait Locatable { fn to_span(&self, tcx: TyCtxt<'_>) -> Span; } @@ -668,7 +668,7 @@ impl Locatable for hir::HirId { /// The Resolver. This is the type folding engine that detects /// unresolved types and so forth. -struct Resolver<'cx, 'tcx> { +crate struct Resolver<'cx, 'tcx> { tcx: TyCtxt<'tcx>, infcx: &'cx InferCtxt<'cx, 'tcx>, span: &'cx dyn Locatable, @@ -679,7 +679,7 @@ struct Resolver<'cx, 'tcx> { } impl<'cx, 'tcx> Resolver<'cx, 'tcx> { - fn new( + crate fn new( fcx: &'cx FnCtxt<'cx, 'tcx>, span: &'cx dyn Locatable, body: &'tcx hir::Body<'tcx>, diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.rs b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.rs new file mode 100644 index 0000000000000..02b373620966e --- /dev/null +++ b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.rs @@ -0,0 +1,130 @@ +#![deny(disjoint_capture_drop_reorder)] +//~^ NOTE: the lint level is defined here + +// Test cases for types that implement a insignificant drop (stlib defined) + +// `t` needs Drop because one of its elements needs drop, +// therefore precise capture might affect drop ordering +fn test1_all_need_migration() { + let t = (String::new(), String::new()); + let t1 = (String::new(), String::new()); + let t2 = (String::new(), String::new()); + + let c = || { + //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` + //~| NOTE: drop(&(t, t1, t2)); + let _t = t.0; + let _t1 = t1.0; + let _t2 = t2.0; + }; + + c(); +} + +// String implements drop and therefore should be migrated. +// But in this test cases, `t2` is completely captured and when it is dropped won't be affected +fn test2_only_precise_paths_need_migration() { + let t = (String::new(), String::new()); + let t1 = (String::new(), String::new()); + let t2 = (String::new(), String::new()); + + let c = || { + //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` + //~| NOTE: drop(&(t, t1)); + let _t = t.0; + let _t1 = t1.0; + let _t2 = t2; + }; + + c(); +} + +// If a variable would've not been captured by value then it would've not been +// dropped with the closure and therefore doesn't need migration. +fn test3_only_by_value_need_migration() { + let t = (String::new(), String::new()); + let t1 = (String::new(), String::new()); + let c = || { + //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` + //~| NOTE: drop(&(t)); + let _t = t.0; + println!("{}", t1.1); + }; + + c(); +} + +// Copy types get copied into the closure instead of move. Therefore we don't need to +// migrate then as their drop order isn't tied to the closure. +fn test4_only_non_copy_types_need_migration() { + let t = (String::new(), String::new()); + + // `t1` is Copy because all of its elements are Copy + let t1 = (0i32, 0i32); + + let c = || { + //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` + //~| NOTE: drop(&(t)); + let _t = t.0; + let _t1 = t1.0; + }; + + c(); +} + +fn test5_only_drop_types_need_migration() { + struct S(i32, i32); + + let t = (String::new(), String::new()); + + // `s` doesn't implement Drop or any elements within it, and doesn't need migration + let s = S(0i32, 0i32); + + let c = || { + //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` + //~| NOTE: drop(&(t)); + let _t = t.0; + let _s = s.0; + }; + + c(); +} + +// Since we are using a move closure here, both `t` and `t1` get moved +// even though they are being used by ref inside the closure. +fn test6_move_closures_non_copy_types_might_need_migration() { + let t = (String::new(), String::new()); + let t1 = (String::new(), String::new()); + let c = move || { + //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` + //~| NOTE: drop(&(t1, t)); + println!("{} {}", t1.1, t.1); + }; + + c(); +} + +// Test migration analysis in case of Drop + Non Drop aggregates. +// Note we need migration here only because the non-copy (because Drop type) is captured, +// otherwise we won't need to, since we can get away with just by ref capture in that case. +fn test7_drop_non_drop_aggregate_need_migration() { + let t = (String::new(), String::new(), 0i32); + + let c = || { + //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` + //~| NOTE: drop(&(t)); + let _t = t.0; + }; + + c(); +} + +fn main() { + test1_all_need_migration(); + test2_only_precise_paths_need_migration(); + test3_only_by_value_need_migration(); + test4_only_non_copy_types_need_migration(); + test5_only_drop_types_need_migration(); + test6_move_closures_non_copy_types_might_need_migration(); + test7_drop_non_drop_aggregate_need_migration(); +} diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.stderr new file mode 100644 index 0000000000000..656c132c12dee --- /dev/null +++ b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.stderr @@ -0,0 +1,105 @@ +error: drop order affected for closure because of `capture_disjoint_fields` + --> $DIR/insignificant_drop.rs:13:13 + | +LL | let c = || { + | _____________^ +LL | | +LL | | +LL | | let _t = t.0; +LL | | let _t1 = t1.0; +LL | | let _t2 = t2.0; +LL | | }; + | |_____^ + | +note: the lint level is defined here + --> $DIR/insignificant_drop.rs:1:9 + | +LL | #![deny(disjoint_capture_drop_reorder)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: drop(&(t, t1, t2)); + +error: drop order affected for closure because of `capture_disjoint_fields` + --> $DIR/insignificant_drop.rs:31:13 + | +LL | let c = || { + | _____________^ +LL | | +LL | | +LL | | let _t = t.0; +LL | | let _t1 = t1.0; +LL | | let _t2 = t2; +LL | | }; + | |_____^ + | + = note: drop(&(t, t1)); + +error: drop order affected for closure because of `capture_disjoint_fields` + --> $DIR/insignificant_drop.rs:47:13 + | +LL | let c = || { + | _____________^ +LL | | +LL | | +LL | | let _t = t.0; +LL | | println!("{}", t1.1); +LL | | }; + | |_____^ + | + = note: drop(&(t)); + +error: drop order affected for closure because of `capture_disjoint_fields` + --> $DIR/insignificant_drop.rs:65:13 + | +LL | let c = || { + | _____________^ +LL | | +LL | | +LL | | let _t = t.0; +LL | | let _t1 = t1.0; +LL | | }; + | |_____^ + | + = note: drop(&(t)); + +error: drop order affected for closure because of `capture_disjoint_fields` + --> $DIR/insignificant_drop.rs:83:13 + | +LL | let c = || { + | _____________^ +LL | | +LL | | +LL | | let _t = t.0; +LL | | let _s = s.0; +LL | | }; + | |_____^ + | + = note: drop(&(t)); + +error: drop order affected for closure because of `capture_disjoint_fields` + --> $DIR/insignificant_drop.rs:98:13 + | +LL | let c = move || { + | _____________^ +LL | | +LL | | +LL | | println!("{} {}", t1.1, t.1); +LL | | }; + | |_____^ + | + = note: drop(&(t1, t)); + +error: drop order affected for closure because of `capture_disjoint_fields` + --> $DIR/insignificant_drop.rs:113:13 + | +LL | let c = || { + | _____________^ +LL | | +LL | | +LL | | let _t = t.0; +LL | | }; + | |_____^ + | + = note: drop(&(t)); + +error: aborting due to 7 previous errors + diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/no_migrations.rs b/src/test/ui/closures/2229_closure_analysis/migrations/no_migrations.rs new file mode 100644 index 0000000000000..73592ce04c28f --- /dev/null +++ b/src/test/ui/closures/2229_closure_analysis/migrations/no_migrations.rs @@ -0,0 +1,84 @@ +// run-pass + +// Set of test cases that don't need migrations + +#![deny(disjoint_capture_drop_reorder)] + + +// Copy types as copied by the closure instead of being moved into the closure +// Therefore their drop order isn't tied to the closure and won't be requiring any +// migrations. +fn test1_only_copy_types() { + let t = (0i32, 0i32); + + let c = || { + let _t = t.0; + }; + + c(); +} + +// Same as test1 but using a move closure +fn test2_only_copy_types_move_closure() { + let t = (0i32, 0i32); + + let c = move || { + println!("{}", t.0); + }; + + c(); +} + +// Don't need to migrate if captured by ref +fn test3_only_copy_types_move_closure() { + let t = (String::new(), String::new()); + + let c = || { + println!("{}", t.0); + }; + + c(); +} + +// Test migration analysis in case of Insignificant Drop + Non Drop aggregates. +// Note in this test the closure captures a non Drop type and therefore the variable +// is only captured by ref. +fn test4_insignificant_drop_non_drop_aggregate() { + let t = (String::new(), 0i32); + + let c = || { + let _t = t.1; + }; + + c(); +} + + +struct Foo(i32); +impl Drop for Foo { + fn drop(&mut self) { + println!("{:?} dropped", self.0); + } +} + +// Test migration analysis in case of Significant Drop + Non Drop aggregates. +// Note in this test the closure captures a non Drop type and therefore the variable +// is only captured by ref. +fn test5_significant_drop_non_drop_aggregate() { + let t = (Foo(0), 0i32); + + let c = || { + let _t = t.1; + }; + + c(); +} + +fn main() { + test1_only_copy_types(); + test2_only_copy_types_move_closure(); + test3_only_copy_types_move_closure(); + test4_insignificant_drop_non_drop_aggregate(); + test5_significant_drop_non_drop_aggregate(); + +} diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.rs b/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.rs new file mode 100644 index 0000000000000..ed5e4ea8be011 --- /dev/null +++ b/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.rs @@ -0,0 +1,137 @@ +#![deny(disjoint_capture_drop_reorder)] +//~^ NOTE: the lint level is defined here + +// Test cases for types that implement a significant drop (user defined) + +#[derive(Debug)] +struct Foo(i32); +impl Drop for Foo { + fn drop(&mut self) { + println!("{:?} dropped", self.0); + } +} + +#[derive(Debug)] +struct ConstainsDropField(Foo, Foo); + +// `t` needs Drop because one of its elements needs drop, +// therefore precise capture might affect drop ordering +fn test1_all_need_migration() { + let t = (Foo(0), Foo(0)); + let t1 = (Foo(0), Foo(0)); + let t2 = (Foo(0), Foo(0)); + + let c = || { + //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` + //~| NOTE: drop(&(t, t1, t2)); + let _t = t.0; + let _t1 = t1.0; + let _t2 = t2.0; + }; + + c(); +} + +// String implements drop and therefore should be migrated. +// But in this test cases, `t2` is completely captured and when it is dropped won't be affected +fn test2_only_precise_paths_need_migration() { + let t = (Foo(0), Foo(0)); + let t1 = (Foo(0), Foo(0)); + let t2 = (Foo(0), Foo(0)); + + let c = || { + //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` + //~| NOTE: drop(&(t, t1)); + let _t = t.0; + let _t1 = t1.0; + let _t2 = t2; + }; + + c(); +} + +// If a variable would've not been captured by value then it would've not been +// dropped with the closure and therefore doesn't need migration. +fn test3_only_by_value_need_migration() { + let t = (Foo(0), Foo(0)); + let t1 = (Foo(0), Foo(0)); + let c = || { + //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` + //~| NOTE: drop(&(t)); + let _t = t.0; + println!("{:?}", t1.1); + }; + + c(); +} + +// The root variable might not implement drop themselves but some path starting +// at the root variable might implement Drop. +// +// If this path isn't captured we need to migrate for the root variable. +fn test4_type_contains_drop_need_migration() { + let t = ConstainsDropField(Foo(0), Foo(0)); + + let c = || { + //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` + //~| NOTE: drop(&(t)); + let _t = t.0; + }; + + c(); +} + +// Test migration analysis in case of Drop + Non Drop aggregates. +// Note we need migration here only because the non-copy (because Drop type) is captured, +// otherwise we won't need to, since we can get away with just by ref capture in that case. +fn test5_drop_non_drop_aggregate_need_migration() { + let t = (Foo(0), Foo(0), 0i32); + + let c = || { + //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` + //~| NOTE: drop(&(t)); + let _t = t.0; + }; + + c(); +} + +// Test migration analysis in case of Significant and Insignificant Drop aggregates. +fn test6_significant_insignificant_drop_aggregate_need_migration() { + struct S(i32, i32); + + let t = (Foo(0), String::new()); + + let c = || { + //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` + //~| NOTE: drop(&(t)); + let _t = t.1; + }; + + c(); +} + +// Since we are using a move closure here, both `t` and `t1` get moved +// even though they are being used by ref inside the closure. +fn test7_move_closures_non_copy_types_might_need_migration() { + let t = (Foo(0), Foo(0)); + let t1 = (Foo(0), Foo(0), Foo(0)); + + let c = move || { + //~^ERROR: drop order affected for closure because of `capture_disjoint_fields` + //~| NOTE: drop(&(t1, t)); + println!("{:?} {:?}", t1.1, t.1); + }; + + c(); +} + +fn main() { + test1_all_need_migration(); + test2_only_precise_paths_need_migration(); + test3_only_by_value_need_migration(); + test4_type_contains_drop_need_migration(); + test5_drop_non_drop_aggregate_need_migration(); + test6_significant_insignificant_drop_aggregate_need_migration(); + test7_move_closures_non_copy_types_might_need_migration(); +} diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr new file mode 100644 index 0000000000000..6c21b27b493ba --- /dev/null +++ b/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr @@ -0,0 +1,103 @@ +error: drop order affected for closure because of `capture_disjoint_fields` + --> $DIR/significant_drop.rs:24:13 + | +LL | let c = || { + | _____________^ +LL | | +LL | | +LL | | let _t = t.0; +LL | | let _t1 = t1.0; +LL | | let _t2 = t2.0; +LL | | }; + | |_____^ + | +note: the lint level is defined here + --> $DIR/significant_drop.rs:1:9 + | +LL | #![deny(disjoint_capture_drop_reorder)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: drop(&(t, t1, t2)); + +error: drop order affected for closure because of `capture_disjoint_fields` + --> $DIR/significant_drop.rs:42:13 + | +LL | let c = || { + | _____________^ +LL | | +LL | | +LL | | let _t = t.0; +LL | | let _t1 = t1.0; +LL | | let _t2 = t2; +LL | | }; + | |_____^ + | + = note: drop(&(t, t1)); + +error: drop order affected for closure because of `capture_disjoint_fields` + --> $DIR/significant_drop.rs:58:13 + | +LL | let c = || { + | _____________^ +LL | | +LL | | +LL | | let _t = t.0; +LL | | println!("{:?}", t1.1); +LL | | }; + | |_____^ + | + = note: drop(&(t)); + +error: drop order affected for closure because of `capture_disjoint_fields` + --> $DIR/significant_drop.rs:75:13 + | +LL | let c = || { + | _____________^ +LL | | +LL | | +LL | | let _t = t.0; +LL | | }; + | |_____^ + | + = note: drop(&(t)); + +error: drop order affected for closure because of `capture_disjoint_fields` + --> $DIR/significant_drop.rs:90:13 + | +LL | let c = || { + | _____________^ +LL | | +LL | | +LL | | let _t = t.0; +LL | | }; + | |_____^ + | + = note: drop(&(t)); + +error: drop order affected for closure because of `capture_disjoint_fields` + --> $DIR/significant_drop.rs:105:13 + | +LL | let c = || { + | _____________^ +LL | | +LL | | +LL | | let _t = t.1; +LL | | }; + | |_____^ + | + = note: drop(&(t)); + +error: drop order affected for closure because of `capture_disjoint_fields` + --> $DIR/significant_drop.rs:120:13 + | +LL | let c = move || { + | _____________^ +LL | | +LL | | +LL | | println!("{:?} {:?}", t1.1, t.1); +LL | | }; + | |_____^ + | + = note: drop(&(t1, t)); + +error: aborting due to 7 previous errors + diff --git a/src/test/ui/nll/closure-requirements/escape-upvar-nested.stderr b/src/test/ui/nll/closure-requirements/escape-upvar-nested.stderr index 1a8258376142a..e1b446fc61f61 100644 --- a/src/test/ui/nll/closure-requirements/escape-upvar-nested.stderr +++ b/src/test/ui/nll/closure-requirements/escape-upvar-nested.stderr @@ -7,10 +7,10 @@ LL | let mut closure1 = || p = &y; = note: defining type: test::{closure#0}::{closure#0} with closure substs [ i16, extern "rust-call" fn(()), - (&'_#1r i32, &'_#2r mut &'_#3r i32), + (&'_#1r mut &'_#2r i32, &'_#3r i32), ] = note: number of external vids: 4 - = note: where '_#1r: '_#3r + = note: where '_#3r: '_#2r note: external requirements --> $DIR/escape-upvar-nested.rs:20:27 @@ -25,10 +25,10 @@ LL | | }; = note: defining type: test::{closure#0} with closure substs [ i16, extern "rust-call" fn(()), - (&'_#1r i32, &'_#2r mut &'_#3r i32), + (&'_#1r mut &'_#2r i32, &'_#3r i32), ] = note: number of external vids: 4 - = note: where '_#1r: '_#3r + = note: where '_#3r: '_#2r note: no external requirements --> $DIR/escape-upvar-nested.rs:13:1 diff --git a/src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr b/src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr index 29fd796882b6a..0ea1076c32ef4 100644 --- a/src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr +++ b/src/test/ui/nll/closure-requirements/escape-upvar-ref.stderr @@ -7,10 +7,10 @@ LL | let mut closure = || p = &y; = note: defining type: test::{closure#0} with closure substs [ i16, extern "rust-call" fn(()), - (&'_#1r i32, &'_#2r mut &'_#3r i32), + (&'_#1r mut &'_#2r i32, &'_#3r i32), ] = note: number of external vids: 4 - = note: where '_#1r: '_#3r + = note: where '_#3r: '_#2r note: no external requirements --> $DIR/escape-upvar-ref.rs:17:1