Rollup merge of #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 #138596
This commit is contained in:
Matthias Krüger 2025-03-21 15:48:57 +01:00 committed by GitHub
commit 7c2475e9aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 59 additions and 8 deletions

View file

@ -8,7 +8,7 @@ use std::sync::Arc;
use rustc_ast::expand::StrippedCfgItem;
use rustc_ast::{self as ast, Crate, NodeId, attr};
use rustc_ast_pretty::pprust;
use rustc_attr_parsing::StabilityLevel;
use rustc_attr_parsing::{AttributeKind, StabilityLevel, find_attr};
use rustc_data_structures::intern::Interned;
use rustc_errors::{Applicability, StashKey};
use rustc_expand::base::{
@ -1125,6 +1125,13 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
edition,
);
// The #[rustc_macro_edition_2021] attribute is used by the pin!() macro
// as a temporary workaround for a regression in expressiveness in Rust 2024.
// See https://github.com/rust-lang/rust/issues/138718.
if find_attr!(attrs.iter(), AttributeKind::RustcMacroEdition2021) {
ext.edition = Edition::Edition2021;
}
if let Some(builtin_name) = ext.builtin_name {
// The macro was marked with `#[rustc_builtin_macro]`.
if let Some(builtin_ext_kind) = self.builtin_macros.get(&builtin_name) {