about summary refs log tree commit diff
path: root/library
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2021-03-06 21:33:02 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2021-03-06 23:03:19 +0300
commit5dad6c25751f577c53bd36d09f033e1c245d0806 (patch)
tree5a5269785f864cdd6f1742f9cfcd5e0444e6427e /library
parent069e612e73f3fabb1184d9df009ea064118fffd8 (diff)
downloadrust-5dad6c25751f577c53bd36d09f033e1c245d0806.tar.gz
rust-5dad6c25751f577c53bd36d09f033e1c245d0806.zip
Implement built-in attribute macro `#[cfg_eval]`
Diffstat (limited to 'library')
-rw-r--r--library/core/src/macros/mod.rs12
-rw-r--r--library/core/src/prelude/v1.rs9
-rw-r--r--library/std/src/lib.rs1
-rw-r--r--library/std/src/prelude/v1.rs9
4 files changed, 31 insertions, 0 deletions
diff --git a/library/core/src/macros/mod.rs b/library/core/src/macros/mod.rs
index 3e70ba81d49..28fed9b8a14 100644
--- a/library/core/src/macros/mod.rs
+++ b/library/core/src/macros/mod.rs
@@ -1452,6 +1452,18 @@ pub(crate) mod builtin {
         /* compiler built-in */
     }
 
+    /// Expands all `#[cfg]` and `#[cfg_attr]` attributes in the code fragment it's applied to.
+    #[cfg(not(bootstrap))]
+    #[unstable(
+        feature = "cfg_eval",
+        issue = "82679",
+        reason = "`cfg_eval` is a recently implemented feature"
+    )]
+    #[rustc_builtin_macro]
+    pub macro cfg_eval($($tt:tt)*) {
+        /* compiler built-in */
+    }
+
     /// Unstable implementation detail of the `rustc` compiler, do not use.
     #[rustc_builtin_macro]
     #[stable(feature = "rust1", since = "1.0.0")]
diff --git a/library/core/src/prelude/v1.rs b/library/core/src/prelude/v1.rs
index a1fbd8dec75..5e8a8d252a2 100644
--- a/library/core/src/prelude/v1.rs
+++ b/library/core/src/prelude/v1.rs
@@ -81,3 +81,12 @@ pub use crate::macros::builtin::derive;
 )]
 #[doc(no_inline)]
 pub use crate::macros::builtin::cfg_accessible;
+
+#[cfg(not(bootstrap))]
+#[unstable(
+    feature = "cfg_eval",
+    issue = "82679",
+    reason = "`cfg_eval` is a recently implemented feature"
+)]
+#[doc(no_inline)]
+pub use crate::macros::builtin::cfg_eval;
diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs
index 72b86338d2c..acdf7550fe7 100644
--- a/library/std/src/lib.rs
+++ b/library/std/src/lib.rs
@@ -234,6 +234,7 @@
 #![feature(box_syntax)]
 #![feature(c_variadic)]
 #![feature(cfg_accessible)]
+#![cfg_attr(not(bootstrap), feature(cfg_eval))]
 #![feature(cfg_target_has_atomic)]
 #![feature(cfg_target_thread_local)]
 #![feature(char_error_internals)]
diff --git a/library/std/src/prelude/v1.rs b/library/std/src/prelude/v1.rs
index ef9aec54a4c..7181dc6e710 100644
--- a/library/std/src/prelude/v1.rs
+++ b/library/std/src/prelude/v1.rs
@@ -67,6 +67,15 @@ pub use core::prelude::v1::derive;
 #[doc(hidden)]
 pub use core::prelude::v1::cfg_accessible;
 
+#[cfg(not(bootstrap))]
+#[unstable(
+    feature = "cfg_eval",
+    issue = "82679",
+    reason = "`cfg_eval` is a recently implemented feature"
+)]
+#[doc(hidden)]
+pub use core::prelude::v1::cfg_eval;
+
 // The file so far is equivalent to src/libcore/prelude/v1.rs,
 // and below to src/liballoc/prelude.rs.
 // Those files are duplicated rather than using glob imports