|
1 | 1 | use std::mem::take;
|
2 | 2 | use std::ops::{Deref, DerefMut};
|
3 |
| -use std::sync::Arc; |
4 | 3 |
|
5 | 4 | use ast::token::IdentIsRaw;
|
6 | 5 | use rustc_ast as ast;
|
7 | 6 | use rustc_ast::ptr::P;
|
8 | 7 | use rustc_ast::token::{self, Delimiter, Lit, LitKind, Token, TokenKind};
|
9 |
| -use rustc_ast::tokenstream::AttrTokenTree; |
10 | 8 | use rustc_ast::util::parser::AssocOp;
|
11 | 9 | use rustc_ast::{
|
12 | 10 | AngleBracketedArg, AngleBracketedArgs, AnonConst, AttrVec, BinOpKind, BindingMode, Block,
|
13 |
| - BlockCheckMode, Expr, ExprKind, GenericArg, Generics, HasTokens, Item, ItemKind, Param, Pat, |
14 |
| - PatKind, Path, PathSegment, QSelf, Recovered, Ty, TyKind, |
| 11 | + BlockCheckMode, Expr, ExprKind, GenericArg, Generics, Item, ItemKind, Param, Pat, PatKind, |
| 12 | + Path, PathSegment, QSelf, Recovered, Ty, TyKind, |
15 | 13 | };
|
16 | 14 | use rustc_ast_pretty::pprust;
|
17 | 15 | use rustc_data_structures::fx::FxHashSet;
|
@@ -2400,52 +2398,6 @@ impl<'a> Parser<'a> {
|
2400 | 2398 | err.subdiagnostic(ExprParenthesesNeeded::surrounding(*sp));
|
2401 | 2399 | }
|
2402 | 2400 | err.span_label(span, "expected expression");
|
2403 |
| - |
2404 |
| - // Walk the chain of macro expansions for the current token to point at how the original |
2405 |
| - // code was interpreted. This helps the user realize when a macro argument of one type is |
2406 |
| - // later reinterpreted as a different type, like `$x:expr` being reinterpreted as `$x:pat` |
2407 |
| - // in a subsequent macro invocation (#71039). |
2408 |
| - let mut tok = self.token.clone(); |
2409 |
| - let mut labels = vec![]; |
2410 |
| - while let TokenKind::Interpolated(nt) = &tok.kind { |
2411 |
| - let tokens = nt.tokens(); |
2412 |
| - labels.push(Arc::clone(nt)); |
2413 |
| - if let Some(tokens) = tokens |
2414 |
| - && let tokens = tokens.to_attr_token_stream() |
2415 |
| - && let tokens = tokens.0.deref() |
2416 |
| - && let [AttrTokenTree::Token(token, _)] = &tokens[..] |
2417 |
| - { |
2418 |
| - tok = token.clone(); |
2419 |
| - } else { |
2420 |
| - break; |
2421 |
| - } |
2422 |
| - } |
2423 |
| - let mut iter = labels.into_iter().peekable(); |
2424 |
| - let mut show_link = false; |
2425 |
| - while let Some(nt) = iter.next() { |
2426 |
| - let descr = nt.descr(); |
2427 |
| - if let Some(next) = iter.peek() { |
2428 |
| - let next_descr = next.descr(); |
2429 |
| - if next_descr != descr { |
2430 |
| - err.span_label(next.use_span(), format!("this is expected to be {next_descr}")); |
2431 |
| - err.span_label( |
2432 |
| - nt.use_span(), |
2433 |
| - format!( |
2434 |
| - "this is interpreted as {}, but it is expected to be {}", |
2435 |
| - next_descr, descr, |
2436 |
| - ), |
2437 |
| - ); |
2438 |
| - show_link = true; |
2439 |
| - } |
2440 |
| - } |
2441 |
| - } |
2442 |
| - if show_link { |
2443 |
| - err.note( |
2444 |
| - "when forwarding a matched fragment to another macro-by-example, matchers in the \ |
2445 |
| - second macro will see an opaque AST of the fragment type, not the underlying \ |
2446 |
| - tokens", |
2447 |
| - ); |
2448 |
| - } |
2449 | 2401 | err
|
2450 | 2402 | }
|
2451 | 2403 |
|
|
0 commit comments