Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit fec0479

Browse files
committed
Fully integrate token collection for additional AST structs
This commit contains miscellaneous changes that don't fit into any of the other commits in this PR
1 parent 156ef2b commit fec0479

File tree

11 files changed

+338
-22
lines changed

11 files changed

+338
-22
lines changed

compiler/rustc_ast/src/token.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ pub enum Nonterminal {
700700

701701
// `Nonterminal` is used a lot. Make sure it doesn't unintentionally get bigger.
702702
#[cfg(target_arch = "x86_64")]
703-
rustc_data_structures::static_assert_size!(Nonterminal, 40);
703+
rustc_data_structures::static_assert_size!(Nonterminal, 48);
704704

705705
#[derive(Debug, Copy, Clone, PartialEq, Encodable, Decodable)]
706706
pub enum NonterminalKind {

compiler/rustc_ast_pretty/src/pprust/tests.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use super::*;
22

33
use rustc_ast as ast;
4-
use rustc_span::source_map::respan;
54
use rustc_span::symbol::Ident;
65
use rustc_span::with_default_session_globals;
76

@@ -45,7 +44,11 @@ fn test_variant_to_string() {
4544

4645
let var = ast::Variant {
4746
ident,
48-
vis: respan(rustc_span::DUMMY_SP, ast::VisibilityKind::Inherited),
47+
vis: ast::Visibility {
48+
span: rustc_span::DUMMY_SP,
49+
kind: ast::VisibilityKind::Inherited,
50+
tokens: None,
51+
},
4952
attrs: Vec::new(),
5053
id: ast::DUMMY_NODE_ID,
5154
data: ast::VariantData::Unit(ast::DUMMY_NODE_ID),

src/test/ui-fulldeps/pprust-expr-roundtrip.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fn expr(kind: ExprKind) -> P<Expr> {
6262

6363
fn make_x() -> P<Expr> {
6464
let seg = PathSegment::from_ident(Ident::from_str("x"));
65-
let path = Path { segments: vec![seg], span: DUMMY_SP };
65+
let path = Path { segments: vec![seg], span: DUMMY_SP, tokens: None };
6666
expr(ExprKind::Path(None, path))
6767
}
6868

@@ -113,6 +113,7 @@ fn iter_exprs(depth: usize, f: &mut dyn FnMut(P<Expr>)) {
113113
id: DUMMY_NODE_ID,
114114
rules: BlockCheckMode::Default,
115115
span: DUMMY_SP,
116+
tokens: None,
116117
});
117118
iter_exprs(depth - 1, &mut |e| g(ExprKind::If(e, block.clone(), None)));
118119
},
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"module":{"inner":{"lo":0,"hi":0},"unsafety":"No","items":[{"attrs":[],"id":0,"span":{"lo":0,"hi":0},"vis":{"node":"Inherited","span":{"lo":0,"hi":0}},"ident":{"name":"core","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null}],"inline":true},"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"crate_type","span":{"lo":0,"hi":0}},"id":0,"args":null}]},"args":{"variant":"Eq","fields":[{"lo":0,"hi":0},{"0":[[{"variant":"Token","fields":[{"kind":{"variant":"Literal","fields":[{"kind":"Str","symbol":"lib","suffix":null}]},"span":{"lo":0,"hi":0}}]},"Alone"]]}]}}]},"id":null,"style":"Inner","span":{"lo":0,"hi":0}}],"span":{"lo":0,"hi":0},"proc_macros":[]}
1+
{"module":{"inner":{"lo":0,"hi":0},"unsafety":"No","items":[{"attrs":[],"id":0,"span":{"lo":0,"hi":0},"vis":{"kind":"Inherited","span":{"lo":0,"hi":0},"tokens":null},"ident":{"name":"core","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null}],"inline":true},"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"crate_type","span":{"lo":0,"hi":0}},"id":0,"args":null}],"tokens":null},"args":{"variant":"Eq","fields":[{"lo":0,"hi":0},{"0":[[{"variant":"Token","fields":[{"kind":{"variant":"Literal","fields":[{"kind":"Str","symbol":"lib","suffix":null}]},"span":{"lo":0,"hi":0}}]},"Alone"]]}]},"tokens":null}]},"id":null,"style":"Inner","span":{"lo":0,"hi":0}}],"span":{"lo":0,"hi":0},"proc_macros":[]}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"module":{"inner":{"lo":0,"hi":0},"unsafety":"No","items":[{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"prelude_import","span":{"lo":0,"hi":0}},"id":0,"args":null}]},"args":"Empty"}]},"id":null,"style":"Outer","span":{"lo":0,"hi":0}}],"id":0,"span":{"lo":0,"hi":0},"vis":{"node":"Inherited","span":{"lo":0,"hi":0}},"ident":{"name":"","span":{"lo":0,"hi":0}},"kind":{"variant":"Use","fields":[{"prefix":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"{{root}}","span":{"lo":0,"hi":0}},"id":0,"args":null},{"ident":{"name":"std","span":{"lo":0,"hi":0}},"id":0,"args":null},{"ident":{"name":"prelude","span":{"lo":0,"hi":0}},"id":0,"args":null},{"ident":{"name":"v1","span":{"lo":0,"hi":0}},"id":0,"args":null}]},"kind":"Glob","span":{"lo":0,"hi":0}}]},"tokens":null},{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"macro_use","span":{"lo":0,"hi":0}},"id":0,"args":null}]},"args":"Empty"}]},"id":null,"style":"Outer","span":{"lo":0,"hi":0}}],"id":0,"span":{"lo":0,"hi":0},"vis":{"node":"Inherited","span":{"lo":0,"hi":0}},"ident":{"name":"std","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null},{"attrs":[],"id":0,"span":{"lo":0,"hi":0},"vis":{"node":"Inherited","span":{"lo":0,"hi":0}},"ident":{"name":"core","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null}],"inline":true},"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"crate_type","span":{"lo":0,"hi":0}},"id":0,"args":null}]},"args":{"variant":"Eq","fields":[{"lo":0,"hi":0},{"0":[[{"variant":"Token","fields":[{"kind":{"variant":"Literal","fields":[{"kind":"Str","symbol":"lib","suffix":null}]},"span":{"lo":0,"hi":0}}]},"Alone"]]}]}}]},"id":null,"style":"Inner","span":{"lo":0,"hi":0}}],"span":{"lo":0,"hi":0},"proc_macros":[]}
1+
{"module":{"inner":{"lo":0,"hi":0},"unsafety":"No","items":[{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"prelude_import","span":{"lo":0,"hi":0}},"id":0,"args":null}],"tokens":null},"args":"Empty","tokens":null}]},"id":null,"style":"Outer","span":{"lo":0,"hi":0}}],"id":0,"span":{"lo":0,"hi":0},"vis":{"kind":"Inherited","span":{"lo":0,"hi":0},"tokens":null},"ident":{"name":"","span":{"lo":0,"hi":0}},"kind":{"variant":"Use","fields":[{"prefix":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"{{root}}","span":{"lo":0,"hi":0}},"id":0,"args":null},{"ident":{"name":"std","span":{"lo":0,"hi":0}},"id":0,"args":null},{"ident":{"name":"prelude","span":{"lo":0,"hi":0}},"id":0,"args":null},{"ident":{"name":"v1","span":{"lo":0,"hi":0}},"id":0,"args":null}],"tokens":null},"kind":"Glob","span":{"lo":0,"hi":0}}]},"tokens":null},{"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"macro_use","span":{"lo":0,"hi":0}},"id":0,"args":null}],"tokens":null},"args":"Empty","tokens":null}]},"id":null,"style":"Outer","span":{"lo":0,"hi":0}}],"id":0,"span":{"lo":0,"hi":0},"vis":{"kind":"Inherited","span":{"lo":0,"hi":0},"tokens":null},"ident":{"name":"std","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null},{"attrs":[],"id":0,"span":{"lo":0,"hi":0},"vis":{"kind":"Inherited","span":{"lo":0,"hi":0},"tokens":null},"ident":{"name":"core","span":{"lo":0,"hi":0}},"kind":{"variant":"ExternCrate","fields":[null]},"tokens":null}],"inline":true},"attrs":[{"kind":{"variant":"Normal","fields":[{"path":{"span":{"lo":0,"hi":0},"segments":[{"ident":{"name":"crate_type","span":{"lo":0,"hi":0}},"id":0,"args":null}],"tokens":null},"args":{"variant":"Eq","fields":[{"lo":0,"hi":0},{"0":[[{"variant":"Token","fields":[{"kind":{"variant":"Literal","fields":[{"kind":"Str","symbol":"lib","suffix":null}]},"span":{"lo":0,"hi":0}}]},"Alone"]]}]},"tokens":null}]},"id":null,"style":"Inner","span":{"lo":0,"hi":0}}],"span":{"lo":0,"hi":0},"proc_macros":[]}

