]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #85185 - GuillaumeGomez:generate-not-more-docs-than-necessary, r...
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Sat, 15 May 2021 15:56:48 +0000 (17:56 +0200)
committerGitHub <noreply@github.com>
Sat, 15 May 2021 15:56:48 +0000 (17:56 +0200)
Generate not more docs than necessary

This is something that `@Nemo157` was talking about: they wanted that when using `x.py doc std`, it only generated `std` (and the crates "before" it).

r? `@Mark-Simulacrum`

951 files changed:
.github/workflows/ci.yml
.mailmap
Cargo.lock
compiler/rustc_ast/src/ast.rs
compiler/rustc_ast/src/mut_visit.rs
compiler/rustc_ast/src/visit.rs
compiler/rustc_ast_lowering/src/asm.rs [new file with mode: 0644]
compiler/rustc_ast_lowering/src/expr.rs
compiler/rustc_ast_lowering/src/item.rs
compiler/rustc_ast_lowering/src/lib.rs
compiler/rustc_ast_lowering/src/path.rs
compiler/rustc_ast_pretty/src/pprust/state.rs
compiler/rustc_builtin_macros/src/asm.rs
compiler/rustc_builtin_macros/src/global_asm.rs [deleted file]
compiler/rustc_builtin_macros/src/lib.rs
compiler/rustc_builtin_macros/src/source_util.rs
compiler/rustc_codegen_cranelift/src/common.rs
compiler/rustc_codegen_cranelift/src/debuginfo/line_info.rs
compiler/rustc_codegen_cranelift/src/debuginfo/mod.rs
compiler/rustc_codegen_cranelift/src/driver/aot.rs
compiler/rustc_codegen_cranelift/src/lib.rs
compiler/rustc_codegen_cranelift/src/metadata.rs
compiler/rustc_codegen_llvm/src/asm.rs
compiler/rustc_codegen_llvm/src/attributes.rs
compiler/rustc_codegen_llvm/src/base.rs
compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
compiler/rustc_codegen_llvm/src/lib.rs
compiler/rustc_codegen_llvm/src/metadata.rs [deleted file]
compiler/rustc_codegen_ssa/Cargo.toml
compiler/rustc_codegen_ssa/src/back/link.rs
compiler/rustc_codegen_ssa/src/back/linker.rs
compiler/rustc_codegen_ssa/src/back/metadata.rs [new file with mode: 0644]
compiler/rustc_codegen_ssa/src/back/mod.rs
compiler/rustc_codegen_ssa/src/back/symbol_export.rs
compiler/rustc_codegen_ssa/src/back/write.rs
compiler/rustc_codegen_ssa/src/base.rs
compiler/rustc_codegen_ssa/src/common.rs
compiler/rustc_codegen_ssa/src/coverageinfo/map.rs
compiler/rustc_codegen_ssa/src/mir/block.rs
compiler/rustc_codegen_ssa/src/mir/coverageinfo.rs
compiler/rustc_codegen_ssa/src/mir/rvalue.rs
compiler/rustc_codegen_ssa/src/mono_item.rs
compiler/rustc_codegen_ssa/src/traits/asm.rs
compiler/rustc_codegen_ssa/src/traits/mod.rs
compiler/rustc_driver/src/lib.rs
compiler/rustc_error_codes/src/error_codes/E0277.md
compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs
compiler/rustc_errors/src/emitter.rs
compiler/rustc_errors/src/json.rs
compiler/rustc_errors/src/lib.rs
compiler/rustc_expand/src/base.rs
compiler/rustc_expand/src/expand.rs
compiler/rustc_expand/src/proc_macro.rs
compiler/rustc_expand/src/proc_macro_server.rs
compiler/rustc_feature/src/active.rs
compiler/rustc_feature/src/builtin_attrs.rs
compiler/rustc_feature/src/removed.rs
compiler/rustc_hir/src/arena.rs
compiler/rustc_hir/src/hir.rs
compiler/rustc_hir/src/intravisit.rs
compiler/rustc_hir/src/lang_items.rs
compiler/rustc_hir_pretty/src/lib.rs
compiler/rustc_incremental/src/persist/load.rs
compiler/rustc_infer/src/infer/error_reporting/mod.rs
compiler/rustc_infer/src/infer/error_reporting/nice_region_error/named_anon_conflict.rs
compiler/rustc_interface/src/passes.rs
compiler/rustc_interface/src/tests.rs
compiler/rustc_lint/src/internal.rs
compiler/rustc_lint/src/non_fmt_panic.rs
compiler/rustc_lint_defs/src/builtin.rs
compiler/rustc_llvm/Cargo.toml
compiler/rustc_metadata/src/rmeta/decoder.rs
compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
compiler/rustc_metadata/src/rmeta/encoder.rs
compiler/rustc_metadata/src/rmeta/mod.rs
compiler/rustc_middle/src/hir/map/collector.rs
compiler/rustc_middle/src/ich/impls_syntax.rs
compiler/rustc_middle/src/lint.rs
compiler/rustc_middle/src/middle/resolve_lifetime.rs
compiler/rustc_middle/src/middle/stability.rs
compiler/rustc_middle/src/mir/mod.rs
compiler/rustc_middle/src/query/mod.rs
compiler/rustc_middle/src/ty/context.rs
compiler/rustc_middle/src/ty/error.rs
compiler/rustc_middle/src/ty/print/pretty.rs
compiler/rustc_middle/src/ty/query/mod.rs
compiler/rustc_middle/src/ty/query/on_disk_cache.rs
compiler/rustc_middle/src/ty/util.rs
compiler/rustc_mir/src/borrow_check/diagnostics/mutability_errors.rs
compiler/rustc_mir/src/borrow_check/region_infer/dump_mir.rs
compiler/rustc_mir/src/dataflow/move_paths/builder.rs
compiler/rustc_mir/src/interpret/cast.rs
compiler/rustc_mir/src/interpret/eval_context.rs
compiler/rustc_mir/src/interpret/intern.rs
compiler/rustc_mir/src/interpret/intrinsics/caller_location.rs
compiler/rustc_mir/src/monomorphize/collector.rs
compiler/rustc_mir/src/transform/const_goto.rs
compiler/rustc_mir/src/transform/coverage/debug.rs
compiler/rustc_mir/src/transform/coverage/mod.rs
compiler/rustc_mir/src/transform/coverage/query.rs
compiler/rustc_mir/src/transform/coverage/spans.rs
compiler/rustc_mir/src/transform/coverage/tests.rs
compiler/rustc_mir/src/transform/deduplicate_blocks.rs
compiler/rustc_mir/src/transform/early_otherwise_branch.rs
compiler/rustc_mir/src/transform/generator.rs
compiler/rustc_mir/src/transform/inline.rs
compiler/rustc_mir/src/transform/lower_intrinsics.rs
compiler/rustc_mir/src/transform/match_branches.rs
compiler/rustc_mir/src/transform/multiple_return_terminators.rs
compiler/rustc_mir/src/transform/promote_consts.rs
compiler/rustc_mir/src/transform/remove_unneeded_drops.rs
compiler/rustc_mir/src/transform/simplify.rs
compiler/rustc_mir/src/transform/simplify_try.rs
compiler/rustc_mir/src/transform/unreachable_prop.rs
compiler/rustc_mir/src/util/pretty.rs
compiler/rustc_mir/src/util/spanview.rs
compiler/rustc_mir_build/src/check_unsafety.rs [new file with mode: 0644]
compiler/rustc_mir_build/src/lib.rs
compiler/rustc_mir_build/src/thir/mod.rs
compiler/rustc_mir_build/src/thir/pattern/check_match.rs
compiler/rustc_mir_build/src/thir/pattern/deconstruct_pat.rs
compiler/rustc_mir_build/src/thir/visit.rs [new file with mode: 0644]
compiler/rustc_parse/src/lib.rs
compiler/rustc_parse/src/parser/item.rs
compiler/rustc_passes/src/check_attr.rs
compiler/rustc_passes/src/intrinsicck.rs
compiler/rustc_passes/src/liveness.rs
compiler/rustc_passes/src/region.rs
compiler/rustc_passes/src/stability.rs
compiler/rustc_resolve/src/build_reduced_graph.rs
compiler/rustc_resolve/src/late.rs
compiler/rustc_resolve/src/late/diagnostics.rs
compiler/rustc_resolve/src/late/lifetimes.rs
compiler/rustc_resolve/src/lib.rs
compiler/rustc_resolve/src/macros.rs
compiler/rustc_save_analysis/src/dump_visitor.rs
compiler/rustc_save_analysis/src/lib.rs
compiler/rustc_save_analysis/src/span_utils.rs
compiler/rustc_session/src/options.rs
compiler/rustc_session/src/parse.rs
compiler/rustc_session/src/session.rs
compiler/rustc_span/src/hygiene.rs
compiler/rustc_span/src/lib.rs
compiler/rustc_span/src/source_map.rs
compiler/rustc_span/src/source_map/tests.rs
compiler/rustc_span/src/symbol.rs
compiler/rustc_target/src/asm/mod.rs
compiler/rustc_target/src/asm/powerpc.rs [new file with mode: 0644]
compiler/rustc_trait_selection/src/lib.rs
compiler/rustc_trait_selection/src/traits/select/mod.rs
compiler/rustc_ty_utils/src/needs_drop.rs
compiler/rustc_typeck/src/astconv/generics.rs
compiler/rustc_typeck/src/astconv/mod.rs
compiler/rustc_typeck/src/check/callee.rs
compiler/rustc_typeck/src/check/expr.rs
compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs
compiler/rustc_typeck/src/check/fn_ctxt/checks.rs
compiler/rustc_typeck/src/check/method/mod.rs
compiler/rustc_typeck/src/check/method/probe.rs
compiler/rustc_typeck/src/check/mod.rs
compiler/rustc_typeck/src/check/pat.rs
compiler/rustc_typeck/src/check/upvar.rs
compiler/rustc_typeck/src/collect/type_of.rs
compiler/rustc_typeck/src/structured_errors/wrong_number_of_generic_args.rs
library/alloc/Cargo.toml
library/alloc/src/collections/btree/map.rs
library/alloc/src/collections/btree/navigate.rs
library/alloc/src/collections/btree/node.rs
library/core/src/macros/mod.rs
library/core/src/marker.rs
library/core/src/num/wrapping.rs
library/core/src/ptr/mut_ptr.rs
library/core/src/str/mod.rs
library/proc_macro/src/bridge/mod.rs
library/proc_macro/src/lib.rs
library/proc_macro/src/quote.rs
library/profiler_builtins/Cargo.toml
library/std/Cargo.toml
library/std/src/env.rs
library/std/src/lib.rs
library/std/src/macros.rs
library/std/src/panic.rs
library/std/src/path.rs
library/std/src/sys/sgx/abi/mod.rs
library/stdarch
library/unwind/Cargo.toml
src/bootstrap/Cargo.toml
src/bootstrap/doc.rs
src/bootstrap/test.rs
src/ci/channel [new file with mode: 0644]
src/ci/github-actions/ci.yml
src/ci/pgo.sh
src/ci/run.sh
src/ci/scripts/verify-channel.sh [new file with mode: 0755]
src/ci/shared.sh
src/doc/book
src/doc/nomicon
src/doc/reference
src/doc/rust-by-example
src/doc/rustc-dev-guide
src/doc/unstable-book/src/language-features/const-fn.md [deleted file]
src/doc/unstable-book/src/library-features/asm.md
src/doc/unstable-book/src/library-features/global-asm.md
src/librustdoc/clean/blanket_impl.rs
src/librustdoc/clean/mod.rs
src/librustdoc/clean/types.rs
src/librustdoc/config.rs
src/librustdoc/core.rs
src/librustdoc/doctest.rs
src/librustdoc/fold.rs
src/librustdoc/formats/cache.rs
src/librustdoc/html/layout.rs
src/librustdoc/html/markdown.rs
src/librustdoc/html/render/cache.rs
src/librustdoc/html/render/context.rs
src/librustdoc/html/render/mod.rs
src/librustdoc/html/render/print_item.rs
src/librustdoc/html/render/write_shared.rs
src/librustdoc/html/sources.rs
src/librustdoc/html/static/main.js
src/librustdoc/html/static/noscript.css
src/librustdoc/html/static/rustdoc.css
src/librustdoc/html/static/search.js
src/librustdoc/html/static/source-script.js
src/librustdoc/html/static/storage.js
src/librustdoc/html/static/themes/ayu.css
src/librustdoc/html/static/themes/dark.css
src/librustdoc/html/static/themes/light.css
src/librustdoc/json/conversions.rs
src/librustdoc/json/mod.rs
src/librustdoc/lib.rs
src/librustdoc/passes/calculate_doc_coverage.rs
src/librustdoc/passes/collect_intra_doc_links.rs
src/librustdoc/passes/collect_trait_impls.rs
src/librustdoc/passes/strip_hidden.rs
src/librustdoc/passes/stripper.rs
src/llvm-project
src/test/assembly/asm/global_asm.rs [new file with mode: 0644]
src/test/assembly/asm/powerpc-types.rs [new file with mode: 0644]
src/test/codegen/remap_path_prefix/issue-73167-remap-std.rs [new file with mode: 0644]
src/test/incremental/issue-61530.rs
src/test/incremental/issue-85197-invalid-span/auxiliary/invalid-span-helper-lib.rs [new file with mode: 0644]
src/test/incremental/issue-85197-invalid-span/auxiliary/invalid-span-helper-mod.rs [new file with mode: 0644]
src/test/incremental/issue-85197-invalid-span/auxiliary/respan.rs [new file with mode: 0644]
src/test/incremental/issue-85197-invalid-span/invalid_span_main.rs [new file with mode: 0644]
src/test/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.mir [new file with mode: 0644]
src/test/mir-opt/retag.main.SimplifyCfg-elaborate-drops.after.mir
src/test/mir-opt/retag.rs
src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.async2.txt
src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.conditions.txt
src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.doctest.txt
src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.drop_trait.txt
src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.generics.txt
src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.loops_branches.txt
src/test/run-make-fulldeps/coverage-reports/expected_show_coverage.tight_inf_loop.txt
src/test/run-make-fulldeps/coverage/conditions.rs
src/test/run-make-fulldeps/coverage/generics.rs
src/test/run-make-fulldeps/coverage/loops_branches.rs
src/test/run-make-fulldeps/hotplug_codegen_backend/the_backend.rs
src/test/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/src/main.rs
src/test/rustdoc-gui/basic-code.goml
src/test/rustdoc-gui/basic.goml
src/test/rustdoc-gui/check_info_sign_position.goml
src/test/rustdoc-gui/code-sidebar-toggle.goml
src/test/rustdoc-gui/hash-item-expansion.goml
src/test/rustdoc-gui/impl-default-expansion.goml
src/test/rustdoc-gui/lib.rs [deleted file]
src/test/rustdoc-gui/list_code_block.goml
src/test/rustdoc-gui/search-input-mobile.goml
src/test/rustdoc-gui/search-tab-selection-if-current-is-empty.goml
src/test/rustdoc-gui/shortcuts.goml
src/test/rustdoc-gui/source-code-page.goml
src/test/rustdoc-gui/src/lib.rs [new file with mode: 0644]
src/test/rustdoc-gui/theme-change.goml
src/test/rustdoc-gui/toggle-docs-mobile.goml [new file with mode: 0644]
src/test/rustdoc-gui/toggle-docs.goml
src/test/rustdoc-gui/trait-sidebar-item-order.goml
src/test/rustdoc-ui/intra-doc/warning.stderr
src/test/rustdoc/type-layout-flag-required.rs [new file with mode: 0644]
src/test/rustdoc/type-layout.rs [new file with mode: 0644]
src/test/ui-fulldeps/hash-stable-is-unstable.stderr
src/test/ui-fulldeps/internal-lints/lint_pass_impl_without_macro.stderr
src/test/ui-fulldeps/session-derive-errors.stderr
src/test/ui/allocator/not-an-allocator.stderr
src/test/ui/allocator/two-allocators.stderr
src/test/ui/asm/bad-arch.rs
src/test/ui/asm/bad-arch.stderr
src/test/ui/asm/bad-options.rs
src/test/ui/asm/bad-options.stderr
src/test/ui/asm/bad-template.rs
src/test/ui/asm/bad-template.stderr
src/test/ui/asm/const.rs
src/test/ui/asm/duplicate-options.fixed
src/test/ui/asm/duplicate-options.rs
src/test/ui/asm/duplicate-options.stderr
src/test/ui/asm/inline-syntax.arm.stderr
src/test/ui/asm/inline-syntax.rs
src/test/ui/asm/inline-syntax.x86_64.stderr
src/test/ui/asm/interpolated-idents.stderr
src/test/ui/asm/naked-functions.stderr
src/test/ui/asm/parse-error.rs
src/test/ui/asm/parse-error.stderr
src/test/ui/asm/type-check-2.rs
src/test/ui/asm/type-check-2.stderr
src/test/ui/asm/type-check-3.rs
src/test/ui/asm/type-check-3.stderr
src/test/ui/associated-consts/defaults-not-assumed-fail.stderr
src/test/ui/async-await/async-unsafe-fn-call-in-safe.mir.stderr [new file with mode: 0644]
src/test/ui/async-await/async-unsafe-fn-call-in-safe.rs
src/test/ui/async-await/async-unsafe-fn-call-in-safe.stderr [deleted file]
src/test/ui/async-await/async-unsafe-fn-call-in-safe.thir.stderr [new file with mode: 0644]
src/test/ui/async-await/issue-73541-2.stderr
src/test/ui/async-await/issues/issue-65159.rs
src/test/ui/async-await/issues/issue-65159.stderr
src/test/ui/attributes/key-value-expansion.stderr
src/test/ui/attributes/nonterminal-expansion.stderr
src/test/ui/binop/issue-77910-1.stderr
src/test/ui/borrowck/borrowck-borrowed-uniq-rvalue-2.stderr
src/test/ui/borrowck/issue-25793.stderr
src/test/ui/borrowck/issue-64453.stderr
src/test/ui/borrowck/issue-82126-mismatched-subst-and-hir.rs
src/test/ui/borrowck/issue-82126-mismatched-subst-and-hir.stderr
src/test/ui/borrowck/move-error-snippets.stderr
src/test/ui/bound-suggestions.stderr
src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.fixed [new file with mode: 0644]
src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.rs [new file with mode: 0644]
src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.stderr [new file with mode: 0644]
src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.fixed
src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.rs
src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop.stderr
src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.fixed [new file with mode: 0644]
src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.rs [new file with mode: 0644]
src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.stderr [new file with mode: 0644]
src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_no_migrations.rs [new file with mode: 0644]
src/test/ui/closures/2229_closure_analysis/migrations/issue-78720.rs
src/test/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.fixed
src/test/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.rs
src/test/ui/closures/2229_closure_analysis/migrations/migrations_rustfix.stderr
src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.fixed [new file with mode: 0644]
src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.rs [new file with mode: 0644]
src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr [new file with mode: 0644]
src/test/ui/closures/2229_closure_analysis/migrations/no_migrations.rs
src/test/ui/closures/2229_closure_analysis/migrations/precise.fixed
src/test/ui/closures/2229_closure_analysis/migrations/precise.rs
src/test/ui/closures/2229_closure_analysis/migrations/precise.stderr
src/test/ui/closures/2229_closure_analysis/migrations/precise_no_migrations.rs
src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.fixed
src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.rs
src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.stderr
src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.nll.stderr
src/test/ui/closures/closure-bounds-static-cant-capture-borrowed.stderr
src/test/ui/closures/closure_no_cap_coerce_many_unsafe_0.mir.stderr [new file with mode: 0644]
src/test/ui/closures/closure_no_cap_coerce_many_unsafe_0.rs
src/test/ui/closures/closure_no_cap_coerce_many_unsafe_0.stderr [deleted file]
src/test/ui/closures/closure_no_cap_coerce_many_unsafe_0.thir.stderr [new file with mode: 0644]
src/test/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.mir.stderr [new file with mode: 0644]
src/test/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.rs
src/test/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.stderr [deleted file]
src/test/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.thir.stderr [new file with mode: 0644]
src/test/ui/codemap_tests/bad-format-args.stderr
src/test/ui/codemap_tests/issue-28308.stderr
src/test/ui/conditional-compilation/cfg-attr-syntax-validation.stderr
src/test/ui/conditional-compilation/cfg-attr-unknown-attribute-macro-expansion.stderr
src/test/ui/const-generics/diagnostics.stderr
src/test/ui/const-generics/incorrect-number-of-const-args.full.stderr
src/test/ui/const-generics/incorrect-number-of-const-args.min.stderr
src/test/ui/const-generics/incorrect-number-of-const-args.rs
src/test/ui/const-generics/invalid-const-arg-for-type-param.rs
src/test/ui/const-generics/invalid-const-arg-for-type-param.stderr
src/test/ui/const-generics/invalid-constant-in-args.stderr
src/test/ui/const-generics/issues/issue-76595.rs
src/test/ui/const-generics/issues/issue-76595.stderr
src/test/ui/const-generics/macro_rules-braces.full.stderr
src/test/ui/const-generics/min_const_generics/macro-fail.stderr
src/test/ui/constructor-lifetime-args.rs
src/test/ui/constructor-lifetime-args.stderr
src/test/ui/consts/const-eval/const_panic.stderr
src/test/ui/consts/const-eval/const_panic_libcore_bin.stderr
src/test/ui/consts/const-eval/double_promotion.rs [deleted file]
src/test/ui/consts/const-eval/feature-gate-const_panic.stderr
src/test/ui/consts/const-eval/panic-assoc-never-type.stderr
src/test/ui/consts/const-eval/panic-never-type.stderr
src/test/ui/consts/const-eval/unwind-abort.stderr
src/test/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.mir.stderr [new file with mode: 0644]
src/test/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.rs
src/test/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.stderr [deleted file]
src/test/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.thir.stderr [new file with mode: 0644]
src/test/ui/consts/const-external-macro-const-err.stderr
src/test/ui/consts/const-unwrap.stderr
src/test/ui/consts/const_arg_local.rs [deleted file]
src/test/ui/consts/const_arg_local.stderr [deleted file]
src/test/ui/consts/const_arg_promotable.rs [deleted file]
src/test/ui/consts/const_arg_promotable.stderr [deleted file]
src/test/ui/consts/const_arg_promotable2.rs [deleted file]
src/test/ui/consts/const_arg_promotable2.stderr [deleted file]
src/test/ui/consts/const_arg_wrapper.rs [deleted file]
src/test/ui/consts/const_arg_wrapper.stderr [deleted file]
src/test/ui/consts/const_unsafe_unreachable_ub.stderr
src/test/ui/consts/control-flow/assert.const_panic.stderr
src/test/ui/consts/control-flow/assert.stock.stderr
src/test/ui/consts/control-flow/issue-50577.stderr
src/test/ui/consts/enum-discr-type-err.stderr
src/test/ui/consts/inline_asm.stderr
src/test/ui/consts/issue-32829.stderr
src/test/ui/consts/issue-66693-panic-in-array-len.stderr
src/test/ui/consts/issue-66693.stderr
src/test/ui/consts/issue-76064.stderr
src/test/ui/consts/min_const_fn/bad_const_fn_body_ice.stderr
src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.32bit.stderr
src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.64bit.stderr
src/test/ui/consts/miri_unleashed/inline_asm.stderr
src/test/ui/consts/rustc-args-required-const.rs [deleted file]
src/test/ui/consts/rustc-args-required-const.stderr [deleted file]
src/test/ui/cross/cross-crate-macro-backtrace/main.stderr
src/test/ui/cross/cross-file-errors/main.stderr
src/test/ui/custom_test_frameworks/mismatch.stderr
src/test/ui/deprecation/deprecation-lint-2.stderr
src/test/ui/deprecation/deprecation-lint-3.stderr
src/test/ui/deprecation/deprecation-lint.stderr
src/test/ui/deprecation/issue-84637-deprecated-associated-function.fixed [new file with mode: 0644]
src/test/ui/deprecation/issue-84637-deprecated-associated-function.rs [new file with mode: 0644]
src/test/ui/deprecation/issue-84637-deprecated-associated-function.stderr [new file with mode: 0644]
src/test/ui/deref-suggestion.stderr
src/test/ui/derives/derives-span-Clone-enum-struct-variant.stderr
src/test/ui/derives/derives-span-Clone-enum.stderr
src/test/ui/derives/derives-span-Clone-struct.stderr
src/test/ui/derives/derives-span-Clone-tuple-struct.stderr
src/test/ui/derives/derives-span-Debug-enum-struct-variant.stderr
src/test/ui/derives/derives-span-Debug-enum.stderr
src/test/ui/derives/derives-span-Debug-struct.stderr
src/test/ui/derives/derives-span-Debug-tuple-struct.stderr
src/test/ui/derives/derives-span-Default-struct.stderr
src/test/ui/derives/derives-span-Default-tuple-struct.stderr
src/test/ui/derives/derives-span-Eq-enum-struct-variant.stderr
src/test/ui/derives/derives-span-Eq-enum.stderr
src/test/ui/derives/derives-span-Eq-struct.stderr
src/test/ui/derives/derives-span-Eq-tuple-struct.stderr
src/test/ui/derives/derives-span-Hash-enum-struct-variant.stderr
src/test/ui/derives/derives-span-Hash-enum.stderr
src/test/ui/derives/derives-span-Hash-struct.stderr
src/test/ui/derives/derives-span-Hash-tuple-struct.stderr
src/test/ui/derives/derives-span-Ord-enum-struct-variant.stderr
src/test/ui/derives/derives-span-Ord-enum.stderr
src/test/ui/derives/derives-span-Ord-struct.stderr
src/test/ui/derives/derives-span-Ord-tuple-struct.stderr
src/test/ui/derives/derives-span-PartialEq-enum-struct-variant.stderr
src/test/ui/derives/derives-span-PartialEq-enum.stderr
src/test/ui/derives/derives-span-PartialEq-struct.stderr
src/test/ui/derives/derives-span-PartialEq-tuple-struct.stderr
src/test/ui/derives/derives-span-PartialOrd-enum-struct-variant.stderr
src/test/ui/derives/derives-span-PartialOrd-enum.stderr
src/test/ui/derives/derives-span-PartialOrd-struct.stderr
src/test/ui/derives/derives-span-PartialOrd-tuple-struct.stderr
src/test/ui/derives/deriving-no-inner-impl-error-message.stderr
src/test/ui/derives/deriving-with-repr-packed.stderr
src/test/ui/did_you_mean/bad-assoc-expr.stderr
src/test/ui/did_you_mean/bad-assoc-pat.stderr
src/test/ui/did_you_mean/bad-assoc-ty.stderr
src/test/ui/did_you_mean/recursion_limit_macro.stderr
src/test/ui/directory_ownership/macro-expanded-mod.stderr
src/test/ui/dollar-crate/dollar-crate-is-keyword-2.stderr
src/test/ui/dollar-crate/dollar-crate-is-keyword.stderr
src/test/ui/editions/edition-imports-2015.stderr
src/test/ui/editions/edition-imports-2018.stderr
src/test/ui/editions/edition-imports-virtual-2015-gated.stderr
src/test/ui/editions/edition-keywords-2015-2018-expansion.stderr
src/test/ui/editions/edition-keywords-2018-2018-expansion.stderr
src/test/ui/error-codes/E0107.rs
src/test/ui/error-codes/E0107.stderr
src/test/ui/error-codes/E0133.mir.stderr [new file with mode: 0644]
src/test/ui/error-codes/E0133.rs
src/test/ui/error-codes/E0133.stderr [deleted file]
src/test/ui/error-codes/E0133.thir.stderr [new file with mode: 0644]
src/test/ui/error-codes/E0184.stderr
src/test/ui/error-codes/E0665.stderr
src/test/ui/exclusive-drop-and-copy.stderr
src/test/ui/expr/if/if-let.stderr
src/test/ui/extenv/extenv-not-defined-custom.stderr
src/test/ui/extenv/extenv-not-defined-default.stderr
src/test/ui/extenv/issue-55897.stderr
src/test/ui/feature-gates/feature-gate-allow-internal-unsafe-nested-macro.stderr
src/test/ui/feature-gates/feature-gate-allow-internal-unstable-nested-macro.stderr
src/test/ui/feature-gates/feature-gate-concat_idents2.stderr
src/test/ui/feature-gates/feature-gate-const_fn.rs [deleted file]
src/test/ui/feature-gates/feature-gate-const_fn.stderr [deleted file]
src/test/ui/feature-gates/feature-gate-const_fn_transmute.mir.stderr [new file with mode: 0644]
src/test/ui/feature-gates/feature-gate-const_fn_transmute.rs
src/test/ui/feature-gates/feature-gate-const_fn_transmute.stderr [deleted file]
src/test/ui/feature-gates/feature-gate-const_fn_transmute.thir.stderr [new file with mode: 0644]
src/test/ui/feature-gates/feature-gate-rustc_const_unstable.rs
src/test/ui/feature-gates/feature-gate-rustc_const_unstable.stderr
src/test/ui/feature-gates/thread-local-const-init.stderr
src/test/ui/feature-gates/trace_macros-gate.stderr
src/test/ui/fmt/format-args-capture-macro-hygiene.stderr
src/test/ui/fmt/ifmt-bad-arg.stderr
src/test/ui/fmt/ifmt-bad-format-args.stderr
src/test/ui/fmt/ifmt-unimpl.stderr
src/test/ui/foreign-unsafe-fn-called.mir.stderr [new file with mode: 0644]
src/test/ui/foreign-unsafe-fn-called.rs
src/test/ui/foreign-unsafe-fn-called.stderr [deleted file]
src/test/ui/foreign-unsafe-fn-called.thir.stderr [new file with mode: 0644]
src/test/ui/generator/generator-region-requirements.stderr
src/test/ui/generic-associated-types/gat-trait-path-missing-lifetime.rs
src/test/ui/generic-associated-types/gat-trait-path-missing-lifetime.stderr
src/test/ui/generic-associated-types/gat-trait-path-parenthesised-args.rs
src/test/ui/generic-associated-types/gat-trait-path-parenthesised-args.stderr
src/test/ui/generic-associated-types/issue-71176.rs
src/test/ui/generic-associated-types/issue-71176.stderr
src/test/ui/generic-associated-types/issue-76535.rs
src/test/ui/generic-associated-types/issue-76535.stderr
src/test/ui/generic-associated-types/issue-78671.rs
src/test/ui/generic-associated-types/issue-78671.stderr
src/test/ui/generic-associated-types/issue-79422.rs
src/test/ui/generic-associated-types/issue-79422.stderr
src/test/ui/generic-associated-types/issue-79636-1.rs
src/test/ui/generic-associated-types/issue-79636-1.stderr
src/test/ui/generic-associated-types/issue-79636-2.rs
src/test/ui/generic-associated-types/issue-79636-2.stderr
src/test/ui/generic-associated-types/issue-80433.rs
src/test/ui/generic-associated-types/issue-80433.stderr
src/test/ui/generic-associated-types/issue-81712-cyclic-traits.rs
src/test/ui/generic-associated-types/issue-81712-cyclic-traits.stderr
src/test/ui/generic-associated-types/issue-81862.rs [new file with mode: 0644]
src/test/ui/generic-associated-types/issue-81862.stderr [new file with mode: 0644]
src/test/ui/generic-associated-types/missing_lifetime_args.rs [new file with mode: 0644]
src/test/ui/generic-associated-types/missing_lifetime_args.stderr [new file with mode: 0644]
src/test/ui/generic-associated-types/missing_lifetime_const.rs [new file with mode: 0644]
src/test/ui/generic-associated-types/missing_lifetime_const.stderr [new file with mode: 0644]
src/test/ui/generic-associated-types/parameter_number_and_kind.rs
src/test/ui/generic-associated-types/parameter_number_and_kind.stderr
src/test/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.rs
src/test/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.stderr
src/test/ui/generic-associated-types/projection-type-lifetime-mismatch.stderr
src/test/ui/generics/bad-mid-path-type-params.rs
src/test/ui/generics/bad-mid-path-type-params.stderr
src/test/ui/generics/generic-arg-mismatch-recover.rs
src/test/ui/generics/generic-arg-mismatch-recover.stderr
src/test/ui/generics/generic-impl-less-params-with-defaults.rs
src/test/ui/generics/generic-impl-less-params-with-defaults.stderr
src/test/ui/generics/generic-impl-more-params-with-defaults.rs
src/test/ui/generics/generic-impl-more-params-with-defaults.stderr
src/test/ui/generics/generic-type-less-params-with-defaults.stderr
src/test/ui/generics/generic-type-more-params-with-defaults.rs
src/test/ui/generics/generic-type-more-params-with-defaults.stderr
src/test/ui/generics/wrong-number-of-args.rs
src/test/ui/generics/wrong-number-of-args.stderr
src/test/ui/half-open-range-patterns/half-open-range-pats-inclusive-dotdotdot-bad-syntax.stderr
src/test/ui/half-open-range-patterns/half-open-range-pats-inclusive-no-end.stderr
src/test/ui/hr-subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.nll.stderr
src/test/ui/hr-subtype/hr-subtype.bound_a_b_ret_a_vs_bound_a_ret_a.stderr
src/test/ui/hr-subtype/hr-subtype.bound_a_vs_free_x.nll.stderr
src/test/ui/hr-subtype/hr-subtype.bound_a_vs_free_x.stderr
src/test/ui/hr-subtype/hr-subtype.bound_inv_a_b_vs_bound_inv_a.nll.stderr
src/test/ui/hr-subtype/hr-subtype.bound_inv_a_b_vs_bound_inv_a.stderr
src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.nll.stderr
src/test/ui/hr-subtype/hr-subtype.free_inv_x_vs_free_inv_y.stderr
src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.nll.stderr
src/test/ui/hr-subtype/hr-subtype.free_x_vs_free_y.stderr
src/test/ui/hygiene/assoc_item_ctxt.stderr
src/test/ui/hygiene/duplicate_lifetimes.stderr
src/test/ui/hygiene/extern-prelude-from-opaque-fail.stderr
src/test/ui/hygiene/fields-definition.stderr
src/test/ui/hygiene/fields-move.stderr
src/test/ui/hygiene/fields.stderr
src/test/ui/hygiene/generate-mod.stderr
src/test/ui/hygiene/globs.stderr
src/test/ui/hygiene/hygienic-label-1.stderr
src/test/ui/hygiene/hygienic-label-3.stderr
src/test/ui/hygiene/hygienic-labels-in-let.stderr
src/test/ui/hygiene/hygienic-labels.stderr
src/test/ui/hygiene/impl_items.stderr
src/test/ui/hygiene/intercrate.stderr
src/test/ui/hygiene/missing-self-diag.stderr
src/test/ui/hygiene/no_implicit_prelude.stderr
src/test/ui/hygiene/privacy-early.stderr
src/test/ui/hygiene/trait_items.stderr
src/test/ui/hygiene/unpretty-debug.stdout
src/test/ui/imports/extern-prelude-extern-crate-fail.stderr
src/test/ui/imports/extern-prelude-extern-crate-restricted-shadowing.stderr
src/test/ui/imports/import-crate-var.stderr
src/test/ui/imports/import-prefix-macro-1.stderr
src/test/ui/imports/import-prefix-macro-2.stderr
src/test/ui/imports/local-modularized-tricky-fail-1.stderr
src/test/ui/imports/local-modularized-tricky-fail-2.stderr
src/test/ui/imports/shadow_builtin_macros.stderr
src/test/ui/in-band-lifetimes/elided-lifetimes.stderr
src/test/ui/include-macros/mismatched-types.stderr
src/test/ui/infinite/infinite-macro-expansion.stderr
src/test/ui/internal/internal-unstable-const.rs
src/test/ui/internal/internal-unstable-noallow.stderr
src/test/ui/internal/internal-unstable.stderr
src/test/ui/intrinsics/unchecked_math_unsafe.mir.stderr [new file with mode: 0644]
src/test/ui/intrinsics/unchecked_math_unsafe.rs
src/test/ui/intrinsics/unchecked_math_unsafe.stderr [deleted file]
src/test/ui/intrinsics/unchecked_math_unsafe.thir.stderr [new file with mode: 0644]
src/test/ui/invalid/invalid-rustc_args_required_const-arguments.rs [deleted file]
src/test/ui/invalid/invalid-rustc_args_required_const-arguments.stderr [deleted file]
src/test/ui/issues/auxiliary/issue-75907.rs
src/test/ui/issues/issue-12997-2.stderr
src/test/ui/issues/issue-13446.stderr
src/test/ui/issues/issue-14091-2.stderr
src/test/ui/issues/issue-14091.stderr
src/test/ui/issues/issue-14092.stderr
src/test/ui/issues/issue-15167.stderr
src/test/ui/issues/issue-16098.stderr
src/test/ui/issues/issue-16966.stderr
src/test/ui/issues/issue-18423.stderr
src/test/ui/issues/issue-21160.stderr
src/test/ui/issues/issue-23024.stderr
src/test/ui/issues/issue-25385.stderr
src/test/ui/issues/issue-25386.stderr
src/test/ui/issues/issue-26093.stderr
src/test/ui/issues/issue-27340.stderr
src/test/ui/issues/issue-27592.stderr
src/test/ui/issues/issue-28776.mir.stderr [new file with mode: 0644]
src/test/ui/issues/issue-28776.rs
src/test/ui/issues/issue-28776.stderr [deleted file]
src/test/ui/issues/issue-28776.thir.stderr [new file with mode: 0644]
src/test/ui/issues/issue-29084.stderr
src/test/ui/issues/issue-3080.mir.stderr [new file with mode: 0644]
src/test/ui/issues/issue-3080.rs
src/test/ui/issues/issue-3080.stderr [deleted file]
src/test/ui/issues/issue-3080.thir.stderr [new file with mode: 0644]
src/test/ui/issues/issue-31011.stderr
src/test/ui/issues/issue-3214.rs
src/test/ui/issues/issue-3214.stderr
src/test/ui/issues/issue-32655.stderr
src/test/ui/issues/issue-32782.stderr
src/test/ui/issues/issue-32950.stderr
src/test/ui/issues/issue-34229.stderr
src/test/ui/issues/issue-38074.rs [deleted file]
src/test/ui/issues/issue-38821.stderr
src/test/ui/issues/issue-39848.stderr
src/test/ui/issues/issue-42954.stderr
src/test/ui/issues/issue-46983.stderr
src/test/ui/issues/issue-48131.mir.stderr [new file with mode: 0644]
src/test/ui/issues/issue-48131.rs
src/test/ui/issues/issue-48131.stderr [deleted file]
src/test/ui/issues/issue-48131.thir.stderr [new file with mode: 0644]
src/test/ui/issues/issue-48364.stderr
src/test/ui/issues/issue-48728.stderr
src/test/ui/issues/issue-50480.stderr
src/test/ui/issues/issue-51848.stderr
src/test/ui/issues/issue-53251.rs
src/test/ui/issues/issue-53251.stderr
src/test/ui/issues/issue-54954.rs
src/test/ui/issues/issue-54954.stderr
src/test/ui/issues/issue-5844.mir.stderr [new file with mode: 0644]
src/test/ui/issues/issue-5844.rs
src/test/ui/issues/issue-5844.stderr [deleted file]
src/test/ui/issues/issue-5844.thir.stderr [new file with mode: 0644]
src/test/ui/issues/issue-59488.stderr
src/test/ui/issues/issue-60622.rs
src/test/ui/issues/issue-60622.stderr
src/test/ui/issues/issue-6596-1.stderr
src/test/ui/issues/issue-6596-2.stderr
src/test/ui/issues/issue-68091-unicode-ident-after-if.stderr
src/test/ui/issues/issue-69396-const-no-type-in-macro.stderr
src/test/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr
src/test/ui/issues/issue-75907_b.rs
src/test/ui/issues/issue-75907_b.stderr
src/test/ui/lifetimes/borrowck-let-suggestion.stderr
src/test/ui/lint/lint-stability-deprecated.stderr
src/test/ui/lint/lint-stability2.stderr
src/test/ui/lint/lint-stability3.stderr
src/test/ui/lint/lint-unsafe-code.stderr
src/test/ui/lint/lints-in-foreign-macros.stderr
src/test/ui/lint/semicolon-in-expressions-from-macros/semicolon-in-expressions-from-macros.stderr
src/test/ui/lint/test-inner-fn.stderr
src/test/ui/lint/unaligned_references_external_macro.stderr
src/test/ui/lint/unreachable_pub-pub_crate.stderr
src/test/ui/lint/unreachable_pub.stderr
src/test/ui/liveness/liveness-return-last-stmt-semi.stderr
src/test/ui/llvm-asm/inline-asm-bad-constraint.stderr
src/test/ui/llvm-asm/issue-62046.stderr
src/test/ui/macro_backtrace/main.default.stderr
src/test/ui/macros/assert.stderr
src/test/ui/macros/auxiliary/proc_macro_sequence.rs
src/test/ui/macros/cfg.stderr
src/test/ui/macros/derive-in-eager-expansion-hang.stderr
src/test/ui/macros/format-parse-errors.stderr
src/test/ui/macros/global-asm.rs
src/test/ui/macros/global-asm.stderr
src/test/ui/macros/issue-34421-mac-expr-bad-stmt-good-add-semi.stderr
src/test/ui/macros/issue-78325-inconsistent-resolution.stderr
src/test/ui/macros/issue-84195-lint-anon-const.stderr
src/test/ui/macros/macro-backtrace-invalid-internals.stderr
src/test/ui/macros/macro-backtrace-nested.stderr
src/test/ui/macros/macro-backtrace-println.stderr
src/test/ui/macros/macro-context.stderr
src/test/ui/macros/macro-lifetime-used-with-labels.stderr
src/test/ui/macros/macro-local-data-key-priv.stderr
src/test/ui/macros/macro-shadowing.stderr
src/test/ui/macros/macros-nonfatal-errors.stderr
src/test/ui/macros/must-use-in-macro-55516.stderr
src/test/ui/macros/nonterminal-matching.stderr
src/test/ui/macros/not-utf8.stderr
src/test/ui/macros/restricted-shadowing-legacy.stderr
src/test/ui/macros/restricted-shadowing-modern.stderr
src/test/ui/macros/same-sequence-span.stderr
src/test/ui/macros/span-covering-argument-1.stderr
src/test/ui/macros/trace_faulty_macros.stderr
src/test/ui/macros/vec-macro-in-pattern.stderr
src/test/ui/malformed/malformed-derive-entry.stderr
src/test/ui/match/auxiliary/match_non_exhaustive_lib.rs [new file with mode: 0644]
src/test/ui/match/match_non_exhaustive.rs [new file with mode: 0644]
src/test/ui/match/match_non_exhaustive.stderr [new file with mode: 0644]
src/test/ui/methods/method-call-lifetime-args-fail.rs
src/test/ui/methods/method-call-lifetime-args-fail.stderr
src/test/ui/mismatched_types/const-fn-in-trait.rs
src/test/ui/mismatched_types/const-fn-in-trait.stderr
src/test/ui/mismatched_types/issue-26480.stderr
src/test/ui/mismatched_types/issue-84976.rs [new file with mode: 0644]
src/test/ui/mismatched_types/issue-84976.stderr [new file with mode: 0644]
src/test/ui/missing/missing-items/missing-type-parameter2.rs [new file with mode: 0644]
src/test/ui/missing/missing-items/missing-type-parameter2.stderr [new file with mode: 0644]
src/test/ui/modules/issue-56411.stderr
src/test/ui/nll/closure-requirements/region-lbr-anon-does-not-outlive-static.stderr
src/test/ui/nll/guarantor-issue-46974.stderr
src/test/ui/on-unimplemented/no-debug.stderr
src/test/ui/or-patterns/exhaustiveness-unreachable-pattern.stderr
src/test/ui/out-of-order-shadowing.stderr
src/test/ui/parser/bad-interpolated-block.stderr
src/test/ui/parser/float-field-interpolated.stderr
src/test/ui/parser/fn-header-semantic-fail.rs
src/test/ui/parser/fn-header-semantic-fail.stderr
src/test/ui/parser/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.stderr
src/test/ui/parser/issue-65122-mac-invoc-in-mut-patterns.stderr
src/test/ui/parser/issue-73568-lifetime-after-mut.stderr
src/test/ui/parser/labeled-no-colon-expr.stderr
src/test/ui/parser/macro/issue-37113.stderr
src/test/ui/parser/macro/issue-37234.stderr
src/test/ui/parser/macro/macro-incomplete-parse.stderr
src/test/ui/parser/macro/pub-item-macro.stderr
src/test/ui/parser/missing-closing-angle-bracket-eq-constraint.stderr
src/test/ui/parser/missing-semicolon.stderr
src/test/ui/parser/mut-patterns.stderr
src/test/ui/parser/recover-range-pats.stderr
src/test/ui/parser/struct-default-values-and-missing-field-separator.fixed [new file with mode: 0644]
src/test/ui/parser/struct-default-values-and-missing-field-separator.rs [new file with mode: 0644]
src/test/ui/parser/struct-default-values-and-missing-field-separator.stderr [new file with mode: 0644]
src/test/ui/pattern/rest-pat-semantic-disallowed.stderr
src/test/ui/privacy/associated-item-privacy-inherent.stderr
src/test/ui/privacy/associated-item-privacy-trait.stderr
src/test/ui/privacy/associated-item-privacy-type-binding.stderr
src/test/ui/privacy/private-inferred-type-3.stderr
src/test/ui/privacy/private-inferred-type.stderr
src/test/ui/proc-macro/auxiliary/custom-quote.rs [new file with mode: 0644]
src/test/ui/proc-macro/auxiliary/span-from-proc-macro.rs [new file with mode: 0644]
src/test/ui/proc-macro/derive-bad.stderr
src/test/ui/proc-macro/derive-helper-shadowing.stderr
src/test/ui/proc-macro/expand-to-unstable-2.stderr
src/test/ui/proc-macro/expand-to-unstable.stderr
src/test/ui/proc-macro/gen-macro-rules-hygiene.stderr
src/test/ui/proc-macro/generate-mod.stderr
src/test/ui/proc-macro/group-compat-hack/group-compat-hack.stderr
src/test/ui/proc-macro/invalid-punct-ident-4.stderr
src/test/ui/proc-macro/issue-38586.stderr
src/test/ui/proc-macro/issue-59191-replace-root-with-fn.stderr
src/test/ui/proc-macro/issue-83510.stderr
src/test/ui/proc-macro/lifetimes.stderr
src/test/ui/proc-macro/lints_in_proc_macros.stderr
src/test/ui/proc-macro/macro-rules-derive.stderr
src/test/ui/proc-macro/meta-macro-hygiene.stdout
src/test/ui/proc-macro/mixed-site-span.stderr
src/test/ui/proc-macro/multispan.stderr
src/test/ui/proc-macro/nonterminal-token-hygiene.stdout
src/test/ui/proc-macro/parent-source-spans.stderr
src/test/ui/proc-macro/quote-debug.rs [new file with mode: 0644]
src/test/ui/proc-macro/quote-debug.stdout [new file with mode: 0644]
src/test/ui/proc-macro/raw-ident.stderr
src/test/ui/proc-macro/resolved-located-at.stderr
src/test/ui/proc-macro/span-from-proc-macro.rs [new file with mode: 0644]
src/test/ui/proc-macro/span-from-proc-macro.stderr [new file with mode: 0644]
src/test/ui/proc-macro/subspan.stderr
src/test/ui/proc-macro/three-equals.stderr
src/test/ui/proc-macro/weird-hygiene.stderr
src/test/ui/range/range_traits-1.stderr
src/test/ui/range/range_traits-2.stderr
src/test/ui/range/range_traits-3.stderr
src/test/ui/range/range_traits-6.stderr
src/test/ui/reachable/expr_again.stderr
src/test/ui/reachable/expr_block.stderr
src/test/ui/reachable/expr_if.stderr
src/test/ui/reachable/expr_loop.stderr
src/test/ui/reachable/expr_match.stderr
src/test/ui/reachable/unreachable-code-ret.stderr
src/test/ui/regions/regions-static-bound.migrate.nll.stderr
src/test/ui/regions/regions-static-bound.migrate.stderr
src/test/ui/regions/regions-static-bound.nll.stderr
src/test/ui/resolve/issue-82865.stderr
src/test/ui/rfc-1937-termination-trait/termination-trait-test-wrong-type.stderr
src/test/ui/rfc-2008-non-exhaustive/enum.stderr
src/test/ui/rfc-2008-non-exhaustive/struct.stderr
src/test/ui/rfc-2008-non-exhaustive/uninhabited/match.stderr
src/test/ui/rfc-2008-non-exhaustive/uninhabited/match_with_exhaustive_patterns.stderr
src/test/ui/rfc-2091-track-caller/caller-location-fnptr-rt-ctfe-equiv.rs
src/test/ui/rfc-2091-track-caller/const-caller-location.rs
src/test/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr
src/test/ui/rust-2018/uniform-paths/ambiguity-macros-nested.stderr
src/test/ui/rust-2018/uniform-paths/ambiguity-macros.stderr
src/test/ui/rustc-args-required-const2.rs [deleted file]
src/test/ui/rustc-args-required-const2.stderr [deleted file]
src/test/ui/seq-args.rs
src/test/ui/seq-args.stderr
src/test/ui/simd-intrinsic/simd-intrinsic-generic-elements.rs
src/test/ui/simd-intrinsic/simd-intrinsic-generic-elements.stderr
src/test/ui/simd-intrinsic/simd-intrinsic-inlining-issue67557-ice.rs
src/test/ui/simd-intrinsic/simd-intrinsic-inlining-issue67557.rs
src/test/ui/simd/shuffle-not-out-of-bounds.stderr
src/test/ui/simd/simd-intrinsic-generic-elements.rs
src/test/ui/span/E0204.stderr
src/test/ui/span/coerce-suggestions.stderr
src/test/ui/span/issue-33884.stderr
src/test/ui/span/macro-span-replacement.stderr
src/test/ui/span/slice-borrow.stderr
src/test/ui/stability-attribute/stability-attribute-sanity.rs
src/test/ui/static/static-drop-scope.rs
src/test/ui/static/static-drop-scope.stderr
src/test/ui/structs/structure-constructor-type-mismatch.rs
src/test/ui/structs/structure-constructor-type-mismatch.stderr
src/test/ui/suggestions/dont-suggest-deref-inside-macro-issue-58298.stderr
src/test/ui/suggestions/dont-suggest-try_into-in-macros.stderr
src/test/ui/suggestions/issue-68049-1.rs [new file with mode: 0644]
src/test/ui/suggestions/issue-68049-1.stderr [new file with mode: 0644]
src/test/ui/suggestions/issue-68049-2.rs [new file with mode: 0644]
src/test/ui/suggestions/issue-68049-2.stderr [new file with mode: 0644]
src/test/ui/suggestions/missing-lifetime-specifier.rs
src/test/ui/suggestions/missing-lifetime-specifier.stderr
src/test/ui/suggestions/mut-borrow-needed-by-trait.stderr
src/test/ui/suggestions/path-display.stderr
src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.rs
src/test/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr
src/test/ui/tag-type-args.stderr
src/test/ui/thread-local-in-ctfe.rs
src/test/ui/threads-sendsync/auxiliary/thread-local-extern-static.rs
src/test/ui/threads-sendsync/issue-43733.mir.stderr [new file with mode: 0644]
src/test/ui/threads-sendsync/issue-43733.rs
src/test/ui/threads-sendsync/issue-43733.stderr [deleted file]
src/test/ui/threads-sendsync/issue-43733.thir.stderr [new file with mode: 0644]
src/test/ui/traits/cache-reached-depth-ice.rs [new file with mode: 0644]
src/test/ui/traits/cache-reached-depth-ice.stderr [new file with mode: 0644]
src/test/ui/traits/issue-71136.stderr
src/test/ui/traits/issue-75627.stderr
src/test/ui/traits/issue-78372.stderr
src/test/ui/traits/issue-79458.stderr
src/test/ui/traits/issue-83538-tainted-cache-after-cycle.rs [new file with mode: 0644]
src/test/ui/traits/issue-83538-tainted-cache-after-cycle.stderr [new file with mode: 0644]
src/test/ui/traits/object/vs-lifetime.rs
src/test/ui/traits/object/vs-lifetime.stderr
src/test/ui/traits/test-2.rs
src/test/ui/traits/test-2.stderr
src/test/ui/try-block/try-block-opt-init.stderr
src/test/ui/tuple/tuple-struct-fields/test2.stderr
src/test/ui/tuple/tuple-struct-fields/test3.stderr
src/test/ui/type-alias-enum-variants/enum-variant-generic-args.rs
src/test/ui/type-alias-enum-variants/enum-variant-generic-args.stderr
src/test/ui/type/ascription/issue-34255-1.stderr
src/test/ui/type/ascription/issue-47666.stderr
src/test/ui/type/type-check/cannot_infer_local_or_vec.stderr
src/test/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.stderr
src/test/ui/typeck/issue-75883.rs
src/test/ui/typeck/issue-75883.stderr
src/test/ui/typeck/issue-81943.stderr
src/test/ui/typeck/typeck-builtin-bound-type-parameters.rs
src/test/ui/typeck/typeck-builtin-bound-type-parameters.stderr
src/test/ui/typeck/typeck_type_placeholder_lifetime_1.rs
src/test/ui/typeck/typeck_type_placeholder_lifetime_1.stderr
src/test/ui/typeck/typeck_type_placeholder_lifetime_2.rs
src/test/ui/typeck/typeck_type_placeholder_lifetime_2.stderr
src/test/ui/ufcs/ufcs-qpath-missing-params.rs
src/test/ui/ufcs/ufcs-qpath-missing-params.stderr
src/test/ui/unboxed-closures/unboxed-closure-sugar-used-on-struct-1.rs
src/test/ui/unboxed-closures/unboxed-closure-sugar-used-on-struct-1.stderr
src/test/ui/unboxed-closures/unboxed-closure-sugar-used-on-struct.rs
src/test/ui/unboxed-closures/unboxed-closure-sugar-used-on-struct.stderr
src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs
src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters-3.stderr
src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters.rs
src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-number-number-type-parameters.stderr
src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-trait.rs
src/test/ui/unboxed-closures/unboxed-closure-sugar-wrong-trait.stderr
src/test/ui/union/union-const-eval-field.rs
src/test/ui/union/union-derive-clone.stderr
src/test/ui/union/union-derive-eq.stderr
src/test/ui/unsafe/unsafe-around-compiler-generated-unsafe.mir.stderr [new file with mode: 0644]
src/test/ui/unsafe/unsafe-around-compiler-generated-unsafe.rs
src/test/ui/unsafe/unsafe-around-compiler-generated-unsafe.stderr [deleted file]
src/test/ui/unsafe/unsafe-around-compiler-generated-unsafe.thir.stderr [new file with mode: 0644]
src/test/ui/unsafe/unsafe-const-fn.mir.stderr [new file with mode: 0644]
src/test/ui/unsafe/unsafe-const-fn.rs
src/test/ui/unsafe/unsafe-const-fn.stderr [deleted file]
src/test/ui/unsafe/unsafe-const-fn.thir.stderr [new file with mode: 0644]
src/test/ui/unsafe/unsafe-fn-called-from-safe.mir.stderr [new file with mode: 0644]
src/test/ui/unsafe/unsafe-fn-called-from-safe.rs
src/test/ui/unsafe/unsafe-fn-called-from-safe.stderr [deleted file]
src/test/ui/unsafe/unsafe-fn-called-from-safe.thir.stderr [new file with mode: 0644]
src/test/ui/unsafe/unsafe-fn-used-as-value.mir.stderr [new file with mode: 0644]
src/test/ui/unsafe/unsafe-fn-used-as-value.rs
src/test/ui/unsafe/unsafe-fn-used-as-value.stderr [deleted file]
src/test/ui/unsafe/unsafe-fn-used-as-value.thir.stderr [new file with mode: 0644]
src/test/ui/unsafe/unsafe-unstable-const-fn.rs
src/test/ui/unsafe/unsafe-unstable-const-fn.stderr
src/test/ui/unused/unused-macro-rules.stderr
src/test/ui/while-let.stderr
src/tools/cargo
src/tools/clippy/clippy_lints/src/macro_use.rs
src/tools/clippy/clippy_lints/src/misc.rs
src/tools/clippy/clippy_lints/src/unit_types/unit_cmp.rs
src/tools/clippy/clippy_utils/src/lib.rs
src/tools/clippy/tests/ui-internal/default_lint.stderr
src/tools/clippy/tests/ui-internal/if_chain_style.stderr
src/tools/clippy/tests/ui-internal/lint_without_lint_pass.stderr
src/tools/clippy/tests/ui/assertions_on_constants.stderr
src/tools/clippy/tests/ui/checked_unwrap/simple_conditionals.stderr
src/tools/clippy/tests/ui/collapsible_match2.stderr
src/tools/clippy/tests/ui/crashes/ice-6255.stderr
src/tools/clippy/tests/ui/declare_interior_mutable_const/others.stderr
src/tools/clippy/tests/ui/declare_interior_mutable_const/traits.stderr
src/tools/clippy/tests/ui/deref_addrof.stderr
src/tools/clippy/tests/ui/derive_hash_xor_eq.stderr
src/tools/clippy/tests/ui/derive_ord_xor_partial_ord.stderr
src/tools/clippy/tests/ui/doc_unsafe.stderr
src/tools/clippy/tests/ui/eq_op_macros.stderr
src/tools/clippy/tests/ui/fallible_impl_from.stderr
src/tools/clippy/tests/ui/implicit_hasher.stderr
src/tools/clippy/tests/ui/item_after_statement.stderr
src/tools/clippy/tests/ui/match_same_arms2.stderr
src/tools/clippy/tests/ui/mem_discriminant.stderr
src/tools/clippy/tests/ui/mem_replace_macro.stderr
src/tools/clippy/tests/ui/missing_panics_doc.stderr
src/tools/clippy/tests/ui/mut_mut.stderr
src/tools/clippy/tests/ui/needless_question_mark.stderr
src/tools/clippy/tests/ui/new_without_default.rs
src/tools/clippy/tests/ui/new_without_default.stderr
src/tools/clippy/tests/ui/option_env_unwrap.stderr
src/tools/clippy/tests/ui/panic_in_result_fn.stderr
src/tools/clippy/tests/ui/panic_in_result_fn_assertions.stderr
src/tools/clippy/tests/ui/panicking_macros.stderr
src/tools/clippy/tests/ui/pattern_type_mismatch/syntax.stderr
src/tools/clippy/tests/ui/toplevel_ref_arg.stderr
src/tools/clippy/tests/ui/toplevel_ref_arg_non_rustfix.stderr
src/tools/clippy/tests/ui/try_err.stderr
src/tools/clippy/tests/ui/unit_cmp.stderr
src/tools/clippy/tests/ui/unsafe_derive_deserialize.stderr
src/tools/clippy/tests/ui/unseparated_prefix_literals.stderr
src/tools/compiletest/src/runtest.rs
src/tools/miri
src/tools/rustdoc-js/tester.js
src/tools/tidy/src/deps.rs
src/tools/tidy/src/ui_tests.rs

index ffaa2b03df9e7b24dc19912f8e4017255deaed73..aa9d97ba477b76b85fddb9391195d4b1a6ce1fca 100644 (file)
@@ -72,6 +72,9 @@ jobs:
       - name: decide whether to skip this job
         run: src/ci/scripts/should-skip-this.sh
         if: success() && !env.SKIP_JOB
+      - name: ensure the channel matches the target branch
+        run: src/ci/scripts/verify-channel.sh
+        if: success() && !env.SKIP_JOB
       - name: configure GitHub Actions to kill the build when outdated
         uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
         with:
@@ -434,6 +437,9 @@ jobs:
       - name: decide whether to skip this job
         run: src/ci/scripts/should-skip-this.sh
         if: success() && !env.SKIP_JOB
+      - name: ensure the channel matches the target branch
+        run: src/ci/scripts/verify-channel.sh
+        if: success() && !env.SKIP_JOB
       - name: configure GitHub Actions to kill the build when outdated
         uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
         with:
@@ -541,6 +547,9 @@ jobs:
       - name: decide whether to skip this job
         run: src/ci/scripts/should-skip-this.sh
         if: success() && !env.SKIP_JOB
+      - name: ensure the channel matches the target branch
+        run: src/ci/scripts/verify-channel.sh
+        if: success() && !env.SKIP_JOB
       - name: configure GitHub Actions to kill the build when outdated
         uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
         with:
index 1019710dc979335b0395ff2308fc958d038492fd..cd617ca2f4285c65243e742f335e7f576574f60f 100644 (file)
--- a/.mailmap
+++ b/.mailmap
@@ -43,7 +43,7 @@ Brian Anderson <banderson@mozilla.com> <andersrb@gmail.com>
 Brian Anderson <banderson@mozilla.com> <banderson@mozilla.org>
 Brian Dawn <brian.t.dawn@gmail.com>
 Brian Leibig <brian@brianleibig.com> Brian Leibig <brian.leibig@gmail.com>
-Camelid <camelidcamel@gmail.com> <37223377+camelid@users.noreply.github.com>
+Noah Lev <camelidcamel@gmail.com> <37223377+camelid@users.noreply.github.com>
 Carl-Anton Ingmarsson <mail@carlanton.se> <ca.ingmarsson@gmail.com>
 Carol (Nichols || Goulding) <carol.nichols@gmail.com> <193874+carols10cents@users.noreply.github.com>
 Carol (Nichols || Goulding) <carol.nichols@gmail.com> <carol.nichols@gmail.com>
index 925898f6bbeeb86018afd91a70ca75254d7633c9..e92b7287f3eb60a5c76680605fb08b5718f3e3a1 100644 (file)
@@ -55,7 +55,7 @@ dependencies = [
  "markup5ever_rcdom",
  "matches",
  "tendril",
- "url 2.1.1",
+ "url 2.2.2",
 ]
 
 [[package]]
@@ -305,7 +305,7 @@ dependencies = [
  "toml",
  "unicode-width",
  "unicode-xid",
- "url 2.1.1",
+ "url 2.2.2",
  "walkdir",
  "winapi 0.3.9",
 ]
@@ -378,7 +378,7 @@ dependencies = [
  "serde_json",
  "tar",
  "toml",
- "url 2.1.1",
+ "url 2.2.2",
 ]
 
 [[package]]
@@ -441,9 +441,9 @@ version = "0.1.0"
 
 [[package]]
 name = "cc"
-version = "1.0.60"
+version = "1.0.67"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ef611cc68ff783f18535d77ddd080185275713d852c4f5cbb6122c462a7a825c"
+checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd"
 dependencies = [
  "jobserver",
 ]
@@ -600,7 +600,7 @@ dependencies = [
  "serde_json",
  "toml",
  "unicode-normalization",
- "url 2.1.1",
+ "url 2.2.2",
 ]
 
 [[package]]
@@ -655,9 +655,9 @@ dependencies = [
 
 [[package]]
 name = "compiler_builtins"
-version = "0.1.39"
+version = "0.1.43"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3748f82c7d366a0b4950257d19db685d4958d2fa27c6d164a3f069fec42b748b"
+checksum = "65af2dcae4779003dfa91aedc6ade7bdc7ba685944e50a8b4f9380df376a4466"
 dependencies = [
  "cc",
  "rustc-std-workspace-core",
@@ -750,7 +750,7 @@ dependencies = [
  "percent-encoding 2.1.0",
  "serde",
  "serde_json",
- "url 2.1.1",
+ "url 2.2.2",
 ]
 
 [[package]]
@@ -1137,13 +1137,13 @@ checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
 
 [[package]]
 name = "filetime"
-version = "0.2.12"
+version = "0.2.14"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3ed85775dcc68644b5c950ac06a2b23768d3bc9390464151aaf27136998dcf9e"
+checksum = "1d34cfa13a63ae058bfa601fe9e313bbdb3746427c1459185464ce0fcf62e1e8"
 dependencies = [
- "cfg-if 0.1.10",
+ "cfg-if 1.0.0",
  "libc",
- "redox_syscall 0.1.57",
+ "redox_syscall",
  "winapi 0.3.9",
 ]
 
@@ -1187,6 +1187,16 @@ version = "0.1.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
 
+[[package]]
+name = "form_urlencoded"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191"
+dependencies = [
+ "matches",
+ "percent-encoding 2.1.0",
+]
+
 [[package]]
 name = "fortanix-sgx-abi"
 version = "0.3.3"
@@ -1441,7 +1451,7 @@ dependencies = [
  "log",
  "openssl-probe",
  "openssl-sys",
- "url 2.1.1",
+ "url 2.2.2",
 ]
 
 [[package]]
@@ -1453,7 +1463,7 @@ dependencies = [
  "curl",
  "git2",
  "log",
- "url 2.1.1",
+ "url 2.2.2",
 ]
 
 [[package]]
@@ -2003,7 +2013,7 @@ dependencies = [
  "serde",
  "serde_json",
  "serde_repr",
- "url 2.1.1",
+ "url 2.2.2",
 ]
 
 [[package]]
@@ -2125,12 +2135,12 @@ dependencies = [
 
 [[package]]
 name = "measureme"
-version = "9.1.0"
+version = "9.1.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4a98e07fe802486895addb2b5467f33f205e82c426bfaf350f5d8109b137767c"
+checksum = "49cf14eb7d2eea897d9949b68f19e165638755e3a1a3c0941b6b6c3e00141f2c"
 dependencies = [
  "log",
- "memmap",
+ "memmap2",
  "parking_lot",
  "perf-event-open-sys",
  "rustc-hash",
@@ -2143,16 +2153,6 @@ version = "2.3.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
 
-[[package]]
-name = "memmap"
-version = "0.7.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b"
-dependencies = [
- "libc",
- "winapi 0.3.9",
-]
-
 [[package]]
 name = "memmap2"
 version = "0.2.1"
@@ -2274,7 +2274,7 @@ version = "0.3.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "5a33c1b55807fbed163481b5ba66db4b2fa6cde694a5027be10fb724206c5897"
 dependencies = [
- "socket2 0.3.16",
+ "socket2 0.3.19",
  "winapi 0.3.9",
 ]
 
@@ -2516,7 +2516,7 @@ dependencies = [
  "cfg-if 1.0.0",
  "instant",
  "libc",
- "redox_syscall 0.2.5",
+ "redox_syscall",
  "smallvec",
  "winapi 0.3.9",
 ]
@@ -3000,12 +3000,6 @@ dependencies = [
  "num_cpus",
 ]
 
-[[package]]
-name = "redox_syscall"
-version = "0.1.57"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
-
 [[package]]
 name = "redox_syscall"
 version = "0.2.5"
@@ -3022,7 +3016,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64"
 dependencies = [
  "getrandom 0.2.0",
- "redox_syscall 0.2.5",
+ "redox_syscall",
 ]
 
 [[package]]
@@ -3114,7 +3108,7 @@ dependencies = [
  "tokio",
  "tokio-util",
  "toml",
- "url 2.1.1",
+ "url 2.2.2",
  "walkdir",
 ]
 
@@ -3546,7 +3540,7 @@ dependencies = [
  "serde_json",
  "smallvec",
  "syn",
- "url 2.1.1",
+ "url 2.2.2",
  "winapi 0.3.9",
 ]
 
@@ -3701,6 +3695,7 @@ dependencies = [
  "itertools 0.9.0",
  "jobserver",
  "libc",
+ "object",
  "pathdiff",
  "rustc_apfloat",
  "rustc_ast",
@@ -4854,13 +4849,12 @@ checksum = "da73c8f77aebc0e40c300b93f0a5f1bece7a248a36eee287d4e095f35c7b7d6e"
 
 [[package]]
 name = "socket2"
-version = "0.3.16"
+version = "0.3.19"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7fd8b795c389288baa5f355489c65e71fd48a02104600d15c4cfbc561e9e429d"
+checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e"
 dependencies = [
- "cfg-if 0.1.10",
+ "cfg-if 1.0.0",
  "libc",
- "redox_syscall 0.1.57",
  "winapi 0.3.9",
 ]
 
@@ -5037,13 +5031,12 @@ dependencies = [
 
 [[package]]
 name = "tar"
-version = "0.4.29"
+version = "0.4.33"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c8a4c1d0bee3230179544336c15eefb563cf0302955d962e456542323e8c2e8a"
+checksum = "c0bcfbd6a598361fda270d82469fff3d65089dc33e175c9a131f7b4cd395f228"
 dependencies = [
  "filetime",
  "libc",
- "redox_syscall 0.1.57",
  "xattr",
 ]
 
@@ -5056,7 +5049,7 @@ dependencies = [
  "cfg-if 1.0.0",
  "libc",
  "rand 0.8.3",
- "redox_syscall 0.2.5",
+ "redox_syscall",
  "remove_dir_all",
  "winapi 0.3.9",
 ]
@@ -5533,10 +5526,11 @@ dependencies = [
 
 [[package]]
 name = "url"
-version = "2.1.1"
+version = "2.2.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb"
+checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c"
 dependencies = [
+ "form_urlencoded",
  "idna 0.2.0",
  "matches",
  "percent-encoding 2.1.0",
@@ -5584,9 +5578,9 @@ dependencies = [
 
 [[package]]
 name = "version_check"
-version = "0.9.1"
+version = "0.9.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce"
+checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe"
 
 [[package]]
 name = "vte"
index e7f19f06ebef5c07197d45a2213c2f5722dcc4fc..fb012d9802f6cb0c92acbae931391dbec9087c79 100644 (file)
@@ -278,7 +278,7 @@ pub fn as_angle_bracketed_args(&self) -> AngleBracketedArgs {
             .cloned()
             .map(|input| AngleBracketedArg::Arg(GenericArg::Type(input)))
             .collect();
-        AngleBracketedArgs { span: self.span, args }
+        AngleBracketedArgs { span: self.inputs_span, args }
     }
 }
 
@@ -2279,14 +2279,6 @@ pub struct ForeignMod {
     pub items: Vec<P<ForeignItem>>,
 }
 
-/// Global inline assembly.
-///
-/// Also known as "module-level assembly" or "file-scoped assembly".
-#[derive(Clone, Encodable, Decodable, Debug, Copy)]
-pub struct GlobalAsm {
-    pub asm: Symbol,
-}
-
 #[derive(Clone, Encodable, Decodable, Debug)]
 pub struct EnumDef {
     pub variants: Vec<Variant>,
@@ -2669,7 +2661,7 @@ pub enum ItemKind {
     /// E.g., `extern {}` or `extern "C" {}`.
     ForeignMod(ForeignMod),
     /// Module-level inline assembly (from `global_asm!()`).
-    GlobalAsm(GlobalAsm),
+    GlobalAsm(InlineAsm),
     /// A type alias (`type`).
     ///
     /// E.g., `type Foo = Bar<u8>;`.
index 05f57f978c7a4c3313abc1e15fbb556eaf96153f..374a6ec972fba40e974b402a67fc288329b4c414 100644 (file)
@@ -965,7 +965,7 @@ pub fn noop_visit_item_kind<T: MutVisitor>(kind: &mut ItemKind, vis: &mut T) {
             ModKind::Unloaded => {}
         },
         ItemKind::ForeignMod(nm) => vis.visit_foreign_mod(nm),
-        ItemKind::GlobalAsm(_ga) => {}
+        ItemKind::GlobalAsm(asm) => noop_visit_inline_asm(asm, vis),
         ItemKind::TyAlias(box TyAliasKind(_, generics, bounds, ty)) => {
             vis.visit_generics(generics);
             visit_bounds(bounds, vis);
@@ -1170,6 +1170,28 @@ pub fn noop_visit_anon_const<T: MutVisitor>(AnonConst { id, value }: &mut AnonCo
     vis.visit_expr(value);
 }
 
+fn noop_visit_inline_asm<T: MutVisitor>(asm: &mut InlineAsm, vis: &mut T) {
+    for (op, _) in &mut asm.operands {
+        match op {
+            InlineAsmOperand::In { expr, .. }
+            | InlineAsmOperand::InOut { expr, .. }
+            | InlineAsmOperand::Sym { expr, .. } => vis.visit_expr(expr),
+            InlineAsmOperand::Out { expr, .. } => {
+                if let Some(expr) = expr {
+                    vis.visit_expr(expr);
+                }
+            }
+            InlineAsmOperand::SplitInOut { in_expr, out_expr, .. } => {
+                vis.visit_expr(in_expr);
+                if let Some(out_expr) = out_expr {
+                    vis.visit_expr(out_expr);
+                }
+            }
+            InlineAsmOperand::Const { anon_const, .. } => vis.visit_anon_const(anon_const),
+        }
+    }
+}
+
 pub fn noop_visit_expr<T: MutVisitor>(
     Expr { kind, id, span, attrs, tokens }: &mut Expr,
     vis: &mut T,
@@ -1288,27 +1310,7 @@ pub fn noop_visit_expr<T: MutVisitor>(
         ExprKind::Ret(expr) => {
             visit_opt(expr, |expr| vis.visit_expr(expr));
         }
-        ExprKind::InlineAsm(asm) => {
-            for (op, _) in &mut asm.operands {
-                match op {
-                    InlineAsmOperand::In { expr, .. }
-                    | InlineAsmOperand::InOut { expr, .. }
-                    | InlineAsmOperand::Sym { expr, .. } => vis.visit_expr(expr),
-                    InlineAsmOperand::Out { expr, .. } => {
-                        if let Some(expr) = expr {
-                            vis.visit_expr(expr);
-                        }
-                    }
-                    InlineAsmOperand::SplitInOut { in_expr, out_expr, .. } => {
-                        vis.visit_expr(in_expr);
-                        if let Some(out_expr) = out_expr {
-                            vis.visit_expr(out_expr);
-                        }
-                    }
-                    InlineAsmOperand::Const { anon_const, .. } => vis.visit_anon_const(anon_const),
-                }
-            }
-        }
+        ExprKind::InlineAsm(asm) => noop_visit_inline_asm(asm, vis),
         ExprKind::LlvmInlineAsm(asm) => {
             let LlvmInlineAsm {
                 asm: _,
index 3f35919ae6a2aa7fbcd0266aeedf7936b356282b..c50b334d3e94902d558814db1febdf31dfa07c92 100644 (file)
@@ -90,9 +90,6 @@ fn visit_ident(&mut self, ident: Ident) {
     fn visit_foreign_item(&mut self, i: &'ast ForeignItem) {
         walk_foreign_item(self, i)
     }
-    fn visit_global_asm(&mut self, ga: &'ast GlobalAsm) {
-        walk_global_asm(self, ga)
-    }
     fn visit_item(&mut self, i: &'ast Item) {
         walk_item(self, i)
     }
@@ -299,7 +296,7 @@ pub fn walk_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a Item) {
         ItemKind::ForeignMod(ref foreign_module) => {
             walk_list!(visitor, visit_foreign_item, &foreign_module.items);
         }
-        ItemKind::GlobalAsm(ref ga) => visitor.visit_global_asm(ga),
+        ItemKind::GlobalAsm(ref asm) => walk_inline_asm(visitor, asm),
         ItemKind::TyAlias(box TyAliasKind(_, ref generics, ref bounds, ref ty)) => {
             visitor.visit_generics(generics);
             walk_list!(visitor, visit_param_bound, bounds);
@@ -557,10 +554,6 @@ pub fn walk_foreign_item<'a, V: Visitor<'a>>(visitor: &mut V, item: &'a ForeignI
     }
 }
 
-pub fn walk_global_asm<'a, V: Visitor<'a>>(_: &mut V, _: &'a GlobalAsm) {
-    // Empty!
-}
-
 pub fn walk_param_bound<'a, V: Visitor<'a>>(visitor: &mut V, bound: &'a GenericBound) {
     match *bound {
         GenericBound::Trait(ref typ, ref modifier) => visitor.visit_poly_trait_ref(typ, modifier),
@@ -708,6 +701,28 @@ pub fn walk_anon_const<'a, V: Visitor<'a>>(visitor: &mut V, constant: &'a AnonCo
     visitor.visit_expr(&constant.value);
 }
 
+fn walk_inline_asm<'a, V: Visitor<'a>>(visitor: &mut V, asm: &'a InlineAsm) {
+    for (op, _) in &asm.operands {
+        match op {
+            InlineAsmOperand::In { expr, .. }
+            | InlineAsmOperand::InOut { expr, .. }
+            | InlineAsmOperand::Sym { expr, .. } => visitor.visit_expr(expr),
+            InlineAsmOperand::Out { expr, .. } => {
+                if let Some(expr) = expr {
+                    visitor.visit_expr(expr);
+                }
+            }
+            InlineAsmOperand::SplitInOut { in_expr, out_expr, .. } => {
+                visitor.visit_expr(in_expr);
+                if let Some(out_expr) = out_expr {
+                    visitor.visit_expr(out_expr);
+                }
+            }
+            InlineAsmOperand::Const { anon_const, .. } => visitor.visit_anon_const(anon_const),
+        }
+    }
+}
+
 pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
     walk_list!(visitor, visit_attribute, expression.attrs.iter());
 
@@ -830,29 +845,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
         }
         ExprKind::MacCall(ref mac) => visitor.visit_mac_call(mac),
         ExprKind::Paren(ref subexpression) => visitor.visit_expr(subexpression),
-        ExprKind::InlineAsm(ref ia) => {
-            for (op, _) in &ia.operands {
-                match op {
-                    InlineAsmOperand::In { expr, .. }
-                    | InlineAsmOperand::InOut { expr, .. }
-                    | InlineAsmOperand::Sym { expr, .. } => visitor.visit_expr(expr),
-                    InlineAsmOperand::Out { expr, .. } => {
-                        if let Some(expr) = expr {
-                            visitor.visit_expr(expr);
-                        }
-                    }
-                    InlineAsmOperand::SplitInOut { in_expr, out_expr, .. } => {
-                        visitor.visit_expr(in_expr);
-                        if let Some(out_expr) = out_expr {
-                            visitor.visit_expr(out_expr);
-                        }
-                    }
-                    InlineAsmOperand::Const { anon_const, .. } => {
-                        visitor.visit_anon_const(anon_const)
-                    }
-                }
-            }
-        }
+        ExprKind::InlineAsm(ref asm) => walk_inline_asm(visitor, asm),
         ExprKind::LlvmInlineAsm(ref ia) => {
             for &(_, ref input) in &ia.inputs {
                 visitor.visit_expr(input)
diff --git a/compiler/rustc_ast_lowering/src/asm.rs b/compiler/rustc_ast_lowering/src/asm.rs
new file mode 100644 (file)
index 0000000..1c3fae2
--- /dev/null
@@ -0,0 +1,329 @@
+use super::LoweringContext;
+
+use rustc_ast::*;
+use rustc_data_structures::fx::FxHashMap;
+use rustc_errors::struct_span_err;
+use rustc_hir as hir;
+use rustc_span::{Span, Symbol};
+use rustc_target::asm;
+use std::collections::hash_map::Entry;
+use std::fmt::Write;
+
+impl<'a, 'hir> LoweringContext<'a, 'hir> {
+    crate fn lower_inline_asm(&mut self, sp: Span, asm: &InlineAsm) -> &'hir hir::InlineAsm<'hir> {
+        // Rustdoc needs to support asm! from foriegn architectures: don't try
+        // lowering the register contraints in this case.
+        let asm_arch = if self.sess.opts.actually_rustdoc { None } else { self.sess.asm_arch };
+        if asm_arch.is_none() && !self.sess.opts.actually_rustdoc {
+            struct_span_err!(self.sess, sp, E0472, "inline assembly is unsupported on this target")
+                .emit();
+        }
+        if asm.options.contains(InlineAsmOptions::ATT_SYNTAX)
+            && !matches!(asm_arch, Some(asm::InlineAsmArch::X86 | asm::InlineAsmArch::X86_64))
+            && !self.sess.opts.actually_rustdoc
+        {
+            self.sess
+                .struct_span_err(sp, "the `att_syntax` option is only supported on x86")
+                .emit();
+        }
+
+        // Lower operands to HIR. We use dummy register classes if an error
+        // occurs during lowering because we still need to be able to produce a
+        // valid HIR.
+        let sess = self.sess;
+        let operands: Vec<_> = asm
+            .operands
+            .iter()
+            .map(|(op, op_sp)| {
+                let lower_reg = |reg| match reg {
+                    InlineAsmRegOrRegClass::Reg(s) => {
+                        asm::InlineAsmRegOrRegClass::Reg(if let Some(asm_arch) = asm_arch {
+                            asm::InlineAsmReg::parse(
+                                asm_arch,
+                                |feature| sess.target_features.contains(&Symbol::intern(feature)),
+                                &sess.target,
+                                s,
+                            )
+                            .unwrap_or_else(|e| {
+                                let msg = format!("invalid register `{}`: {}", s.as_str(), e);
+                                sess.struct_span_err(*op_sp, &msg).emit();
+                                asm::InlineAsmReg::Err
+                            })
+                        } else {
+                            asm::InlineAsmReg::Err
+                        })
+                    }
+                    InlineAsmRegOrRegClass::RegClass(s) => {
+                        asm::InlineAsmRegOrRegClass::RegClass(if let Some(asm_arch) = asm_arch {
+                            asm::InlineAsmRegClass::parse(asm_arch, s).unwrap_or_else(|e| {
+                                let msg = format!("invalid register class `{}`: {}", s.as_str(), e);
+                                sess.struct_span_err(*op_sp, &msg).emit();
+                                asm::InlineAsmRegClass::Err
+                            })
+                        } else {
+                            asm::InlineAsmRegClass::Err
+                        })
+                    }
+                };
+
+                let op = match *op {
+                    InlineAsmOperand::In { reg, ref expr } => hir::InlineAsmOperand::In {
+                        reg: lower_reg(reg),
+                        expr: self.lower_expr_mut(expr),
+                    },
+                    InlineAsmOperand::Out { reg, late, ref expr } => hir::InlineAsmOperand::Out {
+                        reg: lower_reg(reg),
+                        late,
+                        expr: expr.as_ref().map(|expr| self.lower_expr_mut(expr)),
+                    },
+                    InlineAsmOperand::InOut { reg, late, ref expr } => {
+                        hir::InlineAsmOperand::InOut {
+                            reg: lower_reg(reg),
+                            late,
+                            expr: self.lower_expr_mut(expr),
+                        }
+                    }
+                    InlineAsmOperand::SplitInOut { reg, late, ref in_expr, ref out_expr } => {
+                        hir::InlineAsmOperand::SplitInOut {
+                            reg: lower_reg(reg),
+                            late,
+                            in_expr: self.lower_expr_mut(in_expr),
+                            out_expr: out_expr.as_ref().map(|expr| self.lower_expr_mut(expr)),
+                        }
+                    }
+                    InlineAsmOperand::Const { ref anon_const } => hir::InlineAsmOperand::Const {
+                        anon_const: self.lower_anon_const(anon_const),
+                    },
+                    InlineAsmOperand::Sym { ref expr } => {
+                        hir::InlineAsmOperand::Sym { expr: self.lower_expr_mut(expr) }
+                    }
+                };
+                (op, *op_sp)
+            })
+            .collect();
+
+        // Validate template modifiers against the register classes for the operands
+        for p in &asm.template {
+            if let InlineAsmTemplatePiece::Placeholder {
+                operand_idx,
+                modifier: Some(modifier),
+                span: placeholder_span,
+            } = *p
+            {
+                let op_sp = asm.operands[operand_idx].1;
+                match &operands[operand_idx].0 {
+                    hir::InlineAsmOperand::In { reg, .. }
+                    | hir::InlineAsmOperand::Out { reg, .. }
+                    | hir::InlineAsmOperand::InOut { reg, .. }
+                    | hir::InlineAsmOperand::SplitInOut { reg, .. } => {
+                        let class = reg.reg_class();
+                        if class == asm::InlineAsmRegClass::Err {
+                            continue;
+                        }
+                        let valid_modifiers = class.valid_modifiers(asm_arch.unwrap());
+                        if !valid_modifiers.contains(&modifier) {
+                            let mut err = sess.struct_span_err(
+                                placeholder_span,
+                                "invalid asm template modifier for this register class",
+                            );
+                            err.span_label(placeholder_span, "template modifier");
+                            err.span_label(op_sp, "argument");
+                            if !valid_modifiers.is_empty() {
+                                let mut mods = format!("`{}`", valid_modifiers[0]);
+                                for m in &valid_modifiers[1..] {
+                                    let _ = write!(mods, ", `{}`", m);
+                                }
+                                err.note(&format!(
+                                    "the `{}` register class supports \
+                                     the following template modifiers: {}",
+                                    class.name(),
+                                    mods
+                                ));
+                            } else {
+                                err.note(&format!(
+                                    "the `{}` register class does not support template modifiers",
+                                    class.name()
+                                ));
+                            }
+                            err.emit();
+                        }
+                    }
+                    hir::InlineAsmOperand::Const { .. } => {
+                        let mut err = sess.struct_span_err(
+                            placeholder_span,
+                            "asm template modifiers are not allowed for `const` arguments",
+                        );
+                        err.span_label(placeholder_span, "template modifier");
+                        err.span_label(op_sp, "argument");
+                        err.emit();
+                    }
+                    hir::InlineAsmOperand::Sym { .. } => {
+                        let mut err = sess.struct_span_err(
+                            placeholder_span,
+                            "asm template modifiers are not allowed for `sym` arguments",
+                        );
+                        err.span_label(placeholder_span, "template modifier");
+                        err.span_label(op_sp, "argument");
+                        err.emit();
+                    }
+                }
+            }
+        }
+
+        let mut used_input_regs = FxHashMap::default();
+        let mut used_output_regs = FxHashMap::default();
+        let mut required_features: Vec<&str> = vec![];
+        for (idx, &(ref op, op_sp)) in operands.iter().enumerate() {
+            if let Some(reg) = op.reg() {
+                // Make sure we don't accidentally carry features from the
+                // previous iteration.
+                required_features.clear();
+
+                let reg_class = reg.reg_class();
+                if reg_class == asm::InlineAsmRegClass::Err {
+                    continue;
+                }
+
+                // We ignore target feature requirements for clobbers: if the
+                // feature is disabled then the compiler doesn't care what we
+                // do with the registers.
+                //
+                // Note that this is only possible for explicit register
+                // operands, which cannot be used in the asm string.
+                let is_clobber = matches!(
+                    op,
+                    hir::InlineAsmOperand::Out {
+                        reg: asm::InlineAsmRegOrRegClass::Reg(_),
+                        late: _,
+                        expr: None
+                    }
+                );
+
+                if !is_clobber {
+                    // Validate register classes against currently enabled target
+                    // features. We check that at least one type is available for
+                    // the current target.
+                    for &(_, feature) in reg_class.supported_types(asm_arch.unwrap()) {
+                        if let Some(feature) = feature {
+                            if self.sess.target_features.contains(&Symbol::intern(feature)) {
+                                required_features.clear();
+                                break;
+                            } else {
+                                required_features.push(feature);
+                            }
+                        } else {
+                            required_features.clear();
+                            break;
+                        }
+                    }
+                    // We are sorting primitive strs here and can use unstable sort here
+                    required_features.sort_unstable();
+                    required_features.dedup();
+                    match &required_features[..] {
+                        [] => {}
+                        [feature] => {
+                            let msg = format!(
+                                "register class `{}` requires the `{}` target feature",
+                                reg_class.name(),
+                                feature
+                            );
+                            sess.struct_span_err(op_sp, &msg).emit();
+                        }
+                        features => {
+                            let msg = format!(
+                                "register class `{}` requires at least one target feature: {}",
+                                reg_class.name(),
+                                features.join(", ")
+                            );
+                            sess.struct_span_err(op_sp, &msg).emit();
+                        }
+                    }
+                }
+
+                // Check for conflicts between explicit register operands.
+                if let asm::InlineAsmRegOrRegClass::Reg(reg) = reg {
+                    let (input, output) = match op {
+                        hir::InlineAsmOperand::In { .. } => (true, false),
+
+                        // Late output do not conflict with inputs, but normal outputs do
+                        hir::InlineAsmOperand::Out { late, .. } => (!late, true),
+
+                        hir::InlineAsmOperand::InOut { .. }
+                        | hir::InlineAsmOperand::SplitInOut { .. } => (true, true),
+
+                        hir::InlineAsmOperand::Const { .. } | hir::InlineAsmOperand::Sym { .. } => {
+                            unreachable!()
+                        }
+                    };
+
+                    // Flag to output the error only once per operand
+                    let mut skip = false;
+                    reg.overlapping_regs(|r| {
+                        let mut check = |used_regs: &mut FxHashMap<asm::InlineAsmReg, usize>,
+                                         input| {
+                            match used_regs.entry(r) {
+                                Entry::Occupied(o) => {
+                                    if skip {
+                                        return;
+                                    }
+                                    skip = true;
+
+                                    let idx2 = *o.get();
+                                    let &(ref op2, op_sp2) = &operands[idx2];
+                                    let reg2 = match op2.reg() {
+                                        Some(asm::InlineAsmRegOrRegClass::Reg(r)) => r,
+                                        _ => unreachable!(),
+                                    };
+
+                                    let msg = format!(
+                                        "register `{}` conflicts with register `{}`",
+                                        reg.name(),
+                                        reg2.name()
+                                    );
+                                    let mut err = sess.struct_span_err(op_sp, &msg);
+                                    err.span_label(op_sp, &format!("register `{}`", reg.name()));
+                                    err.span_label(op_sp2, &format!("register `{}`", reg2.name()));
+
+                                    match (op, op2) {
+                                        (
+                                            hir::InlineAsmOperand::In { .. },
+                                            hir::InlineAsmOperand::Out { late, .. },
+                                        )
+                                        | (
+                                            hir::InlineAsmOperand::Out { late, .. },
+                                            hir::InlineAsmOperand::In { .. },
+                                        ) => {
+                                            assert!(!*late);
+                                            let out_op_sp = if input { op_sp2 } else { op_sp };
+                                            let msg = "use `lateout` instead of \
+                                                       `out` to avoid conflict";
+                                            err.span_help(out_op_sp, msg);
+                                        }
+                                        _ => {}
+                                    }
+
+                                    err.emit();
+                                }
+                                Entry::Vacant(v) => {
+                                    v.insert(idx);
+                                }
+                            }
+                        };
+                        if input {
+                            check(&mut used_input_regs, true);
+                        }
+                        if output {
+                            check(&mut used_output_regs, false);
+                        }
+                    });
+                }
+            }
+        }
+
+        let operands = self.arena.alloc_from_iter(operands);
+        let template = self.arena.alloc_from_iter(asm.template.iter().cloned());
+        let line_spans = self.arena.alloc_slice(&asm.line_spans[..]);
+        let hir_asm = hir::InlineAsm { template, operands, options: asm.options, line_spans };
+        self.arena.alloc(hir_asm)
+    }
+}
index ea0770daf0eed86232bc7dca6c1944fdcd6108b1..483135ed3a3af56edbc262f9d3719bd47fe7cf3a 100644 (file)
@@ -3,7 +3,6 @@
 use rustc_ast::attr;
 use rustc_ast::ptr::P as AstP;
 use rustc_ast::*;
-use rustc_data_structures::fx::FxHashMap;
 use rustc_data_structures::stack::ensure_sufficient_stack;
 use rustc_data_structures::thin_vec::ThinVec;
 use rustc_errors::struct_span_err;
@@ -15,9 +14,6 @@
 use rustc_span::source_map::{respan, DesugaringKind, Span, Spanned};
 use rustc_span::symbol::{sym, Ident, Symbol};
 use rustc_span::{hygiene::ForLoopLoc, DUMMY_SP};
-use rustc_target::asm;
-use std::collections::hash_map::Entry;
-use std::fmt::Write;
 
 impl<'hir> LoweringContext<'_, 'hir> {
     fn lower_exprs(&mut self, exprs: &[AstP<Expr>]) -> &'hir [hir::Expr<'hir>] {
@@ -222,7 +218,9 @@ pub(super) fn lower_expr_mut(&mut self, e: &Expr) -> hir::Expr<'hir> {
                     let e = e.as_ref().map(|x| self.lower_expr(x));
                     hir::ExprKind::Ret(e)
                 }
-                ExprKind::InlineAsm(ref asm) => self.lower_expr_asm(e.span, asm),
+                ExprKind::InlineAsm(ref asm) => {
+                    hir::ExprKind::InlineAsm(self.lower_inline_asm(e.span, asm))
+                }
                 ExprKind::LlvmInlineAsm(ref asm) => self.lower_expr_llvm_asm(asm),
                 ExprKind::Struct(ref se) => {
                     let rest = match &se.rest {
@@ -1329,319 +1327,6 @@ fn with_loop_condition_scope<T>(&mut self, f: impl FnOnce(&mut Self) -> T) -> T
         result
     }
 
-    fn lower_expr_asm(&mut self, sp: Span, asm: &InlineAsm) -> hir::ExprKind<'hir> {
-        // Rustdoc needs to support asm! from foriegn architectures: don't try
-        // lowering the register contraints in this case.
-        let asm_arch = if self.sess.opts.actually_rustdoc { None } else { self.sess.asm_arch };
-        if asm_arch.is_none() && !self.sess.opts.actually_rustdoc {
-            struct_span_err!(self.sess, sp, E0472, "asm! is unsupported on this target").emit();
-        }
-        if asm.options.contains(InlineAsmOptions::ATT_SYNTAX)
-            && !matches!(asm_arch, Some(asm::InlineAsmArch::X86 | asm::InlineAsmArch::X86_64))
-            && !self.sess.opts.actually_rustdoc
-        {
-            self.sess
-                .struct_span_err(sp, "the `att_syntax` option is only supported on x86")
-                .emit();
-        }
-
-        // Lower operands to HIR. We use dummy register classes if an error
-        // occurs during lowering because we still need to be able to produce a
-        // valid HIR.
-        let sess = self.sess;
-        let operands: Vec<_> = asm
-            .operands
-            .iter()
-            .map(|(op, op_sp)| {
-                let lower_reg = |reg| match reg {
-                    InlineAsmRegOrRegClass::Reg(s) => {
-                        asm::InlineAsmRegOrRegClass::Reg(if let Some(asm_arch) = asm_arch {
-                            asm::InlineAsmReg::parse(
-                                asm_arch,
-                                |feature| sess.target_features.contains(&Symbol::intern(feature)),
-                                &sess.target,
-                                s,
-                            )
-                            .unwrap_or_else(|e| {
-                                let msg = format!("invalid register `{}`: {}", s.as_str(), e);
-                                sess.struct_span_err(*op_sp, &msg).emit();
-                                asm::InlineAsmReg::Err
-                            })
-                        } else {
-                            asm::InlineAsmReg::Err
-                        })
-                    }
-                    InlineAsmRegOrRegClass::RegClass(s) => {
-                        asm::InlineAsmRegOrRegClass::RegClass(if let Some(asm_arch) = asm_arch {
-                            asm::InlineAsmRegClass::parse(asm_arch, s).unwrap_or_else(|e| {
-                                let msg = format!("invalid register class `{}`: {}", s.as_str(), e);
-                                sess.struct_span_err(*op_sp, &msg).emit();
-                                asm::InlineAsmRegClass::Err
-                            })
-                        } else {
-                            asm::InlineAsmRegClass::Err
-                        })
-                    }
-                };
-
-                let op = match *op {
-                    InlineAsmOperand::In { reg, ref expr } => hir::InlineAsmOperand::In {
-                        reg: lower_reg(reg),
-                        expr: self.lower_expr_mut(expr),
-                    },
-                    InlineAsmOperand::Out { reg, late, ref expr } => hir::InlineAsmOperand::Out {
-                        reg: lower_reg(reg),
-                        late,
-                        expr: expr.as_ref().map(|expr| self.lower_expr_mut(expr)),
-                    },
-                    InlineAsmOperand::InOut { reg, late, ref expr } => {
-                        hir::InlineAsmOperand::InOut {
-                            reg: lower_reg(reg),
-                            late,
-                            expr: self.lower_expr_mut(expr),
-                        }
-                    }
-                    InlineAsmOperand::SplitInOut { reg, late, ref in_expr, ref out_expr } => {
-                        hir::InlineAsmOperand::SplitInOut {
-                            reg: lower_reg(reg),
-                            late,
-                            in_expr: self.lower_expr_mut(in_expr),
-                            out_expr: out_expr.as_ref().map(|expr| self.lower_expr_mut(expr)),
-                        }
-                    }
-                    InlineAsmOperand::Const { ref anon_const } => hir::InlineAsmOperand::Const {
-                        anon_const: self.lower_anon_const(anon_const),
-                    },
-                    InlineAsmOperand::Sym { ref expr } => {
-                        hir::InlineAsmOperand::Sym { expr: self.lower_expr_mut(expr) }
-                    }
-                };
-                (op, *op_sp)
-            })
-            .collect();
-
-        // Validate template modifiers against the register classes for the operands
-        for p in &asm.template {
-            if let InlineAsmTemplatePiece::Placeholder {
-                operand_idx,
-                modifier: Some(modifier),
-                span: placeholder_span,
-            } = *p
-            {
-                let op_sp = asm.operands[operand_idx].1;
-                match &operands[operand_idx].0 {
-                    hir::InlineAsmOperand::In { reg, .. }
-                    | hir::InlineAsmOperand::Out { reg, .. }
-                    | hir::InlineAsmOperand::InOut { reg, .. }
-                    | hir::InlineAsmOperand::SplitInOut { reg, .. } => {
-                        let class = reg.reg_class();
-                        if class == asm::InlineAsmRegClass::Err {
-                            continue;
-                        }
-                        let valid_modifiers = class.valid_modifiers(asm_arch.unwrap());
-                        if !valid_modifiers.contains(&modifier) {
-                            let mut err = sess.struct_span_err(
-                                placeholder_span,
-                                "invalid asm template modifier for this register class",
-                            );
-                            err.span_label(placeholder_span, "template modifier");
-                            err.span_label(op_sp, "argument");
-                            if !valid_modifiers.is_empty() {
-                                let mut mods = format!("`{}`", valid_modifiers[0]);
-                                for m in &valid_modifiers[1..] {
-                                    let _ = write!(mods, ", `{}`", m);
-                                }
-                                err.note(&format!(
-                                    "the `{}` register class supports \
-                                     the following template modifiers: {}",
-                                    class.name(),
-                                    mods
-                                ));
-                            } else {
-                                err.note(&format!(
-                                    "the `{}` register class does not support template modifiers",
-                                    class.name()
-                                ));
-                            }
-                            err.emit();
-                        }
-                    }
-                    hir::InlineAsmOperand::Const { .. } => {
-                        let mut err = sess.struct_span_err(
-                            placeholder_span,
-                            "asm template modifiers are not allowed for `const` arguments",
-                        );
-                        err.span_label(placeholder_span, "template modifier");
-                        err.span_label(op_sp, "argument");
-                        err.emit();
-                    }
-                    hir::InlineAsmOperand::Sym { .. } => {
-                        let mut err = sess.struct_span_err(
-                            placeholder_span,
-                            "asm template modifiers are not allowed for `sym` arguments",
-                        );
-                        err.span_label(placeholder_span, "template modifier");
-                        err.span_label(op_sp, "argument");
-                        err.emit();
-                    }
-                }
-            }
-        }
-
-        let mut used_input_regs = FxHashMap::default();
-        let mut used_output_regs = FxHashMap::default();
-        let mut required_features: Vec<&str> = vec![];
-        for (idx, &(ref op, op_sp)) in operands.iter().enumerate() {
-            if let Some(reg) = op.reg() {
-                // Make sure we don't accidentally carry features from the
-                // previous iteration.
-                required_features.clear();
-
-                let reg_class = reg.reg_class();
-                if reg_class == asm::InlineAsmRegClass::Err {
-                    continue;
-                }
-
-                // We ignore target feature requirements for clobbers: if the
-                // feature is disabled then the compiler doesn't care what we
-                // do with the registers.
-                //
-                // Note that this is only possible for explicit register
-                // operands, which cannot be used in the asm string.
-                let is_clobber = matches!(
-                    op,
-                    hir::InlineAsmOperand::Out {
-                        reg: asm::InlineAsmRegOrRegClass::Reg(_),
-                        late: _,
-                        expr: None
-                    }
-                );
-
-                if !is_clobber {
-                    // Validate register classes against currently enabled target
-                    // features. We check that at least one type is available for
-                    // the current target.
-                    for &(_, feature) in reg_class.supported_types(asm_arch.unwrap()) {
-                        if let Some(feature) = feature {
-                            if self.sess.target_features.contains(&Symbol::intern(feature)) {
-                                required_features.clear();
-                                break;
-                            } else {
-                                required_features.push(feature);
-                            }
-                        } else {
-                            required_features.clear();
-                            break;
-                        }
-                    }
-                    // We are sorting primitive strs here and can use unstable sort here
-                    required_features.sort_unstable();
-                    required_features.dedup();
-                    match &required_features[..] {
-                        [] => {}
-                        [feature] => {
-                            let msg = format!(
-                                "register class `{}` requires the `{}` target feature",
-                                reg_class.name(),
-                                feature
-                            );
-                            sess.struct_span_err(op_sp, &msg).emit();
-                        }
-                        features => {
-                            let msg = format!(
-                                "register class `{}` requires at least one target feature: {}",
-                                reg_class.name(),
-                                features.join(", ")
-                            );
-                            sess.struct_span_err(op_sp, &msg).emit();
-                        }
-                    }
-                }
-
-                // Check for conflicts between explicit register operands.
-                if let asm::InlineAsmRegOrRegClass::Reg(reg) = reg {
-                    let (input, output) = match op {
-                        hir::InlineAsmOperand::In { .. } => (true, false),
-                        // Late output do not conflict with inputs, but normal outputs do
-                        hir::InlineAsmOperand::Out { late, .. } => (!late, true),
-                        hir::InlineAsmOperand::InOut { .. }
-                        | hir::InlineAsmOperand::SplitInOut { .. } => (true, true),
-                        hir::InlineAsmOperand::Const { .. } | hir::InlineAsmOperand::Sym { .. } => {
-                            unreachable!()
-                        }
-                    };
-
-                    // Flag to output the error only once per operand
-                    let mut skip = false;
-                    reg.overlapping_regs(|r| {
-                        let mut check = |used_regs: &mut FxHashMap<asm::InlineAsmReg, usize>,
-                                         input| {
-                            match used_regs.entry(r) {
-                                Entry::Occupied(o) => {
-                                    if skip {
-                                        return;
-                                    }
-                                    skip = true;
-
-                                    let idx2 = *o.get();
-                                    let &(ref op2, op_sp2) = &operands[idx2];
-                                    let reg2 = match op2.reg() {
-                                        Some(asm::InlineAsmRegOrRegClass::Reg(r)) => r,
-                                        _ => unreachable!(),
-                                    };
-
-                                    let msg = format!(
-                                        "register `{}` conflicts with register `{}`",
-                                        reg.name(),
-                                        reg2.name()
-                                    );
-                                    let mut err = sess.struct_span_err(op_sp, &msg);
-                                    err.span_label(op_sp, &format!("register `{}`", reg.name()));
-                                    err.span_label(op_sp2, &format!("register `{}`", reg2.name()));
-
-                                    match (op, op2) {
-                                        (
-                                            hir::InlineAsmOperand::In { .. },
-                                            hir::InlineAsmOperand::Out { late, .. },
-                                        )
-                                        | (
-                                            hir::InlineAsmOperand::Out { late, .. },
-                                            hir::InlineAsmOperand::In { .. },
-                                        ) => {
-                                            assert!(!*late);
-                                            let out_op_sp = if input { op_sp2 } else { op_sp };
-                                            let msg = "use `lateout` instead of \
-                                                    `out` to avoid conflict";
-                                            err.span_help(out_op_sp, msg);
-                                        }
-                                        _ => {}
-                                    }
-
-                                    err.emit();
-                                }
-                                Entry::Vacant(v) => {
-                                    v.insert(idx);
-                                }
-                            }
-                        };
-                        if input {
-                            check(&mut used_input_regs, true);
-                        }
-                        if output {
-                            check(&mut used_output_regs, false);
-                        }
-                    });
-                }
-            }
-        }
-
-        let operands = self.arena.alloc_from_iter(operands);
-        let template = self.arena.alloc_from_iter(asm.template.iter().cloned());
-        let line_spans = self.arena.alloc_slice(&asm.line_spans[..]);
-        let hir_asm = hir::InlineAsm { template, operands, options: asm.options, line_spans };
-        hir::ExprKind::InlineAsm(self.arena.alloc(hir_asm))
-    }
-
     fn lower_expr_llvm_asm(&mut self, asm: &LlvmInlineAsm) -> hir::ExprKind<'hir> {
         let inner = hir::LlvmInlineAsmInner {
             inputs: asm.inputs.iter().map(|&(c, _)| c).collect(),
index 5fd8f7eb33a1fa882fdc068c3397cdaf0024dec6..aa236a690ec79757ad0f2470e3b1a8273a1493c7 100644 (file)
@@ -329,7 +329,9 @@ fn lower_item_kind(
                         .alloc_from_iter(fm.items.iter().map(|x| self.lower_foreign_item_ref(x))),
                 }
             }
-            ItemKind::GlobalAsm(ref ga) => hir::ItemKind::GlobalAsm(self.lower_global_asm(ga)),
+            ItemKind::GlobalAsm(ref asm) => {
+                hir::ItemKind::GlobalAsm(self.lower_inline_asm(span, asm))
+            }
             ItemKind::TyAlias(box TyAliasKind(_, ref gen, _, Some(ref ty))) => {
                 // We lower
                 //
@@ -746,10 +748,6 @@ fn lower_foreign_item_ref(&mut self, i: &ForeignItem) -> hir::ForeignItemRef<'hi
         }
     }
 
-    fn lower_global_asm(&mut self, ga: &GlobalAsm) -> &'hir hir::GlobalAsm {
-        self.arena.alloc(hir::GlobalAsm { asm: ga.asm })
-    }
-
     fn lower_variant(&mut self, v: &Variant) -> hir::Variant<'hir> {
         let id = self.lower_node_id(v.id);
         self.lower_attrs(id, &v.attrs);
index 32320130b677cb3e77eef856e493c24489cff013..0439de0ee7bf9727b0cb3459644625b04ffd9c07 100644 (file)
@@ -62,7 +62,7 @@
 use rustc_span::hygiene::ExpnId;
 use rustc_span::source_map::{respan, DesugaringKind};
 use rustc_span::symbol::{kw, sym, Ident, Symbol};
-use rustc_span::Span;
+use rustc_span::{Span, DUMMY_SP};
 use rustc_target::spec::abi::Abi;
 
 use smallvec::{smallvec, SmallVec};
@@ -77,6 +77,7 @@ macro_rules! arena_vec {
     });
 }
 
+mod asm;
 mod expr;
 mod item;
 mod pat;
@@ -2084,6 +2085,7 @@ fn lower_async_fn_output_type_to_future_bound(
             args: &[],
             bindings: arena_vec![self; self.output_ty_binding(span, output_ty)],
             parenthesized: false,
+            span_ext: DUMMY_SP,
         });
 
         hir::GenericBound::LangItemTrait(
@@ -2788,6 +2790,7 @@ struct GenericArgsCtor<'hir> {
     args: SmallVec<[hir::GenericArg<'hir>; 4]>,
     bindings: &'hir [hir::TypeBinding<'hir>],
     parenthesized: bool,
+    span: Span,
 }
 
 impl<'hir> GenericArgsCtor<'hir> {
@@ -2800,6 +2803,7 @@ fn into_generic_args(self, arena: &'hir Arena<'hir>) -> hir::GenericArgs<'hir> {
             args: arena.alloc_from_iter(self.args),
             bindings: self.bindings,
             parenthesized: self.parenthesized,
+            span_ext: self.span,
         }
     }
 }
index 46dac2f1af4f407fe67c75fa3f6971a429277916..fe9f1fb20f05608fe21bc43ffe957ee80a52d6ea 100644 (file)
@@ -10,7 +10,7 @@
 use rustc_session::lint::builtin::ELIDED_LIFETIMES_IN_PATHS;
 use rustc_session::lint::BuiltinLintDiagnostics;
 use rustc_span::symbol::Ident;
-use rustc_span::Span;
+use rustc_span::{BytePos, Span, DUMMY_SP};
 
 use smallvec::smallvec;
 use tracing::debug;
@@ -24,6 +24,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
         param_mode: ParamMode,
         mut itctx: ImplTraitContext<'_, 'hir>,
     ) -> hir::QPath<'hir> {
+        debug!("lower_qpath(id: {:?}, qself: {:?}, p: {:?})", id, qself, p);
         let qself_position = qself.as_ref().map(|q| q.position);
         let qself = qself.as_ref().map(|q| self.lower_ty(&q.ty, itctx.reborrow()));
 
@@ -222,6 +223,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
         itctx: ImplTraitContext<'_, 'hir>,
         explicit_owner: Option<NodeId>,
     ) -> hir::PathSegment<'hir> {
+        debug!(
+            "path_span: {:?}, lower_path_segment(segment: {:?}, expected_lifetimes: {:?})",
+            path_span, segment, expected_lifetimes
+        );
         let (mut generic_args, infer_args) = if let Some(ref generic_args) = segment.args {
             let msg = "parenthesized type parameters may only be used with a `Fn` trait";
             match **generic_args {
@@ -262,23 +267,34 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
                 },
             }
         } else {
-            self.lower_angle_bracketed_parameter_data(&Default::default(), param_mode, itctx)
+            (
+                GenericArgsCtor {
+                    args: Default::default(),
+                    bindings: &[],
+                    parenthesized: false,
+                    span: path_span.shrink_to_hi(),
+                },
+                param_mode == ParamMode::Optional,
+            )
         };
 
         let has_lifetimes =
             generic_args.args.iter().any(|arg| matches!(arg, GenericArg::Lifetime(_)));
-        let first_generic_span = generic_args
-            .args
-            .iter()
-            .map(|a| a.span())
-            .chain(generic_args.bindings.iter().map(|b| b.span))
-            .next();
         if !generic_args.parenthesized && !has_lifetimes {
+            // Note: these spans are used for diagnostics when they can't be inferred.
+            // See rustc_resolve::late::lifetimes::LifetimeContext::add_missing_lifetime_specifiers_label
+            let elided_lifetime_span = if generic_args.span.is_empty() {
+                // If there are no brackets, use the identifier span.
+                segment.ident.span
+            } else if generic_args.is_empty() {
+                // If there are brackets, but not generic arguments, then use the opening bracket
+                generic_args.span.with_hi(generic_args.span.lo() + BytePos(1))
+            } else {
+                // Else use an empty span right after the opening bracket.
+                generic_args.span.with_lo(generic_args.span.lo() + BytePos(1)).shrink_to_lo()
+            };
             generic_args.args = self
-                .elided_path_lifetimes(
-                    first_generic_span.map_or(segment.ident.span, |s| s.shrink_to_lo()),
-                    expected_lifetimes,
-                )
+                .elided_path_lifetimes(elided_lifetime_span, expected_lifetimes)
                 .map(GenericArg::Lifetime)
                 .chain(generic_args.args.into_iter())
                 .collect();
@@ -287,15 +303,15 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
                 let no_non_lt_args = generic_args.args.len() == expected_lifetimes;
                 let no_bindings = generic_args.bindings.is_empty();
                 let (incl_angl_brckt, insertion_sp, suggestion) = if no_non_lt_args && no_bindings {
-                    // If there are no (non-implicit) generic args or associated type
-                    // bindings, our suggestion includes the angle brackets.
+                    // If there are no generic args, our suggestion can include the angle brackets.
                     (true, path_span.shrink_to_hi(), format!("<{}>", anon_lt_suggestion))
                 } else {
-                    // Otherwise (sorry, this is kind of gross) we need to infer the
-                    // place to splice in the `'_, ` from the generics that do exist.
-                    let first_generic_span = first_generic_span
-                        .expect("already checked that non-lifetime args or bindings exist");
-                    (false, first_generic_span.shrink_to_lo(), format!("{}, ", anon_lt_suggestion))
+                    // Otherwise we'll insert a `'_, ` right after the opening bracket.
+                    let span = generic_args
+                        .span
+                        .with_lo(generic_args.span.lo() + BytePos(1))
+                        .shrink_to_lo();
+                    (false, span, format!("{}, ", anon_lt_suggestion))
                 };
                 match self.anonymous_lifetime_mode {
                     // In create-parameter mode we error here because we don't want to support
@@ -357,7 +373,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
             hir_id: Some(id),
             res: Some(self.lower_res(res)),
             infer_args,
-            args: if generic_args.is_empty() {
+            args: if generic_args.is_empty() && generic_args.span.is_empty() {
                 None
             } else {
                 Some(self.arena.alloc(generic_args.into_generic_args(self.arena)))
@@ -390,7 +406,7 @@ pub(crate) fn lower_angle_bracketed_parameter_data(
             }
             AngleBracketedArg::Arg(_) => None,
         }));
-        let ctor = GenericArgsCtor { args, bindings, parenthesized: false };
+        let ctor = GenericArgsCtor { args, bindings, parenthesized: false, span: data.span };
         (ctor, !has_non_lt_args && param_mode == ParamMode::Optional)
     }
 
@@ -415,7 +431,12 @@ fn lower_parenthesized_parameter_data(
             let args = smallvec![GenericArg::Type(this.ty_tup(*inputs_span, inputs))];
             let binding = this.output_ty_binding(output_ty.span, output_ty);
             (
-                GenericArgsCtor { args, bindings: arena_vec![this; binding], parenthesized: true },
+                GenericArgsCtor {
+                    args,
+                    bindings: arena_vec![this; binding],
+                    parenthesized: true,
+                    span: data.inputs_span,
+                },
                 false,
             )
         })
@@ -431,7 +452,12 @@ fn lower_parenthesized_parameter_data(
         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 });
+        let gen_args = self.arena.alloc(hir::GenericArgs {
+            args,
+            bindings,
+            parenthesized: false,
+            span_ext: DUMMY_SP,
+        });
         hir::TypeBinding { hir_id: self.next_id(), gen_args, span, ident, kind }
     }
 }
index fdcb68cf421c1e058d10459fda8d2878d1189c39..0e42e0e3793f5a634362cf5c7d8c5833fba4d644 100644 (file)
@@ -1164,9 +1164,9 @@ fn print_associated_type(
                 self.print_foreign_mod(nmod, &item.attrs);
                 self.bclose(item.span);
             }
-            ast::ItemKind::GlobalAsm(ref ga) => {
+            ast::ItemKind::GlobalAsm(ref asm) => {
                 self.head(visibility_qualified(&item.vis, "global_asm!"));
-                self.s.word(ga.asm.to_string());
+                self.print_inline_asm(asm);
                 self.end();
             }
             ast::ItemKind::TyAlias(box ast::TyAliasKind(def, ref generics, ref bounds, ref ty)) => {
@@ -2066,117 +2066,8 @@ fn print_expr_outer_attr_style(&mut self, expr: &ast::Expr, is_inline: bool) {
                 }
             }
             ast::ExprKind::InlineAsm(ref a) => {
-                enum AsmArg<'a> {
-                    Template(String),
-                    Operand(&'a InlineAsmOperand),
-                    Options(InlineAsmOptions),
-                }
-
-                let mut args = vec![];
-                args.push(AsmArg::Template(InlineAsmTemplatePiece::to_string(&a.template)));
-                args.extend(a.operands.iter().map(|(o, _)| AsmArg::Operand(o)));
-                if !a.options.is_empty() {
-                    args.push(AsmArg::Options(a.options));
-                }
-
                 self.word("asm!");
-                self.popen();
-                self.commasep(Consistent, &args, |s, arg| match arg {
-                    AsmArg::Template(template) => s.print_string(&template, ast::StrStyle::Cooked),
-                    AsmArg::Operand(op) => {
-                        let print_reg_or_class = |s: &mut Self, r: &InlineAsmRegOrRegClass| match r
-                        {
-                            InlineAsmRegOrRegClass::Reg(r) => {
-                                s.print_symbol(*r, ast::StrStyle::Cooked)
-                            }
-                            InlineAsmRegOrRegClass::RegClass(r) => s.word(r.to_string()),
-                        };
-                        match op {
-                            InlineAsmOperand::In { reg, expr } => {
-                                s.word("in");
-                                s.popen();
-                                print_reg_or_class(s, reg);
-                                s.pclose();
-                                s.space();
-                                s.print_expr(expr);
-                            }
-                            InlineAsmOperand::Out { reg, late, expr } => {
-                                s.word(if *late { "lateout" } else { "out" });
-                                s.popen();
-                                print_reg_or_class(s, reg);
-                                s.pclose();
-                                s.space();
-                                match expr {
-                                    Some(expr) => s.print_expr(expr),
-                                    None => s.word("_"),
-                                }
-                            }
-                            InlineAsmOperand::InOut { reg, late, expr } => {
-                                s.word(if *late { "inlateout" } else { "inout" });
-                                s.popen();
-                                print_reg_or_class(s, reg);
-                                s.pclose();
-                                s.space();
-                                s.print_expr(expr);
-                            }
-                            InlineAsmOperand::SplitInOut { reg, late, in_expr, out_expr } => {
-                                s.word(if *late { "inlateout" } else { "inout" });
-                                s.popen();
-                                print_reg_or_class(s, reg);
-                                s.pclose();
-                                s.space();
-                                s.print_expr(in_expr);
-                                s.space();
-                                s.word_space("=>");
-                                match out_expr {
-                                    Some(out_expr) => s.print_expr(out_expr),
-                                    None => s.word("_"),
-                                }
-                            }
-                            InlineAsmOperand::Const { anon_const } => {
-                                s.word("const");
-                                s.space();
-                                s.print_expr(&anon_const.value);
-                            }
-                            InlineAsmOperand::Sym { expr } => {
-                                s.word("sym");
-                                s.space();
-                                s.print_expr(expr);
-                            }
-                        }
-                    }
-                    AsmArg::Options(opts) => {
-                        s.word("options");
-                        s.popen();
-                        let mut options = vec![];
-                        if opts.contains(InlineAsmOptions::PURE) {
-                            options.push("pure");
-                        }
-                        if opts.contains(InlineAsmOptions::NOMEM) {
-                            options.push("nomem");
-                        }
-                        if opts.contains(InlineAsmOptions::READONLY) {
-                            options.push("readonly");
-                        }
-                        if opts.contains(InlineAsmOptions::PRESERVES_FLAGS) {
-                            options.push("preserves_flags");
-                        }
-                        if opts.contains(InlineAsmOptions::NORETURN) {
-                            options.push("noreturn");
-                        }
-                        if opts.contains(InlineAsmOptions::NOSTACK) {
-                            options.push("nostack");
-                        }
-                        if opts.contains(InlineAsmOptions::ATT_SYNTAX) {
-                            options.push("att_syntax");
-                        }
-                        s.commasep(Inconsistent, &options, |s, &opt| {
-                            s.word(opt);
-                        });
-                        s.pclose();
-                    }
-                });
-                self.pclose();
+                self.print_inline_asm(a);
             }
             ast::ExprKind::LlvmInlineAsm(ref a) => {
                 self.s.word("llvm_asm!");
@@ -2267,6 +2158,116 @@ enum AsmArg<'a> {
         self.end();
     }
 
+    fn print_inline_asm(&mut self, asm: &ast::InlineAsm) {
+        enum AsmArg<'a> {
+            Template(String),
+            Operand(&'a InlineAsmOperand),
+            Options(InlineAsmOptions),
+        }
+
+        let mut args = vec![];
+        args.push(AsmArg::Template(InlineAsmTemplatePiece::to_string(&asm.template)));
+        args.extend(asm.operands.iter().map(|(o, _)| AsmArg::Operand(o)));
+        if !asm.options.is_empty() {
+            args.push(AsmArg::Options(asm.options));
+        }
+
+        self.popen();
+        self.commasep(Consistent, &args, |s, arg| match arg {
+            AsmArg::Template(template) => s.print_string(&template, ast::StrStyle::Cooked),
+            AsmArg::Operand(op) => {
+                let print_reg_or_class = |s: &mut Self, r: &InlineAsmRegOrRegClass| match r {
+                    InlineAsmRegOrRegClass::Reg(r) => s.print_symbol(*r, ast::StrStyle::Cooked),
+                    InlineAsmRegOrRegClass::RegClass(r) => s.word(r.to_string()),
+                };
+                match op {
+                    InlineAsmOperand::In { reg, expr } => {
+                        s.word("in");
+                        s.popen();
+                        print_reg_or_class(s, reg);
+                        s.pclose();
+                        s.space();
+                        s.print_expr(expr);
+                    }
+                    InlineAsmOperand::Out { reg, late, expr } => {
+                        s.word(if *late { "lateout" } else { "out" });
+                        s.popen();
+                        print_reg_or_class(s, reg);
+                        s.pclose();
+                        s.space();
+                        match expr {
+                            Some(expr) => s.print_expr(expr),
+                            None => s.word("_"),
+                        }
+                    }
+                    InlineAsmOperand::InOut { reg, late, expr } => {
+                        s.word(if *late { "inlateout" } else { "inout" });
+                        s.popen();
+                        print_reg_or_class(s, reg);
+                        s.pclose();
+                        s.space();
+                        s.print_expr(expr);
+                    }
+                    InlineAsmOperand::SplitInOut { reg, late, in_expr, out_expr } => {
+                        s.word(if *late { "inlateout" } else { "inout" });
+                        s.popen();
+                        print_reg_or_class(s, reg);
+                        s.pclose();
+                        s.space();
+                        s.print_expr(in_expr);
+                        s.space();
+                        s.word_space("=>");
+                        match out_expr {
+                            Some(out_expr) => s.print_expr(out_expr),
+                            None => s.word("_"),
+                        }
+                    }
+                    InlineAsmOperand::Const { anon_const } => {
+                        s.word("const");
+                        s.space();
+                        s.print_expr(&anon_const.value);
+                    }
+                    InlineAsmOperand::Sym { expr } => {
+                        s.word("sym");
+                        s.space();
+                        s.print_expr(expr);
+                    }
+                }
+            }
+            AsmArg::Options(opts) => {
+                s.word("options");
+                s.popen();
+                let mut options = vec![];
+                if opts.contains(InlineAsmOptions::PURE) {
+                    options.push("pure");
+                }
+                if opts.contains(InlineAsmOptions::NOMEM) {
+                    options.push("nomem");
+                }
+                if opts.contains(InlineAsmOptions::READONLY) {
+                    options.push("readonly");
+                }
+                if opts.contains(InlineAsmOptions::PRESERVES_FLAGS) {
+                    options.push("preserves_flags");
+                }
+                if opts.contains(InlineAsmOptions::NORETURN) {
+                    options.push("noreturn");
+                }
+                if opts.contains(InlineAsmOptions::NOSTACK) {
+                    options.push("nostack");
+                }
+                if opts.contains(InlineAsmOptions::ATT_SYNTAX) {
+                    options.push("att_syntax");
+                }
+                s.commasep(Inconsistent, &options, |s, &opt| {
+                    s.word(opt);
+                });
+                s.pclose();
+            }
+        });
+        self.pclose();
+    }
+
     crate fn print_local_decl(&mut self, loc: &ast::Local) {
         self.print_pat(&loc.pat);
         if let Some(ref ty) = loc.ty {
index fd976b119b748bcf8a9a8dd30d814d4e6ea4c654..b28c6f0d99c5e0ebb5ac2d5708d4663f5a235144 100644 (file)
@@ -8,9 +8,11 @@
 use rustc_parse::parser::Parser;
 use rustc_parse_format as parse;
 use rustc_session::lint;
+use rustc_span::symbol::Ident;
 use rustc_span::symbol::{kw, sym, Symbol};
 use rustc_span::{InnerSpan, Span};
 use rustc_target::asm::InlineAsmArch;
+use smallvec::smallvec;
 
 struct AsmArgs {
     templates: Vec<P<ast::Expr>>,
@@ -25,6 +27,7 @@ fn parse_args<'a>(
     ecx: &mut ExtCtxt<'a>,
     sp: Span,
     tts: TokenStream,
+    is_global_asm: bool,
 ) -> Result<AsmArgs, DiagnosticBuilder<'a>> {
     let mut p = ecx.new_parser_from_tts(tts);
 
@@ -33,7 +36,7 @@ fn parse_args<'a>(
     }
 
     // Detect use of the legacy llvm_asm! syntax (which used to be called asm!)
-    if p.look_ahead(1, |t| *t == token::Colon || *t == token::ModSep) {
+    if !is_global_asm && p.look_ahead(1, |t| *t == token::Colon || *t == token::ModSep) {
         let mut err =
             ecx.struct_span_err(sp, "the legacy LLVM-style asm! syntax is no longer supported");
         err.note("consider migrating to the new asm! syntax specified in RFC 2873");
@@ -84,7 +87,7 @@ fn parse_args<'a>(
 
         // Parse options
         if p.eat_keyword(sym::options) {
-            parse_options(&mut p, &mut args)?;
+            parse_options(&mut p, &mut args, is_global_asm)?;
             allow_templates = false;
             continue;
         }
@@ -103,19 +106,19 @@ fn parse_args<'a>(
         };
 
         let mut explicit_reg = false;
-        let op = if p.eat_keyword(kw::In) {
+        let op = if !is_global_asm && p.eat_keyword(kw::In) {
             let reg = parse_reg(&mut p, &mut explicit_reg)?;
             let expr = p.parse_expr()?;
             ast::InlineAsmOperand::In { reg, expr }
-        } else if p.eat_keyword(sym::out) {
+        } else if !is_global_asm && p.eat_keyword(sym::out) {
             let reg = parse_reg(&mut p, &mut explicit_reg)?;
             let expr = if p.eat_keyword(kw::Underscore) { None } else { Some(p.parse_expr()?) };
             ast::InlineAsmOperand::Out { reg, expr, late: false }
-        } else if p.eat_keyword(sym::lateout) {
+        } else if !is_global_asm && p.eat_keyword(sym::lateout) {
             let reg = parse_reg(&mut p, &mut explicit_reg)?;
             let expr = if p.eat_keyword(kw::Underscore) { None } else { Some(p.parse_expr()?) };
             ast::InlineAsmOperand::Out { reg, expr, late: true }
-        } else if p.eat_keyword(sym::inout) {
+        } else if !is_global_asm && p.eat_keyword(sym::inout) {
             let reg = parse_reg(&mut p, &mut explicit_reg)?;
             let expr = p.parse_expr()?;
             if p.eat(&token::FatArrow) {
@@ -125,7 +128,7 @@ fn parse_args<'a>(
             } else {
                 ast::InlineAsmOperand::InOut { reg, expr, late: false }
             }
-        } else if p.eat_keyword(sym::inlateout) {
+        } else if !is_global_asm && p.eat_keyword(sym::inlateout) {
             let reg = parse_reg(&mut p, &mut explicit_reg)?;
             let expr = p.parse_expr()?;
             if p.eat(&token::FatArrow) {
@@ -138,7 +141,7 @@ fn parse_args<'a>(
         } else if p.eat_keyword(kw::Const) {
             let anon_const = p.parse_anon_const_expr()?;
             ast::InlineAsmOperand::Const { anon_const }
-        } else if p.eat_keyword(sym::sym) {
+        } else if !is_global_asm && p.eat_keyword(sym::sym) {
             let expr = p.parse_expr()?;
             match expr.kind {
                 ast::ExprKind::Path(..) => {}
@@ -329,23 +332,27 @@ fn try_set_option<'a>(
     }
 }
 
-fn parse_options<'a>(p: &mut Parser<'a>, args: &mut AsmArgs) -> Result<(), DiagnosticBuilder<'a>> {
+fn parse_options<'a>(
+    p: &mut Parser<'a>,
+    args: &mut AsmArgs,
+    is_global_asm: bool,
+) -> Result<(), DiagnosticBuilder<'a>> {
     let span_start = p.prev_token.span;
 
     p.expect(&token::OpenDelim(token::DelimToken::Paren))?;
 
     while !p.eat(&token::CloseDelim(token::DelimToken::Paren)) {
-        if p.eat_keyword(sym::pure) {
+        if !is_global_asm && p.eat_keyword(sym::pure) {
             try_set_option(p, args, sym::pure, ast::InlineAsmOptions::PURE);
-        } else if p.eat_keyword(sym::nomem) {
+        } else if !is_global_asm && p.eat_keyword(sym::nomem) {
             try_set_option(p, args, sym::nomem, ast::InlineAsmOptions::NOMEM);
-        } else if p.eat_keyword(sym::readonly) {
+        } else if !is_global_asm && p.eat_keyword(sym::readonly) {
             try_set_option(p, args, sym::readonly, ast::InlineAsmOptions::READONLY);
-        } else if p.eat_keyword(sym::preserves_flags) {
+        } else if !is_global_asm && p.eat_keyword(sym::preserves_flags) {
             try_set_option(p, args, sym::preserves_flags, ast::InlineAsmOptions::PRESERVES_FLAGS);
-        } else if p.eat_keyword(sym::noreturn) {
+        } else if !is_global_asm && p.eat_keyword(sym::noreturn) {
             try_set_option(p, args, sym::noreturn, ast::InlineAsmOptions::NORETURN);
-        } else if p.eat_keyword(sym::nostack) {
+        } else if !is_global_asm && p.eat_keyword(sym::nostack) {
             try_set_option(p, args, sym::nostack, ast::InlineAsmOptions::NOSTACK);
         } else if p.eat_keyword(sym::att_syntax) {
             try_set_option(p, args, sym::att_syntax, ast::InlineAsmOptions::ATT_SYNTAX);
@@ -388,7 +395,7 @@ fn parse_reg<'a>(
     Ok(result)
 }
 
-fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, sp: Span, args: AsmArgs) -> P<ast::Expr> {
+fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, args: AsmArgs) -> Option<ast::InlineAsm> {
     let mut template = vec![];
     // Register operands are implicitly used since they are not allowed to be
     // referenced in the template string.
@@ -415,7 +422,7 @@ fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, sp: Span, args: AsmArgs) -> P<ast
                     if let Some(mut err) = err {
                         err.emit();
                     }
-                    return DummyResult::raw_expr(sp, true);
+                    return None;
                 }
             };
 
@@ -492,7 +499,7 @@ fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, sp: Span, args: AsmArgs) -> P<ast
                 e.span_label(err_sp, label);
             }
             e.emit();
-            return DummyResult::raw_expr(sp, true);
+            return None;
         }
 
         curarg = parser.curarg;
@@ -643,15 +650,7 @@ fn expand_preparsed_asm(ecx: &mut ExtCtxt<'_>, sp: Span, args: AsmArgs) -> P<ast
         }
     }
 
-    let inline_asm =
-        ast::InlineAsm { template, operands: args.operands, options: args.options, line_spans };
-    P(ast::Expr {
-        id: ast::DUMMY_NODE_ID,
-        kind: ast::ExprKind::InlineAsm(P(inline_asm)),
-        span: sp,
-        attrs: ast::AttrVec::new(),
-        tokens: None,
-    })
+    Some(ast::InlineAsm { template, operands: args.operands, options: args.options, line_spans })
 }
 
 pub fn expand_asm<'cx>(
@@ -659,8 +658,53 @@ pub fn expand_asm<'cx>(
     sp: Span,
     tts: TokenStream,
 ) -> Box<dyn base::MacResult + 'cx> {
-    match parse_args(ecx, sp, tts) {
-        Ok(args) => MacEager::expr(expand_preparsed_asm(ecx, sp, args)),
+    match parse_args(ecx, sp, tts, false) {
+        Ok(args) => {
+            let expr = if let Some(inline_asm) = expand_preparsed_asm(ecx, args) {
+                P(ast::Expr {
+                    id: ast::DUMMY_NODE_ID,
+                    kind: ast::ExprKind::InlineAsm(P(inline_asm)),
+                    span: sp,
+                    attrs: ast::AttrVec::new(),
+                    tokens: None,
+                })
+            } else {
+                DummyResult::raw_expr(sp, true)
+            };
+            MacEager::expr(expr)
+        }
+        Err(mut err) => {
+            err.emit();
+            DummyResult::any(sp)
+        }
+    }
+}
+
+pub fn expand_global_asm<'cx>(
+    ecx: &'cx mut ExtCtxt<'_>,
+    sp: Span,
+    tts: TokenStream,
+) -> Box<dyn base::MacResult + 'cx> {
+    match parse_args(ecx, sp, tts, true) {
+        Ok(args) => {
+            if let Some(inline_asm) = expand_preparsed_asm(ecx, args) {
+                MacEager::items(smallvec![P(ast::Item {
+                    ident: Ident::invalid(),
+                    attrs: Vec::new(),
+                    id: ast::DUMMY_NODE_ID,
+                    kind: ast::ItemKind::GlobalAsm(inline_asm),
+                    vis: ast::Visibility {
+                        span: sp.shrink_to_lo(),
+                        kind: ast::VisibilityKind::Inherited,
+                        tokens: None,
+                    },
+                    span: ecx.with_def_site_ctxt(sp),
+                    tokens: None,
+                })])
+            } else {
+                DummyResult::any(sp)
+            }
+        }
         Err(mut err) => {
             err.emit();
             DummyResult::any(sp)
diff --git a/compiler/rustc_builtin_macros/src/global_asm.rs b/compiler/rustc_builtin_macros/src/global_asm.rs
deleted file mode 100644 (file)
index 76d8745..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-//! Module-level assembly support.
-//!
-//! The macro defined here allows you to specify "top-level",
-//! "file-scoped", or "module-level" assembly. These synonyms
-//! all correspond to LLVM's module-level inline assembly instruction.
-//!
-//! For example, `global_asm!("some assembly here")` codegens to
-//! LLVM's `module asm "some assembly here"`. All of LLVM's caveats
-//! therefore apply.
-
-use rustc_ast as ast;
-use rustc_ast::ptr::P;
-use rustc_ast::token;
-use rustc_ast::tokenstream::TokenStream;
-use rustc_errors::DiagnosticBuilder;
-use rustc_expand::base::{self, *};
-use rustc_span::symbol::Ident;
-use rustc_span::Span;
-use smallvec::smallvec;
-
-pub fn expand_global_asm<'cx>(
-    cx: &'cx mut ExtCtxt<'_>,
-    sp: Span,
-    tts: TokenStream,
-) -> Box<dyn base::MacResult + 'cx> {
-    match parse_global_asm(cx, sp, tts) {
-        Ok(Some(global_asm)) => MacEager::items(smallvec![P(ast::Item {
-            ident: Ident::invalid(),
-            attrs: Vec::new(),
-            id: ast::DUMMY_NODE_ID,
-            kind: ast::ItemKind::GlobalAsm(global_asm),
-            vis: ast::Visibility {
-                span: sp.shrink_to_lo(),
-                kind: ast::VisibilityKind::Inherited,
-                tokens: None,
-            },
-            span: cx.with_def_site_ctxt(sp),
-            tokens: None,
-        })]),
-        Ok(None) => DummyResult::any(sp),
-        Err(mut err) => {
-            err.emit();
-            DummyResult::any(sp)
-        }
-    }
-}
-
-fn parse_global_asm<'a>(
-    cx: &mut ExtCtxt<'a>,
-    sp: Span,
-    tts: TokenStream,
-) -> Result<Option<ast::GlobalAsm>, DiagnosticBuilder<'a>> {
-    let mut p = cx.new_parser_from_tts(tts);
-
-    if p.token == token::Eof {
-        let mut err = cx.struct_span_err(sp, "macro requires a string literal as an argument");
-        err.span_label(sp, "string literal required");
-        return Err(err);
-    }
-
-    let expr = p.parse_expr()?;
-    let (asm, _) = match expr_to_string(cx, expr, "inline assembly must be a string literal") {
-        Some((s, st)) => (s, st),
-        None => return Ok(None),
-    };
-
-    Ok(Some(ast::GlobalAsm { asm }))
-}
index d7926ed0e0bce1805d7afaee040aec8fd70f81ed..17b7793c7ddc7b8e8a920a6e1324b58ed7bb5017 100644 (file)
@@ -20,6 +20,7 @@
 
 use rustc_expand::base::{MacroExpanderFn, ResolverExpand, SyntaxExtensionKind};
 use rustc_expand::proc_macro::BangProcMacro;
+use rustc_span::def_id::LOCAL_CRATE;
 use rustc_span::symbol::sym;
 
 mod asm;
@@ -36,7 +37,6 @@
 mod format;
 mod format_foreign;
 mod global_allocator;
-mod global_asm;
 mod llvm_asm;
 mod log_syntax;
 mod panic;
@@ -74,7 +74,7 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
         file: source_util::expand_file,
         format_args_nl: format::expand_format_args_nl,
         format_args: format::expand_format_args,
-        global_asm: global_asm::expand_global_asm,
+        global_asm: asm::expand_global_asm,
         include_bytes: source_util::expand_include_bytes,
         include_str: source_util::expand_include_str,
         include: source_util::expand_include,
@@ -114,5 +114,8 @@ pub fn register_builtin_macros(resolver: &mut dyn ResolverExpand) {
     }
 
     let client = proc_macro::bridge::client::Client::expand1(proc_macro::quote);
-    register(sym::quote, SyntaxExtensionKind::Bang(Box::new(BangProcMacro { client })));
+    register(
+        sym::quote,
+        SyntaxExtensionKind::Bang(Box::new(BangProcMacro { client, krate: LOCAL_CRATE })),
+    );
 }
index 4aafcb2fb6dfea067783c635dacaad92d0d9f67e..ccb9f15b0f50585effc0e1918fd6d718a18abcbc 100644 (file)
@@ -61,7 +61,9 @@ pub fn expand_file(
 
     let topmost = cx.expansion_cause().unwrap_or(sp);
     let loc = cx.source_map().lookup_char_pos(topmost.lo());
-    base::MacEager::expr(cx.expr_str(topmost, Symbol::intern(&loc.file.name.to_string())))
+    base::MacEager::expr(
+        cx.expr_str(topmost, Symbol::intern(&loc.file.name.prefer_remapped().to_string_lossy())),
+    )
 }
 
 pub fn expand_stringify(
index 92e4435565ee7575d0e77e8756f1f8040b7de0ce..c12d6d0f1414306a13c698059eb544493129766a 100644 (file)
@@ -334,7 +334,9 @@ pub(crate) fn get_caller_location(&mut self, span: Span) -> CValue<'tcx> {
         let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span);
         let caller = self.tcx.sess.source_map().lookup_char_pos(topmost.lo());
         let const_loc = self.tcx.const_caller_location((
-            rustc_span::symbol::Symbol::intern(&caller.file.name.to_string()),
+            rustc_span::symbol::Symbol::intern(
+                &caller.file.name.prefer_remapped().to_string_lossy(),
+            ),
             caller.line as u32,
             caller.col_display as u32 + 1,
         ));
index 8578ab33ced680bb50340819c7aa2939ff6b9bef..9eb067706309e12cebc5a06146d24e433da1f6e0 100644 (file)
@@ -66,7 +66,7 @@ fn line_program_add_file(
 ) -> FileId {
     match &file.name {
         FileName::Real(path) => {
-            let (dir_path, file_name) = split_path_dir_and_file(path.stable_name());
+            let (dir_path, file_name) = split_path_dir_and_file(path.remapped_path_if_available());
             let dir_name = osstr_as_utf8_bytes(dir_path.as_os_str());
             let file_name = osstr_as_utf8_bytes(file_name);
 
@@ -87,7 +87,7 @@ fn line_program_add_file(
         filename => {
             let dir_id = line_program.default_directory();
             let dummy_file_name = LineString::new(
-                filename.to_string().into_bytes(),
+                filename.prefer_remapped().to_string().into_bytes(),
                 line_program.encoding(),
                 line_strings,
             );
index dc8bc8d9cb74147814e27809f1e7e20457df6885..61e54a76f29ba514956cb25c6066ef6182190e79 100644 (file)
@@ -64,7 +64,7 @@ pub(crate) fn new(tcx: TyCtxt<'tcx>, isa: &dyn TargetIsa) -> Self {
         // FIXME: how to get version when building out of tree?
         // Normally this would use option_env!("CFG_VERSION").
         let producer = format!("cg_clif (rustc {})", "unknown version");
-        let comp_dir = tcx.sess.working_dir.0.to_string_lossy().into_owned();
+        let comp_dir = tcx.sess.working_dir.to_string_lossy(false).into_owned();
         let (name, file_info) = match tcx.sess.local_crate_source_file.clone() {
             Some(path) => {
                 let name = path.to_string_lossy().into_owned();
index 9c5cd53d8669d3a2c48457de36422c3ecd2d1625..004e6bddaf3ee72c5db5b814df90eb788fe52a04 100644 (file)
@@ -3,6 +3,7 @@
 
 use std::path::PathBuf;
 
+use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
 use rustc_codegen_ssa::back::linker::LinkerInfo;
 use rustc_codegen_ssa::{CodegenResults, CompiledModule, CrateInfo, ModuleKind};
 use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
@@ -125,9 +126,19 @@ fn module_codegen(
             MonoItem::Static(def_id) => crate::constant::codegen_static(tcx, &mut module, def_id),
             MonoItem::GlobalAsm(item_id) => {
                 let item = cx.tcx.hir().item(item_id);
-                if let rustc_hir::ItemKind::GlobalAsm(rustc_hir::GlobalAsm { asm }) = item.kind {
-                    cx.global_asm.push_str(&*asm.as_str());
-                    cx.global_asm.push_str("\n\n");
+                if let rustc_hir::ItemKind::GlobalAsm(asm) = item.kind {
+                    if !asm.options.contains(InlineAsmOptions::ATT_SYNTAX) {
+                        cx.global_asm.push_str("\n.intel_syntax noprefix\n");
+                    } else {
+                        cx.global_asm.push_str("\n.att_syntax\n");
+                    }
+                    for piece in asm.template {
+                        match *piece {
+                            InlineAsmTemplatePiece::String(ref s) => cx.global_asm.push_str(s),
+                            InlineAsmTemplatePiece::Placeholder { .. } => todo!(),
+                        }
+                    }
+                    cx.global_asm.push_str("\n.att_syntax\n\n");
                 } else {
                     bug!("Expected GlobalAsm found {:?}", item);
                 }
@@ -298,7 +309,7 @@ pub(crate) fn run_aot(
             metadata_module,
             metadata,
             windows_subsystem,
-            linker_info: LinkerInfo::new(tcx),
+            linker_info: LinkerInfo::new(tcx, crate::target_triple(tcx.sess).to_string()),
             crate_info: CrateInfo::new(tcx),
         },
         work_products,
index 32f403957025a649b8b87763ce0ae0a4377bd6c3..ff6e1856059af0066f85b7f8023f9ec5e03990c8 100644 (file)
@@ -165,7 +165,7 @@ fn init(&self, sess: &Session) {
     }
 
     fn metadata_loader(&self) -> Box<dyn MetadataLoader + Sync> {
-        Box::new(crate::metadata::CraneliftMetadataLoader)
+        Box::new(rustc_codegen_ssa::back::metadata::DefaultMetadataLoader)
     }
 
     fn provide(&self, _providers: &mut Providers) {}
@@ -218,13 +218,11 @@ fn link(
     ) -> Result<(), ErrorReported> {
         use rustc_codegen_ssa::back::link::link_binary;
 
-        let target_cpu = crate::target_triple(sess).to_string();
         link_binary::<crate::archive::ArArchiveBuilder<'_>>(
             sess,
             &codegen_results,
             outputs,
             &codegen_results.crate_name.as_str(),
-            &target_cpu,
         );
 
         Ok(())
index 882232fde09d2bcd10aeb05f7e23c47f8fa5433d..ab238244d68d504c983bfff1ffea366fd6eb7c5f 100644 (file)
@@ -1,73 +1,9 @@
-//! Reading and writing of the rustc metadata for rlibs and dylibs
+//! Writing of the rustc metadata for dylibs
 
-use std::fs::File;
-use std::path::Path;
-
-use rustc_codegen_ssa::METADATA_FILENAME;
-use rustc_data_structures::memmap::Mmap;
-use rustc_data_structures::owning_ref::OwningRef;
-use rustc_data_structures::rustc_erase_owner;
-use rustc_data_structures::sync::MetadataRef;
-use rustc_middle::middle::cstore::MetadataLoader;
 use rustc_middle::ty::TyCtxt;
-use rustc_target::spec::Target;
 
 use crate::backend::WriteMetadata;
 
-/// The metadata loader used by cg_clif.
-///
-/// The metadata is stored in the same format as cg_llvm.
-///
-/// # Metadata location
-///
-/// <dl>
-/// <dt>rlib</dt>
-/// <dd>The metadata can be found in the `lib.rmeta` file inside of the ar archive.</dd>
-/// <dt>dylib</dt>
-/// <dd>The metadata can be found in the `.rustc` section of the shared library.</dd>
-/// </dl>
-pub(crate) struct CraneliftMetadataLoader;
-
-fn load_metadata_with(
-    path: &Path,
-    f: impl for<'a> FnOnce(&'a [u8]) -> Result<&'a [u8], String>,
-) -> Result<MetadataRef, String> {
-    let file = File::open(path).map_err(|e| format!("{:?}", e))?;
-    let data = unsafe { Mmap::map(file) }.map_err(|e| format!("{:?}", e))?;
-    let metadata = OwningRef::new(data).try_map(f)?;
-    return Ok(rustc_erase_owner!(metadata.map_owner_box()));
-}
-
-impl MetadataLoader for CraneliftMetadataLoader {
-    fn get_rlib_metadata(&self, _target: &Target, path: &Path) -> Result<MetadataRef, String> {
-        load_metadata_with(path, |data| {
-            let archive = object::read::archive::ArchiveFile::parse(&*data)
-                .map_err(|e| format!("{:?}", e))?;
-
-            for entry_result in archive.members() {
-                let entry = entry_result.map_err(|e| format!("{:?}", e))?;
-                if entry.name() == METADATA_FILENAME.as_bytes() {
-                    return Ok(entry.data());
-                }
-            }
-
-            Err("couldn't find metadata entry".to_string())
-        })
-    }
-
-    fn get_dylib_metadata(&self, _target: &Target, path: &Path) -> Result<MetadataRef, String> {
-        use object::{Object, ObjectSection};
-
-        load_metadata_with(path, |data| {
-            let file = object::File::parse(&data).map_err(|e| format!("parse: {:?}", e))?;
-            file.section_by_name(".rustc")
-                .ok_or("no .rustc section")?
-                .data()
-                .map_err(|e| format!("failed to read .rustc section: {:?}", e))
-        })
-    }
-}
-
 // Adapted from https://github.com/rust-lang/rust/blob/da573206f87b5510de4b0ee1a9c044127e409bd3/src/librustc_codegen_llvm/base.rs#L47-L112
 pub(crate) fn write_metadata<O: WriteMetadata>(tcx: TyCtxt<'_>, object: &mut O) {
     use snap::write::FrameEncoder;
index 84b091d8d4d79ec4d15710ad20356a9bd21f658b..a571418c1f5ffcfe36e2bfb0b1f2f44cbe922d2f 100644 (file)
@@ -283,6 +283,7 @@ fn codegen_inline_asm(
                 }
                 InlineAsmArch::RiscV32 | InlineAsmArch::RiscV64 => {}
                 InlineAsmArch::Nvptx64 => {}
+                InlineAsmArch::PowerPC => {}
                 InlineAsmArch::Hexagon => {}
                 InlineAsmArch::Mips | InlineAsmArch::Mips64 => {}
                 InlineAsmArch::SpirV => {}
@@ -355,10 +356,49 @@ fn codegen_inline_asm(
 }
 
 impl AsmMethods for CodegenCx<'ll, 'tcx> {
-    fn codegen_global_asm(&self, ga: &hir::GlobalAsm) {
-        let asm = ga.asm.as_str();
+    fn codegen_global_asm(
+        &self,
+        template: &[InlineAsmTemplatePiece],
+        operands: &[GlobalAsmOperandRef],
+        options: InlineAsmOptions,
+        _line_spans: &[Span],
+    ) {
+        let asm_arch = self.tcx.sess.asm_arch.unwrap();
+
+        // Default to Intel syntax on x86
+        let intel_syntax = matches!(asm_arch, InlineAsmArch::X86 | InlineAsmArch::X86_64)
+            && !options.contains(InlineAsmOptions::ATT_SYNTAX);
+
+        // Build the template string
+        let mut template_str = String::new();
+        if intel_syntax {
+            template_str.push_str(".intel_syntax\n");
+        }
+        for piece in template {
+            match *piece {
+                InlineAsmTemplatePiece::String(ref s) => template_str.push_str(s),
+                InlineAsmTemplatePiece::Placeholder { operand_idx, modifier: _, span: _ } => {
+                    match operands[operand_idx] {
+                        GlobalAsmOperandRef::Const { ref string } => {
+                            // Const operands get injected directly into the
+                            // template. Note that we don't need to escape $
+                            // here unlike normal inline assembly.
+                            template_str.push_str(string);
+                        }
+                    }
+                }
+            }
+        }
+        if intel_syntax {
+            template_str.push_str("\n.att_syntax\n");
+        }
+
         unsafe {
-            llvm::LLVMRustAppendModuleInlineAsm(self.llmod, asm.as_ptr().cast(), asm.len());
+            llvm::LLVMRustAppendModuleInlineAsm(
+                self.llmod,
+                template_str.as_ptr().cast(),
+                template_str.len(),
+            );
         }
     }
 }
@@ -540,6 +580,9 @@ fn reg_to_llvm(reg: InlineAsmRegOrRegClass, layout: Option<&TyAndLayout<'tcx>>)
             InlineAsmRegClass::Nvptx(NvptxInlineAsmRegClass::reg16) => "h",
             InlineAsmRegClass::Nvptx(NvptxInlineAsmRegClass::reg32) => "r",
             InlineAsmRegClass::Nvptx(NvptxInlineAsmRegClass::reg64) => "l",
+            InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::reg) => "r",
+            InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::reg_nonzero) => "b",
+            InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::freg) => "f",
             InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::reg) => "r",
             InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::freg) => "f",
             InlineAsmRegClass::X86(X86InlineAsmRegClass::reg) => "r",
@@ -590,6 +633,7 @@ fn modifier_to_llvm(
         InlineAsmRegClass::Hexagon(_) => None,
         InlineAsmRegClass::Mips(_) => None,
         InlineAsmRegClass::Nvptx(_) => None,
+        InlineAsmRegClass::PowerPC(_) => None,
         InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::reg)
         | InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::freg) => None,
         InlineAsmRegClass::X86(X86InlineAsmRegClass::reg)
@@ -651,6 +695,9 @@ fn dummy_output_type(cx: &CodegenCx<'ll, 'tcx>, reg: InlineAsmRegClass) -> &'ll
         InlineAsmRegClass::Nvptx(NvptxInlineAsmRegClass::reg16) => cx.type_i16(),
         InlineAsmRegClass::Nvptx(NvptxInlineAsmRegClass::reg32) => cx.type_i32(),
         InlineAsmRegClass::Nvptx(NvptxInlineAsmRegClass::reg64) => cx.type_i64(),
+        InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::reg) => cx.type_i32(),
+        InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::reg_nonzero) => cx.type_i32(),
+        InlineAsmRegClass::PowerPC(PowerPCInlineAsmRegClass::freg) => cx.type_f64(),
         InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::reg) => cx.type_i32(),
         InlineAsmRegClass::RiscV(RiscVInlineAsmRegClass::freg) => cx.type_f32(),
         InlineAsmRegClass::X86(X86InlineAsmRegClass::reg)
index 9e5e2b1039efecd301ac7413a413a36bdfa9022f..6a032b9be723bc379ad9515a4a17e19f55b15050 100644 (file)
@@ -4,12 +4,10 @@
 
 use cstr::cstr;
 use rustc_codegen_ssa::traits::*;
-use rustc_data_structures::fx::FxHashMap;
 use rustc_data_structures::small_c_str::SmallCStr;
 use rustc_hir::def_id::DefId;
 use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
 use rustc_middle::ty::layout::HasTyCtxt;
-use rustc_middle::ty::query::Providers;
 use rustc_middle::ty::{self, TyCtxt};
 use rustc_session::config::OptLevel;
 use rustc_session::Session;
@@ -355,35 +353,6 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty::
     }
 }
 
-pub fn provide_both(providers: &mut Providers) {
-    providers.wasm_import_module_map = |tcx, cnum| {
-        // Build up a map from DefId to a `NativeLib` structure, where
-        // `NativeLib` internally contains information about
-        // `#[link(wasm_import_module = "...")]` for example.
-        let native_libs = tcx.native_libraries(cnum);
-
-        let def_id_to_native_lib = native_libs
-            .iter()
-            .filter_map(|lib| lib.foreign_module.map(|id| (id, lib)))
-            .collect::<FxHashMap<_, _>>();
-
-        let mut ret = FxHashMap::default();
-        for (def_id, lib) in tcx.foreign_modules(cnum).iter() {
-            let module = def_id_to_native_lib.get(&def_id).and_then(|s| s.wasm_import_module);
-            let module = match module {
-                Some(s) => s,
-                None => continue,
-            };
-            ret.extend(lib.foreign_items.iter().map(|id| {
-                assert_eq!(id.krate, cnum);
-                (*id, module.to_string())
-            }));
-        }
-
-        ret
-    };
-}
-
 fn wasm_import_module(tcx: TyCtxt<'_>, id: DefId) -> Option<CString> {
     tcx.wasm_import_module_map(id.krate).get(&id).map(|s| CString::new(&s[..]).unwrap())
 }
index 6f6c649bb0b18a1cbf7b6d4e4f3effba8ecc9825..893c909b204166eb09dd226a830bb0197ae2fdbe 100644 (file)
@@ -18,7 +18,6 @@
 use crate::common;
 use crate::context::CodegenCx;
 use crate::llvm;
-use crate::metadata;
 use crate::value::Value;
 
 use rustc_codegen_ssa::base::maybe_create_entry_wrapper;
@@ -47,6 +46,22 @@ pub fn write_compressed_metadata<'tcx>(
     use snap::write::FrameEncoder;
     use std::io::Write;
 
+    // Historical note:
+    //
+    // When using link.exe it was seen that the section name `.note.rustc`
+    // was getting shortened to `.note.ru`, and according to the PE and COFF
+    // specification:
+    //
+    // > Executable images do not use a string table and do not support
+    // > section names longer than 8 characters
+    //
+    // https://docs.microsoft.com/en-us/windows/win32/debug/pe-format
+    //
+    // As a result, we choose a slightly shorter name! As to why
+    // `.note.rustc` works on MinGW, see
+    // https://github.com/llvm/llvm-project/blob/llvmorg-12.0.0/lld/COFF/Writer.cpp#L1190-L1197
+    let section_name = if tcx.sess.target.is_like_osx { "__DATA,.rustc" } else { ".rustc" };
+
     let (metadata_llcx, metadata_llmod) = (&*llvm_module.llcx, llvm_module.llmod());
     let mut compressed = tcx.metadata_encoding_version();
     FrameEncoder::new(&mut compressed).write_all(&metadata.raw_data).unwrap();
@@ -59,7 +74,6 @@ pub fn write_compressed_metadata<'tcx>(
         unsafe { llvm::LLVMAddGlobal(metadata_llmod, common::val_ty(llconst), buf.as_ptr()) };
     unsafe {
         llvm::LLVMSetInitializer(llglobal, llconst);
-        let section_name = metadata::metadata_section_name(&tcx.sess.target);
         let name = SmallCStr::new(section_name);
         llvm::LLVMSetSection(llglobal, name.as_ptr());
 
index 280d9a4d3702179a4cef60afa2c4781602293d9a..5cf831475d4645c77be7b90f3f73c4596ea54523 100644 (file)
@@ -760,12 +760,12 @@ fn hex_encode(data: &[u8]) -> String {
 }
 
 pub fn file_metadata(cx: &CodegenCx<'ll, '_>, source_file: &SourceFile) -> &'ll DIFile {
-    debug!("file_metadata: file_name: {}", source_file.name);
+    debug!("file_metadata: file_name: {:?}", source_file.name);
 
     let hash = Some(&source_file.src_hash);
-    let file_name = Some(source_file.name.to_string());
+    let file_name = Some(source_file.name.prefer_remapped().to_string());
     let directory = if source_file.is_real_file() && !source_file.is_imported() {
-        Some(cx.sess().working_dir.0.to_string_lossy().to_string())
+        Some(cx.sess().working_dir.to_string_lossy(false).to_string())
     } else {
         // If the path comes from an upstream crate we assume it has been made
         // independent of the compiler's working directory one way or another.
@@ -993,7 +993,7 @@ pub fn compile_unit_metadata(
     let producer = format!("clang LLVM ({})", rustc_producer);
 
     let name_in_debuginfo = name_in_debuginfo.to_string_lossy();
-    let work_dir = tcx.sess.working_dir.0.to_string_lossy();
+    let work_dir = tcx.sess.working_dir.to_string_lossy(false);
     let flags = "\0";
     let out_dir = &tcx.output_filenames(LOCAL_CRATE).out_directory;
     let split_name = if tcx.sess.target_can_use_split_dwarf() {
index bc35aa72965681b9a7bab3532cdd50813049bb67..329458773ffaff3fbf0afca8815d19a348a9fef8 100644 (file)
@@ -69,7 +69,6 @@ pub mod llvm {
 }
 
 mod llvm_util;
-mod metadata;
 mod mono_item;
 mod type_;
 mod type_of;
@@ -251,16 +250,11 @@ fn target_features(&self, sess: &Session) -> Vec<Symbol> {
     }
 
     fn metadata_loader(&self) -> Box<MetadataLoaderDyn> {
-        Box::new(metadata::LlvmMetadataLoader)
+        Box::new(rustc_codegen_ssa::back::metadata::DefaultMetadataLoader)
     }
 
-    fn provide(&self, providers: &mut ty::query::Providers) {
-        attributes::provide_both(providers);
-    }
-
-    fn provide_extern(&self, providers: &mut ty::query::Providers) {
-        attributes::provide_both(providers);
-    }
+    fn provide(&self, _providers: &mut ty::query::Providers) {}
+    fn provide_extern(&self, _providers: &mut ty::query::Providers) {}
 
     fn codegen_crate<'tcx>(
         &self,
@@ -271,6 +265,7 @@ fn codegen_crate<'tcx>(
         Box::new(rustc_codegen_ssa::base::codegen_crate(
             LlvmCodegenBackend(()),
             tcx,
+            crate::llvm_util::target_cpu(tcx.sess).to_string(),
             metadata,
             need_metadata_module,
         ))
@@ -306,13 +301,11 @@ fn link(
 
         // Run the linker on any artifacts that resulted from the LLVM run.
         // This should produce either a finished executable or library.
-        let target_cpu = crate::llvm_util::target_cpu(sess);
         link_binary::<LlvmArchiveBuilder<'_>>(
             sess,
             &codegen_results,
             outputs,
             &codegen_results.crate_name.as_str(),
-            target_cpu,
         );
 
         Ok(())
diff --git a/compiler/rustc_codegen_llvm/src/metadata.rs b/compiler/rustc_codegen_llvm/src/metadata.rs
deleted file mode 100644 (file)
index decc1e1..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-use crate::llvm;
-use crate::llvm::archive_ro::ArchiveRO;
-use crate::llvm::{mk_section_iter, False, ObjectFile};
-use rustc_middle::middle::cstore::MetadataLoader;
-use rustc_target::spec::Target;
-
-use rustc_codegen_ssa::METADATA_FILENAME;
-use rustc_data_structures::owning_ref::OwningRef;
-use rustc_data_structures::rustc_erase_owner;
-use tracing::debug;
-
-use rustc_fs_util::path_to_c_string;
-use std::path::Path;
-use std::slice;
-
-pub use rustc_data_structures::sync::MetadataRef;
-
-pub struct LlvmMetadataLoader;
-
-impl MetadataLoader for LlvmMetadataLoader {
-    fn get_rlib_metadata(&self, _: &Target, filename: &Path) -> Result<MetadataRef, String> {
-        // Use ArchiveRO for speed here, it's backed by LLVM and uses mmap
-        // internally to read the file. We also avoid even using a memcpy by
-        // just keeping the archive along while the metadata is in use.
-        let archive =
-            ArchiveRO::open(filename).map(|ar| OwningRef::new(Box::new(ar))).map_err(|e| {
-                debug!("llvm didn't like `{}`: {}", filename.display(), e);
-                format!("failed to read rlib metadata in '{}': {}", filename.display(), e)
-            })?;
-        let buf: OwningRef<_, [u8]> = archive.try_map(|ar| {
-            ar.iter()
-                .filter_map(|s| s.ok())
-                .find(|sect| sect.name() == Some(METADATA_FILENAME))
-                .map(|s| s.data())
-                .ok_or_else(|| {
-                    debug!("didn't find '{}' in the archive", METADATA_FILENAME);
-                    format!("failed to read rlib metadata: '{}'", filename.display())
-                })
-        })?;
-        Ok(rustc_erase_owner!(buf))
-    }
-
-    fn get_dylib_metadata(&self, target: &Target, filename: &Path) -> Result<MetadataRef, String> {
-        unsafe {
-            let buf = path_to_c_string(filename);
-            let mb = llvm::LLVMRustCreateMemoryBufferWithContentsOfFile(buf.as_ptr())
-                .ok_or_else(|| format!("error reading library: '{}'", filename.display()))?;
-            let of =
-                ObjectFile::new(mb).map(|of| OwningRef::new(Box::new(of))).ok_or_else(|| {
-                    format!("provided path not an object file: '{}'", filename.display())
-                })?;
-            let buf = of.try_map(|of| search_meta_section(of, target, filename))?;
-            Ok(rustc_erase_owner!(buf))
-        }
-    }
-}
-
-fn search_meta_section<'a>(
-    of: &'a ObjectFile,
-    target: &Target,
-    filename: &Path,
-) -> Result<&'a [u8], String> {
-    unsafe {
-        let si = mk_section_iter(of.llof);
-        while llvm::LLVMIsSectionIteratorAtEnd(of.llof, si.llsi) == False {
-            let mut name_buf = None;
-            let name_len = llvm::LLVMRustGetSectionName(si.llsi, &mut name_buf);
-            let name = name_buf.map_or_else(
-                String::new, // We got a null ptr, ignore `name_len`.
-                |buf| {
-                    String::from_utf8(
-                        slice::from_raw_parts(buf.as_ptr() as *const u8, name_len as usize)
-                            .to_vec(),
-                    )
-                    .unwrap()
-                },
-            );
-            debug!("get_metadata_section: name {}", name);
-            if read_metadata_section_name(target) == name {
-                let cbuf = llvm::LLVMGetSectionContents(si.llsi);
-                let csz = llvm::LLVMGetSectionSize(si.llsi) as usize;
-                // The buffer is valid while the object file is around
-                let buf: &'a [u8] = slice::from_raw_parts(cbuf as *const u8, csz);
-                return Ok(buf);
-            }
-            llvm::LLVMMoveToNextSection(si.llsi);
-        }
-    }
-    Err(format!("metadata not found: '{}'", filename.display()))
-}
-
-pub fn metadata_section_name(target: &Target) -> &'static str {
-    // Historical note:
-    //
-    // When using link.exe it was seen that the section name `.note.rustc`
-    // was getting shortened to `.note.ru`, and according to the PE and COFF
-    // specification:
-    //
-    // > Executable images do not use a string table and do not support
-    // > section names longer than 8 characters
-    //
-    // https://docs.microsoft.com/en-us/windows/win32/debug/pe-format
-    //
-    // As a result, we choose a slightly shorter name! As to why
-    // `.note.rustc` works on MinGW, that's another good question...
-
-    if target.is_like_osx { "__DATA,.rustc" } else { ".rustc" }
-}
-
-fn read_metadata_section_name(_target: &Target) -> &'static str {
-    ".rustc"
-}
index 7a3d715df6dcd55df6b9eeaab051e58e44945d5a..68f40d5f8639593c86dd35f092ad3c1895f80463 100644 (file)
@@ -9,7 +9,7 @@ test = false
 
 [dependencies]
 bitflags = "1.2.1"
-cc = "1.0.1"
+cc = "1.0.67"
 itertools = "0.9"
 tracing = "0.1"
 libc = "0.2.50"
@@ -33,3 +33,8 @@ rustc_index = { path = "../rustc_index" }
 rustc_macros = { path = "../rustc_macros" }
 rustc_target = { path = "../rustc_target" }
 rustc_session = { path = "../rustc_session" }
+
+[dependencies.object]
+version = "0.22.0"
+default-features = false
+features = ["read_core", "elf", "macho", "pe", "unaligned", "archive"]
index 30a56badeb52e2fdb1e5d9bc742d77c7c09bcf0b..e330b5e703b1f449465c45b508d33b1abbca8fa6 100644 (file)
@@ -50,7 +50,6 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(
     codegen_results: &CodegenResults,
     outputs: &OutputFilenames,
     crate_name: &str,
-    target_cpu: &str,
 ) {
     let _timer = sess.timer("link_binary");
     let output_metadata = sess.opts.output_types.contains_key(&OutputType::Metadata);
@@ -100,7 +99,6 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(
                         &out_filename,
                         codegen_results,
                         path.as_ref(),
-                        target_cpu,
                     );
                 }
             }
@@ -532,7 +530,6 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
     out_filename: &Path,
     codegen_results: &CodegenResults,
     tmpdir: &Path,
-    target_cpu: &str,
 ) {
     info!("preparing {:?} to {:?}", crate_type, out_filename);
     let (linker_path, flavor) = linker_and_flavor(sess);
@@ -544,7 +541,6 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
         tmpdir,
         out_filename,
         codegen_results,
-        target_cpu,
     );
 
     linker::disable_localization(&mut cmd);
@@ -1609,14 +1605,13 @@ fn linker_with_args<'a, B: ArchiveBuilder<'a>>(
     tmpdir: &Path,
     out_filename: &Path,
     codegen_results: &CodegenResults,
-    target_cpu: &str,
 ) -> Command {
     let crt_objects_fallback = crt_objects_fallback(sess, crate_type);
     let base_cmd = get_linker(sess, path, flavor, crt_objects_fallback);
     // FIXME: Move `/LIBPATH` addition for uwp targets from the linker construction
     // to the linker args construction.
     assert!(base_cmd.get_args().is_empty() || sess.target.vendor == "uwp");
-    let cmd = &mut *codegen_results.linker_info.to_linker(base_cmd, &sess, flavor, target_cpu);
+    let cmd = &mut *codegen_results.linker_info.to_linker(base_cmd, &sess, flavor);
     let link_output_kind = link_output_kind(sess, crate_type);
 
     // NO-OPT-OUT, OBJECT-FILES-MAYBE, CUSTOMIZATION-POINT
index cb3c98354c8750242c5c91f4a631118651ca59f1..93059b2323da8af64097880eca3fab56fbb5fee8 100644 (file)
@@ -37,12 +37,14 @@ pub fn disable_localization(linker: &mut Command) {
 /// need out of the shared crate context before we get rid of it.
 #[derive(Encodable, Decodable)]
 pub struct LinkerInfo {
+    target_cpu: String,
     exports: FxHashMap<CrateType, Vec<String>>,
 }
 
 impl LinkerInfo {
-    pub fn new(tcx: TyCtxt<'_>) -> LinkerInfo {
+    pub fn new(tcx: TyCtxt<'_>, target_cpu: String) -> LinkerInfo {
         LinkerInfo {
+            target_cpu,
             exports: tcx
                 .sess
                 .crate_types()
@@ -57,38 +59,31 @@ pub fn to_linker<'a>(
         cmd: Command,
         sess: &'a Session,
         flavor: LinkerFlavor,
-        target_cpu: &'a str,
     ) -> Box<dyn Linker + 'a> {
         match flavor {
             LinkerFlavor::Lld(LldFlavor::Link) | LinkerFlavor::Msvc => {
                 Box::new(MsvcLinker { cmd, sess, info: self }) as Box<dyn Linker>
             }
             LinkerFlavor::Em => Box::new(EmLinker { cmd, sess, info: self }) as Box<dyn Linker>,
-            LinkerFlavor::Gcc => Box::new(GccLinker {
-                cmd,
-                sess,
-                info: self,
-                hinted_static: false,
-                is_ld: false,
-                target_cpu,
-            }) as Box<dyn Linker>,
+            LinkerFlavor::Gcc => {
+                Box::new(GccLinker { cmd, sess, info: self, hinted_static: false, is_ld: false })
+                    as Box<dyn Linker>
+            }
 
             LinkerFlavor::Lld(LldFlavor::Ld)
             | LinkerFlavor::Lld(LldFlavor::Ld64)
-            | LinkerFlavor::Ld => Box::new(GccLinker {
-                cmd,
-                sess,
-                info: self,
-                hinted_static: false,
-                is_ld: true,
-                target_cpu,
-            }) as Box<dyn Linker>,
+            | LinkerFlavor::Ld => {
+                Box::new(GccLinker { cmd, sess, info: self, hinted_static: false, is_ld: true })
+                    as Box<dyn Linker>
+            }
 
             LinkerFlavor::Lld(LldFlavor::Wasm) => {
                 Box::new(WasmLd::new(cmd, sess, self)) as Box<dyn Linker>
             }
 
-            LinkerFlavor::PtxLinker => Box::new(PtxLinker { cmd, sess }) as Box<dyn Linker>,
+            LinkerFlavor::PtxLinker => {
+                Box::new(PtxLinker { cmd, sess, info: self }) as Box<dyn Linker>
+            }
         }
     }
 }
@@ -157,7 +152,6 @@ pub struct GccLinker<'a> {
     hinted_static: bool, // Keeps track of the current hinting mode.
     // Link as ld
     is_ld: bool,
-    target_cpu: &'a str,
 }
 
 impl<'a> GccLinker<'a> {
@@ -229,8 +223,7 @@ fn push_linker_plugin_lto_args(&mut self, plugin_path: Option<&OsStr>) {
         };
 
         self.linker_arg(&format!("-plugin-opt={}", opt_level));
-        let target_cpu = self.target_cpu;
-        self.linker_arg(&format!("-plugin-opt=mcpu={}", target_cpu));
+        self.linker_arg(&format!("-plugin-opt=mcpu={}", self.info.target_cpu));
     }
 
     fn build_dylib(&mut self, out_filename: &Path) {
@@ -1336,6 +1329,7 @@ fn exported_symbols(tcx: TyCtxt<'_>, crate_type: CrateType) -> Vec<String> {
 pub struct PtxLinker<'a> {
     cmd: Command,
     sess: &'a Session,
+    info: &'a LinkerInfo,
 }
 
 impl<'a> Linker for PtxLinker<'a> {
@@ -1381,10 +1375,7 @@ fn output_filename(&mut self, path: &Path) {
 
     fn finalize(&mut self) {
         // Provide the linker with fallback to internal `target-cpu`.
-        self.cmd.arg("--fallback-arch").arg(match self.sess.opts.cg.target_cpu {
-            Some(ref s) => s,
-            None => &self.sess.target.cpu,
-        });
+        self.cmd.arg("--fallback-arch").arg(&self.info.target_cpu);
     }
 
     fn link_dylib(&mut self, _lib: Symbol, _verbatim: bool, _as_needed: bool) {
diff --git a/compiler/rustc_codegen_ssa/src/back/metadata.rs b/compiler/rustc_codegen_ssa/src/back/metadata.rs
new file mode 100644 (file)
index 0000000..37d1f8e
--- /dev/null
@@ -0,0 +1,71 @@
+//! Reading of the rustc metadata for rlibs and dylibs
+
+use std::fs::File;
+use std::path::Path;
+
+use rustc_data_structures::memmap::Mmap;
+use rustc_data_structures::owning_ref::OwningRef;
+use rustc_data_structures::rustc_erase_owner;
+use rustc_data_structures::sync::MetadataRef;
+use rustc_middle::middle::cstore::MetadataLoader;
+use rustc_target::spec::Target;
+
+use crate::METADATA_FILENAME;
+
+/// The default metadata loader. This is used by cg_llvm and cg_clif.
+///
+/// # Metadata location
+///
+/// <dl>
+/// <dt>rlib</dt>
+/// <dd>The metadata can be found in the `lib.rmeta` file inside of the ar archive.</dd>
+/// <dt>dylib</dt>
+/// <dd>The metadata can be found in the `.rustc` section of the shared library.</dd>
+/// </dl>
+pub struct DefaultMetadataLoader;
+
+fn load_metadata_with(
+    path: &Path,
+    f: impl for<'a> FnOnce(&'a [u8]) -> Result<&'a [u8], String>,
+) -> Result<MetadataRef, String> {
+    let file =
+        File::open(path).map_err(|e| format!("failed to open file '{}': {}", path.display(), e))?;
+    let data = unsafe { Mmap::map(file) }
+        .map_err(|e| format!("failed to mmap file '{}': {}", path.display(), e))?;
+    let metadata = OwningRef::new(data).try_map(f)?;
+    return Ok(rustc_erase_owner!(metadata.map_owner_box()));
+}
+
+impl MetadataLoader for DefaultMetadataLoader {
+    fn get_rlib_metadata(&self, _target: &Target, path: &Path) -> Result<MetadataRef, String> {
+        load_metadata_with(path, |data| {
+            let archive = object::read::archive::ArchiveFile::parse(&*data)
+                .map_err(|e| format!("failed to parse rlib '{}': {}", path.display(), e))?;
+
+            for entry_result in archive.members() {
+                let entry = entry_result
+                    .map_err(|e| format!("failed to parse rlib '{}': {}", path.display(), e))?;
+                if entry.name() == METADATA_FILENAME.as_bytes() {
+                    return Ok(entry.data());
+                }
+            }
+
+            Err(format!("metadata not found in rlib '{}'", path.display()))
+        })
+    }
+
+    fn get_dylib_metadata(&self, _target: &Target, path: &Path) -> Result<MetadataRef, String> {
+        use object::{Object, ObjectSection};
+
+        load_metadata_with(path, |data| {
+            let file = object::File::parse(&data)
+                .map_err(|e| format!("failed to parse dylib '{}': {}", path.display(), e))?;
+            file.section_by_name(".rustc")
+                .ok_or_else(|| format!("no .rustc section in '{}'", path.display()))?
+                .data()
+                .map_err(|e| {
+                    format!("failed to read .rustc section in '{}': {}", path.display(), e)
+                })
+        })
+    }
+}
index 20ca503d43f45b9dcdc05a2edbe7a11c2bf6d6a3..d11ed54eb209f969ffe88f1709379ab7b6fac785 100644 (file)
@@ -3,6 +3,7 @@
 pub mod link;
 pub mod linker;
 pub mod lto;
+pub mod metadata;
 pub mod rpath;
 pub mod symbol_export;
 pub mod write;
index b8f277c8ff5e3e2de517daa74ddccc3b05ebfcfe..2bff2fcba43836cc329dd60b7e8b5b9771fc7adc 100644 (file)
@@ -370,11 +370,13 @@ pub fn provide(providers: &mut Providers) {
     providers.upstream_monomorphizations = upstream_monomorphizations_provider;
     providers.is_unreachable_local_definition = is_unreachable_local_definition_provider;
     providers.upstream_drop_glue_for = upstream_drop_glue_for_provider;
+    providers.wasm_import_module_map = wasm_import_module_map;
 }
 
 pub fn provide_extern(providers: &mut Providers) {
     providers.is_reachable_non_generic = is_reachable_non_generic_provider_extern;
     providers.upstream_monomorphizations_for = upstream_monomorphizations_for_provider;
+    providers.wasm_import_module_map = wasm_import_module_map;
 }
 
 fn symbol_export_level(tcx: TyCtxt<'_>, sym_def_id: DefId) -> SymbolExportLevel {
@@ -442,3 +444,30 @@ pub fn symbol_name_for_instance_in_crate<'tcx>(
         ExportedSymbol::NoDefId(symbol_name) => symbol_name.to_string(),
     }
 }
+
+fn wasm_import_module_map(tcx: TyCtxt<'_>, cnum: CrateNum) -> FxHashMap<DefId, String> {
+    // Build up a map from DefId to a `NativeLib` structure, where
+    // `NativeLib` internally contains information about
+    // `#[link(wasm_import_module = "...")]` for example.
+    let native_libs = tcx.native_libraries(cnum);
+
+    let def_id_to_native_lib = native_libs
+        .iter()
+        .filter_map(|lib| lib.foreign_module.map(|id| (id, lib)))
+        .collect::<FxHashMap<_, _>>();
+
+    let mut ret = FxHashMap::default();
+    for (def_id, lib) in tcx.foreign_modules(cnum).iter() {
+        let module = def_id_to_native_lib.get(&def_id).and_then(|s| s.wasm_import_module);
+        let module = match module {
+            Some(s) => s,
+            None => continue,
+        };
+        ret.extend(lib.foreign_items.iter().map(|id| {
+            assert_eq!(id.krate, cnum);
+            (*id, module.to_string())
+        }));
+    }
+
+    ret
+}
index 0dfb007a2473e31a6fc135add423bcc8475f9282..fb0662a3993fe796d75db9bde2790459dbe0acfe 100644 (file)
@@ -419,6 +419,7 @@ fn need_pre_lto_bitcode_for_incr_comp(sess: &Session) -> bool {
 pub fn start_async_codegen<B: ExtraBackendMethods>(
     backend: B,
     tcx: TyCtxt<'_>,
+    target_cpu: String,
     metadata: EncodedMetadata,
     total_cgus: usize,
 ) -> OngoingCodegen<B> {
@@ -441,7 +442,7 @@ pub fn start_async_codegen<B: ExtraBackendMethods>(
         subsystem.to_string()
     });
 
-    let linker_info = LinkerInfo::new(tcx);
+    let linker_info = LinkerInfo::new(tcx, target_cpu);
     let crate_info = CrateInfo::new(tcx);
 
     let regular_config =
index 7a19b0e4d5ac3565205aaa74147e05f6f75cb010..a9ab075d3db538fdbdcd6f12b19629a01820baea 100644 (file)
@@ -467,12 +467,13 @@ fn get_argc_argv<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
 pub fn codegen_crate<B: ExtraBackendMethods>(
     backend: B,
     tcx: TyCtxt<'tcx>,
+    target_cpu: String,
     metadata: EncodedMetadata,
     need_metadata_module: bool,
 ) -> OngoingCodegen<B> {
     // Skip crate items and just output metadata in -Z no-codegen mode.
     if tcx.sess.opts.debugging_opts.no_codegen || !tcx.sess.opts.output_types.should_codegen() {
-        let ongoing_codegen = start_async_codegen(backend, tcx, metadata, 1);
+        let ongoing_codegen = start_async_codegen(backend, tcx, target_cpu, metadata, 1);
 
         ongoing_codegen.codegen_finished(tcx);
 
@@ -498,7 +499,8 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
         }
     }
 
-    let ongoing_codegen = start_async_codegen(backend.clone(), tcx, metadata, codegen_units.len());
+    let ongoing_codegen =
+        start_async_codegen(backend.clone(), tcx, target_cpu, metadata, codegen_units.len());
     let ongoing_codegen = AbortCodegenOnDrop::<B>(Some(ongoing_codegen));
 
     // Codegen an allocator shim, if necessary.
index afd83bfcb56922a4d8d791ac4530956c7c5d5a1f..955f658eb1c7ecdb9c9062b94b5fedbb09368a8c 100644 (file)
@@ -4,7 +4,8 @@
 use rustc_hir as hir;
 use rustc_hir::def_id::DefId;
 use rustc_hir::LangItem;
-use rustc_middle::ty::{Ty, TyCtxt};
+use rustc_middle::mir::interpret::ConstValue;
+use rustc_middle::ty::{self, layout::TyAndLayout, Ty, TyCtxt};
 use rustc_session::Session;
 use rustc_span::Span;
 
@@ -194,3 +195,32 @@ pub fn shift_mask_val<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
 pub fn span_invalid_monomorphization_error(a: &Session, b: Span, c: &str) {
     struct_span_err!(a, b, E0511, "{}", c).emit();
 }
+
+pub fn asm_const_to_str<'tcx>(
+    tcx: TyCtxt<'tcx>,
+    sp: Span,
+    const_value: ConstValue<'tcx>,
+    ty_and_layout: TyAndLayout<'tcx>,
+) -> String {
+    let scalar = match const_value {
+        ConstValue::Scalar(s) => s,
+        _ => {
+            span_bug!(sp, "expected Scalar for promoted asm const, but got {:#?}", const_value)
+        }
+    };
+    let value = scalar.assert_bits(ty_and_layout.size);
+    match ty_and_layout.ty.kind() {
+        ty::Uint(_) => value.to_string(),
+        ty::Int(int_ty) => match int_ty.normalize(tcx.sess.target.pointer_width) {
+            ty::IntTy::I8 => (value as i8).to_string(),
+            ty::IntTy::I16 => (value as i16).to_string(),
+            ty::IntTy::I32 => (value as i32).to_string(),
+            ty::IntTy::I64 => (value as i64).to_string(),
+            ty::IntTy::I128 => (value as i128).to_string(),
+            ty::IntTy::Isize => unreachable!(),
+        },
+        ty::Float(ty::FloatTy::F32) => f32::from_bits(value as u32).to_string(),
+        ty::Float(ty::FloatTy::F64) => f64::from_bits(value as u64).to_string(),
+        _ => span_bug!(sp, "asm const has bad type {}", ty_and_layout.ty),
+    }
+}
index 4458fd686788f3857315da62dc20e015dda11d67..08442c588f87902ba3dede3d04cd3f7cf87f8090 100644 (file)
@@ -49,9 +49,9 @@ pub fn unused(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> Self {
     }
 
     fn create(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>, is_used: bool) -> Self {
-        let coverageinfo = tcx.coverageinfo(instance.def_id());
+        let coverageinfo = tcx.coverageinfo(instance.def);
         debug!(
-            "FunctionCoverage::new(instance={:?}) has coverageinfo={:?}. is_used={}",
+            "FunctionCoverage::create(instance={:?}) has coverageinfo={:?}. is_used={}",
             instance, coverageinfo, is_used
         );
         Self {
index fd3f89a2aee965e551be4c11286f9c894ea3d40b..2bd35fe9b1435ed3747f504ad70f6fe5f5792d72 100644 (file)
@@ -12,7 +12,6 @@
 use rustc_ast as ast;
 use rustc_hir::lang_items::LangItem;
 use rustc_index::vec::Idx;
-use rustc_middle::mir::interpret::ConstValue;
 use rustc_middle::mir::AssertKind;
 use rustc_middle::mir::{self, SwitchTargets};
 use rustc_middle::ty::layout::{FnAbiExt, HasTyCtxt};
@@ -825,33 +824,12 @@ fn codegen_asm_terminator(
                     let const_value = self
                         .eval_mir_constant(value)
                         .unwrap_or_else(|_| span_bug!(span, "asm const cannot be resolved"));
-                    let ty = value.ty();
-                    let size = bx.layout_of(ty).size;
-                    let scalar = match const_value {
-                        ConstValue::Scalar(s) => s,
-                        _ => span_bug!(
-                            span,
-                            "expected Scalar for promoted asm const, but got {:#?}",
-                            const_value
-                        ),
-                    };
-                    let value = scalar.assert_bits(size);
-                    let string = match ty.kind() {
-                        ty::Uint(_) => value.to_string(),
-                        ty::Int(int_ty) => {
-                            match int_ty.normalize(bx.tcx().sess.target.pointer_width) {
-                                ty::IntTy::I8 => (value as i8).to_string(),
-                                ty::IntTy::I16 => (value as i16).to_string(),
-                                ty::IntTy::I32 => (value as i32).to_string(),
-                                ty::IntTy::I64 => (value as i64).to_string(),
-                                ty::IntTy::I128 => (value as i128).to_string(),
-                                ty::IntTy::Isize => unreachable!(),
-                            }
-                        }
-                        ty::Float(ty::FloatTy::F32) => f32::from_bits(value as u32).to_string(),
-                        ty::Float(ty::FloatTy::F64) => f64::from_bits(value as u64).to_string(),
-                        _ => span_bug!(span, "asm const has bad type {}", ty),
-                    };
+                    let string = common::asm_const_to_str(
+                        bx.tcx(),
+                        span,
+                        const_value,
+                        bx.layout_of(value.ty()),
+                    );
                     InlineAsmOperandRef::Const { string }
                 }
                 mir::InlineAsmOperand::SymFn { ref value } => {
@@ -1144,7 +1122,7 @@ fn get_caller_location(
             let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span);
             let caller = tcx.sess.source_map().lookup_char_pos(topmost.lo());
             let const_loc = tcx.const_caller_location((
-                Symbol::intern(&caller.file.name.to_string()),
+                Symbol::intern(&caller.file.name.prefer_remapped().to_string_lossy()),
                 caller.line as u32,
                 caller.col_display as u32 + 1,
             ));
index 621ec0519c956fd5af19f145524b5c0527b99cda..a283bf1de763a9da378109d255792eeef0d2f8ff 100644 (file)
@@ -31,7 +31,7 @@ pub fn codegen_coverage(&self, bx: &mut Bx, coverage: Coverage, scope: SourceSco
                         bx.add_coverage_counter(instance, id, code_region);
                     }
 
-                    let coverageinfo = bx.tcx().coverageinfo(instance.def_id());
+                    let coverageinfo = bx.tcx().coverageinfo(instance.def);
 
                     let fn_name = bx.get_pgo_func_name_var(instance);
                     let hash = bx.const_u64(function_source_hash);
index 9917c23f121501f6294debbc4f4c52fb391e2cb5..530de3de9e870e9604afe0526ea6e4f59dc0a346 100644 (file)
@@ -14,7 +14,6 @@
 use rustc_middle::ty::layout::HasTyCtxt;
 use rustc_middle::ty::{self, adjustment::PointerCast, Instance, Ty, TyCtxt};
 use rustc_span::source_map::{Span, DUMMY_SP};
-use rustc_span::symbol::sym;
 use rustc_target::abi::{Abi, Int, LayoutOf, Variants};
 
 impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
@@ -187,9 +186,6 @@ pub fn codegen_rvalue_operand(
                     mir::CastKind::Pointer(PointerCast::ReifyFnPointer) => {
                         match *operand.layout.ty.kind() {
                             ty::FnDef(def_id, substs) => {
-                                if bx.cx().tcx().has_attr(def_id, sym::rustc_args_required_const) {
-                                    bug!("reifying a fn ptr that requires const arguments");
-                                }
                                 let instance = ty::Instance::resolve_for_fn_ptr(
                                     bx.tcx(),
                                     ty::ParamEnv::reveal_all(),
index 8e79193759eb45bda1d576b43303d046d4b4eb8e..48d753e0d843564f7d110c16d0ecad2f14206974 100644 (file)
@@ -1,10 +1,11 @@
 use crate::base;
+use crate::common;
 use crate::traits::*;
 use rustc_hir as hir;
+use rustc_middle::mir::mono::MonoItem;
 use rustc_middle::mir::mono::{Linkage, Visibility};
 use rustc_middle::ty::layout::HasTyCtxt;
-
-use rustc_middle::mir::mono::MonoItem;
+use rustc_target::abi::LayoutOf;
 
 pub trait MonoItemExt<'a, 'tcx> {
     fn define<Bx: BuilderMethods<'a, 'tcx>>(&self, cx: &'a Bx::CodegenCx);
@@ -32,8 +33,35 @@ fn define<Bx: BuilderMethods<'a, 'tcx>>(&self, cx: &'a Bx::CodegenCx) {
             }
             MonoItem::GlobalAsm(item_id) => {
                 let item = cx.tcx().hir().item(item_id);
-                if let hir::ItemKind::GlobalAsm(ref ga) = item.kind {
-                    cx.codegen_global_asm(ga);
+                if let hir::ItemKind::GlobalAsm(ref asm) = item.kind {
+                    let operands: Vec<_> = asm
+                        .operands
+                        .iter()
+                        .map(|(op, op_sp)| match *op {
+                            hir::InlineAsmOperand::Const { ref anon_const } => {
+                                let anon_const_def_id =
+                                    cx.tcx().hir().local_def_id(anon_const.hir_id).to_def_id();
+                                let const_value =
+                                    cx.tcx().const_eval_poly(anon_const_def_id).unwrap_or_else(
+                                        |_| span_bug!(*op_sp, "asm const cannot be resolved"),
+                                    );
+                                let ty = cx
+                                    .tcx()
+                                    .typeck_body(anon_const.body)
+                                    .node_type(anon_const.hir_id);
+                                let string = common::asm_const_to_str(
+                                    cx.tcx(),
+                                    *op_sp,
+                                    const_value,
+                                    cx.layout_of(ty),
+                                );
+                                GlobalAsmOperandRef::Const { string }
+                            }
+                            _ => span_bug!(*op_sp, "invalid operand type for global_asm!"),
+                        })
+                        .collect();
+
+                    cx.codegen_global_asm(asm.template, &operands, asm.options, asm.line_spans);
                 } else {
                     span_bug!(item.span, "Mismatch between hir::Item type and MonoItem type")
                 }
index 69931935c496383087f24f7dfa17c2080622bbb0..86f2781a7663b6a605c06764e75a4c0e26aa055b 100644 (file)
@@ -3,7 +3,7 @@
 use crate::mir::place::PlaceRef;
 use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
 use rustc_hir::def_id::DefId;
-use rustc_hir::{GlobalAsm, LlvmInlineAsmInner};
+use rustc_hir::LlvmInlineAsmInner;
 use rustc_middle::ty::Instance;
 use rustc_span::Span;
 use rustc_target::asm::InlineAsmRegOrRegClass;
@@ -36,6 +36,11 @@ pub enum InlineAsmOperandRef<'tcx, B: BackendTypes + ?Sized> {
     },
 }
 
+#[derive(Debug)]
+pub enum GlobalAsmOperandRef {
+    Const { string: String },
+}
+
 pub trait AsmBuilderMethods<'tcx>: BackendTypes {
     /// Take an inline assembly expression and splat it out via LLVM
     fn codegen_llvm_inline_asm(
@@ -57,5 +62,11 @@ fn codegen_inline_asm(
 }
 
 pub trait AsmMethods {
-    fn codegen_global_asm(&self, ga: &GlobalAsm);
+    fn codegen_global_asm(
+        &self,
+        template: &[InlineAsmTemplatePiece],
+        operands: &[GlobalAsmOperandRef],
+        options: InlineAsmOptions,
+        line_spans: &[Span],
+    );
 }
index be2e0ea230f303c2e04dd6fcae519e53a2423f3f..c529fbbf518b667a9ed02953f9bf67cfcff6b61b 100644 (file)
@@ -29,7 +29,7 @@
 mod write;
 
 pub use self::abi::AbiBuilderMethods;
-pub use self::asm::{AsmBuilderMethods, AsmMethods, InlineAsmOperandRef};
+pub use self::asm::{AsmBuilderMethods, AsmMethods, GlobalAsmOperandRef, InlineAsmOperandRef};
 pub use self::backend::{Backend, BackendTypes, CodegenBackend, ExtraBackendMethods};
 pub use self::builder::{BuilderMethods, OverflowOp};
 pub use self::consts::ConstMethods;
index 51699403a3705dd0d77321da2d1c309bcad6192b..181146342097555300e212e0dc9e4a8f498239f1 100644 (file)
@@ -35,7 +35,7 @@
 use rustc_session::getopts;
 use rustc_session::lint::{Lint, LintId};
 use rustc_session::{config, DiagnosticOutput, Session};
-use rustc_session::{early_error, early_warn};
+use rustc_session::{early_error, early_error_no_abort, early_warn};
 use rustc_span::source_map::{FileLoader, FileName};
 use rustc_span::symbol::sym;
 
@@ -133,6 +133,7 @@ pub fn diagnostics_registry() -> Registry {
     Registry::new(&rustc_error_codes::DIAGNOSTICS)
 }
 
+/// This is the primary entry point for rustc.
 pub struct RunCompiler<'a, 'b> {
     at_args: &'a [String],
     callbacks: &'b mut (dyn Callbacks + Send),
@@ -146,6 +147,9 @@ impl<'a, 'b> RunCompiler<'a, 'b> {
     pub fn new(at_args: &'a [String], callbacks: &'b mut (dyn Callbacks + Send)) -> Self {
         Self { at_args, callbacks, file_loader: None, emitter: None, make_codegen_backend: None }
     }
+
+    /// Set a custom codegen backend.
+    ///
     /// Used by cg_clif.
     pub fn set_make_codegen_backend(
         &mut self,
@@ -156,11 +160,17 @@ pub fn set_make_codegen_backend(
         self.make_codegen_backend = make_codegen_backend;
         self
     }
+
+    /// Emit diagnostics to the specified location.
+    ///
     /// Used by RLS.
     pub fn set_emitter(&mut self, emitter: Option<Box<dyn Write + Send>>) -> &mut Self {
         self.emitter = emitter;
         self
     }
+
+    /// Load files from sources other than the file system.
+    ///
     /// Used by RLS.
     pub fn set_file_loader(
         &mut self,
@@ -169,6 +179,8 @@ pub fn set_file_loader(
         self.file_loader = file_loader;
         self
     }
+
+    /// Parse args and run the compiler.
     pub fn run(self) -> interface::Result<()> {
         run_compiler(
             self.at_args,
@@ -179,8 +191,6 @@ pub fn run(self) -> interface::Result<()> {
         )
     }
 }
-// Parse args and run the compiler. This is the primary entry point for rustc.
-// The FileLoader provides a way to load files from sources other than the file system.
 fn run_compiler(
     at_args: &[String],
     callbacks: &mut (dyn Callbacks + Send),
@@ -199,46 +209,43 @@ fn run_compiler(
     };
 
     let sopts = config::build_session_options(&matches);
-    let cfg = interface::parse_cfgspecs(matches.opt_strs("cfg"));
-
-    // We wrap `make_codegen_backend` in another `Option` such that `dummy_config` can take
-    // ownership of it when necessary, while also allowing the non-dummy config to take ownership
-    // when `dummy_config` is not used.
-    let mut make_codegen_backend = Some(make_codegen_backend);
-
-    let mut dummy_config = |sopts, cfg, diagnostic_output| {
-        let mut config = interface::Config {
-            opts: sopts,
-            crate_cfg: cfg,
-            input: Input::File(PathBuf::new()),
-            input_path: None,
-            output_file: None,
-            output_dir: None,
-            file_loader: None,
-            diagnostic_output,
-            stderr: None,
-            lint_caps: Default::default(),
-            parse_sess_created: None,
-            register_lints: None,
-            override_queries: None,
-            make_codegen_backend: make_codegen_backend.take().unwrap(),
-            registry: diagnostics_registry(),
-        };
-        callbacks.config(&mut config);
-        config
-    };
 
     if let Some(ref code) = matches.opt_str("explain") {
         handle_explain(diagnostics_registry(), code, sopts.error_format);
         return Ok(());
     }
 
+    let cfg = interface::parse_cfgspecs(matches.opt_strs("cfg"));
     let (odir, ofile) = make_output(&matches);
-    let (input, input_file_path, input_err) = match make_input(&matches.free) {
-        Some(v) => v,
-        None => match matches.free.len() {
+    let mut config = interface::Config {
+        opts: sopts,
+        crate_cfg: cfg,
+        input: Input::File(PathBuf::new()),
+        input_path: None,
+        output_file: ofile,
+        output_dir: odir,
+        file_loader,
+        diagnostic_output,
+        stderr: None,
+        lint_caps: Default::default(),
+        parse_sess_created: None,
+        register_lints: None,
+        override_queries: None,
+        make_codegen_backend,
+        registry: diagnostics_registry(),
+    };
+
+    match make_input(config.opts.error_format, &matches.free) {
+        Err(ErrorReported) => return Err(ErrorReported),
+        Ok(Some((input, input_file_path))) => {
+            config.input = input;
+            config.input_path = input_file_path;
+
+            callbacks.config(&mut config);
+        }
+        Ok(None) => match matches.free.len() {
             0 => {
-                let config = dummy_config(sopts, cfg, diagnostic_output);
+                callbacks.config(&mut config);
                 interface::run_compiler(config, |compiler| {
                     let sopts = &compiler.session().opts;
                     if sopts.describe_lints {
@@ -260,8 +267,8 @@ fn run_compiler(
                         &***compiler.codegen_backend(),
                         compiler.session(),
                         None,
-                        &odir,
-                        &ofile,
+                        &compiler.output_dir(),
+                        &compiler.output_file(),
                     );
 
                     if should_stop == Compilation::Stop {
@@ -273,7 +280,7 @@ fn run_compiler(
             }
             1 => panic!("make_input should have provided valid inputs"),
             _ => early_error(
-                sopts.error_format,
+                config.opts.error_format,
                 &format!(
                     "multiple input filenames provided (first two filenames are `{}` and `{}`)",
                     matches.free[0], matches.free[1],
@@ -282,35 +289,6 @@ fn run_compiler(
         },
     };
 
-    if let Some(err) = input_err {
-        // Immediately stop compilation if there was an issue reading
-        // the input (for example if the input stream is not UTF-8).
-        interface::run_compiler(dummy_config(sopts, cfg, diagnostic_output), |compiler| {
-            compiler.session().err(&err.to_string());
-        });
-        return Err(ErrorReported);
-    }
-
-    let mut config = interface::Config {
-        opts: sopts,
-        crate_cfg: cfg,
-        input,
-        input_path: input_file_path,
-        output_file: ofile,
-        output_dir: odir,
-        file_loader,
-        diagnostic_output,
-        stderr: None,
-        lint_caps: Default::default(),
-        parse_sess_created: None,
-        register_lints: None,
-        override_queries: None,
-        make_codegen_backend: make_codegen_backend.unwrap(),
-        registry: diagnostics_registry(),
-    };
-
-    callbacks.config(&mut config);
-
     interface::run_compiler(config, |compiler| {
         let sess = compiler.session();
         let should_stop = RustcDefaultCalls::print_crate_info(
@@ -324,7 +302,6 @@ fn run_compiler(
             RustcDefaultCalls::list_metadata(
                 sess,
                 &*compiler.codegen_backend().metadata_loader(),
-                &matches,
                 compiler.input(),
             )
         })
@@ -411,11 +388,10 @@ fn run_compiler(
                 return early_exit();
             }
 
-            if sess.opts.debugging_opts.save_analysis {
-                let crate_name = queries.crate_name()?.peek().clone();
-                queries.global_ctxt()?.peek_mut().enter(|tcx| {
-                    let result = tcx.analysis(LOCAL_CRATE);
-
+            queries.global_ctxt()?.peek_mut().enter(|tcx| {
+                let result = tcx.analysis(LOCAL_CRATE);
+                if sess.opts.debugging_opts.save_analysis {
+                    let crate_name = queries.crate_name()?.peek().clone();
                     sess.time("save_analysis", || {
                         save::process_crate(
                             tcx,
@@ -428,12 +404,9 @@ fn run_compiler(
                             ),
                         )
                     });
-
-                    result
-                })?;
-            }
-
-            queries.global_ctxt()?.peek_mut().enter(|tcx| tcx.analysis(LOCAL_CRATE))?;
+                }
+                result
+            })?;
 
             if callbacks.after_analysis(compiler, queries) == Compilation::Stop {
                 return early_exit();
@@ -490,19 +463,23 @@ fn make_output(matches: &getopts::Matches) -> (Option<PathBuf>, Option<PathBuf>)
 }
 
 // Extract input (string or file and optional path) from matches.
-fn make_input(free_matches: &[String]) -> Option<(Input, Option<PathBuf>, Option<io::Error>)> {
+fn make_input(
+    error_format: ErrorOutputType,
+    free_matches: &[String],
+) -> Result<Option<(Input, Option<PathBuf>)>, ErrorReported> {
     if free_matches.len() == 1 {
         let ifile = &free_matches[0];
         if ifile == "-" {
             let mut src = String::new();
-            let err = if io::stdin().read_to_string(&mut src).is_err() {
-                Some(io::Error::new(
-                    io::ErrorKind::InvalidData,
+            if io::stdin().read_to_string(&mut src).is_err() {
+                // Immediately stop compilation if there was an issue reading
+                // the input (for example if the input stream is not UTF-8).
+                early_error_no_abort(
+                    error_format,
                     "couldn't read from stdin, as it did not contain valid UTF-8",
-                ))
-            } else {
-                None
-            };
+                );
+                return Err(ErrorReported);
+            }
             if let Ok(path) = env::var("UNSTABLE_RUSTDOC_TEST_PATH") {
                 let line = env::var("UNSTABLE_RUSTDOC_TEST_LINE").expect(
                     "when UNSTABLE_RUSTDOC_TEST_PATH is set \
@@ -511,14 +488,15 @@ fn make_input(free_matches: &[String]) -> Option<(Input, Option<PathBuf>, Option
                 let line = isize::from_str_radix(&line, 10)
                     .expect("UNSTABLE_RUSTDOC_TEST_LINE needs to be an number");
                 let file_name = FileName::doc_test_source_code(PathBuf::from(path), line);
-                return Some((Input::Str { name: file_name, input: src }, None, err));
+                Ok(Some((Input::Str { name: file_name, input: src }, None)))
+            } else {
+                Ok(Some((Input::Str { name: FileName::anon_source_code(&src), input: src }, None)))
             }
-            Some((Input::Str { name: FileName::anon_source_code(&src), input: src }, None, err))
         } else {
-            Some((Input::File(PathBuf::from(ifile)), Some(PathBuf::from(ifile)), None))
+            Ok(Some((Input::File(PathBuf::from(ifile)), Some(PathBuf::from(ifile)))))
         }
     } else {
-        None
+        Ok(None)
     }
 }
 
@@ -619,28 +597,24 @@ fn show_content_with_pager(content: &str) {
 }
 
 impl RustcDefaultCalls {
-    fn process_rlink(sess: &Session, compiler: &interface::Compiler) -> Result<(), ErrorReported> {
-        if let Input::File(file) = compiler.input() {
-            // FIXME: #![crate_type] and #![crate_name] support not implemented yet
-            let attrs = vec![];
-            sess.init_crate_types(collect_crate_types(sess, &attrs));
-            let outputs = compiler.build_output_filenames(&sess, &attrs);
-            let rlink_data = fs::read_to_string(file).unwrap_or_else(|err| {
-                sess.fatal(&format!("failed to read rlink file: {}", err));
-            });
-            let codegen_results: CodegenResults = json::decode(&rlink_data).unwrap_or_else(|err| {
-                sess.fatal(&format!("failed to decode rlink: {}", err));
-            });
-            compiler.codegen_backend().link(&sess, codegen_results, &outputs)
-        } else {
-            sess.fatal("rlink must be a file")
-        }
-    }
-
     pub fn try_process_rlink(sess: &Session, compiler: &interface::Compiler) -> Compilation {
         if sess.opts.debugging_opts.link_only {
-            let result = RustcDefaultCalls::process_rlink(sess, compiler);
-            abort_on_err(result, sess);
+            if let Input::File(file) = compiler.input() {
+                // FIXME: #![crate_type] and #![crate_name] support not implemented yet
+                sess.init_crate_types(collect_crate_types(sess, &[]));
+                let outputs = compiler.build_output_filenames(&sess, &[]);
+                let rlink_data = fs::read_to_string(file).unwrap_or_else(|err| {
+                    sess.fatal(&format!("failed to read rlink file: {}", err));
+                });
+                let codegen_results: CodegenResults =
+                    json::decode(&rlink_data).unwrap_or_else(|err| {
+                        sess.fatal(&format!("failed to decode rlink: {}", err));
+                    });
+                let result = compiler.codegen_backend().link(&sess, codegen_results, &outputs);
+                abort_on_err(result, sess);
+            } else {
+                sess.fatal("rlink must be a file")
+            }
             Compilation::Stop
         } else {
             Compilation::Continue
@@ -650,11 +624,9 @@ pub fn try_process_rlink(sess: &Session, compiler: &interface::Compiler) -> Comp
     pub fn list_metadata(
         sess: &Session,
         metadata_loader: &dyn MetadataLoader,
-        matches: &getopts::Matches,
         input: &Input,
     ) -> Compilation {
-        let r = matches.opt_strs("Z");
-        if r.iter().any(|s| *s == "ls") {
+        if sess.opts.debugging_opts.ls {
             match *input {
                 Input::File(ref ifile) => {
                     let path = &(*ifile);
index 9f6db6ed7a225bc0a1295e667c5b2fd3fcc127dd..5f05b59d5a6d4fd3389bf2e9b3ce91b198384c28 100644 (file)
@@ -29,16 +29,16 @@ trait Foo {
     fn bar(&self);
 }
 
-fn some_func<T: Foo>(foo: T) {
-    foo.bar(); // we can now use this method since i32 implements the
-               // Foo trait
-}
-
 // we implement the trait on the i32 type
 impl Foo for i32 {
     fn bar(&self) {}
 }
 
+fn some_func<T: Foo>(foo: T) {
+    foo.bar(); // we can now use this method since i32 implements the
+               // Foo trait
+}
+
 fn main() {
     some_func(5i32); // ok!
 }
index 6f365c07f6d30a51196eda7165afc34ea5a9ea25..577baec21f064f232d96a83914619cdac7ce4004 100644 (file)
@@ -126,7 +126,8 @@ fn emit_messages_default(
             }
             // owned: line source, line index, annotations
             type Owned = (String, usize, Vec<crate::snippet::Annotation>);
-            let origin = primary_lo.file.name.to_string();
+            let filename = primary_lo.file.name.prefer_local();
+            let origin = filename.to_string_lossy();
             let annotated_files: Vec<Owned> = annotated_files
                 .into_iter()
                 .flat_map(|annotated_file| {
index a58caf2667b063422046e32ebdf2ed020ce5f1eb..d3f92bf3047b06a5db22f290b400c1753103e59b 100644 (file)
@@ -309,7 +309,9 @@ fn fix_multispans_in_extern_macros_and_render_macro_backtrace(
                     // are some which do actually involve macros.
                     ExpnKind::Inlined | ExpnKind::Desugaring(..) | ExpnKind::AstPass(..) => None,
 
-                    ExpnKind::Macro(macro_kind, _) => Some(macro_kind),
+                    ExpnKind::Macro { kind: macro_kind, name, proc_macro: _ } => {
+                        Some((macro_kind, name))
+                    }
                 }
             });
 
@@ -320,13 +322,12 @@ fn fix_multispans_in_extern_macros_and_render_macro_backtrace(
         self.render_multispans_macro_backtrace(span, children, backtrace);
 
         if !backtrace {
-            if let Some(macro_kind) = has_macro_spans {
+            if let Some((macro_kind, name)) = has_macro_spans {
+                let descr = macro_kind.descr();
+
                 let msg = format!(
-                    "this {} originates in {} {} \
+                    "this {level} originates in the {descr} `{name}` \
                     (in Nightly builds, run with -Z macro-backtrace for more info)",
-                    level,
-                    macro_kind.article(),
-                    macro_kind.descr(),
                 );
 
                 children.push(SubDiagnostic {
@@ -371,10 +372,19 @@ fn render_multispan_macro_backtrace(&self, span: &mut MultiSpan, always_backtrac
                     new_labels
                         .push((trace.call_site, "in the inlined copy of this code".to_string()));
                 } else if always_backtrace {
+                    let proc_macro = if let ExpnKind::Macro { kind: _, name: _, proc_macro: true } =
+                        trace.kind
+                    {
+                        "procedural macro "
+                    } else {
+                        ""
+                    };
+
                     new_labels.push((
                         trace.def_site,
                         format!(
-                            "in this expansion of `{}`{}",
+                            "in this expansion of {}`{}`{}",
+                            proc_macro,
                             trace.kind.descr(),
                             if macro_backtrace.len() > 1 {
                                 // if macro_backtrace.len() == 1 it'll be
@@ -400,7 +410,11 @@ fn render_multispan_macro_backtrace(&self, span: &mut MultiSpan, always_backtrac
                 // and it needs an "in this macro invocation" label to match that.
                 let redundant_span = trace.call_site.contains(sp);
 
-                if !redundant_span && matches!(trace.kind, ExpnKind::Macro(MacroKind::Bang, _))
+                if !redundant_span
+                    && matches!(
+                        trace.kind,
+                        ExpnKind::Macro { kind: MacroKind::Bang, name: _, proc_macro: _ }
+                    )
                     || always_backtrace
                 {
                     new_labels.push((
@@ -1309,7 +1323,7 @@ fn emit_message_default(
                         buffer_msg_line_offset,
                         &format!(
                             "{}:{}:{}",
-                            loc.file.name,
+                            loc.file.name.prefer_local(),
                             sm.doctest_offset_line(&loc.file.name, loc.line),
                             loc.col.0 + 1,
                         ),
@@ -1323,7 +1337,7 @@ fn emit_message_default(
                         0,
                         &format!(
                             "{}:{}:{}: ",
-                            loc.file.name,
+                            loc.file.name.prefer_local(),
                             sm.doctest_offset_line(&loc.file.name, loc.line),
                             loc.col.0 + 1,
                         ),
@@ -1347,12 +1361,12 @@ fn emit_message_default(
                     };
                     format!(
                         "{}:{}{}",
-                        annotated_file.file.name,
+                        annotated_file.file.name.prefer_local(),
                         sm.doctest_offset_line(&annotated_file.file.name, first_line.line_index),
                         col
                     )
                 } else {
-                    annotated_file.file.name.to_string()
+                    format!("{}", annotated_file.file.name.prefer_local())
                 };
                 buffer.append(buffer_msg_line_offset + 1, &loc, Style::LineAndColumn);
                 for _ in 0..max_line_num_len {
index 40277006462d2b55cebe960d4ee8a6451311b6a6..5d175a3ade9a2438671595d829616d563c3d4499 100644 (file)
@@ -468,7 +468,7 @@ fn from_span_full(
         });
 
         DiagnosticSpan {
-            file_name: start.file.name.to_string(),
+            file_name: start.file.name.prefer_local().to_string(),
             byte_start: start.file.original_relative_byte_pos(span.lo()).0,
             byte_end: start.file.original_relative_byte_pos(span.hi()).0,
             line_start: start.line,
index dc1664bb2baa866f5ff53d8a2c0b8b7075bf56be..f53ce7ceace134a239c6bd3ef5c48210b714ea85 100644 (file)
@@ -6,6 +6,7 @@
 #![feature(crate_visibility_modifier)]
 #![feature(backtrace)]
 #![feature(extended_key_value_attributes)]
+#![feature(format_args_capture)]
 #![feature(iter_zip)]
 #![feature(nll)]
 
index 595058428164995a6975dcfde5431fbec3a7d17d..e1c218c640851fb2442b7bc6bb876a8ba0fa1450 100644 (file)
@@ -14,7 +14,7 @@
 use rustc_lint_defs::BuiltinLintDiagnostics;
 use rustc_parse::{self, nt_to_tokenstream, parser, MACRO_ARGUMENTS};
 use rustc_session::{parse::ParseSess, Limit, Session};
-use rustc_span::def_id::DefId;
+use rustc_span::def_id::{CrateNum, DefId};
 use rustc_span::edition::Edition;
 use rustc_span::hygiene::{AstPass, ExpnData, ExpnId, ExpnKind};
 use rustc_span::source_map::SourceMap;
@@ -810,8 +810,16 @@ pub fn expn_data(
         descr: Symbol,
         macro_def_id: Option<DefId>,
     ) -> ExpnData {
+        use SyntaxExtensionKind::*;
+        let proc_macro = match self.kind {
+            // User-defined proc macro
+            Bang(..) | Attr(..) | Derive(..) => true,
+            // Consider everthing else to be not a proc
+            // macro for diagnostic purposes
+            LegacyBang(..) | LegacyAttr(..) | NonMacroAttr { .. } | LegacyDerive(..) => false,
+        };
         ExpnData::new(
-            ExpnKind::Macro(self.macro_kind(), descr),
+            ExpnKind::Macro { kind: self.macro_kind(), name: descr, proc_macro },
             parent,
             call_site,
             self.span,
@@ -873,6 +881,10 @@ fn resolve_derives(
     fn take_derive_resolutions(&mut self, expn_id: ExpnId) -> Option<DeriveResolutions>;
     /// Path resolution logic for `#[cfg_accessible(path)]`.
     fn cfg_accessible(&mut self, expn_id: ExpnId, path: &ast::Path) -> Result<bool, Indeterminate>;
+
+    /// Decodes the proc-macro quoted span in the specified crate, with the specified id.
+    /// No caching is performed.
+    fn get_proc_macro_quoted_span(&self, krate: CrateNum, id: usize) -> Span;
 }
 
 #[derive(Clone, Default)]
@@ -1072,13 +1084,18 @@ pub fn resolve_path(
         // after macro expansion (that is, they are unhygienic).
         if !path.is_absolute() {
             let callsite = span.source_callsite();
-            let mut result = match self.source_map().span_to_unmapped_path(callsite) {
-                FileName::Real(name) => name.into_local_path(),
+            let mut result = match self.source_map().span_to_filename(callsite) {
+                FileName::Real(name) => name
+                    .into_local_path()
+                    .expect("attempting to resolve a file path in an external file"),
                 FileName::DocTest(path, _) => path,
                 other => {
                     return Err(self.struct_span_err(
                         span,
-                        &format!("cannot resolve relative path in non-file source `{}`", other),
+                        &format!(
+                            "cannot resolve relative path in non-file source `{}`",
+                            other.prefer_local()
+                        ),
                     ));
                 }
             };
index 3347c93948ccc0347f97def7e133e77dd1d91d53..f5c6bb3db654202ee1f7db9856107f58ba85fc17 100644 (file)
@@ -361,9 +361,11 @@ pub fn new(cx: &'a mut ExtCtxt<'b>, monotonic: bool) -> Self {
     // FIXME: Avoid visiting the crate as a `Mod` item,
     // make crate a first class expansion target instead.
     pub fn expand_crate(&mut self, mut krate: ast::Crate) -> ast::Crate {
-        let file_path = match self.cx.source_map().span_to_unmapped_path(krate.span) {
-            FileName::Real(name) => name.into_local_path(),
-            other => PathBuf::from(other.to_string()),
+        let file_path = match self.cx.source_map().span_to_filename(krate.span) {
+            FileName::Real(name) => name
+                .into_local_path()
+                .expect("attempting to resolve a file path in an external file"),
+            other => PathBuf::from(other.prefer_local().to_string()),
         };
         let dir_path = file_path.parent().unwrap_or(&file_path).to_owned();
         self.cx.root_path = dir_path.clone();
index 3f84979ac05e762bbc26b4bd404c52b2352356a2..494b3fb61ee970d38f1535c83dcd185f202beea1 100644 (file)
@@ -9,12 +9,14 @@
 use rustc_errors::ErrorReported;
 use rustc_parse::nt_to_tokenstream;
 use rustc_parse::parser::ForceCollect;
+use rustc_span::def_id::CrateNum;
 use rustc_span::{Span, DUMMY_SP};
 
 const EXEC_STRATEGY: pm::bridge::server::SameThread = pm::bridge::server::SameThread;
 
 pub struct BangProcMacro {
     pub client: pm::bridge::client::Client<fn(pm::TokenStream) -> pm::TokenStream>,
+    pub krate: CrateNum,
 }
 
 impl base::ProcMacro for BangProcMacro {
@@ -24,7 +26,7 @@ fn expand<'cx>(
         span: Span,
         input: TokenStream,
     ) -> Result<TokenStream, ErrorReported> {
-        let server = proc_macro_server::Rustc::new(ecx);
+        let server = proc_macro_server::Rustc::new(ecx, self.krate);
         self.client.run(&EXEC_STRATEGY, server, input, ecx.ecfg.proc_macro_backtrace).map_err(|e| {
             let mut err = ecx.struct_span_err(span, "proc macro panicked");
             if let Some(s) = e.as_str() {
@@ -38,6 +40,7 @@ fn expand<'cx>(
 
 pub struct AttrProcMacro {
     pub client: pm::bridge::client::Client<fn(pm::TokenStream, pm::TokenStream) -> pm::TokenStream>,
+    pub krate: CrateNum,
 }
 
 impl base::AttrProcMacro for AttrProcMacro {
@@ -48,7 +51,7 @@ fn expand<'cx>(
         annotation: TokenStream,
         annotated: TokenStream,
     ) -> Result<TokenStream, ErrorReported> {
-        let server = proc_macro_server::Rustc::new(ecx);
+        let server = proc_macro_server::Rustc::new(ecx, self.krate);
         self.client
             .run(&EXEC_STRATEGY, server, annotation, annotated, ecx.ecfg.proc_macro_backtrace)
             .map_err(|e| {
@@ -64,6 +67,7 @@ fn expand<'cx>(
 
 pub struct ProcMacroDerive {
     pub client: pm::bridge::client::Client<fn(pm::TokenStream) -> pm::TokenStream>,
+    pub krate: CrateNum,
 }
 
 impl MultiItemModifier for ProcMacroDerive {
@@ -97,7 +101,7 @@ fn expand(
             nt_to_tokenstream(&item, &ecx.sess.parse_sess, CanSynthesizeMissingTokens::No)
         };
 
-        let server = proc_macro_server::Rustc::new(ecx);
+        let server = proc_macro_server::Rustc::new(ecx, self.krate);
         let stream =
             match self.client.run(&EXEC_STRATEGY, server, input, ecx.ecfg.proc_macro_backtrace) {
                 Ok(stream) => stream,
index 1ea26b4eab44b3069ee73c8fcf0810a5016fe545..7bf6502c976ca6d69fd49aa978ee6df9f0ae0406 100644 (file)
@@ -1,4 +1,4 @@
-use crate::base::ExtCtxt;
+use crate::base::{ExtCtxt, ResolverExpand};
 
 use rustc_ast as ast;
 use rustc_ast::token;
@@ -7,6 +7,7 @@
 use rustc_ast::tokenstream::{self, CanSynthesizeMissingTokens};
 use rustc_ast::tokenstream::{DelimSpan, Spacing::*, TokenStream, TreeAndSpacing};
 use rustc_ast_pretty::pprust;
+use rustc_data_structures::fx::FxHashMap;
 use rustc_data_structures::sync::Lrc;
 use rustc_errors::Diagnostic;
 use rustc_lint_defs::builtin::PROC_MACRO_BACK_COMPAT;
@@ -14,6 +15,8 @@
 use rustc_parse::lexer::nfc_normalize;
 use rustc_parse::{nt_to_tokenstream, parse_stream_from_source_str};
 use rustc_session::parse::ParseSess;
+use rustc_span::def_id::CrateNum;
+use rustc_span::hygiene::ExpnId;
 use rustc_span::hygiene::ExpnKind;
 use rustc_span::symbol::{self, kw, sym, Symbol};
 use rustc_span::{BytePos, FileName, MultiSpan, Pos, RealFileName, SourceFile, Span};
@@ -355,22 +358,34 @@ pub struct Literal {
 }
 
 pub(crate) struct Rustc<'a> {
+    resolver: &'a dyn ResolverExpand,
     sess: &'a ParseSess,
     def_site: Span,
     call_site: Span,
     mixed_site: Span,
     span_debug: bool,
+    krate: CrateNum,
+    expn_id: ExpnId,
+    rebased_spans: FxHashMap<usize, Span>,
 }
 
 impl<'a> Rustc<'a> {
-    pub fn new(cx: &'a ExtCtxt<'_>) -> Self {
+    pub fn new(cx: &'a ExtCtxt<'_>, krate: CrateNum) -> Self {
         let expn_data = cx.current_expansion.id.expn_data();
+        let def_site = cx.with_def_site_ctxt(expn_data.def_site);
+        let call_site = cx.with_call_site_ctxt(expn_data.call_site);
+        let mixed_site = cx.with_mixed_site_ctxt(expn_data.call_site);
+        let sess = cx.parse_sess();
         Rustc {
-            sess: &cx.sess.parse_sess,
-            def_site: cx.with_def_site_ctxt(expn_data.def_site),
-            call_site: cx.with_call_site_ctxt(expn_data.call_site),
-            mixed_site: cx.with_mixed_site_ctxt(expn_data.call_site),
+            resolver: cx.resolver,
+            sess,
+            def_site,
+            call_site,
+            mixed_site,
             span_debug: cx.ecfg.span_debug,
+            krate,
+            expn_id: cx.current_expansion.id,
+            rebased_spans: FxHashMap::default(),
         }
     }
 
@@ -623,10 +638,11 @@ fn path(&mut self, file: &Self::SourceFile) -> String {
         match file.name {
             FileName::Real(ref name) => name
                 .local_path()
+                .expect("attempting to get a file path in an imported file in `proc_macro::SourceFile::path`")
                 .to_str()
                 .expect("non-UTF8 file path in `proc_macro::SourceFile::path`")
                 .to_string(),
-            _ => file.name.to_string(),
+            _ => file.name.prefer_local().to_string(),
         }
     }
     fn is_real(&mut self, file: &Self::SourceFile) -> bool {
@@ -713,6 +729,51 @@ fn resolved_at(&mut self, span: Self::Span, at: Self::Span) -> Self::Span {
     fn source_text(&mut self, span: Self::Span) -> Option<String> {
         self.sess.source_map().span_to_snippet(span).ok()
     }
+    /// Saves the provided span into the metadata of
+    /// *the crate we are currently compiling*, which must
+    /// be a proc-macro crate. This id can be passed to
+    /// `recover_proc_macro_span` when our current crate
+    /// is *run* as a proc-macro.
+    ///
+    /// Let's suppose that we have two crates - `my_client`
+    /// and `my_proc_macro`. The `my_proc_macro` crate
+    /// contains a procedural macro `my_macro`, which
+    /// is implemented as: `quote! { "hello" }`
+    ///
+    /// When we *compile* `my_proc_macro`, we will execute
+    /// the `quote` proc-macro. This will save the span of
+    /// "hello" into the metadata of `my_proc_macro`. As a result,
+    /// the body of `my_proc_macro` (after expansion) will end
+    /// up containg a call that looks like this:
+    /// `proc_macro::Ident::new("hello", proc_macro::Span::recover_proc_macro_span(0))`
+    ///
+    /// where `0` is the id returned by this function.
+    /// When `my_proc_macro` *executes* (during the compilation of `my_client`),
+    /// the call to `recover_proc_macro_span` will load the corresponding
+    /// span from the metadata of `my_proc_macro` (which we have access to,
+    /// since we've loaded `my_proc_macro` from disk in order to execute it).
+    /// In this way, we have obtained a span pointing into `my_proc_macro`
+    fn save_span(&mut self, mut span: Self::Span) -> usize {
+        // Throw away the `SyntaxContext`, since we currently
+        // skip serializing `SyntaxContext`s for proc-macro crates
+        span = span.with_ctxt(rustc_span::SyntaxContext::root());
+        self.sess.save_proc_macro_span(span)
+    }
+    fn recover_proc_macro_span(&mut self, id: usize) -> Self::Span {
+        let resolver = self.resolver;
+        let krate = self.krate;
+        let expn_id = self.expn_id;
+        *self.rebased_spans.entry(id).or_insert_with(|| {
+            let raw_span = resolver.get_proc_macro_quoted_span(krate, id);
+            // Ignore the deserialized `SyntaxContext` entirely.
+            // FIXME: Preserve the macro backtrace from the serialized span
+            // For example, if a proc-macro crate has code like
+            // `macro_one!() -> macro_two!() -> quote!()`, we might
+            // want to 'concatenate' this backtrace with the backtrace from
+            // our current call site.
+            raw_span.with_def_site_ctxt(expn_id)
+        })
+    }
 }
 
 // See issue #74616 for details
@@ -722,10 +783,10 @@ fn ident_name_compatibility_hack(
     rustc: &mut Rustc<'_>,
 ) -> Option<(rustc_span::symbol::Ident, bool)> {
     if let NtIdent(ident, is_raw) = nt {
-        if let ExpnKind::Macro(_, macro_name) = orig_span.ctxt().outer_expn_data().kind {
+        if let ExpnKind::Macro { name: macro_name, .. } = orig_span.ctxt().outer_expn_data().kind {
             let source_map = rustc.sess.source_map();
             let filename = source_map.span_to_filename(orig_span);
-            if let FileName::Real(RealFileName::Named(path)) = filename {
+            if let FileName::Real(RealFileName::LocalPath(path)) = filename {
                 let matches_prefix = |prefix, filename| {
                     // Check for a path that ends with 'prefix*/src/<filename>'
                     let mut iter = path.components().rev();
@@ -788,7 +849,7 @@ fn ident_name_compatibility_hack(
                 if macro_name == sym::tuple_from_req && matches_prefix("actix-web", "extract.rs") {
                     let snippet = source_map.span_to_snippet(orig_span);
                     if snippet.as_deref() == Ok("$T") {
-                        if let FileName::Real(RealFileName::Named(macro_path)) =
+                        if let FileName::Real(RealFileName::LocalPath(macro_path)) =
                             source_map.span_to_filename(rustc.def_site)
                         {
                             if macro_path.to_string_lossy().contains("pin-project-internal-0.") {
index f747f8545145ee00a0451d5c16dae9cc240a7c50..9d96a9baa50c8da93def940f152ed8bc329dc94f 100644 (file)
@@ -274,9 +274,6 @@ pub fn set(&self, features: &mut Features, span: Span) {
     /// Allows using non lexical lifetimes (RFC 2094).
     (active, nll, "1.0.0", Some(43234), None),
 
-    /// Allows the definition of `const` functions with some advanced features.
-    (active, const_fn, "1.2.0", Some(57563), None),
-
     /// Allows associated type defaults.
     (active, associated_type_defaults, "1.2.0", Some(29661), None),
 
@@ -703,6 +700,7 @@ pub fn set(&self, features: &mut Features, span: Span) {
     sym::native_link_modifiers_verbatim,
     sym::native_link_modifiers_whole_archive,
     sym::native_link_modifiers_as_needed,
+    sym::rustc_insignificant_dtor,
 ];
 
 /// Some features are not allowed to be used together at the same time, if
index a8719be84c2a44c68ed793f65bd3b16a36c0cc52..e7e128f8a9b21e23bdbc4f74874e6462c9bcf6e2 100644 (file)
@@ -469,7 +469,6 @@ macro_rules! experimental {
     // ==========================================================================
 
     rustc_attr!(rustc_promotable, AssumedUsed, template!(Word), IMPL_DETAIL),
-    rustc_attr!(rustc_args_required_const, AssumedUsed, template!(List: "N"), INTERNAL_UNSTABLE),
     rustc_attr!(rustc_legacy_const_generics, AssumedUsed, template!(List: "N"), INTERNAL_UNSTABLE),
 
     // ==========================================================================
@@ -557,6 +556,7 @@ macro_rules! experimental {
 
     rustc_attr!(TEST, rustc_outlives, Normal, template!(Word)),
     rustc_attr!(TEST, rustc_capture_analysis, Normal, template!(Word)),
+    rustc_attr!(TEST, rustc_insignificant_dtor, Normal, template!(Word)),
     rustc_attr!(TEST, rustc_variance, Normal, template!(Word)),
     rustc_attr!(TEST, rustc_layout, Normal, template!(List: "field1, field2, ...")),
     rustc_attr!(TEST, rustc_regions, Normal, template!(Word)),
@@ -565,6 +565,7 @@ macro_rules! experimental {
         template!(Word, List: "delay_span_bug_from_inside_query")
     ),
     rustc_attr!(TEST, rustc_dump_user_substs, AssumedUsed, template!(Word)),
+    rustc_attr!(TEST, rustc_evaluate_where_clauses, AssumedUsed, template!(Word)),
     rustc_attr!(TEST, rustc_if_this_changed, AssumedUsed, template!(Word, List: "DepNode")),
     rustc_attr!(TEST, rustc_then_this_would_need, AssumedUsed, template!(List: "DepNode")),
     rustc_attr!(
index fa8ef182aeddf2a0eaf815fe6503742cbb304697..138398825af586123ec3c59e07c4fdd96f556113 100644 (file)
@@ -136,6 +136,9 @@ macro_rules! declare_features {
     (removed, main, "1.53.0", Some(29634), None, None),
     (removed, pub_macro_rules, "1.53.0", Some(78855), None,
      Some("removed due to being incomplete, in particular it does not work across crates")),
+     /// Allows the definition of `const` functions with some advanced features.
+    (removed, const_fn, "1.54.0", Some(57563), None,
+     Some("split into finer-grained feature gates")),
 
     // -------------------------------------------------------------------------
     // feature-group-end: removed features
index ddf8218616988756edeea2657241a69ff0a00d32..b05ca381b8ab6e9263be40f01a2e17fa2258073c 100644 (file)
@@ -19,7 +19,6 @@ macro_rules! arena_types {
             [] attribute: rustc_ast::Attribute,
             [] block: rustc_hir::Block<$tcx>,
             [] bare_fn_ty: rustc_hir::BareFnTy<$tcx>,
-            [few] global_asm: rustc_hir::GlobalAsm,
             [] generic_arg: rustc_hir::GenericArg<$tcx>,
             [] generic_args: rustc_hir::GenericArgs<$tcx>,
             [] generic_bound: rustc_hir::GenericBound<$tcx>,
index 5baaaad7370fc6f2bbf1c813154a147743d367e2..91fd97a0d4020150e23f8ecdca355c43d8957ad8 100644 (file)
@@ -12,7 +12,7 @@
 use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
 use rustc_data_structures::sync::{par_for_each_in, Send, Sync};
 use rustc_macros::HashStable_Generic;
-use rustc_span::source_map::{SourceMap, Spanned};
+use rustc_span::source_map::Spanned;
 use rustc_span::symbol::{kw, sym, Ident, Symbol};
 use rustc_span::{def_id::LocalDefId, BytePos};
 use rustc_span::{MultiSpan, Span, DUMMY_SP};
@@ -314,11 +314,18 @@ pub struct GenericArgs<'hir> {
     /// This is required mostly for pretty-printing and diagnostics,
     /// but also for changing lifetime elision rules to be "function-like".
     pub parenthesized: bool,
+    /// The span encompassing arguments and the surrounding brackets `<>` or `()`
+    ///       Foo<A, B, AssocTy = D>           Fn(T, U, V) -> W
+    ///          ^^^^^^^^^^^^^^^^^^^             ^^^^^^^^^
+    /// Note that this may be:
+    /// - empty, if there are no generic brackets (but there may be hidden lifetimes)
+    /// - dummy, if this was generated while desugaring
+    pub span_ext: Span,
 }
 
 impl GenericArgs<'_> {
     pub const fn none() -> Self {
-        Self { args: &[], bindings: &[], parenthesized: false }
+        Self { args: &[], bindings: &[], parenthesized: false, span_ext: DUMMY_SP }
     }
 
     pub fn inputs(&self) -> &[Ty<'_>] {
@@ -356,33 +363,17 @@ pub fn own_counts(&self) -> GenericParamCount {
         own_counts
     }
 
+    /// The span encompassing the text inside the surrounding brackets.
+    /// It will also include bindings if they aren't in the form `-> Ret`
+    /// Returns `None` if the span is empty (e.g. no brackets) or dummy
     pub fn span(&self) -> Option<Span> {
-        self.args
-            .iter()
-            .filter(|arg| !arg.is_synthetic())
-            .map(|arg| arg.span())
-            .reduce(|span1, span2| span1.to(span2))
+        let span_ext = self.span_ext()?;
+        Some(span_ext.with_lo(span_ext.lo() + BytePos(1)).with_hi(span_ext.hi() - BytePos(1)))
     }
 
     /// Returns span encompassing arguments and their surrounding `<>` or `()`
-    pub fn span_ext(&self, sm: &SourceMap) -> Option<Span> {
-        let mut span = self.span()?;
-
-        let (o, c) = if self.parenthesized { ('(', ')') } else { ('<', '>') };
-
-        if let Ok(snippet) = sm.span_to_snippet(span) {
-            let snippet = snippet.as_bytes();
-
-            if snippet[0] != (o as u8) || snippet[snippet.len() - 1] != (c as u8) {
-                span = sm.span_extend_to_prev_char(span, o, true);
-                span = span.with_lo(span.lo() - BytePos(1));
-
-                span = sm.span_extend_to_next_char(span, c, true);
-                span = span.with_hi(span.hi() + BytePos(1));
-            }
-        }
-
-        Some(span)
+    pub fn span_ext(&self) -> Option<Span> {
+        Some(self.span_ext).filter(|span| !span.is_empty())
     }
 
     pub fn is_empty(&self) -> bool {
@@ -2511,11 +2502,6 @@ pub struct Mod<'hir> {
     pub item_ids: &'hir [ItemId],
 }
 
-#[derive(Encodable, Debug, HashStable_Generic)]
-pub struct GlobalAsm {
-    pub asm: Symbol,
-}
-
 #[derive(Debug, HashStable_Generic)]
 pub struct EnumDef<'hir> {
     pub variants: &'hir [Variant<'hir>],
@@ -2775,7 +2761,7 @@ pub enum ItemKind<'hir> {
     /// An external module, e.g. `extern { .. }`.
     ForeignMod { abi: Abi, items: &'hir [ForeignItemRef<'hir>] },
     /// Module-level inline assembly (from `global_asm!`).
-    GlobalAsm(&'hir GlobalAsm),
+    GlobalAsm(&'hir InlineAsm<'hir>),
     /// A type alias, e.g., `type Foo = Bar<u8>`.
     TyAlias(&'hir Ty<'hir>, Generics<'hir>),
     /// An opaque `impl Trait` type alias, e.g., `type Foo = impl Bar;`.
index 0ce04a77a5056b9a92db0cde710037920e8ecbf8..c08f1f53218d625c6062bbe39caf7a89186a1490 100644 (file)
@@ -589,8 +589,9 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) {
             visitor.visit_id(item.hir_id());
             walk_list!(visitor, visit_foreign_item_ref, items);
         }
-        ItemKind::GlobalAsm(_) => {
+        ItemKind::GlobalAsm(asm) => {
             visitor.visit_id(item.hir_id());
+            walk_inline_asm(visitor, asm);
         }
         ItemKind::TyAlias(ref ty, ref generics) => {
             visitor.visit_id(item.hir_id());
@@ -650,6 +651,28 @@ pub fn walk_item<'v, V: Visitor<'v>>(visitor: &mut V, item: &'v Item<'v>) {
     }
 }
 
+fn walk_inline_asm<'v, V: Visitor<'v>>(visitor: &mut V, asm: &'v InlineAsm<'v>) {
+    for (op, _op_sp) in asm.operands {
+        match op {
+            InlineAsmOperand::In { expr, .. }
+            | InlineAsmOperand::InOut { expr, .. }
+            | InlineAsmOperand::Sym { expr, .. } => visitor.visit_expr(expr),
+            InlineAsmOperand::Out { expr, .. } => {
+                if let Some(expr) = expr {
+                    visitor.visit_expr(expr);
+                }
+            }
+            InlineAsmOperand::SplitInOut { in_expr, out_expr, .. } => {
+                visitor.visit_expr(in_expr);
+                if let Some(out_expr) = out_expr {
+                    visitor.visit_expr(out_expr);
+                }
+            }
+            InlineAsmOperand::Const { anon_const } => visitor.visit_anon_const(anon_const),
+        }
+    }
+}
+
 pub fn walk_use<'v, V: Visitor<'v>>(visitor: &mut V, path: &'v Path<'v>, hir_id: HirId) {
     visitor.visit_id(hir_id);
     visitor.visit_path(path, hir_id);
@@ -1185,27 +1208,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr<'v>)
             walk_list!(visitor, visit_expr, optional_expression);
         }
         ExprKind::InlineAsm(ref asm) => {
-            for (op, _op_sp) in asm.operands {
-                match op {
-                    InlineAsmOperand::In { expr, .. }
-                    | InlineAsmOperand::InOut { expr, .. }
-                    | InlineAsmOperand::Sym { expr, .. } => visitor.visit_expr(expr),
-                    InlineAsmOperand::Out { expr, .. } => {
-                        if let Some(expr) = expr {
-                            visitor.visit_expr(expr);
-                        }
-                    }
-                    InlineAsmOperand::SplitInOut { in_expr, out_expr, .. } => {
-                        visitor.visit_expr(in_expr);
-                        if let Some(out_expr) = out_expr {
-                            visitor.visit_expr(out_expr);
-                        }
-                    }
-                    InlineAsmOperand::Const { anon_const, .. } => {
-                        visitor.visit_anon_const(anon_const)
-                    }
-                }
-            }
+            walk_inline_asm(visitor, asm);
         }
         ExprKind::LlvmInlineAsm(ref asm) => {
             walk_list!(visitor, visit_expr, asm.outputs_exprs);
index 498000db50f436a854a9c6e86de2180272aebea5..7b788b13b9f7d41aa197123f2f3398558e8adda0 100644 (file)
@@ -343,4 +343,7 @@ pub fn extract<'a, F>(check_name: F, attrs: &'a [ast::Attribute]) -> Option<(Sym
     Range,                   sym::Range,               range_struct,               Target::Struct;
     RangeToInclusive,        sym::RangeToInclusive,    range_to_inclusive_struct,  Target::Struct;
     RangeTo,                 sym::RangeTo,             range_to_struct,            Target::Struct;
+    Send,                    sym::send,                send_trait,                 Target::Trait;
+    UnwindSafe,              sym::unwind_safe,         unwind_safe_trait,          Target::Trait;
+    RefUnwindSafe,           sym::ref_unwind_safe,     ref_unwind_safe_trait,      Target::Trait;
 }
index 77d083fc5e967b4cae32fd111f2efdc40646c105..fe02cc5de8cb8d459de28973fc3ffee67c52db2b 100644 (file)
@@ -660,9 +660,9 @@ pub fn print_item(&mut self, item: &hir::Item<'_>) {
                 }
                 self.bclose(item.span);
             }
-            hir::ItemKind::GlobalAsm(ref ga) => {
-                self.head(visibility_qualified(&item.vis, "global asm"));
-                self.s.word(ga.asm.to_string());
+            hir::ItemKind::GlobalAsm(ref asm) => {
+                self.head(visibility_qualified(&item.vis, "global_asm!"));
+                self.print_inline_asm(asm);
                 self.end()
             }
             hir::ItemKind::TyAlias(ref ty, ref generics) => {
@@ -1352,6 +1352,110 @@ fn print_literal(&mut self, lit: &hir::Lit) {
         self.word(lit.node.to_lit_token().to_string())
     }
 
+    fn print_inline_asm(&mut self, asm: &hir::InlineAsm<'_>) {
+        enum AsmArg<'a> {
+            Template(String),
+            Operand(&'a hir::InlineAsmOperand<'a>),
+            Options(ast::InlineAsmOptions),
+        }
+
+        let mut args = vec![];
+        args.push(AsmArg::Template(ast::InlineAsmTemplatePiece::to_string(&asm.template)));
+        args.extend(asm.operands.iter().map(|(o, _)| AsmArg::Operand(o)));
+        if !asm.options.is_empty() {
+            args.push(AsmArg::Options(asm.options));
+        }
+
+        self.popen();
+        self.commasep(Consistent, &args, |s, arg| match arg {
+            AsmArg::Template(template) => s.print_string(&template, ast::StrStyle::Cooked),
+            AsmArg::Operand(op) => match op {
+                hir::InlineAsmOperand::In { reg, expr } => {
+                    s.word("in");
+                    s.popen();
+                    s.word(format!("{}", reg));
+                    s.pclose();
+                    s.space();
+                    s.print_expr(expr);
+                }
+                hir::InlineAsmOperand::Out { reg, late, expr } => {
+                    s.word(if *late { "lateout" } else { "out" });
+                    s.popen();
+                    s.word(format!("{}", reg));
+                    s.pclose();
+                    s.space();
+                    match expr {
+                        Some(expr) => s.print_expr(expr),
+                        None => s.word("_"),
+                    }
+                }
+                hir::InlineAsmOperand::InOut { reg, late, expr } => {
+                    s.word(if *late { "inlateout" } else { "inout" });
+                    s.popen();
+                    s.word(format!("{}", reg));
+                    s.pclose();
+                    s.space();
+                    s.print_expr(expr);
+                }
+                hir::InlineAsmOperand::SplitInOut { reg, late, in_expr, out_expr } => {
+                    s.word(if *late { "inlateout" } else { "inout" });
+                    s.popen();
+                    s.word(format!("{}", reg));
+                    s.pclose();
+                    s.space();
+                    s.print_expr(in_expr);
+                    s.space();
+                    s.word_space("=>");
+                    match out_expr {
+                        Some(out_expr) => s.print_expr(out_expr),
+                        None => s.word("_"),
+                    }
+                }
+                hir::InlineAsmOperand::Const { anon_const } => {
+                    s.word("const");
+                    s.space();
+                    s.print_anon_const(anon_const);
+                }
+                hir::InlineAsmOperand::Sym { expr } => {
+                    s.word("sym");
+                    s.space();
+                    s.print_expr(expr);
+                }
+            },
+            AsmArg::Options(opts) => {
+                s.word("options");
+                s.popen();
+                let mut options = vec![];
+                if opts.contains(ast::InlineAsmOptions::PURE) {
+                    options.push("pure");
+                }
+                if opts.contains(ast::InlineAsmOptions::NOMEM) {
+                    options.push("nomem");
+                }
+                if opts.contains(ast::InlineAsmOptions::READONLY) {
+                    options.push("readonly");
+                }
+                if opts.contains(ast::InlineAsmOptions::PRESERVES_FLAGS) {
+                    options.push("preserves_flags");
+                }
+                if opts.contains(ast::InlineAsmOptions::NORETURN) {
+                    options.push("noreturn");
+                }
+                if opts.contains(ast::InlineAsmOptions::NOSTACK) {
+                    options.push("nostack");
+                }
+                if opts.contains(ast::InlineAsmOptions::ATT_SYNTAX) {
+                    options.push("att_syntax");
+                }
+                s.commasep(Inconsistent, &options, |s, &opt| {
+                    s.word(opt);
+                });
+                s.pclose();
+            }
+        });
+        self.pclose();
+    }
+
     pub fn print_expr(&mut self, expr: &hir::Expr<'_>) {
         self.maybe_print_comment(expr.span.lo());
         self.print_outer_attributes(self.attrs(expr.hir_id));
@@ -1530,109 +1634,9 @@ pub fn print_expr(&mut self, expr: &hir::Expr<'_>) {
                     self.print_expr_maybe_paren(&expr, parser::PREC_JUMP);
                 }
             }
-            hir::ExprKind::InlineAsm(ref a) => {
-                enum AsmArg<'a> {
-                    Template(String),
-                    Operand(&'a hir::InlineAsmOperand<'a>),
-                    Options(ast::InlineAsmOptions),
-                }
-
-                let mut args = vec![];
-                args.push(AsmArg::Template(ast::InlineAsmTemplatePiece::to_string(&a.template)));
-                args.extend(a.operands.iter().map(|(o, _)| AsmArg::Operand(o)));
-                if !a.options.is_empty() {
-                    args.push(AsmArg::Options(a.options));
-                }
-
+            hir::ExprKind::InlineAsm(ref asm) => {
                 self.word("asm!");
-                self.popen();
-                self.commasep(Consistent, &args, |s, arg| match arg {
-                    AsmArg::Template(template) => s.print_string(&template, ast::StrStyle::Cooked),
-                    AsmArg::Operand(op) => match op {
-                        hir::InlineAsmOperand::In { reg, expr } => {
-                            s.word("in");
-                            s.popen();
-                            s.word(format!("{}", reg));
-                            s.pclose();
-                            s.space();
-                            s.print_expr(expr);
-                        }
-                        hir::InlineAsmOperand::Out { reg, late, expr } => {
-                            s.word(if *late { "lateout" } else { "out" });
-                            s.popen();
-                            s.word(format!("{}", reg));
-                            s.pclose();
-                            s.space();
-                            match expr {
-                                Some(expr) => s.print_expr(expr),
-                                None => s.word("_"),
-                            }
-                        }
-                        hir::InlineAsmOperand::InOut { reg, late, expr } => {
-                            s.word(if *late { "inlateout" } else { "inout" });
-                            s.popen();
-                            s.word(format!("{}", reg));
-                            s.pclose();
-                            s.space();
-                            s.print_expr(expr);
-                        }
-                        hir::InlineAsmOperand::SplitInOut { reg, late, in_expr, out_expr } => {
-                            s.word(if *late { "inlateout" } else { "inout" });
-                            s.popen();
-                            s.word(format!("{}", reg));
-                            s.pclose();
-                            s.space();
-                            s.print_expr(in_expr);
-                            s.space();
-                            s.word_space("=>");
-                            match out_expr {
-                                Some(out_expr) => s.print_expr(out_expr),
-                                None => s.word("_"),
-                            }
-                        }
-                        hir::InlineAsmOperand::Const { anon_const } => {
-                            s.word("const");
-                            s.space();
-                            s.print_anon_const(anon_const);
-                        }
-                        hir::InlineAsmOperand::Sym { expr } => {
-                            s.word("sym");
-                            s.space();
-                            s.print_expr(expr);
-                        }
-                    },
-                    AsmArg::Options(opts) => {
-                        s.word("options");
-                        s.popen();
-                        let mut options = vec![];
-                        if opts.contains(ast::InlineAsmOptions::PURE) {
-                            options.push("pure");
-                        }
-                        if opts.contains(ast::InlineAsmOptions::NOMEM) {
-                            options.push("nomem");
-                        }
-                        if opts.contains(ast::InlineAsmOptions::READONLY) {
-                            options.push("readonly");
-                        }
-                        if opts.contains(ast::InlineAsmOptions::PRESERVES_FLAGS) {
-                            options.push("preserves_flags");
-                        }
-                        if opts.contains(ast::InlineAsmOptions::NORETURN) {
-                            options.push("noreturn");
-                        }
-                        if opts.contains(ast::InlineAsmOptions::NOSTACK) {
-                            options.push("nostack");
-                        }
-                        if opts.contains(ast::InlineAsmOptions::ATT_SYNTAX) {
-                            options.push("att_syntax");
-                        }
-                        s.commasep(Inconsistent, &options, |s, &opt| {
-                            s.word(opt);
-                        });
-                        s.pclose();
-                    }
-                });
-                self.pclose();
+                self.print_inline_asm(asm);
             }
             hir::ExprKind::LlvmInlineAsm(ref a) => {
                 let i = &a.inner;
index 2661afd7ffc3b32d5a72d88043863cd5664224da..bd3b5239f7bda7245735a1ccd3ea7a7539ceb169 100644 (file)
@@ -1,7 +1,7 @@
 //! Code to save/load the dep-graph from files.
 
 use rustc_data_structures::fx::FxHashMap;
-use rustc_hir::definitions::Definitions;
+use rustc_hir::definitions::DefPathTable;
 use rustc_middle::dep_graph::{PreviousDepGraph, SerializedDepGraph, WorkProduct, WorkProductId};
 use rustc_middle::ty::query::OnDiskCache;
 use rustc_serialize::opaque::Decoder;
@@ -198,7 +198,7 @@ pub fn load_dep_graph(sess: &Session) -> DepGraphFuture {
 /// creating an empty cache if it could not be loaded.
 pub fn load_query_result_cache<'a>(
     sess: &'a Session,
-    definitions: &Definitions,
+    def_path_table: &DefPathTable,
 ) -> Option<OnDiskCache<'a>> {
     if sess.opts.incremental.is_none() {
         return None;
@@ -212,7 +212,7 @@ pub fn load_query_result_cache<'a>(
         sess.is_nightly_build(),
     ) {
         LoadResult::Ok { data: (bytes, start_pos) } => {
-            Some(OnDiskCache::new(sess, bytes, start_pos, definitions))
+            Some(OnDiskCache::new(sess, bytes, start_pos, def_path_table))
         }
         _ => Some(OnDiskCache::new_empty(sess.source_map())),
     }
index 1cafb2fe1a24f48be2c35cb106bb53a5c9973a2a..680f6af63f26c6528bdf9dacb62f58ac88de2c5a 100644 (file)
@@ -1604,13 +1604,19 @@ enum Mismatch<'a> {
             match (&terr, expected == found) {
                 (TypeError::Sorts(values), extra) => {
                     let sort_string = |ty: Ty<'tcx>| match (extra, ty.kind()) {
-                        (true, ty::Opaque(def_id, _)) => format!(
-                            " (opaque type at {})",
-                            self.tcx
+                        (true, ty::Opaque(def_id, _)) => {
+                            let pos = self
+                                .tcx
                                 .sess
                                 .source_map()
-                                .mk_substr_filename(self.tcx.def_span(*def_id)),
-                        ),
+                                .lookup_char_pos(self.tcx.def_span(*def_id).lo());
+                            format!(
+                                " (opaque type at <{}:{}:{}>)",
+                                pos.file.name.prefer_local(),
+                                pos.line,
+                                pos.col.to_usize() + 1,
+                            )
+                        }
                         (true, _) => format!(" ({})", ty.sort_string(self.tcx)),
                         (false, _) => "".to_string(),
                     };
index 2f3c0d6957a613f12ff33bd428369aab78cc83e1..0878f8550da35a6a3d7abf830039bbc4943124ad 100644 (file)
@@ -114,12 +114,16 @@ pub(super) fn try_report_named_anon_conflict(&self) -> Option<DiagnosticBuilder<
         );
 
         diag.span_label(span, format!("lifetime `{}` required", named));
-        diag.span_suggestion(
-            new_ty_span,
-            &format!("add explicit lifetime `{}` to {}", named, span_label_var),
-            new_ty.to_string(),
-            Applicability::Unspecified,
-        );
+        // Suggesting `'static` is nearly always incorrect, and can steer users
+        // down the wrong path.
+        if *named != ty::ReStatic {
+            diag.span_suggestion(
+                new_ty_span,
+                &format!("add explicit lifetime `{}` to {}", named, span_label_var),
+                new_ty.to_string(),
+                Applicability::Unspecified,
+            );
+        }
 
         Some(diag)
     }
index 02e62a2cee951d62044871a00e208ab5901a75e4..06bec91501fd58253f54f98559154483be701581 100644 (file)
@@ -13,7 +13,6 @@
 use rustc_errors::{ErrorReported, PResult};
 use rustc_expand::base::ExtCtxt;
 use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
-use rustc_hir::definitions::Definitions;
 use rustc_hir::Crate;
 use rustc_lint::LintStore;
 use rustc_metadata::creader::CStore;
@@ -36,7 +35,6 @@
 use rustc_session::search_paths::PathKind;
 use rustc_session::Session;
 use rustc_span::symbol::{Ident, Symbol};
-use rustc_span::{FileName, RealFileName};
 use rustc_trait_selection::traits;
 use rustc_typeck as typeck;
 use tracing::{info, warn};
@@ -51,7 +49,7 @@
 use std::lazy::SyncLazy;
 use std::path::PathBuf;
 use std::rc::Rc;
-use std::{env, fs, iter, mem};
+use std::{env, fs, iter};
 
 pub fn parse<'a>(sess: &'a Session, input: &Input) -> PResult<'a, ast::Crate> {
     let krate = sess.time("parse_crate", || match input {
@@ -532,10 +530,10 @@ fn output_conflicts_with_dir(output_paths: &[PathBuf]) -> Option<PathBuf> {
     check_output(output_paths, check)
 }
 
-fn escape_dep_filename(filename: &FileName) -> String {
+fn escape_dep_filename(filename: &String) -> String {
     // Apparently clang and gcc *only* escape spaces:
     // http://llvm.org/klaus/clang/commit/9d50634cfc268ecc9a7250226dd5ca0e945240d4
-    filename.to_string().replace(" ", "\\ ")
+    filename.replace(" ", "\\ ")
 }
 
 // Makefile comments only need escaping newlines and `\`.
@@ -575,7 +573,7 @@ fn write_out_deps(
             .iter()
             .filter(|fmap| fmap.is_real_file())
             .filter(|fmap| !fmap.is_imported())
-            .map(|fmap| escape_dep_filename(&fmap.unmapped_path.as_ref().unwrap_or(&fmap.name)))
+            .map(|fmap| escape_dep_filename(&fmap.name.prefer_local().to_string()))
             .collect();
 
         if let Some(ref backend) = sess.opts.debugging_opts.codegen_backend {
@@ -587,16 +585,13 @@ fn write_out_deps(
                 for cnum in resolver.cstore().crates_untracked() {
                     let source = resolver.cstore().crate_source_untracked(cnum);
                     if let Some((path, _)) = source.dylib {
-                        let file_name = FileName::Real(RealFileName::Named(path));
-                        files.push(escape_dep_filename(&file_name));
+                        files.push(escape_dep_filename(&path.display().to_string()));
                     }
                     if let Some((path, _)) = source.rlib {
-                        let file_name = FileName::Real(RealFileName::Named(path));
-                        files.push(escape_dep_filename(&file_name));
+                        files.push(escape_dep_filename(&path.display().to_string()));
                     }
                     if let Some((path, _)) = source.rmeta {
-                        let file_name = FileName::Real(RealFileName::Named(path));
-                        files.push(escape_dep_filename(&file_name));
+                        files.push(escape_dep_filename(&path.display().to_string()));
                     }
                 }
             });
@@ -761,7 +756,7 @@ pub fn create_global_ctxt<'tcx>(
     lint_store: Lrc<LintStore>,
     krate: &'tcx Crate<'tcx>,
     dep_graph: DepGraph,
-    mut resolver_outputs: ResolverOutputs,
+    resolver_outputs: ResolverOutputs,
     outputs: OutputFilenames,
     crate_name: &str,
     queries: &'tcx OnceCell<TcxQueries<'tcx>>,
@@ -769,12 +764,10 @@ pub fn create_global_ctxt<'tcx>(
     arena: &'tcx WorkerLocal<Arena<'tcx>>,
 ) -> QueryContext<'tcx> {
     let sess = &compiler.session();
-    let defs: &'tcx Definitions = arena.alloc(mem::replace(
-        &mut resolver_outputs.definitions,
-        Definitions::new(crate_name, sess.local_crate_disambiguator()),
-    ));
 
-    let query_result_on_disk_cache = rustc_incremental::load_query_result_cache(sess, defs);
+    let def_path_table = resolver_outputs.definitions.def_path_table();
+    let query_result_on_disk_cache =
+        rustc_incremental::load_query_result_cache(sess, def_path_table);
 
     let codegen_backend = compiler.codegen_backend();
     let mut local_providers = *DEFAULT_QUERY_PROVIDERS;
@@ -798,7 +791,6 @@ pub fn create_global_ctxt<'tcx>(
                 arena,
                 resolver_outputs,
                 krate,
-                defs,
                 dep_graph,
                 query_result_on_disk_cache,
                 queries.as_dyn(),
@@ -884,7 +876,11 @@ fn analysis(tcx: TyCtxt<'_>, cnum: CrateNum) -> Result<()> {
 
     sess.time("MIR_effect_checking", || {
         for def_id in tcx.body_owners() {
-            mir::transform::check_unsafety::check_unsafety(tcx, def_id);
+            if tcx.sess.opts.debugging_opts.thir_unsafeck {
+                tcx.ensure().thir_check_unsafety(def_id);
+            } else {
+                mir::transform::check_unsafety::check_unsafety(tcx, def_id);
+            }
 
             if tcx.hir().body_const_context(def_id).is_some() {
                 tcx.ensure()
index fd13cb3d59acd203b48255f5f09ca60c4ffc574e..bea7d0fb81f95d924292e977b1345d5e2a491637 100644 (file)
@@ -724,6 +724,7 @@ macro_rules! tracked {
     tracked!(profile_emit, Some(PathBuf::from("abc")));
     tracked!(relax_elf_relocations, Some(true));
     tracked!(relro_level, Some(RelroLevel::Full));
+    tracked!(simulate_remapped_rust_src_base, Some(PathBuf::from("/rustc/abc")));
     tracked!(report_delayed_bugs, true);
     tracked!(sanitizer, SanitizerSet::ADDRESS);
     tracked!(sanitizer_memory_track_origins, 2);
@@ -735,6 +736,7 @@ macro_rules! tracked {
     tracked!(symbol_mangling_version, Some(SymbolManglingVersion::V0));
     tracked!(teach, true);
     tracked!(thinlto, Some(true));
+    tracked!(thir_unsafeck, true);
     tracked!(tune_cpu, Some(String::from("abc")));
     tracked!(tls_model, Some(TlsModel::GeneralDynamic));
     tracked!(trap_unreachable, Some(false));
index 9b1a339572ec3cfe5b9fde1709d72415c3aba51a..0398d4a99618a9fe1498bea256be428c69956945 100644 (file)
@@ -248,10 +248,21 @@ fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
                 if last.ident.name == sym::LintPass {
                     let expn_data = lint_pass.path.span.ctxt().outer_expn_data();
                     let call_site = expn_data.call_site;
-                    if expn_data.kind != ExpnKind::Macro(MacroKind::Bang, sym::impl_lint_pass)
-                        && call_site.ctxt().outer_expn_data().kind
-                            != ExpnKind::Macro(MacroKind::Bang, sym::declare_lint_pass)
-                    {
+                    if !matches!(
+                        expn_data.kind,
+                        ExpnKind::Macro {
+                            kind: MacroKind::Bang,
+                            name: sym::impl_lint_pass,
+                            proc_macro: _
+                        }
+                    ) && !matches!(
+                        call_site.ctxt().outer_expn_data().kind,
+                        ExpnKind::Macro {
+                            kind: MacroKind::Bang,
+                            name: sym::declare_lint_pass,
+                            proc_macro: _
+                        }
+                    ) {
                         cx.struct_span_lint(
                             LINT_PASS_IMPL_WITHOUT_MACRO,
                             lint_pass.path.span,
index 070bc3522a453c28cc59199bb086b585ab6e4d83..c91dc37b374f861d221f149d5b7badd552333dce 100644 (file)
@@ -248,10 +248,11 @@ fn panic_call<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>) -> (Span,
         }
     }
 
-    let macro_symbol = if let hygiene::ExpnKind::Macro(_, symbol) = expn.kind {
-        symbol
-    } else {
-        Symbol::intern("panic")
-    };
+    let macro_symbol =
+        if let hygiene::ExpnKind::Macro { kind: _, name: symbol, proc_macro: _ } = expn.kind {
+            symbol
+        } else {
+            Symbol::intern("panic")
+        };
     (expn.call_site, panic_macro, macro_symbol.as_str())
 }
index beb4d36597cfc800ba1be769d31a2d34b1ae2d49..15246971bae02e82175430a15b2b5f92a65ba82f 100644 (file)
         UNSUPPORTED_NAKED_FUNCTIONS,
         MISSING_ABI,
         SEMICOLON_IN_EXPRESSIONS_FROM_MACROS,
-        DISJOINT_CAPTURE_DROP_REORDER,
+        DISJOINT_CAPTURE_MIGRATION,
         LEGACY_DERIVE_HELPERS,
         PROC_MACRO_BACK_COMPAT,
         OR_PATTERNS_BACK_COMPAT,
 }
 
 declare_lint! {
-    /// The `disjoint_capture_drop_reorder` lint detects variables that aren't completely
+    /// The `disjoint_capture_migration` 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.
+    /// It can also detect when a variable implements a trait, but one of its field does not and
+    /// the field is captured by a closure and used with the assumption that said field implements
+    /// the same trait as the root variable.
     ///
-    /// ### Example
+    /// ### Example of drop reorder
     ///
     /// ```rust,compile_fail
-    /// # #![deny(disjoint_capture_drop_reorder)]
+    /// # #![deny(disjoint_capture_migration)]
     /// # #![allow(unused)]
     /// struct FancyInteger(i32);
     ///
     ///
     /// 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,
+    ///
+    /// ### Example of auto-trait
+    ///
+    /// ```rust,compile_fail
+    /// #![deny(disjoint_capture_migration)]
+    /// use std::thread;
+    ///
+    /// struct Pointer (*mut i32);
+    /// unsafe impl Send for Pointer {}
+    ///
+    /// fn main() {
+    ///     let mut f = 10;
+    ///     let fptr = Pointer(&mut f as *mut i32);
+    ///     thread::spawn(move || unsafe {
+    ///         *fptr.0 = 20;
+    ///     });
+    /// }
+    /// ```
+    ///
+    /// {{produces}}
+    ///
+    /// ### Explanation
+    ///
+    /// In the above example `fptr.0` is captured when feature `capture_disjoint_fields` is enabled.
+    /// The field is of type *mut i32 which doesn't implement Send, making the code invalid as the
+    /// field cannot be sent between thread safely.
+    pub DISJOINT_CAPTURE_MIGRATION,
     Allow,
-    "Drop reorder because of `capture_disjoint_fields`"
-
+    "Drop reorder and auto traits error because of `capture_disjoint_fields`"
 }
 
 declare_lint_pass!(UnusedDocComment => [UNUSED_DOC_COMMENTS]);
index e29af0532891f8dee55c7c2b26790fa7904eb4ef..7a34788de91a766a67a9c93c3cbce9c676eb2ca0 100644 (file)
@@ -13,4 +13,4 @@ libc = "0.2.73"
 
 [build-dependencies]
 build_helper = { path = "../../src/build_helper" }
-cc = "1.0.60"
+cc = "1.0.67"
index d74fef0045f511062eff23c98b2cece325811717..b27eef376c49e6f7a5e714d6512e4e41d3ee9758 100644 (file)
@@ -27,7 +27,7 @@
 use rustc_middle::mir::interpret::{AllocDecodingSession, AllocDecodingState};
 use rustc_middle::mir::{self, Body, Promoted};
 use rustc_middle::ty::codec::TyDecoder;
-use rustc_middle::ty::{self, Ty, TyCtxt};
+use rustc_middle::ty::{self, Ty, TyCtxt, Visibility};
 use rustc_serialize::{opaque, Decodable, Decoder};
 use rustc_session::Session;
 use rustc_span::hygiene::ExpnDataDecodeMode;
@@ -406,17 +406,17 @@ fn decode(decoder: &mut DecodeContext<'a, 'tcx>) -> Result<ExpnId, String> {
 
 impl<'a, 'tcx> Decodable<DecodeContext<'a, 'tcx>> for Span {
     fn decode(decoder: &mut DecodeContext<'a, 'tcx>) -> Result<Span, String> {
+        let ctxt = SyntaxContext::decode(decoder)?;
         let tag = u8::decode(decoder)?;
 
-        if tag == TAG_INVALID_SPAN {
-            return Ok(DUMMY_SP);
+        if tag == TAG_PARTIAL_SPAN {
+            return Ok(DUMMY_SP.with_ctxt(ctxt));
         }
 
         debug_assert!(tag == TAG_VALID_SPAN_LOCAL || tag == TAG_VALID_SPAN_FOREIGN);
 
         let lo = BytePos::decode(decoder)?;
         let len = BytePos::decode(decoder)?;
-        let ctxt = SyntaxContext::decode(decoder)?;
         let hi = lo + len;
 
         let sess = if let Some(sess) = decoder.sess {
@@ -716,30 +716,37 @@ fn get_span(&self, index: DefIndex, sess: &Session) -> Span {
             .decode((self, sess))
     }
 
-    fn load_proc_macro(&self, id: DefIndex, sess: &Session) -> SyntaxExtension {
-        let (name, kind, helper_attrs) = match *self.raw_proc_macro(id) {
+    fn load_proc_macro(&self, def_id: DefId, sess: &Session) -> SyntaxExtension {
+        let (name, kind, helper_attrs) = match *self.raw_proc_macro(def_id.index) {
             ProcMacro::CustomDerive { trait_name, attributes, client } => {
                 let helper_attrs =
                     attributes.iter().cloned().map(Symbol::intern).collect::<Vec<_>>();
                 (
                     trait_name,
-                    SyntaxExtensionKind::Derive(Box::new(ProcMacroDerive { client })),
+                    SyntaxExtensionKind::Derive(Box::new(ProcMacroDerive {
+                        client,
+                        krate: def_id.krate,
+                    })),
                     helper_attrs,
                 )
             }
-            ProcMacro::Attr { name, client } => {
-                (name, SyntaxExtensionKind::Attr(Box::new(AttrProcMacro { client })), Vec::new())
-            }
-            ProcMacro::Bang { name, client } => {
-                (name, SyntaxExtensionKind::Bang(Box::new(BangProcMacro { client })), Vec::new())
-            }
+            ProcMacro::Attr { name, client } => (
+                name,
+                SyntaxExtensionKind::Attr(Box::new(AttrProcMacro { client, krate: def_id.krate })),
+                Vec::new(),
+            ),
+            ProcMacro::Bang { name, client } => (
+                name,
+                SyntaxExtensionKind::Bang(Box::new(BangProcMacro { client, krate: def_id.krate })),
+                Vec::new(),
+            ),
         };
 
-        let attrs: Vec<_> = self.get_item_attrs(id, sess).collect();
+        let attrs: Vec<_> = self.get_item_attrs(def_id.index, sess).collect();
         SyntaxExtension::new(
             sess,
             kind,
-            self.get_span(id, sess),
+            self.get_span(def_id.index, sess),
             helper_attrs,
             self.root.edition,
             Symbol::intern(name),
@@ -1305,6 +1312,17 @@ fn get_struct_field_names(&self, id: DefIndex, sess: &Session) -> Vec<Spanned<Sy
             .collect()
     }
 
+    fn get_struct_field_visibilities(&self, id: DefIndex) -> Vec<Visibility> {
+        self.root
+            .tables
+            .children
+            .get(self, id)
+            .unwrap_or_else(Lazy::empty)
+            .decode(self)
+            .map(|field_index| self.get_visibility(field_index))
+            .collect()
+    }
+
     fn get_inherent_implementations_for_type(
         &self,
         tcx: TyCtxt<'tcx>,
@@ -1379,6 +1397,15 @@ fn get_native_libraries(&self, sess: &Session) -> Vec<NativeLib> {
         }
     }
 
+    fn get_proc_macro_quoted_span(&self, index: usize, sess: &Session) -> Span {
+        self.root
+            .tables
+            .proc_macro_quoted_spans
+            .get(self, index)
+            .unwrap_or_else(|| panic!("Missing proc macro quoted span: {:?}", index))
+            .decode((self, sess))
+    }
+
     fn get_foreign_modules(&self, tcx: TyCtxt<'tcx>) -> Lrc<FxHashMap<DefId, ForeignModule>> {
         if self.root.is_proc_macro_crate() {
             // Proc macro crates do not have any *target* foreign modules.
@@ -1635,9 +1662,11 @@ fn imported_source_files(&self, sess: &Session) -> &'a [ImportedSourceFile] {
             if let Some(virtual_dir) = virtual_rust_source_base_dir {
                 if let Some(real_dir) = &sess.opts.real_rust_source_base_dir {
                     if let rustc_span::FileName::Real(old_name) = name {
-                        if let rustc_span::RealFileName::Named(one_path) = old_name {
-                            if let Ok(rest) = one_path.strip_prefix(virtual_dir) {
-                                let virtual_name = one_path.clone();
+                        if let rustc_span::RealFileName::Remapped { local_path: _, virtual_name } =
+                            old_name
+                        {
+                            if let Ok(rest) = virtual_name.strip_prefix(virtual_dir) {
+                                let virtual_name = virtual_name.clone();
 
                                 // The std library crates are in
                                 // `$sysroot/lib/rustlib/src/rust/library`, whereas other crates
@@ -1673,8 +1702,8 @@ fn imported_source_files(&self, sess: &Session) -> &'a [ImportedSourceFile] {
                                     virtual_name.display(),
                                     new_path.display(),
                                 );
-                                let new_name = rustc_span::RealFileName::Devirtualized {
-                                    local_path: new_path,
+                                let new_name = rustc_span::RealFileName::Remapped {
+                                    local_path: Some(new_path),
                                     virtual_name,
                                 };
                                 *old_name = new_name;
@@ -1694,7 +1723,6 @@ fn imported_source_files(&self, sess: &Session) -> &'a [ImportedSourceFile] {
                     // containing the information we need.
                     let rustc_span::SourceFile {
                         mut name,
-                        name_was_remapped,
                         src_hash,
                         start_pos,
                         end_pos,
@@ -1706,11 +1734,34 @@ fn imported_source_files(&self, sess: &Session) -> &'a [ImportedSourceFile] {
                         ..
                     } = source_file_to_import;
 
+                    // If this file is under $sysroot/lib/rustlib/src/ but has not been remapped
+                    // during rust bootstrapping by `remap-debuginfo = true`, and the user
+                    // wish to simulate that behaviour by -Z simulate-remapped-rust-src-base,
+                    // then we change `name` to a similar state as if the rust was bootstrapped
+                    // with `remap-debuginfo = true`.
+                    // This is useful for testing so that tests about the effects of
+                    // `try_to_translate_virtual_to_real` don't have to worry about how the
+                    // compiler is bootstrapped.
+                    if let Some(virtual_dir) =
+                        &sess.opts.debugging_opts.simulate_remapped_rust_src_base
+                    {
+                        if let Some(real_dir) = &sess.opts.real_rust_source_base_dir {
+                            if let rustc_span::FileName::Real(ref mut old_name) = name {
+                                if let rustc_span::RealFileName::LocalPath(local) = old_name {
+                                    if let Ok(rest) = local.strip_prefix(real_dir) {
+                                        *old_name = rustc_span::RealFileName::Remapped {
+                                            local_path: None,
+                                            virtual_name: virtual_dir.join(rest),
+                                        };
+                                    }
+                                }
+                            }
+                        }
+                    }
+
                     // If this file's path has been remapped to `/rustc/$hash`,
                     // we might be able to reverse that (also see comments above,
                     // on `try_to_translate_virtual_to_real`).
-                    // FIXME(eddyb) we could check `name_was_remapped` here,
-                    // but in practice it seems to be always `false`.
                     try_to_translate_virtual_to_real(&mut name);
 
                     let source_length = (end_pos - start_pos).to_usize();
@@ -1735,7 +1786,6 @@ fn imported_source_files(&self, sess: &Session) -> &'a [ImportedSourceFile] {
 
                     let local_version = sess.source_map().new_imported_source_file(
                         name,
-                        name_was_remapped,
                         src_hash,
                         name_hash,
                         source_length,
index b11ad6c7ff86757450be57681c88ab9921076d7b..82ca634f2828ee6677002f87c88c8ddeedbf7c7f 100644 (file)
@@ -8,7 +8,7 @@
 use rustc_data_structures::stable_map::FxHashMap;
 use rustc_data_structures::svh::Svh;
 use rustc_hir as hir;
-use rustc_hir::def::DefKind;
+use rustc_hir::def::{CtorKind, DefKind};
 use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, CRATE_DEF_INDEX, LOCAL_CRATE};
 use rustc_hir::definitions::{DefKey, DefPath, DefPathHash};
 use rustc_middle::hir::exports::Export;
@@ -17,7 +17,7 @@
 use rustc_middle::middle::exported_symbols::ExportedSymbol;
 use rustc_middle::middle::stability::DeprecationEntry;
 use rustc_middle::ty::query::Providers;
-use rustc_middle::ty::{self, TyCtxt};
+use rustc_middle::ty::{self, TyCtxt, Visibility};
 use rustc_session::utils::NativeLibKind;
 use rustc_session::{CrateDisambiguator, Session};
 use rustc_span::source_map::{Span, Spanned};
@@ -392,6 +392,20 @@ pub fn struct_field_names_untracked(&self, def: DefId, sess: &Session) -> Vec<Sp
         self.get_crate_data(def.krate).get_struct_field_names(def.index, sess)
     }
 
+    pub fn struct_field_visibilities_untracked(&self, def: DefId) -> Vec<Visibility> {
+        self.get_crate_data(def.krate).get_struct_field_visibilities(def.index)
+    }
+
+    pub fn ctor_def_id_and_kind_untracked(&self, def: DefId) -> Option<(DefId, CtorKind)> {
+        self.get_crate_data(def.krate).get_ctor_def_id(def.index).map(|ctor_def_id| {
+            (ctor_def_id, self.get_crate_data(def.krate).get_ctor_kind(def.index))
+        })
+    }
+
+    pub fn visibility_untracked(&self, def: DefId) -> Visibility {
+        self.get_crate_data(def.krate).get_visibility(def.index)
+    }
+
     pub fn item_children_untracked(
         &self,
         def_id: DefId,
@@ -411,7 +425,7 @@ pub fn load_macro_untracked(&self, id: DefId, sess: &Session) -> LoadedMacro {
 
         let data = self.get_crate_data(id.krate);
         if data.root.is_proc_macro_crate() {
-            return LoadedMacro::ProcMacro(data.load_proc_macro(id.index, sess));
+            return LoadedMacro::ProcMacro(data.load_proc_macro(id, sess));
         }
 
         let span = data.get_span(id.index, sess);
@@ -461,6 +475,15 @@ pub fn module_expansion_untracked(&self, def_id: DefId, sess: &Session) -> ExpnI
     pub fn item_attrs(&self, def_id: DefId, sess: &Session) -> Vec<ast::Attribute> {
         self.get_crate_data(def_id.krate).get_item_attrs(def_id.index, sess).collect()
     }
+
+    pub fn get_proc_macro_quoted_span_untracked(
+        &self,
+        cnum: CrateNum,
+        id: usize,
+        sess: &Session,
+    ) -> Span {
+        self.get_crate_data(cnum).get_proc_macro_quoted_span(id, sess)
+    }
 }
 
 impl CrateStore for CStore {
index e8f02b8e66f0a9f03caaabd16d90d6c786fba389..29fcbffa0b95298f8bfecde67a3888b0474ad383 100644 (file)
 use rustc_middle::ty::{self, SymbolName, Ty, TyCtxt};
 use rustc_serialize::{opaque, Encodable, Encoder};
 use rustc_session::config::CrateType;
-use rustc_span::hygiene::{ExpnDataEncodeMode, HygieneEncodeContext, MacroKind};
 use rustc_span::symbol::{sym, Ident, Symbol};
 use rustc_span::{self, ExternalSource, FileName, SourceFile, Span, SyntaxContext};
+use rustc_span::{
+    hygiene::{ExpnDataEncodeMode, HygieneEncodeContext, MacroKind},
+    RealFileName,
+};
 use rustc_target::abi::VariantIdx;
 use std::hash::Hash;
 use std::num::NonZeroUsize;
@@ -184,11 +187,48 @@ fn encode(&self, s: &mut EncodeContext<'a, 'tcx>) -> opaque::EncodeResult {
 
 impl<'a, 'tcx> Encodable<EncodeContext<'a, 'tcx>> for Span {
     fn encode(&self, s: &mut EncodeContext<'a, 'tcx>) -> opaque::EncodeResult {
-        if *self == rustc_span::DUMMY_SP {
-            return TAG_INVALID_SPAN.encode(s);
+        let span = self.data();
+
+        // Don't serialize any `SyntaxContext`s from a proc-macro crate,
+        // since we don't load proc-macro dependencies during serialization.
+        // This means that any hygiene information from macros used *within*
+        // a proc-macro crate (e.g. invoking a macro that expands to a proc-macro
+        // definition) will be lost.
+        //
+        // This can show up in two ways:
+        //
+        // 1. Any hygiene information associated with identifier of
+        // a proc macro (e.g. `#[proc_macro] pub fn $name`) will be lost.
+        // Since proc-macros can only be invoked from a different crate,
+        // real code should never need to care about this.
+        //
+        // 2. Using `Span::def_site` or `Span::mixed_site` will not
+        // include any hygiene information associated with the definition
+        // site. This means that a proc-macro cannot emit a `$crate`
+        // identifier which resolves to one of its dependencies,
+        // which also should never come up in practice.
+        //
+        // Additionally, this affects `Span::parent`, and any other
+        // span inspection APIs that would otherwise allow traversing
+        // the `SyntaxContexts` associated with a span.
+        //
+        // None of these user-visible effects should result in any
+        // cross-crate inconsistencies (getting one behavior in the same
+        // crate, and a different behavior in another crate) due to the
+        // limited surface that proc-macros can expose.
+        //
+        // IMPORTANT: If this is ever changed, be sure to update
+        // `rustc_span::hygiene::raw_encode_expn_id` to handle
+        // encoding `ExpnData` for proc-macro crates.
+        if s.is_proc_macro {
+            SyntaxContext::root().encode(s)?;
+        } else {
+            span.ctxt.encode(s)?;
         }
 
-        let span = self.data();
+        if self.is_dummy() {
+            return TAG_PARTIAL_SPAN.encode(s);
+        }
 
         // The Span infrastructure should make sure that this invariant holds:
         debug_assert!(span.lo <= span.hi);
@@ -203,7 +243,7 @@ fn encode(&self, s: &mut EncodeContext<'a, 'tcx>) -> opaque::EncodeResult {
         if !s.source_file_cache.0.contains(span.hi) {
             // Unfortunately, macro expansion still sometimes generates Spans
             // that malformed in this way.
-            return TAG_INVALID_SPAN.encode(s);
+            return TAG_PARTIAL_SPAN.encode(s);
         }
 
         let source_files = s.required_source_files.as_mut().expect("Already encoded SourceMap!");
@@ -259,43 +299,6 @@ fn encode(&self, s: &mut EncodeContext<'a, 'tcx>) -> opaque::EncodeResult {
         let len = hi - lo;
         len.encode(s)?;
 
-        // Don't serialize any `SyntaxContext`s from a proc-macro crate,
-        // since we don't load proc-macro dependencies during serialization.
-        // This means that any hygiene information from macros used *within*
-        // a proc-macro crate (e.g. invoking a macro that expands to a proc-macro
-        // definition) will be lost.
-        //
-        // This can show up in two ways:
-        //
-        // 1. Any hygiene information associated with identifier of
-        // a proc macro (e.g. `#[proc_macro] pub fn $name`) will be lost.
-        // Since proc-macros can only be invoked from a different crate,
-        // real code should never need to care about this.
-        //
-        // 2. Using `Span::def_site` or `Span::mixed_site` will not
-        // include any hygiene information associated with the definition
-        // site. This means that a proc-macro cannot emit a `$crate`
-        // identifier which resolves to one of its dependencies,
-        // which also should never come up in practice.
-        //
-        // Additionally, this affects `Span::parent`, and any other
-        // span inspection APIs that would otherwise allow traversing
-        // the `SyntaxContexts` associated with a span.
-        //
-        // None of these user-visible effects should result in any
-        // cross-crate inconsistencies (getting one behavior in the same
-        // crate, and a different behavior in another crate) due to the
-        // limited surface that proc-macros can expose.
-        //
-        // IMPORTANT: If this is ever changed, be sure to update
-        // `rustc_span::hygiene::raw_encode_expn_id` to handle
-        // encoding `ExpnData` for proc-macro crates.
-        if s.is_proc_macro {
-            SyntaxContext::root().encode(s)?;
-        } else {
-            span.ctxt.encode(s)?;
-        }
-
         if tag == TAG_VALID_SPAN_FOREIGN {
             // This needs to be two lines to avoid holding the `s.source_file_cache`
             // while calling `cnum.encode(s)`
@@ -466,7 +469,6 @@ fn encode_source_map(&mut self) -> Lazy<[rustc_span::SourceFile]> {
         let source_map = self.tcx.sess.source_map();
         let all_source_files = source_map.files();
 
-        let (working_dir, _cwd_remapped) = self.tcx.sess.working_dir.clone();
         // By replacing the `Option` with `None`, we ensure that we can't
         // accidentally serialize any more `Span`s after the source map encoding
         // is done.
@@ -485,18 +487,41 @@ fn encode_source_map(&mut self) -> Lazy<[rustc_span::SourceFile]> {
             })
             .map(|(_, source_file)| {
                 let mut adapted = match source_file.name {
-                    // This path of this SourceFile has been modified by
-                    // path-remapping, so we use it verbatim (and avoid
-                    // cloning the whole map in the process).
-                    _ if source_file.name_was_remapped => source_file.clone(),
-
-                    // Otherwise expand all paths to absolute paths because
-                    // any relative paths are potentially relative to a
-                    // wrong directory.
-                    FileName::Real(ref name) => {
-                        let name = name.stable_name();
+                    FileName::Real(ref realname) => {
                         let mut adapted = (**source_file).clone();
-                        adapted.name = Path::new(&working_dir).join(name).into();
+                        adapted.name = FileName::Real(match realname {
+                            RealFileName::LocalPath(path_to_file) => {
+                                // Prepend path of working directory onto potentially
+                                // relative paths, because they could become relative
+                                // to a wrong directory.
+                                let working_dir = &self.tcx.sess.working_dir;
+                                match working_dir {
+                                    RealFileName::LocalPath(absolute) => {
+                                        // If working_dir has not been remapped, then we emit a
+                                        // LocalPath variant as it's likely to be a valid path
+                                        RealFileName::LocalPath(
+                                            Path::new(absolute).join(path_to_file),
+                                        )
+                                    }
+                                    RealFileName::Remapped { local_path: _, virtual_name } => {
+                                        // If working_dir has been remapped, then we emit
+                                        // Remapped variant as the expanded path won't be valid
+                                        RealFileName::Remapped {
+                                            local_path: None,
+                                            virtual_name: Path::new(virtual_name)
+                                                .join(path_to_file),
+                                        }
+                                    }
+                                }
+                            }
+                            RealFileName::Remapped { local_path: _, virtual_name } => {
+                                RealFileName::Remapped {
+                                    // We do not want any local path to be exported into metadata
+                                    local_path: None,
+                                    virtual_name: virtual_name.clone(),
+                                }
+                            }
+                        });
                         adapted.name_hash = {
                             let mut hasher: StableHasher = StableHasher::new();
                             adapted.name.hash(&mut hasher);
@@ -1579,6 +1604,11 @@ fn encode_proc_macros(&mut self) -> Option<ProcMacroData> {
             let proc_macro_decls_static = tcx.proc_macro_decls_static(LOCAL_CRATE).unwrap().index;
             let stability = tcx.lookup_stability(DefId::local(CRATE_DEF_INDEX)).copied();
             let macros = self.lazy(hir.krate().proc_macros.iter().map(|p| p.owner.local_def_index));
+            let spans = self.tcx.sess.parse_sess.proc_macro_quoted_spans();
+            for (i, span) in spans.into_iter().enumerate() {
+                let span = self.lazy(span);
+                self.tables.proc_macro_quoted_spans.set(i, span);
+            }
 
             record!(self.tables.def_kind[LOCAL_CRATE.as_def_id()] <- DefKind::Mod);
             record!(self.tables.span[LOCAL_CRATE.as_def_id()] <- tcx.def_span(LOCAL_CRATE.as_def_id()));
index 9f665d5daaa032c9b1aabf4c5eca708c4eda1521..1fb68fd5fc309f438f240b1110a7e7ca2147eb77 100644 (file)
@@ -258,15 +258,15 @@ macro_rules! Lazy {
 
 /// Define `LazyTables` and `TableBuilders` at the same time.
 macro_rules! define_tables {
-    ($($name:ident: Table<DefIndex, $T:ty>),+ $(,)?) => {
+    ($($name:ident: Table<$IDX:ty, $T:ty>),+ $(,)?) => {
         #[derive(MetadataEncodable, MetadataDecodable)]
         crate struct LazyTables<'tcx> {
-            $($name: Lazy!(Table<DefIndex, $T>)),+
+            $($name: Lazy!(Table<$IDX, $T>)),+
         }
 
         #[derive(Default)]
         struct TableBuilders<'tcx> {
-            $($name: TableBuilder<DefIndex, $T>),+
+            $($name: TableBuilder<$IDX, $T>),+
         }
 
         impl TableBuilders<'tcx> {
@@ -315,6 +315,7 @@ fn encode(&self, buf: &mut Encoder) -> LazyTables<'tcx> {
     // definitions from any given crate.
     def_keys: Table<DefIndex, Lazy<DefKey>>,
     def_path_hashes: Table<DefIndex, Lazy<DefPathHash>>,
+    proc_macro_quoted_spans: Table<usize, Lazy<Span>>,
 }
 
 #[derive(Copy, Clone, MetadataEncodable, MetadataDecodable)]
@@ -450,4 +451,4 @@ struct GeneratorData<'tcx> {
 // Tags used for encoding Spans:
 const TAG_VALID_SPAN_LOCAL: u8 = 0;
 const TAG_VALID_SPAN_FOREIGN: u8 = 1;
-const TAG_INVALID_SPAN: u8 = 2;
+const TAG_PARTIAL_SPAN: u8 = 2;
index 719bbf04c95bd434bd525e6e1d8b6b64dbea0b9b..342cc9a7397b7cbb44231448b883b3f2fbba2787 100644 (file)
@@ -197,7 +197,7 @@ fn insert_with_hash(&mut self, span: Span, hir_id: HirId, node: Node<'hir>, hash
                     span,
                     "inconsistent DepNode at `{:?}` for `{}`: \
                      current_dep_node_owner={} ({:?}), hir_id.owner={} ({:?})",
-                    self.source_map.span_to_string(span),
+                    self.source_map.span_to_diagnostic_string(span),
                     node_str,
                     self.definitions
                         .def_path(self.current_dep_node_owner)
index b93b25d6b5c9afe610eb4a311a7f6b953091f2cd..2d8f661ef59e92d233000ff1dd2358221fb242c1 100644 (file)
@@ -61,8 +61,6 @@ fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHas
         let SourceFile {
             name: _, // We hash the smaller name_hash instead of this
             name_hash,
-            name_was_remapped,
-            unmapped_path: _,
             cnum,
             // Do not hash the source as it is not encoded
             src: _,
@@ -77,7 +75,6 @@ fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHas
         } = *self;
 
         (name_hash as u64).hash_stable(hcx, hasher);
-        name_was_remapped.hash_stable(hcx, hasher);
 
         src_hash.hash_stable(hcx, hasher);
 
index 7adaf54fa2374418e1a8fff081919a6546af3a8d..38d0793a6825fd9c4e545c61d1ebaa240fa3e4d8 100644 (file)
@@ -389,7 +389,7 @@ pub fn in_external_macro(sess: &Session, span: Span) -> bool {
             false
         }
         ExpnKind::AstPass(_) | ExpnKind::Desugaring(_) => true, // well, it's "external"
-        ExpnKind::Macro(MacroKind::Bang, _) => {
+        ExpnKind::Macro { kind: MacroKind::Bang, name: _, proc_macro: _ } => {
             // Dummy span for the `def_site` means it's an external macro.
             expn_data.def_site.is_dummy() || sess.source_map().is_imported(expn_data.def_site)
         }
index aa6488b329eba76cb14311993556a37c8102d42e..2665ea8d7fd73a48599095131492ea813a7c8329 100644 (file)
@@ -49,6 +49,20 @@ pub enum Region {
     Free(DefId, /* lifetime decl */ DefId),
 }
 
+/// This is used in diagnostics to improve suggestions for missing generic arguments.
+/// It gives information on the type of lifetimes that are in scope for a particular `PathSegment`,
+/// so that we can e.g. suggest elided-lifetimes-in-paths of the form <'_, '_> e.g.
+#[derive(Clone, PartialEq, Eq, Hash, TyEncodable, TyDecodable, Debug, HashStable)]
+pub enum LifetimeScopeForPath {
+    // Contains all lifetime names that are in scope and could possibly be used in generics
+    // arguments of path.
+    NonElided(Vec<String>),
+
+    // Information that allows us to suggest args of the form `<'_>` in case
+    // no generic arguments were provided for a path.
+    Elided,
+}
+
 /// A set containing, at most, one known element.
 /// If two distinct values are inserted into a set, then it
 /// becomes `Many`, which can be used to detect ambiguities.
index fc9a2970e00aeb41f7ebe215ab21eb93ea42e586..aa0f18846d1540c981015f2de000021c19b37d34 100644 (file)
@@ -281,7 +281,13 @@ impl<'tcx> TyCtxt<'tcx> {
     /// If `id` is `Some(_)`, this function will also check if the item at `def_id` has been
     /// deprecated. If the item is indeed deprecated, we will emit a deprecation lint attached to
     /// `id`.
-    pub fn eval_stability(self, def_id: DefId, id: Option<HirId>, span: Span) -> EvalResult {
+    pub fn eval_stability(
+        self,
+        def_id: DefId,
+        id: Option<HirId>,
+        span: Span,
+        method_span: Option<Span>,
+    ) -> EvalResult {
         // Deprecated attributes apply in-crate and cross-crate.
         if let Some(id) = id {
             if let Some(depr_entry) = self.lookup_deprecation_entry(def_id) {
@@ -300,6 +306,7 @@ pub fn eval_stability(self, def_id: DefId, id: Option<HirId>, span: Span) -> Eva
                     let path = &with_no_trimmed_paths(|| self.def_path_str(def_id));
                     let kind = self.def_kind(def_id).descr(def_id);
                     let (message, lint) = deprecation_message(&depr_entry.attr, kind, path);
+                    let span = method_span.unwrap_or(span);
                     late_report_deprecation(
                         self,
                         &message,
@@ -382,8 +389,14 @@ pub fn eval_stability(self, def_id: DefId, id: Option<HirId>, span: Span) -> Eva
     ///
     /// This function will also check if the item is deprecated.
     /// If so, and `id` is not `None`, a deprecated lint attached to `id` will be emitted.
-    pub fn check_stability(self, def_id: DefId, id: Option<HirId>, span: Span) {
-        self.check_optional_stability(def_id, id, span, |span, def_id| {
+    pub fn check_stability(
+        self,
+        def_id: DefId,
+        id: Option<HirId>,
+        span: Span,
+        method_span: Option<Span>,
+    ) {
+        self.check_optional_stability(def_id, id, span, method_span, |span, def_id| {
             // The API could be uncallable for other reasons, for example when a private module
             // was referenced.
             self.sess.delay_span_bug(span, &format!("encountered unmarked API: {:?}", def_id));
@@ -399,6 +412,7 @@ pub fn check_optional_stability(
         def_id: DefId,
         id: Option<HirId>,
         span: Span,
+        method_span: Option<Span>,
         unmarked: impl FnOnce(Span, DefId),
     ) {
         let soft_handler = |lint, span, msg: &_| {
@@ -406,7 +420,7 @@ pub fn check_optional_stability(
                 lint.build(msg).emit()
             })
         };
-        match self.eval_stability(def_id, id, span) {
+        match self.eval_stability(def_id, id, span, method_span) {
             EvalResult::Allow => {}
             EvalResult::Deny { feature, reason, issue, is_soft } => {
                 report_unstable(self.sess, feature, reason, issue, is_soft, span, soft_handler)
index de0c4f2e30e8b0e12ac92e6a3f0d114c9f1dcd81..1cc7f235d7d21dec958528c4f1fa3a6b4689ecb6 100644 (file)
@@ -2374,7 +2374,10 @@ fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
                                 )
                             } else {
                                 let span = tcx.hir().span(hir_id);
-                                format!("[closure@{}]", tcx.sess.source_map().span_to_string(span))
+                                format!(
+                                    "[closure@{}]",
+                                    tcx.sess.source_map().span_to_diagnostic_string(span)
+                                )
                             };
                             let mut struct_fmt = fmt.debug_struct(&name);
 
index 3ffc3641b62aad465b8cd754613ce9c3564f060e..b60d70039458a4ff1207dfeb9851254780b32f61 100644 (file)
 
     /// 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) }
+    query coverageinfo(key: ty::InstanceDef<'tcx>) -> mir::CoverageInfo {
+        desc { |tcx| "retrieving coverage info from MIR for `{}`", tcx.def_path_str(key.def_id()) }
         storage(ArenaCacheSelector<'tcx>)
-        cache_on_disk_if { key.is_local() }
     }
 
     /// Returns the name of the file that contains the function body, if instrumented for coverage.
         }
     }
 
+    /// Unsafety-check this `LocalDefId` with THIR unsafeck. This should be
+    /// used with `-Zthir-unsafeck`.
+    query thir_check_unsafety(key: LocalDefId) {
+        desc { |tcx| "unsafety-checking `{}`", tcx.def_path_str(key.to_def_id()) }
+        cache_on_disk_if { true }
+    }
+    query thir_check_unsafety_for_const_arg(key: (LocalDefId, DefId)) {
+        desc {
+            |tcx| "unsafety-checking the const argument `{}`",
+            tcx.def_path_str(key.0.to_def_id())
+        }
+    }
+
     /// HACK: when evaluated, this reports a "unsafe derive on repr(packed)" error.
     ///
     /// Unsafety checking is executed for each method separately, but we only want
     query needs_drop_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
         desc { "computing whether `{}` needs drop", env.value }
     }
+    /// Query backing `TyS::has_significant_drop_raw`.
+    query has_significant_drop_raw(env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool {
+        desc { "computing whether `{}` has a significant drop", env.value }
+    }
 
     /// Query backing `TyS::is_structural_eq_shallow`.
     ///
         cache_on_disk_if { true }
     }
 
+    /// A list of types where the ADT requires drop if and only if any of those types
+    /// has significant drop. A type marked with the attribute `rustc_insignificant_dtor`
+    /// is considered to not be significant. A drop is significant if it is implemented
+    /// by the user or does anything that will have any observable behavior (other than
+    /// freeing up memory). If the ADT is known to have a significant destructor then
+    /// `Err(AlwaysRequiresDrop)` is returned.
+    query adt_significant_drop_tys(def_id: DefId) -> Result<&'tcx ty::List<Ty<'tcx>>, AlwaysRequiresDrop> {
+        desc { |tcx| "computing when `{}` has a significant destructor", tcx.def_path_str(def_id) }
+        cache_on_disk_if { false }
+    }
+
     query layout_raw(
         env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>
     ) -> Result<&'tcx rustc_target::abi::Layout, ty::layout::LayoutError<'tcx>> {
         desc { "looking up late bound vars" }
     }
 
+    query lifetime_scope_map(_: LocalDefId) -> Option<FxHashMap<ItemLocalId, LifetimeScopeForPath>> {
+        desc { "finds the lifetime scope for an HirId of a PathSegment" }
+    }
+
     query visibility(def_id: DefId) -> ty::Visibility {
         eval_always
         desc { |tcx| "computing visibility of `{}`", tcx.def_path_str(def_id) }
index 10f7cc87c7c7c8145a3ef4d4662f933c4727acd5..7c4229b6db23ed1325c53551c313c808030f301f 100644 (file)
@@ -9,7 +9,7 @@
 use crate::lint::{struct_lint_level, LintDiagnosticBuilder, LintLevelSource};
 use crate::middle;
 use crate::middle::cstore::{CrateStoreDyn, EncodedMetadata};
-use crate::middle::resolve_lifetime::{self, ObjectLifetimeDefault};
+use crate::middle::resolve_lifetime::{self, LifetimeScopeForPath, ObjectLifetimeDefault};
 use crate::middle::stability;
 use crate::mir::interpret::{self, Allocation, ConstValue, Scalar};
 use crate::mir::{Body, Field, Local, Place, PlaceElem, ProjectionKind, Promoted};
@@ -973,7 +973,7 @@ pub struct GlobalCtxt<'tcx> {
     export_map: ExportMap<LocalDefId>,
 
     pub(crate) untracked_crate: &'tcx hir::Crate<'tcx>,
-    pub(crate) definitions: &'tcx Definitions,
+    pub(crate) definitions: Definitions,
 
     /// This provides access to the incremental compilation on-disk cache for query results.
     /// Do not access this directly. It is only meant to be used by
@@ -1130,7 +1130,6 @@ pub fn create_global_ctxt(
         arena: &'tcx WorkerLocal<Arena<'tcx>>,
         resolutions: ty::ResolverOutputs,
         krate: &'tcx hir::Crate<'tcx>,
-        definitions: &'tcx Definitions,
         dep_graph: DepGraph,
         on_disk_cache: Option<query::OnDiskCache<'tcx>>,
         queries: &'tcx dyn query::QueryEngine<'tcx>,
@@ -1172,7 +1171,7 @@ pub fn create_global_ctxt(
             glob_map: resolutions.glob_map,
             extern_prelude: resolutions.extern_prelude,
             untracked_crate: krate,
-            definitions,
+            definitions: resolutions.definitions,
             on_disk_cache,
             queries,
             query_caches: query::QueryCaches::default(),
@@ -1329,14 +1328,14 @@ pub fn cstore_as_any(self) -> &'tcx dyn Any {
     pub fn create_stable_hashing_context(self) -> StableHashingContext<'tcx> {
         let krate = self.gcx.untracked_crate;
 
-        StableHashingContext::new(self.sess, krate, self.definitions, &*self.cstore)
+        StableHashingContext::new(self.sess, krate, &self.definitions, &*self.cstore)
     }
 
     #[inline(always)]
     pub fn create_no_span_stable_hashing_context(self) -> StableHashingContext<'tcx> {
         let krate = self.gcx.untracked_crate;
 
-        StableHashingContext::ignore_spans(self.sess, krate, self.definitions, &*self.cstore)
+        StableHashingContext::ignore_spans(self.sess, krate, &self.definitions, &*self.cstore)
     }
 
     pub fn serialize_query_result_cache(self, encoder: &mut FileEncoder) -> FileEncodeResult {
@@ -2686,6 +2685,10 @@ pub fn late_bound_vars(self, id: HirId) -> &'tcx List<ty::BoundVariableKind> {
                 .iter(),
         )
     }
+
+    pub fn lifetime_scope(self, id: HirId) -> Option<LifetimeScopeForPath> {
+        self.lifetime_scope_map(id.owner).and_then(|mut map| map.remove(&id.local_id))
+    }
 }
 
 impl TyCtxtAt<'tcx> {
index 008e6d015e879e2068c78cc80dbbe19bf1168b6e..96aae3bd70cd21710ac81b3f93b30b01ee674cc0 100644 (file)
@@ -159,10 +159,23 @@ fn report_maybe_different(
                 )
             }),
             IntMismatch(ref values) => {
-                write!(f, "expected `{:?}`, found `{:?}`", values.expected, values.found)
+                let expected = match values.expected {
+                    ty::IntVarValue::IntType(ty) => ty.name_str(),
+                    ty::IntVarValue::UintType(ty) => ty.name_str(),
+                };
+                let found = match values.found {
+                    ty::IntVarValue::IntType(ty) => ty.name_str(),
+                    ty::IntVarValue::UintType(ty) => ty.name_str(),
+                };
+                write!(f, "expected `{}`, found `{}`", expected, found)
             }
             FloatMismatch(ref values) => {
-                write!(f, "expected `{:?}`, found `{:?}`", values.expected, values.found)
+                write!(
+                    f,
+                    "expected `{}`, found `{}`",
+                    values.expected.name_str(),
+                    values.found.name_str()
+                )
             }
             VariadicMismatch(ref values) => write!(
                 f,
index 174ec481ae93d95b0522c84c4186972be915703b..cfb9cfd86f978ad4efb99d501216cd3b70ef1e66 100644 (file)
@@ -667,7 +667,12 @@ fn pretty_print_type(mut self, ty: Ty<'tcx>) -> Result<Self::Type, Self::Error>
                     if let Some(did) = did.as_local() {
                         let hir_id = self.tcx().hir().local_def_id_to_hir_id(did);
                         let span = self.tcx().hir().span(hir_id);
-                        p!(write("@{}", self.tcx().sess.source_map().span_to_string(span)));
+                        p!(write(
+                            "@{}",
+                            // This may end up in stderr diagnostics but it may also be emitted
+                            // into MIR. Hence we use the remapped path if available
+                            self.tcx().sess.source_map().span_to_embeddable_string(span)
+                        ));
                     } else {
                         p!(write("@"), print_def_path(did, substs));
                     }
@@ -702,7 +707,12 @@ fn pretty_print_type(mut self, ty: Ty<'tcx>) -> Result<Self::Type, Self::Error>
                             p!("@", print_def_path(did.to_def_id(), substs));
                         } else {
                             let span = self.tcx().hir().span(hir_id);
-                            p!(write("@{}", self.tcx().sess.source_map().span_to_string(span)));
+                            p!(write(
+                                "@{}",
+                                // This may end up in stderr diagnostics but it may also be emitted
+                                // into MIR. Hence we use the remapped path if available
+                                self.tcx().sess.source_map().span_to_embeddable_string(span)
+                            ));
                         }
                     } else {
                         p!(write("@"), print_def_path(did, substs));
@@ -1407,7 +1417,13 @@ fn print_def_path(
                 if !self.empty_path {
                     write!(self, "::")?;
                 }
-                write!(self, "<impl at {}>", self.tcx.sess.source_map().span_to_string(span))?;
+                write!(
+                    self,
+                    "<impl at {}>",
+                    // This may end up in stderr diagnostics but it may also be emitted
+                    // into MIR. Hence we use the remapped path if available
+                    self.tcx.sess.source_map().span_to_embeddable_string(span)
+                )?;
                 self.empty_path = false;
 
                 return Ok(self);
index 068f81486118a7098ce673adad17c8383f23a391..3c772a14647c87d0889825d3220fa6b56bd343e1 100644 (file)
@@ -9,7 +9,9 @@
 use crate::middle::lib_features::LibFeatures;
 use crate::middle::privacy::AccessLevels;
 use crate::middle::region;
-use crate::middle::resolve_lifetime::{ObjectLifetimeDefault, Region, ResolveLifetimes};
+use crate::middle::resolve_lifetime::{
+    LifetimeScopeForPath, ObjectLifetimeDefault, Region, ResolveLifetimes,
+};
 use crate::middle::stability::{self, DeprecationEntry};
 use crate::mir;
 use crate::mir::interpret::GlobalId;
index 43b775f8083929a3f8cdc9a834bcd88f4c654b61..f220d83b0c7b24d0a16d11f358e167a5259c1f02 100644 (file)
@@ -10,8 +10,7 @@
 use rustc_data_structures::unhash::UnhashMap;
 use rustc_errors::Diagnostic;
 use rustc_hir::def_id::{CrateNum, DefId, DefIndex, LocalDefId, LOCAL_CRATE};
-use rustc_hir::definitions::DefPathHash;
-use rustc_hir::definitions::Definitions;
+use rustc_hir::definitions::{DefPathHash, DefPathTable};
 use rustc_index::vec::{Idx, IndexVec};
 use rustc_query_system::dep_graph::DepContext;
 use rustc_query_system::query::QueryContext;
@@ -167,22 +166,13 @@ fn to_usize(self) -> usize {
     pub index: u32,
 }
 
-fn make_local_def_path_hash_map(definitions: &Definitions) -> UnhashMap<DefPathHash, LocalDefId> {
-    UnhashMap::from_iter(
-        definitions
-            .def_path_table()
-            .all_def_path_hashes_and_def_ids(LOCAL_CRATE)
-            .map(|(hash, def_id)| (hash, def_id.as_local().unwrap())),
-    )
-}
-
 impl<'sess> OnDiskCache<'sess> {
     /// Creates a new `OnDiskCache` instance from the serialized data in `data`.
     pub fn new(
         sess: &'sess Session,
         data: Vec<u8>,
         start_pos: usize,
-        definitions: &Definitions,
+        def_path_table: &DefPathTable,
     ) -> Self {
         debug_assert!(sess.opts.incremental.is_some());
 
@@ -220,7 +210,11 @@ pub fn new(
             hygiene_context: Default::default(),
             foreign_def_path_hashes: footer.foreign_def_path_hashes,
             latest_foreign_def_path_hashes: Default::default(),
-            local_def_path_hash_to_def_id: make_local_def_path_hash_map(definitions),
+            local_def_path_hash_to_def_id: UnhashMap::from_iter(
+                def_path_table
+                    .all_def_path_hashes_and_def_ids(LOCAL_CRATE)
+                    .map(|(hash, def_id)| (hash, def_id.as_local().unwrap())),
+            ),
             def_path_hash_to_def_id_cache: Default::default(),
         }
     }
index e365928c15f918c6e28abcced78c98211a5ca3a7..7bf69b9e637e9a41334728e7c2373e1d7aacca45 100644 (file)
@@ -791,6 +791,39 @@ pub fn needs_drop(&'tcx self, tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>)
         }
     }
 
+    /// Checks if `ty` has has a significant drop.
+    ///
+    /// Note that this method can return false even if `ty` has a destructor
+    /// attached; even if that is the case then the adt has been marked with
+    /// the attribute `rustc_insignificant_dtor`.
+    ///
+    /// Note that this method is used to check for change in drop order for
+    /// 2229 drop reorder migration analysis.
+    #[inline]
+    pub fn has_significant_drop(
+        &'tcx self,
+        tcx: TyCtxt<'tcx>,
+        param_env: ty::ParamEnv<'tcx>,
+    ) -> bool {
+        // Avoid querying in simple cases.
+        match needs_drop_components(self, &tcx.data_layout) {
+            Err(AlwaysRequiresDrop) => true,
+            Ok(components) => {
+                let query_ty = match *components {
+                    [] => return false,
+                    // If we've got a single component, call the query with that
+                    // to increase the chance that we hit the query cache.
+                    [component_ty] => component_ty,
+                    _ => self,
+                };
+                // This doesn't depend on regions, so try to minimize distinct
+                // query keys used.
+                let erased = tcx.normalize_erasing_regions(param_env, query_ty);
+                tcx.has_significant_drop_raw(param_env.and(erased))
+            }
+        }
+    }
+
     /// Returns `true` if equality for this type is both reflexive and structural.
     ///
     /// Reflexive equality for a type is indicated by an `Eq` impl for that type.
index 88122777d2e67e2d32e9e939594b855f0d488dba..1e2714a2c1b2b9f00b1e07f85740a9f0c7909ea6 100644 (file)
@@ -6,7 +6,7 @@
 use rustc_middle::ty::{self, Ty, TyCtxt};
 use rustc_middle::{
     hir::place::PlaceBase,
-    mir::{self, ClearCrossCrate, Local, LocalDecl, LocalInfo, Location},
+    mir::{self, ClearCrossCrate, Local, LocalDecl, LocalInfo, LocalKind, Location},
 };
 use rustc_span::source_map::DesugaringKind;
 use rustc_span::symbol::{kw, Symbol};
@@ -424,15 +424,28 @@ pub(crate) fn report_mutability_error(
 
                         match label {
                             Some((true, err_help_span, suggested_code)) => {
-                                err.span_suggestion(
-                                    err_help_span,
-                                    &format!(
-                                        "consider changing this to be a mutable {}",
-                                        pointer_desc
-                                    ),
-                                    suggested_code,
-                                    Applicability::MachineApplicable,
-                                );
+                                let (is_trait_sig, local_trait) = self.is_error_in_trait(local);
+                                if !is_trait_sig {
+                                    err.span_suggestion(
+                                        err_help_span,
+                                        &format!(
+                                            "consider changing this to be a mutable {}",
+                                            pointer_desc
+                                        ),
+                                        suggested_code,
+                                        Applicability::MachineApplicable,
+                                    );
+                                } else if let Some(x) = local_trait {
+                                    err.span_suggestion(
+                                        x,
+                                        &format!(
+                                            "consider changing that to be a mutable {}",
+                                            pointer_desc
+                                        ),
+                                        suggested_code,
+                                        Applicability::MachineApplicable,
+                                    );
+                                }
                             }
                             Some((false, err_label_span, message)) => {
                                 err.span_label(err_label_span, &message);
@@ -503,6 +516,65 @@ pub(crate) fn report_mutability_error(
         err.buffer(&mut self.errors_buffer);
     }
 
+    /// User cannot make signature of a trait mutable without changing the
+    /// trait. So we find if this error belongs to a trait and if so we move
+    /// suggestion to the trait or disable it if it is out of scope of this crate
+    fn is_error_in_trait(&self, local: Local) -> (bool, Option<Span>) {
+        if self.body.local_kind(local) != LocalKind::Arg {
+            return (false, None);
+        }
+        let hir_map = self.infcx.tcx.hir();
+        let my_def = self.body.source.def_id();
+        let my_hir = hir_map.local_def_id_to_hir_id(my_def.as_local().unwrap());
+        let td = if let Some(a) =
+            self.infcx.tcx.impl_of_method(my_def).and_then(|x| self.infcx.tcx.trait_id_of_impl(x))
+        {
+            a
+        } else {
+            return (false, None);
+        };
+        (
+            true,
+            td.as_local().and_then(|tld| {
+                let h = hir_map.local_def_id_to_hir_id(tld);
+                match hir_map.find(h) {
+                    Some(Node::Item(hir::Item {
+                        kind: hir::ItemKind::Trait(_, _, _, _, items),
+                        ..
+                    })) => {
+                        let mut f_in_trait_opt = None;
+                        for hir::TraitItemRef { id: fi, kind: k, .. } in *items {
+                            let hi = fi.hir_id();
+                            if !matches!(k, hir::AssocItemKind::Fn { .. }) {
+                                continue;
+                            }
+                            if hir_map.name(hi) != hir_map.name(my_hir) {
+                                continue;
+                            }
+                            f_in_trait_opt = Some(hi);
+                            break;
+                        }
+                        f_in_trait_opt.and_then(|f_in_trait| match hir_map.find(f_in_trait) {
+                            Some(Node::TraitItem(hir::TraitItem {
+                                kind:
+                                    hir::TraitItemKind::Fn(
+                                        hir::FnSig { decl: hir::FnDecl { inputs, .. }, .. },
+                                        _,
+                                    ),
+                                ..
+                            })) => {
+                                let hir::Ty { span, .. } = inputs[local.index() - 1];
+                                Some(span)
+                            }
+                            _ => None,
+                        })
+                    }
+                    _ => None,
+                }
+            }),
+        )
+    }
+
     // point to span of upvar making closure call require mutable borrow
     fn show_mutating_upvar(
         &self,
index 86d9db294bf713d52e3b9a16eaa825e3eda1afba..5892ef37ebacb56df38b1306bfae5f16a7bc3eed 100644 (file)
@@ -76,7 +76,9 @@ fn for_each_constraint(
         for constraint in &constraints {
             let OutlivesConstraint { sup, sub, locations, category } = constraint;
             let (name, arg) = match locations {
-                Locations::All(span) => ("All", tcx.sess.source_map().span_to_string(*span)),
+                Locations::All(span) => {
+                    ("All", tcx.sess.source_map().span_to_embeddable_string(*span))
+                }
                 Locations::Single(loc) => ("Single", format!("{:?}", loc)),
             };
             with_msg(&format!("{:?}: {:?} due to {:?} at {}({})", sup, sub, category, name, arg))?;
index 994b403abf3bca3240b55d624c9c25fd3fa43f8c..1bfbb843114da3ea6c4ec545fbdd1f8e15e1850c 100644 (file)
@@ -137,10 +137,7 @@ fn move_path_for(&mut self, place: Place<'tcx>) -> Result<MovePathIndex, MoveErr
                         self.loc,
                         InteriorOfSliceOrArray {
                             ty: place_ty,
-                            is_index: match elem {
-                                ProjectionElem::Index(..) => true,
-                                _ => false,
-                            },
+                            is_index: matches!(elem, ProjectionElem::Index(..)),
                         },
                     ));
                 }
index 2d9e6df0ab86073729c3d9892369191761cc4cc9..848b44d13aadf7b7101aa80add0900333daf7fe0 100644 (file)
@@ -7,7 +7,6 @@
 use rustc_middle::ty::adjustment::PointerCast;
 use rustc_middle::ty::layout::{IntegerExt, TyAndLayout};
 use rustc_middle::ty::{self, FloatTy, Ty, TypeAndMut};
-use rustc_span::symbol::sym;
 use rustc_target::abi::{Integer, LayoutOf, Variants};
 
 use super::{
@@ -49,13 +48,6 @@ pub fn cast(
                         // All reifications must be monomorphic, bail out otherwise.
                         ensure_monomorphic_enough(*self.tcx, src.layout.ty)?;
 
-                        if self.tcx.has_attr(def_id, sym::rustc_args_required_const) {
-                            span_bug!(
-                                self.cur_span(),
-                                "reifying a fn ptr that requires const arguments"
-                            );
-                        }
-
                         let instance = ty::Instance::resolve_for_fn_ptr(
                             *self.tcx,
                             self.param_env,
index 2d83d6cfbdc5ed9c2249655b57f4aaaff8a7014f..e9dd7a3fe68f1cbfbee51a981154a9c50c86a379 100644 (file)
@@ -263,7 +263,13 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
             }
             if !self.span.is_dummy() {
                 let lo = tcx.sess.source_map().lookup_char_pos(self.span.lo());
-                write!(f, " at {}:{}:{}", lo.file.name, lo.line, lo.col.to_usize() + 1)?;
+                write!(
+                    f,
+                    " at {}:{}:{}",
+                    lo.file.name.prefer_local(),
+                    lo.line,
+                    lo.col.to_usize() + 1
+                )?;
             }
             Ok(())
         })
index 95464da145cfd51b2ae17e06325413c8b70f89c4..23c0fe97c5f693b7657f316f48299063518d274d 100644 (file)
@@ -305,7 +305,6 @@ pub fn intern_const_alloc_recursive<M: CompileTimeMachine<'mir, 'tcx, const_eval
     let base_intern_mode = match intern_kind {
         InternKind::Static(mutbl) => InternMode::Static(mutbl),
         // `Constant` includes array lengths.
-        // `Promoted` includes non-`Copy` array initializers and `rustc_args_required_const` arguments.
         InternKind::Constant | InternKind::Promoted => InternMode::Const,
     };
 
index 4dfdc08b875c04fee49a5dbf11e9a1d414d3b849..2b996cf62a3d39166877d449973c9cf7399ad09c 100644 (file)
@@ -106,7 +106,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
         let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span);
         let caller = self.tcx.sess.source_map().lookup_char_pos(topmost.lo());
         (
-            Symbol::intern(&caller.file.name.to_string()),
+            Symbol::intern(&caller.file.name.prefer_remapped().to_string_lossy()),
             u32::try_from(caller.line).unwrap(),
             u32::try_from(caller.col_display).unwrap().checked_add(1).unwrap(),
         )
index fdefc890674774ad21dae37304e2e6557334323d..e4ad92eb1b1a13ab0f22c44bca4d2ffa5155b5b0 100644 (file)
@@ -390,8 +390,24 @@ fn collect_items_rec<'tcx>(
                 collect_neighbours(tcx, instance, &mut neighbors);
             });
         }
-        MonoItem::GlobalAsm(..) => {
+        MonoItem::GlobalAsm(item_id) => {
             recursion_depth_reset = None;
+
+            let item = tcx.hir().item(item_id);
+            if let hir::ItemKind::GlobalAsm(asm) = item.kind {
+                for (op, op_sp) in asm.operands {
+                    match op {
+                        hir::InlineAsmOperand::Const { .. } => {
+                            // Only constants which resolve to a plain integer
+                            // are supported. Therefore the value should not
+                            // depend on any other items.
+                        }
+                        _ => span_bug!(*op_sp, "invalid operand type for global_asm!"),
+                    }
+                }
+            } else {
+                span_bug!(item.span, "Mismatch between hir::Item type and MonoItem type")
+            }
         }
     }
 
index ba10b54c5ae2e37fa579dc694bcfb35a79d50e1f..b5c8b4bebc360496349001822c0dc24c1bece0f2 100644 (file)
@@ -47,7 +47,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
         // if we applied optimizations, we potentially have some cfg to cleanup to
         // make it easier for further passes
         if should_simplify {
-            simplify_cfg(tcx, body);
+            simplify_cfg(body);
             simplify_locals(body, tcx);
         }
     }
index 48361483099f2f325f1b67e9443a74acddd1d32f..2397d627880f337f63fbfa470757f8b40d7d3185 100644 (file)
 use rustc_middle::mir::coverage::*;
 use rustc_middle::mir::{self, BasicBlock, TerminatorKind};
 use rustc_middle::ty::TyCtxt;
+use rustc_span::Span;
 
 use std::iter;
 use std::lazy::SyncOnceCell;
@@ -636,6 +637,7 @@ pub(super) fn dump_coverage_spanview(
     mir_body: &mir::Body<'tcx>,
     basic_coverage_blocks: &CoverageGraph,
     pass_name: &str,
+    body_span: Span,
     coverage_spans: &Vec<CoverageSpan>,
 ) {
     let mir_source = mir_body.source;
@@ -647,7 +649,7 @@ pub(super) fn dump_coverage_spanview(
     let crate_name = tcx.crate_name(def_id.krate);
     let item_name = tcx.def_path(def_id).to_filename_friendly_no_crate();
     let title = format!("{}.{} - Coverage Spans", crate_name, item_name);
-    spanview::write_document(tcx, def_id, span_viewables, &title, &mut file)
+    spanview::write_document(tcx, body_span, span_viewables, &title, &mut file)
         .expect("Unexpected IO error dumping coverage spans as HTML");
 }
 
index c1e8f620b30c1dda7283b18eacc412256731bf79..71c244fdd4a3ae5e991340a2b67251eca40c8ca9 100644 (file)
@@ -95,7 +95,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, mir_body: &mut mir::Body<'tcx>) {
 
         trace!("InstrumentCoverage starting for {:?}", mir_source.def_id());
         Instrumentor::new(&self.name(), tcx, mir_body).inject_counters();
-        trace!("InstrumentCoverage starting for {:?}", mir_source.def_id());
+        trace!("InstrumentCoverage done for {:?}", mir_source.def_id());
     }
 }
 
@@ -116,25 +116,7 @@ fn new(pass_name: &'a str, tcx: TyCtxt<'tcx>, mir_body: &'a mut mir::Body<'tcx>)
         let def_id = mir_body.source.def_id();
         let (some_fn_sig, hir_body) = fn_sig_and_body(tcx, def_id);
 
-        let mut body_span = hir_body.value.span;
-
-        if tcx.is_closure(def_id) {
-            // If the MIR function is a closure, and if the closure body span
-            // starts from a macro, but it's content is not in that macro, try
-            // to find a non-macro callsite, and instrument the spans there
-            // instead.
-            loop {
-                let expn_data = body_span.ctxt().outer_expn_data();
-                if expn_data.is_root() {
-                    break;
-                }
-                if let ExpnKind::Macro(..) = expn_data.kind {
-                    body_span = expn_data.call_site;
-                } else {
-                    break;
-                }
-            }
-        }
+        let body_span = get_body_span(tcx, hir_body, mir_body);
 
         let source_file = source_map.lookup_source_file(body_span.lo());
         let fn_sig_span = match some_fn_sig.filter(|fn_sig| {
@@ -144,6 +126,15 @@ fn new(pass_name: &'a str, tcx: TyCtxt<'tcx>, mir_body: &'a mut mir::Body<'tcx>)
             Some(fn_sig) => fn_sig.span.with_hi(body_span.lo()),
             None => body_span.shrink_to_lo(),
         };
+
+        debug!(
+            "instrumenting {}: {:?}, fn sig span: {:?}, body span: {:?}",
+            if tcx.is_closure(def_id) { "closure" } else { "function" },
+            def_id,
+            fn_sig_span,
+            body_span
+        );
+
         let function_source_hash = hash_mir_source(tcx, hir_body);
         let basic_coverage_blocks = CoverageGraph::from_mir(mir_body);
         Self {
@@ -160,19 +151,11 @@ fn new(pass_name: &'a str, tcx: TyCtxt<'tcx>, mir_body: &'a mut mir::Body<'tcx>)
 
     fn inject_counters(&'a mut self) {
         let tcx = self.tcx;
-        let source_map = tcx.sess.source_map();
         let mir_source = self.mir_body.source;
         let def_id = mir_source.def_id();
         let fn_sig_span = self.fn_sig_span;
         let body_span = self.body_span;
 
-        debug!(
-            "instrumenting {:?}, fn sig span: {}, body span: {}",
-            def_id,
-            source_map.span_to_string(fn_sig_span),
-            source_map.span_to_string(body_span)
-        );
-
         let mut graphviz_data = debug::GraphvizData::new();
         let mut debug_used_expressions = debug::UsedExpressions::new();
 
@@ -204,6 +187,7 @@ fn inject_counters(&'a mut self) {
                 self.mir_body,
                 &self.basic_coverage_blocks,
                 self.pass_name,
+                body_span,
                 &coverage_spans,
             );
         }
@@ -311,7 +295,7 @@ fn inject_coverage_span_counters(
         let tcx = self.tcx;
         let source_map = tcx.sess.source_map();
         let body_span = self.body_span;
-        let file_name = Symbol::intern(&self.source_file.name.to_string());
+        let file_name = Symbol::intern(&self.source_file.name.prefer_remapped().to_string_lossy());
 
         let mut bcb_counters = IndexVec::from_elem_n(None, self.basic_coverage_blocks.num_nodes());
         for covspan in coverage_spans {
@@ -332,8 +316,8 @@ fn inject_coverage_span_counters(
                 "Calling make_code_region(file_name={}, source_file={:?}, span={}, body_span={})",
                 file_name,
                 self.source_file,
-                source_map.span_to_string(span),
-                source_map.span_to_string(body_span)
+                source_map.span_to_diagnostic_string(span),
+                source_map.span_to_diagnostic_string(body_span)
             );
 
             inject_statement(
@@ -560,6 +544,35 @@ fn fn_sig_and_body<'tcx>(
     (hir::map::fn_sig(hir_node), tcx.hir().body(fn_body_id))
 }
 
+fn get_body_span<'tcx>(
+    tcx: TyCtxt<'tcx>,
+    hir_body: &rustc_hir::Body<'tcx>,
+    mir_body: &mut mir::Body<'tcx>,
+) -> Span {
+    let mut body_span = hir_body.value.span;
+    let def_id = mir_body.source.def_id();
+
+    if tcx.is_closure(def_id) {
+        // If the MIR function is a closure, and if the closure body span
+        // starts from a macro, but it's content is not in that macro, try
+        // to find a non-macro callsite, and instrument the spans there
+        // instead.
+        loop {
+            let expn_data = body_span.ctxt().outer_expn_data();
+            if expn_data.is_root() {
+                break;
+            }
+            if let ExpnKind::Macro { .. } = expn_data.kind {
+                body_span = expn_data.call_site;
+            } else {
+                break;
+            }
+        }
+    }
+
+    body_span
+}
+
 fn hash_mir_source<'tcx>(tcx: TyCtxt<'tcx>, hir_body: &'tcx rustc_hir::Body<'tcx>) -> u64 {
     let mut hcx = tcx.create_no_span_stable_hashing_context();
     hash(&mut hcx, &hir_body.value).to_smaller_hash()
index 2ba9d1bdc0c003b89f1186ba5c2c86924a759ff0..760f16eae6b1f85be18bea6412b0f260c77b4ed8 100644 (file)
@@ -120,8 +120,8 @@ fn visit_coverage(&mut self, coverage: &Coverage) {
     }
 }
 
-fn coverageinfo<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> CoverageInfo {
-    let mir_body = mir_body(tcx, def_id);
+fn coverageinfo<'tcx>(tcx: TyCtxt<'tcx>, instance_def: ty::InstanceDef<'tcx>) -> CoverageInfo {
+    let mir_body = tcx.instance_mir(instance_def);
 
     let mut coverage_visitor = CoverageVisitor {
         // num_counters always has at least the `ZERO` counter.
index b3fc2a0cb5e90cc1def39b9fed5ceb9a4cf06fe5..f62171b3c535c757fe25accb398462dfa7bce5b3 100644 (file)
@@ -184,8 +184,11 @@ pub fn current_macro(&self) -> Option<Symbol> {
         self.current_macro_or_none
             .borrow_mut()
             .get_or_insert_with(|| {
-                if let ExpnKind::Macro(MacroKind::Bang, current_macro) =
-                    self.expn_span.ctxt().outer_expn_data().kind
+                if let ExpnKind::Macro {
+                    kind: MacroKind::Bang,
+                    name: current_macro,
+                    proc_macro: _,
+                } = self.expn_span.ctxt().outer_expn_data().kind
                 {
                     return Some(current_macro);
                 }
@@ -527,17 +530,25 @@ fn bcb_to_initial_coverage_spans(
                     .iter()
                     .enumerate()
                     .filter_map(move |(index, statement)| {
-                        filtered_statement_span(statement, self.body_span).map(
-                            |(span, expn_span)| {
-                                CoverageSpan::for_statement(
-                                    statement, span, expn_span, bcb, bb, index,
-                                )
-                            },
-                        )
+                        filtered_statement_span(statement).map(|span| {
+                            CoverageSpan::for_statement(
+                                statement,
+                                function_source_span(span, self.body_span),
+                                span,
+                                bcb,
+                                bb,
+                                index,
+                            )
+                        })
                     })
-                    .chain(filtered_terminator_span(data.terminator(), self.body_span).map(
-                        |(span, expn_span)| CoverageSpan::for_terminator(span, expn_span, bcb, bb),
-                    ))
+                    .chain(filtered_terminator_span(data.terminator()).map(|span| {
+                        CoverageSpan::for_terminator(
+                            function_source_span(span, self.body_span),
+                            span,
+                            bcb,
+                            bb,
+                        )
+                    }))
             })
             .collect()
     }
@@ -792,13 +803,9 @@ fn span_bcb_is_dominated_by(&self, covspan: &CoverageSpan, dom_covspan: &Coverag
     }
 }
 
-/// See `function_source_span()` for a description of the two returned spans.
-/// If the MIR `Statement` is not contributive to computing coverage spans,
-/// returns `None`.
-pub(super) fn filtered_statement_span(
-    statement: &'a Statement<'tcx>,
-    body_span: Span,
-) -> Option<(Span, Span)> {
+/// If the MIR `Statement` has a span contributive to computing coverage spans,
+/// return it; otherwise return `None`.
+pub(super) fn filtered_statement_span(statement: &'a Statement<'tcx>) -> Option<Span> {
     match statement.kind {
         // These statements have spans that are often outside the scope of the executed source code
         // for their parent `BasicBlock`.
@@ -835,18 +842,14 @@ pub(super) fn filtered_statement_span(
         | StatementKind::LlvmInlineAsm(_)
         | StatementKind::Retag(_, _)
         | StatementKind::AscribeUserType(_, _) => {
-            Some(function_source_span(statement.source_info.span, body_span))
+            Some(statement.source_info.span)
         }
     }
 }
 
-/// See `function_source_span()` for a description of the two returned spans.
-/// If the MIR `Terminator` is not contributive to computing coverage spans,
-/// returns `None`.
-pub(super) fn filtered_terminator_span(
-    terminator: &'a Terminator<'tcx>,
-    body_span: Span,
-) -> Option<(Span, Span)> {
+/// If the MIR `Terminator` has a span contributive to computing coverage spans,
+/// return it; otherwise return `None`.
+pub(super) fn filtered_terminator_span(terminator: &'a Terminator<'tcx>) -> Option<Span> {
     match terminator.kind {
         // These terminators have spans that don't positively contribute to computing a reasonable
         // span of actually executed source code. (For example, SwitchInt terminators extracted from
@@ -870,7 +873,7 @@ pub(super) fn filtered_terminator_span(
                     span = span.with_lo(constant.span.lo());
                 }
             }
-            Some(function_source_span(span, body_span))
+            Some(span)
         }
 
         // Retain spans from all other terminators
@@ -881,28 +884,20 @@ pub(super) fn filtered_terminator_span(
         | TerminatorKind::GeneratorDrop
         | TerminatorKind::FalseUnwind { .. }
         | TerminatorKind::InlineAsm { .. } => {
-            Some(function_source_span(terminator.source_info.span, body_span))
+            Some(terminator.source_info.span)
         }
     }
 }
 
-/// Returns two spans from the given span (the span associated with a
-/// `Statement` or `Terminator`):
-///
-///   1. An extrapolated span (pre-expansion[^1]) corresponding to a range within
-///      the function's body source. This span is guaranteed to be contained
-///      within, or equal to, the `body_span`. If the extrapolated span is not
-///      contained within the `body_span`, the `body_span` is returned.
-///   2. The actual `span` value from the `Statement`, before expansion.
-///
-/// Only the first span is used when computing coverage code regions. The second
-/// span is useful if additional expansion data is needed (such as to look up
-/// the macro name for a composed span within that macro).)
+/// Returns an extrapolated span (pre-expansion[^1]) corresponding to a range
+/// within the function's body source. This span is guaranteed to be contained
+/// within, or equal to, the `body_span`. If the extrapolated span is not
+/// contained within the `body_span`, the `body_span` is returned.
 ///
-/// [^1]Expansions result from Rust syntax including macros, syntactic
-/// sugar, etc.).
+/// [^1]Expansions result from Rust syntax including macros, syntactic sugar,
+/// etc.).
 #[inline]
-fn function_source_span(span: Span, body_span: Span) -> (Span, Span) {
+pub(super) fn function_source_span(span: Span, body_span: Span) -> Span {
     let original_span = original_sp(span, body_span).with_ctxt(body_span.ctxt());
-    (if body_span.contains(original_span) { original_span } else { body_span }, span)
+    if body_span.contains(original_span) { original_span } else { body_span }
 }
index 9b84173c8a29307ba11ed5b15a007c11e8e22177..b04c2d542d459fda4a9b5aa30f1e0208b65bede1 100644 (file)
@@ -683,12 +683,10 @@ fn test_make_bcb_counters() {
         let mut basic_coverage_blocks = graph::CoverageGraph::from_mir(&mir_body);
         let mut coverage_spans = Vec::new();
         for (bcb, data) in basic_coverage_blocks.iter_enumerated() {
-            if let Some((span, expn_span)) =
-                spans::filtered_terminator_span(data.terminator(&mir_body), body_span)
-            {
+            if let Some(span) = spans::filtered_terminator_span(data.terminator(&mir_body)) {
                 coverage_spans.push(spans::CoverageSpan::for_terminator(
+                    spans::function_source_span(span, body_span),
                     span,
-                    expn_span,
                     bcb,
                     data.last_bb(),
                 ));
index 912505c65983edb8f06df2ef6fe0016035ef90db..c41e71e09a4efc7d64186850460538b2b254d0cb 100644 (file)
@@ -26,7 +26,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
         if has_opts_to_apply {
             let mut opt_applier = OptApplier { tcx, duplicates };
             opt_applier.visit_body(body);
-            simplify_cfg(tcx, body);
+            simplify_cfg(body);
         }
     }
 }
index ac392066233089914105843a2e224df382ad3761..7934d4ba8499c5364e09b7e00eede429b6d299c3 100644 (file)
@@ -164,16 +164,13 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
         // Since this optimization adds new basic blocks and invalidates others,
         // clean up the cfg to make it nicer for other passes
         if should_cleanup {
-            simplify_cfg(tcx, body);
+            simplify_cfg(body);
         }
     }
 }
 
 fn is_switch<'tcx>(terminator: &Terminator<'tcx>) -> bool {
-    match terminator.kind {
-        TerminatorKind::SwitchInt { .. } => true,
-        _ => false,
-    }
+    matches!(terminator.kind, TerminatorKind::SwitchInt { .. })
 }
 
 struct Helper<'a, 'tcx> {
index 3560b4b1e8645e77ed17488ac8ba954b9ea4c28c..003003a8abbeae90f8f736d89e8a3a504e271de8 100644 (file)
@@ -964,7 +964,7 @@ fn create_generator_drop_shim<'tcx>(
 
     // Make sure we remove dead blocks to remove
     // unrelated code from the resume part of the function
-    simplify::remove_dead_blocks(tcx, &mut body);
+    simplify::remove_dead_blocks(&mut body);
 
     dump_mir(tcx, None, "generator_drop", &0, &body, |_, _| Ok(()));
 
@@ -1137,7 +1137,7 @@ fn create_generator_resume_function<'tcx>(
 
     // Make sure we remove dead blocks to remove
     // unrelated code from the drop part of the function
-    simplify::remove_dead_blocks(tcx, body);
+    simplify::remove_dead_blocks(body);
 
     dump_mir(tcx, None, "generator_resume", &0, body, |_, _| Ok(()));
 }
index f1c95a84ade85a04800a9af36440ba28429fbe6d..b6f80763bc8c4c2b94b445b999a0d1bb85c2f3bb 100644 (file)
@@ -57,7 +57,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
         if inline(tcx, body) {
             debug!("running simplify cfg on {:?}", body.source);
             CfgSimplifier::new(body).simplify();
-            remove_dead_blocks(tcx, body);
+            remove_dead_blocks(body);
         }
     }
 }
index e6ee474285ec1a862ade146a615813a46e45c4ab..6d7e4cdb1c6efcd282c64f293a03aadb97de9167 100644 (file)
@@ -5,6 +5,7 @@
 use rustc_middle::ty::subst::SubstsRef;
 use rustc_middle::ty::{self, Ty, TyCtxt};
 use rustc_span::symbol::{sym, Symbol};
+use rustc_span::Span;
 use rustc_target::spec::abi::Abi;
 
 pub struct LowerIntrinsics;
@@ -119,6 +120,9 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
                             terminator.kind = TerminatorKind::Goto { target };
                         }
                     }
+                    _ if intrinsic_name.as_str().starts_with("simd_shuffle") => {
+                        validate_simd_shuffle(tcx, args, terminator.source_info.span);
+                    }
                     _ => {}
                 }
             }
@@ -132,9 +136,19 @@ fn resolve_rust_intrinsic(
 ) -> Option<(Symbol, SubstsRef<'tcx>)> {
     if let ty::FnDef(def_id, substs) = *func_ty.kind() {
         let fn_sig = func_ty.fn_sig(tcx);
-        if fn_sig.abi() == Abi::RustIntrinsic {
+        if let Abi::RustIntrinsic | Abi::PlatformIntrinsic = fn_sig.abi() {
             return Some((tcx.item_name(def_id), substs));
         }
     }
     None
 }
+
+fn validate_simd_shuffle(tcx: TyCtxt<'tcx>, args: &[Operand<'tcx>], span: Span) {
+    match &args[2] {
+        Operand::Constant(_) => {} // all good
+        _ => {
+            let msg = format!("last argument of `simd_shuffle` is required to be a `const` item");
+            tcx.sess.span_err(span, &msg);
+        }
+    }
+}
index 21b208a08c2dca13cad206c4c28bf986187f3e43..f7a9835353e5cff77c14c762641f2bf99103e088 100644 (file)
@@ -167,7 +167,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
         }
 
         if should_cleanup {
-            simplify_cfg(tcx, body);
+            simplify_cfg(body);
         }
     }
 }
index cd2db180552868c681f5bf862da1b988b43f9375..4aaa0baa9f46a26fb640f59b73e5f322eb84c6db 100644 (file)
@@ -38,6 +38,6 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
             }
         }
 
-        simplify::remove_dead_blocks(tcx, body)
+        simplify::remove_dead_blocks(body)
     }
 }
index 1bbaf833c4fd91710bb8f5c94b1960f31dd7d2f0..f6b1323e107977445a81679dbf846e3afe430d97 100644 (file)
 //! initialization and can otherwise silence errors, if
 //! move analysis runs after promotion on broken MIR.
 
-use rustc_ast::LitKind;
 use rustc_hir as hir;
-use rustc_hir::def_id::DefId;
 use rustc_middle::mir::traversal::ReversePostorder;
 use rustc_middle::mir::visit::{MutVisitor, MutatingUseContext, PlaceContext, Visitor};
 use rustc_middle::mir::*;
 use rustc_middle::ty::cast::CastTy;
 use rustc_middle::ty::subst::InternalSubsts;
 use rustc_middle::ty::{self, List, TyCtxt, TypeFoldable};
-use rustc_span::symbol::sym;
 use rustc_span::Span;
 
 use rustc_index::vec::{Idx, IndexVec};
-use rustc_target::spec::abi::Abi;
 
 use std::cell::Cell;
 use std::{cmp, iter, mem};
@@ -36,8 +32,8 @@
 
 /// A `MirPass` for promotion.
 ///
-/// Promotion is the extraction of promotable temps into separate MIR bodies. This pass also emits
-/// errors when promotion of `#[rustc_args_required_const]` arguments fails.
+/// Promotion is the extraction of promotable temps into separate MIR bodies so they can have
+/// `'static` lifetime.
 ///
 /// After this pass is run, `promoted_fragments` will hold the MIR body corresponding to each
 /// newly created `Constant`.
@@ -101,47 +97,16 @@ pub fn is_promotable(&self) -> bool {
 pub enum Candidate {
     /// Borrow of a constant temporary, candidate for lifetime extension.
     Ref(Location),
-
-    /// Currently applied to function calls where the callee has the unstable
-    /// `#[rustc_args_required_const]` attribute as well as the SIMD shuffle
-    /// intrinsic. The intrinsic requires the arguments are indeed constant and
-    /// the attribute currently provides the semantic requirement that arguments
-    /// must be constant.
-    Argument { bb: BasicBlock, index: usize },
 }
 
 impl Candidate {
-    /// Returns `true` if we should use the "explicit" rules for promotability for this `Candidate`.
-    fn forces_explicit_promotion(&self) -> bool {
-        match self {
-            Candidate::Ref(_) => false,
-            Candidate::Argument { .. } => true,
-        }
-    }
-
     fn source_info(&self, body: &Body<'_>) -> SourceInfo {
         match self {
             Candidate::Ref(location) => *body.source_info(*location),
-            Candidate::Argument { bb, .. } => *body.source_info(body.terminator_loc(*bb)),
         }
     }
 }
 
-fn args_required_const(tcx: TyCtxt<'_>, def_id: DefId) -> Option<Vec<usize>> {
-    let attrs = tcx.get_attrs(def_id);
-    let attr = attrs.iter().find(|a| tcx.sess.check_name(a, sym::rustc_args_required_const))?;
-    let mut ret = vec![];
-    for meta in attr.meta_item_list()? {
-        match meta.literal()?.kind {
-            LitKind::Int(a, _) => {
-                ret.push(a as usize);
-            }
-            _ => bug!("invalid arg index"),
-        }
-    }
-    Some(ret)
-}
-
 struct Collector<'a, 'tcx> {
     ccx: &'a ConstCx<'a, 'tcx>,
     temps: IndexVec<Local, TempState>,
@@ -208,31 +173,6 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
             _ => {}
         }
     }
-
-    fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location) {
-        self.super_terminator(terminator, location);
-
-        if let TerminatorKind::Call { ref func, .. } = terminator.kind {
-            if let ty::FnDef(def_id, _) = *func.ty(self.ccx.body, self.ccx.tcx).kind() {
-                let fn_sig = self.ccx.tcx.fn_sig(def_id);
-                if let Abi::RustIntrinsic | Abi::PlatformIntrinsic = fn_sig.abi() {
-                    let name = self.ccx.tcx.item_name(def_id);
-                    // FIXME(eddyb) use `#[rustc_args_required_const(2)]` for shuffles.
-                    if name.as_str().starts_with("simd_shuffle") {
-                        self.candidates.push(Candidate::Argument { bb: location.block, index: 2 });
-
-                        return; // Don't double count `simd_shuffle` candidates
-                    }
-                }
-
-                if let Some(constant_args) = args_required_const(self.ccx.tcx, def_id) {
-                    for index in constant_args {
-                        self.candidates.push(Candidate::Argument { bb: location.block, index });
-                    }
-                }
-            }
-        }
-    }
 }
 
 pub fn collect_temps_and_candidates(
@@ -256,14 +196,6 @@ pub fn collect_temps_and_candidates(
 struct Validator<'a, 'tcx> {
     ccx: &'a ConstCx<'a, 'tcx>,
     temps: &'a IndexVec<Local, TempState>,
-
-    /// Explicit promotion happens e.g. for constant arguments declared via
-    /// `rustc_args_required_const`.
-    /// Implicit promotion has almost the same rules, except that disallows `const fn`
-    /// except for those marked `#[rustc_promotable]`. This is to avoid changing
-    /// a legitimate run-time operation into a failing compile-time operation
-    /// e.g. due to addresses being compared inside the function.
-    explicit: bool,
 }
 
 impl std::ops::Deref for Validator<'a, 'tcx> {
@@ -280,8 +212,6 @@ impl<'tcx> Validator<'_, 'tcx> {
     fn validate_candidate(&self, candidate: Candidate) -> Result<(), Unpromotable> {
         match candidate {
             Candidate::Ref(loc) => {
-                assert!(!self.explicit);
-
                 let statement = &self.body[loc.block].statements[loc.statement_index];
                 match &statement.kind {
                     StatementKind::Assign(box (_, Rvalue::Ref(_, kind, place))) => {
@@ -310,15 +240,6 @@ fn validate_candidate(&self, candidate: Candidate) -> Result<(), Unpromotable> {
                     _ => bug!(),
                 }
             }
-            Candidate::Argument { bb, index } => {
-                assert!(self.explicit);
-
-                let terminator = self.body[bb].terminator();
-                match &terminator.kind {
-                    TerminatorKind::Call { args, .. } => self.validate_operand(&args[index]),
-                    _ => bug!(),
-                }
-            }
         }
     }
 
@@ -448,12 +369,10 @@ fn validate_place(&self, place: PlaceRef<'tcx>) -> Result<(), Unpromotable> {
                     ProjectionElem::ConstantIndex { .. } | ProjectionElem::Subslice { .. } => {}
 
                     ProjectionElem::Index(local) => {
-                        if !self.explicit {
-                            let mut promotable = false;
-                            // Only accept if we can predict the index and are indexing an array.
-                            let val = if let TempState::Defined { location: loc, .. } =
-                                self.temps[local]
-                            {
+                        let mut promotable = false;
+                        // Only accept if we can predict the index and are indexing an array.
+                        let val =
+                            if let TempState::Defined { location: loc, .. } = self.temps[local] {
                                 let block = &self.body[loc.block];
                                 if loc.statement_index < block.statements.len() {
                                     let statement = &block.statements[loc.statement_index];
@@ -470,28 +389,27 @@ fn validate_place(&self, place: PlaceRef<'tcx>) -> Result<(), Unpromotable> {
                             } else {
                                 None
                             };
-                            if let Some(idx) = val {
-                                // Determine the type of the thing we are indexing.
-                                let ty = place_base.ty(self.body, self.tcx).ty;
-                                match ty.kind() {
-                                    ty::Array(_, len) => {
-                                        // It's an array; determine its length.
-                                        if let Some(len) =
-                                            len.try_eval_usize(self.tcx, self.param_env)
-                                        {
-                                            // If the index is in-bounds, go ahead.
-                                            if idx < len {
-                                                promotable = true;
-                                            }
+                        if let Some(idx) = val {
+                            // Determine the type of the thing we are indexing.
+                            let ty = place_base.ty(self.body, self.tcx).ty;
+                            match ty.kind() {
+                                ty::Array(_, len) => {
+                                    // It's an array; determine its length.
+                                    if let Some(len) = len.try_eval_usize(self.tcx, self.param_env)
+                                    {
+                                        // If the index is in-bounds, go ahead.
+                                        if idx < len {
+                                            promotable = true;
                                         }
                                     }
-                                    _ => {}
                                 }
+                                _ => {}
                             }
-                            if !promotable {
-                                return Err(Unpromotable);
-                            }
                         }
+                        if !promotable {
+                            return Err(Unpromotable);
+                        }
+
                         self.validate_local(local)?;
                     }
 
@@ -636,7 +554,7 @@ fn validate_rvalue(&self, rvalue: &Rvalue<'tcx>) -> Result<(), Unpromotable> {
 
                 match op {
                     BinOp::Div | BinOp::Rem => {
-                        if !self.explicit && lhs_ty.is_integral() {
+                        if lhs_ty.is_integral() {
                             // Integer division: the RHS must be a non-zero const.
                             let const_val = match rhs {
                                 Operand::Constant(c) => {
@@ -721,13 +639,12 @@ fn validate_call(
     ) -> Result<(), Unpromotable> {
         let fn_ty = callee.ty(self.body, self.tcx);
 
-        // When doing explicit promotion and inside const/static items, we promote all (eligible) function calls.
+        // Inside const/static items, we promote all (eligible) function calls.
         // Everywhere else, we require `#[rustc_promotable]` on the callee.
-        let promote_all_const_fn = self.explicit
-            || matches!(
-                self.const_kind,
-                Some(hir::ConstContext::Static(_) | hir::ConstContext::Const)
-            );
+        let promote_all_const_fn = matches!(
+            self.const_kind,
+            Some(hir::ConstContext::Static(_) | hir::ConstContext::Const)
+        );
         if !promote_all_const_fn {
             if let ty::FnDef(def_id, _) = *fn_ty.kind() {
                 // Never promote runtime `const fn` calls of
@@ -765,41 +682,12 @@ pub fn validate_candidates(
     temps: &IndexVec<Local, TempState>,
     candidates: &[Candidate],
 ) -> Vec<Candidate> {
-    let mut validator = Validator { ccx, temps, explicit: false };
+    let validator = Validator { ccx, temps };
 
     candidates
         .iter()
         .copied()
-        .filter(|&candidate| {
-            validator.explicit = candidate.forces_explicit_promotion();
-
-            // FIXME(eddyb) also emit the errors for shuffle indices
-            // and `#[rustc_args_required_const]` arguments here.
-
-            let is_promotable = validator.validate_candidate(candidate).is_ok();
-
-            // If we use explicit validation, we carry the risk of turning a legitimate run-time
-            // operation into a failing compile-time operation. Make sure that does not happen
-            // by asserting that there is no possible run-time behavior here in case promotion
-            // fails.
-            if validator.explicit && !is_promotable {
-                ccx.tcx.sess.delay_span_bug(
-                    ccx.body.span,
-                    "Explicit promotion requested, but failed to promote",
-                );
-            }
-
-            match candidate {
-                Candidate::Argument { bb, index } if !is_promotable => {
-                    let span = ccx.body[bb].terminator().source_info.span;
-                    let msg = format!("argument {} is required to be a constant", index + 1);
-                    ccx.tcx.sess.span_err(span, &msg);
-                }
-                _ => (),
-            }
-
-            is_promotable
-        })
+        .filter(|&candidate| validator.validate_candidate(candidate).is_ok())
         .collect()
 }
 
@@ -1039,26 +927,6 @@ fn promote_candidate(
                         _ => bug!(),
                     }
                 }
-                Candidate::Argument { bb, index } => {
-                    let terminator = blocks[bb].terminator_mut();
-                    match terminator.kind {
-                        TerminatorKind::Call { ref mut args, .. } => {
-                            let ty = args[index].ty(local_decls, self.tcx);
-                            let span = terminator.source_info.span;
-
-                            Rvalue::Use(mem::replace(&mut args[index], promoted_operand(ty, span)))
-                        }
-                        // We expected a `TerminatorKind::Call` for which we'd like to promote an
-                        // argument. `qualify_consts` saw a `TerminatorKind::Call` here, but
-                        // we are seeing a `Goto`. That means that the `promote_temps` method
-                        // already promoted this call away entirely. This case occurs when calling
-                        // a function requiring a constant argument and as that constant value
-                        // providing a value whose computation contains another call to a function
-                        // requiring a constant argument.
-                        TerminatorKind::Goto { .. } => return None,
-                        _ => bug!(),
-                    }
-                }
             }
         };
 
@@ -1113,7 +981,6 @@ pub fn promote_candidates<'tcx>(
                     }
                 }
             }
-            Candidate::Argument { .. } => {}
         }
 
         // Declare return place local so that `mir::Body::new` doesn't complain.
index 02e45021a0aaf343fe3f73173934dbbead3e9f0d..5144d48750de70d7febebd7a0c6dcc013c157781 100644 (file)
@@ -36,7 +36,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
         // if we applied optimizations, we potentially have some cfg to cleanup to
         // make it easier for further passes
         if should_simplify {
-            simplify_cfg(tcx, body);
+            simplify_cfg(body);
         }
     }
 }
index 63373b0cffbb033c6f2f11ed4aceddd1194d6299..65e2d096b209462dd496320f589244ea13d12241 100644 (file)
@@ -29,7 +29,6 @@
 
 use crate::transform::MirPass;
 use rustc_index::vec::{Idx, IndexVec};
-use rustc_middle::mir::coverage::*;
 use rustc_middle::mir::visit::{MutVisitor, MutatingUseContext, PlaceContext, Visitor};
 use rustc_middle::mir::*;
 use rustc_middle::ty::TyCtxt;
@@ -47,9 +46,9 @@ pub fn new(label: &str) -> Self {
     }
 }
 
-pub fn simplify_cfg(tcx: TyCtxt<'tcx>, body: &mut Body<'_>) {
+pub fn simplify_cfg(body: &mut Body<'_>) {
     CfgSimplifier::new(body).simplify();
-    remove_dead_blocks(tcx, body);
+    remove_dead_blocks(body);
 
     // FIXME: Should probably be moved into some kind of pass manager
     body.basic_blocks_mut().raw.shrink_to_fit();
@@ -60,9 +59,9 @@ fn name(&self) -> Cow<'_, str> {
         Cow::Borrowed(&self.label)
     }
 
-    fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
+    fn run_pass(&self, _tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
         debug!("SimplifyCfg({:?}) - simplifying {:?}", self.label, body.source);
-        simplify_cfg(tcx, body);
+        simplify_cfg(body);
     }
 }
 
@@ -287,7 +286,7 @@ fn strip_nops(&mut self) {
     }
 }
 
-pub fn remove_dead_blocks(tcx: TyCtxt<'tcx>, body: &mut Body<'_>) {
+pub fn remove_dead_blocks(body: &mut Body<'_>) {
     let reachable = traversal::reachable_as_bitset(body);
     let num_blocks = body.basic_blocks().len();
     if num_blocks == reachable.count() {
@@ -307,11 +306,6 @@ pub fn remove_dead_blocks(tcx: TyCtxt<'tcx>, body: &mut Body<'_>) {
         }
         used_blocks += 1;
     }
-
-    if tcx.sess.instrument_coverage() {
-        save_unreachable_coverage(basic_blocks, used_blocks);
-    }
-
     basic_blocks.raw.truncate(used_blocks);
 
     for block in basic_blocks {
@@ -321,32 +315,6 @@ pub fn remove_dead_blocks(tcx: TyCtxt<'tcx>, body: &mut Body<'_>) {
     }
 }
 
-fn save_unreachable_coverage(
-    basic_blocks: &mut IndexVec<BasicBlock, BasicBlockData<'_>>,
-    first_dead_block: usize,
-) {
-    // retain coverage info for dead blocks, so coverage reports will still
-    // report `0` executions for the uncovered code regions.
-    let mut dropped_coverage = Vec::new();
-    for dead_block in first_dead_block..basic_blocks.len() {
-        for statement in basic_blocks[BasicBlock::new(dead_block)].statements.iter() {
-            if let StatementKind::Coverage(coverage) = &statement.kind {
-                if let Some(code_region) = &coverage.code_region {
-                    dropped_coverage.push((statement.source_info, code_region.clone()));
-                }
-            }
-        }
-    }
-    for (source_info, code_region) in dropped_coverage {
-        basic_blocks[START_BLOCK].statements.push(Statement {
-            source_info,
-            kind: StatementKind::Coverage(box Coverage {
-                kind: CoverageKind::Unreachable,
-                code_region: Some(code_region),
-            }),
-        })
-    }
-}
 pub struct SimplifyLocals;
 
 impl<'tcx> MirPass<'tcx> for SimplifyLocals {
index c9c4492062720199bf7d5ed0c63b73d892e7b2ef..89fddc95c98f7802cfdc9f8b555c5300e2588ccf 100644 (file)
@@ -558,7 +558,7 @@ fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
 
         if did_remove_blocks {
             // We have dead blocks now, so remove those.
-            simplify::remove_dead_blocks(tcx, body);
+            simplify::remove_dead_blocks(body);
         }
     }
 }
@@ -628,10 +628,7 @@ fn find(&self) -> Vec<SimplifyBranchSameOptimization> {
                     // But `asm!(...)` could abort the program,
                     // so we cannot assume that the `unreachable` terminator itself is reachable.
                     // FIXME(Centril): use a normalization pass instead of a check.
-                    || bb.statements.iter().any(|stmt| match stmt.kind {
-                        StatementKind::LlvmInlineAsm(..) => true,
-                        _ => false,
-                    })
+                    || bb.statements.iter().any(|stmt| matches!(stmt.kind, StatementKind::LlvmInlineAsm(..)))
                     })
                     .peekable();
 
index e7fb6b4f6b4ade858cf5210480c5a4aece8647d9..658c6b6e9db20086855c89e94b73799352195b87 100644 (file)
@@ -60,7 +60,7 @@ fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
         }
 
         if replaced {
-            simplify::remove_dead_blocks(tcx, body);
+            simplify::remove_dead_blocks(body);
         }
     }
 }
index 3b88aec16b26a638fabc287466c3d7fcf78880e2..955e85c944a5d4594e955844c3f0198a410f8df5 100644 (file)
@@ -445,7 +445,10 @@ fn visit_constant(&mut self, constant: &Constant<'tcx>, location: Location) {
             ty::Tuple(tys) if tys.is_empty() => {}
             _ => {
                 self.push("mir::Constant");
-                self.push(&format!("+ span: {}", self.tcx.sess.source_map().span_to_string(*span)));
+                self.push(&format!(
+                    "+ span: {}",
+                    self.tcx.sess.source_map().span_to_embeddable_string(*span)
+                ));
                 if let Some(user_ty) = user_ty {
                     self.push(&format!("+ user_ty: {:?}", user_ty));
                 }
@@ -516,7 +519,7 @@ fn visit_rvalue(&mut self, rvalue: &Rvalue<'tcx>, location: Location) {
 }
 
 fn comment(tcx: TyCtxt<'_>, SourceInfo { span, scope }: SourceInfo) -> String {
-    format!("scope {} at {}", scope.index(), tcx.sess.source_map().span_to_string(span))
+    format!("scope {} at {}", scope.index(), tcx.sess.source_map().span_to_embeddable_string(span))
 }
 
 /// Prints local variables in a scope tree.
@@ -617,7 +620,7 @@ fn write_scope_tree(
                 "{0:1$} // at {2}",
                 indented_header,
                 ALIGN,
-                tcx.sess.source_map().span_to_string(span),
+                tcx.sess.source_map().span_to_embeddable_string(span),
             )?;
         } else {
             writeln!(w, "{}", indented_header)?;
@@ -1004,7 +1007,7 @@ fn write_user_type_annotations(
             "| {:?}: {:?} at {}",
             index.index(),
             annotation.user_ty,
-            tcx.sess.source_map().span_to_string(annotation.span)
+            tcx.sess.source_map().span_to_embeddable_string(annotation.span)
         )?;
     }
     if !body.user_type_annotations.is_empty() {
index 9abfa4a8dc68b7856be0d07aea205157a3dd8e22..42683dac426e3b1fdd5271658149c50ca42bd014 100644 (file)
@@ -131,7 +131,7 @@ pub fn write_mir_fn_spanview<'tcx, W>(
             }
         }
     }
-    write_document(tcx, def_id, span_viewables, title, w)?;
+    write_document(tcx, fn_span(tcx, def_id), span_viewables, title, w)?;
     Ok(())
 }
 
@@ -139,7 +139,7 @@ pub fn write_mir_fn_spanview<'tcx, W>(
 /// list `SpanViewable`s.
 pub fn write_document<'tcx, W>(
     tcx: TyCtxt<'tcx>,
-    def_id: DefId,
+    spanview_span: Span,
     mut span_viewables: Vec<SpanViewable>,
     title: &str,
     w: &mut W,
@@ -147,16 +147,16 @@ pub fn write_document<'tcx, W>(
 where
     W: Write,
 {
-    let fn_span = fn_span(tcx, def_id);
-    let mut from_pos = fn_span.lo();
-    let end_pos = fn_span.hi();
+    let mut from_pos = spanview_span.lo();
+    let end_pos = spanview_span.hi();
     let source_map = tcx.sess.source_map();
     let start = source_map.lookup_char_pos(from_pos);
     let indent_to_initial_start_col = " ".repeat(start.col.to_usize());
     debug!(
-        "fn_span source is:\n{}{}",
+        "spanview_span={:?}; source is:\n{}{}",
+        spanview_span,
         indent_to_initial_start_col,
-        source_map.span_to_snippet(fn_span).expect("function should have printable source")
+        source_map.span_to_snippet(spanview_span).expect("function should have printable source")
     );
     writeln!(w, "{}", HEADER)?;
     writeln!(w, "<title>{}</title>", title)?;
@@ -628,7 +628,7 @@ fn tooltip<'tcx>(
 ) -> String {
     let source_map = tcx.sess.source_map();
     let mut text = Vec::new();
-    text.push(format!("{}: {}:", spanview_id, &source_map.span_to_string(span)));
+    text.push(format!("{}: {}:", spanview_id, &source_map.span_to_embeddable_string(span)));
     for statement in statements {
         let source_range = source_range_no_file(tcx, &statement.source_info.span);
         text.push(format!(
diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs
new file mode 100644 (file)
index 0000000..9333625
--- /dev/null
@@ -0,0 +1,334 @@
+use crate::thir::visit::{self, Visitor};
+use crate::thir::*;
+
+use rustc_errors::struct_span_err;
+use rustc_hir as hir;
+use rustc_middle::ty::{self, TyCtxt};
+use rustc_session::lint::builtin::{UNSAFE_OP_IN_UNSAFE_FN, UNUSED_UNSAFE};
+use rustc_session::lint::Level;
+use rustc_span::def_id::{DefId, LocalDefId};
+use rustc_span::Span;
+
+struct UnsafetyVisitor<'tcx> {
+    tcx: TyCtxt<'tcx>,
+    /// The `HirId` of the current scope, which would be the `HirId`
+    /// of the current HIR node, modulo adjustments. Used for lint levels.
+    hir_context: hir::HirId,
+    /// The current "safety context". This notably tracks whether we are in an
+    /// `unsafe` block, and whether it has been used.
+    safety_context: SafetyContext,
+    body_unsafety: BodyUnsafety,
+}
+
+impl<'tcx> UnsafetyVisitor<'tcx> {
+    fn in_safety_context<R>(
+        &mut self,
+        safety_context: SafetyContext,
+        f: impl FnOnce(&mut Self) -> R,
+    ) {
+        if let (
+            SafetyContext::UnsafeBlock { span: enclosing_span, .. },
+            SafetyContext::UnsafeBlock { span: block_span, hir_id, .. },
+        ) = (self.safety_context, safety_context)
+        {
+            self.warn_unused_unsafe(
+                hir_id,
+                block_span,
+                Some(self.tcx.sess.source_map().guess_head_span(enclosing_span)),
+            );
+            f(self);
+        } else {
+            let prev_context = self.safety_context;
+            self.safety_context = safety_context;
+
+            f(self);
+
+            if let SafetyContext::UnsafeBlock { used: false, span, hir_id } = self.safety_context {
+                self.warn_unused_unsafe(hir_id, span, self.body_unsafety.unsafe_fn_sig_span());
+            }
+            self.safety_context = prev_context;
+            return;
+        }
+    }
+
+    fn requires_unsafe(&mut self, span: Span, kind: UnsafeOpKind) {
+        let (description, note) = kind.description_and_note();
+        let unsafe_op_in_unsafe_fn_allowed = self.unsafe_op_in_unsafe_fn_allowed();
+        match self.safety_context {
+            SafetyContext::UnsafeBlock { ref mut used, .. } => {
+                if !self.body_unsafety.is_unsafe() || !unsafe_op_in_unsafe_fn_allowed {
+                    // Mark this block as useful
+                    *used = true;
+                }
+            }
+            SafetyContext::UnsafeFn if unsafe_op_in_unsafe_fn_allowed => {}
+            SafetyContext::UnsafeFn => {
+                // unsafe_op_in_unsafe_fn is disallowed
+                if kind == BorrowOfPackedField {
+                    // FIXME handle borrows of packed fields
+                } else {
+                    struct_span_err!(
+                        self.tcx.sess,
+                        span,
+                        E0133,
+                        "{} is unsafe and requires unsafe block",
+                        description,
+                    )
+                    .span_label(span, description)
+                    .note(note)
+                    .emit();
+                }
+            }
+            SafetyContext::Safe => {
+                if kind == BorrowOfPackedField {
+                    // FIXME handle borrows of packed fields
+                } else {
+                    let fn_sugg = if unsafe_op_in_unsafe_fn_allowed { " function or" } else { "" };
+                    struct_span_err!(
+                        self.tcx.sess,
+                        span,
+                        E0133,
+                        "{} is unsafe and requires unsafe{} block",
+                        description,
+                        fn_sugg,
+                    )
+                    .span_label(span, description)
+                    .note(note)
+                    .emit();
+                }
+            }
+        }
+    }
+
+    fn warn_unused_unsafe(
+        &self,
+        hir_id: hir::HirId,
+        block_span: Span,
+        enclosing_span: Option<Span>,
+    ) {
+        let block_span = self.tcx.sess.source_map().guess_head_span(block_span);
+        self.tcx.struct_span_lint_hir(UNUSED_UNSAFE, hir_id, block_span, |lint| {
+            let msg = "unnecessary `unsafe` block";
+            let mut db = lint.build(msg);
+            db.span_label(block_span, msg);
+            if let Some(enclosing_span) = enclosing_span {
+                db.span_label(
+                    enclosing_span,
+                    format!("because it's nested under this `unsafe` block"),
+                );
+            }
+            db.emit();
+        });
+    }
+
+    /// Whether the `unsafe_op_in_unsafe_fn` lint is `allow`ed at the current HIR node.
+    fn unsafe_op_in_unsafe_fn_allowed(&self) -> bool {
+        self.tcx.lint_level_at_node(UNSAFE_OP_IN_UNSAFE_FN, self.hir_context).0 == Level::Allow
+    }
+}
+
+impl<'thir, 'tcx> Visitor<'thir, 'tcx> for UnsafetyVisitor<'tcx> {
+    fn visit_block(&mut self, block: &Block<'thir, 'tcx>) {
+        if let BlockSafety::ExplicitUnsafe(hir_id) = block.safety_mode {
+            self.in_safety_context(
+                SafetyContext::UnsafeBlock { span: block.span, hir_id, used: false },
+                |this| visit::walk_block(this, block),
+            );
+        } else {
+            visit::walk_block(self, block);
+        }
+    }
+
+    fn visit_expr(&mut self, expr: &'thir Expr<'thir, 'tcx>) {
+        match expr.kind {
+            ExprKind::Scope { value, lint_level: LintLevel::Explicit(hir_id), region_scope: _ } => {
+                let prev_id = self.hir_context;
+                self.hir_context = hir_id;
+                self.visit_expr(value);
+                self.hir_context = prev_id;
+                return;
+            }
+            ExprKind::Call { fun, ty: _, args: _, from_hir_call: _, fn_span: _ } => {
+                if fun.ty.fn_sig(self.tcx).unsafety() == hir::Unsafety::Unsafe {
+                    self.requires_unsafe(expr.span, CallToUnsafeFunction);
+                }
+            }
+            _ => {}
+        }
+
+        visit::walk_expr(self, expr);
+    }
+}
+
+#[derive(Clone, Copy)]
+enum SafetyContext {
+    Safe,
+    UnsafeFn,
+    UnsafeBlock { span: Span, hir_id: hir::HirId, used: bool },
+}
+
+#[derive(Clone, Copy)]
+enum BodyUnsafety {
+    /// The body is not unsafe.
+    Safe,
+    /// The body is an unsafe function. The span points to
+    /// the signature of the function.
+    Unsafe(Span),
+}
+
+impl BodyUnsafety {
+    /// Returns whether the body is unsafe.
+    fn is_unsafe(&self) -> bool {
+        matches!(self, BodyUnsafety::Unsafe(_))
+    }
+
+    /// If the body is unsafe, returns the `Span` of its signature.
+    fn unsafe_fn_sig_span(self) -> Option<Span> {
+        match self {
+            BodyUnsafety::Unsafe(span) => Some(span),
+            BodyUnsafety::Safe => None,
+        }
+    }
+}
+
+#[derive(Clone, Copy, PartialEq)]
+enum UnsafeOpKind {
+    CallToUnsafeFunction,
+    #[allow(dead_code)] // FIXME
+    UseOfInlineAssembly,
+    #[allow(dead_code)] // FIXME
+    InitializingTypeWith,
+    #[allow(dead_code)] // FIXME
+    CastOfPointerToInt,
+    #[allow(dead_code)] // FIXME
+    BorrowOfPackedField,
+    #[allow(dead_code)] // FIXME
+    UseOfMutableStatic,
+    #[allow(dead_code)] // FIXME
+    UseOfExternStatic,
+    #[allow(dead_code)] // FIXME
+    DerefOfRawPointer,
+    #[allow(dead_code)] // FIXME
+    AssignToDroppingUnionField,
+    #[allow(dead_code)] // FIXME
+    AccessToUnionField,
+    #[allow(dead_code)] // FIXME
+    MutationOfLayoutConstrainedField,
+    #[allow(dead_code)] // FIXME
+    BorrowOfLayoutConstrainedField,
+    #[allow(dead_code)] // FIXME
+    CallToFunctionWith,
+}
+
+use UnsafeOpKind::*;
+
+impl UnsafeOpKind {
+    pub fn description_and_note(&self) -> (&'static str, &'static str) {
+        match self {
+            CallToUnsafeFunction => (
+                "call to unsafe function",
+                "consult the function's documentation for information on how to avoid undefined \
+                 behavior",
+            ),
+            UseOfInlineAssembly => (
+                "use of inline assembly",
+                "inline assembly is entirely unchecked and can cause undefined behavior",
+            ),
+            InitializingTypeWith => (
+                "initializing type with `rustc_layout_scalar_valid_range` attr",
+                "initializing a layout restricted type's field with a value outside the valid \
+                 range is undefined behavior",
+            ),
+            CastOfPointerToInt => {
+                ("cast of pointer to int", "casting pointers to integers in constants")
+            }
+            BorrowOfPackedField => (
+                "borrow of packed field",
+                "fields of packed structs might be misaligned: dereferencing a misaligned pointer \
+                 or even just creating a misaligned reference is undefined behavior",
+            ),
+            UseOfMutableStatic => (
+                "use of mutable static",
+                "mutable statics can be mutated by multiple threads: aliasing violations or data \
+                 races will cause undefined behavior",
+            ),
+            UseOfExternStatic => (
+                "use of extern static",
+                "extern statics are not controlled by the Rust type system: invalid data, \
+                 aliasing violations or data races will cause undefined behavior",
+            ),
+            DerefOfRawPointer => (
+                "dereference of raw pointer",
+                "raw pointers may be NULL, dangling or unaligned; they can violate aliasing rules \
+                 and cause data races: all of these are undefined behavior",
+            ),
+            AssignToDroppingUnionField => (
+                "assignment to union field that might need dropping",
+                "the previous content of the field will be dropped, which causes undefined \
+                 behavior if the field was not properly initialized",
+            ),
+            AccessToUnionField => (
+                "access to union field",
+                "the field may not be properly initialized: using uninitialized data will cause \
+                 undefined behavior",
+            ),
+            MutationOfLayoutConstrainedField => (
+                "mutation of layout constrained field",
+                "mutating layout constrained fields cannot statically be checked for valid values",
+            ),
+            BorrowOfLayoutConstrainedField => (
+                "borrow of layout constrained field with interior mutability",
+                "references to fields of layout constrained fields lose the constraints. Coupled \
+                 with interior mutability, the field can be changed to invalid values",
+            ),
+            CallToFunctionWith => (
+                "call to function with `#[target_feature]`",
+                "can only be called if the required target features are available",
+            ),
+        }
+    }
+}
+
+// FIXME: checking unsafety for closures should be handled by their parent body,
+// as they inherit their "safety context" from their declaration site.
+pub fn check_unsafety<'tcx>(tcx: TyCtxt<'tcx>, thir: &Expr<'_, 'tcx>, hir_id: hir::HirId) {
+    let body_unsafety = tcx.hir().fn_sig_by_hir_id(hir_id).map_or(BodyUnsafety::Safe, |fn_sig| {
+        if fn_sig.header.unsafety == hir::Unsafety::Unsafe {
+            BodyUnsafety::Unsafe(fn_sig.span)
+        } else {
+            BodyUnsafety::Safe
+        }
+    });
+    let safety_context =
+        if body_unsafety.is_unsafe() { SafetyContext::UnsafeFn } else { SafetyContext::Safe };
+    let mut visitor = UnsafetyVisitor { tcx, safety_context, hir_context: hir_id, body_unsafety };
+    visitor.visit_expr(thir);
+}
+
+crate fn thir_check_unsafety_inner<'tcx>(
+    tcx: TyCtxt<'tcx>,
+    def: ty::WithOptConstParam<LocalDefId>,
+) {
+    let hir_id = tcx.hir().local_def_id_to_hir_id(def.did);
+    let body_id = tcx.hir().body_owned_by(hir_id);
+    let body = tcx.hir().body(body_id);
+
+    let arena = Arena::default();
+    let thir = cx::build_thir(tcx, def, &arena, &body.value);
+    check_unsafety(tcx, thir, hir_id);
+}
+
+crate fn thir_check_unsafety<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) {
+    if let Some(def) = ty::WithOptConstParam::try_lookup(def_id, tcx) {
+        tcx.thir_check_unsafety_for_const_arg(def)
+    } else {
+        thir_check_unsafety_inner(tcx, ty::WithOptConstParam::unknown(def_id))
+    }
+}
+
+crate fn thir_check_unsafety_for_const_arg<'tcx>(
+    tcx: TyCtxt<'tcx>,
+    (did, param_did): (LocalDefId, DefId),
+) {
+    thir_check_unsafety_inner(tcx, ty::WithOptConstParam { did, const_param_did: Some(param_did) })
+}
index da9a0b08e865b0d59520e3e435f8f2b336ed3169..d4e9a0a31698583cb15e0c94e45353f06855d820 100644 (file)
@@ -19,6 +19,7 @@
 extern crate rustc_middle;
 
 mod build;
+mod check_unsafety;
 mod lints;
 pub mod thir;
 
@@ -28,4 +29,6 @@ pub fn provide(providers: &mut Providers) {
     providers.check_match = thir::pattern::check_match;
     providers.lit_to_const = thir::constant::lit_to_const;
     providers.mir_built = build::mir_built;
+    providers.thir_check_unsafety = check_unsafety::thir_check_unsafety;
+    providers.thir_check_unsafety_for_const_arg = check_unsafety::thir_check_unsafety_for_const_arg;
 }
index f4596d523d07a711b3363acbdc4509e84b965a46..9bcb000920c04936973eae3cd433744a7f75b3df 100644 (file)
@@ -29,6 +29,7 @@
 pub use arena::Arena;
 
 mod util;
+pub mod visit;
 
 #[derive(Copy, Clone, Debug)]
 pub enum LintLevel {
index fdecbb9478808f9323233fff3147754d3aba2dce..e4419070cbd08f3f9e01ae6704d0fe2afd4eda66 100644 (file)
@@ -496,12 +496,21 @@ fn non_exhaustive_match<'p, 'tcx>(
         err.span_label(sp, pattern_not_covered_label(&witnesses, &joined_patterns));
     };
 
+    let is_variant_list_non_exhaustive = match scrut_ty.kind() {
+        ty::Adt(def, _) if def.is_variant_list_non_exhaustive() && !def.did.is_local() => true,
+        _ => false,
+    };
+
     adt_defined_here(cx, &mut err, scrut_ty, &witnesses);
     err.help(
         "ensure that all possible cases are being handled, \
               possibly by adding wildcards or more match arms",
     );
-    err.note(&format!("the matched value is of type `{}`", scrut_ty));
+    err.note(&format!(
+        "the matched value is of type `{}`{}",
+        scrut_ty,
+        if is_variant_list_non_exhaustive { ", which is marked as non-exhaustive" } else { "" }
+    ));
     if (scrut_ty == cx.tcx.types.usize || scrut_ty == cx.tcx.types.isize)
         && !is_empty_match
         && witnesses.len() == 1
index 8c740a7ec155a3406f6ba5be9634a31a8f0c6b3c..db0f487645fa209d4967a9ede52fb49032eda8b6 100644 (file)
@@ -52,7 +52,6 @@
 use rustc_data_structures::captures::Captures;
 use rustc_index::vec::Idx;
 
-use rustc_hir::def_id::DefId;
 use rustc_hir::{HirId, RangeEnd};
 use rustc_middle::mir::interpret::ConstValue;
 use rustc_middle::mir::Field;
@@ -590,7 +589,7 @@ pub(super) enum Constructor<'tcx> {
     /// and fixed-length arrays.
     Single,
     /// Enum variants.
-    Variant(DefId),
+    Variant(VariantIdx),
     /// Ranges of integer literal values (`2`, `2..=5` or `2..5`).
     IntRange(IntRange),
     /// Ranges of floating-point literal values (`2.0..=5.2`).
@@ -634,7 +633,7 @@ fn as_slice(&self) -> Option<Slice> {
 
     fn variant_index_for_adt(&self, adt: &'tcx ty::AdtDef) -> VariantIdx {
         match *self {
-            Variant(id) => adt.variant_index_with_id(id),
+            Variant(idx) => idx,
             Single => {
                 assert!(!adt.is_enum());
                 VariantIdx::new(0)
@@ -649,9 +648,7 @@ pub(super) fn from_pat<'p>(cx: &MatchCheckCtxt<'p, 'tcx>, pat: &'p Pat<'tcx>) ->
             PatKind::AscribeUserType { .. } => bug!(), // Handled by `expand_pattern`
             PatKind::Binding { .. } | PatKind::Wild => Wildcard,
             PatKind::Leaf { .. } | PatKind::Deref { .. } => Single,
-            &PatKind::Variant { adt_def, variant_index, .. } => {
-                Variant(adt_def.variants[variant_index].def_id)
-            }
+            &PatKind::Variant { variant_index, .. } => Variant(variant_index),
             PatKind::Constant { value } => {
                 if let Some(int_range) = IntRange::from_const(cx.tcx, cx.param_env, value) {
                     IntRange(int_range)
@@ -928,15 +925,15 @@ pub(super) fn new<'p>(pcx: PatCtxt<'_, 'p, 'tcx>) -> Self {
                     // If `exhaustive_patterns` is enabled, we exclude variants known to be
                     // uninhabited.
                     def.variants
-                        .iter()
-                        .filter(|v| {
+                        .iter_enumerated()
+                        .filter(|(_, v)| {
                             !v.uninhabited_from(cx.tcx, substs, def.adt_kind(), cx.param_env)
                                 .contains(cx.tcx, cx.module)
                         })
-                        .map(|v| Variant(v.def_id))
+                        .map(|(idx, _)| Variant(idx))
                         .collect()
                 } else {
-                    def.variants.iter().map(|v| Variant(v.def_id)).collect()
+                    def.variants.indices().map(|idx| Variant(idx)).collect()
                 }
             }
             ty::Char => {
diff --git a/compiler/rustc_mir_build/src/thir/visit.rs b/compiler/rustc_mir_build/src/thir/visit.rs
new file mode 100644 (file)
index 0000000..9c5b07e
--- /dev/null
@@ -0,0 +1,186 @@
+use crate::thir::*;
+
+pub trait Visitor<'thir, 'tcx>: Sized {
+    fn visit_expr(&mut self, expr: &'thir Expr<'thir, 'tcx>) {
+        walk_expr(self, expr);
+    }
+
+    fn visit_stmt(&mut self, stmt: &'thir Stmt<'thir, 'tcx>) {
+        walk_stmt(self, stmt);
+    }
+
+    fn visit_block(&mut self, block: &Block<'thir, 'tcx>) {
+        walk_block(self, block);
+    }
+
+    fn visit_arm(&mut self, arm: &'thir Arm<'thir, 'tcx>) {
+        walk_arm(self, arm);
+    }
+
+    fn visit_const(&mut self, _cnst: &'tcx Const<'tcx>) {}
+}
+
+pub fn walk_expr<'thir, 'tcx, V: Visitor<'thir, 'tcx>>(
+    visitor: &mut V,
+    expr: &'thir Expr<'thir, 'tcx>,
+) {
+    use ExprKind::*;
+    match expr.kind {
+        Scope { value, region_scope: _, lint_level: _ } => visitor.visit_expr(value),
+        Box { value } => visitor.visit_expr(value),
+        If { cond, then, else_opt } => {
+            visitor.visit_expr(cond);
+            visitor.visit_expr(then);
+            if let Some(else_expr) = else_opt {
+                visitor.visit_expr(else_expr);
+            }
+        }
+        Call { fun, args, ty: _, from_hir_call: _, fn_span: _ } => {
+            visitor.visit_expr(fun);
+            for arg in args {
+                visitor.visit_expr(arg);
+            }
+        }
+        Deref { arg } => visitor.visit_expr(arg),
+        Binary { lhs, rhs, op: _ } | LogicalOp { lhs, rhs, op: _ } => {
+            visitor.visit_expr(lhs);
+            visitor.visit_expr(rhs);
+        }
+        Unary { arg, op: _ } => visitor.visit_expr(arg),
+        Cast { source } => visitor.visit_expr(source),
+        Use { source } => visitor.visit_expr(source),
+        NeverToAny { source } => visitor.visit_expr(source),
+        Pointer { source, cast: _ } => visitor.visit_expr(source),
+        Loop { body } => visitor.visit_expr(body),
+        Match { scrutinee, arms } => {
+            visitor.visit_expr(scrutinee);
+            for arm in arms {
+                visitor.visit_arm(arm);
+            }
+        }
+        Block { ref body } => visitor.visit_block(body),
+        Assign { lhs, rhs } | AssignOp { lhs, rhs, op: _ } => {
+            visitor.visit_expr(lhs);
+            visitor.visit_expr(rhs);
+        }
+        Field { lhs, name: _ } => visitor.visit_expr(lhs),
+        Index { lhs, index } => {
+            visitor.visit_expr(lhs);
+            visitor.visit_expr(index);
+        }
+        VarRef { id: _ } | UpvarRef { closure_def_id: _, var_hir_id: _ } => {}
+        Borrow { arg, borrow_kind: _ } => visitor.visit_expr(arg),
+        AddressOf { arg, mutability: _ } => visitor.visit_expr(arg),
+        Break { value, label: _ } => {
+            if let Some(value) = value {
+                visitor.visit_expr(value)
+            }
+        }
+        Continue { label: _ } => {}
+        Return { value } => {
+            if let Some(value) = value {
+                visitor.visit_expr(value)
+            }
+        }
+        ConstBlock { value } => visitor.visit_const(value),
+        Repeat { value, count } => {
+            visitor.visit_expr(value);
+            visitor.visit_const(count);
+        }
+        Array { fields } | Tuple { fields } => {
+            for field in fields {
+                visitor.visit_expr(field);
+            }
+        }
+        Adt { fields, ref base, adt_def: _, variant_index: _, substs: _, user_ty: _ } => {
+            for field in fields {
+                visitor.visit_expr(field.expr);
+            }
+            if let Some(base) = base {
+                visitor.visit_expr(base.base);
+            }
+        }
+        PlaceTypeAscription { source, user_ty: _ } | ValueTypeAscription { source, user_ty: _ } => {
+            visitor.visit_expr(source)
+        }
+        Closure { closure_id: _, substs: _, upvars: _, movability: _, fake_reads: _ } => {}
+        Literal { literal, user_ty: _, const_id: _ } => visitor.visit_const(literal),
+        StaticRef { literal, def_id: _ } => visitor.visit_const(literal),
+        InlineAsm { operands, template: _, options: _, line_spans: _ } => {
+            for op in operands {
+                use InlineAsmOperand::*;
+                match op {
+                    In { expr, reg: _ }
+                    | Out { expr: Some(expr), reg: _, late: _ }
+                    | InOut { expr, reg: _, late: _ }
+                    | SymFn { expr } => visitor.visit_expr(expr),
+                    SplitInOut { in_expr, out_expr, reg: _, late: _ } => {
+                        visitor.visit_expr(in_expr);
+                        if let Some(out_expr) = out_expr {
+                            visitor.visit_expr(out_expr);
+                        }
+                    }
+                    Out { expr: None, reg: _, late: _ }
+                    | Const { value: _, span: _ }
+                    | SymStatic { def_id: _ } => {}
+                }
+            }
+        }
+        ThreadLocalRef(_) => {}
+        LlvmInlineAsm { outputs, inputs, asm: _ } => {
+            for out_expr in outputs {
+                visitor.visit_expr(out_expr);
+            }
+            for in_expr in inputs {
+                visitor.visit_expr(in_expr);
+            }
+        }
+        Yield { value } => visitor.visit_expr(value),
+    }
+}
+
+pub fn walk_stmt<'thir, 'tcx, V: Visitor<'thir, 'tcx>>(
+    visitor: &mut V,
+    stmt: &'thir Stmt<'thir, 'tcx>,
+) {
+    match stmt.kind {
+        StmtKind::Expr { expr, scope: _ } => visitor.visit_expr(expr),
+        StmtKind::Let {
+            initializer,
+            remainder_scope: _,
+            init_scope: _,
+            pattern: _,
+            lint_level: _,
+        } => {
+            if let Some(init) = initializer {
+                visitor.visit_expr(init);
+            }
+        }
+    }
+}
+
+pub fn walk_block<'thir, 'tcx, V: Visitor<'thir, 'tcx>>(
+    visitor: &mut V,
+    block: &Block<'thir, 'tcx>,
+) {
+    for stmt in block.stmts {
+        visitor.visit_stmt(stmt);
+    }
+    if let Some(expr) = block.expr {
+        visitor.visit_expr(expr);
+    }
+}
+
+pub fn walk_arm<'thir, 'tcx, V: Visitor<'thir, 'tcx>>(
+    visitor: &mut V,
+    arm: &'thir Arm<'thir, 'tcx>,
+) {
+    match arm.guard {
+        Some(Guard::If(expr)) => visitor.visit_expr(expr),
+        Some(Guard::IfLet(ref _pat, expr)) => {
+            visitor.visit_expr(expr);
+        }
+        None => {}
+    }
+    visitor.visit_expr(arm.body);
+}
index 905077a48e25a76de0244a5f5cd36a5a210f7a51..077b19fa959596c1fba44713a6c075f3fbba95e8 100644 (file)
@@ -188,8 +188,10 @@ pub fn maybe_file_to_stream(
     override_span: Option<Span>,
 ) -> Result<(TokenStream, Vec<lexer::UnmatchedBrace>), Vec<Diagnostic>> {
     let src = source_file.src.as_ref().unwrap_or_else(|| {
-        sess.span_diagnostic
-            .bug(&format!("cannot lex `source_file` without source: {}", source_file.name));
+        sess.span_diagnostic.bug(&format!(
+            "cannot lex `source_file` without source: {}",
+            source_file.name.prefer_local()
+        ));
     });
 
     let (token_trees, unmatched_braces) =
index 553ffda814fe995eeb091a21cfb78b29aa058011..b2b578f1ed44a41a1c84df1e42d8da5fb15a425b 100644 (file)
@@ -1399,6 +1399,37 @@ fn parse_single_struct_field(
         Ok(a_var)
     }
 
+    fn expect_field_ty_separator(&mut self) -> PResult<'a, ()> {
+        if let Err(mut err) = self.expect(&token::Colon) {
+            let sm = self.sess.source_map();
+            let eq_typo = self.token.kind == token::Eq && self.look_ahead(1, |t| t.is_path_start());
+            let semi_typo = self.token.kind == token::Semi
+                && self.look_ahead(1, |t| {
+                    t.is_path_start()
+                    // We check that we are in a situation like `foo; bar` to avoid bad suggestions
+                    // when there's no type and `;` was used instead of a comma.
+                    && match (sm.lookup_line(self.token.span.hi()), sm.lookup_line(t.span.lo())) {
+                        (Ok(l), Ok(r)) => l.line == r.line,
+                        _ => true,
+                    }
+                });
+            if eq_typo || semi_typo {
+                self.bump();
+                // Gracefully handle small typos.
+                err.span_suggestion_short(
+                    self.prev_token.span,
+                    "field names and their types are separated with `:`",
+                    ":".to_string(),
+                    Applicability::MachineApplicable,
+                );
+                err.emit();
+            } else {
+                return Err(err);
+            }
+        }
+        Ok(())
+    }
+
     /// Parses a structure field.
     fn parse_name_and_ty(
         &mut self,
@@ -1408,8 +1439,21 @@ fn parse_name_and_ty(
         attrs: Vec<Attribute>,
     ) -> PResult<'a, FieldDef> {
         let name = self.parse_field_ident(adt_ty, lo)?;
-        self.expect(&token::Colon)?;
+        self.expect_field_ty_separator()?;
         let ty = self.parse_ty()?;
+        if self.token.kind == token::Eq {
+            self.bump();
+            let const_expr = self.parse_anon_const_expr()?;
+            let sp = ty.span.shrink_to_hi().to(const_expr.value.span);
+            self.struct_span_err(sp, "default values on `struct` fields aren't supported")
+                .span_suggestion(
+                    sp,
+                    "remove this unsupported default value",
+                    String::new(),
+                    Applicability::MachineApplicable,
+                )
+                .emit();
+        }
         Ok(FieldDef {
             span: lo.to(self.prev_token.span),
             ident: Some(name),
index cb06cbfcc7be02c517cbd9285e7bf12517b02c60..bf574bbfbb5aefc9f23c9f7f43f800ef90d09281 100644 (file)
@@ -13,9 +13,7 @@
 use rustc_hir as hir;
 use rustc_hir::def_id::LocalDefId;
 use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
-use rustc_hir::{
-    self, FnSig, ForeignItem, ForeignItemKind, HirId, Item, ItemKind, TraitItem, CRATE_HIR_ID,
-};
+use rustc_hir::{self, FnSig, ForeignItem, HirId, Item, ItemKind, TraitItem, CRATE_HIR_ID};
 use rustc_hir::{MethodKind, Target};
 use rustc_session::lint::builtin::{
     CONFLICTING_REPR_HINTS, INVALID_DOC_ATTRIBUTES, UNUSED_ATTRIBUTES,
@@ -81,9 +79,6 @@ fn check_attributes(
                 sym::doc => self.check_doc_attrs(attr, hir_id, target, &mut specified_inline),
                 sym::no_link => self.check_no_link(hir_id, &attr, span, target),
                 sym::export_name => self.check_export_name(hir_id, &attr, span, target),
-                sym::rustc_args_required_const => {
-                    self.check_rustc_args_required_const(&attr, span, target, item)
-                }
                 sym::rustc_layout_scalar_valid_range_start
                 | sym::rustc_layout_scalar_valid_range_end => {
                     self.check_rustc_layout_scalar_valid_range(&attr, span, target)
@@ -948,79 +943,6 @@ fn check_export_name(
         }
     }
 
-    /// Checks if `#[rustc_args_required_const]` is applied to a function and has a valid argument.
-    fn check_rustc_args_required_const(
-        &self,
-        attr: &Attribute,
-        span: &Span,
-        target: Target,
-        item: Option<ItemLike<'_>>,
-    ) -> bool {
-        let is_function = matches!(target, Target::Fn | Target::Method(..) | Target::ForeignFn);
-        if !is_function {
-            self.tcx
-                .sess
-                .struct_span_err(attr.span, "attribute should be applied to a function")
-                .span_label(*span, "not a function")
-                .emit();
-            return false;
-        }
-
-        let list = match attr.meta_item_list() {
-            // The attribute form is validated on AST.
-            None => return false,
-            Some(it) => it,
-        };
-
-        let mut invalid_args = vec![];
-        for meta in list {
-            if let Some(LitKind::Int(val, _)) = meta.literal().map(|lit| &lit.kind) {
-                if let Some(ItemLike::Item(Item {
-                    kind: ItemKind::Fn(FnSig { decl, .. }, ..),
-                    ..
-                }))
-                | Some(ItemLike::ForeignItem(ForeignItem {
-                    kind: ForeignItemKind::Fn(decl, ..),
-                    ..
-                })) = item
-                {
-                    let arg_count = decl.inputs.len() as u128;
-                    if *val >= arg_count {
-                        let span = meta.span();
-                        self.tcx
-                            .sess
-                            .struct_span_err(span, "index exceeds number of arguments")
-                            .span_label(
-                                span,
-                                format!(
-                                    "there {} only {} argument{}",
-                                    if arg_count != 1 { "are" } else { "is" },
-                                    arg_count,
-                                    pluralize!(arg_count)
-                                ),
-                            )
-                            .emit();
-                        return false;
-                    }
-                } else {
-                    bug!("should be a function item");
-                }
-            } else {
-                invalid_args.push(meta.span());
-            }
-        }
-
-        if !invalid_args.is_empty() {
-            self.tcx
-                .sess
-                .struct_span_err(invalid_args, "arguments should be non-negative integers")
-                .emit();
-            false
-        } else {
-            true
-        }
-    }
-
     fn check_rustc_layout_scalar_valid_range(
         &self,
         attr: &Attribute,
index 3f095d0e82427a4a1fc216ce6a814c48d231e02a..4532a0a350cefc730c3b385bb220b6b66ed3efbc 100644 (file)
@@ -405,6 +405,33 @@ fn visit_nested_body(&mut self, body_id: hir::BodyId) {
         ExprVisitor { tcx: self.tcx, param_env, typeck_results }.visit_body(body);
         self.visit_body(body);
     }
+
+    fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
+        if let hir::ItemKind::GlobalAsm(asm) = item.kind {
+            for (op, op_sp) in asm.operands {
+                match *op {
+                    hir::InlineAsmOperand::Const { ref anon_const } => {
+                        let anon_const_def_id = self.tcx.hir().local_def_id(anon_const.hir_id);
+                        let value = ty::Const::from_anon_const(self.tcx, anon_const_def_id);
+                        match value.ty.kind() {
+                            ty::Int(_) | ty::Uint(_) | ty::Float(_) => {}
+                            _ => {
+                                let msg = "asm `const` arguments must be integer or floating-point values";
+                                self.tcx.sess.span_err(*op_sp, msg);
+                            }
+                        }
+                    }
+                    hir::InlineAsmOperand::In { .. }
+                    | hir::InlineAsmOperand::Out { .. }
+                    | hir::InlineAsmOperand::InOut { .. }
+                    | hir::InlineAsmOperand::SplitInOut { .. }
+                    | hir::InlineAsmOperand::Sym { .. } => unreachable!(),
+                }
+            }
+        }
+
+        intravisit::walk_item(self, item);
+    }
 }
 
 impl Visitor<'tcx> for ExprVisitor<'tcx> {
index fa930471c21102df0049e850af8cbafcc9c8f253..4ceefa17bcf3d01ca84a39feac2fe722d330fb9d 100644 (file)
@@ -132,9 +132,9 @@ enum LiveNodeKind {
 fn live_node_kind_to_string(lnk: LiveNodeKind, tcx: TyCtxt<'_>) -> String {
     let sm = tcx.sess.source_map();
     match lnk {
-        UpvarNode(s) => format!("Upvar node [{}]", sm.span_to_string(s)),
-        ExprNode(s) => format!("Expr node [{}]", sm.span_to_string(s)),
-        VarDefNode(s) => format!("Var def node [{}]", sm.span_to_string(s)),
+        UpvarNode(s) => format!("Upvar node [{}]", sm.span_to_diagnostic_string(s)),
+        ExprNode(s) => format!("Expr node [{}]", sm.span_to_diagnostic_string(s)),
+        VarDefNode(s) => format!("Var def node [{}]", sm.span_to_diagnostic_string(s)),
         ClosureNode => "Closure node".to_owned(),
         ExitNode => "Exit node".to_owned(),
     }
index 14a373c59423fbbdeef6940bca513eb8d63fd551..c133f1a041719b73d0fbb8d29f5d31d967132ef5 100644 (file)
@@ -717,7 +717,7 @@ fn visit_body(&mut self, body: &'tcx hir::Body<'tcx>) {
         debug!(
             "visit_body(id={:?}, span={:?}, body.id={:?}, cx.parent={:?})",
             owner_id,
-            self.tcx.sess.source_map().span_to_string(body.value.span),
+            self.tcx.sess.source_map().span_to_diagnostic_string(body.value.span),
             body_id,
             self.cx.parent
         );
index 9c4f9b1198cf20c66f847902bd288cb8b6907f47..6b1813fba7600db946f8a9710605de147162a399 100644 (file)
@@ -739,7 +739,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
                     None => return,
                 };
                 let def_id = DefId { krate: cnum, index: CRATE_DEF_INDEX };
-                self.tcx.check_stability(def_id, Some(item.hir_id()), item.span);
+                self.tcx.check_stability(def_id, Some(item.hir_id()), item.span, None);
             }
 
             // For implementations of traits, check the stability of each item
@@ -783,7 +783,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
                             .map(|item| item.def_id);
                         if let Some(def_id) = trait_item_def_id {
                             // Pass `None` to skip deprecation warnings.
-                            self.tcx.check_stability(def_id, None, impl_item.span);
+                            self.tcx.check_stability(def_id, None, impl_item.span, None);
                         }
                     }
                 }
@@ -832,7 +832,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
 
     fn visit_path(&mut self, path: &'tcx hir::Path<'tcx>, id: hir::HirId) {
         if let Some(def_id) = path.res.opt_def_id() {
-            self.tcx.check_stability(def_id, Some(id), path.span)
+            self.tcx.check_stability(def_id, Some(id), path.span, None)
         }
         intravisit::walk_path(self, path)
     }
index b5c95cfcb29cbe46e57f414ecef95e53bed03674..e10314a11fc1bbacd6e83a378f10aecc774fb686 100644 (file)
@@ -995,7 +995,20 @@ fn build_reduced_graph_for_external_crate_res(&mut self, child: Export<NodeId>)
         // Record some extra data for better diagnostics.
         let cstore = self.r.cstore();
         match res {
-            Res::Def(DefKind::Struct | DefKind::Union, def_id) => {
+            Res::Def(DefKind::Struct, def_id) => {
+                let field_names = cstore.struct_field_names_untracked(def_id, self.r.session);
+                let ctor = cstore.ctor_def_id_and_kind_untracked(def_id);
+                if let Some((ctor_def_id, ctor_kind)) = ctor {
+                    let ctor_res = Res::Def(DefKind::Ctor(CtorOf::Struct, ctor_kind), ctor_def_id);
+                    let ctor_vis = cstore.visibility_untracked(ctor_def_id);
+                    let field_visibilities = cstore.struct_field_visibilities_untracked(def_id);
+                    self.r
+                        .struct_constructors
+                        .insert(def_id, (ctor_res, ctor_vis, field_visibilities));
+                }
+                self.insert_field_names(def_id, field_names);
+            }
+            Res::Def(DefKind::Union, def_id) => {
                 let field_names = cstore.struct_field_names_untracked(def_id, self.r.session);
                 self.insert_field_names(def_id, field_names);
             }
@@ -1007,12 +1020,6 @@ fn build_reduced_graph_for_external_crate_res(&mut self, child: Export<NodeId>)
                     self.r.has_self.insert(def_id);
                 }
             }
-            Res::Def(DefKind::Ctor(CtorOf::Struct, ..), def_id) => {
-                let parent = cstore.def_key(def_id).parent;
-                if let Some(struct_def_id) = parent.map(|index| DefId { index, ..def_id }) {
-                    self.r.struct_constructors.insert(struct_def_id, (res, vis, vec![]));
-                }
-            }
             _ => {}
         }
     }
index 92f21191de4308a8c12082a128382675f9b16570..ffa825b7d46a33c8faf96edb7f727fcc6c24f358 100644 (file)
@@ -1066,10 +1066,14 @@ fn resolve_item(&mut self, item: &'ast Item) {
                 self.future_proof_import(use_tree);
             }
 
-            ItemKind::ExternCrate(..) | ItemKind::MacroDef(..) | ItemKind::GlobalAsm(..) => {
+            ItemKind::ExternCrate(..) | ItemKind::MacroDef(..) => {
                 // do nothing, these are just around to be encoded
             }
 
+            ItemKind::GlobalAsm(_) => {
+                visit::walk_item(self, item);
+            }
+
             ItemKind::MacCall(_) => panic!("unexpanded macro in resolve!"),
         }
     }
index fdde687d4866c57913ca31bcb8de7394f24b4ed8..03b578d4adeec235d60aa34654cfbdc1962c2845 100644 (file)
@@ -6,7 +6,10 @@
 use crate::{PathResult, PathSource, Segment};
 
 use rustc_ast::visit::FnKind;
-use rustc_ast::{self as ast, Expr, ExprKind, Item, ItemKind, NodeId, Path, Ty, TyKind};
+use rustc_ast::{
+    self as ast, Expr, ExprKind, GenericParam, GenericParamKind, Item, ItemKind, NodeId, Path, Ty,
+    TyKind,
+};
 use rustc_ast_pretty::pprust::path_segment_to_string;
 use rustc_data_structures::fx::FxHashSet;
 use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder, SuggestionStyle};
@@ -1600,8 +1603,8 @@ fn suggest_using_enum_variant(
         if !self.diagnostic_metadata.currently_processing_generics && !single_uppercase_char {
             return None;
         }
-        match (self.diagnostic_metadata.current_item, single_uppercase_char) {
-            (Some(Item { kind: ItemKind::Fn(..), ident, .. }), _) if ident.name == sym::main => {
+        match (self.diagnostic_metadata.current_item, single_uppercase_char, self.diagnostic_metadata.currently_processing_generics) {
+            (Some(Item { kind: ItemKind::Fn(..), ident, .. }), _, _) if ident.name == sym::main => {
                 // Ignore `fn main()` as we don't want to suggest `fn main<T>()`
             }
             (
@@ -1613,9 +1616,11 @@ fn suggest_using_enum_variant(
                         | kind @ ItemKind::Union(..),
                     ..
                 }),
-                true,
+                true, _
             )
-            | (Some(Item { kind, .. }), false) => {
+            // Without the 2nd `true`, we'd suggest `impl <T>` for `impl T` when a type `T` isn't found
+            | (Some(Item { kind: kind @ ItemKind::Impl(..), .. }), true, true)
+            | (Some(Item { kind, .. }), false, _) => {
                 // Likely missing type parameter.
                 if let Some(generics) = kind.generics() {
                     if span.overlaps(generics.span) {
@@ -1633,6 +1638,10 @@ fn suggest_using_enum_variant(
                     let (span, sugg) = if let [.., param] = &generics.params[..] {
                         let span = if let [.., bound] = &param.bounds[..] {
                             bound.span()
+                        } else if let GenericParam {
+                            kind: GenericParamKind::Const { ty, kw_span: _, default  }, ..
+                        } = param {
+                            default.as_ref().map(|def| def.value.span).unwrap_or(ty.span)
                         } else {
                             param.ident.span
                         };
@@ -1821,7 +1830,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
     crate fn add_missing_lifetime_specifiers_label(
         &self,
         err: &mut DiagnosticBuilder<'_>,
-        spans_with_counts: Vec<(Span, usize)>,
+        mut spans_with_counts: Vec<(Span, usize)>,
         lifetime_names: &FxHashSet<Symbol>,
         lifetime_spans: Vec<Span>,
         params: &[ElisionFailureInfo],
@@ -1831,13 +1840,21 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
             .map(|(span, _)| self.tcx.sess.source_map().span_to_snippet(*span).ok())
             .collect();
 
-        for (span, count) in &spans_with_counts {
+        // Empty generics are marked with a span of "<", but since from now on
+        // that information is in the snippets it can be removed from the spans.
+        for ((span, _), snippet) in spans_with_counts.iter_mut().zip(&snippets) {
+            if snippet.as_deref() == Some("<") {
+                *span = span.shrink_to_hi();
+            }
+        }
+
+        for &(span, count) in &spans_with_counts {
             err.span_label(
-                *span,
+                span,
                 format!(
                     "expected {} lifetime parameter{}",
-                    if *count == 1 { "named".to_string() } else { count.to_string() },
-                    pluralize!(*count),
+                    if count == 1 { "named".to_string() } else { count.to_string() },
+                    pluralize!(count),
                 ),
             );
         }
@@ -1982,6 +1999,14 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
                                                 .collect::<Vec<_>>()
                                                 .join(", "),
                                         )
+                                    } else if snippet == "<" || snippet == "(" {
+                                        (
+                                            span.shrink_to_hi(),
+                                            std::iter::repeat("'static")
+                                                .take(count)
+                                                .collect::<Vec<_>>()
+                                                .join(", "),
+                                        )
                                     } else {
                                         (
                                             span.shrink_to_hi(),
@@ -1990,7 +2015,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
                                                 std::iter::repeat("'static")
                                                     .take(count)
                                                     .collect::<Vec<_>>()
-                                                    .join(", ")
+                                                    .join(", "),
                                             ),
                                         )
                                     }
@@ -2045,6 +2070,9 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
                         Some("&") => Some(Box::new(|name| format!("&{} ", name))),
                         Some("'_") => Some(Box::new(|n| n.to_string())),
                         Some("") => Some(Box::new(move |n| format!("{}, ", n).repeat(count))),
+                        Some("<") => Some(Box::new(move |n| {
+                            std::iter::repeat(n).take(count).collect::<Vec<_>>().join(", ")
+                        })),
                         Some(snippet) if !snippet.ends_with('>') => Some(Box::new(move |name| {
                             format!(
                                 "{}<{}>",
@@ -2071,6 +2099,9 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
                         Some("") => {
                             Some(std::iter::repeat("'a, ").take(count).collect::<Vec<_>>().join(""))
                         }
+                        Some("<") => {
+                            Some(std::iter::repeat("'a").take(count).collect::<Vec<_>>().join(", "))
+                        }
                         Some(snippet) => Some(format!(
                             "{}<{}>",
                             snippet,
index e8d21af435887ad907d5f6ebac045b0fdda371c8..efa5d7e7b113902721426d9a0e0c24442bd247b8 100644 (file)
@@ -8,11 +8,11 @@
 
 use crate::late::diagnostics::{ForLifetimeSpanType, MissingLifetimeSpot};
 use rustc_ast::walk_list;
-use rustc_data_structures::fx::{FxHashMap, FxHashSet};
+use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
 use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
 use rustc_hir as hir;
 use rustc_hir::def::{DefKind, Res};
-use rustc_hir::def_id::DefIdMap;
+use rustc_hir::def_id::{DefIdMap, LocalDefId};
 use rustc_hir::hir_id::ItemLocalId;
 use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
 use rustc_hir::{GenericArg, GenericParam, LifetimeName, Node, ParamName, QPath};
@@ -22,7 +22,7 @@
 use rustc_middle::ty::{self, DefIdTree, GenericParamDefKind, TyCtxt};
 use rustc_middle::{bug, span_bug};
 use rustc_session::lint;
-use rustc_span::def_id::{DefId, LocalDefId};
+use rustc_span::def_id::DefId;
 use rustc_span::symbol::{kw, sym, Ident, Symbol};
 use rustc_span::Span;
 use std::borrow::Cow;
@@ -158,6 +158,9 @@ struct NamedRegionMap {
     // - trait refs
     // - bound types (like `T` in `for<'a> T<'a>: Foo`)
     late_bound_vars: HirIdMap<Vec<ty::BoundVariableKind>>,
+
+    // maps `PathSegment` `HirId`s to lifetime scopes.
+    scope_for_path: Option<FxHashMap<LocalDefId, FxHashMap<ItemLocalId, LifetimeScopeForPath>>>,
 }
 
 crate struct LifetimeContext<'a, 'tcx> {
@@ -195,7 +198,9 @@ enum Scope<'a> {
     /// it should be shifted by the number of `Binder`s in between the
     /// declaration `Binder` and the location it's referenced from.
     Binder {
-        lifetimes: FxHashMap<hir::ParamName, Region>,
+        /// We use an IndexMap here because we want these lifetimes in order
+        /// for diagnostics.
+        lifetimes: FxIndexMap<hir::ParamName, Region>,
 
         /// if we extend this scope with another scope, what is the next index
         /// we should use for an early-bound region?
@@ -379,6 +384,10 @@ pub fn provide(providers: &mut ty::query::Providers) {
             }
         },
         late_bound_vars_map: |tcx, id| resolve_lifetimes_for(tcx, id).late_bound_vars.get(&id),
+        lifetime_scope_map: |tcx, id| {
+            let item_id = item_for(tcx, id);
+            do_resolve(tcx, item_id, false, true).scope_for_path.unwrap().remove(&id)
+        },
 
         ..*providers
     };
@@ -419,7 +428,7 @@ fn resolve_lifetimes_trait_definition(
     tcx: TyCtxt<'_>,
     local_def_id: LocalDefId,
 ) -> ResolveLifetimes {
-    do_resolve(tcx, local_def_id, true)
+    convert_named_region_map(do_resolve(tcx, local_def_id, true, false))
 }
 
 /// Computes the `ResolveLifetimes` map that contains data for an entire `Item`.
@@ -427,19 +436,21 @@ fn resolve_lifetimes_trait_definition(
 /// `named_region_map`, `is_late_bound_map`, etc.
 #[tracing::instrument(level = "debug", skip(tcx))]
 fn resolve_lifetimes(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> ResolveLifetimes {
-    do_resolve(tcx, local_def_id, false)
+    convert_named_region_map(do_resolve(tcx, local_def_id, false, false))
 }
 
 fn do_resolve(
     tcx: TyCtxt<'_>,
     local_def_id: LocalDefId,
     trait_definition_only: bool,
-) -> ResolveLifetimes {
+    with_scope_for_path: bool,
+) -> NamedRegionMap {
     let item = tcx.hir().expect_item(tcx.hir().local_def_id_to_hir_id(local_def_id));
     let mut named_region_map = NamedRegionMap {
         defs: Default::default(),
         late_bound: Default::default(),
         late_bound_vars: Default::default(),
+        scope_for_path: with_scope_for_path.then(|| Default::default()),
     };
     let mut visitor = LifetimeContext {
         tcx,
@@ -455,6 +466,10 @@ fn do_resolve(
     };
     visitor.visit_item(item);
 
+    named_region_map
+}
+
+fn convert_named_region_map(named_region_map: NamedRegionMap) -> ResolveLifetimes {
     let mut rl = ResolveLifetimes::default();
 
     for (hir_id, v) in named_region_map.defs {
@@ -567,6 +582,41 @@ fn late_region_as_bound_region<'tcx>(tcx: TyCtxt<'tcx>, region: &Region) -> ty::
     }
 }
 
+#[tracing::instrument(level = "debug")]
+fn get_lifetime_scopes_for_path(mut scope: &Scope<'_>) -> LifetimeScopeForPath {
+    let mut available_lifetimes = vec![];
+    loop {
+        match scope {
+            Scope::Binder { lifetimes, s, .. } => {
+                available_lifetimes.extend(lifetimes.keys().filter_map(|p| match p {
+                    hir::ParamName::Plain(ident) => Some(ident.name.to_string()),
+                    _ => None,
+                }));
+                scope = s;
+            }
+            Scope::Body { s, .. } => {
+                scope = s;
+            }
+            Scope::Elision { elide, s } => {
+                if let Elide::Exact(_) = elide {
+                    return LifetimeScopeForPath::Elided;
+                } else {
+                    scope = s;
+                }
+            }
+            Scope::ObjectLifetimeDefault { s, .. } => {
+                scope = s;
+            }
+            Scope::Root => {
+                return LifetimeScopeForPath::NonElided(available_lifetimes);
+            }
+            Scope::Supertrait { s, .. } | Scope::TraitRefBoundary { s, .. } => {
+                scope = s;
+            }
+        }
+    }
+}
+
 impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
     /// Returns the binders in scope and the type of `Binder` that should be created for a poly trait ref.
     fn poly_trait_ref_binder_info(&mut self) -> (Vec<ty::BoundVariableKind>, BinderScopeType) {
@@ -656,7 +706,7 @@ fn visit_fn(
                 self.map.late_bound_vars.insert(hir_id, vec![]);
                 let scope = Scope::Binder {
                     hir_id,
-                    lifetimes: FxHashMap::default(),
+                    lifetimes: FxIndexMap::default(),
                     next_early_index: self.next_early_index(),
                     s: self.scope,
                     track_lifetime_uses: true,
@@ -720,9 +770,7 @@ fn visit_item(&mut self, item: &'tcx hir::Item<'tcx>) {
                             // We need to add *all* deps, since opaque tys may want them from *us*
                             for (&owner, defs) in resolved_lifetimes.defs.iter() {
                                 defs.iter().for_each(|(&local_id, region)| {
-                                    self.map
-                                        .defs
-                                        .insert(hir::HirId { owner, local_id }, region.clone());
+                                    self.map.defs.insert(hir::HirId { owner, local_id }, *region);
                                 });
                             }
                             for (&owner, late_bound) in resolved_lifetimes.late_bound.iter() {
@@ -836,7 +884,7 @@ fn visit_ty(&mut self, ty: &'tcx hir::Ty<'tcx>) {
                 };
                 self.missing_named_lifetime_spots
                     .push(MissingLifetimeSpot::HigherRanked { span, span_type });
-                let (lifetimes, binders): (FxHashMap<hir::ParamName, Region>, Vec<_>) = c
+                let (lifetimes, binders): (FxIndexMap<hir::ParamName, Region>, Vec<_>) = c
                     .generic_params
                     .iter()
                     .filter_map(|param| match param.kind {
@@ -1010,7 +1058,7 @@ fn visit_ty(&mut self, ty: &'tcx hir::Ty<'tcx>) {
                 debug!(?index);
 
                 let mut elision = None;
-                let mut lifetimes = FxHashMap::default();
+                let mut lifetimes = FxIndexMap::default();
                 let mut non_lifetime_count = 0;
                 for param in generics.params {
                     match param.kind {
@@ -1181,7 +1229,7 @@ fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem<'tcx>) {
                 let mut index = self.next_early_index();
                 let mut non_lifetime_count = 0;
                 debug!("visit_ty: index = {}", index);
-                let lifetimes: FxHashMap<hir::ParamName, Region> = generics
+                let lifetimes: FxIndexMap<hir::ParamName, Region> = generics
                     .params
                     .iter()
                     .filter_map(|param| match param.kind {
@@ -1241,15 +1289,53 @@ fn visit_lifetime(&mut self, lifetime_ref: &'tcx hir::Lifetime) {
         self.resolve_lifetime_ref(lifetime_ref);
     }
 
+    fn visit_assoc_type_binding(&mut self, type_binding: &'tcx hir::TypeBinding<'_>) {
+        let scope = self.scope;
+        if let Some(scope_for_path) = self.map.scope_for_path.as_mut() {
+            // We add lifetime scope information for `Ident`s in associated type bindings and use
+            // the `HirId` of the type binding as the key in `LifetimeMap`
+            let lifetime_scope = get_lifetime_scopes_for_path(scope);
+            let map = scope_for_path.entry(type_binding.hir_id.owner).or_default();
+            map.insert(type_binding.hir_id.local_id, lifetime_scope);
+        }
+        hir::intravisit::walk_assoc_type_binding(self, type_binding);
+    }
+
     fn visit_path(&mut self, path: &'tcx hir::Path<'tcx>, _: hir::HirId) {
         for (i, segment) in path.segments.iter().enumerate() {
             let depth = path.segments.len() - i - 1;
             if let Some(ref args) = segment.args {
                 self.visit_segment_args(path.res, depth, args);
             }
+
+            let scope = self.scope;
+            if let Some(scope_for_path) = self.map.scope_for_path.as_mut() {
+                // Add lifetime scope information to path segment. Note we cannot call `visit_path_segment`
+                // here because that call would yield to resolution problems due to `walk_path_segment`
+                // being called, which processes the path segments generic args, which we have already
+                // processed using `visit_segment_args`.
+                let lifetime_scope = get_lifetime_scopes_for_path(scope);
+                if let Some(hir_id) = segment.hir_id {
+                    let map = scope_for_path.entry(hir_id.owner).or_default();
+                    map.insert(hir_id.local_id, lifetime_scope);
+                }
+            }
         }
     }
 
+    fn visit_path_segment(&mut self, path_span: Span, path_segment: &'tcx hir::PathSegment<'tcx>) {
+        let scope = self.scope;
+        if let Some(scope_for_path) = self.map.scope_for_path.as_mut() {
+            let lifetime_scope = get_lifetime_scopes_for_path(scope);
+            if let Some(hir_id) = path_segment.hir_id {
+                let map = scope_for_path.entry(hir_id.owner).or_default();
+                map.insert(hir_id.local_id, lifetime_scope);
+            }
+        }
+
+        intravisit::walk_path_segment(self, path_span, path_segment);
+    }
+
     fn visit_fn_decl(&mut self, fd: &'tcx hir::FnDecl<'tcx>) {
         let output = match fd.output {
             hir::FnRetTy::DefaultReturn(_) => None,
@@ -1290,7 +1376,7 @@ fn visit_generics(&mut self, generics: &'tcx hir::Generics<'tcx>) {
                         ref bound_generic_params,
                         ..
                     }) => {
-                        let (lifetimes, binders): (FxHashMap<hir::ParamName, Region>, Vec<_>) =
+                        let (lifetimes, binders): (FxIndexMap<hir::ParamName, Region>, Vec<_>) =
                             bound_generic_params
                                 .iter()
                                 .filter_map(|param| match param.kind {
@@ -1360,7 +1446,7 @@ fn visit_param_bound(&mut self, bound: &'tcx hir::GenericBound<'tcx>) {
                 self.map.late_bound_vars.insert(*hir_id, binders);
                 let scope = Scope::Binder {
                     hir_id: *hir_id,
-                    lifetimes: FxHashMap::default(),
+                    lifetimes: FxIndexMap::default(),
                     s: self.scope,
                     next_early_index: self.next_early_index(),
                     track_lifetime_uses: true,
@@ -1388,7 +1474,7 @@ fn visit_poly_trait_ref(
         let (mut binders, scope_type) = self.poly_trait_ref_binder_info();
 
         let initial_bound_vars = binders.len() as u32;
-        let mut lifetimes: FxHashMap<hir::ParamName, Region> = FxHashMap::default();
+        let mut lifetimes: FxIndexMap<hir::ParamName, Region> = FxIndexMap::default();
         let binders_iter = trait_ref
             .bound_generic_params
             .iter()
@@ -2115,7 +2201,7 @@ fn visit_early_late<F>(
 
         let mut non_lifetime_count = 0;
         let mut named_late_bound_vars = 0;
-        let lifetimes: FxHashMap<hir::ParamName, Region> = generics
+        let lifetimes: FxIndexMap<hir::ParamName, Region> = generics
             .params
             .iter()
             .filter_map(|param| match param.kind {
@@ -3034,6 +3120,16 @@ fn resolve_elided_lifetimes(&mut self, lifetime_refs: &[&'tcx hir::Lifetime]) {
             }
         };
 
+        // If we specifically need the `scope_for_path` map, then we're in the
+        // diagnostic pass and we don't want to emit more errors.
+        if self.map.scope_for_path.is_some() {
+            self.tcx.sess.delay_span_bug(
+                rustc_span::DUMMY_SP,
+                "Encountered unexpected errors during diagnostics related part",
+            );
+            return;
+        }
+
         let mut spans: Vec<_> = lifetime_refs.iter().map(|lt| lt.span).collect();
         spans.sort();
         let mut spans_dedup = spans.clone();
@@ -3355,7 +3451,7 @@ fn track_lifetime_uses(&self) -> bool {
     fn insert_lifetime(&mut self, lifetime_ref: &'tcx hir::Lifetime, def: Region) {
         debug!(
             node = ?self.tcx.hir().node_to_string(lifetime_ref.hir_id),
-            span = ?self.tcx.sess.source_map().span_to_string(lifetime_ref.span)
+            span = ?self.tcx.sess.source_map().span_to_diagnostic_string(lifetime_ref.span)
         );
         self.map.defs.insert(lifetime_ref.hir_id, def);
 
index 9197f4059ca2e01387e885642ddbf7bf671455e1..300d2c01cb5d08f03567603637a2fac365113902 100644 (file)
@@ -1770,9 +1770,11 @@ fn visit_scopes<T>(
                     let expn_data = expn_id.expn_data();
                     match expn_data.kind {
                         ExpnKind::Root
-                        | ExpnKind::Macro(MacroKind::Bang | MacroKind::Derive, _) => {
-                            Scope::DeriveHelpersCompat
-                        }
+                        | ExpnKind::Macro {
+                            kind: MacroKind::Bang | MacroKind::Derive,
+                            name: _,
+                            proc_macro: _,
+                        } => Scope::DeriveHelpersCompat,
                         _ => Scope::DeriveHelpers(expn_data.parent),
                     }
                 }
index 10e27f33c29960776dc92d2f77233b8e5fb7e3d7..3f7db2b6962fa51bb50122e238e00c5d18795160 100644 (file)
@@ -20,7 +20,7 @@
 use rustc_expand::expand::{AstFragment, Invocation, InvocationKind, SupportsMacroExpansion};
 use rustc_feature::is_builtin_attr_name;
 use rustc_hir::def::{self, DefKind, NonMacroAttrKind};
-use rustc_hir::def_id;
+use rustc_hir::def_id::{self, CrateNum};
 use rustc_hir::PrimTy;
 use rustc_middle::middle::stability;
 use rustc_middle::ty;
@@ -325,7 +325,11 @@ fn resolve_macro_invocation(
                         let expn_data = expn_id.expn_data();
                         match expn_data.kind {
                             ExpnKind::Root
-                            | ExpnKind::Macro(MacroKind::Bang | MacroKind::Derive, _) => {
+                            | ExpnKind::Macro {
+                                name: _,
+                                kind: MacroKind::Bang | MacroKind::Derive,
+                                proc_macro: _,
+                            } => {
                                 break;
                             }
                             _ => expn_id = expn_data.parent,
@@ -462,6 +466,10 @@ fn cfg_accessible(&mut self, expn_id: ExpnId, path: &ast::Path) -> Result<bool,
             .emit();
         Ok(false)
     }
+
+    fn get_proc_macro_quoted_span(&self, krate: CrateNum, id: usize) -> Span {
+        self.crate_loader.cstore().get_proc_macro_quoted_span_untracked(krate, id, self.session)
+    }
 }
 
 impl<'a> Resolver<'a> {
index 12c77e0c8a60d5a9d98269835f894ab0bc75a6a4..54b6a1215858153f3924214e466085eff3817aae 100644 (file)
@@ -190,7 +190,7 @@ pub fn dump_compilation_options(&mut self, input: &Input, crate_name: &str) {
         };
 
         let data = CompilationOptions {
-            directory: self.tcx.sess.working_dir.0.clone(),
+            directory: self.tcx.sess.working_dir.remapped_path_if_available().into(),
             program,
             arguments,
             output: self.save_ctxt.compilation_output(crate_name),
@@ -1112,7 +1112,7 @@ pub(crate) fn process_crate(&mut self, krate: &'tcx hir::Crate<'tcx>) {
                 name: String::new(),
                 qualname,
                 span,
-                value: filename.to_string(),
+                value: filename.prefer_remapped().to_string(),
                 children,
                 parent: None,
                 decl_id: None,
index c19c16b88a7ab08eceabe64b65b1a31991e942dc..bcd125ae01dde062e578821165469a37a3597127 100644 (file)
@@ -80,7 +80,7 @@ fn span_from_span(&self, span: Span) -> SpanData {
         let end = sm.lookup_char_pos(span.hi());
 
         SpanData {
-            file_name: start.file.name.to_string().into(),
+            file_name: start.file.name.prefer_remapped().to_string().into(),
             byte_start: span.lo().0,
             byte_end: span.hi().0,
             line_start: Row::new_one_indexed(start.line as u32),
@@ -290,7 +290,7 @@ pub fn get_item_data(&self, item: &hir::Item<'_>) -> Option<Data> {
                     name: item.ident.to_string(),
                     qualname,
                     span: self.span_from_span(item.ident.span),
-                    value: filename.to_string(),
+                    value: filename.prefer_remapped().to_string(),
                     parent: None,
                     children: m
                         .item_ids
@@ -786,7 +786,7 @@ fn get_macro_use_data(&self, span: Span) -> Option<MacroRef> {
         let callee = span.source_callee()?;
 
         let mac_name = match callee.kind {
-            ExpnKind::Macro(kind, name) => match kind {
+            ExpnKind::Macro { kind, name, proc_macro: _ } => match kind {
                 MacroKind::Bang => name,
 
                 // Ignore attribute macros, their spans are usually mangled
index edcd4925773743270fc2b97e280b6a3e1599e6d4..1947b04f441c30025dad52f7152a5ad43fc17a09 100644 (file)
@@ -16,8 +16,7 @@ pub fn new(sess: &'a Session) -> SpanUtils<'a> {
 
     pub fn make_filename_string(&self, file: &SourceFile) -> String {
         match &file.name {
-            FileName::Real(name) if !file.name_was_remapped => {
-                let path = name.local_path();
+            FileName::Real(RealFileName::LocalPath(path)) => {
                 if path.is_absolute() {
                     self.sess
                         .source_map()
@@ -27,12 +26,15 @@ pub fn make_filename_string(&self, file: &SourceFile) -> String {
                         .display()
                         .to_string()
                 } else {
-                    self.sess.working_dir.0.join(&path).display().to_string()
+                    self.sess
+                        .working_dir
+                        .remapped_path_if_available()
+                        .join(&path)
+                        .display()
+                        .to_string()
                 }
             }
-            // If the file name is already remapped, we assume the user
-            // configured it the way they wanted to, so use that directly
-            filename => filename.to_string(),
+            filename => filename.prefer_remapped().to_string(),
         }
     }
 
index 10e195f4f2548e1e197edea4372e8f5491186ada..c9f95ed1224d0d23312b94e6c8952b491dd0c110 100644 (file)
@@ -621,9 +621,9 @@ mod parse {
         true
     }
 
-    crate fn parse_linker_flavor(slote: &mut Option<LinkerFlavor>, v: Option<&str>) -> bool {
+    crate fn parse_linker_flavor(slot: &mut Option<LinkerFlavor>, v: Option<&str>) -> bool {
         match v.and_then(LinkerFlavor::from_str) {
-            Some(lf) => *slote = Some(lf),
+            Some(lf) => *slot = Some(lf),
             _ => return false,
         }
         true
@@ -1201,6 +1201,9 @@ mod parse {
         "whether ELF relocations can be relaxed"),
     relro_level: Option<RelroLevel> = (None, parse_relro_level, [TRACKED],
         "choose which RELRO level to use"),
+    simulate_remapped_rust_src_base: Option<PathBuf> = (None, parse_opt_pathbuf, [TRACKED],
+        "simulate the effect of remap-debuginfo = true at bootstrapping by remapping path \
+        to rust's source base directory. only meant for testing purposes"),
     report_delayed_bugs: bool = (false, parse_bool, [TRACKED],
         "immediately print bugs registered with `delay_span_bug` (default: no)"),
     sanitizer: SanitizerSet = (SanitizerSet::empty(), parse_sanitizers, [TRACKED],
@@ -1251,6 +1254,8 @@ mod parse {
         "select processor to schedule for (`rustc --print target-cpus` for details)"),
     thinlto: Option<bool> = (None, parse_opt_bool, [TRACKED],
         "enable ThinLTO when possible"),
+    thir_unsafeck: bool = (false, parse_bool, [TRACKED],
+        "use the work-in-progress THIR unsafety checker. NOTE: this is unsound (default: no)"),
     /// We default to 1 here since we want to behave like
     /// a sequential compiler for now. This'll likely be adjusted
     /// in the future. Note that -Zthreads=0 is the way to get
index 65d5d96aba1de5a39e0557533e82581d1cf3a65b..7b7878e9c7f4223ef501d21753524f0484e44d89 100644 (file)
@@ -137,6 +137,9 @@ pub struct ParseSess {
     pub type_ascription_path_suggestions: Lock<FxHashSet<Span>>,
     /// Whether cfg(version) should treat the current release as incomplete
     pub assume_incomplete_release: bool,
+    /// Spans passed to `proc_macro::quote_span`. Each span has a numerical
+    /// identifier represented by its position in the vector.
+    pub proc_macro_quoted_spans: Lock<Vec<Span>>,
 }
 
 impl ParseSess {
@@ -164,6 +167,7 @@ pub fn with_span_handler(handler: Handler, source_map: Lrc<SourceMap>) -> Self {
             env_depinfo: Default::default(),
             type_ascription_path_suggestions: Default::default(),
             assume_incomplete_release: false,
+            proc_macro_quoted_spans: Default::default(),
         }
     }
 
@@ -236,4 +240,14 @@ pub fn expr_parentheses_needed(
             );
         }
     }
+
+    pub fn save_proc_macro_span(&self, span: Span) -> usize {
+        let mut spans = self.proc_macro_quoted_spans.lock();
+        spans.push(span);
+        return spans.len() - 1;
+    }
+
+    pub fn proc_macro_quoted_spans(&self) -> Vec<Span> {
+        self.proc_macro_quoted_spans.lock().clone()
+    }
 }
index 66b0f5c11be4f41f6a976b75b6b7027f67acff5f..1348b02b8780fa4975f934db61b2bb47781fe04e 100644 (file)
@@ -23,8 +23,8 @@
 use rustc_errors::{Diagnostic, DiagnosticBuilder, DiagnosticId, ErrorReported};
 use rustc_lint_defs::FutureBreakage;
 pub use rustc_span::crate_disambiguator::CrateDisambiguator;
-use rustc_span::edition::Edition;
 use rustc_span::source_map::{FileLoader, MultiSpan, RealFileLoader, SourceMap, Span};
+use rustc_span::{edition::Edition, RealFileName};
 use rustc_span::{sym, SourceFileHashAlgorithm, Symbol};
 use rustc_target::asm::InlineAsmArch;
 use rustc_target::spec::{CodeModel, PanicStrategy, RelocModel, RelroLevel};
@@ -125,9 +125,8 @@ pub struct Session {
     /// The name of the root source file of the crate, in the local file system.
     /// `None` means that there is no source file.
     pub local_crate_source_file: Option<PathBuf>,
-    /// The directory the compiler has been executed in plus a flag indicating
-    /// if the value stored here has been affected by path remapping.
-    pub working_dir: (PathBuf, bool),
+    /// The directory the compiler has been executed in
+    pub working_dir: RealFileName,
 
     /// Set of `(DiagnosticId, Option<Span>, message)` tuples tracking
     /// (sub)diagnostics that have been set once, but should not be set again,
@@ -1356,7 +1355,12 @@ pub fn build_session(
     let working_dir = env::current_dir().unwrap_or_else(|e| {
         parse_sess.span_diagnostic.fatal(&format!("Current directory is invalid: {}", e)).raise()
     });
-    let working_dir = file_path_mapping.map_prefix(working_dir);
+    let (path, remapped) = file_path_mapping.map_prefix(working_dir.clone());
+    let working_dir = if remapped {
+        RealFileName::Remapped { local_path: Some(working_dir), virtual_name: path }
+    } else {
+        RealFileName::LocalPath(path)
+    };
 
     let cgu_reuse_tracker = if sopts.debugging_opts.query_dep_graph {
         CguReuseTracker::new()
@@ -1528,7 +1532,7 @@ pub enum IncrCompSession {
     InvalidBecauseOfErrors { session_directory: PathBuf },
 }
 
-pub fn early_error(output: config::ErrorOutputType, msg: &str) -> ! {
+pub fn early_error_no_abort(output: config::ErrorOutputType, msg: &str) {
     let emitter: Box<dyn Emitter + sync::Send> = match output {
         config::ErrorOutputType::HumanReadable(kind) => {
             let (short, color_config) = kind.unzip();
@@ -1540,6 +1544,10 @@ pub fn early_error(output: config::ErrorOutputType, msg: &str) -> ! {
     };
     let handler = rustc_errors::Handler::with_emitter(true, None, emitter);
     handler.struct_fatal(msg).emit();
+}
+
+pub fn early_error(output: config::ErrorOutputType, msg: &str) -> ! {
+    early_error_no_abort(output, msg);
     rustc_errors::FatalError.raise();
 }
 
index 8b611626fca89e802cd0e521f9020ee10b311208..8f3b8cc2d0efce8ebec4e3061c997c2fc72b0ddc 100644 (file)
@@ -144,7 +144,10 @@ pub fn expansion_cause(mut self) -> Option<Span> {
             let expn_data = self.expn_data();
             // Stop going up the backtrace once include! is encountered
             if expn_data.is_root()
-                || expn_data.kind == ExpnKind::Macro(MacroKind::Bang, sym::include)
+                || matches!(
+                    expn_data.kind,
+                    ExpnKind::Macro { kind: MacroKind::Bang, name: sym::include, proc_macro: _ }
+                )
             {
                 break;
             }
@@ -839,7 +842,13 @@ pub enum ExpnKind {
     /// No expansion, aka root expansion. Only `ExpnId::root()` has this kind.
     Root,
     /// Expansion produced by a macro.
-    Macro(MacroKind, Symbol),
+    Macro {
+        kind: MacroKind,
+        name: Symbol,
+        /// If `true`, this macro is a procedural macro. This
+        /// flag is only used for diagnostic purposes
+        proc_macro: bool,
+    },
     /// Transform done by the compiler on the AST.
     AstPass(AstPass),
     /// Desugaring done by the compiler during HIR lowering.
@@ -852,7 +861,7 @@ impl ExpnKind {
     pub fn descr(&self) -> String {
         match *self {
             ExpnKind::Root => kw::PathRoot.to_string(),
-            ExpnKind::Macro(macro_kind, name) => match macro_kind {
+            ExpnKind::Macro { kind, name, proc_macro: _ } => match kind {
                 MacroKind::Bang => format!("{}!", name),
                 MacroKind::Attr => format!("#[{}]", name),
                 MacroKind::Derive => format!("#[derive({})]", name),
index e0bc754424691ef68eea6f14b28f0a96f59e532c..0301b3645913ae3005f8cbc1a94d421a70e3c2fd 100644 (file)
@@ -114,52 +114,112 @@ pub fn with_default_session_globals<R>(f: impl FnOnce() -> R) -> R {
 // deserialization.
 scoped_tls::scoped_thread_local!(pub static SESSION_GLOBALS: SessionGlobals);
 
-// FIXME: Perhaps this should not implement Rustc{Decodable, Encodable}
-//
 // FIXME: We should use this enum or something like it to get rid of the
 // use of magic `/rust/1.x/...` paths across the board.
-#[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash)]
-#[derive(HashStable_Generic, Decodable, Encodable)]
+#[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd)]
+#[derive(HashStable_Generic, Decodable)]
 pub enum RealFileName {
-    Named(PathBuf),
-    /// For de-virtualized paths (namely paths into libstd that have been mapped
-    /// to the appropriate spot on the local host's file system),
-    Devirtualized {
-        /// `local_path` is the (host-dependent) local path to the file.
-        local_path: PathBuf,
+    LocalPath(PathBuf),
+    /// For remapped paths (namely paths into libstd that have been mapped
+    /// to the appropriate spot on the local host's file system, and local file
+    /// system paths that have been remapped with `FilePathMapping`),
+    Remapped {
+        /// `local_path` is the (host-dependent) local path to the file. This is
+        /// None if the file was imported from another crate
+        local_path: Option<PathBuf>,
         /// `virtual_name` is the stable path rustc will store internally within
         /// build artifacts.
         virtual_name: PathBuf,
     },
 }
 
+impl Hash for RealFileName {
+    fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
+        // To prevent #70924 from happening again we should only hash the
+        // remapped (virtualized) path if that exists. This is because
+        // virtualized paths to sysroot crates (/rust/$hash or /rust/$version)
+        // remain stable even if the corresponding local_path changes
+        self.remapped_path_if_available().hash(state)
+    }
+}
+
+// This is functionally identical to #[derive(Encodable)], with the exception of
+// an added assert statement
+impl<S: Encoder> Encodable<S> for RealFileName {
+    fn encode(&self, encoder: &mut S) -> Result<(), S::Error> {
+        encoder.emit_enum("RealFileName", |encoder| match *self {
+            RealFileName::LocalPath(ref local_path) => {
+                encoder.emit_enum_variant("LocalPath", 0, 1, |encoder| {
+                    Ok({
+                        encoder.emit_enum_variant_arg(0, |encoder| local_path.encode(encoder))?;
+                    })
+                })
+            }
+
+            RealFileName::Remapped { ref local_path, ref virtual_name } => encoder
+                .emit_enum_variant("Remapped", 1, 2, |encoder| {
+                    // For privacy and build reproducibility, we must not embed host-dependant path in artifacts
+                    // if they have been remapped by --remap-path-prefix
+                    assert!(local_path.is_none());
+                    Ok({
+                        encoder.emit_enum_variant_arg(0, |encoder| local_path.encode(encoder))?;
+                        encoder.emit_enum_variant_arg(1, |encoder| virtual_name.encode(encoder))?;
+                    })
+                }),
+        })
+    }
+}
+
 impl RealFileName {
-    /// Returns the path suitable for reading from the file system on the local host.
-    /// Avoid embedding this in build artifacts; see `stable_name()` for that.
-    pub fn local_path(&self) -> &Path {
+    /// Returns the path suitable for reading from the file system on the local host,
+    /// if this information exists.
+    /// Avoid embedding this in build artifacts; see `remapped_path_if_available()` for that.
+    pub fn local_path(&self) -> Option<&Path> {
+        match self {
+            RealFileName::LocalPath(p) => Some(p),
+            RealFileName::Remapped { local_path: p, virtual_name: _ } => {
+                p.as_ref().map(PathBuf::as_path)
+            }
+        }
+    }
+
+    /// Returns the path suitable for reading from the file system on the local host,
+    /// if this information exists.
+    /// Avoid embedding this in build artifacts; see `remapped_path_if_available()` for that.
+    pub fn into_local_path(self) -> Option<PathBuf> {
         match self {
-            RealFileName::Named(p)
-            | RealFileName::Devirtualized { local_path: p, virtual_name: _ } => &p,
+            RealFileName::LocalPath(p) => Some(p),
+            RealFileName::Remapped { local_path: p, virtual_name: _ } => p,
         }
     }
 
-    /// Returns the path suitable for reading from the file system on the local host.
-    /// Avoid embedding this in build artifacts; see `stable_name()` for that.
-    pub fn into_local_path(self) -> PathBuf {
+    /// Returns the path suitable for embedding into build artifacts. This would still
+    /// be a local path if it has not been remapped. A remapped path will not correspond
+    /// to a valid file system path: see `local_path_if_available()` for something that
+    /// is more likely to return paths into the local host file system.
+    pub fn remapped_path_if_available(&self) -> &Path {
         match self {
-            RealFileName::Named(p)
-            | RealFileName::Devirtualized { local_path: p, virtual_name: _ } => p,
+            RealFileName::LocalPath(p)
+            | RealFileName::Remapped { local_path: _, virtual_name: p } => &p,
         }
     }
 
-    /// Returns the path suitable for embedding into build artifacts. Note that
-    /// a virtualized path will not correspond to a valid file system path; see
-    /// `local_path()` for something that is more likely to return paths into the
-    /// local host file system.
-    pub fn stable_name(&self) -> &Path {
+    /// Returns the path suitable for reading from the file system on the local host,
+    /// if this information exists. Otherwise returns the remapped name.
+    /// Avoid embedding this in build artifacts; see `remapped_path_if_available()` for that.
+    pub fn local_path_if_available(&self) -> &Path {
         match self {
-            RealFileName::Named(p)
-            | RealFileName::Devirtualized { local_path: _, virtual_name: p } => &p,
+            RealFileName::LocalPath(path)
+            | RealFileName::Remapped { local_path: None, virtual_name: path }
+            | RealFileName::Remapped { local_path: Some(path), virtual_name: _ } => path,
+        }
+    }
+
+    pub fn to_string_lossy(&self, prefer_local: bool) -> Cow<'_, str> {
+        if prefer_local {
+            self.local_path_if_available().to_string_lossy()
+        } else {
+            self.remapped_path_if_available().to_string_lossy()
         }
     }
 }
@@ -188,16 +248,24 @@ pub enum FileName {
     InlineAsm(u64),
 }
 
-impl std::fmt::Display for FileName {
+impl From<PathBuf> for FileName {
+    fn from(p: PathBuf) -> Self {
+        assert!(!p.to_string_lossy().ends_with('>'));
+        FileName::Real(RealFileName::LocalPath(p))
+    }
+}
+
+pub struct FileNameDisplay<'a> {
+    inner: &'a FileName,
+    prefer_local: bool,
+}
+
+impl fmt::Display for FileNameDisplay<'_> {
     fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         use FileName::*;
-        match *self {
-            Real(RealFileName::Named(ref path)) => write!(fmt, "{}", path.display()),
-            // FIXME: might be nice to display both components of Devirtualized.
-            // But for now (to backport fix for issue #70924), best to not
-            // perturb diagnostics so its obvious test suite still works.
-            Real(RealFileName::Devirtualized { ref local_path, virtual_name: _ }) => {
-                write!(fmt, "{}", local_path.display())
+        match *self.inner {
+            Real(ref name) => {
+                write!(fmt, "{}", name.to_string_lossy(self.prefer_local))
             }
             QuoteExpansion(_) => write!(fmt, "<quote expansion>"),
             MacroExpansion(_) => write!(fmt, "<macro expansion>"),
@@ -212,10 +280,12 @@ fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
     }
 }
 
-impl From<PathBuf> for FileName {
-    fn from(p: PathBuf) -> Self {
-        assert!(!p.to_string_lossy().ends_with('>'));
-        FileName::Real(RealFileName::Named(p))
+impl FileNameDisplay<'_> {
+    pub fn to_string_lossy(&self) -> Cow<'_, str> {
+        match self.inner {
+            FileName::Real(ref inner) => inner.to_string_lossy(self.prefer_local),
+            _ => Cow::from(format!("{}", self)),
+        }
     }
 }
 
@@ -236,6 +306,16 @@ pub fn is_real(&self) -> bool {
         }
     }
 
+    pub fn prefer_remapped(&self) -> FileNameDisplay<'_> {
+        FileNameDisplay { inner: self, prefer_local: false }
+    }
+
+    // This may include transient local filesystem information.
+    // Must not be embedded in build outputs.
+    pub fn prefer_local(&self) -> FileNameDisplay<'_> {
+        FileNameDisplay { inner: self, prefer_local: true }
+    }
+
     pub fn macro_expansion_source_code(src: &str) -> FileName {
         let mut hasher = StableHasher::new();
         src.hash(&mut hasher);
@@ -394,7 +474,10 @@ pub fn from_expansion(self) -> bool {
 
     /// Returns `true` if `span` originates in a derive-macro's expansion.
     pub fn in_derive_expansion(self) -> bool {
-        matches!(self.ctxt().outer_expn_data().kind, ExpnKind::Macro(MacroKind::Derive, _))
+        matches!(
+            self.ctxt().outer_expn_data().kind,
+            ExpnKind::Macro { kind: MacroKind::Derive, name: _, proc_macro: _ }
+        )
     }
 
     #[inline]
@@ -793,7 +876,7 @@ pub fn debug_with_source_map(
     f: &mut fmt::Formatter<'_>,
     source_map: &SourceMap,
 ) -> fmt::Result {
-    write!(f, "{} ({:?})", source_map.span_to_string(span), span.ctxt())
+    write!(f, "{} ({:?})", source_map.span_to_diagnostic_string(span), span.ctxt())
 }
 
 pub fn default_span_debug(span: Span, f: &mut fmt::Formatter<'_>) -> fmt::Result {
@@ -1125,11 +1208,6 @@ pub struct SourceFile {
     /// originate from files has names between angle brackets by convention
     /// (e.g., `<anon>`).
     pub name: FileName,
-    /// `true` if the `name` field above has been modified by `--remap-path-prefix`.
-    pub name_was_remapped: bool,
-    /// The unmapped path of the file that the source came from.
-    /// Set to `None` if the `SourceFile` was imported from an external crate.
-    pub unmapped_path: Option<FileName>,
     /// The complete source code.
     pub src: Option<Lrc<String>>,
     /// The source code's hash.
@@ -1159,7 +1237,6 @@ impl<S: Encoder> Encodable<S> for SourceFile {
     fn encode(&self, s: &mut S) -> Result<(), S::Error> {
         s.emit_struct("SourceFile", 8, |s| {
             s.emit_struct_field("name", 0, |s| self.name.encode(s))?;
-            s.emit_struct_field("name_was_remapped", 1, |s| self.name_was_remapped.encode(s))?;
             s.emit_struct_field("src_hash", 2, |s| self.src_hash.encode(s))?;
             s.emit_struct_field("start_pos", 3, |s| self.start_pos.encode(s))?;
             s.emit_struct_field("end_pos", 4, |s| self.end_pos.encode(s))?;
@@ -1234,8 +1311,6 @@ impl<D: Decoder> Decodable<D> for SourceFile {
     fn decode(d: &mut D) -> Result<SourceFile, D::Error> {
         d.read_struct("SourceFile", 8, |d| {
             let name: FileName = d.read_struct_field("name", 0, |d| Decodable::decode(d))?;
-            let name_was_remapped: bool =
-                d.read_struct_field("name_was_remapped", 1, |d| Decodable::decode(d))?;
             let src_hash: SourceFileHash =
                 d.read_struct_field("src_hash", 2, |d| Decodable::decode(d))?;
             let start_pos: BytePos =
@@ -1279,8 +1354,6 @@ fn decode(d: &mut D) -> Result<SourceFile, D::Error> {
             let cnum: CrateNum = d.read_struct_field("cnum", 10, |d| Decodable::decode(d))?;
             Ok(SourceFile {
                 name,
-                name_was_remapped,
-                unmapped_path: None,
                 start_pos,
                 end_pos,
                 src: None,
@@ -1301,15 +1374,13 @@ fn decode(d: &mut D) -> Result<SourceFile, D::Error> {
 
 impl fmt::Debug for SourceFile {
     fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
-        write!(fmt, "SourceFile({})", self.name)
+        write!(fmt, "SourceFile({:?})", self.name)
     }
 }
 
 impl SourceFile {
     pub fn new(
         name: FileName,
-        name_was_remapped: bool,
-        unmapped_path: FileName,
         mut src: String,
         start_pos: BytePos,
         hash_kind: SourceFileHashAlgorithm,
@@ -1331,8 +1402,6 @@ pub fn new(
 
         SourceFile {
             name,
-            name_was_remapped,
-            unmapped_path: Some(unmapped_path),
             src: Some(Lrc::new(src)),
             src_hash,
             external_src: Lock::new(ExternalSource::Unneeded),
index e365844980b4b2f7eaf0d2cf6631bdad035f1520..0dadd4192004f638d4d9a6c43b46a08e09fa6b68 100644 (file)
 use rustc_data_structures::fx::FxHashMap;
 use rustc_data_structures::stable_hasher::StableHasher;
 use rustc_data_structures::sync::{AtomicU32, Lrc, MappedReadGuard, ReadGuard, RwLock};
-use std::cmp;
-use std::convert::TryFrom;
 use std::hash::Hash;
 use std::path::{Path, PathBuf};
 use std::sync::atomic::Ordering;
+use std::{clone::Clone, cmp};
+use std::{convert::TryFrom, unreachable};
 
 use std::fs;
 use std::io;
@@ -127,30 +127,13 @@ fn read_file(&self, path: &Path) -> io::Result<String> {
 // StableSourceFileId, perhaps built atop source_file.name_hash.
 impl StableSourceFileId {
     pub fn new(source_file: &SourceFile) -> StableSourceFileId {
-        StableSourceFileId::new_from_pieces(
-            &source_file.name,
-            source_file.name_was_remapped,
-            source_file.unmapped_path.as_ref(),
-        )
+        StableSourceFileId::new_from_name(&source_file.name)
     }
 
-    fn new_from_pieces(
-        name: &FileName,
-        name_was_remapped: bool,
-        unmapped_path: Option<&FileName>,
-    ) -> StableSourceFileId {
+    fn new_from_name(name: &FileName) -> StableSourceFileId {
         let mut hasher = StableHasher::new();
 
-        if let FileName::Real(real_name) = name {
-            // rust-lang/rust#70924: Use the stable (virtualized) name when
-            // available. (We do not want artifacts from transient file system
-            // paths for libstd to leak into our build artifacts.)
-            real_name.stable_name().hash(&mut hasher)
-        } else {
-            name.hash(&mut hasher);
-        }
-        name_was_remapped.hash(&mut hasher);
-        unmapped_path.hash(&mut hasher);
+        name.hash(&mut hasher);
 
         StableSourceFileId(hasher.finish())
     }
@@ -283,35 +266,15 @@ pub fn new_source_file(&self, filename: FileName, src: String) -> Lrc<SourceFile
 
     fn try_new_source_file(
         &self,
-        mut filename: FileName,
+        filename: FileName,
         src: String,
     ) -> Result<Lrc<SourceFile>, OffsetOverflowError> {
-        // The path is used to determine the directory for loading submodules and
-        // include files, so it must be before remapping.
         // Note that filename may not be a valid path, eg it may be `<anon>` etc,
         // but this is okay because the directory determined by `path.pop()` will
         // be empty, so the working directory will be used.
-        let unmapped_path = filename.clone();
-
-        let was_remapped;
-        if let FileName::Real(real_filename) = &mut filename {
-            match real_filename {
-                RealFileName::Named(path_to_be_remapped)
-                | RealFileName::Devirtualized {
-                    local_path: path_to_be_remapped,
-                    virtual_name: _,
-                } => {
-                    let mapped = self.path_mapping.map_prefix(path_to_be_remapped.clone());
-                    was_remapped = mapped.1;
-                    *path_to_be_remapped = mapped.0;
-                }
-            }
-        } else {
-            was_remapped = false;
-        }
+        let (filename, _) = self.path_mapping.map_filename_prefix(&filename);
 
-        let file_id =
-            StableSourceFileId::new_from_pieces(&filename, was_remapped, Some(&unmapped_path));
+        let file_id = StableSourceFileId::new_from_name(&filename);
 
         let lrc_sf = match self.source_file_by_stable_id(file_id) {
             Some(lrc_sf) => lrc_sf,
@@ -320,8 +283,6 @@ fn try_new_source_file(
 
                 let source_file = Lrc::new(SourceFile::new(
                     filename,
-                    was_remapped,
-                    unmapped_path,
                     src,
                     Pos::from_usize(start_pos),
                     self.hash_kind,
@@ -345,7 +306,6 @@ fn try_new_source_file(
     pub fn new_imported_source_file(
         &self,
         filename: FileName,
-        name_was_remapped: bool,
         src_hash: SourceFileHash,
         name_hash: u128,
         source_len: usize,
@@ -382,8 +342,6 @@ pub fn new_imported_source_file(
 
         let source_file = Lrc::new(SourceFile {
             name: filename,
-            name_was_remapped,
-            unmapped_path: None,
             src: None,
             src_hash,
             external_src: Lock::new(ExternalSource::Foreign {
@@ -411,11 +369,6 @@ pub fn new_imported_source_file(
         source_file
     }
 
-    pub fn mk_substr_filename(&self, sp: Span) -> String {
-        let pos = self.lookup_char_pos(sp.lo());
-        format!("<{}:{}:{}>", pos.file.name, pos.line, pos.col.to_usize() + 1)
-    }
-
     // If there is a doctest offset, applies it to the line.
     pub fn doctest_offset_line(&self, file: &FileName, orig: usize) -> usize {
         match file {
@@ -453,7 +406,7 @@ pub fn lookup_line(&self, pos: BytePos) -> Result<SourceFileAndLine, Lrc<SourceF
         }
     }
 
-    pub fn span_to_string(&self, sp: Span) -> String {
+    fn span_to_string(&self, sp: Span, prefer_local: bool) -> String {
         if self.files.borrow().source_files.is_empty() && sp.is_dummy() {
             return "no-location".to_string();
         }
@@ -462,7 +415,7 @@ pub fn span_to_string(&self, sp: Span) -> String {
         let hi = self.lookup_char_pos(sp.hi());
         format!(
             "{}:{}:{}: {}:{}",
-            lo.file.name,
+            if prefer_local { lo.file.name.prefer_local() } else { lo.file.name.prefer_remapped() },
             lo.line,
             lo.col.to_usize() + 1,
             hi.line,
@@ -470,16 +423,20 @@ pub fn span_to_string(&self, sp: Span) -> String {
         )
     }
 
-    pub fn span_to_filename(&self, sp: Span) -> FileName {
-        self.lookup_char_pos(sp.lo()).file.name.clone()
+    /// Format the span location suitable for embedding in build artifacts
+    pub fn span_to_embeddable_string(&self, sp: Span) -> String {
+        self.span_to_string(sp, false)
+    }
+
+    /// Format the span location to be printed in diagnostics. Must not be emitted
+    /// to build artifacts as this may leak local file paths. Use span_to_embeddable_string
+    /// for string suitable for embedding.
+    pub fn span_to_diagnostic_string(&self, sp: Span) -> String {
+        self.span_to_string(sp, true)
     }
 
-    pub fn span_to_unmapped_path(&self, sp: Span) -> FileName {
-        self.lookup_char_pos(sp.lo())
-            .file
-            .unmapped_path
-            .clone()
-            .expect("`SourceMap::span_to_unmapped_path` called for imported `SourceFile`?")
+    pub fn span_to_filename(&self, sp: Span) -> FileName {
+        self.lookup_char_pos(sp.lo()).file.name.clone()
     }
 
     pub fn is_multiline(&self, sp: Span) -> bool {
@@ -1001,7 +958,13 @@ pub fn generate_local_type_param_snippet(&self, span: Span) -> Option<(Span, Str
     }
     pub fn ensure_source_file_source_present(&self, source_file: Lrc<SourceFile>) -> bool {
         source_file.add_external_src(|| match source_file.name {
-            FileName::Real(ref name) => self.file_loader.read_file(name.local_path()).ok(),
+            FileName::Real(ref name) => {
+                if let Some(local_path) = name.local_path() {
+                    self.file_loader.read_file(local_path).ok()
+                } else {
+                    None
+                }
+            }
             _ => None,
         })
     }
@@ -1046,9 +1009,20 @@ pub fn map_prefix(&self, path: PathBuf) -> (PathBuf, bool) {
     fn map_filename_prefix(&self, file: &FileName) -> (FileName, bool) {
         match file {
             FileName::Real(realfile) => {
-                let path = realfile.local_path();
-                let (path, mapped) = self.map_prefix(path.to_path_buf());
-                (FileName::Real(RealFileName::Named(path)), mapped)
+                if let RealFileName::LocalPath(local_path) = realfile {
+                    let (mapped_path, mapped) = self.map_prefix(local_path.to_path_buf());
+                    let realfile = if mapped {
+                        RealFileName::Remapped {
+                            local_path: Some(local_path.clone()),
+                            virtual_name: mapped_path,
+                        }
+                    } else {
+                        realfile.clone()
+                    };
+                    (FileName::Real(realfile), mapped)
+                } else {
+                    unreachable!("attempted to remap an already remapped filename");
+                }
             }
             other => (other.clone(), false),
         }
index 7d814f1d82c11404e840161733f0cf2f29615447..f13979941abee7ded0399227f2ee1222a8591227 100644 (file)
@@ -193,7 +193,7 @@ fn t8() {
 fn t9() {
     let sm = init_source_map();
     let span = Span::with_root_ctxt(BytePos(12), BytePos(23));
-    let sstr = sm.span_to_string(span);
+    let sstr = sm.span_to_diagnostic_string(span);
 
     assert_eq!(sstr, "blork.rs:2:1: 2:12");
 }
@@ -229,7 +229,6 @@ fn t10() {
 
     let SourceFile {
         name,
-        name_was_remapped,
         src_hash,
         start_pos,
         end_pos,
@@ -243,7 +242,6 @@ fn t10() {
 
     let imported_src_file = sm.new_imported_source_file(
         name,
-        name_was_remapped,
         src_hash,
         name_hash,
         (end_pos - start_pos).to_usize(),
index 4c80b84e3d275be55b5bb25313739ff7e6eb5d21..c9816c2d5991346b7a452ae9b0ca9f33ec316543 100644 (file)
         receiver,
         recursion_limit,
         reexport_test_harness_main,
+        ref_unwind_safe,
         reference,
         reflect,
         reg,
         reg64,
         reg_abcd,
         reg_byte,
+        reg_nonzero,
         reg_thumb,
         register_attr,
         register_tool,
         rustc_allocator,
         rustc_allocator_nounwind,
         rustc_allow_const_fn_unstable,
-        rustc_args_required_const,
         rustc_attrs,
         rustc_builtin_macro,
         rustc_capture_analysis,
         rustc_dump_program_clauses,
         rustc_dump_user_substs,
         rustc_error,
+        rustc_evaluate_where_clauses,
         rustc_expected_cgu_reuse,
         rustc_if_this_changed,
         rustc_inherit_overflow_checks,
+        rustc_insignificant_dtor,
         rustc_layout,
         rustc_layout_scalar_valid_range_end,
         rustc_layout_scalar_valid_range_start,
         self_in_typedefs,
         self_struct_ctor,
         semitransparent,
+        send,
         send_trait,
         shl,
         shl_assign,
         unused_qualifications,
         unwind,
         unwind_attributes,
+        unwind_safe,
         unwrap,
         unwrap_or,
         use_extern_macros,
index e2268a61a42571277939de276759cc94827d1d0b..f12debb5a3412e277f6c0ca043ac240d94af8c44 100644 (file)
@@ -154,6 +154,7 @@ macro_rules! types {
 mod hexagon;
 mod mips;
 mod nvptx;
+mod powerpc;
 mod riscv;
 mod spirv;
 mod wasm;
@@ -164,6 +165,7 @@ macro_rules! types {
 pub use hexagon::{HexagonInlineAsmReg, HexagonInlineAsmRegClass};
 pub use mips::{MipsInlineAsmReg, MipsInlineAsmRegClass};
 pub use nvptx::{NvptxInlineAsmReg, NvptxInlineAsmRegClass};
+pub use powerpc::{PowerPCInlineAsmReg, PowerPCInlineAsmRegClass};
 pub use riscv::{RiscVInlineAsmReg, RiscVInlineAsmRegClass};
 pub use spirv::{SpirVInlineAsmReg, SpirVInlineAsmRegClass};
 pub use wasm::{WasmInlineAsmReg, WasmInlineAsmRegClass};
@@ -181,6 +183,7 @@ pub enum InlineAsmArch {
     Hexagon,
     Mips,
     Mips64,
+    PowerPC,
     SpirV,
     Wasm32,
 }
@@ -197,6 +200,7 @@ fn from_str(s: &str) -> Result<InlineAsmArch, ()> {
             "riscv32" => Ok(Self::RiscV32),
             "riscv64" => Ok(Self::RiscV64),
             "nvptx64" => Ok(Self::Nvptx64),
+            "powerpc" => Ok(Self::PowerPC),
             "hexagon" => Ok(Self::Hexagon),
             "mips" => Ok(Self::Mips),
             "mips64" => Ok(Self::Mips64),
@@ -225,6 +229,7 @@ pub enum InlineAsmReg {
     AArch64(AArch64InlineAsmReg),
     RiscV(RiscVInlineAsmReg),
     Nvptx(NvptxInlineAsmReg),
+    PowerPC(PowerPCInlineAsmReg),
     Hexagon(HexagonInlineAsmReg),
     Mips(MipsInlineAsmReg),
     SpirV(SpirVInlineAsmReg),
@@ -240,6 +245,7 @@ pub fn name(self) -> &'static str {
             Self::Arm(r) => r.name(),
             Self::AArch64(r) => r.name(),
             Self::RiscV(r) => r.name(),
+            Self::PowerPC(r) => r.name(),
             Self::Hexagon(r) => r.name(),
             Self::Mips(r) => r.name(),
             Self::Err => "<reg>",
@@ -252,6 +258,7 @@ pub fn reg_class(self) -> InlineAsmRegClass {
             Self::Arm(r) => InlineAsmRegClass::Arm(r.reg_class()),
             Self::AArch64(r) => InlineAsmRegClass::AArch64(r.reg_class()),
             Self::RiscV(r) => InlineAsmRegClass::RiscV(r.reg_class()),
+            Self::PowerPC(r) => InlineAsmRegClass::PowerPC(r.reg_class()),
             Self::Hexagon(r) => InlineAsmRegClass::Hexagon(r.reg_class()),
             Self::Mips(r) => InlineAsmRegClass::Mips(r.reg_class()),
             Self::Err => InlineAsmRegClass::Err,
@@ -283,6 +290,9 @@ pub fn parse(
             InlineAsmArch::Nvptx64 => {
                 Self::Nvptx(NvptxInlineAsmReg::parse(arch, has_feature, target, &name)?)
             }
+            InlineAsmArch::PowerPC => {
+                Self::PowerPC(PowerPCInlineAsmReg::parse(arch, has_feature, target, &name)?)
+            }
             InlineAsmArch::Hexagon => {
                 Self::Hexagon(HexagonInlineAsmReg::parse(arch, has_feature, target, &name)?)
             }
@@ -311,6 +321,7 @@ pub fn emit(
             Self::Arm(r) => r.emit(out, arch, modifier),
             Self::AArch64(r) => r.emit(out, arch, modifier),
             Self::RiscV(r) => r.emit(out, arch, modifier),
+            Self::PowerPC(r) => r.emit(out, arch, modifier),
             Self::Hexagon(r) => r.emit(out, arch, modifier),
             Self::Mips(r) => r.emit(out, arch, modifier),
             Self::Err => unreachable!("Use of InlineAsmReg::Err"),
@@ -323,6 +334,7 @@ pub fn overlapping_regs(self, mut cb: impl FnMut(InlineAsmReg)) {
             Self::Arm(r) => r.overlapping_regs(|r| cb(Self::Arm(r))),
             Self::AArch64(_) => cb(self),
             Self::RiscV(_) => cb(self),
+            Self::PowerPC(_) => cb(self),
             Self::Hexagon(r) => r.overlapping_regs(|r| cb(Self::Hexagon(r))),
             Self::Mips(_) => cb(self),
             Self::Err => unreachable!("Use of InlineAsmReg::Err"),
@@ -348,6 +360,7 @@ pub enum InlineAsmRegClass {
     AArch64(AArch64InlineAsmRegClass),
     RiscV(RiscVInlineAsmRegClass),
     Nvptx(NvptxInlineAsmRegClass),
+    PowerPC(PowerPCInlineAsmRegClass),
     Hexagon(HexagonInlineAsmRegClass),
     Mips(MipsInlineAsmRegClass),
     SpirV(SpirVInlineAsmRegClass),
@@ -364,6 +377,7 @@ pub fn name(self) -> Symbol {
             Self::AArch64(r) => r.name(),
             Self::RiscV(r) => r.name(),
             Self::Nvptx(r) => r.name(),
+            Self::PowerPC(r) => r.name(),
             Self::Hexagon(r) => r.name(),
             Self::Mips(r) => r.name(),
             Self::SpirV(r) => r.name(),
@@ -382,6 +396,7 @@ pub fn suggest_class(self, arch: InlineAsmArch, ty: InlineAsmType) -> Option<Sel
             Self::AArch64(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::AArch64),
             Self::RiscV(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::RiscV),
             Self::Nvptx(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::Nvptx),
+            Self::PowerPC(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::PowerPC),
             Self::Hexagon(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::Hexagon),
             Self::Mips(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::Mips),
             Self::SpirV(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::SpirV),
@@ -407,6 +422,7 @@ pub fn suggest_modifier(
             Self::AArch64(r) => r.suggest_modifier(arch, ty),
             Self::RiscV(r) => r.suggest_modifier(arch, ty),
             Self::Nvptx(r) => r.suggest_modifier(arch, ty),
+            Self::PowerPC(r) => r.suggest_modifier(arch, ty),
             Self::Hexagon(r) => r.suggest_modifier(arch, ty),
             Self::Mips(r) => r.suggest_modifier(arch, ty),
             Self::SpirV(r) => r.suggest_modifier(arch, ty),
@@ -428,6 +444,7 @@ pub fn default_modifier(self, arch: InlineAsmArch) -> Option<(char, &'static str
             Self::AArch64(r) => r.default_modifier(arch),
             Self::RiscV(r) => r.default_modifier(arch),
             Self::Nvptx(r) => r.default_modifier(arch),
+            Self::PowerPC(r) => r.default_modifier(arch),
             Self::Hexagon(r) => r.default_modifier(arch),
             Self::Mips(r) => r.default_modifier(arch),
             Self::SpirV(r) => r.default_modifier(arch),
@@ -448,6 +465,7 @@ pub fn supported_types(
             Self::AArch64(r) => r.supported_types(arch),
             Self::RiscV(r) => r.supported_types(arch),
             Self::Nvptx(r) => r.supported_types(arch),
+            Self::PowerPC(r) => r.supported_types(arch),
             Self::Hexagon(r) => r.supported_types(arch),
             Self::Mips(r) => r.supported_types(arch),
             Self::SpirV(r) => r.supported_types(arch),
@@ -467,6 +485,7 @@ pub fn parse(arch: InlineAsmArch, name: Symbol) -> Result<Self, &'static str> {
                 Self::RiscV(RiscVInlineAsmRegClass::parse(arch, name)?)
             }
             InlineAsmArch::Nvptx64 => Self::Nvptx(NvptxInlineAsmRegClass::parse(arch, name)?),
+            InlineAsmArch::PowerPC => Self::PowerPC(PowerPCInlineAsmRegClass::parse(arch, name)?),
             InlineAsmArch::Hexagon => Self::Hexagon(HexagonInlineAsmRegClass::parse(arch, name)?),
             InlineAsmArch::Mips | InlineAsmArch::Mips64 => {
                 Self::Mips(MipsInlineAsmRegClass::parse(arch, name)?)
@@ -485,6 +504,7 @@ pub fn valid_modifiers(self, arch: InlineAsmArch) -> &'static [char] {
             Self::AArch64(r) => r.valid_modifiers(arch),
             Self::RiscV(r) => r.valid_modifiers(arch),
             Self::Nvptx(r) => r.valid_modifiers(arch),
+            Self::PowerPC(r) => r.valid_modifiers(arch),
             Self::Hexagon(r) => r.valid_modifiers(arch),
             Self::Mips(r) => r.valid_modifiers(arch),
             Self::SpirV(r) => r.valid_modifiers(arch),
@@ -633,6 +653,11 @@ pub fn allocatable_registers(
             nvptx::fill_reg_map(arch, has_feature, target, &mut map);
             map
         }
+        InlineAsmArch::PowerPC => {
+            let mut map = powerpc::regclass_map();
+            powerpc::fill_reg_map(arch, has_feature, target, &mut map);
+            map
+        }
         InlineAsmArch::Hexagon => {
             let mut map = hexagon::regclass_map();
             hexagon::fill_reg_map(arch, has_feature, target, &mut map);
diff --git a/compiler/rustc_target/src/asm/powerpc.rs b/compiler/rustc_target/src/asm/powerpc.rs
new file mode 100644 (file)
index 0000000..b254e5f
--- /dev/null
@@ -0,0 +1,146 @@
+use super::{InlineAsmArch, InlineAsmType};
+use rustc_macros::HashStable_Generic;
+use std::fmt;
+
+def_reg_class! {
+    PowerPC PowerPCInlineAsmRegClass {
+        reg,
+        reg_nonzero,
+        freg,
+    }
+}
+
+impl PowerPCInlineAsmRegClass {
+    pub fn valid_modifiers(self, _arch: super::InlineAsmArch) -> &'static [char] {
+        &[]
+    }
+
+    pub fn suggest_class(self, _arch: InlineAsmArch, _ty: InlineAsmType) -> Option<Self> {
+        None
+    }
+
+    pub fn suggest_modifier(
+        self,
+        _arch: InlineAsmArch,
+        _ty: InlineAsmType,
+    ) -> Option<(char, &'static str)> {
+        None
+    }
+
+    pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> {
+        None
+    }
+
+    pub fn supported_types(
+        self,
+        _arch: InlineAsmArch,
+    ) -> &'static [(InlineAsmType, Option<&'static str>)] {
+        match self {
+            Self::reg | Self::reg_nonzero => types! { _: I8, I16, I32; },
+            Self::freg => types! { _: F32, F64; },
+        }
+    }
+}
+
+def_regs! {
+    PowerPC PowerPCInlineAsmReg PowerPCInlineAsmRegClass {
+        r0: reg = ["r0", "0"],
+        r3: reg, reg_nonzero = ["r3", "3"],
+        r4: reg, reg_nonzero = ["r4", "4"],
+        r5: reg, reg_nonzero = ["r5", "5"],
+        r6: reg, reg_nonzero = ["r6", "6"],
+        r7: reg, reg_nonzero = ["r7", "7"],
+        r8: reg, reg_nonzero = ["r8", "8"],
+        r9: reg, reg_nonzero = ["r9", "9"],
+        r10: reg, reg_nonzero = ["r10", "10"],
+        r11: reg, reg_nonzero = ["r11", "11"],
+        r12: reg, reg_nonzero = ["r12", "12"],
+        r14: reg, reg_nonzero = ["r14", "14"],
+        r15: reg, reg_nonzero = ["r15", "15"],
+        r16: reg, reg_nonzero = ["r16", "16"],
+        r17: reg, reg_nonzero = ["r17", "17"],
+        r18: reg, reg_nonzero = ["r18", "18"],
+        r19: reg, reg_nonzero = ["r19", "19"],
+        r20: reg, reg_nonzero = ["r20", "20"],
+        r21: reg, reg_nonzero = ["r21", "21"],
+        r22: reg, reg_nonzero = ["r22", "22"],
+        r23: reg, reg_nonzero = ["r23", "23"],
+        r24: reg, reg_nonzero = ["r24", "24"],
+        r25: reg, reg_nonzero = ["r25", "25"],
+        r26: reg, reg_nonzero = ["r26", "26"],
+        r27: reg, reg_nonzero = ["r27", "27"],
+        r28: reg, reg_nonzero = ["r28", "28"],
+        f0: freg = ["f0", "fr0"],
+        f1: freg = ["f1", "fr1"],
+        f2: freg = ["f2", "fr2"],
+        f3: freg = ["f3", "fr3"],
+        f4: freg = ["f4", "fr4"],
+        f5: freg = ["f5", "fr5"],
+        f6: freg = ["f6", "fr6"],
+        f7: freg = ["f7", "fr7"],
+        f8: freg = ["f8", "fr8"],
+        f9: freg = ["f9", "fr9"],
+        f10: freg = ["f10", "fr10"],
+        f11: freg = ["f11", "fr11"],
+        f12: freg = ["f12", "fr12"],
+        f13: freg = ["f13", "fr13"],
+        f14: freg = ["f14", "fr14"],
+        f15: freg = ["f15", "fr15"],
+        f16: freg = ["f16", "fr16"],
+        f17: freg = ["f17", "fr17"],
+        f18: freg = ["f18", "fr18"],
+        f19: freg = ["f19", "fr19"],
+        f20: freg = ["f20", "fr20"],
+        f21: freg = ["f21", "fr21"],
+        f22: freg = ["f22", "fr22"],
+        f23: freg = ["f23", "fr23"],
+        f24: freg = ["f24", "fr24"],
+        f25: freg = ["f25", "fr25"],
+        f26: freg = ["f26", "fr26"],
+        f27: freg = ["f27", "fr27"],
+        f28: freg = ["f28", "fr28"],
+        f29: freg = ["f29", "fr29"],
+        f30: freg = ["f30", "fr30"],
+        f31: freg = ["f31", "fr31"],
+        #error = ["r1", "1", "sp"] =>
+            "the stack pointer cannot be used as an operand for inline asm",
+        #error = ["r2", "2"] =>
+            "r2 is a system reserved register and cannot be used as an operand for inline asm",
+        #error = ["r13", "13"] =>
+            "r13 is a system reserved register and cannot be used as an operand for inline asm",
+        #error = ["r29", "29"] =>
+            "r29 is used internally by LLVM and cannot be used as an operand for inline asm",
+        #error = ["r30", "30"] =>
+            "r30 is used internally by LLVM and cannot be used as an operand for inline asm",
+        #error = ["r31", "31", "fp"] =>
+            "the frame pointer cannot be used as an operand for inline asm",
+        #error = ["lr"] =>
+            "the link register cannot be used as an operand for inline asm",
+        #error = ["ctr"] =>
+            "the counter register cannot be used as an operand for inline asm",
+        #error = ["vrsave"] =>
+            "the vrsave register cannot be used as an operand for inline asm",
+    }
+}
+
+impl PowerPCInlineAsmReg {
+    pub fn emit(
+        self,
+        out: &mut dyn fmt::Write,
+        _arch: InlineAsmArch,
+        _modifier: Option<char>,
+    ) -> fmt::Result {
+        // Strip off the leading prefix.
+        if self as u32 <= Self::r28 as u32 {
+            let index = self as u32 - Self::r28 as u32;
+            write!(out, "{}", index)
+        } else if self as u32 >= Self::f0 as u32 && self as u32 <= Self::f31 as u32 {
+            let index = self as u32 - Self::f31 as u32;
+            write!(out, "{}", index)
+        } else {
+            unreachable!()
+        }
+    }
+
+    pub fn overlapping_regs(self, mut _cb: impl FnMut(PowerPCInlineAsmReg)) {}
+}
index 4097e1577e1127372621742ecc43231cea25bef4..bf3c8643f0d6b0c7fb788ba010b1ac12a4c22240 100644 (file)
@@ -14,6 +14,7 @@
 #![feature(bool_to_option)]
 #![feature(box_patterns)]
 #![feature(drain_filter)]
+#![feature(hash_drain_filter)]
 #![feature(in_band_lifetimes)]
 #![feature(iter_zip)]
 #![feature(never_type)]
index 08d452900c8e18a69b5fdbdf2f33fd9c7526e7b6..a292de148a67aaa231e0fb44b5f7713d5dc15915 100644 (file)
@@ -636,8 +636,8 @@ fn evaluate_trait_predicate_recursively<'o>(
 
         if let Some(result) = stack.cache().get_provisional(fresh_trait_ref) {
             debug!(?result, "PROVISIONAL CACHE HIT");
-            stack.update_reached_depth(stack.cache().current_reached_depth());
-            return Ok(result);
+            stack.update_reached_depth(result.reached_depth);
+            return Ok(result.result);
         }
 
         // Check if this is a match for something already on the
@@ -661,7 +661,7 @@ fn evaluate_trait_predicate_recursively<'o>(
             debug!(?result, "CACHE MISS");
             self.insert_evaluation_cache(obligation.param_env, fresh_trait_ref, dep_node, result);
 
-            stack.cache().on_completion(stack.depth, |fresh_trait_ref, provisional_result| {
+            stack.cache().on_completion(stack.dfn, |fresh_trait_ref, provisional_result| {
                 self.insert_evaluation_cache(
                     obligation.param_env,
                     fresh_trait_ref,
@@ -2162,7 +2162,7 @@ fn iter(&'o self) -> TraitObligationStackList<'o, 'tcx> {
     /// required accessing something from the stack at depth `reached_depth`.
     fn update_reached_depth(&self, reached_depth: usize) {
         assert!(
-            self.depth > reached_depth,
+            self.depth >= reached_depth,
             "invoked `update_reached_depth` with something under this stack: \
              self.depth={} reached_depth={}",
             self.depth,
@@ -2235,23 +2235,6 @@ struct ProvisionalEvaluationCache<'tcx> {
     /// next "depth first number" to issue -- just a counter
     dfn: Cell<usize>,
 
-    /// Stores the "coldest" depth (bottom of stack) reached by any of
-    /// the evaluation entries. The idea here is that all things in the provisional
-    /// cache are always dependent on *something* that is colder in the stack:
-    /// therefore, if we add a new entry that is dependent on something *colder still*,
-    /// we have to modify the depth for all entries at once.
-    ///
-    /// Example:
-    ///
-    /// Imagine we have a stack `A B C D E` (with `E` being the top of
-    /// the stack).  We cache something with depth 2, which means that
-    /// it was dependent on C.  Then we pop E but go on and process a
-    /// new node F: A B C D F.  Now F adds something to the cache with
-    /// depth 1, meaning it is dependent on B.  Our original cache
-    /// entry is also dependent on B, because there is a path from E
-    /// to C and then from C to F and from F to B.
-    reached_depth: Cell<usize>,
-
     /// Map from cache key to the provisionally evaluated thing.
     /// The cache entries contain the result but also the DFN in which they
     /// were added. The DFN is used to clear out values on failure.
@@ -2275,12 +2258,13 @@ struct ProvisionalEvaluationCache<'tcx> {
 #[derive(Copy, Clone, Debug)]
 struct ProvisionalEvaluation {
     from_dfn: usize,
+    reached_depth: usize,
     result: EvaluationResult,
 }
 
 impl<'tcx> Default for ProvisionalEvaluationCache<'tcx> {
     fn default() -> Self {
-        Self { dfn: Cell::new(0), reached_depth: Cell::new(usize::MAX), map: Default::default() }
+        Self { dfn: Cell::new(0), map: Default::default() }
     }
 }
 
@@ -2295,22 +2279,17 @@ fn next_dfn(&self) -> usize {
     /// Check the provisional cache for any result for
     /// `fresh_trait_ref`. If there is a hit, then you must consider
     /// it an access to the stack slots at depth
-    /// `self.current_reached_depth()` and above.
-    fn get_provisional(&self, fresh_trait_ref: ty::PolyTraitRef<'tcx>) -> Option<EvaluationResult> {
+    /// `reached_depth` (from the returned value).
+    fn get_provisional(
+        &self,
+        fresh_trait_ref: ty::PolyTraitRef<'tcx>,
+    ) -> Option<ProvisionalEvaluation> {
         debug!(
             ?fresh_trait_ref,
-            reached_depth = ?self.reached_depth.get(),
             "get_provisional = {:#?}",
             self.map.borrow().get(&fresh_trait_ref),
         );
-        Some(self.map.borrow().get(&fresh_trait_ref)?.result)
-    }
-
-    /// Current value of the `reached_depth` counter -- all the
-    /// provisional cache entries are dependent on the item at this
-    /// depth.
-    fn current_reached_depth(&self) -> usize {
-        self.reached_depth.get()
+        Some(self.map.borrow().get(&fresh_trait_ref)?.clone())
     }
 
     /// Insert a provisional result into the cache. The result came
@@ -2324,13 +2303,31 @@ fn insert_provisional(
         fresh_trait_ref: ty::PolyTraitRef<'tcx>,
         result: EvaluationResult,
     ) {
-        debug!(?from_dfn, ?reached_depth, ?fresh_trait_ref, ?result, "insert_provisional");
-        let r_d = self.reached_depth.get();
-        self.reached_depth.set(r_d.min(reached_depth));
+        debug!(?from_dfn, ?fresh_trait_ref, ?result, "insert_provisional");
 
-        debug!(reached_depth = self.reached_depth.get());
+        let mut map = self.map.borrow_mut();
+
+        // Subtle: when we complete working on the DFN `from_dfn`, anything
+        // that remains in the provisional cache must be dependent on some older
+        // stack entry than `from_dfn`. We have to update their depth with our transitive
+        // depth in that case or else it would be referring to some popped note.
+        //
+        // Example:
+        // A (reached depth 0)
+        //   ...
+        //      B // depth 1 -- reached depth = 0
+        //          C // depth 2 -- reached depth = 1 (should be 0)
+        //              B
+        //          A // depth 0
+        //   D (reached depth 1)
+        //      C (cache -- reached depth = 2)
+        for (_k, v) in &mut *map {
+            if v.from_dfn >= from_dfn {
+                v.reached_depth = reached_depth.min(v.reached_depth);
+            }
+        }
 
-        self.map.borrow_mut().insert(fresh_trait_ref, ProvisionalEvaluation { from_dfn, result });
+        map.insert(fresh_trait_ref, ProvisionalEvaluation { from_dfn, reached_depth, result });
     }
 
     /// Invoked when the node with dfn `dfn` does not get a successful
@@ -2358,25 +2355,40 @@ fn on_failure(&self, dfn: usize) {
     /// was a failure, then `on_failure` should have been invoked
     /// already). The callback `op` will be invoked for each
     /// provisional entry that we can now confirm.
+    ///
+    /// Note that we may still have provisional cache items remaining
+    /// in the cache when this is done. For example, if there is a
+    /// cycle:
+    ///
+    /// * A depends on...
+    ///     * B depends on A
+    ///     * C depends on...
+    ///         * D depends on C
+    ///     * ...
+    ///
+    /// Then as we complete the C node we will have a provisional cache
+    /// with results for A, B, C, and D. This method would clear out
+    /// the C and D results, but leave A and B provisional.
+    ///
+    /// This is determined based on the DFN: we remove any provisional
+    /// results created since `dfn` started (e.g., in our example, dfn
+    /// would be 2, representing the C node, and hence we would
+    /// remove the result for D, which has DFN 3, but not the results for
+    /// A and B, which have DFNs 0 and 1 respectively).
     fn on_completion(
         &self,
-        depth: usize,
+        dfn: usize,
         mut op: impl FnMut(ty::PolyTraitRef<'tcx>, EvaluationResult),
     ) {
-        debug!(?depth, reached_depth = ?self.reached_depth.get(), "on_completion");
+        debug!(?dfn, "on_completion");
 
-        if self.reached_depth.get() < depth {
-            debug!("on_completion: did not yet reach depth to complete");
-            return;
-        }
-
-        for (fresh_trait_ref, eval) in self.map.borrow_mut().drain() {
+        for (fresh_trait_ref, eval) in
+            self.map.borrow_mut().drain_filter(|_k, eval| eval.from_dfn >= dfn)
+        {
             debug!(?fresh_trait_ref, ?eval, "on_completion");
 
             op(fresh_trait_ref, eval.result);
         }
-
-        self.reached_depth.set(usize::MAX);
     }
 }
 
index 64f82817d3944e4636237b96c744f4d9d38e3bd3..bc8f10e15db8cb180ccaaf1e7898021490549763 100644 (file)
@@ -6,7 +6,7 @@
 use rustc_middle::ty::util::{needs_drop_components, AlwaysRequiresDrop};
 use rustc_middle::ty::{self, Ty, TyCtxt};
 use rustc_session::Limit;
-use rustc_span::DUMMY_SP;
+use rustc_span::{sym, DUMMY_SP};
 
 type NeedsDropResult<T> = Result<T, AlwaysRequiresDrop>;
 
@@ -21,6 +21,19 @@ fn needs_drop_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>
     res
 }
 
+fn has_significant_drop_raw<'tcx>(
+    tcx: TyCtxt<'tcx>,
+    query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>,
+) -> bool {
+    let significant_drop_fields =
+        move |adt_def: &ty::AdtDef| tcx.adt_significant_drop_tys(adt_def.did).map(|tys| tys.iter());
+    let res = NeedsDropTypes::new(tcx, query.param_env, query.value, significant_drop_fields)
+        .next()
+        .is_some();
+    debug!("has_significant_drop_raw({:?}) = {:?}", query, res);
+    res
+}
+
 struct NeedsDropTypes<'tcx, F> {
     tcx: TyCtxt<'tcx>,
     param_env: ty::ParamEnv<'tcx>,
@@ -155,12 +168,20 @@ fn next(&mut self) -> Option<NeedsDropResult<Ty<'tcx>>> {
     }
 }
 
-fn adt_drop_tys(tcx: TyCtxt<'_>, def_id: DefId) -> Result<&ty::List<Ty<'_>>, AlwaysRequiresDrop> {
+// This is a helper function for `adt_drop_tys` and `adt_significant_drop_tys`.
+// Depending on the implentation of `adt_has_dtor`, it is used to check if the
+// ADT has a destructor or if the ADT only has a significant destructor. For
+// understanding significant destructor look at `adt_significant_drop_tys`.
+fn adt_drop_tys_helper(
+    tcx: TyCtxt<'_>,
+    def_id: DefId,
+    adt_has_dtor: impl Fn(&ty::AdtDef) -> bool,
+) -> Result<&ty::List<Ty<'_>>, AlwaysRequiresDrop> {
     let adt_components = move |adt_def: &ty::AdtDef| {
         if adt_def.is_manually_drop() {
             debug!("adt_drop_tys: `{:?}` is manually drop", adt_def);
             return Ok(Vec::new().into_iter());
-        } else if adt_def.destructor(tcx).is_some() {
+        } else if adt_has_dtor(adt_def) {
             debug!("adt_drop_tys: `{:?}` implements `Drop`", adt_def);
             return Err(AlwaysRequiresDrop);
         } else if adt_def.is_union() {
@@ -179,6 +200,30 @@ fn adt_drop_tys(tcx: TyCtxt<'_>, def_id: DefId) -> Result<&ty::List<Ty<'_>>, Alw
     res.map(|components| tcx.intern_type_list(&components))
 }
 
+fn adt_drop_tys(tcx: TyCtxt<'_>, def_id: DefId) -> Result<&ty::List<Ty<'_>>, AlwaysRequiresDrop> {
+    let adt_has_dtor = |adt_def: &ty::AdtDef| adt_def.destructor(tcx).is_some();
+    adt_drop_tys_helper(tcx, def_id, adt_has_dtor)
+}
+
+fn adt_significant_drop_tys(
+    tcx: TyCtxt<'_>,
+    def_id: DefId,
+) -> Result<&ty::List<Ty<'_>>, AlwaysRequiresDrop> {
+    let adt_has_dtor = |adt_def: &ty::AdtDef| {
+        adt_def
+            .destructor(tcx)
+            .map(|dtor| !tcx.has_attr(dtor.did, sym::rustc_insignificant_dtor))
+            .unwrap_or(false)
+    };
+    adt_drop_tys_helper(tcx, def_id, adt_has_dtor)
+}
+
 pub(crate) fn provide(providers: &mut ty::query::Providers) {
-    *providers = ty::query::Providers { needs_drop_raw, adt_drop_tys, ..*providers };
+    *providers = ty::query::Providers {
+        needs_drop_raw,
+        has_significant_drop_raw,
+        adt_drop_tys,
+        adt_significant_drop_tys,
+        ..*providers
+    };
 }
index 077375c7c3b4f956d4193e0f52a6794e3d7b8fb4..456f2a908a8c1c764fe0d64cb460942b7d8d841a 100644 (file)
@@ -4,7 +4,7 @@
     GenericArgCountResult, GenericArgPosition,
 };
 use crate::errors::AssocTypeBindingNotAllowed;
-use crate::structured_errors::{StructuredDiagnostic, WrongNumberOfGenericArgs};
+use crate::structured_errors::{GenericArgsInfo, StructuredDiagnostic, WrongNumberOfGenericArgs};
 use rustc_ast::ast::ParamKindOrd;
 use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorReported};
 use rustc_hir as hir;
@@ -438,6 +438,11 @@ pub(crate) fn check_generic_arg_count(
         has_self: bool,
         infer_args: bool,
     ) -> GenericArgCountResult {
+        debug!(
+            "check_generic_arg_count(span: {:?}, def_id: {:?}, seg: {:?}, gen_params: {:?}, gen_args: {:?})",
+            span, def_id, seg, gen_params, gen_args
+        );
+
         let default_counts = gen_params.own_defaults();
         let param_counts = gen_params.own_counts();
         let named_type_param_count = param_counts.types - has_self as usize;
@@ -453,63 +458,116 @@ pub(crate) fn check_generic_arg_count(
 
         let mut invalid_args = vec![];
 
-        let mut check_generics =
-            |kind, expected_min, expected_max, provided, params_offset, args_offset, silent| {
+        let mut check_lifetime_args = |min_expected_args: usize,
+                                       max_expected_args: usize,
+                                       provided_args: usize,
+                                       late_bounds_ignore: bool|
+         -> bool {
+            if (min_expected_args..=max_expected_args).contains(&provided_args) {
+                return true;
+            }
+
+            if late_bounds_ignore {
+                return true;
+            }
+
+            if provided_args > max_expected_args {
+                invalid_args.extend(
+                    gen_args.args[max_expected_args..provided_args].iter().map(|arg| arg.span()),
+                );
+            };
+
+            let gen_args_info = if provided_args > min_expected_args {
+                invalid_args.extend(
+                    gen_args.args[min_expected_args..provided_args].iter().map(|arg| arg.span()),
+                );
+                let num_redundant_args = provided_args - min_expected_args;
+                GenericArgsInfo::ExcessLifetimes { num_redundant_args }
+            } else {
+                let num_missing_args = min_expected_args - provided_args;
+                GenericArgsInfo::MissingLifetimes { num_missing_args }
+            };
+
+            WrongNumberOfGenericArgs::new(
+                tcx,
+                gen_args_info,
+                seg,
+                gen_params,
+                has_self as usize,
+                gen_args,
+                def_id,
+            )
+            .diagnostic()
+            .emit();
+
+            false
+        };
+
+        let min_expected_lifetime_args = if infer_lifetimes { 0 } else { param_counts.lifetimes };
+        let max_expected_lifetime_args = param_counts.lifetimes;
+        let num_provided_lifetime_args = arg_counts.lifetimes;
+
+        let lifetimes_correct = check_lifetime_args(
+            min_expected_lifetime_args,
+            max_expected_lifetime_args,
+            num_provided_lifetime_args,
+            explicit_late_bound == ExplicitLateBound::Yes,
+        );
+
+        let mut check_types_and_consts =
+            |expected_min, expected_max, provided, params_offset, args_offset| {
+                debug!(
+                    "check_types_and_consts(expected_min: {:?}, expected_max: {:?}, \
+                        provided: {:?}, params_offset: {:?}, args_offset: {:?}",
+                    expected_min, expected_max, provided, params_offset, args_offset
+                );
                 if (expected_min..=expected_max).contains(&provided) {
                     return true;
                 }
 
-                if silent {
-                    return true;
-                }
+                let num_default_params = expected_max - expected_min;
 
-                if provided > expected_max {
+                let gen_args_info = if provided > expected_max {
                     invalid_args.extend(
                         gen_args.args[args_offset + expected_max..args_offset + provided]
                             .iter()
                             .map(|arg| arg.span()),
                     );
+                    let num_redundant_args = provided - expected_max;
+
+                    GenericArgsInfo::ExcessTypesOrConsts {
+                        num_redundant_args,
+                        num_default_params,
+                        args_offset,
+                    }
+                } else {
+                    let num_missing_args = expected_max - provided;
+
+                    GenericArgsInfo::MissingTypesOrConsts {
+                        num_missing_args,
+                        num_default_params,
+                        args_offset,
+                    }
                 };
 
-                WrongNumberOfGenericArgs {
+                debug!("gen_args_info: {:?}", gen_args_info);
+
+                WrongNumberOfGenericArgs::new(
                     tcx,
-                    kind,
-                    expected_min,
-                    expected_max,
-                    provided,
-                    params_offset,
-                    args_offset,
-                    path_segment: seg,
+                    gen_args_info,
+                    seg,
                     gen_params,
+                    params_offset,
                     gen_args,
                     def_id,
-                    span,
-                }
+                )
                 .diagnostic()
                 .emit();
 
                 false
             };
 
-        let lifetimes_correct = check_generics(
-            "lifetime",
-            if infer_lifetimes { 0 } else { param_counts.lifetimes },
-            param_counts.lifetimes,
-            arg_counts.lifetimes,
-            has_self as usize,
-            0,
-            explicit_late_bound == ExplicitLateBound::Yes,
-        );
-
         let args_correct = {
-            let kind = if param_counts.consts + arg_counts.consts == 0 {
-                "type"
-            } else if named_type_param_count + arg_counts.types == 0 {
-                "const"
-            } else {
-                "generic"
-            };
-
             let expected_min = if infer_args {
                 0
             } else {
@@ -517,15 +575,15 @@ pub(crate) fn check_generic_arg_count(
                     - default_counts.types
                     - default_counts.consts
             };
+            debug!("expected_min: {:?}", expected_min);
+            debug!("arg_counts.lifetimes: {:?}", arg_counts.lifetimes);
 
-            check_generics(
-                kind,
+            check_types_and_consts(
                 expected_min,
                 param_counts.consts + named_type_param_count,
                 arg_counts.consts + arg_counts.types,
                 param_counts.lifetimes + has_self as usize,
                 arg_counts.lifetimes,
-                false,
             )
         };
 
index 2f2e90e4bd66fcf465c165478ddc1e29f67f8a8f..5285c1c85987093c20414bf0a2882313ffc3852f 100644 (file)
@@ -120,6 +120,7 @@ pub enum SizedByDefault {
 
 #[derive(Debug)]
 struct ConvertedBinding<'a, 'tcx> {
+    hir_id: hir::HirId,
     item_name: Ident,
     kind: ConvertedBindingKind<'a, 'tcx>,
     gen_args: &'a GenericArgs<'a>,
@@ -431,6 +432,7 @@ fn provided_kind(
                                 param.def_id,
                                 Some(arg.id()),
                                 arg.span(),
+                                None,
                                 |_, _| {
                                     // Default generic parameters may not be marked
                                     // with stability attributes, i.e. when the
@@ -590,6 +592,7 @@ fn create_assoc_bindings_for_generic_args<'a>(
                     }
                 };
                 ConvertedBinding {
+                    hir_id: binding.hir_id,
                     item_name: binding.ident,
                     kind,
                     gen_args: binding.gen_args,
@@ -609,6 +612,10 @@ fn create_assoc_bindings_for_generic_args<'a>(
         item_segment: &hir::PathSegment<'_>,
         parent_substs: SubstsRef<'tcx>,
     ) -> SubstsRef<'tcx> {
+        debug!(
+            "create_substs_for_associated_item(span: {:?}, item_def_id: {:?}, item_segment: {:?}",
+            span, item_def_id, item_segment
+        );
         if tcx.generics_of(item_def_id).params.is_empty() {
             self.prohibit_generics(slice::from_ref(item_segment));
 
@@ -1053,7 +1060,7 @@ fn add_predicates_for_ast_type_binding(
                 .span_label(binding.span, "private associated type")
                 .emit();
         }
-        tcx.check_stability(assoc_ty.def_id, Some(hir_ref_id), binding.span);
+        tcx.check_stability(assoc_ty.def_id, Some(hir_ref_id), binding.span, None);
 
         if !speculative {
             dup_bindings
@@ -1071,9 +1078,10 @@ fn add_predicates_for_ast_type_binding(
 
         // Include substitutions for generic parameters of associated types
         let projection_ty = candidate.map_bound(|trait_ref| {
+            let ident = Ident::new(assoc_ty.ident.name, binding.item_name.span);
             let item_segment = hir::PathSegment {
-                ident: assoc_ty.ident,
-                hir_id: None,
+                ident,
+                hir_id: Some(binding.hir_id),
                 res: None,
                 args: Some(binding.gen_args),
                 infer_args: false,
@@ -1659,7 +1667,7 @@ pub fn associated_path_to_ty(
                     .find(|vd| tcx.hygienic_eq(assoc_ident, vd.ident, adt_def.did));
                 if let Some(variant_def) = variant_def {
                     if permit_variants {
-                        tcx.check_stability(variant_def.def_id, Some(hir_ref_id), span);
+                        tcx.check_stability(variant_def.def_id, Some(hir_ref_id), span, None);
                         self.prohibit_generics(slice::from_ref(assoc_segment));
                         return Ok((qself_ty, DefKind::Variant, variant_def.def_id));
                     } else {
@@ -1779,7 +1787,7 @@ pub fn associated_path_to_ty(
                 .span_label(span, &format!("private {}", kind))
                 .emit();
         }
-        tcx.check_stability(item.def_id, Some(hir_ref_id), span);
+        tcx.check_stability(item.def_id, Some(hir_ref_id), span, None);
 
         if let Some(variant_def_id) = variant_resolution {
             tcx.struct_span_lint_hir(AMBIGUOUS_ASSOCIATED_ITEMS, hir_ref_id, span, |lint| {
index b48102e0fc9b8c900888abf5ebb9393120924d8d..cb8f336721ad6a4d06c1c175e493e4575e803b32 100644 (file)
@@ -6,8 +6,14 @@
 use rustc_hir as hir;
 use rustc_hir::def::{Namespace, Res};
 use rustc_hir::def_id::{DefId, LOCAL_CRATE};
-use rustc_infer::infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
-use rustc_infer::{infer, traits};
+use rustc_infer::{
+    infer,
+    traits::{self, Obligation},
+};
+use rustc_infer::{
+    infer::type_variable::{TypeVariableOrigin, TypeVariableOriginKind},
+    traits::ObligationCause,
+};
 use rustc_middle::ty::adjustment::{
     Adjust, Adjustment, AllowTwoPhase, AutoBorrow, AutoBorrowMutability,
 };
@@ -17,6 +23,7 @@
 use rustc_span::Span;
 use rustc_target::spec::abi;
 use rustc_trait_selection::autoderef::Autoderef;
+use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
 use std::iter;
 
 /// Checks that it is legal to call methods of the trait corresponding
@@ -294,7 +301,34 @@ fn confirm_builtin_call(
         expected: Expectation<'tcx>,
     ) -> Ty<'tcx> {
         let (fn_sig, def_id) = match *callee_ty.kind() {
-            ty::FnDef(def_id, _) => (callee_ty.fn_sig(self.tcx), Some(def_id)),
+            ty::FnDef(def_id, subst) => {
+                // Unit testing: function items annotated with
+                // `#[rustc_evaluate_where_clauses]` trigger special output
+                // to let us test the trait evaluation system.
+                if self.tcx.has_attr(def_id, sym::rustc_evaluate_where_clauses) {
+                    let predicates = self.tcx.predicates_of(def_id);
+                    let predicates = predicates.instantiate(self.tcx, subst);
+                    for (predicate, predicate_span) in
+                        predicates.predicates.iter().zip(&predicates.spans)
+                    {
+                        let obligation = Obligation::new(
+                            ObligationCause::dummy_with_span(callee_expr.span),
+                            self.param_env,
+                            predicate.clone(),
+                        );
+                        let result = self.infcx.evaluate_obligation(&obligation);
+                        self.tcx
+                            .sess
+                            .struct_span_err(
+                                callee_expr.span,
+                                &format!("evaluate({:?}) = {:?}", predicate, result),
+                            )
+                            .span_label(*predicate_span, "predicate")
+                            .emit();
+                    }
+                }
+                (callee_ty.fn_sig(self.tcx), Some(def_id))
+            }
             ty::FnPtr(sig) => (sig, None),
             ref t => {
                 let mut unit_variant = None;
index 991c2ba693d69edc5dbb7736e706cc0478213011..d0cbb58fb10eb8d5cecf377d5bd4c9e652426508 100644 (file)
@@ -1230,7 +1230,7 @@ fn check_expr_struct_fields(
                 // struct-like enums (yet...), but it's definitely not
                 // a bug to have constructed one.
                 if adt_kind != AdtKind::Enum {
-                    tcx.check_stability(v_field.did, Some(expr_id), field.span);
+                    tcx.check_stability(v_field.did, Some(expr_id), field.span, None);
                 }
 
                 self.field_ty(field.span, v_field, substs)
@@ -1571,7 +1571,7 @@ fn check_field(
                             self.apply_adjustments(base, adjustments);
                             self.register_predicates(autoderef.into_obligations());
 
-                            self.tcx.check_stability(field.did, Some(expr.hir_id), expr.span);
+                            self.tcx.check_stability(field.did, Some(expr.hir_id), expr.span, None);
                             return field_ty;
                         }
                         private_candidate = Some((base_def.did, field_ty));
index 4d6caf07236e29593db7c30d89fafea47c1b40c6..4de8216884a6877ca81dc6d3bd5f875795973cdf 100644 (file)
@@ -1537,8 +1537,6 @@ fn inferred_kind(
             }
         }
 
-        self.check_rustc_args_require_const(def_id, hir_id, span);
-
         debug!("instantiate_value_path: type of {:?} is {:?}", hir_id, ty_substituted);
         self.write_substs(hir_id, substs);
 
index 3417bc0197253221379302eea24eb442b3952485..49aea19c8d099970e72e2ec57fb5ddbc58478f0c 100644 (file)
@@ -18,7 +18,7 @@
 use rustc_middle::ty::fold::TypeFoldable;
 use rustc_middle::ty::{self, Ty};
 use rustc_session::Session;
-use rustc_span::symbol::{sym, Ident};
+use rustc_span::symbol::Ident;
 use rustc_span::{self, MultiSpan, Span};
 use rustc_trait_selection::traits::{self, ObligationCauseCode, StatementAsExpression};
 
@@ -720,34 +720,6 @@ pub(in super::super) fn check_block_with_expected(
         ty
     }
 
-    pub(in super::super) fn check_rustc_args_require_const(
-        &self,
-        def_id: DefId,
-        hir_id: hir::HirId,
-        span: Span,
-    ) {
-        // We're only interested in functions tagged with
-        // #[rustc_args_required_const], so ignore anything that's not.
-        if !self.tcx.has_attr(def_id, sym::rustc_args_required_const) {
-            return;
-        }
-
-        // If our calling expression is indeed the function itself, we're good!
-        // If not, generate an error that this can only be called directly.
-        if let Node::Expr(expr) = self.tcx.hir().get(self.tcx.hir().get_parent_node(hir_id)) {
-            if let ExprKind::Call(ref callee, ..) = expr.kind {
-                if callee.hir_id == hir_id {
-                    return;
-                }
-            }
-        }
-
-        self.tcx.sess.span_err(
-            span,
-            "this function can only be invoked directly, not through a function pointer",
-        );
-    }
-
     /// A common error is to add an extra semicolon:
     ///
     /// ```
index bd7ffd057b466f9038fcd70f17eb40d4778c8248..0b1129a6312498a975f1c3f79c98d6ef2656d3e9 100644 (file)
@@ -205,7 +205,7 @@ pub fn lookup_method(
                 .insert(*import_id);
         }
 
-        self.tcx.check_stability(pick.item.def_id, Some(call_expr.hir_id), span);
+        self.tcx.check_stability(pick.item.def_id, Some(call_expr.hir_id), span, None);
 
         let result =
             self.confirm_method(span, self_expr, call_expr, self_ty, pick.clone(), segment);
@@ -445,7 +445,7 @@ pub fn resolve_ufcs(
                     // them as well. It's ok to use the variant's id as a ctor id since an
                     // error will be reported on any use of such resolution anyway.
                     let ctor_def_id = variant_def.ctor_def_id.unwrap_or(variant_def.def_id);
-                    tcx.check_stability(ctor_def_id, Some(expr_id), span);
+                    tcx.check_stability(ctor_def_id, Some(expr_id), span, Some(method_name.span));
                     return Ok((
                         DefKind::Ctor(CtorOf::Variant, variant_def.ctor_kind),
                         ctor_def_id,
@@ -475,7 +475,7 @@ pub fn resolve_ufcs(
 
         let def_kind = pick.item.kind.as_def_kind();
         debug!("resolve_ufcs: def_kind={:?}, def_id={:?}", def_kind, pick.item.def_id);
-        tcx.check_stability(pick.item.def_id, Some(expr_id), span);
+        tcx.check_stability(pick.item.def_id, Some(expr_id), span, Some(method_name.span));
         Ok((def_kind, pick.item.def_id))
     }
 
index c79743f2d7363d48c862c624409f825327fabd05..440e0f4e1a2acfbbaf27c96a01fe94cf766a7db6 100644 (file)
@@ -1286,7 +1286,7 @@ fn consider_candidates<'b, ProbesIter>(
         if let Some(uc) = unstable_candidates {
             applicable_candidates.retain(|&(p, _)| {
                 if let stability::EvalResult::Deny { feature, .. } =
-                    self.tcx.eval_stability(p.item.def_id, None, self.span)
+                    self.tcx.eval_stability(p.item.def_id, None, self.span, None)
                 {
                     uc.push((p, feature));
                     return false;
index cb7589318d2a7ff892de68fd2145ce125fc524bf..994206bd419347a8e974ce65c23dfb2b4bc27811 100644 (file)
@@ -545,8 +545,9 @@ fn typeck_with_fallback<'tcx>(
                             kind: TypeVariableOriginKind::TypeInference,
                             span,
                         }),
-                        Node::Expr(&hir::Expr { kind: hir::ExprKind::InlineAsm(ia), .. })
-                            if ia.operands.iter().any(|(op, _op_sp)| match op {
+                        Node::Expr(&hir::Expr { kind: hir::ExprKind::InlineAsm(asm), .. })
+                        | Node::Item(&hir::Item { kind: hir::ItemKind::GlobalAsm(asm), .. })
+                            if asm.operands.iter().any(|(op, _op_sp)| match op {
                                 hir::InlineAsmOperand::Const { anon_const } => {
                                     anon_const.hir_id == id
                                 }
index 53593b9bab4b82a184704ebbc1c2d611e91e1109..3ac760e23634e33f0d57142d4148e99602b84724 100644 (file)
@@ -958,7 +958,12 @@ fn check_pat_tuple_struct(
                 let field_ty = self.field_ty(subpat.span, &variant.fields[i], substs);
                 self.check_pat(&subpat, field_ty, def_bm, TopInfo { parent_pat: Some(&pat), ..ti });
 
-                self.tcx.check_stability(variant.fields[i].did, Some(pat.hir_id), subpat.span);
+                self.tcx.check_stability(
+                    variant.fields[i].did,
+                    Some(pat.hir_id),
+                    subpat.span,
+                    None,
+                );
             }
         } else {
             // Pattern has wrong number of fields.
@@ -1192,7 +1197,7 @@ fn check_struct_pat_fields(
                         .get(&ident)
                         .map(|(i, f)| {
                             self.write_field_index(field.hir_id, *i);
-                            self.tcx.check_stability(f.did, Some(pat.hir_id), span);
+                            self.tcx.check_stability(f.did, Some(pat.hir_id), span, None);
                             self.field_ty(span, f, substs)
                         })
                         .unwrap_or_else(|| {
index 751eebb9f95644ed2eaa0b0271f2122f6a475ab8..ff506ef8727b9e3bd5e58e9a4b2e4073da9c466c 100644 (file)
 use rustc_infer::infer::UpvarRegion;
 use rustc_middle::hir::place::{Place, PlaceBase, PlaceWithHirId, Projection, ProjectionKind};
 use rustc_middle::mir::FakeReadCause;
-use rustc_middle::ty::{self, Ty, TyCtxt, TypeckResults, UpvarSubsts};
+use rustc_middle::ty::{self, TraitRef, Ty, TyCtxt, TypeckResults, UpvarSubsts};
 use rustc_session::lint;
 use rustc_span::sym;
 use rustc_span::{MultiSpan, Span, Symbol};
+use rustc_trait_selection::traits::{Obligation, ObligationCause};
 
+use rustc_data_structures::stable_set::FxHashSet;
 use rustc_index::vec::Idx;
 use rustc_target::abi::VariantIdx;
 
@@ -168,7 +170,8 @@ fn analyze_closure(
         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) {
+
+        if should_do_disjoint_capture_migration_analysis(self.tcx, closure_hir_id) {
             self.perform_2229_migration_anaysis(closure_def_id, body_id, capture_clause, span);
         }
 
@@ -471,7 +474,7 @@ fn perform_2229_migration_anaysis(
         capture_clause: hir::CaptureBy,
         span: Span,
     ) {
-        let need_migrations = self.compute_2229_migrations(
+        let (need_migrations, reasons) = self.compute_2229_migrations(
             closure_def_id,
             span,
             capture_clause,
@@ -485,12 +488,16 @@ fn perform_2229_migration_anaysis(
             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,
+                lint::builtin::DISJOINT_CAPTURE_MIGRATION,
                 closure_hir_id,
                 span,
                 |lint| {
                     let mut diagnostics_builder = lint.build(
-                        "drop order affected for closure because of `capture_disjoint_fields`",
+                        format!(
+                            "{} affected for closure because of `capture_disjoint_fields`",
+                            reasons
+                        )
+                        .as_str(),
                     );
                     let closure_body_span = self.tcx.hir().span(body_id.hir_id);
                     let (sugg, app) =
@@ -527,6 +534,169 @@ fn perform_2229_migration_anaysis(
         }
     }
 
+    /// Combines all the reasons for 2229 migrations
+    fn compute_2229_migrations_reasons(
+        &self,
+        auto_trait_reasons: FxHashSet<&str>,
+        drop_reason: bool,
+    ) -> String {
+        let mut reasons = String::new();
+
+        if auto_trait_reasons.len() > 0 {
+            reasons = format!(
+                "{} trait implementation",
+                auto_trait_reasons.clone().into_iter().collect::<Vec<&str>>().join(", ")
+            );
+        }
+
+        if auto_trait_reasons.len() > 0 && drop_reason {
+            reasons = format!("{}, and ", reasons);
+        }
+
+        if drop_reason {
+            reasons = format!("{}drop order", reasons);
+        }
+
+        reasons
+    }
+
+    /// Returns true if `ty` may implement `trait_def_id`
+    fn ty_impls_trait(
+        &self,
+        ty: Ty<'tcx>,
+        cause: &ObligationCause<'tcx>,
+        trait_def_id: DefId,
+    ) -> bool {
+        use crate::rustc_middle::ty::ToPredicate;
+        use crate::rustc_middle::ty::WithConstness;
+        use rustc_trait_selection::traits::query::evaluate_obligation::InferCtxtExt;
+        let tcx = self.infcx.tcx;
+
+        let trait_ref = TraitRef { def_id: trait_def_id, substs: tcx.mk_substs_trait(ty, &[]) };
+
+        let obligation = Obligation::new(
+            cause.clone(),
+            self.param_env,
+            trait_ref.without_const().to_predicate(tcx),
+        );
+
+        self.infcx.predicate_may_hold(&obligation)
+    }
+
+    /// Returns true if migration is needed for trait for the provided var_hir_id
+    fn need_2229_migrations_for_trait(
+        &self,
+        min_captures: Option<&ty::RootVariableMinCaptureList<'tcx>>,
+        var_hir_id: hir::HirId,
+        check_trait: Option<DefId>,
+    ) -> bool {
+        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 {
+            return false;
+        };
+
+        let ty = self.infcx.resolve_vars_if_possible(self.node_ty(var_hir_id));
+
+        let cause = ObligationCause::misc(self.tcx.hir().span(var_hir_id), self.body_id);
+
+        let obligation_should_hold = check_trait
+            .map(|check_trait| self.ty_impls_trait(ty, &cause, check_trait))
+            .unwrap_or(false);
+
+        // Check whether catpured fields also implement the trait
+
+        for capture in root_var_min_capture_list.iter() {
+            let ty = capture.place.ty();
+
+            let obligation_holds_for_capture = check_trait
+                .map(|check_trait| self.ty_impls_trait(ty, &cause, check_trait))
+                .unwrap_or(false);
+
+            if !obligation_holds_for_capture && obligation_should_hold {
+                return true;
+            }
+        }
+        false
+    }
+
+    /// 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 auto-traits
+    /// differ between the root variable and the captured paths.
+    ///
+    /// The output list would include a root variable if:
+    /// - It would have been captured into the closure when `capture_disjoint_fields` wasn't
+    ///   enabled, **and**
+    /// - It wasn't completely captured by the closure, **and**
+    /// - One of the paths captured does not implement all the auto-traits its root variable
+    ///   implements.
+    fn compute_2229_migrations_for_trait(
+        &self,
+        min_captures: Option<&ty::RootVariableMinCaptureList<'tcx>>,
+        var_hir_id: hir::HirId,
+    ) -> Option<FxHashSet<&str>> {
+        let tcx = self.infcx.tcx;
+
+        // Check whether catpured fields also implement the trait
+        let mut auto_trait_reasons = FxHashSet::default();
+
+        if self.need_2229_migrations_for_trait(
+            min_captures,
+            var_hir_id,
+            tcx.lang_items().clone_trait(),
+        ) {
+            auto_trait_reasons.insert("`Clone`");
+        }
+
+        if self.need_2229_migrations_for_trait(
+            min_captures,
+            var_hir_id,
+            tcx.lang_items().sync_trait(),
+        ) {
+            auto_trait_reasons.insert("`Sync`");
+        }
+
+        if self.need_2229_migrations_for_trait(
+            min_captures,
+            var_hir_id,
+            tcx.lang_items().send_trait(),
+        ) {
+            auto_trait_reasons.insert("`Send`");
+        }
+
+        if self.need_2229_migrations_for_trait(
+            min_captures,
+            var_hir_id,
+            tcx.lang_items().unpin_trait(),
+        ) {
+            auto_trait_reasons.insert("`Unpin`");
+        }
+
+        if self.need_2229_migrations_for_trait(
+            min_captures,
+            var_hir_id,
+            tcx.lang_items().unwind_safe_trait(),
+        ) {
+            auto_trait_reasons.insert("`UnwindSafe`");
+        }
+
+        if self.need_2229_migrations_for_trait(
+            min_captures,
+            var_hir_id,
+            tcx.lang_items().ref_unwind_safe_trait(),
+        ) {
+            auto_trait_reasons.insert("`RefUnwindSafe`");
+        }
+
+        if auto_trait_reasons.len() > 0 {
+            return Some(auto_trait_reasons);
+        }
+
+        return None;
+    }
+
     /// 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.
@@ -536,76 +706,131 @@ fn perform_2229_migration_anaysis(
     ///   enabled, **and**
     /// - It wasn't completely captured by the closure, **and**
     /// - One of the paths starting at this root variable, that is not captured needs Drop.
-    fn compute_2229_migrations(
+    ///
+    /// This function only returns true for significant drops. A type is considerent to have a
+    /// significant drop if it's Drop implementation is not annotated by `rustc_insignificant_dtor`.
+    fn compute_2229_migrations_for_drop(
         &self,
         closure_def_id: DefId,
         closure_span: Span,
-        closure_clause: hir::CaptureBy,
         min_captures: Option<&ty::RootVariableMinCaptureList<'tcx>>,
-    ) -> Vec<hir::HirId> {
-        let upvars = if let Some(upvars) = self.tcx.upvars_mentioned(closure_def_id) {
-            upvars
-        } else {
-            return vec![];
-        };
+        closure_clause: hir::CaptureBy,
+        var_hir_id: hir::HirId,
+    ) -> bool {
+        let ty = self.infcx.resolve_vars_if_possible(self.node_ty(var_hir_id));
 
-        let mut need_migrations = Vec::new();
+        if !ty.has_significant_drop(self.tcx, self.tcx.param_env(closure_def_id.expect_local())) {
+            return false;
+        }
 
-        for (&var_hir_id, _) in upvars.iter() {
-            let ty = self.infcx.resolve_vars_if_possible(self.node_ty(var_hir_id));
+        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.
 
-            if !ty.needs_drop(self.tcx, self.tcx.param_env(closure_def_id.expect_local())) {
-                continue;
+            match closure_clause {
+                // Only migrate if closure is a move closure
+                hir::CaptureBy::Value => return true,
+                hir::CaptureBy::Ref => {}
             }
 
-            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.
+            return false;
+        };
 
-                match closure_clause {
-                    // Only migrate if closure is a move closure
-                    hir::CaptureBy::Value => need_migrations.push(var_hir_id),
+        let projections_list = root_var_min_capture_list
+            .iter()
+            .filter_map(|captured_place| match captured_place.info.capture_kind {
+                // Only care about captures that are moved into the closure
+                ty::UpvarCapture::ByValue(..) => Some(captured_place.place.projections.as_slice()),
+                ty::UpvarCapture::ByRef(..) => None,
+            })
+            .collect::<Vec<_>>();
 
-                    hir::CaptureBy::Ref => {}
-                }
+        let is_moved = !projections_list.is_empty();
 
-                continue;
-            };
+        let is_not_completely_captured =
+            root_var_min_capture_list.iter().any(|capture| capture.place.projections.len() > 0);
 
-            let projections_list = root_var_min_capture_list
-                .iter()
-                .filter_map(|captured_place| match captured_place.info.capture_kind {
-                    // Only care about captures that are moved into the closure
-                    ty::UpvarCapture::ByValue(..) => {
-                        Some(captured_place.place.projections.as_slice())
-                    }
-                    ty::UpvarCapture::ByRef(..) => None,
-                })
-                .collect::<Vec<_>>();
+        if is_moved
+            && is_not_completely_captured
+            && self.has_significant_drop_outside_of_captures(
+                closure_def_id,
+                closure_span,
+                ty,
+                projections_list,
+            )
+        {
+            return true;
+        }
 
-            let is_moved = !projections_list.is_empty();
+        return false;
+    }
 
-            let is_not_completely_captured =
-                root_var_min_capture_list.iter().any(|capture| capture.place.projections.len() > 0);
+    /// 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 either drop
+    /// order of some path starting at that root variable **might** be affected or auto-traits
+    /// differ between the root variable and the captured paths.
+    ///
+    /// 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**
+    /// - One of the paths starting at this root variable, that is not captured needs Drop **or**
+    /// - One of the paths captured does not implement all the auto-traits its root variable
+    ///   implements.
+    ///
+    /// Returns a tuple containing a vector of HirIds as well as a String containing the reason
+    /// why root variables whose HirId is contained in the vector should be fully captured.
+    fn compute_2229_migrations(
+        &self,
+        closure_def_id: DefId,
+        closure_span: Span,
+        closure_clause: hir::CaptureBy,
+        min_captures: Option<&ty::RootVariableMinCaptureList<'tcx>>,
+    ) -> (Vec<hir::HirId>, String) {
+        let upvars = if let Some(upvars) = self.tcx.upvars_mentioned(closure_def_id) {
+            upvars
+        } else {
+            return (Vec::new(), format!(""));
+        };
 
-            if is_moved
-                && is_not_completely_captured
-                && self.has_significant_drop_outside_of_captures(
-                    closure_def_id,
-                    closure_span,
-                    ty,
-                    projections_list,
-                )
+        let mut need_migrations = Vec::new();
+        let mut auto_trait_reasons = FxHashSet::default();
+        let mut drop_reorder_reason = false;
+
+        // Perform auto-trait analysis
+        for (&var_hir_id, _) in upvars.iter() {
+            let mut need_migration = false;
+            if let Some(trait_migration_cause) =
+                self.compute_2229_migrations_for_trait(min_captures, var_hir_id)
             {
+                need_migration = true;
+                auto_trait_reasons.extend(trait_migration_cause);
+            }
+
+            if self.compute_2229_migrations_for_drop(
+                closure_def_id,
+                closure_span,
+                min_captures,
+                closure_clause,
+                var_hir_id,
+            ) {
+                need_migration = true;
+                drop_reorder_reason = true;
+            }
+
+            if need_migration {
                 need_migrations.push(var_hir_id);
             }
         }
 
-        need_migrations
+        (
+            need_migrations,
+            self.compute_2229_migrations_reasons(auto_trait_reasons, drop_reorder_reason),
+        )
     }
 
     /// This is a helper function to `compute_2229_migrations_precise_pass`. Provided the type
@@ -613,11 +838,6 @@ fn compute_2229_migrations(
     /// using list of `Projection` slices), it returns true if there is a path that is not
     /// captured starting at this root variable that implements Drop.
     ///
-    /// FIXME(project-rfc-2229#35): This should return true only for significant drops.
-    ///                             A drop is significant if it's implemented by the user or does
-    ///                             anything that will have any observable behavior (other than
-    ///                             freeing up memory).
-    ///
     /// The way this function works is at a given call it looks at type `base_path_ty` of some base
     /// path say P and then list of projection slices which represent the different captures moved
     /// into the closure starting off of P.
@@ -673,7 +893,7 @@ fn compute_2229_migrations(
     ///     (Ty((w.p).x), [ &[] ])     (Ty((w.p).y), []) // IMP 2
     ///          |                             |
     ///          v                             v
-    ///        false                     NeedsDrop(Ty(w.p.y))
+    ///        false              NeedsSignificantDrop(Ty(w.p.y))
     ///                                        |
     ///                                        v
     ///                                      true
@@ -717,7 +937,7 @@ fn has_significant_drop_outside_of_captures(
         captured_by_move_projs: Vec<&[Projection<'tcx>]>,
     ) -> bool {
         let needs_drop = |ty: Ty<'tcx>| {
-            ty.needs_drop(self.tcx, self.tcx.param_env(closure_def_id.expect_local()))
+            ty.has_significant_drop(self.tcx, self.tcx.param_env(closure_def_id.expect_local()))
         };
 
         let is_drop_defined_for_ty = |ty: Ty<'tcx>| {
@@ -1544,9 +1764,8 @@ 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);
+fn should_do_disjoint_capture_migration_analysis(tcx: TyCtxt<'_>, closure_id: hir::HirId) -> bool {
+    let (level, _) = tcx.lint_level_at_node(lint::builtin::DISJOINT_CAPTURE_MIGRATION, closure_id);
 
     !matches!(level, lint::Level::Allow)
 }
index 97b6f5cf41211fb8873f22eb9c263b4f8383bcff..5197b620f90ba73532765ea268ea91d39a103fbb 100644 (file)
@@ -450,8 +450,9 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
                     tcx.typeck(def_id).node_type(anon_const.hir_id)
                 }
 
-                Node::Expr(&Expr { kind: ExprKind::InlineAsm(ia), .. })
-                    if ia.operands.iter().any(|(op, _op_sp)| match op {
+                Node::Expr(&Expr { kind: ExprKind::InlineAsm(asm), .. })
+                | Node::Item(&Item { kind: ItemKind::GlobalAsm(asm), .. })
+                    if asm.operands.iter().any(|(op, _op_sp)| match op {
                         hir::InlineAsmOperand::Const { anon_const } => anon_const.hir_id == hir_id,
                         _ => false,
                     }) =>
index e35c1557466426ac819197b3b44e2b5cf0874ed1..56f288ff051c2290e1b9cc347ed6b149182e0781 100644 (file)
@@ -1,34 +1,20 @@
 use crate::structured_errors::StructuredDiagnostic;
-use hir::def::DefKind;
 use rustc_errors::{pluralize, Applicability, DiagnosticBuilder, DiagnosticId};
 use rustc_hir as hir;
+use rustc_middle::middle::resolve_lifetime::LifetimeScopeForPath;
 use rustc_middle::ty::{self as ty, TyCtxt};
 use rustc_session::Session;
-use rustc_span::Span;
 use rustc_span::{def_id::DefId, MultiSpan};
 
+use GenericArgsInfo::*;
+
 /// Handles the `wrong number of type / lifetime / ... arguments` family of error messages.
 pub struct WrongNumberOfGenericArgs<'a, 'tcx> {
     crate tcx: TyCtxt<'tcx>,
 
-    /// "type", "lifetime" etc., put verbatim into the message
-    crate kind: &'static str,
-
-    /// Minimum number of expected generic arguments (e.g. `2` for `HashMap`)
-    crate expected_min: usize,
+    crate angle_brackets: AngleBrackets,
 
-    /// Maximum number of expected generic arguments (e.g. `3` for `HashMap`)
-    crate expected_max: usize,
-
-    /// Number of generic arguments provided by the user
-    crate provided: usize,
-
-    /// Offset into `gen_params` - depends on the `kind`; might be different than `args_offset` when
-    /// user passed e.g. more arguments than was actually expected
-    crate params_offset: usize,
-
-    /// Offset into `gen_args` - depends on the `kind`
-    crate args_offset: usize,
+    crate gen_args_info: GenericArgsInfo,
 
     /// Offending path segment
     crate path_segment: &'a hir::PathSegment<'a>,
@@ -36,64 +22,344 @@ pub struct WrongNumberOfGenericArgs<'a, 'tcx> {
     /// Generic parameters as expected by type or trait
     crate gen_params: &'a ty::Generics,
 
+    /// Index offset into parameters. Depends on whether `Self` is included and on
+    /// number of lifetime parameters in case we're processing missing or redundant
+    /// type or constant arguments.
+    crate params_offset: usize,
+
     /// Generic arguments as provided by user
     crate gen_args: &'a hir::GenericArgs<'a>,
 
     /// DefId of the generic type
     crate def_id: DefId,
+}
+
+// Provides information about the kind of arguments that were provided for
+// the PathSegment, for which missing generic arguments were detected
+#[derive(Debug)]
+pub(crate) enum AngleBrackets {
+    // No angle brackets were provided, but generic arguments exist in elided form
+    Implied,
+
+    // No angle brackets were provided
+    Missing,
+
+    // Angle brackets are available, but missing some generic arguments
+    Available,
+}
 
-    /// Offending place where the generic type has been misused
-    crate span: Span,
+// Information about the kind of arguments that are either missing or are unexpected
+#[derive(Debug)]
+pub enum GenericArgsInfo {
+    MissingLifetimes {
+        num_missing_args: usize,
+    },
+    ExcessLifetimes {
+        num_redundant_args: usize,
+    },
+    MissingTypesOrConsts {
+        num_missing_args: usize,
+
+        // type or const generic arguments can have default values
+        num_default_params: usize,
+
+        // lifetime arguments precede type and const parameters, this
+        // field gives the number of generic lifetime arguments to let
+        // us infer the position of type and const generic arguments
+        // in the angle brackets
+        args_offset: usize,
+    },
+
+    ExcessTypesOrConsts {
+        num_redundant_args: usize,
+
+        // type or const generic arguments can have default values
+        num_default_params: usize,
+
+        // lifetime arguments precede type and const parameters, this
+        // field gives the number of generic lifetime arguments to let
+        // us infer the position of type and const generic arguments
+        // in the angle brackets
+        args_offset: usize,
+    },
 }
 
-impl<'tcx> WrongNumberOfGenericArgs<'_, 'tcx> {
-    fn quantifier_and_bound(&self) -> (&'static str, usize) {
-        if self.expected_min == self.expected_max {
-            ("", self.expected_min)
-        } else if self.provided < self.expected_min {
-            ("at least ", self.expected_min)
+impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
+    pub fn new(
+        tcx: TyCtxt<'tcx>,
+        gen_args_info: GenericArgsInfo,
+        path_segment: &'a hir::PathSegment<'_>,
+        gen_params: &'a ty::Generics,
+        params_offset: usize,
+        gen_args: &'a hir::GenericArgs<'a>,
+        def_id: DefId,
+    ) -> Self {
+        let angle_brackets = if gen_args.span_ext().is_none() {
+            if gen_args.is_empty() { AngleBrackets::Missing } else { AngleBrackets::Implied }
         } else {
-            ("at most ", self.expected_max)
+            AngleBrackets::Available
+        };
+
+        Self {
+            tcx,
+            angle_brackets,
+            gen_args_info,
+            path_segment,
+            gen_params,
+            params_offset,
+            gen_args,
+            def_id,
         }
     }
 
-    fn start_diagnostics(&self) -> DiagnosticBuilder<'tcx> {
-        let span = self.path_segment.ident.span;
+    fn missing_lifetimes(&self) -> bool {
+        match self.gen_args_info {
+            MissingLifetimes { .. } | ExcessLifetimes { .. } => true,
+            MissingTypesOrConsts { .. } | ExcessTypesOrConsts { .. } => false,
+        }
+    }
 
-        let msg = {
-            let def_path = self.tcx.def_path_str(self.def_id);
-            let def_kind = self.tcx.def_kind(self.def_id).descr(self.def_id);
-            let (quantifier, bound) = self.quantifier_and_bound();
+    fn kind(&self) -> String {
+        if self.missing_lifetimes() { "lifetime".to_string() } else { "generic".to_string() }
+    }
 
-            if self.gen_args.span().is_some() {
-                format!(
-                    "this {} takes {}{} {} argument{} but {}{} {} argument{} {} supplied",
-                    def_kind,
-                    quantifier,
-                    bound,
-                    self.kind,
-                    pluralize!(bound),
-                    if self.provided > 0 && self.provided < self.expected_min {
-                        "only "
-                    } else {
-                        ""
-                    },
-                    self.provided,
-                    self.kind,
-                    pluralize!(self.provided),
-                    if self.provided == 1 { "was" } else { "were" },
-                )
-            } else {
-                format!("missing generics for {} `{}`", def_kind, def_path)
+    fn num_provided_args(&self) -> usize {
+        if self.missing_lifetimes() {
+            self.num_provided_lifetime_args()
+        } else {
+            self.num_provided_type_or_const_args()
+        }
+    }
+
+    fn num_provided_lifetime_args(&self) -> usize {
+        match self.angle_brackets {
+            AngleBrackets::Missing => 0,
+            // Only lifetime arguments can be implied
+            AngleBrackets::Implied => self.gen_args.args.len(),
+            AngleBrackets::Available => self.gen_args.args.iter().fold(0, |acc, arg| match arg {
+                hir::GenericArg::Lifetime(_) => acc + 1,
+                _ => acc,
+            }),
+        }
+    }
+
+    fn num_provided_type_or_const_args(&self) -> usize {
+        match self.angle_brackets {
+            AngleBrackets::Missing => 0,
+            // Only lifetime arguments can be implied
+            AngleBrackets::Implied => 0,
+            AngleBrackets::Available => self.gen_args.args.iter().fold(0, |acc, arg| match arg {
+                hir::GenericArg::Type(_) | hir::GenericArg::Const(_) => acc + 1,
+                _ => acc,
+            }),
+        }
+    }
+
+    fn num_expected_lifetime_args(&self) -> usize {
+        let num_provided_args = self.num_provided_lifetime_args();
+        match self.gen_args_info {
+            MissingLifetimes { num_missing_args } => num_provided_args + num_missing_args,
+            ExcessLifetimes { num_redundant_args } => num_provided_args - num_redundant_args,
+            _ => 0,
+        }
+    }
+
+    fn num_expected_type_or_const_args(&self) -> usize {
+        let num_provided_args = self.num_provided_type_or_const_args();
+        match self.gen_args_info {
+            MissingTypesOrConsts { num_missing_args, .. } => num_provided_args + num_missing_args,
+            ExcessTypesOrConsts { num_redundant_args, .. } => {
+                num_provided_args - num_redundant_args
             }
+            _ => 0,
+        }
+    }
+
+    // Gives the number of expected arguments taking into account default arguments
+    fn num_expected_type_or_const_args_including_defaults(&self) -> usize {
+        let provided_args = self.num_provided_type_or_const_args();
+        match self.gen_args_info {
+            MissingTypesOrConsts { num_missing_args, num_default_params, .. } => {
+                provided_args + num_missing_args - num_default_params
+            }
+            ExcessTypesOrConsts { num_redundant_args, num_default_params, .. } => {
+                provided_args - num_redundant_args - num_default_params
+            }
+            _ => 0,
+        }
+    }
+
+    fn num_missing_lifetime_args(&self) -> usize {
+        let missing_args = self.num_expected_lifetime_args() - self.num_provided_lifetime_args();
+        assert!(missing_args > 0);
+        missing_args
+    }
+
+    fn num_missing_type_or_const_args(&self) -> usize {
+        let missing_args = self.num_expected_type_or_const_args_including_defaults()
+            - self.num_provided_type_or_const_args();
+        assert!(missing_args > 0);
+        missing_args
+    }
+
+    fn num_excess_lifetime_args(&self) -> usize {
+        match self.gen_args_info {
+            ExcessLifetimes { num_redundant_args } => num_redundant_args,
+            _ => 0,
+        }
+    }
+
+    fn num_excess_type_or_const_args(&self) -> usize {
+        match self.gen_args_info {
+            ExcessTypesOrConsts { num_redundant_args, .. } => num_redundant_args,
+            _ => 0,
+        }
+    }
+
+    fn too_many_args_provided(&self) -> bool {
+        match self.gen_args_info {
+            MissingLifetimes { .. } | MissingTypesOrConsts { .. } => false,
+            ExcessLifetimes { num_redundant_args }
+            | ExcessTypesOrConsts { num_redundant_args, .. } => {
+                assert!(num_redundant_args > 0);
+                true
+            }
+        }
+    }
+
+    fn not_enough_args_provided(&self) -> bool {
+        match self.gen_args_info {
+            MissingLifetimes { num_missing_args }
+            | MissingTypesOrConsts { num_missing_args, .. } => {
+                assert!(num_missing_args > 0);
+                true
+            }
+            ExcessLifetimes { .. } | ExcessTypesOrConsts { .. } => false,
+        }
+    }
+
+    // Helper method to get the index offset in angle brackets, at which type or const arguments
+    // start appearing
+    fn get_lifetime_args_offset(&self) -> usize {
+        match self.gen_args_info {
+            MissingLifetimes { .. } | ExcessLifetimes { .. } => 0,
+            MissingTypesOrConsts { args_offset, .. } | ExcessTypesOrConsts { args_offset, .. } => {
+                args_offset
+            }
+        }
+    }
+
+    fn get_num_default_params(&self) -> usize {
+        match self.gen_args_info {
+            MissingTypesOrConsts { num_default_params, .. }
+            | ExcessTypesOrConsts { num_default_params, .. } => num_default_params,
+            _ => 0,
+        }
+    }
+
+    // Helper function to choose a quantifier word for the number of expected arguments
+    // and to give a bound for the number of expected arguments
+    fn get_quantifier_and_bound(&self) -> (&'static str, usize) {
+        if self.get_num_default_params() == 0 {
+            match self.gen_args_info {
+                MissingLifetimes { .. } | ExcessLifetimes { .. } => {
+                    ("", self.num_expected_lifetime_args())
+                }
+                MissingTypesOrConsts { .. } | ExcessTypesOrConsts { .. } => {
+                    ("", self.num_expected_type_or_const_args())
+                }
+            }
+        } else {
+            match self.gen_args_info {
+                MissingLifetimes { .. } => ("at least ", self.num_expected_lifetime_args()),
+                MissingTypesOrConsts { .. } => {
+                    ("at least ", self.num_expected_type_or_const_args_including_defaults())
+                }
+                ExcessLifetimes { .. } => ("at most ", self.num_expected_lifetime_args()),
+                ExcessTypesOrConsts { .. } => ("at most ", self.num_expected_type_or_const_args()),
+            }
+        }
+    }
+
+    // Creates lifetime name suggestions from the lifetime parameter names
+    fn get_lifetime_args_suggestions_from_param_names(&self, num_params_to_take: usize) -> String {
+        self.gen_params
+            .params
+            .iter()
+            .skip(self.params_offset + self.num_provided_lifetime_args())
+            .take(num_params_to_take)
+            .map(|param| param.name.to_string())
+            .collect::<Vec<_>>()
+            .join(", ")
+    }
+
+    // Creates type or constant name suggestions from the provided parameter names
+    fn get_type_or_const_args_suggestions_from_param_names(
+        &self,
+        num_params_to_take: usize,
+    ) -> String {
+        self.gen_params
+            .params
+            .iter()
+            .skip(self.params_offset + self.num_provided_type_or_const_args())
+            .take(num_params_to_take)
+            .map(|param| param.name.to_string())
+            .collect::<Vec<_>>()
+            .join(", ")
+    }
+
+    fn create_error_message(&self) -> String {
+        let def_path = self.tcx.def_path_str(self.def_id);
+        let def_kind = self.tcx.def_kind(self.def_id).descr(self.def_id);
+        let (quantifier, bound) = self.get_quantifier_and_bound();
+        let kind = self.kind();
+        let provided_lt_args = self.num_provided_lifetime_args();
+        let provided_type_or_const_args = self.num_provided_type_or_const_args();
+
+        let get_verb = |num_args| if num_args == 1 { "was" } else { "were" };
+
+        let (provided_args_str, verb) = match self.gen_args_info {
+            MissingLifetimes { .. } | ExcessLifetimes { .. } => (
+                format!("{} lifetime argument{}", provided_lt_args, pluralize!(provided_lt_args)),
+                get_verb(provided_lt_args),
+            ),
+            MissingTypesOrConsts { .. } | ExcessTypesOrConsts { .. } => (
+                format!(
+                    "{} generic argument{}",
+                    provided_type_or_const_args,
+                    pluralize!(provided_type_or_const_args)
+                ),
+                get_verb(provided_type_or_const_args),
+            ),
         };
 
+        if self.gen_args.span_ext().is_some() {
+            format!(
+                "this {} takes {}{} {} argument{} but {} {} supplied",
+                def_kind,
+                quantifier,
+                bound,
+                kind,
+                pluralize!(bound),
+                provided_args_str.as_str(),
+                verb
+            )
+        } else {
+            format!("missing generics for {} `{}`", def_kind, def_path)
+        }
+    }
+
+    fn start_diagnostics(&self) -> DiagnosticBuilder<'tcx> {
+        let span = self.path_segment.ident.span;
+        let msg = self.create_error_message();
+
         self.tcx.sess.struct_span_err_with_code(span, &msg, self.code())
     }
 
     /// Builds the `expected 1 type argument / supplied 2 type arguments` message.
     fn notify(&self, err: &mut DiagnosticBuilder<'_>) {
-        let (quantifier, bound) = self.quantifier_and_bound();
+        let (quantifier, bound) = self.get_quantifier_and_bound();
+        let provided_args = self.num_provided_args();
 
         err.span_label(
             self.path_segment.ident.span,
@@ -101,12 +367,12 @@ fn notify(&self, err: &mut DiagnosticBuilder<'_>) {
                 "expected {}{} {} argument{}",
                 quantifier,
                 bound,
-                self.kind,
+                self.kind(),
                 pluralize!(bound),
             ),
         );
 
-        // When user's provided too many arguments, we don't highlight each of them, because it
+        // When too many arguments were provided, we don't highlight each of them, because it
         // would overlap with the suggestion to remove them:
         //
         // ```
@@ -114,21 +380,27 @@ fn notify(&self, err: &mut DiagnosticBuilder<'_>) {
         //                -----  ----- supplied 2 type arguments
         //                     ^^^^^^^ remove this type argument
         // ```
-        if self.provided > self.expected_max {
+        if self.too_many_args_provided() {
             return;
         }
 
-        let args = self.gen_args.args.iter().skip(self.args_offset).take(self.provided).enumerate();
+        let args = self
+            .gen_args
+            .args
+            .iter()
+            .skip(self.get_lifetime_args_offset())
+            .take(provided_args)
+            .enumerate();
 
         for (i, arg) in args {
             err.span_label(
                 arg.span(),
-                if i + 1 == self.provided {
+                if i + 1 == provided_args {
                     format!(
                         "supplied {} {} argument{}",
-                        self.provided,
-                        self.kind,
-                        pluralize!(self.provided)
+                        provided_args,
+                        self.kind(),
+                        pluralize!(provided_args)
                     )
                 } else {
                     String::new()
@@ -138,56 +410,24 @@ fn notify(&self, err: &mut DiagnosticBuilder<'_>) {
     }
 
     fn suggest(&self, err: &mut DiagnosticBuilder<'_>) {
-        if self.provided == 0 {
-            if self.gen_args.span().is_some() {
-                self.suggest_adding_args(err);
-            } else {
-                self.suggest_creating_generics(err);
-            }
-        } else if self.provided < self.expected_min {
-            self.suggest_adding_args(err);
-        } else {
-            self.suggest_removing_args_or_generics(err);
-        }
-    }
-
-    /// Suggests to create generics (`<...>`) when current invocation site contains no generics at
-    /// all:
-    ///
-    /// ```text
-    /// type Map = HashMap;
-    /// ```
-    fn suggest_creating_generics(&self, err: &mut DiagnosticBuilder<'_>) {
-        let params = self
-            .gen_params
-            .params
-            .iter()
-            .skip(self.params_offset)
-            .take(self.expected_min)
-            .map(|param| param.name.to_string())
-            .collect::<Vec<_>>()
-            .join(", ");
-
-        let def_kind = self.tcx.def_kind(self.def_id);
-
-        let sugg = if matches!(def_kind, DefKind::Fn | DefKind::AssocFn) {
-            format!("::<{}>", params)
-        } else {
-            format!("<{}>", params)
-        };
-
-        let msg = format!(
-            "use angle brackets to add missing {} argument{}",
-            self.kind,
-            pluralize!(self.expected_min),
+        debug!(
+            "suggest(self.provided {:?}, self.gen_args.span(): {:?})",
+            self.num_provided_args(),
+            self.gen_args.span(),
         );
 
-        err.span_suggestion_verbose(
-            self.path_segment.ident.span.shrink_to_hi(),
-            &msg,
-            sugg,
-            Applicability::HasPlaceholders,
-        );
+        match self.angle_brackets {
+            AngleBrackets::Missing | AngleBrackets::Implied => self.suggest_adding_args(err),
+            AngleBrackets::Available => {
+                if self.not_enough_args_provided() {
+                    self.suggest_adding_args(err);
+                } else if self.too_many_args_provided() {
+                    self.suggest_removing_args_or_generics(err);
+                } else {
+                    unreachable!();
+                }
+            }
+        }
     }
 
     /// Suggests to add missing argument(s) when current invocation site already contains some
@@ -197,38 +437,172 @@ fn suggest_creating_generics(&self, err: &mut DiagnosticBuilder<'_>) {
     /// type Map = HashMap<String>;
     /// ```
     fn suggest_adding_args(&self, err: &mut DiagnosticBuilder<'_>) {
-        assert!(!self.gen_args.is_empty());
-
         if self.gen_args.parenthesized {
             return;
         }
 
-        let missing_arg_count = self.expected_min - self.provided;
+        match self.gen_args_info {
+            MissingLifetimes { .. } => {
+                self.suggest_adding_lifetime_args(err);
+            }
+            MissingTypesOrConsts { .. } => {
+                self.suggest_adding_type_and_const_args(err);
+            }
+            _ => unreachable!(),
+        }
+    }
 
-        let (span, sugg_prefix) = if self.args_offset + self.provided == 0 {
-            let span = self.gen_args.args[0].span().shrink_to_lo();
-            (span, "")
+    fn suggest_adding_lifetime_args(&self, err: &mut DiagnosticBuilder<'_>) {
+        debug!("suggest_adding_lifetime_args(path_segment: {:?})", self.path_segment);
+        let num_missing_args = self.num_missing_lifetime_args();
+        let num_params_to_take = num_missing_args;
+        let msg = format!("add missing {} argument{}", self.kind(), pluralize!(num_missing_args));
+
+        // we first try to get lifetime name suggestions from scope or elision information. If none is
+        // available we use the parameter defintions
+        let suggested_args = if let Some(hir_id) = self.path_segment.hir_id {
+            if let Some(lifetimes_in_scope) = self.tcx.lifetime_scope(hir_id) {
+                match lifetimes_in_scope {
+                    LifetimeScopeForPath::NonElided(param_names) => {
+                        debug!("NonElided(param_names: {:?})", param_names);
+
+                        if param_names.len() >= num_params_to_take {
+                            // use lifetime parameters in scope for suggestions
+                            param_names
+                                .iter()
+                                .take(num_params_to_take)
+                                .map(|p| (*p).clone())
+                                .collect::<Vec<_>>()
+                                .join(", ")
+                        } else {
+                            // Not enough lifetime arguments in scope -> create suggestions from
+                            // lifetime parameter names in definition. An error for the incorrect
+                            // lifetime scope will be output later.
+                            self.get_lifetime_args_suggestions_from_param_names(num_params_to_take)
+                        }
+                    }
+                    LifetimeScopeForPath::Elided => {
+                        debug!("Elided");
+                        // use suggestions of the form `<'_, '_>` in case lifetime can be elided
+                        ["'_"].repeat(num_params_to_take).join(",")
+                    }
+                }
+            } else {
+                self.get_lifetime_args_suggestions_from_param_names(num_params_to_take)
+            }
         } else {
-            let span =
-                self.gen_args.args[self.args_offset + self.provided - 1].span().shrink_to_hi();
-            (span, ", ")
+            self.get_lifetime_args_suggestions_from_param_names(num_params_to_take)
         };
 
-        let msg = format!("add missing {} argument{}", self.kind, pluralize!(missing_arg_count));
+        debug!("suggested_args: {:?}", &suggested_args);
 
-        let sugg = self
-            .gen_params
-            .params
-            .iter()
-            .skip(self.params_offset + self.provided)
-            .take(missing_arg_count)
-            .map(|param| param.name.to_string())
-            .collect::<Vec<_>>()
-            .join(", ");
+        match self.angle_brackets {
+            AngleBrackets::Missing => {
+                let span = self.path_segment.ident.span;
+
+                // insert a suggestion of the form "Y<'a, 'b>"
+                let ident = self.path_segment.ident.name.to_ident_string();
+                let sugg = format!("{}<{}>", ident, suggested_args);
+                debug!("sugg: {:?}", sugg);
+
+                err.span_suggestion_verbose(span, &msg, sugg, Applicability::HasPlaceholders);
+            }
+
+            AngleBrackets::Available => {
+                // angle brackets exist, so we insert missing arguments after the existing args
+
+                assert!(!self.gen_args.args.is_empty());
+
+                if self.num_provided_lifetime_args() > 0 {
+                    let last_lt_arg_span = self.gen_args.args
+                        [self.num_provided_lifetime_args() - 1]
+                        .span()
+                        .shrink_to_hi();
+                    let source_map = self.tcx.sess.source_map();
 
-        let sugg = format!("{}{}", sugg_prefix, sugg);
+                    if let Ok(last_gen_arg) = source_map.span_to_snippet(last_lt_arg_span) {
+                        let sugg = format!("{}, {}", last_gen_arg, suggested_args);
 
-        err.span_suggestion_verbose(span, &msg, sugg, Applicability::HasPlaceholders);
+                        err.span_suggestion_verbose(
+                            last_lt_arg_span,
+                            &msg,
+                            sugg,
+                            Applicability::HasPlaceholders,
+                        );
+                    }
+                } else {
+                    // Non-lifetime arguments included in `gen_args` -> insert missing lifetimes before
+                    // existing arguments
+                    let first_arg_span = self.gen_args.args[0].span().shrink_to_lo();
+                    let source_map = self.tcx.sess.source_map();
+
+                    if let Ok(first_gen_arg) = source_map.span_to_snippet(first_arg_span) {
+                        let sugg = format!("{}, {}", suggested_args, first_gen_arg);
+
+                        err.span_suggestion_verbose(
+                            first_arg_span,
+                            &msg,
+                            sugg,
+                            Applicability::HasPlaceholders,
+                        );
+                    }
+                }
+            }
+            AngleBrackets::Implied => {
+                // We never encounter missing lifetimes in situations in which lifetimes are elided
+                unreachable!();
+            }
+        }
+    }
+
+    fn suggest_adding_type_and_const_args(&self, err: &mut DiagnosticBuilder<'_>) {
+        let num_missing_args = self.num_missing_type_or_const_args();
+        let msg = format!("add missing {} argument{}", self.kind(), pluralize!(num_missing_args));
+
+        let suggested_args =
+            self.get_type_or_const_args_suggestions_from_param_names(num_missing_args);
+        debug!("suggested_args: {:?}", suggested_args);
+
+        match self.angle_brackets {
+            AngleBrackets::Missing | AngleBrackets::Implied => {
+                let span = self.path_segment.ident.span;
+
+                // insert a suggestion of the form "Y<T, U>"
+                let ident = self.path_segment.ident.name.to_ident_string();
+                let sugg = format!("{}<{}>", ident, suggested_args);
+                debug!("sugg: {:?}", sugg);
+
+                err.span_suggestion_verbose(span, &msg, sugg, Applicability::HasPlaceholders);
+            }
+            AngleBrackets::Available => {
+                let gen_args_span = self.gen_args.span().unwrap();
+                let sugg_offset =
+                    self.get_lifetime_args_offset() + self.num_provided_type_or_const_args();
+
+                let (sugg_span, is_first) = if sugg_offset == 0 {
+                    (gen_args_span.shrink_to_lo(), true)
+                } else {
+                    let arg_span = self.gen_args.args[sugg_offset - 1].span();
+                    // If we came here then inferred lifetimes's spans can only point
+                    // to either the opening bracket or to the space right after.
+                    // Both of these spans have an `hi` lower than or equal to the span
+                    // of the generics excluding the brackets.
+                    // This allows us to check if `arg_span` is the artificial span of
+                    // an inferred lifetime, in which case the generic we're suggesting to
+                    // add will be the first visible, even if it isn't the actual first generic.
+                    (arg_span.shrink_to_hi(), arg_span.hi() <= gen_args_span.lo())
+                };
+
+                let sugg_prefix = if is_first { "" } else { ", " };
+                let sugg_suffix =
+                    if is_first && !self.gen_args.bindings.is_empty() { ", " } else { "" };
+
+                let sugg = format!("{}{}{}", sugg_prefix, suggested_args, sugg_suffix);
+                debug!("sugg: {:?}", sugg);
+
+                err.span_suggestion_verbose(sugg_span, &msg, sugg, Applicability::HasPlaceholders);
+            }
+        }
     }
 
     /// Suggests to remove redundant argument(s):
@@ -237,19 +611,96 @@ fn suggest_adding_args(&self, err: &mut DiagnosticBuilder<'_>) {
     /// type Map = HashMap<String, String, String, String>;
     /// ```
     fn suggest_removing_args_or_generics(&self, err: &mut DiagnosticBuilder<'_>) {
-        assert!(self.provided > 0);
+        let num_provided_lt_args = self.num_provided_lifetime_args();
+        let num_provided_type_const_args = self.num_provided_type_or_const_args();
+        let num_provided_args = num_provided_lt_args + num_provided_type_const_args;
+        assert!(num_provided_args > 0);
+
+        let num_redundant_lt_args = self.num_excess_lifetime_args();
+        let num_redundant_type_or_const_args = self.num_excess_type_or_const_args();
+        let num_redundant_args = num_redundant_lt_args + num_redundant_type_or_const_args;
+
+        let redundant_lifetime_args = num_redundant_lt_args > 0;
+        let redundant_type_or_const_args = num_redundant_type_or_const_args > 0;
+
+        let remove_entire_generics = num_redundant_args >= self.gen_args.args.len();
+
+        let remove_lifetime_args = |err: &mut DiagnosticBuilder<'_>| {
+            let idx_first_redundant_lt_args = self.num_expected_lifetime_args();
+            let span_lo_redundant_lt_args =
+                self.gen_args.args[idx_first_redundant_lt_args].span().shrink_to_lo();
+            let span_hi_redundant_lt_args = self.gen_args.args
+                [idx_first_redundant_lt_args + num_redundant_lt_args - 1]
+                .span()
+                .shrink_to_hi();
+            let eat_comma =
+                idx_first_redundant_lt_args + num_redundant_lt_args - 1 != self.gen_args.args.len();
+
+            let span_redundant_lt_args = if eat_comma {
+                let span_hi = self.gen_args.args
+                    [idx_first_redundant_lt_args + num_redundant_lt_args - 1]
+                    .span()
+                    .shrink_to_hi();
+                span_lo_redundant_lt_args.to(span_hi)
+            } else {
+                span_lo_redundant_lt_args.to(span_hi_redundant_lt_args)
+            };
+            debug!("span_redundant_lt_args: {:?}", span_redundant_lt_args);
+
+            let msg_lifetimes = format!(
+                "remove {} {} argument{}",
+                if num_redundant_args == 1 { "this" } else { "these" },
+                "lifetime",
+                pluralize!(num_redundant_lt_args),
+            );
+
+            err.span_suggestion(
+                span_redundant_lt_args,
+                &msg_lifetimes,
+                String::new(),
+                Applicability::MaybeIncorrect,
+            );
+        };
+
+        let remove_type_or_const_args = |err: &mut DiagnosticBuilder<'_>| {
+            let idx_first_redundant_type_or_const_args = self.get_lifetime_args_offset()
+                + num_redundant_lt_args
+                + self.num_expected_type_or_const_args();
 
-        let redundant_args_count = self.provided - self.expected_max;
-        let remove_entire_generics = redundant_args_count >= self.gen_args.args.len();
+            let span_lo_redundant_type_or_const_args =
+                self.gen_args.args[idx_first_redundant_type_or_const_args].span().shrink_to_lo();
 
-        let (span, msg) = if remove_entire_generics {
-            let sm = self.tcx.sess.source_map();
+            let span_hi_redundant_type_or_const_args = self.gen_args.args
+                [idx_first_redundant_type_or_const_args + num_redundant_type_or_const_args - 1]
+                .span()
+                .shrink_to_hi();
 
+            let span_redundant_type_or_const_args =
+                span_lo_redundant_type_or_const_args.to(span_hi_redundant_type_or_const_args);
+
+            debug!("span_redundant_type_or_const_args: {:?}", span_redundant_type_or_const_args);
+
+            let msg_types_or_consts = format!(
+                "remove {} {} argument{}",
+                if num_redundant_args == 1 { "this" } else { "these" },
+                "generic",
+                pluralize!(num_redundant_type_or_const_args),
+            );
+
+            err.span_suggestion(
+                span_redundant_type_or_const_args,
+                &msg_types_or_consts,
+                String::new(),
+                Applicability::MaybeIncorrect,
+            );
+        };
+
+        if remove_entire_generics {
             let span = self
                 .path_segment
                 .args
                 .unwrap()
-                .span_ext(sm)
+                .span_ext()
                 .unwrap()
                 .with_lo(self.path_segment.ident.span.hi());
 
@@ -258,70 +709,16 @@ fn suggest_removing_args_or_generics(&self, err: &mut DiagnosticBuilder<'_>) {
                 if self.gen_args.parenthesized { "parenthetical " } else { "" },
             );
 
-            (span, msg)
+            err.span_suggestion(span, &msg, String::new(), Applicability::MaybeIncorrect);
+        } else if redundant_lifetime_args && redundant_type_or_const_args {
+            remove_lifetime_args(err);
+            remove_type_or_const_args(err);
+        } else if redundant_lifetime_args {
+            remove_lifetime_args(err);
         } else {
-            // When it comes to removing particular argument(s) from the generics, there are two
-            // edge cases we have to consider:
-            //
-            // When the first redundant argument is at the beginning or in the middle of the
-            // generics, like so:
-            //
-            // ```
-            // type Map = HashMap<String, String, String, String>;
-            //                    ^^^^^^^^^^^^^^^^
-            //                    | span must start with the argument
-            // ```
-            //
-            // When the last redundant argument is at the ending of the generics, like so:
-            //
-            // ```
-            // type Map = HashMap<String, String, String, String>;
-            //                                  ^^^^^^^^^^^^^^^^
-            //                                  | span must start with the comma
-            // ```
-
-            // Index of the first redundant argument
-            let from_idx = self.args_offset + self.expected_max;
-
-            // Index of the last redundant argument
-            let to_idx = self.args_offset + self.provided - 1;
-
-            assert!(from_idx <= to_idx);
-
-            let (from, comma_eaten) = {
-                let first_argument_starts_generics = from_idx == 0;
-                let last_argument_ends_generics = to_idx + 1 == self.gen_args.args.len();
-
-                if !first_argument_starts_generics && last_argument_ends_generics {
-                    (self.gen_args.args[from_idx - 1].span().hi(), true)
-                } else {
-                    (self.gen_args.args[from_idx].span().lo(), false)
-                }
-            };
-
-            let to = {
-                let hi = self.gen_args.args[to_idx].span().hi();
-
-                if comma_eaten {
-                    hi
-                } else {
-                    self.gen_args.args.get(to_idx + 1).map(|arg| arg.span().lo()).unwrap_or(hi)
-                }
-            };
-
-            let span = Span::new(from, to, self.span.ctxt());
-
-            let msg = format!(
-                "remove {} {} argument{}",
-                if redundant_args_count == 1 { "this" } else { "these" },
-                self.kind,
-                pluralize!(redundant_args_count),
-            );
-
-            (span, msg)
-        };
-
-        err.span_suggestion(span, &msg, String::new(), Applicability::MaybeIncorrect);
+            assert!(redundant_type_or_const_args);
+            remove_type_or_const_args(err);
+        }
     }
 
     /// Builds the `type defined here` message.
@@ -334,7 +731,7 @@ fn show_definition(&self, err: &mut DiagnosticBuilder<'_>) {
 
         let msg = {
             let def_kind = self.tcx.def_kind(self.def_id).descr(self.def_id);
-            let (quantifier, bound) = self.quantifier_and_bound();
+            let (quantifier, bound) = self.get_quantifier_and_bound();
 
             let params = if bound == 0 {
                 String::new()
@@ -362,7 +759,7 @@ fn show_definition(&self, err: &mut DiagnosticBuilder<'_>) {
                 def_kind,
                 quantifier,
                 bound,
-                self.kind,
+                self.kind(),
                 pluralize!(bound),
                 params,
             )
index 4f97c95bcb9ea1ccecb0c4752f168a72b4ad8dde..5793f5e681b4820b3baad765de15b046e5fd2505 100644 (file)
@@ -11,7 +11,7 @@ edition = "2018"
 
 [dependencies]
 core = { path = "../core" }
-compiler_builtins = { version = "0.1.39", features = ['rustc-dep-of-std'] }
+compiler_builtins = { version = "0.1.40", features = ['rustc-dep-of-std'] }
 
 [dev-dependencies]
 rand = "0.7"
index 0a46387c34e9c09fae28bd7628f8825605b93cbf..30194aa446f4b43f089c8e61a443f5adc0d68f68 100644 (file)
@@ -1439,7 +1439,10 @@ fn into_iter(self) -> IntoIter<K, V> {
 impl<K, V> Drop for Dropper<K, V> {
     fn drop(&mut self) {
         // Similar to advancing a non-fusing iterator.
-        fn next_or_end<K, V>(this: &mut Dropper<K, V>) -> Option<(K, V)> {
+        fn next_or_end<K, V>(
+            this: &mut Dropper<K, V>,
+        ) -> Option<Handle<NodeRef<marker::Dying, K, V, marker::LeafOrInternal>, marker::KV>>
+        {
             if this.remaining_length == 0 {
                 unsafe { ptr::read(&this.front).deallocating_end() }
                 None
@@ -1455,13 +1458,15 @@ impl<'a, K, V> Drop for DropGuard<'a, K, V> {
             fn drop(&mut self) {
                 // Continue the same loop we perform below. This only runs when unwinding, so we
                 // don't have to care about panics this time (they'll abort).
-                while let Some(_pair) = next_or_end(&mut self.0) {}
+                while let Some(kv) = next_or_end(&mut self.0) {
+                    kv.drop_key_val();
+                }
             }
         }
 
-        while let Some(pair) = next_or_end(self) {
+        while let Some(kv) = next_or_end(self) {
             let guard = DropGuard(self);
-            drop(pair);
+            kv.drop_key_val();
             mem::forget(guard);
         }
     }
@@ -1485,7 +1490,9 @@ fn next(&mut self) -> Option<(K, V)> {
             None
         } else {
             self.length -= 1;
-            Some(unsafe { self.range.front.as_mut().unwrap().deallocating_next_unchecked() })
+            let front = self.range.front.as_mut().unwrap();
+            let kv = unsafe { front.deallocating_next_unchecked() };
+            Some(kv.into_key_val())
         }
     }
 
@@ -1501,7 +1508,9 @@ fn next_back(&mut self) -> Option<(K, V)> {
             None
         } else {
             self.length -= 1;
-            Some(unsafe { self.range.back.as_mut().unwrap().deallocating_next_back_unchecked() })
+            let back = self.range.back.as_mut().unwrap();
+            let kv = unsafe { back.deallocating_next_back_unchecked() };
+            Some(kv.into_key_val())
         }
     }
 }
index 4399feaccc9b7a6b137cb9954601bb9eda5d7f8a..563c070dd0f1f81cc0c38b72bbc6a3fdcbfc2cc7 100644 (file)
@@ -237,25 +237,27 @@ pub fn next_kv(
 
 impl<K, V> Handle<NodeRef<marker::Dying, K, V, marker::Leaf>, marker::Edge> {
     /// Given a leaf edge handle into a dying tree, returns the next leaf edge
-    /// on the right side, and the key-value pair in between, which is either
-    /// in the same leaf node, in an ancestor node, or non-existent.
+    /// on the right side, and the key-value pair in between, if they exist.
     ///
-    /// This method also deallocates any node(s) it reaches the end of. This
-    /// implies that if no more key-value pair exists, the entire remainder of
-    /// the tree will have been deallocated and there is nothing left to return.
+    /// If the given edge is the last one in a leaf, this method deallocates
+    /// the leaf, as well as any ancestor nodes whose last edge was reached.
+    /// This implies that if no more key-value pair follows, the entire tree
+    /// will have been deallocated and there is nothing left to return.
     ///
     /// # Safety
-    /// The given edge must not have been previously returned by counterpart
-    /// `deallocating_next_back`.
-    unsafe fn deallocating_next(self) -> Option<(Self, (K, V))> {
+    /// - The given edge must not have been previously returned by counterpart
+    ///   `deallocating_next_back`.
+    /// - The returned KV handle is only valid to access the key and value,
+    ///   and only valid until the next call to this method or counterpart
+    ///   `deallocating_next_back`.
+    pub unsafe fn deallocating_next(
+        self,
+    ) -> Option<(Self, Handle<NodeRef<marker::Dying, K, V, marker::LeafOrInternal>, marker::KV>)>
+    {
         let mut edge = self.forget_node_type();
         loop {
             edge = match edge.right_kv() {
-                Ok(kv) => {
-                    let k = unsafe { ptr::read(kv.reborrow().into_kv().0) };
-                    let v = unsafe { ptr::read(kv.reborrow().into_kv().1) };
-                    return Some((kv.next_leaf_edge(), (k, v)));
-                }
+                Ok(kv) => return Some((unsafe { ptr::read(&kv) }.next_leaf_edge(), kv)),
                 Err(last_edge) => match unsafe { last_edge.into_node().deallocate_and_ascend() } {
                     Some(parent_edge) => parent_edge.forget_node_type(),
                     None => return None,
@@ -265,25 +267,27 @@ unsafe fn deallocating_next(self) -> Option<(Self, (K, V))> {
     }
 
     /// Given a leaf edge handle into a dying tree, returns the next leaf edge
-    /// on the left side, and the key-value pair in between, which is either
-    /// in the same leaf node, in an ancestor node, or non-existent.
+    /// on the left side, and the key-value pair in between, if they exist.
     ///
-    /// This method also deallocates any node(s) it reaches the end of. This
-    /// implies that if no more key-value pair exists, the entire remainder of
-    /// the tree will have been deallocated and there is nothing left to return.
+    /// If the given edge is the first one in a leaf, this method deallocates
+    /// the leaf, as well as any ancestor nodes whose first edge was reached.
+    /// This implies that if no more key-value pair follows, the entire tree
+    /// will have been deallocated and there is nothing left to return.
     ///
     /// # Safety
-    /// The given edge must not have been previously returned by counterpart
-    /// `deallocating_next`.
-    unsafe fn deallocating_next_back(self) -> Option<(Self, (K, V))> {
+    /// - The given edge must not have been previously returned by counterpart
+    ///   `deallocating_next`.
+    /// - The returned KV handle is only valid to access the key and value,
+    ///   and only valid until the next call to this method or counterpart
+    ///   `deallocating_next`.
+    unsafe fn deallocating_next_back(
+        self,
+    ) -> Option<(Self, Handle<NodeRef<marker::Dying, K, V, marker::LeafOrInternal>, marker::KV>)>
+    {
         let mut edge = self.forget_node_type();
         loop {
             edge = match edge.left_kv() {
-                Ok(kv) => {
-                    let k = unsafe { ptr::read(kv.reborrow().into_kv().0) };
-                    let v = unsafe { ptr::read(kv.reborrow().into_kv().1) };
-                    return Some((kv.next_back_leaf_edge(), (k, v)));
-                }
+                Ok(kv) => return Some((unsafe { ptr::read(&kv) }.next_back_leaf_edge(), kv)),
                 Err(last_edge) => match unsafe { last_edge.into_node().deallocate_and_ascend() } {
                     Some(parent_edge) => parent_edge.forget_node_type(),
                     None => return None,
@@ -373,13 +377,15 @@ impl<K, V> Handle<NodeRef<marker::Dying, K, V, marker::Leaf>, marker::Edge> {
     ///
     /// # Safety
     /// - There must be another KV in the direction travelled.
-    /// - That KV was not previously returned by counterpart `next_back_unchecked`
-    ///   on any copy of the handles being used to traverse the tree.
+    /// - That KV was not previously returned by counterpart
+    ///   `deallocating_next_back_unchecked` on any copy of the handles
+    ///   being used to traverse the tree.
     ///
     /// The only safe way to proceed with the updated handle is to compare it, drop it,
-    /// call this method again subject to its safety conditions, or call counterpart
-    /// `next_back_unchecked` subject to its safety conditions.
-    pub unsafe fn deallocating_next_unchecked(&mut self) -> (K, V) {
+    /// or call this method or counterpart `deallocating_next_back_unchecked` again.
+    pub unsafe fn deallocating_next_unchecked(
+        &mut self,
+    ) -> Handle<NodeRef<marker::Dying, K, V, marker::LeafOrInternal>, marker::KV> {
         super::mem::replace(self, |leaf_edge| unsafe {
             leaf_edge.deallocating_next().unwrap_unchecked()
         })
@@ -391,13 +397,15 @@ pub unsafe fn deallocating_next_unchecked(&mut self) -> (K, V) {
     ///
     /// # Safety
     /// - There must be another KV in the direction travelled.
-    /// - That leaf edge was not previously returned by counterpart `next_unchecked`
-    ///   on any copy of the handles being used to traverse the tree.
+    /// - That leaf edge was not previously returned by counterpart
+    ///   `deallocating_next_unchecked` on any copy of the handles
+    ///   being used to traverse the tree.
     ///
     /// The only safe way to proceed with the updated handle is to compare it, drop it,
-    /// call this method again subject to its safety conditions, or call counterpart
-    /// `next_unchecked` subject to its safety conditions.
-    pub unsafe fn deallocating_next_back_unchecked(&mut self) -> (K, V) {
+    /// or call this method or counterpart `deallocating_next_unchecked` again.
+    pub unsafe fn deallocating_next_back_unchecked(
+        &mut self,
+    ) -> Handle<NodeRef<marker::Dying, K, V, marker::LeafOrInternal>, marker::KV> {
         super::mem::replace(self, |leaf_edge| unsafe {
             leaf_edge.deallocating_next_back().unwrap_unchecked()
         })
index af403496e38e937dd3e995a0203c4fe6b0f0253f..3c453529ba84d3d93794c7da6602c9289955d3ec 100644 (file)
@@ -422,14 +422,14 @@ unsafe fn reborrow_mut(&mut self) -> NodeRef<marker::Mut<'_>, K, V, Type> {
         NodeRef { height: self.height, node: self.node, _marker: PhantomData }
     }
 
-    /// Borrows exclusive access to the leaf portion of any leaf or internal node.
+    /// Borrows exclusive access to the leaf portion of a leaf or internal node.
     fn as_leaf_mut(&mut self) -> &mut LeafNode<K, V> {
         let ptr = Self::as_leaf_ptr(self);
         // SAFETY: we have exclusive access to the entire node.
         unsafe { &mut *ptr }
     }
 
-    /// Offers exclusive access to the leaf portion of any leaf or internal node.
+    /// Offers exclusive access to the leaf portion of a leaf or internal node.
     fn into_leaf_mut(mut self) -> &'a mut LeafNode<K, V> {
         let ptr = Self::as_leaf_ptr(&mut self);
         // SAFETY: we have exclusive access to the entire node.
@@ -437,6 +437,15 @@ fn into_leaf_mut(mut self) -> &'a mut LeafNode<K, V> {
     }
 }
 
+impl<K, V, Type> NodeRef<marker::Dying, K, V, Type> {
+    /// Borrows exclusive access to the leaf portion of a dying leaf or internal node.
+    fn as_leaf_dying(&mut self) -> &mut LeafNode<K, V> {
+        let ptr = Self::as_leaf_ptr(self);
+        // SAFETY: we have exclusive access to the entire node.
+        unsafe { &mut *ptr }
+    }
+}
+
 impl<'a, K: 'a, V: 'a, Type> NodeRef<marker::Mut<'a>, K, V, Type> {
     /// Borrows exclusive access to an element of the key storage area.
     ///
@@ -1040,13 +1049,37 @@ pub fn kv_mut(&mut self) -> (&mut K, &mut V) {
         }
     }
 
-    /// Replace the key and value that the KV handle refers to.
+    /// Replaces the key and value that the KV handle refers to.
     pub fn replace_kv(&mut self, k: K, v: V) -> (K, V) {
         let (key, val) = self.kv_mut();
         (mem::replace(key, k), mem::replace(val, v))
     }
 }
 
+impl<K, V, NodeType> Handle<NodeRef<marker::Dying, K, V, NodeType>, marker::KV> {
+    /// Extracts the key and value that the KV handle refers to.
+    pub fn into_key_val(mut self) -> (K, V) {
+        debug_assert!(self.idx < self.node.len());
+        let leaf = self.node.as_leaf_dying();
+        unsafe {
+            let key = leaf.keys.get_unchecked_mut(self.idx).assume_init_read();
+            let val = leaf.vals.get_unchecked_mut(self.idx).assume_init_read();
+            (key, val)
+        }
+    }
+
+    /// Drops the key and value that the KV handle refers to.
+    #[inline]
+    pub fn drop_key_val(mut self) {
+        debug_assert!(self.idx < self.node.len());
+        let leaf = self.node.as_leaf_dying();
+        unsafe {
+            leaf.keys.get_unchecked_mut(self.idx).assume_init_drop();
+            leaf.vals.get_unchecked_mut(self.idx).assume_init_drop();
+        }
+    }
+}
+
 impl<'a, K: 'a, V: 'a, NodeType> Handle<NodeRef<marker::Mut<'a>, K, V, NodeType>, marker::KV> {
     /// Helps implementations of `split` for a particular `NodeType`,
     /// by taking care of leaf data.
index 5d9b0f80d3a6f3ebcfd9f9b454963dfaaa25072e..b46a7aa138cd1afb19c01af03e6bf0e17faeadcc 100644 (file)
@@ -1358,7 +1358,10 @@ macro_rules! llvm_asm {
     #[rustc_builtin_macro]
     #[macro_export]
     macro_rules! global_asm {
-        ("assembly") => {
+        ("assembly template",
+            $(operands,)*
+            $(options($(option),*))?
+        ) => {
             /* compiler built-in */
         };
     }
index fb957348bebd3837dbfc60d43efa5c389fb7fb2b..2b2404550433ddb6bb9eca9a1ff20d61885e5e35 100644 (file)
@@ -31,6 +31,7 @@
 /// [ub]: ../../reference/behavior-considered-undefined.html
 #[stable(feature = "rust1", since = "1.0.0")]
 #[cfg_attr(not(test), rustc_diagnostic_item = "send_trait")]
+#[cfg_attr(not(bootstrap), lang = "send")]
 #[rustc_on_unimplemented(
     message = "`{Self}` cannot be sent between threads safely",
     label = "`{Self}` cannot be sent between threads safely"
index f1b9dabe7d6b769bc8fb3d746eeccca150cd01fb..be6d70320d407669839cae46e732bc1471becfa3 100644 (file)
@@ -433,6 +433,21 @@ impl Wrapping<$t> {
             #[unstable(feature = "wrapping_int_impl", issue = "32463")]
             pub const MAX: Self = Self(<$t>::MAX);
 
+            /// Returns the size of this integer type in bits.
+            ///
+            /// # Examples
+            ///
+            /// Basic usage:
+            ///
+            /// ```
+            /// #![feature(wrapping_int_impl)]
+            /// use std::num::Wrapping;
+            ///
+            #[doc = concat!("assert_eq!(<Wrapping<", stringify!($t), ">>::BITS, ", stringify!($t), "::BITS);")]
+            /// ```
+            #[unstable(feature = "wrapping_int_impl", issue = "32463")]
+            pub const BITS: u32 = <$t>::BITS;
+
             /// Returns the number of ones in the binary representation of `self`.
             ///
             /// # Examples
index 292ac3e3f7fec3a664588d4b00b8ed05facc96e0..750279ac0dbdc8e0d493122446e5725eab3098c5 100644 (file)
@@ -42,7 +42,7 @@ pub const fn is_null(self) -> bool {
     /// Casts to a pointer of another type.
     #[stable(feature = "ptr_cast", since = "1.38.0")]
     #[rustc_const_stable(feature = "const_ptr_cast", since = "1.38.0")]
-    #[inline]
+    #[inline(always)]
     pub const fn cast<U>(self) -> *mut U {
         self as _
     }
@@ -551,7 +551,7 @@ pub const fn guaranteed_eq(self, other: *mut T) -> bool
     /// ```
     #[stable(feature = "ptr_offset_from", since = "1.47.0")]
     #[rustc_const_unstable(feature = "const_ptr_offset_from", issue = "41079")]
-    #[inline]
+    #[inline(always)]
     pub const unsafe fn offset_from(self, origin: *const T) -> isize
     where
         T: Sized,
@@ -859,7 +859,7 @@ pub fn set_ptr_value(mut self, val: *mut u8) -> Self {
     /// [`ptr::read`]: crate::ptr::read()
     #[stable(feature = "pointer_methods", since = "1.26.0")]
     #[rustc_const_unstable(feature = "const_ptr_read", issue = "80377")]
-    #[inline]
+    #[inline(always)]
     pub const unsafe fn read(self) -> T
     where
         T: Sized,
@@ -879,7 +879,7 @@ pub fn set_ptr_value(mut self, val: *mut u8) -> Self {
     ///
     /// [`ptr::read_volatile`]: crate::ptr::read_volatile()
     #[stable(feature = "pointer_methods", since = "1.26.0")]
-    #[inline]
+    #[inline(always)]
     pub unsafe fn read_volatile(self) -> T
     where
         T: Sized,
@@ -898,7 +898,7 @@ pub unsafe fn read_volatile(self) -> T
     /// [`ptr::read_unaligned`]: crate::ptr::read_unaligned()
     #[stable(feature = "pointer_methods", since = "1.26.0")]
     #[rustc_const_unstable(feature = "const_ptr_read", issue = "80377")]
-    #[inline]
+    #[inline(always)]
     pub const unsafe fn read_unaligned(self) -> T
     where
         T: Sized,
@@ -917,7 +917,7 @@ pub unsafe fn read_volatile(self) -> T
     /// [`ptr::copy`]: crate::ptr::copy()
     #[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
     #[stable(feature = "pointer_methods", since = "1.26.0")]
-    #[inline]
+    #[inline(always)]
     pub const unsafe fn copy_to(self, dest: *mut T, count: usize)
     where
         T: Sized,
@@ -936,7 +936,7 @@ pub unsafe fn read_volatile(self) -> T
     /// [`ptr::copy_nonoverlapping`]: crate::ptr::copy_nonoverlapping()
     #[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
     #[stable(feature = "pointer_methods", since = "1.26.0")]
-    #[inline]
+    #[inline(always)]
     pub const unsafe fn copy_to_nonoverlapping(self, dest: *mut T, count: usize)
     where
         T: Sized,
@@ -955,7 +955,7 @@ pub unsafe fn read_volatile(self) -> T
     /// [`ptr::copy`]: crate::ptr::copy()
     #[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
     #[stable(feature = "pointer_methods", since = "1.26.0")]
-    #[inline]
+    #[inline(always)]
     pub const unsafe fn copy_from(self, src: *const T, count: usize)
     where
         T: Sized,
@@ -974,7 +974,7 @@ pub unsafe fn read_volatile(self) -> T
     /// [`ptr::copy_nonoverlapping`]: crate::ptr::copy_nonoverlapping()
     #[rustc_const_unstable(feature = "const_intrinsic_copy", issue = "80697")]
     #[stable(feature = "pointer_methods", since = "1.26.0")]
-    #[inline]
+    #[inline(always)]
     pub const unsafe fn copy_from_nonoverlapping(self, src: *const T, count: usize)
     where
         T: Sized,
@@ -989,7 +989,7 @@ pub unsafe fn read_volatile(self) -> T
     ///
     /// [`ptr::drop_in_place`]: crate::ptr::drop_in_place()
     #[stable(feature = "pointer_methods", since = "1.26.0")]
-    #[inline]
+    #[inline(always)]
     pub unsafe fn drop_in_place(self) {
         // SAFETY: the caller must uphold the safety contract for `drop_in_place`.
         unsafe { drop_in_place(self) }
@@ -1003,7 +1003,7 @@ pub unsafe fn drop_in_place(self) {
     /// [`ptr::write`]: crate::ptr::write()
     #[stable(feature = "pointer_methods", since = "1.26.0")]
     #[rustc_const_unstable(feature = "const_ptr_write", issue = "none")]
-    #[inline]
+    #[inline(always)]
     pub const unsafe fn write(self, val: T)
     where
         T: Sized,
@@ -1019,7 +1019,7 @@ pub unsafe fn drop_in_place(self) {
     ///
     /// [`ptr::write_bytes`]: crate::ptr::write_bytes()
     #[stable(feature = "pointer_methods", since = "1.26.0")]
-    #[inline]
+    #[inline(always)]
     pub unsafe fn write_bytes(self, val: u8, count: usize)
     where
         T: Sized,
@@ -1039,7 +1039,7 @@ pub unsafe fn write_bytes(self, val: u8, count: usize)
     ///
     /// [`ptr::write_volatile`]: crate::ptr::write_volatile()
     #[stable(feature = "pointer_methods", since = "1.26.0")]
-    #[inline]
+    #[inline(always)]
     pub unsafe fn write_volatile(self, val: T)
     where
         T: Sized,
@@ -1058,7 +1058,7 @@ pub unsafe fn write_volatile(self, val: T)
     /// [`ptr::write_unaligned`]: crate::ptr::write_unaligned()
     #[stable(feature = "pointer_methods", since = "1.26.0")]
     #[rustc_const_unstable(feature = "const_ptr_write", issue = "none")]
-    #[inline]
+    #[inline(always)]
     pub const unsafe fn write_unaligned(self, val: T)
     where
         T: Sized,
@@ -1074,7 +1074,7 @@ pub unsafe fn write_volatile(self, val: T)
     ///
     /// [`ptr::replace`]: crate::ptr::replace()
     #[stable(feature = "pointer_methods", since = "1.26.0")]
-    #[inline]
+    #[inline(always)]
     pub unsafe fn replace(self, src: T) -> T
     where
         T: Sized,
@@ -1091,7 +1091,7 @@ pub unsafe fn replace(self, src: T) -> T
     ///
     /// [`ptr::swap`]: crate::ptr::swap()
     #[stable(feature = "pointer_methods", since = "1.26.0")]
-    #[inline]
+    #[inline(always)]
     pub unsafe fn swap(self, with: *mut T)
     where
         T: Sized,
@@ -1170,7 +1170,7 @@ impl<T> *mut [T] {
     /// let slice: *mut [i8] = ptr::slice_from_raw_parts_mut(ptr::null_mut(), 3);
     /// assert_eq!(slice.len(), 3);
     /// ```
-    #[inline]
+    #[inline(always)]
     #[unstable(feature = "slice_ptr_len", issue = "71146")]
     #[rustc_const_unstable(feature = "const_slice_ptr_len", issue = "71146")]
     pub const fn len(self) -> usize {
@@ -1190,7 +1190,7 @@ pub const fn len(self) -> usize {
     /// let slice: *mut [i8] = ptr::slice_from_raw_parts_mut(ptr::null_mut(), 3);
     /// assert_eq!(slice.as_mut_ptr(), 0 as *mut i8);
     /// ```
-    #[inline]
+    #[inline(always)]
     #[unstable(feature = "slice_ptr_get", issue = "74265")]
     #[rustc_const_unstable(feature = "slice_ptr_get", issue = "74265")]
     pub const fn as_mut_ptr(self) -> *mut T {
@@ -1217,7 +1217,7 @@ pub const fn as_mut_ptr(self) -> *mut T {
     /// }
     /// ```
     #[unstable(feature = "slice_ptr_get", issue = "74265")]
-    #[inline]
+    #[inline(always)]
     pub unsafe fn get_unchecked_mut<I>(self, index: I) -> *mut I::Output
     where
         I: SliceIndex<[T]>,
@@ -1332,7 +1332,7 @@ pub unsafe fn as_uninit_slice_mut<'a>(self) -> Option<&'a mut [MaybeUninit<T>]>
 // Equality for pointers
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: ?Sized> PartialEq for *mut T {
-    #[inline]
+    #[inline(always)]
     fn eq(&self, other: &*mut T) -> bool {
         *self == *other
     }
@@ -1357,27 +1357,27 @@ fn cmp(&self, other: &*mut T) -> Ordering {
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: ?Sized> PartialOrd for *mut T {
-    #[inline]
+    #[inline(always)]
     fn partial_cmp(&self, other: &*mut T) -> Option<Ordering> {
         Some(self.cmp(other))
     }
 
-    #[inline]
+    #[inline(always)]
     fn lt(&self, other: &*mut T) -> bool {
         *self < *other
     }
 
-    #[inline]
+    #[inline(always)]
     fn le(&self, other: &*mut T) -> bool {
         *self <= *other
     }
 
-    #[inline]
+    #[inline(always)]
     fn gt(&self, other: &*mut T) -> bool {
         *self > *other
     }
 
-    #[inline]
+    #[inline(always)]
     fn ge(&self, other: &*mut T) -> bool {
         *self >= *other
     }
index 95dd54976b2c02e2554cc0748e9784faf11e21ee..065acd3f38bb21ad37c3fd337a8536ae160708f5 100644 (file)
@@ -192,14 +192,26 @@ pub const fn is_empty(&self) -> bool {
     #[stable(feature = "is_char_boundary", since = "1.9.0")]
     #[inline]
     pub fn is_char_boundary(&self, index: usize) -> bool {
-        // 0 and len are always ok.
+        // 0 is always ok.
         // Test for 0 explicitly so that it can optimize out the check
         // easily and skip reading string data for that case.
-        if index == 0 || index == self.len() {
+        // Note that optimizing `self.get(..index)` relies on this.
+        if index == 0 {
             return true;
         }
+
         match self.as_bytes().get(index) {
-            None => false,
+            // For `None` we have two options:
+            //
+            // - index == self.len()
+            //   Empty strings are valid, so return true
+            // - index > self.len()
+            //   In this case return false
+            //
+            // The check is placed exactly here, because it improves generated
+            // code on higher opt-levels. See PR #84751 for more details.
+            None => index == self.len(),
+
             // This is bit magic equivalent to: b < 128 || b >= 192
             Some(&b) => (b as i8) >= -0x40,
         }
index c898d483a8ba2e84ccea7ab324796eb49c11d425..355ad1f9f881cb3c44b71ae411a3ea9d7f6d9fda 100644 (file)
@@ -162,6 +162,8 @@ fn sub(
                 fn join($self: $S::Span, other: $S::Span) -> Option<$S::Span>;
                 fn resolved_at($self: $S::Span, at: $S::Span) -> $S::Span;
                 fn source_text($self: $S::Span) -> Option<String>;
+                fn save_span($self: $S::Span) -> usize;
+                fn recover_proc_macro_span(id: usize) -> $S::Span;
             },
         }
     };
@@ -338,6 +340,7 @@ fn unmark(self) -> Self::Unmarked {
     &'a [u8],
     &'a str,
     String,
+    usize,
     Delimiter,
     Level,
     LineColumn,
index c7f58f3615435d6043303e984514957067752457..525fd0fbe3431e3a8d8fdc270af8b7194ea2c5a2 100644 (file)
@@ -265,7 +265,7 @@ fn into_iter(self) -> IntoIter {
 /// Unquoting is done with `$`, and works by taking the single next ident as the unquoted term.
 /// To quote `$` itself, use `$$`.
 #[unstable(feature = "proc_macro_quote", issue = "54722")]
-#[allow_internal_unstable(proc_macro_def_site)]
+#[allow_internal_unstable(proc_macro_def_site, proc_macro_internals)]
 #[rustc_builtin_macro]
 pub macro quote($($t:tt)*) {
     /* compiler built-in */
@@ -394,6 +394,20 @@ pub fn source_text(&self) -> Option<String> {
         self.0.source_text()
     }
 
+    // Used by the implementation of `Span::quote`
+    #[doc(hidden)]
+    #[unstable(feature = "proc_macro_internals", issue = "27812")]
+    pub fn save_span(&self) -> usize {
+        self.0.save_span()
+    }
+
+    // Used by the implementation of `Span::quote`
+    #[doc(hidden)]
+    #[unstable(feature = "proc_macro_internals", issue = "27812")]
+    pub fn recover_proc_macro_span(id: usize) -> Span {
+        Span(bridge::client::Span::recover_proc_macro_span(id))
+    }
+
     diagnostic_method!(error, Level::Error);
     diagnostic_method!(warning, Level::Warning);
     diagnostic_method!(note, Level::Note);
index 144e2d6bac43bb3061ecbb3c785965732e56c7e5..1fd59889709b211f7828314f6d52c5e814c150e5 100644 (file)
@@ -65,6 +65,7 @@ pub fn quote(stream: TokenStream) -> TokenStream {
     if stream.is_empty() {
         return quote!(crate::TokenStream::new());
     }
+    let proc_macro_crate = quote!(crate);
     let mut after_dollar = false;
     let tokens = stream
         .into_iter()
@@ -105,7 +106,7 @@ pub fn quote(stream: TokenStream) -> TokenStream {
                 ))),
                 TokenTree::Ident(tt) => quote!(crate::TokenTree::Ident(crate::Ident::new(
                     (@ TokenTree::from(Literal::string(&tt.to_string()))),
-                    (@ quote_span(tt.span())),
+                    (@ quote_span(proc_macro_crate.clone(), tt.span())),
                 ))),
                 TokenTree::Literal(tt) => quote!(crate::TokenTree::Literal({
                     let mut iter = (@ TokenTree::from(Literal::string(&tt.to_string())))
@@ -115,7 +116,7 @@ pub fn quote(stream: TokenStream) -> TokenStream {
                     if let (Some(crate::TokenTree::Literal(mut lit)), None) =
                         (iter.next(), iter.next())
                     {
-                        lit.set_span((@ quote_span(tt.span())));
+                        lit.set_span((@ quote_span(proc_macro_crate.clone(), tt.span())));
                         lit
                     } else {
                         unreachable!()
@@ -135,6 +136,7 @@ pub fn quote(stream: TokenStream) -> TokenStream {
 /// Quote a `Span` into a `TokenStream`.
 /// This is needed to implement a custom quoter.
 #[unstable(feature = "proc_macro_quote", issue = "54722")]
-pub fn quote_span(_: Span) -> TokenStream {
-    quote!(crate::Span::def_site())
+pub fn quote_span(proc_macro_crate: TokenStream, span: Span) -> TokenStream {
+    let id = span.save_span();
+    quote!((@ proc_macro_crate ) ::Span::recover_proc_macro_span((@ TokenTree::from(Literal::usize_unsuffixed(id)))))
 }
index 695c847d2cde60d8e7ecbcf747a2167a2474f90c..474058a547fd32f43fea34a215941a6551ee66c0 100644 (file)
@@ -14,4 +14,4 @@ core = { path = "../core" }
 compiler_builtins = { version = "0.1.0", features = ['rustc-dep-of-std'] }
 
 [build-dependencies]
-cc = "1.0.1"
+cc = "1.0.67"
index ab7b142ef3db099baee396619ae51edb20f418a6..922c2c2bb8c4dc0749d70c5190e4985733eec1b0 100644 (file)
@@ -17,7 +17,7 @@ panic_unwind = { path = "../panic_unwind", optional = true }
 panic_abort = { path = "../panic_abort" }
 core = { path = "../core" }
 libc = { version = "0.2.93", default-features = false, features = ['rustc-dep-of-std'] }
-compiler_builtins = { version = "0.1.39" }
+compiler_builtins = { version = "0.1.43" }
 profiler_builtins = { path = "../profiler_builtins", optional = true }
 unwind = { path = "../unwind" }
 hashbrown = { version = "0.11", default-features = false, features = ['rustc-dep-of-std'] }
index 11d052dae9e9094a745d2710fd8a720027778611..4403280efc11b9f6f0d93f96800c8ee8acd4cc70 100644 (file)
@@ -324,13 +324,13 @@ fn description(&self) -> &str {
 /// assert_eq!(env::var(key), Ok("VALUE".to_string()));
 /// ```
 #[stable(feature = "env", since = "1.0.0")]
-pub fn set_var<K: AsRef<OsStr>, V: AsRef<OsStr>>(k: K, v: V) {
-    _set_var(k.as_ref(), v.as_ref())
+pub fn set_var<K: AsRef<OsStr>, V: AsRef<OsStr>>(key: K, value: V) {
+    _set_var(key.as_ref(), value.as_ref())
 }
 
-fn _set_var(k: &OsStr, v: &OsStr) {
-    os_imp::setenv(k, v).unwrap_or_else(|e| {
-        panic!("failed to set environment variable `{:?}` to `{:?}`: {}", k, v, e)
+fn _set_var(key: &OsStr, value: &OsStr) {
+    os_imp::setenv(key, value).unwrap_or_else(|e| {
+        panic!("failed to set environment variable `{:?}` to `{:?}`: {}", key, value, e)
     })
 }
 
@@ -366,13 +366,13 @@ fn _set_var(k: &OsStr, v: &OsStr) {
 /// assert!(env::var(key).is_err());
 /// ```
 #[stable(feature = "env", since = "1.0.0")]
-pub fn remove_var<K: AsRef<OsStr>>(k: K) {
-    _remove_var(k.as_ref())
+pub fn remove_var<K: AsRef<OsStr>>(key: K) {
+    _remove_var(key.as_ref())
 }
 
-fn _remove_var(k: &OsStr) {
-    os_imp::unsetenv(k)
-        .unwrap_or_else(|e| panic!("failed to remove environment variable `{:?}`: {}", k, e))
+fn _remove_var(key: &OsStr) {
+    os_imp::unsetenv(key)
+        .unwrap_or_else(|e| panic!("failed to remove environment variable `{:?}`: {}", key, e))
 }
 
 /// An iterator that splits an environment variable into paths according to
index 0ab9f490fd4202b4f2e339fd612c99c06bdcdfad..5f89ac059fd2d9194c7a909a2ee3445a08cc7725 100644 (file)
 #![feature(const_cstr_unchecked)]
 #![feature(const_fn_floating_point_arithmetic)]
 #![feature(const_fn_transmute)]
-#![feature(const_fn)]
 #![feature(const_fn_fn_ptr_basics)]
 #![feature(const_io_structs)]
 #![feature(const_ip)]
index b729349cf530f411adced32a03f01457b2531c9a..b2c5df5410dcab9fa484fc654722a5241a1c9315 100644 (file)
@@ -185,9 +185,10 @@ macro_rules! eprintln {
 /// builds or when debugging in release mode is significantly faster.
 ///
 /// Note that the macro is intended as a debugging tool and therefore you
-/// should avoid having uses of it in version control for long periods.
-/// Use cases involving debug output that should be added to version control
-/// are better served by macros such as [`debug!`] from the [`log`] crate.
+/// should avoid having uses of it in version control for long periods
+/// (other than in tests and similar).
+/// Debug output from production code is better done with other facilities
+/// such as the [`debug!`] macro from the [`log`] crate.
 ///
 /// # Stability
 ///
index 3e634239ad3015f689226f40ebaa7e422dd3f735..7114552745a02f23434a6bd04be48a9e659912f4 100644 (file)
@@ -132,6 +132,7 @@ pub fn panic_any<M: 'static + Any + Send>(msg: M) -> ! {
 /// [`AssertUnwindSafe`] wrapper struct can be used to force this trait to be
 /// implemented for any closed over variables passed to `catch_unwind`.
 #[stable(feature = "catch_unwind", since = "1.9.0")]
+#[cfg_attr(all(not(bootstrap), not(test)), lang = "unwind_safe")]
 #[rustc_on_unimplemented(
     message = "the type `{Self}` may not be safely transferred across an unwind boundary",
     label = "`{Self}` may not be safely transferred across an unwind boundary"
@@ -147,6 +148,7 @@ pub fn panic_any<M: 'static + Any + Send>(msg: M) -> ! {
 /// This is a "helper marker trait" used to provide impl blocks for the
 /// [`UnwindSafe`] trait, for more information see that documentation.
 #[stable(feature = "catch_unwind", since = "1.9.0")]
+#[cfg_attr(all(not(bootstrap), not(test)), lang = "ref_unwind_safe")]
 #[rustc_on_unimplemented(
     message = "the type `{Self}` may contain interior mutability and a reference may not be safely \
                transferrable across a catch_unwind boundary",
index ed0987064e8f744d0473f1619f132c6662aad0c1..cbe14767bd3e7f7e2513e8c60ed3d1b1af19b9c5 100644 (file)
@@ -569,7 +569,7 @@ pub struct Components<'a> {
     prefix: Option<Prefix<'a>>,
 
     // true if path *physically* has a root separator; for most Windows
-    // prefixes, it may have a "logical" rootseparator for the purposes of
+    // prefixes, it may have a "logical" root separator for the purposes of
     // normalization, e.g.,  \\server\share == \\server\share\.
     has_physical_root: bool,
 
index f9536c4203df2928c9e65c25cac6686e964c9e5d..231cc15b8497f30c59e836f7af36e66005d48a7a 100644 (file)
@@ -15,7 +15,7 @@
 pub mod usercalls;
 
 #[cfg(not(test))]
-global_asm!(include_str!("entry.S"));
+global_asm!(include_str!("entry.S"), options(att_syntax));
 
 #[repr(C)]
 struct EntryReturn(u64, u64);
index 6c4f4e1990b76be8a07bde1956d2e3452fd55ee4..c14e98417feb406df66e821ccd81e1293b4baa6f 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 6c4f4e1990b76be8a07bde1956d2e3452fd55ee4
+Subproject commit c14e98417feb406df66e821ccd81e1293b4baa6f
index 69128591e06726b9ce8b55ea6b8412796d92cf9e..f42ded62585e2cb586a1a37baa44bb1a22b0edb8 100644 (file)
@@ -21,7 +21,7 @@ compiler_builtins = "0.1.0"
 cfg-if = "0.1.8"
 
 [build-dependencies]
-cc = { version = "1.0.1" }
+cc = "1.0.67"
 
 [features]
 llvm-libunwind = []
index c14ad6fa5fff4db8878dfe05b24f3b81d647d6a2..a74df97a5c7671f39f9b5c5c60beaa8eb8152e35 100644 (file)
@@ -40,7 +40,7 @@ cmake = "0.1.38"
 filetime = "0.2"
 num_cpus = "1.0"
 getopts = "0.2.19"
-cc = "1.0.35"
+cc = "1.0.67"
 libc = "0.2"
 serde = { version = "1.0.8", features = ["derive"] }
 serde_json = "1.0.2"
index c4cfefb1ce8fa4981cdb81ae29def428c5ae0122..f9972ac7b9d93a3fb1157619f5b40544cf750bc4 100644 (file)
@@ -562,6 +562,7 @@ fn run(self, builder: &Builder<'_>) {
         cargo.rustdocflag("--enable-index-page");
         cargo.rustdocflag("-Zunstable-options");
         cargo.rustdocflag("-Znormalize-docs");
+        cargo.rustdocflag("--show-type-layout");
         compile::rustc_cargo(builder, &mut cargo, target);
 
         // Only include compiler crates, no dependencies of those, such as `libc`.
@@ -661,6 +662,7 @@ fn run(self, builder: &Builder<'_>) {
 
         cargo.rustdocflag("--document-private-items");
         cargo.rustdocflag("--enable-index-page");
+        cargo.rustdocflag("--show-type-layout");
         cargo.rustdocflag("-Zunstable-options");
         builder.run(&mut cargo.into());
     }
index 78163651158ed3452bb5d42640722a55787e5a06..0e9c561c68994820348a175bd5d71b961e2994bb 100644 (file)
@@ -827,17 +827,30 @@ fn run(self, builder: &Builder<'_>) {
             }
 
             let out_dir = builder.test_out(self.target).join("rustdoc-gui");
-            let mut command = builder.rustdoc_cmd(self.compiler);
-            command.arg("src/test/rustdoc-gui/lib.rs").arg("-o").arg(&out_dir);
-            builder.run(&mut command);
 
+            // We remove existing folder to be sure there won't be artifacts remaining.
+            let _ = fs::remove_dir_all(&out_dir);
+
+            // We generate docs for the libraries present in the rustdoc-gui's src folder.
+            let libs_dir = builder.build.src.join("src/test/rustdoc-gui/src");
+            for entry in libs_dir.read_dir().expect("read_dir call failed") {
+                let entry = entry.expect("invalid entry");
+                let path = entry.path();
+                if path.extension().map(|e| e == "rs").unwrap_or(false) {
+                    let mut command = builder.rustdoc_cmd(self.compiler);
+                    command.arg(path).arg("-o").arg(&out_dir);
+                    builder.run(&mut command);
+                }
+            }
+
+            // We now run GUI tests.
             let mut command = Command::new(&nodejs);
             command
-                .arg("src/tools/rustdoc-gui/tester.js")
+                .arg(builder.build.src.join("src/tools/rustdoc-gui/tester.js"))
                 .arg("--doc-folder")
-                .arg(out_dir.join("test_docs"))
+                .arg(out_dir)
                 .arg("--tests-folder")
-                .arg("src/test/rustdoc-gui");
+                .arg(builder.build.src.join("src/test/rustdoc-gui"));
             builder.run(&mut command);
         } else {
             builder.info("No nodejs found, skipping \"src/test/rustdoc-gui\" tests");
diff --git a/src/ci/channel b/src/ci/channel
new file mode 100644 (file)
index 0000000..bf867e0
--- /dev/null
@@ -0,0 +1 @@
+nightly
index a59a90b86bcafbea7bcd52a3ec8400469dfba495..343091cb779fc2705a153c71c9c59c50a935f5fd 100644 (file)
@@ -126,6 +126,10 @@ x--expand-yaml-anchors--remove:
         run: src/ci/scripts/should-skip-this.sh
         <<: *step
 
+      - name: ensure the channel matches the target branch
+        run: src/ci/scripts/verify-channel.sh
+        <<: *step
+
       - name: configure GitHub Actions to kill the build when outdated
         uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
         with:
index ad2a8c771de9caed4c7a9106d0d51420e1b2aa77..c3c717266db4564c673325d7e8ace9d9b19cd3e0 100755 (executable)
@@ -12,7 +12,7 @@ RUSTC_BOOTSTRAP=1 ./build/$PGO_HOST/stage2/bin/rustc --edition=2018 \
 
 # Download and build a single-file stress test benchmark on perf.rust-lang.org.
 function pgo_perf_benchmark {
-    local PERF=9442def56a39d742bf27ebcc3e0614cf117e1bc2
+    local PERF=1e19fc4c6168d2f7596e512f42f358f245d8f09d
     local github_prefix=https://raw.githubusercontent.com/rust-lang/rustc-perf/$PERF
     local name=$1
     curl -o /tmp/$name.rs $github_prefix/collector/benchmarks/$name/src/lib.rs
index 1958b6ee41d7fb9374ed619e8a1680e97652fece..35f80a935c6937ea022eef265ed2f9e89701542a 100755 (executable)
@@ -62,17 +62,10 @@ if [ "$DIST_SRC" = "" ]; then
   RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-dist-src"
 fi
 
-# If we're deploying artifacts then we set the release channel, otherwise if
-# we're not deploying then we want to be sure to enable all assertions because
-# we'll be running tests
-#
-# FIXME: need a scheme for changing this `nightly` value to `beta` and `stable`
-#        either automatically or manually.
-export RUST_RELEASE_CHANNEL=nightly
-
 # Always set the release channel for bootstrap; this is normally not important (i.e., only dist
 # builds would seem to matter) but in practice bootstrap wants to know whether we're targeting
 # master, beta, or stable with a build to determine whether to run some checks (notably toolstate).
+export RUST_RELEASE_CHANNEL="$(cat "${ci_dir}/channel")"
 RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --release-channel=$RUST_RELEASE_CHANNEL"
 
 if [ "$DEPLOY$DEPLOY_ALT" = "1" ]; then
diff --git a/src/ci/scripts/verify-channel.sh b/src/ci/scripts/verify-channel.sh
new file mode 100755 (executable)
index 0000000..d02dc36
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/bash
+# We want to make sure all PRs are targeting the right branch when they're
+# opened, otherwise we risk (for example) to land a beta-specific change to the
+# master branch. This script ensures the branch of the PR matches the channel.
+
+set -euo pipefail
+IFS=$'\n\t'
+
+source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
+
+if isCiBranch auto || isCiBranch try; then
+    echo "channel verification is only executed on PR builds"
+    exit
+fi
+
+channel=$(cat "$(ciCheckoutPath)/src/ci/channel")
+case "${channel}" in
+    nightly)
+        channel_branch="master"
+        ;;
+    beta)
+        channel_branch="beta"
+        ;;
+    stable)
+        channel_branch="stable"
+        ;;
+    *)
+        echo "error: unknown channel defined in src/ci/channel: ${channel}"
+        exit 1
+esac
+
+branch="$(ciBaseBranch)"
+if [[ "${branch}" != "${channel_branch}" ]]; then
+    echo "error: PRs changing the \`${channel}\` channel should be sent to the \
+\`${channel_branch}\` branch!"
+
+    exit 1
+fi
index 3c196c9478cf8adfdb91aac614434078431a5b44..332a949a4dc51bda7202d33aa63337d8902c4212 100644 (file)
@@ -73,6 +73,18 @@ function isCiBranch {
     fi
 }
 
+function ciBaseBranch {
+    if isAzurePipelines; then
+        echo "unsupported on Azure Pipelines"
+        exit 1
+    elif isGitHubActions; then
+        echo "${GITHUB_BASE_REF#refs/heads/}"
+    else
+        echo "ciBaseBranch only works inside CI!"
+        exit 1
+    fi
+}
+
 function ciCommit {
     if isAzurePipelines; then
         echo "${BUILD_SOURCEVERSION}"
index 50dd06cb71beb27fdc0eebade5509cdcc1f821ed..55a26488ddefc8433e73a2e8352d70f7a5c7fc2b 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 50dd06cb71beb27fdc0eebade5509cdcc1f821ed
+Subproject commit 55a26488ddefc8433e73a2e8352d70f7a5c7fc2b
index 8551afbb2ca6f5ea37fe58380318b209785e4e02..55de6fa3c1f331774da19472c9ee57d2ae9eb039 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 8551afbb2ca6f5ea37fe58380318b209785e4e02
+Subproject commit 55de6fa3c1f331774da19472c9ee57d2ae9eb039
index d23f9da8469617e6c81121d9fd123443df70595d..5aa457bf1b54bd2cd5d4cf49797f29299bdf89a7 160000 (submodule)
@@ -1 +1 @@
-Subproject commit d23f9da8469617e6c81121d9fd123443df70595d
+Subproject commit 5aa457bf1b54bd2cd5d4cf49797f29299bdf89a7
index e0a721f5202e6d9bec0aff99f10e44480c0da9e7..5f8c6da200ada77760a2fe1096938ef58151c9a6 160000 (submodule)
@@ -1 +1 @@
-Subproject commit e0a721f5202e6d9bec0aff99f10e44480c0da9e7
+Subproject commit 5f8c6da200ada77760a2fe1096938ef58151c9a6
index e72b43a64925ce053dc7830e21c1a57ba00499bd..1e6c7fbda4c45e85adf63ff3f82fa9c870b1447f 160000 (submodule)
@@ -1 +1 @@
-Subproject commit e72b43a64925ce053dc7830e21c1a57ba00499bd
+Subproject commit 1e6c7fbda4c45e85adf63ff3f82fa9c870b1447f
diff --git a/src/doc/unstable-book/src/language-features/const-fn.md b/src/doc/unstable-book/src/language-features/const-fn.md
deleted file mode 100644 (file)
index bcf7f78..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-# `const_fn`
-
-The tracking issue for this feature is: [#57563]
-
-[#57563]: https://github.com/rust-lang/rust/issues/57563
-
-------------------------
-
-The `const_fn` feature enables additional functionality not stabilized in the
-[minimal subset of `const_fn`](https://github.com/rust-lang/rust/issues/53555)
index fa96e47ee037fe26b43ac4b6bd15c6ffeec06e21..107fc6d42cf8ecf298b4dc5e8fbf890bbfbcc9e4 100644 (file)
@@ -26,6 +26,7 @@ Inline assembly is currently supported on the following architectures:
 - AArch64
 - RISC-V
 - NVPTX
+- PowerPC
 - Hexagon
 - MIPS32r2 and MIPS64r2
 - wasm32
@@ -459,7 +460,7 @@ options := "options(" option *["," option] [","] ")"
 asm := "asm!(" format_string *("," format_string) *("," [ident "="] operand) ["," options] [","] ")"
 ```
 
-The macro will initially be supported only on ARM, AArch64, Hexagon, x86, x86-64 and RISC-V targets. Support for more targets may be added in the future. The compiler will emit an error if `asm!` is used on an unsupported target.
+The macro will initially be supported only on ARM, AArch64, Hexagon, PowerPC, x86, x86-64 and RISC-V targets. Support for more targets may be added in the future. The compiler will emit an error if `asm!` is used on an unsupported target.
 
 [format-syntax]: https://doc.rust-lang.org/std/fmt/#syntax
 
@@ -565,6 +566,9 @@ Here is the list of currently supported register classes:
 | RISC-V | `reg` | `x1`, `x[5-7]`, `x[9-15]`, `x[16-31]` (non-RV32E) | `r` |
 | RISC-V | `freg` | `f[0-31]` | `f` |
 | Hexagon | `reg` | `r[0-28]` | `r` |
+| PowerPC | `reg` | `r[0-31]` | `r` |
+| PowerPC | `reg_nonzero` | | `r[1-31]` | `b` |
+| PowerPC | `freg` | `f[0-31]` | `f` |
 | wasm32 | `local` | None\* | `r` |
 
 > **Note**: On x86 we treat `reg_byte` differently from `reg` because the compiler can allocate `al` and `ah` separately whereas `reg` reserves the whole register.
@@ -607,6 +611,9 @@ Each register class has constraints on which value types they can be used with.
 | RISC-V | `freg` | `f` | `f32` |
 | RISC-V | `freg` | `d` | `f64` |
 | Hexagon | `reg` | None | `i8`, `i16`, `i32`, `f32` |
+| PowerPC | `reg` | None | `i8`, `i16`, `i32` |
+| PowerPC | `reg_nonzero` | None | `i8`, `i16`, `i32` |
+| PowerPC | `freg` | None | `f32`, `f64` |
 | wasm32 | `local` | None | `i8` `i16` `i32` `i64` `f32` `f64` |
 
 > **Note**: For the purposes of the above table pointers, function pointers and `isize`/`usize` are treated as the equivalent integer type (`i16`/`i32`/`i64` depending on the target).
@@ -744,6 +751,9 @@ The supported modifiers are a subset of LLVM's (and GCC's) [asm template argumen
 | RISC-V | `reg` | None | `x1` | None |
 | RISC-V | `freg` | None | `f0` | None |
 | Hexagon | `reg` | None | `r0` | None |
+| PowerPC | `reg` | None | `0` | None |
+| PowerPC | `reg_nonzero` | None | `3` | `b` |
+| PowerPC | `freg` | None | `0` | None |
 
 > Notes:
 > - on ARM `e` / `f`: this prints the low or high doubleword register name of a NEON quad (128-bit) register.
index ce1155a977cd05eb46c79f4a78f62f562d44948f..146d17b4638c8357fcdac18ace09d2209836d299 100644 (file)
@@ -8,12 +8,9 @@ The tracking issue for this feature is: [#35119]
 
 The `global_asm!` macro allows the programmer to write arbitrary
 assembly outside the scope of a function body, passing it through
-`rustc` and `llvm` to the assembler. The macro is a no-frills
-interface to LLVM's concept of [module-level inline assembly]. That is,
-all caveats applicable to LLVM's module-level inline assembly apply
-to `global_asm!`.
-
-[module-level inline assembly]: http://llvm.org/docs/LangRef.html#module-level-inline-assembly
+`rustc` and `llvm` to the assembler. That is to say, `global_asm!` is
+equivalent to assembling the asm with an external assembler and then
+linking the resulting object file with the current crate.
 
 `global_asm!` fills a role not currently satisfied by either `asm!`
 or `#[naked]` functions. The programmer has _all_ features of the
@@ -38,11 +35,11 @@ And a more complicated usage looks like this:
 # mod x86 {
 
 pub mod sally {
-    global_asm!(r#"
-        .global foo
-      foo:
-        jmp baz
-    "#);
+    global_asm!(
+        ".global foo",
+        "foo:",
+        "jmp baz",
+    );
 
     #[no_mangle]
     pub unsafe extern "C" fn baz() {}
@@ -56,11 +53,11 @@ extern "C" {
 }
 
 pub mod harry {
-    global_asm!(r#"
-        .global bar
-      bar:
-        jmp quux
-    "#);
+    global_asm!(
+        ".global bar",
+        "bar:",
+        "jmp quux",
+    );
 
     #[no_mangle]
     pub unsafe extern "C" fn quux() {}
@@ -69,8 +66,44 @@ pub mod harry {
 ```
 
 You may use `global_asm!` multiple times, anywhere in your crate, in
-whatever way suits you. The effect is as if you concatenated all
-usages and placed the larger, single usage in the crate root.
+whatever way suits you. However, you should not rely on assembler state
+(e.g. assembler macros) defined in one `global_asm!` to be available in
+another one. It is implementation-defined whether the multiple usages
+are concatenated into one or assembled separately.
+
+`global_asm!` also supports `const` operands like `asm!`, which allows
+constants defined in Rust to be used in assembly code:
+
+```rust,no_run
+#![feature(global_asm)]
+# #[cfg(any(target_arch="x86", target_arch="x86_64"))]
+# mod x86 {
+const C: i32 = 1234;
+global_asm!(
+    ".global bar",
+    "bar: .word {c}",
+    c = const C,
+);
+# }
+```
+
+The syntax for passing operands is the same as `asm!` except that only
+`const` operands are allowed. Refer to the [asm](asm.md) documentation
+for more details.
+
+On x86, the assembly code will use intel syntax by default. You can
+override this by adding `options(att_syntax)` at the end of the macro
+arguments list:
+
+```rust,no_run
+#![feature(global_asm)]
+# #[cfg(any(target_arch="x86", target_arch="x86_64"))]
+# mod x86 {
+global_asm!("movl ${}, %ecx", const 5, options(att_syntax));
+// is equivalent to
+global_asm!("mov ecx, {}", const 5);
+# }
+```
 
 ------------------------
 
index 68856f82fe94c95827c46f079b2f8d2ad4d3c849..090314e3a4bbdb03a6a42a760c8020f08ca70926 100644 (file)
@@ -119,7 +119,7 @@ impl<'a, 'tcx> BlanketImplFinder<'a, 'tcx> {
                             .clean(self.cx),
                         negative_polarity: false,
                         synthetic: false,
-                        blanket_impl: Some(trait_ref.self_ty().clean(self.cx)),
+                        blanket_impl: Some(box trait_ref.self_ty().clean(self.cx)),
                     }),
                     cfg: None,
                 });
index e1dde8eeaf84ae838513f84283e1aa532c3204e1..feeb03b1b67004db00205d262f0d8b7d523e73d0 100644 (file)
@@ -533,8 +533,7 @@ fn is_elided_lifetime(param: &hir::GenericParam<'_>) -> bool {
                 match param.kind {
                     GenericParamDefKind::Lifetime => unreachable!(),
                     GenericParamDefKind::Type { did, ref bounds, .. } => {
-                        cx.impl_trait_bounds
-                            .insert(FakeDefId::new_real(did).into(), bounds.clone());
+                        cx.impl_trait_bounds.insert(did.into(), bounds.clone());
                     }
                     GenericParamDefKind::Const { .. } => unreachable!(),
                 }
@@ -615,7 +614,7 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Generics {
             .collect::<Vec<GenericParamDef>>();
 
         // param index -> [(DefId of trait, associated type name, type)]
-        let mut impl_trait_proj = FxHashMap::<u32, Vec<(FakeDefId, Symbol, Ty<'tcx>)>>::default();
+        let mut impl_trait_proj = FxHashMap::<u32, Vec<(DefId, Symbol, Ty<'tcx>)>>::default();
 
         let where_predicates = preds
             .predicates
@@ -687,13 +686,7 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Generics {
                 if let Some(proj) = impl_trait_proj.remove(&idx) {
                     for (trait_did, name, rhs) in proj {
                         let rhs = rhs.clean(cx);
-                        simplify::merge_bounds(
-                            cx,
-                            &mut bounds,
-                            trait_did.expect_real(),
-                            name,
-                            &rhs,
-                        );
+                        simplify::merge_bounds(cx, &mut bounds, trait_did, name, &rhs);
                     }
                 }
             } else {
@@ -1183,8 +1176,7 @@ fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &mut DocContext<'_>) -> Type {
                 if let Some(new_ty) = cx.ty_substs.get(&did).cloned() {
                     return new_ty;
                 }
-                if let Some(bounds) = cx.impl_trait_bounds.remove(&FakeDefId::new_real(did).into())
-                {
+                if let Some(bounds) = cx.impl_trait_bounds.remove(&did.into()) {
                     return ImplTrait(bounds);
                 }
             }
index bca7a8cfcee0970a62b55b05ecff01c93dd5c501..edd3d77eeb7809b0acec5031b56f2c4983d43e05 100644 (file)
@@ -73,10 +73,6 @@ impl FakeDefId {
         Self::Fake(DefIndex::from(id), krate)
     }
 
-    crate fn new_real(id: DefId) -> Self {
-        Self::Real(id)
-    }
-
     #[inline]
     crate fn is_local(self) -> bool {
         match self {
@@ -164,7 +160,7 @@ fn def_id(&self) -> DefId {
 
     crate fn src_root(&self, tcx: TyCtxt<'_>) -> PathBuf {
         match self.src(tcx) {
-            FileName::Real(ref p) => match p.local_path().parent() {
+            FileName::Real(ref p) => match p.local_path_if_available().parent() {
                 Some(p) => p.to_path_buf(),
                 None => PathBuf::new(),
             },
@@ -470,7 +466,7 @@ pub fn from_def_id_and_attrs_and_parts(
             .filter_map(|ItemLink { link: s, link_text, did, ref fragment }| {
                 match did {
                     Some(did) => {
-                        if let Some((mut href, ..)) = href(did.expect_real(), cx) {
+                        if let Some((mut href, ..)) = href(did.clone(), cx) {
                             if let Some(ref fragment) = *fragment {
                                 href.push('#');
                                 href.push_str(fragment);
@@ -972,7 +968,7 @@ fn from_iter<T>(iter: T) -> Self
     /// This may not be the same as `link` if there was a disambiguator
     /// in an intra-doc link (e.g. \[`fn@f`\])
     pub(crate) link_text: String,
-    pub(crate) did: Option<FakeDefId>,
+    pub(crate) did: Option<DefId>,
     /// The url fragment to append to the link
     pub(crate) fragment: Option<String>,
 }
@@ -2235,7 +2231,7 @@ impl Constant {
     crate items: Vec<Item>,
     crate negative_polarity: bool,
     crate synthetic: bool,
-    crate blanket_impl: Option<Type>,
+    crate blanket_impl: Option<Box<Type>>,
 }
 
 impl Impl {
index 045b42d0dcaf75b8efbe3fe2827a211e803c5472..b75e98ae16c16f2718d49d7313bc48865ecff5b3 100644 (file)
@@ -267,6 +267,8 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
     crate document_hidden: bool,
     /// If `true`, generate a JSON file in the crate folder instead of HTML redirection files.
     crate generate_redirect_map: bool,
+    /// Show the memory layout of types in the docs.
+    crate show_type_layout: bool,
     crate unstable_features: rustc_feature::UnstableFeatures,
     crate emit: Vec<EmitType>,
 }
@@ -636,6 +638,7 @@ fn println_condition(condition: Condition) {
         let document_hidden = matches.opt_present("document-hidden-items");
         let run_check = matches.opt_present("check");
         let generate_redirect_map = matches.opt_present("generate-redirect-map");
+        let show_type_layout = matches.opt_present("show-type-layout");
 
         let (lint_opts, describe_lints, lint_cap) = get_cmd_lint_options(matches, error_format);
 
@@ -695,6 +698,7 @@ fn println_condition(condition: Condition) {
                 document_private,
                 document_hidden,
                 generate_redirect_map,
+                show_type_layout,
                 unstable_features: rustc_feature::UnstableFeatures::from_environment(
                     crate_name.as_deref(),
                 ),
index b43916f9f332cc76f47ae964b84f32587aebf086..2930c3c5fb7ec510bdea8ac02a2ec01a78f48cd6 100644 (file)
@@ -576,12 +576,12 @@ fn visit_path(&mut self, path: &'tcx Path<'_>, _id: HirId) {
 /// for `impl Trait` in argument position.
 #[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
 crate enum ImplTraitParam {
-    DefId(FakeDefId),
+    DefId(DefId),
     ParamIndex(u32),
 }
 
-impl From<FakeDefId> for ImplTraitParam {
-    fn from(did: FakeDefId) -> Self {
+impl From<DefId> for ImplTraitParam {
+    fn from(did: DefId) -> Self {
         ImplTraitParam::DefId(did)
     }
 }
index 03e3fe52f71ee3535b3d733e2429a3713031f501..3a4d39e1d7f72c9662be328a89fa00b6ffecbcdd 100644 (file)
@@ -839,7 +839,7 @@ fn generate_name(&self, line: usize, filename: &FileName) -> String {
         if !item_path.is_empty() {
             item_path.push(' ');
         }
-        format!("{} - {}(line {})", filename, item_path, line)
+        format!("{} - {}(line {})", filename.prefer_local(), item_path, line)
     }
 
     crate fn set_position(&mut self, position: Span) {
@@ -851,8 +851,10 @@ fn get_filename(&self) -> FileName {
             let filename = source_map.span_to_filename(self.position);
             if let FileName::Real(ref filename) = filename {
                 if let Ok(cur_dir) = env::current_dir() {
-                    if let Ok(path) = filename.local_path().strip_prefix(&cur_dir) {
-                        return path.to_owned().into();
+                    if let Some(local_path) = filename.local_path() {
+                        if let Ok(path) = local_path.strip_prefix(&cur_dir) {
+                            return path.to_owned().into();
+                        }
                     }
                 }
             }
@@ -882,16 +884,22 @@ fn add_test(&mut self, test: String, config: LangString, line: usize) {
             self.compiling_test_count.fetch_add(1, Ordering::SeqCst);
         }
 
-        // FIXME(#44940): if doctests ever support path remapping, then this filename
-        // needs to be the result of `SourceMap::span_to_unmapped_path`.
         let path = match &filename {
-            FileName::Real(path) => path.local_path().to_path_buf(),
+            FileName::Real(path) => {
+                if let Some(local_path) = path.local_path() {
+                    local_path.to_path_buf()
+                } else {
+                    // Somehow we got the filename from the metadata of another crate, should never happen
+                    unreachable!("doctest from a different crate");
+                }
+            }
             _ => PathBuf::from(r"doctest.rs"),
         };
 
         // For example `module/file.rs` would become `module_file_rs`
         let file = filename
-            .to_string()
+            .prefer_local()
+            .to_string_lossy()
             .chars()
             .map(|c| if c.is_ascii_alphanumeric() { c } else { '_' })
             .collect::<String>();
index 37d11d4ed47c445a5fbbe0c904b63e2aab80903c..723792381ef09df8d1820090f1a53a3bf4fada9b 100644 (file)
@@ -1,17 +1,10 @@
 use crate::clean::*;
 
-crate struct StripItem(pub Item);
-
-impl StripItem {
-    crate fn strip(self) -> Item {
-        match self.0 {
-            Item { kind: box StrippedItem(..), .. } => self.0,
-            mut i => {
-                i.kind = box StrippedItem(i.kind);
-                i
-            }
-        }
+crate fn strip_item(mut item: Item) -> Item {
+    if !matches!(*item.kind, StrippedItem(..)) {
+        item.kind = box StrippedItem(item.kind);
     }
+    item
 }
 
 crate trait DocFolder: Sized {
index 50496f320096cf32a47c8159b460b41cdd665a6e..5734a4a98e2b5f32f870497f28c8e567410d747e 100644 (file)
@@ -67,7 +67,7 @@
     /// When rendering traits, it's often useful to be able to list all
     /// implementors of the trait, and this mapping is exactly, that: a mapping
     /// of trait ids to the list of known implementors of the trait
-    crate implementors: FxHashMap<FakeDefId, Vec<Impl>>,
+    crate implementors: FxHashMap<DefId, Vec<Impl>>,
 
     /// Cache of where external crate documentation can be found.
     crate extern_locations: FxHashMap<CrateNum, ExternalLocation>,
@@ -299,7 +299,7 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
                             desc: item
                                 .doc_value()
                                 .map_or_else(String::new, |x| short_markdown_summary(&x.as_str())),
-                            parent: parent.map(FakeDefId::new_real),
+                            parent,
                             parent_idx: None,
                             search_type: get_index_search_type(&item, &self.empty_cache, self.tcx),
                             aliases: item.attrs.get_doc_aliases(),
index 99e96fdcf1eb4e91404e7d65b6ba30f91c59f515..ec04c94dc11f9131c2b8c45dcb1dc9bfe3a97059 100644 (file)
@@ -105,7 +105,7 @@ impl<'a> Page<'a> {
                            placeholder=\"Click or press ‘S’ to search, ‘?’ for more options…\" \
                            type=\"search\">\
                 </div>\
-                <button type=\"button\" class=\"help-button\">?</button>
+                <button type=\"button\" id=\"help-button\">?</button>
                 <a id=\"settings-menu\" href=\"{root_path}settings.html\">\
                     <img src=\"{static_root_path}wheel{suffix}.svg\" \
                          width=\"18\" height=\"18\" \
index c2b40ab34e2551c1062525c3ce6d7f33c45705c4..00a91e07d65e3ff46d5e2d65da8697616a627854 100644 (file)
@@ -1347,6 +1347,7 @@ fn init_id_map() -> FxHashMap<String, usize> {
     map.insert("theme-picker".to_owned(), 1);
     map.insert("theme-choices".to_owned(), 1);
     map.insert("settings-menu".to_owned(), 1);
+    map.insert("help-button".to_owned(), 1);
     map.insert("main".to_owned(), 1);
     map.insert("search".to_owned(), 1);
     map.insert("crate-search".to_owned(), 1);
index 57520a1a1fb46f769b0ccb4449855e6e2cd592fb..3e056c4b67a70df1d3127b54b22d9e7b910444cf 100644 (file)
@@ -7,7 +7,7 @@
 
 use crate::clean;
 use crate::clean::types::{
-    FakeDefId, FnDecl, FnRetTy, GenericBound, Generics, GetDefId, Type, WherePredicate,
+    FnDecl, FnRetTy, GenericBound, Generics, GetDefId, Type, WherePredicate,
 };
 use crate::formats::cache::Cache;
 use crate::formats::item_type::ItemType;
@@ -82,7 +82,7 @@
                 defid_to_pathid.insert(defid, pathid);
                 lastpathid += 1;
 
-                if let Some(&(ref fqp, short)) = paths.get(&defid.expect_real()) {
+                if let Some(&(ref fqp, short)) = paths.get(&defid) {
                     crate_paths.push((short, fqp.last().unwrap().clone()));
                     Some(pathid)
                 } else {
@@ -214,7 +214,7 @@ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
 
 fn get_index_type(clean_type: &clean::Type, cache: &Cache) -> RenderType {
     RenderType {
-        ty: clean_type.def_id_full(cache).map(FakeDefId::new_real),
+        ty: 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),
@@ -256,7 +256,7 @@ fn get_generics(clean_type: &clean::Type, cache: &Cache) -> Option<Vec<Generic>>
             .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).map(FakeDefId::new_real),
+                    defid: t.def_id_full(cache),
                     idx: None,
                 })
             })
index 4e17dc8d3a7d0121f2b9d8f3be38699c0912807d..8676efd9fa8b2549fb90ffba66e34fe0f149bbca 100644 (file)
@@ -91,6 +91,8 @@
     crate include_sources: bool,
     /// The local file sources we've emitted and their respective url-paths.
     crate local_sources: FxHashMap<PathBuf, String>,
+    /// Show the memory layout of types in the docs.
+    pub(super) show_type_layout: bool,
     /// Whether the collapsed pass ran
     collapsed: bool,
     /// The base-URL of the issue tracker for when an item has been tagged with
@@ -135,8 +137,8 @@ impl SharedContext<'_> {
         Ok(())
     }
 
-    /// Based on whether the `collapse-docs` pass was run, return either the `doc_value` or the
-    /// `collapsed_doc_value` of the given item.
+    /// Returns the `collapsed_doc_value` of the given item if this is the main crate, otherwise
+    /// returns the `doc_value`.
     crate fn maybe_collapsed_doc_value<'a>(&self, item: &'a clean::Item) -> Option<String> {
         if self.collapsed { item.collapsed_doc_value() } else { item.doc_value() }
     }
@@ -291,7 +293,7 @@ pub(super) fn src_href(&self, item: &clean::Item) -> Option<String> {
 
         // We can safely ignore synthetic `SourceFile`s.
         let file = match item.span(self.tcx()).filename(self.sess()) {
-            FileName::Real(ref path) => path.local_path().to_path_buf(),
+            FileName::Real(ref path) => path.local_path_if_available().to_path_buf(),
             _ => return None,
         };
         let file = &file;
@@ -373,11 +375,12 @@ fn init(
             generate_search_filter,
             unstable_features,
             generate_redirect_map,
+            show_type_layout,
             ..
         } = options;
 
         let src_root = match krate.src {
-            FileName::Real(ref p) => match p.local_path().parent() {
+            FileName::Real(ref p) => match p.local_path_if_available().parent() {
                 Some(p) => p.to_path_buf(),
                 None => PathBuf::new(),
             },
@@ -446,6 +449,7 @@ fn init(
             all: RefCell::new(AllTypes::new()),
             errors: receiver,
             redirections: if generate_redirect_map { Some(Default::default()) } else { None },
+            show_type_layout,
         };
 
         // Add the default themes to the `Vec` of stylepaths
index 5b54b32e4ddeaef06f1d49e032dc56b250cbc713..e4dbf145866296a64416c840d92f6de732e45cc1 100644 (file)
@@ -87,7 +87,7 @@
     crate name: String,
     crate path: String,
     crate desc: String,
-    crate parent: Option<FakeDefId>,
+    crate parent: Option<DefId>,
     crate parent_idx: Option<usize>,
     crate search_type: Option<IndexItemFunctionType>,
     crate aliases: Box<[String]>,
@@ -96,7 +96,7 @@
 /// A type used for the search index.
 #[derive(Debug)]
 crate struct RenderType {
-    ty: Option<FakeDefId>,
+    ty: Option<DefId>,
     idx: Option<usize>,
     name: Option<String>,
     generics: Option<Vec<Generic>>,
@@ -128,7 +128,7 @@ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
 #[derive(Debug)]
 crate struct Generic {
     name: String,
-    defid: Option<FakeDefId>,
+    defid: Option<DefId>,
     idx: Option<usize>,
 }
 
@@ -2137,7 +2137,7 @@ fn print_sidebar_section(
         "</div>",
     );
 
-    if let Some(implementors) = cx.cache.implementors.get(&it.def_id) {
+    if let Some(implementors) = cx.cache.implementors.get(&it.def_id.expect_real()) {
         let cache = cx.cache();
         let mut res = implementors
             .iter()
index 7ccc313cc5905ef6c6486f33af86d43f80dd38bb..ff639cb292462acd82cbbd4766ef3626b7fcd5d4 100644 (file)
@@ -7,6 +7,7 @@
 use rustc_hir::def::CtorKind;
 use rustc_hir::def_id::DefId;
 use rustc_middle::middle::stability;
+use rustc_middle::ty::layout::LayoutError;
 use rustc_middle::ty::TyCtxt;
 use rustc_span::hygiene::MacroKind;
 use rustc_span::symbol::{kw, sym, Symbol};
@@ -572,10 +573,6 @@ fn write_small_section_header(w: &mut Buffer, id: &str, title: &str, extra_conte
         )
     }
 
-    fn write_loading_content(w: &mut Buffer, extra_content: &str) {
-        write!(w, "{}<span class=\"loading-content\">Loading content...</span>", extra_content)
-    }
-
     fn trait_item(w: &mut Buffer, cx: &Context<'_>, m: &clean::Item, t: &clean::Item) {
         let name = m.name.as_ref().unwrap();
         info!("Documenting {} on {:?}", name, t.name);
@@ -600,7 +597,7 @@ fn trait_item(w: &mut Buffer, cx: &Context<'_>, m: &clean::Item, t: &clean::Item
         for t in types {
             trait_item(w, cx, t, it);
         }
-        write_loading_content(w, "</div>");
+        w.write_str("</div>");
     }
 
     if !consts.is_empty() {
@@ -613,7 +610,7 @@ fn trait_item(w: &mut Buffer, cx: &Context<'_>, m: &clean::Item, t: &clean::Item
         for t in consts {
             trait_item(w, cx, t, it);
         }
-        write_loading_content(w, "</div>");
+        w.write_str("</div>");
     }
 
     // Output the documentation for each function individually
@@ -627,7 +624,7 @@ fn trait_item(w: &mut Buffer, cx: &Context<'_>, m: &clean::Item, t: &clean::Item
         for m in required {
             trait_item(w, cx, m, it);
         }
-        write_loading_content(w, "</div>");
+        w.write_str("</div>");
     }
     if !provided.is_empty() {
         write_small_section_header(
@@ -639,13 +636,13 @@ fn trait_item(w: &mut Buffer, cx: &Context<'_>, m: &clean::Item, t: &clean::Item
         for m in provided {
             trait_item(w, cx, m, it);
         }
-        write_loading_content(w, "</div>");
+        w.write_str("</div>");
     }
 
     // If there are methods directly on this trait object, render them here.
     render_assoc_items(w, cx, it, it.def_id.expect_real(), AssocItemRender::All);
 
-    if let Some(implementors) = cx.cache.implementors.get(&it.def_id) {
+    if let Some(implementors) = cx.cache.implementors.get(&it.def_id.expect_real()) {
         // The DefId is for the first Type found with that name. The bool is
         // if any Types with the same name but different DefId have been found.
         let mut implementor_dups: FxHashMap<Symbol, (DefId, bool)> = FxHashMap::default();
@@ -702,7 +699,6 @@ fn trait_item(w: &mut Buffer, cx: &Context<'_>, m: &clean::Item, t: &clean::Item
                     &[],
                 );
             }
-            write_loading_content(w, "");
         }
 
         write_small_section_header(
@@ -714,7 +710,7 @@ fn trait_item(w: &mut Buffer, cx: &Context<'_>, m: &clean::Item, t: &clean::Item
         for implementor in concrete {
             render_implementor(cx, implementor, it, w, &implementor_dups, &[]);
         }
-        write_loading_content(w, "</div>");
+        w.write_str("</div>");
 
         if t.is_auto {
             write_small_section_header(
@@ -733,7 +729,7 @@ fn trait_item(w: &mut Buffer, cx: &Context<'_>, m: &clean::Item, t: &clean::Item
                     &collect_paths_for_type(implementor.inner_impl().for_.clone(), &cx.cache),
                 );
             }
-            write_loading_content(w, "</div>");
+            w.write_str("</div>");
         }
     } else {
         // even without any implementations to write in, we still want the heading and list, so the
@@ -742,18 +738,16 @@ fn trait_item(w: &mut Buffer, cx: &Context<'_>, m: &clean::Item, t: &clean::Item
             w,
             "implementors",
             "Implementors",
-            "<div class=\"item-list\" id=\"implementors-list\">",
+            "<div class=\"item-list\" id=\"implementors-list\"></div>",
         );
-        write_loading_content(w, "</div>");
 
         if t.is_auto {
             write_small_section_header(
                 w,
                 "synthetic-implementors",
                 "Auto implementors",
-                "<div class=\"item-list\" id=\"synthetic-implementors-list\">",
+                "<div class=\"item-list\" id=\"synthetic-implementors-list\"></div>",
             );
-            write_loading_content(w, "</div>");
         }
     }
 
@@ -830,11 +824,12 @@ fn item_typedef(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::T
 
     document(w, cx, it, None);
 
+    let def_id = it.def_id.expect_real();
     // Render any items associated directly to this alias, as otherwise they
     // won't be visible anywhere in the docs. It would be nice to also show
     // associated items from the aliased type (see discussion in #32077), but
     // we need #14072 to make sense of the generics.
-    render_assoc_items(w, cx, it, it.def_id.expect_real(), AssocItemRender::All)
+    render_assoc_items(w, cx, it, def_id, AssocItemRender::All);
 }
 
 fn item_union(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Union) {
@@ -846,6 +841,7 @@ fn item_union(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Uni
     });
 
     document(w, cx, it, None);
+
     let mut fields = s
         .fields
         .iter()
@@ -880,7 +876,9 @@ fn item_union(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Uni
             document(w, cx, field, Some(it));
         }
     }
-    render_assoc_items(w, cx, it, it.def_id.expect_real(), AssocItemRender::All)
+    let def_id = it.def_id.expect_real();
+    render_assoc_items(w, cx, it, def_id, AssocItemRender::All);
+    document_type_layout(w, cx, def_id);
 }
 
 fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum) {
@@ -940,6 +938,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
     });
 
     document(w, cx, it, None);
+
     if !e.variants.is_empty() {
         write!(
             w,
@@ -1014,7 +1013,9 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum
             render_stability_since(w, variant, it, cx.tcx());
         }
     }
-    render_assoc_items(w, cx, it, it.def_id.expect_real(), AssocItemRender::All)
+    let def_id = it.def_id.expect_real();
+    render_assoc_items(w, cx, it, def_id, AssocItemRender::All);
+    document_type_layout(w, cx, def_id);
 }
 
 fn item_macro(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Macro) {
@@ -1114,6 +1115,7 @@ fn item_struct(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::St
     });
 
     document(w, cx, it, None);
+
     let mut fields = s
         .fields
         .iter()
@@ -1152,7 +1154,9 @@ fn item_struct(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::St
             }
         }
     }
-    render_assoc_items(w, cx, it, it.def_id.expect_real(), AssocItemRender::All)
+    let def_id = it.def_id.expect_real();
+    render_assoc_items(w, cx, it, def_id, AssocItemRender::All);
+    document_type_layout(w, cx, def_id);
 }
 
 fn item_static(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::Static) {
@@ -1522,3 +1526,62 @@ struct update syntax will not work.",
         w.write_str("</div></details>");
     }
 }
+
+fn document_type_layout(w: &mut Buffer, cx: &Context<'_>, ty_def_id: DefId) {
+    if !cx.shared.show_type_layout {
+        return;
+    }
+
+    writeln!(w, "<h2 class=\"small-section-header\">Layout</h2>");
+    writeln!(w, "<div class=\"docblock\">");
+
+    let tcx = cx.tcx();
+    let param_env = tcx.param_env(ty_def_id);
+    let ty = tcx.type_of(ty_def_id);
+    match tcx.layout_of(param_env.and(ty)) {
+        Ok(ty_layout) => {
+            writeln!(
+                w,
+                "<div class=\"warning\"><p><strong>Note:</strong> Most layout information is \
+                 completely unstable and may be different between compiler versions and platforms. \
+                 The only exception is types with certain <code>repr(...)</code> attributes. \
+                 Please see the Rust Reference’s \
+                 <a href=\"https://doc.rust-lang.org/reference/type-layout.html\">“Type Layout”</a> \
+                 chapter for details on type layout guarantees.</p></div>"
+            );
+            if ty_layout.layout.abi.is_unsized() {
+                writeln!(w, "<p><strong>Size:</strong> (unsized)</p>");
+            } else {
+                let bytes = ty_layout.layout.size.bytes();
+                writeln!(
+                    w,
+                    "<p><strong>Size:</strong> {size} byte{pl}</p>",
+                    size = bytes,
+                    pl = if bytes == 1 { "" } else { "s" },
+                );
+            }
+        }
+        // This kind of layout error can occur with valid code, e.g. if you try to
+        // get the layout of a generic type such as `Vec<T>`.
+        Err(LayoutError::Unknown(_)) => {
+            writeln!(
+                w,
+                "<p><strong>Note:</strong> Unable to compute type layout, \
+                 possibly due to this type having generic parameters. \
+                 Layout can only be computed for concrete, fully-instantiated types.</p>"
+            );
+        }
+        // This kind of error probably can't happen with valid code, but we don't
+        // want to panic and prevent the docs from building, so we just let the
+        // user know that we couldn't compute the layout.
+        Err(LayoutError::SizeOverflow(_)) => {
+            writeln!(
+                w,
+                "<p><strong>Note:</strong> Encountered an error during type layout; \
+                 the type was too big.</p>"
+            );
+        }
+    }
+
+    writeln!(w, "</div>");
+}
index d0518cb6862fe3987e4015712bf510e1a6c8a397..c25a73f58eb602328f078f352ff71965f740485f 100644 (file)
@@ -465,8 +465,6 @@ fn to_json_string(&self) -> String {
     // Update the list of all implementors for traits
     let dst = cx.dst.join("implementors");
     for (&did, imps) in &cx.cache.implementors {
-        let did = did.expect_real();
-
         // Private modules can leak through to this phase of rustdoc, which
         // could contain implementations for otherwise private types. In some
         // rare cases we could find an implementation for an item which wasn't
index 57c33f94918d71fd097ddf80609814ca0e406504..5e2a94fe6845ff3026e12f7462702398ada8b53d 100644 (file)
@@ -56,7 +56,11 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
                 Err(e) => {
                     self.scx.tcx.sess.span_err(
                         item.span(self.scx.tcx).inner(),
-                        &format!("failed to render source code for `{}`: {}", filename, e),
+                        &format!(
+                            "failed to render source code for `{}`: {}",
+                            filename.prefer_local(),
+                            e
+                        ),
                     );
                     false
                 }
@@ -76,7 +80,13 @@ fn sess(&self) -> &'tcx Session {
     /// Renders the given filename into its corresponding HTML source file.
     fn emit_source(&mut self, filename: &FileName) -> Result<(), Error> {
         let p = match *filename {
-            FileName::Real(ref file) => file.local_path().to_path_buf(),
+            FileName::Real(ref file) => {
+                if let Some(local_path) = file.local_path() {
+                    local_path.to_path_buf()
+                } else {
+                    unreachable!("only the current crate should have sources emitted");
+                }
+            }
             _ => return Ok(()),
         };
         if self.scx.local_sources.contains_key(&*p) {
@@ -113,7 +123,7 @@ fn emit_source(&mut self, filename: &FileName) -> Result<(), Error> {
         href.push_str(&fname.to_string_lossy());
 
         let title = format!("{} - source", src_fname.to_string_lossy());
-        let desc = format!("Source of the Rust file `{}`.", filename);
+        let desc = format!("Source of the Rust file `{}`.", filename.prefer_remapped());
         let page = layout::Page {
             title: &title,
             css_class: "source",
index dc65e14ab37b83cee273fb8b41710b66e1da45f6..be30871ea4c70f2a27bb2d692a8173041f17ccb7 100644 (file)
@@ -1,6 +1,6 @@
 // Local js definitions:
-/* global addClass, getSettingValue, hasClass */
-/* global onEach, onEachLazy, hasOwnProperty, removeClass, updateLocalStorage */
+/* global addClass, getSettingValue, hasClass, searchState */
+/* global onEach, onEachLazy, removeClass */
 /* global switchTheme, useSystemTheme */
 
 if (!String.prototype.startsWith) {
@@ -156,152 +156,154 @@ function hideThemeButtonState() {
     "use strict";
 
     window.searchState = {
-      loadingText: "Loading search results...",
-      input: document.getElementsByClassName("search-input")[0],
-      outputElement: function() {
-        return document.getElementById("search");
-      },
-      title: null,
-      titleBeforeSearch: document.title,
-      timeout: null,
-      // On the search screen, so you remain on the last tab you opened.
-      //
-      // 0 for "In Names"
-      // 1 for "In Parameters"
-      // 2 for "In Return Types"
-      currentTab: 0,
-      mouseMovedAfterSearch: true,
-      clearInputTimeout: function() {
-        if (searchState.timeout !== null) {
-            clearTimeout(searchState.timeout);
-            searchState.timeout = null;
-        }
-      },
-      // Sets the focus on the search bar at the top of the page
-      focus: function() {
-          searchState.input.focus();
-      },
-      // Removes the focus from the search bar.
-      defocus: function() {
-          searchState.input.blur();
-      },
-      showResults: function(search) {
-        if (search === null || typeof search === 'undefined') {
-            search = searchState.outputElement();
-        }
-        addClass(main, "hidden");
-        removeClass(search, "hidden");
-        searchState.mouseMovedAfterSearch = false;
-        document.title = searchState.title;
-      },
-      hideResults: function(search) {
-        if (search === null || typeof search === 'undefined') {
-            search = searchState.outputElement();
-        }
-        addClass(search, "hidden");
-        removeClass(main, "hidden");
-        document.title = searchState.titleBeforeSearch;
-        // We also remove the query parameter from the URL.
-        if (searchState.browserSupportsHistoryApi()) {
-            history.replaceState("", window.currentCrate + " - Rust",
-                getNakedUrl() + window.location.hash);
-        }
-      },
-      getQueryStringParams: function() {
-        var params = {};
-        window.location.search.substring(1).split("&").
-            map(function(s) {
-                var pair = s.split("=");
-                params[decodeURIComponent(pair[0])] =
-                    typeof pair[1] === "undefined" ? null : decodeURIComponent(pair[1]);
-            });
-        return params;
-      },
-      putBackSearch: function(search_input) {
-        var search = searchState.outputElement();
-        if (search_input.value !== "" && hasClass(search, "hidden")) {
-            searchState.showResults(search);
-            if (searchState.browserSupportsHistoryApi()) {
-                var extra = "?search=" + encodeURIComponent(search_input.value);
-                history.replaceState(search_input.value, "",
-                    getNakedUrl() + extra + window.location.hash);
+        loadingText: "Loading search results...",
+        input: document.getElementsByClassName("search-input")[0],
+        outputElement: function() {
+            return document.getElementById("search");
+        },
+        title: null,
+        titleBeforeSearch: document.title,
+        timeout: null,
+        // On the search screen, so you remain on the last tab you opened.
+        //
+        // 0 for "In Names"
+        // 1 for "In Parameters"
+        // 2 for "In Return Types"
+        currentTab: 0,
+        mouseMovedAfterSearch: true,
+        clearInputTimeout: function() {
+            if (searchState.timeout !== null) {
+                clearTimeout(searchState.timeout);
+                searchState.timeout = null;
             }
+        },
+        // Sets the focus on the search bar at the top of the page
+        focus: function() {
+            searchState.input.focus();
+        },
+        // Removes the focus from the search bar.
+        defocus: function() {
+            searchState.input.blur();
+        },
+        showResults: function(search) {
+            if (search === null || typeof search === 'undefined') {
+                search = searchState.outputElement();
+            }
+            addClass(main, "hidden");
+            removeClass(search, "hidden");
+            searchState.mouseMovedAfterSearch = false;
             document.title = searchState.title;
-        }
-      },
-      browserSupportsHistoryApi: function() {
-          return window.history && typeof window.history.pushState === "function";
-      },
-      setup: function() {
-        var search_input = searchState.input;
-        if (!searchState.input) {
-            return;
-        }
-        function loadScript(url) {
-            var script = document.createElement('script');
-            script.src = url;
-            document.head.append(script);
-        }
-
-        var searchLoaded = false;
-        function loadSearch() {
-            if (!searchLoaded) {
-                searchLoaded = true;
-                loadScript(window.searchJS);
-                loadScript(window.searchIndexJS);
+        },
+        hideResults: function(search) {
+            if (search === null || typeof search === 'undefined') {
+                search = searchState.outputElement();
+            }
+            addClass(search, "hidden");
+            removeClass(main, "hidden");
+            document.title = searchState.titleBeforeSearch;
+            // We also remove the query parameter from the URL.
+            if (searchState.browserSupportsHistoryApi()) {
+                history.replaceState("", window.currentCrate + " - Rust",
+                    getNakedUrl() + window.location.hash);
+            }
+        },
+        getQueryStringParams: function() {
+            var params = {};
+            window.location.search.substring(1).split("&").
+                map(function(s) {
+                    var pair = s.split("=");
+                    params[decodeURIComponent(pair[0])] =
+                        typeof pair[1] === "undefined" ? null : decodeURIComponent(pair[1]);
+                });
+            return params;
+        },
+        putBackSearch: function(search_input) {
+            var search = searchState.outputElement();
+            if (search_input.value !== "" && hasClass(search, "hidden")) {
+                searchState.showResults(search);
+                if (searchState.browserSupportsHistoryApi()) {
+                    var extra = "?search=" + encodeURIComponent(search_input.value);
+                    history.replaceState(search_input.value, "",
+                        getNakedUrl() + extra + window.location.hash);
+                }
+                document.title = searchState.title;
+            }
+        },
+        browserSupportsHistoryApi: function() {
+            return window.history && typeof window.history.pushState === "function";
+        },
+        setup: function() {
+            var search_input = searchState.input;
+            if (!searchState.input) {
+                return;
+            }
+            function loadScript(url) {
+                var script = document.createElement('script');
+                script.src = url;
+                document.head.append(script);
             }
-        }
 
-        search_input.addEventListener("focus", function() {
-            searchState.putBackSearch(this);
-            search_input.origPlaceholder = searchState.input.placeholder;
-            search_input.placeholder = "Type your search here.";
-            loadSearch();
-        });
-        search_input.addEventListener("blur", function() {
-            search_input.placeholder = searchState.input.origPlaceholder;
-        });
+            var searchLoaded = false;
+            function loadSearch() {
+                if (!searchLoaded) {
+                    searchLoaded = true;
+                    loadScript(window.searchJS);
+                    loadScript(window.searchIndexJS);
+                }
+            }
 
-        document.addEventListener("mousemove", function() {
-          searchState.mouseMovedAfterSearch = true;
-        });
+            search_input.addEventListener("focus", function() {
+                searchState.putBackSearch(this);
+                search_input.origPlaceholder = searchState.input.placeholder;
+                search_input.placeholder = "Type your search here.";
+                loadSearch();
+            });
+            search_input.addEventListener("blur", function() {
+                search_input.placeholder = searchState.input.origPlaceholder;
+            });
 
-        search_input.removeAttribute('disabled');
+            document.addEventListener("mousemove", function() {
+                searchState.mouseMovedAfterSearch = true;
+            });
 
-        // `crates{version}.js` should always be loaded before this script, so we can use it safely.
-        searchState.addCrateDropdown(window.ALL_CRATES);
-        var params = searchState.getQueryStringParams();
-        if (params.search !== undefined) {
-            var search = searchState.outputElement();
-            search.innerHTML = "<h3 style=\"text-align: center;\">" +
-               searchState.loadingText + "</h3>";
-            searchState.showResults(search);
-            loadSearch();
-        }
-      },
-      addCrateDropdown: function(crates) {
-        var elem = document.getElementById("crate-search");
+            search_input.removeAttribute('disabled');
+
+            // `crates{version}.js` should always be loaded before this script, so we can use it
+            // safely.
+            searchState.addCrateDropdown(window.ALL_CRATES);
+            var params = searchState.getQueryStringParams();
+            if (params.search !== undefined) {
+                var search = searchState.outputElement();
+                search.innerHTML = "<h3 style=\"text-align: center;\">" +
+                   searchState.loadingText + "</h3>";
+                searchState.showResults(search);
+                loadSearch();
+            }
+        },
+        addCrateDropdown: function(crates) {
+            var elem = document.getElementById("crate-search");
 
-        if (!elem) {
-            return;
-        }
-        var savedCrate = getSettingValue("saved-filter-crate");
-        for (var i = 0, len = crates.length; i < len; ++i) {
-            var option = document.createElement("option");
-            option.value = crates[i];
-            option.innerText = crates[i];
-            elem.appendChild(option);
-            // Set the crate filter from saved storage, if the current page has the saved crate
-            // filter.
-            //
-            // If not, ignore the crate filter -- we want to support filtering for crates on sites
-            // like doc.rust-lang.org where the crates may differ from page to page while on the
-            // same domain.
-            if (crates[i] === savedCrate) {
-                elem.value = savedCrate;
+            if (!elem) {
+                return;
             }
-        }
-      },
+            var savedCrate = getSettingValue("saved-filter-crate");
+            for (var i = 0, len = crates.length; i < len; ++i) {
+                var option = document.createElement("option");
+                option.value = crates[i];
+                option.innerText = crates[i];
+                elem.appendChild(option);
+                // Set the crate filter from saved storage, if the current page has the saved crate
+                // filter.
+                //
+                // If not, ignore the crate filter -- we want to support filtering for crates on
+                // sites like doc.rust-lang.org where the crates may differ from page to page while
+                // on the
+                // same domain.
+                if (crates[i] === savedCrate) {
+                    elem.value = savedCrate;
+                }
+            }
+        },
     };
 
     function getPageId() {
@@ -345,10 +347,6 @@ function hideThemeButtonState() {
         document.getElementsByTagName("body")[0].style.marginTop = "";
     }
 
-    function isHidden(elem) {
-        return elem.offsetHeight === 0;
-    }
-
     var toggleAllDocsId = "toggle-all-docs";
     var main = document.getElementById("main");
     var savedHash = "";
@@ -381,56 +379,9 @@ function hideThemeButtonState() {
         }
     }
 
-    function highlightSourceLines(match, ev) {
-        if (typeof match === "undefined") {
-            // If we're in mobile mode, we should hide the sidebar in any case.
-            hideSidebar();
-            match = window.location.hash.match(/^#?(\d+)(?:-(\d+))?$/);
-        }
-        if (!match) {
-            return;
-        }
-        var from = parseInt(match[1], 10);
-        var to = from;
-        if (typeof match[2] !== "undefined") {
-            to = parseInt(match[2], 10);
-        }
-        if (to < from) {
-            var tmp = to;
-            to = from;
-            from = tmp;
-        }
-        var elem = document.getElementById(from);
-        if (!elem) {
-            return;
-        }
-        if (!ev) {
-            var x = document.getElementById(from);
-            if (x) {
-                x.scrollIntoView();
-            }
-        }
-        onEachLazy(document.getElementsByClassName("line-numbers"), function(e) {
-            onEachLazy(e.getElementsByTagName("span"), function(i_e) {
-                removeClass(i_e, "line-highlighted");
-            });
-        });
-        for (var i = from; i <= to; ++i) {
-            elem = document.getElementById(i);
-            if (!elem) {
-                break;
-            }
-            addClass(elem, "line-highlighted");
-        }
-    }
-
     function onHashChange(ev) {
         // If we're in mobile mode, we should hide the sidebar in any case.
         hideSidebar();
-        var match = window.location.hash.match(/^#?(\d+)(?:-(\d+))?$/);
-        if (match) {
-            return highlightSourceLines(match, ev);
-        }
         handleHashes(ev);
     }
 
@@ -448,14 +399,14 @@ function hideThemeButtonState() {
     }
 
     function getHelpElement(build) {
-        if (build !== false) {
+        if (build) {
             buildHelperPopup();
         }
         return document.getElementById("help");
     }
 
     function displayHelp(display, ev, help) {
-        if (display === true) {
+        if (display) {
             help = help ? help : getHelpElement(true);
             if (hasClass(help, "hidden")) {
                 ev.preventDefault();
@@ -466,7 +417,7 @@ function hideThemeButtonState() {
             // No need to build the help popup if we want to hide it in case it hasn't been
             // built yet...
             help = help ? help : getHelpElement(false);
-            if (help && hasClass(help, "hidden") === false) {
+            if (help && !hasClass(help, "hidden")) {
                 ev.preventDefault();
                 addClass(help, "hidden");
                 removeClass(document.body, "blur");
@@ -477,9 +428,9 @@ function hideThemeButtonState() {
     function handleEscape(ev) {
         var help = getHelpElement(false);
         var search = searchState.outputElement();
-        if (hasClass(help, "hidden") === false) {
+        if (!hasClass(help, "hidden")) {
             displayHelp(false, ev, help);
-        } else if (hasClass(search, "hidden") === false) {
+        } else if (!hasClass(search, "hidden")) {
             searchState.clearInputTimeout();
             ev.preventDefault();
             searchState.hideResults(search);
@@ -491,7 +442,7 @@ function hideThemeButtonState() {
     var disableShortcuts = getSettingValue("disable-shortcuts") === "true";
     function handleShortcut(ev) {
         // Don't interfere with browser shortcuts
-        if (ev.ctrlKey || ev.altKey || ev.metaKey || disableShortcuts === true) {
+        if (ev.ctrlKey || ev.altKey || ev.metaKey || disableShortcuts) {
             return;
         }
 
@@ -585,78 +536,9 @@ function hideThemeButtonState() {
         }
     }
 
-    function findParentElement(elem, tagName) {
-        do {
-            if (elem && elem.tagName === tagName) {
-                return elem;
-            }
-            elem = elem.parentNode;
-        } while (elem);
-        return null;
-    }
-
     document.addEventListener("keypress", handleShortcut);
     document.addEventListener("keydown", handleShortcut);
 
-    var handleSourceHighlight = (function() {
-        var prev_line_id = 0;
-
-        var set_fragment = function(name) {
-            var x = window.scrollX,
-                y = window.scrollY;
-            if (searchState.browserSupportsHistoryApi()) {
-                history.replaceState(null, null, "#" + name);
-                highlightSourceLines();
-            } else {
-                location.replace("#" + name);
-            }
-            // Prevent jumps when selecting one or many lines
-            window.scrollTo(x, y);
-        };
-
-        return function(ev) {
-            var cur_line_id = parseInt(ev.target.id, 10);
-            ev.preventDefault();
-
-            if (ev.shiftKey && prev_line_id) {
-                // Swap selection if needed
-                if (prev_line_id > cur_line_id) {
-                    var tmp = prev_line_id;
-                    prev_line_id = cur_line_id;
-                    cur_line_id = tmp;
-                }
-
-                set_fragment(prev_line_id + "-" + cur_line_id);
-            } else {
-                prev_line_id = cur_line_id;
-
-                set_fragment(cur_line_id);
-            }
-        };
-    }());
-
-    document.addEventListener("click", function(ev) {
-        var helpElem = getHelpElement(false);
-        if (hasClass(ev.target, "help-button")) {
-            displayHelp(true, ev);
-        } else if (ev.target.tagName === "SPAN" && hasClass(ev.target.parentNode, "line-numbers")) {
-            handleSourceHighlight(ev);
-        } else if (helpElem && hasClass(helpElem, "hidden") === false) {
-            var is_inside_help_popup = ev.target !== helpElem && helpElem.contains(ev.target);
-            if (is_inside_help_popup === false) {
-                addClass(helpElem, "hidden");
-                removeClass(document.body, "blur");
-            }
-        } else {
-            // Making a collapsed element visible on onhashchange seems
-            // too late
-            var a = findParentElement(ev.target, "A");
-            if (a && a.hash) {
-                expandSection(a.hash.replace(/^#/, ""));
-            }
-        }
-    });
-
     (function() {
         var x = document.getElementsByClassName("version-selector");
         if (x.length > 0) {
@@ -667,7 +549,7 @@ function hideThemeButtonState() {
                     len = window.rootPath.match(/\.\.\//g).length + 1;
 
                 for (i = 0; i < len; ++i) {
-                    match = url.match(/\/[^\/]*$/);
+                    match = url.match(/\/[^/]*$/);
                     if (i < len - 1) {
                         stripped = match[0] + stripped;
                     }
@@ -908,11 +790,11 @@ function hideThemeButtonState() {
         function implHider(addOrRemove, fullHide) {
             return function(n) {
                 var shouldHide =
-                    fullHide === true ||
-                    hasClass(n, "method") === true ||
-                    hasClass(n, "associatedconstant") === true;
-                if (shouldHide === true || hasClass(n, "type") === true) {
-                    if (shouldHide === true) {
+                    fullHide ||
+                    hasClass(n, "method") ||
+                    hasClass(n, "associatedconstant");
+                if (shouldHide || hasClass(n, "type")) {
+                    if (shouldHide) {
                         if (addOrRemove) {
                             addClass(n, "hidden-by-impl-hider");
                         } else {
@@ -934,7 +816,7 @@ function hideThemeButtonState() {
 
         var relatedDoc;
         var action = mode;
-        if (hasClass(toggle.parentNode, "impl") === false) {
+        if (!hasClass(toggle.parentNode, "impl")) {
             relatedDoc = toggle.parentNode.nextElementSibling;
             if (hasClass(relatedDoc, "item-info")) {
                 relatedDoc = relatedDoc.nextElementSibling;
@@ -964,11 +846,11 @@ function hideThemeButtonState() {
             relatedDoc = parentElem;
             var docblock = relatedDoc.nextElementSibling;
 
-            while (hasClass(relatedDoc, "impl-items") === false) {
+            while (!hasClass(relatedDoc, "impl-items")) {
                 relatedDoc = relatedDoc.nextElementSibling;
             }
 
-            if (!relatedDoc && hasClass(docblock, "docblock") === false) {
+            if (!relatedDoc && !hasClass(docblock, "docblock")) {
                 return;
             }
 
@@ -987,7 +869,7 @@ function hideThemeButtonState() {
             if (action === "show") {
                 removeClass(relatedDoc, "fns-now-collapsed");
                 // Stability/deprecation/portability information is never hidden.
-                if (hasClass(docblock, "item-info") === false) {
+                if (!hasClass(docblock, "item-info")) {
                     removeClass(docblock, "hidden-by-usual-hider");
                 }
                 onEachLazy(toggle.childNodes, adjustToggle(false, dontApplyBlockRule));
@@ -996,7 +878,7 @@ function hideThemeButtonState() {
                 addClass(relatedDoc, "fns-now-collapsed");
                 // Stability/deprecation/portability information should be shown even when detailed
                 // info is hidden.
-                if (hasClass(docblock, "item-info") === false) {
+                if (!hasClass(docblock, "item-info")) {
                     addClass(docblock, "hidden-by-usual-hider");
                 }
                 onEachLazy(toggle.childNodes, adjustToggle(true, dontApplyBlockRule));
@@ -1045,7 +927,7 @@ function hideThemeButtonState() {
             });
         }
 
-        if (hideMethodDocs === true) {
+        if (hideMethodDocs) {
             onEachLazy(document.getElementsByClassName("method"), function(e) {
                 var toggle = e.parentNode;
                 if (toggle) {
@@ -1066,13 +948,11 @@ function hideThemeButtonState() {
         });
 
         var currentType = document.getElementsByClassName("type-decl")[0];
-        var className = null;
         if (currentType) {
             currentType = currentType.getElementsByClassName("rust")[0];
             if (currentType) {
                 onEachLazy(currentType.classList, function(item) {
                     if (item !== "main") {
-                        className = item;
                         return true;
                     }
                 });
@@ -1121,6 +1001,27 @@ function hideThemeButtonState() {
         });
     }());
 
+    function handleClick(id, f) {
+        var elem = document.getElementById(id);
+        if (elem) {
+            elem.addEventListener("click", f);
+        }
+    }
+    handleClick("help-button", function(ev) {
+        displayHelp(true, ev);
+    });
+
+    onEachLazy(document.getElementsByTagName("a"), function(el) {
+        // For clicks on internal links (<A> tags with a hash property), we expand the section we're
+        // jumping to *before* jumping there. We can't do this in onHashChange, because it changes
+        // the height of the document so we wind up scrolled to the wrong place.
+        if (el.hash) {
+            el.addEventListener("click", function() {
+                expandSection(el.hash.slice(1));
+            });
+        }
+    });
+
     onEachLazy(document.getElementsByClassName("notable-traits"), function(e) {
         e.onclick = function() {
             this.getElementsByClassName('notable-traits-tooltiptext')[0]
@@ -1132,7 +1033,7 @@ function hideThemeButtonState() {
     if (sidebar_menu) {
         sidebar_menu.onclick = function() {
             var sidebar = document.getElementsByClassName("sidebar")[0];
-            if (hasClass(sidebar, "mobile") === true) {
+            if (hasClass(sidebar, "mobile")) {
                 hideSidebar();
             } else {
                 showSidebar();
@@ -1140,31 +1041,18 @@ function hideThemeButtonState() {
         };
     }
 
-    if (main) {
-        onEachLazy(main.getElementsByClassName("loading-content"), function(e) {
-            e.remove();
-        });
-        onEachLazy(main.childNodes, function(e) {
-            // Unhide the actual content once loading is complete. Headers get
-            // flex treatment for their horizontal layout, divs get block treatment
-            // for vertical layout (column-oriented flex layout for divs caused
-            // errors in mobile browsers).
-            if (e.tagName === "H2" || e.tagName === "H3") {
-                var nextTagName = e.nextElementSibling.tagName;
-                if (nextTagName === "H2" || nextTagName === "H3") {
-                    e.nextElementSibling.style.display = "flex";
-                } else if (nextTagName !== "DETAILS") {
-                    e.nextElementSibling.style.display = "block";
-                }
-            }
-        });
-    }
-
-    function buildHelperPopup() {
+    var buildHelperPopup = function() {
         var popup = document.createElement("aside");
         addClass(popup, "hidden");
         popup.id = "help";
 
+        popup.addEventListener("click", function(ev) {
+            if (ev.target === popup) {
+                // Clicked the blurred zone outside the help popup; dismiss help.
+                displayHelp(false, ev);
+            }
+        });
+
         var book_info = document.createElement("span");
         book_info.innerHTML = "You can find more information in \
             <a href=\"https://doc.rust-lang.org/rustdoc/\">the rustdoc book</a>.";
@@ -1220,10 +1108,10 @@ function hideThemeButtonState() {
         insertAfter(popup, searchState.outputElement());
         // So that it's only built once and then it'll do nothing when called!
         buildHelperPopup = function() {};
-    }
+    };
 
     onHashChange(null);
-    window.onhashchange = onHashChange;
+    window.addEventListener("hashchange", onHashChange);
     searchState.setup();
 }());
 
index 4d3332877c0d5281c9b6021ec8ebce972f8d1334..0a196edd53b1dd063900a27a45a598e8e49be2f8 100644 (file)
@@ -4,31 +4,6 @@ of content is hidden by default (depending on the settings too), we have to over
 rules.
 */
 
-#main > h2 + div, #main > h2 + h3, #main > h3 + div {
-       display: block;
-}
-
-.loading-content {
-       display: none;
-}
-
-#main > h2 + div, #main > h3 + div {
-       display: block;
-}
-
-#main > h2 + h3 {
-       display: flex;
-}
-
-#main .impl-items .hidden {
-       display: block !important;
-}
-
-#main .impl-items h4.hidden {
-       /* Without this rule, the version and the "[src]" span aren't on the same line as the header. */
-       display: flex !important;
-}
-
 #main .attributes {
        /* Since there is no toggle (the "[-]") when JS is disabled, no need for this margin either. */
        margin-left: 0 !important;
index aaa2525644f117fa2318e26f5fb4d1c09c39c36c..e2e1aefa4a84207cf2530217cfae8b1f264bf494 100644 (file)
@@ -145,7 +145,7 @@ h4.type.trait-impl, h4.associatedconstant.trait-impl, h4.associatedtype.trait-im
 
 h1, h2, h3, h4,
 .sidebar, a.source, .search-input, .content table td:first-child > a,
-.collapse-toggle, div.item-list .out-of-band,
+div.item-list .out-of-band,
 #source-sidebar, #sidebar-toggle,
 details.rustdoc-toggle > summary::before,
 details.undocumented > summary::before,
@@ -371,6 +371,8 @@ nav.sub {
        border: 1px solid;
        padding: 13px 8px;
        text-align: right;
+       border-top-left-radius: 5px;
+       border-bottom-left-radius: 5px;
 }
 
 .rustdoc:not(.source) .example-wrap > pre.rust {
@@ -398,8 +400,6 @@ nav.sub {
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
-       border-top-left-radius: 5px;
-       border-bottom-left-radius: 5px;
 }
 .line-numbers span {
        cursor: pointer;
@@ -431,11 +431,6 @@ nav.sub {
 #main > .docblock h2 { font-size: 1.15em; }
 #main > .docblock h3, #main > .docblock h4, #main > .docblock h5 { font-size: 1em; }
 
-#main > h2 + div, #main > h2 + h3, #main > h3 + div {
-       display: none; /* Changed to flex or block via js once the page is loaded */
-       flex-wrap: wrap;
-}
-
 .docblock h1 { font-size: 1em; }
 .docblock h2 { font-size: 0.95em; }
 .docblock h3, .docblock h4, .docblock h5 { font-size: 0.9em; }
@@ -547,7 +542,7 @@ h4 > code, h3 > code, .invisible > code {
        font-size: 0.8em;
 }
 
-.content .methods > div:not(.notable-traits) {
+.content .methods > div:not(.notable-traits):not(.methods) {
        margin-left: 40px;
        margin-bottom: 15px;
 }
@@ -565,9 +560,6 @@ h4 > code, h3 > code, .invisible > code {
 .content .docblock >.impl-items table td {
        padding: 0;
 }
-.toggle-wrapper.marg-left > .collapse-toggle {
-       left: -24px;
-}
 .content .docblock > .impl-items .table-display, .impl-items table td {
        border: none;
 }
@@ -974,45 +966,6 @@ a.test-arrow:hover{
        font-weight: 300;
 }
 
-.collapse-toggle {
-       font-weight: 300;
-       position: absolute;
-       left: -23px;
-       top: 0;
-}
-
-h3 > .collapse-toggle, h4 > .collapse-toggle {
-       font-size: 0.8em;
-       top: 5px;
-}
-
-.toggle-wrapper > .collapse-toggle {
-       left: -24px;
-       margin-top: 0px;
-}
-
-.toggle-wrapper {
-       position: relative;
-       margin-top: 0;
-}
-
-.toggle-wrapper.collapsed {
-       height: 25px;
-       transition: height .2s;
-       margin-bottom: .6em;
-}
-
-.collapse-toggle > .inner {
-       display: inline-block;
-       width: 1.2ch;
-       text-align: center;
-}
-
-.collapse-toggle.hidden-default {
-       position: relative;
-       margin-left: 20px;
-}
-
 .since + .srclink {
        display: table-cell;
        padding-left: 10px;
@@ -1029,14 +982,6 @@ h3 > .collapse-toggle, h4 > .collapse-toggle {
        margin-right: 5px;
 }
 
-.toggle-wrapper > .collapse-toggle {
-       left: 0;
-}
-
-.variant + .toggle-wrapper + .docblock > p {
-       margin-top: 5px;
-}
-
 .sub-variant, .sub-variant > h3 {
        margin-top: 0px !important;
        padding-top: 1px;
@@ -1289,7 +1234,7 @@ h4 > .notable-traits {
        outline: none;
 }
 
-#settings-menu, .help-button {
+#settings-menu, #help-button {
        position: absolute;
        top: 10px;
 }
@@ -1299,7 +1244,7 @@ h4 > .notable-traits {
        outline: none;
 }
 
-#theme-picker, #settings-menu, .help-button, #copy-path {
+#theme-picker, #settings-menu, #help-button, #copy-path {
        padding: 4px;
        width: 27px;
        height: 29px;
@@ -1308,7 +1253,7 @@ h4 > .notable-traits {
        cursor: pointer;
 }
 
-.help-button {
+#help-button {
        right: 30px;
        font-family: "Fira Sans", Arial, sans-serif;
        text-align: center;
@@ -1348,6 +1293,201 @@ h4 > .notable-traits {
        border-top: 1px solid;
 }
 
+
+
+h3.notable {
+       margin: 0;
+       margin-bottom: 13px;
+       font-size: 19px;
+}
+
+kbd {
+       display: inline-block;
+       padding: 3px 5px;
+       font: 15px monospace;
+       line-height: 10px;
+       vertical-align: middle;
+       border: solid 1px;
+       border-radius: 3px;
+       box-shadow: inset 0 -1px 0;
+       cursor: default;
+}
+
+.hidden-by-impl-hider,
+.hidden-by-usual-hider {
+       /* important because of conflicting rule for small screens */
+       display: none !important;
+}
+
+#implementations-list > h3 > span.in-band {
+       width: 100%;
+}
+
+.table-display {
+       width: 100%;
+       border: 0;
+       border-collapse: collapse;
+       border-spacing: 0;
+       font-size: 16px;
+}
+
+.table-display tr td:first-child {
+       padding-right: 0;
+}
+
+.table-display tr td:last-child {
+       float: right;
+}
+.table-display .out-of-band {
+       position: relative;
+       font-size: 19px;
+       display: block;
+}
+#implementors-list > .impl-items .table-display .out-of-band {
+       font-size: 17px;
+}
+
+.table-display td:hover .anchor {
+       display: block;
+       top: 2px;
+       left: -5px;
+}
+
+#main > ul {
+       padding-left: 10px;
+}
+#main > ul > li {
+       list-style: none;
+}
+
+.non-exhaustive {
+       margin-bottom: 1em;
+}
+
+div.children {
+       padding-left: 27px;
+       display: none;
+}
+div.name {
+       cursor: pointer;
+       position: relative;
+       margin-left: 16px;
+}
+div.files > a {
+       display: block;
+       padding: 0 3px;
+}
+div.files > a:hover, div.name:hover {
+       background-color: #a14b4b;
+}
+div.name.expand + .children {
+       display: block;
+}
+div.name::before {
+       content: "\25B6";
+       padding-left: 4px;
+       font-size: 0.7em;
+       position: absolute;
+       left: -16px;
+       top: 4px;
+}
+div.name.expand::before {
+       transform: rotate(90deg);
+       left: -15px;
+       top: 2px;
+}
+
+/* The hideme class is used on summary tags that contain a span with
+       placeholder text shown only when the toggle is closed. For instance,
+       "Expand description" or "Show methods". */
+details.rustdoc-toggle > summary.hideme {
+       cursor: pointer;
+}
+
+details.rustdoc-toggle > summary, details.undocumented > summary {
+       list-style: none;
+}
+details.rustdoc-toggle > summary::-webkit-details-marker,
+details.rustdoc-toggle > summary::marker,
+details.undocumented > summary::-webkit-details-marker,
+details.undocumented > summary::marker {
+       display: none;
+}
+
+details.rustdoc-toggle > summary.hideme > span {
+       margin-left: 9px;
+}
+
+details.rustdoc-toggle > summary::before {
+       content: "[+]";
+       font-weight: 300;
+       font-size: 0.8em;
+       letter-spacing: 1px;
+       cursor: pointer;
+}
+
+details.rustdoc-toggle.top-doc > summary,
+details.rustdoc-toggle.top-doc > summary::before,
+details.rustdoc-toggle.non-exhaustive > summary,
+details.rustdoc-toggle.non-exhaustive > summary::before {
+       font-family: 'Fira Sans';
+       font-size: 16px;
+}
+
+details.non-exhaustive {
+       margin-bottom: 8px;
+}
+
+details.rustdoc-toggle > summary.hideme::before {
+       position: relative;
+}
+
+details.rustdoc-toggle > summary:not(.hideme)::before {
+       position: absolute;
+       left: -23px;
+       top: initial;
+}
+
+.impl-items > details.rustdoc-toggle > summary:not(.hideme)::before,
+.undocumented > details.rustdoc-toggle > summary:not(.hideme)::before {
+       position: absolute;
+       top: 3px;
+       left: -2px;
+}
+
+/* When a "hideme" summary is open and the "Expand description" or "Show
+       methods" text is hidden, we want the [-] toggle that remains to not
+       affect the layout of the items to its right. To do that, we use
+       absolute positioning. Note that we also set position: relative
+       on the parent <details> to make this work properly. */
+details.rustdoc-toggle[open] > summary.hideme {
+       position: absolute;
+}
+
+details.rustdoc-toggle, details.undocumented {
+       position: relative;
+}
+
+details.rustdoc-toggle[open] > summary.hideme > span {
+       display: none;
+}
+
+details.rustdoc-toggle[open] > summary::before {
+       content: "[−]";
+       display: inline;
+}
+
+details.undocumented > summary::before {
+       content: "[+] Show hidden undocumented items";
+       cursor: pointer;
+       font-size: 16px;
+       font-weight: 300;
+}
+
+details.undocumented[open] > summary::before {
+       content: "[−] Hide undocumented items";
+}
+
 /* Media Queries */
 
 @media (min-width: 701px) {
@@ -1457,14 +1597,6 @@ h4 > .notable-traits {
                position: inherit;
        }
 
-       .toggle-wrapper > .collapse-toggle {
-               left: 0px;
-       }
-
-       .toggle-wrapper {
-               height: 1.5em;
-       }
-
        #search {
                margin-left: 0;
        }
@@ -1555,16 +1687,9 @@ h4 > .notable-traits {
                border-bottom: 1px solid;
        }
 
-       .collapse-toggle {
-               left: -20px;
-       }
-
-       .impl > .collapse-toggle {
-               left: -10px;
-       }
-
-       .item-list > details.rustdoc-toggle > summary:not(.hideme)::before {
-               left: -10px;
+       #main > details.rustdoc-toggle > summary::before,
+       #main > div > details.rustdoc-toggle > summary::before {
+               left: -11px;
        }
 
        #all-types {
@@ -1593,7 +1718,7 @@ h4 > .notable-traits {
        }
 
        /* We don't display the help button on mobile devices. */
-       .help-button {
+       #help-button {
                display: none;
        }
        .search-container > div {
@@ -1602,7 +1727,7 @@ h4 > .notable-traits {
 }
 
 @media print {
-       nav.sub, .content .out-of-band, .collapse-toggle {
+       nav.sub, .content .out-of-band {
                display: none;
        }
 }
@@ -1658,193 +1783,3 @@ h4 > .notable-traits {
                margin-left: 12px;
        }
 }
-
-h3.notable {
-       margin: 0;
-       margin-bottom: 13px;
-       font-size: 19px;
-}
-
-kbd {
-       display: inline-block;
-       padding: 3px 5px;
-       font: 15px monospace;
-       line-height: 10px;
-       vertical-align: middle;
-       border: solid 1px;
-       border-radius: 3px;
-       box-shadow: inset 0 -1px 0;
-       cursor: default;
-}
-
-.hidden-by-impl-hider,
-.hidden-by-usual-hider {
-       /* important because of conflicting rule for small screens */
-       display: none !important;
-}
-
-#implementations-list > h3 > span.in-band {
-       width: 100%;
-}
-
-.table-display {
-       width: 100%;
-       border: 0;
-       border-collapse: collapse;
-       border-spacing: 0;
-       font-size: 16px;
-}
-
-.table-display tr td:first-child {
-       padding-right: 0;
-}
-
-.table-display tr td:last-child {
-       float: right;
-}
-.table-display .out-of-band {
-       position: relative;
-       font-size: 19px;
-       display: block;
-}
-#implementors-list > .impl-items .table-display .out-of-band {
-       font-size: 17px;
-}
-
-.table-display td:hover .anchor {
-       display: block;
-       top: 2px;
-       left: -5px;
-}
-
-#main > ul {
-       padding-left: 10px;
-}
-#main > ul > li {
-       list-style: none;
-}
-
-.non-exhaustive {
-       margin-bottom: 1em;
-}
-
-div.children {
-       padding-left: 27px;
-       display: none;
-}
-div.name {
-       cursor: pointer;
-       position: relative;
-       margin-left: 16px;
-}
-div.files > a {
-       display: block;
-       padding: 0 3px;
-}
-div.files > a:hover, div.name:hover {
-       background-color: #a14b4b;
-}
-div.name.expand + .children {
-       display: block;
-}
-div.name::before {
-       content: "\25B6";
-       padding-left: 4px;
-       font-size: 0.7em;
-       position: absolute;
-       left: -16px;
-       top: 4px;
-}
-div.name.expand::before {
-       transform: rotate(90deg);
-       left: -15px;
-       top: 2px;
-}
-
-/* The hideme class is used on summary tags that contain a span with
-       placeholder text shown only when the toggle is closed. For instance,
-       "Expand description" or "Show methods". */
-details.rustdoc-toggle > summary.hideme {
-       cursor: pointer;
-}
-
-details.rustdoc-toggle > summary::-webkit-details-marker,
-details.rustdoc-toggle > summary::marker,
-details.undocumented > summary::-webkit-details-marker,
-details.undocumented > summary::marker {
-       display: none;
-}
-
-details.rustdoc-toggle > summary.hideme > span {
-       margin-left: 9px;
-}
-
-details.rustdoc-toggle > summary::before {
-       content: "[+]";
-       font-weight: 300;
-       font-size: 0.8em;
-       letter-spacing: 1px;
-       cursor: pointer;
-}
-
-details.rustdoc-toggle.top-doc > summary,
-details.rustdoc-toggle.top-doc > summary::before,
-details.rustdoc-toggle.non-exhaustive > summary,
-details.rustdoc-toggle.non-exhaustive > summary::before {
-       font-family: 'Fira Sans';
-       font-size: 16px;
-}
-
-details.non-exhaustive {
-       margin-bottom: 8px;
-}
-
-details.rustdoc-toggle > summary.hideme::before {
-       position: relative;
-}
-
-details.rustdoc-toggle > summary:not(.hideme)::before {
-       position: absolute;
-       left: -23px;
-       top: initial;
-}
-
-.impl-items > details.rustdoc-toggle > summary:not(.hideme)::before,
-.undocumented > details.rustdoc-toggle > summary:not(.hideme)::before {
-       position: absolute;
-       top: 3px;
-       left: -2px;
-}
-
-/* When a "hideme" summary is open and the "Expand description" or "Show
-       methods" text is hidden, we want the [-] toggle that remains to not
-       affect the layout of the items to its right. To do that, we use
-       absolute positioning. Note that we also set position: relative
-       on the parent <details> to make this work properly. */
-details.rustdoc-toggle[open] > summary.hideme {
-       position: absolute;
-}
-
-details.rustdoc-toggle, details.undocumented {
-       position: relative;
-}
-
-details.rustdoc-toggle[open] > summary.hideme > span {
-       display: none;
-}
-
-details.rustdoc-toggle[open] > summary::before {
-       content: "[−]";
-       display: inline;
-}
-
-details.undocumented > summary::before {
-       content: "[+] Show hidden undocumented items";
-       cursor: pointer;
-       font-size: 16px;
-       font-weight: 300;
-}
-
-details.undocumented[open] > summary::before {
-       content: "[-] Hide undocumented items";
-}
index 9fab435de49c8b8c8739cbf7d3ec37224e7ab411..c53b3d5f14bc644ce2f5bb1521943c51671b827b 100644 (file)
@@ -1,3 +1,6 @@
+/* global addClass, getNakedUrl, getSettingValue, hasOwnPropertyRustdoc, initSearch, onEach */
+/* global onEachLazy, removeClass, searchState, updateLocalStorage */
+
 (function() {
 // This mapping table should match the discriminants of
 // `rustdoc::html::item_type::ItemType` type in Rust.
@@ -146,23 +149,21 @@ window.initSearch = function(rawSearchIndex) {
 
         removeEmptyStringsFromArray(split);
 
-        function transformResults(results, isType) {
+        function transformResults(results) {
             var out = [];
             for (var i = 0, len = results.length; i < len; ++i) {
                 if (results[i].id > -1) {
                     var obj = searchIndex[results[i].id];
                     obj.lev = results[i].lev;
-                    if (isType !== true || obj.type) {
-                        var res = buildHrefAndPath(obj);
-                        obj.displayPath = pathSplitter(res[0]);
-                        obj.fullPath = obj.displayPath + obj.name;
-                        // To be sure than it some items aren't considered as duplicate.
-                        obj.fullPath += "|" + obj.ty;
-                        obj.href = res[1];
-                        out.push(obj);
-                        if (out.length >= MAX_RESULTS) {
-                            break;
-                        }
+                    var res = buildHrefAndPath(obj);
+                    obj.displayPath = pathSplitter(res[0]);
+                    obj.fullPath = obj.displayPath + obj.name;
+                    // To be sure than it some items aren't considered as duplicate.
+                    obj.fullPath += "|" + obj.ty;
+                    obj.href = res[1];
+                    out.push(obj);
+                    if (out.length >= MAX_RESULTS) {
+                        break;
                     }
                 }
             }
@@ -172,7 +173,7 @@ window.initSearch = function(rawSearchIndex) {
         function sortResults(results, isType) {
             var ar = [];
             for (var entry in results) {
-                if (hasOwnProperty(results, entry)) {
+                if (hasOwnPropertyRustdoc(results, entry)) {
                     ar.push(results[entry]);
                 }
             }
@@ -256,7 +257,7 @@ window.initSearch = function(rawSearchIndex) {
             });
 
             for (i = 0, len = results.length; i < len; ++i) {
-                var result = results[i];
+                result = results[i];
 
                 // this validation does not make sense when searching by types
                 if (result.dontValidate) {
@@ -266,9 +267,7 @@ window.initSearch = function(rawSearchIndex) {
                     path = result.item.path.toLowerCase(),
                     parent = result.item.parent;
 
-                if (isType !== true &&
-                    validateResult(name, path, split, parent) === false)
-                {
+                if (!isType && !validateResult(name, path, split, parent)) {
                     result.id = -1;
                 }
             }
@@ -305,7 +304,7 @@ window.initSearch = function(rawSearchIndex) {
                 if (obj.length > GENERICS_DATA &&
                       obj[GENERICS_DATA].length >= val.generics.length) {
                     var elems = Object.create(null);
-                    var elength = object[GENERICS_DATA].length;
+                    var elength = obj[GENERICS_DATA].length;
                     for (var x = 0; x < elength; ++x) {
                         elems[getObjectNameFromId(obj[GENERICS_DATA][x])] += 1;
                     }
@@ -352,7 +351,7 @@ window.initSearch = function(rawSearchIndex) {
             var lev_distance = MAX_LEV_DISTANCE + 1;
             var len, x, firstGeneric;
             if (obj[NAME] === val.name) {
-                if (literalSearch === true) {
+                if (literalSearch) {
                     if (val.generics && val.generics.length !== 0) {
                         if (obj.length > GENERICS_DATA &&
                               obj[GENERICS_DATA].length >= val.generics.length) {
@@ -373,7 +372,7 @@ window.initSearch = function(rawSearchIndex) {
                                     break;
                                 }
                             }
-                            if (allFound === true) {
+                            if (allFound) {
                                 return true;
                             }
                         } else {
@@ -394,7 +393,7 @@ window.initSearch = function(rawSearchIndex) {
                 }
             }
             // Names didn't match so let's check if one of the generic types could.
-            if (literalSearch === true) {
+            if (literalSearch) {
                  if (obj.length > GENERICS_DATA && obj[GENERICS_DATA].length > 0) {
                     return obj[GENERICS_DATA].some(
                         function(name) {
@@ -429,12 +428,12 @@ window.initSearch = function(rawSearchIndex) {
                 var length = obj.type[INPUTS_DATA].length;
                 for (var i = 0; i < length; i++) {
                     var tmp = obj.type[INPUTS_DATA][i];
-                    if (typePassesFilter(typeFilter, tmp[1]) === false) {
+                    if (!typePassesFilter(typeFilter, tmp[1])) {
                         continue;
                     }
                     tmp = checkType(tmp, val, literalSearch);
-                    if (literalSearch === true) {
-                        if (tmp === true) {
+                    if (literalSearch) {
+                        if (tmp) {
                             return true;
                         }
                         continue;
@@ -445,7 +444,7 @@ window.initSearch = function(rawSearchIndex) {
                     }
                 }
             }
-            return literalSearch === true ? false : lev_distance;
+            return literalSearch ? false : lev_distance;
         }
 
         function checkReturned(obj, val, literalSearch, typeFilter) {
@@ -458,12 +457,12 @@ window.initSearch = function(rawSearchIndex) {
                 }
                 for (var x = 0, len = ret.length; x < len; ++x) {
                     var tmp = ret[x];
-                    if (typePassesFilter(typeFilter, tmp[1]) === false) {
+                    if (!typePassesFilter(typeFilter, tmp[1])) {
                         continue;
                     }
                     tmp = checkType(tmp, val, literalSearch);
-                    if (literalSearch === true) {
-                        if (tmp === true) {
+                    if (literalSearch) {
+                        if (tmp) {
                             return true;
                         }
                         continue;
@@ -474,7 +473,7 @@ window.initSearch = function(rawSearchIndex) {
                     }
                 }
             }
-            return literalSearch === true ? false : lev_distance;
+            return literalSearch ? false : lev_distance;
         }
 
         function checkPath(contains, lastElem, ty) {
@@ -507,7 +506,7 @@ window.initSearch = function(rawSearchIndex) {
                     }
                     lev_total += lev;
                 }
-                if (aborted === false) {
+                if (!aborted) {
                     ret_lev = Math.min(ret_lev, Math.round(lev_total / clength));
                 }
             }
@@ -634,14 +633,14 @@ window.initSearch = function(rawSearchIndex) {
                         dontValidate: true,
                     };
                 }
-                if (in_args === true && results_in_args[fullId] === undefined) {
+                if (in_args && results_in_args[fullId] === undefined) {
                     results_in_args[fullId] = {
                         id: i,
                         index: -1,
                         dontValidate: true,
                     };
                 }
-                if (returned === true && results_returned[fullId] === undefined) {
+                if (returned && results_returned[fullId] === undefined) {
                     results_returned[fullId] = {
                         id: i,
                         index: -1,
@@ -676,7 +675,7 @@ window.initSearch = function(rawSearchIndex) {
                 fullId = ty.id;
 
                 returned = checkReturned(ty, output, true, NO_TYPE_FILTER);
-                if (output.name === "*" || returned === true) {
+                if (output.name === "*" || returned) {
                     in_args = false;
                     var is_module = false;
 
@@ -684,26 +683,26 @@ window.initSearch = function(rawSearchIndex) {
                         is_module = true;
                     } else {
                         var allFound = true;
-                        for (it = 0, len = inputs.length; allFound === true && it < len; it++) {
+                        for (it = 0, len = inputs.length; allFound && it < len; it++) {
                             allFound = checkType(type, inputs[it], true);
                         }
                         in_args = allFound;
                     }
-                    if (in_args === true) {
+                    if (in_args) {
                         results_in_args[fullId] = {
                             id: i,
                             index: -1,
                             dontValidate: true,
                         };
                     }
-                    if (returned === true) {
+                    if (returned) {
                         results_returned[fullId] = {
                             id: i,
                             index: -1,
                             dontValidate: true,
                         };
                     }
-                    if (is_module === true) {
+                    if (is_module) {
                         results[fullId] = {
                             id: i,
                             index: -1,
@@ -721,7 +720,7 @@ window.initSearch = function(rawSearchIndex) {
             query.output = val;
             query.search = val;
             // gather matching search results up to a certain maximum
-            val = val.replace(/\_/g, "");
+            val = val.replace(/_/g, "");
 
             var valGenerics = extractGenerics(val);
 
@@ -763,10 +762,10 @@ window.initSearch = function(rawSearchIndex) {
                     }
                 }
                 if ((lev = levenshtein(searchWords[j], val)) <= MAX_LEV_DISTANCE) {
-                    if (typePassesFilter(typeFilter, ty.ty) === false) {
-                        lev = MAX_LEV_DISTANCE + 1;
-                    } else {
+                    if (typePassesFilter(typeFilter, ty.ty)) {
                         lev += 1;
+                    } else {
+                        lev = MAX_LEV_DISTANCE + 1;
                     }
                 }
                 in_args = findArg(ty, valGenerics, false, typeFilter);
@@ -821,7 +820,7 @@ window.initSearch = function(rawSearchIndex) {
         var ret = {
             "in_args": sortResults(results_in_args, true),
             "returned": sortResults(results_returned, true),
-            "others": sortResults(results),
+            "others": sortResults(results, false),
         };
         handleAliases(ret, query, filterCrates);
         return ret;
@@ -1246,7 +1245,9 @@ window.initSearch = function(rawSearchIndex) {
     function getFilterCrates() {
         var elem = document.getElementById("crate-search");
 
-        if (elem && elem.value !== "All crates" && hasOwnProperty(rawSearchIndex, elem.value)) {
+        if (elem && elem.value !== "All crates" &&
+            hasOwnPropertyRustdoc(rawSearchIndex, elem.value))
+        {
             return elem.value;
         }
         return undefined;
@@ -1263,7 +1264,7 @@ window.initSearch = function(rawSearchIndex) {
         if (query.query.length === 0) {
             return;
         }
-        if (forced !== true && query.id === currentResults) {
+        if (!forced && query.id === currentResults) {
             if (query.query.length > 0) {
                 searchState.putBackSearch(searchState.input);
             }
@@ -1297,14 +1298,13 @@ window.initSearch = function(rawSearchIndex) {
         var id = 0;
 
         for (var crate in rawSearchIndex) {
-            if (!hasOwnProperty(rawSearchIndex, crate)) { continue; }
+            if (!hasOwnPropertyRustdoc(rawSearchIndex, crate)) {
+                continue;
+            }
 
             var crateSize = 0;
 
             searchWords.push(crate);
-            var normalizedName = crate.indexOf("_") === -1
-                ? crate
-                : crate.replace(/_/g, "");
             // This object should have exactly the same set of fields as the "row"
             // object defined below. Your JavaScript runtime will thank you.
             // https://mathiasbynens.be/notes/shapes-ics
@@ -1317,7 +1317,7 @@ window.initSearch = function(rawSearchIndex) {
                 parent: undefined,
                 type: null,
                 id: id,
-                normalizedName: normalizedName,
+                normalizedName: crate.indexOf("_") === -1 ? crate : crate.replace(/_/g, ""),
             };
             id += 1;
             searchIndex.push(crateRow);
@@ -1367,9 +1367,6 @@ window.initSearch = function(rawSearchIndex) {
                     word = "";
                     searchWords.push("");
                 }
-                var normalizedName = word.indexOf("_") === -1
-                    ? word
-                    : word.replace(/_/g, "");
                 var row = {
                     crate: crate,
                     ty: itemTypes[i],
@@ -1379,7 +1376,7 @@ window.initSearch = function(rawSearchIndex) {
                     parent: itemParentIdxs[i] > 0 ? paths[itemParentIdxs[i] - 1] : undefined,
                     type: itemFunctionSearchTypes[i],
                     id: id,
-                    normalizedName: normalizedName,
+                    normalizedName: word.indexOf("_") === -1 ? word : word.replace(/_/g, ""),
                 };
                 id += 1;
                 searchIndex.push(row);
@@ -1391,9 +1388,11 @@ window.initSearch = function(rawSearchIndex) {
                 ALIASES[crate] = {};
                 var j, local_aliases;
                 for (var alias_name in aliases) {
-                    if (!aliases.hasOwnProperty(alias_name)) { continue; }
+                    if (!hasOwnPropertyRustdoc(aliases, alias_name)) {
+                        continue;
+                    }
 
-                    if (!ALIASES[crate].hasOwnProperty(alias_name)) {
+                    if (!hasOwnPropertyRustdoc(ALIASES[crate], alias_name)) {
                         ALIASES[crate][alias_name] = [];
                     }
                     local_aliases = aliases[alias_name];
@@ -1509,7 +1508,7 @@ window.initSearch = function(rawSearchIndex) {
 };
 
 if (window.searchIndex !== undefined) {
-  initSearch(window.searchIndex);
+    initSearch(window.searchIndex);
 }
 
 })();
index 42b54e4cc1e46a639b31fc1fffcc0638b0bdb9ea..4d9a59f836b9e1b0d2604a95dbfe8883ac93111d 100644 (file)
@@ -2,7 +2,9 @@
 /* global search, sourcesIndex */
 
 // Local js definitions:
-/* global addClass, getCurrentValue, hasClass, removeClass, updateLocalStorage */
+/* global addClass, getCurrentValue, hasClass, onEachLazy, removeClass, searchState */
+/* global updateLocalStorage */
+(function() {
 
 function getCurrentFilePath() {
     var parts = window.location.pathname.split("/");
@@ -44,7 +46,7 @@ function createDirEntry(elem, parent, fullPath, currentFile, hasFoundFile) {
     if (elem.dirs) {
         for (i = 0, len = elem.dirs.length; i < len; ++i) {
             if (createDirEntry(elem.dirs[i], folders, fullPath, currentFile,
-                               hasFoundFile) === true) {
+                               hasFoundFile)) {
                 addClass(name, "expand");
                 hasFoundFile = true;
             }
@@ -59,8 +61,7 @@ function createDirEntry(elem, parent, fullPath, currentFile, hasFoundFile) {
             var file = document.createElement("a");
             file.innerText = elem.files[i];
             file.href = window.rootPath + "src/" + fullPath + elem.files[i] + ".html";
-            if (hasFoundFile === false &&
-                    currentFile === fullPath + elem.files[i]) {
+            if (!hasFoundFile && currentFile === fullPath + elem.files[i]) {
                 file.className = "selected";
                 addClass(name, "expand");
                 hasFoundFile = true;
@@ -72,7 +73,7 @@ function createDirEntry(elem, parent, fullPath, currentFile, hasFoundFile) {
     children.appendChild(files);
     parent.appendChild(name);
     parent.appendChild(children);
-    return hasFoundFile === true && currentFile.startsWith(fullPath);
+    return hasFoundFile && currentFile.startsWith(fullPath);
 }
 
 function toggleSidebar() {
@@ -116,7 +117,7 @@ function createSidebarToggle() {
 // This function is called from "source-files.js", generated in `html/render/mod.rs`.
 // eslint-disable-next-line no-unused-vars
 function createSourceSidebar() {
-    if (window.rootPath.endsWith("/") === false) {
+    if (!window.rootPath.endsWith("/")) {
         window.rootPath += "/";
     }
     var main = document.getElementById("main");
@@ -150,3 +151,99 @@ function createSourceSidebar() {
         selected_elem.focus();
     }
 }
+
+var lineNumbersRegex = /^#?(\d+)(?:-(\d+))?$/;
+
+function highlightSourceLines(scrollTo, match) {
+    if (typeof match === "undefined") {
+        match = window.location.hash.match(lineNumbersRegex);
+    }
+    if (!match) {
+        return;
+    }
+    var from = parseInt(match[1], 10);
+    var to = from;
+    if (typeof match[2] !== "undefined") {
+        to = parseInt(match[2], 10);
+    }
+    if (to < from) {
+        var tmp = to;
+        to = from;
+        from = tmp;
+    }
+    var elem = document.getElementById(from);
+    if (!elem) {
+        return;
+    }
+    if (scrollTo) {
+        var x = document.getElementById(from);
+        if (x) {
+            x.scrollIntoView();
+        }
+    }
+    onEachLazy(document.getElementsByClassName("line-numbers"), function(e) {
+        onEachLazy(e.getElementsByTagName("span"), function(i_e) {
+            removeClass(i_e, "line-highlighted");
+        });
+    });
+    for (var i = from; i <= to; ++i) {
+        elem = document.getElementById(i);
+        if (!elem) {
+            break;
+        }
+        addClass(elem, "line-highlighted");
+    }
+}
+
+var handleSourceHighlight = (function() {
+    var prev_line_id = 0;
+
+    var set_fragment = function(name) {
+        var x = window.scrollX,
+            y = window.scrollY;
+        if (searchState.browserSupportsHistoryApi()) {
+            history.replaceState(null, null, "#" + name);
+            highlightSourceLines(true);
+        } else {
+            location.replace("#" + name);
+        }
+        // Prevent jumps when selecting one or many lines
+        window.scrollTo(x, y);
+    };
+
+    return function(ev) {
+        var cur_line_id = parseInt(ev.target.id, 10);
+        ev.preventDefault();
+
+        if (ev.shiftKey && prev_line_id) {
+            // Swap selection if needed
+            if (prev_line_id > cur_line_id) {
+                var tmp = prev_line_id;
+                prev_line_id = cur_line_id;
+                cur_line_id = tmp;
+            }
+
+            set_fragment(prev_line_id + "-" + cur_line_id);
+        } else {
+            prev_line_id = cur_line_id;
+
+            set_fragment(cur_line_id);
+        }
+    };
+}());
+
+window.addEventListener("hashchange", function() {
+    var match = window.location.hash.match(lineNumbersRegex);
+    if (match) {
+        return highlightSourceLines(false, match);
+    }
+});
+
+onEachLazy(document.getElementsByClassName("line-numbers"), function(el) {
+    el.addEventListener("click", handleSourceHighlight);
+});
+
+highlightSourceLines(true);
+
+window.createSourceSidebar = createSourceSidebar;
+})();
index 2ed87fdedaec686616e46c3b6435bd5d3b63384d..2eaa81a97d8c5e46f59d1441a4f0bae37eed007e 100644 (file)
@@ -59,15 +59,15 @@ function onEach(arr, func, reversed) {
     if (arr && arr.length > 0 && func) {
         var length = arr.length;
         var i;
-        if (reversed !== true) {
-            for (i = 0; i < length; ++i) {
-                if (func(arr[i]) === true) {
+        if (reversed) {
+            for (i = length - 1; i >= 0; --i) {
+                if (func(arr[i])) {
                     return true;
                 }
             }
         } else {
-            for (i = length - 1; i >= 0; --i) {
-                if (func(arr[i]) === true) {
+            for (i = 0; i < length; ++i) {
+                if (func(arr[i])) {
                     return true;
                 }
             }
@@ -84,7 +84,7 @@ function onEachLazy(lazyArray, func, reversed) {
 }
 
 // eslint-disable-next-line no-unused-vars
-function hasOwnProperty(obj, property) {
+function hasOwnPropertyRustdoc(obj, property) {
     return Object.prototype.hasOwnProperty.call(obj, property);
 }
 
@@ -111,7 +111,7 @@ function switchTheme(styleElem, mainStyleElem, newTheme, saveTheme) {
 
     // If this new value comes from a system setting or from the previously
     // saved theme, no need to save it.
-    if (saveTheme === true) {
+    if (saveTheme) {
         updateLocalStorage("rustdoc-theme", newTheme);
     }
 
@@ -131,7 +131,7 @@ function switchTheme(styleElem, mainStyleElem, newTheme, saveTheme) {
             return true;
         }
     });
-    if (found === true) {
+    if (found) {
         styleElem.href = newHref;
     }
 }
index aafb7f6300ea476aee1b7bc098401e68cd75eb18..13d1a475e4b2ad98877847eae397b4a9ce0b4ce4 100644 (file)
@@ -224,7 +224,6 @@ a {
        color: #39AFD7;
 }
 
-.collapse-toggle,
 details.rustdoc-toggle > summary.hideme > span,
 details.rustdoc-toggle > summary::before,
 details.undocumented > summary::before {
@@ -503,7 +502,7 @@ kbd {
        box-shadow-color: #c6cbd1;
 }
 
-#theme-picker, #settings-menu, .help-button, #copy-path {
+#theme-picker, #settings-menu, #help-button, #copy-path {
        border-color: #5c6773;
        background-color: #0f1419;
        color: #fff;
@@ -515,7 +514,7 @@ kbd {
 
 #theme-picker:hover, #theme-picker:focus,
 #settings-menu:hover, #settings-menu:focus,
-.help-button:hover, .help-button:focus,
+#help-button:hover, #help-button:focus,
 #copy-path:hover, #copy-path:focus {
        border-color: #e0e0e0;
 }
index 715605d7b3785cfa0ea4dd962f40168915afb086..945ca9b252e5f509c0642e946031f6e10486212d 100644 (file)
@@ -186,7 +186,6 @@ a.test-arrow {
        color: #dedede;
 }
 
-.collapse-toggle,
 details.rustdoc-toggle > summary.hideme > span,
 details.rustdoc-toggle > summary::before,
 details.undocumented > summary::before {
@@ -393,7 +392,7 @@ kbd {
        box-shadow-color: #c6cbd1;
 }
 
-#theme-picker, #settings-menu, .help-button, #copy-path {
+#theme-picker, #settings-menu, #help-button, #copy-path {
        border-color: #e0e0e0;
        background: #f0f0f0;
        color: #000;
@@ -401,7 +400,7 @@ kbd {
 
 #theme-picker:hover, #theme-picker:focus,
 #settings-menu:hover, #settings-menu:focus,
-.help-button:hover, .help-button:focus,
+#help-button:hover, #help-button:focus,
 #copy-path:hover, #copy-path:focus {
        border-color: #ffb900;
 }
index 60ed8898793875504b60ac54d027699f55c7473d..2ed638bdd4fa188c4e9a5fa0ef318232c85e7fbe 100644 (file)
@@ -184,7 +184,6 @@ a.test-arrow {
        color: #f5f5f5;
 }
 
-.collapse-toggle,
 details.rustdoc-toggle > summary.hideme > span,
 details.rustdoc-toggle > summary::before,
 details.undocumented > summary::before {
@@ -385,14 +384,14 @@ kbd {
        box-shadow-color: #c6cbd1;
 }
 
-#theme-picker, #settings-menu, .help-button, #copy-path {
+#theme-picker, #settings-menu, #help-button, #copy-path {
        border-color: #e0e0e0;
        background-color: #fff;
 }
 
 #theme-picker:hover, #theme-picker:focus,
 #settings-menu:hover, #settings-menu:focus,
-.help-button:hover, .help-button:focus,
+#help-button:hover, #help-button:focus,
 #copy-path:hover, #copy-path:focus {
        border-color: #717171;
 }
index e3f1c6b1e2dc4ecf34483e54b190dd4b0aff5ef4..5ac43c736462257f12cd7bbb5184b90184da56ff 100644 (file)
@@ -14,9 +14,8 @@
 
 use rustdoc_json_types::*;
 
-use crate::clean;
 use crate::clean::utils::print_const_expr;
-use crate::clean::FakeDefId;
+use crate::clean::{self, FakeDefId};
 use crate::formats::item_type::ItemType;
 use crate::json::JsonRenderer;
 use std::collections::HashSet;
@@ -31,7 +30,7 @@ pub(super) fn convert_item(&self, item: clean::Item) -> Option<Item> {
             .into_iter()
             .flatten()
             .filter_map(|clean::ItemLink { link, did, .. }| {
-                did.map(|did| (link.clone(), from_def_id(did)))
+                did.map(|did| (link.clone(), from_def_id(did.into())))
             })
             .collect();
         let docs = item.attrs.collapsed_doc_value();
@@ -64,18 +63,17 @@ pub(super) fn convert_item(&self, item: clean::Item) -> Option<Item> {
     fn convert_span(&self, span: clean::Span) -> Option<Span> {
         match span.filename(self.sess()) {
             rustc_span::FileName::Real(name) => {
-                let hi = span.hi(self.sess());
-                let lo = span.lo(self.sess());
-                Some(Span {
-                    filename: match name {
-                        rustc_span::RealFileName::Named(path) => path,
-                        rustc_span::RealFileName::Devirtualized { local_path, virtual_name: _ } => {
-                            local_path
-                        }
-                    },
-                    begin: (lo.line, lo.col.to_usize()),
-                    end: (hi.line, hi.col.to_usize()),
-                })
+                if let Some(local_path) = name.into_local_path() {
+                    let hi = span.hi(self.sess());
+                    let lo = span.lo(self.sess());
+                    Some(Span {
+                        filename: local_path,
+                        begin: (lo.line, lo.col.to_usize()),
+                        end: (hi.line, hi.col.to_usize()),
+                    })
+                } else {
+                    None
+                }
             }
             _ => None,
         }
@@ -483,7 +481,7 @@ fn from_tcx(impl_: clean::Impl, tcx: TyCtxt<'_>) -> Self {
             items: ids(items),
             negative: negative_polarity,
             synthetic,
-            blanket_impl: blanket_impl.map(|x| x.into_tcx(tcx)),
+            blanket_impl: blanket_impl.map(|x| (*x).into_tcx(tcx)),
         }
     }
 }
index d56acad60c00f7d35884126a5db5266cb83f1e3a..f8bd971081395a126f771a8bbc9921d3d20de4cd 100644 (file)
 use std::rc::Rc;
 
 use rustc_data_structures::fx::FxHashMap;
+use rustc_hir::def_id::DefId;
 use rustc_middle::ty::TyCtxt;
 use rustc_session::Session;
 
 use rustdoc_json_types as types;
 
 use crate::clean;
-use crate::clean::{ExternalCrate, FakeDefId};
+use crate::clean::ExternalCrate;
 use crate::config::RenderOptions;
 use crate::error::Error;
 use crate::formats::cache::Cache;
@@ -42,7 +43,7 @@ fn sess(&self) -> &'tcx Session {
         self.tcx.sess
     }
 
-    fn get_trait_implementors(&mut self, id: FakeDefId) -> Vec<types::Id> {
+    fn get_trait_implementors(&mut self, id: DefId) -> Vec<types::Id> {
         Rc::clone(&self.cache)
             .implementors
             .get(&id)
@@ -59,10 +60,10 @@ fn get_trait_implementors(&mut self, id: FakeDefId) -> Vec<types::Id> {
             .unwrap_or_default()
     }
 
-    fn get_impls(&mut self, id: FakeDefId) -> Vec<types::Id> {
+    fn get_impls(&mut self, id: DefId) -> Vec<types::Id> {
         Rc::clone(&self.cache)
             .impls
-            .get(&id.expect_real())
+            .get(&id)
             .map(|impls| {
                 impls
                     .iter()
@@ -163,11 +164,11 @@ fn item(&mut self, item: clean::Item) -> Result<(), Error> {
         let id = item.def_id;
         if let Some(mut new_item) = self.convert_item(item) {
             if let types::ItemEnum::Trait(ref mut t) = new_item.inner {
-                t.implementors = self.get_trait_implementors(id)
+                t.implementors = self.get_trait_implementors(id.expect_real())
             } else if let types::ItemEnum::Struct(ref mut s) = new_item.inner {
-                s.impls = self.get_impls(id)
+                s.impls = self.get_impls(id.expect_real())
             } else if let types::ItemEnum::Enum(ref mut e) = new_item.inner {
-                e.impls = self.get_impls(id)
+                e.impls = self.get_impls(id.expect_real())
             }
             let removed = self.index.borrow_mut().insert(from_def_id(id), new_item.clone());
 
index 169ef015fa88c71bff5c03da04b59b27fb83a1b5..5ede3780e87ae8cbe50dec1bab5eaa14786d98e6 100644 (file)
@@ -594,6 +594,9 @@ fn opts() -> Vec<RustcOptGroup> {
             )
         }),
         unstable("no-run", |o| o.optflag("", "no-run", "Compile doctests without running them")),
+        unstable("show-type-layout", |o| {
+            o.optflag("", "show-type-layout", "Include the memory layout of types in the docs")
+        }),
     ]
 }
 
index e65fcf057f15c1605bd09865c214a90f604e1b8a..26a22f5b304945ccb2d426538c43b855821ad799 100644 (file)
@@ -119,7 +119,7 @@ fn to_json(&self) -> String {
             &self
                 .items
                 .iter()
-                .map(|(k, v)| (k.to_string(), v))
+                .map(|(k, v)| (k.prefer_local().to_string(), v))
                 .collect::<BTreeMap<String, &ItemCount>>(),
         )
         .expect("failed to convert JSON data to string")
@@ -159,7 +159,7 @@ fn print_table_record(
         for (file, &count) in &self.items {
             if let Some(percentage) = count.percentage() {
                 print_table_record(
-                    &limit_filename_len(file.to_string()),
+                    &limit_filename_len(file.prefer_local().to_string_lossy().into()),
                     count,
                     percentage,
                     count.examples_percentage().unwrap_or(0.),
@@ -225,7 +225,7 @@ fn fold_item(&mut self, i: clean::Item) -> Option<clean::Item> {
                 // unless the user had an explicit `allow`
                 let should_have_docs =
                     level != lint::Level::Allow || matches!(source, LintLevelSource::Default);
-                debug!("counting {:?} {:?} in {}", i.type_(), i.name, filename);
+                debug!("counting {:?} {:?} in {:?}", i.type_(), i.name, filename);
                 self.items.entry(filename).or_default().count_item(
                     has_docs,
                     has_doc_example,
index 8838dc57d5a059f96bcdf1a0af5e4b5b8aefcb21..88207b67743cf57233420100d32291da3ee79040 100644 (file)
@@ -30,9 +30,7 @@
 use std::mem;
 use std::ops::Range;
 
-use crate::clean::{
-    self, utils::find_nearest_parent_module, Crate, FakeDefId, Item, ItemLink, PrimitiveType,
-};
+use crate::clean::{self, utils::find_nearest_parent_module, Crate, Item, ItemLink, PrimitiveType};
 use crate::core::DocContext;
 use crate::fold::DocFolder;
 use crate::html::markdown::{markdown_links, MarkdownLink};
@@ -248,7 +246,7 @@ enum AnchorFailure {
 
 #[derive(Clone, Debug, Hash, PartialEq, Eq)]
 struct ResolutionInfo {
-    module_id: FakeDefId,
+    module_id: DefId,
     dis: Option<Disambiguator>,
     path_str: String,
     extra_fragment: Option<String>,
@@ -274,7 +272,7 @@ struct LinkCollector<'a, 'tcx> {
     ///
     /// The last module will be used if the parent scope of the current item is
     /// unknown.
-    mod_ids: Vec<FakeDefId>,
+    mod_ids: Vec<DefId>,
     /// This is used to store the kind of associated items,
     /// because `clean` and the disambiguator code expect them to be different.
     /// See the code for associated items on inherent impls for details.
@@ -861,7 +859,7 @@ fn fold_item(&mut self, item: Item) -> Option<Item> {
         let inner_docs = item.inner_docs(self.cx.tcx);
 
         if item.is_mod() && inner_docs {
-            self.mod_ids.push(item.def_id);
+            self.mod_ids.push(item.def_id.expect_real());
         }
 
         // We want to resolve in the lexical scope of the documentation.
@@ -888,7 +886,7 @@ fn fold_item(&mut self, item: Item) -> Option<Item> {
 
         Some(if item.is_mod() {
             if !inner_docs {
-                self.mod_ids.push(item.def_id);
+                self.mod_ids.push(item.def_id.expect_real());
             }
 
             let ret = self.fold_item_recur(item);
@@ -1070,11 +1068,8 @@ fn resolve_link(
         // we've already pushed this node onto the resolution stack but
         // for outer comments we explicitly try and resolve against the
         // parent_node first.
-        let base_node = if item.is_mod() && inner_docs {
-            self.mod_ids.last().copied()
-        } else {
-            parent_node.map(|id| FakeDefId::new_real(id))
-        };
+        let base_node =
+            if item.is_mod() && inner_docs { self.mod_ids.last().copied() } else { parent_node };
 
         let mut module_id = if let Some(id) = base_node {
             id
@@ -1119,7 +1114,7 @@ fn resolve_link(
                 resolved_self = format!("self::{}", &path_str["crate::".len()..]);
                 path_str = &resolved_self;
             }
-            module_id = FakeDefId::new_real(DefId { krate, index: CRATE_DEF_INDEX });
+            module_id = DefId { krate, index: CRATE_DEF_INDEX };
         }
 
         let (mut res, mut fragment) = self.resolve_with_disambiguator_cached(
@@ -1180,8 +1175,8 @@ fn resolve_link(
             report_diagnostic(self.cx.tcx, BROKEN_INTRA_DOC_LINKS, &msg, &diag_info, callback);
         };
 
-        let verify = |kind: DefKind, id: FakeDefId| {
-            let (kind, id) = self.kind_side_channel.take().unwrap_or((kind, id.expect_real()));
+        let verify = |kind: DefKind, id: DefId| {
+            let (kind, id) = self.kind_side_channel.take().unwrap_or((kind, id));
             debug!("intra-doc link to {} resolved to {:?} (id: {:?})", path_str, res, id);
 
             // Disallow e.g. linking to enums with `struct@`
@@ -1345,7 +1340,7 @@ fn resolve_with_disambiguator(
 
         match disambiguator.map(Disambiguator::ns) {
             Some(expected_ns @ (ValueNS | TypeNS)) => {
-                match self.resolve(path_str, expected_ns, base_node.expect_real(), extra_fragment) {
+                match self.resolve(path_str, expected_ns, base_node, extra_fragment) {
                     Ok(res) => Some(res),
                     Err(ErrorKind::Resolve(box mut kind)) => {
                         // We only looked in one namespace. Try to give a better error if possible.
@@ -1354,12 +1349,9 @@ fn resolve_with_disambiguator(
                             // FIXME: really it should be `resolution_failure` that does this, not `resolve_with_disambiguator`
                             // See https://github.com/rust-lang/rust/pull/76955#discussion_r493953382 for a good approach
                             for &new_ns in &[other_ns, MacroNS] {
-                                if let Some(res) = self.check_full_res(
-                                    new_ns,
-                                    path_str,
-                                    base_node.expect_real(),
-                                    extra_fragment,
-                                ) {
+                                if let Some(res) =
+                                    self.check_full_res(new_ns, path_str, base_node, extra_fragment)
+                                {
                                     kind = ResolutionFailure::WrongNamespace { res, expected_ns };
                                     break;
                                 }
@@ -1381,14 +1373,9 @@ fn resolve_with_disambiguator(
                 // Try everything!
                 let mut candidates = PerNS {
                     macro_ns: self
-                        .resolve_macro(path_str, base_node.expect_real())
+                        .resolve_macro(path_str, base_node)
                         .map(|res| (res, extra_fragment.clone())),
-                    type_ns: match self.resolve(
-                        path_str,
-                        TypeNS,
-                        base_node.expect_real(),
-                        extra_fragment,
-                    ) {
+                    type_ns: match self.resolve(path_str, TypeNS, base_node, extra_fragment) {
                         Ok(res) => {
                             debug!("got res in TypeNS: {:?}", res);
                             Ok(res)
@@ -1399,12 +1386,7 @@ fn resolve_with_disambiguator(
                         }
                         Err(ErrorKind::Resolve(box kind)) => Err(kind),
                     },
-                    value_ns: match self.resolve(
-                        path_str,
-                        ValueNS,
-                        base_node.expect_real(),
-                        extra_fragment,
-                    ) {
+                    value_ns: match self.resolve(path_str, ValueNS, base_node, extra_fragment) {
                         Ok(res) => Ok(res),
                         Err(ErrorKind::AnchorFailure(msg)) => {
                             anchor_failure(self.cx, diag, msg);
@@ -1460,17 +1442,14 @@ fn resolve_with_disambiguator(
                 }
             }
             Some(MacroNS) => {
-                match self.resolve_macro(path_str, base_node.expect_real()) {
+                match self.resolve_macro(path_str, base_node) {
                     Ok(res) => Some((res, extra_fragment.clone())),
                     Err(mut kind) => {
                         // `resolve_macro` only looks in the macro namespace. Try to give a better error if possible.
                         for &ns in &[TypeNS, ValueNS] {
-                            if let Some(res) = self.check_full_res(
-                                ns,
-                                path_str,
-                                base_node.expect_real(),
-                                extra_fragment,
-                            ) {
+                            if let Some(res) =
+                                self.check_full_res(ns, path_str, base_node, extra_fragment)
+                            {
                                 kind =
                                     ResolutionFailure::WrongNamespace { res, expected_ns: MacroNS };
                                 break;
index 90b797da24915286fa01d122688ddd65aadcb0b3..9b7e10b2688bb71bf58e200627da73444ac8181e 100644 (file)
@@ -126,7 +126,7 @@ fn add_deref_target(
         // Since only the `DefId` portion of the `Type` instances is known to be same for both the
         // `Deref` target type and the impl for type positions, this map of types is keyed by
         // `DefId` and for convenience uses a special cleaner that accepts `DefId`s directly.
-        if cleaner.keep_impl_with_def_id(&FakeDefId::new_real(*type_did)) {
+        if cleaner.keep_impl_with_def_id(FakeDefId::Real(*type_did)) {
             add_deref_target(&type_did_to_deref_target, &mut cleaner, type_did);
         }
     }
@@ -206,13 +206,13 @@ fn keep_impl(&self, ty: &Type) -> bool {
         } else if let Some(prim) = ty.primitive_type() {
             self.prims.contains(&prim)
         } else if let Some(did) = ty.def_id() {
-            self.keep_impl_with_def_id(&did.into())
+            self.keep_impl_with_def_id(did.into())
         } else {
             false
         }
     }
 
-    fn keep_impl_with_def_id(&self, did: &FakeDefId) -> bool {
-        self.items.contains(did)
+    fn keep_impl_with_def_id(&self, did: FakeDefId) -> bool {
+        self.items.contains(&did)
     }
 }
index e5910d081a5d017deefa791411de14e84325f296..87573e8e037a96c22d546d48647b19c735d65727 100644 (file)
@@ -4,7 +4,7 @@
 use crate::clean;
 use crate::clean::{FakeDefIdSet, Item, NestedAttributesExt};
 use crate::core::DocContext;
-use crate::fold::{DocFolder, StripItem};
+use crate::fold::{strip_item, DocFolder};
 use crate::passes::{ImplStripper, Pass};
 
 crate const STRIP_HIDDEN: Pass = Pass {
@@ -44,7 +44,7 @@ fn fold_item(&mut self, i: Item) -> Option<Item> {
                     // strip things like impl methods but when doing so
                     // we must not add any items to the `retained` set.
                     let old = mem::replace(&mut self.update_retained, false);
-                    let ret = StripItem(self.fold_item_recur(i)).strip();
+                    let ret = strip_item(self.fold_item_recur(i));
                     self.update_retained = old;
                     return Some(ret);
                 }
index 87399256292a865467ac8589517fc3216e8e0425..528518410aa0680a7c0dc24cd7e2cfba1b891b22 100644 (file)
@@ -3,7 +3,7 @@
 use std::mem;
 
 use crate::clean::{self, FakeDefIdSet, GetDefId, Item};
-use crate::fold::{DocFolder, StripItem};
+use crate::fold::{strip_item, DocFolder};
 
 crate struct Stripper<'a> {
     crate retained: &'a mut FakeDefIdSet,
@@ -51,7 +51,7 @@ fn fold_item(&mut self, i: Item) -> Option<Item> {
 
             clean::StructFieldItem(..) => {
                 if !i.visibility.is_public() {
-                    return Some(StripItem(i).strip());
+                    return Some(strip_item(i));
                 }
             }
 
@@ -59,7 +59,7 @@ fn fold_item(&mut self, i: Item) -> Option<Item> {
                 if i.def_id.is_local() && !i.visibility.is_public() {
                     debug!("Stripper: stripping module {:?}", i.name);
                     let old = mem::replace(&mut self.update_retained, false);
-                    let ret = StripItem(self.fold_item_recur(i)).strip();
+                    let ret = strip_item(self.fold_item_recur(i));
                     self.update_retained = old;
                     return Some(ret);
                 }
index c78cf18a07f19faa3e51f15220bca39f47d437e0..5f67a5715771b7d29e4713e8d68338602d216dcf 160000 (submodule)
@@ -1 +1 @@
-Subproject commit c78cf18a07f19faa3e51f15220bca39f47d437e0
+Subproject commit 5f67a5715771b7d29e4713e8d68338602d216dcf
diff --git a/src/test/assembly/asm/global_asm.rs b/src/test/assembly/asm/global_asm.rs
new file mode 100644 (file)
index 0000000..3a7f2fa
--- /dev/null
@@ -0,0 +1,14 @@
+// min-llvm-version: 10.0.1
+// only-x86_64
+// assembly-output: emit-asm
+// compile-flags: -C llvm-args=--x86-asm-syntax=intel
+
+#![feature(asm, global_asm)]
+#![crate_type = "rlib"]
+
+// CHECK: mov eax, eax
+global_asm!("mov eax, eax");
+// CHECK: mov ebx, 5
+global_asm!("mov ebx, {}", const 5);
+// CHECK: mov ecx, 5
+global_asm!("movl ${}, %ecx", const 5, options(att_syntax));
diff --git a/src/test/assembly/asm/powerpc-types.rs b/src/test/assembly/asm/powerpc-types.rs
new file mode 100644 (file)
index 0000000..26c8913
--- /dev/null
@@ -0,0 +1,165 @@
+// min-llvm-version: 10.0.1
+// assembly-output: emit-asm
+// compile-flags: --target powerpc-unknown-linux-gnu
+// needs-llvm-components: powerpc
+
+#![feature(no_core, lang_items, rustc_attrs, repr_simd)]
+#![crate_type = "rlib"]
+#![no_core]
+#![allow(asm_sub_register, non_camel_case_types)]
+
+#[rustc_builtin_macro]
+macro_rules! asm {
+    () => {};
+}
+#[rustc_builtin_macro]
+macro_rules! concat {
+    () => {};
+}
+#[rustc_builtin_macro]
+macro_rules! stringify {
+    () => {};
+}
+
+#[lang = "sized"]
+trait Sized {}
+#[lang = "copy"]
+trait Copy {}
+
+type ptr = *const i32;
+
+impl Copy for i8 {}
+impl Copy for u8 {}
+impl Copy for i16 {}
+impl Copy for i32 {}
+impl Copy for i64 {}
+impl Copy for f32 {}
+impl Copy for f64 {}
+impl Copy for ptr {}
+extern "C" {
+    fn extern_func();
+    static extern_static: u8;
+}
+
+// Hack to avoid function merging
+extern "Rust" {
+    fn dont_merge(s: &str);
+}
+
+macro_rules! check { ($func:ident, $ty:ty, $class:ident, $mov:literal) => {
+    #[no_mangle]
+    pub unsafe fn $func(x: $ty) -> $ty {
+        dont_merge(stringify!($func));
+
+        let y;
+        asm!(concat!($mov," {}, {}"), out($class) y, in($class) x);
+        y
+    }
+};}
+
+macro_rules! check_reg { ($func:ident, $ty:ty, $rego:tt, $regc:tt, $mov:literal) => {
+    #[no_mangle]
+    pub unsafe fn $func(x: $ty) -> $ty {
+        dont_merge(stringify!($func));
+
+        let y;
+        asm!(concat!($mov, " ", $rego, ", ", $rego), lateout($regc) y, in($regc) x);
+        y
+    }
+};}
+
+// CHECK-LABEL: reg_i8:
+// CHECK: #APP
+// CHECK: mr {{[0-9]+}}, {{[0-9]+}}
+// CHECK: #NO_APP
+check!(reg_i8, i8, reg, "mr");
+
+// CHECK-LABEL: reg_i16:
+// CHECK: #APP
+// CHECK: mr {{[0-9]+}}, {{[0-9]+}}
+// CHECK: #NO_APP
+check!(reg_i16, i16, reg, "mr");
+
+// CHECK-LABEL: reg_i32:
+// CHECK: #APP
+// CHECK: mr {{[0-9]+}}, {{[0-9]+}}
+// CHECK: #NO_APP
+check!(reg_i32, i32, reg, "mr");
+
+// CHECK-LABEL: reg_i8_nz:
+// CHECK: #APP
+// CHECK: mr {{[0-9]+}}, {{[0-9]+}}
+// CHECK: #NO_APP
+check!(reg_i8_nz, i8, reg_nonzero, "mr");
+
+// CHECK-LABEL: reg_i16_nz:
+// CHECK: #APP
+// CHECK: mr {{[0-9]+}}, {{[0-9]+}}
+// CHECK: #NO_APP
+check!(reg_i16_nz, i16, reg_nonzero, "mr");
+
+// CHECK-LABEL: reg_i32_nz:
+// CHECK: #APP
+// CHECK: mr {{[0-9]+}}, {{[0-9]+}}
+// CHECK: #NO_APP
+check!(reg_i32_nz, i32, reg_nonzero, "mr");
+
+// CHECK-LABEL: reg_f32:
+// CHECK: #APP
+// CHECK: fmr {{[0-9]+}}, {{[0-9]+}}
+// CHECK: #NO_APP
+check!(reg_f32, f32, freg, "fmr");
+
+// CHECK-LABEL: reg_f64:
+// CHECK: #APP
+// CHECK: fmr {{[0-9]+}}, {{[0-9]+}}
+// CHECK: #NO_APP
+check!(reg_f64, f64, freg, "fmr");
+
+// CHECK-LABEL: reg_i8_r0:
+// CHECK: #APP
+// CHECK: mr 0, 0
+// CHECK: #NO_APP
+check_reg!(reg_i8_r0, i8, "0", "0", "mr");
+
+// CHECK-LABEL: reg_i16_r0:
+// CHECK: #APP
+// CHECK: mr 0, 0
+// CHECK: #NO_APP
+check_reg!(reg_i16_r0, i16, "0", "0", "mr");
+
+// CHECK-LABEL: reg_i32_r0:
+// CHECK: #APP
+// CHECK: mr 0, 0
+// CHECK: #NO_APP
+check_reg!(reg_i32_r0, i32, "0", "0", "mr");
+
+// CHECK-LABEL: reg_i8_r18:
+// CHECK: #APP
+// CHECK: mr 18, 18
+// CHECK: #NO_APP
+check_reg!(reg_i8_r18, i8, "18", "18", "mr");
+
+// CHECK-LABEL: reg_i16_r18:
+// CHECK: #APP
+// CHECK: mr 18, 18
+// CHECK: #NO_APP
+check_reg!(reg_i16_r18, i16, "18", "18", "mr");
+
+// CHECK-LABEL: reg_i32_r18:
+// CHECK: #APP
+// CHECK: mr 18, 18
+// CHECK: #NO_APP
+check_reg!(reg_i32_r18, i32, "18", "18", "mr");
+
+// CHECK-LABEL: reg_f32_f0:
+// CHECK: #APP
+// CHECK: fmr 0, 0
+// CHECK: #NO_APP
+check_reg!(reg_f32_f0, f32, "0", "f0", "fmr");
+
+// CHECK-LABEL: reg_f64_f0:
+// CHECK: #APP
+// CHECK: fmr 0, 0
+// CHECK: #NO_APP
+check_reg!(reg_f64_f0, f64, "0", "f0", "fmr");
diff --git a/src/test/codegen/remap_path_prefix/issue-73167-remap-std.rs b/src/test/codegen/remap_path_prefix/issue-73167-remap-std.rs
new file mode 100644 (file)
index 0000000..b66abc6
--- /dev/null
@@ -0,0 +1,15 @@
+// ignore-windows
+
+// compile-flags: -g  -C no-prepopulate-passes -Z simulate-remapped-rust-src-base=/rustc/xyz
+
+// Here we check that importing std will not cause real path to std source files
+// to leak. If rustc was compiled with remap-debuginfo = true, this should be
+// true automatically. If paths to std library hasn't been remapped, we use the
+// above simulate-remapped-rust-src-base option to do it temporarily
+
+// CHECK: !DIFile(filename: "{{/rustc/.*/library/std/src/panic.rs}}"
+fn main() {
+    std::thread::spawn(|| {
+        println!("hello");
+    });
+}
index 06b2957ac62c9778512404b61cc2680332627abb..edb3d60ba3f894372d0a76936d5f4ada45072fea 100644 (file)
@@ -11,7 +11,8 @@
 
 fn main() {
     unsafe {
-        let _: I32x2 = simd_shuffle2(I32x2(1, 2), I32x2(3, 4), [0, 0]);
-        let _: I32x2 = simd_shuffle2(I32x2(1, 2), I32x2(3, 4), [0, 0]);
+        const IDX: [u32; 2] = [0, 0];
+        let _: I32x2 = simd_shuffle2(I32x2(1, 2), I32x2(3, 4), IDX);
+        let _: I32x2 = simd_shuffle2(I32x2(1, 2), I32x2(3, 4), IDX);
     }
 }
diff --git a/src/test/incremental/issue-85197-invalid-span/auxiliary/invalid-span-helper-lib.rs b/src/test/incremental/issue-85197-invalid-span/auxiliary/invalid-span-helper-lib.rs
new file mode 100644 (file)
index 0000000..2453af5
--- /dev/null
@@ -0,0 +1,11 @@
+// revisions: rpass1 rpass2
+
+extern crate respan;
+
+#[macro_use]
+#[path = "invalid-span-helper-mod.rs"]
+mod invalid_span_helper_mod;
+
+// Invoke a macro from a different file - this
+// allows us to get tokens with spans from different files
+helper!(1);
diff --git a/src/test/incremental/issue-85197-invalid-span/auxiliary/invalid-span-helper-mod.rs b/src/test/incremental/issue-85197-invalid-span/auxiliary/invalid-span-helper-mod.rs
new file mode 100644 (file)
index 0000000..747174b
--- /dev/null
@@ -0,0 +1,14 @@
+#[macro_export]
+macro_rules! helper {
+    // Use `:tt` instead of `:ident` so that we don't get a `None`-delimited group
+    ($first:tt) => {
+        pub fn foo<T>() {
+            // The span of `$first` comes from another file,
+            // so the expression `1 + $first` ends up with an
+            // 'invalid' span that starts and ends in different files.
+            // We use the `respan!` macro to give all tokens the same
+            // `SyntaxContext`, so that the parser will try to merge the spans.
+            respan::respan!(let a = 1 + $first;);
+        }
+    }
+}
diff --git a/src/test/incremental/issue-85197-invalid-span/auxiliary/respan.rs b/src/test/incremental/issue-85197-invalid-span/auxiliary/respan.rs
new file mode 100644 (file)
index 0000000..5088eab
--- /dev/null
@@ -0,0 +1,19 @@
+// force-host
+// no-prefer-dynamic
+
+#![crate_type = "proc-macro"]
+
+extern crate proc_macro;
+use proc_macro::TokenStream;
+
+
+/// Copies the resolution information (the `SyntaxContext`) of the first
+/// token to all other tokens in the stream. Does not recurse into groups.
+#[proc_macro]
+pub fn respan(input: TokenStream) -> TokenStream {
+    let first_span = input.clone().into_iter().next().unwrap().span();
+    input.into_iter().map(|mut tree| {
+        tree.set_span(tree.span().resolved_at(first_span));
+        tree
+    }).collect()
+}
diff --git a/src/test/incremental/issue-85197-invalid-span/invalid_span_main.rs b/src/test/incremental/issue-85197-invalid-span/invalid_span_main.rs
new file mode 100644 (file)
index 0000000..f358460
--- /dev/null
@@ -0,0 +1,24 @@
+// revisions: rpass1 rpass2
+// aux-build:respan.rs
+// aux-build:invalid-span-helper-lib.rs
+
+// This issue has several different parts. The high level idea is:
+// 1. We create an 'invalid' span with the help of the `respan` proc-macro,
+// The compiler attempts to prevent the creation of invalid spans by
+// refusing to join spans with different `SyntaxContext`s. We work around
+// this by applying the same `SyntaxContext` to the span of every token,
+// using `Span::resolved_at`
+// 2. We using this invalid span in the body of a function, causing it to get
+// encoded into the `optimized_mir`
+// 3. We call the function from a different crate - since the function is generic,
+// monomorphization runs, causing `optimized_mir` to get called.
+// 4. We re-run compilation using our populated incremental cache, but without
+// making any changes. When we recompile the crate containing our generic function
+// (`invalid_span_helper_lib`), we load the span from the incremental cache, and
+// write it into the crate metadata.
+
+extern crate invalid_span_helper_lib;
+
+fn main() {
+    invalid_span_helper_lib::foo::<u8>();
+}
diff --git a/src/test/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.mir
new file mode 100644 (file)
index 0000000..c6ef403
--- /dev/null
@@ -0,0 +1,199 @@
+// MIR for `array_casts` after SimplifyCfg-elaborate-drops
+
+fn array_casts() -> () {
+    let mut _0: ();                      // return place in scope 0 at $DIR/retag.rs:57:18: 57:18
+    let mut _1: [usize; 2];              // in scope 0 at $DIR/retag.rs:58:9: 58:14
+    let mut _3: *mut [usize; 2];         // in scope 0 at $DIR/retag.rs:59:13: 59:19
+    let mut _4: &mut [usize; 2];         // in scope 0 at $DIR/retag.rs:59:13: 59:19
+    let _5: ();                          // in scope 0 at $DIR/retag.rs:60:5: 60:30
+    let mut _6: *mut usize;              // in scope 0 at $DIR/retag.rs:60:15: 60:23
+    let mut _7: *mut usize;              // in scope 0 at $DIR/retag.rs:60:15: 60:16
+    let mut _10: *const [usize; 2];      // in scope 0 at $DIR/retag.rs:63:13: 63:15
+    let _11: &[usize; 2];                // in scope 0 at $DIR/retag.rs:63:13: 63:15
+    let _12: ();                         // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+    let mut _13: (&usize, &usize);       // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+    let mut _14: &usize;                 // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+    let _15: usize;                      // in scope 0 at $DIR/retag.rs:64:16: 64:36
+    let mut _16: *const usize;           // in scope 0 at $DIR/retag.rs:64:26: 64:34
+    let mut _17: *const usize;           // in scope 0 at $DIR/retag.rs:64:26: 64:27
+    let mut _18: &usize;                 // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+    let _19: usize;                      // in scope 0 at $DIR/retag.rs:64:38: 64:39
+    let mut _22: bool;                   // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+    let mut _23: bool;                   // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+    let mut _24: usize;                  // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+    let mut _25: usize;                  // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+    let mut _26: !;                      // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+    let _28: !;                          // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+    let mut _29: core::panicking::AssertKind; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+    let mut _30: &usize;                 // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+    let _31: &usize;                     // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+    let mut _32: &usize;                 // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+    let _33: &usize;                     // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+    let mut _34: std::option::Option<std::fmt::Arguments>; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+    scope 1 {
+        debug x => _1;                   // in scope 1 at $DIR/retag.rs:58:9: 58:14
+        let _2: *mut usize;              // in scope 1 at $DIR/retag.rs:59:9: 59:10
+        scope 2 {
+            debug p => _2;               // in scope 2 at $DIR/retag.rs:59:9: 59:10
+            let _8: [usize; 2];          // in scope 2 at $DIR/retag.rs:62:9: 62:10
+            scope 3 {
+            }
+            scope 4 {
+                debug x => _8;           // in scope 4 at $DIR/retag.rs:62:9: 62:10
+                let _9: *const usize;    // in scope 4 at $DIR/retag.rs:63:9: 63:10
+                scope 5 {
+                    debug p => _9;       // in scope 5 at $DIR/retag.rs:63:9: 63:10
+                    let _20: &usize;     // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+                    let _21: &usize;     // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+                    let mut _35: &usize; // in scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+                    scope 6 {
+                    }
+                    scope 7 {
+                        debug left_val => _20; // in scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+                        debug right_val => _21; // in scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+                        let _27: core::panicking::AssertKind; // in scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+                        scope 8 {
+                            debug kind => _27; // in scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    bb0: {
+        StorageLive(_1);                 // scope 0 at $DIR/retag.rs:58:9: 58:14
+        _1 = [const 0_usize, const 0_usize]; // scope 0 at $DIR/retag.rs:58:29: 58:35
+        StorageLive(_2);                 // scope 1 at $DIR/retag.rs:59:9: 59:10
+        StorageLive(_3);                 // scope 1 at $DIR/retag.rs:59:13: 59:19
+        StorageLive(_4);                 // scope 1 at $DIR/retag.rs:59:13: 59:19
+        _4 = &mut _1;                    // scope 1 at $DIR/retag.rs:59:13: 59:19
+        Retag(_4);                       // scope 1 at $DIR/retag.rs:59:13: 59:19
+        _3 = &raw mut (*_4);             // scope 1 at $DIR/retag.rs:59:13: 59:19
+        Retag([raw] _3);                 // scope 1 at $DIR/retag.rs:59:13: 59:19
+        _2 = move _3 as *mut usize (Pointer(ArrayToPointer)); // scope 1 at $DIR/retag.rs:59:13: 59:33
+        StorageDead(_3);                 // scope 1 at $DIR/retag.rs:59:32: 59:33
+        StorageDead(_4);                 // scope 1 at $DIR/retag.rs:59:33: 59:34
+        StorageLive(_5);                 // scope 2 at $DIR/retag.rs:60:5: 60:30
+        StorageLive(_6);                 // scope 3 at $DIR/retag.rs:60:15: 60:23
+        StorageLive(_7);                 // scope 3 at $DIR/retag.rs:60:15: 60:16
+        _7 = _2;                         // scope 3 at $DIR/retag.rs:60:15: 60:16
+        _6 = ptr::mut_ptr::<impl *mut usize>::add(move _7, const 1_usize) -> bb1; // scope 3 at $DIR/retag.rs:60:15: 60:23
+                                         // mir::Constant
+                                         // + span: $DIR/retag.rs:60:17: 60:20
+                                         // + literal: Const { ty: unsafe fn(*mut usize, usize) -> *mut usize {std::ptr::mut_ptr::<impl *mut usize>::add}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb1: {
+        StorageDead(_7);                 // scope 3 at $DIR/retag.rs:60:22: 60:23
+        (*_6) = const 1_usize;           // scope 3 at $DIR/retag.rs:60:14: 60:27
+        StorageDead(_6);                 // scope 3 at $DIR/retag.rs:60:27: 60:28
+        _5 = const ();                   // scope 3 at $DIR/retag.rs:60:5: 60:30
+        StorageDead(_5);                 // scope 2 at $DIR/retag.rs:60:29: 60:30
+        StorageLive(_8);                 // scope 2 at $DIR/retag.rs:62:9: 62:10
+        _8 = [const 0_usize, const 1_usize]; // scope 2 at $DIR/retag.rs:62:25: 62:31
+        StorageLive(_9);                 // scope 4 at $DIR/retag.rs:63:9: 63:10
+        StorageLive(_10);                // scope 4 at $DIR/retag.rs:63:13: 63:15
+        StorageLive(_11);                // scope 4 at $DIR/retag.rs:63:13: 63:15
+        _11 = &_8;                       // scope 4 at $DIR/retag.rs:63:13: 63:15
+        Retag(_11);                      // scope 4 at $DIR/retag.rs:63:13: 63:15
+        _10 = &raw const (*_11);         // scope 4 at $DIR/retag.rs:63:13: 63:15
+        Retag([raw] _10);                // scope 4 at $DIR/retag.rs:63:13: 63:15
+        _9 = move _10 as *const usize (Pointer(ArrayToPointer)); // scope 4 at $DIR/retag.rs:63:13: 63:31
+        StorageDead(_10);                // scope 4 at $DIR/retag.rs:63:30: 63:31
+        StorageDead(_11);                // scope 4 at $DIR/retag.rs:63:31: 63:32
+        StorageLive(_12);                // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageLive(_13);                // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageLive(_14);                // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageLive(_15);                // scope 5 at $DIR/retag.rs:64:16: 64:36
+        StorageLive(_16);                // scope 6 at $DIR/retag.rs:64:26: 64:34
+        StorageLive(_17);                // scope 6 at $DIR/retag.rs:64:26: 64:27
+        _17 = _9;                        // scope 6 at $DIR/retag.rs:64:26: 64:27
+        _16 = ptr::const_ptr::<impl *const usize>::add(move _17, const 1_usize) -> bb2; // scope 6 at $DIR/retag.rs:64:26: 64:34
+                                         // mir::Constant
+                                         // + span: $DIR/retag.rs:64:28: 64:31
+                                         // + literal: Const { ty: unsafe fn(*const usize, usize) -> *const usize {std::ptr::const_ptr::<impl *const usize>::add}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb2: {
+        StorageDead(_17);                // scope 6 at $DIR/retag.rs:64:33: 64:34
+        _15 = (*_16);                    // scope 6 at $DIR/retag.rs:64:25: 64:34
+        _14 = &_15;                      // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        Retag(_14);                      // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageLive(_18);                // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        _35 = const array_casts::promoted[0]; // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+                                         // ty::Const
+                                         // + ty: &usize
+                                         // + val: Unevaluated(array_casts, [], Some(promoted[0]))
+                                         // mir::Constant
+                                         // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL
+                                         // + literal: Const { ty: &usize, val: Unevaluated(Unevaluated { def: WithOptConstParam { did: DefId(0:15 ~ retag[317d]::array_casts), const_param_did: None }, substs: [], promoted: Some(promoted[0]) }) }
+        Retag(_35);                      // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        _18 = &(*_35);                   // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        Retag(_18);                      // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        _13 = (move _14, move _18);      // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageDead(_18);                // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageDead(_14);                // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageLive(_20);                // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        _20 = (_13.0: &usize);           // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        Retag(_20);                      // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageLive(_21);                // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        _21 = (_13.1: &usize);           // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        Retag(_21);                      // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageLive(_22);                // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageLive(_23);                // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageLive(_24);                // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        _24 = (*_20);                    // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageLive(_25);                // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        _25 = (*_21);                    // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        _23 = Eq(move _24, move _25);    // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageDead(_25);                // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageDead(_24);                // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        _22 = Not(move _23);             // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageDead(_23);                // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        switchInt(move _22) -> [false: bb4, otherwise: bb3]; // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+    }
+
+    bb3: {
+        StorageLive(_27);                // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        _27 = core::panicking::AssertKind::Eq; // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageLive(_28);                // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageLive(_29);                // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        _29 = move _27;                  // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageLive(_30);                // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageLive(_31);                // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        _31 = &(*_20);                   // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        Retag(_31);                      // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        _30 = &(*_31);                   // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        Retag(_30);                      // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageLive(_32);                // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageLive(_33);                // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        _33 = &(*_21);                   // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        Retag(_33);                      // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        _32 = &(*_33);                   // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        Retag(_32);                      // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageLive(_34);                // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        _34 = Option::<Arguments>::None; // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        core::panicking::assert_failed::<usize, usize>(move _29, move _30, move _32, move _34); // scope 8 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+                                         // mir::Constant
+                                         // + span: $SRC_DIR/core/src/macros/mod.rs:LL:COL
+                                         // + literal: Const { ty: for<'r, 's, 't0> fn(core::panicking::AssertKind, &'r usize, &'s usize, std::option::Option<std::fmt::Arguments<'t0>>) -> ! {core::panicking::assert_failed::<usize, usize>}, val: Value(Scalar(<ZST>)) }
+    }
+
+    bb4: {
+        _12 = const ();                  // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageDead(_22);                // scope 7 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageDead(_21);                // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageDead(_20);                // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageDead(_16);                // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageDead(_15);                // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageDead(_13);                // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        StorageDead(_12);                // scope 5 at $SRC_DIR/core/src/macros/mod.rs:LL:COL
+        _0 = const ();                   // scope 0 at $DIR/retag.rs:57:18: 65:2
+        StorageDead(_9);                 // scope 4 at $DIR/retag.rs:65:1: 65:2
+        StorageDead(_8);                 // scope 2 at $DIR/retag.rs:65:1: 65:2
+        StorageDead(_2);                 // scope 1 at $DIR/retag.rs:65:1: 65:2
+        StorageDead(_1);                 // scope 0 at $DIR/retag.rs:65:1: 65:2
+        return;                          // scope 0 at $DIR/retag.rs:65:2: 65:2
+    }
+}
index 894f64c77672d76bf2ef4cc192b31fd479694d58..4bab5a974881a6b4f05cd6f7490c26092bd19907 100644 (file)
@@ -21,6 +21,7 @@ fn main() -> () {
     let _23: &i32;                       // in scope 0 at $DIR/retag.rs:47:21: 47:23
     let _24: i32;                        // in scope 0 at $DIR/retag.rs:47:22: 47:23
     let mut _26: *const i32;             // in scope 0 at $DIR/retag.rs:50:14: 50:28
+    let _27: ();                         // in scope 0 at $DIR/retag.rs:52:5: 52:18
     scope 1 {
         debug x => _1;                   // in scope 1 at $DIR/retag.rs:30:9: 30:14
         let _3: &mut i32;                // in scope 1 at $DIR/retag.rs:32:13: 32:14
@@ -46,7 +47,7 @@ fn main() -> () {
             scope 7 {
                 debug _w => _15;         // in scope 7 at $DIR/retag.rs:44:9: 44:11
                 let _25: *const i32;     // in scope 7 at $DIR/retag.rs:50:9: 50:11
-                let mut _27: &i32;       // in scope 7 at $DIR/retag.rs:47:21: 47:23
+                let mut _28: &i32;       // in scope 7 at $DIR/retag.rs:47:21: 47:23
                 scope 8 {
                     debug _w => _25;     // in scope 8 at $DIR/retag.rs:50:9: 50:11
                 }
@@ -70,7 +71,7 @@ fn main() -> () {
         Retag(_7);                       // scope 1 at $DIR/retag.rs:32:29: 32:35
         _6 = &mut (*_7);                 // scope 1 at $DIR/retag.rs:32:29: 32:35
         Retag([2phase] _6);              // scope 1 at $DIR/retag.rs:32:29: 32:35
-        _3 = Test::foo(move _4, move _6) -> [return: bb1, unwind: bb7]; // scope 1 at $DIR/retag.rs:32:17: 32:36
+        _3 = Test::foo(move _4, move _6) -> [return: bb1, unwind: bb8]; // scope 1 at $DIR/retag.rs:32:17: 32:36
                                          // mir::Constant
                                          // + span: $DIR/retag.rs:32:25: 32:28
                                          // + literal: Const { ty: for<'r, 'x> fn(&'r Test, &'x mut i32) -> &'x mut i32 {Test::foo}, val: Value(Scalar(<ZST>)) }
@@ -81,7 +82,7 @@ fn main() -> () {
         StorageDead(_6);                 // scope 1 at $DIR/retag.rs:32:35: 32:36
         StorageDead(_4);                 // scope 1 at $DIR/retag.rs:32:35: 32:36
         StorageDead(_7);                 // scope 1 at $DIR/retag.rs:32:36: 32:37
-        drop(_5) -> [return: bb2, unwind: bb8]; // scope 1 at $DIR/retag.rs:32:36: 32:37
+        drop(_5) -> [return: bb2, unwind: bb9]; // scope 1 at $DIR/retag.rs:32:36: 32:37
     }
 
     bb2: {
@@ -146,19 +147,19 @@ fn main() -> () {
         Retag(_20);                      // scope 7 at $DIR/retag.rs:47:5: 47:12
         StorageLive(_22);                // scope 7 at $DIR/retag.rs:47:21: 47:23
         StorageLive(_23);                // scope 7 at $DIR/retag.rs:47:21: 47:23
-        _27 = const main::promoted[0];   // scope 7 at $DIR/retag.rs:47:21: 47:23
+        _28 = const main::promoted[0];   // scope 7 at $DIR/retag.rs:47:21: 47:23
                                          // ty::Const
                                          // + ty: &i32
                                          // + val: Unevaluated(main, [], Some(promoted[0]))
                                          // mir::Constant
                                          // + span: $DIR/retag.rs:47:21: 47:23
                                          // + literal: Const { ty: &i32, val: Unevaluated(Unevaluated { def: WithOptConstParam { did: DefId(0:13 ~ retag[317d]::main), const_param_did: None }, substs: [], promoted: Some(promoted[0]) }) }
-        Retag(_27);                      // scope 7 at $DIR/retag.rs:47:21: 47:23
-        _23 = &(*_27);                   // scope 7 at $DIR/retag.rs:47:21: 47:23
+        Retag(_28);                      // scope 7 at $DIR/retag.rs:47:21: 47:23
+        _23 = &(*_28);                   // scope 7 at $DIR/retag.rs:47:21: 47:23
         Retag(_23);                      // scope 7 at $DIR/retag.rs:47:21: 47:23
         _22 = &(*_23);                   // scope 7 at $DIR/retag.rs:47:21: 47:23
         Retag(_22);                      // scope 7 at $DIR/retag.rs:47:21: 47:23
-        _19 = Test::foo_shr(move _20, move _22) -> [return: bb4, unwind: bb6]; // scope 7 at $DIR/retag.rs:47:5: 47:24
+        _19 = Test::foo_shr(move _20, move _22) -> [return: bb4, unwind: bb7]; // scope 7 at $DIR/retag.rs:47:5: 47:24
                                          // mir::Constant
                                          // + span: $DIR/retag.rs:47:13: 47:20
                                          // + literal: Const { ty: for<'r, 'x> fn(&'r Test, &'x i32) -> &'x i32 {Test::foo_shr}, val: Value(Scalar(<ZST>)) }
@@ -169,7 +170,7 @@ fn main() -> () {
         StorageDead(_22);                // scope 7 at $DIR/retag.rs:47:23: 47:24
         StorageDead(_20);                // scope 7 at $DIR/retag.rs:47:23: 47:24
         StorageDead(_23);                // scope 7 at $DIR/retag.rs:47:24: 47:25
-        drop(_21) -> [return: bb5, unwind: bb8]; // scope 7 at $DIR/retag.rs:47:24: 47:25
+        drop(_21) -> [return: bb5, unwind: bb9]; // scope 7 at $DIR/retag.rs:47:24: 47:25
     }
 
     bb5: {
@@ -181,23 +182,32 @@ fn main() -> () {
         Retag([raw] _26);                // scope 7 at $DIR/retag.rs:50:14: 50:16
         _25 = _26;                       // scope 7 at $DIR/retag.rs:50:14: 50:28
         StorageDead(_26);                // scope 7 at $DIR/retag.rs:50:28: 50:29
-        _0 = const ();                   // scope 0 at $DIR/retag.rs:29:11: 51:2
-        StorageDead(_25);                // scope 7 at $DIR/retag.rs:51:1: 51:2
-        StorageDead(_15);                // scope 6 at $DIR/retag.rs:51:1: 51:2
-        StorageDead(_13);                // scope 1 at $DIR/retag.rs:51:1: 51:2
-        StorageDead(_1);                 // scope 0 at $DIR/retag.rs:51:1: 51:2
-        return;                          // scope 0 at $DIR/retag.rs:51:2: 51:2
+        StorageLive(_27);                // scope 8 at $DIR/retag.rs:52:5: 52:18
+        _27 = array_casts() -> bb6;      // scope 8 at $DIR/retag.rs:52:5: 52:18
+                                         // mir::Constant
+                                         // + span: $DIR/retag.rs:52:5: 52:16
+                                         // + literal: Const { ty: fn() {array_casts}, val: Value(Scalar(<ZST>)) }
     }
 
-    bb6 (cleanup): {
-        drop(_21) -> bb8;                // scope 7 at $DIR/retag.rs:47:24: 47:25
+    bb6: {
+        StorageDead(_27);                // scope 8 at $DIR/retag.rs:52:18: 52:19
+        _0 = const ();                   // scope 0 at $DIR/retag.rs:29:11: 53:2
+        StorageDead(_25);                // scope 7 at $DIR/retag.rs:53:1: 53:2
+        StorageDead(_15);                // scope 6 at $DIR/retag.rs:53:1: 53:2
+        StorageDead(_13);                // scope 1 at $DIR/retag.rs:53:1: 53:2
+        StorageDead(_1);                 // scope 0 at $DIR/retag.rs:53:1: 53:2
+        return;                          // scope 0 at $DIR/retag.rs:53:2: 53:2
     }
 
     bb7 (cleanup): {
-        drop(_5) -> bb8;                 // scope 1 at $DIR/retag.rs:32:36: 32:37
+        drop(_21) -> bb9;                // scope 7 at $DIR/retag.rs:47:24: 47:25
     }
 
     bb8 (cleanup): {
-        resume;                          // scope 0 at $DIR/retag.rs:29:1: 51:2
+        drop(_5) -> bb9;                 // scope 1 at $DIR/retag.rs:32:36: 32:37
+    }
+
+    bb9 (cleanup): {
+        resume;                          // scope 0 at $DIR/retag.rs:29:1: 53:2
     }
 }
index d0ea2cfb18ba204e2a451fc093999a7d81c3602c..13568b822d4f3c6f1afe163e0d291a2c518288ab 100644 (file)
@@ -48,4 +48,18 @@ fn main() {
 
     // escape-to-raw (shr)
     let _w = _w as *const _;
+
+    array_casts();
+}
+
+/// Casting directly to an array should also go through `&raw` and thus add appropriate retags.
+// EMIT_MIR retag.array_casts.SimplifyCfg-elaborate-drops.after.mir
+fn array_casts() {
+    let mut x: [usize; 2] = [0, 0];
+    let p = &mut x as *mut usize;
+    unsafe { *p.add(1) = 1; }
+
+    let x: [usize; 2] = [0, 1];
+    let p = &x as *const usize;
+    assert_eq!(unsafe { *p.add(1) }, 1);
 }
index dc06a485a8fc124bd26a7779b81c9bd0ebd1dbef..322f5681b3fd9278243359047748a891ca46fe21 100644 (file)
@@ -12,7 +12,6 @@
    12|      1|    if b {
    13|      1|        println!("non_async_func println in block");
    14|      1|    }
-                   ^0
    15|      1|}
    16|       |
    17|       |
index 2d8a98a5d0c92f6a19ebc1c7b3fa63a63515f57c..656a26597759d337bac841ad5a4bfa956cac3a9b 100644 (file)
@@ -5,7 +5,6 @@
     5|      1|    if true {
     6|      1|        countdown = 10;
     7|      1|    }
-                   ^0
     8|       |
     9|       |    const B: u32 = 100;
    10|      1|    let x = if countdown > 7 {
@@ -25,7 +24,6 @@
    24|      1|    if true {
    25|      1|        countdown = 10;
    26|      1|    }
-                   ^0
    27|       |
    28|      1|    if countdown > 7 {
    29|      1|        countdown -= 4;
@@ -44,7 +42,6 @@
    41|      1|        if true {
    42|      1|            countdown = 10;
    43|      1|        }
-                       ^0
    44|       |
    45|      1|        if countdown > 7 {
    46|      1|            countdown -= 4;
    53|       |        } else {
    54|      0|            return;
    55|       |        }
-   56|      0|    }
-   57|       |
+   56|       |    } // Note: closing brace shows uncovered (vs. `0` for implicit else) because condition literal
+   57|       |      // `true` was const-evaluated. The compiler knows the `if` block will be executed.
    58|       |
    59|      1|    let mut countdown = 0;
    60|      1|    if true {
    61|      1|        countdown = 1;
    62|      1|    }
-                   ^0
    63|       |
    64|      1|    let z = if countdown > 7 {
                       ^0
index 7ae0e978808e7e7c717422a44ed141ae1e43b37d..1b6bb9ff8891de6c5ad657868580e8d31afe28ff 100644 (file)
@@ -9,7 +9,7 @@
     8|      1|//!     assert_eq!(1, 1);
     9|       |//! } else {
    10|       |//!     // this is not!
-   11|      0|//!     assert_eq!(1, 2);
+   11|       |//!     assert_eq!(1, 2);
    12|       |//! }
    13|      1|//! ```
    14|       |//!
@@ -84,7 +84,7 @@
    74|      1|    if true {
    75|      1|        assert_eq!(1, 1);
    76|       |    } else {
-   77|      0|        assert_eq!(1, 2);
+   77|       |        assert_eq!(1, 2);
    78|       |    }
    79|      1|}
    80|       |
index fe6a9e93cbf710ab516bdc1e2b283ed7ffae99eb..fab5be41901c9b544ba12e3379b30cb96d331177 100644 (file)
    19|      1|    if true {
    20|      1|        println!("Exiting with error...");
    21|      1|        return Err(1);
-   22|      0|    }
-   23|      0|
-   24|      0|    let _ = Firework { strength: 1000 };
-   25|      0|
-   26|      0|    Ok(())
+   22|       |    }
+   23|       |
+   24|       |    let _ = Firework { strength: 1000 };
+   25|       |
+   26|       |    Ok(())
    27|      1|}
    28|       |
    29|       |// Expected program output:
index 8e8bc0fd1894338f3f7b0579ee35ca6c02baf744..7b38ffb87cba89b257125b6585d09100014763df 100644 (file)
    30|      1|    if true {
    31|      1|        println!("Exiting with error...");
    32|      1|        return Err(1);
-   33|      0|    }
-   34|      0|
-   35|      0|
-   36|      0|
-   37|      0|
-   38|      0|
-   39|      0|    let _ = Firework { strength: 1000 };
-   40|      0|
-   41|      0|    Ok(())
+   33|       |    } // The remaining lines below have no coverage because `if true` (with the constant literal
+   34|       |      // `true`) is guaranteed to execute the `then` block, which is also guaranteed to `return`.
+   35|       |      // Thankfully, in the normal case, conditions are not guaranteed ahead of time, and as shown
+   36|       |      // in other tests, the lines below would have coverage (which would show they had `0`
+   37|       |      // executions, assuming the condition still evaluated to `true`).
+   38|       |
+   39|       |    let _ = Firework { strength: 1000 };
+   40|       |
+   41|       |    Ok(())
    42|      1|}
    43|       |
    44|       |// Expected program output:
index 5d572db7cc60da3b6b90c2a9dd799c7eda9143ed..81d5c7d90346d08a397e577d120352dbe465f124 100644 (file)
@@ -9,23 +9,23 @@
     9|      1|    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
    10|      1|        if true {
    11|      1|            if false {
-   12|      0|                while true {
-   13|      0|                }
+   12|       |                while true {
+   13|       |                }
    14|      1|            }
-   15|      1|            write!(f, "cool")?;
-                                           ^0
-   16|      0|        } else {
-   17|      0|        }
+   15|      1|            write!(f, "error")?;
+                                            ^0
+   16|       |        } else {
+   17|       |        }
    18|       |
    19|     10|        for i in 0..10 {
    20|     10|            if true {
    21|     10|                if false {
-   22|      0|                    while true {}
+   22|       |                    while true {}
    23|     10|                }
-   24|     10|                write!(f, "cool")?;
-                                               ^0
-   25|      0|            } else {
-   26|      0|            }
+   24|     10|                write!(f, "error")?;
+                                                ^0
+   25|       |            } else {
+   26|       |            }
    27|       |        }
    28|      1|        Ok(())
    29|      1|    }
    34|       |impl std::fmt::Display for DisplayTest {
    35|      1|    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
    36|      1|        if false {
-   37|      0|        } else {
+   37|       |        } else {
    38|      1|            if false {
-   39|      0|                while true {}
+   39|       |                while true {}
    40|      1|            }
-   41|      1|            write!(f, "cool")?;
-                                           ^0
+   41|      1|            write!(f, "error")?;
+                                            ^0
    42|       |        }
    43|     10|        for i in 0..10 {
    44|     10|            if false {
-   45|      0|            } else {
+   45|       |            } else {
    46|     10|                if false {
-   47|      0|                    while true {}
+   47|       |                    while true {}
    48|     10|                }
-   49|     10|                write!(f, "cool")?;
-                                               ^0
+   49|     10|                write!(f, "error")?;
+                                                ^0
    50|       |            }
    51|       |        }
    52|      1|        Ok(())
index 2d4c57f451a2de3871bb0223d6cfbd72b71d2dac..5adeef7d0850b462b369da348651e695db38307b 100644 (file)
@@ -1,6 +1,6 @@
     1|      1|fn main() {
     2|      1|    if false {
-    3|      0|        loop {}
+    3|       |        loop {}
     4|      1|    }
     5|      1|}
 
index 057599d1b471ab2e12a63f6a4a0b5b2fc9a3f654..8a2a0b53e5862f3031364e1e340834aedfbefda8 100644 (file)
@@ -53,8 +53,8 @@ fn main() {
         } else {
             return;
         }
-    }
-
+    } // Note: closing brace shows uncovered (vs. `0` for implicit else) because condition literal
+      // `true` was const-evaluated. The compiler knows the `if` block will be executed.
 
     let mut countdown = 0;
     if true {
index 18b38868496d4bc10a699e6fe68035adaf2690e2..cbeda35d3b8cfe8a5b226f769282d568f9689012 100644 (file)
@@ -30,11 +30,11 @@ fn main() -> Result<(),u8> {
     if true {
         println!("Exiting with error...");
         return Err(1);
-    }
-
-
-
-
+    } // The remaining lines below have no coverage because `if true` (with the constant literal
+      // `true`) is guaranteed to execute the `then` block, which is also guaranteed to `return`.
+      // Thankfully, in the normal case, conditions are not guaranteed ahead of time, and as shown
+      // in other tests, the lines below would have coverage (which would show they had `0`
+      // executions, assuming the condition still evaluated to `true`).
 
     let _ = Firework { strength: 1000 };
 
index 7116ce47f4b9dcdf28bbd8fd161509f0e74faa6a..4d9bbad3367f6ef50c9d072327ab996ec5d62cb9 100644 (file)
@@ -12,7 +12,7 @@ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
                 while true {
                 }
             }
-            write!(f, "cool")?;
+            write!(f, "error")?;
         } else {
         }
 
@@ -21,7 +21,7 @@ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
                 if false {
                     while true {}
                 }
-                write!(f, "cool")?;
+                write!(f, "error")?;
             } else {
             }
         }
@@ -38,7 +38,7 @@ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
             if false {
                 while true {}
             }
-            write!(f, "cool")?;
+            write!(f, "error")?;
         }
         for i in 0..10 {
             if false {
@@ -46,7 +46,7 @@ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
                 if false {
                     while true {}
                 }
-                write!(f, "cool")?;
+                write!(f, "error")?;
             }
         }
         Ok(())
index 0e1bef6f68d53c8da40cce74c2fbe1bd07bf2e5a..a9e99d3c10ecc6b0614e4a5b6d5dad90f0dcc358 100644 (file)
 use std::any::Any;
 use std::path::Path;
 
-pub struct NoLlvmMetadataLoader;
-
-impl MetadataLoader for NoLlvmMetadataLoader {
-    fn get_rlib_metadata(&self, _: &Target, filename: &Path) -> Result<MetadataRef, String> {
-        unreachable!("some_crate.rs shouldn't depend on any external crates");
-    }
-
-    fn get_dylib_metadata(&self, target: &Target, filename: &Path) -> Result<MetadataRef, String> {
-        unreachable!("some_crate.rs shouldn't depend on any external crates");
-    }
-}
-
 struct TheBackend;
 
 impl CodegenBackend for TheBackend {
     fn metadata_loader(&self) -> Box<MetadataLoaderDyn> {
-        Box::new(NoLlvmMetadataLoader)
+        Box::new(rustc_codegen_ssa::back::metadata::DefaultMetadataLoader)
     }
 
     fn provide(&self, providers: &mut Providers) {}
@@ -65,7 +53,7 @@ fn codegen_crate<'a, 'tcx>(
             metadata_module: None,
             metadata,
             windows_subsystem: None,
-            linker_info: LinkerInfo::new(tcx),
+            linker_info: LinkerInfo::new(tcx, "fake_target_cpu".to_string()),
             crate_info: CrateInfo::new(tcx),
         })
     }
index 8e91a8d842c6247575ec2090788f0bf86a7d35f5..791dec2ed692b3f7e52774e1a942c646d6cebccb 100644 (file)
@@ -8,7 +8,7 @@
     movl (%rdi), %eax
     inc %eax
     retq
-"# );
+"#, options(att_syntax));
 
 extern {
     fn cc_plus_one_c(arg : &u32) -> u32;
index 8da465662547a6afcb532f44a4ebcf472158571a..d014ed60eb039e737b36b93ed819e25b0b235425 100644 (file)
@@ -1,3 +1,3 @@
-goto: file://|DOC_PATH|/index.html
+goto: file://|DOC_PATH|/test_docs/index.html
 click: ".srclink"
 assert: (".line-numbers", 1)
index ed23300860b706ccf235e281913fc7bd32fdc27d..44fcec3393744dedd21752a821bda94875581b04 100644 (file)
@@ -1,4 +1,4 @@
-goto: file://|DOC_PATH|/index.html
+goto: file://|DOC_PATH|/test_docs/index.html
 assert: ("#functions")
 goto: ./struct.Foo.html
 assert: ("div.type-decl")
index 9aa72a3ad53e746ddc599b253dc31410b318071f..d64ee0261370c9bc327c8c315c8e5df25858f7fb 100644 (file)
@@ -1,4 +1,4 @@
-goto: file://|DOC_PATH|/index.html
+goto: file://|DOC_PATH|/test_docs/index.html
 goto: ./fn.check_list_code_block.html
 // If the codeblock is the first element of the docblock, the information tooltip must have
 // have some top margin to avoid going over the toggle (the "[+]").
index 69fc860244b7b113f24bb9f6031dbbf579a7ef5f..7e7003d4340a3ef281913cdea9563417219b54ca 100644 (file)
@@ -1,4 +1,4 @@
-goto: file://|DOC_PATH|/index.html
+goto: file://|DOC_PATH|/test_docs/index.html
 click: ".srclink"
 click: "#sidebar-toggle"
 wait-for: 500
index d736d15d184a3f0a12a4906412c36ad9cd277b88..1248d11200e6c5f27b51e7a17342f08da84613ad 100644 (file)
@@ -1,5 +1,5 @@
 // This test ensures that the element corresponding to the hash is displayed.
-goto: file://|DOC_PATH|/struct.Foo.html#method.borrow
+goto: file://|DOC_PATH|/test_docs/struct.Foo.html#method.borrow
 // In the blanket implementations list, "Borrow" is the second one, hence the ":nth(2)".
 assert: ("#blanket-implementations-list > details:nth-child(2)", "open", "")
 // Please note the "\" below is needed because otherwise ".borrow" would be interpreted as
index 686d98f9736e48e328cb8d24295d249fe76fd936..3f1e7ec4a789c17db69cd05b2a84b6cfa6f5e6da 100644 (file)
@@ -1,3 +1,3 @@
 // This test ensures that the impl blocks are open by default.
-goto: file://|DOC_PATH|/struct.Foo.html
+goto: file://|DOC_PATH|/test_docs/struct.Foo.html
 assert: ("#main > details.implementors-toggle", "open", "")
diff --git a/src/test/rustdoc-gui/lib.rs b/src/test/rustdoc-gui/lib.rs
deleted file mode 100644 (file)
index eeba3e3..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-//! The point of this crate is to be able to have enough different "kinds" of
-//! documentation generated so we can test each different features.
-
-#![crate_name = "test_docs"]
-
-use std::fmt;
-
-/// Basic function with some code examples:
-///
-/// ```
-/// println!("nothing fancy");
-/// ```
-///
-/// A failing to compile one:
-///
-/// ```compile_fail
-/// println!("where did my argument {} go? :'(");
-/// ```
-///
-/// An ignored one:
-///
-/// ```ignore (it's a test)
-/// Let's say I'm just some text will ya?
-/// ```
-pub fn foo() {}
-
-/// Just a normal struct.
-pub struct Foo;
-
-impl Foo {
-    #[must_use]
-    pub fn must_use(&self) -> bool {
-        true
-    }
-}
-
-/// Just a normal enum.
-pub enum WhoLetTheDogOut {
-    /// Woof!
-    Woof,
-    /// Meoooooooow...
-    Meow,
-}
-
-/// Who doesn't love to wrap a `format!` call?
-pub fn some_more_function<T: fmt::Debug>(t: &T) -> String {
-    format!("{:?}", t)
-}
-
-/// Woohoo! A trait!
-pub trait AnotherOne {
-    /// Some func 3.
-    fn func3();
-
-    /// Some func 1.
-    fn func1();
-
-    fn another();
-    fn why_not();
-
-    /// Some func 2.
-    fn func2();
-
-    fn hello();
-}
-
-/// ```compile_fail
-/// whatever
-/// ```
-///
-/// Check for "i" signs in lists!
-///
-/// 1. elem 1
-/// 2. test 1
-///    ```compile_fail
-///    fn foo() {}
-///    ```
-/// 3. elem 3
-/// 4. ```ignore (it's a test)
-///    fn foo() {}
-///    ```
-/// 5. elem 5
-///
-/// Final one:
-///
-/// ```ignore (still a test)
-/// let x = 12;
-/// ```
-pub fn check_list_code_block() {}
-
-pub enum AnEnum {
-    WithVariants { and: usize, sub: usize, variants: usize },
-}
index 6f2465a5587f2a6674a82e9aebeb2ec8a3fa26e7..7d3490e9d9410b4ab9eae0bdbd49c4a357010b34 100644 (file)
@@ -1,3 +1,3 @@
-goto: file://|DOC_PATH|/index.html
+goto: file://|DOC_PATH|/test_docs/index.html
 goto: ./fn.check_list_code_block.html
 assert: ("pre.rust.fn")
index 3eec3459a6393dc22ecd69c8355cde5a335b3771..5c95db70aecdd46a25f2926967a0d9a5e58dbf10 100644 (file)
@@ -1,6 +1,6 @@
 // Test to ensure that you can click on the search input, whatever the width.
 // The PR which fixed it is: https://github.com/rust-lang/rust/pull/81592
-goto: file://|DOC_PATH|/index.html
+goto: file://|DOC_PATH|/test_docs/index.html
 size: (463, 700)
 // We first check that the search input isn't already focused.
 assert-false: ("input.search-input:focus")
index a4df102d245bea25f768454b83105258af2664ff..c828c72e910d592e104e7a1c4b408dbde90f4114 100644 (file)
@@ -1,11 +1,11 @@
-goto: file://|DOC_PATH|/index.html
+goto: file://|DOC_PATH|/test_docs/index.html
 write: (".search-input", "Foo")
 // Waiting for the search results to appear...
 wait-for: "#titles"
 assert: ("#titles > button:nth-of-type(1)", "class", "selected")
 
 // To go back to the original "state"
-goto: file://|DOC_PATH|/index.html
+goto: file://|DOC_PATH|/test_docs/index.html
 write: (".search-input", "-> String")
 // Waiting for the search results to appear...
 wait-for: "#titles"
@@ -13,7 +13,7 @@ wait-for: "#titles"
 assert: ("#titles > button:nth-of-type(3)", "class", "selected")
 
 // To go back to the original "state"
-goto: file://|DOC_PATH|/index.html
+goto: file://|DOC_PATH|/test_docs/index.html
 write: (".search-input", "-> Something")
 // Waiting for the search results to appear...
 wait-for: "#titles"
index c35b48f57f4d23b3f2cb04bbd536515d1fa10011..884c38d85fbdba6bf6a6f829332d2cfbd039d386 100644 (file)
@@ -1,5 +1,5 @@
 // Check that the various shortcuts are working.
-goto: file://|DOC_PATH|/index.html
+goto: file://|DOC_PATH|/test_docs/index.html
 // We first check that the search input isn't already focused.
 assert-false: "input.search-input:focus"
 press-key: "s"
index f11c41e8bd552eb870377696b5abe25b5669ebaa..ff33a541a1801642dd1164f84d2623e58c16a611 100644 (file)
@@ -1,11 +1,11 @@
-goto: file://|DOC_PATH|/../src/test_docs/lib.rs.html
+goto: file://|DOC_PATH|/src/test_docs/lib.rs.html
 // Check that we can click on the line number.
 click: (40, 224) // This is the position of the span for line 4.
 // Unfortunately, "#4" isn't a valid query selector, so we have to go around that limitation
 // by instead getting the nth span.
 assert: (".line-numbers > span:nth-child(4)", "class", "line-highlighted")
 // We now check that the good spans are highlighted
-goto: file://|DOC_PATH|/../src/test_docs/lib.rs.html#4-6
+goto: file://|DOC_PATH|/src/test_docs/lib.rs.html#4-6
 assert-false: (".line-numbers > span:nth-child(3)", "class", "line-highlighted")
 assert: (".line-numbers > span:nth-child(4)", "class", "line-highlighted")
 assert: (".line-numbers > span:nth-child(5)", "class", "line-highlighted")
diff --git a/src/test/rustdoc-gui/src/lib.rs b/src/test/rustdoc-gui/src/lib.rs
new file mode 100644 (file)
index 0000000..eeba3e3
--- /dev/null
@@ -0,0 +1,93 @@
+//! The point of this crate is to be able to have enough different "kinds" of
+//! documentation generated so we can test each different features.
+
+#![crate_name = "test_docs"]
+
+use std::fmt;
+
+/// Basic function with some code examples:
+///
+/// ```
+/// println!("nothing fancy");
+/// ```
+///
+/// A failing to compile one:
+///
+/// ```compile_fail
+/// println!("where did my argument {} go? :'(");
+/// ```
+///
+/// An ignored one:
+///
+/// ```ignore (it's a test)
+/// Let's say I'm just some text will ya?
+/// ```
+pub fn foo() {}
+
+/// Just a normal struct.
+pub struct Foo;
+
+impl Foo {
+    #[must_use]
+    pub fn must_use(&self) -> bool {
+        true
+    }
+}
+
+/// Just a normal enum.
+pub enum WhoLetTheDogOut {
+    /// Woof!
+    Woof,
+    /// Meoooooooow...
+    Meow,
+}
+
+/// Who doesn't love to wrap a `format!` call?
+pub fn some_more_function<T: fmt::Debug>(t: &T) -> String {
+    format!("{:?}", t)
+}
+
+/// Woohoo! A trait!
+pub trait AnotherOne {
+    /// Some func 3.
+    fn func3();
+
+    /// Some func 1.
+    fn func1();
+
+    fn another();
+    fn why_not();
+
+    /// Some func 2.
+    fn func2();
+
+    fn hello();
+}
+
+/// ```compile_fail
+/// whatever
+/// ```
+///
+/// Check for "i" signs in lists!
+///
+/// 1. elem 1
+/// 2. test 1
+///    ```compile_fail
+///    fn foo() {}
+///    ```
+/// 3. elem 3
+/// 4. ```ignore (it's a test)
+///    fn foo() {}
+///    ```
+/// 5. elem 5
+///
+/// Final one:
+///
+/// ```ignore (still a test)
+/// let x = 12;
+/// ```
+pub fn check_list_code_block() {}
+
+pub enum AnEnum {
+    WithVariants { and: usize, sub: usize, variants: usize },
+}
index 5bd65f61f49050fa302935a8b96af317662b2b65..bc9063edd1e7a460b3d0d6d615395e0627457b41 100644 (file)
@@ -1,4 +1,4 @@
-goto: file://|DOC_PATH|/index.html
+goto: file://|DOC_PATH|/test_docs/index.html
 click: "#theme-picker"
 click: "#theme-choices > button:first-child"
 wait-for: 500
diff --git a/src/test/rustdoc-gui/toggle-docs-mobile.goml b/src/test/rustdoc-gui/toggle-docs-mobile.goml
new file mode 100644 (file)
index 0000000..fcdfc03
--- /dev/null
@@ -0,0 +1,21 @@
+goto: file://|DOC_PATH|/test_docs/struct.Foo.html
+size: (433, 600)
+assert: (".top-doc", "open", "")
+click: (4, 280) // This is the position of the top doc comment toggle
+assert-false: (".top-doc", "open", "")
+click: (4, 280)
+assert: (".top-doc", "open", "")
+// To ensure that the toggle isn't over the text, we check that the toggle isn't clicked.
+click: (3, 280)
+assert: (".top-doc", "open", "")
+
+// Now we do the same but with a little bigger width
+size: (600, 600)
+assert: (".top-doc", "open", "")
+click: (4, 240) // New Y position since all search elements are back on one line.
+assert-false: (".top-doc", "open", "")
+click: (4, 240)
+assert: (".top-doc", "open", "")
+// To ensure that the toggle isn't over the text, we check that the toggle isn't clicked.
+click: (3, 240)
+assert: (".top-doc", "open", "")
index 1ded33f659d3c6fb1e5de86eddc5f48cb0e11115..062bc7d51e54263993f9cda0068d24c200b93f38 100644 (file)
@@ -1,7 +1,10 @@
-goto: file://|DOC_PATH|/index.html
+goto: file://|DOC_PATH|/test_docs/index.html
+assert: ("#main > details.top-doc", "open", "")
 click: "#toggle-all-docs"
-wait-for: 5000
-assert: ("#main > div.docblock.hidden-by-usual-hider")
+wait-for: 1000
+// This is now collapsed so there shouldn't be the "open" attribute on details.
+assert-false: ("#main > details.top-doc", "open", "")
 click: "#toggle-all-docs"
-wait-for: 5000
-assert: ("#main > div.docblock.hidden-by-usual-hider", 0)
+wait-for: 1000
+// Not collapsed anymore so the "open" attribute should be back.
+assert: ("#main > details.top-doc", "open", "")
index 914486e1c281d52bdf5f39b89047ab55196383b6..2e9f85336ecd8f4960a3098501d74318db23f2c6 100644 (file)
@@ -1,4 +1,4 @@
-goto: file://|DOC_PATH|/trait.AnotherOne.html
+goto: file://|DOC_PATH|/test_docs/trait.AnotherOne.html
 assert: (".sidebar-links a:nth-of-type(1)", "another")
 assert: (".sidebar-links a:nth-of-type(2)", "func1")
 assert: (".sidebar-links a:nth-of-type(3)", "func2")
index 135c432e05342a788179ce610e1b0c0746d17961..af83b9b1955464de3f8b76362203680f8c44ec24 100644 (file)
@@ -96,7 +96,7 @@ LL | f!("Foo\nbar [BarF] bar\nbaz");
                 ^^^^
    = note: no item named `BarF` in scope
    = help: to escape `[` and `]` characters, add '\' before them like `\[` or `\]`
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `f` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: unresolved link to `error`
   --> $DIR/warning.rs:58:30
diff --git a/src/test/rustdoc/type-layout-flag-required.rs b/src/test/rustdoc/type-layout-flag-required.rs
new file mode 100644 (file)
index 0000000..a01fbd2
--- /dev/null
@@ -0,0 +1,4 @@
+// Tests that `--show-type-layout` is required in order to show layout info.
+
+// @!has type_layout_flag_required/struct.Foo.html 'Size: '
+pub struct Foo(usize);
diff --git a/src/test/rustdoc/type-layout.rs b/src/test/rustdoc/type-layout.rs
new file mode 100644 (file)
index 0000000..272911d
--- /dev/null
@@ -0,0 +1,54 @@
+// compile-flags: --show-type-layout -Z unstable-options
+
+// @has type_layout/struct.Foo.html 'Size: '
+// @has - ' bytes'
+pub struct Foo {
+    pub a: usize,
+    b: Vec<String>,
+}
+
+// @has type_layout/enum.Bar.html 'Size: '
+// @has - ' bytes'
+pub enum Bar<'a> {
+    A(String),
+    B(&'a str, (std::collections::HashMap<String, usize>, Foo)),
+}
+
+// @has type_layout/union.Baz.html 'Size: '
+// @has - ' bytes'
+pub union Baz {
+    a: &'static str,
+    b: usize,
+    c: &'static [u8],
+}
+
+// @has type_layout/struct.X.html 'Size: '
+// @has - ' bytes'
+pub struct X(usize);
+
+// @has type_layout/struct.Y.html 'Size: '
+// @has - '1 byte'
+// @!has - ' bytes'
+pub struct Y(u8);
+
+// @has type_layout/struct.Z.html 'Size: '
+// @has - '0 bytes'
+pub struct Z;
+
+// We can't compute layout for generic types.
+// @has type_layout/struct.Generic.html 'Unable to compute type layout, possibly due to this type having generic parameters'
+// @!has - 'Size: '
+pub struct Generic<T>(T);
+
+// We *can*, however, compute layout for types that are only generic over lifetimes,
+// because lifetimes are a type-system construct.
+// @has type_layout/struct.GenericLifetimes.html 'Size: '
+// @has - ' bytes'
+pub struct GenericLifetimes<'a>(&'a str);
+
+// @has type_layout/struct.Unsized.html 'Size: '
+// @has - '(unsized)'
+pub struct Unsized([u8]);
+
+// @!has type_layout/trait.MyTrait.html 'Size: '
+pub trait MyTrait {}
index 3c30e0402d96dc86e39661240de7a6b4b4b2f876..212f63f709ec551b489ba74502b19631ae48abf9 100644 (file)
@@ -42,7 +42,7 @@ LL | #[derive(HashStable)]
    |
    = note: see issue #27812 <https://github.com/rust-lang/rust/issues/27812> for more information
    = help: add `#![feature(rustc_private)]` to the crate attributes to enable
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `HashStable` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 5 previous errors
 
index fe920dba3978e610d977b69e35035f51d12cad0c..66f37f1a3432a488d80cf3183476564d7d3dd902 100644 (file)
@@ -21,7 +21,7 @@ LL | custom_lint_pass_macro!();
    | -------------------------- in this macro invocation
    |
    = help: try using `declare_lint_pass!` or `impl_lint_pass!` instead
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `custom_lint_pass_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index c1be151f1c1ce5d28f2a41e10d6e00e5f34140f2..c6c3765b80df0474a5a5db9f649a75d93853b7e7 100644 (file)
@@ -62,7 +62,7 @@ LL | #[message = "This is missing a closing brace: {name"]
    | ^ expected `'}'` in format string
    |
    = note: if you intended to print `{`, you can escape it using `{{`
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `SessionDiagnostic` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: invalid format string: unmatched `}` found
   --> $DIR/session-derive-errors.rs:119:1
@@ -71,7 +71,7 @@ LL | #[message = "This is missing an opening brace: name}"]
    | ^ unmatched `}` in format string
    |
    = note: if you intended to print `}`, you can escape it using `}}`
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `SessionDiagnostic` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: The `#[label = ...]` attribute can only be applied to fields of type Span
   --> $DIR/session-derive-errors.rs:138:5
index c0ea8ff47e85b1e8143d1570a15d250b67c21939..0851e1a5e9cf7b739f59a6973cc372463b796c6d 100644 (file)
@@ -5,7 +5,7 @@ LL | static A: usize = 0;
    | ^^^^^^^^^^^^^^^^^^^^ the trait `GlobalAlloc` is not implemented for `usize`
    |
    = note: required by `std::alloc::GlobalAlloc::alloc`
-   = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the attribute macro `global_allocator` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied
   --> $DIR/not-an-allocator.rs:2:1
@@ -14,7 +14,7 @@ LL | static A: usize = 0;
    | ^^^^^^^^^^^^^^^^^^^^ the trait `GlobalAlloc` is not implemented for `usize`
    |
    = note: required by `std::alloc::GlobalAlloc::dealloc`
-   = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the attribute macro `global_allocator` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied
   --> $DIR/not-an-allocator.rs:2:1
@@ -23,7 +23,7 @@ LL | static A: usize = 0;
    | ^^^^^^^^^^^^^^^^^^^^ the trait `GlobalAlloc` is not implemented for `usize`
    |
    = note: required by `std::alloc::GlobalAlloc::realloc`
-   = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the attribute macro `global_allocator` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0277]: the trait bound `usize: GlobalAlloc` is not satisfied
   --> $DIR/not-an-allocator.rs:2:1
@@ -32,7 +32,7 @@ LL | static A: usize = 0;
    | ^^^^^^^^^^^^^^^^^^^^ the trait `GlobalAlloc` is not implemented for `usize`
    |
    = note: required by `std::alloc::GlobalAlloc::alloc_zeroed`
-   = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the attribute macro `global_allocator` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 4 previous errors
 
index 1b46825c5425cf0b0e8c4fdc8e19a860740cc6bc..dbf1054f1068cfb394b5c27255b2a6eee88d905d 100644 (file)
@@ -7,7 +7,7 @@ LL | #[global_allocator]
 LL | static B: System = System;
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot define a new global allocator
    |
-   = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the attribute macro `global_allocator` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 763b5fe5cca8b0a6e3d6c19414b2698e8741075f..3eeb76f3d00358e6a630cc13c09fa8ed768ea45d 100644 (file)
@@ -8,12 +8,19 @@
 macro_rules! asm {
     () => {};
 }
+#[rustc_builtin_macro]
+macro_rules! global_asm {
+    () => {};
+}
 #[lang = "sized"]
 trait Sized {}
 
 fn main() {
     unsafe {
         asm!("");
-        //~^ ERROR asm! is unsupported on this target
+        //~^ ERROR inline assembly is unsupported on this target
     }
 }
+
+global_asm!("");
+//~^ ERROR inline assembly is unsupported on this target
index cb876f28650aaa7600feff0542033e9b4b94d87e..6094643b038c211d9ce4ae0c61b13b7ae59472d1 100644 (file)
@@ -1,8 +1,16 @@
-error[E0472]: asm! is unsupported on this target
-  --> $DIR/bad-arch.rs:16:9
+error[E0472]: inline assembly is unsupported on this target
+  --> $DIR/bad-arch.rs:20:9
    |
 LL |         asm!("");
    |         ^^^^^^^^^
 
-error: aborting due to previous error
+error[E0472]: inline assembly is unsupported on this target
+  --> $DIR/bad-arch.rs:25:1
+   |
+LL | global_asm!("");
+   | ^^^^^^^^^^^^^^^^
+   |
+   = note: this error originates in the macro `global_asm` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 2 previous errors
 
index 755fc2ca238aa8e7feebfcf0023006764e3ffb2c..923d65bfd96ed8c02c8011fc2bf6d0ff89c992db 100644 (file)
@@ -1,6 +1,6 @@
 // only-x86_64
 
-#![feature(asm)]
+#![feature(asm, global_asm)]
 
 fn main() {
     let mut foo = 0;
@@ -16,3 +16,16 @@ fn main() {
         //~^ ERROR asm outputs are not allowed with the `noreturn` option
     }
 }
+
+global_asm!("", options(nomem));
+//~^ ERROR expected one of
+global_asm!("", options(readonly));
+//~^ ERROR expected one of
+global_asm!("", options(noreturn));
+//~^ ERROR expected one of
+global_asm!("", options(pure));
+//~^ ERROR expected one of
+global_asm!("", options(nostack));
+//~^ ERROR expected one of
+global_asm!("", options(preserves_flags));
+//~^ ERROR expected one of
index c5e8e2ccf44ccf7ab31e139dcb25a359c206129c..4e27a6e2cb5958b77b5e662af07efc95a7e9cf96 100644 (file)
@@ -28,5 +28,41 @@ error: asm outputs are not allowed with the `noreturn` option
 LL |         asm!("{}", out(reg) foo, options(noreturn));
    |                    ^^^^^^^^^^^^
 
-error: aborting due to 5 previous errors
+error: expected one of `)` or `att_syntax`, found `nomem`
+  --> $DIR/bad-options.rs:20:25
+   |
+LL | global_asm!("", options(nomem));
+   |                         ^^^^^ expected one of `)` or `att_syntax`
+
+error: expected one of `)` or `att_syntax`, found `readonly`
+  --> $DIR/bad-options.rs:22:25
+   |
+LL | global_asm!("", options(readonly));
+   |                         ^^^^^^^^ expected one of `)` or `att_syntax`
+
+error: expected one of `)` or `att_syntax`, found `noreturn`
+  --> $DIR/bad-options.rs:24:25
+   |
+LL | global_asm!("", options(noreturn));
+   |                         ^^^^^^^^ expected one of `)` or `att_syntax`
+
+error: expected one of `)` or `att_syntax`, found `pure`
+  --> $DIR/bad-options.rs:26:25
+   |
+LL | global_asm!("", options(pure));
+   |                         ^^^^ expected one of `)` or `att_syntax`
+
+error: expected one of `)` or `att_syntax`, found `nostack`
+  --> $DIR/bad-options.rs:28:25
+   |
+LL | global_asm!("", options(nostack));
+   |                         ^^^^^^^ expected one of `)` or `att_syntax`
+
+error: expected one of `)` or `att_syntax`, found `preserves_flags`
+  --> $DIR/bad-options.rs:30:25
+   |
+LL | global_asm!("", options(preserves_flags));
+   |                         ^^^^^^^^^^^^^^^ expected one of `)` or `att_syntax`
+
+error: aborting due to 11 previous errors
 
index 21ce8c6236d062afbf5cf42c0a12f16c704b4355..4404be4fa3a68020c1d24ed8131630009d4057d0 100644 (file)
@@ -1,6 +1,6 @@
 // only-x86_64
 
-#![feature(asm)]
+#![feature(asm, global_asm)]
 
 fn main() {
     let mut foo = 0;
@@ -26,3 +26,22 @@ fn main() {
         //~^ ERROR multiple unused asm arguments
     }
 }
+
+const FOO: i32 = 1;
+global_asm!("{}");
+//~^ ERROR invalid reference to argument at index 0
+global_asm!("{1}", const FOO);
+//~^ ERROR invalid reference to argument at index 1
+//~^^ ERROR argument never used
+global_asm!("{a}");
+//~^ ERROR there is no argument named `a`
+global_asm!("{}", a = const FOO);
+//~^ ERROR invalid reference to argument at index 0
+//~^^ ERROR argument never used
+global_asm!("{1}", a = const FOO);
+//~^ ERROR invalid reference to argument at index 1
+//~^^ ERROR named argument never used
+global_asm!("{:foo}", const FOO);
+//~^ ERROR asm template modifier must be a single character
+global_asm!("", const FOO, const FOO);
+//~^ ERROR multiple unused asm arguments
index 1aea7467ed0a761d0abde005ee059de567d5ae2d..d95663d2a734a0d920e47955d8671658d469b5c7 100644 (file)
@@ -98,5 +98,90 @@ LL |         asm!("", in(reg) 0, in(reg) 1);
    |
    = help: if these arguments are intentionally unused, consider using them in an asm comment: `"/* {0} {1} */"`
 
-error: aborting due to 11 previous errors
+error: invalid reference to argument at index 0
+  --> $DIR/bad-template.rs:31:14
+   |
+LL | global_asm!("{}");
+   |              ^^ from here
+   |
+   = note: no arguments were given
+
+error: invalid reference to argument at index 1
+  --> $DIR/bad-template.rs:33:14
+   |
+LL | global_asm!("{1}", const FOO);
+   |              ^^^ from here
+   |
+   = note: there is 1 argument
+
+error: argument never used
+  --> $DIR/bad-template.rs:33:20
+   |
+LL | global_asm!("{1}", const FOO);
+   |                    ^^^^^^^^^ argument never used
+   |
+   = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {0} */"`
+
+error: there is no argument named `a`
+  --> $DIR/bad-template.rs:36:14
+   |
+LL | global_asm!("{a}");
+   |              ^^^
+
+error: invalid reference to argument at index 0
+  --> $DIR/bad-template.rs:38:14
+   |
+LL | global_asm!("{}", a = const FOO);
+   |              ^^   ------------- named argument
+   |              |
+   |              from here
+   |
+   = note: no positional arguments were given
+note: named arguments cannot be referenced by position
+  --> $DIR/bad-template.rs:38:19
+   |
+LL | global_asm!("{}", a = const FOO);
+   |                   ^^^^^^^^^^^^^
+
+error: named argument never used
+  --> $DIR/bad-template.rs:38:19
+   |
+LL | global_asm!("{}", a = const FOO);
+   |                   ^^^^^^^^^^^^^ named argument never used
+   |
+   = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
+
+error: invalid reference to argument at index 1
+  --> $DIR/bad-template.rs:41:14
+   |
+LL | global_asm!("{1}", a = const FOO);
+   |              ^^^ from here
+   |
+   = note: no positional arguments were given
+
+error: named argument never used
+  --> $DIR/bad-template.rs:41:20
+   |
+LL | global_asm!("{1}", a = const FOO);
+   |                    ^^^^^^^^^^^^^ named argument never used
+   |
+   = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
+
+error: asm template modifier must be a single character
+  --> $DIR/bad-template.rs:44:16
+   |
+LL | global_asm!("{:foo}", const FOO);
+   |                ^^^
+
+error: multiple unused asm arguments
+  --> $DIR/bad-template.rs:46:17
+   |
+LL | global_asm!("", const FOO, const FOO);
+   |                 ^^^^^^^^^  ^^^^^^^^^ argument never used
+   |                 |
+   |                 argument never used
+   |
+   = help: if these arguments are intentionally unused, consider using them in an asm comment: `"/* {0} {1} */"`
+
+error: aborting due to 21 previous errors
 
index 0f6a7cd44749e033e90c0804facc1ec2884b7b68..fd940173c424c53f195e8bf06d1a78c23e215c4c 100644 (file)
@@ -2,7 +2,7 @@
 // only-x86_64
 // run-pass
 
-#![feature(asm)]
+#![feature(asm, global_asm)]
 
 fn const_generic<const X: usize>() -> usize {
     unsafe {
@@ -34,3 +34,7 @@ fn main() {
     let d = const_generic::<5>();
     assert_eq!(d, 5);
 }
+
+global_asm!("mov eax, {}", const 5);
+global_asm!("mov eax, {}", const constfn(5));
+global_asm!("mov eax, {}", const constfn(5) + constfn(5));
index f4672a50fd0f44838eb3ae48a08f75ec5316ec27..d4444e9c6ccd8ee3098f22628cdf004e668af1af 100644 (file)
@@ -1,7 +1,7 @@
 // only-x86_64
 // run-rustfix
 
-#![feature(asm)]
+#![feature(asm, global_asm)]
 
 fn main() {
     unsafe {
@@ -24,3 +24,6 @@ fn main() {
         );
     }
 }
+
+global_asm!("", options(att_syntax, ));
+//~^ ERROR the `att_syntax` option was already provided
index 80292d7521a9a4f7f812495003241d8bbb34d32a..fd28311984bf18a25254e8c5a2eb5ab32f46ecd5 100644 (file)
@@ -1,7 +1,7 @@
 // only-x86_64
 // run-rustfix
 
-#![feature(asm)]
+#![feature(asm, global_asm)]
 
 fn main() {
     unsafe {
@@ -24,3 +24,6 @@ fn main() {
         );
     }
 }
+
+global_asm!("", options(att_syntax, att_syntax));
+//~^ ERROR the `att_syntax` option was already provided
index cd8d743e031a5e7046ce7b4987a245a6c21ae150..53edf8fb91cf6df19cc48fb8b864b8e5aead7a89 100644 (file)
@@ -52,5 +52,11 @@ error: the `noreturn` option was already provided
 LL |             options(noreturn),
    |                     ^^^^^^^^ this option was already provided
 
-error: aborting due to 9 previous errors
+error: the `att_syntax` option was already provided
+  --> $DIR/duplicate-options.rs:28:37
+   |
+LL | global_asm!("", options(att_syntax, att_syntax));
+   |                                     ^^^^^^^^^^ this option was already provided
+
+error: aborting due to 10 previous errors
 
index bcae1d565f136790d0c004776b9542c3d2bf5356..b1685bd4e027a7600815ff3fbff8623bf6f3b05f 100644 (file)
@@ -1,5 +1,19 @@
 error: unknown directive
-  --> $DIR/inline-syntax.rs:25:15
+.intel_syntax noprefix
+^
+error: unknown directive
+.intel_syntax noprefix
+^
+error: unknown directive
+   |
+note: instantiated into assembly here
+  --> <inline asm>:1:1
+   |
+LL | .intel_syntax noprefix
+   | ^
+
+error: unknown directive
+  --> $DIR/inline-syntax.rs:29:15
    |
 LL |         asm!(".intel_syntax noprefix", "nop");
    |               ^
@@ -11,7 +25,7 @@ LL |     .intel_syntax noprefix
    |     ^
 
 error: unknown directive
-  --> $DIR/inline-syntax.rs:28:15
+  --> $DIR/inline-syntax.rs:32:15
    |
 LL |         asm!(".intel_syntax aaa noprefix", "nop");
    |               ^
@@ -23,7 +37,7 @@ LL |     .intel_syntax aaa noprefix
    |     ^
 
 error: unknown directive
-  --> $DIR/inline-syntax.rs:31:15
+  --> $DIR/inline-syntax.rs:35:15
    |
 LL |         asm!(".att_syntax noprefix", "nop");
    |               ^
@@ -35,7 +49,7 @@ LL |     .att_syntax noprefix
    |     ^
 
 error: unknown directive
-  --> $DIR/inline-syntax.rs:34:15
+  --> $DIR/inline-syntax.rs:38:15
    |
 LL |         asm!(".att_syntax bbb noprefix", "nop");
    |               ^
@@ -47,7 +61,7 @@ LL |     .att_syntax bbb noprefix
    |     ^
 
 error: unknown directive
-  --> $DIR/inline-syntax.rs:37:15
+  --> $DIR/inline-syntax.rs:41:15
    |
 LL |         asm!(".intel_syntax noprefix; nop");
    |               ^
@@ -59,7 +73,7 @@ LL |     .intel_syntax noprefix; nop
    |     ^
 
 error: unknown directive
-  --> $DIR/inline-syntax.rs:43:13
+  --> $DIR/inline-syntax.rs:47:13
    |
 LL |             .intel_syntax noprefix
    |             ^
@@ -70,5 +84,5 @@ note: instantiated into assembly here
 LL |             .intel_syntax noprefix
    |             ^
 
-error: aborting due to 6 previous errors
+error: aborting due to 7 previous errors
 
index 13ded19cfea915e5c6181315e932df4126017c1b..2d54ef7bd6b401e46e4bd593d12cf5c0a97c0579 100644 (file)
 macro_rules! asm {
     () => {};
 }
+#[rustc_builtin_macro]
+macro_rules! global_asm {
+    () => {};
+}
 
 #[lang = "sized"]
 trait Sized {}
@@ -47,3 +51,7 @@ pub fn main() {
         //[arm]~^^^^ ERROR unknown directive
     }
 }
+
+global_asm!(".intel_syntax noprefix", "nop");
+//[x86_64]~^ WARN avoid using `.intel_syntax`
+// Assembler errors don't have line numbers, so no error on ARM
index 02b29b09013ddc5186fd27ca062b82954ae5ae3e..59c95194322aaf2a5bbb4c2aa24ff448a780155b 100644 (file)
@@ -1,40 +1,46 @@
 warning: avoid using `.intel_syntax`, Intel syntax is the default
-  --> $DIR/inline-syntax.rs:25:15
+  --> $DIR/inline-syntax.rs:55:14
    |
-LL |         asm!(".intel_syntax noprefix", "nop");
-   |               ^^^^^^^^^^^^^^^^^^^^^^
+LL | global_asm!(".intel_syntax noprefix", "nop");
+   |              ^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(bad_asm_style)]` on by default
 
 warning: avoid using `.intel_syntax`, Intel syntax is the default
-  --> $DIR/inline-syntax.rs:28:15
+  --> $DIR/inline-syntax.rs:29:15
+   |
+LL |         asm!(".intel_syntax noprefix", "nop");
+   |               ^^^^^^^^^^^^^^^^^^^^^^
+
+warning: avoid using `.intel_syntax`, Intel syntax is the default
+  --> $DIR/inline-syntax.rs:32:15
    |
 LL |         asm!(".intel_syntax aaa noprefix", "nop");
    |               ^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: avoid using `.att_syntax`, prefer using `options(att_syntax)` instead
-  --> $DIR/inline-syntax.rs:31:15
+  --> $DIR/inline-syntax.rs:35:15
    |
 LL |         asm!(".att_syntax noprefix", "nop");
    |               ^^^^^^^^^^^^^^^^^^^^
 
 warning: avoid using `.att_syntax`, prefer using `options(att_syntax)` instead
-  --> $DIR/inline-syntax.rs:34:15
+  --> $DIR/inline-syntax.rs:38:15
    |
 LL |         asm!(".att_syntax bbb noprefix", "nop");
    |               ^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: avoid using `.intel_syntax`, Intel syntax is the default
-  --> $DIR/inline-syntax.rs:37:15
+  --> $DIR/inline-syntax.rs:41:15
    |
 LL |         asm!(".intel_syntax noprefix; nop");
    |               ^^^^^^^^^^^^^^^^^^^^^^
 
 warning: avoid using `.intel_syntax`, Intel syntax is the default
-  --> $DIR/inline-syntax.rs:43:13
+  --> $DIR/inline-syntax.rs:47:13
    |
 LL |             .intel_syntax noprefix
    |             ^^^^^^^^^^^^^^^^^^^^^^
 
-warning: 6 warnings emitted
+warning: 7 warnings emitted
 
index 6ffe8d97b05c117b1fe9fd7d6d1e3cc33f67632f..5de8d20547e3e3035970f59a49124b48182f9049 100644 (file)
@@ -9,7 +9,7 @@ LL | |        pure nomem readonly preserves_flags
 LL | |        noreturn nostack att_syntax options);
    | |____________________________________________- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: the `pure` and `noreturn` options are mutually exclusive
   --> $DIR/interpolated-idents.rs:13:13
@@ -22,7 +22,7 @@ LL | |        pure nomem readonly preserves_flags
 LL | |        noreturn nostack att_syntax options);
    | |____________________________________________- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: asm outputs are not allowed with the `noreturn` option
   --> $DIR/interpolated-idents.rs:10:32
@@ -45,7 +45,7 @@ LL | |        noreturn nostack att_syntax options);
    | |____________________________________________in this macro invocation
    |                                              in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 3 previous errors
 
index 076289427b54f49fb5bfc41e06d0cbea1bba3ea9..9a82da8d90d3c1179eb48d6a244204e2fb31613d 100644 (file)
@@ -233,7 +233,7 @@ LL |     llvm_asm!("");
    = 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 #32408 <https://github.com/rust-lang/rust/issues/32408>
    = help: use the new asm! syntax specified in RFC 2873
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `llvm_asm` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: naked functions must contain a single asm block
   --> $DIR/naked-functions.rs:108:1
index f2e9d9ca08b2469d646ef6ffa6a39eb0ebd53298..e62e6668415bd55abb64d35f6e46fbccfbfdebe2 100644 (file)
@@ -1,6 +1,6 @@
 // only-x86_64
 
-#![feature(asm)]
+#![feature(asm, global_asm)]
 
 fn main() {
     let mut foo = 0;
@@ -63,3 +63,37 @@ fn main() {
         //~^ ERROR asm template must be a string literal
     }
 }
+
+const FOO: i32 = 1;
+const BAR: i32 = 2;
+global_asm!();
+//~^ ERROR requires at least a template string argument
+global_asm!(FOO);
+//~^ ERROR asm template must be a string literal
+global_asm!("{}" FOO);
+//~^ ERROR expected token: `,`
+global_asm!("{}", FOO);
+//~^ ERROR expected operand, options, or additional template string
+global_asm!("{}", const);
+//~^ ERROR expected expression, found end of macro arguments
+global_asm!("{}", const(reg) FOO);
+//~^ ERROR expected one of
+global_asm!("", options(FOO));
+//~^ ERROR expected one of
+global_asm!("", options(nomem FOO));
+//~^ ERROR expected one of
+global_asm!("", options(nomem, FOO));
+//~^ ERROR expected one of
+global_asm!("{}", options(), const FOO);
+//~^ ERROR arguments are not allowed after options
+global_asm!("{a}", a = const FOO, a = const BAR);
+//~^ ERROR duplicate argument named `a`
+//~^^ ERROR argument never used
+global_asm!("", options(), "");
+//~^ ERROR expected one of
+global_asm!("{}", const FOO, "{}", const FOO);
+//~^ ERROR expected one of
+global_asm!(format!("{{{}}}", 0), const FOO);
+//~^ ERROR asm template must be a string literal
+global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR);
+//~^ ERROR asm template must be a string literal
index 4ab9d86948de951ffed1e284e9103e515012626b..afd262b851c0993c567346c22a68fb28e2022747 100644 (file)
@@ -154,7 +154,7 @@ error: asm template must be a string literal
 LL |         asm!(format!("{{{}}}", 0), in(reg) foo);
    |              ^^^^^^^^^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: asm template must be a string literal
   --> $DIR/parse-error.rs:62:21
@@ -162,7 +162,113 @@ error: asm template must be a string literal
 LL |         asm!("{1}", format!("{{{}}}", 0), in(reg) foo, out(reg) bar);
    |                     ^^^^^^^^^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: requires at least a template string argument
+  --> $DIR/parse-error.rs:69:1
+   |
+LL | global_asm!();
+   | ^^^^^^^^^^^^^^
+
+error: asm template must be a string literal
+  --> $DIR/parse-error.rs:71:13
+   |
+LL | global_asm!(FOO);
+   |             ^^^
+
+error: expected token: `,`
+  --> $DIR/parse-error.rs:73:18
+   |
+LL | global_asm!("{}" FOO);
+   |                  ^^^ expected `,`
+
+error: expected operand, options, or additional template string
+  --> $DIR/parse-error.rs:75:19
+   |
+LL | global_asm!("{}", FOO);
+   |                   ^^^ expected operand, options, or additional template string
+
+error: expected expression, found end of macro arguments
+  --> $DIR/parse-error.rs:77:24
+   |
+LL | global_asm!("{}", const);
+   |                        ^ expected expression
+
+error: expected one of `,`, `.`, `?`, or an operator, found `FOO`
+  --> $DIR/parse-error.rs:79:30
+   |
+LL | global_asm!("{}", const(reg) FOO);
+   |                              ^^^ expected one of `,`, `.`, `?`, or an operator
+
+error: expected one of `)` or `att_syntax`, found `FOO`
+  --> $DIR/parse-error.rs:81:25
+   |
+LL | global_asm!("", options(FOO));
+   |                         ^^^ expected one of `)` or `att_syntax`
+
+error: expected one of `)` or `att_syntax`, found `nomem`
+  --> $DIR/parse-error.rs:83:25
+   |
+LL | global_asm!("", options(nomem FOO));
+   |                         ^^^^^ expected one of `)` or `att_syntax`
+
+error: expected one of `)` or `att_syntax`, found `nomem`
+  --> $DIR/parse-error.rs:85:25
+   |
+LL | global_asm!("", options(nomem, FOO));
+   |                         ^^^^^ expected one of `)` or `att_syntax`
+
+error: arguments are not allowed after options
+  --> $DIR/parse-error.rs:87:30
+   |
+LL | global_asm!("{}", options(), const FOO);
+   |                   ---------  ^^^^^^^^^ argument
+   |                   |
+   |                   previous options
+
+error: duplicate argument named `a`
+  --> $DIR/parse-error.rs:89:35
+   |
+LL | global_asm!("{a}", a = const FOO, a = const BAR);
+   |                    -------------  ^^^^^^^^^^^^^ duplicate argument
+   |                    |
+   |                    previously here
+
+error: argument never used
+  --> $DIR/parse-error.rs:89:35
+   |
+LL | global_asm!("{a}", a = const FOO, a = const BAR);
+   |                                   ^^^^^^^^^^^^^ argument never used
+   |
+   = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {1} */"`
+
+error: expected one of `const` or `options`, found `""`
+  --> $DIR/parse-error.rs:92:28
+   |
+LL | global_asm!("", options(), "");
+   |                            ^^ expected one of `const` or `options`
+
+error: expected one of `const` or `options`, found `"{}"`
+  --> $DIR/parse-error.rs:94:30
+   |
+LL | global_asm!("{}", const FOO, "{}", const FOO);
+   |                              ^^^^ expected one of `const` or `options`
+
+error: asm template must be a string literal
+  --> $DIR/parse-error.rs:96:13
+   |
+LL | global_asm!(format!("{{{}}}", 0), const FOO);
+   |             ^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: asm template must be a string literal
+  --> $DIR/parse-error.rs:98:20
+   |
+LL | global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR);
+   |                    ^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0435]: attempt to use a non-constant value in a constant
   --> $DIR/parse-error.rs:37:37
@@ -218,6 +324,6 @@ LL |     let mut bar = 0;
 LL |         asm!("{1}", in("eax") foo, const bar);
    |                                          ^^^ non-constant value
 
-error: aborting due to 31 previous errors
+error: aborting due to 47 previous errors
 
 For more information about this error, try `rustc --explain E0435`.
index 0677167ccfe7356310cd760bcf85988b53d4198e..060a88fc937136491ac867585f7b4dc40e7557be 100644 (file)
@@ -1,6 +1,6 @@
 // only-x86_64
 
-#![feature(asm, repr_simd, never_type)]
+#![feature(asm, global_asm, repr_simd, never_type)]
 
 #[repr(simd)]
 struct SimdNonCopy(f32, f32, f32, f32);
@@ -90,3 +90,11 @@ fn main() {
         asm!("{}", in(reg) u);
     }
 }
+
+// Const operands must be integer or floats, and must be constants.
+
+global_asm!("{}", const 0);
+global_asm!("{}", const 0i32);
+global_asm!("{}", const 0f32);
+global_asm!("{}", const 0 as *mut u8);
+//~^ ERROR asm `const` arguments must be integer or floating-point values
index 830ca7b55509dd1caa2203e1ba57b58f96350f5e..f61f690bdb4dddb5cd693b6951f88d6235f74bd2 100644 (file)
@@ -27,7 +27,7 @@ LL |         asm!("{}", in(reg) vec![0]);
    |                            ^^^^^^^
    |
    = note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: cannot use value of type `(i32, i32, i32)` for inline assembly
   --> $DIR/type-check-2.rs:70:28
@@ -61,6 +61,12 @@ LL |         asm!("{}", inout(reg) r);
    |
    = note: only integers, floats, SIMD vectors, pointers and function pointers can be used as arguments for inline assembly
 
+error: asm `const` arguments must be integer or floating-point values
+  --> $DIR/type-check-2.rs:99:19
+   |
+LL | global_asm!("{}", const 0 as *mut u8);
+   |                   ^^^^^^^^^^^^^^^^^^
+
 error: asm `sym` operand must point to a fn or static
   --> $DIR/type-check-2.rs:47:24
    |
@@ -103,7 +109,7 @@ LL |         let v: Vec<u64> = vec![0, 1, 2];
 LL |         asm!("{}", inout(reg) v[0]);
    |                               ^ cannot borrow as mutable
 
-error: aborting due to 14 previous errors
+error: aborting due to 15 previous errors
 
 Some errors have detailed explanations: E0381, E0596.
 For more information about an error, try `rustc --explain E0381`.
index 6890baead8119b341c61fea5e418d9afa860f3f1..c2c1885ff166f45136a3eb891cbe2d7171387fea 100644 (file)
@@ -1,7 +1,7 @@
 // only-x86_64
 // compile-flags: -C target-feature=+avx512f
 
-#![feature(asm)]
+#![feature(asm, global_asm)]
 
 use std::arch::x86_64::{_mm256_setzero_ps, _mm_setzero_ps};
 
@@ -69,3 +69,21 @@ fn main() {
         asm!("{:r}", inout(reg) main => val_u64);
     }
 }
+
+// Constants must be... constant
+
+static S: i32 = 1;
+const fn const_foo(x: i32) -> i32 {
+    x
+}
+const fn const_bar<T>(x: T) -> T {
+    x
+}
+global_asm!("{}", const S);
+//~^ ERROR constants cannot refer to statics
+global_asm!("{}", const const_foo(0));
+global_asm!("{}", const const_foo(S));
+//~^ ERROR constants cannot refer to statics
+global_asm!("{}", const const_bar(0));
+global_asm!("{}", const const_bar(S));
+//~^ ERROR constants cannot refer to statics
index 42497456ac31ccd4641d908c6c97865cca7a9b4c..9f6989ca03d1b666965db31970e35d6f073ebffb 100644 (file)
@@ -114,5 +114,30 @@ LL |         asm!("{:r}", inout(reg) main => val_u32);
    |
    = note: asm inout arguments must have the same type, unless they are both pointers or integers of the same size
 
-error: aborting due to 9 previous errors; 4 warnings emitted
+error[E0013]: constants cannot refer to statics
+  --> $DIR/type-check-3.rs:82:25
+   |
+LL | global_asm!("{}", const S);
+   |                         ^
+   |
+   = help: consider extracting the value of the `static` to a `const`, and referring to that
+
+error[E0013]: constants cannot refer to statics
+  --> $DIR/type-check-3.rs:85:35
+   |
+LL | global_asm!("{}", const const_foo(S));
+   |                                   ^
+   |
+   = help: consider extracting the value of the `static` to a `const`, and referring to that
+
+error[E0013]: constants cannot refer to statics
+  --> $DIR/type-check-3.rs:88:35
+   |
+LL | global_asm!("{}", const const_bar(S));
+   |                                   ^
+   |
+   = help: consider extracting the value of the `static` to a `const`, and referring to that
+
+error: aborting due to 12 previous errors; 4 warnings emitted
 
+For more information about this error, try `rustc --explain E0013`.
index d034a50299d500a96cff36afa57d07fdc2cded8b..984a8713c991ad0441d855ab99037df21f0c1e32 100644 (file)
@@ -24,7 +24,7 @@ LL |     assert_eq!(<() as Tr>::B, 0);    // causes the error above
    |
    = 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 <https://github.com/rust-lang/rust/issues/71800>
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 3 previous errors
 
diff --git a/src/test/ui/async-await/async-unsafe-fn-call-in-safe.mir.stderr b/src/test/ui/async-await/async-unsafe-fn-call-in-safe.mir.stderr
new file mode 100644 (file)
index 0000000..d22413b
--- /dev/null
@@ -0,0 +1,35 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/async-unsafe-fn-call-in-safe.rs:14:5
+   |
+LL |     S::f();
+   |     ^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/async-unsafe-fn-call-in-safe.rs:15:5
+   |
+LL |     f();
+   |     ^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/async-unsafe-fn-call-in-safe.rs:19:5
+   |
+LL |     S::f();
+   |     ^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/async-unsafe-fn-call-in-safe.rs:20:5
+   |
+LL |     f();
+   |     ^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0133`.
index ccc1b8553f07144c9af97dbe32db522130964579..2ed343b4a07fcbece8420c9a4509f1635cf0af30 100644 (file)
@@ -1,4 +1,6 @@
 // edition:2018
+// revisions: mir thir
+// [thir]compile-flags: -Z thir-unsafeck
 
 struct S;
 
diff --git a/src/test/ui/async-await/async-unsafe-fn-call-in-safe.stderr b/src/test/ui/async-await/async-unsafe-fn-call-in-safe.stderr
deleted file mode 100644 (file)
index c95fe17..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/async-unsafe-fn-call-in-safe.rs:12:5
-   |
-LL |     S::f();
-   |     ^^^^^^ call to unsafe function
-   |
-   = note: consult the function's documentation for information on how to avoid undefined behavior
-
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/async-unsafe-fn-call-in-safe.rs:13:5
-   |
-LL |     f();
-   |     ^^^ call to unsafe function
-   |
-   = note: consult the function's documentation for information on how to avoid undefined behavior
-
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/async-unsafe-fn-call-in-safe.rs:17:5
-   |
-LL |     S::f();
-   |     ^^^^^^ call to unsafe function
-   |
-   = note: consult the function's documentation for information on how to avoid undefined behavior
-
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/async-unsafe-fn-call-in-safe.rs:18:5
-   |
-LL |     f();
-   |     ^^^ call to unsafe function
-   |
-   = note: consult the function's documentation for information on how to avoid undefined behavior
-
-error: aborting due to 4 previous errors
-
-For more information about this error, try `rustc --explain E0133`.
diff --git a/src/test/ui/async-await/async-unsafe-fn-call-in-safe.thir.stderr b/src/test/ui/async-await/async-unsafe-fn-call-in-safe.thir.stderr
new file mode 100644 (file)
index 0000000..d22413b
--- /dev/null
@@ -0,0 +1,35 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/async-unsafe-fn-call-in-safe.rs:14:5
+   |
+LL |     S::f();
+   |     ^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/async-unsafe-fn-call-in-safe.rs:15:5
+   |
+LL |     f();
+   |     ^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/async-unsafe-fn-call-in-safe.rs:19:5
+   |
+LL |     S::f();
+   |     ^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/async-unsafe-fn-call-in-safe.rs:20:5
+   |
+LL |     f();
+   |     ^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0133`.
index 75d769c4e154565d3d4177d7f54fb69e9e5a26e5..495c5f6bf2cb1d114e85afb25a926fa6e86f8e1c 100644 (file)
@@ -11,7 +11,7 @@ LL |                 b!();
    |                 ----- in this macro invocation
    |
    = note: labels are unreachable through functions, closures, async blocks and modules
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `b` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index ce3fa9180cb9e97c103910b50f97d6b2222aaeca..1dbf5db6c32ed9bdae77c7c18787f270c9d003db 100644 (file)
@@ -3,7 +3,7 @@
 // edition:2018
 
 async fn copy() -> Result<()>
-//~^ ERROR this enum takes 2 type arguments but only 1 type argument was supplied
+//~^ ERROR this enum takes 2 generic arguments
 {
     Ok(())
     //~^ ERROR type annotations needed
index bcb4c292e2626f0284378f81c132f170f6af8625..51fc34c48186c5ebf7f4fcfb396331baaa806aac 100644 (file)
@@ -1,17 +1,17 @@
-error[E0107]: this enum takes 2 type arguments but only 1 type argument was supplied
+error[E0107]: this enum takes 2 generic arguments but 1 generic argument was supplied
   --> $DIR/issue-65159.rs:5:20
    |
 LL | async fn copy() -> Result<()>
-   |                    ^^^^^^ -- supplied 1 type argument
+   |                    ^^^^^^ -- supplied 1 generic argument
    |                    |
-   |                    expected 2 type arguments
+   |                    expected 2 generic arguments
    |
-note: enum defined here, with 2 type parameters: `T`, `E`
+note: enum defined here, with 2 generic parameters: `T`, `E`
   --> $SRC_DIR/core/src/result.rs:LL:COL
    |
 LL | pub enum Result<T, E> {
    |          ^^^^^^ -  -
-help: add missing type argument
+help: add missing generic argument
    |
 LL | async fn copy() -> Result<(), E>
    |                             ^^^
index 4b14b88a74f2b74b048cbe53c18362b838dceb74..31e93ef54f26034ffdf2a558bbcc403c47fd4177 100644 (file)
@@ -13,7 +13,7 @@ LL |         bug!("bug" + stringify!(found));
 LL | bug!();
    | ------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `bug` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: unexpected token: `{
     let res =
@@ -33,7 +33,7 @@ LL |         doc_comment! {format!("{coor}", coor = stringify!($t1)).as_str()}
 LL | some_macro!(u8);
    | ---------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `some_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 3 previous errors
 
index 75663a666a56de765f5ba2ef5c159d476f767be3..4124f8cea8ebfe0a588114e5f446cfdb2596f387 100644 (file)
@@ -7,7 +7,7 @@ LL |         #[repr(align($n))]
 LL | pass_nonterminal!(n!());
    | ------------------------ in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `pass_nonterminal` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 2c6d572752796c6d79c2f0d596018c1e07d015a3..fa967ccb9d096167c49afb3e6ad6cf2a27759e9f 100644 (file)
@@ -7,7 +7,7 @@ LL |     assert_eq!(foo, y);
    |     for<'r> fn(&'r i32) -> &'r i32 {foo}
    |     _
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0277]: `for<'r> fn(&'r i32) -> &'r i32 {foo}` doesn't implement `Debug`
   --> $DIR/issue-77910-1.rs:8:5
@@ -21,7 +21,7 @@ LL |     T: fmt::Debug + ?Sized,
    |        ---------- required by this bound in `core::panicking::assert_failed`
    |
    = help: the trait `Debug` is not implemented for `for<'r> fn(&'r i32) -> &'r i32 {foo}`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index bdb073cdcbcc913928fcc75067cc224577e754a9..a6af129bf39f1191315b1ec0e6206fbda31fa7ac 100644 (file)
@@ -9,7 +9,7 @@ LL |     x.x[0];
    |     ------ borrow later used here
    |
    = note: consider using a `let` binding to create a longer lived value
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 9d66ba3aae142f7e3b9dc6eb9155c6b76fe4cfe8..da3412f112d7a9e4f064966d13fca062920bf222 100644 (file)
@@ -11,7 +11,7 @@ LL |         r.get_size(width!(self))
    |           |
    |           borrow later used by call
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `width` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index fba801983cf4e21296c8fa6a00f29eeca2e6e13d..bd8270ef958cb00c7c7ec92742841d0094bd1723 100644 (file)
@@ -10,7 +10,7 @@ error[E0015]: calls in statics are limited to constant functions, tuple structs
 LL | static settings_dir: String = format!("");
    |                               ^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::__export::format_args` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0015]: calls in statics are limited to constant functions, tuple structs and tuple variants
   --> $DIR/issue-64453.rs:4:31
@@ -18,7 +18,7 @@ error[E0015]: calls in statics are limited to constant functions, tuple structs
 LL | static settings_dir: String = format!("");
    |                               ^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 3 previous errors
 
index 2e6b88a4beba8ccbcf4ecb5ce7f4f1fadecf549b..569769b8213bff69417fc07200b2a9ff175ac535 100644 (file)
@@ -15,7 +15,7 @@ fn buy(&mut self) -> &mut usize {
 
 async fn buy_lock(generator: &Mutex<MarketMultiplier>) -> LockedMarket<'_> {
     //~^ ERROR this struct takes 0 lifetime arguments but 1 lifetime argument was supplied
-    //~^^ ERROR this struct takes 1 type argument but 0 type arguments were supplied
+    //~^^ ERROR this struct takes 1 generic argument but 0 generic arguments were supplied
     LockedMarket(generator.lock().unwrap().buy())
     //~^ ERROR cannot return value referencing temporary value
 }
index b6844f50488e106f7a37415619fa4d489455cc7c..0d506a0956d21abbc50e2360995d6e5e737ab0c6 100644 (file)
@@ -12,18 +12,18 @@ note: struct defined here, with 0 lifetime parameters
 LL | struct LockedMarket<T>(T);
    |        ^^^^^^^^^^^^
 
-error[E0107]: this struct takes 1 type argument but 0 type arguments were supplied
+error[E0107]: this struct takes 1 generic argument but 0 generic arguments were supplied
   --> $DIR/issue-82126-mismatched-subst-and-hir.rs:16:59
    |
 LL | async fn buy_lock(generator: &Mutex<MarketMultiplier>) -> LockedMarket<'_> {
-   |                                                           ^^^^^^^^^^^^ expected 1 type argument
+   |                                                           ^^^^^^^^^^^^ expected 1 generic argument
    |
-note: struct defined here, with 1 type parameter: `T`
+note: struct defined here, with 1 generic parameter: `T`
   --> $DIR/issue-82126-mismatched-subst-and-hir.rs:23:8
    |
 LL | struct LockedMarket<T>(T);
    |        ^^^^^^^^^^^^ -
-help: add missing type argument
+help: add missing generic argument
    |
 LL | async fn buy_lock(generator: &Mutex<MarketMultiplier>) -> LockedMarket<'_, T> {
    |                                                                          ^^^
index 58a90b2fca2ca9b4b94044c0c56d32b7d1e2db72..7821dc02bde3c45528ca1a993d00e4890cd85607 100644 (file)
@@ -12,7 +12,7 @@ LL |         let a = $c;
 LL | sss!();
    | ------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `aaa` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index ebf43bdb2717cc2a34f691171ecbb6975c7b9b0b..a3177903162aa70394d929157a6d8c3351ecf845 100644 (file)
@@ -5,7 +5,7 @@ LL |     println!("{:?}", t);
    |                      ^ `impl Sized` cannot be formatted using `{:?}` because it doesn't implement `Debug`
    |
    = note: required by `std::fmt::Debug::fmt`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
 help: consider further restricting this bound
    |
 LL | fn test_impl(t: impl Sized + std::fmt::Debug) {
@@ -18,7 +18,7 @@ LL |     println!("{:?}", t);
    |                      ^ `T` cannot be formatted using `{:?}` because it doesn't implement `Debug`
    |
    = note: required by `std::fmt::Debug::fmt`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
 help: consider restricting type parameter `T`
    |
 LL | fn test_no_bounds<T: std::fmt::Debug>(t: T) {
@@ -31,7 +31,7 @@ LL |     println!("{:?}", t);
    |                      ^ `T` cannot be formatted using `{:?}` because it doesn't implement `Debug`
    |
    = note: required by `std::fmt::Debug::fmt`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
 help: consider further restricting this bound
    |
 LL | fn test_one_bound<T: Sized + std::fmt::Debug>(t: T) {
@@ -44,7 +44,7 @@ LL |     println!("{:?} {:?}", x, y);
    |                              ^ `Y` cannot be formatted using `{:?}` because it doesn't implement `Debug`
    |
    = note: required by `std::fmt::Debug::fmt`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
 help: consider further restricting type parameter `Y`
    |
 LL | fn test_no_bounds_where<X, Y>(x: X, y: Y) where X: std::fmt::Debug, Y: std::fmt::Debug {
@@ -57,7 +57,7 @@ LL |     println!("{:?}", x);
    |                      ^ `X` cannot be formatted using `{:?}` because it doesn't implement `Debug`
    |
    = note: required by `std::fmt::Debug::fmt`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
 help: consider further restricting this bound
    |
 LL | fn test_one_bound_where<X>(x: X) where X: Sized + std::fmt::Debug {
@@ -70,7 +70,7 @@ LL |     println!("{:?}", x);
    |                      ^ `X` cannot be formatted using `{:?}` because it doesn't implement `Debug`
    |
    = note: required by `std::fmt::Debug::fmt`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
 help: consider further restricting type parameter `X`
    |
 LL | fn test_many_bounds_where<X>(x: X) where X: Sized, X: Sized, X: std::fmt::Debug {
diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.fixed b/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.fixed
new file mode 100644 (file)
index 0000000..93e6cf0
--- /dev/null
@@ -0,0 +1,67 @@
+// run-rustfix
+#![deny(disjoint_capture_migration)]
+
+use std::thread;
+
+/* Test Send Trait Migration */
+struct SendPointer (*mut i32);
+unsafe impl Send for SendPointer {}
+
+fn test_send_trait() {
+    let mut f = 10;
+    let fptr = SendPointer(&mut f as *mut i32);
+    thread::spawn(move || { let _ = &fptr; unsafe {
+        //~^ ERROR: `Send` trait implementation affected for closure because of `capture_disjoint_fields`
+        //~| HELP: add a dummy let to cause `fptr` to be fully captured
+        *fptr.0 = 20;
+    } });
+}
+
+/* Test Sync Trait Migration */
+struct CustomInt (*mut i32);
+struct SyncPointer (CustomInt);
+unsafe impl Sync for SyncPointer {}
+unsafe impl Send for CustomInt {}
+
+fn test_sync_trait() {
+    let mut f = 10;
+    let f = CustomInt(&mut f as *mut i32);
+    let fptr = SyncPointer(f);
+    thread::spawn(move || { let _ = &fptr; unsafe {
+        //~^ ERROR: `Sync`, `Send` trait implementation affected for closure because of `capture_disjoint_fields`
+        //~| HELP: add a dummy let to cause `fptr` to be fully captured
+        *fptr.0.0 = 20;
+    } });
+}
+
+/* Test Clone Trait Migration */
+struct S(String);
+struct T(i32);
+
+struct U(S,T);
+
+impl Clone for U {
+    fn clone(&self) -> Self {
+        U(S(String::from("Hello World")), T(0))
+    }
+}
+
+fn test_clone_trait() {
+    let f = U(S(String::from("Hello World")), T(0));
+    let c = || { let _ = &f; 
+        //~^ ERROR: `Clone` trait implementation, and drop order affected for closure because of `capture_disjoint_fields`
+        //~| HELP: add a dummy let to cause `f` to be fully captured
+        let f_1 = f.1;
+        println!("{:?}", f_1.0);
+    };
+
+    let c_clone = c.clone();
+
+    c_clone();
+}
+
+fn main() {
+    test_send_trait();
+    test_sync_trait();
+    test_clone_trait();
+}
diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.rs b/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.rs
new file mode 100644 (file)
index 0000000..2c0dbd0
--- /dev/null
@@ -0,0 +1,67 @@
+// run-rustfix
+#![deny(disjoint_capture_migration)]
+
+use std::thread;
+
+/* Test Send Trait Migration */
+struct SendPointer (*mut i32);
+unsafe impl Send for SendPointer {}
+
+fn test_send_trait() {
+    let mut f = 10;
+    let fptr = SendPointer(&mut f as *mut i32);
+    thread::spawn(move || unsafe {
+        //~^ ERROR: `Send` trait implementation affected for closure because of `capture_disjoint_fields`
+        //~| HELP: add a dummy let to cause `fptr` to be fully captured
+        *fptr.0 = 20;
+    });
+}
+
+/* Test Sync Trait Migration */
+struct CustomInt (*mut i32);
+struct SyncPointer (CustomInt);
+unsafe impl Sync for SyncPointer {}
+unsafe impl Send for CustomInt {}
+
+fn test_sync_trait() {
+    let mut f = 10;
+    let f = CustomInt(&mut f as *mut i32);
+    let fptr = SyncPointer(f);
+    thread::spawn(move || unsafe {
+        //~^ ERROR: `Sync`, `Send` trait implementation affected for closure because of `capture_disjoint_fields`
+        //~| HELP: add a dummy let to cause `fptr` to be fully captured
+        *fptr.0.0 = 20;
+    });
+}
+
+/* Test Clone Trait Migration */
+struct S(String);
+struct T(i32);
+
+struct U(S,T);
+
+impl Clone for U {
+    fn clone(&self) -> Self {
+        U(S(String::from("Hello World")), T(0))
+    }
+}
+
+fn test_clone_trait() {
+    let f = U(S(String::from("Hello World")), T(0));
+    let c = || {
+        //~^ ERROR: `Clone` trait implementation, and drop order affected for closure because of `capture_disjoint_fields`
+        //~| HELP: add a dummy let to cause `f` to be fully captured
+        let f_1 = f.1;
+        println!("{:?}", f_1.0);
+    };
+
+    let c_clone = c.clone();
+
+    c_clone();
+}
+
+fn main() {
+    test_send_trait();
+    test_sync_trait();
+    test_clone_trait();
+}
diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.stderr
new file mode 100644 (file)
index 0000000..6e3723b
--- /dev/null
@@ -0,0 +1,69 @@
+error: `Send` trait implementation affected for closure because of `capture_disjoint_fields`
+  --> $DIR/auto_traits.rs:13:19
+   |
+LL |       thread::spawn(move || unsafe {
+   |  ___________________^
+LL | |
+LL | |
+LL | |         *fptr.0 = 20;
+LL | |     });
+   | |_____^
+   |
+note: the lint level is defined here
+  --> $DIR/auto_traits.rs:2:9
+   |
+LL | #![deny(disjoint_capture_migration)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^
+help: add a dummy let to cause `fptr` to be fully captured
+   |
+LL |     thread::spawn(move || { let _ = &fptr; unsafe {
+LL |
+LL |
+LL |         *fptr.0 = 20;
+LL |     } });
+   |
+
+error: `Sync`, `Send` trait implementation affected for closure because of `capture_disjoint_fields`
+  --> $DIR/auto_traits.rs:30:19
+   |
+LL |       thread::spawn(move || unsafe {
+   |  ___________________^
+LL | |
+LL | |
+LL | |         *fptr.0.0 = 20;
+LL | |     });
+   | |_____^
+   |
+help: add a dummy let to cause `fptr` to be fully captured
+   |
+LL |     thread::spawn(move || { let _ = &fptr; unsafe {
+LL |
+LL |
+LL |         *fptr.0.0 = 20;
+LL |     } });
+   |
+
+error: `Clone` trait implementation, and drop order affected for closure because of `capture_disjoint_fields`
+  --> $DIR/auto_traits.rs:51:13
+   |
+LL |       let c = || {
+   |  _____________^
+LL | |
+LL | |
+LL | |         let f_1 = f.1;
+LL | |         println!("{:?}", f_1.0);
+LL | |     };
+   | |_____^
+   |
+help: add a dummy let to cause `f` to be fully captured
+   |
+LL |     let c = || { let _ = &f; 
+LL |
+LL |
+LL |         let f_1 = f.1;
+LL |         println!("{:?}", f_1.0);
+LL |     };
+   |
+
+error: aborting due to 3 previous errors
+
index 300f67e8b1e811db3e101a203eabf51a517132e3..3770e93239a8efde54d3a754109eee92b0667d20 100644 (file)
@@ -1,6 +1,6 @@
 // run-rustfix
 
-#![deny(disjoint_capture_drop_reorder)]
+#![deny(disjoint_capture_migration)]
 //~^ NOTE: the lint level is defined here
 
 // Test cases for types that implement a insignificant drop (stlib defined)
index a17c70d3e287780e0355a17c072cc11ff708f5c3..2015ab7e9b8cb5b5bb52a2243960b2d84034dfcc 100644 (file)
@@ -1,6 +1,6 @@
 // run-rustfix
 
-#![deny(disjoint_capture_drop_reorder)]
+#![deny(disjoint_capture_migration)]
 //~^ NOTE: the lint level is defined here
 
 // Test cases for types that implement a insignificant drop (stlib defined)
index 69c12d2bb56c0f914eba16073767067714c9e0d0..69a99f7a53a53a30ff483a6b1d06a405cb1b20fd 100644 (file)
@@ -14,8 +14,8 @@ LL | |     };
 note: the lint level is defined here
   --> $DIR/insignificant_drop.rs:3:9
    |
-LL | #![deny(disjoint_capture_drop_reorder)]
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | #![deny(disjoint_capture_migration)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^
 help: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
    |
 LL |     let c = || { let _ = (&t, &t1, &t2); 
diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.fixed b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.fixed
new file mode 100644 (file)
index 0000000..e89cc2c
--- /dev/null
@@ -0,0 +1,67 @@
+// run-rustfix
+
+#![deny(disjoint_capture_migration)]
+//~^ NOTE: the lint level is defined here
+
+#![feature(rustc_attrs)]
+#![allow(unused)]
+
+struct InsignificantDropPoint {
+    x: i32,
+    y: i32,
+}
+
+impl Drop for InsignificantDropPoint {
+    #[rustc_insignificant_dtor]
+    fn drop(&mut self) {}
+}
+
+struct SigDrop;
+
+impl Drop for SigDrop {
+    fn drop(&mut self) {}
+}
+
+struct GenericStruct<T>(T, T);
+
+struct Wrapper<T>(GenericStruct<T>, i32);
+
+impl<T> Drop for GenericStruct<T> {
+    #[rustc_insignificant_dtor]
+    fn drop(&mut self) {}
+}
+
+// `SigDrop` implements drop and therefore needs to be migrated.
+fn significant_drop_needs_migration() {
+    let t = (SigDrop {}, SigDrop {});
+
+    let c = || { let _ = &t; 
+    //~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
+    //~| HELP: add a dummy let to cause `t` to be fully captured
+        let _t = t.0;
+    };
+
+    c();
+}
+
+// Even if a type implements an insignificant drop, if it's
+// elements have a significant drop then the overall type is
+// consdered to have an significant drop. Since the elements
+// of `GenericStruct` implement drop, migration is required.
+fn generic_struct_with_significant_drop_needs_migration() {
+    let t = Wrapper(GenericStruct(SigDrop {}, SigDrop {}), 5);
+
+    // move is used to force i32 to be copied instead of being a ref
+    let c = move || { let _ = &t; 
+    //~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
+    //~| HELP: add a dummy let to cause `t` to be fully captured
+        let _t = t.1;
+    };
+
+    c();
+}
+
+fn main() {
+    significant_drop_needs_migration();
+    generic_struct_with_significant_drop_needs_migration();
+}
diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.rs b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.rs
new file mode 100644 (file)
index 0000000..e16cd9d
--- /dev/null
@@ -0,0 +1,67 @@
+// run-rustfix
+
+#![deny(disjoint_capture_migration)]
+//~^ NOTE: the lint level is defined here
+
+#![feature(rustc_attrs)]
+#![allow(unused)]
+
+struct InsignificantDropPoint {
+    x: i32,
+    y: i32,
+}
+
+impl Drop for InsignificantDropPoint {
+    #[rustc_insignificant_dtor]
+    fn drop(&mut self) {}
+}
+
+struct SigDrop;
+
+impl Drop for SigDrop {
+    fn drop(&mut self) {}
+}
+
+struct GenericStruct<T>(T, T);
+
+struct Wrapper<T>(GenericStruct<T>, i32);
+
+impl<T> Drop for GenericStruct<T> {
+    #[rustc_insignificant_dtor]
+    fn drop(&mut self) {}
+}
+
+// `SigDrop` implements drop and therefore needs to be migrated.
+fn significant_drop_needs_migration() {
+    let t = (SigDrop {}, SigDrop {});
+
+    let c = || {
+    //~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
+    //~| HELP: add a dummy let to cause `t` to be fully captured
+        let _t = t.0;
+    };
+
+    c();
+}
+
+// Even if a type implements an insignificant drop, if it's
+// elements have a significant drop then the overall type is
+// consdered to have an significant drop. Since the elements
+// of `GenericStruct` implement drop, migration is required.
+fn generic_struct_with_significant_drop_needs_migration() {
+    let t = Wrapper(GenericStruct(SigDrop {}, SigDrop {}), 5);
+
+    // move is used to force i32 to be copied instead of being a ref
+    let c = move || {
+    //~^ ERROR: drop order affected for closure because of `capture_disjoint_fields`
+    //~| HELP: add a dummy let to cause `t` to be fully captured
+        let _t = t.1;
+    };
+
+    c();
+}
+
+fn main() {
+    significant_drop_needs_migration();
+    generic_struct_with_significant_drop_needs_migration();
+}
diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_migrations.stderr
new file mode 100644 (file)
index 0000000..2b14165
--- /dev/null
@@ -0,0 +1,47 @@
+error: drop order affected for closure because of `capture_disjoint_fields`
+  --> $DIR/insignificant_drop_attr_migrations.rs:38:13
+   |
+LL |       let c = || {
+   |  _____________^
+LL | |
+LL | |
+LL | |         let _t = t.0;
+LL | |     };
+   | |_____^
+   |
+note: the lint level is defined here
+  --> $DIR/insignificant_drop_attr_migrations.rs:3:9
+   |
+LL | #![deny(disjoint_capture_migration)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^
+help: add a dummy let to cause `t` to be fully captured
+   |
+LL |     let c = || { let _ = &t; 
+LL |
+LL |
+LL |         let _t = t.0;
+LL |     };
+   |
+
+error: drop order affected for closure because of `capture_disjoint_fields`
+  --> $DIR/insignificant_drop_attr_migrations.rs:55:13
+   |
+LL |       let c = move || {
+   |  _____________^
+LL | |
+LL | |
+LL | |         let _t = t.1;
+LL | |     };
+   | |_____^
+   |
+help: add a dummy let to cause `t` to be fully captured
+   |
+LL |     let c = move || { let _ = &t; 
+LL |
+LL |
+LL |         let _t = t.1;
+LL |     };
+   |
+
+error: aborting due to 2 previous errors
+
diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_no_migrations.rs b/src/test/ui/closures/2229_closure_analysis/migrations/insignificant_drop_attr_no_migrations.rs
new file mode 100644 (file)
index 0000000..a003774
--- /dev/null
@@ -0,0 +1,45 @@
+// run-pass
+
+#![deny(disjoint_capture_migration)]
+#![feature(rustc_attrs)]
+#![allow(unused)]
+
+struct InsignificantDropPoint {
+    x: i32,
+    y: i32,
+}
+
+impl Drop for InsignificantDropPoint {
+    #[rustc_insignificant_dtor]
+    fn drop(&mut self) {}
+}
+
+struct GenericStruct<T>(T, T);
+
+// No drop reordering is required as the elements of `t` implement insignificant drop
+fn insignificant_drop_does_not_need_migration() {
+    let t = (InsignificantDropPoint { x: 4, y: 9 }, InsignificantDropPoint { x: 4, y: 9 });
+
+    let c = || {
+        let _t = t.0;
+    };
+
+    c();
+}
+
+// Generic struct whose elements don't have significant drops don't need drop reordering
+fn generic_struct_with_insignificant_drop_does_not_need_migration() {
+    let t =
+        GenericStruct(InsignificantDropPoint { x: 4, y: 9 }, InsignificantDropPoint { x: 4, y: 9 });
+
+    let c = || {
+        let _t = t.0;
+    };
+
+    c();
+}
+
+fn main() {
+    insignificant_drop_does_not_need_migration();
+    generic_struct_with_insignificant_drop_does_not_need_migration();
+}
index 3a6af00254c5a847b9c7c69d444c7823736bfa26..ee3138ea69ee8ac6bb65080b7ad5a4c2e13589fc 100644 (file)
@@ -1,6 +1,6 @@
 // run-pass
 
-#![warn(disjoint_capture_drop_reorder)]
+#![warn(disjoint_capture_migration)]
 
 fn main() {
     if let a = "" {
index a3e51a2b8e91af1c264f196dc7f19ddceb7e1c40..979c023fc53ace02c460c10ed526bda026266289 100644 (file)
@@ -1,5 +1,5 @@
 // run-rustfix
-#![deny(disjoint_capture_drop_reorder)]
+#![deny(disjoint_capture_migration)]
 //~^ NOTE: the lint level is defined here
 
 // Test the two possible cases for automated migartion using rustfix
index 0eb837b6888350413e5d74a7d3bf7680a1ccb016..c2a700bd9caa00be1e8b379d7bd29792eec315c3 100644 (file)
@@ -1,5 +1,5 @@
 // run-rustfix
-#![deny(disjoint_capture_drop_reorder)]
+#![deny(disjoint_capture_migration)]
 //~^ NOTE: the lint level is defined here
 
 // Test the two possible cases for automated migartion using rustfix
index e6173217edc2fb9b95cb4b46ddb626e4136a3773..a968d3a093b154b40b219bdb15eee8a723424128 100644 (file)
@@ -12,8 +12,8 @@ LL | |     };
 note: the lint level is defined here
   --> $DIR/migrations_rustfix.rs:2:9
    |
-LL | #![deny(disjoint_capture_drop_reorder)]
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | #![deny(disjoint_capture_migration)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^
 help: add a dummy let to cause `t` to be fully captured
    |
 LL |     let c = || { let _ = &t; 
diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.fixed b/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.fixed
new file mode 100644 (file)
index 0000000..95463a6
--- /dev/null
@@ -0,0 +1,39 @@
+// run-rustfix
+
+#![deny(disjoint_capture_migration)]
+// ignore-wasm32-bare compiled with panic=abort by default
+
+#![feature(fn_traits)]
+#![feature(never_type)]
+
+use std::panic;
+
+fn foo_diverges() -> ! { panic!() }
+
+fn assert_panics<F>(f: F) where F: FnOnce() {
+    let f = panic::AssertUnwindSafe(f);
+    let result = panic::catch_unwind(move || { let _ = &f; 
+        //~^ ERROR: `UnwindSafe`, `RefUnwindSafe` trait implementation affected for closure because of `capture_disjoint_fields`
+        //~| HELP: add a dummy let to cause `f` to be fully captured
+        f.0()
+    });
+    if let Ok(..) = result {
+        panic!("diverging function returned");
+    }
+}
+
+fn test_fn_ptr_panic<T>(mut t: T)
+    where T: Fn() -> !
+{
+    let as_fn = <T as Fn<()>>::call;
+    assert_panics(|| as_fn(&t, ()));
+    let as_fn_mut = <T as FnMut<()>>::call_mut;
+    assert_panics(|| as_fn_mut(&mut t, ()));
+    let as_fn_once = <T as FnOnce<()>>::call_once;
+    assert_panics(|| as_fn_once(t, ()));
+}
+
+fn main() {
+    test_fn_ptr_panic(foo_diverges);
+    test_fn_ptr_panic(foo_diverges as fn() -> !);
+}
diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.rs b/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.rs
new file mode 100644 (file)
index 0000000..fae7fc8
--- /dev/null
@@ -0,0 +1,39 @@
+// run-rustfix
+
+#![deny(disjoint_capture_migration)]
+// ignore-wasm32-bare compiled with panic=abort by default
+
+#![feature(fn_traits)]
+#![feature(never_type)]
+
+use std::panic;
+
+fn foo_diverges() -> ! { panic!() }
+
+fn assert_panics<F>(f: F) where F: FnOnce() {
+    let f = panic::AssertUnwindSafe(f);
+    let result = panic::catch_unwind(move || {
+        //~^ ERROR: `UnwindSafe`, `RefUnwindSafe` trait implementation affected for closure because of `capture_disjoint_fields`
+        //~| HELP: add a dummy let to cause `f` to be fully captured
+        f.0()
+    });
+    if let Ok(..) = result {
+        panic!("diverging function returned");
+    }
+}
+
+fn test_fn_ptr_panic<T>(mut t: T)
+    where T: Fn() -> !
+{
+    let as_fn = <T as Fn<()>>::call;
+    assert_panics(|| as_fn(&t, ()));
+    let as_fn_mut = <T as FnMut<()>>::call_mut;
+    assert_panics(|| as_fn_mut(&mut t, ()));
+    let as_fn_once = <T as FnOnce<()>>::call_once;
+    assert_panics(|| as_fn_once(t, ()));
+}
+
+fn main() {
+    test_fn_ptr_panic(foo_diverges);
+    test_fn_ptr_panic(foo_diverges as fn() -> !);
+}
diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr b/src/test/ui/closures/2229_closure_analysis/migrations/mir_calls_to_shims.stderr
new file mode 100644 (file)
index 0000000..bbc8eb9
--- /dev/null
@@ -0,0 +1,27 @@
+error: `UnwindSafe`, `RefUnwindSafe` trait implementation affected for closure because of `capture_disjoint_fields`
+  --> $DIR/mir_calls_to_shims.rs:15:38
+   |
+LL |       let result = panic::catch_unwind(move || {
+   |  ______________________________________^
+LL | |
+LL | |
+LL | |         f.0()
+LL | |     });
+   | |_____^
+   |
+note: the lint level is defined here
+  --> $DIR/mir_calls_to_shims.rs:3:9
+   |
+LL | #![deny(disjoint_capture_migration)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^
+help: add a dummy let to cause `f` to be fully captured
+   |
+LL |     let result = panic::catch_unwind(move || { let _ = &f; 
+LL |
+LL |
+LL |         f.0()
+LL |     });
+   |
+
+error: aborting due to previous error
+
index 73592ce04c28f9cfebdbb727369675d319db2939..420d66fba5e306015460b1fa296755f1c98b71a8 100644 (file)
@@ -2,7 +2,7 @@
 
 // Set of test cases that don't need migrations
 
-#![deny(disjoint_capture_drop_reorder)]
+#![deny(disjoint_capture_migration)]
 
 
 // Copy types as copied by the closure instead of being moved into the closure
index b739035c784223ffd5d5ba38f89b5b677deea308..5c93fce92507b8c07dcada0e834ef434559c38f8 100644 (file)
@@ -1,6 +1,6 @@
 // run-rustfix
 
-#![deny(disjoint_capture_drop_reorder)]
+#![deny(disjoint_capture_migration)]
 
 #[derive(Debug)]
 struct Foo(i32);
index e1f29c9d0e9d8cb9544bb6712fbf3e7d112709b7..fb4af00aa06166b2b9f9cd777ad70fbaec4493e4 100644 (file)
@@ -1,6 +1,6 @@
 // run-rustfix
 
-#![deny(disjoint_capture_drop_reorder)]
+#![deny(disjoint_capture_migration)]
 
 #[derive(Debug)]
 struct Foo(i32);
index 7135ded13c2563a6d104c7f6d30f643d7b3c5986..0cd191e2c98c5a3c9c40db94615b81de1d461b9f 100644 (file)
@@ -13,8 +13,8 @@ LL | |     };
 note: the lint level is defined here
   --> $DIR/precise.rs:3:9
    |
-LL | #![deny(disjoint_capture_drop_reorder)]
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | #![deny(disjoint_capture_migration)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^
 help: add a dummy let to cause `t` to be fully captured
    |
 LL |     let c = || { let _ = &t; 
index 8af48501ca2952670fe96143363d1c8ad0f3b0a5..e3a7220bf09d239fe0e0555bee613fd7946a70f8 100644 (file)
@@ -1,6 +1,6 @@
 // run-pass
 
-#![deny(disjoint_capture_drop_reorder)]
+#![deny(disjoint_capture_migration)]
 
 #[derive(Debug)]
 struct Foo(i32);
index e1b212153f431053fb8ce06ddd176a021a589bb1..1fa0fb3db2f8d9d779dcc182baf812f765d2e0a1 100644 (file)
@@ -1,5 +1,5 @@
 // run-rustfix
-#![deny(disjoint_capture_drop_reorder)]
+#![deny(disjoint_capture_migration)]
 //~^ NOTE: the lint level is defined here
 
 // Test cases for types that implement a significant drop (user defined)
index 106b2933515156249b2946595722b10504d115d8..1f0efbe1ebc43313664dcefa08c6bd755db1e3a4 100644 (file)
@@ -1,5 +1,5 @@
 // run-rustfix
-#![deny(disjoint_capture_drop_reorder)]
+#![deny(disjoint_capture_migration)]
 //~^ NOTE: the lint level is defined here
 
 // Test cases for types that implement a significant drop (user defined)
index ee29fe1306059377efa3d28209282d9fd2bb92c5..91e75ffb81a96217e392fad1e8592846962c2935 100644 (file)
@@ -14,8 +14,8 @@ LL | |     };
 note: the lint level is defined here
   --> $DIR/significant_drop.rs:2:9
    |
-LL | #![deny(disjoint_capture_drop_reorder)]
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | #![deny(disjoint_capture_migration)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^
 help: add a dummy let to cause `t`, `t1`, `t2` to be fully captured
    |
 LL |     let c = || { let _ = (&t, &t1, &t2); 
index 1d12e2f585e8d020737a59b1ca3e1680e1c20fbc..1b0e0902d67ba3fe88cf9fe345b41d64071c2015 100644 (file)
@@ -1,8 +1,6 @@
 error[E0621]: explicit lifetime required in the type of `x`
   --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:5
    |
-LL |   fn foo(x: &()) {
-   |             --- help: add explicit lifetime `'static` to the type of `x`: `&'static ()`
 LL | /     bar(|| {
 LL | |
 LL | |         let _ = x;
index f50c3e3b531590d98942c01931332dfe5e99e097..a9add6184f13eab5f969eee592ffe031b1b3ed9c 100644 (file)
@@ -1,8 +1,6 @@
 error[E0621]: explicit lifetime required in the type of `x`
   --> $DIR/closure-bounds-static-cant-capture-borrowed.rs:5:5
    |
-LL | fn foo(x: &()) {
-   |           --- help: add explicit lifetime `'static` to the type of `x`: `&'static ()`
 LL |     bar(|| {
    |     ^^^ lifetime `'static` required
 
diff --git a/src/test/ui/closures/closure_no_cap_coerce_many_unsafe_0.mir.stderr b/src/test/ui/closures/closure_no_cap_coerce_many_unsafe_0.mir.stderr
new file mode 100644 (file)
index 0000000..2f9c797
--- /dev/null
@@ -0,0 +1,19 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/closure_no_cap_coerce_many_unsafe_0.rs:15:23
+   |
+LL |     let result: i32 = foo(5, 5);
+   |                       ^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/closure_no_cap_coerce_many_unsafe_0.rs:24:23
+   |
+LL |     let result: i32 = foo(5, 5);
+   |                       ^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0133`.
index 76a0f2914103d5c304b4e70402f68664bed980f8..bdb3eb23c38f84124d67dc39d7ce40b2f2d54183 100644 (file)
@@ -1,3 +1,6 @@
+// revisions: mir thir
+// [thir]compile-flags: -Z thir-unsafeck
+
 // Ensure we get unsafe function after coercion
 unsafe fn add(a: i32, b: i32) -> i32 {
     a + b
diff --git a/src/test/ui/closures/closure_no_cap_coerce_many_unsafe_0.stderr b/src/test/ui/closures/closure_no_cap_coerce_many_unsafe_0.stderr
deleted file mode 100644 (file)
index 190b479..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/closure_no_cap_coerce_many_unsafe_0.rs:12:23
-   |
-LL |     let result: i32 = foo(5, 5);
-   |                       ^^^^^^^^^ call to unsafe function
-   |
-   = note: consult the function's documentation for information on how to avoid undefined behavior
-
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/closure_no_cap_coerce_many_unsafe_0.rs:21:23
-   |
-LL |     let result: i32 = foo(5, 5);
-   |                       ^^^^^^^^^ call to unsafe function
-   |
-   = note: consult the function's documentation for information on how to avoid undefined behavior
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0133`.
diff --git a/src/test/ui/closures/closure_no_cap_coerce_many_unsafe_0.thir.stderr b/src/test/ui/closures/closure_no_cap_coerce_many_unsafe_0.thir.stderr
new file mode 100644 (file)
index 0000000..2f9c797
--- /dev/null
@@ -0,0 +1,19 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/closure_no_cap_coerce_many_unsafe_0.rs:15:23
+   |
+LL |     let result: i32 = foo(5, 5);
+   |                       ^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/closure_no_cap_coerce_many_unsafe_0.rs:24:23
+   |
+LL |     let result: i32 = foo(5, 5);
+   |                       ^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0133`.
diff --git a/src/test/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.mir.stderr b/src/test/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.mir.stderr
new file mode 100644 (file)
index 0000000..a60100d
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/coerce-unsafe-closure-to-unsafe-fn-ptr.rs:5:31
+   |
+LL |     let _: unsafe fn() = || { ::std::pin::Pin::new_unchecked(&0_u8); };
+   |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0133`.
index 36777693faba0cd54886175384087bbf0d78d476..57358fbdd8404139e644e91b63764a4bc23ecbce 100644 (file)
@@ -1,3 +1,6 @@
+// revisions: mir thir
+// [thir]compile-flags: -Z thir-unsafeck
+
 fn main() {
     let _: unsafe fn() = || { ::std::pin::Pin::new_unchecked(&0_u8); };
     //~^ ERROR E0133
diff --git a/src/test/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.stderr b/src/test/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.stderr
deleted file mode 100644 (file)
index a1fb1c0..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/coerce-unsafe-closure-to-unsafe-fn-ptr.rs:2:31
-   |
-LL |     let _: unsafe fn() = || { ::std::pin::Pin::new_unchecked(&0_u8); };
-   |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
-   |
-   = note: consult the function's documentation for information on how to avoid undefined behavior
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0133`.
diff --git a/src/test/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.thir.stderr b/src/test/ui/closures/coerce-unsafe-closure-to-unsafe-fn-ptr.thir.stderr
new file mode 100644 (file)
index 0000000..a60100d
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/coerce-unsafe-closure-to-unsafe-fn-ptr.rs:5:31
+   |
+LL |     let _: unsafe fn() = || { ::std::pin::Pin::new_unchecked(&0_u8); };
+   |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0133`.
index 5ed023e1f213454735f919902048e91cc05ab4bf..30013a658f13d3604cb8c6d119ca772d07ae272e 100644 (file)
@@ -4,7 +4,7 @@ error: requires at least a format string argument
 LL |     format!();
    |     ^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::__export::format_args` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: expected `,`, found `1`
   --> $DIR/bad-format-args.rs:3:16
index f8820b9efedfcd17cb322bd8a3b9f635e77a7185..fc902a2b6dbf3accab41fe28d730c1540d06f024 100644 (file)
@@ -4,7 +4,7 @@ error[E0600]: cannot apply unary operator `!` to type `&'static str`
 LL |     assert!("foo");
    |     ^^^^^^^^^^^^^^^ cannot apply unary operator `!`
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 8ae2ff16a2b4fcd829221de41257599b69021228..bbcab9690a9c1cad8e045924290f504e9170b3b9 100644 (file)
@@ -61,7 +61,7 @@ LL |         #[cfg(feature = $expr)]
 LL | generate_s10!(concat!("nonexistent"));
    | -------------------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `generate_s10` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: expected unsuffixed literal or identifier, found `concat!("nonexistent")`
   --> $DIR/cfg-attr-syntax-validation.rs:30:25
@@ -72,7 +72,7 @@ LL |         #[cfg(feature = $expr)]
 LL | generate_s10!(concat!("nonexistent"));
    | -------------------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `generate_s10` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 11 previous errors
 
index 330ce2bd2e1b520408b706fab7742f35942e7b78..a662f6803347aa342300d620d6f946f5aae7d4f2 100644 (file)
@@ -7,7 +7,7 @@ LL |         #[cfg_attr(all(), unknown)]
 LL | foo!();
    | ------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index c8ee6ad61ec7304ab78d6837bb24486dea612522..2e3132c2eb7b640072a2d1985414a4a0951a7149 100644 (file)
@@ -5,7 +5,16 @@ LL | struct A<const N: u8>;
    | ---------------------- similarly named struct `A` defined here
 LL | trait Foo {}
 LL | impl Foo for A<N> {}
-   |                ^ help: a struct with a similar name exists: `A`
+   |                ^
+   |
+help: a struct with a similar name exists
+   |
+LL | impl Foo for A<A> {}
+   |                ^
+help: you might be missing a type parameter
+   |
+LL | impl<N> Foo for A<N> {}
+   |     ^^^
 
 error[E0412]: cannot find type `T` in this scope
   --> $DIR/diagnostics.rs:16:32
@@ -14,7 +23,16 @@ LL | struct A<const N: u8>;
    | ---------------------- similarly named struct `A` defined here
 ...
 LL | impl<const N: u8> Foo for C<N, T> {}
-   |                                ^ help: a struct with a similar name exists: `A`
+   |                                ^
+   |
+help: a struct with a similar name exists
+   |
+LL | impl<const N: u8> Foo for C<N, A> {}
+   |                                ^
+help: you might be missing a type parameter
+   |
+LL | impl<const N: u8, T> Foo for C<N, T> {}
+   |                 ^^^
 
 error[E0747]: unresolved item provided when a constant was expected
   --> $DIR/diagnostics.rs:7:16
index dd7e63480eb207ed71d62c1c6ecb9c34d0024f96..9deda56cd0df212ecb3fd3e622d093d6f14c125a 100644 (file)
@@ -1,30 +1,30 @@
-error[E0107]: this function takes 2 const arguments but only 1 const argument was supplied
+error[E0107]: this function takes 2 generic arguments but 1 generic argument was supplied
   --> $DIR/incorrect-number-of-const-args.rs:11:5
    |
 LL |     foo::<0>();
-   |     ^^^   - supplied 1 const argument
+   |     ^^^   - supplied 1 generic argument
    |     |
-   |     expected 2 const arguments
+   |     expected 2 generic arguments
    |
-note: function defined here, with 2 const parameters: `X`, `Y`
+note: function defined here, with 2 generic parameters: `X`, `Y`
   --> $DIR/incorrect-number-of-const-args.rs:6:4
    |
 LL | fn foo<const X: usize, const Y: usize>() -> usize {
    |    ^^^       -               -
-help: add missing const argument
+help: add missing generic argument
    |
 LL |     foo::<0, Y>();
    |            ^^^
 
-error[E0107]: this function takes 2 const arguments but 3 const arguments were supplied
+error[E0107]: this function takes 2 generic arguments but 3 generic arguments were supplied
   --> $DIR/incorrect-number-of-const-args.rs:14:5
    |
 LL |     foo::<0, 0, 0>();
-   |     ^^^       --- help: remove this const argument
+   |     ^^^         - help: remove this generic argument
    |     |
-   |     expected 2 const arguments
+   |     expected 2 generic arguments
    |
-note: function defined here, with 2 const parameters: `X`, `Y`
+note: function defined here, with 2 generic parameters: `X`, `Y`
   --> $DIR/incorrect-number-of-const-args.rs:6:4
    |
 LL | fn foo<const X: usize, const Y: usize>() -> usize {
index dd7e63480eb207ed71d62c1c6ecb9c34d0024f96..9deda56cd0df212ecb3fd3e622d093d6f14c125a 100644 (file)
@@ -1,30 +1,30 @@
-error[E0107]: this function takes 2 const arguments but only 1 const argument was supplied
+error[E0107]: this function takes 2 generic arguments but 1 generic argument was supplied
   --> $DIR/incorrect-number-of-const-args.rs:11:5
    |
 LL |     foo::<0>();
-   |     ^^^   - supplied 1 const argument
+   |     ^^^   - supplied 1 generic argument
    |     |
-   |     expected 2 const arguments
+   |     expected 2 generic arguments
    |
-note: function defined here, with 2 const parameters: `X`, `Y`
+note: function defined here, with 2 generic parameters: `X`, `Y`
   --> $DIR/incorrect-number-of-const-args.rs:6:4
    |
 LL | fn foo<const X: usize, const Y: usize>() -> usize {
    |    ^^^       -               -
-help: add missing const argument
+help: add missing generic argument
    |
 LL |     foo::<0, Y>();
    |            ^^^
 
-error[E0107]: this function takes 2 const arguments but 3 const arguments were supplied
+error[E0107]: this function takes 2 generic arguments but 3 generic arguments were supplied
   --> $DIR/incorrect-number-of-const-args.rs:14:5
    |
 LL |     foo::<0, 0, 0>();
-   |     ^^^       --- help: remove this const argument
+   |     ^^^         - help: remove this generic argument
    |     |
-   |     expected 2 const arguments
+   |     expected 2 generic arguments
    |
-note: function defined here, with 2 const parameters: `X`, `Y`
+note: function defined here, with 2 generic parameters: `X`, `Y`
   --> $DIR/incorrect-number-of-const-args.rs:6:4
    |
 LL | fn foo<const X: usize, const Y: usize>() -> usize {
index 3114e716845bfc7addde8b93ca7146fea736c13f..305559d93fdad20169ba87e80912eeff8df725c1 100644 (file)
@@ -9,8 +9,8 @@ fn foo<const X: usize, const Y: usize>() -> usize {
 
 fn main() {
     foo::<0>();
-    //~^ ERROR this function takes 2 const arguments but only 1 const argument was supplied
+    //~^ ERROR this function takes 2
 
     foo::<0, 0, 0>();
-    //~^ ERROR this function takes 2 const arguments but 3 const arguments were supplied
+    //~^ ERROR this function takes 2
 }
index b67a1f153ffef520efb7ec7f17d1c6b29cb5f3cd..7d4dc98f396b4c7ccf4bcf1a62e0bdab7c693ad0 100644 (file)
@@ -4,11 +4,11 @@
 
 fn main() {
     let _: u32 = 5i32.try_into::<32>().unwrap();
-    //~^ ERROR this associated function takes 0 const arguments but 1 const argument was supplied
+    //~^ ERROR this associated function takes
 
     S.f::<0>();
     //~^ ERROR no method named `f`
 
     S::<0>;
-    //~^ ERROR this struct takes 0 const arguments but 1 const argument was supplied
+    //~^ ERROR this struct takes 0
 }
index a75da91caa84f825f95451a96ba9a9e7d648cf32..aa5cebd873e3191a2bc9c4a336ae6137255f8117 100644 (file)
@@ -1,12 +1,12 @@
-error[E0107]: this associated function takes 0 const arguments but 1 const argument was supplied
+error[E0107]: this associated function takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/invalid-const-arg-for-type-param.rs:6:23
    |
 LL |     let _: u32 = 5i32.try_into::<32>().unwrap();
    |                       ^^^^^^^^------ help: remove these generics
    |                       |
-   |                       expected 0 const arguments
+   |                       expected 0 generic arguments
    |
-note: associated function defined here, with 0 const parameters
+note: associated function defined here, with 0 generic parameters
   --> $SRC_DIR/core/src/convert/mod.rs:LL:COL
    |
 LL |     fn try_into(self) -> Result<T, Self::Error>;
@@ -21,15 +21,15 @@ LL | struct S;
 LL |     S.f::<0>();
    |       ^ method not found in `S`
 
-error[E0107]: this struct takes 0 const arguments but 1 const argument was supplied
+error[E0107]: this struct takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/invalid-const-arg-for-type-param.rs:12:5
    |
 LL |     S::<0>;
    |     ^----- help: remove these generics
    |     |
-   |     expected 0 const arguments
+   |     expected 0 generic arguments
    |
-note: struct defined here, with 0 const parameters
+note: struct defined here, with 0 generic parameters
   --> $DIR/invalid-const-arg-for-type-param.rs:3:8
    |
 LL | struct S;
index 57c1af36d61ccfece39381490b7a0863def360a3..1400d2bf5a7ba64ff65b98d3bad000bb0fb93cab 100644 (file)
@@ -2,7 +2,7 @@ error[E0107]: this struct takes 1 generic argument but 2 generic arguments were
   --> $DIR/invalid-constant-in-args.rs:4:12
    |
 LL |     let _: Cell<&str, "a"> = Cell::new("");
-   |            ^^^^     ----- help: remove this generic argument
+   |            ^^^^       --- help: remove this generic argument
    |            |
    |            expected 1 generic argument
    |
index d95d675ddad76cdf8dae9544237664ff014f5556..2d7051c3a245cf6b59d78ea062e48b33bae25155 100644 (file)
@@ -13,5 +13,5 @@ fn test<T, const P: usize>() where Bool<{core::mem::size_of::<T>() > 4}>: True {
 
 fn main() {
     test::<2>();
-    //~^ ERROR this function takes 2 generic arguments but only 1 generic argument was supplied
+    //~^ ERROR this function takes 2 generic arguments
 }
index 9d95e5a014de4e28e1abda1c7b737cdd96d1ce17..01a0f6bcba9d8512599297c44a0e74f71dc8bdf7 100644 (file)
@@ -1,4 +1,4 @@
-error[E0107]: this function takes 2 generic arguments but only 1 generic argument was supplied
+error[E0107]: this function takes 2 generic arguments but 1 generic argument was supplied
   --> $DIR/issue-76595.rs:15:5
    |
 LL |     test::<2>();
index 1883f454e602164bf7390bfad32e992356cbfd88..ef6e857838a2858a18d14942e7af202cb06f36b8 100644 (file)
@@ -30,7 +30,7 @@ LL |     let _: foo!({{ N }});
    |            ------------- in this macro invocation
    |
    = note: this may fail depending on what value the parameter takes
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: constant expression depends on a generic parameter
   --> $DIR/macro_rules-braces.rs:20:13
@@ -42,7 +42,7 @@ LL |     let _: bar!({ N });
    |            ----------- in this macro invocation
    |
    = note: this may fail depending on what value the parameter takes
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `bar` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: constant expression depends on a generic parameter
   --> $DIR/macro_rules-braces.rs:25:13
@@ -54,7 +54,7 @@ LL |     let _: baz!({{ N }});
    |            ------------- in this macro invocation
    |
    = note: this may fail depending on what value the parameter takes
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `baz` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: constant expression depends on a generic parameter
   --> $DIR/macro_rules-braces.rs:30:13
@@ -66,7 +66,7 @@ LL |     let _: biz!({ N });
    |            ----------- in this macro invocation
    |
    = note: this may fail depending on what value the parameter takes
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `biz` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 6 previous errors
 
index 22930a352a869115a353aa05dff7373353e7e039..d5dd70d9b489cf98bebf5d9a67f4ca2637e3cb6a 100644 (file)
@@ -10,7 +10,7 @@ LL | fn make_marker() -> impl Marker<gimme_a_const!(marker)> {
 LL |       ($rusty: ident) => {{ let $rusty = 3; *&$rusty }}
    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `gimme_a_const` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: expected type, found `{`
   --> $DIR/macro-fail.rs:29:27
@@ -24,7 +24,7 @@ LL |   Example::<gimme_a_const!(marker)>
 LL |       ($rusty: ident) => {{ let $rusty = 3; *&$rusty }}
    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected type
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `gimme_a_const` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: expected type, found `{`
   --> $DIR/macro-fail.rs:4:10
@@ -43,7 +43,7 @@ LL |     let _fail = Example::<external_macro!()>;
    |                           this macro call doesn't expand to a type
    |                           in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `external_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: unexpected end of macro invocation
   --> $DIR/macro-fail.rs:39:25
index d038269382be5ed0c170a1151014030a4636154c..a824a44c9c22264708cb6deca46239bffaf41dfb 100644 (file)
@@ -15,12 +15,12 @@ enum E<'a, 'b> {
 fn main() {
     S(&0, &0); // OK
     S::<'static>(&0, &0);
-    //~^ ERROR this struct takes 2 lifetime arguments but only 1 lifetime argument was supplied
+    //~^ ERROR this struct takes 2 lifetime arguments
     S::<'static, 'static, 'static>(&0, &0);
-    //~^ ERROR this struct takes 2 lifetime arguments but 3 lifetime arguments were supplied
+    //~^ ERROR this struct takes 2 lifetime arguments
     E::V(&0); // OK
     E::V::<'static>(&0);
-    //~^ ERROR this enum takes 2 lifetime arguments but only 1 lifetime argument was supplied
+    //~^ ERROR this enum takes 2 lifetime arguments
     E::V::<'static, 'static, 'static>(&0);
-    //~^ ERROR this enum takes 2 lifetime arguments but 3 lifetime arguments were supplied
+    //~^ ERROR this enum takes 2 lifetime arguments
 }
index 378b07694e6fec451d8f2fd7afacc551e1e89871..f33aa4953e4f51accde9bb0754fb06706d91f5da 100644 (file)
@@ -1,4 +1,4 @@
-error[E0107]: this struct takes 2 lifetime arguments but only 1 lifetime argument was supplied
+error[E0107]: this struct takes 2 lifetime arguments but 1 lifetime argument was supplied
   --> $DIR/constructor-lifetime-args.rs:17:5
    |
 LL |     S::<'static>(&0, &0);
@@ -20,7 +20,7 @@ error[E0107]: this struct takes 2 lifetime arguments but 3 lifetime arguments we
   --> $DIR/constructor-lifetime-args.rs:19:5
    |
 LL |     S::<'static, 'static, 'static>(&0, &0);
-   |     ^                   --------- help: remove this lifetime argument
+   |     ^                     ------- help: remove this lifetime argument
    |     |
    |     expected 2 lifetime arguments
    |
@@ -30,7 +30,7 @@ note: struct defined here, with 2 lifetime parameters: `'a`, `'b`
 LL | struct S<'a, 'b>(&'a u8, &'b u8);
    |        ^ --  --
 
-error[E0107]: this enum takes 2 lifetime arguments but only 1 lifetime argument was supplied
+error[E0107]: this enum takes 2 lifetime arguments but 1 lifetime argument was supplied
   --> $DIR/constructor-lifetime-args.rs:22:8
    |
 LL |     E::V::<'static>(&0);
@@ -52,7 +52,7 @@ error[E0107]: this enum takes 2 lifetime arguments but 3 lifetime arguments were
   --> $DIR/constructor-lifetime-args.rs:24:8
    |
 LL |     E::V::<'static, 'static, 'static>(&0);
-   |        ^                   --------- help: remove this lifetime argument
+   |        ^                     ------- help: remove this lifetime argument
    |        |
    |        expected 2 lifetime arguments
    |
index 74907a0b49518f82e2bd5f2bcbbfb657ef7c5d99..5637de8b3139cff1de98a8bea386d28b222cd970 100644 (file)
@@ -9,7 +9,7 @@ LL | const Z: () = std::panic!("cheese");
    = 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 <https://github.com/rust-lang/rust/issues/71800>
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (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
@@ -21,7 +21,7 @@ LL | const Z2: () = std::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 <https://github.com/rust-lang/rust/issues/71800>
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (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
@@ -33,7 +33,7 @@ LL | const Y: () = std::unreachable!();
    |
    = 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 <https://github.com/rust-lang/rust/issues/71800>
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (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
@@ -45,7 +45,7 @@ LL | const X: () = std::unimplemented!();
    |
    = 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 <https://github.com/rust-lang/rust/issues/71800>
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (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
@@ -57,7 +57,7 @@ LL | const W: () = std::panic!(MSG);
    |
    = 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 <https://github.com/rust-lang/rust/issues/71800>
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (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
@@ -69,7 +69,7 @@ LL | const Z_CORE: () = core::panic!("cheese");
    |
    = 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 <https://github.com/rust-lang/rust/issues/71800>
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (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
@@ -81,7 +81,7 @@ LL | const Z2_CORE: () = core::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 <https://github.com/rust-lang/rust/issues/71800>
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (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
@@ -93,7 +93,7 @@ LL | const Y_CORE: () = core::unreachable!();
    |
    = 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 <https://github.com/rust-lang/rust/issues/71800>
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (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
@@ -105,7 +105,7 @@ LL | const X_CORE: () = core::unimplemented!();
    |
    = 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 <https://github.com/rust-lang/rust/issues/71800>
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (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
@@ -117,7 +117,7 @@ LL | const W_CORE: () = core::panic!(MSG);
    |
    = 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 <https://github.com/rust-lang/rust/issues/71800>
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 10 previous errors
 
index 7c33610faff0a272dc67b7dcc598c7df8d0d12fb..9971559e33b00d7f070b322c7a8a81f12ba6f519 100644 (file)
@@ -9,7 +9,7 @@ LL | const Z: () = panic!("cheese");
    = 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 <https://github.com/rust-lang/rust/issues/71800>
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (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
@@ -21,7 +21,7 @@ LL | const Y: () = unreachable!();
    |
    = 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 <https://github.com/rust-lang/rust/issues/71800>
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (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
@@ -33,7 +33,7 @@ LL | const X: () = unimplemented!();
    |
    = 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 <https://github.com/rust-lang/rust/issues/71800>
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (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/double_promotion.rs b/src/test/ui/consts/const-eval/double_promotion.rs
deleted file mode 100644 (file)
index 9ee2777..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// check-pass
-
-#![feature(rustc_attrs)]
-
-#[rustc_args_required_const(0)]
-pub const fn a(value: u8) -> u8 {
-    value
-}
-
-#[rustc_args_required_const(0)]
-pub fn b(_: u8) {
-    unimplemented!()
-}
-
-fn main() {
-    let _ = b(a(0));
-}
index 29c98c45c4e4c9285dc6e05b498b4af8af7a95b1..8d8e94cd4ff8af1d142a7ff223ae99f734d1c1a6 100644 (file)
@@ -6,7 +6,7 @@ LL | const Z: () = panic!("cheese");
    |
    = note: see issue #51999 <https://github.com/rust-lang/rust/issues/51999> for more information
    = help: add `#![feature(const_panic)]` to the crate attributes to enable
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0658]: panicking in constants is unstable
   --> $DIR/feature-gate-const_panic.rs:6:15
@@ -16,7 +16,7 @@ LL | const Y: () = unreachable!();
    |
    = note: see issue #51999 <https://github.com/rust-lang/rust/issues/51999> for more information
    = help: add `#![feature(const_panic)]` to the crate attributes to enable
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0658]: panicking in constants is unstable
   --> $DIR/feature-gate-const_panic.rs:9:15
@@ -26,7 +26,7 @@ LL | const X: () = unimplemented!();
    |
    = note: see issue #51999 <https://github.com/rust-lang/rust/issues/51999> for more information
    = help: add `#![feature(const_panic)]` to the crate attributes to enable
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 3 previous errors
 
index 28a3ebede5038f4e1cbde1a6123a56ef15b0b85f..d1f067df84888d8c2a0853b0bbef9c25e4bb1324 100644 (file)
@@ -13,7 +13,7 @@ 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 <https://github.com/rust-lang/rust/issues/71800>
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0080]: erroneous constant used
   --> $DIR/panic-assoc-never-type.rs:17:13
index 8f67dd6a8ba427c3f50b62236a9d1c5df306f580..2217bf1e05a00ed4409f0e0c56890a67a4272f59 100644 (file)
@@ -13,7 +13,7 @@ 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 <https://github.com/rust-lang/rust/issues/71800>
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0080]: erroneous constant used
   --> $DIR/panic-never-type.rs:13:13
index f13f2bfe9b110a58263320f96b1c4d32e594a8f1..79fdd05be30ee764224685eaee36006eacdadbeb 100644 (file)
@@ -14,7 +14,7 @@ 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 <https://github.com/rust-lang/rust/issues/71800>
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (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-extern-fn/const-extern-fn-requires-unsafe.mir.stderr b/src/test/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.mir.stderr
new file mode 100644 (file)
index 0000000..b643ecc
--- /dev/null
@@ -0,0 +1,19 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/const-extern-fn-requires-unsafe.rs:11:5
+   |
+LL |     foo();
+   |     ^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/const-extern-fn-requires-unsafe.rs:9:17
+   |
+LL |     let a: [u8; foo()];
+   |                 ^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0133`.
index 71e6c2cb85859bb6966420b4bdd04440bad4dfa7..1ce781479708335eab495c1c62231857721d03e0 100644 (file)
@@ -1,3 +1,6 @@
+// revisions: mir thir
+// [thir]compile-flags: -Z thir-unsafeck
+
 #![feature(const_extern_fn)]
 
 const unsafe extern "C" fn foo() -> usize { 5 }
diff --git a/src/test/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.stderr b/src/test/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.stderr
deleted file mode 100644 (file)
index 5196b8e..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/const-extern-fn-requires-unsafe.rs:8:5
-   |
-LL |     foo();
-   |     ^^^^^ call to unsafe function
-   |
-   = note: consult the function's documentation for information on how to avoid undefined behavior
-
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/const-extern-fn-requires-unsafe.rs:6:17
-   |
-LL |     let a: [u8; foo()];
-   |                 ^^^^^ call to unsafe function
-   |
-   = note: consult the function's documentation for information on how to avoid undefined behavior
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0133`.
diff --git a/src/test/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.thir.stderr b/src/test/ui/consts/const-extern-fn/const-extern-fn-requires-unsafe.thir.stderr
new file mode 100644 (file)
index 0000000..b643ecc
--- /dev/null
@@ -0,0 +1,19 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/const-extern-fn-requires-unsafe.rs:11:5
+   |
+LL |     foo();
+   |     ^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/const-extern-fn-requires-unsafe.rs:9:17
+   |
+LL |     let a: [u8; foo()];
+   |                 ^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0133`.
index 21fdffa115b83267289cbd3c85d30c4278918e51..108d976ec6dbef84a11ec2d1a283a645f5386316 100644 (file)
@@ -7,7 +7,7 @@ LL |     static_assert!(2 + 2 == 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 <https://github.com/rust-lang/rust/issues/71800>
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `static_assert` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 86c2f1c4f8e135165ab932afe4f67f1bd3264567..0100dce5a96a503c6b81c680953d89f7805059f5 100644 (file)
@@ -16,7 +16,7 @@ LL | const BAR: i32 = Option::<i32>::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 <https://github.com/rust-lang/rust/issues/71800>
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (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_arg_local.rs b/src/test/ui/consts/const_arg_local.rs
deleted file mode 100644 (file)
index 9add1f8..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#![feature(rustc_attrs)]
-
-#[rustc_args_required_const(0)]
-fn foo(_imm8: i32) {}
-
-fn bar() {
-    let imm8 = 3;
-    foo(imm8) //~ ERROR argument 1 is required to be a constant
-}
-
-fn main() {}
diff --git a/src/test/ui/consts/const_arg_local.stderr b/src/test/ui/consts/const_arg_local.stderr
deleted file mode 100644 (file)
index bad8547..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-error: argument 1 is required to be a constant
-  --> $DIR/const_arg_local.rs:8:5
-   |
-LL |     foo(imm8)
-   |     ^^^^^^^^^
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/consts/const_arg_promotable.rs b/src/test/ui/consts/const_arg_promotable.rs
deleted file mode 100644 (file)
index cea3817..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#![feature(rustc_attrs)]
-
-#[rustc_args_required_const(0)]
-fn foo(_imm8: i32) {}
-
-fn bar() {
-    foo(*&mut 42) //~ ERROR argument 1 is required to be a constant
-}
-
-fn main() {}
diff --git a/src/test/ui/consts/const_arg_promotable.stderr b/src/test/ui/consts/const_arg_promotable.stderr
deleted file mode 100644 (file)
index b24b245..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-error: argument 1 is required to be a constant
-  --> $DIR/const_arg_promotable.rs:7:5
-   |
-LL |     foo(*&mut 42)
-   |     ^^^^^^^^^^^^^
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/consts/const_arg_promotable2.rs b/src/test/ui/consts/const_arg_promotable2.rs
deleted file mode 100644 (file)
index 3399e51..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// This test is a regression test for a bug where we only checked function calls in no-const
-// functions for `rustc_args_required_const` arguments. This meant that even though `bar` needs its
-// argument to be const, inside a const fn (callable at runtime), the value for it may come from a
-// non-constant (namely an argument to the const fn).
-
-#![feature(rustc_attrs)]
-const fn foo(a: i32) {
-    bar(a); //~ ERROR argument 1 is required to be a constant
-}
-
-#[rustc_args_required_const(0)]
-const fn bar(_: i32) {}
-
-fn main() {
-    // this function call will pass a runtime-value (number of program arguments) to `foo`, which
-    // will in turn forward it to `bar`, which expects a compile-time argument
-    foo(std::env::args().count() as i32);
-}
diff --git a/src/test/ui/consts/const_arg_promotable2.stderr b/src/test/ui/consts/const_arg_promotable2.stderr
deleted file mode 100644 (file)
index 149d1ce..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-error: argument 1 is required to be a constant
-  --> $DIR/const_arg_promotable2.rs:8:5
-   |
-LL |     bar(a);
-   |     ^^^^^^
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/consts/const_arg_wrapper.rs b/src/test/ui/consts/const_arg_wrapper.rs
deleted file mode 100644 (file)
index 3dd3a2f..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#![feature(rustc_attrs)]
-
-#[rustc_args_required_const(0)]
-fn foo(_imm8: i32) {}
-
-fn bar(imm8: i32) {
-    foo(imm8) //~ ERROR argument 1 is required to be a constant
-}
-
-fn main() {}
diff --git a/src/test/ui/consts/const_arg_wrapper.stderr b/src/test/ui/consts/const_arg_wrapper.stderr
deleted file mode 100644 (file)
index 9cd95a2..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-error: argument 1 is required to be a constant
-  --> $DIR/const_arg_wrapper.rs:7:5
-   |
-LL |     foo(imm8)
-   |     ^^^^^^^^^
-
-error: aborting due to previous error
-
index 68d8747d28764eb0af89a40b6cb2ad0f7b43f388..fc7a53e2774866e9933c182254084b7783296b3a 100644 (file)
@@ -37,7 +37,7 @@ LL |   assert_eq!(BAR, true);
    = 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 <https://github.com/rust-lang/rust/issues/71800>
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors; 1 warning emitted
 
index 2f28c2e7bb6427845de4bb9b9ff5aea795b6b203..665b42400110589677a72b481a3b6ac72483d673 100644 (file)
@@ -9,7 +9,7 @@ LL | const _: () = assert!(false);
    = 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 <https://github.com/rust-lang/rust/issues/71800>
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index fd344533ce10fe4f19677982f9d81fd0de0897ba..0caaeca4ad23f128576fedbe22b1d38df6fbad30 100644 (file)
@@ -6,7 +6,7 @@ LL | const _: () = assert!(true);
    |
    = note: see issue #51999 <https://github.com/rust-lang/rust/issues/51999> for more information
    = help: add `#![feature(const_panic)]` to the crate attributes to enable
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0658]: panicking in constants is unstable
   --> $DIR/assert.rs:10:15
@@ -16,7 +16,7 @@ LL | const _: () = assert!(false);
    |
    = note: see issue #51999 <https://github.com/rust-lang/rust/issues/51999> for more information
    = help: add `#![feature(const_panic)]` to the crate attributes to enable
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index 39473343bcf44fe413439964a95e8937eaededee..b6e73f889adaba6bd945ed9bb6663ecf6458ece2 100644 (file)
@@ -6,7 +6,7 @@ LL |         Drop = assert_eq!(1, 1),
    |
    = note: `if` expressions without `else` evaluate to `()`
    = help: consider adding an `else` block that evaluates to the expected type
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 9834a99b79a0e019527cbe34c9aab39a3abeb477..2f97582bea88774b9f9fd5cb0c8e93e7a59e7c09 100644 (file)
@@ -10,7 +10,7 @@ LL | |     B = T,
 LL | | }
    | |_- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0308]: mismatched types
   --> $DIR/enum-discr-type-err.rs:18:21
@@ -24,7 +24,7 @@ LL | |     B = T,
 LL | | }
    | |_- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index 6fb6b69d220ca58538262b310cdc88570803ef1e..7904a35a5724bee71358e4db00bb6cf653a47ec5 100644 (file)
@@ -4,7 +4,7 @@ error[E0015]: inline assembly is not allowed in constants
 LL | const _: () = unsafe { llvm_asm!("nop") };
    |                        ^^^^^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `llvm_asm` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 48e0880d5eda2750c9b26f53bdb6a78dd1df2bf5..eba15e3fcca8afca43ab1008fa0f0ecf543d23e7 100644 (file)
@@ -6,7 +6,7 @@ LL | static S : u64 = { { panic!("foo"); 0 } };
    |
    = note: see issue #51999 <https://github.com/rust-lang/rust/issues/51999> for more information
    = help: add `#![feature(const_panic)]` to the crate attributes to enable
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index e0ca9dfde0bf91dea3abe9ce5f68e2b90f2ec244..2dd445b434b58017d6f5689f459fdf5baeeb4127 100644 (file)
@@ -4,7 +4,7 @@ error: argument to `panic!()` in a const context must have type `&str`
 LL |     let _ = [0i32; panic!(2f32)];
    |                    ^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0080]: evaluation of constant value failed
   --> $DIR/issue-66693-panic-in-array-len.rs:12:21
@@ -12,7 +12,7 @@ error[E0080]: evaluation of constant value failed
 LL |     let _ = [false; panic!()];
    |                     ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/issue-66693-panic-in-array-len.rs:12:21
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index 6bbde057ead7f43adc04728d2e63515837f228dc..50c95c89e0b79485f1e770c344ca98b7fddcb20d 100644 (file)
@@ -4,7 +4,7 @@ error: argument to `panic!()` in a const context must have type `&str`
 LL |     panic!(&1);
    |     ^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: argument to `panic!()` in a const context must have type `&str`
   --> $DIR/issue-66693.rs:6:15
@@ -12,7 +12,7 @@ error: argument to `panic!()` in a const context must have type `&str`
 LL | const _: () = panic!(1);
    |               ^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: argument to `panic!()` in a const context must have type `&str`
   --> $DIR/issue-66693.rs:9:19
@@ -20,7 +20,7 @@ error: argument to `panic!()` in a const context must have type `&str`
 LL | static _FOO: () = panic!(true);
    |                   ^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 3 previous errors
 
index 9bda1b7570d56c122dde437fc9ccd19eccedf08d..875bc5c5cd3300056b0f89895da977b40e8db528 100644 (file)
@@ -6,7 +6,7 @@ LL | struct Bug([u8; panic!("panic")]);
    |
    = note: see issue #51999 <https://github.com/rust-lang/rust/issues/51999> for more information
    = help: add `#![feature(const_panic)]` to the crate attributes to enable
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 23697a8e1181167bf5a1c2773a67944f77c07b0a..fee43864e20dcf9d12d30acc9248bffc523b257d 100644 (file)
@@ -4,7 +4,7 @@ error[E0010]: allocations are not allowed in constant functions
 LL |     vec![1, 2, 3]
    |     ^^^^^^^^^^^^^ allocation not allowed in constant functions
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0015]: calls in constant functions are limited to constant functions, tuple structs and tuple variants
   --> $DIR/bad_const_fn_body_ice.rs:2:5
@@ -12,7 +12,7 @@ error[E0015]: calls in constant functions are limited to constant functions, tup
 LL |     vec![1, 2, 3]
    |     ^^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index 73d1d7c5b9507239337a6ec426a35ba8fd531c34..fa93085dd2b1d6b5269acb891b0d0efe8fffd05d 100644 (file)
@@ -177,7 +177,7 @@ help: skipping check that does not even have a feature gate
    |
 LL |     unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 10 previous errors; 3 warnings emitted
 
index 7228f7178ff87c88b01e8ddfdb10b98a01dc5bdb..8a54d4a313f2d3c7b4056a8c6ef72754da8f32a1 100644 (file)
@@ -177,7 +177,7 @@ help: skipping check that does not even have a feature gate
    |
 LL |     unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } }
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 10 previous errors; 3 warnings emitted
 
index d372b4a5d25c0a199804ab744bbff0aeedcc455d..0bd95909c435c7715aeb4b5a1950732644c74594 100644 (file)
@@ -4,7 +4,7 @@ error[E0080]: could not evaluate static initializer
 LL |     unsafe { llvm_asm!("xor %eax, %eax" ::: "eax"); }
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ inline assembly is not supported
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `llvm_asm` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0080]: could not evaluate static initializer
   --> $DIR/inline_asm.rs:19:14
@@ -24,7 +24,7 @@ help: skipping check that does not even have a feature gate
    |
 LL |     unsafe { asm!("nop"); }
    |              ^^^^^^^^^^^^
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `llvm_asm` (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/rustc-args-required-const.rs b/src/test/ui/consts/rustc-args-required-const.rs
deleted file mode 100644 (file)
index 0723b66..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#![feature(rustc_attrs)]
-
-#[rustc_args_required_const(0)]
-fn foo(_a: i32) {
-}
-
-#[rustc_args_required_const(1)]
-fn bar(_a: i32, _b: i32) {
-}
-
-const A: i32 = 3;
-
-const fn baz() -> i32 {
-    3
-}
-
-fn main() {
-    foo(2);
-    foo(2 + 3);
-    const BAZ: i32 = baz();
-    foo(BAZ);
-    let a = 4;
-    foo(A);
-    foo(a); //~ ERROR: argument 1 is required to be a constant
-    bar(a, 3);
-    bar(a, a); //~ ERROR: argument 2 is required to be a constant
-}
diff --git a/src/test/ui/consts/rustc-args-required-const.stderr b/src/test/ui/consts/rustc-args-required-const.stderr
deleted file mode 100644 (file)
index 8b30269..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-error: argument 1 is required to be a constant
-  --> $DIR/rustc-args-required-const.rs:24:5
-   |
-LL |     foo(a);
-   |     ^^^^^^
-
-error: argument 2 is required to be a constant
-  --> $DIR/rustc-args-required-const.rs:26:5
-   |
-LL |     bar(a, a);
-   |     ^^^^^^^^^
-
-error: aborting due to 2 previous errors
-
index 9f58f16c1a02a571a60c51d8cdcb98ce4ad240ef..9ebffbfb71a532d801b9c915ba173726b874d683 100644 (file)
@@ -4,7 +4,7 @@ error: 1 positional argument in format string, but no arguments were given
 LL |     myprintln!("{}");
    |     ^^^^^^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `concat` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index b8658745060b014e5ed7ef03d7091a552d3f4689..4f015bf2148beb45179c980024b6706238f8b9cc 100644 (file)
@@ -11,7 +11,7 @@ LL |     underscore!();
    |
    = note: see issue #71126 <https://github.com/rust-lang/rust/issues/71126> for more information
    = help: add `#![feature(destructuring_assignment)]` to the crate attributes to enable
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `underscore` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: in expressions, `_` can only be used on the left-hand side of an assignment
   --> $DIR/underscore.rs:8:9
@@ -24,7 +24,7 @@ LL |         _
 LL |     underscore!();
    |     -------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `underscore` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index ea4445deb4a914dd5118f07bac3893aa0e317f0f..8967a7c6d33c7cd55cf8eb66ed34e82fa9be34b6 100644 (file)
@@ -5,7 +5,7 @@ LL | fn wrong_kind(){}
    | ^^^^^^^^^^^^^^^^^ the trait `Testable` is not implemented for `TestDescAndFn`
    |
    = note: required for the cast to the object type `dyn Testable`
-   = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index b81d4bf402a57590eef3962276cfcf7a52c10f53..63da838b3c3d31a7d7b9ad677cb3c0041487f3a5 100644 (file)
@@ -9,7 +9,7 @@ note: the lint level is defined here
    |
 LL | #![deny(deprecated)]
    |         ^^^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `macro_test` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 6f7cd9be2dd7bc063429741bf72719cd3586bbf7..c33ad1519bcc5ca4f6465682b9e7f9eb693574da 100644 (file)
@@ -9,7 +9,7 @@ note: the lint level is defined here
    |
 LL | #![deny(deprecated)]
    |         ^^^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `macro_test_arg_nested` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 959cf93bac05320d9852a8111328ce6fef224bc1..3699a939e27882e21e5a0a5363b9461f21cff183 100644 (file)
@@ -359,16 +359,16 @@ LL |         foo.method_deprecated();
    |             ^^^^^^^^^^^^^^^^^
 
 error: use of deprecated associated function `deprecation_lint::MethodTester::method_deprecated`: text
-  --> $DIR/deprecation-lint.rs:18:9
+  --> $DIR/deprecation-lint.rs:18:14
    |
 LL |         Foo::method_deprecated(&foo);
-   |         ^^^^^^^^^^^^^^^^^^^^^^
+   |              ^^^^^^^^^^^^^^^^^
 
 error: use of deprecated associated function `deprecation_lint::MethodTester::method_deprecated`: text
-  --> $DIR/deprecation-lint.rs:19:9
+  --> $DIR/deprecation-lint.rs:19:16
    |
 LL |         <Foo>::method_deprecated(&foo);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^
+   |                ^^^^^^^^^^^^^^^^^
 
 error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated`: text
   --> $DIR/deprecation-lint.rs:20:13
@@ -377,10 +377,10 @@ LL |         foo.trait_deprecated();
    |             ^^^^^^^^^^^^^^^^
 
 error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated`: text
-  --> $DIR/deprecation-lint.rs:22:9
+  --> $DIR/deprecation-lint.rs:22:16
    |
 LL |         <Foo>::trait_deprecated(&foo);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^
+   |                ^^^^^^^^^^^^^^^^
 
 error: use of deprecated associated function `deprecation_lint::MethodTester::method_deprecated_text`: text
   --> $DIR/deprecation-lint.rs:26:13
@@ -389,16 +389,16 @@ LL | ...   foo.method_deprecated_text();
    |           ^^^^^^^^^^^^^^^^^^^^^^
 
 error: use of deprecated associated function `deprecation_lint::MethodTester::method_deprecated_text`: text
-  --> $DIR/deprecation-lint.rs:27:9
+  --> $DIR/deprecation-lint.rs:27:14
    |
 LL | ...   Foo::method_deprecated_text(&foo);
-   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |            ^^^^^^^^^^^^^^^^^^^^^^
 
 error: use of deprecated associated function `deprecation_lint::MethodTester::method_deprecated_text`: text
-  --> $DIR/deprecation-lint.rs:28:9
+  --> $DIR/deprecation-lint.rs:28:16
    |
 LL | ...   <Foo>::method_deprecated_text(&foo);
-   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |              ^^^^^^^^^^^^^^^^^^^^^^
 
 error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text
   --> $DIR/deprecation-lint.rs:29:13
@@ -407,10 +407,10 @@ LL |         foo.trait_deprecated_text();
    |             ^^^^^^^^^^^^^^^^^^^^^
 
 error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text
-  --> $DIR/deprecation-lint.rs:31:9
+  --> $DIR/deprecation-lint.rs:31:16
    |
 LL | ...   <Foo>::trait_deprecated_text(&foo);
-   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |              ^^^^^^^^^^^^^^^^^^^^^
 
 error: use of deprecated field `deprecation_lint::DeprecatedStruct::i`: text
   --> $DIR/deprecation-lint.rs:35:13
@@ -431,10 +431,10 @@ LL |         foo.trait_deprecated();
    |             ^^^^^^^^^^^^^^^^
 
 error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated`: text
-  --> $DIR/deprecation-lint.rs:66:9
+  --> $DIR/deprecation-lint.rs:66:16
    |
 LL |         <Foo>::trait_deprecated(&foo);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^
+   |                ^^^^^^^^^^^^^^^^
 
 error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text
   --> $DIR/deprecation-lint.rs:68:13
@@ -443,10 +443,10 @@ LL |         foo.trait_deprecated_text();
    |             ^^^^^^^^^^^^^^^^^^^^^
 
 error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated_text`: text
-  --> $DIR/deprecation-lint.rs:70:9
+  --> $DIR/deprecation-lint.rs:70:16
    |
 LL | ...   <Foo>::trait_deprecated_text(&foo);
-   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |              ^^^^^^^^^^^^^^^^^^^^^
 
 error: use of deprecated associated function `deprecation_lint::Trait::trait_deprecated`: text
   --> $DIR/deprecation-lint.rs:75:13
@@ -551,16 +551,16 @@ LL |         foo.method_deprecated();
    |             ^^^^^^^^^^^^^^^^^
 
 error: use of deprecated associated function `this_crate::MethodTester::method_deprecated`: text
-  --> $DIR/deprecation-lint.rs:247:9
+  --> $DIR/deprecation-lint.rs:247:14
    |
 LL |         Foo::method_deprecated(&foo);
-   |         ^^^^^^^^^^^^^^^^^^^^^^
+   |              ^^^^^^^^^^^^^^^^^
 
 error: use of deprecated associated function `this_crate::MethodTester::method_deprecated`: text
-  --> $DIR/deprecation-lint.rs:248:9
+  --> $DIR/deprecation-lint.rs:248:16
    |
 LL |         <Foo>::method_deprecated(&foo);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^
+   |                ^^^^^^^^^^^^^^^^^
 
 error: use of deprecated associated function `this_crate::Trait::trait_deprecated`: text
   --> $DIR/deprecation-lint.rs:249:13
@@ -569,10 +569,10 @@ LL |         foo.trait_deprecated();
    |             ^^^^^^^^^^^^^^^^
 
 error: use of deprecated associated function `this_crate::Trait::trait_deprecated`: text
-  --> $DIR/deprecation-lint.rs:251:9
+  --> $DIR/deprecation-lint.rs:251:16
    |
 LL |         <Foo>::trait_deprecated(&foo);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^
+   |                ^^^^^^^^^^^^^^^^
 
 error: use of deprecated associated function `this_crate::MethodTester::method_deprecated_text`: text
   --> $DIR/deprecation-lint.rs:255:13
@@ -581,16 +581,16 @@ LL | ...   foo.method_deprecated_text();
    |           ^^^^^^^^^^^^^^^^^^^^^^
 
 error: use of deprecated associated function `this_crate::MethodTester::method_deprecated_text`: text
-  --> $DIR/deprecation-lint.rs:256:9
+  --> $DIR/deprecation-lint.rs:256:14
    |
 LL | ...   Foo::method_deprecated_text(&foo);
-   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |            ^^^^^^^^^^^^^^^^^^^^^^
 
 error: use of deprecated associated function `this_crate::MethodTester::method_deprecated_text`: text
-  --> $DIR/deprecation-lint.rs:257:9
+  --> $DIR/deprecation-lint.rs:257:16
    |
 LL | ...   <Foo>::method_deprecated_text(&foo);
-   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |              ^^^^^^^^^^^^^^^^^^^^^^
 
 error: use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text
   --> $DIR/deprecation-lint.rs:258:13
@@ -599,10 +599,10 @@ LL |         foo.trait_deprecated_text();
    |             ^^^^^^^^^^^^^^^^^^^^^
 
 error: use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text
-  --> $DIR/deprecation-lint.rs:260:9
+  --> $DIR/deprecation-lint.rs:260:16
    |
 LL |         <Foo>::trait_deprecated_text(&foo);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                ^^^^^^^^^^^^^^^^^^^^^
 
 error: use of deprecated field `this_crate::DeprecatedStruct::i`: text
   --> $DIR/deprecation-lint.rs:269:13
@@ -623,10 +623,10 @@ LL |         foo.trait_deprecated();
    |             ^^^^^^^^^^^^^^^^
 
 error: use of deprecated associated function `this_crate::Trait::trait_deprecated`: text
-  --> $DIR/deprecation-lint.rs:293:9
+  --> $DIR/deprecation-lint.rs:293:16
    |
 LL |         <Foo>::trait_deprecated(&foo);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^
+   |                ^^^^^^^^^^^^^^^^
 
 error: use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text
   --> $DIR/deprecation-lint.rs:295:13
@@ -635,10 +635,10 @@ LL |         foo.trait_deprecated_text();
    |             ^^^^^^^^^^^^^^^^^^^^^
 
 error: use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text
-  --> $DIR/deprecation-lint.rs:297:9
+  --> $DIR/deprecation-lint.rs:297:16
    |
 LL |         <Foo>::trait_deprecated_text(&foo);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                ^^^^^^^^^^^^^^^^^^^^^
 
 error: use of deprecated associated function `this_crate::Trait::trait_deprecated`: text
   --> $DIR/deprecation-lint.rs:302:13
diff --git a/src/test/ui/deprecation/issue-84637-deprecated-associated-function.fixed b/src/test/ui/deprecation/issue-84637-deprecated-associated-function.fixed
new file mode 100644 (file)
index 0000000..99a2b09
--- /dev/null
@@ -0,0 +1,9 @@
+// run-rustfix
+
+#![deny(deprecated)]
+
+fn main() {
+    let _foo = str::trim_start("   aoeu"); //~ ERROR use of deprecated associated function `core::str::<impl str>::trim_left`: superseded by `trim_start` [deprecated]
+
+    let _bar = "   aoeu".trim_start(); //~ ERROR use of deprecated associated function `core::str::<impl str>::trim_left`: superseded by `trim_start` [deprecated]
+}
diff --git a/src/test/ui/deprecation/issue-84637-deprecated-associated-function.rs b/src/test/ui/deprecation/issue-84637-deprecated-associated-function.rs
new file mode 100644 (file)
index 0000000..62bf84a
--- /dev/null
@@ -0,0 +1,9 @@
+// run-rustfix
+
+#![deny(deprecated)]
+
+fn main() {
+    let _foo = str::trim_left("   aoeu"); //~ ERROR use of deprecated associated function `core::str::<impl str>::trim_left`: superseded by `trim_start` [deprecated]
+
+    let _bar = "   aoeu".trim_left(); //~ ERROR use of deprecated associated function `core::str::<impl str>::trim_left`: superseded by `trim_start` [deprecated]
+}
diff --git a/src/test/ui/deprecation/issue-84637-deprecated-associated-function.stderr b/src/test/ui/deprecation/issue-84637-deprecated-associated-function.stderr
new file mode 100644 (file)
index 0000000..e65d21b
--- /dev/null
@@ -0,0 +1,20 @@
+error: use of deprecated associated function `core::str::<impl str>::trim_left`: superseded by `trim_start`
+  --> $DIR/issue-84637-deprecated-associated-function.rs:6:21
+   |
+LL |     let _foo = str::trim_left("   aoeu");
+   |                     ^^^^^^^^^ help: replace the use of the deprecated associated function: `trim_start`
+   |
+note: the lint level is defined here
+  --> $DIR/issue-84637-deprecated-associated-function.rs:3:9
+   |
+LL | #![deny(deprecated)]
+   |         ^^^^^^^^^^
+
+error: use of deprecated associated function `core::str::<impl str>::trim_left`: superseded by `trim_start`
+  --> $DIR/issue-84637-deprecated-associated-function.rs:8:26
+   |
+LL |     let _bar = "   aoeu".trim_left();
+   |                          ^^^^^^^^^ help: replace the use of the deprecated associated function: `trim_start`
+
+error: aborting due to 2 previous errors
+
index 632a279d79623b92d8bd87c3cc50c707e08991ea..b3f7b042aacd80e28041b431d3ef9b9dfa08db95 100644 (file)
@@ -43,7 +43,7 @@ LL |     ($x:expr) => { &$x }
 LL |     foo3(borrow!(0));
    |          ---------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `borrow` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0308]: mismatched types
   --> $DIR/deref-suggestion.rs:36:5
@@ -51,7 +51,7 @@ error[E0308]: mismatched types
 LL |     assert_eq!(3i32, &3i32);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `&i32`
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0308]: mismatched types
   --> $DIR/deref-suggestion.rs:39:17
index aa33faf5991753d741e5be2bb13f5ab79786a0f7..3d62bd8e8e7918d9fc52cc1a89c68fb8d410a679 100644 (file)
@@ -5,7 +5,7 @@ LL |      x: Error
    |      ^^^^^^^^ the trait `Clone` is not implemented for `Error`
    |
    = note: required by `clone`
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index e3bc2d6a9a0c8f83ef94f2beab6d904487116328..c855ec8e99327abb0d1311cb6311e5357a0924ac 100644 (file)
@@ -5,7 +5,7 @@ LL |      Error
    |      ^^^^^ the trait `Clone` is not implemented for `Error`
    |
    = note: required by `clone`
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 99c0cdecb6e9ea93f89a0fedc8a7f9f94ddf6552..522ec9719ed41ca9277205fa21c34345aa5f58ce 100644 (file)
@@ -5,7 +5,7 @@ LL |     x: Error
    |     ^^^^^^^^ the trait `Clone` is not implemented for `Error`
    |
    = note: required by `clone`
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index e6d734bfcc7bac963d77f5023f617f40ca68f5cb..b1f3e72f0d5634111daecb82bf8516adb1ab90c5 100644 (file)
@@ -5,7 +5,7 @@ LL |     Error
    |     ^^^^^ the trait `Clone` is not implemented for `Error`
    |
    = note: required by `clone`
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 64caba8e80dca021a5634816652cb73957cff2ce..2151335992fbcac3212f2146c0b39e9a47145e83 100644 (file)
@@ -8,7 +8,7 @@ LL |      x: Error
    = note: add `#[derive(Debug)]` or manually implement `Debug`
    = note: required because of the requirements on the impl of `Debug` for `&Error`
    = note: required for the cast to the object type `dyn Debug`
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 88b61f3fccf5eb580b452e8a57130e38c2b26e8d..99e618b40ece2c636ad18969859d665eee388de2 100644 (file)
@@ -8,7 +8,7 @@ LL |      Error
    = note: add `#[derive(Debug)]` or manually implement `Debug`
    = note: required because of the requirements on the impl of `Debug` for `&Error`
    = note: required for the cast to the object type `dyn Debug`
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 558a5796d2207a1ea67c4fb0bc6f5442398a667e..0086642c557cc9a38c97aaad27f26865f8078237 100644 (file)
@@ -8,7 +8,7 @@ LL |     x: Error
    = note: add `#[derive(Debug)]` or manually implement `Debug`
    = note: required because of the requirements on the impl of `Debug` for `&Error`
    = note: required for the cast to the object type `dyn Debug`
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 73a88a653f4c6b43803c98e0942b9941f9fd32c2..0b74908d1ee446b0b1aaab665e6267a12d362ebe 100644 (file)
@@ -8,7 +8,7 @@ LL |     Error
    = note: add `#[derive(Debug)]` or manually implement `Debug`
    = note: required because of the requirements on the impl of `Debug` for `&Error`
    = note: required for the cast to the object type `dyn Debug`
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index d2a5280ac6f3504eb58b390ddd6585cb61cc833d..b4cf1119eeb8ab752801cce4e2309e0c927bf1b8 100644 (file)
@@ -5,7 +5,7 @@ LL |     x: Error
    |     ^^^^^^^^ the trait `Default` is not implemented for `Error`
    |
    = note: required by `std::default::Default::default`
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 96ff7adc72c2387eebbc7d48f3068638f6e6c31a..62661a659be58c1fbdcf4654bb33870e710f3635 100644 (file)
@@ -5,7 +5,7 @@ LL |     Error
    |     ^^^^^ the trait `Default` is not implemented for `Error`
    |
    = note: required by `std::default::Default::default`
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 4ad7b94e414f00d5dde208e97a53e3baabb7556d..b14f2f8f0735c713338bb3e74a270e89c53f472d 100644 (file)
@@ -9,7 +9,7 @@ LL |      x: Error
 LL | pub struct AssertParamIsEq<T: Eq + ?Sized> {
    |                               -- required by this bound in `AssertParamIsEq`
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Eq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 8ee727493317b6b69dc98beeb31e7ff53d993d3e..ed7e6936f56c51ddd5ff5777f784c2e52ee7ff77 100644 (file)
@@ -9,7 +9,7 @@ LL |      Error
 LL | pub struct AssertParamIsEq<T: Eq + ?Sized> {
    |                               -- required by this bound in `AssertParamIsEq`
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Eq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 1b751365a3aa249b4d105790e5dfdf368335be52..ec26c5617210781834e76e3bfd35340f0757cf10 100644 (file)
@@ -9,7 +9,7 @@ LL |     x: Error
 LL | pub struct AssertParamIsEq<T: Eq + ?Sized> {
    |                               -- required by this bound in `AssertParamIsEq`
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Eq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 44b1d2cc026e3a80b189e184cb7efe4814f5cf94..a41acfbf5b515cda3349f66bc7afb894a084c2f1 100644 (file)
@@ -9,7 +9,7 @@ LL |     Error
 LL | pub struct AssertParamIsEq<T: Eq + ?Sized> {
    |                               -- required by this bound in `AssertParamIsEq`
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Eq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 9a03153797539549dcfdc64aa296ec188a6b1c71..fef7b8f75ac6f0bb69a6c2e595e4ffa455c238ed 100644 (file)
@@ -9,7 +9,7 @@ LL |      x: Error
 LL |     fn hash<H: Hasher>(&self, state: &mut H);
    |             - required by this bound in `std::hash::Hash::hash`
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 08ddc66dd0f4f56d825dcabc193b7bddbe02f409..90c5f91af919df7134f22947b08f8f9554974d86 100644 (file)
@@ -9,7 +9,7 @@ LL |      Error
 LL |     fn hash<H: Hasher>(&self, state: &mut H);
    |             - required by this bound in `std::hash::Hash::hash`
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index a2be46dc779b437034a59483d5b3f92a3e646ec7..b48828f439e1fcd306276021213a2e233ae9b6c1 100644 (file)
@@ -9,7 +9,7 @@ LL |     x: Error
 LL |     fn hash<H: Hasher>(&self, state: &mut H);
    |             - required by this bound in `std::hash::Hash::hash`
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 30cc6dc27ab73328cfb4f3868e5eb78899956235..3db0299192f05a5a988b706fd70ee8d8a92f120f 100644 (file)
@@ -9,7 +9,7 @@ LL |     Error
 LL |     fn hash<H: Hasher>(&self, state: &mut H);
    |             - required by this bound in `std::hash::Hash::hash`
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index b0b23217535133e54532f59f3814a73bd7b8ff42..9f77122286ab66fce00fdb08409330d4dfb1dfe7 100644 (file)
@@ -5,7 +5,7 @@ LL |      x: Error
    |      ^^^^^^^^ the trait `Ord` is not implemented for `Error`
    |
    = 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)
+   = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index bc95769294946deb76cb92ebeca92581598828c7..f5d2dd3daefb2e6b4f1dda5666cef0d9c468bef6 100644 (file)
@@ -5,7 +5,7 @@ LL |      Error
    |      ^^^^^ the trait `Ord` is not implemented for `Error`
    |
    = 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)
+   = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 5f324c131c99925bc2e8bbfb130f5bd433cb53ad..7a61ca483127910ee5f1748ce2143d65fd76bdcd 100644 (file)
@@ -5,7 +5,7 @@ LL |     x: Error
    |     ^^^^^^^^ the trait `Ord` is not implemented for `Error`
    |
    = 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)
+   = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 1c277e34ff22d5e57af164bdf946b807eb26a6bf..cd67d9ce98e09fa4b759f52085228a9a7021eee0 100644 (file)
@@ -5,7 +5,7 @@ LL |     Error
    |     ^^^^^ the trait `Ord` is not implemented for `Error`
    |
    = 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)
+   = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 8ff4b4687be3ac0d853db8dcb44ff12945668a70..a579d695700d4286924395298c91582dbc313e24 100644 (file)
@@ -5,7 +5,7 @@ LL |      x: Error
    |      ^^^^^^^^
    |
    = note: an implementation of `std::cmp::PartialEq` might be missing for `Error`
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0369]: binary operation `!=` cannot be applied to type `Error`
   --> $DIR/derives-span-PartialEq-enum-struct-variant.rs:9:6
@@ -14,7 +14,7 @@ LL |      x: Error
    |      ^^^^^^^^
    |
    = note: an implementation of `std::cmp::PartialEq` might be missing for `Error`
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index b4a12b1c4107d962400b196ba41fbc7d0f0343fb..532430729c7cf3463ed05caa63d0a725778e0c90 100644 (file)
@@ -5,7 +5,7 @@ LL |      Error
    |      ^^^^^
    |
    = note: an implementation of `std::cmp::PartialEq` might be missing for `Error`
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0369]: binary operation `!=` cannot be applied to type `Error`
   --> $DIR/derives-span-PartialEq-enum.rs:9:6
@@ -14,7 +14,7 @@ LL |      Error
    |      ^^^^^
    |
    = note: an implementation of `std::cmp::PartialEq` might be missing for `Error`
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index b4f6c51ac3c62db1141ba689a9d7c056c07f7f19..5fec402dcd8565dde5625a2df0955fa8dc16f20d 100644 (file)
@@ -5,7 +5,7 @@ LL |     x: Error
    |     ^^^^^^^^
    |
    = note: an implementation of `std::cmp::PartialEq` might be missing for `Error`
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0369]: binary operation `!=` cannot be applied to type `Error`
   --> $DIR/derives-span-PartialEq-struct.rs:8:5
@@ -14,7 +14,7 @@ LL |     x: Error
    |     ^^^^^^^^
    |
    = note: an implementation of `std::cmp::PartialEq` might be missing for `Error`
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index 2e6b1d71199f4aa9a3722594ed67e8d240305b54..0a7f9e14859ae94e91c5e9f8ebc615ac4837ed2a 100644 (file)
@@ -5,7 +5,7 @@ LL |     Error
    |     ^^^^^
    |
    = note: an implementation of `std::cmp::PartialEq` might be missing for `Error`
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0369]: binary operation `!=` cannot be applied to type `Error`
   --> $DIR/derives-span-PartialEq-tuple-struct.rs:8:5
@@ -14,7 +14,7 @@ LL |     Error
    |     ^^^^^
    |
    = note: an implementation of `std::cmp::PartialEq` might be missing for `Error`
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index 9f2f47add1278ae13f99780a3c15a9d24765141e..8d84b1217b7a371ae3bbc8140d06e177be433baa 100644 (file)
@@ -6,7 +6,7 @@ LL |      x: 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)
+   = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 25073c5718c9de4cc64f30057f5843110a365782..ce12727989df8ad60007a7171a52663f9e868c08 100644 (file)
@@ -6,7 +6,7 @@ LL |      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)
+   = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index b514dd9993f7f2eccee63a6e5573b2e63e8dea29..fc488e734f752821819bb09830b44725a3b6406c 100644 (file)
@@ -6,7 +6,7 @@ LL |     x: 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)
+   = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index c098f6bfb36acd802d652b3f2be133629a4cce90..e18b039f21f26f7ef5c39fed4f627888b6c11cee 100644 (file)
@@ -6,7 +6,7 @@ LL |     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)
+   = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 1842a88bb238cb15748b24fb7b496a64560df49e..0f69f94bf3a2a0d8402451b190a0cc76917ebdab 100644 (file)
@@ -5,7 +5,7 @@ LL |     x: NoCloneOrEq
    |     ^^^^^^^^^^^^^^
    |
    = note: an implementation of `std::cmp::PartialEq` might be missing for `NoCloneOrEq`
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0369]: binary operation `!=` cannot be applied to type `NoCloneOrEq`
   --> $DIR/deriving-no-inner-impl-error-message.rs:5:5
@@ -14,7 +14,7 @@ LL |     x: NoCloneOrEq
    |     ^^^^^^^^^^^^^^
    |
    = note: an implementation of `std::cmp::PartialEq` might be missing for `NoCloneOrEq`
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0277]: the trait bound `NoCloneOrEq: Clone` is not satisfied
   --> $DIR/deriving-no-inner-impl-error-message.rs:10:5
@@ -23,7 +23,7 @@ LL |     x: NoCloneOrEq
    |     ^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `NoCloneOrEq`
    |
    = note: required by `clone`
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 3 previous errors
 
index 3caa563a08560c8ec8bd4126da7fe8a2d1df2116..667f82ee0cfef2fc72598204551dc027622440cf 100644 (file)
@@ -11,7 +11,7 @@ LL | #![deny(unaligned_references)]
    |         ^^^^^^^^^^^^^^^^^^^^
    = 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 #82523 <https://github.com/rust-lang/rust/issues/82523>
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `#[derive]` can't be used on a `#[repr(packed)]` struct with type or const parameters (error E0133)
   --> $DIR/deriving-with-repr-packed.rs:8:23
@@ -21,7 +21,7 @@ LL | #[derive(Copy, Clone, PartialEq, Eq)]
    |
    = 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 #82523 <https://github.com/rust-lang/rust/issues/82523>
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `#[derive]` can't be used on a `#[repr(packed)]` struct that does not derive Copy (error E0133)
   --> $DIR/deriving-with-repr-packed.rs:16:10
@@ -31,7 +31,7 @@ LL | #[derive(PartialEq, Eq)]
    |
    = 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 #82523 <https://github.com/rust-lang/rust/issues/82523>
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `#[derive]` can't be used on a `#[repr(packed)]` struct that does not derive Copy (error E0133)
   --> $DIR/deriving-with-repr-packed.rs:25:10
@@ -41,7 +41,7 @@ LL | #[derive(PartialEq)]
    |
    = 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 #82523 <https://github.com/rust-lang/rust/issues/82523>
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 4 previous errors
 
index fe3fb43730a8c8187d1bbb5f7f6b56458298e0b5..fd29f8940bb153c1eaec4b4ed5e967c745d35dc3 100644 (file)
@@ -55,7 +55,7 @@ LL |     ($ty: ty) => ($ty::clone(&0))
 LL |     expr!(u8);
    |     ---------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `expr` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 9 previous errors
 
index 924a5d756436d718502659cfa8a58241aebfb032..19d173f1b423c14b2675b2d7f11150e824ea87a9 100644 (file)
@@ -37,7 +37,7 @@ LL |     ($ty: ty) => ($ty::AssocItem)
 LL |         pat!(u8) => {}
    |         -------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `pat` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0599]: no associated item named `AssocItem` found for slice `[u8]` in the current scope
   --> $DIR/bad-assoc-pat.rs:3:15
@@ -72,7 +72,7 @@ LL |     ($ty: ty) => ($ty::AssocItem)
 LL |         pat!(u8) => {}
    |         -------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `pat` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0599]: no associated item named `AssocItem` found for type `u8` in the current scope
   --> $DIR/bad-assoc-pat.rs:32:16
index ebc0883370b7d62b0a57f95132d878c23288030c..fc5f218c04f1380e0a9101f67fea0df01360c301 100644 (file)
@@ -55,7 +55,7 @@ LL |     ($ty: ty) => ($ty::AssocTy);
 LL | type J = ty!(u8);
    |          ------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `ty` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0223]: ambiguous associated type
   --> $DIR/bad-assoc-ty.rs:1:10
@@ -114,7 +114,7 @@ LL |     ($ty: ty) => ($ty::AssocTy);
 LL | type J = ty!(u8);
    |          ------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `ty` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0223]: ambiguous associated type
   --> $DIR/bad-assoc-ty.rs:44:10
index 4935c698f2056878d1db64d1c5b9f79b84b02d7b..0c6fdebd5095518b2067a76b27b2a8c390c335f6 100644 (file)
@@ -8,7 +8,7 @@ LL |     recurse!(0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9);
    |     -------------------------------------------------- in this macro invocation
    |
    = help: consider adding a `#![recursion_limit="20"]` attribute to your crate (`recursion_limit_macro`)
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `recurse` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 4039728e18ac384c22fef6784a6559e52969349c..e1bba8b527e767415af5cb5505f7c27a136215bc 100644 (file)
@@ -7,7 +7,7 @@ LL |         mod $i;
 LL |     mod_decl!(foo);
    |     --------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `mod_decl` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 2aad57dee7daabb0d918b785bd1fa9b5438a5b29..b6df4cacf3981b5610c4d88ddd4d37c961f05edc 100644 (file)
@@ -7,7 +7,7 @@ LL |         use a::$crate::b;
 LL | m!();
    | ----- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0432]: unresolved import `a::$crate`
   --> $DIR/dollar-crate-is-keyword-2.rs:5:13
@@ -18,7 +18,7 @@ LL |         use a::$crate;
 LL | m!();
    | ----- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0433]: failed to resolve: `$crate` in paths can only be used in start position
   --> $DIR/dollar-crate-is-keyword-2.rs:7:21
@@ -29,7 +29,7 @@ LL |         type A = a::$crate;
 LL | m!();
    | ----- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 3 previous errors
 
index d424bd2f2858c319bfe5a51fe64c2b4d2f974e15..8e32be897649e829564c4cf25522c47c4c77b8c4 100644 (file)
@@ -7,7 +7,7 @@ LL |             struct $crate {}
 LL | m!();
    | ----- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: expected identifier, found reserved identifier `$crate`
   --> $DIR/dollar-crate-is-keyword.rs:10:23
@@ -18,7 +18,7 @@ LL |         use $crate as $crate;
 LL | m!();
    | ----- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `$crate` may not be imported
   --> $DIR/dollar-crate-is-keyword.rs:9:9
@@ -29,7 +29,7 @@ LL |         use $crate;
 LL | m!();
    | ----- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `$crate` may not be imported
   --> $DIR/dollar-crate-is-keyword.rs:10:9
@@ -40,7 +40,7 @@ LL |         use $crate as $crate;
 LL | m!();
    | ----- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 4 previous errors
 
index ec8b88ecba22b5e776fd29ed1442070ef7dc6934..2b4eb815b7172cbe96d771b1f8177bb8c66da39b 100644 (file)
@@ -4,7 +4,7 @@ error: cannot glob-import all possible crates
 LL |     gen_glob!();
    |     ^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `gen_glob` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 087d2e339548c3fedc6e30df75ea2a298e82da36..1a304ebe9ad2766ed0809b03874cfe20d51f9eaf 100644 (file)
@@ -4,7 +4,7 @@ error: cannot glob-import all possible crates
 LL |     gen_glob!();
    |     ^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `gen_glob` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 1cde0f72140d10389349828c91aef2457b1da778..9ca7514d3aa08676b835ceec26add14145347406 100644 (file)
@@ -4,7 +4,7 @@ error[E0432]: unresolved import `E`
 LL |     gen_gated!();
    |     ^^^^^^^^^^^^^ could not find `E` in the list of imported crates
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `gen_gated` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 88a1f5dc6736d96efb6bebf20eb43fdd57fcd467..22f28a67798f53354bcc767c700a810faac64228 100644 (file)
@@ -4,7 +4,7 @@ error: expected identifier, found keyword `async`
 LL |     produces_async! {}
    |     ^^^^^^^^^^^^^^^^^^ expected identifier, found keyword
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `produces_async` (in Nightly builds, run with -Z macro-backtrace for more info)
 help: you can escape reserved keywords to use them as identifiers
    |
 LL |     () => (pub fn r#async() {})
index 5eaa1d03a4a5f491dfe2d5bd3b5f8089f61d1d34..2a1e7bb4afafd0a4fe80675d19df956cd8ed72f3 100644 (file)
@@ -4,7 +4,7 @@ error: expected identifier, found keyword `async`
 LL |     produces_async! {}
    |     ^^^^^^^^^^^^^^^^^^ expected identifier, found keyword
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `produces_async` (in Nightly builds, run with -Z macro-backtrace for more info)
 help: you can escape reserved keywords to use them as identifiers
    |
 LL |     () => (pub fn r#async() {})
index c3dde72599b71d719f3d9a8b0c8908dcf3c33462..f7f6afa860e0b35ad2d1746148b89ef62e9fa3b8 100644 (file)
@@ -9,15 +9,15 @@ enum Bar {
 
 struct Baz<'a, 'b, 'c> {
     buzz: Buzz<'a>,
-    //~^ ERROR this struct takes 2 lifetime arguments but only 1 lifetime argument was supplied
+    //~^ ERROR this struct takes 2 lifetime arguments
     //~| HELP add missing lifetime argument
 
     bar: Bar<'a>,
-    //~^ ERROR this enum takes 0 lifetime arguments but 1 lifetime argument was supplied
+    //~^ ERROR this enum takes 0 lifetime arguments
     //~| HELP remove these generics
 
     foo2: Foo<'a, 'b, 'c>,
-    //~^ ERROR this struct takes 1 lifetime argument but 3 lifetime arguments were supplied
+    //~^ ERROR this struct takes 1 lifetime argument
     //~| HELP remove these lifetime arguments
 }
 
index 30a2768d060583f2c04e99ac52b47c958fdf3d2a..299776b08f2da6dd4ce2166c478606d0b6695d8d 100644 (file)
@@ -1,4 +1,4 @@
-error[E0107]: this struct takes 2 lifetime arguments but only 1 lifetime argument was supplied
+error[E0107]: this struct takes 2 lifetime arguments but 1 lifetime argument was supplied
   --> $DIR/E0107.rs:11:11
    |
 LL |     buzz: Buzz<'a>,
@@ -13,7 +13,7 @@ LL | struct Buzz<'a, 'b>(&'a str, &'b str);
    |        ^^^^ --  --
 help: add missing lifetime argument
    |
-LL |     buzz: Buzz<'a, 'b>,
+LL |     buzz: Buzz<'a, 'a>,
    |                  ^^^^
 
 error[E0107]: this enum takes 0 lifetime arguments but 1 lifetime argument was supplied
@@ -34,7 +34,7 @@ error[E0107]: this struct takes 1 lifetime argument but 3 lifetime arguments wer
   --> $DIR/E0107.rs:19:11
    |
 LL |     foo2: Foo<'a, 'b, 'c>,
-   |           ^^^   -------- help: remove these lifetime arguments
+   |           ^^^     ------ help: remove these lifetime arguments
    |           |
    |           expected 1 lifetime argument
    |
diff --git a/src/test/ui/error-codes/E0133.mir.stderr b/src/test/ui/error-codes/E0133.mir.stderr
new file mode 100644 (file)
index 0000000..b11d5e2
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/E0133.rs:7:5
+   |
+LL |     f();
+   |     ^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0133`.
index 52494ce6078c4027e35f30f1e7f38be9d6cf6d20..dee1475ba213a8839535aa222359aaf72424939a 100644 (file)
@@ -1,3 +1,6 @@
+// revisions: mir thir
+// [thir]compile-flags: -Z thir-unsafeck
+
 unsafe fn f() { return; }
 
 fn main() {
diff --git a/src/test/ui/error-codes/E0133.stderr b/src/test/ui/error-codes/E0133.stderr
deleted file mode 100644 (file)
index 1eb6965..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/E0133.rs:4:5
-   |
-LL |     f();
-   |     ^^^ call to unsafe function
-   |
-   = note: consult the function's documentation for information on how to avoid undefined behavior
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0133`.
diff --git a/src/test/ui/error-codes/E0133.thir.stderr b/src/test/ui/error-codes/E0133.thir.stderr
new file mode 100644 (file)
index 0000000..b11d5e2
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/E0133.rs:7:5
+   |
+LL |     f();
+   |     ^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0133`.
index 591ea29ff8c5241e536dc3584c8590e23f805321..5bfeaa58bdf1432eaf654fa6ac901678224433ad 100644 (file)
@@ -4,7 +4,7 @@ error[E0184]: the trait `Copy` may not be implemented for this type; the type ha
 LL | #[derive(Copy)]
    |          ^^^^ Copy not allowed on types with destructors
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 3cb69492eb76d41e350e79c41e4d12626c33b24e..bb8b3906ca6b0d625f6e99cf9cabf1fb9d808b44 100644 (file)
@@ -4,7 +4,7 @@ error[E0665]: `Default` cannot be derived for enums, only structs
 LL | #[derive(Default)]
    |          ^^^^^^^
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index f1e725ec34206d43da9d38b5736c6bfd43de5428..36ee6570e42cd8a363c5a055878e5102476865c3 100644 (file)
@@ -4,7 +4,7 @@ error[E0184]: the trait `Copy` may not be implemented for this type; the type ha
 LL | #[derive(Copy, Clone)]
    |          ^^^^ Copy not allowed on types with destructors
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0184]: the trait `Copy` may not be implemented for this type; the type has a destructor
   --> $DIR/exclusive-drop-and-copy.rs:10:10
@@ -12,7 +12,7 @@ error[E0184]: the trait `Copy` may not be implemented for this type; the type ha
 LL | #[derive(Copy, Clone)]
    |          ^^^^ Copy not allowed on types with destructors
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index c64c9093ee54a9771cfe7c94efafac2e0aef766d..bcc3f536c40d5a2578b518591d1d03dc6e84b47c 100644 (file)
@@ -12,7 +12,7 @@ LL | |     });
    = note: `#[warn(irrefutable_let_patterns)]` on by default
    = note: this pattern will always match, so the `if let` is useless
    = help: consider replacing the `if let` with a `let`
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: irrefutable `if let` pattern
   --> $DIR/if-let.rs:6:13
@@ -27,7 +27,7 @@ LL | |     });
    |
    = note: this pattern will always match, so the `if let` is useless
    = help: consider replacing the `if let` with a `let`
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: irrefutable `if let` pattern
   --> $DIR/if-let.rs:26:5
index 56415fd1f0dd0ef4cd262f0f1d440cdd3557b5ad..c81518010bb2974997392e6724ce9b3d090f5c1d 100644 (file)
@@ -4,7 +4,7 @@ error: my error message
 LL | fn main() { env!("__HOPEFULLY_NOT_DEFINED__", "my error message"); }
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 1a9332c4f1c9fd6e880457cc13ba18e2788cb960..8ecba6dbe9af19a6b43a9e163d0d8dadc65f6450 100644 (file)
@@ -4,7 +4,7 @@ error: environment variable `__HOPEFULLY_NOT_DEFINED__` not defined
 LL |     env!("__HOPEFULLY_NOT_DEFINED__");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index b62f06e33e531ccbf230c6f21d8c12d5e20e6791..d2ac0b83016f287d86243d8e62901e298ea88987 100644 (file)
@@ -4,7 +4,7 @@ error: environment variable `NON_EXISTENT` not defined
 LL |     include!(concat!(env!("NON_EXISTENT"), "/data.rs"));
    |                      ^^^^^^^^^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: suffixes on a string literal are invalid
   --> $DIR/issue-55897.rs:16:22
index 89c99b89ca804f5348671ebca535ff92c645cebf..f1becfb99a8cb4f13f103f54c27bbe9296ac0d14 100644 (file)
@@ -8,7 +8,7 @@ LL | bar!();
    | ------- in this macro invocation
    |
    = help: add `#![feature(allow_internal_unsafe)]` to the crate attributes to enable
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `bar` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 935b95668e82b078ab470bc1f8e4ad8ce7141142..91cf2020a49f0df4be34ebb82868dc9454c24454 100644 (file)
@@ -8,7 +8,7 @@ LL | bar!();
    | ------- in this macro invocation
    |
    = help: add `#![feature(allow_internal_unstable)]` to the crate attributes to enable
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `bar` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 32c37806a87b5fb55af05d7a7d3e8121aed522b9..5e6dcd5447efaf45809364bda20c7715bce5ad29 100644 (file)
@@ -13,7 +13,7 @@ error[E0425]: cannot find value `ab` in this scope
 LL |     concat_idents!(a, b);
    |     ^^^^^^^^^^^^^^^^^^^^^ not found in this scope
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `concat_idents` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/feature-gates/feature-gate-const_fn.rs b/src/test/ui/feature-gates/feature-gate-const_fn.rs
deleted file mode 100644 (file)
index b97aa21..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-// Test use of advanced const fn without the `const_fn` feature gate.
-
-const fn foo() -> usize { 0 } // ok
-
-trait Foo {
-    const fn foo() -> u32; //~ ERROR functions in traits cannot be declared const
-    const fn bar() -> u32 { 0 } //~ ERROR functions in traits cannot be declared const
-}
-
-impl Foo for u32 {
-    const fn foo() -> u32 { 0 } //~ ERROR functions in traits cannot be declared const
-}
-
-trait Bar {}
-
-impl dyn Bar {
-    const fn baz() -> u32 { 0 } // ok
-}
-
-static FOO: usize = foo();
-const BAR: usize = foo();
-
-macro_rules! constant {
-    ($n:ident: $t:ty = $v:expr) => {
-        const $n: $t = $v;
-    }
-}
-
-constant! {
-    BAZ: usize = foo()
-}
-
-fn main() {
-    let x: [usize; foo()] = [];
-}
diff --git a/src/test/ui/feature-gates/feature-gate-const_fn.stderr b/src/test/ui/feature-gates/feature-gate-const_fn.stderr
deleted file mode 100644 (file)
index 1e7fd66..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-error[E0379]: functions in traits cannot be declared const
-  --> $DIR/feature-gate-const_fn.rs:6:5
-   |
-LL |     const fn foo() -> u32;
-   |     ^^^^^ functions in traits cannot be const
-
-error[E0379]: functions in traits cannot be declared const
-  --> $DIR/feature-gate-const_fn.rs:7:5
-   |
-LL |     const fn bar() -> u32 { 0 }
-   |     ^^^^^ functions in traits cannot be const
-
-error[E0379]: functions in traits cannot be declared const
-  --> $DIR/feature-gate-const_fn.rs:11:5
-   |
-LL |     const fn foo() -> u32 { 0 }
-   |     ^^^^^ functions in traits cannot be const
-
-error: aborting due to 3 previous errors
-
-For more information about this error, try `rustc --explain E0379`.
diff --git a/src/test/ui/feature-gates/feature-gate-const_fn_transmute.mir.stderr b/src/test/ui/feature-gates/feature-gate-const_fn_transmute.mir.stderr
new file mode 100644 (file)
index 0000000..04efea0
--- /dev/null
@@ -0,0 +1,118 @@
+error[E0658]: `transmute` is not allowed in constant functions
+  --> $DIR/feature-gate-const_fn_transmute.rs:11:43
+   |
+LL | const fn transmute_fn() -> u32 { unsafe { mem::transmute(Foo(3)) } }
+   |                                           ^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
+   = help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
+   = note: `transmute` is only allowed in constants and statics for now
+
+error[E0658]: `transmute` is not allowed in constant functions
+  --> $DIR/feature-gate-const_fn_transmute.rs:14:53
+   |
+LL | const fn transmute_fn_intrinsic() -> u32 { unsafe { std::intrinsics::transmute(Foo(3)) } }
+   |                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
+   = help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
+   = note: `transmute` is only allowed in constants and statics for now
+
+error[E0658]: `transmute` is not allowed in constant functions
+  --> $DIR/feature-gate-const_fn_transmute.rs:17:58
+   |
+LL | const fn transmute_fn_core_intrinsic() -> u32 { unsafe { core::intrinsics::transmute(Foo(3)) } }
+   |                                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
+   = help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
+   = note: `transmute` is only allowed in constants and statics for now
+
+error[E0658]: `transmute` is not allowed in constant functions
+  --> $DIR/feature-gate-const_fn_transmute.rs:20:48
+   |
+LL | const unsafe fn unsafe_transmute_fn() -> u32 { mem::transmute(Foo(3)) }
+   |                                                ^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
+   = help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
+   = note: `transmute` is only allowed in constants and statics for now
+
+error[E0658]: `transmute` is not allowed in constant functions
+  --> $DIR/feature-gate-const_fn_transmute.rs:23:58
+   |
+LL | const unsafe fn unsafe_transmute_fn_intrinsic() -> u32 { std::intrinsics::transmute(Foo(3)) }
+   |                                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
+   = help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
+   = note: `transmute` is only allowed in constants and statics for now
+
+error[E0658]: `transmute` is not allowed in constant functions
+  --> $DIR/feature-gate-const_fn_transmute.rs:26:63
+   |
+LL | const unsafe fn unsafe_transmute_fn_core_intrinsic() -> u32 { core::intrinsics::transmute(Foo(3)) }
+   |                                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
+   = help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
+   = note: `transmute` is only allowed in constants and statics for now
+
+error[E0658]: `transmute` is not allowed in constant functions
+  --> $DIR/feature-gate-const_fn_transmute.rs:29:39
+   |
+LL | const fn safe_transmute_fn() -> u32 { mem::transmute(Foo(3)) }
+   |                                       ^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
+   = help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
+   = note: `transmute` is only allowed in constants and statics for now
+
+error[E0658]: `transmute` is not allowed in constant functions
+  --> $DIR/feature-gate-const_fn_transmute.rs:33:49
+   |
+LL | const fn safe_transmute_fn_intrinsic() -> u32 { std::intrinsics::transmute(Foo(3)) }
+   |                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
+   = help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
+   = note: `transmute` is only allowed in constants and statics for now
+
+error[E0658]: `transmute` is not allowed in constant functions
+  --> $DIR/feature-gate-const_fn_transmute.rs:37:54
+   |
+LL | const fn safe_transmute_fn_core_intrinsic() -> u32 { core::intrinsics::transmute(Foo(3)) }
+   |                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
+   = help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
+   = note: `transmute` is only allowed in constants and statics for now
+
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/feature-gate-const_fn_transmute.rs:29:39
+   |
+LL | const fn safe_transmute_fn() -> u32 { mem::transmute(Foo(3)) }
+   |                                       ^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/feature-gate-const_fn_transmute.rs:33:49
+   |
+LL | const fn safe_transmute_fn_intrinsic() -> u32 { std::intrinsics::transmute(Foo(3)) }
+   |                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/feature-gate-const_fn_transmute.rs:37:54
+   |
+LL | const fn safe_transmute_fn_core_intrinsic() -> u32 { core::intrinsics::transmute(Foo(3)) }
+   |                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to 12 previous errors
+
+Some errors have detailed explanations: E0133, E0658.
+For more information about an error, try `rustc --explain E0133`.
index 9007e501bc2bf958877e08c92f11c343fb7af35a..9a45dbc51d42aa5a6b80f7e01560fc366a8c37bc 100644 (file)
@@ -1,3 +1,6 @@
+// revisions: mir thir
+// [thir]compile-flags: -Z thir-unsafeck
+
 use std::mem;
 
 #[repr(transparent)]
diff --git a/src/test/ui/feature-gates/feature-gate-const_fn_transmute.stderr b/src/test/ui/feature-gates/feature-gate-const_fn_transmute.stderr
deleted file mode 100644 (file)
index 08ba14d..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-error[E0658]: `transmute` is not allowed in constant functions
-  --> $DIR/feature-gate-const_fn_transmute.rs:8:43
-   |
-LL | const fn transmute_fn() -> u32 { unsafe { mem::transmute(Foo(3)) } }
-   |                                           ^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
-   = help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
-   = note: `transmute` is only allowed in constants and statics for now
-
-error[E0658]: `transmute` is not allowed in constant functions
-  --> $DIR/feature-gate-const_fn_transmute.rs:11:53
-   |
-LL | const fn transmute_fn_intrinsic() -> u32 { unsafe { std::intrinsics::transmute(Foo(3)) } }
-   |                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
-   = help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
-   = note: `transmute` is only allowed in constants and statics for now
-
-error[E0658]: `transmute` is not allowed in constant functions
-  --> $DIR/feature-gate-const_fn_transmute.rs:14:58
-   |
-LL | const fn transmute_fn_core_intrinsic() -> u32 { unsafe { core::intrinsics::transmute(Foo(3)) } }
-   |                                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
-   = help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
-   = note: `transmute` is only allowed in constants and statics for now
-
-error[E0658]: `transmute` is not allowed in constant functions
-  --> $DIR/feature-gate-const_fn_transmute.rs:17:48
-   |
-LL | const unsafe fn unsafe_transmute_fn() -> u32 { mem::transmute(Foo(3)) }
-   |                                                ^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
-   = help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
-   = note: `transmute` is only allowed in constants and statics for now
-
-error[E0658]: `transmute` is not allowed in constant functions
-  --> $DIR/feature-gate-const_fn_transmute.rs:20:58
-   |
-LL | const unsafe fn unsafe_transmute_fn_intrinsic() -> u32 { std::intrinsics::transmute(Foo(3)) }
-   |                                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
-   = help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
-   = note: `transmute` is only allowed in constants and statics for now
-
-error[E0658]: `transmute` is not allowed in constant functions
-  --> $DIR/feature-gate-const_fn_transmute.rs:23:63
-   |
-LL | const unsafe fn unsafe_transmute_fn_core_intrinsic() -> u32 { core::intrinsics::transmute(Foo(3)) }
-   |                                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
-   = help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
-   = note: `transmute` is only allowed in constants and statics for now
-
-error[E0658]: `transmute` is not allowed in constant functions
-  --> $DIR/feature-gate-const_fn_transmute.rs:26:39
-   |
-LL | const fn safe_transmute_fn() -> u32 { mem::transmute(Foo(3)) }
-   |                                       ^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
-   = help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
-   = note: `transmute` is only allowed in constants and statics for now
-
-error[E0658]: `transmute` is not allowed in constant functions
-  --> $DIR/feature-gate-const_fn_transmute.rs:30:49
-   |
-LL | const fn safe_transmute_fn_intrinsic() -> u32 { std::intrinsics::transmute(Foo(3)) }
-   |                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
-   = help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
-   = note: `transmute` is only allowed in constants and statics for now
-
-error[E0658]: `transmute` is not allowed in constant functions
-  --> $DIR/feature-gate-const_fn_transmute.rs:34:54
-   |
-LL | const fn safe_transmute_fn_core_intrinsic() -> u32 { core::intrinsics::transmute(Foo(3)) }
-   |                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   |
-   = note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
-   = help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
-   = note: `transmute` is only allowed in constants and statics for now
-
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/feature-gate-const_fn_transmute.rs:26:39
-   |
-LL | const fn safe_transmute_fn() -> u32 { mem::transmute(Foo(3)) }
-   |                                       ^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
-   |
-   = note: consult the function's documentation for information on how to avoid undefined behavior
-
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/feature-gate-const_fn_transmute.rs:30:49
-   |
-LL | const fn safe_transmute_fn_intrinsic() -> u32 { std::intrinsics::transmute(Foo(3)) }
-   |                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
-   |
-   = note: consult the function's documentation for information on how to avoid undefined behavior
-
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/feature-gate-const_fn_transmute.rs:34:54
-   |
-LL | const fn safe_transmute_fn_core_intrinsic() -> u32 { core::intrinsics::transmute(Foo(3)) }
-   |                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
-   |
-   = note: consult the function's documentation for information on how to avoid undefined behavior
-
-error: aborting due to 12 previous errors
-
-Some errors have detailed explanations: E0133, E0658.
-For more information about an error, try `rustc --explain E0133`.
diff --git a/src/test/ui/feature-gates/feature-gate-const_fn_transmute.thir.stderr b/src/test/ui/feature-gates/feature-gate-const_fn_transmute.thir.stderr
new file mode 100644 (file)
index 0000000..04efea0
--- /dev/null
@@ -0,0 +1,118 @@
+error[E0658]: `transmute` is not allowed in constant functions
+  --> $DIR/feature-gate-const_fn_transmute.rs:11:43
+   |
+LL | const fn transmute_fn() -> u32 { unsafe { mem::transmute(Foo(3)) } }
+   |                                           ^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
+   = help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
+   = note: `transmute` is only allowed in constants and statics for now
+
+error[E0658]: `transmute` is not allowed in constant functions
+  --> $DIR/feature-gate-const_fn_transmute.rs:14:53
+   |
+LL | const fn transmute_fn_intrinsic() -> u32 { unsafe { std::intrinsics::transmute(Foo(3)) } }
+   |                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
+   = help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
+   = note: `transmute` is only allowed in constants and statics for now
+
+error[E0658]: `transmute` is not allowed in constant functions
+  --> $DIR/feature-gate-const_fn_transmute.rs:17:58
+   |
+LL | const fn transmute_fn_core_intrinsic() -> u32 { unsafe { core::intrinsics::transmute(Foo(3)) } }
+   |                                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
+   = help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
+   = note: `transmute` is only allowed in constants and statics for now
+
+error[E0658]: `transmute` is not allowed in constant functions
+  --> $DIR/feature-gate-const_fn_transmute.rs:20:48
+   |
+LL | const unsafe fn unsafe_transmute_fn() -> u32 { mem::transmute(Foo(3)) }
+   |                                                ^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
+   = help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
+   = note: `transmute` is only allowed in constants and statics for now
+
+error[E0658]: `transmute` is not allowed in constant functions
+  --> $DIR/feature-gate-const_fn_transmute.rs:23:58
+   |
+LL | const unsafe fn unsafe_transmute_fn_intrinsic() -> u32 { std::intrinsics::transmute(Foo(3)) }
+   |                                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
+   = help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
+   = note: `transmute` is only allowed in constants and statics for now
+
+error[E0658]: `transmute` is not allowed in constant functions
+  --> $DIR/feature-gate-const_fn_transmute.rs:26:63
+   |
+LL | const unsafe fn unsafe_transmute_fn_core_intrinsic() -> u32 { core::intrinsics::transmute(Foo(3)) }
+   |                                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
+   = help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
+   = note: `transmute` is only allowed in constants and statics for now
+
+error[E0658]: `transmute` is not allowed in constant functions
+  --> $DIR/feature-gate-const_fn_transmute.rs:29:39
+   |
+LL | const fn safe_transmute_fn() -> u32 { mem::transmute(Foo(3)) }
+   |                                       ^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
+   = help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
+   = note: `transmute` is only allowed in constants and statics for now
+
+error[E0658]: `transmute` is not allowed in constant functions
+  --> $DIR/feature-gate-const_fn_transmute.rs:33:49
+   |
+LL | const fn safe_transmute_fn_intrinsic() -> u32 { std::intrinsics::transmute(Foo(3)) }
+   |                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
+   = help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
+   = note: `transmute` is only allowed in constants and statics for now
+
+error[E0658]: `transmute` is not allowed in constant functions
+  --> $DIR/feature-gate-const_fn_transmute.rs:37:54
+   |
+LL | const fn safe_transmute_fn_core_intrinsic() -> u32 { core::intrinsics::transmute(Foo(3)) }
+   |                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #53605 <https://github.com/rust-lang/rust/issues/53605> for more information
+   = help: add `#![feature(const_fn_transmute)]` to the crate attributes to enable
+   = note: `transmute` is only allowed in constants and statics for now
+
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/feature-gate-const_fn_transmute.rs:29:39
+   |
+LL | const fn safe_transmute_fn() -> u32 { mem::transmute(Foo(3)) }
+   |                                       ^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/feature-gate-const_fn_transmute.rs:33:49
+   |
+LL | const fn safe_transmute_fn_intrinsic() -> u32 { std::intrinsics::transmute(Foo(3)) }
+   |                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/feature-gate-const_fn_transmute.rs:37:54
+   |
+LL | const fn safe_transmute_fn_core_intrinsic() -> u32 { core::intrinsics::transmute(Foo(3)) }
+   |                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to 12 previous errors
+
+Some errors have detailed explanations: E0133, E0658.
+For more information about an error, try `rustc --explain E0133`.
index 3296a17a0b7ef0416d637b08717b08e3203922d9..d7daaaaa101e7d4e3db0b87a59abf2d02f2d2fda 100644 (file)
@@ -1,7 +1,5 @@
 // Test internal const fn feature gate.
 
-#![feature(const_fn)]
-
 #[rustc_const_unstable(feature="fzzzzzt")] //~ stability attributes may not be used outside
 pub const fn bazinga() {}
 
index 9df926dcf90f5582980ecedb5052bb27e9fb7a9f..48493b786d6495c376ef662b0612dd46ceeb16cb 100644 (file)
@@ -1,5 +1,5 @@
 error[E0734]: stability attributes may not be used outside of the standard library
-  --> $DIR/feature-gate-rustc_const_unstable.rs:5:1
+  --> $DIR/feature-gate-rustc_const_unstable.rs:3:1
    |
 LL | #[rustc_const_unstable(feature="fzzzzzt")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
index a35b18a9c290b89ac1490536dcf2aaeb9c405418..eac2100560a95777f87e56792133b7dc4406d64f 100644 (file)
@@ -6,7 +6,7 @@ LL | thread_local!(static X: u32 = const { 0 });
    |
    = note: see issue #84223 <https://github.com/rust-lang/rust/issues/84223> for more information
    = help: add `#![feature(thread_local_const_init)]` to the crate attributes to enable
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::__thread_local_inner` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 36d7dfdf8f84f2e8ef3d9a4cbf60c658a3d8a432..e934bfcccf540a0cc7a0719a5ee9f05df18e5bf1 100644 (file)
@@ -42,7 +42,7 @@ LL |     expando!(true);
    |
    = note: see issue #29598 <https://github.com/rust-lang/rust/issues/29598> for more information
    = help: add `#![feature(trace_macros)]` to the crate attributes to enable
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `expando` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 5 previous errors
 
index 0c5915149cd6010830f74e3c453e85225ef0a32c..33cd89ad5a7aa244a7a3683fa558a78a82727543 100644 (file)
@@ -6,7 +6,7 @@ LL |     format!(concat!("{foo}"));
    |
    = note: did you intend to capture a variable `foo` from the surrounding scope?
    = note: to avoid ambiguity, `format_args!` cannot capture variables when the format string is expanded from a macro
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `concat` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: there is no argument named `bar`
   --> $DIR/format-args-capture-macro-hygiene.rs:5:13
@@ -16,7 +16,7 @@ LL |     format!(concat!("{ba", "r} {}"), 1);
    |
    = note: did you intend to capture a variable `bar` from the surrounding scope?
    = note: to avoid ambiguity, `format_args!` cannot capture variables when the format string is expanded from a macro
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `concat` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index 0ff478826f728cc8810c4b65404687c15e5a22e3..f4c84e22faaa38e1c3ea0cddb9ac0059e9b11491 100644 (file)
@@ -310,7 +310,7 @@ LL |     println!("{} {:.*} {}", 1, 3.2, 4);
    |
    = note: expected reference `&usize`
               found reference `&{float}`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0308]: mismatched types
   --> $DIR/ifmt-bad-arg.rs:81:35
@@ -320,7 +320,7 @@ LL |     println!("{} {:07$.*} {}", 1, 3.2, 4);
    |
    = note: expected reference `&usize`
               found reference `&{float}`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 36 previous errors
 
index 8bb0d40629f0a35f4ba619bc14cfb9787cb1c73f..d117f3254407bfb83165389ed5249919b6f952aa 100644 (file)
@@ -4,7 +4,7 @@ error: requires at least a format string argument
 LL |     format_args!();
    |     ^^^^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `format_args` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: format argument must be a string literal
   --> $DIR/ifmt-bad-format-args.rs:3:18
index 65b0f4a09b37215ae087f56b3eb6985f34f97479..05305e12c04027c1cf240ed5d7edffc8de27c5a1 100644 (file)
@@ -6,7 +6,7 @@ LL |     format!("{:X}", "3");
    |
    = note: required because of the requirements on the impl of `UpperHex` for `&str`
    = note: required by `std::fmt::UpperHex::fmt`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::__export::format_args` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/foreign-unsafe-fn-called.mir.stderr b/src/test/ui/foreign-unsafe-fn-called.mir.stderr
new file mode 100644 (file)
index 0000000..d3cf5d8
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/foreign-unsafe-fn-called.rs:11:5
+   |
+LL |     test::free();
+   |     ^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0133`.
index abbe462021ed74c14b8a6b0912123e1afcb4473e..de3de286fc93ae6bc80343f56d1e737af46b4116 100644 (file)
@@ -1,3 +1,6 @@
+// revisions: mir thir
+// [thir]compile-flags: -Z thir-unsafeck
+
 mod test {
     extern "C" {
         pub fn free();
diff --git a/src/test/ui/foreign-unsafe-fn-called.stderr b/src/test/ui/foreign-unsafe-fn-called.stderr
deleted file mode 100644 (file)
index afc9632..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/foreign-unsafe-fn-called.rs:8:5
-   |
-LL |     test::free();
-   |     ^^^^^^^^^^^^ call to unsafe function
-   |
-   = note: consult the function's documentation for information on how to avoid undefined behavior
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0133`.
diff --git a/src/test/ui/foreign-unsafe-fn-called.thir.stderr b/src/test/ui/foreign-unsafe-fn-called.thir.stderr
new file mode 100644 (file)
index 0000000..d3cf5d8
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/foreign-unsafe-fn-called.rs:11:5
+   |
+LL |     test::free();
+   |     ^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0133`.
index 53d48bc4f56accc7af93fc3555b96cd3d3e5758b..de90a599e76b79189f94b6718eb8cde298b386ec 100644 (file)
@@ -1,9 +1,6 @@
 error[E0621]: explicit lifetime required in the type of `x`
   --> $DIR/generator-region-requirements.rs:12:51
    |
-LL | fn dangle(x: &mut i32) -> &'static mut i32 {
-   |              -------- help: add explicit lifetime `'static` to the type of `x`: `&'static mut i32`
-...
 LL |             GeneratorState::Complete(c) => return c,
    |                                                   ^ lifetime `'static` required
 
index e69e355ba48e53099b4af9fdeebac414b4d09737..484790501b98e54ede42afa1975ef6dbff5beadc 100644 (file)
@@ -3,14 +3,14 @@
 
 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<T> X for T {
   fn foo<'a, T1: X<Y = T1>>(t : T1) -> T1::Y<'a> {
+    //~^ ERROR missing generics for associated type
+    //~^^ ERROR missing generics for associated type
     t
   }
 }
index 9c6e2ce3e17a36309a219587f09029b3b4a5c980..56b5551cd3fde9d93a403103a4ececb4a57373c2 100644 (file)
@@ -8,36 +8,36 @@ LL | #![feature(generic_associated_types)]
    = note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
 
 error[E0107]: missing generics for associated type `X::Y`
-  --> $DIR/gat-trait-path-missing-lifetime.rs:5:8
+  --> $DIR/gat-trait-path-missing-lifetime.rs:11:20
    |
-LL |   type Y<'a>;
-   |        ^ expected 1 lifetime argument
+LL |   fn foo<'a, T1: X<Y = T1>>(t : T1) -> T1::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
+help: add missing lifetime argument
    |
-LL |   type Y<'a><'a>;
-   |         ^^^^
+LL |   fn foo<'a, T1: X<Y<'a> = T1>>(t : T1) -> T1::Y<'a> {
+   |                    ^^^^^
 
 error[E0107]: missing generics for associated type `X::Y`
-  --> $DIR/gat-trait-path-missing-lifetime.rs:5:8
+  --> $DIR/gat-trait-path-missing-lifetime.rs:11:20
    |
-LL |   type Y<'a>;
-   |        ^ expected 1 lifetime argument
+LL |   fn foo<'a, T1: X<Y = T1>>(t : T1) -> T1::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
+help: add missing lifetime argument
    |
-LL |   type Y<'a><'a>;
-   |         ^^^^
+LL |   fn foo<'a, T1: X<Y<'a> = T1>>(t : T1) -> T1::Y<'a> {
+   |                    ^^^^^
 
 error: aborting due to 2 previous errors; 1 warning emitted
 
index 40ed42c9ce017becbc6190de1be6360032456461..f1af6860284cb5a0ad8988fdcf1898f06e5b00a8 100644 (file)
@@ -3,13 +3,13 @@
 
 trait X {
   type Y<'a>;
-    //~^ ERROR this associated type
-    //~| ERROR this associated type
 }
 
 fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
   //~^ ERROR: lifetime in trait object type must be followed by `+`
   //~| ERROR: parenthesized generic arguments cannot be used
+  //~| ERROR this associated type takes 0 generic arguments but 1 generic argument
+  //~| ERROR this associated type takes 1 lifetime argument but 0 lifetime arguments
   //~| WARNING: trait objects without an explicit `dyn` are deprecated
   //~| WARNING: this was previously accepted by the compiler
 
index 0e95c54d8114ff86e44a7c39db51c14d156bfdd4..400600a086c0c0031f9a81ff6454b5dbb1da31ff 100644 (file)
@@ -1,11 +1,11 @@
 error: lifetime in trait object type must be followed by `+`
-  --> $DIR/gat-trait-path-parenthesised-args.rs:10:29
+  --> $DIR/gat-trait-path-parenthesised-args.rs:8:29
    |
 LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
    |                             ^^
 
 error: parenthesized generic arguments cannot be used in associated type constraints
-  --> $DIR/gat-trait-path-parenthesised-args.rs:10:27
+  --> $DIR/gat-trait-path-parenthesised-args.rs:8:27
    |
 LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
    |                           ^^^^^
@@ -20,7 +20,7 @@ LL | #![feature(generic_associated_types)]
    = note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
 
 warning: trait objects without an explicit `dyn` are deprecated
-  --> $DIR/gat-trait-path-parenthesised-args.rs:10:29
+  --> $DIR/gat-trait-path-parenthesised-args.rs:8:29
    |
 LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
    |                             ^^ help: use `dyn`: `dyn 'a`
@@ -30,10 +30,10 @@ LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
    = note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
 
 error[E0107]: this associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
-  --> $DIR/gat-trait-path-parenthesised-args.rs:5:8
+  --> $DIR/gat-trait-path-parenthesised-args.rs:8:27
    |
-LL |   type Y<'a>;
-   |        ^ expected 1 lifetime argument
+LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
+   |                           ^ expected 1 lifetime argument
    |
 note: associated type defined here, with 1 lifetime parameter: `'a`
   --> $DIR/gat-trait-path-parenthesised-args.rs:5:8
@@ -42,24 +42,18 @@ LL |   type Y<'a>;
    |        ^ --
 help: add missing lifetime argument
    |
-LL | fn foo<'a>(arg: Box<dyn X<Y('a'a) = &'a ()>>) {}
-   |                             ^^
+LL | fn foo<'a>(arg: Box<dyn X<Y('a'a) = &'a ()>>) {}
+   |                             ^^^
 
-error[E0107]: this associated type takes 0 type arguments but 1 type argument was supplied
-  --> $DIR/gat-trait-path-parenthesised-args.rs:5:8
+error[E0107]: this associated type takes 0 generic arguments but 1 generic argument was supplied
+  --> $DIR/gat-trait-path-parenthesised-args.rs:8:27
    |
-LL |     type Y<'a>;
-   |  ________^-
-   | |        |
-   | |        expected 0 type arguments
-LL | |
-LL | |
-LL | | }
-LL | |
-LL | | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
-   | |_________________________________________- help: remove these generics
+LL | fn foo<'a>(arg: Box<dyn X<Y('a) = &'a ()>>) {}
+   |                           ^---- help: remove these generics
+   |                           |
+   |                           expected 0 generic arguments
    |
-note: associated type defined here, with 0 type parameters
+note: associated type defined here, with 0 generic parameters
   --> $DIR/gat-trait-path-parenthesised-args.rs:5:8
    |
 LL |   type Y<'a>;
index 470476bf476a0a0aa4c34e0da13b8d6ffa2c9fc9..c767bef1552ed642e05cb88a1e6b58947571455b 100644 (file)
@@ -3,7 +3,6 @@
 
 trait Provider {
     type A<'a>;
-      //~^ ERROR: missing generics for associated type
 }
 
 impl Provider for () {
@@ -12,6 +11,7 @@ impl Provider for () {
 
 struct Holder<B> {
   inner: Box<dyn Provider<A = B>>,
+  //~^ ERROR: missing generics for associated type
 }
 
 fn main() {
index dd19dd4ad8e8307d7369b0be909e584d207b3d17..2df800d065f4034f73ce644e67619bb4239a5232 100644 (file)
@@ -1,18 +1,18 @@
 error[E0107]: missing generics for associated type `Provider::A`
-  --> $DIR/issue-71176.rs:5:10
+  --> $DIR/issue-71176.rs:13:27
    |
-LL |     type A<'a>;
-   |          ^ expected 1 lifetime argument
+LL |   inner: Box<dyn Provider<A = B>>,
+   |                           ^ expected 1 lifetime argument
    |
 note: associated type defined here, with 1 lifetime parameter: `'a`
   --> $DIR/issue-71176.rs:5:10
    |
 LL |     type A<'a>;
    |          ^ --
-help: use angle brackets to add missing lifetime argument
+help: add missing lifetime argument
    |
-LL |     type A<'a><'a>;
-   |           ^^^^
+LL |   inner: Box<dyn Provider<A<'a> = B>>,
+   |                           ^^^^^
 
 error: aborting due to previous error
 
index 9643c82db773257f08e6172a6fd2726303517780..3db3c38216aaab56049e4d01c49c29631e1b1d6c 100644 (file)
@@ -5,7 +5,6 @@ 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>;
 }
@@ -36,6 +35,7 @@ fn get_sub<'a>(&'a mut self) -> Self::SubType<'a> {
 
 fn main() {
     let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0));
-    //~^ ERROR the trait `SuperTrait` cannot be made into an object
-    //~^^ ERROR the trait `SuperTrait` cannot be made into an object
+      //~^ ERROR missing generics for associated type
+      //~^^ ERROR the trait
+      //~| ERROR the trait
 }
index d31560f12f0bb81af8669081e159e5a37f576bc6..d9829e59605588648fc506ac57307decc4c2ef68 100644 (file)
@@ -8,23 +8,23 @@ LL | #![feature(generic_associated_types)]
    = note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
 
 error[E0107]: missing generics for associated type `SuperTrait::SubType`
-  --> $DIR/issue-76535.rs:7:10
+  --> $DIR/issue-76535.rs:37:33
    |
-LL |     type SubType<'a>: SubTrait;
-   |          ^^^^^^^ expected 1 lifetime argument
+LL |     let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0));
+   |                                 ^^^^^^^ 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
+help: add missing lifetime argument
    |
-LL |     type SubType<'a><'a>: SubTrait;
-   |                 ^^^^
+LL |     let sub: Box<dyn SuperTrait<SubType<'a> = SubStruct>> = Box::new(SuperStruct::new(0));
+   |                                 ^^^^^^^^^^^
 
 error[E0038]: the trait `SuperTrait` cannot be made into an object
-  --> $DIR/issue-76535.rs:38:14
+  --> $DIR/issue-76535.rs:37:14
    |
 LL |     let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0));
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object
@@ -39,7 +39,7 @@ LL |     type SubType<'a>: SubTrait;
    |          ^^^^^^^ ...because it contains the generic associated type `SubType`
 
 error[E0038]: the trait `SuperTrait` cannot be made into an object
-  --> $DIR/issue-76535.rs:38:57
+  --> $DIR/issue-76535.rs:37:57
    |
 LL |     let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0));
    |                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SuperTrait` cannot be made into an object
index 4e47d3c665505a48d597513201637262fda48fcb..310dd51ea0c827d667eb49e6119176ba86587735 100644 (file)
@@ -3,11 +3,11 @@
 
 trait CollectionFamily {
     type Member<T>;
-         //~^ ERROR: missing generics for associated type
 }
 fn floatify() {
     Box::new(Family) as &dyn CollectionFamily<Member=usize>
-    //~^ the trait `CollectionFamily` cannot be made into an object
+    //~^ ERROR: missing generics for associated type
+    //~| ERROR: the trait `CollectionFamily` cannot be made into an object
 }
 
 struct Family;
index c9febfb59af62126ceb93b815cef6df9b55ce35a..0a231d22b62681407ffb3ece1f1e98da43257ee7 100644 (file)
@@ -1,21 +1,21 @@
 error[E0107]: missing generics for associated type `CollectionFamily::Member`
-  --> $DIR/issue-78671.rs:5:10
+  --> $DIR/issue-78671.rs:8:47
    |
-LL |     type Member<T>;
-   |          ^^^^^^ expected 1 type argument
+LL |     Box::new(Family) as &dyn CollectionFamily<Member=usize>
+   |                                               ^^^^^^ expected 1 generic argument
    |
-note: associated type defined here, with 1 type parameter: `T`
+note: associated type defined here, with 1 generic parameter: `T`
   --> $DIR/issue-78671.rs:5:10
    |
 LL |     type Member<T>;
    |          ^^^^^^ -
-help: use angle brackets to add missing type argument
+help: add missing generic argument
    |
-LL |     type Member<T><T>;
-   |                ^^^
+LL |     Box::new(Family) as &dyn CollectionFamily<Member<T>=usize>
+   |                                               ^^^^^^^^^
 
 error[E0038]: the trait `CollectionFamily` cannot be made into an object
-  --> $DIR/issue-78671.rs:9:25
+  --> $DIR/issue-78671.rs:8:25
    |
 LL |     Box::new(Family) as &dyn CollectionFamily<Member=usize>
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `CollectionFamily` cannot be made into an object
index b2ba3c24abbe1d7cb90a545bb452173283cd8e2c..216e426ada265da691b21e5bd957feb802fcb9e2 100644 (file)
@@ -19,7 +19,6 @@ fn t(&'a self) -> &'a T {
 
 trait MapLike<K, V> {
     type VRefCont<'a>: RefCont<'a, V>;
-    //~^ ERROR missing generics
     fn get<'a>(&'a self, key: &K) -> Option<Self::VRefCont<'a>>;
 }
 
@@ -42,6 +41,7 @@ fn get<'a>(&self, _: &K) -> Option<Box<V>> {
 fn main() {
     let m = Box::new(std::collections::BTreeMap::<u8, u8>::new())
         as Box<dyn MapLike<u8, u8, VRefCont = dyn RefCont<'_, u8>>>;
-    //~^^ the trait `MapLike` cannot be made into an object
-    //~^^ the trait `MapLike` cannot be made into an object
+      //~^ ERROR missing generics for associated type
+      //~^^ ERROR the trait
+      //~^^^^ ERROR the trait
 }
index 4973ae19729acd6771b482f8086b271db27d003d..11b4a519d51883764b2d79ea30cdc9ee480a5bc5 100644 (file)
@@ -1,21 +1,21 @@
 error[E0107]: missing generics for associated type `MapLike::VRefCont`
-  --> $DIR/issue-79422.rs:21:10
+  --> $DIR/issue-79422.rs:43:36
    |
-LL |     type VRefCont<'a>: RefCont<'a, V>;
-   |          ^^^^^^^^ expected 1 lifetime argument
+LL |         as Box<dyn MapLike<u8, u8, VRefCont = dyn RefCont<'_, u8>>>;
+   |                                    ^^^^^^^^ 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
+help: add missing lifetime argument
    |
-LL |     type VRefCont<'a><'a>: RefCont<'a, V>;
-   |                  ^^^^
+LL |         as Box<dyn MapLike<u8, u8, VRefCont<'a> = dyn RefCont<'_, u8>>>;
+   |                                    ^^^^^^^^^^^^
 
 error[E0038]: the trait `MapLike` cannot be made into an object
-  --> $DIR/issue-79422.rs:44:12
+  --> $DIR/issue-79422.rs:43:12
    |
 LL |         as Box<dyn MapLike<u8, u8, VRefCont = dyn RefCont<'_, u8>>>;
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` cannot be made into an object
@@ -30,7 +30,7 @@ LL |     type VRefCont<'a>: RefCont<'a, V>;
    |          ^^^^^^^^ ...because it contains the generic associated type `VRefCont`
 
 error[E0038]: the trait `MapLike` cannot be made into an object
-  --> $DIR/issue-79422.rs:43:13
+  --> $DIR/issue-79422.rs:42:13
    |
 LL |     let m = Box::new(std::collections::BTreeMap::<u8, u8>::new())
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `MapLike` cannot be made into an object
index 17f9387e29204cf9019f6cb016ef80314ba6d948..412a9f8257c8ae284ccc62792151ac8b70a77812 100644 (file)
@@ -4,7 +4,6 @@
 trait Monad {
     type Unwrapped;
     type Wrapped<B>;
-         //~^ ERROR: missing generics for associated type `Monad::Wrapped`
 
     fn bind<B, F>(self, f: F) -> Self::Wrapped<B> {
         todo!()
@@ -15,6 +14,7 @@ fn join<MOuter, MInner, A>(outer: MOuter) -> MOuter::Wrapped<A>
 where
     MOuter: Monad<Unwrapped = MInner>,
     MInner: Monad<Unwrapped = A, Wrapped = MOuter::Wrapped<A>>,
+    //~^ ERROR: missing generics for associated type `Monad::Wrapped`
 {
     outer.bind(|inner| inner)
 }
index 58eeb43f70d6637c590f33115f1d5262c205804f..b7a0ef0a6d674a68b952d868130de5b9f5d819bd 100644 (file)
@@ -1,18 +1,18 @@
 error[E0107]: missing generics for associated type `Monad::Wrapped`
-  --> $DIR/issue-79636-1.rs:6:10
+  --> $DIR/issue-79636-1.rs:16:34
    |
-LL |     type Wrapped<B>;
-   |          ^^^^^^^ expected 1 type argument
+LL |     MInner: Monad<Unwrapped = A, Wrapped = MOuter::Wrapped<A>>,
+   |                                  ^^^^^^^ expected 1 generic argument
    |
-note: associated type defined here, with 1 type parameter: `B`
+note: associated type defined here, with 1 generic parameter: `B`
   --> $DIR/issue-79636-1.rs:6:10
    |
 LL |     type Wrapped<B>;
    |          ^^^^^^^ -
-help: use angle brackets to add missing type argument
+help: add missing generic argument
    |
-LL |     type Wrapped<B><B>;
-   |                 ^^^
+LL |     MInner: Monad<Unwrapped = A, Wrapped<B> = MOuter::Wrapped<A>>,
+   |                                  ^^^^^^^^^^
 
 error: aborting due to previous error
 
index 5a6542193752b51cde26561c2a9b4ad9a90a56cc..ef39378e78d68a3f37b4277903bca9402b1044a0 100644 (file)
@@ -3,7 +3,6 @@
 
 trait SomeTrait {
     type Wrapped<A>: SomeTrait;
-         //~^ ERROR: missing generics for associated type `SomeTrait::Wrapped`
 
     fn f() -> ();
 }
@@ -11,6 +10,7 @@ trait SomeTrait {
 fn program<W>() -> ()
 where
     W: SomeTrait<Wrapped = W>,
+    //~^ ERROR: missing generics for associated type `SomeTrait::Wrapped`
 {
     return W::f();
 }
index d5e3c56ebb9ef928bb57e4de4ed6c42ec9824054..d5ba1aaeed5e3863a2a8037052432c624b694afd 100644 (file)
@@ -1,18 +1,18 @@
 error[E0107]: missing generics for associated type `SomeTrait::Wrapped`
-  --> $DIR/issue-79636-2.rs:5:10
+  --> $DIR/issue-79636-2.rs:12:18
    |
-LL |     type Wrapped<A>: SomeTrait;
-   |          ^^^^^^^ expected 1 type argument
+LL |     W: SomeTrait<Wrapped = W>,
+   |                  ^^^^^^^ expected 1 generic argument
    |
-note: associated type defined here, with 1 type parameter: `A`
+note: associated type defined here, with 1 generic parameter: `A`
   --> $DIR/issue-79636-2.rs:5:10
    |
 LL |     type Wrapped<A>: SomeTrait;
    |          ^^^^^^^ -
-help: use angle brackets to add missing type argument
+help: add missing generic argument
    |
-LL |     type Wrapped<A><A>: SomeTrait;
-   |                 ^^^
+LL |     W: SomeTrait<Wrapped<A> = W>,
+   |                  ^^^^^^^^^^
 
 error: aborting due to previous error
 
index ea65f05de23d74ee763cbb38cbcccbfaa0396322..fd81804f234e51797bfa2ccb5e4cca26eeaedd75 100644 (file)
@@ -8,7 +8,6 @@ struct E<T> {
 
 trait TestMut {
     type Output<'a>;
-      //~^ ERROR missing generics
     fn test_mut<'a>(&'a mut self) -> Self::Output<'a>;
 }
 
@@ -23,6 +22,7 @@ fn test_mut<'a>(&'a mut self) -> Self::Output<'a> {
 }
 
 fn test_simpler<'a>(dst: &'a mut impl TestMut<Output = &'a mut f32>)
+  //~^ ERROR missing generics for associated type
 {
     for n in 0i16..100 {
         *dst.test_mut() = n.into();
index 5398920fafdb03ed7249ac34734294b2bf3efd95..31483ff0cd63d58b9996c852dffa05c6853b0bf1 100644 (file)
@@ -1,18 +1,18 @@
 error[E0107]: missing generics for associated type `TestMut::Output`
-  --> $DIR/issue-80433.rs:10:10
+  --> $DIR/issue-80433.rs:24:47
    |
-LL |     type Output<'a>;
-   |          ^^^^^^ expected 1 lifetime argument
+LL | fn test_simpler<'a>(dst: &'a mut impl TestMut<Output = &'a mut f32>)
+   |                                               ^^^^^^ 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
+help: add missing lifetime argument
    |
-LL |     type Output<'a><'a>;
-   |                ^^^^
+LL | fn test_simpler<'a>(dst: &'a mut impl TestMut<Output<'a> = &'a mut f32>)
+   |                                               ^^^^^^^^^^
 
 error: aborting due to previous error
 
index 934870afc119cb7812105eee52379007acd59eae..b5512ee6d6290bc2e3eaecf8837074ac138a6854 100644 (file)
@@ -12,10 +12,10 @@ trait B {
 }
 trait C {
     type DType<T>: D<T, CType = Self>;
-    //~^ ERROR: missing generics for associated type `C::DType` [E0107]
 }
 trait D<T> {
     type CType: C<DType = Self>;
+    //~^ ERROR missing generics for associated type
 }
 
 fn main() {}
index 75f68cd3148930862f44379c4b8032274c083936..4a7b96db30a9b9a705b4a8848d7348853c9ecf78 100644 (file)
@@ -1,18 +1,18 @@
 error[E0107]: missing generics for associated type `C::DType`
-  --> $DIR/issue-81712-cyclic-traits.rs:14:10
+  --> $DIR/issue-81712-cyclic-traits.rs:17:19
    |
-LL |     type DType<T>: D<T, CType = Self>;
-   |          ^^^^^ expected 1 type argument
+LL |     type CType: C<DType = Self>;
+   |                   ^^^^^ expected 1 generic argument
    |
-note: associated type defined here, with 1 type parameter: `T`
+note: associated type defined here, with 1 generic parameter: `T`
   --> $DIR/issue-81712-cyclic-traits.rs:14:10
    |
 LL |     type DType<T>: D<T, CType = Self>;
    |          ^^^^^ -
-help: use angle brackets to add missing type argument
+help: add missing generic argument
    |
-LL |     type DType<T><T>: D<T, CType = Self>;
-   |               ^^^
+LL |     type CType: C<DType<T> = Self>;
+   |                   ^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/generic-associated-types/issue-81862.rs b/src/test/ui/generic-associated-types/issue-81862.rs
new file mode 100644 (file)
index 0000000..02f843b
--- /dev/null
@@ -0,0 +1,13 @@
+#![allow(incomplete_features)]
+#![feature(generic_associated_types)]
+
+trait StreamingIterator {
+    type Item<'a>;
+    fn next(&mut self) -> Option<Self::Item>;
+    //~^ ERROR missing generics for associated type
+}
+
+fn main() {}
+
+// call stack from back to front:
+// create_substs_for_assoc_ty -> qpath_to_ty -> res_to_ty -> ast_ty_to_ty -> ty_of_fn
diff --git a/src/test/ui/generic-associated-types/issue-81862.stderr b/src/test/ui/generic-associated-types/issue-81862.stderr
new file mode 100644 (file)
index 0000000..d7b9041
--- /dev/null
@@ -0,0 +1,19 @@
+error[E0107]: missing generics for associated type `StreamingIterator::Item`
+  --> $DIR/issue-81862.rs:6:40
+   |
+LL |     fn next(&mut self) -> Option<Self::Item>;
+   |                                        ^^^^ expected 1 lifetime argument
+   |
+note: associated type defined here, with 1 lifetime parameter: `'a`
+  --> $DIR/issue-81862.rs:5:10
+   |
+LL |     type Item<'a>;
+   |          ^^^^ --
+help: add missing lifetime argument
+   |
+LL |     fn next(&mut self) -> Option<Self::Item<'_>>;
+   |                                        ^^^^^^^^
+
+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/missing_lifetime_args.rs b/src/test/ui/generic-associated-types/missing_lifetime_args.rs
new file mode 100644 (file)
index 0000000..de24361
--- /dev/null
@@ -0,0 +1,23 @@
+#![feature(generic_associated_types)]
+//~^ WARNING the feature `generic_associated_types`
+
+trait X {
+    type Y<'a, 'b>;
+}
+
+struct Foo<'a, 'b, 'c> {
+    a: &'a u32,
+    b: &'b str,
+    c: &'c str,
+}
+
+fn foo<'c, 'd>(_arg: Box<dyn X<Y = (&'c u32, &'d u32)>>) {}
+//~^ ERROR missing generics for associated type
+
+fn bar<'a, 'b, 'c>(_arg: Foo<'a, 'b>) {}
+//~^ ERROR this struct takes 3 lifetime arguments but 2 lifetime
+
+fn f<'a>(_arg: Foo<'a>) {}
+//~^ ERROR this struct takes 3 lifetime arguments but 1 lifetime
+
+fn main() {}
diff --git a/src/test/ui/generic-associated-types/missing_lifetime_args.stderr b/src/test/ui/generic-associated-types/missing_lifetime_args.stderr
new file mode 100644 (file)
index 0000000..7382959
--- /dev/null
@@ -0,0 +1,64 @@
+warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
+  --> $DIR/missing_lifetime_args.rs:1:12
+   |
+LL | #![feature(generic_associated_types)]
+   |            ^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: `#[warn(incomplete_features)]` on by default
+   = note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
+
+error[E0107]: missing generics for associated type `X::Y`
+  --> $DIR/missing_lifetime_args.rs:14:32
+   |
+LL | fn foo<'c, 'd>(_arg: Box<dyn X<Y = (&'c u32, &'d u32)>>) {}
+   |                                ^ expected 2 lifetime arguments
+   |
+note: associated type defined here, with 2 lifetime parameters: `'a`, `'b`
+  --> $DIR/missing_lifetime_args.rs:5:10
+   |
+LL |     type Y<'a, 'b>;
+   |          ^ --  --
+help: add missing lifetime arguments
+   |
+LL | fn foo<'c, 'd>(_arg: Box<dyn X<Y<'c, 'd> = (&'c u32, &'d u32)>>) {}
+   |                                ^^^^^^^^^
+
+error[E0107]: this struct takes 3 lifetime arguments but 2 lifetime arguments were supplied
+  --> $DIR/missing_lifetime_args.rs:17:26
+   |
+LL | fn bar<'a, 'b, 'c>(_arg: Foo<'a, 'b>) {}
+   |                          ^^^ --  -- supplied 2 lifetime arguments
+   |                          |
+   |                          expected 3 lifetime arguments
+   |
+note: struct defined here, with 3 lifetime parameters: `'a`, `'b`, `'c`
+  --> $DIR/missing_lifetime_args.rs:8:8
+   |
+LL | struct Foo<'a, 'b, 'c> {
+   |        ^^^ --  --  --
+help: add missing lifetime argument
+   |
+LL | fn bar<'a, 'b, 'c>(_arg: Foo<'a, 'b, 'a>) {}
+   |                                    ^^^^
+
+error[E0107]: this struct takes 3 lifetime arguments but 1 lifetime argument was supplied
+  --> $DIR/missing_lifetime_args.rs:20:16
+   |
+LL | fn f<'a>(_arg: Foo<'a>) {}
+   |                ^^^ -- supplied 1 lifetime argument
+   |                |
+   |                expected 3 lifetime arguments
+   |
+note: struct defined here, with 3 lifetime parameters: `'a`, `'b`, `'c`
+  --> $DIR/missing_lifetime_args.rs:8:8
+   |
+LL | struct Foo<'a, 'b, 'c> {
+   |        ^^^ --  --  --
+help: add missing lifetime arguments
+   |
+LL | fn f<'a>(_arg: Foo<'a, 'b, 'c>) {}
+   |                      ^^^^^^^^
+
+error: aborting due to 3 previous errors; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0107`.
diff --git a/src/test/ui/generic-associated-types/missing_lifetime_const.rs b/src/test/ui/generic-associated-types/missing_lifetime_const.rs
new file mode 100644 (file)
index 0000000..37cb7ca
--- /dev/null
@@ -0,0 +1,13 @@
+#![feature(generic_associated_types)]
+//~^ WARNING the feature
+
+trait Foo {
+    type Assoc<'a, const N: usize>;
+}
+
+fn foo<T: Foo>() {
+    let _: <T as Foo>::Assoc<3>;
+      //~^ ERROR  this associated type
+}
+
+fn main() {}
diff --git a/src/test/ui/generic-associated-types/missing_lifetime_const.stderr b/src/test/ui/generic-associated-types/missing_lifetime_const.stderr
new file mode 100644 (file)
index 0000000..6c66312
--- /dev/null
@@ -0,0 +1,28 @@
+warning: the feature `generic_associated_types` is incomplete and may not be safe to use and/or cause compiler crashes
+  --> $DIR/missing_lifetime_const.rs:1:12
+   |
+LL | #![feature(generic_associated_types)]
+   |            ^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: `#[warn(incomplete_features)]` on by default
+   = note: see issue #44265 <https://github.com/rust-lang/rust/issues/44265> for more information
+
+error[E0107]: this associated type takes 1 lifetime argument but 0 lifetime arguments were supplied
+  --> $DIR/missing_lifetime_const.rs:9:24
+   |
+LL |     let _: <T as Foo>::Assoc<3>;
+   |                        ^^^^^ expected 1 lifetime argument
+   |
+note: associated type defined here, with 1 lifetime parameter: `'a`
+  --> $DIR/missing_lifetime_const.rs:5:10
+   |
+LL |     type Assoc<'a, const N: usize>;
+   |          ^^^^^ --
+help: add missing lifetime argument
+   |
+LL |     let _: <T as Foo>::Assoc<'a, 3>;
+   |                              ^^^
+
+error: aborting due to previous error; 1 warning emitted
+
+For more information about this error, try `rustc --explain E0107`.
index 9d7ef88b7679d19140693dbc781828ecdb4e8e90..3f92c031e18d003ad4fc65587889411bd71fdeec 100644 (file)
@@ -12,9 +12,9 @@ trait Foo {
     type FOk<T> = Self::E<'static, T>;
     type FErr1 = Self::E<'static, 'static>;
     //~^ ERROR this associated type takes 1 lifetime argument but 2 lifetime arguments were supplied
-    //~| ERROR this associated type takes 1 type argument but 0 type arguments were supplied
+    //~| ERROR this associated type takes 1
     type FErr2<T> = Self::E<'static, T, u32>;
-    //~^ ERROR this associated type takes 1 type argument but 2 type arguments were supplied
+    //~^ ERROR this associated type takes 1
 }
 
 fn main() {}
index d021889c08424c1d8674ec5ace5f451df0d1f21e..b6f600964c9a398eba8a200b392662ba8801a092 100644 (file)
@@ -2,7 +2,7 @@ error[E0107]: this associated type takes 1 lifetime argument but 2 lifetime argu
   --> $DIR/parameter_number_and_kind.rs:13:24
    |
 LL |     type FErr1 = Self::E<'static, 'static>;
-   |                        ^        --------- help: remove this lifetime argument
+   |                        ^          ------- help: remove this lifetime argument
    |                        |
    |                        expected 1 lifetime argument
    |
@@ -12,31 +12,31 @@ note: associated type defined here, with 1 lifetime parameter: `'a`
 LL |     type E<'a, T>;
    |          ^ --
 
-error[E0107]: this associated type takes 1 type argument but 0 type arguments were supplied
+error[E0107]: this associated type takes 1 generic argument but 0 generic arguments were supplied
   --> $DIR/parameter_number_and_kind.rs:13:24
    |
 LL |     type FErr1 = Self::E<'static, 'static>;
-   |                        ^ expected 1 type argument
+   |                        ^ expected 1 generic argument
    |
-note: associated type defined here, with 1 type parameter: `T`
+note: associated type defined here, with 1 generic parameter: `T`
   --> $DIR/parameter_number_and_kind.rs:10:10
    |
 LL |     type E<'a, T>;
    |          ^     -
-help: add missing type argument
+help: add missing generic argument
    |
 LL |     type FErr1 = Self::E<'static, 'static, T>;
    |                                          ^^^
 
-error[E0107]: this associated type takes 1 type argument but 2 type arguments were supplied
+error[E0107]: this associated type takes 1 generic argument but 2 generic arguments were supplied
   --> $DIR/parameter_number_and_kind.rs:16:27
    |
 LL |     type FErr2<T> = Self::E<'static, T, u32>;
-   |                           ^           ----- help: remove this type argument
+   |                           ^             --- help: remove this generic argument
    |                           |
-   |                           expected 1 type argument
+   |                           expected 1 generic argument
    |
-note: associated type defined here, with 1 type parameter: `T`
+note: associated type defined here, with 1 generic parameter: `T`
   --> $DIR/parameter_number_and_kind.rs:10:10
    |
 LL |     type E<'a, T>;
index 2d38770bcdff84acd99a9cb4d0e222ea013057bf..d7a0ef4916a1820563d2ad14c3e1661eca5afa31 100644 (file)
@@ -3,12 +3,12 @@
 
 trait X {
     type Y<'a>;
-      //~^ ERROR this associated type
-      //~| ERROR this associated type
 }
 
 const _: () = {
   fn f2<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
+      //~^ ERROR this associated type takes 1 lifetime argument but 0 lifetime arguments
+      //~| ERROR this associated type takes 0 generic arguments but 1 generic argument
 };
 
 fn main() {}
index 60b8fb9bcaa2314afc466828023eb6d76090d8c0..5685e5208c6d8e00afffa54ab4478b26c78c7b8e 100644 (file)
@@ -8,10 +8,10 @@ LL | #![feature(generic_associated_types)]
    = note: see issue #44265 <https://github.com/rust-lang/rust/issues/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
+  --> $DIR/trait-path-type-error-once-implemented.rs:9:29
    |
-LL |     type Y<'a>;
-   |          ^ expected 1 lifetime argument
+LL |   fn f2<'a>(arg : Box<dyn X<Y<1> = &'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
@@ -20,25 +20,18 @@ LL |     type Y<'a>;
    |          ^ --
 help: add missing lifetime argument
    |
-LL |   fn f2<'a>(arg : Box<dyn X<Y<'a1> = &'a ()>>) {}
-   |                               ^^
+LL |   fn f2<'a>(arg : Box<dyn X<Y<'a1> = &'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
+error[E0107]: this associated type takes 0 generic arguments but 1 generic argument was supplied
+  --> $DIR/trait-path-type-error-once-implemented.rs:9:29
+   |
+LL |   fn f2<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
+   |                             ^--- help: remove these generics
+   |                             |
+   |                             expected 0 generic arguments
    |
-LL |       type Y<'a>;
-   |  __________^-
-   | |          |
-   | |          expected 0 const arguments
-LL | |
-LL | |
-LL | | }
-LL | |
-LL | | const _: () = {
-LL | |   fn f2<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {}
-   | |________________________________- help: remove these generics
-   |
-note: associated type defined here, with 0 const parameters
+note: associated type defined here, with 0 generic parameters
   --> $DIR/trait-path-type-error-once-implemented.rs:5:10
    |
 LL |     type Y<'a>;
index 13b765dfa57191e8d1aa59ea89233afa283c56b8..aec878625661bef9bb668b8d7f0300515432dc84 100644 (file)
@@ -1,24 +1,18 @@
 error[E0621]: explicit lifetime required in the type of `x`
   --> $DIR/projection-type-lifetime-mismatch.rs:18:5
    |
-LL | fn f(x: &impl for<'a> X<Y<'a> = &'a ()>) -> &'static () {
-   |         ------------------------------- help: add explicit lifetime `'static` to the type of `x`: `&'static impl for<'a> X<Y<'a> = &'a ()>`
 LL |     x.m()
    |     ^^^^^ lifetime `'static` required
 
 error[E0621]: explicit lifetime required in the type of `x`
   --> $DIR/projection-type-lifetime-mismatch.rs:23:5
    |
-LL | fn g<T: for<'a> X<Y<'a> = &'a ()>>(x: &T) -> &'static () {
-   |                                       -- help: add explicit lifetime `'static` to the type of `x`: `&'static T`
 LL |     x.m()
    |     ^^^^^ lifetime `'static` required
 
 error[E0621]: explicit lifetime required in the type of `x`
   --> $DIR/projection-type-lifetime-mismatch.rs:28:5
    |
-LL | fn h(x: &()) -> &'static () {
-   |         --- help: add explicit lifetime `'static` to the type of `x`: `&'static ()`
 LL |     x.m()
    |     ^^^^^ lifetime `'static` required
 
index c42ce602e998799cd9029858037d2f851d584615..23a5d1525d9953a64cc610fe31e251dd1e34c15f 100644 (file)
@@ -28,17 +28,17 @@ fn new<U>(x: isize, _: U) -> S2 {
 
 fn foo<'a>() {
     let _ = S::new::<isize,f64>(1, 1.0);
-    //~^ ERROR this associated function takes 1 type argument but 2 type arguments were supplied
+    //~^ ERROR this associated function takes 1
 
     let _ = S::<'a,isize>::new::<f64>(1, 1.0);
     //~^ ERROR this struct takes 0 lifetime arguments but 1 lifetime argument was supplied
 
     let _: S2 = Trait::new::<isize,f64>(1, 1.0);
-    //~^ ERROR this associated function takes 1 type argument but 2 type arguments were supplied
+    //~^ ERROR this associated function takes 1
 
     let _: S2 = Trait::<'a,isize>::new::<f64,f64>(1, 1.0);
     //~^ ERROR this trait takes 0 lifetime arguments but 1 lifetime argument was supplied
-    //~| ERROR this associated function takes 1 type argument but 2 type arguments were supplied
+    //~| ERROR this associated function takes 1
 }
 
 fn main() {}
index dd96856e563243ecd1b2b878cf19861a46f86b24..aee2b60159f10338d16b48a62d8c72b81c100075 100644 (file)
@@ -1,12 +1,12 @@
-error[E0107]: this associated function takes 1 type argument but 2 type arguments were supplied
+error[E0107]: this associated function takes 1 generic argument but 2 generic arguments were supplied
   --> $DIR/bad-mid-path-type-params.rs:30:16
    |
 LL |     let _ = S::new::<isize,f64>(1, 1.0);
-   |                ^^^        ---- help: remove this type argument
+   |                ^^^         --- help: remove this generic argument
    |                |
-   |                expected 1 type argument
+   |                expected 1 generic argument
    |
-note: associated function defined here, with 1 type parameter: `U`
+note: associated function defined here, with 1 generic parameter: `U`
   --> $DIR/bad-mid-path-type-params.rs:6:8
    |
 LL |     fn new<U>(x: T, _: U) -> S<T> {
@@ -16,7 +16,7 @@ error[E0107]: this struct takes 0 lifetime arguments but 1 lifetime argument was
   --> $DIR/bad-mid-path-type-params.rs:33:13
    |
 LL |     let _ = S::<'a,isize>::new::<f64>(1, 1.0);
-   |             ^   --- help: remove this lifetime argument
+   |             ^   -- help: remove this lifetime argument
    |             |
    |             expected 0 lifetime arguments
    |
@@ -26,15 +26,15 @@ note: struct defined here, with 0 lifetime parameters
 LL | struct S<T> {
    |        ^
 
-error[E0107]: this associated function takes 1 type argument but 2 type arguments were supplied
+error[E0107]: this associated function takes 1 generic argument but 2 generic arguments were supplied
   --> $DIR/bad-mid-path-type-params.rs:36:24
    |
 LL |     let _: S2 = Trait::new::<isize,f64>(1, 1.0);
-   |                        ^^^        ---- help: remove this type argument
+   |                        ^^^         --- help: remove this generic argument
    |                        |
-   |                        expected 1 type argument
+   |                        expected 1 generic argument
    |
-note: associated function defined here, with 1 type parameter: `U`
+note: associated function defined here, with 1 generic parameter: `U`
   --> $DIR/bad-mid-path-type-params.rs:14:8
    |
 LL |     fn new<U>(x: T, y: U) -> Self;
@@ -44,7 +44,7 @@ error[E0107]: this trait takes 0 lifetime arguments but 1 lifetime argument was
   --> $DIR/bad-mid-path-type-params.rs:39:17
    |
 LL |     let _: S2 = Trait::<'a,isize>::new::<f64,f64>(1, 1.0);
-   |                 ^^^^^   --- help: remove this lifetime argument
+   |                 ^^^^^   -- help: remove this lifetime argument
    |                 |
    |                 expected 0 lifetime arguments
    |
@@ -54,15 +54,15 @@ note: trait defined here, with 0 lifetime parameters
 LL | trait Trait<T> {
    |       ^^^^^
 
-error[E0107]: this associated function takes 1 type argument but 2 type arguments were supplied
+error[E0107]: this associated function takes 1 generic argument but 2 generic arguments were supplied
   --> $DIR/bad-mid-path-type-params.rs:39:36
    |
 LL |     let _: S2 = Trait::<'a,isize>::new::<f64,f64>(1, 1.0);
-   |                                    ^^^      ---- help: remove this type argument
+   |                                    ^^^       --- help: remove this generic argument
    |                                    |
-   |                                    expected 1 type argument
+   |                                    expected 1 generic argument
    |
-note: associated function defined here, with 1 type parameter: `U`
+note: associated function defined here, with 1 generic parameter: `U`
   --> $DIR/bad-mid-path-type-params.rs:14:8
    |
 LL |     fn new<U>(x: T, y: U) -> Self;
index 0e0d1daec5f313c6167dd28d2f84e9266724e560..2cf7f1d657b187409411943c86c49dee53704a08 100644 (file)
@@ -8,5 +8,5 @@ fn main() {
 
     Bar::<'static, 'static, ()>(&());
     //~^ ERROR this struct takes 1 lifetime argument but 2 lifetime arguments were supplied
-    //~| ERROR this struct takes 0 type arguments but 1 type argument was supplied
+    //~| ERROR this struct takes 0
 }
index ca73b82737d64b406b8333761919e25fef39ec30..45fea925f27cf59433b8f9d06b0eca4dd6b0f908 100644 (file)
@@ -2,7 +2,7 @@ error[E0107]: this struct takes 1 lifetime argument but 2 lifetime arguments wer
   --> $DIR/generic-arg-mismatch-recover.rs:6:5
    |
 LL |     Foo::<'static, 'static, ()>(&0);
-   |     ^^^            --------- help: remove this lifetime argument
+   |     ^^^            ------- help: remove this lifetime argument
    |     |
    |     expected 1 lifetime argument
    |
@@ -16,7 +16,7 @@ error[E0107]: this struct takes 1 lifetime argument but 2 lifetime arguments wer
   --> $DIR/generic-arg-mismatch-recover.rs:9:5
    |
 LL |     Bar::<'static, 'static, ()>(&());
-   |     ^^^            --------- help: remove this lifetime argument
+   |     ^^^            ------- help: remove this lifetime argument
    |     |
    |     expected 1 lifetime argument
    |
@@ -26,15 +26,15 @@ note: struct defined here, with 1 lifetime parameter: `'a`
 LL | struct Bar<'a>(&'a ());
    |        ^^^ --
 
-error[E0107]: this struct takes 0 type arguments but 1 type argument was supplied
+error[E0107]: this struct takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/generic-arg-mismatch-recover.rs:9:5
    |
 LL |     Bar::<'static, 'static, ()>(&());
-   |     ^^^                   ---- help: remove this type argument
+   |     ^^^                     -- help: remove this generic argument
    |     |
-   |     expected 0 type arguments
+   |     expected 0 generic arguments
    |
-note: struct defined here, with 0 type parameters
+note: struct defined here, with 0 generic parameters
   --> $DIR/generic-arg-mismatch-recover.rs:3:8
    |
 LL | struct Bar<'a>(&'a ());
index 01964f652ee090f30bb36b45b1dde405014a43a9..66afbb58ad49027474e8b7701ee577bc8cb14608 100644 (file)
@@ -9,5 +9,5 @@ fn new() -> Foo<A, B, C> {Foo(marker::PhantomData)}
 
 fn main() {
     Foo::<isize>::new();
-    //~^ ERROR this struct takes at least 2 type arguments but only 1 type argument was supplied
+    //~^ ERROR this struct takes at least 2 generic arguments but 1 generic argument
 }
index a8a17876ee0fdab5578fc30c42fc6f3c41c50680..2c7ffde7ddb97bb2ec406442a7a94731c236433b 100644 (file)
@@ -1,17 +1,17 @@
-error[E0107]: this struct takes at least 2 type arguments but only 1 type argument was supplied
+error[E0107]: this struct takes at least 2 generic arguments but 1 generic argument was supplied
   --> $DIR/generic-impl-less-params-with-defaults.rs:11:5
    |
 LL |     Foo::<isize>::new();
-   |     ^^^   ----- supplied 1 type argument
+   |     ^^^   ----- supplied 1 generic argument
    |     |
-   |     expected at least 2 type arguments
+   |     expected at least 2 generic arguments
    |
-note: struct defined here, with at least 2 type parameters: `A`, `B`
+note: struct defined here, with at least 2 generic parameters: `A`, `B`
   --> $DIR/generic-impl-less-params-with-defaults.rs:3:8
    |
 LL | struct Foo<A, B, C = (A, B)>(
    |        ^^^ -  -
-help: add missing type argument
+help: add missing generic argument
    |
 LL |     Foo::<isize, B>::new();
    |                ^^^
index 24c41a9088b994d267dea8bfb82c4e9f90ef5bfb..a283323742a0f8d7cc72f676b36d8f4047f09fee 100644 (file)
@@ -11,5 +11,5 @@ fn new() -> Vec<T, A> {Vec(marker::PhantomData)}
 
 fn main() {
     Vec::<isize, Heap, bool>::new();
-    //~^ ERROR this struct takes at most 2 type arguments but 3 type arguments were supplied
+    //~^ ERROR this struct takes at most 2 generic arguments but 3 generic arguments were supplied
 }
index 8ba86afe91ea0b99c8f454fd632838ebb9545e90..059289533dadc5df608012e2e620df378244d136 100644 (file)
@@ -1,12 +1,12 @@
-error[E0107]: this struct takes at most 2 type arguments but 3 type arguments were supplied
+error[E0107]: this struct takes at most 2 generic arguments but 3 generic arguments were supplied
   --> $DIR/generic-impl-more-params-with-defaults.rs:13:5
    |
 LL |     Vec::<isize, Heap, bool>::new();
-   |     ^^^              ------ help: remove this type argument
+   |     ^^^                ---- help: remove this generic argument
    |     |
-   |     expected at most 2 type arguments
+   |     expected at most 2 generic arguments
    |
-note: struct defined here, with at most 2 type parameters: `T`, `A`
+note: struct defined here, with at most 2 generic parameters: `T`, `A`
   --> $DIR/generic-impl-more-params-with-defaults.rs:5:8
    |
 LL | struct Vec<T, A = Heap>(
index 93f7a24d877418c3689d5ee635785ffd573b296a..7c0836375e38e7e59f4a4bd9606f66239b55edc1 100644 (file)
@@ -2,17 +2,17 @@ error[E0107]: missing generics for struct `Vec`
   --> $DIR/generic-type-less-params-with-defaults.rs:9:12
    |
 LL |     let _: Vec;
-   |            ^^^ expected at least 1 type argument
+   |            ^^^ expected at least 1 generic argument
    |
-note: struct defined here, with at least 1 type parameter: `T`
+note: struct defined here, with at least 1 generic parameter: `T`
   --> $DIR/generic-type-less-params-with-defaults.rs:5:8
    |
 LL | struct Vec<T, A = Heap>(
    |        ^^^ -
-help: use angle brackets to add missing type argument
+help: add missing generic argument
    |
 LL |     let _: Vec<T>;
-   |               ^^^
+   |            ^^^^^^
 
 error: aborting due to previous error
 
index c421774ebbadd1065aec8fe506ec2592406f2137..3dab03297c9df9484977f763b63acd2f18f89962 100644 (file)
@@ -7,5 +7,5 @@ struct Vec<T, A = Heap>(
 
 fn main() {
     let _: Vec<isize, Heap, bool>;
-    //~^ ERROR this struct takes at most 2 type arguments but 3 type arguments were supplied
+    //~^ ERROR this struct takes at most 2 generic arguments but 3 generic arguments
 }
index e331481390b66f1b066cae91762ed654aea907cd..500880cfb867860f7bb5d790a9910661f29a3d9d 100644 (file)
@@ -1,12 +1,12 @@
-error[E0107]: this struct takes at most 2 type arguments but 3 type arguments were supplied
+error[E0107]: this struct takes at most 2 generic arguments but 3 generic arguments were supplied
   --> $DIR/generic-type-more-params-with-defaults.rs:9:12
    |
 LL |     let _: Vec<isize, Heap, bool>;
-   |            ^^^            ------ help: remove this type argument
+   |            ^^^              ---- help: remove this generic argument
    |            |
-   |            expected at most 2 type arguments
+   |            expected at most 2 generic arguments
    |
-note: struct defined here, with at most 2 type parameters: `T`, `A`
+note: struct defined here, with at most 2 generic parameters: `T`, `A`
   --> $DIR/generic-type-more-params-with-defaults.rs:5:8
    |
 LL | struct Vec<T, A = Heap>(
index 2994ca3c7595cacde40c8babbdfebc0104c312a4..ec2ed9926e2aa04539316be7f78ad7d2308783bd 100644 (file)
@@ -4,18 +4,18 @@ mod no_generics {
     type A = Ty;
 
     type B = Ty<'static>;
-    //~^ ERROR this struct takes 0 lifetime arguments but 1 lifetime argument was supplied
+    //~^ ERROR this struct takes 0 lifetime arguments but 1 lifetime argument
     //~| HELP remove these generics
 
     type C = Ty<'static, usize>;
-    //~^ ERROR this struct takes 0 lifetime arguments but 1 lifetime argument was supplied
-    //~| ERROR this struct takes 0 type arguments but 1 type argument was supplied
+    //~^ ERROR this struct takes 0 lifetime arguments but 1 lifetime argument
+    //~| ERROR this struct takes 0 generic arguments but 1 generic argument
     //~| HELP remove this lifetime argument
-    //~| HELP remove this type argument
+    //~| HELP remove this generic argument
 
     type D = Ty<'static, usize, { 0 }>;
-    //~^ ERROR this struct takes 0 lifetime arguments but 1 lifetime argument was supplied
-    //~| ERROR this struct takes 0 generic arguments but 2 generic arguments were supplied
+    //~^ ERROR this struct takes 0 lifetime arguments but 1 lifetime argument
+    //~| ERROR this struct takes 0 generic arguments but 2 generic arguments
     //~| HELP remove this lifetime argument
     //~| HELP remove these generic arguments
 }
@@ -25,37 +25,47 @@ mod type_and_type {
 
     type A = Ty;
     //~^ ERROR missing generics for struct `type_and_type::Ty`
-    //~| HELP use angle brackets
+    //~| HELP add missing
 
     type B = Ty<usize>;
-    //~^ ERROR this struct takes 2 type arguments but only 1 type argument was supplied
-    //~| HELP add missing type argument
+    //~^ ERROR this struct takes 2 generic arguments but 1 generic argument
+    //~| HELP add missing
 
     type C = Ty<usize, String>;
 
     type D = Ty<usize, String, char>;
-    //~^ ERROR this struct takes 2 type arguments but 3 type arguments were supplied
-    //~| HELP remove this type argument
+    //~^ ERROR this struct takes 2 generic arguments but 3 generic arguments
+    //~| HELP remove this
+
+    type E = Ty<>;
+    //~^ ERROR this struct takes 2 generic arguments but 0 generic arguments were supplied
+    //~| HELP add missing
 }
 
 mod lifetime_and_type {
     struct Ty<'a, T>;
 
     type A = Ty;
-    //~^ ERROR missing generics for struct `lifetime_and_type::Ty`
+    //~^ ERROR missing generics for struct
     //~| ERROR missing lifetime specifier
+    //~| HELP add missing
     //~| HELP consider introducing
-    //~| HELP use angle brackets
 
     type B = Ty<'static>;
-    //~^ ERROR this struct takes 1 type argument but 0 type arguments were supplied
-    //~| HELP add missing type argument
+    //~^ ERROR this struct takes 1 generic argument but 0 generic arguments
+    //~| HELP add missing
 
     type C = Ty<usize>;
     //~^ ERROR missing lifetime specifier
     //~| HELP consider introducing
 
     type D = Ty<'static, usize>;
+
+    type E = Ty<>;
+    //~^ ERROR this struct takes 1 generic argument but 0 generic arguments
+    //~| ERROR missing lifetime specifier
+    //~| HELP consider introducing
+    //~| HELP add missing
 }
 
 mod type_and_type_and_type {
@@ -63,19 +73,23 @@ mod type_and_type_and_type {
 
     type A = Ty;
     //~^ ERROR missing generics for struct `type_and_type_and_type::Ty`
-    //~| HELP use angle brackets
+    //~| HELP add missing
 
     type B = Ty<usize>;
-    //~^ ERROR this struct takes at least 2 type arguments but only 1 type argument was supplied
-    //~| HELP add missing type argument
+    //~^ ERROR this struct takes at least 2
+    //~| HELP add missing
 
     type C = Ty<usize, String>;
 
     type D = Ty<usize, String, char>;
 
     type E = Ty<usize, String, char, f64>;
-    //~^ ERROR this struct takes at most 3 type arguments but 4 type arguments were supplied
+    //~^ ERROR this struct takes at most 3
     //~| HELP remove
+
+    type F = Ty<>;
+    //~^ ERROR this struct takes at least 2 generic arguments but 0 generic arguments
+    //~| HELP add missing
 }
 
 // Traits have an implicit `Self` type - these tests ensure we don't accidentally return it
@@ -94,7 +108,7 @@ trait GenericType<A> {
     }
 
     type A = Box<dyn NonGeneric<usize>>;
-    //~^ ERROR this trait takes 0 type arguments but 1 type argument was supplied
+    //~^ ERROR this trait takes 0 generic arguments but 1 generic argument
     //~| HELP remove
 
     type B = Box<dyn GenericLifetime>;
@@ -107,11 +121,171 @@ trait GenericType<A> {
 
     type D = Box<dyn GenericType>;
     //~^ ERROR missing generics for trait `GenericType`
-    //~| HELP use angle brackets
+    //~| HELP add missing
 
     type E = Box<dyn GenericType<String, usize>>;
-    //~^ ERROR this trait takes 1 type argument but 2 type arguments were supplied
+    //~^ ERROR this trait takes 1 generic argument but 2 generic arguments
     //~| HELP remove
+
+    type F = Box<dyn GenericLifetime<>>;
+    //~^ ERROR missing lifetime specifier
+    //~| HELP consider introducing
+
+    type G = Box<dyn GenericType<>>;
+    //~^ ERROR this trait takes 1 generic argument but 0 generic arguments
+    //~| HELP add missing
+}
+
+mod associated_item {
+    mod non_generic {
+        trait NonGenericAT {
+            type AssocTy;
+        }
+
+        type A = Box<dyn NonGenericAT<usize, AssocTy=()>>;
+        //~^ ERROR this trait takes 0 generic arguments but 1 generic argument
+        //~| HELP remove
+    }
+
+    mod lifetime {
+        trait GenericLifetimeAT<'a> {
+            type AssocTy;
+        }
+
+        type A = Box<dyn GenericLifetimeAT<AssocTy=()>>;
+        //~^ ERROR missing lifetime specifier
+        //~| HELP consider introducing
+
+        type B = Box<dyn GenericLifetimeAT<'static, 'static, AssocTy=()>>;
+        //~^ ERROR this trait takes 1 lifetime argument but 2 lifetime arguments were supplied
+        //~| HELP remove
+
+        type C = Box<dyn GenericLifetimeAT<(), AssocTy=()>>;
+        //~^ ERROR missing lifetime specifier
+        //~| HELP consider introducing
+        //~| ERROR this trait takes 0 generic arguments but 1 generic argument
+        //~| HELP remove
+    }
+
+    mod r#type {
+        trait GenericTypeAT<A> {
+            type AssocTy;
+        }
+
+        type A = Box<dyn GenericTypeAT<AssocTy=()>>;
+        //~^ ERROR this trait takes 1 generic argument but 0 generic arguments
+        //~| HELP add missing
+
+        type B = Box<dyn GenericTypeAT<(), (), AssocTy=()>>;
+        //~^ ERROR this trait takes 1 generic argument but 2 generic arguments
+        //~| HELP remove
+
+        type C = Box<dyn GenericTypeAT<'static, AssocTy=()>>;
+        //~^ ERROR this trait takes 1 generic argument but 0 generic arguments
+        //~| HELP add missing
+        //~| ERROR this trait takes 0 lifetime arguments but 1 lifetime argument was supplied
+        //~| HELP remove
+    }
+
+    mod lifetime_and_type {
+        trait GenericLifetimeTypeAT<'a, A> {
+            type AssocTy;
+        }
+
+        type A = Box<dyn GenericLifetimeTypeAT<AssocTy=()>>;
+        //~^ ERROR this trait takes 1 generic argument but 0 generic arguments
+        //~| HELP add missing
+        //~| ERROR missing lifetime specifier
+        //~| HELP consider introducing
+
+        type B = Box<dyn GenericLifetimeTypeAT<'static, AssocTy=()>>;
+        //~^ ERROR this trait takes 1 generic argument but 0 generic arguments were supplied
+        //~| HELP add missing
+
+        type C = Box<dyn GenericLifetimeTypeAT<'static, 'static, AssocTy=()>>;
+        //~^ ERROR this trait takes 1 lifetime argument but 2 lifetime arguments were supplied
+        //~| HELP remove
+        //~| ERROR this trait takes 1 generic argument but 0 generic arguments
+        //~| HELP add missing
+
+        type D = Box<dyn GenericLifetimeTypeAT<(), AssocTy=()>>;
+        //~^ ERROR missing lifetime specifier
+        //~| HELP consider introducing
+
+        type E = Box<dyn GenericLifetimeTypeAT<(), (), AssocTy=()>>;
+        //~^ ERROR missing lifetime specifier
+        //~| HELP consider introducing
+        //~| ERROR this trait takes 1 generic argument but 2 generic arguments
+        //~| HELP remove
+
+        type F = Box<dyn GenericLifetimeTypeAT<'static, 'static, (), AssocTy=()>>;
+        //~^ ERROR this trait takes 1 lifetime argument but 2 lifetime arguments were supplied
+        //~| HELP remove
+
+        type G = Box<dyn GenericLifetimeTypeAT<'static, (), (), AssocTy=()>>;
+        //~^ ERROR this trait takes 1 generic argument but 2 generic arguments
+        //~| HELP remove
+
+        type H = Box<dyn GenericLifetimeTypeAT<'static, 'static, (), (), AssocTy=()>>;
+        //~^ ERROR this trait takes 1 lifetime argument but 2 lifetime arguments were supplied
+        //~| HELP remove
+        //~| ERROR this trait takes 1 generic argument but 2 generic arguments
+        //~| HELP remove
+    }
+
+    mod type_and_type {
+        trait GenericTypeTypeAT<A, B> {
+            type AssocTy;
+        }
+
+        type A = Box<dyn GenericTypeTypeAT<AssocTy=()>>;
+        //~^ ERROR this trait takes 2 generic arguments but 0 generic arguments
+        //~| HELP add missing
+
+        type B = Box<dyn GenericTypeTypeAT<(), AssocTy=()>>;
+        //~^ ERROR this trait takes 2 generic arguments but 1 generic argument
+        //~| HELP add missing
+
+        type C = Box<dyn GenericTypeTypeAT<(), (), (), AssocTy=()>>;
+        //~^ ERROR this trait takes 2 generic arguments but 3 generic arguments
+        //~| HELP remove
+    }
+
+    mod lifetime_and_lifetime {
+        trait GenericLifetimeLifetimeAT<'a, 'b> {
+            type AssocTy;
+        }
+
+        type A = Box<dyn GenericLifetimeLifetimeAT<AssocTy=()>>;
+        //~^ ERROR missing lifetime specifier
+        //~| HELP consider introducing
+
+        type B = Box<dyn GenericLifetimeLifetimeAT<'static, AssocTy=()>>;
+        //~^ ERROR this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
+        //~| HELP add missing lifetime argument
+    }
+
+    mod lifetime_and_lifetime_and_type {
+        trait GenericLifetimeLifetimeTypeAT<'a, 'b, A> {
+            type AssocTy;
+        }
+
+        type A = Box<dyn GenericLifetimeLifetimeTypeAT<AssocTy=()>>;
+        //~^ ERROR missing lifetime specifier
+        //~| HELP consider introducing
+        //~| ERROR this trait takes 1 generic argument but 0 generic arguments
+        //~| HELP add missing
+
+        type B = Box<dyn GenericLifetimeLifetimeTypeAT<'static, AssocTy=()>>;
+        //~^ ERROR this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
+        //~| HELP add missing lifetime argument
+        //~| ERROR this trait takes 1 generic argument but 0 generic arguments
+        //~| HELP add missing
+
+        type C = Box<dyn GenericLifetimeLifetimeTypeAT<'static, (), AssocTy=()>>;
+        //~^ ERROR this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
+        //~| HELP add missing lifetime argument
+    }
 }
 
 mod stdlib {
@@ -120,41 +294,49 @@ mod hash_map {
 
         type A = HashMap;
         //~^ ERROR missing generics for struct `HashMap`
-        //~| HELP use angle brackets
+        //~| HELP add missing
 
         type B = HashMap<String>;
-        //~^ ERROR this struct takes at least 2 type arguments but only 1 type argument was supplied
-        //~| HELP add missing type argument
+        //~^ ERROR this struct takes at least
+        //~| HELP add missing
 
         type C = HashMap<'static>;
-        //~^ ERROR this struct takes 0 lifetime arguments but 1 lifetime argument was supplied
+        //~^ ERROR this struct takes 0 lifetime arguments but 1 lifetime argument
         //~| HELP remove these generics
-        //~| ERROR this struct takes at least 2 type arguments but 0 type arguments were supplied
-        //~| HELP add missing type arguments
+        //~| ERROR this struct takes at least 2
+        //~| HELP add missing
 
         type D = HashMap<usize, String, char, f64>;
-        //~^ ERROR this struct takes at most 3 type arguments but 4 type arguments were supplied
-        //~| HELP remove this type argument
+        //~^ ERROR this struct takes at most 3
+        //~| HELP remove this
+
+        type E = HashMap<>;
+        //~^ ERROR this struct takes at least 2 generic arguments but 0 generic arguments
+        //~| HELP add missing
     }
 
     mod result {
         type A = Result;
         //~^ ERROR missing generics for enum `Result`
-        //~| HELP use angle brackets
+        //~| HELP add missing
 
         type B = Result<String>;
-        //~^ ERROR this enum takes 2 type arguments but only 1 type argument was supplied
-        //~| HELP add missing type argument
+        //~^ ERROR this enum takes 2 generic arguments but 1 generic argument
+        //~| HELP add missing
 
         type C = Result<'static>;
-        //~^ ERROR this enum takes 0 lifetime arguments but 1 lifetime argument was supplied
+        //~^ ERROR this enum takes 0 lifetime arguments but 1 lifetime argument
         //~| HELP remove these generics
-        //~| ERROR this enum takes 2 type arguments but 0 type arguments were supplied
-        //~| HELP add missing type arguments
+        //~| ERROR this enum takes 2 generic arguments but 0 generic arguments
+        //~| HELP add missing
 
         type D = Result<usize, String, char>;
-        //~^ ERROR this enum takes 2 type arguments but 3 type arguments were supplied
+        //~^ ERROR this enum takes 2 generic arguments but 3 generic arguments
         //~| HELP remove
+
+        type E = Result<>;
+        //~^ ERROR this enum takes 2 generic arguments but 0 generic arguments
+        //~| HELP add missing
     }
 }
 
index 94fdd355d48caacf560e0d740199587f33bb986d..17a924cedad2ce5f878cbcdddbcf0507163106cd 100644 (file)
@@ -16,7 +16,7 @@ error[E0107]: this struct takes 0 lifetime arguments but 1 lifetime argument was
   --> $DIR/wrong-number-of-args.rs:10:14
    |
 LL |     type C = Ty<'static, usize>;
-   |              ^^ --------- help: remove this lifetime argument
+   |              ^^ ------- help: remove this lifetime argument
    |              |
    |              expected 0 lifetime arguments
    |
@@ -26,15 +26,15 @@ note: struct defined here, with 0 lifetime parameters
 LL |     struct Ty;
    |            ^^
 
-error[E0107]: this struct takes 0 type arguments but 1 type argument was supplied
+error[E0107]: this struct takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/wrong-number-of-args.rs:10:14
    |
 LL |     type C = Ty<'static, usize>;
-   |              ^^        ------- help: remove this type argument
+   |              ^^          ----- help: remove this generic argument
    |              |
-   |              expected 0 type arguments
+   |              expected 0 generic arguments
    |
-note: struct defined here, with 0 type parameters
+note: struct defined here, with 0 generic parameters
   --> $DIR/wrong-number-of-args.rs:2:12
    |
 LL |     struct Ty;
@@ -44,7 +44,7 @@ error[E0107]: this struct takes 0 lifetime arguments but 1 lifetime argument was
   --> $DIR/wrong-number-of-args.rs:16:14
    |
 LL |     type D = Ty<'static, usize, { 0 }>;
-   |              ^^ --------- help: remove this lifetime argument
+   |              ^^ ------- help: remove this lifetime argument
    |              |
    |              expected 0 lifetime arguments
    |
@@ -58,7 +58,7 @@ error[E0107]: this struct takes 0 generic arguments but 2 generic arguments were
   --> $DIR/wrong-number-of-args.rs:16:14
    |
 LL |     type D = Ty<'static, usize, { 0 }>;
-   |              ^^        -------------- help: remove these generic arguments
+   |              ^^          ------------ help: remove these generic arguments
    |              |
    |              expected 0 generic arguments
    |
@@ -72,68 +72,84 @@ error[E0107]: missing generics for struct `type_and_type::Ty`
   --> $DIR/wrong-number-of-args.rs:26:14
    |
 LL |     type A = Ty;
-   |              ^^ expected 2 type arguments
+   |              ^^ expected 2 generic arguments
    |
-note: struct defined here, with 2 type parameters: `A`, `B`
+note: struct defined here, with 2 generic parameters: `A`, `B`
   --> $DIR/wrong-number-of-args.rs:24:12
    |
 LL |     struct Ty<A, B>;
    |            ^^ -  -
-help: use angle brackets to add missing type arguments
+help: add missing generic arguments
    |
 LL |     type A = Ty<A, B>;
-   |                ^^^^^^
+   |              ^^^^^^^^
 
-error[E0107]: this struct takes 2 type arguments but only 1 type argument was supplied
+error[E0107]: this struct takes 2 generic arguments but 1 generic argument was supplied
   --> $DIR/wrong-number-of-args.rs:30:14
    |
 LL |     type B = Ty<usize>;
-   |              ^^ ----- supplied 1 type argument
+   |              ^^ ----- supplied 1 generic argument
    |              |
-   |              expected 2 type arguments
+   |              expected 2 generic arguments
    |
-note: struct defined here, with 2 type parameters: `A`, `B`
+note: struct defined here, with 2 generic parameters: `A`, `B`
   --> $DIR/wrong-number-of-args.rs:24:12
    |
 LL |     struct Ty<A, B>;
    |            ^^ -  -
-help: add missing type argument
+help: add missing generic argument
    |
 LL |     type B = Ty<usize, B>;
    |                      ^^^
 
-error[E0107]: this struct takes 2 type arguments but 3 type arguments were supplied
+error[E0107]: this struct takes 2 generic arguments but 3 generic arguments were supplied
   --> $DIR/wrong-number-of-args.rs:36:14
    |
 LL |     type D = Ty<usize, String, char>;
-   |              ^^              ------ help: remove this type argument
+   |              ^^                ---- help: remove this generic argument
    |              |
-   |              expected 2 type arguments
+   |              expected 2 generic arguments
+   |
+note: struct defined here, with 2 generic parameters: `A`, `B`
+  --> $DIR/wrong-number-of-args.rs:24:12
+   |
+LL |     struct Ty<A, B>;
+   |            ^^ -  -
+
+error[E0107]: this struct takes 2 generic arguments but 0 generic arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:40:14
+   |
+LL |     type E = Ty<>;
+   |              ^^ expected 2 generic arguments
    |
-note: struct defined here, with 2 type parameters: `A`, `B`
+note: struct defined here, with 2 generic parameters: `A`, `B`
   --> $DIR/wrong-number-of-args.rs:24:12
    |
 LL |     struct Ty<A, B>;
    |            ^^ -  -
+help: add missing generic arguments
+   |
+LL |     type E = Ty<A, B>;
+   |                 ^^^^
 
 error[E0107]: missing generics for struct `lifetime_and_type::Ty`
-  --> $DIR/wrong-number-of-args.rs:44:14
+  --> $DIR/wrong-number-of-args.rs:48:14
    |
 LL |     type A = Ty;
-   |              ^^ expected 1 type argument
+   |              ^^ expected 1 generic argument
    |
-note: struct defined here, with 1 type parameter: `T`
-  --> $DIR/wrong-number-of-args.rs:42:12
+note: struct defined here, with 1 generic parameter: `T`
+  --> $DIR/wrong-number-of-args.rs:46:12
    |
 LL |     struct Ty<'a, T>;
    |            ^^     -
-help: use angle brackets to add missing type argument
+help: add missing generic argument
    |
 LL |     type A = Ty<T>;
-   |                ^^^
+   |              ^^^^^
 
 error[E0106]: missing lifetime specifier
-  --> $DIR/wrong-number-of-args.rs:44:14
+  --> $DIR/wrong-number-of-args.rs:48:14
    |
 LL |     type A = Ty;
    |              ^^ expected named lifetime parameter
@@ -143,24 +159,24 @@ help: consider introducing a named lifetime parameter
 LL |     type A<'a> = Ty<'a>;
    |           ^^^^   ^^^^^^
 
-error[E0107]: this struct takes 1 type argument but 0 type arguments were supplied
-  --> $DIR/wrong-number-of-args.rs:50:14
+error[E0107]: this struct takes 1 generic argument but 0 generic arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:54:14
    |
 LL |     type B = Ty<'static>;
-   |              ^^ expected 1 type argument
+   |              ^^ expected 1 generic argument
    |
-note: struct defined here, with 1 type parameter: `T`
-  --> $DIR/wrong-number-of-args.rs:42:12
+note: struct defined here, with 1 generic parameter: `T`
+  --> $DIR/wrong-number-of-args.rs:46:12
    |
 LL |     struct Ty<'a, T>;
    |            ^^     -
-help: add missing type argument
+help: add missing generic argument
    |
 LL |     type B = Ty<'static, T>;
    |                        ^^^
 
 error[E0106]: missing lifetime specifier
-  --> $DIR/wrong-number-of-args.rs:54:17
+  --> $DIR/wrong-number-of-args.rs:58:17
    |
 LL |     type C = Ty<usize>;
    |                 ^ expected named lifetime parameter
@@ -170,70 +186,113 @@ help: consider introducing a named lifetime parameter
 LL |     type C<'a> = Ty<'a, usize>;
    |           ^^^^      ^^^
 
-error[E0107]: missing generics for struct `type_and_type_and_type::Ty`
+error[E0107]: this struct takes 1 generic argument but 0 generic arguments were supplied
   --> $DIR/wrong-number-of-args.rs:64:14
    |
+LL |     type E = Ty<>;
+   |              ^^ expected 1 generic argument
+   |
+note: struct defined here, with 1 generic parameter: `T`
+  --> $DIR/wrong-number-of-args.rs:46:12
+   |
+LL |     struct Ty<'a, T>;
+   |            ^^     -
+help: add missing generic argument
+   |
+LL |     type E = Ty<T>;
+   |                 ^
+
+error[E0106]: missing lifetime specifier
+  --> $DIR/wrong-number-of-args.rs:64:16
+   |
+LL |     type E = Ty<>;
+   |                ^- expected named lifetime parameter
+   |
+help: consider introducing a named lifetime parameter
+   |
+LL |     type E<'a> = Ty<'a>;
+   |           ^^^^      ^^
+
+error[E0107]: missing generics for struct `type_and_type_and_type::Ty`
+  --> $DIR/wrong-number-of-args.rs:74:14
+   |
 LL |     type A = Ty;
-   |              ^^ expected at least 2 type arguments
+   |              ^^ expected at least 2 generic arguments
    |
-note: struct defined here, with at least 2 type parameters: `A`, `B`
-  --> $DIR/wrong-number-of-args.rs:62:12
+note: struct defined here, with at least 2 generic parameters: `A`, `B`
+  --> $DIR/wrong-number-of-args.rs:72:12
    |
 LL |     struct Ty<A, B, C = &'static str>;
    |            ^^ -  -
-help: use angle brackets to add missing type arguments
+help: add missing generic arguments
    |
 LL |     type A = Ty<A, B>;
-   |                ^^^^^^
+   |              ^^^^^^^^
 
-error[E0107]: this struct takes at least 2 type arguments but only 1 type argument was supplied
-  --> $DIR/wrong-number-of-args.rs:68:14
+error[E0107]: this struct takes at least 2 generic arguments but 1 generic argument was supplied
+  --> $DIR/wrong-number-of-args.rs:78:14
    |
 LL |     type B = Ty<usize>;
-   |              ^^ ----- supplied 1 type argument
+   |              ^^ ----- supplied 1 generic argument
    |              |
-   |              expected at least 2 type arguments
+   |              expected at least 2 generic arguments
    |
-note: struct defined here, with at least 2 type parameters: `A`, `B`
-  --> $DIR/wrong-number-of-args.rs:62:12
+note: struct defined here, with at least 2 generic parameters: `A`, `B`
+  --> $DIR/wrong-number-of-args.rs:72:12
    |
 LL |     struct Ty<A, B, C = &'static str>;
    |            ^^ -  -
-help: add missing type argument
+help: add missing generic argument
    |
 LL |     type B = Ty<usize, B>;
    |                      ^^^
 
-error[E0107]: this struct takes at most 3 type arguments but 4 type arguments were supplied
-  --> $DIR/wrong-number-of-args.rs:76:14
+error[E0107]: this struct takes at most 3 generic arguments but 4 generic arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:86:14
    |
 LL |     type E = Ty<usize, String, char, f64>;
-   |              ^^                    ----- help: remove this type argument
+   |              ^^                      --- help: remove this generic argument
    |              |
-   |              expected at most 3 type arguments
+   |              expected at most 3 generic arguments
    |
-note: struct defined here, with at most 3 type parameters: `A`, `B`, `C`
-  --> $DIR/wrong-number-of-args.rs:62:12
+note: struct defined here, with at most 3 generic parameters: `A`, `B`, `C`
+  --> $DIR/wrong-number-of-args.rs:72:12
    |
 LL |     struct Ty<A, B, C = &'static str>;
    |            ^^ -  -  -
 
-error[E0107]: this trait takes 0 type arguments but 1 type argument was supplied
-  --> $DIR/wrong-number-of-args.rs:96:22
+error[E0107]: this struct takes at least 2 generic arguments but 0 generic arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:90:14
+   |
+LL |     type F = Ty<>;
+   |              ^^ expected at least 2 generic arguments
+   |
+note: struct defined here, with at least 2 generic parameters: `A`, `B`
+  --> $DIR/wrong-number-of-args.rs:72:12
+   |
+LL |     struct Ty<A, B, C = &'static str>;
+   |            ^^ -  -
+help: add missing generic arguments
+   |
+LL |     type F = Ty<A, B>;
+   |                 ^^^^
+
+error[E0107]: this trait takes 0 generic arguments but 1 generic argument was supplied
+  --> $DIR/wrong-number-of-args.rs:110:22
    |
 LL |     type A = Box<dyn NonGeneric<usize>>;
    |                      ^^^^^^^^^^------- help: remove these generics
    |                      |
-   |                      expected 0 type arguments
+   |                      expected 0 generic arguments
    |
-note: trait defined here, with 0 type parameters
-  --> $DIR/wrong-number-of-args.rs:84:11
+note: trait defined here, with 0 generic parameters
+  --> $DIR/wrong-number-of-args.rs:98:11
    |
 LL |     trait NonGeneric {
    |           ^^^^^^^^^^
 
 error[E0106]: missing lifetime specifier
-  --> $DIR/wrong-number-of-args.rs:100:22
+  --> $DIR/wrong-number-of-args.rs:114:22
    |
 LL |     type B = Box<dyn GenericLifetime>;
    |                      ^^^^^^^^^^^^^^^ expected named lifetime parameter
@@ -244,85 +303,557 @@ LL |     type B<'a> = Box<dyn GenericLifetime<'a>>;
    |           ^^^^           ^^^^^^^^^^^^^^^^^^^
 
 error[E0107]: this trait takes 1 lifetime argument but 2 lifetime arguments were supplied
-  --> $DIR/wrong-number-of-args.rs:104:22
+  --> $DIR/wrong-number-of-args.rs:118:22
    |
 LL |     type C = Box<dyn GenericLifetime<'static, 'static>>;
-   |                      ^^^^^^^^^^^^^^^        --------- help: remove this lifetime argument
+   |                      ^^^^^^^^^^^^^^^          ------- help: remove this lifetime argument
    |                      |
    |                      expected 1 lifetime argument
    |
 note: trait defined here, with 1 lifetime parameter: `'a`
-  --> $DIR/wrong-number-of-args.rs:88:11
+  --> $DIR/wrong-number-of-args.rs:102:11
    |
 LL |     trait GenericLifetime<'a> {
    |           ^^^^^^^^^^^^^^^ --
 
 error[E0107]: missing generics for trait `GenericType`
-  --> $DIR/wrong-number-of-args.rs:108:22
+  --> $DIR/wrong-number-of-args.rs:122:22
    |
 LL |     type D = Box<dyn GenericType>;
-   |                      ^^^^^^^^^^^ expected 1 type argument
+   |                      ^^^^^^^^^^^ expected 1 generic argument
    |
-note: trait defined here, with 1 type parameter: `A`
-  --> $DIR/wrong-number-of-args.rs:92:11
+note: trait defined here, with 1 generic parameter: `A`
+  --> $DIR/wrong-number-of-args.rs:106:11
    |
 LL |     trait GenericType<A> {
    |           ^^^^^^^^^^^ -
-help: use angle brackets to add missing type argument
+help: add missing generic argument
    |
 LL |     type D = Box<dyn GenericType<A>>;
-   |                                 ^^^
+   |                      ^^^^^^^^^^^^^^
 
-error[E0107]: this trait takes 1 type argument but 2 type arguments were supplied
-  --> $DIR/wrong-number-of-args.rs:112:22
+error[E0107]: this trait takes 1 generic argument but 2 generic arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:126:22
    |
 LL |     type E = Box<dyn GenericType<String, usize>>;
-   |                      ^^^^^^^^^^^       ------- help: remove this type argument
+   |                      ^^^^^^^^^^^         ----- help: remove this generic argument
    |                      |
-   |                      expected 1 type argument
+   |                      expected 1 generic argument
    |
-note: trait defined here, with 1 type parameter: `A`
-  --> $DIR/wrong-number-of-args.rs:92:11
+note: trait defined here, with 1 generic parameter: `A`
+  --> $DIR/wrong-number-of-args.rs:106:11
    |
 LL |     trait GenericType<A> {
    |           ^^^^^^^^^^^ -
 
+error[E0106]: missing lifetime specifier
+  --> $DIR/wrong-number-of-args.rs:130:37
+   |
+LL |     type F = Box<dyn GenericLifetime<>>;
+   |                                     ^- expected named lifetime parameter
+   |
+help: consider introducing a named lifetime parameter
+   |
+LL |     type F<'a> = Box<dyn GenericLifetime<'a>>;
+   |           ^^^^                           ^^
+
+error[E0107]: this trait takes 1 generic argument but 0 generic arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:134:22
+   |
+LL |     type G = Box<dyn GenericType<>>;
+   |                      ^^^^^^^^^^^ expected 1 generic argument
+   |
+note: trait defined here, with 1 generic parameter: `A`
+  --> $DIR/wrong-number-of-args.rs:106:11
+   |
+LL |     trait GenericType<A> {
+   |           ^^^^^^^^^^^ -
+help: add missing generic argument
+   |
+LL |     type G = Box<dyn GenericType<A>>;
+   |                                  ^
+
+error[E0107]: this trait takes 0 generic arguments but 1 generic argument was supplied
+  --> $DIR/wrong-number-of-args.rs:145:26
+   |
+LL |         type A = Box<dyn NonGenericAT<usize, AssocTy=()>>;
+   |                          ^^^^^^^^^^^^------------------- help: remove these generics
+   |                          |
+   |                          expected 0 generic arguments
+   |
+note: trait defined here, with 0 generic parameters
+  --> $DIR/wrong-number-of-args.rs:141:15
+   |
+LL |         trait NonGenericAT {
+   |               ^^^^^^^^^^^^
+
+error[E0106]: missing lifetime specifier
+  --> $DIR/wrong-number-of-args.rs:155:44
+   |
+LL |         type A = Box<dyn GenericLifetimeAT<AssocTy=()>>;
+   |                                            ^ expected named lifetime parameter
+   |
+help: consider introducing a named lifetime parameter
+   |
+LL |         type A<'a> = Box<dyn GenericLifetimeAT<'a, AssocTy=()>>;
+   |               ^^^^                             ^^^
+
+error[E0107]: this trait takes 1 lifetime argument but 2 lifetime arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:159:26
+   |
+LL |         type B = Box<dyn GenericLifetimeAT<'static, 'static, AssocTy=()>>;
+   |                          ^^^^^^^^^^^^^^^^^          ------- help: remove this lifetime argument
+   |                          |
+   |                          expected 1 lifetime argument
+   |
+note: trait defined here, with 1 lifetime parameter: `'a`
+  --> $DIR/wrong-number-of-args.rs:151:15
+   |
+LL |         trait GenericLifetimeAT<'a> {
+   |               ^^^^^^^^^^^^^^^^^ --
+
+error[E0106]: missing lifetime specifier
+  --> $DIR/wrong-number-of-args.rs:163:44
+   |
+LL |         type C = Box<dyn GenericLifetimeAT<(), AssocTy=()>>;
+   |                                            ^ expected named lifetime parameter
+   |
+help: consider introducing a named lifetime parameter
+   |
+LL |         type C<'a> = Box<dyn GenericLifetimeAT<'a, (), AssocTy=()>>;
+   |               ^^^^                             ^^^
+
+error[E0107]: this trait takes 0 generic arguments but 1 generic argument was supplied
+  --> $DIR/wrong-number-of-args.rs:163:26
+   |
+LL |         type C = Box<dyn GenericLifetimeAT<(), AssocTy=()>>;
+   |                          ^^^^^^^^^^^^^^^^^ -- help: remove this generic argument
+   |                          |
+   |                          expected 0 generic arguments
+   |
+note: trait defined here, with 0 generic parameters
+  --> $DIR/wrong-number-of-args.rs:151:15
+   |
+LL |         trait GenericLifetimeAT<'a> {
+   |               ^^^^^^^^^^^^^^^^^
+
+error[E0107]: this trait takes 1 generic argument but 0 generic arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:175:26
+   |
+LL |         type A = Box<dyn GenericTypeAT<AssocTy=()>>;
+   |                          ^^^^^^^^^^^^^ expected 1 generic argument
+   |
+note: trait defined here, with 1 generic parameter: `A`
+  --> $DIR/wrong-number-of-args.rs:171:15
+   |
+LL |         trait GenericTypeAT<A> {
+   |               ^^^^^^^^^^^^^ -
+help: add missing generic argument
+   |
+LL |         type A = Box<dyn GenericTypeAT<A, AssocTy=()>>;
+   |                                        ^^
+
+error[E0107]: this trait takes 1 generic argument but 2 generic arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:179:26
+   |
+LL |         type B = Box<dyn GenericTypeAT<(), (), AssocTy=()>>;
+   |                          ^^^^^^^^^^^^^     -- help: remove this generic argument
+   |                          |
+   |                          expected 1 generic argument
+   |
+note: trait defined here, with 1 generic parameter: `A`
+  --> $DIR/wrong-number-of-args.rs:171:15
+   |
+LL |         trait GenericTypeAT<A> {
+   |               ^^^^^^^^^^^^^ -
+
+error[E0107]: this trait takes 0 lifetime arguments but 1 lifetime argument was supplied
+  --> $DIR/wrong-number-of-args.rs:183:26
+   |
+LL |         type C = Box<dyn GenericTypeAT<'static, AssocTy=()>>;
+   |                          ^^^^^^^^^^^^^--------------------- help: remove these generics
+   |                          |
+   |                          expected 0 lifetime arguments
+   |
+note: trait defined here, with 0 lifetime parameters
+  --> $DIR/wrong-number-of-args.rs:171:15
+   |
+LL |         trait GenericTypeAT<A> {
+   |               ^^^^^^^^^^^^^
+
+error[E0107]: this trait takes 1 generic argument but 0 generic arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:183:26
+   |
+LL |         type C = Box<dyn GenericTypeAT<'static, AssocTy=()>>;
+   |                          ^^^^^^^^^^^^^ expected 1 generic argument
+   |
+note: trait defined here, with 1 generic parameter: `A`
+  --> $DIR/wrong-number-of-args.rs:171:15
+   |
+LL |         trait GenericTypeAT<A> {
+   |               ^^^^^^^^^^^^^ -
+help: add missing generic argument
+   |
+LL |         type C = Box<dyn GenericTypeAT<'static, A, AssocTy=()>>;
+   |                                               ^^^
+
+error[E0106]: missing lifetime specifier
+  --> $DIR/wrong-number-of-args.rs:195:48
+   |
+LL |         type A = Box<dyn GenericLifetimeTypeAT<AssocTy=()>>;
+   |                                                ^ expected named lifetime parameter
+   |
+help: consider introducing a named lifetime parameter
+   |
+LL |         type A<'a> = Box<dyn GenericLifetimeTypeAT<'a, AssocTy=()>>;
+   |               ^^^^                                 ^^^
+
+error[E0107]: this trait takes 1 generic argument but 0 generic arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:195:26
+   |
+LL |         type A = Box<dyn GenericLifetimeTypeAT<AssocTy=()>>;
+   |                          ^^^^^^^^^^^^^^^^^^^^^ expected 1 generic argument
+   |
+note: trait defined here, with 1 generic parameter: `A`
+  --> $DIR/wrong-number-of-args.rs:191:15
+   |
+LL |         trait GenericLifetimeTypeAT<'a, A> {
+   |               ^^^^^^^^^^^^^^^^^^^^^     -
+help: add missing generic argument
+   |
+LL |         type A = Box<dyn GenericLifetimeTypeAT<A, AssocTy=()>>;
+   |                                                ^^
+
+error[E0107]: this trait takes 1 generic argument but 0 generic arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:201:26
+   |
+LL |         type B = Box<dyn GenericLifetimeTypeAT<'static, AssocTy=()>>;
+   |                          ^^^^^^^^^^^^^^^^^^^^^ expected 1 generic argument
+   |
+note: trait defined here, with 1 generic parameter: `A`
+  --> $DIR/wrong-number-of-args.rs:191:15
+   |
+LL |         trait GenericLifetimeTypeAT<'a, A> {
+   |               ^^^^^^^^^^^^^^^^^^^^^     -
+help: add missing generic argument
+   |
+LL |         type B = Box<dyn GenericLifetimeTypeAT<'static, A, AssocTy=()>>;
+   |                                                       ^^^
+
+error[E0107]: this trait takes 1 lifetime argument but 2 lifetime arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:205:26
+   |
+LL |         type C = Box<dyn GenericLifetimeTypeAT<'static, 'static, AssocTy=()>>;
+   |                          ^^^^^^^^^^^^^^^^^^^^^          ------- help: remove this lifetime argument
+   |                          |
+   |                          expected 1 lifetime argument
+   |
+note: trait defined here, with 1 lifetime parameter: `'a`
+  --> $DIR/wrong-number-of-args.rs:191:15
+   |
+LL |         trait GenericLifetimeTypeAT<'a, A> {
+   |               ^^^^^^^^^^^^^^^^^^^^^ --
+
+error[E0107]: this trait takes 1 generic argument but 0 generic arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:205:26
+   |
+LL |         type C = Box<dyn GenericLifetimeTypeAT<'static, 'static, AssocTy=()>>;
+   |                          ^^^^^^^^^^^^^^^^^^^^^ expected 1 generic argument
+   |
+note: trait defined here, with 1 generic parameter: `A`
+  --> $DIR/wrong-number-of-args.rs:191:15
+   |
+LL |         trait GenericLifetimeTypeAT<'a, A> {
+   |               ^^^^^^^^^^^^^^^^^^^^^     -
+help: add missing generic argument
+   |
+LL |         type C = Box<dyn GenericLifetimeTypeAT<'static, 'static, A, AssocTy=()>>;
+   |                                                                ^^^
+
+error[E0106]: missing lifetime specifier
+  --> $DIR/wrong-number-of-args.rs:211:48
+   |
+LL |         type D = Box<dyn GenericLifetimeTypeAT<(), AssocTy=()>>;
+   |                                                ^ expected named lifetime parameter
+   |
+help: consider introducing a named lifetime parameter
+   |
+LL |         type D<'a> = Box<dyn GenericLifetimeTypeAT<'a, (), AssocTy=()>>;
+   |               ^^^^                                 ^^^
+
+error[E0106]: missing lifetime specifier
+  --> $DIR/wrong-number-of-args.rs:215:48
+   |
+LL |         type E = Box<dyn GenericLifetimeTypeAT<(), (), AssocTy=()>>;
+   |                                                ^ expected named lifetime parameter
+   |
+help: consider introducing a named lifetime parameter
+   |
+LL |         type E<'a> = Box<dyn GenericLifetimeTypeAT<'a, (), (), AssocTy=()>>;
+   |               ^^^^                                 ^^^
+
+error[E0107]: this trait takes 1 generic argument but 2 generic arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:215:26
+   |
+LL |         type E = Box<dyn GenericLifetimeTypeAT<(), (), AssocTy=()>>;
+   |                          ^^^^^^^^^^^^^^^^^^^^^     -- help: remove this generic argument
+   |                          |
+   |                          expected 1 generic argument
+   |
+note: trait defined here, with 1 generic parameter: `A`
+  --> $DIR/wrong-number-of-args.rs:191:15
+   |
+LL |         trait GenericLifetimeTypeAT<'a, A> {
+   |               ^^^^^^^^^^^^^^^^^^^^^     -
+
+error[E0107]: this trait takes 1 lifetime argument but 2 lifetime arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:221:26
+   |
+LL |         type F = Box<dyn GenericLifetimeTypeAT<'static, 'static, (), AssocTy=()>>;
+   |                          ^^^^^^^^^^^^^^^^^^^^^          ------- help: remove this lifetime argument
+   |                          |
+   |                          expected 1 lifetime argument
+   |
+note: trait defined here, with 1 lifetime parameter: `'a`
+  --> $DIR/wrong-number-of-args.rs:191:15
+   |
+LL |         trait GenericLifetimeTypeAT<'a, A> {
+   |               ^^^^^^^^^^^^^^^^^^^^^ --
+
+error[E0107]: this trait takes 1 generic argument but 2 generic arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:225:26
+   |
+LL |         type G = Box<dyn GenericLifetimeTypeAT<'static, (), (), AssocTy=()>>;
+   |                          ^^^^^^^^^^^^^^^^^^^^^              -- help: remove this generic argument
+   |                          |
+   |                          expected 1 generic argument
+   |
+note: trait defined here, with 1 generic parameter: `A`
+  --> $DIR/wrong-number-of-args.rs:191:15
+   |
+LL |         trait GenericLifetimeTypeAT<'a, A> {
+   |               ^^^^^^^^^^^^^^^^^^^^^     -
+
+error[E0107]: this trait takes 1 lifetime argument but 2 lifetime arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:229:26
+   |
+LL |         type H = Box<dyn GenericLifetimeTypeAT<'static, 'static, (), (), AssocTy=()>>;
+   |                          ^^^^^^^^^^^^^^^^^^^^^          ------- help: remove this lifetime argument
+   |                          |
+   |                          expected 1 lifetime argument
+   |
+note: trait defined here, with 1 lifetime parameter: `'a`
+  --> $DIR/wrong-number-of-args.rs:191:15
+   |
+LL |         trait GenericLifetimeTypeAT<'a, A> {
+   |               ^^^^^^^^^^^^^^^^^^^^^ --
+
+error[E0107]: this trait takes 1 generic argument but 2 generic arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:229:26
+   |
+LL |         type H = Box<dyn GenericLifetimeTypeAT<'static, 'static, (), (), AssocTy=()>>;
+   |                          ^^^^^^^^^^^^^^^^^^^^^                       -- help: remove this generic argument
+   |                          |
+   |                          expected 1 generic argument
+   |
+note: trait defined here, with 1 generic parameter: `A`
+  --> $DIR/wrong-number-of-args.rs:191:15
+   |
+LL |         trait GenericLifetimeTypeAT<'a, A> {
+   |               ^^^^^^^^^^^^^^^^^^^^^     -
+
+error[E0107]: this trait takes 2 generic arguments but 0 generic arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:241:26
+   |
+LL |         type A = Box<dyn GenericTypeTypeAT<AssocTy=()>>;
+   |                          ^^^^^^^^^^^^^^^^^ expected 2 generic arguments
+   |
+note: trait defined here, with 2 generic parameters: `A`, `B`
+  --> $DIR/wrong-number-of-args.rs:237:15
+   |
+LL |         trait GenericTypeTypeAT<A, B> {
+   |               ^^^^^^^^^^^^^^^^^ -  -
+help: add missing generic arguments
+   |
+LL |         type A = Box<dyn GenericTypeTypeAT<A, B, AssocTy=()>>;
+   |                                            ^^^^^
+
+error[E0107]: this trait takes 2 generic arguments but 1 generic argument was supplied
+  --> $DIR/wrong-number-of-args.rs:245:26
+   |
+LL |         type B = Box<dyn GenericTypeTypeAT<(), AssocTy=()>>;
+   |                          ^^^^^^^^^^^^^^^^^ -- supplied 1 generic argument
+   |                          |
+   |                          expected 2 generic arguments
+   |
+note: trait defined here, with 2 generic parameters: `A`, `B`
+  --> $DIR/wrong-number-of-args.rs:237:15
+   |
+LL |         trait GenericTypeTypeAT<A, B> {
+   |               ^^^^^^^^^^^^^^^^^ -  -
+help: add missing generic argument
+   |
+LL |         type B = Box<dyn GenericTypeTypeAT<(), B, AssocTy=()>>;
+   |                                              ^^^
+
+error[E0107]: this trait takes 2 generic arguments but 3 generic arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:249:26
+   |
+LL |         type C = Box<dyn GenericTypeTypeAT<(), (), (), AssocTy=()>>;
+   |                          ^^^^^^^^^^^^^^^^^         -- help: remove this generic argument
+   |                          |
+   |                          expected 2 generic arguments
+   |
+note: trait defined here, with 2 generic parameters: `A`, `B`
+  --> $DIR/wrong-number-of-args.rs:237:15
+   |
+LL |         trait GenericTypeTypeAT<A, B> {
+   |               ^^^^^^^^^^^^^^^^^ -  -
+
+error[E0106]: missing lifetime specifiers
+  --> $DIR/wrong-number-of-args.rs:259:52
+   |
+LL |         type A = Box<dyn GenericLifetimeLifetimeAT<AssocTy=()>>;
+   |                                                    ^ expected 2 lifetime parameters
+   |
+help: consider introducing a named lifetime parameter
+   |
+LL |         type A<'a> = Box<dyn GenericLifetimeLifetimeAT<'a, 'a, AssocTy=()>>;
+   |               ^^^^                                     ^^^^^^^
+
+error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
+  --> $DIR/wrong-number-of-args.rs:263:26
+   |
+LL |         type B = Box<dyn GenericLifetimeLifetimeAT<'static, AssocTy=()>>;
+   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^ ------- supplied 1 lifetime argument
+   |                          |
+   |                          expected 2 lifetime arguments
+   |
+note: trait defined here, with 2 lifetime parameters: `'a`, `'b`
+  --> $DIR/wrong-number-of-args.rs:255:15
+   |
+LL |         trait GenericLifetimeLifetimeAT<'a, 'b> {
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^ --  --
+help: add missing lifetime argument
+   |
+LL |         type B = Box<dyn GenericLifetimeLifetimeAT<'static, 'b, AssocTy=()>>;
+   |                                                           ^^^^
+
+error[E0106]: missing lifetime specifiers
+  --> $DIR/wrong-number-of-args.rs:273:56
+   |
+LL |         type A = Box<dyn GenericLifetimeLifetimeTypeAT<AssocTy=()>>;
+   |                                                        ^ expected 2 lifetime parameters
+   |
+help: consider introducing a named lifetime parameter
+   |
+LL |         type A<'a> = Box<dyn GenericLifetimeLifetimeTypeAT<'a, 'a, AssocTy=()>>;
+   |               ^^^^                                         ^^^^^^^
+
+error[E0107]: this trait takes 1 generic argument but 0 generic arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:273:26
+   |
+LL |         type A = Box<dyn GenericLifetimeLifetimeTypeAT<AssocTy=()>>;
+   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 1 generic argument
+   |
+note: trait defined here, with 1 generic parameter: `A`
+  --> $DIR/wrong-number-of-args.rs:269:15
+   |
+LL |         trait GenericLifetimeLifetimeTypeAT<'a, 'b, A> {
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^         -
+help: add missing generic argument
+   |
+LL |         type A = Box<dyn GenericLifetimeLifetimeTypeAT<A, AssocTy=()>>;
+   |                                                        ^^
+
+error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
+  --> $DIR/wrong-number-of-args.rs:279:26
+   |
+LL |         type B = Box<dyn GenericLifetimeLifetimeTypeAT<'static, AssocTy=()>>;
+   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------- supplied 1 lifetime argument
+   |                          |
+   |                          expected 2 lifetime arguments
+   |
+note: trait defined here, with 2 lifetime parameters: `'a`, `'b`
+  --> $DIR/wrong-number-of-args.rs:269:15
+   |
+LL |         trait GenericLifetimeLifetimeTypeAT<'a, 'b, A> {
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ --  --
+help: add missing lifetime argument
+   |
+LL |         type B = Box<dyn GenericLifetimeLifetimeTypeAT<'static, 'b, AssocTy=()>>;
+   |                                                               ^^^^
+
+error[E0107]: this trait takes 1 generic argument but 0 generic arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:279:26
+   |
+LL |         type B = Box<dyn GenericLifetimeLifetimeTypeAT<'static, AssocTy=()>>;
+   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 1 generic argument
+   |
+note: trait defined here, with 1 generic parameter: `A`
+  --> $DIR/wrong-number-of-args.rs:269:15
+   |
+LL |         trait GenericLifetimeLifetimeTypeAT<'a, 'b, A> {
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^         -
+help: add missing generic argument
+   |
+LL |         type B = Box<dyn GenericLifetimeLifetimeTypeAT<'static, A, AssocTy=()>>;
+   |                                                               ^^^
+
+error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
+  --> $DIR/wrong-number-of-args.rs:285:26
+   |
+LL |         type C = Box<dyn GenericLifetimeLifetimeTypeAT<'static, (), AssocTy=()>>;
+   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------- supplied 1 lifetime argument
+   |                          |
+   |                          expected 2 lifetime arguments
+   |
+note: trait defined here, with 2 lifetime parameters: `'a`, `'b`
+  --> $DIR/wrong-number-of-args.rs:269:15
+   |
+LL |         trait GenericLifetimeLifetimeTypeAT<'a, 'b, A> {
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ --  --
+help: add missing lifetime argument
+   |
+LL |         type C = Box<dyn GenericLifetimeLifetimeTypeAT<'static, 'b, (), AssocTy=()>>;
+   |                                                               ^^^^
+
 error[E0107]: missing generics for struct `HashMap`
-  --> $DIR/wrong-number-of-args.rs:121:18
+  --> $DIR/wrong-number-of-args.rs:295:18
    |
 LL |         type A = HashMap;
-   |                  ^^^^^^^ expected at least 2 type arguments
+   |                  ^^^^^^^ expected at least 2 generic arguments
    |
-note: struct defined here, with at least 2 type parameters: `K`, `V`
+note: struct defined here, with at least 2 generic parameters: `K`, `V`
   --> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL
    |
 LL | pub struct HashMap<K, V, S = RandomState> {
    |            ^^^^^^^ -  -
-help: use angle brackets to add missing type arguments
+help: add missing generic arguments
    |
 LL |         type A = HashMap<K, V>;
-   |                         ^^^^^^
+   |                  ^^^^^^^^^^^^^
 
-error[E0107]: this struct takes at least 2 type arguments but only 1 type argument was supplied
-  --> $DIR/wrong-number-of-args.rs:125:18
+error[E0107]: this struct takes at least 2 generic arguments but 1 generic argument was supplied
+  --> $DIR/wrong-number-of-args.rs:299:18
    |
 LL |         type B = HashMap<String>;
-   |                  ^^^^^^^ ------ supplied 1 type argument
+   |                  ^^^^^^^ ------ supplied 1 generic argument
    |                  |
-   |                  expected at least 2 type arguments
+   |                  expected at least 2 generic arguments
    |
-note: struct defined here, with at least 2 type parameters: `K`, `V`
+note: struct defined here, with at least 2 generic parameters: `K`, `V`
   --> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL
    |
 LL | pub struct HashMap<K, V, S = RandomState> {
    |            ^^^^^^^ -  -
-help: add missing type argument
+help: add missing generic argument
    |
 LL |         type B = HashMap<String, V>;
    |                                ^^^
 
 error[E0107]: this struct takes 0 lifetime arguments but 1 lifetime argument was supplied
-  --> $DIR/wrong-number-of-args.rs:129:18
+  --> $DIR/wrong-number-of-args.rs:303:18
    |
 LL |         type C = HashMap<'static>;
    |                  ^^^^^^^--------- help: remove these generics
@@ -335,72 +866,88 @@ note: struct defined here, with 0 lifetime parameters
 LL | pub struct HashMap<K, V, S = RandomState> {
    |            ^^^^^^^
 
-error[E0107]: this struct takes at least 2 type arguments but 0 type arguments were supplied
-  --> $DIR/wrong-number-of-args.rs:129:18
+error[E0107]: this struct takes at least 2 generic arguments but 0 generic arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:303:18
    |
 LL |         type C = HashMap<'static>;
-   |                  ^^^^^^^ expected at least 2 type arguments
+   |                  ^^^^^^^ expected at least 2 generic arguments
    |
-note: struct defined here, with at least 2 type parameters: `K`, `V`
+note: struct defined here, with at least 2 generic parameters: `K`, `V`
   --> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL
    |
 LL | pub struct HashMap<K, V, S = RandomState> {
    |            ^^^^^^^ -  -
-help: add missing type arguments
+help: add missing generic arguments
    |
 LL |         type C = HashMap<'static, K, V>;
    |                                 ^^^^^^
 
-error[E0107]: this struct takes at most 3 type arguments but 4 type arguments were supplied
-  --> $DIR/wrong-number-of-args.rs:135:18
+error[E0107]: this struct takes at most 3 generic arguments but 4 generic arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:309:18
    |
 LL |         type D = HashMap<usize, String, char, f64>;
-   |                  ^^^^^^^                    ----- help: remove this type argument
+   |                  ^^^^^^^                      --- help: remove this generic argument
    |                  |
-   |                  expected at most 3 type arguments
+   |                  expected at most 3 generic arguments
    |
-note: struct defined here, with at most 3 type parameters: `K`, `V`, `S`
+note: struct defined here, with at most 3 generic parameters: `K`, `V`, `S`
   --> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL
    |
 LL | pub struct HashMap<K, V, S = RandomState> {
    |            ^^^^^^^ -  -  -
 
+error[E0107]: this struct takes at least 2 generic arguments but 0 generic arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:313:18
+   |
+LL |         type E = HashMap<>;
+   |                  ^^^^^^^ expected at least 2 generic arguments
+   |
+note: struct defined here, with at least 2 generic parameters: `K`, `V`
+  --> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL
+   |
+LL | pub struct HashMap<K, V, S = RandomState> {
+   |            ^^^^^^^ -  -
+help: add missing generic arguments
+   |
+LL |         type E = HashMap<K, V>;
+   |                          ^^^^
+
 error[E0107]: missing generics for enum `Result`
-  --> $DIR/wrong-number-of-args.rs:141:18
+  --> $DIR/wrong-number-of-args.rs:319:18
    |
 LL |         type A = Result;
-   |                  ^^^^^^ expected 2 type arguments
+   |                  ^^^^^^ expected 2 generic arguments
    |
-note: enum defined here, with 2 type parameters: `T`, `E`
+note: enum defined here, with 2 generic parameters: `T`, `E`
   --> $SRC_DIR/core/src/result.rs:LL:COL
    |
 LL | pub enum Result<T, E> {
    |          ^^^^^^ -  -
-help: use angle brackets to add missing type arguments
+help: add missing generic arguments
    |
 LL |         type A = Result<T, E>;
-   |                        ^^^^^^
+   |                  ^^^^^^^^^^^^
 
-error[E0107]: this enum takes 2 type arguments but only 1 type argument was supplied
-  --> $DIR/wrong-number-of-args.rs:145:18
+error[E0107]: this enum takes 2 generic arguments but 1 generic argument was supplied
+  --> $DIR/wrong-number-of-args.rs:323:18
    |
 LL |         type B = Result<String>;
-   |                  ^^^^^^ ------ supplied 1 type argument
+   |                  ^^^^^^ ------ supplied 1 generic argument
    |                  |
-   |                  expected 2 type arguments
+   |                  expected 2 generic arguments
    |
-note: enum defined here, with 2 type parameters: `T`, `E`
+note: enum defined here, with 2 generic parameters: `T`, `E`
   --> $SRC_DIR/core/src/result.rs:LL:COL
    |
 LL | pub enum Result<T, E> {
    |          ^^^^^^ -  -
-help: add missing type argument
+help: add missing generic argument
    |
 LL |         type B = Result<String, E>;
    |                               ^^^
 
 error[E0107]: this enum takes 0 lifetime arguments but 1 lifetime argument was supplied
-  --> $DIR/wrong-number-of-args.rs:149:18
+  --> $DIR/wrong-number-of-args.rs:327:18
    |
 LL |         type C = Result<'static>;
    |                  ^^^^^^--------- help: remove these generics
@@ -413,37 +960,53 @@ note: enum defined here, with 0 lifetime parameters
 LL | pub enum Result<T, E> {
    |          ^^^^^^
 
-error[E0107]: this enum takes 2 type arguments but 0 type arguments were supplied
-  --> $DIR/wrong-number-of-args.rs:149:18
+error[E0107]: this enum takes 2 generic arguments but 0 generic arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:327:18
    |
 LL |         type C = Result<'static>;
-   |                  ^^^^^^ expected 2 type arguments
+   |                  ^^^^^^ expected 2 generic arguments
    |
-note: enum defined here, with 2 type parameters: `T`, `E`
+note: enum defined here, with 2 generic parameters: `T`, `E`
   --> $SRC_DIR/core/src/result.rs:LL:COL
    |
 LL | pub enum Result<T, E> {
    |          ^^^^^^ -  -
-help: add missing type arguments
+help: add missing generic arguments
    |
 LL |         type C = Result<'static, T, E>;
    |                                ^^^^^^
 
-error[E0107]: this enum takes 2 type arguments but 3 type arguments were supplied
-  --> $DIR/wrong-number-of-args.rs:155:18
+error[E0107]: this enum takes 2 generic arguments but 3 generic arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:333:18
    |
 LL |         type D = Result<usize, String, char>;
-   |                  ^^^^^^              ------ help: remove this type argument
+   |                  ^^^^^^                ---- help: remove this generic argument
    |                  |
-   |                  expected 2 type arguments
+   |                  expected 2 generic arguments
    |
-note: enum defined here, with 2 type parameters: `T`, `E`
+note: enum defined here, with 2 generic parameters: `T`, `E`
   --> $SRC_DIR/core/src/result.rs:LL:COL
    |
 LL | pub enum Result<T, E> {
    |          ^^^^^^ -  -
 
-error: aborting due to 30 previous errors
+error[E0107]: this enum takes 2 generic arguments but 0 generic arguments were supplied
+  --> $DIR/wrong-number-of-args.rs:337:18
+   |
+LL |         type E = Result<>;
+   |                  ^^^^^^ expected 2 generic arguments
+   |
+note: enum defined here, with 2 generic parameters: `T`, `E`
+  --> $SRC_DIR/core/src/result.rs:LL:COL
+   |
+LL | pub enum Result<T, E> {
+   |          ^^^^^^ -  -
+help: add missing generic arguments
+   |
+LL |         type E = Result<T, E>;
+   |                         ^^^^
+
+error: aborting due to 69 previous errors
 
 Some errors have detailed explanations: E0106, E0107.
 For more information about an error, try `rustc --explain E0106`.
index 3a9c918cd3720f652e4d5cf49f342e874cd48a5a..8584b650ae689e63e1d6a310fbf53d2fe6e7fb0e 100644 (file)
@@ -31,7 +31,7 @@ LL |             let ...$e;
 LL |     mac!(0);
    |     -------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 5 previous errors
 
index 871c9b57e5444878ae7987f1319b65abdf97a4f0..42c55de28e465e709723456f3e47c897bfc8795e 100644 (file)
@@ -40,7 +40,7 @@ LL |     mac!(0);
    |     -------- in this macro invocation
    |
    = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0586]: inclusive range with no end
   --> $DIR/half-open-range-pats-inclusive-no-end.rs:21:19
@@ -52,7 +52,7 @@ LL |     mac!(0);
    |     -------- in this macro invocation
    |
    = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 6 previous errors
 
index d5343566633d56f75ce1b3b60fdb9dee0992395f..4cca552d7d4739d4328e9ac01547508383840406 100644 (file)
@@ -8,7 +8,7 @@ LL | / check! { bound_a_b_ret_a_vs_bound_a_ret_a: (for<'a,'b> fn(&'a u32, &'b u3
 LL | | for<'a>    fn(&'a u32, &'a u32) -> &'a u32) }
    | |_____________________________________________- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index f6acb34982c9c70c24218488b9fb72e52e25cea9..91bd0b6929ac44cd68987cf07c0816cf62a83d20 100644 (file)
@@ -10,7 +10,7 @@ LL | | for<'a>    fn(&'a u32, &'a u32) -> &'a u32) }
    |
    = note: expected enum `Option<for<'a, 'b> fn(&'a u32, &'b u32) -> &'a u32>`
               found enum `Option<for<'a> fn(&'a u32, &'a u32) -> &'a u32>`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index f11560939675603db95ea999a65a2aa2d2e30476..2c1ac126fabb90c0f9be69f3c0ba18f2d7675bee 100644 (file)
@@ -8,7 +8,7 @@ LL | / check! { bound_a_vs_free_x: (for<'a> fn(&'a u32),
 LL | | fn(&'x u32)) }
    | |______________- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index ebad4b93dcaed5991b116b8e6d03a1e112f53e86..27ce56fc16afa6845f4d33abe98e8036960dd4f7 100644 (file)
@@ -10,7 +10,7 @@ LL | | fn(&'x u32)) }
    |
    = note: expected enum `Option<for<'a> fn(&'a u32)>`
               found enum `Option<fn(&'x u32)>`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 4541c462ee0565c8bebcceb8ecc3bd2d4e2cea95..816984654f7f7302df16b03cfa85cd40f917d554 100644 (file)
@@ -8,7 +8,7 @@ LL | / check! { bound_inv_a_b_vs_bound_inv_a: (for<'a,'b> fn(Inv<'a>, Inv<'b>),
 LL | | for<'a>    fn(Inv<'a>, Inv<'a>)) }
    | |__________________________________- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: higher-ranked subtype error
   --> $DIR/hr-subtype.rs:45:13
@@ -20,7 +20,7 @@ LL | / check! { bound_inv_a_b_vs_bound_inv_a: (for<'a,'b> fn(Inv<'a>, Inv<'b>),
 LL | | for<'a>    fn(Inv<'a>, Inv<'a>)) }
    | |__________________________________- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index 40a0ff97b63e605ea4faedbd9b86158c2be10add..bb20f81a1deefed6b1c1414130afb24c1c9e9966 100644 (file)
@@ -10,7 +10,7 @@ LL | | for<'a>    fn(Inv<'a>, Inv<'a>)) }
    |
    = note: expected enum `Option<for<'a, 'b> fn(Inv<'a>, Inv<'b>)>`
               found enum `Option<for<'a> fn(Inv<'a>, Inv<'a>)>`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index af5cf41be0a48f279b49f81e9961cd5cbf91785c..e25acebf7f6a882976fb06ce9ce0ed997ab23881 100644 (file)
@@ -13,7 +13,7 @@ LL | | fn(Inv<'y>)) }
    | |______________- in this macro invocation
    |
    = help: consider adding the following bound: `'x: 'y`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: lifetime may not live long enough
   --> $DIR/hr-subtype.rs:45:13
@@ -30,7 +30,7 @@ LL | | fn(Inv<'y>)) }
    | |______________- in this macro invocation
    |
    = help: consider adding the following bound: `'x: 'y`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index d2f40f7fb5e605297f6edc86c8bbbb3fe727aca7..8b0e36ab5f6b1062e7ff3b9cb3b884ebf10264aa 100644 (file)
@@ -28,7 +28,7 @@ LL |           fn subtype<'x, 'y: 'x, 'z: 'y>() {
 LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>),
 LL | | fn(Inv<'y>)) }
    | |______________- in this macro invocation
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0308]: mismatched types
   --> $DIR/hr-subtype.rs:45:26
@@ -60,7 +60,7 @@ LL |           fn supertype<'x, 'y: 'x, 'z: 'y>() {
 LL | / check! { free_inv_x_vs_free_inv_y: (fn(Inv<'x>),
 LL | | fn(Inv<'y>)) }
    | |______________- in this macro invocation
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index 75d7e0e46b72a75d25055944a0af69b368d81a7f..ab97481824d82209d145326aa559d1d840eb679b 100644 (file)
@@ -13,7 +13,7 @@ LL | | fn(&'y u32)) }
    | |______________- in this macro invocation
    |
    = help: consider adding the following bound: `'x: 'y`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 57610beb862fa26636befa0711abf63d39d9d8fc..fb1127f7f402c9a5185a937e4315d2500ed8cfc3 100644 (file)
@@ -28,7 +28,7 @@ LL |           fn supertype<'x, 'y: 'x, 'z: 'y>() {
 LL | / check! { free_x_vs_free_y: (fn(&'x u32),
 LL | | fn(&'y u32)) }
    | |______________- in this macro invocation
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `check` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index dec1bd62ca936fa8d03a547b8a8368635f28c2e3..6e4fecf0ce4b234fad77637e771efae6104e0e1f 100644 (file)
@@ -7,7 +7,7 @@ LL |             fn method() {}
 LL |     mac_trait_impl!();
    |     ------------------ in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `mac_trait_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0046]: not all trait items implemented, missing: `method`
   --> $DIR/assoc_item_ctxt.rs:34:9
@@ -21,7 +21,7 @@ LL |         impl Tr for u8 {
 LL |     mac_trait_impl!();
    |     ------------------ in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `mac_trait_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index 04f5bed5e05eaff01baf550d7fd67c0083973b52..b699142c6787a8edb25f7441cb8c04bb49ef21fb 100644 (file)
@@ -10,7 +10,7 @@ LL | m!('a);
    | |  previous declaration here
    | in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0263]: lifetime name `'a` declared twice in the same scope
   --> $DIR/duplicate_lifetimes.rs:13:14
@@ -24,7 +24,7 @@ LL | n!('a);
    | |  previous declaration here
    | in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `n` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index d3e6021a1ed074f2f49cbe00aa307ab33299c075..98e15c9aad050152a64b274c9b498557fa519a08 100644 (file)
@@ -16,7 +16,7 @@ LL |         use my_core;
 LL | a!();
    | ----- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `a` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0433]: failed to resolve: use of undeclared crate or module `my_core`
   --> $DIR/extern-prelude-from-opaque-fail.rs:11:18
@@ -27,7 +27,7 @@ LL |         fn f() { my_core::mem::drop(0); }
 LL | a!();
    | ----- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `a` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0433]: failed to resolve: use of undeclared crate or module `my_core`
   --> $DIR/extern-prelude-from-opaque-fail.rs:24:14
index fd8846bb13c88de3193341b760e7645e9f12a021..0c62c00aabc18e7d07f50e3680d2eebd9090bb79 100644 (file)
@@ -9,7 +9,7 @@ LL |             $a: u8,
 LL | legacy!(a);
    | ----------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `legacy` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 5ce786dce837c078706231893d2c5bd7241a9787..b5b507c7daa55d0f5898f1871393135506114b61 100644 (file)
@@ -10,7 +10,7 @@ LL |     assert_two_copies(copy_legacy!(foo), foo.x);
    |                       ----------------- in this macro invocation
    |
    = note: move occurs because `foo.x` has type `NonCopy`, which does not implement the `Copy` trait
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `copy_legacy` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0382]: use of moved value: `foo.x`
   --> $DIR/fields-move.rs:28:42
index 3666aeabfa7736420f00b0ac0f9fb29d99b216ef..978120b1f101d7f01f39d95ae7b14e515704abf5 100644 (file)
@@ -7,7 +7,7 @@ LL |         let s = S { x: 0 };
 LL |     let s = foo::m!(S, x);
    |             ------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `foo::m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `foo::S` is private
   --> $DIR/fields.rs:16:17
@@ -18,7 +18,7 @@ LL |         let _ = s.x;
 LL |     let s = foo::m!(S, x);
    |             ------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `foo::m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `T` is private
   --> $DIR/fields.rs:18:17
@@ -29,7 +29,7 @@ LL |         let t = T(0);
 LL |     let s = foo::m!(S, x);
    |             ------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `foo::m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `T` is private
   --> $DIR/fields.rs:19:17
@@ -40,7 +40,7 @@ LL |         let _ = t.0;
 LL |     let s = foo::m!(S, x);
    |             ------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `foo::m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 4 previous errors
 
index 073e1527b2e111f978c3769e89809dec817b9451..d96f8329fbde429e8e5cfc599c52472615d24455 100644 (file)
@@ -19,7 +19,7 @@ LL |         type A = FromOutside;
 LL |     genmod_transparent!();
    |     ---------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `genmod_transparent` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0412]: cannot find type `Outer` in this scope
   --> $DIR/generate-mod.rs:20:22
@@ -30,7 +30,7 @@ LL |         type Inner = Outer;
 LL |     genmod_transparent!();
    |     ---------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `genmod_transparent` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0412]: cannot find type `FromOutside` in this scope
   --> $DIR/generate-mod.rs:28:18
@@ -41,7 +41,7 @@ LL |         type A = FromOutside;
 LL |     genmod_legacy!();
    |     ----------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `genmod_legacy` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0412]: cannot find type `Outer` in this scope
   --> $DIR/generate-mod.rs:29:22
@@ -52,7 +52,7 @@ LL |         type Inner = Outer;
 LL |     genmod_legacy!();
    |     ----------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `genmod_legacy` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 6 previous errors
 
index 6dcbf055a8bb78fbc0f968c83b6c146e253b2189..c2497f8ff74d2629ef0f0a00e6a2e384a5bfa5f5 100644 (file)
@@ -22,7 +22,7 @@ LL | |         f();
 LL | |     }
    | |_____- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
 help: consider importing this function
    |
 LL | use bar::g;
@@ -39,7 +39,7 @@ LL |         n!(f);
    |
    = note: consider importing one of these items:
            foo::f
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `n` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0425]: cannot find function `f` in this scope
   --> $DIR/globs.rs:65:17
@@ -52,7 +52,7 @@ LL |                 f
    |
    = note: consider importing one of these items:
            foo::f
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `n` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 4 previous errors
 
index 60df494e131c66bb0c5ceb3d948504d7c342770e..97a7240b9069b60329a5b341251d4b37e04c14a3 100644 (file)
@@ -7,7 +7,7 @@ LL |     () => { break 'x; }
 LL |     'x: loop { foo!() }
    |                ------ in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index dbec71fcaa4023244a1062c33f2b1959e4b4270d..52840049f825aa52e6ed6167f83f72c2ab7e9849 100644 (file)
@@ -7,7 +7,7 @@ LL |     () => { break 'x; }
 LL |         foo!()
    |         ------ in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 9e7811b807210d4ee4a49fbfe358cdf52f6f62f2..afca48fe847206a173b9476f535d8a83e52d8ebe 100644 (file)
@@ -10,7 +10,7 @@ LL |             // this 'x should refer to the outer loop, lexically
 LL |             loop_x!(break 'x);
    |             ------------------ in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `loop_x` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels-in-let.rs:64:9
@@ -42,7 +42,7 @@ LL |         'x: loop {
 LL |             loop_x!(break 'x);
    |             ------------------ in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `loop_x` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels-in-let.rs:16:9
@@ -56,7 +56,7 @@ LL |         'x: loop { $e }
 LL |             loop_x!(break 'x);
    |             ------------------ in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `loop_x` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels-in-let.rs:16:9
@@ -70,7 +70,7 @@ LL |         'x: for _ in 0..1 {
 LL |             loop_x!(break 'x);
    |             ------------------ in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `loop_x` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels-in-let.rs:76:9
@@ -120,7 +120,7 @@ LL |         'x: loop {
 LL |             while_true!(break 'x);
    |             ---------------------- in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `while_true` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels-in-let.rs:27:9
@@ -134,7 +134,7 @@ LL |         'x: while 1 + 1 == 2 { $e }
 LL |             while_true!(break 'x);
    |             ---------------------- in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `while_true` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels-in-let.rs:27:9
@@ -148,7 +148,7 @@ LL |         'x: for _ in 0..1 {
 LL |             while_true!(break 'x);
    |             ---------------------- in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `while_true` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels-in-let.rs:27:9
@@ -162,7 +162,7 @@ LL |         'x: while 1 + 1 == 2 { $e }
 LL |             while_true!(break 'x);
    |             ---------------------- in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `while_true` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels-in-let.rs:27:9
@@ -176,7 +176,7 @@ LL |         'x: for _ in 0..1 {
 LL |             while_true!(break 'x);
    |             ---------------------- in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `while_true` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels-in-let.rs:90:9
@@ -244,7 +244,7 @@ LL |         'x: loop {
 LL |             run_once!(continue 'x);
    |             ----------------------- in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `run_once` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels-in-let.rs:39:9
@@ -258,7 +258,7 @@ LL |         'x: for _ in 0..1 { $e }
 LL |             run_once!(continue 'x);
    |             ----------------------- in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `run_once` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels-in-let.rs:39:9
@@ -272,7 +272,7 @@ LL |         'x: for _ in 0..1 {
 LL |             run_once!(continue 'x);
    |             ----------------------- in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `run_once` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels-in-let.rs:39:9
@@ -286,7 +286,7 @@ LL |         'x: for _ in 0..1 { $e }
 LL |             run_once!(continue 'x);
    |             ----------------------- in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `run_once` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels-in-let.rs:39:9
@@ -300,7 +300,7 @@ LL |         'x: for _ in 0..1 {
 LL |             run_once!(continue 'x);
    |             ----------------------- in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `run_once` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels-in-let.rs:39:9
@@ -314,7 +314,7 @@ LL |         'x: for _ in 0..1 { $e }
 LL |             run_once!(continue 'x);
    |             ----------------------- in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `run_once` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels-in-let.rs:39:9
@@ -328,7 +328,7 @@ LL |         'x: for _ in 0..1 {
 LL |             run_once!(continue 'x);
    |             ----------------------- in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `run_once` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: 28 warnings emitted
 
index 275478d292d952af873cb786987853d100c6274f..8c14e4f8a499f429da4014077bc8ea3229e59b6d 100644 (file)
@@ -10,7 +10,7 @@ LL |         // this 'x should refer to the outer loop, lexically
 LL |         loop_x!(break 'x);
    |         ------------------ in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `loop_x` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels.rs:54:5
@@ -42,7 +42,7 @@ LL |     'x: for _ in 0..1 {
 LL |         loop_x!(break 'x);
    |         ------------------ in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `loop_x` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels.rs:13:9
@@ -56,7 +56,7 @@ LL |         'x: loop { $e }
 LL |         loop_x!(break 'x);
    |         ------------------ in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `loop_x` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels.rs:13:9
@@ -70,7 +70,7 @@ LL |     'x: loop {
 LL |         loop_x!(break 'x);
    |         ------------------ in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `loop_x` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels.rs:63:5
@@ -120,7 +120,7 @@ LL |     'x: for _ in 0..1 {
 LL |         while_x!(break 'x);
    |         ------------------- in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `while_x` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels.rs:38:9
@@ -134,7 +134,7 @@ LL |         'x: while 1 + 1 == 2 { $e }
 LL |         while_x!(break 'x);
    |         ------------------- in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `while_x` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels.rs:38:9
@@ -148,7 +148,7 @@ LL |     'x: loop {
 LL |         while_x!(break 'x);
    |         ------------------- in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `while_x` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels.rs:38:9
@@ -162,7 +162,7 @@ LL |         'x: while 1 + 1 == 2 { $e }
 LL |         while_x!(break 'x);
    |         ------------------- in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `while_x` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels.rs:38:9
@@ -176,7 +176,7 @@ LL |     'x: while 1 + 1 == 2 {
 LL |         while_x!(break 'x);
    |         ------------------- in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `while_x` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels.rs:73:5
@@ -244,7 +244,7 @@ LL |     'x: for _ in 0..1 {
 LL |         run_once!(continue 'x);
    |         ----------------------- in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `run_once` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels.rs:24:9
@@ -258,7 +258,7 @@ LL |         'x: for _ in 0..1 { $e }
 LL |         run_once!(continue 'x);
    |         ----------------------- in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `run_once` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels.rs:24:9
@@ -272,7 +272,7 @@ LL |     'x: loop {
 LL |         run_once!(continue 'x);
    |         ----------------------- in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `run_once` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels.rs:24:9
@@ -286,7 +286,7 @@ LL |         'x: for _ in 0..1 { $e }
 LL |         run_once!(continue 'x);
    |         ----------------------- in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `run_once` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels.rs:24:9
@@ -300,7 +300,7 @@ LL |     'x: while 1 + 1 == 2 {
 LL |         run_once!(continue 'x);
    |         ----------------------- in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `run_once` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels.rs:24:9
@@ -314,7 +314,7 @@ LL |         'x: while 1 + 1 == 2 { $e }
 LL |         run_once!(continue 'x);
    |         ----------------------- in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `run_once` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: label name `'x` shadows a label name that is already in scope
   --> $DIR/hygienic-labels.rs:24:9
@@ -328,7 +328,7 @@ LL |     'x: for _ in 0..1 {
 LL |         run_once!(continue 'x);
    |         ----------------------- in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `run_once` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: 28 warnings emitted
 
index 8ac59263cf21a247d029aee8a80a0000ce45aed3..9fefa29c4d081f4b9337c923ed9dc4e5664a6f7e 100644 (file)
@@ -7,7 +7,7 @@ LL |         let _: () = S.f();
 LL |     foo::m!();
    |     ---------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `foo::m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index cd593abf530e88d9e084c9d97eaae9c8bbb160ed..91358b279e2b2f6c19d99930d9f6bda90254f86d 100644 (file)
@@ -4,7 +4,7 @@ error: type `fn() -> u32 {foo::bar::f}` is private
 LL |     assert_eq!(intercrate::foo::m!(), 1);
    |                ^^^^^^^^^^^^^^^^^^^^^ private type
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `intercrate::foo::m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 075d6b76bb7b2bf017af7ed88353ed3e7dfc3ce9..b5370209f9d0efc86a086f47db36ab83ec3c367e 100644 (file)
@@ -10,7 +10,7 @@ LL | |         call_bar!();
 LL | |     }
    | |_____- this function has a `self` parameter, but a macro invocation can only access identifiers it receives from parameters
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `call_bar` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 835ecce94b97a759346f0855eafc2a628a6b2cdf..4f49b3106edc405b9b3c709d368f25f16ae3d035 100644 (file)
@@ -7,7 +7,7 @@ LL |     fn f() { ::bar::m!(); }
 LL |         Vec::new();
    |         ^^^ not found in this scope
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `::bar::m` (in Nightly builds, run with -Z macro-backtrace for more info)
 help: consider importing this struct
    |
 LL |     use std::vec::Vec;
@@ -25,7 +25,7 @@ LL |         ().clone()
    = help: items from traits can only be used if the trait is in scope
    = note: the following trait is implemented but not in scope; perhaps add a `use` for it:
            `use std::clone::Clone;`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `::bar::m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index afc94bf79f6825a5f7add141ce452693061746fc..42aee62e0970c30e87125a3b6a63bcaf359a2a69 100644 (file)
@@ -15,7 +15,7 @@ LL |         use f as g;
 ...
 LL |     foo::m!();
    |     ---------- in this macro invocation
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `foo::m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 2913a955dce1b2cf37ff2c61d62528093fb1f549..f16bb80dbb8568dbf5897d24f0dfa3b2679eca0f 100644 (file)
@@ -13,7 +13,7 @@ LL |     pub macro m() { ().f() }
    = help: items from traits can only be used if the trait is in scope
    = note: the following trait is implemented but not in scope; perhaps add a `use` for it:
            `use foo::T;`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `::baz::m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 96044a89289464a86d01f8d1b44be3a9beb7741f..e3445a4b80f7b00564a98746ccd9330a0e839ff9 100644 (file)
@@ -20,7 +20,7 @@ fn y /* 0#0 */() { }
 /*
 Expansions:
 0: parent: ExpnId(0), call_site_ctxt: #0, def_site_ctxt: #0, kind: Root
-1: parent: ExpnId(0), call_site_ctxt: #0, def_site_ctxt: #0, kind: Macro(Bang, "foo")
+1: parent: ExpnId(0), call_site_ctxt: #0, def_site_ctxt: #0, kind: Macro { kind: Bang, name: "foo", proc_macro: false }
 
 SyntaxContexts:
 #0: parent: #0, outer_mark: (ExpnId(0), Opaque)
index 011ea02050820c1938543003816caec73f69410e..ade757127794a3492b47aba48c1ea196b9369e31 100644 (file)
@@ -7,7 +7,7 @@ LL |         extern crate std as non_existent;
 LL | define_std_as_non_existent!();
    | ------------------------------ in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `define_std_as_non_existent` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0433]: failed to resolve: use of undeclared crate or module `two_macros`
   --> $DIR/extern-prelude-extern-crate-fail.rs:10:9
index 4cda07758527ae0e99e653e9cbfd1e4e9594b64e..089a897f1c29aa812029f364b61e425aebafc202 100644 (file)
@@ -7,7 +7,7 @@ LL |         extern crate std as core;
 LL | define_other_core!();
    | --------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `define_other_core` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0659]: `Vec` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/extern-prelude-extern-crate-restricted-shadowing.rs:13:9
@@ -28,7 +28,7 @@ note: `Vec` could also refer to the struct defined here
    |
 LL |     pub use super::v1::*;
    |             ^^^^^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `define_vec` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index 6bc2d15b2ff1b33d354e630d4beb0ef099287a20..fd4c76c1fa4b2c1860bfe19b8a346f28bc830dcf 100644 (file)
@@ -4,7 +4,7 @@ error: `$crate` may not be imported
 LL |     m!();
    |     ^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 2ecc519e718f6910958bb37129eb5a17a9aa4f8d..8868ee3aeaadd05cd85725f245651c60d4e77b65 100644 (file)
@@ -7,7 +7,7 @@ LL |     ($p: path) => (use $p {S, Z});
 LL | import! { a::b::c }
    | ------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `import` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 80317a34944c6306fe95cd0738672e75a377f2c2..23f8d57645d18dce34c670e50766a46e98a6b80c 100644 (file)
@@ -7,7 +7,7 @@ LL |     ($p: path) => (use ::$p {S, Z});
 LL | import! { a::b::c }
    | ------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `import` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index ea720c8b8730dd7200cc02473516a13620439514..9983073ece7cd3e67a34ccddea9d38d242c5ba22 100644 (file)
@@ -20,7 +20,7 @@ note: `exported` could also refer to the macro imported here
 LL | use inner1::*;
    |     ^^^^^^^^^
    = help: consider adding an explicit import of `exported` to disambiguate
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `define_exported` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0659]: `exported` is ambiguous (glob import vs macro-expanded name in the same module during import/macro resolution)
   --> $DIR/local-modularized-tricky-fail-1.rs:28:1
@@ -44,7 +44,7 @@ note: `exported` could also refer to the macro imported here
 LL | use inner1::*;
    |     ^^^^^^^^^
    = help: consider adding an explicit import of `exported` to disambiguate
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `define_exported` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0659]: `panic` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/local-modularized-tricky-fail-1.rs:36:5
@@ -64,7 +64,7 @@ LL | |     }
 LL |       define_panic!();
    |       ---------------- in this macro invocation
    = help: use `crate::panic` to refer to this macro unambiguously
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `define_panic` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0659]: `include` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/local-modularized-tricky-fail-1.rs:47:1
@@ -84,7 +84,7 @@ LL | |     }
 LL |       define_include!();
    |       ------------------ in this macro invocation
    = help: use `crate::include` to refer to this macro unambiguously
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `define_include` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 4 previous errors
 
index 5cc6fa1e40a8844f5d1bba9b2bf0e90497a0ba8f..ab9f1eca23d921c2cd87b62f730be9e57aa3c837 100644 (file)
@@ -17,7 +17,7 @@ LL | |     }
 ...
 LL |   define_exported!();
    |   ------------------- in this macro invocation
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `define_exported` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths
   --> $DIR/local-modularized-tricky-fail-2.rs:19:5
@@ -37,7 +37,7 @@ LL | |     }
 ...
 LL |   define_exported!();
    |   ------------------- in this macro invocation
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `define_exported` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index 413ead8c25edc2fc50c57467363e79ed16e73faa..82d8078856d58dad06513392a39eb266248d09e1 100644 (file)
@@ -28,7 +28,7 @@ LL |         macro_rules! panic { () => {} }
 LL |     } }
 LL |     m!();
    |     ----- in this macro invocation
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0659]: `n` is ambiguous (glob import vs any other name from outer scope during import/macro resolution)
   --> $DIR/shadow_builtin_macros.rs:49:5
index 6eddd9c411bc5934ade5eb8c4a313ec7b364874f..7094f427aa4601b37a38c304b7c2927a7249b256 100644 (file)
@@ -37,7 +37,7 @@ LL |         fn $fn_name(gift: &str) -> $type_name {
 LL | autowrapper!(Autowrapped, autowrap_gift, 'a);
    | --------------------------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `autowrapper` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: hidden lifetime parameters in types are deprecated
   --> $DIR/elided-lifetimes.rs:78:18
@@ -54,7 +54,7 @@ LL |         Ref<($($types),*)>
 LL |     let yellow: anytuple_ref_ty!(bool, &str) = laughter.borrow();
    |                 ---------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `anytuple_ref_ty` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 7 previous errors
 
index d035df8e5d83adfbab010e8314762ebd3688cf62..a408877afb61c9c299b3ff14e2f39e89b649c0f7 100644 (file)
@@ -8,7 +8,7 @@ LL |     let b: &[u8] = include_str!("file.txt");
    |
    = note: expected reference `&[u8]`
               found reference `&'static str`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `include_str` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0308]: mismatched types
   --> $DIR/mismatched-types.rs:3:19
@@ -20,7 +20,7 @@ LL |     let s: &str = include_bytes!("file.txt");
    |
    = note: expected reference `&str`
               found reference `&'static [u8; 0]`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `include_bytes` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index c9254915d030d5ead6dd9cfe83c892b4cdeab5aa..c7d9118d3f3a879d19860fdd5cdb9309cb50b183 100644 (file)
@@ -8,7 +8,7 @@ LL |     recursive!()
    |     ------------ in this macro invocation
    |
    = help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`infinite_macro_expansion`)
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `recursive` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 554c67be4e0b04ef6cf4b3f61c1fcc5272d208ec..470262a15ba0dea88f7e7bf4871ae79b3def2273 100644 (file)
@@ -3,7 +3,7 @@
 #![stable(feature = "rust1", since = "1.0.0")]
 
 #![feature(staged_api)]
-#![feature(const_transmute, const_fn)]
+#![feature(const_transmute)]
 
 #[stable(feature = "rust1", since = "1.0.0")]
 #[rustc_const_stable(feature = "rust1", since = "1.0.0")]
index ede8e5437ffbc4964e28162820987e04f4d55185..29680c0a630ea97359672470b7409427e8f12a13 100644 (file)
@@ -5,7 +5,7 @@ LL |     call_unstable_noallow!();
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: add `#![feature(function)]` to the crate attributes to enable
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `call_unstable_noallow` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0658]: use of unstable library feature 'struct_field'
   --> $DIR/internal-unstable-noallow.rs:18:5
@@ -14,7 +14,7 @@ LL |     construct_unstable_noallow!(0);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: add `#![feature(struct_field)]` to the crate attributes to enable
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `construct_unstable_noallow` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0658]: use of unstable library feature 'method'
   --> $DIR/internal-unstable-noallow.rs:20:35
@@ -23,7 +23,7 @@ LL |     |x: internal_unstable::Foo| { call_method_noallow!(x) };
    |                                   ^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: add `#![feature(method)]` to the crate attributes to enable
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `call_method_noallow` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0658]: use of unstable library feature 'struct2_field'
   --> $DIR/internal-unstable-noallow.rs:22:35
@@ -32,7 +32,7 @@ LL |     |x: internal_unstable::Bar| { access_field_noallow!(x) };
    |                                   ^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: add `#![feature(struct2_field)]` to the crate attributes to enable
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `access_field_noallow` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 4 previous errors
 
index a92ca4957b573314aefeb3ef6d6a0efdc0475c94..5261a79dfa2e10344129c49b66140df035037039 100644 (file)
@@ -40,7 +40,7 @@ LL |     bar!(internal_unstable::unstable());
    |     ------------------------------------ in this macro invocation
    |
    = help: add `#![feature(function)]` to the crate attributes to enable
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 5 previous errors
 
diff --git a/src/test/ui/intrinsics/unchecked_math_unsafe.mir.stderr b/src/test/ui/intrinsics/unchecked_math_unsafe.mir.stderr
new file mode 100644 (file)
index 0000000..26b2f9f
--- /dev/null
@@ -0,0 +1,27 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/unchecked_math_unsafe.rs:8:15
+   |
+LL |     let add = std::intrinsics::unchecked_add(x, y);
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/unchecked_math_unsafe.rs:9:15
+   |
+LL |     let sub = std::intrinsics::unchecked_sub(x, y);
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/unchecked_math_unsafe.rs:10:15
+   |
+LL |     let mul = std::intrinsics::unchecked_mul(x, y);
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0133`.
index a034b45f5308c8a2d5e1ff98bb8f5949d7e833ed..98d3a11ad027643ede5c575a27bdbabdb76e4f4f 100644 (file)
@@ -1,3 +1,6 @@
+// revisions: mir thir
+// [thir]compile-flags: -Z thir-unsafeck
+
 #![feature(core_intrinsics)]
 
 fn main() {
diff --git a/src/test/ui/intrinsics/unchecked_math_unsafe.stderr b/src/test/ui/intrinsics/unchecked_math_unsafe.stderr
deleted file mode 100644 (file)
index 4066cf8..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/unchecked_math_unsafe.rs:5:15
-   |
-LL |     let add = std::intrinsics::unchecked_add(x, y);
-   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
-   |
-   = note: consult the function's documentation for information on how to avoid undefined behavior
-
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/unchecked_math_unsafe.rs:6:15
-   |
-LL |     let sub = std::intrinsics::unchecked_sub(x, y);
-   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
-   |
-   = note: consult the function's documentation for information on how to avoid undefined behavior
-
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/unchecked_math_unsafe.rs:7:15
-   |
-LL |     let mul = std::intrinsics::unchecked_mul(x, y);
-   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
-   |
-   = note: consult the function's documentation for information on how to avoid undefined behavior
-
-error: aborting due to 3 previous errors
-
-For more information about this error, try `rustc --explain E0133`.
diff --git a/src/test/ui/intrinsics/unchecked_math_unsafe.thir.stderr b/src/test/ui/intrinsics/unchecked_math_unsafe.thir.stderr
new file mode 100644 (file)
index 0000000..26b2f9f
--- /dev/null
@@ -0,0 +1,27 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/unchecked_math_unsafe.rs:8:15
+   |
+LL |     let add = std::intrinsics::unchecked_add(x, y);
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/unchecked_math_unsafe.rs:9:15
+   |
+LL |     let sub = std::intrinsics::unchecked_sub(x, y);
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/unchecked_math_unsafe.rs:10:15
+   |
+LL |     let mul = std::intrinsics::unchecked_mul(x, y);
+   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0133`.
diff --git a/src/test/ui/invalid/invalid-rustc_args_required_const-arguments.rs b/src/test/ui/invalid/invalid-rustc_args_required_const-arguments.rs
deleted file mode 100644 (file)
index 99508ba..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#![feature(rustc_attrs)]
-
-#[rustc_args_required_const(0)] //~ ERROR index exceeds number of arguments
-fn foo1() {}
-
-#[rustc_args_required_const(1)] //~ ERROR index exceeds number of arguments
-fn foo2(_: u8) {}
-
-#[rustc_args_required_const(a)] //~ ERROR arguments should be non-negative integers
-fn foo4() {}
-
-#[rustc_args_required_const(1, a, 2, b)] //~ ERROR arguments should be non-negative integers
-fn foo5(_: u8, _: u8, _: u8) {}
-
-#[rustc_args_required_const(0)] //~ ERROR attribute should be applied to a function
-struct S;
-
-#[rustc_args_required_const(0usize)] //~ ERROR suffixed literals are not allowed in attributes
-fn foo6(_: u8) {}
-
-extern {
-    #[rustc_args_required_const(1)] //~ ERROR index exceeds number of arguments
-    fn foo7(_: u8);
-}
-
-#[rustc_args_required_const] //~ ERROR malformed `rustc_args_required_const` attribute
-fn bar1() {}
-
-#[rustc_args_required_const = 1] //~ ERROR malformed `rustc_args_required_const` attribute
-fn bar2() {}
-
-fn main() {}
diff --git a/src/test/ui/invalid/invalid-rustc_args_required_const-arguments.stderr b/src/test/ui/invalid/invalid-rustc_args_required_const-arguments.stderr
deleted file mode 100644 (file)
index 932344f..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-error: suffixed literals are not allowed in attributes
-  --> $DIR/invalid-rustc_args_required_const-arguments.rs:18:29
-   |
-LL | #[rustc_args_required_const(0usize)]
-   |                             ^^^^^^
-   |
-   = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.)
-
-error: malformed `rustc_args_required_const` attribute input
-  --> $DIR/invalid-rustc_args_required_const-arguments.rs:26:1
-   |
-LL | #[rustc_args_required_const]
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_args_required_const(N)]`
-
-error: malformed `rustc_args_required_const` attribute input
-  --> $DIR/invalid-rustc_args_required_const-arguments.rs:29:1
-   |
-LL | #[rustc_args_required_const = 1]
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_args_required_const(N)]`
-
-error: index exceeds number of arguments
-  --> $DIR/invalid-rustc_args_required_const-arguments.rs:3:29
-   |
-LL | #[rustc_args_required_const(0)]
-   |                             ^ there are only 0 arguments
-
-error: index exceeds number of arguments
-  --> $DIR/invalid-rustc_args_required_const-arguments.rs:6:29
-   |
-LL | #[rustc_args_required_const(1)]
-   |                             ^ there is only 1 argument
-
-error: arguments should be non-negative integers
-  --> $DIR/invalid-rustc_args_required_const-arguments.rs:9:29
-   |
-LL | #[rustc_args_required_const(a)]
-   |                             ^
-
-error: arguments should be non-negative integers
-  --> $DIR/invalid-rustc_args_required_const-arguments.rs:12:32
-   |
-LL | #[rustc_args_required_const(1, a, 2, b)]
-   |                                ^     ^
-
-error: attribute should be applied to a function
-  --> $DIR/invalid-rustc_args_required_const-arguments.rs:15:1
-   |
-LL | #[rustc_args_required_const(0)]
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-LL | struct S;
-   | --------- not a function
-
-error: index exceeds number of arguments
-  --> $DIR/invalid-rustc_args_required_const-arguments.rs:22:33
-   |
-LL |     #[rustc_args_required_const(1)]
-   |                                 ^ there is only 1 argument
-
-error: aborting due to 9 previous errors
-
index 0b70452a24d7177777498105eefcc171fe83dafe..389c9c35101ab4367eee05aeda41003eb3487b3d 100644 (file)
@@ -3,3 +3,15 @@
 pub fn make_bar() -> Bar {
     Bar(1, 12, 10)
 }
+
+mod inner {
+    pub struct Foo(u8, pub u8, u8);
+
+    impl Foo {
+        pub fn new() -> Foo {
+            Foo(1, 12, 10)
+        }
+    }
+}
+
+pub use inner::Foo;
index 895b415a7e2e1e7eb75cab94435aefd384f6cfc6..695d657cb529ca65e272d02b9a84d7d8a3939089 100644 (file)
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
 LL | fn bar(x: isize) { }
    | ^^^^^^^^^^^^^^^^^^^^ expected `isize`, found `&mut Bencher`
    |
-   = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the attribute macro `bench` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 962f8ee9ddb593ee29114e39393f85c894e918ea..30fb73dd37282a8b54800c39a7ffd60eba0b8d65 100644 (file)
@@ -6,7 +6,7 @@ LL | static VEC: [u32; 256] = vec![];
    |
    = note: expected array `[u32; 256]`
              found struct `Vec<_>`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 499ebe977edc4cd33bb1f7f99fdb03c1e58061e7..acf837d0f76b8fda226feaa76fac8338a841283e 100644 (file)
@@ -5,7 +5,7 @@ LL |     assert!(x, x);
    |     ^^^^^^^^^^^^^^ cannot apply unary operator `!`
    |
    = note: an implementation of `std::ops::Not` might be missing for `BytePos`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index fc49cc6d68ea02b673f36d1d8332bf1a409abe0d..9e9c7a596961f032e705d45d3fdc61f95e35f248 100644 (file)
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
 LL |     assert!(1,1);
    |     ^^^^^^^^^^^^^ expected `bool`, found integer
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 5cacce751c925bd27721baa4a2aabe19b0ba076e..1aa278b450f9f15ed7afc63c08339a545dac68b9 100644 (file)
@@ -2,19 +2,19 @@ error[E0107]: missing generics for struct `Box`
   --> $DIR/issue-14092.rs:1:11
    |
 LL | fn fn1(0: Box) {}
-   |           ^^^ expected at least 1 type argument
+   |           ^^^ expected at least 1 generic argument
    |
-note: struct defined here, with at least 1 type parameter: `T`
+note: struct defined here, with at least 1 generic parameter: `T`
   --> $SRC_DIR/alloc/src/boxed.rs:LL:COL
    |
 LL | pub struct Box<
    |            ^^^
 LL |     T: ?Sized,
    |     -
-help: use angle brackets to add missing type argument
+help: add missing generic argument
    |
 LL | fn fn1(0: Box<T>) {}
-   |              ^^^
+   |           ^^^^^^
 
 error: aborting due to previous error
 
index fff28b0c3afc45b32f237c08f40f959349a5e6b0..53082ea0ec6bb4989fed6ddee21c0882f698852d 100644 (file)
@@ -7,7 +7,7 @@ LL | macro_rules! f { () => (n) }
 LL |         println!("{}", f!());
    |                        ---- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `f` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0425]: cannot find value `n` in this scope
   --> $DIR/issue-15167.rs:3:25
@@ -18,7 +18,7 @@ LL | macro_rules! f { () => (n) }
 LL |         println!("{}", f!());
    |                        ---- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `f` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0425]: cannot find value `n` in this scope
   --> $DIR/issue-15167.rs:3:25
@@ -29,7 +29,7 @@ LL | macro_rules! f { () => (n) }
 LL |         println!("{}", f!());
    |                        ---- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `f` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0425]: cannot find value `n` in this scope
   --> $DIR/issue-15167.rs:3:25
@@ -40,7 +40,7 @@ LL | macro_rules! f { () => (n) }
 LL |         println!("{}", f!());
    |                        ---- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `f` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 4 previous errors
 
index 077c720a9cdb46e9123275533b82075d6bb13cf3..a63bcd9ba5c760f650ea2fe6ed2763547daf0a69 100644 (file)
@@ -8,7 +8,7 @@ LL |     println!("Problem 1: {}", prob1!(1000));
    |                               ------------ in this macro invocation
    |
    = help: consider adding a `#![recursion_limit="256"]` attribute to your crate (`issue_16098`)
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `prob1` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 30932a375b1f01924f3fa0c20d98e8683d49ef95..f9467af9e3c4c0a68153e0409f7a4016ef5d88a9 100644 (file)
@@ -4,7 +4,7 @@ error[E0282]: type annotations needed
 LL |     panic!(std::default::Default::default());
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `M` declared on the function `begin_panic`
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index f9006235234b3f0c901911a4414062db1505498c..4711a3f3ce07ef57db1388c1320a73036051634d 100644 (file)
@@ -2,7 +2,7 @@ error[E0107]: this struct takes 0 lifetime arguments but 1 lifetime argument was
   --> $DIR/issue-18423.rs:4:8
    |
 LL |     x: Box<'a, isize>
-   |        ^^^ ---- help: remove this lifetime argument
+   |        ^^^ -- help: remove this lifetime argument
    |        |
    |        expected 0 lifetime arguments
    |
index b6ebfb35560f2b0a385f122dc6bbdc007ea9ae5c..4cef23ac42cb394c031dfedea09340b746ed30f7 100644 (file)
@@ -9,7 +9,7 @@ LL | struct Foo(Bar);
 LL |     fn hash<H: Hasher>(&self, state: &mut H);
    |             - required by this bound in `std::hash::Hash::hash`
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 1b876090ad6f6522e4d60584ba8ac59cc7c72de7..5d7ffeb0deb0ef5e968967fb83f6249f8b18f177 100644 (file)
@@ -11,17 +11,17 @@ error[E0107]: missing generics for trait `Fn`
   --> $DIR/issue-23024.rs:9:39
    |
 LL |     println!("{:?}",(vfnfer[0] as dyn Fn)(3));
-   |                                       ^^ expected 1 type argument
+   |                                       ^^ expected 1 generic argument
    |
-note: trait defined here, with 1 type parameter: `Args`
+note: trait defined here, with 1 generic parameter: `Args`
   --> $SRC_DIR/core/src/ops/function.rs:LL:COL
    |
 LL | pub trait Fn<Args>: FnMut<Args> {
    |           ^^ ----
-help: use angle brackets to add missing type argument
+help: add missing generic argument
    |
 LL |     println!("{:?}",(vfnfer[0] as dyn Fn<Args>)(3));
-   |                                         ^^^^^^
+   |                                       ^^^^^^^^
 
 error[E0191]: the value of the associated type `Output` (from trait `FnOnce`) must be specified
   --> $DIR/issue-23024.rs:9:39
index 2ed48356e9f56c6a9a3cc0409443aaee2df000dc..5b8bd9418629ad6f0743f33f22d5ad9012769e31 100644 (file)
@@ -7,7 +7,7 @@ LL |     ($e:expr) => { $e.foo() }
 LL |     foo!(a);
    |     -------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0599]: no method named `foo` found for type `i32` in the current scope
   --> $DIR/issue-25385.rs:10:15
index dcf2f5afa5caa8648c1f67b4b175737f661dd76d..bce269393eec4ba6ca6677d0e79140c1711e929d 100644 (file)
@@ -7,7 +7,7 @@ LL |         (*$var.c_object).$member.is_some()
 LL |     println!("{}", check_ptr_exist!(item, name));
    |                    ---------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `check_ptr_exist` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0616]: field `name` of struct `CObj` is private
   --> $DIR/issue-25386.rs:26:43
index 204786c65c1d9ba49df688b759c39e46f40feec3..33526721b1715e58aabd0f9ec2f9015c884e590f 100644 (file)
@@ -10,7 +10,7 @@ LL |     not_a_place!(99);
    |     |            cannot assign to this expression
    |     in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `not_a_place` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0067]: invalid left-hand side of assignment
   --> $DIR/issue-26093.rs:5:16
@@ -24,7 +24,7 @@ LL |     not_a_place!(99);
    |     |            cannot assign to this expression
    |     in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `not_a_place` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index f2c659083f63ca4e72ddecb65977c21c9cb730f1..40889b8666839c3b76f7536dca43181f4b08f4f5 100644 (file)
@@ -7,7 +7,7 @@ LL |
 LL | struct Bar(Foo);
    |            --- this field does not implement `Copy`
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index cf59016ded4cf02962132894199dadaa32c8e73a..1205a8b656b119a455ea5cc903d2033cdf540b90 100644 (file)
@@ -7,7 +7,7 @@ LL |     write(|| format_args!("{}", String::from("Hello world")));
    |              |                  temporary value created here
    |              returns a value referencing data owned by the current function
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `format_args` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0515]: cannot return reference to temporary value
   --> $DIR/issue-27592.rs:16:14
@@ -15,7 +15,7 @@ error[E0515]: cannot return reference to temporary value
 LL |     write(|| format_args!("{}", String::from("Hello world")));
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returns a reference to data owned by the current function
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `format_args` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/issues/issue-28776.mir.stderr b/src/test/ui/issues/issue-28776.mir.stderr
new file mode 100644 (file)
index 0000000..1d470fb
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/issue-28776.rs:7:5
+   |
+LL |     (&ptr::write)(1 as *mut _, 42);
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0133`.
index e564ebcd110cbabbe798847a571e9c1cf285fe3a..19df3c4a4252b1c51fc22dd6d52afb2c6e874971 100644 (file)
@@ -1,3 +1,6 @@
+// revisions: mir thir
+// [thir]compile-flags: -Z thir-unsafeck
+
 use std::ptr;
 
 fn main() {
diff --git a/src/test/ui/issues/issue-28776.stderr b/src/test/ui/issues/issue-28776.stderr
deleted file mode 100644 (file)
index 7faac88..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/issue-28776.rs:4:5
-   |
-LL |     (&ptr::write)(1 as *mut _, 42);
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
-   |
-   = note: consult the function's documentation for information on how to avoid undefined behavior
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0133`.
diff --git a/src/test/ui/issues/issue-28776.thir.stderr b/src/test/ui/issues/issue-28776.thir.stderr
new file mode 100644 (file)
index 0000000..1d470fb
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/issue-28776.rs:7:5
+   |
+LL |     (&ptr::write)(1 as *mut _, 42);
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0133`.
index bc22e9371395f107be3e27a8ec01b21514450c83..fec1c55f89eb0fbb76d7e9e5cbd61dce0b57a222 100644 (file)
@@ -7,7 +7,7 @@ LL |         bar(&mut $d);
 LL |     foo!(0u8);
    |     ---------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-3080.mir.stderr b/src/test/ui/issues/issue-3080.mir.stderr
new file mode 100644 (file)
index 0000000..f395c30
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/issue-3080.rs:10:5
+   |
+LL |     X(()).with();
+   |     ^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0133`.
index 883f3bfd24e8345c1b7ca92987080a847f262ae0..2b5269dda8fa6b05ef0b156e46f41bf993f056c7 100644 (file)
@@ -1,3 +1,6 @@
+// revisions: mir thir
+// [thir]compile-flags: -Z thir-unsafeck
+
 struct X(());
 impl X {
     pub unsafe fn with(&self) { }
diff --git a/src/test/ui/issues/issue-3080.stderr b/src/test/ui/issues/issue-3080.stderr
deleted file mode 100644 (file)
index 138d6df..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/issue-3080.rs:7:5
-   |
-LL |     X(()).with();
-   |     ^^^^^^^^^^^^ call to unsafe function
-   |
-   = note: consult the function's documentation for information on how to avoid undefined behavior
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0133`.
diff --git a/src/test/ui/issues/issue-3080.thir.stderr b/src/test/ui/issues/issue-3080.thir.stderr
new file mode 100644 (file)
index 0000000..f395c30
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/issue-3080.rs:10:5
+   |
+LL |     X(()).with();
+   |     ^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0133`.
index deaf490466cec7dfab061088c354d0475b274cbf..ab041594863ce051f9a43692bb5d67727bf3f405 100644 (file)
@@ -10,7 +10,7 @@ LL | {
 LL |     log!(context, "entered wrapper");
    |     --------------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `log` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index ccfaf23b4b9ff3948009b6a28b4a64123c3af49c..aa43d06c99b0101d8387d74209455aa89a5e7742 100644 (file)
@@ -4,7 +4,7 @@ struct Foo {
     }
 
     impl<T> Drop for Foo<T> {
-        //~^ ERROR this struct takes 0 type arguments but 1 type argument was supplied
+        //~^ ERROR this struct takes 0 generic arguments but 1 generic argument
         //~| ERROR the type parameter `T` is not constrained by the impl trait, self type, or predicates
         fn drop(&mut self) {}
     }
index 0da095b7fdab8b84da8bcad382a1b5a8463364ed..094da64d76d4d252df3da36b9555b843c275012e 100644 (file)
@@ -9,15 +9,15 @@ LL |     struct Foo {
 LL |         x: T,
    |            ^ use of generic parameter from outer function
 
-error[E0107]: this struct takes 0 type arguments but 1 type argument was supplied
+error[E0107]: this struct takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/issue-3214.rs:6:22
    |
 LL |     impl<T> Drop for Foo<T> {
    |                      ^^^--- help: remove these generics
    |                      |
-   |                      expected 0 type arguments
+   |                      expected 0 generic arguments
    |
-note: struct defined here, with 0 type parameters
+note: struct defined here, with 0 generic parameters
   --> $DIR/issue-3214.rs:2:12
    |
 LL |     struct Foo {
index 5d5ad8aed985500a7eb5b713eb623ffadd14f9bf..c0d9899eb841c61cb84be7218638542160e68b58 100644 (file)
@@ -7,7 +7,7 @@ LL |         #[derive_Clone]
 LL | foo!();
    | ------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: cannot find attribute `derive_Clone` in this scope
   --> $DIR/issue-32655.rs:15:7
index 3d74897aab28da6e49c68766042cc29315d8b8d6..ed43fa73a09e30cc399c4cf06016e4f624e76f0b 100644 (file)
@@ -8,7 +8,7 @@ LL | foo!();
    | ------- in this macro invocation
    |
    = help: add `#![feature(allow_internal_unstable)]` to the crate attributes to enable
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 06a6ebd9704f1c27c95bbade0a61d004919cc3a7..f6635d982e4ec7e6966e574e80fe9007e93d1bd2 100644 (file)
@@ -10,7 +10,7 @@ error[E0412]: cannot find type `FooBar` in this scope
 LL |     concat_idents!(Foo, Bar)
    |     ^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `concat_idents` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index 7268e94c8d167e2c69e7fc5419830434524e0c74..c32fe7e0ec6238c910ac515007427f61ccccbf08 100644 (file)
@@ -6,7 +6,7 @@ LL | #[derive(PartialEq, PartialOrd)] struct Nope(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)
+   = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-38074.rs b/src/test/ui/issues/issue-38074.rs
deleted file mode 100644 (file)
index 214d675..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// run-pass
-// ignore-emscripten FIXME(#45351)
-
-#![feature(platform_intrinsics, repr_simd)]
-
-extern "platform-intrinsic" {
-    fn simd_shuffle2<T, U>(x: T, y: T, idx: [u32; 2]) -> U;
-}
-
-#[repr(simd)]
-#[derive(Clone, Copy)]
-#[allow(non_camel_case_types)]
-struct u64x2(u64, u64);
-
-fn main() {
-    let a = u64x2(1, 2);
-    let r: u64x2 = unsafe { simd_shuffle2(a, a, [0-0, 0-0]) };
-    assert_eq!(r.0, 1);
-    assert_eq!(r.1, 1);
-}
index 296efab7512f16709f9f2c3b01e855e5e2dd33e4..e53a543f3a0bab6185fccc25417b7ebfa5c26e76 100644 (file)
@@ -9,7 +9,7 @@ note: required because of the requirements on the impl of `IntoNullable` for `<C
    |
 LL | impl<T: NotNull> IntoNullable for T {
    |                  ^^^^^^^^^^^^     ^
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 0250c6b1fdd0f16aa040e8b6972c5a752d46c03f..02c6cd0ca44a904dcd5c159823ebab0ad4906c5a 100644 (file)
@@ -11,7 +11,7 @@ LL |         if $tgt.has_$field() {}
 LL |     get_opt!(bar, foo);
    |     ------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `get_opt` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 840cceea7b0fd1608ddd8f413b87010a2944956f..8227f8df1e09f600e72966c3fc07915743e6d0c8 100644 (file)
@@ -10,7 +10,7 @@ LL |         $i as u32 < 0
 LL |     is_plainly_printable!(c);
    |     ------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `is_plainly_printable` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 8a4a6bdb39fa4202a72193a357f84533dd88ac04..d328329edad22209166ef61166d347bf00c959f1 100644 (file)
@@ -1,8 +1,6 @@
 error[E0621]: explicit lifetime required in the type of `x`
   --> $DIR/issue-46983.rs:2:5
    |
-LL | fn foo(x: &u32) -> &'static u32 {
-   |           ---- help: add explicit lifetime `'static` to the type of `x`: `&'static u32`
 LL |     &*x
    |     ^^^ lifetime `'static` required
 
diff --git a/src/test/ui/issues/issue-48131.mir.stderr b/src/test/ui/issues/issue-48131.mir.stderr
new file mode 100644 (file)
index 0000000..6817e88
--- /dev/null
@@ -0,0 +1,20 @@
+error: unnecessary `unsafe` block
+  --> $DIR/issue-48131.rs:12:9
+   |
+LL |         unsafe { /* unnecessary */ }
+   |         ^^^^^^ unnecessary `unsafe` block
+   |
+note: the lint level is defined here
+  --> $DIR/issue-48131.rs:6:9
+   |
+LL | #![deny(unused_unsafe)]
+   |         ^^^^^^^^^^^^^
+
+error: unnecessary `unsafe` block
+  --> $DIR/issue-48131.rs:23:13
+   |
+LL |             unsafe { /* unnecessary */ }
+   |             ^^^^^^ unnecessary `unsafe` block
+
+error: aborting due to 2 previous errors
+
index 85664e62eaded5ee6c62ce5f4b37b20a134e28fe..df98547084d696bcf01e949c0fd470fbfd1bf44f 100644 (file)
@@ -1,3 +1,6 @@
+// revisions: mir thir
+// [thir]compile-flags: -Z thir-unsafeck
+
 // This note is annotated because the purpose of the test
 // is to ensure that certain other notes are not generated.
 #![deny(unused_unsafe)] //~ NOTE
diff --git a/src/test/ui/issues/issue-48131.stderr b/src/test/ui/issues/issue-48131.stderr
deleted file mode 100644 (file)
index 5acc4f1..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-error: unnecessary `unsafe` block
-  --> $DIR/issue-48131.rs:9:9
-   |
-LL |         unsafe { /* unnecessary */ }
-   |         ^^^^^^ unnecessary `unsafe` block
-   |
-note: the lint level is defined here
-  --> $DIR/issue-48131.rs:3:9
-   |
-LL | #![deny(unused_unsafe)]
-   |         ^^^^^^^^^^^^^
-
-error: unnecessary `unsafe` block
-  --> $DIR/issue-48131.rs:20:13
-   |
-LL |             unsafe { /* unnecessary */ }
-   |             ^^^^^^ unnecessary `unsafe` block
-
-error: aborting due to 2 previous errors
-
diff --git a/src/test/ui/issues/issue-48131.thir.stderr b/src/test/ui/issues/issue-48131.thir.stderr
new file mode 100644 (file)
index 0000000..6817e88
--- /dev/null
@@ -0,0 +1,20 @@
+error: unnecessary `unsafe` block
+  --> $DIR/issue-48131.rs:12:9
+   |
+LL |         unsafe { /* unnecessary */ }
+   |         ^^^^^^ unnecessary `unsafe` block
+   |
+note: the lint level is defined here
+  --> $DIR/issue-48131.rs:6:9
+   |
+LL | #![deny(unused_unsafe)]
+   |         ^^^^^^^^^^^^^
+
+error: unnecessary `unsafe` block
+  --> $DIR/issue-48131.rs:23:13
+   |
+LL |             unsafe { /* unnecessary */ }
+   |             ^^^^^^ unnecessary `unsafe` block
+
+error: aborting due to 2 previous errors
+
index 5ccede308a1c1d7d9d3223526b6cb7fca4b27c1b..37a42d2382d6be7b5bbd02c22a03fe01c9cf0fb7 100644 (file)
@@ -6,7 +6,7 @@ LL |     b"".starts_with(stringify!(foo))
    |
    = note: expected reference `&[u8]`
               found reference `&'static str`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `stringify` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index ca2e234cee668d1623bf0800deb391609a66d787..628f026b680469ccbe91863140271a5b094f670f 100644 (file)
@@ -8,7 +8,7 @@ LL | impl<T: Clone + ?Sized> Clone for Node<[T]> {
    | ------------------------------------------- first implementation here
    |
    = note: upstream crates may add a new impl of trait `std::clone::Clone` for type `[_]` in future versions
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 50691f1f57fa524ad2b61863c3e06b18038f43ab..15f38c892679bcd75a87805b461c63a42b9cc576 100644 (file)
@@ -30,7 +30,7 @@ LL | struct Foo(NotDefined, <i32 as Iterator>::Item, Vec<i32>, String);
    |                                                 |
    |                                                 this field does not implement `Copy`
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 4 previous errors
 
index 051c4d7f427937e3ffa8eb49e34587f16db48ccb..bb32b7f9a13131e87a05b062a1ea430c9899896f 100644 (file)
@@ -10,7 +10,7 @@ LL |     macro_with_error!();
    |     -------------------- in this macro invocation
    |
    = note: if you intended to print `{`, you can escape it using `{{`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `macro_with_error` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: invalid format string: unmatched `}` found
   --> $DIR/issue-51848.rs:18:15
index 937271d42f4bd1f906a7aae63b7345cae1302374..240826a161d976b93e636b80f9277dadb7018694 100644 (file)
@@ -9,8 +9,8 @@ macro_rules! impl_add {
         $(
             fn $n() {
                 S::f::<i64>();
-                //~^ ERROR this associated function takes 0 type arguments but 1 type argument was supplied
-                //~| ERROR this associated function takes 0 type arguments but 1 type argument was supplied
+                //~^ ERROR this associated function takes 0 generic
+                //~| ERROR this associated function takes 0 generic
             }
         )*
     }
index 1676c508a4dccfe304739c11447b918c7e637e89..fd2522dfbeee4d5cf10131913f5894acb6de0a56 100644 (file)
@@ -1,38 +1,38 @@
-error[E0107]: this associated function takes 0 type arguments but 1 type argument was supplied
+error[E0107]: this associated function takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/issue-53251.rs:11:20
    |
 LL |                 S::f::<i64>();
    |                    ^------- help: remove these generics
    |                    |
-   |                    expected 0 type arguments
+   |                    expected 0 generic arguments
 ...
 LL | impl_add!(a b);
    | --------------- in this macro invocation
    |
-note: associated function defined here, with 0 type parameters
+note: associated function defined here, with 0 generic parameters
   --> $DIR/issue-53251.rs:4:8
    |
 LL |     fn f() {}
    |        ^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `impl_add` (in Nightly builds, run with -Z macro-backtrace for more info)
 
-error[E0107]: this associated function takes 0 type arguments but 1 type argument was supplied
+error[E0107]: this associated function takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/issue-53251.rs:11:20
    |
 LL |                 S::f::<i64>();
    |                    ^------- help: remove these generics
    |                    |
-   |                    expected 0 type arguments
+   |                    expected 0 generic arguments
 ...
 LL | impl_add!(a b);
    | --------------- in this macro invocation
    |
-note: associated function defined here, with 0 type parameters
+note: associated function defined here, with 0 generic parameters
   --> $DIR/issue-53251.rs:4:8
    |
 LL |     fn f() {}
    |        ^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `impl_add` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index 00805eb5dc90d041c1d5aae815b9034e03ee56cf..42a4d5b674b229c239149037f9398ce90f86565c 100644 (file)
@@ -1,5 +1,3 @@
-#![feature(const_fn)]
-
 const ARR_LEN: usize = Tt::const_val::<[i8; 123]>();
 //~^ ERROR type annotations needed
 
index 29d439b457ff64ecc2d3e5891911317c8da1c581..9de58d83c8b074340f6cdb2749baf202b7b94a66 100644 (file)
@@ -1,11 +1,11 @@
 error[E0379]: functions in traits cannot be declared const
-  --> $DIR/issue-54954.rs:7:5
+  --> $DIR/issue-54954.rs:5:5
    |
 LL |     const fn const_val<T: Sized>() -> usize {
    |     ^^^^^ functions in traits cannot be const
 
 error[E0283]: type annotations needed
-  --> $DIR/issue-54954.rs:3:24
+  --> $DIR/issue-54954.rs:1:24
    |
 LL | const ARR_LEN: usize = Tt::const_val::<[i8; 123]>();
    |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
diff --git a/src/test/ui/issues/issue-5844.mir.stderr b/src/test/ui/issues/issue-5844.mir.stderr
new file mode 100644 (file)
index 0000000..6134d68
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/issue-5844.rs:8:5
+   |
+LL |     issue_5844_aux::rand();
+   |     ^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0133`.
index b855e87e3f5599430913ff3cc228e1d44be47062..4f90a9c66451f1825be4cc510a8f61a93e8aaad9 100644 (file)
@@ -1,4 +1,6 @@
 //aux-build:issue-5844-aux.rs
+// revisions: mir thir
+// [thir]compile-flags: -Z thir-unsafeck
 
 extern crate issue_5844_aux;
 
diff --git a/src/test/ui/issues/issue-5844.stderr b/src/test/ui/issues/issue-5844.stderr
deleted file mode 100644 (file)
index ed5a3dc..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/issue-5844.rs:6:5
-   |
-LL |     issue_5844_aux::rand();
-   |     ^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
-   |
-   = note: consult the function's documentation for information on how to avoid undefined behavior
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0133`.
diff --git a/src/test/ui/issues/issue-5844.thir.stderr b/src/test/ui/issues/issue-5844.thir.stderr
new file mode 100644 (file)
index 0000000..6134d68
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/issue-5844.rs:8:5
+   |
+LL |     issue_5844_aux::rand();
+   |     ^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0133`.
index 2627724f877fabf0bfaee7e0a8559dda75a1d576..93d2f3001f8991ecc38cbd1bef301c91f9b88224 100644 (file)
@@ -77,7 +77,7 @@ LL |     assert_eq!(Foo::Bar, i);
    |     fn(usize) -> Foo {Foo::Bar}
    |     fn(usize) -> Foo {Foo::Bar}
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0277]: `fn(usize) -> Foo {Foo::Bar}` doesn't implement `Debug`
   --> $DIR/issue-59488.rs:30:5
@@ -91,7 +91,7 @@ LL |     T: fmt::Debug + ?Sized,
    |        ---------- required by this bound in `core::panicking::assert_failed`
    |
    = help: the trait `Debug` is not implemented for `fn(usize) -> Foo {Foo::Bar}`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 9 previous errors
 
index 1018c88ae55e36e060d3566eea94cd1fc35c608b..8e230c615bc93837ccf9fe94e95b79ebc9ef1fc4 100644 (file)
@@ -9,7 +9,7 @@ fn a(&self) {}
 fn run_wild<T>(b: &Borked) {
     b.a::<'_, T>();
     //~^ ERROR cannot specify lifetime arguments explicitly if late bound lifetime parameters are present
-    //~| ERROR this associated function takes 0 type arguments but 1 type argument was supplied
+    //~| ERROR this associated function takes 0 generic arguments but 1 generic argument
     //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
 }
 
index f970a63e4b2fe49e470f248040571c34f42b1f9d..b305cc78535372e5fd5298807b43f8098dbf0125 100644 (file)
@@ -16,15 +16,15 @@ LL | #![deny(warnings)]
    = 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 #42868 <https://github.com/rust-lang/rust/issues/42868>
 
-error[E0107]: this associated function takes 0 type arguments but 1 type argument was supplied
+error[E0107]: this associated function takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/issue-60622.rs:10:7
    |
 LL |     b.a::<'_, T>();
-   |       ^     --- help: remove this type argument
+   |       ^       - help: remove this generic argument
    |       |
-   |       expected 0 type arguments
+   |       expected 0 generic arguments
    |
-note: associated function defined here, with 0 type parameters
+note: associated function defined here, with 0 generic parameters
   --> $DIR/issue-60622.rs:6:8
    |
 LL |     fn a(&self) {}
index 216fe6472a5033187e793bb4f92067544ed6475c..c01205223d661429ae1560dc94dda9850e6f83aa 100644 (file)
@@ -7,7 +7,7 @@ LL |         $nonexistent
 LL |     e!(foo);
    |     -------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `e` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 3d13c64f762ea5e6885fd16ffb52d0a2d08d8e27..90627d3bbd55efaea7c3b98c27f4aea801ad15e5 100644 (file)
@@ -7,7 +7,7 @@ LL |         { $inp $nonexistent }
 LL |     g!(foo);
    |     -------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `g` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 78760efd8d12330b0af7662d91506c8a15cc96b6..43fda800cfa1cefa62c50c15de166656210351fa 100644 (file)
@@ -13,7 +13,7 @@ LL |         $($c)ö* {}
 LL |     x!(if);
    |     ------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `x` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index 1af5368d2b6d934b909827f73e5e839d81527293..6a744812e41d15929ae4f84da3978997d308b9c7 100644 (file)
@@ -14,7 +14,7 @@ LL | | }
    | |_- in this macro invocation
    |
    = note: `A` must be defined only once in the value namespace of this module
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `suite` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: missing type for `const` item
   --> $DIR/issue-69396-const-no-type-in-macro.rs:4:19
@@ -28,7 +28,7 @@ LL | |     is_empty;
 LL | | }
    | |_- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `suite` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0121]: the type placeholder `_` is not allowed within types on item signatures
   --> $DIR/issue-69396-const-no-type-in-macro.rs:4:19
@@ -45,7 +45,7 @@ LL | |     is_empty;
 LL | | }
    | |_- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `suite` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 3 previous errors
 
index 20e4b1076812712611fb6e45b7edc70fb6ebbe55..0f095f5a77b231b7e69ad797986dbad7269862d8 100644 (file)
@@ -8,7 +8,7 @@ LL |     assert_eq!(a, 0);
    |     {integer}
    |     help: you might have forgotten to call this function: `*left_val()`
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0308]: mismatched types
   --> $DIR/issue-70724-add_type_neq_err_label-unwrap.rs:6:5
@@ -18,7 +18,7 @@ LL |     assert_eq!(a, 0);
    |
    = note: expected fn item `fn() -> i32 {a}`
                  found type `i32`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0277]: `fn() -> i32 {a}` doesn't implement `Debug`
   --> $DIR/issue-70724-add_type_neq_err_label-unwrap.rs:6:5
@@ -36,7 +36,7 @@ LL |     T: fmt::Debug + ?Sized,
    |
    = help: the trait `Debug` is not implemented for `fn() -> i32 {a}`
    = help: use parentheses to call the function: `a()`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 3 previous errors
 
index a775845279eb8c5d90ed89d661d398b0b099c561..e30747782339cb4c675e783ba043beeb3f6a78cb 100644 (file)
@@ -3,9 +3,12 @@
 
 extern crate issue_75907 as a;
 
-use a::{make_bar, Bar};
+use a::{make_bar, Bar, Foo};
 
 fn main() {
     let Bar(x, y, z) = make_bar();
     //~^ ERROR cannot match against a tuple struct which contains private fields
+
+    let Foo(x, y, z) = Foo::new();
+    //~^ ERROR cannot match against a tuple struct which contains private fields
 }
index 8884484e18d8152c937004677e64d5f4c39bee56..b82d08473c8c9962a6298c577adf58a916286085 100644 (file)
@@ -2,8 +2,30 @@ error[E0532]: cannot match against a tuple struct which contains private fields
   --> $DIR/issue-75907_b.rs:9:9
    |
 LL |     let Bar(x, y, z) = make_bar();
-   |         ^^^ constructor is not visible here due to private fields
+   |         ^^^
+   |
+note: constructor is not visible here due to private fields
+  --> $DIR/issue-75907_b.rs:9:16
+   |
+LL |     let Bar(x, y, z) = make_bar();
+   |                ^  ^ private field
+   |                |
+   |                private field
+
+error[E0532]: cannot match against a tuple struct which contains private fields
+  --> $DIR/issue-75907_b.rs:12:9
+   |
+LL |     let Foo(x, y, z) = Foo::new();
+   |         ^^^
+   |
+note: constructor is not visible here due to private fields
+  --> $DIR/issue-75907_b.rs:12:13
+   |
+LL |     let Foo(x, y, z) = Foo::new();
+   |             ^     ^ private field
+   |             |
+   |             private field
 
-error: aborting due to previous error
+error: aborting due to 2 previous errors
 
 For more information about this error, try `rustc --explain E0532`.
index 2cb6e62e4129416f514c1a7788253c92aa9088b5..4a605cfb8621b0bb5a410f902572c0c82e888dce 100644 (file)
@@ -10,7 +10,7 @@ LL |     x.use_mut();
    |     - borrow later used here
    |
    = note: consider using a `let` binding to create a longer lived value
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 47dc8e4a63c07dfeb3151e5722ea37b3be97bbba..94fc1a7b46dbaf85e1234f8e109091572ad66541 100644 (file)
@@ -335,16 +335,16 @@ LL |         foo.method_deprecated();
    |             ^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `lint_stability::MethodTester::method_deprecated`: text
-  --> $DIR/lint-stability-deprecated.rs:26:9
+  --> $DIR/lint-stability-deprecated.rs:26:14
    |
 LL |         Foo::method_deprecated(&foo);
-   |         ^^^^^^^^^^^^^^^^^^^^^^
+   |              ^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `lint_stability::MethodTester::method_deprecated`: text
-  --> $DIR/lint-stability-deprecated.rs:27:9
+  --> $DIR/lint-stability-deprecated.rs:27:16
    |
 LL |         <Foo>::method_deprecated(&foo);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^
+   |                ^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `lint_stability::Trait::trait_deprecated`: text
   --> $DIR/lint-stability-deprecated.rs:28:13
@@ -353,10 +353,10 @@ LL |         foo.trait_deprecated();
    |             ^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `lint_stability::Trait::trait_deprecated`: text
-  --> $DIR/lint-stability-deprecated.rs:30:9
+  --> $DIR/lint-stability-deprecated.rs:30:16
    |
 LL |         <Foo>::trait_deprecated(&foo);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^
+   |                ^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `lint_stability::MethodTester::method_deprecated_text`: text
   --> $DIR/lint-stability-deprecated.rs:34:13
@@ -365,16 +365,16 @@ LL | ...   foo.method_deprecated_text();
    |           ^^^^^^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `lint_stability::MethodTester::method_deprecated_text`: text
-  --> $DIR/lint-stability-deprecated.rs:35:9
+  --> $DIR/lint-stability-deprecated.rs:35:14
    |
 LL | ...   Foo::method_deprecated_text(&foo);
-   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |            ^^^^^^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `lint_stability::MethodTester::method_deprecated_text`: text
-  --> $DIR/lint-stability-deprecated.rs:36:9
+  --> $DIR/lint-stability-deprecated.rs:36:16
    |
 LL | ...   <Foo>::method_deprecated_text(&foo);
-   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |              ^^^^^^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `lint_stability::Trait::trait_deprecated_text`: text
   --> $DIR/lint-stability-deprecated.rs:37:13
@@ -383,10 +383,10 @@ LL |         foo.trait_deprecated_text();
    |             ^^^^^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `lint_stability::Trait::trait_deprecated_text`: text
-  --> $DIR/lint-stability-deprecated.rs:39:9
+  --> $DIR/lint-stability-deprecated.rs:39:16
    |
 LL | ...   <Foo>::trait_deprecated_text(&foo);
-   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |              ^^^^^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `lint_stability::MethodTester::method_deprecated_unstable`: text
   --> $DIR/lint-stability-deprecated.rs:43:13
@@ -395,16 +395,16 @@ LL | ...   foo.method_deprecated_unstable();
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `lint_stability::MethodTester::method_deprecated_unstable`: text
-  --> $DIR/lint-stability-deprecated.rs:44:9
+  --> $DIR/lint-stability-deprecated.rs:44:14
    |
 LL | ...   Foo::method_deprecated_unstable(&foo);
-   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `lint_stability::MethodTester::method_deprecated_unstable`: text
-  --> $DIR/lint-stability-deprecated.rs:45:9
+  --> $DIR/lint-stability-deprecated.rs:45:16
    |
 LL | ...   <Foo>::method_deprecated_unstable(&foo);
-   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `lint_stability::Trait::trait_deprecated_unstable`: text
   --> $DIR/lint-stability-deprecated.rs:46:13
@@ -413,10 +413,10 @@ LL |         foo.trait_deprecated_unstable();
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `lint_stability::Trait::trait_deprecated_unstable`: text
-  --> $DIR/lint-stability-deprecated.rs:48:9
+  --> $DIR/lint-stability-deprecated.rs:48:16
    |
 LL | ...   <Foo>::trait_deprecated_unstable(&foo);
-   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |              ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `lint_stability::MethodTester::method_deprecated_unstable_text`: text
   --> $DIR/lint-stability-deprecated.rs:52:13
@@ -425,16 +425,16 @@ LL | ...   foo.method_deprecated_unstable_text();
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `lint_stability::MethodTester::method_deprecated_unstable_text`: text
-  --> $DIR/lint-stability-deprecated.rs:53:9
+  --> $DIR/lint-stability-deprecated.rs:53:14
    |
 LL | ...   Foo::method_deprecated_unstable_text(&foo);
-   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `lint_stability::MethodTester::method_deprecated_unstable_text`: text
-  --> $DIR/lint-stability-deprecated.rs:54:9
+  --> $DIR/lint-stability-deprecated.rs:54:16
    |
 LL | ...   <Foo>::method_deprecated_unstable_text(&foo);
-   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `lint_stability::Trait::trait_deprecated_unstable_text`: text
   --> $DIR/lint-stability-deprecated.rs:55:13
@@ -443,10 +443,10 @@ LL | ...   foo.trait_deprecated_unstable_text();
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `lint_stability::Trait::trait_deprecated_unstable_text`: text
-  --> $DIR/lint-stability-deprecated.rs:57:9
+  --> $DIR/lint-stability-deprecated.rs:57:16
    |
 LL | ...   <Foo>::trait_deprecated_unstable_text(&foo);
-   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated field `lint_stability::DeprecatedStruct::i`: text
   --> $DIR/lint-stability-deprecated.rs:109:13
@@ -467,10 +467,10 @@ LL |         foo.trait_deprecated();
    |             ^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `lint_stability::Trait::trait_deprecated`: text
-  --> $DIR/lint-stability-deprecated.rs:146:9
+  --> $DIR/lint-stability-deprecated.rs:146:16
    |
 LL |         <Foo>::trait_deprecated(&foo);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^
+   |                ^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `lint_stability::Trait::trait_deprecated_text`: text
   --> $DIR/lint-stability-deprecated.rs:148:13
@@ -479,10 +479,10 @@ LL |         foo.trait_deprecated_text();
    |             ^^^^^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `lint_stability::Trait::trait_deprecated_text`: text
-  --> $DIR/lint-stability-deprecated.rs:150:9
+  --> $DIR/lint-stability-deprecated.rs:150:16
    |
 LL | ...   <Foo>::trait_deprecated_text(&foo);
-   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |              ^^^^^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `lint_stability::Trait::trait_deprecated_unstable`: text
   --> $DIR/lint-stability-deprecated.rs:152:13
@@ -491,10 +491,10 @@ LL |         foo.trait_deprecated_unstable();
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `lint_stability::Trait::trait_deprecated_unstable`: text
-  --> $DIR/lint-stability-deprecated.rs:154:9
+  --> $DIR/lint-stability-deprecated.rs:154:16
    |
 LL | ...   <Foo>::trait_deprecated_unstable(&foo);
-   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |              ^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `lint_stability::Trait::trait_deprecated_unstable_text`: text
   --> $DIR/lint-stability-deprecated.rs:156:13
@@ -503,10 +503,10 @@ LL | ...   foo.trait_deprecated_unstable_text();
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `lint_stability::Trait::trait_deprecated_unstable_text`: text
-  --> $DIR/lint-stability-deprecated.rs:158:9
+  --> $DIR/lint-stability-deprecated.rs:158:16
    |
 LL | ...   <Foo>::trait_deprecated_unstable_text(&foo);
-   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `lint_stability::Trait::trait_deprecated`: text
   --> $DIR/lint-stability-deprecated.rs:175:13
@@ -539,16 +539,16 @@ LL |         foo.method_deprecated();
    |             ^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `this_crate::MethodTester::method_deprecated`: text
-  --> $DIR/lint-stability-deprecated.rs:332:9
+  --> $DIR/lint-stability-deprecated.rs:332:14
    |
 LL |         Foo::method_deprecated(&foo);
-   |         ^^^^^^^^^^^^^^^^^^^^^^
+   |              ^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `this_crate::MethodTester::method_deprecated`: text
-  --> $DIR/lint-stability-deprecated.rs:333:9
+  --> $DIR/lint-stability-deprecated.rs:333:16
    |
 LL |         <Foo>::method_deprecated(&foo);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^
+   |                ^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `this_crate::Trait::trait_deprecated`: text
   --> $DIR/lint-stability-deprecated.rs:334:13
@@ -557,10 +557,10 @@ LL |         foo.trait_deprecated();
    |             ^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `this_crate::Trait::trait_deprecated`: text
-  --> $DIR/lint-stability-deprecated.rs:336:9
+  --> $DIR/lint-stability-deprecated.rs:336:16
    |
 LL |         <Foo>::trait_deprecated(&foo);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^
+   |                ^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `this_crate::MethodTester::method_deprecated_text`: text
   --> $DIR/lint-stability-deprecated.rs:340:13
@@ -569,16 +569,16 @@ LL | ...   foo.method_deprecated_text();
    |           ^^^^^^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `this_crate::MethodTester::method_deprecated_text`: text
-  --> $DIR/lint-stability-deprecated.rs:341:9
+  --> $DIR/lint-stability-deprecated.rs:341:14
    |
 LL | ...   Foo::method_deprecated_text(&foo);
-   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |            ^^^^^^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `this_crate::MethodTester::method_deprecated_text`: text
-  --> $DIR/lint-stability-deprecated.rs:342:9
+  --> $DIR/lint-stability-deprecated.rs:342:16
    |
 LL | ...   <Foo>::method_deprecated_text(&foo);
-   |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |              ^^^^^^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text
   --> $DIR/lint-stability-deprecated.rs:343:13
@@ -587,10 +587,10 @@ LL |         foo.trait_deprecated_text();
    |             ^^^^^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text
-  --> $DIR/lint-stability-deprecated.rs:345:9
+  --> $DIR/lint-stability-deprecated.rs:345:16
    |
 LL |         <Foo>::trait_deprecated_text(&foo);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                ^^^^^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated field `this_crate::DeprecatedStruct::i`: text
   --> $DIR/lint-stability-deprecated.rs:386:13
@@ -605,10 +605,10 @@ LL |         foo.trait_deprecated();
    |             ^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `this_crate::Trait::trait_deprecated`: text
-  --> $DIR/lint-stability-deprecated.rs:407:9
+  --> $DIR/lint-stability-deprecated.rs:407:16
    |
 LL |         <Foo>::trait_deprecated(&foo);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^
+   |                ^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text
   --> $DIR/lint-stability-deprecated.rs:409:13
@@ -617,10 +617,10 @@ LL |         foo.trait_deprecated_text();
    |             ^^^^^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `this_crate::Trait::trait_deprecated_text`: text
-  --> $DIR/lint-stability-deprecated.rs:411:9
+  --> $DIR/lint-stability-deprecated.rs:411:16
    |
 LL |         <Foo>::trait_deprecated_text(&foo);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                ^^^^^^^^^^^^^^^^^^^^^
 
 warning: use of deprecated associated function `this_crate::Trait::trait_deprecated`: text
   --> $DIR/lint-stability-deprecated.rs:428:13
index 036304d25f9bf9adf71a5ea821429ed3ecd5d51a..52f6c69cfc90cd719b249dc68ea0f1f71af76ded 100644 (file)
@@ -9,7 +9,7 @@ note: the lint level is defined here
    |
 LL | #![deny(deprecated)]
    |         ^^^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `macro_test` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index b89a7df493877640a190577ce8d5df500540d785..56d4ffc4727b2e2e627f76e5d9b4bdaf4d633bea 100644 (file)
@@ -9,7 +9,7 @@ note: the lint level is defined here
    |
 LL | #![deny(deprecated)]
    |         ^^^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `macro_test_arg_nested` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index a8ef047e517b49569e315cf85ad71023ad179dcd..fc6e6c29db11ca22a17c84a0adfe4f5fe381e0cb 100644 (file)
@@ -123,7 +123,7 @@ 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)
+   = note: this error originates in the macro `unsafe_in_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
@@ -135,7 +135,7 @@ 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)
+   = note: this error originates in the macro `unsafe_in_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
@@ -147,7 +147,7 @@ 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)
+   = note: this error originates in the macro `unsafe_in_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
@@ -159,7 +159,7 @@ 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)
+   = note: this error originates in the macro `unsafe_in_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
@@ -170,7 +170,7 @@ LL |         unsafe {}
 LL |     unsafe_in_macro!()
    |     ------------------ in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `unsafe_in_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 22 previous errors
 
index ea8d4bf96411558c280998ecc35ecc8b593c5b80..55fea4e3636f4081a8acab87abbc93762b41b758 100644 (file)
@@ -12,7 +12,7 @@ note: the lint level is defined here
    |
 LL | #![warn(unused_imports)]
    |         ^^^^^^^^^^^^^^
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: unused import: `std::string::ToString`
   --> $DIR/lints-in-foreign-macros.rs:16:18
index bfdce732e029d102ad1f8fa8c1da777f1233b0a0..111ebea61dd12c94499ab583a31d7165214cc9a3 100644 (file)
@@ -14,7 +14,7 @@ LL | #![warn(semicolon_in_expressions_from_macros)]
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = 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 #79813 <https://github.com/rust-lang/rust/issues/79813>
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `foo` (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
@@ -27,7 +27,7 @@ LL |     let _ = foo!(second);
    |
    = 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 #79813 <https://github.com/rust-lang/rust/issues/79813>
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: 2 warnings emitted
 
index a8974e1cf96b7b2e75c1e6ef368d3366bc3dbfd1..7a32bc86bf706e8508c9ba84ad6b2b4a9365c77a 100644 (file)
@@ -5,7 +5,7 @@ LL |     #[test]
    |     ^^^^^^^
    |
    = note: requested on the command line with `-D unnameable-test-items`
-   = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: cannot test inner items
   --> $DIR/test-inner-fn.rs:13:9
@@ -13,7 +13,7 @@ error: cannot test inner items
 LL |         #[test]
    |         ^^^^^^^
    |
-   = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index 4e7c6bfc98d9d2c68fcfc7bcf8e45aabe50d5865..5e84fdca1d3ce2ff0e06b738bcd8ae8d77ce2609 100644 (file)
@@ -24,7 +24,7 @@ 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 #82523 <https://github.com/rust-lang/rust/issues/82523>
    = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced)
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `unaligned_references_external_crate::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index ef38a516e149ae790656c5583a4663c773c09b81..27444e05532eb7317b2d9115bb8fc6ca8dc2c664 100644 (file)
@@ -132,7 +132,7 @@ LL |     define_empty_struct_with_visibility!(pub, Fluorine);
    |     in this macro invocation
    |
    = help: or consider exporting it for use by other crates
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `define_empty_struct_with_visibility` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: unreachable `pub` item
   --> $DIR/unreachable_pub-pub_crate.rs:45:9
index 1e554612fa865c6670aa1b433402fd5049927791..5d79292e3e382beb52e1c261714d395e6e55c714 100644 (file)
@@ -132,7 +132,7 @@ LL |     define_empty_struct_with_visibility!(pub, Fluorine);
    |     in this macro invocation
    |
    = help: or consider exporting it for use by other crates
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `define_empty_struct_with_visibility` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: unreachable `pub` item
   --> $DIR/unreachable_pub.rs:41:9
index ae63bad841fa30f6b73df5caaa3cdd9e7adb5843..d08fbac0bcaabc006112c6dafc5f7b0b79710ea2 100644 (file)
@@ -10,7 +10,7 @@ LL | macro_rules! test { () => { fn foo() -> i32 { 1; } } }
 LL |     test!();
    |     -------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0308]: mismatched types
   --> $DIR/liveness-return-last-stmt-semi.rs:7:19
index d6a3b6e8382f4bae0d5db492dfe744cad1b62464..2b5c2eced08a80e477800a41fca2c0079816fdd4 100644 (file)
@@ -4,7 +4,7 @@ error[E0668]: malformed inline assembly
 LL |         llvm_asm!("" :"={rax"(rax))
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `llvm_asm` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0668]: malformed inline assembly
   --> $DIR/inline-asm-bad-constraint.rs:30:9
@@ -12,7 +12,7 @@ error[E0668]: malformed inline assembly
 LL |         llvm_asm!("callq $0" : : "0"(foo))
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `llvm_asm` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0668]: malformed inline assembly
   --> $DIR/inline-asm-bad-constraint.rs:37:9
@@ -20,7 +20,7 @@ error[E0668]: malformed inline assembly
 LL |         llvm_asm!("addb $1, $0" : "={rax}"((0i32, rax)));
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `llvm_asm` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 3 previous errors
 
index cf27052df05aa6aed400e478207c76880158c55a..6b313ac0faad85bc096460e300a8b92a09505a6d 100644 (file)
@@ -4,7 +4,7 @@ error[E0668]: malformed inline assembly
 LL |         llvm_asm!("nop" : "+r"("r15"));
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `llvm_asm` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index fac76fd6080febe0302ac30ba87b9bc971fea438..f03637abb67330b3012d5d7b250ac2f2259ab5dd 100644 (file)
@@ -7,7 +7,7 @@ LL |     () => { syntax error };
 LL |     pong!();
    |     -------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `pong` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `error`
   --> $DIR/main.rs:10:20
@@ -18,7 +18,7 @@ LL |     () => { syntax error };
 LL |     ping!();
    |     -------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `pong` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found `error`
   --> $DIR/main.rs:10:20
@@ -29,7 +29,7 @@ LL |     () => { syntax error };
 LL |     deep!();
    |     -------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `pong` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 3 previous errors
 
index 8aa7c33185983ecb9af1bbb881604e859f7ddef5..c7566d893188242b8cb787a5574e979798c54dd9 100644 (file)
@@ -16,7 +16,7 @@ error: macro requires a boolean expression as an argument
 LL |     debug_assert!();
    |     ^^^^^^^^^^^^^^^^ boolean expression required
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `debug_assert` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: expected expression, found keyword `struct`
   --> $DIR/assert.rs:5:19
index cb8055de6e3f62b79bec2531cf084312213f0ca5..1331480d835a495c12eabc399288357f984ee6df 100644 (file)
@@ -23,24 +23,5 @@ macro_rules! generated_foo {
         }
     };
 
-    // Check that all spans are equal.
-    // FIXME: `quote!` gives def-site spans to idents and literals,
-    // but leaves (default) call-site spans on groups and punctuation.
-    let mut span_call = None;
-    let mut span_def = None;
-    for tt in result.clone() {
-        match tt {
-            TokenTree::Ident(..) | TokenTree::Literal(..) => match span_def {
-                None => span_def = Some(tt.span()),
-                Some(span) => assert_same_span(tt.span(), span),
-            }
-            TokenTree::Punct(..) | TokenTree::Group(..) => match span_call {
-                None => span_call = Some(tt.span()),
-                Some(span) => assert_same_span(tt.span(), span),
-            }
-        }
-
-    }
-
     result
 }
index bbfc5e27fec04c4933bfb053f49294892463d045..a8e96c0137b575cc4f2d6e8ac1e74c87de6fbe5a 100644 (file)
@@ -4,7 +4,7 @@ error: macro requires a cfg-pattern as an argument
 LL |     cfg!();
    |     ^^^^^^^ cfg-pattern required
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `cfg` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: expected identifier, found `123`
   --> $DIR/cfg.rs:3:10
index 5943a252579abb5ffe5ad5fb3a3785d013947a04..dfbbb07de588ae7e68f2310363797ab12f07e3ed 100644 (file)
@@ -12,7 +12,7 @@ LL | |     }
 LL |       format_args!(hang!());
    |                    ------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `hang` (in Nightly builds, run with -Z macro-backtrace for more info)
 help: you might be missing a string literal to format with
    |
 LL |     format_args!("{}", hang!());
index 66cffbfa181703ea1dcf4aec4ff0775cb52bf172..b479a2778e0ef55819d0b3e82562cc6a09569437 100644 (file)
@@ -4,7 +4,7 @@ error: requires at least a format string argument
 LL |     format!();
    |     ^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::__export::format_args` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: expected expression, found keyword `struct`
   --> $DIR/format-parse-errors.rs:5:13
index 8402afa50857af3e9d12a5fe112bde6ca93892cd..b8903e07cfd38cf0fbf048b65c05d1afb7f319c2 100644 (file)
@@ -1,7 +1,7 @@
 #![feature(global_asm)]
 
 fn main() {
-    global_asm!();  //~ ERROR requires a string literal as an argument
+    global_asm!();  //~ ERROR requires at least a template string argument
     global_asm!(struct); //~ ERROR expected expression
-    global_asm!(123); //~ ERROR inline assembly must be a string literal
+    global_asm!(123); //~ ERROR asm template must be a string literal
 }
index c43bf83fe1912773f5c2ac2fbb8f55a94934660e..a8621a0c5185e50514a5fa28d5d9cbfb947e53cf 100644 (file)
@@ -1,8 +1,8 @@
-error: macro requires a string literal as an argument
+error: requires at least a template string argument
   --> $DIR/global-asm.rs:4:5
    |
 LL |     global_asm!();
-   |     ^^^^^^^^^^^^^^ string literal required
+   |     ^^^^^^^^^^^^^^
 
 error: expected expression, found keyword `struct`
   --> $DIR/global-asm.rs:5:17
@@ -10,7 +10,7 @@ error: expected expression, found keyword `struct`
 LL |     global_asm!(struct);
    |                 ^^^^^^ expected expression
 
-error: inline assembly must be a string literal
+error: asm template must be a string literal
   --> $DIR/global-asm.rs:6:17
    |
 LL |     global_asm!(123);
index c8d69640071c686dfefb088ad76cfb3be05cf824..b7079158fb093a253d0b6ef2eca66a557e7408ff 100644 (file)
@@ -8,7 +8,7 @@ LL |     make_item!(A)
    |     ------------- in this macro invocation
    |
    = note: the macro call doesn't expand to an expression, but it can expand to a statement
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `make_item` (in Nightly builds, run with -Z macro-backtrace for more info)
 help: add `;` to interpret the expansion as a statement
    |
 LL |     make_item!(A);
@@ -24,7 +24,7 @@ LL |     make_item!(B)
    |     ------------- in this macro invocation
    |
    = note: the macro call doesn't expand to an expression, but it can expand to a statement
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `make_item` (in Nightly builds, run with -Z macro-backtrace for more info)
 help: add `;` to interpret the expansion as a statement
    |
 LL |     make_item!(B);
index cf3af593141ff98b97de6fef9992a4748e3efcd4..2934281cdd6cbced8a41ace5d192ecc1b823e216 100644 (file)
@@ -7,7 +7,7 @@ LL |         extern crate std as core;
 LL | define_other_core!();
    | --------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `define_other_core` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 558e0349e2f32777dc280e32f844b7dc548e8453..39485d74e5eb2b0a67bc5e7f82025d311a883dc9 100644 (file)
@@ -14,7 +14,7 @@ LL | #![deny(semicolon_in_expressions_from_macros)]
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = 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 #79813 <https://github.com/rust-lang/rust/issues/79813>
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `len` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 2ce565936f2b53a6d746d34410af0dfce3cdbf13..b4d20699221abcdb50ccd1941d9082671f0f9e75 100644 (file)
@@ -7,7 +7,7 @@ LL |           1.fake()
 LL |     fake_method_stmt!();
    |     -------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `fake_method_stmt` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
   --> $DIR/macro-backtrace-invalid-internals.rs:11:13
@@ -18,7 +18,7 @@ LL |           1.fake
 LL |     fake_field_stmt!();
    |     ------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `fake_field_stmt` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
   --> $DIR/macro-backtrace-invalid-internals.rs:17:15
@@ -29,7 +29,7 @@ LL |           (1).0
 LL |     fake_anon_field_stmt!();
    |     ------------------------ in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `fake_anon_field_stmt` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0689]: can't call method `neg` on ambiguous numeric type `{float}`
   --> $DIR/macro-backtrace-invalid-internals.rs:41:15
@@ -40,7 +40,7 @@ LL |           2.0.neg()
 LL |     real_method_stmt!();
    |     -------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `real_method_stmt` (in Nightly builds, run with -Z macro-backtrace for more info)
 help: you must specify a concrete type for this numeric value, like `f32`
    |
 LL |           2.0_f32.neg()
@@ -55,7 +55,7 @@ LL |           1.fake()
 LL |     let _ = fake_method_expr!();
    |             ------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `fake_method_expr` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
   --> $DIR/macro-backtrace-invalid-internals.rs:29:13
@@ -66,7 +66,7 @@ LL |           1.fake
 LL |     let _ = fake_field_expr!();
    |             ------------------ in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `fake_field_expr` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
   --> $DIR/macro-backtrace-invalid-internals.rs:35:15
@@ -77,7 +77,7 @@ LL |           (1).0
 LL |     let _ = fake_anon_field_expr!();
    |             ----------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `fake_anon_field_expr` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0689]: can't call method `neg` on ambiguous numeric type `{float}`
   --> $DIR/macro-backtrace-invalid-internals.rs:47:15
@@ -88,7 +88,7 @@ LL |           2.0.neg()
 LL |     let _ = real_method_expr!();
    |             ------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `real_method_expr` (in Nightly builds, run with -Z macro-backtrace for more info)
 help: you must specify a concrete type for this numeric value, like `f32`
    |
 LL |           2.0_f32.neg()
index 8d3663833660cd92e14a536379175e49d2770fd6..d61434e5f2ff2540c224ceaf8268aaf66975d37f 100644 (file)
@@ -7,7 +7,7 @@ LL |     () => (fake)
 LL |     1 + call_nested_expr!();
    |         ------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `nested_expr` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0425]: cannot find value `fake` in this scope
   --> $DIR/macro-backtrace-nested.rs:5:12
@@ -18,7 +18,7 @@ LL |     () => (fake)
 LL |     call_nested_expr_sum!();
    |     ------------------------ in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `nested_expr` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index b4194a833a4facf33af8c95c0a2ce9264cd8970b..0703868e9b7e526328bce830980ceb41a210a568 100644 (file)
@@ -7,7 +7,7 @@ LL |     ($fmt:expr) => (myprint!(concat!($fmt, "\n")));
 LL |     myprintln!("{}");
    |     ----------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `concat` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 17c7389812475ac0a8eb48aff453d1adc6246cbd..5ed73b7fb93a3a57b79d7a3156742f0235636736 100644 (file)
@@ -40,7 +40,7 @@ LL |     () => ( i ; typeof );
 LL |     m!();
    |     ----- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0412]: cannot find type `i` in this scope
   --> $DIR/macro-context.rs:3:13
@@ -51,7 +51,7 @@ LL |     () => ( i ; typeof );
 LL |     let a: m!();
    |            ---- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0425]: cannot find value `i` in this scope
   --> $DIR/macro-context.rs:3:13
@@ -62,7 +62,7 @@ LL |     () => ( i ; typeof );
 LL |     let i = m!();
    |             ---- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 6 previous errors
 
index 68f885e9e45c7fb7baf720c2fa8967314ebf994d..f6fc8034410ef4cf3e5993581ae6fba27c97d2f5 100644 (file)
@@ -9,7 +9,7 @@ LL |     'b: loop {
 LL |         br2!('b);
    |         --------- in this macro invocation
    |
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `br2` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: 1 warning emitted
 
index 3092d76c268adaa36f009d7a2d46e913525b9061..89ff753b378dbf0454ea795c02a53ceff6ab6d42 100644 (file)
@@ -9,7 +9,7 @@ note: the constant `baz` is defined here
    |
 LL |     thread_local!(static baz: f64 = 0.0);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::__thread_local_inner` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 461e71471fb3d9fbeb81d0fadfe902f61839b2d0..010520845396a5437ec571a9b4c976702544ad3e 100644 (file)
@@ -8,7 +8,7 @@ LL | m1!();
    | ------ in this macro invocation
    |
    = note: macro-expanded `#[macro_use]`s may not shadow existing macros (see RFC 1560)
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m1` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0659]: `foo` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/macro-shadowing.rs:17:1
@@ -29,7 +29,7 @@ note: `foo` could also refer to the macro defined here
    |
 LL | macro_rules! foo { () => {} }
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m1` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index 42954ebcdc1cd4df6e4cdf7f70804773b13ecfca..14058f866393312262bc8f2969ffee8fa4f0d257 100644 (file)
@@ -4,7 +4,7 @@ error[E0665]: `Default` cannot be derived for enums, only structs
 LL | #[derive(Default)]
    |          ^^^^^^^
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: asm template must be a string literal
   --> $DIR/macros-nonfatal-errors.rs:13:10
@@ -48,7 +48,7 @@ error: environment variable `RUST_HOPEFULLY_THIS_DOESNT_EXIST` not defined
 LL |     env!("RUST_HOPEFULLY_THIS_DOESNT_EXIST");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: format argument must be a string literal
   --> $DIR/macros-nonfatal-errors.rs:23:13
@@ -79,7 +79,7 @@ error: couldn't read $DIR/i'd be quite surprised if a file with this name existe
 LL |     include_str!("i'd be quite surprised if a file with this name existed");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `include_str` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: argument must be a string literal
   --> $DIR/macros-nonfatal-errors.rs:29:20
@@ -93,7 +93,7 @@ error: couldn't read $DIR/i'd be quite surprised if a file with this name existe
 LL |     include_bytes!("i'd be quite surprised if a file with this name existed");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `include_bytes` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: trace_macros! accepts only `true` or `false`
   --> $DIR/macros-nonfatal-errors.rs:32:5
index b4072a1ad7e57af499eeb2bda1bb857fc3dcd8fd..46fa43ac96519d9227261f5a404dc89392a625d5 100644 (file)
@@ -6,7 +6,7 @@ LL |     write!(&mut example, "{}", 42);
    |
    = note: `-W unused-must-use` implied by `-W unused`
    = note: this `Result` may be an `Err` variant, which should be handled
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: 1 warning emitted
 
index 9521322f5c28102aaa94ae3e36876539385e3a19..38df53fb698c931a0263df6992c92f8edf5d4342 100644 (file)
@@ -10,7 +10,7 @@ LL |     n!(a $nt_item b);
 LL | complex_nonterminal!(enum E {});
    | -------------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `complex_nonterminal` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index f47be14fae3bc9ed0c492804987a57928fe673b8..7e1f2dcad11c47e66b2574ded045e8944f175038 100644 (file)
@@ -4,7 +4,7 @@ error: couldn't read $DIR/not-utf8.bin: stream did not contain valid UTF-8
 LL |     include!("not-utf8.bin")
    |     ^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `include` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 662266013d04ad02bfe18ce6cd829085251b310b..cf4203525e6cbd19339e921bf408f3b851997c4e 100644 (file)
@@ -23,7 +23,7 @@ LL |         macro_rules! m { () => {} }
 ...
 LL | include!();
    | ----------- in this macro invocation
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `gen_gen_inner_invoc` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/restricted-shadowing-legacy.rs:139:42
@@ -50,7 +50,7 @@ LL |         macro_rules! m { () => {} }
 ...
 LL | include!();
    | ----------- in this macro invocation
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `gen_invoc` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/restricted-shadowing-legacy.rs:148:9
@@ -77,7 +77,7 @@ LL |         macro_rules! m { () => {} }
 ...
 LL | include!();
    | ----------- in this macro invocation
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `include` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/restricted-shadowing-legacy.rs:164:9
@@ -104,7 +104,7 @@ LL |         macro_rules! m { () => { Wrong } }
 ...
 LL | include!();
    | ----------- in this macro invocation
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `include` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/restricted-shadowing-legacy.rs:180:13
@@ -131,7 +131,7 @@ LL |         macro_rules! m { () => { Wrong } }
 ...
 LL | include!();
    | ----------- in this macro invocation
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `gen_gen_inner_invoc` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/restricted-shadowing-legacy.rs:218:42
@@ -158,7 +158,7 @@ LL |         macro_rules! m { () => { Wrong } }
 ...
 LL | include!();
    | ----------- in this macro invocation
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `gen_invoc` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/restricted-shadowing-legacy.rs:232:9
@@ -185,7 +185,7 @@ LL |             macro_rules! m { () => {} }
 ...
 LL | include!();
    | ----------- in this macro invocation
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `include` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/restricted-shadowing-legacy.rs:262:42
@@ -212,7 +212,7 @@ LL |             macro_rules! m { () => {} }
 ...
 LL | include!();
    | ----------- in this macro invocation
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `gen_invoc` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 8 previous errors
 
index 609f0b6b18aaf88527db5140d3bd1f39d87ae1a3..6161e46e48b582662a24e0efefbce4dd1b874ea9 100644 (file)
@@ -23,7 +23,7 @@ LL |         macro m() {}
 ...
 LL | include!();
    | ----------- in this macro invocation
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `gen_gen_inner_invoc` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/restricted-shadowing-modern.rs:147:33
@@ -50,7 +50,7 @@ LL |         macro m() {}
 ...
 LL | include!();
    | ----------- in this macro invocation
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `gen_invoc` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/restricted-shadowing-modern.rs:156:13
@@ -77,7 +77,7 @@ LL |         macro m() {}
 ...
 LL | include!();
    | ----------- in this macro invocation
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `include` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/restricted-shadowing-modern.rs:172:13
@@ -104,7 +104,7 @@ LL |         macro m() { Wrong }
 ...
 LL | include!();
    | ----------- in this macro invocation
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `include` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/restricted-shadowing-modern.rs:190:17
@@ -131,7 +131,7 @@ LL |         macro m() { Wrong }
 ...
 LL | include!();
    | ----------- in this macro invocation
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `gen_gen_inner_invoc` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0659]: `m` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
   --> $DIR/restricted-shadowing-modern.rs:233:33
@@ -158,7 +158,7 @@ LL |         macro m() { Wrong }
 ...
 LL | include!();
    | ----------- in this macro invocation
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `gen_invoc` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 6 previous errors
 
index 63b8b29d6ce2861db2a879c6d2d2bca76fa67d3c..4581d5831881b0f30ffb37d2734cb8204de5a1e9 100644 (file)
@@ -17,14 +17,18 @@ LL |                $(= $z:tt)*
 error: `$x:expr` may be followed by `$y:tt`, which is not allowed for `expr` fragments
   --> $DIR/same-sequence-span.rs:19:1
    |
-LL | proc_macro_sequence::make_foo!();
-   | ---------------------------------^^^^^^^^^^^^^
+LL |   proc_macro_sequence::make_foo!();
+   |   ^--------------------------------
+   |   |
+   |  _in this macro invocation
    | |
-   | not allowed after `expr` fragments
-   | in this macro invocation
+LL | |
+LL | |
+LL | | fn main() {}
+   | |_________________________________^ not allowed after `expr` fragments
    |
    = note: allowed there are: `=>`, `,` or `;`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `proc_macro_sequence::make_foo` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `$x:expr` may be followed by `=`, which is not allowed for `expr` fragments
   --> $DIR/same-sequence-span.rs:19:1
@@ -33,7 +37,7 @@ LL | proc_macro_sequence::make_foo!();
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not allowed after `expr` fragments
    |
    = note: allowed there are: `=>`, `,` or `;`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `proc_macro_sequence::make_foo` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 4 previous errors
 
index efb8f61e4621a2952014c4737d2d55ab2359619f..f563b0dc1292335312964b392229f8996929fe75 100644 (file)
@@ -9,7 +9,7 @@ LL |             *&mut $s = 0;
 LL |     bad!(foo whatever);
    |     ------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `bad` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index cecc942f4702aabd22a8870d77e5cad8bf916873..6a54bb10b79a2eefe4c3f5b428bcaba00cb0a0e4 100644 (file)
@@ -10,7 +10,7 @@ LL |         my_faulty_macro!(bcd);
 LL |     my_faulty_macro!();
    |     ------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `my_faulty_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 note: trace_macro
   --> $DIR/trace_faulty_macros.rs:31:5
@@ -32,7 +32,7 @@ LL |     my_recursive_macro!();
    |     ---------------------- in this macro invocation
    |
    = help: consider adding a `#![recursion_limit="8"]` attribute to your crate (`trace_faulty_macros`)
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `my_recursive_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 note: trace_macro
   --> $DIR/trace_faulty_macros.rs:32:5
@@ -58,7 +58,7 @@ LL |         $a
 LL |     let a = pat_macro!();
    |             ------------ in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `pat_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0774]: `derive` may only be applied to structs, enums and unions
   --> $DIR/trace_faulty_macros.rs:42:1
index 3dabebfdaa25346b427478adc93c4a9dc9343849..7060f5d8b4791010de64a1023784d7d8bf73c1f1 100644 (file)
@@ -4,7 +4,7 @@ error: arbitrary expressions aren't allowed in patterns
 LL |         Some(vec![43]) => {}
    |              ^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 365cc099e9d3ecd370a1dc52c0ea26fed1a71255..ba096a9080ae2b409ca29bca453475b76cd8ec12 100644 (file)
@@ -27,7 +27,7 @@ LL | #[derive(Copy(Bad))]
 LL | pub trait Copy: Clone {
    |                 ----- required by this bound in `Copy`
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0277]: the trait bound `Test2: Clone` is not satisfied
   --> $DIR/malformed-derive-entry.rs:6:10
@@ -40,7 +40,7 @@ LL | #[derive(Copy="bad")]
 LL | pub trait Copy: Clone {
    |                 ----- required by this bound in `Copy`
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 5 previous errors
 
diff --git a/src/test/ui/match/auxiliary/match_non_exhaustive_lib.rs b/src/test/ui/match/auxiliary/match_non_exhaustive_lib.rs
new file mode 100644 (file)
index 0000000..3be7255
--- /dev/null
@@ -0,0 +1,5 @@
+#[non_exhaustive]
+pub enum E1 {}
+
+#[non_exhaustive]
+pub enum E2 { A, B }
diff --git a/src/test/ui/match/match_non_exhaustive.rs b/src/test/ui/match/match_non_exhaustive.rs
new file mode 100644 (file)
index 0000000..8219f0e
--- /dev/null
@@ -0,0 +1,32 @@
+// aux-build:match_non_exhaustive_lib.rs
+
+/* The error message for non-exhaustive matches on non-local enums
+ * marked as non-exhaustive should mention the fact that the enum
+ * is marked as non-exhaustive (issue #85227).
+ */
+
+// Ignore non_exhaustive in the same crate
+#[non_exhaustive]
+enum L { A, B }
+
+extern crate match_non_exhaustive_lib;
+use match_non_exhaustive_lib::{E1, E2};
+
+fn foo() -> L {todo!()}
+fn bar() -> (E1, E2) {todo!()}
+
+fn main() {
+    let l = foo();
+    // No error for enums defined in this crate
+    match l { L::A => (), L::B => () };
+    // (except if the match is already non-exhaustive)
+    match l { L::A => () };
+    //~^ ERROR: non-exhaustive patterns: `B` not covered [E0004]
+
+    // E1 is not visibly uninhabited from here
+    let (e1, e2) = bar();
+    match e1 {};
+    //~^ ERROR: non-exhaustive patterns: type `E1` is non-empty [E0004]
+    match e2 { E2::A => (), E2::B => () };
+    //~^ ERROR: non-exhaustive patterns: `_` not covered [E0004]
+}
diff --git a/src/test/ui/match/match_non_exhaustive.stderr b/src/test/ui/match/match_non_exhaustive.stderr
new file mode 100644 (file)
index 0000000..5debfe1
--- /dev/null
@@ -0,0 +1,36 @@
+error[E0004]: non-exhaustive patterns: `B` not covered
+  --> $DIR/match_non_exhaustive.rs:23:11
+   |
+LL | enum L { A, B }
+   | ---------------
+   | |           |
+   | |           not covered
+   | `L` defined here
+...
+LL |     match l { L::A => () };
+   |           ^ pattern `B` 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 `L`
+
+error[E0004]: non-exhaustive patterns: type `E1` is non-empty
+  --> $DIR/match_non_exhaustive.rs:28:11
+   |
+LL |     match e1 {};
+   |           ^^
+   |
+   = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
+   = note: the matched value is of type `E1`, which is marked as non-exhaustive
+
+error[E0004]: non-exhaustive patterns: `_` not covered
+  --> $DIR/match_non_exhaustive.rs:30:11
+   |
+LL |     match e2 { E2::A => (), E2::B => () };
+   |           ^^ pattern `_` 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 `E2`, which is marked as non-exhaustive
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0004`.
index af1738512527c38b1a439242b8aeccc29333aad1..6bf55844da8f25aae7643d042a0eb2ca665f77c8 100644 (file)
@@ -14,7 +14,7 @@ fn life_and_type<'a, T>(self) -> &'a T { loop {} }
 fn method_call() {
     S.early(); // OK
     S.early::<'static>();
-    //~^ ERROR this associated function takes 2 lifetime arguments but only 1 lifetime argument was supplied
+    //~^ ERROR this associated function takes 2 lifetime arguments but 1 lifetime argument
     S.early::<'static, 'static, 'static>();
     //~^ ERROR this associated function takes 2 lifetime arguments but 3 lifetime arguments were supplied
     let _: &u8 = S.life_and_type::<'static>();
@@ -61,7 +61,7 @@ fn ufcs() {
 
     S::early(S); // OK
     S::early::<'static>(S);
-    //~^ ERROR this associated function takes 2 lifetime arguments but only 1 lifetime argument was supplied
+    //~^ ERROR this associated function takes 2 lifetime arguments but 1 lifetime argument
     S::early::<'static, 'static, 'static>(S);
     //~^ ERROR this associated function takes 2 lifetime arguments but 3 lifetime arguments were supplied
     let _: &u8 = S::life_and_type::<'static>(S);
index 2907309c27c7b26203d37d63e7256a02885f362d..ea50815ec1af71711e8bc0b74f06588142d44da9 100644 (file)
@@ -1,4 +1,4 @@
-error[E0107]: this associated function takes 2 lifetime arguments but only 1 lifetime argument was supplied
+error[E0107]: this associated function takes 2 lifetime arguments but 1 lifetime argument was supplied
   --> $DIR/method-call-lifetime-args-fail.rs:16:7
    |
 LL |     S.early::<'static>();
@@ -20,7 +20,7 @@ error[E0107]: this associated function takes 2 lifetime arguments but 3 lifetime
   --> $DIR/method-call-lifetime-args-fail.rs:18:7
    |
 LL |     S.early::<'static, 'static, 'static>();
-   |       ^^^^^                   --------- help: remove this lifetime argument
+   |       ^^^^^                     ------- help: remove this lifetime argument
    |       |
    |       expected 2 lifetime arguments
    |
@@ -198,7 +198,7 @@ note: the late bound lifetime parameter is introduced here
 LL |     fn late_unused_early<'a, 'b>(self) -> &'b u8 { loop {} }
    |                          ^^
 
-error[E0107]: this associated function takes 2 lifetime arguments but only 1 lifetime argument was supplied
+error[E0107]: this associated function takes 2 lifetime arguments but 1 lifetime argument was supplied
   --> $DIR/method-call-lifetime-args-fail.rs:63:8
    |
 LL |     S::early::<'static>(S);
@@ -220,7 +220,7 @@ error[E0107]: this associated function takes 2 lifetime arguments but 3 lifetime
   --> $DIR/method-call-lifetime-args-fail.rs:65:8
    |
 LL |     S::early::<'static, 'static, 'static>(S);
-   |        ^^^^^                   --------- help: remove this lifetime argument
+   |        ^^^^^                     ------- help: remove this lifetime argument
    |        |
    |        expected 2 lifetime arguments
    |
index 3b1992d90b7c5966ee8932701b534d615954b1a4..e04d59c58c22bfa86c4f021c66f6ef21d2a29c77 100644 (file)
@@ -1,5 +1,3 @@
-#![feature(const_fn)]
-
 trait Foo {
     fn f() -> u32;
     const fn g(); //~ ERROR cannot be declared const
index 450981a9183a220cd45744eed319c0643b9aacc5..7d1fbe45c5302ce815920f4b06566e218f1f65de 100644 (file)
@@ -1,11 +1,11 @@
 error[E0379]: functions in traits cannot be declared const
-  --> $DIR/const-fn-in-trait.rs:5:5
+  --> $DIR/const-fn-in-trait.rs:3:5
    |
 LL |     const fn g();
    |     ^^^^^ functions in traits cannot be const
 
 error[E0379]: functions in traits cannot be declared const
-  --> $DIR/const-fn-in-trait.rs:9:5
+  --> $DIR/const-fn-in-trait.rs:7:5
    |
 LL |     const fn f() -> u32 { 22 }
    |     ^^^^^ functions in traits cannot be const
index e608cd99af238a21835ea8fa2c897bcb929bad80..d0859726a49f6d787cf7c97781541c8a2f5cf1b8 100644 (file)
@@ -7,7 +7,7 @@ LL |                   $arr.len() * size_of($arr[0]));
 LL |     write!(hello);
    |     -------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info)
 help: you can convert a `usize` to a `u64` and panic if the converted value doesn't fit
    |
 LL |                   ($arr.len() * size_of($arr[0])).try_into().unwrap());
@@ -22,7 +22,7 @@ LL |     ($x:expr) => ($x as ())
 LL |     cast!(2);
    |     --------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `cast` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/mismatched_types/issue-84976.rs b/src/test/ui/mismatched_types/issue-84976.rs
new file mode 100644 (file)
index 0000000..db6fe0b
--- /dev/null
@@ -0,0 +1,25 @@
+/* Checks whether primitive type names are formatted correctly in the
+ * error messages about mismatched types (#84976).
+ */
+
+fn foo(length: &u32) -> i32 {
+    0
+}
+
+fn bar(length: &f32) -> f64 {
+    0.0
+}
+
+fn main() {
+    let mut length = 0;
+    length = { foo(&length) };
+    //~^ ERROR mismatched types [E0308]
+    length = foo(&length);
+    //~^ ERROR mismatched types [E0308]
+
+    let mut float_length = 0.0;
+    float_length = { bar(&float_length) };
+    //~^ ERROR mismatched types [E0308]
+    float_length = bar(&float_length);
+    //~^ ERROR mismatched types [E0308]
+}
diff --git a/src/test/ui/mismatched_types/issue-84976.stderr b/src/test/ui/mismatched_types/issue-84976.stderr
new file mode 100644 (file)
index 0000000..0c27e17
--- /dev/null
@@ -0,0 +1,27 @@
+error[E0308]: mismatched types
+  --> $DIR/issue-84976.rs:15:16
+   |
+LL |     length = { foo(&length) };
+   |                ^^^^^^^^^^^^ expected `u32`, found `i32`
+
+error[E0308]: mismatched types
+  --> $DIR/issue-84976.rs:17:14
+   |
+LL |     length = foo(&length);
+   |              ^^^^^^^^^^^^ expected `u32`, found `i32`
+
+error[E0308]: mismatched types
+  --> $DIR/issue-84976.rs:21:22
+   |
+LL |     float_length = { bar(&float_length) };
+   |                      ^^^^^^^^^^^^^^^^^^ expected `f32`, found `f64`
+
+error[E0308]: mismatched types
+  --> $DIR/issue-84976.rs:23:20
+   |
+LL |     float_length = bar(&float_length);
+   |                    ^^^^^^^^^^^^^^^^^^ expected `f32`, found `f64`
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/missing/missing-items/missing-type-parameter2.rs b/src/test/ui/missing/missing-items/missing-type-parameter2.rs
new file mode 100644 (file)
index 0000000..15dc5ef
--- /dev/null
@@ -0,0 +1,22 @@
+#![allow(incomplete_features)]
+#![feature(const_generics_defaults)]
+
+struct X<const N: u8>();
+
+impl X<N> {}
+//~^ ERROR cannot find type `N` in this scope
+//~| ERROR unresolved item provided when a constant was expected
+impl<T, const A: u8 = 2> X<N> {}
+//~^ ERROR cannot find type `N` in this scope
+//~| ERROR defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
+//~| ERROR unresolved item provided when a constant was expected
+
+fn foo(_: T) where T: Send {}
+//~^ ERROR cannot find type `T` in this scope
+//~| ERROR cannot find type `T` in this scope
+
+fn bar<const N: u8>(_: A) {}
+//~^ ERROR cannot find type `A` in this scope
+
+fn main() {
+}
diff --git a/src/test/ui/missing/missing-items/missing-type-parameter2.stderr b/src/test/ui/missing/missing-items/missing-type-parameter2.stderr
new file mode 100644 (file)
index 0000000..985a9bb
--- /dev/null
@@ -0,0 +1,121 @@
+error[E0412]: cannot find type `N` in this scope
+  --> $DIR/missing-type-parameter2.rs:6:8
+   |
+LL | struct X<const N: u8>();
+   | ------------------------ similarly named struct `X` defined here
+LL | 
+LL | impl X<N> {}
+   |        ^
+   |
+help: a struct with a similar name exists
+   |
+LL | impl X<X> {}
+   |        ^
+help: you might be missing a type parameter
+   |
+LL | impl<N> X<N> {}
+   |     ^^^
+
+error[E0412]: cannot find type `N` in this scope
+  --> $DIR/missing-type-parameter2.rs:9:28
+   |
+LL | impl<T, const A: u8 = 2> X<N> {}
+   |      -                     ^
+   |      |
+   |      similarly named type parameter `T` defined here
+   |
+help: a type parameter with a similar name exists
+   |
+LL | impl<T, const A: u8 = 2> X<T> {}
+   |                            ^
+help: you might be missing a type parameter
+   |
+LL | impl<T, const A: u8 = 2, N> X<N> {}
+   |                        ^^^
+
+error[E0412]: cannot find type `T` in this scope
+  --> $DIR/missing-type-parameter2.rs:14:20
+   |
+LL | struct X<const N: u8>();
+   | ------------------------ similarly named struct `X` defined here
+...
+LL | fn foo(_: T) where T: Send {}
+   |                    ^
+   |
+help: a struct with a similar name exists
+   |
+LL | fn foo(_: T) where X: Send {}
+   |                    ^
+help: you might be missing a type parameter
+   |
+LL | fn foo<T>(_: T) where T: Send {}
+   |       ^^^
+
+error[E0412]: cannot find type `T` in this scope
+  --> $DIR/missing-type-parameter2.rs:14:11
+   |
+LL | struct X<const N: u8>();
+   | ------------------------ similarly named struct `X` defined here
+...
+LL | fn foo(_: T) where T: Send {}
+   |           ^
+   |
+help: a struct with a similar name exists
+   |
+LL | fn foo(_: X) where T: Send {}
+   |           ^
+help: you might be missing a type parameter
+   |
+LL | fn foo<T>(_: T) where T: Send {}
+   |       ^^^
+
+error[E0412]: cannot find type `A` in this scope
+  --> $DIR/missing-type-parameter2.rs:18:24
+   |
+LL | struct X<const N: u8>();
+   | ------------------------ similarly named struct `X` defined here
+...
+LL | fn bar<const N: u8>(_: A) {}
+   |                        ^
+   |
+help: a struct with a similar name exists
+   |
+LL | fn bar<const N: u8>(_: X) {}
+   |                        ^
+help: you might be missing a type parameter
+   |
+LL | fn bar<const N: u8, A>(_: A) {}
+   |                   ^^^
+
+error[E0747]: unresolved item provided when a constant was expected
+  --> $DIR/missing-type-parameter2.rs:6:8
+   |
+LL | impl X<N> {}
+   |        ^
+   |
+help: if this generic argument was intended as a const parameter, surround it with braces
+   |
+LL | impl X<{ N }> {}
+   |        ^   ^
+
+error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions
+  --> $DIR/missing-type-parameter2.rs:9:15
+   |
+LL | impl<T, const A: u8 = 2> X<N> {}
+   |               ^
+
+error[E0747]: unresolved item provided when a constant was expected
+  --> $DIR/missing-type-parameter2.rs:9:28
+   |
+LL | impl<T, const A: u8 = 2> X<N> {}
+   |                            ^
+   |
+help: if this generic argument was intended as a const parameter, surround it with braces
+   |
+LL | impl<T, const A: u8 = 2> X<{ N }> {}
+   |                            ^   ^
+
+error: aborting due to 8 previous errors
+
+Some errors have detailed explanations: E0412, E0747.
+For more information about an error, try `rustc --explain E0412`.
index 3ac8dc548aeb9363dbbd436cd6d6e95246870971..cbeaafd9268aab5113aef32f07a558612c7028c3 100644 (file)
@@ -13,7 +13,7 @@ LL | import!(("issue-56411-aux.rs", issue_56411_aux));
    | ------------------------------------------------- in this macro invocation
    |
    = note: `issue_56411_aux` must be defined only once in the type namespace of this module
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `import` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0365]: `issue_56411_aux` is private, and cannot be re-exported
   --> $DIR/issue-56411.rs:6:21
@@ -25,7 +25,7 @@ LL | import!(("issue-56411-aux.rs", issue_56411_aux));
    | ------------------------------------------------- in this macro invocation
    |
    = note: consider declaring type or module `issue_56411_aux` with `pub`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `import` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index e813f21e01df203cb5286e44f1885696695b93d7..4c302d935db96338085329cd6099a5e99e397082 100644 (file)
@@ -1,8 +1,6 @@
 error[E0621]: explicit lifetime required in the type of `x`
   --> $DIR/region-lbr-anon-does-not-outlive-static.rs:9:5
    |
-LL | fn foo(x: &u32) -> &'static u32 {
-   |           ---- help: add explicit lifetime `ReStatic` to the type of `x`: `&ReStatic u32`
 LL |     &*x
    |     ^^^ lifetime `ReStatic` required
 
index 361466c4d54e05488926ce7b6756d57682900902..eabc3105c029307a119e5a94489f6aca70d55784 100644 (file)
@@ -12,9 +12,6 @@ LL |     *x
 error[E0621]: explicit lifetime required in the type of `s`
   --> $DIR/guarantor-issue-46974.rs:15:5
    |
-LL | fn bar(s: &Box<(i32,)>) -> &'static i32 {
-   |           ------------ help: add explicit lifetime `'static` to the type of `s`: `&'static Box<(i32,)>`
-LL |     // FIXME(#46983): error message should be better
 LL |     &s.0
    |     ^^^^ lifetime `'static` required
 
index 2382fd848438e4633ef2ff1b32212dc6c615ff0f..fe4114aeddc009f002a70eb9229680a2b4c4e3a7 100644 (file)
@@ -7,7 +7,7 @@ LL |     println!("{:?} {:?}", Foo, Bar);
    = help: the trait `Debug` is not implemented for `Foo`
    = note: add `#[derive(Debug)]` or manually implement `Debug`
    = note: required by `std::fmt::Debug::fmt`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0277]: `Bar` doesn't implement `Debug`
   --> $DIR/no-debug.rs:10:32
@@ -17,7 +17,7 @@ LL |     println!("{:?} {:?}", Foo, Bar);
    |
    = help: the trait `Debug` is not implemented for `Bar`
    = note: required by `std::fmt::Debug::fmt`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0277]: `Foo` doesn't implement `std::fmt::Display`
   --> $DIR/no-debug.rs:11:23
@@ -28,7 +28,7 @@ LL |     println!("{} {}", Foo, Bar);
    = help: the trait `std::fmt::Display` is not implemented for `Foo`
    = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
    = note: required by `std::fmt::Display::fmt`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0277]: `Bar` doesn't implement `std::fmt::Display`
   --> $DIR/no-debug.rs:11:28
@@ -39,7 +39,7 @@ LL |     println!("{} {}", Foo, Bar);
    = help: the trait `std::fmt::Display` is not implemented for `Bar`
    = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
    = note: required by `std::fmt::Display::fmt`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 4 previous errors
 
index a84681e0056f01e0eda5ab3ee44feedb4dc8162f..3f7d47dcb8ceb2ef307ed919d80d9a59d46e5691 100644 (file)
@@ -140,7 +140,7 @@ 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)
+   = note: this error originates in the macro `t_or_f` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: unreachable pattern
   --> $DIR/exhaustiveness-unreachable-pattern.rs:116:14
index b414f9230b6758355ea8f440487ddb7234342367..1db31e0272c91d794b82f31118c4a7b79ee96ee0 100644 (file)
@@ -14,7 +14,7 @@ note: `bar` could also refer to the macro defined here
    |
 LL | macro_rules! bar { () => {} }
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `define_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 2cbb6a13e74b9b192b790b05fe8bfc07d9e470da..9a6957a0408497eb19a53bbd941868b96fc74a51 100644 (file)
@@ -9,7 +9,7 @@ LL |         'lab: $b;
 LL |     m!({});
    |     ------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: cannot use a `block` macro fragment here
   --> $DIR/bad-interpolated-block.rs:8:16
@@ -22,7 +22,7 @@ LL |         unsafe $b;
 LL |     m!({});
    |     ------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: cannot use a `block` macro fragment here
   --> $DIR/bad-interpolated-block.rs:9:23
@@ -33,7 +33,7 @@ LL |         |x: u8| -> () $b;
 LL |     m!({});
    |     ------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 3 previous errors
 
index fb974f085cbf15e3c78b8b3f13cc904a5cbe45e1..4b03427cd5871093711cc159848d704534d727a6 100644 (file)
@@ -7,7 +7,7 @@ LL |         { s.$b; }
 LL |     generate_field_accesses!(1.1, 1.1, 1.1);
    |     ---------------------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `generate_field_accesses` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: expected one of `.`, `;`, `?`, `}`, or an operator, found `1.1`
   --> $DIR/float-field-interpolated.rs:8:13
@@ -18,7 +18,7 @@ LL |         { s.$b; }
 LL |     generate_field_accesses!(1.1, 1.1, 1.1);
    |     ---------------------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `generate_field_accesses` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: unexpected token: `1.1`
   --> $DIR/float-field-interpolated.rs:10:13
@@ -29,7 +29,7 @@ LL |         { s.$c; }
 LL |     generate_field_accesses!(1.1, 1.1, 1.1);
    |     ---------------------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `generate_field_accesses` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: expected one of `.`, `;`, `?`, `}`, or an operator, found `1.1`
   --> $DIR/float-field-interpolated.rs:10:13
@@ -40,7 +40,7 @@ LL |         { s.$c; }
 LL |     generate_field_accesses!(1.1, 1.1, 1.1);
    |     ---------------------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `generate_field_accesses` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 4 previous errors
 
index 0bbaeec0c7fec54c8f1d358f53ee7501bc846585..91a63bafd99a9688d6847e380c863a8ee8768dca 100644 (file)
@@ -3,7 +3,6 @@
 // edition:2018
 
 #![feature(const_extern_fn)]
-#![feature(const_fn)]
 
 fn main() {
     async fn ff1() {} // OK.
index 2e513415e6c64fdbcf862e3fe1a333ba2781ccf2..b3f60b13b0f74a640869a8bb5dd1a8e9c0ec07ea 100644 (file)
@@ -1,5 +1,5 @@
 error: functions cannot be both `const` and `async`
-  --> $DIR/fn-header-semantic-fail.rs:13:5
+  --> $DIR/fn-header-semantic-fail.rs:12:5
    |
 LL |     const async unsafe extern "C" fn ff5() {} // OK.
    |     ^^^^^-^^^^^------------------------------
@@ -8,7 +8,7 @@ LL |     const async unsafe extern "C" fn ff5() {} // OK.
    |     `const` because of this
 
 error[E0706]: functions in traits cannot be declared `async`
-  --> $DIR/fn-header-semantic-fail.rs:17:9
+  --> $DIR/fn-header-semantic-fail.rs:16:9
    |
 LL |         async fn ft1();
    |         -----^^^^^^^^^^
@@ -19,19 +19,19 @@ LL |         async fn ft1();
    = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
 
 error[E0379]: functions in traits cannot be declared const
-  --> $DIR/fn-header-semantic-fail.rs:19:9
+  --> $DIR/fn-header-semantic-fail.rs:18:9
    |
 LL |         const fn ft3();
    |         ^^^^^ functions in traits cannot be const
 
 error[E0379]: functions in traits cannot be declared const
-  --> $DIR/fn-header-semantic-fail.rs:21:9
+  --> $DIR/fn-header-semantic-fail.rs:20:9
    |
 LL |         const async unsafe extern "C" fn ft5();
    |         ^^^^^ functions in traits cannot be const
 
 error[E0706]: functions in traits cannot be declared `async`
-  --> $DIR/fn-header-semantic-fail.rs:21:9
+  --> $DIR/fn-header-semantic-fail.rs:20:9
    |
 LL |         const async unsafe extern "C" fn ft5();
    |         ^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -42,7 +42,7 @@ LL |         const async unsafe extern "C" fn ft5();
    = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
 
 error: functions cannot be both `const` and `async`
-  --> $DIR/fn-header-semantic-fail.rs:21:9
+  --> $DIR/fn-header-semantic-fail.rs:20:9
    |
 LL |         const async unsafe extern "C" fn ft5();
    |         ^^^^^-^^^^^----------------------------
@@ -51,7 +51,7 @@ LL |         const async unsafe extern "C" fn ft5();
    |         `const` because of this
 
 error[E0706]: functions in traits cannot be declared `async`
-  --> $DIR/fn-header-semantic-fail.rs:29:9
+  --> $DIR/fn-header-semantic-fail.rs:28:9
    |
 LL |         async fn ft1() {}
    |         -----^^^^^^^^^^^^
@@ -62,19 +62,19 @@ LL |         async fn ft1() {}
    = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
 
 error[E0379]: functions in traits cannot be declared const
-  --> $DIR/fn-header-semantic-fail.rs:32:9
+  --> $DIR/fn-header-semantic-fail.rs:31:9
    |
 LL |         const fn ft3() {}
    |         ^^^^^ functions in traits cannot be const
 
 error[E0379]: functions in traits cannot be declared const
-  --> $DIR/fn-header-semantic-fail.rs:34:9
+  --> $DIR/fn-header-semantic-fail.rs:33:9
    |
 LL |         const async unsafe extern "C" fn ft5() {}
    |         ^^^^^ functions in traits cannot be const
 
 error[E0706]: functions in traits cannot be declared `async`
-  --> $DIR/fn-header-semantic-fail.rs:34:9
+  --> $DIR/fn-header-semantic-fail.rs:33:9
    |
 LL |         const async unsafe extern "C" fn ft5() {}
    |         ^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -85,7 +85,7 @@ LL |         const async unsafe extern "C" fn ft5() {}
    = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait
 
 error: functions cannot be both `const` and `async`
-  --> $DIR/fn-header-semantic-fail.rs:34:9
+  --> $DIR/fn-header-semantic-fail.rs:33:9
    |
 LL |         const async unsafe extern "C" fn ft5() {}
    |         ^^^^^-^^^^^------------------------------
@@ -94,7 +94,7 @@ LL |         const async unsafe extern "C" fn ft5() {}
    |         `const` because of this
 
 error: functions cannot be both `const` and `async`
-  --> $DIR/fn-header-semantic-fail.rs:46:9
+  --> $DIR/fn-header-semantic-fail.rs:45:9
    |
 LL |         const async unsafe extern "C" fn fi5() {}
    |         ^^^^^-^^^^^------------------------------
@@ -103,7 +103,7 @@ LL |         const async unsafe extern "C" fn fi5() {}
    |         `const` because of this
 
 error: functions in `extern` blocks cannot have qualifiers
-  --> $DIR/fn-header-semantic-fail.rs:51:18
+  --> $DIR/fn-header-semantic-fail.rs:50:18
    |
 LL |     extern "C" {
    |     ---------- in this `extern` block
@@ -116,7 +116,7 @@ LL |         fn fe1();
    |         ^^
 
 error: functions in `extern` blocks cannot have qualifiers
-  --> $DIR/fn-header-semantic-fail.rs:52:19
+  --> $DIR/fn-header-semantic-fail.rs:51:19
    |
 LL |     extern "C" {
    |     ---------- in this `extern` block
@@ -130,7 +130,7 @@ LL |         fn fe2();
    |         ^^
 
 error: functions in `extern` blocks cannot have qualifiers
-  --> $DIR/fn-header-semantic-fail.rs:53:18
+  --> $DIR/fn-header-semantic-fail.rs:52:18
    |
 LL |     extern "C" {
    |     ---------- in this `extern` block
@@ -144,7 +144,7 @@ LL |         fn fe3();
    |         ^^
 
 error: functions in `extern` blocks cannot have qualifiers
-  --> $DIR/fn-header-semantic-fail.rs:54:23
+  --> $DIR/fn-header-semantic-fail.rs:53:23
    |
 LL |     extern "C" {
    |     ---------- in this `extern` block
@@ -158,7 +158,7 @@ LL |         fn fe4();
    |         ^^
 
 error: functions in `extern` blocks cannot have qualifiers
-  --> $DIR/fn-header-semantic-fail.rs:55:42
+  --> $DIR/fn-header-semantic-fail.rs:54:42
    |
 LL |     extern "C" {
    |     ---------- in this `extern` block
@@ -172,7 +172,7 @@ LL |         fn fe5();
    |         ^^
 
 error: functions cannot be both `const` and `async`
-  --> $DIR/fn-header-semantic-fail.rs:55:9
+  --> $DIR/fn-header-semantic-fail.rs:54:9
    |
 LL |         const async unsafe extern "C" fn fe5();
    |         ^^^^^-^^^^^----------------------------
@@ -181,7 +181,7 @@ LL |         const async unsafe extern "C" fn fe5();
    |         `const` because of this
 
 error[E0053]: method `ft1` has an incompatible type for trait
-  --> $DIR/fn-header-semantic-fail.rs:29:24
+  --> $DIR/fn-header-semantic-fail.rs:28:24
    |
 LL |         async fn ft1();
    |                       - type in trait
@@ -197,7 +197,7 @@ LL |         async fn ft1() {}
               found fn pointer `fn() -> impl Future`
 
 error[E0053]: method `ft5` has an incompatible type for trait
-  --> $DIR/fn-header-semantic-fail.rs:34:48
+  --> $DIR/fn-header-semantic-fail.rs:33:48
    |
 LL |         const async unsafe extern "C" fn ft5();
    |                                               - type in trait
index c83205aadd6729a28b408be3b617e8babe5300bc..0ab718d8bd4f5b6acf006f1bf12a0af5a1395497 100644 (file)
@@ -16,7 +16,7 @@ LL |     expand_to_enum!();
    |     ------------------ in this macro invocation
    |
    = help: consider moving the enum out to a nearby module scope
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `expand_to_enum` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: struct is not supported in `trait`s or `impl`s
   --> $DIR/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs:31:5
@@ -36,7 +36,7 @@ LL |     expand_to_enum!();
    |     ------------------ in this macro invocation
    |
    = help: consider moving the enum out to a nearby module scope
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `expand_to_enum` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: struct is not supported in `extern` blocks
   --> $DIR/issue-48137-macros-cannot-interpolate-impl-items-bad-variants.rs:42:5
@@ -56,7 +56,7 @@ LL |     expand_to_enum!();
    |     ------------------ in this macro invocation
    |
    = help: consider moving the enum out to a nearby module scope
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `expand_to_enum` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 6 previous errors
 
index 16a08b9b85607cb582f410aded39dcac4dc4a275..8c032e588e31d8962ccc3df628f1349635451638 100644 (file)
@@ -8,7 +8,7 @@ LL |     mac1! { does_not_exist!() }
    |     --------------------------- in this macro invocation
    |
    = note: `mut` may be followed by `variable` and `variable @ pattern`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `mac1` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: expected identifier, found `does_not_exist!()`
   --> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:13:17
@@ -19,7 +19,7 @@ LL |         let mut $eval = ();
 LL |     mac2! { does_not_exist!() }
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `mac2` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `mut` must be followed by a named binding
   --> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:13:13
@@ -31,7 +31,7 @@ LL |     mac2! { does_not_exist!() }
    |     --------------------------- in this macro invocation
    |
    = note: `mut` may be followed by `variable` and `variable @ pattern`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `mac2` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: cannot find macro `does_not_exist` in this scope
   --> $DIR/issue-65122-mac-invoc-in-mut-patterns.rs:22:13
index 9b05383dd7de0e1443e2e5946c11513981791398..f83b7944b1ba181adbac974dd823a4765e4d1e26 100644 (file)
@@ -19,7 +19,7 @@ LL |         fn w<$lt>(w: &mut $lt i32) {}
 LL | mac!('a);
    | --------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0423]: expected value, found trait `Send`
   --> $DIR/issue-73568-lifetime-after-mut.rs:19:28
index 4f5e8f78aa0cdcb5bd400a23ce34f0b159901306..50995895bc8fe09bb40a46357d0a83365ad113e1 100644 (file)
@@ -70,7 +70,7 @@ LL |             'l5 $b;
 LL |     m!({});
    |     ------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: labeled expression must be followed by `:`
   --> $DIR/labeled-no-colon-expr.rs:16:8
index 20ee9d35ec7e1b6f24216047cebdfb9740f03597..f9f53e65d7bf0dd1b2ab4e64767d7cea22498431 100644 (file)
@@ -7,7 +7,7 @@ LL |             $( $t, )*
 LL |     test_macro!(String,);
    |     --------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `test_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 2db0f848f75f18b71f5e97b49778b071b532a9f9..f0ec79e53574a1ad5939ee8647d71ad61c02d5c7 100644 (file)
@@ -7,7 +7,7 @@ LL |         let x = 5 "";
 LL |     failed!();
    |     ---------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `failed` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index c9d220b1a274318ad514c645dac4f392429f9a71..186b22dce9a585b1fe101b96ebacd1ca3f3a7046 100644 (file)
@@ -18,7 +18,7 @@ LL |     () => ( 1,
 LL |     ignored_expr!();
    |     ---------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `ignored_expr` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: macro expansion ignores token `,` and any following
   --> $DIR/macro-incomplete-parse.rs:16:14
index 1c5613ac986c438f1f71f4affa08790700fb63b6..0b81d2074b6f1d1f6c13ca0e8e1676330ed1c01f 100644 (file)
@@ -8,7 +8,7 @@ LL |     pub_x!();
    |     --------- in this macro invocation
    |
    = help: try adjusting the macro to put `pub` inside the invocation
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `pub_x` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0603]: static `x` is private
   --> $DIR/pub-item-macro.rs:20:23
@@ -24,7 +24,7 @@ LL |         static x: u32 = 0;
 ...
 LL |     pub_x!();
    |     --------- in this macro invocation
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_x` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index ae53334f5e02a439e90ad8e78af4404e83b8828d..93403372bcb914dea61a7092ad79a606b76b0737 100644 (file)
@@ -32,7 +32,7 @@ LL |   let v : Vec<(u32,_) = vec![];
    |       |
    |       consider giving `v` the explicit type `Vec<T>`, where the type parameter `T` is specified
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0282]: type annotations needed for `Vec<T>`
   --> $DIR/missing-closing-angle-bracket-eq-constraint.rs:18:20
@@ -42,7 +42,7 @@ LL |   let v : Vec<'a = vec![];
    |       |
    |       consider giving `v` the explicit type `Vec<T>`, where the type parameter `T` is specified
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 5 previous errors
 
index 26cb3d13d9c481a047ec82fa7daaf70f406aff92..68f0f440c46b923585394963b72c45c9cdb208eb 100644 (file)
@@ -7,7 +7,7 @@ LL |         $( let x = $e1 )*;
 LL | fn main() { m!(0, 0; 0, 0); }
    |             --------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 9a6af7394bf4a41a71e5ba2ca400ca81ddcf0702..88a77adcd31cdc02013f18bdd667c7a832b59f2c 100644 (file)
@@ -108,7 +108,7 @@ LL |             let mut $p = 0;
 LL |     foo!(x);
    |     -------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 13 previous errors
 
index 45f6b111e259cb03642bec49b5ab1a26cdd75b44..3236ef0db2837d11494abf7943f5e52ec4e877d8 100644 (file)
@@ -167,7 +167,7 @@ LL |             let ...$e;
 LL |     mac!(0);
    |     -------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0586]: inclusive range with no end
   --> $DIR/recover-range-pats.rs:154:19
@@ -179,7 +179,7 @@ LL |     mac!(0);
    |     -------- in this macro invocation
    |
    = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0586]: inclusive range with no end
   --> $DIR/recover-range-pats.rs:155:19
@@ -191,7 +191,7 @@ LL |     mac!(0);
    |     -------- in this macro invocation
    |
    = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`)
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `...` range patterns are deprecated
   --> $DIR/recover-range-pats.rs:42:13
@@ -281,7 +281,7 @@ LL |     mac2!(0, 1);
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2021 edition!
    = note: for more information, see issue #80165 <https://github.com/rust-lang/rust/issues/80165>
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `mac2` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0029]: only `char` and numeric types are allowed in range patterns
   --> $DIR/recover-range-pats.rs:20:12
diff --git a/src/test/ui/parser/struct-default-values-and-missing-field-separator.fixed b/src/test/ui/parser/struct-default-values-and-missing-field-separator.fixed
new file mode 100644 (file)
index 0000000..28191b8
--- /dev/null
@@ -0,0 +1,35 @@
+// run-rustfix
+#![allow(dead_code)]
+
+enum E {
+    A,
+}
+
+struct S {
+    field1: i32, //~ ERROR default values on `struct` fields aren't supported
+    field2: E, //~ ERROR default values on `struct` fields aren't supported
+    field3: i32, //~ ERROR default values on `struct` fields aren't supported
+    field4: i32, //~ ERROR default values on `struct` fields aren't supported
+    field5: E, //~ ERROR default values on `struct` fields aren't supported
+    field6: E, //~ ERROR default values on `struct` fields aren't supported
+}
+
+struct S1 {
+    field1: i32, //~ ERROR expected `,`, or `}`, found `field2`
+    field2: E, //~ ERROR expected `,`, or `}`, found `field3`
+    field3: i32, //~ ERROR default values on `struct` fields aren't supported
+    field4: i32, //~ ERROR default values on `struct` fields aren't supported
+    field5: E, //~ ERROR default values on `struct` fields aren't supported
+    field6: E, //~ ERROR default values on `struct` fields aren't supported
+}
+
+struct S2 {
+    field1 : i32, //~ ERROR expected `:`, found `=`
+    field2: E, //~ ERROR expected `:`, found `;`
+}
+
+const fn foo(_: i32) -> E {
+    E::A
+}
+
+fn main() {}
diff --git a/src/test/ui/parser/struct-default-values-and-missing-field-separator.rs b/src/test/ui/parser/struct-default-values-and-missing-field-separator.rs
new file mode 100644 (file)
index 0000000..924cb08
--- /dev/null
@@ -0,0 +1,35 @@
+// run-rustfix
+#![allow(dead_code)]
+
+enum E {
+    A,
+}
+
+struct S {
+    field1: i32 = 42, //~ ERROR default values on `struct` fields aren't supported
+    field2: E = E::A, //~ ERROR default values on `struct` fields aren't supported
+    field3: i32 = 1 + 2, //~ ERROR default values on `struct` fields aren't supported
+    field4: i32 = { 1 + 2 }, //~ ERROR default values on `struct` fields aren't supported
+    field5: E = foo(42), //~ ERROR default values on `struct` fields aren't supported
+    field6: E = { foo(42) }, //~ ERROR default values on `struct` fields aren't supported
+}
+
+struct S1 {
+    field1: i32 //~ ERROR expected `,`, or `}`, found `field2`
+    field2: E //~ ERROR expected `,`, or `}`, found `field3`
+    field3: i32 = 1 + 2, //~ ERROR default values on `struct` fields aren't supported
+    field4: i32 = { 1 + 2 }, //~ ERROR default values on `struct` fields aren't supported
+    field5: E = foo(42), //~ ERROR default values on `struct` fields aren't supported
+    field6: E = { foo(42) }, //~ ERROR default values on `struct` fields aren't supported
+}
+
+struct S2 {
+    field1 = i32, //~ ERROR expected `:`, found `=`
+    field2; E, //~ ERROR expected `:`, found `;`
+}
+
+const fn foo(_: i32) -> E {
+    E::A
+}
+
+fn main() {}
diff --git a/src/test/ui/parser/struct-default-values-and-missing-field-separator.stderr b/src/test/ui/parser/struct-default-values-and-missing-field-separator.stderr
new file mode 100644 (file)
index 0000000..7f16ebc
--- /dev/null
@@ -0,0 +1,92 @@
+error: default values on `struct` fields aren't supported
+  --> $DIR/struct-default-values-and-missing-field-separator.rs:9:16
+   |
+LL |     field1: i32 = 42,
+   |                ^^^^^ help: remove this unsupported default value
+
+error: default values on `struct` fields aren't supported
+  --> $DIR/struct-default-values-and-missing-field-separator.rs:10:14
+   |
+LL |     field2: E = E::A,
+   |              ^^^^^^^ help: remove this unsupported default value
+
+error: default values on `struct` fields aren't supported
+  --> $DIR/struct-default-values-and-missing-field-separator.rs:11:16
+   |
+LL |     field3: i32 = 1 + 2,
+   |                ^^^^^^^^ help: remove this unsupported default value
+
+error: default values on `struct` fields aren't supported
+  --> $DIR/struct-default-values-and-missing-field-separator.rs:12:16
+   |
+LL |     field4: i32 = { 1 + 2 },
+   |                ^^^^^^^^^^^^ help: remove this unsupported default value
+
+error: default values on `struct` fields aren't supported
+  --> $DIR/struct-default-values-and-missing-field-separator.rs:13:14
+   |
+LL |     field5: E = foo(42),
+   |              ^^^^^^^^^^ help: remove this unsupported default value
+
+error: default values on `struct` fields aren't supported
+  --> $DIR/struct-default-values-and-missing-field-separator.rs:14:14
+   |
+LL |     field6: E = { foo(42) },
+   |              ^^^^^^^^^^^^^^ help: remove this unsupported default value
+
+error: expected `,`, or `}`, found `field2`
+  --> $DIR/struct-default-values-and-missing-field-separator.rs:18:16
+   |
+LL |     field1: i32
+   |                ^ help: try adding a comma: `,`
+
+error: expected `,`, or `}`, found `field3`
+  --> $DIR/struct-default-values-and-missing-field-separator.rs:19:14
+   |
+LL |     field2: E
+   |              ^ help: try adding a comma: `,`
+
+error: default values on `struct` fields aren't supported
+  --> $DIR/struct-default-values-and-missing-field-separator.rs:20:16
+   |
+LL |     field3: i32 = 1 + 2,
+   |                ^^^^^^^^ help: remove this unsupported default value
+
+error: default values on `struct` fields aren't supported
+  --> $DIR/struct-default-values-and-missing-field-separator.rs:21:16
+   |
+LL |     field4: i32 = { 1 + 2 },
+   |                ^^^^^^^^^^^^ help: remove this unsupported default value
+
+error: default values on `struct` fields aren't supported
+  --> $DIR/struct-default-values-and-missing-field-separator.rs:22:14
+   |
+LL |     field5: E = foo(42),
+   |              ^^^^^^^^^^ help: remove this unsupported default value
+
+error: default values on `struct` fields aren't supported
+  --> $DIR/struct-default-values-and-missing-field-separator.rs:23:14
+   |
+LL |     field6: E = { foo(42) },
+   |              ^^^^^^^^^^^^^^ help: remove this unsupported default value
+
+error: expected `:`, found `=`
+  --> $DIR/struct-default-values-and-missing-field-separator.rs:27:12
+   |
+LL |     field1 = i32,
+   |            ^
+   |            |
+   |            expected `:`
+   |            help: field names and their types are separated with `:`
+
+error: expected `:`, found `;`
+  --> $DIR/struct-default-values-and-missing-field-separator.rs:28:11
+   |
+LL |     field2; E,
+   |           ^
+   |           |
+   |           expected `:`
+   |           help: field names and their types are separated with `:`
+
+error: aborting due to 14 previous errors
+
index 95f6d53a9d40df1863e3cdefb67af1d41c5f3187..06b6e80b44f7aca098b99fe304306199f019690b 100644 (file)
@@ -8,7 +8,7 @@ LL |     let mk_pat!();
    |         --------- in this macro invocation
    |
    = note: only allowed in tuple, tuple struct, and slice patterns
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `mk_pat` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `..` patterns are not allowed here
   --> $DIR/rest-pat-semantic-disallowed.rs:18:9
index f8585014fd6d827edb82cbd4fed06671b8baef54..08b282e1870deb64349e0240a41a28a72af950c7 100644 (file)
@@ -7,7 +7,7 @@ LL |         let value = Pub::method;
 LL |     priv_nominal::mac!();
    |     --------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_nominal::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private
   --> $DIR/associated-item-privacy-inherent.rs:15:9
@@ -18,7 +18,7 @@ LL |         value;
 LL |     priv_nominal::mac!();
    |     --------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_nominal::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `for<'r> fn(&'r priv_nominal::Pub) {priv_nominal::Pub::method}` is private
   --> $DIR/associated-item-privacy-inherent.rs:17:13
@@ -29,7 +29,7 @@ LL |         Pub.method();
 LL |     priv_nominal::mac!();
    |     --------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_nominal::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: associated constant `CONST` is private
   --> $DIR/associated-item-privacy-inherent.rs:19:9
@@ -40,7 +40,7 @@ LL |         Pub::CONST;
 LL |     priv_nominal::mac!();
    |     --------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_nominal::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_signature::Priv` is private
   --> $DIR/associated-item-privacy-inherent.rs:37:21
@@ -51,7 +51,7 @@ LL |         let value = Pub::method;
 LL |     priv_signature::mac!();
    |     ----------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_signature::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_signature::Priv` is private
   --> $DIR/associated-item-privacy-inherent.rs:39:9
@@ -62,7 +62,7 @@ LL |         value;
 LL |     priv_signature::mac!();
    |     ----------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_signature::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_signature::Priv` is private
   --> $DIR/associated-item-privacy-inherent.rs:41:13
@@ -73,7 +73,7 @@ LL |         Pub.method(loop {});
 LL |     priv_signature::mac!();
    |     ----------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_signature::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_substs::Priv` is private
   --> $DIR/associated-item-privacy-inherent.rs:57:21
@@ -84,7 +84,7 @@ LL |         let value = Pub::method::<Priv>;
 LL |     priv_substs::mac!();
    |     -------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_substs::Priv` is private
   --> $DIR/associated-item-privacy-inherent.rs:59:9
@@ -95,7 +95,7 @@ LL |         value;
 LL |     priv_substs::mac!();
    |     -------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_substs::Priv` is private
   --> $DIR/associated-item-privacy-inherent.rs:61:9
@@ -106,7 +106,7 @@ LL |         Pub.method::<Priv>();
 LL |     priv_substs::mac!();
    |     -------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
   --> $DIR/associated-item-privacy-inherent.rs:80:21
@@ -117,7 +117,7 @@ LL |         let value = <Pub>::method;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
   --> $DIR/associated-item-privacy-inherent.rs:82:9
@@ -128,7 +128,7 @@ LL |         value;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
   --> $DIR/associated-item-privacy-inherent.rs:84:21
@@ -139,7 +139,7 @@ LL |         let value = Pub::method;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
   --> $DIR/associated-item-privacy-inherent.rs:86:9
@@ -150,7 +150,7 @@ LL |         value;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
   --> $DIR/associated-item-privacy-inherent.rs:88:21
@@ -161,7 +161,7 @@ LL |         let value = <Pub>::static_method;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
   --> $DIR/associated-item-privacy-inherent.rs:90:9
@@ -172,7 +172,7 @@ LL |         value;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
   --> $DIR/associated-item-privacy-inherent.rs:92:21
@@ -183,7 +183,7 @@ LL |         let value = Pub::static_method;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
   --> $DIR/associated-item-privacy-inherent.rs:94:9
@@ -194,7 +194,7 @@ LL |         value;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
   --> $DIR/associated-item-privacy-inherent.rs:96:19
@@ -205,7 +205,7 @@ LL |         Pub(Priv).method();
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
   --> $DIR/associated-item-privacy-inherent.rs:99:10
@@ -216,7 +216,7 @@ LL |         <Pub>::CONST;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
   --> $DIR/associated-item-privacy-inherent.rs:101:9
@@ -227,7 +227,7 @@ LL |         Pub::CONST;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 21 previous errors
 
index e36ce8d541500c5e041ec034f73354ae01042075..3a42415e4746c9d3347f99cd49fd4596fb24c212 100644 (file)
@@ -7,7 +7,7 @@ LL |         let value = <Pub as PrivTr>::method;
 LL |     priv_trait::mac!();
    |     ------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_trait::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `for<'r> fn(&'r priv_trait::Pub) {<priv_trait::Pub as PrivTr>::method}` is private
   --> $DIR/associated-item-privacy-trait.rs:17:9
@@ -18,7 +18,7 @@ LL |         value;
 LL |     priv_trait::mac!();
    |     ------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_trait::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `for<'r> fn(&'r Self) {<Self as PrivTr>::method}` is private
   --> $DIR/associated-item-privacy-trait.rs:19:13
@@ -29,7 +29,7 @@ LL |         Pub.method();
 LL |     priv_trait::mac!();
    |     ------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_trait::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: associated constant `<Pub as PrivTr>::CONST` is private
   --> $DIR/associated-item-privacy-trait.rs:21:9
@@ -40,7 +40,7 @@ LL |         <Pub as PrivTr>::CONST;
 LL |     priv_trait::mac!();
    |     ------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_trait::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: associated type `<Pub as PrivTr>::AssocTy` is private
   --> $DIR/associated-item-privacy-trait.rs:23:16
@@ -51,7 +51,7 @@ LL |         let _: <Pub as PrivTr>::AssocTy;
 LL |     priv_trait::mac!();
    |     ------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_trait::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: trait `PrivTr` is private
   --> $DIR/associated-item-privacy-trait.rs:25:34
@@ -62,7 +62,7 @@ LL |         pub type InSignatureTy = <Pub as PrivTr>::AssocTy;
 LL |     priv_trait::mac!();
    |     ------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_trait::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: trait `PrivTr` is private
   --> $DIR/associated-item-privacy-trait.rs:27:34
@@ -73,7 +73,7 @@ LL |         pub trait InSignatureTr: PrivTr {}
 LL |     priv_trait::mac!();
    |     ------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_trait::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: trait `PrivTr` is private
   --> $DIR/associated-item-privacy-trait.rs:29:14
@@ -84,7 +84,7 @@ LL |         impl PrivTr for u8 {}
 LL |     priv_trait::mac!();
    |     ------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_trait::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_signature::Priv` is private
   --> $DIR/associated-item-privacy-trait.rs:46:21
@@ -95,7 +95,7 @@ LL |         let value = <Pub as PubTr>::method;
 LL |     priv_signature::mac!();
    |     ----------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_signature::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_signature::Priv` is private
   --> $DIR/associated-item-privacy-trait.rs:48:9
@@ -106,7 +106,7 @@ LL |         value;
 LL |     priv_signature::mac!();
    |     ----------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_signature::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_signature::Priv` is private
   --> $DIR/associated-item-privacy-trait.rs:50:13
@@ -117,7 +117,7 @@ LL |         Pub.method(loop {});
 LL |     priv_signature::mac!();
    |     ----------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_signature::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_substs::Priv` is private
   --> $DIR/associated-item-privacy-trait.rs:67:21
@@ -128,7 +128,7 @@ LL |         let value = <Pub as PubTr>::method::<Priv>;
 LL |     priv_substs::mac!();
    |     -------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_substs::Priv` is private
   --> $DIR/associated-item-privacy-trait.rs:69:9
@@ -139,7 +139,7 @@ LL |         value;
 LL |     priv_substs::mac!();
    |     -------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_substs::Priv` is private
   --> $DIR/associated-item-privacy-trait.rs:71:9
@@ -150,7 +150,7 @@ LL |         Pub.method::<Priv>();
 LL |     priv_substs::mac!();
    |     -------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
   --> $DIR/associated-item-privacy-trait.rs:91:21
@@ -161,7 +161,7 @@ LL |         let value = <Pub as PubTr>::method;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
   --> $DIR/associated-item-privacy-trait.rs:93:9
@@ -172,7 +172,7 @@ LL |         value;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
   --> $DIR/associated-item-privacy-trait.rs:95:21
@@ -183,7 +183,7 @@ LL |         let value = <Pub as PubTr<_>>::method;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
   --> $DIR/associated-item-privacy-trait.rs:97:9
@@ -194,7 +194,7 @@ LL |         value;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
   --> $DIR/associated-item-privacy-trait.rs:99:9
@@ -205,7 +205,7 @@ LL |         Pub.method();
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
   --> $DIR/associated-item-privacy-trait.rs:102:21
@@ -216,7 +216,7 @@ LL |         let value = <Priv as PubTr<_>>::method;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
   --> $DIR/associated-item-privacy-trait.rs:104:9
@@ -227,7 +227,7 @@ LL |         value;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
   --> $DIR/associated-item-privacy-trait.rs:106:9
@@ -238,7 +238,7 @@ LL |         Priv.method();
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
   --> $DIR/associated-item-privacy-trait.rs:109:9
@@ -249,7 +249,7 @@ LL |         <Pub as PubTr>::CONST;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
   --> $DIR/associated-item-privacy-trait.rs:111:9
@@ -260,7 +260,7 @@ LL |         <Pub as PubTr<_>>::CONST;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
   --> $DIR/associated-item-privacy-trait.rs:113:9
@@ -271,7 +271,7 @@ LL |         <Priv as PubTr<_>>::CONST;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
   --> $DIR/associated-item-privacy-trait.rs:117:30
@@ -282,7 +282,7 @@ LL |         let _: <Pub as PubTr<_>>::AssocTy;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
   --> $DIR/associated-item-privacy-trait.rs:119:17
@@ -293,7 +293,7 @@ LL |         let _: <Priv as PubTr<_>>::AssocTy;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
   --> $DIR/associated-item-privacy-trait.rs:122:35
@@ -304,7 +304,7 @@ LL |         pub type InSignatureTy1 = <Pub as PubTr>::AssocTy;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
   --> $DIR/associated-item-privacy-trait.rs:124:35
@@ -315,7 +315,7 @@ LL |         pub type InSignatureTy2 = <Priv as PubTr<Pub>>::AssocTy;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `priv_parent_substs::Priv` is private
   --> $DIR/associated-item-privacy-trait.rs:126:14
@@ -326,7 +326,7 @@ LL |         impl PubTr for u8 {}
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 30 previous errors
 
index 5df2dfb871b371d2986827fd4ba2da37c90c91d8..c275413b4501a3eaaede1cba26ace872ef0cda01 100644 (file)
@@ -7,7 +7,7 @@ LL |         let _: Box<dyn PubTr<AssocTy = u8>>;
 LL |     priv_trait::mac1!();
    |     -------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_trait::mac1` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: trait `PrivTr` is private
   --> $DIR/associated-item-privacy-type-binding.rs:11:16
@@ -18,7 +18,7 @@ LL |         let _: Box<dyn PubTr<AssocTy = u8>>;
 LL |     priv_trait::mac1!();
    |     -------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_trait::mac1` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: trait `PrivTr` is private
   --> $DIR/associated-item-privacy-type-binding.rs:14:31
@@ -29,7 +29,7 @@ LL |         type InSignatureTy2 = Box<dyn PubTr<AssocTy = u8>>;
 LL |     priv_trait::mac1!();
    |     -------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_trait::mac1` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: trait `PrivTr` is private
   --> $DIR/associated-item-privacy-type-binding.rs:16:31
@@ -40,7 +40,7 @@ LL |         trait InSignatureTr2: PubTr<AssocTy = u8> {}
 LL |     priv_trait::mac1!();
    |     -------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_trait::mac1` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: trait `PrivTr` is private
   --> $DIR/associated-item-privacy-type-binding.rs:20:13
@@ -51,7 +51,7 @@ LL |         let _: Box<dyn PrivTr<AssocTy = u8>>;
 LL |     priv_trait::mac2!();
    |     -------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_trait::mac2` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: trait `PrivTr` is private
   --> $DIR/associated-item-privacy-type-binding.rs:20:16
@@ -62,7 +62,7 @@ LL |         let _: Box<dyn PrivTr<AssocTy = u8>>;
 LL |     priv_trait::mac2!();
    |     -------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_trait::mac2` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: trait `PrivTr` is private
   --> $DIR/associated-item-privacy-type-binding.rs:23:31
@@ -73,7 +73,7 @@ LL |         type InSignatureTy1 = Box<dyn PrivTr<AssocTy = u8>>;
 LL |     priv_trait::mac2!();
    |     -------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_trait::mac2` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: trait `PrivTr` is private
   --> $DIR/associated-item-privacy-type-binding.rs:25:31
@@ -84,7 +84,7 @@ LL |         trait InSignatureTr1: PrivTr<AssocTy = u8> {}
 LL |     priv_trait::mac2!();
    |     -------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_trait::mac2` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `Priv` is private
   --> $DIR/associated-item-privacy-type-binding.rs:44:13
@@ -95,7 +95,7 @@ LL |         let _: Box<dyn PubTrWithParam<AssocTy = u8>>;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `Priv` is private
   --> $DIR/associated-item-privacy-type-binding.rs:44:16
@@ -106,7 +106,7 @@ LL |         let _: Box<dyn PubTrWithParam<AssocTy = u8>>;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `Priv` is private
   --> $DIR/associated-item-privacy-type-binding.rs:47:13
@@ -117,7 +117,7 @@ LL |         let _: Box<dyn PubTr<AssocTy = u8>>;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `Priv` is private
   --> $DIR/associated-item-privacy-type-binding.rs:47:16
@@ -128,7 +128,7 @@ LL |         let _: Box<dyn PubTr<AssocTy = u8>>;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `Priv` is private
   --> $DIR/associated-item-privacy-type-binding.rs:50:35
@@ -139,7 +139,7 @@ LL |         pub type InSignatureTy1 = Box<dyn PubTrWithParam<AssocTy = u8>>;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `Priv` is private
   --> $DIR/associated-item-privacy-type-binding.rs:52:35
@@ -150,7 +150,7 @@ LL |         pub type InSignatureTy2 = Box<dyn PubTr<AssocTy = u8>>;
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `Priv` is private
   --> $DIR/associated-item-privacy-type-binding.rs:54:31
@@ -161,7 +161,7 @@ LL |         trait InSignatureTr1: PubTrWithParam<AssocTy = u8> {}
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `Priv` is private
   --> $DIR/associated-item-privacy-type-binding.rs:56:31
@@ -172,7 +172,7 @@ LL |         trait InSignatureTr2: PubTr<AssocTy = u8> {}
 LL |     priv_parent_substs::mac!();
    |     --------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `priv_parent_substs::mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 16 previous errors
 
index 165d932f083277a6f962eb286a2d1b672b05b019..3cd4b4d26c80935b51e5ce9e2536da8a29ea1689 100644 (file)
@@ -4,7 +4,7 @@ error: type `fn() {ext::priv_fn}` is private
 LL |     ext::m!();
    |     ^^^^^^^^^^ private type
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `ext::m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: static `PRIV_STATIC` is private
   --> $DIR/private-inferred-type-3.rs:16:5
@@ -12,7 +12,7 @@ error: static `PRIV_STATIC` is private
 LL |     ext::m!();
    |     ^^^^^^^^^^ private static
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `ext::m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `ext::PrivEnum` is private
   --> $DIR/private-inferred-type-3.rs:16:5
@@ -20,7 +20,7 @@ error: type `ext::PrivEnum` is private
 LL |     ext::m!();
    |     ^^^^^^^^^^ private type
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `ext::m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `fn() {<u8 as ext::PrivTrait>::method}` is private
   --> $DIR/private-inferred-type-3.rs:16:5
@@ -28,7 +28,7 @@ error: type `fn() {<u8 as ext::PrivTrait>::method}` is private
 LL |     ext::m!();
    |     ^^^^^^^^^^ private type
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `ext::m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `fn(u8) -> ext::PrivTupleStruct {ext::PrivTupleStruct}` is private
   --> $DIR/private-inferred-type-3.rs:16:5
@@ -36,7 +36,7 @@ error: type `fn(u8) -> ext::PrivTupleStruct {ext::PrivTupleStruct}` is private
 LL |     ext::m!();
    |     ^^^^^^^^^^ private type
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `ext::m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `fn(u8) -> PubTupleStruct {PubTupleStruct}` is private
   --> $DIR/private-inferred-type-3.rs:16:5
@@ -44,7 +44,7 @@ error: type `fn(u8) -> PubTupleStruct {PubTupleStruct}` is private
 LL |     ext::m!();
    |     ^^^^^^^^^^ private type
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `ext::m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `for<'r> fn(&'r Pub<u8>) {Pub::<u8>::priv_method}` is private
   --> $DIR/private-inferred-type-3.rs:16:5
@@ -52,7 +52,7 @@ error: type `for<'r> fn(&'r Pub<u8>) {Pub::<u8>::priv_method}` is private
 LL |     ext::m!();
    |     ^^^^^^^^^^ private type
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `ext::m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 7 previous errors
 
index 11bcb9074d09707ce3675f3ac3340c331edd70a6..c6bdb898f966d3115320229315d06aeecbdf8673 100644 (file)
@@ -115,7 +115,7 @@ LL |         priv_fn;
 LL |     m::m!();
    |     -------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m::m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `PrivEnum` is private
   --> $DIR/private-inferred-type.rs:41:9
@@ -126,7 +126,7 @@ LL |         PrivEnum::Variant;
 LL |     m::m!();
    |     -------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m::m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `fn() {<u8 as PrivTrait>::method}` is private
   --> $DIR/private-inferred-type.rs:43:9
@@ -137,7 +137,7 @@ LL |         <u8 as PrivTrait>::method;
 LL |     m::m!();
    |     -------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m::m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `fn(u8) -> PrivTupleStruct {PrivTupleStruct}` is private
   --> $DIR/private-inferred-type.rs:45:9
@@ -148,7 +148,7 @@ LL |         PrivTupleStruct;
 LL |     m::m!();
    |     -------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m::m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `fn(u8) -> PubTupleStruct {PubTupleStruct}` is private
   --> $DIR/private-inferred-type.rs:47:9
@@ -159,7 +159,7 @@ LL |         PubTupleStruct;
 LL |     m::m!();
    |     -------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m::m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: type `for<'r> fn(&'r Pub<u8>) {Pub::<u8>::priv_method}` is private
   --> $DIR/private-inferred-type.rs:49:18
@@ -170,7 +170,7 @@ LL |         Pub(0u8).priv_method();
 LL |     m::m!();
    |     -------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m::m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: trait `Trait` is private
   --> $DIR/private-inferred-type.rs:118:5
diff --git a/src/test/ui/proc-macro/auxiliary/custom-quote.rs b/src/test/ui/proc-macro/auxiliary/custom-quote.rs
new file mode 100644 (file)
index 0000000..714417d
--- /dev/null
@@ -0,0 +1,31 @@
+// force-host
+// no-prefer-dynamic
+// ignore-tidy-linelength
+
+#![feature(proc_macro_quote)]
+#![crate_type = "proc-macro"]
+
+extern crate proc_macro;
+use std::str::FromStr;
+use proc_macro::*;
+
+#[proc_macro]
+pub fn custom_quote(input: TokenStream) -> TokenStream {
+    let mut tokens: Vec<_> = input.into_iter().collect();
+    assert_eq!(tokens.len(), 1, "Unexpected input: {:?}", tokens);
+    match tokens.pop() {
+        Some(TokenTree::Ident(ident)) => {
+            assert_eq!(ident.to_string(), "my_ident");
+
+            let proc_macro_crate = TokenStream::from_str("::proc_macro").unwrap();
+            let quoted_span = proc_macro::quote_span(proc_macro_crate, ident.span());
+            let prefix = TokenStream::from_str(r#"let mut ident = proc_macro::Ident::new("my_ident", proc_macro::Span::call_site());"#).unwrap();
+            let set_span_method = TokenStream::from_str("ident.set_span").unwrap();
+            let set_span_arg = TokenStream::from(TokenTree::Group(Group::new(Delimiter::Parenthesis, quoted_span)));
+            let suffix = TokenStream::from_str(";proc_macro::TokenStream::from(proc_macro::TokenTree::Ident(ident))").unwrap();
+            let full_stream: TokenStream = std::array::IntoIter::new([prefix, set_span_method, set_span_arg, suffix]).collect();
+            full_stream
+        }
+        _ => unreachable!()
+    }
+}
diff --git a/src/test/ui/proc-macro/auxiliary/span-from-proc-macro.rs b/src/test/ui/proc-macro/auxiliary/span-from-proc-macro.rs
new file mode 100644 (file)
index 0000000..49292ac
--- /dev/null
@@ -0,0 +1,49 @@
+// force-host
+// no-prefer-dynamic
+
+#![feature(proc_macro_quote)]
+#![feature(proc_macro_internals)] // FIXME - this shouldn't be necessary
+#![crate_type = "proc-macro"]
+
+extern crate proc_macro;
+extern crate custom_quote;
+
+use proc_macro::{quote, TokenStream};
+
+macro_rules! expand_to_quote {
+    () => {
+        quote! {
+            let bang_error: bool = 25;
+        }
+    }
+}
+
+#[proc_macro]
+pub fn error_from_bang(_input: TokenStream) -> TokenStream {
+    expand_to_quote!()
+}
+
+#[proc_macro]
+pub fn other_error_from_bang(_input: TokenStream) -> TokenStream {
+    custom_quote::custom_quote! {
+        my_ident
+    }
+}
+
+#[proc_macro_attribute]
+pub fn error_from_attribute(_args: TokenStream, _input: TokenStream) -> TokenStream {
+    quote! {
+        struct AttributeError {
+            field: MissingType
+        }
+    }
+}
+
+#[proc_macro_derive(ErrorFromDerive)]
+pub fn error_from_derive(_input: TokenStream) -> TokenStream {
+    quote! {
+        enum DeriveError {
+            Variant(OtherMissingType)
+        }
+    }
+}
index bc5ed9815238adf026d3e4d5130641585feda6f4..ae48141fb313340bafd4c40f12317aba6da7761c 100644 (file)
@@ -4,7 +4,7 @@ error: expected `:`, found `}`
 LL | #[derive(A)]
    |          ^ expected `:`
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `A` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: proc-macro derive produced unparseable tokens
   --> $DIR/derive-bad.rs:6:10
index a49df9f2d4a33affb09086ded90b5242cb3e2288..4115fec86fbc84ca4ef0a155154fee2f551e1174 100644 (file)
@@ -16,7 +16,7 @@ error: cannot find attribute `empty_helper` in this scope
 LL |             #[derive(GenHelperUse)]
    |                      ^^^^^^^^^^^^
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `GenHelperUse` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: cannot find attribute `empty_helper` in this scope
   --> $DIR/derive-helper-shadowing.rs:14:11
@@ -27,7 +27,7 @@ LL |         #[empty_helper]
 LL |             gen_helper_use!();
    |             ------------------ in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `gen_helper_use` (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
index 5974fa4c554ca33974d48832bfbe3a991e610de6..8b16ffb76f26fc1e419cba16fad42760f5ddc5ae 100644 (file)
@@ -4,7 +4,7 @@ error: attributes starting with `rustc` are reserved for use by the `rustc` comp
 LL | #[derive(Unstable)]
    |          ^^^^^^^^
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Unstable` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index fdbf80f9b33ac45427186f30a28b80207f15c8b5..b27dcd7e6cdba7134f25cbf04bd7493fd52883ba 100644 (file)
@@ -5,7 +5,7 @@ LL | #[derive(Unstable)]
    |          ^^^^^^^^
    |
    = help: add `#![feature(core_intrinsics)]` to the crate attributes to enable
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Unstable` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index b65fc739e09cb7c83f735b53f20b9ca440b5a66c..b16b24b9dc673fafcaa3463debb621caf097cae3 100644 (file)
@@ -7,7 +7,7 @@ LL | gen_macro_rules!();
 LL |         generated!();
    |         ------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `generated` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0425]: cannot find value `local_use` in this scope
   --> $DIR/gen-macro-rules-hygiene.rs:12:1
@@ -18,7 +18,7 @@ LL | gen_macro_rules!();
 LL |         generated!();
    |         ------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `generated` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0425]: cannot find value `local_def` in this scope
   --> $DIR/gen-macro-rules-hygiene.rs:21:9
index 5a4ed65ecdc8fe265a2487bc69e2e0ef2ec208c8..285876aadb2932dec176b5ad8f3243adf277ea76 100644 (file)
@@ -6,7 +6,7 @@ LL | generate_mod::check!();
    |
    = note: consider importing this struct:
            FromOutside
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `generate_mod::check` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0412]: cannot find type `Outer` in this scope
   --> $DIR/generate-mod.rs:9:1
@@ -16,7 +16,7 @@ LL | generate_mod::check!();
    |
    = note: consider importing this struct:
            Outer
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `generate_mod::check` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0412]: cannot find type `FromOutside` in this scope
   --> $DIR/generate-mod.rs:12:1
@@ -26,7 +26,7 @@ LL | #[generate_mod::check_attr]
    |
    = note: consider importing this struct:
            FromOutside
-   = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the attribute macro `generate_mod::check_attr` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0412]: cannot find type `OuterAttr` in this scope
   --> $DIR/generate-mod.rs:12:1
@@ -36,7 +36,7 @@ LL | #[generate_mod::check_attr]
    |
    = note: consider importing this struct:
            OuterAttr
-   = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the attribute macro `generate_mod::check_attr` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: cannot find type `FromOutside` in this scope
   --> $DIR/generate-mod.rs:16:10
@@ -47,7 +47,7 @@ LL | #[derive(generate_mod::CheckDerive)]
    = note: `#[warn(proc_macro_derive_resolution_fallback)]` 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 #83583 <https://github.com/rust-lang/rust/issues/83583>
-   = note: this warning originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: cannot find type `OuterDerive` in this scope
   --> $DIR/generate-mod.rs:16:10
@@ -57,7 +57,7 @@ LL | #[derive(generate_mod::CheckDerive)]
    |
    = 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 #83583 <https://github.com/rust-lang/rust/issues/83583>
-   = note: this warning originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: cannot find type `FromOutside` in this scope
   --> $DIR/generate-mod.rs:23:14
@@ -67,7 +67,7 @@ LL |     #[derive(generate_mod::CheckDerive)]
    |
    = 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 #83583 <https://github.com/rust-lang/rust/issues/83583>
-   = note: this warning originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: cannot find type `OuterDerive` in this scope
   --> $DIR/generate-mod.rs:23:14
@@ -77,7 +77,7 @@ LL |     #[derive(generate_mod::CheckDerive)]
    |
    = 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 #83583 <https://github.com/rust-lang/rust/issues/83583>
-   = note: this warning originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 4 previous errors; 4 warnings emitted
 
index effcd68cf967c9fe331b3d9fb3cf3b029b8ebe92..e764480e8e548b881f8fa0ba37aee390933d65be 100644 (file)
@@ -13,7 +13,7 @@ LL |     impl_macros!(Foo);
    = 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 #83125 <https://github.com/rust-lang/rust/issues/83125>
    = note: the `time-macros-impl` crate will stop compiling in futures version of Rust. Please update to the latest version of the `time` crate to avoid breakage
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `impl_macros` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: using an old version of `time-macros-impl`
   --> $DIR/time-macros-impl-0.1.0/src/lib.rs:5:32
@@ -29,7 +29,7 @@ LL |     impl_macros!(Foo);
    = 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 #83125 <https://github.com/rust-lang/rust/issues/83125>
    = note: the `time-macros-impl` crate will stop compiling in futures version of Rust. Please update to the latest version of the `time` crate to avoid breakage
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `impl_macros` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: using an old version of `js-sys`
   --> $DIR/js-sys-0.3.17/src/lib.rs:5:32
@@ -45,7 +45,7 @@ LL |     arrays!(Foo);
    = 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 #83125 <https://github.com/rust-lang/rust/issues/83125>
    = note: older versions of the `js-sys` crate will stop compiling in future versions of Rust; please update to `js-sys` v0.3.40 or above
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `arrays` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: using an old version of `actix-web`
   --> $DIR/actix-web/src/extract.rs:5:34
@@ -61,7 +61,7 @@ LL |     tuple_from_req!(Foo);
    = 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 #83125 <https://github.com/rust-lang/rust/issues/83125>
    = note: the version of `actix-web` you are using might stop compiling in future versions of Rust; please update to the latest version of the `actix-web` crate to avoid breakage
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `tuple_from_req` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: using an old version of `actix-web`
   --> $DIR/actix-web-2.0.0/src/extract.rs:5:34
@@ -77,7 +77,7 @@ LL |     tuple_from_req!(Foo);
    = 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 #83125 <https://github.com/rust-lang/rust/issues/83125>
    = note: the version of `actix-web` you are using might stop compiling in future versions of Rust; please update to the latest version of the `actix-web` crate to avoid breakage
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `tuple_from_req` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: 5 warnings emitted
 
@@ -97,7 +97,7 @@ LL |     impl_macros!(Foo);
    = 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 #83125 <https://github.com/rust-lang/rust/issues/83125>
    = note: the `time-macros-impl` crate will stop compiling in futures version of Rust. Please update to the latest version of the `time` crate to avoid breakage
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `impl_macros` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 Future breakage date: None, diagnostic:
 warning: using an old version of `time-macros-impl`
@@ -114,7 +114,7 @@ LL |     impl_macros!(Foo);
    = 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 #83125 <https://github.com/rust-lang/rust/issues/83125>
    = note: the `time-macros-impl` crate will stop compiling in futures version of Rust. Please update to the latest version of the `time` crate to avoid breakage
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `impl_macros` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 Future breakage date: None, diagnostic:
 warning: using an old version of `js-sys`
@@ -131,7 +131,7 @@ LL |     arrays!(Foo);
    = 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 #83125 <https://github.com/rust-lang/rust/issues/83125>
    = note: older versions of the `js-sys` crate will stop compiling in future versions of Rust; please update to `js-sys` v0.3.40 or above
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `arrays` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 Future breakage date: None, diagnostic:
 warning: using an old version of `actix-web`
@@ -148,7 +148,7 @@ LL |     tuple_from_req!(Foo);
    = 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 #83125 <https://github.com/rust-lang/rust/issues/83125>
    = note: the version of `actix-web` you are using might stop compiling in future versions of Rust; please update to the latest version of the `actix-web` crate to avoid breakage
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `tuple_from_req` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 Future breakage date: None, diagnostic:
 warning: using an old version of `actix-web`
@@ -165,5 +165,5 @@ LL |     tuple_from_req!(Foo);
    = 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 #83125 <https://github.com/rust-lang/rust/issues/83125>
    = note: the version of `actix-web` you are using might stop compiling in future versions of Rust; please update to the latest version of the `actix-web` crate to avoid breakage
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `tuple_from_req` (in Nightly builds, run with -Z macro-backtrace for more info)
 
index 3b357aecea864d685397256279ec1cb31f317979..59cf767c559599f75c0ca47128df9a4408f2d8b4 100644 (file)
@@ -4,7 +4,7 @@ error: unexpected closing delimiter: `)`
 LL | lexer_failure!();
    | ^^^^^^^^^^^^^^^^^ unexpected closing delimiter
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `lexer_failure` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: proc macro panicked
   --> $DIR/invalid-punct-ident-4.rs:6:1
index 4cdca5c8e01b095bcb833d76bb266be7930402ac..ddd0a0874dd3e17eca93713a18a4786efb2a20d0 100644 (file)
@@ -4,7 +4,7 @@ error[E0425]: cannot find value `foo` in this scope
 LL | #[derive(A)]
    |          ^ not found in this scope
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `A` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 579041c52598f0d39d2f89541d71c50b505237d4..126c52db548f7db96dad562bd76a6b6bd8c964d9 100644 (file)
@@ -4,7 +4,7 @@ error: expected crate top-level item to be a module after macro expansion, found
 LL | #![issue_59191::no_main]
    | ^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the attribute macro `issue_59191::no_main` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index e0803550906db248c463ebe0f7405211297f3f0d..040ace9160f624870e4b879550475d9b10322434 100644 (file)
@@ -4,7 +4,7 @@ error[E0412]: cannot find type `Foo` in this scope
 LL | issue_83510::dance_like_you_want_to_ice!();
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `issue_83510::dance_like_you_want_to_ice` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0404]: expected trait, found struct `Box`
   --> $DIR/issue-83510.rs:5:1
@@ -12,7 +12,7 @@ error[E0404]: expected trait, found struct `Box`
 LL | issue_83510::dance_like_you_want_to_ice!();
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a trait
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `issue_83510::dance_like_you_want_to_ice` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0405]: cannot find trait `Baz` in this scope
   --> $DIR/issue-83510.rs:5:1
@@ -20,7 +20,7 @@ error[E0405]: cannot find trait `Baz` in this scope
 LL | issue_83510::dance_like_you_want_to_ice!();
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `issue_83510::dance_like_you_want_to_ice` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0658]: inherent associated types are unstable
   --> $DIR/issue-83510.rs:5:1
@@ -30,7 +30,7 @@ LL | issue_83510::dance_like_you_want_to_ice!();
    |
    = note: see issue #8995 <https://github.com/rust-lang/rust/issues/8995> for more information
    = help: add `#![feature(inherent_associated_types)]` to the crate attributes to enable
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `issue_83510::dance_like_you_want_to_ice` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 4 previous errors
 
index 58f6165388ca167c3db93524d8c5b1de41f81621..0c99809ed5c13ec57b515c65b8e39bebf4f5df24 100644 (file)
@@ -7,7 +7,7 @@ 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)
+   = note: this error originates in the macro `single_quote_alone` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 03c4d19268ceb2454a548388b6249cb5c1dc40c3..f36f937fc06b82ba7a97271f4e67ec8eecc7c95a 100644 (file)
@@ -4,7 +4,7 @@ error[E0425]: cannot find value `foobar2` in this scope
 LL |     bang_proc_macro2!();
    |     ^^^^^^^^^^^^^^^^^^^^ help: a local variable with a similar name exists: `foobar`
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `bang_proc_macro2` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 54a079e4e736af0e9ae1152d3e98bdb8a21dc9a4..85766548bff2ac6226a3bd9ce06015f9c53b945b 100644 (file)
@@ -7,7 +7,7 @@ LL |             field: MissingType
 LL | produce_it!(MyName);
    | -------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `produce_it` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index b7a37ab10ed5c23c1f6c13b0befc0798dd97c1c4..d9337fb361bee262b78af084242627824556e334 100644 (file)
@@ -45,10 +45,10 @@ fn main /* 0#0 */() { ; }
 Expansions:
 0: parent: ExpnId(0), call_site_ctxt: #0, def_site_ctxt: #0, kind: Root
 1: parent: ExpnId(0), call_site_ctxt: #0, def_site_ctxt: #0, kind: AstPass(StdImports)
-2: parent: ExpnId(0), call_site_ctxt: #0, def_site_ctxt: #0, kind: Macro(Bang, "produce_it")
+2: parent: ExpnId(0), call_site_ctxt: #0, def_site_ctxt: #0, kind: Macro { kind: Bang, name: "produce_it", proc_macro: false }
 3: parent: ExpnId(0), call_site_ctxt: #0, def_site_ctxt: #0, kind: AstPass(StdImports)
-4: parent: ExpnId(2), call_site_ctxt: #4, def_site_ctxt: #0, kind: Macro(Bang, "meta_macro::print_def_site")
-5: parent: ExpnId(4), call_site_ctxt: #5, def_site_ctxt: #0, kind: Macro(Bang, "$crate::dummy")
+4: parent: ExpnId(2), call_site_ctxt: #4, def_site_ctxt: #0, kind: Macro { kind: Bang, name: "meta_macro::print_def_site", proc_macro: true }
+5: parent: ExpnId(4), call_site_ctxt: #5, def_site_ctxt: #0, kind: Macro { kind: Bang, name: "$crate::dummy", proc_macro: true }
 
 SyntaxContexts:
 #0: parent: #0, outer_mark: (ExpnId(0), Opaque)
index 6244ffc47a64bf19a306495b92328cd60f3ceabd..c8ed20d30c911bbe58d72984609d98c5a936bc94 100644 (file)
@@ -4,7 +4,7 @@ error[E0426]: use of undeclared label `'label_use`
 LL |         proc_macro_rules!();
    |         ^^^^^^^^^^^^^^^^^^^^ undeclared label `'label_use`
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `proc_macro_rules` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0425]: cannot find value `local_use` in this scope
   --> $DIR/mixed-site-span.rs:13:9
@@ -12,7 +12,7 @@ error[E0425]: cannot find value `local_use` in this scope
 LL |         proc_macro_rules!();
    |         ^^^^^^^^^^^^^^^^^^^^ not found in this scope
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `proc_macro_rules` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0425]: cannot find value `local_def` in this scope
   --> $DIR/mixed-site-span.rs:17:9
@@ -26,7 +26,7 @@ error[E0412]: cannot find type `ItemUse` in crate `$crate`
 LL | pass_dollar_crate!();
    | ^^^^^^^^^^^^^^^^^^^^^ not found in `$crate`
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `proc_macro_rules` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 4 previous errors
 
index 8dc2f3d12afd6a7d76bbd81ce7bfc9fb352c8e93..d37df81496c387fac89c791bca9d9910b96313d7 100644 (file)
@@ -9,7 +9,7 @@ note: found these 'hi's
    |
 LL |     hello!(hi);
    |            ^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `hello` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: hello to you, too!
   --> $DIR/multispan.rs:15:5
@@ -22,7 +22,7 @@ note: found these 'hi's
    |
 LL |     hello!(hi hi);
    |            ^^ ^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `hello` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: hello to you, too!
   --> $DIR/multispan.rs:18:5
@@ -35,7 +35,7 @@ note: found these 'hi's
    |
 LL |     hello!(hi hi hi);
    |            ^^ ^^ ^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `hello` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: hello to you, too!
   --> $DIR/multispan.rs:21:5
@@ -48,7 +48,7 @@ note: found these 'hi's
    |
 LL |     hello!(hi hey hi yo hi beep beep hi hi);
    |            ^^     ^^    ^^           ^^ ^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `hello` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: hello to you, too!
   --> $DIR/multispan.rs:22:5
@@ -61,7 +61,7 @@ note: found these 'hi's
    |
 LL |     hello!(hi there, hi how are you? hi... hi.);
    |            ^^        ^^              ^^    ^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `hello` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: hello to you, too!
   --> $DIR/multispan.rs:23:5
@@ -74,7 +74,7 @@ note: found these 'hi's
    |
 LL |     hello!(whoah. hi di hi di ho);
    |                   ^^    ^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `hello` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: hello to you, too!
   --> $DIR/multispan.rs:24:5
@@ -87,7 +87,7 @@ note: found these 'hi's
    |
 LL |     hello!(hi good hi and good bye);
    |            ^^      ^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `hello` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 7 previous errors
 
index ba3b3ee78278480fe5f3ff65c1e684772f226d05..54dc856bfb03a4871e186d17110e98ea12ca6a6a 100644 (file)
@@ -69,10 +69,10 @@ fn main /* 0#0 */() { }
 Expansions:
 0: parent: ExpnId(0), call_site_ctxt: #0, def_site_ctxt: #0, kind: Root
 1: parent: ExpnId(0), call_site_ctxt: #0, def_site_ctxt: #0, kind: AstPass(StdImports)
-2: parent: ExpnId(0), call_site_ctxt: #0, def_site_ctxt: #0, kind: Macro(Bang, "outer")
+2: parent: ExpnId(0), call_site_ctxt: #0, def_site_ctxt: #0, kind: Macro { kind: Bang, name: "outer", proc_macro: false }
 3: parent: ExpnId(0), call_site_ctxt: #0, def_site_ctxt: #0, kind: AstPass(StdImports)
-4: parent: ExpnId(2), call_site_ctxt: #4, def_site_ctxt: #4, kind: Macro(Bang, "inner")
-5: parent: ExpnId(4), call_site_ctxt: #6, def_site_ctxt: #0, kind: Macro(Bang, "print_bang")
+4: parent: ExpnId(2), call_site_ctxt: #4, def_site_ctxt: #4, kind: Macro { kind: Bang, name: "inner", proc_macro: false }
+5: parent: ExpnId(4), call_site_ctxt: #6, def_site_ctxt: #0, kind: Macro { kind: Bang, name: "print_bang", proc_macro: true }
 
 SyntaxContexts:
 #0: parent: #0, outer_mark: (ExpnId(0), Opaque)
index 5ae2583f01c6065a8f8b5b46dd28524253cef071..0af1b4a182295daa91afeb1960c7e38a58394eb4 100644 (file)
@@ -7,7 +7,7 @@ LL |     three!($a, $b);
 LL |     one!("hello", "world");
    |     ----------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `two` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: second final: "world"
   --> $DIR/parent-source-spans.rs:16:16
@@ -18,7 +18,7 @@ LL |     three!($a, $b);
 LL |     one!("hello", "world");
    |     ----------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `two` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: first parent: "hello"
   --> $DIR/parent-source-spans.rs:10:5
@@ -29,7 +29,7 @@ LL |     two!($a, $b);
 LL |     one!("hello", "world");
    |     ----------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `one` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: second parent: "world"
   --> $DIR/parent-source-spans.rs:10:5
@@ -40,7 +40,7 @@ LL |     two!($a, $b);
 LL |     one!("hello", "world");
    |     ----------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `one` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: first grandparent: "hello"
   --> $DIR/parent-source-spans.rs:36:5
@@ -75,7 +75,7 @@ LL |     three!($a, $b);
 LL |     two!("yay", "rust");
    |     -------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `two` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: second final: "rust"
   --> $DIR/parent-source-spans.rs:16:16
@@ -86,7 +86,7 @@ LL |     three!($a, $b);
 LL |     two!("yay", "rust");
    |     -------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `two` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: first parent: "yay"
   --> $DIR/parent-source-spans.rs:42:5
@@ -150,7 +150,7 @@ LL |     one!("hello", "world");
 LL |     Ok(#[stable(feature = "rust1", since = "1.0.0")] T),
    |     --------------------------------------------------- similarly named tuple variant `Ok` defined here
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `parent_source_spans` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0425]: cannot find value `ok` in this scope
   --> $DIR/parent-source-spans.rs:29:5
@@ -166,7 +166,7 @@ LL |     two!("yay", "rust");
 LL |     Ok(#[stable(feature = "rust1", since = "1.0.0")] T),
    |     --------------------------------------------------- similarly named tuple variant `Ok` defined here
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `parent_source_spans` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0425]: cannot find value `ok` in this scope
   --> $DIR/parent-source-spans.rs:29:5
@@ -182,7 +182,7 @@ LL |     three!("hip", "hop");
 LL |     Ok(#[stable(feature = "rust1", since = "1.0.0")] T),
    |     --------------------------------------------------- similarly named tuple variant `Ok` defined here
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `parent_source_spans` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 21 previous errors
 
diff --git a/src/test/ui/proc-macro/quote-debug.rs b/src/test/ui/proc-macro/quote-debug.rs
new file mode 100644 (file)
index 0000000..e0304a0
--- /dev/null
@@ -0,0 +1,18 @@
+// check-pass
+// force-host
+// no-prefer-dynamic
+// compile-flags: -Z unpretty=expanded
+//
+// This file is not actually used as a proc-macro - instead,
+// it's just used to show the output of the `quote!` macro
+
+#![feature(proc_macro_quote)]
+#![crate_type = "proc-macro"]
+
+extern crate proc_macro;
+
+fn main() {
+    proc_macro::quote! {
+        let hello = "world";
+    }
+}
diff --git a/src/test/ui/proc-macro/quote-debug.stdout b/src/test/ui/proc-macro/quote-debug.stdout
new file mode 100644 (file)
index 0000000..4bdc04b
--- /dev/null
@@ -0,0 +1,52 @@
+#![feature(prelude_import)]
+#![no_std]
+// check-pass
+// force-host
+// no-prefer-dynamic
+// compile-flags: -Z unpretty=expanded
+//
+// This file is not actually used as a proc-macro - instead,
+// it's just used to show the output of the `quote!` macro
+
+#![feature(proc_macro_quote)]
+#![crate_type = "proc-macro"]
+#[prelude_import]
+use ::std::prelude::rust_2015::*;
+#[macro_use]
+extern crate std;
+
+extern crate proc_macro;
+
+fn main() {
+    [crate::TokenStream::from(crate::TokenTree::Ident(crate::Ident::new("let",
+                                                                        crate::Span::recover_proc_macro_span(0)))),
+     crate::TokenStream::from(crate::TokenTree::Ident(crate::Ident::new("hello",
+                                                                        crate::Span::recover_proc_macro_span(1)))),
+     crate::TokenStream::from(crate::TokenTree::Punct(crate::Punct::new('\u{3d}',
+                                                                        crate::Spacing::Alone))),
+     crate::TokenStream::from(crate::TokenTree::Literal({
+                                                            let mut iter =
+                                                                "\"world\"".parse::<crate::TokenStream>().unwrap().into_iter();
+                                                            if let (Some(crate::TokenTree::Literal(mut lit)),
+                                                                    None) =
+                                                                   (iter.next(),
+                                                                    iter.next())
+                                                               {
+                                                                lit.set_span(crate::Span::recover_proc_macro_span(2));
+                                                                lit
+                                                            } else {
+                                                                {
+                                                                    ::core::panicking::panic("internal error: entered unreachable code")
+                                                                }
+                                                            }
+                                                        })),
+     crate::TokenStream::from(crate::TokenTree::Punct(crate::Punct::new('\u{3b}',
+                                                                        crate::Spacing::Alone)))].iter().cloned().collect::<crate::TokenStream>()
+}
+const _: () =
+    {
+        extern crate proc_macro;
+        #[rustc_proc_macro_decls]
+        #[allow(deprecated)]
+        static _DECLS: &[proc_macro::bridge::client::ProcMacro] = &[];
+    };
index e82a1226b5aef4be18bb0e1162297bc102641418..ee6dffe93edce7fcb9c3c442b0b648537c6d2def 100644 (file)
@@ -4,7 +4,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found
 LL |     make_bad_struct!(S);
    |     ^^^^^^^^^^^^^^^^^^^^ expected one of 8 possible tokens
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `make_bad_struct` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index db1aa5d5720b939348a090dcea8e028bc031149b..422820e9d8bd5068112d82fbc78eb43b590109f4 100644 (file)
@@ -4,7 +4,7 @@ error: expected error
 LL |     resolve_located_at!(a b)
    |                         ^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `resolve_located_at` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0308]: mismatched types
   --> $DIR/resolved-located-at.rs:7:27
@@ -14,7 +14,7 @@ LL | fn main() {
 LL |     resolve_located_at!(a b)
    |                           ^ expected `()`, found struct `S`
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `resolve_located_at` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/proc-macro/span-from-proc-macro.rs b/src/test/ui/proc-macro/span-from-proc-macro.rs
new file mode 100644 (file)
index 0000000..ecff2d7
--- /dev/null
@@ -0,0 +1,17 @@
+// aux-build:custom-quote.rs
+// aux-build:span-from-proc-macro.rs
+// compile-flags: -Z macro-backtrace
+
+#[macro_use]
+extern crate span_from_proc_macro;
+
+#[error_from_attribute] //~ ERROR cannot find type `MissingType`
+struct ShouldBeRemoved;
+
+#[derive(ErrorFromDerive)] //~ ERROR cannot find type `OtherMissingType`
+struct Kept;
+
+fn main() {
+    error_from_bang!(); //~ ERROR mismatched types
+    other_error_from_bang!(); //~ ERROR cannot find value `my_ident`
+}
diff --git a/src/test/ui/proc-macro/span-from-proc-macro.stderr b/src/test/ui/proc-macro/span-from-proc-macro.stderr
new file mode 100644 (file)
index 0000000..2cbe91a
--- /dev/null
@@ -0,0 +1,62 @@
+error[E0412]: cannot find type `MissingType` in this scope
+  --> $DIR/auxiliary/span-from-proc-macro.rs:37:20
+   |
+LL | pub fn error_from_attribute(_args: TokenStream, _input: TokenStream) -> TokenStream {
+   | ----------------------------------------------------------------------------------- in this expansion of procedural macro `#[error_from_attribute]`
+...
+LL |             field: MissingType
+   |                    ^^^^^^^^^^^ not found in this scope
+   | 
+  ::: $DIR/span-from-proc-macro.rs:8:1
+   |
+LL | #[error_from_attribute]
+   | ----------------------- in this macro invocation
+
+error[E0412]: cannot find type `OtherMissingType` in this scope
+  --> $DIR/auxiliary/span-from-proc-macro.rs:46:21
+   |
+LL | pub fn error_from_derive(_input: TokenStream) -> TokenStream {
+   | ------------------------------------------------------------ in this expansion of procedural macro `#[derive(ErrorFromDerive)]`
+...
+LL |             Variant(OtherMissingType)
+   |                     ^^^^^^^^^^^^^^^^ not found in this scope
+   | 
+  ::: $DIR/span-from-proc-macro.rs:11:10
+   |
+LL | #[derive(ErrorFromDerive)]
+   |          --------------- in this macro invocation
+
+error[E0425]: cannot find value `my_ident` in this scope
+  --> $DIR/auxiliary/span-from-proc-macro.rs:29:9
+   |
+LL | pub fn other_error_from_bang(_input: TokenStream) -> TokenStream {
+   | ---------------------------------------------------------------- in this expansion of procedural macro `other_error_from_bang!`
+LL |     custom_quote::custom_quote! {
+LL |         my_ident
+   |         ^^^^^^^^ not found in this scope
+   | 
+  ::: $DIR/span-from-proc-macro.rs:16:5
+   |
+LL |     other_error_from_bang!();
+   |     ------------------------- in this macro invocation
+
+error[E0308]: mismatched types
+  --> $DIR/auxiliary/span-from-proc-macro.rs:16:36
+   |
+LL |             let bang_error: bool = 25;
+   |                             ----   ^^ expected `bool`, found integer
+   |                             |
+   |                             expected due to this
+...
+LL | pub fn error_from_bang(_input: TokenStream) -> TokenStream {
+   | ---------------------------------------------------------- in this expansion of procedural macro `error_from_bang!`
+   | 
+  ::: $DIR/span-from-proc-macro.rs:15:5
+   |
+LL |     error_from_bang!();
+   |     ------------------- in this macro invocation
+
+error: aborting due to 4 previous errors
+
+Some errors have detailed explanations: E0308, E0412, E0425.
+For more information about an error, try `rustc --explain E0308`.
index c82c2dee67673716f0f92b94d35765f095fa0487..d65b1d0cfaf56cdd23954998674893d4776880aa 100644 (file)
@@ -9,7 +9,7 @@ note: here
    |
 LL | subspan!("hi");
    |           ^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `subspan` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: found 'hi's
   --> $DIR/subspan.rs:14:1
@@ -22,7 +22,7 @@ note: here
    |
 LL | subspan!("hihi");
    |           ^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `subspan` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: found 'hi's
   --> $DIR/subspan.rs:17:1
@@ -35,7 +35,7 @@ note: here
    |
 LL | subspan!("hihihi");
    |           ^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `subspan` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: found 'hi's
   --> $DIR/subspan.rs:20:1
@@ -48,7 +48,7 @@ note: here
    |
 LL | subspan!("why I hide? hi!");
    |                 ^^    ^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `subspan` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: found 'hi's
   --> $DIR/subspan.rs:21:1
@@ -61,7 +61,7 @@ note: here
    |
 LL | subspan!("hey, hi, hidy, hidy, hi hi");
    |                ^^  ^^    ^^    ^^ ^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `subspan` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: found 'hi's
   --> $DIR/subspan.rs:22:1
@@ -74,7 +74,7 @@ note: here
    |
 LL | subspan!("this is a hi, and this is another hi");
    |            ^^       ^^       ^^             ^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `subspan` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: found 'hi's
   --> $DIR/subspan.rs:23:1
@@ -87,7 +87,7 @@ note: here
    |
 LL | subspan!("how are you this evening");
    |                        ^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `subspan` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: found 'hi's
   --> $DIR/subspan.rs:24:1
@@ -100,7 +100,7 @@ note: here
    |
 LL | subspan!("this is highly eradic");
    |            ^^     ^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `subspan` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 8 previous errors
 
index 33a8c762a945bc828148710324ee10cdac133ddc..485aefe62fd5806a9950a0c1f92c28d6d3325fd0 100644 (file)
@@ -5,7 +5,7 @@ LL |     three_equals!(==);
    |     ^^^^^^^^^^^^^^^^^^
    |
    = help: input must be: `===`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `three_equals` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: expected EOF, found `=`.
   --> $DIR/three-equals.rs:15:21
index b17dc28f84091a6cf3cda30423291e1af0e37d6d..03a984c58ceb84c637f5af220032762e2d0c076d 100644 (file)
@@ -7,7 +7,7 @@ LL |             Value = (stringify!($tokens + hidden_ident), 1).1
 LL |     other!(50);
    |     ----------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `inner` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0425]: cannot find value `hidden_ident` in this scope
   --> $DIR/weird-hygiene.rs:34:13
@@ -18,7 +18,7 @@ LL |             hidden_ident
 LL |     invoke_it!(25);
    |     --------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `invoke_it` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index e2c1eeb292a7bf10bd5d97173db8f69b5ff7bbb5..bc4c9a04b5e4b3aff82dc4c45dbe8362763a5f8a 100644 (file)
@@ -6,7 +6,7 @@ LL |     a: Range<usize>,
    |
    = help: the trait `PartialOrd` is not implemented for `std::ops::Range<usize>`
    = 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)
+   = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0277]: can't compare `std::ops::RangeTo<usize>` with `std::ops::RangeTo<usize>`
   --> $DIR/range_traits-1.rs:8:5
@@ -16,7 +16,7 @@ LL |     b: RangeTo<usize>,
    |
    = help: the trait `PartialOrd` is not implemented for `std::ops::RangeTo<usize>`
    = 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)
+   = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0277]: can't compare `std::ops::RangeFrom<usize>` with `std::ops::RangeFrom<usize>`
   --> $DIR/range_traits-1.rs:11:5
@@ -26,7 +26,7 @@ LL |     c: RangeFrom<usize>,
    |
    = help: the trait `PartialOrd` is not implemented for `std::ops::RangeFrom<usize>`
    = 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)
+   = note: this error originates in the derive macro `PartialOrd` (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
@@ -36,7 +36,7 @@ LL |     d: 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)
+   = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0277]: can't compare `std::ops::RangeInclusive<usize>` with `std::ops::RangeInclusive<usize>`
   --> $DIR/range_traits-1.rs:17:5
@@ -46,7 +46,7 @@ LL |     e: RangeInclusive<usize>,
    |
    = help: the trait `PartialOrd` is not implemented for `std::ops::RangeInclusive<usize>`
    = 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)
+   = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0277]: can't compare `std::ops::RangeToInclusive<usize>` with `std::ops::RangeToInclusive<usize>`
   --> $DIR/range_traits-1.rs:20:5
@@ -56,7 +56,7 @@ LL |     f: RangeToInclusive<usize>,
    |
    = help: the trait `PartialOrd` is not implemented for `std::ops::RangeToInclusive<usize>`
    = 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)
+   = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0277]: the trait bound `std::ops::Range<usize>: Ord` is not satisfied
   --> $DIR/range_traits-1.rs:5:5
@@ -65,7 +65,7 @@ LL |     a: Range<usize>,
    |     ^^^^^^^^^^^^^^^ the trait `Ord` is not implemented for `std::ops::Range<usize>`
    |
    = 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)
+   = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0277]: the trait bound `std::ops::RangeTo<usize>: Ord` is not satisfied
   --> $DIR/range_traits-1.rs:8:5
@@ -74,7 +74,7 @@ LL |     b: RangeTo<usize>,
    |     ^^^^^^^^^^^^^^^^^ the trait `Ord` is not implemented for `std::ops::RangeTo<usize>`
    |
    = 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)
+   = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0277]: the trait bound `std::ops::RangeFrom<usize>: Ord` is not satisfied
   --> $DIR/range_traits-1.rs:11:5
@@ -83,7 +83,7 @@ LL |     c: RangeFrom<usize>,
    |     ^^^^^^^^^^^^^^^^^^^ the trait `Ord` is not implemented for `std::ops::RangeFrom<usize>`
    |
    = 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)
+   = note: this error originates in the derive macro `Ord` (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
@@ -92,7 +92,7 @@ LL |     d: RangeFull,
    |     ^^^^^^^^^^^^ the trait `Ord` is not implemented for `std::ops::RangeFull`
    |
    = 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)
+   = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0277]: the trait bound `std::ops::RangeInclusive<usize>: Ord` is not satisfied
   --> $DIR/range_traits-1.rs:17:5
@@ -101,7 +101,7 @@ LL |     e: RangeInclusive<usize>,
    |     ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Ord` is not implemented for `std::ops::RangeInclusive<usize>`
    |
    = 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)
+   = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0277]: the trait bound `std::ops::RangeToInclusive<usize>: Ord` is not satisfied
   --> $DIR/range_traits-1.rs:20:5
@@ -110,7 +110,7 @@ LL |     f: RangeToInclusive<usize>,
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Ord` is not implemented for `std::ops::RangeToInclusive<usize>`
    |
    = 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)
+   = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 12 previous errors
 
index 8a9d15f09996bf32818aca11c724ef6ec4626025..61facba535bfff97ae74d49328ef3a0de8b26d03 100644 (file)
@@ -6,7 +6,7 @@ LL | #[derive(Copy, Clone)]
 LL | struct R(Range<usize>);
    |          ------------ this field does not implement `Copy`
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 14fda58e1f813351778cd4fdde952cd5d60989e9..e54d17b329ec5989bd05c08af6ae7e61631bfc61 100644 (file)
@@ -6,7 +6,7 @@ LL | #[derive(Copy, Clone)]
 LL | struct R(RangeFrom<usize>);
    |          ---------------- this field does not implement `Copy`
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 693600cdce4d1fb75e5b6795ade9e5fb337f0752..addc525f1fa36810543d19005cfa9afdb3e60176 100644 (file)
@@ -6,7 +6,7 @@ LL | #[derive(Copy, Clone)]
 LL | struct R(RangeInclusive<usize>);
    |          --------------------- this field does not implement `Copy`
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 130fd8535e0ff08734e7c35f111958cbd53c2a7a..0192f4359e590b4d9da8507521a70ca3d897a9bf 100644 (file)
@@ -11,7 +11,7 @@ note: the lint level is defined here
    |
 LL | #![deny(unreachable_code)]
    |         ^^^^^^^^^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 154734b0f696cdb4cccbf064cb93560b21d2eca2..4ed84c566a772296194ba911117cde374c5a700e 100644 (file)
@@ -20,7 +20,7 @@ LL |         return;
 LL |         println!("foo");
    |         ^^^^^^^^^^^^^^^^ unreachable statement
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index 850570d05646dd520c357fd7df0c69f88861093c..71cc94be3ee44f84e13cf59e18a69db7db8dc797 100644 (file)
@@ -24,7 +24,7 @@ LL |         return;
 LL |     println!("But I am.");
    |     ^^^^^^^^^^^^^^^^^^^^^^ unreachable statement
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index fe7d7782edf55bbd68a7a21c442b63d8971d77d5..d6c140375e3c72c25d9de3427b0bc9249cee535d 100644 (file)
@@ -11,7 +11,7 @@ note: the lint level is defined here
    |
 LL | #![deny(unreachable_code)]
    |         ^^^^^^^^^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: unreachable statement
   --> $DIR/expr_loop.rs:21:5
@@ -21,7 +21,7 @@ LL |     loop { return; }
 LL |     println!("I am dead.");
    |     ^^^^^^^^^^^^^^^^^^^^^^^ unreachable statement
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: unreachable statement
   --> $DIR/expr_loop.rs:32:5
@@ -31,7 +31,7 @@ LL |     loop { 'middle: loop { loop { break 'middle; } } }
 LL |     println!("I am dead.");
    |     ^^^^^^^^^^^^^^^^^^^^^^^ unreachable statement
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 3 previous errors
 
index a1c396e0c6116d530275e78145bcc1bdde62cfd0..9d660a43866de9485a96a1a72f0bba16e3ec5622 100644 (file)
@@ -11,7 +11,7 @@ note: the lint level is defined here
    |
 LL | #![deny(unreachable_code)]
    |         ^^^^^^^^^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: unreachable statement
   --> $DIR/expr_match.rs:19:5
@@ -21,7 +21,7 @@ LL |     match () { () if false => return, () => return }
 LL |     println!("I am dead");
    |     ^^^^^^^^^^^^^^^^^^^^^^ unreachable statement
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index 72abb4fc8db19a55be725e00011f521e56b9ed30..839b585c63f2679a1267ed9777fdf04d7c36dbb1 100644 (file)
@@ -11,7 +11,7 @@ note: the lint level is defined here
    |
 LL | #![deny(unreachable_code)]
    |         ^^^^^^^^^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 6f2c75d2ebad8fdf81a9dfbed7049ff7a1ccea11..a4c8e721145eb4c3afef74e83f2f550d9e80e21d 100644 (file)
@@ -11,17 +11,12 @@ LL |     t
 error[E0621]: explicit lifetime required in the type of `u`
   --> $DIR/regions-static-bound.rs:14:5
    |
-LL | fn error(u: &(), v: &()) {
-   |             --- help: add explicit lifetime `'static` to the type of `u`: `&'static ()`
 LL |     static_id(&u);
    |     ^^^^^^^^^^^^^ lifetime `'static` required
 
 error[E0621]: explicit lifetime required in the type of `v`
   --> $DIR/regions-static-bound.rs:16:5
    |
-LL | fn error(u: &(), v: &()) {
-   |                     --- help: add explicit lifetime `'static` to the type of `v`: `&'static ()`
-...
 LL |     static_id_indirect(&v);
    |     ^^^^^^^^^^^^^^^^^^^^^^ lifetime `'static` required
 
index 6e631d40d45008119732c8a0fd60be27ce050666..644458e2063ce8efa80f3c44ace25de2a1184e20 100644 (file)
@@ -14,17 +14,12 @@ LL | fn static_id_wrong_way<'a>(t: &'a ()) -> &'static () where 'static: 'a {
 error[E0621]: explicit lifetime required in the type of `u`
   --> $DIR/regions-static-bound.rs:14:5
    |
-LL | fn error(u: &(), v: &()) {
-   |             --- help: add explicit lifetime `'static` to the type of `u`: `&'static ()`
 LL |     static_id(&u);
    |     ^^^^^^^^^ lifetime `'static` required
 
 error[E0621]: explicit lifetime required in the type of `v`
   --> $DIR/regions-static-bound.rs:16:5
    |
-LL | fn error(u: &(), v: &()) {
-   |                     --- help: add explicit lifetime `'static` to the type of `v`: `&'static ()`
-...
 LL |     static_id_indirect(&v);
    |     ^^^^^^^^^^^^^^^^^^ lifetime `'static` required
 
index 6f2c75d2ebad8fdf81a9dfbed7049ff7a1ccea11..a4c8e721145eb4c3afef74e83f2f550d9e80e21d 100644 (file)
@@ -11,17 +11,12 @@ LL |     t
 error[E0621]: explicit lifetime required in the type of `u`
   --> $DIR/regions-static-bound.rs:14:5
    |
-LL | fn error(u: &(), v: &()) {
-   |             --- help: add explicit lifetime `'static` to the type of `u`: `&'static ()`
 LL |     static_id(&u);
    |     ^^^^^^^^^^^^^ lifetime `'static` required
 
 error[E0621]: explicit lifetime required in the type of `v`
   --> $DIR/regions-static-bound.rs:16:5
    |
-LL | fn error(u: &(), v: &()) {
-   |                     --- help: add explicit lifetime `'static` to the type of `v`: `&'static ()`
-...
 LL |     static_id_indirect(&v);
    |     ^^^^^^^^^^^^^^^^^^^^^^ lifetime `'static` required
 
index 027d7a0e0e448188147d87602f87a019e81456e1..0aa0610de74d9b66871581a43bb6f1fc7dc1f045 100644 (file)
@@ -13,7 +13,7 @@ LL |     Box::z
 LL |     mac!();
    |     ------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index 4580620186197ae2ef5119cf1e8ffb5344f00866..1949e762873761067502b20afd4462e50270cf29 100644 (file)
@@ -12,7 +12,7 @@ LL |   pub fn assert_test_result<T: Termination>(result: T) {
    |                                ----------- required by this bound in `assert_test_result`
    |
    = help: the trait `Termination` is not implemented for `Result<f32, ParseFloatError>`
-   = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the attribute macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 1d1c43c9e8f49e38449a708c96bb2111207bb494..cd9ded81e6a09e72c701039230308050a8293ba9 100644 (file)
@@ -5,7 +5,7 @@ LL |     match x {}
    |           ^
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
-   = note: the matched value is of type `EmptyNonExhaustiveEnum`
+   = note: the matched value is of type `EmptyNonExhaustiveEnum`, which is marked as non-exhaustive
 
 error[E0004]: non-exhaustive patterns: `_` not covered
   --> $DIR/enum.rs:16:11
@@ -14,7 +14,7 @@ LL |     match enum_unit {
    |           ^^^^^^^^^ pattern `_` 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 `NonExhaustiveEnum`
+   = note: the matched value is of type `NonExhaustiveEnum`, which is marked as non-exhaustive
 
 error[E0004]: non-exhaustive patterns: `_` not covered
   --> $DIR/enum.rs:23:11
@@ -23,7 +23,7 @@ LL |     match enum_unit {};
    |           ^^^^^^^^^ pattern `_` 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 `NonExhaustiveEnum`
+   = note: the matched value is of type `NonExhaustiveEnum`, which is marked as non-exhaustive
 
 error: aborting due to 3 previous errors
 
index e2ee8d6a6fe5e0b35d347f8974bbf5febb5757e2..d023ba3096e68ee0b85998869d2c802304f8a508 100644 (file)
@@ -2,7 +2,7 @@ error[E0423]: cannot initialize a tuple struct which contains private fields
   --> $DIR/struct.rs:20:14
    |
 LL |     let ts = TupleStruct(640, 480);
-   |              ^^^^^^^^^^^ constructor is not visible here due to private fields
+   |              ^^^^^^^^^^^
 
 error[E0423]: expected value, found struct `UnitStruct`
   --> $DIR/struct.rs:29:14
index 1f981ba82d08397217e76fcb9b13d04562805257..746c1fd4aceb7d77f7cb5c01f1d539705f9b8c3d 100644 (file)
@@ -5,7 +5,7 @@ LL |     match x {}
    |           ^
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
-   = note: the matched value is of type `UninhabitedEnum`
+   = note: the matched value is of type `UninhabitedEnum`, which is marked as non-exhaustive
 
 error[E0004]: non-exhaustive patterns: type `UninhabitedStruct` is non-empty
   --> $DIR/match.rs:23:11
index 0ff1c01cbdd0c1abaf027303b096a7a3cbe3ea19..46e84dc09a3ead2763e20474005eea5717082be2 100644 (file)
@@ -5,7 +5,7 @@ LL |     match x {}
    |           ^
    |
    = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
-   = note: the matched value is of type `UninhabitedEnum`
+   = note: the matched value is of type `UninhabitedEnum`, which is marked as non-exhaustive
 
 error[E0004]: non-exhaustive patterns: type `UninhabitedStruct` is non-empty
   --> $DIR/match_with_exhaustive_patterns.rs:26:11
index 05240908917bc0f37e55ead53e56ab9a1dd67f15..a3bed707eccda69c6ea5c9614ba97787853a5819 100644 (file)
@@ -6,7 +6,7 @@
 // run-pass
 // compile-flags: -Z unleash-the-miri-inside-of-you
 
-#![feature(core_intrinsics, const_caller_location, const_fn)]
+#![feature(core_intrinsics, const_caller_location)]
 
 type L = &'static std::panic::Location<'static>;
 
index 89b0b69f38dc09cd5e7d0e81929908c67a9362c8..6e15cf3fe8ad375922d9468447b0164ff6de2060 100644 (file)
@@ -2,7 +2,7 @@
 // revisions: default mir-opt
 //[mir-opt] compile-flags: -Zmir-opt-level=4
 
-#![feature(const_caller_location, const_fn)]
+#![feature(const_caller_location)]
 
 use std::panic::Location;
 
index 6d150b84dd81ecec1d1103c7b4ca120c7aa04a9e..850ca30405ff1025a6358802c7d2236b9e04d1f3 100644 (file)
@@ -8,7 +8,7 @@ LL |     let _: NotDebug = dbg!(NotDebug);
    = note: add `#[derive(Debug)]` or manually implement `Debug`
    = note: required because of the requirements on the impl of `Debug` for `&NotDebug`
    = note: required by `std::fmt::Debug::fmt`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 14c2582121bfd897a39308ae36186b669b621380..7819a2588e8a6b184225847f865b43424cbdc0a7 100644 (file)
@@ -17,7 +17,7 @@ LL | |             }
 LL |       m!();
    |       ----- in this macro invocation
    = help: use `self::std` to refer to this module unambiguously
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index de7b79de95c30484081df97f2a59028529b81c72..54f28113cba52f785833198382a2eb7284e0e0c2 100644 (file)
@@ -17,7 +17,7 @@ LL | |         }
 LL |   m!();
    |   ----- in this macro invocation
    = help: use `crate::std` to refer to this module unambiguously
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/rustc-args-required-const2.rs b/src/test/ui/rustc-args-required-const2.rs
deleted file mode 100644 (file)
index 5feeca6..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#![feature(rustc_attrs, const_fn)]
-
-#[rustc_args_required_const(0)]
-fn foo(_a: i32) {
-}
-
-fn main() {
-    let a = foo; //~ ERROR: this function can only be invoked directly
-    a(2);
-}
diff --git a/src/test/ui/rustc-args-required-const2.stderr b/src/test/ui/rustc-args-required-const2.stderr
deleted file mode 100644 (file)
index a8906ad..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-error: this function can only be invoked directly, not through a function pointer
-  --> $DIR/rustc-args-required-const2.rs:8:13
-   |
-LL |     let a = foo;
-   |             ^^^
-
-error: aborting due to previous error
-
index 9a3c495602a69b968345d56a157d079ae7e85e15..a5ebeecd3116c1fe390450e5745d1b531d83ca9b 100644 (file)
@@ -2,12 +2,12 @@ fn main() {
     trait Seq { }
 
     impl<T> Seq<T> for Vec<T> {
-        //~^ ERROR this trait takes 0 type arguments but 1 type argument was supplied
+        //~^ ERROR this trait takes 0 generic arguments but 1 generic argument
         /* ... */
     }
 
     impl Seq<bool> for u32 {
-        //~^ ERROR this trait takes 0 type arguments but 1 type argument was supplied
+        //~^ ERROR this trait takes 0 generic arguments but 1 generic argument
         /* Treat the integer as a sequence of bits */
     }
 }
index 0e89fefc69ddc060851be94222625363639f26fa..c404d95748b5c703314f619bd6f346f16ddc4e17 100644 (file)
@@ -1,26 +1,26 @@
-error[E0107]: this trait takes 0 type arguments but 1 type argument was supplied
+error[E0107]: this trait takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/seq-args.rs:4:13
    |
 LL |     impl<T> Seq<T> for Vec<T> {
    |             ^^^--- help: remove these generics
    |             |
-   |             expected 0 type arguments
+   |             expected 0 generic arguments
    |
-note: trait defined here, with 0 type parameters
+note: trait defined here, with 0 generic parameters
   --> $DIR/seq-args.rs:2:11
    |
 LL |     trait Seq { }
    |           ^^^
 
-error[E0107]: this trait takes 0 type arguments but 1 type argument was supplied
+error[E0107]: this trait takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/seq-args.rs:9:10
    |
 LL |     impl Seq<bool> for u32 {
    |          ^^^------ help: remove these generics
    |          |
-   |          expected 0 type arguments
+   |          expected 0 generic arguments
    |
-note: trait defined here, with 0 type parameters
+note: trait defined here, with 0 generic parameters
   --> $DIR/seq-args.rs:2:11
    |
 LL |     trait Seq { }
index 493cd7a477c7a861686519145ecb0355b2a320fd..abde69163bd4eb1e95e4b39b26030788ad3c9f17 100644 (file)
@@ -50,25 +50,28 @@ fn main() {
         simd_extract::<_, f32>(x, 0);
         //~^ ERROR expected return type `i32` (element of input `i32x4`), found `f32`
 
-        simd_shuffle2::<i32, i32>(0, 0, [0; 2]);
+        const IDX2: [u32; 2] = [0; 2];
+        simd_shuffle2::<i32, i32>(0, 0, IDX2);
         //~^ ERROR expected SIMD input type, found non-SIMD `i32`
-        simd_shuffle4::<i32, i32>(0, 0, [0; 4]);
+        const IDX4: [u32; 4] = [0; 4];
+        simd_shuffle4::<i32, i32>(0, 0, IDX4);
         //~^ ERROR expected SIMD input type, found non-SIMD `i32`
-        simd_shuffle8::<i32, i32>(0, 0, [0; 8]);
+        const IDX8: [u32; 8] = [0; 8];
+        simd_shuffle8::<i32, i32>(0, 0, IDX8);
         //~^ ERROR expected SIMD input type, found non-SIMD `i32`
 
-        simd_shuffle2::<_, f32x2>(x, x, [0; 2]);
+        simd_shuffle2::<_, f32x2>(x, x, IDX2);
 //~^ ERROR element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32`
-        simd_shuffle4::<_, f32x4>(x, x, [0; 4]);
+        simd_shuffle4::<_, f32x4>(x, x, IDX4);
 //~^ ERROR element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32`
-        simd_shuffle8::<_, f32x8>(x, x, [0; 8]);
+        simd_shuffle8::<_, f32x8>(x, x, IDX8);
 //~^ ERROR element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32`
 
-        simd_shuffle2::<_, i32x8>(x, x, [0; 2]);
+        simd_shuffle2::<_, i32x8>(x, x, IDX2);
         //~^ ERROR expected return type of length 2, found `i32x8` with length 8
-        simd_shuffle4::<_, i32x8>(x, x, [0; 4]);
+        simd_shuffle4::<_, i32x8>(x, x, IDX4);
         //~^ ERROR expected return type of length 4, found `i32x8` with length 8
-        simd_shuffle8::<_, i32x2>(x, x, [0; 8]);
+        simd_shuffle8::<_, i32x2>(x, x, IDX8);
         //~^ ERROR expected return type of length 8, found `i32x2` with length 2
     }
 }
index 703e64d1ddcc83c31a952cc5203a263ca114cb86..4220411114efd6d4dcc728d540a407c7039902bc 100644 (file)
@@ -17,58 +17,58 @@ 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:54:9
    |
-LL |         simd_shuffle2::<i32, i32>(0, 0, [0; 2]);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |         simd_shuffle2::<i32, i32>(0, 0, IDX2);
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 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:57:9
    |
-LL |         simd_shuffle4::<i32, i32>(0, 0, [0; 4]);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |         simd_shuffle4::<i32, i32>(0, 0, IDX4);
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 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:60:9
    |
-LL |         simd_shuffle8::<i32, i32>(0, 0, [0; 8]);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |         simd_shuffle8::<i32, i32>(0, 0, IDX8);
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 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:63:9
    |
-LL |         simd_shuffle2::<_, f32x2>(x, x, [0; 2]);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |         simd_shuffle2::<_, f32x2>(x, x, IDX2);
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 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:65:9
    |
-LL |         simd_shuffle4::<_, f32x4>(x, x, [0; 4]);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |         simd_shuffle4::<_, f32x4>(x, x, IDX4);
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 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:67:9
    |
-LL |         simd_shuffle8::<_, f32x8>(x, x, [0; 8]);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |         simd_shuffle8::<_, f32x8>(x, x, IDX8);
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 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:70:9
    |
-LL |         simd_shuffle2::<_, i32x8>(x, x, [0; 2]);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |         simd_shuffle2::<_, i32x8>(x, x, IDX2);
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 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
+  --> $DIR/simd-intrinsic-generic-elements.rs:72:9
    |
-LL |         simd_shuffle4::<_, i32x8>(x, x, [0; 4]);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |         simd_shuffle4::<_, i32x8>(x, x, IDX4);
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 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:74:9
    |
-LL |         simd_shuffle8::<_, i32x2>(x, x, [0; 8]);
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |         simd_shuffle8::<_, i32x2>(x, x, IDX8);
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to 12 previous errors
 
index 4be6818305010dc95147275ee8df857ed0be0342..7221b3ab769db460c8be8dc1836479cee74401f6 100644 (file)
@@ -21,5 +21,6 @@ fn main() {
 
 #[inline(always)]
 unsafe fn inline_me() -> Simd2 {
-    simd_shuffle2(Simd2(10, 11), Simd2(12, 13), [0, 3])
+    const IDX: [u32; 2] = [0, 3];
+    simd_shuffle2(Simd2(10, 11), Simd2(12, 13), IDX)
 }
index 67556829815b3eb6e781950a36f30611f55e4361..0d15427095a749d69964a5c8246ab596aa2c86e6 100644 (file)
@@ -15,7 +15,8 @@
 
 fn main() {
     unsafe {
-        let p_res: Simd2 = simd_shuffle2(Simd2(10, 11), Simd2(12, 13), [0, 1]);
+        const IDX: [u32; 2] = [0, 1];
+        let p_res: Simd2 = simd_shuffle2(Simd2(10, 11), Simd2(12, 13), IDX);
         let a_res: Simd2 = inline_me();
 
         assert_10_11(p_res);
@@ -36,5 +37,6 @@ fn assert_10_13(x: Simd2) {
 
 #[inline(always)]
 unsafe fn inline_me() -> Simd2 {
-    simd_shuffle2(Simd2(10, 11), Simd2(12, 13), [0, 3])
+    const IDX: [u32; 2] = [0, 3];
+    simd_shuffle2(Simd2(10, 11), Simd2(12, 13), IDX)
 }
index 4806f2ca27b9eeb94f3e611c8aff15bcd5f0db5b..07253a4ae46bc44ad98bfdf796e62aea1858e460 100644 (file)
@@ -7,7 +7,7 @@ LL |                     $y(vec1, vec2, ARR)
 LL |     test_shuffle_lanes!(2, u8x2, simd_shuffle2, (2, 1));
    |     ---------------------------------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0511]: invalid monomorphization of `simd_shuffle4` intrinsic: shuffle index #0 is out of bounds (limit 8)
   --> $DIR/shuffle-not-out-of-bounds.rs:163:21
@@ -18,7 +18,7 @@ LL |                     $y(vec1, vec2, ARR)
 LL |     test_shuffle_lanes!(4, u8x4, simd_shuffle4, (4, 3, 2, 1));
    |     ---------------------------------------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0511]: invalid monomorphization of `simd_shuffle8` intrinsic: shuffle index #0 is out of bounds (limit 16)
   --> $DIR/shuffle-not-out-of-bounds.rs:163:21
@@ -29,7 +29,7 @@ LL |                     $y(vec1, vec2, ARR)
 LL |     test_shuffle_lanes!(8, u8x8, simd_shuffle8, (8, 7, 6, 5, 4, 3, 2, 1));
    |     ---------------------------------------------------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0511]: invalid monomorphization of `simd_shuffle16` intrinsic: shuffle index #0 is out of bounds (limit 32)
   --> $DIR/shuffle-not-out-of-bounds.rs:163:21
@@ -41,7 +41,7 @@ LL | /     test_shuffle_lanes!(16, u8x16, simd_shuffle16,
 LL | |         (16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1));
    | |_________________________________________________________________- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0511]: invalid monomorphization of `simd_shuffle32` intrinsic: shuffle index #0 is out of bounds (limit 64)
   --> $DIR/shuffle-not-out-of-bounds.rs:163:21
@@ -54,7 +54,7 @@ LL | |         (32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17,
 LL | |          15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1));
    | |_____________________________________________________________- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0511]: invalid monomorphization of `simd_shuffle64` intrinsic: shuffle index #0 is out of bounds (limit 128)
   --> $DIR/shuffle-not-out-of-bounds.rs:163:21
@@ -69,7 +69,7 @@ LL | |          32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17,
 LL | |          16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1));
    | |_________________________________________________________________- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `test_shuffle_lanes` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 6 previous errors
 
index a85ec7c58235ba8554c7ab750a4def27c2f9dd4e..08544bce45db97dca47c604f50a2b0073337edff 100644 (file)
@@ -2,6 +2,8 @@
 // ignore-emscripten FIXME(#45351) hits an LLVM assert
 
 #![feature(repr_simd, platform_intrinsics)]
+#![allow(incomplete_features)]
+#![feature(inline_const)]
 
 #[repr(simd)]
 #[derive(Copy, Clone, Debug, PartialEq)]
@@ -82,19 +84,19 @@ fn main() {
     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_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]),
+        all_eq!(simd_shuffle2(x2, y2, const { [3u32, 0] }), i32x2(121, 20));
+        all_eq!(simd_shuffle4(x2, y2, const { [3u32, 0, 1, 2] }), i32x4(121, 20, 21, 120));
+        all_eq!(simd_shuffle8(x2, y2, const { [3u32, 0, 1, 2, 1, 2, 3, 0] }),
                 i32x8(121, 20, 21, 120, 21, 120, 121, 20));
 
-        all_eq!(simd_shuffle2(x4, y4, [7, 2]), i32x2(143, 42));
-        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]),
+        all_eq!(simd_shuffle2(x4, y4, const { [7u32, 2] }), i32x2(143, 42));
+        all_eq!(simd_shuffle4(x4, y4, const { [7u32, 2, 5, 0] }), i32x4(143, 42, 141, 40));
+        all_eq!(simd_shuffle8(x4, y4, const { [7u32, 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_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]),
+        all_eq!(simd_shuffle2(x8, y8, const { [11u32, 5] }), i32x2(183, 85));
+        all_eq!(simd_shuffle4(x8, y8, const { [11u32, 5, 15, 0] }), i32x4(183, 85, 187, 80));
+        all_eq!(simd_shuffle8(x8, y8, const { [11u32, 5, 15, 0, 3, 8, 12, 1] }),
                 i32x8(183, 85, 187, 80, 83, 180, 184, 81));
     }
 
index 23c9513f9ccb40de503c7fa7ce7a066a83353fbb..2575848435206033d4f027dec5a5234da36ca4ee 100644 (file)
@@ -16,7 +16,7 @@ LL | struct Foo2<'a> {
 LL |     ty: &'a mut bool,
    |     ---------------- this field does not implement `Copy`
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0204]: the trait `Copy` may not be implemented for this type
   --> $DIR/E0204.rs:17:6
@@ -36,7 +36,7 @@ LL | enum EFoo2<'a> {
 LL |     Bar(&'a mut bool),
    |         ------------ this field does not implement `Copy`
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 4 previous errors
 
index 857c3081c62ef408626d0ab8869c6f0285be0ab1..0e40ca67351e7c7aecf0bd91c0ce939a5d59539c 100644 (file)
@@ -49,7 +49,7 @@ error[E0308]: mismatched types
 LL |     s = format!("foo");
    |         ^^^^^^^^^^^^^^ expected `&mut String`, found struct `String`
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 6 previous errors
 
index 473d36c2ab1e332afe6ad4f0e09e3033c7516064..aee1530851773aaa55c7cba4061fd453b9856667 100644 (file)
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
 LL |     stream.write_fmt(format!("message received"))
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `Arguments`, found struct `String`
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 45cf5f8688cd1f77bc2637fb5ce11b481fb19b0f..afdf036f833b11571e89e7d866a0ee8da8107f25 100644 (file)
@@ -13,7 +13,7 @@ note: the lint level is defined here
 LL | #![warn(unused)]
    |         ^^^^^^
    = note: `#[warn(dead_code)]` implied by `#[warn(unused)]`
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: 1 warning emitted
 
index 745936e11eafc05d45a8bee1d4704290e8746b7f..62a4a6009d433780516a3ff835ca8712b89e6704 100644 (file)
@@ -10,7 +10,7 @@ LL |     y.use_ref();
    |     - borrow later used here
    |
    = note: consider using a `let` binding to create a longer lived value
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 9f8ecc262812624d7e593f9b564db7e9e03ad1fa..d7cb66d9c84ec72657e53a69a519c5fb9f9c6f20 100644 (file)
@@ -1,6 +1,6 @@
 // Various checks that stability attributes are used correctly, per RFC 507
 
-#![feature(const_fn, staged_api)]
+#![feature(staged_api)]
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
index 0de28d5469b389b2d9830dbb4573a6a9a31e5dd0..e7ea8663d5af84cefa08ff85ab170f6cc144c464 100644 (file)
@@ -1,5 +1,3 @@
-#![feature(const_fn)]
-
 struct WithDtor;
 
 impl Drop for WithDtor {
index ed81734f6ebd7cd981f0d8d968f47044ed3ccab7..ac32f217fd76904facc0c879a6e08aae9e01127d 100644 (file)
@@ -1,5 +1,5 @@
 error[E0493]: destructors cannot be evaluated at compile-time
-  --> $DIR/static-drop-scope.rs:9:60
+  --> $DIR/static-drop-scope.rs:7:60
    |
 LL | static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor);
    |                                                            ^^^^^^^^- value is dropped here
@@ -7,7 +7,7 @@ LL | static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor);
    |                                                            statics cannot evaluate destructors
 
 error[E0716]: temporary value dropped while borrowed
-  --> $DIR/static-drop-scope.rs:9:60
+  --> $DIR/static-drop-scope.rs:7:60
    |
 LL | static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor);
    |                                                      ------^^^^^^^^-
@@ -17,7 +17,7 @@ LL | static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor);
    |                                                      using this value as a static requires that borrow lasts for `'static`
 
 error[E0493]: destructors cannot be evaluated at compile-time
-  --> $DIR/static-drop-scope.rs:13:59
+  --> $DIR/static-drop-scope.rs:11:59
    |
 LL | const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor);
    |                                                           ^^^^^^^^- value is dropped here
@@ -25,7 +25,7 @@ LL | const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor);
    |                                                           constants cannot evaluate destructors
 
 error[E0716]: temporary value dropped while borrowed
-  --> $DIR/static-drop-scope.rs:13:59
+  --> $DIR/static-drop-scope.rs:11:59
    |
 LL | const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor);
    |                                                     ------^^^^^^^^-
@@ -35,7 +35,7 @@ LL | const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor);
    |                                                     using this value as a constant requires that borrow lasts for `'static`
 
 error[E0493]: destructors cannot be evaluated at compile-time
-  --> $DIR/static-drop-scope.rs:17:28
+  --> $DIR/static-drop-scope.rs:15:28
    |
 LL | static EARLY_DROP_S: i32 = (WithDtor, 0).1;
    |                            ^^^^^^^^^^^^^ - value is dropped here
@@ -43,7 +43,7 @@ LL | static EARLY_DROP_S: i32 = (WithDtor, 0).1;
    |                            statics cannot evaluate destructors
 
 error[E0493]: destructors cannot be evaluated at compile-time
-  --> $DIR/static-drop-scope.rs:20:27
+  --> $DIR/static-drop-scope.rs:18:27
    |
 LL | const EARLY_DROP_C: i32 = (WithDtor, 0).1;
    |                           ^^^^^^^^^^^^^ - value is dropped here
@@ -51,7 +51,7 @@ LL | const EARLY_DROP_C: i32 = (WithDtor, 0).1;
    |                           constants cannot evaluate destructors
 
 error[E0493]: destructors cannot be evaluated at compile-time
-  --> $DIR/static-drop-scope.rs:23:24
+  --> $DIR/static-drop-scope.rs:21:24
    |
 LL | const fn const_drop<T>(_: T) {}
    |                        ^      - value is dropped here
@@ -59,7 +59,7 @@ LL | const fn const_drop<T>(_: T) {}
    |                        constant functions cannot evaluate destructors
 
 error[E0493]: destructors cannot be evaluated at compile-time
-  --> $DIR/static-drop-scope.rs:27:5
+  --> $DIR/static-drop-scope.rs:25:5
    |
 LL |     (x, ()).1
    |     ^^^^^^^ constant functions cannot evaluate destructors
@@ -68,7 +68,7 @@ LL | }
    | - value is dropped here
 
 error[E0493]: destructors cannot be evaluated at compile-time
-  --> $DIR/static-drop-scope.rs:31:34
+  --> $DIR/static-drop-scope.rs:29:34
    |
 LL | const EARLY_DROP_C_OPTION: i32 = (Some(WithDtor), 0).1;
    |                                  ^^^^^^^^^^^^^^^^^^^ - value is dropped here
@@ -76,7 +76,7 @@ LL | const EARLY_DROP_C_OPTION: i32 = (Some(WithDtor), 0).1;
    |                                  constants cannot evaluate destructors
 
 error[E0493]: destructors cannot be evaluated at compile-time
-  --> $DIR/static-drop-scope.rs:36:43
+  --> $DIR/static-drop-scope.rs:34:43
    |
 LL | const EARLY_DROP_C_OPTION_CONSTANT: i32 = (HELPER, 0).1;
    |                                           ^^^^^^^^^^^ - value is dropped here
index efc6304a6f7426d3d7dd8a961e275939ec667ef5..a03ef590cb3a12a24305aa5bba19bd687b80b4fe 100644 (file)
@@ -45,13 +45,13 @@ fn main() {
         y: 8,
     };
 
-    let pt3 = PointF::<i32> { //~ ERROR this type alias takes 0 type arguments but 1 type argument was supplied
+    let pt3 = PointF::<i32> { //~ ERROR this type alias takes 0 generic arguments but 1 generic argument
         x: 9,  //~ ERROR mismatched types
         y: 10, //~ ERROR mismatched types
     };
 
     match (Point { x: 1, y: 2 }) {
-        PointF::<u32> { .. } => {} //~ ERROR this type alias takes 0 type arguments but 1 type argument was supplied
+        PointF::<u32> { .. } => {} //~ ERROR this type alias takes 0 generic arguments but 1 generic argument
         //~^ ERROR mismatched types
     }
 
index 6438127868133b277c24af7e9a1bf4b50fe25d7f..3d64fc601df988f32052207bbcddca2a85ebed28 100644 (file)
@@ -52,15 +52,15 @@ LL |         x: 7,
    |            expected `f32`, found integer
    |            help: use a float literal: `7.0`
 
-error[E0107]: this type alias takes 0 type arguments but 1 type argument was supplied
+error[E0107]: this type alias takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/structure-constructor-type-mismatch.rs:48:15
    |
 LL |     let pt3 = PointF::<i32> {
    |               ^^^^^^------- help: remove these generics
    |               |
-   |               expected 0 type arguments
+   |               expected 0 generic arguments
    |
-note: type alias defined here, with 0 type parameters
+note: type alias defined here, with 0 generic parameters
   --> $DIR/structure-constructor-type-mismatch.rs:6:6
    |
 LL | type PointF = Point<f32>;
@@ -84,15 +84,15 @@ LL |         y: 10,
    |            expected `f32`, found integer
    |            help: use a float literal: `10.0`
 
-error[E0107]: this type alias takes 0 type arguments but 1 type argument was supplied
+error[E0107]: this type alias takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/structure-constructor-type-mismatch.rs:54:9
    |
 LL |         PointF::<u32> { .. } => {}
    |         ^^^^^^------- help: remove these generics
    |         |
-   |         expected 0 type arguments
+   |         expected 0 generic arguments
    |
-note: type alias defined here, with 0 type parameters
+note: type alias defined here, with 0 generic parameters
   --> $DIR/structure-constructor-type-mismatch.rs:6:6
    |
 LL | type PointF = Point<f32>;
index 0123e617c4f462f3c631bbe7b3b68b03b6ca5925..59e7cfc6f085ffb0bdf5f9ff8bf519d33abf57f5 100644 (file)
@@ -6,7 +6,7 @@ LL | |         "abc"
 LL | |     };
    | |______^ expected `&str`, found struct `String`
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index b1ea100f1646400a6671e2f9b338df22ad513e75..e15e7e905cf6745617b8833b5ffde9773821180c 100644 (file)
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
 LL |     assert_eq!(10u64, 10usize);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u64`, found `usize`
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/suggestions/issue-68049-1.rs b/src/test/ui/suggestions/issue-68049-1.rs
new file mode 100644 (file)
index 0000000..0acb7b1
--- /dev/null
@@ -0,0 +1,16 @@
+use std::alloc::{GlobalAlloc, Layout};
+
+struct Test(u32);
+
+unsafe impl GlobalAlloc for Test {
+    unsafe fn alloc(&self, _layout: Layout) -> *mut u8 {
+        self.0 += 1; //~ ERROR cannot assign
+        0 as *mut u8
+    }
+
+    unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {
+        unimplemented!();
+    }
+}
+
+fn main() { }
diff --git a/src/test/ui/suggestions/issue-68049-1.stderr b/src/test/ui/suggestions/issue-68049-1.stderr
new file mode 100644 (file)
index 0000000..32367d2
--- /dev/null
@@ -0,0 +1,9 @@
+error[E0594]: cannot assign to `self.0` which is behind a `&` reference
+  --> $DIR/issue-68049-1.rs:7:9
+   |
+LL |         self.0 += 1;
+   |         ^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0594`.
diff --git a/src/test/ui/suggestions/issue-68049-2.rs b/src/test/ui/suggestions/issue-68049-2.rs
new file mode 100644 (file)
index 0000000..1c3430c
--- /dev/null
@@ -0,0 +1,21 @@
+trait Hello {
+  fn example(&self, input: &i32); // should suggest here
+}
+
+struct Test1(i32);
+
+impl Hello for Test1 {
+  fn example(&self, input: &i32) { // should not suggest here
+      *input = self.0; //~ ERROR cannot assign
+  }
+}
+
+struct Test2(i32);
+
+impl Hello for Test2 {
+  fn example(&self, input: &i32) { // should not suggest here
+    self.0 += *input; //~ ERROR cannot assign
+  }
+}
+
+fn main() { }
diff --git a/src/test/ui/suggestions/issue-68049-2.stderr b/src/test/ui/suggestions/issue-68049-2.stderr
new file mode 100644 (file)
index 0000000..f10a83c
--- /dev/null
@@ -0,0 +1,21 @@
+error[E0594]: cannot assign to `*input` which is behind a `&` reference
+  --> $DIR/issue-68049-2.rs:9:7
+   |
+LL |   fn example(&self, input: &i32); // should suggest here
+   |                            ---- help: consider changing that to be a mutable reference: `&mut i32`
+...
+LL |       *input = self.0;
+   |       ^^^^^^^^^^^^^^^ `input` is a `&` reference, so the data it refers to cannot be written
+
+error[E0594]: cannot assign to `self.0` which is behind a `&` reference
+  --> $DIR/issue-68049-2.rs:17:5
+   |
+LL |   fn example(&self, input: &i32); // should suggest here
+   |              ----- help: consider changing that to be a mutable reference: `&mut self`
+...
+LL |     self.0 += *input;
+   |     ^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0594`.
index 761922beb17d580353f393afc9d52ba1e6ad8aac..4aaac2d95d44793907e0fb459cc79a19405d66c5 100644 (file)
@@ -16,44 +16,44 @@ trait Tar<'t, 'k, I> {}
 
 thread_local! {
     static a: RefCell<HashMap<i32, Vec<Vec<Foo>>>> = RefCell::new(HashMap::new());
-    //~^ ERROR missing lifetime specifier
-    //~| ERROR missing lifetime specifier
+      //~^ ERROR missing lifetime specifiers
+      //~| ERROR missing lifetime specifiers
 }
 thread_local! {
     static b: RefCell<HashMap<i32, Vec<Vec<&Bar>>>> = RefCell::new(HashMap::new());
-    //~^ ERROR missing lifetime specifier
-    //~| ERROR missing lifetime specifier
-    //~| ERROR missing lifetime specifier
-    //~| ERROR missing lifetime specifier
+      //~^ ERROR missing lifetime specifier
+      //~| ERROR missing lifetime specifier
+      //~| ERROR missing lifetime specifier
+      //~| ERROR missing lifetime specifier
 }
 thread_local! {
     static c: RefCell<HashMap<i32, Vec<Vec<Qux<i32>>>>> = RefCell::new(HashMap::new());
-    //~^ ERROR missing lifetime specifier
-    //~| ERROR missing lifetime specifier
+    //~^ ERROR missing lifetime
+    //~| ERROR missing lifetime
 }
 thread_local! {
     static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32>>>>> = RefCell::new(HashMap::new());
-    //~^ ERROR missing lifetime specifier
-    //~| ERROR missing lifetime specifier
-    //~| ERROR missing lifetime specifier
-    //~| ERROR missing lifetime specifier
+    //~^ ERROR missing lifetime
+    //~| ERROR missing lifetime
+    //~| ERROR missing lifetime
+    //~| ERROR missing lifetime
 }
 
 thread_local! {
     static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, i32>>>>> = RefCell::new(HashMap::new());
-    //~^ ERROR this union takes 2 lifetime arguments but only 1 lifetime argument was supplied
-    //~| ERROR this union takes 2 lifetime arguments but only 1 lifetime argument was supplied
-    //~| ERROR this union takes 2 lifetime arguments but only 1 lifetime argument was supplied
-    //~| ERROR this union takes 2 lifetime arguments but only 1 lifetime argument was supplied
+    //~^ ERROR this union takes 2 lifetime arguments but 1 lifetime argument
+    //~| ERROR this union takes 2 lifetime arguments but 1 lifetime argument was supplied
+    //~| ERROR this union takes 2 lifetime arguments but 1 lifetime argument was supplied
+    //~| ERROR this union takes 2 lifetime arguments but 1 lifetime argument was supplied
 }
 thread_local! {
     static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
-    //~^ ERROR this trait takes 2 lifetime arguments but only 1 lifetime argument was supplied
-    //~| ERROR this trait takes 2 lifetime arguments but only 1 lifetime argument was supplied
-    //~| ERROR this trait takes 2 lifetime arguments but only 1 lifetime argument was supplied
-    //~| ERROR this trait takes 2 lifetime arguments but only 1 lifetime argument was supplied
-    //~| ERROR missing lifetime specifier
-    //~| ERROR missing lifetime specifier
+    //~^ ERROR this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
+    //~| ERROR this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
+    //~| ERROR this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
+    //~| ERROR this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
+    //~| ERROR missing lifetime
+    //~| ERROR missing lifetime
 }
 
 fn main() {}
index 489926ea78a9d5f93a63f8d0ce248aa5cad53a97..8ddd2f7d52221fa585f94a725180a760dfda1d5e 100644 (file)
@@ -142,7 +142,7 @@ help: consider using the `'static` lifetime
 LL |     static d: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'static, i32>>>>> = RefCell::new(HashMap::new());
    |                                                 ^^^^^^^^^^^^^^^^^
 
-error[E0107]: this union takes 2 lifetime arguments but only 1 lifetime argument was supplied
+error[E0107]: this union takes 2 lifetime arguments but 1 lifetime argument was supplied
   --> $DIR/missing-lifetime-specifier.rs:43:44
    |
 LL |     static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, i32>>>>> = RefCell::new(HashMap::new());
@@ -157,10 +157,10 @@ LL | pub union Qux<'t, 'k, I> {
    |           ^^^ --  --
 help: add missing lifetime argument
    |
-LL |     static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'k, i32>>>>> = RefCell::new(HashMap::new());
+LL |     static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, '_, i32>>>>> = RefCell::new(HashMap::new());
    |                                                       ^^^^
 
-error[E0107]: this union takes 2 lifetime arguments but only 1 lifetime argument was supplied
+error[E0107]: this union takes 2 lifetime arguments but 1 lifetime argument was supplied
   --> $DIR/missing-lifetime-specifier.rs:43:44
    |
 LL |     static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, i32>>>>> = RefCell::new(HashMap::new());
@@ -178,7 +178,7 @@ help: add missing lifetime argument
 LL |     static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'k, i32>>>>> = RefCell::new(HashMap::new());
    |                                                       ^^^^
 
-error[E0107]: this union takes 2 lifetime arguments but only 1 lifetime argument was supplied
+error[E0107]: this union takes 2 lifetime arguments but 1 lifetime argument was supplied
   --> $DIR/missing-lifetime-specifier.rs:43:44
    |
 LL |     static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, i32>>>>> = RefCell::new(HashMap::new());
@@ -196,7 +196,7 @@ help: add missing lifetime argument
 LL |     static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'k, i32>>>>> = RefCell::new(HashMap::new());
    |                                                       ^^^^
 
-error[E0107]: this union takes 2 lifetime arguments but only 1 lifetime argument was supplied
+error[E0107]: this union takes 2 lifetime arguments but 1 lifetime argument was supplied
   --> $DIR/missing-lifetime-specifier.rs:43:44
    |
 LL |     static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, i32>>>>> = RefCell::new(HashMap::new());
@@ -211,10 +211,10 @@ LL | pub union Qux<'t, 'k, I> {
    |           ^^^ --  --
 help: add missing lifetime argument
    |
-LL |     static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'k, i32>>>>> = RefCell::new(HashMap::new());
+LL |     static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, '_, i32>>>>> = RefCell::new(HashMap::new());
    |                                                       ^^^^
 
-error[E0107]: this trait takes 2 lifetime arguments but only 1 lifetime argument was supplied
+error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
   --> $DIR/missing-lifetime-specifier.rs:50:45
    |
 LL |     static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
@@ -229,7 +229,7 @@ LL | trait Tar<'t, 'k, I> {}
    |       ^^^ --  --
 help: add missing lifetime argument
    |
-LL |     static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'k, i32>>>>> = RefCell::new(HashMap::new());
+LL |     static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, '_, i32>>>>> = RefCell::new(HashMap::new());
    |                                                        ^^^^
 
 error[E0106]: missing lifetime specifier
@@ -244,7 +244,7 @@ help: consider using the `'static` lifetime
 LL |     static f: RefCell<HashMap<i32, Vec<Vec<&'static Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
    |                                            ^^^^^^^^
 
-error[E0107]: this trait takes 2 lifetime arguments but only 1 lifetime argument was supplied
+error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
   --> $DIR/missing-lifetime-specifier.rs:50:45
    |
 LL |     static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
@@ -274,7 +274,7 @@ help: consider using the `'static` lifetime
 LL |     static f: RefCell<HashMap<i32, Vec<Vec<&'static Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
    |                                            ^^^^^^^^
 
-error[E0107]: this trait takes 2 lifetime arguments but only 1 lifetime argument was supplied
+error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
   --> $DIR/missing-lifetime-specifier.rs:50:45
    |
 LL |     static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
@@ -292,7 +292,7 @@ help: add missing lifetime argument
 LL |     static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'k, i32>>>>> = RefCell::new(HashMap::new());
    |                                                        ^^^^
 
-error[E0107]: this trait takes 2 lifetime arguments but only 1 lifetime argument was supplied
+error[E0107]: this trait takes 2 lifetime arguments but 1 lifetime argument was supplied
   --> $DIR/missing-lifetime-specifier.rs:50:45
    |
 LL |     static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new());
@@ -307,7 +307,7 @@ LL | trait Tar<'t, 'k, I> {}
    |       ^^^ --  --
 help: add missing lifetime argument
    |
-LL |     static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, 'k, i32>>>>> = RefCell::new(HashMap::new());
+LL |     static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, '_, i32>>>>> = RefCell::new(HashMap::new());
    |                                                        ^^^^
 
 error: aborting due to 22 previous errors
index b8ef230b44bb7661f2408aafcab9da07eb3cddb2..a9b06214fe8c6db570d2d34c887ee2cdd773eb79 100644 (file)
@@ -47,7 +47,7 @@ LL | pub struct BufWriter<W: Write> {
    = note: the following trait bounds were not satisfied:
            `&dyn std::io::Write: std::io::Write`
            which is required by `BufWriter<&dyn std::io::Write>: std::io::Write`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `writeln` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 4 previous errors
 
index 3ee2860b4ffc7033b91131d17c06ce1bb59b5116..80ed1cdedf1e7972b8e58cee1e4626096478572a 100644 (file)
@@ -8,7 +8,7 @@ LL |     println!("{}", path);
    = note: call `.display()` or `.to_string_lossy()` to safely print paths, as they may contain non-Unicode data
    = note: required because of the requirements on the impl of `std::fmt::Display` for `&Path`
    = note: required by `std::fmt::Display::fmt`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 05e2d38c43b53c94026f03140dba8a4db075cae9..8b6e8cfd720be6cf213eb762e3ed999f04202555 100644 (file)
@@ -6,7 +6,7 @@ pub trait T<X, Y> {
 pub struct Foo {
     i: Box<dyn T<usize, usize, usize, usize, B=usize>>,
     //~^ ERROR must be specified
-    //~| ERROR this trait takes 2 type arguments but 4 type arguments were supplied
+    //~| ERROR this trait takes 2 generic arguments but 4 generic arguments were supplied
 }
 
 
index 2d06591f4c7bd6e44a71b4034c5d03054c66d764..f1248643105eba7e30c2626ff3a9985ecf8b6610 100644 (file)
@@ -1,12 +1,12 @@
-error[E0107]: this trait takes 2 type arguments but 4 type arguments were supplied
+error[E0107]: this trait takes 2 generic arguments but 4 generic arguments were supplied
   --> $DIR/use-type-argument-instead-of-assoc-type.rs:7:16
    |
 LL |     i: Box<dyn T<usize, usize, usize, usize, B=usize>>,
-   |                ^             -------------- help: remove these type arguments
+   |                ^               ------------ help: remove these generic arguments
    |                |
-   |                expected 2 type arguments
+   |                expected 2 generic arguments
    |
-note: trait defined here, with 2 type parameters: `X`, `Y`
+note: trait defined here, with 2 generic parameters: `X`, `Y`
   --> $DIR/use-type-argument-instead-of-assoc-type.rs:1:11
    |
 LL | pub trait T<X, Y> {
index c9888dc54dc52a3b6d678751e679fade68dde16f..7523a931dd58f172ae7fda97408de4ce92d18462 100644 (file)
@@ -2,17 +2,17 @@ error[E0107]: missing generics for enum `Quux`
   --> $DIR/tag-type-args.rs:3:11
    |
 LL | fn foo(c: Quux) { assert!((false)); }
-   |           ^^^^ expected 1 type argument
+   |           ^^^^ expected 1 generic argument
    |
-note: enum defined here, with 1 type parameter: `T`
+note: enum defined here, with 1 generic parameter: `T`
   --> $DIR/tag-type-args.rs:1:6
    |
 LL | enum Quux<T> { Bar }
    |      ^^^^ -
-help: use angle brackets to add missing type argument
+help: add missing generic argument
    |
 LL | fn foo(c: Quux<T>) { assert!((false)); }
-   |               ^^^
+   |           ^^^^^^^
 
 error: aborting due to previous error
 
index 313d39de36b6a98d6f156642c9049a109c4f1d0d..547e5445aa1b63f3207db8a157b708dc2c066134 100644 (file)
@@ -1,4 +1,4 @@
-#![feature(const_fn, thread_local)]
+#![feature(thread_local)]
 
 #[thread_local]
 static A: u32 = 1;
index b237b1c480e3a6b73aa599a5054c76be8d55ffbf..4d3c4e8accd8888bbfb535927bf773387322b6da 100644 (file)
@@ -1,4 +1,4 @@
-#![feature(cfg_target_thread_local, const_fn, thread_local)]
+#![feature(cfg_target_thread_local, thread_local)]
 #![crate_type = "lib"]
 
 #[cfg(target_thread_local)]
diff --git a/src/test/ui/threads-sendsync/issue-43733.mir.stderr b/src/test/ui/threads-sendsync/issue-43733.mir.stderr
new file mode 100644 (file)
index 0000000..0f4b593
--- /dev/null
@@ -0,0 +1,19 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/issue-43733.rs:17:5
+   |
+LL |     __KEY.get(Default::default)
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/issue-43733.rs:20:42
+   |
+LL | static FOO: std::thread::LocalKey<Foo> = std::thread::LocalKey::new(__getit);
+   |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0133`.
index a602d7667c48dd2201f643590f87d8e122075efe..5434140cd61280b7bc7f6d06eed501b815aac9f3 100644 (file)
@@ -1,4 +1,6 @@
-#![feature(const_fn)]
+// revisions: mir thir
+// [thir]compile-flags: -Z thir-unsafeck
+
 #![feature(thread_local)]
 #![feature(cfg_target_thread_local, thread_local_internals)]
 
@@ -6,26 +8,24 @@
 
 #[cfg(target_thread_local)]
 #[thread_local]
-static __KEY: std::thread::__FastLocalKeyInner<Foo> =
-    std::thread::__FastLocalKeyInner::new();
+static __KEY: std::thread::__FastLocalKeyInner<Foo> = std::thread::__FastLocalKeyInner::new();
 
 #[cfg(not(target_thread_local))]
-static __KEY: std::thread::__OsLocalKeyInner<Foo> =
-    std::thread::__OsLocalKeyInner::new();
+static __KEY: std::thread::__OsLocalKeyInner<Foo> = std::thread::__OsLocalKeyInner::new();
 
-fn __getit() -> std::option::Option<&'static Foo>
-{
+fn __getit() -> std::option::Option<&'static Foo> {
     __KEY.get(Default::default) //~ ERROR call to unsafe function is unsafe
 }
 
-static FOO: std::thread::LocalKey<Foo> =
-    std::thread::LocalKey::new(__getit);
+static FOO: std::thread::LocalKey<Foo> = std::thread::LocalKey::new(__getit);
 //~^ ERROR call to unsafe function is unsafe
 
 fn main() {
     FOO.with(|foo| println!("{}", foo.borrow()));
     std::thread::spawn(|| {
         FOO.with(|foo| *foo.borrow_mut() += "foo");
-    }).join().unwrap();
+    })
+    .join()
+    .unwrap();
     FOO.with(|foo| println!("{}", foo.borrow()));
 }
diff --git a/src/test/ui/threads-sendsync/issue-43733.stderr b/src/test/ui/threads-sendsync/issue-43733.stderr
deleted file mode 100644 (file)
index ee6a3b0..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/issue-43733.rs:18:5
-   |
-LL |     __KEY.get(Default::default)
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
-   |
-   = note: consult the function's documentation for information on how to avoid undefined behavior
-
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/issue-43733.rs:22:5
-   |
-LL |     std::thread::LocalKey::new(__getit);
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
-   |
-   = note: consult the function's documentation for information on how to avoid undefined behavior
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0133`.
diff --git a/src/test/ui/threads-sendsync/issue-43733.thir.stderr b/src/test/ui/threads-sendsync/issue-43733.thir.stderr
new file mode 100644 (file)
index 0000000..0f4b593
--- /dev/null
@@ -0,0 +1,19 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/issue-43733.rs:17:5
+   |
+LL |     __KEY.get(Default::default)
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/issue-43733.rs:20:42
+   |
+LL | static FOO: std::thread::LocalKey<Foo> = std::thread::LocalKey::new(__getit);
+   |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0133`.
diff --git a/src/test/ui/traits/cache-reached-depth-ice.rs b/src/test/ui/traits/cache-reached-depth-ice.rs
new file mode 100644 (file)
index 0000000..4318e07
--- /dev/null
@@ -0,0 +1,45 @@
+#![feature(rustc_attrs)]
+
+// Test for a particular corner case where the evaluation
+// cache can get out of date. The problem here is that
+// when we cache C, we have observed that it reaches
+// to depth 2 (the node for B), but we later realize
+// that B itself depends on A (reached depth 0). We
+// failed to update the depth for C transitively, which
+// resulted in an assertion failure when it was referenced
+// from D.
+//
+// A (reached depth 0)
+//   E
+//      B // depth 2 -- reached depth = 0
+//          C // depth 3 -- reached depth = 2 (should be 0)
+//              B
+//          A // depth 0
+//   D (depth 1)
+//      C (cache -- reached depth = 2)
+
+struct A {
+    e: E,
+    d: C,
+}
+
+struct E {
+    b: B,
+}
+
+struct B {
+    a: Option<Box<A>>,
+    c: C,
+}
+
+struct C {
+    b: Option<Box<B>>,
+}
+
+#[rustc_evaluate_where_clauses]
+fn test<X: ?Sized + Send>() {}
+
+fn main() {
+    test::<A>();
+    //~^ ERROR evaluate(Binder(TraitPredicate(<A as std::marker::Send>), [])) = Ok(EvaluatedToOk)
+}
diff --git a/src/test/ui/traits/cache-reached-depth-ice.stderr b/src/test/ui/traits/cache-reached-depth-ice.stderr
new file mode 100644 (file)
index 0000000..5e66297
--- /dev/null
@@ -0,0 +1,11 @@
+error: evaluate(Binder(TraitPredicate(<A as std::marker::Send>), [])) = Ok(EvaluatedToOk)
+  --> $DIR/cache-reached-depth-ice.rs:43:5
+   |
+LL | fn test<X: ?Sized + Send>() {}
+   |                     ---- predicate
+...
+LL |     test::<A>();
+   |     ^^^^^^^^^
+
+error: aborting due to previous error
+
index ba47fdb152239fcb2a6656c3affa9f52436ccf1d..d1be955b41ed64fa2e50692adcb0ac09c7c1b713 100644 (file)
@@ -6,7 +6,7 @@ LL |     the_foos: Vec<Foo>,
    |
    = note: required because of the requirements on the impl of `Clone` for `Vec<Foo>`
    = note: required by `clone`
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 92d9ac0f84c990a622e6fb149688f595c1835f60..432ddf2dcdbdc3d101f5fb35cbcf9cfc1f253d5c 100644 (file)
@@ -2,7 +2,9 @@ error[E0412]: cannot find type `T` in this scope
   --> $DIR/issue-75627.rs:3:26
    |
 LL | unsafe impl Send for Foo<T> {}
-   |                          ^ not found in this scope
+   |            -             ^ not found in this scope
+   |            |
+   |            help: you might be missing a type parameter: `<T>`
 
 error: aborting due to previous error
 
index 9267e838ceae917f839578f08d9396950f904381..e63740c4ea928df9dc9a59faf8cfa7280735ef61 100644 (file)
@@ -13,9 +13,18 @@ error[E0412]: cannot find type `U` in this scope
   --> $DIR/issue-78372.rs:3:31
    |
 LL | impl<T> DispatchFromDyn<Smaht<U, MISC>> for T {}
-   |      -                        ^ help: a type parameter with a similar name exists: `T`
+   |      -                        ^
    |      |
    |      similarly named type parameter `T` defined here
+   |
+help: a type parameter with a similar name exists
+   |
+LL | impl<T> DispatchFromDyn<Smaht<T, MISC>> for T {}
+   |                               ^
+help: you might be missing a type parameter
+   |
+LL | impl<T, U> DispatchFromDyn<Smaht<U, MISC>> for T {}
+   |       ^^^
 
 error[E0412]: cannot find type `MISC` in this scope
   --> $DIR/issue-78372.rs:3:34
index 54947b57c03b1b5bb82bc6bda1f25ab4619f705f..7e990cdc34e25fbda74db60ceb4aa8ffe21bd22e 100644 (file)
@@ -8,7 +8,7 @@ LL |     bar: &'a mut T
              <&T as Clone>
    = note: `Clone` is implemented for `&T`, but not for `&mut T`
    = note: required by `clone`
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/traits/issue-83538-tainted-cache-after-cycle.rs b/src/test/ui/traits/issue-83538-tainted-cache-after-cycle.rs
new file mode 100644 (file)
index 0000000..e186570
--- /dev/null
@@ -0,0 +1,66 @@
+// Regression test for issue #83538. The problem here is that we have
+// two cycles:
+//
+// * `Ty` embeds `Box<Ty>` indirectly, which depends on `Global: 'static`, which is OkModuloRegions.
+// * But `Ty` also references `First`, which has a cycle on itself. That should just be `Ok`.
+//
+// But our caching mechanism was blending both cycles and giving the incorrect result.
+
+#![feature(rustc_attrs)]
+#![allow(bad_style)]
+
+struct First {
+    b: Vec<First>,
+}
+
+pub struct Second {
+    d: Vec<First>,
+}
+
+struct Third<f> {
+    g: Vec<f>,
+}
+
+enum Ty {
+    j(Fourth, Fifth, Sixth),
+}
+
+struct Fourth {
+    o: Vec<Ty>,
+}
+
+struct Fifth {
+    bounds: First,
+}
+
+struct Sixth {
+    p: Box<Ty>,
+}
+
+#[rustc_evaluate_where_clauses]
+fn forward()
+where
+    Vec<First>: Unpin,
+    Third<Ty>: Unpin,
+{
+}
+
+#[rustc_evaluate_where_clauses]
+fn reverse()
+where
+    Third<Ty>: Unpin,
+    Vec<First>: Unpin,
+{
+}
+
+fn main() {
+    // Key is that Vec<First> is "ok" and Third<Ty> is "ok modulo regions":
+
+    forward();
+    //~^ ERROR evaluate(Binder(TraitPredicate(<std::vec::Vec<First> as std::marker::Unpin>), [])) = Ok(EvaluatedToOk)
+    //~| ERROR evaluate(Binder(TraitPredicate(<Third<Ty> as std::marker::Unpin>), [])) = Ok(EvaluatedToOkModuloRegions)
+
+    reverse();
+    //~^ ERROR evaluate(Binder(TraitPredicate(<std::vec::Vec<First> as std::marker::Unpin>), [])) = Ok(EvaluatedToOk)
+    //~| ERROR evaluate(Binder(TraitPredicate(<Third<Ty> as std::marker::Unpin>), [])) = Ok(EvaluatedToOkModuloRegions)
+}
diff --git a/src/test/ui/traits/issue-83538-tainted-cache-after-cycle.stderr b/src/test/ui/traits/issue-83538-tainted-cache-after-cycle.stderr
new file mode 100644 (file)
index 0000000..bfe3e76
--- /dev/null
@@ -0,0 +1,38 @@
+error: evaluate(Binder(TraitPredicate(<std::vec::Vec<First> as std::marker::Unpin>), [])) = Ok(EvaluatedToOk)
+  --> $DIR/issue-83538-tainted-cache-after-cycle.rs:59:5
+   |
+LL |     Vec<First>: Unpin,
+   |                 ----- predicate
+...
+LL |     forward();
+   |     ^^^^^^^
+
+error: evaluate(Binder(TraitPredicate(<Third<Ty> as std::marker::Unpin>), [])) = Ok(EvaluatedToOkModuloRegions)
+  --> $DIR/issue-83538-tainted-cache-after-cycle.rs:59:5
+   |
+LL |     Third<Ty>: Unpin,
+   |                ----- predicate
+...
+LL |     forward();
+   |     ^^^^^^^
+
+error: evaluate(Binder(TraitPredicate(<Third<Ty> as std::marker::Unpin>), [])) = Ok(EvaluatedToOkModuloRegions)
+  --> $DIR/issue-83538-tainted-cache-after-cycle.rs:63:5
+   |
+LL |     Third<Ty>: Unpin,
+   |                ----- predicate
+...
+LL |     reverse();
+   |     ^^^^^^^
+
+error: evaluate(Binder(TraitPredicate(<std::vec::Vec<First> as std::marker::Unpin>), [])) = Ok(EvaluatedToOk)
+  --> $DIR/issue-83538-tainted-cache-after-cycle.rs:63:5
+   |
+LL |     Vec<First>: Unpin,
+   |                 ----- predicate
+...
+LL |     reverse();
+   |     ^^^^^^^
+
+error: aborting due to 4 previous errors
+
index e49d276a55a92b5bd3e092994be6201f11776016..14ae67cffd703dfcad7f0116f1c1ef9311c3cf95 100644 (file)
@@ -10,7 +10,7 @@ fn main() {
     //~^ at least one trait is required for an object type
     let _: S<'static, 'static>;
     //~^ ERROR this struct takes 1 lifetime argument but 2 lifetime arguments were supplied
-    //~| ERROR this struct takes 1 type argument but 0 type arguments were supplied
+    //~| ERROR this struct takes 1 generic argument but 0 generic arguments were supplied
     let _: S<dyn 'static +, 'static>;
     //~^ ERROR type provided when a lifetime was expected
     //~| ERROR at least one trait is required for an object type
index 6673472e4a9674d1e58c7c0100b7a466af03594f..40f5fcbceaf0b0a5613e3eebc36a5b2c78cd27cf 100644 (file)
@@ -8,7 +8,7 @@ error[E0107]: this struct takes 1 lifetime argument but 2 lifetime arguments wer
   --> $DIR/vs-lifetime.rs:11:12
    |
 LL |     let _: S<'static, 'static>;
-   |            ^        --------- help: remove this lifetime argument
+   |            ^          ------- help: remove this lifetime argument
    |            |
    |            expected 1 lifetime argument
    |
@@ -18,18 +18,18 @@ note: struct defined here, with 1 lifetime parameter: `'a`
 LL | struct S<'a, T>(&'a u8, T);
    |        ^ --
 
-error[E0107]: this struct takes 1 type argument but 0 type arguments were supplied
+error[E0107]: this struct takes 1 generic argument but 0 generic arguments were supplied
   --> $DIR/vs-lifetime.rs:11:12
    |
 LL |     let _: S<'static, 'static>;
-   |            ^ expected 1 type argument
+   |            ^ expected 1 generic argument
    |
-note: struct defined here, with 1 type parameter: `T`
+note: struct defined here, with 1 generic parameter: `T`
   --> $DIR/vs-lifetime.rs:4:8
    |
 LL | struct S<'a, T>(&'a u8, T);
    |        ^     -
-help: add missing type argument
+help: add missing generic argument
    |
 LL |     let _: S<'static, 'static, T>;
    |                              ^^^
index a33773144c21b8d2088fd2dba45153750f0cb742..183c779607c9510a09c1e948ea9811443e65b2cf 100644 (file)
@@ -7,9 +7,9 @@ impl bar for u32 { fn dup(&self) -> u32 { *self } fn blah<X>(&self) {} }
 
 fn main() {
     10.dup::<i32>();
-    //~^ ERROR this associated function takes 0 type arguments but 1 type argument was supplied
+    //~^ ERROR this associated function takes 0 generic arguments but 1
     10.blah::<i32, i32>();
-    //~^ ERROR this associated function takes 1 type argument but 2 type arguments were supplied
+    //~^ ERROR this associated function takes 1 generic argument but 2
     (box 10 as Box<dyn bar>).dup();
     //~^ ERROR E0038
     //~| ERROR E0038
index 12b55c3a4fdf9e87159657eb1657d73b81aa6977..0289424510f9781cebb0e0ecc267897e5d9ad9ab 100644 (file)
@@ -1,26 +1,26 @@
-error[E0107]: this associated function takes 0 type arguments but 1 type argument was supplied
+error[E0107]: this associated function takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/test-2.rs:9:8
    |
 LL |     10.dup::<i32>();
    |        ^^^------- help: remove these generics
    |        |
-   |        expected 0 type arguments
+   |        expected 0 generic arguments
    |
-note: associated function defined here, with 0 type parameters
+note: associated function defined here, with 0 generic parameters
   --> $DIR/test-2.rs:4:16
    |
 LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); }
    |                ^^^
 
-error[E0107]: this associated function takes 1 type argument but 2 type arguments were supplied
+error[E0107]: this associated function takes 1 generic argument but 2 generic arguments were supplied
   --> $DIR/test-2.rs:11:8
    |
 LL |     10.blah::<i32, i32>();
-   |        ^^^^      ----- help: remove this type argument
+   |        ^^^^        --- help: remove this generic argument
    |        |
-   |        expected 1 type argument
+   |        expected 1 generic argument
    |
-note: associated function defined here, with 1 type parameter: `X`
+note: associated function defined here, with 1 generic parameter: `X`
   --> $DIR/test-2.rs:4:39
    |
 LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); }
index 6bae3a8587df038925e09450bf9ecc63942867e5..58eb076bba3f1ef22a529e41de9f1044d28a24b6 100644 (file)
@@ -4,7 +4,7 @@ error[E0381]: borrow of possibly-uninitialized variable: `cfg_res`
 LL |     assert_eq!(cfg_res, 5);
    |     ^^^^^^^^^^^^^^^^^^^^^^^ use of possibly-uninitialized `cfg_res`
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index d6ea3626675d82ca0117b8778b0b17b34cd1559c..64a9ac13566f722f3868dd2d2739d4d71f6eb5b5 100644 (file)
@@ -9,7 +9,7 @@ LL |         struct S3(pub $t ());
 LL |     define_struct! { (foo) }
    |     ------------------------ in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `define_struct` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0412]: cannot find type `foo` in this scope
   --> $DIR/test2.rs:11:23
index b38513e5a92a3c4b73fe268360b9ef72befe243c..75262ed5780e07982a3b4baaebf61e5d0de67769 100644 (file)
@@ -9,7 +9,7 @@ LL |         struct S3(pub($t) ());
 LL |     define_struct! { foo }
    |     ---------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `define_struct` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0412]: cannot find type `foo` in this scope
   --> $DIR/test3.rs:11:22
index f204035248a6f16e178926bf53bad98190cbf701..6bc4f528faaf9092f705e0e308c6044f72ecb835 100644 (file)
@@ -62,10 +62,10 @@ fn main() {
     AliasFixed::TSVariant::<()>(());
     //~^ ERROR type arguments are not allowed for this type [E0109]
     AliasFixed::<()>::TSVariant(());
-    //~^ ERROR this type alias takes 0 type arguments but 1 type argument was supplied [E0107]
+    //~^ ERROR this type alias takes 0 generic arguments but 1 generic argument was supplied [E0107]
     AliasFixed::<()>::TSVariant::<()>(());
     //~^ ERROR type arguments are not allowed for this type [E0109]
-    //~| ERROR this type alias takes 0 type arguments but 1 type argument was supplied [E0107]
+    //~| ERROR this type alias takes 0 generic arguments but 1 generic argument was supplied [E0107]
 
     // Struct variant
 
@@ -80,10 +80,10 @@ fn main() {
     AliasFixed::SVariant::<()> { v: () };
     //~^ ERROR type arguments are not allowed for this type [E0109]
     AliasFixed::<()>::SVariant { v: () };
-    //~^ ERROR this type alias takes 0 type arguments but 1 type argument was supplied [E0107]
+    //~^ ERROR this type alias takes 0 generic arguments but 1 generic argument was supplied [E0107]
     AliasFixed::<()>::SVariant::<()> { v: () };
     //~^ ERROR type arguments are not allowed for this type [E0109]
-    //~| ERROR this type alias takes 0 type arguments but 1 type argument was supplied [E0107]
+    //~| ERROR this type alias takes 0 generic arguments but 1 generic argument was supplied [E0107]
 
     // Unit variant
 
@@ -98,8 +98,8 @@ fn main() {
     AliasFixed::UVariant::<()>;
     //~^ ERROR type arguments are not allowed for this type [E0109]
     AliasFixed::<()>::UVariant;
-    //~^ ERROR this type alias takes 0 type arguments but 1 type argument was supplied [E0107]
+    //~^ ERROR this type alias takes 0 generic arguments but 1 generic argument was supplied [E0107]
     AliasFixed::<()>::UVariant::<()>;
     //~^ ERROR type arguments are not allowed for this type [E0109]
-    //~| ERROR this type alias takes 0 type arguments but 1 type argument was supplied [E0107]
+    //~| ERROR this type alias takes 0 generic arguments but 1 generic argument was supplied [E0107]
 }
index e83db3b0d512ba99c6897e2a7735f555fb4f7504..a384d5f561c940e9d1d1b01d87443aec5c2d4e65 100644 (file)
@@ -166,29 +166,29 @@ error[E0109]: type arguments are not allowed for this type
 LL |     AliasFixed::TSVariant::<()>(());
    |                             ^^ type argument not allowed
 
-error[E0107]: this type alias takes 0 type arguments but 1 type argument was supplied
+error[E0107]: this type alias takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/enum-variant-generic-args.rs:64:5
    |
 LL |     AliasFixed::<()>::TSVariant(());
    |     ^^^^^^^^^^------ help: remove these generics
    |     |
-   |     expected 0 type arguments
+   |     expected 0 generic arguments
    |
-note: type alias defined here, with 0 type parameters
+note: type alias defined here, with 0 generic parameters
   --> $DIR/enum-variant-generic-args.rs:9:6
    |
 LL | type AliasFixed = Enum<()>;
    |      ^^^^^^^^^^
 
-error[E0107]: this type alias takes 0 type arguments but 1 type argument was supplied
+error[E0107]: this type alias takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/enum-variant-generic-args.rs:66:5
    |
 LL |     AliasFixed::<()>::TSVariant::<()>(());
    |     ^^^^^^^^^^------ help: remove these generics
    |     |
-   |     expected 0 type arguments
+   |     expected 0 generic arguments
    |
-note: type alias defined here, with 0 type parameters
+note: type alias defined here, with 0 generic parameters
   --> $DIR/enum-variant-generic-args.rs:9:6
    |
 LL | type AliasFixed = Enum<()>;
@@ -224,29 +224,29 @@ error[E0109]: type arguments are not allowed for this type
 LL |     AliasFixed::SVariant::<()> { v: () };
    |                            ^^ type argument not allowed
 
-error[E0107]: this type alias takes 0 type arguments but 1 type argument was supplied
+error[E0107]: this type alias takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/enum-variant-generic-args.rs:82:5
    |
 LL |     AliasFixed::<()>::SVariant { v: () };
    |     ^^^^^^^^^^------ help: remove these generics
    |     |
-   |     expected 0 type arguments
+   |     expected 0 generic arguments
    |
-note: type alias defined here, with 0 type parameters
+note: type alias defined here, with 0 generic parameters
   --> $DIR/enum-variant-generic-args.rs:9:6
    |
 LL | type AliasFixed = Enum<()>;
    |      ^^^^^^^^^^
 
-error[E0107]: this type alias takes 0 type arguments but 1 type argument was supplied
+error[E0107]: this type alias takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/enum-variant-generic-args.rs:84:5
    |
 LL |     AliasFixed::<()>::SVariant::<()> { v: () };
    |     ^^^^^^^^^^------ help: remove these generics
    |     |
-   |     expected 0 type arguments
+   |     expected 0 generic arguments
    |
-note: type alias defined here, with 0 type parameters
+note: type alias defined here, with 0 generic parameters
   --> $DIR/enum-variant-generic-args.rs:9:6
    |
 LL | type AliasFixed = Enum<()>;
@@ -282,29 +282,29 @@ error[E0109]: type arguments are not allowed for this type
 LL |     AliasFixed::UVariant::<()>;
    |                            ^^ type argument not allowed
 
-error[E0107]: this type alias takes 0 type arguments but 1 type argument was supplied
+error[E0107]: this type alias takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/enum-variant-generic-args.rs:100:5
    |
 LL |     AliasFixed::<()>::UVariant;
    |     ^^^^^^^^^^------ help: remove these generics
    |     |
-   |     expected 0 type arguments
+   |     expected 0 generic arguments
    |
-note: type alias defined here, with 0 type parameters
+note: type alias defined here, with 0 generic parameters
   --> $DIR/enum-variant-generic-args.rs:9:6
    |
 LL | type AliasFixed = Enum<()>;
    |      ^^^^^^^^^^
 
-error[E0107]: this type alias takes 0 type arguments but 1 type argument was supplied
+error[E0107]: this type alias takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/enum-variant-generic-args.rs:102:5
    |
 LL |     AliasFixed::<()>::UVariant::<()>;
    |     ^^^^^^^^^^------ help: remove these generics
    |     |
-   |     expected 0 type arguments
+   |     expected 0 generic arguments
    |
-note: type alias defined here, with 0 type parameters
+note: type alias defined here, with 0 generic parameters
   --> $DIR/enum-variant-generic-args.rs:9:6
    |
 LL | type AliasFixed = Enum<()>;
index fc474e1ec3b7593e7101f23725a5d22bb4b26a04..00449af6a459fab5375837f4182aa678429f0ccb 100644 (file)
@@ -14,17 +14,17 @@ error[E0107]: missing generics for struct `Vec`
   --> $DIR/issue-34255-1.rs:7:22
    |
 LL |         input_cells: Vec::new()
-   |                      ^^^ expected at least 1 type argument
+   |                      ^^^ expected at least 1 generic argument
    |
-note: struct defined here, with at least 1 type parameter: `T`
+note: struct defined here, with at least 1 generic parameter: `T`
   --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
    |
 LL | pub struct Vec<T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global> {
    |            ^^^ -
-help: use angle brackets to add missing type argument
+help: add missing generic argument
    |
 LL |         input_cells: Vec<T>::new()
-   |                         ^^^
+   |                      ^^^^^^
 
 error: aborting due to 3 previous errors
 
index 755eec23c2ee33e886d8b835f651b2be4c95ecef..59b3529272688cca09599f0d39e9713882dc2b3d 100644 (file)
@@ -10,7 +10,7 @@ LL |     let _ = Option:Some(vec![0, 1]);
    |                   help: maybe write a path separator here: `::`
    |
    = note: `#![feature(type_ascription)]` lets you annotate an expression with a type: `<expr>: <type>`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::__rust_force_expr` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 729a8c63b624036f5c0f9fde80e1c758d8e06af2..69a4af4672f913e14b059bd7872eb3e004159d48 100644 (file)
@@ -6,7 +6,7 @@ LL |     let x = vec![];
    |         |
    |         consider giving `x` the explicit type `Vec<T>`, where the type parameter `T` is specified
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index e24593a89b3bc8251a07c225e443e38ea9280c80..af7db43970442d68ad37063620951dafc95703b0 100644 (file)
@@ -6,7 +6,7 @@ LL |     let (x, ) = (vec![], );
    |         |
    |         consider giving this pattern the explicit type `(Vec<T>,)`, where the type parameter `T` is specified
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 3a59ca049ba3e8487dddc7416cb1b657a2af6a91..8cd34f48835edf27e4903cd4ea1777d794b446ec 100644 (file)
@@ -4,7 +4,7 @@ pub struct UI {}
 
 impl UI {
     pub fn run() -> Result<_> {
-        //~^ ERROR: this enum takes 2 type arguments but only 1 type argument was supplied
+        //~^ ERROR: this enum takes 2 generic arguments but 1 generic argument was supplied
         //~| ERROR: the type placeholder `_` is not allowed within types on item signatures
         let mut ui = UI {};
         ui.interact();
@@ -13,7 +13,7 @@ pub fn run() -> Result<_> {
     }
 
     pub fn interact(&mut self) -> Result<_> {
-        //~^ ERROR: this enum takes 2 type arguments but only 1 type argument was supplied
+        //~^ ERROR: this enum takes 2 generic arguments but 1 generic argument was supplied
         //~| ERROR: the type placeholder `_` is not allowed within types on item signatures
         unimplemented!();
     }
index a6b2eb8f9727cdeb4a75af55f175ae1bc34ec782..71f4138c81d56c08f7a8a282b7e24855340435d6 100644 (file)
@@ -1,35 +1,35 @@
-error[E0107]: this enum takes 2 type arguments but only 1 type argument was supplied
+error[E0107]: this enum takes 2 generic arguments but 1 generic argument was supplied
   --> $DIR/issue-75883.rs:6:21
    |
 LL |     pub fn run() -> Result<_> {
-   |                     ^^^^^^ - supplied 1 type argument
+   |                     ^^^^^^ - supplied 1 generic argument
    |                     |
-   |                     expected 2 type arguments
+   |                     expected 2 generic arguments
    |
-note: enum defined here, with 2 type parameters: `T`, `E`
+note: enum defined here, with 2 generic parameters: `T`, `E`
   --> $SRC_DIR/core/src/result.rs:LL:COL
    |
 LL | pub enum Result<T, E> {
    |          ^^^^^^ -  -
-help: add missing type argument
+help: add missing generic argument
    |
 LL |     pub fn run() -> Result<_, E> {
    |                             ^^^
 
-error[E0107]: this enum takes 2 type arguments but only 1 type argument was supplied
+error[E0107]: this enum takes 2 generic arguments but 1 generic argument was supplied
   --> $DIR/issue-75883.rs:15:35
    |
 LL |     pub fn interact(&mut self) -> Result<_> {
-   |                                   ^^^^^^ - supplied 1 type argument
+   |                                   ^^^^^^ - supplied 1 generic argument
    |                                   |
-   |                                   expected 2 type arguments
+   |                                   expected 2 generic arguments
    |
-note: enum defined here, with 2 type parameters: `T`, `E`
+note: enum defined here, with 2 generic parameters: `T`, `E`
   --> $SRC_DIR/core/src/result.rs:LL:COL
    |
 LL | pub enum Result<T, E> {
    |          ^^^^^^ -  -
-help: add missing type argument
+help: add missing generic argument
    |
 LL |     pub fn interact(&mut self) -> Result<_, E> {
    |                                           ^^^
index a30facfeb6daa8ee35a1fc57a4ce65880f04971c..7a1846529761cb34ae794edb7e36b7ba47c618bd 100644 (file)
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
 LL |   f(|x| lib::d!(x));
    |         ^^^^^^^^^^ expected `()`, found `i32`
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `lib::d` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0308]: mismatched types
   --> $DIR/issue-81943.rs:8:28
@@ -36,7 +36,7 @@ LL |   }
 LL |   f(|x| d!(x));
    |         ----- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `d` (in Nightly builds, run with -Z macro-backtrace for more info)
 help: consider using a semicolon here
    |
 LL |     ($e:expr) => { match $e { x => { g(x); } } }
index f1659d086702e8dddae5d6a57c353c04d91ec0c1..c463a8ad0c75789f50f9db67f17a96fff71b83b1 100644 (file)
@@ -1,17 +1,17 @@
 fn foo1<T:Copy<U>, U>(x: T) {}
-//~^ ERROR this trait takes 0 type arguments but 1 type argument was supplied
+//~^ ERROR this trait takes 0 generic arguments but 1 generic argument was supplied
 
 trait Trait: Copy<dyn Send> {}
-//~^ ERROR this trait takes 0 type arguments but 1 type argument was supplied
+//~^ ERROR this trait takes 0 generic arguments but 1 generic argument was supplied
 
 struct MyStruct1<T: Copy<T>>;
-//~^ ERROR this trait takes 0 type arguments but 1 type argument was supplied
+//~^ ERROR this trait takes 0 generic arguments but 1 generic argument was supplied
 
 struct MyStruct2<'a, T: Copy<'a>>;
 //~^ ERROR this trait takes 0 lifetime arguments but 1 lifetime argument was supplied
 
 fn foo2<'a, T:Copy<'a, U>, U>(x: T) {}
 //~^ ERROR this trait takes 0 lifetime arguments but 1 lifetime argument was supplied
-//~| ERROR this trait takes 0 type arguments but 1 type argument was supplied
+//~| ERROR this trait takes 0 generic arguments but 1 generic argument was supplied
 
 fn main() { }
index 777bc1c95b0b3e765ed6402a4b47a9599d50d6ba..bf74dd7dec0040ede852fdd6ab1bc4f8db2e2f2d 100644 (file)
@@ -1,40 +1,40 @@
-error[E0107]: this trait takes 0 type arguments but 1 type argument was supplied
+error[E0107]: this trait takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/typeck-builtin-bound-type-parameters.rs:1:11
    |
 LL | fn foo1<T:Copy<U>, U>(x: T) {}
    |           ^^^^--- help: remove these generics
    |           |
-   |           expected 0 type arguments
+   |           expected 0 generic arguments
    |
-note: trait defined here, with 0 type parameters
+note: trait defined here, with 0 generic parameters
   --> $SRC_DIR/core/src/marker.rs:LL:COL
    |
 LL | pub trait Copy: Clone {
    |           ^^^^
 
-error[E0107]: this trait takes 0 type arguments but 1 type argument was supplied
+error[E0107]: this trait takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/typeck-builtin-bound-type-parameters.rs:4:14
    |
 LL | trait Trait: Copy<dyn Send> {}
    |              ^^^^---------- help: remove these generics
    |              |
-   |              expected 0 type arguments
+   |              expected 0 generic arguments
    |
-note: trait defined here, with 0 type parameters
+note: trait defined here, with 0 generic parameters
   --> $SRC_DIR/core/src/marker.rs:LL:COL
    |
 LL | pub trait Copy: Clone {
    |           ^^^^
 
-error[E0107]: this trait takes 0 type arguments but 1 type argument was supplied
+error[E0107]: this trait takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/typeck-builtin-bound-type-parameters.rs:7:21
    |
 LL | struct MyStruct1<T: Copy<T>>;
    |                     ^^^^--- help: remove these generics
    |                     |
-   |                     expected 0 type arguments
+   |                     expected 0 generic arguments
    |
-note: trait defined here, with 0 type parameters
+note: trait defined here, with 0 generic parameters
   --> $SRC_DIR/core/src/marker.rs:LL:COL
    |
 LL | pub trait Copy: Clone {
@@ -58,7 +58,7 @@ error[E0107]: this trait takes 0 lifetime arguments but 1 lifetime argument was
   --> $DIR/typeck-builtin-bound-type-parameters.rs:13:15
    |
 LL | fn foo2<'a, T:Copy<'a, U>, U>(x: T) {}
-   |               ^^^^ ---- help: remove this lifetime argument
+   |               ^^^^ -- help: remove this lifetime argument
    |               |
    |               expected 0 lifetime arguments
    |
@@ -68,15 +68,15 @@ note: trait defined here, with 0 lifetime parameters
 LL | pub trait Copy: Clone {
    |           ^^^^
 
-error[E0107]: this trait takes 0 type arguments but 1 type argument was supplied
+error[E0107]: this trait takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/typeck-builtin-bound-type-parameters.rs:13:15
    |
 LL | fn foo2<'a, T:Copy<'a, U>, U>(x: T) {}
-   |               ^^^^   --- help: remove this type argument
+   |               ^^^^     - help: remove this generic argument
    |               |
-   |               expected 0 type arguments
+   |               expected 0 generic arguments
    |
-note: trait defined here, with 0 type parameters
+note: trait defined here, with 0 generic parameters
   --> $SRC_DIR/core/src/marker.rs:LL:COL
    |
 LL | pub trait Copy: Clone {
index 8f8917e16afdafff87ddd53de145597cedc91969..43e46c5b6c3d771c3f5cb81b734cedd1808fb384 100644 (file)
@@ -7,5 +7,5 @@ struct Foo<'a, T:'a> {
 
 pub fn main() {
     let c: Foo<_, _> = Foo { r: &5 };
-    //~^ ERROR this struct takes 1 type argument but 2 type arguments were supplied
+    //~^ ERROR this struct takes 1 generic argument but 2 generic arguments were supplied
 }
index 01ab8e78d7ca3fda7791ac851371c626f0a7504b..a89c6b85c78edc0ab925c2905a270327d36cb96b 100644 (file)
@@ -1,12 +1,12 @@
-error[E0107]: this struct takes 1 type argument but 2 type arguments were supplied
+error[E0107]: this struct takes 1 generic argument but 2 generic arguments were supplied
   --> $DIR/typeck_type_placeholder_lifetime_1.rs:9:12
    |
 LL |     let c: Foo<_, _> = Foo { r: &5 };
-   |            ^^^  --- help: remove this type argument
+   |            ^^^    - help: remove this generic argument
    |            |
-   |            expected 1 type argument
+   |            expected 1 generic argument
    |
-note: struct defined here, with 1 type parameter: `T`
+note: struct defined here, with 1 generic parameter: `T`
   --> $DIR/typeck_type_placeholder_lifetime_1.rs:4:8
    |
 LL | struct Foo<'a, T:'a> {
index b491a7e1a9caa20044e827c37e864be00ef81c12..178b8b1229a591850b332500d73f80e9ca84e25d 100644 (file)
@@ -7,5 +7,5 @@ struct Foo<'a, T:'a> {
 
 pub fn main() {
     let c: Foo<_, usize> = Foo { r: &5 };
-    //~^ ERROR this struct takes 1 type argument but 2 type arguments were supplied
+    //~^ ERROR this struct takes 1 generic argument but 2 generic arguments were supplied
 }
index 6d03b833c0f151413ba5247d0a8c2145a021a56a..f30766bdf0121a413bf89b3c5c27ae9ea2bbf9ee 100644 (file)
@@ -1,12 +1,12 @@
-error[E0107]: this struct takes 1 type argument but 2 type arguments were supplied
+error[E0107]: this struct takes 1 generic argument but 2 generic arguments were supplied
   --> $DIR/typeck_type_placeholder_lifetime_2.rs:9:12
    |
 LL |     let c: Foo<_, usize> = Foo { r: &5 };
-   |            ^^^  ------- help: remove this type argument
+   |            ^^^    ----- help: remove this generic argument
    |            |
-   |            expected 1 type argument
+   |            expected 1 generic argument
    |
-note: struct defined here, with 1 type parameter: `T`
+note: struct defined here, with 1 generic parameter: `T`
   --> $DIR/typeck_type_placeholder_lifetime_2.rs:4:8
    |
 LL | struct Foo<'a, T:'a> {
index 7d2fbdae6a2b2729a59b35e1cb8a1cacc922815e..766351634bb8af20293bac1bea6179d3b43db31d 100644 (file)
@@ -12,9 +12,9 @@ fn into_cow(self) -> Cow<'a, str> {
 
 fn main() {
     <String as IntoCow>::into_cow("foo".to_string());
-    //~^ ERROR missing generics for trait `IntoCow`
+      //~^ ERROR missing generics for
 
     <String as IntoCow>::into_cow::<str>("foo".to_string());
-    //~^ ERROR missing generics for trait `IntoCow`
-    //~| ERROR this associated function takes 0 type arguments but 1 type argument was supplied
+    //~^ ERROR this associated function takes 0 generic arguments but 1
+    //~| ERROR missing generics for
 }
index e3fcef3dc1bb202a092ba5332faf87f7ddafad14..37aa4d949daeaddbe395e3ebed546c0271495e6a 100644 (file)
@@ -2,43 +2,43 @@ error[E0107]: missing generics for trait `IntoCow`
   --> $DIR/ufcs-qpath-missing-params.rs:14:16
    |
 LL |     <String as IntoCow>::into_cow("foo".to_string());
-   |                ^^^^^^^ expected 1 type argument
+   |                ^^^^^^^ expected 1 generic argument
    |
-note: trait defined here, with 1 type parameter: `B`
+note: trait defined here, with 1 generic parameter: `B`
   --> $DIR/ufcs-qpath-missing-params.rs:3:11
    |
 LL | pub trait IntoCow<'a, B: ?Sized> where B: ToOwned {
    |           ^^^^^^^     -
-help: use angle brackets to add missing type argument
+help: add missing generic argument
    |
 LL |     <String as IntoCow<B>>::into_cow("foo".to_string());
-   |                       ^^^
+   |                ^^^^^^^^^^
 
 error[E0107]: missing generics for trait `IntoCow`
   --> $DIR/ufcs-qpath-missing-params.rs:17:16
    |
 LL |     <String as IntoCow>::into_cow::<str>("foo".to_string());
-   |                ^^^^^^^ expected 1 type argument
+   |                ^^^^^^^ expected 1 generic argument
    |
-note: trait defined here, with 1 type parameter: `B`
+note: trait defined here, with 1 generic parameter: `B`
   --> $DIR/ufcs-qpath-missing-params.rs:3:11
    |
 LL | pub trait IntoCow<'a, B: ?Sized> where B: ToOwned {
    |           ^^^^^^^     -
-help: use angle brackets to add missing type argument
+help: add missing generic argument
    |
 LL |     <String as IntoCow<B>>::into_cow::<str>("foo".to_string());
-   |                       ^^^
+   |                ^^^^^^^^^^
 
-error[E0107]: this associated function takes 0 type arguments but 1 type argument was supplied
+error[E0107]: this associated function takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/ufcs-qpath-missing-params.rs:17:26
    |
 LL |     <String as IntoCow>::into_cow::<str>("foo".to_string());
    |                          ^^^^^^^^------- help: remove these generics
    |                          |
-   |                          expected 0 type arguments
+   |                          expected 0 generic arguments
    |
-note: associated function defined here, with 0 type parameters
+note: associated function defined here, with 0 generic parameters
   --> $DIR/ufcs-qpath-missing-params.rs:4:8
    |
 LL |     fn into_cow(self) -> Cow<'a, B>;
index a82856add59425b62955b7998eaf7734445932c8..462f6fb7b872001b336381aefc607379ec2b1a2d 100644 (file)
@@ -7,7 +7,7 @@ struct Bar<A> {
 fn bar() {
     let x: Box<Bar()> = panic!();
     //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait
-    //~| ERROR missing generics for struct `Bar`
+    //~| ERROR this struct takes 1 generic argument but 0 generic arguments
 }
 
 fn main() { }
index d81975abbe9929df154796119d05079b5ee6dfd8..90bef7ba1180808305bea54c4d54e159700a18a0 100644 (file)
@@ -4,21 +4,21 @@ error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
 LL |     let x: Box<Bar()> = panic!();
    |                ^^^^^ only `Fn` traits may use parentheses
 
-error[E0107]: missing generics for struct `Bar`
+error[E0107]: this struct takes 1 generic argument but 0 generic arguments were supplied
   --> $DIR/unboxed-closure-sugar-used-on-struct-1.rs:8:16
    |
 LL |     let x: Box<Bar()> = panic!();
-   |                ^^^ expected 1 type argument
+   |                ^^^ expected 1 generic argument
    |
-note: struct defined here, with 1 type parameter: `A`
+note: struct defined here, with 1 generic parameter: `A`
   --> $DIR/unboxed-closure-sugar-used-on-struct-1.rs:3:8
    |
 LL | struct Bar<A> {
    |        ^^^ -
-help: use angle brackets to add missing type argument
+help: add missing generic argument
    |
-LL |     let x: Box<Bar<A>()> = panic!();
-   |                   ^^^
+LL |     let x: Box<Bar(A)> = panic!();
+   |                    ^
 
 error: aborting due to 2 previous errors
 
index b44505f8a4133bdc2571a72eab6ac8b0cf31c88e..bd61cbd80220e15665ec2c4473e1b8ac35b373b8 100644 (file)
@@ -6,7 +6,7 @@ struct Bar<A> {
 
 fn foo(b: Box<Bar()>) {
     //~^ ERROR parenthesized type parameters may only be used with a `Fn` trait
-    //~| ERROR missing generics for struct `Bar`
+    //~| ERROR this struct takes 1 generic argument but 0 generic arguments
 }
 
 fn main() { }
index 80d7c2402b6cf5e0389fea56fd57ad97accaa8f2..931675afd83f027e4d38dba99aac7e08f3ed76a1 100644 (file)
@@ -4,21 +4,21 @@ error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
 LL | fn foo(b: Box<Bar()>) {
    |               ^^^^^ only `Fn` traits may use parentheses
 
-error[E0107]: missing generics for struct `Bar`
+error[E0107]: this struct takes 1 generic argument but 0 generic arguments were supplied
   --> $DIR/unboxed-closure-sugar-used-on-struct.rs:7:15
    |
 LL | fn foo(b: Box<Bar()>) {
-   |               ^^^ expected 1 type argument
+   |               ^^^ expected 1 generic argument
    |
-note: struct defined here, with 1 type parameter: `A`
+note: struct defined here, with 1 generic parameter: `A`
   --> $DIR/unboxed-closure-sugar-used-on-struct.rs:3:8
    |
 LL | struct Bar<A> {
    |        ^^^ -
-help: use angle brackets to add missing type argument
+help: add missing generic argument
    |
-LL | fn foo(b: Box<Bar<A>()>) {
-   |                  ^^^
+LL | fn foo(b: Box<Bar(A)>) {
+   |                   ^
 
 error: aborting due to 2 previous errors
 
index a496b7da2f10a4becf4687350fbd87386d045cd0..f26ad8e93a153e5f4203c12403ff4386aa9a5885 100644 (file)
@@ -3,7 +3,7 @@
 trait Three<A,B,C> { fn dummy(&self) -> (A,B,C); }
 
 fn foo(_: &dyn Three())
-//~^ ERROR this trait takes 3 type arguments but only 1 type argument was supplied
+//~^ ERROR this trait takes 3 generic arguments but 1 generic argument
 //~| ERROR associated type `Output` not found
 {}
 
index ef5e7d222b4b77d60df707db3e32715e70343bbc..ebaacf0a6982dd15884187800b4cbb84db34d6c0 100644 (file)
@@ -1,12 +1,12 @@
-error[E0107]: this trait takes 3 type arguments but only 1 type argument was supplied
+error[E0107]: this trait takes 3 generic arguments but 1 generic argument was supplied
   --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs:5:16
    |
 LL | fn foo(_: &dyn Three())
-   |                ^^^^^-- supplied 1 type argument
+   |                ^^^^^-- supplied 1 generic argument
    |                |
-   |                expected 3 type arguments
+   |                expected 3 generic arguments
    |
-note: trait defined here, with 3 type parameters: `A`, `B`, `C`
+note: trait defined here, with 3 generic parameters: `A`, `B`, `C`
   --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters-3.rs:3:7
    |
 LL | trait Three<A,B,C> { fn dummy(&self) -> (A,B,C); }
index d0c85150efe2b87cdd4499b01e98eef3020a9898..4465b43a75724ce795facef4e05aecfffa7cde73 100644 (file)
@@ -3,25 +3,25 @@
 trait Zero { fn dummy(&self); }
 
 fn foo1(_: dyn Zero()) {
-    //~^ ERROR this trait takes 0 type arguments but 1 type argument was supplied
+    //~^ ERROR this trait takes 0 generic arguments but 1 generic argument
     //~| ERROR associated type `Output` not found for `Zero`
 }
 
 fn foo2(_: dyn Zero<usize>) {
-    //~^ ERROR this trait takes 0 type arguments but 1 type argument was supplied
+    //~^ ERROR this trait takes 0 generic arguments but 1 generic argument
 }
 
 fn foo3(_: dyn Zero <   usize   >) {
-    //~^ ERROR this trait takes 0 type arguments but 1 type argument was supplied
+    //~^ ERROR this trait takes 0 generic arguments but 1 generic argument
 }
 
 fn foo4(_: dyn Zero(usize)) {
-    //~^ ERROR this trait takes 0 type arguments but 1 type argument was supplied
+    //~^ ERROR this trait takes 0 generic arguments but 1 generic argument
     //~| ERROR associated type `Output` not found for `Zero`
 }
 
 fn foo5(_: dyn Zero (   usize   )) {
-    //~^ ERROR this trait takes 0 type arguments but 1 type argument was supplied
+    //~^ ERROR this trait takes 0 generic arguments but 1 generic argument
     //~| ERROR associated type `Output` not found for `Zero`
 }
 
index 2e620a5563f551f27655c5b304d35b95e432a2ec..9601e64c1895b6ecf77fd308287359d13e4d8703 100644 (file)
@@ -1,12 +1,12 @@
-error[E0107]: this trait takes 0 type arguments but 1 type argument was supplied
+error[E0107]: this trait takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters.rs:5:16
    |
 LL | fn foo1(_: dyn Zero()) {
    |                ^^^^-- help: remove these parenthetical generics
    |                |
-   |                expected 0 type arguments
+   |                expected 0 generic arguments
    |
-note: trait defined here, with 0 type parameters
+note: trait defined here, with 0 generic parameters
   --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters.rs:3:7
    |
 LL | trait Zero { fn dummy(&self); }
@@ -18,43 +18,43 @@ error[E0220]: associated type `Output` not found for `Zero`
 LL | fn foo1(_: dyn Zero()) {
    |                ^^^^^^ associated type `Output` not found
 
-error[E0107]: this trait takes 0 type arguments but 1 type argument was supplied
+error[E0107]: this trait takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters.rs:10:16
    |
 LL | fn foo2(_: dyn Zero<usize>) {
    |                ^^^^------- help: remove these generics
    |                |
-   |                expected 0 type arguments
+   |                expected 0 generic arguments
    |
-note: trait defined here, with 0 type parameters
+note: trait defined here, with 0 generic parameters
   --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters.rs:3:7
    |
 LL | trait Zero { fn dummy(&self); }
    |       ^^^^
 
-error[E0107]: this trait takes 0 type arguments but 1 type argument was supplied
+error[E0107]: this trait takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters.rs:14:16
    |
 LL | fn foo3(_: dyn Zero <   usize   >) {
    |                ^^^^-------------- help: remove these generics
    |                |
-   |                expected 0 type arguments
+   |                expected 0 generic arguments
    |
-note: trait defined here, with 0 type parameters
+note: trait defined here, with 0 generic parameters
   --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters.rs:3:7
    |
 LL | trait Zero { fn dummy(&self); }
    |       ^^^^
 
-error[E0107]: this trait takes 0 type arguments but 1 type argument was supplied
+error[E0107]: this trait takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters.rs:18:16
    |
 LL | fn foo4(_: dyn Zero(usize)) {
    |                ^^^^------- help: remove these parenthetical generics
    |                |
-   |                expected 0 type arguments
+   |                expected 0 generic arguments
    |
-note: trait defined here, with 0 type parameters
+note: trait defined here, with 0 generic parameters
   --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters.rs:3:7
    |
 LL | trait Zero { fn dummy(&self); }
@@ -66,15 +66,15 @@ error[E0220]: associated type `Output` not found for `Zero`
 LL | fn foo4(_: dyn Zero(usize)) {
    |                ^^^^^^^^^^^ associated type `Output` not found
 
-error[E0107]: this trait takes 0 type arguments but 1 type argument was supplied
+error[E0107]: this trait takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters.rs:23:16
    |
 LL | fn foo5(_: dyn Zero (   usize   )) {
    |                ^^^^-------------- help: remove these parenthetical generics
    |                |
-   |                expected 0 type arguments
+   |                expected 0 generic arguments
    |
-note: trait defined here, with 0 type parameters
+note: trait defined here, with 0 generic parameters
   --> $DIR/unboxed-closure-sugar-wrong-number-number-type-parameters.rs:3:7
    |
 LL | trait Zero { fn dummy(&self); }
index 5a47942e5afc68f568c63cee384ee3ba5de3940f..4bcf90552f9067ac3f87fc48a950b67231587037 100644 (file)
@@ -3,7 +3,7 @@
 trait Trait {}
 
 fn f<F:Trait(isize) -> isize>(x: F) {}
-//~^ ERROR this trait takes 0 type arguments but 1 type argument was supplied
+//~^ ERROR this trait takes 0 generic arguments but 1 generic argument
 //~| ERROR associated type `Output` not found for `Trait`
 
 fn main() {}
index b88a316c0c9dc529e1b7a0e2929dd85c6b04b784..3ff05fb2331ef6e993fa165f018f87cb7c14afb4 100644 (file)
@@ -1,12 +1,12 @@
-error[E0107]: this trait takes 0 type arguments but 1 type argument was supplied
+error[E0107]: this trait takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/unboxed-closure-sugar-wrong-trait.rs:5:8
    |
 LL | fn f<F:Trait(isize) -> isize>(x: F) {}
    |        ^^^^^------- help: remove these parenthetical generics
    |        |
-   |        expected 0 type arguments
+   |        expected 0 generic arguments
    |
-note: trait defined here, with 0 type parameters
+note: trait defined here, with 0 generic parameters
   --> $DIR/unboxed-closure-sugar-wrong-trait.rs:3:7
    |
 LL | trait Trait {}
index 3b40a21d80d48233fa47a35df54d0f948fb63841..15a20899a78d1a24419303e24dde5591a9ecb19d 100644 (file)
@@ -1,7 +1,5 @@
 // run-pass
 
-#![feature(const_fn)]
-
 type Field1 = (i32, u32);
 type Field2 = f32;
 type Field3 = i64;
index 546394664dfe8ecd8bdaafc038b6b4a688a26fcd..789bcc92fc6aed25304df9410549289d22e1f333 100644 (file)
@@ -9,7 +9,7 @@ LL | #[derive(Clone)]
 LL | pub struct AssertParamIsCopy<T: Copy + ?Sized> {
    |                                 ---- required by this bound in `AssertParamIsCopy`
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0599]: the method `clone` exists for union `U5<CloneNoCopy>`, but its trait bounds were not satisfied
   --> $DIR/union-derive-clone.rs:35:15
index 0591d12d598ba790e8b3993f57bf5cfa1b6ad03f..3198e97552d321712b96f206ad7a7483d40292df 100644 (file)
@@ -9,7 +9,7 @@ LL |     a: PartialEqNotEq,
 LL | pub struct AssertParamIsEq<T: Eq + ?Sized> {
    |                               -- required by this bound in `AssertParamIsEq`
    |
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Eq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/unsafe/unsafe-around-compiler-generated-unsafe.mir.stderr b/src/test/ui/unsafe/unsafe-around-compiler-generated-unsafe.mir.stderr
new file mode 100644 (file)
index 0000000..6810132
--- /dev/null
@@ -0,0 +1,14 @@
+error: unnecessary `unsafe` block
+  --> $DIR/unsafe-around-compiler-generated-unsafe.rs:9:5
+   |
+LL |     unsafe { println!("foo"); }
+   |     ^^^^^^ unnecessary `unsafe` block
+   |
+note: the lint level is defined here
+  --> $DIR/unsafe-around-compiler-generated-unsafe.rs:6:9
+   |
+LL | #![deny(unused_unsafe)]
+   |         ^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
index 817939e0757b38586164be9d7eb0ad349d8959e4..08801f9ef59ffb14f410db4cb3da59f8b927a62a 100644 (file)
@@ -1,5 +1,8 @@
 // issue #12418
 
+// revisions: mir thir
+// [thir]compile-flags: -Z thir-unsafeck
+
 #![deny(unused_unsafe)]
 
 fn main() {
diff --git a/src/test/ui/unsafe/unsafe-around-compiler-generated-unsafe.stderr b/src/test/ui/unsafe/unsafe-around-compiler-generated-unsafe.stderr
deleted file mode 100644 (file)
index 0dba849..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-error: unnecessary `unsafe` block
-  --> $DIR/unsafe-around-compiler-generated-unsafe.rs:6:5
-   |
-LL |     unsafe { println!("foo"); }
-   |     ^^^^^^ unnecessary `unsafe` block
-   |
-note: the lint level is defined here
-  --> $DIR/unsafe-around-compiler-generated-unsafe.rs:3:9
-   |
-LL | #![deny(unused_unsafe)]
-   |         ^^^^^^^^^^^^^
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/unsafe/unsafe-around-compiler-generated-unsafe.thir.stderr b/src/test/ui/unsafe/unsafe-around-compiler-generated-unsafe.thir.stderr
new file mode 100644 (file)
index 0000000..6810132
--- /dev/null
@@ -0,0 +1,14 @@
+error: unnecessary `unsafe` block
+  --> $DIR/unsafe-around-compiler-generated-unsafe.rs:9:5
+   |
+LL |     unsafe { println!("foo"); }
+   |     ^^^^^^ unnecessary `unsafe` block
+   |
+note: the lint level is defined here
+  --> $DIR/unsafe-around-compiler-generated-unsafe.rs:6:9
+   |
+LL | #![deny(unused_unsafe)]
+   |         ^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/unsafe/unsafe-const-fn.mir.stderr b/src/test/ui/unsafe/unsafe-const-fn.mir.stderr
new file mode 100644 (file)
index 0000000..3031be7
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/unsafe-const-fn.rs:10:18
+   |
+LL | const VAL: u32 = dummy(0xFFFF);
+   |                  ^^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0133`.
index 3b4becf17a76c9147c956c11ff3cda3dfa45226b..65e3acf3063726233ef35b681b7259833ae13ff1 100644 (file)
@@ -1,5 +1,8 @@
 // A quick test of 'unsafe const fn' functionality
 
+// revisions: mir thir
+// [thir]compile-flags: -Z thir-unsafeck
+
 const unsafe fn dummy(v: u32) -> u32 {
     !v
 }
diff --git a/src/test/ui/unsafe/unsafe-const-fn.stderr b/src/test/ui/unsafe/unsafe-const-fn.stderr
deleted file mode 100644 (file)
index 370e1e6..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/unsafe-const-fn.rs:7:18
-   |
-LL | const VAL: u32 = dummy(0xFFFF);
-   |                  ^^^^^^^^^^^^^ call to unsafe function
-   |
-   = note: consult the function's documentation for information on how to avoid undefined behavior
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0133`.
diff --git a/src/test/ui/unsafe/unsafe-const-fn.thir.stderr b/src/test/ui/unsafe/unsafe-const-fn.thir.stderr
new file mode 100644 (file)
index 0000000..3031be7
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/unsafe-const-fn.rs:10:18
+   |
+LL | const VAL: u32 = dummy(0xFFFF);
+   |                  ^^^^^^^^^^^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0133`.
diff --git a/src/test/ui/unsafe/unsafe-fn-called-from-safe.mir.stderr b/src/test/ui/unsafe/unsafe-fn-called-from-safe.mir.stderr
new file mode 100644 (file)
index 0000000..1d6fa4c
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/unsafe-fn-called-from-safe.rs:7:5
+   |
+LL |     f();
+   |     ^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0133`.
index 5487a8ecc37f90bb0d8d304282bbe0e73e0590be..df12e4415165ccc5cb7674ffef0a70bc5a55e0d2 100644 (file)
@@ -1,3 +1,6 @@
+// revisions: mir thir
+// [thir]compile-flags: -Z thir-unsafeck
+
 unsafe fn f() { return; }
 
 fn main() {
diff --git a/src/test/ui/unsafe/unsafe-fn-called-from-safe.stderr b/src/test/ui/unsafe/unsafe-fn-called-from-safe.stderr
deleted file mode 100644 (file)
index 80d2c6c..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/unsafe-fn-called-from-safe.rs:4:5
-   |
-LL |     f();
-   |     ^^^ call to unsafe function
-   |
-   = note: consult the function's documentation for information on how to avoid undefined behavior
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0133`.
diff --git a/src/test/ui/unsafe/unsafe-fn-called-from-safe.thir.stderr b/src/test/ui/unsafe/unsafe-fn-called-from-safe.thir.stderr
new file mode 100644 (file)
index 0000000..1d6fa4c
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/unsafe-fn-called-from-safe.rs:7:5
+   |
+LL |     f();
+   |     ^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0133`.
diff --git a/src/test/ui/unsafe/unsafe-fn-used-as-value.mir.stderr b/src/test/ui/unsafe/unsafe-fn-used-as-value.mir.stderr
new file mode 100644 (file)
index 0000000..b08a710
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/unsafe-fn-used-as-value.rs:8:5
+   |
+LL |     x();
+   |     ^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0133`.
index 59b814779305ba897975cc975812d138ddc4ef96..2af0786617bccba4ea753432eee66ee822f3af07 100644 (file)
@@ -1,3 +1,6 @@
+// revisions: mir thir
+// [thir]compile-flags: -Z thir-unsafeck
+
 unsafe fn f() { return; }
 
 fn main() {
diff --git a/src/test/ui/unsafe/unsafe-fn-used-as-value.stderr b/src/test/ui/unsafe/unsafe-fn-used-as-value.stderr
deleted file mode 100644 (file)
index a7b73ec..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
-  --> $DIR/unsafe-fn-used-as-value.rs:5:5
-   |
-LL |     x();
-   |     ^^^ call to unsafe function
-   |
-   = note: consult the function's documentation for information on how to avoid undefined behavior
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0133`.
diff --git a/src/test/ui/unsafe/unsafe-fn-used-as-value.thir.stderr b/src/test/ui/unsafe/unsafe-fn-used-as-value.thir.stderr
new file mode 100644 (file)
index 0000000..b08a710
--- /dev/null
@@ -0,0 +1,11 @@
+error[E0133]: call to unsafe function is unsafe and requires unsafe function or block
+  --> $DIR/unsafe-fn-used-as-value.rs:8:5
+   |
+LL |     x();
+   |     ^^^ call to unsafe function
+   |
+   = note: consult the function's documentation for information on how to avoid undefined behavior
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0133`.
index 963d892931a7503b874cb5f9cf8d373694ffc01d..c7120e05007256dda4c0dedcc36076657a42c32e 100644 (file)
@@ -1,7 +1,6 @@
 #![stable(feature = "foo", since = "1.33.0")]
 #![feature(staged_api)]
 #![feature(const_raw_ptr_deref)]
-#![feature(const_fn)]
 
 #[stable(feature = "foo", since = "1.33.0")]
 #[rustc_const_unstable(feature = "const_foo", issue = "none")]
index 98d7ae9f854341209df4fad6111abec211eb5fd6..410d8d3fb4024a0922584484d1e7b63d11fe0f3e 100644 (file)
@@ -1,5 +1,5 @@
 error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block
-  --> $DIR/unsafe-unstable-const-fn.rs:9:5
+  --> $DIR/unsafe-unstable-const-fn.rs:8:5
    |
 LL |     *a == b
    |     ^^ dereference of raw pointer
index 532d9339781d24fff539e4210431f6c2e4745cc2..55072bd81bf8cc2cd408c9a8bfc68ea6ff8c0337 100644 (file)
@@ -23,7 +23,7 @@ LL | |         }
 LL |   create_macro!();
    |   ---------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `create_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: unused macro definition
   --> $DIR/unused-macro-rules.rs:24:5
index 04e77bf9470a29d38d78dc9490ca081fa8932784..d2f96f66421283b5dbb37b119b6504f3e0da5014 100644 (file)
@@ -12,7 +12,7 @@ LL | |     });
    = note: `#[warn(irrefutable_let_patterns)]` on by default
    = note: this pattern will always match, so the loop will never exit
    = help: consider instead using a `loop { ... }` with a `let` inside it
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: irrefutable `while let` pattern
   --> $DIR/while-let.rs:7:13
@@ -27,7 +27,7 @@ LL | |     });
    |
    = note: this pattern will always match, so the loop will never exit
    = help: consider instead using a `loop { ... }` with a `let` inside it
-   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 warning: irrefutable `while let` pattern
   --> $DIR/while-let.rs:27:5
index e51522ab3db23b0d8f1de54eb1f0113924896331..070e459c2d8b79c5b2ac5218064e7603329c92ae 160000 (submodule)
@@ -1 +1 @@
-Subproject commit e51522ab3db23b0d8f1de54eb1f0113924896331
+Subproject commit 070e459c2d8b79c5b2ac5218064e7603329c92ae
index ec03daff87b075c2fd470a798a79ccc092bec5f5..314bf11e2d66616edc9f9636310fb5f483e221a8 100644 (file)
@@ -47,7 +47,7 @@ pub struct MacroRefData {
 
 impl MacroRefData {
     pub fn new(name: String, callee: Span, cx: &LateContext<'_>) -> Self {
-        let mut path = cx.sess().source_map().span_to_filename(callee).to_string();
+        let mut path = cx.sess().source_map().span_to_filename(callee).prefer_local().to_string();
 
         // std lib paths are <::std::module::file type>
         // so remove brackets, space and type.
@@ -96,8 +96,7 @@ fn push_unique_macro_pat_ty(&mut self, cx: &LateContext<'_>, span: Span) {
         let name = snippet(cx, cx.sess().source_map().span_until_char(call_site, '!'), "_");
         if let Some(callee) = span.source_callee() {
             if !self.collected.contains(&call_site) {
-                self.mac_refs
-                    .push(MacroRefData::new(name.to_string(), callee.def_site, cx));
+                self.mac_refs.push(MacroRefData::new(name.to_string(), callee.def_site, cx));
                 self.collected.insert(call_site);
             }
         }
@@ -175,7 +174,7 @@ fn check_crate_post(&mut self, cx: &LateContext<'_>, _krate: &hir::Crate<'_>) {
                                 .push((*item).to_string());
                             check_dup.push((*item).to_string());
                         }
-                    },
+                    }
                     [root, rest @ ..] => {
                         if rest.iter().all(|item| !check_dup.contains(&(*item).to_string())) {
                             let filtered = rest
@@ -199,7 +198,7 @@ fn check_crate_post(&mut self, cx: &LateContext<'_>, _krate: &hir::Crate<'_>) {
                                 .push(rest.join("::"));
                             check_dup.extend(rest.iter().map(ToString::to_string));
                         }
-                    },
+                    }
                 }
             }
         }
index 0b0cd9be46cf41f02614a99d6a4839aac9c235e3..6966d798c537a8e963cac529d724f22e072142a0 100644 (file)
@@ -660,7 +660,7 @@ fn in_attributes_expansion(expr: &Expr<'_>) -> bool {
     use rustc_span::hygiene::MacroKind;
     if expr.span.from_expansion() {
         let data = expr.span.ctxt().outer_expn_data();
-        matches!(data.kind, ExpnKind::Macro(MacroKind::Attr, _))
+        matches!(data.kind, ExpnKind::Macro { kind: MacroKind::Attr, name: _, proc_macro: _ })
     } else {
         false
     }
index 85257f3113cb774adc43f326707c0182b1eac616..d22f7d9a96bf112b59baef5c1ae5ad4c863ec8f4 100644 (file)
@@ -8,7 +8,7 @@
 pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>) {
     if expr.span.from_expansion() {
         if let Some(callee) = expr.span.source_callee() {
-            if let ExpnKind::Macro(MacroKind::Bang, symbol) = callee.kind {
+            if let ExpnKind::Macro { kind: MacroKind::Bang, name: symbol, proc_macro: _ } = callee.kind {
                 if let ExprKind::Binary(ref cmp, left, _) = expr.kind {
                     let op = cmp.node;
                     if op.is_comparison() && cx.typeck_results().expr_ty(left).is_unit() {
index f5ee49c7d5f99f31f3cc4d912451fd99c8eabc0c..9a0b72f06bbc939f7a4cb2f8f3938c3de91d25fe 100644 (file)
@@ -947,7 +947,7 @@ pub fn is_expn_of(mut span: Span, name: &str) -> Option<Span> {
             let data = span.ctxt().outer_expn_data();
             let new_span = data.call_site;
 
-            if let ExpnKind::Macro(MacroKind::Bang, mac_name) = data.kind {
+            if let ExpnKind::Macro { kind: MacroKind::Bang, name: mac_name, proc_macro: _ } = data.kind {
                 if mac_name.as_str() == name {
                     return Some(new_span);
                 }
@@ -975,7 +975,7 @@ pub fn is_direct_expn_of(span: Span, name: &str) -> Option<Span> {
         let data = span.ctxt().outer_expn_data();
         let new_span = data.call_site;
 
-        if let ExpnKind::Macro(MacroKind::Bang, mac_name) = data.kind {
+        if let ExpnKind::Macro { kind: MacroKind::Bang, name: mac_name, proc_macro: _ } = data.kind {
             if mac_name.as_str() == name {
                 return Some(new_span);
             }
index 5c5836a7d297e82a0ae0c18b819d73ef39b3caf9..4735573a47d3fa2b93b8c9093d6d47f6624e0567 100644 (file)
@@ -15,7 +15,7 @@ note: the lint level is defined here
 LL | #![deny(clippy::internal)]
    |         ^^^^^^^^^^^^^^^^
    = note: `#[deny(clippy::default_lint)]` implied by `#[deny(clippy::internal)]`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::declare_tool_lint` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index b53c3ea05da9f20d91195349d78029390279cc26..d0f100f00692f354b225bf5dc035034982a47538 100644 (file)
@@ -56,7 +56,7 @@ LL | |         }
 LL | |     }
    | |_____^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `__if_chain` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `let` expression should be above the `if_chain!`
   --> $DIR/if_chain_style.rs:40:9
index 1257dae96d71cc17c0261ff5f66efcea3575c165..e308e13da138304f34e1a2a340683f247eb8529a 100644 (file)
@@ -15,7 +15,7 @@ note: the lint level is defined here
 LL | #![deny(clippy::internal)]
    |         ^^^^^^^^^^^^^^^^
    = note: `#[deny(clippy::lint_without_lint_pass)]` implied by `#[deny(clippy::internal)]`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `declare_tool_lint` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index c66fdf093f5148a9a6aa660bea88dd23c6d9f61d..1eb87d89fad027a9dbb4cd1ff2aa43d5914904d4 100644 (file)
@@ -6,7 +6,7 @@ LL |     assert!(true);
    |
    = note: `-D clippy::assertions-on-constants` implied by `-D warnings`
    = help: remove it
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert` (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
@@ -15,7 +15,7 @@ LL |     assert!(false);
    |     ^^^^^^^^^^^^^^^
    |
    = help: use `panic!()` or `unreachable!()`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert` (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
@@ -24,7 +24,7 @@ LL |     assert!(true, "true message");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: remove it
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert` (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
@@ -33,7 +33,7 @@ LL |     assert!(false, "false message");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use `panic!("false message")` or `unreachable!("false message")`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert` (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
@@ -42,7 +42,7 @@ LL |     assert!(false, msg.to_uppercase());
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use `panic!(msg.to_uppercase())` or `unreachable!(msg.to_uppercase())`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert` (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
@@ -51,7 +51,7 @@ LL |     assert!(B);
    |     ^^^^^^^^^^^
    |
    = help: remove it
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert` (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
@@ -60,7 +60,7 @@ LL |     assert!(C);
    |     ^^^^^^^^^^^
    |
    = help: use `panic!()` or `unreachable!()`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert` (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
@@ -69,7 +69,7 @@ LL |     assert!(C, "C message");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use `panic!("C message")` or `unreachable!("C message")`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert` (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
@@ -78,7 +78,7 @@ LL |     debug_assert!(true);
    |     ^^^^^^^^^^^^^^^^^^^^
    |
    = help: remove it
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::assert` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 9 previous errors
 
index 416ec1a01ab3aa27e59b9ed44bd9d8cde45c911e..a4bc058fe2020b2263e5323c55160e56de9750ae 100644 (file)
@@ -55,7 +55,7 @@ LL |             $a.unwrap(); // unnecessary
 LL |     m!(x);
    |     ------ in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: you checked before that `unwrap()` cannot fail, instead of checking and unwrapping, it's better to use `if let` or `match`
   --> $DIR/simple_conditionals.rs:54:9
index ffef32d1fde9aac110ff74304c5d002d301a63e7..8975b2efbaeeb8900e1f22e3af2be375675d6785 100644 (file)
@@ -55,7 +55,7 @@ LL |         mac!(res_opt => Ok(val), val => Some(n), foo(n));
    |                            ^^^          ^^^^^^^ with this pattern
    |                            |
    |                            replace this binding
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: unnecessary nested match
   --> $DIR/collapsible_match2.rs:51:20
index d973ea1e23a259951b14e471c63bbee6f58fa3bf..5dbf9d440dd7594e2d69a048f1985849b0d7ed27 100644 (file)
@@ -7,7 +7,7 @@ LL |         extern crate std as core;
 LL | define_other_core!();
    | --------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `define_other_core` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index 6153c96edc4f425e254084377242028e490203cb..7c9d705fa9895d80c380f7943b31de9f5363b9ad 100644 (file)
@@ -33,7 +33,7 @@ LL |         const $name: $ty = $e;
 LL | declare_const!(_ONCE: Once = Once::new()); //~ ERROR interior mutable
    | ------------------------------------------ in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `declare_const` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 4 previous errors
 
index bb77f39b62c1f668a2729b871c728ecb66567816..bed385b5273a96bd2ee7b6bcb224fc86ff054b85 100644 (file)
@@ -15,7 +15,7 @@ LL |         const $name: $ty = $e;
 LL |     declare_const!(ANOTHER_ATOMIC: AtomicUsize = Self::ATOMIC); //~ ERROR interior mutable
    |     ----------------------------------------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `declare_const` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: a `const` item should never be interior mutable
   --> $DIR/traits.rs:43:5
index e85b30fa56eb884ff719241f62e659a57b3cc7fd..1a14f31af8d77c0a8df40c2cc5e72e5ce9a3be49 100644 (file)
@@ -57,7 +57,7 @@ LL |         *& $visitor
 LL |         m!(self)
    |         -------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: immediately dereferencing a reference
   --> $DIR/deref_addrof.rs:51:9
@@ -68,7 +68,7 @@ LL |         *& mut $visitor
 LL |         m_mut!(self)
    |         ------------ in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `m_mut` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 10 previous errors
 
index 2287a548fe46cc67a8b3de8de09ea609a97424e7..b383072ca4db75afa7f1c9da49a73ece05f2fce5 100644 (file)
@@ -14,7 +14,7 @@ LL | |         true
 LL | |     }
 LL | | }
    | |_^
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: you are deriving `Hash` but have implemented `PartialEq` explicitly
   --> $DIR/derive_hash_xor_eq.rs:19:10
@@ -31,7 +31,7 @@ LL | |         true
 LL | |     }
 LL | | }
    | |_^
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: you are implementing `Hash` explicitly but have derived `PartialEq`
   --> $DIR/derive_hash_xor_eq.rs:31:1
@@ -46,7 +46,7 @@ note: `PartialEq` implemented here
    |
 LL | #[derive(PartialEq)]
    |          ^^^^^^^^^
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: you are implementing `Hash` explicitly but have derived `PartialEq`
   --> $DIR/derive_hash_xor_eq.rs:49:5
@@ -61,7 +61,7 @@ note: `PartialEq` implemented here
    |
 LL |     #[derive(PartialEq)]
    |              ^^^^^^^^^
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 4 previous errors
 
index 97b46a4aa89828c3dda6d9ed82f65c8f288cf835..32896c99dad0ac687923836ea865b7302d937a8c 100644 (file)
@@ -14,7 +14,7 @@ LL | |         Some(other.cmp(self))
 LL | |     }
 LL | | }
    | |_^
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: you are deriving `Ord` but have implemented `PartialOrd` explicitly
   --> $DIR/derive_ord_xor_partial_ord.rs:30:10
@@ -31,7 +31,7 @@ LL | |         Some(other.cmp(self))
 LL | |     }
 LL | | }
    | |_^
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: you are implementing `Ord` explicitly but have derived `PartialOrd`
   --> $DIR/derive_ord_xor_partial_ord.rs:42:1
@@ -48,7 +48,7 @@ note: `PartialOrd` implemented here
    |
 LL | #[derive(PartialOrd, PartialEq, Eq)]
    |          ^^^^^^^^^^
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: you are implementing `Ord` explicitly but have derived `PartialOrd`
   --> $DIR/derive_ord_xor_partial_ord.rs:62:5
@@ -65,7 +65,7 @@ note: `PartialOrd` implemented here
    |
 LL |     #[derive(PartialOrd, PartialEq, Eq)]
    |              ^^^^^^^^^^
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 4 previous errors
 
index c784d41ba1724815db75e43289b7e082db391fed..73b53f3431e7aa8737be2a2e998aa4ad665d6c73 100644 (file)
@@ -41,7 +41,7 @@ LL | |         }
 LL |   very_unsafe!();
    |   --------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `very_unsafe` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 5 previous errors
 
index fb9378108b98ce010b7641418b64b3c0a116087f..a28961e7568edda36c40234222b3a7d481bcfb94 100644 (file)
@@ -8,7 +8,7 @@ LL |     assert_in_macro_def!();
    |     ----------------------- in this macro invocation
    |
    = note: `-D clippy::eq-op` implied by `-D warnings`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert_in_macro_def` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: identical args used in this `assert_ne!` macro call
   --> $DIR/eq_op_macros.rs:8:20
@@ -19,7 +19,7 @@ LL |         assert_ne!(a, a);
 LL |     assert_in_macro_def!();
    |     ----------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert_in_macro_def` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: identical args used in this `assert_eq!` macro call
   --> $DIR/eq_op_macros.rs:22:16
@@ -54,7 +54,7 @@ LL |         debug_assert_eq!(a, a);
 LL |     assert_in_macro_def!();
    |     ----------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert_in_macro_def` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: identical args used in this `debug_assert_ne!` macro call
   --> $DIR/eq_op_macros.rs:10:26
@@ -65,7 +65,7 @@ LL |         debug_assert_ne!(a, a);
 LL |     assert_in_macro_def!();
    |     ----------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert_in_macro_def` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: identical args used in this `debug_assert_eq!` macro call
   --> $DIR/eq_op_macros.rs:38:22
index a938d234fa07b0cad80a8eb012c655eb452684b7..64c8ea857277e2af5b4a81e4390d55c2c7be23a3 100644 (file)
@@ -38,7 +38,7 @@ note: potential failure(s)
    |
 LL |             panic!();
    |             ^^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: consider implementing `TryFrom` instead
   --> $DIR/fallible_impl_from.rs:35:1
@@ -65,7 +65,7 @@ LL |         } else if s.parse::<u32>().unwrap() != 42 {
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^
 LL |             panic!("{:?}", s);
    |             ^^^^^^^^^^^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: consider implementing `TryFrom` instead
   --> $DIR/fallible_impl_from.rs:53:1
@@ -87,7 +87,7 @@ LL |         if s.parse::<u32>().ok().unwrap() != 42 {
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 LL |             panic!("{:?}", s);
    |             ^^^^^^^^^^^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 4 previous errors
 
index 2b06d661772d28083e71f35e4abe9f7f056fe338..41ca6485c4c97fcdef8b980cb2e9bb4786c917e4 100644 (file)
@@ -109,7 +109,7 @@ LL |         impl<K: Hash + Eq, V> Foo<u8> for HashMap<K, V> {
 LL | gen!(impl);
    | ----------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `gen` (in Nightly builds, run with -Z macro-backtrace for more info)
 help: consider adding a type parameter
    |
 LL |         impl<K: Hash + Eq, V, S: ::std::hash::BuildHasher + Default> Foo<u8> for HashMap<K, V, S> {
@@ -128,7 +128,7 @@ LL |         pub fn $name(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32>)
 LL | gen!(fn bar);
    | ------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `gen` (in Nightly builds, run with -Z macro-backtrace for more info)
 help: consider adding a type parameter
    |
 LL |         pub fn $name<S: ::std::hash::BuildHasher>(_map: &mut HashMap<i32, i32, S>, _set: &mut HashSet<i32>) {}
@@ -143,7 +143,7 @@ LL |         pub fn $name(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32>)
 LL | gen!(fn bar);
    | ------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `gen` (in Nightly builds, run with -Z macro-backtrace for more info)
 help: consider adding a type parameter
    |
 LL |         pub fn $name<S: ::std::hash::BuildHasher>(_map: &mut HashMap<i32, i32>, _set: &mut HashSet<i32, S>) {}
index 68a3c81b6a804e7f25a23e454a171b7ef494c401..bcb163d4bc1243e2604ecd40ed818448c0dbc3a8 100644 (file)
@@ -27,7 +27,7 @@ LL | |             }
 LL |       b!();
    |       ----- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `b` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 3 previous errors
 
index 95f9494cdc99e9f82f202a00698a7e2592571e70..430021a0f7f5acddf88545d543bef5f20d90b077 100644 (file)
@@ -121,7 +121,7 @@ help: consider refactoring into `(Ok(x), Some(_)) | (Ok(_), Some(x))`
    |
 LL |         (Ok(x), Some(_)) => println!("ok {}", x),
    |         ^^^^^^^^^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: this `match` has identical arm bodies
   --> $DIR/match_same_arms2.rs:117:18
@@ -139,7 +139,7 @@ help: consider refactoring into `Ok(3) | Ok(_)`
    |
 LL |         Ok(3) => println!("ok"),
    |         ^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: this `match` has identical arm bodies
   --> $DIR/match_same_arms2.rs:144:14
index 8d9810970adee1bbe7d8301b15eec78c6d36f6ee..36a225b759484da68bd6f98fa1f1f4c8cfdf216f 100644 (file)
@@ -72,7 +72,7 @@ LL |     mem_discriminant_but_in_a_macro!(&rro);
    |     |                                help: try dereferencing: `*rro`
    |     in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `mem_discriminant_but_in_a_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: calling `mem::discriminant` on non-enum type `&&&&&std::option::Option<i32>`
   --> $DIR/mem_discriminant.rs:34:5
index 4971a91050bf20f968bd2bf62547a8558babd156..b4963acc4553c79808b546bda11d1515e6bfdef9 100644 (file)
@@ -8,7 +8,7 @@ LL |     take!(s);
    |     --------- in this macro invocation
    |
    = note: `-D clippy::mem-replace-with-default` implied by `-D warnings`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `take` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to previous error
 
index ba96a6a12b5dc7e29e4ab21263c2aed6c95c4278..8d882cc6e0d07cdc266a8a9fa1b4045c6f8a9628 100644 (file)
@@ -27,7 +27,7 @@ note: first possible panic found here
    |
 LL |     panic!("This function panics")
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: docs for function which may panic missing `# Panics` section
   --> $DIR/missing_panics_doc.rs:18:1
@@ -42,7 +42,7 @@ note: first possible panic found here
    |
 LL |     todo!()
    |     ^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: docs for function which may panic missing `# Panics` section
   --> $DIR/missing_panics_doc.rs:23:1
@@ -61,7 +61,7 @@ note: first possible panic found here
    |
 LL |             panic!()
    |             ^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: docs for function which may panic missing `# Panics` section
   --> $DIR/missing_panics_doc.rs:32:1
@@ -76,7 +76,7 @@ note: first possible panic found here
    |
 LL |     if true { unreachable!() } else { panic!() }
    |                                       ^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: docs for function which may panic missing `# Panics` section
   --> $DIR/missing_panics_doc.rs:37:1
@@ -92,7 +92,7 @@ note: first possible panic found here
    |
 LL |     assert_eq!(x, 0);
    |     ^^^^^^^^^^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: docs for function which may panic missing `# Panics` section
   --> $DIR/missing_panics_doc.rs:43:1
@@ -108,7 +108,7 @@ note: first possible panic found here
    |
 LL |     assert_ne!(x, 0);
    |     ^^^^^^^^^^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert_ne` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 7 previous errors
 
index 44e81422714181250edb7b3338c7d4cf3e7fe7c8..0fed6953cb85c295fc022a50e9d13a97c2772ded 100644 (file)
@@ -21,7 +21,7 @@ LL |         &mut $p
 LL |     let mut z = mut_ptr!(&mut 3u32);
    |                 ------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `mut_ptr` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: this expression mutably borrows a mutable reference. Consider reborrowing
   --> $DIR/mut_mut.rs:22:21
index afd68d91e51fe54c022487f30388a72ea434511e..f1f05d1af3ae8fa744b3bfbf0c46c3d932f93f77 100644 (file)
@@ -75,7 +75,7 @@ LL |         || -> Option<_> { Some(Some($expr)?) }()
 LL |     let _x = some_and_qmark_in_macro!(x?);
    |              ---------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `some_and_qmark_in_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 12 previous errors
 
index 64659b63f469934e3f0aecc5e8359fbaeb557b78..58094646b505cad518d16b3a65665336e47b9856 100644 (file)
@@ -1,4 +1,3 @@
-#![feature(const_fn)]
 #![allow(dead_code, clippy::missing_safety_doc)]
 #![warn(clippy::new_without_default)]
 
index 973836f75a905d02165931646bef411e422ff52b..56c5fe1c6189acaa638acfdf3fe88c97e5be2829 100644 (file)
@@ -1,5 +1,5 @@
 error: you should consider adding a `Default` implementation for `Foo`
-  --> $DIR/new_without_default.rs:8:5
+  --> $DIR/new_without_default.rs:7:5
    |
 LL | /     pub fn new() -> Foo {
 LL | |         Foo
@@ -17,7 +17,7 @@ LL | }
    |
 
 error: you should consider adding a `Default` implementation for `Bar`
-  --> $DIR/new_without_default.rs:16:5
+  --> $DIR/new_without_default.rs:15:5
    |
 LL | /     pub fn new() -> Self {
 LL | |         Bar
@@ -34,7 +34,7 @@ LL | }
    |
 
 error: you should consider adding a `Default` implementation for `LtKo<'c>`
-  --> $DIR/new_without_default.rs:80:5
+  --> $DIR/new_without_default.rs:79:5
    |
 LL | /     pub fn new() -> LtKo<'c> {
 LL | |         unimplemented!()
@@ -51,7 +51,7 @@ LL | }
    |
 
 error: you should consider adding a `Default` implementation for `NewNotEqualToDerive`
-  --> $DIR/new_without_default.rs:157:5
+  --> $DIR/new_without_default.rs:156:5
    |
 LL | /     pub fn new() -> Self {
 LL | |         NewNotEqualToDerive { foo: 1 }
@@ -68,7 +68,7 @@ LL | }
    |
 
 error: you should consider adding a `Default` implementation for `FooGenerics<T>`
-  --> $DIR/new_without_default.rs:165:5
+  --> $DIR/new_without_default.rs:164:5
    |
 LL | /     pub fn new() -> Self {
 LL | |         Self(Default::default())
@@ -85,7 +85,7 @@ LL | }
    |
 
 error: you should consider adding a `Default` implementation for `BarGenerics<T>`
-  --> $DIR/new_without_default.rs:172:5
+  --> $DIR/new_without_default.rs:171:5
    |
 LL | /     pub fn new() -> Self {
 LL | |         Self(Default::default())
index 8de9c8a9d29e0a1da2b4c59bef6ccdd48b8b7491..e6a58b0b2b752f3cca87b1a42816c2900a37953b 100644 (file)
@@ -25,7 +25,7 @@ LL |     let _ = option_env_unwrap!("PATH");
    |             -------------------------- in this macro invocation
    |
    = help: consider using the `env!` macro instead
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `option_env_unwrap` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: this will panic at run-time if the environment variable doesn't exist at compile-time
   --> $DIR/option_env_unwrap.rs:12:9
@@ -37,7 +37,7 @@ LL |     let _ = option_env_unwrap!("PATH", "environment variable PATH isn't set
    |             ----------------------------------------------------------------- in this macro invocation
    |
    = help: consider using the `env!` macro instead
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `option_env_unwrap` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: this will panic at run-time if the environment variable doesn't exist at compile-time
   --> $DIR/option_env_unwrap.rs:21:13
@@ -46,7 +46,7 @@ LL |     let _ = option_env_unwrap_external!("PATH");
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: consider using the `env!` macro instead
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `option_env_unwrap_external` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: this will panic at run-time if the environment variable doesn't exist at compile-time
   --> $DIR/option_env_unwrap.rs:22:13
@@ -55,7 +55,7 @@ LL |     let _ = option_env_unwrap_external!("PATH", "environment variable PATH
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: consider using the `env!` macro instead
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `option_env_unwrap_external` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 6 previous errors
 
index eb744b0c198fabf28dc94e0b387d4d09da513c57..8d6e40c30a10909280d80fbb24ad155d3ce45bf0 100644 (file)
@@ -14,7 +14,7 @@ note: return Err() instead of panicking
    |
 LL |         panic!("error");
    |         ^^^^^^^^^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result`
   --> $DIR/panic_in_result_fn.rs:12:5
@@ -31,7 +31,7 @@ note: return Err() instead of panicking
    |
 LL |         unimplemented!();
    |         ^^^^^^^^^^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result`
   --> $DIR/panic_in_result_fn.rs:17:5
@@ -48,7 +48,7 @@ note: return Err() instead of panicking
    |
 LL |         unreachable!();
    |         ^^^^^^^^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `unreachable` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result`
   --> $DIR/panic_in_result_fn.rs:22:5
@@ -65,7 +65,7 @@ note: return Err() instead of panicking
    |
 LL |         todo!("Finish this");
    |         ^^^^^^^^^^^^^^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result`
   --> $DIR/panic_in_result_fn.rs:53:1
@@ -82,7 +82,7 @@ note: return Err() instead of panicking
    |
 LL |     panic!("error");
    |     ^^^^^^^^^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result`
   --> $DIR/panic_in_result_fn.rs:68:1
@@ -99,7 +99,7 @@ note: return Err() instead of panicking
    |
 LL |     todo!("finish main method");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 6 previous errors
 
index a17f043737d4e009fae59b46d62399e6c8ae3a5d..4c39b37d8798fcf1839ff629f7842153ae15daf1 100644 (file)
@@ -15,7 +15,7 @@ note: return Err() instead of panicking
    |
 LL |         assert!(x == 5, "wrong argument");
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result`
   --> $DIR/panic_in_result_fn_assertions.rs:13:5
@@ -33,7 +33,7 @@ note: return Err() instead of panicking
    |
 LL |         assert_eq!(x, 5);
    |         ^^^^^^^^^^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: used `unimplemented!()`, `unreachable!()`, `todo!()`, `panic!()` or assertion in a function that returns `Result`
   --> $DIR/panic_in_result_fn_assertions.rs:19:5
@@ -51,7 +51,7 @@ note: return Err() instead of panicking
    |
 LL |         assert_ne!(x, 1);
    |         ^^^^^^^^^^^^^^^^^
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert_ne` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 3 previous errors
 
index ffced49690e97bc7c57f5455d270cce81670b6b4..2e83c305a67e055c7b7f8dc3bd06021cbb1b79eb 100644 (file)
@@ -25,7 +25,7 @@ LL |     todo!();
    |     ^^^^^^^^
    |
    = note: `-D clippy::todo` implied by `-D warnings`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `todo` should not be present in production code
   --> $DIR/panicking_macros.rs:17:5
@@ -33,7 +33,7 @@ error: `todo` should not be present in production code
 LL |     todo!("message");
    |     ^^^^^^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `todo` should not be present in production code
   --> $DIR/panicking_macros.rs:18:5
@@ -41,7 +41,7 @@ error: `todo` should not be present in production code
 LL |     todo!("{} {}", "panic with", "multiple arguments");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `unimplemented` should not be present in production code
   --> $DIR/panicking_macros.rs:24:5
@@ -50,7 +50,7 @@ LL |     unimplemented!();
    |     ^^^^^^^^^^^^^^^^^
    |
    = note: `-D clippy::unimplemented` implied by `-D warnings`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `unimplemented` should not be present in production code
   --> $DIR/panicking_macros.rs:25:5
@@ -58,7 +58,7 @@ error: `unimplemented` should not be present in production code
 LL |     unimplemented!("message");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `unimplemented` should not be present in production code
   --> $DIR/panicking_macros.rs:26:5
@@ -66,7 +66,7 @@ error: `unimplemented` should not be present in production code
 LL |     unimplemented!("{} {}", "panic with", "multiple arguments");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: usage of the `unreachable!` macro
   --> $DIR/panicking_macros.rs:32:5
@@ -75,7 +75,7 @@ LL |     unreachable!();
    |     ^^^^^^^^^^^^^^^
    |
    = note: `-D clippy::unreachable` implied by `-D warnings`
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `unreachable` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: usage of the `unreachable!` macro
   --> $DIR/panicking_macros.rs:33:5
@@ -83,7 +83,7 @@ error: usage of the `unreachable!` macro
 LL |     unreachable!("message");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::unreachable` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: usage of the `unreachable!` macro
   --> $DIR/panicking_macros.rs:34:5
@@ -91,7 +91,7 @@ error: usage of the `unreachable!` macro
 LL |     unreachable!("{} {}", "panic with", "multiple arguments");
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `unreachable` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `panic` should not be present in production code
   --> $DIR/panicking_macros.rs:40:5
@@ -105,7 +105,7 @@ error: `todo` should not be present in production code
 LL |     todo!();
    |     ^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `todo` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `unimplemented` should not be present in production code
   --> $DIR/panicking_macros.rs:42:5
@@ -113,7 +113,7 @@ error: `unimplemented` should not be present in production code
 LL |     unimplemented!();
    |     ^^^^^^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `unimplemented` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: usage of the `unreachable!` macro
   --> $DIR/panicking_macros.rs:43:5
@@ -121,7 +121,7 @@ error: usage of the `unreachable!` macro
 LL |     unreachable!();
    |     ^^^^^^^^^^^^^^^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `unreachable` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 16 previous errors
 
index 5a5186bd4fcb3389cbca59b4e09fd7554e7f5330..f309b2739829f90b921b139646abf2dbcce5ae51 100644 (file)
@@ -73,7 +73,7 @@ LL |     matching_macro!(value);
    |     ----------------------- in this macro invocation
    |
    = help: use `*` to dereference the match expression or explicitly match against a `&_` pattern and adjust the enclosed variable bindings
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `matching_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 9 previous errors
 
index 15cb933fedc9e78f34b2511d5d8650c3934bed93..48e7d9ddd5aee5086731acb05f99456c6d97c1f4 100644 (file)
@@ -39,7 +39,7 @@ LL |         let ref _y = 42;
 LL |         gen_binding!();
    |         --------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `gen_binding` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 6 previous errors
 
index b8cfd987394976da96c02ed4d70624068bbe68b6..31f8c103ede573ad1153c653bf64759cccbe3def 100644 (file)
@@ -15,7 +15,7 @@ LL |         fn fun_example(ref _x: usize) {}
 LL |         gen_function!();
    |         ---------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `gen_function` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 2 previous errors
 
index 8f332a9b6492caf32c24c28edf46fec5c03eaa1d..09efc16c154ef70ef9e676f411af7594903b1349 100644 (file)
@@ -37,7 +37,7 @@ LL |             Err(_) => Err(1)?,
 LL |     try_validation!(Ok::<_, i32>(5));
    |     --------------------------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `try_validation` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: returning an `Err(_)` with the `?` operator
   --> $DIR/try_err.rs:102:23
@@ -48,7 +48,7 @@ LL |             Err(_) => Err(ret_one!())?,
 LL |     try_validation_in_macro!(Ok::<_, i32>(5));
    |     ------------------------------------------ in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `try_validation_in_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: returning an `Err(_)` with the `?` operator
   --> $DIR/try_err.rs:141:9
index c8c0a85dfc102d9b2cb4c25e03803a7c8ec260c6..75017cab05776f2a98a9f0931f4803542b02d2dd 100644 (file)
@@ -34,7 +34,7 @@ LL | |         }
 LL | |     );
    | |______^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `debug_assert_eq` of unit values detected. This will always succeed
   --> $DIR/unit_cmp.rs:32:5
@@ -48,7 +48,7 @@ LL | |         }
 LL | |     );
    | |______^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `assert_ne` of unit values detected. This will always fail
   --> $DIR/unit_cmp.rs:41:5
@@ -62,7 +62,7 @@ LL | |         }
 LL | |     );
    | |______^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `assert_ne` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `debug_assert_ne` of unit values detected. This will always fail
   --> $DIR/unit_cmp.rs:49:5
@@ -76,7 +76,7 @@ LL | |         }
 LL | |     );
    | |______^
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `$crate::assert_ne` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 6 previous errors
 
index 1978bd95a67035f6b90403927757fd84dfa63cd3..18c4276c6ddfd7c62578a9e535b01b70b8c8a37a 100644 (file)
@@ -6,7 +6,7 @@ LL | #[derive(Deserialize)]
    |
    = note: `-D clippy::unsafe-derive-deserialize` implied by `-D warnings`
    = help: consider implementing `serde::Deserialize` manually. See https://serde.rs/impl-deserialize.html
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe`
   --> $DIR/unsafe_derive_deserialize.rs:16:10
@@ -15,7 +15,7 @@ LL | #[derive(Deserialize)]
    |          ^^^^^^^^^^^
    |
    = help: consider implementing `serde::Deserialize` manually. See https://serde.rs/impl-deserialize.html
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe`
   --> $DIR/unsafe_derive_deserialize.rs:22:10
@@ -24,7 +24,7 @@ LL | #[derive(Deserialize)]
    |          ^^^^^^^^^^^
    |
    = help: consider implementing `serde::Deserialize` manually. See https://serde.rs/impl-deserialize.html
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe`
   --> $DIR/unsafe_derive_deserialize.rs:30:10
@@ -33,7 +33,7 @@ LL | #[derive(Deserialize)]
    |          ^^^^^^^^^^^
    |
    = help: consider implementing `serde::Deserialize` manually. See https://serde.rs/impl-deserialize.html
-   = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: aborting due to 4 previous errors
 
index d7dd526bcb9af431f2f93291401e3781be90f64f..a0c0be7a9d154277f849edca0b5563f8b0aa116d 100644 (file)
@@ -51,7 +51,7 @@ LL |         42usize
 LL |     let _ = lit_from_macro!();
    |             ----------------- in this macro invocation
    |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   = note: this error originates in the macro `lit_from_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: integer type suffix should be separated by an underscore
   --> $DIR/unseparated_prefix_literals.rs:40:16
index c606aa1dfbfd42b06045176855533a817fc4d558..f4e16483d8c3a65083b738164a12e3b0cb47012e 100644 (file)
@@ -3650,6 +3650,12 @@ fn normalize_output(&self, output: &str, custom_rules: &[(String, String)]) -> S
             .join("library");
         normalize_path(&src_dir, "$SRC_DIR");
 
+        if let Some(virtual_rust_source_base_dir) =
+            option_env!("CFG_VIRTUAL_RUST_SOURCE_BASE_DIR").map(PathBuf::from)
+        {
+            normalize_path(&virtual_rust_source_base_dir.join("library"), "$SRC_DIR");
+        }
+
         // Paths into the build directory
         let test_build_dir = &self.config.build_base;
         let parent_build_dir = test_build_dir.parent().unwrap().parent().unwrap().parent().unwrap();
index 38b5f236d2c62ff0b1017efd183b193f5db33123..bcae3315a76876eb48e06519749cfe6e453a8e93 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 38b5f236d2c62ff0b1017efd183b193f5db33123
+Subproject commit bcae3315a76876eb48e06519749cfe6e453a8e93
index e583bd225a9eb164fe9901e3353712faeda67d9b..86b16f8b0e60d8bba1d879c66fe6b37db9ed88c6 100644 (file)
@@ -267,9 +267,10 @@ function loadSearchJsAndIndex(searchJs, searchIndex, storageJs, crate) {
                            "handleAliases", "getQuery", "buildIndex", "execQuery", "execSearch",
                            "removeEmptyStringsFromArray"];
 
+    const functions = ["hasOwnPropertyRustdoc", "onEach"];
     ALIASES = {};
     finalJS += 'window = { "currentCrate": "' + crate + '", rootPath: "../" };\n';
-    finalJS += loadThings(["hasOwnProperty", "onEach"], 'function', extractFunction, storageJs);
+    finalJS += loadThings(functions, 'function', extractFunction, storageJs);
     finalJS += loadThings(arraysToLoad, 'array', extractArrayVariable, searchJs);
     finalJS += loadThings(variablesToLoad, 'variable', extractVariable, searchJs);
     finalJS += loadThings(functionsToLoad, 'function', extractFunction, searchJs);
index 064dd716521f51dda66b7afa0667b7a12ea0edf8..bba689d07a42e03c2c46b61671cdd1134841ad0f 100644 (file)
     "md-5",
     "measureme",
     "memchr",
-    "memmap",
     "memmap2",
     "memoffset",
     "miniz_oxide",
index 8334bc68ae72943a0cd3a0b8eddb861c62ba0829..7b42de0ec436991ab453b95c86052ab0f3b91f8b 100644 (file)
@@ -7,8 +7,8 @@
 
 const ENTRY_LIMIT: usize = 1000;
 // FIXME: The following limits should be reduced eventually.
-const ROOT_ENTRY_LIMIT: usize = 1388;
-const ISSUES_ENTRY_LIMIT: usize = 2551;
+const ROOT_ENTRY_LIMIT: usize = 1370;
+const ISSUES_ENTRY_LIMIT: usize = 2555;
 
 fn check_entries(path: &Path, bad: &mut bool) {
     let dirs = walkdir::WalkDir::new(&path.join("test/ui"))