about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2025-01-03 07:57:24 +0100
committerGitHub <noreply@github.com>2025-01-03 07:57:24 +0100
commit8439ae74226d68abddcbf609794602f5305061f9 (patch)
treea270b5c90b9f5aa6ad95eddbbd0eb4359c4321df /compiler
parent870c13dc9b85944ceb172df54c7b1c615a46cb6e (diff)
parentc73d81ec3333cf76c9419c5f30699001f388be53 (diff)
downloadrust-8439ae74226d68abddcbf609794602f5305061f9.tar.gz
rust-8439ae74226d68abddcbf609794602f5305061f9.zip
Rollup merge of #131729 - Urgau:check-cfg-test-userspace, r=petrochenkov
Make the `test` cfg a userspace check-cfg

This PR implements MCP https://github.com/rust-lang/compiler-team/issues/785, which makes the `test` cfg a "userspace" check-cfg, i.e. no longer included in the well known cfg list.

Things to do:

- [x] Accept the MCP (https://github.com/rust-lang/compiler-team/issues/785#issuecomment-2424121886)
- [x] Mark `test` in Cargo (https://github.com/rust-lang/cargo/pull/14963)

`@rustbot` labels +S-waiting-on-MCP +F-check_cfg
r? `@petrochenkov`
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_session/src/config/cfg.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler/rustc_session/src/config/cfg.rs b/compiler/rustc_session/src/config/cfg.rs
index 3426858495b..b68dfeffa34 100644
--- a/compiler/rustc_session/src/config/cfg.rs
+++ b/compiler/rustc_session/src/config/cfg.rs
@@ -332,6 +332,11 @@ impl CheckCfg {
         // Note that symbols inserted conditionally in `default_configuration`
         // are inserted unconditionally here.
         //
+        // One exception is the `test` cfg which is consider to be a "user-space"
+        // cfg, despite being also set by in `default_configuration` above.
+        // It allows the build system to "deny" using the config by not marking it
+        // as expected (e.g. `lib.test = false` for Cargo).
+        //
         // When adding a new config here you should also update
         // `tests/ui/check-cfg/well-known-values.rs` (in order to test the
         // expected values of the new config) and bless the all directory.
@@ -453,8 +458,6 @@ impl CheckCfg {
 
         ins!(sym::target_thread_local, no_values);
 
-        ins!(sym::test, no_values);
-
         ins!(sym::ub_checks, no_values);
 
         ins!(sym::unix, no_values);