├── .github └── workflows │ └── ci.yml ├── .gitignore ├── ARCHITECTURE.md ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md └── src ├── error.rs ├── lib.rs ├── parse.rs ├── parse_extern.rs ├── parse_fn.rs ├── parse_impl.rs ├── parse_mod.rs ├── parse_type.rs ├── parse_utils.rs ├── punctuated.rs ├── snapshots ├── venial__tests__add_bounded_lifetime.snap ├── venial__tests__add_bounded_ty_param.snap ├── venial__tests__add_const_param-2.snap ├── venial__tests__add_const_param.snap ├── venial__tests__add_lifetime-2.snap ├── venial__tests__add_lifetime-3.snap ├── venial__tests__add_lifetime.snap ├── venial__tests__add_ty_param-2.snap ├── venial__tests__add_ty_param.snap ├── venial__tests__add_where_item-2.snap ├── venial__tests__add_where_item.snap ├── venial__tests__interpret_ty_expr_from_declarative_macro.snap ├── venial__tests__interpret_ty_expr_generic_as_path.snap ├── venial__tests__interpret_ty_expr_simple_as_path.snap ├── venial__tests__parse_all_kw_fn.snap ├── venial__tests__parse_async_fn.snap ├── venial__tests__parse_attr_fn.snap ├── venial__tests__parse_bounded_type_param_no_comma.snap ├── venial__tests__parse_complex_attributes-2.snap ├── venial__tests__parse_complex_attributes-3.snap ├── venial__tests__parse_complex_attributes.snap ├── venial__tests__parse_complex_enum_variant-2.snap ├── venial__tests__parse_complex_enum_variant-3.snap ├── venial__tests__parse_complex_enum_variant.snap ├── venial__tests__parse_const_fn.snap ├── venial__tests__parse_const_generics.snap ├── venial__tests__parse_constant_complex.snap ├── venial__tests__parse_constant_expressionless.snap ├── venial__tests__parse_constant_simple.snap ├── venial__tests__parse_default_fn.snap ├── venial__tests__parse_empty_enum.snap ├── venial__tests__parse_empty_fn.snap ├── venial__tests__parse_empty_struct.snap ├── venial__tests__parse_empty_tuple.snap ├── venial__tests__parse_enum.snap ├── venial__tests__parse_enum_attributes.snap ├── venial__tests__parse_enum_empty_generic_params.snap ├── venial__tests__parse_enum_empty_where_clause.snap ├── venial__tests__parse_enum_generic_params.snap ├── venial__tests__parse_enum_vis-2.snap ├── venial__tests__parse_enum_vis-3.snap ├── venial__tests__parse_enum_vis.snap ├── venial__tests__parse_enum_where_clause.snap ├── venial__tests__parse_extern_abi_fn.snap ├── venial__tests__parse_extern_block-2.snap ├── venial__tests__parse_extern_block.snap ├── venial__tests__parse_extern_crate-2.snap ├── venial__tests__parse_extern_crate-3.snap ├── venial__tests__parse_extern_crate.snap ├── venial__tests__parse_extern_fn.snap ├── venial__tests__parse_fn.snap ├── venial__tests__parse_fn_body.snap ├── venial__tests__parse_fn_lifetimes.snap ├── venial__tests__parse_fn_mut_param.snap ├── venial__tests__parse_fn_mut_receiver_lifetime.snap ├── venial__tests__parse_fn_prototype.snap ├── venial__tests__parse_fn_receiver_lifetime.snap ├── venial__tests__parse_fn_self_param-2.snap ├── venial__tests__parse_fn_self_param-3.snap ├── venial__tests__parse_fn_self_param-4.snap ├── venial__tests__parse_fn_self_param.snap ├── venial__tests__parse_fn_traits.snap ├── venial__tests__parse_generic_args.snap ├── venial__tests__parse_generic_args_turbofish.snap ├── venial__tests__parse_generic_fn.snap ├── venial__tests__parse_impl_inherent.snap ├── venial__tests__parse_impl_inherent_generic.snap ├── venial__tests__parse_impl_trait.snap ├── venial__tests__parse_impl_trait_generic.snap ├── venial__tests__parse_inline_generic_args-2.snap ├── venial__tests__parse_inline_generic_args.snap ├── venial__tests__parse_mod.snap ├── venial__tests__parse_multiple_brackets.snap ├── venial__tests__parse_normal_struct.snap ├── venial__tests__parse_normal_struct_attributes.snap ├── venial__tests__parse_normal_struct_empty_where_clause.snap ├── venial__tests__parse_normal_struct_generic_params.snap ├── venial__tests__parse_normal_struct_vis-2.snap ├── venial__tests__parse_normal_struct_vis-3.snap ├── venial__tests__parse_normal_struct_vis.snap ├── venial__tests__parse_normal_struct_where_clause.snap ├── venial__tests__parse_param_attr_fn.snap ├── venial__tests__parse_struct_fields_attributes.snap ├── venial__tests__parse_struct_fields_vis.snap ├── venial__tests__parse_trait_decorated.snap ├── venial__tests__parse_trait_simple.snap ├── venial__tests__parse_tuple_fields_attributes.snap ├── venial__tests__parse_tuple_fields_vis.snap ├── venial__tests__parse_tuple_struct.snap ├── venial__tests__parse_tuple_struct_attributes.snap ├── venial__tests__parse_tuple_struct_empty_where_clause.snap ├── venial__tests__parse_tuple_struct_generic_params.snap ├── venial__tests__parse_tuple_struct_vis-2.snap ├── venial__tests__parse_tuple_struct_vis-3.snap ├── venial__tests__parse_tuple_struct_vis.snap ├── venial__tests__parse_tuple_struct_where_clause.snap ├── venial__tests__parse_type_complex.snap ├── venial__tests__parse_type_simple.snap ├── venial__tests__parse_union.snap ├── venial__tests__parse_unit_struct.snap ├── venial__tests__parse_unit_struct_attributes.snap ├── venial__tests__parse_unit_struct_empty_where_clause.snap ├── venial__tests__parse_unit_struct_generic_params.snap ├── venial__tests__parse_unit_struct_vis-2.snap ├── venial__tests__parse_unit_struct_vis-3.snap ├── venial__tests__parse_unit_struct_vis.snap ├── venial__tests__parse_unit_struct_where_clause.snap ├── venial__tests__parse_unsafe_extern_block.snap ├── venial__tests__parse_unsafe_fn.snap ├── venial__tests__parse_visi_fn.snap ├── venial__tests__parse_where_fn-2.snap └── venial__tests__parse_where_fn.snap ├── tests.rs ├── types.rs └── types_edition.rs /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - master 5 | pull_request: 6 | 7 | jobs: 8 | rustfmt: 9 | runs-on: ubuntu-latest 10 | name: cargo fmt 11 | steps: 12 | - uses: actions/checkout@v2 13 | 14 | - name: install stable toolchain 15 | uses: actions-rs/toolchain@v1 16 | with: 17 | toolchain: stable 18 | profile: minimal 19 | components: rustfmt 20 | override: true 21 | 22 | - name: cargo fmt 23 | uses: actions-rs/cargo@v1 24 | with: 25 | command: fmt 26 | args: --all -- --check 27 | 28 | test: 29 | runs-on: ubuntu-latest 30 | name: cargo test 31 | steps: 32 | - uses: actions/checkout@v2 33 | 34 | - name: restore cache 35 | uses: Swatinem/rust-cache@v1 36 | 37 | - name: install stable toolchain 38 | uses: actions-rs/toolchain@v1 39 | with: 40 | toolchain: stable 41 | components: clippy 42 | profile: minimal 43 | override: true 44 | 45 | - name: cargo test 46 | uses: actions-rs/cargo@v1 47 | with: 48 | command: test 49 | 50 | clippy: 51 | runs-on: ubuntu-latest 52 | name: cargo clippy 53 | steps: 54 | - uses: actions/checkout@v2 55 | 56 | - name: restore cache 57 | uses: Swatinem/rust-cache@v1 58 | 59 | - name: install stable toolchain 60 | uses: actions-rs/toolchain@v1 61 | with: 62 | toolchain: stable 63 | components: clippy 64 | profile: minimal 65 | override: true 66 | 67 | - name: cargo clippy 68 | uses: actions-rs/cargo@v1 69 | with: 70 | command: clippy 71 | args: -- -D warnings 72 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | 5 | # These are backup files generated by rustfmt 6 | **/*.rs.bk 7 | 8 | # Folder generated by fuzzcheck 9 | /fuzz 10 | 11 | # IDEs 12 | /.vscode 13 | /.idea -------------------------------------------------------------------------------- /ARCHITECTURE.md: -------------------------------------------------------------------------------- 1 | # Project architecture 2 | 3 | The composition root of the project is the `parse_declaration` function. 4 | 5 | This project tries to have a low MSRV. It has minimal dependencies, and doesn't use any advanced Rust features. 6 | 7 | The code tends to use using `match` rather `if let`, and `loop` rather than `while`. This is more a matter of style than necessity. 8 | 9 | 10 | ## Files 11 | 12 | - **`parse.rs` -** composition root. 13 | - **`parse_fn.rs` -** parsing function declarations. 14 | - **`parse_impl.rs` -** parsing `impl` blocks. 15 | - **`parse_mod.rs` -** parsing modules and `use` statements. 16 | - **`parse_type.rs` -** parsing chunks of type declarations (generic args, where clauses, enum variants, struct fields, etc). 17 | - **`parse_utils.rs` -** parsing attributes, paths, common token, `consume_stuff_until`. 18 | - **`types.rs` -** the types of all data structures returned by the parser; includes implementations of `std::fmt::Debug` and`quote::ToTokens`. 19 | - **`types_edition.rs` -** method for editing types and getting useful information from them. 20 | - **`punctuated.rs` -** generic data structure representing a list of objects separated by punctuation. Includes optional trailing punctuation. 21 | - **`tests.rs` -** all the unit tests of the crate. 22 | - **`snapshots/` -** The values of snapshot tests. See [the documentation of `insta`](https://docs.rs/insta/latest/insta/) for details. 23 | - **`error.rs` -** convenient error type for displaying errors in your macros to users. 24 | 25 | 26 | ## Naming schemes 27 | 28 | Functions named `parse_xxx` take a token stream or another token container *by value* and either return a successfully parsed value, return an error, or panic. 29 | 30 | Functions named `consume_xxx` take a token stream *by mutable reference* and either return a successfully parsed value, or nothing (None or empty array). If they return nothing, no token is consumed. 31 | 32 | Therefore parse_xxx methods are better for cases where you know what you expect and not getting be would be incorrect Rust syntax (eg enum variants after an `enum` keyword). And consume_xxx mehods are better for cases where you're expecting optional syntax (eg `pub` keywords). 33 | 34 | 35 | ## `consume_stuff_until` 36 | 37 | Rust has some syntax bits that are too complicated from Venial to parse. 38 | 39 | Instead, venial uses its knowledge of when that syntax bit is guaranteed to end (eg: a `where` clause is guaranteed to end with `;` or `{`) and just captures and stores the whole token stream. 40 | 41 | `consume_stuff_until` is the function that handles that logic. There's also some logic to handle generic braces. 42 | 43 | 44 | ## Unit tests 45 | 46 | The `tests.rs` includes a few utility macros/functions: 47 | 48 | - **`assert_quote_snapshot` -** A wrapper around `insta`'s `assert_display_snapshot`. Serializes the given object with `quote!` before snapshotting it. 49 | - **`parse_xxx_checked` -** Parses XXX, then serializes the parsed object with `quote!`; checks that the token stream is preserved by the round-trip. -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "bstr" 7 | version = "0.2.17" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" 10 | dependencies = [ 11 | "lazy_static", 12 | "memchr", 13 | "regex-automata", 14 | ] 15 | 16 | [[package]] 17 | name = "console" 18 | version = "0.15.8" 19 | source = "registry+https://github.com/rust-lang/crates.io-index" 20 | checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" 21 | dependencies = [ 22 | "encode_unicode", 23 | "lazy_static", 24 | "libc", 25 | "windows-sys", 26 | ] 27 | 28 | [[package]] 29 | name = "encode_unicode" 30 | version = "0.3.6" 31 | source = "registry+https://github.com/rust-lang/crates.io-index" 32 | checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" 33 | 34 | [[package]] 35 | name = "insta" 36 | version = "1.38.0" 37 | source = "registry+https://github.com/rust-lang/crates.io-index" 38 | checksum = "3eab73f58e59ca6526037208f0e98851159ec1633cf17b6cd2e1f2c3fd5d53cc" 39 | dependencies = [ 40 | "console", 41 | "lazy_static", 42 | "linked-hash-map", 43 | "similar", 44 | ] 45 | 46 | [[package]] 47 | name = "lazy_static" 48 | version = "1.4.0" 49 | source = "registry+https://github.com/rust-lang/crates.io-index" 50 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 51 | 52 | [[package]] 53 | name = "libc" 54 | version = "0.2.153" 55 | source = "registry+https://github.com/rust-lang/crates.io-index" 56 | checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" 57 | 58 | [[package]] 59 | name = "linked-hash-map" 60 | version = "0.5.6" 61 | source = "registry+https://github.com/rust-lang/crates.io-index" 62 | checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" 63 | 64 | [[package]] 65 | name = "memchr" 66 | version = "2.7.2" 67 | source = "registry+https://github.com/rust-lang/crates.io-index" 68 | checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" 69 | 70 | [[package]] 71 | name = "proc-macro2" 72 | version = "1.0.79" 73 | source = "registry+https://github.com/rust-lang/crates.io-index" 74 | checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e" 75 | dependencies = [ 76 | "unicode-ident", 77 | ] 78 | 79 | [[package]] 80 | name = "quote" 81 | version = "1.0.35" 82 | source = "registry+https://github.com/rust-lang/crates.io-index" 83 | checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" 84 | dependencies = [ 85 | "proc-macro2", 86 | ] 87 | 88 | [[package]] 89 | name = "regex-automata" 90 | version = "0.1.10" 91 | source = "registry+https://github.com/rust-lang/crates.io-index" 92 | checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" 93 | 94 | [[package]] 95 | name = "similar" 96 | version = "2.4.0" 97 | source = "registry+https://github.com/rust-lang/crates.io-index" 98 | checksum = "32fea41aca09ee824cc9724996433064c89f7777e60762749a4170a14abbfa21" 99 | dependencies = [ 100 | "bstr", 101 | "unicode-segmentation", 102 | ] 103 | 104 | [[package]] 105 | name = "similar-asserts" 106 | version = "1.5.0" 107 | source = "registry+https://github.com/rust-lang/crates.io-index" 108 | checksum = "e041bb827d1bfca18f213411d51b665309f1afb37a04a5d1464530e13779fc0f" 109 | dependencies = [ 110 | "console", 111 | "similar", 112 | ] 113 | 114 | [[package]] 115 | name = "unicode-ident" 116 | version = "1.0.12" 117 | source = "registry+https://github.com/rust-lang/crates.io-index" 118 | checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" 119 | 120 | [[package]] 121 | name = "unicode-segmentation" 122 | version = "1.11.0" 123 | source = "registry+https://github.com/rust-lang/crates.io-index" 124 | checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" 125 | 126 | [[package]] 127 | name = "venial" 128 | version = "0.6.1" 129 | dependencies = [ 130 | "insta", 131 | "proc-macro2", 132 | "quote", 133 | "similar-asserts", 134 | ] 135 | 136 | [[package]] 137 | name = "windows-sys" 138 | version = "0.52.0" 139 | source = "registry+https://github.com/rust-lang/crates.io-index" 140 | checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" 141 | dependencies = [ 142 | "windows-targets", 143 | ] 144 | 145 | [[package]] 146 | name = "windows-targets" 147 | version = "0.52.4" 148 | source = "registry+https://github.com/rust-lang/crates.io-index" 149 | checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" 150 | dependencies = [ 151 | "windows_aarch64_gnullvm", 152 | "windows_aarch64_msvc", 153 | "windows_i686_gnu", 154 | "windows_i686_msvc", 155 | "windows_x86_64_gnu", 156 | "windows_x86_64_gnullvm", 157 | "windows_x86_64_msvc", 158 | ] 159 | 160 | [[package]] 161 | name = "windows_aarch64_gnullvm" 162 | version = "0.52.4" 163 | source = "registry+https://github.com/rust-lang/crates.io-index" 164 | checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" 165 | 166 | [[package]] 167 | name = "windows_aarch64_msvc" 168 | version = "0.52.4" 169 | source = "registry+https://github.com/rust-lang/crates.io-index" 170 | checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" 171 | 172 | [[package]] 173 | name = "windows_i686_gnu" 174 | version = "0.52.4" 175 | source = "registry+https://github.com/rust-lang/crates.io-index" 176 | checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" 177 | 178 | [[package]] 179 | name = "windows_i686_msvc" 180 | version = "0.52.4" 181 | source = "registry+https://github.com/rust-lang/crates.io-index" 182 | checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" 183 | 184 | [[package]] 185 | name = "windows_x86_64_gnu" 186 | version = "0.52.4" 187 | source = "registry+https://github.com/rust-lang/crates.io-index" 188 | checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" 189 | 190 | [[package]] 191 | name = "windows_x86_64_gnullvm" 192 | version = "0.52.4" 193 | source = "registry+https://github.com/rust-lang/crates.io-index" 194 | checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" 195 | 196 | [[package]] 197 | name = "windows_x86_64_msvc" 198 | version = "0.52.4" 199 | source = "registry+https://github.com/rust-lang/crates.io-index" 200 | checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" 201 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "venial" 3 | version = "0.6.1" 4 | authors = ["Olivier Faure "] 5 | edition = "2021" 6 | description = "A very small syn" 7 | repository = "https://github.com/PoignardAzur/venial" 8 | license = "MIT" 9 | keywords = ["syn", "parsing", "proc-macro", "small", "derive"] 10 | categories = ["development-tools::procedural-macro-helpers"] 11 | exclude = ["*.snap"] 12 | 13 | [dependencies] 14 | proc-macro2 = "1.0.36" 15 | quote = "1.0.15" 16 | 17 | [dev-dependencies] 18 | insta = "1.12.0" 19 | similar-asserts = "1.2.0" 20 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Olivier FAURE 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/error.rs: -------------------------------------------------------------------------------- 1 | // Most of this code is copy-pasted from syn roughly as-is. 2 | 3 | use proc_macro2::{Delimiter, Group, Ident, Literal, Punct, Spacing, Span, TokenStream, TokenTree}; 4 | use quote::ToTokens; 5 | use std::fmt::{Debug, Display}; 6 | 7 | /// Convenient error type for displaying errors in your macros to users. 8 | /// 9 | /// # Error reporting in proc macros 10 | /// 11 | /// The correct way to report errors back to the compiler from a procedural 12 | /// macro is by emitting an appropriately spanned invocation of 13 | /// [`compile_error!`] in the generated code. This produces a better diagnostic 14 | /// message than simply panicking the macro. 15 | /// 16 | /// This type provides a convenient [`.to_compile_error()`] method that returns 17 | /// `compile_error!("Your error message")` in TokenStream form. 18 | /// 19 | /// [`compile_error!`]: std::compile_error! 20 | /// 21 | /// ``` 22 | /// # extern crate proc_macro; 23 | /// # 24 | /// # use proc_macro2::TokenStream; 25 | /// # use venial::{parse_item, Item, Struct, Error}; 26 | /// # 27 | /// # const IGNORE: &str = stringify! { 28 | /// #[proc_macro_derive(MyDerive)] 29 | /// # }; 30 | /// pub fn my_derive(input: TokenStream) -> TokenStream { 31 | /// let input = parse_item(input); 32 | /// 33 | /// let parse_res = match input { 34 | /// Err(error) => Err(error), 35 | /// Ok(Item::Struct(struct_decl)) => parse_my_struct(struct_decl), 36 | /// Ok(item) => Err(Error::new_at_span( 37 | /// item.span(), 38 | /// "Error in my_derive macro: only structs are accepted" 39 | /// )), 40 | /// }; 41 | /// 42 | /// parse_res 43 | /// .unwrap_or_else(|err| err.to_compile_error()) 44 | /// .into() 45 | /// } 46 | /// 47 | /// pub fn parse_my_struct(input: Struct) -> Result { 48 | /// // ... 49 | /// # unimplemented!() 50 | /// } 51 | /// ``` 52 | 53 | #[derive(Clone)] 54 | pub struct Error { 55 | messages: Vec, 56 | } 57 | 58 | #[derive(Clone)] 59 | struct ErrorMessage { 60 | start_span: Span, 61 | end_span: Span, 62 | message: String, 63 | } 64 | 65 | impl Error { 66 | /// Create a new error message with the given text. 67 | /// 68 | /// The span will be located at the macro's call site. 69 | pub fn new(message: T) -> Self { 70 | Error { 71 | messages: vec![ErrorMessage { 72 | start_span: Span::call_site(), 73 | end_span: Span::call_site(), 74 | message: message.to_string(), 75 | }], 76 | } 77 | } 78 | 79 | /// Create a new error message with the given text and span. 80 | pub fn new_at_span(span: Span, message: T) -> Self { 81 | Error { 82 | messages: vec![ErrorMessage { 83 | start_span: span, 84 | end_span: span, 85 | message: message.to_string(), 86 | }], 87 | } 88 | } 89 | 90 | /// Create a new error message with the given text. 91 | /// 92 | /// Venial will do its best to locate the message at a span encompassing 93 | /// all the given tokens. 94 | pub fn new_at_tokens(tokens: T, message: U) -> Self { 95 | let mut iter = tokens.into_token_stream().into_iter(); 96 | let start = iter.next().map_or_else(Span::call_site, |t| t.span()); 97 | let end = iter.last().map_or(start, |t| t.span()); 98 | Error { 99 | messages: vec![ErrorMessage { 100 | start_span: start, 101 | end_span: end, 102 | message: message.to_string(), 103 | }], 104 | } 105 | } 106 | 107 | /// Returns a span in the first error. 108 | /// 109 | /// Note that, if span merging isn't enabled (currently nightly-only), the 110 | /// returned span will the smalled than the span that `self.to_compile_error()` 111 | /// inhabits. 112 | pub fn span(&self) -> Span { 113 | let start = self.messages[0].start_span; 114 | let end = self.messages[0].end_span; 115 | start.join(end).unwrap_or(start) 116 | } 117 | 118 | /// Render the error as an invocation of [`compile_error!`]. 119 | /// 120 | /// [`compile_error!`]: std::compile_error! 121 | pub fn to_compile_error(&self) -> TokenStream { 122 | self.messages 123 | .iter() 124 | .map(ErrorMessage::to_compile_error) 125 | .collect() 126 | } 127 | 128 | /// Add another error message to self such that when `to_compile_error()` is 129 | /// called, both errors will be emitted together. 130 | pub fn combine(&mut self, another: Error) { 131 | self.messages.extend(another.messages); 132 | } 133 | } 134 | 135 | impl ErrorMessage { 136 | fn to_compile_error(&self) -> TokenStream { 137 | // compile_error!($message) 138 | TokenStream::from_iter(vec![ 139 | TokenTree::Ident(Ident::new("compile_error", self.start_span)), 140 | TokenTree::Punct({ 141 | let mut punct = Punct::new('!', Spacing::Alone); 142 | punct.set_span(self.start_span); 143 | punct 144 | }), 145 | TokenTree::Group({ 146 | let mut group = Group::new(Delimiter::Brace, { 147 | TokenStream::from_iter(vec![TokenTree::Literal({ 148 | let mut string = Literal::string(&self.message); 149 | string.set_span(self.end_span); 150 | string 151 | })]) 152 | }); 153 | group.set_span(self.end_span); 154 | group 155 | }), 156 | ]) 157 | } 158 | } 159 | 160 | // -- Trait impls -- 161 | 162 | impl std::error::Error for Error {} 163 | 164 | impl Debug for Error { 165 | fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { 166 | if self.messages.len() == 1 { 167 | formatter 168 | .debug_tuple("Error") 169 | .field(&self.messages[0]) 170 | .finish() 171 | } else { 172 | formatter 173 | .debug_tuple("Error") 174 | .field(&self.messages) 175 | .finish() 176 | } 177 | } 178 | } 179 | 180 | impl Debug for ErrorMessage { 181 | fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { 182 | Debug::fmt(&self.message, formatter) 183 | } 184 | } 185 | 186 | impl Display for Error { 187 | fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { 188 | formatter.write_str(&self.messages[0].message) 189 | } 190 | } 191 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | #![warn(missing_docs)] 2 | #![warn(clippy::missing_errors_doc)] 3 | #![warn(clippy::missing_panics_doc)] 4 | #![warn(clippy::cargo)] 5 | #![allow(clippy::match_like_matches_macro)] 6 | #![allow(clippy::needless_late_init)] 7 | #![allow(clippy::large_enum_variant)] 8 | 9 | //! ## Lightweight parsing for Rust proc macros 10 | //! 11 | //! Venial is a small parser for Rust [proc macros](https://doc.rust-lang.org/reference/procedural-macros.html). 12 | //! 13 | //! When writing proc macros that need to parse Rust code (such as attribute and derive macros), the most common solution is to use the [syn](https://docs.rs/syn/latest/syn/index.html) crate. Syn can parse arbitrary valid Rust code, and even Rust-based DSLs, and return versatile data structures that can inspected and mutated in powerful ways. 14 | //! 15 | //! **It's also extremely heavy**. In [one analysis](https://hackmd.io/mxdn4U58Su-UQXwzOHpHag?view#round-13-cargo-timing-opt-j8) of [lqd's early 2022 benchmark collection](https://github.com/lqd/rustc-benchmarking-data), the author estimates that syn is reponsible for 8% of compile times of the benchmark, which accounts for Rust's most popular crates. There are subtleties (eg this isn't necessarily critical path time, but syn is often in the critical path anyway), but the overall takeaway is clear: syn is expensive. 16 | //! 17 | //! And yet, a lot of the power of syn is often unneeded. If we look at the [crates that depend on syn](https://crates.io/crates/syn/reverse_dependencies), we can see that the 5 most downloaded are: 18 | //! 19 | //! - serde_derive 20 | //! - proc-macro-hack 21 | //! - pin-project-internal 22 | //! - anyhow 23 | //! - thiserror-impl 24 | //! 25 | //! Of these, proc-macro-hack is deprecated, and the other four only need to parse basic information on a type. 26 | //! 27 | //! Other popular reverse-dependencies of syn (such as futures-macro, tokios-macros, async-trait, etc) *do* use syn's more advanced features, but there's still room for a lightweight parser in proc-macros. 28 | //! 29 | //! Venial is that parser. 30 | //! 31 | //! ## Example 32 | //! 33 | //! ```rust 34 | //! use venial::{parse_item, Item}; 35 | //! use quote::quote; 36 | //! 37 | //! let enum_type = parse_item(quote!( 38 | //! enum Shape { 39 | //! Square(Square), 40 | //! Circle(Circle), 41 | //! Triangle(Triangle), 42 | //! } 43 | //! )); 44 | //! 45 | //! let enum_type = match enum_type { 46 | //! Ok(Item::Enum(enum_type)) => enum_type, 47 | //! _ => unreachable!(), 48 | //! }; 49 | //! 50 | //! assert_eq!(enum_type.variants[0].0.name, "Square"); 51 | //! assert_eq!(enum_type.variants[1].0.name, "Circle"); 52 | //! assert_eq!(enum_type.variants[2].0.name, "Triangle"); 53 | //! ``` 54 | //! 55 | //! ## Spans 56 | //! 57 | //! Spans mark the beginning and end of tokens in the source code and can be used to generate precise error messages, highlighting certain parts. 58 | //! Item types provide a `span()` method that returns their respective span. 59 | //! 60 | //! Note that Rust's `proc_macro` crate [does not support span joining in stable][span-join]. That means that if you want items to hold the full 61 | //! full span of the input, you'll need a nightly compiler. Otherwise, the span will typically only include the first token-tree in the sequence. 62 | //! 63 | //! For example, if you have a [`NamedField`] you'd like to highlight in an error message, you can use `named_field.span()`. 64 | //! On nightly, a custom error could be rendered as follows: 65 | //! 66 | //! ```text 67 | //! error: my_attribute cannot be applied in this context 68 | //! --> crate/rust/src/file.rs:58:5 69 | //! | 70 | //! 58 | / #[my_attribute] 71 | //! 59 | | field: i32, 72 | //! | |______________^ 73 | //! ``` 74 | //! 75 | //! However, on stable, the span might only refer to the first token tree (here `#`): 76 | //! 77 | //! ```text 78 | //! error: my_attribute cannot be applied in this context 79 | //! --> crate/rust/src/file.rs:58:5 80 | //! | 81 | //! 58 | #[my_attribute] 82 | //! | ^ 83 | //! ``` 84 | //! 85 | //! You can however control this behavior more precisely by choosing which sub-tokens to highlight. On stable compilers, you might want to 86 | //! put focus on the field name `named_field.name.span()` instead of the entire field `named_field.span()`. This would yield: 87 | //! 88 | //! ```text 89 | //! error: my_attribute cannot be applied in this context 90 | //! --> crate/rust/src/file.rs:58:5 91 | //! | 92 | //! 59 | field: i32, 93 | //! | ^^^^^ 94 | //! ``` 95 | //! 96 | //! [span-join]: https://doc.rust-lang.org/proc_macro/struct.Span.html#method.join 97 | 98 | // Implementation guidelines and naming conventions: 99 | // - `parse_xxx` functions return `T`. 100 | // - They expect the whole item to be present, and panic otherwise. 101 | // - `consume_xxx` functions return Option: 102 | // - None if the syntax item is absent 103 | // - panic if the beginning of the syntax item is present but the expect continuation isn't. 104 | 105 | #[cfg(test)] 106 | mod tests; 107 | 108 | mod error; 109 | mod parse; 110 | mod parse_extern; 111 | mod parse_fn; 112 | mod parse_impl; 113 | mod parse_mod; 114 | mod parse_type; 115 | mod parse_utils; 116 | mod punctuated; 117 | mod types; 118 | mod types_edition; 119 | 120 | pub use error::Error; 121 | pub use parse::{consume_item, parse_item}; 122 | pub use punctuated::Punctuated; 123 | pub use types::*; 124 | -------------------------------------------------------------------------------- /src/parse_extern.rs: -------------------------------------------------------------------------------- 1 | use crate::parse_impl::parse_impl_body; 2 | use crate::parse_utils::{consume_ident, parse_any_ident, parse_ident, parse_punct, TokenIter}; 3 | use crate::{Attribute, ExternBlock, ExternCrate, VisMarker}; 4 | use proc_macro2::{Delimiter, TokenTree}; 5 | 6 | pub(crate) fn parse_extern_crate( 7 | tokens: &mut TokenIter, 8 | attributes: Vec, 9 | vis_marker: Option, 10 | ) -> ExternCrate { 11 | consume_extern_crate(tokens, attributes, vis_marker).expect("cannot parse extern crate") 12 | } 13 | 14 | fn consume_extern_crate( 15 | tokens: &mut TokenIter, 16 | attributes: Vec, 17 | vis_marker: Option, 18 | ) -> Option { 19 | let tk_extern = consume_ident(tokens, "extern")?; 20 | let tk_crate = consume_ident(tokens, "crate")?; 21 | 22 | let name = parse_any_ident(tokens, "extern crate"); 23 | let tk_as = consume_ident(tokens, "as"); 24 | 25 | let alias; 26 | let tk_underscore; 27 | if tk_as.is_some() { 28 | alias = Some(parse_any_ident(tokens, "extern crate: alias")); 29 | if alias.is_none() { 30 | tk_underscore = Some(parse_ident(tokens, "_", "extern crate")); 31 | } else { 32 | tk_underscore = None; 33 | } 34 | } else { 35 | alias = None; 36 | tk_underscore = None; 37 | } 38 | 39 | let tk_semicolon = parse_punct(tokens, ';', "extern crate"); 40 | 41 | Some(ExternCrate { 42 | attributes, 43 | vis_marker, 44 | tk_extern, 45 | tk_crate, 46 | name, 47 | tk_as, 48 | alias, 49 | tk_underscore, 50 | tk_semicolon, 51 | }) 52 | } 53 | 54 | pub(crate) fn parse_extern_block( 55 | tokens: &mut TokenIter, 56 | attributes: Vec, 57 | vis_marker: Option, 58 | ) -> ExternBlock { 59 | consume_extern_block(tokens, attributes, vis_marker).expect("cannot parse extern block") 60 | } 61 | 62 | fn consume_extern_block( 63 | tokens: &mut TokenIter, 64 | attributes: Vec, 65 | vis_marker: Option, 66 | ) -> Option { 67 | let tk_unsafe = consume_ident(tokens, "unsafe"); 68 | let tk_extern = consume_ident(tokens, "extern")?; 69 | 70 | let extern_abi = match tokens.peek() { 71 | Some(TokenTree::Literal(lit)) => { 72 | let lit = Some(lit.clone()); 73 | tokens.next(); 74 | lit 75 | } 76 | _ => None, 77 | }; 78 | 79 | let (tk_braces, inner_attributes, body_items) = match tokens.next() { 80 | Some(TokenTree::Group(group)) if group.delimiter() == Delimiter::Brace => { 81 | parse_impl_body(group, true) 82 | } 83 | _ => { 84 | // Only here we know that it's not an extern crate or extern block, so try other options on call-site (fn). 85 | return None; 86 | } 87 | }; 88 | 89 | Some(ExternBlock { 90 | attributes, 91 | vis_marker, 92 | tk_unsafe, 93 | tk_extern, 94 | extern_abi, 95 | tk_braces, 96 | inner_attributes, 97 | body_items, 98 | }) 99 | } 100 | -------------------------------------------------------------------------------- /src/parse_mod.rs: -------------------------------------------------------------------------------- 1 | use crate::parse::consume_item; 2 | use crate::parse_type::consume_item_name; 3 | use crate::parse_utils::{ 4 | consume_ident, consume_inner_attributes, consume_stuff_until, parse_ident, parse_punct, 5 | TokenIter, 6 | }; 7 | use crate::{Attribute, GroupSpan, Module, TypeExpr, UseDeclaration, VisMarker}; 8 | use proc_macro2::token_stream::IntoIter; 9 | use proc_macro2::{Delimiter, TokenTree}; 10 | use std::iter::Peekable; 11 | 12 | pub(crate) fn parse_mod( 13 | tokens: &mut Peekable, 14 | attributes: Vec, 15 | vis_marker: Option, 16 | ) -> Module { 17 | let tk_unsafe = consume_ident(tokens, "unsafe"); 18 | let tk_mod = parse_ident(tokens, "mod", "module declaration"); 19 | let module_name = consume_item_name(tokens); 20 | 21 | let (group, tk_semicolon) = match tokens.next().unwrap() { 22 | TokenTree::Group(group) if group.delimiter() == Delimiter::Brace => (Some(group), None), 23 | TokenTree::Punct(punct) if punct.as_char() == ';' => (None, Some(punct)), 24 | token => panic!( 25 | "cannot parse mod: expected `{{ }}` or `;`, but got token {:?}", 26 | token 27 | ), 28 | }; 29 | 30 | let inner_attributes; 31 | let tk_braces; 32 | let members; 33 | if let Some(group) = group { 34 | // Parse mod block body 35 | let mut mod_members = vec![]; 36 | let mut tokens = group.stream().into_iter().peekable(); 37 | 38 | tk_braces = Some(GroupSpan::new(&group)); 39 | inner_attributes = consume_inner_attributes(&mut tokens); 40 | loop { 41 | if tokens.peek().is_none() { 42 | break; 43 | } 44 | let item = 45 | consume_item(&mut tokens).unwrap_or_else(|e| panic!("declaration in mod: {}", e)); 46 | mod_members.push(item); 47 | } 48 | members = mod_members; 49 | } else { 50 | tk_braces = None; 51 | inner_attributes = vec![]; 52 | members = vec![]; 53 | } 54 | 55 | Module { 56 | attributes, 57 | vis_marker, 58 | tk_unsafe, 59 | tk_mod, 60 | name: module_name, 61 | tk_semicolon, 62 | tk_braces, 63 | inner_attributes, 64 | members, 65 | } 66 | } 67 | 68 | pub(crate) fn parse_use_declaration( 69 | tokens: &mut TokenIter, 70 | attributes: Vec, 71 | vis_marker: Option, 72 | ) -> UseDeclaration { 73 | let tk_use = parse_ident(tokens, "use", "use declaration"); 74 | 75 | let import_tree = consume_stuff_until( 76 | tokens, 77 | |token| match token { 78 | TokenTree::Punct(punct) if punct.as_char() == ';' => true, 79 | _ => false, 80 | }, 81 | true, 82 | ); 83 | 84 | let tk_semicolon = parse_punct(tokens, ';', "use declaration"); 85 | 86 | UseDeclaration { 87 | attributes, 88 | vis_marker, 89 | tk_use, 90 | import_tree: TypeExpr { 91 | tokens: import_tree, 92 | }, 93 | tk_semicolon, 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/punctuated.rs: -------------------------------------------------------------------------------- 1 | use proc_macro2::{Punct, Spacing, TokenStream}; 2 | use quote::{ToTokens, TokenStreamExt as _}; 3 | 4 | // Inspired by syn's `Punctuated` type. 5 | 6 | /// Comma-separated list of items. 7 | #[derive(Clone)] 8 | pub struct Punctuated { 9 | /// Vec of items and commas. 10 | pub inner: Vec<(T, Punct)>, 11 | /// If true, the last comma shouldn't be printed or considered part of the list. 12 | pub skip_last: bool, 13 | } 14 | 15 | impl Punctuated { 16 | /// Create a new list. 17 | pub fn new() -> Self { 18 | Punctuated { 19 | inner: Vec::new(), 20 | skip_last: false, 21 | } 22 | } 23 | 24 | /// Add an items at the end of the list. 25 | /// 26 | /// If `comma` is None, sets `self.skip_last` to true, and adds a comma 27 | /// to the array with default values. That comma will be considered as the 28 | /// item's comma if **push** is called again. 29 | pub fn push(&mut self, value: T, comma: Option) { 30 | self.skip_last = comma.is_none(); 31 | let comma = comma.unwrap_or_else(|| Punct::new(',', Spacing::Alone)); 32 | self.inner.push((value, comma)) 33 | } 34 | 35 | /// Inserts an element at position `index`. 36 | /// 37 | /// # Panics 38 | /// 39 | /// Panics if `index` is greater than the number of elements previously in 40 | /// this punctuated sequence. 41 | pub fn insert(&mut self, index: usize, value: T, comma: Option) { 42 | assert!(index <= self.len()); 43 | 44 | if index == self.len() { 45 | self.push(value, comma); 46 | } else { 47 | self.inner 48 | .insert(index, (value, Punct::new(',', Spacing::Alone))); 49 | } 50 | } 51 | 52 | /// Return an interator that reads items. 53 | pub fn items(&self) -> impl Iterator { 54 | self.inner.iter().map(|(item, _punct)| item) 55 | } 56 | 57 | /// Return an interator that reads commas. 58 | pub fn punct(&self) -> impl Iterator { 59 | let len = self.inner.len(); 60 | let slice = if self.skip_last && len > 0 { 61 | &self.inner[..len - 1] 62 | } else { 63 | &self.inner[..] 64 | }; 65 | slice.iter().map(|(_item, punct)| punct) 66 | } 67 | 68 | /// Return number of items. 69 | pub fn len(&self) -> usize { 70 | self.inner.len() 71 | } 72 | 73 | /// Return true if collection has no items. 74 | pub fn is_empty(&self) -> bool { 75 | self.inner.is_empty() 76 | } 77 | } 78 | 79 | // --- Trait impls --- 80 | 81 | impl Default for Punctuated { 82 | fn default() -> Self { 83 | Self::new() 84 | } 85 | } 86 | 87 | impl std::fmt::Debug for Punctuated { 88 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 89 | let mut list = f.debug_list(); 90 | for (item, _) in &self.inner { 91 | list.entry(item); 92 | } 93 | list.finish() 94 | } 95 | } 96 | 97 | impl ToTokens for Punctuated { 98 | fn to_tokens(&self, tokens: &mut TokenStream) { 99 | if self.inner.is_empty() { 100 | return; 101 | } 102 | 103 | for (item, punct) in &self.inner[..self.inner.len() - 1] { 104 | item.to_tokens(tokens); 105 | tokens.append(punct.clone()); 106 | } 107 | self.inner.last().unwrap().0.to_tokens(tokens); 108 | if !self.skip_last { 109 | tokens.append(self.inner.last().unwrap().1.clone()); 110 | } 111 | } 112 | } 113 | 114 | impl std::ops::Deref for Punctuated { 115 | type Target = [(T, Punct)]; 116 | 117 | fn deref(&self) -> &Self::Target { 118 | &self.inner 119 | } 120 | } 121 | 122 | impl std::ops::DerefMut for Punctuated { 123 | fn deref_mut(&mut self) -> &mut ::Target { 124 | &mut self.inner 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__add_bounded_lifetime.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: tokens 4 | --- 5 | struct Hello < ' b : c + d > { a : A , b : B , } 6 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__add_bounded_ty_param.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: tokens 4 | --- 5 | struct Hello < T : Clone > { a : A , b : B , } 6 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__add_const_param-2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: tokens 4 | --- 5 | struct Hello < A , B , const N : u32 > { a : A , b : B , } 6 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__add_const_param.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: tokens 4 | --- 5 | struct Hello < const N : u32 > { a : A , b : B , } 6 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__add_lifetime-2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: tokens 4 | --- 5 | struct Hello < 'b , A , B > { a : A , b : B , } 6 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__add_lifetime-3.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: tokens 4 | --- 5 | struct Hello < 'b , 'a , A , B > { a : & 'a A , b : B , } 6 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__add_lifetime.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: tokens 4 | --- 5 | struct Hello < 'b > { a : A , b : B , } 6 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__add_ty_param-2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: tokens 4 | --- 5 | struct Hello < A , B , T > { a : A , b : B , } 6 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__add_ty_param.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: tokens 4 | --- 5 | struct Hello < T > { a : A , b : B , } 6 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__add_where_item-2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: tokens 4 | --- 5 | struct Hello < A , B > where A : Clone , B : Clone , Self : Sized { a : A , b : B , } 6 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__add_where_item.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: tokens 4 | --- 5 | struct Hello where Self : Sized { a : A , b : B , } 6 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__interpret_ty_expr_from_declarative_macro.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: path 4 | --- 5 | Path { 6 | segments: [ 7 | PathSegment { 8 | ident: Ident( 9 | path, 10 | ), 11 | }, 12 | PathSegment { 13 | tk_separator_colons: "::", 14 | ident: Ident( 15 | to, 16 | ), 17 | }, 18 | PathSegment { 19 | tk_separator_colons: "::", 20 | ident: Ident( 21 | Type, 22 | ), 23 | }, 24 | ], 25 | } 26 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__interpret_ty_expr_generic_as_path.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: path 4 | --- 5 | Path { 6 | segments: [ 7 | PathSegment { 8 | ident: Ident( 9 | path, 10 | ), 11 | }, 12 | PathSegment { 13 | tk_separator_colons: "::", 14 | ident: Ident( 15 | to, 16 | ), 17 | }, 18 | PathSegment { 19 | tk_separator_colons: "::", 20 | ident: Ident( 21 | Type, 22 | ), 23 | generic_args: GenericArgList { 24 | args: [ 25 | Lifetime { 26 | lifetime: Lifetime { 27 | tk_apostrophe: Punct { 28 | char: '\'', 29 | spacing: Joint, 30 | }, 31 | name: Ident( 32 | a, 33 | ), 34 | }, 35 | }, 36 | TypeOrConst { 37 | expr: [ 38 | other, 39 | ":", 40 | ":", 41 | Arg, 42 | ], 43 | }, 44 | TypeOrConst { 45 | expr: [ 46 | 36, 47 | ], 48 | }, 49 | ], 50 | }, 51 | }, 52 | PathSegment { 53 | tk_separator_colons: "::", 54 | ident: Ident( 55 | Turbofish, 56 | ), 57 | generic_args: GenericArgList { 58 | tk_turbofish_colons: "::", 59 | args: [], 60 | }, 61 | }, 62 | ], 63 | } 64 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__interpret_ty_expr_simple_as_path.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: path 4 | --- 5 | Path { 6 | segments: [ 7 | PathSegment { 8 | tk_separator_colons: "::", 9 | ident: Ident( 10 | path, 11 | ), 12 | }, 13 | PathSegment { 14 | tk_separator_colons: "::", 15 | ident: Ident( 16 | to, 17 | ), 18 | }, 19 | PathSegment { 20 | tk_separator_colons: "::", 21 | ident: Ident( 22 | Type, 23 | ), 24 | }, 25 | ], 26 | } 27 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_all_kw_fn.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: func 4 | --- 5 | Function( 6 | Function { 7 | attributes: [], 8 | vis_marker: Some( 9 | pub, 10 | ), 11 | qualifiers: FnQualifiers { 12 | tk_default: Some( 13 | Ident( 14 | default, 15 | ), 16 | ), 17 | tk_const: Some( 18 | Ident( 19 | const, 20 | ), 21 | ), 22 | tk_async: Some( 23 | Ident( 24 | async, 25 | ), 26 | ), 27 | tk_unsafe: Some( 28 | Ident( 29 | unsafe, 30 | ), 31 | ), 32 | tk_extern: Some( 33 | Ident( 34 | extern, 35 | ), 36 | ), 37 | extern_abi: Some( 38 | Literal { 39 | lit: "C", 40 | }, 41 | ), 42 | }, 43 | tk_fn_keyword: Ident( 44 | fn, 45 | ), 46 | name: Ident( 47 | all_kw, 48 | ), 49 | generic_params: None, 50 | tk_params_parens: (), 51 | params: [ 52 | Typed( 53 | FnTypedParam { 54 | attributes: [], 55 | tk_mut: None, 56 | name: Ident( 57 | b, 58 | ), 59 | tk_colon: Punct { 60 | char: ':', 61 | spacing: Alone, 62 | }, 63 | ty: [ 64 | f32, 65 | ], 66 | }, 67 | ), 68 | ], 69 | where_clause: None, 70 | tk_return_arrow: None, 71 | return_ty: None, 72 | tk_semicolon: None, 73 | body: Some( 74 | Group { 75 | delimiter: Brace, 76 | stream: TokenStream [], 77 | }, 78 | ), 79 | }, 80 | ) 81 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_async_fn.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: func 4 | --- 5 | Function( 6 | Function { 7 | attributes: [], 8 | vis_marker: Some( 9 | pub, 10 | ), 11 | qualifiers: FnQualifiers { 12 | tk_default: None, 13 | tk_const: None, 14 | tk_async: Some( 15 | Ident( 16 | async, 17 | ), 18 | ), 19 | tk_unsafe: None, 20 | tk_extern: None, 21 | extern_abi: None, 22 | }, 23 | tk_fn_keyword: Ident( 24 | fn, 25 | ), 26 | name: Ident( 27 | async_fn, 28 | ), 29 | generic_params: None, 30 | tk_params_parens: (), 31 | params: [ 32 | Typed( 33 | FnTypedParam { 34 | attributes: [], 35 | tk_mut: None, 36 | name: Ident( 37 | b, 38 | ), 39 | tk_colon: Punct { 40 | char: ':', 41 | spacing: Alone, 42 | }, 43 | ty: [ 44 | f32, 45 | ], 46 | }, 47 | ), 48 | ], 49 | where_clause: None, 50 | tk_return_arrow: None, 51 | return_ty: None, 52 | tk_semicolon: None, 53 | body: Some( 54 | Group { 55 | delimiter: Brace, 56 | stream: TokenStream [], 57 | }, 58 | ), 59 | }, 60 | ) 61 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_attr_fn.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: func 4 | --- 5 | Function( 6 | Function { 7 | attributes: [ 8 | Attribute { 9 | tk_hash: Punct { 10 | char: '#', 11 | spacing: Alone, 12 | }, 13 | tk_brackets: [], 14 | path: [ 15 | my_attr, 16 | ], 17 | value: Empty, 18 | }, 19 | ], 20 | vis_marker: None, 21 | qualifiers: FnQualifiers { 22 | tk_default: None, 23 | tk_const: None, 24 | tk_async: None, 25 | tk_unsafe: None, 26 | tk_extern: None, 27 | extern_abi: None, 28 | }, 29 | tk_fn_keyword: Ident( 30 | fn, 31 | ), 32 | name: Ident( 33 | my_attr_fn, 34 | ), 35 | generic_params: None, 36 | tk_params_parens: (), 37 | params: [ 38 | Typed( 39 | FnTypedParam { 40 | attributes: [], 41 | tk_mut: None, 42 | name: Ident( 43 | a, 44 | ), 45 | tk_colon: Punct { 46 | char: ':', 47 | spacing: Alone, 48 | }, 49 | ty: [ 50 | i32, 51 | ], 52 | }, 53 | ), 54 | ], 55 | where_clause: None, 56 | tk_return_arrow: None, 57 | return_ty: None, 58 | tk_semicolon: None, 59 | body: Some( 60 | Group { 61 | delimiter: Brace, 62 | stream: TokenStream [], 63 | }, 64 | ), 65 | }, 66 | ) 67 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_bounded_type_param_no_comma.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_struct: Ident( 10 | struct, 11 | ), 12 | name: Ident( 13 | Example, 14 | ), 15 | generic_params: Some( 16 | [ 17 | GenericParam { 18 | name: "A", 19 | bound: Some( 20 | [ 21 | Clone, 22 | ], 23 | ), 24 | }, 25 | ], 26 | ), 27 | where_clause: None, 28 | fields: Named( 29 | [ 30 | NamedField { 31 | attributes: [], 32 | vis_marker: None, 33 | name: Ident( 34 | _test, 35 | ), 36 | tk_colon: Punct { 37 | char: ':', 38 | spacing: Alone, 39 | }, 40 | ty: [ 41 | A, 42 | ], 43 | }, 44 | ], 45 | ), 46 | tk_semicolon: None, 47 | }, 48 | ) 49 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_complex_attributes-2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: "struct_type.attributes()[0].get_single_path_segment()" 4 | --- 5 | None 6 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_complex_attributes-3.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: "struct_type.attributes()[1].get_single_path_segment()" 4 | --- 5 | Some( 6 | Ident( 7 | hello, 8 | ), 9 | ) 10 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_complex_attributes.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [ 8 | Attribute { 9 | tk_hash: Punct { 10 | char: '#', 11 | spacing: Alone, 12 | }, 13 | tk_brackets: [], 14 | path: [ 15 | hello, 16 | ":", 17 | ":", 18 | world, 19 | ], 20 | value: Empty, 21 | }, 22 | Attribute { 23 | tk_hash: Punct { 24 | char: '#', 25 | spacing: Alone, 26 | }, 27 | tk_brackets: [], 28 | path: [ 29 | hello, 30 | ], 31 | value: Equals( 32 | [ 33 | a, 34 | "+", 35 | b, 36 | ], 37 | Punct { 38 | char: '=', 39 | spacing: Alone, 40 | }, 41 | ), 42 | }, 43 | Attribute { 44 | tk_hash: Punct { 45 | char: '#', 46 | spacing: Alone, 47 | }, 48 | tk_brackets: [], 49 | path: [ 50 | hello, 51 | ":", 52 | ":", 53 | world, 54 | ], 55 | value: Equals( 56 | [ 57 | a, 58 | "+", 59 | b, 60 | ], 61 | Punct { 62 | char: '=', 63 | spacing: Alone, 64 | }, 65 | ), 66 | }, 67 | Attribute { 68 | tk_hash: Punct { 69 | char: '#', 70 | spacing: Alone, 71 | }, 72 | tk_brackets: [], 73 | path: [ 74 | hello, 75 | ], 76 | value: Group( 77 | [ 78 | a, 79 | b, 80 | c, 81 | ], 82 | (), 83 | ), 84 | }, 85 | Attribute { 86 | tk_hash: Punct { 87 | char: '#', 88 | spacing: Alone, 89 | }, 90 | tk_brackets: [], 91 | path: [ 92 | hello, 93 | ":", 94 | ":", 95 | world, 96 | ], 97 | value: Group( 98 | [ 99 | a, 100 | b, 101 | c, 102 | ], 103 | (), 104 | ), 105 | }, 106 | ], 107 | vis_marker: Some( 108 | pub, 109 | ), 110 | tk_struct: Ident( 111 | struct, 112 | ), 113 | name: Ident( 114 | Hello, 115 | ), 116 | generic_params: None, 117 | where_clause: None, 118 | fields: Unit, 119 | tk_semicolon: Some( 120 | Punct { 121 | char: ';', 122 | spacing: Alone, 123 | }, 124 | ), 125 | }, 126 | ) 127 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_complex_enum_variant-2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: enum_type_2 4 | --- 5 | Err( 6 | Error( 7 | "Complex values for enum variants are not supported unless they are between parentheses.", 8 | ), 9 | ) 10 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_complex_enum_variant-3.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: enum_type_3 4 | --- 5 | Ok( 6 | Enum( 7 | Enum { 8 | attributes: [], 9 | vis_marker: None, 10 | tk_enum: Ident( 11 | enum, 12 | ), 13 | name: Ident( 14 | Hello, 15 | ), 16 | generic_params: None, 17 | where_clauses: None, 18 | variants: [ 19 | EnumVariant { 20 | attributes: [], 21 | vis_marker: None, 22 | name: Ident( 23 | A, 24 | ), 25 | fields: Unit, 26 | value: Some( 27 | EnumVariantValue { 28 | tk_equal: Punct { 29 | char: '=', 30 | spacing: Alone, 31 | }, 32 | value: Literal { 33 | lit: 1, 34 | }, 35 | }, 36 | ), 37 | }, 38 | EnumVariant { 39 | attributes: [], 40 | vis_marker: None, 41 | name: Ident( 42 | B, 43 | ), 44 | fields: Tuple( 45 | [ 46 | TupleField { 47 | attributes: [], 48 | vis_marker: None, 49 | ty: [ 50 | Foo, 51 | ], 52 | }, 53 | TupleField { 54 | attributes: [], 55 | vis_marker: None, 56 | ty: [ 57 | Bar, 58 | ], 59 | }, 60 | ], 61 | ), 62 | value: Some( 63 | EnumVariantValue { 64 | tk_equal: Punct { 65 | char: '=', 66 | spacing: Alone, 67 | }, 68 | value: Group { 69 | delimiter: Bracket, 70 | stream: TokenStream [ 71 | Literal { 72 | lit: 1, 73 | }, 74 | Punct { 75 | char: '+', 76 | spacing: Alone, 77 | }, 78 | Literal { 79 | lit: 2, 80 | }, 81 | Punct { 82 | char: '+', 83 | spacing: Alone, 84 | }, 85 | Literal { 86 | lit: 3, 87 | }, 88 | ], 89 | }, 90 | }, 91 | ), 92 | }, 93 | EnumVariant { 94 | attributes: [], 95 | vis_marker: None, 96 | name: Ident( 97 | C, 98 | ), 99 | fields: Named( 100 | [ 101 | NamedField { 102 | attributes: [], 103 | vis_marker: None, 104 | name: Ident( 105 | foo, 106 | ), 107 | tk_colon: Punct { 108 | char: ':', 109 | spacing: Alone, 110 | }, 111 | ty: [ 112 | Foo, 113 | ], 114 | }, 115 | NamedField { 116 | attributes: [], 117 | vis_marker: None, 118 | name: Ident( 119 | bar, 120 | ), 121 | tk_colon: Punct { 122 | char: ':', 123 | spacing: Alone, 124 | }, 125 | ty: [ 126 | Bar, 127 | ], 128 | }, 129 | ], 130 | ), 131 | value: Some( 132 | EnumVariantValue { 133 | tk_equal: Punct { 134 | char: '=', 135 | spacing: Alone, 136 | }, 137 | value: Group { 138 | delimiter: Parenthesis, 139 | stream: TokenStream [ 140 | Ident { 141 | sym: foo, 142 | }, 143 | Group { 144 | delimiter: Parenthesis, 145 | stream: TokenStream [ 146 | Ident { 147 | sym: bar, 148 | }, 149 | ], 150 | }, 151 | ], 152 | }, 153 | }, 154 | ), 155 | }, 156 | ], 157 | }, 158 | ), 159 | ) 160 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_complex_enum_variant.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: enum_type_1 4 | --- 5 | Err( 6 | Error( 7 | "Complex values for enum variants are not supported unless they are between parentheses.", 8 | ), 9 | ) 10 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_const_fn.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: func 4 | --- 5 | Function( 6 | Function { 7 | attributes: [], 8 | vis_marker: Some( 9 | pub, 10 | ), 11 | qualifiers: FnQualifiers { 12 | tk_default: None, 13 | tk_const: Some( 14 | Ident( 15 | const, 16 | ), 17 | ), 18 | tk_async: None, 19 | tk_unsafe: None, 20 | tk_extern: None, 21 | extern_abi: None, 22 | }, 23 | tk_fn_keyword: Ident( 24 | fn, 25 | ), 26 | name: Ident( 27 | const_fn, 28 | ), 29 | generic_params: None, 30 | tk_params_parens: (), 31 | params: [ 32 | Typed( 33 | FnTypedParam { 34 | attributes: [], 35 | tk_mut: None, 36 | name: Ident( 37 | b, 38 | ), 39 | tk_colon: Punct { 40 | char: ':', 41 | spacing: Alone, 42 | }, 43 | ty: [ 44 | f32, 45 | ], 46 | }, 47 | ), 48 | ], 49 | where_clause: None, 50 | tk_return_arrow: None, 51 | return_ty: None, 52 | tk_semicolon: None, 53 | body: Some( 54 | Group { 55 | delimiter: Brace, 56 | stream: TokenStream [], 57 | }, 58 | ), 59 | }, 60 | ) 61 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_const_generics.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_struct: Ident( 10 | struct, 11 | ), 12 | name: Ident( 13 | Hello, 14 | ), 15 | generic_params: None, 16 | where_clause: None, 17 | fields: Tuple( 18 | [ 19 | TupleField { 20 | attributes: [], 21 | vis_marker: None, 22 | ty: [ 23 | Array, 24 | "<", 25 | A, 26 | ",", 27 | Group { 28 | delimiter: Brace, 29 | stream: TokenStream [ 30 | Literal { 31 | lit: 123, 32 | }, 33 | Punct { 34 | char: '+', 35 | spacing: Alone, 36 | }, 37 | Group { 38 | delimiter: Parenthesis, 39 | stream: TokenStream [ 40 | Literal { 41 | lit: 1, 42 | }, 43 | Punct { 44 | char: ',', 45 | spacing: Alone, 46 | }, 47 | Literal { 48 | lit: 2, 49 | }, 50 | Punct { 51 | char: ',', 52 | spacing: Alone, 53 | }, 54 | Literal { 55 | lit: 3, 56 | }, 57 | ], 58 | }, 59 | ], 60 | }, 61 | ">", 62 | ], 63 | }, 64 | TupleField { 65 | attributes: [], 66 | vis_marker: None, 67 | ty: [ 68 | B, 69 | "<", 70 | Group { 71 | delimiter: Brace, 72 | stream: TokenStream [ 73 | Literal { 74 | lit: 1, 75 | }, 76 | ], 77 | }, 78 | ",", 79 | Group { 80 | delimiter: Brace, 81 | stream: TokenStream [ 82 | Literal { 83 | lit: 2, 84 | }, 85 | ], 86 | }, 87 | ">", 88 | ], 89 | }, 90 | ], 91 | ), 92 | tk_semicolon: Some( 93 | Punct { 94 | char: ';', 95 | spacing: Alone, 96 | }, 97 | ), 98 | }, 99 | ) 100 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_constant_complex.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: const_decl 4 | --- 5 | Constant( 6 | Constant { 7 | attributes: [ 8 | Attribute { 9 | tk_hash: Punct { 10 | char: '#', 11 | spacing: Alone, 12 | }, 13 | tk_brackets: [], 14 | path: [ 15 | attribute, 16 | ], 17 | value: Empty, 18 | }, 19 | ], 20 | vis_marker: Some( 21 | pub( 22 | crate, 23 | ), 24 | ), 25 | tk_const_or_static: Ident( 26 | const, 27 | ), 28 | tk_mut: None, 29 | name: Ident( 30 | CONSTANT, 31 | ), 32 | tk_colon: Punct { 33 | char: ':', 34 | spacing: Alone, 35 | }, 36 | ty: [ 37 | some, 38 | ":", 39 | ":", 40 | complex, 41 | ":", 42 | ":", 43 | Type, 44 | "<", 45 | "'", 46 | static, 47 | ",", 48 | bool, 49 | ">", 50 | ], 51 | tk_equals: Some( 52 | Punct { 53 | char: '=', 54 | spacing: Alone, 55 | }, 56 | ), 57 | initializer: Some( 58 | [ 59 | some, 60 | ":", 61 | ":", 62 | complex, 63 | ":", 64 | ":", 65 | Expr, 66 | "+", 67 | 77, 68 | ], 69 | ), 70 | tk_semicolon: Punct { 71 | char: ';', 72 | spacing: Alone, 73 | }, 74 | }, 75 | ) 76 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_constant_expressionless.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: const_decl 4 | --- 5 | Constant( 6 | Constant { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_const_or_static: Ident( 10 | const, 11 | ), 12 | tk_mut: None, 13 | name: Ident( 14 | CONSTANT, 15 | ), 16 | tk_colon: Punct { 17 | char: ':', 18 | spacing: Alone, 19 | }, 20 | ty: [ 21 | some, 22 | ":", 23 | ":", 24 | Type, 25 | ], 26 | tk_equals: None, 27 | initializer: None, 28 | tk_semicolon: Punct { 29 | char: ';', 30 | spacing: Alone, 31 | }, 32 | }, 33 | ) 34 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_constant_simple.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: const_decl 4 | --- 5 | Constant( 6 | Constant { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_const_or_static: Ident( 10 | const, 11 | ), 12 | tk_mut: None, 13 | name: Ident( 14 | CONSTANT, 15 | ), 16 | tk_colon: Punct { 17 | char: ':', 18 | spacing: Alone, 19 | }, 20 | ty: [ 21 | i32, 22 | ], 23 | tk_equals: Some( 24 | Punct { 25 | char: '=', 26 | spacing: Alone, 27 | }, 28 | ), 29 | initializer: Some( 30 | [ 31 | 20, 32 | ], 33 | ), 34 | tk_semicolon: Punct { 35 | char: ';', 36 | spacing: Alone, 37 | }, 38 | }, 39 | ) 40 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_default_fn.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: func 4 | --- 5 | Function( 6 | Function { 7 | attributes: [], 8 | vis_marker: Some( 9 | pub, 10 | ), 11 | qualifiers: FnQualifiers { 12 | tk_default: Some( 13 | Ident( 14 | default, 15 | ), 16 | ), 17 | tk_const: None, 18 | tk_async: None, 19 | tk_unsafe: None, 20 | tk_extern: None, 21 | extern_abi: None, 22 | }, 23 | tk_fn_keyword: Ident( 24 | fn, 25 | ), 26 | name: Ident( 27 | default_fn, 28 | ), 29 | generic_params: None, 30 | tk_params_parens: (), 31 | params: [ 32 | Typed( 33 | FnTypedParam { 34 | attributes: [], 35 | tk_mut: None, 36 | name: Ident( 37 | b, 38 | ), 39 | tk_colon: Punct { 40 | char: ':', 41 | spacing: Alone, 42 | }, 43 | ty: [ 44 | f32, 45 | ], 46 | }, 47 | ), 48 | ], 49 | where_clause: None, 50 | tk_return_arrow: None, 51 | return_ty: None, 52 | tk_semicolon: None, 53 | body: Some( 54 | Group { 55 | delimiter: Brace, 56 | stream: TokenStream [], 57 | }, 58 | ), 59 | }, 60 | ) 61 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_empty_enum.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: enum_type 4 | --- 5 | Enum( 6 | Enum { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_enum: Ident( 10 | enum, 11 | ), 12 | name: Ident( 13 | Hello, 14 | ), 15 | generic_params: None, 16 | where_clauses: None, 17 | variants: [], 18 | }, 19 | ) 20 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_empty_fn.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: func 4 | --- 5 | Function( 6 | Function { 7 | attributes: [], 8 | vis_marker: None, 9 | qualifiers: FnQualifiers { 10 | tk_default: None, 11 | tk_const: None, 12 | tk_async: None, 13 | tk_unsafe: None, 14 | tk_extern: None, 15 | extern_abi: None, 16 | }, 17 | tk_fn_keyword: Ident( 18 | fn, 19 | ), 20 | name: Ident( 21 | test_me, 22 | ), 23 | generic_params: None, 24 | tk_params_parens: (), 25 | params: [], 26 | where_clause: None, 27 | tk_return_arrow: None, 28 | return_ty: None, 29 | tk_semicolon: None, 30 | body: Some( 31 | Group { 32 | delimiter: Brace, 33 | stream: TokenStream [], 34 | }, 35 | ), 36 | }, 37 | ) 38 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_empty_struct.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_struct: Ident( 10 | struct, 11 | ), 12 | name: Ident( 13 | Hello, 14 | ), 15 | generic_params: None, 16 | where_clause: None, 17 | fields: Named( 18 | [], 19 | ), 20 | tk_semicolon: None, 21 | }, 22 | ) 23 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_empty_tuple.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_struct: Ident( 10 | struct, 11 | ), 12 | name: Ident( 13 | Hello, 14 | ), 15 | generic_params: None, 16 | where_clause: None, 17 | fields: Tuple( 18 | [], 19 | ), 20 | tk_semicolon: Some( 21 | Punct { 22 | char: ';', 23 | spacing: Alone, 24 | }, 25 | ), 26 | }, 27 | ) 28 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_enum.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: enum_type 4 | --- 5 | Enum( 6 | Enum { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_enum: Ident( 10 | enum, 11 | ), 12 | name: Ident( 13 | Hello, 14 | ), 15 | generic_params: None, 16 | where_clauses: None, 17 | variants: [ 18 | EnumVariant { 19 | attributes: [], 20 | vis_marker: None, 21 | name: Ident( 22 | A, 23 | ), 24 | fields: Unit, 25 | value: None, 26 | }, 27 | EnumVariant { 28 | attributes: [], 29 | vis_marker: None, 30 | name: Ident( 31 | B, 32 | ), 33 | fields: Tuple( 34 | [ 35 | TupleField { 36 | attributes: [], 37 | vis_marker: None, 38 | ty: [ 39 | Foo, 40 | ], 41 | }, 42 | TupleField { 43 | attributes: [], 44 | vis_marker: None, 45 | ty: [ 46 | Bar, 47 | ], 48 | }, 49 | ], 50 | ), 51 | value: None, 52 | }, 53 | EnumVariant { 54 | attributes: [], 55 | vis_marker: None, 56 | name: Ident( 57 | C, 58 | ), 59 | fields: Named( 60 | [ 61 | NamedField { 62 | attributes: [], 63 | vis_marker: None, 64 | name: Ident( 65 | foo, 66 | ), 67 | tk_colon: Punct { 68 | char: ':', 69 | spacing: Alone, 70 | }, 71 | ty: [ 72 | Foo, 73 | ], 74 | }, 75 | NamedField { 76 | attributes: [], 77 | vis_marker: None, 78 | name: Ident( 79 | bar, 80 | ), 81 | tk_colon: Punct { 82 | char: ':', 83 | spacing: Alone, 84 | }, 85 | ty: [ 86 | Bar, 87 | ], 88 | }, 89 | ], 90 | ), 91 | value: None, 92 | }, 93 | ], 94 | }, 95 | ) 96 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_enum_attributes.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: enum_type 4 | --- 5 | Enum( 6 | Enum { 7 | attributes: [ 8 | Attribute { 9 | tk_hash: Punct { 10 | char: '#', 11 | spacing: Alone, 12 | }, 13 | tk_brackets: [], 14 | path: [ 15 | hello, 16 | ], 17 | value: Empty, 18 | }, 19 | ], 20 | vis_marker: Some( 21 | pub, 22 | ), 23 | tk_enum: Ident( 24 | enum, 25 | ), 26 | name: Ident( 27 | Hello, 28 | ), 29 | generic_params: None, 30 | where_clauses: None, 31 | variants: [ 32 | EnumVariant { 33 | attributes: [], 34 | vis_marker: None, 35 | name: Ident( 36 | A, 37 | ), 38 | fields: Unit, 39 | value: None, 40 | }, 41 | EnumVariant { 42 | attributes: [], 43 | vis_marker: None, 44 | name: Ident( 45 | B, 46 | ), 47 | fields: Tuple( 48 | [ 49 | TupleField { 50 | attributes: [], 51 | vis_marker: None, 52 | ty: [ 53 | Foo, 54 | ], 55 | }, 56 | TupleField { 57 | attributes: [], 58 | vis_marker: None, 59 | ty: [ 60 | Bar, 61 | ], 62 | }, 63 | ], 64 | ), 65 | value: None, 66 | }, 67 | EnumVariant { 68 | attributes: [], 69 | vis_marker: None, 70 | name: Ident( 71 | C, 72 | ), 73 | fields: Named( 74 | [ 75 | NamedField { 76 | attributes: [], 77 | vis_marker: None, 78 | name: Ident( 79 | foo, 80 | ), 81 | tk_colon: Punct { 82 | char: ':', 83 | spacing: Alone, 84 | }, 85 | ty: [ 86 | Foo, 87 | ], 88 | }, 89 | NamedField { 90 | attributes: [], 91 | vis_marker: None, 92 | name: Ident( 93 | bar, 94 | ), 95 | tk_colon: Punct { 96 | char: ':', 97 | spacing: Alone, 98 | }, 99 | ty: [ 100 | Bar, 101 | ], 102 | }, 103 | ], 104 | ), 105 | value: None, 106 | }, 107 | ], 108 | }, 109 | ) 110 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_enum_empty_generic_params.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: enum_type 4 | --- 5 | Enum( 6 | Enum { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_enum: Ident( 10 | enum, 11 | ), 12 | name: Ident( 13 | Hello, 14 | ), 15 | generic_params: Some( 16 | [], 17 | ), 18 | where_clauses: Some( 19 | [ 20 | [ 21 | A, 22 | "<", 23 | ">", 24 | ":", 25 | B, 26 | "<", 27 | ">", 28 | ], 29 | ], 30 | ), 31 | variants: [ 32 | EnumVariant { 33 | attributes: [], 34 | vis_marker: None, 35 | name: Ident( 36 | A, 37 | ), 38 | fields: Unit, 39 | value: None, 40 | }, 41 | EnumVariant { 42 | attributes: [], 43 | vis_marker: None, 44 | name: Ident( 45 | B, 46 | ), 47 | fields: Tuple( 48 | [ 49 | TupleField { 50 | attributes: [], 51 | vis_marker: None, 52 | ty: [ 53 | Foo, 54 | ], 55 | }, 56 | TupleField { 57 | attributes: [], 58 | vis_marker: None, 59 | ty: [ 60 | Bar, 61 | "<", 62 | ">", 63 | ], 64 | }, 65 | ], 66 | ), 67 | value: None, 68 | }, 69 | EnumVariant { 70 | attributes: [], 71 | vis_marker: None, 72 | name: Ident( 73 | C, 74 | ), 75 | fields: Named( 76 | [ 77 | NamedField { 78 | attributes: [], 79 | vis_marker: None, 80 | name: Ident( 81 | foo, 82 | ), 83 | tk_colon: Punct { 84 | char: ':', 85 | spacing: Alone, 86 | }, 87 | ty: [ 88 | Foo, 89 | "<", 90 | ">", 91 | ], 92 | }, 93 | NamedField { 94 | attributes: [], 95 | vis_marker: None, 96 | name: Ident( 97 | bar, 98 | ), 99 | tk_colon: Punct { 100 | char: ':', 101 | spacing: Alone, 102 | }, 103 | ty: [ 104 | Bar, 105 | ], 106 | }, 107 | ], 108 | ), 109 | value: None, 110 | }, 111 | ], 112 | }, 113 | ) 114 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_enum_empty_where_clause.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: enum_type 4 | --- 5 | Enum( 6 | Enum { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_enum: Ident( 10 | enum, 11 | ), 12 | name: Ident( 13 | Hello, 14 | ), 15 | generic_params: None, 16 | where_clauses: Some( 17 | [], 18 | ), 19 | variants: [ 20 | EnumVariant { 21 | attributes: [], 22 | vis_marker: None, 23 | name: Ident( 24 | A, 25 | ), 26 | fields: Unit, 27 | value: None, 28 | }, 29 | EnumVariant { 30 | attributes: [], 31 | vis_marker: None, 32 | name: Ident( 33 | B, 34 | ), 35 | fields: Tuple( 36 | [ 37 | TupleField { 38 | attributes: [], 39 | vis_marker: None, 40 | ty: [ 41 | Foo, 42 | ], 43 | }, 44 | TupleField { 45 | attributes: [], 46 | vis_marker: None, 47 | ty: [ 48 | Bar, 49 | ], 50 | }, 51 | ], 52 | ), 53 | value: None, 54 | }, 55 | EnumVariant { 56 | attributes: [], 57 | vis_marker: None, 58 | name: Ident( 59 | C, 60 | ), 61 | fields: Named( 62 | [ 63 | NamedField { 64 | attributes: [], 65 | vis_marker: None, 66 | name: Ident( 67 | foo, 68 | ), 69 | tk_colon: Punct { 70 | char: ':', 71 | spacing: Alone, 72 | }, 73 | ty: [ 74 | Foo, 75 | ], 76 | }, 77 | NamedField { 78 | attributes: [], 79 | vis_marker: None, 80 | name: Ident( 81 | bar, 82 | ), 83 | tk_colon: Punct { 84 | char: ':', 85 | spacing: Alone, 86 | }, 87 | ty: [ 88 | Bar, 89 | ], 90 | }, 91 | ], 92 | ), 93 | value: None, 94 | }, 95 | ], 96 | }, 97 | ) 98 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_enum_generic_params.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: enum_type 4 | --- 5 | Enum( 6 | Enum { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_enum: Ident( 10 | enum, 11 | ), 12 | name: Ident( 13 | Hello, 14 | ), 15 | generic_params: Some( 16 | [ 17 | GenericParam { 18 | name: "X", 19 | bound: None, 20 | }, 21 | GenericParam { 22 | name: "Y", 23 | bound: Some( 24 | [ 25 | Z, 26 | "<", 27 | A, 28 | ">", 29 | ], 30 | ), 31 | }, 32 | GenericParam { 33 | name: "Z", 34 | bound: None, 35 | }, 36 | ], 37 | ), 38 | where_clauses: None, 39 | variants: [ 40 | EnumVariant { 41 | attributes: [], 42 | vis_marker: None, 43 | name: Ident( 44 | A, 45 | ), 46 | fields: Unit, 47 | value: None, 48 | }, 49 | EnumVariant { 50 | attributes: [], 51 | vis_marker: None, 52 | name: Ident( 53 | B, 54 | ), 55 | fields: Tuple( 56 | [ 57 | TupleField { 58 | attributes: [], 59 | vis_marker: None, 60 | ty: [ 61 | Foo, 62 | ], 63 | }, 64 | TupleField { 65 | attributes: [], 66 | vis_marker: None, 67 | ty: [ 68 | Bar, 69 | "<", 70 | X, 71 | ",", 72 | Y, 73 | ",", 74 | Z, 75 | ">", 76 | ], 77 | }, 78 | ], 79 | ), 80 | value: None, 81 | }, 82 | EnumVariant { 83 | attributes: [], 84 | vis_marker: None, 85 | name: Ident( 86 | C, 87 | ), 88 | fields: Named( 89 | [ 90 | NamedField { 91 | attributes: [], 92 | vis_marker: None, 93 | name: Ident( 94 | foo, 95 | ), 96 | tk_colon: Punct { 97 | char: ':', 98 | spacing: Alone, 99 | }, 100 | ty: [ 101 | Foo, 102 | "<", 103 | X, 104 | ",", 105 | Y, 106 | ",", 107 | Z, 108 | ">", 109 | ], 110 | }, 111 | NamedField { 112 | attributes: [], 113 | vis_marker: None, 114 | name: Ident( 115 | bar, 116 | ), 117 | tk_colon: Punct { 118 | char: ':', 119 | spacing: Alone, 120 | }, 121 | ty: [ 122 | Bar, 123 | ], 124 | }, 125 | ], 126 | ), 127 | value: None, 128 | }, 129 | ], 130 | }, 131 | ) 132 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_enum_vis-2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: enum_type_pub_crate 4 | --- 5 | Enum( 6 | Enum { 7 | attributes: [], 8 | vis_marker: Some( 9 | pub( 10 | crate, 11 | ), 12 | ), 13 | tk_enum: Ident( 14 | enum, 15 | ), 16 | name: Ident( 17 | Hello, 18 | ), 19 | generic_params: None, 20 | where_clauses: None, 21 | variants: [ 22 | EnumVariant { 23 | attributes: [], 24 | vis_marker: None, 25 | name: Ident( 26 | A, 27 | ), 28 | fields: Unit, 29 | value: None, 30 | }, 31 | EnumVariant { 32 | attributes: [], 33 | vis_marker: None, 34 | name: Ident( 35 | B, 36 | ), 37 | fields: Tuple( 38 | [ 39 | TupleField { 40 | attributes: [], 41 | vis_marker: None, 42 | ty: [ 43 | Foo, 44 | ], 45 | }, 46 | TupleField { 47 | attributes: [], 48 | vis_marker: None, 49 | ty: [ 50 | Bar, 51 | ], 52 | }, 53 | ], 54 | ), 55 | value: None, 56 | }, 57 | EnumVariant { 58 | attributes: [], 59 | vis_marker: None, 60 | name: Ident( 61 | C, 62 | ), 63 | fields: Named( 64 | [ 65 | NamedField { 66 | attributes: [], 67 | vis_marker: None, 68 | name: Ident( 69 | foo, 70 | ), 71 | tk_colon: Punct { 72 | char: ':', 73 | spacing: Alone, 74 | }, 75 | ty: [ 76 | Foo, 77 | ], 78 | }, 79 | NamedField { 80 | attributes: [], 81 | vis_marker: None, 82 | name: Ident( 83 | bar, 84 | ), 85 | tk_colon: Punct { 86 | char: ':', 87 | spacing: Alone, 88 | }, 89 | ty: [ 90 | Bar, 91 | ], 92 | }, 93 | ], 94 | ), 95 | value: None, 96 | }, 97 | ], 98 | }, 99 | ) 100 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_enum_vis-3.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: enum_type_crate 4 | --- 5 | Enum( 6 | Enum { 7 | attributes: [], 8 | vis_marker: Some( 9 | crate, 10 | ), 11 | tk_enum: Ident( 12 | enum, 13 | ), 14 | name: Ident( 15 | Hello, 16 | ), 17 | generic_params: None, 18 | where_clauses: None, 19 | variants: [ 20 | EnumVariant { 21 | attributes: [], 22 | vis_marker: None, 23 | name: Ident( 24 | A, 25 | ), 26 | fields: Unit, 27 | value: None, 28 | }, 29 | EnumVariant { 30 | attributes: [], 31 | vis_marker: None, 32 | name: Ident( 33 | B, 34 | ), 35 | fields: Tuple( 36 | [ 37 | TupleField { 38 | attributes: [], 39 | vis_marker: None, 40 | ty: [ 41 | Foo, 42 | ], 43 | }, 44 | TupleField { 45 | attributes: [], 46 | vis_marker: None, 47 | ty: [ 48 | Bar, 49 | ], 50 | }, 51 | ], 52 | ), 53 | value: None, 54 | }, 55 | EnumVariant { 56 | attributes: [], 57 | vis_marker: None, 58 | name: Ident( 59 | C, 60 | ), 61 | fields: Named( 62 | [ 63 | NamedField { 64 | attributes: [], 65 | vis_marker: None, 66 | name: Ident( 67 | foo, 68 | ), 69 | tk_colon: Punct { 70 | char: ':', 71 | spacing: Alone, 72 | }, 73 | ty: [ 74 | Foo, 75 | ], 76 | }, 77 | NamedField { 78 | attributes: [], 79 | vis_marker: None, 80 | name: Ident( 81 | bar, 82 | ), 83 | tk_colon: Punct { 84 | char: ':', 85 | spacing: Alone, 86 | }, 87 | ty: [ 88 | Bar, 89 | ], 90 | }, 91 | ], 92 | ), 93 | value: None, 94 | }, 95 | ], 96 | }, 97 | ) 98 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_enum_vis.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: enum_type_pub 4 | --- 5 | Enum( 6 | Enum { 7 | attributes: [], 8 | vis_marker: Some( 9 | pub, 10 | ), 11 | tk_enum: Ident( 12 | enum, 13 | ), 14 | name: Ident( 15 | Hello, 16 | ), 17 | generic_params: None, 18 | where_clauses: None, 19 | variants: [ 20 | EnumVariant { 21 | attributes: [], 22 | vis_marker: None, 23 | name: Ident( 24 | A, 25 | ), 26 | fields: Unit, 27 | value: None, 28 | }, 29 | EnumVariant { 30 | attributes: [], 31 | vis_marker: None, 32 | name: Ident( 33 | B, 34 | ), 35 | fields: Tuple( 36 | [ 37 | TupleField { 38 | attributes: [], 39 | vis_marker: None, 40 | ty: [ 41 | Foo, 42 | ], 43 | }, 44 | TupleField { 45 | attributes: [], 46 | vis_marker: None, 47 | ty: [ 48 | Bar, 49 | ], 50 | }, 51 | ], 52 | ), 53 | value: None, 54 | }, 55 | EnumVariant { 56 | attributes: [], 57 | vis_marker: None, 58 | name: Ident( 59 | C, 60 | ), 61 | fields: Named( 62 | [ 63 | NamedField { 64 | attributes: [], 65 | vis_marker: None, 66 | name: Ident( 67 | foo, 68 | ), 69 | tk_colon: Punct { 70 | char: ':', 71 | spacing: Alone, 72 | }, 73 | ty: [ 74 | Foo, 75 | ], 76 | }, 77 | NamedField { 78 | attributes: [], 79 | vis_marker: None, 80 | name: Ident( 81 | bar, 82 | ), 83 | tk_colon: Punct { 84 | char: ':', 85 | spacing: Alone, 86 | }, 87 | ty: [ 88 | Bar, 89 | ], 90 | }, 91 | ], 92 | ), 93 | value: None, 94 | }, 95 | ], 96 | }, 97 | ) 98 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_enum_where_clause.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: enum_type 4 | --- 5 | Enum( 6 | Enum { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_enum: Ident( 10 | enum, 11 | ), 12 | name: Ident( 13 | Hello, 14 | ), 15 | generic_params: None, 16 | where_clauses: Some( 17 | [ 18 | [ 19 | A, 20 | ":", 21 | B, 22 | ], 23 | [ 24 | C, 25 | "<", 26 | D, 27 | ">", 28 | ":", 29 | E, 30 | "<", 31 | F, 32 | ">", 33 | ], 34 | ], 35 | ), 36 | variants: [ 37 | EnumVariant { 38 | attributes: [], 39 | vis_marker: None, 40 | name: Ident( 41 | A, 42 | ), 43 | fields: Unit, 44 | value: None, 45 | }, 46 | EnumVariant { 47 | attributes: [], 48 | vis_marker: None, 49 | name: Ident( 50 | B, 51 | ), 52 | fields: Tuple( 53 | [ 54 | TupleField { 55 | attributes: [], 56 | vis_marker: None, 57 | ty: [ 58 | Foo, 59 | ], 60 | }, 61 | TupleField { 62 | attributes: [], 63 | vis_marker: None, 64 | ty: [ 65 | Bar, 66 | ], 67 | }, 68 | ], 69 | ), 70 | value: None, 71 | }, 72 | EnumVariant { 73 | attributes: [], 74 | vis_marker: None, 75 | name: Ident( 76 | C, 77 | ), 78 | fields: Named( 79 | [ 80 | NamedField { 81 | attributes: [], 82 | vis_marker: None, 83 | name: Ident( 84 | foo, 85 | ), 86 | tk_colon: Punct { 87 | char: ':', 88 | spacing: Alone, 89 | }, 90 | ty: [ 91 | Foo, 92 | ], 93 | }, 94 | NamedField { 95 | attributes: [], 96 | vis_marker: None, 97 | name: Ident( 98 | bar, 99 | ), 100 | tk_colon: Punct { 101 | char: ':', 102 | spacing: Alone, 103 | }, 104 | ty: [ 105 | Bar, 106 | ], 107 | }, 108 | ], 109 | ), 110 | value: None, 111 | }, 112 | ], 113 | }, 114 | ) 115 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_extern_abi_fn.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: func 4 | --- 5 | Function( 6 | Function { 7 | attributes: [], 8 | vis_marker: Some( 9 | pub, 10 | ), 11 | qualifiers: FnQualifiers { 12 | tk_default: None, 13 | tk_const: None, 14 | tk_async: None, 15 | tk_unsafe: None, 16 | tk_extern: Some( 17 | Ident( 18 | extern, 19 | ), 20 | ), 21 | extern_abi: Some( 22 | Literal { 23 | lit: "C", 24 | }, 25 | ), 26 | }, 27 | tk_fn_keyword: Ident( 28 | fn, 29 | ), 30 | name: Ident( 31 | extern_fn, 32 | ), 33 | generic_params: None, 34 | tk_params_parens: (), 35 | params: [ 36 | Typed( 37 | FnTypedParam { 38 | attributes: [], 39 | tk_mut: None, 40 | name: Ident( 41 | b, 42 | ), 43 | tk_colon: Punct { 44 | char: ':', 45 | spacing: Alone, 46 | }, 47 | ty: [ 48 | f32, 49 | ], 50 | }, 51 | ), 52 | ], 53 | where_clause: None, 54 | tk_return_arrow: None, 55 | return_ty: None, 56 | tk_semicolon: None, 57 | body: Some( 58 | Group { 59 | delimiter: Brace, 60 | stream: TokenStream [], 61 | }, 62 | ), 63 | }, 64 | ) 65 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_extern_block-2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: unsafe_extern 4 | --- 5 | ExternBlock( 6 | ExternBlock { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_unsafe: Some( 10 | Ident( 11 | unsafe, 12 | ), 13 | ), 14 | tk_extern: Ident( 15 | extern, 16 | ), 17 | extern_abi: None, 18 | tk_braces: {}, 19 | inner_attributes: [], 20 | body_items: [], 21 | }, 22 | ) 23 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_extern_block.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: filled_extern 4 | --- 5 | ExternBlock( 6 | ExternBlock { 7 | attributes: [ 8 | Attribute { 9 | tk_hash: Punct { 10 | char: '#', 11 | spacing: Alone, 12 | }, 13 | tk_brackets: [], 14 | path: [ 15 | decorated, 16 | ], 17 | value: Empty, 18 | }, 19 | ], 20 | vis_marker: Some( 21 | pub( 22 | crate, 23 | ), 24 | ), 25 | tk_unsafe: None, 26 | tk_extern: Ident( 27 | extern, 28 | ), 29 | extern_abi: Some( 30 | Literal { 31 | lit: "stdcall", 32 | }, 33 | ), 34 | tk_braces: {}, 35 | inner_attributes: [ 36 | Attribute { 37 | tk_hash: Punct { 38 | char: '#', 39 | spacing: Alone, 40 | }, 41 | tk_bang: Punct { 42 | char: '!', 43 | spacing: Alone, 44 | }, 45 | tk_brackets: [], 46 | path: [ 47 | allow, 48 | ], 49 | value: Group( 50 | [ 51 | unused_variables, 52 | ], 53 | (), 54 | ), 55 | }, 56 | ], 57 | body_items: [ 58 | Macro( 59 | Macro { 60 | attributes: [], 61 | name: Ident( 62 | some_macro, 63 | ), 64 | tk_bang: Punct { 65 | char: '!', 66 | spacing: Alone, 67 | }, 68 | tk_declared_name: None, 69 | tk_braces_or_parens: (), 70 | inner_tokens: [], 71 | tk_semicolon: Some( 72 | Punct { 73 | char: ';', 74 | spacing: Alone, 75 | }, 76 | ), 77 | }, 78 | ), 79 | AssocFunction( 80 | Function { 81 | attributes: [], 82 | vis_marker: None, 83 | qualifiers: FnQualifiers { 84 | tk_default: None, 85 | tk_const: None, 86 | tk_async: None, 87 | tk_unsafe: None, 88 | tk_extern: None, 89 | extern_abi: None, 90 | }, 91 | tk_fn_keyword: Ident( 92 | fn, 93 | ), 94 | name: Ident( 95 | c_function, 96 | ), 97 | generic_params: None, 98 | tk_params_parens: (), 99 | params: [], 100 | where_clause: None, 101 | tk_return_arrow: None, 102 | return_ty: None, 103 | tk_semicolon: Some( 104 | Punct { 105 | char: ';', 106 | spacing: Alone, 107 | }, 108 | ), 109 | body: None, 110 | }, 111 | ), 112 | AssocConstant( 113 | Constant { 114 | attributes: [], 115 | vis_marker: None, 116 | tk_const_or_static: Ident( 117 | static, 118 | ), 119 | tk_mut: None, 120 | name: Ident( 121 | S, 122 | ), 123 | tk_colon: Punct { 124 | char: ':', 125 | spacing: Alone, 126 | }, 127 | ty: [ 128 | i32, 129 | ], 130 | tk_equals: None, 131 | initializer: None, 132 | tk_semicolon: Punct { 133 | char: ';', 134 | spacing: Alone, 135 | }, 136 | }, 137 | ), 138 | ], 139 | }, 140 | ) 141 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_extern_crate-2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: as_crate 4 | --- 5 | ExternCrate( 6 | ExternCrate { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_extern: Ident( 10 | extern, 11 | ), 12 | tk_crate: Ident( 13 | crate, 14 | ), 15 | name: Ident( 16 | std, 17 | ), 18 | tk_as: Some( 19 | Ident( 20 | as, 21 | ), 22 | ), 23 | alias: Some( 24 | Ident( 25 | ruststd, 26 | ), 27 | ), 28 | tk_underscore: None, 29 | tk_semicolon: Punct { 30 | char: ';', 31 | spacing: Alone, 32 | }, 33 | }, 34 | ) 35 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_extern_crate-3.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: as_underscore_crate 4 | --- 5 | ExternCrate( 6 | ExternCrate { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_extern: Ident( 10 | extern, 11 | ), 12 | tk_crate: Ident( 13 | crate, 14 | ), 15 | name: Ident( 16 | self, 17 | ), 18 | tk_as: Some( 19 | Ident( 20 | as, 21 | ), 22 | ), 23 | alias: Some( 24 | Ident( 25 | _, 26 | ), 27 | ), 28 | tk_underscore: None, 29 | tk_semicolon: Punct { 30 | char: ';', 31 | spacing: Alone, 32 | }, 33 | }, 34 | ) 35 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_extern_crate.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: simple_crate 4 | --- 5 | ExternCrate( 6 | ExternCrate { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_extern: Ident( 10 | extern, 11 | ), 12 | tk_crate: Ident( 13 | crate, 14 | ), 15 | name: Ident( 16 | std, 17 | ), 18 | tk_as: None, 19 | alias: None, 20 | tk_underscore: None, 21 | tk_semicolon: Punct { 22 | char: ';', 23 | spacing: Alone, 24 | }, 25 | }, 26 | ) 27 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_extern_fn.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: func 4 | --- 5 | Function( 6 | Function { 7 | attributes: [], 8 | vis_marker: Some( 9 | pub, 10 | ), 11 | qualifiers: FnQualifiers { 12 | tk_default: None, 13 | tk_const: None, 14 | tk_async: None, 15 | tk_unsafe: None, 16 | tk_extern: Some( 17 | Ident( 18 | extern, 19 | ), 20 | ), 21 | extern_abi: None, 22 | }, 23 | tk_fn_keyword: Ident( 24 | fn, 25 | ), 26 | name: Ident( 27 | extern_fn, 28 | ), 29 | generic_params: None, 30 | tk_params_parens: (), 31 | params: [ 32 | Typed( 33 | FnTypedParam { 34 | attributes: [], 35 | tk_mut: None, 36 | name: Ident( 37 | b, 38 | ), 39 | tk_colon: Punct { 40 | char: ':', 41 | spacing: Alone, 42 | }, 43 | ty: [ 44 | f32, 45 | ], 46 | }, 47 | ), 48 | ], 49 | where_clause: None, 50 | tk_return_arrow: None, 51 | return_ty: None, 52 | tk_semicolon: None, 53 | body: Some( 54 | Group { 55 | delimiter: Brace, 56 | stream: TokenStream [], 57 | }, 58 | ), 59 | }, 60 | ) 61 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_fn.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: func 4 | --- 5 | Function( 6 | Function { 7 | attributes: [], 8 | vis_marker: None, 9 | qualifiers: FnQualifiers { 10 | tk_default: None, 11 | tk_const: None, 12 | tk_async: None, 13 | tk_unsafe: None, 14 | tk_extern: None, 15 | extern_abi: None, 16 | }, 17 | tk_fn_keyword: Ident( 18 | fn, 19 | ), 20 | name: Ident( 21 | hello, 22 | ), 23 | generic_params: None, 24 | tk_params_parens: (), 25 | params: [ 26 | Typed( 27 | FnTypedParam { 28 | attributes: [], 29 | tk_mut: None, 30 | name: Ident( 31 | a, 32 | ), 33 | tk_colon: Punct { 34 | char: ':', 35 | spacing: Alone, 36 | }, 37 | ty: [ 38 | i32, 39 | ], 40 | }, 41 | ), 42 | Typed( 43 | FnTypedParam { 44 | attributes: [], 45 | tk_mut: None, 46 | name: Ident( 47 | b, 48 | ), 49 | tk_colon: Punct { 50 | char: ':', 51 | spacing: Alone, 52 | }, 53 | ty: [ 54 | f32, 55 | ], 56 | }, 57 | ), 58 | ], 59 | where_clause: None, 60 | tk_return_arrow: Some( 61 | [ 62 | Punct { 63 | char: '-', 64 | spacing: Joint, 65 | }, 66 | Punct { 67 | char: '>', 68 | spacing: Alone, 69 | }, 70 | ], 71 | ), 72 | return_ty: Some( 73 | [ 74 | String, 75 | ], 76 | ), 77 | tk_semicolon: None, 78 | body: Some( 79 | Group { 80 | delimiter: Brace, 81 | stream: TokenStream [], 82 | }, 83 | ), 84 | }, 85 | ) 86 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_fn_body.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: func 4 | --- 5 | Function( 6 | Function { 7 | attributes: [], 8 | vis_marker: None, 9 | qualifiers: FnQualifiers { 10 | tk_default: None, 11 | tk_const: None, 12 | tk_async: None, 13 | tk_unsafe: None, 14 | tk_extern: None, 15 | extern_abi: None, 16 | }, 17 | tk_fn_keyword: Ident( 18 | fn, 19 | ), 20 | name: Ident( 21 | hello_world, 22 | ), 23 | generic_params: None, 24 | tk_params_parens: (), 25 | params: [ 26 | Typed( 27 | FnTypedParam { 28 | attributes: [], 29 | tk_mut: None, 30 | name: Ident( 31 | a, 32 | ), 33 | tk_colon: Punct { 34 | char: ':', 35 | spacing: Alone, 36 | }, 37 | ty: [ 38 | i32, 39 | ], 40 | }, 41 | ), 42 | Typed( 43 | FnTypedParam { 44 | attributes: [], 45 | tk_mut: None, 46 | name: Ident( 47 | b, 48 | ), 49 | tk_colon: Punct { 50 | char: ':', 51 | spacing: Alone, 52 | }, 53 | ty: [ 54 | f32, 55 | ], 56 | }, 57 | ), 58 | ], 59 | where_clause: None, 60 | tk_return_arrow: Some( 61 | [ 62 | Punct { 63 | char: '-', 64 | spacing: Joint, 65 | }, 66 | Punct { 67 | char: '>', 68 | spacing: Alone, 69 | }, 70 | ], 71 | ), 72 | return_ty: Some( 73 | [ 74 | String, 75 | ], 76 | ), 77 | tk_semicolon: None, 78 | body: Some( 79 | Group { 80 | delimiter: Brace, 81 | stream: TokenStream [ 82 | Ident { 83 | sym: println, 84 | }, 85 | Punct { 86 | char: '!', 87 | spacing: Alone, 88 | }, 89 | Group { 90 | delimiter: Parenthesis, 91 | stream: TokenStream [ 92 | Literal { 93 | lit: "hello world", 94 | }, 95 | ], 96 | }, 97 | ], 98 | }, 99 | ), 100 | }, 101 | ) 102 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_fn_lifetimes.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: func 4 | --- 5 | Function( 6 | Function { 7 | attributes: [], 8 | vis_marker: None, 9 | qualifiers: FnQualifiers { 10 | tk_default: None, 11 | tk_const: None, 12 | tk_async: None, 13 | tk_unsafe: None, 14 | tk_extern: None, 15 | extern_abi: None, 16 | }, 17 | tk_fn_keyword: Ident( 18 | fn, 19 | ), 20 | name: Ident( 21 | prototype, 22 | ), 23 | generic_params: Some( 24 | [ 25 | GenericParam { 26 | tk_prefix: "'", 27 | name: "a", 28 | bound: None, 29 | }, 30 | ], 31 | ), 32 | tk_params_parens: (), 33 | params: [ 34 | Typed( 35 | FnTypedParam { 36 | attributes: [], 37 | tk_mut: None, 38 | name: Ident( 39 | a, 40 | ), 41 | tk_colon: Punct { 42 | char: ':', 43 | spacing: Alone, 44 | }, 45 | ty: [ 46 | "&", 47 | "'", 48 | a, 49 | mut, 50 | i32, 51 | ], 52 | }, 53 | ), 54 | ], 55 | where_clause: None, 56 | tk_return_arrow: Some( 57 | [ 58 | Punct { 59 | char: '-', 60 | spacing: Joint, 61 | }, 62 | Punct { 63 | char: '>', 64 | spacing: Alone, 65 | }, 66 | ], 67 | ), 68 | return_ty: Some( 69 | [ 70 | "&", 71 | "'", 72 | a, 73 | String, 74 | ], 75 | ), 76 | tk_semicolon: Some( 77 | Punct { 78 | char: ';', 79 | spacing: Alone, 80 | }, 81 | ), 82 | body: None, 83 | }, 84 | ) 85 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_fn_mut_param.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: func 4 | --- 5 | Function( 6 | Function { 7 | attributes: [], 8 | vis_marker: None, 9 | qualifiers: FnQualifiers { 10 | tk_default: None, 11 | tk_const: None, 12 | tk_async: None, 13 | tk_unsafe: None, 14 | tk_extern: None, 15 | extern_abi: None, 16 | }, 17 | tk_fn_keyword: Ident( 18 | fn, 19 | ), 20 | name: Ident( 21 | prototype, 22 | ), 23 | generic_params: None, 24 | tk_params_parens: (), 25 | params: [ 26 | Typed( 27 | FnTypedParam { 28 | attributes: [], 29 | tk_mut: None, 30 | name: Ident( 31 | a, 32 | ), 33 | tk_colon: Punct { 34 | char: ':', 35 | spacing: Alone, 36 | }, 37 | ty: [ 38 | i32, 39 | ], 40 | }, 41 | ), 42 | Typed( 43 | FnTypedParam { 44 | attributes: [], 45 | tk_mut: Some( 46 | Ident( 47 | mut, 48 | ), 49 | ), 50 | name: Ident( 51 | b, 52 | ), 53 | tk_colon: Punct { 54 | char: ':', 55 | spacing: Alone, 56 | }, 57 | ty: [ 58 | f32, 59 | ], 60 | }, 61 | ), 62 | ], 63 | where_clause: None, 64 | tk_return_arrow: Some( 65 | [ 66 | Punct { 67 | char: '-', 68 | spacing: Joint, 69 | }, 70 | Punct { 71 | char: '>', 72 | spacing: Alone, 73 | }, 74 | ], 75 | ), 76 | return_ty: Some( 77 | [ 78 | String, 79 | ], 80 | ), 81 | tk_semicolon: Some( 82 | Punct { 83 | char: ';', 84 | spacing: Alone, 85 | }, 86 | ), 87 | body: None, 88 | }, 89 | ) 90 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_fn_mut_receiver_lifetime.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: func 4 | --- 5 | Function( 6 | Function { 7 | attributes: [], 8 | vis_marker: None, 9 | qualifiers: FnQualifiers { 10 | tk_default: None, 11 | tk_const: None, 12 | tk_async: None, 13 | tk_unsafe: None, 14 | tk_extern: None, 15 | extern_abi: None, 16 | }, 17 | tk_fn_keyword: Ident( 18 | fn, 19 | ), 20 | name: Ident( 21 | prototype, 22 | ), 23 | generic_params: Some( 24 | [ 25 | GenericParam { 26 | tk_prefix: "'", 27 | name: "a", 28 | bound: None, 29 | }, 30 | ], 31 | ), 32 | tk_params_parens: (), 33 | params: [ 34 | Receiver( 35 | FnReceiverParam { 36 | attributes: [], 37 | tk_ref: Some( 38 | Punct { 39 | char: '&', 40 | spacing: Alone, 41 | }, 42 | ), 43 | lifetime: Some( 44 | Lifetime { 45 | tk_apostrophe: Punct { 46 | char: '\'', 47 | spacing: Joint, 48 | }, 49 | name: Ident( 50 | a, 51 | ), 52 | }, 53 | ), 54 | tk_mut: Some( 55 | Ident( 56 | mut, 57 | ), 58 | ), 59 | tk_self: Ident( 60 | self, 61 | ), 62 | }, 63 | ), 64 | ], 65 | where_clause: None, 66 | tk_return_arrow: None, 67 | return_ty: None, 68 | tk_semicolon: Some( 69 | Punct { 70 | char: ';', 71 | spacing: Alone, 72 | }, 73 | ), 74 | body: None, 75 | }, 76 | ) 77 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_fn_prototype.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: func 4 | --- 5 | Function( 6 | Function { 7 | attributes: [], 8 | vis_marker: None, 9 | qualifiers: FnQualifiers { 10 | tk_default: None, 11 | tk_const: None, 12 | tk_async: None, 13 | tk_unsafe: None, 14 | tk_extern: None, 15 | extern_abi: None, 16 | }, 17 | tk_fn_keyword: Ident( 18 | fn, 19 | ), 20 | name: Ident( 21 | prototype, 22 | ), 23 | generic_params: None, 24 | tk_params_parens: (), 25 | params: [ 26 | Typed( 27 | FnTypedParam { 28 | attributes: [], 29 | tk_mut: None, 30 | name: Ident( 31 | a, 32 | ), 33 | tk_colon: Punct { 34 | char: ':', 35 | spacing: Alone, 36 | }, 37 | ty: [ 38 | i32, 39 | ], 40 | }, 41 | ), 42 | Typed( 43 | FnTypedParam { 44 | attributes: [], 45 | tk_mut: None, 46 | name: Ident( 47 | b, 48 | ), 49 | tk_colon: Punct { 50 | char: ':', 51 | spacing: Alone, 52 | }, 53 | ty: [ 54 | f32, 55 | ], 56 | }, 57 | ), 58 | ], 59 | where_clause: None, 60 | tk_return_arrow: Some( 61 | [ 62 | Punct { 63 | char: '-', 64 | spacing: Joint, 65 | }, 66 | Punct { 67 | char: '>', 68 | spacing: Alone, 69 | }, 70 | ], 71 | ), 72 | return_ty: Some( 73 | [ 74 | String, 75 | ], 76 | ), 77 | tk_semicolon: Some( 78 | Punct { 79 | char: ';', 80 | spacing: Alone, 81 | }, 82 | ), 83 | body: None, 84 | }, 85 | ) 86 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_fn_receiver_lifetime.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: func 4 | --- 5 | Function( 6 | Function { 7 | attributes: [], 8 | vis_marker: None, 9 | qualifiers: FnQualifiers { 10 | tk_default: None, 11 | tk_const: None, 12 | tk_async: None, 13 | tk_unsafe: None, 14 | tk_extern: None, 15 | extern_abi: None, 16 | }, 17 | tk_fn_keyword: Ident( 18 | fn, 19 | ), 20 | name: Ident( 21 | prototype, 22 | ), 23 | generic_params: None, 24 | tk_params_parens: (), 25 | params: [ 26 | Receiver( 27 | FnReceiverParam { 28 | attributes: [], 29 | tk_ref: Some( 30 | Punct { 31 | char: '&', 32 | spacing: Alone, 33 | }, 34 | ), 35 | lifetime: Some( 36 | Lifetime { 37 | tk_apostrophe: Punct { 38 | char: '\'', 39 | spacing: Joint, 40 | }, 41 | name: Ident( 42 | lifetime, 43 | ), 44 | }, 45 | ), 46 | tk_mut: None, 47 | tk_self: Ident( 48 | self, 49 | ), 50 | }, 51 | ), 52 | ], 53 | where_clause: None, 54 | tk_return_arrow: None, 55 | return_ty: None, 56 | tk_semicolon: Some( 57 | Punct { 58 | char: ';', 59 | spacing: Alone, 60 | }, 61 | ), 62 | body: None, 63 | }, 64 | ) 65 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_fn_self_param-2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: func_ref_self 4 | --- 5 | Ok( 6 | Function( 7 | Function { 8 | attributes: [], 9 | vis_marker: None, 10 | qualifiers: FnQualifiers { 11 | tk_default: None, 12 | tk_const: None, 13 | tk_async: None, 14 | tk_unsafe: None, 15 | tk_extern: None, 16 | extern_abi: None, 17 | }, 18 | tk_fn_keyword: Ident( 19 | fn, 20 | ), 21 | name: Ident( 22 | foobar, 23 | ), 24 | generic_params: None, 25 | tk_params_parens: (), 26 | params: [ 27 | Receiver( 28 | FnReceiverParam { 29 | attributes: [], 30 | tk_ref: Some( 31 | Punct { 32 | char: '&', 33 | spacing: Alone, 34 | }, 35 | ), 36 | lifetime: None, 37 | tk_mut: None, 38 | tk_self: Ident( 39 | self, 40 | ), 41 | }, 42 | ), 43 | ], 44 | where_clause: None, 45 | tk_return_arrow: None, 46 | return_ty: None, 47 | tk_semicolon: None, 48 | body: Some( 49 | Group { 50 | delimiter: Brace, 51 | stream: TokenStream [], 52 | }, 53 | ), 54 | }, 55 | ), 56 | ) 57 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_fn_self_param-3.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: func_mut_self 4 | --- 5 | Ok( 6 | Function( 7 | Function { 8 | attributes: [], 9 | vis_marker: None, 10 | qualifiers: FnQualifiers { 11 | tk_default: None, 12 | tk_const: None, 13 | tk_async: None, 14 | tk_unsafe: None, 15 | tk_extern: None, 16 | extern_abi: None, 17 | }, 18 | tk_fn_keyword: Ident( 19 | fn, 20 | ), 21 | name: Ident( 22 | foobar, 23 | ), 24 | generic_params: None, 25 | tk_params_parens: (), 26 | params: [ 27 | Receiver( 28 | FnReceiverParam { 29 | attributes: [], 30 | tk_ref: None, 31 | lifetime: None, 32 | tk_mut: Some( 33 | Ident( 34 | mut, 35 | ), 36 | ), 37 | tk_self: Ident( 38 | self, 39 | ), 40 | }, 41 | ), 42 | ], 43 | where_clause: None, 44 | tk_return_arrow: None, 45 | return_ty: None, 46 | tk_semicolon: None, 47 | body: Some( 48 | Group { 49 | delimiter: Brace, 50 | stream: TokenStream [], 51 | }, 52 | ), 53 | }, 54 | ), 55 | ) 56 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_fn_self_param-4.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: func_ref_mut_self 4 | --- 5 | Ok( 6 | Function( 7 | Function { 8 | attributes: [], 9 | vis_marker: None, 10 | qualifiers: FnQualifiers { 11 | tk_default: None, 12 | tk_const: None, 13 | tk_async: None, 14 | tk_unsafe: None, 15 | tk_extern: None, 16 | extern_abi: None, 17 | }, 18 | tk_fn_keyword: Ident( 19 | fn, 20 | ), 21 | name: Ident( 22 | foobar, 23 | ), 24 | generic_params: None, 25 | tk_params_parens: (), 26 | params: [ 27 | Receiver( 28 | FnReceiverParam { 29 | attributes: [], 30 | tk_ref: Some( 31 | Punct { 32 | char: '&', 33 | spacing: Alone, 34 | }, 35 | ), 36 | lifetime: None, 37 | tk_mut: Some( 38 | Ident( 39 | mut, 40 | ), 41 | ), 42 | tk_self: Ident( 43 | self, 44 | ), 45 | }, 46 | ), 47 | ], 48 | where_clause: None, 49 | tk_return_arrow: None, 50 | return_ty: None, 51 | tk_semicolon: None, 52 | body: Some( 53 | Group { 54 | delimiter: Brace, 55 | stream: TokenStream [], 56 | }, 57 | ), 58 | }, 59 | ), 60 | ) 61 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_fn_self_param.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: func_self 4 | --- 5 | Ok( 6 | Function( 7 | Function { 8 | attributes: [], 9 | vis_marker: None, 10 | qualifiers: FnQualifiers { 11 | tk_default: None, 12 | tk_const: None, 13 | tk_async: None, 14 | tk_unsafe: None, 15 | tk_extern: None, 16 | extern_abi: None, 17 | }, 18 | tk_fn_keyword: Ident( 19 | fn, 20 | ), 21 | name: Ident( 22 | foobar, 23 | ), 24 | generic_params: None, 25 | tk_params_parens: (), 26 | params: [ 27 | Receiver( 28 | FnReceiverParam { 29 | attributes: [], 30 | tk_ref: None, 31 | lifetime: None, 32 | tk_mut: None, 33 | tk_self: Ident( 34 | self, 35 | ), 36 | }, 37 | ), 38 | ], 39 | where_clause: None, 40 | tk_return_arrow: None, 41 | return_ty: None, 42 | tk_semicolon: None, 43 | body: Some( 44 | Group { 45 | delimiter: Brace, 46 | stream: TokenStream [], 47 | }, 48 | ), 49 | }, 50 | ), 51 | ) 52 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_fn_traits.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_struct: Ident( 10 | struct, 11 | ), 12 | name: Ident( 13 | Hello, 14 | ), 15 | generic_params: None, 16 | where_clause: None, 17 | fields: Tuple( 18 | [ 19 | TupleField { 20 | attributes: [], 21 | vis_marker: None, 22 | ty: [ 23 | fn, 24 | Group { 25 | delimiter: Parenthesis, 26 | stream: TokenStream [ 27 | Ident { 28 | sym: A, 29 | }, 30 | Punct { 31 | char: ',', 32 | spacing: Alone, 33 | }, 34 | Ident { 35 | sym: B, 36 | }, 37 | ], 38 | }, 39 | "-", 40 | ">", 41 | C, 42 | ], 43 | }, 44 | TupleField { 45 | attributes: [], 46 | vis_marker: None, 47 | ty: [ 48 | A, 49 | "<", 50 | FnOnce, 51 | Group { 52 | delimiter: Parenthesis, 53 | stream: TokenStream [ 54 | Ident { 55 | sym: A, 56 | }, 57 | Punct { 58 | char: ',', 59 | spacing: Alone, 60 | }, 61 | Ident { 62 | sym: B, 63 | }, 64 | Punct { 65 | char: ',', 66 | spacing: Alone, 67 | }, 68 | Ident { 69 | sym: C, 70 | }, 71 | Punct { 72 | char: '<', 73 | spacing: Alone, 74 | }, 75 | Ident { 76 | sym: D, 77 | }, 78 | Punct { 79 | char: '>', 80 | spacing: Alone, 81 | }, 82 | ], 83 | }, 84 | "-", 85 | ">", 86 | E, 87 | ",", 88 | ], 89 | }, 90 | ], 91 | ), 92 | tk_semicolon: Some( 93 | Punct { 94 | char: ';', 95 | spacing: Alone, 96 | }, 97 | ), 98 | }, 99 | ) 100 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_generic_args.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: generic_args 4 | --- 5 | GenericArgList { 6 | args: [ 7 | Lifetime { 8 | lifetime: Lifetime { 9 | tk_apostrophe: Punct { 10 | char: '\'', 11 | spacing: Joint, 12 | }, 13 | name: Ident( 14 | a, 15 | ), 16 | }, 17 | }, 18 | TypeOrConst { 19 | expr: [ 20 | path, 21 | ":", 22 | ":", 23 | to, 24 | ":", 25 | ":", 26 | Type, 27 | ], 28 | }, 29 | TypeOrConst { 30 | expr: [ 31 | 15, 32 | ], 33 | }, 34 | Binding { 35 | ident: Ident( 36 | Item, 37 | ), 38 | tk_equals: Punct { 39 | char: '=', 40 | spacing: Alone, 41 | }, 42 | ty: [ 43 | i32, 44 | ], 45 | }, 46 | TypeOrConst { 47 | expr: [ 48 | module, 49 | ":", 50 | ":", 51 | NestedType, 52 | "<", 53 | another, 54 | ":", 55 | ":", 56 | Type, 57 | ">", 58 | ], 59 | }, 60 | ], 61 | } 62 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_generic_args_turbofish.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: generic_args 4 | --- 5 | GenericArgList { 6 | tk_turbofish_colons: "::", 7 | args: [], 8 | } 9 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_generic_fn.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: func 4 | --- 5 | Function( 6 | Function { 7 | attributes: [], 8 | vis_marker: None, 9 | qualifiers: FnQualifiers { 10 | tk_default: None, 11 | tk_const: None, 12 | tk_async: None, 13 | tk_unsafe: None, 14 | tk_extern: None, 15 | extern_abi: None, 16 | }, 17 | tk_fn_keyword: Ident( 18 | fn, 19 | ), 20 | name: Ident( 21 | generic, 22 | ), 23 | generic_params: Some( 24 | [ 25 | GenericParam { 26 | name: "T", 27 | bound: None, 28 | }, 29 | GenericParam { 30 | name: "B", 31 | bound: None, 32 | }, 33 | ], 34 | ), 35 | tk_params_parens: (), 36 | params: [ 37 | Typed( 38 | FnTypedParam { 39 | attributes: [], 40 | tk_mut: None, 41 | name: Ident( 42 | a, 43 | ), 44 | tk_colon: Punct { 45 | char: ':', 46 | spacing: Alone, 47 | }, 48 | ty: [ 49 | T, 50 | ], 51 | }, 52 | ), 53 | ], 54 | where_clause: None, 55 | tk_return_arrow: Some( 56 | [ 57 | Punct { 58 | char: '-', 59 | spacing: Joint, 60 | }, 61 | Punct { 62 | char: '>', 63 | spacing: Alone, 64 | }, 65 | ], 66 | ), 67 | return_ty: Some( 68 | [ 69 | B, 70 | ], 71 | ), 72 | tk_semicolon: None, 73 | body: Some( 74 | Group { 75 | delimiter: Brace, 76 | stream: TokenStream [], 77 | }, 78 | ), 79 | }, 80 | ) 81 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_impl_inherent_generic.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: impl_decl 4 | --- 5 | Impl( 6 | Impl { 7 | attributes: [], 8 | tk_unsafe: None, 9 | tk_impl: Ident( 10 | impl, 11 | ), 12 | impl_generic_params: Some( 13 | [ 14 | GenericParam { 15 | tk_prefix: "'", 16 | name: "a", 17 | bound: None, 18 | }, 19 | GenericParam { 20 | name: "T", 21 | bound: Some( 22 | [ 23 | Clone, 24 | ], 25 | ), 26 | }, 27 | GenericParam { 28 | tk_prefix: "const", 29 | name: "N", 30 | bound: Some( 31 | [ 32 | i8, 33 | ], 34 | ), 35 | }, 36 | ], 37 | ), 38 | trait_ty: None, 39 | tk_for: None, 40 | self_ty: [ 41 | structs, 42 | ":", 43 | ":", 44 | MyStruct, 45 | "<", 46 | "'", 47 | a, 48 | ",", 49 | T, 50 | ",", 51 | N, 52 | ">", 53 | ], 54 | where_clause: None, 55 | tk_braces: {}, 56 | inner_attributes: [], 57 | body_items: [], 58 | }, 59 | ) 60 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_impl_trait_generic.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: impl_decl 4 | --- 5 | Impl( 6 | Impl { 7 | attributes: [], 8 | tk_unsafe: Some( 9 | Ident( 10 | unsafe, 11 | ), 12 | ), 13 | tk_impl: Ident( 14 | impl, 15 | ), 16 | impl_generic_params: Some( 17 | [ 18 | GenericParam { 19 | tk_prefix: "'", 20 | name: "a", 21 | bound: None, 22 | }, 23 | GenericParam { 24 | name: "T", 25 | bound: None, 26 | }, 27 | GenericParam { 28 | tk_prefix: "const", 29 | name: "N", 30 | bound: Some( 31 | [ 32 | i8, 33 | ], 34 | ), 35 | }, 36 | ], 37 | ), 38 | trait_ty: Some( 39 | [ 40 | traits, 41 | ":", 42 | ":", 43 | MyTrait, 44 | "<", 45 | T, 46 | ",", 47 | N, 48 | ">", 49 | ], 50 | ), 51 | tk_for: Some( 52 | Ident( 53 | for, 54 | ), 55 | ), 56 | self_ty: [ 57 | structs, 58 | ":", 59 | ":", 60 | MyStruct, 61 | "<", 62 | "'", 63 | a, 64 | ",", 65 | T, 66 | ">", 67 | ], 68 | where_clause: Some( 69 | [ 70 | [ 71 | T, 72 | ":", 73 | Clone, 74 | ], 75 | ], 76 | ), 77 | tk_braces: {}, 78 | inner_attributes: [], 79 | body_items: [ 80 | AssocConstant( 81 | Constant { 82 | attributes: [ 83 | Attribute { 84 | tk_hash: Punct { 85 | char: '#', 86 | spacing: Alone, 87 | }, 88 | tk_brackets: [], 89 | path: [ 90 | attr, 91 | ], 92 | value: Empty, 93 | }, 94 | ], 95 | vis_marker: Some( 96 | pub( 97 | crate, 98 | ), 99 | ), 100 | tk_const_or_static: Ident( 101 | const, 102 | ), 103 | tk_mut: None, 104 | name: Ident( 105 | CONSTANT, 106 | ), 107 | tk_colon: Punct { 108 | char: ':', 109 | spacing: Alone, 110 | }, 111 | ty: [ 112 | i8, 113 | ], 114 | tk_equals: Some( 115 | Punct { 116 | char: '=', 117 | spacing: Alone, 118 | }, 119 | ), 120 | initializer: Some( 121 | [ 122 | N, 123 | ], 124 | ), 125 | tk_semicolon: Punct { 126 | char: ';', 127 | spacing: Alone, 128 | }, 129 | }, 130 | ), 131 | ], 132 | }, 133 | ) 134 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_inline_generic_args-2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: owned_args 4 | --- 5 | GenericArgList { 6 | args: [ 7 | Lifetime { 8 | lifetime: Lifetime { 9 | tk_apostrophe: Punct { 10 | char: '\'', 11 | spacing: Joint, 12 | }, 13 | name: Ident( 14 | a, 15 | ), 16 | }, 17 | }, 18 | TypeOrConst { 19 | expr: [ 20 | T, 21 | ], 22 | }, 23 | TypeOrConst { 24 | expr: [ 25 | U, 26 | ], 27 | }, 28 | TypeOrConst { 29 | expr: [ 30 | N, 31 | ], 32 | }, 33 | ], 34 | } 35 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_inline_generic_args.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: params 4 | --- 5 | [ 6 | GenericParam { 7 | tk_prefix: "'", 8 | name: "a", 9 | bound: Some( 10 | [ 11 | "'", 12 | static, 13 | ], 14 | ), 15 | }, 16 | GenericParam { 17 | name: "T", 18 | bound: None, 19 | }, 20 | GenericParam { 21 | name: "U", 22 | bound: Some( 23 | [ 24 | Clone, 25 | ], 26 | ), 27 | }, 28 | GenericParam { 29 | tk_prefix: "const", 30 | name: "N", 31 | bound: Some( 32 | [ 33 | usize, 34 | ], 35 | ), 36 | }, 37 | ] 38 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_multiple_brackets.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_struct: Ident( 10 | struct, 11 | ), 12 | name: Ident( 13 | Hello, 14 | ), 15 | generic_params: None, 16 | where_clause: None, 17 | fields: Tuple( 18 | [ 19 | TupleField { 20 | attributes: [], 21 | vis_marker: None, 22 | ty: [ 23 | A, 24 | "<", 25 | B, 26 | "<", 27 | C, 28 | ">", 29 | ">", 30 | ], 31 | }, 32 | TupleField { 33 | attributes: [], 34 | vis_marker: None, 35 | ty: [ 36 | A, 37 | "<", 38 | B, 39 | "<", 40 | C, 41 | ",", 42 | D, 43 | ">", 44 | ">", 45 | ], 46 | }, 47 | TupleField { 48 | attributes: [], 49 | vis_marker: None, 50 | ty: [ 51 | "<", 52 | "<", 53 | D, 54 | as, 55 | Trait, 56 | ">", 57 | ":", 58 | ":", 59 | X, 60 | as, 61 | Trait, 62 | ">", 63 | ":", 64 | ":", 65 | Y, 66 | ], 67 | }, 68 | ], 69 | ), 70 | tk_semicolon: Some( 71 | Punct { 72 | char: ';', 73 | spacing: Alone, 74 | }, 75 | ), 76 | }, 77 | ) 78 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_normal_struct.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_struct: Ident( 10 | struct, 11 | ), 12 | name: Ident( 13 | Hello, 14 | ), 15 | generic_params: None, 16 | where_clause: None, 17 | fields: Named( 18 | [ 19 | NamedField { 20 | attributes: [], 21 | vis_marker: None, 22 | name: Ident( 23 | a, 24 | ), 25 | tk_colon: Punct { 26 | char: ':', 27 | spacing: Alone, 28 | }, 29 | ty: [ 30 | A, 31 | ], 32 | }, 33 | NamedField { 34 | attributes: [], 35 | vis_marker: None, 36 | name: Ident( 37 | b, 38 | ), 39 | tk_colon: Punct { 40 | char: ':', 41 | spacing: Alone, 42 | }, 43 | ty: [ 44 | B, 45 | ], 46 | }, 47 | ], 48 | ), 49 | tk_semicolon: None, 50 | }, 51 | ) 52 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_normal_struct_attributes.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [ 8 | Attribute { 9 | tk_hash: Punct { 10 | char: '#', 11 | spacing: Alone, 12 | }, 13 | tk_brackets: [], 14 | path: [ 15 | hello, 16 | ], 17 | value: Empty, 18 | }, 19 | ], 20 | vis_marker: Some( 21 | pub, 22 | ), 23 | tk_struct: Ident( 24 | struct, 25 | ), 26 | name: Ident( 27 | Hello, 28 | ), 29 | generic_params: None, 30 | where_clause: None, 31 | fields: Named( 32 | [ 33 | NamedField { 34 | attributes: [], 35 | vis_marker: None, 36 | name: Ident( 37 | a, 38 | ), 39 | tk_colon: Punct { 40 | char: ':', 41 | spacing: Alone, 42 | }, 43 | ty: [ 44 | A, 45 | ], 46 | }, 47 | NamedField { 48 | attributes: [], 49 | vis_marker: None, 50 | name: Ident( 51 | b, 52 | ), 53 | tk_colon: Punct { 54 | char: ':', 55 | spacing: Alone, 56 | }, 57 | ty: [ 58 | B, 59 | ], 60 | }, 61 | ], 62 | ), 63 | tk_semicolon: None, 64 | }, 65 | ) 66 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_normal_struct_empty_where_clause.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_struct: Ident( 10 | struct, 11 | ), 12 | name: Ident( 13 | Hello, 14 | ), 15 | generic_params: None, 16 | where_clause: Some( 17 | [], 18 | ), 19 | fields: Named( 20 | [ 21 | NamedField { 22 | attributes: [], 23 | vis_marker: None, 24 | name: Ident( 25 | a, 26 | ), 27 | tk_colon: Punct { 28 | char: ':', 29 | spacing: Alone, 30 | }, 31 | ty: [ 32 | A, 33 | ], 34 | }, 35 | NamedField { 36 | attributes: [], 37 | vis_marker: None, 38 | name: Ident( 39 | b, 40 | ), 41 | tk_colon: Punct { 42 | char: ':', 43 | spacing: Alone, 44 | }, 45 | ty: [ 46 | B, 47 | ], 48 | }, 49 | ], 50 | ), 51 | tk_semicolon: None, 52 | }, 53 | ) 54 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_normal_struct_generic_params.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_struct: Ident( 10 | struct, 11 | ), 12 | name: Ident( 13 | Hello, 14 | ), 15 | generic_params: Some( 16 | [ 17 | GenericParam { 18 | name: "X", 19 | bound: None, 20 | }, 21 | GenericParam { 22 | name: "Y", 23 | bound: Some( 24 | [ 25 | Z, 26 | "<", 27 | A, 28 | ">", 29 | ], 30 | ), 31 | }, 32 | GenericParam { 33 | name: "Z", 34 | bound: None, 35 | }, 36 | ], 37 | ), 38 | where_clause: None, 39 | fields: Named( 40 | [ 41 | NamedField { 42 | attributes: [], 43 | vis_marker: None, 44 | name: Ident( 45 | a, 46 | ), 47 | tk_colon: Punct { 48 | char: ':', 49 | spacing: Alone, 50 | }, 51 | ty: [ 52 | A, 53 | ], 54 | }, 55 | NamedField { 56 | attributes: [], 57 | vis_marker: None, 58 | name: Ident( 59 | b, 60 | ), 61 | tk_colon: Punct { 62 | char: ':', 63 | spacing: Alone, 64 | }, 65 | ty: [ 66 | B, 67 | "<", 68 | X, 69 | ",", 70 | Y, 71 | ",", 72 | Z, 73 | ">", 74 | ], 75 | }, 76 | ], 77 | ), 78 | tk_semicolon: None, 79 | }, 80 | ) 81 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_normal_struct_vis-2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type_pub_crate 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: Some( 9 | pub( 10 | crate, 11 | ), 12 | ), 13 | tk_struct: Ident( 14 | struct, 15 | ), 16 | name: Ident( 17 | Hello, 18 | ), 19 | generic_params: None, 20 | where_clause: None, 21 | fields: Named( 22 | [ 23 | NamedField { 24 | attributes: [], 25 | vis_marker: None, 26 | name: Ident( 27 | a, 28 | ), 29 | tk_colon: Punct { 30 | char: ':', 31 | spacing: Alone, 32 | }, 33 | ty: [ 34 | A, 35 | ], 36 | }, 37 | NamedField { 38 | attributes: [], 39 | vis_marker: None, 40 | name: Ident( 41 | b, 42 | ), 43 | tk_colon: Punct { 44 | char: ':', 45 | spacing: Alone, 46 | }, 47 | ty: [ 48 | B, 49 | ], 50 | }, 51 | ], 52 | ), 53 | tk_semicolon: None, 54 | }, 55 | ) 56 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_normal_struct_vis-3.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type_crate 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: Some( 9 | crate, 10 | ), 11 | tk_struct: Ident( 12 | struct, 13 | ), 14 | name: Ident( 15 | Hello, 16 | ), 17 | generic_params: None, 18 | where_clause: None, 19 | fields: Named( 20 | [ 21 | NamedField { 22 | attributes: [], 23 | vis_marker: None, 24 | name: Ident( 25 | a, 26 | ), 27 | tk_colon: Punct { 28 | char: ':', 29 | spacing: Alone, 30 | }, 31 | ty: [ 32 | A, 33 | ], 34 | }, 35 | NamedField { 36 | attributes: [], 37 | vis_marker: None, 38 | name: Ident( 39 | b, 40 | ), 41 | tk_colon: Punct { 42 | char: ':', 43 | spacing: Alone, 44 | }, 45 | ty: [ 46 | B, 47 | ], 48 | }, 49 | ], 50 | ), 51 | tk_semicolon: None, 52 | }, 53 | ) 54 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_normal_struct_vis.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type_pub 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: Some( 9 | pub, 10 | ), 11 | tk_struct: Ident( 12 | struct, 13 | ), 14 | name: Ident( 15 | Hello, 16 | ), 17 | generic_params: None, 18 | where_clause: None, 19 | fields: Named( 20 | [ 21 | NamedField { 22 | attributes: [], 23 | vis_marker: None, 24 | name: Ident( 25 | a, 26 | ), 27 | tk_colon: Punct { 28 | char: ':', 29 | spacing: Alone, 30 | }, 31 | ty: [ 32 | A, 33 | ], 34 | }, 35 | NamedField { 36 | attributes: [], 37 | vis_marker: None, 38 | name: Ident( 39 | b, 40 | ), 41 | tk_colon: Punct { 42 | char: ':', 43 | spacing: Alone, 44 | }, 45 | ty: [ 46 | B, 47 | ], 48 | }, 49 | ], 50 | ), 51 | tk_semicolon: None, 52 | }, 53 | ) 54 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_normal_struct_where_clause.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_struct: Ident( 10 | struct, 11 | ), 12 | name: Ident( 13 | Hello, 14 | ), 15 | generic_params: None, 16 | where_clause: Some( 17 | [ 18 | [ 19 | A, 20 | ":", 21 | B, 22 | ], 23 | [ 24 | C, 25 | "<", 26 | D, 27 | ">", 28 | ":", 29 | E, 30 | "<", 31 | F, 32 | ">", 33 | ], 34 | ], 35 | ), 36 | fields: Named( 37 | [ 38 | NamedField { 39 | attributes: [], 40 | vis_marker: None, 41 | name: Ident( 42 | a, 43 | ), 44 | tk_colon: Punct { 45 | char: ':', 46 | spacing: Alone, 47 | }, 48 | ty: [ 49 | A, 50 | ], 51 | }, 52 | NamedField { 53 | attributes: [], 54 | vis_marker: None, 55 | name: Ident( 56 | b, 57 | ), 58 | tk_colon: Punct { 59 | char: ':', 60 | spacing: Alone, 61 | }, 62 | ty: [ 63 | B, 64 | ], 65 | }, 66 | ], 67 | ), 68 | tk_semicolon: None, 69 | }, 70 | ) 71 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_param_attr_fn.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: func 4 | --- 5 | Function( 6 | Function { 7 | attributes: [], 8 | vis_marker: Some( 9 | pub, 10 | ), 11 | qualifiers: FnQualifiers { 12 | tk_default: None, 13 | tk_const: None, 14 | tk_async: Some( 15 | Ident( 16 | async, 17 | ), 18 | ), 19 | tk_unsafe: None, 20 | tk_extern: None, 21 | extern_abi: None, 22 | }, 23 | tk_fn_keyword: Ident( 24 | fn, 25 | ), 26 | name: Ident( 27 | visibility, 28 | ), 29 | generic_params: None, 30 | tk_params_parens: (), 31 | params: [ 32 | Typed( 33 | FnTypedParam { 34 | attributes: [ 35 | Attribute { 36 | tk_hash: Punct { 37 | char: '#', 38 | spacing: Alone, 39 | }, 40 | tk_brackets: [], 41 | path: [ 42 | my_attr, 43 | ], 44 | value: Empty, 45 | }, 46 | ], 47 | tk_mut: None, 48 | name: Ident( 49 | b, 50 | ), 51 | tk_colon: Punct { 52 | char: ':', 53 | spacing: Alone, 54 | }, 55 | ty: [ 56 | f32, 57 | ], 58 | }, 59 | ), 60 | ], 61 | where_clause: None, 62 | tk_return_arrow: None, 63 | return_ty: None, 64 | tk_semicolon: None, 65 | body: Some( 66 | Group { 67 | delimiter: Brace, 68 | stream: TokenStream [], 69 | }, 70 | ), 71 | }, 72 | ) 73 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_struct_fields_attributes.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: Some( 9 | pub, 10 | ), 11 | tk_struct: Ident( 12 | struct, 13 | ), 14 | name: Ident( 15 | Hello, 16 | ), 17 | generic_params: None, 18 | where_clause: None, 19 | fields: Named( 20 | [ 21 | NamedField { 22 | attributes: [ 23 | Attribute { 24 | tk_hash: Punct { 25 | char: '#', 26 | spacing: Alone, 27 | }, 28 | tk_brackets: [], 29 | path: [ 30 | hello, 31 | ], 32 | value: Empty, 33 | }, 34 | ], 35 | vis_marker: None, 36 | name: Ident( 37 | a, 38 | ), 39 | tk_colon: Punct { 40 | char: ':', 41 | spacing: Alone, 42 | }, 43 | ty: [ 44 | A, 45 | ], 46 | }, 47 | NamedField { 48 | attributes: [], 49 | vis_marker: None, 50 | name: Ident( 51 | b, 52 | ), 53 | tk_colon: Punct { 54 | char: ':', 55 | spacing: Alone, 56 | }, 57 | ty: [ 58 | B, 59 | ], 60 | }, 61 | NamedField { 62 | attributes: [ 63 | Attribute { 64 | tk_hash: Punct { 65 | char: '#', 66 | spacing: Alone, 67 | }, 68 | tk_brackets: [], 69 | path: [ 70 | hello, 71 | ], 72 | value: Empty, 73 | }, 74 | Attribute { 75 | tk_hash: Punct { 76 | char: '#', 77 | spacing: Alone, 78 | }, 79 | tk_brackets: [], 80 | path: [ 81 | hello, 82 | ], 83 | value: Empty, 84 | }, 85 | Attribute { 86 | tk_hash: Punct { 87 | char: '#', 88 | spacing: Alone, 89 | }, 90 | tk_brackets: [], 91 | path: [ 92 | hello, 93 | ], 94 | value: Empty, 95 | }, 96 | ], 97 | vis_marker: None, 98 | name: Ident( 99 | c, 100 | ), 101 | tk_colon: Punct { 102 | char: ':', 103 | spacing: Alone, 104 | }, 105 | ty: [ 106 | C, 107 | ], 108 | }, 109 | NamedField { 110 | attributes: [], 111 | vis_marker: None, 112 | name: Ident( 113 | d, 114 | ), 115 | tk_colon: Punct { 116 | char: ':', 117 | spacing: Alone, 118 | }, 119 | ty: [ 120 | D, 121 | ], 122 | }, 123 | ], 124 | ), 125 | tk_semicolon: None, 126 | }, 127 | ) 128 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_struct_fields_vis.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: Some( 9 | pub, 10 | ), 11 | tk_struct: Ident( 12 | struct, 13 | ), 14 | name: Ident( 15 | Hello, 16 | ), 17 | generic_params: None, 18 | where_clause: None, 19 | fields: Named( 20 | [ 21 | NamedField { 22 | attributes: [], 23 | vis_marker: Some( 24 | pub, 25 | ), 26 | name: Ident( 27 | a, 28 | ), 29 | tk_colon: Punct { 30 | char: ':', 31 | spacing: Alone, 32 | }, 33 | ty: [ 34 | A, 35 | ], 36 | }, 37 | NamedField { 38 | attributes: [], 39 | vis_marker: Some( 40 | pub( 41 | super, 42 | ), 43 | ), 44 | name: Ident( 45 | b, 46 | ), 47 | tk_colon: Punct { 48 | char: ':', 49 | spacing: Alone, 50 | }, 51 | ty: [ 52 | B, 53 | ], 54 | }, 55 | NamedField { 56 | attributes: [], 57 | vis_marker: Some( 58 | crate, 59 | ), 60 | name: Ident( 61 | c, 62 | ), 63 | tk_colon: Punct { 64 | char: ':', 65 | spacing: Alone, 66 | }, 67 | ty: [ 68 | C, 69 | ], 70 | }, 71 | NamedField { 72 | attributes: [], 73 | vis_marker: None, 74 | name: Ident( 75 | d, 76 | ), 77 | tk_colon: Punct { 78 | char: ':', 79 | spacing: Alone, 80 | }, 81 | ty: [ 82 | D, 83 | ], 84 | }, 85 | ], 86 | ), 87 | tk_semicolon: None, 88 | }, 89 | ) 90 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_trait_decorated.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: trait_decl 4 | --- 5 | Trait( 6 | Trait { 7 | attributes: [ 8 | Attribute { 9 | tk_hash: Punct { 10 | char: '#', 11 | spacing: Alone, 12 | }, 13 | tk_brackets: [], 14 | path: [ 15 | fancy, 16 | ":", 17 | ":", 18 | api, 19 | ], 20 | value: Empty, 21 | }, 22 | ], 23 | vis_marker: Some( 24 | pub( 25 | super, 26 | ), 27 | ), 28 | tk_unsafe: Some( 29 | Ident( 30 | unsafe, 31 | ), 32 | ), 33 | tk_trait: Ident( 34 | trait, 35 | ), 36 | name: Ident( 37 | MyTrait, 38 | ), 39 | generic_params: Some( 40 | [ 41 | GenericParam { 42 | tk_prefix: "'", 43 | name: "p", 44 | bound: None, 45 | }, 46 | GenericParam { 47 | name: "U", 48 | bound: None, 49 | }, 50 | GenericParam { 51 | tk_prefix: "const", 52 | name: "N", 53 | bound: None, 54 | }, 55 | ], 56 | ), 57 | bound: Some( 58 | [ 59 | Supertrait, 60 | ], 61 | ), 62 | where_clause: Some( 63 | [ 64 | [ 65 | Self, 66 | ":", 67 | Sized, 68 | ], 69 | ], 70 | ), 71 | tk_braces: {}, 72 | inner_attributes: [], 73 | body_items: [], 74 | }, 75 | ) 76 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_tuple_fields_attributes.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: Some( 9 | pub, 10 | ), 11 | tk_struct: Ident( 12 | struct, 13 | ), 14 | name: Ident( 15 | Hello, 16 | ), 17 | generic_params: None, 18 | where_clause: None, 19 | fields: Tuple( 20 | [ 21 | TupleField { 22 | attributes: [ 23 | Attribute { 24 | tk_hash: Punct { 25 | char: '#', 26 | spacing: Alone, 27 | }, 28 | tk_brackets: [], 29 | path: [ 30 | hello, 31 | ], 32 | value: Empty, 33 | }, 34 | ], 35 | vis_marker: None, 36 | ty: [ 37 | A, 38 | ], 39 | }, 40 | TupleField { 41 | attributes: [], 42 | vis_marker: None, 43 | ty: [ 44 | B, 45 | ], 46 | }, 47 | TupleField { 48 | attributes: [ 49 | Attribute { 50 | tk_hash: Punct { 51 | char: '#', 52 | spacing: Alone, 53 | }, 54 | tk_brackets: [], 55 | path: [ 56 | hello, 57 | ], 58 | value: Empty, 59 | }, 60 | Attribute { 61 | tk_hash: Punct { 62 | char: '#', 63 | spacing: Alone, 64 | }, 65 | tk_brackets: [], 66 | path: [ 67 | hello, 68 | ], 69 | value: Empty, 70 | }, 71 | Attribute { 72 | tk_hash: Punct { 73 | char: '#', 74 | spacing: Alone, 75 | }, 76 | tk_brackets: [], 77 | path: [ 78 | hello, 79 | ], 80 | value: Empty, 81 | }, 82 | ], 83 | vis_marker: None, 84 | ty: [ 85 | C, 86 | ], 87 | }, 88 | TupleField { 89 | attributes: [], 90 | vis_marker: None, 91 | ty: [ 92 | D, 93 | ], 94 | }, 95 | ], 96 | ), 97 | tk_semicolon: Some( 98 | Punct { 99 | char: ';', 100 | spacing: Alone, 101 | }, 102 | ), 103 | }, 104 | ) 105 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_tuple_fields_vis.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: Some( 9 | pub, 10 | ), 11 | tk_struct: Ident( 12 | struct, 13 | ), 14 | name: Ident( 15 | Hello, 16 | ), 17 | generic_params: None, 18 | where_clause: None, 19 | fields: Tuple( 20 | [ 21 | TupleField { 22 | attributes: [], 23 | vis_marker: Some( 24 | pub, 25 | ), 26 | ty: [ 27 | A, 28 | ], 29 | }, 30 | TupleField { 31 | attributes: [], 32 | vis_marker: Some( 33 | pub( 34 | super, 35 | ), 36 | ), 37 | ty: [ 38 | B, 39 | ], 40 | }, 41 | TupleField { 42 | attributes: [], 43 | vis_marker: Some( 44 | crate, 45 | ), 46 | ty: [ 47 | C, 48 | ], 49 | }, 50 | TupleField { 51 | attributes: [], 52 | vis_marker: None, 53 | ty: [ 54 | D, 55 | ], 56 | }, 57 | ], 58 | ), 59 | tk_semicolon: Some( 60 | Punct { 61 | char: ';', 62 | spacing: Alone, 63 | }, 64 | ), 65 | }, 66 | ) 67 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_tuple_struct.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_struct: Ident( 10 | struct, 11 | ), 12 | name: Ident( 13 | Hello, 14 | ), 15 | generic_params: None, 16 | where_clause: None, 17 | fields: Tuple( 18 | [ 19 | TupleField { 20 | attributes: [], 21 | vis_marker: None, 22 | ty: [ 23 | A, 24 | ], 25 | }, 26 | TupleField { 27 | attributes: [], 28 | vis_marker: None, 29 | ty: [ 30 | B, 31 | ], 32 | }, 33 | ], 34 | ), 35 | tk_semicolon: Some( 36 | Punct { 37 | char: ';', 38 | spacing: Alone, 39 | }, 40 | ), 41 | }, 42 | ) 43 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_tuple_struct_attributes.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [ 8 | Attribute { 9 | tk_hash: Punct { 10 | char: '#', 11 | spacing: Alone, 12 | }, 13 | tk_brackets: [], 14 | path: [ 15 | hello, 16 | ], 17 | value: Empty, 18 | }, 19 | ], 20 | vis_marker: Some( 21 | pub, 22 | ), 23 | tk_struct: Ident( 24 | struct, 25 | ), 26 | name: Ident( 27 | Hello, 28 | ), 29 | generic_params: None, 30 | where_clause: None, 31 | fields: Tuple( 32 | [ 33 | TupleField { 34 | attributes: [], 35 | vis_marker: None, 36 | ty: [ 37 | A, 38 | ], 39 | }, 40 | TupleField { 41 | attributes: [], 42 | vis_marker: None, 43 | ty: [ 44 | B, 45 | ], 46 | }, 47 | ], 48 | ), 49 | tk_semicolon: Some( 50 | Punct { 51 | char: ';', 52 | spacing: Alone, 53 | }, 54 | ), 55 | }, 56 | ) 57 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_tuple_struct_empty_where_clause.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_struct: Ident( 10 | struct, 11 | ), 12 | name: Ident( 13 | Hello, 14 | ), 15 | generic_params: None, 16 | where_clause: Some( 17 | [], 18 | ), 19 | fields: Tuple( 20 | [ 21 | TupleField { 22 | attributes: [], 23 | vis_marker: None, 24 | ty: [ 25 | A, 26 | ], 27 | }, 28 | TupleField { 29 | attributes: [], 30 | vis_marker: None, 31 | ty: [ 32 | B, 33 | ], 34 | }, 35 | ], 36 | ), 37 | tk_semicolon: Some( 38 | Punct { 39 | char: ';', 40 | spacing: Alone, 41 | }, 42 | ), 43 | }, 44 | ) 45 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_tuple_struct_generic_params.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_struct: Ident( 10 | struct, 11 | ), 12 | name: Ident( 13 | Hello, 14 | ), 15 | generic_params: Some( 16 | [ 17 | GenericParam { 18 | name: "X", 19 | bound: None, 20 | }, 21 | GenericParam { 22 | name: "Y", 23 | bound: Some( 24 | [ 25 | Z, 26 | "<", 27 | A, 28 | ">", 29 | ], 30 | ), 31 | }, 32 | GenericParam { 33 | name: "Z", 34 | bound: None, 35 | }, 36 | ], 37 | ), 38 | where_clause: None, 39 | fields: Tuple( 40 | [ 41 | TupleField { 42 | attributes: [], 43 | vis_marker: None, 44 | ty: [ 45 | A, 46 | ], 47 | }, 48 | TupleField { 49 | attributes: [], 50 | vis_marker: None, 51 | ty: [ 52 | B, 53 | ], 54 | }, 55 | ], 56 | ), 57 | tk_semicolon: Some( 58 | Punct { 59 | char: ';', 60 | spacing: Alone, 61 | }, 62 | ), 63 | }, 64 | ) 65 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_tuple_struct_vis-2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type_pub_crate 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: Some( 9 | pub( 10 | crate, 11 | ), 12 | ), 13 | tk_struct: Ident( 14 | struct, 15 | ), 16 | name: Ident( 17 | Hello, 18 | ), 19 | generic_params: None, 20 | where_clause: None, 21 | fields: Tuple( 22 | [ 23 | TupleField { 24 | attributes: [], 25 | vis_marker: None, 26 | ty: [ 27 | A, 28 | ], 29 | }, 30 | TupleField { 31 | attributes: [], 32 | vis_marker: None, 33 | ty: [ 34 | B, 35 | ], 36 | }, 37 | ], 38 | ), 39 | tk_semicolon: Some( 40 | Punct { 41 | char: ';', 42 | spacing: Alone, 43 | }, 44 | ), 45 | }, 46 | ) 47 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_tuple_struct_vis-3.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type_crate 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: Some( 9 | crate, 10 | ), 11 | tk_struct: Ident( 12 | struct, 13 | ), 14 | name: Ident( 15 | Hello, 16 | ), 17 | generic_params: None, 18 | where_clause: None, 19 | fields: Tuple( 20 | [ 21 | TupleField { 22 | attributes: [], 23 | vis_marker: None, 24 | ty: [ 25 | A, 26 | ], 27 | }, 28 | TupleField { 29 | attributes: [], 30 | vis_marker: None, 31 | ty: [ 32 | B, 33 | ], 34 | }, 35 | ], 36 | ), 37 | tk_semicolon: Some( 38 | Punct { 39 | char: ';', 40 | spacing: Alone, 41 | }, 42 | ), 43 | }, 44 | ) 45 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_tuple_struct_vis.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type_pub 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: Some( 9 | pub, 10 | ), 11 | tk_struct: Ident( 12 | struct, 13 | ), 14 | name: Ident( 15 | Hello, 16 | ), 17 | generic_params: None, 18 | where_clause: None, 19 | fields: Tuple( 20 | [ 21 | TupleField { 22 | attributes: [], 23 | vis_marker: None, 24 | ty: [ 25 | A, 26 | ], 27 | }, 28 | TupleField { 29 | attributes: [], 30 | vis_marker: None, 31 | ty: [ 32 | B, 33 | ], 34 | }, 35 | ], 36 | ), 37 | tk_semicolon: Some( 38 | Punct { 39 | char: ';', 40 | spacing: Alone, 41 | }, 42 | ), 43 | }, 44 | ) 45 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_tuple_struct_where_clause.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_struct: Ident( 10 | struct, 11 | ), 12 | name: Ident( 13 | Hello, 14 | ), 15 | generic_params: None, 16 | where_clause: Some( 17 | [ 18 | [ 19 | A, 20 | ":", 21 | B, 22 | ], 23 | [ 24 | C, 25 | "<", 26 | D, 27 | ">", 28 | ":", 29 | E, 30 | "<", 31 | F, 32 | ">", 33 | ], 34 | ], 35 | ), 36 | fields: Tuple( 37 | [ 38 | TupleField { 39 | attributes: [], 40 | vis_marker: None, 41 | ty: [ 42 | A, 43 | ], 44 | }, 45 | TupleField { 46 | attributes: [], 47 | vis_marker: None, 48 | ty: [ 49 | B, 50 | ], 51 | }, 52 | ], 53 | ), 54 | tk_semicolon: Some( 55 | Punct { 56 | char: ';', 57 | spacing: Alone, 58 | }, 59 | ), 60 | }, 61 | ) 62 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_type_complex.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: ty_decl 4 | --- 5 | TypeAlias( 6 | TypeAlias { 7 | attributes: [ 8 | Attribute { 9 | tk_hash: Punct { 10 | char: '#', 11 | spacing: Alone, 12 | }, 13 | tk_brackets: [], 14 | path: [ 15 | attribute, 16 | ], 17 | value: Empty, 18 | }, 19 | ], 20 | vis_marker: Some( 21 | pub( 22 | crate, 23 | ), 24 | ), 25 | tk_type: Ident( 26 | type, 27 | ), 28 | name: Ident( 29 | MyType, 30 | ), 31 | bound: None, 32 | tk_equals: Some( 33 | Punct { 34 | char: '=', 35 | spacing: Alone, 36 | }, 37 | ), 38 | initializer_ty: Some( 39 | [ 40 | some, 41 | ":", 42 | ":", 43 | module, 44 | ":", 45 | ":", 46 | OtherType, 47 | "<", 48 | i32, 49 | ",", 50 | 10, 51 | ">", 52 | ":", 53 | ":", 54 | AssocType, 55 | "<", 56 | Item, 57 | "=", 58 | char, 59 | ">", 60 | ], 61 | ), 62 | tk_semicolon: Punct { 63 | char: ';', 64 | spacing: Alone, 65 | }, 66 | }, 67 | ) 68 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_type_simple.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: ty_decl 4 | --- 5 | TypeAlias( 6 | TypeAlias { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_type: Ident( 10 | type, 11 | ), 12 | name: Ident( 13 | MyType, 14 | ), 15 | bound: None, 16 | tk_equals: Some( 17 | Punct { 18 | char: '=', 19 | spacing: Alone, 20 | }, 21 | ), 22 | initializer_ty: Some( 23 | [ 24 | std, 25 | ":", 26 | ":", 27 | string, 28 | ":", 29 | ":", 30 | String, 31 | ], 32 | ), 33 | tk_semicolon: Punct { 34 | char: ';', 35 | spacing: Alone, 36 | }, 37 | }, 38 | ) 39 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_union.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: union_type 4 | --- 5 | Union( 6 | Union { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_union: Ident( 10 | union, 11 | ), 12 | name: Ident( 13 | Hello, 14 | ), 15 | generic_params: None, 16 | where_clauses: None, 17 | fields: [ 18 | NamedField { 19 | attributes: [], 20 | vis_marker: None, 21 | name: Ident( 22 | a, 23 | ), 24 | tk_colon: Punct { 25 | char: ':', 26 | spacing: Alone, 27 | }, 28 | ty: [ 29 | A, 30 | ], 31 | }, 32 | NamedField { 33 | attributes: [], 34 | vis_marker: None, 35 | name: Ident( 36 | b, 37 | ), 38 | tk_colon: Punct { 39 | char: ':', 40 | spacing: Alone, 41 | }, 42 | ty: [ 43 | B, 44 | ], 45 | }, 46 | ], 47 | }, 48 | ) 49 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_unit_struct.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_struct: Ident( 10 | struct, 11 | ), 12 | name: Ident( 13 | Hello, 14 | ), 15 | generic_params: None, 16 | where_clause: None, 17 | fields: Unit, 18 | tk_semicolon: Some( 19 | Punct { 20 | char: ';', 21 | spacing: Alone, 22 | }, 23 | ), 24 | }, 25 | ) 26 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_unit_struct_attributes.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [ 8 | Attribute { 9 | tk_hash: Punct { 10 | char: '#', 11 | spacing: Alone, 12 | }, 13 | tk_brackets: [], 14 | path: [ 15 | hello, 16 | ], 17 | value: Empty, 18 | }, 19 | ], 20 | vis_marker: Some( 21 | pub, 22 | ), 23 | tk_struct: Ident( 24 | struct, 25 | ), 26 | name: Ident( 27 | Hello, 28 | ), 29 | generic_params: None, 30 | where_clause: None, 31 | fields: Unit, 32 | tk_semicolon: Some( 33 | Punct { 34 | char: ';', 35 | spacing: Alone, 36 | }, 37 | ), 38 | }, 39 | ) 40 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_unit_struct_empty_where_clause.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_struct: Ident( 10 | struct, 11 | ), 12 | name: Ident( 13 | Hello, 14 | ), 15 | generic_params: None, 16 | where_clause: Some( 17 | [], 18 | ), 19 | fields: Unit, 20 | tk_semicolon: Some( 21 | Punct { 22 | char: ';', 23 | spacing: Alone, 24 | }, 25 | ), 26 | }, 27 | ) 28 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_unit_struct_generic_params.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_struct: Ident( 10 | struct, 11 | ), 12 | name: Ident( 13 | Hello, 14 | ), 15 | generic_params: Some( 16 | [ 17 | GenericParam { 18 | name: "X", 19 | bound: None, 20 | }, 21 | GenericParam { 22 | name: "Y", 23 | bound: Some( 24 | [ 25 | Z, 26 | "<", 27 | A, 28 | ">", 29 | ], 30 | ), 31 | }, 32 | GenericParam { 33 | name: "Z", 34 | bound: None, 35 | }, 36 | ], 37 | ), 38 | where_clause: None, 39 | fields: Unit, 40 | tk_semicolon: Some( 41 | Punct { 42 | char: ';', 43 | spacing: Alone, 44 | }, 45 | ), 46 | }, 47 | ) 48 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_unit_struct_vis-2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type_pub_crate 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: Some( 9 | pub( 10 | crate, 11 | ), 12 | ), 13 | tk_struct: Ident( 14 | struct, 15 | ), 16 | name: Ident( 17 | Hello, 18 | ), 19 | generic_params: None, 20 | where_clause: None, 21 | fields: Unit, 22 | tk_semicolon: Some( 23 | Punct { 24 | char: ';', 25 | spacing: Alone, 26 | }, 27 | ), 28 | }, 29 | ) 30 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_unit_struct_vis-3.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type_crate 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: Some( 9 | crate, 10 | ), 11 | tk_struct: Ident( 12 | struct, 13 | ), 14 | name: Ident( 15 | Hello, 16 | ), 17 | generic_params: None, 18 | where_clause: None, 19 | fields: Unit, 20 | tk_semicolon: Some( 21 | Punct { 22 | char: ';', 23 | spacing: Alone, 24 | }, 25 | ), 26 | }, 27 | ) 28 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_unit_struct_vis.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type_pub 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: Some( 9 | pub, 10 | ), 11 | tk_struct: Ident( 12 | struct, 13 | ), 14 | name: Ident( 15 | Hello, 16 | ), 17 | generic_params: None, 18 | where_clause: None, 19 | fields: Unit, 20 | tk_semicolon: Some( 21 | Punct { 22 | char: ';', 23 | spacing: Alone, 24 | }, 25 | ), 26 | }, 27 | ) 28 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_unit_struct_where_clause.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: struct_type 4 | --- 5 | Struct( 6 | Struct { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_struct: Ident( 10 | struct, 11 | ), 12 | name: Ident( 13 | Hello, 14 | ), 15 | generic_params: None, 16 | where_clause: Some( 17 | [ 18 | [ 19 | A, 20 | ":", 21 | B, 22 | ], 23 | [ 24 | C, 25 | "<", 26 | D, 27 | ">", 28 | ":", 29 | E, 30 | "<", 31 | F, 32 | ">", 33 | ], 34 | ], 35 | ), 36 | fields: Unit, 37 | tk_semicolon: Some( 38 | Punct { 39 | char: ';', 40 | spacing: Alone, 41 | }, 42 | ), 43 | }, 44 | ) 45 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_unsafe_extern_block.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: unsafe_extern 4 | --- 5 | ExternBlock( 6 | ExternBlock { 7 | attributes: [], 8 | vis_marker: None, 9 | tk_unsafe: Some( 10 | Ident( 11 | unsafe, 12 | ), 13 | ), 14 | tk_extern: Ident( 15 | extern, 16 | ), 17 | extern_abi: None, 18 | tk_braces: {}, 19 | inner_attributes: [], 20 | body_items: [], 21 | }, 22 | ) 23 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_unsafe_fn.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: func 4 | --- 5 | Function( 6 | Function { 7 | attributes: [], 8 | vis_marker: Some( 9 | pub, 10 | ), 11 | qualifiers: FnQualifiers { 12 | tk_default: None, 13 | tk_const: None, 14 | tk_async: None, 15 | tk_unsafe: Some( 16 | Ident( 17 | unsafe, 18 | ), 19 | ), 20 | tk_extern: None, 21 | extern_abi: None, 22 | }, 23 | tk_fn_keyword: Ident( 24 | fn, 25 | ), 26 | name: Ident( 27 | unsafe_fn, 28 | ), 29 | generic_params: None, 30 | tk_params_parens: (), 31 | params: [ 32 | Typed( 33 | FnTypedParam { 34 | attributes: [], 35 | tk_mut: None, 36 | name: Ident( 37 | b, 38 | ), 39 | tk_colon: Punct { 40 | char: ':', 41 | spacing: Alone, 42 | }, 43 | ty: [ 44 | f32, 45 | ], 46 | }, 47 | ), 48 | ], 49 | where_clause: None, 50 | tk_return_arrow: None, 51 | return_ty: None, 52 | tk_semicolon: None, 53 | body: Some( 54 | Group { 55 | delimiter: Brace, 56 | stream: TokenStream [], 57 | }, 58 | ), 59 | }, 60 | ) 61 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_visi_fn.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: func 4 | --- 5 | Function( 6 | Function { 7 | attributes: [], 8 | vis_marker: Some( 9 | pub, 10 | ), 11 | qualifiers: FnQualifiers { 12 | tk_default: None, 13 | tk_const: None, 14 | tk_async: None, 15 | tk_unsafe: None, 16 | tk_extern: None, 17 | extern_abi: None, 18 | }, 19 | tk_fn_keyword: Ident( 20 | fn, 21 | ), 22 | name: Ident( 23 | visibility, 24 | ), 25 | generic_params: None, 26 | tk_params_parens: (), 27 | params: [ 28 | Typed( 29 | FnTypedParam { 30 | attributes: [], 31 | tk_mut: None, 32 | name: Ident( 33 | b, 34 | ), 35 | tk_colon: Punct { 36 | char: ':', 37 | spacing: Alone, 38 | }, 39 | ty: [ 40 | f32, 41 | ], 42 | }, 43 | ), 44 | ], 45 | where_clause: None, 46 | tk_return_arrow: None, 47 | return_ty: None, 48 | tk_semicolon: None, 49 | body: Some( 50 | Group { 51 | delimiter: Brace, 52 | stream: TokenStream [], 53 | }, 54 | ), 55 | }, 56 | ) 57 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_where_fn-2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: func_2 4 | --- 5 | Function( 6 | Function { 7 | attributes: [], 8 | vis_marker: None, 9 | qualifiers: FnQualifiers { 10 | tk_default: None, 11 | tk_const: None, 12 | tk_async: None, 13 | tk_unsafe: None, 14 | tk_extern: None, 15 | extern_abi: None, 16 | }, 17 | tk_fn_keyword: Ident( 18 | fn, 19 | ), 20 | name: Ident( 21 | where_clause, 22 | ), 23 | generic_params: Some( 24 | [ 25 | GenericParam { 26 | name: "T", 27 | bound: None, 28 | }, 29 | ], 30 | ), 31 | tk_params_parens: (), 32 | params: [], 33 | where_clause: Some( 34 | [ 35 | [ 36 | T, 37 | ":", 38 | Debug, 39 | ], 40 | ], 41 | ), 42 | tk_return_arrow: None, 43 | return_ty: None, 44 | tk_semicolon: None, 45 | body: Some( 46 | Group { 47 | delimiter: Brace, 48 | stream: TokenStream [], 49 | }, 50 | ), 51 | }, 52 | ) 53 | -------------------------------------------------------------------------------- /src/snapshots/venial__tests__parse_where_fn.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests.rs 3 | expression: func 4 | --- 5 | Function( 6 | Function { 7 | attributes: [], 8 | vis_marker: None, 9 | qualifiers: FnQualifiers { 10 | tk_default: None, 11 | tk_const: None, 12 | tk_async: None, 13 | tk_unsafe: None, 14 | tk_extern: None, 15 | extern_abi: None, 16 | }, 17 | tk_fn_keyword: Ident( 18 | fn, 19 | ), 20 | name: Ident( 21 | where_clause, 22 | ), 23 | generic_params: Some( 24 | [ 25 | GenericParam { 26 | name: "T", 27 | bound: None, 28 | }, 29 | ], 30 | ), 31 | tk_params_parens: (), 32 | params: [], 33 | where_clause: Some( 34 | [ 35 | [ 36 | T, 37 | ":", 38 | Debug, 39 | ], 40 | ], 41 | ), 42 | tk_return_arrow: Some( 43 | [ 44 | Punct { 45 | char: '-', 46 | spacing: Joint, 47 | }, 48 | Punct { 49 | char: '>', 50 | spacing: Alone, 51 | }, 52 | ], 53 | ), 54 | return_ty: Some( 55 | [ 56 | T, 57 | ], 58 | ), 59 | tk_semicolon: None, 60 | body: Some( 61 | Group { 62 | delimiter: Brace, 63 | stream: TokenStream [], 64 | }, 65 | ), 66 | }, 67 | ) 68 | --------------------------------------------------------------------------------