From d636a6590ce1429ff011e04bb0b4d393dc382226 Mon Sep 17 00:00:00 2001 From: Kivooeo Date: Thu, 24 Jul 2025 17:15:36 +0500 Subject: [PATCH 1/9] moved 35 tests to organized locations --- .../issue-11709.rs => block-result/blocks-without-results.rs} | 0 .../issue-12033.rs => borrowck/refcell-borrow-comparison.rs} | 0 .../ui/{issues/issue-12127.rs => closures/fnonce-moved-twice.rs} | 0 .../{issues/issue-11958.rs => closures/moved-upvar-mut-rebind.rs} | 0 .../issue-12860.rs => collections/hashset-connected-border.rs} | 0 .../vec-macro-in-static-array.rs} | 0 .../format-message-windows-ffi.rs} | 0 .../{issues/issue-13105.rs => fn/anonymous-parameters-trait.rs} | 0 tests/ui/{issues/issue-12729.rs => imports/use-in-impl-scope.rs} | 0 .../{issues/issue-12677.rs => iterators/bytes-iterator-clone.rs} | 0 .../issue-13167.rs => iterators/phf-map-entries-iterator.rs} | 0 .../issue-13058.rs => lifetimes/iterator-trait-lifetime-error.rs} | 0 .../struct-lifetime-field-assignment.rs} | 0 .../{issues/issue-12863.rs => match/function-in-pattern-error.rs} | 0 .../issue-13027.rs => match/guard-literal-range-shadow.rs} | 0 .../ui/{issues/issue-11844.rs => match/option-result-mismatch.rs} | 0 .../issue-13466.rs => match/option-result-type-param-mismatch.rs} | 0 tests/ui/{issues/issue-12567.rs => match/slice-move-out-error.rs} | 0 .../issue-11869.rs => match/string-literal-match-patterns.rs} | 0 .../{issues/issue-12285.rs => match/struct-reference-patterns.rs} | 0 .../issue-12920.rs => panics/explicit-panic-unreachable.rs} | 0 .../ui/{issues/issue-13202.rs => panics/unwrap-or-panic-input.rs} | 0 .../issue-13407.rs => privacy/private-unit-struct-assignment.rs} | 0 .../issue-13214.rs => statics/enum-with-static-str-variant.rs} | 0 .../issue-12041.rs => threads/moved-value-in-thread-loop.rs} | 0 .../{issues/issue-12744.rs => traits/any-trait-object-debug.rs} | 0 .../issue-13204.rs => traits/default-method-lifetime-params.rs} | 0 .../{issues/issue-13264.rs => traits/deref-chain-method-calls.rs} | 0 .../{issues/issue-13434.rs => traits/fnonce-repro-trait-impl.rs} | 0 .../{issues/issue-13323.rs => traits/matcher-trait-equality.rs} | 0 .../{issues/issue-11820.rs => traits/reference-clone-noclone.rs} | 0 .../isize-usize-mismatch-error.rs} | 0 .../issue-12909.rs => type-inference/type-collect-inference.rs} | 0 .../issue-11771.rs => type-inference/unit-type-add-error.rs} | 0 .../{issues/issue-11740.rs => unsafe/unsafe-transmute-in-find.rs} | 0 35 files changed, 0 insertions(+), 0 deletions(-) rename tests/ui/{issues/issue-11709.rs => block-result/blocks-without-results.rs} (100%) rename tests/ui/{issues/issue-12033.rs => borrowck/refcell-borrow-comparison.rs} (100%) rename tests/ui/{issues/issue-12127.rs => closures/fnonce-moved-twice.rs} (100%) rename tests/ui/{issues/issue-11958.rs => closures/moved-upvar-mut-rebind.rs} (100%) rename tests/ui/{issues/issue-12860.rs => collections/hashset-connected-border.rs} (100%) rename tests/ui/{issues/issue-13446.rs => const-generics/vec-macro-in-static-array.rs} (100%) rename tests/ui/{issues/issue-13259-windows-tcb-trash.rs => extern/format-message-windows-ffi.rs} (100%) rename tests/ui/{issues/issue-13105.rs => fn/anonymous-parameters-trait.rs} (100%) rename tests/ui/{issues/issue-12729.rs => imports/use-in-impl-scope.rs} (100%) rename tests/ui/{issues/issue-12677.rs => iterators/bytes-iterator-clone.rs} (100%) rename tests/ui/{issues/issue-13167.rs => iterators/phf-map-entries-iterator.rs} (100%) rename tests/ui/{issues/issue-13058.rs => lifetimes/iterator-trait-lifetime-error.rs} (100%) rename tests/ui/{issues/issue-13405.rs => lifetimes/struct-lifetime-field-assignment.rs} (100%) rename tests/ui/{issues/issue-12863.rs => match/function-in-pattern-error.rs} (100%) rename tests/ui/{issues/issue-13027.rs => match/guard-literal-range-shadow.rs} (100%) rename tests/ui/{issues/issue-11844.rs => match/option-result-mismatch.rs} (100%) rename tests/ui/{issues/issue-13466.rs => match/option-result-type-param-mismatch.rs} (100%) rename tests/ui/{issues/issue-12567.rs => match/slice-move-out-error.rs} (100%) rename tests/ui/{issues/issue-11869.rs => match/string-literal-match-patterns.rs} (100%) rename tests/ui/{issues/issue-12285.rs => match/struct-reference-patterns.rs} (100%) rename tests/ui/{issues/issue-12920.rs => panics/explicit-panic-unreachable.rs} (100%) rename tests/ui/{issues/issue-13202.rs => panics/unwrap-or-panic-input.rs} (100%) rename tests/ui/{issues/issue-13407.rs => privacy/private-unit-struct-assignment.rs} (100%) rename tests/ui/{issues/issue-13214.rs => statics/enum-with-static-str-variant.rs} (100%) rename tests/ui/{issues/issue-12041.rs => threads/moved-value-in-thread-loop.rs} (100%) rename tests/ui/{issues/issue-12744.rs => traits/any-trait-object-debug.rs} (100%) rename tests/ui/{issues/issue-13204.rs => traits/default-method-lifetime-params.rs} (100%) rename tests/ui/{issues/issue-13264.rs => traits/deref-chain-method-calls.rs} (100%) rename tests/ui/{issues/issue-13434.rs => traits/fnonce-repro-trait-impl.rs} (100%) rename tests/ui/{issues/issue-13323.rs => traits/matcher-trait-equality.rs} (100%) rename tests/ui/{issues/issue-11820.rs => traits/reference-clone-noclone.rs} (100%) rename tests/ui/{issues/issue-13359.rs => type-inference/isize-usize-mismatch-error.rs} (100%) rename tests/ui/{issues/issue-12909.rs => type-inference/type-collect-inference.rs} (100%) rename tests/ui/{issues/issue-11771.rs => type-inference/unit-type-add-error.rs} (100%) rename tests/ui/{issues/issue-11740.rs => unsafe/unsafe-transmute-in-find.rs} (100%) diff --git a/tests/ui/issues/issue-11709.rs b/tests/ui/block-result/blocks-without-results.rs similarity index 100% rename from tests/ui/issues/issue-11709.rs rename to tests/ui/block-result/blocks-without-results.rs diff --git a/tests/ui/issues/issue-12033.rs b/tests/ui/borrowck/refcell-borrow-comparison.rs similarity index 100% rename from tests/ui/issues/issue-12033.rs rename to tests/ui/borrowck/refcell-borrow-comparison.rs diff --git a/tests/ui/issues/issue-12127.rs b/tests/ui/closures/fnonce-moved-twice.rs similarity index 100% rename from tests/ui/issues/issue-12127.rs rename to tests/ui/closures/fnonce-moved-twice.rs diff --git a/tests/ui/issues/issue-11958.rs b/tests/ui/closures/moved-upvar-mut-rebind.rs similarity index 100% rename from tests/ui/issues/issue-11958.rs rename to tests/ui/closures/moved-upvar-mut-rebind.rs diff --git a/tests/ui/issues/issue-12860.rs b/tests/ui/collections/hashset-connected-border.rs similarity index 100% rename from tests/ui/issues/issue-12860.rs rename to tests/ui/collections/hashset-connected-border.rs diff --git a/tests/ui/issues/issue-13446.rs b/tests/ui/const-generics/vec-macro-in-static-array.rs similarity index 100% rename from tests/ui/issues/issue-13446.rs rename to tests/ui/const-generics/vec-macro-in-static-array.rs diff --git a/tests/ui/issues/issue-13259-windows-tcb-trash.rs b/tests/ui/extern/format-message-windows-ffi.rs similarity index 100% rename from tests/ui/issues/issue-13259-windows-tcb-trash.rs rename to tests/ui/extern/format-message-windows-ffi.rs diff --git a/tests/ui/issues/issue-13105.rs b/tests/ui/fn/anonymous-parameters-trait.rs similarity index 100% rename from tests/ui/issues/issue-13105.rs rename to tests/ui/fn/anonymous-parameters-trait.rs diff --git a/tests/ui/issues/issue-12729.rs b/tests/ui/imports/use-in-impl-scope.rs similarity index 100% rename from tests/ui/issues/issue-12729.rs rename to tests/ui/imports/use-in-impl-scope.rs diff --git a/tests/ui/issues/issue-12677.rs b/tests/ui/iterators/bytes-iterator-clone.rs similarity index 100% rename from tests/ui/issues/issue-12677.rs rename to tests/ui/iterators/bytes-iterator-clone.rs diff --git a/tests/ui/issues/issue-13167.rs b/tests/ui/iterators/phf-map-entries-iterator.rs similarity index 100% rename from tests/ui/issues/issue-13167.rs rename to tests/ui/iterators/phf-map-entries-iterator.rs diff --git a/tests/ui/issues/issue-13058.rs b/tests/ui/lifetimes/iterator-trait-lifetime-error.rs similarity index 100% rename from tests/ui/issues/issue-13058.rs rename to tests/ui/lifetimes/iterator-trait-lifetime-error.rs diff --git a/tests/ui/issues/issue-13405.rs b/tests/ui/lifetimes/struct-lifetime-field-assignment.rs similarity index 100% rename from tests/ui/issues/issue-13405.rs rename to tests/ui/lifetimes/struct-lifetime-field-assignment.rs diff --git a/tests/ui/issues/issue-12863.rs b/tests/ui/match/function-in-pattern-error.rs similarity index 100% rename from tests/ui/issues/issue-12863.rs rename to tests/ui/match/function-in-pattern-error.rs diff --git a/tests/ui/issues/issue-13027.rs b/tests/ui/match/guard-literal-range-shadow.rs similarity index 100% rename from tests/ui/issues/issue-13027.rs rename to tests/ui/match/guard-literal-range-shadow.rs diff --git a/tests/ui/issues/issue-11844.rs b/tests/ui/match/option-result-mismatch.rs similarity index 100% rename from tests/ui/issues/issue-11844.rs rename to tests/ui/match/option-result-mismatch.rs diff --git a/tests/ui/issues/issue-13466.rs b/tests/ui/match/option-result-type-param-mismatch.rs similarity index 100% rename from tests/ui/issues/issue-13466.rs rename to tests/ui/match/option-result-type-param-mismatch.rs diff --git a/tests/ui/issues/issue-12567.rs b/tests/ui/match/slice-move-out-error.rs similarity index 100% rename from tests/ui/issues/issue-12567.rs rename to tests/ui/match/slice-move-out-error.rs diff --git a/tests/ui/issues/issue-11869.rs b/tests/ui/match/string-literal-match-patterns.rs similarity index 100% rename from tests/ui/issues/issue-11869.rs rename to tests/ui/match/string-literal-match-patterns.rs diff --git a/tests/ui/issues/issue-12285.rs b/tests/ui/match/struct-reference-patterns.rs similarity index 100% rename from tests/ui/issues/issue-12285.rs rename to tests/ui/match/struct-reference-patterns.rs diff --git a/tests/ui/issues/issue-12920.rs b/tests/ui/panics/explicit-panic-unreachable.rs similarity index 100% rename from tests/ui/issues/issue-12920.rs rename to tests/ui/panics/explicit-panic-unreachable.rs diff --git a/tests/ui/issues/issue-13202.rs b/tests/ui/panics/unwrap-or-panic-input.rs similarity index 100% rename from tests/ui/issues/issue-13202.rs rename to tests/ui/panics/unwrap-or-panic-input.rs diff --git a/tests/ui/issues/issue-13407.rs b/tests/ui/privacy/private-unit-struct-assignment.rs similarity index 100% rename from tests/ui/issues/issue-13407.rs rename to tests/ui/privacy/private-unit-struct-assignment.rs diff --git a/tests/ui/issues/issue-13214.rs b/tests/ui/statics/enum-with-static-str-variant.rs similarity index 100% rename from tests/ui/issues/issue-13214.rs rename to tests/ui/statics/enum-with-static-str-variant.rs diff --git a/tests/ui/issues/issue-12041.rs b/tests/ui/threads/moved-value-in-thread-loop.rs similarity index 100% rename from tests/ui/issues/issue-12041.rs rename to tests/ui/threads/moved-value-in-thread-loop.rs diff --git a/tests/ui/issues/issue-12744.rs b/tests/ui/traits/any-trait-object-debug.rs similarity index 100% rename from tests/ui/issues/issue-12744.rs rename to tests/ui/traits/any-trait-object-debug.rs diff --git a/tests/ui/issues/issue-13204.rs b/tests/ui/traits/default-method-lifetime-params.rs similarity index 100% rename from tests/ui/issues/issue-13204.rs rename to tests/ui/traits/default-method-lifetime-params.rs diff --git a/tests/ui/issues/issue-13264.rs b/tests/ui/traits/deref-chain-method-calls.rs similarity index 100% rename from tests/ui/issues/issue-13264.rs rename to tests/ui/traits/deref-chain-method-calls.rs diff --git a/tests/ui/issues/issue-13434.rs b/tests/ui/traits/fnonce-repro-trait-impl.rs similarity index 100% rename from tests/ui/issues/issue-13434.rs rename to tests/ui/traits/fnonce-repro-trait-impl.rs diff --git a/tests/ui/issues/issue-13323.rs b/tests/ui/traits/matcher-trait-equality.rs similarity index 100% rename from tests/ui/issues/issue-13323.rs rename to tests/ui/traits/matcher-trait-equality.rs diff --git a/tests/ui/issues/issue-11820.rs b/tests/ui/traits/reference-clone-noclone.rs similarity index 100% rename from tests/ui/issues/issue-11820.rs rename to tests/ui/traits/reference-clone-noclone.rs diff --git a/tests/ui/issues/issue-13359.rs b/tests/ui/type-inference/isize-usize-mismatch-error.rs similarity index 100% rename from tests/ui/issues/issue-13359.rs rename to tests/ui/type-inference/isize-usize-mismatch-error.rs diff --git a/tests/ui/issues/issue-12909.rs b/tests/ui/type-inference/type-collect-inference.rs similarity index 100% rename from tests/ui/issues/issue-12909.rs rename to tests/ui/type-inference/type-collect-inference.rs diff --git a/tests/ui/issues/issue-11771.rs b/tests/ui/type-inference/unit-type-add-error.rs similarity index 100% rename from tests/ui/issues/issue-11771.rs rename to tests/ui/type-inference/unit-type-add-error.rs diff --git a/tests/ui/issues/issue-11740.rs b/tests/ui/unsafe/unsafe-transmute-in-find.rs similarity index 100% rename from tests/ui/issues/issue-11740.rs rename to tests/ui/unsafe/unsafe-transmute-in-find.rs From effcd540608f4e58f17a2161a6c8344c0a92f8cf Mon Sep 17 00:00:00 2001 From: Jens Reidel Date: Thu, 24 Jul 2025 18:22:51 +0200 Subject: [PATCH 2/9] Make tier 3 musl targets link dynamically by default Since we don't build std for these and don't provide any support for them, these can trivially be changed to link dynamically by default. Signed-off-by: Jens Reidel --- .../rustc_target/src/spec/targets/hexagon_unknown_linux_musl.rs | 1 - .../src/spec/targets/mips64_unknown_linux_muslabi64.rs | 2 -- .../src/spec/targets/powerpc64_unknown_linux_musl.rs | 2 -- .../rustc_target/src/spec/targets/powerpc_unknown_linux_musl.rs | 2 -- .../src/spec/targets/powerpc_unknown_linux_muslspe.rs | 2 -- .../src/spec/targets/riscv32gc_unknown_linux_musl.rs | 2 -- .../rustc_target/src/spec/targets/s390x_unknown_linux_musl.rs | 2 -- .../src/spec/targets/thumbv7neon_unknown_linux_musleabihf.rs | 2 -- 8 files changed, 15 deletions(-) diff --git a/compiler/rustc_target/src/spec/targets/hexagon_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/hexagon_unknown_linux_musl.rs index f7416a7e0fdee..1abf0537cda77 100644 --- a/compiler/rustc_target/src/spec/targets/hexagon_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/hexagon_unknown_linux_musl.rs @@ -7,7 +7,6 @@ pub(crate) fn target() -> Target { // FIXME: HVX length defaults are per-CPU base.features = "-small-data,+hvx-length128b".into(); - base.crt_static_default = false; base.has_rpath = true; base.linker_flavor = LinkerFlavor::Unix(Cc::Yes); diff --git a/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_muslabi64.rs b/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_muslabi64.rs index f95ce75635490..94ecd3590a93a 100644 --- a/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_muslabi64.rs +++ b/compiler/rustc_target/src/spec/targets/mips64_unknown_linux_muslabi64.rs @@ -23,8 +23,6 @@ pub(crate) fn target() -> Target { abi: "abi64".into(), endian: Endian::Big, mcount: "_mcount".into(), - // FIXME(compiler-team#422): musl targets should be dynamically linked by default. - crt_static_default: true, llvm_abiname: "n64".into(), ..base }, diff --git a/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_musl.rs index 4dc76f0936c92..482b6790dadcd 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_musl.rs @@ -10,8 +10,6 @@ pub(crate) fn target() -> Target { base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); base.max_atomic_width = Some(64); base.stack_probes = StackProbeType::Inline; - // FIXME(compiler-team#422): musl targets should be dynamically linked by default. - base.crt_static_default = true; base.abi = "elfv2".into(); base.llvm_abiname = "elfv2".into(); diff --git a/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_musl.rs index 316b62d941b4b..f39142d01018b 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_musl.rs @@ -9,8 +9,6 @@ pub(crate) fn target() -> Target { base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m32"]); base.max_atomic_width = Some(32); base.stack_probes = StackProbeType::Inline; - // FIXME(compiler-team#422): musl targets should be dynamically linked by default. - base.crt_static_default = true; Target { llvm_target: "powerpc-unknown-linux-musl".into(), diff --git a/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_muslspe.rs b/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_muslspe.rs index 30d0d9cb60a77..8ddb45483b3b9 100644 --- a/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_muslspe.rs +++ b/compiler/rustc_target/src/spec/targets/powerpc_unknown_linux_muslspe.rs @@ -9,8 +9,6 @@ pub(crate) fn target() -> Target { base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-mspe"]); base.max_atomic_width = Some(32); base.stack_probes = StackProbeType::Inline; - // FIXME(compiler-team#422): musl targets should be dynamically linked by default. - base.crt_static_default = true; Target { llvm_target: "powerpc-unknown-linux-muslspe".into(), diff --git a/compiler/rustc_target/src/spec/targets/riscv32gc_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/riscv32gc_unknown_linux_musl.rs index 938b39b10c64e..eb592cca1c81d 100644 --- a/compiler/rustc_target/src/spec/targets/riscv32gc_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/riscv32gc_unknown_linux_musl.rs @@ -23,8 +23,6 @@ pub(crate) fn target() -> Target { llvm_abiname: "ilp32d".into(), max_atomic_width: Some(32), supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]), - // FIXME(compiler-team#422): musl targets should be dynamically linked by default. - crt_static_default: true, ..base::linux_musl::opts() }, } diff --git a/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_musl.rs b/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_musl.rs index e9522ac760e1d..0cdbb626739d0 100644 --- a/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_musl.rs +++ b/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_musl.rs @@ -13,8 +13,6 @@ pub(crate) fn target() -> Target { base.stack_probes = StackProbeType::Inline; base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::LEAK | SanitizerSet::MEMORY | SanitizerSet::THREAD; - // FIXME(compiler-team#422): musl targets should be dynamically linked by default. - base.crt_static_default = true; Target { llvm_target: "s390x-unknown-linux-musl".into(), diff --git a/compiler/rustc_target/src/spec/targets/thumbv7neon_unknown_linux_musleabihf.rs b/compiler/rustc_target/src/spec/targets/thumbv7neon_unknown_linux_musleabihf.rs index 81c502bfeadac..e026595439f48 100644 --- a/compiler/rustc_target/src/spec/targets/thumbv7neon_unknown_linux_musleabihf.rs +++ b/compiler/rustc_target/src/spec/targets/thumbv7neon_unknown_linux_musleabihf.rs @@ -27,8 +27,6 @@ pub(crate) fn target() -> Target { features: "+v7,+thumb-mode,+thumb2,+vfp3,+neon".into(), max_atomic_width: Some(64), mcount: "\u{1}mcount".into(), - // FIXME(compiler-team#422): musl targets should be dynamically linked by default. - crt_static_default: true, ..base::linux_musl::opts() }, } From a4a5bf5a71bd0c3fb52a28f81d88ce1755b3bc30 Mon Sep 17 00:00:00 2001 From: Kivooeo Date: Thu, 24 Jul 2025 17:22:54 +0500 Subject: [PATCH 3/9] comments --- .../deref-chain-method-calls-13264.rs} | 2 + ...lts.rs => blocks-without-results-11709.rs} | 2 + .../moved-value-in-thread-loop-12041.rs} | 2 + .../moved-value-in-thread-loop-12041.stderr} | 2 +- ....rs => refcell-borrow-comparison-12033.rs} | 2 + .../string-literal-match-patterns-11869.rs} | 2 + ...d-twice.rs => fnonce-moved-twice-12127.rs} | 2 + .../fnonce-moved-twice-12127.stderr} | 6 +-- ...ind.rs => moved-upvar-mut-rebind-11958.rs} | 2 + .../moved-upvar-mut-rebind-11958.stderr} | 4 +- .../any-trait-object-debug-12744.rs} | 2 + ...r.rs => hashset-connected-border-12860.rs} | 2 + .../vec-macro-in-static-array.rs | 2 + .../vec-macro-in-static-array.stderr} | 2 +- tests/ui/extern/format-message-windows-ffi.rs | 39 --------------- tests/ui/extern/windows-tcb-trash-13259.rs | 49 +++++++++++++++++++ ...rs => anonymous-parameters-trait-13105.rs} | 2 + ...clone.rs => bytes-iterator-clone-12677.rs} | 2 + ...=> iterator-trait-lifetime-error-13058.rs} | 2 + ...terator-trait-lifetime-error-13058.stderr} | 2 +- .../lifetime-inference-destructuring-arg.rs} | 2 + .../matcher-trait-equality-13323.rs} | 2 + ...struct-lifetime-field-assignment-13405.rs} | 2 + .../unsafe-transmute-in-find-11740.rs} | 2 + ...tch.rs => option-result-mismatch-11844.rs} | 2 + .../option-result-mismatch-11844.stderr} | 2 +- ...ption-result-type-param-mismatch-13466.rs} | 2 + ...n-result-type-param-mismatch-13466.stderr} | 4 +- ...s => overeager-sub-match-pruning-13027.rs} | 2 + ...error.rs => slice-move-out-error-12567.rs} | 2 + .../slice-move-out-error-12567.stderr} | 4 +- ....rs => struct-reference-patterns-12285.rs} | 2 + .../encode-symbol-ice-12920.rs} | 2 + .../privacy/private-unit-struct-assignment.rs | 2 + .../private-unit-struct-assignment.stderr} | 6 +-- .../use-in-impl-scope-12729.rs} | 2 + .../reference-clone-nonclone-11820.rs} | 2 + ... => enum-with-static-str-variant-13214.rs} | 2 + ...> default-method-lifetime-params-13204.rs} | 2 + ...pl.rs => fnonce-repro-trait-impl-13434.rs} | 2 + ...nference.rs => partial-type-hint-12909.rs} | 2 + .../function-in-pattern-error-12863.rs} | 2 + .../function-in-pattern-error-12863.stderr} | 2 +- .../isize-usize-mismatch-error.rs | 2 + .../isize-usize-mismatch-error.stderr} | 8 +-- .../unit-type-add-error-11771.rs} | 2 + .../unit-type-add-error-11771.stderr} | 4 +- .../unwrap-or-panic-input-13202.rs} | 2 + 48 files changed, 140 insertions(+), 62 deletions(-) rename tests/ui/{traits/deref-chain-method-calls.rs => autoref-autoderef/deref-chain-method-calls-13264.rs} (93%) rename tests/ui/block-result/{blocks-without-results.rs => blocks-without-results-11709.rs} (91%) rename tests/ui/{threads/moved-value-in-thread-loop.rs => borrowck/moved-value-in-thread-loop-12041.rs} (78%) rename tests/ui/{issues/issue-12041.stderr => borrowck/moved-value-in-thread-loop-12041.stderr} (87%) rename tests/ui/borrowck/{refcell-borrow-comparison.rs => refcell-borrow-comparison-12033.rs} (61%) rename tests/ui/{match/string-literal-match-patterns.rs => borrowck/string-literal-match-patterns-11869.rs} (75%) rename tests/ui/closures/{fnonce-moved-twice.rs => fnonce-moved-twice-12127.rs} (82%) rename tests/ui/{issues/issue-12127.stderr => closures/fnonce-moved-twice-12127.stderr} (62%) rename tests/ui/closures/{moved-upvar-mut-rebind.rs => moved-upvar-mut-rebind-11958.rs} (78%) rename tests/ui/{issues/issue-11958.stderr => closures/moved-upvar-mut-rebind-11958.stderr} (84%) rename tests/ui/{traits/any-trait-object-debug.rs => coercion/any-trait-object-debug-12744.rs} (62%) rename tests/ui/collections/{hashset-connected-border.rs => hashset-connected-border-12860.rs} (95%) rename tests/ui/{issues/issue-13446.stderr => const-generics/vec-macro-in-static-array.stderr} (90%) delete mode 100644 tests/ui/extern/format-message-windows-ffi.rs create mode 100644 tests/ui/extern/windows-tcb-trash-13259.rs rename tests/ui/fn/{anonymous-parameters-trait.rs => anonymous-parameters-trait-13105.rs} (61%) rename tests/ui/iterators/{bytes-iterator-clone.rs => bytes-iterator-clone-12677.rs} (71%) rename tests/ui/lifetimes/{iterator-trait-lifetime-error.rs => iterator-trait-lifetime-error-13058.rs} (90%) rename tests/ui/{issues/issue-13058.stderr => lifetimes/iterator-trait-lifetime-error-13058.stderr} (90%) rename tests/ui/{iterators/phf-map-entries-iterator.rs => lifetimes/lifetime-inference-destructuring-arg.rs} (88%) rename tests/ui/{traits/matcher-trait-equality.rs => lifetimes/matcher-trait-equality-13323.rs} (93%) rename tests/ui/lifetimes/{struct-lifetime-field-assignment.rs => struct-lifetime-field-assignment-13405.rs} (79%) rename tests/ui/{unsafe/unsafe-transmute-in-find.rs => lifetimes/unsafe-transmute-in-find-11740.rs} (87%) rename tests/ui/match/{option-result-mismatch.rs => option-result-mismatch-11844.rs} (69%) rename tests/ui/{issues/issue-11844.stderr => match/option-result-mismatch-11844.stderr} (90%) rename tests/ui/match/{option-result-type-param-mismatch.rs => option-result-type-param-mismatch-13466.rs} (91%) rename tests/ui/{issues/issue-13466.stderr => match/option-result-type-param-mismatch-13466.stderr} (87%) rename tests/ui/match/{guard-literal-range-shadow.rs => overeager-sub-match-pruning-13027.rs} (97%) rename tests/ui/match/{slice-move-out-error.rs => slice-move-out-error-12567.rs} (85%) rename tests/ui/{issues/issue-12567.stderr => match/slice-move-out-error-12567.stderr} (94%) rename tests/ui/match/{struct-reference-patterns.rs => struct-reference-patterns-12285.rs} (73%) rename tests/ui/{panics/explicit-panic-unreachable.rs => parser/encode-symbol-ice-12920.rs} (63%) rename tests/ui/{issues/issue-13407.stderr => privacy/private-unit-struct-assignment.stderr} (79%) rename tests/ui/{imports/use-in-impl-scope.rs => privacy/use-in-impl-scope-12729.rs} (68%) rename tests/ui/{traits/reference-clone-noclone.rs => resolve/reference-clone-nonclone-11820.rs} (73%) rename tests/ui/statics/{enum-with-static-str-variant.rs => enum-with-static-str-variant-13214.rs} (81%) rename tests/ui/traits/{default-method-lifetime-params.rs => default-method-lifetime-params-13204.rs} (88%) rename tests/ui/traits/{fnonce-repro-trait-impl.rs => fnonce-repro-trait-impl-13434.rs} (84%) rename tests/ui/type-inference/{type-collect-inference.rs => partial-type-hint-12909.rs} (86%) rename tests/ui/{match/function-in-pattern-error.rs => typeck/function-in-pattern-error-12863.rs} (71%) rename tests/ui/{issues/issue-12863.stderr => typeck/function-in-pattern-error-12863.stderr} (85%) rename tests/ui/{type-inference => typeck}/isize-usize-mismatch-error.rs (80%) rename tests/ui/{issues/issue-13359.stderr => typeck/isize-usize-mismatch-error.stderr} (85%) rename tests/ui/{type-inference/unit-type-add-error.rs => typeck/unit-type-add-error-11771.rs} (63%) rename tests/ui/{issues/issue-11771.stderr => typeck/unit-type-add-error-11771.stderr} (93%) rename tests/ui/{panics/unwrap-or-panic-input.rs => typeck/unwrap-or-panic-input-13202.rs} (65%) diff --git a/tests/ui/traits/deref-chain-method-calls.rs b/tests/ui/autoref-autoderef/deref-chain-method-calls-13264.rs similarity index 93% rename from tests/ui/traits/deref-chain-method-calls.rs rename to tests/ui/autoref-autoderef/deref-chain-method-calls-13264.rs index bf4ec388c4fd0..f471c1c7eefca 100644 --- a/tests/ui/traits/deref-chain-method-calls.rs +++ b/tests/ui/autoref-autoderef/deref-chain-method-calls-13264.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13264 + //@ run-pass #![allow(non_camel_case_types)] #![allow(non_snake_case)] diff --git a/tests/ui/block-result/blocks-without-results.rs b/tests/ui/block-result/blocks-without-results-11709.rs similarity index 91% rename from tests/ui/block-result/blocks-without-results.rs rename to tests/ui/block-result/blocks-without-results-11709.rs index 8a11074eca8e2..97ea6f9e19edc 100644 --- a/tests/ui/block-result/blocks-without-results.rs +++ b/tests/ui/block-result/blocks-without-results-11709.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/11709 + //@ run-pass #![allow(dead_code)] diff --git a/tests/ui/threads/moved-value-in-thread-loop.rs b/tests/ui/borrowck/moved-value-in-thread-loop-12041.rs similarity index 78% rename from tests/ui/threads/moved-value-in-thread-loop.rs rename to tests/ui/borrowck/moved-value-in-thread-loop-12041.rs index 091e8fe8b2a66..98f9cdbdef790 100644 --- a/tests/ui/threads/moved-value-in-thread-loop.rs +++ b/tests/ui/borrowck/moved-value-in-thread-loop-12041.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/12041 + use std::sync::mpsc::channel; use std::thread; diff --git a/tests/ui/issues/issue-12041.stderr b/tests/ui/borrowck/moved-value-in-thread-loop-12041.stderr similarity index 87% rename from tests/ui/issues/issue-12041.stderr rename to tests/ui/borrowck/moved-value-in-thread-loop-12041.stderr index f2c10b833836b..627dd193dadeb 100644 --- a/tests/ui/issues/issue-12041.stderr +++ b/tests/ui/borrowck/moved-value-in-thread-loop-12041.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `tx` - --> $DIR/issue-12041.rs:8:22 + --> $DIR/moved-value-in-thread-loop-12041.rs:10:22 | LL | let tx = tx; | ^^ value moved here, in previous iteration of loop diff --git a/tests/ui/borrowck/refcell-borrow-comparison.rs b/tests/ui/borrowck/refcell-borrow-comparison-12033.rs similarity index 61% rename from tests/ui/borrowck/refcell-borrow-comparison.rs rename to tests/ui/borrowck/refcell-borrow-comparison-12033.rs index 0bf6490bafed8..de22cedd5b94a 100644 --- a/tests/ui/borrowck/refcell-borrow-comparison.rs +++ b/tests/ui/borrowck/refcell-borrow-comparison-12033.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/12033 + //@ run-pass use std::cell::RefCell; diff --git a/tests/ui/match/string-literal-match-patterns.rs b/tests/ui/borrowck/string-literal-match-patterns-11869.rs similarity index 75% rename from tests/ui/match/string-literal-match-patterns.rs rename to tests/ui/borrowck/string-literal-match-patterns-11869.rs index dd752227bbec7..4c159e457cf10 100644 --- a/tests/ui/match/string-literal-match-patterns.rs +++ b/tests/ui/borrowck/string-literal-match-patterns-11869.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/11869 + //@ check-pass #![allow(dead_code)] diff --git a/tests/ui/closures/fnonce-moved-twice.rs b/tests/ui/closures/fnonce-moved-twice-12127.rs similarity index 82% rename from tests/ui/closures/fnonce-moved-twice.rs rename to tests/ui/closures/fnonce-moved-twice-12127.rs index 199d542e816f4..369ddcafaabd3 100644 --- a/tests/ui/closures/fnonce-moved-twice.rs +++ b/tests/ui/closures/fnonce-moved-twice-12127.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/12127 + #![feature(unboxed_closures, tuple_trait)] fn to_fn_once>(f: F) -> F { f } diff --git a/tests/ui/issues/issue-12127.stderr b/tests/ui/closures/fnonce-moved-twice-12127.stderr similarity index 62% rename from tests/ui/issues/issue-12127.stderr rename to tests/ui/closures/fnonce-moved-twice-12127.stderr index 2a6233547ee8c..c2e12827527b3 100644 --- a/tests/ui/issues/issue-12127.stderr +++ b/tests/ui/closures/fnonce-moved-twice-12127.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `f` - --> $DIR/issue-12127.rs:11:9 + --> $DIR/fnonce-moved-twice-12127.rs:13:9 | LL | f(); | --- `f` moved due to this call @@ -7,11 +7,11 @@ LL | f(); | ^ value used here after move | note: this value implements `FnOnce`, which causes it to be moved when called - --> $DIR/issue-12127.rs:10:9 + --> $DIR/fnonce-moved-twice-12127.rs:12:9 | LL | f(); | ^ - = note: move occurs because `f` has type `{closure@$DIR/issue-12127.rs:8:24: 8:30}`, which does not implement the `Copy` trait + = note: move occurs because `f` has type `{closure@$DIR/fnonce-moved-twice-12127.rs:10:24: 10:30}`, which does not implement the `Copy` trait error: aborting due to 1 previous error diff --git a/tests/ui/closures/moved-upvar-mut-rebind.rs b/tests/ui/closures/moved-upvar-mut-rebind-11958.rs similarity index 78% rename from tests/ui/closures/moved-upvar-mut-rebind.rs rename to tests/ui/closures/moved-upvar-mut-rebind-11958.rs index 9185c5158af64..701dc1a2cefd2 100644 --- a/tests/ui/closures/moved-upvar-mut-rebind.rs +++ b/tests/ui/closures/moved-upvar-mut-rebind-11958.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/11958 + //@ run-pass // We shouldn't need to rebind a moved upvar as mut if it's already diff --git a/tests/ui/issues/issue-11958.stderr b/tests/ui/closures/moved-upvar-mut-rebind-11958.stderr similarity index 84% rename from tests/ui/issues/issue-11958.stderr rename to tests/ui/closures/moved-upvar-mut-rebind-11958.stderr index 5dca4c2f01d56..b12bbcad92588 100644 --- a/tests/ui/issues/issue-11958.stderr +++ b/tests/ui/closures/moved-upvar-mut-rebind-11958.stderr @@ -1,5 +1,5 @@ warning: value assigned to `x` is never read - --> $DIR/issue-11958.rs:8:36 + --> $DIR/moved-upvar-mut-rebind-11958.rs:10:36 | LL | let _thunk = Box::new(move|| { x = 2; }); | ^ @@ -8,7 +8,7 @@ LL | let _thunk = Box::new(move|| { x = 2; }); = note: `#[warn(unused_assignments)]` on by default warning: unused variable: `x` - --> $DIR/issue-11958.rs:8:36 + --> $DIR/moved-upvar-mut-rebind-11958.rs:10:36 | LL | let _thunk = Box::new(move|| { x = 2; }); | ^ diff --git a/tests/ui/traits/any-trait-object-debug.rs b/tests/ui/coercion/any-trait-object-debug-12744.rs similarity index 62% rename from tests/ui/traits/any-trait-object-debug.rs rename to tests/ui/coercion/any-trait-object-debug-12744.rs index eaf92d413d57e..4d981c077ee25 100644 --- a/tests/ui/traits/any-trait-object-debug.rs +++ b/tests/ui/coercion/any-trait-object-debug-12744.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/12744 + //@ run-pass fn main() { fn test() -> Box { Box::new(1) } diff --git a/tests/ui/collections/hashset-connected-border.rs b/tests/ui/collections/hashset-connected-border-12860.rs similarity index 95% rename from tests/ui/collections/hashset-connected-border.rs rename to tests/ui/collections/hashset-connected-border-12860.rs index 255f667079375..40185bef7c8df 100644 --- a/tests/ui/collections/hashset-connected-border.rs +++ b/tests/ui/collections/hashset-connected-border-12860.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/12860 + //@ run-pass use std::collections::HashSet; diff --git a/tests/ui/const-generics/vec-macro-in-static-array.rs b/tests/ui/const-generics/vec-macro-in-static-array.rs index 9f1fc42774fb2..7a81836e2556b 100644 --- a/tests/ui/const-generics/vec-macro-in-static-array.rs +++ b/tests/ui/const-generics/vec-macro-in-static-array.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13446 + // Used to cause ICE static VEC: [u32; 256] = vec![]; diff --git a/tests/ui/issues/issue-13446.stderr b/tests/ui/const-generics/vec-macro-in-static-array.stderr similarity index 90% rename from tests/ui/issues/issue-13446.stderr rename to tests/ui/const-generics/vec-macro-in-static-array.stderr index 28c459e6e62ce..de21f2274f3a4 100644 --- a/tests/ui/issues/issue-13446.stderr +++ b/tests/ui/const-generics/vec-macro-in-static-array.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-13446.rs:3:26 + --> $DIR/vec-macro-in-static-array.rs:5:26 | LL | static VEC: [u32; 256] = vec![]; | ^^^^^^ expected `[u32; 256]`, found `Vec<_>` diff --git a/tests/ui/extern/format-message-windows-ffi.rs b/tests/ui/extern/format-message-windows-ffi.rs deleted file mode 100644 index 381e3f1525901..0000000000000 --- a/tests/ui/extern/format-message-windows-ffi.rs +++ /dev/null @@ -1,39 +0,0 @@ -//@ run-pass - -#[cfg(windows)] -mod imp { - type LPVOID = *mut u8; - type DWORD = u32; - type LPWSTR = *mut u16; - - extern "system" { - fn FormatMessageW(flags: DWORD, - lpSrc: LPVOID, - msgId: DWORD, - langId: DWORD, - buf: LPWSTR, - nsize: DWORD, - args: *const u8) - -> DWORD; - } - - pub fn test() { - let mut buf: [u16; 50] = [0; 50]; - let ret = unsafe { - FormatMessageW(0x1000, core::ptr::null_mut(), 1, 0x400, - buf.as_mut_ptr(), buf.len() as u32, core::ptr::null()) - }; - // On some 32-bit Windowses (Win7-8 at least) this will panic with segmented - // stacks taking control of pvArbitrary - assert!(ret != 0); - } -} - -#[cfg(not(windows))] -mod imp { - pub fn test() { } -} - -fn main() { - imp::test() -} diff --git a/tests/ui/extern/windows-tcb-trash-13259.rs b/tests/ui/extern/windows-tcb-trash-13259.rs new file mode 100644 index 0000000000000..0852e31251ac4 --- /dev/null +++ b/tests/ui/extern/windows-tcb-trash-13259.rs @@ -0,0 +1,49 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13259 + +//@ run-pass + +#[cfg(windows)] +mod imp { + type LPVOID = *mut u8; + type DWORD = u32; + type LPWSTR = *mut u16; + + extern "system" { + fn FormatMessageW( + flags: DWORD, + lpSrc: LPVOID, + msgId: DWORD, + langId: DWORD, + buf: LPWSTR, + nsize: DWORD, + args: *const u8, + ) -> DWORD; + } + + pub fn test() { + let mut buf: [u16; 50] = [0; 50]; + let ret = unsafe { + FormatMessageW( + 0x1000, + core::ptr::null_mut(), + 1, + 0x400, + buf.as_mut_ptr(), + buf.len() as u32, + core::ptr::null(), + ) + }; + // On some 32-bit Windowses (Win7-8 at least) this will panic with segmented + // stacks taking control of pvArbitrary + assert!(ret != 0); + } +} + +#[cfg(not(windows))] +mod imp { + pub fn test() {} +} + +fn main() { + imp::test() +} diff --git a/tests/ui/fn/anonymous-parameters-trait.rs b/tests/ui/fn/anonymous-parameters-trait-13105.rs similarity index 61% rename from tests/ui/fn/anonymous-parameters-trait.rs rename to tests/ui/fn/anonymous-parameters-trait-13105.rs index d119aa9c788d9..171dab15fe716 100644 --- a/tests/ui/fn/anonymous-parameters-trait.rs +++ b/tests/ui/fn/anonymous-parameters-trait-13105.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13105 + //@ edition: 2015 //@ check-pass diff --git a/tests/ui/iterators/bytes-iterator-clone.rs b/tests/ui/iterators/bytes-iterator-clone-12677.rs similarity index 71% rename from tests/ui/iterators/bytes-iterator-clone.rs rename to tests/ui/iterators/bytes-iterator-clone-12677.rs index dbc2dbc85276e..cfbb85a3ecba5 100644 --- a/tests/ui/iterators/bytes-iterator-clone.rs +++ b/tests/ui/iterators/bytes-iterator-clone-12677.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/12677 + //@ run-pass fn main() { diff --git a/tests/ui/lifetimes/iterator-trait-lifetime-error.rs b/tests/ui/lifetimes/iterator-trait-lifetime-error-13058.rs similarity index 90% rename from tests/ui/lifetimes/iterator-trait-lifetime-error.rs rename to tests/ui/lifetimes/iterator-trait-lifetime-error-13058.rs index a5806feb720d6..6cfe440b43d71 100644 --- a/tests/ui/lifetimes/iterator-trait-lifetime-error.rs +++ b/tests/ui/lifetimes/iterator-trait-lifetime-error-13058.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13058 + use std::ops::Range; trait Itble<'r, T, I: Iterator> { fn iter(&'r self) -> I; } diff --git a/tests/ui/issues/issue-13058.stderr b/tests/ui/lifetimes/iterator-trait-lifetime-error-13058.stderr similarity index 90% rename from tests/ui/issues/issue-13058.stderr rename to tests/ui/lifetimes/iterator-trait-lifetime-error-13058.stderr index 4f4108fa18254..e6564e36b2151 100644 --- a/tests/ui/issues/issue-13058.stderr +++ b/tests/ui/lifetimes/iterator-trait-lifetime-error-13058.stderr @@ -1,5 +1,5 @@ error[E0621]: explicit lifetime required in the type of `cont` - --> $DIR/issue-13058.rs:14:21 + --> $DIR/iterator-trait-lifetime-error-13058.rs:16:21 | LL | let cont_iter = cont.iter(); | ^^^^^^^^^^^ lifetime `'r` required diff --git a/tests/ui/iterators/phf-map-entries-iterator.rs b/tests/ui/lifetimes/lifetime-inference-destructuring-arg.rs similarity index 88% rename from tests/ui/iterators/phf-map-entries-iterator.rs rename to tests/ui/lifetimes/lifetime-inference-destructuring-arg.rs index 5f733e8594888..7a019a71d75c7 100644 --- a/tests/ui/iterators/phf-map-entries-iterator.rs +++ b/tests/ui/lifetimes/lifetime-inference-destructuring-arg.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13167 + //@ check-pass //@ revisions: current next //@ ignore-compare-mode-next-solver (explicit revisions) diff --git a/tests/ui/traits/matcher-trait-equality.rs b/tests/ui/lifetimes/matcher-trait-equality-13323.rs similarity index 93% rename from tests/ui/traits/matcher-trait-equality.rs rename to tests/ui/lifetimes/matcher-trait-equality-13323.rs index 8f334404f9ab8..efd56294b3981 100644 --- a/tests/ui/traits/matcher-trait-equality.rs +++ b/tests/ui/lifetimes/matcher-trait-equality-13323.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13323 + //@ run-pass struct StrWrap { diff --git a/tests/ui/lifetimes/struct-lifetime-field-assignment.rs b/tests/ui/lifetimes/struct-lifetime-field-assignment-13405.rs similarity index 79% rename from tests/ui/lifetimes/struct-lifetime-field-assignment.rs rename to tests/ui/lifetimes/struct-lifetime-field-assignment-13405.rs index 80b298d2f37aa..9482d89681b5d 100644 --- a/tests/ui/lifetimes/struct-lifetime-field-assignment.rs +++ b/tests/ui/lifetimes/struct-lifetime-field-assignment-13405.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13405 + //@ check-pass #![allow(dead_code)] #![allow(unused_variables)] diff --git a/tests/ui/unsafe/unsafe-transmute-in-find.rs b/tests/ui/lifetimes/unsafe-transmute-in-find-11740.rs similarity index 87% rename from tests/ui/unsafe/unsafe-transmute-in-find.rs rename to tests/ui/lifetimes/unsafe-transmute-in-find-11740.rs index c6099c2a0c041..eeecd2e9e4046 100644 --- a/tests/ui/unsafe/unsafe-transmute-in-find.rs +++ b/tests/ui/lifetimes/unsafe-transmute-in-find-11740.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/11740 + //@ check-pass struct Attr { diff --git a/tests/ui/match/option-result-mismatch.rs b/tests/ui/match/option-result-mismatch-11844.rs similarity index 69% rename from tests/ui/match/option-result-mismatch.rs rename to tests/ui/match/option-result-mismatch-11844.rs index f974a4702960a..24a2004134df2 100644 --- a/tests/ui/match/option-result-mismatch.rs +++ b/tests/ui/match/option-result-mismatch-11844.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/11844 + fn main() { let a = Some(Box::new(1)); match a { diff --git a/tests/ui/issues/issue-11844.stderr b/tests/ui/match/option-result-mismatch-11844.stderr similarity index 90% rename from tests/ui/issues/issue-11844.stderr rename to tests/ui/match/option-result-mismatch-11844.stderr index 9ff66eaef498e..8a84b7b8a4861 100644 --- a/tests/ui/issues/issue-11844.stderr +++ b/tests/ui/match/option-result-mismatch-11844.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-11844.rs:4:9 + --> $DIR/option-result-mismatch-11844.rs:6:9 | LL | match a { | - this expression has type `Option>` diff --git a/tests/ui/match/option-result-type-param-mismatch.rs b/tests/ui/match/option-result-type-param-mismatch-13466.rs similarity index 91% rename from tests/ui/match/option-result-type-param-mismatch.rs rename to tests/ui/match/option-result-type-param-mismatch-13466.rs index 78ce4c1d2f604..05dbdfdee0e3a 100644 --- a/tests/ui/match/option-result-type-param-mismatch.rs +++ b/tests/ui/match/option-result-type-param-mismatch-13466.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13466 + // Regression test for #13466 //@ dont-require-annotations: NOTE diff --git a/tests/ui/issues/issue-13466.stderr b/tests/ui/match/option-result-type-param-mismatch-13466.stderr similarity index 87% rename from tests/ui/issues/issue-13466.stderr rename to tests/ui/match/option-result-type-param-mismatch-13466.stderr index 68a555a16260a..b0cf1591f5eed 100644 --- a/tests/ui/issues/issue-13466.stderr +++ b/tests/ui/match/option-result-type-param-mismatch-13466.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-13466.rs:10:9 + --> $DIR/option-result-type-param-mismatch-13466.rs:12:9 | LL | let _x: usize = match Some(1) { | ------- this expression has type `Option<{integer}>` @@ -10,7 +10,7 @@ LL | Ok(u) => u, found enum `Result<_, _>` error[E0308]: mismatched types - --> $DIR/issue-13466.rs:16:9 + --> $DIR/option-result-type-param-mismatch-13466.rs:18:9 | LL | let _x: usize = match Some(1) { | ------- this expression has type `Option<{integer}>` diff --git a/tests/ui/match/guard-literal-range-shadow.rs b/tests/ui/match/overeager-sub-match-pruning-13027.rs similarity index 97% rename from tests/ui/match/guard-literal-range-shadow.rs rename to tests/ui/match/overeager-sub-match-pruning-13027.rs index fbd1d75067b5c..c4feb697f7d12 100644 --- a/tests/ui/match/guard-literal-range-shadow.rs +++ b/tests/ui/match/overeager-sub-match-pruning-13027.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13027 + //@ run-pass // Tests that match expression handles overlapped literal and range diff --git a/tests/ui/match/slice-move-out-error.rs b/tests/ui/match/slice-move-out-error-12567.rs similarity index 85% rename from tests/ui/match/slice-move-out-error.rs rename to tests/ui/match/slice-move-out-error-12567.rs index 1b2a37de47539..3f9bf9c76cf3d 100644 --- a/tests/ui/match/slice-move-out-error.rs +++ b/tests/ui/match/slice-move-out-error-12567.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/12567 + fn match_vecs<'a, T>(l1: &'a [T], l2: &'a [T]) { match (l1, l2) { //~^ ERROR: cannot move out of type `[T]`, a non-copy slice diff --git a/tests/ui/issues/issue-12567.stderr b/tests/ui/match/slice-move-out-error-12567.stderr similarity index 94% rename from tests/ui/issues/issue-12567.stderr rename to tests/ui/match/slice-move-out-error-12567.stderr index 0b19299ece3ec..ab5377d470135 100644 --- a/tests/ui/issues/issue-12567.stderr +++ b/tests/ui/match/slice-move-out-error-12567.stderr @@ -1,5 +1,5 @@ error[E0508]: cannot move out of type `[T]`, a non-copy slice - --> $DIR/issue-12567.rs:2:11 + --> $DIR/slice-move-out-error-12567.rs:4:11 | LL | match (l1, l2) { | ^^^^^^^^ cannot move out of here @@ -23,7 +23,7 @@ LL + (&[hd1, ..], [hd2, ..]) | error[E0508]: cannot move out of type `[T]`, a non-copy slice - --> $DIR/issue-12567.rs:2:11 + --> $DIR/slice-move-out-error-12567.rs:4:11 | LL | match (l1, l2) { | ^^^^^^^^ cannot move out of here diff --git a/tests/ui/match/struct-reference-patterns.rs b/tests/ui/match/struct-reference-patterns-12285.rs similarity index 73% rename from tests/ui/match/struct-reference-patterns.rs rename to tests/ui/match/struct-reference-patterns-12285.rs index fe199147128b4..246e230b0de74 100644 --- a/tests/ui/match/struct-reference-patterns.rs +++ b/tests/ui/match/struct-reference-patterns-12285.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/12285 + //@ run-pass struct S; diff --git a/tests/ui/panics/explicit-panic-unreachable.rs b/tests/ui/parser/encode-symbol-ice-12920.rs similarity index 63% rename from tests/ui/panics/explicit-panic-unreachable.rs rename to tests/ui/parser/encode-symbol-ice-12920.rs index f3b1b643c45af..87389c0ffb420 100644 --- a/tests/ui/panics/explicit-panic-unreachable.rs +++ b/tests/ui/parser/encode-symbol-ice-12920.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/12920 + //@ run-fail //@ error-pattern:explicit panic //@ needs-subprocess diff --git a/tests/ui/privacy/private-unit-struct-assignment.rs b/tests/ui/privacy/private-unit-struct-assignment.rs index 7794be37b8507..b8e1c4ecb188e 100644 --- a/tests/ui/privacy/private-unit-struct-assignment.rs +++ b/tests/ui/privacy/private-unit-struct-assignment.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13407 + mod A { struct C; } diff --git a/tests/ui/issues/issue-13407.stderr b/tests/ui/privacy/private-unit-struct-assignment.stderr similarity index 79% rename from tests/ui/issues/issue-13407.stderr rename to tests/ui/privacy/private-unit-struct-assignment.stderr index ac2eb6581fe25..8c36a08846d81 100644 --- a/tests/ui/issues/issue-13407.stderr +++ b/tests/ui/privacy/private-unit-struct-assignment.stderr @@ -1,17 +1,17 @@ error[E0603]: unit struct `C` is private - --> $DIR/issue-13407.rs:6:8 + --> $DIR/private-unit-struct-assignment.rs:8:8 | LL | A::C = 1; | ^ private unit struct | note: the unit struct `C` is defined here - --> $DIR/issue-13407.rs:2:5 + --> $DIR/private-unit-struct-assignment.rs:4:5 | LL | struct C; | ^^^^^^^^^ error[E0308]: mismatched types - --> $DIR/issue-13407.rs:6:5 + --> $DIR/private-unit-struct-assignment.rs:8:5 | LL | struct C; | -------- unit struct defined here diff --git a/tests/ui/imports/use-in-impl-scope.rs b/tests/ui/privacy/use-in-impl-scope-12729.rs similarity index 68% rename from tests/ui/imports/use-in-impl-scope.rs rename to tests/ui/privacy/use-in-impl-scope-12729.rs index 4d45846bc6083..58fe042beece4 100644 --- a/tests/ui/imports/use-in-impl-scope.rs +++ b/tests/ui/privacy/use-in-impl-scope-12729.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/12729 + //@ edition: 2015 //@ check-pass #![allow(dead_code)] diff --git a/tests/ui/traits/reference-clone-noclone.rs b/tests/ui/resolve/reference-clone-nonclone-11820.rs similarity index 73% rename from tests/ui/traits/reference-clone-noclone.rs rename to tests/ui/resolve/reference-clone-nonclone-11820.rs index ada844f8ee121..74dad96da94e2 100644 --- a/tests/ui/traits/reference-clone-noclone.rs +++ b/tests/ui/resolve/reference-clone-nonclone-11820.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/11820 + //@ run-pass #![allow(noop_method_call)] diff --git a/tests/ui/statics/enum-with-static-str-variant.rs b/tests/ui/statics/enum-with-static-str-variant-13214.rs similarity index 81% rename from tests/ui/statics/enum-with-static-str-variant.rs rename to tests/ui/statics/enum-with-static-str-variant-13214.rs index 8140ec943a01f..1db37da632de3 100644 --- a/tests/ui/statics/enum-with-static-str-variant.rs +++ b/tests/ui/statics/enum-with-static-str-variant-13214.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13214 + //@ build-pass #![allow(dead_code)] // defining static with struct that contains enum diff --git a/tests/ui/traits/default-method-lifetime-params.rs b/tests/ui/traits/default-method-lifetime-params-13204.rs similarity index 88% rename from tests/ui/traits/default-method-lifetime-params.rs rename to tests/ui/traits/default-method-lifetime-params-13204.rs index 01362f6fe61d6..cdf34ab773c1c 100644 --- a/tests/ui/traits/default-method-lifetime-params.rs +++ b/tests/ui/traits/default-method-lifetime-params-13204.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13204 + //@ run-pass #![allow(unused_mut)] // Test that when instantiating trait default methods, typeck handles diff --git a/tests/ui/traits/fnonce-repro-trait-impl.rs b/tests/ui/traits/fnonce-repro-trait-impl-13434.rs similarity index 84% rename from tests/ui/traits/fnonce-repro-trait-impl.rs rename to tests/ui/traits/fnonce-repro-trait-impl-13434.rs index caf7b6323933e..61d5a1d74aeed 100644 --- a/tests/ui/traits/fnonce-repro-trait-impl.rs +++ b/tests/ui/traits/fnonce-repro-trait-impl-13434.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13434 + //@ run-pass #[derive(Debug)] struct MyStruct; diff --git a/tests/ui/type-inference/type-collect-inference.rs b/tests/ui/type-inference/partial-type-hint-12909.rs similarity index 86% rename from tests/ui/type-inference/type-collect-inference.rs rename to tests/ui/type-inference/partial-type-hint-12909.rs index f2c33806aae88..d7017f451e323 100644 --- a/tests/ui/type-inference/type-collect-inference.rs +++ b/tests/ui/type-inference/partial-type-hint-12909.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/12909 + //@ run-pass #![allow(unused_variables)] diff --git a/tests/ui/match/function-in-pattern-error.rs b/tests/ui/typeck/function-in-pattern-error-12863.rs similarity index 71% rename from tests/ui/match/function-in-pattern-error.rs rename to tests/ui/typeck/function-in-pattern-error-12863.rs index 1ac1c3d818e58..d2fa255565847 100644 --- a/tests/ui/match/function-in-pattern-error.rs +++ b/tests/ui/typeck/function-in-pattern-error-12863.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/12863 + mod foo { pub fn bar() {} } fn main() { diff --git a/tests/ui/issues/issue-12863.stderr b/tests/ui/typeck/function-in-pattern-error-12863.stderr similarity index 85% rename from tests/ui/issues/issue-12863.stderr rename to tests/ui/typeck/function-in-pattern-error-12863.stderr index 95d4a704e72db..f28874b5d4850 100644 --- a/tests/ui/issues/issue-12863.stderr +++ b/tests/ui/typeck/function-in-pattern-error-12863.stderr @@ -1,5 +1,5 @@ error[E0532]: expected unit struct, unit variant or constant, found function `foo::bar` - --> $DIR/issue-12863.rs:5:9 + --> $DIR/function-in-pattern-error-12863.rs:7:9 | LL | foo::bar => {} | ^^^^^^^^ not a unit struct, unit variant or constant diff --git a/tests/ui/type-inference/isize-usize-mismatch-error.rs b/tests/ui/typeck/isize-usize-mismatch-error.rs similarity index 80% rename from tests/ui/type-inference/isize-usize-mismatch-error.rs rename to tests/ui/typeck/isize-usize-mismatch-error.rs index 5d31d7f861c68..2fb5cf489c03b 100644 --- a/tests/ui/type-inference/isize-usize-mismatch-error.rs +++ b/tests/ui/typeck/isize-usize-mismatch-error.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13359 + //@ dont-require-annotations: NOTE fn foo(_s: i16) { } diff --git a/tests/ui/issues/issue-13359.stderr b/tests/ui/typeck/isize-usize-mismatch-error.stderr similarity index 85% rename from tests/ui/issues/issue-13359.stderr rename to tests/ui/typeck/isize-usize-mismatch-error.stderr index 91f5de8e8f3ad..d5724665a03c8 100644 --- a/tests/ui/issues/issue-13359.stderr +++ b/tests/ui/typeck/isize-usize-mismatch-error.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-13359.rs:8:9 + --> $DIR/isize-usize-mismatch-error.rs:10:9 | LL | foo(1*(1 as isize)); | --- ^^^^^^^^^^^^^^ expected `i16`, found `isize` @@ -7,7 +7,7 @@ LL | foo(1*(1 as isize)); | arguments to this function are incorrect | note: function defined here - --> $DIR/issue-13359.rs:3:4 + --> $DIR/isize-usize-mismatch-error.rs:5:4 | LL | fn foo(_s: i16) { } | ^^^ ------- @@ -17,7 +17,7 @@ LL | foo((1*(1 as isize)).try_into().unwrap()); | + +++++++++++++++++++++ error[E0308]: mismatched types - --> $DIR/issue-13359.rs:12:9 + --> $DIR/isize-usize-mismatch-error.rs:14:9 | LL | bar(1*(1 as usize)); | --- ^^^^^^^^^^^^^^ expected `u32`, found `usize` @@ -25,7 +25,7 @@ LL | bar(1*(1 as usize)); | arguments to this function are incorrect | note: function defined here - --> $DIR/issue-13359.rs:5:4 + --> $DIR/isize-usize-mismatch-error.rs:7:4 | LL | fn bar(_s: u32) { } | ^^^ ------- diff --git a/tests/ui/type-inference/unit-type-add-error.rs b/tests/ui/typeck/unit-type-add-error-11771.rs similarity index 63% rename from tests/ui/type-inference/unit-type-add-error.rs rename to tests/ui/typeck/unit-type-add-error-11771.rs index c69cd1e79e372..d009f50f4b925 100644 --- a/tests/ui/type-inference/unit-type-add-error.rs +++ b/tests/ui/typeck/unit-type-add-error-11771.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/11771 + fn main() { let x = (); 1 + diff --git a/tests/ui/issues/issue-11771.stderr b/tests/ui/typeck/unit-type-add-error-11771.stderr similarity index 93% rename from tests/ui/issues/issue-11771.stderr rename to tests/ui/typeck/unit-type-add-error-11771.stderr index 5603dc18b635f..155cc09352456 100644 --- a/tests/ui/issues/issue-11771.stderr +++ b/tests/ui/typeck/unit-type-add-error-11771.stderr @@ -1,5 +1,5 @@ error[E0277]: cannot add `()` to `{integer}` - --> $DIR/issue-11771.rs:3:7 + --> $DIR/unit-type-add-error-11771.rs:5:7 | LL | 1 + | ^ no implementation for `{integer} + ()` @@ -17,7 +17,7 @@ LL | 1 + and 56 others error[E0277]: cannot add `()` to `{integer}` - --> $DIR/issue-11771.rs:8:7 + --> $DIR/unit-type-add-error-11771.rs:10:7 | LL | 1 + | ^ no implementation for `{integer} + ()` diff --git a/tests/ui/panics/unwrap-or-panic-input.rs b/tests/ui/typeck/unwrap-or-panic-input-13202.rs similarity index 65% rename from tests/ui/panics/unwrap-or-panic-input.rs rename to tests/ui/typeck/unwrap-or-panic-input-13202.rs index 99ffba3fba51a..29833a727c559 100644 --- a/tests/ui/panics/unwrap-or-panic-input.rs +++ b/tests/ui/typeck/unwrap-or-panic-input-13202.rs @@ -1,3 +1,5 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/13202 + //@ run-fail //@ error-pattern:bad input //@ needs-subprocess From 32f4876bf156317536c7a2a06f451fedf8afc22a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Thu, 31 Jul 2025 19:39:59 +0200 Subject: [PATCH 4/9] Create a typed wrapper for codegen backends To avoid representing them just with strings. --- src/bootstrap/src/core/build_steps/check.rs | 19 +++++---- src/bootstrap/src/core/build_steps/compile.rs | 24 ++++++----- src/bootstrap/src/core/build_steps/dist.rs | 30 +++++++------- src/bootstrap/src/core/build_steps/install.rs | 4 +- src/bootstrap/src/core/build_steps/test.rs | 10 +++-- src/bootstrap/src/core/builder/cargo.rs | 2 +- src/bootstrap/src/core/builder/mod.rs | 16 ++++---- src/bootstrap/src/core/builder/tests.rs | 24 +++++------ src/bootstrap/src/core/config/config.rs | 12 +++--- src/bootstrap/src/core/config/toml/rust.rs | 27 +++++++++---- src/bootstrap/src/core/config/toml/target.rs | 8 ++-- src/bootstrap/src/lib.rs | 40 +++++++++++++++++++ src/bootstrap/src/utils/build_stamp.rs | 6 +-- 13 files changed, 143 insertions(+), 79 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/check.rs b/src/bootstrap/src/core/build_steps/check.rs index b4232409ba83d..f6653ed899bfc 100644 --- a/src/bootstrap/src/core/build_steps/check.rs +++ b/src/bootstrap/src/core/build_steps/check.rs @@ -13,7 +13,7 @@ use crate::core::builder::{ }; use crate::core::config::TargetSelection; use crate::utils::build_stamp::{self, BuildStamp}; -use crate::{Compiler, Mode, Subcommand}; +use crate::{CodegenBackendKind, Compiler, Mode, Subcommand}; #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct Std { @@ -312,7 +312,7 @@ fn prepare_compiler_for_check( pub struct CodegenBackend { pub build_compiler: Compiler, pub target: TargetSelection, - pub backend: &'static str, + pub backend: CodegenBackendKind, } impl Step for CodegenBackend { @@ -327,14 +327,14 @@ impl Step for CodegenBackend { fn make_run(run: RunConfig<'_>) { // FIXME: only check the backend(s) that were actually selected in run.paths let build_compiler = prepare_compiler_for_check(run.builder, run.target, Mode::Codegen); - for &backend in &["cranelift", "gcc"] { + for backend in [CodegenBackendKind::Cranelift, CodegenBackendKind::Gcc] { run.builder.ensure(CodegenBackend { build_compiler, target: run.target, backend }); } } fn run(self, builder: &Builder<'_>) { // FIXME: remove once https://github.com/rust-lang/rust/issues/112393 is resolved - if builder.build.config.vendor && self.backend == "gcc" { + if builder.build.config.vendor && self.backend.is_gcc() { println!("Skipping checking of `rustc_codegen_gcc` with vendoring enabled."); return; } @@ -354,19 +354,22 @@ impl Step for CodegenBackend { cargo .arg("--manifest-path") - .arg(builder.src.join(format!("compiler/rustc_codegen_{backend}/Cargo.toml"))); + .arg(builder.src.join(format!("compiler/{}/Cargo.toml", backend.crate_name()))); rustc_cargo_env(builder, &mut cargo, target); - let _guard = builder.msg_check(format!("rustc_codegen_{backend}"), target, None); + let _guard = builder.msg_check(backend.crate_name(), target, None); - let stamp = build_stamp::codegen_backend_stamp(builder, build_compiler, target, backend) + let stamp = build_stamp::codegen_backend_stamp(builder, build_compiler, target, &backend) .with_prefix("check"); run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false); } fn metadata(&self) -> Option { - Some(StepMetadata::check(self.backend, self.target).built_by(self.build_compiler)) + Some( + StepMetadata::check(&self.backend.crate_name(), self.target) + .built_by(self.build_compiler), + ) } } diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 4abfe1843ebeb..59541bf12def0 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -33,7 +33,10 @@ use crate::utils::exec::command; use crate::utils::helpers::{ exe, get_clang_cl_resource_dir, is_debug_info, is_dylib, symlink_dir, t, up_to_date, }; -use crate::{CLang, Compiler, DependencyType, FileType, GitRepo, LLVM_TOOLS, Mode, debug, trace}; +use crate::{ + CLang, CodegenBackendKind, Compiler, DependencyType, FileType, GitRepo, LLVM_TOOLS, Mode, + debug, trace, +}; /// Build a standard library for the given `target` using the given `compiler`. #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] @@ -1330,7 +1333,7 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetS } if let Some(backend) = builder.config.default_codegen_backend(target) { - cargo.env("CFG_DEFAULT_CODEGEN_BACKEND", backend); + cargo.env("CFG_DEFAULT_CODEGEN_BACKEND", backend.name()); } let libdir_relative = builder.config.libdir_relative().unwrap_or_else(|| Path::new("lib")); @@ -1543,7 +1546,7 @@ impl Step for RustcLink { pub struct CodegenBackend { pub target: TargetSelection, pub compiler: Compiler, - pub backend: String, + pub backend: CodegenBackendKind, } fn needs_codegen_config(run: &RunConfig<'_>) -> bool { @@ -1568,7 +1571,7 @@ fn is_codegen_cfg_needed(path: &TaskPath, run: &RunConfig<'_>) -> bool { if path.contains(CODEGEN_BACKEND_PREFIX) { let mut needs_codegen_backend_config = true; for backend in run.builder.config.codegen_backends(run.target) { - if path.ends_with(&(CODEGEN_BACKEND_PREFIX.to_owned() + backend)) { + if path.ends_with(&(CODEGEN_BACKEND_PREFIX.to_owned() + backend.name())) { needs_codegen_backend_config = false; } } @@ -1602,7 +1605,7 @@ impl Step for CodegenBackend { } for backend in run.builder.config.codegen_backends(run.target) { - if backend == "llvm" { + if backend.is_llvm() { continue; // Already built as part of rustc } @@ -1663,20 +1666,21 @@ impl Step for CodegenBackend { ); cargo .arg("--manifest-path") - .arg(builder.src.join(format!("compiler/rustc_codegen_{backend}/Cargo.toml"))); + .arg(builder.src.join(format!("compiler/{}/Cargo.toml", backend.crate_name()))); rustc_cargo_env(builder, &mut cargo, target); // Ideally, we'd have a separate step for the individual codegen backends, // like we have in tests (test::CodegenGCC) but that would require a lot of restructuring. // If the logic gets more complicated, it should probably be done. - if backend == "gcc" { + if backend.is_gcc() { let gcc = builder.ensure(Gcc { target }); add_cg_gcc_cargo_flags(&mut cargo, &gcc); } let tmp_stamp = BuildStamp::new(&out_dir).with_prefix("tmp"); - let _guard = builder.msg_build(compiler, format_args!("codegen backend {backend}"), target); + let _guard = + builder.msg_build(compiler, format_args!("codegen backend {}", backend.name()), target); let files = run_cargo(builder, cargo, vec![], &tmp_stamp, vec![], false, false); if builder.config.dry_run() { return; @@ -1731,7 +1735,7 @@ fn copy_codegen_backends_to_sysroot( } for backend in builder.config.codegen_backends(target) { - if backend == "llvm" { + if backend.is_llvm() { continue; // Already built as part of rustc } @@ -2161,7 +2165,7 @@ impl Step for Assemble { let _codegen_backend_span = span!(tracing::Level::DEBUG, "building requested codegen backends").entered(); for backend in builder.config.codegen_backends(target_compiler.host) { - if backend == "llvm" { + if backend.is_llvm() { debug!("llvm codegen backend is already built as part of rustc"); continue; // Already built as part of rustc } diff --git a/src/bootstrap/src/core/build_steps/dist.rs b/src/bootstrap/src/core/build_steps/dist.rs index c8a54ad250cb3..4699813abf42a 100644 --- a/src/bootstrap/src/core/build_steps/dist.rs +++ b/src/bootstrap/src/core/build_steps/dist.rs @@ -32,7 +32,7 @@ use crate::utils::helpers::{ exe, is_dylib, move_file, t, target_supports_cranelift_backend, timeit, }; use crate::utils::tarball::{GeneratedTarball, OverlayKind, Tarball}; -use crate::{Compiler, DependencyType, FileType, LLVM_TOOLS, Mode, trace}; +use crate::{CodegenBackendKind, Compiler, DependencyType, FileType, LLVM_TOOLS, Mode, trace}; pub fn pkgname(builder: &Builder<'_>, component: &str) -> String { format!("{}-{}", component, builder.rust_package_vers()) @@ -1372,10 +1372,10 @@ impl Step for Miri { } } -#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct CodegenBackend { pub compiler: Compiler, - pub backend: String, + pub backend: CodegenBackendKind, } impl Step for CodegenBackend { @@ -1389,7 +1389,7 @@ impl Step for CodegenBackend { fn make_run(run: RunConfig<'_>) { for backend in run.builder.config.codegen_backends(run.target) { - if backend == "llvm" { + if backend.is_llvm() { continue; // Already built as part of rustc } @@ -1412,12 +1412,11 @@ impl Step for CodegenBackend { return None; } - if !builder.config.codegen_backends(self.compiler.host).contains(&self.backend.to_string()) - { + if !builder.config.codegen_backends(self.compiler.host).contains(&self.backend) { return None; } - if self.backend == "cranelift" && !target_supports_cranelift_backend(self.compiler.host) { + if self.backend.is_cranelift() && !target_supports_cranelift_backend(self.compiler.host) { builder.info("target not supported by rustc_codegen_cranelift. skipping"); return None; } @@ -1425,15 +1424,18 @@ impl Step for CodegenBackend { let compiler = self.compiler; let backend = self.backend; - let mut tarball = - Tarball::new(builder, &format!("rustc-codegen-{backend}"), &compiler.host.triple); - if backend == "cranelift" { + let mut tarball = Tarball::new( + builder, + &format!("rustc-codegen-{}", backend.name()), + &compiler.host.triple, + ); + if backend.is_cranelift() { tarball.set_overlay(OverlayKind::RustcCodegenCranelift); } else { - panic!("Unknown backend rustc_codegen_{backend}"); + panic!("Unknown codegen backend {}", backend.name()); } tarball.is_preview(true); - tarball.add_legal_and_readme_to(format!("share/doc/rustc_codegen_{backend}")); + tarball.add_legal_and_readme_to(format!("share/doc/{}", backend.crate_name())); let src = builder.sysroot(compiler); let backends_src = builder.sysroot_codegen_backends(compiler); @@ -1445,7 +1447,7 @@ impl Step for CodegenBackend { // Don't use custom libdir here because ^lib/ will be resolved again with installer let backends_dst = PathBuf::from("lib").join(backends_rel); - let backend_name = format!("rustc_codegen_{backend}"); + let backend_name = backend.crate_name(); let mut found_backend = false; for backend in fs::read_dir(&backends_src).unwrap() { let file_name = backend.unwrap().file_name(); @@ -1575,7 +1577,7 @@ impl Step for Extended { add_component!("analysis" => Analysis { compiler, target }); add_component!("rustc-codegen-cranelift" => CodegenBackend { compiler: builder.compiler(stage, target), - backend: "cranelift".to_string(), + backend: CodegenBackendKind::Cranelift, }); add_component!("llvm-bitcode-linker" => LlvmBitcodeLinker { build_compiler: compiler, diff --git a/src/bootstrap/src/core/build_steps/install.rs b/src/bootstrap/src/core/build_steps/install.rs index 4156b49a8b337..4513a138e192a 100644 --- a/src/bootstrap/src/core/build_steps/install.rs +++ b/src/bootstrap/src/core/build_steps/install.rs @@ -12,7 +12,7 @@ use crate::core::config::{Config, TargetSelection}; use crate::utils::exec::command; use crate::utils::helpers::t; use crate::utils::tarball::GeneratedTarball; -use crate::{Compiler, Kind}; +use crate::{CodegenBackendKind, Compiler, Kind}; #[cfg(target_os = "illumos")] const SHELL: &str = "bash"; @@ -276,7 +276,7 @@ install!((self, builder, _config), RustcCodegenCranelift, alias = "rustc-codegen-cranelift", Self::should_build(_config), only_hosts: true, { if let Some(tarball) = builder.ensure(dist::CodegenBackend { compiler: self.compiler, - backend: "cranelift".to_string(), + backend: CodegenBackendKind::Cranelift, }) { install_sh(builder, "rustc-codegen-cranelift", self.compiler.stage, Some(self.target), &tarball); } else { diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 951ca73fcc494..119fa4237bcfe 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -33,7 +33,7 @@ use crate::utils::helpers::{ linker_flags, t, target_supports_cranelift_backend, up_to_date, }; use crate::utils::render_tests::{add_flags_and_try_run_tests, try_run_tests}; -use crate::{CLang, DocTests, GitRepo, Mode, PathSet, debug, envify}; +use crate::{CLang, CodegenBackendKind, DocTests, GitRepo, Mode, PathSet, debug, envify}; const ADB_TEST_DIR: &str = "/data/local/tmp/work"; @@ -1786,7 +1786,9 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the cmd.arg("--llvm-filecheck").arg(builder.llvm_filecheck(builder.config.host_target)); if let Some(codegen_backend) = builder.config.default_codegen_backend(compiler.host) { - cmd.arg("--codegen-backend").arg(&codegen_backend); + // Tells compiletest which codegen backend is used by default by the compiler. + // It is used to e.g. ignore tests that don't support that codegen backend. + cmd.arg("--codegen-backend").arg(codegen_backend.name()); } if builder.build.config.llvm_enzyme { @@ -3406,7 +3408,7 @@ impl Step for CodegenCranelift { return; } - if !builder.config.codegen_backends(run.target).contains(&"cranelift".to_owned()) { + if !builder.config.codegen_backends(run.target).contains(&CodegenBackendKind::Cranelift) { builder.info("cranelift not in rust.codegen-backends. skipping"); return; } @@ -3533,7 +3535,7 @@ impl Step for CodegenGCC { return; } - if !builder.config.codegen_backends(run.target).contains(&"gcc".to_owned()) { + if !builder.config.codegen_backends(run.target).contains(&CodegenBackendKind::Gcc) { builder.info("gcc not in rust.codegen-backends. skipping"); return; } diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index badd5f24dba7e..6b3236ef47ef6 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -1286,7 +1286,7 @@ impl Builder<'_> { if let Some(limit) = limit && (build_compiler_stage == 0 - || self.config.default_codegen_backend(target).unwrap_or_default() == "llvm") + || self.config.default_codegen_backend(target).unwrap_or_default().is_llvm()) { rustflags.arg(&format!("-Cllvm-args=-import-instr-limit={limit}")); } diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs index 020622d1c1219..96289a63785e2 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -141,7 +141,7 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash { #[allow(unused)] #[derive(Debug, PartialEq, Eq)] pub struct StepMetadata { - name: &'static str, + name: String, kind: Kind, target: TargetSelection, built_by: Option, @@ -151,28 +151,28 @@ pub struct StepMetadata { } impl StepMetadata { - pub fn build(name: &'static str, target: TargetSelection) -> Self { + pub fn build(name: &str, target: TargetSelection) -> Self { Self::new(name, target, Kind::Build) } - pub fn check(name: &'static str, target: TargetSelection) -> Self { + pub fn check(name: &str, target: TargetSelection) -> Self { Self::new(name, target, Kind::Check) } - pub fn doc(name: &'static str, target: TargetSelection) -> Self { + pub fn doc(name: &str, target: TargetSelection) -> Self { Self::new(name, target, Kind::Doc) } - pub fn dist(name: &'static str, target: TargetSelection) -> Self { + pub fn dist(name: &str, target: TargetSelection) -> Self { Self::new(name, target, Kind::Dist) } - pub fn test(name: &'static str, target: TargetSelection) -> Self { + pub fn test(name: &str, target: TargetSelection) -> Self { Self::new(name, target, Kind::Test) } - fn new(name: &'static str, target: TargetSelection, kind: Kind) -> Self { - Self { name, kind, target, built_by: None, stage: None, metadata: None } + fn new(name: &str, target: TargetSelection, kind: Kind) -> Self { + Self { name: name.to_string(), kind, target, built_by: None, stage: None, metadata: None } } pub fn built_by(mut self, compiler: Compiler) -> Self { diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs index 6ea5d4e655328..7192c9f9a175e 100644 --- a/src/bootstrap/src/core/builder/tests.rs +++ b/src/bootstrap/src/core/builder/tests.rs @@ -1309,8 +1309,8 @@ mod snapshot { .path("compiler") .render_steps(), @r" [check] rustc 0 -> rustc 1 - [check] rustc 0 -> cranelift 1 - [check] rustc 0 -> gcc 1 + [check] rustc 0 -> rustc_codegen_cranelift 1 + [check] rustc 0 -> rustc_codegen_gcc 1 "); } @@ -1341,8 +1341,8 @@ mod snapshot { .stage(1) .render_steps(), @r" [check] rustc 0 -> rustc 1 - [check] rustc 0 -> cranelift 1 - [check] rustc 0 -> gcc 1 + [check] rustc 0 -> rustc_codegen_cranelift 1 + [check] rustc 0 -> rustc_codegen_gcc 1 "); } @@ -1358,8 +1358,8 @@ mod snapshot { [build] rustc 0 -> rustc 1 [build] rustc 1 -> std 1 [check] rustc 1 -> rustc 2 - [check] rustc 1 -> cranelift 2 - [check] rustc 1 -> gcc 2 + [check] rustc 1 -> rustc_codegen_cranelift 2 + [check] rustc 1 -> rustc_codegen_gcc 2 "); } @@ -1377,8 +1377,8 @@ mod snapshot { [build] rustc 1 -> std 1 [check] rustc 1 -> rustc 2 [check] rustc 1 -> Rustdoc 2 - [check] rustc 1 -> cranelift 2 - [check] rustc 1 -> gcc 2 + [check] rustc 1 -> rustc_codegen_cranelift 2 + [check] rustc 1 -> rustc_codegen_gcc 2 [check] rustc 1 -> Clippy 2 [check] rustc 1 -> Miri 2 [check] rustc 1 -> CargoMiri 2 @@ -1472,8 +1472,8 @@ mod snapshot { .args(&args) .render_steps(), @r" [check] rustc 0 -> rustc 1 - [check] rustc 0 -> cranelift 1 - [check] rustc 0 -> gcc 1 + [check] rustc 0 -> rustc_codegen_cranelift 1 + [check] rustc 0 -> rustc_codegen_gcc 1 "); } @@ -1557,8 +1557,8 @@ mod snapshot { .path("rustc_codegen_cranelift") .render_steps(), @r" [check] rustc 0 -> rustc 1 - [check] rustc 0 -> cranelift 1 - [check] rustc 0 -> gcc 1 + [check] rustc 0 -> rustc_codegen_cranelift 1 + [check] rustc 0 -> rustc_codegen_gcc 1 "); } diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 78abdd7f9b8ce..6055876c47579 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -51,7 +51,7 @@ use crate::core::download::{ use crate::utils::channel; use crate::utils::exec::{ExecutionContext, command}; use crate::utils::helpers::{exe, get_host_target}; -use crate::{GitInfo, OnceLock, TargetSelection, check_ci_llvm, helpers, t}; +use crate::{CodegenBackendKind, GitInfo, OnceLock, TargetSelection, check_ci_llvm, helpers, t}; /// Each path in this list is considered "allowed" in the `download-rustc="if-unchanged"` logic. /// This means they can be modified and changes to these paths should never trigger a compiler build @@ -208,7 +208,7 @@ pub struct Config { pub rustc_default_linker: Option, pub rust_optimize_tests: bool, pub rust_dist_src: bool, - pub rust_codegen_backends: Vec, + pub rust_codegen_backends: Vec, pub rust_verify_llvm_ir: bool, pub rust_thin_lto_import_instr_limit: Option, pub rust_randomize_layout: bool, @@ -350,7 +350,7 @@ impl Config { channel: "dev".to_string(), codegen_tests: true, rust_dist_src: true, - rust_codegen_backends: vec!["llvm".to_owned()], + rust_codegen_backends: vec![CodegenBackendKind::Llvm], deny_warnings: true, bindir: "bin".into(), dist_include_mingw_linker: true, @@ -1747,7 +1747,7 @@ impl Config { .unwrap_or(self.profiler) } - pub fn codegen_backends(&self, target: TargetSelection) -> &[String] { + pub fn codegen_backends(&self, target: TargetSelection) -> &[CodegenBackendKind] { self.target_config .get(&target) .and_then(|cfg| cfg.codegen_backends.as_deref()) @@ -1758,7 +1758,7 @@ impl Config { self.target_config.get(&target).and_then(|cfg| cfg.jemalloc).unwrap_or(self.jemalloc) } - pub fn default_codegen_backend(&self, target: TargetSelection) -> Option { + pub fn default_codegen_backend(&self, target: TargetSelection) -> Option { self.codegen_backends(target).first().cloned() } @@ -1774,7 +1774,7 @@ impl Config { } pub fn llvm_enabled(&self, target: TargetSelection) -> bool { - self.codegen_backends(target).contains(&"llvm".to_owned()) + self.codegen_backends(target).contains(&CodegenBackendKind::Llvm) } pub fn llvm_libunwind(&self, target: TargetSelection) -> LlvmLibunwind { diff --git a/src/bootstrap/src/core/config/toml/rust.rs b/src/bootstrap/src/core/config/toml/rust.rs index c136bd4a6f9bd..03da993a17dd2 100644 --- a/src/bootstrap/src/core/config/toml/rust.rs +++ b/src/bootstrap/src/core/config/toml/rust.rs @@ -11,7 +11,9 @@ use crate::core::config::{ DebuginfoLevel, Merge, ReplaceOpt, RustcLto, StringOrBool, set, threads_from_config, }; use crate::flags::Warnings; -use crate::{BTreeSet, Config, HashSet, PathBuf, TargetSelection, define_config, exit}; +use crate::{ + BTreeSet, CodegenBackendKind, Config, HashSet, PathBuf, TargetSelection, define_config, exit, +}; define_config! { /// TOML representation of how the Rust build is configured. @@ -389,9 +391,13 @@ pub fn check_incompatible_options_for_ci_rustc( Ok(()) } -pub(crate) const VALID_CODEGEN_BACKENDS: &[&str] = &["llvm", "cranelift", "gcc"]; +pub(crate) const BUILTIN_CODEGEN_BACKENDS: &[&str] = &["llvm", "cranelift", "gcc"]; -pub(crate) fn validate_codegen_backends(backends: Vec, section: &str) -> Vec { +pub(crate) fn parse_codegen_backends( + backends: Vec, + section: &str, +) -> Vec { + let mut found_backends = vec![]; for backend in &backends { if let Some(stripped) = backend.strip_prefix(CODEGEN_BACKEND_PREFIX) { panic!( @@ -400,14 +406,21 @@ pub(crate) fn validate_codegen_backends(backends: Vec, section: &str) -> Please, use '{stripped}' instead." ) } - if !VALID_CODEGEN_BACKENDS.contains(&backend.as_str()) { + if !BUILTIN_CODEGEN_BACKENDS.contains(&backend.as_str()) { println!( "HELP: '{backend}' for '{section}.codegen-backends' might fail. \ - List of known good values: {VALID_CODEGEN_BACKENDS:?}" + List of known codegen backends: {BUILTIN_CODEGEN_BACKENDS:?}" ); } + let backend = match backend.as_str() { + "llvm" => CodegenBackendKind::Llvm, + "cranelift" => CodegenBackendKind::Cranelift, + "gcc" => CodegenBackendKind::Gcc, + backend => CodegenBackendKind::Custom(backend.to_string()), + }; + found_backends.push(backend); } - backends + found_backends } #[cfg(not(test))] @@ -609,7 +622,7 @@ impl Config { llvm_libunwind.map(|v| v.parse().expect("failed to parse rust.llvm-libunwind")); set( &mut self.rust_codegen_backends, - codegen_backends.map(|backends| validate_codegen_backends(backends, "rust")), + codegen_backends.map(|backends| parse_codegen_backends(backends, "rust")), ); self.rust_codegen_units = codegen_units.map(threads_from_config); diff --git a/src/bootstrap/src/core/config/toml/target.rs b/src/bootstrap/src/core/config/toml/target.rs index 337276948b324..9dedadff3a19d 100644 --- a/src/bootstrap/src/core/config/toml/target.rs +++ b/src/bootstrap/src/core/config/toml/target.rs @@ -16,9 +16,9 @@ use std::collections::HashMap; use serde::{Deserialize, Deserializer}; -use crate::core::config::toml::rust::validate_codegen_backends; +use crate::core::config::toml::rust::parse_codegen_backends; use crate::core::config::{LlvmLibunwind, Merge, ReplaceOpt, SplitDebuginfo, StringOrBool}; -use crate::{Config, HashSet, PathBuf, TargetSelection, define_config, exit}; +use crate::{CodegenBackendKind, Config, HashSet, PathBuf, TargetSelection, define_config, exit}; define_config! { /// TOML representation of how each build target is configured. @@ -76,7 +76,7 @@ pub struct Target { pub qemu_rootfs: Option, pub runner: Option, pub no_std: bool, - pub codegen_backends: Option>, + pub codegen_backends: Option>, pub optimized_compiler_builtins: Option, pub jemalloc: Option, } @@ -144,7 +144,7 @@ impl Config { target.jemalloc = cfg.jemalloc; if let Some(backends) = cfg.codegen_backends { target.codegen_backends = - Some(validate_codegen_backends(backends, &format!("target.{triple}"))) + Some(parse_codegen_backends(backends, &format!("target.{triple}"))) } target.split_debuginfo = cfg.split_debuginfo.as_ref().map(|v| { diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs index 51a84ad5272c9..011b52df97bbd 100644 --- a/src/bootstrap/src/lib.rs +++ b/src/bootstrap/src/lib.rs @@ -123,6 +123,46 @@ impl PartialEq for Compiler { } } +/// Represents a codegen backend. +#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)] +pub enum CodegenBackendKind { + #[default] + Llvm, + Cranelift, + Gcc, + Custom(String), +} + +impl CodegenBackendKind { + /// Name of the codegen backend, as identified in the `compiler` directory + /// (`rustc_codegen_`). + pub fn name(&self) -> &str { + match self { + CodegenBackendKind::Llvm => "llvm", + CodegenBackendKind::Cranelift => "cranelift", + CodegenBackendKind::Gcc => "gcc", + CodegenBackendKind::Custom(name) => name, + } + } + + /// Name of the codegen backend's crate, e.g. `rustc_codegen_cranelift`. + pub fn crate_name(&self) -> String { + format!("rustc_codegen_{}", self.name()) + } + + pub fn is_llvm(&self) -> bool { + matches!(self, Self::Llvm) + } + + pub fn is_cranelift(&self) -> bool { + matches!(self, Self::Cranelift) + } + + pub fn is_gcc(&self) -> bool { + matches!(self, Self::Gcc) + } +} + #[derive(PartialEq, Eq, Copy, Clone, Debug)] pub enum DocTests { /// Run normal tests and doc tests (default). diff --git a/src/bootstrap/src/utils/build_stamp.rs b/src/bootstrap/src/utils/build_stamp.rs index f43d860893f6b..bd4eb790ae50e 100644 --- a/src/bootstrap/src/utils/build_stamp.rs +++ b/src/bootstrap/src/utils/build_stamp.rs @@ -10,7 +10,7 @@ use sha2::digest::Digest; use crate::core::builder::Builder; use crate::core::config::TargetSelection; use crate::utils::helpers::{hex_encode, mtime}; -use crate::{Compiler, Mode, helpers, t}; +use crate::{CodegenBackendKind, Compiler, Mode, helpers, t}; #[cfg(test)] mod tests; @@ -129,10 +129,10 @@ pub fn codegen_backend_stamp( builder: &Builder<'_>, compiler: Compiler, target: TargetSelection, - backend: &str, + backend: &CodegenBackendKind, ) -> BuildStamp { BuildStamp::new(&builder.cargo_out(compiler, Mode::Codegen, target)) - .with_prefix(&format!("librustc_codegen_{backend}")) + .with_prefix(&format!("lib{}", backend.crate_name())) } /// Cargo's output path for the standard library in a given stage, compiled From 4e806c8a342589f64f61119f69fc68c565e331c8 Mon Sep 17 00:00:00 2001 From: Stypox Date: Wed, 30 Jul 2025 23:50:31 +0200 Subject: [PATCH 5/9] Add tracing calls to eval_statement/terminator --- .../rustc_const_eval/src/interpret/step.rs | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_const_eval/src/interpret/step.rs b/compiler/rustc_const_eval/src/interpret/step.rs index 629dcc3523ca0..b43854fd60bc3 100644 --- a/compiler/rustc_const_eval/src/interpret/step.rs +++ b/compiler/rustc_const_eval/src/interpret/step.rs @@ -9,13 +9,14 @@ use rustc_middle::ty::{self, Instance, Ty}; use rustc_middle::{bug, mir, span_bug}; use rustc_span::source_map::Spanned; use rustc_target::callconv::FnAbi; +use tracing::field::Empty; use tracing::{info, instrument, trace}; use super::{ FnArg, FnVal, ImmTy, Immediate, InterpCx, InterpResult, Machine, MemPlaceMeta, PlaceTy, Projectable, Scalar, interp_ok, throw_ub, throw_unsup_format, }; -use crate::util; +use crate::{enter_trace_span, util}; struct EvaluatedCalleeAndArgs<'tcx, M: Machine<'tcx>> { callee: FnVal<'tcx, M::ExtraFnVal>, @@ -74,7 +75,14 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { /// /// This does NOT move the statement counter forward, the caller has to do that! pub fn eval_statement(&mut self, stmt: &mir::Statement<'tcx>) -> InterpResult<'tcx> { - info!("{:?}", stmt); + let _span = enter_trace_span!( + M, + step::eval_statement, + stmt = ?stmt.kind, + span = ?stmt.source_info.span, + tracing_separate_thread = Empty, + ); + info!(stmt = ?stmt.kind); use rustc_middle::mir::StatementKind::*; @@ -456,7 +464,14 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { } fn eval_terminator(&mut self, terminator: &mir::Terminator<'tcx>) -> InterpResult<'tcx> { - info!("{:?}", terminator.kind); + let _span = enter_trace_span!( + M, + step::eval_terminator, + terminator = ?terminator.kind, + span = ?terminator.source_info.span, + tracing_separate_thread = Empty, + ); + info!(terminator = ?terminator.kind); use rustc_middle::mir::TerminatorKind::*; match terminator.kind { From 188f7367bff680a9e3ef2141a08cec24163ba70d Mon Sep 17 00:00:00 2001 From: Stypox Date: Thu, 31 Jul 2025 00:27:42 +0200 Subject: [PATCH 6/9] Add tracing to more functions related to step.rs --- compiler/rustc_const_eval/src/interpret/call.rs | 7 ++++++- compiler/rustc_const_eval/src/interpret/operand.rs | 12 ++++++++++++ compiler/rustc_const_eval/src/interpret/place.rs | 5 +++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_const_eval/src/interpret/call.rs b/compiler/rustc_const_eval/src/interpret/call.rs index 5b3adba02659c..24c440844226d 100644 --- a/compiler/rustc_const_eval/src/interpret/call.rs +++ b/compiler/rustc_const_eval/src/interpret/call.rs @@ -11,6 +11,7 @@ use rustc_middle::ty::{self, AdtDef, Instance, Ty, VariantDef}; use rustc_middle::{bug, mir, span_bug}; use rustc_span::sym; use rustc_target::callconv::{ArgAbi, FnAbi, PassMode}; +use tracing::field::Empty; use tracing::{info, instrument, trace}; use super::{ @@ -18,7 +19,7 @@ use super::{ Projectable, Provenance, ReturnAction, ReturnContinuation, Scalar, StackPopInfo, interp_ok, throw_ub, throw_ub_custom, throw_unsup_format, }; -use crate::fluent_generated as fluent; +use crate::{enter_trace_span, fluent_generated as fluent}; /// An argument passed to a function. #[derive(Clone, Debug)] @@ -344,6 +345,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { destination: &PlaceTy<'tcx, M::Provenance>, mut cont: ReturnContinuation, ) -> InterpResult<'tcx> { + let _span = enter_trace_span!(M, step::init_stack_frame, %instance, tracing_separate_thread = Empty); + // Compute callee information. // FIXME: for variadic support, do we have to somehow determine callee's extra_args? let callee_fn_abi = self.fn_abi_of_instance(instance, ty::List::empty())?; @@ -523,6 +526,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { target: Option, unwind: mir::UnwindAction, ) -> InterpResult<'tcx> { + let _span = + enter_trace_span!(M, step::init_fn_call, tracing_separate_thread = Empty, ?fn_val); trace!("init_fn_call: {:#?}", fn_val); let instance = match fn_val { diff --git a/compiler/rustc_const_eval/src/interpret/operand.rs b/compiler/rustc_const_eval/src/interpret/operand.rs index 21afd082a0551..4171345790864 100644 --- a/compiler/rustc_const_eval/src/interpret/operand.rs +++ b/compiler/rustc_const_eval/src/interpret/operand.rs @@ -13,6 +13,7 @@ use rustc_middle::ty::print::{FmtPrinter, PrettyPrinter}; use rustc_middle::ty::{ConstInt, ScalarInt, Ty, TyCtxt}; use rustc_middle::{bug, mir, span_bug, ty}; use rustc_span::DUMMY_SP; +use tracing::field::Empty; use tracing::trace; use super::{ @@ -20,6 +21,7 @@ use super::{ OffsetMode, PlaceTy, Pointer, Projectable, Provenance, Scalar, alloc_range, err_ub, from_known_layout, interp_ok, mir_assign_valid_types, throw_ub, }; +use crate::enter_trace_span; /// An `Immediate` represents a single immediate self-contained Rust value. /// @@ -770,6 +772,13 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { mir_place: mir::Place<'tcx>, layout: Option>, ) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>> { + let _span = enter_trace_span!( + M, + step::eval_place_to_op, + ?mir_place, + tracing_separate_thread = Empty + ); + // Do not use the layout passed in as argument if the base we are looking at // here is not the entire place. let layout = if mir_place.projection.is_empty() { layout } else { None }; @@ -813,6 +822,9 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { mir_op: &mir::Operand<'tcx>, layout: Option>, ) -> InterpResult<'tcx, OpTy<'tcx, M::Provenance>> { + let _span = + enter_trace_span!(M, step::eval_operand, ?mir_op, tracing_separate_thread = Empty); + use rustc_middle::mir::Operand::*; let op = match mir_op { // FIXME: do some more logic on `move` to invalidate the old location diff --git a/compiler/rustc_const_eval/src/interpret/place.rs b/compiler/rustc_const_eval/src/interpret/place.rs index e2284729efdcf..45c4edb850373 100644 --- a/compiler/rustc_const_eval/src/interpret/place.rs +++ b/compiler/rustc_const_eval/src/interpret/place.rs @@ -9,6 +9,7 @@ use rustc_abi::{BackendRepr, HasDataLayout, Size}; use rustc_middle::ty::Ty; use rustc_middle::ty::layout::TyAndLayout; use rustc_middle::{bug, mir, span_bug}; +use tracing::field::Empty; use tracing::{instrument, trace}; use super::{ @@ -16,6 +17,7 @@ use super::{ InterpResult, Machine, MemoryKind, Misalignment, OffsetMode, OpTy, Operand, Pointer, Projectable, Provenance, Scalar, alloc_range, interp_ok, mir_assign_valid_types, }; +use crate::enter_trace_span; #[derive(Copy, Clone, Hash, PartialEq, Eq, Debug)] /// Information required for the sound usage of a `MemPlace`. @@ -524,6 +526,9 @@ where &self, mir_place: mir::Place<'tcx>, ) -> InterpResult<'tcx, PlaceTy<'tcx, M::Provenance>> { + let _span = + enter_trace_span!(M, step::eval_place, ?mir_place, tracing_separate_thread = Empty); + let mut place = self.local_to_place(mir_place.local)?; // Using `try_fold` turned out to be bad for performance, hence the loop. for elem in mir_place.projection.iter() { From 88c9a256a94dfc3545dadd33fef15e52a6b7d73e Mon Sep 17 00:00:00 2001 From: Stypox Date: Thu, 31 Jul 2025 00:12:48 +0200 Subject: [PATCH 7/9] Add EnteredTraceSpan::or_if_tracing_disabled --- .../rustc_const_eval/src/interpret/call.rs | 5 +-- .../rustc_const_eval/src/interpret/step.rs | 9 ++--- .../rustc_const_eval/src/interpret/util.rs | 35 ++++++++++++++++--- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_const_eval/src/interpret/call.rs b/compiler/rustc_const_eval/src/interpret/call.rs index 24c440844226d..b8a653698258f 100644 --- a/compiler/rustc_const_eval/src/interpret/call.rs +++ b/compiler/rustc_const_eval/src/interpret/call.rs @@ -19,6 +19,7 @@ use super::{ Projectable, Provenance, ReturnAction, ReturnContinuation, Scalar, StackPopInfo, interp_ok, throw_ub, throw_ub_custom, throw_unsup_format, }; +use crate::interpret::EnteredTraceSpan; use crate::{enter_trace_span, fluent_generated as fluent}; /// An argument passed to a function. @@ -527,8 +528,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { unwind: mir::UnwindAction, ) -> InterpResult<'tcx> { let _span = - enter_trace_span!(M, step::init_fn_call, tracing_separate_thread = Empty, ?fn_val); - trace!("init_fn_call: {:#?}", fn_val); + enter_trace_span!(M, step::init_fn_call, tracing_separate_thread = Empty, ?fn_val) + .or_if_tracing_disabled(|| trace!("init_fn_call: {:#?}", fn_val)); let instance = match fn_val { FnVal::Instance(instance) => instance, diff --git a/compiler/rustc_const_eval/src/interpret/step.rs b/compiler/rustc_const_eval/src/interpret/step.rs index b43854fd60bc3..9df49c0f4ccdf 100644 --- a/compiler/rustc_const_eval/src/interpret/step.rs +++ b/compiler/rustc_const_eval/src/interpret/step.rs @@ -16,6 +16,7 @@ use super::{ FnArg, FnVal, ImmTy, Immediate, InterpCx, InterpResult, Machine, MemPlaceMeta, PlaceTy, Projectable, Scalar, interp_ok, throw_ub, throw_unsup_format, }; +use crate::interpret::EnteredTraceSpan; use crate::{enter_trace_span, util}; struct EvaluatedCalleeAndArgs<'tcx, M: Machine<'tcx>> { @@ -81,8 +82,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { stmt = ?stmt.kind, span = ?stmt.source_info.span, tracing_separate_thread = Empty, - ); - info!(stmt = ?stmt.kind); + ) + .or_if_tracing_disabled(|| info!(stmt = ?stmt.kind)); use rustc_middle::mir::StatementKind::*; @@ -470,8 +471,8 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { terminator = ?terminator.kind, span = ?terminator.source_info.span, tracing_separate_thread = Empty, - ); - info!(terminator = ?terminator.kind); + ) + .or_if_tracing_disabled(|| info!(terminator = ?terminator.kind)); use rustc_middle::mir::TerminatorKind::*; match terminator.kind { diff --git a/compiler/rustc_const_eval/src/interpret/util.rs b/compiler/rustc_const_eval/src/interpret/util.rs index 6696a0c502600..71800950faab2 100644 --- a/compiler/rustc_const_eval/src/interpret/util.rs +++ b/compiler/rustc_const_eval/src/interpret/util.rs @@ -48,10 +48,24 @@ pub(crate) fn create_static_alloc<'tcx>( /// A marker trait returned by [crate::interpret::Machine::enter_trace_span], identifying either a /// real [tracing::span::EnteredSpan] in case tracing is enabled, or the dummy type `()` when -/// tracing is disabled. -pub trait EnteredTraceSpan {} -impl EnteredTraceSpan for () {} -impl EnteredTraceSpan for tracing::span::EnteredSpan {} +/// tracing is disabled. Also see [crate::enter_trace_span!] below. +pub trait EnteredTraceSpan { + /// Allows executing an alternative function when tracing is disabled. Useful for example if you + /// want to open a trace span when tracing is enabled, and alternatively just log a line when + /// tracing is disabled. + fn or_if_tracing_disabled(self, f: impl FnOnce()) -> Self; +} +impl EnteredTraceSpan for () { + fn or_if_tracing_disabled(self, f: impl FnOnce()) -> Self { + f(); // tracing is disabled, execute the function + self + } +} +impl EnteredTraceSpan for tracing::span::EnteredSpan { + fn or_if_tracing_disabled(self, _f: impl FnOnce()) -> Self { + self // tracing is enabled, don't execute anything + } +} /// Shortand for calling [crate::interpret::Machine::enter_trace_span] on a [tracing::info_span!]. /// This is supposed to be compiled out when [crate::interpret::Machine::enter_trace_span] has the @@ -112,6 +126,19 @@ impl EnteredTraceSpan for tracing::span::EnteredSpan {} /// # type M = rustc_const_eval::const_eval::CompileTimeMachine<'static>; /// let _span = enter_trace_span!(M, step::eval_statement, tracing_separate_thread = tracing::field::Empty); /// ``` +/// +/// ### Executing something else when tracing is disabled +/// +/// [crate::interpret::Machine::enter_trace_span] returns [EnteredTraceSpan], on which you can call +/// [EnteredTraceSpan::or_if_tracing_disabled], to e.g. log a line as an alternative to the tracing +/// span for when tracing is disabled. For example: +/// ```rust +/// # use rustc_const_eval::enter_trace_span; +/// # use rustc_const_eval::interpret::EnteredTraceSpan; +/// # type M = rustc_const_eval::const_eval::CompileTimeMachine<'static>; +/// let _span = enter_trace_span!(M, step::eval_statement) +/// .or_if_tracing_disabled(|| tracing::info!("eval_statement")); +/// ``` #[macro_export] macro_rules! enter_trace_span { ($machine:ty, $name:ident :: $subname:ident $($tt:tt)*) => { From 89b4bb66d8a439b9906a91a65a4656ea67211a77 Mon Sep 17 00:00:00 2001 From: Jieyou Xu Date: Fri, 1 Aug 2025 14:52:00 +0800 Subject: [PATCH 8/9] Remove some noisy triagebot pings --- triagebot.toml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/triagebot.toml b/triagebot.toml index e1b4983adf7b6..7603bed4d108e 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -1006,10 +1006,6 @@ cc = [ message = "Some changes occurred in GUI tests." cc = ["@GuillaumeGomez"] -[mentions."tests/run-make/"] -message = "This PR modifies `run-make` tests." -cc = ["@jieyouxu"] - [mentions."tests/auxiliary/minicore.rs"] message = "This PR modifies `tests/auxiliary/minicore.rs`." cc = ["@jieyouxu"] @@ -1104,10 +1100,6 @@ Otherwise, you can ignore this comment. [mentions."src/tools/x"] message = "`src/tools/x` was changed. Bump version of Cargo.toml in `src/tools/x` so tidy will suggest installing the new version." -[mentions."src/tools/tidy"] -message = "There are changes to the `tidy` tool." -cc = ["@jieyouxu"] - [mentions."src/tools/tidy/src/deps.rs"] message = "The list of allowed third-party dependencies may have been modified! You must ensure that any new dependencies have compatible licenses before merging." cc = ["@davidtwco", "@wesleywiser"] From 0cc4be268ecd30dbcf63444e0b604f9bd5e127a1 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 1 Aug 2025 09:47:47 +0200 Subject: [PATCH 9/9] add unsupported_calling_conventions to lint list --- compiler/rustc_lint_defs/src/builtin.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index b1edb5c304425..3b84c6b611016 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -125,6 +125,7 @@ declare_lint_pass! { UNSAFE_OP_IN_UNSAFE_FN, UNSTABLE_NAME_COLLISIONS, UNSTABLE_SYNTAX_PRE_EXPANSION, + UNSUPPORTED_CALLING_CONVENTIONS, UNUSED_ASSIGNMENTS, UNUSED_ASSOCIATED_TYPE_BOUNDS, UNUSED_ATTRIBUTES,