Skip to content

Commit 5ab8085

Browse files
authored
Rollup merge of rust-lang#138717 - jdonszelmann:pin-macro, r=WaffleLapkin
Add an attribute that makes the spans from a macro edition 2021, and fix pin on edition 2024 with it Fixes a regression, see issue below. This is a temporary fix, super let is the real solution. Closes rust-lang#138596
2 parents 70a0931 + ece839e commit 5ab8085

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

core/src/pin.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1943,6 +1943,7 @@ unsafe impl<T: ?Sized> PinCoerceUnsized for *mut T {}
19431943
#[stable(feature = "pin_macro", since = "1.68.0")]
19441944
#[rustc_macro_transparency = "semitransparent"]
19451945
#[allow_internal_unstable(unsafe_pin_internals)]
1946+
#[cfg_attr(not(bootstrap), rustc_macro_edition_2021)]
19461947
pub macro pin($value:expr $(,)?) {
19471948
// This is `Pin::new_unchecked(&mut { $value })`, so, for starters, let's
19481949
// review such a hypothetical macro (that any user-code could define):

coretests/tests/pin.rs

+14
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ fn pin_const() {
3434
}
3535

3636
pin_mut_const();
37+
38+
// Check that we accept a Rust 2024 $expr.
39+
std::pin::pin!(const { 1 });
3740
}
3841

3942
#[allow(unused)]
@@ -81,3 +84,14 @@ mod pin_coerce_unsized {
8184
arg
8285
}
8386
}
87+
88+
#[test]
89+
#[cfg(not(bootstrap))]
90+
fn temp_lifetime() {
91+
// Check that temporary lifetimes work as in Rust 2021.
92+
// Regression test for https://github.com/rust-lang/rust/issues/138596
93+
match std::pin::pin!(foo(&mut 0)) {
94+
_ => {}
95+
}
96+
async fn foo(_: &mut usize) {}
97+
}

0 commit comments

Comments
 (0)