rust/tests
Matthias Krüger 5019bdaefe
Rollup merge of #147841 - jdonszelmann:test-macro-ice, r=wafflelapkin
Fix ICE when applying test macro to crate root

This PR does a couple of things. First of all, I found [an ICE](https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=a733a7f3d223e1a9712e44b571f3e5cf) that happens when applying `#![core::prelude::v1::test]` to the crate root. This is caused by the test macro not expanding to an item when `--test` isn't applied. For the crate root, that means it deletes the crate....

The fix now first does target checking, and only if the target is valid discards the item when `--test` isn't applied. The discarding is, I think, important for perf.

The problem with this PR is that it means that `#[test]` applied to structs previously would give no errors unless `--test` is applied! That sounds like a bug to me, but maybe we should crater run it just in case, since technically that's a breaking change. Errors in such items wouldn't be reported previously.

 Also fixed a smol diagnostics bug with `#[bench]`'s error messages refering to `#[test]` accidentally.

r? noratrieb (since I already explained you a bunch, feel free to re-assign)

Fixes https://github.com/rust-lang/rust/issues/114920
2025-12-04 08:46:17 +01:00
..
assembly-llvm Rollup merge of #149409 - cezarbbb:stable_ssp, r=SparrowLii 2025-11-29 21:12:26 +11:00
auxiliary Rollup merge of #147521 - sayantn:simd-const-intrinsics, r=madsmtm 2025-11-19 09:48:07 +01:00
codegen-llvm Auto merge of #147404 - JamieCunliffe:inline-always, r=jackh726 2025-11-28 22:58:22 +00:00
codegen-units Document fmt::Arguments internal representation. 2025-11-12 12:48:39 +01:00
coverage Auto merge of #142821 - cjgillot:jump-threading-single, r=saethlin 2025-12-01 23:44:49 +00:00
coverage-run-rustdoc
crashes ICE when applying test to crate root 2025-12-03 16:38:22 +01:00
debuginfo debuginfo/macro-stepping test: extend comments 2025-12-01 22:32:36 +01:00
incremental Bless tests. 2025-11-12 12:48:27 +01:00
mir-opt Auto merge of #142821 - cjgillot:jump-threading-single, r=saethlin 2025-12-01 23:44:49 +00:00
pretty Document fmt::Arguments internal representation. 2025-11-12 12:48:39 +01:00
run-make Rollup merge of #148234 - notriddle:doc-cci, r=GuillaumeGomez 2025-11-24 19:10:43 +01:00
run-make-cargo Skip the panic-immediate-abort-works test when cross-compiling 2025-09-22 21:13:38 -04:00
rustdoc add test 2025-11-26 16:33:13 +09:00
rustdoc-gui Fix invalid link generation for type alias methods 2025-11-24 17:01:32 +01:00
rustdoc-js Auto merge of #149370 - Zalathar:rollup-6fkk5x4, r=Zalathar 2025-11-27 07:30:25 +00:00
rustdoc-js-std Add regression test for including derive macros in macro filtering 2025-10-27 16:00:32 +01:00
rustdoc-json Add tests for doc(attribute = "...") attribute 2025-08-28 15:56:30 +02:00
rustdoc-ui Merge E0412 into E0425 2025-12-02 18:25:13 +00:00
ui Rollup merge of #147841 - jdonszelmann:test-macro-ice, r=wafflelapkin 2025-12-04 08:46:17 +01:00
ui-fulldeps Add UI test for DefId::parent() 2025-11-14 20:33:56 -05:00
COMPILER_TESTS.md