Skip to content

Commit a953cc8

Browse files
committed
Create unstable From builtin macro and register it
1 parent 7de45d7 commit a953cc8

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

core/src/macros/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,4 +1768,15 @@ pub(crate) mod builtin {
17681768
pub macro deref($pat:pat) {
17691769
builtin # deref($pat)
17701770
}
1771+
1772+
/// Derive macro generating an impl of the trait `From`.
1773+
/// Currently, it can only be used on single-field structs.
1774+
// Note that the macro is in a different module than the `From` trait,
1775+
// to avoid triggering an unstable feature being used if someone imports
1776+
// `std::convert::From`.
1777+
#[rustc_builtin_macro]
1778+
#[unstable(feature = "derive_from", issue = "144889")]
1779+
pub macro From($item: item) {
1780+
/* compiler built-in */
1781+
}
17711782
}

core/src/prelude/v1.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,10 @@ pub use crate::macros::builtin::deref;
117117
reason = "`type_alias_impl_trait` has open design concerns"
118118
)]
119119
pub use crate::macros::builtin::define_opaque;
120+
121+
#[unstable(
122+
feature = "derive_from",
123+
issue = "144889",
124+
reason = "`derive(From)` is unstable"
125+
)]
126+
pub use crate::macros::builtin::From;

0 commit comments

Comments
 (0)