-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add an attribute that makes the spans from a macro edition 2021, and fix pin on edition 2024 with it #138717
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an attribute that makes the spans from a macro edition 2021, and fix pin on edition 2024 with it #138717
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use rustc_attr_data_structures::AttributeKind; | ||
use rustc_span::sym; | ||
|
||
use super::{AcceptContext, SingleAttributeParser}; | ||
use crate::parser::ArgParser; | ||
|
||
pub(crate) struct RustcMacroEdition2021Parser; | ||
|
||
// FIXME(jdonszelmann): make these proper diagnostics | ||
impl SingleAttributeParser for RustcMacroEdition2021Parser { | ||
const PATH: &'static [rustc_span::Symbol] = &[sym::rustc_macro_edition_2021]; | ||
|
||
fn on_duplicate(_cx: &crate::context::AcceptContext<'_>, _first_span: rustc_span::Span) {} | ||
|
||
fn convert(_cx: &AcceptContext<'_>, args: &ArgParser<'_>) -> Option<AttributeKind> { | ||
assert!(args.no_args()); | ||
Some(AttributeKind::RustcMacroEdition2021) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,9 @@ fn pin_const() { | |
} | ||
|
||
pin_mut_const(); | ||
|
||
// Check that we accept a Rust 2024 $expr. | ||
std::pin::pin!(const { 1 }); | ||
} | ||
|
||
#[allow(unused)] | ||
|
@@ -81,3 +84,14 @@ mod pin_coerce_unsized { | |
arg | ||
} | ||
} | ||
|
||
#[test] | ||
#[cfg(not(bootstrap))] | ||
fn temp_lifetime() { | ||
// Check that temporary lifetimes work as in Rust 2021. | ||
// Regression test for https://github.com/rust-lang/rust/issues/138596 | ||
match std::pin::pin!(foo(&mut 0)) { | ||
_ => {} | ||
} | ||
async fn foo(_: &mut usize) {} | ||
} | ||
Comment on lines
+88
to
+97
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I tried to work on this with my failed attempt, I thought of extra tests which seem important for fn transitive_extension {
async fn temporary() {}
// `pin!` witnessed in the wild being used like this, even if it yields
// a `Pin<&mut &mut impl Unpin>`; it does work because `pin!`
// happens to transitively extend the lifespan of `temporary()`.
let p = pin!(&mut temporary());
let _use = p;
} as well as the following things which have to fail to compile to guarantee the soundness of
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! Would you mind putting that in a PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've put them in #139097 |
Uh oh!
There was an error while loading. Please reload this page.