Skip to content

Commit 30ba044

Browse files
committed
Add a benchmark for exhaustive_patterns
1 parent 623acd9 commit 30ba044

File tree

14 files changed

+2188
-0
lines changed

14 files changed

+2188
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
target
2+
Cargo.lock
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[package]
2+
name = "syn"
3+
version = "0.0.0"
4+
5+
[workspace]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"supports_stable": false,
3+
"touch_file": "src/lib.rs"
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
use super::*;
2+
use delimited::Delimited;
3+
4+
ast_enum! {
5+
/// Distinguishes between Attributes that decorate items and Attributes that
6+
/// are contained as statements within items. These two cases need to be
7+
/// distinguished for pretty-printing.
8+
pub enum AttrStyle {
9+
/// Attribute of the form `#[...]`.
10+
Outer,
11+
12+
/// Attribute of the form `#![...]`.
13+
Inner(tokens::Bang),
14+
}
15+
}
16+
17+
ast_enum_of_structs! {
18+
/// A compile-time attribute item.
19+
///
20+
/// E.g. `#[test]`, `#[derive(..)]` or `#[feature = "foo"]`
21+
pub enum MetaItem {
22+
/// Term meta item.
23+
///
24+
/// E.g. `test` as in `#[test]`
25+
pub Term(Ident),
26+
27+
/// List meta item.
28+
///
29+
/// E.g. `derive(..)` as in `#[derive(..)]`
30+
pub List(MetaItemList {
31+
/// Name of this attribute.
32+
///
33+
/// E.g. `derive` in `#[derive(..)]`
34+
pub ident: Ident,
35+
36+
pub paren_token: tokens::Paren,
37+
38+
/// Arguments to this attribute
39+
///
40+
/// E.g. `..` in `#[derive(..)]`
41+
pub nested: Delimited,
42+
}),
43+
44+
/// Name-value meta item.
45+
///
46+
/// E.g. `feature = "foo"` as in `#[feature = "foo"]`
47+
pub NameValue(MetaNameValue {
48+
/// Name of this attribute.
49+
///
50+
/// E.g. `feature` in `#[feature = "foo"]`
51+
pub ident: Ident,
52+
53+
pub eq_token: tokens::Eq,
54+
55+
/// Arguments to this attribute
56+
///
57+
/// E.g. `"foo"` in `#[feature = "foo"]`
58+
pub lit: Lit,
59+
}),
60+
}
61+
}
62+
63+
ast_enum_of_structs! {
64+
/// Possible values inside of compile-time attribute lists.
65+
///
66+
/// E.g. the '..' in `#[name(..)]`.
67+
pub enum NestedMetaItem {
68+
/// A full `MetaItem`.
69+
///
70+
/// E.g. `Copy` in `#[derive(Copy)]` would be a `MetaItem::Term(Ident::from("Copy"))`.
71+
pub MetaItem(MetaItem),
72+
73+
/// A Rust literal.
74+
///
75+
/// E.g. `"name"` in `#[rename("name")]`.
76+
pub Literal(Lit),
77+
}
78+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
use super::*;
2+
use delimited::Delimited;
3+
4+
ast_struct! {
5+
/// An enum variant.
6+
pub struct Variant {
7+
/// Name of the variant.
8+
pub ident: Ident,
9+
10+
/// Attributes tagged on the variant.
11+
pub attrs: Vec<u64>,
12+
13+
/// Type of variant.
14+
pub data: VariantData,
15+
16+
/// Explicit discriminant, e.g. `Foo = 1`
17+
pub discriminant: Option<Expr>,
18+
19+
pub eq_token: Option<tokens::Eq>,
20+
}
21+
}
22+
23+
ast_enum! {
24+
/// Data stored within an enum variant or struct.
25+
pub enum VariantData {
26+
/// Struct variant, e.g. `Point { x: f64, y: f64 }`.
27+
Struct(Delimited, tokens::Brace),
28+
29+
/// Tuple variant, e.g. `Some(T)`.
30+
Tuple(Delimited, tokens::Paren),
31+
32+
/// Unit variant, e.g. `None`.
33+
Unit,
34+
}
35+
}
36+
37+
ast_struct! {
38+
/// A field of a struct or enum variant.
39+
pub struct Field {
40+
/// Name of the field, if any.
41+
///
42+
/// Fields of tuple structs have no names.
43+
pub ident: Option<Ident>,
44+
45+
/// Visibility of the field.
46+
pub vis: Visibility,
47+
48+
/// Attributes tagged on the field.
49+
pub attrs: Vec<u64>,
50+
51+
/// Type of the field.
52+
pub ty: Ty,
53+
54+
pub colon_token: Option<tokens::Colon>,
55+
}
56+
}
57+
58+
ast_enum_of_structs! {
59+
/// Visibility level of an item.
60+
pub enum Visibility {
61+
/// Public, i.e. `pub`.
62+
pub Public(VisPublic {
63+
pub pub_token: tokens::Pub,
64+
}),
65+
66+
/// Crate-visible, i.e. `pub(crate)`.
67+
pub Crate(VisCrate {
68+
pub pub_token: tokens::Pub,
69+
pub paren_token: tokens::Paren,
70+
pub crate_token: tokens::Crate,
71+
}),
72+
73+
/// Restricted, e.g. `pub(self)` or `pub(super)` or `pub(in some::module)`.
74+
pub Restricted(VisRestricted {
75+
pub pub_token: tokens::Pub,
76+
pub paren_token: tokens::Paren,
77+
pub in_token: Option<tokens::In>,
78+
pub path: Box<u64>,
79+
}),
80+
81+
/// Inherited, i.e. private.
82+
pub Inherited(VisInherited {}),
83+
}
84+
}

0 commit comments

Comments
 (0)