Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 17de919

Browse files
committedMar 7, 2025
Auto merge of rust-lang#138083 - nnethercote:rm-NtItem-NtStmt, r=<try>
Remove `NtItem` and `NtStmt` Another piece of rust-lang#124141. r? `@petrochenkov`
2 parents 91a0e16 + 3378ee1 commit 17de919

File tree

49 files changed

+269
-141
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+269
-141
lines changed
 

‎compiler/rustc_expand/src/proc_macro.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl MultiItemModifier for DeriveProcMacro {
122122
// We had a lint for a long time, but now we just emit a hard error.
123123
// Eventually we might remove the special case hard error check
124124
// altogether. See #73345.
125-
crate::base::ann_pretty_printing_compatibility_hack(&item, &ecx.sess);
125+
crate::base::ann_pretty_printing_compatibility_hack(&item, &ecx.sess.psess);
126126
let input = item.to_tokens();
127127
let stream = {
128128
let _timer =

‎compiler/rustc_expand/src/proc_macro_server.rs

+36-13
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,43 @@ impl FromInternal<(TokenStream, &mut Rustc<'_, '_>)> for Vec<TokenTree<TokenStre
115115

116116
while let Some(tree) = iter.next() {
117117
let (Token { kind, span }, joint) = match tree.clone() {
118-
tokenstream::TokenTree::Delimited(span, _, delim, tts) => {
119-
let delimiter = pm::Delimiter::from_internal(delim);
118+
tokenstream::TokenTree::Delimited(span, _, mut delim, mut stream) => {
119+
// We used to have an alternative behaviour for crates that
120+
// needed it: a hack used to pass AST fragments to
121+
// attribute and derive macros as a single nonterminal
122+
// token instead of a token stream. Such token needs to be
123+
// "unwrapped" and not represented as a delimited group. We
124+
// had a lint for a long time, but now we just emit a hard
125+
// error. Eventually we might remove the special case hard
126+
// error check altogether. See #73345.
127+
if let Delimiter::Invisible(InvisibleOrigin::MetaVar(kind)) = delim {
128+
crate::base::stream_pretty_printing_compatibility_hack(
129+
kind,
130+
&stream,
131+
rustc.psess(),
132+
);
133+
}
134+
135+
// In `mk_delimited` we avoid nesting invisible delimited
136+
// of the same `MetaVarKind`. Here we do the same but
137+
// ignore the `MetaVarKind` because it is discarded when we
138+
// convert it to a `Group`.
139+
while let Delimiter::Invisible(InvisibleOrigin::MetaVar(_)) = delim {
140+
if stream.len() == 1
141+
&& let tree = stream.iter().next().unwrap()
142+
&& let tokenstream::TokenTree::Delimited(_, _, delim2, stream2) = tree
143+
&& let Delimiter::Invisible(InvisibleOrigin::MetaVar(_)) = delim2
144+
{
145+
delim = *delim2;
146+
stream = stream2.clone();
147+
} else {
148+
break;
149+
}
150+
}
151+
120152
trees.push(TokenTree::Group(Group {
121-
delimiter,
122-
stream: Some(tts),
153+
delimiter: pm::Delimiter::from_internal(delim),
154+
stream: Some(stream),
123155
span: DelimSpan {
124156
open: span.open,
125157
close: span.close,
@@ -279,15 +311,6 @@ impl FromInternal<(TokenStream, &mut Rustc<'_, '_>)> for Vec<TokenTree<TokenStre
279311

280312
Interpolated(nt) => {
281313
let stream = TokenStream::from_nonterminal_ast(&nt);
282-
// We used to have an alternative behaviour for crates that
283-
// needed it: a hack used to pass AST fragments to
284-
// attribute and derive macros as a single nonterminal
285-
// token instead of a token stream. Such token needs to be
286-
// "unwrapped" and not represented as a delimited group. We
287-
// had a lint for a long time, but now we just emit a hard
288-
// error. Eventually we might remove the special case hard
289-
// error check altogether. See #73345.
290-
crate::base::nt_pretty_printing_compatibility_hack(&nt, rustc.ecx.sess);
291314
trees.push(TokenTree::Group(Group {
292315
delimiter: pm::Delimiter::None,
293316
stream: Some(stream),

‎compiler/rustc_hir/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
// tidy-alphabetical-start
66
#![allow(internal_features)]
7+
#![cfg_attr(doc, recursion_limit = "256")] // FIXME(nnethercote): will be removed by #124141
78
#![feature(associated_type_defaults)]
89
#![feature(box_patterns)]
910
#![feature(closure_track_caller)]
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.