-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a benchmark for exhaustive_patterns
- Loading branch information
Showing
16 changed files
with
2,338 additions
and
0 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
collector/benchmarks/match-stress-exhaustive_patterns/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
target | ||
Cargo.lock |
5 changes: 5 additions & 0 deletions
5
collector/benchmarks/match-stress-exhaustive_patterns/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[package] | ||
name = "syn" | ||
version = "0.0.0" | ||
|
||
[workspace] |
4 changes: 4 additions & 0 deletions
4
collector/benchmarks/match-stress-exhaustive_patterns/perf-config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"supports_stable": false, | ||
"touch_file": "src/lib.rs" | ||
} |
101 changes: 101 additions & 0 deletions
101
collector/benchmarks/match-stress-exhaustive_patterns/src/attr.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
use super::*; | ||
use delimited::Delimited; | ||
|
||
ast_struct! { | ||
/// Doc-comments are promoted to attributes that have `is_sugared_doc` = true | ||
pub struct Attribute { | ||
pub style: AttrStyle, | ||
pub pound_token: tokens::Pound, | ||
pub bracket_token: tokens::Bracket, | ||
|
||
/// The path of the attribute. | ||
/// | ||
/// E.g. `derive` in `#[derive(Copy)]` | ||
/// E.g. `crate::precondition` in `#[crate::precondition x < 5]` | ||
pub path: Path, | ||
|
||
/// Any tokens after the path. | ||
/// | ||
/// E.g. `( Copy )` in `#[derive(Copy)]` | ||
/// E.g. `x < 5` in `#[crate::precondition x < 5]` | ||
pub tts: Vec<TokenTree>, | ||
|
||
pub is_sugared_doc: bool, | ||
} | ||
} | ||
|
||
ast_enum! { | ||
/// Distinguishes between Attributes that decorate items and Attributes that | ||
/// are contained as statements within items. These two cases need to be | ||
/// distinguished for pretty-printing. | ||
pub enum AttrStyle { | ||
/// Attribute of the form `#[...]`. | ||
Outer, | ||
|
||
/// Attribute of the form `#![...]`. | ||
Inner(tokens::Bang), | ||
} | ||
} | ||
|
||
ast_enum_of_structs! { | ||
/// A compile-time attribute item. | ||
/// | ||
/// E.g. `#[test]`, `#[derive(..)]` or `#[feature = "foo"]` | ||
pub enum MetaItem { | ||
/// Term meta item. | ||
/// | ||
/// E.g. `test` as in `#[test]` | ||
pub Term(Ident), | ||
|
||
/// List meta item. | ||
/// | ||
/// E.g. `derive(..)` as in `#[derive(..)]` | ||
pub List(MetaItemList { | ||
/// Name of this attribute. | ||
/// | ||
/// E.g. `derive` in `#[derive(..)]` | ||
pub ident: Ident, | ||
|
||
pub paren_token: tokens::Paren, | ||
|
||
/// Arguments to this attribute | ||
/// | ||
/// E.g. `..` in `#[derive(..)]` | ||
pub nested: Delimited<NestedMetaItem, tokens::Comma>, | ||
}), | ||
|
||
/// Name-value meta item. | ||
/// | ||
/// E.g. `feature = "foo"` as in `#[feature = "foo"]` | ||
pub NameValue(MetaNameValue { | ||
/// Name of this attribute. | ||
/// | ||
/// E.g. `feature` in `#[feature = "foo"]` | ||
pub ident: Ident, | ||
|
||
pub eq_token: tokens::Eq, | ||
|
||
/// Arguments to this attribute | ||
/// | ||
/// E.g. `"foo"` in `#[feature = "foo"]` | ||
pub lit: Lit, | ||
}), | ||
} | ||
} | ||
|
||
ast_enum_of_structs! { | ||
/// Possible values inside of compile-time attribute lists. | ||
/// | ||
/// E.g. the '..' in `#[name(..)]`. | ||
pub enum NestedMetaItem { | ||
/// A full `MetaItem`. | ||
/// | ||
/// E.g. `Copy` in `#[derive(Copy)]` would be a `MetaItem::Term(Ident::from("Copy"))`. | ||
pub MetaItem(MetaItem), | ||
|
||
/// A Rust literal. | ||
/// | ||
/// E.g. `"name"` in `#[rename("name")]`. | ||
pub Literal(Lit), | ||
} | ||
} |
84 changes: 84 additions & 0 deletions
84
collector/benchmarks/match-stress-exhaustive_patterns/src/data.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
use super::*; | ||
use delimited::Delimited; | ||
|
||
ast_struct! { | ||
/// An enum variant. | ||
pub struct Variant { | ||
/// Name of the variant. | ||
pub ident: Ident, | ||
|
||
/// Attributes tagged on the variant. | ||
pub attrs: Vec<Attribute>, | ||
|
||
/// Type of variant. | ||
pub data: VariantData, | ||
|
||
/// Explicit discriminant, e.g. `Foo = 1` | ||
pub discriminant: Option<Expr>, | ||
|
||
pub eq_token: Option<tokens::Eq>, | ||
} | ||
} | ||
|
||
ast_enum! { | ||
/// Data stored within an enum variant or struct. | ||
pub enum VariantData { | ||
/// Struct variant, e.g. `Point { x: f64, y: f64 }`. | ||
Struct(Delimited<Field, tokens::Comma>, tokens::Brace), | ||
|
||
/// Tuple variant, e.g. `Some(T)`. | ||
Tuple(Delimited<Field, tokens::Comma>, tokens::Paren), | ||
|
||
/// Unit variant, e.g. `None`. | ||
Unit, | ||
} | ||
} | ||
|
||
ast_struct! { | ||
/// A field of a struct or enum variant. | ||
pub struct Field { | ||
/// Name of the field, if any. | ||
/// | ||
/// Fields of tuple structs have no names. | ||
pub ident: Option<Ident>, | ||
|
||
/// Visibility of the field. | ||
pub vis: Visibility, | ||
|
||
/// Attributes tagged on the field. | ||
pub attrs: Vec<Attribute>, | ||
|
||
/// Type of the field. | ||
pub ty: Ty, | ||
|
||
pub colon_token: Option<tokens::Colon>, | ||
} | ||
} | ||
|
||
ast_enum_of_structs! { | ||
/// Visibility level of an item. | ||
pub enum Visibility { | ||
/// Public, i.e. `pub`. | ||
pub Public(VisPublic { | ||
pub pub_token: tokens::Pub, | ||
}), | ||
|
||
/// Crate-visible, i.e. `pub(crate)`. | ||
pub Crate(VisCrate { | ||
pub pub_token: tokens::Pub, | ||
pub paren_token: tokens::Paren, | ||
pub crate_token: tokens::Crate, | ||
}), | ||
|
||
/// Restricted, e.g. `pub(self)` or `pub(super)` or `pub(in some::module)`. | ||
pub Restricted(VisRestricted { | ||
pub pub_token: tokens::Pub, | ||
pub paren_token: tokens::Paren, | ||
pub in_token: Option<tokens::In>, | ||
pub path: Box<Path>, | ||
}), | ||
|
||
/// Inherited, i.e. private. | ||
pub Inherited(VisInherited {}), | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
collector/benchmarks/match-stress-exhaustive_patterns/src/derive.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use super::*; | ||
use delimited::Delimited; | ||
|
||
ast_struct! { | ||
/// Struct or enum sent to a `proc_macro_derive` macro. | ||
pub struct DeriveInput { | ||
/// Name of the struct or enum. | ||
pub ident: Ident, | ||
|
||
/// Visibility of the struct or enum. | ||
pub vis: Visibility, | ||
|
||
/// Attributes tagged on the whole struct or enum. | ||
pub attrs: Vec<Attribute>, | ||
|
||
/// Generics required to complete the definition. | ||
pub generics: Generics, | ||
|
||
/// Data within the struct or enum. | ||
pub body: Body, | ||
} | ||
} | ||
|
||
ast_enum_of_structs! { | ||
/// Body of a derived struct or enum. | ||
pub enum Body { | ||
/// It's an enum. | ||
pub Enum(BodyEnum { | ||
pub enum_token: tokens::Enum, | ||
pub brace_token: tokens::Brace, | ||
pub variants: Delimited<Variant, tokens::Comma>, | ||
}), | ||
|
||
/// It's a struct. | ||
pub Struct(BodyStruct { | ||
pub data: VariantData, | ||
pub struct_token: tokens::Struct, | ||
pub semi_token: Option<tokens::Semi>, | ||
}), | ||
} | ||
} |
Oops, something went wrong.