Skip to content

Commit bd9522d

Browse files
authored
Rollup merge of #102049 - fee1-dead-contrib:derive_const, r=oli-obk
Add the `#[derive_const]` attribute Closes #102371. This is a minimal patchset for the attribute to work. There are no restrictions on what traits this attribute applies to. r? `````@oli-obk`````
2 parents 2a0e67c + a3ac232 commit bd9522d

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
@@ -81,6 +81,10 @@ pub use crate::macros::builtin::alloc_error_handler;
8181
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
8282
pub use crate::macros::builtin::{bench, derive, global_allocator, test, test_case};
8383

84+
#[unstable(feature = "derive_const", issue = "none")]
85+
#[cfg(not(bootstrap))]
86+
pub use crate::macros::builtin::derive_const;
87+
8488
#[unstable(
8589
feature = "cfg_accessible",
8690
issue = "64797",

std/src/prelude/v1.rs

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

68+
#[unstable(feature = "derive_const", issue = "none")]
69+
#[cfg(not(bootstrap))]
70+
pub use core::prelude::v1::derive_const;
71+
6872
// Do not `doc(no_inline)` either.
6973
#[unstable(
7074
feature = "cfg_accessible",

0 commit comments

Comments
 (0)