Skip to content

Commit a3ac232

Browse files
committed
Add the #[derive_const] attribute
1 parent 2db743d commit a3ac232

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

core/src/macros/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,6 +1464,19 @@ pub(crate) mod builtin {
14641464
/* compiler built-in */
14651465
}
14661466

1467+
/// Attribute macro used to apply derive macros for implementing traits
1468+
/// in a const context.
1469+
///
1470+
/// See [the reference] for more info.
1471+
///
1472+
/// [the reference]: ../../../reference/attributes/derive.html
1473+
#[unstable(feature = "derive_const", issue = "none")]
1474+
#[rustc_builtin_macro]
1475+
#[cfg(not(bootstrap))]
1476+
pub macro derive_const($item:item) {
1477+
/* compiler built-in */
1478+
}
1479+
14671480
/// Attribute macro applied to a function to turn it into a unit test.
14681481
///
14691482
/// See [the reference] for more info.

core/src/prelude/v1.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ pub use crate::macros::builtin::{RustcDecodable, RustcEncodable};
7878
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
7979
pub use crate::macros::builtin::{bench, derive, global_allocator, test, test_case};
8080

81+
#[unstable(feature = "derive_const", issue = "none")]
82+
#[cfg(not(bootstrap))]
83+
pub use crate::macros::builtin::derive_const;
84+
8185
#[unstable(
8286
feature = "cfg_accessible",
8387
issue = "64797",

std/src/prelude/v1.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ pub use core::prelude::v1::{RustcDecodable, RustcEncodable};
6262
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
6363
pub use core::prelude::v1::{bench, derive, global_allocator, test, test_case};
6464

65+
#[unstable(feature = "derive_const", issue = "none")]
66+
#[cfg(not(bootstrap))]
67+
pub use core::prelude::v1::derive_const;
68+
6569
// Do not `doc(no_inline)` either.
6670
#[unstable(
6771
feature = "cfg_accessible",

0 commit comments

Comments
 (0)