about summary refs log tree commit diff
path: root/library
diff options
context:
space:
mode:
authorJana Dönszelmann <jana@donsz.nl>2025-03-19 17:29:31 +0100
committerJana Dönszelmann <jana@donsz.nl>2025-03-19 17:37:35 +0100
commit7c085f7ffdf731175430b908bc11bd97282cff9e (patch)
tree83cbcafe22c15fd17f0e6675486a15f24f617ba3 /library
parentc4b38a596767c9c6275c937cf3a2d4b9612b4875 (diff)
downloadrust-7c085f7ffdf731175430b908bc11bd97282cff9e.tar.gz
rust-7c085f7ffdf731175430b908bc11bd97282cff9e.zip
add rustc_macro_edition_2021
Diffstat (limited to 'library')
-rw-r--r--library/core/src/pin.rs1
-rw-r--r--library/coretests/tests/pin.rs13
2 files changed, 14 insertions, 0 deletions
diff --git a/library/core/src/pin.rs b/library/core/src/pin.rs
index 7fcd19f67ee..bc097bf198d 100644
--- a/library/core/src/pin.rs
+++ b/library/core/src/pin.rs
@@ -1943,6 +1943,7 @@ unsafe impl<T: ?Sized> PinCoerceUnsized for *mut T {}
 #[stable(feature = "pin_macro", since = "1.68.0")]
 #[rustc_macro_transparency = "semitransparent"]
 #[allow_internal_unstable(unsafe_pin_internals)]
+#[cfg_attr(not(bootstrap), rustc_macro_edition_2021)]
 pub macro pin($value:expr $(,)?) {
     // This is `Pin::new_unchecked(&mut { $value })`, so, for starters, let's
     // review such a hypothetical macro (that any user-code could define):
diff --git a/library/coretests/tests/pin.rs b/library/coretests/tests/pin.rs
index b3fb06e710d..d31b24144e2 100644
--- a/library/coretests/tests/pin.rs
+++ b/library/coretests/tests/pin.rs
@@ -81,3 +81,16 @@ mod pin_coerce_unsized {
         arg
     }
 }
+
+#[test]
+fn spans_2021() {
+    // Check that we accept a Rust 2024 $expr.
+    std::pin::pin!(const { 1 });
+
+    // Check that temporary lifetimes work as in Rust 2021.
+    match std::pin::pin!(foo(&mut 0)) {
+        _f => {}
+    }
+}
+
+async fn foo(_: &mut usize) {}