about summary refs log tree commit diff
path: root/library/core/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-12-13 17:25:31 +0100
committerGitHub <noreply@github.com>2024-12-13 17:25:31 +0100
commit5c9b227a3df48cff16a7f66957806db46caeeac8 (patch)
tree9994cef76fa8b2d8b9d4d77bc90fca06842c8654 /library/core/src
parent9f6b07e2f5a1267c976a0f8a30dbea6e461a198e (diff)
parentb8c5a0f0eba036700775a33c924deaeeb34f3974 (diff)
downloadrust-5c9b227a3df48cff16a7f66957806db46caeeac8.tar.gz
rust-5c9b227a3df48cff16a7f66957806db46caeeac8.zip
Rollup merge of #134140 - compiler-errors:unsafe-binders-ast, r=oli-obk
Add AST support for unsafe binders

I'm splitting up #130514 into pieces. It's impossible for me to keep up with a huge PR like that. I'll land type system support for this next, probably w/o MIR lowering, which will come later.

r? `@oli-obk`
cc `@BoxyUwU` and `@lcnr` who also may want to look at this, though this PR doesn't do too much yet
Diffstat (limited to 'library/core/src')
-rw-r--r--library/core/src/lib.rs2
-rw-r--r--library/core/src/unsafe_binder.rs25
2 files changed, 27 insertions, 0 deletions
diff --git a/library/core/src/lib.rs b/library/core/src/lib.rs
index fde6887c5ab..d45cb01910f 100644
--- a/library/core/src/lib.rs
+++ b/library/core/src/lib.rs
@@ -354,6 +354,8 @@ pub mod random;
 pub mod range;
 pub mod result;
 pub mod sync;
+#[unstable(feature = "unsafe_binders", issue = "130516")]
+pub mod unsafe_binder;
 
 pub mod fmt;
 pub mod hash;
diff --git a/library/core/src/unsafe_binder.rs b/library/core/src/unsafe_binder.rs
new file mode 100644
index 00000000000..98f53e07d9d
--- /dev/null
+++ b/library/core/src/unsafe_binder.rs
@@ -0,0 +1,25 @@
+//! Operators used to turn types into unsafe binders and back.
+
+/// Unwrap an unsafe binder into its underlying type.
+#[allow_internal_unstable(builtin_syntax)]
+#[unstable(feature = "unsafe_binders", issue = "130516")]
+pub macro unwrap_binder {
+    ($expr:expr) => {
+        builtin # unwrap_binder ( $expr )
+    },
+    ($expr:expr ; $ty:ty) => {
+        builtin # unwrap_binder ( $expr, $ty )
+    },
+}
+
+/// Wrap a type into an unsafe binder.
+#[allow_internal_unstable(builtin_syntax)]
+#[unstable(feature = "unsafe_binders", issue = "130516")]
+pub macro wrap_binder {
+    ($expr:expr) => {
+        builtin # wrap_binder ( $expr )
+    },
+    ($expr:expr ; $ty:ty) => {
+        builtin # wrap_binder ( $expr, $ty )
+    },
+}