Skip to content

Commit 7eca7fe

Browse files
authored
Rollup merge of rust-lang#104614 - Nilstrieb:type-ascribe!, r=TaKO8Ki
Add `type_ascribe!` macro as placeholder syntax for type ascription This makes it still possible to test the internal semantics of type ascription even once the `:`-syntax is removed from the parser. The macro now gets used in a bunch of UI tests that test the semantics and not syntax of type ascription. I might have forgotten a few tests but this should hopefully be most of them. The remaining ones will certainly be found once type ascription is removed from the parser altogether. Part of rust-lang#101728
2 parents d3f1a85 + e6185dc commit 7eca7fe

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

core/src/macros/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,6 +1546,18 @@ pub(crate) mod builtin {
15461546
/* compiler built-in */
15471547
}
15481548

1549+
/// Unstable placeholder for type ascription.
1550+
#[rustc_builtin_macro]
1551+
#[unstable(
1552+
feature = "type_ascription",
1553+
issue = "23416",
1554+
reason = "placeholder syntax for type ascription"
1555+
)]
1556+
#[cfg(not(bootstrap))]
1557+
pub macro type_ascribe($expr:expr, $ty:ty) {
1558+
/* compiler built-in */
1559+
}
1560+
15491561
/// Unstable implementation detail of the `rustc` compiler, do not use.
15501562
#[rustc_builtin_macro]
15511563
#[stable(feature = "rust1", since = "1.0.0")]

core/src/prelude/v1.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,11 @@ pub use crate::macros::builtin::cfg_accessible;
9898
reason = "`cfg_eval` is a recently implemented feature"
9999
)]
100100
pub use crate::macros::builtin::cfg_eval;
101+
102+
#[unstable(
103+
feature = "type_ascription",
104+
issue = "23416",
105+
reason = "placeholder syntax for type ascription"
106+
)]
107+
#[cfg(not(bootstrap))]
108+
pub use crate::macros::builtin::type_ascribe;

std/src/prelude/v1.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,15 @@ pub use core::prelude::v1::cfg_accessible;
8585
)]
8686
pub use core::prelude::v1::cfg_eval;
8787

88+
// Do not `doc(no_inline)` either.
89+
#[unstable(
90+
feature = "type_ascription",
91+
issue = "23416",
92+
reason = "placeholder syntax for type ascription"
93+
)]
94+
#[cfg(not(bootstrap))]
95+
pub use core::prelude::v1::type_ascribe;
96+
8897
// The file so far is equivalent to src/libcore/prelude/v1.rs,
8998
// and below to src/liballoc/prelude.rs.
9099
// Those files are duplicated rather than using glob imports

0 commit comments

Comments
 (0)