src/test/ui/proc-macro/capture-macro-rules-invoke.rs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
// aux-build:test-macros.rs
22
// check-pass
33
// compile-flags: -Z span-debug
4-
// normalize-stdout-test "#\d+" -> "#CTXT"
4+
5+
#![no_std] // Don't load unnecessary hygiene information from std
6+
extern crate std;
57

68
extern crate test_macros;
7-
use test_macros::print_bang;
9+
use test_macros::{print_bang, print_bang_consume};
10+
11+
macro_rules! test_matchers {
12+
($expr:expr, $block:block, $stmt:stmt, $ty:ty, $ident:ident, $lifetime:lifetime,
13+
$meta:meta, $path:path, $vis:vis, $tt:tt, $lit:literal) => {
14+
print_bang_consume!($expr, $block, $stmt, $ty, $ident,
15+
$lifetime, $meta, $path, $vis, $tt, $lit)
16+
}
17+
}
818

919
macro_rules! use_expr {
1020
($expr:expr) => {
@@ -24,10 +34,23 @@ impl Foo {
2434
#[allow(dead_code)]
2535
fn use_self(self) {
2636
drop(use_expr!(self));
37+
test_matchers!(
38+
1 + 1,
39+
{ "a" },
40+
let a = 1,
41+
String,
42+
my_name,
43+
'a,
44+
my_val = 30,
45+
std::option::Option,
46+
pub(in some::path),
47+
[ a b c ],
48+
-30
49+
);
2750
}
2851

2952
fn with_pat(use_pat!((a, b)): (u32, u32)) {
30-
println!("Args: {} {}", a, b);
53+
let _ = (a, b);
3154
}
3255
}
3356

0 commit comments

Comments
 (0)